// Metro module 1222 (f1223). import { ComponentActions, PageAnalyticsLocations, Routes, RelativeMarketingURLs } from "../../Constants"; import Logger from "../debug/Logger"; import { createMemoryHistory } from "../../_bundle/Module1223"; import { ComponentDispatch } from "../../utils/ComponentDispatchUtils"; import { ChannelBackNavigationSources } from "./RoutingSources"; function $mk68500($env) { return (a0) => $env[0].startsWith(a0); } let memoryHistory, source, sourceLocationStack, c1027_8, c1027_9, c1027_10; const transitionTo = function transitionTo(a0, a1) { let env12924; const r2 = env12924 = {}; env12924[0] = a0; const r1 = typeof a0 === "string" ? !c1027_9.some($mk68500(r2)) : typeof a0 !== "string"; let r0 = !r1; if (!r1) { c1027_8.log(`assign - route to external path ${a0}`); window.dispatchEvent(new Event("beforeunload")); window.location.assign(a0); r0 = true; } if (!r0) { c1027_8.log(`transitionTo - Transitioning to ${a0}`); const source2 = a1?.source; const sourceLocationStack2 = a1?.sourceLocationStack; if (a1 == null) { memoryHistory.push(a0); } else { const uRL = new URL(a0, `https:${window.GLOBAL_ENV.WEBAPP_ENDPOINT}`); memoryHistory.push({ pathname: uRL.pathname, search: uRL.search, hash: uRL.hash, ...a1 }); } source = source2; sourceLocationStack = sourceLocationStack2; } }; c1027_8 = new Logger("Routing/Utils"); c1027_9 = [RelativeMarketingURLs.DEVELOPER_PORTAL]; memoryHistory = createMemoryHistory(); c1027_10 = memoryHistory.listen((a0, a1) => { if (a1 !== "REPLACE") { c1027_10(); } }); export function shouldNavigate() { return !ComponentDispatch.hasSubscribers(ComponentActions.MODAL_CLOSE); } export { transitionTo }; export function transitionToGuild(a0, a1, a2, a3) { c1027_8.log(`transitionToGuild - Transitioning to ${JSON.stringify({ guildId: a0, channelId: a1, messageId: a2 })}`); transitionTo(Routes.CHANNEL(a0, a1, a2), a3); } export function currentRouteHasBackNavigation() { return source != null && ChannelBackNavigationSources.has(source); } export function replaceWith(a0, a1, a2) { let env12925; const r2 = env12925 = {}; env12925[0] = a0; const r0 = typeof a0 === "string" ? !c1027_9.some($mk68500(r2)) : typeof a0 !== "string"; let r1 = !r0; if (!r0) { c1027_8.log(`replace - route to external path ${a0}`); window.dispatchEvent(new Event("beforeunload")); window.location.replace(a0); r1 = true; } if (!r1) { c1027_8.log(`Replacing route with ${a0}`); if (typeof a0 === "string") { memoryHistory.replace(a0, a1); } else { memoryHistory.replace(a0); } source = a2; } } export function getHistory() { return memoryHistory; } export function getLastRouteChangeSource() { return source; } export function getLastRouteChangeSourceLocationStack() { return sourceLocationStack; } export function isValidFingerprintRoute(a0) { if (a0 == null) { memoryHistory.location.pathname == null; } return true; } export function getFingerprintLocation(a0) { let r1 = a0; if (a0 == null) { let pathname = memoryHistory.location.pathname; if (pathname == null) { pathname = ""; } r1 = pathname; } if (r1.startsWith(Routes.LOGIN)) { r1 = PageAnalyticsLocations.LOGIN; } else if (r1.startsWith(Routes.REGISTER)) { r1 = PageAnalyticsLocations.REGISTER; } else if (r1.startsWith(Routes.INVITE(""))) { r1 = PageAnalyticsLocations.INVITE; } else if (r1.startsWith(Routes.VERIFY)) { r1 = PageAnalyticsLocations.VERIFY; } else if (r1.startsWith(Routes.DISABLE_EMAIL_NOTIFICATIONS)) { r1 = PageAnalyticsLocations.DISABLE_EMAIL_NOTIFICATIONS; } else if (r1.startsWith(Routes.DISABLE_SERVER_HIGHLIGHT_NOTIFICATIONS)) { r1 = PageAnalyticsLocations.DISABLE_SERVER_HIGHLIGHT_NOTIFICATIONS; } else if (r1.startsWith(Routes.REJECT_IP)) { r1 = PageAnalyticsLocations.REJECT_IP; } else if (r1.startsWith(Routes.REJECT_MFA)) { r1 = PageAnalyticsLocations.REJECT_MFA; } else if (r1.startsWith(Routes.AUTHORIZE_IP)) { r1 = PageAnalyticsLocations.AUTHORIZE_IP; } else if (r1.startsWith(Routes.AUTHORIZE_PAYMENT)) { r1 = PageAnalyticsLocations.AUTHORIZE_PAYMENT; } else if (r1.startsWith(Routes.RESET)) { r1 = PageAnalyticsLocations.RESET; } else if (r1.startsWith(Routes.REPORT)) { r1 = PageAnalyticsLocations.REPORT; } else if (r1.startsWith(Routes.REPORT_SECOND_LOOK)) { r1 = PageAnalyticsLocations.REPORT_SECOND_LOOK; } else if (r1.startsWith(Routes.ACCOUNT_REVERT(""))) { r1 = PageAnalyticsLocations.ACCOUNT_REVERT; } return r1; } export function hasNavigated() { return false; } export function back() { if (!ComponentDispatch.hasSubscribers(ComponentActions.MODAL_CLOSE)) { source = null; memoryHistory.goBack(); } } export function forward() { if (!ComponentDispatch.hasSubscribers(ComponentActions.MODAL_CLOSE)) { source = null; memoryHistory.goForward(); } }