// Metro module 10647 (f10648). import ChannelStore from "../../../stores/ChannelStore"; import EmbeddedActivitiesStore from "../EmbeddedActivitiesStore"; import { ApplicationFlags } from "../../../Constants"; import getCachedOrFetchActivityApplicationForLaunch from "./getCachedOrFetchActivityApplicationForLaunch"; import { EmbeddedActivityLocationKind } from "../../../_bundle/Module10648"; import Dispatcher from "../../../Dispatcher"; import { APIError } from "../../../errors/index"; import { getEmbeddedActivityLocationChannelId } from "./embeddedActivityLocationUtils"; import confirmActivityChangeAlert from "../confirmActivityChangeAlert"; import { confirmActivityAgeGateAlert } from "../confirmActivityAgeGateAlert.native"; import * as _ApplicationFlagUtils from "../../applications/utils/ApplicationFlagUtils"; import { confirmExternalAppLaunchAlert } from "../confirmExternalAppLaunchAlert.native"; function $mk116032($env) { return (a0) => { const r8 = $env; let env31581 = { $parent: $env }; env31581[0] = a0; const selfEmbeddedActivities = EmbeddedActivitiesStore.getSelfEmbeddedActivities(); const r7 = r8[0]; const r21 = selfEmbeddedActivities.get(r7.id); env31581[1] = r21; const channel = ChannelStore.getChannel(getEmbeddedActivityLocationChannelId(r21?.location)); if (r21 != null && channel != null) { const r32 = r8[2]; if (r32 != null) { r32(); } confirmActivityChangeAlert(r7, channel, () => { const r3 = env31581.$parent.$parent; const r5 = (0, r3[1])(r3[2][10])(); const r14 = env31581.$parent; r5.leaveActivity({ location: env31581[1].location, applicationId: r14[0].id, shouldClosePopout: r14[1] }); (0, env31581[0])(true); }, () => (0, env31581[0])(false)); } else { a0(true); } }; } function $mk116033($env) { return (c31582_0) => { const r6 = $env; const r8 = r6[4]; if (r8 != null) { r8(); } confirmActivityAgeGateAlert({ application: r6[5], channelId: r6[2]?.id, onAgree: () => c31582_0(true), onDisagree: () => c31582_0(false) }); }; } function $mk116034($env) { return (c31583_0) => { const r5 = $env; const r6 = r5[3]; if (r6 != null) { r6(); } confirmExternalAppLaunchAlert({ application: r5[4], onConfirm: () => c31583_0(true), onCancel: () => c31583_0(false) }); }; } function $mk116036($env) { return function confirmActivityAgeGate() { return $env[10].apply(this, arguments); }; } function $mk116037($env) { return function confirmExternalAppLaunch() { return $env[11].apply(this, arguments); }; } let env7147 = {}; const getOrFetchApplicationForLaunch = async function getOrFetchApplicationForLaunch(c26777_0) { let cachedOrFetchActivityApplicationForLaunch; let channelId, guildId, c26777_5; let c26777_6 = 0; let c30276_0, c30276_1, c30276_2, c30276_3, c30276_4; try { c30276_0 = void 0; c30276_1 = void 0; c30276_2 = void 0; c30276_0 = c26777_0.applicationId; c30276_1 = c26777_0.channelId; c30276_2 = c26777_0.guildId; c30276_3 = void 0; await void 0; c26777_6 = 1; cachedOrFetchActivityApplicationForLaunch = await getCachedOrFetchActivityApplicationForLaunch(c30276_0, c30276_1); c26777_6 = 0; } catch ($e) { const r31 = $e; let r8 = r31; c26777_5 = r31; if (c26777_6 !== 0) { while (true) { try { const r84 = c26777_5; c26777_6 = 0; c30276_4 = r84; c30276_3 = c30276_2 != null ? EmbeddedActivityLocationKind.GUILD_CHANNEL : EmbeddedActivityLocationKind.PRIVATE_CHANNEL; channelId = c30276_1; if (channelId == null) { channelId = null; } guildId = c30276_2; if (guildId == null) { guildId = null; } Dispatcher.dispatch({ type: "EMBEDDED_ACTIVITY_LAUNCH_FAIL", nonce: "", applicationId: c30276_0, channelId, guildId, error: new APIError(c30276_4), locationKind: c30276_3 }); } catch (r81) { r8 = r81; c26777_5 = r81; if (c26777_6 === 0) { break; } continue; } return void 0; } } throw r8; } return cachedOrFetchActivityApplicationForLaunch; }; env7147[9] = function _confirmActivityChange() { const r8 = async (c26778_0) => { let c26778_1; L11: { L15: { let env30277; const r9 = env30277 = { $parent: env7147 }; c26778_1 = r9; env30277[0] = void 0; env30277[1] = void 0; env30277[2] = void 0; env30277[0] = c26778_0.currentEmbeddedApplication; env30277[1] = c26778_0.shouldClosePopoutOnLeaveCurrentEmbeddedApplication; env30277[2] = c26778_0.onConfirmActivityLaunchChecksAlertOpen; await void 0; if (env30277[0] != null) { if (await new Promise($mk116032(c26778_1))) { break L11; } break L15; } break L11; } return false; } return true; }; env7147[9] = r8; return r8.apply(this, arguments); }; env7147[10] = function _confirmActivityAgeGate() { const r8 = async (c26779_0) => { let c26779_1, guildId2, c26779_3, c26779_4; L32: { L23: { let env30278; const r29 = env7147; c26779_4 = r29; const r9 = env30278 = { $parent: r29 }; c26779_3 = r9; env30278[0] = void 0; env30278[1] = void 0; env30278[2] = void 0; env30278[3] = void 0; env30278[4] = void 0; env30278[0] = c26779_0.application; env30278[1] = c26779_0.applicationId; env30278[2] = c26779_0.channel; env30278[3] = c26779_0.user; env30278[4] = c26779_0.onConfirmActivityLaunchChecksAlertOpen; env30278[5] = void 0; await void 0; if (env30278[3].nsfwAllowed != null) { break L32; } const r53 = env30278[0]; c26779_1 = r53; if (r53 == null) { const id = env30278[2]?.id; const r92 = env30278[2]; guildId2 = r92 == null ? void 0 : r92.getGuildId(); if (guildId2 == null) { guildId2 = void 0; } c26779_1 = await getOrFetchApplicationForLaunch({ applicationId: env30278[1], channelId: id, guildId: guildId2 }); } env30278[5] = c26779_1; if (env30278[5] == null) { break L23; } const requires_age_gate = env30278[5].embeddedActivityConfig?.requires_age_gate; if (requires_age_gate == null) { break L32; } if (!requires_age_gate) { break L32; } if (await new Promise($mk116033(c26779_3))) { break L32; } return false; } return false; } return true; }; env7147[10] = r8; return r8.apply(this, arguments); }; env7147[11] = function _confirmExternalAppLaunch() { const r8 = async (c26780_0) => { let guildId3; let env30279; const r28 = env7147; let c26780_4 = r28; const r9 = env30279 = { $parent: r28 }; let c26780_3 = r9; env30279[0] = void 0; env30279[1] = void 0; env30279[2] = void 0; env30279[3] = void 0; env30279[0] = c26780_0.application; env30279[1] = c26780_0.applicationId; env30279[2] = c26780_0.channel; env30279[3] = c26780_0.onConfirmActivityLaunchChecksAlertOpen; env30279[4] = void 0; await void 0; const r47 = env30279[0]; let c26780_1 = r47; if (r47 == null) { const id = env30279[2]?.id; const r92 = env30279[2]; guildId3 = r92 == null ? void 0 : r92.getGuildId(); if (guildId3 == null) { guildId3 = void 0; } c26780_1 = await getOrFetchApplicationForLaunch({ applicationId: env30279[1], channelId: id, guildId: guildId3 }); } env30279[4] = c26780_1; let r59 = env30279[4] != null; if (r59) { const hasApplicationFlag = _ApplicationFlagUtils.hasApplicationFlag(env30279[4], ApplicationFlags.EMBEDDED_RELEASED); const r73 = hasApplicationFlag ? !hasApplicationFlag : !env30279[4].isVerified; r59 = r73 ? !!EmbeddedActivitiesStore.hasActivityEverBeenLaunched(env30279[1]) || new Promise($mk116034(c26780_3)) : !r73; } return r59; }; env7147[11] = r8; return r8.apply(this, arguments); }; export async function confirmActivityLaunchChecks(c26781_0) { let r90; let c26781_1; L19: { L16: { let env30280; const r10 = env30280 = { $parent: env7147 }; c26781_1 = r10; env30280[0] = c26781_0; env30280[1] = void 0; env30280[2] = void 0; env30280[3] = void 0; env30280[1] = await (function confirmActivityChange() { return env7147[9].apply(this, arguments); })({ currentEmbeddedApplication: c26781_0.currentEmbeddedApplication, shouldClosePopoutOnLeaveCurrentEmbeddedApplication: c26781_0.shouldClosePopoutOnLeaveCurrentEmbeddedApplication, onConfirmActivityLaunchChecksAlertOpen: c26781_0.onConfirmActivityLaunchChecksAlertOpen }); if (env30280[1]) { const r48 = env30280[0]; env30280[2] = await $mk116036(env7147)(r48); if (env30280[2]) { const r69 = env30280[0]; env30280[3] = await $mk116037(env7147)(r69); r90 = !env30280[3]; break L19; } break L16; } return false; } return false; } return !r90; }