@vkontakte/calls-sdk 2.8.12 → 2.8.13-dev.0b862caf.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
3
- * Wed, 09 Sep 2026 10:07:50 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-dev.0b862caf.0
3
+ * Tue, 15 Sep 2026 20:28:59 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -1029,7 +1029,7 @@ var w;
1029
1029
  function g() {
1030
1030
  if (!yt || yt.readyState === "ended") {
1031
1031
  let e = w.getAudioContext(), t = e.createMediaStreamDestination(), n = e.createGain();
1032
- n.gain.value = 1e-5, n.connect(t), n.connect(e.destination);
1032
+ n.gain.value = 1e-5, n.connect(t), w.browserName() === "Safari" && n.connect(e.destination);
1033
1033
  let r = e.createOscillator();
1034
1034
  r.type = "sine", r.frequency.value = 0, r.connect(n), r.start(), yt = t.stream.getAudioTracks()[0];
1035
1035
  }
@@ -2155,7 +2155,7 @@ var yn = vn.getInstance(), M = class e {
2155
2155
  return 1.1;
2156
2156
  }
2157
2157
  static get sdkVersion() {
2158
- return "2.8.12";
2158
+ return "2.8.13-dev.0b862caf.0";
2159
2159
  }
2160
2160
  static get debug() {
2161
2161
  return e._params.debug;
@@ -2275,6 +2275,9 @@ var yn = vn.getInstance(), M = class e {
2275
2275
  static get signalingReconnectMaxCount() {
2276
2276
  return e._params.signalingReconnectMaxCount;
2277
2277
  }
2278
+ static get signalingReconnectMaxDuration() {
2279
+ return e._params.signalingReconnectMaxDuration;
2280
+ }
2278
2281
  static get waitConnectionDelay() {
2279
2282
  return e._params.waitConnectionDelay;
2280
2283
  }
@@ -2610,6 +2613,7 @@ h(M, "_params", {
2610
2613
  signalingReconnectDelay: 1e3,
2611
2614
  signalingReconnectMaxDelay: 5e3,
2612
2615
  signalingReconnectMaxCount: 10,
2616
+ signalingReconnectMaxDuration: 6e4,
2613
2617
  waitConnectionDelay: 1e4,
2614
2618
  waitResponseDelay: 1e4,
2615
2619
  waitMessageDelay: 15e3,
@@ -3065,6 +3069,10 @@ var xn;
3065
3069
  P("onPeerRegistered", e, t);
3066
3070
  }
3067
3071
  e.onPeerRegistered = ot;
3072
+ function st(e, t) {
3073
+ P("onNonFatalError", e, t);
3074
+ }
3075
+ e.onNonFatalError = st;
3068
3076
  })(xn || (xn = {}));
3069
3077
  var L = xn, Sn = /* @__PURE__ */ function(e) {
3070
3078
  return e.DEBUG = "DEBUG", e.LOG = "LOG", e.WARN = "WARN", e.ERROR = "ERROR", e;
@@ -4916,7 +4924,7 @@ var Qr = class {
4916
4924
  }
4917
4925
  }, ui = class extends oi {
4918
4926
  constructor(e, t, n, r, i, a = R, o = null) {
4919
- super(e, t, n, r, i, a), h(this, "_renderer", void 0), h(this, "_decoder", void 0), h(this, "_decoderReady", !1), h(this, "_decoderBusy", !1), h(this, "_decoderQueue", []), h(this, "_fpsMeter", void 0), h(this, "_logger", void 0), this._logger = o, this._debug.debug(`StreamBuilder started for participant [${e}]`), this._initFpsMeter(), this._initRenderer(), this._initDecoder();
4927
+ super(e, t, n, r, i, a), h(this, "_renderer", void 0), h(this, "_decoder", void 0), h(this, "_decoderReady", !1), h(this, "_decoderBusy", !1), h(this, "_decoderQueue", []), h(this, "_webCodecsRetryAttempted", !1), h(this, "_fpsMeter", void 0), h(this, "_logger", void 0), this._logger = o, this._debug.debug(`StreamBuilder started for participant [${e}]`), this._initFpsMeter(), this._initRenderer(), this._initDecoder();
4920
4928
  }
4921
4929
  _processFrame(e) {
4922
4930
  e.keyframe && (this._decoderQueue = []), this._decoderQueue.push(e), this._decodeQueue();
@@ -4931,7 +4939,11 @@ var Qr = class {
4931
4939
  e || !ti.isBrowserSupported() ? this._decoder = new ei(this._debug, this._logger) : this._decoder = new ti(this._debug, this._logger), this._decoder.init(async (e) => {
4932
4940
  this._decoderBusy = !1, "VideoFrame" in window && e instanceof VideoFrame ? await this._renderer.drawFrame(e) : await this._renderer.drawImage(e), this._fpsMeter.increment(), this._decodeQueue();
4933
4941
  }, (e) => {
4934
- this._decoderBusy = !1, this._decodeQueue(), this._decoder instanceof ti && typeof e == "string" && e.includes("EncodingError") && this._switchToLibVPXDecoder();
4942
+ if (this._decoderBusy = !1, this._decoder instanceof ti && typeof e == "string" && e.includes("EncodingError")) {
4943
+ this._decoderQueue = [], !this._webCodecsRetryAttempted && e.includes("reset because error during decoding") ? (this._webCodecsRetryAttempted = !0, this._debug.warn("StreamBuilder retry WebCodecs with software decoder"), this._onKeyFrameRequested?.()) : this._switchToLibVPXDecoder();
4944
+ return;
4945
+ }
4946
+ this._decodeQueue();
4935
4947
  }, this._onKeyFrameRequested).then(() => {
4936
4948
  this._decoderReady = !0, this._decodeQueue();
4937
4949
  }).catch((e) => {
@@ -4939,7 +4951,7 @@ var Qr = class {
4939
4951
  });
4940
4952
  }
4941
4953
  _switchToLibVPXDecoder() {
4942
- this._debug.warn("StreamBuilder switch to LibVPX decoder"), this._fpsMeter && this._fpsMeter.destroy(), this._decoder && (this._decoderReady = !1, this._decoderBusy = !1, this._decoder.destroy()), this._renderer && this._renderer.destroy(), this._initFpsMeter(), this._initRenderer(!0), this._initDecoder(!0);
4954
+ this._debug.warn("StreamBuilder switch to LibVPX decoder"), this._decoderQueue = [], this._fpsMeter && this._fpsMeter.destroy(), this._decoder && (this._decoderReady = !1, this._decoderBusy = !1, this._decoder.destroy()), this._renderer && this._renderer.destroy(), this._initFpsMeter(), this._initRenderer(!0), this._initDecoder(!0), this._onKeyFrameRequested?.();
4943
4955
  }
4944
4956
  _decodeQueue() {
4945
4957
  if (!this._decoderReady || this._decoderBusy) return;
@@ -5838,7 +5850,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5838
5850
  this._perfStatReporter?.destroy(), this._perfStatReporter = new pa(this, this._signaling, this._statAggregator, !1, this._debug);
5839
5851
  }
5840
5852
  _closeConnection() {
5841
- this._signaling.resetProducerConnection(), this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcast.reset(), this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(X.PEER_CONNECTION_CLOSED);
5853
+ this._signaling.resetProducerConnection(), this._ssrcMap = {}, this._ssrcMapUpdated = !0, this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcast.reset(), this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(X.PEER_CONNECTION_CLOSED);
5842
5854
  }
5843
5855
  static _closeDataChannel(e) {
5844
5856
  e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
@@ -5908,10 +5920,10 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5908
5920
  this._triggerEvent(X.NETWORK_STATUS, e);
5909
5921
  }
5910
5922
  _updateSSRCMap(e) {
5911
- e && ln(e.sdp).forEach((e) => {
5923
+ e && (this._ssrcMap = {}, this._ssrcMapUpdated = !0, ln(e.sdp).forEach((e) => {
5912
5924
  let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${qr.PARTICIPANT_AGNOSTIC_TRACK_PREFIX}-[0-9]+)|(?:${qr.TRANSPARENT_AUDIO_TRACK_PREFIX}-[0-9]+))`, n = new RegExp(t).exec(e);
5913
- n && (this._ssrcMap[n[1]] = n[3], this._ssrcMapUpdated = !0);
5914
- });
5925
+ n && (this._ssrcMap[n[1]] = n[3]);
5926
+ }));
5915
5927
  }
5916
5928
  _createCaptureSender(e) {
5917
5929
  let t = this._mediaSource.mediaSettings;
@@ -6913,10 +6925,10 @@ var ya = va, ba = {
6913
6925
  }, n;
6914
6926
  }
6915
6927
  }, ja = /* @__PURE__ */ function(e) {
6916
- return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.ABORTED = "ABORTED", e;
6928
+ return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.RECONNECT_TIMEOUT = "RECONNECT_TIMEOUT", e.ABORTED = "ABORTED", e;
6917
6929
  }({}), Ma = class {
6918
6930
  constructor(e = R, t) {
6919
- h(this, "handlers", void 0), h(this, "socket", null), h(this, "endpoint", ""), h(this, "wtEndpoint", null), h(this, "peerId", null), h(this, "lastStamp", 0), h(this, "connectionType", void 0), h(this, "reconnectCount", 0), h(this, "reconnectTimer", 0), h(this, "doctorTimer", 0), h(this, "forceWebSocket", !1), h(this, "abortSignal", void 0), h(this, "manualClose", !1), h(this, "currentType", yr.WEBSOCKET), h(this, "_debug", void 0), this.handlers = t, this._debug = e;
6931
+ h(this, "handlers", void 0), h(this, "socket", null), h(this, "endpoint", ""), h(this, "wtEndpoint", null), h(this, "peerId", null), h(this, "lastStamp", 0), h(this, "connectionType", void 0), h(this, "reconnectCount", 0), h(this, "reconnectTimer", 0), h(this, "reconnectDeadlineTimer", 0), h(this, "doctorTimer", 0), h(this, "forceWebSocket", !1), h(this, "abortSignal", void 0), h(this, "manualClose", !1), h(this, "currentType", yr.WEBSOCKET), h(this, "_debug", void 0), this.handlers = t, this._debug = e;
6920
6932
  }
6921
6933
  get readyState() {
6922
6934
  return this.socket?.readyState ?? null;
@@ -6939,14 +6951,14 @@ var ya = va, ba = {
6939
6951
  setAbortSignal(e) {
6940
6952
  this.abortSignal = e;
6941
6953
  }
6942
- resetReconnectCount() {
6943
- this.reconnectCount = 0;
6954
+ onConnectionRestored() {
6955
+ this.reconnectCount = 0, this._stopReconnectDeadline();
6944
6956
  }
6945
6957
  connect(e) {
6946
6958
  this.socket && this.socket.readyState < WebSocket.CLOSING || (e !== vr.RETRY && (this.forceWebSocket = !1, this.reconnectCount = 0), this.manualClose = !1, this.connectionType = e, this._connect());
6947
6959
  }
6948
6960
  close(e) {
6949
- this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this.lastStamp = 0;
6961
+ this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._stopReconnectDeadline(), this.lastStamp = 0;
6950
6962
  }
6951
6963
  async send(e) {
6952
6964
  await this.socket?.send(e);
@@ -7019,20 +7031,32 @@ var ya = va, ba = {
7019
7031
  }
7020
7032
  _scheduleReconnect(e = this._getReconnectDelay()) {
7021
7033
  if (this.reconnectCount >= M.signalingReconnectMaxCount) {
7022
- this.handlers.onFailed({
7034
+ this._stopReconnectDeadline(), this.handlers.onFailed({
7023
7035
  failure: "NETWORK_ERROR",
7024
7036
  message: "Unable to connect to the signaling: reconnect attempts exhausted",
7025
7037
  source: this.currentType
7026
7038
  });
7027
7039
  return;
7028
7040
  }
7029
- this.reconnectCount++, this.handlers.onReconnectScheduled({
7041
+ this._startReconnectDeadline(), this.reconnectCount++, this.handlers.onReconnectScheduled({
7030
7042
  count: this.reconnectCount,
7031
7043
  delay: e
7032
7044
  }), this.reconnectTimer = window.setTimeout(() => {
7033
7045
  this.connectionType = vr.RETRY, this._connect();
7034
7046
  }, e);
7035
7047
  }
7048
+ _startReconnectDeadline() {
7049
+ this.reconnectDeadlineTimer || (this.reconnectDeadlineTimer = window.setTimeout(() => {
7050
+ this.reconnectDeadlineTimer = 0, window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._disconnect(4e3), this.handlers.onFailed({
7051
+ failure: "RECONNECT_TIMEOUT",
7052
+ message: "Unable to connect to the signaling: reconnect timeout",
7053
+ source: this.currentType
7054
+ });
7055
+ }, M.signalingReconnectMaxDuration));
7056
+ }
7057
+ _stopReconnectDeadline() {
7058
+ window.clearTimeout(this.reconnectDeadlineTimer), this.reconnectDeadlineTimer = 0;
7059
+ }
7036
7060
  _getReconnectDelay() {
7037
7061
  return Math.min(M.signalingReconnectMaxDelay, M.signalingReconnectDelay * 2 ** this.reconnectCount);
7038
7062
  }
@@ -7461,7 +7485,7 @@ var Ra = new Set([
7461
7485
  _handleMessage(e) {
7462
7486
  switch (e.type) {
7463
7487
  case "notification":
7464
- this._attachNotificationCallError(e), e.notification === "connection" ? (this._debug.debug("[signaling] signaling connected", e), this.connected = !0, this.transport.resetReconnectCount(), this.transport.setEndpoint(e.endpoint), e.peerId && this.peerId !== e.peerId.id && (this.peerId = e.peerId.id, this.transport.setPeerId(e.peerId.id)), this._stopWaitConnectionMessage(), this.conversationResolve ? this.conversationResolve(e) : (this._logTransportStat(br.RESTART), this._triggerEvent(G.RECONNECT, e), e.conversation.topology && this._triggerEvent(G.NOTIFICATION, {
7488
+ this._attachNotificationCallError(e), e.notification === "connection" ? (this._debug.debug("[signaling] signaling connected", e), this.connected = !0, this.transport.onConnectionRestored(), this.transport.setEndpoint(e.endpoint), e.peerId && this.peerId !== e.peerId.id && (this.peerId = e.peerId.id, this.transport.setPeerId(e.peerId.id)), this._stopWaitConnectionMessage(), this.conversationResolve ? this.conversationResolve(e) : (this._logTransportStat(br.RESTART), this._triggerEvent(G.RECONNECT, e), e.conversation.topology && this._triggerEvent(G.NOTIFICATION, {
7465
7489
  type: "notification",
7466
7490
  notification: K.TOPOLOGY_CHANGED,
7467
7491
  topology: e.conversation.topology
@@ -7733,6 +7757,14 @@ var Ra = new Set([
7733
7757
  description: "connection-failed"
7734
7758
  } }));
7735
7759
  break;
7760
+ case ja.RECONNECT_TIMEOUT:
7761
+ this._fail(new O(D.NETWORK_ERROR, { callError: {
7762
+ scope: "network",
7763
+ source: e.source,
7764
+ code: "reconnect-timeout",
7765
+ description: "connection-failed"
7766
+ } }));
7767
+ break;
7736
7768
  case ja.ABORTED:
7737
7769
  this._debug.debug("[signaling] aborted reconnect"), this._fail(new O(D.CANCELED));
7738
7770
  break;
@@ -8251,8 +8283,8 @@ var bo = 90, xo = 3, So = class extends b {
8251
8283
  t > bo ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= xo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8252
8284
  }
8253
8285
  }, Co = class {
8254
- constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i }) {
8255
- h(this, "_api", void 0), h(this, "_debug", void 0), h(this, "_getParticipants", void 0), h(this, "_isMe", void 0), h(this, "_updateDisplayLayout", void 0), h(this, "_requestedLayouts", {}), h(this, "_uncertainLayouts", {}), h(this, "_pendingRequests", null), h(this, "_pendingPromises", []), h(this, "_lastRequests", null), h(this, "_timer", null), h(this, "_inFlight", !1), h(this, "_lastFlushAt", null), h(this, "_generation", 0), h(this, "_forceNextFlush", !1), this._api = e, this._debug = t, this._getParticipants = n, this._isMe = r, this._updateDisplayLayout = i;
8286
+ constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i, onNonFatalError: a }) {
8287
+ h(this, "_api", void 0), h(this, "_debug", void 0), h(this, "_getParticipants", void 0), h(this, "_isMe", void 0), h(this, "_updateDisplayLayout", void 0), h(this, "_onNonFatalError", void 0), h(this, "_requestedLayouts", {}), h(this, "_uncertainLayouts", {}), h(this, "_pendingRequests", null), h(this, "_pendingPromises", []), h(this, "_lastRequests", null), h(this, "_timer", null), h(this, "_inFlight", !1), h(this, "_lastFlushAt", null), h(this, "_generation", 0), h(this, "_forceNextFlush", !1), this._api = e, this._debug = t, this._getParticipants = n, this._isMe = r, this._updateDisplayLayout = i, this._onNonFatalError = a;
8256
8288
  }
8257
8289
  request(e) {
8258
8290
  this._pendingRequests = e.slice(), this._lastRequests = e.slice();
@@ -8288,11 +8320,16 @@ var bo = 90, xo = 3, So = class extends b {
8288
8320
  this._pendingRequests = null, this._pendingPromises = [];
8289
8321
  let r = {};
8290
8322
  try {
8291
- r = this._getRequestLayouts(t);
8292
- let i = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8323
+ let i = this._getRequestLayouts(t);
8324
+ if (!i) {
8325
+ n.forEach(({ resolve: e }) => e());
8326
+ return;
8327
+ }
8328
+ r = i;
8329
+ let a = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8293
8330
  this._forceNextFlush = !1;
8294
- let a = this._getDiff(r, i);
8295
- a.length && await this._updateDisplayLayout(a), e === this._generation && (this._requestedLayouts = r, this._uncertainLayouts = {}), n.forEach(({ resolve: e }) => e());
8331
+ let o = this._getDiff(r, a);
8332
+ o.length && await this._updateDisplayLayout(o), e === this._generation && (this._requestedLayouts = r, this._uncertainLayouts = {}), n.forEach(({ resolve: e }) => e());
8296
8333
  } catch (t) {
8297
8334
  e === this._generation ? (this._uncertainLayouts = {
8298
8335
  ...this._uncertainLayouts,
@@ -8303,30 +8340,30 @@ var bo = 90, xo = 3, So = class extends b {
8303
8340
  }
8304
8341
  }
8305
8342
  _getRequestLayouts(e) {
8306
- let t = {}, n = this._getParticipants();
8307
- for (let r of e) {
8308
- let e = typeof r.uid == "object" ? r.uid : Q.fromId(r.uid), i = this._api.getCachedOkIdByExternalId(e);
8309
- if (!i) {
8310
- this._debug.log(`Unknown participant external ID ${typeof r.uid == "object" ? Q.toString(r.uid) : r.uid}`);
8343
+ let t = {}, n = [], r = this._getParticipants();
8344
+ for (let i of e) {
8345
+ let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedParticipantIdByExternalId(e);
8346
+ if (!a) {
8347
+ this._debug.log(`Unknown participant external ID ${typeof i.uid == "object" ? Q.toString(i.uid) : i.uid}`), n.push(e.id);
8311
8348
  continue;
8312
8349
  }
8313
- if (!n[i] && !this._isMe(i)) continue;
8314
- let a = Mn({
8315
- participantId: i,
8316
- mediaType: r.mediaType,
8317
- streamName: r.streamName
8350
+ if (!r[a] && !this._isMe(a)) continue;
8351
+ let o = Mn({
8352
+ participantId: a,
8353
+ mediaType: i.mediaType,
8354
+ streamName: i.streamName
8318
8355
  });
8319
- t[a] = {
8320
- uid: r.uid,
8321
- mediaType: r.mediaType,
8322
- width: r.width,
8323
- height: r.height,
8324
- fit: r.cover ? "cv" : "cn",
8325
- ...r.priority === void 0 ? {} : { priority: r.priority },
8326
- ...r.streamName === void 0 ? {} : { streamName: r.streamName }
8356
+ t[o] = {
8357
+ uid: i.uid,
8358
+ mediaType: i.mediaType,
8359
+ width: i.width,
8360
+ height: i.height,
8361
+ fit: i.cover ? "cv" : "cn",
8362
+ ...i.priority === void 0 ? {} : { priority: i.priority },
8363
+ ...i.streamName === void 0 ? {} : { streamName: i.streamName }
8327
8364
  };
8328
8365
  }
8329
- return t;
8366
+ return n.length ? (this._onNonFatalError(`Participant ID mapping not found for external IDs "${Array.from(new Set(n)).join("\", \"")}" while handling requestDisplayLayout`), null) : t;
8330
8367
  }
8331
8368
  _getDiff(e, t = !1) {
8332
8369
  let n = [];
@@ -8365,7 +8402,7 @@ var bo = 90, xo = 3, So = class extends b {
8365
8402
  h(this, "_analyser", null), h(this, "_gainNode", null), h(this, "_fftBins", null), h(this, "_mediaStreamSource", null), h(this, "_lastSmoothedLevel", 0), h(this, "_trackId", void 0), h(this, "_track", void 0), h(this, "_stream", void 0), this._trackId = e, this._track = t, this._stream = new MediaStream([t]);
8366
8403
  try {
8367
8404
  let e = T.getAudioContext();
8368
- this._gainNode = e.createGain(), this._gainNode.gain.value = 1e-5, this._gainNode.connect(e.destination), this._analyser = e.createAnalyser(), this._analyser.fftSize = 1024, this._analyser.smoothingTimeConstant = 0, this._analyser.connect(this._gainNode), this._fftBins = new Uint8Array(this._analyser.frequencyBinCount), this._mediaStreamSource = e.createMediaStreamSource(this._stream), this._mediaStreamSource.connect(this._analyser);
8405
+ this._analyser = e.createAnalyser(), this._analyser.fftSize = 1024, this._analyser.smoothingTimeConstant = 0, T.browserName() === "Safari" && (this._gainNode = e.createGain(), this._gainNode.gain.value = 1e-5, this._gainNode.connect(e.destination), this._analyser.connect(this._gainNode)), this._fftBins = new Uint8Array(this._analyser.frequencyBinCount), this._mediaStreamSource = e.createMediaStreamSource(this._stream), this._mediaStreamSource.connect(this._analyser);
8369
8406
  } catch {}
8370
8407
  }
8371
8408
  get track() {
@@ -9348,7 +9385,8 @@ var ls = 15, $ = class e extends b {
9348
9385
  debug: this._debug,
9349
9386
  getParticipants: () => this._participants,
9350
9387
  isMe: (e) => this._isMe(e),
9351
- updateDisplayLayout: (e) => this.updateDisplayLayout(e)
9388
+ updateDisplayLayout: (e) => this.updateDisplayLayout(e),
9389
+ onNonFatalError: (e) => this._onNonFatalError(e)
9352
9390
  }), this._onUnload = () => {
9353
9391
  this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? D.CANCELED : D.HUNGUP), this._stats.destroy();
9354
9392
  }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new as(this._stats.statAggregator), this._audioOutput = new go(this._statFirstMediaReceived, M.transparentAudio, this._debug, this._stats.logger), M.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), os));
@@ -9384,6 +9422,9 @@ var ls = 15, $ = class e extends b {
9384
9422
  get isCallHeld() {
9385
9423
  return this._state === "HELD";
9386
9424
  }
9425
+ get isIncomingRinging() {
9426
+ return this._conversation?.direction === Ba.INCOMING && this._state === "IDLE";
9427
+ }
9387
9428
  static debugSessionId() {
9388
9429
  return e.current()?.debugSessionId ?? null;
9389
9430
  }
@@ -9401,8 +9442,14 @@ var ls = 15, $ = class e extends b {
9401
9442
  get debugSessionId() {
9402
9443
  return this._debug.sessionId;
9403
9444
  }
9404
- getCachedRawOkIdByExternalId(e) {
9405
- return this._api.getCachedRawOkIdByExternalId(e);
9445
+ getCachedParticipantIdByExternalId(e) {
9446
+ return this._api.getCachedParticipantIdByExternalId(e);
9447
+ }
9448
+ _onNonFatalError(e) {
9449
+ L.onNonFatalError(Error(e), this.id);
9450
+ }
9451
+ getIncomingCallerExternalId() {
9452
+ return this._conversation?.direction === Ba.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
9406
9453
  }
9407
9454
  _buildInternalParams() {
9408
9455
  let e = {
@@ -9445,11 +9492,15 @@ var ls = 15, $ = class e extends b {
9445
9492
  description: "not-initialized-after-start"
9446
9493
  } });
9447
9494
  if (this._participantState = Z.ACCEPTED, this._changeMediaSettings(l), await this._processConnection(d), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._signaling.readyToSend(), this._delayedHangup) throw new O(D.CANCELED);
9448
- return this._debug.debug("Outgoing call", {
9495
+ if (this._debug.debug("Outgoing call", {
9449
9496
  opponentIds: e,
9450
9497
  opponentType: t,
9451
9498
  mediaOptions: n
9452
- }), 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), us = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9499
+ }), 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(), this._conversation?.concurrent) {
9500
+ let e = z.get(this._conversation.id);
9501
+ e && e !== this && e._close(new O(D.HUNGUP, { remote: !0 }));
9502
+ }
9503
+ return z.add(this), await z.setActive(this.id), us = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9453
9504
  this._calleeUnavailableTimer = null, this._close(new O(D.CALLEE_UNAVAILABLE), { signalingReason: D.CANCELED });
9454
9505
  }, f)), this._conversation;
9455
9506
  } catch (e) {
@@ -9506,7 +9557,11 @@ var ls = 15, $ = class e extends b {
9506
9557
  }
9507
9558
  }
9508
9559
  _extractExternalRooms(e) {
9509
- return e.map(this._convertRoomToExternal.bind(this)).filter((e) => !!e);
9560
+ let t = [], n = [];
9561
+ return e.forEach((e) => {
9562
+ let { room: r, missingParticipantIds: i } = this._convertRoomToExternal(e);
9563
+ r && n.push(r), t.push(...i);
9564
+ }), this._reportMissingExternalIds(t, "EXTRACT_EXTERNAL_ROOMS"), n.filter((e) => !!e);
9510
9565
  }
9511
9566
  _extractExternalRoomsData(e, t) {
9512
9567
  if (!e || !e.length) return;
@@ -9731,7 +9786,8 @@ var ls = 15, $ = class e extends b {
9731
9786
  D.CALLEE_IS_OFFLINE,
9732
9787
  D.CALLEE_UNAVAILABLE,
9733
9788
  D.CALLER_IS_BLOCKED,
9734
- D.CALLER_IS_REJECTED
9789
+ D.CALLER_IS_REJECTED,
9790
+ D.HAS_ACTIVE_CALL
9735
9791
  ].indexOf(e.hangup) !== -1 || e.hangup === D.REJECTED && !e.remote) {
9736
9792
  this._emitHangupOnce(e, i), this._destroy(r);
9737
9793
  return;
@@ -9988,19 +10044,17 @@ var ls = 15, $ = class e extends b {
9988
10044
  isInRoom: !1,
9989
10045
  markers: null
9990
10046
  }, e), i = !!r.externalId;
9991
- 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 = eo.create(r.connectionStatus), r;
10047
+ if (!i) {
10048
+ let e = this._getParticipantId(t ?? r.id);
10049
+ e && (r.externalId = e);
10050
+ }
10051
+ return n && i && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && r.externalId && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = eo.create(r.connectionStatus), r;
9992
10052
  }
9993
10053
  _getParticipantId(e) {
9994
- try {
9995
- return this._api.userId(e);
9996
- } catch (e) {
9997
- throw this._close(e instanceof O ? e : new O(D.NETWORK_ERROR, { callError: {
9998
- scope: "network",
9999
- source: "api",
10000
- code: "fetch-failed",
10001
- description: "request-failed"
10002
- } }), { errorText: e }), e;
10003
- }
10054
+ let t = this._api.userId(e);
10055
+ if (t) return t;
10056
+ let { compositeUserId: n, deviceIdx: r } = j.decomposeParticipantId(e), { id: i, type: a } = j.decomposeId(n);
10057
+ return a === A.GROUP ? Q.fromId(String(i), void 0, r) : null;
10004
10058
  }
10005
10059
  _cacheParticipantExternalIds(e) {
10006
10060
  e.forEach((e) => {
@@ -10008,7 +10062,7 @@ var ls = 15, $ = class e extends b {
10008
10062
  if (n) {
10009
10063
  this._api.cacheExternalId(t, n);
10010
10064
  let r = j.composeDecorativeId(e), i = Q.fromSignalingParticipant(e);
10011
- r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(e.decorativeUserId, e.id));
10065
+ r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(r, t));
10012
10066
  }
10013
10067
  });
10014
10068
  }
@@ -10057,7 +10111,11 @@ var ls = 15, $ = class e extends b {
10057
10111
  audienceMode: this._isAudienceMode(t),
10058
10112
  restricted: this._isRestricted(t),
10059
10113
  urlSharingInfoByRoom: /* @__PURE__ */ new Map()
10060
- }, this._debug.setConversationId(t.conversation.id || e.id), e.p2p_forbidden && (M.forceRelayPolicy = e.p2p_forbidden), this._stats.logger.log(C.RELAY_POLICY, M.forceRelayPolicy ? "1" : "0"), this._changeFeatureSet(), this._changeFeaturesPerRole(), this._logDevices();
10114
+ }, this._debug.setConversationId(t.conversation.id || e.id), e.p2p_forbidden && (M.forceRelayPolicy = e.p2p_forbidden), this._stats.logger.log(C.RELAY_POLICY, M.forceRelayPolicy ? "1" : "0");
10115
+ let l = z.get(this._conversation.id);
10116
+ if (l && l !== this) this._conversation.concurrent = !0;
10117
+ else if (!M.hold && z.callsLength > 0) throw new O(D.HAS_ACTIVE_CALL);
10118
+ this._changeFeatureSet(), this._changeFeaturesPerRole(), this._logDevices();
10061
10119
  }
10062
10120
  _updateConversation(e) {
10063
10121
  if (!this._conversation) throw new O(D.UNKNOWN_ERROR, { callError: {
@@ -10187,33 +10245,40 @@ var ls = 15, $ = class e extends b {
10187
10245
  _getExistedParticipantByIdOrCreate(e) {
10188
10246
  let t = this._participants[e];
10189
10247
  if (t) return t;
10190
- 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);
10248
+ let n = this._api.getDecorativeIdByInitialId(e), r = this._getParticipantId(e), { deviceIdx: i } = j.decomposeParticipantId(e);
10191
10249
  return this._createParticipant({
10192
10250
  id: e,
10193
- externalId: {
10194
- ...i,
10195
- deviceIdx: a
10196
- }
10197
- }, r, !1);
10251
+ externalId: r ? {
10252
+ ...r,
10253
+ deviceIdx: i
10254
+ } : void 0
10255
+ }, n, !1);
10198
10256
  }
10199
10257
  _getExternalIdByParticipantId(e) {
10200
- if (this._isMe(e)) return this._conversation?.externalId;
10258
+ if (this._isMe(e)) return this._conversation?.externalId ?? null;
10201
10259
  if (M.useParticipantListChunk) return this._getExistedParticipantByIdOrCreate(e).externalId;
10202
10260
  let t = this._participants;
10203
10261
  if (t[e]?.externalId) return t[e].externalId;
10204
- {
10205
- let t = this._getParticipantId(e);
10206
- return this._api.cacheExternalId(e, t), t;
10207
- }
10262
+ let n = this._api.getCachedExternalIdByParticipantId(e);
10263
+ if (n) return n;
10264
+ let r = this._getParticipantId(e);
10265
+ return r && this._api.cacheExternalId(e, r), r;
10208
10266
  }
10209
- _getExternalIdsByOkIdsFromCache(e) {
10210
- return e.map((e) => this._api.getCachedExternalIdByOkId(e) ?? Q.fromId(String(e)));
10267
+ _getExternalIdsByParticipantIds(e) {
10268
+ let t = [], n = [];
10269
+ return e.forEach((e) => {
10270
+ let r = this._getExternalIdByParticipantId(e);
10271
+ r ? t.push(r) : n.push(e);
10272
+ }), {
10273
+ externalIds: t,
10274
+ missingIds: n
10275
+ };
10211
10276
  }
10212
- _getOrCacheExternalIdByCompositeId(e) {
10213
- let t = j.extractOkId(e), n = this._api.getCachedExternalIdByOkId(t);
10214
- if (n) return n;
10215
- let r = Q.fromId(String(t));
10216
- return this._api.cacheExternalId(e, r), r;
10277
+ _reportMissingExternalIds(e, t) {
10278
+ e.length && this._onNonFatalError(`External ID mapping not found for participants "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10279
+ }
10280
+ _reportMissingExternalIdsById(e, t) {
10281
+ e.length && this._onNonFatalError(`Participant ID mapping not found for external IDs "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10217
10282
  }
10218
10283
  _registerParticipantAndSetMarkersIfChunkEnabled(e, t) {
10219
10284
  if (M.useParticipantListChunk) {
@@ -10498,30 +10563,34 @@ var ls = 15, $ = class e extends b {
10498
10563
  async updateDisplayLayout(e) {
10499
10564
  if (e.length < 1 || !this._signaling.ready) return;
10500
10565
  this._debug.log(`Update display layout request [${this._signaling.getNextCommandSequenceNumber()}]`, e);
10501
- let t = {}, n = [], r = this._participants;
10502
- for (let i of e) {
10503
- let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedOkIdByExternalId(e);
10504
- if (!a) {
10566
+ let t = {}, n = [], r = [], i = this._participants;
10567
+ for (let a of e) {
10568
+ let e = typeof a.uid == "object" ? a.uid : Q.fromId(a.uid), o = this._api.getCachedParticipantIdByExternalId(e);
10569
+ if (!o) {
10505
10570
  let t = Q.toString(e);
10506
- this._debug.log(`Unknown participant external ID ${t}`);
10571
+ this._debug.log(`Unknown participant external ID ${t}`), r.push(e.id);
10507
10572
  continue;
10508
10573
  }
10509
- let o = Mn({
10510
- participantId: a,
10511
- mediaType: i.mediaType,
10512
- streamName: i.streamName
10513
- }), s = r[a];
10514
- s ? n.push(() => {
10515
- s.lastRequestedLayouts[o] = i;
10516
- }) : this._isMe(a) && n.push(() => {
10517
- this._myLastRequestedLayouts[o] = i;
10518
- }), Dn(i) ? (this._isMe(a) && n.push(() => {
10519
- delete this._myLastRequestedLayouts[o];
10520
- }), this._streamIdByStreamDescription.has(o) && !this._cooldownTimestampByStreamDescription.has(o) && this._cooldownTimestampByStreamDescription.set(o, Date.now())) : (this._cooldownTimestampByStreamDescription.delete(o), !this._streamIdByStreamDescription.has(o) && M.videoTracksCount > 0 && this._streamIdByStreamDescription.set(o, null), t[o] = i), i.mediaType === V.SCREEN && !Dn(i) && W.setMark(W.getMarkNameScreenshareFirstFrame(a));
10521
- }
10522
- let i = this._cooldownTimestampByStreamDescription.keys();
10574
+ let s = Mn({
10575
+ participantId: o,
10576
+ mediaType: a.mediaType,
10577
+ streamName: a.streamName
10578
+ }), c = i[o];
10579
+ c ? n.push(() => {
10580
+ c.lastRequestedLayouts[s] = a;
10581
+ }) : this._isMe(o) && n.push(() => {
10582
+ this._myLastRequestedLayouts[s] = a;
10583
+ }), Dn(a) ? (this._isMe(o) && n.push(() => {
10584
+ delete this._myLastRequestedLayouts[s];
10585
+ }), this._streamIdByStreamDescription.has(s) && !this._cooldownTimestampByStreamDescription.has(s) && this._cooldownTimestampByStreamDescription.set(s, Date.now())) : (this._cooldownTimestampByStreamDescription.delete(s), !this._streamIdByStreamDescription.has(s) && M.videoTracksCount > 0 && this._streamIdByStreamDescription.set(s, null), t[s] = a), a.mediaType === V.SCREEN && !Dn(a) && W.setMark(W.getMarkNameScreenshareFirstFrame(o));
10586
+ }
10587
+ if (r.length) {
10588
+ this._reportMissingExternalIdsById(r, "updateDisplayLayout");
10589
+ return;
10590
+ }
10591
+ let a = this._cooldownTimestampByStreamDescription.keys();
10523
10592
  for (; this._streamIdByStreamDescription.size > M.videoTracksCount;) {
10524
- let e = i.next();
10593
+ let e = a.next();
10525
10594
  if (e.done) {
10526
10595
  this._debug.error("Cannot accommodate all streaming requests: tracks available " + M.videoTracksCount + "; requested streams: " + Array.from(this._streamIdByStreamDescription.keys()));
10527
10596
  break;
@@ -10613,17 +10682,22 @@ var ls = 15, $ = class e extends b {
10613
10682
  async _onParticipantPromoted(e) {
10614
10683
  this._conversation && this._conversation.audienceMode ? (this._debug.log("Promoted in audience mode", !e.demote), this._conversation.restricted = e.demote, this._processRecordInfos(e), !e.demote && this._mediaSource && this._changeMediaSettings(this._mediaSource.mediaSettings)) : (this._debug.log("Promoted in waiting hall", !e.demote), e.demote ? (this._debug.log("Kicked from waiting hall"), this._close(new O(D.REMOVED))) : (this._updateConversation(e), this._waitingHallHoldPending ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !1), this._waitingHallHoldPending = !1) : z.getActive() && M.hold ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !0, !0), this._waitingHallHoldPending = !1) : await this._onJoinPart2(e))), L.onPromoted(e.demote, this.id);
10615
10684
  }
10616
- async _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10685
+ _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10617
10686
  this._debug.log(`Chat room updated: ${e}`);
10618
- let a = [];
10687
+ let a = [], o = [];
10619
10688
  n.length && n.forEach((e) => {
10620
10689
  if (e.externalId) {
10621
10690
  let t = Q.fromSignaling(e.externalId);
10622
10691
  a.push(t), this._api.cacheExternalId(e.id.id, t);
10623
- } else a.push(this._getOrCacheExternalIdByCompositeId(e.id.id));
10692
+ } else {
10693
+ let t = this._getExternalIdByParticipantId(e.id.id);
10694
+ t ? a.push(t) : o.push(e.id.id);
10695
+ }
10624
10696
  });
10625
- let o = r?.map((e) => this._getOrCacheExternalIdByCompositeId(e)) ?? [], s = i?.map((e) => this._getOrCacheExternalIdByCompositeId(e)) ?? [];
10626
- L.onChatRoomUpdated(e, t, a, o, s, this.id);
10697
+ let { externalIds: s, missingIds: c } = this._getExternalIdsByParticipantIds(r ?? []);
10698
+ o.push(...c);
10699
+ let { externalIds: l, missingIds: u } = this._getExternalIdsByParticipantIds(i ?? []);
10700
+ o.push(...u), this._reportMissingExternalIds(o, "CHAT_ROOM_UPDATED"), L.onChatRoomUpdated(e, t, a, s, l, this.id);
10627
10701
  }
10628
10702
  _onSharedMovieUpdate(e) {
10629
10703
  let t = this._conversation?.externalId;
@@ -10846,34 +10920,37 @@ var ls = 15, $ = class e extends b {
10846
10920
  let r = null;
10847
10921
  if (e && (r = ro(e), r)) {
10848
10922
  let e = this._api.getDecorativeIdByInitialId(r.id);
10849
- r.id = e ? j.composeUserId(e) : r.id;
10923
+ r.id = e ?? r.id;
10850
10924
  }
10851
10925
  let i = await this._signaling.getWaitingHall(r, t, n);
10852
10926
  if (i.error) return Promise.reject(i.message);
10853
- let a = i.participants || [], { externalIds: o } = await this._resolveWaitingHallExternalIds(a), s = null;
10927
+ let a = i.participants || [], { externalIds: o } = this._resolveWaitingHallExternalIds(a, "getWaitingHall"), s = null;
10854
10928
  return a.length && i.hasMore && (s = no(a[a.length - 1].id)), {
10855
10929
  participants: o,
10856
10930
  pageMarker: s,
10857
10931
  totalCount: i.totalCount || 0
10858
10932
  };
10859
10933
  }
10860
- async _resolveWaitingHallExternalIds(e) {
10861
- let t = [], n = [];
10934
+ _resolveWaitingHallExternalIds(e, t) {
10935
+ let n = [], r = [], i = [];
10862
10936
  return e.length && e.forEach((e) => {
10863
10937
  if (e.externalId) {
10864
- let r = Q.fromSignaling(e.externalId);
10865
- t.push(e.id.addedTs), n.push(r), this._api.cacheExternalId(e.id.id, r);
10866
- } else n.push(this._getOrCacheExternalIdByCompositeId(e.id.id)), t.push(e.id.addedTs);
10867
- }), {
10868
- externalIds: n,
10869
- timestamps: t
10938
+ let t = Q.fromSignaling(e.externalId);
10939
+ n.push(e.id.addedTs), r.push(t), this._api.cacheExternalId(e.id.id, t);
10940
+ } else {
10941
+ let t = this._getExternalIdByParticipantId(e.id.id);
10942
+ t ? (r.push(t), n.push(e.id.addedTs)) : i.push(e.id.id);
10943
+ }
10944
+ }), this._reportMissingExternalIds(i, t), {
10945
+ externalIds: r,
10946
+ timestamps: n
10870
10947
  };
10871
10948
  }
10872
10949
  async getAudienceModeHands() {
10873
10950
  if (!this._signaling.ready) throw Error("Signaling is not ready");
10874
10951
  let e = await this._signaling.getHandQueue();
10875
10952
  if (e.error) return Promise.reject(e.message);
10876
- let t = e.participants || [], { externalIds: n, timestamps: r } = await this._resolveWaitingHallExternalIds(t);
10953
+ let t = e.participants || [], { externalIds: n, timestamps: r } = this._resolveWaitingHallExternalIds(t, "getAudienceModeHands");
10877
10954
  return {
10878
10955
  timestamps: r,
10879
10956
  participants: n,
@@ -11042,7 +11119,7 @@ var ls = 15, $ = class e extends b {
11042
11119
  unmuteOptions: e.unmuteOptions || [],
11043
11120
  observedIds: e.observedIds || [],
11044
11121
  markers: this._denormalizeMarkers(t, e.markers)
11045
- }, e.decorativeUserId);
11122
+ }, j.composeDecorativeId(e));
11046
11123
  }));
11047
11124
  }
11048
11125
  async getParticipantListChunk(e) {
@@ -11088,7 +11165,7 @@ var ls = 15, $ = class e extends b {
11088
11165
  this._warnParticipantNotInConversation(e);
11089
11166
  return;
11090
11167
  }
11091
- r.mediaSettings = t, ["ACTIVE", "HELD"].includes(this._state) && L.onRemoteMediaSettings(r.externalId, t, r.markers, this.id), this._specListener && this._specListener.onChangeRemoteMediaSettings(e, t);
11168
+ r.mediaSettings = t, ["ACTIVE", "HELD"].includes(this._state) && (r.externalId ? L.onRemoteMediaSettings(r.externalId, t, r.markers, this.id) : this._reportMissingExternalIds([e], "REMOTE_MEDIA_SETTINGS")), this._specListener && this._specListener.onChangeRemoteMediaSettings(e, t);
11092
11169
  }
11093
11170
  _extractLocalParticipantFromConnection(e) {
11094
11171
  let t = this._api.getUserId();
@@ -11104,7 +11181,7 @@ var ls = 15, $ = class e extends b {
11104
11181
  this._warnParticipantNotInConversation(e);
11105
11182
  return;
11106
11183
  }
11107
- n.participantState = t || {}, ["ACTIVE", "HELD"].includes(this._state) && L.onRemoteParticipantState(n.externalId, n.participantState, n.markers, this.id);
11184
+ n.participantState = t || {}, ["ACTIVE", "HELD"].includes(this._state) && (n.externalId ? L.onRemoteParticipantState(n.externalId, n.participantState, n.markers, this.id) : this._reportMissingExternalIds([e], "REMOTE_PARTICIPANT_STATE"));
11108
11185
  }
11109
11186
  _changeMultipleParticipantState(e, t) {
11110
11187
  this._debug.debug("Multiple participants state changed", e);
@@ -11239,30 +11316,37 @@ var ls = 15, $ = class e extends b {
11239
11316
  async _onAcceptedCall(e) {
11240
11317
  let t = j.composeMessageId(e), n = j.getPeerIdString(e.peerId);
11241
11318
  if (this._debug.debug(`Participant accepted call [${t}]`), this._statFirstMediaReceived.markAcceptedCall(this._transport?.getTopology()), this._conversation && this._isMe(t)) {
11319
+ if (this._conversation.concurrent) return;
11242
11320
  this._close(new O(D.MISSED), { errorText: "Call accepted on other device" });
11243
11321
  return;
11244
11322
  }
11245
11323
  this._conversation?.direction === Ba.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
11246
11324
  let r = this._getParticipant(t);
11247
11325
  if (!r) {
11248
- let n = this._api.getDecorativeIdByInitialId(t), i = n ? j.composeUserId(n, e.participantType) : void 0;
11326
+ let n = this._api.getDecorativeIdByInitialId(t);
11249
11327
  r = this._registerParticipantInCache(this._createParticipant({
11250
11328
  id: t,
11251
11329
  externalId: e.externalId ? Q.fromSignaling(e.externalId, e.deviceIdx) : void 0,
11252
11330
  mediaSettings: E(e.mediaSettings)
11253
- }, i));
11331
+ }, n));
11254
11332
  } else if (e.externalId) {
11255
11333
  let t = Q.fromSignaling(e.externalId, e.deviceIdx);
11256
11334
  r.externalId = t, this._api.cacheExternalId(r.id, t);
11257
11335
  }
11258
11336
  r.state = Z.ACCEPTED, r.mediaSettings = E(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === Ba.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);
11259
11337
  let i = Object.keys(r.muteStates);
11260
- i.length && this._onMuteParticipant({
11338
+ if (i.length && this._onMuteParticipant({
11261
11339
  muteStates: r.muteStates,
11262
11340
  mediaOptions: i,
11263
11341
  stateUpdated: !0,
11264
11342
  participantId: t
11265
- }), ["ACTIVE", "HELD"].includes(this._state) && L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11343
+ }), ["ACTIVE", "HELD"].includes(this._state)) {
11344
+ if (!r.externalId) {
11345
+ this._reportMissingExternalIds([t], "ACCEPTED_CALL");
11346
+ return;
11347
+ }
11348
+ L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11349
+ }
11266
11350
  }
11267
11351
  async _onHungup(e) {
11268
11352
  this._debug.debug(`Participant hungup [${e.participantId}]`, { reason: e.reason });
@@ -11331,7 +11415,7 @@ var ls = 15, $ = class e extends b {
11331
11415
  return;
11332
11416
  }
11333
11417
  if (!n) {
11334
- let { participant: r } = e, i = r.decorativeUserId;
11418
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11335
11419
  this._registerParticipant({
11336
11420
  id: t,
11337
11421
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11358,7 +11442,7 @@ var ls = 15, $ = class e extends b {
11358
11442
  return;
11359
11443
  }
11360
11444
  if (!n) {
11361
- let { participant: r } = e, i = r.decorativeUserId;
11445
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11362
11446
  this._registerParticipant({
11363
11447
  id: t,
11364
11448
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11401,7 +11485,7 @@ var ls = 15, $ = class e extends b {
11401
11485
  _onParticipantsStateChanged(e) {
11402
11486
  let { participants: t, roomId: n } = e;
11403
11487
  t.map(({ id: e, markers: t }) => this._registerParticipantAndSetMarkersIfChunkEnabled(e, t));
11404
- let r = /* @__PURE__ */ new Map(), i = t.map(({ id: e, participantState: t }) => [e, this._getExternalIdByParticipantId(e) && j.mapParticipantState({ participantState: t })]);
11488
+ let r = /* @__PURE__ */ new Map(), i = t.map(({ id: e, participantState: t }) => [e, this._getExternalIdByParticipantId(e) ? j.mapParticipantState({ participantState: t }) : void 0]);
11405
11489
  try {
11406
11490
  i.forEach(([e, t]) => {
11407
11491
  t && r.set(e, t);
@@ -11800,8 +11884,8 @@ var ls = 15, $ = class e extends b {
11800
11884
  this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
11801
11885
  let r = this._getParticipant(e);
11802
11886
  if (!r) {
11803
- let t = this._api.getDecorativeIdByInitialId(e), n = t ? j.composeUserId(t) : void 0;
11804
- 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);
11887
+ let t = this._api.getDecorativeIdByInitialId(e);
11888
+ this._debug.warn(`Conversation: track added before participant [id: ${e}, decorativeId: ${t}]`), this._registerParticipant({ id: e }, t), r = this._getParticipant(e), this._setParticipantsStatus([r], N.WAITING), this._activeSpeakerId === e && this._lastSignalledActiveSpeakerId !== e && (L.onSpeakerChanged(r.externalId, this.id), this._lastSignalledActiveSpeakerId = e);
11805
11889
  }
11806
11890
  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) {
11807
11891
  if (r.remoteStream = t, r.secondStream) return;
@@ -11911,46 +11995,63 @@ var ls = 15, $ = class e extends b {
11911
11995
  }
11912
11996
  _onRoomsUpdated(e) {
11913
11997
  if (this._isCalledState()) return;
11914
- let t = {};
11915
- for (let n of Object.keys(Ja)) {
11916
- let r = e.updates[n];
11917
- r && (t[n] = {
11918
- rooms: r?.rooms?.map(this._convertRoomToExternal.bind(this)) || [],
11919
- roomIds: r?.roomIds,
11920
- deactivated: r?.deactivated
11998
+ let t = {}, n = [], r = [];
11999
+ for (let i of Object.keys(Ja)) {
12000
+ let a = e.updates[i];
12001
+ a && (a?.rooms?.forEach((e) => {
12002
+ let { room: t, missingParticipantIds: i } = this._convertRoomToExternal(e);
12003
+ t && n.push(t), r.push(...i);
12004
+ }), t[i] = {
12005
+ rooms: n,
12006
+ roomIds: a?.roomIds,
12007
+ deactivated: a?.deactivated
11921
12008
  });
11922
12009
  }
11923
- L.onRoomsUpdated(t, this.id);
12010
+ this._reportMissingExternalIds(r, "ROOMS_UPDATED"), L.onRoomsUpdated(t, this.id);
11924
12011
  }
11925
12012
  _onRoomUpdated(e) {
11926
- let t = this._convertRoomToExternal(e.room || null);
11927
- e.events.some((e) => e === Ja.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);
12013
+ let { room: t, missingParticipantIds: n } = this._convertRoomToExternal(e.room || null);
12014
+ e.events.some((e) => e === Ja.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() || (this._reportMissingExternalIds(n, "ROOM_UPDATED"), L.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id));
11928
12015
  }
11929
12016
  _convertRoomToExternal(e) {
11930
- if (!e) return null;
11931
- 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;
12017
+ if (!e) return {
12018
+ room: null,
12019
+ missingParticipantIds: []
12020
+ };
12021
+ let t = [], { externalIds: n, missingIds: r } = this._getExternalIdsByParticipantIds(e.participantIds ?? []), { externalIds: i, missingIds: a } = this._getExternalIdsByParticipantIds(e.addParticipantIds ?? []), { externalIds: o, missingIds: s } = this._getExternalIdsByParticipantIds(e.removeParticipantIds ?? []);
12022
+ t.push(...r, ...a, ...s);
12023
+ let c;
12024
+ if (e.pinnedParticipantId) {
12025
+ let n = this._getExternalIdByParticipantId(e.pinnedParticipantId);
12026
+ n ? c = n : t.push(e.pinnedParticipantId);
12027
+ }
11932
12028
  return {
11933
- id: e.id,
11934
- name: e.name,
11935
- participantCount: e.participantCount,
11936
- participantIds: t,
11937
- addParticipantIds: n,
11938
- removeParticipantIds: r,
11939
- participants: e.participants?.participants ? this._participantListChunkToExternalChunk(e.participants) : void 0,
11940
- active: e.active,
11941
- muteStates: e.muteStates,
11942
- pinnedParticipantId: i,
11943
- countdownSec: e.countdownSec,
11944
- timeoutMs: e.timeoutMs
12029
+ room: {
12030
+ id: e.id,
12031
+ name: e.name,
12032
+ participantCount: e.participantCount,
12033
+ participantIds: n,
12034
+ addParticipantIds: i,
12035
+ removeParticipantIds: o,
12036
+ participants: e.participants?.participants ? this._participantListChunkToExternalChunk(e.participants) : void 0,
12037
+ active: e.active,
12038
+ muteStates: e.muteStates,
12039
+ pinnedParticipantId: c,
12040
+ countdownSec: e.countdownSec,
12041
+ timeoutMs: e.timeoutMs
12042
+ },
12043
+ missingParticipantIds: t
11945
12044
  };
11946
12045
  }
11947
12046
  async _onRoomParticipantsUpdated(e) {
11948
- let t = this._transport?.getState(), n = e.roomId ?? null, r = e.addedParticipantIds?.map((e) => j.decomposeId(e).id) || [], i = this._getExternalIdsByOkIdsFromCache(r), a = e.addedParticipants;
11949
- if (i.length && a?.length !== i.length && !this._isCalledState()) {
12047
+ let t = this._transport?.getState(), n = e.roomId ?? null, r = [], { externalIds: i, missingIds: a } = this._getExternalIdsByParticipantIds(e.addedParticipantIds ?? []);
12048
+ r.push(...a);
12049
+ let o = e.addedParticipants;
12050
+ if (i.length && o?.length !== i.length && !this._isCalledState()) {
11950
12051
  let e = this._convertExternalIdsToServerExternalIds(i);
11951
- a = (await this._signaling.getParticipants(e)).participants;
12052
+ o = (await this._signaling.getParticipants(e)).participants;
11952
12053
  }
11953
- let o = a?.map((e) => {
12054
+ let s = o?.map((e) => {
11954
12055
  let r = j.composeId(e);
11955
12056
  return this._createParticipant({
11956
12057
  id: r,
@@ -11966,38 +12067,38 @@ var ls = 15, $ = class e extends b {
11966
12067
  observedIds: e.observedIds || [],
11967
12068
  markers: this._denormalizeMarkers(r, e.markers),
11968
12069
  isInRoom: n !== null
11969
- }, e.decorativeUserId);
11970
- }) || [], s = !1;
11971
- for (let e of o) e.id === this._conversation?.compositeUserId && (s = !0), this._registerParticipantInCache(e);
11972
- this._transport?.getState() === q.IDLE && !this._isCalledState() && this._openTransport(o, !0);
11973
- let c = [];
12070
+ }, j.composeDecorativeId(e));
12071
+ }) || [], c = !1;
12072
+ for (let e of s) e.id === this._conversation?.compositeUserId && (c = !0), this._registerParticipantInCache(e);
12073
+ this._transport?.getState() === q.IDLE && !this._isCalledState() && this._openTransport(s, !0);
12074
+ let l = [];
11974
12075
  if (e?.removedParticipantMarkers) {
11975
12076
  for (let t of e.removedParticipantMarkers) if (t.GRID?.id) {
11976
12077
  let e = this._getExternalIdByParticipantId(t.GRID.id);
11977
- c.push(e);
12078
+ e ? l.push(e) : r.push(t.GRID.id);
11978
12079
  }
11979
12080
  }
11980
- if (s && await this._onRoomSwitched(n), c) {
12081
+ if (this._reportMissingExternalIds(r, "ROOM_PARTICIPANTS_UPDATED"), c && await this._onRoomSwitched(n), l) {
11981
12082
  let e = this._conversation?.pinnedParticipantIdByRoom.get(n);
11982
12083
  if (e) {
11983
12084
  let t = this._getExternalIdByParticipantId(e);
11984
12085
  if (t) {
11985
- for (let e of c) if (Q.compare(t, e)) {
12086
+ for (let e of l) if (Q.compare(t, e)) {
11986
12087
  this._conversation?.pinnedParticipantIdByRoom.delete(n);
11987
12088
  break;
11988
12089
  }
11989
12090
  }
11990
12091
  }
11991
12092
  }
11992
- let l = {
12093
+ let u = {
11993
12094
  roomId: n,
11994
12095
  participantCount: e.participantCount,
11995
12096
  addedParticipantIds: i,
11996
- addedParticipants: j.mapSharedParticipants(o),
12097
+ addedParticipants: j.mapSharedParticipants(s),
11997
12098
  removedParticipantMarkers: e?.removedParticipantMarkers,
11998
- removedParticipantIds: c
12099
+ removedParticipantIds: l
11999
12100
  };
12000
- this._isCalledState() || L.onRoomParticipantsUpdated(l, this.id);
12101
+ this._isCalledState() || L.onRoomParticipantsUpdated(u, this.id);
12001
12102
  }
12002
12103
  async _onRoomSwitched(e, t = !1) {
12003
12104
  if (!this._conversation || this._conversation.roomId === e) return;
@@ -12017,7 +12118,7 @@ var ls = 15, $ = class e extends b {
12017
12118
  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) {
12018
12119
  let e = this._participants;
12019
12120
  await this._registerParticipants(t?.participants?.participants?.filter((t) => !e[j.composeId(t)]) || [], !0);
12020
- let n = this._convertRoomToExternal(t);
12121
+ let { room: n } = this._convertRoomToExternal(t);
12021
12122
  n && r.push(n);
12022
12123
  }
12023
12124
  }
@@ -12051,7 +12152,9 @@ var ls = 15, $ = class e extends b {
12051
12152
  return;
12052
12153
  }
12053
12154
  let o = Q.fromSignaling(r, a.deviceIdx);
12054
- if (L.onParticipantIdChanged(a, o, this.id), this._api.cacheExternalId(n, o), this._api.mapDecorativeId(n, t), i) this._conversation.externalId = o;
12155
+ L.onParticipantIdChanged(a, o, this.id);
12156
+ let s = j.compose(n, a.deviceIdx), c = j.compose(t, a.deviceIdx);
12157
+ if (this._api.cacheExternalId(s, o), this._api.mapDecorativeId(s, c), i) this._conversation.externalId = o;
12055
12158
  else {
12056
12159
  let e = this._participants;
12057
12160
  e[t].externalId = o;
@@ -12223,22 +12326,16 @@ var Es = class {
12223
12326
  }
12224
12327
  log(e) {}
12225
12328
  logClientStats(e) {}
12226
- getCachedOkIdByExternalId(e) {
12329
+ getCachedParticipantIdByExternalId(e) {
12227
12330
  return null;
12228
12331
  }
12229
- getCachedRawOkIdByExternalId(e) {
12230
- return null;
12231
- }
12232
- getCachedExternalIdByOkId(e) {
12332
+ getCachedExternalIdByParticipantId(e) {
12233
12333
  return null;
12234
12334
  }
12235
12335
  cacheExternalId(e, t) {}
12236
12336
  mapDecorativeId(e, t) {}
12237
12337
  unmapDecorativeId(e) {}
12238
12338
  getDecorativeIdByInitialId(e) {}
12239
- replaceByInitialIdIdIfExists(e) {
12240
- return typeof e == "string" ? parseInt(e, 10) : e;
12241
- }
12242
12339
  hangupConversation(e, t = D.HUNGUP, n) {}
12243
12340
  async removeHistoryRecords(e) {}
12244
12341
  async getServerTime() {
@@ -12250,7 +12347,7 @@ var Es = class {
12250
12347
  }
12251
12348
  }, Ds = class e {
12252
12349
  constructor() {
12253
- h(this, "_okIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToOkId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12350
+ h(this, "_participantIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToParticipantId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12254
12351
  }
12255
12352
  static _normalizeType(e) {
12256
12353
  return e.type === to.GROUP ? {
@@ -12258,46 +12355,30 @@ var Es = class {
12258
12355
  type: to.USER
12259
12356
  } : e;
12260
12357
  }
12261
- getOkId(t) {
12262
- let n = Q.toString(e._normalizeType(t)), r = this._externalIdToOkId.get(n);
12263
- return r == null ? null : this.replaceByInitialIdIdIfExists(r);
12264
- }
12265
12358
  getExternalId(e) {
12266
- let t = this.getDecorativeIdByInitialId(e) ?? e, n = this._okIdToExternalId.get(t);
12359
+ let t = this._initialIdToDecorativeId.get(e) ?? e, n = this._participantIdToExternalId.get(t);
12267
12360
  return n == null ? null : Q.fromString(n);
12268
12361
  }
12269
- hasByExternalId(t) {
12270
- return this._externalIdToOkId.has(Q.toString(e._normalizeType(t)));
12271
- }
12272
- hasByOkId(e) {
12273
- return this._okIdToExternalId.has(e);
12362
+ getParticipantId(t) {
12363
+ let n = Q.toString(e._normalizeType(t)), r = this._externalIdToParticipantId.get(n);
12364
+ return r == null ? null : this._decorativeIdToInitialId.get(r) ?? r;
12274
12365
  }
12275
12366
  cache(t, n) {
12276
- let r = j.extractOkId(t), i = e._normalizeType(n), a = Q.toString(i);
12277
- this._okIdToExternalId.set(r, a), this._externalIdToOkId.set(a, r);
12367
+ let r = e._normalizeType(n), i = Q.toString(r);
12368
+ this._participantIdToExternalId.set(t, i), this._externalIdToParticipantId.set(i, t);
12278
12369
  }
12279
12370
  mapDecorativeId(e, t) {
12280
- let n = j.extractOkId(e), r = j.extractOkId(t);
12281
- this._decorativeIdToInitialId.set(n, r), this._initialIdToDecorativeId.set(r, n);
12371
+ this._decorativeIdToInitialId.set(e, t), this._initialIdToDecorativeId.set(t, e);
12282
12372
  }
12283
12373
  unmapDecorativeId(e) {
12284
- let t = j.extractOkId(e), n = this.getDecorativeIdByInitialId(t);
12285
- n && this._decorativeIdToInitialId.delete(n), this._initialIdToDecorativeId.delete(t);
12374
+ let t = this._initialIdToDecorativeId.get(e);
12375
+ t && this._decorativeIdToInitialId.delete(t), this._initialIdToDecorativeId.delete(e);
12286
12376
  }
12287
12377
  getDecorativeIdByInitialId(e) {
12288
- let t = j.extractOkId(e);
12289
- return this._initialIdToDecorativeId.get(t);
12290
- }
12291
- replaceByInitialIdIdIfExists(e) {
12292
- let t = j.extractOkId(e);
12293
- return this._decorativeIdToInitialId.get(t) ?? t;
12294
- }
12295
- getParticipantIdByExternalId(e) {
12296
- let t = this.getOkId(e);
12297
- return t == null ? null : j.composeParticipantId(t, A.USER, e.deviceIdx ?? 0);
12378
+ return this._initialIdToDecorativeId.get(e);
12298
12379
  }
12299
12380
  clear() {
12300
- this._okIdToExternalId.clear(), this._externalIdToOkId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12381
+ this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12301
12382
  }
12302
12383
  }, Os = "anonymLogin:", ks = 700, As = 3e3;
12303
12384
  function js(e) {
@@ -12385,8 +12466,11 @@ var Ps = class extends Es {
12385
12466
  }
12386
12467
  }
12387
12468
  userId(e) {
12388
- let { compositeUserId: t } = j.decomposeParticipantId(e), { id: n } = j.decomposeId(t);
12389
- return y.isEmpty() ? Q.fromId(String(n)) : this._idCache.getExternalId(n) || Q.fromId(String(n));
12469
+ if (y.isEmpty()) {
12470
+ let { compositeUserId: t } = j.decomposeParticipantId(e), { id: n } = j.decomposeId(t);
12471
+ return Q.fromId(String(n));
12472
+ }
12473
+ return this._idCache.getExternalId(e);
12390
12474
  }
12391
12475
  async authorize() {
12392
12476
  if (this._ensureUuid(), !M.apiKey) throw new O(x.API, {
@@ -12574,13 +12658,10 @@ var Ps = class extends Es {
12574
12658
  };
12575
12659
  return n?.length && (i.observedIds = n.join(",")), M.anonymToken && (i.anonymToken = M.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
12576
12660
  }
12577
- getCachedOkIdByExternalId(e) {
12578
- return this._idCache.getParticipantIdByExternalId(e);
12661
+ getCachedParticipantIdByExternalId(e) {
12662
+ return this._idCache.getParticipantId(e);
12579
12663
  }
12580
- getCachedRawOkIdByExternalId(e) {
12581
- return this._idCache.getOkId(e);
12582
- }
12583
- getCachedExternalIdByOkId(e) {
12664
+ getCachedExternalIdByParticipantId(e) {
12584
12665
  return this._idCache.getExternalId(e);
12585
12666
  }
12586
12667
  cacheExternalId(e, t) {
@@ -12595,9 +12676,6 @@ var Ps = class extends Es {
12595
12676
  getDecorativeIdByInitialId(e) {
12596
12677
  return this._idCache.getDecorativeIdByInitialId(e);
12597
12678
  }
12598
- replaceByInitialIdIdIfExists(e) {
12599
- return this._idCache.replaceByInitialIdIdIfExists(e);
12600
- }
12601
12679
  async getConversationParams(e) {
12602
12680
  let t = {};
12603
12681
  return M.anonymToken && (t.anonymToken = M.anonymToken), e && (t.conversationId = e), this._call("vchat.getConversationParams", t);
@@ -12747,10 +12825,16 @@ async function Xs(t) {
12747
12825
  }
12748
12826
  async function Zs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12749
12827
  let c = [];
12750
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Qs([], Va.USER, t, n, r, i, a, c, o, s);
12828
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), $s([], Va.USER, t, n, r, i, a, c, o, s);
12751
12829
  }
12752
- async function Qs(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12753
- if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12830
+ function Qs(e, t = []) {
12831
+ let n = e.getIncomingCallerExternalId();
12832
+ return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
12833
+ }
12834
+ async function $s(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12835
+ if (!M.hold && z.getActive()) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12836
+ let u = z.getAll().find((e) => e.isIncomingRinging);
12837
+ if (!M.hold && u && !Qs(u, s)) throw R.error("There is already incoming call"), new O(D.HAS_ACTIVE_CALL);
12754
12838
  return new $(new Ps(), Hs).onStart({
12755
12839
  opponentIds: e,
12756
12840
  opponentType: t,
@@ -12764,30 +12848,30 @@ async function Qs(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12764
12848
  conversationId: l
12765
12849
  });
12766
12850
  }
12767
- async function $s(e, t) {
12768
- return ec(e, A.USER, void 0, t);
12851
+ async function ec(e, t) {
12852
+ return tc(e, A.USER, void 0, t);
12769
12853
  }
12770
- async function ec(e, t = A.USER, n, r, i, a) {
12854
+ async function tc(e, t = A.USER, n, r, i, a) {
12771
12855
  if (e === $.id()) throw Error("Push has already been processed");
12772
12856
  return new $(new Ps(), Hs).onPush(e, t, n, r, i, a);
12773
12857
  }
12774
- async function tc() {
12858
+ async function nc() {
12775
12859
  return Vs.getInbounds();
12776
12860
  }
12777
- async function nc(e, t) {
12861
+ async function rc(e, t) {
12778
12862
  return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, hs()), Vs.authorize();
12779
12863
  }
12780
- async function rc(e = [S.AUDIO], t) {
12781
- return El(t).accept(e);
12864
+ async function ic(e = [S.AUDIO], t) {
12865
+ return kl(t).accept(e);
12782
12866
  }
12783
- async function ic(e) {
12784
- let t = Tl(e?.conversationId);
12867
+ async function ac(e) {
12868
+ let t = El(e?.conversationId);
12785
12869
  if (t) return t.decline(e);
12786
12870
  }
12787
- async function ac(e, t = [S.AUDIO]) {
12788
- return oc(e, t);
12871
+ async function oc(e, t = [S.AUDIO]) {
12872
+ return sc(e, t);
12789
12873
  }
12790
- async function oc(e, t, n) {
12874
+ async function sc(e, t, n) {
12791
12875
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12792
12876
  return new $(new Ps(), Hs).onJoin({
12793
12877
  conversationId: e,
@@ -12795,7 +12879,7 @@ async function oc(e, t, n) {
12795
12879
  chatId: n
12796
12880
  });
12797
12881
  }
12798
- async function sc(e, t = [S.AUDIO], n, r, i, a) {
12882
+ async function cc(e, t = [S.AUDIO], n, r, i, a) {
12799
12883
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12800
12884
  return n && (M.anonymToken = n), new $(new Ps(), Hs).onJoin({
12801
12885
  joinLink: e,
@@ -12806,30 +12890,30 @@ async function sc(e, t = [S.AUDIO], n, r, i, a) {
12806
12890
  anonymous: !!M.anonymToken
12807
12891
  });
12808
12892
  }
12809
- function cc(e) {
12810
- let t = Tl(e?.conversationId);
12893
+ function lc(e) {
12894
+ let t = El(e?.conversationId);
12811
12895
  return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
12812
12896
  }
12813
- async function lc(e, t) {
12897
+ async function uc(e, t) {
12814
12898
  let n = Array.isArray(e) ? e : [e], r = $.current();
12815
12899
  r && await r.addParticipant(n, t);
12816
12900
  }
12817
- async function uc(e, t) {
12901
+ async function dc(e, t) {
12818
12902
  let n = $.current();
12819
12903
  if (n) {
12820
12904
  let r = e.map((e) => j.composeUserId(e));
12821
12905
  await n.addParticipantLegacy(r, t);
12822
12906
  }
12823
12907
  }
12824
- async function dc(e, t = !1) {
12825
- let n = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12826
- if (!n) {
12827
- R.warn("removeParticipant: externalId not found in cache", e);
12828
- return;
12908
+ async function fc(e, t = !1) {
12909
+ let n = Al(e, "removeParticipant");
12910
+ if (n) try {
12911
+ await n.conversation.removeParticipant(j.decomposeParticipantId(n.participantId).compositeUserId, t);
12912
+ } catch (e) {
12913
+ R.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
12829
12914
  }
12830
- return fc(n, t);
12831
12915
  }
12832
- async function fc(e, t = !1) {
12916
+ async function pc(e, t = !1) {
12833
12917
  let n = $.current();
12834
12918
  if (n) try {
12835
12919
  await n.removeParticipant(j.composeUserId(e), t);
@@ -12837,13 +12921,13 @@ async function fc(e, t = !1) {
12837
12921
  R.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
12838
12922
  }
12839
12923
  }
12840
- async function pc(e, t) {
12924
+ async function mc(e, t) {
12841
12925
  let n = $.current();
12842
12926
  if (e === "videoinput" && jt.contains(t)) return M.videoFacingMode = t, n ? (T.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
12843
12927
  if (!await T._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
12844
12928
  if (n) return n.changeDevice(e);
12845
12929
  }
12846
- async function mc(e, t) {
12930
+ async function hc(e, t) {
12847
12931
  let n = typeof e == "object" ? {
12848
12932
  ...e,
12849
12933
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -12852,151 +12936,149 @@ async function mc(e, t) {
12852
12936
  captureScreen: e,
12853
12937
  fastScreenSharing: !1,
12854
12938
  captureAudio: !1
12855
- }, r = Tl(t);
12939
+ }, r = El(t);
12856
12940
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
12857
12941
  }
12858
- function hc(e) {
12942
+ function gc(e) {
12859
12943
  let t = $.current();
12860
12944
  t && t.toggleAnimojiCapturing(e);
12861
12945
  }
12862
- async function gc(e, t = !1) {
12946
+ async function _c(e, t = !1) {
12863
12947
  let n = $.current();
12864
12948
  n && await n.setVideoStream(e, t);
12865
12949
  }
12866
- async function _c(e, t) {
12867
- let n = Tl(t);
12950
+ async function vc(e, t) {
12951
+ let n = El(t);
12868
12952
  n && await n.toggleLocalVideo(e);
12869
12953
  }
12870
- async function vc(e, t) {
12871
- let n = Tl(t);
12954
+ async function yc(e, t) {
12955
+ let n = El(t);
12872
12956
  n && await n.toggleLocalAudio(e);
12873
12957
  }
12874
- async function yc(e) {
12958
+ async function bc(e) {
12875
12959
  let t = $.current();
12876
12960
  if (t) return t.setLocalResolution(e);
12877
12961
  }
12878
- async function bc(e) {
12962
+ async function xc(e) {
12879
12963
  let t = $.current();
12880
12964
  t && await t.changePriorities(e);
12881
12965
  }
12882
- async function xc(e, t) {
12966
+ async function Sc(e, t) {
12883
12967
  let n = $.current();
12884
12968
  if (n) {
12885
- let r;
12886
12969
  if (t) {
12887
- let e = n.getCachedRawOkIdByExternalId(t);
12888
- if (!e) {
12889
- R.warn("changeParticipantState: externalId not found in cache", t);
12970
+ let r = n.getCachedParticipantIdByExternalId(t);
12971
+ if (!r) {
12972
+ Dl(t, "changeParticipantState", n);
12890
12973
  return;
12891
12974
  }
12892
- r = j.composeParticipantId(e, A.USER, t.deviceIdx);
12975
+ await n.changeParticipantState(e, r);
12976
+ return;
12893
12977
  }
12894
- await n.changeParticipantState(e, r);
12978
+ await n.changeParticipantState(e);
12895
12979
  }
12896
12980
  }
12897
- async function Sc() {
12981
+ async function Cc() {
12898
12982
  let e = $.current();
12899
12983
  e && await e.putHandsDown();
12900
12984
  }
12901
- async function Cc(e) {
12985
+ async function wc(e) {
12902
12986
  let t = $.current();
12903
12987
  t && await t.updateDisplayLayout(e);
12904
12988
  }
12905
- async function wc(e) {
12989
+ async function Tc(e) {
12906
12990
  let t = $.current();
12907
12991
  t && await t.requestDisplayLayout(e);
12908
12992
  }
12909
- async function Tc(e, t, n = !1) {
12910
- let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12911
- if (!r) {
12912
- R.warn("grantRoles: externalId not found in cache", e);
12913
- return;
12914
- }
12915
- return Ec(r, Q.getDeviceIdx(e), t, n);
12993
+ async function Ec(e, t, n = !1) {
12994
+ let r = Al(e, "grantRoles");
12995
+ r && await r.conversation.grantRoles(r.participantId, t, n);
12916
12996
  }
12917
- async function Ec(e, t, n, r = !1) {
12997
+ async function Dc(e, t, n, r = !1) {
12918
12998
  let i = $.current();
12919
12999
  i && await i.grantRoles(j.composeParticipantId(e, A.USER, t), n, r);
12920
13000
  }
12921
- async function Dc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12922
- let i = null;
12923
- return e && (i = $.current()?.getCachedRawOkIdByExternalId(e) ?? null, i || R.warn("muteParticipant: externalId not found in cache", e)), Oc({
12924
- uid: i,
12925
- muteStates: t,
12926
- requestedMedia: n,
12927
- deviceIdx: Q.getDeviceIdx(e),
12928
- roomId: r
12929
- });
13001
+ async function Oc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
13002
+ if (e) {
13003
+ let i = Al(e, "muteParticipant");
13004
+ return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
13005
+ }
13006
+ let i = $.current();
13007
+ i && await i.muteParticipant(null, t, n, r);
12930
13008
  }
12931
- async function Oc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
13009
+ async function kc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12932
13010
  let a = $.current();
12933
13011
  if (a) {
12934
13012
  let o = e ? j.composeParticipantId(e, A.USER, r) : null;
12935
13013
  await a.muteParticipant(o, t, n, i);
12936
13014
  }
12937
13015
  }
12938
- async function kc(e, t = !1, n = null) {
12939
- let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12940
- if (!r) {
12941
- R.warn("pinParticipant: externalId not found in cache", e);
12942
- return;
12943
- }
12944
- return Ac(r, t, Q.getDeviceIdx(e), n);
13016
+ async function Ac(e, t = !1, n = null) {
13017
+ let r = Al(e, "pinParticipant");
13018
+ r && await r.conversation.pinParticipant(r.participantId, t, n);
12945
13019
  }
12946
- async function Ac(e, t = !1, n = 0, r = null) {
13020
+ async function jc(e, t = !1, n = 0, r = null) {
12947
13021
  let i = $.current();
12948
13022
  i && await i.pinParticipant(j.composeParticipantId(e, A.USER, n), t, r);
12949
13023
  }
12950
- async function jc(e) {
13024
+ async function Mc(e) {
12951
13025
  let t = $.current();
12952
13026
  t && await t.updateMediaModifiers(e);
12953
13027
  }
12954
- async function Mc(e) {
13028
+ async function Nc(e) {
12955
13029
  let t = $.current();
12956
13030
  t && await t.enableVideoSuspend(e);
12957
13031
  }
12958
- async function Nc(e) {
13032
+ async function Pc(e) {
12959
13033
  let t = $.current();
12960
13034
  t && await t.enableVideoSuspendSuggest(e);
12961
13035
  }
12962
- async function Pc(e) {
13036
+ async function Fc(e) {
12963
13037
  let t = $.current();
12964
13038
  t && await t.changeOptions(e);
12965
13039
  }
12966
- async function Fc(e, t = null) {
12967
- let n = null;
12968
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("chatMessage: externalId not found in cache", t)), Ic(e, n);
12969
- }
12970
13040
  async function Ic(e, t = null) {
13041
+ if (t) {
13042
+ let n = Al(t, "chatMessage");
13043
+ return n ? n.conversation.chatMessage(e, j.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
13044
+ }
13045
+ let n = $.current();
13046
+ n && await n.chatMessage(e, null);
13047
+ }
13048
+ async function Lc(e, t = null) {
12971
13049
  let n = $.current();
12972
13050
  if (n) {
12973
13051
  let r = t ? j.composeUserId(t) : null;
12974
13052
  await n.chatMessage(e, r);
12975
13053
  }
12976
13054
  }
12977
- async function Lc(e = 10) {
13055
+ async function Rc(e = 10) {
12978
13056
  let t = $.current();
12979
13057
  if (t) return t.chatHistory(e);
12980
13058
  }
12981
- async function Rc(e, t = null) {
12982
- let n = null;
12983
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("customData: externalId not found in cache", t)), zc(e, n, Q.getDeviceIdx(t));
13059
+ async function zc(e, t = null) {
13060
+ if (t) {
13061
+ let n = Al(t, "customData");
13062
+ return n ? n.conversation.customData(e, n.participantId) : void 0;
13063
+ }
13064
+ let n = $.current();
13065
+ n && await n.customData(e, null);
12984
13066
  }
12985
- async function zc(e, t = null, n = 0) {
13067
+ async function Bc(e, t = null, n = 0) {
12986
13068
  let r = $.current();
12987
13069
  if (r) {
12988
13070
  let i = t ? j.composeParticipantId(t, A.USER, n) : null;
12989
13071
  await r.customData(e, i);
12990
13072
  }
12991
13073
  }
12992
- async function Bc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
13074
+ async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12993
13075
  return (await Vs.createConversation(a ?? j.uuid(), e, t, {
12994
13076
  onlyAdminCanShareMovie: n,
12995
13077
  waitForAdmin: r,
12996
13078
  closedConversation: i
12997
13079
  })).join_link;
12998
13080
  }
12999
- async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13081
+ async function Hc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13000
13082
  let a = i.map((e) => Q.fromId(e));
13001
13083
  return (await Vs.createConversation(j.uuid(), e, t, {
13002
13084
  onlyAdminCanShareMovie: n,
@@ -13004,115 +13086,114 @@ async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r
13004
13086
  audioOnly: r
13005
13087
  }, a)).join_link;
13006
13088
  }
13007
- async function Hc() {
13089
+ async function Uc() {
13008
13090
  let e = $.current();
13009
13091
  return e ? e.createJoinLink() : Promise.reject();
13010
13092
  }
13011
- async function Uc() {
13093
+ async function Wc() {
13012
13094
  let e = $.current();
13013
13095
  return e ? e.removeJoinLink() : Promise.reject();
13014
13096
  }
13015
- async function Wc(e, t) {
13097
+ async function Gc(e, t) {
13016
13098
  return Vs.getAnonymTokenByLink(e, t);
13017
13099
  }
13018
- function Gc(e) {
13100
+ function Kc(e) {
13019
13101
  let t = $.current();
13020
13102
  t && t.setVolume(e);
13021
13103
  }
13022
- function Kc(e) {
13104
+ function qc(e) {
13023
13105
  M.forceRelayPolicy = e;
13024
13106
  }
13025
- async function qc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13107
+ async function Jc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13026
13108
  let o = $.current();
13027
13109
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
13028
13110
  }
13029
- async function Jc(e = null, t) {
13111
+ async function Yc(e = null, t) {
13030
13112
  let n = $.current();
13031
13113
  return n ? n.stopStream(e, t) : Promise.reject();
13032
13114
  }
13033
- async function Yc(e = null) {
13115
+ async function Xc(e = null) {
13034
13116
  let t = $.current();
13035
13117
  return t ? t.publishStream(e) : Promise.reject();
13036
13118
  }
13037
- async function Xc() {
13119
+ async function Zc() {
13038
13120
  let e = $.current();
13039
13121
  return e ? e.getStreamInfo() : Promise.reject();
13040
13122
  }
13041
- async function Zc(e) {
13123
+ async function Qc(e) {
13042
13124
  let t = $.current();
13043
13125
  return t ? t.addMovie(e) : Promise.reject();
13044
13126
  }
13045
- async function Qc(e) {
13127
+ async function $c(e) {
13046
13128
  let t = $.current();
13047
13129
  return t ? t.updateMovie(e) : Promise.reject();
13048
13130
  }
13049
- async function $c(e) {
13131
+ async function el(e) {
13050
13132
  let t = $.current();
13051
13133
  return t ? t.removeMovie(e) : Promise.reject();
13052
13134
  }
13053
- async function el(e, t) {
13135
+ async function tl(e, t) {
13054
13136
  let n = $.current();
13055
13137
  if (n) {
13056
- let r = [];
13138
+ let r = [], i = [];
13057
13139
  for (let t of e) {
13058
- let e, i;
13140
+ let e, a;
13059
13141
  t.addParticipantIds && (e = [], t.addParticipantIds.forEach((t) => {
13060
- let r = n.getCachedRawOkIdByExternalId(t);
13061
- r ? e.push(j.composeUserId(r)) : R.warn("updateRooms addParticipant: externalId not found in cache", t);
13062
- })), t.removeParticipantIds && (i = [], t.removeParticipantIds.forEach((e) => {
13063
- let t = n.getCachedRawOkIdByExternalId(e);
13064
- t ? i.push(j.composeUserId(t)) : R.warn("updateRooms removeParticipant: externalId not found in cache", e);
13142
+ let r = n.getCachedParticipantIdByExternalId(t);
13143
+ r ? e.push(j.decomposeParticipantId(r).compositeUserId) : i.push(t.id);
13144
+ })), t.removeParticipantIds && (a = [], t.removeParticipantIds.forEach((e) => {
13145
+ let t = n.getCachedParticipantIdByExternalId(e);
13146
+ t ? a.push(j.decomposeParticipantId(t).compositeUserId) : i.push(e.id);
13065
13147
  })), r.push({
13066
13148
  id: t.id,
13067
13149
  name: t.name,
13068
13150
  participantCount: t.participantCount,
13069
13151
  addParticipantIds: e,
13070
- removeParticipantIds: i,
13152
+ removeParticipantIds: a,
13071
13153
  countdownSec: t.countdownSec
13072
13154
  });
13073
13155
  }
13156
+ if (i.length) {
13157
+ Ol(i, "updateRooms", n);
13158
+ return;
13159
+ }
13074
13160
  return n.updateRooms(r, t);
13075
13161
  }
13076
13162
  return Promise.reject();
13077
13163
  }
13078
- async function tl(e, t) {
13164
+ async function nl(e, t) {
13079
13165
  let n = $.current();
13080
13166
  return n ? n.activateRooms(e, t) : Promise.reject();
13081
13167
  }
13082
- async function nl(e = null, t = null) {
13168
+ async function rl(e = null, t = null) {
13083
13169
  let n = $.current();
13084
13170
  if (!n) return Promise.reject();
13085
13171
  let r;
13086
- if (t) {
13087
- let e = n.getCachedRawOkIdByExternalId(t);
13088
- if (!e) {
13089
- R.warn("switchRoom: externalId not found in cache", t);
13090
- return;
13091
- }
13092
- let i = Q.getDeviceIdx(t);
13093
- r = j.composeParticipantId(e, A.USER, i);
13172
+ if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
13173
+ Dl(t, "switchRoom", n);
13174
+ return;
13094
13175
  }
13095
13176
  return n.switchRoom(e, r);
13096
13177
  }
13097
- async function rl(e) {
13178
+ async function il(e) {
13098
13179
  let t = $.current();
13099
13180
  return t ? t.removeRooms(e) : Promise.reject();
13100
13181
  }
13101
- function il(e) {
13182
+ function al(e) {
13102
13183
  M.statisticsInterval = e;
13103
13184
  let t = $.current();
13104
13185
  if (t) return t.updateStatisticsInterval();
13105
13186
  }
13106
- function al(t) {
13187
+ function ol(t) {
13107
13188
  e.disableLog(!t), R.toggle(t);
13108
13189
  }
13109
- function ol(e, ...t) {
13190
+ function sl(e, ...t) {
13110
13191
  M.debugLog && ($.debugMessage(e, "[external]", ...t) || R.send(e, "[external]", ...t));
13111
13192
  }
13112
- function sl(e, t, ...n) {
13193
+ function cl(e, t, ...n) {
13113
13194
  M.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || R.send(e, "[external]", ...n));
13114
13195
  }
13115
- var cl = {
13196
+ var ll = {
13116
13197
  list: Ne,
13117
13198
  get: Pe,
13118
13199
  getJson: Fe,
@@ -13120,7 +13201,7 @@ var cl = {
13120
13201
  clear: Le,
13121
13202
  stats: Re
13122
13203
  };
13123
- function ll() {
13204
+ function ul() {
13124
13205
  let e = [
13125
13206
  [`Calls SDK ${M.sdkVersion}`, M.toJSON()],
13126
13207
  ["UserAgent:", navigator.userAgent],
@@ -13137,124 +13218,139 @@ function ll() {
13137
13218
  d: e
13138
13219
  }));
13139
13220
  }
13140
- async function ul() {
13221
+ async function dl() {
13141
13222
  let e = $.id(), t = $.debugSessionId();
13142
13223
  if (!t || !e) throw R.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
13143
13224
  let n = await Pe({ sessionId: t });
13144
13225
  if (n.length === 0) throw R.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
13145
13226
  let r = n[0].t, i = n[n.length - 1].t;
13146
13227
  try {
13147
- return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ll(), ...n]));
13228
+ return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ul(), ...n]));
13148
13229
  } catch (e) {
13149
13230
  throw R.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
13150
13231
  }
13151
13232
  }
13152
- async function dl(e) {
13233
+ async function fl(e) {
13153
13234
  let t = $.current();
13154
13235
  if (t) return t.videoEffect(e);
13155
13236
  }
13156
- async function fl(e, t) {
13237
+ async function pl(e, t) {
13157
13238
  let n = $.current();
13158
13239
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
13159
13240
  }
13160
- async function pl(e) {
13241
+ async function ml(e) {
13161
13242
  let t = $.current();
13162
13243
  t && await t.setAudioStream(e);
13163
13244
  }
13164
- async function ml(e, t = null, n = null) {
13245
+ async function hl(e, t = null, n = null) {
13165
13246
  let r = $.current();
13166
13247
  if (!r) return;
13167
13248
  let i = n ?? t?.id, a = null;
13168
- if (t) {
13169
- let e = r.getCachedRawOkIdByExternalId(t);
13170
- if (!e) throw Error("Could not get user id to set animoji svg");
13171
- a = j.composeParticipantId(e, A.USER, Q.getDeviceIdx(t));
13249
+ if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
13250
+ Dl(t, "setVmojiSvg", r);
13251
+ return;
13172
13252
  }
13173
13253
  r.setAnimojiSvg(e, a, i);
13174
13254
  }
13175
- function hl(e) {
13255
+ function gl(e) {
13176
13256
  let t = $.current();
13177
13257
  t && t.setAnimojiFill(e);
13178
13258
  }
13179
- async function gl(e = null, t, n = !1) {
13180
- return El().getWaitingHall(e, t, n);
13259
+ async function _l(e = null, t, n = !1) {
13260
+ return kl().getWaitingHall(e, t, n);
13181
13261
  }
13182
- async function _l() {
13183
- return El().getAudienceModeHands();
13262
+ async function vl() {
13263
+ return kl().getAudienceModeHands();
13184
13264
  }
13185
- async function vl(e, t = !1) {
13186
- let n = El(), r;
13265
+ async function yl(e, t = !1) {
13266
+ let n = kl(), r;
13187
13267
  if (e) {
13188
- let t = n.getCachedRawOkIdByExternalId(e);
13268
+ let t = n.getCachedParticipantIdByExternalId(e);
13189
13269
  if (!t) {
13190
- R.warn("promoteParticipant: externalId not found in cache", e);
13270
+ Dl(e, "promoteParticipant", n);
13191
13271
  return;
13192
13272
  }
13193
- r = j.composeUserId(t);
13273
+ r = j.decomposeParticipantId(t).compositeUserId;
13194
13274
  }
13195
13275
  return n.promoteParticipant(r, t);
13196
13276
  }
13197
- async function yl(e = !1) {
13198
- return El().requestPromotion(e);
13199
- }
13200
13277
  async function bl(e = !1) {
13201
- return El().acceptPromotion(e);
13278
+ return kl().requestPromotion(e);
13202
13279
  }
13203
- async function xl(e) {
13204
- return El().getParticipantListChunk(e);
13280
+ async function xl(e = !1) {
13281
+ return kl().acceptPromotion(e);
13205
13282
  }
13206
13283
  async function Sl(e) {
13207
- return El().getParticipants(e);
13284
+ return kl().getParticipantListChunk(e);
13208
13285
  }
13209
13286
  async function Cl(e) {
13210
- return El().feedback(e);
13287
+ return kl().getParticipants(e);
13211
13288
  }
13212
- async function wl(e, t, n) {
13213
- return El(n).enableFeatureForRoles(e, t);
13289
+ async function wl(e) {
13290
+ return kl().feedback(e);
13214
13291
  }
13215
- function Tl(e) {
13216
- return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13292
+ async function Tl(e, t, n) {
13293
+ return kl(n).enableFeatureForRoles(e, t);
13217
13294
  }
13218
13295
  function El(e) {
13219
- let t = Tl(e);
13296
+ return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13297
+ }
13298
+ function Dl(e, t, n) {
13299
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
13300
+ }
13301
+ function Ol(e, t, n) {
13302
+ let r = Array.from(new Set(e));
13303
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
13304
+ }
13305
+ function kl(e) {
13306
+ let t = El(e);
13220
13307
  if (!t) throw Error("Conversation not found");
13221
13308
  return t;
13222
13309
  }
13223
- async function Dl(e) {
13310
+ function Al(e, t) {
13311
+ let n = $.current();
13312
+ if (!n) return null;
13313
+ let r = n.getCachedParticipantIdByExternalId(e);
13314
+ return r ? {
13315
+ conversation: n,
13316
+ participantId: r
13317
+ } : (Dl(e, t, n), null);
13318
+ }
13319
+ async function jl(e) {
13224
13320
  await Vs.removeHistoryRecords(e);
13225
13321
  }
13226
- async function Ol(e) {
13322
+ async function Ml(e) {
13227
13323
  let t = $.current() ?? z.getFirst();
13228
13324
  t && await t.startAsr(e);
13229
13325
  }
13230
- async function kl(e) {
13326
+ async function Nl(e) {
13231
13327
  let t = $.current() ?? z.getFirst();
13232
13328
  t && await t.stopAsr(e);
13233
13329
  }
13234
- async function Al(e) {
13330
+ async function Pl(e) {
13235
13331
  let t = $.current() ?? z.getFirst();
13236
13332
  t && await t.requestAsr(e);
13237
13333
  }
13238
- async function jl(e) {
13334
+ async function Fl(e) {
13239
13335
  let t = $.current();
13240
13336
  return t ? t.startUrlSharing(e) : Promise.reject();
13241
13337
  }
13242
- async function Ml() {
13338
+ async function Il() {
13243
13339
  let e = $.current();
13244
13340
  return e ? e.stopUrlSharing() : Promise.reject();
13245
13341
  }
13246
- async function Nl(e) {
13342
+ async function Ll(e) {
13247
13343
  await z.switchCall(e);
13248
13344
  }
13249
- function Pl() {
13345
+ function Rl() {
13250
13346
  return z.getActiveId();
13251
13347
  }
13252
- function Fl() {
13348
+ function zl() {
13253
13349
  return $.getSyncedTime();
13254
13350
  }
13255
- function Il() {
13351
+ function Bl() {
13256
13352
  return M.sdkVersion;
13257
13353
  }
13258
13354
  typeof window < "u" && (window.__CALLS_SDK = yn);
13259
13355
  //#endregion
13260
- export { Ps as Api, Bs as ApiExternal, zs as ArrayDequeue, y as AuthData, f as BaseLogger, Ba as CallDirection, Va as CallType, Ha as ChatRoomEventType, Ua as ConversationFeature, Wa as ConversationOption, Sn as DebugMessageType, to as ExternalIdType, jt as FacingMode, x as FatalError, O as HangupReason, D as HangupType, S as MediaOption, k as MediaTrackKind, V as MediaType, qa as MuteState, Z as ParticipantState, Rs as ParticipantStateDataValue, N as ParticipantStatus, Ls as RecordRole, Ja as RoomsEventType, za as Signaling, B as SignalingCommandType, vr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, Za as UserRole, A as UserType, To as VolumeDetector, rc as acceptCall, bl as acceptPromotion, tl as activateRooms, Zc as addMovie, lc as addParticipant, uc as addParticipantInternal, nc as authorize, Us as browser, Qs as callInternal, Zs as callTo, mc as captureScreen, hc as captureVmoji, fl as changeAudioEffect, Pc as changeConversationOptions, pc as changeDevice, xc as changeParticipantState, bc as changePriorities, dl as changeVideoEffect, Lc as chatHistory, Fc as chatMessage, Ic as chatMessageInternal, Hc as createJoinLink, Rc as customData, zc as customDataInternal, al as debug, cl as debugLogs, ol as debugMessage, sl as debugMessageWithContext, ic as declineCall, wl as enableFeatureForRoles, Mc as enableVideoSuspend, Nc as enableVideoSuspendSuggest, Cl as feedback, Kc as forceRelayPolicy, Pl as getActiveCallId, Wc as getAnonymTokenByLink, _l as getAudienceModeHands, tc as getInbounds, xl as getParticipantListChunk, Sl as getParticipants, Xc as getStreamInfo, Fl as getSyncedTime, gl as getWaitingHall, Tc as grantRoles, Ec as grantRolesInternal, cc as hangup, Xs as init, ac as joinCall, sc as joinCallByLink, oc as joinCallInternal, Dc as muteParticipant, Oc as muteParticipantInternal, kc as pinParticipant, Ac as pinParticipantInternal, $s as processPush, ec as processPushInternal, vl as promoteParticipant, Yc as publishStream, Sc as putHandsDown, Dl as removeHistoryRecords, Uc as removeJoinLink, $c as removeMovie, dc as removeParticipant, fc as removeParticipantInternal, rl as removeRooms, Al as requestAsr, wc as requestDisplayLayout, yl as requestPromotion, qs as setAudioEffects, pl as setAudioStream, yc as setLocalResolution, Gs as setLogger, jc as setMediaModifiers, il as setStatisticsInterval, Js as setVad, Ks as setVideoEffects, gc as setVideoStream, Ys as setVmoji, hl as setVmojiFill, ml as setVmojiSvg, Gc as setVolume, Ol as startAsr, Vc as startAudienceConversation, Bc as startConversation, qc as startStream, jl as startUrlSharing, kl as stopAsr, Jc as stopStream, Ml as stopUrlSharing, Nl as switchCall, nl as switchRoom, vc as toggleLocalAudio, _c as toggleLocalVideo, Cc as updateDisplayLayout, Qc as updateMovie, el as updateRooms, ul as uploadDebugLogs, Ws as utils, Il as version };
13356
+ export { Ps as Api, Bs as ApiExternal, zs as ArrayDequeue, y as AuthData, f as BaseLogger, Ba as CallDirection, Va as CallType, Ha as ChatRoomEventType, Ua as ConversationFeature, Wa as ConversationOption, Sn as DebugMessageType, to as ExternalIdType, jt as FacingMode, x as FatalError, O as HangupReason, D as HangupType, S as MediaOption, k as MediaTrackKind, V as MediaType, qa as MuteState, Z as ParticipantState, Rs as ParticipantStateDataValue, N as ParticipantStatus, Ls as RecordRole, Ja as RoomsEventType, za as Signaling, B as SignalingCommandType, vr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, Za as UserRole, A as UserType, To as VolumeDetector, ic as acceptCall, xl as acceptPromotion, nl as activateRooms, Qc as addMovie, uc as addParticipant, dc as addParticipantInternal, rc as authorize, Us as browser, $s as callInternal, Zs as callTo, hc as captureScreen, gc as captureVmoji, pl as changeAudioEffect, Fc as changeConversationOptions, mc as changeDevice, Sc as changeParticipantState, xc as changePriorities, fl as changeVideoEffect, Rc as chatHistory, Ic as chatMessage, Lc as chatMessageInternal, Uc as createJoinLink, zc as customData, Bc as customDataInternal, ol as debug, ll as debugLogs, sl as debugMessage, cl as debugMessageWithContext, ac as declineCall, Tl as enableFeatureForRoles, Nc as enableVideoSuspend, Pc as enableVideoSuspendSuggest, wl as feedback, qc as forceRelayPolicy, Rl as getActiveCallId, Gc as getAnonymTokenByLink, vl as getAudienceModeHands, nc as getInbounds, Sl as getParticipantListChunk, Cl as getParticipants, Zc as getStreamInfo, zl as getSyncedTime, _l as getWaitingHall, Ec as grantRoles, Dc as grantRolesInternal, lc as hangup, Xs as init, oc as joinCall, cc as joinCallByLink, sc as joinCallInternal, Oc as muteParticipant, kc as muteParticipantInternal, Ac as pinParticipant, jc as pinParticipantInternal, ec as processPush, tc as processPushInternal, yl as promoteParticipant, Xc as publishStream, Cc as putHandsDown, jl as removeHistoryRecords, Wc as removeJoinLink, el as removeMovie, fc as removeParticipant, pc as removeParticipantInternal, il as removeRooms, Pl as requestAsr, Tc as requestDisplayLayout, bl as requestPromotion, qs as setAudioEffects, ml as setAudioStream, bc as setLocalResolution, Gs as setLogger, Mc as setMediaModifiers, al as setStatisticsInterval, Js as setVad, Ks as setVideoEffects, _c as setVideoStream, Ys as setVmoji, gl as setVmojiFill, hl as setVmojiSvg, Kc as setVolume, Ml as startAsr, Hc as startAudienceConversation, Vc as startConversation, Jc as startStream, Fl as startUrlSharing, Nl as stopAsr, Yc as stopStream, Il as stopUrlSharing, Ll as switchCall, rl as switchRoom, yc as toggleLocalAudio, vc as toggleLocalVideo, wc as updateDisplayLayout, $c as updateMovie, tl as updateRooms, dl as uploadDebugLogs, Ws as utils, Bl as version };