/* Metro module 4491; source: modules/go_live/native/VoiceEngineStreamingManager.tsx; dependencies: [6, 7, 15, 17, 18, 99, 100, 5, 27, 4492, 1379, 1934, 661, 4237, 3, 4041, 3829, 694, 507, 4285, 8913, 4261, 44, 7712, 1478, 10794, 10741, 1244, 4561, 2] */ function _fun38261(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#38261, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:6, offset: 0x010bb011, size: 596 bytes, params: 8, frame: 22 const env0_0 = require; 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 env0_8 = importDefault(99) /* metro dependency 99 */; let value = importDefault(100) /* metro dependency 100 */; const env0_9 = importDefault(5) /* metro dependency 5 */; const env0_10 = (require(27) /* metro dependency 27 */).Linking; const applicationStreamingStore = importDefault(4492) /* metro dependency 4492: ApplicationStreamingStore */; const channelStore = importDefault(1379) /* metro dependency 1379: ChannelStore */; const selectedChannelStore = importDefault(1934) /* metro dependency 1934: SelectedChannelStore */; const constantsModule = require(661) /* metro dependency 661: Constants */; const env0_14 = constantsModule.Base64JPEGPrefix; const env0_15 = constantsModule.Endpoints; const env0_16 = constantsModule.NOOP_NULL; const env0_17 = constantsModule.IOS_BUNDLE_ID; const env0_18 = (require(4237) /* metro dependency 4237: Constants */).getAppIntentScheme; const logger = importDefault(3) /* metro dependency 3: Logger */; const value5 = Object.create(logger.prototype, {constructor: {value: logger}}); const logger2 = new logger('VoiceEngineStreamingManager'); (logger2 instanceof Object ? logger2 : value5).enableNativeLogger(true); const Timeout = (require(4041) /* metro dependency 4041: Timers */).Timeout; let timeout = new Timeout(); timeout = new Timeout(); const env0_23 = []; const env0_24 = _fun38265(); const env0_25 = selectedChannelStore.getVoiceChannelId(); const env0_26 = value('handleVoiceChannelSelect'); value = importDefault(4561) /* metro dependency 4561: LifecycleManager */; value = _fun38270(value); value = new value(); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/go_live/native/VoiceEngineStreamingManager.tsx'); exports.default = value; } function _isNativeReflectConstruct_38262() { // fn#38262, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:336, offset: 0x010bb265, 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_38262_isNativeReflectConstruct = function() { return !!result; })(); } function _fun38265() { // fn#38265, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:666, offset: 0x010bb2c3, size: 32 bytes, params: 1, frame: 12 const env0_0 = env0_9(_fun38267); return _fun38269; } function _fun38270(a0) { // fn#38270, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:1167, offset: 0x010bb456, size: 116 bytes, params: 2, frame: 16 const closure = VoiceEngineStreamingManager; env0_7(closure, a0); return env0_4(closure, [{key: '_initialize', value: value_38274}, {key: '_terminate', value: value_38281}, {key: 'getApplicationNames', value: value_38282}]); } function* _fun38267(a0, a1) { // fn#38267, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:686, offset: 0x010bb2ec, size: 334 bytes, params: 3, frame: 20 var environment; var binding; var DisableStreamPreviews; var getSetting; var stop; var HermesInternal; var concat; var value3; var value4; var dispatch; var object3; var binding2; var property; var value5; var HTTP; var post; var STREAM_PREVIEW; var value6; var object4; var value7; var value8; var value9; var error; var error2; var start; if (true) { reduciblePort28: while (true) { exceptionLanding27: while (true) { var env0_0 = a0; var env0_1 = a1; value = environment.__proto__.__proto__; binding = env2_0; DisableStreamPreviews = binding(env2_2[16]).DisableStreamPreviews; getSetting = DisableStreamPreviews.getSetting; if (Reflect.apply(getSetting, DisableStreamPreviews, [])) { break reduciblePort28; } binding = env2_21; stop = binding.stop; Reflect.apply(stop, binding, []); binding = env2_14; HermesInternal = global.HermesInternal; concat = HermesInternal.concat; value3 = '' + binding + a1; binding = env2_1; value4 = binding(env2_2[17]); dispatch = value4.dispatch; Reflect.apply(dispatch, value4, [{type: 'STREAM_PREVIEW_FETCH_SUCCESS', streamKey: a0, previewURL: value3}]); try { binding = env2_0; } catch (error) { break exceptionLanding27; } try { binding2 = env2_2; } catch (error) { break exceptionLanding27; } try { property = binding2[18]; } catch (error) { break exceptionLanding27; } try { value5 = binding(property); } catch (error) { break exceptionLanding27; } try { HTTP = value5.HTTP; } catch (error) { break exceptionLanding27; } try { post = HTTP.post; } catch (error) { break exceptionLanding27; } try { object3 = {}; } catch (error) { break exceptionLanding27; } try { binding = env2_15; } catch (error) { break exceptionLanding27; } try { STREAM_PREVIEW = binding.STREAM_PREVIEW; } catch (error) { break exceptionLanding27; } try { value6 = Reflect.apply(STREAM_PREVIEW, binding, [a0]); } catch (error) { break exceptionLanding27; } try { object3.url = value6; } catch (error) { break exceptionLanding27; } try { object4 = {}; } catch (error) { break exceptionLanding27; } try { object4.thumbnail = value3; } catch (error) { break exceptionLanding27; } try { object3.body = object4; } catch (error) { break exceptionLanding27; } try { object3.oldFormErrors = true; } catch (error) { break exceptionLanding27; } try { object3.rejectWithError = false; } catch (error) { break exceptionLanding27; } try { value7 = Reflect.apply(post, HTTP, [object3]); } catch (error) { break exceptionLanding27; } yield value7; try { value8 = undefined; value9 = false; } catch (error) { break exceptionLanding27; } if (value9) { return value8; } break reduciblePort28; } binding = env2_19; error2 = binding.error; Reflect.apply(error2, binding, ['Failed to post stream preview', error]); binding = env2_21; start = binding.start; Reflect.apply(start, binding, [60000, _fun38268]); break reduciblePort28; } } } function VoiceEngineStreamingManager(a0) { // fn#38271, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:1179, offset: 0x010bb4ca, size: 170 bytes, params: 2, frame: 20 var r0; var Reflect; let value = copyRestArgs(0, undefined); let binding = env1_3; binding(this, VoiceEngineStreamingManager); const items = []; arraySpread(items, value, 0, items); value = env1_6(VoiceEngineStreamingManager); binding = env1_5; if (_isNativeReflectConstruct_38262()) { 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); const Object = global.Object; Object.defineProperty(value, env1_26, {writable: true, value: value_38272}); return value; } function value_38274() { // fn#38274, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:1781, offset: 0x010bb61b, size: 172 bytes, params: 1, frame: 16 const voiceEngine = (require(4261) /* metro dependency 4261: inject */).getVoiceEngine(); env1_20 = voiceEngine; voiceEngine.setBroadcastRequestCallback(_fun38275); let binding = env1_20; binding.setBroadcastFinishedCallback(_fun38278); env1_20.setBroadcastAnnotatedCallback(_fun38279); env1_20.setBroadcastBlockedCallback(_fun38280); const defaultImport = importDefault(694) /* metro dependency 694: Dispatcher */; const subscribe = defaultImport.subscribe; binding = env1_8; const binding2 = env1_26; Reflect.apply(subscribe, defaultImport, ['VOICE_CHANNEL_SELECT', binding(this, binding2)[binding2]]); } function value_38281() { // fn#38281, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:3164, offset: 0x010bba7b, size: 176 bytes, params: 1, frame: 15 const voiceEngine = (require(4261) /* metro dependency 4261: inject */).getVoiceEngine(); if (voiceEngine != null) { voiceEngine.setBroadcastRequestCallback(NOOP_NULL); voiceEngine.setBroadcastFinishedCallback(NOOP_NULL); voiceEngine.setBroadcastAnnotatedCallback(NOOP_NULL); voiceEngine.setBroadcastBlockedCallback(NOOP_NULL); } let binding = env1_21; binding.stop(); env1_22.stop(); const defaultImport = importDefault(694) /* metro dependency 694: Dispatcher */; const unsubscribe = defaultImport.unsubscribe; binding = env1_8; const binding2 = env1_26; Reflect.apply(unsubscribe, defaultImport, ['VOICE_CHANNEL_SELECT', binding(this, binding2)[binding2]]); } function _fun38268() { // fn#38268, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:1034, offset: 0x010bb43a, size: 28 bytes, params: 1, frame: 13 return env3_24(env0_0, require); } function VoiceEngineStreamingManagerValue({channelId}) { // fn#38272, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:1491, owner: VoiceEngineStreamingManager.value, offset: 0x010bb574, size: 82 bytes, params: 2, frame: 13 var binding; if (env2_25 !== channelId) { binding = env2_20; if (binding != null) { binding.stopBroadcast(); } ApplicationStreamingStore.getAllActiveStreams().forEach(_fun38273); } } function _fun38275() { // fn#38275, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:1851, offset: 0x010bb6c7, size: 385 bytes, params: 1, frame: 22 var guildId; var moduleValue; var startStream; var id; var currentUserActiveStream; var defaultImport2; var selectParticipant; var moduleValue2; env2_19.log('Broadcast Requested'); (importDefault(44) /* metro dependency 44 */)(env2_20 != null, 'Voice Engine should be initialized in callback'); env2_23 = []; const channel = ChannelStore.getChannel(SelectedChannelStore.getVoiceChannelId()); const currentAppIntent = ApplicationStreamingStore.getCurrentAppIntent(); if (channel != null) { guildId = channel.getGuildId(); moduleValue = require(8913) /* metro dependency 8913: StreamActionCreators */; startStream = moduleValue.startStream; id = channel.id; Reflect.apply(startStream, moduleValue, [guildId, id, {sourceId: 'screen:0'}]); currentUserActiveStream = ApplicationStreamingStore.getCurrentUserActiveStream(); if (currentUserActiveStream != null) { defaultImport2 = importDefault(7712) /* metro dependency 7712: ChannelRTCActionCreators */; selectParticipant = defaultImport2.selectParticipant; id = channel.id; moduleValue2 = require(4285) /* metro dependency 4285: StreamKeyUtils */; Reflect.apply(selectParticipant, defaultImport2, [id, moduleValue2.encodeStreamKey(currentUserActiveStream)]); if (env2_20.platform === 'android') { env2_22.start(15000, _fun38276); } if (currentAppIntent != null) { Linking.openURL(getAppIntentScheme(currentAppIntent)); } } } else { env2_20.stopBroadcastWithError(-1, 'Not currently in a voice channel'); } } function _fun38278() { // fn#38278, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:2707, offset: 0x010bb949, size: 86 bytes, params: 1, frame: 12 const value = environment.__proto__.__proto__; env2_19.log('Broadcast Finished'); env2_21.stop(); env2_22.stop(); (require(10794) /* metro dependency 10794: useScreenshareUtils */).handleCloseScreenshare(); } function _fun38279(a0) { // fn#38279, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:2828, offset: 0x010bb99f, size: 101 bytes, params: 2, frame: 15 var value2; let binding = env2_19; binding.log('Broadcast Annotated:', a0); if (a0 !== IOS_BUNDLE_ID) { binding = env2_23; value2 = binding.indexOf(a0, 0); if (value2 > -1) { env2_23.splice(value2, 1); } binding = env2_23; binding.push(a0); } } function _fun38280() { // fn#38280, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:2960, offset: 0x010bba04, size: 119 bytes, params: 1, frame: 17 env2_19.log('Broadcast Blocked'); const defaultImport = importDefault(10741) /* metro dependency 10741: PushNotification */; const presentLocalNotification = defaultImport.presentLocalNotification; const object2 = {}; const intl = (require(1244) /* metro dependency 1244: indexNative */).intl; object2.alertBody = intl.string((require(1244) /* metro dependency 1244: indexNative */).t.iYQlwv); Reflect.apply(presentLocalNotification, defaultImport, [object2]); } function _fun38273(a0) { // fn#38273, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:1587, offset: 0x010bb5c6, size: 85 bytes, params: 2, frame: 15 const channelId2 = a0.channelId; var value; if (channelId2 !== channelId) { value = environment.__proto__.__proto__.__proto__; value = require(4285) /* metro dependency 4285: StreamKeyUtils */; value = value.encodeStreamKey(a0); (require(8913) /* metro dependency 8913: StreamActionCreators */).stopStream(value, false); } } function _fun38276() { // fn#38276, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:2260, offset: 0x010bb848, size: 172 bytes, params: 1, frame: 18 (importDefault(44) /* metro dependency 44 */)(env3_20 != null, 'Voice Engine should be initialized in callback'); const windowDimensions = (require(1478) /* metro dependency 1478: useWindowDimensionsNative */).getWindowDimensions(); const value3 = 512 / windowDimensions.width; const value4 = 288 / windowDimensions.height; const Math = global.Math; const value5 = Math.min(value3, value4); env3_20.setBroadcastThumbnailCallback(windowDimensions.width * value5, windowDimensions.height * value5, 300, _fun38277); } function _fun38277(a0) { // fn#38277, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4669:2480, offset: 0x010bb8f4, size: 85 bytes, params: 2, frame: 15 const binding = env4_19; binding.log('Broadcast thumbnail of size:', a0.length); env4_24((require(4285) /* metro dependency 4285: StreamKeyUtils */).encodeStreamKey(env1_0), a0); }