/* Metro module 15666; source: modules/voice_calls/VoicePermissionManager.tsx; dependencies: [6, 7, 15, 17, 18, 4811, 4298, 1226, 1379, 4259, 4294, 661, 4661, 4662, 15667, 4802, 4860, 2] */ function _fun120113(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#120113, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15874:6, offset: 0x025213d0, size: 404 bytes, params: 8, frame: 20 const env0_0 = require; const closure = shouldImmediatelyRequestVoicePermissions; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_3 = importDefault(6) /* metro dependency 6 */; const env0_4 = importDefault(7) /* metro dependency 7 */; const env0_5 = importDefault(15) /* metro dependency 15 */; const env0_6 = importDefault(17) /* metro dependency 17 */; const env0_7 = importDefault(18) /* metro dependency 18 */; const stageChannelRoleStore = importDefault(4811) /* metro dependency 4811: StageChannelRoleStore */; const voiceStateRecord = importDefault(4298) /* metro dependency 4298: VoiceStateRecord */; const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */; const channelStore = importDefault(1379) /* metro dependency 1379: ChannelStore */; const mediaEngineStore = importDefault(4259) /* metro dependency 4259: MediaEngineStore */; const rtcConnectionStore = importDefault(4294) /* metro dependency 4294: RTCConnectionStore */; const env0_14 = (require(661) /* metro dependency 661: Constants */).InputModes; const env0_15 = (require(4661) /* metro dependency 4661: NativePermissionConstants */).NativePermissionTypes; let value = importDefault(4860) /* metro dependency 4860: AutomaticLifecycleManager */; value = _fun120120(value); value = new value(); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/voice_calls/VoicePermissionManager.tsx'); exports.default = value; exports.shouldImmediatelyRequestVoicePermissions = closure; } function _isNativeReflectConstruct_120114() { // fn#120114, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15874:264, offset: 0x02521564, size: 98 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_120114_isNativeReflectConstruct = function() { return !!result; })(); } function voicePermissionRequest() { // fn#120117, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15874:468, offset: 0x025215c6, size: 133 bytes, params: 1, frame: 14 var defaultImport2; const defaultImport = importDefault(4662) /* metro dependency 4662: NativePermissionUtils */; const requestPermission = defaultImport.requestPermission; const AUDIO = NativePermissionTypes.AUDIO; Reflect.apply(requestPermission, defaultImport, [AUDIO]).then(_fun120118); const mode = MediaEngineStore.getMode(); const PUSH_TO_TALK = InputModes.PUSH_TO_TALK; if (mode === PUSH_TO_TALK) { defaultImport2 = defaultImport; defaultImport2.requestPermission(NativePermissionTypes.INPUT_MONITORING); } } function shouldImmediatelyRequestVoicePermissions(a0, a1) { // fn#120119, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15874:644, offset: 0x02521675, size: 70 bytes, params: 3, frame: 14 let r0 = ChannelStore.getChannel(a1)?.isListenModeCapable(); r0 = r0 ? StageChannelRoleStore.isSpeaker(a0, a1) : !r0; return r0; } function _fun120120(a0) { // fn#120120, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15874:799, offset: 0x025216bb, size: 97 bytes, params: 2, frame: 16 const closure = VoicePermissionManager; env0_7(closure, a0); return env0_4(closure, [{key: 'handleVoiceChannelSelect', value: value_120122}, {key: 'handleVoiceStateUpdates', value: function({voiceStates}) { voiceStates.forEach(_fun120124); }}]); } function _fun120118(a0) { // fn#120118, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15874:544, offset: 0x0252164b, size: 42 bytes, params: 2, frame: 11 var value; if (a0) { value = environment.__proto__; value = importDefault(15667) /* metro dependency 15667: setAudioInputEnabledAndroid */; value(true); } } function VoicePermissionManager(a0) { // fn#120121, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15874:811, offset: 0x0252171c, size: 156 bytes, params: 2, frame: 19 var r0; var Reflect; let value = copyRestArgs(0, undefined); let binding = env1_3; binding(this, VoicePermissionManager); const items = []; arraySpread(items, value, 0, items); value = env1_6(VoicePermissionManager); binding = env1_5; if (_isNativeReflectConstruct_120114()) { Reflect = global.Reflect; value = Reflect.construct(value, items, env1_6(this).constructor); r0 = value; } else { value = value.apply(this, items); r0 = value; } value = binding(this, r0); value.actions = {VOICE_STATE_UPDATES: value.handleVoiceStateUpdates, VOICE_CHANNEL_SELECT: value.handleVoiceChannelSelect}; return value; } function value_120122({channelId}) { // fn#120122, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15874:1270, offset: 0x025217b8, size: 25 bytes, params: 2, frame: 2 var value; if (channelId == null) { value = environment.__proto__; } } function value_120123({voiceStates}) { // fn#120123, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15874:1351, offset: 0x025217d1, size: 32 bytes, params: 2, frame: 11 voiceStates.forEach(_fun120124); } function _fun120124(a0) { // fn#120124, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15874:1388, offset: 0x025217f1, size: 200 bytes, params: 2, frame: 18 const userId = a0.userId; const channelId = a0.channelId; if (channelId != null) { var getId = AuthenticationStore.getId; if (Reflect.apply(getId, AuthenticationStore, []) !== userId) { return undefined; } var getRTCConnectionId = RTCConnectionStore.getRTCConnectionId; if (Reflect.apply(getRTCConnectionId, RTCConnectionStore, []) == null) { return undefined; } if (env2_16 === channelId) { return undefined; } if (shouldImmediatelyRequestVoicePermissions(userId, channelId)) { voicePermissionRequest(); return undefined; } var value2 = Object.create(VoiceStateRecord.prototype, {constructor: {value: VoiceStateRecord}}); var voiceStateRecord = new VoiceStateRecord(a0); var audienceRequestToSpeakState = (require(4802) /* metro dependency 4802: useAudienceRequestToSpeakState */).getAudienceRequestToSpeakState(voiceStateRecord instanceof Object ? voiceStateRecord : value2); var RequestToSpeakStates = (require(4802) /* metro dependency 4802: useAudienceRequestToSpeakState */).RequestToSpeakStates; var REQUESTED_TO_SPEAK_AND_AWAITING_USER_ACK = RequestToSpeakStates.REQUESTED_TO_SPEAK_AND_AWAITING_USER_ACK; if (audienceRequestToSpeakState === REQUESTED_TO_SPEAK_AND_AWAITING_USER_ACK) { voicePermissionRequest(); } } }