/* Metro module 8357; source: modules/interaction_components/ComponentStateContext.tsx; dependencies: [57, 31, 8057, 3785, 1379, 1945, 4798, 1878, 8358, 33, 1909, 4633, 4629, 566, 8229, 6860, 8360, 8056, 694, 4594, 4627, 2] */ function _fun66523(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#66523, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:6, offset: 0x01bffa12, size: 439 bytes, params: 8, frame: 20 let env0_0 = require; const getApplicationWidgetContainerId = function({applicationId}) { return 'app-widget-' + applicationId; }; const getParentsNotSupported = function(a0) { var env0_0 = 'ApplicationWidget'; return _fun66540; }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_3 = importDefault(57) /* metro dependency 57 */; const value = importAll(31) /* metro dependency 31 */; const interactionStore = importDefault(8057) /* metro dependency 8057: InteractionStore */; const lurkingStore = importDefault(3785) /* metro dependency 3785: LurkingStore */; const channelStore = importDefault(1379) /* metro dependency 1379: ChannelStore */; const guildMemberStore = importDefault(1945) /* metro dependency 1945: GuildMemberStore */; const guildVerificationStore = importDefault(4798) /* metro dependency 4798: GuildVerificationStore */; const userStore = importDefault(1878) /* metro dependency 1878: UserStore */; const localInteractionComponentStateStore = importDefault(8358) /* metro dependency 8358: LocalInteractionComponentStateStore */; const env0_12 = (require(33) /* metro dependency 33 */).jsx; const closure = getActionComponentState; const closure2 = useShouldDisableInteractiveComponents; const env0_16 = value.createContext(null); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/interaction_components/ComponentStateContext.tsx'); exports.getActionComponentState = closure; exports.useShouldDisableInteractiveComponents = closure2; exports.ComponentStateContextProvider = ComponentStateContextProvider; exports.useComponentState = useComponentState; exports.useComponentStateContext = useComponentStateContext; exports.useComponentContainerId = useComponentContainerId; exports.useComponentError = useComponentError; } function useComponentValidatorState(a0, a1) { // fn#66525, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1888, offset: 0x01bffbeb, size: 184 bytes, params: 3, frame: 18 const env0_0 = a0; const env0_1 = a1; const value2 = env0_4.useContext(env0_16); const value3 = env0_4.useCallback(_fun66526, [a0, value2]); env0_4.useEffect(_fun66528, [value2.validators, value3, a1, a0.id]); const validationErrors = value2.validationErrors; const value = null; const r3 = value == validationErrors ? undefined : validationErrors[a0.id]; return {error: value != r3 ? r3 : value, validate: value3}; } function useComponentStateForMessage(a0, a1, a2) { // fn#66531, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2406, offset: 0x01bffdad, size: 335 bytes, params: 4, frame: 25 var object2; let value = a1; const env0_0 = a0; const env0_1 = a2; const interactionComponentState = (require(566) /* metro dependency 566: flux */).useStateFromStores([LocalInteractionComponentStateStore], _fun66532); const value3 = (require(566) /* metro dependency 566: flux */).useStateFromStores([InteractionStore], _fun66533, [a0]); const r3 = useShouldDisableInteractiveComponents(a0.channel_id) || value; value = useComponentValidatorState(a2, interactionComponentState); const error = value.error; const validate = value.validate; const r12 = a0.applicationId ?? a0.author.id; object2 = {state: interactionComponentState}; object2.executeStateUpdate = env0_4.useCallback(_fun66534, [a0.channel_id, a0.flags, a0.id, a2.customId, a2.type, a2.id, r12, validate]); object2.isDisabled = r3 && isInteractionComponent(a2); object2.visualState = getActionComponentState(value3, a2, r3); object2.error = error; return object2; } function useComponentStateForModal(a0, a1, a2) { // fn#66535, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:3255, offset: 0x01c0000e, size: 303 bytes, params: 4, frame: 22 var object2; const env0_0 = a0; const env0_1 = a1; const env0_2 = a2; const interactionComponentState = (require(566) /* metro dependency 566: flux */).useStateFromStores([LocalInteractionComponentStateStore], _fun66536); const property = interactionComponentState(env0_4.useState(a2), 1)[0]; const {error, validate} = useComponentValidatorState(a1, interactionComponentState); var env0_4 = validate; const value5 = env0_4.useCallback(_fun66537, [a0.customId, a1.id, validate]); (importDefault(4594) /* metro dependency 4594: useMountEffect */)(_fun66538); object2 = {}; const value6 = null; const r6 = value6 == interactionComponentState ? property : interactionComponentState; object2.state = value6 != r6 ? r6 : value6; object2.executeStateUpdate = value5; object2.isDisabled = false; const ActionComponentState = (require(4633) /* metro dependency 4633: InteractionComponentTypes */).ActionComponentState; const NORMAL = ActionComponentState.NORMAL; object2.visualState = NORMAL; object2.error = error; return object2; } function getParentsNotSupported(a0) { // fn#66539, offset: 0x01c001f8, size: 19 bytes, params: 2, frame: 2 return _fun66540; } function isInteractionComponent(a0) { // fn#66541, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:223, offset: 0x01c0024b, size: 336 bytes, params: 2, frame: 15 const type = a0.type; const ComponentType = (require(1909) /* metro dependency 1909: Server */).ComponentType; const BUTTON = ComponentType.BUTTON; if (BUTTON === type) { return a0.style !== (require(1909) /* metro dependency 1909: Server */).ButtonStyle.LINK; } const STRING_SELECT = ComponentType.STRING_SELECT; if (STRING_SELECT === type) { return true; } const USER_SELECT = ComponentType.USER_SELECT; if (USER_SELECT === type) { return true; } const ROLE_SELECT = ComponentType.ROLE_SELECT; if (ROLE_SELECT === type) { return true; } const MENTIONABLE_SELECT = ComponentType.MENTIONABLE_SELECT; if (MENTIONABLE_SELECT === type) { return true; } const CHANNEL_SELECT = ComponentType.CHANNEL_SELECT; if (CHANNEL_SELECT === type) { return true; } const ACTION_ROW = ComponentType.ACTION_ROW; if (ACTION_ROW !== type) { ComponentType.TEXT_INPUT; } return false; } function getActionComponentState(a0, a1) { // fn#66542, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:662, offset: 0x01c0039b, size: 299 bytes, params: 3, frame: 20 const value = a2; let r2 = value !== undefined ? value : false; const ActionComponentState = (require(4633) /* metro dependency 4633: InteractionComponentTypes */).ActionComponentState; const NORMAL = ActionComponentState.NORMAL; let r0 = a0 != null && a0.state !== (require(4629) /* metro dependency 4629: InteractionTypes */).InteractionState.FAILED ? a0.data.interactionType !== (require(1909) /* metro dependency 1909: Server */).InteractionTypes.MESSAGE_COMPONENT ? isInteractionComponent(a1) ? ActionComponentState.DISABLED : NORMAL : a0.data.componentId === a1.id ? ActionComponentState.LOADING : isInteractionComponent(a1) ? ActionComponentState.DISABLED : NORMAL : NORMAL; r2 = r2 && isInteractionComponent(a1); r0 = r2 ? ActionComponentState.DISABLED : r0; return r0; } function useShouldDisableInteractiveComponents(a0) { // fn#66543, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1186, offset: 0x01c004c6, size: 379 bytes, params: 2, frame: 23 var r4; var r2; const channel = ChannelStore.getChannel(a0); const value3 = undefined; const value4 = (require(566) /* metro dependency 566: flux */).useStateFromStores([GuildVerificationStore], _fun66544, [channel]); const value5 = (require(566) /* metro dependency 566: flux */).useStateFromStores([LurkingStore], _fun66545, [channel]); const value6 = (require(566) /* metro dependency 566: flux */).useStateFromStores([GuildMemberStore, UserStore], _fun66546); const useUserCommunicationDisabledModule = require(8229) /* metro dependency 8229: useUserCommunicationDisabled */; const useCurrentUserCommunicationDisabled = useUserCommunicationDisabledModule.useCurrentUserCommunicationDisabled; const property = env0_3(Reflect.apply(useCurrentUserCommunicationDisabled, useUserCommunicationDisabledModule, [channel == null ? value3 : channel.guild_id]), 2)[1]; let value = require(6860) /* metro dependency 6860: ThreadHooks */; value = value.useIsThreadModerator(channel); const value9 = (require(6860) /* metro dependency 6860: ThreadHooks */).useCanUnarchiveThread(channel); let r0 = value4 ? value5 : !value4; r0 = !r0 ? value6 : r0; if (!r0) { r4 = channel != null && channel.isLockedThread(); r4 = r4 && !value; r0 = r4; } if (!r0) { r2 = channel != null && channel.isArchivedThread(); r2 = r2 && !value9; r0 = r2; } r0 = !r0 ? property : r0; return !!r0; } function ComponentStateContextProvider({children, message, modal, applicationWidget, validators, validationErrors, setValidationErrors, shouldDisableInteractiveComponents}) { // fn#66547, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:4192, offset: 0x01c00745, size: 176 bytes, params: 2, frame: 23 const env0_4 = validationErrors; shouldDisableInteractiveComponents = !(shouldDisableInteractiveComponents === undefined) && shouldDisableInteractiveComponents; const value2 = env0_4.useMemo(_fun66548, [message, modal, applicationWidget, shouldDisableInteractiveComponents, validators, validationErrors, setValidationErrors]); const Provider = env0_16.Provider; return ( {children} ); } function useComponentState(a0, a1) { // fn#66552, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:5314, offset: 0x01c009f8, size: 42 bytes, params: 3, frame: 13 return env0_4.useContext(env0_16).useComponentState(a0, a1); } function useComponentStateContext() { // fn#66553, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:5420, offset: 0x01c00a22, size: 24 bytes, params: 1, frame: 11 return env0_4.useContext(env0_16); } function useComponentContainerId() { // fn#66554, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:5506, offset: 0x01c00a3a, size: 30 bytes, params: 1, frame: 11 const binding = env0_4; const useContext = binding.useContext; return Reflect.apply(useContext, binding, [env0_16]).containerId; } function useComponentError(a0) { // fn#66555, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:5597, offset: 0x01c00a58, size: 65 bytes, params: 2, frame: 12 const binding = env0_4; const useContext = binding.useContext; const validationErrors = Reflect.apply(useContext, binding, [env0_16]).validationErrors; const value = null; const r1 = value == validationErrors ? undefined : validationErrors[a0.id]; return value != r1 ? r1 : value; } function _fun66526(a0) { // fn#66526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1972, offset: 0x01bffca3, size: 117 bytes, params: 2, frame: 18 var environment; let value = environment.__proto__; value = importDefault(8360) /* metro dependency 8360: validateComponent */; value = value(env0_0, a0, env0_2.modal != null ? 'modal' : 'message'); if (env0_2.setValidationErrors != null) { env0_2.setValidationErrors(_fun66527); } return value == null; } function _fun66528() { // fn#66528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2147, offset: 0x01bffd3e, size: 51 bytes, params: 1, frame: 12 const closure = currentValidate; const validators = env0_2.validators; if (validators != null) { validators.add(closure); } return _fun66530; } function _fun66532() { // fn#66532, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2491, offset: 0x01bffefc, size: 42 bytes, params: 1, frame: 13 return LocalInteractionComponentStateStore.getInteractionComponentState(env0_0.id, importDefault.id); } function _fun66533() { // fn#66533, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2574, offset: 0x01bfff26, size: 27 bytes, params: 1, frame: 11 return InteractionStore.getInteraction(env0_0); } function _fun66534(a0) { // fn#66534, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2809, offset: 0x01bfff41, size: 205 bytes, params: 2, frame: 17 var value2; var value3; var moduleValue; var executeMessageComponentInteraction; var object2; var binding; var id; if (validate(a0)) { value2 = environment.__proto__; value3 = ChannelStore.getChannel(env0_0.channel_id); if (value3 != null && importDefault.customId != null) { moduleValue = require(8056) /* metro dependency 8056: InteractionUtils */; executeMessageComponentInteraction = moduleValue.executeMessageComponentInteraction; object2 = {}; object2.componentType = importDefault.type; binding = env0_0; id = binding.id; object2.messageId = id; object2.messageFlags = binding.flags; object2.customId = importDefault.customId; id = importDefault.id; object2.componentId = id; object2.applicationId = env0_3; id = value3.id; object2.channelId = id; object2.guildId = value3.guild_id; object2.localState = a0; Reflect.apply(executeMessageComponentInteraction, moduleValue, [object2]); } return true; } return false; } function _fun66536() { // fn#66536, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:3338, offset: 0x01c0013d, size: 43 bytes, params: 1, frame: 13 return LocalInteractionComponentStateStore.getInteractionComponentState(env0_0.customId, require.id); } function _fun66537(a0) { // fn#66537, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:3494, offset: 0x01c00168, size: 112 bytes, params: 2, frame: 16 var r0; let value = a0 == null; if (value) { r0 = value; } else { value = environment.__proto__; value = importDefault(694) /* metro dependency 694: Dispatcher */; value.dispatch({type: 'SET_INTERACTION_COMPONENT_STATE', rootContainerId: env0_0.customId, componentId: require.id, state: a0}); value = !!validate(a0); r0 = value; } return r0; } function _fun66538() { // fn#66538, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:3666, offset: 0x01c001d8, size: 32 bytes, params: 1, frame: 11 if (interactionComponentState == null) { env0_5(importDefault); } } function _fun66540() { // fn#66540, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:3858, offset: 0x01c0020b, size: 64 bytes, params: 1, frame: 14 const Error = global.Error; const value = '' + env0_0 + ' does not support parents'; const value2 = Object.create(Error.prototype, {constructor: {value: Error}}); const error = new Error(); throw error instanceof Object ? error : value2; } function _fun66544() { // fn#66544, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1247, offset: 0x01c00641, size: 63 bytes, params: 1, frame: 12 return env0_0?.guild_id == null || GuildVerificationStore.canChatInGuild(env0_0.guild_id); } function _fun66545() { // fn#66545, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1356, offset: 0x01c00680, size: 63 bytes, params: 1, frame: 12 return env0_0?.guild_id != null && LurkingStore.isLurking(env0_0.guild_id); } function _fun66546() { // fn#66546, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:1462, offset: 0x01c006bf, size: 134 bytes, params: 1, frame: 18 const value = environment.__proto__; const currentUser = UserStore.getCurrentUser(); const value4 = null; const value5 = undefined; const r1 = value4 != (value4 == env0_0 ? value5 : env0_0.guild_id) && value4 != currentUser ? value4 == GuildMemberStore.getMember(value4 == env0_0 ? value5 : env0_0.guild_id, currentUser.id) ? value5 : GuildMemberStore.getMember(value4 == env0_0 ? value5 : env0_0.guild_id, currentUser.id).isPending : value4; return value4 != r1 && r1; } function _fun66548() { // fn#66548, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:4394, offset: 0x01c007f5, size: 341 bytes, params: 1, frame: 19 var environment; var object2; var value2; var getApplicationWidgetContainerIdBinding; var value3; var bind; var value4; let messageBinding = message; if (messageBinding != null) { value4 = environment.__proto__; bind = useComponentStateForMessage.bind; messageBinding = message; return {useComponentState: Reflect.apply(bind, useComponentStateForMessage, [null, messageBinding, shouldDisableInteractiveComponents]), channelId: messageBinding.channel_id, containerId: messageBinding.id, message: messageBinding, validators: validators, getParents: getParents_66549}; } let modalBinding = modal; if (modalBinding != null) { value3 = environment.__proto__; bind = useComponentStateForModal.bind; modalBinding = modal; return {useComponentState: Reflect.apply(bind, useComponentStateForModal, [null, modalBinding]), channelId: modalBinding.channelId, containerId: modalBinding.customId, modal: modalBinding, validators: validators, validationErrors: validationErrors, setValidationErrors: setValidationErrors, getParents: getParents_66550}; } let applicationWidgetBinding = applicationWidget; if (applicationWidgetBinding != null) { object2 = {}; object2.useComponentState = useComponentState_66551; value2 = environment.__proto__; getApplicationWidgetContainerIdBinding = getApplicationWidgetContainerId; applicationWidgetBinding = applicationWidget; object2.containerId = getApplicationWidgetContainerIdBinding(applicationWidgetBinding); object2.applicationWidget = applicationWidgetBinding; object2.validators = validators; object2.validationErrors = validationErrors; object2.setValidationErrors = setValidationErrors; object2.getParents = getParentsNotSupported('ApplicationWidget'); return object2; } const Error = global.Error; throw new Error('ComponentStateContextProvider requires at least one of message, modal, or applicationWidget'); } function currentValidate() { // fn#66529, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2174, offset: 0x01bffd71, size: 20 bytes, params: 1, frame: 11 return env1_3(require); } function _fun66530() { // fn#66530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:2237, offset: 0x01bffd85, size: 40 bytes, params: 1, frame: 11 const validators = env1_2.validators; if (validators != null) { validators.delete(currentValidate); } } function getParents_66549(a0) { // fn#66549, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:4552, offset: 0x01c0094a, size: 55 bytes, params: 2, frame: 13 const value = environment.__proto__.__proto__; return (require(4627) /* metro dependency 4627: InteractionComponentUtils */).getParents(message.components, a0); } function getParents_66550(a0) { // fn#66550, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:4785, offset: 0x01c00981, size: 55 bytes, params: 2, frame: 13 const value = environment.__proto__.__proto__; return (require(4627) /* metro dependency 4627: InteractionComponentUtils */).getParents(modal.components, a0); } function useComponentState_66551() { // fn#66551, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8542:4884, offset: 0x01c009b8, size: 64 bytes, params: 1, frame: 14 const Error = global.Error; const value = '' + env0_0 + ' does not support state'; const value2 = Object.create(Error.prototype, {constructor: {value: Error}}); const error = new Error(); throw error instanceof Object ? error : value2; }