@vkontakte/calls-sdk 2.8.12-beta.1 → 2.8.12-dev.8c2bbcbf.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/calls-sdk.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @vkontakte/calls-sdk v2.8.12-beta.1
3
- * Fri, 24 Jul 2026 10:37:01 GMT
2
+ * @vkontakte/calls-sdk v2.8.12-dev.8c2bbcbf.0
3
+ * Mon, 27 Jul 2026 08:32:42 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -464,11 +464,22 @@ var v = class e {
464
464
  static set accessToken(t) {
465
465
  e._accessToken = t;
466
466
  }
467
+ static get userId() {
468
+ return e._userId;
469
+ }
470
+ static set userId(t) {
471
+ e._userId = t;
472
+ }
467
473
  static isEmpty() {
468
474
  return !e._sessionKey;
469
475
  }
476
+ static reauthorize(t) {
477
+ return e._reauthorizePromise || (e._reauthorizePromise = t().finally(() => {
478
+ e._reauthorizePromise = null;
479
+ })), e._reauthorizePromise;
480
+ }
470
481
  };
471
- h(v, "_sessionKey", void 0), h(v, "_sessionSecretKey", void 0), h(v, "_accessToken", void 0);
482
+ h(v, "_sessionKey", void 0), h(v, "_sessionSecretKey", void 0), h(v, "_accessToken", void 0), h(v, "_userId", null), h(v, "_reauthorizePromise", null);
472
483
  //#endregion
473
484
  //#region src/classes/EventEmitter.ts
474
485
  var y = class {
@@ -2159,7 +2170,7 @@ var mn = pn.getInstance(), M = class e {
2159
2170
  return 1.1;
2160
2171
  }
2161
2172
  static get sdkVersion() {
2162
- return "2.8.12-beta.1";
2173
+ return "2.8.12-dev.8c2bbcbf.0";
2163
2174
  }
2164
2175
  static get debug() {
2165
2176
  return e._params.debug;
@@ -3164,14 +3175,28 @@ var L = gn, _n = /* @__PURE__ */ function(e) {
3164
3175
  })(vn || (vn = {}));
3165
3176
  var R = vn, z = new class {
3166
3177
  constructor() {
3167
- h(this, "_conversations", /* @__PURE__ */ new Map()), h(this, "_activeId", null), h(this, "_mutex", !1);
3178
+ h(this, "_conversations", /* @__PURE__ */ new Map()), h(this, "_reserved", /* @__PURE__ */ new Set()), h(this, "_activeId", null), h(this, "_mutex", !1), h(this, "_pendingRemovals", /* @__PURE__ */ new Set());
3179
+ }
3180
+ reserve(e) {
3181
+ if (this._conversations.has(e) || this._reserved.has(e)) throw Error(`CallRegistry: conversation ${e} already exists`);
3182
+ this._reserved.add(e);
3168
3183
  }
3169
3184
  add(e) {
3170
- if (this._conversations.has(e.id)) throw Error(`CallRegistry: conversation ${e.id} already exists`);
3171
- this._conversations.set(e.id, e);
3185
+ let t = e.id;
3186
+ if (this._conversations.has(t)) {
3187
+ R.warn(`CallRegistry: conversation ${t} already exists, skip duplicate add`), this._reserved.delete(t);
3188
+ return;
3189
+ }
3190
+ this._conversations.set(t, e), this._reserved.delete(t);
3172
3191
  }
3173
3192
  remove(e) {
3174
- this._mutex || (e && this._conversations.delete(e), this._activeId === e && (this._activeId = null));
3193
+ if (e) {
3194
+ if (this._reserved.delete(e), this._mutex) {
3195
+ this._pendingRemovals.add(e);
3196
+ return;
3197
+ }
3198
+ this._conversations.delete(e), this._activeId === e && (this._activeId = null);
3199
+ }
3175
3200
  }
3176
3201
  get(e) {
3177
3202
  return this._conversations.get(e);
@@ -3186,7 +3211,7 @@ var R = vn, z = new class {
3186
3211
  return this._activeId;
3187
3212
  }
3188
3213
  has(e) {
3189
- return this._conversations.has(e);
3214
+ return this._conversations.has(e) || this._reserved.has(e);
3190
3215
  }
3191
3216
  getAll() {
3192
3217
  return Array.from(this._conversations.values());
@@ -3215,7 +3240,7 @@ var R = vn, z = new class {
3215
3240
  throw R.error(`Can't hold next active, error: ${e}`), Error("Cannot switch call: hold failed");
3216
3241
  }
3217
3242
  } finally {
3218
- this._mutex = !1;
3243
+ this._mutex = !1, this._flushPendingRemovals();
3219
3244
  }
3220
3245
  }
3221
3246
  }
@@ -3231,7 +3256,7 @@ var R = vn, z = new class {
3231
3256
  }
3232
3257
  this._activeId = null;
3233
3258
  } finally {
3234
- this._mutex = !1;
3259
+ this._mutex = !1, this._flushPendingRemovals();
3235
3260
  }
3236
3261
  }
3237
3262
  }
@@ -3239,7 +3264,13 @@ var R = vn, z = new class {
3239
3264
  this._activeId === e ? await this.setHold(e) : await this.setActive(e);
3240
3265
  }
3241
3266
  clear() {
3242
- this._conversations.clear(), this._activeId = null;
3267
+ this._conversations.clear(), this._reserved.clear(), this._pendingRemovals.clear(), this._activeId = null;
3268
+ }
3269
+ _flushPendingRemovals() {
3270
+ if (this._pendingRemovals.size !== 0) {
3271
+ for (let e of this._pendingRemovals) this._conversations.delete(e), this._activeId === e && (this._activeId = null);
3272
+ this._pendingRemovals.clear();
3273
+ }
3243
3274
  }
3244
3275
  }(), yn = class extends y {
3245
3276
  constructor(...e) {
@@ -3926,7 +3957,7 @@ var Tr = class {
3926
3957
  let a = Date.now(), o = this._calcRating(this._localNetworkStat, this._remoteNetworkStat, t), s = Math.max(Math.round(o * 10) / 10, .1), c = this._getNetworkState(s);
3927
3958
  (t || c !== this._currentState || a - this._lastStatSentTimestamp > M.networkStatisticsInterval) && (this._lastStatSentTimestamp = a, this._signaling.customData({ sdk: Object.assign({ type: "bad-net" }, i) }, null).catch((e) => {
3928
3959
  this._debug.warn("Unable to send [bad-net]", e);
3929
- })), this._currentState = c, this._triggerEvent(Y.NETWORK_STATUS, s);
3960
+ })), this._currentState = c, this._triggerEvent(X.NETWORK_STATUS, s);
3930
3961
  }
3931
3962
  reportRemote(e) {
3932
3963
  let { rtt: t, loss: n, bitrate: r } = e || {};
@@ -3947,7 +3978,7 @@ var Tr = class {
3947
3978
  worst: 320,
3948
3979
  bad: 640,
3949
3980
  good: 1280
3950
- }), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), this._participantId = e, this._isMaster = t, this._serverSettings = i, this._debug = a, this._logger = o, this._statAggregator = s, this._codecStatsAggregator = c, this._perfStatReporter = new oa(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new Lr(n, this._debug), this.subscribe(this._signaling, G.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, Kt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, Kt.SOURCE_CHANGED, this._applySettings.bind(this)), this.subscribe(this._directStatReporter, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this));
3981
+ }), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), this._participantId = e, this._isMaster = t, this._serverSettings = i, this._debug = a, this._logger = o, this._statAggregator = s, this._codecStatsAggregator = c, this._perfStatReporter = new aa(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new Lr(n, this._debug), this.subscribe(this._signaling, G.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, Kt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, Kt.SOURCE_CHANGED, this._applySettings.bind(this)), this.subscribe(this._directStatReporter, X.NETWORK_STATUS, this._onNetworkStatus.bind(this));
3951
3982
  try {
3952
3983
  this._pc = this._createPeerConnection();
3953
3984
  } catch (e) {
@@ -4059,7 +4090,7 @@ var Tr = class {
4059
4090
  if (this._disposeFirstMediaSentProbe(), this._lastStat = null, this._remoteStream) {
4060
4091
  let e = this._remoteStream;
4061
4092
  e.getTracks().forEach((t) => {
4062
- t.stop(), this._triggerEvent(Y.REMOTE_TRACK_REMOVED, e, t);
4093
+ t.stop(), this._triggerEvent(X.REMOTE_TRACK_REMOVED, e, t);
4063
4094
  }), this._remoteStream = null;
4064
4095
  }
4065
4096
  this._animojiDataChannel && (this._animojiDataChannel.onopen = null, this._animojiDataChannel.onmessage = null, this._animojiDataChannel.onerror = null, this._animojiDataChannel.close(), this._animojiDataChannel = null), this._pc && (this._pc.onicecandidate = null, this._pc.ontrack = null, this._pc.oniceconnectionstatechange = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._pc.close(), this._pc = null);
@@ -4071,10 +4102,10 @@ var Tr = class {
4071
4102
  }
4072
4103
  }
4073
4104
  close(e) {
4074
- this._isOpen && (this._isOpen = !1, this._stopReconnection(), this._stopStatInterval(), this._stopSettingsInterval(), this._disposePeerConnection(), this._onNetworkStatus(1), this.unsubscribe(), e ? (this._debug.error("DirectTransport: Closed", e, { participantId: this._participantId }), this._setState(q.FAILED)) : (this._debug.debug("DirectTransport: Closed", { participantId: this._participantId }), this._setState(q.CLOSED)), this._triggerEvent(Y.PEER_CONNECTION_CLOSED));
4105
+ this._isOpen && (this._isOpen = !1, this._stopReconnection(), this._stopStatInterval(), this._stopSettingsInterval(), this._disposePeerConnection(), this._onNetworkStatus(1), this.unsubscribe(), e ? (this._debug.error("DirectTransport: Closed", e, { participantId: this._participantId }), this._setState(q.FAILED)) : (this._debug.debug("DirectTransport: Closed", { participantId: this._participantId }), this._setState(q.CLOSED)), this._triggerEvent(X.PEER_CONNECTION_CLOSED));
4075
4106
  }
4076
4107
  _setState(e) {
4077
- this._state !== e && (this._debug.debug(`DirectTransport: State changed to ${e}`, { participantId: this._participantId }), this._state = e, this._triggerEvent(Y.STATE_CHANGED, e));
4108
+ this._state !== e && (this._debug.debug(`DirectTransport: State changed to ${e}`, { participantId: this._participantId }), this._state = e, this._triggerEvent(X.STATE_CHANGED, e));
4078
4109
  }
4079
4110
  _onSignalingNotification(e) {
4080
4111
  switch (e.notification) {
@@ -4149,8 +4180,8 @@ var Tr = class {
4149
4180
  participantId: this._participantId,
4150
4181
  kind: e.track.kind
4151
4182
  }), this._remoteStream ? this._remoteStream.addTrack(e.track) : (this._remoteStream = new MediaStream([e.track]), this._remoteStream.onremovetrack = (e) => {
4152
- this._triggerEvent(Y.REMOTE_TRACK_REMOVED, this._remoteStream, e.track);
4153
- }), this._triggerEvent(Y.REMOTE_TRACK_ADDED, this._remoteStream, e.track);
4183
+ this._triggerEvent(X.REMOTE_TRACK_REMOVED, this._remoteStream, e.track);
4184
+ }), this._triggerEvent(X.REMOTE_TRACK_ADDED, this._remoteStream, e.track);
4154
4185
  }
4155
4186
  async _handleIceCandidate(e) {
4156
4187
  e.candidate && this._signaling.ready && (this._debug.debug("Local ice candidate", {
@@ -4306,7 +4337,7 @@ var Tr = class {
4306
4337
  rtps: t.remoteRtps ?? []
4307
4338
  }
4308
4339
  };
4309
- this._checkPPTNetwork(n), this._directStatReporter.reportLocal(n), this._triggerEvent(Y.REMOTE_DATA_STATS, n), this._statInterval = window.setTimeout(e, M.statisticsInterval);
4340
+ this._checkPPTNetwork(n), this._directStatReporter.reportLocal(n), this._triggerEvent(X.REMOTE_DATA_STATS, n), this._statInterval = window.setTimeout(e, M.statisticsInterval);
4310
4341
  });
4311
4342
  };
4312
4343
  this._statInterval = window.setTimeout(e, M.statisticsInterval);
@@ -4359,7 +4390,7 @@ var Tr = class {
4359
4390
  }
4360
4391
  _onNetworkStatus(e) {
4361
4392
  let t = {};
4362
- t[this._participantId] = t[""] = e, this._triggerEvent(Y.NETWORK_STATUS, t);
4393
+ t[this._participantId] = t[""] = e, this._triggerEvent(X.NETWORK_STATUS, t);
4363
4394
  }
4364
4395
  _startSettingsInterval() {
4365
4396
  let e = 2e3;
@@ -4583,9 +4614,9 @@ var Gr = class {
4583
4614
  participantUpdateInfos: n
4584
4615
  };
4585
4616
  }
4586
- }, Kr = /* @__PURE__ */ function(e) {
4617
+ }, Y = /* @__PURE__ */ function(e) {
4587
4618
  return e.INIT = "init", e.READY = "ready", e.FRAME = "frame", e.SET_BITRATE = "set_bitrate", e.ERROR = "error", e.DEBUG = "debug", e.LOG_ERROR = "log_error", e;
4588
- }({}), qr = class {
4619
+ }({}), Kr = class {
4589
4620
  constructor(e = R, t = null) {
4590
4621
  h(this, "_worker", null), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = e, this._logger = t;
4591
4622
  }
@@ -4601,7 +4632,7 @@ var Gr = class {
4601
4632
  return;
4602
4633
  }
4603
4634
  t({
4604
- type: Kr.FRAME,
4635
+ type: Y.FRAME,
4605
4636
  error: e
4606
4637
  });
4607
4638
  };
@@ -4611,23 +4642,23 @@ var Gr = class {
4611
4642
  e.preventDefault?.(), m(this._formatWorkerMessageError(e));
4612
4643
  }, f.onmessage = (e) => {
4613
4644
  switch (e.data.type) {
4614
- case Kr.READY:
4645
+ case Y.READY:
4615
4646
  s = !0, c || (c = !0, a());
4616
4647
  break;
4617
- case Kr.ERROR:
4648
+ case Y.ERROR:
4618
4649
  s ? m(e.data.error) : p(e.data.error);
4619
4650
  break;
4620
- case Kr.FRAME:
4651
+ case Y.FRAME:
4621
4652
  t(e.data);
4622
4653
  break;
4623
- case Kr.DEBUG:
4654
+ case Y.DEBUG:
4624
4655
  this._debug.debug(e.data.message);
4625
4656
  break;
4626
- case Kr.LOG_ERROR:
4657
+ case Y.LOG_ERROR:
4627
4658
  this._logger?.log(S.ERROR, e.data.message);
4628
4659
  break;
4629
4660
  }
4630
- }, this._sendToWorker(Kr.INIT, r, i);
4661
+ }, this._sendToWorker(Y.INIT, r, i);
4631
4662
  });
4632
4663
  }
4633
4664
  _removeWorker() {
@@ -4650,7 +4681,7 @@ var Gr = class {
4650
4681
  static isBrowserSupported() {
4651
4682
  throw Error("Not implemented");
4652
4683
  }
4653
- }, Jr = class extends qr {
4684
+ }, qr = class extends Kr {
4654
4685
  constructor(e = R, t = null) {
4655
4686
  super(e, t);
4656
4687
  }
@@ -4660,7 +4691,7 @@ var Gr = class {
4660
4691
  }, [c, c.getUrl]);
4661
4692
  }
4662
4693
  decodeFrame(e, t, n, r) {
4663
- this._sendToWorker(Kr.FRAME, {
4694
+ this._sendToWorker(Y.FRAME, {
4664
4695
  timestamp: e,
4665
4696
  data: t.buffer,
4666
4697
  isVP9: n,
@@ -4674,7 +4705,7 @@ var Gr = class {
4674
4705
  static isBrowserSupported() {
4675
4706
  return "WebAssembly" in window && "Worker" in window;
4676
4707
  }
4677
- }, Yr = class extends qr {
4708
+ }, Jr = class extends Kr {
4678
4709
  constructor(e = R, t = null) {
4679
4710
  super(e, t);
4680
4711
  }
@@ -4684,7 +4715,7 @@ var Gr = class {
4684
4715
  }, [T.baseChromeVersion() >= 92 || T.browserName() === "Safari"]);
4685
4716
  }
4686
4717
  decodeFrame(e, t, n, r = !1) {
4687
- this._sendToWorker(Kr.FRAME, {
4718
+ this._sendToWorker(Y.FRAME, {
4688
4719
  timestamp: e,
4689
4720
  data: t.buffer,
4690
4721
  isVP9: n,
@@ -4697,7 +4728,7 @@ var Gr = class {
4697
4728
  static isBrowserSupported() {
4698
4729
  return "VideoDecoder" in window && "Worker" in window && "VideoFrame" in window && !T.isBrokenVP9Decoder() && T.browserName() !== "Firefox";
4699
4730
  }
4700
- }, Xr = class {
4731
+ }, Yr = class {
4701
4732
  constructor(e = null, t = 0) {
4702
4733
  h(this, "_counter", 0), h(this, "_interval", 0), h(this, "_lastCalculationTime", Date.now()), h(this, "_onCalculated", null), this._onCalculated = e, t && (this._interval = window.setInterval(() => this.calculate(), t));
4703
4734
  }
@@ -4711,7 +4742,7 @@ var Gr = class {
4711
4742
  destroy() {
4712
4743
  window.clearInterval(this._interval), this._interval = 0;
4713
4744
  }
4714
- }, Zr = class {
4745
+ }, Xr = class {
4715
4746
  constructor(e, t) {
4716
4747
  h(this, "_participantId", void 0), h(this, "_statAggregator", void 0), h(this, "_firstFrameReceived", !1), this._participantId = e, this._statAggregator = t;
4717
4748
  }
@@ -4726,14 +4757,14 @@ var Gr = class {
4726
4757
  height: t
4727
4758
  });
4728
4759
  }
4729
- }, Qr = 65536, $r = "MARK_SCREENSHARE_FREEZE_DURATION", ei = class e {
4760
+ }, Zr = 65536, Qr = "MARK_SCREENSHARE_FREEZE_DURATION", $r = class e {
4730
4761
  constructor(e, t, n, r, i, a = R) {
4731
- h(this, "_participantId", void 0), h(this, "_onStream", void 0), h(this, "_onStat", void 0), h(this, "_onKeyFrameRequested", void 0), h(this, "_statScreenShareFirstFrame", void 0), h(this, "_debug", void 0), h(this, "_chunks", []), this._participantId = e, this._onStream = t, this._onStat = n, this._onKeyFrameRequested = i, this._statScreenShareFirstFrame = new Zr(e, r), this._debug = a;
4762
+ h(this, "_participantId", void 0), h(this, "_onStream", void 0), h(this, "_onStat", void 0), h(this, "_onKeyFrameRequested", void 0), h(this, "_statScreenShareFirstFrame", void 0), h(this, "_debug", void 0), h(this, "_chunks", []), this._participantId = e, this._onStream = t, this._onStat = n, this._onKeyFrameRequested = i, this._statScreenShareFirstFrame = new Xr(e, r), this._debug = a;
4732
4763
  }
4733
4764
  appendChunk(t) {
4734
4765
  let n = this._chunks.length;
4735
4766
  if (t.start) this._measureFreezeDuration(!1), this._measureFreezeDuration(!0), n && (this._debug.warn("[FrameBuilder] Cleanup buffer", Array.prototype.slice.call(this._chunks)), this._chunks = []);
4736
- else if (!n || (this._chunks[n - 1].sequence + 1) % Qr !== t.sequence) {
4767
+ else if (!n || (this._chunks[n - 1].sequence + 1) % Zr !== t.sequence) {
4737
4768
  this._debug.warn("[FrameBuilder] Got incorrect chunk");
4738
4769
  return;
4739
4770
  }
@@ -4750,7 +4781,7 @@ var Gr = class {
4750
4781
  }
4751
4782
  }
4752
4783
  destroy() {
4753
- W.clearMark($r), W.clearMark(W.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
4784
+ W.clearMark(Qr), W.clearMark(W.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
4754
4785
  }
4755
4786
  _processFrameData() {
4756
4787
  let e = this._chunks;
@@ -4773,13 +4804,13 @@ var Gr = class {
4773
4804
  }
4774
4805
  _measureFreezeDuration(e) {
4775
4806
  if (e) {
4776
- W.setMark($r);
4807
+ W.setMark(Qr);
4777
4808
  return;
4778
4809
  }
4779
- let t = W.measureMark($r);
4810
+ let t = W.measureMark(Qr);
4780
4811
  t !== null && t > 1e3 && this._onStat({ freeze_duration: t });
4781
4812
  }
4782
- }, ti = class {
4813
+ }, ei = class {
4783
4814
  constructor(e) {
4784
4815
  h(this, "_onStream", void 0), this._onStream = e;
4785
4816
  }
@@ -4792,7 +4823,7 @@ var Gr = class {
4792
4823
  static isBrowserSupported() {
4793
4824
  throw Error("Method `isBrowserSupported` is not implemented");
4794
4825
  }
4795
- }, ni = class extends ti {
4826
+ }, ti = class extends ei {
4796
4827
  constructor(e, t = R) {
4797
4828
  super(e), h(this, "_useImageBitmap", void 0), h(this, "_canvas", null), h(this, "_canvasContext", null), h(this, "_stream", null), h(this, "_track", null), h(this, "_debug", void 0), this._debug = t, this._debug.debug("CanvasRenderer started"), this._useImageBitmap = "ImageBitmap" in window;
4798
4829
  }
@@ -4852,7 +4883,7 @@ var Gr = class {
4852
4883
  static isBrowserSupported() {
4853
4884
  return ("CanvasCaptureMediaStream" in window || "CanvasCaptureMediaStreamTrack" in window) && !(T.browserName() === "Safari" && Number(T.browserVersion()) === 15) && !(T.browserName() === "Firefox" && Number(T.browserVersion()) < 60);
4854
4885
  }
4855
- }, ri = class extends ti {
4886
+ }, ni = class extends ei {
4856
4887
  constructor(e, t = R) {
4857
4888
  super(e), h(this, "_generator", void 0), h(this, "_writer", void 0), h(this, "_stream", void 0), h(this, "_debug", void 0), this._debug = t, this._debug.debug("TrackGeneratorRenderer started"), this._generator = new MediaStreamTrackGenerator({ kind: k.video }), this._writer = this._generator.writable.getWriter(), this._stream = new MediaStream([this._generator]), this._onStream(this._stream);
4858
4889
  }
@@ -4863,9 +4894,9 @@ var Gr = class {
4863
4894
  this._writer.releaseLock(), this._generator.writable.close().then(() => this._generator.stop()), this._debug.debug("TrackGeneratorRenderer destroyed");
4864
4895
  }
4865
4896
  static isBrowserSupported() {
4866
- return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && Yr.isBrowserSupported();
4897
+ return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && Jr.isBrowserSupported();
4867
4898
  }
4868
- }, ii = class extends ei {
4899
+ }, ri = class extends $r {
4869
4900
  constructor(e, t, n, r, i, a = R, o = null) {
4870
4901
  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();
4871
4902
  }
@@ -4873,20 +4904,20 @@ var Gr = class {
4873
4904
  e.keyframe && (this._decoderQueue = []), this._decoderQueue.push(e), this._decodeQueue();
4874
4905
  }
4875
4906
  _initFpsMeter() {
4876
- this._fpsMeter = new Xr((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
4907
+ this._fpsMeter = new Yr((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
4877
4908
  }
4878
4909
  _initRenderer(e = !1) {
4879
- e || !ri.isBrowserSupported() ? this._renderer = new ni(this._onStream, this._debug) : this._renderer = new ri(this._onStream, this._debug);
4910
+ e || !ni.isBrowserSupported() ? this._renderer = new ti(this._onStream, this._debug) : this._renderer = new ni(this._onStream, this._debug);
4880
4911
  }
4881
4912
  _initDecoder(e = !1) {
4882
- e || !Yr.isBrowserSupported() ? this._decoder = new Jr(this._debug, this._logger) : this._decoder = new Yr(this._debug, this._logger), this._decoder.init(async (e) => {
4913
+ e || !Jr.isBrowserSupported() ? this._decoder = new qr(this._debug, this._logger) : this._decoder = new Jr(this._debug, this._logger), this._decoder.init(async (e) => {
4883
4914
  this._decoderBusy = !1, "VideoFrame" in window && e instanceof VideoFrame ? await this._renderer.drawFrame(e) : await this._renderer.drawImage(e), this._fpsMeter.increment(), this._decodeQueue();
4884
4915
  }, (e) => {
4885
- this._decoderBusy = !1, this._decodeQueue(), this._decoder instanceof Yr && typeof e == "string" && e.includes("EncodingError") && this._switchToLibVPXDecoder();
4916
+ this._decoderBusy = !1, this._decodeQueue(), this._decoder instanceof Jr && typeof e == "string" && e.includes("EncodingError") && this._switchToLibVPXDecoder();
4886
4917
  }, this._onKeyFrameRequested).then(() => {
4887
4918
  this._decoderReady = !0, this._decodeQueue();
4888
4919
  }).catch((e) => {
4889
- this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof Yr && this._switchToLibVPXDecoder();
4920
+ this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof Jr && this._switchToLibVPXDecoder();
4890
4921
  });
4891
4922
  }
4892
4923
  _switchToLibVPXDecoder() {
@@ -4901,20 +4932,20 @@ var Gr = class {
4901
4932
  super.destroy(), this._fpsMeter.destroy(), this._decoder.destroy(), this._renderer.destroy(), this._debug.debug(`StreamBuilder destroyed for participant ${this._participantId}`);
4902
4933
  }
4903
4934
  static isBrowserSupported() {
4904
- return ni.isBrowserSupported() || ri.isBrowserSupported();
4935
+ return ti.isBrowserSupported() || ni.isBrowserSupported();
4905
4936
  }
4906
- }, ai = 1, oi = 1, si = 2, ci = 0, li = 1, ui = 2, di = 4, fi = 8;
4907
- function pi(e, t, n, r, i, a, o) {
4937
+ }, ii = 1, ai = 1, oi = 2, si = 0, ci = 1, li = 2, ui = 4, di = 8;
4938
+ function fi(e, t, n, r, i, a, o) {
4908
4939
  let s = 0;
4909
- t && (s |= li), n && (s |= ui), r && (s |= di), o || (s |= fi);
4940
+ t && (s |= ci), n && (s |= li), r && (s |= ui), o || (s |= di);
4910
4941
  let c = /* @__PURE__ */ new ArrayBuffer(11), l = new DataView(c);
4911
- if (l.setUint8(0, ai), l.setUint16(1, i), l.setUint32(3, e), l.setUint8(7, +!!a), l.setUint16(8, ci), l.setUint8(10, s), !o) return c;
4942
+ if (l.setUint8(0, ii), l.setUint16(1, i), l.setUint32(3, e), l.setUint8(7, +!!a), l.setUint16(8, si), l.setUint8(10, s), !o) return c;
4912
4943
  let u = new Uint8Array(c.byteLength + o.byteLength);
4913
4944
  return u.set(new Uint8Array(c), 0), u.set(new Uint8Array(o), c.byteLength), u.buffer;
4914
4945
  }
4915
- function mi(e) {
4916
- let t = new DataView(e), n = t.getUint8(0), r = t.getUint16(1), i = t.getUint32(3), a = t.getUint8(7) === 1, o = t.getUint16(8), s = t.getUint8(10), c = !!(s & li), l = !!(s & ui), u = !!(s & di), d = !!(s & fi);
4917
- if (n !== ai) throw Error(`Unexpected protocol version. Got ${n}, expected ${ai}`);
4946
+ function pi(e) {
4947
+ let t = new DataView(e), n = t.getUint8(0), r = t.getUint16(1), i = t.getUint32(3), a = t.getUint8(7) === 1, o = t.getUint16(8), s = t.getUint8(10), c = !!(s & ci), l = !!(s & li), u = !!(s & ui), d = !!(s & di);
4948
+ if (n !== ii) throw Error(`Unexpected protocol version. Got ${n}, expected ${ii}`);
4918
4949
  return {
4919
4950
  timestamp: i,
4920
4951
  start: c,
@@ -4927,26 +4958,26 @@ function mi(e) {
4927
4958
  data: e.slice(11)
4928
4959
  };
4929
4960
  }
4930
- function hi(e) {
4961
+ function mi(e) {
4931
4962
  if (!e || !e.byteLength || e.byteLength !== 4) return !1;
4932
4963
  let t = new DataView(e);
4933
- return !(t.getUint8(0) !== ai || t.getUint8(1) !== oi || t.getUint16(2) !== ci);
4964
+ return !(t.getUint8(0) !== ii || t.getUint8(1) !== ai || t.getUint16(2) !== si);
4934
4965
  }
4935
- function gi(e) {
4966
+ function hi(e) {
4936
4967
  if (!e || !e.byteLength || e.byteLength !== 10) return null;
4937
4968
  let t = new DataView(e);
4938
- return t.getUint8(0) !== ai || t.getUint8(1) !== si || t.getUint16(2) !== ci ? null : {
4969
+ return t.getUint8(0) !== ii || t.getUint8(1) !== oi || t.getUint16(2) !== si ? null : {
4939
4970
  seq: t.getUint16(4),
4940
4971
  ts2: t.getUint32(6)
4941
4972
  };
4942
4973
  }
4943
- function _i(e) {
4974
+ function gi(e) {
4944
4975
  let t = /* @__PURE__ */ new ArrayBuffer(4), n = new DataView(t);
4945
- return n.setUint8(0, ai), n.setUint8(1, oi), n.setUint16(2, e), t;
4976
+ return n.setUint8(0, ii), n.setUint8(1, ai), n.setUint16(2, e), t;
4946
4977
  }
4947
4978
  //#endregion
4948
4979
  //#region src/classes/screenshare/WebmBuilder.ts
4949
- var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
4980
+ var _i = 2 ** 15 - 1, vi = 1, yi = 5, bi = 5, xi = class e {
4950
4981
  constructor(e, t = R) {
4951
4982
  h(this, "_mediaSource", void 0), h(this, "_codec", void 0), h(this, "_sourceBuffer", null), h(this, "_queue", []), h(this, "_clearBufferTill", 0), h(this, "_debug", void 0), this._mediaSource = new MediaSource(), this._codec = e, this._debug = t;
4952
4983
  let n = () => {
@@ -4989,8 +5020,8 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
4989
5020
  this._mediaSource?.readyState === "open" && this._sourceBuffer?.abort();
4990
5021
  let e = this._sourceBuffer?.buffered, t = e?.length;
4991
5022
  if (!t) return;
4992
- let n = e.start(0), r = Math.max(0, e.end(t - 1) - bi);
4993
- r - n > xi && (this._clearBufferTill = r);
5023
+ let n = e.start(0), r = Math.max(0, e.end(t - 1) - yi);
5024
+ r - n > bi && (this._clearBufferTill = r);
4994
5025
  }
4995
5026
  destroy() {
4996
5027
  this._queue = [], this._mediaSource.readyState === "open" && (this._sourceBuffer?.abort(), this._mediaSource.endOfStream()), this._sourceBuffer = null, this._clearBufferTill = 0;
@@ -5004,7 +5035,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5004
5035
  get buffered() {
5005
5036
  return this._sourceBuffer?.buffered;
5006
5037
  }
5007
- }, Ci = class e extends ei {
5038
+ }, Si = class e extends $r {
5008
5039
  constructor(e, t, n, r, i = R) {
5009
5040
  super(e, t, n, r, void 0, i), h(this, "_mediaBuffer", null), h(this, "_video", null), h(this, "_stream", null), h(this, "_earliestTimestamp", 0), h(this, "_clusterStartTime", 0), h(this, "_lastFrameTimestamp", 0), this._debug.debug(`[WebmBuilder] started for participant [${e}]`);
5010
5041
  }
@@ -5028,8 +5059,8 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5028
5059
  u.element(u.ID.MuxingApp, u.string("vk-webm-builder")),
5029
5060
  u.element(u.ID.WritingApp, u.string("vk-webm-builder"))
5030
5061
  ]), i = [u.element(u.ID.PixelWidth, u.number(e)), u.element(u.ID.PixelHeight, u.number(t))], a = u.element(u.ID.Tracks, u.element(u.ID.TrackEntry, [
5031
- u.element(u.ID.TrackNumber, u.number(yi)),
5032
- u.element(u.ID.TrackUID, u.number(yi)),
5062
+ u.element(u.ID.TrackNumber, u.number(vi)),
5063
+ u.element(u.ID.TrackUID, u.number(vi)),
5033
5064
  u.element(u.ID.TrackType, u.number(1)),
5034
5065
  u.element(u.ID.FlagLacing, u.number(0)),
5035
5066
  u.element(u.ID.DefaultDuration, u.number(1e9)),
@@ -5042,7 +5073,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5042
5073
  return u.unknownSizeElement(u.ID.Cluster, [u.element(u.ID.Timecode, u.number(Math.round(e)))]);
5043
5074
  }
5044
5075
  _createVideo(e) {
5045
- this._mediaBuffer = new Si(e, this._debug), this._video = document.createElement("video"), this._video.autoplay = !0, this._video.controls = !1, this._video.muted = !0, this._video.style.pointerEvents = "none", this._video.style.visibility = "hidden", this._video.style.position = "absolute", this._video.style.width = "160px", this._video.style.height = "90px", this._video.style.bottom = "0", this._video.style.right = "0", this._video.style.zIndex = "5000", this._video.src = URL.createObjectURL(this._mediaBuffer.mediaSource), document.body.appendChild(this._video);
5076
+ this._mediaBuffer = new xi(e, this._debug), this._video = document.createElement("video"), this._video.autoplay = !0, this._video.controls = !1, this._video.muted = !0, this._video.style.pointerEvents = "none", this._video.style.visibility = "hidden", this._video.style.position = "absolute", this._video.style.width = "160px", this._video.style.height = "90px", this._video.style.bottom = "0", this._video.style.right = "0", this._video.style.zIndex = "5000", this._video.src = URL.createObjectURL(this._mediaBuffer.mediaSource), document.body.appendChild(this._video);
5046
5077
  let t = () => {
5047
5078
  if (this._video?.src) {
5048
5079
  this._debug.warn(`[WebmBuilder] Video paused for participant [${this._participantId}], try to play again`);
@@ -5069,13 +5100,13 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5069
5100
  this._mediaBuffer?.append(a);
5070
5101
  }
5071
5102
  let i = Math.round(r - this._clusterStartTime);
5072
- if (i > vi && (this._clusterStartTime = r, i = 0), i === 0) {
5103
+ if (i > _i && (this._clusterStartTime = r, i = 0), i === 0) {
5073
5104
  this._debug.debug(`[WebmBuilder] Cluster header for participant [${this._participantId}]`);
5074
5105
  let t = e._genClusterHeader(this._clusterStartTime);
5075
5106
  this._mediaBuffer?.append(t);
5076
5107
  }
5077
5108
  let a = u.element(u.ID.SimpleBlock, [
5078
- u.vintEncodedNumber(yi),
5109
+ u.vintEncodedNumber(vi),
5079
5110
  u.bytes(e._intToU16BE(i)),
5080
5111
  u.number(!!t.keyframe << 7),
5081
5112
  u.bytes(t.frameData)
@@ -5088,12 +5119,12 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5088
5119
  static isBrowserSupported() {
5089
5120
  return "captureStream" in window.HTMLVideoElement?.prototype && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp8\"") && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp9\"");
5090
5121
  }
5091
- }, wi = class {
5122
+ }, Ci = class {
5092
5123
  constructor(e, t, n, r, i, a = null, o = R, s = null) {
5093
5124
  h(this, "_datachannel", void 0), h(this, "_participantIdRegistry", null), h(this, "_streamBuilders", {}), h(this, "_onStream", () => {}), h(this, "_onEos", () => {}), h(this, "_onStat", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), this._debug = o, this._logger = s, this._statAggregator = a, this._debug.debug("ScreenCaptureReceiver started"), this._datachannel = e, this._participantIdRegistry = t, this._onStream = n, this._onEos = r, this._onStat = i, this._datachannel.onmessage = (e) => this._onDataChannelMessage(e.data);
5094
5125
  }
5095
5126
  _onDataChannelMessage(e) {
5096
- let t = mi(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5127
+ let t = pi(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5097
5128
  if (!n) {
5098
5129
  this._debug.warn(`Participant id for ssrc ${t.ssrc} not found in registry`);
5099
5130
  return;
@@ -5105,7 +5136,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5105
5136
  let r = this._streamBuilders[n];
5106
5137
  if (!r) {
5107
5138
  let e = (e) => this._onStream(n, e);
5108
- r = M.screenShareWebmBuilder && Ci.isBrowserSupported() ? new Ci(n, e, this._onStat, this._statAggregator, this._debug) : new ii(n, e, this._onStat, this._statAggregator, () => {
5139
+ r = M.screenShareWebmBuilder && Si.isBrowserSupported() ? new Si(n, e, this._onStat, this._statAggregator, this._debug) : new ri(n, e, this._onStat, this._statAggregator, () => {
5109
5140
  this._requestKeyFrame(t.ssrc);
5110
5141
  }, this._debug, this._logger), this._streamBuilders[n] = r;
5111
5142
  }
@@ -5113,7 +5144,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5113
5144
  }
5114
5145
  _requestKeyFrame(e) {
5115
5146
  if (!(!this._datachannel || this._datachannel.readyState !== "open")) try {
5116
- let t = _i(e);
5147
+ let t = gi(e);
5117
5148
  this._datachannel.send(t), this._debug.debug(`ScreenCaptureReceiver request for keyframe for ssrc ${e}`);
5118
5149
  } catch (e) {
5119
5150
  this._debug.warn("Failed to send keyframe request", e);
@@ -5126,7 +5157,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5126
5157
  destroy() {
5127
5158
  this._datachannel.onbufferedamountlow = null, this._datachannel.onmessage = null, this._onStream = () => {}, Object.values(this._streamBuilders).forEach((e) => e.destroy()), this._streamBuilders = {}, this._participantIdRegistry = null, this._debug.debug("ScreenCaptureReceiver destroyed");
5128
5159
  }
5129
- }, Ti = class {
5160
+ }, wi = class {
5130
5161
  constructor(e, t, n) {
5131
5162
  h(this, "_prev", void 0), h(this, "_next", void 0), h(this, "_data", void 0), this._next = n, n && (n.prev = this), this._prev = t, t && (t.next = this), this._data = e;
5132
5163
  }
@@ -5145,7 +5176,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5145
5176
  get data() {
5146
5177
  return this._data;
5147
5178
  }
5148
- }, Ei = class {
5179
+ }, Ti = class {
5149
5180
  constructor() {
5150
5181
  h(this, "_head", null), h(this, "_tail", null), h(this, "_length", 0);
5151
5182
  }
@@ -5153,7 +5184,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5153
5184
  return this._length;
5154
5185
  }
5155
5186
  push(...e) {
5156
- for (let t of e) this._tail = new Ti(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5187
+ for (let t of e) this._tail = new wi(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5157
5188
  }
5158
5189
  merge(e) {
5159
5190
  this._tail && (this._tail.next = e._head), this._head || (this._head = e._head), this._tail = e._tail, this._length += e._length, e.clear();
@@ -5183,7 +5214,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5183
5214
  for (; t !== null;) e.push(t.data), t = t.next;
5184
5215
  return e.length ? JSON.stringify(e, (e, t) => t instanceof Error ? String(t) : t) : "";
5185
5216
  }
5186
- }, Di = 1e3, Oi = class extends qr {
5217
+ }, Ei = 1e3, Di = class extends Kr {
5187
5218
  constructor(e, t, n, r, i = R, a = null) {
5188
5219
  super(i, a), h(this, "_sourceTrack", void 0), h(this, "_onFrame", void 0), h(this, "_useCongestionControl", void 0), h(this, "_maxBitrate", void 0), h(this, "_useImageCapture", void 0), h(this, "_video", null), h(this, "_imageCapture", null), h(this, "_canvas", null), h(this, "_canvasCtx", null), h(this, "_frameReadTimeout", 0), h(this, "_lastFrame", null), this._sourceTrack = e, this._onFrame = t, this._useCongestionControl = n, this._maxBitrate = r, this._useImageCapture = "ImageCapture" in window && ImageCapture.prototype.grabFrame !== void 0 && "ImageBitmap" in window, (e.readyState !== "live" || !e.enabled || e.muted) && (this._useImageCapture = !1);
5189
5220
  }
@@ -5252,7 +5283,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5252
5283
  }
5253
5284
  _encode(e, t) {
5254
5285
  let n = e.data.buffer;
5255
- this._sendToWorker(Kr.FRAME, {
5286
+ this._sendToWorker(Y.FRAME, {
5256
5287
  width: e.width,
5257
5288
  height: e.height,
5258
5289
  imageData: n,
@@ -5269,7 +5300,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5269
5300
  let t = this._drawFrameData(this._lastFrame);
5270
5301
  this._encode(t, e);
5271
5302
  } else this._onFrame(null);
5272
- }, Di), this._getFrameBitmap().then((t) => {
5303
+ }, Ei), this._getFrameBitmap().then((t) => {
5273
5304
  window.clearTimeout(this._frameReadTimeout), this._lastFrame?.close(), this._lastFrame = t;
5274
5305
  let n = this._drawFrameData(t);
5275
5306
  this._encode(n, e);
@@ -5279,7 +5310,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5279
5310
  this._useImageCapture ? this._requestFrameBitmap(e) : this._requestFrameVideo(e);
5280
5311
  }
5281
5312
  setBitrate(e, t, n) {
5282
- this._sendToWorker(Kr.SET_BITRATE, {
5313
+ this._sendToWorker(Y.SET_BITRATE, {
5283
5314
  bitrate: e,
5284
5315
  useCbr: t
5285
5316
  });
@@ -5290,7 +5321,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5290
5321
  destroy() {
5291
5322
  this._removeWorker(), this._removeStream(), this._removeDom(), this._debug.debug("LibVPxEncoder destroyed");
5292
5323
  }
5293
- }, ki = class extends qr {
5324
+ }, Oi = class extends Kr {
5294
5325
  constructor(e, t, n, r, i, a, o = R, s = null) {
5295
5326
  super(o, s), h(this, "_sourceTrack", void 0), h(this, "_trackProcessor", void 0), h(this, "_onFrame", void 0), h(this, "_useCongestionControl", void 0), h(this, "_maxBitrate", void 0), h(this, "_useCbr", void 0), h(this, "_frameRate", void 0), this._sourceTrack = e, this._onFrame = t, this._useCongestionControl = n, this._maxBitrate = r, this._useCbr = i, this._frameRate = a, this._trackProcessor = new MediaStreamTrackProcessor({ track: e });
5296
5327
  }
@@ -5318,10 +5349,10 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5318
5349
  }, [n]);
5319
5350
  }
5320
5351
  requestFrame(e = !1) {
5321
- this._sendToWorker(Kr.FRAME, { keyFrame: e });
5352
+ this._sendToWorker(Y.FRAME, { keyFrame: e });
5322
5353
  }
5323
5354
  setBitrate(e, t, n) {
5324
- this._sendToWorker(Kr.SET_BITRATE, {
5355
+ this._sendToWorker(Y.SET_BITRATE, {
5325
5356
  bitrate: e,
5326
5357
  useCbr: t,
5327
5358
  fps: n
@@ -5336,11 +5367,11 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5336
5367
  static isBrowserSupported() {
5337
5368
  return "VideoEncoder" in window && "Worker" in window && "EncodedVideoChunk" in window && "MediaStreamTrackProcessor" in window;
5338
5369
  }
5339
- }, Ai = 2100, ji = 600, Mi = 1.2, Ni = .8, Pi = 2e3, Fi = 8e3, Ii = 8e3, Li = 16e3, Ri = 4, zi = 2e3, Bi = /* @__PURE__ */ function(e) {
5370
+ }, ki = 2100, Ai = 600, ji = 1.2, Mi = .8, Ni = 2e3, Pi = 8e3, Fi = 8e3, Ii = 16e3, Li = 4, Ri = 2e3, zi = /* @__PURE__ */ function(e) {
5340
5371
  return e[e.NONE = 0] = "NONE", e[e.UP = 1] = "UP", e[e.DOWN = 2] = "DOWN", e;
5341
- }(Bi || {}), Vi = class {
5372
+ }(zi || {}), Bi = class {
5342
5373
  constructor(e, t, n, r, i, a, o, s = R) {
5343
- h(this, "_onCongestion", void 0), h(this, "_ccEnabled", void 0), h(this, "_fastSharing", void 0), h(this, "_trendDelayThreshold", void 0), h(this, "_highDelayThreshold", void 0), h(this, "_targetFps", void 0), h(this, "_minBitrate", void 0), h(this, "_maxBitrate", void 0), h(this, "_targetBitrate", void 0), h(this, "_lastDown", void 0), h(this, "_lastUp", void 0), h(this, "_lastProbing", void 0), h(this, "_lastCheckDelay", void 0), h(this, "_upPenalty", 0), h(this, "_probing", void 0), h(this, "_delayAvgShort", -1), h(this, "_delayAvgLong", -1), h(this, "_minDelay", Number.MAX_VALUE), h(this, "_maxDelay", 0), h(this, "_largeDelayDuration", 0), h(this, "_lastFpsCalcMs", void 0), h(this, "_frames", 0), h(this, "_fps", 0), h(this, "_debug", void 0), this._onCongestion = e, this._ccEnabled = r, this._debug = s, this._minBitrate = t, this._maxBitrate = n, this._fastSharing = i, this._targetFps = o, a > 0 ? this._highDelayThreshold = a : this._highDelayThreshold = Ai, i && (this._highDelayThreshold = ji), this._trendDelayThreshold = Math.round(this._highDelayThreshold / 3), this._targetBitrate = this._maxBitrate, this._probing = !1;
5374
+ h(this, "_onCongestion", void 0), h(this, "_ccEnabled", void 0), h(this, "_fastSharing", void 0), h(this, "_trendDelayThreshold", void 0), h(this, "_highDelayThreshold", void 0), h(this, "_targetFps", void 0), h(this, "_minBitrate", void 0), h(this, "_maxBitrate", void 0), h(this, "_targetBitrate", void 0), h(this, "_lastDown", void 0), h(this, "_lastUp", void 0), h(this, "_lastProbing", void 0), h(this, "_lastCheckDelay", void 0), h(this, "_upPenalty", 0), h(this, "_probing", void 0), h(this, "_delayAvgShort", -1), h(this, "_delayAvgLong", -1), h(this, "_minDelay", Number.MAX_VALUE), h(this, "_maxDelay", 0), h(this, "_largeDelayDuration", 0), h(this, "_lastFpsCalcMs", void 0), h(this, "_frames", 0), h(this, "_fps", 0), h(this, "_debug", void 0), this._onCongestion = e, this._ccEnabled = r, this._debug = s, this._minBitrate = t, this._maxBitrate = n, this._fastSharing = i, this._targetFps = o, a > 0 ? this._highDelayThreshold = a : this._highDelayThreshold = ki, i && (this._highDelayThreshold = Ai), this._trendDelayThreshold = Math.round(this._highDelayThreshold / 3), this._targetBitrate = this._maxBitrate, this._probing = !1;
5344
5375
  let c = Date.now();
5345
5376
  this._lastDown = 0, this._lastUp = c, this._lastProbing = c, this._lastCheckDelay = 0, this._lastFpsCalcMs = 0;
5346
5377
  }
@@ -5350,27 +5381,27 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5350
5381
  let i = 0, a = this._delayAvgShort - this._delayAvgLong, o = Math.round(Math.abs(a) * 100 / this._delayAvgLong), s = a > 40 && o > 30 && this._delayAvgShort > this._trendDelayThreshold, c = this._delayAvgShort > this._highDelayThreshold;
5351
5382
  s || c ? i = 2 : Math.abs(a) < 40 && o < 10 && !c && (i = 1);
5352
5383
  let l = Math.round(this._targetBitrate / 1e3), u = n;
5353
- e % 20 == 0 && this._debug.debug(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Bi[i]} tr=${l} br=${n}`);
5384
+ e % 20 == 0 && this._debug.debug(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${zi[i]} tr=${l} br=${n}`);
5354
5385
  let d = r - this._lastDown;
5355
- if (i === 2 && d > Pi) {
5356
- this._probing && (this._upPenalty = Math.min(++this._upPenalty, Ri), this._probing = !1);
5357
- let n = Ni * u * 1e3;
5358
- if (n >= this._targetBitrate && (n = this._targetBitrate * Ni), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
5359
- let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * Ii / 1e3);
5360
- this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Bi[i]}`), this._debug.log(`#${e}: cc: DOWN delay=${t} bitrate=${u} target=${l} -> newBitrate=${r} penalty=${s}s`), this._setBitrate(n, !0), this._targetBitrate = n;
5386
+ if (i === 2 && d > Ni) {
5387
+ this._probing && (this._upPenalty = Math.min(++this._upPenalty, Li), this._probing = !1);
5388
+ let n = Mi * u * 1e3;
5389
+ if (n >= this._targetBitrate && (n = this._targetBitrate * Mi), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
5390
+ let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * Fi / 1e3);
5391
+ this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${zi[i]}`), this._debug.log(`#${e}: cc: DOWN delay=${t} bitrate=${u} target=${l} -> newBitrate=${r} penalty=${s}s`), this._setBitrate(n, !0), this._targetBitrate = n;
5361
5392
  }
5362
5393
  this._lastDown = r;
5363
5394
  }
5364
- let f = r - this._lastUp, p = Fi + this._upPenalty * Ii;
5395
+ let f = r - this._lastUp, p = Pi + this._upPenalty * Fi;
5365
5396
  if (i === 1 && f > p && d > p) {
5366
- let n = Math.min(this._targetBitrate * Mi, this._maxBitrate);
5397
+ let n = Math.min(this._targetBitrate * ji, this._maxBitrate);
5367
5398
  if (n > this._targetBitrate) {
5368
- let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty * Ii / 1e3);
5369
- this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Bi[i]}`), this._debug.log(`#${e}: cc: UP bitrate=${u} target=${c} -> newBitrate=${s} penalty=${l}s`), this._setBitrate(n, !1), this._targetBitrate = n, this._probing = !0, this._lastProbing = r, this._lastUp = r;
5399
+ let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty * Fi / 1e3);
5400
+ this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${zi[i]}`), this._debug.log(`#${e}: cc: UP bitrate=${u} target=${c} -> newBitrate=${s} penalty=${l}s`), this._setBitrate(n, !1), this._targetBitrate = n, this._probing = !0, this._lastProbing = r, this._lastUp = r;
5370
5401
  }
5371
5402
  }
5372
5403
  let m = r - this._lastProbing;
5373
- this._probing && m > Li && (this._probing = !1);
5404
+ this._probing && m > Ii && (this._probing = !1);
5374
5405
  let ee = r - this._lastDown;
5375
5406
  this._upPenalty > 0 && ee > 3 * p && (this._debug.log(`#${e}: cc: UP reset penalty: oldPenalty=${this._upPenalty}`), this._upPenalty = 0);
5376
5407
  }
@@ -5381,7 +5412,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5381
5412
  }
5382
5413
  _calcDelay(e, t) {
5383
5414
  if (!(e <= 0)) {
5384
- if (this._delayAvgShort === -1 && (this._delayAvgShort = e, this._delayAvgLong = e), this._delayAvgShort = Math.round((this._delayAvgShort * 3 + e) / 4), this._delayAvgLong = Math.round((this._delayAvgLong * 23 + e) / 24), e > 0 && e < this._minDelay ? this._minDelay = e : e > this._maxDelay && (this._maxDelay = e), this._lastCheckDelay === 0 && (this._lastCheckDelay = t), e > zi) {
5415
+ if (this._delayAvgShort === -1 && (this._delayAvgShort = e, this._delayAvgLong = e), this._delayAvgShort = Math.round((this._delayAvgShort * 3 + e) / 4), this._delayAvgLong = Math.round((this._delayAvgLong * 23 + e) / 24), e > 0 && e < this._minDelay ? this._minDelay = e : e > this._maxDelay && (this._maxDelay = e), this._lastCheckDelay === 0 && (this._lastCheckDelay = t), e > Ri) {
5385
5416
  let e = t - this._lastCheckDelay;
5386
5417
  this._largeDelayDuration += e;
5387
5418
  }
@@ -5410,7 +5441,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5410
5441
  this._fps === 0 ? this._fps = Math.round(r) : this._fps = Math.round((this._fps * 3 + r) / 4), this._frames = 0, this._fps !== n && this._debug.log(`cc: fps=${this._fps}`);
5411
5442
  }
5412
5443
  }
5413
- }, Hi = class {
5444
+ }, Vi = class {
5414
5445
  constructor(e) {
5415
5446
  h(this, "_maxSize", void 0), h(this, "_size", 0), h(this, "_buffer", void 0), h(this, "_head", 0), h(this, "_tail", 0), this._maxSize = e, this._buffer = Array(e);
5416
5447
  }
@@ -5484,11 +5515,11 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5484
5515
  clear() {
5485
5516
  this._buffer.fill(void 0), this._size = 0, this._head = 0, this._tail = 0;
5486
5517
  }
5487
- }, Ui = 65536, Wi = 50, Gi = 400, Ki = 1e6, qi = 3e5, Ji = 3e4, Yi = 2e3, Xi = 5, Zi = 0, Qi = class {
5518
+ }, Hi = 65536, Ui = 50, Wi = 400, Gi = 1e6, Ki = 3e5, qi = 3e4, Ji = 2e3, Yi = 5, Xi = 0, Zi = class {
5488
5519
  constructor(e, t, n, r, i = R, a = null) {
5489
- h(this, "_encoder", void 0), h(this, "_datachannel", void 0), h(this, "_signaling", void 0), h(this, "_fastSharing", void 0), h(this, "_destroyed", !1), h(this, "_needKeyframe", !0), h(this, "DATA_SIZE", void 0), h(this, "_congestionControl", void 0), h(this, "_frameNum", 0), h(this, "_width", void 0), h(this, "_height", void 0), h(this, "_feedback", new Hi(1024)), h(this, "_lastSentFrameSeq", 0), h(this, "_lastDeliveredFrameSeq", 0), h(this, "_lastFrameDelay", 0), h(this, "_lastFramerateReduced", Date.now()), h(this, "_lastSharingStat", Date.now()), h(this, "_congestionControlEnabled", void 0), h(this, "_queue", new Ei()), h(this, "_fpsMeter", void 0), h(this, "_maxFrameDelay", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = i, this._logger = a, this._debug.debug("ScreenCaptureSender started"), this.DATA_SIZE = M.consumerScreenDataChannelPacketSize - 11, this._datachannel = t, this._signaling = n, this._fastSharing = r, this._congestionControlEnabled = M.screenShareCongestionControl || this._fastSharing, this._width = e.getSettings().width, this._height = e.getSettings().height, this._maxFrameDelay = this._fastSharing ? M.screenShareCongestionControlThreshold : M.screenShareCongestionControlThreshold * 2;
5520
+ h(this, "_encoder", void 0), h(this, "_datachannel", void 0), h(this, "_signaling", void 0), h(this, "_fastSharing", void 0), h(this, "_destroyed", !1), h(this, "_needKeyframe", !0), h(this, "DATA_SIZE", void 0), h(this, "_congestionControl", void 0), h(this, "_frameNum", 0), h(this, "_width", void 0), h(this, "_height", void 0), h(this, "_feedback", new Vi(1024)), h(this, "_lastSentFrameSeq", 0), h(this, "_lastDeliveredFrameSeq", 0), h(this, "_lastFrameDelay", 0), h(this, "_lastFramerateReduced", Date.now()), h(this, "_lastSharingStat", Date.now()), h(this, "_congestionControlEnabled", void 0), h(this, "_queue", new Ti()), h(this, "_fpsMeter", void 0), h(this, "_maxFrameDelay", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = i, this._logger = a, this._debug.debug("ScreenCaptureSender started"), this.DATA_SIZE = M.consumerScreenDataChannelPacketSize - 11, this._datachannel = t, this._signaling = n, this._fastSharing = r, this._congestionControlEnabled = M.screenShareCongestionControl || this._fastSharing, this._width = e.getSettings().width, this._height = e.getSettings().height, this._maxFrameDelay = this._fastSharing ? M.screenShareCongestionControlThreshold : M.screenShareCongestionControlThreshold * 2;
5490
5521
  let o = M.getScreenFrameRate(this._fastSharing), { minBitrate: s, maxBitrate: c } = this._calcMinMaxBitrate(this._width, this._height), l = this._onCongestionCallback.bind(this);
5491
- this._debug.log(`ScreenCaptureSender: CongestionControl: enabled=${this._congestionControlEnabled} minBitrate=${Math.round(s / 1e3)}k maxBitrate=${Math.round(c / 1e3)}k delayThreshold=${M.screenShareCongestionControlThreshold}`), this._congestionControl = new Vi(l, s, c, this._congestionControlEnabled, this._fastSharing, M.screenShareCongestionControlThreshold, o, this._debug);
5522
+ this._debug.log(`ScreenCaptureSender: CongestionControl: enabled=${this._congestionControlEnabled} minBitrate=${Math.round(s / 1e3)}k maxBitrate=${Math.round(c / 1e3)}k delayThreshold=${M.screenShareCongestionControlThreshold}`), this._congestionControl = new Bi(l, s, c, this._congestionControlEnabled, this._fastSharing, M.screenShareCongestionControlThreshold, o, this._debug);
5492
5523
  let u = (e, t) => {
5493
5524
  if (this._destroyed) return;
5494
5525
  if (!e) {
@@ -5499,23 +5530,23 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5499
5530
  let n = this._sliceFrame(e);
5500
5531
  this._queue.merge(n), this._handleQueue(), this._sendSharingStat();
5501
5532
  };
5502
- if (ki.isBrowserSupported()) {
5533
+ if (Oi.isBrowserSupported()) {
5503
5534
  let t = this._fastSharing;
5504
- this._encoder = new ki(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
5505
- } else this._encoder = new Oi(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
5535
+ this._encoder = new Oi(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
5536
+ } else this._encoder = new Di(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
5506
5537
  this._datachannel.onmessage = (e) => {
5507
- hi(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
5508
- let t = gi(e.data);
5538
+ mi(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
5539
+ let t = hi(e.data);
5509
5540
  t !== null && this._checkCcFeedback(t);
5510
- }, this._encoder.init().then(() => this._handleQueue()).catch((e) => this._debug.warn("ScreenCaptureSender init failed", e)), this._fpsMeter = new Xr((e) => this._debug.log(`[ScreenCaptureSender] fps: ${e}`), 5e3);
5541
+ }, this._encoder.init().then(() => this._handleQueue()).catch((e) => this._debug.warn("ScreenCaptureSender init failed", e)), this._fpsMeter = new Yr((e) => this._debug.log(`[ScreenCaptureSender] fps: ${e}`), 5e3);
5511
5542
  }
5512
5543
  _handleQueue() {
5513
5544
  if (this._destroyed) return;
5514
5545
  let e = this._queue.shift();
5515
5546
  if (!e) {
5516
- if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + Ui) % Ui > Xi && this._lastFrameDelay > this._maxFrameDelay) {
5547
+ if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + Hi) % Hi > Yi && this._lastFrameDelay > this._maxFrameDelay) {
5517
5548
  let e = Date.now();
5518
- e - this._lastFramerateReduced > Yi && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5549
+ e - this._lastFramerateReduced > Ji && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5519
5550
  } else this._requestFrame();
5520
5551
  return;
5521
5552
  }
@@ -5541,7 +5572,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5541
5572
  this._destroyed || (this._encoder.requestFrame(this._needKeyframe), this._needKeyframe = !1);
5542
5573
  }
5543
5574
  _sliceFrame(e) {
5544
- let t = e.type === "key", n = e.data.byteLength, r = new Ei();
5575
+ let t = e.type === "key", n = e.data.byteLength, r = new Ti();
5545
5576
  for (let i = 0; i < n; i += this.DATA_SIZE) {
5546
5577
  let a = e.data.slice(i, i + this.DATA_SIZE), o = i === 0, s = n <= i + a.byteLength, c = this._wrapHeader(e.timestamp, o, s, t, a);
5547
5578
  r.push({
@@ -5557,11 +5588,11 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5557
5588
  return r;
5558
5589
  }
5559
5590
  _wrapHeader(e, t, n, r, i) {
5560
- let a = pi(e, t, n, r, Zi, this._encoder.isVP9(), i), o = {
5561
- sequence: Zi,
5591
+ let a = fi(e, t, n, r, Xi, this._encoder.isVP9(), i), o = {
5592
+ sequence: Xi,
5562
5593
  data: a
5563
5594
  };
5564
- return Zi = (Zi + 1) % Ui, o;
5595
+ return Xi = (Xi + 1) % Hi, o;
5565
5596
  }
5566
5597
  _stopPacket() {
5567
5598
  return this._wrapHeader(Date.now(), !1, !1, !1, null).data;
@@ -5578,7 +5609,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5578
5609
  this._queue.clear(), this._fpsMeter.destroy(), this._datachannel.onmessage = null, this._feedback.clear(), this._datachannel.readyState === "open" && this._datachannel.send(this._stopPacket()), this._destroyed = !0, this._encoder.destroy(), this._debug.debug("ScreenCaptureSender destroyed");
5579
5610
  }
5580
5611
  static isBrowserSupported() {
5581
- return ki.isBrowserSupported() || Oi.isBrowserSupported();
5612
+ return Oi.isBrowserSupported() || Di.isBrowserSupported();
5582
5613
  }
5583
5614
  _onCongestionCallback(e, t, n) {
5584
5615
  this._encoder.setBitrate(e, t, n);
@@ -5591,8 +5622,8 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5591
5622
  (e === void 0 || e < 640) && (e = 640), (t === void 0 || t < 360) && (t = 360);
5592
5623
  let n = e * t / 256;
5593
5624
  return {
5594
- minBitrate: Math.max(qi, Math.min(Ki, Math.round(n * Wi))),
5595
- maxBitrate: Math.round(n * Gi)
5625
+ minBitrate: Math.max(Ki, Math.min(Gi, Math.round(n * Ui))),
5626
+ maxBitrate: Math.round(n * Wi)
5596
5627
  };
5597
5628
  }
5598
5629
  _checkCcFeedback(e) {
@@ -5606,12 +5637,12 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5606
5637
  }
5607
5638
  _sendSharingStat() {
5608
5639
  let e = Date.now();
5609
- if (e - this._lastSharingStat > Ji) {
5640
+ if (e - this._lastSharingStat > qi) {
5610
5641
  let t = this._congestionControl.getStat();
5611
5642
  t !== null && (this._debug.debug(`cc: send stats: ${JSON.stringify(t)}`), this._signaling.reportSharingStat(t)), this._lastSharingStat = e;
5612
5643
  }
5613
5644
  }
5614
- }, $i = 90, ea = 4294967295, ta = class e extends Er {
5645
+ }, Qi = 90, $i = 4294967295, ea = class e extends Er {
5615
5646
  constructor(e, t, n, r = R, i = null, a = null, o = null, s = null) {
5616
5647
  super(e, t, s), h(this, "_producerNotification", null), h(this, "_producerCommand", null), h(this, "_producerScreen", null), h(this, "_consumerScreen", null), h(this, "_asr", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_isOpen", !1), h(this, "_observer", !1), h(this, "_reconnectionPrevented", !1), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_monitorRtpShareInterval", null), h(this, "_statBytes", {}), h(this, "_ssrcMap", {}), h(this, "_ssrcMapUpdated", !1), h(this, "_perfStatReporter", void 0), h(this, "_producerOfferIsProcessing", !1), h(this, "_producerNextOffer", null), h(this, "_producerNextSessionId", null), h(this, "_lastStat", null), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_prevConsumerFastSharingSettings", {}), h(this, "_asrTrack", null), h(this, "_captureSender", null), h(this, "_captureReceiver", null), h(this, "_participantIdRegistry", null), h(this, "_disabledSenders", /* @__PURE__ */ new Set()), h(this, "_rtpReceiversByStreamId", {}), h(this, "_producerSessionId", ""), h(this, "_newAudioShareTrack", null), h(this, "_simulcastInfo", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._codecStatsAggregator = o, this.subscribe(this._signaling, G.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, Kt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, Kt.SOURCE_CHANGED, this._onSourcesChanged.bind(this)), this.subscribe(this._mediaSource, Kt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._createPerfStatsReporter(), this._serverSettings = n, this._debug.debug("ServerTransport: Created");
5617
5648
  }
@@ -5652,10 +5683,10 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5652
5683
  M.simulcast && await this._changeSimulcastInfo(!0, !1);
5653
5684
  }
5654
5685
  _createPerfStatsReporter() {
5655
- this._perfStatReporter?.destroy(), this._perfStatReporter = new oa(this, this._signaling, this._statAggregator, !1, this._debug);
5686
+ this._perfStatReporter?.destroy(), this._perfStatReporter = new aa(this, this._signaling, this._statAggregator, !1, this._debug);
5656
5687
  }
5657
5688
  _closeConnection() {
5658
- this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcastInfo = null, this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(Y.PEER_CONNECTION_CLOSED);
5689
+ this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcastInfo = null, this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(X.PEER_CONNECTION_CLOSED);
5659
5690
  }
5660
5691
  static _closeDataChannel(e) {
5661
5692
  e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
@@ -5713,16 +5744,16 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5713
5744
  this.getState() !== q.OPENED && (this._setState(q.RECONNECTING), this._closeConnection(), this._openConnection(!0));
5714
5745
  }
5715
5746
  _signalActiveParticipants(e) {
5716
- this._triggerEvent(Y.SIGNALLED_ACTIVE_PARTICIPANTS, e);
5747
+ this._triggerEvent(X.SIGNALLED_ACTIVE_PARTICIPANTS, e);
5717
5748
  }
5718
5749
  _signalStalledParticipants(e) {
5719
- this._triggerEvent(Y.SIGNALLED_STALLED_PARTICIPANTS, e);
5750
+ this._triggerEvent(X.SIGNALLED_STALLED_PARTICIPANTS, e);
5720
5751
  }
5721
5752
  _signalSpeakerChanged(e) {
5722
- this._triggerEvent(Y.SIGNALLED_SPEAKER_CHANGED, e);
5753
+ this._triggerEvent(X.SIGNALLED_SPEAKER_CHANGED, e);
5723
5754
  }
5724
5755
  _signalNetworkStatus(e) {
5725
- this._triggerEvent(Y.NETWORK_STATUS, e);
5756
+ this._triggerEvent(X.NETWORK_STATUS, e);
5726
5757
  }
5727
5758
  _updateSSRCMap(e) {
5728
5759
  e && e.sdp.split("\n").forEach((e) => {
@@ -5732,18 +5763,18 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5732
5763
  }
5733
5764
  _createCaptureSender(e) {
5734
5765
  let t = this._mediaSource.mediaSettings;
5735
- !e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new Qi(e, this._consumerScreen, this._signaling, t.isFastScreenSharingEnabled, this._debug, this._logger));
5766
+ !e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new Zi(e, this._consumerScreen, this._signaling, t.isFastScreenSharingEnabled, this._debug, this._logger));
5736
5767
  }
5737
5768
  _removeCaptureSender() {
5738
5769
  this._captureSender?.destroy(), this._captureSender = null;
5739
5770
  }
5740
5771
  _createCaptureReceiver() {
5741
- this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new wi(this._producerScreen, this._participantIdRegistry, (e, t) => {
5742
- this._triggerEvent(Y.REMOTE_STREAM_SECOND, e, t);
5772
+ this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Ci(this._producerScreen, this._participantIdRegistry, (e, t) => {
5773
+ this._triggerEvent(X.REMOTE_STREAM_SECOND, e, t);
5743
5774
  }, (e) => {
5744
- this._triggerEvent(Y.REMOTE_STREAM_SECOND, e, null);
5775
+ this._triggerEvent(X.REMOTE_STREAM_SECOND, e, null);
5745
5776
  }, (e) => {
5746
- this._triggerEvent(Y.SCREEN_SHARING_STAT, e);
5777
+ this._triggerEvent(X.SCREEN_SHARING_STAT, e);
5747
5778
  }, this._statAggregator, this._debug, this._logger));
5748
5779
  }
5749
5780
  _removeCaptureReceiver() {
@@ -5787,7 +5818,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5787
5818
  e.track ? (!M.consumerFastScreenShare || !this._mediaSource.mediaSettings.isFastScreenSharingEnabled) && this._createCaptureSender(e.track) : this._removeCaptureSender();
5788
5819
  }
5789
5820
  _setState(e) {
5790
- this._state !== e && (this._state = e, this._triggerEvent(Y.STATE_CHANGED, e));
5821
+ this._state !== e && (this._state = e, this._triggerEvent(X.STATE_CHANGED, e));
5791
5822
  }
5792
5823
  _startStatInterval() {
5793
5824
  if (this._statInterval) return;
@@ -5827,7 +5858,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5827
5858
  return this._lastStat = e, e;
5828
5859
  }
5829
5860
  _reportStats(e) {
5830
- this._triggerEvent(Y.REMOTE_DATA_STATS, {
5861
+ this._triggerEvent(X.REMOTE_DATA_STATS, {
5831
5862
  inbound: {
5832
5863
  topology: J.SERVER,
5833
5864
  transport: e.transport,
@@ -5851,7 +5882,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5851
5882
  let n = Br.AUDIO_MIX, r = this._statBytes[n], i = !1;
5852
5883
  if (r) {
5853
5884
  let e = t.bytesReceived - r.bytesReceived;
5854
- e >= 0 && e <= 5 && (i = !0), r.stalled !== i && this._triggerEvent(Y.AUDIO_MIX_STALL, i);
5885
+ e >= 0 && e <= 5 && (i = !0), r.stalled !== i && this._triggerEvent(X.AUDIO_MIX_STALL, i);
5855
5886
  }
5856
5887
  this._statBytes[n] = {
5857
5888
  bytesReceived: t.bytesReceived,
@@ -5860,7 +5891,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
5860
5891
  }
5861
5892
  _allocateConsumer() {
5862
5893
  if (!this._signaling.ready) return;
5863
- let e = fa.get();
5894
+ let e = da.get();
5864
5895
  !M.videoTracksCount && !this._observer && this._debug.warn("Setting videoTracksCount to 0 is deprecated"), this._signaling.allocateConsumer(null, e);
5865
5896
  }
5866
5897
  async _processOffer(e, t) {
@@ -6000,7 +6031,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
6000
6031
  }
6001
6032
  }
6002
6033
  _onAsrTranscription(e) {
6003
- this._triggerEvent(Y.ASR_TRANSCRIPTION, e);
6034
+ this._triggerEvent(X.ASR_TRANSCRIPTION, e);
6004
6035
  }
6005
6036
  async _onProducerUpdated(e) {
6006
6037
  this._producerSessionId && this._producerSessionId !== e.sessionId && this._reconnect(), M.breakVideoPayloadTypes && (this._debug.log("test mode enabled, video switched off"), this._signaling.requestTestMode("breakVideoPayloadTypes", null)), this._producerSessionId = e.sessionId, await this._acceptProducer(e.description, e.sessionId);
@@ -6009,8 +6040,8 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
6009
6040
  this._debug.debug("[single] remote track (added)", { track: t.track });
6010
6041
  let n = t.streams[0];
6011
6042
  n ? (n.onremovetrack || (n.onremovetrack = (e) => {
6012
- this._triggerEvent(Y.REMOTE_TRACK_REMOVED, n.id, n, e.track);
6013
- }), n.getTracks().find((e) => e.id === t.track.id) || n.addTrack(t.track), this._rtpReceiversByStreamId[n.id] = t.receiver, this._triggerEvent(Y.REMOTE_TRACK_ADDED, n.id, n, t.track)) : this._debug.error("[single] unable to get media stream from track event");
6043
+ this._triggerEvent(X.REMOTE_TRACK_REMOVED, n.id, n, e.track);
6044
+ }), n.getTracks().find((e) => e.id === t.track.id) || n.addTrack(t.track), this._rtpReceiversByStreamId[n.id] = t.receiver, this._triggerEvent(X.REMOTE_TRACK_ADDED, n.id, n, t.track)) : this._debug.error("[single] unable to get media stream from track event");
6014
6045
  }
6015
6046
  _onSignalingStateChange(e, t) {
6016
6047
  this._debug.debug("[single] signaling state changed", { state: e.signalingState }, t);
@@ -6064,7 +6095,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
6064
6095
  if (!r || !r.length) return this._debug.log(`Cannot get stream waiting time, ${e} receiver has no synchronization sources`), 0;
6065
6096
  let i = r[0].rtpTimestamp;
6066
6097
  if (!Number.isInteger(i)) return this._logger?.log(S.PAT_WAITING_TIME_ERROR, "timestampNotInteger"), this._debug.error(`Cannot get stream waiting time, ${e} receiver's RTP timestamp is not an integer: ${i}`), 0;
6067
- let a = t - i & ea, o = Math.ceil(a / $i);
6098
+ let a = t - i & $i, o = Math.ceil(a / Qi);
6068
6099
  return Math.min(100, Math.max(0, o));
6069
6100
  }
6070
6101
  async _changeSimulcastInfo(e, t) {
@@ -6122,9 +6153,9 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
6122
6153
  _stopMonitorRtpShareInterval() {
6123
6154
  this._monitorRtpShareInterval && (window.clearTimeout(this._monitorRtpShareInterval), this._monitorRtpShareInterval = null);
6124
6155
  }
6125
- }, Y = /* @__PURE__ */ function(e) {
6156
+ }, X = /* @__PURE__ */ function(e) {
6126
6157
  return e.REMOTE_TRACK_ADDED = "REMOTE_TRACK_ADDED", e.REMOTE_TRACK_REMOVED = "REMOTE_TRACK_REMOVED", e.REMOTE_STREAM_SECOND = "REMOTE_STREAM_SECOND", e.AUDIO_MIX_STALL = "AUDIO_MIX_STALL", e.REMOTE_DATA_STATS = "REMOTE_DATA_STATS", e.STATE_CHANGED = "STATE_CHANGED", e.LOCAL_STATE_CHANGED = "LOCAL_STATE_CHANGED", e.SIGNALLED_ACTIVE_PARTICIPANTS = "SIGNALLED_ACTIVE_PARTICIPANTS", e.SIGNALLED_SPEAKER_CHANGED = "SIGNALLED_SPEAKER_CHANGED", e.SIGNALLED_STALLED_PARTICIPANTS = "SIGNALLED_STALLED_PARTICIPANTS", e.TOPOLOGY_CHANGED = "TOPOLOGY_CHANGED", e.NETWORK_STATUS = "NETWORK_STATUS", e.PEER_CONNECTION_CLOSED = "PEER_CONNECTION_CLOSED", e.ASR_TRANSCRIPTION = "ASR_TRANSCRIPTION", e.ANIMOJI_STREAM = "ANIMOJI_STREAM", e.ANIMOJI_ERROR = "ANIMOJI_ERROR", e.SCREEN_SHARING_STAT = "SCREEN_SHARING_STAT", e;
6127
- }({}), na = class extends y {
6158
+ }({}), ta = class extends y {
6128
6159
  constructor(e, t, n, r, i = R, a = null, o = null, s = null, c = null) {
6129
6160
  super(), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_topology", void 0), h(this, "_allocated", []), h(this, "_opened", []), h(this, "_directTransport", null), h(this, "_serverTransport", null), h(this, "_serverSettings", void 0), h(this, "_dtListeners", []), h(this, "_stListeners", []), h(this, "_states", {}), h(this, "_localState", q.IDLE), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_onFirstMediaSent", void 0), h(this, "_firstMediaSentProbeStopped", !1), this._signaling = t, this._mediaSource = n, this._topology = e, this._serverSettings = r, this._debug = i, this._logger = a, this._statAggregator = o, this._codecStatsAggregator = s, this._onFirstMediaSent = c, this.subscribe(this._signaling, G.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, Kt.ANIMOJI_STATUS, this._onAnimojiStatus.bind(this)), this.subscribe(this._mediaSource, Kt.SOURCE_CHANGED, this._onSourceChanged.bind(this)), this._createAnimojiTransport(), e === J.SERVER && (this._serverTransport = this._createServerTransport());
6130
6161
  }
@@ -6247,7 +6278,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
6247
6278
  return this._dtListeners.length > 0 && this._debug.warn(`The list of direct listeners for the participant [${e}] is not empty`), this._dtListeners = [], this._dtListeners.push(n.addEventListener("REMOTE_TRACK_ADDED", this._onRemoteTrackAdded.bind(this, e)), n.addEventListener("REMOTE_TRACK_REMOVED", this._onRemoteTrackRemoved.bind(this, e)), n.addEventListener("REMOTE_DATA_STATS", this._onRemoteDataStats.bind(this)), n.addEventListener("STATE_CHANGED", this._onDirectTransportChanged.bind(this)), n.addEventListener("NETWORK_STATUS", this._onTransportNetworkStatus.bind(this)), n.addEventListener("PEER_CONNECTION_CLOSED", this._onPeerConnectionClosed.bind(this, J.DIRECT))), this._animojiReceiver && this._animojiSender && n.setAnimojiTransport(this._animojiReceiver, this._animojiSender), n;
6248
6279
  }
6249
6280
  _createServerTransport() {
6250
- let e = new ta(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6281
+ let e = new ea(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6251
6282
  return this._stListeners.length > 0 && this._debug.warn("The list of server transport listeners is not empty"), this._stListeners = [], this._stListeners.push(e.addEventListener("REMOTE_TRACK_ADDED", this._onRemoteTrackAdded.bind(this)), e.addEventListener("REMOTE_TRACK_REMOVED", this._onRemoteTrackRemoved.bind(this)), e.addEventListener("AUDIO_MIX_STALL", this._onServerAudioMixStall.bind(this)), e.addEventListener("REMOTE_DATA_STATS", this._onRemoteDataStats.bind(this)), e.addEventListener("STATE_CHANGED", this._onServerTransportChanged.bind(this)), e.addEventListener("SIGNALLED_ACTIVE_PARTICIPANTS", this._onTransportActiveParticipants.bind(this)), e.addEventListener("SIGNALLED_SPEAKER_CHANGED", this._onTransportSpeakerChanged.bind(this)), e.addEventListener("SIGNALLED_STALLED_PARTICIPANTS", this._onTransportStalledParticipants.bind(this)), e.addEventListener("NETWORK_STATUS", this._onTransportNetworkStatus.bind(this)), e.addEventListener("REMOTE_STREAM_SECOND", this._onRemoteStreamSecond.bind(this)), e.addEventListener("PEER_CONNECTION_CLOSED", this._onPeerConnectionClosed.bind(this, J.SERVER)), e.addEventListener("ASR_TRANSCRIPTION", this._onAsrTranscription.bind(this))), this._animojiReceiver && this._animojiSender && e.setAnimojiTransport(this._animojiReceiver, this._animojiSender), e;
6252
6283
  }
6253
6284
  _releaseDirectTransport() {
@@ -6334,20 +6365,20 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
6334
6365
  getStreamWaitingTimeMs(e, t) {
6335
6366
  return this._topology === J.SERVER ? this._serverTransport ? this._serverTransport.getStreamWaitingTimeMs(e, t) : (this._logger?.log(S.PAT_WAITING_TIME_ERROR, "noTransport"), this._debug.error("Cannot get stream waiting time, server transport is not initialized"), 0) : (this._logger?.log(S.PAT_WAITING_TIME_ERROR, "wrongTopology"), this._debug.error(`Cannot get stream waiting time, incorrect topology: ${this._topology}`), 0);
6336
6367
  }
6337
- }, ra = "videochat-epi", ia = 5e3, aa = 500, oa = class extends y {
6368
+ }, na = "videochat-epi", ra = 5e3, ia = 500, aa = class extends y {
6338
6369
  constructor(e, t, n = null, r = !1, i = R) {
6339
6370
  super(), h(this, "_previousPerfStatReportTimestamp", 0), h(this, "_previousNetworkStatReportTimestamp", Date.now()), h(this, "_previousCallStatReportTimestamp", Date.now()), h(this, "_previousCallStatReport", null), h(this, "_screenShareStats", []), h(this, "_signaling", void 0), h(this, "_directTopology", void 0), h(this, "_debug", void 0), h(this, "_statAggregator", void 0), h(this, "_handleScreenSharingStat", (e) => {
6340
6371
  this._screenShareStats.push(e);
6341
6372
  }), h(this, "_handleTransportStateChanged", (e) => {
6342
6373
  (this._directTopology && e === q.CONNECTED || !this._directTopology && e === q.OPENED) && (this._previousNetworkStatReportTimestamp = Date.now(), this._previousCallStatReportTimestamp = Date.now());
6343
- }), this._signaling = t, this._directTopology = r, this._debug = i, this._statAggregator = n, this.subscribe(e, Y.REMOTE_DATA_STATS, this._handleStats.bind(this)), this.subscribe(e, Y.SCREEN_SHARING_STAT, this._handleScreenSharingStat.bind(this)), this.subscribe(e, Y.STATE_CHANGED, this._handleTransportStateChanged.bind(this));
6374
+ }), this._signaling = t, this._directTopology = r, this._debug = i, this._statAggregator = n, this.subscribe(e, X.REMOTE_DATA_STATS, this._handleStats.bind(this)), this.subscribe(e, X.SCREEN_SHARING_STAT, this._handleScreenSharingStat.bind(this)), this.subscribe(e, X.STATE_CHANGED, this._handleTransportStateChanged.bind(this));
6344
6375
  }
6345
6376
  destroy() {
6346
6377
  this.unsubscribe();
6347
6378
  }
6348
6379
  static getEstimatedPerformanceIndex() {
6349
6380
  try {
6350
- let e = parseInt(localStorage.getItem(ra) || "", 10);
6381
+ let e = parseInt(localStorage.getItem(na) || "", 10);
6351
6382
  return isNaN(e) ? 0 : e;
6352
6383
  } catch {
6353
6384
  return 0;
@@ -6356,9 +6387,9 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
6356
6387
  async _handleStats(e) {
6357
6388
  if (!e.inbound || !e.inbound.rtps) return;
6358
6389
  let t = Date.now();
6359
- !this._directTopology && M.perfStatReportEnabled && this._previousPerfStatReportTimestamp + ia <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6390
+ !this._directTopology && M.perfStatReportEnabled && this._previousPerfStatReportTimestamp + ra <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6360
6391
  let n = e.outbound.transport.local?.protocol === "tcp";
6361
- !this._directTopology && n && this._previousNetworkStatReportTimestamp + aa <= t && (await this.reportNetworkStats(e), this._previousNetworkStatReportTimestamp = t), M.callStatReportEnabled && this._previousCallStatReportTimestamp + M.statisticsInterval <= t && (this._reportCallStats(e), this._previousCallStatReportTimestamp = t);
6392
+ !this._directTopology && n && this._previousNetworkStatReportTimestamp + ia <= t && (await this.reportNetworkStats(e), this._previousNetworkStatReportTimestamp = t), M.callStatReportEnabled && this._previousCallStatReportTimestamp + M.statisticsInterval <= t && (this._reportCallStats(e), this._previousCallStatReportTimestamp = t);
6362
6393
  }
6363
6394
  async reportPerfStats(e) {
6364
6395
  let t = e.inbound.rtps.reduce((e, t) => (t.kind === "video" && (e.framesDecoded += t.framesDecoded || 0, e.framesReceived += t.framesReceived || 0), e), {
@@ -6367,7 +6398,7 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
6367
6398
  });
6368
6399
  if (t.framesDecoded) try {
6369
6400
  let e = await this._signaling.reportPerfStat(t);
6370
- localStorage.setItem(ra, e.estimatedPerformanceIndex);
6401
+ localStorage.setItem(na, e.estimatedPerformanceIndex);
6371
6402
  } catch {}
6372
6403
  }
6373
6404
  async reportNetworkStats(e) {
@@ -6411,11 +6442,11 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
6411
6442
  rtt: Math.round(e.inbound.transport.currentRoundTripTime * 1e3),
6412
6443
  ss_freeze_count: 0,
6413
6444
  ss_total_freezes_duration: 0,
6414
- local_address: ca(e.inbound.transport.local),
6445
+ local_address: sa(e.inbound.transport.local),
6415
6446
  local_connection_type: e.inbound.transport.local?.type,
6416
6447
  network_type: e.inbound.transport.local?.networkType,
6417
6448
  transport: e.inbound.transport.local?.protocol,
6418
- remote_address: ca(e.inbound.transport.remote),
6449
+ remote_address: sa(e.inbound.transport.remote),
6419
6450
  remote_connection_type: e.inbound.transport.remote?.type
6420
6451
  };
6421
6452
  this._previousCallStatReport || (this._previousCallStatReport = Object.assign({}, t));
@@ -6436,35 +6467,35 @@ var vi = 2 ** 15 - 1, yi = 1, bi = 5, xi = 5, Si = class e {
6436
6467
  frames_dropped: Math.max(0, t.frames_dropped - this._previousCallStatReport.frames_dropped),
6437
6468
  rtt: Math.max(0, t.rtt)
6438
6469
  };
6439
- if (M.simulcast && (i.is_simulcast = !0), navigator.hardwareConcurrency && (i.cpu_hardware_concurrency = navigator.hardwareConcurrency), n && !la(t.jitter_video) && (i.jitter_video = Math.round(t.jitter_video)), r && !la(t.jitter_audio) && (i.jitter_audio = Math.round(t.jitter_audio)), n && !la(t.interframe_delay_variance) && (i.interframe_delay_variance = t.interframe_delay_variance), t.freeze_count && t.total_freezes_duration && (i.freeze_count = t.freeze_count, i.total_freezes_duration = Math.round(t.total_freezes_duration * 1e3)), t.ss_freeze_count && t.ss_total_freezes_duration && (i.ss_freeze_count = t.ss_freeze_count, i.ss_total_freezes_duration = t.ss_total_freezes_duration), r && !la(t.total_audio_samples_received)) {
6470
+ if (M.simulcast && (i.is_simulcast = !0), navigator.hardwareConcurrency && (i.cpu_hardware_concurrency = navigator.hardwareConcurrency), n && !ca(t.jitter_video) && (i.jitter_video = Math.round(t.jitter_video)), r && !ca(t.jitter_audio) && (i.jitter_audio = Math.round(t.jitter_audio)), n && !ca(t.interframe_delay_variance) && (i.interframe_delay_variance = t.interframe_delay_variance), t.freeze_count && t.total_freezes_duration && (i.freeze_count = t.freeze_count, i.total_freezes_duration = Math.round(t.total_freezes_duration * 1e3)), t.ss_freeze_count && t.ss_total_freezes_duration && (i.ss_freeze_count = t.ss_freeze_count, i.ss_total_freezes_duration = t.ss_total_freezes_duration), r && !ca(t.total_audio_samples_received)) {
6440
6471
  let e = Math.max(0, t.total_audio_samples_received - this._previousCallStatReport.total_audio_samples_received), n = Math.max(0, t.inserted_audio_samples_for_deceleration - this._previousCallStatReport.inserted_audio_samples_for_deceleration), r = Math.max(0, t.removed_audio_samples_for_acceleration - this._previousCallStatReport.removed_audio_samples_for_acceleration), a = Math.max(0, t.concealed_audio_samples - this._previousCallStatReport.concealed_audio_samples), o = Math.max(0, t.silent_concealed_audio_samples - this._previousCallStatReport.silent_concealed_audio_samples), s = Math.max(0, t.audio_concealment_events - this._previousCallStatReport.audio_concealment_events);
6441
- i.inserted_audio_samples_for_deceleration = ua(n / e * 1e3), i.removed_audio_samples_for_acceleration = ua(r / e * 1e3), i.concealed_audio_samples = ua(a / e * 1e3), i.concealed_silent_audio_samples = ua(o / e * 1e3), i.concealment_audio_avg_size = ua(a / s), i.total_audio_energy = t.total_audio_energy;
6472
+ i.inserted_audio_samples_for_deceleration = la(n / e * 1e3), i.removed_audio_samples_for_acceleration = la(r / e * 1e3), i.concealed_audio_samples = la(a / e * 1e3), i.concealed_silent_audio_samples = la(o / e * 1e3), i.concealment_audio_avg_size = la(a / s), i.total_audio_energy = t.total_audio_energy;
6442
6473
  }
6443
- sa(t, "local_address", "local_connection_type", "network_type", "transport") && (i.local_address = t.local_address, i.local_connection_type = t.local_connection_type, i.network_type = t.network_type, i.transport = t.transport), sa(t, "remote_address", "remote_connection_type") && (i.remote_address = t.remote_address, i.remote_connection_type = t.remote_connection_type);
6474
+ oa(t, "local_address", "local_connection_type", "network_type", "transport") && (i.local_address = t.local_address, i.local_connection_type = t.local_connection_type, i.network_type = t.network_type, i.transport = t.transport), oa(t, "remote_address", "remote_connection_type") && (i.remote_address = t.remote_address, i.remote_connection_type = t.remote_connection_type);
6444
6475
  let a = Math.max(0, t.packets_sent_video - this._previousCallStatReport.packets_sent_video), o = Math.max(0, t.packets_sent_audio - this._previousCallStatReport.packets_sent_audio);
6445
- a > 0 && (i.video_loss = ua(Math.max(0, t.packets_lost_video - this._previousCallStatReport.packets_lost_video) / a * 100)), o > 0 && (i.audio_loss = ua(Math.max(0, t.packets_lost_audio - this._previousCallStatReport.packets_lost_audio) / o * 100)), this._statAggregator?.logCallStat(i), M.enableLogPerfStatReport && this._debug.log("Sent call stats", i), this._previousCallStatReport = t;
6476
+ a > 0 && (i.video_loss = la(Math.max(0, t.packets_lost_video - this._previousCallStatReport.packets_lost_video) / a * 100)), o > 0 && (i.audio_loss = la(Math.max(0, t.packets_lost_audio - this._previousCallStatReport.packets_lost_audio) / o * 100)), this._statAggregator?.logCallStat(i), M.enableLogPerfStatReport && this._debug.log("Sent call stats", i), this._previousCallStatReport = t;
6446
6477
  }
6447
6478
  };
6448
- function sa(e, ...t) {
6479
+ function oa(e, ...t) {
6449
6480
  for (let n of t) if (!Object.hasOwn(e, n) || e[n] === void 0) return !1;
6450
6481
  return !0;
6451
6482
  }
6452
- function ca(e, t = !1) {
6483
+ function sa(e, t = !1) {
6453
6484
  if (e?.address) return e.address + (t ? `:${e.port}` : "");
6454
6485
  }
6455
- function la(e) {
6486
+ function ca(e) {
6456
6487
  return e === void 0;
6457
6488
  }
6458
- function ua(e) {
6489
+ function la(e) {
6459
6490
  return Number.isNaN(e) ? 0 : e;
6460
6491
  }
6461
6492
  //#endregion
6462
6493
  //#region src/static/Capabilities.ts
6463
- var da;
6494
+ var ua;
6464
6495
  (function(e) {
6465
6496
  function t() {
6466
6497
  return {
6467
- estimatedPerformanceIndex: oa.getEstimatedPerformanceIndex(),
6498
+ estimatedPerformanceIndex: aa.getEstimatedPerformanceIndex(),
6468
6499
  audioMix: !0,
6469
6500
  consumerUpdate: !0,
6470
6501
  producerNotificationDataChannelVersion: 8,
@@ -6489,8 +6520,8 @@ var da;
6489
6520
  };
6490
6521
  }
6491
6522
  e.get = t;
6492
- })(da || (da = {}));
6493
- var fa = da, pa = {
6523
+ })(ua || (ua = {}));
6524
+ var da = ua, fa = {
6494
6525
  producerScreenTrack: () => !0,
6495
6526
  videoTracksCount: () => M.videoTracksCount > 0,
6496
6527
  waitingHall: () => !0,
@@ -6510,28 +6541,28 @@ var fa = da, pa = {
6510
6541
  p2pRelay: () => !1,
6511
6542
  waitForAdmin: () => M.waitForAdminInGroupCalls,
6512
6543
  hold: () => M.hold
6513
- }, ma = class {
6544
+ }, pa = class {
6514
6545
  static getFlags() {
6515
- let e = Object.values(pa), t = 0;
6546
+ let e = Object.values(fa), t = 0;
6516
6547
  for (let n = 0; n < e.length; n++) e[n]() && (t |= 1 << n);
6517
6548
  return t.toString(16).toUpperCase();
6518
6549
  }
6519
6550
  static parseCapabilities(e) {
6520
6551
  let t = parseInt(e || "0", 16);
6521
- return Object.keys(pa).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6552
+ return Object.keys(fa).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6522
6553
  }
6523
- }, ha = 63n, ga = 16383n, _a = 1073741823, va = 4611686018427387903n, ya = class {
6554
+ }, ma = 63n, ha = 16383n, ga = 1073741823, _a = 4611686018427387903n, va = class {
6524
6555
  encode(e) {
6525
6556
  let t = typeof e == "number" ? BigInt(e) : e;
6526
- if (t <= ha) return new Uint8Array([Number(t)]);
6527
- if (t <= ga) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
6528
- if (t <= BigInt(_a)) return new Uint8Array([
6557
+ if (t <= ma) return new Uint8Array([Number(t)]);
6558
+ if (t <= ha) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
6559
+ if (t <= BigInt(ga)) return new Uint8Array([
6529
6560
  128 | Number(t >> 24n),
6530
6561
  Number(t >> 16n & 255n),
6531
6562
  Number(t >> 8n & 255n),
6532
6563
  Number(t & 255n)
6533
6564
  ]);
6534
- if (t <= va) return new Uint8Array([
6565
+ if (t <= _a) return new Uint8Array([
6535
6566
  192 | Number(t >> 56n),
6536
6567
  Number(t >> 48n & 255n),
6537
6568
  Number(t >> 40n & 255n),
@@ -6543,7 +6574,7 @@ var fa = da, pa = {
6543
6574
  ]);
6544
6575
  throw RangeError("Number is too large to encode using varint");
6545
6576
  }
6546
- }, ba = class {
6577
+ }, ya = class {
6547
6578
  decode(e) {
6548
6579
  let t = this.getNumBytesForLengthInteger(e);
6549
6580
  if (t < 0) throw Error("Invalid length prefix");
@@ -6569,9 +6600,9 @@ var fa = da, pa = {
6569
6600
  let t = e[0] & 192;
6570
6601
  return t === 0 ? 1 : t === 64 ? 2 : t === 128 ? 4 : t === 192 ? 8 : -1;
6571
6602
  }
6572
- }, xa = class {
6603
+ }, ba = class {
6573
6604
  constructor(e) {
6574
- h(this, "encoder", void 0), h(this, "compression", void 0), h(this, "lengthEncoder", void 0), this.encoder = new TextEncoder(), this.lengthEncoder = new ya(), this.compression = e ?? null;
6605
+ h(this, "encoder", void 0), h(this, "compression", void 0), h(this, "lengthEncoder", void 0), this.encoder = new TextEncoder(), this.lengthEncoder = new va(), this.compression = e ?? null;
6575
6606
  }
6576
6607
  encode(e) {
6577
6608
  let t = this.encoder.encode(e);
@@ -6588,9 +6619,9 @@ var fa = da, pa = {
6588
6619
  default: return e;
6589
6620
  }
6590
6621
  }
6591
- }, Sa = class {
6622
+ }, xa = class {
6592
6623
  constructor(e) {
6593
- h(this, "decoder", void 0), h(this, "compression", void 0), h(this, "lengthDecoder", void 0), h(this, "buffer", void 0), h(this, "expectedLength", void 0), h(this, "offset", void 0), h(this, "lengthPrefixLength", void 0), this.decoder = new TextDecoder(), this.lengthDecoder = new ba(), this.compression = e ?? null, this.buffer = new Uint8Array(), this.expectedLength = null, this.offset = 0;
6624
+ h(this, "decoder", void 0), h(this, "compression", void 0), h(this, "lengthDecoder", void 0), h(this, "buffer", void 0), h(this, "expectedLength", void 0), h(this, "offset", void 0), h(this, "lengthPrefixLength", void 0), this.decoder = new TextDecoder(), this.lengthDecoder = new ya(), this.compression = e ?? null, this.buffer = new Uint8Array(), this.expectedLength = null, this.offset = 0;
6594
6625
  }
6595
6626
  decode(e) {
6596
6627
  let t = [];
@@ -6620,9 +6651,9 @@ var fa = da, pa = {
6620
6651
  default: return e;
6621
6652
  }
6622
6653
  }
6623
- }, Ca = class {
6654
+ }, Sa = class {
6624
6655
  constructor(e, t = {}, n = R) {
6625
- h(this, "webTransport", void 0), h(this, "stream", null), h(this, "writer", null), h(this, "reader", null), h(this, "url", void 0), h(this, "options", void 0), h(this, "compression", void 0), h(this, "closeRequested", null), h(this, "closeEventEmitted", !1), h(this, "encoder", void 0), h(this, "decoder", void 0), h(this, "_debug", void 0), h(this, "onopen", null), h(this, "onmessage", null), h(this, "onerror", null), h(this, "onclose", null), h(this, "readyState", WebSocket.CONNECTING), this._debug = n, this.url = e, this.options = t, this.readyState = WebSocket.CONNECTING, this.compression = this.getCompressionTypeFromUrl(e), this.encoder = new xa(this.compression), this.decoder = new Sa(this.compression), this.connect();
6656
+ h(this, "webTransport", void 0), h(this, "stream", null), h(this, "writer", null), h(this, "reader", null), h(this, "url", void 0), h(this, "options", void 0), h(this, "compression", void 0), h(this, "closeRequested", null), h(this, "closeEventEmitted", !1), h(this, "encoder", void 0), h(this, "decoder", void 0), h(this, "_debug", void 0), h(this, "onopen", null), h(this, "onmessage", null), h(this, "onerror", null), h(this, "onclose", null), h(this, "readyState", WebSocket.CONNECTING), this._debug = n, this.url = e, this.options = t, this.readyState = WebSocket.CONNECTING, this.compression = this.getCompressionTypeFromUrl(e), this.encoder = new ba(this.compression), this.decoder = new xa(this.compression), this.connect();
6626
6657
  }
6627
6658
  getCompressionTypeFromUrl(e) {
6628
6659
  try {
@@ -6740,9 +6771,9 @@ var fa = da, pa = {
6740
6771
  static isBrowserSupported() {
6741
6772
  return !(!("WebTransport" in window && typeof WebTransport == "function") || T.browserName() === "Safari");
6742
6773
  }
6743
- }, wa = /* @__PURE__ */ function(e) {
6774
+ }, Ca = /* @__PURE__ */ function(e) {
6744
6775
  return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.ABORTED = "ABORTED", e;
6745
- }({}), Ta = class {
6776
+ }({}), wa = class {
6746
6777
  constructor(e = R, t) {
6747
6778
  h(this, "handlers", void 0), h(this, "socket", null), h(this, "endpoint", ""), h(this, "wtEndpoint", null), h(this, "peerId", null), h(this, "lastStamp", 0), h(this, "connectionType", void 0), h(this, "reconnectCount", 0), h(this, "reconnectTimer", 0), h(this, "doctorTimer", 0), h(this, "forceWebSocket", !1), h(this, "abortSignal", void 0), h(this, "manualClose", !1), h(this, "currentType", fr.WEBSOCKET), h(this, "_debug", void 0), this.handlers = t, this._debug = e;
6748
6779
  }
@@ -6792,7 +6823,7 @@ var fa = da, pa = {
6792
6823
  return;
6793
6824
  }
6794
6825
  let e = this._buildUrl(this.wtEndpoint, !0);
6795
- this.currentType = fr.WEBTRANSPORT, this.socket = new Ca(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
6826
+ this.currentType = fr.WEBTRANSPORT, this.socket = new Sa(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
6796
6827
  }
6797
6828
  _connectWebSocket() {
6798
6829
  if (!this.endpoint) {
@@ -6811,10 +6842,10 @@ var fa = da, pa = {
6811
6842
  }
6812
6843
  _buildUrl(e, t) {
6813
6844
  let n = new URL(e), r = n.searchParams;
6814
- 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", ma.getFlags()), r.set("clientType", M.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === dr.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();
6845
+ 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", pa.getFlags()), r.set("clientType", M.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === dr.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();
6815
6846
  }
6816
6847
  _canUseWebTransport() {
6817
- return !this.forceWebSocket && Ca.isBrowserSupported() && this.wtEndpoint !== null && M.webtransport;
6848
+ return !this.forceWebSocket && Sa.isBrowserSupported() && this.wtEndpoint !== null && M.webtransport;
6818
6849
  }
6819
6850
  _onOpen() {
6820
6851
  this._startDoctor(), this.handlers.onOpen();
@@ -6866,11 +6897,11 @@ var fa = da, pa = {
6866
6897
  _stopDoctor() {
6867
6898
  window.clearTimeout(this.doctorTimer), this.doctorTimer = 0;
6868
6899
  }
6869
- }, Ea = "open", Da = 10, Oa = [
6900
+ }, Ta = "open", Ea = 10, Da = [
6870
6901
  "service-unavailable",
6871
6902
  "conversation-ended",
6872
6903
  "invalid-token"
6873
- ], ka = class e extends yn {
6904
+ ], Oa = class e extends yn {
6874
6905
  static get WAIT_CONNECTION_DELAY() {
6875
6906
  return M.waitConnectionDelay;
6876
6907
  }
@@ -6881,7 +6912,7 @@ var fa = da, pa = {
6881
6912
  return this.transport.readyState !== null;
6882
6913
  }
6883
6914
  constructor(e = R, t = null, n = null, r = null, i = null) {
6884
- super(), h(this, "transport", void 0), h(this, "sequence", 1), h(this, "lastStamp", 0), h(this, "websocketCommandsQueue", []), h(this, "datachannelCommandsQueue", []), h(this, "incomingCache", []), h(this, "responseHandlers", {}), h(this, "connectionType", void 0), h(this, "conversationResolve", null), h(this, "conversationReject", null), h(this, "connected", !1), h(this, "listenersReady", !1), h(this, "peerId", null), h(this, "conversationId", null), h(this, "connectionMessageWaitTimer", 0), h(this, "participantIdRegistry", null), h(this, "producerNotificationDataChannel", null), h(this, "producerCommandDataChannel", null), h(this, "producerCommandDataChannelEnabled", !1), h(this, "producerCommandSerializationService", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_statPings", void 0), h(this, "_statSignalingCommands", void 0), this._debug = e, this._logger = t, this._statAggregator = n, this._statPings = r, this._statSignalingCommands = i, this.producerCommandSerializationService = new Kn(e), this.transport = new Ta(e, {
6915
+ super(), h(this, "transport", void 0), h(this, "sequence", 1), h(this, "lastStamp", 0), h(this, "websocketCommandsQueue", []), h(this, "datachannelCommandsQueue", []), h(this, "incomingCache", []), h(this, "responseHandlers", {}), h(this, "connectionType", void 0), h(this, "conversationResolve", null), h(this, "conversationReject", null), h(this, "connected", !1), h(this, "listenersReady", !1), h(this, "peerId", null), h(this, "conversationId", null), h(this, "connectionMessageWaitTimer", 0), h(this, "participantIdRegistry", null), h(this, "producerNotificationDataChannel", null), h(this, "producerCommandDataChannel", null), h(this, "producerCommandDataChannelEnabled", !1), h(this, "producerCommandSerializationService", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_statPings", void 0), h(this, "_statSignalingCommands", void 0), this._debug = e, this._logger = t, this._statAggregator = n, this._statPings = r, this._statSignalingCommands = i, this.producerCommandSerializationService = new Kn(e), this.transport = new wa(e, {
6885
6916
  onOpen: this._onOpen.bind(this),
6886
6917
  onMessage: this._onMessage.bind(this),
6887
6918
  onError: this._onError.bind(this),
@@ -6963,20 +6994,20 @@ var fa = da, pa = {
6963
6994
  return this._send(B.TRANSMIT_DATA, {
6964
6995
  participantId: e,
6965
6996
  data: r
6966
- }, !0, Da);
6997
+ }, !0, Ea);
6967
6998
  }
6968
6999
  async acceptCall(e) {
6969
7000
  return this._send(B.ACCEPT_CALL, { mediaSettings: e });
6970
7001
  }
6971
7002
  async changeMediaSettings(e) {
6972
- return this._send(B.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, Da);
7003
+ return this._send(B.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, Ea);
6973
7004
  }
6974
7005
  async changeParticipantState(e, t) {
6975
7006
  let n = { participantState: { state: e } };
6976
7007
  return t && (n.participantId = t), this._sendRaw(B.CHANGE_PARTICIPANT_STATE, n);
6977
7008
  }
6978
7009
  async hold(e) {
6979
- let t = fa.get();
7010
+ let t = da.get();
6980
7011
  return this._send(B.HOLD, {
6981
7012
  hold: e,
6982
7013
  capabilities: e ? void 0 : t
@@ -7205,7 +7236,7 @@ var fa = da, pa = {
7205
7236
  }
7206
7237
  async _sendRaw(e, t = {}, n = !0, r = 0) {
7207
7238
  let i = (t) => {
7208
- if (this._isDataChannelCommand(e)) this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === Ea && this._handleCommandsQueue(this.datachannelCommandsQueue);
7239
+ if (this._isDataChannelCommand(e)) this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === Ta && this._handleCommandsQueue(this.datachannelCommandsQueue);
7209
7240
  else {
7210
7241
  if (this.transport.readyState === null) {
7211
7242
  this._logger?.log(S.SOCKET_ACTION, "not_opened"), this._debug.warn("[signaling] socket is not opened"), t.reject(/* @__PURE__ */ Error(`Socket not opened [${e}]`), !0);
@@ -7273,7 +7304,7 @@ var fa = da, pa = {
7273
7304
  }
7274
7305
  _handleErrorMessage(e) {
7275
7306
  this._logger?.log(S.SOCKET_ACTION, `error-${e.error}`);
7276
- let t = e.error ? Oa.includes(e.error) : !1;
7307
+ let t = e.error ? Da.includes(e.error) : !1;
7277
7308
  switch (this._debug.debug(`[signaling] error message [${e.sequence}]`, e), e.sequence && this.responseHandlers[e.sequence] && this._handleCommandResponse(!1, e), e.error) {
7278
7309
  case "service-unavailable":
7279
7310
  let n = new O(D.SERVICE_UNAVAILABLE, {
@@ -7377,7 +7408,7 @@ var fa = da, pa = {
7377
7408
  for (; e.length > 0;) {
7378
7409
  let t = e.shift();
7379
7410
  if (this._debug.debug(`[signaling] command send [${t.sequence}]`, `'${t.name}'`, t.params), this._isDataChannelCommand(t.name)) {
7380
- if (this.producerCommandDataChannel?.readyState !== Ea) {
7411
+ if (this.producerCommandDataChannel?.readyState !== Ta) {
7381
7412
  t.reject(/* @__PURE__ */ Error(`Invalid data channel state: ${this.producerCommandDataChannel?.readyState}`));
7382
7413
  return;
7383
7414
  }
@@ -7448,16 +7479,16 @@ var fa = da, pa = {
7448
7479
  }
7449
7480
  _onTransportFailed(e) {
7450
7481
  switch (e.failure) {
7451
- case wa.EMPTY_ENDPOINT:
7482
+ case Ca.EMPTY_ENDPOINT:
7452
7483
  this.conversationReject?.(new O(b.SIGNALING_FAILED, {
7453
7484
  message: e.message,
7454
7485
  remote: e.remote
7455
7486
  }));
7456
7487
  break;
7457
- case wa.NETWORK_ERROR:
7488
+ case Ca.NETWORK_ERROR:
7458
7489
  this._closeSocket(new O(D.NETWORK_ERROR));
7459
7490
  break;
7460
- case wa.ABORTED:
7491
+ case Ca.ABORTED:
7461
7492
  this._debug.debug("[signaling] aborted reconnect"), this._closeSocket(new O(D.CANCELED));
7462
7493
  break;
7463
7494
  }
@@ -7482,39 +7513,39 @@ var fa = da, pa = {
7482
7513
  ...t
7483
7514
  });
7484
7515
  }
7485
- }, Aa = /* @__PURE__ */ function(e) {
7516
+ }, ka = /* @__PURE__ */ function(e) {
7486
7517
  return e.INCOMING = "INCOMING", e.OUTGOING = "OUTGOING", e.JOINING = "JOINING", e;
7487
- }(Aa || {}), ja = /* @__PURE__ */ function(e) {
7518
+ }(ka || {}), Aa = /* @__PURE__ */ function(e) {
7488
7519
  return e.USER = "USER", e.GROUP = "GROUP", e.CHAT = "CHAT", e;
7489
- }(ja || {}), Ma = /* @__PURE__ */ function(e) {
7520
+ }(Aa || {}), ja = /* @__PURE__ */ function(e) {
7490
7521
  return e.ATTENDEE = "ATTENDEE", e.HAND_UP = "HAND_UP", e;
7491
- }(Ma || {}), Na = /* @__PURE__ */ function(e) {
7522
+ }(ja || {}), Ma = /* @__PURE__ */ function(e) {
7492
7523
  return e.ADD_PARTICIPANT = "ADD_PARTICIPANT", e.RECORD = "RECORD", e.MOVIE_SHARE = "MOVIE_SHARE", e;
7493
- }(Na || {}), Pa = /* @__PURE__ */ function(e) {
7524
+ }(Ma || {}), Na = /* @__PURE__ */ function(e) {
7494
7525
  return e.REQUIRE_AUTH_TO_JOIN = "REQUIRE_AUTH_TO_JOIN", e.AUDIENCE_MODE = "AUDIENCE_MODE", e.WAITING_HALL = "WAITING_HALL", e.WAIT_FOR_ADMIN = "WAIT_FOR_ADMIN", e.ADMIN_IS_HERE = "ADMIN_IS_HERE", e.ASR = "ASR", e.FEEDBACK = "FEEDBACK", e.RECURRING = "RECURRING", e;
7495
- }(Pa || {});
7496
- function Fa(e, t) {
7526
+ }(Na || {});
7527
+ function Pa(e, t) {
7497
7528
  if (e.length !== t.length) return !1;
7498
7529
  for (let n of e) if (!t.includes(n)) return !1;
7499
7530
  return !0;
7500
7531
  }
7501
- function Ia(e, t) {
7532
+ function Fa(e, t) {
7502
7533
  let n = new Set(e);
7503
7534
  for (let [e, r] of Object.entries(t)) r ? n.add(e) : n.delete(e);
7504
7535
  return Array.from(n);
7505
7536
  }
7506
7537
  //#endregion
7507
7538
  //#region src/enums/MuteState.ts
7508
- var La = /* @__PURE__ */ function(e) {
7539
+ var Ia = /* @__PURE__ */ function(e) {
7509
7540
  return e.UNMUTE = "UNMUTE", e.MUTE = "MUTE", e.MUTE_PERMANENT = "MUTE_PERMANENT", e;
7510
- }(La || {}), X = /* @__PURE__ */ function(e) {
7541
+ }(Ia || {}), Z = /* @__PURE__ */ function(e) {
7511
7542
  return e.CALLED = "CALLED", e.ACCEPTED = "ACCEPTED", e.REJECTED = "REJECTED", e.HUNGUP = "HUNGUP", e;
7512
- }(X || {}), Ra = /* @__PURE__ */ function(e) {
7543
+ }(Z || {}), La = /* @__PURE__ */ function(e) {
7513
7544
  return e.UPDATE = "UPDATE", e.REMOVE = "REMOVE", e.ACTIVATE = "ACTIVATE", e.TIMEOUT = "TIMEOUT", e;
7514
- }(Ra || {}), za = /* @__PURE__ */ function(e) {
7545
+ }(La || {}), Ra = /* @__PURE__ */ function(e) {
7515
7546
  return e.NO_AVAILABLE_TRACKS = "no-available-tracks", e.UNKNOWN_ERROR = "unknown-error", e;
7516
- }(za || {});
7517
- function Ba(e) {
7547
+ }(Ra || {});
7548
+ function za(e) {
7518
7549
  switch (e) {
7519
7550
  case 1: return "no-available-tracks";
7520
7551
  default: return "unknown-error";
@@ -7522,17 +7553,17 @@ function Ba(e) {
7522
7553
  }
7523
7554
  //#endregion
7524
7555
  //#region src/enums/UserRole.ts
7525
- var Va = /* @__PURE__ */ function(e) {
7556
+ var Ba = /* @__PURE__ */ function(e) {
7526
7557
  return e.CREATOR = "CREATOR", e.ADMIN = "ADMIN", e;
7527
- }(Va || {});
7528
- function Ha(e, t) {
7558
+ }(Ba || {});
7559
+ function Va(e, t) {
7529
7560
  if (e.length !== t.length) return !1;
7530
7561
  for (let n of e) if (!t.includes(n)) return !1;
7531
7562
  return !0;
7532
7563
  }
7533
7564
  //#endregion
7534
7565
  //#region src/static/ParticipantConnectionStatusUtils.ts
7535
- var Ua;
7566
+ var Ha;
7536
7567
  (function(e) {
7537
7568
  function t(e) {
7538
7569
  let t = e?.transport ?? e?.lastEffective ?? N.WAITING, n = {
@@ -7579,10 +7610,10 @@ var Ua;
7579
7610
  shouldNotify: !0
7580
7611
  });
7581
7612
  }
7582
- })(Ua || (Ua = {}));
7583
- var Wa = Ua, Ga = /* @__PURE__ */ function(e) {
7613
+ })(Ha || (Ha = {}));
7614
+ var Ua = Ha, Wa = /* @__PURE__ */ function(e) {
7584
7615
  return e.USER = "USER", e.ANONYM = "ANONYM", e.GROUP = "GROUP", e;
7585
- }({}), Z;
7616
+ }({}), Q;
7586
7617
  (function(e) {
7587
7618
  function t(e) {
7588
7619
  return e.length ? typeof e[0] == "object" ? e : e.map((e) => n(e)) : [];
@@ -7639,10 +7670,10 @@ var Wa = Ua, Ga = /* @__PURE__ */ function(e) {
7639
7670
  return e?.deviceIdx || 0;
7640
7671
  }
7641
7672
  e.getDeviceIdx = u;
7642
- })(Z || (Z = {}));
7673
+ })(Q || (Q = {}));
7643
7674
  //#endregion
7644
7675
  //#region src/types/WaitingHall.ts
7645
- function Ka(e) {
7676
+ function Ga(e) {
7646
7677
  try {
7647
7678
  return btoa(JSON.stringify(e));
7648
7679
  } catch (t) {
@@ -7650,7 +7681,7 @@ function Ka(e) {
7650
7681
  }
7651
7682
  return null;
7652
7683
  }
7653
- function qa(e) {
7684
+ function Ka(e) {
7654
7685
  try {
7655
7686
  return JSON.parse(atob(e));
7656
7687
  } catch (t) {
@@ -7660,12 +7691,12 @@ function qa(e) {
7660
7691
  }
7661
7692
  //#endregion
7662
7693
  //#region src/utils/Conversation.ts
7663
- var Ja = (e, t) => j.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
7664
- function Ya(e) {
7694
+ var qa = (e, t) => j.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
7695
+ function Ja(e) {
7665
7696
  if (e.conversation?.muteStates) return e.conversation.muteStates;
7666
7697
  if (e.muteState && e.muteOptions) return e.muteOptions.reduce((t, n) => (t[n] = e.muteState, t), {});
7667
7698
  }
7668
- function Xa(e, t) {
7699
+ function Ya(e, t) {
7669
7700
  switch (e) {
7670
7701
  case x.AUDIO: return !!t.isAudioEnabled;
7671
7702
  case x.AUDIO_SHARING: return !!t.isAudioSharingEnabled;
@@ -7674,12 +7705,12 @@ function Xa(e, t) {
7674
7705
  default: return !1;
7675
7706
  }
7676
7707
  }
7677
- function Za(e, t) {
7708
+ function Xa(e, t) {
7678
7709
  return j.objectReduce(e, (e, n, r) => {
7679
7710
  switch (n) {
7680
- case La.MUTE:
7681
- case La.MUTE_PERMANENT:
7682
- Xa(r, t) || (e[r] = n);
7711
+ case Ia.MUTE:
7712
+ case Ia.MUTE_PERMANENT:
7713
+ Ya(r, t) || (e[r] = n);
7683
7714
  break;
7684
7715
  default:
7685
7716
  e[r] = n;
@@ -7688,19 +7719,19 @@ function Za(e, t) {
7688
7719
  return e;
7689
7720
  }, {});
7690
7721
  }
7691
- function Qa(e) {
7722
+ function Za(e) {
7692
7723
  let { muteStates: t = {}, mediaSettings: n } = e;
7693
- return Za(t, n);
7724
+ return Xa(t, n);
7694
7725
  }
7695
- function $a(e, t) {
7726
+ function Qa(e, t) {
7696
7727
  let n = e.conversation.participants.find((t) => j.comparePeerId(t.peerId, e.peerId));
7697
7728
  if (!n) return t;
7698
7729
  let { mediaSettings: r } = n;
7699
- return Za(t, r);
7730
+ return Xa(t, r);
7700
7731
  }
7701
7732
  //#endregion
7702
7733
  //#region src/utils/Lz4.ts
7703
- function eo(e, t) {
7734
+ function $a(e, t) {
7704
7735
  let n = new Uint8Array(t), r = 0, i = 0;
7705
7736
  for (; r < e.length && i < t;) {
7706
7737
  let a = e[r++], o = a >> 4, s = a & 15;
@@ -7727,7 +7758,7 @@ function eo(e, t) {
7727
7758
  }
7728
7759
  //#endregion
7729
7760
  //#region src/classes/AudioFix.ts
7730
- var to = class {
7761
+ var eo = class {
7731
7762
  constructor(e, t = R, n = null) {
7732
7763
  h(this, "_fixNoPacketsApplied", !1), h(this, "_fixNoPacketsChecked", !1), h(this, "_fixTooManyPacketsApplied", !1), h(this, "_fixTooManyPacketsSucceeded", !1), h(this, "_fixTooManyPacketsFailed", !1), h(this, "_fixTooManyPacketsTime", void 0), h(this, "_mediaSource", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_lastPacketsSent", void 0), h(this, "_lastPacketsSentTime", void 0), h(this, "_toggleAudioPromise", null), h(this, "_fixNoPacketsAppliedVideo", !1), this._mediaSource = e, this._debug = t, this._logger = n;
7733
7764
  }
@@ -7765,7 +7796,7 @@ var to = class {
7765
7796
  this._debug.warn("[AudioFix] Failed to fix RV (no packets): video restart", e);
7766
7797
  }));
7767
7798
  }
7768
- }, no = class {
7799
+ }, to = class {
7769
7800
  constructor(e, t = !1, n = R, r = null) {
7770
7801
  h(this, "_audioElement", null), h(this, "_audioTracks", /* @__PURE__ */ new Map()), h(this, "_allowMultipleTracks", void 0), h(this, "_volume", 1), h(this, "_features", { setSinkId: !!Audio.prototype.setSinkId }), h(this, "_statFirstMediaReceived", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._statFirstMediaReceived = e, this._allowMultipleTracks = t, this._debug = n, this._logger = r;
7771
7802
  }
@@ -7853,18 +7884,18 @@ var to = class {
7853
7884
  };
7854
7885
  //#endregion
7855
7886
  //#region src/classes/ConversationResponseValidator.ts
7856
- function ro(e, t) {
7857
- e || ao(t, "response is empty"), e.id || ao(t, "id is empty"), e.endpoint || ao(t, "endpoint is empty"), !io(e.stun_server) && !io(e.turn_server) && ao(t, "ice servers are empty");
7887
+ function no(e, t) {
7888
+ e || io(t, "response is empty"), e.id || io(t, "id is empty"), e.endpoint || io(t, "endpoint is empty"), !ro(e.stun_server) && !ro(e.turn_server) && io(t, "ice servers are empty");
7858
7889
  }
7859
- function io(e) {
7890
+ function ro(e) {
7860
7891
  return Array.isArray(e?.urls) && e.urls.length > 0;
7861
7892
  }
7862
- function ao(e, t) {
7893
+ function io(e, t) {
7863
7894
  throw new O(D.UNKNOWN_ERROR, { message: `Invalid ${e} response: ${t}` });
7864
7895
  }
7865
7896
  //#endregion
7866
7897
  //#region src/classes/DebugInfo.ts
7867
- var oo = 90, so = 3, co = class extends y {
7898
+ var ao = 90, oo = 3, so = class extends y {
7868
7899
  constructor(e = R) {
7869
7900
  super(), h(this, "_lastMemoryStat", {
7870
7901
  percent: 0,
@@ -7880,9 +7911,9 @@ var oo = 90, so = 3, co = class extends y {
7880
7911
  let e = window?.performance?.memory;
7881
7912
  if (!e || !e.usedJSHeapSize || !e.jsHeapSizeLimit) return;
7882
7913
  let t = Number((100 * e.usedJSHeapSize / e.jsHeapSizeLimit).toFixed(2)), n = Number((e.usedJSHeapSize / 1024 / 1024).toFixed(1));
7883
- t > oo ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= so) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
7914
+ t > ao ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= oo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
7884
7915
  }
7885
- }, lo = class {
7916
+ }, co = class {
7886
7917
  constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i }) {
7887
7918
  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;
7888
7919
  }
@@ -7937,9 +7968,9 @@ var oo = 90, so = 3, co = class extends y {
7937
7968
  async _getRequestLayouts(e) {
7938
7969
  let t = {}, n = await this._getParticipants();
7939
7970
  for (let r of e) {
7940
- let e = typeof r.uid == "object" ? r.uid : Z.fromId(r.uid), i = this._api.getCachedOkIdByExternalId(e);
7971
+ let e = typeof r.uid == "object" ? r.uid : Q.fromId(r.uid), i = this._api.getCachedOkIdByExternalId(e);
7941
7972
  if (!i) {
7942
- this._debug.log(`Unknown participant external ID ${typeof r.uid == "object" ? Z.toString(r.uid) : r.uid}`);
7973
+ this._debug.log(`Unknown participant external ID ${typeof r.uid == "object" ? Q.toString(r.uid) : r.uid}`);
7943
7974
  continue;
7944
7975
  }
7945
7976
  if (!n[i] && !this._isMe(i)) continue;
@@ -7992,7 +8023,7 @@ var oo = 90, so = 3, co = class extends y {
7992
8023
  let n = e, r = t;
7993
8024
  return n.width !== r.width || n.height !== r.height || n.fit !== r.fit || n.priority !== r.priority;
7994
8025
  }
7995
- }, uo = 44100, fo = class {
8026
+ }, lo = 44100, uo = class {
7996
8027
  constructor(e, t) {
7997
8028
  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]);
7998
8029
  try {
@@ -8009,7 +8040,7 @@ var oo = 90, so = 3, co = class extends y {
8009
8040
  _getBins() {
8010
8041
  if (!this._fftBins || !this._analyser) return new Uint8Array();
8011
8042
  this._analyser.getByteFrequencyData(this._fftBins);
8012
- let e = uo / this._fftBins.length, t = Math.ceil(M.voiceParams.minFreq / e), n = Math.floor(M.voiceParams.maxFreq / e);
8043
+ let e = lo / this._fftBins.length, t = Math.ceil(M.voiceParams.minFreq / e), n = Math.floor(M.voiceParams.maxFreq / e);
8013
8044
  return this._fftBins.subarray(t, n);
8014
8045
  }
8015
8046
  getLevel() {
@@ -8022,7 +8053,7 @@ var oo = 90, so = 3, co = class extends y {
8022
8053
  destroy() {
8023
8054
  this._mediaStreamSource && (this._mediaStreamSource.disconnect(), this._mediaStreamSource = null), this._gainNode && (this._gainNode.disconnect(), this._gainNode = null), this._analyser && (this._analyser.disconnect(), this._analyser = null, this._fftBins = null, this._lastSmoothedLevel = 0), this._stream.removeTrack(this._track);
8024
8055
  }
8025
- }, po = class extends y {
8056
+ }, fo = class extends y {
8026
8057
  constructor(e) {
8027
8058
  super(), h(this, "_detector", null), h(this, "_interval", null);
8028
8059
  let t = () => {
@@ -8038,7 +8069,7 @@ var oo = 90, so = 3, co = class extends y {
8038
8069
  }), this.subscribe(e, Kt.SOURCE_READY, n), n();
8039
8070
  }
8040
8071
  init(e) {
8041
- this._stopDetector(), this._detector = new fo("local", e.clone());
8072
+ this._stopDetector(), this._detector = new uo("local", e.clone());
8042
8073
  }
8043
8074
  _stopDetector() {
8044
8075
  this._detector && (this._detector.track.stop(), this._detector.destroy(), this._detector = null);
@@ -8046,7 +8077,7 @@ var oo = 90, so = 3, co = class extends y {
8046
8077
  destroy() {
8047
8078
  this.unsubscribe(), this._interval && (window.clearTimeout(this._interval), this._interval = null), this._stopDetector();
8048
8079
  }
8049
- }, mo = class {
8080
+ }, po = class {
8050
8081
  constructor(e, t = R) {
8051
8082
  h(this, "processor", void 0), h(this, "queue", []), h(this, "isProcessing", !1), h(this, "_debug", void 0), this.processor = e, this._debug = t;
8052
8083
  }
@@ -8066,17 +8097,17 @@ var oo = 90, so = 3, co = class extends y {
8066
8097
  this.isProcessing = !1;
8067
8098
  }
8068
8099
  }
8069
- }, ho = /* @__PURE__ */ function(e) {
8100
+ }, mo = /* @__PURE__ */ function(e) {
8070
8101
  return e.VOLUMES_DETECTED = "VOLUMES_DETECTED", e;
8071
- }({}), go = class extends y {
8102
+ }({}), ho = class extends y {
8072
8103
  constructor(e) {
8073
- super(), h(this, "_detectors", /* @__PURE__ */ new Map()), h(this, "_interval", null), h(this, "_activeParticipants", void 0), h(this, "_removedParticipants", void 0), h(this, "_topology", void 0), this._topology = e.getTopology(), this.subscribe(e, Y.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(e, Y.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(e, Y.SIGNALLED_ACTIVE_PARTICIPANTS, this._onSignalledActiveParticipants.bind(this)), this.subscribe(e, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8104
+ super(), h(this, "_detectors", /* @__PURE__ */ new Map()), h(this, "_interval", null), h(this, "_activeParticipants", void 0), h(this, "_removedParticipants", void 0), h(this, "_topology", void 0), this._topology = e.getTopology(), this.subscribe(e, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(e, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(e, X.SIGNALLED_ACTIVE_PARTICIPANTS, this._onSignalledActiveParticipants.bind(this)), this.subscribe(e, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8074
8105
  }
8075
8106
  destroy() {
8076
8107
  this._interval && (window.clearTimeout(this._interval), this._interval = null), this.unsubscribe(), this._destroyDetectors();
8077
8108
  }
8078
8109
  _onRemoteTrackAdded(e, t, n) {
8079
- if (n.kind === k.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new fo(e, n)), !this._interval)) {
8110
+ if (n.kind === k.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new uo(e, n)), !this._interval)) {
8080
8111
  let e = () => {
8081
8112
  this._collectVolumes(), this._interval = window.setTimeout(e, M.voiceParams.interval);
8082
8113
  };
@@ -8134,11 +8165,11 @@ var oo = 90, so = 3, co = class extends y {
8134
8165
  e.destroy();
8135
8166
  }), this._detectors.clear();
8136
8167
  }
8137
- }, _o = /* @__PURE__ */ function(e) {
8168
+ }, go = /* @__PURE__ */ function(e) {
8138
8169
  return e.SPEAKER_CHANGED = "SPEAKER_CHANGED", e;
8139
- }({}), vo = class extends y {
8170
+ }({}), _o = class extends y {
8140
8171
  constructor(e, t, n) {
8141
- super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === J.SERVER, this.subscribe(e, ho.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, Y.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8172
+ super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === J.SERVER, this.subscribe(e, mo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, X.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8142
8173
  }
8143
8174
  destroy() {
8144
8175
  this.unsubscribe();
@@ -8160,9 +8191,9 @@ var oo = 90, so = 3, co = class extends y {
8160
8191
  _onTopologyChanged(e) {
8161
8192
  this._serverSideSpeakerDetection = e === J.SERVER;
8162
8193
  }
8163
- }, yo = 15e3, bo = 15e3, xo = class extends y {
8194
+ }, vo = 15e3, yo = 15e3, bo = class extends y {
8164
8195
  constructor(e, t, n, r = R, i = null) {
8165
- super(), h(this, "_transport", void 0), h(this, "_volumes", {}), h(this, "_participants", {}), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_connectionTimeout", 0), h(this, "_connectionTimeoutSuppressed", !1), h(this, "_volumeTimeout", 0), this._transport = e, this._participants = n, this._debug = r, this._logger = i, this.subscribe(e, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, ho.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8196
+ super(), h(this, "_transport", void 0), h(this, "_volumes", {}), h(this, "_participants", {}), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_connectionTimeout", 0), h(this, "_connectionTimeoutSuppressed", !1), h(this, "_volumeTimeout", 0), this._transport = e, this._participants = n, this._debug = r, this._logger = i, this.subscribe(e, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, mo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8166
8197
  }
8167
8198
  destroy() {
8168
8199
  this.unsubscribe(), this._connectionTimeout && window.clearTimeout(this._connectionTimeout), this._volumeTimeout && window.clearTimeout(this._volumeTimeout);
@@ -8174,10 +8205,10 @@ var oo = 90, so = 3, co = class extends y {
8174
8205
  this._connectionTimeout || !this._connectionTimeoutSuppressed || this._reportConnectionTimeout();
8175
8206
  }
8176
8207
  _getConnectionTimeout() {
8177
- return this._transport.getTopology() === J.DIRECT ? yo : M.specListenerParams.connectionTimeout;
8208
+ return this._transport.getTopology() === J.DIRECT ? vo : M.specListenerParams.connectionTimeout;
8178
8209
  }
8179
8210
  _getVolumeTimeout() {
8180
- return this._transport.getTopology() === J.DIRECT ? bo : M.specListenerParams.volumeTimeout;
8211
+ return this._transport.getTopology() === J.DIRECT ? yo : M.specListenerParams.volumeTimeout;
8181
8212
  }
8182
8213
  _onTransportStateChanged(e, t) {
8183
8214
  t === q.OPENED && (this._connectionTimeout || (this._connectionTimeoutSuppressed = !1, this._connectionTimeout = window.setTimeout(this._onConnectionTimeout.bind(this), this._getConnectionTimeout()))), t === q.CONNECTED && (this._volumeTimeout || (this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout())), this._volumeTimeout && (window.clearTimeout(this._volumeTimeout), this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout()))), t === q.FAILED && this._connectionTimeout && (this._debug.warn("Transport failed, send callSpecError"), this._logger?.log(S.CALL_SPEC_ERROR, `${this._transport.getTopology()}_CONNECTION_TIMEOUT`));
@@ -8210,7 +8241,7 @@ var oo = 90, so = 3, co = class extends y {
8210
8241
  r && r.platform && (n = r.platform), e.indexOf(n) < 0 && (e.push(n), this._logger?.log(S.CALL_SPEC_ERROR, `${this._transport.getTopology()}_VOLUME_TIMEOUT_${n}`));
8211
8242
  }), e.length && this._debug.warn("There is silent participant, send callSpecError"), this._volumeTimeout = 0;
8212
8243
  }
8213
- }, So = class extends f {
8244
+ }, xo = class extends f {
8214
8245
  constructor(e, t, n, r = () => void 0) {
8215
8246
  super(), h(this, "_externalLogger", void 0), h(this, "_api", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_batchInterval", 3e3), h(this, "_batchedClientStats", []), h(this, "_batchTimeout", null), h(this, "_serverTimeDelta", 0), h(this, "_waitingForServerTime", !0), h(this, "_deferredClientStats", []), this._api = e, this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._calculateServerTimeDelta();
8216
8247
  }
@@ -8290,11 +8321,11 @@ var oo = 90, so = 3, co = class extends y {
8290
8321
  _now() {
8291
8322
  return Date.now() - this._serverTimeDelta;
8292
8323
  }
8293
- }, Co = {
8324
+ }, So = {
8294
8325
  wallNow: () => Date.now(),
8295
8326
  monotonicNow: () => performance.now()
8296
8327
  };
8297
- function wo(e) {
8328
+ function Co(e) {
8298
8329
  switch (e.hangup) {
8299
8330
  case D.HUNGUP: return "hangup";
8300
8331
  case D.CANCELED: return "canceled";
@@ -8316,11 +8347,11 @@ function wo(e) {
8316
8347
  default: return "failed";
8317
8348
  }
8318
8349
  }
8319
- function To(e) {
8350
+ function wo(e) {
8320
8351
  return e === "anonym_join" ? "join" : e;
8321
8352
  }
8322
- var Eo = class {
8323
- constructor(e, t = Co) {
8353
+ var To = class {
8354
+ constructor(e, t = So) {
8324
8355
  h(this, "_logger", void 0), h(this, "_clock", void 0), h(this, "_conversationId", null), h(this, "_callStartLabel", null), h(this, "_lifecycleStartedAtMonotonic", 0), h(this, "_warmupStartedAtMonotonic", null), h(this, "_pendingEvents", []), h(this, "_warmupCompleted", !1), h(this, "_callStarted", !1), h(this, "_accepted", !1), h(this, "_firstMediaSent", !1), h(this, "_finished", !1), h(this, "_destroyed", !1), this._logger = e, this._clock = t;
8325
8356
  }
8326
8357
  get firstMediaSentReported() {
@@ -8332,7 +8363,7 @@ var Eo = class {
8332
8363
  markInitializationStarted({ source: e, conversationId: t }) {
8333
8364
  if (this._destroyed || this._callStartLabel !== null) return;
8334
8365
  let n = this._clock.wallNow();
8335
- this._callStartLabel = To(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
8366
+ this._callStartLabel = wo(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
8336
8367
  name: H.CALL_INIT,
8337
8368
  source: e
8338
8369
  }, n);
@@ -8373,7 +8404,7 @@ var Eo = class {
8373
8404
  }
8374
8405
  markFinished(e) {
8375
8406
  let t = e.custom_error?.vchat_detailed_api_error?.code;
8376
- this._finish(wo(e), t);
8407
+ this._finish(Co(e), t);
8377
8408
  }
8378
8409
  markTerminated() {
8379
8410
  this._finish("terminated");
@@ -8424,7 +8455,7 @@ var Eo = class {
8424
8455
  ...n && { immediately: !0 }
8425
8456
  });
8426
8457
  }
8427
- }, Do = class {
8458
+ }, Eo = class {
8428
8459
  constructor(e, t) {
8429
8460
  h(this, "_logger", void 0), h(this, "_codecUsages", /* @__PURE__ */ new Map()), h(this, "getCurrentTransportTopology", void 0), this._logger = e, this.getCurrentTransportTopology = t;
8430
8461
  }
@@ -8487,7 +8518,7 @@ var Eo = class {
8487
8518
  this.report(e);
8488
8519
  }), this._codecUsages.clear();
8489
8520
  }
8490
- }, Oo = class {
8521
+ }, Do = class {
8491
8522
  constructor(e) {
8492
8523
  h(this, "_logger", void 0), h(this, "_eventualLogs", /* @__PURE__ */ new Set()), this._logger = e;
8493
8524
  }
@@ -8512,7 +8543,7 @@ var Eo = class {
8512
8543
  destroy() {
8513
8544
  this._eventualLogs.clear();
8514
8545
  }
8515
- }, ko = class {
8546
+ }, Oo = class {
8516
8547
  constructor(e) {
8517
8548
  if (h(this, "q", void 0), h(this, "inits", []), h(this, "n", [
8518
8549
  1,
@@ -8571,7 +8602,7 @@ var Eo = class {
8571
8602
  5
8572
8603
  ];
8573
8604
  }
8574
- }, Ao = class {
8605
+ }, ko = class {
8575
8606
  constructor() {
8576
8607
  h(this, "n", 0), h(this, "mean", 0);
8577
8608
  }
@@ -8583,9 +8614,9 @@ var Eo = class {
8583
8614
  get avg() {
8584
8615
  return this.n ? this.mean : NaN;
8585
8616
  }
8586
- }, jo = class {
8617
+ }, Ao = class {
8587
8618
  constructor() {
8588
- h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new Ao()), h(this, "p50", new ko(.5)), h(this, "p95", new ko(.95));
8619
+ h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new ko()), h(this, "p50", new Oo(.5)), h(this, "p95", new Oo(.95));
8589
8620
  }
8590
8621
  add(e) {
8591
8622
  e < this.minVal && (this.minVal = e), e > this.maxVal && (this.maxVal = e), this.mean.add(e), this.p50.add(e), this.p95.add(e), this.count++;
@@ -8603,11 +8634,11 @@ var Eo = class {
8603
8634
  get hasData() {
8604
8635
  return this.count > 0;
8605
8636
  }
8606
- }, Mo = class {
8637
+ }, jo = class {
8607
8638
  constructor(e) {
8608
8639
  h(this, "_logger", void 0), h(this, "trackerByTransport", {
8609
- ws: new jo(),
8610
- wt: new jo()
8640
+ ws: new Ao(),
8641
+ wt: new Ao()
8611
8642
  }), h(this, "lastSeen", {}), this._logger = e;
8612
8643
  }
8613
8644
  mark(e) {
@@ -8636,17 +8667,17 @@ var Eo = class {
8636
8667
  }
8637
8668
  destroy() {
8638
8669
  this.trackerByTransport = {
8639
- ws: new jo(),
8640
- wt: new jo()
8670
+ ws: new Ao(),
8671
+ wt: new Ao()
8641
8672
  }, this.lastSeen = {};
8642
8673
  }
8643
- }, No = class {
8674
+ }, Mo = class {
8644
8675
  constructor(e) {
8645
8676
  h(this, "_logger", void 0), h(this, "trackerByCommand", /* @__PURE__ */ new Map()), this._logger = e;
8646
8677
  }
8647
8678
  mark(e, t, n) {
8648
8679
  let r = `${e}|${n}`, i;
8649
- this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new jo(), this.trackerByCommand.set(r, i)), i.add(t);
8680
+ this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new Ao(), this.trackerByCommand.set(r, i)), i.add(t);
8650
8681
  }
8651
8682
  logMetrics() {
8652
8683
  for (let [e, t] of this.trackerByCommand.entries()) {
@@ -8668,9 +8699,9 @@ var Eo = class {
8668
8699
  destroy() {
8669
8700
  this.trackerByCommand.clear();
8670
8701
  }
8671
- }, Po = class {
8702
+ }, No = class {
8672
8703
  constructor(e, t, n, r) {
8673
- h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), this.logger = new So(e, t, n, r), this.lifecycle = new Eo(this.logger), this.statAggregator = new Oo(this.logger), this.codecStatsAggregator = new Do(this.logger, r), this.pings = new Mo(this.logger), this.signalingCommands = new No(this.logger);
8704
+ h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), this.logger = new xo(e, t, n, r), this.lifecycle = new To(this.logger), this.statAggregator = new Do(this.logger), this.codecStatsAggregator = new Eo(this.logger, r), this.pings = new jo(this.logger), this.signalingCommands = new Mo(this.logger);
8674
8705
  }
8675
8706
  logHangup(e) {
8676
8707
  this.lifecycle.markFinished(e);
@@ -8681,7 +8712,7 @@ var Eo = class {
8681
8712
  destroy() {
8682
8713
  this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.logger.destroy();
8683
8714
  }
8684
- }, Fo = class {
8715
+ }, Po = class {
8685
8716
  constructor(e) {
8686
8717
  h(this, "_statAggregator", void 0), h(this, "_isCallMarked", !1), h(this, "_isFinished", !1), h(this, "_callType", null), this._statAggregator = e;
8687
8718
  }
@@ -8706,9 +8737,9 @@ var Eo = class {
8706
8737
  call_type: this._callType
8707
8738
  }));
8708
8739
  }
8709
- }, Io = 1e3, Lo = 1e4, Ro = 15, Q = class e extends y {
8740
+ }, Fo = 1e3, Io = 1e4, Lo = 15, $ = class e extends y {
8710
8741
  constructor(e, t) {
8711
- super(), h(this, "_api", void 0), h(this, "_signaling", void 0), h(this, "_signalingActor", void 0), h(this, "_displayLayoutRequester", void 0), h(this, "_mediaSource", null), h(this, "_conversation", null), h(this, "_myLastRequestedLayouts", {}), h(this, "_state", "IDLE"), h(this, "_previousState", null), h(this, "_waitingHallHoldPending", !1), h(this, "_participantState", X.CALLED), h(this, "_participants", {}), h(this, "_pendingParticipants", /* @__PURE__ */ new Map()), h(this, "_directTransportIsMaster", void 0), h(this, "_transport", null), h(this, "_debugInfo", null), h(this, "_debug", R.createSessionLogger()), h(this, "_volumesDetector", null), h(this, "_speakerDetector", null), h(this, "_localVolumeDetector", null), h(this, "_specListener", null), h(this, "_activeSpeakerId", null), h(this, "_lastSignalledActiveSpeakerId", null), h(this, "_isRealTimeAsrRequested", !1), h(this, "_serverSettings", Sr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_abortController", null), h(this, "_registeredPeerReceived", !1), h(this, "_calleeUnavailableTimer", null), h(this, "_onUnload", void 0), h(this, "_audioOutput", void 0), h(this, "_stats", void 0), h(this, "_lastStalled", {}), h(this, "_audioMixStalled", !1), h(this, "_audioFix", null), h(this, "_streamByStreamId", /* @__PURE__ */ new Map()), h(this, "_streamIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_streamWaitTimerByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_sequenceNumberByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownTimestampByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownQueueCleanupTimer", null), h(this, "_statFirstMediaReceived", void 0), h(this, "_changeMediaSettings", j.debounce(async (e) => {
8742
+ super(), h(this, "_api", void 0), h(this, "_signaling", void 0), h(this, "_signalingActor", void 0), h(this, "_displayLayoutRequester", void 0), h(this, "_mediaSource", null), h(this, "_conversation", null), h(this, "_myLastRequestedLayouts", {}), h(this, "_state", "IDLE"), h(this, "_previousState", null), h(this, "_waitingHallHoldPending", !1), h(this, "_participantState", Z.CALLED), h(this, "_participants", {}), h(this, "_pendingParticipants", /* @__PURE__ */ new Map()), h(this, "_directTransportIsMaster", void 0), h(this, "_transport", null), h(this, "_debugInfo", null), h(this, "_debug", R.createSessionLogger()), h(this, "_volumesDetector", null), h(this, "_speakerDetector", null), h(this, "_localVolumeDetector", null), h(this, "_specListener", null), h(this, "_activeSpeakerId", null), h(this, "_lastSignalledActiveSpeakerId", null), h(this, "_isRealTimeAsrRequested", !1), h(this, "_serverSettings", Sr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_abortController", null), h(this, "_registeredPeerReceived", !1), h(this, "_calleeUnavailableTimer", null), h(this, "_reservedId", null), h(this, "_onUnload", void 0), h(this, "_audioOutput", void 0), h(this, "_stats", void 0), h(this, "_lastStalled", {}), h(this, "_audioMixStalled", !1), h(this, "_audioFix", null), h(this, "_streamByStreamId", /* @__PURE__ */ new Map()), h(this, "_streamIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_streamWaitTimerByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_sequenceNumberByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownTimestampByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownQueueCleanupTimer", null), h(this, "_statFirstMediaReceived", void 0), h(this, "_changeMediaSettings", j.debounce(async (e) => {
8712
8743
  if (this._signaling.ready) try {
8713
8744
  await this._signaling.changeMediaSettings(e);
8714
8745
  } catch (e) {
@@ -8718,7 +8749,7 @@ var Eo = class {
8718
8749
  captureAudio: !1
8719
8750
  });
8720
8751
  }
8721
- }, 100)), this._stats = new Po(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new ka(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new mo(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new lo({
8752
+ }, 100)), this._stats = new No(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new Oa(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new po(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new co({
8722
8753
  api: this._api,
8723
8754
  debug: this._debug,
8724
8755
  getParticipants: () => this._getParticipants(),
@@ -8726,13 +8757,13 @@ var Eo = class {
8726
8757
  updateDisplayLayout: (e) => this.updateDisplayLayout(e)
8727
8758
  }), this._onUnload = () => {
8728
8759
  this._stopFirstMediaSentProbe(), this._conversation && this._api && this._api.hangupConversation(this._conversation.id, this._state === "IDLE" ? D.CANCELED : D.HUNGUP), this._stats.destroy();
8729
- }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new Fo(this._stats.statAggregator), this._audioOutput = new no(this._statFirstMediaReceived, M.transparentAudio, this._debug, this._stats.logger), M.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), Io));
8760
+ }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new Po(this._stats.statAggregator), this._audioOutput = new to(this._statFirstMediaReceived, M.transparentAudio, this._debug, this._stats.logger), M.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), Fo));
8730
8761
  }
8731
8762
  static current() {
8732
8763
  return z.getActive() ?? (M.hold ? null : z.getFirst());
8733
8764
  }
8734
8765
  static hangupAfterInit() {
8735
- let e = zo;
8766
+ let e = Ro;
8736
8767
  e && e._delayedHangup === !1 && !e._conversation && (e._delayedHangup = !0, e._abortController?.abort(new O(D.CANCELED)));
8737
8768
  }
8738
8769
  static id() {
@@ -8767,20 +8798,23 @@ var Eo = class {
8767
8798
  get debugSessionId() {
8768
8799
  return this._debug.sessionId;
8769
8800
  }
8801
+ getCachedRawOkIdByExternalId(e) {
8802
+ return this._api.getCachedRawOkIdByExternalId(e);
8803
+ }
8770
8804
  async onStart({ opponentIds: e, opponentType: t, mediaOptions: n, payload: r = "", joiningAllowed: i = !1, requireAuthToJoin: a = !1, onlyAdminCanShareMovie: o, externalIds: s, onFastStart: c, conversationId: l }) {
8771
- let u = l ?? j.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === ja.USER && d === 1 ? M.calleeUnavailableWaitingTime : void 0;
8805
+ let u = l ?? j.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === Aa.USER && d === 1 ? M.calleeUnavailableWaitingTime : void 0;
8772
8806
  this._stats.lifecycle.markInitializationStarted({
8773
8807
  source: "outgoing",
8774
8808
  conversationId: u
8775
- }), this._debug.setConversationId(u), zo = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
8809
+ }), this._debug.setConversationId(u), Ro = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
8776
8810
  try {
8777
8811
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
8778
8812
  let l = this._mediaSource.mediaSettings;
8779
- t === ja.CHAT || e && e.length > 1 ? this._logWithMediaSettings(S.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(S.OUTGOING_CALL, l), this._stats.lifecycle.markWarmupStarted();
8813
+ t === Aa.CHAT || e && e.length > 1 ? this._logWithMediaSettings(S.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(S.OUTGOING_CALL, l), this._stats.lifecycle.markWarmupStarted();
8780
8814
  let d = await this._startConversation({
8781
8815
  opponentIds: e,
8782
8816
  opponentType: t,
8783
- direction: Aa.OUTGOING,
8817
+ direction: ka.OUTGOING,
8784
8818
  mediaOptions: n,
8785
8819
  payload: r,
8786
8820
  joiningAllowed: i,
@@ -8791,23 +8825,23 @@ var Eo = class {
8791
8825
  conversationId: u
8792
8826
  });
8793
8827
  if (!this._conversation) throw new O(D.UNKNOWN_ERROR);
8794
- if (this._participantState = X.ACCEPTED, this._changeMediaSettings(l), await this._processConnection(d), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), this._signaling.readyToSend(), this._delayedHangup) throw new O(D.CANCELED);
8828
+ if (this._participantState = Z.ACCEPTED, this._changeMediaSettings(l), await this._processConnection(d), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), this._signaling.readyToSend(), this._delayedHangup) throw new O(D.CANCELED);
8795
8829
  return this._debug.debug("Outgoing call", {
8796
8830
  opponentIds: e,
8797
8831
  opponentType: t,
8798
8832
  mediaOptions: n
8799
- }), await this._processConnectionSharedMovieInfo(d), await this._processConversationUrlSharingInfo(d), L.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), await this._getMainRoomParticipants(), void 0, this.id), await this._onConversationParticipantListChunk(d), await this._processPinnedParticipants(d), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), z.add(this), await z.setActive(this.id), zo = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
8833
+ }), await this._processConnectionSharedMovieInfo(d), await this._processConversationUrlSharingInfo(d), L.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), await this._getMainRoomParticipants(), void 0, this.id), await this._onConversationParticipantListChunk(d), await this._processPinnedParticipants(d), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), z.add(this), await z.setActive(this.id), Ro = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
8800
8834
  this._calleeUnavailableTimer = null, this._signaling.ready && this._signaling.hangup(D.CANCELED), this._close(new O(D.CALLEE_UNAVAILABLE));
8801
8835
  }, f)), this._conversation;
8802
8836
  } catch (e) {
8803
- throw zo = null, this._close(e, "Unable to start conversation"), e;
8837
+ throw Ro = null, this._cleanupRegistry(), this._close(e, "Unable to start conversation"), e;
8804
8838
  }
8805
8839
  }
8806
8840
  async onJoin(e) {
8807
8841
  this._stats.lifecycle.markInitializationStarted({
8808
8842
  source: e.anonymous ? "anonym_join" : "join",
8809
8843
  conversationId: e.conversationId
8810
- }), zo = this, this._state = "PROCESSING", this._debug.setConversationId(e.conversationId ?? null), this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
8844
+ }), Ro = this, this._state = "PROCESSING", this._debug.setConversationId(e.conversationId ?? null), this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
8811
8845
  try {
8812
8846
  let t = !!e.observedIds?.length;
8813
8847
  if (t && M.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new O(D.UNSUPPORTED);
@@ -8816,20 +8850,20 @@ var Eo = class {
8816
8850
  this._logWithMediaSettings(S.JOIN_CONVERSATION, n), this._stats.lifecycle.markWarmupStarted();
8817
8851
  let r = await this._joinConversation(e);
8818
8852
  if (!this._conversation) throw new O(D.UNKNOWN_ERROR);
8819
- return this._conversation.observer = t, L.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), z.add(this), zo = null, this._signaling.readyToSend(), L.onLocalStatus(this._conversation.waitForAdmin ? N.WAIT_FOR_ADMIN : N.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
8853
+ return this._conversation.observer = t, L.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), z.add(this), Ro = null, this._signaling.readyToSend(), L.onLocalStatus(this._conversation.waitForAdmin ? N.WAIT_FOR_ADMIN : N.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
8820
8854
  } catch (e) {
8821
- throw zo = null, this._close(e, "Unable to join conversation"), e;
8855
+ throw Ro = null, this._cleanupRegistry(), this._close(e, "Unable to join conversation"), e;
8822
8856
  }
8823
8857
  }
8824
8858
  async _onJoinPart2(e, t = !0, n = !1) {
8825
8859
  this._debug.debug("Join conversation part 2");
8826
8860
  try {
8827
- if (this._participantState = X.ACCEPTED, !this._conversation || !this._mediaSource) throw new O(D.UNKNOWN_ERROR);
8861
+ if (this._participantState = Z.ACCEPTED, !this._conversation || !this._mediaSource) throw new O(D.UNKNOWN_ERROR);
8828
8862
  if (this._statFirstMediaReceived.markOnJoin(this._conversation.topology), !n && !this._conversation.observer && !this._isAudienceModeListener() && this._changeMediaSettings(this._mediaSource.mediaSettings), await this._processConnection(e), t && (await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener()), this._signaling.readyToSend(), this._state === "CLOSE") return this._conversation;
8829
8863
  if (this._delayedHangup) throw new O(D.CANCELED);
8830
8864
  await this._processConnectionSharedMovieInfo(e), await this._processConversationUrlSharingInfo(e), await this._processConnectionAsrInfo(e);
8831
8865
  let r = await this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
8832
- L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), await this._getMainRoomParticipants(), r, this.id), await this._onConversationParticipantListChunk(e), await this._processPinnedParticipants(e), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (z.has(this.id) || z.add(this), n ? await this._holdLocally() : await z.setActive(this.id), zo = null);
8866
+ L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), await this._getMainRoomParticipants(), r, this.id), await this._onConversationParticipantListChunk(e), await this._processPinnedParticipants(e), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (z.add(this), n ? await this._holdLocally() : await z.setActive(this.id), Ro = null);
8833
8867
  let i = this._extractLocalParticipantFromConnection(e);
8834
8868
  if (i) {
8835
8869
  let e = j.mapParticipantState(i);
@@ -8837,7 +8871,7 @@ var Eo = class {
8837
8871
  }
8838
8872
  return t && this._openTransport(Object.values(await this._getParticipants()), !1), this._conversation;
8839
8873
  } catch (e) {
8840
- throw zo = null, this._close(e, "Unable to join conversation"), e;
8874
+ throw Ro = null, this._cleanupRegistry(), this._close(e, "Unable to join conversation"), e;
8841
8875
  }
8842
8876
  }
8843
8877
  async _extractExternalRooms(e) {
@@ -8849,28 +8883,28 @@ var Eo = class {
8849
8883
  let n = { rooms: await this._extractExternalRooms(e) };
8850
8884
  return t && (n.roomId = t), n;
8851
8885
  }
8852
- async onPush(e, t = A.USER, n, r, i) {
8886
+ async onPush(e, t = A.USER, n, r, i, a) {
8853
8887
  if (z.has(e)) throw new O(D.HAS_ACTIVE_CALL);
8854
- this._stats.lifecycle.markInitializationStarted({
8888
+ z.reserve(e), this._reservedId = e, this._stats.lifecycle.markInitializationStarted({
8855
8889
  source: "incoming",
8856
8890
  conversationId: e
8857
- }), this._debug.setConversationId(e), zo = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
8891
+ }), this._debug.setConversationId(e), Ro = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal), a && this._api.setUserId(a);
8858
8892
  try {
8859
8893
  this._stats.lifecycle.markWarmupStarted();
8860
8894
  let a = await this._prepareConversation(e, t, n, r, i);
8861
8895
  if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new O(D.UNKNOWN_ERROR);
8862
- if (!a.conversation.participants.find((e) => e.state === X.CALLED && e.id === this._conversation?.userId)) throw this._debug.log("Push rejected (there is an active call)"), this._stats.logger.log(S.PUSH, "rejected"), new O(D.REJECTED);
8863
- if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), await this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(S.PUSH, "accepted"), z.add(this), zo = null, this._delayedHangup) throw new O(D.CANCELED);
8896
+ if (!a.conversation.participants.find((e) => e.state === Z.CALLED && e.id === this._conversation?.userId)) throw this._debug.log("Push rejected (there is an active call)"), this._stats.logger.log(S.PUSH, "rejected"), new O(D.REJECTED);
8897
+ if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), await this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(S.PUSH, "accepted"), z.add(this), Ro = null, this._delayedHangup) throw new O(D.CANCELED);
8864
8898
  } catch (e) {
8865
- throw zo = null, this._close(e, "Unable to handle inbound call push"), e;
8899
+ throw Ro = null, this._cleanupRegistry(), this._close(e, "Unable to handle inbound call push"), e;
8866
8900
  }
8867
8901
  }
8868
8902
  _isInWaitingHall(e) {
8869
- return !e.conversation || !e.conversation.options.includes(Pa.WAITING_HALL) ? !1 : this._isRestricted(e);
8903
+ return !e.conversation || !e.conversation.options.includes(Na.WAITING_HALL) ? !1 : this._isRestricted(e);
8870
8904
  }
8871
8905
  _isWaitForAdmin(e) {
8872
8906
  if (!e.conversation) return !1;
8873
- let t = e.conversation.options.includes(Pa.WAIT_FOR_ADMIN), n = e.conversation.options.includes(Pa.ADMIN_IS_HERE);
8907
+ let t = e.conversation.options.includes(Na.WAIT_FOR_ADMIN), n = e.conversation.options.includes(Na.ADMIN_IS_HERE);
8874
8908
  return !t || t && n ? !1 : this._isRestricted(e);
8875
8909
  }
8876
8910
  _isRestricted(e) {
@@ -8878,7 +8912,7 @@ var Eo = class {
8878
8912
  return t && t.restricted || !1;
8879
8913
  }
8880
8914
  _isAudienceMode(e) {
8881
- return e.conversation?.options?.includes(Pa.AUDIENCE_MODE) || !1;
8915
+ return e.conversation?.options?.includes(Na.AUDIENCE_MODE) || !1;
8882
8916
  }
8883
8917
  _isAudienceModeListener() {
8884
8918
  return this._conversation?.audienceMode && this._conversation?.restricted;
@@ -8889,7 +8923,7 @@ var Eo = class {
8889
8923
  let e = this._mediaSource.mediaSettings;
8890
8924
  this._logWithMediaSettings(S.ACCEPT_CONCURRENT, e), this._debug.debug("Concurrent call", { conversationId: this._conversation.id });
8891
8925
  try {
8892
- this._statFirstMediaReceived.markAcceptCall(this._transport.getTopology()), await this._signaling.acceptCall(this._mediaSource.mediaSettings), this._stats.lifecycle.markIncomingAccepted(!0), L.onCallAccepted(this.id), this._state = "ACTIVE", this._participantState = X.ACCEPTED, this._changeFeatureSet(), this._openTransport(Object.values(await this._getParticipants()), !0);
8926
+ this._statFirstMediaReceived.markAcceptCall(this._transport.getTopology()), await this._signaling.acceptCall(this._mediaSource.mediaSettings), this._stats.lifecycle.markIncomingAccepted(!0), L.onCallAccepted(this.id), this._state = "ACTIVE", this._participantState = Z.ACCEPTED, this._changeFeatureSet(), this._openTransport(Object.values(await this._getParticipants()), !0);
8893
8927
  } catch (e) {
8894
8928
  this._close(e, "Unable to accept concurrent call");
8895
8929
  }
@@ -8904,7 +8938,7 @@ var Eo = class {
8904
8938
  let i = atob(n), a = new Uint8Array(i.length);
8905
8939
  for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
8906
8940
  try {
8907
- let e = eo(a, r).reduce((e, t) => (e += String.fromCharCode(t), e), ""), { srcp: t, stne: n, tkn: i, trne: o, trnp: s, trnu: c, wse: l, wte: u } = JSON.parse(e);
8941
+ let e = $a(a, r).reduce((e, t) => (e += String.fromCharCode(t), e), ""), { srcp: t, stne: n, tkn: i, trne: o, trnp: s, trnu: c, wse: l, wte: u } = JSON.parse(e);
8908
8942
  return {
8909
8943
  token: i,
8910
8944
  endpoint: l,
@@ -8928,7 +8962,7 @@ var Eo = class {
8928
8962
  try {
8929
8963
  await this._mediaSource.request(e);
8930
8964
  let t = this._mediaSource.mediaSettings;
8931
- this._logWithMediaSettings(S.ACCEPT_INCOMING, t), this._changeMediaSettings(t), this._statFirstMediaReceived.markAcceptCall(this._transport.getTopology()), await this._signaling.acceptCall(t), this._stats.lifecycle.markIncomingAccepted(!1), this._participantState = X.ACCEPTED;
8965
+ this._logWithMediaSettings(S.ACCEPT_INCOMING, t), this._changeMediaSettings(t), this._statFirstMediaReceived.markAcceptCall(this._transport.getTopology()), await this._signaling.acceptCall(t), this._stats.lifecycle.markIncomingAccepted(!1), this._participantState = Z.ACCEPTED;
8932
8966
  let n = this._getMuteStatesForCurrentRoom(), r = Object.keys(n);
8933
8967
  r.length && this._onMuteParticipant({
8934
8968
  muteStates: n,
@@ -8963,7 +8997,7 @@ var Eo = class {
8963
8997
  }
8964
8998
  async decline() {
8965
8999
  if (this._state !== "IDLE") throw this._stats.logger.log(S.ERROR, "declineIncoming"), this._debug.error("Unable to decline a call - invalid state"), Error("Unable to decline a call - invalid state");
8966
- this._state = "PROCESSING", this._debug.debug("Decline incoming call"), this._logWithMediaSettings(S.DECLINE_INCOMING, this.mediaSettings), this._participantState = X.HUNGUP;
9000
+ this._state = "PROCESSING", this._debug.debug("Decline incoming call"), this._logWithMediaSettings(S.DECLINE_INCOMING, this.mediaSettings), this._participantState = Z.HUNGUP;
8967
9001
  let e = new O(D.REJECTED);
8968
9002
  this._finishLifecycle(e);
8969
9003
  try {
@@ -8981,14 +9015,14 @@ var Eo = class {
8981
9015
  } finally {
8982
9016
  await this._close(t);
8983
9017
  }
8984
- this._conversation?.id && z.has(this._conversation.id) && z.remove(this._conversation.id);
9018
+ this._conversation?.id && z.has(this._conversation.id) && this._cleanupRegistry();
8985
9019
  }
8986
9020
  async addParticipant(e, t) {
8987
9021
  if (!this._signaling.ready) {
8988
9022
  this._close(new O(D.UNKNOWN_ERROR), "Unable to add participant");
8989
9023
  return;
8990
9024
  }
8991
- let n = await this._signaling.addParticipant(e.map(Z.toSignaling), t), r = null;
9025
+ let n = await this._signaling.addParticipant(e.map(Q.toSignaling), t), r = null;
8992
9026
  n.type === "error" && (r = n.error === "call-unfeasible" ? n.status : D.UNKNOWN_ERROR);
8993
9027
  let i = n.participants;
8994
9028
  if (!i && n.rejectedParticipants) throw Error(n.rejectedParticipants[0].reason);
@@ -9016,12 +9050,15 @@ var Eo = class {
9016
9050
  _openTransport(e, t) {
9017
9051
  if (!this._transport) return;
9018
9052
  let n = new Set(this._transport.opened()), r = [];
9019
- for (let i of e) (i.state === X.CALLED || i.state === X.ACCEPTED) && (this._transport.isAllocated(i.id) || this._allocateParticipantTransport(i.id, t)), i.state === X.ACCEPTED && !n.has(i.id) && r.push(i.id);
9053
+ for (let i of e) (i.state === Z.CALLED || i.state === Z.ACCEPTED) && (this._transport.isAllocated(i.id) || this._allocateParticipantTransport(i.id, t)), i.state === Z.ACCEPTED && !n.has(i.id) && r.push(i.id);
9020
9054
  r.length ? this._transport.open(r, null, !!this._conversation?.observer) : this._transport.getTopology() === J.SERVER && this._forceOpenTransportForAloneInCall();
9021
9055
  }
9022
9056
  _allocateParticipantTransport(e, t) {
9023
9057
  this._transport && (this._transport.getTopology() === J.DIRECT && (t = this._directTransportIsMaster ?? (this._directTransportIsMaster = t)), this._transport.allocate(e, t));
9024
9058
  }
9059
+ _cleanupRegistry() {
9060
+ z.remove(this._reservedId), z.remove(this.id), this._reservedId = null;
9061
+ }
9025
9062
  async _close(e, t) {
9026
9063
  this._clearCalleeUnavailableWatchdog(), t && this._debug.error(t, e), this._debug.debug("Close conversation", e), this._finishLifecycle(e), this._stats.flushCallMetrics(), this._signaling.readyToSend(!1), e.error ? this._signaling.ready && this._signaling.hangup(D.FAILED) : this._stats.logger.log(S.ERROR, e.hangup);
9027
9064
  let n = this._conversation && this._conversation.id;
@@ -9052,15 +9089,15 @@ var Eo = class {
9052
9089
  this._cleanupSignaling(), this._cleanupMediaSource();
9053
9090
  return;
9054
9091
  }
9055
- this._state = "CLOSE", this._participantState = X.HUNGUP, this._changeFeatureSet(), this._cleanupMediaSource(), await this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._cleanupSignaling(), this._api.cleanup(), this._api.setAbortSignal(void 0), this._signaling.setAbortSignal(void 0), this._stats.destroy(), z.remove(this.id), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null, L.onHangup(e || new O(D.UNKNOWN_ERROR), n);
9092
+ this._state = "CLOSE", this._participantState = Z.HUNGUP, this._changeFeatureSet(), this._cleanupMediaSource(), await this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._cleanupSignaling(), this._api.cleanup(), this._api.setAbortSignal(void 0), this._signaling.setAbortSignal(void 0), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null, L.onHangup(e || new O(D.UNKNOWN_ERROR), n);
9056
9093
  }
9057
9094
  async destroy() {
9058
9095
  this._clearCalleeUnavailableWatchdog();
9059
9096
  let e = this._conversation && this._conversation.id;
9060
- if (this._debug.debug("Destroy conversation", { conversationId: e }), this._stopFirstMediaSentProbe(), this._cooldownQueueCleanupTimer !== null && (window.clearInterval(this._cooldownQueueCleanupTimer), this._cooldownQueueCleanupTimer = null), this._state = "CLOSE", this._participantState = X.HUNGUP, this._cleanupMediaSource(), await this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._cleanupSignaling(), this._api.cleanup(), this._api.setAbortSignal(void 0), this._signaling.setAbortSignal(void 0), this._delayedHangup && e) try {
9097
+ if (this._debug.debug("Destroy conversation", { conversationId: e }), this._stopFirstMediaSentProbe(), this._cooldownQueueCleanupTimer !== null && (window.clearInterval(this._cooldownQueueCleanupTimer), this._cooldownQueueCleanupTimer = null), this._state = "CLOSE", this._participantState = Z.HUNGUP, this._cleanupMediaSource(), await this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._cleanupSignaling(), this._api.cleanup(), this._api.setAbortSignal(void 0), this._signaling.setAbortSignal(void 0), this._delayedHangup && e) try {
9061
9098
  this._api.hangupConversation(e, D.CANCELED);
9062
9099
  } catch {}
9063
- this._cleanupListeners(), this._stats.destroy(), z.remove(this.id), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null;
9100
+ this._cleanupListeners(), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null;
9064
9101
  }
9065
9102
  async _getConversationParams(e) {
9066
9103
  let t = await this._api.getConversationParams(e);
@@ -9098,7 +9135,7 @@ var Eo = class {
9098
9135
  async _startConversation({ opponentIds: e, opponentType: t, direction: n, mediaOptions: r, payload: i = "", joiningAllowed: a = !1, requireAuthToJoin: o = !1, onlyAdminCanShareMovie: s, externalIds: c, onFastStart: l, conversationId: u }) {
9099
9136
  let d = u ?? j.uuid();
9100
9137
  if (z.has(d)) throw new O(D.HAS_ACTIVE_CALL);
9101
- this._debug.debug("Conversation: start", {
9138
+ z.reserve(d), this._reservedId = d, this._debug.debug("Conversation: start", {
9102
9139
  conversationId: d,
9103
9140
  opponentIds: e,
9104
9141
  opponentType: t,
@@ -9113,7 +9150,7 @@ var Eo = class {
9113
9150
  platform: M.platform,
9114
9151
  protocolVersion: M.protocolVersion,
9115
9152
  domainId: M.domain,
9116
- capabilities: ma.getFlags()
9153
+ capabilities: pa.getFlags()
9117
9154
  }, n = JSON.stringify(e), s;
9118
9155
  try {
9119
9156
  if (s = await l({
@@ -9172,7 +9209,7 @@ var Eo = class {
9172
9209
  platform: M.platform,
9173
9210
  protocolVersion: M.protocolVersion,
9174
9211
  domainId: M.domain,
9175
- capabilities: ma.getFlags()
9212
+ capabilities: pa.getFlags()
9176
9213
  }, t = JSON.stringify(e), n;
9177
9214
  try {
9178
9215
  if (n = await s({
@@ -9202,10 +9239,13 @@ var Eo = class {
9202
9239
  } else if (t) l = await this._api.joinConversation(t, c, r), u = "joinConversation";
9203
9240
  else if (i) l = await this._api.joinConversationByLink(i, c, a, o), u = "joinConversationByLink";
9204
9241
  else throw new O(D.UNKNOWN_ERROR);
9205
- if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), ro(l, u), l.id && z.has(l.id)) throw new O(D.HAS_ACTIVE_CALL);
9242
+ if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), no(l, u), l.id) {
9243
+ if (z.has(l.id)) throw new O(D.HAS_ACTIVE_CALL);
9244
+ z.reserve(l.id), this._reservedId = l.id;
9245
+ }
9206
9246
  this._setConversationParams(l), this._stats.lifecycle.markWarmupCompleted();
9207
9247
  let d = await this._connectSignaling(dr.JOIN, l);
9208
- return await this._setConversation(l, d, Aa.JOINING), this._stats.lifecycle.markCallStarted(), d;
9248
+ return await this._setConversation(l, d, ka.JOINING), this._stats.lifecycle.markCallStarted(), d;
9209
9249
  }
9210
9250
  async _prepareConversation(e, t = A.USER, n, r, i) {
9211
9251
  W.setMark(H.SIGNALING_CONNECTED), this._debug.debug("Conversation: push", {
@@ -9264,7 +9304,7 @@ var Eo = class {
9264
9304
  }
9265
9305
  this._stats.lifecycle.markWarmupCompleted();
9266
9306
  let u = await this._connectSignaling(dr.ACCEPT, l);
9267
- return z.callsLength >= M.maxParallelCalls || !M.hold && z.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(S.PUSH, "busy"), this._signaling.ready && this._signaling.hangup(D.BUSY), Promise.reject(new O(D.BUSY))) : (await this._setConversation(l, u, Aa.INCOMING, t), u);
9307
+ return z.callsLength >= M.maxParallelCalls || !M.hold && z.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(S.PUSH, "busy"), this._signaling.ready && this._signaling.hangup(D.BUSY), Promise.reject(new O(D.BUSY))) : (await this._setConversation(l, u, ka.INCOMING, t), u);
9268
9308
  }
9269
9309
  async _createParticipant(e, t, n = !0) {
9270
9310
  let r = Object.assign({
@@ -9272,7 +9312,7 @@ var Eo = class {
9272
9312
  externalId: null,
9273
9313
  mediaSettings: E(),
9274
9314
  participantState: {},
9275
- state: X.CALLED,
9315
+ state: Z.CALLED,
9276
9316
  connectionStatus: null,
9277
9317
  remoteStream: null,
9278
9318
  mediaSource: null,
@@ -9287,7 +9327,7 @@ var Eo = class {
9287
9327
  isInRoom: !1,
9288
9328
  markers: null
9289
9329
  }, e);
9290
- return r.externalId || (r.externalId = await this._getParticipantId(t ?? r.id)), n && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = Wa.create(r.connectionStatus), r;
9330
+ return r.externalId || (r.externalId = await this._getParticipantId(t ?? r.id)), n && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = Ua.create(r.connectionStatus), r;
9291
9331
  }
9292
9332
  async _getParticipantId(e) {
9293
9333
  try {
@@ -9298,10 +9338,10 @@ var Eo = class {
9298
9338
  }
9299
9339
  _cacheParticipantExternalIds(e) {
9300
9340
  e.forEach((e) => {
9301
- let t = j.composeId(e), n = Z.fromSignalingParticipant(e, !1);
9341
+ let t = j.composeId(e), n = Q.fromSignalingParticipant(e, !1);
9302
9342
  if (n) {
9303
9343
  this._api.cacheExternalId(t, n);
9304
- let r = j.composeDecorativeId(e), i = Z.fromSignalingParticipant(e);
9344
+ let r = j.composeDecorativeId(e), i = Q.fromSignalingParticipant(e);
9305
9345
  r && i && (this._api.cacheExternalId(r, i), this._api.mapDecorativeId(e.decorativeUserId, e.id));
9306
9346
  }
9307
9347
  });
@@ -9355,7 +9395,7 @@ var Eo = class {
9355
9395
  }
9356
9396
  _createMediaSource() {
9357
9397
  let e = new Jt(this._debug, this._stats.logger);
9358
- return this.subscribe(e, Kt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, Kt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new to(e, this._debug, this._stats.logger), e;
9398
+ return this.subscribe(e, Kt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, Kt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new eo(e, this._debug, this._stats.logger), e;
9359
9399
  }
9360
9400
  async _connectSignaling(e, t) {
9361
9401
  this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null), this.subscribe(this._signaling, G.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, G.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, G.RECONNECT, this._onSignalingReconnect.bind(this));
@@ -9363,7 +9403,7 @@ var Eo = class {
9363
9403
  return this._stats.statAggregator.logEventualStat({ name: H.SIGNALING_CONNECTED }), n;
9364
9404
  }
9365
9405
  async _processConnection(e) {
9366
- await this._registerConnectionParticipants(e), this._processRooms(e), this._processMuteStates(e), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), e.chatRoom && e.chatRoom.totalCount && this._onChatRoomUpdated(Ma.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
9406
+ await this._registerConnectionParticipants(e), this._processRooms(e), this._processMuteStates(e), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), e.chatRoom && e.chatRoom.totalCount && this._onChatRoomUpdated(ja.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
9367
9407
  }
9368
9408
  async _onConversationParticipantListChunk(e) {
9369
9409
  let t = e.participants;
@@ -9404,14 +9444,14 @@ var Eo = class {
9404
9444
  this._conversation.roles = n.roles || [], this._conversation.roles.length && (this._debug.debug(`Local roles changed: ${n.roles}`), L.onLocalRolesChanged(this._conversation.roles, !0, this.id)), this._registerParticipantLocalMuteState(n);
9405
9445
  continue;
9406
9446
  }
9407
- if (n.state === X.HUNGUP || n.state === X.REJECTED) {
9447
+ if (n.state === Z.HUNGUP || n.state === Z.REJECTED) {
9408
9448
  r[n.id] && await this._removeParticipant(r[n.id], D.HUNGUP);
9409
9449
  continue;
9410
9450
  }
9411
9451
  let i = j.composeDecorativeId(n);
9412
9452
  this._registerParticipant({
9413
9453
  id: e,
9414
- externalId: Z.fromSignalingParticipant(n, !0, !0),
9454
+ externalId: Q.fromSignalingParticipant(n, !0, !0),
9415
9455
  mediaSettings: E(n.mediaSettings),
9416
9456
  participantState: j.mapParticipantState(n),
9417
9457
  state: n.state,
@@ -9432,7 +9472,7 @@ var Eo = class {
9432
9472
  _registerParticipantLocalMuteState({ muteStates: e, unmuteOptions: t }) {
9433
9473
  if (!e) return;
9434
9474
  let n = async () => {
9435
- let n = Ja(e, La.MUTE), r = Ja(e, La.MUTE_PERMANENT);
9475
+ let n = qa(e, Ia.MUTE), r = qa(e, Ia.MUTE_PERMANENT);
9436
9476
  for (let i of [n, r]) i.length && await this._onMuteParticipant({
9437
9477
  muteStates: e,
9438
9478
  unmuteOptions: t,
@@ -9446,8 +9486,8 @@ var Eo = class {
9446
9486
  if (!(!M.enableSessionStateUpdates || this._isMe(e))) return t;
9447
9487
  }
9448
9488
  _buildConnectionStatus(e, t, n, r = !1) {
9449
- return Wa.create({
9450
- transport: r ? N.ONHOLD : Wa.fromTransportState(n) ?? N.WAITING,
9489
+ return Ua.create({
9490
+ transport: r ? N.ONHOLD : Ua.fromTransportState(n) ?? N.WAITING,
9451
9491
  sessionState: this._remoteParticipantSessionState(e, t),
9452
9492
  sessionStateApplicable: this._isParticipantSessionStateApplicable(e)
9453
9493
  });
@@ -9456,12 +9496,12 @@ var Eo = class {
9456
9496
  return M.enableSessionStateUpdates && !this._isMe(e) && this._conversation?.topology === J.SERVER;
9457
9497
  }
9458
9498
  _setTransportStatus(e, t) {
9459
- return Wa.setTransport(e.connectionStatus, t);
9499
+ return Ua.setTransport(e.connectionStatus, t);
9460
9500
  }
9461
9501
  _setSessionState(e, t) {
9462
- let n = Wa.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
9502
+ let n = Ua.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
9463
9503
  this._emitParticipantTransition(e, n);
9464
- let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === N.CONNECTED, i = Wa.setSessionState(e.connectionStatus, t, r);
9504
+ let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === N.CONNECTED, i = Ua.setSessionState(e.connectionStatus, t, r);
9465
9505
  return this._emitParticipantTransition(e, i), i;
9466
9506
  }
9467
9507
  _emitParticipantTransition(e, t, n = null) {
@@ -9493,7 +9533,7 @@ var Eo = class {
9493
9533
  }
9494
9534
  }
9495
9535
  _getExternalIdsByOkIdsFromCache(e) {
9496
- return e.map((e) => this._api.getCachedExternalIdByOkId(e) ?? Z.fromId(String(e)));
9536
+ return e.map((e) => this._api.getCachedExternalIdByOkId(e) ?? Q.fromId(String(e)));
9497
9537
  }
9498
9538
  async _registerParticipantAndSetMarkersIfChunkEnabled(e, t) {
9499
9539
  if (M.useParticipantListChunk) {
@@ -9519,11 +9559,11 @@ var Eo = class {
9519
9559
  this._onRoomSwitched(t, !0);
9520
9560
  }
9521
9561
  _processMuteStates(e, t = !1) {
9522
- let n = Ya(e);
9562
+ let n = Ja(e);
9523
9563
  this._setMuteStatesForRoomId(n, null);
9524
9564
  for (let t of e.rooms?.rooms ?? []) this._setMuteStatesForRoomId(t.muteStates, t.id);
9525
9565
  let r = this._getMuteStatesForCurrentRoom();
9526
- t && (r = $a(e, r));
9566
+ t && (r = Qa(e, r));
9527
9567
  let i = Object.keys(r), a = this._conversation?.roomId;
9528
9568
  i.length && this._onMuteParticipant({
9529
9569
  muteStates: r,
@@ -9543,15 +9583,15 @@ var Eo = class {
9543
9583
  }
9544
9584
  async _allocateTransport() {
9545
9585
  if (!this._conversation || !this._mediaSource) return;
9546
- this._transport = new na(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator, this._getFirstMediaSentCallback()), this._debugInfo = new co(this._debug), this.subscribe(this._transport, Y.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, Y.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, Y.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, Y.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, Y.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, Y.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, Y.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, Y.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, Y.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, Y.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, Y.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, Y.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
9547
- let e = this._conversation.direction === Aa.OUTGOING && !this._conversation.concurrent, t = await this._getParticipants();
9548
- for (let n of Object.values(t)) (n.state === X.ACCEPTED || n.state === X.CALLED) && this._allocateParticipantTransport(n.id, e);
9586
+ this._transport = new ta(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator, this._getFirstMediaSentCallback()), this._debugInfo = new so(this._debug), this.subscribe(this._transport, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, X.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, X.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, X.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, X.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, X.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, X.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, X.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, X.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, X.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, X.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
9587
+ let e = this._conversation.direction === ka.OUTGOING && !this._conversation.concurrent, t = await this._getParticipants();
9588
+ for (let n of Object.values(t)) (n.state === Z.ACCEPTED || n.state === Z.CALLED) && this._allocateParticipantTransport(n.id, e);
9549
9589
  }
9550
9590
  _createSpeakerDetector() {
9551
- this._transport && this._conversation && (this._volumesDetector = new go(this._transport), this.subscribe(this._volumesDetector, ho.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new vo(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, _o.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new po(this._mediaSource));
9591
+ this._transport && this._conversation && (this._volumesDetector = new ho(this._transport), this.subscribe(this._volumesDetector, mo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new _o(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, go.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new fo(this._mediaSource));
9552
9592
  }
9553
9593
  async _createSpecListener() {
9554
- this._transport && this._volumesDetector && (this._specListener = new xo(this._transport, this._volumesDetector, await this._getParticipants(), this._debug, this._stats.logger));
9594
+ this._transport && this._volumesDetector && (this._specListener = new bo(this._transport, this._volumesDetector, await this._getParticipants(), this._debug, this._stats.logger));
9555
9595
  }
9556
9596
  _logDevices() {
9557
9597
  let e = T.getCameras().length, t = T.getMicrophones().length;
@@ -9561,7 +9601,7 @@ var Eo = class {
9561
9601
  this._stats.logger.log(e, [t?.isAudioEnabled && "audio", t?.isVideoEnabled && "video"].filter(Boolean).join("_"));
9562
9602
  }
9563
9603
  async _removeParticipant(e, t) {
9564
- if (e.state === X.CALLED || e.state === X.ACCEPTED || this._state === "CLOSE") return;
9604
+ if (e.state === Z.CALLED || e.state === Z.ACCEPTED || this._state === "CLOSE") return;
9565
9605
  e.id === this._lastSignalledActiveSpeakerId && (this._lastSignalledActiveSpeakerId = null);
9566
9606
  let n = await this._getParticipants();
9567
9607
  if (n[e.id]) {
@@ -9620,7 +9660,7 @@ var Eo = class {
9620
9660
  let r = await this._getParticipant(e);
9621
9661
  r && this._updateParticipantExternalId(r, t);
9622
9662
  let i = !r;
9623
- if (r && (r.state === X.ACCEPTED || r.state === X.CALLED)) {
9663
+ if (r && (r.state === Z.ACCEPTED || r.state === Z.CALLED)) {
9624
9664
  this._debug.warn(`Participant [${r.id}:${r.state}] is already in conversation`);
9625
9665
  return;
9626
9666
  }
@@ -9628,7 +9668,7 @@ var Eo = class {
9628
9668
  let n = j.composeDecorativeId(t);
9629
9669
  this._registerParticipant({
9630
9670
  id: e,
9631
- externalId: Z.fromSignalingParticipant(t, !0, !0),
9671
+ externalId: Q.fromSignalingParticipant(t, !0, !0),
9632
9672
  mediaSettings: E(t.mediaSettings),
9633
9673
  state: t.state,
9634
9674
  roles: t.roles || [],
@@ -9639,12 +9679,12 @@ var Eo = class {
9639
9679
  observedIds: t.observedIds || []
9640
9680
  }, n), r = await this._getParticipant(e);
9641
9681
  }
9642
- this._setParticipantsStatus([r], N.WAITING), i && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(r), n ? (r.state = X.HUNGUP, await this._removeParticipant(r, n)) : this._transport && (r.state = X.CALLED, this._allocateParticipantTransport(r.id, !0), this._stats.logger.log(S.ADD_PARTICIPANT), this._invokeRolesChangedCallbackIfNeeded(r));
9682
+ this._setParticipantsStatus([r], N.WAITING), i && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(r), n ? (r.state = Z.HUNGUP, await this._removeParticipant(r, n)) : this._transport && (r.state = Z.CALLED, this._allocateParticipantTransport(r.id, !0), this._stats.logger.log(S.ADD_PARTICIPANT), this._invokeRolesChangedCallbackIfNeeded(r));
9643
9683
  }
9644
9684
  async _onRemoveParticipant(e) {
9645
9685
  this._debug.debug(`Remove participant [${e}]`);
9646
9686
  let t = [], n = await this._getParticipants();
9647
- for (let r = 0; r <= Ro; r++) {
9687
+ for (let r = 0; r <= Lo; r++) {
9648
9688
  let i = n[j.compose(e, r)];
9649
9689
  i && t.push(i);
9650
9690
  }
@@ -9706,12 +9746,12 @@ var Eo = class {
9706
9746
  if (e.length < 2 || !this._signaling.ready) return;
9707
9747
  let t = {}, n = {};
9708
9748
  for (let t of e) {
9709
- let e = typeof t.uid == "object" ? t.uid : Z.fromId(t.uid), r = Z.toString(e);
9749
+ let e = typeof t.uid == "object" ? t.uid : Q.fromId(t.uid), r = Q.toString(e);
9710
9750
  n[r] = t.priority;
9711
9751
  }
9712
9752
  let r = await this._getParticipants();
9713
9753
  for (let e of Object.values(r)) {
9714
- let r = Z.toString(e.externalId);
9754
+ let r = Q.toString(e.externalId);
9715
9755
  Object.hasOwn(n, r) && (t[e.id] = n[r]);
9716
9756
  }
9717
9757
  await this._signaling.changePriorities(t);
@@ -9734,11 +9774,11 @@ var Eo = class {
9734
9774
  this._waitingHallHoldPending = !1, await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus());
9735
9775
  return;
9736
9776
  }
9737
- let n = fa.get();
9777
+ let n = da.get();
9738
9778
  await this._signaling.hold(!1, n), this._restoreStateAfterHold();
9739
9779
  let r = null;
9740
- if (this._state === "IDLE" && this._participantState === X.ACCEPTED && (r = Object.values(await this._getParticipants()), r.some((e) => e.state === X.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), await this._resumeLocalMedia(t, N.WAITING), this._state === "ACTIVE") {
9741
- let e = this._conversation?.direction === Aa.OUTGOING && !this._conversation.concurrent;
9780
+ if (this._state === "IDLE" && this._participantState === Z.ACCEPTED && (r = Object.values(await this._getParticipants()), r.some((e) => e.state === Z.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), await this._resumeLocalMedia(t, N.WAITING), this._state === "ACTIVE") {
9781
+ let e = this._conversation?.direction === ka.OUTGOING && !this._conversation.concurrent;
9742
9782
  this._openTransport(r ?? Object.values(await this._getParticipants()), e);
9743
9783
  }
9744
9784
  }
@@ -9774,9 +9814,9 @@ var Eo = class {
9774
9814
  this._debug.log(`Update display layout request [${this._signaling.getNextCommandSequenceNumber()}]`, e);
9775
9815
  let t = {}, n = [], r = await this._getParticipants();
9776
9816
  for (let i of e) {
9777
- let e = typeof i.uid == "object" ? i.uid : Z.fromId(i.uid), a = this._api.getCachedOkIdByExternalId(e);
9817
+ let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedOkIdByExternalId(e);
9778
9818
  if (!a) {
9779
- let t = Z.toString(e);
9819
+ let t = Q.toString(e);
9780
9820
  this._debug.log(`Unknown participant external ID ${t}`);
9781
9821
  continue;
9782
9822
  }
@@ -9857,13 +9897,13 @@ var Eo = class {
9857
9897
  let n = En(e), a = i[n.participantId];
9858
9898
  if (a) {
9859
9899
  let e;
9860
- typeof t == "number" ? e = Ba(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = za.UNKNOWN_ERROR), r.push({
9900
+ typeof t == "number" ? e = za(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = Ra.UNKNOWN_ERROR), r.push({
9861
9901
  externalId: a.externalId,
9862
9902
  errorReason: e
9863
9903
  });
9864
9904
  }
9865
9905
  }
9866
- if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new Bo("Could not allocate one or more participants", r);
9906
+ if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new zo("Could not allocate one or more participants", r);
9867
9907
  }
9868
9908
  async _cleanupCooldownQueue() {
9869
9909
  let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
@@ -9871,7 +9911,7 @@ var Eo = class {
9871
9911
  let n = t.next();
9872
9912
  if (n.done) break;
9873
9913
  let r = n.value;
9874
- if (r[1] + Lo > Date.now()) break;
9914
+ if (r[1] + Io > Date.now()) break;
9875
9915
  let i = r[0];
9876
9916
  await this._stopStreaming(i), e[i] = { stopStream: !0 };
9877
9917
  } while (!0);
@@ -9892,7 +9932,7 @@ var Eo = class {
9892
9932
  let a = [], o = [], s = [], c = [], l = [];
9893
9933
  if (n.length && n.forEach((e) => {
9894
9934
  if (e.externalId) {
9895
- let t = Z.fromSignaling(e.externalId);
9935
+ let t = Q.fromSignaling(e.externalId);
9896
9936
  l.push(t), this._api.cacheExternalId(e.id.id, t);
9897
9937
  } else {
9898
9938
  let t = j.decomposeId(e.id.id).id;
@@ -10083,13 +10123,13 @@ var Eo = class {
10083
10123
  throw Error("transport is not initialized");
10084
10124
  }
10085
10125
  _isCallAdmin() {
10086
- return this._conversation ? j.includesOneOf(this._conversation.roles, [Va.ADMIN, Va.CREATOR]) : !1;
10126
+ return this._conversation ? j.includesOneOf(this._conversation.roles, [Ba.ADMIN, Ba.CREATOR]) : !1;
10087
10127
  }
10088
10128
  _checkAdminRole() {
10089
- if (this._conversation && !j.includesOneOf(this._conversation.roles, [Va.ADMIN, Va.CREATOR])) throw Error("You don't have the required permission");
10129
+ if (this._conversation && !j.includesOneOf(this._conversation.roles, [Ba.ADMIN, Ba.CREATOR])) throw Error("You don't have the required permission");
10090
10130
  }
10091
10131
  _isCalledState() {
10092
- return this._participantState === X.CALLED;
10132
+ return this._participantState === Z.CALLED;
10093
10133
  }
10094
10134
  async grantRoles(e, t, n) {
10095
10135
  this._checkAdminRole(), await this._signaling.grantRoles(e, t, n);
@@ -10124,21 +10164,21 @@ var Eo = class {
10124
10164
  async changeOptions(e) {
10125
10165
  if (this._signaling.ready && this._conversation) {
10126
10166
  this._checkAdminRole(), await this._signaling.changeOptions(e);
10127
- let t = Ia(this._conversation.options, e);
10167
+ let t = Fa(this._conversation.options, e);
10128
10168
  this._onOptionsChanged(t);
10129
10169
  }
10130
10170
  }
10131
10171
  async getWaitingHall(e, t, n) {
10132
10172
  if (!this._signaling) return Promise.reject();
10133
10173
  let r = null;
10134
- if (e && (r = qa(e), r)) {
10174
+ if (e && (r = Ka(e), r)) {
10135
10175
  let e = this._api.getDecorativeIdByInitialId(r.id);
10136
10176
  r.id = e ? j.composeUserId(e) : r.id;
10137
10177
  }
10138
10178
  let i = await this._signaling.getWaitingHall(r, t, n);
10139
10179
  if (i.error) return Promise.reject(i.message);
10140
10180
  let a = i.participants || [], { externalIds: o } = await this._resolveWaitingHallExternalIds(a), s = null;
10141
- return a.length && i.hasMore && (s = Ka(a[a.length - 1].id)), {
10181
+ return a.length && i.hasMore && (s = Ga(a[a.length - 1].id)), {
10142
10182
  participants: o,
10143
10183
  pageMarker: s,
10144
10184
  totalCount: i.totalCount || 0
@@ -10150,7 +10190,7 @@ var Eo = class {
10150
10190
  let i = [];
10151
10191
  e.forEach((e) => {
10152
10192
  if (t.set(e.id.id, e.id.addedTs), e.externalId) {
10153
- let t = Z.fromSignaling(e.externalId);
10193
+ let t = Q.fromSignaling(e.externalId);
10154
10194
  n.push(e.id.addedTs), r.push(t), this._api.cacheExternalId(e.id.id, t);
10155
10195
  } else i.push(j.decomposeId(e.id.id).id);
10156
10196
  }), i.length && !r.length && (r = this._getExternalIdsByOkIdsFromCache(i), n = r.map((e) => {
@@ -10176,7 +10216,7 @@ var Eo = class {
10176
10216
  }
10177
10217
  async promoteParticipant(e, t) {
10178
10218
  if (this._signaling && this._conversation) try {
10179
- if (!j.includesOneOf(this._conversation.options, [Pa.WAITING_HALL, Pa.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
10219
+ if (!j.includesOneOf(this._conversation.options, [Na.WAITING_HALL, Na.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
10180
10220
  if (this._checkAdminRole(), !e && t) throw Error("participantId is required");
10181
10221
  await this._signaling.promoteParticipant(e, t);
10182
10222
  } catch (t) {
@@ -10325,7 +10365,7 @@ var Eo = class {
10325
10365
  let t = j.composeId(e);
10326
10366
  return this._createParticipant({
10327
10367
  id: t,
10328
- externalId: Z.fromSignalingParticipant(e, !0, !0),
10368
+ externalId: Q.fromSignalingParticipant(e, !0, !0),
10329
10369
  mediaSettings: E(e.mediaSettings),
10330
10370
  participantState: j.mapParticipantState(e),
10331
10371
  state: e.state,
@@ -10348,7 +10388,7 @@ var Eo = class {
10348
10388
  let a = this._transport?.getState();
10349
10389
  return n.participants.forEach((e) => {
10350
10390
  let t = j.composeId(e), n = r[t];
10351
- this._updateParticipantExternalId(n, e), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, Wa.fromTransportState(a) ?? N.WAITING), n.movieShareInfos = e.movieShareInfos, Object.assign(n.mediaSettings, E(e.mediaSettings)), Object.assign(n.muteStates, e.muteStates), n.unmuteOptions = e.unmuteOptions ?? n.unmuteOptions, this._openTransport([n], !0);
10391
+ this._updateParticipantExternalId(n, e), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, Ua.fromTransportState(a) ?? N.WAITING), n.movieShareInfos = e.movieShareInfos, Object.assign(n.mediaSettings, E(e.mediaSettings)), Object.assign(n.muteStates, e.muteStates), n.unmuteOptions = e.unmuteOptions ?? n.unmuteOptions, this._openTransport([n], !0);
10352
10392
  }), this._participantListChunkToExternalChunk(n);
10353
10393
  }
10354
10394
  async _getInitialParticiapntListChunk() {
@@ -10362,7 +10402,7 @@ var Eo = class {
10362
10402
  _onLocalMediaStreamChanged(e) {
10363
10403
  if (!this._conversation || !this._mediaSource) return;
10364
10404
  let t = this._mediaSource.mediaSettings;
10365
- this._debug.debug("Local media stream changed", t), e.kind === k.audio && this._mediaSource && (this._audioFix = new to(this._mediaSource, this._debug, this._stats.logger)), L.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
10405
+ this._debug.debug("Local media stream changed", t), e.kind === k.audio && this._mediaSource && (this._audioFix = new eo(this._mediaSource, this._debug, this._stats.logger)), L.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
10366
10406
  }
10367
10407
  _onScreenSharingStatus(e) {
10368
10408
  let t = this.mediaSettings;
@@ -10492,9 +10532,9 @@ var Eo = class {
10492
10532
  for (let n of e.conversation.participants) {
10493
10533
  let e = j.composeId(n), i = n.roles || [];
10494
10534
  if (this._isMe(e)) {
10495
- Ha(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
10535
+ Va(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
10496
10536
  this._registerParticipantLocalMuteState({
10497
- muteStates: Qa(n),
10537
+ muteStates: Za(n),
10498
10538
  unmuteOptions: n.unmuteOptions
10499
10539
  });
10500
10540
  };
@@ -10512,7 +10552,7 @@ var Eo = class {
10512
10552
  let t = E(n.mediaSettings);
10513
10553
  Ut(t, a.mediaSettings) || await this._changeRemoteMediaSettings(e, t);
10514
10554
  let r = j.mapParticipantState(n), o = a.participantState;
10515
- j.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), Ha(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? N.ONHOLD : N.CONNECTED));
10555
+ j.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), Va(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? N.ONHOLD : N.CONNECTED));
10516
10556
  }
10517
10557
  }
10518
10558
  let i = await this._getParticipants();
@@ -10536,7 +10576,7 @@ var Eo = class {
10536
10576
  this._close(new O(D.MISSED), "Call accepted on other device");
10537
10577
  return;
10538
10578
  }
10539
- this._conversation?.direction === Aa.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
10579
+ this._conversation?.direction === ka.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
10540
10580
  let r = await this._getParticipant(t);
10541
10581
  if (!r) {
10542
10582
  let n = this._api.getDecorativeIdByInitialId(t), i = n ? j.composeUserId(n, e.participantType) : void 0;
@@ -10545,14 +10585,14 @@ var Eo = class {
10545
10585
  mediaSettings: E(e.mediaSettings)
10546
10586
  }, i));
10547
10587
  }
10548
- r.state = X.ACCEPTED, r.mediaSettings = E(e.mediaSettings), this._logWithMediaSettings(S.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === Aa.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), await this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
10588
+ r.state = Z.ACCEPTED, r.mediaSettings = E(e.mediaSettings), this._logWithMediaSettings(S.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === ka.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), await this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
10549
10589
  let i = Object.keys(r.muteStates);
10550
10590
  i.length && this._onMuteParticipant({
10551
10591
  muteStates: r.muteStates,
10552
10592
  mediaOptions: i,
10553
10593
  stateUpdated: !0,
10554
10594
  participantId: t
10555
- }), ["ACTIVE", "HELD"].includes(this._state) && L.onAcceptedCall(r.externalId, ma.parseCapabilities(e.capabilities), this.id);
10595
+ }), ["ACTIVE", "HELD"].includes(this._state) && L.onAcceptedCall(r.externalId, pa.parseCapabilities(e.capabilities), this.id);
10556
10596
  }
10557
10597
  async _onHungup(e) {
10558
10598
  this._debug.debug(`Participant hungup [${e.participantId}]`, { reason: e.reason });
@@ -10568,7 +10608,7 @@ var Eo = class {
10568
10608
  this._warnParticipantNotInConversation(t);
10569
10609
  return;
10570
10610
  }
10571
- if (this._transport && this._transport.close(t), n.state = e.reason === D.REJECTED ? X.REJECTED : X.HUNGUP, this._state !== "CLOSE") {
10611
+ if (this._transport && this._transport.close(t), n.state = e.reason === D.REJECTED ? Z.REJECTED : Z.HUNGUP, this._state !== "CLOSE") {
10572
10612
  let t = e.reason === D.OBSOLETE_CLIENT ? D.OBSOLETE_CLIENT : D.HUNGUP;
10573
10613
  this._removeParticipant(n, t);
10574
10614
  }
@@ -10584,7 +10624,7 @@ var Eo = class {
10584
10624
  return;
10585
10625
  }
10586
10626
  if (e.connected) {
10587
- let e = Wa.fromTransportState(this._transport?.getState());
10627
+ let e = Ua.fromTransportState(this._transport?.getState());
10588
10628
  e && this._setTransportStatus(n, e);
10589
10629
  }
10590
10630
  this._setSessionState(n, { connected: e.connected });
@@ -10598,7 +10638,7 @@ var Eo = class {
10598
10638
  }
10599
10639
  }
10600
10640
  _updateParticipantExternalId(e, t) {
10601
- let n = Z.fromSignalingParticipant(t) ?? Z.fromSignalingParticipant(t, !1);
10641
+ let n = Q.fromSignalingParticipant(t) ?? Q.fromSignalingParticipant(t, !1);
10602
10642
  n && (e.externalId = n, this._api.cacheExternalId(e.id, n));
10603
10643
  }
10604
10644
  _updateParticipantSessionState(e, t, n) {
@@ -10612,7 +10652,7 @@ var Eo = class {
10612
10652
  let t = j.composeMessageId(e), n = await this._getParticipant(t);
10613
10653
  n && this._updateParticipantExternalId(n, e.participant);
10614
10654
  let r = !n;
10615
- if (n && n.state !== X.HUNGUP && n.state !== X.REJECTED) {
10655
+ if (n && n.state !== Z.HUNGUP && n.state !== Z.REJECTED) {
10616
10656
  this._debug.debug(`Participant [${t}] is already in conversation and is active`);
10617
10657
  return;
10618
10658
  }
@@ -10620,7 +10660,7 @@ var Eo = class {
10620
10660
  let { participant: r } = e, i = r.decorativeUserId;
10621
10661
  this._registerParticipant({
10622
10662
  id: t,
10623
- externalId: Z.fromSignalingParticipant(r, !0, !0),
10663
+ externalId: Q.fromSignalingParticipant(r, !0, !0),
10624
10664
  mediaSettings: E(r.mediaSettings),
10625
10665
  state: r.state,
10626
10666
  participantState: j.mapParticipantState(r),
@@ -10632,14 +10672,14 @@ var Eo = class {
10632
10672
  observedIds: r.observedIds || []
10633
10673
  }, i), n = await this._getParticipant(t);
10634
10674
  }
10635
- n.state = X.CALLED, n.mediaSettings = E(e.participant?.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant?.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), this._setParticipantsStatus([n], N.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && this._allocateParticipantTransport(n.id, !0), L.onParticipantAdded(n.externalId, n.markers, this.id), await this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
10675
+ n.state = Z.CALLED, n.mediaSettings = E(e.participant?.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant?.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), this._setParticipantsStatus([n], N.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && this._allocateParticipantTransport(n.id, !0), L.onParticipantAdded(n.externalId, n.markers, this.id), await this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
10636
10676
  }
10637
10677
  async _onJoinedParticipant(e) {
10638
10678
  this._debug.debug(`Participant joined [${e.participantId}]`), this._statFirstMediaReceived.markOnJoin(this._transport?.getTopology());
10639
10679
  let t = j.composeMessageId(e), n = await this._getParticipant(t);
10640
10680
  n && this._updateParticipantExternalId(n, e.participant);
10641
10681
  let r = !n;
10642
- if (n && n.state === X.ACCEPTED) {
10682
+ if (n && n.state === Z.ACCEPTED) {
10643
10683
  this._debug.warn(`Participant [${t}] is already in conversation and is active`);
10644
10684
  return;
10645
10685
  }
@@ -10647,7 +10687,7 @@ var Eo = class {
10647
10687
  let { participant: r } = e, i = r.decorativeUserId;
10648
10688
  this._registerParticipant({
10649
10689
  id: t,
10650
- externalId: Z.fromSignalingParticipant(r, !0, !0),
10690
+ externalId: Q.fromSignalingParticipant(r, !0, !0),
10651
10691
  mediaSettings: E(r.mediaSettings),
10652
10692
  state: r.state,
10653
10693
  participantState: j.mapParticipantState(r),
@@ -10661,7 +10701,7 @@ var Eo = class {
10661
10701
  isOnHold: !!r.onHold
10662
10702
  }, i), n = await this._getParticipant(t);
10663
10703
  }
10664
- this._conversation && this._conversation.direction === Aa.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = X.ACCEPTED, n.mediaSettings = E(e.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], N.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], N.CONNECTED) : this._setParticipantsStatus([n], N.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._allocateParticipantTransport(n.id, !0), this._transport.open([n.id], null, !!this._conversation?.observer)), L.onParticipantJoined(n.externalId, n.markers, this.id), await this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
10704
+ this._conversation && this._conversation.direction === ka.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = Z.ACCEPTED, n.mediaSettings = E(e.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], N.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], N.CONNECTED) : this._setParticipantsStatus([n], N.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._allocateParticipantTransport(n.id, !0), this._transport.open([n.id], null, !!this._conversation?.observer)), L.onParticipantJoined(n.externalId, n.markers, this.id), await this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
10665
10705
  let i = Object.keys(n.muteStates);
10666
10706
  i.length && this._onMuteParticipant({
10667
10707
  muteStates: n.muteStates,
@@ -10849,15 +10889,15 @@ var Eo = class {
10849
10889
  L.onAsrTranscription(t, e.text, e.timestamp, e.duration, this.id);
10850
10890
  }
10851
10891
  async _onRolesChanged(e, t) {
10852
- if (this._conversation && this._isMe(e) && !Ha(this._conversation.roles, t)) {
10892
+ if (this._conversation && this._isMe(e) && !Va(this._conversation.roles, t)) {
10853
10893
  this._debug.debug(`Local roles changed: ${t}`), this._conversation.roles = t, L.onLocalRolesChanged(t, !1, this.id), this._processMuteState({
10854
- mediaOptions: Ja(this._getMuteStatesForCurrentRoom(), La.MUTE_PERMANENT),
10894
+ mediaOptions: qa(this._getMuteStatesForCurrentRoom(), Ia.MUTE_PERMANENT),
10855
10895
  stateUpdated: !0
10856
- }), j.includesOneOf(t, [Va.ADMIN, Va.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
10896
+ }), j.includesOneOf(t, [Ba.ADMIN, Ba.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
10857
10897
  return;
10858
10898
  }
10859
10899
  let n = await this._getParticipant(e);
10860
- n && !Ha(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, L.onRolesChanged(n.externalId, t, !1, this.id));
10900
+ n && !Va(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, L.onRolesChanged(n.externalId, t, !1, this.id));
10861
10901
  }
10862
10902
  async _onMuteParticipant(e, t = !1) {
10863
10903
  if (!this._conversation) return;
@@ -10902,11 +10942,11 @@ var Eo = class {
10902
10942
  });
10903
10943
  }
10904
10944
  async _processMuteState(e) {
10905
- if (!this._conversation || !this._mediaSource || this._participantState !== X.ACCEPTED) return;
10945
+ if (!this._conversation || !this._mediaSource || this._participantState !== Z.ACCEPTED) return;
10906
10946
  let { mediaOptions: t = [], muteAll: n, unmute: r, stateUpdated: i, requestedMedia: a, roomId: o = null, unmuteOptions: s = [] } = e, c = e.adminId ? await this._getExternalIdByParticipantId(e.adminId) : null, l = Object.assign({}, e.muteStates ?? this._getMuteStatesForRoomId(o)), u = this._mediaSource.mediaSettings, d = Object.entries(l);
10907
10947
  for (let [e, i] of d) {
10908
10948
  let a = this._isCallAdmin() && n;
10909
- if (!(i !== La.MUTE && i !== La.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === La.MUTE_PERMANENT && !n && (l[e] = La.MUTE), !(!t.includes(e) || r))) switch (e) {
10949
+ if (!(i !== Ia.MUTE && i !== Ia.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === Ia.MUTE_PERMANENT && !n && (l[e] = Ia.MUTE), !(!t.includes(e) || r))) switch (e) {
10910
10950
  case x.VIDEO:
10911
10951
  u.isVideoEnabled && (L.onDeviceSwitched(x.VIDEO, !1, this.id), await this.toggleLocalVideo(!1));
10912
10952
  break;
@@ -10943,7 +10983,7 @@ var Eo = class {
10943
10983
  this._conversation.pinnedParticipantIdByRoom.set(r, t ? null : e);
10944
10984
  }
10945
10985
  _onOptionsChanged(e) {
10946
- this._conversation && !Fa(this._conversation.options, e) && (this._conversation.options = e, L.onOptionsChanged(e, this.id), e.includes(Pa.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && L.onLocalStatus(N.WAITING_HALL, this.id) : e.includes(Pa.WAIT_FOR_ADMIN) && this._conversation.restricted && L.onLocalStatus(N.WAIT_FOR_ADMIN, this.id));
10986
+ this._conversation && !Pa(this._conversation.options, e) && (this._conversation.options = e, L.onOptionsChanged(e, this.id), e.includes(Na.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && L.onLocalStatus(N.WAITING_HALL, this.id) : e.includes(Na.WAIT_FOR_ADMIN) && this._conversation.restricted && L.onLocalStatus(N.WAIT_FOR_ADMIN, this.id));
10947
10987
  }
10948
10988
  async _onNetworkStatus(e) {
10949
10989
  if (this._conversation) {
@@ -10998,7 +11038,7 @@ var Eo = class {
10998
11038
  }
10999
11039
  _changeFeatureSet() {
11000
11040
  if (this._conversation) {
11001
- let e = this._state === "ACTIVE", t = this._conversation.features.includes(Na.ADD_PARTICIPANT);
11041
+ let e = this._state === "ACTIVE", t = this._conversation.features.includes(Ma.ADD_PARTICIPANT);
11002
11042
  L.onCallState(e, t, this._conversation, this.id);
11003
11043
  }
11004
11044
  }
@@ -11032,7 +11072,7 @@ var Eo = class {
11032
11072
  let n = await this._getParticipant(e);
11033
11073
  if (n) {
11034
11074
  if (n.connectionStatus.sessionStateApplicable && n.connectionStatus.sessionState?.connected === !1) {
11035
- let e = Wa.fromTransportState(this._transport?.getState());
11075
+ let e = Ua.fromTransportState(this._transport?.getState());
11036
11076
  e && this._setTransportStatus(n, e), n.connectionStatus.sessionStateConnectedBySpeaker = !0;
11037
11077
  let t = this._setTransportStatus(n, n.connectionStatus.transport);
11038
11078
  this._emitParticipantTransition(n, t);
@@ -11042,7 +11082,7 @@ var Eo = class {
11042
11082
  }
11043
11083
  async _onTransportStateChanged(e, t) {
11044
11084
  this._debug.debug(`Transport state has changed: ${t}`, e);
11045
- let n = Wa.fromTransportState(t);
11085
+ let n = Ua.fromTransportState(t);
11046
11086
  if (!n) return;
11047
11087
  let r = await this._getParticipants(), i = [], a = e.reduce((e, n) => {
11048
11088
  if (n in r) {
@@ -11112,7 +11152,7 @@ var Eo = class {
11112
11152
  if (this._statFirstMediaReceived.markTopologyChanged(e), e === J.DIRECT && (this._onRemoteSignalledStall([]), this._onAudioMixStall(!1)), this._conversation) {
11113
11153
  this._conversation.topology = e;
11114
11154
  for (let e of Object.values(this._participants)) {
11115
- let t = Wa.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
11155
+ let t = Ua.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
11116
11156
  this._emitParticipantTransition(e, t);
11117
11157
  }
11118
11158
  this._changeFeatureSet(), this._forceOpenTransportForAloneInCall();
@@ -11182,7 +11222,7 @@ var Eo = class {
11182
11222
  async _onRoomsUpdated(e) {
11183
11223
  if (this._isCalledState()) return;
11184
11224
  let t = {};
11185
- for (let n of Object.keys(Ra)) {
11225
+ for (let n of Object.keys(La)) {
11186
11226
  let r = e.updates[n];
11187
11227
  r && (t[n] = {
11188
11228
  rooms: await Promise.all(r?.rooms?.map(this._convertRoomToExternal.bind(this)) || []),
@@ -11194,7 +11234,7 @@ var Eo = class {
11194
11234
  }
11195
11235
  async _onRoomUpdated(e) {
11196
11236
  let t = await this._convertRoomToExternal(e.room || null);
11197
- e.events.some((e) => e === Ra.UPDATE) && (e.muteStates !== void 0 && this._setMuteStatesForRoomId(e.muteStates, e.roomId), e.recordInfo !== void 0 && this._conversation?.recordsInfoByRoom.set(e.roomId, e.recordInfo), e.asrInfo !== void 0 && this._conversation?.asrInfoByRoom.set(e.roomId, e.asrInfo)), this._isCalledState() || L.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id);
11237
+ e.events.some((e) => e === La.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);
11198
11238
  }
11199
11239
  async _convertRoomToExternal(e) {
11200
11240
  if (!e) return null;
@@ -11224,7 +11264,7 @@ var Eo = class {
11224
11264
  let r = j.composeId(e);
11225
11265
  return this._createParticipant({
11226
11266
  id: r,
11227
- externalId: Z.fromSignalingParticipant(e, !0, !0),
11267
+ externalId: Q.fromSignalingParticipant(e, !0, !0),
11228
11268
  mediaSettings: E(e.mediaSettings),
11229
11269
  participantState: j.mapParticipantState(e),
11230
11270
  state: e.state,
@@ -11253,7 +11293,7 @@ var Eo = class {
11253
11293
  if (e) {
11254
11294
  let t = await this._getExternalIdByParticipantId(e);
11255
11295
  if (t) {
11256
- for (let e of c) if (Z.compare(t, e)) {
11296
+ for (let e of c) if (Q.compare(t, e)) {
11257
11297
  this._conversation?.pinnedParticipantIdByRoom.delete(n);
11258
11298
  break;
11259
11299
  }
@@ -11292,7 +11332,7 @@ var Eo = class {
11292
11332
  n && r.push(n);
11293
11333
  }
11294
11334
  }
11295
- r.length && !this._isCalledState() && L.onRoomsUpdated({ [Ra.UPDATE]: { rooms: r } }, this.id);
11335
+ r.length && !this._isCalledState() && L.onRoomsUpdated({ [La.UPDATE]: { rooms: r } }, this.id);
11296
11336
  }
11297
11337
  async _onFeedback(e) {
11298
11338
  let t = [];
@@ -11321,7 +11361,7 @@ var Eo = class {
11321
11361
  this._warnParticipantNotInConversation(t);
11322
11362
  return;
11323
11363
  }
11324
- let o = Z.fromSignaling(r, a.deviceIdx);
11364
+ let o = Q.fromSignaling(r, a.deviceIdx);
11325
11365
  if (L.onParticipantIdChanged(a, o, this.id), this._api.cacheExternalId(n, o), this._api.mapDecorativeId(n, t), i) this._conversation.externalId = o;
11326
11366
  else {
11327
11367
  let e = await this._getParticipants();
@@ -11384,19 +11424,19 @@ var Eo = class {
11384
11424
  async _getParticipant(e) {
11385
11425
  return (await this._getParticipants())[e];
11386
11426
  }
11387
- }, zo = null, Bo = class e extends Error {
11427
+ }, Ro = null, zo = class e extends Error {
11388
11428
  constructor(t, n) {
11389
11429
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
11390
11430
  }
11391
- }, Vo = null, Ho = null;
11392
- function Uo() {
11393
- Vo = null, Ho = null;
11431
+ }, Bo = null, Vo = null;
11432
+ function Ho() {
11433
+ Bo = null, Vo = null;
11394
11434
  }
11395
- function Wo(e) {
11435
+ function Uo(e) {
11396
11436
  return e?.endsWith("/") ? e.slice(0, -1) : e;
11397
11437
  }
11398
- async function Go(e = null, t) {
11399
- let n = Wo(e ?? M.apiBaseUrl);
11438
+ async function Wo(e = null, t) {
11439
+ let n = Uo(e ?? M.apiBaseUrl);
11400
11440
  if (n) return n;
11401
11441
  if ((t ?? M.apiEnv) !== "AUTO") return M.apiEndpoint(t);
11402
11442
  try {
@@ -11411,20 +11451,20 @@ async function Go(e = null, t) {
11411
11451
  return R.warn("Failed to resolve API endpoint using DNS, default is used", e), M.apiEndpoint(t);
11412
11452
  }
11413
11453
  }
11414
- async function Ko() {
11415
- return Vo || Ho || (Ho = Go(), Vo = await Ho, Ho = null, Vo);
11454
+ async function Go() {
11455
+ return Bo || Vo || (Vo = Wo(), Bo = await Vo, Vo = null, Bo);
11416
11456
  }
11417
- async function qo(e, t = {}, n = !1) {
11457
+ async function Ko(e, t = {}, n = !1) {
11418
11458
  if (!window.Blob || !window.navigator.sendBeacon) return;
11419
- await Ko();
11420
- let r = Zo(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
11421
- window.navigator.sendBeacon(`${Vo}/fb.do`, i);
11459
+ await Go();
11460
+ let r = Xo(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
11461
+ window.navigator.sendBeacon(`${Bo}/fb.do`, i);
11422
11462
  }
11423
- async function Jo(e, t = {}, n = !1, r) {
11424
- return await Ko(), Yo(Zo(e, t, n), r);
11463
+ async function qo(e, t = {}, n = !1, r) {
11464
+ return await Go(), Jo(Xo(e, t, n), r);
11425
11465
  }
11426
- async function Yo(e, t) {
11427
- let n = `${t ?? Vo}/fb.do`, r = new AbortController(), i = setTimeout(() => r.abort(new O(D.NETWORK_ERROR)), M.apiTimeout), a = await fetch(n, {
11466
+ async function Jo(e, t) {
11467
+ let n = `${t ?? Bo}/fb.do`, r = new AbortController(), i = setTimeout(() => r.abort(new O(D.NETWORK_ERROR)), M.apiTimeout), a = await fetch(n, {
11428
11468
  method: "POST",
11429
11469
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
11430
11470
  body: e,
@@ -11440,7 +11480,7 @@ async function Yo(e, t) {
11440
11480
  if (!a.ok || Object.hasOwn(s, "error_msg")) throw s;
11441
11481
  return s;
11442
11482
  }
11443
- async function Xo(e, t) {
11483
+ async function Yo(e, t) {
11444
11484
  try {
11445
11485
  let n = await fetch(e, {
11446
11486
  method: "POST",
@@ -11453,7 +11493,7 @@ async function Xo(e, t) {
11453
11493
  throw R.warn("Failed to send form data", e), e;
11454
11494
  }
11455
11495
  }
11456
- function Zo(e, t = {}, n = !1) {
11496
+ function Xo(e, t = {}, n = !1) {
11457
11497
  t.method = e, t.format = "JSON", t.application_key || (t.application_key = M.apiKey), n || (v.sessionKey ? t.session_key = v.sessionKey : v.accessToken && (t.access_token = v.accessToken));
11458
11498
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
11459
11499
  let r = "";
@@ -11462,7 +11502,7 @@ function Zo(e, t = {}, n = !1) {
11462
11502
  }
11463
11503
  //#endregion
11464
11504
  //#region src/abstract/BaseApi.ts
11465
- var Qo = class {
11505
+ var Zo = class {
11466
11506
  constructor() {
11467
11507
  h(this, "_abortSignal", void 0);
11468
11508
  }
@@ -11505,26 +11545,26 @@ var Qo = class {
11505
11545
  async getInbounds() {
11506
11546
  return [];
11507
11547
  }
11508
- }, $o = class {
11548
+ }, Qo = class {
11509
11549
  constructor() {
11510
11550
  h(this, "_okIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToOkId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
11511
11551
  }
11512
11552
  getOkId(e) {
11513
- let t = Z.toString(e), n = this._externalIdToOkId.get(t);
11553
+ let t = Q.toString(e), n = this._externalIdToOkId.get(t);
11514
11554
  return n == null ? null : this.replaceByInitialIdIdIfExists(n);
11515
11555
  }
11516
11556
  getExternalId(e) {
11517
11557
  let t = this.getDecorativeIdByInitialId(e) ?? e, n = this._okIdToExternalId.get(t);
11518
- return n == null ? null : Z.fromString(n);
11558
+ return n == null ? null : Q.fromString(n);
11519
11559
  }
11520
11560
  hasByExternalId(e) {
11521
- return this._externalIdToOkId.has(Z.toString(e));
11561
+ return this._externalIdToOkId.has(Q.toString(e));
11522
11562
  }
11523
11563
  hasByOkId(e) {
11524
11564
  return this._okIdToExternalId.has(e);
11525
11565
  }
11526
11566
  cache(e, t) {
11527
- let n = j.extractOkId(e), r = Z.toString(t);
11567
+ let n = j.extractOkId(e), r = Q.toString(t);
11528
11568
  this._okIdToExternalId.set(n, r), this._externalIdToOkId.set(r, n);
11529
11569
  }
11530
11570
  mapDecorativeId(e, t) {
@@ -11550,19 +11590,19 @@ var Qo = class {
11550
11590
  clear() {
11551
11591
  this._okIdToExternalId.clear(), this._externalIdToOkId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
11552
11592
  }
11553
- }, es = "anonymLogin:", ts = 700, ns = 3e3, rs = class extends Qo {
11593
+ }, $o = "anonymLogin:", es = 700, ts = 3e3, ns = class extends Zo {
11554
11594
  constructor(...e) {
11555
- super(...e), h(this, "_userId", null), h(this, "_uuid", void 0), h(this, "_idCache", new $o());
11595
+ super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new Qo());
11556
11596
  }
11557
11597
  async _callUnsafe(e, t = {}, n = !1) {
11558
11598
  let r = async (i) => {
11559
11599
  try {
11560
- return await Jo(e, t, n);
11600
+ return await qo(e, t, n);
11561
11601
  } catch (t) {
11562
11602
  if (!Object.hasOwn(t, "error_msg")) {
11563
11603
  i++;
11564
11604
  let n = Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`);
11565
- if (R.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (R.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < M.apiMaxAttempt) return await j.delay(Math.min(i * ts, ns), { signal: this._abortSignal }), r(i);
11605
+ if (R.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (R.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < M.apiMaxAttempt) return await j.delay(Math.min(i * es, ts), { signal: this._abortSignal }), r(i);
11566
11606
  }
11567
11607
  throw R.warn(e, "error", t), t;
11568
11608
  }
@@ -11578,14 +11618,14 @@ var Qo = class {
11578
11618
  switch (r.error_code) {
11579
11619
  case 102:
11580
11620
  case 103:
11581
- case 104: return this._removeCachedAnonymLogin(), await this.authorize(), this._callUnsafe(e, t, n);
11621
+ case 104: return this._removeCachedAnonymLogin(), await v.reauthorize(() => this.authorize()), this._callUnsafe(e, t, n);
11582
11622
  }
11583
11623
  let a = {
11584
11624
  message: r.error_msg,
11585
11625
  code: r.error_code
11586
11626
  };
11587
11627
  if (r instanceof O) throw r;
11588
- if (r.custom_error && (a.custom_error = r.custom_error), is(r)) switch (r.error_code) {
11628
+ if (r.custom_error && (a.custom_error = r.custom_error), rs(r)) switch (r.error_code) {
11589
11629
  case 1101:
11590
11630
  i = D.SERVICE_DISABLED;
11591
11631
  break;
@@ -11620,7 +11660,7 @@ var Qo = class {
11620
11660
  }
11621
11661
  async userId(e) {
11622
11662
  let t = j.extractOkId(e);
11623
- return v.isEmpty() ? Z.fromId(String(t)) : this._idCache.getExternalId(t) || Z.fromId(String(t));
11663
+ return v.isEmpty() ? Q.fromId(String(t)) : this._idCache.getExternalId(t) || Q.fromId(String(t));
11624
11664
  }
11625
11665
  async authorize() {
11626
11666
  if (this._ensureUuid(), !M.apiKey) throw new O(b.API, { message: "Required argument apiAppKey not passed" });
@@ -11645,17 +11685,17 @@ var Qo = class {
11645
11685
  });
11646
11686
  }
11647
11687
  _getAnonymLoginCacheKey() {
11648
- return M.authToken ? `${es}${M.authToken}` : null;
11688
+ return M.authToken ? `${$o}${M.authToken}` : null;
11649
11689
  }
11650
11690
  _getCachedAnonymLogin() {
11651
11691
  let e = this._getAnonymLoginCacheKey();
11652
11692
  if (!e) return null;
11653
11693
  let t = ot.get(e);
11654
- return as(t) ? t : (t && ot.remove(e), null);
11694
+ return is(t) ? t : (t && ot.remove(e), null);
11655
11695
  }
11656
11696
  _setCachedAnonymLogin(e) {
11657
11697
  let t = this._getAnonymLoginCacheKey();
11658
- !t || !as(e) || ot.set(t, {
11698
+ !t || !is(e) || ot.set(t, {
11659
11699
  session_key: e.session_key,
11660
11700
  session_secret_key: e.session_secret_key,
11661
11701
  uid: e.uid
@@ -11666,7 +11706,7 @@ var Qo = class {
11666
11706
  e && ot.remove(e);
11667
11707
  }
11668
11708
  _applyAnonymLogin(e) {
11669
- e.uid && (this._userId = Number(e.uid)), v.sessionKey = e.session_key, v.sessionSecretKey = e.session_secret_key;
11709
+ e.uid && (v.userId = Number(e.uid)), v.sessionKey = e.session_key, v.sessionSecretKey = e.session_secret_key;
11670
11710
  }
11671
11711
  logClientStats(e) {
11672
11712
  let t = {
@@ -11676,7 +11716,7 @@ var Qo = class {
11676
11716
  version: 1,
11677
11717
  items: e
11678
11718
  };
11679
- M.clientStatsPlatform && (t.platform = M.clientStatsPlatform), qo("vchat.clientStats", { data: JSON.stringify(t) });
11719
+ M.clientStatsPlatform && (t.platform = M.clientStatsPlatform), Ko("vchat.clientStats", { data: JSON.stringify(t) });
11680
11720
  }
11681
11721
  async uploadDebugLogs(e, t, n, r) {
11682
11722
  let i = {
@@ -11687,14 +11727,14 @@ var Qo = class {
11687
11727
  }, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
11688
11728
  o.append("file", s, "log.json");
11689
11729
  let c = new URL(a.upload_url);
11690
- return c.searchParams.append("size", s.size.toString()), Xo(c.toString(), o);
11730
+ return c.searchParams.append("size", s.size.toString()), Yo(c.toString(), o);
11691
11731
  }
11692
11732
  async joinConversation(e, t = !1, n) {
11693
11733
  let r = {
11694
11734
  conversationId: e,
11695
11735
  isVideo: t,
11696
11736
  protocolVersion: M.protocolVersion,
11697
- capabilities: ma.getFlags()
11737
+ capabilities: pa.getFlags()
11698
11738
  };
11699
11739
  return n && (r.chatId = n), this._call("vchat.joinConversation", r);
11700
11740
  }
@@ -11726,13 +11766,13 @@ var Qo = class {
11726
11766
  externalIds: l
11727
11767
  });
11728
11768
  if (t && t.length) switch (n) {
11729
- case ja.USER:
11769
+ case Aa.USER:
11730
11770
  u.uids = t.join(",");
11731
11771
  break;
11732
- case ja.GROUP:
11772
+ case Aa.GROUP:
11733
11773
  u.gid = t[0];
11734
11774
  break;
11735
- case ja.CHAT:
11775
+ case Aa.CHAT:
11736
11776
  u.chatId = t[0];
11737
11777
  break;
11738
11778
  }
@@ -11753,7 +11793,7 @@ var Qo = class {
11753
11793
  isVideo: t,
11754
11794
  protocolVersion: M.protocolVersion
11755
11795
  };
11756
- return r && (d.createJoinLink = !0), n && (d.payload = n), M.domain && (d.domainId = M.domain), M.externalDomain && (d.externalDomain = M.externalDomain), i && (d.requireAuthToJoin = !0), a !== void 0 && (d.onlyAdminCanShareMovie = a), o !== void 0 && (d.waitForAdmin = o), s && (d.audienceMode = s), c && (d.audioOnly = c), l && (d.closed = l), u && (d.externalIds = u.map(Z.toSignaling).join(",")), d;
11796
+ return r && (d.createJoinLink = !0), n && (d.payload = n), M.domain && (d.domainId = M.domain), M.externalDomain && (d.externalDomain = M.externalDomain), i && (d.requireAuthToJoin = !0), a !== void 0 && (d.onlyAdminCanShareMovie = a), o !== void 0 && (d.waitForAdmin = o), s && (d.audienceMode = s), c && (d.audioOnly = c), l && (d.closed = l), u && (d.externalIds = u.map(Q.toSignaling).join(",")), d;
11757
11797
  }
11758
11798
  async _startConversation(e) {
11759
11799
  return this._call("vchat.startConversation", e);
@@ -11768,14 +11808,14 @@ var Qo = class {
11768
11808
  let n = { joinLink: e };
11769
11809
  t && (n.anonymName = t);
11770
11810
  let r = await this._call("vchat.getAnonymTokenByLink", n);
11771
- return this._userId = Number(r.uid), r.token;
11811
+ return v.userId = Number(r.uid), r.token;
11772
11812
  }
11773
11813
  async joinConversationByLink(e, t = !1, n, r) {
11774
11814
  let i = {
11775
11815
  joinLink: e,
11776
11816
  isVideo: t,
11777
11817
  protocolVersion: M.protocolVersion,
11778
- capabilities: ma.getFlags()
11818
+ capabilities: pa.getFlags()
11779
11819
  };
11780
11820
  return n?.length && (i.observedIds = n.join(",")), M.anonymToken && (i.anonymToken = M.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
11781
11821
  }
@@ -11808,17 +11848,17 @@ var Qo = class {
11808
11848
  return M.anonymToken && (t.anonymToken = M.anonymToken), e && (t.conversationId = e), this._call("vchat.getConversationParams", t);
11809
11849
  }
11810
11850
  getUserId() {
11811
- return this._userId;
11851
+ return v.userId;
11812
11852
  }
11813
11853
  setUserId(e) {
11814
- this._userId = e;
11854
+ v.userId = e;
11815
11855
  }
11816
11856
  hangupConversation(e, t = D.HUNGUP) {
11817
11857
  let n = {
11818
11858
  conversationId: e,
11819
11859
  reason: t
11820
11860
  };
11821
- M.anonymToken && (n.anonymToken = M.anonymToken), qo("vchat.hangupConversation", n);
11861
+ M.anonymToken && (n.anonymToken = M.anonymToken), Ko("vchat.hangupConversation", n);
11822
11862
  }
11823
11863
  async removeHistoryRecords(e) {
11824
11864
  await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
@@ -11834,19 +11874,19 @@ var Qo = class {
11834
11874
  return Array.isArray(e?.inbounds) ? e.inbounds : [];
11835
11875
  }
11836
11876
  };
11837
- function is(e) {
11877
+ function rs(e) {
11838
11878
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
11839
11879
  }
11840
- function as(e) {
11880
+ function is(e) {
11841
11881
  return typeof e == "object" && !!e && "session_key" in e && "session_secret_key" in e && typeof e.session_key == "string" && e.session_key.length > 0 && typeof e.session_secret_key == "string" && e.session_secret_key.length > 0;
11842
11882
  }
11843
11883
  //#endregion
11844
11884
  //#region src/enums/RecordRole.ts
11845
- var os = /* @__PURE__ */ function(e) {
11885
+ var as = /* @__PURE__ */ function(e) {
11846
11886
  return e.KING = "KING", e.PAWN = "PAWN", e;
11847
- }(os || {}), ss = /* @__PURE__ */ function(e) {
11887
+ }(as || {}), os = /* @__PURE__ */ function(e) {
11848
11888
  return e.OFF = "0", e.ON = "1", e;
11849
- }({}), cs = class {
11889
+ }({}), ss = class {
11850
11890
  constructor(e) {
11851
11891
  h(this, "_queue", void 0), h(this, "_readCursor", void 0), h(this, "_writeCursor", void 0), h(this, "_moveReadCursor", void 0), h(this, "_left", void 0), this._queue = Array(e).fill(null), this._readCursor = this._writeCursor = this._left = 0, this._moveReadCursor = !1;
11852
11892
  }
@@ -11869,12 +11909,12 @@ var os = /* @__PURE__ */ function(e) {
11869
11909
  let e = this._queue[this._readCursor];
11870
11910
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
11871
11911
  }
11872
- }, ls = class {
11912
+ }, cs = class {
11873
11913
  constructor(e, t, n, r = null) {
11874
11914
  h(this, "_uuid", void 0), h(this, "_apiKey", void 0), h(this, "_callToken", void 0), h(this, "_apiEnv", void 0), h(this, "_baseApiUrl", void 0), h(this, "_sessionKey", void 0), this._uuid = j.uuid(), this._apiKey = t, this._callToken = n, this._apiEnv = e, this._baseApiUrl = r;
11875
11915
  }
11876
11916
  async authorize() {
11877
- let e = await Jo("auth.anonymLogin", {
11917
+ let e = await qo("auth.anonymLogin", {
11878
11918
  session_data: {
11879
11919
  device_id: this._uuid,
11880
11920
  client_version: M.appVersion,
@@ -11883,18 +11923,18 @@ var os = /* @__PURE__ */ function(e) {
11883
11923
  version: 3
11884
11924
  },
11885
11925
  application_key: this._apiKey
11886
- }, !0, await Go(this._baseApiUrl, this._apiEnv));
11926
+ }, !0, await Wo(this._baseApiUrl, this._apiEnv));
11887
11927
  return j.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
11888
11928
  }
11889
11929
  async hangupConversation(e) {
11890
- await Jo("vchat.hangupConversation", {
11930
+ await qo("vchat.hangupConversation", {
11891
11931
  conversationId: e,
11892
11932
  reason: D.HUNGUP,
11893
11933
  application_key: this._apiKey,
11894
11934
  session_key: this._sessionKey
11895
- }, !0, await Go(this._baseApiUrl, this._apiEnv));
11935
+ }, !0, await Wo(this._baseApiUrl, this._apiEnv));
11896
11936
  }
11897
- }, $, us = null, ds = {
11937
+ }, ls, us = null, ds = {
11898
11938
  getCameras: T.getCameras,
11899
11939
  getMicrophones: T.getMicrophones,
11900
11940
  getOutput: T.getOutput,
@@ -11937,16 +11977,16 @@ function gs(e, t = null, n = {}, r = 1) {
11937
11977
  }, t && e.setSDK(t);
11938
11978
  }
11939
11979
  async function _s(t) {
11940
- if (M.set(t), $ || ($ = new rs()), e.disableLog(!M.debug), R.toggle(M.debug), R.log(`Calls SDK ${M.sdkVersion}`, t), await T.init(), !T.isBrowserSupported()) throw new O(b.UNSUPPORTED);
11980
+ if (M.set(t), ls || (ls = new ns()), e.disableLog(!M.debug), R.toggle(M.debug), R.log(`Calls SDK ${M.sdkVersion}`, t), await T.init(), !T.isBrowserSupported()) throw new O(b.UNSUPPORTED);
11941
11981
  R.log("UserAgent:", navigator.userAgent), R.log("Screen resolution:", `${window.screen.width}x${window.screen.height}`), R.log("Permissions:", `Camera: ${T.hasCameraPermission()}, Mic: ${T.hasMicrophonePermission()}`), R.log("Simulcast:", `${t.simulcast} => ${M.simulcast}`);
11942
11982
  }
11943
11983
  async function vs(e, t = [x.AUDIO], n = "", r = !1, i = !1, a, o, s) {
11944
11984
  let c = [];
11945
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), ys([], ja.USER, t, n, r, i, a, c, o, s);
11985
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), ys([], Aa.USER, t, n, r, i, a, c, o, s);
11946
11986
  }
11947
- async function ys(e, t = ja.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
11987
+ async function ys(e, t = Aa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
11948
11988
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.FAILED);
11949
- return new Q($, us).onStart({
11989
+ return new $(new ns(), us).onStart({
11950
11990
  opponentIds: e,
11951
11991
  opponentType: t,
11952
11992
  mediaOptions: n,
@@ -11963,14 +12003,14 @@ async function bs(e, t) {
11963
12003
  return xs(e, A.USER, void 0, t);
11964
12004
  }
11965
12005
  async function xs(e, t = A.USER, n, r, i, a) {
11966
- if (e === Q.id()) throw Error("Push has already been processed");
11967
- return a && $.setUserId(a), new Q($, us).onPush(e, t, n, r, i);
12006
+ if (e === $.id()) throw Error("Push has already been processed");
12007
+ return new $(new ns(), us).onPush(e, t, n, r, i, a);
11968
12008
  }
11969
12009
  async function Ss() {
11970
- return $.getInbounds();
12010
+ return ls.getInbounds();
11971
12011
  }
11972
12012
  async function Cs(e, t) {
11973
- return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, Uo()), $.authorize();
12013
+ return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, Ho()), ls.authorize();
11974
12014
  }
11975
12015
  async function ws(e = [x.AUDIO], t) {
11976
12016
  return qc(t).accept(e);
@@ -11984,7 +12024,7 @@ async function Es(e, t = [x.AUDIO]) {
11984
12024
  }
11985
12025
  async function Ds(e, t, n) {
11986
12026
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.FAILED);
11987
- return new Q($, us).onJoin({
12027
+ return new $(new ns(), us).onJoin({
11988
12028
  conversationId: e,
11989
12029
  mediaOptions: t,
11990
12030
  chatId: n
@@ -11992,7 +12032,7 @@ async function Ds(e, t, n) {
11992
12032
  }
11993
12033
  async function Os(e, t = [x.AUDIO], n, r, i, a) {
11994
12034
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.FAILED);
11995
- return n && (M.anonymToken = n), new Q($, us).onJoin({
12035
+ return n && (M.anonymToken = n), new $(new ns(), us).onJoin({
11996
12036
  joinLink: e,
11997
12037
  mediaOptions: t,
11998
12038
  observedIds: r,
@@ -12004,21 +12044,21 @@ async function Os(e, t = [x.AUDIO], n, r, i, a) {
12004
12044
  async function ks(e) {
12005
12045
  let t = Kc(e);
12006
12046
  if (t) return t.hangup();
12007
- Q.hangupAfterInit();
12047
+ $.hangupAfterInit();
12008
12048
  }
12009
12049
  async function As(e, t) {
12010
- let n = Array.isArray(e) ? e : [e], r = Q.current();
12050
+ let n = Array.isArray(e) ? e : [e], r = $.current();
12011
12051
  r && await r.addParticipant(n, t);
12012
12052
  }
12013
12053
  async function js(e, t) {
12014
- let n = Q.current();
12054
+ let n = $.current();
12015
12055
  if (n) {
12016
12056
  let r = e.map((e) => j.composeUserId(e));
12017
12057
  await n.addParticipantLegacy(r, t);
12018
12058
  }
12019
12059
  }
12020
12060
  async function Ms(e, t = !1) {
12021
- let n = $.getCachedRawOkIdByExternalId(e);
12061
+ let n = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12022
12062
  if (!n) {
12023
12063
  R.warn("removeParticipant: externalId not found in cache", e);
12024
12064
  return;
@@ -12026,7 +12066,7 @@ async function Ms(e, t = !1) {
12026
12066
  return Ns(n, t);
12027
12067
  }
12028
12068
  async function Ns(e, t = !1) {
12029
- let n = Q.current();
12069
+ let n = $.current();
12030
12070
  if (n) try {
12031
12071
  await n.removeParticipant(j.composeUserId(e), t);
12032
12072
  } catch (t) {
@@ -12034,7 +12074,7 @@ async function Ns(e, t = !1) {
12034
12074
  }
12035
12075
  }
12036
12076
  async function Ps(e, t) {
12037
- let n = Q.current();
12077
+ let n = $.current();
12038
12078
  if (e === "videoinput" && At.contains(t)) return M.videoFacingMode = t, n ? (T.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
12039
12079
  if (!await T._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
12040
12080
  if (n) return n.changeDevice(e);
@@ -12052,11 +12092,11 @@ async function Fs(e, t) {
12052
12092
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
12053
12093
  }
12054
12094
  function Is(e) {
12055
- let t = Q.current();
12095
+ let t = $.current();
12056
12096
  t && t.toggleAnimojiCapturing(e);
12057
12097
  }
12058
12098
  async function Ls(e, t = !1) {
12059
- let n = Q.current();
12099
+ let n = $.current();
12060
12100
  n && await n.setVideoStream(e, t);
12061
12101
  }
12062
12102
  async function Rs(e, t) {
@@ -12068,19 +12108,19 @@ async function zs(e, t) {
12068
12108
  n && await n.toggleLocalAudio(e);
12069
12109
  }
12070
12110
  async function Bs(e) {
12071
- let t = Q.current();
12111
+ let t = $.current();
12072
12112
  if (t) return t.setLocalResolution(e);
12073
12113
  }
12074
12114
  async function Vs(e) {
12075
- let t = Q.current();
12115
+ let t = $.current();
12076
12116
  t && await t.changePriorities(e);
12077
12117
  }
12078
12118
  async function Hs(e, t) {
12079
- let n = Q.current();
12119
+ let n = $.current();
12080
12120
  if (n) {
12081
12121
  let r;
12082
12122
  if (t) {
12083
- let e = $.getCachedRawOkIdByExternalId(t);
12123
+ let e = n.getCachedRawOkIdByExternalId(t);
12084
12124
  if (!e) {
12085
12125
  R.warn("changeParticipantState: externalId not found in cache", t);
12086
12126
  return;
@@ -12091,179 +12131,179 @@ async function Hs(e, t) {
12091
12131
  }
12092
12132
  }
12093
12133
  async function Us() {
12094
- let e = Q.current();
12134
+ let e = $.current();
12095
12135
  e && await e.putHandsDown();
12096
12136
  }
12097
12137
  async function Ws(e) {
12098
- let t = Q.current();
12138
+ let t = $.current();
12099
12139
  t && await t.updateDisplayLayout(e);
12100
12140
  }
12101
12141
  async function Gs(e) {
12102
- let t = Q.current();
12142
+ let t = $.current();
12103
12143
  t && await t.requestDisplayLayout(e);
12104
12144
  }
12105
12145
  async function Ks(e, t, n = !1) {
12106
- let r = $.getCachedRawOkIdByExternalId(e);
12146
+ let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12107
12147
  if (!r) {
12108
12148
  R.warn("grantRoles: externalId not found in cache", e);
12109
12149
  return;
12110
12150
  }
12111
- return qs(r, Z.getDeviceIdx(e), t, n);
12151
+ return qs(r, Q.getDeviceIdx(e), t, n);
12112
12152
  }
12113
12153
  async function qs(e, t, n, r = !1) {
12114
- let i = Q.current();
12154
+ let i = $.current();
12115
12155
  i && await i.grantRoles(j.composeParticipantId(e, A.USER, t), n, r);
12116
12156
  }
12117
12157
  async function Js({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12118
12158
  let i = null;
12119
- return e && (i = $.getCachedRawOkIdByExternalId(e), i || R.warn("muteParticipant: externalId not found in cache", e)), Ys({
12159
+ return e && (i = $.current()?.getCachedRawOkIdByExternalId(e) ?? null, i || R.warn("muteParticipant: externalId not found in cache", e)), Ys({
12120
12160
  uid: i,
12121
12161
  muteStates: t,
12122
12162
  requestedMedia: n,
12123
- deviceIdx: Z.getDeviceIdx(e),
12163
+ deviceIdx: Q.getDeviceIdx(e),
12124
12164
  roomId: r
12125
12165
  });
12126
12166
  }
12127
12167
  async function Ys({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12128
- let a = Q.current();
12168
+ let a = $.current();
12129
12169
  if (a) {
12130
12170
  let o = e ? j.composeParticipantId(e, A.USER, r) : null;
12131
12171
  await a.muteParticipant(o, t, n, i);
12132
12172
  }
12133
12173
  }
12134
12174
  async function Xs(e, t = !1, n = null) {
12135
- let r = $.getCachedRawOkIdByExternalId(e);
12175
+ let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12136
12176
  if (!r) {
12137
12177
  R.warn("pinParticipant: externalId not found in cache", e);
12138
12178
  return;
12139
12179
  }
12140
- return Zs(r, t, Z.getDeviceIdx(e), n);
12180
+ return Zs(r, t, Q.getDeviceIdx(e), n);
12141
12181
  }
12142
12182
  async function Zs(e, t = !1, n = 0, r = null) {
12143
- let i = Q.current();
12183
+ let i = $.current();
12144
12184
  i && await i.pinParticipant(j.composeParticipantId(e, A.USER, n), t, r);
12145
12185
  }
12146
12186
  async function Qs(e) {
12147
- let t = Q.current();
12187
+ let t = $.current();
12148
12188
  t && await t.updateMediaModifiers(e);
12149
12189
  }
12150
12190
  async function $s(e) {
12151
- let t = Q.current();
12191
+ let t = $.current();
12152
12192
  t && await t.enableVideoSuspend(e);
12153
12193
  }
12154
12194
  async function ec(e) {
12155
- let t = Q.current();
12195
+ let t = $.current();
12156
12196
  t && await t.enableVideoSuspendSuggest(e);
12157
12197
  }
12158
12198
  async function tc(e) {
12159
- let t = Q.current();
12199
+ let t = $.current();
12160
12200
  t && await t.changeOptions(e);
12161
12201
  }
12162
12202
  async function nc(e, t = null) {
12163
12203
  let n = null;
12164
- return t && (n = $.getCachedRawOkIdByExternalId(t), n || R.warn("chatMessage: externalId not found in cache", t)), rc(e, n);
12204
+ return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("chatMessage: externalId not found in cache", t)), rc(e, n);
12165
12205
  }
12166
12206
  async function rc(e, t = null) {
12167
- let n = Q.current();
12207
+ let n = $.current();
12168
12208
  if (n) {
12169
12209
  let r = t ? j.composeUserId(t) : null;
12170
12210
  await n.chatMessage(e, r);
12171
12211
  }
12172
12212
  }
12173
12213
  async function ic(e = 10) {
12174
- let t = Q.current();
12214
+ let t = $.current();
12175
12215
  if (t) return t.chatHistory(e);
12176
12216
  }
12177
12217
  async function ac(e, t = null) {
12178
12218
  let n = null;
12179
- return t && (n = $.getCachedRawOkIdByExternalId(t), n || R.warn("customData: externalId not found in cache", t)), oc(e, n, Z.getDeviceIdx(t));
12219
+ return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || R.warn("customData: externalId not found in cache", t)), oc(e, n, Q.getDeviceIdx(t));
12180
12220
  }
12181
12221
  async function oc(e, t = null, n = 0) {
12182
- let r = Q.current();
12222
+ let r = $.current();
12183
12223
  if (r) {
12184
12224
  let i = t ? j.composeParticipantId(t, A.USER, n) : null;
12185
12225
  await r.customData(e, i);
12186
12226
  }
12187
12227
  }
12188
12228
  async function sc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12189
- return (await $.createConversation(a ?? j.uuid(), e, t, {
12229
+ return (await ls.createConversation(a ?? j.uuid(), e, t, {
12190
12230
  onlyAdminCanShareMovie: n,
12191
12231
  waitForAdmin: r,
12192
12232
  closedConversation: i
12193
12233
  })).join_link;
12194
12234
  }
12195
12235
  async function cc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
12196
- let a = i.map((e) => Z.fromId(e));
12197
- return (await $.createConversation(j.uuid(), e, t, {
12236
+ let a = i.map((e) => Q.fromId(e));
12237
+ return (await ls.createConversation(j.uuid(), e, t, {
12198
12238
  onlyAdminCanShareMovie: n,
12199
12239
  audienceMode: !0,
12200
12240
  audioOnly: r
12201
12241
  }, a)).join_link;
12202
12242
  }
12203
12243
  async function lc() {
12204
- let e = Q.current();
12244
+ let e = $.current();
12205
12245
  return e ? e.createJoinLink() : Promise.reject();
12206
12246
  }
12207
12247
  async function uc() {
12208
- let e = Q.current();
12248
+ let e = $.current();
12209
12249
  return e ? e.removeJoinLink() : Promise.reject();
12210
12250
  }
12211
12251
  async function dc(e, t) {
12212
- return $.getAnonymTokenByLink(e, t);
12252
+ return ls.getAnonymTokenByLink(e, t);
12213
12253
  }
12214
12254
  function fc(e) {
12215
- let t = Q.current();
12255
+ let t = $.current();
12216
12256
  t && t.setVolume(e);
12217
12257
  }
12218
12258
  function pc(e) {
12219
12259
  M.forceRelayPolicy = e;
12220
12260
  }
12221
12261
  async function mc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
12222
- let o = Q.current();
12262
+ let o = $.current();
12223
12263
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
12224
12264
  }
12225
12265
  async function hc(e = null, t) {
12226
- let n = Q.current();
12266
+ let n = $.current();
12227
12267
  return n ? n.stopStream(e, t) : Promise.reject();
12228
12268
  }
12229
12269
  async function gc(e = null) {
12230
- let t = Q.current();
12270
+ let t = $.current();
12231
12271
  return t ? t.publishStream(e) : Promise.reject();
12232
12272
  }
12233
12273
  async function _c() {
12234
- let e = Q.current();
12274
+ let e = $.current();
12235
12275
  return e ? e.getStreamInfo() : Promise.reject();
12236
12276
  }
12237
12277
  async function vc(e) {
12238
- let t = Q.current();
12278
+ let t = $.current();
12239
12279
  return t ? t.addMovie(e) : Promise.reject();
12240
12280
  }
12241
12281
  async function yc(e) {
12242
- let t = Q.current();
12282
+ let t = $.current();
12243
12283
  return t ? t.updateMovie(e) : Promise.reject();
12244
12284
  }
12245
12285
  async function bc(e) {
12246
- let t = Q.current();
12286
+ let t = $.current();
12247
12287
  return t ? t.removeMovie(e) : Promise.reject();
12248
12288
  }
12249
12289
  async function xc(e, t) {
12250
- let n = Q.current();
12290
+ let n = $.current();
12251
12291
  if (n) {
12252
12292
  let r = [];
12253
12293
  for (let t of e) {
12254
- let e, n;
12294
+ let e, i;
12255
12295
  t.addParticipantIds && (e = [], t.addParticipantIds.forEach((t) => {
12256
- let n = $.getCachedRawOkIdByExternalId(t);
12257
- n ? e.push(j.composeUserId(n)) : R.warn("updateRooms addParticipant: externalId not found in cache", t);
12258
- })), t.removeParticipantIds && (n = [], t.removeParticipantIds.forEach((e) => {
12259
- let t = $.getCachedRawOkIdByExternalId(e);
12260
- t ? n.push(j.composeUserId(t)) : R.warn("updateRooms removeParticipant: externalId not found in cache", e);
12296
+ let r = n.getCachedRawOkIdByExternalId(t);
12297
+ r ? e.push(j.composeUserId(r)) : R.warn("updateRooms addParticipant: externalId not found in cache", t);
12298
+ })), t.removeParticipantIds && (i = [], t.removeParticipantIds.forEach((e) => {
12299
+ let t = n.getCachedRawOkIdByExternalId(e);
12300
+ t ? i.push(j.composeUserId(t)) : R.warn("updateRooms removeParticipant: externalId not found in cache", e);
12261
12301
  })), r.push({
12262
12302
  id: t.id,
12263
12303
  name: t.name,
12264
12304
  participantCount: t.participantCount,
12265
12305
  addParticipantIds: e,
12266
- removeParticipantIds: n,
12306
+ removeParticipantIds: i,
12267
12307
  countdownSec: t.countdownSec
12268
12308
  });
12269
12309
  }
@@ -12272,41 +12312,41 @@ async function xc(e, t) {
12272
12312
  return Promise.reject();
12273
12313
  }
12274
12314
  async function Sc(e, t) {
12275
- let n = Q.current();
12315
+ let n = $.current();
12276
12316
  return n ? n.activateRooms(e, t) : Promise.reject();
12277
12317
  }
12278
12318
  async function Cc(e = null, t = null) {
12279
- let n = Q.current();
12319
+ let n = $.current();
12280
12320
  if (!n) return Promise.reject();
12281
12321
  let r;
12282
12322
  if (t) {
12283
- let e = $.getCachedRawOkIdByExternalId(t);
12323
+ let e = n.getCachedRawOkIdByExternalId(t);
12284
12324
  if (!e) {
12285
12325
  R.warn("switchRoom: externalId not found in cache", t);
12286
12326
  return;
12287
12327
  }
12288
- let n = Z.getDeviceIdx(t);
12289
- r = j.composeParticipantId(e, A.USER, n);
12328
+ let i = Q.getDeviceIdx(t);
12329
+ r = j.composeParticipantId(e, A.USER, i);
12290
12330
  }
12291
12331
  return n.switchRoom(e, r);
12292
12332
  }
12293
12333
  async function wc(e) {
12294
- let t = Q.current();
12334
+ let t = $.current();
12295
12335
  return t ? t.removeRooms(e) : Promise.reject();
12296
12336
  }
12297
12337
  function Tc(e) {
12298
12338
  M.statisticsInterval = e;
12299
- let t = Q.current();
12339
+ let t = $.current();
12300
12340
  if (t) return t.updateStatisticsInterval();
12301
12341
  }
12302
12342
  function Ec(t) {
12303
12343
  e.disableLog(!t), R.toggle(t);
12304
12344
  }
12305
12345
  function Dc(e, ...t) {
12306
- M.debugLog && (Q.debugMessage(e, "[external]", ...t) || R.send(e, "[external]", ...t));
12346
+ M.debugLog && ($.debugMessage(e, "[external]", ...t) || R.send(e, "[external]", ...t));
12307
12347
  }
12308
12348
  function Oc(e, t, ...n) {
12309
- M.debugLog && (Q.debugMessageWithContext(e, t, "[external]", ...n) || R.send(e, "[external]", ...n));
12349
+ M.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || R.send(e, "[external]", ...n));
12310
12350
  }
12311
12351
  var kc = {
12312
12352
  list: Pe,
@@ -12334,42 +12374,42 @@ function Ac() {
12334
12374
  }));
12335
12375
  }
12336
12376
  async function jc() {
12337
- let e = Q.id(), t = Q.debugSessionId();
12377
+ let e = $.id(), t = $.debugSessionId();
12338
12378
  if (!t || !e) throw R.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
12339
12379
  let n = await Fe({ sessionId: t });
12340
12380
  if (n.length === 0) throw R.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
12341
12381
  let r = n[0].t, i = n[n.length - 1].t;
12342
12382
  try {
12343
- return $?.uploadDebugLogs(e, r, i, JSON.stringify([...Ac(), ...n]));
12383
+ return ls?.uploadDebugLogs(e, r, i, JSON.stringify([...Ac(), ...n]));
12344
12384
  } catch (e) {
12345
12385
  throw R.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
12346
12386
  }
12347
12387
  }
12348
12388
  async function Mc(e) {
12349
- let t = Q.current();
12389
+ let t = $.current();
12350
12390
  if (t) return t.videoEffect(e);
12351
12391
  }
12352
12392
  async function Nc(e, t) {
12353
- let n = Q.current();
12393
+ let n = $.current();
12354
12394
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
12355
12395
  }
12356
12396
  async function Pc(e) {
12357
- let t = Q.current();
12397
+ let t = $.current();
12358
12398
  t && await t.setAudioStream(e);
12359
12399
  }
12360
12400
  async function Fc(e, t = null, n = null) {
12361
- let r = Q.current();
12401
+ let r = $.current();
12362
12402
  if (!r) return;
12363
12403
  let i = n ?? t?.id, a = null;
12364
12404
  if (t) {
12365
- let e = $.getCachedRawOkIdByExternalId(t);
12405
+ let e = r.getCachedRawOkIdByExternalId(t);
12366
12406
  if (!e) throw Error("Could not get user id to set animoji svg");
12367
- a = j.composeParticipantId(e, A.USER, Z.getDeviceIdx(t));
12407
+ a = j.composeParticipantId(e, A.USER, Q.getDeviceIdx(t));
12368
12408
  }
12369
12409
  r.setAnimojiSvg(e, a, i);
12370
12410
  }
12371
12411
  function Ic(e) {
12372
- let t = Q.current();
12412
+ let t = $.current();
12373
12413
  t && t.setAnimojiFill(e);
12374
12414
  }
12375
12415
  async function Lc(e = null, t, n = !1) {
@@ -12381,7 +12421,7 @@ async function Rc() {
12381
12421
  async function zc(e, t = !1) {
12382
12422
  let n = qc(), r;
12383
12423
  if (e) {
12384
- let t = $.getCachedRawOkIdByExternalId(e);
12424
+ let t = n.getCachedRawOkIdByExternalId(e);
12385
12425
  if (!t) {
12386
12426
  R.warn("promoteParticipant: externalId not found in cache", e);
12387
12427
  return;
@@ -12409,7 +12449,7 @@ async function Gc(e, t, n) {
12409
12449
  return qc(n).enableFeatureForRoles(e, t);
12410
12450
  }
12411
12451
  function Kc(e) {
12412
- return e ? z.get(e) ?? null : Q.current() ?? z.getFirst();
12452
+ return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
12413
12453
  }
12414
12454
  function qc(e) {
12415
12455
  let t = Kc(e);
@@ -12417,26 +12457,26 @@ function qc(e) {
12417
12457
  return t;
12418
12458
  }
12419
12459
  async function Jc(e) {
12420
- await $.removeHistoryRecords(e);
12460
+ await ls.removeHistoryRecords(e);
12421
12461
  }
12422
12462
  async function Yc(e) {
12423
- let t = Q.current() ?? z.getFirst();
12463
+ let t = $.current() ?? z.getFirst();
12424
12464
  t && await t.startAsr(e);
12425
12465
  }
12426
12466
  async function Xc(e) {
12427
- let t = Q.current() ?? z.getFirst();
12467
+ let t = $.current() ?? z.getFirst();
12428
12468
  t && await t.stopAsr(e);
12429
12469
  }
12430
12470
  async function Zc(e) {
12431
- let t = Q.current() ?? z.getFirst();
12471
+ let t = $.current() ?? z.getFirst();
12432
12472
  t && await t.requestAsr(e);
12433
12473
  }
12434
12474
  async function Qc(e) {
12435
- let t = Q.current();
12475
+ let t = $.current();
12436
12476
  return t ? t.startUrlSharing(e) : Promise.reject();
12437
12477
  }
12438
12478
  async function $c() {
12439
- let e = Q.current();
12479
+ let e = $.current();
12440
12480
  return e ? e.stopUrlSharing() : Promise.reject();
12441
12481
  }
12442
12482
  async function el(e) {
@@ -12446,11 +12486,11 @@ function tl() {
12446
12486
  return z.getActiveId();
12447
12487
  }
12448
12488
  function nl() {
12449
- return Q.getSyncedTime();
12489
+ return $.getSyncedTime();
12450
12490
  }
12451
12491
  function rl() {
12452
12492
  return M.sdkVersion;
12453
12493
  }
12454
12494
  typeof window < "u" && (window.__CALLS_SDK = mn);
12455
12495
  //#endregion
12456
- export { rs as Api, ls as ApiExternal, cs as ArrayDequeue, v as AuthData, f as BaseLogger, Aa as CallDirection, ja as CallType, Ma as ChatRoomEventType, Na as ConversationFeature, Pa as ConversationOption, _n as DebugMessageType, Ga as ExternalIdType, At as FacingMode, b as FatalError, O as HangupReason, D as HangupType, x as MediaOption, k as MediaTrackKind, V as MediaType, La as MuteState, X as ParticipantState, ss as ParticipantStateDataValue, N as ParticipantStatus, os as RecordRole, Ra as RoomsEventType, ka as Signaling, B as SignalingCommandType, dr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, Va as UserRole, A as UserType, fo as VolumeDetector, ws as acceptCall, Vc as acceptPromotion, Sc as activateRooms, vc as addMovie, As as addParticipant, js as addParticipantInternal, Cs as authorize, ds as browser, ys as callInternal, vs as callTo, Fs as captureScreen, Is as captureVmoji, Nc as changeAudioEffect, tc as changeConversationOptions, Ps as changeDevice, Hs as changeParticipantState, Vs as changePriorities, Mc as changeVideoEffect, ic as chatHistory, nc as chatMessage, rc as chatMessageInternal, lc as createJoinLink, ac as customData, oc as customDataInternal, Ec as debug, kc as debugLogs, Dc as debugMessage, Oc as debugMessageWithContext, Ts as declineCall, Gc as enableFeatureForRoles, $s as enableVideoSuspend, ec as enableVideoSuspendSuggest, Wc as feedback, pc as forceRelayPolicy, tl as getActiveCallId, dc as getAnonymTokenByLink, Rc as getAudienceModeHands, Ss as getInbounds, Hc as getParticipantListChunk, Uc as getParticipants, _c as getStreamInfo, nl as getSyncedTime, Lc as getWaitingHall, Ks as grantRoles, qs as grantRolesInternal, ks as hangup, _s as init, Es as joinCall, Os as joinCallByLink, Ds as joinCallInternal, Js as muteParticipant, Ys as muteParticipantInternal, Xs as pinParticipant, Zs as pinParticipantInternal, bs as processPush, xs as processPushInternal, zc as promoteParticipant, gc as publishStream, Us as putHandsDown, Jc as removeHistoryRecords, uc as removeJoinLink, bc as removeMovie, Ms as removeParticipant, Ns as removeParticipantInternal, wc as removeRooms, Zc as requestAsr, Gs as requestDisplayLayout, Bc as requestPromotion, hs as setAudioEffects, Pc as setAudioStream, Bs as setLocalResolution, ps as setLogger, Qs as setMediaModifiers, Tc as setStatisticsInterval, ms as setVideoEffects, Ls as setVideoStream, gs as setVmoji, Ic as setVmojiFill, Fc as setVmojiSvg, fc as setVolume, Yc as startAsr, cc as startAudienceConversation, sc as startConversation, mc as startStream, Qc as startUrlSharing, Xc as stopAsr, hc as stopStream, $c as stopUrlSharing, el as switchCall, Cc as switchRoom, zs as toggleLocalAudio, Rs as toggleLocalVideo, Ws as updateDisplayLayout, yc as updateMovie, xc as updateRooms, jc as uploadDebugLogs, fs as utils, rl as version };
12496
+ export { ns as Api, cs as ApiExternal, ss as ArrayDequeue, v as AuthData, f as BaseLogger, ka as CallDirection, Aa as CallType, ja as ChatRoomEventType, Ma as ConversationFeature, Na as ConversationOption, _n as DebugMessageType, Wa as ExternalIdType, At as FacingMode, b as FatalError, O as HangupReason, D as HangupType, x as MediaOption, k as MediaTrackKind, V as MediaType, Ia as MuteState, Z as ParticipantState, os as ParticipantStateDataValue, N as ParticipantStatus, as as RecordRole, La as RoomsEventType, Oa as Signaling, B as SignalingCommandType, dr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, Ba as UserRole, A as UserType, uo as VolumeDetector, ws as acceptCall, Vc as acceptPromotion, Sc as activateRooms, vc as addMovie, As as addParticipant, js as addParticipantInternal, Cs as authorize, ds as browser, ys as callInternal, vs as callTo, Fs as captureScreen, Is as captureVmoji, Nc as changeAudioEffect, tc as changeConversationOptions, Ps as changeDevice, Hs as changeParticipantState, Vs as changePriorities, Mc as changeVideoEffect, ic as chatHistory, nc as chatMessage, rc as chatMessageInternal, lc as createJoinLink, ac as customData, oc as customDataInternal, Ec as debug, kc as debugLogs, Dc as debugMessage, Oc as debugMessageWithContext, Ts as declineCall, Gc as enableFeatureForRoles, $s as enableVideoSuspend, ec as enableVideoSuspendSuggest, Wc as feedback, pc as forceRelayPolicy, tl as getActiveCallId, dc as getAnonymTokenByLink, Rc as getAudienceModeHands, Ss as getInbounds, Hc as getParticipantListChunk, Uc as getParticipants, _c as getStreamInfo, nl as getSyncedTime, Lc as getWaitingHall, Ks as grantRoles, qs as grantRolesInternal, ks as hangup, _s as init, Es as joinCall, Os as joinCallByLink, Ds as joinCallInternal, Js as muteParticipant, Ys as muteParticipantInternal, Xs as pinParticipant, Zs as pinParticipantInternal, bs as processPush, xs as processPushInternal, zc as promoteParticipant, gc as publishStream, Us as putHandsDown, Jc as removeHistoryRecords, uc as removeJoinLink, bc as removeMovie, Ms as removeParticipant, Ns as removeParticipantInternal, wc as removeRooms, Zc as requestAsr, Gs as requestDisplayLayout, Bc as requestPromotion, hs as setAudioEffects, Pc as setAudioStream, Bs as setLocalResolution, ps as setLogger, Qs as setMediaModifiers, Tc as setStatisticsInterval, ms as setVideoEffects, Ls as setVideoStream, gs as setVmoji, Ic as setVmojiFill, Fc as setVmojiSvg, fc as setVolume, Yc as startAsr, cc as startAudienceConversation, sc as startConversation, mc as startStream, Qc as startUrlSharing, Xc as stopAsr, hc as stopStream, $c as stopUrlSharing, el as switchCall, Cc as switchRoom, zs as toggleLocalAudio, Rs as toggleLocalVideo, Ws as updateDisplayLayout, yc as updateMovie, xc as updateRooms, jc as uploadDebugLogs, fs as utils, rl as version };