// Module ID: 10726 // Function ID: 10727 // Name: sortKey // Dependencies: [1390, 4402, 1218, 5103, 1391, 4431, 5244, 1922, 10727, 4399, 4401, 676, 4444, 5252, 4021, 10728, 12, 10729, 10730, 4573, 8960, 4446, 2] // Exports: activityParticipantIdToApplicationId, areParticipantsEqual, getEmbeddedActivityParticipantId // Module 10726 (sortKey) import apply from "apply" /* 12 */; import version from "version" /* 4021 */; import isStreamKey from "isStreamKey" /* 4446 */; import getNicknameDefault from "getNickname" /* 4573 */; import getParticipantUserKeyDefault from "getParticipantUserKey" /* 5252 */; import useAvatarDecoration from "useAvatarDecoration" /* 8960 */; import useIsSpeaking from "useIsSpeaking" /* 10728 */; import apexExperiment from "apexExperiment" /* 10729 */; import closure_3 from "participantFromServer" /* 1390 */; import closure_4 from "reset" /* 4402 */; import closure_5 from "fetchFingerprint" /* 1218 */; import closure_6 from "callConnect" /* 5103 */; import closure_7 from "ensureGuildLoaded" /* 1391 */; import closure_8 from "_detectH265HardwareDecode" /* 4431 */; import closure_9 from "anyoneHasFlagInContext" /* 5244 */; import closure_10 from "mergeGuildAvatar" /* 1922 */; import closure_11 from "makeTimeoutKey" /* 10727 */; import closure_12 from "updateVoiceState" /* 4399 */; import ParticipantTypes from "ParticipantTypes" /* 4401 */; import ME from "ME" /* 676 */; import DesktopSources from "DesktopSources" /* 4444 */; require = arg1; function sortKey(type) { type = type.type; if (constants.ACTIVITY === type) { const _HermesInternal3 = HermesInternal; return "\u0001" + type.sortKey; } else { if (tmp.HIDDEN_STREAM !== type) { if (tmp.STREAM !== type) { if (tmp.USER === type) { const voiceState = type.voiceState; let selfVideo; if (voiceState != null) { selfVideo = voiceState.selfVideo; } let str = "\u0003"; if (!selfVideo) { const voiceState2 = type.voiceState; let selfStream; if (voiceState2 != null) { selfStream = voiceState2.selfStream; } str = "\u0005"; if (selfStream) { str = "\u0004"; } } const _HermesInternal = HermesInternal; return "" + str + getParticipantUserKeyDefault(type.userNick, type.user); } } } let str4 = "\u0003"; if (type.userVideo) { str4 = "\u0002"; } const _HermesInternal2 = HermesInternal; return "" + str4 + getParticipantUserKeyDefault(type.userNick, type.user) + "\u0003"; } } ({ isStreamParticipant: map1, ParticipantTypes: closure_14 } = ParticipantTypes); ({ ActivityTypes: closure_15, ChannelTypes: closure_16 } = ME); ({ MediaEngineContextTypes: closure_17, Features: closure_18 } = DesktopSources); const __EMBEDDED_ACTIVITIES__ = "__EMBEDDED_ACTIVITIES__"; let obj = { VIDEO: "VIDEO", STREAM: "STREAM", FILTERED: "FILTERED", SPEAKING: "SPEAKING", ACTIVITY: "ACTIVITY", NOT_POPPED_OUT: "NOT_POPPED_OUT" }; let result = require("set").fileFinishedImporting("modules/calls/ChannelRTCParticipants.tsx"); class ChannelRTCParticipants { constructor(arg0) { obj = Object.create(new.target.prototype); obj[0] = {}; obj[1] = {}; set = new Set(); obj[2] = set; set1 = new Set(); obj[3] = set1; secondaryIndexMap = new require("version").SecondaryIndexMap((type) => { const items = []; if (tmp2) { items.push(constants2.SPEAKING); } if (type.type === constants.USER) { const voiceState = type.voiceState; let selfVideo; if (voiceState != null) { selfVideo = voiceState.selfVideo; } if (selfVideo) { items.push(constants2.VIDEO); if (!tmp13) { items.push(tmp11.FILTERED); } tmp11 = constants2; tmp13 = type.localVideoDisabled || type.isPoppedOut; } if (type.type === tmp.ACTIVITY) { items.push(constants2.ACTIVITY); } if (!tmp17) { items.push(constants2.NOT_POPPED_OUT); } return items; } if (callback(type)) { items.push(constants2.STREAM); let isPoppedOut = type.type === tmp.HIDDEN_STREAM; if (!isPoppedOut) { isPoppedOut = null == type.streamId; } if (!isPoppedOut) { isPoppedOut = type.isPoppedOut; } if (!isPoppedOut) { items.push(tmp7.FILTERED); } tmp7 = constants2; } }, sortKey); obj[4] = secondaryIndexMap; obj.channelId = global; return obj; } } const prototype = ChannelRTCParticipants.prototype; Object.defineProperty(prototype, "version", { get: function version() { return this.participantByIndex.version; }, set: undefined }); prototype["size"] = function size(arg0) { const participantByIndex = this.participantByIndex; return participantByIndex.size(arg0); }; prototype["toArray"] = function toArray(arg0) { const participantByIndex = this.participantByIndex; return participantByIndex.values(arg0, true); }; prototype["rebuild"] = function rebuild() { let self = this; self = this; const channel = store3.getChannel(this.channelId); if (null != channel) { if (channel.type !== constants2.GUILD_TEXT) { self.call = call.getCall(self.channelId); if (channel.isPrivate()) { return false; } if (channel.isGuildVocalOrThread()) { const _Object = Object; let recipients = Object.keys(store4.getVoiceStatesForChannel(channel.id)); } else { recipients = channel.recipients; } const set = new Set(recipients); let set1 = set; set.add(store2.getId()); let arr = set; if (self.guildRingingUsers.size > 0) { const _Set = Set; const items = []; HermesBuiltin.arraySpread(self.guildRingingUsers, HermesBuiltin.arraySpread(set, 0)); set1 = new Set(items); arr = set1; } const allActiveStreamsForChannel = authStore.getAllActiveStreamsForChannel(self.channelId); const item = allActiveStreamsForChannel.forEach((ownerId) => set1.add(ownerId.ownerId)); const participantByIndex = self.participantByIndex; participantByIndex.clear(); self.participants = {}; const item1 = arr.forEach((arg0) => self.updateParticipant(arg0)); const result = self.updateEmbeddedActivities(); return true; } } return false; }; prototype["getParticipant"] = function getParticipant(arg0) { const participantByIndex = this.participantByIndex; let value = participantByIndex.get(arg0); if (value == null) { value = null; } return value; }; prototype["updateEmbeddedActivities"] = function updateEmbeddedActivities() { return this.updateParticipant(__EMBEDDED_ACTIVITIES__); }; prototype["hasEmbeddedActivity"] = function hasEmbeddedActivity() { return this.size(obj.ACTIVITY) > 0; }; prototype["updateParticipant"] = function updateParticipant(arg0) { let self = this; self = this; if (arg0 === __EMBEDDED_ACTIVITIES__) { let result = self._getParticipantsForEmbeddedActivities(); } else { result = self._getParticipantsForUser(arg0); } let flag = null != arr; if (!flag) { flag = 0 !== result.length; } if (flag) { if (arr != null) { const item = arr.forEach((id) => { const participantByIndex = self.participantByIndex; participantByIndex.delete(id.id); }); } const item1 = result.forEach((id) => { const participantByIndex = self.participantByIndex; const result = participantByIndex.set(id.id, id); }); self.participants[arg0] = result; flag = true; } return flag; }; prototype["updateParticipantSpeaking"] = function updateParticipantSpeaking(f75792) { const self = this; closure_0 = f75792; let flag; if (this.participants[f75792] != null) { flag = arr.reduce((arg0, type) => { let flag = arg0; if (type.type === closure_1_14.USER) { obj = callback(closure_1_2[15]); obj = { userId: null, checkIsMuted: true }; obj[0] = callback; const isSpeaking = obj.getIsSpeaking(obj); const isSoundSharingResult = closure_1_9.isSoundSharing(callback); const participantByIndex = self.participantByIndex; const value = participantByIndex.get(type.id); type = undefined; if (value != null) { type = value.type; } if (type === tmp.USER) { return flag; } if (isSpeaking) { const _Date = Date; tmp8.lastSpoke[tmp4] = Date.now(); } const participantByIndex2 = tmp8.participantByIndex; obj = {}; const merged = Object.assign(type); obj.speaking = isSpeaking; obj.lastSpoke = self.lastSpoke[callback]; obj.soundsharing = isSoundSharingResult; const result = participantByIndex2.set(type.id, obj); flag = true; } else { return flag; } }, false); } if (flag == null) { flag = false; } return flag; }; prototype["updateParticipantQuality"] = function updateParticipantQuality(f75799, closure_1, closure_2) { const self = this; closure_0 = closure_2; let flag; if (this.participants[f75799] != null) { flag = arr.reduce((arg0, type) => { let flag = arg0; if (type.type === closure_1_14.STREAM) { const participantByIndex = self.participantByIndex; obj = {}; const merged = Object.assign(type); obj.maxResolution = closure_1; obj.maxFrameRate = closure_0; const result = participantByIndex.set(type.id, obj); flag = true; } return flag; }, false); } if (flag == null) { flag = false; } return flag; }; prototype["updateGuildRingingUsers"] = function updateGuildRingingUsers(userId, arg1) { const guildRingingUsers = this.guildRingingUsers; if (arg1) { guildRingingUsers.add(userId); } else { guildRingingUsers.delete(userId); } }; prototype["updateParticipantPoppedOut"] = function updateParticipantPoppedOut(participantId, arg1) { const poppedOutParticipants = this.poppedOutParticipants; if (arg1) { poppedOutParticipants.add(participantId); } else { poppedOutParticipants.delete(participantId); } }; prototype["_getEmbeddedActivities"] = function _getEmbeddedActivities() { const embeddedActivitiesForChannelIncludingHidden = store.getEmbeddedActivitiesForChannelIncludingHidden(this.channelId); const selfEmbeddedActivityForChannel = store.getSelfEmbeddedActivityForChannel(this.channelId); let uniqByResult = embeddedActivitiesForChannelIncludingHidden; if (null != selfEmbeddedActivityForChannel) { const items = []; items[HermesBuiltin.arraySpread(embeddedActivitiesForChannelIncludingHidden, 0)] = selfEmbeddedActivityForChannel; uniqByResult = apply.uniqBy(items, (compositeInstanceId) => compositeInstanceId.compositeInstanceId); obj = apply; } const ContentClassificationEmbeddedActivityFilterExperiment = apexExperiment.ContentClassificationEmbeddedActivityFilterExperiment; const currentUser = authStore2.getCurrentUser(); let nsfwAllowed; if (currentUser != null) { nsfwAllowed = currentUser.nsfwAllowed; } let found = uniqByResult; if (!nsfwAllowed) { found = uniqByResult; if (ContentClassificationEmbeddedActivityFilterExperiment.getConfig({ location: "rtc_participants" }).enabled) { found = uniqByResult.filter((contentClassification) => !callback(table[18]).isAgeRestrictedClassificationReference(contentClassification.contentClassification)); } } return found; }; prototype["_getParticipantsForEmbeddedActivities"] = function _getParticipantsForEmbeddedActivities() { const self = this; const result = this._getEmbeddedActivities(); return result.map((applicationId) => { obj = { type: closure_1_14.ACTIVITY, id: null, applicationId: null, activityType: null, activityUrl: null, participants: null, guildId: null, sortKey: null }; ({ applicationId, compositeInstanceId } = applicationId); if (null != compositeInstanceId) { const _HermesInternal2 = HermesInternal; let combined = "activity-" + applicationId + "-" + compositeInstanceId; } else { const _HermesInternal = HermesInternal; combined = "activity-" + applicationId; } obj[1] = combined; obj[2] = applicationId.applicationId; obj[3] = closure_1_15.PLAYING; ({ url: obj[4], participants } = applicationId); if (participants == null) { participants = []; } const items = [...participants]; obj[5] = items; const channel = closure_1_7.getChannel(self.channelId); let guildId; if (channel != null) { guildId = channel.getGuildId(); } if (guildId == null) { guildId = null; } obj[6] = guildId; obj[7] = arg1.toString(); return obj; }); }; prototype["_getParticipantsForUser"] = function _getParticipantsForUser(userId) { const items = []; const user = authStore2.getUser(userId); if (null == user) { return items; } else { const self = this; const voiceStateForChannel = store4.getVoiceStateForChannel(this.channelId, userId); const voicePlatformForChannel = store4.getVoicePlatformForChannel(this.channelId, userId); const channel = store3.getChannel(this.channelId); let guildId; if (channel != null) { guildId = channel.getGuildId(); } const call = self.call; let flag; if (call != null) { const ringing = call.ringing; if (ringing != null) { flag = ringing.includes(userId); } } if (!flag) { const guildRingingUsers = self.guildRingingUsers; flag = guildRingingUsers.has(userId); } if (flag == null) { flag = false; } if (tmp3) { obj = { type: null }; obj[0] = constants.USER; const merged = Object.assign(authStore3.getUserStreamData(userId, guildId)); obj.user = user; obj.id = user.id; obj.voiceState = voiceStateForChannel; obj.voicePlatform = voicePlatformForChannel; obj1 = useIsSpeaking; obj = { userId: null, checkIsMuted: true }; obj[0] = userId; obj.speaking = obj1.getIsSpeaking(obj); let num = self.lastSpoke[userId]; if (num == null) { num = 0; } obj.lastSpoke = num; obj.soundsharing = soundSharing.isSoundSharing(userId); obj.ringing = flag; obj.userNick = getNicknameDefault.getName(guildId, self.channelId, user); const obj4 = getNicknameDefault; const tmp8 = require; obj.userAvatarDecoration = useAvatarDecoration.getAvatarDecoration(user, guildId); obj.localVideoDisabled = closure_8.isLocalVideoDisabled(user.id); const poppedOutParticipants = self.poppedOutParticipants; obj.isPoppedOut = poppedOutParticipants.has(user.id); items.push(obj); const tmp8Result = useAvatarDecoration; } let streamForUser = authStore.getStreamForUser(userId, guildId); if (streamForUser == null) { streamForUser = obj6.getActiveStreamForUser(userId, guildId); } if (closure_8.supports(constants4.VIDEO)) { if (null != streamForUser) { if (streamForUser.channelId === self.channelId) { const encodeStreamKeyResult = isStreamKey.encodeStreamKey(streamForUser); const participant = self.getParticipant(encodeStreamKeyResult); const obj12 = isStreamKey; let type; if (participant != null) { type = participant.type; } let tmp20 = null; if (type === constants.STREAM) { let tmp21; if (null != participant.maxResolution) { obj = {}; const merged1 = Object.assign(participant.maxResolution); tmp21 = obj; } obj1 = { maxResolution: null, maxFrameRate: null }; obj1[0] = tmp21; obj1[1] = participant.maxFrameRate; tmp20 = obj1; } const obj2 = {}; const merged2 = Object.assign(authStore3.getUserStreamData(userId, guildId, constants3.STREAM)); const merged3 = Object.assign(tmp20); obj2.type = streamForUser.ownerId === store2.getId() && obj6.isSelfStreamHidden(self.channelId) ? constants.HIDDEN_STREAM : constants.STREAM; obj2.id = encodeStreamKeyResult; let flag2; if (voiceStateForChannel != null) { flag2 = voiceStateForChannel.selfVideo; } if (flag2 == null) { flag2 = false; } obj2.userVideo = flag2; obj2.user = user; const tmp17 = streamForUser.ownerId === store2.getId() && obj6.isSelfStreamHidden(self.channelId); obj2.userNick = getNicknameDefault.getName(guildId, self.channelId, user); obj2.stream = streamForUser; const poppedOutParticipants2 = self.poppedOutParticipants; obj2.isPoppedOut = poppedOutParticipants2.has(encodeStreamKeyResult); items.push(obj2); const obj10 = getNicknameDefault; } } } return items; } }; export default ChannelRTCParticipants; export const getEmbeddedActivityParticipantId = function getEmbeddedActivityParticipantId(arg0) { ({ applicationId, instanceId } = arg0); if (null != instanceId) { const _HermesInternal2 = HermesInternal; let combined = "activity-" + applicationId + "-" + instanceId; } else { const _HermesInternal = HermesInternal; combined = "activity-" + applicationId; } return combined; }; export const activityParticipantIdToApplicationId = function activityParticipantIdToApplicationId(id) { let tmp = id; if (null != id) { tmp = id.split("-")[1]; } return tmp; }; export { sortKey }; export const areParticipantsEqual = function areParticipantsEqual(arg0, arg1) { [, tmp] = arg0; [, tmp2] = arg1; return tmp === tmp2; }; export const ChannelRTCParticipantsIndexes = obj;