@vkontakte/calls-sdk 2.8.12-dev.fd0aff08.0 → 2.8.13-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/calls-sdk.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @vkontakte/calls-sdk v2.8.12-dev.fd0aff08.0
3
- * Fri, 04 Sep 2026 08:25:26 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-beta.0
3
+ * Fri, 11 Sep 2026 06:36:40 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-dev.fd0aff08.0";
2158
+ return "2.8.13-beta.0";
2159
2159
  }
2160
2160
  static get debug() {
2161
2161
  return e._params.debug;
@@ -2700,7 +2700,7 @@ h(M, "_params", {
2700
2700
  waitForRecordResponse: !1,
2701
2701
  transparentAudio: !1,
2702
2702
  enableSessionStateUpdates: !1,
2703
- safariAudioElement: !1,
2703
+ safariAudioElement: !0,
2704
2704
  forwardEmptyIceCandidate: !1
2705
2705
  });
2706
2706
  //#endregion
@@ -3065,6 +3065,10 @@ var xn;
3065
3065
  P("onPeerRegistered", e, t);
3066
3066
  }
3067
3067
  e.onPeerRegistered = ot;
3068
+ function st(e, t) {
3069
+ P("onNonFatalError", e, t);
3070
+ }
3071
+ e.onNonFatalError = st;
3068
3072
  })(xn || (xn = {}));
3069
3073
  var L = xn, Sn = /* @__PURE__ */ function(e) {
3070
3074
  return e.DEBUG = "DEBUG", e.LOG = "LOG", e.WARN = "WARN", e.ERROR = "ERROR", e;
@@ -5842,7 +5846,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5842
5846
  this._perfStatReporter?.destroy(), this._perfStatReporter = new pa(this, this._signaling, this._statAggregator, !1, this._debug);
5843
5847
  }
5844
5848
  _closeConnection() {
5845
- 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);
5849
+ 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);
5846
5850
  }
5847
5851
  static _closeDataChannel(e) {
5848
5852
  e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
@@ -5912,10 +5916,10 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5912
5916
  this._triggerEvent(X.NETWORK_STATUS, e);
5913
5917
  }
5914
5918
  _updateSSRCMap(e) {
5915
- e && ln(e.sdp).forEach((e) => {
5919
+ e && (this._ssrcMap = {}, this._ssrcMapUpdated = !0, ln(e.sdp).forEach((e) => {
5916
5920
  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);
5917
- n && (this._ssrcMap[n[1]] = n[3], this._ssrcMapUpdated = !0);
5918
- });
5921
+ n && (this._ssrcMap[n[1]] = n[3]);
5922
+ }));
5919
5923
  }
5920
5924
  _createCaptureSender(e) {
5921
5925
  let t = this._mediaSource.mediaSettings;
@@ -8112,7 +8116,7 @@ var ho = class {
8112
8116
  }
8113
8117
  }, go = class {
8114
8118
  constructor(e, t = !1, n = R, r = null) {
8115
- h(this, "_audioElement", null), h(this, "_audioTracks", /* @__PURE__ */ new Map()), h(this, "_allowMultipleTracks", void 0), h(this, "_volume", 1), h(this, "_features", { setSinkId: !!Audio.prototype.setSinkId }), h(this, "_statFirstMediaReceived", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._statFirstMediaReceived = e, this._allowMultipleTracks = t, this._debug = n, this._logger = r;
8119
+ h(this, "_audioElement", null), h(this, "_debug", void 0), h(this, "_preparedAudioElement", void 0), h(this, "_audioTracks", /* @__PURE__ */ new Map()), h(this, "_allowMultipleTracks", void 0), h(this, "_volume", 1), h(this, "_features", { setSinkId: !!Audio.prototype.setSinkId }), h(this, "_statFirstMediaReceived", void 0), h(this, "_logger", void 0), this._statFirstMediaReceived = e, this._allowMultipleTracks = t, this._debug = n, this._logger = r, this._preparedAudioElement = this._prepareAudioElement();
8116
8120
  }
8117
8121
  add(e, t) {
8118
8122
  this._allowMultipleTracks || this._clearTracks();
@@ -8161,31 +8165,40 @@ var ho = class {
8161
8165
  if (M.muteMode) return;
8162
8166
  let e = this._getTracks();
8163
8167
  if (!e.length) return;
8164
- let t = T.browserName() !== "Safari" || T.isMobile() || M.safariAudioElement, n = document.createElement(t ? "audio" : "video");
8165
- n.muted = !1, n.volume = this._volume, n.preload = "auto";
8166
- let r = () => {
8168
+ let t = this._preparedAudioElement ?? this._createAudioElement();
8169
+ t.muted = !1, t.volume = this._volume, t.preload = "auto";
8170
+ let n = () => {
8167
8171
  this._debug.warn("[audio] Error on play audio"), L.onAutoplayError();
8168
- }, i = (e) => {
8169
- this._debug.debug("[audio] Play audio"), n.srcObject = null, n.srcObject = new MediaStream(e), n.load();
8170
- let t = n.play();
8171
- t && t.catch(r);
8172
- }, a = () => {
8172
+ }, r = (e) => {
8173
+ this._debug.debug("[audio] Play audio"), t.srcObject = null, t.srcObject = new MediaStream(e), t.load();
8174
+ let r = t.play();
8175
+ r && r.catch(n);
8176
+ }, i = () => {
8173
8177
  this._debug.debug("[audio] Recover audio playback");
8174
8178
  let e = this._getTracks();
8175
- e.length ? i(e) : this._debug.warn("[audio] Broken audio tracks");
8179
+ e.length ? r(e) : this._debug.warn("[audio] Broken audio tracks");
8176
8180
  };
8177
- n.onpause = a, n.onstalled = a, n.onerror = a, n.onloadeddata = () => {
8181
+ t.onpause = i, t.onstalled = i, t.onerror = i, t.onloadeddata = () => {
8178
8182
  this._statFirstMediaReceived.measure();
8179
- }, i(e), this._audioElement = n;
8180
- let o = T.getSavedOutput()?.deviceId;
8181
- o && n.setSinkId?.(o).catch((e) => {
8182
- this._debug.warn(`[audio] Failed to set output device '${o}'`, e);
8183
+ }, r(e), this._audioElement = t;
8184
+ let a = T.getSavedOutput()?.deviceId;
8185
+ a && t.setSinkId?.(a).catch((e) => {
8186
+ this._debug.warn(`[audio] Failed to set output device '${a}'`, e);
8183
8187
  });
8184
8188
  }
8185
8189
  _stopAudioElement() {
8186
- this._audioElement && (this._audioElement.pause(), this._audioElement.srcObject = null);
8190
+ this._audioElement && (this._audioElement.onpause = null, this._audioElement.onstalled = null, this._audioElement.onerror = null, this._audioElement.onloadeddata = null, this._audioElement.pause(), this._audioElement.srcObject = null);
8187
8191
  for (let e of this._audioTracks.values()) e.stop();
8188
8192
  }
8193
+ _createAudioElement() {
8194
+ let e = T.browserName() !== "Safari" || T.isMobile() || M.safariAudioElement;
8195
+ return document.createElement(e ? "audio" : "video");
8196
+ }
8197
+ _prepareAudioElement() {
8198
+ if (M.muteMode || T.browserName() !== "Safari" || T.isMobile()) return null;
8199
+ let e = this._createAudioElement();
8200
+ return e.load(), e;
8201
+ }
8189
8202
  _addTrackToAudioElement(e) {
8190
8203
  if (!this._audioElement) return;
8191
8204
  this._debug.debug(`[audio] Adding track ${e}`);
@@ -8246,8 +8259,8 @@ var bo = 90, xo = 3, So = class extends b {
8246
8259
  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);
8247
8260
  }
8248
8261
  }, Co = class {
8249
- constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i }) {
8250
- 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;
8262
+ constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i, onNonFatalError: a }) {
8263
+ 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;
8251
8264
  }
8252
8265
  request(e) {
8253
8266
  this._pendingRequests = e.slice(), this._lastRequests = e.slice();
@@ -8283,11 +8296,16 @@ var bo = 90, xo = 3, So = class extends b {
8283
8296
  this._pendingRequests = null, this._pendingPromises = [];
8284
8297
  let r = {};
8285
8298
  try {
8286
- r = this._getRequestLayouts(t);
8287
- let i = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8299
+ let i = this._getRequestLayouts(t);
8300
+ if (!i) {
8301
+ n.forEach(({ resolve: e }) => e());
8302
+ return;
8303
+ }
8304
+ r = i;
8305
+ let a = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8288
8306
  this._forceNextFlush = !1;
8289
- let a = this._getDiff(r, i);
8290
- a.length && await this._updateDisplayLayout(a), e === this._generation && (this._requestedLayouts = r, this._uncertainLayouts = {}), n.forEach(({ resolve: e }) => e());
8307
+ let o = this._getDiff(r, a);
8308
+ o.length && await this._updateDisplayLayout(o), e === this._generation && (this._requestedLayouts = r, this._uncertainLayouts = {}), n.forEach(({ resolve: e }) => e());
8291
8309
  } catch (t) {
8292
8310
  e === this._generation ? (this._uncertainLayouts = {
8293
8311
  ...this._uncertainLayouts,
@@ -8298,30 +8316,30 @@ var bo = 90, xo = 3, So = class extends b {
8298
8316
  }
8299
8317
  }
8300
8318
  _getRequestLayouts(e) {
8301
- let t = {}, n = this._getParticipants();
8302
- for (let r of e) {
8303
- let e = typeof r.uid == "object" ? r.uid : Q.fromId(r.uid), i = this._api.getCachedOkIdByExternalId(e);
8304
- if (!i) {
8305
- this._debug.log(`Unknown participant external ID ${typeof r.uid == "object" ? Q.toString(r.uid) : r.uid}`);
8319
+ let t = {}, n = [], r = this._getParticipants();
8320
+ for (let i of e) {
8321
+ let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedParticipantIdByExternalId(e);
8322
+ if (!a) {
8323
+ this._debug.log(`Unknown participant external ID ${typeof i.uid == "object" ? Q.toString(i.uid) : i.uid}`), n.push(e.id);
8306
8324
  continue;
8307
8325
  }
8308
- if (!n[i] && !this._isMe(i)) continue;
8309
- let a = Mn({
8310
- participantId: i,
8311
- mediaType: r.mediaType,
8312
- streamName: r.streamName
8326
+ if (!r[a] && !this._isMe(a)) continue;
8327
+ let o = Mn({
8328
+ participantId: a,
8329
+ mediaType: i.mediaType,
8330
+ streamName: i.streamName
8313
8331
  });
8314
- t[a] = {
8315
- uid: r.uid,
8316
- mediaType: r.mediaType,
8317
- width: r.width,
8318
- height: r.height,
8319
- fit: r.cover ? "cv" : "cn",
8320
- ...r.priority === void 0 ? {} : { priority: r.priority },
8321
- ...r.streamName === void 0 ? {} : { streamName: r.streamName }
8332
+ t[o] = {
8333
+ uid: i.uid,
8334
+ mediaType: i.mediaType,
8335
+ width: i.width,
8336
+ height: i.height,
8337
+ fit: i.cover ? "cv" : "cn",
8338
+ ...i.priority === void 0 ? {} : { priority: i.priority },
8339
+ ...i.streamName === void 0 ? {} : { streamName: i.streamName }
8322
8340
  };
8323
8341
  }
8324
- return t;
8342
+ return n.length ? (this._onNonFatalError(`Participant ID mapping not found for external IDs "${Array.from(new Set(n)).join("\", \"")}" while handling requestDisplayLayout`), null) : t;
8325
8343
  }
8326
8344
  _getDiff(e, t = !1) {
8327
8345
  let n = [];
@@ -8360,7 +8378,7 @@ var bo = 90, xo = 3, So = class extends b {
8360
8378
  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]);
8361
8379
  try {
8362
8380
  let e = T.getAudioContext();
8363
- 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);
8381
+ 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);
8364
8382
  } catch {}
8365
8383
  }
8366
8384
  get track() {
@@ -9343,7 +9361,8 @@ var ls = 15, $ = class e extends b {
9343
9361
  debug: this._debug,
9344
9362
  getParticipants: () => this._participants,
9345
9363
  isMe: (e) => this._isMe(e),
9346
- updateDisplayLayout: (e) => this.updateDisplayLayout(e)
9364
+ updateDisplayLayout: (e) => this.updateDisplayLayout(e),
9365
+ onNonFatalError: (e) => this._onNonFatalError(e)
9347
9366
  }), this._onUnload = () => {
9348
9367
  this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? D.CANCELED : D.HUNGUP), this._stats.destroy();
9349
9368
  }, 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));
@@ -9379,6 +9398,9 @@ var ls = 15, $ = class e extends b {
9379
9398
  get isCallHeld() {
9380
9399
  return this._state === "HELD";
9381
9400
  }
9401
+ get isIncomingRinging() {
9402
+ return this._conversation?.direction === Ba.INCOMING && this._state === "IDLE";
9403
+ }
9382
9404
  static debugSessionId() {
9383
9405
  return e.current()?.debugSessionId ?? null;
9384
9406
  }
@@ -9396,8 +9418,14 @@ var ls = 15, $ = class e extends b {
9396
9418
  get debugSessionId() {
9397
9419
  return this._debug.sessionId;
9398
9420
  }
9399
- getCachedRawOkIdByExternalId(e) {
9400
- return this._api.getCachedRawOkIdByExternalId(e);
9421
+ getCachedParticipantIdByExternalId(e) {
9422
+ return this._api.getCachedParticipantIdByExternalId(e);
9423
+ }
9424
+ _onNonFatalError(e) {
9425
+ L.onNonFatalError(Error(e), this.id);
9426
+ }
9427
+ getIncomingCallerExternalId() {
9428
+ return this._conversation?.direction === Ba.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
9401
9429
  }
9402
9430
  _buildInternalParams() {
9403
9431
  let e = {
@@ -9440,11 +9468,15 @@ var ls = 15, $ = class e extends b {
9440
9468
  description: "not-initialized-after-start"
9441
9469
  } });
9442
9470
  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);
9443
- return this._debug.debug("Outgoing call", {
9471
+ if (this._debug.debug("Outgoing call", {
9444
9472
  opponentIds: e,
9445
9473
  opponentType: t,
9446
9474
  mediaOptions: n
9447
- }), 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(() => {
9475
+ }), 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) {
9476
+ let e = z.get(this._conversation.id);
9477
+ e && e !== this && e._close(new O(D.HUNGUP, { remote: !0 }));
9478
+ }
9479
+ 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(() => {
9448
9480
  this._calleeUnavailableTimer = null, this._close(new O(D.CALLEE_UNAVAILABLE), { signalingReason: D.CANCELED });
9449
9481
  }, f)), this._conversation;
9450
9482
  } catch (e) {
@@ -9501,7 +9533,11 @@ var ls = 15, $ = class e extends b {
9501
9533
  }
9502
9534
  }
9503
9535
  _extractExternalRooms(e) {
9504
- return e.map(this._convertRoomToExternal.bind(this)).filter((e) => !!e);
9536
+ let t = [], n = [];
9537
+ return e.forEach((e) => {
9538
+ let { room: r, missingParticipantIds: i } = this._convertRoomToExternal(e);
9539
+ r && n.push(r), t.push(...i);
9540
+ }), this._reportMissingExternalIds(t, "EXTRACT_EXTERNAL_ROOMS"), n.filter((e) => !!e);
9505
9541
  }
9506
9542
  _extractExternalRoomsData(e, t) {
9507
9543
  if (!e || !e.length) return;
@@ -9726,7 +9762,8 @@ var ls = 15, $ = class e extends b {
9726
9762
  D.CALLEE_IS_OFFLINE,
9727
9763
  D.CALLEE_UNAVAILABLE,
9728
9764
  D.CALLER_IS_BLOCKED,
9729
- D.CALLER_IS_REJECTED
9765
+ D.CALLER_IS_REJECTED,
9766
+ D.HAS_ACTIVE_CALL
9730
9767
  ].indexOf(e.hangup) !== -1 || e.hangup === D.REJECTED && !e.remote) {
9731
9768
  this._emitHangupOnce(e, i), this._destroy(r);
9732
9769
  return;
@@ -9983,19 +10020,17 @@ var ls = 15, $ = class e extends b {
9983
10020
  isInRoom: !1,
9984
10021
  markers: null
9985
10022
  }, e), i = !!r.externalId;
9986
- 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;
10023
+ if (!i) {
10024
+ let e = this._getParticipantId(t ?? r.id);
10025
+ e && (r.externalId = e);
10026
+ }
10027
+ 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;
9987
10028
  }
9988
10029
  _getParticipantId(e) {
9989
- try {
9990
- return this._api.userId(e);
9991
- } catch (e) {
9992
- throw this._close(e instanceof O ? e : new O(D.NETWORK_ERROR, { callError: {
9993
- scope: "network",
9994
- source: "api",
9995
- code: "fetch-failed",
9996
- description: "request-failed"
9997
- } }), { errorText: e }), e;
9998
- }
10030
+ let t = this._api.userId(e);
10031
+ if (t) return t;
10032
+ let { compositeUserId: n, deviceIdx: r } = j.decomposeParticipantId(e), { id: i, type: a } = j.decomposeId(n);
10033
+ return a === A.GROUP ? Q.fromId(String(i), void 0, r) : null;
9999
10034
  }
10000
10035
  _cacheParticipantExternalIds(e) {
10001
10036
  e.forEach((e) => {
@@ -10003,7 +10038,7 @@ var ls = 15, $ = class e extends b {
10003
10038
  if (n) {
10004
10039
  this._api.cacheExternalId(t, n);
10005
10040
  let r = j.composeDecorativeId(e), i = Q.fromSignalingParticipant(e);
10006
- r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(e.decorativeUserId, e.id));
10041
+ r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(r, t));
10007
10042
  }
10008
10043
  });
10009
10044
  }
@@ -10052,7 +10087,11 @@ var ls = 15, $ = class e extends b {
10052
10087
  audienceMode: this._isAudienceMode(t),
10053
10088
  restricted: this._isRestricted(t),
10054
10089
  urlSharingInfoByRoom: /* @__PURE__ */ new Map()
10055
- }, 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();
10090
+ }, 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");
10091
+ let l = z.get(this._conversation.id);
10092
+ if (l && l !== this) this._conversation.concurrent = !0;
10093
+ else if (!M.hold && z.callsLength > 0) throw new O(D.HAS_ACTIVE_CALL);
10094
+ this._changeFeatureSet(), this._changeFeaturesPerRole(), this._logDevices();
10056
10095
  }
10057
10096
  _updateConversation(e) {
10058
10097
  if (!this._conversation) throw new O(D.UNKNOWN_ERROR, { callError: {
@@ -10182,33 +10221,40 @@ var ls = 15, $ = class e extends b {
10182
10221
  _getExistedParticipantByIdOrCreate(e) {
10183
10222
  let t = this._participants[e];
10184
10223
  if (t) return t;
10185
- 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);
10224
+ let n = this._api.getDecorativeIdByInitialId(e), r = this._getParticipantId(e), { deviceIdx: i } = j.decomposeParticipantId(e);
10186
10225
  return this._createParticipant({
10187
10226
  id: e,
10188
- externalId: {
10189
- ...i,
10190
- deviceIdx: a
10191
- }
10192
- }, r, !1);
10227
+ externalId: r ? {
10228
+ ...r,
10229
+ deviceIdx: i
10230
+ } : void 0
10231
+ }, n, !1);
10193
10232
  }
10194
10233
  _getExternalIdByParticipantId(e) {
10195
- if (this._isMe(e)) return this._conversation?.externalId;
10234
+ if (this._isMe(e)) return this._conversation?.externalId ?? null;
10196
10235
  if (M.useParticipantListChunk) return this._getExistedParticipantByIdOrCreate(e).externalId;
10197
10236
  let t = this._participants;
10198
10237
  if (t[e]?.externalId) return t[e].externalId;
10199
- {
10200
- let t = this._getParticipantId(e);
10201
- return this._api.cacheExternalId(e, t), t;
10202
- }
10238
+ let n = this._api.getCachedExternalIdByParticipantId(e);
10239
+ if (n) return n;
10240
+ let r = this._getParticipantId(e);
10241
+ return r && this._api.cacheExternalId(e, r), r;
10242
+ }
10243
+ _getExternalIdsByParticipantIds(e) {
10244
+ let t = [], n = [];
10245
+ return e.forEach((e) => {
10246
+ let r = this._getExternalIdByParticipantId(e);
10247
+ r ? t.push(r) : n.push(e);
10248
+ }), {
10249
+ externalIds: t,
10250
+ missingIds: n
10251
+ };
10203
10252
  }
10204
- _getExternalIdsByOkIdsFromCache(e) {
10205
- return e.map((e) => this._api.getCachedExternalIdByOkId(e) ?? Q.fromId(String(e)));
10253
+ _reportMissingExternalIds(e, t) {
10254
+ e.length && this._onNonFatalError(`External ID mapping not found for participants "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10206
10255
  }
10207
- _getOrCacheExternalIdByCompositeId(e) {
10208
- let t = j.extractOkId(e), n = this._api.getCachedExternalIdByOkId(t);
10209
- if (n) return n;
10210
- let r = Q.fromId(String(t));
10211
- return this._api.cacheExternalId(e, r), r;
10256
+ _reportMissingExternalIdsById(e, t) {
10257
+ e.length && this._onNonFatalError(`Participant ID mapping not found for external IDs "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10212
10258
  }
10213
10259
  _registerParticipantAndSetMarkersIfChunkEnabled(e, t) {
10214
10260
  if (M.useParticipantListChunk) {
@@ -10493,30 +10539,34 @@ var ls = 15, $ = class e extends b {
10493
10539
  async updateDisplayLayout(e) {
10494
10540
  if (e.length < 1 || !this._signaling.ready) return;
10495
10541
  this._debug.log(`Update display layout request [${this._signaling.getNextCommandSequenceNumber()}]`, e);
10496
- let t = {}, n = [], r = this._participants;
10497
- for (let i of e) {
10498
- let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedOkIdByExternalId(e);
10499
- if (!a) {
10542
+ let t = {}, n = [], r = [], i = this._participants;
10543
+ for (let a of e) {
10544
+ let e = typeof a.uid == "object" ? a.uid : Q.fromId(a.uid), o = this._api.getCachedParticipantIdByExternalId(e);
10545
+ if (!o) {
10500
10546
  let t = Q.toString(e);
10501
- this._debug.log(`Unknown participant external ID ${t}`);
10547
+ this._debug.log(`Unknown participant external ID ${t}`), r.push(e.id);
10502
10548
  continue;
10503
10549
  }
10504
- let o = Mn({
10505
- participantId: a,
10506
- mediaType: i.mediaType,
10507
- streamName: i.streamName
10508
- }), s = r[a];
10509
- s ? n.push(() => {
10510
- s.lastRequestedLayouts[o] = i;
10511
- }) : this._isMe(a) && n.push(() => {
10512
- this._myLastRequestedLayouts[o] = i;
10513
- }), Dn(i) ? (this._isMe(a) && n.push(() => {
10514
- delete this._myLastRequestedLayouts[o];
10515
- }), 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));
10516
- }
10517
- let i = this._cooldownTimestampByStreamDescription.keys();
10550
+ let s = Mn({
10551
+ participantId: o,
10552
+ mediaType: a.mediaType,
10553
+ streamName: a.streamName
10554
+ }), c = i[o];
10555
+ c ? n.push(() => {
10556
+ c.lastRequestedLayouts[s] = a;
10557
+ }) : this._isMe(o) && n.push(() => {
10558
+ this._myLastRequestedLayouts[s] = a;
10559
+ }), Dn(a) ? (this._isMe(o) && n.push(() => {
10560
+ delete this._myLastRequestedLayouts[s];
10561
+ }), 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));
10562
+ }
10563
+ if (r.length) {
10564
+ this._reportMissingExternalIdsById(r, "updateDisplayLayout");
10565
+ return;
10566
+ }
10567
+ let a = this._cooldownTimestampByStreamDescription.keys();
10518
10568
  for (; this._streamIdByStreamDescription.size > M.videoTracksCount;) {
10519
- let e = i.next();
10569
+ let e = a.next();
10520
10570
  if (e.done) {
10521
10571
  this._debug.error("Cannot accommodate all streaming requests: tracks available " + M.videoTracksCount + "; requested streams: " + Array.from(this._streamIdByStreamDescription.keys()));
10522
10572
  break;
@@ -10608,17 +10658,22 @@ var ls = 15, $ = class e extends b {
10608
10658
  async _onParticipantPromoted(e) {
10609
10659
  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);
10610
10660
  }
10611
- async _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10661
+ _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10612
10662
  this._debug.log(`Chat room updated: ${e}`);
10613
- let a = [];
10663
+ let a = [], o = [];
10614
10664
  n.length && n.forEach((e) => {
10615
10665
  if (e.externalId) {
10616
10666
  let t = Q.fromSignaling(e.externalId);
10617
10667
  a.push(t), this._api.cacheExternalId(e.id.id, t);
10618
- } else a.push(this._getOrCacheExternalIdByCompositeId(e.id.id));
10668
+ } else {
10669
+ let t = this._getExternalIdByParticipantId(e.id.id);
10670
+ t ? a.push(t) : o.push(e.id.id);
10671
+ }
10619
10672
  });
10620
- let o = r?.map((e) => this._getOrCacheExternalIdByCompositeId(e)) ?? [], s = i?.map((e) => this._getOrCacheExternalIdByCompositeId(e)) ?? [];
10621
- L.onChatRoomUpdated(e, t, a, o, s, this.id);
10673
+ let { externalIds: s, missingIds: c } = this._getExternalIdsByParticipantIds(r ?? []);
10674
+ o.push(...c);
10675
+ let { externalIds: l, missingIds: u } = this._getExternalIdsByParticipantIds(i ?? []);
10676
+ o.push(...u), this._reportMissingExternalIds(o, "CHAT_ROOM_UPDATED"), L.onChatRoomUpdated(e, t, a, s, l, this.id);
10622
10677
  }
10623
10678
  _onSharedMovieUpdate(e) {
10624
10679
  let t = this._conversation?.externalId;
@@ -10841,34 +10896,37 @@ var ls = 15, $ = class e extends b {
10841
10896
  let r = null;
10842
10897
  if (e && (r = ro(e), r)) {
10843
10898
  let e = this._api.getDecorativeIdByInitialId(r.id);
10844
- r.id = e ? j.composeUserId(e) : r.id;
10899
+ r.id = e ?? r.id;
10845
10900
  }
10846
10901
  let i = await this._signaling.getWaitingHall(r, t, n);
10847
10902
  if (i.error) return Promise.reject(i.message);
10848
- let a = i.participants || [], { externalIds: o } = await this._resolveWaitingHallExternalIds(a), s = null;
10903
+ let a = i.participants || [], { externalIds: o } = this._resolveWaitingHallExternalIds(a, "getWaitingHall"), s = null;
10849
10904
  return a.length && i.hasMore && (s = no(a[a.length - 1].id)), {
10850
10905
  participants: o,
10851
10906
  pageMarker: s,
10852
10907
  totalCount: i.totalCount || 0
10853
10908
  };
10854
10909
  }
10855
- async _resolveWaitingHallExternalIds(e) {
10856
- let t = [], n = [];
10910
+ _resolveWaitingHallExternalIds(e, t) {
10911
+ let n = [], r = [], i = [];
10857
10912
  return e.length && e.forEach((e) => {
10858
10913
  if (e.externalId) {
10859
- let r = Q.fromSignaling(e.externalId);
10860
- t.push(e.id.addedTs), n.push(r), this._api.cacheExternalId(e.id.id, r);
10861
- } else n.push(this._getOrCacheExternalIdByCompositeId(e.id.id)), t.push(e.id.addedTs);
10862
- }), {
10863
- externalIds: n,
10864
- timestamps: t
10914
+ let t = Q.fromSignaling(e.externalId);
10915
+ n.push(e.id.addedTs), r.push(t), this._api.cacheExternalId(e.id.id, t);
10916
+ } else {
10917
+ let t = this._getExternalIdByParticipantId(e.id.id);
10918
+ t ? (r.push(t), n.push(e.id.addedTs)) : i.push(e.id.id);
10919
+ }
10920
+ }), this._reportMissingExternalIds(i, t), {
10921
+ externalIds: r,
10922
+ timestamps: n
10865
10923
  };
10866
10924
  }
10867
10925
  async getAudienceModeHands() {
10868
10926
  if (!this._signaling.ready) throw Error("Signaling is not ready");
10869
10927
  let e = await this._signaling.getHandQueue();
10870
10928
  if (e.error) return Promise.reject(e.message);
10871
- let t = e.participants || [], { externalIds: n, timestamps: r } = await this._resolveWaitingHallExternalIds(t);
10929
+ let t = e.participants || [], { externalIds: n, timestamps: r } = this._resolveWaitingHallExternalIds(t, "getAudienceModeHands");
10872
10930
  return {
10873
10931
  timestamps: r,
10874
10932
  participants: n,
@@ -11037,7 +11095,7 @@ var ls = 15, $ = class e extends b {
11037
11095
  unmuteOptions: e.unmuteOptions || [],
11038
11096
  observedIds: e.observedIds || [],
11039
11097
  markers: this._denormalizeMarkers(t, e.markers)
11040
- }, e.decorativeUserId);
11098
+ }, j.composeDecorativeId(e));
11041
11099
  }));
11042
11100
  }
11043
11101
  async getParticipantListChunk(e) {
@@ -11083,7 +11141,7 @@ var ls = 15, $ = class e extends b {
11083
11141
  this._warnParticipantNotInConversation(e);
11084
11142
  return;
11085
11143
  }
11086
- r.mediaSettings = t, ["ACTIVE", "HELD"].includes(this._state) && L.onRemoteMediaSettings(r.externalId, t, r.markers, this.id), this._specListener && this._specListener.onChangeRemoteMediaSettings(e, t);
11144
+ 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);
11087
11145
  }
11088
11146
  _extractLocalParticipantFromConnection(e) {
11089
11147
  let t = this._api.getUserId();
@@ -11099,7 +11157,7 @@ var ls = 15, $ = class e extends b {
11099
11157
  this._warnParticipantNotInConversation(e);
11100
11158
  return;
11101
11159
  }
11102
- n.participantState = t || {}, ["ACTIVE", "HELD"].includes(this._state) && L.onRemoteParticipantState(n.externalId, n.participantState, n.markers, this.id);
11160
+ 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"));
11103
11161
  }
11104
11162
  _changeMultipleParticipantState(e, t) {
11105
11163
  this._debug.debug("Multiple participants state changed", e);
@@ -11234,30 +11292,37 @@ var ls = 15, $ = class e extends b {
11234
11292
  async _onAcceptedCall(e) {
11235
11293
  let t = j.composeMessageId(e), n = j.getPeerIdString(e.peerId);
11236
11294
  if (this._debug.debug(`Participant accepted call [${t}]`), this._statFirstMediaReceived.markAcceptedCall(this._transport?.getTopology()), this._conversation && this._isMe(t)) {
11295
+ if (this._conversation.concurrent) return;
11237
11296
  this._close(new O(D.MISSED), { errorText: "Call accepted on other device" });
11238
11297
  return;
11239
11298
  }
11240
11299
  this._conversation?.direction === Ba.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
11241
11300
  let r = this._getParticipant(t);
11242
11301
  if (!r) {
11243
- let n = this._api.getDecorativeIdByInitialId(t), i = n ? j.composeUserId(n, e.participantType) : void 0;
11302
+ let n = this._api.getDecorativeIdByInitialId(t);
11244
11303
  r = this._registerParticipantInCache(this._createParticipant({
11245
11304
  id: t,
11246
11305
  externalId: e.externalId ? Q.fromSignaling(e.externalId, e.deviceIdx) : void 0,
11247
11306
  mediaSettings: E(e.mediaSettings)
11248
- }, i));
11307
+ }, n));
11249
11308
  } else if (e.externalId) {
11250
11309
  let t = Q.fromSignaling(e.externalId, e.deviceIdx);
11251
11310
  r.externalId = t, this._api.cacheExternalId(r.id, t);
11252
11311
  }
11253
11312
  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);
11254
11313
  let i = Object.keys(r.muteStates);
11255
- i.length && this._onMuteParticipant({
11314
+ if (i.length && this._onMuteParticipant({
11256
11315
  muteStates: r.muteStates,
11257
11316
  mediaOptions: i,
11258
11317
  stateUpdated: !0,
11259
11318
  participantId: t
11260
- }), ["ACTIVE", "HELD"].includes(this._state) && L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11319
+ }), ["ACTIVE", "HELD"].includes(this._state)) {
11320
+ if (!r.externalId) {
11321
+ this._reportMissingExternalIds([t], "ACCEPTED_CALL");
11322
+ return;
11323
+ }
11324
+ L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11325
+ }
11261
11326
  }
11262
11327
  async _onHungup(e) {
11263
11328
  this._debug.debug(`Participant hungup [${e.participantId}]`, { reason: e.reason });
@@ -11326,7 +11391,7 @@ var ls = 15, $ = class e extends b {
11326
11391
  return;
11327
11392
  }
11328
11393
  if (!n) {
11329
- let { participant: r } = e, i = r.decorativeUserId;
11394
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11330
11395
  this._registerParticipant({
11331
11396
  id: t,
11332
11397
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11353,7 +11418,7 @@ var ls = 15, $ = class e extends b {
11353
11418
  return;
11354
11419
  }
11355
11420
  if (!n) {
11356
- let { participant: r } = e, i = r.decorativeUserId;
11421
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11357
11422
  this._registerParticipant({
11358
11423
  id: t,
11359
11424
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11396,7 +11461,7 @@ var ls = 15, $ = class e extends b {
11396
11461
  _onParticipantsStateChanged(e) {
11397
11462
  let { participants: t, roomId: n } = e;
11398
11463
  t.map(({ id: e, markers: t }) => this._registerParticipantAndSetMarkersIfChunkEnabled(e, t));
11399
- let r = /* @__PURE__ */ new Map(), i = t.map(({ id: e, participantState: t }) => [e, this._getExternalIdByParticipantId(e) && j.mapParticipantState({ participantState: t })]);
11464
+ let r = /* @__PURE__ */ new Map(), i = t.map(({ id: e, participantState: t }) => [e, this._getExternalIdByParticipantId(e) ? j.mapParticipantState({ participantState: t }) : void 0]);
11400
11465
  try {
11401
11466
  i.forEach(([e, t]) => {
11402
11467
  t && r.set(e, t);
@@ -11795,8 +11860,8 @@ var ls = 15, $ = class e extends b {
11795
11860
  this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
11796
11861
  let r = this._getParticipant(e);
11797
11862
  if (!r) {
11798
- let t = this._api.getDecorativeIdByInitialId(e), n = t ? j.composeUserId(t) : void 0;
11799
- 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);
11863
+ let t = this._api.getDecorativeIdByInitialId(e);
11864
+ 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);
11800
11865
  }
11801
11866
  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) {
11802
11867
  if (r.remoteStream = t, r.secondStream) return;
@@ -11906,46 +11971,63 @@ var ls = 15, $ = class e extends b {
11906
11971
  }
11907
11972
  _onRoomsUpdated(e) {
11908
11973
  if (this._isCalledState()) return;
11909
- let t = {};
11910
- for (let n of Object.keys(Ja)) {
11911
- let r = e.updates[n];
11912
- r && (t[n] = {
11913
- rooms: r?.rooms?.map(this._convertRoomToExternal.bind(this)) || [],
11914
- roomIds: r?.roomIds,
11915
- deactivated: r?.deactivated
11974
+ let t = {}, n = [], r = [];
11975
+ for (let i of Object.keys(Ja)) {
11976
+ let a = e.updates[i];
11977
+ a && (a?.rooms?.forEach((e) => {
11978
+ let { room: t, missingParticipantIds: i } = this._convertRoomToExternal(e);
11979
+ t && n.push(t), r.push(...i);
11980
+ }), t[i] = {
11981
+ rooms: n,
11982
+ roomIds: a?.roomIds,
11983
+ deactivated: a?.deactivated
11916
11984
  });
11917
11985
  }
11918
- L.onRoomsUpdated(t, this.id);
11986
+ this._reportMissingExternalIds(r, "ROOMS_UPDATED"), L.onRoomsUpdated(t, this.id);
11919
11987
  }
11920
11988
  _onRoomUpdated(e) {
11921
- let t = this._convertRoomToExternal(e.room || null);
11922
- 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);
11989
+ let { room: t, missingParticipantIds: n } = this._convertRoomToExternal(e.room || null);
11990
+ 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));
11923
11991
  }
11924
11992
  _convertRoomToExternal(e) {
11925
- if (!e) return null;
11926
- 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;
11993
+ if (!e) return {
11994
+ room: null,
11995
+ missingParticipantIds: []
11996
+ };
11997
+ 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 ?? []);
11998
+ t.push(...r, ...a, ...s);
11999
+ let c;
12000
+ if (e.pinnedParticipantId) {
12001
+ let n = this._getExternalIdByParticipantId(e.pinnedParticipantId);
12002
+ n ? c = n : t.push(e.pinnedParticipantId);
12003
+ }
11927
12004
  return {
11928
- id: e.id,
11929
- name: e.name,
11930
- participantCount: e.participantCount,
11931
- participantIds: t,
11932
- addParticipantIds: n,
11933
- removeParticipantIds: r,
11934
- participants: e.participants?.participants ? this._participantListChunkToExternalChunk(e.participants) : void 0,
11935
- active: e.active,
11936
- muteStates: e.muteStates,
11937
- pinnedParticipantId: i,
11938
- countdownSec: e.countdownSec,
11939
- timeoutMs: e.timeoutMs
12005
+ room: {
12006
+ id: e.id,
12007
+ name: e.name,
12008
+ participantCount: e.participantCount,
12009
+ participantIds: n,
12010
+ addParticipantIds: i,
12011
+ removeParticipantIds: o,
12012
+ participants: e.participants?.participants ? this._participantListChunkToExternalChunk(e.participants) : void 0,
12013
+ active: e.active,
12014
+ muteStates: e.muteStates,
12015
+ pinnedParticipantId: c,
12016
+ countdownSec: e.countdownSec,
12017
+ timeoutMs: e.timeoutMs
12018
+ },
12019
+ missingParticipantIds: t
11940
12020
  };
11941
12021
  }
11942
12022
  async _onRoomParticipantsUpdated(e) {
11943
- 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;
11944
- if (i.length && a?.length !== i.length && !this._isCalledState()) {
12023
+ let t = this._transport?.getState(), n = e.roomId ?? null, r = [], { externalIds: i, missingIds: a } = this._getExternalIdsByParticipantIds(e.addedParticipantIds ?? []);
12024
+ r.push(...a);
12025
+ let o = e.addedParticipants;
12026
+ if (i.length && o?.length !== i.length && !this._isCalledState()) {
11945
12027
  let e = this._convertExternalIdsToServerExternalIds(i);
11946
- a = (await this._signaling.getParticipants(e)).participants;
12028
+ o = (await this._signaling.getParticipants(e)).participants;
11947
12029
  }
11948
- let o = a?.map((e) => {
12030
+ let s = o?.map((e) => {
11949
12031
  let r = j.composeId(e);
11950
12032
  return this._createParticipant({
11951
12033
  id: r,
@@ -11961,38 +12043,38 @@ var ls = 15, $ = class e extends b {
11961
12043
  observedIds: e.observedIds || [],
11962
12044
  markers: this._denormalizeMarkers(r, e.markers),
11963
12045
  isInRoom: n !== null
11964
- }, e.decorativeUserId);
11965
- }) || [], s = !1;
11966
- for (let e of o) e.id === this._conversation?.compositeUserId && (s = !0), this._registerParticipantInCache(e);
11967
- this._transport?.getState() === q.IDLE && !this._isCalledState() && this._openTransport(o, !0);
11968
- let c = [];
12046
+ }, j.composeDecorativeId(e));
12047
+ }) || [], c = !1;
12048
+ for (let e of s) e.id === this._conversation?.compositeUserId && (c = !0), this._registerParticipantInCache(e);
12049
+ this._transport?.getState() === q.IDLE && !this._isCalledState() && this._openTransport(s, !0);
12050
+ let l = [];
11969
12051
  if (e?.removedParticipantMarkers) {
11970
12052
  for (let t of e.removedParticipantMarkers) if (t.GRID?.id) {
11971
12053
  let e = this._getExternalIdByParticipantId(t.GRID.id);
11972
- c.push(e);
12054
+ e ? l.push(e) : r.push(t.GRID.id);
11973
12055
  }
11974
12056
  }
11975
- if (s && await this._onRoomSwitched(n), c) {
12057
+ if (this._reportMissingExternalIds(r, "ROOM_PARTICIPANTS_UPDATED"), c && await this._onRoomSwitched(n), l) {
11976
12058
  let e = this._conversation?.pinnedParticipantIdByRoom.get(n);
11977
12059
  if (e) {
11978
12060
  let t = this._getExternalIdByParticipantId(e);
11979
12061
  if (t) {
11980
- for (let e of c) if (Q.compare(t, e)) {
12062
+ for (let e of l) if (Q.compare(t, e)) {
11981
12063
  this._conversation?.pinnedParticipantIdByRoom.delete(n);
11982
12064
  break;
11983
12065
  }
11984
12066
  }
11985
12067
  }
11986
12068
  }
11987
- let l = {
12069
+ let u = {
11988
12070
  roomId: n,
11989
12071
  participantCount: e.participantCount,
11990
12072
  addedParticipantIds: i,
11991
- addedParticipants: j.mapSharedParticipants(o),
12073
+ addedParticipants: j.mapSharedParticipants(s),
11992
12074
  removedParticipantMarkers: e?.removedParticipantMarkers,
11993
- removedParticipantIds: c
12075
+ removedParticipantIds: l
11994
12076
  };
11995
- this._isCalledState() || L.onRoomParticipantsUpdated(l, this.id);
12077
+ this._isCalledState() || L.onRoomParticipantsUpdated(u, this.id);
11996
12078
  }
11997
12079
  async _onRoomSwitched(e, t = !1) {
11998
12080
  if (!this._conversation || this._conversation.roomId === e) return;
@@ -12012,7 +12094,7 @@ var ls = 15, $ = class e extends b {
12012
12094
  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) {
12013
12095
  let e = this._participants;
12014
12096
  await this._registerParticipants(t?.participants?.participants?.filter((t) => !e[j.composeId(t)]) || [], !0);
12015
- let n = this._convertRoomToExternal(t);
12097
+ let { room: n } = this._convertRoomToExternal(t);
12016
12098
  n && r.push(n);
12017
12099
  }
12018
12100
  }
@@ -12046,7 +12128,9 @@ var ls = 15, $ = class e extends b {
12046
12128
  return;
12047
12129
  }
12048
12130
  let o = Q.fromSignaling(r, a.deviceIdx);
12049
- if (L.onParticipantIdChanged(a, o, this.id), this._api.cacheExternalId(n, o), this._api.mapDecorativeId(n, t), i) this._conversation.externalId = o;
12131
+ L.onParticipantIdChanged(a, o, this.id);
12132
+ let s = j.compose(n, a.deviceIdx), c = j.compose(t, a.deviceIdx);
12133
+ if (this._api.cacheExternalId(s, o), this._api.mapDecorativeId(s, c), i) this._conversation.externalId = o;
12050
12134
  else {
12051
12135
  let e = this._participants;
12052
12136
  e[t].externalId = o;
@@ -12218,22 +12302,16 @@ var Es = class {
12218
12302
  }
12219
12303
  log(e) {}
12220
12304
  logClientStats(e) {}
12221
- getCachedOkIdByExternalId(e) {
12305
+ getCachedParticipantIdByExternalId(e) {
12222
12306
  return null;
12223
12307
  }
12224
- getCachedRawOkIdByExternalId(e) {
12225
- return null;
12226
- }
12227
- getCachedExternalIdByOkId(e) {
12308
+ getCachedExternalIdByParticipantId(e) {
12228
12309
  return null;
12229
12310
  }
12230
12311
  cacheExternalId(e, t) {}
12231
12312
  mapDecorativeId(e, t) {}
12232
12313
  unmapDecorativeId(e) {}
12233
12314
  getDecorativeIdByInitialId(e) {}
12234
- replaceByInitialIdIdIfExists(e) {
12235
- return typeof e == "string" ? parseInt(e, 10) : e;
12236
- }
12237
12315
  hangupConversation(e, t = D.HUNGUP, n) {}
12238
12316
  async removeHistoryRecords(e) {}
12239
12317
  async getServerTime() {
@@ -12245,7 +12323,7 @@ var Es = class {
12245
12323
  }
12246
12324
  }, Ds = class e {
12247
12325
  constructor() {
12248
- h(this, "_okIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToOkId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12326
+ h(this, "_participantIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToParticipantId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12249
12327
  }
12250
12328
  static _normalizeType(e) {
12251
12329
  return e.type === to.GROUP ? {
@@ -12253,46 +12331,30 @@ var Es = class {
12253
12331
  type: to.USER
12254
12332
  } : e;
12255
12333
  }
12256
- getOkId(t) {
12257
- let n = Q.toString(e._normalizeType(t)), r = this._externalIdToOkId.get(n);
12258
- return r == null ? null : this.replaceByInitialIdIdIfExists(r);
12259
- }
12260
12334
  getExternalId(e) {
12261
- let t = this.getDecorativeIdByInitialId(e) ?? e, n = this._okIdToExternalId.get(t);
12335
+ let t = this._initialIdToDecorativeId.get(e) ?? e, n = this._participantIdToExternalId.get(t);
12262
12336
  return n == null ? null : Q.fromString(n);
12263
12337
  }
12264
- hasByExternalId(t) {
12265
- return this._externalIdToOkId.has(Q.toString(e._normalizeType(t)));
12266
- }
12267
- hasByOkId(e) {
12268
- return this._okIdToExternalId.has(e);
12338
+ getParticipantId(t) {
12339
+ let n = Q.toString(e._normalizeType(t)), r = this._externalIdToParticipantId.get(n);
12340
+ return r == null ? null : this._decorativeIdToInitialId.get(r) ?? r;
12269
12341
  }
12270
12342
  cache(t, n) {
12271
- let r = j.extractOkId(t), i = e._normalizeType(n), a = Q.toString(i);
12272
- this._okIdToExternalId.set(r, a), this._externalIdToOkId.set(a, r);
12343
+ let r = e._normalizeType(n), i = Q.toString(r);
12344
+ this._participantIdToExternalId.set(t, i), this._externalIdToParticipantId.set(i, t);
12273
12345
  }
12274
12346
  mapDecorativeId(e, t) {
12275
- let n = j.extractOkId(e), r = j.extractOkId(t);
12276
- this._decorativeIdToInitialId.set(n, r), this._initialIdToDecorativeId.set(r, n);
12347
+ this._decorativeIdToInitialId.set(e, t), this._initialIdToDecorativeId.set(t, e);
12277
12348
  }
12278
12349
  unmapDecorativeId(e) {
12279
- let t = j.extractOkId(e), n = this.getDecorativeIdByInitialId(t);
12280
- n && this._decorativeIdToInitialId.delete(n), this._initialIdToDecorativeId.delete(t);
12350
+ let t = this._initialIdToDecorativeId.get(e);
12351
+ t && this._decorativeIdToInitialId.delete(t), this._initialIdToDecorativeId.delete(e);
12281
12352
  }
12282
12353
  getDecorativeIdByInitialId(e) {
12283
- let t = j.extractOkId(e);
12284
- return this._initialIdToDecorativeId.get(t);
12285
- }
12286
- replaceByInitialIdIdIfExists(e) {
12287
- let t = j.extractOkId(e);
12288
- return this._decorativeIdToInitialId.get(t) ?? t;
12289
- }
12290
- getParticipantIdByExternalId(e) {
12291
- let t = this.getOkId(e);
12292
- return t == null ? null : j.composeParticipantId(t, A.USER, e.deviceIdx ?? 0);
12354
+ return this._initialIdToDecorativeId.get(e);
12293
12355
  }
12294
12356
  clear() {
12295
- this._okIdToExternalId.clear(), this._externalIdToOkId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12357
+ this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12296
12358
  }
12297
12359
  }, Os = "anonymLogin:", ks = 700, As = 3e3;
12298
12360
  function js(e) {
@@ -12380,8 +12442,11 @@ var Ps = class extends Es {
12380
12442
  }
12381
12443
  }
12382
12444
  userId(e) {
12383
- let { compositeUserId: t } = j.decomposeParticipantId(e), { id: n } = j.decomposeId(t);
12384
- return y.isEmpty() ? Q.fromId(String(n)) : this._idCache.getExternalId(n) || Q.fromId(String(n));
12445
+ if (y.isEmpty()) {
12446
+ let { compositeUserId: t } = j.decomposeParticipantId(e), { id: n } = j.decomposeId(t);
12447
+ return Q.fromId(String(n));
12448
+ }
12449
+ return this._idCache.getExternalId(e);
12385
12450
  }
12386
12451
  async authorize() {
12387
12452
  if (this._ensureUuid(), !M.apiKey) throw new O(x.API, {
@@ -12569,13 +12634,10 @@ var Ps = class extends Es {
12569
12634
  };
12570
12635
  return n?.length && (i.observedIds = n.join(",")), M.anonymToken && (i.anonymToken = M.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
12571
12636
  }
12572
- getCachedOkIdByExternalId(e) {
12573
- return this._idCache.getParticipantIdByExternalId(e);
12637
+ getCachedParticipantIdByExternalId(e) {
12638
+ return this._idCache.getParticipantId(e);
12574
12639
  }
12575
- getCachedRawOkIdByExternalId(e) {
12576
- return this._idCache.getOkId(e);
12577
- }
12578
- getCachedExternalIdByOkId(e) {
12640
+ getCachedExternalIdByParticipantId(e) {
12579
12641
  return this._idCache.getExternalId(e);
12580
12642
  }
12581
12643
  cacheExternalId(e, t) {
@@ -12590,9 +12652,6 @@ var Ps = class extends Es {
12590
12652
  getDecorativeIdByInitialId(e) {
12591
12653
  return this._idCache.getDecorativeIdByInitialId(e);
12592
12654
  }
12593
- replaceByInitialIdIdIfExists(e) {
12594
- return this._idCache.replaceByInitialIdIdIfExists(e);
12595
- }
12596
12655
  async getConversationParams(e) {
12597
12656
  let t = {};
12598
12657
  return M.anonymToken && (t.anonymToken = M.anonymToken), e && (t.conversationId = e), this._call("vchat.getConversationParams", t);
@@ -12742,10 +12801,16 @@ async function Xs(t) {
12742
12801
  }
12743
12802
  async function Zs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12744
12803
  let c = [];
12745
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Qs([], Va.USER, t, n, r, i, a, c, o, s);
12804
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), $s([], Va.USER, t, n, r, i, a, c, o, s);
12746
12805
  }
12747
- async function Qs(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12748
- if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12806
+ function Qs(e, t = []) {
12807
+ let n = e.getIncomingCallerExternalId();
12808
+ return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
12809
+ }
12810
+ async function $s(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12811
+ if (!M.hold && z.getActive()) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12812
+ let u = z.getAll().find((e) => e.isIncomingRinging);
12813
+ if (!M.hold && u && !Qs(u, s)) throw R.error("There is already incoming call"), new O(D.HAS_ACTIVE_CALL);
12749
12814
  return new $(new Ps(), Hs).onStart({
12750
12815
  opponentIds: e,
12751
12816
  opponentType: t,
@@ -12759,30 +12824,30 @@ async function Qs(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12759
12824
  conversationId: l
12760
12825
  });
12761
12826
  }
12762
- async function $s(e, t) {
12763
- return ec(e, A.USER, void 0, t);
12827
+ async function ec(e, t) {
12828
+ return tc(e, A.USER, void 0, t);
12764
12829
  }
12765
- async function ec(e, t = A.USER, n, r, i, a) {
12830
+ async function tc(e, t = A.USER, n, r, i, a) {
12766
12831
  if (e === $.id()) throw Error("Push has already been processed");
12767
12832
  return new $(new Ps(), Hs).onPush(e, t, n, r, i, a);
12768
12833
  }
12769
- async function tc() {
12834
+ async function nc() {
12770
12835
  return Vs.getInbounds();
12771
12836
  }
12772
- async function nc(e, t) {
12837
+ async function rc(e, t) {
12773
12838
  return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, hs()), Vs.authorize();
12774
12839
  }
12775
- async function rc(e = [S.AUDIO], t) {
12776
- return El(t).accept(e);
12840
+ async function ic(e = [S.AUDIO], t) {
12841
+ return kl(t).accept(e);
12777
12842
  }
12778
- async function ic(e) {
12779
- let t = Tl(e?.conversationId);
12843
+ async function ac(e) {
12844
+ let t = El(e?.conversationId);
12780
12845
  if (t) return t.decline(e);
12781
12846
  }
12782
- async function ac(e, t = [S.AUDIO]) {
12783
- return oc(e, t);
12847
+ async function oc(e, t = [S.AUDIO]) {
12848
+ return sc(e, t);
12784
12849
  }
12785
- async function oc(e, t, n) {
12850
+ async function sc(e, t, n) {
12786
12851
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12787
12852
  return new $(new Ps(), Hs).onJoin({
12788
12853
  conversationId: e,
@@ -12790,7 +12855,7 @@ async function oc(e, t, n) {
12790
12855
  chatId: n
12791
12856
  });
12792
12857
  }
12793
- async function sc(e, t = [S.AUDIO], n, r, i, a) {
12858
+ async function cc(e, t = [S.AUDIO], n, r, i, a) {
12794
12859
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12795
12860
  return n && (M.anonymToken = n), new $(new Ps(), Hs).onJoin({
12796
12861
  joinLink: e,
@@ -12801,30 +12866,30 @@ async function sc(e, t = [S.AUDIO], n, r, i, a) {
12801
12866
  anonymous: !!M.anonymToken
12802
12867
  });
12803
12868
  }
12804
- function cc(e) {
12805
- let t = Tl(e?.conversationId);
12869
+ function lc(e) {
12870
+ let t = El(e?.conversationId);
12806
12871
  return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
12807
12872
  }
12808
- async function lc(e, t) {
12873
+ async function uc(e, t) {
12809
12874
  let n = Array.isArray(e) ? e : [e], r = $.current();
12810
12875
  r && await r.addParticipant(n, t);
12811
12876
  }
12812
- async function uc(e, t) {
12877
+ async function dc(e, t) {
12813
12878
  let n = $.current();
12814
12879
  if (n) {
12815
12880
  let r = e.map((e) => j.composeUserId(e));
12816
12881
  await n.addParticipantLegacy(r, t);
12817
12882
  }
12818
12883
  }
12819
- async function dc(e, t = !1) {
12820
- let n = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12821
- if (!n) {
12822
- R.warn("removeParticipant: externalId not found in cache", e);
12823
- return;
12884
+ async function fc(e, t = !1) {
12885
+ let n = Al(e, "removeParticipant");
12886
+ if (n) try {
12887
+ await n.conversation.removeParticipant(j.decomposeParticipantId(n.participantId).compositeUserId, t);
12888
+ } catch (e) {
12889
+ R.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
12824
12890
  }
12825
- return fc(n, t);
12826
12891
  }
12827
- async function fc(e, t = !1) {
12892
+ async function pc(e, t = !1) {
12828
12893
  let n = $.current();
12829
12894
  if (n) try {
12830
12895
  await n.removeParticipant(j.composeUserId(e), t);
@@ -12832,13 +12897,13 @@ async function fc(e, t = !1) {
12832
12897
  R.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
12833
12898
  }
12834
12899
  }
12835
- async function pc(e, t) {
12900
+ async function mc(e, t) {
12836
12901
  let n = $.current();
12837
12902
  if (e === "videoinput" && jt.contains(t)) return M.videoFacingMode = t, n ? (T.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
12838
12903
  if (!await T._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
12839
12904
  if (n) return n.changeDevice(e);
12840
12905
  }
12841
- async function mc(e, t) {
12906
+ async function hc(e, t) {
12842
12907
  let n = typeof e == "object" ? {
12843
12908
  ...e,
12844
12909
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -12847,151 +12912,149 @@ async function mc(e, t) {
12847
12912
  captureScreen: e,
12848
12913
  fastScreenSharing: !1,
12849
12914
  captureAudio: !1
12850
- }, r = Tl(t);
12915
+ }, r = El(t);
12851
12916
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
12852
12917
  }
12853
- function hc(e) {
12918
+ function gc(e) {
12854
12919
  let t = $.current();
12855
12920
  t && t.toggleAnimojiCapturing(e);
12856
12921
  }
12857
- async function gc(e, t = !1) {
12922
+ async function _c(e, t = !1) {
12858
12923
  let n = $.current();
12859
12924
  n && await n.setVideoStream(e, t);
12860
12925
  }
12861
- async function _c(e, t) {
12862
- let n = Tl(t);
12926
+ async function vc(e, t) {
12927
+ let n = El(t);
12863
12928
  n && await n.toggleLocalVideo(e);
12864
12929
  }
12865
- async function vc(e, t) {
12866
- let n = Tl(t);
12930
+ async function yc(e, t) {
12931
+ let n = El(t);
12867
12932
  n && await n.toggleLocalAudio(e);
12868
12933
  }
12869
- async function yc(e) {
12934
+ async function bc(e) {
12870
12935
  let t = $.current();
12871
12936
  if (t) return t.setLocalResolution(e);
12872
12937
  }
12873
- async function bc(e) {
12938
+ async function xc(e) {
12874
12939
  let t = $.current();
12875
12940
  t && await t.changePriorities(e);
12876
12941
  }
12877
- async function xc(e, t) {
12942
+ async function Sc(e, t) {
12878
12943
  let n = $.current();
12879
12944
  if (n) {
12880
- let r;
12881
12945
  if (t) {
12882
- let e = n.getCachedRawOkIdByExternalId(t);
12883
- if (!e) {
12884
- R.warn("changeParticipantState: externalId not found in cache", t);
12946
+ let r = n.getCachedParticipantIdByExternalId(t);
12947
+ if (!r) {
12948
+ Dl(t, "changeParticipantState", n);
12885
12949
  return;
12886
12950
  }
12887
- r = j.composeParticipantId(e, A.USER, t.deviceIdx);
12951
+ await n.changeParticipantState(e, r);
12952
+ return;
12888
12953
  }
12889
- await n.changeParticipantState(e, r);
12954
+ await n.changeParticipantState(e);
12890
12955
  }
12891
12956
  }
12892
- async function Sc() {
12957
+ async function Cc() {
12893
12958
  let e = $.current();
12894
12959
  e && await e.putHandsDown();
12895
12960
  }
12896
- async function Cc(e) {
12961
+ async function wc(e) {
12897
12962
  let t = $.current();
12898
12963
  t && await t.updateDisplayLayout(e);
12899
12964
  }
12900
- async function wc(e) {
12965
+ async function Tc(e) {
12901
12966
  let t = $.current();
12902
12967
  t && await t.requestDisplayLayout(e);
12903
12968
  }
12904
- async function Tc(e, t, n = !1) {
12905
- let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12906
- if (!r) {
12907
- R.warn("grantRoles: externalId not found in cache", e);
12908
- return;
12909
- }
12910
- return Ec(r, Q.getDeviceIdx(e), t, n);
12969
+ async function Ec(e, t, n = !1) {
12970
+ let r = Al(e, "grantRoles");
12971
+ r && await r.conversation.grantRoles(r.participantId, t, n);
12911
12972
  }
12912
- async function Ec(e, t, n, r = !1) {
12973
+ async function Dc(e, t, n, r = !1) {
12913
12974
  let i = $.current();
12914
12975
  i && await i.grantRoles(j.composeParticipantId(e, A.USER, t), n, r);
12915
12976
  }
12916
- async function Dc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12917
- let i = null;
12918
- return e && (i = $.current()?.getCachedRawOkIdByExternalId(e) ?? null, i || R.warn("muteParticipant: externalId not found in cache", e)), Oc({
12919
- uid: i,
12920
- muteStates: t,
12921
- requestedMedia: n,
12922
- deviceIdx: Q.getDeviceIdx(e),
12923
- roomId: r
12924
- });
12977
+ async function Oc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12978
+ if (e) {
12979
+ let i = Al(e, "muteParticipant");
12980
+ return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
12981
+ }
12982
+ let i = $.current();
12983
+ i && await i.muteParticipant(null, t, n, r);
12925
12984
  }
12926
- async function Oc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12985
+ async function kc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12927
12986
  let a = $.current();
12928
12987
  if (a) {
12929
12988
  let o = e ? j.composeParticipantId(e, A.USER, r) : null;
12930
12989
  await a.muteParticipant(o, t, n, i);
12931
12990
  }
12932
12991
  }
12933
- async function kc(e, t = !1, n = null) {
12934
- let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12935
- if (!r) {
12936
- R.warn("pinParticipant: externalId not found in cache", e);
12937
- return;
12938
- }
12939
- return Ac(r, t, Q.getDeviceIdx(e), n);
12992
+ async function Ac(e, t = !1, n = null) {
12993
+ let r = Al(e, "pinParticipant");
12994
+ r && await r.conversation.pinParticipant(r.participantId, t, n);
12940
12995
  }
12941
- async function Ac(e, t = !1, n = 0, r = null) {
12996
+ async function jc(e, t = !1, n = 0, r = null) {
12942
12997
  let i = $.current();
12943
12998
  i && await i.pinParticipant(j.composeParticipantId(e, A.USER, n), t, r);
12944
12999
  }
12945
- async function jc(e) {
13000
+ async function Mc(e) {
12946
13001
  let t = $.current();
12947
13002
  t && await t.updateMediaModifiers(e);
12948
13003
  }
12949
- async function Mc(e) {
13004
+ async function Nc(e) {
12950
13005
  let t = $.current();
12951
13006
  t && await t.enableVideoSuspend(e);
12952
13007
  }
12953
- async function Nc(e) {
13008
+ async function Pc(e) {
12954
13009
  let t = $.current();
12955
13010
  t && await t.enableVideoSuspendSuggest(e);
12956
13011
  }
12957
- async function Pc(e) {
13012
+ async function Fc(e) {
12958
13013
  let t = $.current();
12959
13014
  t && await t.changeOptions(e);
12960
13015
  }
12961
- async function Fc(e, t = null) {
12962
- let n = null;
12963
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("chatMessage: externalId not found in cache", t)), Ic(e, n);
12964
- }
12965
13016
  async function Ic(e, t = null) {
13017
+ if (t) {
13018
+ let n = Al(t, "chatMessage");
13019
+ return n ? n.conversation.chatMessage(e, j.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
13020
+ }
13021
+ let n = $.current();
13022
+ n && await n.chatMessage(e, null);
13023
+ }
13024
+ async function Lc(e, t = null) {
12966
13025
  let n = $.current();
12967
13026
  if (n) {
12968
13027
  let r = t ? j.composeUserId(t) : null;
12969
13028
  await n.chatMessage(e, r);
12970
13029
  }
12971
13030
  }
12972
- async function Lc(e = 10) {
13031
+ async function Rc(e = 10) {
12973
13032
  let t = $.current();
12974
13033
  if (t) return t.chatHistory(e);
12975
13034
  }
12976
- async function Rc(e, t = null) {
12977
- let n = null;
12978
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("customData: externalId not found in cache", t)), zc(e, n, Q.getDeviceIdx(t));
13035
+ async function zc(e, t = null) {
13036
+ if (t) {
13037
+ let n = Al(t, "customData");
13038
+ return n ? n.conversation.customData(e, n.participantId) : void 0;
13039
+ }
13040
+ let n = $.current();
13041
+ n && await n.customData(e, null);
12979
13042
  }
12980
- async function zc(e, t = null, n = 0) {
13043
+ async function Bc(e, t = null, n = 0) {
12981
13044
  let r = $.current();
12982
13045
  if (r) {
12983
13046
  let i = t ? j.composeParticipantId(t, A.USER, n) : null;
12984
13047
  await r.customData(e, i);
12985
13048
  }
12986
13049
  }
12987
- async function Bc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
13050
+ async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12988
13051
  return (await Vs.createConversation(a ?? j.uuid(), e, t, {
12989
13052
  onlyAdminCanShareMovie: n,
12990
13053
  waitForAdmin: r,
12991
13054
  closedConversation: i
12992
13055
  })).join_link;
12993
13056
  }
12994
- async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13057
+ async function Hc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
12995
13058
  let a = i.map((e) => Q.fromId(e));
12996
13059
  return (await Vs.createConversation(j.uuid(), e, t, {
12997
13060
  onlyAdminCanShareMovie: n,
@@ -12999,115 +13062,114 @@ async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r
12999
13062
  audioOnly: r
13000
13063
  }, a)).join_link;
13001
13064
  }
13002
- async function Hc() {
13065
+ async function Uc() {
13003
13066
  let e = $.current();
13004
13067
  return e ? e.createJoinLink() : Promise.reject();
13005
13068
  }
13006
- async function Uc() {
13069
+ async function Wc() {
13007
13070
  let e = $.current();
13008
13071
  return e ? e.removeJoinLink() : Promise.reject();
13009
13072
  }
13010
- async function Wc(e, t) {
13073
+ async function Gc(e, t) {
13011
13074
  return Vs.getAnonymTokenByLink(e, t);
13012
13075
  }
13013
- function Gc(e) {
13076
+ function Kc(e) {
13014
13077
  let t = $.current();
13015
13078
  t && t.setVolume(e);
13016
13079
  }
13017
- function Kc(e) {
13080
+ function qc(e) {
13018
13081
  M.forceRelayPolicy = e;
13019
13082
  }
13020
- async function qc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13083
+ async function Jc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13021
13084
  let o = $.current();
13022
13085
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
13023
13086
  }
13024
- async function Jc(e = null, t) {
13087
+ async function Yc(e = null, t) {
13025
13088
  let n = $.current();
13026
13089
  return n ? n.stopStream(e, t) : Promise.reject();
13027
13090
  }
13028
- async function Yc(e = null) {
13091
+ async function Xc(e = null) {
13029
13092
  let t = $.current();
13030
13093
  return t ? t.publishStream(e) : Promise.reject();
13031
13094
  }
13032
- async function Xc() {
13095
+ async function Zc() {
13033
13096
  let e = $.current();
13034
13097
  return e ? e.getStreamInfo() : Promise.reject();
13035
13098
  }
13036
- async function Zc(e) {
13099
+ async function Qc(e) {
13037
13100
  let t = $.current();
13038
13101
  return t ? t.addMovie(e) : Promise.reject();
13039
13102
  }
13040
- async function Qc(e) {
13103
+ async function $c(e) {
13041
13104
  let t = $.current();
13042
13105
  return t ? t.updateMovie(e) : Promise.reject();
13043
13106
  }
13044
- async function $c(e) {
13107
+ async function el(e) {
13045
13108
  let t = $.current();
13046
13109
  return t ? t.removeMovie(e) : Promise.reject();
13047
13110
  }
13048
- async function el(e, t) {
13111
+ async function tl(e, t) {
13049
13112
  let n = $.current();
13050
13113
  if (n) {
13051
- let r = [];
13114
+ let r = [], i = [];
13052
13115
  for (let t of e) {
13053
- let e, i;
13116
+ let e, a;
13054
13117
  t.addParticipantIds && (e = [], t.addParticipantIds.forEach((t) => {
13055
- let r = n.getCachedRawOkIdByExternalId(t);
13056
- r ? e.push(j.composeUserId(r)) : R.warn("updateRooms addParticipant: externalId not found in cache", t);
13057
- })), t.removeParticipantIds && (i = [], t.removeParticipantIds.forEach((e) => {
13058
- let t = n.getCachedRawOkIdByExternalId(e);
13059
- t ? i.push(j.composeUserId(t)) : R.warn("updateRooms removeParticipant: externalId not found in cache", e);
13118
+ let r = n.getCachedParticipantIdByExternalId(t);
13119
+ r ? e.push(j.decomposeParticipantId(r).compositeUserId) : i.push(t.id);
13120
+ })), t.removeParticipantIds && (a = [], t.removeParticipantIds.forEach((e) => {
13121
+ let t = n.getCachedParticipantIdByExternalId(e);
13122
+ t ? a.push(j.decomposeParticipantId(t).compositeUserId) : i.push(e.id);
13060
13123
  })), r.push({
13061
13124
  id: t.id,
13062
13125
  name: t.name,
13063
13126
  participantCount: t.participantCount,
13064
13127
  addParticipantIds: e,
13065
- removeParticipantIds: i,
13128
+ removeParticipantIds: a,
13066
13129
  countdownSec: t.countdownSec
13067
13130
  });
13068
13131
  }
13132
+ if (i.length) {
13133
+ Ol(i, "updateRooms", n);
13134
+ return;
13135
+ }
13069
13136
  return n.updateRooms(r, t);
13070
13137
  }
13071
13138
  return Promise.reject();
13072
13139
  }
13073
- async function tl(e, t) {
13140
+ async function nl(e, t) {
13074
13141
  let n = $.current();
13075
13142
  return n ? n.activateRooms(e, t) : Promise.reject();
13076
13143
  }
13077
- async function nl(e = null, t = null) {
13144
+ async function rl(e = null, t = null) {
13078
13145
  let n = $.current();
13079
13146
  if (!n) return Promise.reject();
13080
13147
  let r;
13081
- if (t) {
13082
- let e = n.getCachedRawOkIdByExternalId(t);
13083
- if (!e) {
13084
- R.warn("switchRoom: externalId not found in cache", t);
13085
- return;
13086
- }
13087
- let i = Q.getDeviceIdx(t);
13088
- r = j.composeParticipantId(e, A.USER, i);
13148
+ if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
13149
+ Dl(t, "switchRoom", n);
13150
+ return;
13089
13151
  }
13090
13152
  return n.switchRoom(e, r);
13091
13153
  }
13092
- async function rl(e) {
13154
+ async function il(e) {
13093
13155
  let t = $.current();
13094
13156
  return t ? t.removeRooms(e) : Promise.reject();
13095
13157
  }
13096
- function il(e) {
13158
+ function al(e) {
13097
13159
  M.statisticsInterval = e;
13098
13160
  let t = $.current();
13099
13161
  if (t) return t.updateStatisticsInterval();
13100
13162
  }
13101
- function al(t) {
13163
+ function ol(t) {
13102
13164
  e.disableLog(!t), R.toggle(t);
13103
13165
  }
13104
- function ol(e, ...t) {
13166
+ function sl(e, ...t) {
13105
13167
  M.debugLog && ($.debugMessage(e, "[external]", ...t) || R.send(e, "[external]", ...t));
13106
13168
  }
13107
- function sl(e, t, ...n) {
13169
+ function cl(e, t, ...n) {
13108
13170
  M.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || R.send(e, "[external]", ...n));
13109
13171
  }
13110
- var cl = {
13172
+ var ll = {
13111
13173
  list: Ne,
13112
13174
  get: Pe,
13113
13175
  getJson: Fe,
@@ -13115,7 +13177,7 @@ var cl = {
13115
13177
  clear: Le,
13116
13178
  stats: Re
13117
13179
  };
13118
- function ll() {
13180
+ function ul() {
13119
13181
  let e = [
13120
13182
  [`Calls SDK ${M.sdkVersion}`, M.toJSON()],
13121
13183
  ["UserAgent:", navigator.userAgent],
@@ -13132,124 +13194,139 @@ function ll() {
13132
13194
  d: e
13133
13195
  }));
13134
13196
  }
13135
- async function ul() {
13197
+ async function dl() {
13136
13198
  let e = $.id(), t = $.debugSessionId();
13137
13199
  if (!t || !e) throw R.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
13138
13200
  let n = await Pe({ sessionId: t });
13139
13201
  if (n.length === 0) throw R.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
13140
13202
  let r = n[0].t, i = n[n.length - 1].t;
13141
13203
  try {
13142
- return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ll(), ...n]));
13204
+ return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ul(), ...n]));
13143
13205
  } catch (e) {
13144
13206
  throw R.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
13145
13207
  }
13146
13208
  }
13147
- async function dl(e) {
13209
+ async function fl(e) {
13148
13210
  let t = $.current();
13149
13211
  if (t) return t.videoEffect(e);
13150
13212
  }
13151
- async function fl(e, t) {
13213
+ async function pl(e, t) {
13152
13214
  let n = $.current();
13153
13215
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
13154
13216
  }
13155
- async function pl(e) {
13217
+ async function ml(e) {
13156
13218
  let t = $.current();
13157
13219
  t && await t.setAudioStream(e);
13158
13220
  }
13159
- async function ml(e, t = null, n = null) {
13221
+ async function hl(e, t = null, n = null) {
13160
13222
  let r = $.current();
13161
13223
  if (!r) return;
13162
13224
  let i = n ?? t?.id, a = null;
13163
- if (t) {
13164
- let e = r.getCachedRawOkIdByExternalId(t);
13165
- if (!e) throw Error("Could not get user id to set animoji svg");
13166
- a = j.composeParticipantId(e, A.USER, Q.getDeviceIdx(t));
13225
+ if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
13226
+ Dl(t, "setVmojiSvg", r);
13227
+ return;
13167
13228
  }
13168
13229
  r.setAnimojiSvg(e, a, i);
13169
13230
  }
13170
- function hl(e) {
13231
+ function gl(e) {
13171
13232
  let t = $.current();
13172
13233
  t && t.setAnimojiFill(e);
13173
13234
  }
13174
- async function gl(e = null, t, n = !1) {
13175
- return El().getWaitingHall(e, t, n);
13235
+ async function _l(e = null, t, n = !1) {
13236
+ return kl().getWaitingHall(e, t, n);
13176
13237
  }
13177
- async function _l() {
13178
- return El().getAudienceModeHands();
13238
+ async function vl() {
13239
+ return kl().getAudienceModeHands();
13179
13240
  }
13180
- async function vl(e, t = !1) {
13181
- let n = El(), r;
13241
+ async function yl(e, t = !1) {
13242
+ let n = kl(), r;
13182
13243
  if (e) {
13183
- let t = n.getCachedRawOkIdByExternalId(e);
13244
+ let t = n.getCachedParticipantIdByExternalId(e);
13184
13245
  if (!t) {
13185
- R.warn("promoteParticipant: externalId not found in cache", e);
13246
+ Dl(e, "promoteParticipant", n);
13186
13247
  return;
13187
13248
  }
13188
- r = j.composeUserId(t);
13249
+ r = j.decomposeParticipantId(t).compositeUserId;
13189
13250
  }
13190
13251
  return n.promoteParticipant(r, t);
13191
13252
  }
13192
- async function yl(e = !1) {
13193
- return El().requestPromotion(e);
13194
- }
13195
13253
  async function bl(e = !1) {
13196
- return El().acceptPromotion(e);
13254
+ return kl().requestPromotion(e);
13197
13255
  }
13198
- async function xl(e) {
13199
- return El().getParticipantListChunk(e);
13256
+ async function xl(e = !1) {
13257
+ return kl().acceptPromotion(e);
13200
13258
  }
13201
13259
  async function Sl(e) {
13202
- return El().getParticipants(e);
13260
+ return kl().getParticipantListChunk(e);
13203
13261
  }
13204
13262
  async function Cl(e) {
13205
- return El().feedback(e);
13263
+ return kl().getParticipants(e);
13206
13264
  }
13207
- async function wl(e, t, n) {
13208
- return El(n).enableFeatureForRoles(e, t);
13265
+ async function wl(e) {
13266
+ return kl().feedback(e);
13209
13267
  }
13210
- function Tl(e) {
13211
- return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13268
+ async function Tl(e, t, n) {
13269
+ return kl(n).enableFeatureForRoles(e, t);
13212
13270
  }
13213
13271
  function El(e) {
13214
- let t = Tl(e);
13272
+ return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13273
+ }
13274
+ function Dl(e, t, n) {
13275
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
13276
+ }
13277
+ function Ol(e, t, n) {
13278
+ let r = Array.from(new Set(e));
13279
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
13280
+ }
13281
+ function kl(e) {
13282
+ let t = El(e);
13215
13283
  if (!t) throw Error("Conversation not found");
13216
13284
  return t;
13217
13285
  }
13218
- async function Dl(e) {
13286
+ function Al(e, t) {
13287
+ let n = $.current();
13288
+ if (!n) return null;
13289
+ let r = n.getCachedParticipantIdByExternalId(e);
13290
+ return r ? {
13291
+ conversation: n,
13292
+ participantId: r
13293
+ } : (Dl(e, t, n), null);
13294
+ }
13295
+ async function jl(e) {
13219
13296
  await Vs.removeHistoryRecords(e);
13220
13297
  }
13221
- async function Ol(e) {
13298
+ async function Ml(e) {
13222
13299
  let t = $.current() ?? z.getFirst();
13223
13300
  t && await t.startAsr(e);
13224
13301
  }
13225
- async function kl(e) {
13302
+ async function Nl(e) {
13226
13303
  let t = $.current() ?? z.getFirst();
13227
13304
  t && await t.stopAsr(e);
13228
13305
  }
13229
- async function Al(e) {
13306
+ async function Pl(e) {
13230
13307
  let t = $.current() ?? z.getFirst();
13231
13308
  t && await t.requestAsr(e);
13232
13309
  }
13233
- async function jl(e) {
13310
+ async function Fl(e) {
13234
13311
  let t = $.current();
13235
13312
  return t ? t.startUrlSharing(e) : Promise.reject();
13236
13313
  }
13237
- async function Ml() {
13314
+ async function Il() {
13238
13315
  let e = $.current();
13239
13316
  return e ? e.stopUrlSharing() : Promise.reject();
13240
13317
  }
13241
- async function Nl(e) {
13318
+ async function Ll(e) {
13242
13319
  await z.switchCall(e);
13243
13320
  }
13244
- function Pl() {
13321
+ function Rl() {
13245
13322
  return z.getActiveId();
13246
13323
  }
13247
- function Fl() {
13324
+ function zl() {
13248
13325
  return $.getSyncedTime();
13249
13326
  }
13250
- function Il() {
13327
+ function Bl() {
13251
13328
  return M.sdkVersion;
13252
13329
  }
13253
13330
  typeof window < "u" && (window.__CALLS_SDK = yn);
13254
13331
  //#endregion
13255
- 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 };
13332
+ 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 };