@vkontakte/calls-sdk 2.8.12-dev.dfea6e89.0 → 2.8.12-dev.ec5956ec.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/calls-sdk.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @vkontakte/calls-sdk v2.8.12-dev.dfea6e89.0
3
- * Wed, 12 Aug 2026 08:37:27 GMT
2
+ * @vkontakte/calls-sdk v2.8.12-dev.ec5956ec.0
3
+ * Mon, 24 Aug 2026 07:53:13 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -694,9 +694,9 @@ var jt = class {
694
694
  }
695
695
  }, Mt = class extends jt {
696
696
  constructor(e, t, n, r) {
697
- if (super(!1, !0), h(this, "captureController", void 0), this.captureController = "CaptureController" in window ? new CaptureController() : null, typeof this.video == "object" ? (delete this.video.deviceId, delete this.video.groupId, delete this.video.aspectRatio, delete this.video.frameRate, delete this.video.facingMode) : this.video = {}, this.video.cursor = "motion", this.video.width = e, this.video.height = t, this.video.frameRate = n, this.video.displaySurface = N.displaySurface, T.browserName() === "Safari") {
697
+ if (super(!1, !0), h(this, "captureController", void 0), this.captureController = "CaptureController" in window ? new CaptureController() : null, typeof this.video == "object" ? (delete this.video.deviceId, delete this.video.groupId, delete this.video.aspectRatio, delete this.video.frameRate, delete this.video.facingMode, delete this.video.width, delete this.video.height) : this.video = {}, this.video.cursor = "motion", e && (this.video.width = e), t && (this.video.height = t), this.video.frameRate = n, this.video.displaySurface = N.displaySurface, T.browserName() === "Safari") {
698
698
  let n = Number(T.browserVersion());
699
- n === 16 ? (this.video.width = { max: e }, this.video.height = { max: t }) : n === 17 && (delete this.video.width, delete this.video.height);
699
+ n === 16 ? (e && (this.video.width = { max: e }), t && (this.video.height = { max: t })) : n === 17 && (delete this.video.width, delete this.video.height);
700
700
  }
701
701
  r && (this.audio = {
702
702
  noiseSuppression: !1,
@@ -1018,7 +1018,7 @@ var T;
1018
1018
  }
1019
1019
  e.getUserMedia = h;
1020
1020
  async function te(e, t, n = z, r = null) {
1021
- return Vt(new Mt(e && !N.consumerFastScreenShare ? N.fastScreenShareWidth : window.screen.width, e && !N.consumerFastScreenShare ? N.fastScreenShareHeight : window.screen.height, N.getScreenFrameRate(e), t), n, r);
1021
+ return Vt(new Mt(e && !N.consumerFastScreenShare ? N.fastScreenShareWidth : 0, e && !N.consumerFastScreenShare ? N.fastScreenShareHeight : 0, N.getScreenFrameRate(e), t), n, r);
1022
1022
  }
1023
1023
  e.getScreenMedia = te;
1024
1024
  async function ne(e = !1, t, n = z, r = null) {
@@ -1288,7 +1288,8 @@ var O = /* @__PURE__ */ function(e) {
1288
1288
  return this._sendVideoTrack && !e ? this._sendVideoTrack : this._stream ? this._stream.getVideoTracks()[0] : null;
1289
1289
  }
1290
1290
  getSendAudioTrack() {
1291
- return this._stream?.getAudioTracks().find((e) => !e.contentHint) || null;
1291
+ let e = this._stream?.getAudioTracks().filter((e) => !e.contentHint) ?? [];
1292
+ return e.find((e) => e.enabled) ?? e[0] ?? null;
1292
1293
  }
1293
1294
  get isAnimojiRequested() {
1294
1295
  return this._animojiEnabled && !this._mediaSettings.isVideoEnabled;
@@ -1468,11 +1469,11 @@ var O = /* @__PURE__ */ function(e) {
1468
1469
  };
1469
1470
  if (e) try {
1470
1471
  let e = await E.getUserAudio(void 0, this._debug, this._logger);
1471
- this._micAudioTrack = e.getAudioTracks()[0], t(await this._applyAudioEffect(), !0);
1472
+ this._micAudioTrack = e.getAudioTracks()[0], await t(await this._applyAudioEffect(), !0);
1472
1473
  } catch (e) {
1473
- throw N.audioEffects?.pause(), t(E.getSilentMediaTrack(), !1), typeof e == "string" ? Error(e) : e;
1474
+ throw N.audioEffects?.pause(), await t(E.getSilentMediaTrack(), !1), typeof e == "string" ? Error(e) : e;
1474
1475
  }
1475
- else N.audioEffects?.pause(), t(E.getSilentMediaTrack(), !1);
1476
+ else N.audioEffects?.pause(), await t(E.getSilentMediaTrack(), !1);
1476
1477
  }
1477
1478
  toggleAnimojiCapturing(e) {
1478
1479
  this._animojiEnabled = e, this._mediaSettings.isVideoEnabled || this._triggerEvent("ANIMOJI_STATUS", e);
@@ -2183,7 +2184,7 @@ var mn = pn.getInstance(), N = class e {
2183
2184
  return 1.1;
2184
2185
  }
2185
2186
  static get sdkVersion() {
2186
- return "2.8.12-dev.dfea6e89.0";
2187
+ return "2.8.12-dev.ec5956ec.0";
2187
2188
  }
2188
2189
  static get debug() {
2189
2190
  return e._params.debug;
@@ -3581,7 +3582,7 @@ var Mn = 0, Nn = 1, Pn = 2, Fn = 3, In = 4, Ln = 5, Rn = 6, zn = 7, Bn = 0, Vn =
3581
3582
  };
3582
3583
  }
3583
3584
  }, U = /* @__PURE__ */ function(e) {
3584
- return e.CALL_INIT = "call_init", e.CALL_WARMUP = "call_warmup", e.CALL_START = "call_start", e.CALL_ACCEPTED_OUTGOING = "call_accepted_outgoing", e.CALL_ACCEPTED_INCOMING = "call_accepted_incoming", e.FIRST_MEDIA_SENT = "first_media_sent", e.CALL_FINISH = "call_finish", e.CODEC_USAGE = "codec_usage", e.SIGNALING_CONNECTED = "signaling_connected", e.SCREENSHARE_FIRST_FRAME = "screen_share_first_frame", e.FIRST_MEDIA_RECEIVED = "first_media_received", e.CALL_DECLINED_OR_HANGED_LOCALLY = "CallDeclinedOrHangedLocally", e.USER_FEEDBACK_RECEIVED = "UserFeedbackReceived", e.SIGNALING_PING_SUMMARY = "signaling_ping_summary", e.SIGNALING_COMMAND_SUMMARY = "signaling_command_summary", e.WEBSOCKET_CONNECTED = "websocket_connected", e.WEBSOCKET_RECONNECTED = "websocket_reconnected", e.WEBSOCKET_FAILED_PINGS = "websocket_failed_pings", e.WEBSOCKET_FAILED_EXCEPTION = "websocket_failed_exception", e.WEBSOCKET_TIMEOUT = "websocket_timeout", e.WEBSOCKET_RESTART = "websocket_restart", e.WEBTRANSPORT_CONNECTED = "webtransport_connected", e.WEBTRANSPORT_RECONNECTED = "webtransport_reconnected", e.WEBTRANSPORT_FAILED_PINGS = "webtransport_failed_pings", e.WEBTRANSPORT_FAILED_EXCEPTION = "webtransport_failed_exception", e.WEBTRANSPORT_TIMEOUT = "webtransport_timeout", e.WEBTRANSPORT_RESTART = "webtransport_restart", e;
3585
+ return e.CALL_INIT = "call_init", e.CALL_START = "call_start", e.CALL_ACCEPTED_OUTGOING = "call_accepted_outgoing", e.CALL_ACCEPTED_INCOMING = "call_accepted_incoming", e.FIRST_MEDIA_SENT = "first_media_sent", e.CALL_FINISH = "call_finish", e.CODEC_USAGE = "codec_usage", e.SIGNALING_CONNECTED = "signaling_connected", e.SCREENSHARE_FIRST_FRAME = "screen_share_first_frame", e.FIRST_MEDIA_RECEIVED = "first_media_received", e.CALL_DECLINED_OR_HANGED_LOCALLY = "CallDeclinedOrHangedLocally", e.USER_FEEDBACK_RECEIVED = "UserFeedbackReceived", e.SIGNALING_PING_SUMMARY = "signaling_ping_summary", e.SIGNALING_COMMAND_SUMMARY = "signaling_command_summary", e.WEBSOCKET_CONNECTED = "websocket_connected", e.WEBSOCKET_RECONNECTED = "websocket_reconnected", e.WEBSOCKET_FAILED_PINGS = "websocket_failed_pings", e.WEBSOCKET_FAILED_EXCEPTION = "websocket_failed_exception", e.WEBSOCKET_TIMEOUT = "websocket_timeout", e.WEBSOCKET_RESTART = "websocket_restart", e.WEBTRANSPORT_CONNECTED = "webtransport_connected", e.WEBTRANSPORT_RECONNECTED = "webtransport_reconnected", e.WEBTRANSPORT_FAILED_PINGS = "webtransport_failed_pings", e.WEBTRANSPORT_FAILED_EXCEPTION = "webtransport_failed_exception", e.WEBTRANSPORT_TIMEOUT = "webtransport_timeout", e.WEBTRANSPORT_RESTART = "webtransport_restart", e;
3585
3586
  }(U || {}), Jn = 1e3;
3586
3587
  function W(e, t, n = 0) {
3587
3588
  return t in e && e[t] ? e[t] : n;
@@ -3700,7 +3701,7 @@ function ir(e, t, n = !1) {
3700
3701
  }).filter((e) => !!e);
3701
3702
  }
3702
3703
  function ar(e, t, n = !1) {
3703
- if (!t || !t.rtps || !e.rtps) return e;
3704
+ if (!t || !t.rtps.length || !e.rtps.length) return e;
3704
3705
  let r, i;
3705
3706
  n && (r = Qn("ssrc", e?.remoteRtps || []), i = Qn("ssrc", t?.remoteRtps || []));
3706
3707
  let a = Qn("ssrc", e.rtps), o = Qn("ssrc", t.rtps), s = (e.timestamp - t.timestamp) / 1e3;
@@ -3997,7 +3998,7 @@ var Er = class {
3997
3998
  try {
3998
3999
  this._pc = this._createPeerConnection();
3999
4000
  } catch (e) {
4000
- this._debug.error("Failed to create RTCPeerConnection:", e), this.close(e);
4001
+ this._debug.error("Failed to create RTCPeerConnection:", e), this._failedOnCreate = e;
4001
4002
  return;
4002
4003
  }
4003
4004
  if (this._isMaster) {
@@ -4032,7 +4033,7 @@ var Er = class {
4032
4033
  return;
4033
4034
  }
4034
4035
  if (this._failedOnCreate) {
4035
- this.close(this._failedOnCreate);
4036
+ this._finishClose(this._failedOnCreate);
4036
4037
  return;
4037
4038
  }
4038
4039
  if (this._debug.debug("DirectTransport: Open transport", { participantId: this._participantId }), this._isOpen = !0, this._remotePeerId = e, !this._isMaster) try {
@@ -4117,7 +4118,10 @@ var Er = class {
4117
4118
  }
4118
4119
  }
4119
4120
  close(e) {
4120
- this._isOpen && (this._isOpen = !1, this._stopReconnection(), this._stopStatInterval(), this._stopSettingsInterval(), this._disposePeerConnection(), this._onNetworkStatus(1), this.unsubscribe(), e ? (this._debug.error("DirectTransport: Closed", e, { participantId: this._participantId }), this._setState(J.FAILED)) : (this._debug.debug("DirectTransport: Closed", { participantId: this._participantId }), this._setState(J.CLOSED)), this._triggerEvent(X.PEER_CONNECTION_CLOSED));
4121
+ this._isOpen && this._finishClose(e);
4122
+ }
4123
+ _finishClose(e) {
4124
+ this._isOpen = !1, this._stopReconnection(), this._stopStatInterval(), this._stopSettingsInterval(), this._disposePeerConnection(), this._onNetworkStatus(1), this.unsubscribe(), e ? (this._debug.error("DirectTransport: Closed", e, { participantId: this._participantId }), this._setState(J.FAILED)) : (this._debug.debug("DirectTransport: Closed", { participantId: this._participantId }), this._setState(J.CLOSED)), this._triggerEvent(X.PEER_CONNECTION_CLOSED);
4121
4125
  }
4122
4126
  _setState(e) {
4123
4127
  this._state !== e && (this._debug.debug(`DirectTransport: State changed to ${e}`, { participantId: this._participantId }), this._state = e, this._triggerEvent(X.STATE_CHANGED, e));
@@ -5344,7 +5348,7 @@ var yi = 2 ** 15 - 1, bi = 1, xi = 5, Si = 5, Ci = class e {
5344
5348
  }
5345
5349
  async init() {
5346
5350
  let e = this._sourceTrack.getSettings().width, t = this._sourceTrack.getSettings().height, n = this._trackProcessor.readable;
5347
- this._debug.debug(`WebCodecsEncoder started ${e}x${t}, codec ${this.isVP9() ? "VP9" : "VP8"}`), await this._createWorker("var workerExports=(function(){var e=function(e){return e.VP9=`vp09.00.50.08`,e.VP8=`vp8`,e}({}),t=function(e){return e.INIT=`init`,e.READY=`ready`,e.FRAME=`frame`,e.SET_BITRATE=`set_bitrate`,e.ERROR=`error`,e.DEBUG=`debug`,e.LOG_ERROR=`log_error`,e}({});return()=>{let n,r,i,a,o,s,c=null,l=0,u=!1,d=0,f,p,m=!1,h=!1,g=null;function _(e){return e instanceof Error?[e.name,e.message,e.stack].filter(Boolean).join(`: `):String(e)}function v(e,n){try{self.postMessage({type:t.FRAME,error:`WebCodecsEncoder ${e} failed: ${_(n)}`})}catch{}}function y(e,n){try{self.postMessage({type:t.ERROR,error:`WebCodecsEncoder ${e} failed: ${_(n)}`})}catch{}}function b(e){try{n=e.readable,r=n.getReader(),i=e.width,a=e.height,o=e.isVP9,s=e.framerate,f=e.useCongestionControl,p=e.maxBitrate,f&&(d=p,m=e.useCbr),T(),C(),self.postMessage({type:t.READY})}catch(e){y(`init`,e)}}function x(e){e&&!h&&(h=!0),self.clearTimeout(l),l=self.setTimeout(()=>{c&&S(c,h)},1e3),!u&&(u=!0,r.read().finally(()=>{u=!1,self.clearTimeout(l)}).then(({done:e,value:t})=>{if(c?.close(),c=null,!(e||!t)){if(!g){r.releaseLock(),n.cancel();return}c=t,S(t,h)}}).catch(e=>{v(`read`,e)}))}function S(e,t){try{if((e.codedWidth!==i||e.codedHeight!==a)&&(i=e.codedWidth,a=e.codedHeight,C(),h=!0),!g)throw Error(`encoder is not initialized`);g.encode(e,{keyFrame:t}),t&&(h=!1)}catch(e){v(`encode`,e)}}function C(){if(!g)throw Error(`encoder is not initialized`);let t={framerate:s,codec:o?e.VP9:e.VP8,width:i,height:a,latencyMode:`realtime`,bitrateMode:m?`constant`:`variable`};d>0&&(t.bitrate=d),g.configure(t)}function w(e,t,n){try{d=e,m=t,s=n,C()}catch(e){v(`setBitrate`,e)}}function T(){g=new VideoEncoder({output:e=>{try{let n;e.data?n=e.data:(n=new ArrayBuffer(e.byteLength),e.copyTo(n)),self.postMessage({type:t.FRAME,frameType:e.type,timestamp:e.timestamp,duration:e.duration,width:i,height:a,data:n},[n])}catch(e){v(`output`,e)}},error:e=>{v(`codec`,e)}})}self.onmessage=e=>{try{switch(e.data.type){case t.INIT:b(e.data);break;case t.FRAME:x(e.data.keyFrame);break;case t.SET_BITRATE:w(e.data.bitrate,e.data.useCbr,e.data.fps);break}}catch(e){v(`message`,e)}}}})(),exports={default:workerExports};", (e) => {
5351
+ this._debug.debug(`WebCodecsEncoder started ${e}x${t}, codec ${this.isVP9() ? "VP9" : "VP8"}`), await this._createWorker("var workerExports=(function(){var e=function(e){return e.VP9=`vp09.00.50.08`,e.VP8=`vp8`,e}({}),t=function(e){return e.INIT=`init`,e.READY=`ready`,e.FRAME=`frame`,e.SET_BITRATE=`set_bitrate`,e.ERROR=`error`,e.DEBUG=`debug`,e.LOG_ERROR=`log_error`,e}({});return()=>{let n,r,i,a,o,s,c=null,l=0,u=!1,d=0,f,p,m=!1,h=!1,g=null;function _(e){return e instanceof Error?[e.name,e.message,e.stack].filter(Boolean).join(`: `):String(e)}function v(e,n){try{self.postMessage({type:t.FRAME,error:`WebCodecsEncoder ${e} failed: ${_(n)}`})}catch{}}function y(e,n){try{self.postMessage({type:t.ERROR,error:`WebCodecsEncoder ${e} failed: ${_(n)}`})}catch{}}function b(e){try{n=e.readable,r=n.getReader(),i=e.width,a=e.height,o=e.isVP9,s=e.framerate,f=e.useCongestionControl,p=e.maxBitrate,f&&(d=p,m=e.useCbr),T(),C(),self.postMessage({type:t.READY})}catch(e){y(`init`,e)}}function x(e){e&&!h&&(h=!0),self.clearTimeout(l),l=self.setTimeout(()=>{c&&S(c,h)},1e3),!u&&(u=!0,r.read().finally(()=>{u=!1,self.clearTimeout(l)}).then(({done:e,value:t})=>{if(c?.close(),c=null,!(e||!t)){if(!g){r.releaseLock(),n.cancel();return}c=t,S(t,h)}}).catch(e=>{v(`read`,e)}))}function S(e,t){try{let n=e.codedWidth!==i||e.codedHeight!==a;n&&(i=e.codedWidth,a=e.codedHeight,t=!0),!g||g.state===`closed`?(T(),C()):n&&C(),g?.encode(e,{keyFrame:t}),t&&(h=!1)}catch(e){g&&g.state===`closed`&&(g=null),v(`encode`,e)}}function C(){if(!g)throw Error(`encoder is not initialized`);let t={framerate:s,codec:o?e.VP9:e.VP8,width:i,height:a,latencyMode:`realtime`,bitrateMode:m?`constant`:`variable`};d>0&&(t.bitrate=d),g.configure(t)}function w(e,t,n){try{d=e,m=t,s=n,(!g||g.state===`closed`)&&T(),C()}catch(e){v(`setBitrate`,e)}}function T(){g=new VideoEncoder({output:e=>{try{let n;e.data?n=e.data:(n=new ArrayBuffer(e.byteLength),e.copyTo(n)),self.postMessage({type:t.FRAME,frameType:e.type,timestamp:e.timestamp,duration:e.duration,width:i,height:a,data:n},[n])}catch(e){v(`output`,e)}},error:e=>{g&&g.state===`closed`&&(g=null),v(`codec`,e)}})}self.onmessage=e=>{try{switch(e.data.type){case t.INIT:b(e.data);break;case t.FRAME:x(e.data.keyFrame);break;case t.SET_BITRATE:w(e.data.bitrate,e.data.useCbr,e.data.fps);break}}catch(e){v(`message`,e)}}}})(),exports={default:workerExports};", (e) => {
5348
5352
  e.error ? this._onFrame(null, e.error) : this._onFrame({
5349
5353
  type: e.frameType,
5350
5354
  timestamp: e.timestamp,
@@ -5663,7 +5667,7 @@ var yi = 2 ** 15 - 1, bi = 1, xi = 5, Si = 5, Ci = class e {
5663
5667
  }
5664
5668
  }, ea = 90, ta = 4294967295, na = class e extends Dr {
5665
5669
  constructor(e, t, n, r = z, i = null, a = null, o = null, s = null) {
5666
- super(e, t, s), h(this, "_producerNotification", null), h(this, "_producerCommand", null), h(this, "_producerScreen", null), h(this, "_consumerScreen", null), h(this, "_asr", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_isOpen", !1), h(this, "_observer", !1), h(this, "_reconnectionPrevented", !1), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_monitorRtpShareInterval", null), h(this, "_statBytes", {}), h(this, "_ssrcMap", {}), h(this, "_ssrcMapUpdated", !1), h(this, "_perfStatReporter", void 0), h(this, "_producerOfferIsProcessing", !1), h(this, "_producerNextOffer", null), h(this, "_producerNextSessionId", null), h(this, "_lastStat", null), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_prevConsumerFastSharingSettings", {}), h(this, "_asrTrack", null), h(this, "_captureSender", null), h(this, "_captureReceiver", null), h(this, "_participantIdRegistry", null), h(this, "_disabledSenders", /* @__PURE__ */ new Set()), h(this, "_rtpReceiversByStreamId", {}), h(this, "_producerSessionId", ""), h(this, "_newAudioShareTrack", null), h(this, "_simulcastInfo", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._codecStatsAggregator = o, this.subscribe(this._signaling, K.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");
5670
+ super(e, t, s), h(this, "_producerNotification", null), h(this, "_producerCommand", null), h(this, "_producerScreen", null), h(this, "_consumerScreen", null), h(this, "_asr", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_isOpen", !1), h(this, "_observer", !1), h(this, "_reconnectionPrevented", !1), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_monitorRtpShareInterval", null), h(this, "_statBytes", {}), h(this, "_ssrcMap", {}), h(this, "_ssrcMapUpdated", !1), h(this, "_perfStatReporter", void 0), h(this, "_producerOfferIsProcessing", !1), h(this, "_producerNextOffer", null), h(this, "_producerNextSessionId", null), h(this, "_lastStat", null), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_prevConsumerFastSharingSettings", {}), h(this, "_asrTrack", null), h(this, "_captureSender", null), h(this, "_captureReceiver", null), h(this, "_participantIdRegistry", null), h(this, "_disabledSenders", /* @__PURE__ */ new Set()), h(this, "_rtpReceiversByStreamId", {}), h(this, "_producerSessionId", ""), h(this, "_newAudioShareTrack", null), h(this, "_simulcastInfo", null), h(this, "_isSimulcastNegotiated", !1), 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, K.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");
5667
5671
  }
5668
5672
  updateStatisticsInterval() {
5669
5673
  this._stopStatInterval();
@@ -5699,13 +5703,13 @@ var yi = 2 ** 15 - 1, bi = 1, xi = 5, Si = 5, Ci = class e {
5699
5703
  }
5700
5704
  }
5701
5705
  async onCameraResolutionChanged() {
5702
- N.simulcast && await this._changeSimulcastInfo(!0, !1);
5706
+ this._isSimulcastNegotiated && await this._changeSimulcastInfo(!0, !1);
5703
5707
  }
5704
5708
  _createPerfStatsReporter() {
5705
5709
  this._perfStatReporter?.destroy(), this._perfStatReporter = new sa(this, this._signaling, this._statAggregator, !1, this._debug);
5706
5710
  }
5707
5711
  _closeConnection() {
5708
- this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcastInfo = null, this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(X.PEER_CONNECTION_CLOSED);
5712
+ this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcastInfo = null, this._isSimulcastNegotiated = !1, this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(X.PEER_CONNECTION_CLOSED);
5709
5713
  }
5710
5714
  static _closeDataChannel(e) {
5711
5715
  e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
@@ -5926,8 +5930,8 @@ var yi = 2 ** 15 - 1, bi = 1, xi = 5, Si = 5, Ci = class e {
5926
5930
  let r = this._findFirstSimTransceiver();
5927
5931
  if (N.simulcast) if (r) {
5928
5932
  this._debug.log(`_processOffer: caps.simulcast=${N.simulcast} mid=${r.mid} dir=${r.direction}`);
5929
- let e = this._mediaSource.getStream(), t = await this._setupSimulcastTransceiver(e, r);
5930
- this._debug.log("_processOffer: simulcastInfo", t), t || (this._debug.log(`_processOffer: simulcast transceiver not found in server offer mid=${r.mid}, disable simulcast`), n = !1);
5933
+ let e = this._mediaSource.getStream();
5934
+ this._isSimulcastNegotiated = await this._setupSimulcastTransceiver(e, r), this._debug.log("_processOffer: simulcastInfo", this._isSimulcastNegotiated), this._isSimulcastNegotiated || (this._debug.log(`_processOffer: simulcast transceiver not found in server offer mid=${r.mid}, disable simulcast`), n = !1);
5931
5935
  } else this._debug.log("_processOffer: simulcast transceiver not found in server offer, disable simulcast"), n = !1;
5932
5936
  let i;
5933
5937
  try {
@@ -5964,12 +5968,12 @@ var yi = 2 ** 15 - 1, bi = 1, xi = 5, Si = 5, Ci = class e {
5964
5968
  return null;
5965
5969
  }
5966
5970
  async _setupSimulcastTransceiver(e, t) {
5967
- if (!t?.sender || !e) return null;
5971
+ if (!t?.sender || !e) return !1;
5968
5972
  t.direction = "sendonly";
5969
5973
  let n = e.getVideoTracks()[0];
5970
5974
  await t.sender.replaceTrack(n), t.sender.setStreams(e);
5971
5975
  let r = t.sender.getParameters();
5972
- if (!r.encodings || r.encodings.length <= 1) return this._debug.log(`_setup:sim: mid=${t.mid} dir=${t.direction}: wrong encodings:${JSON.stringify(r.encodings)}`), null;
5976
+ if (!r.encodings || r.encodings.length <= 1) return this._debug.log(`_setup:sim: mid=${t.mid} dir=${t.direction}: wrong encodings:${JSON.stringify(r.encodings)}`), !1;
5973
5977
  let i = tn(Yt.WIDTH, Yt.HEIGHT, this._serverSettings.camera?.bitrates?.generic), a = 0, o = 1;
5974
5978
  for (let e of r.encodings) e.scalabilityMode = Xt, e.active = !0, a >= i.streams.length ? e.maxBitrate = 0 : e.maxBitrate = i.streams[a].bitrate, e.scaleResolutionDownBy = o, o *= 2, a++;
5975
5979
  await t.sender.setParameters(r);
@@ -6096,7 +6100,7 @@ var yi = 2 ** 15 - 1, bi = 1, xi = 5, Si = 5, Ci = class e {
6096
6100
  this._debug.error("ServerTransport: Unable to replace track", e), this._logger?.log(C.ERROR, "replaceTrack-single");
6097
6101
  });
6098
6102
  };
6099
- if (this._debug.log(`_onReplacedTrack: newTrack=${e.getSettings().width}x${e.getSettings().height}`), N.simulcast && e.kind === A.video) {
6103
+ if (this._debug.log(`_onReplacedTrack: newTrack=${e.getSettings().width}x${e.getSettings().height}`), this._isSimulcastNegotiated && e.kind === A.video) {
6100
6104
  let t = this._pc?.getTransceivers().find((t) => t.direction === "sendonly" && t.sender?.track?.kind === A.video && t.sender.track.contentHint === e.contentHint)?.sender;
6101
6105
  t?.track ? (n(t, e), e.getSettings().width && e.getSettings().height && this._changeSimulcastInfo(!1, !1)) : this._debug.warn("_onReplacedTrack: simulcast video transceiver not found");
6102
6106
  } else {
@@ -6123,13 +6127,13 @@ var yi = 2 ** 15 - 1, bi = 1, xi = 5, Si = 5, Ci = class e {
6123
6127
  }
6124
6128
  async _changeSimulcastInfo(e, t) {
6125
6129
  let n = this._mediaSource.mediaSettings.isVideoEnabled, r = this._findFirstSimTransceiver();
6126
- if (!N.simulcast || !n || !r || !r.sender) return;
6130
+ if (!this._isSimulcastNegotiated || !n || !r || !r.sender) return;
6127
6131
  let i = this._mediaSource.getStream();
6128
6132
  if (!i) return;
6129
6133
  let a = i.getVideoTracks()[0], o = a.getSettings().width, s = a.getSettings().height, c = tn(o, s, this._serverSettings.camera?.bitrates?.generic), l = t || !$t(this._simulcastInfo, c);
6130
6134
  if (!c.streams.length || !l) return;
6131
6135
  let u = r.sender.getParameters();
6132
- if (u.encodings || (u.encodings = [{}]), !(u.encodings.length <= 1)) {
6136
+ if (u.encodings.length || (u.encodings = [{}]), !(u.encodings.length <= 1)) {
6133
6137
  if (this._debug.log(`_changeSimulcastInfo: ${o}x${s} command: ${JSON.stringify(c)} `), e) {
6134
6138
  let e = 0;
6135
6139
  for (let t of u.encodings) t.scaleResolutionDownBy = nn(t.rid), t.scalabilityMode = Xt, e >= c.streams.length ? (t.maxBitrate = 0, t.active = !1) : (t.active = !0, t.maxBitrate = c.streams[e].bitrate), e++;
@@ -6137,7 +6141,7 @@ var yi = 2 ** 15 - 1, bi = 1, xi = 5, Si = 5, Ci = class e {
6137
6141
  this._debug.error("Failed to set sender parameters", u, e);
6138
6142
  }), this._debug.log(`_changeSimulcastInfo: actual encodings: ${JSON.stringify(u.encodings)} `);
6139
6143
  }
6140
- if (this._simulcastInfo = c, c.streams) {
6144
+ if (this._simulcastInfo = c, c.streams.length) {
6141
6145
  let e = {
6142
6146
  mediaSource: qt.CAMERA,
6143
6147
  simulcastInfo: c
@@ -6841,8 +6845,8 @@ var pa = fa, ma = {
6841
6845
  close(e) {
6842
6846
  this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this.lastStamp = 0;
6843
6847
  }
6844
- send(e) {
6845
- this.socket?.send(e);
6848
+ async send(e) {
6849
+ await this.socket?.send(e);
6846
6850
  }
6847
6851
  _connect() {
6848
6852
  if (this._canUseWebTransport()) {
@@ -6873,7 +6877,10 @@ var pa = fa, ma = {
6873
6877
  this.currentType = pr.WEBSOCKET, this.socket = new WebSocket(e), this._setSocketHandlers();
6874
6878
  }
6875
6879
  _setSocketHandlers() {
6876
- 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());
6880
+ this.socket && (this.handlers.onConnecting({
6881
+ connectionType: this.connectionType,
6882
+ source: this.currentType
6883
+ }), 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());
6877
6884
  }
6878
6885
  _buildUrl(e, t) {
6879
6886
  let n = new URL(e), r = n.searchParams;
@@ -6968,6 +6975,7 @@ var Ma = new Set([
6968
6975
  }
6969
6976
  constructor(e = z, t = null, n = null, r = null, i = null) {
6970
6977
  super(), h(this, "transport", void 0), h(this, "sequence", 1), h(this, "lastStamp", 0), h(this, "websocketCommandsQueue", []), h(this, "datachannelCommandsQueue", []), h(this, "incomingCache", []), h(this, "responseHandlers", {}), h(this, "disposed", !1), 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, "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 qn(e), this.transport = new Ea(e, {
6978
+ onConnecting: this._onTransportConnecting.bind(this),
6971
6979
  onOpen: this._onOpen.bind(this),
6972
6980
  onMessage: this._onMessage.bind(this),
6973
6981
  onError: this._onError.bind(this),
@@ -7024,7 +7032,7 @@ var Ma = new Set([
7024
7032
  return this.sequence;
7025
7033
  }
7026
7034
  hangup(e) {
7027
- return this._send(V.HANGUP, { reason: e });
7035
+ return this._send(V.HANGUP, { reason: e }, !1);
7028
7036
  }
7029
7037
  async sendCandidate(e, t) {
7030
7038
  return this._send(V.TRANSMIT_DATA, {
@@ -7092,7 +7100,7 @@ var Ma = new Set([
7092
7100
  description: e.sdp,
7093
7101
  sessionId: n
7094
7102
  };
7095
- return t && (r.ssrcs = t), this._send(V.ACCEPT_PRODUCER, r);
7103
+ return t.length && (r.ssrcs = t), this._send(V.ACCEPT_PRODUCER, r);
7096
7104
  }
7097
7105
  async changePriorities(e) {
7098
7106
  return this._send(V.CHANGE_STREAM_PRIORITIES, { typedPriorities: e }).catch(() => {});
@@ -7321,7 +7329,7 @@ var Ma = new Set([
7321
7329
  }
7322
7330
  _onMessage(e) {
7323
7331
  if (e.data === "ping") {
7324
- this._statPings?.mark(this._getSocketType()), this._markTransportStat(mr.FAILED_PINGS), R.onSignalingMessage(e.data), this.transport.readyState === WebSocket.OPEN && this.transport.send("pong");
7332
+ this._statPings?.mark(this._getSocketType()), this._markTransportStat(mr.FAILED_PINGS), R.onSignalingMessage(e.data), this.transport.readyState === WebSocket.OPEN && this.transport.send("pong").catch((e) => this._debug.warn("[signaling] unable to send pong", e));
7325
7333
  return;
7326
7334
  }
7327
7335
  try {
@@ -7483,7 +7491,15 @@ var Ma = new Set([
7483
7491
  }
7484
7492
  }
7485
7493
  _handleCommandResponse(t, n) {
7486
- if (!Object.hasOwn(this.responseHandlers, n.sequence)) return;
7494
+ if (!Object.hasOwn(this.responseHandlers, n.sequence)) {
7495
+ if (n.participants) for (let e of n.participants) this._triggerEvent(K.NOTIFICATION, {
7496
+ ...n,
7497
+ notification: q.PARTICIPANT_ADDED,
7498
+ type: "notification",
7499
+ participant: e
7500
+ });
7501
+ return;
7502
+ }
7487
7503
  let r = this.responseHandlers[n.sequence];
7488
7504
  window.clearTimeout(r.responseTimer);
7489
7505
  let i = G.measureMark(r.statMarkName);
@@ -7497,7 +7513,7 @@ var Ma = new Set([
7497
7513
  t.reject(/* @__PURE__ */ Error(`Invalid data channel state: ${this.producerCommandDataChannel?.readyState}`));
7498
7514
  return;
7499
7515
  }
7500
- this._startResponseTimer(t);
7516
+ t.needResponse ? this._startResponseTimer(t) : this._resolveCommandWithoutResponse(t);
7501
7517
  let e = this._serializeBinary(t);
7502
7518
  e !== null && this.producerCommandDataChannel.send(e);
7503
7519
  } else {
@@ -7505,25 +7521,28 @@ var Ma = new Set([
7505
7521
  t.reject(/* @__PURE__ */ Error("Invalid state or socket already closed"));
7506
7522
  continue;
7507
7523
  }
7508
- this._startResponseTimer(t), this.transport.send(this._serializeJson(t));
7524
+ t.needResponse && this._startResponseTimer(t), this.transport.send(this._serializeJson(t)).then(() => {
7525
+ t.needResponse || this._resolveCommandWithoutResponse(t);
7526
+ }, (e) => {
7527
+ window.clearTimeout(t.responseTimer), delete this.responseHandlers[t.sequence], t.reject(e, !0);
7528
+ });
7509
7529
  }
7510
7530
  }
7511
7531
  }
7512
7532
  _startResponseTimer(t) {
7513
- if (!t.needResponse) {
7514
- t.resolve({
7515
- type: "response",
7516
- sequence: t.sequence,
7517
- response: t.name
7518
- });
7519
- return;
7520
- }
7521
7533
  t.responseTimer = window.setTimeout(() => this._handleCommandResponse(!1, {
7522
7534
  response: t.name,
7523
7535
  sequence: t.sequence,
7524
7536
  type: "timeout"
7525
7537
  }), e.WAIT_RESPONSE_DELAY), this.responseHandlers[t.sequence] = t;
7526
7538
  }
7539
+ _resolveCommandWithoutResponse(e) {
7540
+ e.resolve({
7541
+ type: "response",
7542
+ sequence: e.sequence,
7543
+ response: e.name
7544
+ });
7545
+ }
7527
7546
  _serializeBinary(e) {
7528
7547
  switch (e.name) {
7529
7548
  case V.UPDATE_DISPLAY_LAYOUT: return this.producerCommandSerializationService.serializeUpdateDisplayLayout(e.sequence, e.params);
@@ -7569,6 +7588,10 @@ var Ma = new Set([
7569
7588
  _stopWaitConnectionMessage() {
7570
7589
  window.clearTimeout(this.connectionMessageWaitTimer), this.connectionMessageWaitTimer = 0;
7571
7590
  }
7591
+ _onTransportConnecting(e) {
7592
+ let t = e.connectionType === fr.RETRY ? mr.RECONNECTED : mr.CONNECTED;
7593
+ this._markTransportStat(t, e.source);
7594
+ }
7572
7595
  _onTransportFailed(e) {
7573
7596
  switch (e.failure) {
7574
7597
  case Ta.EMPTY_ENDPOINT:
@@ -7621,8 +7644,8 @@ var Ma = new Set([
7621
7644
  _getSocketType() {
7622
7645
  return this.transport.type;
7623
7646
  }
7624
- _markTransportStat(e) {
7625
- let t = this._getSocketType(), n = hr[e][t];
7647
+ _markTransportStat(e, t = this._getSocketType()) {
7648
+ let n = hr[e][t];
7626
7649
  G.setMark(n);
7627
7650
  }
7628
7651
  _logTransportStat(e, t) {
@@ -7850,8 +7873,29 @@ function ro(e, t) {
7850
7873
  return to(t, r);
7851
7874
  }
7852
7875
  //#endregion
7876
+ //#region src/utils/IceServers.ts
7877
+ function io(e) {
7878
+ if (!e) return null;
7879
+ let t = Array.from(new Set((e.urls ?? []).map((e) => e.trim()).filter((e) => e.length > 0)));
7880
+ return t.length ? {
7881
+ ...e,
7882
+ urls: t
7883
+ } : null;
7884
+ }
7885
+ function ao(e, t) {
7886
+ let n = [], r = io(e), i = io(t);
7887
+ if (r && n.push(r), i) {
7888
+ let e = [...i.urls];
7889
+ e.push(`${e[e.length - 1]}?transport=tcp`), n.push({
7890
+ ...i,
7891
+ urls: e
7892
+ });
7893
+ }
7894
+ return n;
7895
+ }
7896
+ //#endregion
7853
7897
  //#region src/utils/Lz4.ts
7854
- function io(e, t) {
7898
+ function oo(e, t) {
7855
7899
  let n = new Uint8Array(t), r = 0, i = 0;
7856
7900
  for (; r < e.length && i < t;) {
7857
7901
  let a = e[r++], o = a >> 4, s = a & 15;
@@ -7878,7 +7922,7 @@ function io(e, t) {
7878
7922
  }
7879
7923
  //#endregion
7880
7924
  //#region src/classes/AudioFix.ts
7881
- var ao = class {
7925
+ var so = class {
7882
7926
  constructor(e, t = z, n = null) {
7883
7927
  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;
7884
7928
  }
@@ -7888,7 +7932,7 @@ var ao = class {
7888
7932
  this._fixNoPacketsChecked = !0, this._logger?.log(C.ERROR, `audio_device_recover_${e.bandwidth ? "success" : "fail"}`);
7889
7933
  return;
7890
7934
  }
7891
- !this._fixNoPacketsApplied && !e.bandwidth && (this._fixNoPacketsApplied = !0, this._logger?.log(C.ERROR, "audio_device_recover"), this._debug.log("[AudioFix] Trying to fix RV (no packets)"), this._toggleAudioPromise = this._mediaSource.toggleAudio(E.getMicrophonePermissionState() !== "denied"), this._toggleAudioPromise.catch(() => void 0));
7935
+ !this._fixNoPacketsApplied && !e.bandwidth && e.packetsSent > 0 && (this._fixNoPacketsApplied = !0, this._logger?.log(C.ERROR, "audio_device_recover"), this._debug.log("[AudioFix] Trying to fix RV (no packets)"), this._toggleAudioPromise = this._mediaSource.toggleAudio(E.getMicrophonePermissionState() !== "denied"), this._toggleAudioPromise.catch(() => void 0));
7892
7936
  }
7893
7937
  }
7894
7938
  _fixAudioDeviceTooManyPackets(e) {
@@ -7916,7 +7960,7 @@ var ao = class {
7916
7960
  this._debug.warn("[AudioFix] Failed to fix RV (no packets): video restart", e);
7917
7961
  }));
7918
7962
  }
7919
- }, oo = class {
7963
+ }, co = class {
7920
7964
  constructor(e, t = !1, n = z, r = null) {
7921
7965
  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;
7922
7966
  }
@@ -8003,14 +8047,14 @@ var ao = class {
8003
8047
  }
8004
8048
  };
8005
8049
  //#endregion
8006
- //#region src/classes/ConversationResponseValidator.ts
8007
- function so(e, t) {
8008
- e || lo(t, "response-empty"), e.id || lo(t, "id-empty"), e.endpoint || lo(t, "endpoint-empty"), !co(e.stun_server) && !co(e.turn_server) && lo(t, "ice-servers-empty");
8050
+ //#region src/classes/conversation/ConversationResponseValidator.ts
8051
+ function lo(e, t) {
8052
+ e || fo(t, "response-empty"), e.id || fo(t, "id-empty"), e.endpoint || fo(t, "endpoint-empty"), !uo(e.stun_server) && !uo(e.turn_server) && fo(t, "ice-servers-empty");
8009
8053
  }
8010
- function co(e) {
8054
+ function uo(e) {
8011
8055
  return Array.isArray(e?.urls) && e.urls.length > 0;
8012
8056
  }
8013
- function lo(e, t) {
8057
+ function fo(e, t) {
8014
8058
  let n = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), r = e === "fastStart" || e === "fastJoin";
8015
8059
  throw new k(r ? e === "fastStart" ? O.FAST_START_ERROR : O.FAST_JOIN_ERROR : O.UNKNOWN_ERROR, {
8016
8060
  message: `Invalid ${e} response: ${t}`,
@@ -8029,7 +8073,7 @@ function lo(e, t) {
8029
8073
  }
8030
8074
  //#endregion
8031
8075
  //#region src/classes/DebugInfo.ts
8032
- var uo = 90, fo = 3, po = class extends b {
8076
+ var po = 90, mo = 3, ho = class extends b {
8033
8077
  constructor(e = z) {
8034
8078
  super(), h(this, "_lastMemoryStat", {
8035
8079
  percent: 0,
@@ -8045,9 +8089,9 @@ var uo = 90, fo = 3, po = class extends b {
8045
8089
  let e = window?.performance?.memory;
8046
8090
  if (!e || !e.usedJSHeapSize || !e.jsHeapSizeLimit) return;
8047
8091
  let t = Number((100 * e.usedJSHeapSize / e.jsHeapSizeLimit).toFixed(2)), n = Number((e.usedJSHeapSize / 1024 / 1024).toFixed(1));
8048
- t > uo ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= fo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8092
+ t > po ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= mo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8049
8093
  }
8050
- }, mo = class {
8094
+ }, go = class {
8051
8095
  constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i }) {
8052
8096
  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;
8053
8097
  }
@@ -8157,7 +8201,7 @@ var uo = 90, fo = 3, po = class extends b {
8157
8201
  let n = e, r = t;
8158
8202
  return n.width !== r.width || n.height !== r.height || n.fit !== r.fit || n.priority !== r.priority;
8159
8203
  }
8160
- }, ho = 44100, go = class {
8204
+ }, _o = 44100, vo = class {
8161
8205
  constructor(e, t) {
8162
8206
  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]);
8163
8207
  try {
@@ -8174,7 +8218,7 @@ var uo = 90, fo = 3, po = class extends b {
8174
8218
  _getBins() {
8175
8219
  if (!this._fftBins || !this._analyser) return new Uint8Array();
8176
8220
  this._analyser.getByteFrequencyData(this._fftBins);
8177
- let e = ho / this._fftBins.length, t = Math.ceil(N.voiceParams.minFreq / e), n = Math.floor(N.voiceParams.maxFreq / e);
8221
+ let e = _o / this._fftBins.length, t = Math.ceil(N.voiceParams.minFreq / e), n = Math.floor(N.voiceParams.maxFreq / e);
8178
8222
  return this._fftBins.subarray(t, n);
8179
8223
  }
8180
8224
  getLevel() {
@@ -8187,7 +8231,7 @@ var uo = 90, fo = 3, po = class extends b {
8187
8231
  destroy() {
8188
8232
  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);
8189
8233
  }
8190
- }, _o = class extends b {
8234
+ }, yo = class extends b {
8191
8235
  constructor(e) {
8192
8236
  super(), h(this, "_detector", null), h(this, "_interval", null);
8193
8237
  let t = () => {
@@ -8203,7 +8247,7 @@ var uo = 90, fo = 3, po = class extends b {
8203
8247
  }), this.subscribe(e, Kt.SOURCE_READY, n), n();
8204
8248
  }
8205
8249
  init(e) {
8206
- this._stopDetector(), this._detector = new go("local", e.clone());
8250
+ this._stopDetector(), this._detector = new vo("local", e.clone());
8207
8251
  }
8208
8252
  _stopDetector() {
8209
8253
  this._detector && (this._detector.track.stop(), this._detector.destroy(), this._detector = null);
@@ -8211,7 +8255,7 @@ var uo = 90, fo = 3, po = class extends b {
8211
8255
  destroy() {
8212
8256
  this.unsubscribe(), this._interval && (window.clearTimeout(this._interval), this._interval = null), this._stopDetector();
8213
8257
  }
8214
- }, vo = class {
8258
+ }, bo = class {
8215
8259
  constructor(e, t = z) {
8216
8260
  h(this, "processor", void 0), h(this, "queue", []), h(this, "isProcessing", !1), h(this, "_debug", void 0), this.processor = e, this._debug = t;
8217
8261
  }
@@ -8231,9 +8275,9 @@ var uo = 90, fo = 3, po = class extends b {
8231
8275
  this.isProcessing = !1;
8232
8276
  }
8233
8277
  }
8234
- }, yo = /* @__PURE__ */ function(e) {
8278
+ }, xo = /* @__PURE__ */ function(e) {
8235
8279
  return e.VOLUMES_DETECTED = "VOLUMES_DETECTED", e;
8236
- }({}), bo = class extends b {
8280
+ }({}), So = class extends b {
8237
8281
  constructor(e) {
8238
8282
  super(), h(this, "_detectors", /* @__PURE__ */ new Map()), h(this, "_interval", null), h(this, "_activeParticipants", void 0), h(this, "_removedParticipants", void 0), h(this, "_topology", void 0), this._topology = e.getTopology(), this.subscribe(e, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(e, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(e, X.SIGNALLED_ACTIVE_PARTICIPANTS, this._onSignalledActiveParticipants.bind(this)), this.subscribe(e, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8239
8283
  }
@@ -8241,7 +8285,7 @@ var uo = 90, fo = 3, po = class extends b {
8241
8285
  this._interval && (window.clearTimeout(this._interval), this._interval = null), this.unsubscribe(), this._destroyDetectors();
8242
8286
  }
8243
8287
  _onRemoteTrackAdded(e, t, n) {
8244
- if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new go(e, n)), !this._interval)) {
8288
+ if (n.kind === A.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new vo(e, n)), !this._interval)) {
8245
8289
  let e = () => {
8246
8290
  this._collectVolumes(), this._interval = window.setTimeout(e, N.voiceParams.interval);
8247
8291
  };
@@ -8299,11 +8343,11 @@ var uo = 90, fo = 3, po = class extends b {
8299
8343
  e.destroy();
8300
8344
  }), this._detectors.clear();
8301
8345
  }
8302
- }, xo = /* @__PURE__ */ function(e) {
8346
+ }, Co = /* @__PURE__ */ function(e) {
8303
8347
  return e.SPEAKER_CHANGED = "SPEAKER_CHANGED", e;
8304
- }({}), So = class extends b {
8348
+ }({}), wo = class extends b {
8305
8349
  constructor(e, t, n) {
8306
- super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === Y.SERVER, this.subscribe(e, yo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, X.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8350
+ super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === Y.SERVER, this.subscribe(e, xo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this.subscribe(t, X.SIGNALLED_SPEAKER_CHANGED, this._onServerSpeakerChanged.bind(this)), this.subscribe(t, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this));
8307
8351
  }
8308
8352
  destroy() {
8309
8353
  this.unsubscribe();
@@ -8325,9 +8369,9 @@ var uo = 90, fo = 3, po = class extends b {
8325
8369
  _onTopologyChanged(e) {
8326
8370
  this._serverSideSpeakerDetection = e === Y.SERVER;
8327
8371
  }
8328
- }, Co = 15e3, wo = 15e3, To = class extends b {
8372
+ }, To = 15e3, Eo = 15e3, Do = class extends b {
8329
8373
  constructor(e, t, n, r = z, i = null) {
8330
- super(), h(this, "_transport", void 0), h(this, "_volumes", {}), h(this, "_participants", {}), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_connectionTimeout", 0), h(this, "_connectionTimeoutSuppressed", !1), h(this, "_volumeTimeout", 0), this._transport = e, this._participants = n, this._debug = r, this._logger = i, this.subscribe(e, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, yo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8374
+ super(), h(this, "_transport", void 0), h(this, "_volumes", {}), h(this, "_participants", {}), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_connectionTimeout", 0), h(this, "_connectionTimeoutSuppressed", !1), h(this, "_volumeTimeout", 0), this._transport = e, this._participants = n, this._debug = r, this._logger = i, this.subscribe(e, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(t, xo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8331
8375
  }
8332
8376
  destroy() {
8333
8377
  this.unsubscribe(), this._connectionTimeout && window.clearTimeout(this._connectionTimeout), this._volumeTimeout && window.clearTimeout(this._volumeTimeout);
@@ -8339,10 +8383,10 @@ var uo = 90, fo = 3, po = class extends b {
8339
8383
  this._connectionTimeout || !this._connectionTimeoutSuppressed || this._reportConnectionTimeout();
8340
8384
  }
8341
8385
  _getConnectionTimeout() {
8342
- return this._transport.getTopology() === Y.DIRECT ? Co : N.specListenerParams.connectionTimeout;
8386
+ return this._transport.getTopology() === Y.DIRECT ? To : N.specListenerParams.connectionTimeout;
8343
8387
  }
8344
8388
  _getVolumeTimeout() {
8345
- return this._transport.getTopology() === Y.DIRECT ? wo : N.specListenerParams.volumeTimeout;
8389
+ return this._transport.getTopology() === Y.DIRECT ? Eo : N.specListenerParams.volumeTimeout;
8346
8390
  }
8347
8391
  _onTransportStateChanged(e, t) {
8348
8392
  t === J.OPENED && (this._connectionTimeout || (this._connectionTimeoutSuppressed = !1, this._connectionTimeout = window.setTimeout(this._onConnectionTimeout.bind(this), this._getConnectionTimeout()))), t === J.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 === J.FAILED && this._connectionTimeout && (this._debug.warn("Transport failed, send callSpecError"), this._logger?.log(C.CALL_SPEC_ERROR, `${this._transport.getTopology()}_CONNECTION_TIMEOUT`));
@@ -8375,7 +8419,7 @@ var uo = 90, fo = 3, po = class extends b {
8375
8419
  r && r.platform && (n = r.platform), e.indexOf(n) < 0 && (e.push(n), this._logger?.log(C.CALL_SPEC_ERROR, `${this._transport.getTopology()}_VOLUME_TIMEOUT_${n}`));
8376
8420
  }), e.length && this._debug.warn("There is silent participant, send callSpecError"), this._volumeTimeout = 0;
8377
8421
  }
8378
- }, Eo = class extends f {
8422
+ }, Oo = class extends f {
8379
8423
  constructor(e, t, n, r = () => void 0) {
8380
8424
  super(), h(this, "_externalLogger", void 0), h(this, "_api", void 0), h(this, "_conversationIdProvider", void 0), h(this, "_topologyProvider", void 0), h(this, "_batchInterval", 3e3), h(this, "_batchedClientStats", []), h(this, "_batchTimeout", null), h(this, "_serverTimeDelta", 0), h(this, "_waitingForServerTime", !0), h(this, "_deferredClientStats", []), this._api = e, this._externalLogger = t, this._conversationIdProvider = n, this._topologyProvider = r, this._calculateServerTimeDelta();
8381
8425
  }
@@ -8455,7 +8499,7 @@ var uo = 90, fo = 3, po = class extends b {
8455
8499
  _now() {
8456
8500
  return Date.now() - this._serverTimeDelta;
8457
8501
  }
8458
- }, Do = "invalid-error-metadata", Oo = 64, ko = new Set(Object.values(O)), Ao = new Set(Object.values(x)), jo = {
8502
+ }, ko = "invalid-error-metadata", Ao = 64, jo = new Set(Object.values(O)), Mo = new Set(Object.values(x)), No = {
8459
8503
  [O.CANCELED]: {
8460
8504
  type: "semantic",
8461
8505
  reason: "canceled"
@@ -8576,7 +8620,7 @@ var uo = 90, fo = 3, po = class extends b {
8576
8620
  type: "semantic",
8577
8621
  reason: "obsolete_client"
8578
8622
  }
8579
- }, Mo = {
8623
+ }, Po = {
8580
8624
  [x.MIC_CAMERA_PERMISSION]: {
8581
8625
  type: "direct-error",
8582
8626
  error: {
@@ -8665,14 +8709,14 @@ var uo = 90, fo = 3, po = class extends b {
8665
8709
  }
8666
8710
  }
8667
8711
  };
8668
- function No(e) {
8669
- if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return Do;
8712
+ function Fo(e) {
8713
+ if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return ko;
8670
8714
  let t = String(e).trim();
8671
- if (!t) return Do;
8715
+ if (!t) return ko;
8672
8716
  let n = t.toLowerCase().replace(/[\s_:]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
8673
- return !n || !/^[a-z0-9.-]+$/.test(n) ? Do : n.length > Oo ? `${n.slice(0, Oo - 3)}...` : n;
8717
+ return !n || !/^[a-z0-9.-]+$/.test(n) ? ko : n.length > Ao ? `${n.slice(0, Ao - 3)}...` : n;
8674
8718
  }
8675
- function Po(e) {
8719
+ function Io(e) {
8676
8720
  if (!e || typeof e != "object") return !1;
8677
8721
  let t = e;
8678
8722
  switch (t.scope) {
@@ -8684,50 +8728,50 @@ function Po(e) {
8684
8728
  default: return !1;
8685
8729
  }
8686
8730
  }
8687
- function Fo(e) {
8688
- let t = No(e.description);
8731
+ function Lo(e) {
8732
+ let t = Fo(e.description);
8689
8733
  if (e.scope === "unknown") return `unknown:${t}`;
8690
- let n = No(e.code);
8734
+ let n = Fo(e.code);
8691
8735
  return e.scope === "internal" ? `internal:${n}:${t}` : `${e.scope}:${e.source}:${n}:${t}`;
8692
8736
  }
8693
- function Io(e, t) {
8737
+ function Ro(e, t) {
8694
8738
  return t === null ? e.type === "direct-error" ? {
8695
8739
  reason: "error",
8696
- string_value: Fo(e.error)
8697
- } : { reason: "failed" } : Po(t) ? {
8740
+ string_value: Lo(e.error)
8741
+ } : { reason: "failed" } : Io(t) ? {
8698
8742
  reason: "error",
8699
- string_value: Fo(t)
8743
+ string_value: Lo(t)
8700
8744
  } : { reason: "failed" };
8701
8745
  }
8702
- function Lo(e) {
8746
+ function zo(e) {
8703
8747
  if (e.hangup) {
8704
- let t = jo[e.hangup];
8748
+ let t = No[e.hangup];
8705
8749
  return t ? t.type === "semantic" ? e.hangup === O.OBSOLETE_CLIENT && e.custom_error?.vchat_detailed_api_error.code ? {
8706
8750
  reason: t.reason,
8707
8751
  string_value: e.custom_error.vchat_detailed_api_error.code
8708
- } : { reason: t.reason } : Io(t, e.callError) : { reason: "failed" };
8752
+ } : { reason: t.reason } : Ro(t, e.callError) : { reason: "failed" };
8709
8753
  }
8710
8754
  if (e.error) {
8711
- let t = Mo[e.error];
8712
- return t ? Io(t, e.callError) : { reason: "failed" };
8755
+ let t = Po[e.error];
8756
+ return t ? Ro(t, e.callError) : { reason: "failed" };
8713
8757
  }
8714
8758
  return { reason: "failed" };
8715
8759
  }
8716
- function Ro(e) {
8717
- return e instanceof k ? Lo(e) : typeof e == "string" && (ko.has(e) || Ao.has(e)) ? Lo(new k(e)) : { reason: "failed" };
8760
+ function Bo(e) {
8761
+ return e instanceof k ? zo(e) : typeof e == "string" && (jo.has(e) || Mo.has(e)) ? zo(new k(e)) : { reason: "failed" };
8718
8762
  }
8719
8763
  //#endregion
8720
8764
  //#region src/classes/stat/CallLifecycleStats.ts
8721
- var zo = {
8765
+ var Vo = {
8722
8766
  wallNow: () => Date.now(),
8723
8767
  monotonicNow: () => performance.now()
8724
8768
  };
8725
- function Bo(e) {
8769
+ function Ho(e) {
8726
8770
  return e === "anonym_join" ? "join" : e;
8727
8771
  }
8728
- var Vo = class {
8729
- constructor(e, t = zo) {
8730
- h(this, "_logger", void 0), h(this, "_clock", void 0), h(this, "_conversationId", null), h(this, "_callStartLabel", null), h(this, "_lifecycleStartedAtMonotonic", 0), h(this, "_warmupStartedAtMonotonic", null), h(this, "_pendingEvents", []), h(this, "_warmupCompleted", !1), h(this, "_callStarted", !1), h(this, "_accepted", !1), h(this, "_firstMediaSent", !1), h(this, "_finished", !1), h(this, "_destroyed", !1), this._logger = e, this._clock = t;
8772
+ var Uo = class {
8773
+ constructor(e, t = Vo) {
8774
+ h(this, "_logger", void 0), h(this, "_clock", void 0), h(this, "_conversationId", null), h(this, "_callStartLabel", null), h(this, "_lifecycleStartedAtMonotonic", 0), h(this, "_pendingEvents", []), h(this, "_callStarted", !1), h(this, "_accepted", !1), h(this, "_firstMediaSent", !1), h(this, "_finished", !1), h(this, "_destroyed", !1), this._logger = e, this._clock = t;
8731
8775
  }
8732
8776
  get firstMediaSentReported() {
8733
8777
  return this._firstMediaSent;
@@ -8738,7 +8782,7 @@ var Vo = class {
8738
8782
  markInitializationStarted({ source: e, conversationId: t }) {
8739
8783
  if (this._destroyed || this._callStartLabel !== null) return;
8740
8784
  let n = this._clock.wallNow();
8741
- this._callStartLabel = Bo(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
8785
+ this._callStartLabel = Ho(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
8742
8786
  name: U.CALL_INIT,
8743
8787
  source: e
8744
8788
  }, n);
@@ -8746,23 +8790,11 @@ var Vo = class {
8746
8790
  bindConversationId(e) {
8747
8791
  this._destroyed || this._conversationId || !e || (this._conversationId = e, this._flushPendingEvents());
8748
8792
  }
8749
- markWarmupStarted() {
8750
- !this._canRecord() || this._warmupStartedAtMonotonic !== null || (this._warmupStartedAtMonotonic = this._clock.monotonicNow());
8751
- }
8752
- markWarmupCompleted() {
8753
- if (!this._canRecord() || this._warmupCompleted || this._warmupStartedAtMonotonic === null) return;
8754
- this._warmupCompleted = !0;
8755
- let e = this._durationSince(this._warmupStartedAtMonotonic);
8756
- this._record({
8757
- name: U.CALL_WARMUP,
8758
- value: e
8759
- });
8760
- }
8761
8793
  markCallStarted() {
8762
8794
  !this._canRecord() || this._callStarted || !this._callStartLabel || (this._callStarted = !0, this._record({
8763
8795
  name: U.CALL_START,
8764
8796
  value: this._durationSince(this._lifecycleStartedAtMonotonic),
8765
- string_value: JSON.stringify({ labels: [this._callStartLabel, "warmup_start"] })
8797
+ string_value: JSON.stringify({ labels: [this._callStartLabel] })
8766
8798
  }));
8767
8799
  }
8768
8800
  markOutgoingAccepted() {
@@ -8778,7 +8810,7 @@ var Vo = class {
8778
8810
  !this._canRecord() || this._firstMediaSent || (this._firstMediaSent = !0, this._record({ name: U.FIRST_MEDIA_SENT }));
8779
8811
  }
8780
8812
  markFinished(e) {
8781
- this._finish(Ro(e));
8813
+ this._finish(Bo(e));
8782
8814
  }
8783
8815
  markTerminated() {
8784
8816
  this._finish({ reason: "terminated" });
@@ -8829,7 +8861,7 @@ var Vo = class {
8829
8861
  ...n && { immediately: !0 }
8830
8862
  });
8831
8863
  }
8832
- }, Ho = class {
8864
+ }, Wo = class {
8833
8865
  constructor(e, t) {
8834
8866
  h(this, "_logger", void 0), h(this, "_codecUsages", /* @__PURE__ */ new Map()), h(this, "getCurrentTransportTopology", void 0), this._logger = e, this.getCurrentTransportTopology = t;
8835
8867
  }
@@ -8892,7 +8924,7 @@ var Vo = class {
8892
8924
  this.report(e);
8893
8925
  }), this._codecUsages.clear();
8894
8926
  }
8895
- }, Uo = class {
8927
+ }, Go = class {
8896
8928
  constructor(e) {
8897
8929
  h(this, "_logger", void 0), h(this, "_eventualLogs", /* @__PURE__ */ new Set()), this._logger = e;
8898
8930
  }
@@ -8917,7 +8949,7 @@ var Vo = class {
8917
8949
  destroy() {
8918
8950
  this._eventualLogs.clear();
8919
8951
  }
8920
- }, Wo = class {
8952
+ }, Ko = class {
8921
8953
  constructor(e) {
8922
8954
  if (h(this, "q", void 0), h(this, "inits", []), h(this, "n", [
8923
8955
  1,
@@ -8976,7 +9008,7 @@ var Vo = class {
8976
9008
  5
8977
9009
  ];
8978
9010
  }
8979
- }, Go = class {
9011
+ }, qo = class {
8980
9012
  constructor() {
8981
9013
  h(this, "n", 0), h(this, "mean", 0);
8982
9014
  }
@@ -8988,9 +9020,9 @@ var Vo = class {
8988
9020
  get avg() {
8989
9021
  return this.n ? this.mean : NaN;
8990
9022
  }
8991
- }, Ko = class {
9023
+ }, Jo = class {
8992
9024
  constructor() {
8993
- h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new Go()), h(this, "p50", new Wo(.5)), h(this, "p95", new Wo(.95));
9025
+ h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new qo()), h(this, "p50", new Ko(.5)), h(this, "p95", new Ko(.95));
8994
9026
  }
8995
9027
  add(e) {
8996
9028
  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++;
@@ -9008,11 +9040,11 @@ var Vo = class {
9008
9040
  get hasData() {
9009
9041
  return this.count > 0;
9010
9042
  }
9011
- }, qo = class {
9043
+ }, Yo = class {
9012
9044
  constructor(e) {
9013
9045
  h(this, "_logger", void 0), h(this, "trackerByTransport", {
9014
- ws: new Ko(),
9015
- wt: new Ko()
9046
+ ws: new Jo(),
9047
+ wt: new Jo()
9016
9048
  }), h(this, "lastSeen", {}), this._logger = e;
9017
9049
  }
9018
9050
  mark(e) {
@@ -9041,17 +9073,17 @@ var Vo = class {
9041
9073
  }
9042
9074
  destroy() {
9043
9075
  this.trackerByTransport = {
9044
- ws: new Ko(),
9045
- wt: new Ko()
9076
+ ws: new Jo(),
9077
+ wt: new Jo()
9046
9078
  }, this.lastSeen = {};
9047
9079
  }
9048
- }, Jo = class {
9080
+ }, Xo = class {
9049
9081
  constructor(e) {
9050
9082
  h(this, "_logger", void 0), h(this, "trackerByCommand", /* @__PURE__ */ new Map()), this._logger = e;
9051
9083
  }
9052
9084
  mark(e, t, n) {
9053
9085
  let r = `${e}|${n}`, i;
9054
- this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new Ko(), this.trackerByCommand.set(r, i)), i.add(t);
9086
+ this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new Jo(), this.trackerByCommand.set(r, i)), i.add(t);
9055
9087
  }
9056
9088
  logMetrics() {
9057
9089
  for (let [e, t] of this.trackerByCommand.entries()) {
@@ -9073,9 +9105,9 @@ var Vo = class {
9073
9105
  destroy() {
9074
9106
  this.trackerByCommand.clear();
9075
9107
  }
9076
- }, Yo = class {
9108
+ }, Zo = class {
9077
9109
  constructor(e, t, n, r) {
9078
- h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), this.logger = new Eo(e, t, n, r), this.lifecycle = new Vo(this.logger), this.statAggregator = new Uo(this.logger), this.codecStatsAggregator = new Ho(this.logger, r), this.pings = new qo(this.logger), this.signalingCommands = new Jo(this.logger);
9110
+ h(this, "logger", void 0), h(this, "lifecycle", void 0), h(this, "statAggregator", void 0), h(this, "codecStatsAggregator", void 0), h(this, "pings", void 0), h(this, "signalingCommands", void 0), this.logger = new Oo(e, t, n, r), this.lifecycle = new Uo(this.logger), this.statAggregator = new Go(this.logger), this.codecStatsAggregator = new Wo(this.logger, r), this.pings = new Yo(this.logger), this.signalingCommands = new Xo(this.logger);
9079
9111
  }
9080
9112
  logHangup(e) {
9081
9113
  this.lifecycle.markFinished(e);
@@ -9086,7 +9118,7 @@ var Vo = class {
9086
9118
  destroy() {
9087
9119
  this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.logger.destroy();
9088
9120
  }
9089
- }, Xo = class {
9121
+ }, Qo = class {
9090
9122
  constructor(e) {
9091
9123
  h(this, "_statAggregator", void 0), h(this, "_isCallMarked", !1), h(this, "_isFinished", !1), h(this, "_callType", null), this._statAggregator = e;
9092
9124
  }
@@ -9111,8 +9143,8 @@ var Vo = class {
9111
9143
  call_type: this._callType
9112
9144
  }));
9113
9145
  }
9114
- }, Zo = 1e3, Qo = 1e4;
9115
- function $o(e, t, n, r) {
9146
+ }, $o = 1e3, es = 1e4;
9147
+ function ts(e, t, n, r) {
9116
9148
  return new k(e, {
9117
9149
  callError: {
9118
9150
  scope: "external",
@@ -9123,9 +9155,9 @@ function $o(e, t, n, r) {
9123
9155
  message: r
9124
9156
  });
9125
9157
  }
9126
- var es = 15, $ = class e extends b {
9158
+ var ns = 15, $ = class e extends b {
9127
9159
  constructor(e, t) {
9128
- super(), h(this, "_api", void 0), h(this, "_signaling", void 0), h(this, "_signalingActor", void 0), h(this, "_displayLayoutRequester", void 0), h(this, "_mediaSource", null), h(this, "_conversation", null), h(this, "_myLastRequestedLayouts", {}), h(this, "_state", "IDLE"), h(this, "_previousState", null), h(this, "_waitingHallHoldPending", !1), h(this, "_participantState", Z.CALLED), h(this, "_participants", {}), h(this, "_pendingParticipants", /* @__PURE__ */ new Map()), h(this, "_directTransportIsMaster", void 0), h(this, "_transport", null), h(this, "_debugInfo", null), h(this, "_debug", z.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, "_hangupEmitted", !1), h(this, "_hangupPromise", null), h(this, "_abortController", null), h(this, "_registeredPeerReceived", !1), h(this, "_calleeUnavailableTimer", null), h(this, "_reservedId", null), h(this, "_onUnload", void 0), h(this, "_audioOutput", void 0), h(this, "_stats", void 0), h(this, "_lastStalled", {}), h(this, "_audioMixStalled", !1), h(this, "_audioFix", null), h(this, "_streamByStreamId", /* @__PURE__ */ new Map()), h(this, "_streamIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_streamWaitTimerByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_sequenceNumberByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownTimestampByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownQueueCleanupTimer", null), h(this, "_statFirstMediaReceived", void 0), h(this, "_changeMediaSettings", M.debounce(async (e) => {
9160
+ super(), h(this, "_api", void 0), h(this, "_signaling", void 0), h(this, "_signalingActor", void 0), h(this, "_displayLayoutRequester", void 0), h(this, "_mediaSource", null), h(this, "_conversation", null), h(this, "_myLastRequestedLayouts", {}), h(this, "_state", "IDLE"), h(this, "_previousState", null), h(this, "_waitingHallHoldPending", !1), h(this, "_participantState", Z.CALLED), h(this, "_participants", {}), h(this, "_directTransportIsMaster", void 0), h(this, "_transport", null), h(this, "_debugInfo", null), h(this, "_debug", z.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, "_hangupEmitted", !1), h(this, "_hangupPromise", null), h(this, "_abortController", null), h(this, "_registeredPeerReceived", !1), h(this, "_calleeUnavailableTimer", null), h(this, "_reservedId", null), h(this, "_onUnload", void 0), h(this, "_audioOutput", void 0), h(this, "_stats", void 0), h(this, "_lastStalled", {}), h(this, "_audioMixStalled", !1), h(this, "_audioFix", null), h(this, "_streamByStreamId", /* @__PURE__ */ new Map()), h(this, "_streamIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_streamWaitTimerByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_sequenceNumberByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownTimestampByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_cooldownQueueCleanupTimer", null), h(this, "_statFirstMediaReceived", void 0), h(this, "_changeMediaSettings", M.debounce(async (e) => {
9129
9161
  if (this._signaling.ready) try {
9130
9162
  await this._signaling.changeMediaSettings(e);
9131
9163
  } catch (e) {
@@ -9135,21 +9167,21 @@ var es = 15, $ = class e extends b {
9135
9167
  captureAudio: !1
9136
9168
  });
9137
9169
  }
9138
- }, 100)), this._stats = new Yo(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new Na(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new vo(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new mo({
9170
+ }, 100)), this._stats = new Zo(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new Na(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new bo(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new go({
9139
9171
  api: this._api,
9140
9172
  debug: this._debug,
9141
- getParticipants: () => this._getParticipants(),
9173
+ getParticipants: () => this._participants,
9142
9174
  isMe: (e) => this._isMe(e),
9143
9175
  updateDisplayLayout: (e) => this.updateDisplayLayout(e)
9144
9176
  }), this._onUnload = () => {
9145
9177
  this._stopFirstMediaSentProbe(), this._conversation && this._api && this._api.hangupConversation(this._conversation.id, this._state === "IDLE" ? O.CANCELED : O.HUNGUP), this._stats.destroy();
9146
- }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new Xo(this._stats.statAggregator), this._audioOutput = new oo(this._statFirstMediaReceived, N.transparentAudio, this._debug, this._stats.logger), N.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), Zo));
9178
+ }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new Qo(this._stats.statAggregator), this._audioOutput = new co(this._statFirstMediaReceived, N.transparentAudio, this._debug, this._stats.logger), N.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), $o));
9147
9179
  }
9148
9180
  static current() {
9149
9181
  return B.getActive() ?? (N.hold ? null : B.getFirst());
9150
9182
  }
9151
9183
  static hangupAfterInit() {
9152
- let e = ts;
9184
+ let e = rs;
9153
9185
  e && e._delayedHangup === !1 && !e._conversation && (e._delayedHangup = !0, e._abortController?.abort(new k(O.CANCELED)));
9154
9186
  }
9155
9187
  static id() {
@@ -9192,11 +9224,11 @@ var es = 15, $ = class e extends b {
9192
9224
  this._stats.lifecycle.markInitializationStarted({
9193
9225
  source: "outgoing",
9194
9226
  conversationId: u
9195
- }), this._debug.setConversationId(u), ts = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
9227
+ }), this._debug.setConversationId(u), rs = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
9196
9228
  try {
9197
9229
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
9198
9230
  let l = this._mediaSource.mediaSettings;
9199
- t === Fa.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l), this._stats.lifecycle.markWarmupStarted();
9231
+ t === Fa.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
9200
9232
  let d = await this._startConversation({
9201
9233
  opponentIds: e,
9202
9234
  opponentType: t,
@@ -9220,18 +9252,18 @@ var es = 15, $ = class e extends b {
9220
9252
  opponentIds: e,
9221
9253
  opponentType: t,
9222
9254
  mediaOptions: n
9223
- }), this._processConnectionSharedMovieInfo(d), this._processConversationUrlSharingInfo(d), R.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), void 0, this.id), this._onConversationParticipantListChunk(d), this._processPinnedParticipants(d), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), B.add(this), await B.setActive(this.id), ts = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9255
+ }), this._processConnectionSharedMovieInfo(d), this._processConversationUrlSharingInfo(d), R.onLocalStream(this._mediaSource.getStream(), this._mediaSource.mediaSettings, this.id), R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), void 0, this.id), this._onConversationParticipantListChunk(d), this._processPinnedParticipants(d), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeFeatureSet(), this._changeNeedRate(), B.add(this), await B.setActive(this.id), rs = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9224
9256
  this._calleeUnavailableTimer = null, this._close(new k(O.CALLEE_UNAVAILABLE), { signalingReason: O.CANCELED });
9225
9257
  }, f)), this._conversation;
9226
9258
  } catch (e) {
9227
- throw ts = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
9259
+ throw rs = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
9228
9260
  }
9229
9261
  }
9230
9262
  async onJoin(e) {
9231
9263
  this._stats.lifecycle.markInitializationStarted({
9232
9264
  source: e.anonymous ? "anonym_join" : "join",
9233
9265
  conversationId: e.conversationId
9234
- }), ts = 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);
9266
+ }), rs = 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);
9235
9267
  try {
9236
9268
  let t = !!e.observedIds?.length;
9237
9269
  if (t && N.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new k(O.UNSUPPORTED, { callError: {
@@ -9241,16 +9273,16 @@ var es = 15, $ = class e extends b {
9241
9273
  } });
9242
9274
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(e.mediaOptions, !t);
9243
9275
  let n = this._mediaSource.mediaSettings;
9244
- this._logWithMediaSettings(C.JOIN_CONVERSATION, n), this._stats.lifecycle.markWarmupStarted();
9276
+ this._logWithMediaSettings(C.JOIN_CONVERSATION, n);
9245
9277
  let r = await this._joinConversation(e);
9246
9278
  if (!this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
9247
9279
  scope: "internal",
9248
9280
  code: "conversation",
9249
9281
  description: "not-initialized-after-join"
9250
9282
  } });
9251
- return this._conversation.observer = t, R.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), B.add(this), ts = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
9283
+ return this._conversation.observer = t, R.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), B.add(this), rs = null, this._signaling.readyToSend(), R.onLocalStatus(this._conversation.waitForAdmin ? P.WAIT_FOR_ADMIN : P.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
9252
9284
  } catch (e) {
9253
- throw ts = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9285
+ throw rs = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9254
9286
  }
9255
9287
  }
9256
9288
  async _onJoinPart2(e, t = !0, n = !1) {
@@ -9265,15 +9297,15 @@ var es = 15, $ = class e extends b {
9265
9297
  if (this._delayedHangup) throw new k(O.CANCELED);
9266
9298
  this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
9267
9299
  let r = this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
9268
- R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (B.add(this), n ? await this._holdLocally() : await B.setActive(this.id), ts = null);
9300
+ R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (B.add(this), n ? await this._holdLocally() : await B.setActive(this.id), rs = null);
9269
9301
  let i = this._extractLocalParticipantFromConnection(e);
9270
9302
  if (i) {
9271
9303
  let e = M.mapParticipantState(i);
9272
9304
  Object.keys(e).length > 0 && R.onLocalParticipantState(e, !1, this.id);
9273
9305
  }
9274
- return t && this._openTransport(Object.values(this._getParticipants()), !1), this._conversation;
9306
+ return t && this._openTransport(Object.values(this._participants), !1), this._conversation;
9275
9307
  } catch (e) {
9276
- throw ts = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9308
+ throw rs = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9277
9309
  }
9278
9310
  }
9279
9311
  _extractExternalRooms(e) {
@@ -9289,9 +9321,8 @@ var es = 15, $ = class e extends b {
9289
9321
  B.reserve(e), this._reservedId = e, this._stats.lifecycle.markInitializationStarted({
9290
9322
  source: "incoming",
9291
9323
  conversationId: e
9292
- }), this._debug.setConversationId(e), ts = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal), a && this._api.setUserId(a);
9324
+ }), this._debug.setConversationId(e), rs = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal), a && this._api.setUserId(a);
9293
9325
  try {
9294
- this._stats.lifecycle.markWarmupStarted();
9295
9326
  let a = await this._prepareConversation(e, t, n, r, i);
9296
9327
  if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new k(O.UNKNOWN_ERROR, { callError: {
9297
9328
  scope: "internal",
@@ -9299,9 +9330,9 @@ var es = 15, $ = class e extends b {
9299
9330
  description: "incoming-not-initialized"
9300
9331
  } });
9301
9332
  if (!a.conversation.participants.find((e) => e.state === Z.CALLED && e.id === this._conversation?.userId)) throw this._debug.log("Push rejected (there is an active call)"), this._stats.logger.log(C.PUSH, "rejected"), new k(O.REJECTED);
9302
- if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(C.PUSH, "accepted"), B.add(this), ts = null, this._delayedHangup) throw new k(O.CANCELED);
9333
+ if (await this._processConnection(a), this._extractConnectionUrlSharingInfo(a), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._processPinnedParticipants(a), this._signaling.readyToSend(), this._stats.lifecycle.markCallStarted(), this._stats.logger.log(C.PUSH, "accepted"), B.add(this), rs = null, this._delayedHangup) throw new k(O.CANCELED);
9303
9334
  } catch (e) {
9304
- throw ts = null, this._cleanupRegistry(), this._close(e, {
9335
+ throw rs = null, this._cleanupRegistry(), this._close(e, {
9305
9336
  errorText: "Unable to handle inbound call push",
9306
9337
  signalingReason: e instanceof k && e.hangup === O.BUSY ? O.BUSY : void 0
9307
9338
  }), e;
@@ -9335,13 +9366,13 @@ var es = 15, $ = class e extends b {
9335
9366
  let e = this._mediaSource.mediaSettings;
9336
9367
  this._logWithMediaSettings(C.ACCEPT_CONCURRENT, e), this._debug.debug("Concurrent call", { conversationId: this._conversation.id });
9337
9368
  try {
9338
- this._statFirstMediaReceived.markAcceptCall(this._transport.getTopology()), await this._signaling.acceptCall(this._mediaSource.mediaSettings), this._stats.lifecycle.markIncomingAccepted(!0), R.onCallAccepted(this.id), this._state = "ACTIVE", this._participantState = Z.ACCEPTED, this._changeFeatureSet(), this._openTransport(Object.values(this._getParticipants()), !0);
9369
+ this._statFirstMediaReceived.markAcceptCall(this._transport.getTopology()), await this._signaling.acceptCall(this._mediaSource.mediaSettings), this._stats.lifecycle.markIncomingAccepted(!0), R.onCallAccepted(this.id), this._state = "ACTIVE", this._participantState = Z.ACCEPTED, this._changeFeatureSet(), this._openTransport(Object.values(this._participants), !0);
9339
9370
  } catch (e) {
9340
9371
  this._close(e, { errorText: "Unable to accept concurrent call" });
9341
9372
  }
9342
9373
  }
9343
9374
  _getMainRoomParticipants() {
9344
- let e = this._getParticipants();
9375
+ let e = this._participants;
9345
9376
  return M.mapSharedParticipants(Object.values(e).filter((e) => !e.isInRoom));
9346
9377
  }
9347
9378
  _decodeExternalConversationParams(e) {
@@ -9350,7 +9381,7 @@ var es = 15, $ = class e extends b {
9350
9381
  let i = atob(n), a = new Uint8Array(i.length);
9351
9382
  for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
9352
9383
  try {
9353
- let e = io(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);
9384
+ let e = oo(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);
9354
9385
  return {
9355
9386
  token: i,
9356
9387
  endpoint: l,
@@ -9387,8 +9418,8 @@ var es = 15, $ = class e extends b {
9387
9418
  stateUpdated: !0
9388
9419
  }), this._registerParticipantLocalMuteState({ muteStates: this._conversation.muteStatesPersonal });
9389
9420
  let i = await this._signaling.getRooms(this._isCallAdmin());
9390
- if (i.rooms?.rooms) {
9391
- let e = this._getParticipants();
9421
+ if (i.rooms?.rooms?.length) {
9422
+ let e = this._participants;
9392
9423
  i.rooms.rooms.forEach((t) => {
9393
9424
  t.participantIds?.forEach((t) => {
9394
9425
  e[t] && (e[t].isInRoom = !0);
@@ -9398,30 +9429,32 @@ var es = 15, $ = class e extends b {
9398
9429
  this._conversation.roomId = i.rooms?.roomId || null;
9399
9430
  let a = this._extractExternalRoomsData(i.rooms?.rooms, i.rooms?.roomId);
9400
9431
  if (R.onCallAccepted(this.id), R.onLocalStream(this._mediaSource.getStream(), t, this.id), R.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), a, this.id), await this._emitHeldParticipantsStatus(), N.useParticipantListChunk) {
9401
- let e = await this._getInitialParticiapntListChunk(), t = this._getParticipants();
9432
+ let e = await this._getInitialParticiapntListChunk(), t = this._participants;
9402
9433
  e?.participants?.forEach((e) => {
9403
9434
  let n = t[M.composeId(e)];
9404
9435
  n && (n.movieShareInfos = e.movieShareInfos);
9405
9436
  }), this._onConversationParticipantListChunk({ participants: e });
9406
9437
  }
9407
- return R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), this._state = "ACTIVE", this._changeFeatureSet(), this._openTransport(Object.values(this._getParticipants()), !0), this._processConversationUrlSharingInfo(), this._processConnectionAsrInfo(), B.setActive(this.id).catch((e) => {
9438
+ return R.onLocalStatus(P.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), this._state = "ACTIVE", this._changeFeatureSet(), this._openTransport(Object.values(this._participants), !0), this._processConversationUrlSharingInfo(), this._processConnectionAsrInfo(), B.setActive(this.id).catch((e) => {
9408
9439
  this._debug.error(e), this._close(e, { errorText: "Unable to activated accepted call" });
9409
9440
  }), this._conversation;
9410
9441
  } catch (e) {
9411
9442
  throw this._close(e, { errorText: "Unable to accept call" }), e;
9412
9443
  }
9413
9444
  }
9414
- async decline() {
9445
+ async decline(e) {
9415
9446
  if (this._state !== "IDLE") throw this._stats.logger.log(C.ERROR, "declineIncoming"), this._debug.error("Unable to decline a call - invalid state"), Error("Unable to decline a call - invalid state");
9416
9447
  this._state = "PROCESSING", this._debug.debug("Decline incoming call"), this._logWithMediaSettings(C.DECLINE_INCOMING, this.mediaSettings), this._participantState = Z.HUNGUP;
9417
- let e = new k(O.REJECTED);
9418
- this._finishLifecycle(e), this._close(e, { signalingReason: O.REJECTED });
9448
+ let t = e ?? O.REJECTED, n = new k(t);
9449
+ this._finishLifecycle(n), this._close(n, { signalingReason: t });
9419
9450
  }
9420
- hangup() {
9451
+ hangup(e) {
9421
9452
  if (this._hangupPromise) return this._hangupPromise;
9422
9453
  this._clearCalleeUnavailableWatchdog(), this._debug.debug("Hangup");
9423
- let e = this._state === "ACTIVE" || this._state === "HELD" ? O.HUNGUP : O.CANCELED, t = new k(e), n = this._conversation?.id ?? null;
9424
- return this._stats.logger.log(C.HANGUP, e), this._finishLifecycle(t), this._hangupPromise = this._signaling.hangup(e).then(() => void 0).finally(() => this._close(t)), this._emitHangupOnce(t, n), this._cleanupMediaSource(), this._hangupPromise;
9454
+ let t = e ?? (this._state === "ACTIVE" || this._state === "HELD" ? O.HUNGUP : O.CANCELED), n = new k(t), r = this._conversation?.id ?? null;
9455
+ return this._stats.logger.log(C.HANGUP, t), this._finishLifecycle(n), this._hangupPromise = this._signaling.hangup(t).then(() => void 0).catch((e) => {
9456
+ if (!(e instanceof yn)) throw e;
9457
+ }).finally(() => this._close(n)), this._emitHangupOnce(n, r), this._cleanupTransport(), this._cleanupMediaSource(), this._hangupPromise;
9425
9458
  }
9426
9459
  async addParticipant(e, t) {
9427
9460
  if (!this._signaling.ready) {
@@ -9435,7 +9468,7 @@ var es = 15, $ = class e extends b {
9435
9468
  let n = await this._signaling.addParticipant(e.map(Q.toSignaling), t), r = null;
9436
9469
  n.type === "error" && (r = n.error === "call-unfeasible" ? n.status : O.UNKNOWN_ERROR);
9437
9470
  let i = n.participants;
9438
- if (!i && n.rejectedParticipants) throw Error(n.rejectedParticipants[0].reason);
9471
+ if (!i && n.rejectedParticipants?.length) throw Error(n.rejectedParticipants[0].reason);
9439
9472
  for (let e of i) await this._onAddParticipant(M.composeId(e), e, r);
9440
9473
  }
9441
9474
  async addParticipantLegacy(e, t) {
@@ -9478,11 +9511,9 @@ var es = 15, $ = class e extends b {
9478
9511
  }
9479
9512
  _close(e, t = {}) {
9480
9513
  this._clearCalleeUnavailableWatchdog(), t.errorText && this._debug.error(t.errorText, e), this._debug.debug("Close conversation", e), this._finishLifecycle(e), this._stats.flushCallMetrics();
9481
- let n = t.signalingReason ?? (e.error ? O.FAILED : void 0);
9482
- n && this._signaling.ready && this._signaling.hangup(n).catch((e) => {
9483
- this._debug.warn("[signaling] unable to send hangup", e);
9484
- }), this._signaling.readyToSend(!1), e.error || this._stats.logger.log(C.ERROR, e.hangup);
9485
- let r = this._conversation && this._conversation.id;
9514
+ let n = t.signalingReason ?? (e.error ? O.FAILED : void 0), r = n && this._signaling.ready ? this._signaling.hangup(n) : void 0;
9515
+ this._signaling.readyToSend(!1), e.error || this._stats.logger.log(C.ERROR, e.hangup);
9516
+ let i = this._conversation && this._conversation.id;
9486
9517
  if ([
9487
9518
  O.CANCELED,
9488
9519
  O.NOT_FRIENDS,
@@ -9491,60 +9522,46 @@ var es = 15, $ = class e extends b {
9491
9522
  O.CALLER_IS_BLOCKED,
9492
9523
  O.CALLER_IS_REJECTED
9493
9524
  ].indexOf(e.hangup) !== -1 || e.hangup === O.REJECTED && !e.remote) {
9494
- this._emitHangupOnce(e, r), this.destroy();
9525
+ this._emitHangupOnce(e, i), this._destroy(r);
9495
9526
  return;
9496
9527
  }
9497
9528
  if (e.hangup === O.HUNGUP && (!e.remote || this._isCalledState())) {
9498
- this._emitHangupOnce(e, r), this.destroy();
9529
+ this._emitHangupOnce(e, i), this._destroy(r);
9499
9530
  return;
9500
9531
  }
9501
9532
  if (e.hangup === O.MISSED && !e.remote) {
9502
- this._emitHangupOnce(e, r), this.destroy();
9533
+ this._emitHangupOnce(e, i), this._destroy(r);
9503
9534
  return;
9504
9535
  }
9505
9536
  if (this._cooldownQueueCleanupTimer !== null && (window.clearInterval(this._cooldownQueueCleanupTimer), this._cooldownQueueCleanupTimer = null), (e.hangup === O.SOCKET_CLOSED || e.hangup === O.NOT_FOUND) && B.getActive() && !this._conversation) {
9506
- this._disposeSignaling(), this._cleanupMediaSource();
9537
+ this._disposeSignaling(r), this._cleanupMediaSource();
9507
9538
  return;
9508
9539
  }
9509
9540
  if (e.hangup === O.BUSY && !e.remote) {
9510
- this._disposeSignaling(), this._cleanupMediaSource();
9541
+ this._disposeSignaling(r), this._cleanupMediaSource();
9511
9542
  return;
9512
9543
  }
9513
- this._state = "CLOSE", this._participantState = Z.HUNGUP, this._changeFeatureSet(), this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._disposeSignaling(), this._api.cleanup(), this._api.setAbortSignal(void 0), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null, this._emitHangupOnce(e || new k(O.UNKNOWN_ERROR), r);
9544
+ this._state = "CLOSE", this._participantState = Z.HUNGUP, this._changeFeatureSet(), this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._disposeSignaling(r), this._api.cleanup(), this._api.setAbortSignal(void 0), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null, this._emitHangupOnce(e || new k(O.UNKNOWN_ERROR), i);
9514
9545
  }
9515
9546
  destroy() {
9547
+ this._destroy();
9548
+ }
9549
+ _destroy(e) {
9516
9550
  this._clearCalleeUnavailableWatchdog();
9517
- let e = this._conversation && this._conversation.id;
9518
- if (this._debug.debug("Destroy conversation", { conversationId: e }), this._stopFirstMediaSentProbe(), this._cooldownQueueCleanupTimer !== null && (window.clearInterval(this._cooldownQueueCleanupTimer), this._cooldownQueueCleanupTimer = null), this._state = "CLOSE", this._participantState = Z.HUNGUP, this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._disposeSignaling(), this._api.cleanup(), this._api.setAbortSignal(void 0), this._delayedHangup && e) try {
9519
- this._api.hangupConversation(e, O.CANCELED);
9551
+ let t = this._conversation && this._conversation.id;
9552
+ if (this._debug.debug("Destroy conversation", { conversationId: t }), this._stopFirstMediaSentProbe(), this._cooldownQueueCleanupTimer !== null && (window.clearInterval(this._cooldownQueueCleanupTimer), this._cooldownQueueCleanupTimer = null), this._state = "CLOSE", this._participantState = Z.HUNGUP, this._cleanupMediaSource(), this._cleanupParticipants(), this._cleanupParticipantAgnosticStreams(), this._cleanupTransport(), this._cleanupSpeakerDetector(), this._cleanupSpecListener(), this._disposeSignaling(e), this._api.cleanup(), this._api.setAbortSignal(void 0), this._delayedHangup && t) try {
9553
+ this._api.hangupConversation(t, O.CANCELED);
9520
9554
  } catch {}
9521
9555
  this._cleanupListeners(), this._stats.destroy(), this._cleanupRegistry(), this._conversation = null, this._myLastRequestedLayouts = {}, this._displayLayoutRequester.clear(), this._delayedHangup = !1, this._abortController = null;
9522
9556
  }
9523
9557
  async _getConversationParams(e) {
9524
9558
  let t = await this._api.getConversationParams(e);
9525
9559
  this._debug.debug("Api.getConversationParams", t);
9526
- let n = [], { turn_server: r, stun_server: i } = t;
9527
- if (i && n.push(i), r && r.urls) {
9528
- let e = r.urls.filter((e, t, n) => n.indexOf(e) === t);
9529
- e.push(`${e[e.length - 1]}?transport=tcp`), n.push({
9530
- urls: e,
9531
- username: r.username,
9532
- credential: r.credential
9533
- });
9534
- }
9535
- return N.iceServers = n, N.wssBase = t.endpoint, t.wt_endpoint && (N.wtsBase = t.wt_endpoint), N.wssToken = t.token, t.client_type && (N.clientType = t.client_type), t.external_user_type && (N.externalUserType = t.external_user_type), t;
9560
+ let { turn_server: n, stun_server: r } = t;
9561
+ return N.iceServers = ao(r, n), N.wssBase = t.endpoint, t.wt_endpoint && (N.wtsBase = t.wt_endpoint), N.wssToken = t.token, t.client_type && (N.clientType = t.client_type), t.external_user_type && (N.externalUserType = t.external_user_type), t;
9536
9562
  }
9537
9563
  _setConversationParams({ turn_server: e, stun_server: t, endpoint: n, wt_endpoint: r, token: i, client_type: a }) {
9538
- let o = [];
9539
- if (t && o.push(t), e && e.urls) {
9540
- let t = e.urls.filter((e, t, n) => n.indexOf(e) === t);
9541
- t.push(`${t[t.length - 1]}?transport=tcp`), o.push({
9542
- urls: t,
9543
- username: e.username,
9544
- credential: e.credential
9545
- });
9546
- }
9547
- N.iceServers = o, N.wssBase = n, N.wssToken = i, r && (N.wtsBase = r), a && (N.clientType = a);
9564
+ N.iceServers = ao(t, e), N.wssBase = n, N.wssToken = i, r && (N.wtsBase = r), a && (N.clientType = a);
9548
9565
  }
9549
9566
  _buildSignalingEndpoint({ baseEndpoint: e, userId: t, type: n, deviceIdx: r, conversationId: i, token: a, conversationParams: o }) {
9550
9567
  let s = new URL(e), c = s.searchParams;
@@ -9584,10 +9601,10 @@ var es = 15, $ = class e extends b {
9584
9601
  isVideo: f,
9585
9602
  joiningAllowed: a,
9586
9603
  requireAuthToJoin: o
9587
- }, this._abortController?.signal), !s) throw $o(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
9604
+ }, this._abortController?.signal), !s) throw ts(O.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
9588
9605
  if (!s.internalCallerParams) {
9589
9606
  let e = s.rejectedParticipants[0]?.status;
9590
- throw $o(O.FAST_START_ERROR, e ? "fast-start" : "invalid-response", e ?? "fast-start-internal-caller-params-empty", JSON.stringify(s));
9607
+ throw ts(O.FAST_START_ERROR, e ? "fast-start" : "invalid-response", e ?? "fast-start-internal-caller-params-empty", JSON.stringify(s));
9591
9608
  }
9592
9609
  } catch (e) {
9593
9610
  throw this._delayedHangup && this._abortController?.signal.aborted ? new k(O.CANCELED) : e instanceof k ? e : e instanceof Error ? new k(O.FAST_START_ERROR, { message: e.message }) : new k(O.FAST_START_ERROR, { message: String(e) });
@@ -9609,10 +9626,10 @@ var es = 15, $ = class e extends b {
9609
9626
  token: new URL(e.endpoint).searchParams.get("token") ?? ""
9610
9627
  }, this._debug.debug("FastStart", p), m = "fastStart";
9611
9628
  } catch {
9612
- throw $o(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
9629
+ throw ts(O.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
9613
9630
  }
9614
9631
  } else p = await this._api.startConversation(d, e, t, f, i, a, o, { onlyAdminCanShareMovie: s }, c), this._debug.debug("Api.startConversation", p), m = "startConversation";
9615
- so(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id), this._stats.lifecycle.markWarmupCompleted();
9632
+ lo(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
9616
9633
  let ee = await this._connectSignaling(fr.START, p);
9617
9634
  return this._setConversation(p, ee, n), this._stats.lifecycle.markCallStarted(), ee;
9618
9635
  }
@@ -9645,9 +9662,9 @@ var es = 15, $ = class e extends b {
9645
9662
  joinLink: i,
9646
9663
  isVideo: c,
9647
9664
  internalParams: t
9648
- }, this._abortController?.signal), !n) throw $o(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
9649
- if (!n.internalCallerParams) throw $o(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(n));
9650
- if (!n.conversationId) throw $o(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(n));
9665
+ }, this._abortController?.signal), !n) throw ts(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
9666
+ if (!n.internalCallerParams) throw ts(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(n));
9667
+ if (!n.conversationId) throw ts(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(n));
9651
9668
  } catch (e) {
9652
9669
  throw this._delayedHangup && this._abortController?.signal.aborted ? new k(O.CANCELED) : e instanceof k ? e : e instanceof Error ? new k(O.FAST_JOIN_ERROR, { message: e.message }) : new k(O.FAST_JOIN_ERROR, { message: String(e) });
9653
9670
  }
@@ -9665,7 +9682,7 @@ var es = 15, $ = class e extends b {
9665
9682
  token: new URL(e.endpoint).searchParams.get("token") ?? ""
9666
9683
  }, this._debug.debug("FastJoin", l), u = "fastJoin";
9667
9684
  } catch (e) {
9668
- throw e instanceof k ? e : $o(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
9685
+ throw e instanceof k ? e : ts(O.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
9669
9686
  }
9670
9687
  } else if (t) l = await this._api.joinConversation(t, c, r), u = "joinConversation";
9671
9688
  else if (i) l = await this._api.joinConversationByLink(i, c, a, o), u = "joinConversationByLink";
@@ -9674,11 +9691,11 @@ var es = 15, $ = class e extends b {
9674
9691
  code: "join",
9675
9692
  description: "target-missing"
9676
9693
  } });
9677
- if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), so(l, u), l.id) {
9694
+ if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), lo(l, u), l.id) {
9678
9695
  if (B.has(l.id)) throw new k(O.HAS_ACTIVE_CALL);
9679
9696
  B.reserve(l.id), this._reservedId = l.id;
9680
9697
  }
9681
- this._setConversationParams(l), this._stats.lifecycle.markWarmupCompleted();
9698
+ this._setConversationParams(l);
9682
9699
  let d = await this._connectSignaling(fr.JOIN, l);
9683
9700
  return this._setConversation(l, d, Pa.JOINING), this._stats.lifecycle.markCallStarted(), d;
9684
9701
  }
@@ -9741,7 +9758,6 @@ var es = 15, $ = class e extends b {
9741
9758
  conversationParams: n
9742
9759
  }), l.wt_endpoint = c);
9743
9760
  }
9744
- this._stats.lifecycle.markWarmupCompleted();
9745
9761
  let u = await this._connectSignaling(fr.ACCEPT, l);
9746
9762
  return B.callsLength >= N.maxParallelCalls || !N.hold && B.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(C.PUSH, "busy"), Promise.reject(new k(O.BUSY))) : (this._setConversation(l, u, Pa.INCOMING, t), u);
9747
9763
  }
@@ -9847,7 +9863,7 @@ var es = 15, $ = class e extends b {
9847
9863
  }
9848
9864
  _createMediaSource() {
9849
9865
  let e = new Jt(this._debug, this._stats.logger);
9850
- return this.subscribe(e, Kt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, Kt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new ao(e, this._debug, this._stats.logger), e;
9866
+ return this.subscribe(e, Kt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, Kt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new so(e, this._debug, this._stats.logger), e;
9851
9867
  }
9852
9868
  async _connectSignaling(e, t) {
9853
9869
  this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null), this.subscribe(this._signaling, K.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, K.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, K.RECONNECT, this._onSignalingReconnect.bind(this));
@@ -9871,7 +9887,7 @@ var es = 15, $ = class e extends b {
9871
9887
  };
9872
9888
  }
9873
9889
  _participantListChunkToExternalChunk(e) {
9874
- let t = this._getParticipants(), n = M.mapSharedParticipants(e.participants.reduce((e, n) => {
9890
+ let t = this._participants, n = M.mapSharedParticipants(e.participants.reduce((e, n) => {
9875
9891
  let r = M.composeId(n);
9876
9892
  return t[r] && e.push(t[r]), e;
9877
9893
  }, []));
@@ -9889,7 +9905,7 @@ var es = 15, $ = class e extends b {
9889
9905
  if (!this._conversation) return;
9890
9906
  let n = e[0]?.externalId?.type;
9891
9907
  n && (N.externalUserType = n);
9892
- let r = this._getParticipants();
9908
+ let r = this._participants;
9893
9909
  for (let n of e) {
9894
9910
  let e = M.composeId(n);
9895
9911
  if (z.test("Conversation:RegisterParticipant", e), this._isMe(e)) {
@@ -9963,7 +9979,7 @@ var es = 15, $ = class e extends b {
9963
9979
  return this._participants[e.id] = e, e;
9964
9980
  }
9965
9981
  _getExistedParticipantByIdOrCreate(e) {
9966
- let t = this._getParticipants()[e];
9982
+ let t = this._participants[e];
9967
9983
  if (t) return t;
9968
9984
  let n = this._api.getDecorativeIdByInitialId(M.decomposeId(e).id), r = n ? M.composeUserId(n) : void 0, i = this._getParticipantId(e), { deviceIdx: a } = M.decomposeParticipantId(e);
9969
9985
  return this._createParticipant({
@@ -9977,7 +9993,7 @@ var es = 15, $ = class e extends b {
9977
9993
  _getExternalIdByParticipantId(e) {
9978
9994
  if (this._isMe(e)) return this._conversation?.externalId;
9979
9995
  if (N.useParticipantListChunk) return this._getExistedParticipantByIdOrCreate(e).externalId;
9980
- let t = this._getParticipants();
9996
+ let t = this._participants;
9981
9997
  if (t[e]?.externalId) return t[e].externalId;
9982
9998
  {
9983
9999
  let t = this._getParticipantId(e);
@@ -9998,7 +10014,7 @@ var es = 15, $ = class e extends b {
9998
10014
  let n = this._registerParticipantInCache(this._getExistedParticipantByIdOrCreate(e));
9999
10015
  return n.markers = this._denormalizeMarkers(n.id, t), n;
10000
10016
  }
10001
- return this._getParticipants()[e];
10017
+ return this._participants[e];
10002
10018
  }
10003
10019
  _warnParticipantNotInConversation(e) {
10004
10020
  this._debug.warn(`Participant [${e}] isn't in conversation`);
@@ -10041,15 +10057,15 @@ var es = 15, $ = class e extends b {
10041
10057
  }
10042
10058
  _allocateTransport() {
10043
10059
  if (!this._conversation || !this._mediaSource) return;
10044
- this._transport = new ra(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator, this._getFirstMediaSentCallback()), this._debugInfo = new po(this._debug), this.subscribe(this._transport, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, X.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, X.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, X.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, X.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, X.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, X.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, X.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, X.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, X.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, X.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
10045
- let e = this._conversation.direction === Pa.OUTGOING && !this._conversation.concurrent, t = this._getParticipants();
10060
+ this._transport = new ra(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator, this._getFirstMediaSentCallback()), this._debugInfo = new ho(this._debug), this.subscribe(this._transport, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, X.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, X.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, X.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, X.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, X.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, X.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, X.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, X.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, X.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, X.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
10061
+ let e = this._conversation.direction === Pa.OUTGOING && !this._conversation.concurrent, t = this._participants;
10046
10062
  for (let n of Object.values(t)) (n.state === Z.ACCEPTED || n.state === Z.CALLED) && this._allocateParticipantTransport(n.id, e);
10047
10063
  }
10048
10064
  _createSpeakerDetector() {
10049
- this._transport && this._conversation && (this._volumesDetector = new bo(this._transport), this.subscribe(this._volumesDetector, yo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new So(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, xo.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new _o(this._mediaSource));
10065
+ this._transport && this._conversation && (this._volumesDetector = new So(this._transport), this.subscribe(this._volumesDetector, xo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new wo(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, Co.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new yo(this._mediaSource));
10050
10066
  }
10051
10067
  _createSpecListener() {
10052
- this._transport && this._volumesDetector && (this._specListener = new To(this._transport, this._volumesDetector, this._getParticipants(), this._debug, this._stats.logger));
10068
+ this._transport && this._volumesDetector && (this._specListener = new Do(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
10053
10069
  }
10054
10070
  _logDevices() {
10055
10071
  let e = E.getCameras().length, t = E.getMicrophones().length;
@@ -10061,7 +10077,7 @@ var es = 15, $ = class e extends b {
10061
10077
  async _removeParticipant(e, t) {
10062
10078
  if (e.state === Z.CALLED || e.state === Z.ACCEPTED || this._state === "CLOSE") return;
10063
10079
  e.id === this._lastSignalledActiveSpeakerId && (this._lastSignalledActiveSpeakerId = null);
10064
- let n = this._getParticipants();
10080
+ let n = this._participants;
10065
10081
  if (n[e.id]) {
10066
10082
  t === O.HUNGUP ? this._setParticipantsStatus([e], P.HANGUP) : this._setParticipantsStatus([e], P.ERROR, t), e.mediaSource?.disconnect(), this._displayLayoutRequester.cleanupParticipant(e.id), this._conversation && this._conversation.pinnedParticipantIdByRoom.get(null) === e.id && this._conversation.pinnedParticipantIdByRoom.delete(null), this._conversation && this._conversation.roomId && this._conversation.pinnedParticipantIdByRoom.get(this._conversation.roomId) === e.id && this._conversation.pinnedParticipantIdByRoom.delete(this._conversation.roomId);
10067
10083
  for (let [t, n] of Object.entries(e.lastRequestedLayouts)) this._streamIdByStreamDescription.delete(t), this._sequenceNumberByStreamDescription.delete(t), this._cooldownTimestampByStreamDescription.delete(t), this._streamWaitTimerByStreamDescription.has(t) && (window.clearTimeout(this._streamWaitTimerByStreamDescription.get(t)), this._streamWaitTimerByStreamDescription.delete(t)), this._sendUpdateDisplayLayout({ [t]: { stopStream: !0 } }, !1);
@@ -10075,7 +10091,7 @@ var es = 15, $ = class e extends b {
10075
10091
  this._mediaSource && (this._mediaSource.destroy(), this._mediaSource = null);
10076
10092
  }
10077
10093
  _cleanupParticipants() {
10078
- Object.values(this._getParticipants()).forEach((e) => {
10094
+ Object.values(this._participants).forEach((e) => {
10079
10095
  e.remoteStream?.getTracks().forEach((e) => e.stop()), e.remoteAudioTrack?.stop(), e.secondStream?.getTracks().forEach((e) => e.stop()), e.mediaSource?.disconnect();
10080
10096
  }), this._participants = {}, this._audioOutput && this._audioOutput.destroy();
10081
10097
  }
@@ -10110,8 +10126,14 @@ var es = 15, $ = class e extends b {
10110
10126
  _cleanupSpecListener() {
10111
10127
  this._specListener && (this._specListener.destroy(), this._specListener = null);
10112
10128
  }
10113
- _disposeSignaling() {
10114
- this._signaling.dispose();
10129
+ _disposeSignaling(e) {
10130
+ if (!e) {
10131
+ this._signaling.dispose();
10132
+ return;
10133
+ }
10134
+ e.catch((e) => {
10135
+ e instanceof yn || this._debug.warn("[signaling] unable to send hangup", e);
10136
+ }).finally(() => this._signaling.dispose());
10115
10137
  }
10116
10138
  async _onAddParticipant(e, t, n) {
10117
10139
  this._debug.debug(`Add new participant [${e}]`);
@@ -10141,8 +10163,8 @@ var es = 15, $ = class e extends b {
10141
10163
  }
10142
10164
  _onRemoveParticipant(e) {
10143
10165
  this._debug.debug(`Remove participant [${e}]`);
10144
- let t = [], n = this._getParticipants();
10145
- for (let r = 0; r <= es; r++) {
10166
+ let t = [], n = this._participants;
10167
+ for (let r = 0; r <= ns; r++) {
10146
10168
  let i = n[M.compose(e, r)];
10147
10169
  i && t.push(i);
10148
10170
  }
@@ -10207,7 +10229,7 @@ var es = 15, $ = class e extends b {
10207
10229
  let e = typeof t.uid == "object" ? t.uid : Q.fromId(t.uid), r = Q.toString(e);
10208
10230
  n[r] = t.priority;
10209
10231
  }
10210
- let r = this._getParticipants();
10232
+ let r = this._participants;
10211
10233
  for (let e of Object.values(r)) {
10212
10234
  let r = Q.toString(e.externalId);
10213
10235
  Object.hasOwn(n, r) && (t[e.id] = n[r]);
@@ -10229,15 +10251,15 @@ var es = 15, $ = class e extends b {
10229
10251
  return;
10230
10252
  }
10231
10253
  if (this._isWaitingForPromotion()) {
10232
- this._waitingHallHoldPending = !1, this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus());
10254
+ this._waitingHallHoldPending = !1, await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus()), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener();
10233
10255
  return;
10234
10256
  }
10235
10257
  let n = pa.get();
10236
10258
  await this._signaling.hold(!1, n), this._restoreStateAfterHold();
10237
10259
  let r = null;
10238
- if (this._state === "IDLE" && this._participantState === Z.ACCEPTED && (r = Object.values(this._getParticipants()), r.some((e) => e.state === Z.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), await this._resumeLocalMedia(t, P.WAITING), this._state === "ACTIVE") {
10260
+ if (this._state === "IDLE" && this._participantState === Z.ACCEPTED && (r = Object.values(this._participants), r.some((e) => e.state === Z.ACCEPTED) && (this._state = "ACTIVE", this._changeFeatureSet())), await this._resumeLocalMedia(t, P.WAITING), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._state === "ACTIVE") {
10239
10261
  let e = this._conversation?.direction === Pa.OUTGOING && !this._conversation.concurrent;
10240
- this._openTransport(r ?? Object.values(this._getParticipants()), e);
10262
+ this._openTransport(r ?? Object.values(this._participants), e);
10241
10263
  }
10242
10264
  }
10243
10265
  async _holdLocally() {
@@ -10270,7 +10292,7 @@ var es = 15, $ = class e extends b {
10270
10292
  async updateDisplayLayout(e) {
10271
10293
  if (e.length < 1 || !this._signaling.ready) return;
10272
10294
  this._debug.log(`Update display layout request [${this._signaling.getNextCommandSequenceNumber()}]`, e);
10273
- let t = {}, n = [], r = this._getParticipants();
10295
+ let t = {}, n = [], r = this._participants;
10274
10296
  for (let i of e) {
10275
10297
  let e = typeof i.uid == "object" ? i.uid : Q.fromId(i.uid), a = this._api.getCachedOkIdByExternalId(e);
10276
10298
  if (!a) {
@@ -10314,7 +10336,7 @@ var es = 15, $ = class e extends b {
10314
10336
  }
10315
10337
  _stopStreaming(e) {
10316
10338
  if (this._cooldownTimestampByStreamDescription.delete(e), this._sequenceNumberByStreamDescription.set(e, this._signaling.getNextCommandSequenceNumber()), this._streamWaitTimerByStreamDescription.has(e) && (this._debug.log("Client asked to stop streaming before stream became available", e), window.clearTimeout(this._streamWaitTimerByStreamDescription.get(e)), this._streamWaitTimerByStreamDescription.delete(e)), this._streamIdByStreamDescription.get(e)) {
10317
- let t = this._getParticipants(), n = Dn(e), r = t[n.participantId], i = this._conversation?.externalId, a = this._isMe(n.participantId);
10339
+ let t = this._participants, n = Dn(e), r = t[n.participantId], i = this._conversation?.externalId, a = this._isMe(n.participantId);
10318
10340
  if (r || a) {
10319
10341
  switch (n.mediaType) {
10320
10342
  case H.STREAM:
@@ -10350,7 +10372,7 @@ var es = 15, $ = class e extends b {
10350
10372
  if (this._debug.warn(`Failed to update display layout ${JSON.stringify(e)}. ${n}`), t) throw n;
10351
10373
  return;
10352
10374
  }
10353
- let r = [], i = this._getParticipants();
10375
+ let r = [], i = this._participants;
10354
10376
  for (let [e, t] of Object.entries(n.errorCodeByParticipantId || {})) {
10355
10377
  let n = Dn(e), a = i[n.participantId];
10356
10378
  if (a) {
@@ -10361,7 +10383,7 @@ var es = 15, $ = class e extends b {
10361
10383
  });
10362
10384
  }
10363
10385
  }
10364
- if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new ns("Could not allocate one or more participants", r);
10386
+ if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new is("Could not allocate one or more participants", r);
10365
10387
  }
10366
10388
  async _cleanupCooldownQueue() {
10367
10389
  let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
@@ -10369,7 +10391,7 @@ var es = 15, $ = class e extends b {
10369
10391
  let n = t.next();
10370
10392
  if (n.done) break;
10371
10393
  let r = n.value;
10372
- if (r[1] + Qo > Date.now()) break;
10394
+ if (r[1] + es > Date.now()) break;
10373
10395
  let i = r[0];
10374
10396
  await this._stopStreaming(i), e[i] = { stopStream: !0 };
10375
10397
  } while (!0);
@@ -10461,7 +10483,7 @@ var es = 15, $ = class e extends b {
10461
10483
  else {
10462
10484
  let e = this._getExternalIdByParticipantId(n);
10463
10485
  if (e) {
10464
- let t = this._getParticipants()[n];
10486
+ let t = this._participants[n];
10465
10487
  t?.movieShareInfos && (t.movieShareInfos = t.movieShareInfos.filter((e) => e && e.movieId !== r)), R.onRemoteSharedMovieStoppedInfo(e, o, a, this.id);
10466
10488
  }
10467
10489
  }
@@ -10821,7 +10843,7 @@ var es = 15, $ = class e extends b {
10821
10843
  this._debug.log("Request participant list chunk", e);
10822
10844
  let t = await this._signaling.getParticipantListChunk(e);
10823
10845
  if (t.error) throw Error(t.error);
10824
- let n = this._createParticipantListChunk(t.chunk), r = this._getParticipants(), i = n.participants.filter((e) => !r[M.composeId(e)]);
10846
+ let n = this._createParticipantListChunk(t.chunk), r = this._participants, i = n.participants.filter((e) => !r[M.composeId(e)]);
10825
10847
  await this._registerParticipants(i);
10826
10848
  let a = this._transport?.getState();
10827
10849
  return n.participants.forEach((e) => {
@@ -10840,7 +10862,7 @@ var es = 15, $ = class e extends b {
10840
10862
  _onLocalMediaStreamChanged(e) {
10841
10863
  if (!this._conversation || !this._mediaSource) return;
10842
10864
  let t = this._mediaSource.mediaSettings;
10843
- this._debug.debug("Local media stream changed", t), e.kind === A.audio && this._mediaSource && (this._audioFix = new ao(this._mediaSource, this._debug, this._stats.logger)), R.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
10865
+ this._debug.debug("Local media stream changed", t), e.kind === A.audio && this._mediaSource && (this._audioFix = new so(this._mediaSource, this._debug, this._stats.logger)), R.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
10844
10866
  }
10845
10867
  _onScreenSharingStatus(e) {
10846
10868
  let t = this.mediaSettings;
@@ -10880,7 +10902,7 @@ var es = 15, $ = class e extends b {
10880
10902
  }
10881
10903
  _changeMultipleParticipantState(e, t) {
10882
10904
  this._debug.debug("Multiple participants state changed", e);
10883
- let n = [], r, i = this._getParticipants();
10905
+ let n = [], r, i = this._participants;
10884
10906
  e.forEach((e, t) => {
10885
10907
  if (this._isMe(t)) r = e;
10886
10908
  else {
@@ -10966,7 +10988,7 @@ var es = 15, $ = class e extends b {
10966
10988
  e.conversationParams?.serverTime && (this._serverTimeOffset = e.conversationParams.serverTime - Date.now()), e.conversation.acceptTime && (this._conversation.acceptTime = e.conversation.acceptTime), e.conversation.participantsLimit && (this._conversation.participantsLimit = e.conversation.participantsLimit), e.conversation.features && (this._conversation.features = e.conversation.features, this._conversation.featuresPerRole = e.conversation.featuresPerRole, this._changeFeatureSet(), this._changeFeaturesPerRole()), this._processPinnedParticipants(e), e.conversation.state;
10967
10989
  let t = null;
10968
10990
  if (e.conversation.participants) {
10969
- let n = Object.keys(this._getParticipants()), r = [];
10991
+ let n = Object.keys(this._participants), r = [];
10970
10992
  for (let n of e.conversation.participants) {
10971
10993
  let e = M.composeId(n), i = n.roles || [];
10972
10994
  if (this._isMe(e)) {
@@ -10993,7 +11015,7 @@ var es = 15, $ = class e extends b {
10993
11015
  M.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), Ka(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? P.ONHOLD : P.CONNECTED));
10994
11016
  }
10995
11017
  }
10996
- let i = this._getParticipants();
11018
+ let i = this._participants;
10997
11019
  for (let e of n) r.indexOf(e) < 0 && i[e] && this._removeParticipant(i[e], O.HUNGUP);
10998
11020
  }
10999
11021
  let n = [...e.participants?.participants ?? [], ...e.rooms?.rooms.flatMap((e) => e.participants?.participants ?? []) ?? []];
@@ -11020,8 +11042,12 @@ var es = 15, $ = class e extends b {
11020
11042
  let n = this._api.getDecorativeIdByInitialId(t), i = n ? M.composeUserId(n, e.participantType) : void 0;
11021
11043
  r = this._registerParticipantInCache(this._createParticipant({
11022
11044
  id: t,
11045
+ externalId: e.externalId ? Q.fromSignaling(e.externalId, e.deviceIdx) : void 0,
11023
11046
  mediaSettings: D(e.mediaSettings)
11024
11047
  }, i));
11048
+ } else if (e.externalId) {
11049
+ let t = Q.fromSignaling(e.externalId, e.deviceIdx);
11050
+ r.externalId = t, this._api.cacheExternalId(r.id, t);
11025
11051
  }
11026
11052
  r.state = Z.ACCEPTED, r.mediaSettings = D(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === Pa.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
11027
11053
  let i = Object.keys(r.muteStates);
@@ -11073,7 +11099,7 @@ var es = 15, $ = class e extends b {
11073
11099
  }
11074
11100
  async _reconcileParticipantSessionStates(e) {
11075
11101
  if (!N.enableSessionStateUpdates || !e.length) return;
11076
- let t = this._getParticipants();
11102
+ let t = this._participants;
11077
11103
  for (let n of e) {
11078
11104
  let e = M.composeId(n), r = t[e];
11079
11105
  r && !this._isMe(e) && (this._updateParticipantExternalId(r, n), this._updateParticipantSessionState(r, e, n.sessionState));
@@ -11188,7 +11214,7 @@ var es = 15, $ = class e extends b {
11188
11214
  this._conversation && (this._conversation.chatId = e.chatId, this._toggleJoinAvailability(), R.onMultipartyChatCreated(this._conversation));
11189
11215
  }
11190
11216
  async _onForceMediaSettingsChange(e) {
11191
- if (!this._mediaSource) return;
11217
+ if (!this._mediaSource || this._state === "HELD") return;
11192
11218
  let t = this._mediaSource.mediaSettings, n = D(e.mediaSettings);
11193
11219
  t.isAudioEnabled !== n.isAudioEnabled && await this._mediaSource.toggleAudio(n.isAudioEnabled), t.isVideoEnabled !== n.isVideoEnabled && await this._mediaSource.toggleVideo(n.isVideoEnabled), t.isScreenSharingEnabled !== n.isScreenSharingEnabled && await this._mediaSource.toggleScreenCapturing({
11194
11220
  captureScreen: n.isScreenSharingEnabled,
@@ -11224,7 +11250,7 @@ var es = 15, $ = class e extends b {
11224
11250
  async _onPeerRegistered(e) {
11225
11251
  this._registeredPeerReceived = !0, this._clearCalleeUnavailableWatchdog();
11226
11252
  let t = M.composeMessageId(e), n = this._getParticipant(t);
11227
- n && (n.clientType = e.clientType, n.platform = e.platform), R.onPeerRegistered(this.id, [n.externalId]);
11253
+ n && (n.clientType = e.clientType, n.platform = e.platform, R.onPeerRegistered(this.id, [n.externalId]));
11228
11254
  }
11229
11255
  async _onMicSwitched(e) {
11230
11256
  R.onDeviceSwitched(S.AUDIO, !e.mute, this.id), await this.toggleLocalAudio(!e.mute);
@@ -11432,7 +11458,7 @@ var es = 15, $ = class e extends b {
11432
11458
  }
11433
11459
  async _onNetworkStatus(e) {
11434
11460
  if (this._conversation) {
11435
- let t = [], n = this._getParticipants();
11461
+ let t = [], n = this._participants;
11436
11462
  for (let [r, i] of Object.entries(e)) {
11437
11463
  let e;
11438
11464
  if (this._isMe(r) || r === "") e = this._conversation.networkRating;
@@ -11452,7 +11478,7 @@ var es = 15, $ = class e extends b {
11452
11478
  }
11453
11479
  }
11454
11480
  async _emitHeldParticipantsStatus() {
11455
- let e = Object.values(this._getParticipants()).filter((e) => e.isOnHold).map((e) => e.externalId);
11481
+ let e = Object.values(this._participants).filter((e) => e.isOnHold).map((e) => e.externalId);
11456
11482
  e.length && R.onRemoteStatus(e, P.ONHOLD, null, this.id);
11457
11483
  }
11458
11484
  async _onRemoteStreamSecond(e, t) {
@@ -11529,7 +11555,7 @@ var es = 15, $ = class e extends b {
11529
11555
  this._debug.debug(`Transport state has changed: ${t}`, e);
11530
11556
  let n = Ja.fromTransportState(t);
11531
11557
  if (!n) return;
11532
- let r = this._getParticipants(), i = [], a = e.reduce((e, n) => {
11558
+ let r = this._participants, i = [], a = e.reduce((e, n) => {
11533
11559
  if (n in r) {
11534
11560
  let a = r[n];
11535
11561
  e.push(a), t === J.CONNECTED && (a.remoteStream || (a.mediaSettings && this._changeRemoteMediaSettings(n, a.mediaSettings), this._changeRemoteParticipantState(n, a.participantState)), i.push(...Object.values(a.lastRequestedLayouts)));
@@ -11557,7 +11583,7 @@ var es = 15, $ = class e extends b {
11557
11583
  if (!N.hold || !this._transport) return !1;
11558
11584
  let e = this._transport.opened().length ? this._transport.opened() : this._transport.allocated();
11559
11585
  if (!e.length) return !1;
11560
- let t = this._getParticipants();
11586
+ let t = this._participants;
11561
11587
  return e.every((e) => t[e]?.isOnHold);
11562
11588
  }
11563
11589
  _onRemoteTrackAdded(e, t, n) {
@@ -11618,7 +11644,7 @@ var es = 15, $ = class e extends b {
11618
11644
  _onRemoteSignalledStall(e) {
11619
11645
  let t = {}, n = [], r = [];
11620
11646
  this._debug.debug("Participants stalled:", e);
11621
- let i = this._getParticipants();
11647
+ let i = this._participants;
11622
11648
  for (let r of e) {
11623
11649
  if (t[r] = !0, !this._lastStalled[r]) {
11624
11650
  let e = i[r];
@@ -11633,7 +11659,7 @@ var es = 15, $ = class e extends b {
11633
11659
  n.length && this._setParticipantsStatus(n, P.RECONNECT), r.length && this._setParticipantsStatus(r, P.CONNECTED), this._lastStalled = t;
11634
11660
  }
11635
11661
  _onRemoteDataStats(e) {
11636
- this._debugInfo && this._debugInfo.onRemoteDataStats(e, this._getParticipants()), this._fixAudioDevice(e.outbound.rtps), this._fixVideoDevice(e.outbound.rtps);
11662
+ this._debugInfo && this._debugInfo.onRemoteDataStats(e, this._participants), this._fixAudioDevice(e.outbound.rtps), this._fixVideoDevice(e.outbound.rtps);
11637
11663
  }
11638
11664
  _fixAudioDevice(e) {
11639
11665
  !E.hasMicrophone() || !this._audioFix || !this.mediaSettings?.isAudioEnabled || this._audioFix.fix(e);
@@ -11778,7 +11804,7 @@ var es = 15, $ = class e extends b {
11778
11804
  for (let t of n) {
11779
11805
  let n = t.id ?? null;
11780
11806
  if (this._setMuteStatesForRoomId(t.muteStates, n), this._conversation?.recordsInfoByRoom.set(n, t.recordInfo ?? null), this._conversation?.pinnedParticipantIdByRoom.set(n, t.pinnedParticipantId ?? null), t.asrInfo && this._conversation?.asrInfoByRoom.set(n, t.asrInfo), t.urlSharingInfo ? this._conversation?.urlSharingInfoByRoom.set(n, t.urlSharingInfo) : this._conversation?.urlSharingInfoByRoom.delete(n), e) {
11781
- let e = this._getParticipants();
11807
+ let e = this._participants;
11782
11808
  await this._registerParticipants(t?.participants?.participants?.filter((t) => !e[M.composeId(t)]) || [], !0);
11783
11809
  let n = this._convertRoomToExternal(t);
11784
11810
  n && r.push(n);
@@ -11816,7 +11842,7 @@ var es = 15, $ = class e extends b {
11816
11842
  let o = Q.fromSignaling(r, a.deviceIdx);
11817
11843
  if (R.onParticipantIdChanged(a, o, this.id), this._api.cacheExternalId(n, o), this._api.mapDecorativeId(n, t), i) this._conversation.externalId = o;
11818
11844
  else {
11819
- let e = this._getParticipants();
11845
+ let e = this._participants;
11820
11846
  e[t].externalId = o;
11821
11847
  }
11822
11848
  }
@@ -11853,31 +11879,24 @@ var es = 15, $ = class e extends b {
11853
11879
  }
11854
11880
  _registerParticipant(e, t) {
11855
11881
  let n = this._createParticipant(e, t);
11856
- this._pendingParticipants.set(e.id, n);
11857
- }
11858
- _getParticipants() {
11859
- if (this._pendingParticipants.size) {
11860
- for (let e of this._pendingParticipants.values()) this._participants[e.id] = e;
11861
- this._pendingParticipants.clear();
11862
- }
11863
- return this._participants;
11882
+ this._registerParticipantInCache(n);
11864
11883
  }
11865
11884
  _getParticipant(e) {
11866
- return this._getParticipants()[e];
11885
+ return this._participants[e];
11867
11886
  }
11868
- }, ts = null, ns = class e extends Error {
11887
+ }, rs = null, is = class e extends Error {
11869
11888
  constructor(t, n) {
11870
11889
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
11871
11890
  }
11872
- }, rs = null, is = null;
11873
- function as() {
11874
- rs = null, is = null;
11891
+ }, as = null, os = null;
11892
+ function ss() {
11893
+ as = null, os = null;
11875
11894
  }
11876
- function os(e) {
11895
+ function cs(e) {
11877
11896
  return e?.endsWith("/") ? e.slice(0, -1) : e;
11878
11897
  }
11879
- async function ss(e = null, t) {
11880
- let n = os(e ?? N.apiBaseUrl);
11898
+ async function ls(e = null, t) {
11899
+ let n = cs(e ?? N.apiBaseUrl);
11881
11900
  if (n) return n;
11882
11901
  if ((t ?? N.apiEnv) !== "AUTO") return N.apiEndpoint(t);
11883
11902
  try {
@@ -11892,20 +11911,20 @@ async function ss(e = null, t) {
11892
11911
  return z.warn("Failed to resolve API endpoint using DNS, default is used", e), N.apiEndpoint(t);
11893
11912
  }
11894
11913
  }
11895
- async function cs() {
11896
- return rs || is || (is = ss(), rs = await is, is = null, rs);
11914
+ async function us() {
11915
+ return as || os || (os = ls(), as = await os, os = null, as);
11897
11916
  }
11898
- async function ls(e, t = {}, n = !1) {
11917
+ async function ds(e, t = {}, n = !1) {
11899
11918
  if (!window.Blob || !window.navigator.sendBeacon) return;
11900
- await cs();
11901
- let r = ms(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
11902
- window.navigator.sendBeacon(`${rs}/fb.do`, i);
11919
+ await us();
11920
+ let r = gs(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
11921
+ window.navigator.sendBeacon(`${as}/fb.do`, i);
11903
11922
  }
11904
- async function us(e, t = {}, n = !1, r) {
11905
- return await cs(), ds(ms(e, t, n), r);
11923
+ async function fs(e, t = {}, n = !1, r) {
11924
+ return await us(), ps(gs(e, t, n), r);
11906
11925
  }
11907
- async function ds(e, t) {
11908
- let n = `${t ?? rs}/fb.do`, r = new AbortController(), i = new k(x.NETWORK, { callError: {
11926
+ async function ps(e, t) {
11927
+ let n = `${t ?? as}/fb.do`, r = new AbortController(), i = new k(x.NETWORK, { callError: {
11909
11928
  scope: "network",
11910
11929
  source: "api",
11911
11930
  code: "timeout",
@@ -11923,16 +11942,16 @@ async function ds(e, t) {
11923
11942
  } catch {
11924
11943
  a = { result: i };
11925
11944
  }
11926
- if (!t.ok && !fs(a)) throw new k(x.API, { callError: {
11945
+ if (!t.ok && !ms(a)) throw new k(x.API, { callError: {
11927
11946
  scope: "server",
11928
11947
  source: "api",
11929
11948
  code: `http-${t.status}`,
11930
11949
  description: "http-error"
11931
11950
  } });
11932
- if (fs(a)) throw a;
11951
+ if (ms(a)) throw a;
11933
11952
  return a;
11934
11953
  } catch (e) {
11935
- throw e instanceof k ? e : r.signal.aborted ? i : fs(e) ? e : new k(x.NETWORK, { callError: {
11954
+ throw e instanceof k ? e : r.signal.aborted ? i : ms(e) ? e : new k(x.NETWORK, { callError: {
11936
11955
  scope: "network",
11937
11956
  source: "api",
11938
11957
  code: "fetch-failed",
@@ -11942,12 +11961,12 @@ async function ds(e, t) {
11942
11961
  clearTimeout(a);
11943
11962
  }
11944
11963
  }
11945
- function fs(e) {
11964
+ function ms(e) {
11946
11965
  if (typeof e != "object" || !e) return !1;
11947
11966
  let t = e;
11948
11967
  return typeof t.error_code == "number" && typeof t.error_msg == "string";
11949
11968
  }
11950
- async function ps(e, t) {
11969
+ async function hs(e, t) {
11951
11970
  try {
11952
11971
  let n = await fetch(e, {
11953
11972
  method: "POST",
@@ -11960,7 +11979,7 @@ async function ps(e, t) {
11960
11979
  throw z.warn("Failed to send form data", e), e;
11961
11980
  }
11962
11981
  }
11963
- function ms(e, t = {}, n = !1) {
11982
+ function gs(e, t = {}, n = !1) {
11964
11983
  t.method = e, t.format = "JSON", t.application_key || (t.application_key = N.apiKey), n || (y.sessionKey ? t.session_key = y.sessionKey : y.accessToken && (t.access_token = y.accessToken));
11965
11984
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
11966
11985
  let r = "";
@@ -11969,7 +11988,7 @@ function ms(e, t = {}, n = !1) {
11969
11988
  }
11970
11989
  //#endregion
11971
11990
  //#region src/abstract/BaseApi.ts
11972
- var hs = class {
11991
+ var _s = class {
11973
11992
  constructor() {
11974
11993
  h(this, "_abortSignal", void 0);
11975
11994
  }
@@ -12012,7 +12031,7 @@ var hs = class {
12012
12031
  async getInbounds() {
12013
12032
  return [];
12014
12033
  }
12015
- }, gs = class e {
12034
+ }, vs = class e {
12016
12035
  constructor() {
12017
12036
  h(this, "_okIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToOkId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12018
12037
  }
@@ -12063,27 +12082,27 @@ var hs = class {
12063
12082
  clear() {
12064
12083
  this._okIdToExternalId.clear(), this._externalIdToOkId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12065
12084
  }
12066
- }, _s = "anonymLogin:", vs = 700, ys = 3e3;
12067
- function bs(e) {
12085
+ }, ys = "anonymLogin:", bs = 700, xs = 3e3;
12086
+ function Ss(e) {
12068
12087
  let t = e.error_code;
12069
12088
  switch (t) {
12070
- case 2: return xs(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
12071
- case 4: return e.error_msg.includes("participants.limit.exceeded") ? xs(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : xs(x.API, t, "request-error");
12072
- case 300: return xs(O.NOT_FOUND, t, "not-found");
12073
- case 1101: return xs(O.SERVICE_DISABLED, t, "vchat-service-disabled");
12074
- case 1102: return xs(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
12075
- case 1103: return xs(O.NOT_FRIENDS, t, "friendship-required");
12076
- case 1104: return Ss(t, "youla-api-error");
12077
- case 1106: return Ss(t, "vk-api-error");
12078
- case 1113: return xs(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
12089
+ case 2: return Cs(O.SERVICE_UNAVAILABLE, t, "service-unavailable");
12090
+ case 4: return e.error_msg.includes("participants.limit.exceeded") ? Cs(O.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Cs(x.API, t, "request-error");
12091
+ case 300: return Cs(O.NOT_FOUND, t, "not-found");
12092
+ case 1101: return Cs(O.SERVICE_DISABLED, t, "vchat-service-disabled");
12093
+ case 1102: return Cs(O.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
12094
+ case 1103: return Cs(O.NOT_FRIENDS, t, "friendship-required");
12095
+ case 1104: return ws(t, "youla-api-error");
12096
+ case 1106: return ws(t, "vk-api-error");
12097
+ case 1113: return Cs(O.CALLER_IS_REJECTED, t, "caller-is-rejected");
12079
12098
  case 1114: {
12080
12099
  let n = e.custom_error?.vchat_detailed_api_error?.code, r = n?.startsWith("obsolete_client");
12081
- return xs(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
12100
+ return Cs(r ? O.OBSOLETE_CLIENT : O.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
12082
12101
  }
12083
- default: return xs(x.API, t, "api-error");
12102
+ default: return Cs(x.API, t, "api-error");
12084
12103
  }
12085
12104
  }
12086
- function xs(e, t, n, r) {
12105
+ function Cs(e, t, n, r) {
12087
12106
  return {
12088
12107
  type: e,
12089
12108
  callError: {
@@ -12095,7 +12114,7 @@ function xs(e, t, n, r) {
12095
12114
  message: r
12096
12115
  };
12097
12116
  }
12098
- function Ss(e, t) {
12117
+ function ws(e, t) {
12099
12118
  return {
12100
12119
  type: O.EXTERNAL_API_ERROR,
12101
12120
  callError: {
@@ -12106,19 +12125,19 @@ function Ss(e, t) {
12106
12125
  }
12107
12126
  };
12108
12127
  }
12109
- var Cs = class extends hs {
12128
+ var Ts = class extends _s {
12110
12129
  constructor(...e) {
12111
- super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new gs());
12130
+ super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new vs());
12112
12131
  }
12113
12132
  async _callUnsafe(e, t = {}, n = !1) {
12114
12133
  let r = async (i) => {
12115
12134
  try {
12116
- return await us(e, t, n);
12135
+ return await fs(e, t, n);
12117
12136
  } catch (t) {
12118
12137
  if (!t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
12119
12138
  i++;
12120
12139
  let n = t && (typeof t == "object" || typeof t == "function") ? Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`) : [String(t)];
12121
- if (z.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (z.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < N.apiMaxAttempt) return await M.delay(Math.min(i * vs, ys), { signal: this._abortSignal }), r(i);
12140
+ if (z.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (z.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < N.apiMaxAttempt) return await M.delay(Math.min(i * bs, xs), { signal: this._abortSignal }), r(i);
12122
12141
  }
12123
12142
  throw z.warn(e, "error", t), t;
12124
12143
  }
@@ -12141,8 +12160,8 @@ var Cs = class extends hs {
12141
12160
  message: i?.error_msg,
12142
12161
  code: i?.error_code
12143
12162
  };
12144
- if (i.custom_error && (a.custom_error = i.custom_error), ws(i)) {
12145
- let e = bs(i);
12163
+ if (i.custom_error && (a.custom_error = i.custom_error), Es(i)) {
12164
+ let e = Ss(i);
12146
12165
  throw a.callError = e.callError, a.message = e.message ?? a.message, new k(e.type, a);
12147
12166
  }
12148
12167
  throw new k(x.API, a);
@@ -12188,17 +12207,17 @@ var Cs = class extends hs {
12188
12207
  });
12189
12208
  }
12190
12209
  _getAnonymLoginCacheKey() {
12191
- return N.authToken ? `${_s}${N.authToken}` : null;
12210
+ return N.authToken ? `${ys}${N.authToken}` : null;
12192
12211
  }
12193
12212
  _getCachedAnonymLogin() {
12194
12213
  let e = this._getAnonymLoginCacheKey();
12195
12214
  if (!e) return null;
12196
12215
  let t = at.get(e);
12197
- return Ts(t) ? t : (t && at.remove(e), null);
12216
+ return Ds(t) ? t : (t && at.remove(e), null);
12198
12217
  }
12199
12218
  _setCachedAnonymLogin(e) {
12200
12219
  let t = this._getAnonymLoginCacheKey();
12201
- !t || !Ts(e) || at.set(t, {
12220
+ !t || !Ds(e) || at.set(t, {
12202
12221
  session_key: e.session_key,
12203
12222
  session_secret_key: e.session_secret_key,
12204
12223
  uid: e.uid
@@ -12219,7 +12238,7 @@ var Cs = class extends hs {
12219
12238
  version: 1,
12220
12239
  items: e
12221
12240
  };
12222
- N.clientStatsPlatform && (t.platform = N.clientStatsPlatform), ls("vchat.clientStats", { data: JSON.stringify(t) });
12241
+ N.clientStatsPlatform && (t.platform = N.clientStatsPlatform), ds("vchat.clientStats", { data: JSON.stringify(t) });
12223
12242
  }
12224
12243
  async uploadDebugLogs(e, t, n, r) {
12225
12244
  let i = {
@@ -12230,7 +12249,7 @@ var Cs = class extends hs {
12230
12249
  }, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
12231
12250
  o.append("file", s, "log.json");
12232
12251
  let c = new URL(a.upload_url);
12233
- return c.searchParams.append("size", s.size.toString()), ps(c.toString(), o);
12252
+ return c.searchParams.append("size", s.size.toString()), hs(c.toString(), o);
12234
12253
  }
12235
12254
  async joinConversation(e, t = !1, n) {
12236
12255
  let r = {
@@ -12361,7 +12380,7 @@ var Cs = class extends hs {
12361
12380
  conversationId: e,
12362
12381
  reason: t
12363
12382
  };
12364
- N.anonymToken && (n.anonymToken = N.anonymToken), ls("vchat.hangupConversation", n);
12383
+ N.anonymToken && (n.anonymToken = N.anonymToken), ds("vchat.hangupConversation", n);
12365
12384
  }
12366
12385
  async removeHistoryRecords(e) {
12367
12386
  await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
@@ -12377,19 +12396,19 @@ var Cs = class extends hs {
12377
12396
  return Array.isArray(e?.inbounds) ? e.inbounds : [];
12378
12397
  }
12379
12398
  };
12380
- function ws(e) {
12399
+ function Es(e) {
12381
12400
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
12382
12401
  }
12383
- function Ts(e) {
12402
+ function Ds(e) {
12384
12403
  return typeof e == "object" && !!e && "session_key" in e && "session_secret_key" in e && typeof e.session_key == "string" && e.session_key.length > 0 && typeof e.session_secret_key == "string" && e.session_secret_key.length > 0;
12385
12404
  }
12386
12405
  //#endregion
12387
12406
  //#region src/enums/RecordRole.ts
12388
- var Es = /* @__PURE__ */ function(e) {
12407
+ var Os = /* @__PURE__ */ function(e) {
12389
12408
  return e.KING = "KING", e.PAWN = "PAWN", e;
12390
- }(Es || {}), Ds = /* @__PURE__ */ function(e) {
12409
+ }(Os || {}), ks = /* @__PURE__ */ function(e) {
12391
12410
  return e.OFF = "0", e.ON = "1", e;
12392
- }({}), Os = class {
12411
+ }({}), As = class {
12393
12412
  constructor(e) {
12394
12413
  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;
12395
12414
  }
@@ -12412,12 +12431,12 @@ var Es = /* @__PURE__ */ function(e) {
12412
12431
  let e = this._queue[this._readCursor];
12413
12432
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
12414
12433
  }
12415
- }, ks = class {
12434
+ }, js = class {
12416
12435
  constructor(e, t, n, r = null) {
12417
12436
  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 = M.uuid(), this._apiKey = t, this._callToken = n, this._apiEnv = e, this._baseApiUrl = r;
12418
12437
  }
12419
12438
  async authorize() {
12420
- let e = await us("auth.anonymLogin", {
12439
+ let e = await fs("auth.anonymLogin", {
12421
12440
  session_data: {
12422
12441
  device_id: this._uuid,
12423
12442
  client_version: N.appVersion,
@@ -12426,18 +12445,18 @@ var Es = /* @__PURE__ */ function(e) {
12426
12445
  version: 3
12427
12446
  },
12428
12447
  application_key: this._apiKey
12429
- }, !0, await ss(this._baseApiUrl, this._apiEnv));
12448
+ }, !0, await ls(this._baseApiUrl, this._apiEnv));
12430
12449
  return M.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
12431
12450
  }
12432
12451
  async hangupConversation(e) {
12433
- await us("vchat.hangupConversation", {
12452
+ await fs("vchat.hangupConversation", {
12434
12453
  conversationId: e,
12435
12454
  reason: O.HUNGUP,
12436
12455
  application_key: this._apiKey,
12437
12456
  session_key: this._sessionKey
12438
- }, !0, await ss(this._baseApiUrl, this._apiEnv));
12457
+ }, !0, await ls(this._baseApiUrl, this._apiEnv));
12439
12458
  }
12440
- }, As, js = null, Ms = {
12459
+ }, Ms, Ns = null, Ps = {
12441
12460
  getCameras: E.getCameras,
12442
12461
  getMicrophones: E.getMicrophones,
12443
12462
  getOutput: E.getOutput,
@@ -12463,24 +12482,24 @@ var Es = /* @__PURE__ */ function(e) {
12463
12482
  baseChromeVersion: E.baseChromeVersion,
12464
12483
  getAudioContext: E.getAudioContext,
12465
12484
  isAudioShareSupported: E.isAudioShareSupported
12466
- }, Ns = { participantMarkerCompare: M.participantMarkerCompare };
12467
- function Ps(e) {
12468
- js = e;
12485
+ }, Fs = { participantMarkerCompare: M.participantMarkerCompare };
12486
+ function Is(e) {
12487
+ Ns = e;
12469
12488
  }
12470
- function Fs(e) {
12489
+ function Ls(e) {
12471
12490
  N.videoEffects = e;
12472
12491
  }
12473
- function Is(e) {
12492
+ function Rs(e) {
12474
12493
  N.audioEffects = e;
12475
12494
  }
12476
- function Ls(e, t = null, n = {}, r = 1) {
12495
+ function zs(e, t = null, n = {}, r = 1) {
12477
12496
  N.vmoji = e, N.vmojiOptions = {
12478
12497
  protocolVersion: r,
12479
12498
  renderingOptions: n
12480
12499
  }, t && e.setSDK(t);
12481
12500
  }
12482
- async function Rs(t) {
12483
- N.set(t), As || (As = new Cs()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
12501
+ async function Bs(t) {
12502
+ N.set(t), Ms || (Ms = new Ts()), e.disableLog(!N.debug), z.toggle(N.debug), z.log(`Calls SDK ${N.sdkVersion}`, t), await E.init();
12484
12503
  let n = E.getBrowserSupportFailure();
12485
12504
  if (n) throw new k(x.UNSUPPORTED, { callError: {
12486
12505
  scope: "internal",
@@ -12489,13 +12508,13 @@ async function Rs(t) {
12489
12508
  } });
12490
12509
  z.log("UserAgent:", navigator.userAgent), z.log("Screen resolution:", `${window.screen.width}x${window.screen.height}`), z.log("Permissions:", `Camera: ${E.hasCameraPermission()}, Mic: ${E.hasMicrophonePermission()}`), z.log("Simulcast:", `${t.simulcast} => ${N.simulcast}`);
12491
12510
  }
12492
- async function zs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12511
+ async function Vs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12493
12512
  let c = [];
12494
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Bs([], Fa.USER, t, n, r, i, a, c, o, s);
12513
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), Hs([], Fa.USER, t, n, r, i, a, c, o, s);
12495
12514
  }
12496
- async function Bs(e, t = Fa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12515
+ async function Hs(e, t = Fa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12497
12516
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
12498
- return new $(new Cs(), js).onStart({
12517
+ return new $(new Ts(), Ns).onStart({
12499
12518
  opponentIds: e,
12500
12519
  opponentType: t,
12501
12520
  mediaOptions: n,
@@ -12508,40 +12527,40 @@ async function Bs(e, t = Fa.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12508
12527
  conversationId: l
12509
12528
  });
12510
12529
  }
12511
- async function Vs(e, t) {
12512
- return Hs(e, j.USER, void 0, t);
12530
+ async function Us(e, t) {
12531
+ return Ws(e, j.USER, void 0, t);
12513
12532
  }
12514
- async function Hs(e, t = j.USER, n, r, i, a) {
12533
+ async function Ws(e, t = j.USER, n, r, i, a) {
12515
12534
  if (e === $.id()) throw Error("Push has already been processed");
12516
- return new $(new Cs(), js).onPush(e, t, n, r, i, a);
12535
+ return new $(new Ts(), Ns).onPush(e, t, n, r, i, a);
12517
12536
  }
12518
- async function Us() {
12519
- return As.getInbounds();
12537
+ async function Gs() {
12538
+ return Ms.getInbounds();
12520
12539
  }
12521
- async function Ws(e, t) {
12522
- return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, as()), As.authorize();
12540
+ async function Ks(e, t) {
12541
+ return e && (N.authToken = e), t !== void 0 && N.apiBaseUrl !== t && (N.apiBaseUrl = t, ss()), Ms.authorize();
12523
12542
  }
12524
- async function Gs(e = [S.AUDIO], t) {
12525
- return ml(t).accept(e);
12543
+ async function qs(e = [S.AUDIO], t) {
12544
+ return gl(t).accept(e);
12526
12545
  }
12527
- async function Ks(e) {
12528
- let t = pl(e);
12529
- if (t) return t.decline();
12546
+ async function Js(e, t) {
12547
+ let n = hl(e);
12548
+ if (n) return n.decline(t?.reason);
12530
12549
  }
12531
- async function qs(e, t = [S.AUDIO]) {
12532
- return Js(e, t);
12550
+ async function Ys(e, t = [S.AUDIO]) {
12551
+ return Xs(e, t);
12533
12552
  }
12534
- async function Js(e, t, n) {
12553
+ async function Xs(e, t, n) {
12535
12554
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
12536
- return new $(new Cs(), js).onJoin({
12555
+ return new $(new Ts(), Ns).onJoin({
12537
12556
  conversationId: e,
12538
12557
  mediaOptions: t,
12539
12558
  chatId: n
12540
12559
  });
12541
12560
  }
12542
- async function Ys(e, t = [S.AUDIO], n, r, i, a) {
12561
+ async function Zs(e, t = [S.AUDIO], n, r, i, a) {
12543
12562
  if (!N.hold && B.callsLength > 0) throw z.error("There is already active call"), new k(O.HAS_ACTIVE_CALL);
12544
- return n && (N.anonymToken = n), new $(new Cs(), js).onJoin({
12563
+ return n && (N.anonymToken = n), new $(new Ts(), Ns).onJoin({
12545
12564
  joinLink: e,
12546
12565
  mediaOptions: t,
12547
12566
  observedIds: r,
@@ -12550,30 +12569,30 @@ async function Ys(e, t = [S.AUDIO], n, r, i, a) {
12550
12569
  anonymous: !!N.anonymToken
12551
12570
  });
12552
12571
  }
12553
- function Xs(e) {
12554
- let t = pl(e);
12555
- return t ? t.hangup() : ($.hangupAfterInit(), Promise.resolve());
12572
+ function Qs(e, t) {
12573
+ let n = hl(e);
12574
+ return n ? n.hangup(t?.reason) : ($.hangupAfterInit(), Promise.resolve());
12556
12575
  }
12557
- async function Zs(e, t) {
12576
+ async function $s(e, t) {
12558
12577
  let n = Array.isArray(e) ? e : [e], r = $.current();
12559
12578
  r && await r.addParticipant(n, t);
12560
12579
  }
12561
- async function Qs(e, t) {
12580
+ async function ec(e, t) {
12562
12581
  let n = $.current();
12563
12582
  if (n) {
12564
12583
  let r = e.map((e) => M.composeUserId(e));
12565
12584
  await n.addParticipantLegacy(r, t);
12566
12585
  }
12567
12586
  }
12568
- async function $s(e, t = !1) {
12587
+ async function tc(e, t = !1) {
12569
12588
  let n = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12570
12589
  if (!n) {
12571
12590
  z.warn("removeParticipant: externalId not found in cache", e);
12572
12591
  return;
12573
12592
  }
12574
- return ec(n, t);
12593
+ return nc(n, t);
12575
12594
  }
12576
- async function ec(e, t = !1) {
12595
+ async function nc(e, t = !1) {
12577
12596
  let n = $.current();
12578
12597
  if (n) try {
12579
12598
  await n.removeParticipant(M.composeUserId(e), t);
@@ -12581,13 +12600,13 @@ async function ec(e, t = !1) {
12581
12600
  z.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
12582
12601
  }
12583
12602
  }
12584
- async function tc(e, t) {
12603
+ async function rc(e, t) {
12585
12604
  let n = $.current();
12586
12605
  if (e === "videoinput" && At.contains(t)) return N.videoFacingMode = t, n ? (E.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
12587
12606
  if (!await E._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
12588
12607
  if (n) return n.changeDevice(e);
12589
12608
  }
12590
- async function nc(e, t) {
12609
+ async function ic(e, t) {
12591
12610
  let n = typeof e == "object" ? {
12592
12611
  ...e,
12593
12612
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -12596,34 +12615,34 @@ async function nc(e, t) {
12596
12615
  captureScreen: e,
12597
12616
  fastScreenSharing: !1,
12598
12617
  captureAudio: !1
12599
- }, r = pl(t);
12618
+ }, r = hl(t);
12600
12619
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
12601
12620
  }
12602
- function rc(e) {
12621
+ function ac(e) {
12603
12622
  let t = $.current();
12604
12623
  t && t.toggleAnimojiCapturing(e);
12605
12624
  }
12606
- async function ic(e, t = !1) {
12625
+ async function oc(e, t = !1) {
12607
12626
  let n = $.current();
12608
12627
  n && await n.setVideoStream(e, t);
12609
12628
  }
12610
- async function ac(e, t) {
12611
- let n = pl(t);
12629
+ async function sc(e, t) {
12630
+ let n = hl(t);
12612
12631
  n && await n.toggleLocalVideo(e);
12613
12632
  }
12614
- async function oc(e, t) {
12615
- let n = pl(t);
12633
+ async function cc(e, t) {
12634
+ let n = hl(t);
12616
12635
  n && await n.toggleLocalAudio(e);
12617
12636
  }
12618
- async function sc(e) {
12637
+ async function lc(e) {
12619
12638
  let t = $.current();
12620
12639
  if (t) return t.setLocalResolution(e);
12621
12640
  }
12622
- async function cc(e) {
12641
+ async function uc(e) {
12623
12642
  let t = $.current();
12624
12643
  t && await t.changePriorities(e);
12625
12644
  }
12626
- async function lc(e, t) {
12645
+ async function dc(e, t) {
12627
12646
  let n = $.current();
12628
12647
  if (n) {
12629
12648
  let r;
@@ -12638,33 +12657,33 @@ async function lc(e, t) {
12638
12657
  await n.changeParticipantState(e, r);
12639
12658
  }
12640
12659
  }
12641
- async function uc() {
12660
+ async function fc() {
12642
12661
  let e = $.current();
12643
12662
  e && await e.putHandsDown();
12644
12663
  }
12645
- async function dc(e) {
12664
+ async function pc(e) {
12646
12665
  let t = $.current();
12647
12666
  t && await t.updateDisplayLayout(e);
12648
12667
  }
12649
- async function fc(e) {
12668
+ async function mc(e) {
12650
12669
  let t = $.current();
12651
12670
  t && await t.requestDisplayLayout(e);
12652
12671
  }
12653
- async function pc(e, t, n = !1) {
12672
+ async function hc(e, t, n = !1) {
12654
12673
  let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12655
12674
  if (!r) {
12656
12675
  z.warn("grantRoles: externalId not found in cache", e);
12657
12676
  return;
12658
12677
  }
12659
- return mc(r, Q.getDeviceIdx(e), t, n);
12678
+ return gc(r, Q.getDeviceIdx(e), t, n);
12660
12679
  }
12661
- async function mc(e, t, n, r = !1) {
12680
+ async function gc(e, t, n, r = !1) {
12662
12681
  let i = $.current();
12663
12682
  i && await i.grantRoles(M.composeParticipantId(e, j.USER, t), n, r);
12664
12683
  }
12665
- async function hc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12684
+ async function _c({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
12666
12685
  let i = null;
12667
- return e && (i = $.current()?.getCachedRawOkIdByExternalId(e) ?? null, i || z.warn("muteParticipant: externalId not found in cache", e)), gc({
12686
+ return e && (i = $.current()?.getCachedRawOkIdByExternalId(e) ?? null, i || z.warn("muteParticipant: externalId not found in cache", e)), vc({
12668
12687
  uid: i,
12669
12688
  muteStates: t,
12670
12689
  requestedMedia: n,
@@ -12672,129 +12691,129 @@ async function hc({ externalId: e = null, muteStates: t, requestedMedia: n = [],
12672
12691
  roomId: r
12673
12692
  });
12674
12693
  }
12675
- async function gc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12694
+ async function vc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
12676
12695
  let a = $.current();
12677
12696
  if (a) {
12678
12697
  let o = e ? M.composeParticipantId(e, j.USER, r) : null;
12679
12698
  await a.muteParticipant(o, t, n, i);
12680
12699
  }
12681
12700
  }
12682
- async function _c(e, t = !1, n = null) {
12701
+ async function yc(e, t = !1, n = null) {
12683
12702
  let r = $.current()?.getCachedRawOkIdByExternalId(e) ?? null;
12684
12703
  if (!r) {
12685
12704
  z.warn("pinParticipant: externalId not found in cache", e);
12686
12705
  return;
12687
12706
  }
12688
- return vc(r, t, Q.getDeviceIdx(e), n);
12707
+ return bc(r, t, Q.getDeviceIdx(e), n);
12689
12708
  }
12690
- async function vc(e, t = !1, n = 0, r = null) {
12709
+ async function bc(e, t = !1, n = 0, r = null) {
12691
12710
  let i = $.current();
12692
12711
  i && await i.pinParticipant(M.composeParticipantId(e, j.USER, n), t, r);
12693
12712
  }
12694
- async function yc(e) {
12713
+ async function xc(e) {
12695
12714
  let t = $.current();
12696
12715
  t && await t.updateMediaModifiers(e);
12697
12716
  }
12698
- async function bc(e) {
12717
+ async function Sc(e) {
12699
12718
  let t = $.current();
12700
12719
  t && await t.enableVideoSuspend(e);
12701
12720
  }
12702
- async function xc(e) {
12721
+ async function Cc(e) {
12703
12722
  let t = $.current();
12704
12723
  t && await t.enableVideoSuspendSuggest(e);
12705
12724
  }
12706
- async function Sc(e) {
12725
+ async function wc(e) {
12707
12726
  let t = $.current();
12708
12727
  t && await t.changeOptions(e);
12709
12728
  }
12710
- async function Cc(e, t = null) {
12729
+ async function Tc(e, t = null) {
12711
12730
  let n = null;
12712
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || z.warn("chatMessage: externalId not found in cache", t)), wc(e, n);
12731
+ return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || z.warn("chatMessage: externalId not found in cache", t)), Ec(e, n);
12713
12732
  }
12714
- async function wc(e, t = null) {
12733
+ async function Ec(e, t = null) {
12715
12734
  let n = $.current();
12716
12735
  if (n) {
12717
12736
  let r = t ? M.composeUserId(t) : null;
12718
12737
  await n.chatMessage(e, r);
12719
12738
  }
12720
12739
  }
12721
- async function Tc(e = 10) {
12740
+ async function Dc(e = 10) {
12722
12741
  let t = $.current();
12723
12742
  if (t) return t.chatHistory(e);
12724
12743
  }
12725
- async function Ec(e, t = null) {
12744
+ async function Oc(e, t = null) {
12726
12745
  let n = null;
12727
- return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || z.warn("customData: externalId not found in cache", t)), Dc(e, n, Q.getDeviceIdx(t));
12746
+ return t && (n = $.current()?.getCachedRawOkIdByExternalId(t) ?? null, n || z.warn("customData: externalId not found in cache", t)), kc(e, n, Q.getDeviceIdx(t));
12728
12747
  }
12729
- async function Dc(e, t = null, n = 0) {
12748
+ async function kc(e, t = null, n = 0) {
12730
12749
  let r = $.current();
12731
12750
  if (r) {
12732
12751
  let i = t ? M.composeParticipantId(t, j.USER, n) : null;
12733
12752
  await r.customData(e, i);
12734
12753
  }
12735
12754
  }
12736
- async function Oc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12737
- return (await As.createConversation(a ?? M.uuid(), e, t, {
12755
+ async function Ac(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
12756
+ return (await Ms.createConversation(a ?? M.uuid(), e, t, {
12738
12757
  onlyAdminCanShareMovie: n,
12739
12758
  waitForAdmin: r,
12740
12759
  closedConversation: i
12741
12760
  })).join_link;
12742
12761
  }
12743
- async function kc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
12762
+ async function jc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
12744
12763
  let a = i.map((e) => Q.fromId(e));
12745
- return (await As.createConversation(M.uuid(), e, t, {
12764
+ return (await Ms.createConversation(M.uuid(), e, t, {
12746
12765
  onlyAdminCanShareMovie: n,
12747
12766
  audienceMode: !0,
12748
12767
  audioOnly: r
12749
12768
  }, a)).join_link;
12750
12769
  }
12751
- async function Ac() {
12770
+ async function Mc() {
12752
12771
  let e = $.current();
12753
12772
  return e ? e.createJoinLink() : Promise.reject();
12754
12773
  }
12755
- async function jc() {
12774
+ async function Nc() {
12756
12775
  let e = $.current();
12757
12776
  return e ? e.removeJoinLink() : Promise.reject();
12758
12777
  }
12759
- async function Mc(e, t) {
12760
- return As.getAnonymTokenByLink(e, t);
12778
+ async function Pc(e, t) {
12779
+ return Ms.getAnonymTokenByLink(e, t);
12761
12780
  }
12762
- function Nc(e) {
12781
+ function Fc(e) {
12763
12782
  let t = $.current();
12764
12783
  t && t.setVolume(e);
12765
12784
  }
12766
- function Pc(e) {
12785
+ function Ic(e) {
12767
12786
  N.forceRelayPolicy = e;
12768
12787
  }
12769
- async function Fc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
12788
+ async function Lc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
12770
12789
  let o = $.current();
12771
12790
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
12772
12791
  }
12773
- async function Ic(e = null, t) {
12792
+ async function Rc(e = null, t) {
12774
12793
  let n = $.current();
12775
12794
  return n ? n.stopStream(e, t) : Promise.reject();
12776
12795
  }
12777
- async function Lc(e = null) {
12796
+ async function zc(e = null) {
12778
12797
  let t = $.current();
12779
12798
  return t ? t.publishStream(e) : Promise.reject();
12780
12799
  }
12781
- async function Rc() {
12800
+ async function Bc() {
12782
12801
  let e = $.current();
12783
12802
  return e ? e.getStreamInfo() : Promise.reject();
12784
12803
  }
12785
- async function zc(e) {
12804
+ async function Vc(e) {
12786
12805
  let t = $.current();
12787
12806
  return t ? t.addMovie(e) : Promise.reject();
12788
12807
  }
12789
- async function Bc(e) {
12808
+ async function Hc(e) {
12790
12809
  let t = $.current();
12791
12810
  return t ? t.updateMovie(e) : Promise.reject();
12792
12811
  }
12793
- async function Vc(e) {
12812
+ async function Uc(e) {
12794
12813
  let t = $.current();
12795
12814
  return t ? t.removeMovie(e) : Promise.reject();
12796
12815
  }
12797
- async function Hc(e, t) {
12816
+ async function Wc(e, t) {
12798
12817
  let n = $.current();
12799
12818
  if (n) {
12800
12819
  let r = [];
@@ -12819,11 +12838,11 @@ async function Hc(e, t) {
12819
12838
  }
12820
12839
  return Promise.reject();
12821
12840
  }
12822
- async function Uc(e, t) {
12841
+ async function Gc(e, t) {
12823
12842
  let n = $.current();
12824
12843
  return n ? n.activateRooms(e, t) : Promise.reject();
12825
12844
  }
12826
- async function Wc(e = null, t = null) {
12845
+ async function Kc(e = null, t = null) {
12827
12846
  let n = $.current();
12828
12847
  if (!n) return Promise.reject();
12829
12848
  let r;
@@ -12838,25 +12857,25 @@ async function Wc(e = null, t = null) {
12838
12857
  }
12839
12858
  return n.switchRoom(e, r);
12840
12859
  }
12841
- async function Gc(e) {
12860
+ async function qc(e) {
12842
12861
  let t = $.current();
12843
12862
  return t ? t.removeRooms(e) : Promise.reject();
12844
12863
  }
12845
- function Kc(e) {
12864
+ function Jc(e) {
12846
12865
  N.statisticsInterval = e;
12847
12866
  let t = $.current();
12848
12867
  if (t) return t.updateStatisticsInterval();
12849
12868
  }
12850
- function qc(t) {
12869
+ function Yc(t) {
12851
12870
  e.disableLog(!t), z.toggle(t);
12852
12871
  }
12853
- function Jc(e, ...t) {
12872
+ function Xc(e, ...t) {
12854
12873
  N.debugLog && ($.debugMessage(e, "[external]", ...t) || z.send(e, "[external]", ...t));
12855
12874
  }
12856
- function Yc(e, t, ...n) {
12875
+ function Zc(e, t, ...n) {
12857
12876
  N.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || z.send(e, "[external]", ...n));
12858
12877
  }
12859
- var Xc = {
12878
+ var Qc = {
12860
12879
  list: Ne,
12861
12880
  get: Pe,
12862
12881
  getJson: Fe,
@@ -12864,7 +12883,7 @@ var Xc = {
12864
12883
  clear: Le,
12865
12884
  stats: Re
12866
12885
  };
12867
- function Zc() {
12886
+ function $c() {
12868
12887
  let e = [
12869
12888
  [`Calls SDK ${N.sdkVersion}`, N.toJSON()],
12870
12889
  ["UserAgent:", navigator.userAgent],
@@ -12881,31 +12900,31 @@ function Zc() {
12881
12900
  d: e
12882
12901
  }));
12883
12902
  }
12884
- async function Qc() {
12903
+ async function el() {
12885
12904
  let e = $.id(), t = $.debugSessionId();
12886
12905
  if (!t || !e) throw z.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
12887
12906
  let n = await Pe({ sessionId: t });
12888
12907
  if (n.length === 0) throw z.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
12889
12908
  let r = n[0].t, i = n[n.length - 1].t;
12890
12909
  try {
12891
- return As?.uploadDebugLogs(e, r, i, JSON.stringify([...Zc(), ...n]));
12910
+ return Ms?.uploadDebugLogs(e, r, i, JSON.stringify([...$c(), ...n]));
12892
12911
  } catch (e) {
12893
12912
  throw z.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
12894
12913
  }
12895
12914
  }
12896
- async function $c(e) {
12915
+ async function tl(e) {
12897
12916
  let t = $.current();
12898
12917
  if (t) return t.videoEffect(e);
12899
12918
  }
12900
- async function el(e, t) {
12919
+ async function nl(e, t) {
12901
12920
  let n = $.current();
12902
12921
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
12903
12922
  }
12904
- async function tl(e) {
12923
+ async function rl(e) {
12905
12924
  let t = $.current();
12906
12925
  t && await t.setAudioStream(e);
12907
12926
  }
12908
- async function nl(e, t = null, n = null) {
12927
+ async function il(e, t = null, n = null) {
12909
12928
  let r = $.current();
12910
12929
  if (!r) return;
12911
12930
  let i = n ?? t?.id, a = null;
@@ -12916,18 +12935,18 @@ async function nl(e, t = null, n = null) {
12916
12935
  }
12917
12936
  r.setAnimojiSvg(e, a, i);
12918
12937
  }
12919
- function rl(e) {
12938
+ function al(e) {
12920
12939
  let t = $.current();
12921
12940
  t && t.setAnimojiFill(e);
12922
12941
  }
12923
- async function il(e = null, t, n = !1) {
12924
- return ml().getWaitingHall(e, t, n);
12942
+ async function ol(e = null, t, n = !1) {
12943
+ return gl().getWaitingHall(e, t, n);
12925
12944
  }
12926
- async function al() {
12927
- return ml().getAudienceModeHands();
12945
+ async function sl() {
12946
+ return gl().getAudienceModeHands();
12928
12947
  }
12929
- async function ol(e, t = !1) {
12930
- let n = ml(), r;
12948
+ async function cl(e, t = !1) {
12949
+ let n = gl(), r;
12931
12950
  if (e) {
12932
12951
  let t = n.getCachedRawOkIdByExternalId(e);
12933
12952
  if (!t) {
@@ -12938,67 +12957,67 @@ async function ol(e, t = !1) {
12938
12957
  }
12939
12958
  return n.promoteParticipant(r, t);
12940
12959
  }
12941
- async function sl(e = !1) {
12942
- return ml().requestPromotion(e);
12960
+ async function ll(e = !1) {
12961
+ return gl().requestPromotion(e);
12943
12962
  }
12944
- async function cl(e = !1) {
12945
- return ml().acceptPromotion(e);
12963
+ async function ul(e = !1) {
12964
+ return gl().acceptPromotion(e);
12946
12965
  }
12947
- async function ll(e) {
12948
- return ml().getParticipantListChunk(e);
12966
+ async function dl(e) {
12967
+ return gl().getParticipantListChunk(e);
12949
12968
  }
12950
- async function ul(e) {
12951
- return ml().getParticipants(e);
12969
+ async function fl(e) {
12970
+ return gl().getParticipants(e);
12952
12971
  }
12953
- async function dl(e) {
12954
- return ml().feedback(e);
12972
+ async function pl(e) {
12973
+ return gl().feedback(e);
12955
12974
  }
12956
- async function fl(e, t, n) {
12957
- return ml(n).enableFeatureForRoles(e, t);
12975
+ async function ml(e, t, n) {
12976
+ return gl(n).enableFeatureForRoles(e, t);
12958
12977
  }
12959
- function pl(e) {
12978
+ function hl(e) {
12960
12979
  return e ? B.get(e) ?? null : $.current() ?? B.getFirst();
12961
12980
  }
12962
- function ml(e) {
12963
- let t = pl(e);
12981
+ function gl(e) {
12982
+ let t = hl(e);
12964
12983
  if (!t) throw Error("Conversation not found");
12965
12984
  return t;
12966
12985
  }
12967
- async function hl(e) {
12968
- await As.removeHistoryRecords(e);
12986
+ async function _l(e) {
12987
+ await Ms.removeHistoryRecords(e);
12969
12988
  }
12970
- async function gl(e) {
12989
+ async function vl(e) {
12971
12990
  let t = $.current() ?? B.getFirst();
12972
12991
  t && await t.startAsr(e);
12973
12992
  }
12974
- async function _l(e) {
12993
+ async function yl(e) {
12975
12994
  let t = $.current() ?? B.getFirst();
12976
12995
  t && await t.stopAsr(e);
12977
12996
  }
12978
- async function vl(e) {
12997
+ async function bl(e) {
12979
12998
  let t = $.current() ?? B.getFirst();
12980
12999
  t && await t.requestAsr(e);
12981
13000
  }
12982
- async function yl(e) {
13001
+ async function xl(e) {
12983
13002
  let t = $.current();
12984
13003
  return t ? t.startUrlSharing(e) : Promise.reject();
12985
13004
  }
12986
- async function bl() {
13005
+ async function Sl() {
12987
13006
  let e = $.current();
12988
13007
  return e ? e.stopUrlSharing() : Promise.reject();
12989
13008
  }
12990
- async function xl(e) {
13009
+ async function Cl(e) {
12991
13010
  await B.switchCall(e);
12992
13011
  }
12993
- function Sl() {
13012
+ function wl() {
12994
13013
  return B.getActiveId();
12995
13014
  }
12996
- function Cl() {
13015
+ function Tl() {
12997
13016
  return $.getSyncedTime();
12998
13017
  }
12999
- function wl() {
13018
+ function El() {
13000
13019
  return N.sdkVersion;
13001
13020
  }
13002
13021
  typeof window < "u" && (window.__CALLS_SDK = mn);
13003
13022
  //#endregion
13004
- export { Cs as Api, ks as ApiExternal, Os as ArrayDequeue, y as AuthData, f as BaseLogger, Pa as CallDirection, Fa as CallType, Ia as ChatRoomEventType, La as ConversationFeature, Ra as ConversationOption, _n as DebugMessageType, Ya as ExternalIdType, At as FacingMode, x as FatalError, k as HangupReason, O as HangupType, S as MediaOption, A as MediaTrackKind, H as MediaType, Va as MuteState, Z as ParticipantState, Ds as ParticipantStateDataValue, P as ParticipantStatus, Es as RecordRole, Ha as RoomsEventType, Na as Signaling, V as SignalingCommandType, fr as SignalingConnectionType, q as SignalingNotification, Y as TransportTopology, Ga as UserRole, j as UserType, go as VolumeDetector, Gs as acceptCall, cl as acceptPromotion, Uc as activateRooms, zc as addMovie, Zs as addParticipant, Qs as addParticipantInternal, Ws as authorize, Ms as browser, Bs as callInternal, zs as callTo, nc as captureScreen, rc as captureVmoji, el as changeAudioEffect, Sc as changeConversationOptions, tc as changeDevice, lc as changeParticipantState, cc as changePriorities, $c as changeVideoEffect, Tc as chatHistory, Cc as chatMessage, wc as chatMessageInternal, Ac as createJoinLink, Ec as customData, Dc as customDataInternal, qc as debug, Xc as debugLogs, Jc as debugMessage, Yc as debugMessageWithContext, Ks as declineCall, fl as enableFeatureForRoles, bc as enableVideoSuspend, xc as enableVideoSuspendSuggest, dl as feedback, Pc as forceRelayPolicy, Sl as getActiveCallId, Mc as getAnonymTokenByLink, al as getAudienceModeHands, Us as getInbounds, ll as getParticipantListChunk, ul as getParticipants, Rc as getStreamInfo, Cl as getSyncedTime, il as getWaitingHall, pc as grantRoles, mc as grantRolesInternal, Xs as hangup, Rs as init, qs as joinCall, Ys as joinCallByLink, Js as joinCallInternal, hc as muteParticipant, gc as muteParticipantInternal, _c as pinParticipant, vc as pinParticipantInternal, Vs as processPush, Hs as processPushInternal, ol as promoteParticipant, Lc as publishStream, uc as putHandsDown, hl as removeHistoryRecords, jc as removeJoinLink, Vc as removeMovie, $s as removeParticipant, ec as removeParticipantInternal, Gc as removeRooms, vl as requestAsr, fc as requestDisplayLayout, sl as requestPromotion, Is as setAudioEffects, tl as setAudioStream, sc as setLocalResolution, Ps as setLogger, yc as setMediaModifiers, Kc as setStatisticsInterval, Fs as setVideoEffects, ic as setVideoStream, Ls as setVmoji, rl as setVmojiFill, nl as setVmojiSvg, Nc as setVolume, gl as startAsr, kc as startAudienceConversation, Oc as startConversation, Fc as startStream, yl as startUrlSharing, _l as stopAsr, Ic as stopStream, bl as stopUrlSharing, xl as switchCall, Wc as switchRoom, oc as toggleLocalAudio, ac as toggleLocalVideo, dc as updateDisplayLayout, Bc as updateMovie, Hc as updateRooms, Qc as uploadDebugLogs, Ns as utils, wl as version };
13023
+ export { Ts as Api, js as ApiExternal, As as ArrayDequeue, y as AuthData, f as BaseLogger, Pa as CallDirection, Fa as CallType, Ia as ChatRoomEventType, La as ConversationFeature, Ra as ConversationOption, _n as DebugMessageType, Ya as ExternalIdType, At as FacingMode, x as FatalError, k as HangupReason, O as HangupType, S as MediaOption, A as MediaTrackKind, H as MediaType, Va as MuteState, Z as ParticipantState, ks as ParticipantStateDataValue, P as ParticipantStatus, Os as RecordRole, Ha as RoomsEventType, Na as Signaling, V as SignalingCommandType, fr as SignalingConnectionType, q as SignalingNotification, Y as TransportTopology, Ga as UserRole, j as UserType, vo as VolumeDetector, qs as acceptCall, ul as acceptPromotion, Gc as activateRooms, Vc as addMovie, $s as addParticipant, ec as addParticipantInternal, Ks as authorize, Ps as browser, Hs as callInternal, Vs as callTo, ic as captureScreen, ac as captureVmoji, nl as changeAudioEffect, wc as changeConversationOptions, rc as changeDevice, dc as changeParticipantState, uc as changePriorities, tl as changeVideoEffect, Dc as chatHistory, Tc as chatMessage, Ec as chatMessageInternal, Mc as createJoinLink, Oc as customData, kc as customDataInternal, Yc as debug, Qc as debugLogs, Xc as debugMessage, Zc as debugMessageWithContext, Js as declineCall, ml as enableFeatureForRoles, Sc as enableVideoSuspend, Cc as enableVideoSuspendSuggest, pl as feedback, Ic as forceRelayPolicy, wl as getActiveCallId, Pc as getAnonymTokenByLink, sl as getAudienceModeHands, Gs as getInbounds, dl as getParticipantListChunk, fl as getParticipants, Bc as getStreamInfo, Tl as getSyncedTime, ol as getWaitingHall, hc as grantRoles, gc as grantRolesInternal, Qs as hangup, Bs as init, Ys as joinCall, Zs as joinCallByLink, Xs as joinCallInternal, _c as muteParticipant, vc as muteParticipantInternal, yc as pinParticipant, bc as pinParticipantInternal, Us as processPush, Ws as processPushInternal, cl as promoteParticipant, zc as publishStream, fc as putHandsDown, _l as removeHistoryRecords, Nc as removeJoinLink, Uc as removeMovie, tc as removeParticipant, nc as removeParticipantInternal, qc as removeRooms, bl as requestAsr, mc as requestDisplayLayout, ll as requestPromotion, Rs as setAudioEffects, rl as setAudioStream, lc as setLocalResolution, Is as setLogger, xc as setMediaModifiers, Jc as setStatisticsInterval, Ls as setVideoEffects, oc as setVideoStream, zs as setVmoji, al as setVmojiFill, il as setVmojiSvg, Fc as setVolume, vl as startAsr, jc as startAudienceConversation, Ac as startConversation, Lc as startStream, xl as startUrlSharing, yl as stopAsr, Rc as stopStream, Sl as stopUrlSharing, Cl as switchCall, Kc as switchRoom, cc as toggleLocalAudio, sc as toggleLocalVideo, pc as updateDisplayLayout, Hc as updateMovie, Wc as updateRooms, el as uploadDebugLogs, Fs as utils, El as version };