/* Metro module 11661; source: modules/app_launcher/hooks/useAppLauncherFrecents.tsx; dependencies: [31, 5109, 1878, 11662, 4237, 5066, 1909, 8060, 566, 6779, 4122, 11663, 8040, 8046, 10657, 2] */ import UserStore from '../../../stores/UserStore.tsx'; /* Metro dependency 1878 */ import AuthorizedAppsStore from '../../../stores/AuthorizedAppsStore.tsx'; /* Metro dependency 5109 */ import AppLauncherLastUsedCommandStore from '../AppLauncherLastUsedCommandStore.tsx'; /* Metro dependency 11662 */ import * as FileImportTrackerModule from '../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ReactModule from '../../../by-id/module-00031-React.js'; /* Metro dependency 31 */ import * as ServerModule from '../../../flow/Server.tsx'; /* Metro dependency 1909 */ import * as ConstantsModule from '../../activities/Constants.tsx'; /* Metro dependency 4237 */ import * as ApplicationCommandConstantsModule from '../../application_commands/ApplicationCommandConstants.tsx'; /* Metro dependency 5066 */ import * as AuthorizedAppsStoreModule from '../../../stores/AuthorizedAppsStore.tsx'; /* Metro dependency 5109 */ import * as ApplicationCommandQueryApiModule from '../../application_commands/ApplicationCommandQueryApi.tsx'; /* Metro dependency 8060 */ import * as ApplicationFrecencyHooksModule from '../../applications/ApplicationFrecencyHooks.tsx'; /* Metro dependency 11663 */ function _fun89378(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#89378, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:6, offset: 0x0200c0da, size: 360 bytes, params: 8, frame: 20 const env0_0 = require; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const DISCOVERY_COMMANDS_QUERY_LIMIT = ApplicationCommandConstantsModule.DISCOVERY_COMMANDS_QUERY_LIMIT; object = {}; const {CHAT, PRIMARY_ENTRY_POINT} = (ServerModule).ApplicationCommandType; object.commandTypes = [CHAT, PRIMARY_ENTRY_POINT]; ({'placeholderCount': 0, 'limit': null, 'includeFrecency': true}).limit = DISCOVERY_COMMANDS_QUERY_LIMIT; (FileImportTrackerModule).fileFinishedImporting('modules/app_launcher/hooks/useAppLauncherFrecents.tsx'); exports.default = useAppLauncherFrecentCommandsAndApps; exports.useAppLauncherFrecentApps = useAppLauncherFrecentApps; function useFrecentApps({sectionDescriptors, context, onlyActivityApps, includeAuthorizedAppsAndFetch}) { // fn#89379, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:415, offset: 0x0200c242, size: 362 bytes, params: 2, frame: 23 ReactModule.useEffect(_fun89381, [includeAuthorizedAppsAndFetch, (require(566) /* metro dependency 566: flux */).useStateFromStores([AuthorizedAppsStore], function() { return AuthorizedAppsStore.getFetchState(); })]); return ReactModule.useMemo(_fun89387, [onlyActivityApps, (ApplicationFrecencyHooksModule).useSortApplicationsViaFrecency(sectionDescriptors.filter(_fun89384), (require(566) /* metro dependency 566: flux */).useStateFromStoresArray([AuthorizedAppsStore], _fun89382)), context, ReactModule.useMemo(_fun89385, [context.type === 'contextless']), (require(566) /* metro dependency 566: flux */).useStateFromStores([UserStore], _fun89386)]); function _fun89381() { // fn#89381, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:599, offset: 0x0200c3bf, size: 73 bytes, params: 1, frame: 11 var r0; var fetchStateBinding; var value; const includeAuthorizedAppsAndFetchBinding = includeAuthorizedAppsAndFetch; if (includeAuthorizedAppsAndFetchBinding) { fetchStateBinding = fetchState; value = environment.__proto__; value = fetchStateBinding === FetchState.NOT_FETCHED; r0 = value; } else { r0 = includeAuthorizedAppsAndFetchBinding; } if (r0) { value = environment.__proto__; value = importDefault(6779) /* metro dependency 6779: AuthorizedAppsActionCreators */; value.fetch(); } } function _fun89382() { // fn#89382, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:694, offset: 0x0200c408, size: 54 bytes, params: 1, frame: 12 var environment; var r0; var value; if (includeAuthorizedAppsAndFetch) { value = environment.__proto__; value = AuthorizedAppsStore.getNewestTokens(); value = value.filter(function({scopes}) { return scopes.includes(require(dependencyMap[10]).OAuth2Scopes.APPLICATIONS_COMMANDS); }); r0 = value; } else { r0 = []; } return r0; } function _fun89384(a0) { // fn#89384, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:813, offset: 0x0200c478, size: 49 bytes, params: 2, frame: 4 const id = a0.id; const value = environment.__proto__; const FRECENCY = BuiltInSectionId.FRECENCY; return id !== FRECENCY && a0.id !== BuiltInSectionId.BUILT_IN; } function _fun89385() { // fn#89385, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:893, offset: 0x0200c4a9, size: 33 bytes, params: 1, frame: 11 var push; const items2 = []; if (result) { push = items2.push; value = environment.__proto__; Reflect.apply(push, items2, [WATCH_YOUTUBE_PROD_APP_ID]); } return items2; } function _fun89386() { // fn#89386, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1017, offset: 0x0200c4ca, size: 35 bytes, params: 1, frame: 10 const value = environment.__proto__; return UserStore.getCurrentUser()?.nsfwAllowed; } function _fun89387() { // fn#89387, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1106, offset: 0x0200c4ed, size: 93 bytes, params: 1, frame: 14 var r0; const hideAgeRestricted2 = hideAgeRestricted; var value; const onlyActivityAppsBinding = onlyActivityApps; const filter = AuthorizedAppsStoreModule.FetchState.filter; if (onlyActivityAppsBinding) { value = Reflect.apply(filter, AuthorizedAppsStoreModule.FetchState, [_fun89389]); value = value.filter(_fun89390); value = value.filter(hideAgeRestricted2); r0 = value; } else { value = Reflect.apply(filter, AuthorizedAppsStoreModule.FetchState, [_fun89391]); value = value.filter(hideAgeRestricted2); r0 = value; } return r0; function hideAgeRestricted(a0) { // fn#89388, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1133, offset: 0x0200c54a, size: 59 bytes, params: 2, frame: 12 var r0; let value = environment.__proto__; value = env1_7 === false; if (value) { value = environment.__proto__.__proto__; value = importDefault(8040) /* metro dependency 8040: isApplicationAgeRestricted */; value = value(a0.id); r0 = value; } else { r0 = value; } return !r0; } function _fun89389(a0) { // fn#89389, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1181, offset: 0x0200c585, size: 116 bytes, params: 2, frame: 15 var r0; var queryForPrimaryAppCommand; var value2; let value = a0.application != null; if (value) { value = environment.__proto__.__proto__; value = require(8046) /* metro dependency 8046: AppLauncherUtils */; value = value.isEmbeddedApp(a0.application); r0 = value; } else { r0 = value; } if (r0) { value = environment.__proto__.__proto__; value = require(10657) /* metro dependency 10657: getPrimaryAppCommand */; queryForPrimaryAppCommand = value.queryForPrimaryAppCommand; value2 = environment.__proto__; value = Reflect.apply(queryForPrimaryAppCommand, value, [context, a0.id]) != null; r0 = value; } return r0; } function _fun89390({id}) { // fn#89390, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1303, offset: 0x0200c5f9, size: 30 bytes, params: 2, frame: 11 const binding = env1_5; return !binding.includes(id); } function _fun89391({id}) { // fn#89391, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1362, offset: 0x0200c5f9, size: 30 bytes, params: 2, frame: 11 const binding = env1_5; return !binding.includes(id); } } } function useAppLauncherFrecentCommandsAndApps({context, onlyActivityApps}) { // fn#89392, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1524, offset: 0x0200c617, size: 304 bytes, params: 2, frame: 24 const {commands, commandsByActiveSection, sectionDescriptors, filterSection, loading} = (ApplicationCommandQueryApiModule).useDiscovery({context: context, filters: env0_11, options: env0_12, allowFetch: true}); lastUsedCommandId2.useEffect(function() { filterSection(BuiltInSectionId.FRECENCY); }, [filterSection]); const lastUsedCommandId = (require(566) /* metro dependency 566: flux */).useStateFromStores([AppLauncherLastUsedCommandStore], function() { return AppLauncherLastUsedCommandStore.getLastUsedCommandId(); }); var lastUsedCommandId2 = lastUsedCommandId; object = {loading: loading}; object.frecencyCommands = lastUsedCommandId2.useMemo(_fun89395, [commands, commandsByActiveSection, lastUsedCommandId, onlyActivityApps]); object.frecentApps = useFrecentApps({sectionDescriptors: sectionDescriptors, context: context, onlyActivityApps: onlyActivityApps, includeAuthorizedAppsAndFetch: true}); object.sectionDescriptors = sectionDescriptors; return object; function _fun89395() { // fn#89395, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:1923, offset: 0x0200c779, size: 121 bytes, params: 1, frame: 16 var r0; var items2; if (onlyActivityApps) { return []; } const r4 = commandsByActiveSection[0]?.data ?? []; const commandsBinding = commands; let value = commandsBinding.find(function({id}) { return id === lastUsedCommandId; }); if (value == null) { r0 = r4; } else { items2 = [value]; value = r4.filter(function({id}) { return id !== lastUsedCommandId; }); arraySpread(items2, value, 1, commandsBinding); r0 = items2; } return r0; } } function useAppLauncherFrecentApps({context, onlyActivityApps, allowCommandFetch, includeAuthorizedAppsAndFetch}) { // fn#89398, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:11847:2249, offset: 0x0200c81c, size: 148 bytes, params: 2, frame: 18 const value2 = (ApplicationCommandQueryApiModule).useDiscovery({context: context, filters: env0_11, options: env0_12, allowFetch: allowCommandFetch}); const sectionDescriptors = value2.sectionDescriptors; object = {}; object.loading = value2.loading; object.frecentApps = useFrecentApps({sectionDescriptors: sectionDescriptors, context: context, onlyActivityApps: onlyActivityApps, includeAuthorizedAppsAndFetch: includeAuthorizedAppsAndFetch}); return object; } } global.__d(_fun89378, 11661, [31, 5109, 1878, 11662, 4237, 5066, 1909, 8060, 566, 6779, 4122, 11663, 8040, 8046, 10657, 2]) /* metro module 11661, dependencies: [31, 5109, 1878, 11662, 4237, 5066, 1909, 8060, 566, 6779, 4122, 11663, 8040, 8046, 10657, 2] */;