/* Metro module 7167; source: modules/application_commands/ApplicationCommandAutocompleteStore.tsx; dependencies: [6, 7, 15, 17, 18, 7168, 661, 477, 1909, 4863, 566, 694, 2] */ function _fun57523(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#57523, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:6, offset: 0x013e7d30, size: 508 bytes, params: 8, frame: 22 const env0_0 = require; const closure = CONNECTION_OPEN_57528; const closure2 = APPLICATION_COMMAND_SET_ACTIVE_COMMAND; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_2 = importDefault(6) /* metro dependency 6 */; const env0_3 = importDefault(7) /* metro dependency 7 */; const env0_4 = importDefault(15) /* metro dependency 15 */; const env0_5 = importDefault(17) /* metro dependency 17 */; const env0_6 = importDefault(18) /* metro dependency 18 */; const applicationCommandStore = importDefault(7168) /* metro dependency 7168: ApplicationCommandStore */; const env0_8 = (require(661) /* metro dependency 661: Constants */).AnalyticEvents; let Map = global.Map; let map = new Map(); Map = global.Map; map = new Map(); Map = global.Map; map = new Map(); const env0_12 = (require(477) /* metro dependency 477: PlatformUtils */).isDesktop(); const Store = (importDefault(566) /* metro dependency 566: flux */).Store; _fun57531(Store).displayName = 'ApplicationCommandAutocompleteStore'; map = new map(importDefault(694) /* metro dependency 694: Dispatcher */, {CONNECTION_OPEN: closure, LOGOUT: closure, CHANNEL_SELECT: closure, APPLICATION_COMMAND_AUTOCOMPLETE_REQUEST: APPLICATION_COMMAND_AUTOCOMPLETE_REQUEST, APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE: APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE, INTERACTION_FAILURE: INTERACTION_FAILURE_57541, APPLICATION_COMMAND_SET_ACTIVE_COMMAND: closure2, APP_LAUNCHER_SET_ACTIVE_COMMAND: closure2, APPLICATION_COMMAND_UPDATE_CHANNEL_STATE: APPLICATION_COMMAND_UPDATE_CHANNEL_STATE}); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/application_commands/ApplicationCommandAutocompleteStore.tsx'); exports.default = map; } function _isNativeReflectConstruct_57524() { // fn#57524, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:183, offset: 0x013e7f2c, size: 94 bytes, params: 1, frame: 18 var Boolean; var prototype; var valueOf; var call; var Reflect; var construct; var closure; var value; var error; try { Boolean = global.Boolean; prototype = Boolean.prototype; valueOf = prototype.valueOf; call = valueOf.call; Reflect = global.Reflect; construct = Reflect.construct; Boolean = global.Boolean; closure = function() { }; value = Reflect.apply(construct, Reflect, [Boolean, [], closure]); value = Reflect.apply(call, valueOf, [value]); var result = !value; } catch (error) { } return (_isNativeReflectConstruct_57524_isNativeReflectConstruct = function() { return !!result; })(); } function getOrCreateChannelState(a0) { // fn#57527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:410, offset: 0x013e7f8a, size: 255 bytes, params: 2, frame: 18 var set; var object2; var activeCommand; var value3; var Map; var prototype; var value4; var map; var value6; var value8; var value10; let binding = env0_10; if (!binding.has(a0)) { binding = env0_10; set = binding.set; object2 = {}; activeCommand = ApplicationCommandStore.getActiveCommand(a0); value3 = undefined; object2.commandId = activeCommand == null ? value3 : activeCommand.id; object2.optionName = ApplicationCommandStore.getActiveOptionName(a0); Map = global.Map; prototype = Map.prototype; value4 = Object.create(prototype, {constructor: {value: Map}}); map = new Map(); object2.optionNameToAutocompleteQueries = map instanceof Object ? map : value4; Map = global.Map; prototype = Map.prototype; value6 = Object.create(prototype, {constructor: {value: Map}}); map = new Map(); object2.optionNameToLastResults = map instanceof Object ? map : value6; Map = global.Map; prototype = Map.prototype; value8 = Object.create(prototype, {constructor: {value: Map}}); map = new Map(); object2.optionNameToNonce = map instanceof Object ? map : value8; Map = global.Map; prototype = Map.prototype; value10 = Object.create(prototype, {constructor: {value: Map}}); map = new Map(); object2.optionNameToLastQuery = map instanceof Object ? map : value10; object2.lastErrored = false; object2.lastResponseNonce = value3; Reflect.apply(set, binding, [a0, object2]); } return env0_10.get(a0); } function CHANNEL_SELECT_57528() { // fn#57528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:747, offset: 0x013e8089, size: 35 bytes, params: 1, frame: 10 env0_9.clear(); env0_10.clear(); return true; } function APPLICATION_COMMAND_SET_ACTIVE_COMMAND({channelId, command}) { // fn#57529, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:825, offset: 0x013e80ac, size: 47 bytes, params: 2, frame: 15 handleCommandChange(channelId, command?.id); } function handleCommandChange(a0, a1) { // fn#57530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:925, offset: 0x013e80db, size: 184 bytes, params: 3, frame: 15 const activeOptionName = ApplicationCommandStore.getActiveOptionName(a0); let value = env0_10.get(a0); let r0 = value != null && (a1 !== value.commandId || activeOptionName !== value.optionName); if (r0) { if (a1 != null && a1 !== value.commandId) { value.optionNameToLastResults.clear(); value.optionNameToNonce.clear(); value.optionNameToLastQuery.clear(); value.optionNameToAutocompleteQueries.clear(); } value.lastErrored = false; value.commandId = a1; value.optionName = activeOptionName; value = true; r0 = value; } return r0; } function _fun57531(a0) { // fn#57531, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:1275, offset: 0x013e8193, size: 164 bytes, params: 2, frame: 16 const closure = ApplicationCommandAutocompleteStore; env0_6(closure, a0); return env0_3(closure, [{key: 'initialize', value: function() { this.waitFor(ApplicationCommandStore); }}, {key: 'getLastErrored', value: function(a0) { return getOrCreateChannelState(a0).lastErrored; }}, {key: 'getAutocompleteChoices', value: value_57535}, {key: 'getAutocompleteLastChoices', value: function(a0, a1) { return getOrCreateChannelState(a0).optionNameToLastResults.get(a1); }}, {key: 'getLastResponseNonce', value: function(a0) { return getOrCreateChannelState(a0).lastResponseNonce; }}]); } function APPLICATION_COMMAND_AUTOCOMPLETE_REQUEST({nonce, channelId, query, name}) { // fn#57538, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:2382, offset: 0x013e82cb, size: 303 bytes, params: 2, frame: 20 var r1; const orCreateChannelState = getOrCreateChannelState(channelId); let optionNameToLastQuery = orCreateChannelState.optionNameToLastQuery; const get = optionNameToLastQuery.get; if (Reflect.apply(get, optionNameToLastQuery, [name]) === query) { return false; } optionNameToLastQuery = orCreateChannelState.optionNameToLastQuery; let set = optionNameToLastQuery.set; Reflect.apply(set, optionNameToLastQuery, [name, query]); const r2 = orCreateChannelState.optionNameToAutocompleteQueries.get(name)?.get(query); if (r2 != null) { orCreateChannelState.lastErrored = false; orCreateChannelState.optionNameToLastResults.set(name, r2); return true; } const value6 = orCreateChannelState.optionNameToNonce.get(name); if (value6 != null) { env0_9.delete(value6); } let binding = env0_9; binding.set(nonce, {channelId: channelId, query: query, name: name}); binding = env0_11; set = binding.set; const Date = global.Date; Reflect.apply(set, binding, [nonce, new Date()]); orCreateChannelState.optionNameToNonce.set(name, nonce); if (orCreateChannelState.lastErrored) { orCreateChannelState.lastErrored = false; r1 = true; } else { r1 = undefined; } return r1; } function APPLICATION_COMMAND_AUTOCOMPLETE_RESPONSE({choices, nonce}) { // fn#57539, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:2966, offset: 0x013e83fa, size: 534 bytes, params: 2, frame: 22 var r5; var r3; var set; var Map; var value5; var map; var value7; var Date; var value12; var date; var optionNameToLastResults; let value = undefined; let binding = env0_9; let get = binding.get; const value3 = Reflect.apply(get, binding, [nonce]); if (value3 == null) { return false; } env0_9.delete(nonce); const orCreateChannelState = getOrCreateChannelState(value3.channelId); let optionNameToAutocompleteQueries = orCreateChannelState.optionNameToAutocompleteQueries; get = optionNameToAutocompleteQueries.get; let name = value3.name; if (Reflect.apply(get, optionNameToAutocompleteQueries, [name]) == null) { optionNameToAutocompleteQueries = orCreateChannelState.optionNameToAutocompleteQueries; set = optionNameToAutocompleteQueries.set; name = value3.name; Map = global.Map; value5 = Object.create(Map.prototype, {constructor: {value: Map}}); map = new Map(); Reflect.apply(set, optionNameToAutocompleteQueries, [name, map instanceof Object ? map : value5]); } binding = env0_12; if (binding) { value7 = ApplicationCommandStore.getActiveOption(value3.channelId); r5 = (value7 == null ? value : value7.type) === (require(1909) /* metro dependency 1909: Server */).ApplicationCommandOptionType.INTEGER; } else { r5 = binding; } r5 = choices == null ? value : choices.map(_fun57540); r5 = r5 ?? []; const value10 = env0_11.get(nonce); if (value10 != null) { Date = global.Date; value12 = Object.create(Date.prototype, {constructor: {value: Date}}); date = new Date(); r3 = (date instanceof Object ? date : value12).getTime() - value10.getTime(); } else { r3 = 0; } value = require(4863) /* metro dependency 4863: AppAnalyticsUtils */; const trackWithMetadata = value.trackWithMetadata; const APPLICATION_COMMAND_OPTION_STRING_AUTOCOMPLETE_PERFORMANCE = AnalyticEvents.APPLICATION_COMMAND_OPTION_STRING_AUTOCOMPLETE_PERFORMANCE; Reflect.apply(trackWithMetadata, value, [APPLICATION_COMMAND_OPTION_STRING_AUTOCOMPLETE_PERFORMANCE, {duration_ms: r3, error: false, num_options: r5.length}]); env0_11.delete(nonce); value = orCreateChannelState.optionNameToAutocompleteQueries.get(value3.name); if (value != null) { value.set(value3.query, r5); } const optionNameToLastQuery = orCreateChannelState.optionNameToLastQuery; get = optionNameToLastQuery.get; if (Reflect.apply(get, optionNameToLastQuery, [value3.name]) === value3.query) { orCreateChannelState.lastErrored = false; optionNameToLastResults = orCreateChannelState.optionNameToLastResults; optionNameToLastResults.set(value3.name, r5); } orCreateChannelState.lastResponseNonce = nonce; return true; } function INTERACTION_FAILURE_57541({nonce}) { // fn#57541, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:3927, offset: 0x013e865b, size: 232 bytes, params: 2, frame: 19 var r0; var Date; var value5; var date; if (nonce == null) { return false; } const value2 = env0_9.get(nonce); if (value2 == null) { return false; } env0_9.delete(nonce); const value3 = env0_11.get(nonce); if (value3 != null) { Date = global.Date; value5 = Object.create(Date.prototype, {constructor: {value: Date}}); date = new Date(); r0 = (date instanceof Object ? date : value5).getTime() - value3.getTime(); } else { r0 = 0; } const appAnalyticsUtilsModule = require(4863) /* metro dependency 4863: AppAnalyticsUtils */; const trackWithMetadata = appAnalyticsUtilsModule.trackWithMetadata; const APPLICATION_COMMAND_OPTION_STRING_AUTOCOMPLETE_PERFORMANCE = AnalyticEvents.APPLICATION_COMMAND_OPTION_STRING_AUTOCOMPLETE_PERFORMANCE; Reflect.apply(trackWithMetadata, appAnalyticsUtilsModule, [APPLICATION_COMMAND_OPTION_STRING_AUTOCOMPLETE_PERFORMANCE, {duration_ms: r0, error: true}]); env0_11.delete(nonce); getOrCreateChannelState(value2.channelId).lastErrored = true; return true; } function value_57535(a0, a1, a2) { // fn#57535, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:1833, offset: 0x013e8250, size: 60 bytes, params: 4, frame: 12 let value = environment.__proto__; const getOrCreateChannelStateBinding = getOrCreateChannelState; value = undefined; const value2 = getOrCreateChannelStateBinding(a0).optionNameToAutocompleteQueries.get(a1); return value2 == null ? value : value2.get(a2); } function _fun57540({value, name_localized, name}) { // fn#57540, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7345:3390, offset: 0x013e8610, size: 75 bytes, params: 2, frame: 14 var r1; const object2 = {}; object2.displayName = name_localized ?? name; object2.name = name; if (env0_0) { value = global.Number(value); r1 = value; } else { r1 = value; } object2.value = r1; return object2; }