// Metro module 8650 (f8651).
import { memo, useCallback } from "react";
import { ActivityIndicator, Image as Image2, Pressable, ScrollView, View } from "react-native";
import { getParser } from "../../../markup/CustomMarkup.native";
import { intl, t } from "../../../../intl/index.native";
import { createStyles } from "../../../../design/components/Styles/native/createStyles";
import Module712 from "../../../../_bundle/Module712";
import { getPosterUrl, getPollExpiryLabel } from "../../AnnouncementMessageUtils";
import { Text } from "../../../../design/components/Text/native/Text";
import { ImageWithPlaceholder } from "../../../../components_native/common/ImageWithPlaceholder";
import { dateFormat } from "../../../../utils/DateUtils";
import { ReactionIcon } from "../../../../design/components/Icon/native/redesign/generated/ReactionIcon";
import useAnalyticsLocations from "../../../app_analytics/useAnalyticsLocations";
import useGameAnnouncements from "../../hooks/useGameAnnouncements";
import { GameProfileTrackActionActions } from "../../GameProfileAnalyticUtils";
import GameProfileActionCreators_native from "../../GameProfileActionCreators.native";
import navigateToGameAnnouncement from "../../navigateToGameAnnouncement";
import { Button } from "../../../../design/components/Button/native/Button.native";
import { ChevronSmallRightIcon } from "../../../../design/components/Icon/native/redesign/generated/ChevronSmallRightIcon";
let c5627_12, parser, c5627_14, useStyles, MessageAnnouncementCard, PollAnnouncementCard, Component;
const EmbedAnnouncementCard = function EmbedAnnouncementCard(props) {
const { message, onPress: onPress2, guildId: guildId2, channelId: channelId2 } = props;
const styles2 = useStyles();
if (parser == null) {
parser = getParser();
}
const r23 = parser;
let r43 = message.media?.proxyUrl;
if (r43 == null) {
r43 = message.media?.url;
}
let uri = r43 != null ? getPosterUrl(r43, 160, c5627_12) : null;
if (uri == null) {
uri = r43;
}
const embedSource = message.embedSource;
if (embedSource == null) {
return null;
}
const r14 = embedSource.color != null ? {
borderLeftColor: embedSource.color
} : void 0;
const props2 = {
style: styles2.card,
onPress: () => onPress2(message.id),
accessibilityRole: "button",
accessibilityLabel: message.title,
children: null
};
const r70 = [embedSource.url != null && {embedSource.url}, ,];
const r90 = [embedSource.authorName != null &&
{embedSource.authorIconUrl != null && }
{embedSource.authorName}
, message.media != null && uri != null &&
, message.title != null &&
{r23(message.title, true, {
guildId: guildId2,
channelId: channelId2
})}
, message.body.length > 0 &&
{r23(message.body, true, {
guildId: guildId2,
channelId: channelId2
})}
, ,];
const r142 = [embedSource.providerIconUrl != null && ,
{embedSource.providerName != null ? `${embedSource.providerName} ยท ` : ""}
{dateFormat(new Date(message.timestamp), "LL")}
, ,];
let r169 = message.reactionCount > 0;
if (r169) {
const r182 = [, ,];
const reactionCount = message.reactionCount;
if (!(c5627_14 != null && c5627_14.locale === intl.currentLocale)) {
c5627_14 = {
locale: intl.currentLocale,
format: new Intl.NumberFormat(intl.currentLocale)
};
}
r182[1] =
{c5627_14.format.format(reactionCount)}
;
r169 = {r182};
}
r142[2] = r169;
r90[4] = {r142};
r70[1] = {r90};
props2.children = {r70};
return ;
};
MessageAnnouncementCard = function MessageAnnouncementCard(props) {
const { message: message2, onPress: onPress3, guildId: guildId2, channelId: channelId2 } = props;
const styles2 = useStyles();
if (parser == null) {
parser = getParser();
}
const r20 = parser;
let r39 = message2.media?.proxyUrl;
if (r39 == null) {
r39 = message2.media?.url;
}
let uri = r39 != null ? getPosterUrl(r39, 160, c5627_12) : null;
if (uri == null) {
uri = r39;
}
const props2 = {
style: styles2.card,
onPress: () => onPress3(message2.id),
accessibilityRole: "button",
accessibilityLabel: message2.title,
children: null
};
const children = [message2.media != null && uri != null &&
, ,];
const r83 = [message2.title != null &&
{r20(message2.title, true, {
guildId: guildId2,
channelId: channelId2
})}
, message2.body.length > 0 &&
{r20(message2.body, true, {
guildId: guildId2,
channelId: channelId2
})}
, ,];
const r115 = [
{dateFormat(new Date(message2.timestamp), "LL")}
, ,];
let r117 = message2.reactionCount > 0;
if (r117) {
const r130 = [, ,];
const reactionCount = message2.reactionCount;
if (!(c5627_14 != null && c5627_14.locale === intl.currentLocale)) {
c5627_14 = {
locale: intl.currentLocale,
format: new Intl.NumberFormat(intl.currentLocale)
};
}
r130[1] =
{c5627_14.format.format(reactionCount)}
;
r117 = {r130};
}
r115[1] = r117;
r83[2] = {r115};
children[1] = {r83};
props2.children = children;
return ;
};
PollAnnouncementCard = function PollAnnouncementCard(props) {
const { message: message3, onPress: onPress4 } = props;
const styles = useStyles();
const poll = message3.poll;
if (poll == null) {
return null;
}
const r15 = poll.answers.slice(0, 3);
const count = poll.answers.length - r15.length;
return onPress4(message3.id)} accessibilityRole="button" accessibilityLabel={poll.question.text}>
{poll.question.text}
{r15.map((item) => {
let text = item.poll_media.text;
if (text == null) {
text = "";
}
return
{text}
;
})}
{count > 0 &&
{intl.format(t["mv/nIa"], {
count
})}
}
{intl.format(t.t0FTsH, {
createdAt: new Date(message3.timestamp),
expiryLabel: getPollExpiryLabel(poll)
})}
;
};
c5627_12 = 120;
parser = null;
c5627_14 = null;
useStyles = createStyles({
container: {
gap: Module712.space.PX_8
},
smallCardsScroller: {
marginHorizontal: -Module712.space.PX_16,
overflow: "visible"
},
smallCardsContainer: {
flexDirection: "row",
gap: Module712.space.PX_12,
paddingHorizontal: Module712.space.PX_16
},
sectionHeader: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
paddingHorizontal: Module712.space.PX_8
},
loadingContainer: {
height: 120,
alignItems: "center",
justifyContent: "center"
},
card: {
flexDirection: "column",
borderRadius: Module712.radii.lg,
overflow: "hidden",
backgroundColor: Module712.colors.BACKGROUND_BASE_LOW,
borderWidth: 1,
borderColor: Module712.colors.BORDER_SUBTLE,
width: 160
},
cardBody: {
flex: 1,
flexDirection: "column",
gap: Module712.space.PX_4,
overflow: "hidden",
padding: Module712.space.PX_12
},
smallCardMedia: {
height: 120,
overflow: "hidden",
flexShrink: 0
},
mediaImage: {
width: "100%",
height: "100%",
resizeMode: "cover"
},
metadataRow: {
flexDirection: "row",
alignItems: "center",
gap: Module712.space.PX_8,
marginTop: "auto"
},
reactionInfo: {
flexDirection: "row",
alignItems: "center",
gap: Module712.space.PX_4
},
embedContentArea: {
flex: 1,
gap: Module712.space.PX_4,
borderLeftWidth: 4,
borderLeftColor: Module712.colors.BORDER_SUBTLE,
borderTopLeftRadius: Module712.radii.xs,
borderBottomLeftRadius: Module712.radii.xs,
paddingLeft: Module712.space.PX_8
},
embedAuthorRow: {
flexDirection: "row",
alignItems: "center",
gap: Module712.space.PX_4
},
embedAuthorIcon: {
width: 20,
height: 20,
borderRadius: Module712.radii.round
},
embedProviderIcon: {
width: 16,
height: 16
},
embedMedia: {
overflow: "hidden",
borderRadius: Module712.radii.sm,
aspectRatio: 1.7777777777777777
},
pollAnswers: {
flexDirection: "column",
gap: Module712.space.PX_4,
flex: 1
},
pollAnswerOption: {
paddingVertical: Module712.space.PX_8,
paddingHorizontal: Module712.space.PX_12,
borderRadius: Module712.radii.sm,
backgroundColor: Module712.colors.BACKGROUND_BASE_LOWEST
},
pollMoreOptions: {
paddingHorizontal: Module712.space.PX_12
}
});
Component = memo(function(a0) {
return a0.message.poll != null ? : a0.message.embedSource != null ? : ;
});
export default function GameProfileAnnouncements(props) {
let callback;
const { gameId, invite, closeModal, trackAction, scrollOffsetRef } = props;
callback = void 0;
const styles2 = useStyles();
const analyticsLocations = useAnalyticsLocations().analyticsLocations;
const gameAnnouncements = useGameAnnouncements(gameId, 10);
const { messages, channelId, guildId, loading } = gameAnnouncements;
const callback2 = useCallback(() => {
let guildId2 = invite == null ? void 0 : invite.guild?.id;
if (guildId2 == null) {
guildId2 = guildId;
}
if (guildId2 != null && channelId != null) {
trackAction(GameProfileTrackActionActions.Announcements);
GameProfileActionCreators_native.setGameProfilePendingReturn({
gameId,
channelId,
initialScrollOffset: scrollOffsetRef.current
});
closeModal();
navigateToGameAnnouncement({
invite,
guildId: guildId2,
channelId,
analyticsLocationStack: analyticsLocations
});
}
}, [trackAction, closeModal, invite, guildId, channelId, analyticsLocations, gameId, scrollOffsetRef]);
callback = useCallback((a0) => {
let guildId2 = invite == null ? void 0 : invite.guild?.id;
if (guildId2 == null) {
guildId2 = guildId;
}
if (guildId2 != null && channelId != null) {
trackAction(GameProfileTrackActionActions.AnnouncementsItem);
GameProfileActionCreators_native.setGameProfilePendingReturn({
gameId,
channelId,
initialScrollOffset: scrollOffsetRef.current
});
closeModal();
navigateToGameAnnouncement({
invite,
guildId: guildId2,
channelId,
messageId: a0,
analyticsLocationStack: analyticsLocations
});
}
}, [trackAction, closeModal, invite, guildId, channelId, analyticsLocations, gameId, scrollOffsetRef]);
return loading ?
{intl.string(t.B0BV3Y)}
: channelId == null ? null : messages.length !== 0 ?
{intl.string(t.B0BV3Y)}
} iconPosition="end" onPress={callback2} />
{messages.map((a0) => )}
: null;
};