Files
discord-decomp/sources/modules/application_commands/ApplicationCommandStore.tsx
T
2026-07-27 16:20:00 +03:00

349 lines
17 KiB
TypeScript

/* Metro module 7168; source: modules/application_commands/ApplicationCommandStore.tsx; dependencies: [6, 7, 15, 17, 18, 57, 4791, 1934, 5065, 566, 694, 2] */
function _fun57543(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#57543, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:6, offset: 0x013e8743, size: 396 bytes, params: 8, frame: 23
const env0_0 = require;
const closure = function() {
env0_10 = {};
return true;
};
const closure2 = APPLICATION_COMMAND_SET_ACTIVE_COMMAND_57549;
const closure3 = APPLICATION_COMMAND_SET_PREFERRED_COMMAND;
const closure4 = APPLICATION_COMMAND_UPDATE_OPTIONS;
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 env0_7 = importDefault(57) /* metro dependency 57 */;
const channelSectionStore = importDefault(4791) /* metro dependency 4791: ChannelSectionStore */;
const selectedChannelStore = importDefault(1934) /* metro dependency 1934: SelectedChannelStore */;
let env0_10 = {};
const Store = (importDefault(566) /* metro dependency 566: flux */).Store;
let value = _fun57553(Store);
value.displayName = 'ApplicationCommandStore';
value = new value(importDefault(694) /* metro dependency 694: Dispatcher */, {CONNECTION_OPEN: closure,
CHANNEL_SELECT: closure, LOGOUT: closure, APPLICATION_COMMAND_SET_ACTIVE_COMMAND: closure2,
APPLICATION_COMMAND_SET_PREFERRED_COMMAND: closure3, APPLICATION_COMMAND_UPDATE_OPTIONS: closure4,
APPLICATION_COMMAND_UPDATE_CHANNEL_STATE: APPLICATION_COMMAND_UPDATE_CHANNEL_STATE_57570});
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/application_commands/ApplicationCommandStore.tsx');
exports.default = value;
}
function _isNativeReflectConstruct_57544() { // fn#57544, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:178, offset: 0x013e88cf, 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_57544_isNativeReflectConstruct = function() {
return !!result;
})();
}
function getOrCreateChannelState_57548(a0) { // fn#57548, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:417, offset: 0x013e893a, size: 65 bytes, params: 2, frame: 5
if (!(a0 in env0_10)) {
env0_10[a0] = {'activeCommand': null, 'activeCommandSection': null, 'activeOptionName': null,
'preferredCommandId': null, 'optionStates': null, 'initialValues': null, 'commandOrigin': null,
optionStates: {}, initialValues: {}};
}
return env0_10[a0];
}
function APPLICATION_COMMAND_SET_ACTIVE_COMMAND_57549({channelId, command, section, initialValues, location, triggerSection, queryLength, sectionName, query, searchResultsPosition, source, commandOrigin}) { // fn#57549, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:625, offset: 0x013e897b, size: 328 bytes, params: 2, frame: 28
let value = undefined;
const orCreateChannelState_57548 = getOrCreateChannelState_57548(channelId);
const id = command == null ? value : command.id;
const activeCommand = orCreateChannelState_57548.activeCommand;
if (id === (activeCommand == null ? value : activeCommand.id)) {
return false;
}
orCreateChannelState_57548.activeCommand = command;
orCreateChannelState_57548.activeCommandSection = section;
orCreateChannelState_57548.activeOptionName = null;
orCreateChannelState_57548.preferredCommandId = null;
orCreateChannelState_57548.initialValues = initialValues ?? ({});
orCreateChannelState_57548.commandOrigin = commandOrigin ?? null;
orCreateChannelState_57548.source = source;
if ((command == null ? value : command.options) != null) {
command.options.forEach(_fun57550);
}
orCreateChannelState_57548.optionStates = {};
if (command != null) {
value = require(5065) /* metro dependency 5065: ApplicationCommandUtils */;
value.trackCommandSelected({command: command, location: location, triggerSection: triggerSection,
queryLength: queryLength, sectionName: sectionName, query: query,
searchResultsPosition: searchResultsPosition,
source: source});
}
return true;
}
function APPLICATION_COMMAND_SET_PREFERRED_COMMAND({channelId, commandId}) { // fn#57551, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:1419, offset: 0x013e8ae8, size: 130 bytes, params: 2, frame: 16
const getOrCreateChannelState_57548Binding = getOrCreateChannelState_57548;
const value = undefined;
const orCreateChannelState_57548Binding = getOrCreateChannelState_57548Binding(channelId);
let r0 = commandId !== orCreateChannelState_57548Binding.preferredCommandId && (orCreateChannelState_57548Binding.preferredCommandId !== null || commandId !== ((orCreateChannelState_57548Binding.activeCommand == null ? value : orCreateChannelState_57548Binding.activeCommand.id) ?? null));
if (r0) {
orCreateChannelState_57548Binding.activeCommand = null;
orCreateChannelState_57548Binding.activeOptionName = null;
orCreateChannelState_57548Binding.preferredCommandId = commandId;
orCreateChannelState_57548Binding.optionStates = {};
r0 = true;
}
return r0;
}
function APPLICATION_COMMAND_UPDATE_OPTIONS({channelId, changedOptionStates}) { // fn#57552, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:1735, offset: 0x013e8b6a, size: 589 bytes, params: 2, frame: 38
var r8;
var hasValue;
var isActive;
var lastValidationResult;
var r21;
var r27;
var r25;
var property;
var value5;
var property2;
var activeOptionName;
var property3;
var object2;
var optionValue;
var location;
var value6;
var value7;
var object5;
var activeOptionName2;
var value8;
const orCreateChannelState_57548 = getOrCreateChannelState_57548(channelId);
const object6 = {};
let optionStates = orCreateChannelState_57548.optionStates;
copyDataProperties(object6, optionStates, undefined);
const Object = global.Object;
const value3 = Object.entries(changedOptionStates);
let length = value3.length;
if (0 < length) {
r8 = 0;
while (true) {
property = value3[r8];
value5 = env0_7(property, 2);
property = value5[0];
property2 = value5[1];
optionStates = orCreateChannelState_57548.optionStates;
if (property in optionStates) {
hasValue = property2.hasValue;
hasValue = hasValue !== undefined ? property2.hasValue : object6[property].hasValue;
if (hasValue) {
property3 = object6[property];
object2 = {hasValue: true};
isActive = property2.isActive;
isActive = isActive !== undefined ? property2.isActive : property3.isActive;
object2.isActive = isActive;
lastValidationResult = property2.lastValidationResult;
lastValidationResult = lastValidationResult !== undefined ? property2.lastValidationResult : property3.lastValidationResult;
object2.lastValidationResult = lastValidationResult;
optionValue = property2.optionValue;
if (optionValue != null) {
r21 = optionValue;
continue;
}
optionValue = property3.optionValue;
r21 = optionValue;
object2.optionValue = r21;
location = property2.location;
if (location != null) {
r21 = location;
continue;
}
location = property3.location;
r21 = location;
object2.location = r21;
length = property2.length;
if (length != null) {
r27 = length;
continue;
}
r27 = property3.length;
object2.length = r27;
object6[property] = object2;
isActive = property2.isActive;
if (isActive === undefined) {
break;
}
isActive = property2.isActive;
activeOptionName = orCreateChannelState_57548.activeOptionName;
if (isActive) {
value6 = activeOptionName != null;
if (!value6) {
r25 = value6;
continue;
}
activeOptionName = orCreateChannelState_57548.activeOptionName;
value7 = activeOptionName !== property;
r25 = value7;
if (!r25) {
continue;
}
activeOptionName = orCreateChannelState_57548.activeOptionName;
object5 = {};
activeOptionName2 = orCreateChannelState_57548.activeOptionName;
copyDataProperties(object5, object6[activeOptionName2], undefined);
object6[activeOptionName] = object5;
activeOptionName = orCreateChannelState_57548.activeOptionName;
object6[activeOptionName].isActive = false;
orCreateChannelState_57548.activeOptionName = property;
break;
}
if (property !== activeOptionName) {
break;
}
orCreateChannelState_57548.activeOptionName = null;
break;
}
object6[property] = {'hasValue': false, 'isActive': false, 'lastValidationResult': null,
'optionValue': null,
location: undefined, length: undefined};
activeOptionName = orCreateChannelState_57548.activeOptionName;
if (activeOptionName !== property) {
break;
}
orCreateChannelState_57548.activeOptionName = null;
break;
}
value8 = typeof r8 === 'bigint' ? r8 + 1n : +r8 + 1;
length = value3.length;
if (value8 < length) {
r8 = value8;
continue;
}
break;
}
}
orCreateChannelState_57548.optionStates = object6;
return true;
}
function _fun57553(a0) { // fn#57553, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:2763, offset: 0x013e8db7, size: 329 bytes, params: 2, frame: 16
const closure = ApplicationCommandStore;
env0_6(closure, a0);
return env0_3(closure, [{key: 'initialize', value: function() {
this.waitFor(ChannelSectionStore, SelectedChannelStore);
ChannelSectionStore.addChangeListener(_fun57556);
}}, {key: 'getActiveCommand', value: function(a0) {
return getOrCreateChannelState_57548(a0).activeCommand;
}}, {key: 'getActiveCommandSection', value: function(a0) {
return getOrCreateChannelState_57548(a0).activeCommandSection;
}}, {key: 'getActiveOptionName', value: function(a0) {
return getOrCreateChannelState_57548(a0).activeOptionName;
}}, {key: 'getActiveOption', value: value_57560}, {key: 'getPreferredCommandId', value: function(a0) {
return getOrCreateChannelState_57548(a0).preferredCommandId;
}}, {key: 'getOptionStates', value: function(a0) {
return getOrCreateChannelState_57548(a0).optionStates;
}}, {key: 'getOptionState', value: function(a0, a1) {
return getOrCreateChannelState_57548(a0).optionStates[a1];
}}, {key: 'getCommandOrigin', value: function(a0) {
return getOrCreateChannelState_57548(a0).commandOrigin;
}}, {key: 'getSource', value: function(a0) {
return getOrCreateChannelState_57548(a0).source;
}}, {key: 'getOption', value: value_57567}, {key: 'getState', value: function(a0) {
var object = {};
var getOrCreateChannelState_57548Binding = getOrCreateChannelState_57548;
copyDataProperties(object, getOrCreateChannelState_57548Binding(a0), getOrCreateChannelState_57548Binding);
return object;
}}]);
}
function APPLICATION_COMMAND_UPDATE_CHANNEL_STATE_57570({channelId, preferredCommandId, command, section, location, changedOptionStates}) { // fn#57570, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:4868, offset: 0x013e9140, size: 152 bytes, params: 2, frame: 18
const value2 = APPLICATION_COMMAND_SET_ACTIVE_COMMAND_57549({type: 'APPLICATION_COMMAND_SET_ACTIVE_COMMAND',
channelId: channelId, command: command, section: section, location: location});
const value3 = APPLICATION_COMMAND_SET_PREFERRED_COMMAND({type: 'APPLICATION_COMMAND_SET_PREFERRED_COMMAND',
channelId: channelId, commandId: preferredCommandId});
APPLICATION_COMMAND_UPDATE_OPTIONS({type: 'APPLICATION_COMMAND_UPDATE_OPTIONS', channelId: channelId,
changedOptionStates: changedOptionStates});
let r0 = value2 || value3;
r0 = !r0 || r0;
return r0;
}
function _fun57550({name}) { // fn#57550, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:1165, offset: 0x013e8ac3, size: 37 bytes, params: 2, frame: 3
env0_0[name] = {'isActive': false, 'hasValue': false, 'lastValidationResult': null, 'optionValue': null};
}
function value_57555() { // fn#57555, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:3108, offset: 0x013e8f00, size: 48 bytes, params: 1, frame: 13
this.waitFor(ChannelSectionStore, SelectedChannelStore);
ChannelSectionStore.addChangeListener(_fun57556);
}
function value_57560(a0) { // fn#57560, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:3631, offset: 0x013e8fe7, size: 84 bytes, params: 2, frame: 14
var environment;
let value = environment.__proto__;
const getOrCreateChannelState_57548Binding = getOrCreateChannelState_57548;
value = undefined;
const activeCommand = getOrCreateChannelState_57548Binding(a0).activeCommand;
const value3 = null;
const r1 = value3 == activeCommand || value3 == activeCommand.options ? value : activeCommand.options.find(_fun57561);
return value3 != r1 ? r1 : value3;
}
function value_57567(a0, a1) { // fn#57567, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:4280, offset: 0x013e90d9, size: 75 bytes, params: 3, frame: 14
var environment;
const env0_0 = a1;
let value = environment.__proto__;
const getOrCreateChannelState_57548Binding = getOrCreateChannelState_57548;
value = undefined;
const activeCommand = getOrCreateChannelState_57548Binding(a0).activeCommand;
return activeCommand == null || activeCommand.options == null ? value : activeCommand.options.find(function({name}) {
return name === require;
});
}
function _fun57556() { // fn#57556, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:3158, offset: 0x013e8f30, size: 108 bytes, params: 1, frame: 13
var object;
const channelId = SelectedChannelStore.getChannelId();
if (channelId == null) {
env2_10 = {};
return true;
}
const currentSidebarChannelId = ChannelSectionStore.getCurrentSidebarChannelId(channelId);
if (currentSidebarChannelId == null) {
if (channelId in env2_10) {
({})[channelId] = env2_10[channelId];
} else {
object = {};
}
} else {
if (currentSidebarChannelId in env2_10) {
return false;
}
if (channelId in env2_10) {
({})[channelId] = env2_10[channelId];
} else {
object = {};
}
}
}
function _fun57561({name}) { // fn#57561, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7346:3758, offset: 0x013e903b, size: 27 bytes, params: 2, frame: 2
return name === env0_0.activeOptionName;
}