/* Metro module 4607; source: stores/SpeakingStore.tsx; dependencies: [6, 7, 15, 17, 18, 57, 1379, 4259, 4294, 1934, 661, 4291, 3789, 4608, 566, 694, 2] */ import ClassCallCheck from '../by-id/module-00006-ClassCallCheck.js'; /* Metro dependency 6 */ import CreateClass from '../by-id/module-00007-CreateClass.js'; /* Metro dependency 7 */ import PossibleConstructorReturn from '../by-id/module-00015-PossibleConstructorReturn.js'; /* Metro dependency 15 */ import Module00017 from '../by-id/module-00017.js'; /* Metro dependency 17 */ import Inherits from '../by-id/module-00018-Inherits.js'; /* Metro dependency 18 */ import Module00057 from '../by-id/module-00057.js'; /* Metro dependency 57 */ import Flux from '../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */ import ChannelStore from './ChannelStore.tsx'; /* Metro dependency 1379 */ import SelectedChannelStore from './SelectedChannelStore.tsx'; /* Metro dependency 1934 */ import MediaEngineStore from './MediaEngineStore.tsx'; /* Metro dependency 4259 */ import RTCConnectionStore from './RTCConnectionStore.tsx'; /* Metro dependency 4294 */ import ProportionalVadIndicatorExperiment from '../modules/calls/ProportionalVadIndicatorExperiment.tsx'; /* Metro dependency 4608 */ import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 661 */ import * as ConstantsModule2 from '../external/discord_common/js/packages/media-engine/Constants.tsx'; /* Metro dependency 4291 */ function _fun39488(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#39488, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:6, offset: 0x010e321e, size: 547 bytes, params: 8, frame: 21 const _arrayLikeToArray_39494 = 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({user, sessionId}) { env0_17 = user.id; env0_18 = sessionId; env0_19 = null; }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const constantsModule = ConstantsModule2; const env0_14 = constantsModule.SpeakingFlags; const env0_15 = constantsModule.MediaEngineContextTypes; const Map = global.Map; let map = new Map(); const Store = (Flux).Store; _fun39500(Store).displayName = 'SpeakingStore'; map = new map(importDefault(694) /* metro dependency 694: Dispatcher */, {CONNECTION_OPEN: closure, OVERLAY_INITIALIZE: closure, SPEAKING: SPEAKING_39517, VOICE_STATE_UPDATES: function({voiceStates}) { return voiceStates.reduce(_fun39519, false); }, PUSH_TO_TALK_STATE_CHANGE: function(a0) { env0_20 = a0.isActive; }}); (FileImportTrackerModule).fileFinishedImporting('stores/SpeakingStore.tsx'); exports.default = map; function _isNativeReflectConstruct_39489() { // fn#39489, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:282, offset: 0x010e3441, 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_39489_isNativeReflectConstruct = function() { return !!result; })(); } function _createForOfIteratorHelperLoose_39492(a0, a1) { // fn#39492, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:475, offset: 0x010e349f, 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 _fun39493; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_39494(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_39494(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_39494(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun39493; } 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 _fun39493() { // fn#39493, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:1046, 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 clearSpeakingFlagsInContext(a0, a1) { // fn#39495, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:1425, offset: 0x010e3611, size: 70 bytes, params: 3, frame: 13 const value2 = env0_16.get(a0); if (value2 == null) { return false; } const value3 = value2.delete(a1); if (value2.size === 0) { env0_16.delete(a0); } return value3; } function hasSpeakingFlagInContext(a0, a1, a2) { // fn#39496, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:1553, offset: 0x010e3657, size: 85 bytes, params: 4, frame: 16 var flags; var value4; const value2 = env0_16.get(a0); const value3 = undefined; if (value2 == null) { flags = value3; } else { value4 = value2.get(a1); flags = value4 == null ? value3 : value4.flags; } return ((flags ?? SpeakingFlags.NONE) & a2) === a2; } function anyoneHasFlagInContext(a0, a1) { // fn#39497, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:1691, offset: 0x010e36ac, size: 145 bytes, params: 3, frame: 21 var r8; var r1; var value5; var value6; var property; var flags; var value7; let value = a2; reducibleJoin2: while (true) { if (value !== undefined) { r8 = value; break reducibleJoin2; } value = false; r8 = value; break reducibleJoin2; } const value2 = env0_16.get(a0); if (value2 != null) { var value3 = _createForOfIteratorHelperLoose_39492(value2); var value4 = value3(); var done = value4.done; if (!done) { r1 = value4; reducibleLoop4: while (true) { value5 = r1.value; value6 = Module00057(value5, 2); property = value6[0]; flags = value6[1].flags; if (r8) { reducibleJoin6: while (true) { if (property === env0_17) { value7 = value3(); done = value7.done; if (done) { return false; } r1 = value7; continue reducibleLoop4; } break reducibleJoin6; } } if ((flags & a1) === a1) { return true; } value7 = value3(); done = value7.done; if (done) { return false; } r1 = value7; continue reducibleLoop4; } } } return false; } function setSpeakingFlagForUserInContext(a0, a1, a2) { // fn#39498, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:1918, offset: 0x010e373d, size: 358 bytes, params: 4, frame: 22 var r1; var since; var r8; var map; var VOICE; var value14; let value = a0; const value2 = a3; const value3 = undefined; const r7 = value2 !== value3 ? value2 : -Infinity; const r3 = value !== value3 ? value : MediaEngineContextTypes.DEFAULT; const value7 = env0_16.get(r3); const value8 = null; if (value8 != value7) { r1 = value7; } else { map = new global.Map(); env0_16.set(r3, map); r1 = map; } const value11 = r1.get(a1); const flags = value8 == value11 ? value3 : value11.flags; const value12 = 0; const r10 = value8 != flags ? flags : value12; if (value12 !== r10) { if (value12 === a2) { r1.delete(a1); if (value12 === r1.size) { env0_16.delete(value); } } else { since = value8 == value11 ? value3 : value11.since; r8 = value8 != since ? since : value8; VOICE = SpeakingFlags.VOICE; value = r10 & VOICE; VOICE = SpeakingFlags.VOICE; value14 = (a2 & SpeakingFlags.VOICE) === SpeakingFlags.VOICE; r8 = value === VOICE !== value14 ? value14 ? global.Date.now() : value8 : r8; r1.set(a1, {flags: a2, since: r8, voiceDb: r7}); } } else { if (value12 === a2) { return false; } if (value12 === a2) { r1.delete(a1); if (value12 === r1.size) { env0_16.delete(value); } } else { since = value8 == value11 ? value3 : value11.since; r8 = value8 != since ? since : value8; VOICE = SpeakingFlags.VOICE; value = r10 & VOICE; VOICE = SpeakingFlags.VOICE; value14 = (a2 & SpeakingFlags.VOICE) === SpeakingFlags.VOICE; r8 = value === VOICE !== value14 ? value14 ? global.Date.now() : value8 : r8; r1.set(a1, {flags: a2, since: r8, voiceDb: r7}); } } return true; } function _fun39500(a0) { // fn#39500, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:2457, offset: 0x010e38cb, size: 358 bytes, params: 2, frame: 16 const SpeakingStore2 = SpeakingStore; Inherits(SpeakingStore2, a0); return CreateClass(SpeakingStore2, [{key: 'initialize', value: function() { this.mustEmitChanges(_fun39503); this.waitFor(ChannelStore, MediaEngineStore, RTCConnectionStore, SelectedChannelStore); }}, {key: 'getSpeakingDuration', value: value_39504}, {key: 'getSpeakers', value: value_39505}, {key: 'isSpeaking', value: value_39507}, {key: 'isPrioritySpeaker', value: value_39508}, {key: 'isSoundSharing', value: value_39509}, {key: 'isAnyoneElseSpeaking', value: value_39510}, {key: 'isCurrentUserSpeaking', value: value_39511}, {key: 'isCurrentUserPTTActive', value: value_39512}, {key: 'isAnyonePrioritySpeaking', value: value_39513}, {key: 'isCurrentUserPrioritySpeaker', value: value_39514}, {key: 'isCurrentUserPrioritySpeaking', value: value_39515}, {key: 'getVoiceVolume', value: value_39516}]); function SpeakingStore() { // fn#39501, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:2469, offset: 0x010e3a31, size: 113 bytes, params: 1, frame: 20 const value = environment.__proto__; env1_3(this, SpeakingStore); const value3 = env1_6(SpeakingStore); return env1_5(this, _isNativeReflectConstruct_39489() ? global.Reflect.construct(value3, arguments, env1_6(this).constructor) : value3.apply(this, arguments)); } function value_39502() { // fn#39502, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:2752, offset: 0x010e3aa2, size: 57 bytes, params: 1, frame: 17 this.mustEmitChanges(function(a0) { return a0.type !== 'CONNECTION_OPEN' && a0.type !== 'VOICE_STATE_UPDATES'; }); this.waitFor(ChannelStore, MediaEngineStore, RTCConnectionStore, SelectedChannelStore); } function value_39504(a0, a1) { // fn#39504, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:2906, offset: 0x010e3adb, size: 96 bytes, params: 3, frame: 14 var since; let value = a2; const value2 = undefined; const r2 = value !== value2 ? value : MediaEngineContextTypes.DEFAULT; value = environment.__proto__; value = env1_16.get(r2); if (value == null) { since = value2; } else { value = value.get(a0); since = value == null ? value2 : value.since; } return since != null ? a1 - since : 0; } function value_39505() { // fn#39505, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:3042, offset: 0x010e3b3b, size: 108 bytes, params: 1, frame: 15 var environment; var r3; let value = a0; const value2 = undefined; const r6 = value !== value2 ? value : MediaEngineContextTypes.DEFAULT; const Array = global.Array; const from = Array.from; value = environment.__proto__; value = env1_16.get(r6); if (value == null) { r3 = value2; } else { value = value.keys(); r3 = value; } r3 = r3 ?? []; return Reflect.apply(from, Array, [r3]).filter(_fun39506); function _fun39506(a0) { // fn#39506, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:3149, offset: 0x010e3ba7, size: 38 bytes, params: 2, frame: 15 const hasSpeakingFlagInContextBinding = hasSpeakingFlagInContext; const binding = env0_0; const VOICE = SpeakingFlags.VOICE; return hasSpeakingFlagInContextBinding(binding, a0, VOICE); } } function value_39507(a0) { // fn#39507, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:3218, offset: 0x010e3bcd, size: 51 bytes, params: 2, frame: 15 let value = a1; const r4 = value !== undefined ? value : MediaEngineContextTypes.DEFAULT; value = environment.__proto__; const hasSpeakingFlagInContextBinding = hasSpeakingFlagInContext; const VOICE = SpeakingFlags.VOICE; return hasSpeakingFlagInContextBinding(r4, a0, VOICE); } function value_39508(a0) { // fn#39508, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:3320, offset: 0x010e3c00, size: 51 bytes, params: 2, frame: 15 let value = a1; const r4 = value !== undefined ? value : MediaEngineContextTypes.DEFAULT; value = environment.__proto__; const hasSpeakingFlagInContextBinding = hasSpeakingFlagInContext; const PRIORITY = SpeakingFlags.PRIORITY; return hasSpeakingFlagInContextBinding(r4, a0, PRIORITY); } function value_39509(a0) { // fn#39509, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:3422, offset: 0x010e3c33, size: 51 bytes, params: 2, frame: 15 let value = a1; const r4 = value !== undefined ? value : MediaEngineContextTypes.DEFAULT; value = environment.__proto__; const hasSpeakingFlagInContextBinding = hasSpeakingFlagInContext; const SOUNDSHARE = SpeakingFlags.SOUNDSHARE; return hasSpeakingFlagInContextBinding(r4, a0, SOUNDSHARE); } function value_39510() { // fn#39510, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:3532, offset: 0x010e3c66, size: 50 bytes, params: 1, frame: 15 let value = a0; const r4 = value !== undefined ? value : MediaEngineContextTypes.DEFAULT; value = environment.__proto__; const anyoneHasFlagInContextBinding = anyoneHasFlagInContext; const VOICE = SpeakingFlags.VOICE; return anyoneHasFlagInContextBinding(r4, VOICE, true); } function value_39511() { // fn#39511, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:3635, offset: 0x010e3c98, size: 59 bytes, params: 1, frame: 14 let value = a0; const r4 = value !== undefined ? value : MediaEngineContextTypes.DEFAULT; value = environment.__proto__; return env1_17 != null && this.isSpeaking(env1_17, r4); } function value_39512() { // fn#39512, offset: 0x00e4253a, size: 9 bytes, params: 1, frame: 1 return env1_20; } function value_39513() { // fn#39513, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:3792, offset: 0x010e3cd3, size: 61 bytes, params: 1, frame: 14 let value = a0; const r3 = value !== undefined ? value : MediaEngineContextTypes.DEFAULT; value = environment.__proto__; const anyoneHasFlagInContextBinding = anyoneHasFlagInContext; const VOICE = SpeakingFlags.VOICE; const PRIORITY = SpeakingFlags.PRIORITY; return anyoneHasFlagInContextBinding(r3, VOICE | PRIORITY); } function value_39514() { // fn#39514, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:3910, offset: 0x010e3d10, size: 59 bytes, params: 1, frame: 14 let value = a0; const r4 = value !== undefined ? value : MediaEngineContextTypes.DEFAULT; value = environment.__proto__; return env1_17 != null && this.isPrioritySpeaker(env1_17, r4); } function value_39515() { // fn#39515, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:4021, offset: 0x010e3d4b, size: 78 bytes, params: 1, frame: 15 let value = a0; const r4 = value !== undefined ? value : MediaEngineContextTypes.DEFAULT; value = environment.__proto__; return env1_17 != null && this.isPrioritySpeaker(env1_17, r4) && this.isSpeaking(env1_17, r4); } function value_39516(a0) { // fn#39516, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:4139, offset: 0x010e3d99, size: 169 bytes, params: 2, frame: 16 var voiceDb; var r0; let value = a1; const value2 = undefined; const r4 = value !== value2 ? value : MediaEngineContextTypes.DEFAULT; value = environment.__proto__; const config = (ProportionalVadIndicatorExperiment).getConfig({location: 'SpeakingStore'}); const enabled = config.enabled; const value4 = -Infinity; if (enabled) { if (config.disableUI) { r0 = value4; } else { value = env1_16.get(r4); if (value == null) { voiceDb = value2; } else { value = value.get(a0); voiceDb = value == null ? value2 : value.voiceDb; } r0 = voiceDb ?? value4; } } else { r0 = value4; } return r0; } } function SPEAKING_39517({context, userId, speakingFlags, voiceDb}) { // fn#39517, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:4484, offset: 0x010e3e42, size: 269 bytes, params: 2, frame: 22 var r2; var channelStoreBinding; var getChannel; var selectedChannelStoreBinding; var value3; var moduleValue; var can; var object; let PRIORITY = SpeakingFlags.PRIORITY; const value2 = speakingFlags & PRIORITY; PRIORITY = SpeakingFlags.PRIORITY; if (value2 !== PRIORITY) { r2 = speakingFlags; } else { channelStoreBinding = ChannelStore; getChannel = channelStoreBinding.getChannel; selectedChannelStoreBinding = SelectedChannelStore; value3 = Reflect.apply(getChannel, channelStoreBinding, [selectedChannelStoreBinding.getVoiceChannelId()]); if (value3 == null) { MediaEngineStore.setCanHavePriority(userId, false); r2 = speakingFlags & ~SpeakingFlags.PRIORITY; } else { moduleValue = importAll(3789) /* metro dependency 3789: PermissionUtils */; can = moduleValue.can; object = {}; object.permission = Permissions.PRIORITY_SPEAKER; object.user = userId; object.context = value3; if (Reflect.apply(can, moduleValue, [object])) { MediaEngineStore.setCanHavePriority(userId, true); r2 = speakingFlags; } else { MediaEngineStore.setCanHavePriority(userId, false); r2 = speakingFlags & ~SpeakingFlags.PRIORITY; } } } let HIDDEN = SpeakingFlags.HIDDEN; const value5 = r2 & HIDDEN; HIDDEN = SpeakingFlags.HIDDEN; r2 = value5 === HIDDEN ? 0 : r2; return setSpeakingFlagForUserInContext(context, userId, r2, voiceDb); } function VOICE_STATE_UPDATES_39518({voiceStates}) { // fn#39518, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:4873, offset: 0x010e3f4f, size: 32 bytes, params: 2, frame: 13 return voiceStates.reduce(_fun39519, false); function _fun39519(a0, {userId, channelId, sessionId}) { // fn#39519, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:4940, offset: 0x010e3f6f, size: 330 bytes, params: 3, frame: 19 const value = a0; const binding = env1_19; let r0 = userId === env1_17 && sessionId === env1_18; env1_19 = r0 ? channelId ?? null : env1_19; const r4 = !(binding === env1_19) && (env1_16.delete(MediaEngineContextTypes.DEFAULT) || false); r0 = channelId == null ? userId !== env1_17 ? clearSpeakingFlagsInContext(MediaEngineContextTypes.DEFAULT, userId) || r4 : sessionId === env1_18 ? env1_16.delete(MediaEngineContextTypes.DEFAULT) || r4 : clearSpeakingFlagsInContext(MediaEngineContextTypes.DEFAULT, userId) || r4 : userId !== env1_17 ? userId !== env1_17 && channelId !== RTCConnectionStore.getChannelId() ? clearSpeakingFlagsInContext(MediaEngineContextTypes.DEFAULT, userId) || r4 : r4 : sessionId !== env1_18 ? env1_16.delete(MediaEngineContextTypes.DEFAULT) || r4 : userId !== env1_17 && channelId !== RTCConnectionStore.getChannelId() ? clearSpeakingFlagsInContext(MediaEngineContextTypes.DEFAULT, userId) || r4 : r4; r0 = !r0 ? value : r0; return r0; } } } function _fun39503(a0) { // fn#39503, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4785:2785, offset: 0x00eef690, size: 34 bytes, params: 2, frame: 3 return a0.type !== 'CONNECTION_OPEN' && a0.type !== 'VOICE_STATE_UPDATES'; } global.__d(_fun39488, 4607, [6, 7, 15, 17, 18, 57, 1379, 4259, 4294, 1934, 661, 4291, 3789, 4608, 566, 694, 2]) /* metro module 4607, dependencies: [6, 7, 15, 17, 18, 57, 1379, 4259, 4294, 1934, 661, 4291, 3789, 4608, 566, 694, 2] */;