/* Metro module 4863; source: modules/app_analytics/AppAnalyticsUtils.tsx; dependencies: [1383, 1226, 1379, 1935, 4111, 1945, 1938, 1867, 4259, 3784, 4396, 4294, 4605, 3793, 1934, 3969, 4864, 1878, 4297, 661, 1386, 3789, 483, 4866, 683, 672, 4867, 4868, 22, 2] */ function _fun42492(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#42492, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:6, offset: 0x0113b00b, size: 690 bytes, params: 8, frame: 25 var object2; const env0_0 = require; const _arrayLikeToArray_42495 = 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 countKeys = function(a0) { var r1; var r5; var r0; var propertyName; var propertyName2; var value = 0; var properties = Object.keys(a0); var properties2 = 0; var properties3 = properties.length; if (properties === undefined) { r0 = value; } else { r1 = value; for (r5 = properties2; true; r5 = propertyName2) { propertyName = properties[r5]; propertyName2 = r5 + 1; if (propertyName === undefined) { r0 = r1; break; } value = r1 + 1; r1 = value; } } return r0; }; const closure = collectGuildAnalyticsMetadata; const closure2 = function(a0, a1) { return {channel_static_route: a1, channel_hidden: false}; }; const closure3 = collectChannelAnalyticsMetadata; const closure4 = trackWithMetadata; const closure5 = function(a0) { var r3; var r4; var r8; var r2; var value5; var value6; var value7; var value2 = _createForOfIteratorHelperLoose_42493(a0); var value3 = value2(); var value4 = 0; if (value3.done) { r2 = value4; } else { r3 = value4; r4 = value3; while (true) { value5 = r4.value; if (RelationshipStore.isFriend(value5)) { value6 = typeof r3 === 'bigint' ? r3 + 1n : +r3 + 1; r8 = value6; } else { r8 = r3; } value7 = value2(); if (value7.done) { r2 = r8; break; } r3 = r8; r4 = value7; continue; } } return {friendCount: r2, nonFriendCount: a0.length - r2}; }; const closure6 = getVoiceStateMetadata; const Object = global.Object; Object.defineProperty(exports, '__esModule', {value: true}); const env0_4 = (require(1383) /* metro dependency 1383: ChannelRecord */).THREAD_CHANNEL_TYPES; const authenticationStore = importDefault(1226) /* metro dependency 1226: AuthenticationStore */; const channelStore = importDefault(1379) /* metro dependency 1379: ChannelStore */; let value = require(1935) /* metro dependency 1935: GuildChannelStore */; const env0_7 = value.GUILD_SELECTABLE_CHANNELS_KEY; const env0_8 = value.GUILD_VOCAL_CHANNELS_KEY; const guildChannelStore = importDefault(1935) /* metro dependency 1935: GuildChannelStore */; const guildMemberCountStore = importDefault(4111) /* metro dependency 4111: GuildMemberCountStore */; const guildMemberStore = importDefault(1945) /* metro dependency 1945: GuildMemberStore */; const guildRoleStore = importDefault(1938) /* metro dependency 1938: GuildRoleStore */; const guildStore = importDefault(1867) /* metro dependency 1867: GuildStore */; const mediaEngineStore = importDefault(4259) /* metro dependency 4259: MediaEngineStore */; const permissionStore = importDefault(3784) /* metro dependency 3784: PermissionStore */; const presenceStore = importDefault(4396) /* metro dependency 4396: PresenceStore */; const rtcConnectionStore = importDefault(4294) /* metro dependency 4294: RTCConnectionStore */; const readStateStore = importDefault(4605) /* metro dependency 4605: ReadStateStore */; const relationshipStore = importDefault(3793) /* metro dependency 3793: RelationshipStore */; const selectedChannelStore = importDefault(1934) /* metro dependency 1934: SelectedChannelStore */; const selectedGuildStore = importDefault(3969) /* metro dependency 3969: SelectedGuildStore */; const userGuildSettingsStore = importDefault(4864) /* metro dependency 4864: UserGuildSettingsStore */; const userStore = importDefault(1878) /* metro dependency 1878: UserStore */; const voiceStateStore = importDefault(4297) /* metro dependency 4297: VoiceStateStore */; value = require(661) /* metro dependency 661: Constants */; const env0_25 = value.GuildFeatures; const env0_26 = value.AnalyticsLocations; const env0_27 = value.Permissions; const env0_28 = value.ActivityTypes; const env0_29 = (require(1386) /* metro dependency 1386: ChannelConstants */).isStaticChannelRoute; object2 = {trackWithMetadata: closure4, getVoiceStateMetadata: closure6}; (require(2) /* metro dependency 2 */).fileFinishedImporting('modules/app_analytics/AppAnalyticsUtils.tsx'); exports.default = object2; exports.collectGuildAnalyticsMetadata = closure; exports.collectStaticChannelRouteAnalyticsMetadata = closure2; exports.collectChannelAnalyticsMetadataFromId = function(a0) { var value = null; if (value == a0) { return value; } var value3 = ChannelStore.getChannel(a0); return value == value3 ? value : collectChannelAnalyticsMetadata(value3); }; exports.collectChannelAnalyticsMetadata = closure3; exports.collectVoiceAnalyticsMetadata = collectVoiceAnalyticsMetadata; exports.trackWithMetadata = closure4; exports.getChannelOpenedMetadata = getChannelOpenedMetadata; exports.getRecipientFriendCounts = closure5; exports.getVoiceStateMetadata = closure6; exports.getCustomStatusMetadata = getCustomStatusMetadata; } function _createForOfIteratorHelperLoose_42493(a0, a1) { // fn#42493, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:515, offset: 0x0113b2bd, 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 _fun42494; } value = undefined; if (a0) { if (typeof a0 === 'string') { value = _arrayLikeToArray_42495(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_42495(a0, value); r6 = value; } else { regexp = RegExp('^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$', ''); if (regexp.test(r9)) { value = _arrayLikeToArray_42495(a0, value); r6 = value; } else { r6 = value; } } r5 = r6; } } else { r5 = value; } if (r5) { if (r5) { } return _fun42494; } 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 collectGuildAnalyticsMetadata(a0) { // fn#42497, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:1484, offset: 0x0113b455, size: 370 bytes, params: 2, frame: 21 if (a0 == null) { return null; } const guild = GuildStore.getGuild(a0); if (guild == null) { return null; } const numRoles = GuildRoleStore.getNumRoles(guild.id); const member = GuildMemberStore.getMember(a0, AuthenticationStore.getId()); const channels = GuildChannelStore.getChannels(a0); const length = channels[GUILD_SELECTABLE_CHANNELS_KEY].length; const length2 = channels[GUILD_VOCAL_CHANNELS_KEY].length; const voiceStates = VoiceStateStore.getVoiceStates(a0); const object2 = {}; object2.guild_id = guild.id; object2.guild_size_total = GuildMemberCountStore.getMemberCount(a0); object2.guild_num_channels = length + length2; object2.guild_num_text_channels = length; object2.guild_num_voice_channels = length2; object2.guild_num_roles = numRoles; object2.guild_member_num_roles = member != null ? member.roles.length : 0; const String = global.String; object2.guild_member_perms = String(PermissionStore.getGuildPermissions(guild) ?? (importAll(3789) /* metro dependency 3789: PermissionUtils */).NONE); const features = guild.features; const has = features.has; const VIP_REGIONS = GuildFeatures.VIP_REGIONS; object2.guild_is_vip = Reflect.apply(has, features, [VIP_REGIONS]); object2.is_member = member != null; object2.num_voice_channels_active = countKeys(voiceStates); return object2; } function collectChannelAnalyticsMetadata(a0) { // fn#42499, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:2210, offset: 0x0113b5da, size: 260 bytes, params: 2, frame: 17 if (a0 == null) { return null; } const guildId = a0.getGuildId(); const r2 = guildId != null && (THREAD_CHANNEL_TYPES.has(a0.type) && a0.parent_id != null ? isHidden(ChannelStore.getChannel(a0.parent_id)) : isHidden(a0)); const object2 = {}; object2.channel_id = a0.id; object2.channel_type = a0.type; object2.channel_size_total = a0.isPrivate() ? a0.recipients.length : 0; const String = global.String; object2.channel_member_perms = String(guildId == null ? (importAll(3789) /* metro dependency 3789: PermissionUtils */).NONE : PermissionStore.getChannelPermissions(a0) ?? (importAll(3789) /* metro dependency 3789: PermissionUtils */).NONE); object2.channel_hidden = r2; return object2; } function trackWithMetadata(a0) { // fn#42501, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:2735, offset: 0x0113b739, size: 380 bytes, params: 2, frame: 24 var r2; var r8; var r4; var r12; var r11; var object2; var value3; var channel; var value11; var guildId; let value = a1; const value2 = a2; const r10 = value !== undefined ? value : {}; const r6 = value2 !== undefined ? value2 : false; const defaultImport = importDefault(683) /* metro dependency 683: AnalyticsUtils */; if (!defaultImport.isThrottled(a0)) { value3 = 'location' in r10; r2 = value3 ? r10.location !== AnalyticsLocations.GUILD_CREATE_INVITE_SUGGESTION : !value3; r8 = 'guild_id' in r10 ? r10.guild_id : r2 ? SelectedGuildStore.getGuildId() : null; r4 = 'channel_id' in r10 ? r10.channel_id : r2 ? SelectedChannelStore.getChannelId(r8) : null; channel = ChannelStore.getChannel(r4); value11 = null; if (value11 == channel) { r11 = value11 != r8 ? r8 : value11; } else if (channel.isPrivate()) { r11 = value11; } else { guildId = channel.getGuildId(); r12 = value11 == guildId ? r8 : guildId; r11 = value11 != r12 ? r12 : value11; } object2 = {}; copyDataProperties(object2, r10, undefined); copyDataProperties(object2, collectGuildAnalyticsMetadata(r11), undefined); r2 = value11 == r8 || value11 == r4 ? collectChannelAnalyticsMetadata(channel) : isStaticChannelRoute(r4) ? collectStaticChannelRouteAnalyticsMetadata(0, r4) : collectChannelAnalyticsMetadata(channel); copyDataProperties(object2, r2, undefined); value = defaultImport; value.track(a0, object2, {flush: r6}); } } function getVoiceStateMetadata(a0, a1, a2) { // fn#42503, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:3517, offset: 0x0113b922, size: 132 bytes, params: 4, frame: 15 const env0_0 = a1; const defaultImport = importDefault(22) /* metro dependency 22 */; const getVoiceStates = VoiceStateStore.getVoiceStates; let value = defaultImport(Reflect.apply(getVoiceStates, VoiceStateStore, [a0])); value = value.filter(function({channelId}) { return channelId === require; }); value = value.filter(function({userId}) { return userId !== AuthenticationStore.getId(); }); value.forEach(_fun42506); return {'voice_state_count': 0, 'video_stream_count': 0, video_enabled: a2}; } function collectVoiceAnalyticsMetadata(a0) { // fn#42508, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:4436, offset: 0x0113ba39, size: 182 bytes, params: 2, frame: 18 if (a0 == null) { return null; } const channel = ChannelStore.getChannel(a0); if (channel == null) { return null; } const isVideoEnabled2 = MediaEngineStore.isVideoEnabled(); const mediaSessionId = RTCConnectionStore.getMediaSessionId(); const object2 = {}; object2.channel_id = channel.id; object2.channel_type = channel.type; object2.guild_id = channel.getGuildId(); object2.media_session_id = mediaSessionId; copyDataProperties(object2, getVoiceStateMetadata(channel.getGuildId(), channel.id, isVideoEnabled2), undefined); const value = require(4866) /* metro dependency 4866: AppAnalyticsUtilsAdditionalNative */; const getVoiceAnalyticsMetadataAdditional = value.getVoiceAnalyticsMetadataAdditional; copyDataProperties(object2, Reflect.apply(getVoiceAnalyticsMetadataAdditional, value, []), undefined); return object2; } function getChannelOpenedMetadata(a0) { // fn#42509, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:4849, offset: 0x0113baef, size: 705 bytes, params: 2, frame: 25 var bot; var r4; var object2; if (isStaticChannelRoute(a0)) { return {channel_static_route: a0}; } const channel = ChannelStore.getChannel(a0); const value3 = null; if (value3 == channel) { return {channel_id: a0}; } const guild = GuildStore.getGuild(channel.guild_id); if (value3 == guild) { bot = channel.isDM() && value3 != UserStore.getUser(channel.recipients[0]) && UserStore.getUser(channel.recipients[0]).bot; r4 = channel.isDM() || channel.isGroupDM() ? getRecipientFriendCounts(channel.recipients) : value3; copyDataProperties({channel_id: a0, is_app_dm: bot}, value3 != r4 ? {friend_recipient_count: r4.friendCount, non_friend_recipient_count: r4.nonFriendCount} : value3, undefined); } else { var getSnapshot = ReadStateStore.getSnapshot; var Millis = (importDefault(672) /* metro dependency 672: Durations */).Millis; var SECOND = Millis.SECOND; var value5 = Reflect.apply(getSnapshot, ReadStateStore, [a0, 10 * SECOND]); object2 = {channel_id: a0}; object2.channel_was_unread = value5.unread; object2.channel_mention_count = value5.mentionCount; object2.channel_is_muted = UserGuildSettingsStore.isChannelMuted(channel.guild_id, channel.id); object2.channel_is_nsfw = channel.isNSFW(); object2.channel_is_spoiler = channel.isSpoilerChannel(); object2.channel_resolved_unread_setting = UserGuildSettingsStore.resolveUnreadSetting(channel); var moduleValue = require(4867) /* metro dependency 4867: notificationSettingsPresetUtils */; var presetFromSettings = moduleValue.presetFromSettings; object2.channel_preset = Reflect.apply(presetFromSettings, moduleValue, [UserGuildSettingsStore.resolveUnreadSetting(channel), UserGuildSettingsStore.resolvedMessageNotifications(channel)]); object2.guild_id = channel.guild_id; object2.guild_was_unread = value5.guildUnread; object2.guild_mention_count = value5.guildMentionCount; object2.guild_is_muted = UserGuildSettingsStore.isMuted(channel.guild_id); object2.guild_resolved_unread_setting = UserGuildSettingsStore.resolveGuildUnreadSetting(guild); var moduleValue2 = require(4867) /* metro dependency 4867: notificationSettingsPresetUtils */; presetFromSettings = moduleValue2.presetFromSettings; var guildUnreadSetting = UserGuildSettingsStore.resolveGuildUnreadSetting(guild); var getMessageNotifications = UserGuildSettingsStore.getMessageNotifications; object2.guild_preset = Reflect.apply(presetFromSettings, moduleValue2, [guildUnreadSetting, Reflect.apply(getMessageNotifications, UserGuildSettingsStore, [channel.guild_id])]); object2.parent_id = channel.parent_id; object2.parent_channel_type = channel.parentChannelThreadType; var moduleValue3 = require(4868) /* metro dependency 4868: hasPendingMemberAction */; object2.has_pending_member_action = moduleValue3.hasPendingMemberAction(channel.guild_id, a0); var can = PermissionStore.can; var SEND_MESSAGES = Permissions.SEND_MESSAGES; object2.can_send_message = Reflect.apply(can, PermissionStore, [SEND_MESSAGES, channel]); object2.is_app_dm = false; } return object2; } function getCustomStatusMetadata(a0, a1) { // fn#42510, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:6341, offset: 0x0113bdb0, size: 87 bytes, params: 3, frame: 15 const env0_0 = a1; const defaultImport = importDefault(22) /* metro dependency 22 */; const getVoiceStates = VoiceStateStore.getVoiceStates; defaultImport(Reflect.apply(getVoiceStates, VoiceStateStore, [a0])).forEach(_fun42511); return {custom_status_count: 0}; } function isHidden(a0) { // fn#42500, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:2334, owner: collectChannelAnalyticsMetadata.isHidden, offset: 0x0113b6de, size: 91 bytes, params: 2, frame: 15 var r0; var moduleValue; if (a0 == null) { return false; } const permissionOverwrites = a0.permissionOverwrites; const property = permissionOverwrites[env0_0]; let value = property != null; if (value) { value = environment.__proto__; moduleValue = importAll(483) /* metro dependency 483: BigFlagUtils */; value = moduleValue.has(property.deny, Permissions.VIEW_CHANNEL); r0 = value; } else { r0 = value; } return r0; } function _fun42506(a0) { // fn#42506, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:3729, offset: 0x0113b9c5, size: 66 bytes, params: 2, frame: 4 var video_stream_count; let binding = env0_1; const voice_state_count = binding.voice_state_count; binding.voice_state_count = typeof voice_state_count === 'bigint' ? voice_state_count + 1n : +voice_state_count + 1; if (a0.selfVideo || a0.selfStream) { binding = env0_1; video_stream_count = binding.video_stream_count; binding.video_stream_count = typeof video_stream_count === 'bigint' ? video_stream_count + 1n : +video_stream_count + 1; } } function _fun42511(a0) { // fn#42511, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:5041:6455, offset: 0x0113be07, size: 85 bytes, params: 2, frame: 15 var binding; var custom_status_count; if (a0.channelId === require && PresenceStore.findActivity(a0.userId, function({type}) { return type === ActivityTypes.CUSTOM_STATUS; }) != null) { binding = env0_1; custom_status_count = binding.custom_status_count; binding.custom_status_count = typeof custom_status_count === 'bigint' ? custom_status_count + 1n : +custom_status_count + 1; } }