/* Metro module 4795; source: stores/IdleStore.tsx; dependencies: [6, 7, 15, 17, 18, 1226, 661, 4291, 477, 3829, 672, 694, 3767, 4796, 6949, 566, 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 Flux from '../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */ import Durations from '../utils/Durations.tsx'; /* Metro dependency 672 */ import AuthenticationStore from './AuthenticationStore.tsx'; /* Metro dependency 1226 */ import SelectedChannelActionCreators from '../actions/SelectedChannelActionCreators.tsx'; /* Metro dependency 4796 */ import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */ import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 661 */ import * as UserSettingsModule from '../modules/user_settings/UserSettings.tsx'; /* Metro dependency 3829 */ import * as ConstantsModule2 from '../external/discord_common/js/packages/media-engine/Constants.tsx'; /* Metro dependency 4291 */ function _fun41515(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#41515, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:6, offset: 0x011201a3, size: 783 bytes, params: 8, frame: 23 var powerMonitor; const env0_0 = require; const checkIdleAFK2 = checkIdleAFK; const OVERLAY_SET_NOT_IDLE2 = OVERLAY_SET_NOT_IDLE; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const value = undefined; const Date = global.Date; let env0_13 = Date.now(); if ((require(477) /* metro dependency 477: PlatformUtils */).isPlatformEmbedded) { powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */) == null ? value : (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor; if (powerMonitor != null) { checkNativeIdle(); powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor; powerMonitor.on('resume', function() { env0_16 = false; handlePowerEvent(false); }); powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor; powerMonitor.on('suspend', _fun41526); powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor; powerMonitor.on('lock-screen', _fun41527); powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor; powerMonitor.on('unlock-screen', _fun41528); } else { global.setInterval(checkIdleAFK2, 30 * (importDefault(672) /* metro dependency 672: Durations */).Millis.SECOND); } } else { global.setInterval(checkIdleAFK2, 30 * (importDefault(672) /* metro dependency 672: Durations */).Millis.SECOND); } (importDefault(6949) /* metro dependency 6949 */)(function() { OVERLAY_SET_NOT_IDLE({}); }, 500); const Store = (Flux).Store; const value5 = _fun41530(Store); value5.displayName = 'IdleStore'; const value8 = new value5(importDefault(694) /* metro dependency 694: Dispatcher */, {IDLE: function(a0) { env0_14 = a0.idle; }, AFK: function(a0) { env0_15 = a0.afk; }, SPEAKING: function({userId, speakingFlags}) { if (speakingFlags !== SpeakingFlags.NONE && userId === AuthenticationStore.getId()) { OVERLAY_SET_NOT_IDLE({}); } return false; }, APP_STATE_UPDATE: function({state}) { env0_18 = state === AppStates.BACKGROUND; env0_12 = null; env0_13 = global.Date.now(); checkIdleAFK(); return false; }, OVERLAY_SET_NOT_IDLE: OVERLAY_SET_NOT_IDLE2, CHANNEL_SELECT: OVERLAY_SET_NOT_IDLE2, VOICE_CHANNEL_SELECT: OVERLAY_SET_NOT_IDLE2, WINDOW_FOCUS: OVERLAY_SET_NOT_IDLE2, OVERLAY_INITIALIZE: OVERLAY_SET_NOT_IDLE2, OVERLAY_SET_INPUT_LOCKED: OVERLAY_SET_NOT_IDLE2}); (FileImportTrackerModule).fileFinishedImporting('stores/IdleStore.tsx'); exports.default = value8; return value; function _isNativeReflectConstruct_41516() { // fn#41516, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:224, offset: 0x011204b2, 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_41516_isNativeReflectConstruct = function() { return !!result; })(); } function isSystemIdle() { // fn#41519, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:461, offset: 0x01120510, size: 61 bytes, params: 1, frame: 13 let r0 = env0_16 || env0_17; r0 = !r0 ? (require(477) /* metro dependency 477: PlatformUtils */).isAndroid() && env0_18 : r0; return r0; } function checkIdleAFK() { // fn#41520, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:521, offset: 0x0112054d, size: 427 bytes, params: 1, frame: 18 var value4; var Math; var min; const Date = global.Date; let value = Date.now(); value -= env0_13; if (value > IDLE_DURATION) { if (!env0_14) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'IDLE', 'idle': true, idleSince: env0_13}); } } else if (isSystemIdle()) { if (!env0_14) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'IDLE', 'idle': true, idleSince: env0_13}); } } else if (env0_14) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'IDLE', 'idle': false}); } const AfkTimeout = (UserSettingsModule).AfkTimeout; value = AfkTimeout.getSetting(); if (value === 0) { if (!env0_15) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'AFK', 'afk': true}); } } else if (env0_12 != null) { if (!env0_15) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'AFK', 'afk': true}); } } else { value4 = global.Date.now() - env0_13; Math = global.Math; min = Math.min; value *= (importDefault(672) /* metro dependency 672: Durations */).Millis.SECOND; if (value4 > Reflect.apply(min, Math, [value, IDLE_DURATION])) { if (!env0_15) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'AFK', 'afk': true}); } } else if (isSystemIdle()) { if (!env0_15) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'AFK', 'afk': true}); } } else if (env0_15) { (importDefault(694) /* metro dependency 694: Dispatcher */).dispatch({'type': 'AFK', 'afk': false}); } } } function handlePowerEvent(a0) { // fn#41521, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:928, offset: 0x011206f8, size: 45 bytes, params: 2, frame: 9 var value; if (a0) { value = global.Date.now(); } checkIdleAFK(); } function CHANNEL_SELECT_41522({timestamp, type, bypassIdleUpdate}) { // fn#41522, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1869, offset: 0x01120725, size: 112 bytes, params: 2, frame: 12 var value2; const r2 = type === 'OVERLAY_SET_NOT_IDLE' && timestamp != null; let r0 = r2 && timestamp <= env0_13; r0 = !r0 ? bypassIdleUpdate : r0; if (!r0) { if (!r2) { value2 = global.Date.now(); } checkIdleAFK(); } return false; } function checkNativeIdle() { // fn#41523, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1072, offset: 0x01120795, size: 152 bytes, params: 1, frame: 16 var getSystemIdleTimeMs; var powerMonitor; const handleIdleTime2 = handleIdleTime; var systemIdleTimeMs; const value2 = undefined; if ((importDefault(3767) /* metro dependency 3767: DiscordNative */) == null) { getSystemIdleTimeMs = value2; } else { powerMonitor = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor; getSystemIdleTimeMs = powerMonitor == null ? value2 : powerMonitor.getSystemIdleTimeMs; } if (getSystemIdleTimeMs != null) { systemIdleTimeMs = (importDefault(3767) /* metro dependency 3767: DiscordNative */).powerMonitor.getSystemIdleTimeMs(); if (systemIdleTimeMs instanceof global.Promise) { systemIdleTimeMs.then(handleIdleTime2); } else { handleIdleTime2(systemIdleTimeMs); } } return value2; function handleIdleTime(a0) { // fn#41524, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1120, owner: checkNativeIdle.handleIdleTime, offset: 0x0112082d, size: 144 bytes, params: 2, frame: 16 const Date = global.Date; let value = Date.now(); value -= a0; if (env1_12 == null || value > env1_12) { env1_13 = global.Math.max(value, env1_13); } checkIdleAFK(); const setTimeout = global.setTimeout; const checkNativeIdleBinding = checkNativeIdle; const Millis = (Durations).Millis; const SECOND = Millis.SECOND; setTimeout(checkNativeIdleBinding, 10 * SECOND); } } function _fun41526() { // fn#41526, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1564, offset: 0x011208d3, size: 52 bytes, params: 1, frame: 12 handlePowerEvent(true); (SelectedChannelActionCreators).disconnect(); } function _fun41527() { // fn#41527, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1660, offset: 0x01120907, size: 22 bytes, params: 1, frame: 11 handlePowerEvent(true); } function _fun41528() { // fn#41528, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:1736, offset: 0x0112091d, size: 22 bytes, params: 1, frame: 11 handlePowerEvent(false); } function _fun41530(a0) { // fn#41530, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:2050, offset: 0x01120945, size: 187 bytes, params: 2, frame: 16 const IdleStore2 = IdleStore; Inherits(IdleStore2, a0); return CreateClass(IdleStore2, [{key: 'initialize', value: function() { this.waitFor(AuthenticationStore); }}, {key: 'isIdle', value: value_41533}, {key: 'isAFK', value: value_41534}, {key: 'getIdleSince', value: value_41535}, {key: 'getSystemSuspended', value: value_41536}, {key: 'getSystemLocked', value: value_41537}]); function IdleStore() { // fn#41531, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:4973:2062, offset: 0x00e07435, size: 113 bytes, params: 1, frame: 20 const value = environment.__proto__; env1_3(this, IdleStore); const value3 = env1_6(IdleStore); return env1_5(this, _isNativeReflectConstruct_41516() ? global.Reflect.construct(value3, arguments, env1_6(this).constructor) : value3.apply(this, arguments)); } function value_41533() { // fn#41533, offset: 0x00df0f5a, size: 9 bytes, params: 1, frame: 1 return env1_14; } function value_41534() { // fn#41534, offset: 0x00df0e8b, size: 9 bytes, params: 1, frame: 1 return env1_15; } function value_41535() { // fn#41535, offset: 0x01120a00, size: 18 bytes, params: 1, frame: 3 return env1_14 ? env1_13 : null; } function value_41536() { // fn#41536, offset: 0x00df0e94, size: 9 bytes, params: 1, frame: 1 return env1_16; } function value_41537() { // fn#41537, offset: 0x00e07553, size: 9 bytes, params: 1, frame: 1 return env1_17; } } } global.__d(_fun41515, 4795, [6, 7, 15, 17, 18, 1226, 661, 4291, 477, 3829, 672, 694, 3767, 4796, 6949, 566, 2]) /* metro module 4795, dependencies: [6, 7, 15, 17, 18, 1226, 661, 4291, 477, 3829, 672, 694, 3767, 4796, 6949, 566, 2] */;