// Metro module 8348 (f8349). import GuildTemplateStore from "../../guild_templates/GuildTemplateStore"; import { ChannelRecordBase } from "../../../records/ChannelRecord"; import ChannelStore from "../../../stores/ChannelStore"; import CreateInviteModalStore from "../../../stores/CreateInviteModalStore"; import GuildChannelStore from "../../../stores/GuildChannelStore"; import InviteStore from "../../../stores/InviteStore"; import PresenceStore from "../../../stores/PresenceStore"; import UserStore from "../../../stores/UserStore"; import DisplayedInviteStore from "../../../stores/native/DisplayedInviteStore"; import { InviteTargetTypes } from "../Constants"; import { IOS_COPY_TO_PASTEBOARD } from "./InstantInviteConstants"; import { AnalyticEvents, InviteOptionsType, Permissions } from "../../../Constants"; import AnalyticsUtils from "../../../utils/AnalyticsUtils"; import { getStreamerApplication } from "../../go_live/utils/StreamerApplicationSelectors"; import CreateInviteModalActionCreators from "../../../actions/CreateInviteModalActionCreators"; import openInstantInviteActionSheet from "./components/openInstantInviteActionSheet"; import { parseExtraDataFromInviteKey, parseInviteCodeFromInviteKey } from "../InviteCodeUtils"; import ActionSheetActionCreators from "../../action_sheet/native/ActionSheetActionCreators"; import { showShareActionSheet } from "../../action_sheet/native/showShareActionSheet"; import { presentInviteSent, presentLinkCopied } from "../../toast/native/ToastUtils"; import getInviteURL from "../getInviteURL"; import { copy } from "../../../utils/ClipboardUtils.native"; import { canOpenUrlScheme } from "./DCDSendUtils"; import Module38 from "../../../_bundle/Module38"; import { getInviteChannelId } from "../../../utils/native/InstantInviteUtils"; let trackOptionClicked; const showInstantInviteActionSheet = function showInstantInviteActionSheet(a0, a1) { AnalyticsUtils.track(AnalyticEvents.OPEN_POPOUT, { type: "Instant Invite", source: a1?.source }); const stream = a1?.stream; const r19 = { isActionSheet: true, location: "IOS Instant Invite Action Sheet Mount" }; if (stream != null) { const stream2 = a1.stream; r19.targetType = InviteTargetTypes.STREAM; r19.targetUserId = stream2.ownerId; const streamerApplication = getStreamerApplication(stream2, PresenceStore); AnalyticsUtils.track(AnalyticEvents.OPEN_MODAL, { type: "Send Stream Invite", location: r19.location, other_user_id: stream2.ownerId, application_id: streamerApplication?.id, application_name: streamerApplication?.name, game_id: streamerApplication?.id }); } else if (a1?.targetApplicationId != null) { r19.targetType = InviteTargetTypes.EMBEDDED_APPLICATION; r19.targetApplicationId = a1.targetApplicationId; } if (a1?.createInvite !== false && a1?.code == null) { CreateInviteModalActionCreators.init(a0.getGuildId(), a0.id, r19); } openInstantInviteActionSheet({ channel: a0, source: a1?.source, guildScheduledEventId: a1?.guildScheduledEventId, targetApplicationId: a1?.targetApplicationId, code: a1?.code, vanityURLCode: null, stackingBehavior: a1?.stackingBehavior }); }; trackOptionClicked = function trackOptionClicked(a0, a1, a2, a3) { let guild_id; const invite = InviteStore.getInvite(parseExtraDataFromInviteKey(a0).baseCode); const INSTANT_INVITE_OPTION_CLICKED = AnalyticEvents.INSTANT_INVITE_OPTION_CLICKED; if (a1 instanceof ChannelRecordBase) { guild_id = a1.guild_id; } else { const channel = ChannelStore.getChannel(a1?.id); guild_id = channel == null ? void 0 : channel.getGuildId(); } AnalyticsUtils.track(INSTANT_INVITE_OPTION_CLICKED, { invite_type: a2, guild_id, channel_id: a1?.id, invite_code: parseInviteCodeFromInviteKey(a0), invite_channel_type: a1?.type, invite_inviter_id: UserStore.getCurrentUser()?.id, location: a3, application_id: invite == null ? void 0 : invite.target_application?.id }); }; export function showInstantInviteActionSheetForChannel(a0) { const channel = ChannelStore.getChannel(a0); if (channel != null) { showInstantInviteActionSheet(channel); } } export { showInstantInviteActionSheet }; export function showVanityUrlInviteActionSheet(a0, a1, a2, a3) { AnalyticsUtils.track(AnalyticEvents.OPEN_POPOUT, { type: "Vanity URL Invite", source: a2 }); CreateInviteModalActionCreators.init(a0.id, a1.id, { skipCreateInvite: true }); openInstantInviteActionSheet({ vanityURLCode: a0.vanityURLCode, channel: a1, source: a2, guildScheduledEventId: a3?.guildScheduledEventId, stackingBehavior: a3?.stackingBehavior }); } export { trackOptionClicked }; export function getShareMessage(a0) { return a0; } export function handleOpenShareSheet(a0, a1, a2, a3, r5 = true) { let guild_id; if (a0 != null) { const r15 = parseExtraDataFromInviteKey(a0); const invite = InviteStore.getInvite(r15.baseCode); const INSTANT_INVITE_SHARED = AnalyticEvents.INSTANT_INVITE_SHARED; if (a1 instanceof ChannelRecordBase) { guild_id = a1.guild_id; } else { const channel = ChannelStore.getChannel(a1?.id); guild_id = channel == null ? void 0 : channel.getGuildId(); } const id = a1?.id; AnalyticsUtils.track(INSTANT_INVITE_SHARED, { guild_id, channel_id: id, invite_code: r15.baseCode, invite_channel_type: a1?.type, invite_inviter_id: UserStore.getCurrentUser()?.id, invite_guild_scheduled_event_id: r15.guildScheduledEventId, location: a3, application_id: invite == null ? void 0 : invite.target_application?.id }); if (r5) { trackOptionClicked(a0, a1, InviteOptionsType.SHARE, a3); } ActionSheetActionCreators.hideAllActionSheets(); showShareActionSheet({ message: a2, iOSOnlyShareCallback: (a0, a1) => { if ((a0 ? a1 != null : a0) && !a1.includes(IOS_COPY_TO_PASTEBOARD)) { presentInviteSent(); } } }, a3); } } export function handleCopy(a0, a1, a2, r6 = true) { let guild_id; if (a0 != null) { const r13 = parseExtraDataFromInviteKey(a0); copy(getInviteURL(a0)); const invite = InviteStore.getInvite(r13.baseCode); const COPY_INSTANT_INVITE = AnalyticEvents.COPY_INSTANT_INVITE; if (a1 instanceof ChannelRecordBase) { guild_id = a1.guild_id; } else { const channel = ChannelStore.getChannel(a1?.id); guild_id = channel == null ? void 0 : channel.getGuildId(); } AnalyticsUtils.track(COPY_INSTANT_INVITE, { server: guild_id, channel: a1?.id, channel_type: a1?.type, location: a2, code: r13.baseCode, guild_scheduled_event_id: r13.guildScheduledEventId, application_id: invite == null ? void 0 : invite.target_application?.id }); if (r6) { trackOptionClicked(a0, a1, InviteOptionsType.COPY); } presentLinkCopied(); } } export function handlePressSettings(a0, c16520_1, a2) { let r7 = a2; ActionSheetActionCreators.hideActionSheet(); const pendingSettings = CreateInviteModalStore.getPendingSettings(); const { guild_id, id } = a0; if (a2 == null) { r7 = "Instant Invite Action Sheet"; } CreateInviteModalActionCreators.openSettings(guild_id, id, r7, () => { if (c16520_1 != null) { c16520_1(); } else { let targetApplicationId = pendingSettings?.targetApplicationId; if (targetApplicationId == null) { targetApplicationId = void 0; } showInstantInviteActionSheet(a0, { createInvite: false, targetApplicationId }); } }); } export function isAppInstalled(a0) { return canOpenUrlScheme(a0); } export function handleOpenInviteActionsheet(a0, a1, a2, a3) { let channel = ChannelStore.getChannel(a1); if (channel == null) { channel = GuildChannelStore.getDefaultChannel(a0.id, true, Permissions.CREATE_INSTANT_INVITE); } Module38(channel != null, "Channel cannot be null"); if (a0.vanityURLCode != null && a0.vanityURLCode !== "") { AnalyticsUtils.track(AnalyticEvents.OPEN_POPOUT, { type: "Vanity URL Invite", source: a3 }); CreateInviteModalActionCreators.init(a0.id, channel.id, { skipCreateInvite: true }); openInstantInviteActionSheet({ vanityURLCode: a0.vanityURLCode, channel, source: a3, guildScheduledEventId: void 0, stackingBehavior: void 0 }); } else { const inviteChannelId = getInviteChannelId(channel.id, a2); if (inviteChannelId != null) { let r33 = ChannelStore.getChannel(inviteChannelId); if (r33 == null) { r33 = GuildChannelStore.getDefaultChannel(a0.id, true, Permissions.CREATE_INSTANT_INVITE); } Module38(r33 != null, "Channel cannot be null"); showInstantInviteActionSheet(r33, { source: a3 }); } } } export function hasDeferredInvite() { const displayedInviteCode = DisplayedInviteStore.getDisplayedInviteCode(); const displayedGuildTemplateCode = GuildTemplateStore.getDisplayedGuildTemplateCode(); const r9 = displayedInviteCode != null ? InviteStore.getInvite(displayedInviteCode) : null; const r13 = displayedGuildTemplateCode != null ? GuildTemplateStore.getGuildTemplate(displayedGuildTemplateCode) : null; return r9 != null || r13 != null; }