// Metro module 8117 (f8118). import { useMemo } from "react"; import { NativeModules } from "react-native"; import { MessageAttachmentFlags, WEBP_RE_IOS } from "../../../Constants"; import * as _MediaFormatTesters from "../../messages/MediaFormatTesters"; import { isImageFile, isWebPlayerVideoUrl, urlMatchesFileExtension } from "../../messages/MediaFormatTesters"; import { hasFlag } from "../../../_bundle/Module1384"; import * as _ObscuredMediaUtils from "../../explicit_media_redaction/ObscuredMediaUtils"; import { getEnabledHarmTypesForMessage, getMediaObscuredReasonFromBitmask } from "../../explicit_media_redaction/ObscuredMediaUtils"; import { ObscuredMediaTypes } from "../../explicit_media_redaction/ExplicitMediaRedactionModels"; import ImageUtils from "../../../utils/native/ImageUtils"; import getDisplayFilename from "../../messages/getDisplayFilename"; import renderMessageMarkup from "../../messages/renderMessageMarkup"; import * as _EmbedUtils from "../../../utils/EmbedUtils"; import { getEffectiveVideoProvider } from "../../../utils/EmbedUtils"; import * as _EmbedUtils2 from "../../messages/native/renderer/EmbedUtils"; import { flattenComponents } from "../../interaction_components/InteractionComponentUtils"; import { ComponentType } from "../../../flow/Server"; import { getUnfurledMediaItemType } from "../../messages/native/renderer/transformMessageComponents"; import { MediaGalleryItemType } from "../../messages/native/renderer/RowGeneratorTypes"; import { isNotNullish } from "../../../utils/GlobalUtils"; import useStateFromSharedValue from "../../reanimated/native/useStateFromSharedValue"; import { GIF_RE_IOS } from "../../../ConstantsIOS"; import AlertActionCreators from "../../../actions/native/AlertActionCreators"; import { intl, t } from "../../../intl/index.native"; import { isPortalExpired } from "../../../components_native/common/NativePortalView"; function $mk79875($env) { return () => { const r4 = $env[0]; const r5 = $env.$parent; const r2 = r5[0]; const r6 = r5[2]; if (r2(r6[18]).MediaType.IMAGE === r4) { r2(r6[19]).presentImageSaved(); } else if (r2(r6[18]).MediaType.GIF === r4) { r2(r6[19]).presentGifSaved(); } else if (r2(r6[18]).MediaType.VIDEO === r4) { r2(r6[19]).presentVideoSaved(); } r2(r6[20]).MediaViewerAnalytics.trackMediaViewerDownloadButtonTapped(); }; } let extractMediaFromAttachment, extractMediaFromEmbed, toMediaSourceFromUnfurledMedia, handleDownloadError, c5153_7, c5153_13; let env5153 = {}; export function isValidImageAttachment(a0) { if (a0 == null) { return false; } const { filename, height, width } = a0; return isImageFile(filename) && height != null && height > 0 && width != null && width > 0 && !(a0 != null && (a0.flags != null && hasFlag(a0.flags, MessageAttachmentFlags.IS_THUMBNAIL))); } extractMediaFromAttachment = function extractMediaFromAttachment(a0, a1, a2, a3, a4) { if (a0.width != null && !(a0.width <= 0) && a0.height != null && !(a0.height <= 0)) { const isMediaObscuredForHarmTypes = _ObscuredMediaUtils.isMediaObscuredForHarmTypes({ type: ObscuredMediaTypes.Attachment, media: a0 }, getEnabledHarmTypesForMessage(a1)); const isVideoFile = _MediaFormatTesters.isVideoFile(a0.filename); const videoURI = a0.proxy_url != null && a0.proxy_url !== "" ? a0.proxy_url : a0.url; const mobileOptimizedSrc = ImageUtils.getMobileOptimizedSrc(videoURI, a0.width, a0.height, isVideoFile ? "png" : void 0); if (isVideoFile) { const r143 = { uri: mobileOptimizedSrc, messageId: a1.id, guildId: a3, channelId: a1.channel_id, videoURI, filename: getDisplayFilename(a0), mediaIndex: a2, width: a0.width, height: a0.height, sourceURI: videoURI, contentType: a0.content_type, description: a0.description, accessoryType: "attachment", spoiler: null, flags: null, obscure: null, placeholder: null, contentScanVersion: null, mediaViewIndex: null, attachmentId: null }; let flags3 = a0.flags; if (flags3 == null) { flags3 = 0; } r143.spoiler = hasFlag(flags3, MessageAttachmentFlags.IS_SPOILER); r143.flags = a0.flags; r143.obscure = isMediaObscuredForHarmTypes; r143.placeholder = a0.placeholder; r143.contentScanVersion = a0.content_scan_version; r143.mediaViewIndex = a4; r143.attachmentId = a0.id; return r143; } const r54 = { uri: mobileOptimizedSrc, messageId: a1.id, guildId: a3, channelId: a1.channel_id, filename: getDisplayFilename(a0), mediaIndex: a2, width: a0.width, height: a0.height, sourceURI: a0.url, contentType: a0.content_type, description: a0.description, accessoryType: "attachment", spoiler: null, flags: null, obscure: null, placeholder: null, contentScanVersion: null, mediaViewIndex: null, attachmentId: null }; let flags = a0.flags; if (flags == null) { flags = 0; } r54.spoiler = hasFlag(flags, MessageAttachmentFlags.IS_SPOILER); r54.flags = a0.flags; r54.obscure = isMediaObscuredForHarmTypes; r54.placeholder = a0.placeholder; r54.contentScanVersion = a0.content_scan_version; r54.mediaViewIndex = a4; r54.attachmentId = a0.id; const r74 = { ...r54, uri: videoURI }; const r85 = getDisplayFilename(a0).toLowerCase().endsWith(".webp"); const r92 = getDisplayFilename(a0).toLowerCase().endsWith(".avif"); let flags2 = a0.flags; if (flags2 == null) { flags2 = 0; } L18: { if (hasFlag(flags2, MessageAttachmentFlags.IS_ANIMATED)) { if (!r85 && !r92) { break L18; } const uRL2 = new URL(videoURI); uRL2.searchParams.append("animated", "true"); if (r92) { uRL2.searchParams.append("format", "webp"); } return [r54, { ...r74, uri: uRL2.toString() }]; } } if (r92) { const uRL = new URL(videoURI); uRL.searchParams.append("format", "webp"); return [r54, { ...r74, uri: uRL.toString() }]; } return videoURI !== mobileOptimizedSrc ? [r54, r74] : r74; } }; extractMediaFromEmbed = function extractMediaFromEmbed(a0, a1, a2, a3, a4) { let r34, r204, contentType, contentType2, contentType3, contentType4, embedURI, type, uri; let image = a0.image; if (image == null) { image = a0.video; } if (image == null) { image = a0.thumbnail; } if (image != null) { const r2 = a0.video != null; let videoURI = void 0; if (r2) { L16: { const video = a0.video; const { proxyURL, url, srcIsAnimated } = video; r34 = url; if (proxyURL != null) { r34 = url; if (proxyURL !== "") { const uRL = new URL(proxyURL); const r43 = uRL.pathname.toLowerCase().endsWith(".avif"); const r48 = uRL.pathname.toLowerCase().endsWith(".webp"); if (srcIsAnimated) { if (!r48) { r34 = proxyURL; if (!r43) { break L16; } } uRL.searchParams.append("animated", "true"); if (r43) { uRL.searchParams.append("format", "webp"); } r34 = uRL.toString(); } else { r34 = proxyURL; if (r43) { uRL.searchParams.append("format", "webp"); r34 = uRL.toString(); } } } } } videoURI = r34; } L27: { type = a0.type; const { proxyURL: proxyURL3, url: url2, srcIsAnimated: srcIsAnimated3 } = image; uri = url2; if (proxyURL3 != null) { uri = url2; if (proxyURL3 !== "") { const uRL2 = new URL(proxyURL3); const r82 = uRL2.pathname.toLowerCase().endsWith(".avif"); const r88 = uRL2.pathname.toLowerCase().endsWith(".webp"); if (srcIsAnimated3) { if (!r88) { uri = proxyURL3; if (!r82) { break L27; } } uRL2.searchParams.append("animated", "true"); if (r82) { uRL2.searchParams.append("format", "webp"); } uri = uRL2.toString(); } else { uri = proxyURL3; if (r82) { uRL2.searchParams.append("format", "webp"); uri = uRL2.toString(); } } } } } const contentScanVersion = a0.contentScanVersion != null ? a0.contentScanVersion : a0.content_scan_version != null ? a0.content_scan_version : void 0; const mobileOptimizedSrc = ImageUtils.getMobileOptimizedSrc(uri, image.width, image.height); const hasSpoilerEmbeds2 = renderMessageMarkup(a1, { contentMessage: a2 }).hasSpoilerEmbeds; const isMediaObscuredForHarmTypes = _ObscuredMediaUtils.isMediaObscuredForHarmTypes({ type: ObscuredMediaTypes.Embed, media: a0 }, getEnabledHarmTypesForMessage(a1)); const isEmbedInline = _EmbedUtils.isEmbedInline({ ...a0, rawTitle: "title" in a0 ? a0.title : "rawTitle" in a0 ? a0.rawTitle : void 0 }); const effectiveVideoProvider = getEffectiveVideoProvider(a0.provider?.name, a0.video?.url); const shouldPlayVideoInline = _EmbedUtils2.shouldPlayVideoInline(effectiveVideoProvider); let r160 = shouldPlayVideoInline && a0.video != null; if (videoURI != null && !shouldPlayVideoInline) { const name = a0.provider?.name; if ("contentType" in image) { contentType = image.contentType; } else { const r181 = "content_type" in image; contentType = void 0; if (r181) { let content_type = image.content_type; if (content_type == null) { content_type = void 0; } contentType = content_type; } } return { uri: mobileOptimizedSrc, messageId: a1.id, guildId: a4, channelId: a1.channel_id, mediaIndex: a3, videoURI, embedURI: a0.url, width: image.width, height: image.height, isGIFV: type === "gifv", sourceURI: image.url, embedProviderName: name, accessoryType: "embed", noCarousel: !isEmbedInline, spoiler: hasSpoilerEmbeds2, flags: a0.flags, contentScanVersion, contentType, obscure: isMediaObscuredForHarmTypes, thumbnail: a0.thumbnail != null ? { width: a0.thumbnail.width, height: a0.thumbnail.height, uri: a0.thumbnail.url } : void 0 }; } L60: { if (a0.type !== "video") { if (!(a0.type !== "rich" && a0.type !== "article") && r160) { break L60; } if ("contentType" in image) { contentType4 = image.contentType; } else { const r349 = "content_type" in image; contentType4 = void 0; if (r349) { let content_type4 = image.content_type; if (content_type4 == null) { content_type4 = void 0; } contentType4 = content_type4; } } const r341 = { uri: mobileOptimizedSrc, messageId: a1.id, guildId: a4, channelId: a1.channel_id, mediaIndex: a3, width: image.width, height: image.height, sourceURI: image.url, accessoryType: "embed", noCarousel: !isEmbedInline, spoiler: hasSpoilerEmbeds2, flags: a0.flags, obscure: isMediaObscuredForHarmTypes, contentScanVersion, contentType: contentType4 }; const r352 = { ...r341, uri }; return uri !== mobileOptimizedSrc ? [r341, r352] : r352; } } const r200 = []; if (a0.thumbnail != null) { L71: { const thumbnail = a0.thumbnail; const { proxyURL: proxyURL2, url: url3, srcIsAnimated: srcIsAnimated2 } = thumbnail; r204 = url3; if (proxyURL2 != null) { r204 = url3; if (proxyURL2 !== "") { const uRL3 = new URL(proxyURL2); const r216 = uRL3.pathname.toLowerCase().endsWith(".avif"); const r221 = uRL3.pathname.toLowerCase().endsWith(".webp"); if (srcIsAnimated2) { if (!r221) { r204 = proxyURL2; if (!r216) { break L71; } } uRL3.searchParams.append("animated", "true"); if (r216) { uRL3.searchParams.append("format", "webp"); } r204 = uRL3.toString(); } else { r204 = proxyURL2; if (r216) { uRL3.searchParams.append("format", "webp"); r204 = uRL3.toString(); } } } } } const r247 = { uri: ImageUtils.getMobileOptimizedSrc(r204, a0.thumbnail.width, a0.thumbnail.height), guildId: a4, spoiler: hasSpoilerEmbeds2, flags: a0.flags, obscure: isMediaObscuredForHarmTypes, contentScanVersion, contentType: null, messageId: null, noCarousel: null, mediaIndex: null, accessoryType: "embed", channelId: null, sourceURI: null, width: null, height: null }; const thumbnail2 = a0.thumbnail; if ("contentType" in thumbnail2) { contentType2 = thumbnail2.contentType; } else { const r253 = "content_type" in thumbnail2; contentType2 = void 0; if (r253) { let content_type2 = thumbnail2.content_type; if (content_type2 == null) { content_type2 = void 0; } contentType2 = content_type2; } } r247.contentType = contentType2; r247.messageId = a1.id; r247.noCarousel = !isEmbedInline; r247.mediaIndex = a3; r247.channelId = a1.channel_id; r247.sourceURI = a0.thumbnail.url; r247.width = a0.thumbnail.width; r247.height = a0.thumbnail.height; r200.push(r247); } if (r160) { r160 = a0.video != null; } if (r160) { const r269 = { uri: mobileOptimizedSrc, guildId: a4, spoiler: hasSpoilerEmbeds2, flags: a0.flags, obscure: isMediaObscuredForHarmTypes, contentScanVersion, contentType: null, sourceURI: null, messageId: null, noCarousel: null, mediaIndex: null, accessoryType: "embed", width: null, height: null, channelId: null, embedURI: null, embedProviderName: null, disableDownload: true }; const video2 = a0.video; if ("contentType" in video2) { contentType3 = video2.contentType; } else { const r274 = "content_type" in video2; contentType3 = void 0; if (r274) { let content_type3 = video2.content_type; if (content_type3 == null) { content_type3 = void 0; } contentType3 = content_type3; } } L99: { r269.contentType = contentType3; r269.sourceURI = a0.url; r269.messageId = a1.id; r269.noCarousel = !isEmbedInline; r269.mediaIndex = a3; r269.width = a0.video.width; r269.height = a0.video.height; r269.channelId = a1.channel_id; const video3 = a0.video; const { proxyURL: proxyURL4, url: url4, srcIsAnimated: srcIsAnimated4 } = video3; embedURI = url4; if (proxyURL4 != null) { embedURI = url4; if (proxyURL4 !== "") { const uRL4 = new URL(proxyURL4); const r303 = uRL4.pathname.toLowerCase().endsWith(".avif"); const r309 = uRL4.pathname.toLowerCase().endsWith(".webp"); if (srcIsAnimated4) { if (!r309) { embedURI = proxyURL4; if (!r303) { break L99; } } uRL4.searchParams.append("animated", "true"); if (r303) { uRL4.searchParams.append("format", "webp"); } embedURI = uRL4.toString(); } else { embedURI = proxyURL4; if (r303) { uRL4.searchParams.append("format", "webp"); embedURI = uRL4.toString(); } } } } } r269.embedURI = embedURI; r269.embedProviderName = effectiveVideoProvider; r200.push(r269); } if (r200.length !== 0) { return r200.length === 1 ? r200[0] : r200.length === 2 ? [r200[0], r200[1]] : void 0; } } }; toMediaSourceFromUnfurledMedia = function toMediaSourceFromUnfurledMedia(a0, a1, a2, a3, a4) { const unfurledMediaItemType = getUnfurledMediaItemType(a2); if (unfurledMediaItemType === MediaGalleryItemType.VISUAL_PLACEHOLDER) { return null; } const VIDEO = MediaGalleryItemType.VIDEO; const proxyUrl = a2.proxyUrl; let width = a2.width; if (width == null) { width = 0; } let height = a2.height; if (height == null) { height = 0; } const r3 = unfurledMediaItemType === VIDEO; const mobileOptimizedSrc = ImageUtils.getMobileOptimizedSrc(proxyUrl, width, height, r3 ? "png" : void 0); const version = a2.contentScanMetadata?.version; const isMediaObscuredForHarmTypes = _ObscuredMediaUtils.isMediaObscuredForHarmTypes({ type: ObscuredMediaTypes.GenericMedia, media: a2 }, getEnabledHarmTypesForMessage(a0)); let width2 = a2.width; if (width2 == null) { width2 = 0; } let height2 = a2.height; if (height2 == null) { height2 = 0; } const r54 = { messageId: a0.id, guildId: a1, channelId: a0.channel_id, uri: mobileOptimizedSrc, sourceURI: a2.url, width: width2, height: height2, contentType: a2.contentType, description: a3, spoiler: a4, obscure: isMediaObscuredForHarmTypes, contentScanVersion: version, accessoryType: "component", mediaIndex: 0 }; const r61 = { ...r54 }; const proxyUrl2 = a2.proxyUrl; if (r3) { r61.videoURI = proxyUrl2; return r61; } r61.uri = proxyUrl2; return a2.proxyUrl !== mobileOptimizedSrc ? [{ ...r54 }, r61] : r61; }; handleDownloadError = function handleDownloadError() { AlertActionCreators.show({ title: intl.string(t.cV3alD), body: intl.string(t.r4Zjzv), isDismissable: true }); }; c5153_7 = /\.avif$/i; c5153_13 = { PORTAL: 0, 0: "PORTAL", TIKTOK_IFRAME: 1, 1: "TIKTOK_IFRAME", WEB_FILE_IFRAME: 2, 2: "WEB_FILE_IFRAME", DEFAULT: 3, 3: "DEFAULT" }; export function flattenSource(a0, a1) { return Array.isArray(a0) ? a1 ? a0[a0.length - 1] : a0[0] : a0; } export function isValidVideoAttachment(a0) { return a0 != null && (a0 != null && _MediaFormatTesters.isVideoFile(a0.filename) && a0.proxy_url != null); } export function isValidImageEmbed(a0) { return a0.image != null || a0.thumbnail != null; } export function isValidVideoEmbed(a0) { return a0.video != null; } export function isThumbnailAttachment(a0) { return a0 != null && (a0.flags != null && hasFlag(a0.flags, MessageAttachmentFlags.IS_THUMBNAIL)); } export function getAttachmentUrl(a0) { return a0.proxy_url != null && a0.proxy_url !== "" ? a0.proxy_url : a0.url; } export { extractMediaFromAttachment }; export function getEmbedUrl({ proxyURL, url, srcIsAnimated }) { if (proxyURL != null && proxyURL !== "") { L8: { const uRL = new URL(proxyURL); const r21 = uRL.pathname.toLowerCase().endsWith(".avif"); const r26 = uRL.pathname.toLowerCase().endsWith(".webp"); if (srcIsAnimated) { if (!r26 && !r21) { break L8; } uRL.searchParams.append("animated", "true"); if (r21) { uRL.searchParams.append("format", "webp"); } return uRL.toString(); } if (r21) { uRL.searchParams.append("format", "webp"); return uRL.toString(); } } return proxyURL; } return url; } export function getEmbedMedia(a0) { let image = a0.image; if (image == null) { image = a0.video; } if (image == null) { image = a0.thumbnail; } return image; } export { extractMediaFromEmbed }; export function extractMediaFromMessageComponents(a0, a1, a2) { if (a1.components.length === 0) { return []; } const r38 = []; const r45 = [...flattenComponents(a1.components).values()]; for (const item of r45) { const type = item.type; if (ComponentType.MEDIA_GALLERY === type) { for (const item2 of item.items) { const sources2 = toMediaSourceFromUnfurledMedia(a0, a2, item2.media, item2.description, item2.spoiler); if (sources2 != null) { r38.push({ sources: sources2, unfurledMediaItem: item2.media }); } } continue; } if (require(dependencyMap[13]).ComponentType.THUMBNAIL === type) { const sources = toMediaSourceFromUnfurledMedia(a0, a2, item.media, item.description, item.spoiler); if (sources != null) { r38.push({ sources, unfurledMediaItem: item.media }); } } } return r38; } export function extractMediaSourcesFromEmbed(a0, a1, a2, mediaIndex, guildId) { const media = a2; const hasSpoilerEmbeds = renderMessageMarkup(a0, { contentMessage: a1 }).hasSpoilerEmbeds; let images = a2.images; if (images == null) { images = [a2.image]; } return images.map((image) => { let r9; L10: { const { proxyURL, url, srcIsAnimated } = image; r9 = url; if (proxyURL != null) { r9 = url; if (proxyURL !== "") { const uRL = new URL(proxyURL); const r28 = uRL.pathname.toLowerCase().endsWith(".avif"); const r33 = uRL.pathname.toLowerCase().endsWith(".webp"); if (srcIsAnimated) { if (!r33) { r9 = proxyURL; if (!r28) { break L10; } } uRL.searchParams.append("animated", "true"); if (r28) { uRL.searchParams.append("format", "webp"); } r9 = uRL.toString(); } else { r9 = proxyURL; if (r28) { uRL.searchParams.append("format", "webp"); r9 = uRL.toString(); } } } } } const mobileOptimizedSrc = ImageUtils.getMobileOptimizedSrc(r9, image.width, image.height); const contentScanVersion = media.contentScanVersion; const uri = r9; const contentScanVersion2 = contentScanVersion != null ? media.contentScanVersion : media.content_scan_version != null ? media.content_scan_version : void 0; const obscure = getMediaObscuredReasonFromBitmask({ type: ObscuredMediaTypes.Embed, media }, getEnabledHarmTypesForMessage(a0)).length > 0; return [{ uri: mobileOptimizedSrc, messageId: a0.id, guildId, channelId: a0.channel_id, mediaIndex, width: image.width, height: image.height, sourceURI: image.url, accessoryType: "embed", noCarousel: false, spoiler: hasSpoilerEmbeds, flags: media.flags, obscure, contentScanVersion: contentScanVersion2, contentType: image.contentType }, { uri, messageId: a0.id, guildId, channelId: a0.channel_id, mediaIndex, width: image.width, height: image.height, sourceURI: image.url, accessoryType: "embed", noCarousel: false, spoiler: hasSpoilerEmbeds, contentType: image.contentType, flags: media.flags, obscure, contentScanVersion: contentScanVersion2 }]; }); } export function extractMediaSourcesFromComponent(a0, a1, a2, a3, a4) { let initialIndex; const r24 = flattenComponents(a1).get(a3); if (r24 == null) { return null; } const type = r24.type; if (ComponentType.MEDIA_GALLERY === type) { initialIndex = a4 != null ? a4 <= r24.items.length ? a4 : 0 : 0; return { initialIndex, sources: r24.items.map((item, index) => { let r16 = toMediaSourceFromUnfurledMedia(a0, a2, item.media, item.description, item.spoiler); if (r16 == null) { const r2 = index < initialIndex; r16 = null; if (r2) { initialIndex = initialIndex - 1; r16 = null; } } return r16; }).filter(isNotNullish) }; } if (ComponentType.THUMBNAIL === type) { const r34 = toMediaSourceFromUnfurledMedia(a0, a2, r24.media, r24.description, r24.spoiler); return r34 == null ? null : { initialIndex: 0, sources: [r34] }; } return null; } export function extractMediaSourcesFromMessage(a0, a1, a2, a3) { let length; const r11 = []; const r7 = 0 < a1.attachments.length; let r2 = 0; let r0 = 0; if (r7) { do { const r19 = a1.attachments[r2]; const isValidImageAttachment2 = isValidImageAttachment(r19); const r6 = r2; const r4 = r0; if (!(!isValidImageAttachment2 && !(r19 != null && (r19 != null && _MediaFormatTesters.isVideoFile(r19.filename) && r19.proxy_url != null)))) { const r39 = extractMediaFromAttachment(r19, a0, r6, a2, r4); if (r39 != null) { r11.push(r39); } } const r3 = r19 != null && (r19.flags != null && hasFlag(r19.flags, MessageAttachmentFlags.IS_THUMBNAIL)) ? r4 : r4 + 1; r2 = r6 + 1; length = a1.attachments.length; r0 = r3; } while (r2 < length); } const r57 = 0 < a1.embeds.length; let r58 = 0; if (r57) { do { const r60 = a1.embeds[r58]; const r61 = r58; if (!(a3 != null && !a3.has(r60.type)) && !(!(r60.image != null || r60.thumbnail != null) && r60.video == null)) { const r76 = extractMediaFromEmbed(r60, a0, a1, r61, a2); if (r76 != null) { r11.push(r76); } } r58 = r61 + 1; } while (r58 < a1.embeds.length); } return r11; } export function setMediaSourcePortal(a0, a1) { const r6 = Array.isArray(a0) ? a0[0] : a0; if (!(r6 == null || r6.obscure)) { if (Array.isArray(a0)) { a0[0].portal = a1; } else { a0.portal = a1; } } } export function getSelectedMediaSource(a0) { const r6 = a0.index.get(); if (!(r6 < 0) && !(r6 >= a0.sources.length)) { const r10 = a0.sources[r6]; return r10 != null ? Array.isArray(r10) ? r10[r10.length - 1] : r10 : null; } return null; } export function useSelectedMediaSource(a0) { const stateFromSharedValue = useStateFromSharedValue(a0.index); let c16262_1 = stateFromSharedValue; return [stateFromSharedValue, useMemo(() => { if (!(c16262_1 < 0)) { if (!(c16262_1 >= a0.sources.length)) { const r9 = a0.sources[c16262_1]; return r9 != null ? Array.isArray(r9) ? r9[r9.length - 1] : r9 : null; } } return null; }, [a0.sources, stateFromSharedValue])]; } export function downloadMediaAsset(a0, a1) { let env16263; const r0 = env16263 = { $parent: env5153 }; env16263[0] = a1; return NativeModules.MediaManager.downloadMediaAsset(a0, a1).then($mk79875(r0), handleDownloadError); } export function downloadMediaAssetWithContentType(a0, a1, a2) { let env16259; const r1 = env16259 = { $parent: env5153 }; env16259[0] = a1; return (a2 != null ? NativeModules.MediaManager.downloadMediaAssetWithContentType(a0, a1, a2) : NativeModules.MediaManager.downloadMediaAsset(a0, a1)).then($mk79875(r1), handleDownloadError); } export function getYoutubeClipVideoIdFromURI(a0) { const r8 = a0.match(/^https:\/\/www\.youtube\.com\/embed\/([A-Za-z0-9_-]*)(\?clip=([A-Za-z0-9_-]+)(&clipt=([A-Za-z0-9_-]+)))?$/); if (r8 != null && r8.length === 6) { const videoId = r8[1]; const clip = r8[3]; const clipt = r8[5]; return videoId == null ? null : clip == null ? null : clipt == null ? null : { videoId, clip, clipt }; } return null; } export function getYoutubeVideoIdFromURI(a0) { const r6 = a0.match(/^https:\/\/www\.youtube\.com\/embed\/([A-Za-z0-9_-]*)(\?start=([0-9]+))?$/); return r6 == null ? null : r6[1] == null ? null : r6[1].length === 11 ? r6.length === 4 && r6[3] != null ? { videoId: r6[1], start: Number(r6[3]) } : { videoId: r6[1] } : null; } export { c5153_13 as VideoSourceType }; export function getVideoSourceType(a0) { return a0.videoURI != null && isWebPlayerVideoUrl(a0.videoURI) ? c5153_13.WEB_FILE_IFRAME : a0.portal != null && !isPortalExpired(a0.portal) ? c5153_13.PORTAL : a0.embedURI != null && a0.embedProviderName === "TikTok" ? c5153_13.TIKTOK_IFRAME : c5153_13.DEFAULT; } export function supportOverlayVideoControls(a0) { return a0.videoURI != null && a0.isGIFV !== true || a0.embedURI != null && a0.embedProviderName === "TikTok"; } export function isAnimatedWebpSource(a0) { return a0.sourceURI != null && a0.uri != null && urlMatchesFileExtension(a0.sourceURI, WEBP_RE_IOS) && new URL(a0.uri).searchParams.get("animated") === "true"; } export function isAnimatedAvifSource(a0) { return a0.sourceURI != null && a0.uri != null && urlMatchesFileExtension(a0.sourceURI, c5153_7) && new URL(a0.uri).searchParams.get("animated") === "true"; } export function isGIFSource(a0) { return urlMatchesFileExtension(a0.sourceURI, GIF_RE_IOS); } export function isAnimatedImageSource(a0) { return urlMatchesFileExtension(a0.sourceURI, GIF_RE_IOS) || a0.sourceURI != null && a0.uri != null && urlMatchesFileExtension(a0.sourceURI, WEBP_RE_IOS) && new URL(a0.uri).searchParams.get("animated") === "true" || a0.sourceURI != null && a0.uri != null && urlMatchesFileExtension(a0.sourceURI, c5153_7) && new URL(a0.uri).searchParams.get("animated") === "true"; }