/* Metro module 4873; source: modules/network/NetStats.android.tsx; dependencies: [5, 6, 7, 27, 4257, 4874, 1867, 661, 3, 1460, 1459, 4883, 672, 587, 694, 4014, 4875, 4884, 14, 2] */ function _fun42678(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#42678, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:6, offset: 0x0113f70d, size: 599 bytes, params: 8, frame: 22 var object2; const env0_0 = require; const closure = receiveNetworkInfoformation; const updateNetworkUsage = function() { if (NativeModules.SystemResourceManager.getNetworkUsage != null) { NativeModules.SystemResourceManager.getNetworkUsage(_fun42681); } }; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_3 = importDefault(5) /* metro dependency 5 */; const env0_4 = importDefault(6) /* metro dependency 6 */; const env0_5 = importDefault(7) /* metro dependency 7 */; let value = require(27) /* metro dependency 27 */; const AppState = value.AppState; const env0_6 = value.NativeModules; const gatewayConnectionStore = importDefault(4257) /* metro dependency 4257: GatewayConnectionStore */; const analyticsTrackingStore = importDefault(4874) /* metro dependency 4874: AnalyticsTrackingStore */; const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */; const env0_10 = (require(661) /* metro dependency 661: Constants */).AnalyticEvents; value = importDefault(3) /* metro dependency 3: Logger */; value = new value('NetStats'); const env0_12 = {'signalStrengthLevel': null, 'isNetworkRoaming': false, 'cellularReceiveBytes': 0, 'cellularSendBytes': 0, 'totalReceiveBytes': 0, 'totalSendBytes': 0, 'uidReceiveBytes': 0, 'uidSendBytes': 0, 'socketBytesReceived': 0, 'otaBytesReceived': 0, 'otaNumRequests': 0, 'xhrBytesReceived': 0, 'xhrNumRequests': 0, 'frescoBytesReceived': 0, 'frescoNumRequests': 0, 'downloadBytesReceived': 0, 'downloadNumRequests': 0, 'mediaPlayerBytesReceived': 0}; object2 = {'type': null, 'effectiveSpeed': null, 'serviceProvider': null}; const NetInfoStateType = (require(1460) /* metro dependency 1460 */).NetInfoStateType; object2.type = NetInfoStateType.unknown; const result = AppState.currentState === 'active'; (importDefault(1459) /* metro dependency 1459: NetworkUtils */).addChangeCallback(closure); value = importDefault(1459) /* metro dependency 1459: NetworkUtils */; value = value.getNetworkInformation(); value.then(closure); value = _fun42682(); value = new value(); (importDefault(694) /* metro dependency 694: Dispatcher */).subscribe('APP_STATE_UPDATE', _fun42703); (importDefault(694) /* metro dependency 694: Dispatcher */).subscribe('MESSAGE_CREATE', _fun42704); (importDefault(694) /* metro dependency 694: Dispatcher */).subscribe('MESSAGE_SEND_FAILED', _fun42705); (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/network/NetStats.android.tsx'); exports.isSlowNetwork = isSlowNetwork; exports.getSignalStrength = getSignalStrength; } function receiveNetworkInfoformation(a0) { // fn#42679, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:763, offset: 0x0113f964, size: 36 bytes, params: 2, frame: 11 env0_14 = a0; if (env0_15 == null) { env0_15 = a0; } updateNetworkUsage(); } function updateNetworkUsage() { // fn#42680, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:843, offset: 0x0113f988, size: 57 bytes, params: 1, frame: 11 const SystemResourceManager = NativeModules.SystemResourceManager; const getNetworkUsage = SystemResourceManager.getNetworkUsage; if (getNetworkUsage != null) { NativeModules.SystemResourceManager.getNetworkUsage(_fun42681); } } function _fun42682() { // fn#42682, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1208, offset: 0x0113fa2d, size: 170 bytes, params: 1, frame: 17 const binding = env0_5; const closure = EventTracker; const items2 = [{key: 'handleAppStateChange', value: value_42689}]; const binding2 = env0_3; const env0_2 = binding2(_fun42693); items2[1] = {key: 'writeExistingEventStorage', value: value_42694}; const env0_1 = binding2(_fun42696); items2[2] = {key: 'track', value: value_42699}; const env0_0 = binding2(_fun42701); items2[3] = {key: 'getQueuedEvent', value: value_42702}; return binding(closure, items2); } function _fun42703({state}) { // fn#42703, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:5234, offset: 0x01140486, size: 38 bytes, params: 2, frame: 12 env0_21.handleAppStateChange(state === 'active'); } function _fun42704(a0) { // fn#42704, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:5321, offset: 0x011404ac, size: 135 bytes, params: 2, frame: 17 var binding; var Math; var max; let sendMessageOptions = a0.sendMessageOptions; const value = undefined; let sendAnalytics = sendMessageOptions == null ? value : sendMessageOptions.sendAnalytics; if (sendAnalytics != null) { binding = env0_17; env0_17 = typeof binding === 'bigint' ? binding + 1n : +binding + 1; Math = global.Math; max = Math.max; binding = env0_18; sendMessageOptions = a0.sendMessageOptions; sendAnalytics = sendMessageOptions.sendAnalytics; env0_18 = Reflect.apply(max, Math, [binding, sendAnalytics.duration]); Math = global.Math; max = Math.max; binding = env0_19; sendMessageOptions = a0.sendMessageOptions; sendAnalytics = sendMessageOptions.sendAnalytics; env0_19 = Reflect.apply(max, Math, [binding, sendAnalytics.queueSize]); } return value; } function _fun42705() { // fn#42705, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:5562, offset: 0x01140533, size: 18 bytes, params: 1, frame: 2 const binding = env0_20; env0_20 = typeof binding === 'bigint' ? binding + 1n : +binding + 1; } function isSlowNetwork() { // fn#42706, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:5662, offset: 0x01140545, size: 128 bytes, params: 1, frame: 13 var r1; var r0; const type = env0_14.type; const NetInfoStateType = (require(1460) /* metro dependency 1460 */).NetInfoStateType; const value2 = type === NetInfoStateType.cellular; if (value2) { r1 = env0_12.signalStrengthLevel != null && env0_12.signalStrengthLevel <= 2; r1 = !r1 ? env0_14.effectiveSpeed === '2g' : r1; r1 = !r1 ? env0_12.isNetworkRoaming : r1; r0 = r1; } else { r0 = value2; } return r0; } function getSignalStrength() { // fn#42707, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:5861, offset: 0x011405c5, size: 15 bytes, params: 1, frame: 1 return env0_12.signalStrengthLevel; } function _fun42681(a0) { // fn#42681, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:961, offset: 0x0113f9c1, size: 108 bytes, params: 2, frame: 15 const value = environment.__proto__; env1_12 = a0; if (env1_13 == null) { env1_13 = a0; } const binding = env1_11; const fileOnly = binding.fileOnly; const object2 = {state: env1_14, nativeStats: env1_12}; object2.rtc = (require(4883) /* metro dependency 4883: RTCBandwidthMonitor */).getRTCTotalBytes(); Reflect.apply(fileOnly, binding, ['Updating Network Info', object2]); } function EventTracker() { // fn#42683, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1229, offset: 0x0113fad7, size: 327 bytes, params: 1, frame: 19 var environment; var trackExistingEvents; let value = environment.__proto__; env1_4(this, EventTracker); const resultBinding = result; const value3 = 0; this.trackTimeout = resultBinding ? global.setTimeout(_fun42684, 1 * (importDefault(672) /* metro dependency 672: Durations */).Millis.MINUTE) : value3; this.flushStorageInterval = result ? global.setInterval(_fun42685, 5 * (importDefault(672) /* metro dependency 672: Durations */).Millis.SECOND) : value3; this.didEverTrack = false; const Storage = (require(587) /* metro dependency 587: Storage */).Storage; this.existingEvents = Storage.get('previousNetStatsEvents') ?? []; this.trackExistingEvents = trackExistingEvents; if (GatewayConnectionStore.isConnected()) { this.trackExistingEvents(); } else { value = importDefault(694) /* metro dependency 694: Dispatcher */; value.subscribe('CONNECTION_OPEN', this.trackExistingEvents); } } function value_42689(a0) { // fn#42689, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2090, offset: 0x0113fd1e, size: 156 bytes, params: 2, frame: 16 var environment; var value; var resultBinding; if (!this.didEverTrack) { value = environment.__proto__; resultBinding = result; if (a0) { if (!resultBinding) { this.trackTimeout = global.setTimeout(_fun42690, 1 * (importDefault(672) /* metro dependency 672: Durations */).Millis.MINUTE); this.flushStorageInterval = global.setInterval(_fun42691, 5000); } } else if (resultBinding) { this.track(); } } } function* _fun42693() { // fn#42693, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2351, offset: 0x0113fdd5, size: 202 bytes, params: 1, frame: 14 var value4; let value = undefined; if (false) { return value; } if (this.didEverTrack) { value = this.existingEvents.concat([]); if (value.length === 0) { value = environment.__proto__.__proto__; env2_0(env2_2[13]).Storage.remove('previousNetStatsEvents'); } else { value4 = environment.__proto__.__proto__; env2_0(env2_2[13]).Storage.set('previousNetStatsEvents', value); } } else { value = environment.__proto__.__proto__; if (env2_16) { yield this.getQueuedEvent(); value = undefined; if (false) { return value; } value = this.existingEvents.concat([value]); if (value.length === 0) { value = environment.__proto__.__proto__; env2_0(env2_2[13]).Storage.remove('previousNetStatsEvents'); } else { value4 = environment.__proto__.__proto__; env2_0(env2_2[13]).Storage.set('previousNetStatsEvents', value); } return undefined; } value = this.existingEvents.concat([]); if (value.length === 0) { value = environment.__proto__.__proto__; env2_0(env2_2[13]).Storage.remove('previousNetStatsEvents'); } else { value4 = environment.__proto__.__proto__; env2_0(env2_2[13]).Storage.set('previousNetStatsEvents', value); } } } function* _fun42696() { // fn#42696, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2667, offset: 0x0113fea8, size: 173 bytes, params: 1, frame: 15 var environment; let value = undefined; if (false) { return value; } if (!this.didEverTrack) { this.didEverTrack = true; global.clearTimeout(this.trackTimeout); global.clearInterval(this.flushStorageInterval); var getQueuedEvent = this.getQueuedEvent; yield Reflect.apply(getQueuedEvent, this, []); value = undefined; if (false) { return value; } var items2 = [value]; value = environment.__proto__.__proto__; value = env2_8.submitEventsImmediately(items2); value = value.then(_fun42697); value.catch(_fun42698); } } function* _fun42701() { // fn#42701, original name: ?anon_0_, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:3201, offset: 0x0113fff1, size: 1173 bytes, params: 1, frame: 22 if (false) { return undefined; } value = environment.__proto__.__proto__; const value3 = undefined; env2_22(); let binding = env2_1; const value4 = binding(env2_2[15]); const getAppFirstVisibleTimestamp = value4.getAppFirstVisibleTimestamp; yield Reflect.apply(getAppFirstVisibleTimestamp, value4, []); const value5 = undefined; if (false) { return value5; } const value7 = env2_0(env2_2[16]); const getSession = value7.getSession; yield Reflect.apply(getSession, value7, []); const value8 = undefined; if (false) { return value8; } const object3 = {}; const APP_NETWORK_USAGE = env2_10.APP_NETWORK_USAGE; object3.type = APP_NETWORK_USAGE; const object4 = {}; const value10 = env2_0(env2_2[17]); const getDeviceMetadata = value10.getDeviceMetadata; copyDataProperties(object4, Reflect.apply(getDeviceMetadata, value10, []), undefined); const Date = global.Date; object4['client_track_timestamp'] = Date.now(); object4['client_heartbeat_session_id'] = value8 == null ? value3 : value8.uuid; binding = env2_0; const binding2 = env2_2; object4['load_id'] = binding(binding2[17]).currentLoadId(); object4['num_guilds'] = env2_9.getGuildCount(); binding = env2_1; object4['was_authenticated'] = binding(binding2[18]).wasAuthenticated; object4['did_background_app'] = binding(binding2[18]).didBackgroundApp; object4['headless_task_ran'] = binding(binding2[18]).extraProperties.headless_task_ran; object4['ready_payload_duration_ms'] = binding(binding2[18]).ready.serializeEnd(value5); binding = env2_13; object4['initial_signal_strength_level'] = (binding == null ? value3 : binding.signalStrengthLevel) ?? value3; object4['final_signal_strength_level'] = env2_12.signalStrengthLevel ?? value3; binding = env2_15; object4['initial_network_type'] = (binding == null ? value3 : binding.type) ?? value3; object4['final_network_type'] = env2_14.type; binding = env2_15; object4['initial_cellular_generation'] = (binding == null ? value3 : binding.effectiveSpeed) ?? value3; object4['final_cellular_generation'] = env2_14.effectiveSpeed; object4['is_network_roaming'] = env2_12.isNetworkRoaming; object4['cellular_receive_bytes'] = env2_12.cellularReceiveBytes; object4['cellular_send_bytes'] = env2_12.cellularSendBytes; object4['total_receive_bytes'] = env2_12.totalReceiveBytes; object4['total_send_bytes'] = env2_12.totalSendBytes; object4['uid_receive_bytes'] = env2_12.uidReceiveBytes; object4['uid_send_bytes'] = env2_12.uidSendBytes; object4['socket_bytes_received'] = env2_12.socketBytesReceived; object4['ota_bytes_received'] = env2_12.otaBytesReceived; object4['ota_num_requests'] = env2_12.otaNumRequests; object4['xhr_bytes_received'] = env2_12.xhrBytesReceived; object4['xhr_num_requests'] = env2_12.xhrNumRequests; object4['fresco_bytes_received'] = env2_12.frescoBytesReceived; object4['fresco_num_requests'] = env2_12.frescoNumRequests; object4['download_bytes_received'] = env2_12.downloadBytesReceived; object4['download_num_requests'] = env2_12.downloadNumRequests; object4['media_player_bytes_received'] = env2_12.mediaPlayerBytesReceived; object4['rtc_bytes'] = env2_0(env2_2[11]).getRTCTotalBytes(); object4['num_message_sends'] = env2_17; object4['max_message_send_duration'] = env2_17 === 0 ? value3 : env2_18; object4['max_message_queue_length'] = env2_17 === 0 ? value3 : env2_19; object4['num_message_send_fails'] = env2_20; binding = env2_7; const getSocket = binding.getSocket; object4['num_identifies'] = Reflect.apply(getSocket, binding, []).identifyCount; object4['render_latest_messages_duration_ms'] = env2_1(env2_2[18]).renderLatestMessages.serialize(value5); object3.properties = object4; return object3; } function _fun42684() { // fn#42684, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1312, offset: 0x0113fc1e, size: 18 bytes, params: 1, frame: 9 return env0_0.track(); } function _fun42685() { // fn#42685, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1399, offset: 0x0113fc30, size: 19 bytes, params: 1, frame: 9 return env0_0.writeExistingEventStorage(); } function trackExistingEvents() { // fn#42686, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1593, owner: EventTracker.trackExistingEvents, offset: 0x0113fc43, size: 89 bytes, params: 1, frame: 12 var environment; var value2; var value; if (env0_0.existingEvents.length > 0) { value2 = environment.__proto__.__proto__; value = AnalyticsTrackingStore.submitEventsImmediately(env0_0.existingEvents); value = value.then(_fun42687); value.catch(_fun42688); } } function _fun42690() { // fn#42690, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2163, offset: 0x0113fdba, size: 18 bytes, params: 1, frame: 9 return env2_21.track(); } function _fun42697() { // fn#42697, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2867, offset: 0x0113ff55, size: 50 bytes, params: 1, frame: 14 env3_11.fileOnly('Successfully tracked latest network usage', env0_1); env0_0.writeExistingEventStorage(); } function _fun42698(a0) { // fn#42698, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:2973, offset: 0x0113ff87, size: 97 bytes, params: 2, frame: 15 var value; if (a0.status !== 429) { value = environment.__proto__.__proto__.__proto__; env3_11.error('Failed to track latest network usage', env0_1, a0); } const binding = env0_0; binding.existingEvents.push(env0_1[0]); binding.writeExistingEventStorage(); } function _fun42687() { // fn#42687, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1681, offset: 0x0113fc9c, size: 62 bytes, params: 1, frame: 14 const binding = env3_11; const fileOnly = binding.fileOnly; const binding2 = env1_0; Reflect.apply(fileOnly, binding, ['Successfully logged existing network usage events', binding2.existingEvents]); binding2.existingEvents = []; binding2.writeExistingEventStorage(); } function _fun42688(a0) { // fn#42688, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5051:1836, offset: 0x0113fcda, size: 68 bytes, params: 2, frame: 15 var binding; var error; let value = a0.status === 429; if (value || false) { value = environment.__proto__.__proto__.__proto__; binding = env3_11; error = binding.error; value = environment.__proto__; Reflect.apply(error, binding, ['Failed to log log existing network usage events', env1_0.existingEvents, a0]); } }