// Module ID: 9157 // Function ID: 9158 // Name: AssetUtils // Dependencies: [5979, 1085, 9158, 9159, 9160, 9161, 9162, 7389, 9167, 9168, 5987, 1384, 1898, 2] // Exports: buildUrl, getDevicePixelScaledDimensions, getQuestAsset, getScaledFirstFrameImageUrl, getScaledImageUrl, resolveAdCreativeCdnUrl, resolveOptionalAdCreativeCdnUrl // Module 9157 (AssetUtils) import URLUtilsDefault from "URLUtils" /* 1384 */; import react_nativeDefault from "react-native" /* 1898 */; import FirstPartyQuestTaskTypes2 from "FirstPartyQuestTaskTypes" /* 5987 */; import QuestRewardTypes from "QuestRewardTypes" /* 7389 */; import _modDef9158 from "module_9158" /* 9158 */; import _modDef9159 from "module_9159" /* 9159 */; import _modDef9160 from "module_9160" /* 9160 */; import _modDef9161 from "module_9161" /* 9161 */; import QuestRewardUtils from "QuestRewardUtils" /* 9162 */; import _modDef9167 from "module_9167" /* 9167 */; import _modDef9168 from "module_9168" /* 9168 */; import QuestConstants from "QuestConstants" /* 5979 */; import Constants from "Constants" /* 1085 */; import size_mod from "module_2" /* 2 */; let TIER_1; let TIER_2; let TIER_3; let TIER_4; let c3; let closure_4; let hasOwnProperty; let metroRequire; function resolveAsset(id, questBarHeroVideo, arg2) { let combined; let hasItem; let theme; if (arg2 != null) { theme = arg2.theme; } if (questBarHeroVideo.startsWith("blob:")) { const parts = questBarHeroVideo.split("?", 1); let atResult = parts.at(0); if (atResult == null) { atResult = questBarHeroVideo; } combined = atResult; } else if (questBarHeroVideo.includes("/")) { const _HermesInternal3 = HermesInternal; combined = "" + _false + questBarHeroVideo; } else { let str5 = ""; if (null != tmp2) { const _HermesInternal = HermesInternal; str5 = "/" + tmp2; } const _HermesInternal2 = HermesInternal; combined = "" + tmp4 + id + str5 + "/" + questBarHeroVideo; } const tmp15 = getMimetype(questBarHeroVideo); const obj = { url: combined, mimetype: tmp15, isAnimated: hasItem }; hasItem = null != tmp15 && items.includes(tmp15); return obj; } function getMimetype(videoPreview) { if (null == videoPreview) { return null; } else { const startsWithResult = videoPreview.startsWith("blob:"); const obj = URLUtilsDefault; const toURLSafeResult = obj.toURLSafe(videoPreview); if (startsWithResult) { let value; if (toURLSafeResult != null) { const searchParams2 = toURLSafeResult.searchParams; value = searchParams2.get("mimetype"); } let decodeURIComponentResult = null; if (null != value) { const _decodeURIComponent = decodeURIComponent; decodeURIComponentResult = decodeURIComponent(value); } return decodeURIComponentResult; } else { let formatted; if (toURLSafeResult != null) { const searchParams = toURLSafeResult.searchParams; const str2 = searchParams.get("format"); if (str2 != null) { formatted = str2.toLowerCase(); } } if (formatted == null) { const match = re7.exec(videoPreview); let formatted1; if (match != null) { if (match[1] != null) { formatted1 = str3.toLowerCase(); } } formatted = formatted1; } switch (formatted) { case "webm": { return "video/webm"; } case "mp4": { return "video/mp4"; } case "webp": { return "image/webp"; } case "jpg": { return "image/jpeg"; } case "jpeg": { return "image/jpeg"; } case "png": { return "image/png"; } case "gif": { return "image/gif"; } case "svg": { return "image/svg+xml"; } case "txt": { return "text/plain"; } case "vtt": { return "text/vtt"; } case "ts": { return "video/mp2t"; } case "m3u8": { return "application/x-mpegURL"; } default: { return null; } } } } } function getAssetUrlWithMediaProxyQueryParams(assetUrl, size) { if (size === undefined) { size = {}; } if (assetUrl.startsWith("blob:")) { return assetUrl; } else { const obj = URLUtilsDefault; const str = obj.toURLSafe(assetUrl); let str1 = assetUrl; if (null != str) { if (null != size.format) { const searchParams = str.searchParams; const result = searchParams.set("format", size.format); } if (null != size.width) { const searchParams2 = str.searchParams; const _Math = Math; const _Math2 = Math; const _HermesInternal = HermesInternal; const result1 = searchParams2.set("width", "" + Math.min(Math.ceil(size.width), hasOwnProperty)); } if (null != size.height) { const searchParams3 = str.searchParams; const _Math3 = Math; const _Math4 = Math; const _HermesInternal2 = HermesInternal; const result2 = searchParams3.set("height", "" + Math.min(Math.ceil(size.height), hasOwnProperty)); } str1 = str.toString(); } return str1; } } function convertVideoToFirstFrameImageWithMediaProxy(assetUrl, size) { if (assetUrl.startsWith("blob:")) { return assetUrl; } else { const obj = URLUtilsDefault; const str = obj.toURLSafe(assetUrl); let str1 = null; if (null != str) { const searchParams = str.searchParams; const result = searchParams.set("format", "webp"); if (null != size) { const searchParams2 = str.searchParams; const _Math = Math; const _Math2 = Math; const _HermesInternal = HermesInternal; const result1 = searchParams2.set("width", "" + Math.min(Math.ceil(size.width), hasOwnProperty)); const searchParams3 = str.searchParams; const _Math3 = Math; const _Math4 = Math; const _HermesInternal2 = HermesInternal; const result2 = searchParams3.set("height", "" + Math.min(Math.ceil(size.height), hasOwnProperty)); } str1 = str.toString(); } return str1; } } ({ CDN_URL_BASE: c3, QUESTS_CDN_URL_BASE: closure_4 } = QuestConstants); ({ MEDIA_PROXY_MAX_TARGET_RESOLUTION: hasOwnProperty, ThemeTypes: metroRequire } = Constants); const tmp4 = /\.([a-zA-Z0-9]+)$/; const re7 = tmp4; const items = ["video/mp4", "video/webm"]; const QuestAssetType = { HERO: "hero", HERO_IMAGE: "hero_image", HERO_VIDEO: "hero_video", QUEST_BAR_HERO: "quest_bar_hero", QUEST_BAR_HERO_VIDEO: "quest_bar_hero_video", QUEST_BAR_HERO_IMAGE: "quest_bar_hero_image", REWARD: "reward", REWARD_IMAGE: "reward_image", GAME_TILE: "game_tile", LOGO_TYPE: "logo_type", COSPONSOR_LOGO_TYPE: "cosponsor_logo_type", VIDEO_PLAYER_VIDEO: "video_player_video", VIDEO_PLAYER_VIDEO_LOW_RES: "video_player_video_low_res", VIDEO_PLAYER_VIDEO_HLS: "video_player_video_hls", VIDEO_PLAYER_THUMBNAIL: "video_player_thumbnail", VIDEO_PLAYER_CAPTION: "video_player_caption", VIDEO_PLAYER_TRANSCRIPT: "video_player_transcript" }; let obj2 = { VIDEO: "video", VIDEO_LOW_RES: "videoLowRes", VIDEO_HLS: "videoHls" }; let obj3 = { VIDEO: "url", THUMBNAIL: "thumbnail", CAPTION: "caption", TRANSCRIPT: "transcript" }; let obj4 = { TIER_1: 1, [1]: "TIER_1", TIER_2: 2, [2]: "TIER_2", TIER_3: 3, [3]: "TIER_3", TIER_4: 4, [4]: "TIER_4" }; let obj5 = { variant: obj2.VIDEO, property: obj3.VIDEO }; let closure_11 = { [QuestAssetType.VIDEO_PLAYER_VIDEO]: obj5, [QuestAssetType.VIDEO_PLAYER_VIDEO_LOW_RES]: { variant: obj2.VIDEO_LOW_RES, property: obj3.VIDEO }, [QuestAssetType.VIDEO_PLAYER_VIDEO_HLS]: { variant: obj2.VIDEO_HLS, property: obj3.VIDEO }, [QuestAssetType.VIDEO_PLAYER_THUMBNAIL]: { variant: obj2.VIDEO, property: obj3.THUMBNAIL }, [QuestAssetType.VIDEO_PLAYER_CAPTION]: { variant: obj2.VIDEO, property: obj3.CAPTION }, [QuestAssetType.VIDEO_PLAYER_TRANSCRIPT]: { variant: obj2.VIDEO, property: obj3.TRANSCRIPT } }; const obj11 = { [TIER_1]: _modDef9158, [TIER_2]: _modDef9159, [TIER_3]: _modDef9160, [TIER_4]: _modDef9161 }; ({ TIER_1, TIER_2, TIER_3, TIER_4 } = obj4); let size = size_mod; let result = size.fileFinishedImporting("modules/quests/lib/AssetUtils.tsx"); export const EXTENSION_RE = tmp4; export const ANIMATED_MIMETYPES = items; export { QuestAssetType }; export { resolveAsset }; export const OrbsValueTier = obj4; export const getQuestAsset = function getQuestAsset(quest, VIDEO_PLAYER_THUMBNAIL, DARK, flag, arg4) { let asset; let assetVideo; let flag2; let obj; let tmp41; if (obj.HERO === VIDEO_PLAYER_THUMBNAIL) { const heroVideo2 = quest.config.assets.heroVideo; asset = quest.config.assets.hero; flag = false; flag2 = false; } else if (obj.HERO_IMAGE === VIDEO_PLAYER_THUMBNAIL) { asset = quest.config.assets.hero; flag = false; flag2 = false; } else if (obj.HERO_VIDEO === VIDEO_PLAYER_THUMBNAIL) { const heroVideo = quest.config.assets.heroVideo; flag = false; flag2 = false; asset = heroVideo; if (null == heroVideo) { return null; } } else if (obj.QUEST_BAR_HERO === VIDEO_PLAYER_THUMBNAIL) { const questBarHeroVideo2 = quest.config.assets.questBarHeroVideo; asset = quest.config.assets.questBarHero; flag = false; flag2 = false; } else if (obj.QUEST_BAR_HERO_VIDEO === VIDEO_PLAYER_THUMBNAIL) { const questBarHeroVideo = quest.config.assets.questBarHeroVideo; flag = false; flag2 = false; asset = questBarHeroVideo; if (null == questBarHeroVideo) { return null; } } else if (obj.QUEST_BAR_HERO_IMAGE === VIDEO_PLAYER_THUMBNAIL) { asset = quest.config.assets.questBarHero; flag = false; flag2 = false; } else if (obj.REWARD === VIDEO_PLAYER_THUMBNAIL) { const obj2 = QuestRewardUtils; const questPrimaryReward = obj2.getQuestPrimaryReward(quest); if (questPrimaryReward.type === QuestRewardTypes.QuestRewardTypes.VIRTUAL_CURRENCY) { let obj5; let tmp29; if (null != arg4) { tmp29 = obj11[arg4]; } if (null != tmp29) { obj5 = { url: tmp29, mimetype: "video/webm", isAnimated: true }; const obj3 = { url: tmp29, mimetype: "video/webm", isAnimated: true }; } else if (flag) { obj5 = { url: _modDef9167, mimetype: "video/mp4", isAnimated: true }; const obj4 = { url: _modDef9167, mimetype: "video/mp4", isAnimated: true }; } else { obj5 = { url: _modDef9168, mimetype: "video/webm", isAnimated: true }; } return obj5; } else { ({ assetVideo, asset } = questPrimaryReward); flag = false; flag2 = false; } } else if (obj.REWARD_IMAGE === VIDEO_PLAYER_THUMBNAIL) { obj = QuestRewardUtils; const questPrimaryReward1 = obj.getQuestPrimaryReward(quest); if (questPrimaryReward1.type === QuestRewardTypes.QuestRewardTypes.VIRTUAL_CURRENCY) { return null; } else { asset = questPrimaryReward1.asset; flag = false; flag2 = false; } } else if (obj.GAME_TILE === VIDEO_PLAYER_THUMBNAIL) { let tmp18; if (null != DARK) { let str10; if (DARK === metroRequire.LIGHT) { str10 = "light"; } else { str10 = "dark"; } tmp18 = str10; } if ("dark" === tmp18) { if (null != quest.config.assets.gameTileDark) { asset = quest.config.assets.gameTileDark; flag = false; flag2 = false; } } if ("light" === tmp18) { if (null != quest.config.assets.gameTileLight) { asset = quest.config.assets.gameTileLight; flag = false; flag2 = false; } } asset = quest.config.assets.gameTile; flag = false; flag2 = true; } else if (obj.LOGO_TYPE === VIDEO_PLAYER_THUMBNAIL) { let tmp15; if (null != DARK) { let str6; if (DARK === metroRequire.LIGHT) { str6 = "light"; } else { str6 = "dark"; } tmp15 = str6; } if ("dark" === tmp15) { if (null != quest.config.assets.logotypeDark) { asset = quest.config.assets.logotypeDark; flag = false; flag2 = false; } } if ("light" === tmp15) { if (null != quest.config.assets.logotypeLight) { asset = quest.config.assets.logotypeLight; flag = false; flag2 = false; } } asset = quest.config.assets.logotype; flag = false; flag2 = true; } else if (obj.COSPONSOR_LOGO_TYPE === VIDEO_PLAYER_THUMBNAIL) { if (null == quest.config.cosponsorMetadata) { return null; } else { let tmp13; if (null != DARK) { let str2; if (DARK === metroRequire.LIGHT) { str2 = "light"; } else { str2 = "dark"; } tmp13 = str2; } if ("dark" === tmp13) { if (null != quest.config.cosponsorMetadata.logotypeDark) { asset = quest.config.cosponsorMetadata.logotypeDark; flag = false; flag2 = false; } } if ("light" === tmp13) { if (null != quest.config.cosponsorMetadata.logotypeLight) { asset = quest.config.cosponsorMetadata.logotypeLight; flag = false; flag2 = false; } } asset = quest.config.cosponsorMetadata.logotype; flag = false; flag2 = true; } } else { if (obj.VIDEO_PLAYER_VIDEO !== VIDEO_PLAYER_THUMBNAIL) { if (obj.VIDEO_PLAYER_VIDEO_LOW_RES !== VIDEO_PLAYER_THUMBNAIL) { if (obj.VIDEO_PLAYER_VIDEO_HLS !== VIDEO_PLAYER_THUMBNAIL) { if (obj.VIDEO_PLAYER_THUMBNAIL !== VIDEO_PLAYER_THUMBNAIL) { if (obj.VIDEO_PLAYER_CAPTION !== VIDEO_PLAYER_THUMBNAIL) { flag = false; flag2 = false; } } } } } if ("taskConfigV2" in quest.config) { const tasks = quest.config.taskConfigV2.tasks; const FirstPartyQuestTaskTypes = FirstPartyQuestTaskTypes2.FirstPartyQuestTaskTypes; const tmp5 = tasks[flag ? FirstPartyQuestTaskTypes.WATCH_VIDEO_ON_MOBILE : FirstPartyQuestTaskTypes.WATCH_VIDEO]; let tmp9; if (tmp5 != null) { if (tmp5.assets[closure_11[VIDEO_PLAYER_THUMBNAIL].variant] != null) { tmp9 = tmp10[tmp7.property]; } } flag = true; flag2 = false; asset = tmp9; if (null == tmp9) { return null; } } else { return null; } } let tmp36; const id = quest.id; const tmp35 = resolveAsset; if (flag2) { let tmp38; if (null != DARK) { let str14; if (DARK === metroRequire.LIGHT) { str14 = "light"; } else { str14 = "dark"; } tmp38 = str14; } tmp36 = tmp38; } const tmp35Result = tmp35(id, asset, { theme: tmp36 }); if (!flag) { tmp41 = tmp35Result; } else { tmp41 = null; } return tmp41; }; export const buildUrl = function buildUrl(arg0, str, theme) { if (str.startsWith("blob:")) { const parts = str.split("?", 1); let atResult = parts.at(0); if (atResult == null) { atResult = str; } return atResult; } else { let combined; if (str.includes("/")) { const _HermesInternal3 = HermesInternal; combined = "" + _false + str; } else { theme = undefined; if (theme != null) { theme = theme.theme; } let str3 = ""; if (null != theme) { const _HermesInternal = HermesInternal; str3 = "/" + theme.theme; } const _HermesInternal2 = HermesInternal; combined = "" + tmp + arg0 + str3 + "/" + str; } return combined; } }; export const resolveOptionalAdCreativeCdnUrl = function resolveOptionalAdCreativeCdnUrl(hero_video) { if (null != hero_video) { let combined = hero_video; if (!hero_video.startsWith("http://")) { combined = hero_video; if (!hero_video.startsWith("https://")) { combined = hero_video; if (!hero_video.startsWith("blob:")) { const _HermesInternal = HermesInternal; combined = "" + _false + hero_video; } } } return combined; } }; export const resolveAdCreativeCdnUrl = function resolveAdCreativeCdnUrl(hero_image) { let combined = hero_image; if (!hero_image.startsWith("http://")) { combined = hero_image; if (!hero_image.startsWith("https://")) { combined = hero_image; if (!hero_image.startsWith("blob:")) { const _HermesInternal = HermesInternal; combined = "" + _false + hero_image; } } } return combined; }; export { getMimetype }; export const getDevicePixelScaledDimensions = function getDevicePixelScaledDimensions(width, height) { let size1; const tmp = react_nativeDefault(); if (tmp < 3) { size = { width, height }; size1 = size; } else { size1 = { width: width * tmp, height: height * tmp }; } return size1; }; export { getAssetUrlWithMediaProxyQueryParams }; export const getScaledImageUrl = function getScaledImageUrl(size) { let assetUrl; let height; let width; ({ assetUrl, width, height } = size); const tmp = react_nativeDefault(); size = { width: width * tmp, height: height * tmp, format: "webp" }; return getAssetUrlWithMediaProxyQueryParams(assetUrl, size); }; export { convertVideoToFirstFrameImageWithMediaProxy }; export const getScaledFirstFrameImageUrl = function getScaledFirstFrameImageUrl(size) { let assetUrl; let height; let width; ({ assetUrl, width, height } = size); const tmp = react_nativeDefault(); size = { width: width * tmp, height: height * tmp }; return convertVideoToFirstFrameImageWithMediaProxy(assetUrl, size); };