/* Metro module 6876; source: stores/SelfPresenceStore.tsx; dependencies: [6, 7, 15, 17, 18, 6867, 1348, 4267, 4795, 4270, 6877, 4396, 4296, 661, 4278, 3829, 1391, 6887, 644, 22, 566, 694, 2] */ function _fun54523(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#54523, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:6, offset: 0x01367670, size: 778 bytes, params: 8, frame: 24 const env0_0 = require; const _arrayLikeToArray_54529 = 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 shouldShowApplicationActivity = function(a0) { return require(dependencyMap[14]).shouldShareApplicationActivity(a0, LibraryApplicationStore); }; const closure = START_SESSION_54533; const closure2 = CONNECTION_OPEN_SUPPLEMENTAL_54536; let 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 spotifyStore = importDefault(6867) /* metro dependency 6867: SpotifyStore */; const userSettingsProtoStore = importDefault(1348) /* metro dependency 1348: UserSettingsProtoStore */; const detectableGameStore = importDefault(4267) /* metro dependency 4267: DetectableGameStore */; const idleStore = importDefault(4795) /* metro dependency 4795: IdleStore */; const libraryApplicationStore = importDefault(4270) /* metro dependency 4270: LibraryApplicationStore */; const localActivityStore = importDefault(6877) /* metro dependency 6877: LocalActivityStore */; const presenceStore = importDefault(4396) /* metro dependency 4396: PresenceStore */; const env0_15 = (require(4396) /* metro dependency 4396: PresenceStore */).sortActivity; const sessionsStore = importDefault(4296) /* metro dependency 4296: SessionsStore */; let value = require(661) /* metro dependency 661: Constants */; const StatusTypes = value.StatusTypes; const env0_18 = value.ActivityFlags; const env0_19 = value.ActivityTypes; const env0_20 = value.AppStates; const env0_22 = StatusTypes.ONLINE; let env0_23 = StatusTypes.UNKNOWN; const env0_25 = []; const env0_26 = []; Object = global.Object; const env0_29 = Object.freeze([]); Object = global.Object; const env0_30 = Object.freeze([]); const env0_31 = []; const env0_32 = []; const Store = (importDefault(566) /* metro dependency 566: flux */).Store; _fun54537(Store).displayName = 'SelfPresenceStore'; value = new value(importDefault(694) /* metro dependency 694: Dispatcher */, {START_SESSION: closure, CONNECTION_OPEN: function() { CONNECTION_OPEN_SUPPLEMENTAL_54536(); }, CONNECTION_OPEN_SUPPLEMENTAL: closure2, OVERLAY_INITIALIZE: closure2, CONNECTION_CLOSED: closure, IDLE: closure, AFK: closure, RUNNING_GAMES_CHANGE: closure, STREAMING_UPDATE: closure, USER_SETTINGS_PROTO_UPDATE: closure, LOCAL_ACTIVITY_UPDATE: closure, SPOTIFY_PLAYER_STATE: closure, SPOTIFY_PLAYER_PLAY: closure, USER_CONNECTIONS_UPDATE: closure, SESSIONS_REPLACE: closure, RPC_APP_DISCONNECTED: closure, LIBRARY_FETCH_SUCCESS: closure, LIBRARY_APPLICATION_FLAGS_UPDATE_SUCCESS: closure, LOGOUT: function() { env0_28 = true; env0_23 = ONLINE; START_SESSION_54533(); }, FORCE_INVISIBLE: function(a0) { env0_21 = a0.invisible; START_SESSION_54533(); }, WINDOW_FOCUS: function() { env0_21 = false; START_SESSION_54533(); }, APP_STATE_UPDATE: APP_STATE_UPDATE_54553}); (require(2) /* metro dependency 2 */).fileFinishedImporting('stores/SelfPresenceStore.tsx'); exports.default = value; } function _isNativeReflectConstruct_54524() { // fn#54524, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:336, offset: 0x0136797a, 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_54524_isNativeReflectConstruct = function() { return !!result; })(); } function _createForOfIteratorHelperLoose_54527(a0, a1) { // fn#54527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:529, offset: 0x013679d8, 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 _fun54528; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_54529(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_54529(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_54529(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun54528; } 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 filterPlayingActivities_54530(a0) { // fn#54530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:1545, offset: 0x01367b4a, size: 214 bytes, params: 2, frame: 21 var r10; var r5; var value4; var type; var PLAYING; var value5; if (a0.length === 0) { return a0; } const items5 = []; const items2 = []; const value2 = _createForOfIteratorHelperLoose_54527(a0); const value3 = value2(); let done = value3.done; if (!done) { r5 = value3; while (true) { value4 = r5.value; type = value4.type; PLAYING = ActivityTypes.PLAYING; if (type === PLAYING) { items2.push(value4); } else { items5.push(value4); } value5 = value2(); done = value5.done; if (done) { r10 = type; break; } r5 = value5; continue; } } if (items2.length === 0) { return a0; } if (items2.length === 1) { return a0; } const items3 = []; arraySpread(items3, items2, 0, r10); const property = items3.sort(sortActivity)[0]; const items4 = []; const value6 = arraySpread(items4, items5, 0, r10); items4[value6] = property; value6 + 1; return items4.sort(sortActivity); } function shouldShowActivity(a0) { // fn#54532, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:1924, offset: 0x01367c4e, size: 357 bytes, params: 2, frame: 19 var r0; var value4; const flagUtilsModule = require(1391) /* metro dependency 1391: FlagUtils */; const hasFlag = flagUtilsModule.hasFlag; const flags = a0.flags; const value2 = 0; const r5 = flags ?? value2; const CONTEXTLESS = ActivityFlags.CONTEXTLESS; if (Reflect.apply(hasFlag, flagUtilsModule, [r5, CONTEXTLESS])) { return true; } const type = a0.type; const LISTENING = ActivityTypes.LISTENING; if (LISTENING === type) { r0 = (importDefault(6887) /* metro dependency 6887: isListeningOnSpotify */)(a0) ? SpotifyStore.shouldShowActivity() : a0.application_id != null && shouldShowApplicationActivity(a0.application_id); } else { var PLAYING = ActivityTypes.PLAYING; if (PLAYING === type) { if (a0.application_id != null) { r0 = shouldShowApplicationActivity(a0.application_id); } else { value4 = DetectableGameStore.searchGamesByName(a0.name); r0 = value4.length === 1 ? shouldShowApplicationActivity(value4[value2]) : (require(3829) /* metro dependency 3829: UserSettings */).ShowCurrentGame.getSetting(); } return r0; } var STREAMING = ActivityTypes.STREAMING; if (STREAMING !== type) { ActivityTypes.WATCHING; } r0 = a0.application_id == null || shouldShowApplicationActivity(a0.application_id); } return r0; } function AFK_54533() { // fn#54533, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:2556, offset: 0x01367db3, size: 511 bytes, params: 1, frame: 19 var r6; var r3; var setting; var StatusTypesBinding; var INVISIBLE; var activities; var items2; var defaultImport2; var binding; var value15; const idleSince = IdleStore.getIdleSince(); const value3 = 0; let r0 = idleSince ?? value3; env0_24 = r0; env0_27 = IdleStore.isAFK(); if (!env0_28) { if (env0_21) { INVISIBLE = StatusTypes.INVISIBLE; } else { setting = (require(3829) /* metro dependency 3829: UserSettings */).StatusSetting.getSetting(); r0 = setting !== StatusTypes.UNKNOWN ? setting : StatusTypes.ONLINE; } } const ONLINE3 = StatusTypes.ONLINE; StatusTypesBinding = ONLINE === ONLINE3 && env0_24 > value3 ? StatusTypes : StatusTypesBinding; if (env0_28) { r6 = []; } else if (ONLINE === StatusTypes.INVISIBLE) { r6 = []; } else { activities = LocalActivityStore.getActivities(); r6 = activities.filter(shouldShowActivity); } if ((importDefault(644) /* metro dependency 644 */)(env0_25, r6)) { r3 = false; } else { env0_25 = r6; env0_26 = filterPlayingActivities_54530(r6); r3 = true; } const remoteActivities = SessionsStore.getRemoteActivities(); if (env0_29 !== remoteActivities) { env0_29 = remoteActivities; r3 = true; } if (env0_30 === SessionsStore.getHiddenActivities()) { } if (r3) { defaultImport2 = importDefault(22) /* metro dependency 22 */; binding = env0_25; items2 = []; value15 = arraySpread(items2, binding, value3, undefined); binding = env0_29; arraySpread(items2, binding.filter(function({type}) { return type !== ActivityTypes.CUSTOM_STATUS; }), value15, binding); env0_32 = filterPlayingActivities_54530(defaultImport2(items2.sort(sortActivity)).uniqBy(_fun54535).value()); } } function CONNECTION_OPEN_SUPPLEMENTAL_54536() { // fn#54536, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:3160, offset: 0x01368001, size: 61 bytes, params: 1, frame: 14 env0_23 = StatusTypes.UNKNOWN; START_SESSION_54533(); PresenceStore.setCurrentUserOnConnectionOpen(ONLINE, env0_31); } function _fun54537(a0) { // fn#54537, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:3268, offset: 0x0136803e, size: 254 bytes, params: 2, frame: 16 const closure = SelfPresenceStore; env0_7(closure, a0); return env0_4(closure, [{key: 'initialize', value: function() { this.waitFor(DetectableGameStore, IdleStore, LibraryApplicationStore, LocalActivityStore, PresenceStore, SessionsStore, SpotifyStore, UserSettingsProtoStore); this.syncWith([LocalActivityStore], START_SESSION_54533); }}, {key: 'getLocalPresence', value: value_54540}, {key: 'getStatus', value: function() { return ONLINE; }}, {key: 'getActivities', value: value_54542}, {key: 'getUnfilteredActivities', value: value_54543}, {key: 'getHiddenActivities', value: value_54544}, {key: 'getPrimaryActivity', value: function() { var value = a0; return this.getActivities(!(value !== undefined) || value)[0]; }}, {key: 'getApplicationActivity', value: function(a0) { var value = a1; var env0_0 = a0; return this.findActivity(_fun54547, !(value !== undefined) || value); }}, {key: 'findActivity', value: function(a0) { var value = a1; return this.getActivities(!(value !== undefined) || value).find(a0); }}]); } function APP_STATE_UPDATE_54553({state}) { // fn#54553, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:5203, offset: 0x01368335, size: 54 bytes, params: 2, frame: 10 const ACTIVE = AppStates.ACTIVE; if (state === ACTIVE) { if (env0_21) { START_SESSION_54533(); return undefined; } } return false; } function _fun54535({type, application_id, name}) { // fn#54535, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:3075, offset: 0x01367fcd, size: 52 bytes, params: 2, frame: 18 return '' + type + ':' + application_id + ':' + name; } function SelfPresenceStore() { // fn#54538, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:3280, offset: 0x0136813c, size: 113 bytes, params: 1, frame: 20 const value = environment.__proto__; env1_3(this, SelfPresenceStore); const value3 = env1_6(SelfPresenceStore); return env1_5(this, _isNativeReflectConstruct_54524() ? global.Reflect.construct(value3, arguments, env1_6(this).constructor) : value3.apply(this, arguments)); } function value_54540() { // fn#54540, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:3688, offset: 0x01368200, size: 42 bytes, params: 1, frame: 3 return {status: ONLINE, since: env1_24, activities: env1_26, afk: env1_27}; } function value_54542() { // fn#54542, offset: 0x0136822a, size: 29 bytes, params: 1, frame: 3 let value = a0; let r0 = !(value !== undefined) || value; value = environment.__proto__; r0 = r0 ? env1_32 : env1_26; return r0; } function value_54543() { // fn#54543, offset: 0x01368247, size: 29 bytes, params: 1, frame: 3 let value = a0; let r0 = !(value !== undefined) || value; value = environment.__proto__; r0 = r0 ? env1_31 : env1_25; return r0; } function value_54546(a0) { // fn#54546, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:7054:4086, offset: 0x01368285, size: 42 bytes, params: 2, frame: 13 const value = a1; const env0_0 = a0; return this.findActivity(_fun54547, !(value !== undefined) || value); }