Files
discord-decomp/sources/modules/application_commands/ApplicationCommandOptionUtils.tsx
T
2026-07-28 01:06:53 +03:00

438 lines
19 KiB
TypeScript

/* Metro module 8051; source: modules/application_commands/ApplicationCommandOptionUtils.tsx; dependencies: [5066, 44, 8052, 4100, 1909, 2] */
import defaultImport2 from '../../by-id/module-00044.js'; /* Metro dependency 44 */
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ServerModule from '../../flow/Server.tsx'; /* Metro dependency 1909 */
import * as ApplicationCommandConstantsModule from './ApplicationCommandConstants.tsx'; /* Metro dependency 5066 */
import * as NumberPartsModule from '../../intl/number-parts.tsx'; /* Metro dependency 8052 */
function _fun63857(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#63857, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:6, offset: 0x01b93765, size: 308 bytes, params: 8, frame: 24
let env0_0 = require;
const _arrayLikeToArray_63860 = function(a0, a1) {
var r0;
var r1;
var r2;
var value3;
var length;
var value5;
var value = undefined;
var value2 = value == null;
reducibleJoin2: while (true) {
if (value2) {
r0 = value2;
break reducibleJoin2;
}
value3 = value > a0.length;
r0 = value3;
break reducibleJoin2;
}
reducibleJoin4: while (true) {
if (r0) {
length = a0.length;
r1 = length;
break reducibleJoin4;
}
r1 = value;
break reducibleJoin4;
}
value = (0, global.Array)(r1);
var value4 = 0;
if (value4 < r1) {
r2 = value4;
reducibleLoop5: while (true) {
value[r2] = a0[r2];
value5 = typeof r2 === 'bigint' ? r2 + 1n : +r2 + 1;
if (value5 < r1) {
r2 = value5;
continue reducibleLoop5;
}
break reducibleLoop5;
}
}
return value;
};
const closure = function(a0) {
var env0_0 = a0;
return a0 == null ? [] : a0.filter(_fun63862);
};
const getBoolean2 = getBoolean;
const getChannelId2 = getChannelId;
const getUserId_638652 = getUserId_63865;
const getRoleId2 = getRoleId;
const getString_638672 = getString_63867;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
(FileImportTrackerModule).fileFinishedImporting('modules/application_commands/ApplicationCommandOptionUtils.tsx');
exports.filterEmpty = closure;
exports.getBoolean = getBoolean2;
exports.getOptionalBoolean = getOptionalBoolean;
exports.getChannelId = getChannelId2;
exports.getOptionalChannelId = getOptionalChannelId;
exports.getUserId = getUserId_638652;
exports.getOptionalUserId = getOptionalUserId;
exports.getRoleId = getRoleId2;
exports.getOptionalRoleId = getOptionalRoleId;
exports.getString = getString_638672;
exports.getOptionalString = getOptionalString;
exports.normalizeNumericString = normalizeNumericString;
exports.getInitialValuesFromInteractionOptions = getInitialValuesFromInteractionOptions;
function _createForOfIteratorHelperLoose_63858(a0, a1) { // fn#63858, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:134, offset: 0x01b93899, size: 370 bytes, params: 3, frame: 20
var r6;
var r9;
var r5;
var value3;
var regexp;
const env0_0 = a0;
const Symbol = global.Symbol;
let value = typeof Symbol !== 'undefined';
let r1 = value && a0[global.Symbol.iterator];
r1 = !r1 ? a0['@@iterator'] : r1;
if (r1) {
value = r1.call(a0);
return value.next.bind(value);
}
const Array = global.Array;
if (Array.isArray(a0)) {
if (r1) {
}
return _fun63859;
}
value = undefined;
if (a0) {
if (typeof a0 === 'string') {
value = _arrayLikeToArray_63860(a0, value);
r5 = value;
} else {
value3 = ({}).toString.call(a0).slice(8, -1);
r6 = value3 === 'Object' && a0.constructor;
r9 = r6 ? a0.constructor.name : value3;
if (r9 === 'Map') {
r6 = global.Array.from(a0);
} else if (r9 === 'Set') {
r6 = global.Array.from(a0);
} else if (r9 === 'Arguments') {
value = _arrayLikeToArray_63860(a0, value);
r6 = value;
} else {
regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', '');
if (regexp.test(r9)) {
value = _arrayLikeToArray_63860(a0, value);
r6 = value;
} else {
r6 = value;
}
}
r5 = r6;
}
} else {
r5 = value;
}
if (r5) {
if (r5) {
}
return _fun63859;
}
const TypeError = global.TypeError;
throw new TypeError('Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.');
function _fun63859() { // fn#63859, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:705, offset: 0x00c39d73, size: 69 bytes, params: 1, frame: 5
return env0_1 >= env0_0.length ? {done: true} : {done: false,
value: env0_0[typeof env0_1 === 'bigint' ? env0_1 : +env0_1]};
}
}
function filterEmpty(a0) { // fn#63861, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:1044, offset: 0x01b93a0b, size: 38 bytes, params: 2, frame: 11
const env0_0 = a0;
return a0 == null ? [] : a0.filter(_fun63862);
function _fun63862(a0, a1) { // fn#63862, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:1096, offset: 0x01b93a31, size: 94 bytes, params: 3, frame: 12
var r1;
var r0;
let value = a0.type !== 'text';
if (value) {
r0 = value;
} else {
if (a1 > 0) {
if (a1 < env0_0.length - 1) {
r1 = a0.text !== '';
} else {
value = a0.text.trim();
value = value !== '';
r1 = value;
}
} else {
value = a0.text.trim();
value = value !== '';
r1 = value;
}
r0 = r1;
}
return r0;
}
}
function getBoolean(a0, a1) { // fn#63863, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:1173, offset: 0x01b93a8f, size: 135 bytes, params: 3, frame: 18
const filterEmptyBinding = filterEmpty;
const value2 = undefined;
const value3 = filterEmptyBinding(a0[a1]);
(defaultImport2)(value3.length === 1, 'Contains multiple values');
const property = value3[0];
defaultImport2((property == null ? value2 : property.type) === 'text', 'First value is not text');
return value3[0].text === TRUE_OPTION_NAME;
}
function getChannelId(a0, a1) { // fn#63864, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:1369, offset: 0x01b93b16, size: 127 bytes, params: 3, frame: 17
const filterEmptyBinding = filterEmpty;
const value2 = undefined;
const value3 = filterEmptyBinding(a0[a1]);
(defaultImport2)(value3.length === 1, 'Contains multiple values');
const property = value3[0];
defaultImport2((property == null ? value2 : property.type) === 'channelMention', 'First value is not a channel mention');
return value3[0].channelId;
}
function getUserId_63865(a0, a1) { // fn#63865, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:1591, offset: 0x01b93b95, size: 129 bytes, params: 3, frame: 17
const filterEmptyBinding = filterEmpty;
const value2 = undefined;
const value3 = filterEmptyBinding(a0[a1]);
(defaultImport2)(value3.length === 1, 'Contains multiple values');
const property = value3[0];
defaultImport2((property == null ? value2 : property.type) === 'userMention', 'First value is not a user mention');
return value3[0].userId;
}
function getRoleId(a0, a1) { // fn#63866, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:1801, offset: 0x01b93c16, size: 128 bytes, params: 3, frame: 17
const filterEmptyBinding = filterEmpty;
const value2 = undefined;
const value3 = filterEmptyBinding(a0[a1]);
(defaultImport2)(value3.length === 1, 'Contains multiple values');
const property = value3[0];
defaultImport2((property == null ? value2 : property.type) === 'roleMention', 'First value is not a role mention');
return value3[0].roleId;
}
function getString_63867(a0, a1) { // fn#63867, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:2011, offset: 0x01b93c96, size: 420 bytes, params: 3, frame: 42
var r2;
var r3;
var r28;
var r24;
var r0;
var value5;
var type;
var animated;
var name;
var replace;
var value6;
var split;
var property;
var emojiId;
var HermesInternal;
var concat;
var value7;
var surrogate;
var value8;
var roleId;
var value9;
var channelId;
var value10;
var userId;
var value11;
var text;
var value12;
var value13;
const value = _createForOfIteratorHelperLoose_63858(a0[a1]);
const value2 = value();
let done = value2.done;
const value3 = '';
if (done) {
r0 = value3;
} else {
r2 = value3;
r3 = value2;
reducibleLoop1: while (true) {
value5 = r3.value;
type = value5.type;
reducibleJoin15: while (true) {
reducibleJoin14: while (true) {
if (type === 'text') {
break reducibleJoin14;
}
if (type === 'textMention') {
break reducibleJoin14;
}
if (type === 'userMention') {
userId = value5.userId;
concat = global.HermesInternal.concat;
value11 = r2 + ('<@' + userId + '>');
r24 = value11;
break reducibleJoin15;
}
if (type === 'channelMention') {
channelId = value5.channelId;
concat = global.HermesInternal.concat;
value10 = r2 + ('<#' + channelId + '>');
r24 = value10;
break reducibleJoin15;
}
if (type === 'roleMention') {
roleId = value5.roleId;
concat = global.HermesInternal.concat;
value9 = r2 + ('<@&' + roleId + '>');
r24 = value9;
break reducibleJoin15;
}
if (type === 'emoji') {
surrogate = value5.surrogate;
value8 = r2 + surrogate;
r24 = value8;
break reducibleJoin15;
}
if (type !== 'customEmoji') {
r24 = r2;
break reducibleJoin15;
}
animated = value5.animated;
r28 = animated ? 'a' : value3;
name = value5.name;
replace = name.replace;
value6 = Reflect.apply(replace, name, [RegExp(':', 'g'), value3]);
split = value6.split;
property = Reflect.apply(split, value6, ['~'])[0];
emojiId = value5.emojiId;
HermesInternal = global.HermesInternal;
concat = HermesInternal.concat;
value7 = r2 + ('<' + r28 + ':' + property + ':' + emojiId + '>');
r24 = value7;
break reducibleJoin15;
}
text = value5.text;
value12 = r2 + text;
r24 = value12;
break reducibleJoin15;
}
value13 = value();
done = value13.done;
if (done) {
r0 = r24;
break reducibleLoop1;
}
r2 = r24;
r3 = value13;
continue reducibleLoop1;
}
}
return r0;
}
function getOptionalBoolean(a0, a1) { // fn#63868, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:2633, offset: 0x01b93e3a, size: 36 bytes, params: 3, frame: 14
const value = null;
return value == a0[a1] ? value : getBoolean(a0, a1);
}
function getOptionalChannelId(a0, a1) { // fn#63869, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:2759, offset: 0x01b93e5e, size: 36 bytes, params: 3, frame: 14
const value = null;
return value == a0[a1] ? value : getChannelId(a0, a1);
}
function getOptionalUserId(a0, a1) { // fn#63870, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:2880, offset: 0x01b93e82, size: 36 bytes, params: 3, frame: 14
const value = null;
return value == a0[a1] ? value : getUserId_63865(a0, a1);
}
function getOptionalRoleId(a0, a1) { // fn#63871, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:2995, offset: 0x01b93ea6, size: 36 bytes, params: 3, frame: 14
const value = null;
return value == a0[a1] ? value : getRoleId(a0, a1);
}
function getOptionalString(a0, a1) { // fn#63872, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:3110, offset: 0x01b93eca, size: 36 bytes, params: 3, frame: 14
const value = null;
return value == a0[a1] ? value : getString_63867(a0, a1);
}
function normalizeNumericString(a0, a1) { // fn#63873, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:3207, offset: 0x01b93eee, size: 263 bytes, params: 3, frame: 21
var r1;
const numberParts = (NumberPartsModule).numberParts;
var group;
var decimal;
var RegExp;
var value2;
var prototype;
var value3;
var regExp;
var value5;
var value6;
if (a0 !== env0_5) {
env0_5 = a0;
r1 = numberParts[a0] ?? numberParts['en-US'];
group = r1.group;
decimal = r1.decimal;
RegExp = global.RegExp;
value2 = (importDefault(4100) /* metro dependency 4100: RegexUtils */).escape(group);
prototype = RegExp.prototype;
value3 = Object.create(prototype, {constructor: {value: RegExp}});
regExp = new RegExp(value2, 'g');
env0_3 = regExp instanceof Object ? regExp : value3;
RegExp = global.RegExp;
value5 = (importDefault(4100) /* metro dependency 4100: RegexUtils */).escape(decimal);
prototype = RegExp.prototype;
value6 = Object.create(prototype, {constructor: {value: RegExp}});
regExp = new RegExp(value5, 'g');
env0_4 = regExp instanceof Object ? regExp : value6;
}
return a1.replace(env0_3, '').replace(env0_4, '.');
}
function getInitialValuesFromInteractionOptions(a0, a1) { // fn#63874, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:3511, offset: 0x01b93ff5, size: 76 bytes, params: 3, frame: 15
var r2;
var value3;
var value4;
const env0_0 = a0;
const getInitialValuesFromInteractionOptions_loop2 = getInitialValuesFromInteractionOptions_loop;
const value = _createForOfIteratorHelperLoose_63858(a1);
const value2 = value();
let done = value2.done;
if (!done) {
for (r2 = value2; true; r2 = value4) {
value3 = r2.value;
getInitialValuesFromInteractionOptions_loop2(value3);
value4 = value();
done = value4.done;
if (done) {
break;
}
}
}
return {};
function getInitialValuesFromInteractionOptions_loop(a0) { // fn#63875, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:3585, owner: getInitialValuesFromInteractionOptions._loop, offset: 0x01b94041, size: 128 bytes, params: 2, frame: 17
var r0;
const options = a0.options;
const value2 = undefined;
const r3 = options == null ? value2 : options.find(_fun63876);
const type = a0.type;
const ApplicationCommandOptionType = (ServerModule).ApplicationCommandOptionType;
const ATTACHMENT = ApplicationCommandOptionType.ATTACHMENT;
const value5 = 0;
if (type === ATTACHMENT) {
r0 = value5;
} else if (r3 == null) {
env0_1[a0.name] = a0;
r0 = value2;
} else if (r3.autocomplete) {
r0 = value5;
} else {
env0_1[a0.name] = a0;
r0 = value2;
}
return r0;
function _fun63876({name}) { // fn#63876, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8229:3640, offset: 0x01b940c1, size: 26 bytes, params: 2, frame: 2
return name === env0_0.name;
}
}
}
}
global.__d(_fun63857, 8051, [5066, 44, 8052, 4100, 1909,
2]) /* metro module 8051, dependencies: [5066, 44, 8052, 4100, 1909, 2] */;