/* Metro module 15736; source: modules/interaction_components/InteractionModalUtils.tsx; dependencies: [5, 57, 31, 1226, 1379, 4645, 1945, 3969, 4644, 12952, 8358, 661, 8357, 1909, 1423, 8067, 6844, 566, 6518, 21, 694, 7879, 1244, 44, 4627, 7226, 8055, 4651, 507, 672, 2] */ import Module00005 from '../../by-id/module-00005.js'; /* Metro dependency 5 */ import Module00044 from '../../by-id/module-00044.js'; /* Metro dependency 44 */ import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */ import AuthenticationStore from '../../stores/AuthenticationStore.tsx'; /* Metro dependency 1226 */ import ChannelStore from '../../stores/ChannelStore.tsx'; /* Metro dependency 1379 */ import AvatarUtils from '../../utils/AvatarUtils.tsx'; /* Metro dependency 1423 */ import GuildMemberStore from '../../stores/GuildMemberStore.tsx'; /* Metro dependency 1945 */ import SelectedGuildStore from '../../stores/SelectedGuildStore.tsx'; /* Metro dependency 3969 */ import UploadAttachmentStore from '../../stores/UploadAttachmentStore.tsx'; /* Metro dependency 4644 */ import UseUnmountAbortSignal from '../../hooks/useUnmountAbortSignal.tsx'; /* Metro dependency 6844 */ import LocalInteractionComponentStateStore from './LocalInteractionComponentStateStore.tsx'; /* Metro dependency 8358 */ import InteractionModalStore from './InteractionModalStore.tsx'; /* Metro dependency 12952 */ 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 FluxModule from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */ import * as ConstantsModule from '../../Constants.tsx'; /* Metro dependency 661 */ import * as ServerModule from '../../flow/Server.tsx'; /* Metro dependency 1909 */ import * as InteractionComponentUtilsModule from './InteractionComponentUtils.tsx'; /* Metro dependency 4627 */ import * as DraftStoreModule from '../../stores/DraftStore.tsx'; /* Metro dependency 4645 */ import * as ComponentStateContextModule from './ComponentStateContext.tsx'; /* Metro dependency 8357 */ import * as InteractionModalStoreModule from './InteractionModalStore.tsx'; /* Metro dependency 12952 */ function _fun120826(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#120826, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:6, offset: 0x02536e50, size: 417 bytes, params: 8, frame: 20 let env0_0 = require; const closure = function() { return _submitModal.apply(this, arguments); }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const getData_120838 = function(a0, a1, a2) { var env0_0 = a0; var env0_1 = a2; return a1.map(_fun120839); }; (FileImportTrackerModule).fileFinishedImporting('modules/interaction_components/InteractionModalUtils.tsx'); exports.useIsFirstTextInputInModal = useIsFirstTextInputInModal; exports.useModalState = useModalState_120844; exports.useIframeModalState = useIframeModalState; exports.submitModal = closure; function useApplicationInfo(a0) { // fn#120827, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:274, offset: 0x02536ff1, size: 77 bytes, params: 2, frame: 15 const env0_0 = a0; return ReactModule.useMemo(_fun120828, [a0.id, a0.icon, a0.name, a0.bot]); function _fun120828() { // fn#120828, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:323, offset: 0x0253703e, size: 298 bytes, params: 1, frame: 20 const value = environment.__proto__; const guildId = SelectedGuildStore.getGuildId(); const value3 = undefined; const r5 = guildId != null && env0_0.bot != null ? GuildMemberStore.getMember(guildId, env0_0.bot.id) : value3; const object = {}; const defaultImport = AvatarUtils; const getApplicationIconURL = defaultImport.getApplicationIconURL; const binding = env0_0; object.applicationIconURL = Reflect.apply(getApplicationIconURL, defaultImport, [{id: binding.id, icon: binding.icon, botIconFirst: true, bot: r5 != null ? env0_0.bot : value3, guildMember: r5}]); object.applicationName = (r5 == null ? value3 : r5.nick) != null ? r5.nick : env0_0.bot != null ? env0_0.bot.username : env0_0.name; object.applicationBaseUrl = (importDefault(8067) /* metro dependency 8067: getURLForApplication */)(env0_0.id); return object; } } function getUploadsForModal(a0, a1) { // fn#120829, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:2534, offset: 0x02537168, size: 60 bytes, params: 3, frame: 14 const env0_0 = a1; const uploadAttachmentStoreBinding = UploadAttachmentStore; const getUploads = uploadAttachmentStoreBinding.getUploads; const InteractionModal = DraftType.InteractionModal; return Reflect.apply(getUploads, uploadAttachmentStoreBinding, [a0, InteractionModal]).filter(_fun120830); function _fun120830({id}) { // fn#120830, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:2617, offset: 0x025371a4, size: 72 bytes, params: 2, frame: 12 let value = environment.__proto__; value = undefined; const value2 = (InteractionComponentUtilsModule).deserializeComponentUploadId(id); return (value2 == null ? value : value2.containerId) === require; } } function _submitModal() { // fn#120832, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:2783, offset: 0x025371ec, size: 50 bytes, params: 1, frame: 14 return Module00005(_fun120834).apply(this, arguments); function* _fun120834(a0, a1, a2) { // fn#120834, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:2830, offset: 0x02537229, size: 349 bytes, params: 4, frame: 25 if (false) { return undefined; } const env0_0 = a0; const env0_1 = a1; const env0_2 = a2; value = undefined; const channelId = a0.channelId; let binding = env2_7; env2_1(env2_2[23])(binding.getChannel(channelId) != null, 'expected channel'); const value6 = env2_18(channelId, a0.customId); const r1 = value6.length > 0 ? env2_1(env2_2[25])(value6) : value; binding = env2_0; const binding2 = env2_2; const value8 = binding(binding2[26]); const addQueued = value8.addQueued; const InteractionTypes = binding(binding2[13]).InteractionTypes; const MODAL_SUBMIT = InteractionTypes.MODAL_SUBMIT; Reflect.apply(addQueued, value8, [a2, {data: {interactionType: MODAL_SUBMIT, applicationId: a0.application.id}, preflight: r1}]); yield r1; if (false) { return undefined; } const env0_4 = value6.map(_fun120835); const env0_5 = env2_16(a0.customId, a0.components, {uploads: value6}); send_120836(); return value; function _fun120835(a0, a1) { // fn#120835, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:3143, offset: 0x02537386, size: 45 bytes, params: 3, frame: 13 const value = environment.__proto__.__proto__.__proto__; return env3_0(env3_2[27]).getAttachmentPayload(a0, a1); } function send_120836() { // fn#120836, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:3240, offset: 0x025373b3, size: 297 bytes, params: 1, frame: 18 var environment; var value3; var binding; var binding2; var value4; var HTTP; var post; var object; var object2; var id; if (!(require != null && require.aborted)) { value3 = environment.__proto__.__proto__.__proto__; binding = env3_0; binding2 = env3_2; value4 = undefined; HTTP = binding(binding2[28]).HTTP; post = HTTP.post; object = {}; object.url = env3_15.INTERACTIONS; object2 = {}; object2.type = binding(binding2[13]).InteractionTypes.MODAL_SUBMIT; binding = env0_0; id = binding.application.id; object2.application_id = id; id = Module00005.id; object2.channel_id = id; object2.guild_id = Module00005.guild_id; id = binding.id; object2.data = {id: id, custom_id: binding.customId, components: env0_5, attachments: env0_4.length > 0 ? env0_4 : value4}; binding = env3_6; object2.session_id = binding.getSessionId(); object2.nonce = importDefault; object.body = object2; object.signal = require; object.rejectWithError = false; Reflect.apply(post, HTTP, [object]).catch(_fun120837); } function _fun120837(a0) { // fn#120837, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:3579, offset: 0x025374dc, size: 140 bytes, params: 2, frame: 15 var value; var setFailed; var value2; var setTimeout; var send_120836Binding; var retry_after; if (a0.status === 429) { setTimeout = global.setTimeout; value = environment.__proto__; send_120836Binding = send_120836; retry_after = a0.body.retry_after; value = environment.__proto__.__proto__.__proto__.__proto__; setTimeout(send_120836Binding, retry_after * env4_1(env4_2[29]).Millis.SECOND); } else { value = environment.__proto__.__proto__.__proto__.__proto__; value = env4_0(env4_2[26]); setFailed = value.setFailed; value2 = environment.__proto__; Reflect.apply(setFailed, value, [importDefault]); } } } } } function getData_120838(a0, a1, a2) { // fn#120838, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:702, offset: 0x02537568, size: 38 bytes, params: 4, frame: 11 const env0_0 = a0; const env0_1 = a2; return a1.map(_fun120839); function _fun120839(a0) { // fn#120839, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:718, offset: 0x0253758e, size: 1312 bytes, params: 2, frame: 20 var environment; var r3; var uploadIds; var r4; var localInteractionComponentStateStoreBinding; var object; var value4; var value5; var value6; var value7; var value8; var value9; let type = a0.type; let value = environment.__proto__; const value2 = undefined; const ComponentType = (ServerModule).ComponentType; const ACTION_ROW = ComponentType.ACTION_ROW; if (ACTION_ROW === type) { object = {}; object.type = a0.type; object.components = getData_120838(env0_0, a0.components, importDefault); return object; } const TEXT_INPUT = ComponentType.TEXT_INPUT; if (TEXT_INPUT === type) { localInteractionComponentStateStoreBinding = LocalInteractionComponentStateStore; value = localInteractionComponentStateStoreBinding.getInteractionComponentState(env0_0, a0.id); object = {}; type = a0.type; object.type = type; object.custom_id = a0.customId; value9 = null; type = value9 == value ? value2 : value.type; object.value = type !== a0.type ? value9 : value.value; return object; } const FILE_UPLOAD = ComponentType.FILE_UPLOAD; if (FILE_UPLOAD === type) { localInteractionComponentStateStoreBinding = LocalInteractionComponentStateStore; value = localInteractionComponentStateStoreBinding.getInteractionComponentState(env0_0, a0.id); value8 = null; type = value8 == value ? value2 : value.type; uploadIds = type !== a0.type ? value8 : value.uploadIds; object = {}; type = a0.type; object.type = type; object.custom_id = a0.customId; r4 = value8 == uploadIds ? value2 : uploadIds.map(function(a0) { var env0_0 = a0; return importDefault.uploads.findIndex(_fun120841); }); object.values = value8 != r4 ? r4 : value8; return object; } const STRING_SELECT = ComponentType.STRING_SELECT; if (STRING_SELECT === type) { localInteractionComponentStateStoreBinding = LocalInteractionComponentStateStore; value = localInteractionComponentStateStoreBinding.getInteractionComponentState(env0_0, a0.id); object = {}; type = a0.type; object.type = type; object.custom_id = a0.customId; value7 = null; type = value7 == value ? value2 : value.type; object.values = type !== a0.type ? value7 : value.values; return object; } const USER_SELECT = ComponentType.USER_SELECT; if (USER_SELECT === type) { localInteractionComponentStateStoreBinding = LocalInteractionComponentStateStore; value = localInteractionComponentStateStoreBinding.getInteractionComponentState(env0_0, a0.id); object = {}; type = a0.type; object.type = type; object.custom_id = a0.customId; value6 = null; type = value6 == value ? value2 : value.type; if (type !== a0.type) { r3 = value6; } else { value = value.selectedOptions.map(function(a0) { return a0.value; }); r3 = value; } object.values = r3; return object; } const ROLE_SELECT = ComponentType.ROLE_SELECT; if (ROLE_SELECT === type) { localInteractionComponentStateStoreBinding = LocalInteractionComponentStateStore; value = localInteractionComponentStateStoreBinding.getInteractionComponentState(env0_0, a0.id); object = {}; type = a0.type; object.type = type; object.custom_id = a0.customId; value6 = null; type = value6 == value ? value2 : value.type; if (type !== a0.type) { r3 = value6; } else { value = value.selectedOptions.map(function(a0) { return a0.value; }); r3 = value; } object.values = r3; return object; } const MENTIONABLE_SELECT = ComponentType.MENTIONABLE_SELECT; if (MENTIONABLE_SELECT === type) { localInteractionComponentStateStoreBinding = LocalInteractionComponentStateStore; value = localInteractionComponentStateStoreBinding.getInteractionComponentState(env0_0, a0.id); object = {}; type = a0.type; object.type = type; object.custom_id = a0.customId; value6 = null; type = value6 == value ? value2 : value.type; if (type !== a0.type) { r3 = value6; } else { value = value.selectedOptions.map(function(a0) { return a0.value; }); r3 = value; } object.values = r3; return object; } const CHANNEL_SELECT = ComponentType.CHANNEL_SELECT; if (CHANNEL_SELECT === type) { localInteractionComponentStateStoreBinding = LocalInteractionComponentStateStore; value = localInteractionComponentStateStoreBinding.getInteractionComponentState(env0_0, a0.id); object = {}; type = a0.type; object.type = type; object.custom_id = a0.customId; value6 = null; type = value6 == value ? value2 : value.type; if (type !== a0.type) { r3 = value6; } else { value = value.selectedOptions.map(function(a0) { return a0.value; }); r3 = value; } object.values = r3; return object; } const TEXT_DISPLAY = ComponentType.TEXT_DISPLAY; if (TEXT_DISPLAY === type) { return {type: a0.type}; } const LABEL = ComponentType.LABEL; if (LABEL === type) { object = {}; object.type = a0.type; object.component = getData_120838(env0_0, [a0.component], importDefault)[0]; return object; } const RADIO_GROUP = ComponentType.RADIO_GROUP; if (RADIO_GROUP === type) { localInteractionComponentStateStoreBinding = LocalInteractionComponentStateStore; value = localInteractionComponentStateStoreBinding.getInteractionComponentState(env0_0, a0.id); object = {}; type = a0.type; object.type = type; object.custom_id = a0.customId; value5 = null; type = value5 == value ? value2 : value.type; object.value = type !== a0.type ? value5 : value.value; return object; } const CHECKBOX_GROUP = ComponentType.CHECKBOX_GROUP; if (CHECKBOX_GROUP === type) { localInteractionComponentStateStoreBinding = LocalInteractionComponentStateStore; value = localInteractionComponentStateStoreBinding.getInteractionComponentState(env0_0, a0.id); object = {}; type = a0.type; object.type = type; object.custom_id = a0.customId; value4 = null; type = value4 == value ? value2 : value.type; object.values = type !== a0.type ? value4 : value.values; return object; } const CHECKBOX = ComponentType.CHECKBOX; if (CHECKBOX === type) { localInteractionComponentStateStoreBinding = LocalInteractionComponentStateStore; value = localInteractionComponentStateStoreBinding.getInteractionComponentState(env0_0, a0.id); object = {}; type = a0.type; object.type = type; object.custom_id = a0.customId; type = value == null ? value2 : value.type; object.value = type === a0.type && value.value; return object; } (Module00044)(false, 'unreachable'); return value2; function _fun120840(a0) { // fn#120840, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:1230, offset: 0x02537aae, size: 42 bytes, params: 2, frame: 11 const env0_0 = a0; return importDefault.uploads.findIndex(_fun120841); function _fun120841({id}) { // fn#120841, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:1254, offset: 0x00db0c48, size: 21 bytes, params: 2, frame: 2 return id === env0_0; } } } } function useIsFirstTextInputInModal(a0) { // fn#120843, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:3838, offset: 0x02537ad8, size: 152 bytes, params: 2, frame: 14 const value2 = undefined; const value3 = (ComponentStateContextModule).useComponentStateContext(); const r1 = value3 == null || value3.modal == null ? value2 : value3.modal.components[0]; const type = r1 == null ? value2 : r1.type; const ComponentType = (ServerModule).ComponentType; const ACTION_ROW = ComponentType.ACTION_ROW; return type === ACTION_ROW && r1.components[0].id === a0; } function useModalState_120844(a0, a1) { // fn#120844, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:4082, offset: 0x02537b70, size: 436 bytes, params: 3, frame: 30 const env0_0 = a0; const env0_1 = a1; const application = a0.application; const customId = a0.customId; const components = a0.components; let value2 = (UseUnmountAbortSignal)(); const env0_3 = value2; let binding = property22; let useState = binding.useState; const value3 = Reflect.apply(useState, binding, [null]); binding = env0_4; const value4 = binding(value3, 2); const property = value4[0]; var env0_4 = value4[1]; const binding2 = property22; useState = binding2.useState; const value5 = binding(Reflect.apply(useState, binding2, [null]), 2); const property2 = value5[0]; var property22 = property2; const env0_6 = value5[1]; const binding3 = property22; useState = binding3.useState; const value6 = binding(Reflect.apply(useState, binding3, [{}]), 2); const property3 = value6[0]; const property4 = value6[1]; const value7 = (FluxModule).useStateFromStores([InteractionModalStore], _fun120845, [property2]); const value8 = (importDefault(6518) /* metro dependency 6518: useInitialValue */)(function() { var Set = global.Set; var value = Object.create(Set.prototype, {constructor: {value: Set}}); var value2 = new Set(); return value2 instanceof Object ? value2 : value; }); const value10 = property22.useCallback(env0_3(_fun120848), [value2, a0, value8]); property22.useEffect(_fun120851, [property2, value7, a1, customId, a0.channelId]); let value = useApplicationInfo(application); return {components: components, applicationIconURL: value.applicationIconURL, applicationName: value.applicationName, submissionState: value7, error: property, validators: value8, validationErrors: property3, setValidationErrors: property4, onSubmit: value10}; function _fun120845() { // fn#120845, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:4331, offset: 0x02537d24, size: 29 bytes, params: 1, frame: 11 return InteractionModalStore.getModalState(ReactModule); } function* _fun120848() { // fn#120848, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:4405, offset: 0x02537d4c, size: 154 bytes, params: 1, frame: 18 var environment; var value3; var binding; var value4; var fromTimestamp; var Date; var value5; if (true) { value = environment.__proto__; env1_4(null); AuthenticationStore(null); if (_fun120849(DraftType)) { value3 = environment.__proto__.__proto__; binding = env2_1; value4 = binding(env2_2[19]); fromTimestamp = value4.fromTimestamp; Date = global.Date; value5 = Reflect.apply(fromTimestamp, value4, [Date.now()]); AuthenticationStore(value5); binding = env2_19; yield binding(require, env1_3, value5); return undefined; } } function _fun120849(a0) { // fn#120849, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:4437, offset: 0x02537de6, size: 34 bytes, params: 2, frame: 12 const env0_0 = true; a0.forEach(_fun120850); return env0_0; function _fun120850(a0) { // fn#120850, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:4468, offset: 0x02537e08, size: 23 bytes, params: 2, frame: 10 if (a0()) { } } } } function _fun120851() { // fn#120851, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:4592, offset: 0x02537e1f, size: 256 bytes, params: 1, frame: 20 var defaultImport; var dispatch; var customIdBinding; var defaultImport2; var removeFiles; var intl; let binding = env0_7; const SUCCEEDED = InteractionModalState.SUCCEEDED; if (binding === SUCCEEDED) { defaultImport = importDefault(694) /* metro dependency 694: Dispatcher */; dispatch = defaultImport.dispatch; customIdBinding = customId; Reflect.apply(dispatch, defaultImport, [{type: 'CLEAR_INTERACTION_MODAL_STATE', customId: customIdBinding}]); defaultImport2 = importDefault(7879) /* metro dependency 7879: UploadAttachmentActionCreators */; removeFiles = defaultImport2.removeFiles; binding = env0_0; Reflect.apply(removeFiles, defaultImport2, [binding.channelId, getUploadsForModal(binding.channelId, customIdBinding).map(function(a0) { return a0.id; }), DraftType.InteractionModal]); require(); } binding = env0_7; const ERRORED = InteractionModalState.ERRORED; if (binding === ERRORED) { binding = env0_4; intl = (require(1244) /* metro dependency 1244: indexNative */).intl; binding(intl.string((require(1244) /* metro dependency 1244: indexNative */).t.uJgdEu)); } } } function useIframeModalState(a0) { // fn#120853, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15944:5113, offset: 0x02537f1f, size: 295 bytes, params: 2, frame: 26 const application = a0.application; const customId = a0.customId; const {applicationIconURL, applicationName, applicationBaseUrl} = useApplicationInfo(application); const channelStoreBinding = ChannelStore; const getChannel = channelStoreBinding.getChannel; let channelId = a0.channelId; const value3 = Reflect.apply(getChannel, channelStoreBinding, [channelId]); (Module00044)(value3 != null, 'channel should not be null'); const object = {}; channelId = a0.channelId; const id = application.id; const value = ''; object.instance_id = value + channelId + ':' + id + ':' + customId; object.custom_id = customId; object.channel_id = a0.channelId; if (value3.guild_id != null && value !== value3.guild_id) { object.guild_id = value3.guild_id; } const URL = global.URL; const uRL = new URL(applicationBaseUrl ?? value); uRL.pathname = a0.iframePath; const object2 = {applicationIconURL: applicationIconURL, applicationName: applicationName, applicationBaseUrl: applicationBaseUrl, queryParams: object}; object2.iframeUrl = uRL.toString(); return object2; } } global.__d(_fun120826, 15736, [5, 57, 31, 1226, 1379, 4645, 1945, 3969, 4644, 12952, 8358, 661, 8357, 1909, 1423, 8067, 6844, 566, 6518, 21, 694, 7879, 1244, 44, 4627, 7226, 8055, 4651, 507, 672, 2]) /* metro module 15736, dependencies: [5, 57, 31, 1226, 1379, 4645, 1945, 3969, 4644, 12952, 8358, 661, 8357, 1909, 1423, 8067, 6844, 566, 6518, 21, 694, 7879, 1244, 44, 4627, 7226, 8055, 4651, 507, 672, 2] */;