@vkontakte/calls-sdk 2.8.13-dev.7195a780.0 → 2.8.13-dev.805c82c2.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.13-dev.7195a780.0
3
- * Wed, 09 Sep 2026 12:14:39 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-dev.805c82c2.0
3
+ * Mon, 21 Sep 2026 08:19:28 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
  }
@@ -2152,10 +2152,13 @@ var yn = vn.getInstance(), M = class e {
2152
2152
  return "ok.calls.sdk.js";
2153
2153
  }
2154
2154
  static get appVersion() {
2155
+ return e._params.appVersion;
2156
+ }
2157
+ static get apiClientVersion() {
2155
2158
  return 1.1;
2156
2159
  }
2157
2160
  static get sdkVersion() {
2158
- return "2.8.13-dev.7195a780.0";
2161
+ return "2.8.13-dev.805c82c2.0";
2159
2162
  }
2160
2163
  static get debug() {
2161
2164
  return e._params.debug;
@@ -2395,6 +2398,9 @@ var yn = vn.getInstance(), M = class e {
2395
2398
  static get transportConnectionWaitTime() {
2396
2399
  return e._params.transportConnectionWaitTime;
2397
2400
  }
2401
+ static get switchTopologyOnReconnectFromAnySide() {
2402
+ return e._params.switchTopologyOnReconnectFromAnySide;
2403
+ }
2398
2404
  static get statisticsInterval() {
2399
2405
  return e._params.statisticsInterval;
2400
2406
  }
@@ -2578,6 +2584,7 @@ var yn = vn.getInstance(), M = class e {
2578
2584
  movieShare: e._params.movieShare,
2579
2585
  clientType: e._params.clientType,
2580
2586
  clientStatsPlatform: e._params.clientStatsPlatform,
2587
+ appVersion: e._params.appVersion,
2581
2588
  consumerScreenDataChannelPacketSize: e._params.consumerScreenDataChannelPacketSize,
2582
2589
  switchVideoAtBadNetwork: e._params.switchVideoAtBadNetwork,
2583
2590
  simulcast: e._params.simulcast,
@@ -2593,6 +2600,7 @@ var yn = vn.getInstance(), M = class e {
2593
2600
  h(M, "_params", {
2594
2601
  platform: "WEB",
2595
2602
  clientStatsPlatform: "",
2603
+ appVersion: "0.0.0",
2596
2604
  clientType: "PORTAL",
2597
2605
  externalUserType: "",
2598
2606
  device: "browser",
@@ -2638,6 +2646,7 @@ h(M, "_params", {
2638
2646
  vmojiOptions: null,
2639
2647
  iceRestartWaitTime: 2e4,
2640
2648
  transportConnectionWaitTime: 5e3,
2649
+ switchTopologyOnReconnectFromAnySide: !1,
2641
2650
  statisticsInterval: 5e3,
2642
2651
  networkStatisticsInterval: 2e4,
2643
2652
  perfStatReportEnabled: !0,
@@ -3065,6 +3074,10 @@ var xn;
3065
3074
  P("onPeerRegistered", e, t);
3066
3075
  }
3067
3076
  e.onPeerRegistered = ot;
3077
+ function st(e, t) {
3078
+ P("onNonFatalError", e, t);
3079
+ }
3080
+ e.onNonFatalError = st;
3068
3081
  })(xn || (xn = {}));
3069
3082
  var L = xn, Sn = /* @__PURE__ */ function(e) {
3070
3083
  return e.DEBUG = "DEBUG", e.LOG = "LOG", e.WARN = "WARN", e.ERROR = "ERROR", e;
@@ -4254,8 +4267,8 @@ var Mr = class {
4254
4267
  this._reconnectionTimeout = null, this._neverConnected ? this._requestTopologySwitch() : this._startIceRestart();
4255
4268
  }, M.transportConnectionWaitTime));
4256
4269
  }
4257
- _requestTopologySwitch() {
4258
- this._isMaster && this._signaling.ready && (this._debug.log("Switch topology DIRECT to SERVER", { participantId: this._participantId }), this._signaling.switchTopology(J.SERVER).catch((e) => {
4270
+ _requestTopologySwitch(e = !1) {
4271
+ (this._isMaster || e) && this._signaling.ready && (this._debug.log("Switch topology DIRECT to SERVER", { participantId: this._participantId }), this._signaling.switchTopology(J.SERVER).catch((e) => {
4259
4272
  e instanceof wn || this._debug.warn("Unable to switch topology DIRECT to SERVER", e);
4260
4273
  }));
4261
4274
  }
@@ -4264,7 +4277,7 @@ var Mr = class {
4264
4277
  }
4265
4278
  _startIceRestart() {
4266
4279
  this._isMaster ? (this._logger?.log(C.ICE_RESTART), this._debug.log("Ice restart", { participantId: this._participantId }), this._createOffer(!0).catch(this.close.bind(this))) : this._debug.debug("Waiting for ice restart...", { participantId: this._participantId }), this._iceRestartTimeout = window.setTimeout(() => {
4267
- this._iceRestartTimeout = null, this._debug.error("Ice restart failed", { participantId: this._participantId }), this._logger?.log(C.ERROR, "iceRestart-direct"), this._requestTopologySwitch();
4280
+ this._iceRestartTimeout = null, this._debug.error("Ice restart failed", { participantId: this._participantId }), this._logger?.log(C.ERROR, "iceRestart-direct"), this._requestTopologySwitch(M.switchTopologyOnReconnectFromAnySide);
4268
4281
  }, M.iceRestartWaitTime);
4269
4282
  }
4270
4283
  async _createOffer(t) {
@@ -4916,7 +4929,7 @@ var Qr = class {
4916
4929
  }
4917
4930
  }, ui = class extends oi {
4918
4931
  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();
4932
+ 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
4933
  }
4921
4934
  _processFrame(e) {
4922
4935
  e.keyframe && (this._decoderQueue = []), this._decoderQueue.push(e), this._decodeQueue();
@@ -4931,7 +4944,11 @@ var Qr = class {
4931
4944
  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
4945
  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
4946
  }, (e) => {
4934
- this._decoderBusy = !1, this._decodeQueue(), this._decoder instanceof ti && typeof e == "string" && e.includes("EncodingError") && this._switchToLibVPXDecoder();
4947
+ if (this._decoderBusy = !1, this._decoder instanceof ti && typeof e == "string" && e.includes("EncodingError")) {
4948
+ 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();
4949
+ return;
4950
+ }
4951
+ this._decodeQueue();
4935
4952
  }, this._onKeyFrameRequested).then(() => {
4936
4953
  this._decoderReady = !0, this._decodeQueue();
4937
4954
  }).catch((e) => {
@@ -4939,7 +4956,7 @@ var Qr = class {
4939
4956
  });
4940
4957
  }
4941
4958
  _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);
4959
+ 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
4960
  }
4944
4961
  _decodeQueue() {
4945
4962
  if (!this._decoderReady || this._decoderBusy) return;
@@ -6987,7 +7004,7 @@ var ya = va, ba = {
6987
7004
  }
6988
7005
  _buildUrl(e, t) {
6989
7006
  let n = new URL(e), r = n.searchParams;
6990
- return r.set("platform", M.platform), r.set("appVersion", String(M.appVersion)), r.set("version", String(M.protocolVersion)), r.set("device", M.device), r.set("capabilities", xa.getFlags()), r.set("clientType", M.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === vr.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), M.useParticipantListChunk && (r.set("partIdx", String(M.participantListChunkInitIndex)), M.participantListChunkInitCount !== null && r.set("partCount", String(M.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
7007
+ return r.set("platform", M.platform), r.set("appVersion", M.appVersion), r.set("version", String(M.protocolVersion)), r.set("device", M.device), r.set("capabilities", xa.getFlags()), r.set("clientType", M.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === vr.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), M.useParticipantListChunk && (r.set("partIdx", String(M.participantListChunkInitIndex)), M.participantListChunkInitCount !== null && r.set("partCount", String(M.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
6991
7008
  }
6992
7009
  _canUseWebTransport() {
6993
7010
  return !this.forceWebSocket && Aa.isBrowserSupported() && this.wtEndpoint !== null && M.webtransport;
@@ -8251,8 +8268,8 @@ var bo = 90, xo = 3, So = class extends b {
8251
8268
  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
8269
  }
8253
8270
  }, 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;
8271
+ constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i, onNonFatalError: a }) {
8272
+ 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
8273
  }
8257
8274
  request(e) {
8258
8275
  this._pendingRequests = e.slice(), this._lastRequests = e.slice();
@@ -8288,11 +8305,16 @@ var bo = 90, xo = 3, So = class extends b {
8288
8305
  this._pendingRequests = null, this._pendingPromises = [];
8289
8306
  let r = {};
8290
8307
  try {
8291
- r = this._getRequestLayouts(t);
8292
- let i = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8308
+ let i = this._getRequestLayouts(t);
8309
+ if (!i) {
8310
+ n.forEach(({ resolve: e }) => e());
8311
+ return;
8312
+ }
8313
+ r = i;
8314
+ let a = this._forceNextFlush || Object.keys(this._uncertainLayouts).length > 0;
8293
8315
  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());
8316
+ let o = this._getDiff(r, a);
8317
+ o.length && await this._updateDisplayLayout(o), e === this._generation && (this._requestedLayouts = r, this._uncertainLayouts = {}), n.forEach(({ resolve: e }) => e());
8296
8318
  } catch (t) {
8297
8319
  e === this._generation ? (this._uncertainLayouts = {
8298
8320
  ...this._uncertainLayouts,
@@ -8303,30 +8325,30 @@ var bo = 90, xo = 3, So = class extends b {
8303
8325
  }
8304
8326
  }
8305
8327
  _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}`);
8328
+ let t = {}, n = [], r = this._getParticipants();
8329
+ for (let i of e) {
8330
+ let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedParticipantIdByExternalId(e);
8331
+ if (!a) {
8332
+ this._debug.log(`Unknown participant external ID ${typeof i.uid == "object" ? Q.toString(i.uid) : i.uid}`), n.push(e.id);
8311
8333
  continue;
8312
8334
  }
8313
- if (!n[i] && !this._isMe(i)) continue;
8314
- let a = Mn({
8315
- participantId: i,
8316
- mediaType: r.mediaType,
8317
- streamName: r.streamName
8335
+ if (!r[a] && !this._isMe(a)) continue;
8336
+ let o = Mn({
8337
+ participantId: a,
8338
+ mediaType: i.mediaType,
8339
+ streamName: i.streamName
8318
8340
  });
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 }
8341
+ t[o] = {
8342
+ uid: i.uid,
8343
+ mediaType: i.mediaType,
8344
+ width: i.width,
8345
+ height: i.height,
8346
+ fit: i.cover ? "cv" : "cn",
8347
+ ...i.priority === void 0 ? {} : { priority: i.priority },
8348
+ ...i.streamName === void 0 ? {} : { streamName: i.streamName }
8327
8349
  };
8328
8350
  }
8329
- return t;
8351
+ 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
8352
  }
8331
8353
  _getDiff(e, t = !1) {
8332
8354
  let n = [];
@@ -8365,7 +8387,7 @@ var bo = 90, xo = 3, So = class extends b {
8365
8387
  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
8388
  try {
8367
8389
  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);
8390
+ 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
8391
  } catch {}
8370
8392
  }
8371
8393
  get track() {
@@ -8475,9 +8497,8 @@ var bo = 90, xo = 3, So = class extends b {
8475
8497
  this._triggerEvent("VOLUMES_DETECTED", e);
8476
8498
  }
8477
8499
  _getAudioTrackLevelByParticipantId(e) {
8478
- if (this._isTransparentAudioMode()) return this._getTransparentAudioLevelByParticipantId(e);
8479
8500
  let t = this._detectors.get(qr.AUDIO_MIX);
8480
- return t ? t.getLevel() : null;
8501
+ return t ? t.getLevel() : this._getTransparentAudioLevelByParticipantId(e);
8481
8502
  }
8482
8503
  _getTransparentAudioLevelByParticipantId(e) {
8483
8504
  if (!this._activeParticipants?.includes(e)) return null;
@@ -8494,9 +8515,6 @@ var bo = 90, xo = 3, So = class extends b {
8494
8515
  _onTopologyChanged(e) {
8495
8516
  this._topology = e, this._destroyDetectors(), e === J.DIRECT && (this._activeParticipants = null, this._removedParticipants = null);
8496
8517
  }
8497
- _isTransparentAudioMode() {
8498
- return this._topology === J.SERVER && M.transparentAudio;
8499
- }
8500
8518
  _destroyDetectors() {
8501
8519
  this._detectors.forEach((e) => {
8502
8520
  e.destroy();
@@ -9348,7 +9366,8 @@ var ls = 15, $ = class e extends b {
9348
9366
  debug: this._debug,
9349
9367
  getParticipants: () => this._participants,
9350
9368
  isMe: (e) => this._isMe(e),
9351
- updateDisplayLayout: (e) => this.updateDisplayLayout(e)
9369
+ updateDisplayLayout: (e) => this.updateDisplayLayout(e),
9370
+ onNonFatalError: (e) => this._onNonFatalError(e)
9352
9371
  }), this._onUnload = () => {
9353
9372
  this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? D.CANCELED : D.HUNGUP), this._stats.destroy();
9354
9373
  }, 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 +9403,9 @@ var ls = 15, $ = class e extends b {
9384
9403
  get isCallHeld() {
9385
9404
  return this._state === "HELD";
9386
9405
  }
9406
+ get isIncomingRinging() {
9407
+ return this._conversation?.direction === Ba.INCOMING && this._state === "IDLE";
9408
+ }
9387
9409
  static debugSessionId() {
9388
9410
  return e.current()?.debugSessionId ?? null;
9389
9411
  }
@@ -9401,8 +9423,14 @@ var ls = 15, $ = class e extends b {
9401
9423
  get debugSessionId() {
9402
9424
  return this._debug.sessionId;
9403
9425
  }
9404
- getCachedRawOkIdByExternalId(e) {
9405
- return this._api.getCachedRawOkIdByExternalId(e);
9426
+ getCachedParticipantIdByExternalId(e) {
9427
+ return this._api.getCachedParticipantIdByExternalId(e);
9428
+ }
9429
+ _onNonFatalError(e) {
9430
+ L.onNonFatalError(Error(e), this.id);
9431
+ }
9432
+ getIncomingCallerExternalId() {
9433
+ return this._conversation?.direction === Ba.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
9406
9434
  }
9407
9435
  _buildInternalParams() {
9408
9436
  let e = {
@@ -9445,11 +9473,15 @@ var ls = 15, $ = class e extends b {
9445
9473
  description: "not-initialized-after-start"
9446
9474
  } });
9447
9475
  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", {
9476
+ if (this._debug.debug("Outgoing call", {
9449
9477
  opponentIds: e,
9450
9478
  opponentType: t,
9451
9479
  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(() => {
9480
+ }), 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) {
9481
+ let e = z.get(this._conversation.id);
9482
+ e && e !== this && e._close(new O(D.HUNGUP, { remote: !0 }));
9483
+ }
9484
+ 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
9485
  this._calleeUnavailableTimer = null, this._close(new O(D.CALLEE_UNAVAILABLE), { signalingReason: D.CANCELED });
9454
9486
  }, f)), this._conversation;
9455
9487
  } catch (e) {
@@ -9506,7 +9538,11 @@ var ls = 15, $ = class e extends b {
9506
9538
  }
9507
9539
  }
9508
9540
  _extractExternalRooms(e) {
9509
- return e.map(this._convertRoomToExternal.bind(this)).filter((e) => !!e);
9541
+ let t = [], n = [];
9542
+ return e.forEach((e) => {
9543
+ let { room: r, missingParticipantIds: i } = this._convertRoomToExternal(e);
9544
+ r && n.push(r), t.push(...i);
9545
+ }), this._reportMissingExternalIds(t, "EXTRACT_EXTERNAL_ROOMS"), n.filter((e) => !!e);
9510
9546
  }
9511
9547
  _extractExternalRoomsData(e, t) {
9512
9548
  if (!e || !e.length) return;
@@ -9731,7 +9767,8 @@ var ls = 15, $ = class e extends b {
9731
9767
  D.CALLEE_IS_OFFLINE,
9732
9768
  D.CALLEE_UNAVAILABLE,
9733
9769
  D.CALLER_IS_BLOCKED,
9734
- D.CALLER_IS_REJECTED
9770
+ D.CALLER_IS_REJECTED,
9771
+ D.HAS_ACTIVE_CALL
9735
9772
  ].indexOf(e.hangup) !== -1 || e.hangup === D.REJECTED && !e.remote) {
9736
9773
  this._emitHangupOnce(e, i), this._destroy(r);
9737
9774
  return;
@@ -9988,19 +10025,17 @@ var ls = 15, $ = class e extends b {
9988
10025
  isInRoom: !1,
9989
10026
  markers: null
9990
10027
  }, 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;
10028
+ if (!i) {
10029
+ let e = this._getParticipantId(t ?? r.id);
10030
+ e && (r.externalId = e);
10031
+ }
10032
+ 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
10033
  }
9993
10034
  _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
- }
10035
+ let t = this._api.userId(e);
10036
+ if (t) return t;
10037
+ let { compositeUserId: n, deviceIdx: r } = j.decomposeParticipantId(e), { id: i, type: a } = j.decomposeId(n);
10038
+ return a === A.GROUP ? Q.fromId(String(i), void 0, r) : null;
10004
10039
  }
10005
10040
  _cacheParticipantExternalIds(e) {
10006
10041
  e.forEach((e) => {
@@ -10008,7 +10043,7 @@ var ls = 15, $ = class e extends b {
10008
10043
  if (n) {
10009
10044
  this._api.cacheExternalId(t, n);
10010
10045
  let r = j.composeDecorativeId(e), i = Q.fromSignalingParticipant(e);
10011
- r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(e.decorativeUserId, e.id));
10046
+ r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(r, t));
10012
10047
  }
10013
10048
  });
10014
10049
  }
@@ -10057,7 +10092,11 @@ var ls = 15, $ = class e extends b {
10057
10092
  audienceMode: this._isAudienceMode(t),
10058
10093
  restricted: this._isRestricted(t),
10059
10094
  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();
10095
+ }, 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");
10096
+ let l = z.get(this._conversation.id);
10097
+ if (l && l !== this) this._conversation.concurrent = !0;
10098
+ else if (!M.hold && z.callsLength > 0) throw new O(D.HAS_ACTIVE_CALL);
10099
+ this._changeFeatureSet(), this._changeFeaturesPerRole(), this._logDevices();
10061
10100
  }
10062
10101
  _updateConversation(e) {
10063
10102
  if (!this._conversation) throw new O(D.UNKNOWN_ERROR, { callError: {
@@ -10187,33 +10226,40 @@ var ls = 15, $ = class e extends b {
10187
10226
  _getExistedParticipantByIdOrCreate(e) {
10188
10227
  let t = this._participants[e];
10189
10228
  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);
10229
+ let n = this._api.getDecorativeIdByInitialId(e), r = this._getParticipantId(e), { deviceIdx: i } = j.decomposeParticipantId(e);
10191
10230
  return this._createParticipant({
10192
10231
  id: e,
10193
- externalId: {
10194
- ...i,
10195
- deviceIdx: a
10196
- }
10197
- }, r, !1);
10232
+ externalId: r ? {
10233
+ ...r,
10234
+ deviceIdx: i
10235
+ } : void 0
10236
+ }, n, !1);
10198
10237
  }
10199
10238
  _getExternalIdByParticipantId(e) {
10200
- if (this._isMe(e)) return this._conversation?.externalId;
10239
+ if (this._isMe(e)) return this._conversation?.externalId ?? null;
10201
10240
  if (M.useParticipantListChunk) return this._getExistedParticipantByIdOrCreate(e).externalId;
10202
10241
  let t = this._participants;
10203
10242
  if (t[e]?.externalId) return t[e].externalId;
10204
- {
10205
- let t = this._getParticipantId(e);
10206
- return this._api.cacheExternalId(e, t), t;
10207
- }
10243
+ let n = this._api.getCachedExternalIdByParticipantId(e);
10244
+ if (n) return n;
10245
+ let r = this._getParticipantId(e);
10246
+ return r && this._api.cacheExternalId(e, r), r;
10247
+ }
10248
+ _getExternalIdsByParticipantIds(e) {
10249
+ let t = [], n = [];
10250
+ return e.forEach((e) => {
10251
+ let r = this._getExternalIdByParticipantId(e);
10252
+ r ? t.push(r) : n.push(e);
10253
+ }), {
10254
+ externalIds: t,
10255
+ missingIds: n
10256
+ };
10208
10257
  }
10209
- _getExternalIdsByOkIdsFromCache(e) {
10210
- return e.map((e) => this._api.getCachedExternalIdByOkId(e) ?? Q.fromId(String(e)));
10258
+ _reportMissingExternalIds(e, t) {
10259
+ e.length && this._onNonFatalError(`External ID mapping not found for participants "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10211
10260
  }
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;
10261
+ _reportMissingExternalIdsById(e, t) {
10262
+ e.length && this._onNonFatalError(`Participant ID mapping not found for external IDs "${Array.from(new Set(e)).join("\", \"")}" while handling ${t}`);
10217
10263
  }
10218
10264
  _registerParticipantAndSetMarkersIfChunkEnabled(e, t) {
10219
10265
  if (M.useParticipantListChunk) {
@@ -10498,30 +10544,34 @@ var ls = 15, $ = class e extends b {
10498
10544
  async updateDisplayLayout(e) {
10499
10545
  if (e.length < 1 || !this._signaling.ready) return;
10500
10546
  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) {
10547
+ let t = {}, n = [], r = [], i = this._participants;
10548
+ for (let a of e) {
10549
+ let e = typeof a.uid == "object" ? a.uid : Q.fromId(a.uid), o = this._api.getCachedParticipantIdByExternalId(e);
10550
+ if (!o) {
10505
10551
  let t = Q.toString(e);
10506
- this._debug.log(`Unknown participant external ID ${t}`);
10552
+ this._debug.log(`Unknown participant external ID ${t}`), r.push(e.id);
10507
10553
  continue;
10508
10554
  }
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();
10555
+ let s = Mn({
10556
+ participantId: o,
10557
+ mediaType: a.mediaType,
10558
+ streamName: a.streamName
10559
+ }), c = i[o];
10560
+ c ? n.push(() => {
10561
+ c.lastRequestedLayouts[s] = a;
10562
+ }) : this._isMe(o) && n.push(() => {
10563
+ this._myLastRequestedLayouts[s] = a;
10564
+ }), Dn(a) ? (this._isMe(o) && n.push(() => {
10565
+ delete this._myLastRequestedLayouts[s];
10566
+ }), 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));
10567
+ }
10568
+ if (r.length) {
10569
+ this._reportMissingExternalIdsById(r, "updateDisplayLayout");
10570
+ return;
10571
+ }
10572
+ let a = this._cooldownTimestampByStreamDescription.keys();
10523
10573
  for (; this._streamIdByStreamDescription.size > M.videoTracksCount;) {
10524
- let e = i.next();
10574
+ let e = a.next();
10525
10575
  if (e.done) {
10526
10576
  this._debug.error("Cannot accommodate all streaming requests: tracks available " + M.videoTracksCount + "; requested streams: " + Array.from(this._streamIdByStreamDescription.keys()));
10527
10577
  break;
@@ -10613,17 +10663,22 @@ var ls = 15, $ = class e extends b {
10613
10663
  async _onParticipantPromoted(e) {
10614
10664
  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
10665
  }
10616
- async _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10666
+ _onChatRoomUpdated(e, t = 0, n = [], r, i) {
10617
10667
  this._debug.log(`Chat room updated: ${e}`);
10618
- let a = [];
10668
+ let a = [], o = [];
10619
10669
  n.length && n.forEach((e) => {
10620
10670
  if (e.externalId) {
10621
10671
  let t = Q.fromSignaling(e.externalId);
10622
10672
  a.push(t), this._api.cacheExternalId(e.id.id, t);
10623
- } else a.push(this._getOrCacheExternalIdByCompositeId(e.id.id));
10673
+ } else {
10674
+ let t = this._getExternalIdByParticipantId(e.id.id);
10675
+ t ? a.push(t) : o.push(e.id.id);
10676
+ }
10624
10677
  });
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);
10678
+ let { externalIds: s, missingIds: c } = this._getExternalIdsByParticipantIds(r ?? []);
10679
+ o.push(...c);
10680
+ let { externalIds: l, missingIds: u } = this._getExternalIdsByParticipantIds(i ?? []);
10681
+ o.push(...u), this._reportMissingExternalIds(o, "CHAT_ROOM_UPDATED"), L.onChatRoomUpdated(e, t, a, s, l, this.id);
10627
10682
  }
10628
10683
  _onSharedMovieUpdate(e) {
10629
10684
  let t = this._conversation?.externalId;
@@ -10846,34 +10901,37 @@ var ls = 15, $ = class e extends b {
10846
10901
  let r = null;
10847
10902
  if (e && (r = ro(e), r)) {
10848
10903
  let e = this._api.getDecorativeIdByInitialId(r.id);
10849
- r.id = e ? j.composeUserId(e) : r.id;
10904
+ r.id = e ?? r.id;
10850
10905
  }
10851
10906
  let i = await this._signaling.getWaitingHall(r, t, n);
10852
10907
  if (i.error) return Promise.reject(i.message);
10853
- let a = i.participants || [], { externalIds: o } = await this._resolveWaitingHallExternalIds(a), s = null;
10908
+ let a = i.participants || [], { externalIds: o } = this._resolveWaitingHallExternalIds(a, "getWaitingHall"), s = null;
10854
10909
  return a.length && i.hasMore && (s = no(a[a.length - 1].id)), {
10855
10910
  participants: o,
10856
10911
  pageMarker: s,
10857
10912
  totalCount: i.totalCount || 0
10858
10913
  };
10859
10914
  }
10860
- async _resolveWaitingHallExternalIds(e) {
10861
- let t = [], n = [];
10915
+ _resolveWaitingHallExternalIds(e, t) {
10916
+ let n = [], r = [], i = [];
10862
10917
  return e.length && e.forEach((e) => {
10863
10918
  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
10919
+ let t = Q.fromSignaling(e.externalId);
10920
+ n.push(e.id.addedTs), r.push(t), this._api.cacheExternalId(e.id.id, t);
10921
+ } else {
10922
+ let t = this._getExternalIdByParticipantId(e.id.id);
10923
+ t ? (r.push(t), n.push(e.id.addedTs)) : i.push(e.id.id);
10924
+ }
10925
+ }), this._reportMissingExternalIds(i, t), {
10926
+ externalIds: r,
10927
+ timestamps: n
10870
10928
  };
10871
10929
  }
10872
10930
  async getAudienceModeHands() {
10873
10931
  if (!this._signaling.ready) throw Error("Signaling is not ready");
10874
10932
  let e = await this._signaling.getHandQueue();
10875
10933
  if (e.error) return Promise.reject(e.message);
10876
- let t = e.participants || [], { externalIds: n, timestamps: r } = await this._resolveWaitingHallExternalIds(t);
10934
+ let t = e.participants || [], { externalIds: n, timestamps: r } = this._resolveWaitingHallExternalIds(t, "getAudienceModeHands");
10877
10935
  return {
10878
10936
  timestamps: r,
10879
10937
  participants: n,
@@ -11042,7 +11100,7 @@ var ls = 15, $ = class e extends b {
11042
11100
  unmuteOptions: e.unmuteOptions || [],
11043
11101
  observedIds: e.observedIds || [],
11044
11102
  markers: this._denormalizeMarkers(t, e.markers)
11045
- }, e.decorativeUserId);
11103
+ }, j.composeDecorativeId(e));
11046
11104
  }));
11047
11105
  }
11048
11106
  async getParticipantListChunk(e) {
@@ -11088,7 +11146,7 @@ var ls = 15, $ = class e extends b {
11088
11146
  this._warnParticipantNotInConversation(e);
11089
11147
  return;
11090
11148
  }
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);
11149
+ 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
11150
  }
11093
11151
  _extractLocalParticipantFromConnection(e) {
11094
11152
  let t = this._api.getUserId();
@@ -11104,7 +11162,7 @@ var ls = 15, $ = class e extends b {
11104
11162
  this._warnParticipantNotInConversation(e);
11105
11163
  return;
11106
11164
  }
11107
- n.participantState = t || {}, ["ACTIVE", "HELD"].includes(this._state) && L.onRemoteParticipantState(n.externalId, n.participantState, n.markers, this.id);
11165
+ 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
11166
  }
11109
11167
  _changeMultipleParticipantState(e, t) {
11110
11168
  this._debug.debug("Multiple participants state changed", e);
@@ -11239,30 +11297,37 @@ var ls = 15, $ = class e extends b {
11239
11297
  async _onAcceptedCall(e) {
11240
11298
  let t = j.composeMessageId(e), n = j.getPeerIdString(e.peerId);
11241
11299
  if (this._debug.debug(`Participant accepted call [${t}]`), this._statFirstMediaReceived.markAcceptedCall(this._transport?.getTopology()), this._conversation && this._isMe(t)) {
11300
+ if (this._conversation.concurrent) return;
11242
11301
  this._close(new O(D.MISSED), { errorText: "Call accepted on other device" });
11243
11302
  return;
11244
11303
  }
11245
11304
  this._conversation?.direction === Ba.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
11246
11305
  let r = this._getParticipant(t);
11247
11306
  if (!r) {
11248
- let n = this._api.getDecorativeIdByInitialId(t), i = n ? j.composeUserId(n, e.participantType) : void 0;
11307
+ let n = this._api.getDecorativeIdByInitialId(t);
11249
11308
  r = this._registerParticipantInCache(this._createParticipant({
11250
11309
  id: t,
11251
11310
  externalId: e.externalId ? Q.fromSignaling(e.externalId, e.deviceIdx) : void 0,
11252
11311
  mediaSettings: E(e.mediaSettings)
11253
- }, i));
11312
+ }, n));
11254
11313
  } else if (e.externalId) {
11255
11314
  let t = Q.fromSignaling(e.externalId, e.deviceIdx);
11256
11315
  r.externalId = t, this._api.cacheExternalId(r.id, t);
11257
11316
  }
11258
11317
  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
11318
  let i = Object.keys(r.muteStates);
11260
- i.length && this._onMuteParticipant({
11319
+ if (i.length && this._onMuteParticipant({
11261
11320
  muteStates: r.muteStates,
11262
11321
  mediaOptions: i,
11263
11322
  stateUpdated: !0,
11264
11323
  participantId: t
11265
- }), ["ACTIVE", "HELD"].includes(this._state) && L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11324
+ }), ["ACTIVE", "HELD"].includes(this._state)) {
11325
+ if (!r.externalId) {
11326
+ this._reportMissingExternalIds([t], "ACCEPTED_CALL");
11327
+ return;
11328
+ }
11329
+ L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11330
+ }
11266
11331
  }
11267
11332
  async _onHungup(e) {
11268
11333
  this._debug.debug(`Participant hungup [${e.participantId}]`, { reason: e.reason });
@@ -11331,7 +11396,7 @@ var ls = 15, $ = class e extends b {
11331
11396
  return;
11332
11397
  }
11333
11398
  if (!n) {
11334
- let { participant: r } = e, i = r.decorativeUserId;
11399
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11335
11400
  this._registerParticipant({
11336
11401
  id: t,
11337
11402
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11358,7 +11423,7 @@ var ls = 15, $ = class e extends b {
11358
11423
  return;
11359
11424
  }
11360
11425
  if (!n) {
11361
- let { participant: r } = e, i = r.decorativeUserId;
11426
+ let { participant: r } = e, i = j.composeDecorativeId(r);
11362
11427
  this._registerParticipant({
11363
11428
  id: t,
11364
11429
  externalId: Q.fromSignalingParticipant(r, !0, !0),
@@ -11401,7 +11466,7 @@ var ls = 15, $ = class e extends b {
11401
11466
  _onParticipantsStateChanged(e) {
11402
11467
  let { participants: t, roomId: n } = e;
11403
11468
  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 })]);
11469
+ let r = /* @__PURE__ */ new Map(), i = t.map(({ id: e, participantState: t }) => [e, this._getExternalIdByParticipantId(e) ? j.mapParticipantState({ participantState: t }) : void 0]);
11405
11470
  try {
11406
11471
  i.forEach(([e, t]) => {
11407
11472
  t && r.set(e, t);
@@ -11800,8 +11865,8 @@ var ls = 15, $ = class e extends b {
11800
11865
  this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
11801
11866
  let r = this._getParticipant(e);
11802
11867
  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);
11868
+ let t = this._api.getDecorativeIdByInitialId(e);
11869
+ 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
11870
  }
11806
11871
  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
11872
  if (r.remoteStream = t, r.secondStream) return;
@@ -11911,46 +11976,63 @@ var ls = 15, $ = class e extends b {
11911
11976
  }
11912
11977
  _onRoomsUpdated(e) {
11913
11978
  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
11979
+ let t = {}, n = [], r = [];
11980
+ for (let i of Object.keys(Ja)) {
11981
+ let a = e.updates[i];
11982
+ a && (a?.rooms?.forEach((e) => {
11983
+ let { room: t, missingParticipantIds: i } = this._convertRoomToExternal(e);
11984
+ t && n.push(t), r.push(...i);
11985
+ }), t[i] = {
11986
+ rooms: n,
11987
+ roomIds: a?.roomIds,
11988
+ deactivated: a?.deactivated
11921
11989
  });
11922
11990
  }
11923
- L.onRoomsUpdated(t, this.id);
11991
+ this._reportMissingExternalIds(r, "ROOMS_UPDATED"), L.onRoomsUpdated(t, this.id);
11924
11992
  }
11925
11993
  _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);
11994
+ let { room: t, missingParticipantIds: n } = this._convertRoomToExternal(e.room || null);
11995
+ 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
11996
  }
11929
11997
  _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;
11998
+ if (!e) return {
11999
+ room: null,
12000
+ missingParticipantIds: []
12001
+ };
12002
+ 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 ?? []);
12003
+ t.push(...r, ...a, ...s);
12004
+ let c;
12005
+ if (e.pinnedParticipantId) {
12006
+ let n = this._getExternalIdByParticipantId(e.pinnedParticipantId);
12007
+ n ? c = n : t.push(e.pinnedParticipantId);
12008
+ }
11932
12009
  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
12010
+ room: {
12011
+ id: e.id,
12012
+ name: e.name,
12013
+ participantCount: e.participantCount,
12014
+ participantIds: n,
12015
+ addParticipantIds: i,
12016
+ removeParticipantIds: o,
12017
+ participants: e.participants?.participants ? this._participantListChunkToExternalChunk(e.participants) : void 0,
12018
+ active: e.active,
12019
+ muteStates: e.muteStates,
12020
+ pinnedParticipantId: c,
12021
+ countdownSec: e.countdownSec,
12022
+ timeoutMs: e.timeoutMs
12023
+ },
12024
+ missingParticipantIds: t
11945
12025
  };
11946
12026
  }
11947
12027
  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()) {
12028
+ let t = this._transport?.getState(), n = e.roomId ?? null, r = [], { externalIds: i, missingIds: a } = this._getExternalIdsByParticipantIds(e.addedParticipantIds ?? []);
12029
+ r.push(...a);
12030
+ let o = e.addedParticipants;
12031
+ if (i.length && o?.length !== i.length && !this._isCalledState()) {
11950
12032
  let e = this._convertExternalIdsToServerExternalIds(i);
11951
- a = (await this._signaling.getParticipants(e)).participants;
12033
+ o = (await this._signaling.getParticipants(e)).participants;
11952
12034
  }
11953
- let o = a?.map((e) => {
12035
+ let s = o?.map((e) => {
11954
12036
  let r = j.composeId(e);
11955
12037
  return this._createParticipant({
11956
12038
  id: r,
@@ -11966,38 +12048,38 @@ var ls = 15, $ = class e extends b {
11966
12048
  observedIds: e.observedIds || [],
11967
12049
  markers: this._denormalizeMarkers(r, e.markers),
11968
12050
  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 = [];
12051
+ }, j.composeDecorativeId(e));
12052
+ }) || [], c = !1;
12053
+ for (let e of s) e.id === this._conversation?.compositeUserId && (c = !0), this._registerParticipantInCache(e);
12054
+ this._transport?.getState() === q.IDLE && !this._isCalledState() && this._openTransport(s, !0);
12055
+ let l = [];
11974
12056
  if (e?.removedParticipantMarkers) {
11975
12057
  for (let t of e.removedParticipantMarkers) if (t.GRID?.id) {
11976
12058
  let e = this._getExternalIdByParticipantId(t.GRID.id);
11977
- c.push(e);
12059
+ e ? l.push(e) : r.push(t.GRID.id);
11978
12060
  }
11979
12061
  }
11980
- if (s && await this._onRoomSwitched(n), c) {
12062
+ if (this._reportMissingExternalIds(r, "ROOM_PARTICIPANTS_UPDATED"), c && await this._onRoomSwitched(n), l) {
11981
12063
  let e = this._conversation?.pinnedParticipantIdByRoom.get(n);
11982
12064
  if (e) {
11983
12065
  let t = this._getExternalIdByParticipantId(e);
11984
12066
  if (t) {
11985
- for (let e of c) if (Q.compare(t, e)) {
12067
+ for (let e of l) if (Q.compare(t, e)) {
11986
12068
  this._conversation?.pinnedParticipantIdByRoom.delete(n);
11987
12069
  break;
11988
12070
  }
11989
12071
  }
11990
12072
  }
11991
12073
  }
11992
- let l = {
12074
+ let u = {
11993
12075
  roomId: n,
11994
12076
  participantCount: e.participantCount,
11995
12077
  addedParticipantIds: i,
11996
- addedParticipants: j.mapSharedParticipants(o),
12078
+ addedParticipants: j.mapSharedParticipants(s),
11997
12079
  removedParticipantMarkers: e?.removedParticipantMarkers,
11998
- removedParticipantIds: c
12080
+ removedParticipantIds: l
11999
12081
  };
12000
- this._isCalledState() || L.onRoomParticipantsUpdated(l, this.id);
12082
+ this._isCalledState() || L.onRoomParticipantsUpdated(u, this.id);
12001
12083
  }
12002
12084
  async _onRoomSwitched(e, t = !1) {
12003
12085
  if (!this._conversation || this._conversation.roomId === e) return;
@@ -12017,7 +12099,7 @@ var ls = 15, $ = class e extends b {
12017
12099
  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
12100
  let e = this._participants;
12019
12101
  await this._registerParticipants(t?.participants?.participants?.filter((t) => !e[j.composeId(t)]) || [], !0);
12020
- let n = this._convertRoomToExternal(t);
12102
+ let { room: n } = this._convertRoomToExternal(t);
12021
12103
  n && r.push(n);
12022
12104
  }
12023
12105
  }
@@ -12051,7 +12133,9 @@ var ls = 15, $ = class e extends b {
12051
12133
  return;
12052
12134
  }
12053
12135
  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;
12136
+ L.onParticipantIdChanged(a, o, this.id);
12137
+ let s = j.compose(n, a.deviceIdx), c = j.compose(t, a.deviceIdx);
12138
+ if (this._api.cacheExternalId(s, o), this._api.mapDecorativeId(s, c), i) this._conversation.externalId = o;
12055
12139
  else {
12056
12140
  let e = this._participants;
12057
12141
  e[t].externalId = o;
@@ -12223,22 +12307,16 @@ var Es = class {
12223
12307
  }
12224
12308
  log(e) {}
12225
12309
  logClientStats(e) {}
12226
- getCachedOkIdByExternalId(e) {
12310
+ getCachedParticipantIdByExternalId(e) {
12227
12311
  return null;
12228
12312
  }
12229
- getCachedRawOkIdByExternalId(e) {
12230
- return null;
12231
- }
12232
- getCachedExternalIdByOkId(e) {
12313
+ getCachedExternalIdByParticipantId(e) {
12233
12314
  return null;
12234
12315
  }
12235
12316
  cacheExternalId(e, t) {}
12236
12317
  mapDecorativeId(e, t) {}
12237
12318
  unmapDecorativeId(e) {}
12238
12319
  getDecorativeIdByInitialId(e) {}
12239
- replaceByInitialIdIdIfExists(e) {
12240
- return typeof e == "string" ? parseInt(e, 10) : e;
12241
- }
12242
12320
  hangupConversation(e, t = D.HUNGUP, n) {}
12243
12321
  async removeHistoryRecords(e) {}
12244
12322
  async getServerTime() {
@@ -12250,7 +12328,7 @@ var Es = class {
12250
12328
  }
12251
12329
  }, Ds = class e {
12252
12330
  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());
12331
+ 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
12332
  }
12255
12333
  static _normalizeType(e) {
12256
12334
  return e.type === to.GROUP ? {
@@ -12258,46 +12336,30 @@ var Es = class {
12258
12336
  type: to.USER
12259
12337
  } : e;
12260
12338
  }
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
12339
  getExternalId(e) {
12266
- let t = this.getDecorativeIdByInitialId(e) ?? e, n = this._okIdToExternalId.get(t);
12340
+ let t = this._initialIdToDecorativeId.get(e) ?? e, n = this._participantIdToExternalId.get(t);
12267
12341
  return n == null ? null : Q.fromString(n);
12268
12342
  }
12269
- hasByExternalId(t) {
12270
- return this._externalIdToOkId.has(Q.toString(e._normalizeType(t)));
12271
- }
12272
- hasByOkId(e) {
12273
- return this._okIdToExternalId.has(e);
12343
+ getParticipantId(t) {
12344
+ let n = Q.toString(e._normalizeType(t)), r = this._externalIdToParticipantId.get(n);
12345
+ return r == null ? null : this._decorativeIdToInitialId.get(r) ?? r;
12274
12346
  }
12275
12347
  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);
12348
+ let r = e._normalizeType(n), i = Q.toString(r);
12349
+ this._participantIdToExternalId.set(t, i), this._externalIdToParticipantId.set(i, t);
12278
12350
  }
12279
12351
  mapDecorativeId(e, t) {
12280
- let n = j.extractOkId(e), r = j.extractOkId(t);
12281
- this._decorativeIdToInitialId.set(n, r), this._initialIdToDecorativeId.set(r, n);
12352
+ this._decorativeIdToInitialId.set(e, t), this._initialIdToDecorativeId.set(t, e);
12282
12353
  }
12283
12354
  unmapDecorativeId(e) {
12284
- let t = j.extractOkId(e), n = this.getDecorativeIdByInitialId(t);
12285
- n && this._decorativeIdToInitialId.delete(n), this._initialIdToDecorativeId.delete(t);
12355
+ let t = this._initialIdToDecorativeId.get(e);
12356
+ t && this._decorativeIdToInitialId.delete(t), this._initialIdToDecorativeId.delete(e);
12286
12357
  }
12287
12358
  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);
12359
+ return this._initialIdToDecorativeId.get(e);
12298
12360
  }
12299
12361
  clear() {
12300
- this._okIdToExternalId.clear(), this._externalIdToOkId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12362
+ this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12301
12363
  }
12302
12364
  }, Os = "anonymLogin:", ks = 700, As = 3e3;
12303
12365
  function js(e) {
@@ -12385,8 +12447,11 @@ var Ps = class extends Es {
12385
12447
  }
12386
12448
  }
12387
12449
  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));
12450
+ if (y.isEmpty()) {
12451
+ let { compositeUserId: t } = j.decomposeParticipantId(e), { id: n } = j.decomposeId(t);
12452
+ return Q.fromId(String(n));
12453
+ }
12454
+ return this._idCache.getExternalId(e);
12390
12455
  }
12391
12456
  async authorize() {
12392
12457
  if (this._ensureUuid(), !M.apiKey) throw new O(x.API, {
@@ -12405,7 +12470,7 @@ var Ps = class extends Es {
12405
12470
  let t = { session_data: {
12406
12471
  version: 2,
12407
12472
  device_id: this._uuid,
12408
- client_version: M.appVersion,
12473
+ client_version: M.apiClientVersion,
12409
12474
  client_type: "SDK_JS"
12410
12475
  } };
12411
12476
  return M.authToken && (t.session_data.auth_token = M.authToken, t.session_data.version = 3), this._callUnsafe("auth.anonymLogin", t, !0).then((e) => {
@@ -12463,7 +12528,7 @@ var Ps = class extends Es {
12463
12528
  }
12464
12529
  logClientStats(e) {
12465
12530
  let t = {
12466
- app_version: String(M.appVersion),
12531
+ app_version: M.appVersion,
12467
12532
  sdk_type: "WEB",
12468
12533
  sdk_version: M.sdkVersion,
12469
12534
  version: 1,
@@ -12574,13 +12639,10 @@ var Ps = class extends Es {
12574
12639
  };
12575
12640
  return n?.length && (i.observedIds = n.join(",")), M.anonymToken && (i.anonymToken = M.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
12576
12641
  }
12577
- getCachedOkIdByExternalId(e) {
12578
- return this._idCache.getParticipantIdByExternalId(e);
12642
+ getCachedParticipantIdByExternalId(e) {
12643
+ return this._idCache.getParticipantId(e);
12579
12644
  }
12580
- getCachedRawOkIdByExternalId(e) {
12581
- return this._idCache.getOkId(e);
12582
- }
12583
- getCachedExternalIdByOkId(e) {
12645
+ getCachedExternalIdByParticipantId(e) {
12584
12646
  return this._idCache.getExternalId(e);
12585
12647
  }
12586
12648
  cacheExternalId(e, t) {
@@ -12595,9 +12657,6 @@ var Ps = class extends Es {
12595
12657
  getDecorativeIdByInitialId(e) {
12596
12658
  return this._idCache.getDecorativeIdByInitialId(e);
12597
12659
  }
12598
- replaceByInitialIdIdIfExists(e) {
12599
- return this._idCache.replaceByInitialIdIdIfExists(e);
12600
- }
12601
12660
  async getConversationParams(e) {
12602
12661
  let t = {};
12603
12662
  return M.anonymToken && (t.anonymToken = M.anonymToken), e && (t.conversationId = e), this._call("vchat.getConversationParams", t);
@@ -12672,7 +12731,7 @@ var Ls = /* @__PURE__ */ function(e) {
12672
12731
  let e = await bs("auth.anonymLogin", {
12673
12732
  session_data: {
12674
12733
  device_id: this._uuid,
12675
- client_version: M.appVersion,
12734
+ client_version: M.apiClientVersion,
12676
12735
  client_type: "SDK_JS",
12677
12736
  auth_token: this._callToken,
12678
12737
  version: 3
@@ -12747,10 +12806,16 @@ async function Xs(t) {
12747
12806
  }
12748
12807
  async function Zs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12749
12808
  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);
12809
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), $s([], Va.USER, t, n, r, i, a, c, o, s);
12751
12810
  }
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);
12811
+ function Qs(e, t = []) {
12812
+ let n = e.getIncomingCallerExternalId();
12813
+ return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
12814
+ }
12815
+ async function $s(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12816
+ if (!M.hold && z.getActive()) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12817
+ let u = z.getAll().find((e) => e.isIncomingRinging);
12818
+ if (!M.hold && u && !Qs(u, s)) throw R.error("There is already incoming call"), new O(D.HAS_ACTIVE_CALL);
12754
12819
  return new $(new Ps(), Hs).onStart({
12755
12820
  opponentIds: e,
12756
12821
  opponentType: t,
@@ -12764,30 +12829,30 @@ async function Qs(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12764
12829
  conversationId: l
12765
12830
  });
12766
12831
  }
12767
- async function $s(e, t) {
12768
- return ec(e, A.USER, void 0, t);
12832
+ async function ec(e, t) {
12833
+ return tc(e, A.USER, void 0, t);
12769
12834
  }
12770
- async function ec(e, t = A.USER, n, r, i, a) {
12835
+ async function tc(e, t = A.USER, n, r, i, a) {
12771
12836
  if (e === $.id()) throw Error("Push has already been processed");
12772
12837
  return new $(new Ps(), Hs).onPush(e, t, n, r, i, a);
12773
12838
  }
12774
- async function tc() {
12839
+ async function nc() {
12775
12840
  return Vs.getInbounds();
12776
12841
  }
12777
- async function nc(e, t) {
12842
+ async function rc(e, t) {
12778
12843
  return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, hs()), Vs.authorize();
12779
12844
  }
12780
- async function rc(e = [S.AUDIO], t) {
12781
- return El(t).accept(e);
12845
+ async function ic(e = [S.AUDIO], t) {
12846
+ return kl(t).accept(e);
12782
12847
  }
12783
- async function ic(e) {
12784
- let t = Tl(e?.conversationId);
12848
+ async function ac(e) {
12849
+ let t = El(e?.conversationId);
12785
12850
  if (t) return t.decline(e);
12786
12851
  }
12787
- async function ac(e, t = [S.AUDIO]) {
12788
- return oc(e, t);
12852
+ async function oc(e, t = [S.AUDIO]) {
12853
+ return sc(e, t);
12789
12854
  }
12790
- async function oc(e, t, n) {
12855
+ async function sc(e, t, n) {
12791
12856
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12792
12857
  return new $(new Ps(), Hs).onJoin({
12793
12858
  conversationId: e,
@@ -12795,7 +12860,7 @@ async function oc(e, t, n) {
12795
12860
  chatId: n
12796
12861
  });
12797
12862
  }
12798
- async function sc(e, t = [S.AUDIO], n, r, i, a) {
12863
+ async function cc(e, t = [S.AUDIO], n, r, i, a) {
12799
12864
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12800
12865
  return n && (M.anonymToken = n), new $(new Ps(), Hs).onJoin({
12801
12866
  joinLink: e,
@@ -12806,30 +12871,30 @@ async function sc(e, t = [S.AUDIO], n, r, i, a) {
12806
12871
  anonymous: !!M.anonymToken
12807
12872
  });
12808
12873
  }
12809
- function cc(e) {
12810
- let t = Tl(e?.conversationId);
12874
+ function lc(e) {
12875
+ let t = El(e?.conversationId);
12811
12876
  return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
12812
12877
  }
12813
- async function lc(e, t) {
12878
+ async function uc(e, t) {
12814
12879
  let n = Array.isArray(e) ? e : [e], r = $.current();
12815
12880
  r && await r.addParticipant(n, t);
12816
12881
  }
12817
- async function uc(e, t) {
12882
+ async function dc(e, t) {
12818
12883
  let n = $.current();
12819
12884
  if (n) {
12820
12885
  let r = e.map((e) => j.composeUserId(e));
12821
12886
  await n.addParticipantLegacy(r, t);
12822
12887
  }
12823
12888
  }
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;
12889
+ async function fc(e, t = !1) {
12890
+ let n = Al(e, "removeParticipant");
12891
+ if (n) try {
12892
+ await n.conversation.removeParticipant(j.decomposeParticipantId(n.participantId).compositeUserId, t);
12893
+ } catch (e) {
12894
+ R.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
12829
12895
  }
12830
- return fc(n, t);
12831
12896
  }
12832
- async function fc(e, t = !1) {
12897
+ async function pc(e, t = !1) {
12833
12898
  let n = $.current();
12834
12899
  if (n) try {
12835
12900
  await n.removeParticipant(j.composeUserId(e), t);
@@ -12837,13 +12902,13 @@ async function fc(e, t = !1) {
12837
12902
  R.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
12838
12903
  }
12839
12904
  }
12840
- async function pc(e, t) {
12905
+ async function mc(e, t) {
12841
12906
  let n = $.current();
12842
12907
  if (e === "videoinput" && jt.contains(t)) return M.videoFacingMode = t, n ? (T.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
12843
12908
  if (!await T._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
12844
12909
  if (n) return n.changeDevice(e);
12845
12910
  }
12846
- async function mc(e, t) {
12911
+ async function hc(e, t) {
12847
12912
  let n = typeof e == "object" ? {
12848
12913
  ...e,
12849
12914
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -12852,151 +12917,149 @@ async function mc(e, t) {
12852
12917
  captureScreen: e,
12853
12918
  fastScreenSharing: !1,
12854
12919
  captureAudio: !1
12855
- }, r = Tl(t);
12920
+ }, r = El(t);
12856
12921
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
12857
12922
  }
12858
- function hc(e) {
12923
+ function gc(e) {
12859
12924
  let t = $.current();
12860
12925
  t && t.toggleAnimojiCapturing(e);
12861
12926
  }
12862
- async function gc(e, t = !1) {
12927
+ async function _c(e, t = !1) {
12863
12928
  let n = $.current();
12864
12929
  n && await n.setVideoStream(e, t);
12865
12930
  }
12866
- async function _c(e, t) {
12867
- let n = Tl(t);
12931
+ async function vc(e, t) {
12932
+ let n = El(t);
12868
12933
  n && await n.toggleLocalVideo(e);
12869
12934
  }
12870
- async function vc(e, t) {
12871
- let n = Tl(t);
12935
+ async function yc(e, t) {
12936
+ let n = El(t);
12872
12937
  n && await n.toggleLocalAudio(e);
12873
12938
  }
12874
- async function yc(e) {
12939
+ async function bc(e) {
12875
12940
  let t = $.current();
12876
12941
  if (t) return t.setLocalResolution(e);
12877
12942
  }
12878
- async function bc(e) {
12943
+ async function xc(e) {
12879
12944
  let t = $.current();
12880
12945
  t && await t.changePriorities(e);
12881
12946
  }
12882
- async function xc(e, t) {
12947
+ async function Sc(e, t) {
12883
12948
  let n = $.current();
12884
12949
  if (n) {
12885
- let r;
12886
12950
  if (t) {
12887
- let e = n.getCachedRawOkIdByExternalId(t);
12888
- if (!e) {
12889
- R.warn("changeParticipantState: externalId not found in cache", t);
12951
+ let r = n.getCachedParticipantIdByExternalId(t);
12952
+ if (!r) {
12953
+ Dl(t, "changeParticipantState", n);
12890
12954
  return;
12891
12955
  }
12892
- r = j.composeParticipantId(e, A.USER, t.deviceIdx);
12956
+ await n.changeParticipantState(e, r);
12957
+ return;
12893
12958
  }
12894
- await n.changeParticipantState(e, r);
12959
+ await n.changeParticipantState(e);
12895
12960
  }
12896
12961
  }
12897
- async function Sc() {
12962
+ async function Cc() {
12898
12963
  let e = $.current();
12899
12964
  e && await e.putHandsDown();
12900
12965
  }
12901
- async function Cc(e) {
12966
+ async function wc(e) {
12902
12967
  let t = $.current();
12903
12968
  t && await t.updateDisplayLayout(e);
12904
12969
  }
12905
- async function wc(e) {
12970
+ async function Tc(e) {
12906
12971
  let t = $.current();
12907
12972
  t && await t.requestDisplayLayout(e);
12908
12973
  }
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);
12974
+ async function Ec(e, t, n = !1) {
12975
+ let r = Al(e, "grantRoles");
12976
+ r && await r.conversation.grantRoles(r.participantId, t, n);
12916
12977
  }
12917
- async function Ec(e, t, n, r = !1) {
12978
+ async function Dc(e, t, n, r = !1) {
12918
12979
  let i = $.current();
12919
12980
  i && await i.grantRoles(j.composeParticipantId(e, A.USER, t), n, r);
12920
12981
  }
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
- });
12982
+ async function Oc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12983
+ if (e) {
12984
+ let i = Al(e, "muteParticipant");
12985
+ return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
12986
+ }
12987
+ let i = $.current();
12988
+ i && await i.muteParticipant(null, t, n, r);
12930
12989
  }
12931
- async function Oc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12990
+ async function kc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12932
12991
  let a = $.current();
12933
12992
  if (a) {
12934
12993
  let o = e ? j.composeParticipantId(e, A.USER, r) : null;
12935
12994
  await a.muteParticipant(o, t, n, i);
12936
12995
  }
12937
12996
  }
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);
12997
+ async function Ac(e, t = !1, n = null) {
12998
+ let r = Al(e, "pinParticipant");
12999
+ r && await r.conversation.pinParticipant(r.participantId, t, n);
12945
13000
  }
12946
- async function Ac(e, t = !1, n = 0, r = null) {
13001
+ async function jc(e, t = !1, n = 0, r = null) {
12947
13002
  let i = $.current();
12948
13003
  i && await i.pinParticipant(j.composeParticipantId(e, A.USER, n), t, r);
12949
13004
  }
12950
- async function jc(e) {
13005
+ async function Mc(e) {
12951
13006
  let t = $.current();
12952
13007
  t && await t.updateMediaModifiers(e);
12953
13008
  }
12954
- async function Mc(e) {
13009
+ async function Nc(e) {
12955
13010
  let t = $.current();
12956
13011
  t && await t.enableVideoSuspend(e);
12957
13012
  }
12958
- async function Nc(e) {
13013
+ async function Pc(e) {
12959
13014
  let t = $.current();
12960
13015
  t && await t.enableVideoSuspendSuggest(e);
12961
13016
  }
12962
- async function Pc(e) {
13017
+ async function Fc(e) {
12963
13018
  let t = $.current();
12964
13019
  t && await t.changeOptions(e);
12965
13020
  }
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
13021
  async function Ic(e, t = null) {
13022
+ if (t) {
13023
+ let n = Al(t, "chatMessage");
13024
+ return n ? n.conversation.chatMessage(e, j.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
13025
+ }
13026
+ let n = $.current();
13027
+ n && await n.chatMessage(e, null);
13028
+ }
13029
+ async function Lc(e, t = null) {
12971
13030
  let n = $.current();
12972
13031
  if (n) {
12973
13032
  let r = t ? j.composeUserId(t) : null;
12974
13033
  await n.chatMessage(e, r);
12975
13034
  }
12976
13035
  }
12977
- async function Lc(e = 10) {
13036
+ async function Rc(e = 10) {
12978
13037
  let t = $.current();
12979
13038
  if (t) return t.chatHistory(e);
12980
13039
  }
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));
13040
+ async function zc(e, t = null) {
13041
+ if (t) {
13042
+ let n = Al(t, "customData");
13043
+ return n ? n.conversation.customData(e, n.participantId) : void 0;
13044
+ }
13045
+ let n = $.current();
13046
+ n && await n.customData(e, null);
12984
13047
  }
12985
- async function zc(e, t = null, n = 0) {
13048
+ async function Bc(e, t = null, n = 0) {
12986
13049
  let r = $.current();
12987
13050
  if (r) {
12988
13051
  let i = t ? j.composeParticipantId(t, A.USER, n) : null;
12989
13052
  await r.customData(e, i);
12990
13053
  }
12991
13054
  }
12992
- async function Bc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
13055
+ async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12993
13056
  return (await Vs.createConversation(a ?? j.uuid(), e, t, {
12994
13057
  onlyAdminCanShareMovie: n,
12995
13058
  waitForAdmin: r,
12996
13059
  closedConversation: i
12997
13060
  })).join_link;
12998
13061
  }
12999
- async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13062
+ async function Hc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13000
13063
  let a = i.map((e) => Q.fromId(e));
13001
13064
  return (await Vs.createConversation(j.uuid(), e, t, {
13002
13065
  onlyAdminCanShareMovie: n,
@@ -13004,115 +13067,114 @@ async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r
13004
13067
  audioOnly: r
13005
13068
  }, a)).join_link;
13006
13069
  }
13007
- async function Hc() {
13070
+ async function Uc() {
13008
13071
  let e = $.current();
13009
13072
  return e ? e.createJoinLink() : Promise.reject();
13010
13073
  }
13011
- async function Uc() {
13074
+ async function Wc() {
13012
13075
  let e = $.current();
13013
13076
  return e ? e.removeJoinLink() : Promise.reject();
13014
13077
  }
13015
- async function Wc(e, t) {
13078
+ async function Gc(e, t) {
13016
13079
  return Vs.getAnonymTokenByLink(e, t);
13017
13080
  }
13018
- function Gc(e) {
13081
+ function Kc(e) {
13019
13082
  let t = $.current();
13020
13083
  t && t.setVolume(e);
13021
13084
  }
13022
- function Kc(e) {
13085
+ function qc(e) {
13023
13086
  M.forceRelayPolicy = e;
13024
13087
  }
13025
- async function qc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13088
+ async function Jc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13026
13089
  let o = $.current();
13027
13090
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
13028
13091
  }
13029
- async function Jc(e = null, t) {
13092
+ async function Yc(e = null, t) {
13030
13093
  let n = $.current();
13031
13094
  return n ? n.stopStream(e, t) : Promise.reject();
13032
13095
  }
13033
- async function Yc(e = null) {
13096
+ async function Xc(e = null) {
13034
13097
  let t = $.current();
13035
13098
  return t ? t.publishStream(e) : Promise.reject();
13036
13099
  }
13037
- async function Xc() {
13100
+ async function Zc() {
13038
13101
  let e = $.current();
13039
13102
  return e ? e.getStreamInfo() : Promise.reject();
13040
13103
  }
13041
- async function Zc(e) {
13104
+ async function Qc(e) {
13042
13105
  let t = $.current();
13043
13106
  return t ? t.addMovie(e) : Promise.reject();
13044
13107
  }
13045
- async function Qc(e) {
13108
+ async function $c(e) {
13046
13109
  let t = $.current();
13047
13110
  return t ? t.updateMovie(e) : Promise.reject();
13048
13111
  }
13049
- async function $c(e) {
13112
+ async function el(e) {
13050
13113
  let t = $.current();
13051
13114
  return t ? t.removeMovie(e) : Promise.reject();
13052
13115
  }
13053
- async function el(e, t) {
13116
+ async function tl(e, t) {
13054
13117
  let n = $.current();
13055
13118
  if (n) {
13056
- let r = [];
13119
+ let r = [], i = [];
13057
13120
  for (let t of e) {
13058
- let e, i;
13121
+ let e, a;
13059
13122
  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);
13123
+ let r = n.getCachedParticipantIdByExternalId(t);
13124
+ r ? e.push(j.decomposeParticipantId(r).compositeUserId) : i.push(t.id);
13125
+ })), t.removeParticipantIds && (a = [], t.removeParticipantIds.forEach((e) => {
13126
+ let t = n.getCachedParticipantIdByExternalId(e);
13127
+ t ? a.push(j.decomposeParticipantId(t).compositeUserId) : i.push(e.id);
13065
13128
  })), r.push({
13066
13129
  id: t.id,
13067
13130
  name: t.name,
13068
13131
  participantCount: t.participantCount,
13069
13132
  addParticipantIds: e,
13070
- removeParticipantIds: i,
13133
+ removeParticipantIds: a,
13071
13134
  countdownSec: t.countdownSec
13072
13135
  });
13073
13136
  }
13137
+ if (i.length) {
13138
+ Ol(i, "updateRooms", n);
13139
+ return;
13140
+ }
13074
13141
  return n.updateRooms(r, t);
13075
13142
  }
13076
13143
  return Promise.reject();
13077
13144
  }
13078
- async function tl(e, t) {
13145
+ async function nl(e, t) {
13079
13146
  let n = $.current();
13080
13147
  return n ? n.activateRooms(e, t) : Promise.reject();
13081
13148
  }
13082
- async function nl(e = null, t = null) {
13149
+ async function rl(e = null, t = null) {
13083
13150
  let n = $.current();
13084
13151
  if (!n) return Promise.reject();
13085
13152
  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);
13153
+ if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
13154
+ Dl(t, "switchRoom", n);
13155
+ return;
13094
13156
  }
13095
13157
  return n.switchRoom(e, r);
13096
13158
  }
13097
- async function rl(e) {
13159
+ async function il(e) {
13098
13160
  let t = $.current();
13099
13161
  return t ? t.removeRooms(e) : Promise.reject();
13100
13162
  }
13101
- function il(e) {
13163
+ function al(e) {
13102
13164
  M.statisticsInterval = e;
13103
13165
  let t = $.current();
13104
13166
  if (t) return t.updateStatisticsInterval();
13105
13167
  }
13106
- function al(t) {
13168
+ function ol(t) {
13107
13169
  e.disableLog(!t), R.toggle(t);
13108
13170
  }
13109
- function ol(e, ...t) {
13171
+ function sl(e, ...t) {
13110
13172
  M.debugLog && ($.debugMessage(e, "[external]", ...t) || R.send(e, "[external]", ...t));
13111
13173
  }
13112
- function sl(e, t, ...n) {
13174
+ function cl(e, t, ...n) {
13113
13175
  M.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || R.send(e, "[external]", ...n));
13114
13176
  }
13115
- var cl = {
13177
+ var ll = {
13116
13178
  list: Ne,
13117
13179
  get: Pe,
13118
13180
  getJson: Fe,
@@ -13120,7 +13182,7 @@ var cl = {
13120
13182
  clear: Le,
13121
13183
  stats: Re
13122
13184
  };
13123
- function ll() {
13185
+ function ul() {
13124
13186
  let e = [
13125
13187
  [`Calls SDK ${M.sdkVersion}`, M.toJSON()],
13126
13188
  ["UserAgent:", navigator.userAgent],
@@ -13137,124 +13199,139 @@ function ll() {
13137
13199
  d: e
13138
13200
  }));
13139
13201
  }
13140
- async function ul() {
13202
+ async function dl() {
13141
13203
  let e = $.id(), t = $.debugSessionId();
13142
13204
  if (!t || !e) throw R.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
13143
13205
  let n = await Pe({ sessionId: t });
13144
13206
  if (n.length === 0) throw R.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
13145
13207
  let r = n[0].t, i = n[n.length - 1].t;
13146
13208
  try {
13147
- return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ll(), ...n]));
13209
+ return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ul(), ...n]));
13148
13210
  } catch (e) {
13149
13211
  throw R.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
13150
13212
  }
13151
13213
  }
13152
- async function dl(e) {
13214
+ async function fl(e) {
13153
13215
  let t = $.current();
13154
13216
  if (t) return t.videoEffect(e);
13155
13217
  }
13156
- async function fl(e, t) {
13218
+ async function pl(e, t) {
13157
13219
  let n = $.current();
13158
13220
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
13159
13221
  }
13160
- async function pl(e) {
13222
+ async function ml(e) {
13161
13223
  let t = $.current();
13162
13224
  t && await t.setAudioStream(e);
13163
13225
  }
13164
- async function ml(e, t = null, n = null) {
13226
+ async function hl(e, t = null, n = null) {
13165
13227
  let r = $.current();
13166
13228
  if (!r) return;
13167
13229
  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));
13230
+ if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
13231
+ Dl(t, "setVmojiSvg", r);
13232
+ return;
13172
13233
  }
13173
13234
  r.setAnimojiSvg(e, a, i);
13174
13235
  }
13175
- function hl(e) {
13236
+ function gl(e) {
13176
13237
  let t = $.current();
13177
13238
  t && t.setAnimojiFill(e);
13178
13239
  }
13179
- async function gl(e = null, t, n = !1) {
13180
- return El().getWaitingHall(e, t, n);
13240
+ async function _l(e = null, t, n = !1) {
13241
+ return kl().getWaitingHall(e, t, n);
13181
13242
  }
13182
- async function _l() {
13183
- return El().getAudienceModeHands();
13243
+ async function vl() {
13244
+ return kl().getAudienceModeHands();
13184
13245
  }
13185
- async function vl(e, t = !1) {
13186
- let n = El(), r;
13246
+ async function yl(e, t = !1) {
13247
+ let n = kl(), r;
13187
13248
  if (e) {
13188
- let t = n.getCachedRawOkIdByExternalId(e);
13249
+ let t = n.getCachedParticipantIdByExternalId(e);
13189
13250
  if (!t) {
13190
- R.warn("promoteParticipant: externalId not found in cache", e);
13251
+ Dl(e, "promoteParticipant", n);
13191
13252
  return;
13192
13253
  }
13193
- r = j.composeUserId(t);
13254
+ r = j.decomposeParticipantId(t).compositeUserId;
13194
13255
  }
13195
13256
  return n.promoteParticipant(r, t);
13196
13257
  }
13197
- async function yl(e = !1) {
13198
- return El().requestPromotion(e);
13199
- }
13200
13258
  async function bl(e = !1) {
13201
- return El().acceptPromotion(e);
13259
+ return kl().requestPromotion(e);
13202
13260
  }
13203
- async function xl(e) {
13204
- return El().getParticipantListChunk(e);
13261
+ async function xl(e = !1) {
13262
+ return kl().acceptPromotion(e);
13205
13263
  }
13206
13264
  async function Sl(e) {
13207
- return El().getParticipants(e);
13265
+ return kl().getParticipantListChunk(e);
13208
13266
  }
13209
13267
  async function Cl(e) {
13210
- return El().feedback(e);
13268
+ return kl().getParticipants(e);
13211
13269
  }
13212
- async function wl(e, t, n) {
13213
- return El(n).enableFeatureForRoles(e, t);
13270
+ async function wl(e) {
13271
+ return kl().feedback(e);
13214
13272
  }
13215
- function Tl(e) {
13216
- return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13273
+ async function Tl(e, t, n) {
13274
+ return kl(n).enableFeatureForRoles(e, t);
13217
13275
  }
13218
13276
  function El(e) {
13219
- let t = Tl(e);
13277
+ return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13278
+ }
13279
+ function Dl(e, t, n) {
13280
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
13281
+ }
13282
+ function Ol(e, t, n) {
13283
+ let r = Array.from(new Set(e));
13284
+ L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
13285
+ }
13286
+ function kl(e) {
13287
+ let t = El(e);
13220
13288
  if (!t) throw Error("Conversation not found");
13221
13289
  return t;
13222
13290
  }
13223
- async function Dl(e) {
13291
+ function Al(e, t) {
13292
+ let n = $.current();
13293
+ if (!n) return null;
13294
+ let r = n.getCachedParticipantIdByExternalId(e);
13295
+ return r ? {
13296
+ conversation: n,
13297
+ participantId: r
13298
+ } : (Dl(e, t, n), null);
13299
+ }
13300
+ async function jl(e) {
13224
13301
  await Vs.removeHistoryRecords(e);
13225
13302
  }
13226
- async function Ol(e) {
13303
+ async function Ml(e) {
13227
13304
  let t = $.current() ?? z.getFirst();
13228
13305
  t && await t.startAsr(e);
13229
13306
  }
13230
- async function kl(e) {
13307
+ async function Nl(e) {
13231
13308
  let t = $.current() ?? z.getFirst();
13232
13309
  t && await t.stopAsr(e);
13233
13310
  }
13234
- async function Al(e) {
13311
+ async function Pl(e) {
13235
13312
  let t = $.current() ?? z.getFirst();
13236
13313
  t && await t.requestAsr(e);
13237
13314
  }
13238
- async function jl(e) {
13315
+ async function Fl(e) {
13239
13316
  let t = $.current();
13240
13317
  return t ? t.startUrlSharing(e) : Promise.reject();
13241
13318
  }
13242
- async function Ml() {
13319
+ async function Il() {
13243
13320
  let e = $.current();
13244
13321
  return e ? e.stopUrlSharing() : Promise.reject();
13245
13322
  }
13246
- async function Nl(e) {
13323
+ async function Ll(e) {
13247
13324
  await z.switchCall(e);
13248
13325
  }
13249
- function Pl() {
13326
+ function Rl() {
13250
13327
  return z.getActiveId();
13251
13328
  }
13252
- function Fl() {
13329
+ function zl() {
13253
13330
  return $.getSyncedTime();
13254
13331
  }
13255
- function Il() {
13332
+ function Bl() {
13256
13333
  return M.sdkVersion;
13257
13334
  }
13258
13335
  typeof window < "u" && (window.__CALLS_SDK = yn);
13259
13336
  //#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 };
13337
+ 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 };