2026-07-27 11:26:19 +00:00
// Module ID: 10806
// Function ID: 83811
2026-07-20 16:05:17 +00:00
// Name: matchPathToRoutes
2026-07-27 11:26:19 +00:00
// Dependencies: [29, 10174, 1352, 1348, 3952, 1908, 1907, 653, 10175, 3, 3966, 10807, 4945, 1198, 10812, 4338, 4342, 5049, 10627, 3982, 686, 4324, 4063, 10813, 2]
2026-07-20 16:05:17 +00:00
// Exports: cleanupRouteManager, initializeRouteManagerIfNeeded, popVoiceRoute, transitionToVoiceRoute
2026-07-27 11:26:19 +00:00
// Module 10806 (matchPathToRoutes)
2026-07-23 10:11:24 +00:00
import _objectWithoutProperties from "_objectWithoutProperties" ;
import { setVoiceChatDrawerState } from "resetFocusTimer" ;
import { isGuildSelectableChannelType as closure_6 } from "_callSuper" ;
import _isNativeReflectConstruct from "_isNativeReflectConstruct" ;
import closure_8 from "_isNativeReflectConstruct" ;
import closure_9 from "_isNativeReflectConstruct" ;
import closure_10 from "_isNativeReflectConstruct" ;
import ME from "ME" ;
import { VoiceChatDrawerState } from "BOX_MODE_ACTIONSHEET_WIDTH" ;
import importDefaultResult from "_isNativeReflectConstruct" ;
import { RouteParam } from "isPseudoGuildId" ;
import { RouteParam as RouteParam2 } from "isPseudoGuildId" ;
import { RouteParam as RouteParam3 } from "isPseudoGuildId" ;
import { RouteParam as RouteParam4 } from "isPseudoGuildId" ;
2026-07-20 16:05:17 +00:00
let Routes ;
2026-07-23 10:11:24 +00:00
let closure_11 ;
const require = arg1 ;
2026-07-20 16:05:17 +00:00
function matchPathToRoutes ( pathname , items ) {
2026-07-27 11:26:19 +00:00
let obj = require ( 10807 ) /* MemoryRouter */ ;
2026-07-23 10:11:24 +00:00
obj = { path : items , strict : false , exact : false } ;
2026-07-20 16:05:17 +00:00
return obj . matchPath ( pathname , obj ) ;
}
function extractParamsFromVoiceModalRoute ( location ) {
let voiceChannelId ;
let voiceGuildId ;
let voiceMessageId ;
const tmp = matchPathToRoutes ( location . pathname , items ) ;
let params ;
if ( null != tmp ) {
params = tmp . params ;
}
if ( null == params ) {
params = { } ;
}
let obj = { } ;
obj = { match : tmp , location } ;
( { voiceChannelId , voiceGuildId , voiceMessageId } = params ) ;
const merged = Object . assign ( extractParams ( obj ) ) ;
obj [ "voiceChannelId" ] = voiceChannelId ;
obj [ "voiceGuildId" ] = voiceGuildId ;
obj [ "voiceMessageId" ] = voiceMessageId ;
return obj ;
}
function selectLastVisitedTextChannel ( guildId ) {
const channel = store . getChannel ( store2 . getLastSelectedChannelId ( ) ) ;
let type ;
if ( null != channel ) {
type = channel . type ;
}
if ( null != type ) {
let type1 ;
if ( null != channel ) {
type1 = channel . type ;
}
if ( closure_6 ( type1 ) ) {
let id = channel . id ;
}
return id ;
}
id = store2 . getMostRecentSelectedTextChannelId ( guildId ) ;
if ( null == id ) {
2026-07-23 10:11:24 +00:00
defaultChannel = defaultChannel . getDefaultChannel ( guildId ) ;
2026-07-20 16:05:17 +00:00
id = undefined ;
if ( null != defaultChannel ) {
id = defaultChannel . id ;
}
}
}
function voiceRouteRewriter ( location ) {
let channelId ;
let guildId ;
let obj = { match : matchPathToRoutes ( location . pathname , items ) , location } ;
const tmp = extractParams ( obj ) ;
( { channelId , guildId } = tmp ) ;
const tmp2 = callback ( tmp , closure_3 ) ;
const channel = store . getChannel ( channelId ) ;
let tmp4 = null ;
if ( null != channelId ) {
tmp4 = null ;
if ( null != guildId ) {
let type ;
if ( null != channel ) {
type = channel . type ;
}
if ( type === ChannelTypes . GUILD_VOICE ) {
obj = { } ;
const merged = Object . assign ( tmp2 ) ;
obj [ "channelId" ] = channelId ;
obj [ "guildId" ] = guildId ;
tmp4 = obj ;
} else {
let type1 ;
if ( null != channel ) {
type1 = channel . type ;
}
tmp4 = null ;
}
}
}
if ( null != tmp4 ) {
if ( null != importDefaultResult ) {
const _JSON = JSON ;
const _HermesInternal = HermesInternal ;
importDefaultResult . log ( "voiceRouteRewriter: has voiceChannelParams = " + JSON . stringify ( tmp4 ) ) ;
}
const _HermesInternal2 = HermesInternal ;
const combined = "" + closure_8 . lastNonVoiceRoute + Routes . VOICE_CHAT_CHANNEL_PARTIAL ( tmp4 . guildId , tmp4 . channelId , tmp4 . messageId ) ;
let tmp20 = null ;
if ( combined !== location . pathname ) {
if ( null != importDefaultResult ) {
const _HermesInternal3 = HermesInternal ;
importDefaultResult . log ( "voiceRouteRewriter: rewriting route: " + location . pathname + " -> " + combined ) ;
}
obj = { path : combined , state : location.state } ;
tmp20 = obj ;
}
return tmp20 ;
} else {
return null ;
}
}
function saveLastRouteListener ( pathname ) {
2026-07-27 11:26:19 +00:00
require ( 10812 ) /* isLurkingGuildRoute */ . saveLastRoute ( pathname . pathname ) ;
2026-07-20 16:05:17 +00:00
}
function saveLastNonVoiceRouteListener ( pathname ) {
const tmp = matchPathToRoutes ( pathname . pathname , items ) ;
let channelId ;
if ( null != tmp ) {
channelId = tmp . params . channelId ;
}
const channel = store . getChannel ( channelId ) ;
let type ;
if ( null != channel ) {
type = channel . type ;
}
let tmp6 = null ;
if ( type !== ChannelTypes . GUILD_VOICE ) {
let type1 ;
if ( null != channel ) {
type1 = channel . type ;
}
tmp6 = null ;
if ( type1 !== ChannelTypes . GUILD_STAGE_VOICE ) {
const obj = { match : tmp , location : pathname } ;
tmp6 = extractParams ( obj ) ;
}
}
if ( null != tmp6 ) {
2026-07-27 11:26:19 +00:00
const result = require ( 10812 ) /* isLurkingGuildRoute */ . saveLastNonVoiceRoute ( Routes . CHANNEL ( tmp6 . guildId , tmp6 . channelId ) ) ;
const obj2 = require ( 10812 ) /* isLurkingGuildRoute */ ;
2026-07-20 16:05:17 +00:00
}
}
function updateSelectedChannelListener ( location ) {
let channelId ;
let guildId ;
let jumpType ;
let messageId ;
let voiceChannelId ;
let voiceGuildId ;
let voiceMessageId ;
let obj = extractParamsFromVoiceModalRoute ( location ) ;
if ( null == obj ) {
obj = { } ;
}
( { guildId , channelId , messageId , jumpType , voiceChannelId , voiceGuildId , voiceMessageId } = obj ) ;
if ( null == voiceChannelId ) {
if ( null == voiceGuildId ) {
if ( null != importDefaultResult ) {
const _JSON5 = JSON ;
const json = JSON . stringify ( location ) ;
const _JSON6 = JSON ;
obj = { guildId , channelId , messageId , jumpType , voiceChannelId , voiceGuildId , voiceMessageId } ;
const _HermesInternal3 = HermesInternal ;
importDefaultResult . verbose ( "UpdateSelectedChannelListener -> no voice route present in " + json + " " + JSON . stringify ( obj ) + " " ) ;
}
const channel = store . getChannel ( store2 . getLastSelectedChannelId ( ) ) ;
let tmp36 = null != channel && channel . isGuildVoice ( ) ;
if ( ! tmp36 ) {
tmp36 = null != channel && channel . isGuildStageVoice ( ) ;
const tmp37 = null != channel && channel . isGuildStageVoice ( ) ;
}
if ( tmp36 ) {
2026-07-25 08:10:48 +00:00
const obj15 = importDefault ( 4338 ) ;
obj15 . popWithKey ( channel2 ( 4342 ) . getVoiceChannelKey ( channel . id ) ) ;
const obj16 = channel2 ( 4342 ) ;
2026-07-20 16:05:17 +00:00
}
2026-07-25 08:10:48 +00:00
const guild = importDefault ( 5049 ) . selectGuild ( guildId ) ;
const obj17 = importDefault ( 5049 ) ;
2026-07-20 16:05:17 +00:00
obj = { guildId , channelId , messageId , jumpType , skipMessageFetch : tmp } ;
2026-07-25 08:10:48 +00:00
const channel1 = importDefault ( 4945 ) . selectChannel ( obj ) ;
2026-07-20 16:05:17 +00:00
}
}
2026-07-23 10:11:24 +00:00
channel2 = store . getChannel ( voiceChannelId ) ;
2026-07-20 16:05:17 +00:00
let type ;
if ( null != channel2 ) {
type = channel2 . type ;
}
if ( type !== ChannelTypes . GUILD_VOICE ) {
let type1 ;
if ( null != channel2 ) {
type1 = channel2 . type ;
}
if ( type1 !== ChannelTypes . GUILD_STAGE_VOICE ) {
if ( null != importDefaultResult ) {
let id ;
if ( null != channel2 ) {
id = channel2 . id ;
}
const _JSON = JSON ;
const _JSON2 = JSON ;
const obj1 = { guildId , channelId , messageId , jumpType , voiceChannelId , voiceGuildId , voiceMessageId } ;
const json1 = JSON . stringify ( location ) ;
const _HermesInternal = HermesInternal ;
importDefaultResult . log ( "UpdateSelectedChannelListener -> !!!VERY BAD!!! channel.id " + id + " (voiceChannelId " + voiceChannelId + ") is not a voice channel! and yet RouteUtils thinks it is! " + json1 + " " + JSON . stringify ( obj1 ) + " " ) ;
}
}
}
if ( null != importDefaultResult ) {
const _JSON3 = JSON ;
const json2 = JSON . stringify ( location ) ;
const _JSON4 = JSON ;
const obj2 = { guildId , channelId , messageId , jumpType , voiceChannelId , voiceGuildId , voiceMessageId } ;
const _HermesInternal2 = HermesInternal ;
importDefaultResult . verbose ( "UpdateSelectedChannelListener -> voice route present! " + json2 + " " + JSON . stringify ( obj2 ) + " " ) ;
}
2026-07-27 11:26:19 +00:00
let obj3 = channel2 ( 10627 ) ;
2026-07-20 16:05:17 +00:00
if ( ! obj3 . isVoicePanelEnabled ( channel2 ) ) {
2026-07-25 08:10:48 +00:00
const guild1 = importDefault ( 5049 ) . selectGuild ( voiceGuildId ) ;
const obj5 = importDefault ( 5049 ) ;
2026-07-20 16:05:17 +00:00
obj3 = { guildId : voiceGuildId , channelId : voiceChannelId , messageId : voiceMessageId , jumpType } ;
2026-07-25 08:10:48 +00:00
const channel3 = importDefault ( 4945 ) . selectChannel ( obj3 ) ;
const obj6 = importDefault ( 4945 ) ;
2026-07-20 16:05:17 +00:00
}
2026-07-25 08:10:48 +00:00
const obj8 = channel2 ( 3982 ) ;
2026-07-20 16:05:17 +00:00
if ( ! obj8 . isModalOpen ( obj9 . getVoiceChannelKey ( channel2 . id ) ) ) {
2026-07-25 08:10:48 +00:00
const obj10 = importDefault ( 4338 ) ;
obj10 . popAboveKey ( channel2 ( 4342 ) . getVoiceChannelKey ( channel2 . id ) ) ;
const obj11 = channel2 ( 4342 ) ;
2026-07-23 10:11:24 +00:00
importDefault ( 686 ) . wait ( ( ) = > {
channel2 ( outer1_2 [ 16 ] ) . openGuildVoiceModal ( channel2 ) ;
2026-07-20 16:05:17 +00:00
} ) ;
2026-07-23 10:11:24 +00:00
const obj12 = importDefault ( 686 ) ;
2026-07-20 16:05:17 +00:00
}
2026-07-25 08:10:48 +00:00
obj9 = channel2 ( 4342 ) ;
2026-07-20 16:05:17 +00:00
if ( tmp20 ) {
setVoiceChatDrawerState ( channel2 . id , VoiceChatDrawerState . OPEN ) ;
if ( tmp24 ) {
2026-07-25 08:10:48 +00:00
const obj13 = importDefault ( 4324 ) ;
2026-07-20 16:05:17 +00:00
const result = obj13 . jumpToVoiceChannelMessage ( voiceGuildId , voiceChannelId , voiceMessageId , jumpType ) ;
}
2026-07-23 10:11:24 +00:00
tmp24 = null != voiceGuildId && null != voiceChannelId && null != voiceMessageId ;
2026-07-20 16:05:17 +00:00
}
}
function extractParams ( arg0 ) {
let _location ;
let channelId ;
let guildId ;
let match ;
( { match , location : _location } = arg0 ) ;
if ( null == match ) {
2026-07-25 08:10:48 +00:00
let obj = { guildId : closure_11 , channelId : null , messageId : null , jumpType : require ( 4063 ) /* GuildThemeSourcePreference */ . JumpType . ANIMATED , skipMessageFetch : false } ;
2026-07-20 16:05:17 +00:00
return obj ;
} else {
const params = match . params ;
( { guildId , channelId } = params ) ;
2026-07-25 08:10:48 +00:00
if ( _location . jumpType === require ( 4063 ) /* GuildThemeSourcePreference */ . JumpType . INSTANT ) {
let ANIMATED = require ( 4063 ) /* GuildThemeSourcePreference */ . JumpType . INSTANT ;
2026-07-20 16:05:17 +00:00
} else {
2026-07-25 08:10:48 +00:00
ANIMATED = require ( 4063 ) /* GuildThemeSourcePreference */ . JumpType . ANIMATED ;
2026-07-20 16:05:17 +00:00
}
obj = { } ;
if ( ! obj2 . isValidGuildId ( guildId ) ) {
guildId = closure_11 ;
}
obj . guildId = guildId ;
2026-07-25 08:10:48 +00:00
obj2 = require ( 3966 ) /* isPseudoGuildId */ ;
2026-07-20 16:05:17 +00:00
let tmp9 = null ;
if ( obj3 . isValidChannelId ( channelId ) ) {
tmp9 = channelId ;
}
obj . channelId = tmp9 ;
obj . messageId = params . messageId ;
obj . jumpType = ANIMATED ;
obj . skipMessageFetch = _location . skipMessageFetch ;
return obj ;
}
}
function logRouteChange ( pathname ) {
importDefaultResult . log ( "Navigated to: " + pathname . pathname ) ;
}
2026-07-23 10:11:24 +00:00
let closure_3 = [ "channelId" , "guildId" ] ;
( { ME : closure_11 , Routes } = ME ) ;
const ChannelTypes = ME . ChannelTypes ;
2026-07-20 16:05:17 +00:00
importDefaultResult = new importDefaultResult ( "RouteUtils" ) ;
2026-07-23 10:11:24 +00:00
let c16 = false ;
2026-07-20 16:05:17 +00:00
const CHANNELResult = Routes . CHANNEL ( RouteParam . guildId ( ) , RouteParam2 . channelId ( { optional : true } ) , ":messageId?" ) ;
const guildIdResult = RouteParam . guildId ( ) ;
const items = [ "" + CHANNELResult + Routes . VOICE_CHAT_CHANNEL_PARTIAL ( RouteParam3 . guildId ( { name : "voiceGuildId" } ) , RouteParam4 . channelId ( { name : "voiceChannelId" } ) , ":voiceMessageId?" ) , CHANNELResult ] ;
const guildIdResult1 = RouteParam3 . guildId ( { name : "voiceGuildId" } ) ;
2026-07-23 10:11:24 +00:00
let result = require ( "_callSuper" ) . fileFinishedImporting ( "modules/routing/native/RouteManagerUtils.tsx" ) ;
2026-07-20 16:05:17 +00:00
export const MAIN_DRAWER_ROUTES = CHANNELResult ;
export { extractParamsFromVoiceModalRoute } ;
export const popVoiceRoute = function popVoiceRoute ( guildId ) {
const lastNonVoiceRoute = closure_8 . lastNonVoiceRoute ;
importDefaultResult . log ( "popVoiceRoute: last non-voice route is " + lastNonVoiceRoute ) ;
2026-07-25 08:10:48 +00:00
let obj = importDefault ( 4945 ) ;
2026-07-20 16:05:17 +00:00
obj = { guildId , channelId : selectLastVisitedTextChannel ( guildId ) } ;
const channel = obj . selectChannel ( obj ) ;
2026-07-23 10:11:24 +00:00
require ( 1198 ) /* shouldNavigate */ . transitionTo ( lastNonVoiceRoute ) ;
2026-07-20 16:05:17 +00:00
} ;
export const transitionToVoiceRoute = function transitionToVoiceRoute ( arg0 , arg1 ) {
const defaultRoute = closure_8 . defaultRoute ;
const tmp = matchPathToRoutes ( defaultRoute , items ) ;
let params ;
if ( null != tmp ) {
params = tmp . params ;
}
if ( null == params ) {
params = { } ;
}
const voiceChannelId = params . voiceChannelId ;
importDefaultResult . log ( "transitionToVoiceRoute(<" + arg0 + ">, <" + arg1 + ">), current route " + defaultRoute + " has voiceChannelId " + voiceChannelId ) ;
if ( voiceChannelId !== arg1 ) {
2026-07-23 10:11:24 +00:00
require ( 1198 ) /* shouldNavigate */ . transitionToGuild ( arg0 , arg1 ) ;
const obj2 = require ( 1198 ) /* shouldNavigate */ ;
2026-07-20 16:05:17 +00:00
} else {
const _HermesInternal = HermesInternal ;
importDefaultResult . log ( "transitionToVoiceRoute -> " + voiceChannelId + " === " + arg1 + ". staying where we are" ) ;
}
} ;
export { voiceRouteRewriter } ;
export { saveLastRouteListener } ;
export { saveLastNonVoiceRouteListener } ;
export { updateSelectedChannelListener } ;
export { extractParams } ;
export const initializeRouteManagerIfNeeded = function initializeRouteManagerIfNeeded() {
2026-07-23 10:11:24 +00:00
if ( ! c16 ) {
2026-07-27 11:26:19 +00:00
importDefault ( 10813 ) . addRouteRewriter ( voiceRouteRewriter ) ;
const obj = importDefault ( 10813 ) ;
const result = importDefault ( 10813 ) . addRouteChangeListener ( saveLastRouteListener ) ;
const obj2 = importDefault ( 10813 ) ;
const result1 = importDefault ( 10813 ) . addRouteChangeListener ( saveLastNonVoiceRouteListener ) ;
const obj3 = importDefault ( 10813 ) ;
const result2 = importDefault ( 10813 ) . addRouteChangeListener ( updateSelectedChannelListener ) ;
const obj4 = importDefault ( 10813 ) ;
const result3 = importDefault ( 10813 ) . addRouteChangeListener ( logRouteChange ) ;
const obj5 = importDefault ( 10813 ) ;
importDefault ( 10813 ) . initialize ( ) ;
2026-07-23 10:11:24 +00:00
c16 = true ;
2026-07-27 11:26:19 +00:00
const obj6 = importDefault ( 10813 ) ;
2026-07-20 16:05:17 +00:00
}
} ;
export const cleanupRouteManager = function cleanupRouteManager() {
2026-07-23 10:11:24 +00:00
if ( c16 ) {
2026-07-27 11:26:19 +00:00
importDefault ( 10813 ) . removeRouteRewriter ( voiceRouteRewriter ) ;
const obj = importDefault ( 10813 ) ;
const result = importDefault ( 10813 ) . removeRouteChangeListener ( saveLastRouteListener ) ;
const obj2 = importDefault ( 10813 ) ;
const result1 = importDefault ( 10813 ) . removeRouteChangeListener ( saveLastNonVoiceRouteListener ) ;
const obj3 = importDefault ( 10813 ) ;
const result2 = importDefault ( 10813 ) . removeRouteChangeListener ( updateSelectedChannelListener ) ;
const obj4 = importDefault ( 10813 ) ;
const result3 = importDefault ( 10813 ) . removeRouteChangeListener ( logRouteChange ) ;
const obj5 = importDefault ( 10813 ) ;
importDefault ( 10813 ) . cleanup ( ) ;
2026-07-23 10:11:24 +00:00
c16 = false ;
2026-07-27 11:26:19 +00:00
const obj6 = importDefault ( 10813 ) ;
2026-07-20 16:05:17 +00:00
}
} ;