@vkontakte/calls-sdk 2.8.11-dev.e80e239d.0 → 2.8.11-dev.f092dc48.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.11-dev.e80e239d.0
3
- * Mon, 08 Jun 2026 19:12:24 GMT
2
+ * @vkontakte/calls-sdk v2.8.11-dev.f092dc48.0
3
+ * Fri, 03 Jul 2026 05:50:21 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -1177,7 +1177,7 @@ function E(e) {
1177
1177
  //#endregion
1178
1178
  //#region src/enums/HangupType.ts
1179
1179
  var D = /* @__PURE__ */ function(e) {
1180
- return e.CANCELED = "CANCELED", e.REJECTED = "REJECTED", e.REMOVED = "REMOVED", e.HUNGUP = "HUNGUP", e.MISSED = "MISSED", e.BUSY = "BUSY", e.FAILED = "FAILED", e.NETWORK_ERROR = "NETWORK_ERROR", e.KILLED = "KILLED", e.BANNED = "BANNED", e.HAS_ACTIVE_CALL = "HAS_ACTIVE_CALL", e.CALLER_IS_BLOCKED = "CALLER_IS_BLOCKED", e.NOT_FRIENDS = "NOT_FRIENDS", e.CALLEE_IS_OFFLINE = "CALLEE_IS_OFFLINE", e.CALLER_IS_REJECTED = "CALLER_IS_REJECTED", e.UNKNOWN_ERROR = "UNKNOWN_ERROR", e.UNSUPPORTED = "UNSUPPORTED", e.OLD_VERSION = "OLD_VERSION", e.SERVICE_DISABLED = "SERVICE_DISABLED", e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.EXTERNAL_API_ERROR = "EXTERNAL_API_ERROR", e.SOCKET_CLOSED = "SOCKET_CLOSED", e.ENDED = "ENDED", e.KILLED_WITHOUT_DELETE = "KILLED_WITHOUT_DELETE", e.ANOTHER_DEVICE = "ANOTHER_DEVICE", e.NOT_FOUND = "NOT_FOUND", e.VCHAT_DETAILED_ERROR = "VCHAT_DETAILED_ERROR", e.TIMEOUT = "TIMEOUT", e.PARTICIPANT_LIMIT_REACHED = "PARTICIPANT_LIMIT_REACHED", e.FAST_START_ERROR = "FAST_START_ERROR", e.FAST_JOIN_ERROR = "FAST_JOIN_ERROR", e.CALL_TIMEOUT = "CALL_TIMEOUT", e;
1180
+ return e.CANCELED = "CANCELED", e.REJECTED = "REJECTED", e.REMOVED = "REMOVED", e.HUNGUP = "HUNGUP", e.MISSED = "MISSED", e.BUSY = "BUSY", e.FAILED = "FAILED", e.NETWORK_ERROR = "NETWORK_ERROR", e.KILLED = "KILLED", e.BANNED = "BANNED", e.HAS_ACTIVE_CALL = "HAS_ACTIVE_CALL", e.CALLER_IS_BLOCKED = "CALLER_IS_BLOCKED", e.NOT_FRIENDS = "NOT_FRIENDS", e.CALLEE_IS_OFFLINE = "CALLEE_IS_OFFLINE", e.CALLER_IS_REJECTED = "CALLER_IS_REJECTED", e.UNKNOWN_ERROR = "UNKNOWN_ERROR", e.UNSUPPORTED = "UNSUPPORTED", e.OLD_VERSION = "OLD_VERSION", e.SERVICE_DISABLED = "SERVICE_DISABLED", e.SERVICE_UNAVAILABLE = "SERVICE_UNAVAILABLE", e.EXTERNAL_API_ERROR = "EXTERNAL_API_ERROR", e.SOCKET_CLOSED = "SOCKET_CLOSED", e.ENDED = "ENDED", e.KILLED_WITHOUT_DELETE = "KILLED_WITHOUT_DELETE", e.ANOTHER_DEVICE = "ANOTHER_DEVICE", e.NOT_FOUND = "NOT_FOUND", e.VCHAT_DETAILED_ERROR = "VCHAT_DETAILED_ERROR", e.TIMEOUT = "TIMEOUT", e.PARTICIPANT_LIMIT_REACHED = "PARTICIPANT_LIMIT_REACHED", e.FAST_START_ERROR = "FAST_START_ERROR", e.FAST_JOIN_ERROR = "FAST_JOIN_ERROR", e.CALL_TIMEOUT = "CALL_TIMEOUT", e.OBSOLETE_CLIENT = "OBSOLETE_CLIENT", e;
1181
1181
  }(D || {}), O = class e extends Error {
1182
1182
  constructor(t, n) {
1183
1183
  super(), h(this, "message", void 0), h(this, "hangup", void 0), h(this, "error", void 0), h(this, "code", void 0), h(this, "remote", void 0), h(this, "custom_error", void 0), this.name = "HangupReason", this.code = n && n.code || 0, this.remote = n && n.remote || !1, this.custom_error = n?.custom_error ?? null, Object.values(D).indexOf(t) > -1 ? this.hangup = t : this.error = t;
@@ -1403,10 +1403,10 @@ var D = /* @__PURE__ */ function(e) {
1403
1403
  async stopLocalMedia() {
1404
1404
  this._mediaSettings.isScreenSharingEnabled && await this.disableScreenCapturing(), this._stream && (this._lastMediaSettings = { ...this._mediaSettings }, this._stream.getAudioTracks().length > 0 && await this.toggleAudio(!1), this._stream.getVideoTracks().length > 0 && await this.toggleVideo(!1), this.cameraVideoTrack = null, this._micAudioTrack = null);
1405
1405
  }
1406
- async resumeLocalMedia() {
1406
+ async resumeLocalMedia(e) {
1407
1407
  if (!this._lastMediaSettings) return;
1408
- let e = [];
1409
- if (this._lastMediaSettings.isAudioEnabled && (e.push(x.AUDIO), await this.toggleAudio(!0)), await this.request(e), this._lastMediaSettings = null, this._stream) for (let e of this._stream.getTracks()) this._triggerEvent("TRACK_REPLACED", e);
1408
+ let t = [];
1409
+ if ((e ? e.isAudioEnabled : this._lastMediaSettings.isAudioEnabled) && (t.push(x.AUDIO), await this.toggleAudio(!0)), await this.request(t), this._lastMediaSettings = null, this._stream) for (let e of this._stream.getTracks()) this._triggerEvent("TRACK_REPLACED", e);
1410
1410
  }
1411
1411
  async toggleScreenCapturing(e) {
1412
1412
  if (e.captureScreen) {
@@ -2159,7 +2159,7 @@ var mn = pn.getInstance(), M = class e {
2159
2159
  return 1.1;
2160
2160
  }
2161
2161
  static get sdkVersion() {
2162
- return "2.8.11-dev.e80e239d.0";
2162
+ return "2.8.11-dev.f092dc48.0";
2163
2163
  }
2164
2164
  static get debug() {
2165
2165
  return e._params.debug;
@@ -3174,6 +3174,10 @@ var R = vn, z = new class {
3174
3174
  getActive() {
3175
3175
  return this._activeId ? this._conversations.get(this._activeId) ?? null : null;
3176
3176
  }
3177
+ getFirstHeld() {
3178
+ for (let e of this._conversations.values()) if (e.isCallHeld) return e;
3179
+ return null;
3180
+ }
3177
3181
  getActiveId() {
3178
3182
  return this._activeId;
3179
3183
  }
@@ -3190,16 +3194,19 @@ var R = vn, z = new class {
3190
3194
  if (!(this._activeId === e || !this._conversations.has(e) || this._mutex)) {
3191
3195
  this._mutex = !0;
3192
3196
  try {
3193
- let t = this.getActive();
3194
- if (t) try {
3195
- await t.hold(!0);
3196
- } catch (e) {
3197
- throw R.error(`Can't hold previous active, error: ${e}`), Error("Cannot switch call: hold failed");
3197
+ let t = this.getActive(), n;
3198
+ if (t) {
3199
+ n = t.mediaSettings;
3200
+ try {
3201
+ await t.hold(!0);
3202
+ } catch (e) {
3203
+ throw R.error(`Can't hold previous active, error: ${e}`), Error("Cannot switch call: hold failed");
3204
+ }
3198
3205
  }
3199
3206
  this._conversations.has(e) && (this._activeId = e, L.onCallActive(e));
3200
- let n = this._conversations.get(e);
3201
- if (n && n?.isCallHeld) try {
3202
- await n.hold(!1);
3207
+ let r = this._conversations.get(e);
3208
+ if (r && r?.isCallHeld) try {
3209
+ await r.hold(!1, n);
3203
3210
  } catch (e) {
3204
3211
  throw R.error(`Can't hold next active, error: ${e}`), Error("Cannot switch call: hold failed");
3205
3212
  }
@@ -3208,6 +3215,25 @@ var R = vn, z = new class {
3208
3215
  }
3209
3216
  }
3210
3217
  }
3218
+ async setHold(e) {
3219
+ if (!(this._activeId !== e || !this._conversations.has(e) || this._mutex)) {
3220
+ this._mutex = !0;
3221
+ try {
3222
+ let e = this.getActive();
3223
+ if (e) try {
3224
+ await e.hold(!0);
3225
+ } catch (e) {
3226
+ throw R.error(`Can't hold previous active, error: ${e}`), Error("Cannot switch call: hold failed");
3227
+ }
3228
+ this._activeId = null;
3229
+ } finally {
3230
+ this._mutex = !1;
3231
+ }
3232
+ }
3233
+ }
3234
+ async switchCall(e) {
3235
+ this._activeId === e ? await this.setHold(e) : await this.setActive(e);
3236
+ }
3211
3237
  clear() {
3212
3238
  this._conversations.clear(), this._activeId = null;
3213
3239
  }
@@ -3853,7 +3879,7 @@ var wr = class extends y {
3853
3879
  }
3854
3880
  }, Ir = 30 * 1e3, Lr = class e extends wr {
3855
3881
  constructor(e, t, n, r, i, a = R, o = null, s = null, c = null) {
3856
- super(n, r), h(this, "_participantId", void 0), h(this, "_isMaster", void 0), h(this, "_remoteSDP", {}), h(this, "_remoteCandidates", {}), h(this, "_lastRemoteSDP", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_remoteAnimojiVersion", 1), h(this, "_isOpen", !1), h(this, "_remotePeerId", null), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_failedOnCreate", null), h(this, "_remoteStream", null), h(this, "_iceRestartTimeout", null), h(this, "_reconnectionTimeout", null), h(this, "_reconnectionPrevented", !1), h(this, "_lastStat", void 0), h(this, "_fingerprint", null), h(this, "_neverConnected", !0), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_networkLimitsForVideo", {
3882
+ super(n, r), h(this, "_participantId", void 0), h(this, "_isMaster", void 0), h(this, "_remoteSDP", {}), h(this, "_remoteCandidates", {}), h(this, "_lastRemoteSDP", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_remoteAnimojiVersion", 1), h(this, "_isOpen", !1), h(this, "_remotePeerId", null), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_failedOnCreate", null), h(this, "_remoteStream", null), h(this, "_iceRestartTimeout", null), h(this, "_reconnectionTimeout", null), h(this, "_reconnectionPrevented", !1), h(this, "_lastStat", void 0), h(this, "_fingerprint", null), h(this, "_neverConnected", !0), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_heldAudioSender", null), h(this, "_heldAudioTrack", null), h(this, "_networkLimitsForVideo", {
3857
3883
  bad: {
3858
3884
  loss: 4,
3859
3885
  rtt: 1e3
@@ -3942,6 +3968,17 @@ var wr = class extends y {
3942
3968
  allowRestart() {
3943
3969
  this._reconnectionPrevented = !1;
3944
3970
  }
3971
+ setOutgoingAudioEnabled(e) {
3972
+ if (this._pc) if (e) this._heldAudioSender && this._heldAudioTrack && (this._heldAudioSender.replaceTrack(this._heldAudioTrack).catch((e) => {
3973
+ this._debug.error("DirectTransport: Unable to restore audio track from hold", e);
3974
+ }), this._heldAudioSender = null, this._heldAudioTrack = null);
3975
+ else {
3976
+ let e = this._pc.getSenders().find((e) => e.track?.kind === "audio");
3977
+ e && e.track && (this._heldAudioSender = e, this._heldAudioTrack = e.track, e.replaceTrack(null).catch((e) => {
3978
+ this._debug.error("DirectTransport: Unable to null audio track for hold", e);
3979
+ }));
3980
+ }
3981
+ }
3945
3982
  setAnimojiTransport(e, t) {
3946
3983
  if (M.vmoji && (this._animojiReceiver = e, this._animojiSender = t, e.setParticipantId(this._participantId), this._animojiDataChannel)) {
3947
3984
  e.setDataChannel(this._animojiDataChannel), t.setDataChannel(this._animojiDataChannel);
@@ -5463,7 +5500,7 @@ var gi = 2 ** 15 - 1, _i = 1, vi = 5, yi = 5, bi = class e {
5463
5500
  }
5464
5501
  }, Zi = 90, Qi = 4294967295, $i = class e extends wr {
5465
5502
  constructor(e, t, n, r = R, i = null, a = null, o = null) {
5466
- super(e, t), 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, fr.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");
5503
+ super(e, t), 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, "_heldAudioSender", null), h(this, "_heldAudioTrack", 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, fr.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");
5467
5504
  }
5468
5505
  updateStatisticsInterval() {
5469
5506
  this._stopStatInterval();
@@ -5483,6 +5520,17 @@ var gi = 2 ** 15 - 1, _i = 1, vi = 5, yi = 5, bi = class e {
5483
5520
  removeParticipant(e) {
5484
5521
  this._captureReceiver?.close(e);
5485
5522
  }
5523
+ setOutgoingAudioEnabled(e) {
5524
+ if (this._pc) if (e) this._heldAudioSender && this._heldAudioTrack && (this._disabledSenders.delete(this._heldAudioSender), this._heldAudioSender.replaceTrack(this._heldAudioTrack).catch((e) => {
5525
+ this._debug.error("ServerTransport: Unable to restore audio track from hold", e);
5526
+ }), this._heldAudioSender = null, this._heldAudioTrack = null);
5527
+ else {
5528
+ let e = this._pc.getSenders().find((e) => e.track?.kind === k.audio && !this._disabledSenders.has(e));
5529
+ e && e.track && (this._heldAudioSender = e, this._heldAudioTrack = e.track, this._disabledSenders.add(e), e.replaceTrack(null).catch((e) => {
5530
+ this._debug.error("ServerTransport: Unable to null audio track for hold", e);
5531
+ }));
5532
+ }
5533
+ }
5486
5534
  preventRestart() {
5487
5535
  this._reconnectionPrevented = !0;
5488
5536
  }
@@ -6017,6 +6065,9 @@ var gi = 2 ** 15 - 1, _i = 1, vi = 5, yi = 5, bi = class e {
6017
6065
  for (let e of this._stListeners) e.dispose();
6018
6066
  this._removeAnimojiTransport(), M.audioEffects?.destroy(), this._directTransport?.close(), this._directTransport = null, this._serverTransport?.close(), this._serverTransport = null, this._allocated = [], this._opened = [];
6019
6067
  }
6068
+ setOutgoingAudioEnabled(e) {
6069
+ this._directTransport?.setOutgoingAudioEnabled(e), this._serverTransport?.setOutgoingAudioEnabled(e);
6070
+ }
6020
6071
  getTopology() {
6021
6072
  return this._topology;
6022
6073
  }
@@ -6454,7 +6505,7 @@ var ua = la, da = {
6454
6505
  }
6455
6506
  }, xa = class {
6456
6507
  constructor(e, t = {}) {
6457
- 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, "encoder", void 0), h(this, "decoder", void 0), h(this, "onopen", null), h(this, "onmessage", null), h(this, "onerror", null), h(this, "onclose", null), h(this, "readyState", WebSocket.CONNECTING), this.url = e, this.options = t, this.readyState = WebSocket.CONNECTING, this.compression = this.getCompressionTypeFromUrl(e), this.encoder = new ya(this.compression), this.decoder = new ba(this.compression), this.connect();
6508
+ 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, "onopen", null), h(this, "onmessage", null), h(this, "onerror", null), h(this, "onclose", null), h(this, "readyState", WebSocket.CONNECTING), this.url = e, this.options = t, this.readyState = WebSocket.CONNECTING, this.compression = this.getCompressionTypeFromUrl(e), this.encoder = new ya(this.compression), this.decoder = new ba(this.compression), this.connect();
6458
6509
  }
6459
6510
  getCompressionTypeFromUrl(e) {
6460
6511
  try {
@@ -6471,8 +6522,16 @@ var ua = la, da = {
6471
6522
  }
6472
6523
  async connect() {
6473
6524
  try {
6474
- this.webTransport = new WebTransport(this.url, { ...this.options }), await this.webTransport.ready, R.debug("[WebTransport] WebTransport connected to " + this.url), this.stream = await this.webTransport.createBidirectionalStream(), this.writer = this.stream.writable.getWriter(), this.reader = this.stream.readable.getReader(), this.readyState = WebSocket.OPEN, this.onopen?.(new Event("open")), await this.readLoop();
6525
+ if (this.webTransport = new WebTransport(this.url, { ...this.options }), await this.webTransport.ready, this.closeRequested) {
6526
+ this.closeConnectedTransport(this.closeRequested.code, this.closeRequested.reason);
6527
+ return;
6528
+ }
6529
+ R.debug("[WebTransport] WebTransport connected to " + this.url), this.stream = await this.webTransport.createBidirectionalStream(), this.writer = this.stream.writable.getWriter(), this.reader = this.stream.readable.getReader(), this.readyState = WebSocket.OPEN, this.onopen?.(new Event("open")), await this.readLoop();
6475
6530
  } catch (e) {
6531
+ if (this.closeRequested) {
6532
+ this.readyState = WebSocket.CLOSED, this.emitClose(this.closeRequested.code, this.closeRequested.reason);
6533
+ return;
6534
+ }
6476
6535
  R.error("[WebTransport] WebTransport connection failed. This will cause fallback to WebSocket", e), this.readyState = WebSocket.CLOSED, this.onerror?.(this.createErrorEvent(e, "connect")), this.onclose?.(new CloseEvent("close", {
6477
6536
  code: 1006,
6478
6537
  reason: "Connection Failed"
@@ -6530,57 +6589,197 @@ var ua = la, da = {
6530
6589
  }
6531
6590
  close(e = 1e3, t) {
6532
6591
  if (!(this.readyState === WebSocket.CLOSED || this.readyState === WebSocket.CLOSING)) {
6592
+ if (this.closeRequested = {
6593
+ code: e,
6594
+ reason: t
6595
+ }, this.readyState === WebSocket.CONNECTING) {
6596
+ this.readyState = WebSocket.CLOSING;
6597
+ return;
6598
+ }
6599
+ this.closeConnectedTransport(e, t);
6600
+ }
6601
+ }
6602
+ closeConnectedTransport(e = 1e3, t) {
6603
+ if (this.readyState !== WebSocket.CLOSED) {
6533
6604
  this.readyState = WebSocket.CLOSING, this.reader?.cancel();
6534
6605
  try {
6535
6606
  this.webTransport.close();
6536
6607
  } catch (e) {
6537
6608
  R.warn("[WebTransport] already closed. Did we get a STOP_SENDING? ignore", e);
6538
6609
  }
6539
- this.readyState = WebSocket.CLOSED, this.onclose?.(new CloseEvent("close", {
6540
- code: e,
6541
- reason: t
6542
- })), this.webTransport.closed.then(() => {
6610
+ this.readyState = WebSocket.CLOSED, this.emitClose(e, t), this.webTransport.closed.then(() => {
6543
6611
  this.writer = null, this.reader = null, this.stream = null;
6544
6612
  });
6545
6613
  }
6546
6614
  }
6615
+ emitClose(e, t) {
6616
+ this.closeEventEmitted || (this.closeEventEmitted = !0, this.onclose?.(new CloseEvent("close", {
6617
+ code: e,
6618
+ reason: t
6619
+ })));
6620
+ }
6547
6621
  static isBrowserSupported() {
6548
6622
  return "WebTransport" in window && typeof WebTransport == "function" ? T.browserName() === "Firefox" ? M.webtransportFF : T.browserName() !== "Safari" : !1;
6549
6623
  }
6550
- }, Sa = "open", Ca = 10, wa = [
6551
- "service-unavailable",
6552
- "conversation-ended",
6553
- "invalid-token"
6554
- ], Ta = class e extends yn {
6555
- static get RECONNECT_DELAY() {
6556
- return M.signalingReconnectDelay;
6624
+ }, Sa = /* @__PURE__ */ function(e) {
6625
+ return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.ABORTED = "ABORTED", e;
6626
+ }({}), Ca = class {
6627
+ constructor(e) {
6628
+ 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", pr.WEBSOCKET), this.handlers = e;
6629
+ }
6630
+ get readyState() {
6631
+ return this.socket?.readyState ?? null;
6632
+ }
6633
+ get type() {
6634
+ return this.currentType;
6635
+ }
6636
+ setEndpoint(e) {
6637
+ this.endpoint = e;
6638
+ }
6639
+ setWebTransportEndpoint(e) {
6640
+ this.wtEndpoint = e || null;
6641
+ }
6642
+ setPeerId(e) {
6643
+ this.peerId = e;
6644
+ }
6645
+ setLastStamp(e) {
6646
+ this.lastStamp = e;
6647
+ }
6648
+ setAbortSignal(e) {
6649
+ this.abortSignal = e;
6650
+ }
6651
+ resetReconnectCount() {
6652
+ this.reconnectCount = 0;
6653
+ }
6654
+ connect(e) {
6655
+ this.socket && this.socket.readyState < WebSocket.CLOSING || (e !== dr.RETRY && (this.forceWebSocket = !1, this.reconnectCount = 0), this.manualClose = !1, this.connectionType = e, this._connect());
6656
+ }
6657
+ close(e) {
6658
+ this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this.lastStamp = 0;
6659
+ }
6660
+ send(e) {
6661
+ this.socket?.send(e);
6557
6662
  }
6558
- static get RECONNECT_MAX_DELAY() {
6559
- return M.signalingReconnectMaxDelay;
6663
+ _connect() {
6664
+ if (this._canUseWebTransport()) {
6665
+ this._connectWebTransport();
6666
+ return;
6667
+ }
6668
+ this._connectWebSocket();
6669
+ }
6670
+ _connectWebTransport() {
6671
+ if (!this.wtEndpoint) {
6672
+ this._connectWebSocket();
6673
+ return;
6674
+ }
6675
+ let e = this._buildUrl(this.wtEndpoint, !0);
6676
+ this.currentType = pr.WEBTRANSPORT, this.socket = new xa(e, { congestionControl: "low-latency" }), this._setSocketHandlers();
6677
+ }
6678
+ _connectWebSocket() {
6679
+ if (!this.endpoint) {
6680
+ this.handlers.onFailed({
6681
+ failure: "EMPTY_ENDPOINT",
6682
+ message: "Unable to connect to the signaling: endpoint is not set",
6683
+ remote: !0
6684
+ });
6685
+ return;
6686
+ }
6687
+ let e = this._buildUrl(this.endpoint, !1);
6688
+ this.currentType = pr.WEBSOCKET, this.socket = new WebSocket(e), this._setSocketHandlers();
6689
+ }
6690
+ _setSocketHandlers() {
6691
+ this.socket && (this.socket.onopen = this._onOpen.bind(this), this.socket.onmessage = this._onMessage.bind(this), this.socket.onerror = this._onError.bind(this), this.socket.onclose = this._onClose.bind(this), this._startDoctor());
6692
+ }
6693
+ _buildUrl(e, t) {
6694
+ let n = new URL(e), r = n.searchParams;
6695
+ 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", fa.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();
6696
+ }
6697
+ _canUseWebTransport() {
6698
+ return !this.forceWebSocket && xa.isBrowserSupported() && this.wtEndpoint !== null && M.webtransport;
6699
+ }
6700
+ _onOpen() {
6701
+ this._startDoctor(), this.handlers.onOpen();
6702
+ }
6703
+ _onMessage(e) {
6704
+ this._startDoctor(), this.handlers.onMessage(e);
6705
+ }
6706
+ _onError(e) {
6707
+ this.handlers.onError(e);
6708
+ }
6709
+ _onClose(e) {
6710
+ if (this._stopDoctor(), this.handlers.onClose(e), !this.manualClose) {
6711
+ if (this.abortSignal?.aborted) {
6712
+ this.handlers.onFailed({
6713
+ failure: "ABORTED",
6714
+ message: "Signaling connection aborted"
6715
+ });
6716
+ return;
6717
+ }
6718
+ this.forceWebSocket = !0, this._scheduleReconnect();
6719
+ }
6720
+ }
6721
+ _disconnect(e) {
6722
+ this.socket && this.socket.readyState < WebSocket.CLOSING && (this.socket.onopen = null, this.socket.onmessage = null, this.socket.onerror = null, this.socket.onclose = null, this.socket.close(e)), this.socket = null, this._stopDoctor();
6723
+ }
6724
+ _scheduleReconnect(e = this._getReconnectDelay()) {
6725
+ if (this.reconnectCount >= M.signalingReconnectMaxCount) {
6726
+ this.handlers.onFailed({
6727
+ failure: "NETWORK_ERROR",
6728
+ message: "Unable to connect to the signaling: reconnect attempts exhausted"
6729
+ });
6730
+ return;
6731
+ }
6732
+ this.reconnectCount++, this.handlers.onReconnectScheduled({
6733
+ count: this.reconnectCount,
6734
+ delay: e
6735
+ }), this.reconnectTimer = window.setTimeout(() => {
6736
+ this.connectionType = dr.RETRY, this._connect();
6737
+ }, e);
6560
6738
  }
6561
- static get RECONNECT_MAX_COUNT() {
6562
- return M.signalingReconnectMaxCount;
6739
+ _getReconnectDelay() {
6740
+ return Math.min(M.signalingReconnectMaxDelay, M.signalingReconnectDelay * 2 ** this.reconnectCount);
6741
+ }
6742
+ _startDoctor() {
6743
+ this._stopDoctor(), !(this.reconnectCount >= M.signalingReconnectMaxCount) && (this.doctorTimer = window.setTimeout(() => {
6744
+ this.handlers.onConnectionDead(), this.forceWebSocket = !0, this._disconnect(4e3), this._scheduleReconnect(0);
6745
+ }, M.waitMessageDelay));
6563
6746
  }
6747
+ _stopDoctor() {
6748
+ window.clearTimeout(this.doctorTimer), this.doctorTimer = 0;
6749
+ }
6750
+ }, wa = "open", Ta = 10, Ea = [
6751
+ "service-unavailable",
6752
+ "conversation-ended",
6753
+ "invalid-token"
6754
+ ], Da = class e extends yn {
6564
6755
  static get WAIT_CONNECTION_DELAY() {
6565
6756
  return M.waitConnectionDelay;
6566
6757
  }
6567
6758
  static get WAIT_RESPONSE_DELAY() {
6568
6759
  return M.waitResponseDelay;
6569
6760
  }
6570
- static get WAIT_MESSAGE_DELAY() {
6571
- return M.waitMessageDelay;
6761
+ get ready() {
6762
+ return this.transport.readyState !== null;
6572
6763
  }
6573
6764
  constructor(e = R, t = null, n = null, r = null, i = null) {
6574
- super(), h(this, "socket", null), 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, "reconnectCount", 0), h(this, "endpoint", void 0), h(this, "wtEndpoint", null), 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, "reconnectTimer", 0), h(this, "connectionMessageWaitTimer", 0), h(this, "doctorTimer", 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, "_pings", void 0), h(this, "_signalingCommands", void 0), this._debug = e, this._logger = t, this._statAggregator = n, this._pings = r, this._signalingCommands = i, this.producerCommandSerializationService = new Kn(e);
6765
+ super(), h(this, "transport", new Ca({
6766
+ onOpen: this._onOpen.bind(this),
6767
+ onMessage: this._onMessage.bind(this),
6768
+ onError: this._onError.bind(this),
6769
+ onClose: this._onClose.bind(this),
6770
+ onFailed: this._onTransportFailed.bind(this),
6771
+ onReconnectScheduled: this._onTransportReconnectScheduled.bind(this),
6772
+ onConnectionDead: this._onTransportConnectionDead.bind(this)
6773
+ })), 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);
6575
6774
  }
6576
- get ready() {
6577
- return this.socket !== null;
6775
+ setAbortSignal(e) {
6776
+ super.setAbortSignal(e), this.transport.setAbortSignal(e);
6578
6777
  }
6579
6778
  setEndpoint(e) {
6580
- this.endpoint = e;
6779
+ this.transport.setEndpoint(e);
6581
6780
  }
6582
6781
  setWebTransportEndpoint(e) {
6583
- this.wtEndpoint = e;
6782
+ this.transport.setWebTransportEndpoint(e);
6584
6783
  }
6585
6784
  setConversationId(e) {
6586
6785
  this.conversationId = e;
@@ -6611,7 +6810,7 @@ var ua = la, da = {
6611
6810
  }
6612
6811
  async connect(e) {
6613
6812
  return new Promise((t, n) => {
6614
- if (this.socket && this.socket.readyState < WebSocket.CLOSING) {
6813
+ if (this.transport.readyState !== null && this.transport.readyState < WebSocket.CLOSING) {
6615
6814
  this._logger?.log(S.SOCKET_ACTION, "already_opened"), n(Error("Socket already opened"));
6616
6815
  return;
6617
6816
  }
@@ -6619,51 +6818,9 @@ var ua = la, da = {
6619
6818
  t(e), this.conversationResolve = null, this.conversationReject = null;
6620
6819
  }, this.conversationReject = (e) => {
6621
6820
  n(e), this.conversationResolve = null, this.conversationReject = null;
6622
- }, this._connect(e, this.isWebTransportAvailable());
6623
- });
6624
- }
6625
- async _send(e, t = {}, n = !0, r = 0) {
6626
- if (t.participantId) {
6627
- let e = j.decomposeParticipantId(t.participantId), n = j.decomposeId(e.compositeUserId);
6628
- t = Object.assign({}, t, {
6629
- participantId: n.id,
6630
- participantType: n.type
6631
- }), e.deviceIdx && (t.deviceIdx = e.deviceIdx);
6632
- }
6633
- return this._sendRaw(e, t, n, r);
6634
- }
6635
- async _sendRaw(e, t = {}, n = !0, r = 0) {
6636
- let i = (t) => {
6637
- if (this._isDataChannelCommand(e)) this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === Sa && this._handleCommandsQueue(this.datachannelCommandsQueue);
6638
- else {
6639
- if (!this.socket) {
6640
- 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);
6641
- return;
6642
- }
6643
- this.socket.readyState > WebSocket.OPEN && (this._logger?.log(S.SOCKET_ACTION, "invalid_state"), this._debug.warn(`[signaling] socket is not opened, state ${this.socket.readyState}`)), this.websocketCommandsQueue.push(t), this.socket && this.socket.readyState === WebSocket.OPEN && this._handleCommandsQueue(this.websocketCommandsQueue);
6644
- }
6645
- };
6646
- return new Promise((a, o) => {
6647
- let s = (t, n = !1) => {
6648
- !r || n ? o(t) : (this._debug.debug("[signaling] resending a signaling message", e, u.sequence), r--, i(u));
6649
- }, c = this.sequence++, l = `${e}_${c}`;
6650
- W.setMark(l);
6651
- let u = {
6652
- sequence: c,
6653
- name: e,
6654
- statMarkName: l,
6655
- params: t,
6656
- responseTimer: 0,
6657
- needResponse: n,
6658
- resolve: a,
6659
- reject: s
6660
- };
6661
- i(u);
6821
+ }, this.connectionType = e, this.transport.connect(e);
6662
6822
  });
6663
6823
  }
6664
- _isDataChannelCommand(e) {
6665
- return this.producerCommandDataChannelEnabled ? e === B.UPDATE_DISPLAY_LAYOUT || e === B.REPORT_PERF_STAT || e === B.REPORT_SHARING_STAT || e === B.REQUEST_ASR || e === B.ENABLE_VIDEO_SUSPEND || e === B.ENABLE_VIDEO_SUSPEND_SUGGEST || e === B.REPORT_NETWORK_STAT || e === B.CHANGE_SIMULCAST : !1;
6666
- }
6667
6824
  getNextCommandSequenceNumber() {
6668
6825
  return this.sequence;
6669
6826
  }
@@ -6687,13 +6844,13 @@ var ua = la, da = {
6687
6844
  return this._send(B.TRANSMIT_DATA, {
6688
6845
  participantId: e,
6689
6846
  data: r
6690
- }, !0, Ca);
6847
+ }, !0, Ta);
6691
6848
  }
6692
6849
  async acceptCall(e) {
6693
6850
  return this._send(B.ACCEPT_CALL, { mediaSettings: e });
6694
6851
  }
6695
6852
  async changeMediaSettings(e) {
6696
- return this._send(B.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, Ca);
6853
+ return this._send(B.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, Ta);
6697
6854
  }
6698
6855
  async changeParticipantState(e, t) {
6699
6856
  let n = { participantState: { state: e } };
@@ -6894,7 +7051,7 @@ var ua = la, da = {
6894
7051
  return this._send(B.GET_HAND_QUEUE);
6895
7052
  }
6896
7053
  close() {
6897
- this.socket && this.socket.readyState < WebSocket.CLOSING && this._closeSocket(), this._stopWaitConnectionMessage(), this._stopDoctor(), clearTimeout(this.reconnectTimer);
7054
+ this.transport.readyState !== null && this.transport.readyState < WebSocket.CLOSING && this._closeSocket(), this._stopWaitConnectionMessage();
6898
7055
  }
6899
7056
  readyToSend(e = !0) {
6900
7057
  this.listenersReady = e, this._handleCachedMessages();
@@ -6917,38 +7074,54 @@ var ua = la, da = {
6917
7074
  async requestAsr(e) {
6918
7075
  return this._send(B.REQUEST_ASR, { request: e }, !1);
6919
7076
  }
6920
- _buildUrl(e, t, n) {
6921
- let r = new URL(e), i = r.searchParams;
6922
- return i.set("platform", M.platform), i.set("appVersion", String(M.appVersion)), i.set("version", String(M.protocolVersion)), i.set("device", M.device), i.set("capabilities", fa.getFlags()), i.set("clientType", M.clientType), t && i.set("tgt", t), t === dr.RETRY && this.lastStamp && i.set("recoverTs", String(this.lastStamp)), M.useParticipantListChunk && (i.set("partIdx", String(M.participantListChunkInitIndex)), M.participantListChunkInitCount !== null && i.set("partCount", String(M.participantListChunkInitCount))), n && (i.set("compression", "deflate-raw"), i.set("ua", navigator.userAgent)), this.peerId !== null && i.set("peerId", String(this.peerId)), r.toString();
6923
- }
6924
- _connect(e, t) {
6925
- if (!(this.socket && this.socket.readyState < WebSocket.CLOSING)) {
6926
- if (this.connectionType = e, t) {
6927
- if (!this.wtEndpoint) {
6928
- this._debug.error("[signaling] empty wt endpoint"), this.conversationReject?.(new O(b.SIGNALING_FAILED, {
6929
- message: "Unable to connect to the signaling: wtEndpoint is not set",
6930
- remote: !0
6931
- }));
7077
+ async _send(e, t = {}, n = !0, r = 0) {
7078
+ if (t.participantId) {
7079
+ let e = j.decomposeParticipantId(t.participantId), n = j.decomposeId(e.compositeUserId);
7080
+ t = Object.assign({}, t, {
7081
+ participantId: n.id,
7082
+ participantType: n.type
7083
+ }), e.deviceIdx && (t.deviceIdx = e.deviceIdx);
7084
+ }
7085
+ return this._sendRaw(e, t, n, r);
7086
+ }
7087
+ async _sendRaw(e, t = {}, n = !0, r = 0) {
7088
+ let i = (t) => {
7089
+ if (this._isDataChannelCommand(e)) this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === wa && this._handleCommandsQueue(this.datachannelCommandsQueue);
7090
+ else {
7091
+ if (this.transport.readyState === null) {
7092
+ 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);
6932
7093
  return;
6933
7094
  }
6934
- let t = this._buildUrl(this.wtEndpoint, e, !0);
6935
- this._debug.debug("[signaling] connecting to wt " + t), this.socket = new xa(t, { congestionControl: "low-latency" });
6936
- } else {
6937
- let t = this._buildUrl(this.endpoint, e, !1);
6938
- this._debug.debug("[signaling] connecting to ws " + t), this.socket = new WebSocket(t);
7095
+ this.transport.readyState > WebSocket.OPEN && (this._logger?.log(S.SOCKET_ACTION, "invalid_state"), this._debug.warn(`[signaling] socket is not opened, state ${this.transport.readyState}`)), this.websocketCommandsQueue.push(t), this.transport.readyState === WebSocket.OPEN && this._handleCommandsQueue(this.websocketCommandsQueue);
6939
7096
  }
6940
- this._markTransportStat(e === dr.RETRY ? mr.RECONNECTED : mr.CONNECTED), this.socket.onopen = this._onOpen.bind(this), this.socket.onmessage = this._onMessage.bind(this), this.socket.onerror = this._onError.bind(this), this.socket.onclose = this._onClose.bind(this), this._startDoctor();
6941
- }
7097
+ };
7098
+ return new Promise((a, o) => {
7099
+ let s = (t, n = !1) => {
7100
+ !r || n ? o(t) : (this._debug.debug("[signaling] resending a signaling message", e, u.sequence), r--, i(u));
7101
+ }, c = this.sequence++, l = `${e}_${c}`;
7102
+ W.setMark(l);
7103
+ let u = {
7104
+ sequence: c,
7105
+ name: e,
7106
+ statMarkName: l,
7107
+ params: t,
7108
+ responseTimer: 0,
7109
+ needResponse: n,
7110
+ resolve: a,
7111
+ reject: s
7112
+ };
7113
+ i(u);
7114
+ });
6942
7115
  }
6943
- _disconnect(e) {
6944
- this.socket && this.socket.readyState < WebSocket.CLOSING && (this.socket.onopen = null, this.socket.onmessage = null, this.socket.onerror = null, this.socket.onclose = null, this.socket.close(e), this.socket = null), this._stopWaitConnectionMessage(), this._stopDoctor(), clearTimeout(this.reconnectTimer);
7116
+ _isDataChannelCommand(e) {
7117
+ return this.producerCommandDataChannelEnabled ? e === B.UPDATE_DISPLAY_LAYOUT || e === B.REPORT_PERF_STAT || e === B.REPORT_SHARING_STAT || e === B.REQUEST_ASR || e === B.ENABLE_VIDEO_SUSPEND || e === B.ENABLE_VIDEO_SUSPEND_SUGGEST || e === B.REPORT_NETWORK_STAT || e === B.CHANGE_SIMULCAST : !1;
6945
7118
  }
6946
7119
  _onOpen() {
6947
- this._debug.debug("[signaling] socket opened"), this._logger?.log(S.SOCKET_ACTION, "opened"), this._waitConnectionMessage(), this._startDoctor(), this._logTransportStat(this.connectionType === dr.RETRY ? mr.RECONNECTED : mr.CONNECTED);
7120
+ this._debug.debug("[signaling] socket opened"), this._logger?.log(S.SOCKET_ACTION, "opened"), this._waitConnectionMessage(), this._logTransportStat(this.connectionType === dr.RETRY ? mr.RECONNECTED : mr.CONNECTED);
6948
7121
  }
6949
7122
  _onMessage(e) {
6950
- if (this._startDoctor(), e.data === "ping") {
6951
- this._pings?.mark(this._getSocketType()), this._markTransportStat(mr.FAILED_PINGS), L.onSignalingMessage(e.data), this.socket && this.socket.readyState === WebSocket.OPEN && this.socket.send("pong");
7123
+ if (e.data === "ping") {
7124
+ this._statPings?.mark(this._getSocketType()), this._markTransportStat(mr.FAILED_PINGS), L.onSignalingMessage(e.data), this.transport.readyState === WebSocket.OPEN && this.transport.send("pong");
6952
7125
  return;
6953
7126
  }
6954
7127
  try {
@@ -6961,7 +7134,7 @@ var ua = la, da = {
6961
7134
  _handleMessage(e) {
6962
7135
  switch (e.type) {
6963
7136
  case "notification":
6964
- e.notification === "connection" ? (this._debug.debug("[signaling] signaling connected", e), this.connected = !0, this.reconnectCount = 0, this.endpoint = e.endpoint, e.peerId && this.peerId !== e.peerId.id && (this.peerId = e.peerId.id), this._stopWaitConnectionMessage(), this.conversationResolve ? this.conversationResolve(e) : (this._logTransportStat(mr.RESTART), this._triggerEvent(fr.RECONNECT, e), e.conversation.topology && this._triggerEvent(fr.NOTIFICATION, {
7137
+ e.notification === "connection" ? (this._debug.debug("[signaling] signaling connected", e), this.connected = !0, this.transport.resetReconnectCount(), this.transport.setEndpoint(e.endpoint), e.peerId && this.peerId !== e.peerId.id && (this.peerId = e.peerId.id, this.transport.setPeerId(e.peerId.id)), this._stopWaitConnectionMessage(), this.conversationResolve ? this.conversationResolve(e) : (this._logTransportStat(mr.RESTART), this._triggerEvent(fr.RECONNECT, e), e.conversation.topology && this._triggerEvent(fr.NOTIFICATION, {
6965
7138
  type: "notification",
6966
7139
  notification: G.TOPOLOGY_CHANGED,
6967
7140
  topology: e.conversation.topology
@@ -6977,11 +7150,11 @@ var ua = la, da = {
6977
7150
  break;
6978
7151
  default: this._logger?.log(S.SOCKET_ACTION, "unknown_message"), this._debug.warn("[signaling] unhandled message", e);
6979
7152
  }
6980
- this.lastStamp = e.stamp || this.lastStamp;
7153
+ e.stamp && (this.lastStamp = e.stamp, this.transport.setLastStamp(e.stamp));
6981
7154
  }
6982
7155
  _handleErrorMessage(e) {
6983
7156
  this._logger?.log(S.SOCKET_ACTION, `error-${e.error}`);
6984
- let t = e.error ? wa.includes(e.error) : !1;
7157
+ let t = e.error ? Ea.includes(e.error) : !1;
6985
7158
  switch (this._debug.debug(`[signaling] error message [${e.sequence}]`, e), e.sequence && this.responseHandlers[e.sequence] && this._handleCommandResponse(!1, e), e.error) {
6986
7159
  case "service-unavailable":
6987
7160
  let n = new O(D.SERVICE_UNAVAILABLE, {
@@ -7005,6 +7178,12 @@ var ua = la, da = {
7005
7178
  case "participant-not-found":
7006
7179
  this._throwError(/* @__PURE__ */ Error(`Signaling error: ${e.error}`));
7007
7180
  break;
7181
+ case "gen.obsoleteClient":
7182
+ this.conversationReject?.(new O(e.reason || D.OBSOLETE_CLIENT, {
7183
+ message: e.code || e.error,
7184
+ remote: !0
7185
+ }));
7186
+ break;
7008
7187
  default:
7009
7188
  if (!t) break;
7010
7189
  this.connected ? this._throwError(/* @__PURE__ */ Error(`Signaling error: ${e.error}`)) : e.sequence || (this.conversationReject?.(new O(e.reason || b.SIGNALING_FAILED, {
@@ -7031,44 +7210,36 @@ var ua = la, da = {
7031
7210
  return JSON.stringify({
7032
7211
  eventType: e.type,
7033
7212
  socketType: this._getSocketType(),
7034
- readyState: this.socket?.readyState,
7213
+ readyState: this.transport.readyState,
7035
7214
  errorName: n?.name || t.errorInfo?.name,
7036
7215
  errorMessage: n?.message || t.errorInfo?.message || t.message,
7037
7216
  errorStack: n?.stack || t.errorInfo?.stack,
7038
7217
  errorInfo: t.errorInfo
7039
7218
  });
7040
7219
  }
7041
- _onClose(t) {
7042
- if (this._logger?.log(S.SOCKET_ACTION, "closed"), this._debug.debug("[signaling] connection closed", {
7043
- code: t.code,
7044
- reason: t.reason
7045
- }), this.connected = !1, this._stopDoctor(), this.socket && this._abortSignal?.aborted) {
7046
- this._debug.debug("[signaling] aborted reconnect"), this._closeSocket(new O(D.CANCELED));
7047
- return;
7048
- }
7049
- this.socket && this.reconnectCount++ < e.RECONNECT_MAX_COUNT ? this._reconnect() : this.socket && this._closeSocket(new O(D.NETWORK_ERROR));
7220
+ _onClose(e) {
7221
+ this._logger?.log(S.SOCKET_ACTION, "closed"), this._debug.debug("[signaling] connection closed", {
7222
+ code: e.code,
7223
+ reason: e.reason
7224
+ }), this.connected = !1;
7050
7225
  }
7051
7226
  _closeSocket(e = null) {
7052
- this.socket && (this._disconnect(), Object.values(this.responseHandlers).forEach((t) => {
7227
+ this.transport.readyState !== null && (this.transport.close(), this._stopWaitConnectionMessage(), Object.values(this.responseHandlers).forEach((t) => {
7053
7228
  window.clearTimeout(t.responseTimer), e && t.reject(/* @__PURE__ */ Error(`Connection closed. Command ${t.name}`), !0);
7054
7229
  }), this.websocketCommandsQueue = [], this.responseHandlers = {}, this.lastStamp = 0, e && this._throwError(e));
7055
7230
  }
7056
- _reconnect() {
7057
- let t = Math.min(e.RECONNECT_MAX_DELAY, e.RECONNECT_DELAY * 2 ** (this.reconnectCount - 1));
7058
- this._debug.log(`[signaling] reconnect websocket after ${t}ms (${this.reconnectCount})`), this._logger?.log(S.SOCKET_ACTION, "reconnect"), this.reconnectTimer = window.setTimeout(this._connect.bind(this, dr.RETRY, !1), t);
7059
- }
7060
7231
  _handleCommandResponse(t, n) {
7061
7232
  if (!Object.hasOwn(this.responseHandlers, n.sequence)) return;
7062
7233
  let r = this.responseHandlers[n.sequence];
7063
7234
  window.clearTimeout(r.responseTimer);
7064
7235
  let i = W.measureMark(r.statMarkName);
7065
- i !== null && this._signalingCommands?.mark(r.name, i, this._getSocketType()), this._debug.debug(`[signaling] command response [${n.sequence}]`, n), t ? (delete this.responseHandlers[n.sequence], r.resolve(n)) : n.type === "error" ? (delete this.responseHandlers[n.sequence], this._logger?.log(S.SOCKET_ACTION, "response-error"), r.reject(Error(n.error || `Response error [${r.name}]`), !0)) : this.socket?.readyState === WebSocket.OPEN ? (delete this.responseHandlers[n.sequence], this._logger?.log(S.SOCKET_ACTION, "response-timeout"), r.reject(Error(n.error || `Response timeout [${r.name}]`))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
7236
+ i !== null && this._statSignalingCommands?.mark(r.name, i, this._getSocketType()), this._debug.debug(`[signaling] command response [${n.sequence}]`, n), t ? (delete this.responseHandlers[n.sequence], r.resolve(n)) : n.type === "error" ? (delete this.responseHandlers[n.sequence], this._logger?.log(S.SOCKET_ACTION, "response-error"), r.reject(Error(n.error || `Response error [${r.name}]`), !0)) : this.transport.readyState === WebSocket.OPEN ? (delete this.responseHandlers[n.sequence], this._logger?.log(S.SOCKET_ACTION, "response-timeout"), r.reject(Error(n.error || `Response timeout [${r.name}]`))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
7066
7237
  }
7067
7238
  _handleCommandsQueue(e) {
7068
7239
  for (; e.length > 0;) {
7069
7240
  let t = e.shift();
7070
7241
  if (this._debug.debug(`[signaling] command send [${t.sequence}]`, `'${t.name}'`, t.params), this._isDataChannelCommand(t.name)) {
7071
- if (this.producerCommandDataChannel?.readyState !== Sa) {
7242
+ if (this.producerCommandDataChannel?.readyState !== wa) {
7072
7243
  t.reject(/* @__PURE__ */ Error(`Invalid data channel state: ${this.producerCommandDataChannel?.readyState}`));
7073
7244
  return;
7074
7245
  }
@@ -7076,11 +7247,11 @@ var ua = la, da = {
7076
7247
  let e = this._serializeBinary(t);
7077
7248
  e !== null && this.producerCommandDataChannel.send(e);
7078
7249
  } else {
7079
- if (!this.socket || this.socket.readyState !== WebSocket.OPEN) {
7250
+ if (this.transport.readyState !== WebSocket.OPEN) {
7080
7251
  t.reject(/* @__PURE__ */ Error("Invalid state or socket already closed"));
7081
7252
  continue;
7082
7253
  }
7083
- this._startResponseTimer(t), this.socket.send(this._serializeJson(t));
7254
+ this._startResponseTimer(t), this.transport.send(this._serializeJson(t));
7084
7255
  }
7085
7256
  }
7086
7257
  }
@@ -7137,19 +7308,30 @@ var ua = la, da = {
7137
7308
  _stopWaitConnectionMessage() {
7138
7309
  window.clearTimeout(this.connectionMessageWaitTimer), this.connectionMessageWaitTimer = 0;
7139
7310
  }
7140
- _startDoctor() {
7141
- this._stopDoctor(), !(this.reconnectCount >= e.RECONNECT_MAX_COUNT) && (this.doctorTimer = window.setTimeout(() => {
7142
- this.isWebTransportAvailable() ? this._debug.warn(`[signaling] socket is dead. Fallback to WebSocket. Trying to connect ${this.reconnectCount}`) : this._debug.warn(`[signaling] socket is dead, trying to reconnect ${this.reconnectCount}`), this._logTransportStat(mr.FAILED_PINGS), this._disconnect(4e3), this._connect(dr.RETRY, !1), this.reconnectCount++;
7143
- }, e.WAIT_MESSAGE_DELAY));
7311
+ _onTransportFailed(e) {
7312
+ switch (e.failure) {
7313
+ case Sa.EMPTY_ENDPOINT:
7314
+ this.conversationReject?.(new O(b.SIGNALING_FAILED, {
7315
+ message: e.message,
7316
+ remote: e.remote
7317
+ }));
7318
+ break;
7319
+ case Sa.NETWORK_ERROR:
7320
+ this._closeSocket(new O(D.NETWORK_ERROR));
7321
+ break;
7322
+ case Sa.ABORTED:
7323
+ this._debug.debug("[signaling] aborted reconnect"), this._closeSocket(new O(D.CANCELED));
7324
+ break;
7325
+ }
7144
7326
  }
7145
- _stopDoctor() {
7146
- window.clearTimeout(this.doctorTimer), this.doctorTimer = 0;
7327
+ _onTransportReconnectScheduled(e) {
7328
+ this.connectionType = dr.RETRY, this._debug.log(`[signaling] reconnect websocket after ${e.delay}ms (${e.count})`), this._logger?.log(S.SOCKET_ACTION, "reconnect");
7147
7329
  }
7148
- isWebTransportAvailable() {
7149
- return xa.isBrowserSupported() && this.wtEndpoint !== null && M.webtransport;
7330
+ _onTransportConnectionDead() {
7331
+ this._debug.warn("[signaling] socket is dead, trying to reconnect"), this._logTransportStat(mr.FAILED_PINGS);
7150
7332
  }
7151
7333
  _getSocketType() {
7152
- return this.socket instanceof xa ? pr.WEBTRANSPORT : pr.WEBSOCKET;
7334
+ return this.transport.type;
7153
7335
  }
7154
7336
  _markTransportStat(e) {
7155
7337
  let t = this._getSocketType(), n = hr[e][t];
@@ -7164,37 +7346,37 @@ var ua = la, da = {
7164
7346
  }
7165
7347
  }, Y = /* @__PURE__ */ function(e) {
7166
7348
  return e.INCOMING = "INCOMING", e.OUTGOING = "OUTGOING", e.JOINING = "JOINING", e;
7167
- }(Y || {}), Ea = /* @__PURE__ */ function(e) {
7349
+ }(Y || {}), Oa = /* @__PURE__ */ function(e) {
7168
7350
  return e.USER = "USER", e.GROUP = "GROUP", e.CHAT = "CHAT", e;
7169
- }(Ea || {}), Da = /* @__PURE__ */ function(e) {
7351
+ }(Oa || {}), ka = /* @__PURE__ */ function(e) {
7170
7352
  return e.ATTENDEE = "ATTENDEE", e.HAND_UP = "HAND_UP", e;
7171
- }(Da || {}), Oa = /* @__PURE__ */ function(e) {
7353
+ }(ka || {}), Aa = /* @__PURE__ */ function(e) {
7172
7354
  return e.ADD_PARTICIPANT = "ADD_PARTICIPANT", e.RECORD = "RECORD", e.MOVIE_SHARE = "MOVIE_SHARE", e;
7173
- }(Oa || {}), ka = /* @__PURE__ */ function(e) {
7355
+ }(Aa || {}), ja = /* @__PURE__ */ function(e) {
7174
7356
  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;
7175
- }(ka || {});
7176
- function Aa(e, t) {
7357
+ }(ja || {});
7358
+ function Ma(e, t) {
7177
7359
  if (e.length !== t.length) return !1;
7178
7360
  for (let n of e) if (!t.includes(n)) return !1;
7179
7361
  return !0;
7180
7362
  }
7181
- function ja(e, t) {
7363
+ function Na(e, t) {
7182
7364
  let n = new Set(e);
7183
7365
  for (let [e, r] of Object.entries(t)) r ? n.add(e) : n.delete(e);
7184
7366
  return Array.from(n);
7185
7367
  }
7186
7368
  //#endregion
7187
7369
  //#region src/enums/MuteState.ts
7188
- var Ma = /* @__PURE__ */ function(e) {
7370
+ var Pa = /* @__PURE__ */ function(e) {
7189
7371
  return e.UNMUTE = "UNMUTE", e.MUTE = "MUTE", e.MUTE_PERMANENT = "MUTE_PERMANENT", e;
7190
- }(Ma || {}), X = /* @__PURE__ */ function(e) {
7372
+ }(Pa || {}), X = /* @__PURE__ */ function(e) {
7191
7373
  return e.CALLED = "CALLED", e.ACCEPTED = "ACCEPTED", e.REJECTED = "REJECTED", e.HUNGUP = "HUNGUP", e;
7192
- }(X || {}), Na = /* @__PURE__ */ function(e) {
7374
+ }(X || {}), Fa = /* @__PURE__ */ function(e) {
7193
7375
  return e.UPDATE = "UPDATE", e.REMOVE = "REMOVE", e.ACTIVATE = "ACTIVATE", e.TIMEOUT = "TIMEOUT", e;
7194
- }(Na || {}), Pa = /* @__PURE__ */ function(e) {
7376
+ }(Fa || {}), Ia = /* @__PURE__ */ function(e) {
7195
7377
  return e.NO_AVAILABLE_TRACKS = "no-available-tracks", e.UNKNOWN_ERROR = "unknown-error", e;
7196
- }(Pa || {});
7197
- function Fa(e) {
7378
+ }(Ia || {});
7379
+ function La(e) {
7198
7380
  switch (e) {
7199
7381
  case 1: return "no-available-tracks";
7200
7382
  default: return "unknown-error";
@@ -7202,17 +7384,17 @@ function Fa(e) {
7202
7384
  }
7203
7385
  //#endregion
7204
7386
  //#region src/enums/UserRole.ts
7205
- var Ia = /* @__PURE__ */ function(e) {
7387
+ var Ra = /* @__PURE__ */ function(e) {
7206
7388
  return e.CREATOR = "CREATOR", e.ADMIN = "ADMIN", e;
7207
- }(Ia || {});
7208
- function La(e, t) {
7389
+ }(Ra || {});
7390
+ function za(e, t) {
7209
7391
  if (e.length !== t.length) return !1;
7210
7392
  for (let n of e) if (!t.includes(n)) return !1;
7211
7393
  return !0;
7212
7394
  }
7213
7395
  //#endregion
7214
7396
  //#region src/types/ExternalId.ts
7215
- var Ra = /* @__PURE__ */ function(e) {
7397
+ var Ba = /* @__PURE__ */ function(e) {
7216
7398
  return e.USER = "USER", e.ANONYM = "ANONYM", e.GROUP = "GROUP", e;
7217
7399
  }({}), Z;
7218
7400
  (function(e) {
@@ -7273,7 +7455,7 @@ var Ra = /* @__PURE__ */ function(e) {
7273
7455
  })(Z || (Z = {}));
7274
7456
  //#endregion
7275
7457
  //#region src/types/WaitingHall.ts
7276
- function za(e) {
7458
+ function Va(e) {
7277
7459
  try {
7278
7460
  return btoa(JSON.stringify(e));
7279
7461
  } catch (t) {
@@ -7281,7 +7463,7 @@ function za(e) {
7281
7463
  }
7282
7464
  return null;
7283
7465
  }
7284
- function Ba(e) {
7466
+ function Ha(e) {
7285
7467
  try {
7286
7468
  return JSON.parse(atob(e));
7287
7469
  } catch (t) {
@@ -7291,12 +7473,12 @@ function Ba(e) {
7291
7473
  }
7292
7474
  //#endregion
7293
7475
  //#region src/utils/Conversation.ts
7294
- var Va = (e, t) => j.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
7295
- function Ha(e) {
7476
+ var Ua = (e, t) => j.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
7477
+ function Wa(e) {
7296
7478
  if (e.conversation?.muteStates) return e.conversation.muteStates;
7297
7479
  if (e.muteState && e.muteOptions) return e.muteOptions.reduce((t, n) => (t[n] = e.muteState, t), {});
7298
7480
  }
7299
- function Ua(e, t) {
7481
+ function Ga(e, t) {
7300
7482
  switch (e) {
7301
7483
  case x.AUDIO: return !!t.isAudioEnabled;
7302
7484
  case x.AUDIO_SHARING: return !!t.isAudioSharingEnabled;
@@ -7305,12 +7487,12 @@ function Ua(e, t) {
7305
7487
  default: return !1;
7306
7488
  }
7307
7489
  }
7308
- function Wa(e, t) {
7490
+ function Ka(e, t) {
7309
7491
  return j.objectReduce(e, (e, n, r) => {
7310
7492
  switch (n) {
7311
- case Ma.MUTE:
7312
- case Ma.MUTE_PERMANENT:
7313
- Ua(r, t) || (e[r] = n);
7493
+ case Pa.MUTE:
7494
+ case Pa.MUTE_PERMANENT:
7495
+ Ga(r, t) || (e[r] = n);
7314
7496
  break;
7315
7497
  default:
7316
7498
  e[r] = n;
@@ -7319,19 +7501,19 @@ function Wa(e, t) {
7319
7501
  return e;
7320
7502
  }, {});
7321
7503
  }
7322
- function Ga(e) {
7504
+ function qa(e) {
7323
7505
  let { muteStates: t = {}, mediaSettings: n } = e;
7324
- return Wa(t, n);
7506
+ return Ka(t, n);
7325
7507
  }
7326
- function Ka(e, t) {
7508
+ function Ja(e, t) {
7327
7509
  let n = e.conversation.participants.find((t) => j.comparePeerId(t.peerId, e.peerId));
7328
7510
  if (!n) return t;
7329
7511
  let { mediaSettings: r } = n;
7330
- return Wa(t, r);
7512
+ return Ka(t, r);
7331
7513
  }
7332
7514
  //#endregion
7333
7515
  //#region src/utils/Lz4.ts
7334
- function qa(e, t) {
7516
+ function Ya(e, t) {
7335
7517
  let n = new Uint8Array(t), r = 0, i = 0;
7336
7518
  for (; r < e.length && i < t;) {
7337
7519
  let a = e[r++], o = a >> 4, s = a & 15;
@@ -7358,12 +7540,12 @@ function qa(e, t) {
7358
7540
  }
7359
7541
  //#endregion
7360
7542
  //#region src/classes/AudioFix.ts
7361
- var Ja = class {
7543
+ var Xa = class {
7362
7544
  constructor(e, t = R, n = null) {
7363
- 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;
7545
+ 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), h(this, "_disabled", !1), this._mediaSource = e, this._debug = t, this._logger = n;
7364
7546
  }
7365
7547
  _fixAudioDeviceNoPackets(e) {
7366
- if (!(this._fixNoPacketsApplied && this._fixNoPacketsChecked)) {
7548
+ if (!this._disabled && !(this._fixNoPacketsApplied && this._fixNoPacketsChecked)) {
7367
7549
  if (this._fixNoPacketsApplied && !this._fixNoPacketsChecked) {
7368
7550
  this._fixNoPacketsChecked = !0, this._logger?.log(S.ERROR, `audio_device_recover_${e.bandwidth ? "success" : "fail"}`);
7369
7551
  return;
@@ -7372,7 +7554,7 @@ var Ja = class {
7372
7554
  }
7373
7555
  }
7374
7556
  _fixAudioDeviceTooManyPackets(e) {
7375
- if (this._fixTooManyPacketsSucceeded || this._fixTooManyPacketsFailed) return;
7557
+ if (this._disabled || this._fixTooManyPacketsSucceeded || this._fixTooManyPacketsFailed) return;
7376
7558
  let t = Date.now();
7377
7559
  if (!this._lastPacketsSentTime) e.packetsSent > 0 && (this._lastPacketsSentTime = t, this._lastPacketsSent = e.packetsSent);
7378
7560
  else if (t - this._lastPacketsSentTime > 500) {
@@ -7383,7 +7565,7 @@ var Ja = class {
7383
7565
  }
7384
7566
  }
7385
7567
  fix(e) {
7386
- if (!this._mediaSource) return;
7568
+ if (this._disabled || !this._mediaSource) return;
7387
7569
  let t = e.find((e) => e.kind === k.audio);
7388
7570
  t && (this._fixAudioDeviceNoPackets(t), this._fixAudioDeviceTooManyPackets(t));
7389
7571
  }
@@ -7396,7 +7578,10 @@ var Ja = class {
7396
7578
  this._debug.warn("[AudioFix] Failed to fix RV (no packets): video restart", e);
7397
7579
  }));
7398
7580
  }
7399
- }, Ya = class {
7581
+ disable() {
7582
+ this._disabled = !0;
7583
+ }
7584
+ }, Za = class {
7400
7585
  constructor(e, t = !1, n = R, r = null) {
7401
7586
  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;
7402
7587
  }
@@ -7481,7 +7666,21 @@ var Ja = class {
7481
7666
  for (let e of this._audioTracks.values()) this._removeTrackFromAudioElement(e), e.stop();
7482
7667
  this._audioTracks.clear();
7483
7668
  }
7484
- }, Xa = 90, Za = 3, Qa = class extends y {
7669
+ };
7670
+ //#endregion
7671
+ //#region src/classes/ConversationResponseValidator.ts
7672
+ function Qa(e, t) {
7673
+ e || eo(t, "response is empty"), e.id || eo(t, "id is empty"), e.endpoint || eo(t, "endpoint is empty"), !$a(e.stun_server) && !$a(e.turn_server) && eo(t, "ice servers are empty");
7674
+ }
7675
+ function $a(e) {
7676
+ return Array.isArray(e?.urls) && e.urls.length > 0;
7677
+ }
7678
+ function eo(e, t) {
7679
+ throw new O(D.UNKNOWN_ERROR, { message: `Invalid ${e} response: ${t}` });
7680
+ }
7681
+ //#endregion
7682
+ //#region src/classes/DebugInfo.ts
7683
+ var to = 90, no = 3, ro = class extends y {
7485
7684
  constructor(e = R) {
7486
7685
  super(), h(this, "_lastMemoryStat", {
7487
7686
  percent: 0,
@@ -7497,9 +7696,9 @@ var Ja = class {
7497
7696
  let e = window?.performance?.memory;
7498
7697
  if (!e || !e.usedJSHeapSize || !e.jsHeapSizeLimit) return;
7499
7698
  let t = Number((100 * e.usedJSHeapSize / e.jsHeapSizeLimit).toFixed(2)), n = Number((e.usedJSHeapSize / 1024 / 1024).toFixed(1));
7500
- t > Xa ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= Za) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
7699
+ t > to ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= no) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
7501
7700
  }
7502
- }, $a = class {
7701
+ }, io = class {
7503
7702
  constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i }) {
7504
7703
  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;
7505
7704
  }
@@ -7609,7 +7808,7 @@ var Ja = class {
7609
7808
  let n = e, r = t;
7610
7809
  return n.width !== r.width || n.height !== r.height || n.fit !== r.fit || n.priority !== r.priority;
7611
7810
  }
7612
- }, eo = 44100, to = class {
7811
+ }, ao = 44100, oo = class {
7613
7812
  constructor(e, t) {
7614
7813
  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]);
7615
7814
  try {
@@ -7626,7 +7825,7 @@ var Ja = class {
7626
7825
  _getBins() {
7627
7826
  if (!this._fftBins || !this._analyser) return new Uint8Array();
7628
7827
  this._analyser.getByteFrequencyData(this._fftBins);
7629
- let e = eo / this._fftBins.length, t = Math.ceil(M.voiceParams.minFreq / e), n = Math.floor(M.voiceParams.maxFreq / e);
7828
+ let e = ao / this._fftBins.length, t = Math.ceil(M.voiceParams.minFreq / e), n = Math.floor(M.voiceParams.maxFreq / e);
7630
7829
  return this._fftBins.subarray(t, n);
7631
7830
  }
7632
7831
  getLevel() {
@@ -7639,7 +7838,7 @@ var Ja = class {
7639
7838
  destroy() {
7640
7839
  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);
7641
7840
  }
7642
- }, no = class extends y {
7841
+ }, so = class extends y {
7643
7842
  constructor(e) {
7644
7843
  super(), h(this, "_detector", null), h(this, "_interval", null);
7645
7844
  let t = () => {
@@ -7655,7 +7854,7 @@ var Ja = class {
7655
7854
  }), this.subscribe(e, Kt.SOURCE_READY, n), n();
7656
7855
  }
7657
7856
  init(e) {
7658
- this._stopDetector(), this._detector = new to("local", e.clone());
7857
+ this._stopDetector(), this._detector = new oo("local", e.clone());
7659
7858
  }
7660
7859
  _stopDetector() {
7661
7860
  this._detector && (this._detector.track.stop(), this._detector.destroy(), this._detector = null);
@@ -7663,7 +7862,7 @@ var Ja = class {
7663
7862
  destroy() {
7664
7863
  this.unsubscribe(), this._interval && (window.clearTimeout(this._interval), this._interval = null), this._stopDetector();
7665
7864
  }
7666
- }, ro = class {
7865
+ }, co = class {
7667
7866
  constructor(e, t = R) {
7668
7867
  h(this, "processor", void 0), h(this, "queue", []), h(this, "isProcessing", !1), h(this, "_debug", void 0), this.processor = e, this._debug = t;
7669
7868
  }
@@ -7683,9 +7882,9 @@ var Ja = class {
7683
7882
  this.isProcessing = !1;
7684
7883
  }
7685
7884
  }
7686
- }, io = /* @__PURE__ */ function(e) {
7885
+ }, lo = /* @__PURE__ */ function(e) {
7687
7886
  return e.VOLUMES_DETECTED = "VOLUMES_DETECTED", e;
7688
- }({}), ao = class extends y {
7887
+ }({}), uo = class extends y {
7689
7888
  constructor(e) {
7690
7889
  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, J.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(e, J.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(e, J.SIGNALLED_ACTIVE_PARTICIPANTS, this._onSignalledActiveParticipants.bind(this)), this.subscribe(e, J.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
7691
7890
  }
@@ -7693,7 +7892,7 @@ var Ja = class {
7693
7892
  this._interval && (window.clearTimeout(this._interval), this._interval = null), this.unsubscribe(), this._destroyDetectors();
7694
7893
  }
7695
7894
  _onRemoteTrackAdded(e, t, n) {
7696
- if (n.kind === k.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new to(e, n)), !this._interval)) {
7895
+ if (n.kind === k.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new oo(e, n)), !this._interval)) {
7697
7896
  let e = () => {
7698
7897
  this._collectVolumes(), this._interval = window.setTimeout(e, M.voiceParams.interval);
7699
7898
  };
@@ -7751,11 +7950,11 @@ var Ja = class {
7751
7950
  e.destroy();
7752
7951
  }), this._detectors.clear();
7753
7952
  }
7754
- }, oo = /* @__PURE__ */ function(e) {
7953
+ }, fo = /* @__PURE__ */ function(e) {
7755
7954
  return e.SPEAKER_CHANGED = "SPEAKER_CHANGED", e;
7756
- }({}), so = class extends y {
7955
+ }({}), po = class extends y {
7757
7956
  constructor(e, t, n) {
7758
- super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === q.SERVER, this.subscribe(e, io.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, J.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, J.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
7957
+ super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === q.SERVER, this.subscribe(e, lo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, J.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, J.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
7759
7958
  }
7760
7959
  destroy() {
7761
7960
  this.unsubscribe();
@@ -7777,9 +7976,9 @@ var Ja = class {
7777
7976
  _onTopologyChanged(e) {
7778
7977
  this._serverSideSpeakerDetection = e === q.SERVER;
7779
7978
  }
7780
- }, co = 15e3, lo = 15e3, uo = class extends y {
7979
+ }, mo = 15e3, ho = 15e3, go = class extends y {
7781
7980
  constructor(e, t, n, r = R, i = null) {
7782
- 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, J.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, io.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
7981
+ 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, J.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, lo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
7783
7982
  }
7784
7983
  destroy() {
7785
7984
  this.unsubscribe(), this._connectionTimeout && window.clearTimeout(this._connectionTimeout), this._volumeTimeout && window.clearTimeout(this._volumeTimeout);
@@ -7791,10 +7990,10 @@ var Ja = class {
7791
7990
  this._connectionTimeout || !this._connectionTimeoutSuppressed || this._reportConnectionTimeout();
7792
7991
  }
7793
7992
  _getConnectionTimeout() {
7794
- return this._transport.getTopology() === q.DIRECT ? co : M.specListenerParams.connectionTimeout;
7993
+ return this._transport.getTopology() === q.DIRECT ? mo : M.specListenerParams.connectionTimeout;
7795
7994
  }
7796
7995
  _getVolumeTimeout() {
7797
- return this._transport.getTopology() === q.DIRECT ? lo : M.specListenerParams.volumeTimeout;
7996
+ return this._transport.getTopology() === q.DIRECT ? ho : M.specListenerParams.volumeTimeout;
7798
7997
  }
7799
7998
  _onTransportStateChanged(e, t) {
7800
7999
  t === K.OPENED && (this._connectionTimeout || (this._connectionTimeoutSuppressed = !1, this._connectionTimeout = window.setTimeout(this._onConnectionTimeout.bind(this), this._getConnectionTimeout()))), t === K.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 === K.FAILED && this._connectionTimeout && (this._debug.warn("Transport failed, send callSpecError"), this._logger?.log(S.CALL_SPEC_ERROR, `${this._transport.getTopology()}_CONNECTION_TIMEOUT`));
@@ -7827,7 +8026,7 @@ var Ja = class {
7827
8026
  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}`));
7828
8027
  }), e.length && this._debug.warn("There is silent participant, send callSpecError"), this._volumeTimeout = 0;
7829
8028
  }
7830
- }, fo = class extends f {
8029
+ }, _o = class extends f {
7831
8030
  constructor(e, t, n) {
7832
8031
  super(), h(this, "_externalLogger", void 0), h(this, "_api", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_batchInterval", 3e3), h(this, "_batchedClientStats", []), h(this, "_batchedClientEvents", []), h(this, "_batchTimeout", null), h(this, "_serverTimeDelta", 0), this._api = e, this._externalLogger = t, this._conversationIdProvider = n, this._calculateServerTimeDelta();
7833
8032
  }
@@ -7886,7 +8085,7 @@ var Ja = class {
7886
8085
  _now() {
7887
8086
  return Date.now() - this._serverTimeDelta;
7888
8087
  }
7889
- }, po = class {
8088
+ }, vo = class {
7890
8089
  constructor(e, t) {
7891
8090
  h(this, "_logger", void 0), h(this, "_codecUsages", /* @__PURE__ */ new Map()), h(this, "getCurrentTransportTopology", void 0), this._logger = e, this.getCurrentTransportTopology = t;
7892
8091
  }
@@ -7949,7 +8148,7 @@ var Ja = class {
7949
8148
  this.report(e);
7950
8149
  }), this._codecUsages.clear();
7951
8150
  }
7952
- }, mo = class {
8151
+ }, yo = class {
7953
8152
  constructor(e) {
7954
8153
  h(this, "_logger", void 0), h(this, "_eventualLogs", /* @__PURE__ */ new Set()), this._logger = e;
7955
8154
  }
@@ -7974,7 +8173,7 @@ var Ja = class {
7974
8173
  destroy() {
7975
8174
  this._eventualLogs.clear();
7976
8175
  }
7977
- }, ho = class {
8176
+ }, bo = class {
7978
8177
  constructor(e) {
7979
8178
  if (h(this, "q", void 0), h(this, "inits", []), h(this, "n", [
7980
8179
  1,
@@ -8033,7 +8232,7 @@ var Ja = class {
8033
8232
  5
8034
8233
  ];
8035
8234
  }
8036
- }, go = class {
8235
+ }, xo = class {
8037
8236
  constructor() {
8038
8237
  h(this, "n", 0), h(this, "mean", 0);
8039
8238
  }
@@ -8045,9 +8244,9 @@ var Ja = class {
8045
8244
  get avg() {
8046
8245
  return this.n ? this.mean : NaN;
8047
8246
  }
8048
- }, _o = class {
8247
+ }, So = class {
8049
8248
  constructor() {
8050
- h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new go()), h(this, "p50", new ho(.5)), h(this, "p95", new ho(.95));
8249
+ h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new xo()), h(this, "p50", new bo(.5)), h(this, "p95", new bo(.95));
8051
8250
  }
8052
8251
  add(e) {
8053
8252
  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++;
@@ -8065,11 +8264,11 @@ var Ja = class {
8065
8264
  get hasData() {
8066
8265
  return this.count > 0;
8067
8266
  }
8068
- }, vo = class {
8267
+ }, Co = class {
8069
8268
  constructor(e) {
8070
8269
  h(this, "_logger", void 0), h(this, "trackerByTransport", {
8071
- ws: new _o(),
8072
- wt: new _o()
8270
+ ws: new So(),
8271
+ wt: new So()
8073
8272
  }), h(this, "lastSeen", {}), this._logger = e;
8074
8273
  }
8075
8274
  mark(e) {
@@ -8099,17 +8298,17 @@ var Ja = class {
8099
8298
  }
8100
8299
  destroy() {
8101
8300
  this.trackerByTransport = {
8102
- ws: new _o(),
8103
- wt: new _o()
8301
+ ws: new So(),
8302
+ wt: new So()
8104
8303
  }, this.lastSeen = {};
8105
8304
  }
8106
- }, yo = class {
8305
+ }, wo = class {
8107
8306
  constructor(e) {
8108
8307
  h(this, "_logger", void 0), h(this, "trackerByCommand", /* @__PURE__ */ new Map()), this._logger = e;
8109
8308
  }
8110
8309
  mark(e, t, n) {
8111
8310
  let r = `${e}|${n}`, i;
8112
- this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new _o(), this.trackerByCommand.set(r, i)), i.add(t);
8311
+ this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new So(), this.trackerByCommand.set(r, i)), i.add(t);
8113
8312
  }
8114
8313
  logMetrics(e) {
8115
8314
  for (let [t, n] of this.trackerByCommand.entries()) {
@@ -8132,9 +8331,9 @@ var Ja = class {
8132
8331
  destroy() {
8133
8332
  this.trackerByCommand.clear();
8134
8333
  }
8135
- }, bo = class e {
8334
+ }, To = class e {
8136
8335
  constructor(e, t, n, r) {
8137
- h(this, "logger", 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 fo(e, t, n), this.statAggregator = new mo(this.logger), this.codecStatsAggregator = new po(this.logger, r), this.pings = new vo(this.logger), this.signalingCommands = new yo(this.logger);
8336
+ h(this, "logger", 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 _o(e, t, n), this.statAggregator = new yo(this.logger), this.codecStatsAggregator = new vo(this.logger, r), this.pings = new Co(this.logger), this.signalingCommands = new wo(this.logger);
8138
8337
  }
8139
8338
  logHangup(t, n) {
8140
8339
  if (![
@@ -8178,7 +8377,7 @@ var Ja = class {
8178
8377
  default: return "hangup";
8179
8378
  }
8180
8379
  }
8181
- }, xo = class {
8380
+ }, Eo = class {
8182
8381
  constructor(e) {
8183
8382
  h(this, "_statAggregator", void 0), h(this, "_isCallMarked", !1), h(this, "_isFinished", !1), h(this, "_callType", null), this._statAggregator = e;
8184
8383
  }
@@ -8188,14 +8387,14 @@ var Ja = class {
8188
8387
  markAcceptedCall(e) {
8189
8388
  e === q.DIRECT && this.mark("direct_outgoing");
8190
8389
  }
8191
- markParticipantJoined(e) {
8192
- e === q.DIRECT && this.mark("server_change_topology");
8193
- }
8194
8390
  markOnJoin(e) {
8195
- e === q.SERVER && this.mark("server_join_server");
8391
+ this.mark(e === q.DIRECT ? "direct_join" : "server_join_server", e === q.DIRECT);
8196
8392
  }
8197
- mark(e) {
8198
- this._isCallMarked || (this._isCallMarked = !0, this._callType = e, W.setMark(H.FIRST_MEDIA_RECEIVED));
8393
+ markTopologyChanged(e) {
8394
+ this._isFinished || e !== q.SERVER || (this._callType = "server_change_topology");
8395
+ }
8396
+ mark(e, t = !1) {
8397
+ (!this._isCallMarked || t) && (this._isCallMarked = !0, this._callType = e, W.setMark(H.FIRST_MEDIA_RECEIVED));
8199
8398
  }
8200
8399
  measure() {
8201
8400
  this._isFinished || (this._isFinished = !0, this._callType && this._statAggregator.logEventualStat({
@@ -8203,9 +8402,9 @@ var Ja = class {
8203
8402
  call_type: this._callType
8204
8403
  }));
8205
8404
  }
8206
- }, So = 1e3, Co = 1e4, wo = 15, Q = class e extends y {
8405
+ }, Do = 1e3, Oo = 1e4, ko = 15, Q = class e extends y {
8207
8406
  constructor(e, t) {
8208
- 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, "_participantState", X.CALLED), h(this, "_participants", {}), h(this, "_pendingParticipants", /* @__PURE__ */ new Map()), 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", Cr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_abortController", 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) => {
8407
+ 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, "_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", Cr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_abortController", 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) => {
8209
8408
  if (this._signaling.ready) try {
8210
8409
  await this._signaling.changeMediaSettings(e);
8211
8410
  } catch (e) {
@@ -8215,7 +8414,7 @@ var Ja = class {
8215
8414
  captureAudio: !1
8216
8415
  });
8217
8416
  }
8218
- }, 100)), this._stats = new bo(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology()), this._api = e, this._signaling = new Ta(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new ro(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new $a({
8417
+ }, 100)), this._stats = new To(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology()), this._api = e, this._signaling = new Da(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new co(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new io({
8219
8418
  api: this._api,
8220
8419
  debug: this._debug,
8221
8420
  getParticipants: () => this._getParticipants(),
@@ -8226,13 +8425,13 @@ var Ja = class {
8226
8425
  event_type: H.CALL_DECLINED_OR_HANGED_LOCALLY,
8227
8426
  reason: "none"
8228
8427
  }, !0)), this._stats.destroy();
8229
- }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new xo(this._stats.statAggregator), this._audioOutput = new Ya(this._statFirstMediaReceived, M.transparentAudio, this._debug, this._stats.logger), M.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), So));
8428
+ }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new Eo(this._stats.statAggregator), this._audioOutput = new Za(this._statFirstMediaReceived, M.transparentAudio, this._debug, this._stats.logger), M.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), Do));
8230
8429
  }
8231
8430
  static current() {
8232
8431
  return z.getActive();
8233
8432
  }
8234
8433
  static hangupAfterInit() {
8235
- let e = To;
8434
+ let e = Ao;
8236
8435
  e && e._delayedHangup === !1 && !e._conversation && (e._delayedHangup = !0, e._abortController?.abort(new O(D.CANCELED)));
8237
8436
  }
8238
8437
  static id() {
@@ -8261,11 +8460,11 @@ var Ja = class {
8261
8460
  }
8262
8461
  async onStart({ opponentIds: e, opponentType: t, mediaOptions: n, payload: r = "", joiningAllowed: i = !1, requireAuthToJoin: a = !1, onlyAdminCanShareMovie: o, externalIds: s, onFastStart: c, conversationId: l }) {
8263
8462
  let u = Date.now();
8264
- this._debug.setConversationId(l ?? null), To = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
8463
+ this._debug.setConversationId(l ?? null), Ao = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
8265
8464
  try {
8266
8465
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
8267
8466
  let d = this._mediaSource.mediaSettings;
8268
- t === Ea.CHAT || e && e.length > 1 ? this._logWithMediaSettings(S.OUTGOING_MULTIPARTY_CALL, d) : this._logWithMediaSettings(S.OUTGOING_CALL, d);
8467
+ t === Oa.CHAT || e && e.length > 1 ? this._logWithMediaSettings(S.OUTGOING_MULTIPARTY_CALL, d) : this._logWithMediaSettings(S.OUTGOING_CALL, d);
8269
8468
  let f = await this._startConversation({
8270
8469
  opponentIds: e,
8271
8470
  opponentType: t,
@@ -8286,14 +8485,14 @@ var Ja = class {
8286
8485
  opponentIds: e,
8287
8486
  opponentType: t,
8288
8487
  mediaOptions: n
8289
- }), await this._processConnectionSharedMovieInfo(f), await this._processConversationUrlSharingInfo(f), 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(f), await this._processPinnedParticipants(f), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), z.add(this), await z.setActive(this.id), To = null, this._conversation.concurrent && await this._acceptConcurrent(), this._conversation;
8488
+ }), await this._processConnectionSharedMovieInfo(f), await this._processConversationUrlSharingInfo(f), 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(f), await this._processPinnedParticipants(f), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), z.add(this), await z.setActive(this.id), Ao = null, this._conversation.concurrent && await this._acceptConcurrent(), this._conversation;
8290
8489
  } catch (e) {
8291
- throw To = null, this._close(e, "Unable to start conversation"), e;
8490
+ throw Ao = null, this._close(e, "Unable to start conversation"), e;
8292
8491
  }
8293
8492
  }
8294
8493
  async onJoin(e) {
8295
8494
  let t = Date.now();
8296
- To = 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);
8495
+ Ao = 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);
8297
8496
  try {
8298
8497
  let n = !!e.observedIds?.length;
8299
8498
  if (n && M.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new O(D.UNSUPPORTED);
@@ -8302,28 +8501,28 @@ var Ja = class {
8302
8501
  this._logWithMediaSettings(S.JOIN_CONVERSATION, r);
8303
8502
  let i = await this._joinConversation(e, t);
8304
8503
  if (!this._conversation) throw new O(D.UNKNOWN_ERROR);
8305
- return this._conversation.observer = n, L.onLocalStream(this._mediaSource.getStream(), r, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), z.add(this), To = null, this._signaling.readyToSend(), L.onLocalStatus(this._conversation.waitForAdmin ? N.WAIT_FOR_ADMIN : N.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(i);
8504
+ return this._conversation.observer = n, L.onLocalStream(this._mediaSource.getStream(), r, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), z.add(this), Ao = null, this._signaling.readyToSend(), L.onLocalStatus(this._conversation.waitForAdmin ? N.WAIT_FOR_ADMIN : N.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(i);
8306
8505
  } catch (e) {
8307
- throw To = null, this._close(e, "Unable to join conversation"), e;
8506
+ throw Ao = null, this._close(e, "Unable to join conversation"), e;
8308
8507
  }
8309
8508
  }
8310
- async _onJoinPart2(e) {
8509
+ async _onJoinPart2(e, t = !0, n = !1) {
8311
8510
  this._debug.debug("Join conversation part 2");
8312
8511
  try {
8313
8512
  if (this._participantState = X.ACCEPTED, !this._conversation || !this._mediaSource) throw new O(D.UNKNOWN_ERROR);
8314
- if (this._statFirstMediaReceived.markOnJoin(this._conversation.topology), !this._conversation.observer && !this._isAudienceModeListener() && this._changeMediaSettings(this._mediaSource.mediaSettings), await this._processConnection(e), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), this._signaling.readyToSend(), this._state === "CLOSE") return this._conversation;
8513
+ if (this._statFirstMediaReceived.markOnJoin(this._conversation.topology), !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;
8315
8514
  if (this._delayedHangup) throw new O(D.CANCELED);
8316
8515
  await this._processConnectionSharedMovieInfo(e), await this._processConversationUrlSharingInfo(e), await this._processConnectionAsrInfo(e);
8317
- let t = await this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
8318
- L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), await this._getMainRoomParticipants(), t, this.id), await this._onConversationParticipantListChunk(e), await this._processPinnedParticipants(e), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), this._state = "ACTIVE", this._changeFeatureSet(), z.has(this.id) || z.add(this), await z.setActive(this.id), To = null;
8319
- let n = this._extractLocalParticipantFromConnection(e);
8320
- if (n) {
8321
- let e = j.mapParticipantState(n);
8516
+ let r = await this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
8517
+ 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), Ao = null);
8518
+ let i = this._extractLocalParticipantFromConnection(e);
8519
+ if (i) {
8520
+ let e = j.mapParticipantState(i);
8322
8521
  Object.keys(e).length > 0 && L.onLocalParticipantState(e, !1, this.id);
8323
8522
  }
8324
- return this._openTransport(Object.values(await this._getParticipants()), !1), this._conversation;
8523
+ return t && this._openTransport(Object.values(await this._getParticipants()), !1), this._conversation;
8325
8524
  } catch (e) {
8326
- throw To = null, this._close(e, "Unable to join conversation"), e;
8525
+ throw Ao = null, this._close(e, "Unable to join conversation"), e;
8327
8526
  }
8328
8527
  }
8329
8528
  async _extractExternalRooms(e) {
@@ -8337,22 +8536,22 @@ var Ja = class {
8337
8536
  }
8338
8537
  async onPush(e, t = A.USER, n, r, i) {
8339
8538
  if (z.has(e)) throw new O(D.HAS_ACTIVE_CALL);
8340
- this._debug.setConversationId(e), To = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
8539
+ this._debug.setConversationId(e), Ao = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
8341
8540
  try {
8342
8541
  let a = Date.now(), o = await this._prepareConversation(e, t, n, r, i);
8343
8542
  if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new O(D.UNKNOWN_ERROR);
8344
8543
  if (!o.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);
8345
- if (await this._processConnection(o), this._extractConnectionUrlSharingInfo(o), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), await this._processPinnedParticipants(o), this._signaling.readyToSend(), this._logCallStartEvent(a, Y.INCOMING), this._stats.logger.log(S.PUSH, "accepted"), z.add(this), To = null, this._delayedHangup) throw new O(D.CANCELED);
8544
+ if (await this._processConnection(o), this._extractConnectionUrlSharingInfo(o), await this._allocateTransport(), this._createSpeakerDetector(), await this._createSpecListener(), await this._processPinnedParticipants(o), this._signaling.readyToSend(), this._logCallStartEvent(a, Y.INCOMING), this._stats.logger.log(S.PUSH, "accepted"), z.add(this), Ao = null, this._delayedHangup) throw new O(D.CANCELED);
8346
8545
  } catch (e) {
8347
- throw To = null, this._close(e, "Unable to handle inbound call push"), e;
8546
+ throw Ao = null, this._close(e, "Unable to handle inbound call push"), e;
8348
8547
  }
8349
8548
  }
8350
8549
  _isInWaitingHall(e) {
8351
- return !e.conversation || !e.conversation.options.includes(ka.WAITING_HALL) ? !1 : this._isRestricted(e);
8550
+ return !e.conversation || !e.conversation.options.includes(ja.WAITING_HALL) ? !1 : this._isRestricted(e);
8352
8551
  }
8353
8552
  _isWaitForAdmin(e) {
8354
8553
  if (!e.conversation) return !1;
8355
- let t = e.conversation.options.includes(ka.WAIT_FOR_ADMIN), n = e.conversation.options.includes(ka.ADMIN_IS_HERE);
8554
+ let t = e.conversation.options.includes(ja.WAIT_FOR_ADMIN), n = e.conversation.options.includes(ja.ADMIN_IS_HERE);
8356
8555
  return !t || t && n ? !1 : this._isRestricted(e);
8357
8556
  }
8358
8557
  _isRestricted(e) {
@@ -8360,7 +8559,7 @@ var Ja = class {
8360
8559
  return t && t.restricted || !1;
8361
8560
  }
8362
8561
  _isAudienceMode(e) {
8363
- return e.conversation?.options?.includes(ka.AUDIENCE_MODE) || !1;
8562
+ return e.conversation?.options?.includes(ja.AUDIENCE_MODE) || !1;
8364
8563
  }
8365
8564
  _isAudienceModeListener() {
8366
8565
  return this._conversation?.audienceMode && this._conversation?.restricted;
@@ -8386,7 +8585,7 @@ var Ja = class {
8386
8585
  let i = atob(n), a = new Uint8Array(i.length);
8387
8586
  for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
8388
8587
  try {
8389
- let e = qa(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);
8588
+ let e = Ya(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);
8390
8589
  return {
8391
8590
  token: i,
8392
8591
  endpoint: l,
@@ -8459,7 +8658,7 @@ var Ja = class {
8459
8658
  }
8460
8659
  async hangup() {
8461
8660
  this._debug.debug("Hangup");
8462
- let e = this._state === "ACTIVE" ? D.HUNGUP : D.CANCELED;
8661
+ let e = this._state === "ACTIVE" || this._state === "HELD" ? D.HUNGUP : D.CANCELED;
8463
8662
  this._stats.logger.log(S.HANGUP, e), this._signaling.ready ? (await this._signaling.hangup(e), this._close(new O(e))) : L.onHangup(new O(D.HUNGUP), this._conversation && this._conversation.id), this._conversation?.id && z.has(this._conversation.id) && z.remove(this._conversation.id);
8464
8663
  }
8465
8664
  async addParticipant(e, t) {
@@ -8632,7 +8831,7 @@ var Ja = class {
8632
8831
  joinLink: a,
8633
8832
  observedIds: o
8634
8833
  }), n && z.has(n)) throw new O(D.HAS_ACTIVE_CALL);
8635
- let l = r.includes(x.VIDEO), u;
8834
+ let l = r.includes(x.VIDEO), u, d;
8636
8835
  if (c) {
8637
8836
  if (!a) throw new O(D.FAST_JOIN_ERROR, { message: "joinLink is required for fast join" });
8638
8837
  let e = {
@@ -8665,17 +8864,17 @@ var Ja = class {
8665
8864
  stun_server: e.stun,
8666
8865
  turn_server: e.turn,
8667
8866
  token: new URL(e.endpoint).searchParams.get("token") ?? ""
8668
- }, this._debug.debug("FastJoin", u);
8867
+ }, this._debug.debug("FastJoin", u), d = "fastJoin";
8669
8868
  } catch {
8670
8869
  throw new O(D.FAST_JOIN_ERROR, { message: "Cannot parse internal params" });
8671
8870
  }
8672
- } else if (n) u = await this._api.joinConversation(n, l, i);
8673
- else if (a) u = await this._api.joinConversationByLink(a, l, o, s);
8871
+ } else if (n) u = await this._api.joinConversation(n, l, i), d = "joinConversation";
8872
+ else if (a) u = await this._api.joinConversationByLink(a, l, o, s), d = "joinConversationByLink";
8674
8873
  else throw new O(D.UNKNOWN_ERROR);
8675
- if (this._debug.debug("Api.joinConversation", u), u.id && z.has(u.id)) throw new O(D.HAS_ACTIVE_CALL);
8874
+ if (this._debug.debug("Api.joinConversation", u), Qa(u, d), u.id && z.has(u.id)) throw new O(D.HAS_ACTIVE_CALL);
8676
8875
  this._setConversationParams(u);
8677
- let d = await this._connectSignaling(dr.JOIN, u);
8678
- return await this._setConversation(u, d, Y.JOINING), this._logCallStartEvent(t, Y.JOINING), d;
8876
+ let f = await this._connectSignaling(dr.JOIN, u);
8877
+ return await this._setConversation(u, f, Y.JOINING), this._logCallStartEvent(t, Y.JOINING), f;
8679
8878
  }
8680
8879
  async _prepareConversation(e, t = A.USER, n, r, i) {
8681
8880
  W.setMark(H.SIGNALING_CONNECTED), this._debug.debug("Conversation: push", {
@@ -8791,7 +8990,7 @@ var Ja = class {
8791
8990
  }
8792
8991
  _createMediaSource() {
8793
8992
  let e = new Jt(this._debug, this._stats.logger);
8794
- return this.subscribe(e, Kt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, Kt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new Ja(e, this._debug, this._stats.logger), e;
8993
+ return this.subscribe(e, Kt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, Kt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new Xa(e, this._debug, this._stats.logger), e;
8795
8994
  }
8796
8995
  async _connectSignaling(e, t) {
8797
8996
  this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null), this.subscribe(this._signaling, fr.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, fr.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, fr.RECONNECT, this._onSignalingReconnect.bind(this));
@@ -8799,7 +8998,7 @@ var Ja = class {
8799
8998
  return this._stats.statAggregator.logEventualStat({ name: H.SIGNALING_CONNECTED }), n;
8800
8999
  }
8801
9000
  async _processConnection(e) {
8802
- 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(Da.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
9001
+ 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(ka.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
8803
9002
  }
8804
9003
  async _onConversationParticipantListChunk(e) {
8805
9004
  let t = e.participants;
@@ -8852,7 +9051,8 @@ var Ja = class {
8852
9051
  participantState: j.mapParticipantState(n),
8853
9052
  state: n.state,
8854
9053
  roles: n.roles || [],
8855
- status: N.WAITING,
9054
+ status: n.onHold ? N.ONHOLD : N.WAITING,
9055
+ isOnHold: !!n.onHold,
8856
9056
  muteStates: n.muteStates || {},
8857
9057
  unmuteOptions: n.unmuteOptions || [],
8858
9058
  observedIds: n.observedIds || [],
@@ -8861,13 +9061,13 @@ var Ja = class {
8861
9061
  isInRoom: t
8862
9062
  }, i);
8863
9063
  let a = await this._getParticipant(e);
8864
- a && n.roles && n.roles.length && (this._debug.debug(`Roles for participant [${e}] changed: ${n.roles}`), L.onRolesChanged(a.externalId, n.roles, !0, this.id));
9064
+ a && n.roles && n.roles.length && (this._debug.debug(`Roles for participant [${e}] changed: ${n.roles}`), L.onRolesChanged(a.externalId, n.roles, !0, this.id)), a && a.isOnHold && L.onRemoteStatus([a.externalId], N.ONHOLD, null, this.id);
8865
9065
  }
8866
9066
  }
8867
9067
  _registerParticipantLocalMuteState({ muteStates: e, unmuteOptions: t }) {
8868
9068
  if (!e) return;
8869
9069
  let n = async () => {
8870
- let n = Va(e, Ma.MUTE), r = Va(e, Ma.MUTE_PERMANENT);
9070
+ let n = Ua(e, Pa.MUTE), r = Ua(e, Pa.MUTE_PERMANENT);
8871
9071
  for (let i of [n, r]) i.length && await this._onMuteParticipant({
8872
9072
  muteStates: e,
8873
9073
  unmuteOptions: t,
@@ -8924,11 +9124,11 @@ var Ja = class {
8924
9124
  this._onRoomSwitched(t, !0);
8925
9125
  }
8926
9126
  _processMuteStates(e, t = !1) {
8927
- let n = Ha(e);
9127
+ let n = Wa(e);
8928
9128
  this._setMuteStatesForRoomId(n, null);
8929
9129
  for (let t of e.rooms?.rooms ?? []) this._setMuteStatesForRoomId(t.muteStates, t.id);
8930
9130
  let r = this._getMuteStatesForCurrentRoom();
8931
- t && (r = Ka(e, r));
9131
+ t && (r = Ja(e, r));
8932
9132
  let i = Object.keys(r), a = this._conversation?.roomId;
8933
9133
  i.length && this._onMuteParticipant({
8934
9134
  muteStates: r,
@@ -8948,15 +9148,15 @@ var Ja = class {
8948
9148
  }
8949
9149
  async _allocateTransport() {
8950
9150
  if (!this._conversation || !this._mediaSource) return;
8951
- this._transport = new ea(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator), this._debugInfo = new Qa(this._debug), this.subscribe(this._transport, J.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, J.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, J.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, J.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, J.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, J.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, J.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, J.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, J.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, J.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, J.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, J.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, J.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, J.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
9151
+ this._transport = new ea(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator), this._debugInfo = new ro(this._debug), this.subscribe(this._transport, J.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, J.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, J.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, J.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, J.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, J.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, J.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, J.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, J.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, J.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, J.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, J.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, J.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, J.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
8952
9152
  let e = this._conversation.direction === Y.OUTGOING && !this._conversation.concurrent, t = await this._getParticipants();
8953
9153
  for (let n of Object.values(t)) (n.state === X.ACCEPTED || n.state === X.CALLED) && this._transport.allocate(n.id, e);
8954
9154
  }
8955
9155
  _createSpeakerDetector() {
8956
- this._transport && this._conversation && (this._volumesDetector = new ao(this._transport), this.subscribe(this._volumesDetector, io.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new so(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, oo.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new no(this._mediaSource));
9156
+ this._transport && this._conversation && (this._volumesDetector = new uo(this._transport), this.subscribe(this._volumesDetector, lo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new po(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, fo.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new so(this._mediaSource));
8957
9157
  }
8958
9158
  async _createSpecListener() {
8959
- this._transport && this._volumesDetector && (this._specListener = new uo(this._transport, this._volumesDetector, await this._getParticipants(), this._debug, this._stats.logger));
9159
+ this._transport && this._volumesDetector && (this._specListener = new go(this._transport, this._volumesDetector, await this._getParticipants(), this._debug, this._stats.logger));
8960
9160
  }
8961
9161
  _logDevices() {
8962
9162
  let e = T.getCameras().length, t = T.getMicrophones().length;
@@ -9032,7 +9232,7 @@ var Ja = class {
9032
9232
  async _onRemoveParticipant(e) {
9033
9233
  this._debug.debug(`Remove participant [${e}]`);
9034
9234
  let t = [], n = await this._getParticipants();
9035
- for (let r = 0; r <= wo; r++) {
9235
+ for (let r = 0; r <= ko; r++) {
9036
9236
  let i = n[j.compose(e, r)];
9037
9237
  i && t.push(i);
9038
9238
  }
@@ -9088,7 +9288,7 @@ var Ja = class {
9088
9288
  if (this._mediaSource) return this._stats.logger.log(S.MEDIA_STATUS, e ? "video_1" : "video_0"), this._mediaSource.toggleVideo(e);
9089
9289
  }
9090
9290
  async toggleLocalAudio(e) {
9091
- if (this._mediaSource) return this._stats.logger.log(S.MEDIA_STATUS, e ? "audio_1" : "audio_0"), this._mediaSource.toggleAudio(e);
9291
+ if (!(e && this._state === "HELD") && this._mediaSource) return this._stats.logger.log(S.MEDIA_STATUS, e ? "audio_1" : "audio_0"), this._mediaSource.toggleAudio(e);
9092
9292
  }
9093
9293
  async changePriorities(e) {
9094
9294
  if (e.length < 2 || !this._signaling.ready) return;
@@ -9108,17 +9308,44 @@ var Ja = class {
9108
9308
  for (let [t, n] of Object.entries(e)) if (t.length > 5 || n.length > 5) throw Error("key/value max length is 5 chars, mappings with empty values (null or empty string) are discarded");
9109
9309
  t && !this._isCallAdmin() && (t = void 0), await this._signaling.changeParticipantState(e, t);
9110
9310
  }
9111
- async hold(e) {
9112
- let t = ua.get();
9113
- if (await this._signaling.hold(e, e ? void 0 : t), e) (this._state === "ACTIVE" || this._state === "IDLE") && (this._previousState = this._state, this._state = "HELD"), await this._mediaSource?.stopLocalMedia(), L.onLocalStatus(N.ONHOLD, this.id);
9114
- else {
9115
- this._state === "HELD" && (this._state = this._previousState || "ACTIVE", this._previousState = null);
9116
- let e = null;
9117
- if (this._state === "IDLE" && this._participantState === X.ACCEPTED && (e = Object.values(await this._getParticipants()), e.some((e) => e.state === X.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._mediaSource?.resumeLocalMedia(), L.onLocalStatus(N.WAITING, this.id), this._mediaSource && L.onLocalStream(this._mediaSource?.getStream() ?? null, this._mediaSource.mediaSettings, this.id), this._state === "ACTIVE") {
9118
- let t = this._conversation?.direction === Y.OUTGOING && !this._conversation.concurrent;
9119
- this._openTransport(e ?? Object.values(await this._getParticipants()), t);
9311
+ async hold(e, t) {
9312
+ if (e) {
9313
+ if (this._isWaitingForPromotion()) {
9314
+ this._waitingHallHoldPending = !0, await this._holdLocally();
9315
+ return;
9120
9316
  }
9317
+ await this._signaling.hold(!0), await this._holdLocally();
9318
+ return;
9121
9319
  }
9320
+ if (this._isWaitingForPromotion()) {
9321
+ this._waitingHallHoldPending = !1, await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus());
9322
+ return;
9323
+ }
9324
+ let n = ua.get();
9325
+ await this._signaling.hold(!1, n), this._restoreStateAfterHold();
9326
+ let r = null;
9327
+ 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._resumeLocalMedia(t, N.WAITING), this._state === "ACTIVE") {
9328
+ let e = this._conversation?.direction === Y.OUTGOING && !this._conversation.concurrent;
9329
+ this._openTransport(r ?? Object.values(await this._getParticipants()), e);
9330
+ }
9331
+ }
9332
+ async _holdLocally() {
9333
+ this._state !== "HELD" && (this._previousState = this._state, this._state = "HELD"), this._audioFix?.disable(), this._setOutgoingAudioEnabled(!1), await this._mediaSource?.stopLocalMedia(), L.onLocalStatus(N.ONHOLD, this.id);
9334
+ }
9335
+ async _resumeLocalMedia(e, t) {
9336
+ this._restoreStateAfterHold(), this._setOutgoingAudioEnabled(!0), await this._mediaSource?.resumeLocalMedia(e), L.onLocalStatus(t, this.id), this._mediaSource && L.onLocalStream(this._mediaSource?.getStream() ?? null, this._mediaSource.mediaSettings, this.id);
9337
+ }
9338
+ _setOutgoingAudioEnabled(e) {
9339
+ this._transport?.setOutgoingAudioEnabled(e);
9340
+ }
9341
+ _restoreStateAfterHold() {
9342
+ this._state === "HELD" && (this._state = this._previousState || "ACTIVE", this._previousState = null);
9343
+ }
9344
+ _isWaitingForPromotion() {
9345
+ return !!this._conversation?.waitingHall || !!this._conversation?.waitForAdmin;
9346
+ }
9347
+ _getWaitingForPromotionStatus() {
9348
+ return this._conversation?.waitForAdmin ? N.WAIT_FOR_ADMIN : N.WAITING_HALL;
9122
9349
  }
9123
9350
  async putHandsDown() {
9124
9351
  this._checkAdminRole(), await this._signaling.putHandsDown();
@@ -9234,13 +9461,13 @@ var Ja = class {
9234
9461
  let n = En(e), a = i[n.participantId];
9235
9462
  if (a) {
9236
9463
  let e;
9237
- typeof t == "number" ? e = Fa(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = Pa.UNKNOWN_ERROR), r.push({
9464
+ typeof t == "number" ? e = La(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = Ia.UNKNOWN_ERROR), r.push({
9238
9465
  externalId: a.externalId,
9239
9466
  errorReason: e
9240
9467
  });
9241
9468
  }
9242
9469
  }
9243
- if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new Eo("Could not allocate one or more participants", r);
9470
+ if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new jo("Could not allocate one or more participants", r);
9244
9471
  }
9245
9472
  async _cleanupCooldownQueue() {
9246
9473
  let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
@@ -9248,7 +9475,7 @@ var Ja = class {
9248
9475
  let n = t.next();
9249
9476
  if (n.done) break;
9250
9477
  let r = n.value;
9251
- if (r[1] + Co > Date.now()) break;
9478
+ if (r[1] + Oo > Date.now()) break;
9252
9479
  let i = r[0];
9253
9480
  await this._stopStreaming(i), e[i] = { stopStream: !0 };
9254
9481
  } while (!0);
@@ -9262,7 +9489,7 @@ var Ja = class {
9262
9489
  }
9263
9490
  }
9264
9491
  async _onParticipantPromoted(e) {
9265
- this._conversation && this._conversation.audienceMode ? (this._debug.log("Promoted in audience mode", !e.demote), this._conversation.restricted = e.demote, this._processRecordInfos(e), !e.demote && this._mediaSource && this._changeMediaSettings(this._mediaSource.mediaSettings)) : (this._debug.log("Promoted in waiting hall", !e.demote), e.demote ? (this._debug.log("Kicked from waiting hall"), this._close(new O(D.REMOVED))) : (this._updateConversation(e), await this._onJoinPart2(e))), L.onPromoted(e.demote, this.id);
9492
+ this._conversation && this._conversation.audienceMode ? (this._debug.log("Promoted in audience mode", !e.demote), this._conversation.restricted = e.demote, this._processRecordInfos(e), !e.demote && this._mediaSource && this._changeMediaSettings(this._mediaSource.mediaSettings)) : (this._debug.log("Promoted in waiting hall", !e.demote), e.demote ? (this._debug.log("Kicked from waiting hall"), this._close(new O(D.REMOVED))) : (this._updateConversation(e), this._waitingHallHoldPending ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !1), this._waitingHallHoldPending = !1) : z.getActive() ? (await this._signaling.hold(!0), await this._onJoinPart2(e, !0, !0), this._waitingHallHoldPending = !1) : await this._onJoinPart2(e))), L.onPromoted(e.demote, this.id);
9266
9493
  }
9267
9494
  async _onChatRoomUpdated(e, t = 0, n = [], r, i) {
9268
9495
  this._debug.log(`Chat room updated: ${e}`);
@@ -9463,10 +9690,10 @@ var Ja = class {
9463
9690
  throw Error("transport is not initialized");
9464
9691
  }
9465
9692
  _isCallAdmin() {
9466
- return this._conversation ? j.includesOneOf(this._conversation.roles, [Ia.ADMIN, Ia.CREATOR]) : !1;
9693
+ return this._conversation ? j.includesOneOf(this._conversation.roles, [Ra.ADMIN, Ra.CREATOR]) : !1;
9467
9694
  }
9468
9695
  _checkAdminRole() {
9469
- if (this._conversation && !j.includesOneOf(this._conversation.roles, [Ia.ADMIN, Ia.CREATOR])) throw Error("You don't have the required permission");
9696
+ if (this._conversation && !j.includesOneOf(this._conversation.roles, [Ra.ADMIN, Ra.CREATOR])) throw Error("You don't have the required permission");
9470
9697
  }
9471
9698
  _isCalledState() {
9472
9699
  return this._participantState === X.CALLED;
@@ -9504,21 +9731,21 @@ var Ja = class {
9504
9731
  async changeOptions(e) {
9505
9732
  if (this._signaling.ready && this._conversation) {
9506
9733
  this._checkAdminRole(), await this._signaling.changeOptions(e);
9507
- let t = ja(this._conversation.options, e);
9734
+ let t = Na(this._conversation.options, e);
9508
9735
  this._onOptionsChanged(t);
9509
9736
  }
9510
9737
  }
9511
9738
  async getWaitingHall(e, t, n) {
9512
9739
  if (!this._signaling) return Promise.reject();
9513
9740
  let r = null;
9514
- if (e && (r = Ba(e), r)) {
9741
+ if (e && (r = Ha(e), r)) {
9515
9742
  let e = this._api.getDecorativeIdByInitialId(r.id);
9516
9743
  r.id = e ? j.composeUserId(e) : r.id;
9517
9744
  }
9518
9745
  let i = await this._signaling.getWaitingHall(r, t, n);
9519
9746
  if (i.error) return Promise.reject(i.message);
9520
9747
  let a = i.participants || [], { externalIds: o } = await this._resolveWaitingHallExternalIds(a), s = null;
9521
- return a.length && i.hasMore && (s = za(a[a.length - 1].id)), {
9748
+ return a.length && i.hasMore && (s = Va(a[a.length - 1].id)), {
9522
9749
  participants: o,
9523
9750
  pageMarker: s,
9524
9751
  totalCount: i.totalCount || 0
@@ -9556,7 +9783,7 @@ var Ja = class {
9556
9783
  }
9557
9784
  async promoteParticipant(e, t) {
9558
9785
  if (this._signaling && this._conversation) try {
9559
- if (!j.includesOneOf(this._conversation.options, [ka.WAITING_HALL, ka.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
9786
+ if (!j.includesOneOf(this._conversation.options, [ja.WAITING_HALL, ja.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
9560
9787
  if (this._checkAdminRole(), !e && t) throw Error("participantId is required");
9561
9788
  await this._signaling.promoteParticipant(e, t);
9562
9789
  } catch (t) {
@@ -9709,7 +9936,8 @@ var Ja = class {
9709
9936
  participantState: j.mapParticipantState(e),
9710
9937
  state: e.state,
9711
9938
  roles: e.roles || [],
9712
- status: this._getStatusByTransportState(i) ?? N.WAITING,
9939
+ status: e.onHold ? N.ONHOLD : this._getStatusByTransportState(i) ?? N.WAITING,
9940
+ isOnHold: !!e.onHold,
9713
9941
  muteStates: e.muteStates || {},
9714
9942
  unmuteOptions: e.unmuteOptions || [],
9715
9943
  observedIds: e.observedIds || [],
@@ -9726,7 +9954,7 @@ var Ja = class {
9726
9954
  let a = this._transport?.getState();
9727
9955
  return n.participants.forEach((e) => {
9728
9956
  let t = r[j.composeId(e)];
9729
- t.status = this._getStatusByTransportState(a) ?? N.WAITING, t.movieShareInfos = e.movieShareInfos, Object.assign(t.mediaSettings, E(e.mediaSettings)), Object.assign(t.muteStates, e.muteStates), t.unmuteOptions = e.unmuteOptions ?? t.unmuteOptions, this._openTransport([t], !0);
9957
+ t.isOnHold || (t.status = this._getStatusByTransportState(a) ?? N.WAITING), t.movieShareInfos = e.movieShareInfos, Object.assign(t.mediaSettings, E(e.mediaSettings)), Object.assign(t.muteStates, e.muteStates), t.unmuteOptions = e.unmuteOptions ?? t.unmuteOptions, this._openTransport([t], !0);
9730
9958
  }), this._participantListChunkToExternalChunk(n);
9731
9959
  }
9732
9960
  async _getInitialParticiapntListChunk() {
@@ -9738,9 +9966,9 @@ var Ja = class {
9738
9966
  return this._debug.debug("Get initial participant list chunk", n.chunk), n.chunk;
9739
9967
  }
9740
9968
  _onLocalMediaStreamChanged(e) {
9741
- if (!this._conversation || !this._mediaSource) return;
9969
+ if (!this._conversation || !this._mediaSource || this._state === "HELD") return;
9742
9970
  let t = this._mediaSource.mediaSettings;
9743
- this._debug.debug("Local media stream changed", t), e.kind === k.audio && this._mediaSource && (this._audioFix = new Ja(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);
9971
+ this._debug.debug("Local media stream changed", t), e.kind === k.audio && this._mediaSource && (this._audioFix = new Xa(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);
9744
9972
  }
9745
9973
  _onScreenSharingStatus(e) {
9746
9974
  let t = this.mediaSettings;
@@ -9865,9 +10093,9 @@ var Ja = class {
9865
10093
  for (let n of e.conversation.participants) {
9866
10094
  let e = j.composeId(n), i = n.roles || [];
9867
10095
  if (this._isMe(e)) {
9868
- La(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
10096
+ za(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
9869
10097
  this._registerParticipantLocalMuteState({
9870
- muteStates: Ga(n),
10098
+ muteStates: qa(n),
9871
10099
  unmuteOptions: n.unmuteOptions
9872
10100
  });
9873
10101
  };
@@ -9884,7 +10112,7 @@ var Ja = class {
9884
10112
  let t = E(n.mediaSettings);
9885
10113
  Ut(t, a.mediaSettings) || await this._changeRemoteMediaSettings(e, t);
9886
10114
  let r = j.mapParticipantState(n), o = a.participantState;
9887
- j.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), La(i, a.roles) || this._onRolesChanged(a.id, i);
10115
+ j.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), za(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));
9888
10116
  }
9889
10117
  }
9890
10118
  let i = await this._getParticipants();
@@ -9927,7 +10155,8 @@ var Ja = class {
9927
10155
  this._debug.debug(`Participant hungup [${e.participantId}]`, { reason: e.reason });
9928
10156
  let t = j.composeMessageId(e);
9929
10157
  if (this._conversation && this._isMe(t)) {
9930
- this._close(new O(e.reason, { remote: !0 }));
10158
+ let t = { remote: !0 };
10159
+ e.reason === D.OBSOLETE_CLIENT && e.errorCode && (t.message = e.errorCode), this._close(new O(e.reason, t));
9931
10160
  return;
9932
10161
  }
9933
10162
  await this._registerParticipantAndSetMarkersIfChunkEnabled(t, e.markers);
@@ -9936,7 +10165,7 @@ var Ja = class {
9936
10165
  this._warnParticipantNotInConversation(t);
9937
10166
  return;
9938
10167
  }
9939
- this._transport && this._transport.close(t), n.state = e.reason === D.REJECTED ? X.REJECTED : X.HUNGUP, this._state !== "CLOSE" && this._removeParticipant(n, D.HUNGUP);
10168
+ this._transport && this._transport.close(t), n.state = e.reason === D.REJECTED ? X.REJECTED : X.HUNGUP, this._state !== "CLOSE" && this._removeParticipant(n, e.reason ?? D.HUNGUP);
9940
10169
  }
9941
10170
  async _onAddedParticipant(e) {
9942
10171
  this._debug.debug(`Participant added [${e.participantId}]`);
@@ -9962,7 +10191,7 @@ var Ja = class {
9962
10191
  n.state = X.CALLED, n.mediaSettings = E(e.participant?.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant?.roles || [], this._setParticipantsStatus([n], N.WAITING), this._state !== "IDLE" && this._transport && this._transport.allocate(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);
9963
10192
  }
9964
10193
  async _onJoinedParticipant(e) {
9965
- this._debug.debug(`Participant joined [${e.participantId}]`), this._statFirstMediaReceived.markParticipantJoined(this._transport?.getTopology());
10194
+ this._debug.debug(`Participant joined [${e.participantId}]`), this._statFirstMediaReceived.markOnJoin(this._transport?.getTopology());
9966
10195
  let t = j.composeMessageId(e), n = await this._getParticipant(t);
9967
10196
  if (n && n.state === X.ACCEPTED) {
9968
10197
  this._debug.warn(`Participant [${t}] is already in conversation and is active`);
@@ -9981,10 +10210,11 @@ var Ja = class {
9981
10210
  movieShareInfos: r.movieShareInfos,
9982
10211
  unmuteOptions: r.unmuteOptions || [],
9983
10212
  observedIds: r.observedIds || [],
9984
- markers: this._denormalizeMarkers(t, r.markers)
10213
+ markers: this._denormalizeMarkers(t, r.markers),
10214
+ isOnHold: !!r.onHold
9985
10215
  }, i), n = await this._getParticipant(t);
9986
10216
  }
9987
- this._conversation && this._conversation.direction === Y.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._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], N.CONNECTED) : this._setParticipantsStatus([n], N.WAITING), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._transport.allocate(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);
10217
+ this._conversation && this._conversation.direction === Y.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 || [], 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), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._transport.allocate(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);
9988
10218
  let r = Object.keys(n.muteStates);
9989
10219
  r.length && this._onMuteParticipant({
9990
10220
  muteStates: n.muteStates,
@@ -10171,15 +10401,15 @@ var Ja = class {
10171
10401
  L.onAsrTranscription(t, e.text, e.timestamp, e.duration, this.id);
10172
10402
  }
10173
10403
  async _onRolesChanged(e, t) {
10174
- if (this._conversation && this._isMe(e) && !La(this._conversation.roles, t)) {
10404
+ if (this._conversation && this._isMe(e) && !za(this._conversation.roles, t)) {
10175
10405
  this._debug.debug(`Local roles changed: ${t}`), this._conversation.roles = t, L.onLocalRolesChanged(t, !1, this.id), this._processMuteState({
10176
- mediaOptions: Va(this._getMuteStatesForCurrentRoom(), Ma.MUTE_PERMANENT),
10406
+ mediaOptions: Ua(this._getMuteStatesForCurrentRoom(), Pa.MUTE_PERMANENT),
10177
10407
  stateUpdated: !0
10178
- }), j.includesOneOf(t, [Ia.ADMIN, Ia.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
10408
+ }), j.includesOneOf(t, [Ra.ADMIN, Ra.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
10179
10409
  return;
10180
10410
  }
10181
10411
  let n = await this._getParticipant(e);
10182
- n && !La(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, L.onRolesChanged(n.externalId, t, !1, this.id));
10412
+ n && !za(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, L.onRolesChanged(n.externalId, t, !1, this.id));
10183
10413
  }
10184
10414
  async _onMuteParticipant(e, t = !1) {
10185
10415
  if (!this._conversation) return;
@@ -10228,7 +10458,7 @@ var Ja = class {
10228
10458
  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);
10229
10459
  for (let [e, i] of d) {
10230
10460
  let a = this._isCallAdmin() && n;
10231
- if (!(i !== Ma.MUTE && i !== Ma.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === Ma.MUTE_PERMANENT && !n && (l[e] = Ma.MUTE), !(!t.includes(e) || r))) switch (e) {
10461
+ if (!(i !== Pa.MUTE && i !== Pa.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === Pa.MUTE_PERMANENT && !n && (l[e] = Pa.MUTE), !(!t.includes(e) || r))) switch (e) {
10232
10462
  case x.VIDEO:
10233
10463
  u.isVideoEnabled && (L.onDeviceSwitched(x.VIDEO, !1, this.id), await this.toggleLocalVideo(!1));
10234
10464
  break;
@@ -10265,7 +10495,7 @@ var Ja = class {
10265
10495
  this._conversation.pinnedParticipantIdByRoom.set(r, t ? null : e);
10266
10496
  }
10267
10497
  _onOptionsChanged(e) {
10268
- this._conversation && !Aa(this._conversation.options, e) && (this._conversation.options = e, L.onOptionsChanged(e, this.id), e.includes(ka.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && L.onLocalStatus(N.WAITING_HALL, this.id) : e.includes(ka.WAIT_FOR_ADMIN) && this._conversation.restricted && L.onLocalStatus(N.WAIT_FOR_ADMIN, this.id));
10498
+ this._conversation && !Ma(this._conversation.options, e) && (this._conversation.options = e, L.onOptionsChanged(e, this.id), e.includes(ja.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && L.onLocalStatus(N.WAITING_HALL, this.id) : e.includes(ja.WAIT_FOR_ADMIN) && this._conversation.restricted && L.onLocalStatus(N.WAIT_FOR_ADMIN, this.id));
10269
10499
  }
10270
10500
  async _onNetworkStatus(e) {
10271
10501
  if (this._conversation) {
@@ -10320,7 +10550,7 @@ var Ja = class {
10320
10550
  }
10321
10551
  _changeFeatureSet() {
10322
10552
  if (this._conversation) {
10323
- let e = this._state === "ACTIVE", t = this._conversation.features.includes(Oa.ADD_PARTICIPANT);
10553
+ let e = this._state === "ACTIVE", t = this._conversation.features.includes(Aa.ADD_PARTICIPANT);
10324
10554
  L.onCallState(e, t, this._conversation, this.id);
10325
10555
  }
10326
10556
  }
@@ -10411,7 +10641,7 @@ var Ja = class {
10411
10641
  }
10412
10642
  _removeVideoTrack(e, t, n) {}
10413
10643
  _onTopologyChanged(e) {
10414
- e === q.DIRECT && (this._onRemoteSignalledStall([]), this._onAudioMixStall(!1)), this._conversation && (this._conversation.topology = e, this._changeFeatureSet(), this._forceOpenTransportForAloneInCall()), this._audioOutput.destroy();
10644
+ this._statFirstMediaReceived.markTopologyChanged(e), e === q.DIRECT && (this._onRemoteSignalledStall([]), this._onAudioMixStall(!1)), this._conversation && (this._conversation.topology = e, this._changeFeatureSet(), this._forceOpenTransportForAloneInCall()), this._audioOutput.destroy();
10415
10645
  }
10416
10646
  _onAudioMixStall(e) {
10417
10647
  this._audioMixStalled !== e && !this.isCallHeld && (this._audioMixStalled = e, this._debug.debug("Audio mix stalled:", e), L.onLocalStatus(e ? N.RECONNECT : N.CONNECTED, this.id));
@@ -10471,7 +10701,7 @@ var Ja = class {
10471
10701
  async _onRoomsUpdated(e) {
10472
10702
  if (this._isCalledState()) return;
10473
10703
  let t = {};
10474
- for (let n of Object.keys(Na)) {
10704
+ for (let n of Object.keys(Fa)) {
10475
10705
  let r = e.updates[n];
10476
10706
  r && (t[n] = {
10477
10707
  rooms: await Promise.all(r?.rooms?.map(this._convertRoomToExternal.bind(this)) || []),
@@ -10483,7 +10713,7 @@ var Ja = class {
10483
10713
  }
10484
10714
  async _onRoomUpdated(e) {
10485
10715
  let t = await this._convertRoomToExternal(e.room || null);
10486
- e.events.some((e) => e === Na.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);
10716
+ e.events.some((e) => e === Fa.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);
10487
10717
  }
10488
10718
  async _convertRoomToExternal(e) {
10489
10719
  if (!e) return null;
@@ -10580,7 +10810,7 @@ var Ja = class {
10580
10810
  n && r.push(n);
10581
10811
  }
10582
10812
  }
10583
- r.length && !this._isCalledState() && L.onRoomsUpdated({ [Na.UPDATE]: { rooms: r } }, this.id);
10813
+ r.length && !this._isCalledState() && L.onRoomsUpdated({ [Fa.UPDATE]: { rooms: r } }, this.id);
10584
10814
  }
10585
10815
  async _onFeedback(e) {
10586
10816
  let t = [];
@@ -10668,19 +10898,19 @@ var Ja = class {
10668
10898
  async _getParticipant(e) {
10669
10899
  return (await this._getParticipants())[e];
10670
10900
  }
10671
- }, To = null, Eo = class e extends Error {
10901
+ }, Ao = null, jo = class e extends Error {
10672
10902
  constructor(t, n) {
10673
10903
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
10674
10904
  }
10675
- }, Do = null, Oo = null;
10676
- function ko() {
10677
- Do = null, Oo = null;
10905
+ }, Mo = null, No = null;
10906
+ function Po() {
10907
+ Mo = null, No = null;
10678
10908
  }
10679
- function Ao(e) {
10909
+ function Fo(e) {
10680
10910
  return e?.endsWith("/") ? e.slice(0, -1) : e;
10681
10911
  }
10682
- async function jo(e = null, t) {
10683
- let n = Ao(e ?? M.apiBaseUrl);
10912
+ async function Io(e = null, t) {
10913
+ let n = Fo(e ?? M.apiBaseUrl);
10684
10914
  if (n) return n;
10685
10915
  if ((t ?? M.apiEnv) !== "AUTO") return M.apiEndpoint(t);
10686
10916
  try {
@@ -10695,20 +10925,20 @@ async function jo(e = null, t) {
10695
10925
  return R.warn("Failed to resolve API endpoint using DNS, default is used", e), M.apiEndpoint(t);
10696
10926
  }
10697
10927
  }
10698
- async function Mo() {
10699
- return Do || Oo || (Oo = jo(), Do = await Oo, Oo = null, Do);
10928
+ async function Lo() {
10929
+ return Mo || No || (No = Io(), Mo = await No, No = null, Mo);
10700
10930
  }
10701
- async function No(e, t = {}, n = !1) {
10931
+ async function Ro(e, t = {}, n = !1) {
10702
10932
  if (!window.Blob || !window.navigator.sendBeacon) return;
10703
- await Mo();
10704
- let r = Lo(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
10705
- window.navigator.sendBeacon(`${Do}/fb.do`, i);
10933
+ await Lo();
10934
+ let r = Ho(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
10935
+ window.navigator.sendBeacon(`${Mo}/fb.do`, i);
10706
10936
  }
10707
- async function Po(e, t = {}, n = !1, r) {
10708
- return await Mo(), Fo(Lo(e, t, n), r);
10937
+ async function zo(e, t = {}, n = !1, r) {
10938
+ return await Lo(), Bo(Ho(e, t, n), r);
10709
10939
  }
10710
- async function Fo(e, t) {
10711
- let n = `${t ?? Do}/fb.do`, r = new AbortController(), i = setTimeout(() => r.abort(new O(D.NETWORK_ERROR)), M.apiTimeout), a = await fetch(n, {
10940
+ async function Bo(e, t) {
10941
+ let n = `${t ?? Mo}/fb.do`, r = new AbortController(), i = setTimeout(() => r.abort(new O(D.NETWORK_ERROR)), M.apiTimeout), a = await fetch(n, {
10712
10942
  method: "POST",
10713
10943
  headers: { "Content-Type": "application/x-www-form-urlencoded" },
10714
10944
  body: e,
@@ -10724,7 +10954,7 @@ async function Fo(e, t) {
10724
10954
  if (!a.ok || Object.hasOwn(s, "error_msg")) throw s;
10725
10955
  return s;
10726
10956
  }
10727
- async function Io(e, t) {
10957
+ async function Vo(e, t) {
10728
10958
  try {
10729
10959
  let n = await fetch(e, {
10730
10960
  method: "POST",
@@ -10737,7 +10967,7 @@ async function Io(e, t) {
10737
10967
  throw R.warn("Failed to send form data", e), e;
10738
10968
  }
10739
10969
  }
10740
- function Lo(e, t = {}, n = !1) {
10970
+ function Ho(e, t = {}, n = !1) {
10741
10971
  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));
10742
10972
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
10743
10973
  let r = "";
@@ -10746,7 +10976,7 @@ function Lo(e, t = {}, n = !1) {
10746
10976
  }
10747
10977
  //#endregion
10748
10978
  //#region src/abstract/BaseApi.ts
10749
- var Ro = class {
10979
+ var Uo = class {
10750
10980
  constructor() {
10751
10981
  h(this, "_abortSignal", void 0);
10752
10982
  }
@@ -10784,7 +11014,7 @@ var Ro = class {
10784
11014
  return Date.now();
10785
11015
  }
10786
11016
  cleanup() {}
10787
- }, zo = class {
11017
+ }, Wo = class {
10788
11018
  constructor() {
10789
11019
  h(this, "_okIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToOkId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
10790
11020
  }
@@ -10829,19 +11059,19 @@ var Ro = class {
10829
11059
  clear() {
10830
11060
  this._okIdToExternalId.clear(), this._externalIdToOkId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
10831
11061
  }
10832
- }, Bo = 700, Vo = 3e3, Ho = class extends Ro {
11062
+ }, Go = 700, Ko = 3e3, qo = class extends Uo {
10833
11063
  constructor(...e) {
10834
- super(...e), h(this, "_userId", null), h(this, "_uuid", void 0), h(this, "_idCache", new zo());
11064
+ super(...e), h(this, "_userId", null), h(this, "_uuid", void 0), h(this, "_idCache", new Wo());
10835
11065
  }
10836
11066
  async _callUnsafe(e, t = {}, n = !1) {
10837
11067
  let r = async (i) => {
10838
11068
  try {
10839
- return await Po(e, t, n);
11069
+ return await zo(e, t, n);
10840
11070
  } catch (t) {
10841
11071
  if (!Object.hasOwn(t, "error_msg")) {
10842
11072
  i++;
10843
11073
  let n = Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`);
10844
- 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 * Bo, Vo), { signal: this._abortSignal }), r(i);
11074
+ 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 * Go, Ko), { signal: this._abortSignal }), r(i);
10845
11075
  }
10846
11076
  throw R.warn(e, "error", t), t;
10847
11077
  }
@@ -10864,7 +11094,7 @@ var Ro = class {
10864
11094
  code: r.error_code
10865
11095
  };
10866
11096
  if (r instanceof O) throw r;
10867
- if (r.custom_error && (a.custom_error = r.custom_error), Uo(r)) switch (r.error_code) {
11097
+ if (r.custom_error && (a.custom_error = r.custom_error), Jo(r)) switch (r.error_code) {
10868
11098
  case 1101:
10869
11099
  i = D.SERVICE_DISABLED;
10870
11100
  break;
@@ -10888,7 +11118,7 @@ var Ro = class {
10888
11118
  i = D.CALLER_IS_REJECTED;
10889
11119
  break;
10890
11120
  case 1114:
10891
- i = D.VCHAT_DETAILED_ERROR;
11121
+ a.custom_error?.vchat_detailed_api_error?.code?.startsWith("obsolete_client") ? (i = D.OBSOLETE_CLIENT, a.message = a.custom_error.vchat_detailed_api_error.code) : i = D.VCHAT_DETAILED_ERROR;
10892
11122
  break;
10893
11123
  case 2:
10894
11124
  i = D.SERVICE_UNAVAILABLE;
@@ -10926,7 +11156,7 @@ var Ro = class {
10926
11156
  version: 1,
10927
11157
  items: e
10928
11158
  };
10929
- M.clientStatsPlatform && (t.platform = M.clientStatsPlatform), No("vchat.clientStats", { data: JSON.stringify(t) });
11159
+ M.clientStatsPlatform && (t.platform = M.clientStatsPlatform), Ro("vchat.clientStats", { data: JSON.stringify(t) });
10930
11160
  }
10931
11161
  logClientEvents(e) {
10932
11162
  let t = {
@@ -10936,7 +11166,7 @@ var Ro = class {
10936
11166
  version: 1,
10937
11167
  items: e
10938
11168
  };
10939
- M.clientStatsPlatform && (t.platform = M.clientStatsPlatform), No("vchat.clientEvents", { data: JSON.stringify(t) });
11169
+ M.clientStatsPlatform && (t.platform = M.clientStatsPlatform), Ro("vchat.clientEvents", { data: JSON.stringify(t) });
10940
11170
  }
10941
11171
  async uploadDebugLogs(e, t, n, r) {
10942
11172
  let i = {
@@ -10947,7 +11177,7 @@ var Ro = class {
10947
11177
  }, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
10948
11178
  o.append("file", s, "log.json");
10949
11179
  let c = new URL(a.upload_url);
10950
- return c.searchParams.append("size", s.size.toString()), Io(c.toString(), o);
11180
+ return c.searchParams.append("size", s.size.toString()), Vo(c.toString(), o);
10951
11181
  }
10952
11182
  async joinConversation(e, t = !1, n) {
10953
11183
  let r = {
@@ -10986,13 +11216,13 @@ var Ro = class {
10986
11216
  externalIds: l
10987
11217
  });
10988
11218
  if (t && t.length) switch (n) {
10989
- case Ea.USER:
11219
+ case Oa.USER:
10990
11220
  u.uids = t.join(",");
10991
11221
  break;
10992
- case Ea.GROUP:
11222
+ case Oa.GROUP:
10993
11223
  u.gid = t[0];
10994
11224
  break;
10995
- case Ea.CHAT:
11225
+ case Oa.CHAT:
10996
11226
  u.chatId = t[0];
10997
11227
  break;
10998
11228
  }
@@ -11085,7 +11315,7 @@ var Ro = class {
11085
11315
  conversationId: e,
11086
11316
  reason: t
11087
11317
  };
11088
- M.anonymToken && (n.anonymToken = M.anonymToken), No("vchat.hangupConversation", n);
11318
+ M.anonymToken && (n.anonymToken = M.anonymToken), Ro("vchat.hangupConversation", n);
11089
11319
  }
11090
11320
  async removeHistoryRecords(e) {
11091
11321
  await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
@@ -11103,7 +11333,7 @@ var Ro = class {
11103
11333
  t.set(e, a), this.cacheExternalId(e, a);
11104
11334
  }
11105
11335
  };
11106
- n.external_ids && r(n.external_ids, Ra.USER), n.anonym_ids && r(n.anonym_ids, Ra.ANONYM);
11336
+ n.external_ids && r(n.external_ids, Ba.USER), n.anonym_ids && r(n.anonym_ids, Ba.ANONYM);
11107
11337
  for (let n of e) {
11108
11338
  let e = Number(n);
11109
11339
  if (!t.has(e)) {
@@ -11120,16 +11350,16 @@ var Ro = class {
11120
11350
  return (await this._call("system.getInfo")).serverTime;
11121
11351
  }
11122
11352
  };
11123
- function Uo(e) {
11353
+ function Jo(e) {
11124
11354
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
11125
11355
  }
11126
11356
  //#endregion
11127
11357
  //#region src/enums/RecordRole.ts
11128
- var Wo = /* @__PURE__ */ function(e) {
11358
+ var Yo = /* @__PURE__ */ function(e) {
11129
11359
  return e.KING = "KING", e.PAWN = "PAWN", e;
11130
- }(Wo || {}), Go = /* @__PURE__ */ function(e) {
11360
+ }(Yo || {}), Xo = /* @__PURE__ */ function(e) {
11131
11361
  return e.OFF = "0", e.ON = "1", e;
11132
- }({}), Ko = class {
11362
+ }({}), Zo = class {
11133
11363
  constructor(e) {
11134
11364
  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;
11135
11365
  }
@@ -11152,12 +11382,12 @@ var Wo = /* @__PURE__ */ function(e) {
11152
11382
  let e = this._queue[this._readCursor];
11153
11383
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
11154
11384
  }
11155
- }, qo = class {
11385
+ }, Qo = class {
11156
11386
  constructor(e, t, n, r = null) {
11157
11387
  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;
11158
11388
  }
11159
11389
  async authorize() {
11160
- let e = await Po("auth.anonymLogin", {
11390
+ let e = await zo("auth.anonymLogin", {
11161
11391
  session_data: {
11162
11392
  device_id: this._uuid,
11163
11393
  client_version: M.appVersion,
@@ -11166,18 +11396,18 @@ var Wo = /* @__PURE__ */ function(e) {
11166
11396
  version: 3
11167
11397
  },
11168
11398
  application_key: this._apiKey
11169
- }, !0, await jo(this._baseApiUrl, this._apiEnv));
11399
+ }, !0, await Io(this._baseApiUrl, this._apiEnv));
11170
11400
  return j.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
11171
11401
  }
11172
11402
  async hangupConversation(e) {
11173
- await Po("vchat.hangupConversation", {
11403
+ await zo("vchat.hangupConversation", {
11174
11404
  conversationId: e,
11175
11405
  reason: D.HUNGUP,
11176
11406
  application_key: this._apiKey,
11177
11407
  session_key: this._sessionKey
11178
- }, !0, await jo(this._baseApiUrl, this._apiEnv));
11408
+ }, !0, await Io(this._baseApiUrl, this._apiEnv));
11179
11409
  }
11180
- }, $, Jo = null, Yo = {
11410
+ }, $, $o = null, es = {
11181
11411
  getCameras: T.getCameras,
11182
11412
  getMicrophones: T.getMicrophones,
11183
11413
  getOutput: T.getOutput,
@@ -11203,33 +11433,33 @@ var Wo = /* @__PURE__ */ function(e) {
11203
11433
  baseChromeVersion: T.baseChromeVersion,
11204
11434
  getAudioContext: T.getAudioContext,
11205
11435
  isAudioShareSupported: T.isAudioShareSupported
11206
- }, Xo = { participantMarkerCompare: j.participantMarkerCompare };
11207
- function Zo(e) {
11208
- Jo = e;
11436
+ }, ts = { participantMarkerCompare: j.participantMarkerCompare };
11437
+ function ns(e) {
11438
+ $o = e;
11209
11439
  }
11210
- function Qo(e) {
11440
+ function rs(e) {
11211
11441
  M.videoEffects = e;
11212
11442
  }
11213
- function $o(e) {
11443
+ function is(e) {
11214
11444
  M.audioEffects = e;
11215
11445
  }
11216
- function es(e, t = null, n = {}, r = 1) {
11446
+ function as(e, t = null, n = {}, r = 1) {
11217
11447
  M.vmoji = e, M.vmojiOptions = {
11218
11448
  protocolVersion: r,
11219
11449
  renderingOptions: n
11220
11450
  }, t && e.setSDK(t);
11221
11451
  }
11222
- async function ts(t) {
11223
- if (M.set(t), $ || ($ = new Ho()), 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);
11452
+ async function os(t) {
11453
+ if (M.set(t), $ || ($ = new qo()), 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);
11224
11454
  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}`);
11225
11455
  }
11226
- async function ns(e, t = [x.AUDIO], n = "", r = !1, i = !1, a, o, s) {
11456
+ async function ss(e, t = [x.AUDIO], n = "", r = !1, i = !1, a, o, s) {
11227
11457
  let c = [];
11228
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), rs([], Ea.USER, t, n, r, i, a, c, o, s);
11458
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), cs([], Oa.USER, t, n, r, i, a, c, o, s);
11229
11459
  }
11230
- async function rs(e, t = Ea.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
11460
+ async function cs(e, t = Oa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
11231
11461
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.FAILED);
11232
- return new Q($, Jo).onStart({
11462
+ return new Q($, $o).onStart({
11233
11463
  opponentIds: e,
11234
11464
  opponentType: t,
11235
11465
  mediaOptions: n,
@@ -11242,37 +11472,37 @@ async function rs(e, t = Ea.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
11242
11472
  conversationId: l
11243
11473
  });
11244
11474
  }
11245
- async function is(e, t) {
11246
- return as(e, A.USER, void 0, t);
11475
+ async function ls(e, t) {
11476
+ return us(e, A.USER, void 0, t);
11247
11477
  }
11248
- async function as(e, t = A.USER, n, r, i, a) {
11478
+ async function us(e, t = A.USER, n, r, i, a) {
11249
11479
  if (e === Q.id()) throw Error("Push has already been processed");
11250
- return a && $.setUserId(a), new Q($, Jo).onPush(e, t, n, r, i);
11480
+ return a && $.setUserId(a), new Q($, $o).onPush(e, t, n, r, i);
11251
11481
  }
11252
- async function os(e, t) {
11253
- return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, ko()), $.authorize();
11482
+ async function ds(e, t) {
11483
+ return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, Po()), $.authorize();
11254
11484
  }
11255
- async function ss(e = [x.AUDIO], t) {
11256
- return jc(t).accept(e);
11485
+ async function fs(e = [x.AUDIO], t) {
11486
+ return Ic(t).accept(e);
11257
11487
  }
11258
- async function cs(e) {
11259
- let t = Ac(e);
11488
+ async function ps(e) {
11489
+ let t = Fc(e);
11260
11490
  if (t) return t.decline();
11261
11491
  }
11262
- async function ls(e, t = [x.AUDIO]) {
11263
- return us(e, t);
11492
+ async function ms(e, t = [x.AUDIO]) {
11493
+ return hs(e, t);
11264
11494
  }
11265
- async function us(e, t, n) {
11495
+ async function hs(e, t, n) {
11266
11496
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.FAILED);
11267
- return new Q($, Jo).onJoin({
11497
+ return new Q($, $o).onJoin({
11268
11498
  conversationId: e,
11269
11499
  mediaOptions: t,
11270
11500
  chatId: n
11271
11501
  });
11272
11502
  }
11273
- async function ds(e, t = [x.AUDIO], n, r, i, a) {
11503
+ async function gs(e, t = [x.AUDIO], n, r, i, a) {
11274
11504
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.FAILED);
11275
- return n && (M.anonymToken = n), new Q($, Jo).onJoin({
11505
+ return n && (M.anonymToken = n), new Q($, $o).onJoin({
11276
11506
  joinLink: e,
11277
11507
  mediaOptions: t,
11278
11508
  observedIds: r,
@@ -11280,31 +11510,31 @@ async function ds(e, t = [x.AUDIO], n, r, i, a) {
11280
11510
  onFastJoin: a
11281
11511
  });
11282
11512
  }
11283
- async function fs(e) {
11284
- let t = Ac(e);
11513
+ async function _s(e) {
11514
+ let t = Fc(e);
11285
11515
  if (t) return t.hangup();
11286
11516
  Q.hangupAfterInit();
11287
11517
  }
11288
- async function ps(e, t) {
11518
+ async function vs(e, t) {
11289
11519
  let n = Array.isArray(e) ? e : [e], r = Q.current();
11290
11520
  r && await r.addParticipant(n, t);
11291
11521
  }
11292
- async function ms(e, t) {
11522
+ async function ys(e, t) {
11293
11523
  let n = Q.current();
11294
11524
  if (n) {
11295
11525
  let r = e.map((e) => j.composeUserId(e));
11296
11526
  await n.addParticipantLegacy(r, t);
11297
11527
  }
11298
11528
  }
11299
- async function hs(e, t = !1) {
11529
+ async function bs(e, t = !1) {
11300
11530
  let n = $.getCachedRawOkIdByExternalId(e);
11301
11531
  if (!n) {
11302
11532
  R.warn("removeParticipant: externalId not found in cache", e);
11303
11533
  return;
11304
11534
  }
11305
- return gs(n, t);
11535
+ return xs(n, t);
11306
11536
  }
11307
- async function gs(e, t = !1) {
11537
+ async function xs(e, t = !1) {
11308
11538
  let n = Q.current();
11309
11539
  if (n) try {
11310
11540
  await n.removeParticipant(j.composeUserId(e), t);
@@ -11312,13 +11542,13 @@ async function gs(e, t = !1) {
11312
11542
  R.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
11313
11543
  }
11314
11544
  }
11315
- async function _s(e, t) {
11545
+ async function Ss(e, t) {
11316
11546
  let n = Q.current();
11317
11547
  if (e === "videoinput" && At.contains(t)) return M.videoFacingMode = t, n ? (T.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
11318
11548
  if (!await T._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
11319
11549
  if (n) return n.changeDevice(e);
11320
11550
  }
11321
- async function vs(e, t) {
11551
+ async function Cs(e, t) {
11322
11552
  let n = typeof e == "object" ? {
11323
11553
  ...e,
11324
11554
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -11327,34 +11557,34 @@ async function vs(e, t) {
11327
11557
  captureScreen: e,
11328
11558
  fastScreenSharing: !1,
11329
11559
  captureAudio: !1
11330
- }, r = Ac(t);
11560
+ }, r = Fc(t);
11331
11561
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
11332
11562
  }
11333
- function ys(e) {
11563
+ function ws(e) {
11334
11564
  let t = Q.current();
11335
11565
  t && t.toggleAnimojiCapturing(e);
11336
11566
  }
11337
- async function bs(e, t = !1) {
11567
+ async function Ts(e, t = !1) {
11338
11568
  let n = Q.current();
11339
11569
  n && await n.setVideoStream(e, t);
11340
11570
  }
11341
- async function xs(e, t) {
11342
- let n = Ac(t);
11571
+ async function Es(e, t) {
11572
+ let n = Fc(t);
11343
11573
  n && await n.toggleLocalVideo(e);
11344
11574
  }
11345
- async function Ss(e, t) {
11346
- let n = Ac(t);
11575
+ async function Ds(e, t) {
11576
+ let n = Fc(t);
11347
11577
  n && await n.toggleLocalAudio(e);
11348
11578
  }
11349
- async function Cs(e) {
11579
+ async function Os(e) {
11350
11580
  let t = Q.current();
11351
11581
  if (t) return t.setLocalResolution(e);
11352
11582
  }
11353
- async function ws(e) {
11583
+ async function ks(e) {
11354
11584
  let t = Q.current();
11355
11585
  t && await t.changePriorities(e);
11356
11586
  }
11357
- async function Ts(e, t) {
11587
+ async function As(e, t) {
11358
11588
  let n = Q.current();
11359
11589
  if (n) {
11360
11590
  let r;
@@ -11369,33 +11599,33 @@ async function Ts(e, t) {
11369
11599
  await n.changeParticipantState(e, r);
11370
11600
  }
11371
11601
  }
11372
- async function Es() {
11602
+ async function js() {
11373
11603
  let e = Q.current();
11374
11604
  e && await e.putHandsDown();
11375
11605
  }
11376
- async function Ds(e) {
11606
+ async function Ms(e) {
11377
11607
  let t = Q.current();
11378
11608
  t && await t.updateDisplayLayout(e);
11379
11609
  }
11380
- async function Os(e) {
11610
+ async function Ns(e) {
11381
11611
  let t = Q.current();
11382
11612
  t && await t.requestDisplayLayout(e);
11383
11613
  }
11384
- async function ks(e, t, n = !1) {
11614
+ async function Ps(e, t, n = !1) {
11385
11615
  let r = $.getCachedRawOkIdByExternalId(e);
11386
11616
  if (!r) {
11387
11617
  R.warn("grantRoles: externalId not found in cache", e);
11388
11618
  return;
11389
11619
  }
11390
- return As(r, Z.getDeviceIdx(e), t, n);
11620
+ return Fs(r, Z.getDeviceIdx(e), t, n);
11391
11621
  }
11392
- async function As(e, t, n, r = !1) {
11622
+ async function Fs(e, t, n, r = !1) {
11393
11623
  let i = Q.current();
11394
11624
  i && await i.grantRoles(j.composeParticipantId(e, A.USER, t), n, r);
11395
11625
  }
11396
- async function js({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
11626
+ async function Is({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
11397
11627
  let i = null;
11398
- return e && (i = $.getCachedRawOkIdByExternalId(e), i || R.warn("muteParticipant: externalId not found in cache", e)), Ms({
11628
+ return e && (i = $.getCachedRawOkIdByExternalId(e), i || R.warn("muteParticipant: externalId not found in cache", e)), Ls({
11399
11629
  uid: i,
11400
11630
  muteStates: t,
11401
11631
  requestedMedia: n,
@@ -11403,75 +11633,75 @@ async function js({ externalId: e = null, muteStates: t, requestedMedia: n = [],
11403
11633
  roomId: r
11404
11634
  });
11405
11635
  }
11406
- async function Ms({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
11636
+ async function Ls({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
11407
11637
  let a = Q.current();
11408
11638
  if (a) {
11409
11639
  let o = e ? j.composeParticipantId(e, A.USER, r) : null;
11410
11640
  await a.muteParticipant(o, t, n, i);
11411
11641
  }
11412
11642
  }
11413
- async function Ns(e, t = !1, n = null) {
11643
+ async function Rs(e, t = !1, n = null) {
11414
11644
  let r = $.getCachedRawOkIdByExternalId(e);
11415
11645
  if (!r) {
11416
11646
  R.warn("pinParticipant: externalId not found in cache", e);
11417
11647
  return;
11418
11648
  }
11419
- return Ps(r, t, Z.getDeviceIdx(e), n);
11649
+ return zs(r, t, Z.getDeviceIdx(e), n);
11420
11650
  }
11421
- async function Ps(e, t = !1, n = 0, r = null) {
11651
+ async function zs(e, t = !1, n = 0, r = null) {
11422
11652
  let i = Q.current();
11423
11653
  i && await i.pinParticipant(j.composeParticipantId(e, A.USER, n), t, r);
11424
11654
  }
11425
- async function Fs(e) {
11655
+ async function Bs(e) {
11426
11656
  let t = Q.current();
11427
11657
  t && await t.updateMediaModifiers(e);
11428
11658
  }
11429
- async function Is(e) {
11659
+ async function Vs(e) {
11430
11660
  let t = Q.current();
11431
11661
  t && await t.enableVideoSuspend(e);
11432
11662
  }
11433
- async function Ls(e) {
11663
+ async function Hs(e) {
11434
11664
  let t = Q.current();
11435
11665
  t && await t.enableVideoSuspendSuggest(e);
11436
11666
  }
11437
- async function Rs(e) {
11667
+ async function Us(e) {
11438
11668
  let t = Q.current();
11439
11669
  t && await t.changeOptions(e);
11440
11670
  }
11441
- async function zs(e, t = null) {
11671
+ async function Ws(e, t = null) {
11442
11672
  let n = null;
11443
- return t && (n = $.getCachedRawOkIdByExternalId(t), n || R.warn("chatMessage: externalId not found in cache", t)), Bs(e, n);
11673
+ return t && (n = $.getCachedRawOkIdByExternalId(t), n || R.warn("chatMessage: externalId not found in cache", t)), Gs(e, n);
11444
11674
  }
11445
- async function Bs(e, t = null) {
11675
+ async function Gs(e, t = null) {
11446
11676
  let n = Q.current();
11447
11677
  if (n) {
11448
11678
  let r = t ? j.composeUserId(t) : null;
11449
11679
  await n.chatMessage(e, r);
11450
11680
  }
11451
11681
  }
11452
- async function Vs(e = 10) {
11682
+ async function Ks(e = 10) {
11453
11683
  let t = Q.current();
11454
11684
  if (t) return t.chatHistory(e);
11455
11685
  }
11456
- async function Hs(e, t = null) {
11686
+ async function qs(e, t = null) {
11457
11687
  let n = null;
11458
- return t && (n = $.getCachedRawOkIdByExternalId(t), n || R.warn("customData: externalId not found in cache", t)), Us(e, n, Z.getDeviceIdx(t));
11688
+ return t && (n = $.getCachedRawOkIdByExternalId(t), n || R.warn("customData: externalId not found in cache", t)), Js(e, n, Z.getDeviceIdx(t));
11459
11689
  }
11460
- async function Us(e, t = null, n = 0) {
11690
+ async function Js(e, t = null, n = 0) {
11461
11691
  let r = Q.current();
11462
11692
  if (r) {
11463
11693
  let i = t ? j.composeParticipantId(t, A.USER, n) : null;
11464
11694
  await r.customData(e, i);
11465
11695
  }
11466
11696
  }
11467
- async function Ws(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
11697
+ async function Ys(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
11468
11698
  return (await $.createConversation(a ?? j.uuid(), e, t, {
11469
11699
  onlyAdminCanShareMovie: n,
11470
11700
  waitForAdmin: r,
11471
11701
  closedConversation: i
11472
11702
  })).join_link;
11473
11703
  }
11474
- async function Gs(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
11704
+ async function Xs(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
11475
11705
  let a = i.map((e) => Z.fromId(e));
11476
11706
  return (await $.createConversation(j.uuid(), e, t, {
11477
11707
  onlyAdminCanShareMovie: n,
@@ -11479,53 +11709,53 @@ async function Gs(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r
11479
11709
  audioOnly: r
11480
11710
  }, a)).join_link;
11481
11711
  }
11482
- async function Ks() {
11712
+ async function Zs() {
11483
11713
  let e = Q.current();
11484
11714
  return e ? e.createJoinLink() : Promise.reject();
11485
11715
  }
11486
- async function qs() {
11716
+ async function Qs() {
11487
11717
  let e = Q.current();
11488
11718
  return e ? e.removeJoinLink() : Promise.reject();
11489
11719
  }
11490
- async function Js(e, t) {
11720
+ async function $s(e, t) {
11491
11721
  return $.getAnonymTokenByLink(e, t);
11492
11722
  }
11493
- function Ys(e) {
11723
+ function ec(e) {
11494
11724
  let t = Q.current();
11495
11725
  t && t.setVolume(e);
11496
11726
  }
11497
- function Xs(e) {
11727
+ function tc(e) {
11498
11728
  M.forceRelayPolicy = e;
11499
11729
  }
11500
- async function Zs(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
11730
+ async function nc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
11501
11731
  let o = Q.current();
11502
11732
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
11503
11733
  }
11504
- async function Qs(e = null, t) {
11734
+ async function rc(e = null, t) {
11505
11735
  let n = Q.current();
11506
11736
  return n ? n.stopStream(e, t) : Promise.reject();
11507
11737
  }
11508
- async function $s(e = null) {
11738
+ async function ic(e = null) {
11509
11739
  let t = Q.current();
11510
11740
  return t ? t.publishStream(e) : Promise.reject();
11511
11741
  }
11512
- async function ec() {
11742
+ async function ac() {
11513
11743
  let e = Q.current();
11514
11744
  return e ? e.getStreamInfo() : Promise.reject();
11515
11745
  }
11516
- async function tc(e) {
11746
+ async function oc(e) {
11517
11747
  let t = Q.current();
11518
11748
  return t ? t.addMovie(e) : Promise.reject();
11519
11749
  }
11520
- async function nc(e) {
11750
+ async function sc(e) {
11521
11751
  let t = Q.current();
11522
11752
  return t ? t.updateMovie(e) : Promise.reject();
11523
11753
  }
11524
- async function rc(e) {
11754
+ async function cc(e) {
11525
11755
  let t = Q.current();
11526
11756
  return t ? t.removeMovie(e) : Promise.reject();
11527
11757
  }
11528
- async function ic(e, t) {
11758
+ async function lc(e, t) {
11529
11759
  let n = Q.current();
11530
11760
  if (n) {
11531
11761
  let r = [];
@@ -11550,11 +11780,11 @@ async function ic(e, t) {
11550
11780
  }
11551
11781
  return Promise.reject();
11552
11782
  }
11553
- async function ac(e, t) {
11783
+ async function uc(e, t) {
11554
11784
  let n = Q.current();
11555
11785
  return n ? n.activateRooms(e, t) : Promise.reject();
11556
11786
  }
11557
- async function oc(e = null, t = null) {
11787
+ async function dc(e = null, t = null) {
11558
11788
  let n = Q.current();
11559
11789
  if (!n) return Promise.reject();
11560
11790
  let r;
@@ -11569,22 +11799,22 @@ async function oc(e = null, t = null) {
11569
11799
  }
11570
11800
  return n.switchRoom(e, r);
11571
11801
  }
11572
- async function sc(e) {
11802
+ async function fc(e) {
11573
11803
  let t = Q.current();
11574
11804
  return t ? t.removeRooms(e) : Promise.reject();
11575
11805
  }
11576
- function cc(e) {
11806
+ function pc(e) {
11577
11807
  M.statisticsInterval = e;
11578
11808
  let t = Q.current();
11579
11809
  if (t) return t.updateStatisticsInterval();
11580
11810
  }
11581
- function lc(t) {
11811
+ function mc(t) {
11582
11812
  e.disableLog(!t), R.toggle(t);
11583
11813
  }
11584
- function uc(e, ...t) {
11814
+ function hc(e, ...t) {
11585
11815
  M.debugLog && R.send(e, "[external]", ...t);
11586
11816
  }
11587
- var dc = {
11817
+ var gc = {
11588
11818
  list: Pe,
11589
11819
  get: Fe,
11590
11820
  getJson: Ie,
@@ -11592,7 +11822,7 @@ var dc = {
11592
11822
  clear: Re,
11593
11823
  stats: ze
11594
11824
  };
11595
- function fc() {
11825
+ function _c() {
11596
11826
  let e = [
11597
11827
  [`Calls SDK ${M.sdkVersion}`, M.toJSON()],
11598
11828
  ["UserAgent:", navigator.userAgent],
@@ -11609,31 +11839,31 @@ function fc() {
11609
11839
  d: e
11610
11840
  }));
11611
11841
  }
11612
- async function pc() {
11842
+ async function vc() {
11613
11843
  let e = Q.id(), t = Q.debugSessionId();
11614
11844
  if (!t || !e) throw R.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
11615
11845
  let n = await Fe({ sessionId: t });
11616
11846
  if (n.length === 0) throw R.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
11617
11847
  let r = n[0].t, i = n[n.length - 1].t;
11618
11848
  try {
11619
- return $?.uploadDebugLogs(e, r, i, JSON.stringify([...fc(), ...n]));
11849
+ return $?.uploadDebugLogs(e, r, i, JSON.stringify([..._c(), ...n]));
11620
11850
  } catch (e) {
11621
11851
  throw R.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
11622
11852
  }
11623
11853
  }
11624
- async function mc(e) {
11854
+ async function yc(e) {
11625
11855
  let t = Q.current();
11626
11856
  if (t) return t.videoEffect(e);
11627
11857
  }
11628
- async function hc(e, t) {
11858
+ async function bc(e, t) {
11629
11859
  let n = Q.current();
11630
11860
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
11631
11861
  }
11632
- async function gc(e) {
11862
+ async function xc(e) {
11633
11863
  let t = Q.current();
11634
11864
  t && await t.setAudioStream(e);
11635
11865
  }
11636
- async function _c(e, t = null, n = null) {
11866
+ async function Sc(e, t = null, n = null) {
11637
11867
  let r = Q.current();
11638
11868
  if (!r) return;
11639
11869
  let i = n ?? t?.id, a = null;
@@ -11644,18 +11874,18 @@ async function _c(e, t = null, n = null) {
11644
11874
  }
11645
11875
  r.setAnimojiSvg(e, a, i);
11646
11876
  }
11647
- function vc(e) {
11877
+ function Cc(e) {
11648
11878
  let t = Q.current();
11649
11879
  t && t.setAnimojiFill(e);
11650
11880
  }
11651
- async function yc(e = null, t, n = !1) {
11652
- return jc().getWaitingHall(e, t, n);
11881
+ async function wc(e = null, t, n = !1) {
11882
+ return Ic().getWaitingHall(e, t, n);
11653
11883
  }
11654
- async function bc() {
11655
- return jc().getAudienceModeHands();
11884
+ async function Tc() {
11885
+ return Ic().getAudienceModeHands();
11656
11886
  }
11657
- async function xc(e, t = !1) {
11658
- let n = jc(), r;
11887
+ async function Ec(e, t = !1) {
11888
+ let n = Ic(), r;
11659
11889
  if (e) {
11660
11890
  let t = $.getCachedRawOkIdByExternalId(e);
11661
11891
  if (!t) {
@@ -11666,74 +11896,74 @@ async function xc(e, t = !1) {
11666
11896
  }
11667
11897
  return n.promoteParticipant(r, t);
11668
11898
  }
11669
- async function Sc(e = !1) {
11670
- return jc().requestPromotion(e);
11899
+ async function Dc(e = !1) {
11900
+ return Ic().requestPromotion(e);
11671
11901
  }
11672
- async function Cc(e = !1) {
11673
- return jc().acceptPromotion(e);
11902
+ async function Oc(e = !1) {
11903
+ return Ic().acceptPromotion(e);
11674
11904
  }
11675
- async function wc(e) {
11676
- return jc().getParticipantListChunk(e);
11905
+ async function kc(e) {
11906
+ return Ic().getParticipantListChunk(e);
11677
11907
  }
11678
- async function Tc(e) {
11679
- return jc().getParticipants(e);
11908
+ async function Ac(e) {
11909
+ return Ic().getParticipants(e);
11680
11910
  }
11681
- async function Ec(e) {
11682
- return jc().feedback(e);
11911
+ async function jc(e) {
11912
+ return Ic().feedback(e);
11683
11913
  }
11684
- function Dc(e, t, n) {
11685
- return jc().userFeedbackStats(e, t, n);
11914
+ function Mc(e, t, n) {
11915
+ return Ic().userFeedbackStats(e, t, n);
11686
11916
  }
11687
- function Oc(e, t = {}, n = !1) {
11917
+ function Nc(e, t = {}, n = !1) {
11688
11918
  let r = Q.current();
11689
11919
  r && r.sendClientEvent(e, t, n);
11690
11920
  }
11691
- async function kc(e, t, n) {
11692
- return jc(n).enableFeatureForRoles(e, t);
11921
+ async function Pc(e, t, n) {
11922
+ return Ic(n).enableFeatureForRoles(e, t);
11693
11923
  }
11694
- function Ac(e) {
11695
- return e ? z.get(e) ?? null : Q.current();
11924
+ function Fc(e) {
11925
+ return e ? z.get(e) ?? null : Q.current() ?? z.getFirstHeld();
11696
11926
  }
11697
- function jc(e) {
11698
- let t = Ac(e);
11927
+ function Ic(e) {
11928
+ let t = Fc(e);
11699
11929
  if (!t) throw Error("Conversation not found");
11700
11930
  return t;
11701
11931
  }
11702
- async function Mc(e) {
11932
+ async function Lc(e) {
11703
11933
  await $.removeHistoryRecords(e);
11704
11934
  }
11705
- async function Nc(e) {
11935
+ async function Rc(e) {
11706
11936
  let t = Q.current();
11707
11937
  t && await t.startAsr(e);
11708
11938
  }
11709
- async function Pc(e) {
11939
+ async function zc(e) {
11710
11940
  let t = Q.current();
11711
11941
  t && await t.stopAsr(e);
11712
11942
  }
11713
- async function Fc(e) {
11943
+ async function Bc(e) {
11714
11944
  let t = Q.current();
11715
11945
  t && await t.requestAsr(e);
11716
11946
  }
11717
- async function Ic(e) {
11947
+ async function Vc(e) {
11718
11948
  let t = Q.current();
11719
11949
  return t ? t.startUrlSharing(e) : Promise.reject();
11720
11950
  }
11721
- async function Lc() {
11951
+ async function Hc() {
11722
11952
  let e = Q.current();
11723
11953
  return e ? e.stopUrlSharing() : Promise.reject();
11724
11954
  }
11725
- async function Rc(e) {
11726
- await z.setActive(e);
11955
+ async function Uc(e) {
11956
+ await z.switchCall(e);
11727
11957
  }
11728
- function zc() {
11958
+ function Wc() {
11729
11959
  return z.getActiveId();
11730
11960
  }
11731
- function Bc() {
11961
+ function Gc() {
11732
11962
  return Q.getSyncedTime();
11733
11963
  }
11734
- function Vc() {
11964
+ function Kc() {
11735
11965
  return M.sdkVersion;
11736
11966
  }
11737
11967
  typeof window < "u" && (window.__CALLS_SDK = mn);
11738
11968
  //#endregion
11739
- export { Ho as Api, qo as ApiExternal, Ko as ArrayDequeue, v as AuthData, f as BaseLogger, Y as CallDirection, Ea as CallType, Da as ChatRoomEventType, Oa as ConversationFeature, ka as ConversationOption, _n as DebugMessageType, Ra as ExternalIdType, At as FacingMode, b as FatalError, O as HangupReason, D as HangupType, x as MediaOption, k as MediaTrackKind, V as MediaType, Ma as MuteState, X as ParticipantState, Go as ParticipantStateDataValue, N as ParticipantStatus, Wo as RecordRole, Na as RoomsEventType, Ta as Signaling, B as SignalingCommandType, dr as SignalingConnectionType, G as SignalingNotification, q as TransportTopology, Ia as UserRole, A as UserType, to as VolumeDetector, ss as acceptCall, Cc as acceptPromotion, ac as activateRooms, tc as addMovie, ps as addParticipant, ms as addParticipantInternal, os as authorize, Yo as browser, rs as callInternal, ns as callTo, vs as captureScreen, ys as captureVmoji, hc as changeAudioEffect, Rs as changeConversationOptions, _s as changeDevice, Ts as changeParticipantState, ws as changePriorities, mc as changeVideoEffect, Vs as chatHistory, zs as chatMessage, Bs as chatMessageInternal, Ks as createJoinLink, Hs as customData, Us as customDataInternal, lc as debug, dc as debugLogs, uc as debugMessage, cs as declineCall, kc as enableFeatureForRoles, Is as enableVideoSuspend, Ls as enableVideoSuspendSuggest, Ec as feedback, Xs as forceRelayPolicy, zc as getActiveCallId, Js as getAnonymTokenByLink, bc as getAudienceModeHands, wc as getParticipantListChunk, Tc as getParticipants, ec as getStreamInfo, Bc as getSyncedTime, yc as getWaitingHall, ks as grantRoles, As as grantRolesInternal, fs as hangup, ts as init, ls as joinCall, ds as joinCallByLink, us as joinCallInternal, Oc as logClientEvent, js as muteParticipant, Ms as muteParticipantInternal, Ns as pinParticipant, Ps as pinParticipantInternal, is as processPush, as as processPushInternal, xc as promoteParticipant, $s as publishStream, Es as putHandsDown, Mc as removeHistoryRecords, qs as removeJoinLink, rc as removeMovie, hs as removeParticipant, gs as removeParticipantInternal, sc as removeRooms, Fc as requestAsr, Os as requestDisplayLayout, Sc as requestPromotion, $o as setAudioEffects, gc as setAudioStream, Cs as setLocalResolution, Zo as setLogger, Fs as setMediaModifiers, cc as setStatisticsInterval, Qo as setVideoEffects, bs as setVideoStream, es as setVmoji, vc as setVmojiFill, _c as setVmojiSvg, Ys as setVolume, Nc as startAsr, Gs as startAudienceConversation, Ws as startConversation, Zs as startStream, Ic as startUrlSharing, Pc as stopAsr, Qs as stopStream, Lc as stopUrlSharing, Rc as switchCall, oc as switchRoom, Ss as toggleLocalAudio, xs as toggleLocalVideo, Ds as updateDisplayLayout, nc as updateMovie, ic as updateRooms, pc as uploadDebugLogs, Dc as userFeedbackStats, Xo as utils, Vc as version };
11969
+ export { qo as Api, Qo as ApiExternal, Zo as ArrayDequeue, v as AuthData, f as BaseLogger, Y as CallDirection, Oa as CallType, ka as ChatRoomEventType, Aa as ConversationFeature, ja as ConversationOption, _n as DebugMessageType, Ba as ExternalIdType, At as FacingMode, b as FatalError, O as HangupReason, D as HangupType, x as MediaOption, k as MediaTrackKind, V as MediaType, Pa as MuteState, X as ParticipantState, Xo as ParticipantStateDataValue, N as ParticipantStatus, Yo as RecordRole, Fa as RoomsEventType, Da as Signaling, B as SignalingCommandType, dr as SignalingConnectionType, G as SignalingNotification, q as TransportTopology, Ra as UserRole, A as UserType, oo as VolumeDetector, fs as acceptCall, Oc as acceptPromotion, uc as activateRooms, oc as addMovie, vs as addParticipant, ys as addParticipantInternal, ds as authorize, es as browser, cs as callInternal, ss as callTo, Cs as captureScreen, ws as captureVmoji, bc as changeAudioEffect, Us as changeConversationOptions, Ss as changeDevice, As as changeParticipantState, ks as changePriorities, yc as changeVideoEffect, Ks as chatHistory, Ws as chatMessage, Gs as chatMessageInternal, Zs as createJoinLink, qs as customData, Js as customDataInternal, mc as debug, gc as debugLogs, hc as debugMessage, ps as declineCall, Pc as enableFeatureForRoles, Vs as enableVideoSuspend, Hs as enableVideoSuspendSuggest, jc as feedback, tc as forceRelayPolicy, Wc as getActiveCallId, $s as getAnonymTokenByLink, Tc as getAudienceModeHands, kc as getParticipantListChunk, Ac as getParticipants, ac as getStreamInfo, Gc as getSyncedTime, wc as getWaitingHall, Ps as grantRoles, Fs as grantRolesInternal, _s as hangup, os as init, ms as joinCall, gs as joinCallByLink, hs as joinCallInternal, Nc as logClientEvent, Is as muteParticipant, Ls as muteParticipantInternal, Rs as pinParticipant, zs as pinParticipantInternal, ls as processPush, us as processPushInternal, Ec as promoteParticipant, ic as publishStream, js as putHandsDown, Lc as removeHistoryRecords, Qs as removeJoinLink, cc as removeMovie, bs as removeParticipant, xs as removeParticipantInternal, fc as removeRooms, Bc as requestAsr, Ns as requestDisplayLayout, Dc as requestPromotion, is as setAudioEffects, xc as setAudioStream, Os as setLocalResolution, ns as setLogger, Bs as setMediaModifiers, pc as setStatisticsInterval, rs as setVideoEffects, Ts as setVideoStream, as as setVmoji, Cc as setVmojiFill, Sc as setVmojiSvg, ec as setVolume, Rc as startAsr, Xs as startAudienceConversation, Ys as startConversation, nc as startStream, Vc as startUrlSharing, zc as stopAsr, rc as stopStream, Hc as stopUrlSharing, Uc as switchCall, dc as switchRoom, Ds as toggleLocalAudio, Es as toggleLocalVideo, Ms as updateDisplayLayout, sc as updateMovie, lc as updateRooms, vc as uploadDebugLogs, Mc as userFeedbackStats, ts as utils, Kc as version };