@vkontakte/calls-sdk 2.8.12-dev.a3089173.0 → 2.8.12-dev.c60cf16f.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/calls-sdk.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @vkontakte/calls-sdk v2.8.12-dev.a3089173.0
3
- * Mon, 27 Jul 2026 07:24:37 GMT
2
+ * @vkontakte/calls-sdk v2.8.12-dev.c60cf16f.0
3
+ * Mon, 03 Aug 2026 08:12:02 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -2159,7 +2159,7 @@ var mn = pn.getInstance(), M = class e {
2159
2159
  return 1.1;
2160
2160
  }
2161
2161
  static get sdkVersion() {
2162
- return "2.8.12-dev.a3089173.0";
2162
+ return "2.8.12-dev.c60cf16f.0";
2163
2163
  }
2164
2164
  static get debug() {
2165
2165
  return e._params.debug;
@@ -4021,10 +4021,10 @@ var Tr = class {
4021
4021
  setRemoteHold(e) {
4022
4022
  if (this._remoteHold !== e) {
4023
4023
  if (this._remoteHold = e, e) {
4024
- this._stopReconnection(), this._stopStatInterval(), this._stopSettingsInterval(), this._disposePeerConnection(), this._remoteSDP = {}, this._remoteCandidates = {}, this._lastRemoteSDP = null;
4024
+ this._stopReconnection(), this._stopStatInterval(), this._stopSettingsInterval(), this._isOpen && (this._disposePeerConnection(), this._remoteSDP = {}, this._remoteCandidates = {}, this._lastRemoteSDP = null);
4025
4025
  return;
4026
4026
  }
4027
- this._recreatePeerConnection();
4027
+ this._isOpen && this._recreatePeerConnection();
4028
4028
  }
4029
4029
  }
4030
4030
  _recreatePeerConnection() {
@@ -7920,7 +7920,7 @@ var oo = 90, so = 3, co = class extends y {
7920
7920
  this._pendingRequests = null, this._pendingPromises = [];
7921
7921
  let r = {};
7922
7922
  try {
7923
- r = this._getRequestLayouts(t);
7923
+ r = await this._getRequestLayouts(t);
7924
7924
  let i = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
7925
7925
  this._forceNextFlush = !1;
7926
7926
  let a = this._getDiff(r, i);
@@ -7934,8 +7934,8 @@ var oo = 90, so = 3, co = class extends y {
7934
7934
  e === this._generation && (this._lastFlushAt = Date.now(), this._inFlight = !1, this._pendingRequests && this._schedule());
7935
7935
  }
7936
7936
  }
7937
- _getRequestLayouts(e) {
7938
- let t = {}, n = this._getParticipants();
7937
+ async _getRequestLayouts(e) {
7938
+ let t = {}, n = await this._getParticipants();
7939
7939
  for (let r of e) {
7940
7940
  let e = typeof r.uid == "object" ? r.uid : Z.fromId(r.uid), i = this._api.getCachedOkIdByExternalId(e);
7941
7941
  if (!i) {
@@ -8791,12 +8791,12 @@ var Eo = class {
8791
8791
  conversationId: u
8792
8792
  });
8793
8793
  if (!this._conversation) throw new O(D.UNKNOWN_ERROR);
8794
- if (this._participantState = X.ACCEPTED, this._changeMediaSettings(l), await this._processConnection(d), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._signaling.readyToSend(), this._delayedHangup) throw new O(D.CANCELED);
8794
+ if (this._participantState = X.ACCEPTED, this._changeMediaSettings(l), await this._processConnection(d), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), this._signaling.readyToSend(), this._delayedHangup) throw new O(D.CANCELED);
8795
8795
  return this._debug.debug("Outgoing call", {
8796
8796
  opponentIds: e,
8797
8797
  opponentType: t,
8798
8798
  mediaOptions: n
8799
- }), this._processConnectionSharedMovieInfo(d), this._processConversationUrlSharingInfo(d), L.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), void 0, this.id), this._onConversationParticipantListChunk(d), this._processPinnedParticipants(d), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), z.add(this), await z.setActive(this.id), zo = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
8799
+ }), await this._processConnectionSharedMovieInfo(d), await this._processConversationUrlSharingInfo(d), L.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), await this._getMainRoomParticipants(), void 0, this.id), await this._onConversationParticipantListChunk(d), await this._processPinnedParticipants(d), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), z.add(this), await z.setActive(this.id), zo = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
8800
8800
  this._calleeUnavailableTimer = null, this._signaling.ready && this._signaling.hangup(D.CANCELED), this._close(new O(D.CALLEE_UNAVAILABLE));
8801
8801
  }, f)), this._conversation;
8802
8802
  } catch (e) {
@@ -8825,27 +8825,28 @@ var Eo = class {
8825
8825
  this._debug.debug("Join conversation part 2");
8826
8826
  try {
8827
8827
  if (this._participantState = X.ACCEPTED, !this._conversation || !this._mediaSource) throw new O(D.UNKNOWN_ERROR);
8828
- if (this._statFirstMediaReceived.markOnJoin(this._conversation.topology), !n && !this._conversation.observer && !this._isAudienceModeListener() && this._changeMediaSettings(this._mediaSource.mediaSettings), await this._processConnection(e), t && (this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener()), this._signaling.readyToSend(), this._state === "CLOSE") return this._conversation;
8828
+ if (this._statFirstMediaReceived.markOnJoin(this._conversation.topology), !n && !this._conversation.observer && !this._isAudienceModeListener() && this._changeMediaSettings(this._mediaSource.mediaSettings), await this._processConnection(e), t && (await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener()), this._signaling.readyToSend(), this._state === "CLOSE") return this._conversation;
8829
8829
  if (this._delayedHangup) throw new O(D.CANCELED);
8830
- this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
8831
- let r = this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
8832
- L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (z.has(this.id) || z.add(this), n ? await this._holdLocally() : await z.setActive(this.id), zo = null);
8830
+ await this._processConnectionSharedMovieInfo(e), await this._processConversationUrlSharingInfo(e), await this._processConnectionAsrInfo(e);
8831
+ let r = await this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
8832
+ L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), await this._getMainRoomParticipants(), r, this.id), await this._onConversationParticipantListChunk(e), await this._processPinnedParticipants(e), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (z.has(this.id) || z.add(this), n ? await this._holdLocally() : await z.setActive(this.id), zo = null);
8833
8833
  let i = this._extractLocalParticipantFromConnection(e);
8834
8834
  if (i) {
8835
8835
  let e = j.mapParticipantState(i);
8836
8836
  Object.keys(e).length > 0 && L.onLocalParticipantState(e, !1, this.id);
8837
8837
  }
8838
- return t && this._openTransport(Object.values(this._getParticipants()), !1), this._conversation;
8838
+ return t && this._openTransport(Object.values(await this._getParticipants()), !1), this._conversation;
8839
8839
  } catch (e) {
8840
8840
  throw zo = null, this._close(e, "Unable to join conversation"), e;
8841
8841
  }
8842
8842
  }
8843
- _extractExternalRooms(e) {
8844
- return e.map(this._convertRoomToExternal.bind(this)).filter((e) => !!e);
8843
+ async _extractExternalRooms(e) {
8844
+ let t = e.map(this._convertRoomToExternal.bind(this));
8845
+ return (await Promise.all(t)).filter((e) => !!e);
8845
8846
  }
8846
- _extractExternalRoomsData(e, t) {
8847
+ async _extractExternalRoomsData(e, t) {
8847
8848
  if (!e || !e.length) return;
8848
- let n = { rooms: this._extractExternalRooms(e) };
8849
+ let n = { rooms: await this._extractExternalRooms(e) };
8849
8850
  return t && (n.roomId = t), n;
8850
8851
  }
8851
8852
  async onPush(e, t = A.USER, n, r, i) {
@@ -8859,7 +8860,7 @@ var Eo = class {
8859
8860
  let a = await this._prepareConversation(e, t, n, r, i);
8860
8861
  if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new O(D.UNKNOWN_ERROR);
8861
8862
  if (!a.conversation.participants.find((e) => e.state === X.CALLED && e.id === this._conversation?.userId)) throw this._debug.log("Push rejected (there is an active call)"), this._stats.logger.log(S.PUSH, "rejected"), new O(D.REJECTED);
8862
- if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(S.PUSH, "accepted"), z.add(this), zo = null, this._delayedHangup) throw new O(D.CANCELED);
8863
+ if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), await this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(S.PUSH, "accepted"), z.add(this), zo = null, this._delayedHangup) throw new O(D.CANCELED);
8863
8864
  } catch (e) {
8864
8865
  throw zo = null, this._close(e, "Unable to handle inbound call push"), e;
8865
8866
  }
@@ -8888,13 +8889,13 @@ var Eo = class {
8888
8889
  let e = this._mediaSource.mediaSettings;
8889
8890
  this._logWithMediaSettings(S.ACCEPT_CONCURRENT, e), this._debug.debug("Concurrent call", { conversationId: this._conversation.id });
8890
8891
  try {
8891
- this._statFirstMediaReceived.markAcceptCall(this._transport.getTopology()), await this._signaling.acceptCall(this._mediaSource.mediaSettings), this._stats.lifecycle.markIncomingAccepted(!0), L.onCallAccepted(this.id), this._state = "ACTIVE", this._participantState = X.ACCEPTED, this._changeFeatureSet(), this._openTransport(Object.values(this._getParticipants()), !0);
8892
+ this._statFirstMediaReceived.markAcceptCall(this._transport.getTopology()), await this._signaling.acceptCall(this._mediaSource.mediaSettings), this._stats.lifecycle.markIncomingAccepted(!0), L.onCallAccepted(this.id), this._state = "ACTIVE", this._participantState = X.ACCEPTED, this._changeFeatureSet(), this._openTransport(Object.values(await this._getParticipants()), !0);
8892
8893
  } catch (e) {
8893
8894
  this._close(e, "Unable to accept concurrent call");
8894
8895
  }
8895
8896
  }
8896
- _getMainRoomParticipants() {
8897
- let e = this._getParticipants();
8897
+ async _getMainRoomParticipants() {
8898
+ let e = await this._getParticipants();
8898
8899
  return j.mapSharedParticipants(Object.values(e).filter((e) => !e.isInRoom));
8899
8900
  }
8900
8901
  _decodeExternalConversationParams(e) {
@@ -8937,7 +8938,7 @@ var Eo = class {
8937
8938
  }), this._registerParticipantLocalMuteState({ muteStates: this._conversation.muteStatesPersonal });
8938
8939
  let i = await this._signaling.getRooms(this._isCallAdmin());
8939
8940
  if (i.rooms?.rooms) {
8940
- let e = this._getParticipants();
8941
+ let e = await this._getParticipants();
8941
8942
  i.rooms.rooms.forEach((t) => {
8942
8943
  t.participantIds?.forEach((t) => {
8943
8944
  e[t] && (e[t].isInRoom = !0);
@@ -8945,15 +8946,15 @@ var Eo = class {
8945
8946
  });
8946
8947
  }
8947
8948
  this._conversation.roomId = i.rooms?.roomId || null;
8948
- let a = this._extractExternalRoomsData(i.rooms?.rooms, i.rooms?.roomId);
8949
- if (L.onCallAccepted(this.id), L.onLocalStream(this._mediaSource.getStream(), t, this.id), L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), a, this.id), await this._emitHeldParticipantsStatus(), M.useParticipantListChunk) {
8950
- let e = await this._getInitialParticiapntListChunk(), t = this._getParticipants();
8949
+ let a = await this._extractExternalRoomsData(i.rooms?.rooms, i.rooms?.roomId);
8950
+ if (L.onCallAccepted(this.id), L.onLocalStream(this._mediaSource.getStream(), t, this.id), L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), await this._getMainRoomParticipants(), a, this.id), await this._emitHeldParticipantsStatus(), M.useParticipantListChunk) {
8951
+ let e = await this._getInitialParticiapntListChunk(), t = await this._getParticipants();
8951
8952
  e?.participants?.forEach((e) => {
8952
8953
  let n = t[j.composeId(e)];
8953
8954
  n && (n.movieShareInfos = e.movieShareInfos);
8954
- }), this._onConversationParticipantListChunk({ participants: e });
8955
+ }), await this._onConversationParticipantListChunk({ participants: e });
8955
8956
  }
8956
- return L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), this._state = "ACTIVE", this._changeFeatureSet(), this._openTransport(Object.values(this._getParticipants()), !0), this._processConversationUrlSharingInfo(), this._processConnectionAsrInfo(), z.setActive(this.id).catch((e) => {
8957
+ return L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), this._state = "ACTIVE", this._changeFeatureSet(), this._openTransport(Object.values(await this._getParticipants()), !0), await this._processConversationUrlSharingInfo(), await this._processConnectionAsrInfo(), z.setActive(this.id).catch((e) => {
8957
8958
  this._debug.error(e), this._close(e, "Unable to activated accepted call");
8958
8959
  }), this._conversation;
8959
8960
  } catch (e) {
@@ -9051,12 +9052,12 @@ var Eo = class {
9051
9052
  this._cleanupSignaling(), this._cleanupMediaSource();
9052
9053
  return;
9053
9054
  }
9054
- this._state = "CLOSE", this._participantState = X.HUNGUP, this._changeFeatureSet(), this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._cleanupSignaling(), this._api.cleanup(), this._api.setAbortSignal(void 0), this._signaling.setAbortSignal(void 0), this._stats.destroy(), z.remove(this.id), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null, L.onHangup(e || new O(D.UNKNOWN_ERROR), n);
9055
+ this._state = "CLOSE", this._participantState = X.HUNGUP, this._changeFeatureSet(), this._cleanupMediaSource(), await this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._cleanupSignaling(), this._api.cleanup(), this._api.setAbortSignal(void 0), this._signaling.setAbortSignal(void 0), this._stats.destroy(), z.remove(this.id), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null, L.onHangup(e || new O(D.UNKNOWN_ERROR), n);
9055
9056
  }
9056
- destroy() {
9057
+ async destroy() {
9057
9058
  this._clearCalleeUnavailableWatchdog();
9058
9059
  let e = this._conversation && this._conversation.id;
9059
- if (this._debug.debug("Destroy conversation", { conversationId: e }), this._stopFirstMediaSentProbe(), this._cooldownQueueCleanupTimer !== null && (window.clearInterval(this._cooldownQueueCleanupTimer), this._cooldownQueueCleanupTimer = null), this._state = "CLOSE", this._participantState = X.HUNGUP, this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._cleanupSignaling(), this._api.cleanup(), this._api.setAbortSignal(void 0), this._signaling.setAbortSignal(void 0), this._delayedHangup && e) try {
9060
+ if (this._debug.debug("Destroy conversation", { conversationId: e }), this._stopFirstMediaSentProbe(), this._cooldownQueueCleanupTimer !== null && (window.clearInterval(this._cooldownQueueCleanupTimer), this._cooldownQueueCleanupTimer = null), this._state = "CLOSE", this._participantState = X.HUNGUP, this._cleanupMediaSource(), await this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._cleanupSignaling(), this._api.cleanup(), this._api.setAbortSignal(void 0), this._signaling.setAbortSignal(void 0), this._delayedHangup && e) try {
9060
9061
  this._api.hangupConversation(e, D.CANCELED);
9061
9062
  } catch {}
9062
9063
  this._cleanupListeners(), this._stats.destroy(), z.remove(this.id), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null;
@@ -9151,7 +9152,7 @@ var Eo = class {
9151
9152
  } else p = await this._api.startConversation(d, e, t, f, i, a, o, { onlyAdminCanShareMovie: s }, c), this._debug.debug("Api.startConversation", p);
9152
9153
  this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id), this._stats.lifecycle.markWarmupCompleted();
9153
9154
  let m = await this._connectSignaling(dr.START, p);
9154
- return this._setConversation(p, m, n), this._stats.lifecycle.markCallStarted(), m;
9155
+ return await this._setConversation(p, m, n), this._stats.lifecycle.markCallStarted(), m;
9155
9156
  }
9156
9157
  async _joinConversation(e) {
9157
9158
  W.setMark(H.SIGNALING_CONNECTED);
@@ -9204,7 +9205,7 @@ var Eo = class {
9204
9205
  if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), ro(l, u), l.id && z.has(l.id)) throw new O(D.HAS_ACTIVE_CALL);
9205
9206
  this._setConversationParams(l), this._stats.lifecycle.markWarmupCompleted();
9206
9207
  let d = await this._connectSignaling(dr.JOIN, l);
9207
- return this._setConversation(l, d, Aa.JOINING), this._stats.lifecycle.markCallStarted(), d;
9208
+ return await this._setConversation(l, d, Aa.JOINING), this._stats.lifecycle.markCallStarted(), d;
9208
9209
  }
9209
9210
  async _prepareConversation(e, t = A.USER, n, r, i) {
9210
9211
  W.setMark(H.SIGNALING_CONNECTED), this._debug.debug("Conversation: push", {
@@ -9263,9 +9264,9 @@ var Eo = class {
9263
9264
  }
9264
9265
  this._stats.lifecycle.markWarmupCompleted();
9265
9266
  let u = await this._connectSignaling(dr.ACCEPT, l);
9266
- return z.callsLength >= M.maxParallelCalls || !M.hold && z.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(S.PUSH, "busy"), this._signaling.ready && this._signaling.hangup(D.BUSY), Promise.reject(new O(D.BUSY))) : (this._setConversation(l, u, Aa.INCOMING, t), u);
9267
+ return z.callsLength >= M.maxParallelCalls || !M.hold && z.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(S.PUSH, "busy"), this._signaling.ready && this._signaling.hangup(D.BUSY), Promise.reject(new O(D.BUSY))) : (await this._setConversation(l, u, Aa.INCOMING, t), u);
9267
9268
  }
9268
- _createParticipant(e, t, n = !0) {
9269
+ async _createParticipant(e, t, n = !0) {
9269
9270
  let r = Object.assign({
9270
9271
  id: null,
9271
9272
  externalId: null,
@@ -9285,12 +9286,12 @@ var Eo = class {
9285
9286
  observedIds: [],
9286
9287
  isInRoom: !1,
9287
9288
  markers: null
9288
- }, e), i = !!r.externalId;
9289
- return i || (r.externalId = this._getParticipantId(t ?? r.id)), n && i && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = Wa.create(r.connectionStatus), r;
9289
+ }, e);
9290
+ return r.externalId || (r.externalId = await this._getParticipantId(t ?? r.id)), n && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = Wa.create(r.connectionStatus), r;
9290
9291
  }
9291
- _getParticipantId(e) {
9292
+ async _getParticipantId(e) {
9292
9293
  try {
9293
- return this._api.userId(e);
9294
+ return await this._api.userId(e);
9294
9295
  } catch (e) {
9295
9296
  throw this._close(new O(D.NETWORK_ERROR), e), e;
9296
9297
  }
@@ -9305,7 +9306,7 @@ var Eo = class {
9305
9306
  }
9306
9307
  });
9307
9308
  }
9308
- _setConversation(e, t, n, r = A.USER) {
9309
+ async _setConversation(e, t, n, r = A.USER) {
9309
9310
  let { participants: i } = t.conversation;
9310
9311
  t.conversationParams?.serverTime && (this._serverTimeOffset = t.conversationParams.serverTime - Date.now()), this._cacheParticipantExternalIds(i);
9311
9312
  let a = this._api.getUserId(), o = this._extractLocalParticipantFromConnection(t), s = e.device_idx || 0;
@@ -9317,7 +9318,7 @@ var Eo = class {
9317
9318
  this._conversation = {
9318
9319
  userId: a,
9319
9320
  compositeUserId: c,
9320
- externalId: this._getExternalIdByParticipantId(c),
9321
+ externalId: await this._getExternalIdByParticipantId(c),
9321
9322
  acceptTime: t.conversation.acceptTime,
9322
9323
  features: t.conversation.features || [],
9323
9324
  featuresPerRole: t.conversation.featuresPerRole,
@@ -9364,9 +9365,9 @@ var Eo = class {
9364
9365
  async _processConnection(e) {
9365
9366
  await this._registerConnectionParticipants(e), this._processRooms(e), this._processMuteStates(e), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), e.chatRoom && e.chatRoom.totalCount && this._onChatRoomUpdated(Ma.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
9366
9367
  }
9367
- _onConversationParticipantListChunk(e) {
9368
+ async _onConversationParticipantListChunk(e) {
9368
9369
  let t = e.participants;
9369
- t && L.onConversationParticipantListChunk(this._participantListChunkToExternalChunk(this._createParticipantListChunk(t)), this.id);
9370
+ t && L.onConversationParticipantListChunk(await this._participantListChunkToExternalChunk(this._createParticipantListChunk(t)), this.id);
9370
9371
  }
9371
9372
  _createParticipantListChunk(e) {
9372
9373
  return {
@@ -9377,8 +9378,8 @@ var Eo = class {
9377
9378
  ...e
9378
9379
  };
9379
9380
  }
9380
- _participantListChunkToExternalChunk(e) {
9381
- let t = this._getParticipants(), n = j.mapSharedParticipants(e.participants.reduce((e, n) => {
9381
+ async _participantListChunkToExternalChunk(e) {
9382
+ let t = await this._getParticipants(), n = j.mapSharedParticipants(e.participants.reduce((e, n) => {
9382
9383
  let r = j.composeId(n);
9383
9384
  return t[r] && e.push(t[r]), e;
9384
9385
  }, []));
@@ -9396,7 +9397,7 @@ var Eo = class {
9396
9397
  if (!this._conversation) return;
9397
9398
  let n = e[0]?.externalId?.type;
9398
9399
  n && (M.externalUserType = n);
9399
- let r = this._getParticipants();
9400
+ let r = await this._getParticipants();
9400
9401
  for (let n of e) {
9401
9402
  let e = j.composeId(n);
9402
9403
  if (R.test("Conversation:RegisterParticipant", e), this._isMe(e)) {
@@ -9424,7 +9425,7 @@ var Eo = class {
9424
9425
  movieShareInfos: n.movieShareInfos,
9425
9426
  isInRoom: t
9426
9427
  }, i);
9427
- let a = this._getParticipant(e);
9428
+ let a = await this._getParticipant(e);
9428
9429
  a && n.roles && n.roles.length && (this._debug.debug(`Roles for participant [${e}] changed: ${n.roles}`), L.onRolesChanged(a.externalId, n.roles, !0, this.id)), a && a.isOnHold && L.onRemoteStatus([a.externalId], N.ONHOLD, null, this.id);
9429
9430
  }
9430
9431
  }
@@ -9469,10 +9470,10 @@ var Eo = class {
9469
9470
  _registerParticipantInCache(e) {
9470
9471
  return this._participants[e.id] = e, e;
9471
9472
  }
9472
- _getExistedParticipantByIdOrCreate(e) {
9473
- let t = this._getParticipants()[e];
9473
+ async _getExistedParticipantByIdOrCreate(e) {
9474
+ let t = (await this._getParticipants())[e];
9474
9475
  if (t) return t;
9475
- let n = this._api.getDecorativeIdByInitialId(j.decomposeId(e).id), r = n ? j.composeUserId(n) : void 0, i = this._getParticipantId(e), { deviceIdx: a } = j.decomposeParticipantId(e);
9476
+ let n = this._api.getDecorativeIdByInitialId(j.decomposeId(e).id), r = n ? j.composeUserId(n) : void 0, i = await this._getParticipantId(e), { deviceIdx: a } = j.decomposeParticipantId(e);
9476
9477
  return this._createParticipant({
9477
9478
  id: e,
9478
9479
  externalId: {
@@ -9481,31 +9482,25 @@ var Eo = class {
9481
9482
  }
9482
9483
  }, r, !1);
9483
9484
  }
9484
- _getExternalIdByParticipantId(e) {
9485
+ async _getExternalIdByParticipantId(e) {
9485
9486
  if (this._isMe(e)) return this._conversation?.externalId;
9486
- if (M.useParticipantListChunk) return this._getExistedParticipantByIdOrCreate(e).externalId;
9487
- let t = this._getParticipants();
9487
+ if (M.useParticipantListChunk) return (await this._getExistedParticipantByIdOrCreate(e)).externalId;
9488
+ let t = await this._getParticipants();
9488
9489
  if (t[e]?.externalId) return t[e].externalId;
9489
9490
  {
9490
- let t = this._getParticipantId(e);
9491
+ let t = await this._getParticipantId(e);
9491
9492
  return this._api.cacheExternalId(e, t), t;
9492
9493
  }
9493
9494
  }
9494
9495
  _getExternalIdsByOkIdsFromCache(e) {
9495
9496
  return e.map((e) => this._api.getCachedExternalIdByOkId(e) ?? Z.fromId(String(e)));
9496
9497
  }
9497
- _getOrCacheExternalIdByCompositeId(e) {
9498
- let t = j.extractOkId(e), n = this._api.getCachedExternalIdByOkId(t);
9499
- if (n) return n;
9500
- let { type: r } = j.decomposeId(e), i = Z.fromId(String(t), r === A.GROUP ? Ga.GROUP : Ga.USER);
9501
- return this._api.cacheExternalId(e, i), i;
9502
- }
9503
- _registerParticipantAndSetMarkersIfChunkEnabled(e, t) {
9498
+ async _registerParticipantAndSetMarkersIfChunkEnabled(e, t) {
9504
9499
  if (M.useParticipantListChunk) {
9505
- let n = this._registerParticipantInCache(this._getExistedParticipantByIdOrCreate(e));
9500
+ let n = this._registerParticipantInCache(await this._getExistedParticipantByIdOrCreate(e));
9506
9501
  return n.markers = this._denormalizeMarkers(n.id, t), n;
9507
9502
  }
9508
- return this._getParticipants()[e];
9503
+ return (await this._getParticipants())[e];
9509
9504
  }
9510
9505
  _warnParticipantNotInConversation(e) {
9511
9506
  this._debug.warn(`Participant [${e}] isn't in conversation`);
@@ -9542,21 +9537,21 @@ var Eo = class {
9542
9537
  this._onRecordInfo(e.conversation?.recordInfo ?? null);
9543
9538
  for (let t of e.rooms?.rooms ?? []) this._onRecordInfo(t.recordInfo ?? null, t.id);
9544
9539
  }
9545
- _processPinnedParticipants(e) {
9546
- e.conversation.pinnedParticipantId ? this._onPinParticipant(e.conversation.pinnedParticipantId) : this._conversation?.pinnedParticipantIdByRoom.delete(null);
9547
- for (let t of e.rooms?.rooms ?? []) t.pinnedParticipantId ? this._onPinParticipant(t.pinnedParticipantId, !1, void 0, t.id) : this._conversation?.pinnedParticipantIdByRoom.delete(t.id);
9540
+ async _processPinnedParticipants(e) {
9541
+ e.conversation.pinnedParticipantId ? await this._onPinParticipant(e.conversation.pinnedParticipantId) : this._conversation?.pinnedParticipantIdByRoom.delete(null);
9542
+ for (let t of e.rooms?.rooms ?? []) t.pinnedParticipantId ? await this._onPinParticipant(t.pinnedParticipantId, !1, void 0, t.id) : this._conversation?.pinnedParticipantIdByRoom.delete(t.id);
9548
9543
  }
9549
- _allocateTransport() {
9544
+ async _allocateTransport() {
9550
9545
  if (!this._conversation || !this._mediaSource) return;
9551
9546
  this._transport = new na(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator, this._getFirstMediaSentCallback()), this._debugInfo = new co(this._debug), this.subscribe(this._transport, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, Y.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, Y.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, Y.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, Y.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, Y.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, Y.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, Y.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
9552
- let e = this._conversation.direction === Aa.OUTGOING && !this._conversation.concurrent, t = this._getParticipants();
9547
+ let e = this._conversation.direction === Aa.OUTGOING && !this._conversation.concurrent, t = await this._getParticipants();
9553
9548
  for (let n of Object.values(t)) (n.state === X.ACCEPTED || n.state === X.CALLED) && this._allocateParticipantTransport(n.id, e);
9554
9549
  }
9555
9550
  _createSpeakerDetector() {
9556
9551
  this._transport && this._conversation && (this._volumesDetector = new go(this._transport), this.subscribe(this._volumesDetector, ho.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new vo(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, _o.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new po(this._mediaSource));
9557
9552
  }
9558
- _createSpecListener() {
9559
- this._transport && this._volumesDetector && (this._specListener = new xo(this._transport, this._volumesDetector, this._getParticipants(), this._debug, this._stats.logger));
9553
+ async _createSpecListener() {
9554
+ this._transport && this._volumesDetector && (this._specListener = new xo(this._transport, this._volumesDetector, await this._getParticipants(), this._debug, this._stats.logger));
9560
9555
  }
9561
9556
  _logDevices() {
9562
9557
  let e = T.getCameras().length, t = T.getMicrophones().length;
@@ -9568,7 +9563,7 @@ var Eo = class {
9568
9563
  async _removeParticipant(e, t) {
9569
9564
  if (e.state === X.CALLED || e.state === X.ACCEPTED || this._state === "CLOSE") return;
9570
9565
  e.id === this._lastSignalledActiveSpeakerId && (this._lastSignalledActiveSpeakerId = null);
9571
- let n = this._getParticipants();
9566
+ let n = await this._getParticipants();
9572
9567
  if (n[e.id]) {
9573
9568
  t === D.HUNGUP ? this._setParticipantsStatus([e], N.HANGUP) : this._setParticipantsStatus([e], N.ERROR, t), e.mediaSource?.disconnect(), this._displayLayoutRequester.cleanupParticipant(e.id), this._conversation && this._conversation.pinnedParticipantIdByRoom.get(null) === e.id && this._conversation.pinnedParticipantIdByRoom.delete(null), this._conversation && this._conversation.roomId && this._conversation.pinnedParticipantIdByRoom.get(this._conversation.roomId) === e.id && this._conversation.pinnedParticipantIdByRoom.delete(this._conversation.roomId);
9574
9569
  for (let [t, n] of Object.entries(e.lastRequestedLayouts)) this._streamIdByStreamDescription.delete(t), this._sequenceNumberByStreamDescription.delete(t), this._cooldownTimestampByStreamDescription.delete(t), this._streamWaitTimerByStreamDescription.has(t) && (window.clearTimeout(this._streamWaitTimerByStreamDescription.get(t)), this._streamWaitTimerByStreamDescription.delete(t)), this._sendUpdateDisplayLayout({ [t]: { stopStream: !0 } }, !1);
@@ -9581,8 +9576,8 @@ var Eo = class {
9581
9576
  _cleanupMediaSource() {
9582
9577
  this._mediaSource && (this._mediaSource.destroy(), this._mediaSource = null);
9583
9578
  }
9584
- _cleanupParticipants() {
9585
- Object.values(this._getParticipants()).forEach((e) => {
9579
+ async _cleanupParticipants() {
9580
+ Object.values(await this._getParticipants()).forEach((e) => {
9586
9581
  e.remoteStream?.getTracks().forEach((e) => e.stop()), e.remoteAudioTrack?.stop(), e.secondStream?.getTracks().forEach((e) => e.stop()), e.mediaSource?.disconnect();
9587
9582
  }), this._participants = {}, this._audioOutput && this._audioOutput.destroy();
9588
9583
  }
@@ -9622,7 +9617,7 @@ var Eo = class {
9622
9617
  }
9623
9618
  async _onAddParticipant(e, t, n) {
9624
9619
  this._debug.debug(`Add new participant [${e}]`);
9625
- let r = this._getParticipant(e);
9620
+ let r = await this._getParticipant(e);
9626
9621
  r && this._updateParticipantExternalId(r, t);
9627
9622
  let i = !r;
9628
9623
  if (r && (r.state === X.ACCEPTED || r.state === X.CALLED)) {
@@ -9642,13 +9637,13 @@ var Eo = class {
9642
9637
  muteStates: t.muteStates || {},
9643
9638
  unmuteOptions: t.unmuteOptions || [],
9644
9639
  observedIds: t.observedIds || []
9645
- }, n), r = this._getParticipant(e);
9640
+ }, n), r = await this._getParticipant(e);
9646
9641
  }
9647
9642
  this._setParticipantsStatus([r], N.WAITING), i && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(r), n ? (r.state = X.HUNGUP, await this._removeParticipant(r, n)) : this._transport && (r.state = X.CALLED, this._allocateParticipantTransport(r.id, !0), this._stats.logger.log(S.ADD_PARTICIPANT), this._invokeRolesChangedCallbackIfNeeded(r));
9648
9643
  }
9649
- _onRemoveParticipant(e) {
9644
+ async _onRemoveParticipant(e) {
9650
9645
  this._debug.debug(`Remove participant [${e}]`);
9651
- let t = [], n = this._getParticipants();
9646
+ let t = [], n = await this._getParticipants();
9652
9647
  for (let r = 0; r <= Ro; r++) {
9653
9648
  let i = n[j.compose(e, r)];
9654
9649
  i && t.push(i);
@@ -9714,7 +9709,7 @@ var Eo = class {
9714
9709
  let e = typeof t.uid == "object" ? t.uid : Z.fromId(t.uid), r = Z.toString(e);
9715
9710
  n[r] = t.priority;
9716
9711
  }
9717
- let r = this._getParticipants();
9712
+ let r = await this._getParticipants();
9718
9713
  for (let e of Object.values(r)) {
9719
9714
  let r = Z.toString(e.externalId);
9720
9715
  Object.hasOwn(n, r) && (t[e.id] = n[r]);
@@ -9736,15 +9731,15 @@ var Eo = class {
9736
9731
  return;
9737
9732
  }
9738
9733
  if (this._isWaitingForPromotion()) {
9739
- this._waitingHallHoldPending = !1, this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus());
9734
+ this._waitingHallHoldPending = !1, await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus());
9740
9735
  return;
9741
9736
  }
9742
9737
  let n = fa.get();
9743
9738
  await this._signaling.hold(!1, n), this._restoreStateAfterHold();
9744
9739
  let r = null;
9745
- if (this._state === "IDLE" && this._participantState === X.ACCEPTED && (r = Object.values(this._getParticipants()), r.some((e) => e.state === X.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), await this._resumeLocalMedia(t, N.WAITING), this._state === "ACTIVE") {
9740
+ if (this._state === "IDLE" && this._participantState === X.ACCEPTED && (r = Object.values(await this._getParticipants()), r.some((e) => e.state === X.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), await this._resumeLocalMedia(t, N.WAITING), this._state === "ACTIVE") {
9746
9741
  let e = this._conversation?.direction === Aa.OUTGOING && !this._conversation.concurrent;
9747
- this._openTransport(r ?? Object.values(this._getParticipants()), e);
9742
+ this._openTransport(r ?? Object.values(await this._getParticipants()), e);
9748
9743
  }
9749
9744
  }
9750
9745
  async _holdLocally() {
@@ -9777,7 +9772,7 @@ var Eo = class {
9777
9772
  async updateDisplayLayout(e) {
9778
9773
  if (e.length < 1 || !this._signaling.ready) return;
9779
9774
  this._debug.log(`Update display layout request [${this._signaling.getNextCommandSequenceNumber()}]`, e);
9780
- let t = {}, n = [], r = this._getParticipants();
9775
+ let t = {}, n = [], r = await this._getParticipants();
9781
9776
  for (let i of e) {
9782
9777
  let e = typeof i.uid == "object" ? i.uid : Z.fromId(i.uid), a = this._api.getCachedOkIdByExternalId(e);
9783
9778
  if (!a) {
@@ -9805,7 +9800,7 @@ var Eo = class {
9805
9800
  this._debug.error("Cannot accommodate all streaming requests: tracks available " + M.videoTracksCount + "; requested streams: " + Array.from(this._streamIdByStreamDescription.keys()));
9806
9801
  break;
9807
9802
  }
9808
- this._stopStreaming(e.value), t[e.value] = { stopStream: !0 };
9803
+ await this._stopStreaming(e.value), t[e.value] = { stopStream: !0 };
9809
9804
  }
9810
9805
  if (this._transport?.getTopology() !== J.SERVER) {
9811
9806
  n.forEach((e) => e());
@@ -9819,9 +9814,9 @@ var Eo = class {
9819
9814
  async feedback(e) {
9820
9815
  return this._signaling.feedback(e);
9821
9816
  }
9822
- _stopStreaming(e) {
9817
+ async _stopStreaming(e) {
9823
9818
  if (this._cooldownTimestampByStreamDescription.delete(e), this._sequenceNumberByStreamDescription.set(e, this._signaling.getNextCommandSequenceNumber()), this._streamWaitTimerByStreamDescription.has(e) && (this._debug.log("Client asked to stop streaming before stream became available", e), window.clearTimeout(this._streamWaitTimerByStreamDescription.get(e)), this._streamWaitTimerByStreamDescription.delete(e)), this._streamIdByStreamDescription.get(e)) {
9824
- let t = this._getParticipants(), n = En(e), r = t[n.participantId], i = this._conversation?.externalId, a = this._isMe(n.participantId);
9819
+ let t = await this._getParticipants(), n = En(e), r = t[n.participantId], i = this._conversation?.externalId, a = this._isMe(n.participantId);
9825
9820
  if (r || a) {
9826
9821
  switch (n.mediaType) {
9827
9822
  case V.STREAM:
@@ -9857,7 +9852,7 @@ var Eo = class {
9857
9852
  if (this._debug.warn(`Failed to update display layout ${JSON.stringify(e)}. ${n}`), t) throw n;
9858
9853
  return;
9859
9854
  }
9860
- let r = [], i = this._getParticipants();
9855
+ let r = [], i = await this._getParticipants();
9861
9856
  for (let [e, t] of Object.entries(n.errorCodeByParticipantId || {})) {
9862
9857
  let n = En(e), a = i[n.participantId];
9863
9858
  if (a) {
@@ -9894,61 +9889,74 @@ var Eo = class {
9894
9889
  }
9895
9890
  async _onChatRoomUpdated(e, t = 0, n = [], r, i) {
9896
9891
  this._debug.log(`Chat room updated: ${e}`);
9897
- let a = [];
9898
- n.length && n.forEach((e) => {
9892
+ let a = [], o = [], s = [], c = [], l = [];
9893
+ if (n.length && n.forEach((e) => {
9899
9894
  if (e.externalId) {
9900
9895
  let t = Z.fromSignaling(e.externalId);
9901
- a.push(t), this._api.cacheExternalId(e.id.id, t);
9902
- } else a.push(this._getOrCacheExternalIdByCompositeId(e.id.id));
9903
- });
9904
- let o = r?.map((e) => this._getOrCacheExternalIdByCompositeId(e)) ?? [], s = i?.map((e) => this._getOrCacheExternalIdByCompositeId(e)) ?? [];
9905
- L.onChatRoomUpdated(e, t, a, o, s, this.id);
9896
+ l.push(t), this._api.cacheExternalId(e.id.id, t);
9897
+ } else {
9898
+ let t = j.decomposeId(e.id.id).id;
9899
+ a.push(t), c.push(t);
9900
+ }
9901
+ }), r?.length && r.forEach((e) => {
9902
+ let t = j.decomposeId(e).id;
9903
+ a.push(t), o.push(t);
9904
+ }), i?.length && i.forEach((e) => {
9905
+ let t = j.decomposeId(e).id;
9906
+ a.push(t), s.push(t);
9907
+ }), !a.length) {
9908
+ L.onChatRoomUpdated(e, t, l, [], [], this.id);
9909
+ return;
9910
+ }
9911
+ c.length && l.push(...this._getExternalIdsByOkIdsFromCache(c));
9912
+ let u = this._getExternalIdsByOkIdsFromCache(o), d = this._getExternalIdsByOkIdsFromCache(s);
9913
+ L.onChatRoomUpdated(e, t, l, u, d, this.id);
9906
9914
  }
9907
- _onSharedMovieUpdate(e) {
9915
+ async _onSharedMovieUpdate(e) {
9908
9916
  let t = this._conversation?.externalId;
9909
9917
  for (let n of e.data) if (this._isMe(n.participantId)) L.onLocalLiveUpdate(t, n, this.id);
9910
9918
  else {
9911
- let e = this._getExternalIdByParticipantId(n.participantId);
9919
+ let e = await this._getExternalIdByParticipantId(n.participantId);
9912
9920
  e && L.onRemoteLiveUpdate(e, n, this.id);
9913
9921
  }
9914
9922
  }
9915
- _onSharedMovieInfoStarted(e) {
9916
- this._debug.log(`Shared movie started data received: ${e.notification}`), this._processSharedMovieInfo(e.movieShareInfo, e.roomId);
9923
+ async _onSharedMovieInfoStarted(e) {
9924
+ this._debug.log(`Shared movie started data received: ${e.notification}`), await this._processSharedMovieInfo(e.movieShareInfo, e.roomId);
9917
9925
  }
9918
- _processSharedMovieInfos(e, t = null) {
9919
- e && e.forEach((e) => this._processSharedMovieInfo(e, t));
9926
+ async _processSharedMovieInfos(e, t = null) {
9927
+ e && await Promise.all(e.map((e) => this._processSharedMovieInfo(e, t)));
9920
9928
  }
9921
- _processSharedMovieInfo(e, t = null) {
9929
+ async _processSharedMovieInfo(e, t = null) {
9922
9930
  if (!e) return;
9923
9931
  let n = this._conversation?.externalId;
9924
9932
  if (this._isMe(e.initiatorId)) L.onLocalSharedMovieInfo(n, e, t, this.id);
9925
9933
  else {
9926
- let n = this._getExternalIdByParticipantId(e.initiatorId);
9934
+ let n = await this._getExternalIdByParticipantId(e.initiatorId);
9927
9935
  n && L.onRemoteSharedMovieInfo(n, e, t, this.id);
9928
9936
  }
9929
9937
  }
9930
- _processConnectionSharedMovieInfo(e) {
9938
+ async _processConnectionSharedMovieInfo(e) {
9931
9939
  let t = e.conversation.participants.find((e) => this._isMe(j.composeId(e)));
9932
- this._processSharedMovieInfos(t?.movieShareInfos, e?.rooms?.roomId ?? null);
9940
+ await this._processSharedMovieInfos(t?.movieShareInfos, e?.rooms?.roomId ?? null);
9933
9941
  }
9934
- _processConnectionAsrInfo(e) {
9942
+ async _processConnectionAsrInfo(e) {
9935
9943
  let t = e?.conversation.asrInfo ?? this._conversation?.asrInfo;
9936
9944
  if (t && this._conversation?.asrInfoByRoom.set(null, t), e?.rooms?.rooms) for (let t of e.rooms.rooms) t.asrInfo && this._conversation?.asrInfoByRoom.set(t.id, t.asrInfo);
9937
9945
  let n = e?.rooms?.roomId ?? this._conversation?.roomId ?? null, r = this._conversation?.asrInfoByRoom.get(n);
9938
9946
  if (r) {
9939
- let e = this._getExternalIdByParticipantId(r.initiatorId);
9947
+ let e = await this._getExternalIdByParticipantId(r.initiatorId);
9940
9948
  e && L.onAsrSet({
9941
9949
  externalId: e,
9942
9950
  movieId: r.movieId
9943
9951
  }, n, this.id);
9944
9952
  } else n && L.onAsrSet(null, n, this.id);
9945
9953
  }
9946
- _processConversationUrlSharingInfo(e) {
9954
+ async _processConversationUrlSharingInfo(e) {
9947
9955
  if (!this._conversation) return;
9948
9956
  e && this._extractConnectionUrlSharingInfo(e);
9949
9957
  let { urlSharingInfoByRoom: t } = this._conversation, n = this._conversation.roomId, r = t.get(n);
9950
9958
  if (r && !this._isMe(r.initiatorId)) {
9951
- let e = this._getExternalIdByParticipantId(r.initiatorId);
9959
+ let e = await this._getExternalIdByParticipantId(r.initiatorId);
9952
9960
  e && L.onRemoteSharedUrl(e, r.sharedUrl, n, this.id);
9953
9961
  }
9954
9962
  }
@@ -9957,7 +9965,7 @@ var Eo = class {
9957
9965
  let { urlSharingInfoByRoom: t } = this._conversation;
9958
9966
  if (e.conversation.urlSharingInfo ? t.set(null, e.conversation.urlSharingInfo) : t.delete(null), e.rooms?.rooms) for (let n of e.rooms.rooms) n.urlSharingInfo ? t.set(n.id, n.urlSharingInfo) : t.delete(n.id);
9959
9967
  }
9960
- _onSharedMovieInfoStopped(e) {
9968
+ async _onSharedMovieInfoStopped(e) {
9961
9969
  this._debug.log(`Shared movie stopped data received: ${e.notification}`);
9962
9970
  let t = this._conversation?.externalId, { initiatorId: n, movieId: r, source: i, roomId: a = null } = e, o = {
9963
9971
  initiatorId: n,
@@ -9966,21 +9974,21 @@ var Eo = class {
9966
9974
  };
9967
9975
  if (this._isMe(n)) L.onLocalSharedMovieStoppedInfo(t, o, a, this.id);
9968
9976
  else {
9969
- let e = this._getExternalIdByParticipantId(n);
9977
+ let e = await this._getExternalIdByParticipantId(n);
9970
9978
  if (e) {
9971
- let t = this._getParticipants()[n];
9979
+ let t = (await this._getParticipants())[n];
9972
9980
  t?.movieShareInfos && (t.movieShareInfos = t.movieShareInfos.filter((e) => e && e.movieId !== r)), L.onRemoteSharedMovieStoppedInfo(e, o, a, this.id);
9973
9981
  }
9974
9982
  }
9975
9983
  }
9976
- _onUrlSharingInfoUpdated(e) {
9984
+ async _onUrlSharingInfoUpdated(e) {
9977
9985
  if (this._debug.log(`Shared URL data received: ${e.notification}`), !this._conversation) return;
9978
9986
  let { urlSharingInfoByRoom: t, roomId: n } = this._conversation, { initiatorId: r, sharedUrl: i, roomId: a = null } = e;
9979
9987
  if (i ? t.set(a, {
9980
9988
  sharedUrl: i,
9981
9989
  initiatorId: r
9982
9990
  }) : t.delete(a), !(!i && a !== n && t.has(n)) && (!i || !this._isMe(r))) {
9983
- let e = this._getExternalIdByParticipantId(r);
9991
+ let e = await this._getExternalIdByParticipantId(r);
9984
9992
  e && L.onRemoteSharedUrl(e, i, a, this.id);
9985
9993
  }
9986
9994
  }
@@ -9991,7 +9999,7 @@ var Eo = class {
9991
9999
  if (e.fastScreenShare && !e.participantStreamDescription) {
9992
10000
  let t = this._getStreamDescriptionById(e.streamId);
9993
10001
  if (t) {
9994
- let e = En(t), n = this._getParticipant(e.participantId);
10002
+ let e = En(t), n = await this._getParticipant(e.participantId);
9995
10003
  L.onRemoteScreenStream(n.externalId, null, this.id);
9996
10004
  return;
9997
10005
  }
@@ -10000,7 +10008,7 @@ var Eo = class {
10000
10008
  if (!t) return;
10001
10009
  let { mediaType: n, participantId: r } = t;
10002
10010
  if (n === V.ANIMOJI) return;
10003
- let i = this._getParticipant(r);
10011
+ let i = await this._getParticipant(r);
10004
10012
  if (n === V.SCREEN && !e.fastScreenShare) {
10005
10013
  this._debug.log("skipping participant-sources-update notification since screenshare will be received over datachannel");
10006
10014
  return;
@@ -10137,15 +10145,22 @@ var Eo = class {
10137
10145
  };
10138
10146
  }
10139
10147
  async _resolveWaitingHallExternalIds(e) {
10140
- let t = [], n = [];
10141
- return e.length && e.forEach((e) => {
10142
- if (e.externalId) {
10143
- let r = Z.fromSignaling(e.externalId);
10144
- t.push(e.id.addedTs), n.push(r), this._api.cacheExternalId(e.id.id, r);
10145
- } else n.push(this._getOrCacheExternalIdByCompositeId(e.id.id)), t.push(e.id.addedTs);
10146
- }), {
10147
- externalIds: n,
10148
- timestamps: t
10148
+ let t = /* @__PURE__ */ new Map(), n = [], r = [];
10149
+ if (e.length) {
10150
+ let i = [];
10151
+ e.forEach((e) => {
10152
+ if (t.set(e.id.id, e.id.addedTs), e.externalId) {
10153
+ let t = Z.fromSignaling(e.externalId);
10154
+ n.push(e.id.addedTs), r.push(t), this._api.cacheExternalId(e.id.id, t);
10155
+ } else i.push(j.decomposeId(e.id.id).id);
10156
+ }), i.length && !r.length && (r = this._getExternalIdsByOkIdsFromCache(i), n = r.map((e) => {
10157
+ let n = this._api.getCachedOkIdByExternalId(e);
10158
+ return (n ? t.get(n) : void 0) || Date.now();
10159
+ }));
10160
+ }
10161
+ return {
10162
+ externalIds: r,
10163
+ timestamps: n
10149
10164
  };
10150
10165
  }
10151
10166
  async getAudienceModeHands() {
@@ -10182,7 +10197,7 @@ var Eo = class {
10182
10197
  let t = await this._signaling.chatHistory(e);
10183
10198
  for (let e = t.messages.length - 1; e >= 0; e--) {
10184
10199
  let n = t.messages[e];
10185
- this._onChatMessage(n);
10200
+ await this._onChatMessage(n);
10186
10201
  }
10187
10202
  }
10188
10203
  }
@@ -10306,7 +10321,7 @@ var Eo = class {
10306
10321
  let t = this._convertExternalIdsToServerExternalIds(e.externalIds), n = await this._signaling.getParticipants(t);
10307
10322
  if (n.error) throw Error(n.error);
10308
10323
  let r = n.participants, i = this._transport?.getState();
10309
- return j.mapSharedParticipants(r.map((e) => {
10324
+ return Promise.all(r.map(async (e) => {
10310
10325
  let t = j.composeId(e);
10311
10326
  return this._createParticipant({
10312
10327
  id: t,
@@ -10322,13 +10337,13 @@ var Eo = class {
10322
10337
  observedIds: e.observedIds || [],
10323
10338
  markers: this._denormalizeMarkers(t, e.markers)
10324
10339
  }, e.decorativeUserId);
10325
- }));
10340
+ })).then(j.mapSharedParticipants);
10326
10341
  }
10327
10342
  async getParticipantListChunk(e) {
10328
10343
  this._debug.log("Request participant list chunk", e);
10329
10344
  let t = await this._signaling.getParticipantListChunk(e);
10330
10345
  if (t.error) throw Error(t.error);
10331
- let n = this._createParticipantListChunk(t.chunk), r = this._getParticipants(), i = n.participants.filter((e) => !r[j.composeId(e)]);
10346
+ let n = this._createParticipantListChunk(t.chunk), r = await this._getParticipants(), i = n.participants.filter((e) => !r[j.composeId(e)]);
10332
10347
  await this._registerParticipants(i);
10333
10348
  let a = this._transport?.getState();
10334
10349
  return n.participants.forEach((e) => {
@@ -10355,14 +10370,14 @@ var Eo = class {
10355
10370
  let n = e.track ? new MediaStream([e.track]) : null;
10356
10371
  L.onScreenStream(n, t, this.id);
10357
10372
  }
10358
- _changeRemoteMediaSettings(e, t) {
10373
+ async _changeRemoteMediaSettings(e, t) {
10359
10374
  this._debug.debug(`Remote media settings changed [${e}]`, t);
10360
10375
  let n = this._conversation?.externalId;
10361
10376
  if (this._isMe(e) && n) {
10362
10377
  L.onLocalMediaSettings(n, t, this.id);
10363
10378
  return;
10364
10379
  }
10365
- let r = this._getParticipant(e);
10380
+ let r = await this._getParticipant(e);
10366
10381
  if (!r) {
10367
10382
  this._warnParticipantNotInConversation(e);
10368
10383
  return;
@@ -10378,16 +10393,16 @@ var Eo = class {
10378
10393
  }
10379
10394
  async _changeRemoteParticipantState(e, t) {
10380
10395
  this._debug.debug(`Remote participant state changed [${e}]`, t);
10381
- let n = this._getParticipant(e);
10396
+ let n = await this._getParticipant(e);
10382
10397
  if (!n) {
10383
10398
  this._warnParticipantNotInConversation(e);
10384
10399
  return;
10385
10400
  }
10386
10401
  n.participantState = t || {}, ["ACTIVE", "HELD"].includes(this._state) && L.onRemoteParticipantState(n.externalId, n.participantState, n.markers, this.id);
10387
10402
  }
10388
- _changeMultipleParticipantState(e, t) {
10403
+ async _changeMultipleParticipantState(e, t) {
10389
10404
  this._debug.debug("Multiple participants state changed", e);
10390
- let n = [], r, i = this._getParticipants();
10405
+ let n = [], r, i = await this._getParticipants();
10391
10406
  e.forEach((e, t) => {
10392
10407
  if (this._isMe(t)) r = e;
10393
10408
  else {
@@ -10460,8 +10475,8 @@ var Eo = class {
10460
10475
  _onSignalingTopologyChanged(e) {
10461
10476
  this._conversation && e.topology !== this._conversation.topology && (this._debug.log(`Signaling topology changed while transport is down: ${this._conversation.topology} -> ${e.topology}`), this._conversation.topology = e.topology);
10462
10477
  }
10463
- _onPromotionApproved(e) {
10464
- let t = this._getExternalIdByParticipantId(e.adminId);
10478
+ async _onPromotionApproved(e) {
10479
+ let t = await this._getExternalIdByParticipantId(e.adminId);
10465
10480
  if (!t) {
10466
10481
  this._warnParticipantNotInConversation(e.adminId);
10467
10482
  return;
@@ -10470,10 +10485,10 @@ var Eo = class {
10470
10485
  }
10471
10486
  async _onSignalingReconnect(e) {
10472
10487
  if (!this._conversation) return;
10473
- e.conversationParams?.serverTime && (this._serverTimeOffset = e.conversationParams.serverTime - Date.now()), e.conversation.acceptTime && (this._conversation.acceptTime = e.conversation.acceptTime), e.conversation.participantsLimit && (this._conversation.participantsLimit = e.conversation.participantsLimit), e.conversation.features && (this._conversation.features = e.conversation.features, this._conversation.featuresPerRole = e.conversation.featuresPerRole, this._changeFeatureSet(), this._changeFeaturesPerRole()), this._processPinnedParticipants(e), e.conversation.state;
10488
+ e.conversationParams?.serverTime && (this._serverTimeOffset = e.conversationParams.serverTime - Date.now()), e.conversation.acceptTime && (this._conversation.acceptTime = e.conversation.acceptTime), e.conversation.participantsLimit && (this._conversation.participantsLimit = e.conversation.participantsLimit), e.conversation.features && (this._conversation.features = e.conversation.features, this._conversation.featuresPerRole = e.conversation.featuresPerRole, this._changeFeatureSet(), this._changeFeaturesPerRole()), await this._processPinnedParticipants(e), e.conversation.state;
10474
10489
  let t = null;
10475
10490
  if (e.conversation.participants) {
10476
- let n = Object.keys(this._getParticipants()), r = [];
10491
+ let n = Object.keys(await this._getParticipants()), r = [];
10477
10492
  for (let n of e.conversation.participants) {
10478
10493
  let e = j.composeId(n), i = n.roles || [];
10479
10494
  if (this._isMe(e)) {
@@ -10486,7 +10501,7 @@ var Eo = class {
10486
10501
  continue;
10487
10502
  }
10488
10503
  r.push(e);
10489
- let a = this._getParticipant(e);
10504
+ let a = await this._getParticipant(e);
10490
10505
  if (!a) await this._onJoinedParticipant({
10491
10506
  participantId: n.id,
10492
10507
  participant: n,
@@ -10495,12 +10510,12 @@ var Eo = class {
10495
10510
  else {
10496
10511
  this._updateParticipantSessionState(a, e, n.sessionState);
10497
10512
  let t = E(n.mediaSettings);
10498
- Ut(t, a.mediaSettings) || this._changeRemoteMediaSettings(e, t);
10513
+ Ut(t, a.mediaSettings) || await this._changeRemoteMediaSettings(e, t);
10499
10514
  let r = j.mapParticipantState(n), o = a.participantState;
10500
10515
  j.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), Ha(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? N.ONHOLD : N.CONNECTED));
10501
10516
  }
10502
10517
  }
10503
- let i = this._getParticipants();
10518
+ let i = await this._getParticipants();
10504
10519
  for (let e of n) r.indexOf(e) < 0 && i[e] && this._removeParticipant(i[e], D.HUNGUP);
10505
10520
  }
10506
10521
  let n = [...e.participants?.participants ?? [], ...e.rooms?.rooms.flatMap((e) => e.participants?.participants ?? []) ?? []];
@@ -10522,15 +10537,15 @@ var Eo = class {
10522
10537
  return;
10523
10538
  }
10524
10539
  this._conversation?.direction === Aa.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
10525
- let r = this._getParticipant(t);
10540
+ let r = await this._getParticipant(t);
10526
10541
  if (!r) {
10527
10542
  let n = this._api.getDecorativeIdByInitialId(t), i = n ? j.composeUserId(n, e.participantType) : void 0;
10528
- r = this._registerParticipantInCache(this._createParticipant({
10543
+ r = this._registerParticipantInCache(await this._createParticipant({
10529
10544
  id: t,
10530
10545
  mediaSettings: E(e.mediaSettings)
10531
10546
  }, i));
10532
10547
  }
10533
- r.state = X.ACCEPTED, r.mediaSettings = E(e.mediaSettings), this._logWithMediaSettings(S.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === Aa.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
10548
+ r.state = X.ACCEPTED, r.mediaSettings = E(e.mediaSettings), this._logWithMediaSettings(S.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === Aa.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), await this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
10534
10549
  let i = Object.keys(r.muteStates);
10535
10550
  i.length && this._onMuteParticipant({
10536
10551
  muteStates: r.muteStates,
@@ -10547,8 +10562,8 @@ var Eo = class {
10547
10562
  e.reason === D.OBSOLETE_CLIENT && e.errorCode && (t.message = e.errorCode), this._close(new O(e.reason, t));
10548
10563
  return;
10549
10564
  }
10550
- this._registerParticipantAndSetMarkersIfChunkEnabled(t, e.markers);
10551
- let n = this._getParticipant(t);
10565
+ await this._registerParticipantAndSetMarkersIfChunkEnabled(t, e.markers);
10566
+ let n = await this._getParticipant(t);
10552
10567
  if (!n) {
10553
10568
  this._warnParticipantNotInConversation(t);
10554
10569
  return;
@@ -10558,12 +10573,12 @@ var Eo = class {
10558
10573
  this._removeParticipant(n, t);
10559
10574
  }
10560
10575
  }
10561
- _onSessionState(e) {
10576
+ async _onSessionState(e) {
10562
10577
  if (!M.enableSessionStateUpdates) return;
10563
10578
  let t = j.composeMessageId(e);
10564
10579
  if (this._isMe(t)) return;
10565
- this._registerParticipantAndSetMarkersIfChunkEnabled(t, e.markers);
10566
- let n = this._getParticipant(t);
10580
+ await this._registerParticipantAndSetMarkersIfChunkEnabled(t, e.markers);
10581
+ let n = await this._getParticipant(t);
10567
10582
  if (!n) {
10568
10583
  this._warnParticipantNotInConversation(t);
10569
10584
  return;
@@ -10576,7 +10591,7 @@ var Eo = class {
10576
10591
  }
10577
10592
  async _reconcileParticipantSessionStates(e) {
10578
10593
  if (!M.enableSessionStateUpdates || !e.length) return;
10579
- let t = this._getParticipants();
10594
+ let t = await this._getParticipants();
10580
10595
  for (let n of e) {
10581
10596
  let e = j.composeId(n), r = t[e];
10582
10597
  r && !this._isMe(e) && (this._updateParticipantExternalId(r, n), this._updateParticipantSessionState(r, e, n.sessionState));
@@ -10594,7 +10609,7 @@ var Eo = class {
10594
10609
  }
10595
10610
  async _onAddedParticipant(e) {
10596
10611
  this._debug.debug(`Participant added [${e.participantId}]`);
10597
- let t = j.composeMessageId(e), n = this._getParticipant(t);
10612
+ let t = j.composeMessageId(e), n = await this._getParticipant(t);
10598
10613
  n && this._updateParticipantExternalId(n, e.participant);
10599
10614
  let r = !n;
10600
10615
  if (n && n.state !== X.HUNGUP && n.state !== X.REJECTED) {
@@ -10615,13 +10630,13 @@ var Eo = class {
10615
10630
  muteStates: r.muteStates || {},
10616
10631
  unmuteOptions: r.unmuteOptions || [],
10617
10632
  observedIds: r.observedIds || []
10618
- }, i), n = this._getParticipant(t);
10633
+ }, i), n = await this._getParticipant(t);
10619
10634
  }
10620
- n.state = X.CALLED, n.mediaSettings = E(e.participant?.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant?.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), this._setParticipantsStatus([n], N.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && this._allocateParticipantTransport(n.id, !0), L.onParticipantAdded(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
10635
+ n.state = X.CALLED, n.mediaSettings = E(e.participant?.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant?.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), this._setParticipantsStatus([n], N.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && this._allocateParticipantTransport(n.id, !0), L.onParticipantAdded(n.externalId, n.markers, this.id), await this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
10621
10636
  }
10622
10637
  async _onJoinedParticipant(e) {
10623
10638
  this._debug.debug(`Participant joined [${e.participantId}]`), this._statFirstMediaReceived.markOnJoin(this._transport?.getTopology());
10624
- let t = j.composeMessageId(e), n = this._getParticipant(t);
10639
+ let t = j.composeMessageId(e), n = await this._getParticipant(t);
10625
10640
  n && this._updateParticipantExternalId(n, e.participant);
10626
10641
  let r = !n;
10627
10642
  if (n && n.state === X.ACCEPTED) {
@@ -10644,36 +10659,36 @@ var Eo = class {
10644
10659
  connectionStatus: this._buildConnectionStatus(t, r.sessionState, this._transport?.getState(), r.onHold),
10645
10660
  markers: this._denormalizeMarkers(t, r.markers),
10646
10661
  isOnHold: !!r.onHold
10647
- }, i), n = this._getParticipant(t);
10662
+ }, i), n = await this._getParticipant(t);
10648
10663
  }
10649
- this._conversation && this._conversation.direction === Aa.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = X.ACCEPTED, n.mediaSettings = E(e.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], N.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], N.CONNECTED) : this._setParticipantsStatus([n], N.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._allocateParticipantTransport(n.id, !0), this._transport.open([n.id], null, !!this._conversation?.observer)), L.onParticipantJoined(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
10664
+ this._conversation && this._conversation.direction === Aa.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = X.ACCEPTED, n.mediaSettings = E(e.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], N.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], N.CONNECTED) : this._setParticipantsStatus([n], N.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._allocateParticipantTransport(n.id, !0), this._transport.open([n.id], null, !!this._conversation?.observer)), L.onParticipantJoined(n.externalId, n.markers, this.id), await this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
10650
10665
  let i = Object.keys(n.muteStates);
10651
10666
  i.length && this._onMuteParticipant({
10652
10667
  muteStates: n.muteStates,
10653
10668
  mediaOptions: i,
10654
10669
  stateUpdated: !0,
10655
10670
  participantId: t
10656
- }), this._processSharedMovieInfos(n.movieShareInfos);
10671
+ }), await this._processSharedMovieInfos(n.movieShareInfos);
10657
10672
  }
10658
10673
  _onClosedConversation(e) {
10659
10674
  this._toggleJoinAvailability(), this._close(new O(e.reason, { remote: !0 }));
10660
10675
  }
10661
- _onMediaSettingsChanged(e) {
10676
+ async _onMediaSettingsChanged(e) {
10662
10677
  let t = j.composeMessageId(e);
10663
- this._registerParticipantAndSetMarkersIfChunkEnabled(t, e.markers), this._changeRemoteMediaSettings(t, E(e.mediaSettings));
10678
+ await this._registerParticipantAndSetMarkersIfChunkEnabled(t, e.markers), await this._changeRemoteMediaSettings(t, E(e.mediaSettings));
10664
10679
  }
10665
10680
  async _onParticipantStateChanged(e) {
10666
10681
  let t = j.composeMessageId(e), n = j.mapParticipantState(e);
10667
- this._isMe(t) ? this._changeLocalParticipantState(n) : (this._registerParticipantAndSetMarkersIfChunkEnabled(t, e.markers), await this._changeRemoteParticipantState(t, n));
10682
+ this._isMe(t) ? this._changeLocalParticipantState(n) : (await this._registerParticipantAndSetMarkersIfChunkEnabled(t, e.markers), await this._changeRemoteParticipantState(t, n));
10668
10683
  }
10669
- _onParticipantsStateChanged(e) {
10670
- let { participants: t, roomId: n } = e;
10671
- t.map(({ id: e, markers: t }) => this._registerParticipantAndSetMarkersIfChunkEnabled(e, t));
10672
- let r = /* @__PURE__ */ new Map(), i = t.map(({ id: e, participantState: t }) => [e, this._getExternalIdByParticipantId(e) && j.mapParticipantState({ participantState: t })]);
10684
+ async _onParticipantsStateChanged(e) {
10685
+ let { participants: t, roomId: n } = e, r = t.map(({ id: e, markers: t }) => this._registerParticipantAndSetMarkersIfChunkEnabled(e, t));
10686
+ await Promise.all(r);
10687
+ let i = /* @__PURE__ */ new Map(), a = t.map(({ id: e, participantState: t }) => this._getExternalIdByParticipantId(e).then((n) => [e, n && j.mapParticipantState({ participantState: t })]));
10673
10688
  try {
10674
- i.forEach(([e, t]) => {
10675
- t && r.set(e, t);
10676
- }), this._changeMultipleParticipantState(r, n);
10689
+ (await Promise.all(a)).forEach(([e, t]) => {
10690
+ t && i.set(e, t);
10691
+ }), await this._changeMultipleParticipantState(i, n);
10677
10692
  } catch (e) {
10678
10693
  this._debug.warn(`_onParticipantsStateChanged: Failed to get external ids. ${e}`);
10679
10694
  }
@@ -10723,84 +10738,84 @@ var Eo = class {
10723
10738
  }
10724
10739
  async _onPeerRegistered(e) {
10725
10740
  this._registeredPeerReceived = !0, this._clearCalleeUnavailableWatchdog();
10726
- let t = j.composeMessageId(e), n = this._getParticipant(t);
10741
+ let t = j.composeMessageId(e), n = await this._getParticipant(t);
10727
10742
  n && (n.clientType = e.clientType, n.platform = e.platform), L.onPeerRegistered(this.id);
10728
10743
  }
10729
10744
  async _onMicSwitched(e) {
10730
10745
  L.onDeviceSwitched(x.AUDIO, !e.mute, this.id), await this.toggleLocalAudio(!e.mute);
10731
10746
  }
10732
- _onChatMessage(e) {
10733
- let t = j.composeMessageId(e), n = this._getExternalIdByParticipantId(t);
10747
+ async _onChatMessage(e) {
10748
+ let t = j.composeMessageId(e), n = await this._getExternalIdByParticipantId(t);
10734
10749
  if (!n) {
10735
10750
  this._warnParticipantNotInConversation(t);
10736
10751
  return;
10737
10752
  }
10738
10753
  L.onChatMessage(e.message, n, e.direct, this.id);
10739
10754
  }
10740
- _onCustomData(e) {
10755
+ async _onCustomData(e) {
10741
10756
  if (Object.hasOwn(e.data, "sdk")) return;
10742
- let t = j.composeMessageId(e), n = this._getExternalIdByParticipantId(t);
10757
+ let t = j.composeMessageId(e), n = await this._getExternalIdByParticipantId(t);
10743
10758
  if (!n) {
10744
10759
  this._warnParticipantNotInConversation(t);
10745
10760
  return;
10746
10761
  }
10747
10762
  L.onCustomData(e.data, n, e.direct, this.id);
10748
10763
  }
10749
- _onRecordInfo(e, t = null) {
10764
+ async _onRecordInfo(e, t = null) {
10750
10765
  if (!this._conversation || !e) return;
10751
10766
  let n = this._conversation.recordsInfoByRoom.get(t);
10752
10767
  if (n?.recordMovieId !== e?.recordMovieId || n?.recordStartTime !== e?.recordStartTime) {
10753
10768
  this._conversation.recordsInfoByRoom.set(t, e);
10754
- let n = this._getExternalIdByParticipantId(e.initiator);
10769
+ let n = await this._getExternalIdByParticipantId(e.initiator);
10755
10770
  n ? L.onRecordStarted(n, e.recordMovieId, e.recordStartTime, e.recordType, e.recordExternalMovieId, e.recordExternalOwnerId, t, this.id) : this._warnParticipantNotInConversation(e.initiator);
10756
10771
  }
10757
10772
  }
10758
- _onStopRecordInfo({ participant: e, recordMovieId: t }, n = null) {
10773
+ async _onStopRecordInfo({ participant: e, recordMovieId: t }, n = null) {
10759
10774
  if (!this._conversation) return;
10760
10775
  let r = this._conversation.recordsInfoByRoom.get(n);
10761
10776
  if (!(!r || r.recordMovieId !== t)) if (this._conversation.recordsInfoByRoom.set(n, null), e) {
10762
- let t = this._getExternalIdByParticipantId(e);
10777
+ let t = await this._getExternalIdByParticipantId(e);
10763
10778
  L.onRecordStopped(n, t ?? null, this.id);
10764
10779
  } else L.onRecordStopped(n, null, this.id);
10765
10780
  }
10766
- _changePinnedParticipantForRoom() {
10781
+ async _changePinnedParticipantForRoom() {
10767
10782
  if (!this._conversation) return;
10768
10783
  let e = this._conversation.roomId, t = this._conversation.pinnedParticipantIdByRoom.get(e);
10769
10784
  if (t && !this._isMe(t)) {
10770
- let n = this._getExternalIdByParticipantId(t);
10785
+ let n = await this._getExternalIdByParticipantId(t);
10771
10786
  n && L.onPinnedParticipant(n, !1, null, e, this.id);
10772
10787
  }
10773
10788
  }
10774
- _changeRecordInfoForRoom() {
10789
+ async _changeRecordInfoForRoom() {
10775
10790
  if (!this._conversation) return;
10776
10791
  let e = this._conversation.roomId, t = this._conversation.recordsInfoByRoom.get(e);
10777
10792
  if (t) {
10778
- let n = this._getExternalIdByParticipantId(t.initiator);
10793
+ let n = await this._getExternalIdByParticipantId(t.initiator);
10779
10794
  n ? L.onRecordStarted(n, t.recordMovieId, t.recordStartTime, t.recordType, t.recordExternalMovieId, t.recordExternalOwnerId, e, this.id) : this._warnParticipantNotInConversation(t.initiator);
10780
10795
  } else L.onRecordStopped(e, null, this.id);
10781
10796
  }
10782
- _changeAsrInfoForRoom() {
10797
+ async _changeAsrInfoForRoom() {
10783
10798
  if (!this._conversation) return;
10784
10799
  let e = this._conversation.roomId, t = this._conversation.asrInfoByRoom.get(e);
10785
10800
  if (t) {
10786
- let n = this._getExternalIdByParticipantId(t.initiatorId);
10801
+ let n = await this._getExternalIdByParticipantId(t.initiatorId);
10787
10802
  n && L.onAsrSet({
10788
10803
  externalId: n,
10789
10804
  movieId: t.movieId
10790
10805
  }, e, this.id);
10791
10806
  } else L.onAsrSet(null, e, this.id);
10792
10807
  }
10793
- _changeUrlSharingInfoForRoom() {
10808
+ async _changeUrlSharingInfoForRoom() {
10794
10809
  if (!this._conversation) return;
10795
10810
  let { roomId: e } = this._conversation, { urlSharingInfoByRoom: t } = this._conversation, n = t.get(e);
10796
10811
  if (n) {
10797
- let t = this._getExternalIdByParticipantId(n.initiatorId);
10812
+ let t = await this._getExternalIdByParticipantId(n.initiatorId);
10798
10813
  t && L.onRemoteSharedUrl(t, n.sharedUrl, e, this.id);
10799
10814
  }
10800
10815
  }
10801
- _onParticipantAnimojiChanged(e) {
10816
+ async _onParticipantAnimojiChanged(e) {
10802
10817
  if (this._conversation) {
10803
- let t = this._getExternalIdByParticipantId(e.participantId);
10818
+ let t = await this._getExternalIdByParticipantId(e.participantId);
10804
10819
  if (!t) {
10805
10820
  this._warnParticipantNotInConversation(e.participantId);
10806
10821
  return;
@@ -10808,11 +10823,11 @@ var Eo = class {
10808
10823
  L.onParticipantVmojiUpdate(t, this.id);
10809
10824
  }
10810
10825
  }
10811
- _onAsrStart(e) {
10826
+ async _onAsrStart(e) {
10812
10827
  if (!this._conversation) return;
10813
10828
  let t = e.asrInfo, n = e.roomId || null;
10814
10829
  this._conversation.asrInfoByRoom.set(n, t);
10815
- let r = this._getExternalIdByParticipantId(t.initiatorId);
10830
+ let r = await this._getExternalIdByParticipantId(t.initiatorId);
10816
10831
  if (!r) {
10817
10832
  this._warnParticipantNotInConversation(t.initiatorId);
10818
10833
  return;
@@ -10824,9 +10839,9 @@ var Eo = class {
10824
10839
  let t = e.roomId || null;
10825
10840
  t === null && (this._conversation.asrInfo = null), this._conversation.asrInfoByRoom.delete(t), L.onAsrStopped(t, this.id);
10826
10841
  }
10827
- _onAsrTranscription(e) {
10842
+ async _onAsrTranscription(e) {
10828
10843
  if (!this._conversation) return;
10829
- let t = this._getExternalIdByParticipantId(e.participantId);
10844
+ let t = await this._getExternalIdByParticipantId(e.participantId);
10830
10845
  if (!t) {
10831
10846
  this._warnParticipantNotInConversation(e.participantId);
10832
10847
  return;
@@ -10841,7 +10856,7 @@ var Eo = class {
10841
10856
  }), j.includesOneOf(t, [Va.ADMIN, Va.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
10842
10857
  return;
10843
10858
  }
10844
- let n = this._getParticipant(e);
10859
+ let n = await this._getParticipant(e);
10845
10860
  n && !Ha(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, L.onRolesChanged(n.externalId, t, !1, this.id));
10846
10861
  }
10847
10862
  async _onMuteParticipant(e, t = !1) {
@@ -10852,10 +10867,10 @@ var Eo = class {
10852
10867
  this._debug.warn(`Not admin got mute states for participant [${e.participantId}]`);
10853
10868
  return;
10854
10869
  }
10855
- let t = this._getParticipant(e.participantId);
10870
+ let t = await this._getParticipant(e.participantId);
10856
10871
  if (t) {
10857
10872
  this._debug.debug(`Mute states for participant [${e.participantId}] changed`, r);
10858
- let o = e.adminId ? this._getExternalIdByParticipantId(e.adminId) : null;
10873
+ let o = e.adminId ? await this._getExternalIdByParticipantId(e.adminId) : null;
10859
10874
  L.onMuteStates(r, i, a, n, e.unmute, t.externalId, o, e.stateUpdated, e.requestedMedia, e.roomId, this.id);
10860
10875
  }
10861
10876
  return;
@@ -10888,7 +10903,7 @@ var Eo = class {
10888
10903
  }
10889
10904
  async _processMuteState(e) {
10890
10905
  if (!this._conversation || !this._mediaSource || this._participantState !== X.ACCEPTED) return;
10891
- let { mediaOptions: t = [], muteAll: n, unmute: r, stateUpdated: i, requestedMedia: a, roomId: o = null, unmuteOptions: s = [] } = e, c = e.adminId ? this._getExternalIdByParticipantId(e.adminId) : null, l = Object.assign({}, e.muteStates ?? this._getMuteStatesForRoomId(o)), u = this._mediaSource.mediaSettings, d = Object.entries(l);
10906
+ let { mediaOptions: t = [], muteAll: n, unmute: r, stateUpdated: i, requestedMedia: a, roomId: o = null, unmuteOptions: s = [] } = e, c = e.adminId ? await this._getExternalIdByParticipantId(e.adminId) : null, l = Object.assign({}, e.muteStates ?? this._getMuteStatesForRoomId(o)), u = this._mediaSource.mediaSettings, d = Object.entries(l);
10892
10907
  for (let [e, i] of d) {
10893
10908
  let a = this._isCallAdmin() && n;
10894
10909
  if (!(i !== La.MUTE && i !== La.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === La.MUTE_PERMANENT && !n && (l[e] = La.MUTE), !(!t.includes(e) || r))) switch (e) {
@@ -10912,17 +10927,17 @@ var Eo = class {
10912
10927
  }
10913
10928
  L.onMuteStates(l, s, t, n, r, null, c, i, a, o, this.id);
10914
10929
  }
10915
- _onPinParticipant(e, t = !1, n, r = null) {
10930
+ async _onPinParticipant(e, t = !1, n, r = null) {
10916
10931
  if (!this._conversation) return;
10917
10932
  let i = this._conversation.pinnedParticipantIdByRoom.get(r);
10918
10933
  if (i && i !== e) if (this._isMe(i)) L.onLocalPin(!0, r, this.id);
10919
10934
  else {
10920
- let t = this._getExternalIdByParticipantId(i);
10935
+ let t = await this._getExternalIdByParticipantId(i);
10921
10936
  t && L.onPinnedParticipant(t, !0, this._denormalizeMarkers(e, n), r, this.id);
10922
10937
  }
10923
10938
  if (this._isMe(e)) L.onLocalPin(t, r, this.id);
10924
10939
  else {
10925
- let i = this._getExternalIdByParticipantId(e);
10940
+ let i = await this._getExternalIdByParticipantId(e);
10926
10941
  i && L.onPinnedParticipant(i, t, this._denormalizeMarkers(e, n), r, this.id);
10927
10942
  }
10928
10943
  this._conversation.pinnedParticipantIdByRoom.set(r, t ? null : e);
@@ -10932,7 +10947,7 @@ var Eo = class {
10932
10947
  }
10933
10948
  async _onNetworkStatus(e) {
10934
10949
  if (this._conversation) {
10935
- let t = [], n = this._getParticipants();
10950
+ let t = [], n = await this._getParticipants();
10936
10951
  for (let [r, i] of Object.entries(e)) {
10937
10952
  let e;
10938
10953
  if (this._isMe(r) || r === "") e = this._conversation.networkRating;
@@ -10952,11 +10967,11 @@ var Eo = class {
10952
10967
  }
10953
10968
  }
10954
10969
  async _emitHeldParticipantsStatus() {
10955
- let e = Object.values(this._getParticipants()).filter((e) => e.isOnHold).map((e) => e.externalId);
10970
+ let e = Object.values(await this._getParticipants()).filter((e) => e.isOnHold).map((e) => e.externalId);
10956
10971
  e.length && L.onRemoteStatus(e, N.ONHOLD, null, this.id);
10957
10972
  }
10958
10973
  async _onRemoteStreamSecond(e, t) {
10959
- let n = this._getParticipant(e);
10974
+ let n = await this._getParticipant(e);
10960
10975
  n && L.onRemoteScreenStream(n.externalId, t, this.id);
10961
10976
  }
10962
10977
  async _onAnimojiStream(e, t) {
@@ -10964,12 +10979,12 @@ var Eo = class {
10964
10979
  L.onVmojiStream(t, this._mediaSource.mediaSettings, this.id);
10965
10980
  return;
10966
10981
  }
10967
- let n = this._getParticipant(e);
10982
+ let n = await this._getParticipant(e);
10968
10983
  n && L.onRemoteVmojiStream(n.externalId, t, this.id);
10969
10984
  }
10970
- _onAnimojiError(e) {
10985
+ async _onAnimojiError(e) {
10971
10986
  try {
10972
- let t = this._getExternalIdByParticipantId(e.participantId);
10987
+ let t = await this._getExternalIdByParticipantId(e.participantId);
10973
10988
  t && (delete e.participantId, L.onVmojiError({
10974
10989
  ...e,
10975
10990
  externalId: t
@@ -10996,7 +11011,7 @@ var Eo = class {
10996
11011
  async _onVolumesDetected(e) {
10997
11012
  let t = [];
10998
11013
  for (let [n, r] of Object.entries(e)) {
10999
- let e = this._getParticipant(n);
11014
+ let e = await this._getParticipant(n);
11000
11015
  e && e.externalId && t.push({
11001
11016
  uid: e.externalId,
11002
11017
  volume: r.real
@@ -11007,14 +11022,14 @@ var Eo = class {
11007
11022
  async _onSpeakerChanged(e) {
11008
11023
  let t = this._activeSpeakerId;
11009
11024
  if (this._activeSpeakerId = e, t && t !== e) {
11010
- let e = this._getParticipant(t);
11025
+ let e = await this._getParticipant(t);
11011
11026
  if (e?.connectionStatus.sessionStateConnectedBySpeaker) {
11012
11027
  e.connectionStatus.sessionStateConnectedBySpeaker = !1;
11013
11028
  let t = this._setTransportStatus(e, e.connectionStatus.transport);
11014
11029
  this._emitParticipantTransition(e, t);
11015
11030
  }
11016
11031
  }
11017
- let n = this._getParticipant(e);
11032
+ let n = await this._getParticipant(e);
11018
11033
  if (n) {
11019
11034
  if (n.connectionStatus.sessionStateApplicable && n.connectionStatus.sessionState?.connected === !1) {
11020
11035
  let e = Wa.fromTransportState(this._transport?.getState());
@@ -11029,7 +11044,7 @@ var Eo = class {
11029
11044
  this._debug.debug(`Transport state has changed: ${t}`, e);
11030
11045
  let n = Wa.fromTransportState(t);
11031
11046
  if (!n) return;
11032
- let r = this._getParticipants(), i = [], a = e.reduce((e, n) => {
11047
+ let r = await this._getParticipants(), i = [], a = e.reduce((e, n) => {
11033
11048
  if (n in r) {
11034
11049
  let a = r[n];
11035
11050
  e.push(a), t === q.CONNECTED && (a.remoteStream || (a.mediaSettings && this._changeRemoteMediaSettings(n, a.mediaSettings), this._changeRemoteParticipantState(n, a.participantState)), i.push(...Object.values(a.lastRequestedLayouts)));
@@ -11043,25 +11058,25 @@ var Eo = class {
11043
11058
  let e = Object.values(this._myLastRequestedLayouts);
11044
11059
  await this.updateDisplayLayout(e), this._displayLayoutRequester.resend();
11045
11060
  }
11046
- this._state !== "HELD" && ((e === q.CONNECTING || e === q.RECONNECTING) && this._areTransportParticipantsOnHold() || (e === q.CONNECTING && L.onLocalStatus(N.CONNECTING, this.id), e === q.RECONNECTING && L.onLocalStatus(N.RECONNECT, this.id), e === q.FAILED && this._transport && this._transport.allocated().length === 0 && (this._signaling.ready && await this._signaling.hangup(D.FAILED), this._close(new O(D.FAILED), "Transport failed"))));
11061
+ this._state !== "HELD" && ((e === q.CONNECTING || e === q.RECONNECTING) && await this._areTransportParticipantsOnHold() || (e === q.CONNECTING && L.onLocalStatus(N.CONNECTING, this.id), e === q.RECONNECTING && L.onLocalStatus(N.RECONNECT, this.id), e === q.FAILED && this._transport && this._transport.allocated().length === 0 && (this._signaling.ready && await this._signaling.hangup(D.FAILED), this._close(new O(D.FAILED), "Transport failed"))));
11047
11062
  }
11048
- _areTransportParticipantsOnHold() {
11063
+ async _areTransportParticipantsOnHold() {
11049
11064
  if (!M.hold || !this._transport) return !1;
11050
11065
  let e = this._transport.opened().length ? this._transport.opened() : this._transport.allocated();
11051
11066
  if (!e.length) return !1;
11052
- let t = this._getParticipants();
11067
+ let t = await this._getParticipants();
11053
11068
  return e.every((e) => t[e]?.isOnHold);
11054
11069
  }
11055
- _onRemoteTrackAdded(e, t, n) {
11070
+ async _onRemoteTrackAdded(e, t, n) {
11056
11071
  if (e.endsWith(Br.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), L.onRemoteMixedAudioStream(t, this.id);
11057
11072
  else if (e.startsWith(Br.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
11058
11073
  else if (e.startsWith(Br.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
11059
11074
  else {
11060
11075
  this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
11061
- let r = this._getParticipant(e);
11076
+ let r = await this._getParticipant(e);
11062
11077
  if (!r) {
11063
11078
  let t = this._api.getDecorativeIdByInitialId(e), n = t ? j.composeUserId(t) : void 0;
11064
- this._debug.warn(`Conversation: track added before participant [id: ${e}, decorativeId: ${n}]`), this._registerParticipant({ id: e }, n), r = this._getParticipant(e), this._setParticipantsStatus([r], N.WAITING), this._activeSpeakerId === e && this._lastSignalledActiveSpeakerId !== e && (L.onSpeakerChanged(r.externalId, this.id), this._lastSignalledActiveSpeakerId = e);
11079
+ this._debug.warn(`Conversation: track added before participant [id: ${e}, decorativeId: ${n}]`), this._registerParticipant({ id: e }, n), r = await this._getParticipant(e), this._setParticipantsStatus([r], N.WAITING), this._activeSpeakerId === e && this._lastSignalledActiveSpeakerId !== e && (L.onSpeakerChanged(r.externalId, this.id), this._lastSignalledActiveSpeakerId = e);
11065
11080
  }
11066
11081
  if (this._transport && !this._transport.isAllocated(r.id) && this._allocateParticipantTransport(r.id, !1), n.kind === k.audio && (this._audioOutput.add(e, n), M.preserveAudioTracks || (r.remoteAudioTrack = n, t.removeTrack(n))), r.remoteStream !== t && t.getTracks().length) {
11067
11082
  if (r.remoteStream = t, r.secondStream) return;
@@ -11083,7 +11098,7 @@ var Eo = class {
11083
11098
  }
11084
11099
  async _removeAudioTrack(e, t, n) {
11085
11100
  if (e !== Br.AUDIO_MIX) {
11086
- let n = this._getParticipant(e);
11101
+ let n = await this._getParticipant(e);
11087
11102
  if (!n || n.remoteStream && n.remoteStream !== t) return;
11088
11103
  }
11089
11104
  this._audioOutput.remove(e, n);
@@ -11107,10 +11122,10 @@ var Eo = class {
11107
11122
  _onAudioMixStall(e) {
11108
11123
  this._audioMixStalled !== e && !this.isCallHeld && (this._audioMixStalled = e, this._debug.debug("Audio mix stalled:", e), L.onLocalStatus(e ? N.RECONNECT : N.CONNECTED, this.id));
11109
11124
  }
11110
- _onRemoteSignalledStall(e) {
11125
+ async _onRemoteSignalledStall(e) {
11111
11126
  let t = {}, n = [], r = [];
11112
11127
  this._debug.debug("Participants stalled:", e);
11113
- let i = this._getParticipants();
11128
+ let i = await this._getParticipants();
11114
11129
  for (let r of e) {
11115
11130
  if (t[r] = !0, !this._lastStalled[r]) {
11116
11131
  let e = i[r];
@@ -11124,8 +11139,8 @@ var Eo = class {
11124
11139
  }
11125
11140
  n.length && this._setParticipantsStatus(n, N.RECONNECT), r.length && this._setParticipantsStatus(r, N.CONNECTED), this._lastStalled = t;
11126
11141
  }
11127
- _onRemoteDataStats(e) {
11128
- this._debugInfo && this._debugInfo.onRemoteDataStats(e, this._getParticipants()), this._fixAudioDevice(e.outbound.rtps), this._fixVideoDevice(e.outbound.rtps);
11142
+ async _onRemoteDataStats(e) {
11143
+ this._debugInfo && this._debugInfo.onRemoteDataStats(e, await this._getParticipants()), this._fixAudioDevice(e.outbound.rtps), this._fixVideoDevice(e.outbound.rtps);
11129
11144
  }
11130
11145
  _fixAudioDevice(e) {
11131
11146
  !T.hasMicrophone() || !this._audioFix || !this.mediaSettings?.isAudioEnabled || this._audioFix.fix(e);
@@ -11164,26 +11179,26 @@ var Eo = class {
11164
11179
  _onJoinLinkChanged(e) {
11165
11180
  this._conversation && e.joinLink && (this._conversation.joinLink = e.joinLink), L.onJoinLinkChanged(e.joinLink, this.id);
11166
11181
  }
11167
- _onRoomsUpdated(e) {
11182
+ async _onRoomsUpdated(e) {
11168
11183
  if (this._isCalledState()) return;
11169
11184
  let t = {};
11170
11185
  for (let n of Object.keys(Ra)) {
11171
11186
  let r = e.updates[n];
11172
11187
  r && (t[n] = {
11173
- rooms: r?.rooms?.map(this._convertRoomToExternal.bind(this)) || [],
11188
+ rooms: await Promise.all(r?.rooms?.map(this._convertRoomToExternal.bind(this)) || []),
11174
11189
  roomIds: r?.roomIds,
11175
11190
  deactivated: r?.deactivated
11176
11191
  });
11177
11192
  }
11178
11193
  L.onRoomsUpdated(t, this.id);
11179
11194
  }
11180
- _onRoomUpdated(e) {
11181
- let t = this._convertRoomToExternal(e.room || null);
11195
+ async _onRoomUpdated(e) {
11196
+ let t = await this._convertRoomToExternal(e.room || null);
11182
11197
  e.events.some((e) => e === Ra.UPDATE) && (e.muteStates !== void 0 && this._setMuteStatesForRoomId(e.muteStates, e.roomId), e.recordInfo !== void 0 && this._conversation?.recordsInfoByRoom.set(e.roomId, e.recordInfo), e.asrInfo !== void 0 && this._conversation?.asrInfoByRoom.set(e.roomId, e.asrInfo)), this._isCalledState() || L.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id);
11183
11198
  }
11184
- _convertRoomToExternal(e) {
11199
+ async _convertRoomToExternal(e) {
11185
11200
  if (!e) return null;
11186
- let t = e.participantIds?.map((e) => this._getExternalIdByParticipantId(e)) || [], n = e.addParticipantIds?.map((e) => this._getExternalIdByParticipantId(e)) || [], r = e.removeParticipantIds?.map?.((e) => this._getExternalIdByParticipantId(e)) || [], i = e.pinnedParticipantId ? this._getExternalIdByParticipantId(e.pinnedParticipantId) : void 0;
11201
+ let t = await Promise.all(e.participantIds?.map((e) => this._getExternalIdByParticipantId(e)) || []), n = await Promise.all(e.addParticipantIds?.map((e) => this._getExternalIdByParticipantId(e)) || []), r = await Promise.all(e.removeParticipantIds?.map?.((e) => this._getExternalIdByParticipantId(e)) || []), i = e.pinnedParticipantId ? await this._getExternalIdByParticipantId(e.pinnedParticipantId) : void 0;
11187
11202
  return {
11188
11203
  id: e.id,
11189
11204
  name: e.name,
@@ -11191,7 +11206,7 @@ var Eo = class {
11191
11206
  participantIds: t,
11192
11207
  addParticipantIds: n,
11193
11208
  removeParticipantIds: r,
11194
- participants: e.participants?.participants ? this._participantListChunkToExternalChunk(e.participants) : void 0,
11209
+ participants: e.participants?.participants ? await this._participantListChunkToExternalChunk(e.participants) : void 0,
11195
11210
  active: e.active,
11196
11211
  muteStates: e.muteStates,
11197
11212
  pinnedParticipantId: i,
@@ -11205,7 +11220,7 @@ var Eo = class {
11205
11220
  let e = this._convertExternalIdsToServerExternalIds(i);
11206
11221
  a = (await this._signaling.getParticipants(e)).participants;
11207
11222
  }
11208
- let o = a?.map((e) => {
11223
+ let o = await Promise.all(a?.map(async (e) => {
11209
11224
  let r = j.composeId(e);
11210
11225
  return this._createParticipant({
11211
11226
  id: r,
@@ -11222,20 +11237,21 @@ var Eo = class {
11222
11237
  markers: this._denormalizeMarkers(r, e.markers),
11223
11238
  isInRoom: n !== null
11224
11239
  }, e.decorativeUserId);
11225
- }) || [], s = !1;
11240
+ }) || []), s = !1;
11226
11241
  for (let e of o) e.id === this._conversation?.compositeUserId && (s = !0), this._registerParticipantInCache(e);
11227
11242
  this._transport?.getState() === q.IDLE && !this._isCalledState() && this._openTransport(o, !0);
11228
- let c = [];
11243
+ let c = [], l = [];
11229
11244
  if (e?.removedParticipantMarkers) {
11230
11245
  for (let t of e.removedParticipantMarkers) if (t.GRID?.id) {
11231
11246
  let e = this._getExternalIdByParticipantId(t.GRID.id);
11232
- c.push(e);
11247
+ l.push(e);
11233
11248
  }
11249
+ c = await Promise.all(l);
11234
11250
  }
11235
11251
  if (s && await this._onRoomSwitched(n), c) {
11236
11252
  let e = this._conversation?.pinnedParticipantIdByRoom.get(n);
11237
11253
  if (e) {
11238
- let t = this._getExternalIdByParticipantId(e);
11254
+ let t = await this._getExternalIdByParticipantId(e);
11239
11255
  if (t) {
11240
11256
  for (let e of c) if (Z.compare(t, e)) {
11241
11257
  this._conversation?.pinnedParticipantIdByRoom.delete(n);
@@ -11244,7 +11260,7 @@ var Eo = class {
11244
11260
  }
11245
11261
  }
11246
11262
  }
11247
- let l = {
11263
+ let u = {
11248
11264
  roomId: n,
11249
11265
  participantCount: e.participantCount,
11250
11266
  addedParticipantIds: i,
@@ -11252,7 +11268,7 @@ var Eo = class {
11252
11268
  removedParticipantMarkers: e?.removedParticipantMarkers,
11253
11269
  removedParticipantIds: c
11254
11270
  };
11255
- this._isCalledState() || L.onRoomParticipantsUpdated(l, this.id);
11271
+ this._isCalledState() || L.onRoomParticipantsUpdated(u, this.id);
11256
11272
  }
11257
11273
  async _onRoomSwitched(e, t = !1) {
11258
11274
  if (!this._conversation || this._conversation.roomId === e) return;
@@ -11261,7 +11277,7 @@ var Eo = class {
11261
11277
  L.onRoomStart(e, this.id);
11262
11278
  return;
11263
11279
  }
11264
- this._isCalledState() || L.onRoomSwitched(e, this.id), e !== null && !this._isCallAdmin() && await this._refreshRooms(!1), this._changePinnedParticipantForRoom(), this._changeRecordInfoForRoom(), this._changeMuteStatesForRoom(e, n), this._changeAsrInfoForRoom(), this._changeUrlSharingInfoForRoom();
11280
+ this._isCalledState() || L.onRoomSwitched(e, this.id), e !== null && !this._isCallAdmin() && await this._refreshRooms(!1), this._changePinnedParticipantForRoom(), this._changeRecordInfoForRoom(), this._changeMuteStatesForRoom(e, n), await this._changeAsrInfoForRoom(), await this._changeUrlSharingInfoForRoom();
11265
11281
  }
11266
11282
  async _refreshRooms(e) {
11267
11283
  let t;
@@ -11270,15 +11286,15 @@ var Eo = class {
11270
11286
  for (let t of n) {
11271
11287
  let n = t.id ?? null;
11272
11288
  if (this._setMuteStatesForRoomId(t.muteStates, n), this._conversation?.recordsInfoByRoom.set(n, t.recordInfo ?? null), this._conversation?.pinnedParticipantIdByRoom.set(n, t.pinnedParticipantId ?? null), t.asrInfo && this._conversation?.asrInfoByRoom.set(n, t.asrInfo), t.urlSharingInfo ? this._conversation?.urlSharingInfoByRoom.set(n, t.urlSharingInfo) : this._conversation?.urlSharingInfoByRoom.delete(n), e) {
11273
- let e = this._getParticipants();
11289
+ let e = await this._getParticipants();
11274
11290
  await this._registerParticipants(t?.participants?.participants?.filter((t) => !e[j.composeId(t)]) || [], !0);
11275
- let n = this._convertRoomToExternal(t);
11291
+ let n = await this._convertRoomToExternal(t);
11276
11292
  n && r.push(n);
11277
11293
  }
11278
11294
  }
11279
11295
  r.length && !this._isCalledState() && L.onRoomsUpdated({ [Ra.UPDATE]: { rooms: r } }, this.id);
11280
11296
  }
11281
- _onFeedback(e) {
11297
+ async _onFeedback(e) {
11282
11298
  let t = [];
11283
11299
  for (let n of e.feedback) {
11284
11300
  let e = {
@@ -11286,7 +11302,7 @@ var Eo = class {
11286
11302
  items: []
11287
11303
  };
11288
11304
  for (let t of n.items) {
11289
- let n = this._getExternalIdByParticipantId(t.participantId);
11305
+ let n = await this._getExternalIdByParticipantId(t.participantId);
11290
11306
  n ? e.items.push({
11291
11307
  ...t,
11292
11308
  participantId: n
@@ -11296,11 +11312,11 @@ var Eo = class {
11296
11312
  }
11297
11313
  L.onFeedback(t, e.roomId, this.id);
11298
11314
  }
11299
- _onDecorativeParticipantIdChanged(e) {
11315
+ async _onDecorativeParticipantIdChanged(e) {
11300
11316
  if (!this._conversation || !e.decorativeParticipantId || !e.decorativeExternalParticipantId) return;
11301
11317
  let { participantId: t, decorativeParticipantId: n, decorativeExternalParticipantId: r } = e, i = this._isMe(t);
11302
11318
  this._debug.debug(`Decorative participant id changed [${t}]`, e);
11303
- let a = this._getExternalIdByParticipantId(t);
11319
+ let a = await this._getExternalIdByParticipantId(t);
11304
11320
  if (!a) {
11305
11321
  this._warnParticipantNotInConversation(t);
11306
11322
  return;
@@ -11308,7 +11324,7 @@ var Eo = class {
11308
11324
  let o = Z.fromSignaling(r, a.deviceIdx);
11309
11325
  if (L.onParticipantIdChanged(a, o, this.id), this._api.cacheExternalId(n, o), this._api.mapDecorativeId(n, t), i) this._conversation.externalId = o;
11310
11326
  else {
11311
- let e = this._getParticipants();
11327
+ let e = await this._getParticipants();
11312
11328
  e[t].externalId = o;
11313
11329
  }
11314
11330
  }
@@ -11317,7 +11333,7 @@ var Eo = class {
11317
11333
  }
11318
11334
  async _onParticipantHold(e) {
11319
11335
  this._debug.debug("Participant hold suggested", e);
11320
- let t = this._getParticipant(e.participantId);
11336
+ let t = await this._getParticipant(e.participantId);
11321
11337
  if (!t) {
11322
11338
  this._warnParticipantNotInConversation(e.participantId);
11323
11339
  return;
@@ -11345,17 +11361,28 @@ var Eo = class {
11345
11361
  }
11346
11362
  _registerParticipant(e, t) {
11347
11363
  let n = this._createParticipant(e, t);
11348
- this._pendingParticipants.set(e.id, n);
11364
+ n.catch(() => void 0), this._pendingParticipants.set(e.id, n);
11349
11365
  }
11350
- _getParticipants() {
11366
+ async _getParticipants() {
11351
11367
  if (this._pendingParticipants.size) {
11352
- for (let e of this._pendingParticipants.values()) this._participants[e.id] = e;
11353
- this._pendingParticipants.clear();
11368
+ let e = Array.from(this._pendingParticipants.entries()), t = await Promise.allSettled(e.map((e) => e[1])), n = null;
11369
+ for (let r = 0; r < t.length; r++) {
11370
+ let [i] = e[r];
11371
+ this._pendingParticipants.delete(i);
11372
+ let a = t[r];
11373
+ if (a.status === "fulfilled") {
11374
+ let e = a.value;
11375
+ this._participants[e.id] = e;
11376
+ continue;
11377
+ }
11378
+ n = n ?? a.reason, this._debug.warn(`Failed to resolve pending participant [${i}]`, a.reason);
11379
+ }
11380
+ if (n) throw n;
11354
11381
  }
11355
11382
  return this._participants;
11356
11383
  }
11357
- _getParticipant(e) {
11358
- return this._getParticipants()[e];
11384
+ async _getParticipant(e) {
11385
+ return (await this._getParticipants())[e];
11359
11386
  }
11360
11387
  }, zo = null, Bo = class e extends Error {
11361
11388
  constructor(t, n) {
@@ -11591,7 +11618,7 @@ var Qo = class {
11591
11618
  throw new O(i, a);
11592
11619
  }
11593
11620
  }
11594
- userId(e) {
11621
+ async userId(e) {
11595
11622
  let t = j.extractOkId(e);
11596
11623
  return v.isEmpty() ? Z.fromId(String(t)) : this._idCache.getExternalId(t) || Z.fromId(String(t));
11597
11624
  }
@@ -12359,8 +12386,7 @@ async function zc(e, t = !1) {
12359
12386
  R.warn("promoteParticipant: externalId not found in cache", e);
12360
12387
  return;
12361
12388
  }
12362
- let n = e.type === Ga.GROUP ? A.GROUP : A.USER;
12363
- r = j.composeUserId(t, n);
12389
+ r = j.composeUserId(t);
12364
12390
  }
12365
12391
  return n.promoteParticipant(r, t);
12366
12392
  }