@vkontakte/calls-sdk 2.8.13-dev.0b862caf.0 → 2.8.13-dev.41a8e3bd.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/calls-sdk.esm.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * @vkontakte/calls-sdk v2.8.13-dev.0b862caf.0
3
- * Tue, 15 Sep 2026 20:28:59 GMT
2
+ * @vkontakte/calls-sdk v2.8.13-dev.41a8e3bd.0
3
+ * Thu, 17 Sep 2026 10:29:34 GMT
4
4
  * https://calls-sdk.cdn-vk.ru/doc/latest/index.html
5
5
  */
6
6
 
@@ -2152,10 +2152,13 @@ var yn = vn.getInstance(), M = class e {
2152
2152
  return "ok.calls.sdk.js";
2153
2153
  }
2154
2154
  static get appVersion() {
2155
+ return e._params.appVersion;
2156
+ }
2157
+ static get apiClientVersion() {
2155
2158
  return 1.1;
2156
2159
  }
2157
2160
  static get sdkVersion() {
2158
- return "2.8.13-dev.0b862caf.0";
2161
+ return "2.8.13-dev.41a8e3bd.0";
2159
2162
  }
2160
2163
  static get debug() {
2161
2164
  return e._params.debug;
@@ -2275,9 +2278,6 @@ var yn = vn.getInstance(), M = class e {
2275
2278
  static get signalingReconnectMaxCount() {
2276
2279
  return e._params.signalingReconnectMaxCount;
2277
2280
  }
2278
- static get signalingReconnectMaxDuration() {
2279
- return e._params.signalingReconnectMaxDuration;
2280
- }
2281
2281
  static get waitConnectionDelay() {
2282
2282
  return e._params.waitConnectionDelay;
2283
2283
  }
@@ -2581,6 +2581,7 @@ var yn = vn.getInstance(), M = class e {
2581
2581
  movieShare: e._params.movieShare,
2582
2582
  clientType: e._params.clientType,
2583
2583
  clientStatsPlatform: e._params.clientStatsPlatform,
2584
+ appVersion: e._params.appVersion,
2584
2585
  consumerScreenDataChannelPacketSize: e._params.consumerScreenDataChannelPacketSize,
2585
2586
  switchVideoAtBadNetwork: e._params.switchVideoAtBadNetwork,
2586
2587
  simulcast: e._params.simulcast,
@@ -2596,6 +2597,7 @@ var yn = vn.getInstance(), M = class e {
2596
2597
  h(M, "_params", {
2597
2598
  platform: "WEB",
2598
2599
  clientStatsPlatform: "",
2600
+ appVersion: "0.0.0",
2599
2601
  clientType: "PORTAL",
2600
2602
  externalUserType: "",
2601
2603
  device: "browser",
@@ -2613,7 +2615,6 @@ h(M, "_params", {
2613
2615
  signalingReconnectDelay: 1e3,
2614
2616
  signalingReconnectMaxDelay: 5e3,
2615
2617
  signalingReconnectMaxCount: 10,
2616
- signalingReconnectMaxDuration: 6e4,
2617
2618
  waitConnectionDelay: 1e4,
2618
2619
  waitResponseDelay: 1e4,
2619
2620
  waitMessageDelay: 15e3,
@@ -3589,7 +3590,7 @@ var Rn = 0, zn = 1, Bn = 2, Vn = 3, Hn = 4, Un = 5, Wn = 6, Gn = 7, Kn = 0, qn =
3589
3590
  };
3590
3591
  }
3591
3592
  }, H = /* @__PURE__ */ function(e) {
3592
- 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;
3593
+ 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.SDP_CREATE_OFFER = "sdp_create_offer", e.SDP_CREATE_ANSWER = "sdp_create_answer", e.SDP_SET_LOCAL_OFFER = "sdp_set_local_offer", e.SDP_SET_LOCAL_PRANSWER = "sdp_set_local_pranswer", e.SDP_SET_LOCAL_ANSWER = "sdp_set_local_answer", e.SDP_SET_LOCAL_ROLLBACK = "sdp_set_local_rollback", e.SDP_SET_REMOTE_OFFER = "sdp_set_remote_offer", e.SDP_SET_REMOTE_PRANSWER = "sdp_set_remote_pranswer", e.SDP_SET_REMOTE_ANSWER = "sdp_set_remote_answer", e.SDP_SET_REMOTE_ROLLBACK = "sdp_set_remote_rollback", e.SDP_GENERATED = "sdp_generated", e.SDP_RECEIVED = "sdp_received", 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;
3593
3594
  }(H || {}), er = 1e3;
3594
3595
  function U(e, t, n = 0) {
3595
3596
  return t in e && e[t] ? e[t] : n;
@@ -3827,14 +3828,132 @@ function kr() {
3827
3828
  };
3828
3829
  }
3829
3830
  //#endregion
3831
+ //#region src/classes/stat/SdpStats.ts
3832
+ var Ar = {
3833
+ offer: H.SDP_CREATE_OFFER,
3834
+ answer: H.SDP_CREATE_ANSWER
3835
+ }, jr = {
3836
+ offer: H.SDP_SET_LOCAL_OFFER,
3837
+ pranswer: H.SDP_SET_LOCAL_PRANSWER,
3838
+ answer: H.SDP_SET_LOCAL_ANSWER,
3839
+ rollback: H.SDP_SET_LOCAL_ROLLBACK
3840
+ }, Mr = {
3841
+ offer: H.SDP_SET_REMOTE_OFFER,
3842
+ pranswer: H.SDP_SET_REMOTE_PRANSWER,
3843
+ answer: H.SDP_SET_REMOTE_ANSWER,
3844
+ rollback: H.SDP_SET_REMOTE_ROLLBACK
3845
+ }, Nr = {
3846
+ local_address: null,
3847
+ remote_address: null,
3848
+ transport: null
3849
+ }, Pr = class {
3850
+ constructor(e) {
3851
+ h(this, "_statAggregator", void 0), h(this, "_pc", null), h(this, "_gatheringStartedAt", 0), h(this, "_remoteSdpReceivedAt", 0), h(this, "_handleGatheringStateChange", () => {
3852
+ this._pc?.iceGatheringState === "gathering" && (this._gatheringStartedAt = Date.now());
3853
+ }), this._statAggregator = e;
3854
+ }
3855
+ observe(e) {
3856
+ this.stop(), this._pc = e, this._gatheringStartedAt = Date.now(), this._remoteSdpReceivedAt = 0, e.addEventListener("icegatheringstatechange", this._handleGatheringStateChange);
3857
+ }
3858
+ stop() {
3859
+ this._pc?.removeEventListener("icegatheringstatechange", this._handleGatheringStateChange), this._pc = null;
3860
+ }
3861
+ logSdpGenerated(e) {
3862
+ this._log({
3863
+ name: H.SDP_GENERATED,
3864
+ value: 0,
3865
+ string_value: e,
3866
+ ...Nr
3867
+ });
3868
+ }
3869
+ logCandidateGenerated(e) {
3870
+ let t = Ir(e.candidate);
3871
+ t && this._log({
3872
+ name: H.SDP_GENERATED,
3873
+ value: Math.max(0, Date.now() - this._gatheringStartedAt),
3874
+ string_value: t.type,
3875
+ local_address: t.address,
3876
+ remote_address: null,
3877
+ transport: t.protocol
3878
+ });
3879
+ }
3880
+ logSdpReceived(e) {
3881
+ this._remoteSdpReceivedAt = Date.now(), this._log({
3882
+ name: H.SDP_RECEIVED,
3883
+ value: 0,
3884
+ string_value: e,
3885
+ ...Nr
3886
+ });
3887
+ }
3888
+ logCandidateReceived(e) {
3889
+ let t = Ir(e.candidate);
3890
+ t && this._log({
3891
+ name: H.SDP_RECEIVED,
3892
+ value: this._remoteSdpReceivedAt > 0 ? Math.max(0, Date.now() - this._remoteSdpReceivedAt) : 0,
3893
+ string_value: t.type,
3894
+ local_address: null,
3895
+ remote_address: t.address,
3896
+ transport: t.protocol
3897
+ });
3898
+ }
3899
+ logCreateFailed(e, t) {
3900
+ let n = Ar[e];
3901
+ n && this._logFailure(n, t, { remote: e === "answer" ? this._pc?.remoteDescription : void 0 });
3902
+ }
3903
+ logSetLocalFailed(e, t) {
3904
+ this._logFailure(jr[e.type], t, {
3905
+ local: e,
3906
+ remote: this._pc?.remoteDescription
3907
+ });
3908
+ }
3909
+ logSetRemoteFailed(e, t) {
3910
+ this._logFailure(Mr[e.type], t, {
3911
+ local: this._pc?.localDescription,
3912
+ remote: e
3913
+ });
3914
+ }
3915
+ destroy() {
3916
+ this.stop();
3917
+ }
3918
+ _logFailure(e, t, n) {
3919
+ this._log({
3920
+ name: e,
3921
+ value: 0,
3922
+ string_value: JSON.stringify({
3923
+ error: t instanceof Error ? t.message : String(t),
3924
+ local: Fr(n.local),
3925
+ remote: Fr(n.remote)
3926
+ }),
3927
+ ...Nr
3928
+ });
3929
+ }
3930
+ _log(e) {
3931
+ this._statAggregator?.logEventualStat(e);
3932
+ }
3933
+ };
3934
+ function Fr(e) {
3935
+ return e ? {
3936
+ type: e.type,
3937
+ sdp: e.sdp
3938
+ } : void 0;
3939
+ }
3940
+ function Ir(e) {
3941
+ let t = e?.split(" ") ?? [], n = t.indexOf("typ"), r = t[2]?.toLowerCase(), i = t[4], a = n === -1 ? void 0 : t[n + 1];
3942
+ return r === void 0 || i === void 0 || a === void 0 ? null : {
3943
+ protocol: r,
3944
+ address: i,
3945
+ type: a
3946
+ };
3947
+ }
3948
+ //#endregion
3830
3949
  //#region src/classes/stat/FirstMediaSentProbe.ts
3831
- var Ar = 200;
3832
- function jr(e) {
3950
+ var Lr = 200;
3951
+ function Rr(e) {
3833
3952
  for (let t of e.values()) if (t.type === "outbound-rtp" && (t.packetsSent ?? 0) > 0) return !0;
3834
3953
  return !1;
3835
3954
  }
3836
- var Mr = class {
3837
- constructor(e, t, n = Ar) {
3955
+ var zr = class {
3956
+ constructor(e, t, n = Lr) {
3838
3957
  h(this, "_peerConnection", void 0), h(this, "_onFirstMediaSent", void 0), h(this, "_pollIntervalMs", void 0), h(this, "_timer", null), h(this, "_state", "idle"), this._peerConnection = e, this._onFirstMediaSent = t, this._pollIntervalMs = n;
3839
3958
  }
3840
3959
  start() {
@@ -3857,7 +3976,7 @@ var Mr = class {
3857
3976
  try {
3858
3977
  let e = await this._getStatsReports();
3859
3978
  if (this._state !== "polling") return;
3860
- if (e.some(jr)) {
3979
+ if (e.some(Rr)) {
3861
3980
  this._state = "stopped", this._onFirstMediaSent();
3862
3981
  return;
3863
3982
  }
@@ -3870,7 +3989,7 @@ var Mr = class {
3870
3989
  this._timer = null, this._poll();
3871
3990
  }, this._pollIntervalMs));
3872
3991
  }
3873
- }, Nr = class extends b {
3992
+ }, Br = class extends b {
3874
3993
  constructor(e, t, n = null) {
3875
3994
  super(), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_state", q.IDLE), h(this, "_pc", null), h(this, "_onFirstMediaSent", void 0), h(this, "_firstMediaSentProbe", null), h(this, "_firstMediaSentProbeStopped", !1), this._signaling = e, this._mediaSource = t, this._onFirstMediaSent = n;
3876
3995
  }
@@ -3881,12 +4000,12 @@ var Mr = class {
3881
4000
  this._firstMediaSentProbeStopped = !0, this._disposeFirstMediaSentProbe();
3882
4001
  }
3883
4002
  _startFirstMediaSentProbe() {
3884
- this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new Mr(this._pc, this._onFirstMediaSent), this._firstMediaSentProbe.start());
4003
+ this._disposeFirstMediaSentProbe(), !(!this._pc || !this._onFirstMediaSent || this._firstMediaSentProbeStopped) && (this._firstMediaSentProbe = new zr(this._pc, this._onFirstMediaSent), this._firstMediaSentProbe.start());
3885
4004
  }
3886
4005
  _disposeFirstMediaSentProbe() {
3887
4006
  this._firstMediaSentProbe?.destroy(), this._firstMediaSentProbe = null;
3888
4007
  }
3889
- }, Pr = class {
4008
+ }, Vr = class {
3890
4009
  constructor(e, t = null) {
3891
4010
  h(this, "weightUp", void 0), h(this, "weightDown", void 0), h(this, "value", NaN), this.weightUp = e, this.weightDown = t ?? e;
3892
4011
  }
@@ -3904,7 +4023,7 @@ var Mr = class {
3904
4023
  getValue() {
3905
4024
  return this.value;
3906
4025
  }
3907
- }, Fr = .25, Ir = .35, Lr = 85, Rr = .1, zr = 1.5, Br = .1, Vr = 1, Hr = .6, Ur = .3, Wr = class extends b {
4026
+ }, Hr = .25, Ur = .35, Wr = 85, Gr = .1, Kr = 1.5, qr = .1, Jr = 1, Yr = .6, Xr = .3, Zr = class extends b {
3908
4027
  constructor(e, t = R) {
3909
4028
  super(), h(this, "_signaling", void 0), h(this, "_localNetworkStat", void 0), h(this, "_remoteNetworkStat", void 0), h(this, "_lastNetworkStat", void 0), h(this, "_networkLimits", {
3910
4029
  badNet: {
@@ -3916,8 +4035,8 @@ var Mr = class {
3916
4035
  rtt: 600
3917
4036
  }
3918
4037
  }), h(this, "_lastStatSentTimestamp", 0), h(this, "_currentState", "good"), h(this, "_debug", void 0), this._debug = t, this._signaling = e, this._localNetworkStat = {
3919
- rtt: new Pr(Fr, Fr),
3920
- loss: new Pr(Ir, Ir),
4038
+ rtt: new Vr(Hr, Hr),
4039
+ loss: new Vr(Ur, Ur),
3921
4040
  bitrate: 0
3922
4041
  }, this._remoteNetworkStat = {
3923
4042
  rtt: 0,
@@ -3932,20 +4051,20 @@ var Mr = class {
3932
4051
  _calcRttRating(e) {
3933
4052
  let t = typeof e == "number" ? e : e.getValue(), n = 1;
3934
4053
  if (isNaN(t)) return n;
3935
- let r = Math.round((t - this._networkLimits.goodNet.rtt) / Lr);
3936
- for (let e = 0; e < r; e++) n *= 1 - Rr;
4054
+ let r = Math.round((t - this._networkLimits.goodNet.rtt) / Wr);
4055
+ for (let e = 0; e < r; e++) n *= 1 - Gr;
3937
4056
  return n;
3938
4057
  }
3939
4058
  _calcLossRating(e) {
3940
4059
  let t = typeof e == "number" ? e : e.getValue(), n = 1;
3941
4060
  if (isNaN(t)) return n;
3942
- let r = Math.round((t - this._networkLimits.goodNet.loss) / zr);
3943
- for (let e = 0; e < r; e++) n *= 1 - Br;
4061
+ let r = Math.round((t - this._networkLimits.goodNet.loss) / Kr);
4062
+ for (let e = 0; e < r; e++) n *= 1 - qr;
3944
4063
  return n;
3945
4064
  }
3946
4065
  _calcBitrateRating(e, t) {
3947
4066
  if (!e || !t) return 1;
3948
- let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) * Vr;
4067
+ let n = 1 - (1 - Math.min(e, t) / Math.max(e, t)) * Jr;
3949
4068
  return Math.min(n, 1);
3950
4069
  }
3951
4070
  _calcUDPRating({ rtt: e, loss: t }) {
@@ -3955,7 +4074,7 @@ var Mr = class {
3955
4074
  return n ? this._calcBitrateRating(e.bitrate, t.bitrate) : this._calcUDPRating(e) * this._calcUDPRating(t);
3956
4075
  }
3957
4076
  _getNetworkState(e) {
3958
- return isNaN(e) || e >= Hr ? "good" : e >= Ur ? "medium" : "bad";
4077
+ return isNaN(e) || e >= Yr ? "good" : e >= Xr ? "medium" : "bad";
3959
4078
  }
3960
4079
  updateSettings(e) {
3961
4080
  Object.assign(this._networkLimits.badNet, e?.badNet || {}), Object.assign(this._networkLimits.goodNet, e?.goodNet || {});
@@ -3979,7 +4098,7 @@ var Mr = class {
3979
4098
  let { rtt: t, loss: n, bitrate: r } = e || {};
3980
4099
  this._remoteNetworkStat.rtt = t || 0, this._remoteNetworkStat.loss = n || 0, this._remoteNetworkStat.bitrate = r || 0;
3981
4100
  }
3982
- }, Gr = 30 * 1e3, Kr = class e extends Nr {
4101
+ }, Qr = 30 * 1e3, $r = class e extends Br {
3983
4102
  constructor(e, t, n, r, i, a = R, o = null, s = null, c = null, l = null) {
3984
4103
  super(n, r, l), h(this, "_participantId", void 0), h(this, "_isMaster", void 0), h(this, "_remoteSDP", {}), h(this, "_remoteCandidates", {}), h(this, "_lastRemoteSDP", null), h(this, "_animojiDataChannel", null), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_remoteAnimojiVersion", 1), h(this, "_isOpen", !1), h(this, "_remotePeerId", null), h(this, "_statInterval", null), h(this, "_settingsInterval", null), h(this, "_failedOnCreate", null), h(this, "_remoteStream", null), h(this, "_iceRestartTimeout", null), h(this, "_reconnectionTimeout", null), h(this, "_reconnectionPrevented", !1), h(this, "_remoteHold", !1), h(this, "_lastStat", null), h(this, "_fingerprint", null), h(this, "_neverConnected", !0), h(this, "_serverSettings", void 0), h(this, "_prevConsumerSettings", {}), h(this, "_networkLimitsForVideo", {
3985
4104
  bad: {
@@ -3994,7 +4113,7 @@ var Mr = class {
3994
4113
  worst: 320,
3995
4114
  bad: 640,
3996
4115
  good: 1280
3997
- }), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), this._participantId = e, this._isMaster = t, this._serverSettings = i, this._debug = a, this._logger = o, this._statAggregator = s, this._codecStatsAggregator = c, this._perfStatReporter = new pa(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new Wr(n, this._debug), this.subscribe(this._signaling, G.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, qt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, qt.SOURCE_CHANGED, this._applySettings.bind(this)), this.subscribe(this._directStatReporter, X.NETWORK_STATUS, this._onNetworkStatus.bind(this));
4116
+ }), h(this, "_lastVideoMaxDimension", this._videoMaxDimensionsForNet.good), h(this, "_lastBadConnection", 0), h(this, "_perfStatReporter", void 0), h(this, "_directStatReporter", void 0), h(this, "_sdpStats", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), this._participantId = e, this._isMaster = t, this._serverSettings = i, this._debug = a, this._logger = o, this._statAggregator = s, this._codecStatsAggregator = c, this._perfStatReporter = new ba(this, n, this._statAggregator, !0, this._debug), this._directStatReporter = new Zr(n, this._debug), this._sdpStats = new Pr(this._statAggregator), this.subscribe(this._signaling, G.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, qt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, qt.SOURCE_CHANGED, this._applySettings.bind(this)), this.subscribe(this._directStatReporter, X.NETWORK_STATUS, this._onNetworkStatus.bind(this));
3998
4117
  try {
3999
4118
  this._pc = this._createPeerConnection();
4000
4119
  } catch (e) {
@@ -4098,12 +4217,12 @@ var Mr = class {
4098
4217
  iceServers: M.iceServers,
4099
4218
  iceTransportPolicy: M.forceRelayPolicy ? "relay" : "all"
4100
4219
  });
4101
- return e.onicecandidate = this._handleIceCandidate.bind(this), e.ontrack = this._onAddTrack.bind(this), e.oniceconnectionstatechange = this._onIceConnectionStateChange.bind(this), e.onconnectionstatechange = this._onConnectionStateChange.bind(this), e.onsignalingstatechange = this._onSignalingStateChange.bind(this), this._prevConsumerSettings = {}, M.vmoji && this._createDataChannel(e, Sr.animoji, (e) => {
4220
+ return e.onicecandidate = this._handleIceCandidate.bind(this), e.ontrack = this._onAddTrack.bind(this), e.oniceconnectionstatechange = this._onIceConnectionStateChange.bind(this), e.onconnectionstatechange = this._onConnectionStateChange.bind(this), e.onsignalingstatechange = this._onSignalingStateChange.bind(this), this._sdpStats.observe(e), this._prevConsumerSettings = {}, M.vmoji && this._createDataChannel(e, Sr.animoji, (e) => {
4102
4221
  this._animojiDataChannel = e, this._animojiDataChannel.binaryType = "arraybuffer", this._animojiReceiver?.setDataChannel(this._animojiDataChannel), this._animojiSender?.setDataChannel(this._animojiDataChannel);
4103
4222
  }), e;
4104
4223
  }
4105
4224
  _disposePeerConnection() {
4106
- if (this._disposeFirstMediaSentProbe(), this._lastStat = null, this._remoteStream) {
4225
+ if (this._disposeFirstMediaSentProbe(), this._sdpStats.stop(), this._lastStat = null, this._remoteStream) {
4107
4226
  let e = this._remoteStream;
4108
4227
  e.getTracks().forEach((t) => {
4109
4228
  t.stop(), this._triggerEvent(X.REMOTE_TRACK_REMOVED, e, t);
@@ -4141,7 +4260,7 @@ var Mr = class {
4141
4260
  }
4142
4261
  _handleTransmittedData(e) {
4143
4262
  let t = e.data, n = j.getPeerIdString(e.peerId);
4144
- j.composeMessageId(e) === this._participantId && (t.candidate && t.candidate.candidate ? this._addIceCandidate(n, t.candidate).catch(this.close.bind(this)) : t.sdp && (this._remoteAnimojiVersion = t.animojiVersion || 1, this._setRemoteDescription(n, t.sdp).catch(this.close.bind(this))));
4263
+ j.composeMessageId(e) === this._participantId && (t.candidate && t.candidate.candidate ? (this._sdpStats.logCandidateReceived(t.candidate), this._addIceCandidate(n, t.candidate).catch(this.close.bind(this))) : t.sdp && (this._sdpStats.logSdpReceived(t.sdp.type), this._remoteAnimojiVersion = t.animojiVersion || 1, this._setRemoteDescription(n, t.sdp).catch(this.close.bind(this))));
4145
4264
  }
4146
4265
  async _addIceCandidate(e, t) {
4147
4266
  if (this._isOpen && (!this._remotePeerId || this._remotePeerId === e) && this._pc && this._pc.remoteDescription) {
@@ -4183,7 +4302,7 @@ var Mr = class {
4183
4302
  try {
4184
4303
  await this._pc.setRemoteDescription(n), await this._setRemoteCandidates(t), this._processAnimojiProtocolVersion(this._remoteAnimojiVersion);
4185
4304
  } catch (e) {
4186
- throw this._logger?.log(C.ERROR, "setRemoteDescription-direct"), this._debug.error("Unable to set remote description", e, {
4305
+ throw this._logger?.log(C.ERROR, "setRemoteDescription-direct"), this._sdpStats.logSetRemoteFailed(n, e), this._debug.error("Unable to set remote description", e, {
4187
4306
  participantId: this._participantId,
4188
4307
  sdp: n
4189
4308
  }), e;
@@ -4206,7 +4325,7 @@ var Mr = class {
4206
4325
  this._signaling.ready && (e.candidate ? (this._debug.debug("Local ice candidate", {
4207
4326
  participantId: this._participantId,
4208
4327
  candidate: e.candidate
4209
- }), await this._signaling.sendCandidate(this._participantId, e.candidate)) : M.forwardEmptyIceCandidate && (this._debug.debug("ICE gathering complete, forwarding empty candidate", { participantId: this._participantId }), await this._signaling.sendCandidate(this._participantId, { candidate: "" })));
4328
+ }), this._sdpStats.logCandidateGenerated(e.candidate), await this._signaling.sendCandidate(this._participantId, e.candidate)) : M.forwardEmptyIceCandidate && (this._debug.debug("ICE gathering complete, forwarding empty candidate", { participantId: this._participantId }), await this._signaling.sendCandidate(this._participantId, { candidate: "" })));
4210
4329
  }
4211
4330
  _onSignalingStateChange() {
4212
4331
  this._debug.debug(`DirectTransport: Signaling state changed to ${this._pc?.signalingState}`, { participantId: this._participantId });
@@ -4290,9 +4409,9 @@ var Mr = class {
4290
4409
  r = await this._pc?.createOffer(n), this._debug.debug("Created offer", {
4291
4410
  participantId: this._participantId,
4292
4411
  offer: r
4293
- }), r = e._patchLocalDescription(r);
4412
+ }), this._sdpStats.logSdpGenerated("offer"), r = e._patchLocalDescription(r);
4294
4413
  } catch (e) {
4295
- throw this._debug.error("Unable to create offer", e, { participantId: this._participantId }), this._logger?.log(C.ERROR, "createOffer-direct"), e;
4414
+ throw this._debug.error("Unable to create offer", e, { participantId: this._participantId }), this._logger?.log(C.ERROR, "createOffer-direct"), this._sdpStats.logCreateFailed("offer", e), e;
4296
4415
  }
4297
4416
  try {
4298
4417
  return this._debug.debug("Set local description", {
@@ -4300,7 +4419,7 @@ var Mr = class {
4300
4419
  offer: r
4301
4420
  }), this._calcFingerprint(r.sdp), await this._pc?.setLocalDescription(r), r;
4302
4421
  } catch (e) {
4303
- throw this._debug.error("Unable to set local description", e, { participantId: this._participantId }), this._logger?.log(C.ERROR, "setLocalDescription-direct"), e;
4422
+ throw this._debug.error("Unable to set local description", e, { participantId: this._participantId }), this._logger?.log(C.ERROR, "setLocalDescription-direct"), this._sdpStats.logSetLocalFailed(r, e), e;
4304
4423
  }
4305
4424
  }
4306
4425
  async _createAnswer() {
@@ -4310,9 +4429,9 @@ var Mr = class {
4310
4429
  t = await this._pc?.createAnswer(), this._debug.debug("Created answer", {
4311
4430
  participantId: this._participantId,
4312
4431
  answer: t
4313
- }), t = e._patchLocalDescription(t);
4432
+ }), this._sdpStats.logSdpGenerated("answer"), t = e._patchLocalDescription(t);
4314
4433
  } catch (e) {
4315
- throw this._debug.error("Unable to create answer", e, { participantId: this._participantId }), this._logger?.log(C.ERROR, "createAnswer-direct"), e;
4434
+ throw this._debug.error("Unable to create answer", e, { participantId: this._participantId }), this._logger?.log(C.ERROR, "createAnswer-direct"), this._sdpStats.logCreateFailed("answer", e), e;
4316
4435
  }
4317
4436
  try {
4318
4437
  return this._debug.debug("Set local description", {
@@ -4320,7 +4439,7 @@ var Mr = class {
4320
4439
  answer: t
4321
4440
  }), this._calcFingerprint(t.sdp), await this._pc?.setLocalDescription(t), t;
4322
4441
  } catch (e) {
4323
- throw this._debug.error("Unable to set local description", e, { participantId: this._participantId }), this._logger?.log(C.ERROR, "setLocalDescription-direct"), e;
4442
+ throw this._debug.error("Unable to set local description", e, { participantId: this._participantId }), this._logger?.log(C.ERROR, "setLocalDescription-direct"), this._sdpStats.logSetLocalFailed(t, e), e;
4324
4443
  }
4325
4444
  }
4326
4445
  static _patchLocalDescription(e) {
@@ -4393,7 +4512,7 @@ var Mr = class {
4393
4512
  async _checkPPTNetwork(e) {
4394
4513
  if (!M.switchVideoAtBadNetwork || !e.inbound.transport.averageNetStat) return;
4395
4514
  let { averageNetStat: t } = e.inbound.transport, n = t.currentRoundTripTime <= this._networkLimitsForVideo.good.rtt && t.lostPercent <= this._networkLimitsForVideo.good.loss, r = t.currentRoundTripTime >= this._networkLimitsForVideo.bad.rtt || t.lostPercent >= this._networkLimitsForVideo.bad.loss, i = t.currentRoundTripTime < this._networkLimitsForVideo.bad.rtt, a = this._videoMaxDimensionsForNet.good, o = Er.L1T1;
4396
- if (r ? (this._lastBadConnection = Date.now(), i ? (a = this._videoMaxDimensionsForNet.bad, o = Er.L1T2) : (a = this._videoMaxDimensionsForNet.worst, o = Er.L1T3)) : n && (a = this._videoMaxDimensionsForNet.good, o = Er.L1T1), !(a < this._lastVideoMaxDimension || Date.now() - this._lastBadConnection > Gr) || this._lastVideoMaxDimension === a) return;
4515
+ if (r ? (this._lastBadConnection = Date.now(), i ? (a = this._videoMaxDimensionsForNet.bad, o = Er.L1T2) : (a = this._videoMaxDimensionsForNet.worst, o = Er.L1T3)) : n && (a = this._videoMaxDimensionsForNet.good, o = Er.L1T1), !(a < this._lastVideoMaxDimension || Date.now() - this._lastBadConnection > Qr) || this._lastVideoMaxDimension === a) return;
4397
4516
  let s = this._serverSettings.camera;
4398
4517
  if (!s || !await this._isSVCSupported(e, o)) return;
4399
4518
  this._debug.debug("Switch outbound video frame size and scalabilityMode", {
@@ -4458,9 +4577,9 @@ var Mr = class {
4458
4577
  }, n(r)) : this._debug.error(`[${t}] data channel open failed, state [${e}]`);
4459
4578
  };
4460
4579
  }
4461
- }, qr = /* @__PURE__ */ function(e) {
4580
+ }, ei = /* @__PURE__ */ function(e) {
4462
4581
  return e.AUDIO_MIX = "audio-mix", e.PARTICIPANT_AGNOSTIC_TRACK_PREFIX = "pat", e.TRANSPARENT_AUDIO_TRACK_PREFIX = "ta", e;
4463
- }({}), Jr = 16, Yr = class e {
4582
+ }({}), ti = 16, ni = class e {
4464
4583
  constructor(e, t, n, r = R) {
4465
4584
  h(this, "_datachannel", void 0), h(this, "_participantIdRegistry", void 0), h(this, "_asrCallback", void 0), h(this, "_textDecoder", void 0), h(this, "_debug", void 0), this._debug = r, this._debug.debug("AsrReceiver started"), this._datachannel = e, this._participantIdRegistry = t, this._asrCallback = n, this._textDecoder = new TextDecoder(), this._datachannel.onmessage = (e) => this._onDataChannelMessage(e.data);
4466
4585
  }
@@ -4474,7 +4593,7 @@ var Mr = class {
4474
4593
  ssrc: a,
4475
4594
  timestamp: o,
4476
4595
  duration: s,
4477
- data: e.slice(Jr)
4596
+ data: e.slice(ti)
4478
4597
  };
4479
4598
  }
4480
4599
  _onDataChannelMessage(t) {
@@ -4494,7 +4613,7 @@ var Mr = class {
4494
4613
  destroy() {
4495
4614
  this._datachannel.onmessage = null;
4496
4615
  }
4497
- }, Xr, Zr = class {
4616
+ }, ri, ii = class {
4498
4617
  constructor() {
4499
4618
  h(this, "_value", 1);
4500
4619
  }
@@ -4505,10 +4624,10 @@ var Mr = class {
4505
4624
  this._value = e;
4506
4625
  }
4507
4626
  };
4508
- Xr = Zr, h(Zr, "_instance", null), h(Zr, "getInstance", () => (Xr._instance || (Xr._instance = new Xr()), Xr._instance));
4627
+ ri = ii, h(ii, "_instance", null), h(ii, "getInstance", () => (ri._instance || (ri._instance = new ri()), ri._instance));
4509
4628
  //#endregion
4510
4629
  //#region src/classes/ParticipantIdRegistry.ts
4511
- var Qr = class {
4630
+ var ai = class {
4512
4631
  constructor(e = R) {
4513
4632
  h(this, "streamDescriptionByCompactId", /* @__PURE__ */ new Map()), h(this, "compactIdByStreamDescription", /* @__PURE__ */ new Map()), h(this, "_debug", void 0), this._debug = e;
4514
4633
  }
@@ -4624,7 +4743,7 @@ var Qr = class {
4624
4743
  this._debug.error("unexpected null sequenceNumber", e, r);
4625
4744
  continue;
4626
4745
  }
4627
- let l = qr.PARTICIPANT_AGNOSTIC_TRACK_PREFIX + "-" + e, u = i ? i >>> 0 : null;
4746
+ let l = ei.PARTICIPANT_AGNOSTIC_TRACK_PREFIX + "-" + e, u = i ? i >>> 0 : null;
4628
4747
  n.push({
4629
4748
  participantStreamDescription: c,
4630
4749
  streamId: l,
@@ -4642,7 +4761,7 @@ var Qr = class {
4642
4761
  }
4643
4762
  }, Y = /* @__PURE__ */ function(e) {
4644
4763
  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;
4645
- }({}), $r = class {
4764
+ }({}), oi = class {
4646
4765
  constructor(e = R, t = null) {
4647
4766
  h(this, "_worker", null), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = e, this._logger = t;
4648
4767
  }
@@ -4707,7 +4826,7 @@ var Qr = class {
4707
4826
  static isBrowserSupported() {
4708
4827
  throw Error("Not implemented");
4709
4828
  }
4710
- }, ei = class extends $r {
4829
+ }, si = class extends oi {
4711
4830
  constructor(e = R, t = null) {
4712
4831
  super(e, t);
4713
4832
  }
@@ -4731,7 +4850,7 @@ var Qr = class {
4731
4850
  static isBrowserSupported() {
4732
4851
  return "WebAssembly" in window && "Worker" in window;
4733
4852
  }
4734
- }, ti = class extends $r {
4853
+ }, ci = class extends oi {
4735
4854
  constructor(e = R, t = null) {
4736
4855
  super(e, t);
4737
4856
  }
@@ -4754,7 +4873,7 @@ var Qr = class {
4754
4873
  static isBrowserSupported() {
4755
4874
  return "VideoDecoder" in window && "Worker" in window && "VideoFrame" in window && !T.isBrokenVP9Decoder() && T.browserName() !== "Firefox";
4756
4875
  }
4757
- }, ni = class {
4876
+ }, li = class {
4758
4877
  constructor(e = null, t = 0) {
4759
4878
  h(this, "_counter", 0), h(this, "_interval", 0), h(this, "_lastCalculationTime", Date.now()), h(this, "_onCalculated", null), this._onCalculated = e, t && (this._interval = window.setInterval(() => this.calculate(), t));
4760
4879
  }
@@ -4768,7 +4887,7 @@ var Qr = class {
4768
4887
  destroy() {
4769
4888
  window.clearInterval(this._interval), this._interval = 0;
4770
4889
  }
4771
- }, ri = class {
4890
+ }, ui = class {
4772
4891
  constructor(e, t) {
4773
4892
  h(this, "_participantId", void 0), h(this, "_statAggregator", void 0), h(this, "_firstFrameReceived", !1), this._participantId = e, this._statAggregator = t;
4774
4893
  }
@@ -4783,14 +4902,14 @@ var Qr = class {
4783
4902
  height: t
4784
4903
  });
4785
4904
  }
4786
- }, ii = 65536, ai = "MARK_SCREENSHARE_FREEZE_DURATION", oi = class e {
4905
+ }, di = 65536, fi = "MARK_SCREENSHARE_FREEZE_DURATION", pi = class e {
4787
4906
  constructor(e, t, n, r, i, a = R) {
4788
- h(this, "_participantId", void 0), h(this, "_onStream", void 0), h(this, "_onStat", void 0), h(this, "_onKeyFrameRequested", void 0), h(this, "_statScreenShareFirstFrame", void 0), h(this, "_debug", void 0), h(this, "_chunks", []), this._participantId = e, this._onStream = t, this._onStat = n, this._onKeyFrameRequested = i, this._statScreenShareFirstFrame = new ri(e, r), this._debug = a;
4907
+ h(this, "_participantId", void 0), h(this, "_onStream", void 0), h(this, "_onStat", void 0), h(this, "_onKeyFrameRequested", void 0), h(this, "_statScreenShareFirstFrame", void 0), h(this, "_debug", void 0), h(this, "_chunks", []), this._participantId = e, this._onStream = t, this._onStat = n, this._onKeyFrameRequested = i, this._statScreenShareFirstFrame = new ui(e, r), this._debug = a;
4789
4908
  }
4790
4909
  appendChunk(t) {
4791
4910
  let n = this._chunks.length;
4792
4911
  if (t.start) this._measureFreezeDuration(!1), this._measureFreezeDuration(!0), n && (this._debug.warn("[FrameBuilder] Cleanup buffer", Array.prototype.slice.call(this._chunks)), this._chunks = []);
4793
- else if (!n || (this._chunks[n - 1].sequence + 1) % ii !== t.sequence) {
4912
+ else if (!n || (this._chunks[n - 1].sequence + 1) % di !== t.sequence) {
4794
4913
  this._debug.warn("[FrameBuilder] Got incorrect chunk");
4795
4914
  return;
4796
4915
  }
@@ -4807,7 +4926,7 @@ var Qr = class {
4807
4926
  }
4808
4927
  }
4809
4928
  destroy() {
4810
- W.clearMark(ai), W.clearMark(W.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
4929
+ W.clearMark(fi), W.clearMark(W.getMarkNameScreenshareFirstFrame(this._participantId)), this._chunks = [];
4811
4930
  }
4812
4931
  _processFrameData() {
4813
4932
  let e = this._chunks;
@@ -4830,13 +4949,13 @@ var Qr = class {
4830
4949
  }
4831
4950
  _measureFreezeDuration(e) {
4832
4951
  if (e) {
4833
- W.setMark(ai);
4952
+ W.setMark(fi);
4834
4953
  return;
4835
4954
  }
4836
- let t = W.measureMark(ai);
4955
+ let t = W.measureMark(fi);
4837
4956
  t !== null && t > 1e3 && this._onStat({ freeze_duration: t });
4838
4957
  }
4839
- }, si = class {
4958
+ }, mi = class {
4840
4959
  constructor(e) {
4841
4960
  h(this, "_onStream", void 0), this._onStream = e;
4842
4961
  }
@@ -4849,7 +4968,7 @@ var Qr = class {
4849
4968
  static isBrowserSupported() {
4850
4969
  throw Error("Method `isBrowserSupported` is not implemented");
4851
4970
  }
4852
- }, ci = class extends si {
4971
+ }, hi = class extends mi {
4853
4972
  constructor(e, t = R) {
4854
4973
  super(e), h(this, "_useImageBitmap", void 0), h(this, "_canvas", null), h(this, "_canvasContext", null), h(this, "_stream", null), h(this, "_track", null), h(this, "_debug", void 0), this._debug = t, this._debug.debug("CanvasRenderer started"), this._useImageBitmap = "ImageBitmap" in window;
4855
4974
  }
@@ -4909,7 +5028,7 @@ var Qr = class {
4909
5028
  static isBrowserSupported() {
4910
5029
  return ("CanvasCaptureMediaStream" in window || "CanvasCaptureMediaStreamTrack" in window) && !(T.browserName() === "Safari" && Number(T.browserVersion()) === 15);
4911
5030
  }
4912
- }, li = class extends si {
5031
+ }, gi = class extends mi {
4913
5032
  constructor(e, t = R) {
4914
5033
  super(e), h(this, "_generator", void 0), h(this, "_writer", void 0), h(this, "_stream", void 0), h(this, "_debug", void 0), this._debug = t, this._debug.debug("TrackGeneratorRenderer started"), this._generator = new MediaStreamTrackGenerator({ kind: k.video }), this._writer = this._generator.writable.getWriter(), this._stream = new MediaStream([this._generator]), this._onStream(this._stream);
4915
5034
  }
@@ -4920,9 +5039,9 @@ var Qr = class {
4920
5039
  this._writer.releaseLock(), this._generator.writable.close().then(() => this._generator.stop()), this._debug.debug("TrackGeneratorRenderer destroyed");
4921
5040
  }
4922
5041
  static isBrowserSupported() {
4923
- return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && ti.isBrowserSupported();
5042
+ return "VideoFrame" in window && "MediaStreamTrackGenerator" in window && ci.isBrowserSupported();
4924
5043
  }
4925
- }, ui = class extends oi {
5044
+ }, _i = class extends pi {
4926
5045
  constructor(e, t, n, r, i, a = R, o = null) {
4927
5046
  super(e, t, n, r, i, a), h(this, "_renderer", void 0), h(this, "_decoder", void 0), h(this, "_decoderReady", !1), h(this, "_decoderBusy", !1), h(this, "_decoderQueue", []), h(this, "_webCodecsRetryAttempted", !1), h(this, "_fpsMeter", void 0), h(this, "_logger", void 0), this._logger = o, this._debug.debug(`StreamBuilder started for participant [${e}]`), this._initFpsMeter(), this._initRenderer(), this._initDecoder();
4928
5047
  }
@@ -4930,16 +5049,16 @@ var Qr = class {
4930
5049
  e.keyframe && (this._decoderQueue = []), this._decoderQueue.push(e), this._decodeQueue();
4931
5050
  }
4932
5051
  _initFpsMeter() {
4933
- this._fpsMeter = new ni((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
5052
+ this._fpsMeter = new li((e) => this._debug.log(`[StreamBuilder][${this._participantId}] fps: ${e}`), 2e4);
4934
5053
  }
4935
5054
  _initRenderer(e = !1) {
4936
- e || !li.isBrowserSupported() ? this._renderer = new ci(this._onStream, this._debug) : this._renderer = new li(this._onStream, this._debug);
5055
+ e || !gi.isBrowserSupported() ? this._renderer = new hi(this._onStream, this._debug) : this._renderer = new gi(this._onStream, this._debug);
4937
5056
  }
4938
5057
  _initDecoder(e = !1) {
4939
- e || !ti.isBrowserSupported() ? this._decoder = new ei(this._debug, this._logger) : this._decoder = new ti(this._debug, this._logger), this._decoder.init(async (e) => {
5058
+ e || !ci.isBrowserSupported() ? this._decoder = new si(this._debug, this._logger) : this._decoder = new ci(this._debug, this._logger), this._decoder.init(async (e) => {
4940
5059
  this._decoderBusy = !1, "VideoFrame" in window && e instanceof VideoFrame ? await this._renderer.drawFrame(e) : await this._renderer.drawImage(e), this._fpsMeter.increment(), this._decodeQueue();
4941
5060
  }, (e) => {
4942
- if (this._decoderBusy = !1, this._decoder instanceof ti && typeof e == "string" && e.includes("EncodingError")) {
5061
+ if (this._decoderBusy = !1, this._decoder instanceof ci && typeof e == "string" && e.includes("EncodingError")) {
4943
5062
  this._decoderQueue = [], !this._webCodecsRetryAttempted && e.includes("reset because error during decoding") ? (this._webCodecsRetryAttempted = !0, this._debug.warn("StreamBuilder retry WebCodecs with software decoder"), this._onKeyFrameRequested?.()) : this._switchToLibVPXDecoder();
4944
5063
  return;
4945
5064
  }
@@ -4947,7 +5066,7 @@ var Qr = class {
4947
5066
  }, this._onKeyFrameRequested).then(() => {
4948
5067
  this._decoderReady = !0, this._decodeQueue();
4949
5068
  }).catch((e) => {
4950
- this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof ti && this._switchToLibVPXDecoder();
5069
+ this._debug.warn("StreamBuilder decoder init failed", e), this._decoder instanceof ci && this._switchToLibVPXDecoder();
4951
5070
  });
4952
5071
  }
4953
5072
  _switchToLibVPXDecoder() {
@@ -4962,20 +5081,20 @@ var Qr = class {
4962
5081
  super.destroy(), this._fpsMeter.destroy(), this._decoder.destroy(), this._renderer.destroy(), this._debug.debug(`StreamBuilder destroyed for participant ${this._participantId}`);
4963
5082
  }
4964
5083
  static isBrowserSupported() {
4965
- return ci.isBrowserSupported() || li.isBrowserSupported();
5084
+ return hi.isBrowserSupported() || gi.isBrowserSupported();
4966
5085
  }
4967
- }, di = 1, fi = 1, pi = 2, mi = 0, hi = 1, gi = 2, _i = 4, vi = 8;
4968
- function yi(e, t, n, r, i, a, o) {
5086
+ }, vi = 1, yi = 1, bi = 2, xi = 0, Si = 1, Ci = 2, wi = 4, Ti = 8;
5087
+ function Ei(e, t, n, r, i, a, o) {
4969
5088
  let s = 0;
4970
- t && (s |= hi), n && (s |= gi), r && (s |= _i), o || (s |= vi);
5089
+ t && (s |= Si), n && (s |= Ci), r && (s |= wi), o || (s |= Ti);
4971
5090
  let c = /* @__PURE__ */ new ArrayBuffer(11), l = new DataView(c);
4972
- if (l.setUint8(0, di), l.setUint16(1, i), l.setUint32(3, e), l.setUint8(7, +!!a), l.setUint16(8, mi), l.setUint8(10, s), !o) return c;
5091
+ if (l.setUint8(0, vi), l.setUint16(1, i), l.setUint32(3, e), l.setUint8(7, +!!a), l.setUint16(8, xi), l.setUint8(10, s), !o) return c;
4973
5092
  let u = new Uint8Array(c.byteLength + o.byteLength);
4974
5093
  return u.set(new Uint8Array(c), 0), u.set(new Uint8Array(o), c.byteLength), u.buffer;
4975
5094
  }
4976
- function bi(e) {
4977
- let t = new DataView(e), n = t.getUint8(0), r = t.getUint16(1), i = t.getUint32(3), a = t.getUint8(7) === 1, o = t.getUint16(8), s = t.getUint8(10), c = !!(s & hi), l = !!(s & gi), u = !!(s & _i), d = !!(s & vi);
4978
- if (n !== di) throw Error(`Unexpected protocol version. Got ${n}, expected ${di}`);
5095
+ function Di(e) {
5096
+ let t = new DataView(e), n = t.getUint8(0), r = t.getUint16(1), i = t.getUint32(3), a = t.getUint8(7) === 1, o = t.getUint16(8), s = t.getUint8(10), c = !!(s & Si), l = !!(s & Ci), u = !!(s & wi), d = !!(s & Ti);
5097
+ if (n !== vi) throw Error(`Unexpected protocol version. Got ${n}, expected ${vi}`);
4979
5098
  return {
4980
5099
  timestamp: i,
4981
5100
  start: c,
@@ -4988,26 +5107,26 @@ function bi(e) {
4988
5107
  data: e.slice(11)
4989
5108
  };
4990
5109
  }
4991
- function xi(e) {
5110
+ function Oi(e) {
4992
5111
  if (!e || !e.byteLength || e.byteLength !== 4) return !1;
4993
5112
  let t = new DataView(e);
4994
- return !(t.getUint8(0) !== di || t.getUint8(1) !== fi || t.getUint16(2) !== mi);
5113
+ return !(t.getUint8(0) !== vi || t.getUint8(1) !== yi || t.getUint16(2) !== xi);
4995
5114
  }
4996
- function Si(e) {
5115
+ function ki(e) {
4997
5116
  if (!e || !e.byteLength || e.byteLength !== 10) return null;
4998
5117
  let t = new DataView(e);
4999
- return t.getUint8(0) !== di || t.getUint8(1) !== pi || t.getUint16(2) !== mi ? null : {
5118
+ return t.getUint8(0) !== vi || t.getUint8(1) !== bi || t.getUint16(2) !== xi ? null : {
5000
5119
  seq: t.getUint16(4),
5001
5120
  ts2: t.getUint32(6)
5002
5121
  };
5003
5122
  }
5004
- function Ci(e) {
5123
+ function Ai(e) {
5005
5124
  let t = /* @__PURE__ */ new ArrayBuffer(4), n = new DataView(t);
5006
- return n.setUint8(0, di), n.setUint8(1, fi), n.setUint16(2, e), t;
5125
+ return n.setUint8(0, vi), n.setUint8(1, yi), n.setUint16(2, e), t;
5007
5126
  }
5008
5127
  //#endregion
5009
5128
  //#region src/classes/screenshare/WebmBuilder.ts
5010
- var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5129
+ var ji = 2 ** 15 - 1, Mi = 1, Ni = 5, Pi = 5, Fi = class e {
5011
5130
  constructor(e, t = R) {
5012
5131
  h(this, "_mediaSource", void 0), h(this, "_codec", void 0), h(this, "_sourceBuffer", null), h(this, "_queue", []), h(this, "_clearBufferTill", 0), h(this, "_debug", void 0), this._mediaSource = new MediaSource(), this._codec = e, this._debug = t;
5013
5132
  let n = () => {
@@ -5050,8 +5169,8 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5050
5169
  this._mediaSource?.readyState === "open" && this._sourceBuffer?.abort();
5051
5170
  let e = this._sourceBuffer?.buffered, t = e?.length;
5052
5171
  if (!t) return;
5053
- let n = e.start(0), r = Math.max(0, e.end(t - 1) - Ei);
5054
- r - n > Di && (this._clearBufferTill = r);
5172
+ let n = e.start(0), r = Math.max(0, e.end(t - 1) - Ni);
5173
+ r - n > Pi && (this._clearBufferTill = r);
5055
5174
  }
5056
5175
  destroy() {
5057
5176
  this._queue = [], this._mediaSource.readyState === "open" && (this._sourceBuffer?.abort(), this._mediaSource.endOfStream()), this._sourceBuffer = null, this._clearBufferTill = 0;
@@ -5065,7 +5184,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5065
5184
  get buffered() {
5066
5185
  return this._sourceBuffer?.buffered;
5067
5186
  }
5068
- }, ki = class e extends oi {
5187
+ }, Ii = class e extends pi {
5069
5188
  constructor(e, t, n, r, i = R) {
5070
5189
  super(e, t, n, r, void 0, i), h(this, "_mediaBuffer", null), h(this, "_video", null), h(this, "_stream", null), h(this, "_earliestTimestamp", 0), h(this, "_clusterStartTime", 0), h(this, "_lastFrameTimestamp", 0), this._debug.debug(`[WebmBuilder] started for participant [${e}]`);
5071
5190
  }
@@ -5089,8 +5208,8 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5089
5208
  u.element(u.ID.MuxingApp, u.string("vk-webm-builder")),
5090
5209
  u.element(u.ID.WritingApp, u.string("vk-webm-builder"))
5091
5210
  ]), i = [u.element(u.ID.PixelWidth, u.number(e)), u.element(u.ID.PixelHeight, u.number(t))], a = u.element(u.ID.Tracks, u.element(u.ID.TrackEntry, [
5092
- u.element(u.ID.TrackNumber, u.number(Ti)),
5093
- u.element(u.ID.TrackUID, u.number(Ti)),
5211
+ u.element(u.ID.TrackNumber, u.number(Mi)),
5212
+ u.element(u.ID.TrackUID, u.number(Mi)),
5094
5213
  u.element(u.ID.TrackType, u.number(1)),
5095
5214
  u.element(u.ID.FlagLacing, u.number(0)),
5096
5215
  u.element(u.ID.DefaultDuration, u.number(1e9)),
@@ -5103,7 +5222,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5103
5222
  return u.unknownSizeElement(u.ID.Cluster, [u.element(u.ID.Timecode, u.number(Math.round(e)))]);
5104
5223
  }
5105
5224
  _createVideo(e) {
5106
- this._mediaBuffer = new Oi(e, this._debug), this._video = document.createElement("video"), this._video.autoplay = !0, this._video.controls = !1, this._video.muted = !0, this._video.style.pointerEvents = "none", this._video.style.visibility = "hidden", this._video.style.position = "absolute", this._video.style.width = "160px", this._video.style.height = "90px", this._video.style.bottom = "0", this._video.style.right = "0", this._video.style.zIndex = "5000", this._video.src = URL.createObjectURL(this._mediaBuffer.mediaSource), document.body.appendChild(this._video);
5225
+ this._mediaBuffer = new Fi(e, this._debug), this._video = document.createElement("video"), this._video.autoplay = !0, this._video.controls = !1, this._video.muted = !0, this._video.style.pointerEvents = "none", this._video.style.visibility = "hidden", this._video.style.position = "absolute", this._video.style.width = "160px", this._video.style.height = "90px", this._video.style.bottom = "0", this._video.style.right = "0", this._video.style.zIndex = "5000", this._video.src = URL.createObjectURL(this._mediaBuffer.mediaSource), document.body.appendChild(this._video);
5107
5226
  let t = () => {
5108
5227
  if (this._video?.src) {
5109
5228
  this._debug.warn(`[WebmBuilder] Video paused for participant [${this._participantId}], try to play again`);
@@ -5130,13 +5249,13 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5130
5249
  this._mediaBuffer?.append(a);
5131
5250
  }
5132
5251
  let i = Math.round(r - this._clusterStartTime);
5133
- if (i > wi && (this._clusterStartTime = r, i = 0), i === 0) {
5252
+ if (i > ji && (this._clusterStartTime = r, i = 0), i === 0) {
5134
5253
  this._debug.debug(`[WebmBuilder] Cluster header for participant [${this._participantId}]`);
5135
5254
  let t = e._genClusterHeader(this._clusterStartTime);
5136
5255
  this._mediaBuffer?.append(t);
5137
5256
  }
5138
5257
  let a = u.element(u.ID.SimpleBlock, [
5139
- u.vintEncodedNumber(Ti),
5258
+ u.vintEncodedNumber(Mi),
5140
5259
  u.bytes(e._intToU16BE(i)),
5141
5260
  u.number(!!t.keyframe << 7),
5142
5261
  u.bytes(t.frameData)
@@ -5149,12 +5268,12 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5149
5268
  static isBrowserSupported() {
5150
5269
  return "captureStream" in window.HTMLVideoElement?.prototype && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp8\"") && window.MediaSource?.isTypeSupported("video/webm; codecs=\"vp9\"");
5151
5270
  }
5152
- }, Ai = class {
5271
+ }, Li = class {
5153
5272
  constructor(e, t, n, r, i, a = null, o = R, s = null) {
5154
5273
  h(this, "_datachannel", void 0), h(this, "_participantIdRegistry", null), h(this, "_streamBuilders", {}), h(this, "_onStream", () => {}), h(this, "_onEos", () => {}), h(this, "_onStat", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), this._debug = o, this._logger = s, this._statAggregator = a, this._debug.debug("ScreenCaptureReceiver started"), this._datachannel = e, this._participantIdRegistry = t, this._onStream = n, this._onEos = r, this._onStat = i, this._datachannel.onmessage = (e) => this._onDataChannelMessage(e.data);
5155
5274
  }
5156
5275
  _onDataChannelMessage(e) {
5157
- let t = bi(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5276
+ let t = Di(e), n = this._participantIdRegistry?.getStreamDescription(t.ssrc)?.participantId;
5158
5277
  if (!n) {
5159
5278
  this._debug.warn(`Participant id for ssrc ${t.ssrc} not found in registry`);
5160
5279
  return;
@@ -5166,7 +5285,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5166
5285
  let r = this._streamBuilders[n];
5167
5286
  if (!r) {
5168
5287
  let e = (e) => this._onStream(n, e);
5169
- r = M.screenShareWebmBuilder && ki.isBrowserSupported() ? new ki(n, e, this._onStat, this._statAggregator, this._debug) : new ui(n, e, this._onStat, this._statAggregator, () => {
5288
+ r = M.screenShareWebmBuilder && Ii.isBrowserSupported() ? new Ii(n, e, this._onStat, this._statAggregator, this._debug) : new _i(n, e, this._onStat, this._statAggregator, () => {
5170
5289
  this._requestKeyFrame(t.ssrc);
5171
5290
  }, this._debug, this._logger), this._streamBuilders[n] = r;
5172
5291
  }
@@ -5174,7 +5293,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5174
5293
  }
5175
5294
  _requestKeyFrame(e) {
5176
5295
  if (!(!this._datachannel || this._datachannel.readyState !== "open")) try {
5177
- let t = Ci(e);
5296
+ let t = Ai(e);
5178
5297
  this._datachannel.send(t), this._debug.debug(`ScreenCaptureReceiver request for keyframe for ssrc ${e}`);
5179
5298
  } catch (e) {
5180
5299
  this._debug.warn("Failed to send keyframe request", e);
@@ -5187,7 +5306,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5187
5306
  destroy() {
5188
5307
  this._datachannel.onbufferedamountlow = null, this._datachannel.onmessage = null, this._onStream = () => {}, Object.values(this._streamBuilders).forEach((e) => e.destroy()), this._streamBuilders = {}, this._participantIdRegistry = null, this._debug.debug("ScreenCaptureReceiver destroyed");
5189
5308
  }
5190
- }, ji = class {
5309
+ }, Ri = class {
5191
5310
  constructor(e, t, n) {
5192
5311
  h(this, "_prev", void 0), h(this, "_next", void 0), h(this, "_data", void 0), this._next = n, n && (n.prev = this), this._prev = t, t && (t.next = this), this._data = e;
5193
5312
  }
@@ -5206,7 +5325,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5206
5325
  get data() {
5207
5326
  return this._data;
5208
5327
  }
5209
- }, Mi = class {
5328
+ }, zi = class {
5210
5329
  constructor() {
5211
5330
  h(this, "_head", null), h(this, "_tail", null), h(this, "_length", 0);
5212
5331
  }
@@ -5214,7 +5333,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5214
5333
  return this._length;
5215
5334
  }
5216
5335
  push(...e) {
5217
- for (let t of e) this._tail = new ji(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5336
+ for (let t of e) this._tail = new Ri(t, this._tail, null), this._head || (this._head = this._tail), this._length++;
5218
5337
  }
5219
5338
  merge(e) {
5220
5339
  this._tail && (this._tail.next = e._head), this._head || (this._head = e._head), this._tail = e._tail, this._length += e._length, e.clear();
@@ -5244,7 +5363,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5244
5363
  for (; t !== null;) e.push(t.data), t = t.next;
5245
5364
  return e.length ? JSON.stringify(e, (e, t) => t instanceof Error ? String(t) : t) : "";
5246
5365
  }
5247
- }, Ni = 1e3, Pi = class extends $r {
5366
+ }, Bi = 1e3, Vi = class extends oi {
5248
5367
  constructor(e, t, n, r, i = R, a = null) {
5249
5368
  super(i, a), h(this, "_sourceTrack", void 0), h(this, "_onFrame", void 0), h(this, "_useCongestionControl", void 0), h(this, "_maxBitrate", void 0), h(this, "_useImageCapture", void 0), h(this, "_video", null), h(this, "_imageCapture", null), h(this, "_canvas", null), h(this, "_canvasCtx", null), h(this, "_frameReadTimeout", 0), h(this, "_lastFrame", null), this._sourceTrack = e, this._onFrame = t, this._useCongestionControl = n, this._maxBitrate = r, this._useImageCapture = "ImageCapture" in window && ImageCapture.prototype.grabFrame !== void 0 && "ImageBitmap" in window, (e.readyState !== "live" || !e.enabled || e.muted) && (this._useImageCapture = !1);
5250
5369
  }
@@ -5330,7 +5449,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5330
5449
  let t = this._drawFrameData(this._lastFrame);
5331
5450
  this._encode(t, e);
5332
5451
  } else this._onFrame(null);
5333
- }, Ni), this._getFrameBitmap().then((t) => {
5452
+ }, Bi), this._getFrameBitmap().then((t) => {
5334
5453
  window.clearTimeout(this._frameReadTimeout), this._lastFrame?.close(), this._lastFrame = t;
5335
5454
  let n = this._drawFrameData(t);
5336
5455
  this._encode(n, e);
@@ -5351,7 +5470,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5351
5470
  destroy() {
5352
5471
  this._removeWorker(), this._removeStream(), this._removeDom(), this._debug.debug("LibVPxEncoder destroyed");
5353
5472
  }
5354
- }, Fi = class extends $r {
5473
+ }, Hi = class extends oi {
5355
5474
  constructor(e, t, n, r, i, a, o = R, s = null) {
5356
5475
  super(o, s), h(this, "_sourceTrack", void 0), h(this, "_trackProcessor", void 0), h(this, "_onFrame", void 0), h(this, "_useCongestionControl", void 0), h(this, "_maxBitrate", void 0), h(this, "_useCbr", void 0), h(this, "_frameRate", void 0), this._sourceTrack = e, this._onFrame = t, this._useCongestionControl = n, this._maxBitrate = r, this._useCbr = i, this._frameRate = a, this._trackProcessor = new MediaStreamTrackProcessor({ track: e });
5357
5476
  }
@@ -5397,11 +5516,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5397
5516
  static isBrowserSupported() {
5398
5517
  return "VideoEncoder" in window && "Worker" in window && "EncodedVideoChunk" in window && "MediaStreamTrackProcessor" in window;
5399
5518
  }
5400
- }, Ii = 2100, Li = 600, Ri = 1.2, zi = .8, Bi = 2e3, Vi = 8e3, Hi = 8e3, Ui = 16e3, Wi = 4, Gi = 2e3, Ki = /* @__PURE__ */ function(e) {
5519
+ }, Ui = 2100, Wi = 600, Gi = 1.2, Ki = .8, qi = 2e3, Ji = 8e3, Yi = 8e3, Xi = 16e3, Zi = 4, Qi = 2e3, $i = /* @__PURE__ */ function(e) {
5401
5520
  return e[e.NONE = 0] = "NONE", e[e.UP = 1] = "UP", e[e.DOWN = 2] = "DOWN", e;
5402
- }(Ki || {}), qi = class {
5521
+ }($i || {}), ea = class {
5403
5522
  constructor(e, t, n, r, i, a, o, s = R) {
5404
- h(this, "_onCongestion", void 0), h(this, "_ccEnabled", void 0), h(this, "_fastSharing", void 0), h(this, "_trendDelayThreshold", void 0), h(this, "_highDelayThreshold", void 0), h(this, "_targetFps", void 0), h(this, "_minBitrate", void 0), h(this, "_maxBitrate", void 0), h(this, "_targetBitrate", void 0), h(this, "_lastDown", void 0), h(this, "_lastUp", void 0), h(this, "_lastProbing", void 0), h(this, "_lastCheckDelay", void 0), h(this, "_upPenalty", 0), h(this, "_probing", void 0), h(this, "_delayAvgShort", -1), h(this, "_delayAvgLong", -1), h(this, "_minDelay", Number.MAX_VALUE), h(this, "_maxDelay", 0), h(this, "_largeDelayDuration", 0), h(this, "_lastFpsCalcMs", void 0), h(this, "_frames", 0), h(this, "_fps", 0), h(this, "_debug", void 0), this._onCongestion = e, this._ccEnabled = r, this._debug = s, this._minBitrate = t, this._maxBitrate = n, this._fastSharing = i, this._targetFps = o, a > 0 ? this._highDelayThreshold = a : this._highDelayThreshold = Ii, i && (this._highDelayThreshold = Li), this._trendDelayThreshold = Math.round(this._highDelayThreshold / 3), this._targetBitrate = this._maxBitrate, this._probing = !1;
5523
+ h(this, "_onCongestion", void 0), h(this, "_ccEnabled", void 0), h(this, "_fastSharing", void 0), h(this, "_trendDelayThreshold", void 0), h(this, "_highDelayThreshold", void 0), h(this, "_targetFps", void 0), h(this, "_minBitrate", void 0), h(this, "_maxBitrate", void 0), h(this, "_targetBitrate", void 0), h(this, "_lastDown", void 0), h(this, "_lastUp", void 0), h(this, "_lastProbing", void 0), h(this, "_lastCheckDelay", void 0), h(this, "_upPenalty", 0), h(this, "_probing", void 0), h(this, "_delayAvgShort", -1), h(this, "_delayAvgLong", -1), h(this, "_minDelay", Number.MAX_VALUE), h(this, "_maxDelay", 0), h(this, "_largeDelayDuration", 0), h(this, "_lastFpsCalcMs", void 0), h(this, "_frames", 0), h(this, "_fps", 0), h(this, "_debug", void 0), this._onCongestion = e, this._ccEnabled = r, this._debug = s, this._minBitrate = t, this._maxBitrate = n, this._fastSharing = i, this._targetFps = o, a > 0 ? this._highDelayThreshold = a : this._highDelayThreshold = Ui, i && (this._highDelayThreshold = Wi), this._trendDelayThreshold = Math.round(this._highDelayThreshold / 3), this._targetBitrate = this._maxBitrate, this._probing = !1;
5405
5524
  let c = Date.now();
5406
5525
  this._lastDown = 0, this._lastUp = c, this._lastProbing = c, this._lastCheckDelay = 0, this._lastFpsCalcMs = 0;
5407
5526
  }
@@ -5411,27 +5530,27 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5411
5530
  let i = 0, a = this._delayAvgShort - this._delayAvgLong, o = Math.round(Math.abs(a) * 100 / this._delayAvgLong), s = a > 40 && o > 30 && this._delayAvgShort > this._trendDelayThreshold, c = this._delayAvgShort > this._highDelayThreshold;
5412
5531
  s || c ? i = 2 : Math.abs(a) < 40 && o < 10 && !c && (i = 1);
5413
5532
  let l = Math.round(this._targetBitrate / 1e3), u = n;
5414
- e % 20 == 0 && this._debug.debug(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Ki[i]} tr=${l} br=${n}`);
5533
+ e % 20 == 0 && this._debug.debug(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${$i[i]} tr=${l} br=${n}`);
5415
5534
  let d = r - this._lastDown;
5416
- if (i === 2 && d > Bi) {
5417
- this._probing && (this._upPenalty = Math.min(++this._upPenalty, Wi), this._probing = !1);
5418
- let n = zi * u * 1e3;
5419
- if (n >= this._targetBitrate && (n = this._targetBitrate * zi), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
5420
- let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * Hi / 1e3);
5421
- this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Ki[i]}`), this._debug.log(`#${e}: cc: DOWN delay=${t} bitrate=${u} target=${l} -> newBitrate=${r} penalty=${s}s`), this._setBitrate(n, !0), this._targetBitrate = n;
5535
+ if (i === 2 && d > qi) {
5536
+ this._probing && (this._upPenalty = Math.min(++this._upPenalty, Zi), this._probing = !1);
5537
+ let n = Ki * u * 1e3;
5538
+ if (n >= this._targetBitrate && (n = this._targetBitrate * Ki), n = Math.max(n, this._minBitrate), n < this._targetBitrate) {
5539
+ let r = Math.round(n / 1e3), s = Math.round(this._upPenalty * Yi / 1e3);
5540
+ this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${$i[i]}`), this._debug.log(`#${e}: cc: DOWN delay=${t} bitrate=${u} target=${l} -> newBitrate=${r} penalty=${s}s`), this._setBitrate(n, !0), this._targetBitrate = n;
5422
5541
  }
5423
5542
  this._lastDown = r;
5424
5543
  }
5425
- let f = r - this._lastUp, p = Vi + this._upPenalty * Hi;
5544
+ let f = r - this._lastUp, p = Ji + this._upPenalty * Yi;
5426
5545
  if (i === 1 && f > p && d > p) {
5427
- let n = Math.min(this._targetBitrate * Ri, this._maxBitrate);
5546
+ let n = Math.min(this._targetBitrate * Gi, this._maxBitrate);
5428
5547
  if (n > this._targetBitrate) {
5429
- let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty * Hi / 1e3);
5430
- this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${Ki[i]}`), this._debug.log(`#${e}: cc: UP bitrate=${u} target=${c} -> newBitrate=${s} penalty=${l}s`), this._setBitrate(n, !1), this._targetBitrate = n, this._probing = !0, this._lastProbing = r, this._lastUp = r;
5548
+ let s = Math.round(n / 1e3), c = Math.round(this._targetBitrate / 1e3), l = Math.round(this._upPenalty * Yi / 1e3);
5549
+ this._debug.log(`#${e}: cc: delay=${t} short=${this._delayAvgShort} long=${this._delayAvgLong} delta=${a} percent=${o} -> ${$i[i]}`), this._debug.log(`#${e}: cc: UP bitrate=${u} target=${c} -> newBitrate=${s} penalty=${l}s`), this._setBitrate(n, !1), this._targetBitrate = n, this._probing = !0, this._lastProbing = r, this._lastUp = r;
5431
5550
  }
5432
5551
  }
5433
5552
  let m = r - this._lastProbing;
5434
- this._probing && m > Ui && (this._probing = !1);
5553
+ this._probing && m > Xi && (this._probing = !1);
5435
5554
  let ee = r - this._lastDown;
5436
5555
  this._upPenalty > 0 && ee > 3 * p && (this._debug.log(`#${e}: cc: UP reset penalty: oldPenalty=${this._upPenalty}`), this._upPenalty = 0);
5437
5556
  }
@@ -5442,7 +5561,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5442
5561
  }
5443
5562
  _calcDelay(e, t) {
5444
5563
  if (!(e <= 0)) {
5445
- if (this._delayAvgShort === -1 && (this._delayAvgShort = e, this._delayAvgLong = e), this._delayAvgShort = Math.round((this._delayAvgShort * 3 + e) / 4), this._delayAvgLong = Math.round((this._delayAvgLong * 23 + e) / 24), e > 0 && e < this._minDelay ? this._minDelay = e : e > this._maxDelay && (this._maxDelay = e), this._lastCheckDelay === 0 && (this._lastCheckDelay = t), e > Gi) {
5564
+ if (this._delayAvgShort === -1 && (this._delayAvgShort = e, this._delayAvgLong = e), this._delayAvgShort = Math.round((this._delayAvgShort * 3 + e) / 4), this._delayAvgLong = Math.round((this._delayAvgLong * 23 + e) / 24), e > 0 && e < this._minDelay ? this._minDelay = e : e > this._maxDelay && (this._maxDelay = e), this._lastCheckDelay === 0 && (this._lastCheckDelay = t), e > Qi) {
5446
5565
  let e = t - this._lastCheckDelay;
5447
5566
  this._largeDelayDuration += e;
5448
5567
  }
@@ -5471,7 +5590,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5471
5590
  this._fps === 0 ? this._fps = Math.round(r) : this._fps = Math.round((this._fps * 3 + r) / 4), this._frames = 0, this._fps !== n && this._debug.log(`cc: fps=${this._fps}`);
5472
5591
  }
5473
5592
  }
5474
- }, Ji = class {
5593
+ }, ta = class {
5475
5594
  constructor(e) {
5476
5595
  h(this, "_maxSize", void 0), h(this, "_size", 0), h(this, "_buffer", void 0), h(this, "_head", 0), h(this, "_tail", 0), this._maxSize = e, this._buffer = Array(e);
5477
5596
  }
@@ -5545,11 +5664,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5545
5664
  clear() {
5546
5665
  this._buffer.fill(void 0), this._size = 0, this._head = 0, this._tail = 0;
5547
5666
  }
5548
- }, Yi = 65536, Xi = 50, Zi = 400, Qi = 1e6, $i = 3e5, ea = 3e4, ta = 2e3, na = 5, ra = 0, ia = class {
5667
+ }, na = 65536, ra = 50, ia = 400, aa = 1e6, oa = 3e5, sa = 3e4, ca = 2e3, la = 5, ua = 0, da = class {
5549
5668
  constructor(e, t, n, r, i = R, a = null) {
5550
- h(this, "_encoder", void 0), h(this, "_datachannel", void 0), h(this, "_signaling", void 0), h(this, "_fastSharing", void 0), h(this, "_destroyed", !1), h(this, "_needKeyframe", !0), h(this, "DATA_SIZE", void 0), h(this, "_congestionControl", void 0), h(this, "_frameNum", 0), h(this, "_width", void 0), h(this, "_height", void 0), h(this, "_feedback", new Ji(1024)), h(this, "_lastSentFrameSeq", 0), h(this, "_lastDeliveredFrameSeq", 0), h(this, "_lastFrameDelay", 0), h(this, "_lastFramerateReduced", Date.now()), h(this, "_lastSharingStat", Date.now()), h(this, "_congestionControlEnabled", void 0), h(this, "_queue", new Mi()), h(this, "_fpsMeter", void 0), h(this, "_maxFrameDelay", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = i, this._logger = a, this._debug.debug("ScreenCaptureSender started"), this.DATA_SIZE = M.consumerScreenDataChannelPacketSize - 11, this._datachannel = t, this._signaling = n, this._fastSharing = r, this._congestionControlEnabled = M.screenShareCongestionControl || this._fastSharing, this._width = e.getSettings().width, this._height = e.getSettings().height, this._maxFrameDelay = this._fastSharing ? M.screenShareCongestionControlThreshold : M.screenShareCongestionControlThreshold * 2;
5669
+ h(this, "_encoder", void 0), h(this, "_datachannel", void 0), h(this, "_signaling", void 0), h(this, "_fastSharing", void 0), h(this, "_destroyed", !1), h(this, "_needKeyframe", !0), h(this, "DATA_SIZE", void 0), h(this, "_congestionControl", void 0), h(this, "_frameNum", 0), h(this, "_width", void 0), h(this, "_height", void 0), h(this, "_feedback", new ta(1024)), h(this, "_lastSentFrameSeq", 0), h(this, "_lastDeliveredFrameSeq", 0), h(this, "_lastFrameDelay", 0), h(this, "_lastFramerateReduced", Date.now()), h(this, "_lastSharingStat", Date.now()), h(this, "_congestionControlEnabled", void 0), h(this, "_queue", new zi()), h(this, "_fpsMeter", void 0), h(this, "_maxFrameDelay", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._debug = i, this._logger = a, this._debug.debug("ScreenCaptureSender started"), this.DATA_SIZE = M.consumerScreenDataChannelPacketSize - 11, this._datachannel = t, this._signaling = n, this._fastSharing = r, this._congestionControlEnabled = M.screenShareCongestionControl || this._fastSharing, this._width = e.getSettings().width, this._height = e.getSettings().height, this._maxFrameDelay = this._fastSharing ? M.screenShareCongestionControlThreshold : M.screenShareCongestionControlThreshold * 2;
5551
5670
  let o = M.getScreenFrameRate(this._fastSharing), { minBitrate: s, maxBitrate: c } = this._calcMinMaxBitrate(this._width, this._height), l = this._onCongestionCallback.bind(this);
5552
- this._debug.log(`ScreenCaptureSender: CongestionControl: enabled=${this._congestionControlEnabled} minBitrate=${Math.round(s / 1e3)}k maxBitrate=${Math.round(c / 1e3)}k delayThreshold=${M.screenShareCongestionControlThreshold}`), this._congestionControl = new qi(l, s, c, this._congestionControlEnabled, this._fastSharing, M.screenShareCongestionControlThreshold, o, this._debug);
5671
+ this._debug.log(`ScreenCaptureSender: CongestionControl: enabled=${this._congestionControlEnabled} minBitrate=${Math.round(s / 1e3)}k maxBitrate=${Math.round(c / 1e3)}k delayThreshold=${M.screenShareCongestionControlThreshold}`), this._congestionControl = new ea(l, s, c, this._congestionControlEnabled, this._fastSharing, M.screenShareCongestionControlThreshold, o, this._debug);
5553
5672
  let u = (e, t) => {
5554
5673
  if (this._destroyed) return;
5555
5674
  if (!e) {
@@ -5560,23 +5679,23 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5560
5679
  let n = this._sliceFrame(e);
5561
5680
  this._queue.merge(n), this._handleQueue(), this._sendSharingStat();
5562
5681
  };
5563
- if (Fi.isBrowserSupported()) {
5682
+ if (Hi.isBrowserSupported()) {
5564
5683
  let t = this._fastSharing;
5565
- this._encoder = new Fi(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
5566
- } else this._encoder = new Pi(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
5684
+ this._encoder = new Hi(e, u, this._congestionControlEnabled, c, t, o, this._debug, this._logger);
5685
+ } else this._encoder = new Vi(e, u, this._congestionControlEnabled, c, this._debug, this._logger);
5567
5686
  this._datachannel.onmessage = (e) => {
5568
- xi(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
5569
- let t = Si(e.data);
5687
+ Oi(e.data) && (this._debug.debug(`[${this._datachannel.label}] Requested keyframe`), this._needKeyframe = !0);
5688
+ let t = ki(e.data);
5570
5689
  t !== null && this._checkCcFeedback(t);
5571
- }, this._encoder.init().then(() => this._handleQueue()).catch((e) => this._debug.warn("ScreenCaptureSender init failed", e)), this._fpsMeter = new ni((e) => this._debug.log(`[ScreenCaptureSender] fps: ${e}`), 5e3);
5690
+ }, this._encoder.init().then(() => this._handleQueue()).catch((e) => this._debug.warn("ScreenCaptureSender init failed", e)), this._fpsMeter = new li((e) => this._debug.log(`[ScreenCaptureSender] fps: ${e}`), 5e3);
5572
5691
  }
5573
5692
  _handleQueue() {
5574
5693
  if (this._destroyed) return;
5575
5694
  let e = this._queue.shift();
5576
5695
  if (!e) {
5577
- if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + Yi) % Yi > na && this._lastFrameDelay > this._maxFrameDelay) {
5696
+ if ((this._lastSentFrameSeq - this._lastDeliveredFrameSeq + na) % na > la && this._lastFrameDelay > this._maxFrameDelay) {
5578
5697
  let e = Date.now();
5579
- e - this._lastFramerateReduced > ta && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5698
+ e - this._lastFramerateReduced > ca && (this._lastFramerateReduced = e, this._debug.debug(`[ScreenCaptureSender] reduce framerate: delay=${this._lastFrameDelay} maxDelay=${this._maxFrameDelay}`));
5580
5699
  } else this._requestFrame();
5581
5700
  return;
5582
5701
  }
@@ -5602,7 +5721,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5602
5721
  this._destroyed || (this._encoder.requestFrame(this._needKeyframe), this._needKeyframe = !1);
5603
5722
  }
5604
5723
  _sliceFrame(e) {
5605
- let t = e.type === "key", n = e.data.byteLength, r = new Mi();
5724
+ let t = e.type === "key", n = e.data.byteLength, r = new zi();
5606
5725
  for (let i = 0; i < n; i += this.DATA_SIZE) {
5607
5726
  let a = e.data.slice(i, i + this.DATA_SIZE), o = i === 0, s = n <= i + a.byteLength, c = this._wrapHeader(e.timestamp, o, s, t, a);
5608
5727
  r.push({
@@ -5618,11 +5737,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5618
5737
  return r;
5619
5738
  }
5620
5739
  _wrapHeader(e, t, n, r, i) {
5621
- let a = yi(e, t, n, r, ra, this._encoder.isVP9(), i), o = {
5622
- sequence: ra,
5740
+ let a = Ei(e, t, n, r, ua, this._encoder.isVP9(), i), o = {
5741
+ sequence: ua,
5623
5742
  data: a
5624
5743
  };
5625
- return ra = (ra + 1) % Yi, o;
5744
+ return ua = (ua + 1) % na, o;
5626
5745
  }
5627
5746
  _stopPacket() {
5628
5747
  return this._wrapHeader(Date.now(), !1, !1, !1, null).data;
@@ -5639,7 +5758,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5639
5758
  this._queue.clear(), this._fpsMeter.destroy(), this._datachannel.onmessage = null, this._feedback.clear(), this._datachannel.readyState === "open" && this._datachannel.send(this._stopPacket()), this._destroyed = !0, this._encoder.destroy(), this._debug.debug("ScreenCaptureSender destroyed");
5640
5759
  }
5641
5760
  static isBrowserSupported() {
5642
- return Fi.isBrowserSupported() || Pi.isBrowserSupported();
5761
+ return Hi.isBrowserSupported() || Vi.isBrowserSupported();
5643
5762
  }
5644
5763
  _onCongestionCallback(e, t, n) {
5645
5764
  this._encoder.setBitrate(e, t, n);
@@ -5652,8 +5771,8 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5652
5771
  (e === void 0 || e < 640) && (e = 640), (t === void 0 || t < 360) && (t = 360);
5653
5772
  let n = e * t / 256;
5654
5773
  return {
5655
- minBitrate: Math.max($i, Math.min(Qi, Math.round(n * Xi))),
5656
- maxBitrate: Math.round(n * Zi)
5774
+ minBitrate: Math.max(oa, Math.min(aa, Math.round(n * ra))),
5775
+ maxBitrate: Math.round(n * ia)
5657
5776
  };
5658
5777
  }
5659
5778
  _checkCcFeedback(e) {
@@ -5667,14 +5786,14 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5667
5786
  }
5668
5787
  _sendSharingStat() {
5669
5788
  let e = Date.now();
5670
- if (e - this._lastSharingStat > ea) {
5789
+ if (e - this._lastSharingStat > sa) {
5671
5790
  let t = this._congestionControl.getStat();
5672
5791
  t !== null && (this._debug.debug(`cc: send stats: ${JSON.stringify(t)}`), this._signaling.reportSharingStat(t).catch((e) => {
5673
5792
  !(e instanceof wn) && !(e instanceof Tn) && this._debug.warn("Unable to send sharing stats", e);
5674
5793
  })), this._lastSharingStat = e;
5675
5794
  }
5676
5795
  }
5677
- }, aa = class {
5796
+ }, fa = class {
5678
5797
  constructor(e, t, n, r = R, i = null) {
5679
5798
  h(this, "_pc", null), h(this, "_transceiver", null), h(this, "_currentSimulcastInfo", null), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_getCameraSettings", void 0), h(this, "_debug", void 0), h(this, "_logger", void 0), this._signaling = e, this._mediaSource = t, this._getCameraSettings = n, this._debug = r, this._logger = i;
5680
5799
  }
@@ -5806,9 +5925,9 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5806
5925
  if (!(e instanceof Tn)) throw e;
5807
5926
  }
5808
5927
  }
5809
- }, oa = 90, sa = 4294967295, ca = class e extends Nr {
5928
+ }, pa = 90, ma = 4294967295, ha = class e extends Br {
5810
5929
  constructor(e, t, n, r = R, i = null, a = null, o = null, s = null) {
5811
- 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, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_simulcast", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._codecStatsAggregator = o, this._serverSettings = n, this._simulcast = new aa(e, t, () => this._serverSettings.camera, r, i), this.subscribe(this._signaling, G.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, qt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, qt.SOURCE_CHANGED, this._onSourcesChanged.bind(this)), this.subscribe(this._mediaSource, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._createPerfStatsReporter(), this._debug.debug("ServerTransport: Created");
5930
+ 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, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_sdpStats", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_simulcast", void 0), this._debug = r, this._logger = i, this._statAggregator = a, this._sdpStats = new Pr(a), this._codecStatsAggregator = o, this._serverSettings = n, this._simulcast = new fa(e, t, () => this._serverSettings.camera, r, i), this.subscribe(this._signaling, G.NOTIFICATION, this._onSignalingNotification.bind(this)), this.subscribe(this._mediaSource, qt.TRACK_REPLACED, this._onReplacedTrack.bind(this)), this.subscribe(this._mediaSource, qt.SOURCE_CHANGED, this._onSourcesChanged.bind(this)), this.subscribe(this._mediaSource, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._createPerfStatsReporter(), this._debug.debug("ServerTransport: Created");
5812
5931
  }
5813
5932
  updateStatisticsInterval() {
5814
5933
  this._stopStatInterval();
@@ -5847,10 +5966,10 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5847
5966
  await this._simulcast.sync();
5848
5967
  }
5849
5968
  _createPerfStatsReporter() {
5850
- this._perfStatReporter?.destroy(), this._perfStatReporter = new pa(this, this._signaling, this._statAggregator, !1, this._debug);
5969
+ this._perfStatReporter?.destroy(), this._perfStatReporter = new ba(this, this._signaling, this._statAggregator, !1, this._debug);
5851
5970
  }
5852
5971
  _closeConnection() {
5853
- this._signaling.resetProducerConnection(), this._ssrcMap = {}, this._ssrcMapUpdated = !0, this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcast.reset(), this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._participantIdRegistry = null, e._closeDataChannel(this._producerNotification), e._closeDataChannel(this._producerCommand), e._closeDataChannel(this._producerScreen), e._closeDataChannel(this._consumerScreen), e._closeDataChannel(this._asr), e._closeDataChannel(this._animojiDataChannel), this._pc.close(), this._pc = null, this._producerOfferIsProcessing = !1, this._producerNextOffer = null), this._triggerEvent(X.PEER_CONNECTION_CLOSED);
5972
+ this._signaling.resetProducerConnection(), this._ssrcMap = {}, this._ssrcMapUpdated = !0, this._disposeFirstMediaSentProbe(), this._stopStatInterval(), this._stopSettingsInterval(), this._stopMonitorRtpShareInterval(), this._removeAsrTrack(), this._removeCaptureSender(), this._removeCaptureReceiver(), this._simulcast.reset(), this._pc && (this._rtpReceiversByStreamId = {}, this._disabledSenders.forEach((e) => e.track?.stop()), this._disabledSenders.clear(), this._pc.ontrack = null, this._pc.onconnectionstatechange = null, this._pc.onsignalingstatechange = null, this._sdpStats.stop(), 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);
5854
5973
  }
5855
5974
  static _closeDataChannel(e) {
5856
5975
  e && (e.onopen = null, e.onmessage = null, e.onerror = null, e.close());
@@ -5876,14 +5995,14 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5876
5995
  }
5877
5996
  this._pc.ontrack = this._onAddTrack.bind(this, this._pc), this._pc.onconnectionstatechange = j.debounce((e) => {
5878
5997
  this._pc && this._onConnectionStateChange(this._pc, e);
5879
- }, 500), this._pc.onsignalingstatechange = this._onSignalingStateChange.bind(this, this._pc), this._participantIdRegistry = new Qr(this._debug), this._signaling.setParticipantIdRegistry(this._participantIdRegistry), this._createDataChannel(this._pc, Sr.producerNotification, (e) => {
5998
+ }, 500), this._pc.onsignalingstatechange = this._onSignalingStateChange.bind(this, this._pc), this._sdpStats.observe(this._pc), this._participantIdRegistry = new ai(this._debug), this._signaling.setParticipantIdRegistry(this._participantIdRegistry), this._createDataChannel(this._pc, Sr.producerNotification, (e) => {
5880
5999
  this._producerNotification = e, this._producerNotification.binaryType = "arraybuffer", this._signaling.setProducerNotificationDataChannel(e);
5881
6000
  }), this._signaling.useCommandDataChannel(!0), this._createDataChannel(this._pc, Sr.producerCommand, (e) => {
5882
6001
  this._producerCommand = e, this._signaling.setProducerCommandDataChannel(e);
5883
6002
  }), this._createDataChannel(this._pc, Sr.producerScreenShare, (e) => {
5884
6003
  this._producerScreen = e, this._producerScreen.binaryType = "arraybuffer", this._createCaptureReceiver();
5885
6004
  }), M.asrDataChannel && this._createDataChannel(this._pc, Sr.asr, (e) => {
5886
- this._asr = e, this._asr.binaryType = "arraybuffer", this._removeAsrTrack(), this._asrTrack = new Yr(e, this._participantIdRegistry, (e) => {
6005
+ this._asr = e, this._asr.binaryType = "arraybuffer", this._removeAsrTrack(), this._asrTrack = new ni(e, this._participantIdRegistry, (e) => {
5887
6006
  this._onAsrTranscription(e);
5888
6007
  }, this._debug);
5889
6008
  }), M.vmoji && this._createDataChannel(this._pc, Sr.animoji, (e) => {
@@ -5921,19 +6040,19 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
5921
6040
  }
5922
6041
  _updateSSRCMap(e) {
5923
6042
  e && (this._ssrcMap = {}, this._ssrcMapUpdated = !0, ln(e.sdp).forEach((e) => {
5924
- let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${qr.PARTICIPANT_AGNOSTIC_TRACK_PREFIX}-[0-9]+)|(?:${qr.TRANSPARENT_AUDIO_TRACK_PREFIX}-[0-9]+))`, n = new RegExp(t).exec(e);
6043
+ let t = `a=ssrc:([0-9]+) label:(audio|video)-((?:[ug]?[\\d]+)|(?:mix)|(?:${ei.PARTICIPANT_AGNOSTIC_TRACK_PREFIX}-[0-9]+)|(?:${ei.TRANSPARENT_AUDIO_TRACK_PREFIX}-[0-9]+))`, n = new RegExp(t).exec(e);
5925
6044
  n && (this._ssrcMap[n[1]] = n[3]);
5926
6045
  }));
5927
6046
  }
5928
6047
  _createCaptureSender(e) {
5929
6048
  let t = this._mediaSource.mediaSettings;
5930
- !e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new ia(e, this._consumerScreen, this._signaling, t.isFastScreenSharingEnabled, this._debug, this._logger));
6049
+ !e || !this._consumerScreen || !t.isScreenSharingEnabled || (this._captureSender && this._removeCaptureSender(), this._captureSender = new da(e, this._consumerScreen, this._signaling, t.isFastScreenSharingEnabled, this._debug, this._logger));
5931
6050
  }
5932
6051
  _removeCaptureSender() {
5933
6052
  this._captureSender?.destroy(), this._captureSender = null;
5934
6053
  }
5935
6054
  _createCaptureReceiver() {
5936
- this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Ai(this._producerScreen, this._participantIdRegistry, (e, t) => {
6055
+ this._producerScreen && (this._captureReceiver && this._removeCaptureReceiver(), this._captureReceiver = new Li(this._producerScreen, this._participantIdRegistry, (e, t) => {
5937
6056
  this._triggerEvent(X.REMOTE_STREAM_SECOND, e, t);
5938
6057
  }, (e) => {
5939
6058
  this._triggerEvent(X.REMOTE_STREAM_SECOND, e, null);
@@ -6043,7 +6162,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6043
6162
  _detectStaleTracks(e) {
6044
6163
  let t = e.rtps.find((e) => e.type === "inbound-rtp" && e.kind === "audio" && this._ssrcMap[e.ssrc] === "mix");
6045
6164
  if (!t) return;
6046
- let n = qr.AUDIO_MIX, r = this._statBytes[n], i = !1;
6165
+ let n = ei.AUDIO_MIX, r = this._statBytes[n], i = !1;
6047
6166
  if (r) {
6048
6167
  let e = t.bytesReceived - r.bytesReceived;
6049
6168
  e >= 0 && e <= 5 && (i = !0), r.stalled !== i && this._triggerEvent(X.AUDIO_MIX_STALL, i);
@@ -6055,31 +6174,31 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6055
6174
  }
6056
6175
  _allocateConsumer() {
6057
6176
  if (!this._signaling.ready) return;
6058
- let e = ya.get();
6177
+ let e = Ea.get();
6059
6178
  !M.videoTracksCount && !this._observer && this._debug.warn("Setting videoTracksCount to 0 is deprecated"), this._signaling.allocateConsumer(null, e).catch((e) => {
6060
6179
  e instanceof wn || this._debug.warn("ServerTransport: Unable to allocate consumer", e);
6061
6180
  });
6062
6181
  }
6063
6182
  async _processOffer(e, t) {
6064
6183
  if (!this._pc) throw Error("Interrupt allocation");
6184
+ this._sdpStats.logSdpReceived(e.type);
6065
6185
  try {
6066
6186
  await this._pc.setRemoteDescription(e);
6067
- } catch (e) {
6068
- throw this._debug.error("[single] unable to set remote offer", e), this._logger?.log(C.ERROR, "setRemoteDescription-single"), e;
6187
+ } catch (t) {
6188
+ throw this._debug.error("[single] unable to set remote offer", t), this._logger?.log(C.ERROR, "setRemoteDescription-single"), this._sdpStats.logSetRemoteFailed(e, t), t;
6069
6189
  }
6070
- await this._simulcast.configureFromRemoteOffer(this._pc);
6190
+ if (await this._simulcast.configureFromRemoteOffer(this._pc), await this._handleTracks(), this._debug.debug("[single] create local answer"), !this._pc) throw Error("Interrupt allocation");
6071
6191
  let n;
6072
6192
  try {
6073
- if (await this._handleTracks(), this._debug.debug("[single] create local answer"), !this._pc) throw Error("Interrupt allocation");
6074
- n = await this._pc.createAnswer();
6193
+ n = await this._pc.createAnswer(), this._sdpStats.logSdpGenerated("answer");
6075
6194
  } catch (e) {
6076
- throw this._debug.error("[single] unable to create answer", e), this._logger?.log(C.ERROR, "createAnswer-single"), e;
6195
+ throw this._debug.error("[single] unable to create answer", e), this._logger?.log(C.ERROR, "createAnswer-single"), this._sdpStats.logCreateFailed("answer", e), e;
6077
6196
  }
6078
6197
  try {
6079
6198
  if (!this._pc) throw Error("Interrupt allocation");
6080
6199
  n.sdp = j.patchLocalSDP(n.sdp, !1, T.isBrokenH264Decoder(), !1), this._debug.debug("[single] set local answer", { answer: n }), await this._pc.setLocalDescription(n);
6081
6200
  } catch (e) {
6082
- throw this._debug.error("[single] unable to set local answer", e), this._logger?.log(C.ERROR, "setLocalDescription-single"), e;
6201
+ throw this._debug.error("[single] unable to set local answer", e), this._logger?.log(C.ERROR, "setLocalDescription-single"), this._sdpStats.logSetLocalFailed(n, e), e;
6083
6202
  }
6084
6203
  n.sdp = this._simulcast.finalizeAnswer(n.sdp);
6085
6204
  try {
@@ -6231,11 +6350,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6231
6350
  if (!r || !r.length) return this._debug.log(`Cannot get stream waiting time, ${e} receiver has no synchronization sources`), 0;
6232
6351
  let i = r[0].rtpTimestamp;
6233
6352
  if (!Number.isInteger(i)) return this._logger?.log(C.PAT_WAITING_TIME_ERROR, "timestampNotInteger"), this._debug.error(`Cannot get stream waiting time, ${e} receiver's RTP timestamp is not an integer: ${i}`), 0;
6234
- let a = t - i & sa, o = Math.ceil(a / oa);
6353
+ let a = t - i & ma, o = Math.ceil(a / pa);
6235
6354
  return Math.min(100, Math.max(0, o));
6236
6355
  }
6237
6356
  async _monitorRtpShare() {
6238
- let e = Zr.getInstance().value;
6357
+ let e = ii.getInstance().value;
6239
6358
  if (!this._mediaSource.mediaSettings.isFastScreenSharingEnabled || !M.consumerFastScreenShare || e < .6) return;
6240
6359
  let t = this._pc?.getSenders().find((e) => e.track?.kind === k.video && e.track?.contentHint === "motion");
6241
6360
  t && (await t.getStats()).forEach((e) => {
@@ -6266,7 +6385,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6266
6385
  }
6267
6386
  }, X = /* @__PURE__ */ function(e) {
6268
6387
  return e.REMOTE_TRACK_ADDED = "REMOTE_TRACK_ADDED", e.REMOTE_TRACK_REMOVED = "REMOTE_TRACK_REMOVED", e.REMOTE_STREAM_SECOND = "REMOTE_STREAM_SECOND", e.AUDIO_MIX_STALL = "AUDIO_MIX_STALL", e.REMOTE_DATA_STATS = "REMOTE_DATA_STATS", e.STATE_CHANGED = "STATE_CHANGED", e.LOCAL_STATE_CHANGED = "LOCAL_STATE_CHANGED", e.SIGNALLED_ACTIVE_PARTICIPANTS = "SIGNALLED_ACTIVE_PARTICIPANTS", e.SIGNALLED_SPEAKER_CHANGED = "SIGNALLED_SPEAKER_CHANGED", e.SIGNALLED_STALLED_PARTICIPANTS = "SIGNALLED_STALLED_PARTICIPANTS", e.TOPOLOGY_CHANGED = "TOPOLOGY_CHANGED", e.NETWORK_STATUS = "NETWORK_STATUS", e.PEER_CONNECTION_CLOSED = "PEER_CONNECTION_CLOSED", e.ASR_TRANSCRIPTION = "ASR_TRANSCRIPTION", e.ANIMOJI_STREAM = "ANIMOJI_STREAM", e.ANIMOJI_ERROR = "ANIMOJI_ERROR", e.SCREEN_SHARING_STAT = "SCREEN_SHARING_STAT", e;
6269
- }({}), la = class extends b {
6388
+ }({}), ga = class extends b {
6270
6389
  constructor(e, t, n, r, i = R, a = null, o = null, s = null, c = null) {
6271
6390
  super(), h(this, "_signaling", void 0), h(this, "_mediaSource", void 0), h(this, "_topology", void 0), h(this, "_allocated", []), h(this, "_opened", []), h(this, "_directTransport", null), h(this, "_serverTransport", null), h(this, "_serverSettings", void 0), h(this, "_dtListeners", []), h(this, "_stListeners", []), h(this, "_states", {}), h(this, "_localState", q.IDLE), h(this, "_animojiReceiver", null), h(this, "_animojiSender", null), h(this, "_debug", void 0), h(this, "_logger", void 0), h(this, "_statAggregator", void 0), h(this, "_codecStatsAggregator", void 0), h(this, "_onFirstMediaSent", void 0), h(this, "_firstMediaSentProbeStopped", !1), h(this, "_vadController", null), h(this, "_updateVadTrack", () => {
6272
6391
  this._vadController?.setSendTrack(this._mediaSource.getSendAudioTrack());
@@ -6387,11 +6506,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6387
6506
  }
6388
6507
  }
6389
6508
  _createDirectTransport(e, t = !1) {
6390
- let n = new Kr(e, t, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6509
+ let n = new $r(e, t, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6391
6510
  return this._dtListeners.length > 0 && this._debug.warn(`The list of direct listeners for the participant [${e}] is not empty`), this._dtListeners = [], this._dtListeners.push(n.addEventListener("REMOTE_TRACK_ADDED", this._onRemoteTrackAdded.bind(this, e)), n.addEventListener("REMOTE_TRACK_REMOVED", this._onRemoteTrackRemoved.bind(this, e)), n.addEventListener("REMOTE_DATA_STATS", this._onRemoteDataStats.bind(this)), n.addEventListener("STATE_CHANGED", this._onDirectTransportChanged.bind(this)), n.addEventListener("NETWORK_STATUS", this._onTransportNetworkStatus.bind(this)), n.addEventListener("PEER_CONNECTION_CLOSED", this._onPeerConnectionClosed.bind(this, J.DIRECT))), this._animojiReceiver && this._animojiSender && n.setAnimojiTransport(this._animojiReceiver, this._animojiSender), n;
6392
6511
  }
6393
6512
  _createServerTransport() {
6394
- let e = new ca(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6513
+ let e = new ha(this._signaling, this._mediaSource, this._serverSettings, this._debug, this._logger, this._statAggregator, this._codecStatsAggregator, this._getFirstMediaSentCallback());
6395
6514
  return this._stListeners.length > 0 && this._debug.warn("The list of server transport listeners is not empty"), this._stListeners = [], this._stListeners.push(e.addEventListener("REMOTE_TRACK_ADDED", this._onRemoteTrackAdded.bind(this)), e.addEventListener("REMOTE_TRACK_REMOVED", this._onRemoteTrackRemoved.bind(this)), e.addEventListener("AUDIO_MIX_STALL", this._onServerAudioMixStall.bind(this)), e.addEventListener("REMOTE_DATA_STATS", this._onRemoteDataStats.bind(this)), e.addEventListener("STATE_CHANGED", this._onServerTransportChanged.bind(this)), e.addEventListener("SIGNALLED_ACTIVE_PARTICIPANTS", this._onTransportActiveParticipants.bind(this)), e.addEventListener("SIGNALLED_SPEAKER_CHANGED", this._onTransportSpeakerChanged.bind(this)), e.addEventListener("SIGNALLED_STALLED_PARTICIPANTS", this._onTransportStalledParticipants.bind(this)), e.addEventListener("NETWORK_STATUS", this._onTransportNetworkStatus.bind(this)), e.addEventListener("REMOTE_STREAM_SECOND", this._onRemoteStreamSecond.bind(this)), e.addEventListener("PEER_CONNECTION_CLOSED", this._onPeerConnectionClosed.bind(this, J.SERVER)), e.addEventListener("ASR_TRANSCRIPTION", this._onAsrTranscription.bind(this))), this._animojiReceiver && this._animojiSender && e.setAnimojiTransport(this._animojiReceiver, this._animojiSender), e;
6396
6515
  }
6397
6516
  _releaseDirectTransport() {
@@ -6483,7 +6602,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6483
6602
  getStreamWaitingTimeMs(e, t) {
6484
6603
  return this._topology === J.SERVER ? this._serverTransport ? this._serverTransport.getStreamWaitingTimeMs(e, t) : (this._logger?.log(C.PAT_WAITING_TIME_ERROR, "noTransport"), this._debug.error("Cannot get stream waiting time, server transport is not initialized"), 0) : (this._logger?.log(C.PAT_WAITING_TIME_ERROR, "wrongTopology"), this._debug.error(`Cannot get stream waiting time, incorrect topology: ${this._topology}`), 0);
6485
6604
  }
6486
- }, ua = "videochat-epi", da = 5e3, fa = 500, pa = class extends b {
6605
+ }, _a = "videochat-epi", va = 5e3, ya = 500, ba = class extends b {
6487
6606
  constructor(e, t, n = null, r = !1, i = R) {
6488
6607
  super(), h(this, "_previousPerfStatReportTimestamp", 0), h(this, "_previousNetworkStatReportTimestamp", Date.now()), h(this, "_previousCallStatReportTimestamp", Date.now()), h(this, "_previousCallStatReport", null), h(this, "_previousRemoteInboundRtps", /* @__PURE__ */ new Map()), h(this, "_screenShareStats", []), h(this, "_signaling", void 0), h(this, "_directTopology", void 0), h(this, "_debug", void 0), h(this, "_statAggregator", void 0), h(this, "_handleScreenSharingStat", (e) => {
6489
6608
  this._screenShareStats.push(e);
@@ -6496,7 +6615,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6496
6615
  }
6497
6616
  static getEstimatedPerformanceIndex() {
6498
6617
  try {
6499
- let e = parseInt(localStorage.getItem(ua) || "", 10);
6618
+ let e = parseInt(localStorage.getItem(_a) || "", 10);
6500
6619
  return isNaN(e) ? 0 : e;
6501
6620
  } catch {
6502
6621
  return 0;
@@ -6505,9 +6624,9 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6505
6624
  async _handleStats(e) {
6506
6625
  if (!e.inbound || !e.inbound.rtps) return;
6507
6626
  let t = Date.now();
6508
- !this._directTopology && M.perfStatReportEnabled && this._previousPerfStatReportTimestamp + da <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6627
+ !this._directTopology && M.perfStatReportEnabled && this._previousPerfStatReportTimestamp + va <= t && (await this.reportPerfStats(e), this._previousPerfStatReportTimestamp = t);
6509
6628
  let n = e.outbound.transport.local?.protocol === "tcp";
6510
- !this._directTopology && n && this._previousNetworkStatReportTimestamp + fa <= t && (await this.reportNetworkStats(e), this._previousNetworkStatReportTimestamp = t), M.callStatReportEnabled && this._previousCallStatReportTimestamp + M.statisticsInterval <= t && (this._reportCallStats(e), this._previousCallStatReportTimestamp = t);
6629
+ !this._directTopology && n && this._previousNetworkStatReportTimestamp + ya <= t && (await this.reportNetworkStats(e), this._previousNetworkStatReportTimestamp = t), M.callStatReportEnabled && this._previousCallStatReportTimestamp + M.statisticsInterval <= t && (this._reportCallStats(e), this._previousCallStatReportTimestamp = t);
6511
6630
  }
6512
6631
  async reportPerfStats(e) {
6513
6632
  let t = e.inbound.rtps.reduce((e, t) => (t.kind === "video" && (e.framesDecoded += t.framesDecoded || 0, e.framesReceived += t.framesReceived || 0), e), {
@@ -6516,7 +6635,7 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6516
6635
  });
6517
6636
  if (t.framesDecoded) try {
6518
6637
  let e = await this._signaling.reportPerfStat(t);
6519
- localStorage.setItem(ua, e.estimatedPerformanceIndex);
6638
+ localStorage.setItem(_a, e.estimatedPerformanceIndex);
6520
6639
  } catch {}
6521
6640
  }
6522
6641
  async reportNetworkStats(e) {
@@ -6556,11 +6675,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6556
6675
  rtt: Math.round(e.inbound.transport.currentRoundTripTime * 1e3),
6557
6676
  ss_freeze_count: 0,
6558
6677
  ss_total_freezes_duration: 0,
6559
- local_address: ha(e.inbound.transport.local),
6678
+ local_address: Sa(e.inbound.transport.local),
6560
6679
  local_connection_type: e.inbound.transport.local?.type,
6561
6680
  network_type: e.inbound.transport.local?.networkType,
6562
6681
  transport: e.inbound.transport.local?.protocol,
6563
- remote_address: ha(e.inbound.transport.remote),
6682
+ remote_address: Sa(e.inbound.transport.remote),
6564
6683
  remote_connection_type: e.inbound.transport.remote?.type
6565
6684
  };
6566
6685
  this._previousCallStatReport || (this._previousCallStatReport = Object.assign({}, t));
@@ -6581,11 +6700,11 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6581
6700
  frames_dropped: Math.max(0, t.frames_dropped - this._previousCallStatReport.frames_dropped),
6582
6701
  rtt: Math.max(0, t.rtt)
6583
6702
  };
6584
- if (M.simulcast && (i.is_simulcast = !0), navigator.hardwareConcurrency && (i.cpu_hardware_concurrency = navigator.hardwareConcurrency), n && !ga(t.jitter_video) && (i.jitter_video = Math.round(t.jitter_video)), r && !ga(t.jitter_audio) && (i.jitter_audio = Math.round(t.jitter_audio)), n && !ga(t.interframe_delay_variance) && (i.interframe_delay_variance = t.interframe_delay_variance), t.freeze_count && t.total_freezes_duration && (i.freeze_count = t.freeze_count, i.total_freezes_duration = Math.round(t.total_freezes_duration * 1e3)), t.ss_freeze_count && t.ss_total_freezes_duration && (i.ss_freeze_count = t.ss_freeze_count, i.ss_total_freezes_duration = t.ss_total_freezes_duration), r && !ga(t.total_audio_samples_received)) {
6703
+ if (M.simulcast && (i.is_simulcast = !0), navigator.hardwareConcurrency && (i.cpu_hardware_concurrency = navigator.hardwareConcurrency), n && !Ca(t.jitter_video) && (i.jitter_video = Math.round(t.jitter_video)), r && !Ca(t.jitter_audio) && (i.jitter_audio = Math.round(t.jitter_audio)), n && !Ca(t.interframe_delay_variance) && (i.interframe_delay_variance = t.interframe_delay_variance), t.freeze_count && t.total_freezes_duration && (i.freeze_count = t.freeze_count, i.total_freezes_duration = Math.round(t.total_freezes_duration * 1e3)), t.ss_freeze_count && t.ss_total_freezes_duration && (i.ss_freeze_count = t.ss_freeze_count, i.ss_total_freezes_duration = t.ss_total_freezes_duration), r && !Ca(t.total_audio_samples_received)) {
6585
6704
  let e = Math.max(0, t.total_audio_samples_received - this._previousCallStatReport.total_audio_samples_received), n = Math.max(0, t.inserted_audio_samples_for_deceleration - this._previousCallStatReport.inserted_audio_samples_for_deceleration), r = Math.max(0, t.removed_audio_samples_for_acceleration - this._previousCallStatReport.removed_audio_samples_for_acceleration), a = Math.max(0, t.concealed_audio_samples - this._previousCallStatReport.concealed_audio_samples), o = Math.max(0, t.silent_concealed_audio_samples - this._previousCallStatReport.silent_concealed_audio_samples), s = Math.max(0, t.audio_concealment_events - this._previousCallStatReport.audio_concealment_events);
6586
- i.inserted_audio_samples_for_deceleration = _a(n / e * 1e3), i.removed_audio_samples_for_acceleration = _a(r / e * 1e3), i.concealed_audio_samples = _a(a / e * 1e3), i.concealed_silent_audio_samples = _a(o / e * 1e3), i.concealment_audio_avg_size = _a(a / s), i.total_audio_energy = t.total_audio_energy;
6705
+ i.inserted_audio_samples_for_deceleration = wa(n / e * 1e3), i.removed_audio_samples_for_acceleration = wa(r / e * 1e3), i.concealed_audio_samples = wa(a / e * 1e3), i.concealed_silent_audio_samples = wa(o / e * 1e3), i.concealment_audio_avg_size = wa(a / s), i.total_audio_energy = t.total_audio_energy;
6587
6706
  }
6588
- ma(t, "local_address", "local_connection_type", "network_type", "transport") && (i.local_address = t.local_address, i.local_connection_type = t.local_connection_type, i.network_type = t.network_type, i.transport = t.transport), ma(t, "remote_address", "remote_connection_type") && (i.remote_address = t.remote_address, i.remote_connection_type = t.remote_connection_type);
6707
+ xa(t, "local_address", "local_connection_type", "network_type", "transport") && (i.local_address = t.local_address, i.local_connection_type = t.local_connection_type, i.network_type = t.network_type, i.transport = t.transport), xa(t, "remote_address", "remote_connection_type") && (i.remote_address = t.remote_address, i.remote_connection_type = t.remote_connection_type);
6589
6708
  let a = this._calculatePacketLoss(e.remoteInbound.rtps);
6590
6709
  a.video !== void 0 && (i.video_loss = a.video), a.audio !== void 0 && (i.audio_loss = a.audio), this._statAggregator?.logCallStat(i), M.enableLogPerfStatReport && this._debug.log("Sent call stats", i), this._previousCallStatReport = t;
6591
6710
  }
@@ -6617,26 +6736,26 @@ var wi = 2 ** 15 - 1, Ti = 1, Ei = 5, Di = 5, Oi = class e {
6617
6736
  return r;
6618
6737
  }
6619
6738
  };
6620
- function ma(e, ...t) {
6739
+ function xa(e, ...t) {
6621
6740
  for (let n of t) if (!Object.hasOwn(e, n) || e[n] === void 0) return !1;
6622
6741
  return !0;
6623
6742
  }
6624
- function ha(e, t = !1) {
6743
+ function Sa(e, t = !1) {
6625
6744
  if (e?.address) return e.address + (t ? `:${e.port}` : "");
6626
6745
  }
6627
- function ga(e) {
6746
+ function Ca(e) {
6628
6747
  return e === void 0;
6629
6748
  }
6630
- function _a(e) {
6749
+ function wa(e) {
6631
6750
  return Number.isNaN(e) ? 0 : e;
6632
6751
  }
6633
6752
  //#endregion
6634
6753
  //#region src/static/Capabilities.ts
6635
- var va;
6754
+ var Ta;
6636
6755
  (function(e) {
6637
6756
  function t() {
6638
6757
  return {
6639
- estimatedPerformanceIndex: pa.getEstimatedPerformanceIndex(),
6758
+ estimatedPerformanceIndex: ba.getEstimatedPerformanceIndex(),
6640
6759
  audioMix: !0,
6641
6760
  consumerUpdate: !0,
6642
6761
  producerNotificationDataChannelVersion: 8,
@@ -6662,8 +6781,8 @@ var va;
6662
6781
  };
6663
6782
  }
6664
6783
  e.get = t;
6665
- })(va || (va = {}));
6666
- var ya = va, ba = {
6784
+ })(Ta || (Ta = {}));
6785
+ var Ea = Ta, Da = {
6667
6786
  producerScreenTrack: () => !0,
6668
6787
  videoTracksCount: () => M.videoTracksCount > 0,
6669
6788
  waitingHall: () => !0,
@@ -6683,28 +6802,28 @@ var ya = va, ba = {
6683
6802
  p2pRelay: () => !1,
6684
6803
  waitForAdmin: () => M.waitForAdminInGroupCalls,
6685
6804
  hold: () => M.hold
6686
- }, xa = class {
6805
+ }, Oa = class {
6687
6806
  static getFlags() {
6688
- let e = Object.values(ba), t = 0;
6807
+ let e = Object.values(Da), t = 0;
6689
6808
  for (let n = 0; n < e.length; n++) e[n]() && (t |= 1 << n);
6690
6809
  return t.toString(16).toUpperCase();
6691
6810
  }
6692
6811
  static parseCapabilities(e) {
6693
6812
  let t = parseInt(e || "0", 16);
6694
- return Object.keys(ba).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6813
+ return Object.keys(Da).reduce((e, n, r) => (e[n] = !!(t & 1 << r), e), {});
6695
6814
  }
6696
- }, Sa = 63n, Ca = 16383n, wa = 1073741823, Ta = 4611686018427387903n, Ea = class {
6815
+ }, ka = 63n, Aa = 16383n, ja = 1073741823, Ma = 4611686018427387903n, Na = class {
6697
6816
  encode(e) {
6698
6817
  let t = typeof e == "number" ? BigInt(e) : e;
6699
- if (t <= Sa) return new Uint8Array([Number(t)]);
6700
- if (t <= Ca) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
6701
- if (t <= BigInt(wa)) return new Uint8Array([
6818
+ if (t <= ka) return new Uint8Array([Number(t)]);
6819
+ if (t <= Aa) return new Uint8Array([64 | Number(t >> 8n), Number(t & 255n)]);
6820
+ if (t <= BigInt(ja)) return new Uint8Array([
6702
6821
  128 | Number(t >> 24n),
6703
6822
  Number(t >> 16n & 255n),
6704
6823
  Number(t >> 8n & 255n),
6705
6824
  Number(t & 255n)
6706
6825
  ]);
6707
- if (t <= Ta) return new Uint8Array([
6826
+ if (t <= Ma) return new Uint8Array([
6708
6827
  192 | Number(t >> 56n),
6709
6828
  Number(t >> 48n & 255n),
6710
6829
  Number(t >> 40n & 255n),
@@ -6716,7 +6835,7 @@ var ya = va, ba = {
6716
6835
  ]);
6717
6836
  throw RangeError("Number is too large to encode using varint");
6718
6837
  }
6719
- }, Da = class {
6838
+ }, Pa = class {
6720
6839
  decode(e) {
6721
6840
  let t = this.getNumBytesForLengthInteger(e);
6722
6841
  if (t < 0) throw Error("Invalid length prefix");
@@ -6742,9 +6861,9 @@ var ya = va, ba = {
6742
6861
  let t = e[0] & 192;
6743
6862
  return t === 0 ? 1 : t === 64 ? 2 : t === 128 ? 4 : t === 192 ? 8 : -1;
6744
6863
  }
6745
- }, Oa = class {
6864
+ }, Fa = class {
6746
6865
  constructor(e) {
6747
- h(this, "encoder", void 0), h(this, "compression", void 0), h(this, "lengthEncoder", void 0), this.encoder = new TextEncoder(), this.lengthEncoder = new Ea(), this.compression = e ?? null;
6866
+ h(this, "encoder", void 0), h(this, "compression", void 0), h(this, "lengthEncoder", void 0), this.encoder = new TextEncoder(), this.lengthEncoder = new Na(), this.compression = e ?? null;
6748
6867
  }
6749
6868
  encode(e) {
6750
6869
  let t = this.encoder.encode(e);
@@ -6761,9 +6880,9 @@ var ya = va, ba = {
6761
6880
  default: return e;
6762
6881
  }
6763
6882
  }
6764
- }, ka = class {
6883
+ }, Ia = class {
6765
6884
  constructor(e) {
6766
- h(this, "decoder", void 0), h(this, "compression", void 0), h(this, "lengthDecoder", void 0), h(this, "buffer", void 0), h(this, "expectedLength", void 0), h(this, "offset", void 0), h(this, "lengthPrefixLength", void 0), this.decoder = new TextDecoder(), this.lengthDecoder = new Da(), this.compression = e ?? null, this.buffer = new Uint8Array(), this.expectedLength = null, this.offset = 0;
6885
+ h(this, "decoder", void 0), h(this, "compression", void 0), h(this, "lengthDecoder", void 0), h(this, "buffer", void 0), h(this, "expectedLength", void 0), h(this, "offset", void 0), h(this, "lengthPrefixLength", void 0), this.decoder = new TextDecoder(), this.lengthDecoder = new Pa(), this.compression = e ?? null, this.buffer = new Uint8Array(), this.expectedLength = null, this.offset = 0;
6767
6886
  }
6768
6887
  decode(e) {
6769
6888
  let t = [];
@@ -6793,12 +6912,12 @@ var ya = va, ba = {
6793
6912
  default: return e;
6794
6913
  }
6795
6914
  }
6796
- }, Aa = class {
6915
+ }, La = class {
6797
6916
  static isBrowserSupported() {
6798
6917
  return !(!("WebTransport" in window && typeof WebTransport == "function") || T.browserName() === "Safari");
6799
6918
  }
6800
6919
  constructor(e, t = {}, n = R) {
6801
- h(this, "onopen", null), h(this, "onmessage", null), h(this, "onerror", null), h(this, "onclose", null), h(this, "readyState", WebSocket.CONNECTING), h(this, "webTransport", null), h(this, "writer", null), h(this, "url", void 0), h(this, "options", void 0), h(this, "compression", void 0), h(this, "encoder", void 0), h(this, "decoder", void 0), h(this, "_debug", void 0), this._debug = n, this.url = e, this.options = t, this.compression = this.getCompressionTypeFromUrl(e), this.encoder = new Oa(this.compression), this.decoder = new ka(this.compression), this.connect();
6920
+ h(this, "onopen", null), h(this, "onmessage", null), h(this, "onerror", null), h(this, "onclose", null), h(this, "readyState", WebSocket.CONNECTING), h(this, "webTransport", null), h(this, "writer", null), h(this, "url", void 0), h(this, "options", void 0), h(this, "compression", void 0), h(this, "encoder", void 0), h(this, "decoder", void 0), h(this, "_debug", void 0), this._debug = n, this.url = e, this.options = t, this.compression = this.getCompressionTypeFromUrl(e), this.encoder = new Fa(this.compression), this.decoder = new Ia(this.compression), this.connect();
6802
6921
  }
6803
6922
  async send(e) {
6804
6923
  if (this.readyState !== WebSocket.OPEN) {
@@ -6924,11 +7043,11 @@ var ya = va, ba = {
6924
7043
  compression: this.compression
6925
7044
  }, n;
6926
7045
  }
6927
- }, ja = /* @__PURE__ */ function(e) {
6928
- return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.RECONNECT_TIMEOUT = "RECONNECT_TIMEOUT", e.ABORTED = "ABORTED", e;
6929
- }({}), Ma = class {
7046
+ }, Ra = /* @__PURE__ */ function(e) {
7047
+ return e.EMPTY_ENDPOINT = "EMPTY_ENDPOINT", e.NETWORK_ERROR = "NETWORK_ERROR", e.ABORTED = "ABORTED", e;
7048
+ }({}), za = class {
6930
7049
  constructor(e = R, t) {
6931
- h(this, "handlers", void 0), h(this, "socket", null), h(this, "endpoint", ""), h(this, "wtEndpoint", null), h(this, "peerId", null), h(this, "lastStamp", 0), h(this, "connectionType", void 0), h(this, "reconnectCount", 0), h(this, "reconnectTimer", 0), h(this, "reconnectDeadlineTimer", 0), h(this, "doctorTimer", 0), h(this, "forceWebSocket", !1), h(this, "abortSignal", void 0), h(this, "manualClose", !1), h(this, "currentType", yr.WEBSOCKET), h(this, "_debug", void 0), this.handlers = t, this._debug = e;
7050
+ h(this, "handlers", void 0), h(this, "socket", null), h(this, "endpoint", ""), h(this, "wtEndpoint", null), h(this, "peerId", null), h(this, "lastStamp", 0), h(this, "connectionType", void 0), h(this, "reconnectCount", 0), h(this, "reconnectTimer", 0), h(this, "doctorTimer", 0), h(this, "forceWebSocket", !1), h(this, "abortSignal", void 0), h(this, "manualClose", !1), h(this, "currentType", yr.WEBSOCKET), h(this, "_debug", void 0), this.handlers = t, this._debug = e;
6932
7051
  }
6933
7052
  get readyState() {
6934
7053
  return this.socket?.readyState ?? null;
@@ -6951,14 +7070,14 @@ var ya = va, ba = {
6951
7070
  setAbortSignal(e) {
6952
7071
  this.abortSignal = e;
6953
7072
  }
6954
- onConnectionRestored() {
6955
- this.reconnectCount = 0, this._stopReconnectDeadline();
7073
+ resetReconnectCount() {
7074
+ this.reconnectCount = 0;
6956
7075
  }
6957
7076
  connect(e) {
6958
7077
  this.socket && this.socket.readyState < WebSocket.CLOSING || (e !== vr.RETRY && (this.forceWebSocket = !1, this.reconnectCount = 0), this.manualClose = !1, this.connectionType = e, this._connect());
6959
7078
  }
6960
7079
  close(e) {
6961
- this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._stopReconnectDeadline(), this.lastStamp = 0;
7080
+ this.manualClose = !0, this._disconnect(e), window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this.lastStamp = 0;
6962
7081
  }
6963
7082
  async send(e) {
6964
7083
  await this.socket?.send(e);
@@ -6976,7 +7095,7 @@ var ya = va, ba = {
6976
7095
  return;
6977
7096
  }
6978
7097
  let e = this._buildUrl(this.wtEndpoint, !0);
6979
- this.currentType = yr.WEBTRANSPORT, this.socket = new Aa(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
7098
+ this.currentType = yr.WEBTRANSPORT, this.socket = new La(e, { congestionControl: "low-latency" }, this._debug), this._setSocketHandlers();
6980
7099
  }
6981
7100
  _connectWebSocket() {
6982
7101
  if (!this.endpoint) {
@@ -6999,10 +7118,10 @@ var ya = va, ba = {
6999
7118
  }
7000
7119
  _buildUrl(e, t) {
7001
7120
  let n = new URL(e), r = n.searchParams;
7002
- return r.set("platform", M.platform), r.set("appVersion", String(M.appVersion)), r.set("version", String(M.protocolVersion)), r.set("device", M.device), r.set("capabilities", xa.getFlags()), r.set("clientType", M.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === vr.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), M.useParticipantListChunk && (r.set("partIdx", String(M.participantListChunkInitIndex)), M.participantListChunkInitCount !== null && r.set("partCount", String(M.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
7121
+ return r.set("platform", M.platform), r.set("appVersion", M.appVersion), r.set("version", String(M.protocolVersion)), r.set("device", M.device), r.set("capabilities", Oa.getFlags()), r.set("clientType", M.clientType), this.connectionType && r.set("tgt", this.connectionType), this.connectionType === vr.RETRY && this.lastStamp && r.set("recoverTs", String(this.lastStamp)), M.useParticipantListChunk && (r.set("partIdx", String(M.participantListChunkInitIndex)), M.participantListChunkInitCount !== null && r.set("partCount", String(M.participantListChunkInitCount))), t && (r.set("compression", "deflate-raw"), r.set("ua", navigator.userAgent)), this.peerId !== null && r.set("peerId", String(this.peerId)), n.toString();
7003
7122
  }
7004
7123
  _canUseWebTransport() {
7005
- return !this.forceWebSocket && Aa.isBrowserSupported() && this.wtEndpoint !== null && M.webtransport;
7124
+ return !this.forceWebSocket && La.isBrowserSupported() && this.wtEndpoint !== null && M.webtransport;
7006
7125
  }
7007
7126
  _onOpen() {
7008
7127
  this._startDoctor(), this.handlers.onOpen();
@@ -7031,32 +7150,20 @@ var ya = va, ba = {
7031
7150
  }
7032
7151
  _scheduleReconnect(e = this._getReconnectDelay()) {
7033
7152
  if (this.reconnectCount >= M.signalingReconnectMaxCount) {
7034
- this._stopReconnectDeadline(), this.handlers.onFailed({
7153
+ this.handlers.onFailed({
7035
7154
  failure: "NETWORK_ERROR",
7036
7155
  message: "Unable to connect to the signaling: reconnect attempts exhausted",
7037
7156
  source: this.currentType
7038
7157
  });
7039
7158
  return;
7040
7159
  }
7041
- this._startReconnectDeadline(), this.reconnectCount++, this.handlers.onReconnectScheduled({
7160
+ this.reconnectCount++, this.handlers.onReconnectScheduled({
7042
7161
  count: this.reconnectCount,
7043
7162
  delay: e
7044
7163
  }), this.reconnectTimer = window.setTimeout(() => {
7045
7164
  this.connectionType = vr.RETRY, this._connect();
7046
7165
  }, e);
7047
7166
  }
7048
- _startReconnectDeadline() {
7049
- this.reconnectDeadlineTimer || (this.reconnectDeadlineTimer = window.setTimeout(() => {
7050
- this.reconnectDeadlineTimer = 0, window.clearTimeout(this.reconnectTimer), this.reconnectTimer = 0, this._disconnect(4e3), this.handlers.onFailed({
7051
- failure: "RECONNECT_TIMEOUT",
7052
- message: "Unable to connect to the signaling: reconnect timeout",
7053
- source: this.currentType
7054
- });
7055
- }, M.signalingReconnectMaxDuration));
7056
- }
7057
- _stopReconnectDeadline() {
7058
- window.clearTimeout(this.reconnectDeadlineTimer), this.reconnectDeadlineTimer = 0;
7059
- }
7060
7167
  _getReconnectDelay() {
7061
7168
  return Math.min(M.signalingReconnectMaxDelay, M.signalingReconnectDelay * 2 ** this.reconnectCount);
7062
7169
  }
@@ -7068,31 +7175,31 @@ var ya = va, ba = {
7068
7175
  _stopDoctor() {
7069
7176
  window.clearTimeout(this.doctorTimer), this.doctorTimer = 0;
7070
7177
  }
7071
- }, Na = "open", Pa = 10, Fa = {
7178
+ }, Ba = "open", Va = 10, Ha = {
7072
7179
  CONVERSATION_ENDED: "conversation-ended",
7073
7180
  OBSOLETE_CLIENT: "gen.obsoleteClient",
7074
7181
  INVALID_TOKEN: "invalid-token",
7075
7182
  PARTICIPANT_NOT_FOUND: "participant-not-found",
7076
7183
  ILLEGAL_PARTICIPANT_STATE: "illegal-participant-state",
7077
7184
  SERVICE_UNAVAILABLE: "service-unavailable"
7078
- }, Ia = {
7079
- [Fa.CONVERSATION_ENDED]: "conversation-ended",
7080
- [Fa.OBSOLETE_CLIENT]: "obsolete-client",
7081
- [Fa.INVALID_TOKEN]: "invalid-token",
7082
- [Fa.PARTICIPANT_NOT_FOUND]: "participant-not-found",
7083
- [Fa.ILLEGAL_PARTICIPANT_STATE]: "illegal-participant-state",
7084
- [Fa.SERVICE_UNAVAILABLE]: "service-unavailable"
7185
+ }, Ua = {
7186
+ [Ha.CONVERSATION_ENDED]: "conversation-ended",
7187
+ [Ha.OBSOLETE_CLIENT]: "obsolete-client",
7188
+ [Ha.INVALID_TOKEN]: "invalid-token",
7189
+ [Ha.PARTICIPANT_NOT_FOUND]: "participant-not-found",
7190
+ [Ha.ILLEGAL_PARTICIPANT_STATE]: "illegal-participant-state",
7191
+ [Ha.SERVICE_UNAVAILABLE]: "service-unavailable"
7085
7192
  };
7086
- function La(e, t) {
7193
+ function Wa(e, t) {
7087
7194
  return e.errorMessage ?? e.message ?? e.error ?? t;
7088
7195
  }
7089
- var Ra = new Set([
7196
+ var Ga = new Set([
7090
7197
  D.CALLER_IS_BLOCKED,
7091
7198
  D.ENDED,
7092
7199
  D.NOT_FOUND,
7093
7200
  D.PARTICIPANT_LIMIT_REACHED,
7094
7201
  D.SERVICE_UNAVAILABLE
7095
- ]), za = class e extends En {
7202
+ ]), Ka = class e extends En {
7096
7203
  static get WAIT_CONNECTION_DELAY() {
7097
7204
  return M.waitConnectionDelay;
7098
7205
  }
@@ -7103,7 +7210,7 @@ var Ra = new Set([
7103
7210
  return !this.disposed && this.transport.readyState !== null;
7104
7211
  }
7105
7212
  constructor(e = R, t = null, n = null, r = null, i = null) {
7106
- 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 $n(e), this.transport = new Ma(e, {
7213
+ 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 $n(e), this.transport = new za(e, {
7107
7214
  onConnecting: this._onTransportConnecting.bind(this),
7108
7215
  onOpen: this._onOpen.bind(this),
7109
7216
  onMessage: this._onMessage.bind(this),
@@ -7190,20 +7297,20 @@ var Ra = new Set([
7190
7297
  return this._send(B.TRANSMIT_DATA, {
7191
7298
  participantId: e,
7192
7299
  data: r
7193
- }, !0, Pa);
7300
+ }, !0, Va);
7194
7301
  }
7195
7302
  async acceptCall(e) {
7196
7303
  return this._send(B.ACCEPT_CALL, { mediaSettings: e });
7197
7304
  }
7198
7305
  async changeMediaSettings(e) {
7199
- return this._send(B.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, Pa);
7306
+ return this._send(B.CHANGE_MEDIA_SETTINGS, { mediaSettings: e }, !0, Va);
7200
7307
  }
7201
7308
  async changeParticipantState(e, t) {
7202
7309
  let n = { participantState: { state: e } };
7203
7310
  return t && (n.participantId = t), this._sendRaw(B.CHANGE_PARTICIPANT_STATE, n);
7204
7311
  }
7205
7312
  async hold(e) {
7206
- let t = ya.get();
7313
+ let t = Ea.get();
7207
7314
  return this._send(B.HOLD, {
7208
7315
  hold: e,
7209
7316
  capabilities: e ? void 0 : t
@@ -7435,7 +7542,7 @@ var Ra = new Set([
7435
7542
  if (this.disposed) throw new wn(e);
7436
7543
  switch (t.route) {
7437
7544
  case "producer":
7438
- this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === Na && this._handleCommandsQueue(this.datachannelCommandsQueue);
7545
+ this.datachannelCommandsQueue.push(t), this.producerCommandDataChannel?.readyState === Ba && this._handleCommandsQueue(this.datachannelCommandsQueue);
7439
7546
  break;
7440
7547
  case "websocket":
7441
7548
  if (this.transport.readyState === null) {
@@ -7485,7 +7592,7 @@ var Ra = new Set([
7485
7592
  _handleMessage(e) {
7486
7593
  switch (e.type) {
7487
7594
  case "notification":
7488
- this._attachNotificationCallError(e), e.notification === "connection" ? (this._debug.debug("[signaling] signaling connected", e), this.connected = !0, this.transport.onConnectionRestored(), this.transport.setEndpoint(e.endpoint), e.peerId && this.peerId !== e.peerId.id && (this.peerId = e.peerId.id, this.transport.setPeerId(e.peerId.id)), this._stopWaitConnectionMessage(), this.conversationResolve ? this.conversationResolve(e) : (this._logTransportStat(br.RESTART), this._triggerEvent(G.RECONNECT, e), e.conversation.topology && this._triggerEvent(G.NOTIFICATION, {
7595
+ this._attachNotificationCallError(e), e.notification === "connection" ? (this._debug.debug("[signaling] signaling connected", e), this.connected = !0, this.transport.resetReconnectCount(), this.transport.setEndpoint(e.endpoint), e.peerId && this.peerId !== e.peerId.id && (this.peerId = e.peerId.id, this.transport.setPeerId(e.peerId.id)), this._stopWaitConnectionMessage(), this.conversationResolve ? this.conversationResolve(e) : (this._logTransportStat(br.RESTART), this._triggerEvent(G.RECONNECT, e), e.conversation.topology && this._triggerEvent(G.NOTIFICATION, {
7489
7596
  type: "notification",
7490
7597
  notification: K.TOPOLOGY_CHANGED,
7491
7598
  topology: e.conversation.topology
@@ -7505,9 +7612,9 @@ var Ra = new Set([
7505
7612
  }
7506
7613
  _handleErrorMessage(e) {
7507
7614
  this._logger?.log(C.SOCKET_ACTION, `error-${e.error}`);
7508
- let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = La(e, "Unknown signaling error");
7615
+ let t = this._getSocketType(), n = e.error ? this._createSignalingCallError(e.error, e.errorCode, t) : void 0, r = Wa(e, "Unknown signaling error");
7509
7616
  switch (this._debug.debug(`[signaling] error message [${e.sequence}]`, e), e.sequence && this.responseHandlers[e.sequence] && this._handleCommandResponse(!1, e), e.error) {
7510
- case Fa.SERVICE_UNAVAILABLE:
7617
+ case Ha.SERVICE_UNAVAILABLE:
7511
7618
  let i = new O(D.SERVICE_UNAVAILABLE, {
7512
7619
  callError: n,
7513
7620
  message: r,
@@ -7519,7 +7626,7 @@ var Ra = new Set([
7519
7626
  reason: D.SERVICE_UNAVAILABLE
7520
7627
  });
7521
7628
  break;
7522
- case Fa.CONVERSATION_ENDED:
7629
+ case Ha.CONVERSATION_ENDED:
7523
7630
  this.conversationReject ? this.conversationReject(new O(e.reason || x.SIGNALING_FAILED, {
7524
7631
  callError: n,
7525
7632
  message: r,
@@ -7530,22 +7637,22 @@ var Ra = new Set([
7530
7637
  reason: e.reason
7531
7638
  });
7532
7639
  break;
7533
- case Fa.ILLEGAL_PARTICIPANT_STATE:
7534
- case Fa.PARTICIPANT_NOT_FOUND:
7640
+ case Ha.ILLEGAL_PARTICIPANT_STATE:
7641
+ case Ha.PARTICIPANT_NOT_FOUND:
7535
7642
  this._throwError(new O(x.SIGNALING_FAILED, {
7536
7643
  callError: n,
7537
7644
  message: r,
7538
7645
  remote: !0
7539
7646
  }));
7540
7647
  break;
7541
- case Fa.OBSOLETE_CLIENT:
7648
+ case Ha.OBSOLETE_CLIENT:
7542
7649
  this.conversationReject?.(new O(e.reason || D.OBSOLETE_CLIENT, {
7543
7650
  callError: n,
7544
7651
  message: r,
7545
7652
  remote: !0
7546
7653
  }));
7547
7654
  break;
7548
- case Fa.INVALID_TOKEN:
7655
+ case Ha.INVALID_TOKEN:
7549
7656
  default:
7550
7657
  if (e.sequence || t === yr.WEBTRANSPORT) break;
7551
7658
  if (this.connected) this._throwError(new O(e.reason || x.SIGNALING_FAILED, {
@@ -7647,13 +7754,13 @@ var Ra = new Set([
7647
7754
  let r = this.responseHandlers[n.sequence];
7648
7755
  window.clearTimeout(r.responseTimer);
7649
7756
  let i = W.measureMark(r.statMarkName);
7650
- i !== null && this._statSignalingCommands?.mark(r.name, i, this._getSocketType()), this._debug.debug(`[signaling] command response [${n.sequence}]`, n), t ? (delete this.responseHandlers[n.sequence], r.resolve(n)) : n.type === "error" ? (delete this.responseHandlers[n.sequence], this._logger?.log(C.SOCKET_ACTION, "response-error"), r.reject(Error(La(n, `Response error [${r.name}]`)), !0)) : this.transport.readyState === WebSocket.OPEN ? (delete this.responseHandlers[n.sequence], this._logger?.log(C.SOCKET_ACTION, "response-timeout"), r.reject(Error(La(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
7757
+ i !== null && this._statSignalingCommands?.mark(r.name, i, this._getSocketType()), this._debug.debug(`[signaling] command response [${n.sequence}]`, n), t ? (delete this.responseHandlers[n.sequence], r.resolve(n)) : n.type === "error" ? (delete this.responseHandlers[n.sequence], this._logger?.log(C.SOCKET_ACTION, "response-error"), r.reject(Error(Wa(n, `Response error [${r.name}]`)), !0)) : this.transport.readyState === WebSocket.OPEN ? (delete this.responseHandlers[n.sequence], this._logger?.log(C.SOCKET_ACTION, "response-timeout"), r.reject(Error(Wa(n, `Response timeout [${r.name}]`)))) : r.responseTimer = window.setTimeout(() => this._handleCommandResponse(t, n), e.WAIT_RESPONSE_DELAY);
7651
7758
  }
7652
7759
  _handleCommandsQueue(e) {
7653
7760
  for (; e.length > 0;) {
7654
7761
  let t = e.shift();
7655
7762
  if (this._debug.debug(`[signaling] command send [${t.sequence}]`, `'${t.name}'`, t.params), t.route === "producer") {
7656
- if (this.producerCommandDataChannel?.readyState !== Na) {
7763
+ if (this.producerCommandDataChannel?.readyState !== Ba) {
7657
7764
  t.reject(/* @__PURE__ */ Error(`Invalid data channel state: ${this.producerCommandDataChannel?.readyState}`));
7658
7765
  return;
7659
7766
  }
@@ -7738,7 +7845,7 @@ var Ra = new Set([
7738
7845
  }
7739
7846
  _onTransportFailed(e) {
7740
7847
  switch (e.failure) {
7741
- case ja.EMPTY_ENDPOINT:
7848
+ case Ra.EMPTY_ENDPOINT:
7742
7849
  this.conversationReject?.(new O(x.SIGNALING_FAILED, {
7743
7850
  callError: {
7744
7851
  scope: "internal",
@@ -7749,7 +7856,7 @@ var Ra = new Set([
7749
7856
  remote: e.remote
7750
7857
  }));
7751
7858
  break;
7752
- case ja.NETWORK_ERROR:
7859
+ case Ra.NETWORK_ERROR:
7753
7860
  this._fail(new O(D.NETWORK_ERROR, { callError: {
7754
7861
  scope: "network",
7755
7862
  source: e.source,
@@ -7757,15 +7864,7 @@ var Ra = new Set([
7757
7864
  description: "connection-failed"
7758
7865
  } }));
7759
7866
  break;
7760
- case ja.RECONNECT_TIMEOUT:
7761
- this._fail(new O(D.NETWORK_ERROR, { callError: {
7762
- scope: "network",
7763
- source: e.source,
7764
- code: "reconnect-timeout",
7765
- description: "connection-failed"
7766
- } }));
7767
- break;
7768
- case ja.ABORTED:
7867
+ case Ra.ABORTED:
7769
7868
  this._debug.debug("[signaling] aborted reconnect"), this._fail(new O(D.CANCELED));
7770
7869
  break;
7771
7870
  }
@@ -7777,7 +7876,7 @@ var Ra = new Set([
7777
7876
  this._debug.warn("[signaling] socket is dead, trying to reconnect"), this._logTransportStat(br.FAILED_PINGS);
7778
7877
  }
7779
7878
  _attachNotificationCallError(e) {
7780
- e.callError || !e.reason || e.reason === D.FAILED || e.reason === D.UNKNOWN_ERROR || !Ra.has(e.reason) && !e.errorCode || (e.callError = {
7879
+ e.callError || !e.reason || e.reason === D.FAILED || e.reason === D.UNKNOWN_ERROR || !Ga.has(e.reason) && !e.errorCode || (e.callError = {
7781
7880
  scope: "server",
7782
7881
  source: this._getSocketType(),
7783
7882
  code: e.errorCode || "protocol",
@@ -7785,7 +7884,7 @@ var Ra = new Set([
7785
7884
  });
7786
7885
  }
7787
7886
  _createSignalingCallError(e, t, n) {
7788
- let r = Ia[e];
7887
+ let r = Ua[e];
7789
7888
  if (r) return {
7790
7889
  scope: "server",
7791
7890
  source: n,
@@ -7807,39 +7906,39 @@ var Ra = new Set([
7807
7906
  ...t
7808
7907
  });
7809
7908
  }
7810
- }, Ba = /* @__PURE__ */ function(e) {
7909
+ }, qa = /* @__PURE__ */ function(e) {
7811
7910
  return e.INCOMING = "INCOMING", e.OUTGOING = "OUTGOING", e.JOINING = "JOINING", e;
7812
- }(Ba || {}), Va = /* @__PURE__ */ function(e) {
7911
+ }(qa || {}), Ja = /* @__PURE__ */ function(e) {
7813
7912
  return e.USER = "USER", e.GROUP = "GROUP", e.CHAT = "CHAT", e;
7814
- }(Va || {}), Ha = /* @__PURE__ */ function(e) {
7913
+ }(Ja || {}), Ya = /* @__PURE__ */ function(e) {
7815
7914
  return e.ATTENDEE = "ATTENDEE", e.HAND_UP = "HAND_UP", e;
7816
- }(Ha || {}), Ua = /* @__PURE__ */ function(e) {
7915
+ }(Ya || {}), Xa = /* @__PURE__ */ function(e) {
7817
7916
  return e.ADD_PARTICIPANT = "ADD_PARTICIPANT", e.RECORD = "RECORD", e.MOVIE_SHARE = "MOVIE_SHARE", e;
7818
- }(Ua || {}), Wa = /* @__PURE__ */ function(e) {
7917
+ }(Xa || {}), Za = /* @__PURE__ */ function(e) {
7819
7918
  return e.REQUIRE_AUTH_TO_JOIN = "REQUIRE_AUTH_TO_JOIN", e.AUDIENCE_MODE = "AUDIENCE_MODE", e.WAITING_HALL = "WAITING_HALL", e.WAIT_FOR_ADMIN = "WAIT_FOR_ADMIN", e.ADMIN_IS_HERE = "ADMIN_IS_HERE", e.ASR = "ASR", e.FEEDBACK = "FEEDBACK", e.RECURRING = "RECURRING", e;
7820
- }(Wa || {});
7821
- function Ga(e, t) {
7919
+ }(Za || {});
7920
+ function Qa(e, t) {
7822
7921
  if (e.length !== t.length) return !1;
7823
7922
  for (let n of e) if (!t.includes(n)) return !1;
7824
7923
  return !0;
7825
7924
  }
7826
- function Ka(e, t) {
7925
+ function $a(e, t) {
7827
7926
  let n = new Set(e);
7828
7927
  for (let [e, r] of Object.entries(t)) r ? n.add(e) : n.delete(e);
7829
7928
  return Array.from(n);
7830
7929
  }
7831
7930
  //#endregion
7832
7931
  //#region src/enums/MuteState.ts
7833
- var qa = /* @__PURE__ */ function(e) {
7932
+ var eo = /* @__PURE__ */ function(e) {
7834
7933
  return e.UNMUTE = "UNMUTE", e.MUTE = "MUTE", e.MUTE_PERMANENT = "MUTE_PERMANENT", e;
7835
- }(qa || {}), Z = /* @__PURE__ */ function(e) {
7934
+ }(eo || {}), Z = /* @__PURE__ */ function(e) {
7836
7935
  return e.CALLED = "CALLED", e.ACCEPTED = "ACCEPTED", e.REJECTED = "REJECTED", e.HUNGUP = "HUNGUP", e;
7837
- }(Z || {}), Ja = /* @__PURE__ */ function(e) {
7936
+ }(Z || {}), to = /* @__PURE__ */ function(e) {
7838
7937
  return e.UPDATE = "UPDATE", e.REMOVE = "REMOVE", e.ACTIVATE = "ACTIVATE", e.TIMEOUT = "TIMEOUT", e;
7839
- }(Ja || {}), Ya = /* @__PURE__ */ function(e) {
7938
+ }(to || {}), no = /* @__PURE__ */ function(e) {
7840
7939
  return e.NO_AVAILABLE_TRACKS = "no-available-tracks", e.UNKNOWN_ERROR = "unknown-error", e;
7841
- }(Ya || {});
7842
- function Xa(e) {
7940
+ }(no || {});
7941
+ function ro(e) {
7843
7942
  switch (e) {
7844
7943
  case 1: return "no-available-tracks";
7845
7944
  default: return "unknown-error";
@@ -7847,17 +7946,17 @@ function Xa(e) {
7847
7946
  }
7848
7947
  //#endregion
7849
7948
  //#region src/enums/UserRole.ts
7850
- var Za = /* @__PURE__ */ function(e) {
7949
+ var io = /* @__PURE__ */ function(e) {
7851
7950
  return e.CREATOR = "CREATOR", e.ADMIN = "ADMIN", e;
7852
- }(Za || {});
7853
- function Qa(e, t) {
7951
+ }(io || {});
7952
+ function ao(e, t) {
7854
7953
  if (e.length !== t.length) return !1;
7855
7954
  for (let n of e) if (!t.includes(n)) return !1;
7856
7955
  return !0;
7857
7956
  }
7858
7957
  //#endregion
7859
7958
  //#region src/static/ParticipantConnectionStatusUtils.ts
7860
- var $a;
7959
+ var oo;
7861
7960
  (function(e) {
7862
7961
  function t(e) {
7863
7962
  let t = e?.transport ?? e?.lastEffective ?? N.WAITING, n = {
@@ -7909,8 +8008,8 @@ var $a;
7909
8008
  shouldNotify: !0
7910
8009
  });
7911
8010
  }
7912
- })($a || ($a = {}));
7913
- var eo = $a, to = /* @__PURE__ */ function(e) {
8011
+ })(oo || (oo = {}));
8012
+ var so = oo, co = /* @__PURE__ */ function(e) {
7914
8013
  return e.USER = "USER", e.ANONYM = "ANONYM", e.GROUP = "GROUP", e;
7915
8014
  }({}), Q;
7916
8015
  (function(e) {
@@ -7973,7 +8072,7 @@ var eo = $a, to = /* @__PURE__ */ function(e) {
7973
8072
  })(Q || (Q = {}));
7974
8073
  //#endregion
7975
8074
  //#region src/types/WaitingHall.ts
7976
- function no(e) {
8075
+ function lo(e) {
7977
8076
  try {
7978
8077
  return btoa(JSON.stringify(e));
7979
8078
  } catch (t) {
@@ -7981,7 +8080,7 @@ function no(e) {
7981
8080
  }
7982
8081
  return null;
7983
8082
  }
7984
- function ro(e) {
8083
+ function uo(e) {
7985
8084
  try {
7986
8085
  return JSON.parse(atob(e));
7987
8086
  } catch (t) {
@@ -7991,12 +8090,12 @@ function ro(e) {
7991
8090
  }
7992
8091
  //#endregion
7993
8092
  //#region src/utils/Conversation.ts
7994
- var io = (e, t) => j.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
7995
- function ao(e) {
8093
+ var fo = (e, t) => j.objectReduce(e, (e, n, r) => (n === t && e.push(r), e), []);
8094
+ function po(e) {
7996
8095
  if (e.conversation?.muteStates) return e.conversation.muteStates;
7997
8096
  if (e.muteState && e.muteOptions) return e.muteOptions.reduce((t, n) => (t[n] = e.muteState, t), {});
7998
8097
  }
7999
- function oo(e, t) {
8098
+ function mo(e, t) {
8000
8099
  switch (e) {
8001
8100
  case S.AUDIO: return !!t.isAudioEnabled;
8002
8101
  case S.AUDIO_SHARING: return !!t.isAudioSharingEnabled;
@@ -8005,12 +8104,12 @@ function oo(e, t) {
8005
8104
  default: return !1;
8006
8105
  }
8007
8106
  }
8008
- function so(e, t) {
8107
+ function ho(e, t) {
8009
8108
  return j.objectReduce(e, (e, n, r) => {
8010
8109
  switch (n) {
8011
- case qa.MUTE:
8012
- case qa.MUTE_PERMANENT:
8013
- oo(r, t) || (e[r] = n);
8110
+ case eo.MUTE:
8111
+ case eo.MUTE_PERMANENT:
8112
+ mo(r, t) || (e[r] = n);
8014
8113
  break;
8015
8114
  default:
8016
8115
  e[r] = n;
@@ -8019,19 +8118,19 @@ function so(e, t) {
8019
8118
  return e;
8020
8119
  }, {});
8021
8120
  }
8022
- function co(e) {
8121
+ function go(e) {
8023
8122
  let { muteStates: t = {}, mediaSettings: n } = e;
8024
- return so(t, n);
8123
+ return ho(t, n);
8025
8124
  }
8026
- function lo(e, t) {
8125
+ function _o(e, t) {
8027
8126
  let n = e.conversation.participants.find((t) => j.comparePeerId(t.peerId, e.peerId));
8028
8127
  if (!n) return t;
8029
8128
  let { mediaSettings: r } = n;
8030
- return so(t, r);
8129
+ return ho(t, r);
8031
8130
  }
8032
8131
  //#endregion
8033
8132
  //#region src/utils/IceServers.ts
8034
- function uo(e) {
8133
+ function vo(e) {
8035
8134
  if (!e) return null;
8036
8135
  let t = Array.from(new Set((e.urls ?? []).map((e) => e.trim()).filter((e) => e.length > 0)));
8037
8136
  return t.length ? {
@@ -8039,8 +8138,8 @@ function uo(e) {
8039
8138
  urls: t
8040
8139
  } : null;
8041
8140
  }
8042
- function fo(e, t) {
8043
- let n = [], r = uo(e), i = uo(t);
8141
+ function yo(e, t) {
8142
+ let n = [], r = vo(e), i = vo(t);
8044
8143
  if (r && n.push(r), i) {
8045
8144
  let e = [...i.urls];
8046
8145
  e.push(`${e[e.length - 1]}?transport=tcp`), n.push({
@@ -8052,7 +8151,7 @@ function fo(e, t) {
8052
8151
  }
8053
8152
  //#endregion
8054
8153
  //#region src/utils/Lz4.ts
8055
- function po(e, t) {
8154
+ function bo(e, t) {
8056
8155
  let n = new Uint8Array(t), r = 0, i = 0;
8057
8156
  for (; r < e.length && i < t;) {
8058
8157
  let a = e[r++], o = a >> 4, s = a & 15;
@@ -8079,7 +8178,7 @@ function po(e, t) {
8079
8178
  }
8080
8179
  //#endregion
8081
8180
  //#region src/utils/SerializeLatest.ts
8082
- function mo(e) {
8181
+ function xo(e) {
8083
8182
  let t, n = !1, r, i = async () => {
8084
8183
  let t = !1, i;
8085
8184
  for (; n;) {
@@ -8100,7 +8199,7 @@ function mo(e) {
8100
8199
  }
8101
8200
  //#endregion
8102
8201
  //#region src/classes/AudioFix.ts
8103
- var ho = class {
8202
+ var So = class {
8104
8203
  constructor(e, t = R, n = null) {
8105
8204
  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;
8106
8205
  }
@@ -8138,7 +8237,7 @@ var ho = class {
8138
8237
  this._debug.warn("[AudioFix] Failed to fix RV (no packets): video restart", e);
8139
8238
  }));
8140
8239
  }
8141
- }, go = class {
8240
+ }, Co = class {
8142
8241
  constructor(e, t = !1, n = R, r = null) {
8143
8242
  h(this, "_audioElement", null), h(this, "_debug", void 0), h(this, "_preparedAudioElement", void 0), h(this, "_audioTracks", /* @__PURE__ */ new Map()), h(this, "_allowMultipleTracks", void 0), h(this, "_volume", 1), h(this, "_features", { setSinkId: !!Audio.prototype.setSinkId }), h(this, "_statFirstMediaReceived", void 0), h(this, "_logger", void 0), this._statFirstMediaReceived = e, this._allowMultipleTracks = t, this._debug = n, this._logger = r, this._preparedAudioElement = this._prepareAudioElement();
8144
8243
  }
@@ -8239,13 +8338,13 @@ var ho = class {
8239
8338
  };
8240
8339
  //#endregion
8241
8340
  //#region src/classes/conversation/ConversationResponseValidator.ts
8242
- function _o(e, t) {
8243
- e || yo(t, "response-empty"), e.id || yo(t, "id-empty"), e.endpoint || yo(t, "endpoint-empty"), !vo(e.stun_server) && !vo(e.turn_server) && yo(t, "ice-servers-empty");
8341
+ function wo(e, t) {
8342
+ e || Eo(t, "response-empty"), e.id || Eo(t, "id-empty"), e.endpoint || Eo(t, "endpoint-empty"), !To(e.stun_server) && !To(e.turn_server) && Eo(t, "ice-servers-empty");
8244
8343
  }
8245
- function vo(e) {
8344
+ function To(e) {
8246
8345
  return Array.isArray(e?.urls) && e.urls.length > 0;
8247
8346
  }
8248
- function yo(e, t) {
8347
+ function Eo(e, t) {
8249
8348
  let n = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), r = e === "fastStart" || e === "fastJoin";
8250
8349
  throw new O(r ? e === "fastStart" ? D.FAST_START_ERROR : D.FAST_JOIN_ERROR : D.UNKNOWN_ERROR, {
8251
8350
  message: `Invalid ${e} response: ${t}`,
@@ -8264,7 +8363,7 @@ function yo(e, t) {
8264
8363
  }
8265
8364
  //#endregion
8266
8365
  //#region src/classes/DebugInfo.ts
8267
- var bo = 90, xo = 3, So = class extends b {
8366
+ var Do = 90, Oo = 3, ko = class extends b {
8268
8367
  constructor(e = R) {
8269
8368
  super(), h(this, "_lastMemoryStat", {
8270
8369
  percent: 0,
@@ -8280,9 +8379,9 @@ var bo = 90, xo = 3, So = class extends b {
8280
8379
  let e = window?.performance?.memory;
8281
8380
  if (!e || !e.usedJSHeapSize || !e.jsHeapSizeLimit) return;
8282
8381
  let t = Number((100 * e.usedJSHeapSize / e.jsHeapSizeLimit).toFixed(2)), n = Number((e.usedJSHeapSize / 1024 / 1024).toFixed(1));
8283
- t > bo ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= xo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8382
+ t > Do ? this._debug.warn(`High memory usage: ${t}% (${n} MiB)`) : (!this._lastMemoryStat.percent || Math.abs(t - this._lastMemoryStat.percent) >= Oo) && (this._debug.debug(`Memory usage: ${t}% (${n} MiB)`), this._lastMemoryStat.percent = t, this._lastMemoryStat.bytes = e.usedJSHeapSize);
8284
8383
  }
8285
- }, Co = class {
8384
+ }, Ao = class {
8286
8385
  constructor({ api: e, debug: t, getParticipants: n, isMe: r, updateDisplayLayout: i, onNonFatalError: a }) {
8287
8386
  h(this, "_api", void 0), h(this, "_debug", void 0), h(this, "_getParticipants", void 0), h(this, "_isMe", void 0), h(this, "_updateDisplayLayout", void 0), h(this, "_onNonFatalError", void 0), h(this, "_requestedLayouts", {}), h(this, "_uncertainLayouts", {}), h(this, "_pendingRequests", null), h(this, "_pendingPromises", []), h(this, "_lastRequests", null), h(this, "_timer", null), h(this, "_inFlight", !1), h(this, "_lastFlushAt", null), h(this, "_generation", 0), h(this, "_forceNextFlush", !1), this._api = e, this._debug = t, this._getParticipants = n, this._isMe = r, this._updateDisplayLayout = i, this._onNonFatalError = a;
8288
8387
  }
@@ -8397,7 +8496,7 @@ var bo = 90, xo = 3, So = class extends b {
8397
8496
  let n = e, r = t;
8398
8497
  return n.width !== r.width || n.height !== r.height || n.fit !== r.fit || n.priority !== r.priority;
8399
8498
  }
8400
- }, wo = 44100, To = class {
8499
+ }, jo = 44100, Mo = class {
8401
8500
  constructor(e, t) {
8402
8501
  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]);
8403
8502
  try {
@@ -8414,7 +8513,7 @@ var bo = 90, xo = 3, So = class extends b {
8414
8513
  _getBins() {
8415
8514
  if (!this._fftBins || !this._analyser) return new Uint8Array();
8416
8515
  this._analyser.getByteFrequencyData(this._fftBins);
8417
- let e = wo / this._fftBins.length, t = Math.ceil(M.voiceParams.minFreq / e), n = Math.floor(M.voiceParams.maxFreq / e);
8516
+ let e = jo / this._fftBins.length, t = Math.ceil(M.voiceParams.minFreq / e), n = Math.floor(M.voiceParams.maxFreq / e);
8418
8517
  return this._fftBins.subarray(t, n);
8419
8518
  }
8420
8519
  getLevel() {
@@ -8427,7 +8526,7 @@ var bo = 90, xo = 3, So = class extends b {
8427
8526
  destroy() {
8428
8527
  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);
8429
8528
  }
8430
- }, Eo = class extends b {
8529
+ }, No = class extends b {
8431
8530
  constructor(e) {
8432
8531
  super(), h(this, "_detector", null), h(this, "_interval", null);
8433
8532
  let t = () => {
@@ -8443,7 +8542,7 @@ var bo = 90, xo = 3, So = class extends b {
8443
8542
  }), this.subscribe(e, qt.SOURCE_READY, n), n();
8444
8543
  }
8445
8544
  init(e) {
8446
- this._stopDetector(), this._detector = new To("local", e.clone());
8545
+ this._stopDetector(), this._detector = new Mo("local", e.clone());
8447
8546
  }
8448
8547
  _stopDetector() {
8449
8548
  this._detector && (this._detector.track.stop(), this._detector.destroy(), this._detector = null);
@@ -8451,7 +8550,7 @@ var bo = 90, xo = 3, So = class extends b {
8451
8550
  destroy() {
8452
8551
  this.unsubscribe(), this._interval && (window.clearTimeout(this._interval), this._interval = null), this._stopDetector();
8453
8552
  }
8454
- }, Do = class {
8553
+ }, Po = class {
8455
8554
  constructor(e, t = R) {
8456
8555
  h(this, "processor", void 0), h(this, "queue", []), h(this, "isProcessing", !1), h(this, "_debug", void 0), this.processor = e, this._debug = t;
8457
8556
  }
@@ -8471,9 +8570,9 @@ var bo = 90, xo = 3, So = class extends b {
8471
8570
  this.isProcessing = !1;
8472
8571
  }
8473
8572
  }
8474
- }, Oo = /* @__PURE__ */ function(e) {
8573
+ }, Fo = /* @__PURE__ */ function(e) {
8475
8574
  return e.VOLUMES_DETECTED = "VOLUMES_DETECTED", e;
8476
- }({}), ko = class extends b {
8575
+ }({}), Io = class extends b {
8477
8576
  constructor(e) {
8478
8577
  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));
8479
8578
  }
@@ -8481,7 +8580,7 @@ var bo = 90, xo = 3, So = class extends b {
8481
8580
  this._interval && (window.clearTimeout(this._interval), this._interval = null), this.unsubscribe(), this._destroyDetectors();
8482
8581
  }
8483
8582
  _onRemoteTrackAdded(e, t, n) {
8484
- if (n.kind === k.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new To(e, n)), !this._interval)) {
8583
+ if (n.kind === k.audio && (this._detectors.get(e)?.destroy(), this._detectors.set(e, new Mo(e, n)), !this._interval)) {
8485
8584
  let e = () => {
8486
8585
  this._collectVolumes(), this._interval = window.setTimeout(e, M.voiceParams.interval);
8487
8586
  };
@@ -8513,14 +8612,14 @@ var bo = 90, xo = 3, So = class extends b {
8513
8612
  }
8514
8613
  _getAudioTrackLevelByParticipantId(e) {
8515
8614
  if (this._isTransparentAudioMode()) return this._getTransparentAudioLevelByParticipantId(e);
8516
- let t = this._detectors.get(qr.AUDIO_MIX);
8615
+ let t = this._detectors.get(ei.AUDIO_MIX);
8517
8616
  return t ? t.getLevel() : null;
8518
8617
  }
8519
8618
  _getTransparentAudioLevelByParticipantId(e) {
8520
8619
  if (!this._activeParticipants?.includes(e)) return null;
8521
8620
  let t = null;
8522
8621
  return this._detectors.forEach((e, n) => {
8523
- if (!n.startsWith(`${qr.TRANSPARENT_AUDIO_TRACK_PREFIX}-`)) return;
8622
+ if (!n.startsWith(`${ei.TRANSPARENT_AUDIO_TRACK_PREFIX}-`)) return;
8524
8623
  let r = e.getLevel();
8525
8624
  (!t || r.real > t.real) && (t = r);
8526
8625
  }), t;
@@ -8539,11 +8638,11 @@ var bo = 90, xo = 3, So = class extends b {
8539
8638
  e.destroy();
8540
8639
  }), this._detectors.clear();
8541
8640
  }
8542
- }, Ao = /* @__PURE__ */ function(e) {
8641
+ }, Lo = /* @__PURE__ */ function(e) {
8543
8642
  return e.SPEAKER_CHANGED = "SPEAKER_CHANGED", e;
8544
- }({}), jo = class extends b {
8643
+ }({}), Ro = class extends b {
8545
8644
  constructor(e, t, n) {
8546
- super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === J.SERVER, this.subscribe(e, Oo.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));
8645
+ super(), h(this, "_speakerId", null), h(this, "_serverSideSpeakerDetection", !1), this._serverSideSpeakerDetection = n === J.SERVER, this.subscribe(e, Fo.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));
8547
8646
  }
8548
8647
  destroy() {
8549
8648
  this.unsubscribe();
@@ -8565,9 +8664,9 @@ var bo = 90, xo = 3, So = class extends b {
8565
8664
  _onTopologyChanged(e) {
8566
8665
  this._serverSideSpeakerDetection = e === J.SERVER;
8567
8666
  }
8568
- }, Mo = 15e3, No = 15e3, Po = class extends b {
8667
+ }, zo = 15e3, Bo = 15e3, Vo = class extends b {
8569
8668
  constructor(e, t, n, r = R, i = null) {
8570
- 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, Oo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8669
+ 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, Fo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this));
8571
8670
  }
8572
8671
  destroy() {
8573
8672
  this.unsubscribe(), this._connectionTimeout && window.clearTimeout(this._connectionTimeout), this._volumeTimeout && window.clearTimeout(this._volumeTimeout);
@@ -8579,10 +8678,10 @@ var bo = 90, xo = 3, So = class extends b {
8579
8678
  this._connectionTimeout || !this._connectionTimeoutSuppressed || this._reportConnectionTimeout();
8580
8679
  }
8581
8680
  _getConnectionTimeout() {
8582
- return this._transport.getTopology() === J.DIRECT ? Mo : M.specListenerParams.connectionTimeout;
8681
+ return this._transport.getTopology() === J.DIRECT ? zo : M.specListenerParams.connectionTimeout;
8583
8682
  }
8584
8683
  _getVolumeTimeout() {
8585
- return this._transport.getTopology() === J.DIRECT ? No : M.specListenerParams.volumeTimeout;
8684
+ return this._transport.getTopology() === J.DIRECT ? Bo : M.specListenerParams.volumeTimeout;
8586
8685
  }
8587
8686
  _onTransportStateChanged(e, t) {
8588
8687
  t === q.OPENED && (this._connectionTimeout || (this._connectionTimeoutSuppressed = !1, this._connectionTimeout = window.setTimeout(this._onConnectionTimeout.bind(this), this._getConnectionTimeout()))), t === q.CONNECTED && (this._volumeTimeout || (this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout())), this._volumeTimeout && (window.clearTimeout(this._volumeTimeout), this._volumeTimeout = window.setTimeout(this._onVolumeTimeout.bind(this), this._getVolumeTimeout()))), t === q.FAILED && this._connectionTimeout && (this._debug.warn("Transport failed, send callSpecError"), this._logger?.log(C.CALL_SPEC_ERROR, `${this._transport.getTopology()}_CONNECTION_TIMEOUT`));
@@ -8615,7 +8714,7 @@ var bo = 90, xo = 3, So = class extends b {
8615
8714
  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}`));
8616
8715
  }), e.length && this._debug.warn("There is silent participant, send callSpecError"), this._volumeTimeout = 0;
8617
8716
  }
8618
- }, Fo = class extends f {
8717
+ }, Ho = class extends f {
8619
8718
  constructor(e, t, n, r = () => void 0) {
8620
8719
  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();
8621
8720
  }
@@ -8695,7 +8794,7 @@ var bo = 90, xo = 3, So = class extends b {
8695
8794
  _now() {
8696
8795
  return Date.now() - this._serverTimeDelta;
8697
8796
  }
8698
- }, Io = "invalid-error-metadata", Lo = 64, Ro = new Set(Object.values(D)), zo = new Set(Object.values(x)), Bo = {
8797
+ }, Uo = "invalid-error-metadata", Wo = 64, Go = new Set(Object.values(D)), Ko = new Set(Object.values(x)), qo = {
8699
8798
  [D.CANCELED]: {
8700
8799
  type: "semantic",
8701
8800
  reason: "canceled"
@@ -8816,7 +8915,7 @@ var bo = 90, xo = 3, So = class extends b {
8816
8915
  type: "semantic",
8817
8916
  reason: "obsolete_client"
8818
8917
  }
8819
- }, Vo = {
8918
+ }, Jo = {
8820
8919
  [x.MIC_CAMERA_PERMISSION]: {
8821
8920
  type: "direct-error",
8822
8921
  error: {
@@ -8905,14 +9004,14 @@ var bo = 90, xo = 3, So = class extends b {
8905
9004
  }
8906
9005
  }
8907
9006
  };
8908
- function Ho(e) {
8909
- if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return Io;
9007
+ function Yo(e) {
9008
+ if (typeof e != "string" && typeof e != "number" || typeof e == "number" && !Number.isFinite(e)) return Uo;
8910
9009
  let t = String(e).trim();
8911
- if (!t) return Io;
9010
+ if (!t) return Uo;
8912
9011
  let n = t.toLowerCase().replace(/[\s_:]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
8913
- return !n || !/^[a-z0-9.-]+$/.test(n) ? Io : n.length > Lo ? `${n.slice(0, Lo - 3)}...` : n;
9012
+ return !n || !/^[a-z0-9.-]+$/.test(n) ? Uo : n.length > Wo ? `${n.slice(0, Wo - 3)}...` : n;
8914
9013
  }
8915
- function Uo(e) {
9014
+ function Xo(e) {
8916
9015
  if (!e || typeof e != "object") return !1;
8917
9016
  let t = e;
8918
9017
  switch (t.scope) {
@@ -8924,49 +9023,49 @@ function Uo(e) {
8924
9023
  default: return !1;
8925
9024
  }
8926
9025
  }
8927
- function Wo(e) {
8928
- let t = Ho(e.description);
9026
+ function Zo(e) {
9027
+ let t = Yo(e.description);
8929
9028
  if (e.scope === "unknown") return `unknown:${t}`;
8930
- let n = Ho(e.code);
9029
+ let n = Yo(e.code);
8931
9030
  return e.scope === "internal" ? `internal:${n}:${t}` : `${e.scope}:${e.source}:${n}:${t}`;
8932
9031
  }
8933
- function Go(e, t) {
9032
+ function Qo(e, t) {
8934
9033
  return t === null ? e.type === "direct-error" ? {
8935
9034
  reason: "error",
8936
- string_value: Wo(e.error)
8937
- } : { reason: "failed" } : Uo(t) ? {
9035
+ string_value: Zo(e.error)
9036
+ } : { reason: "failed" } : Xo(t) ? {
8938
9037
  reason: "error",
8939
- string_value: Wo(t)
9038
+ string_value: Zo(t)
8940
9039
  } : { reason: "failed" };
8941
9040
  }
8942
- function Ko(e) {
9041
+ function $o(e) {
8943
9042
  if (e.hangup) {
8944
- let t = Bo[e.hangup];
9043
+ let t = qo[e.hangup];
8945
9044
  return t ? t.type === "semantic" ? e.hangup === D.OBSOLETE_CLIENT && e.custom_error?.vchat_detailed_api_error.code ? {
8946
9045
  reason: t.reason,
8947
9046
  string_value: e.custom_error.vchat_detailed_api_error.code
8948
- } : { reason: t.reason } : Go(t, e.callError) : { reason: "failed" };
9047
+ } : { reason: t.reason } : Qo(t, e.callError) : { reason: "failed" };
8949
9048
  }
8950
9049
  if (e.error) {
8951
- let t = Vo[e.error];
8952
- return t ? Go(t, e.callError) : { reason: "failed" };
9050
+ let t = Jo[e.error];
9051
+ return t ? Qo(t, e.callError) : { reason: "failed" };
8953
9052
  }
8954
9053
  return { reason: "failed" };
8955
9054
  }
8956
- function qo(e) {
8957
- return e instanceof O ? Ko(e) : typeof e == "string" && (Ro.has(e) || zo.has(e)) ? Ko(new O(e)) : { reason: "failed" };
9055
+ function es(e) {
9056
+ return e instanceof O ? $o(e) : typeof e == "string" && (Go.has(e) || Ko.has(e)) ? $o(new O(e)) : { reason: "failed" };
8958
9057
  }
8959
9058
  //#endregion
8960
9059
  //#region src/classes/stat/CallLifecycleStats.ts
8961
- var Jo = {
9060
+ var ts = {
8962
9061
  wallNow: () => Date.now(),
8963
9062
  monotonicNow: () => performance.now()
8964
9063
  };
8965
- function Yo(e) {
9064
+ function ns(e) {
8966
9065
  return e === "anonym_join" ? "join" : e;
8967
9066
  }
8968
- var Xo = class {
8969
- constructor(e, t = Jo) {
9067
+ var rs = class {
9068
+ constructor(e, t = ts) {
8970
9069
  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;
8971
9070
  }
8972
9071
  get firstMediaSentReported() {
@@ -8978,7 +9077,7 @@ var Xo = class {
8978
9077
  markInitializationStarted({ source: e, conversationId: t }) {
8979
9078
  if (this._destroyed || this._callStartLabel !== null) return;
8980
9079
  let n = this._clock.wallNow();
8981
- this._callStartLabel = Yo(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
9080
+ this._callStartLabel = ns(e), this._lifecycleStartedAtMonotonic = this._clock.monotonicNow(), t && (this._conversationId = t), this._record({
8982
9081
  name: H.CALL_INIT,
8983
9082
  source: e
8984
9083
  }, n);
@@ -9006,7 +9105,7 @@ var Xo = class {
9006
9105
  !this._canRecord() || this._firstMediaSent || (this._firstMediaSent = !0, this._record({ name: H.FIRST_MEDIA_SENT }));
9007
9106
  }
9008
9107
  markFinished(e) {
9009
- this._finish(qo(e));
9108
+ this._finish(es(e));
9010
9109
  }
9011
9110
  markTerminated() {
9012
9111
  this._finish({ reason: "terminated" });
@@ -9057,7 +9156,7 @@ var Xo = class {
9057
9156
  ...n && { immediately: !0 }
9058
9157
  });
9059
9158
  }
9060
- }, Zo = class {
9159
+ }, is = class {
9061
9160
  constructor(e, t) {
9062
9161
  h(this, "_logger", void 0), h(this, "_codecUsages", /* @__PURE__ */ new Map()), h(this, "getCurrentTransportTopology", void 0), this._logger = e, this.getCurrentTransportTopology = t;
9063
9162
  }
@@ -9120,7 +9219,7 @@ var Xo = class {
9120
9219
  this.report(e);
9121
9220
  }), this._codecUsages.clear();
9122
9221
  }
9123
- }, Qo = class {
9222
+ }, as = class {
9124
9223
  constructor(e) {
9125
9224
  h(this, "_logger", void 0), h(this, "_eventualLogs", /* @__PURE__ */ new Set()), h(this, "_lastCallStatContext", null), this._logger = e;
9126
9225
  }
@@ -9153,12 +9252,11 @@ var Xo = class {
9153
9252
  for (let t of e) this._logEventualStat(t), this._eventualLogs.delete(t);
9154
9253
  }
9155
9254
  _logEventualStat({ data: e, occurredAt: t }) {
9156
- this._logger.logClientStats({
9157
- ...e,
9158
- ...this._lastCallStatContext ?? {}
9159
- }, { occurredAt: t });
9255
+ let n = { ...this._lastCallStatContext ?? {} };
9256
+ for (let [t, r] of Object.entries(e)) r !== void 0 && (r === null ? delete n[t] : n[t] = r);
9257
+ this._logger.logClientStats(n, { occurredAt: t });
9160
9258
  }
9161
- }, $o = class {
9259
+ }, os = class {
9162
9260
  constructor(e) {
9163
9261
  if (h(this, "q", void 0), h(this, "inits", []), h(this, "n", [
9164
9262
  1,
@@ -9217,7 +9315,7 @@ var Xo = class {
9217
9315
  5
9218
9316
  ];
9219
9317
  }
9220
- }, es = class {
9318
+ }, ss = class {
9221
9319
  constructor() {
9222
9320
  h(this, "n", 0), h(this, "mean", 0);
9223
9321
  }
@@ -9229,9 +9327,9 @@ var Xo = class {
9229
9327
  get avg() {
9230
9328
  return this.n ? this.mean : NaN;
9231
9329
  }
9232
- }, ts = class {
9330
+ }, cs = class {
9233
9331
  constructor() {
9234
- h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new es()), h(this, "p50", new $o(.5)), h(this, "p95", new $o(.95));
9332
+ h(this, "count", 0), h(this, "minVal", Infinity), h(this, "maxVal", -Infinity), h(this, "mean", new ss()), h(this, "p50", new os(.5)), h(this, "p95", new os(.95));
9235
9333
  }
9236
9334
  add(e) {
9237
9335
  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++;
@@ -9249,11 +9347,11 @@ var Xo = class {
9249
9347
  get hasData() {
9250
9348
  return this.count > 0;
9251
9349
  }
9252
- }, ns = class {
9350
+ }, ls = class {
9253
9351
  constructor(e) {
9254
9352
  h(this, "_logger", void 0), h(this, "trackerByTransport", {
9255
- ws: new ts(),
9256
- wt: new ts()
9353
+ ws: new cs(),
9354
+ wt: new cs()
9257
9355
  }), h(this, "lastSeen", {}), this._logger = e;
9258
9356
  }
9259
9357
  mark(e) {
@@ -9282,17 +9380,17 @@ var Xo = class {
9282
9380
  }
9283
9381
  destroy() {
9284
9382
  this.trackerByTransport = {
9285
- ws: new ts(),
9286
- wt: new ts()
9383
+ ws: new cs(),
9384
+ wt: new cs()
9287
9385
  }, this.lastSeen = {};
9288
9386
  }
9289
- }, rs = class {
9387
+ }, us = class {
9290
9388
  constructor(e) {
9291
9389
  h(this, "_logger", void 0), h(this, "trackerByCommand", /* @__PURE__ */ new Map()), this._logger = e;
9292
9390
  }
9293
9391
  mark(e, t, n) {
9294
9392
  let r = `${e}|${n}`, i;
9295
- this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new ts(), this.trackerByCommand.set(r, i)), i.add(t);
9393
+ this.trackerByCommand.has(r) ? i = this.trackerByCommand.get(r) : (i = new cs(), this.trackerByCommand.set(r, i)), i.add(t);
9296
9394
  }
9297
9395
  logMetrics() {
9298
9396
  for (let [e, t] of this.trackerByCommand.entries()) {
@@ -9314,9 +9412,9 @@ var Xo = class {
9314
9412
  destroy() {
9315
9413
  this.trackerByCommand.clear();
9316
9414
  }
9317
- }, is = class {
9415
+ }, ds = class {
9318
9416
  constructor(e, t, n, r) {
9319
- 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 Fo(e, t, n, r), this.lifecycle = new Xo(this.logger), this.statAggregator = new Qo(this.logger), this.codecStatsAggregator = new Zo(this.logger, r), this.pings = new ns(this.logger), this.signalingCommands = new rs(this.logger);
9417
+ 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 Ho(e, t, n, r), this.lifecycle = new rs(this.logger), this.statAggregator = new as(this.logger), this.codecStatsAggregator = new is(this.logger, r), this.pings = new ls(this.logger), this.signalingCommands = new us(this.logger);
9320
9418
  }
9321
9419
  logHangup(e) {
9322
9420
  this.lifecycle.markFinished(e);
@@ -9327,7 +9425,7 @@ var Xo = class {
9327
9425
  destroy() {
9328
9426
  this.lifecycle.markTerminated(), this.lifecycle.destroy(), this.statAggregator.destroy(), this.codecStatsAggregator.destroy(), this.pings.destroy(), this.signalingCommands.destroy(), this.logger.destroy();
9329
9427
  }
9330
- }, as = class {
9428
+ }, fs = class {
9331
9429
  constructor(e) {
9332
9430
  h(this, "_statAggregator", void 0), h(this, "_isCallMarked", !1), h(this, "_isFinished", !1), h(this, "_callType", null), this._statAggregator = e;
9333
9431
  }
@@ -9352,8 +9450,8 @@ var Xo = class {
9352
9450
  call_type: this._callType
9353
9451
  }));
9354
9452
  }
9355
- }, os = 1e3, ss = 1e4;
9356
- function cs(e, t, n, r) {
9453
+ }, ps = 1e3, ms = 1e4;
9454
+ function hs(e, t, n, r) {
9357
9455
  return new O(e, {
9358
9456
  callError: {
9359
9457
  scope: "external",
@@ -9364,11 +9462,11 @@ function cs(e, t, n, r) {
9364
9462
  message: r
9365
9463
  });
9366
9464
  }
9367
- var ls = 15, $ = class e extends b {
9465
+ var gs = 15, $ = class e extends b {
9368
9466
  constructor(e, t) {
9369
- 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", R.createSessionLogger()), h(this, "_volumesDetector", null), h(this, "_speakerDetector", null), h(this, "_localVolumeDetector", null), h(this, "_specListener", null), h(this, "_activeSpeakerId", null), h(this, "_lastSignalledActiveSpeakerId", null), h(this, "_isRealTimeAsrRequested", !1), h(this, "_serverSettings", kr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_onFastHangup", void 0), 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, "_toggleLocalVideo", mo((e) => {
9467
+ 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", R.createSessionLogger()), h(this, "_volumesDetector", null), h(this, "_speakerDetector", null), h(this, "_localVolumeDetector", null), h(this, "_specListener", null), h(this, "_activeSpeakerId", null), h(this, "_lastSignalledActiveSpeakerId", null), h(this, "_isRealTimeAsrRequested", !1), h(this, "_serverSettings", kr()), h(this, "_serverTimeOffset", 0), h(this, "_delayedHangup", !1), h(this, "_onFastHangup", void 0), 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, "_toggleLocalVideo", xo((e) => {
9370
9468
  if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "video_1" : "video_0"), this._mediaSource.toggleVideo(e);
9371
- })), h(this, "_toggleLocalAudio", mo((e) => {
9469
+ })), h(this, "_toggleLocalAudio", xo((e) => {
9372
9470
  if (this._mediaSource) return this._stats.logger.log(C.MEDIA_STATUS, e ? "audio_1" : "audio_0"), this._mediaSource.toggleAudio(e);
9373
9471
  })), h(this, "_changeMediaSettings", j.debounce(async (e) => {
9374
9472
  if (this._signaling.ready) try {
@@ -9380,7 +9478,7 @@ var ls = 15, $ = class e extends b {
9380
9478
  captureAudio: !1
9381
9479
  });
9382
9480
  }
9383
- }, 100)), this._stats = new is(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new za(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new Do(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new Co({
9481
+ }, 100)), this._stats = new ds(e, t, () => this._conversation?.id || null, () => this._transport?.getTopology() ?? this._conversation?.topology), this._api = e, this._signaling = new Ka(this._debug, this._stats.logger, this._stats.statAggregator, this._stats.pings, this._stats.signalingCommands), this._signalingActor = new Po(this._onSignalingNotification.bind(this), this._debug), this._displayLayoutRequester = new Ao({
9384
9482
  api: this._api,
9385
9483
  debug: this._debug,
9386
9484
  getParticipants: () => this._participants,
@@ -9389,13 +9487,13 @@ var ls = 15, $ = class e extends b {
9389
9487
  onNonFatalError: (e) => this._onNonFatalError(e)
9390
9488
  }), this._onUnload = () => {
9391
9489
  this._stopFirstMediaSentProbe(), this._conversation && this._api && this._sendHangupApi(this._conversation.id, this._state === "IDLE" ? D.CANCELED : D.HUNGUP), this._stats.destroy();
9392
- }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new as(this._stats.statAggregator), this._audioOutput = new go(this._statFirstMediaReceived, M.transparentAudio, this._debug, this._stats.logger), M.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), os));
9490
+ }, window.addEventListener("pagehide", this._onUnload), this._statFirstMediaReceived = new fs(this._stats.statAggregator), this._audioOutput = new Co(this._statFirstMediaReceived, M.transparentAudio, this._debug, this._stats.logger), M.videoTracksCount > 0 && (this._cooldownQueueCleanupTimer = window.setInterval(this._cleanupCooldownQueue.bind(this), ps));
9393
9491
  }
9394
9492
  static current() {
9395
9493
  return z.getActive() ?? (M.hold ? null : z.getFirst());
9396
9494
  }
9397
9495
  static hangupAfterInit(e) {
9398
- let t = us;
9496
+ let t = _s;
9399
9497
  if (t) {
9400
9498
  if (typeof e == "function" && (t._onFastHangup = e), t._delayedHangup === !1 && !t._conversation) {
9401
9499
  t._delayedHangup = !0, t._abortController?.abort(new O(D.CANCELED));
@@ -9423,7 +9521,7 @@ var ls = 15, $ = class e extends b {
9423
9521
  return this._state === "HELD";
9424
9522
  }
9425
9523
  get isIncomingRinging() {
9426
- return this._conversation?.direction === Ba.INCOMING && this._state === "IDLE";
9524
+ return this._conversation?.direction === qa.INCOMING && this._state === "IDLE";
9427
9525
  }
9428
9526
  static debugSessionId() {
9429
9527
  return e.current()?.debugSessionId ?? null;
@@ -9449,7 +9547,7 @@ var ls = 15, $ = class e extends b {
9449
9547
  L.onNonFatalError(Error(e), this.id);
9450
9548
  }
9451
9549
  getIncomingCallerExternalId() {
9452
- return this._conversation?.direction === Ba.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
9550
+ return this._conversation?.direction === qa.INCOMING ? Object.values(this._participants).find((e) => !this._isMe(e.id))?.externalId ?? null : null;
9453
9551
  }
9454
9552
  _buildInternalParams() {
9455
9553
  let e = {
@@ -9459,24 +9557,24 @@ var ls = 15, $ = class e extends b {
9459
9557
  platform: M.platform,
9460
9558
  protocolVersion: M.protocolVersion,
9461
9559
  domainId: M.domain,
9462
- capabilities: xa.getFlags()
9560
+ capabilities: Oa.getFlags()
9463
9561
  };
9464
9562
  return JSON.stringify(e);
9465
9563
  }
9466
9564
  async onStart({ opponentIds: e, opponentType: t, mediaOptions: n, payload: r = "", joiningAllowed: i = !1, requireAuthToJoin: a = !1, onlyAdminCanShareMovie: o, externalIds: s, onFastStart: c, conversationId: l }) {
9467
- let u = l ?? j.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === Va.USER && d === 1 ? M.calleeUnavailableWaitingTime : void 0;
9565
+ let u = l ?? j.uuid(), d = (e?.length ?? 0) + (s?.length ?? 0), f = t === Ja.USER && d === 1 ? M.calleeUnavailableWaitingTime : void 0;
9468
9566
  this._stats.lifecycle.markInitializationStarted({
9469
9567
  source: "outgoing",
9470
9568
  conversationId: u
9471
- }), this._debug.setConversationId(u), us = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
9569
+ }), this._debug.setConversationId(u), _s = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal);
9472
9570
  try {
9473
9571
  this._mediaSource = this._createMediaSource(), await this._mediaSource.request(n);
9474
9572
  let l = this._mediaSource.mediaSettings;
9475
- t === Va.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
9573
+ t === Ja.CHAT || e && e.length > 1 ? this._logWithMediaSettings(C.OUTGOING_MULTIPARTY_CALL, l) : this._logWithMediaSettings(C.OUTGOING_CALL, l);
9476
9574
  let d = await this._startConversation({
9477
9575
  opponentIds: e,
9478
9576
  opponentType: t,
9479
- direction: Ba.OUTGOING,
9577
+ direction: qa.OUTGOING,
9480
9578
  mediaOptions: n,
9481
9579
  payload: r,
9482
9580
  joiningAllowed: i,
@@ -9500,18 +9598,18 @@ var ls = 15, $ = class e extends b {
9500
9598
  let e = z.get(this._conversation.id);
9501
9599
  e && e !== this && e._close(new O(D.HUNGUP, { remote: !0 }));
9502
9600
  }
9503
- return z.add(this), await z.setActive(this.id), us = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9601
+ return z.add(this), await z.setActive(this.id), _s = null, this._conversation.concurrent && await this._acceptConcurrent(), f && !this._registeredPeerReceived && this._state !== "CLOSE" && (this._calleeUnavailableTimer = window.setTimeout(() => {
9504
9602
  this._calleeUnavailableTimer = null, this._close(new O(D.CALLEE_UNAVAILABLE), { signalingReason: D.CANCELED });
9505
9603
  }, f)), this._conversation;
9506
9604
  } catch (e) {
9507
- throw us = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
9605
+ throw _s = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to start conversation" }), e;
9508
9606
  }
9509
9607
  }
9510
9608
  async onJoin(e) {
9511
9609
  this._stats.lifecycle.markInitializationStarted({
9512
9610
  source: e.anonymous ? "anonym_join" : "join",
9513
9611
  conversationId: e.conversationId
9514
- }), us = 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);
9612
+ }), _s = 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);
9515
9613
  try {
9516
9614
  let t = !!e.observedIds?.length;
9517
9615
  if (t && M.videoTracksCount > 0) throw this._debug.error("Observer mode: please set videoTracksCount=0"), new O(D.UNSUPPORTED, { callError: {
@@ -9528,9 +9626,9 @@ var ls = 15, $ = class e extends b {
9528
9626
  code: "conversation",
9529
9627
  description: "not-initialized-after-join"
9530
9628
  } });
9531
- return this._conversation.observer = t, L.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), z.add(this), us = null, this._signaling.readyToSend(), L.onLocalStatus(this._conversation.waitForAdmin ? N.WAIT_FOR_ADMIN : N.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
9629
+ return this._conversation.observer = t, L.onLocalStream(this._mediaSource.getStream(), n, this.id), this._conversation.waitForAdmin || this._conversation.waitingHall ? (this._debug.log(this._conversation.waitForAdmin ? "Wait for admin" : "In waiting hall"), z.add(this), _s = null, this._signaling.readyToSend(), L.onLocalStatus(this._conversation.waitForAdmin ? N.WAIT_FOR_ADMIN : N.WAITING_HALL, this.id), this._conversation) : this._onJoinPart2(r);
9532
9630
  } catch (e) {
9533
- throw us = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9631
+ throw _s = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9534
9632
  }
9535
9633
  }
9536
9634
  async _onJoinPart2(e, t = !0, n = !1) {
@@ -9545,7 +9643,7 @@ var ls = 15, $ = class e extends b {
9545
9643
  if (this._delayedHangup) throw new O(D.CANCELED);
9546
9644
  this._processConnectionSharedMovieInfo(e), this._processConversationUrlSharingInfo(e), this._processConnectionAsrInfo(e);
9547
9645
  let r = this._extractExternalRoomsData(e.rooms?.rooms, e.rooms?.roomId);
9548
- L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (z.add(this), n ? await this._holdLocally() : await z.setActive(this.id), us = null);
9646
+ L.onConversation(this._conversation.externalId, this._conversation.mediaModifiers, this._getMuteStatesForCurrentRoom(), this._getMainRoomParticipants(), r, this.id), this._onConversationParticipantListChunk(e), this._processPinnedParticipants(e), L.onLocalStatus(N.WAITING, this.id), this._toggleJoinAvailability(), this._changeNeedRate(), t && (this._state = "ACTIVE"), this._changeFeatureSet(), t && (z.add(this), n ? await this._holdLocally() : await z.setActive(this.id), _s = null);
9549
9647
  let i = this._extractLocalParticipantFromConnection(e);
9550
9648
  if (i) {
9551
9649
  let e = j.mapParticipantState(i);
@@ -9553,7 +9651,7 @@ var ls = 15, $ = class e extends b {
9553
9651
  }
9554
9652
  return t && this._openTransport(Object.values(this._participants), !1), this._conversation;
9555
9653
  } catch (e) {
9556
- throw us = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9654
+ throw _s = null, this._cleanupRegistry(), this._close(e, { errorText: "Unable to join conversation" }), e;
9557
9655
  }
9558
9656
  }
9559
9657
  _extractExternalRooms(e) {
@@ -9573,7 +9671,7 @@ var ls = 15, $ = class e extends b {
9573
9671
  z.reserve(e), this._reservedId = e, this._stats.lifecycle.markInitializationStarted({
9574
9672
  source: "incoming",
9575
9673
  conversationId: e
9576
- }), this._debug.setConversationId(e), us = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal), a && this._api.setUserId(a);
9674
+ }), this._debug.setConversationId(e), _s = this, this._abortController = new AbortController(), this._api.setAbortSignal(this._abortController?.signal), this._signaling.setAbortSignal(this._abortController?.signal), a && this._api.setUserId(a);
9577
9675
  try {
9578
9676
  let a = await this._prepareConversation(e, t, n, r, i);
9579
9677
  if (this._mediaSource = this._createMediaSource(), !this._conversation) throw new O(D.UNKNOWN_ERROR, { callError: {
@@ -9582,20 +9680,20 @@ var ls = 15, $ = class e extends b {
9582
9680
  description: "incoming-not-initialized"
9583
9681
  } });
9584
9682
  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 O(D.REJECTED);
9585
- 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"), z.add(this), us = null, this._delayedHangup) throw new O(D.CANCELED);
9683
+ 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"), z.add(this), _s = null, this._delayedHangup) throw new O(D.CANCELED);
9586
9684
  } catch (e) {
9587
- throw us = null, this._cleanupRegistry(), this._close(e, {
9685
+ throw _s = null, this._cleanupRegistry(), this._close(e, {
9588
9686
  errorText: "Unable to handle inbound call push",
9589
9687
  signalingReason: e instanceof O && e.hangup === D.BUSY ? D.BUSY : void 0
9590
9688
  }), e;
9591
9689
  }
9592
9690
  }
9593
9691
  _isInWaitingHall(e) {
9594
- return !e.conversation || !e.conversation.options.includes(Wa.WAITING_HALL) ? !1 : this._isRestricted(e);
9692
+ return !e.conversation || !e.conversation.options.includes(Za.WAITING_HALL) ? !1 : this._isRestricted(e);
9595
9693
  }
9596
9694
  _isWaitForAdmin(e) {
9597
9695
  if (!e.conversation) return !1;
9598
- let t = e.conversation.options.includes(Wa.WAIT_FOR_ADMIN), n = e.conversation.options.includes(Wa.ADMIN_IS_HERE);
9696
+ let t = e.conversation.options.includes(Za.WAIT_FOR_ADMIN), n = e.conversation.options.includes(Za.ADMIN_IS_HERE);
9599
9697
  return !t || t && n ? !1 : this._isRestricted(e);
9600
9698
  }
9601
9699
  _isRestricted(e) {
@@ -9603,7 +9701,7 @@ var ls = 15, $ = class e extends b {
9603
9701
  return t && t.restricted || !1;
9604
9702
  }
9605
9703
  _isAudienceMode(e) {
9606
- return e.conversation?.options?.includes(Wa.AUDIENCE_MODE) || !1;
9704
+ return e.conversation?.options?.includes(Za.AUDIENCE_MODE) || !1;
9607
9705
  }
9608
9706
  _isAudienceModeListener() {
9609
9707
  return this._conversation?.audienceMode && this._conversation?.restricted;
@@ -9633,7 +9731,7 @@ var ls = 15, $ = class e extends b {
9633
9731
  let i = atob(n), a = new Uint8Array(i.length);
9634
9732
  for (let e = 0; e < i.length; e++) a[e] = i.charCodeAt(e);
9635
9733
  try {
9636
- let e = po(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);
9734
+ let e = bo(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);
9637
9735
  return {
9638
9736
  token: i,
9639
9737
  endpoint: l,
@@ -9836,10 +9934,10 @@ var ls = 15, $ = class e extends b {
9836
9934
  let t = await this._api.getConversationParams(e);
9837
9935
  this._debug.debug("Api.getConversationParams", t);
9838
9936
  let { turn_server: n, stun_server: r } = t;
9839
- return M.iceServers = fo(r, n), M.wssBase = t.endpoint, t.wt_endpoint && (M.wtsBase = t.wt_endpoint), M.wssToken = t.token, t.client_type && (M.clientType = t.client_type), t.external_user_type && (M.externalUserType = t.external_user_type), t;
9937
+ return M.iceServers = yo(r, n), M.wssBase = t.endpoint, t.wt_endpoint && (M.wtsBase = t.wt_endpoint), M.wssToken = t.token, t.client_type && (M.clientType = t.client_type), t.external_user_type && (M.externalUserType = t.external_user_type), t;
9840
9938
  }
9841
9939
  _setConversationParams({ turn_server: e, stun_server: t, endpoint: n, wt_endpoint: r, token: i, client_type: a }) {
9842
- M.iceServers = fo(t, e), M.wssBase = n, M.wssToken = i, r && (M.wtsBase = r), a && (M.clientType = a);
9940
+ M.iceServers = yo(t, e), M.wssBase = n, M.wssToken = i, r && (M.wtsBase = r), a && (M.clientType = a);
9843
9941
  }
9844
9942
  _buildSignalingEndpoint({ baseEndpoint: e, userId: t, type: n, deviceIdx: r, conversationId: i, token: a, conversationParams: o }) {
9845
9943
  let s = new URL(e), c = s.searchParams;
@@ -9871,10 +9969,10 @@ var ls = 15, $ = class e extends b {
9871
9969
  isVideo: f,
9872
9970
  joiningAllowed: a,
9873
9971
  requireAuthToJoin: o
9874
- }, this._abortController?.signal), !e) throw cs(D.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
9972
+ }, this._abortController?.signal), !e) throw hs(D.FAST_START_ERROR, "invalid-response", "fast-start-response-empty");
9875
9973
  if (!e.internalCallerParams) {
9876
9974
  let t = e.rejectedParticipants[0]?.status;
9877
- throw cs(D.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
9975
+ throw hs(D.FAST_START_ERROR, t ? "fast-start" : "invalid-response", t ?? "fast-start-internal-caller-params-empty", JSON.stringify(e));
9878
9976
  }
9879
9977
  } catch (e) {
9880
9978
  throw this._delayedHangup && this._abortController?.signal.aborted ? new O(D.CANCELED) : e instanceof O ? e : e instanceof Error ? new O(D.FAST_START_ERROR, { message: e.message }) : new O(D.FAST_START_ERROR, { message: String(e) });
@@ -9896,10 +9994,10 @@ var ls = 15, $ = class e extends b {
9896
9994
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
9897
9995
  }, this._debug.debug("FastStart", p), m = "fastStart";
9898
9996
  } catch {
9899
- throw cs(D.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
9997
+ throw hs(D.FAST_START_ERROR, "invalid-response", "fast-start-internal-caller-params-invalid");
9900
9998
  }
9901
9999
  } else p = await this._api.startConversation(d, e, t, f, i, a, o, { onlyAdminCanShareMovie: s }, c), this._debug.debug("Api.startConversation", p), m = "startConversation";
9902
- _o(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
10000
+ wo(p, m), this._setConversationParams(p), this._stats.lifecycle.bindConversationId(p.id);
9903
10001
  let ee = await this._connectSignaling(vr.START, p);
9904
10002
  return this._setConversation(p, ee, n), this._stats.lifecycle.markCallStarted(), ee;
9905
10003
  }
@@ -9924,9 +10022,9 @@ var ls = 15, $ = class e extends b {
9924
10022
  joinLink: i,
9925
10023
  isVideo: c,
9926
10024
  internalParams: this._buildInternalParams()
9927
- }, this._abortController?.signal), !e) throw cs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
9928
- if (!e.internalCallerParams) throw cs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
9929
- if (!e.conversationId) throw cs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
10025
+ }, this._abortController?.signal), !e) throw hs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-response-empty");
10026
+ if (!e.internalCallerParams) throw hs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-empty", JSON.stringify(e));
10027
+ if (!e.conversationId) throw hs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-conversation-id-empty", JSON.stringify(e));
9930
10028
  } catch (e) {
9931
10029
  throw this._delayedHangup && this._abortController?.signal.aborted ? new O(D.CANCELED) : e instanceof O ? e : e instanceof Error ? new O(D.FAST_JOIN_ERROR, { message: e.message }) : new O(D.FAST_JOIN_ERROR, { message: String(e) });
9932
10030
  }
@@ -9944,7 +10042,7 @@ var ls = 15, $ = class e extends b {
9944
10042
  token: new URL(t.endpoint).searchParams.get("token") ?? ""
9945
10043
  }, this._debug.debug("FastJoin", l), u = "fastJoin";
9946
10044
  } catch (e) {
9947
- throw e instanceof O ? e : cs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
10045
+ throw e instanceof O ? e : hs(D.FAST_JOIN_ERROR, "invalid-response", "fast-join-internal-caller-params-invalid");
9948
10046
  }
9949
10047
  } else if (t) l = await this._api.joinConversation(t, c, r), u = "joinConversation";
9950
10048
  else if (i) l = await this._api.joinConversationByLink(i, c, a, o), u = "joinConversationByLink";
@@ -9953,13 +10051,13 @@ var ls = 15, $ = class e extends b {
9953
10051
  code: "join",
9954
10052
  description: "target-missing"
9955
10053
  } });
9956
- if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), _o(l, u), l.id) {
10054
+ if (this._debug.debug("Api.joinConversation", l), l.id && this._stats.lifecycle.bindConversationId(l.id), wo(l, u), l.id) {
9957
10055
  if (z.has(l.id)) throw new O(D.HAS_ACTIVE_CALL);
9958
10056
  z.reserve(l.id), this._reservedId = l.id;
9959
10057
  }
9960
10058
  this._setConversationParams(l);
9961
10059
  let d = await this._connectSignaling(vr.JOIN, l);
9962
- return this._setConversation(l, d, Ba.JOINING), this._stats.lifecycle.markCallStarted(), d;
10060
+ return this._setConversation(l, d, qa.JOINING), this._stats.lifecycle.markCallStarted(), d;
9963
10061
  }
9964
10062
  async _prepareConversation(e, t = A.USER, n, r, i) {
9965
10063
  W.setMark(H.SIGNALING_CONNECTED), this._debug.debug("Conversation: push", {
@@ -10021,7 +10119,7 @@ var ls = 15, $ = class e extends b {
10021
10119
  }), l.wt_endpoint = c);
10022
10120
  }
10023
10121
  let u = await this._connectSignaling(vr.ACCEPT, l);
10024
- return z.callsLength >= M.maxParallelCalls || !M.hold && z.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(C.PUSH, "busy"), Promise.reject(new O(D.BUSY))) : (this._setConversation(l, u, Ba.INCOMING, t), u);
10122
+ return z.callsLength >= M.maxParallelCalls || !M.hold && z.callsLength > 0 ? (this._debug.log("Push rejected (busy)"), this._stats.logger.log(C.PUSH, "busy"), Promise.reject(new O(D.BUSY))) : (this._setConversation(l, u, qa.INCOMING, t), u);
10025
10123
  }
10026
10124
  _createParticipant(e, t, n = !0) {
10027
10125
  let r = Object.assign({
@@ -10048,7 +10146,7 @@ var ls = 15, $ = class e extends b {
10048
10146
  let e = this._getParticipantId(t ?? r.id);
10049
10147
  e && (r.externalId = e);
10050
10148
  }
10051
- return n && i && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && r.externalId && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = eo.create(r.connectionStatus), r;
10149
+ return n && i && this._api.cacheExternalId(t ?? r.id, r.externalId), t && this._api.mapDecorativeId(t, r.id), r.observedIds?.length && r.externalId && (r.externalId.observer = !0), e.markers && (r.markers = this._denormalizeMarkers(r.id, e.markers)), r.connectionStatus = so.create(r.connectionStatus), r;
10052
10150
  }
10053
10151
  _getParticipantId(e) {
10054
10152
  let t = this._api.userId(e);
@@ -10127,7 +10225,7 @@ var ls = 15, $ = class e extends b {
10127
10225
  }
10128
10226
  _createMediaSource() {
10129
10227
  let e = new Yt(this._debug, this._stats.logger);
10130
- return this.subscribe(e, qt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new ho(e, this._debug, this._stats.logger), e;
10228
+ return this.subscribe(e, qt.SOURCE_CHANGED, this._onLocalMediaStreamChanged.bind(this)), this.subscribe(e, qt.SCREEN_STATUS, this._onScreenSharingStatus.bind(this)), this._audioFix = new So(e, this._debug, this._stats.logger), e;
10131
10229
  }
10132
10230
  async _connectSignaling(e, t) {
10133
10231
  this._signaling.setEndpoint(t.endpoint), this._signaling.setWebTransportEndpoint(t.wt_endpoint ? t.wt_endpoint : null), this.subscribe(this._signaling, G.NOTIFICATION, (e) => this._signalingActor.add(e)), this.subscribe(this._signaling, G.FAILED, this._onSignalingFailed.bind(this)), this.subscribe(this._signaling, G.RECONNECT, this._onSignalingReconnect.bind(this));
@@ -10135,7 +10233,7 @@ var ls = 15, $ = class e extends b {
10135
10233
  return this._stats.statAggregator.logEventualStat({ name: H.SIGNALING_CONNECTED }), n;
10136
10234
  }
10137
10235
  async _processConnection(e) {
10138
- await this._registerConnectionParticipants(e), this._processRooms(e), this._processMuteStates(e), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), e.chatRoom && e.chatRoom.totalCount && this._onChatRoomUpdated(Ha.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
10236
+ await this._registerConnectionParticipants(e), this._processRooms(e), this._processMuteStates(e), this._processRecordInfos(e), this._onOptionsChanged(e.conversation.options), e.chatRoom && e.chatRoom.totalCount && this._onChatRoomUpdated(Ya.ATTENDEE, e.chatRoom.totalCount, e.chatRoom.firstParticipants, null, null);
10139
10237
  }
10140
10238
  _onConversationParticipantListChunk(e) {
10141
10239
  let t = e.participants;
@@ -10204,7 +10302,7 @@ var ls = 15, $ = class e extends b {
10204
10302
  _registerParticipantLocalMuteState({ muteStates: e, unmuteOptions: t }) {
10205
10303
  if (!e) return;
10206
10304
  let n = async () => {
10207
- let n = io(e, qa.MUTE), r = io(e, qa.MUTE_PERMANENT);
10305
+ let n = fo(e, eo.MUTE), r = fo(e, eo.MUTE_PERMANENT);
10208
10306
  for (let i of [n, r]) i.length && await this._onMuteParticipant({
10209
10307
  muteStates: e,
10210
10308
  unmuteOptions: t,
@@ -10218,8 +10316,8 @@ var ls = 15, $ = class e extends b {
10218
10316
  if (!(!M.enableSessionStateUpdates || this._isMe(e))) return t;
10219
10317
  }
10220
10318
  _buildConnectionStatus(e, t, n, r = !1) {
10221
- return eo.create({
10222
- transport: r ? N.ONHOLD : eo.fromTransportState(n) ?? N.WAITING,
10319
+ return so.create({
10320
+ transport: r ? N.ONHOLD : so.fromTransportState(n) ?? N.WAITING,
10223
10321
  sessionState: this._remoteParticipantSessionState(e, t),
10224
10322
  sessionStateApplicable: this._isParticipantSessionStateApplicable(e)
10225
10323
  });
@@ -10228,12 +10326,12 @@ var ls = 15, $ = class e extends b {
10228
10326
  return M.enableSessionStateUpdates && !this._isMe(e) && this._conversation?.topology === J.SERVER;
10229
10327
  }
10230
10328
  _setTransportStatus(e, t) {
10231
- return eo.setTransport(e.connectionStatus, t);
10329
+ return so.setTransport(e.connectionStatus, t);
10232
10330
  }
10233
10331
  _setSessionState(e, t) {
10234
- let n = eo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
10332
+ let n = so.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
10235
10333
  this._emitParticipantTransition(e, n);
10236
- let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === N.CONNECTED, i = eo.setSessionState(e.connectionStatus, t, r);
10334
+ let r = e.connectionStatus.sessionStateApplicable && e.id === this._activeSpeakerId && e.connectionStatus.transport === N.CONNECTED, i = so.setSessionState(e.connectionStatus, t, r);
10237
10335
  return this._emitParticipantTransition(e, i), i;
10238
10336
  }
10239
10337
  _emitParticipantTransition(e, t, n = null) {
@@ -10304,11 +10402,11 @@ var ls = 15, $ = class e extends b {
10304
10402
  this._onRoomSwitched(t, !0);
10305
10403
  }
10306
10404
  _processMuteStates(e, t = !1) {
10307
- let n = ao(e);
10405
+ let n = po(e);
10308
10406
  this._setMuteStatesForRoomId(n, null);
10309
10407
  for (let t of e.rooms?.rooms ?? []) this._setMuteStatesForRoomId(t.muteStates, t.id);
10310
10408
  let r = this._getMuteStatesForCurrentRoom();
10311
- t && (r = lo(e, r));
10409
+ t && (r = _o(e, r));
10312
10410
  let i = Object.keys(r), a = this._conversation?.roomId;
10313
10411
  i.length && this._onMuteParticipant({
10314
10412
  muteStates: r,
@@ -10328,15 +10426,15 @@ var ls = 15, $ = class e extends b {
10328
10426
  }
10329
10427
  _allocateTransport() {
10330
10428
  if (!this._conversation || !this._mediaSource) return;
10331
- this._transport = new la(this._conversation.topology, this._signaling, this._mediaSource, this._serverSettings, this._debug, this._stats.logger, this._stats.statAggregator, this._stats.codecStatsAggregator, this._getFirstMediaSentCallback()), this._debugInfo = new So(this._debug), this.subscribe(this._transport, X.STATE_CHANGED, this._onTransportStateChanged.bind(this)), this.subscribe(this._transport, X.LOCAL_STATE_CHANGED, this._onTransportLocalStateChanged.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_ADDED, this._onRemoteTrackAdded.bind(this)), this.subscribe(this._transport, X.REMOTE_TRACK_REMOVED, this._onRemoteTrackRemoved.bind(this)), this.subscribe(this._transport, X.AUDIO_MIX_STALL, this._onAudioMixStall.bind(this)), this.subscribe(this._transport, X.REMOTE_DATA_STATS, this._onRemoteDataStats.bind(this)), this.subscribe(this._transport, X.SIGNALLED_STALLED_PARTICIPANTS, this._onRemoteSignalledStall.bind(this)), this.subscribe(this._transport, X.TOPOLOGY_CHANGED, this._onTopologyChanged.bind(this)), this.subscribe(this._transport, X.NETWORK_STATUS, this._onNetworkStatus.bind(this)), this.subscribe(this._transport, X.REMOTE_STREAM_SECOND, this._onRemoteStreamSecond.bind(this)), this.subscribe(this._transport, X.PEER_CONNECTION_CLOSED, this._onPeerConnectionClosed.bind(this)), this.subscribe(this._transport, X.ASR_TRANSCRIPTION, this._onAsrTranscription.bind(this)), this.subscribe(this._transport, X.ANIMOJI_STREAM, this._onAnimojiStream.bind(this)), this.subscribe(this._transport, X.ANIMOJI_ERROR, this._onAnimojiError.bind(this));
10332
- let e = this._conversation.direction === Ba.OUTGOING && !this._conversation.concurrent, t = this._participants;
10429
+ this._transport = new ga(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 ko(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));
10430
+ let e = this._conversation.direction === qa.OUTGOING && !this._conversation.concurrent, t = this._participants;
10333
10431
  for (let n of Object.values(t)) (n.state === Z.ACCEPTED || n.state === Z.CALLED) && this._allocateParticipantTransport(n.id, e);
10334
10432
  }
10335
10433
  _createSpeakerDetector() {
10336
- this._transport && this._conversation && (this._volumesDetector = new ko(this._transport), this.subscribe(this._volumesDetector, Oo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new jo(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, Ao.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new Eo(this._mediaSource));
10434
+ this._transport && this._conversation && (this._volumesDetector = new Io(this._transport), this.subscribe(this._volumesDetector, Fo.VOLUMES_DETECTED, this._onVolumesDetected.bind(this)), this._speakerDetector = new Ro(this._volumesDetector, this._transport, this._conversation.topology), this.subscribe(this._speakerDetector, Lo.SPEAKER_CHANGED, this._onSpeakerChanged.bind(this)), this._localVolumeDetector = new No(this._mediaSource));
10337
10435
  }
10338
10436
  _createSpecListener() {
10339
- this._transport && this._volumesDetector && (this._specListener = new Po(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
10437
+ this._transport && this._volumesDetector && (this._specListener = new Vo(this._transport, this._volumesDetector, this._participants, this._debug, this._stats.logger));
10340
10438
  }
10341
10439
  _logDevices() {
10342
10440
  let e = T.getCameras().length, t = T.getMicrophones().length;
@@ -10435,7 +10533,7 @@ var ls = 15, $ = class e extends b {
10435
10533
  _onRemoveParticipant(e) {
10436
10534
  this._debug.debug(`Remove participant [${e}]`);
10437
10535
  let t = [], n = this._participants;
10438
- for (let r = 0; r <= ls; r++) {
10536
+ for (let r = 0; r <= gs; r++) {
10439
10537
  let i = n[j.compose(e, r)];
10440
10538
  i && t.push(i);
10441
10539
  }
@@ -10525,11 +10623,11 @@ var ls = 15, $ = class e extends b {
10525
10623
  this._waitingHallHoldPending = !1, await this._resumeLocalMedia(t, this._getWaitingForPromotionStatus()), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener();
10526
10624
  return;
10527
10625
  }
10528
- let n = ya.get();
10626
+ let n = Ea.get();
10529
10627
  await this._signaling.hold(!1, n), this._restoreStateAfterHold();
10530
10628
  let r = null;
10531
10629
  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, N.WAITING), this._allocateTransport(), this._createSpeakerDetector(), this._createSpecListener(), this._state === "ACTIVE") {
10532
- let e = this._conversation?.direction === Ba.OUTGOING && !this._conversation.concurrent;
10630
+ let e = this._conversation?.direction === qa.OUTGOING && !this._conversation.concurrent;
10533
10631
  this._openTransport(r ?? Object.values(this._participants), e);
10534
10632
  }
10535
10633
  }
@@ -10652,13 +10750,13 @@ var ls = 15, $ = class e extends b {
10652
10750
  let n = Nn(e), a = i[n.participantId];
10653
10751
  if (a) {
10654
10752
  let e;
10655
- typeof t == "number" ? e = Xa(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = Ya.UNKNOWN_ERROR), r.push({
10753
+ typeof t == "number" ? e = ro(t) : (this._debug.warn(`Unexpected error code ${t} received for participant ${n.participantId}`), e = no.UNKNOWN_ERROR), r.push({
10656
10754
  externalId: a.externalId,
10657
10755
  errorReason: e
10658
10756
  });
10659
10757
  }
10660
10758
  }
10661
- if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new ds("Could not allocate one or more participants", r);
10759
+ if (r && r.length && (this._debug.warn("Could not allocate one or more participants", r), t)) throw new vs("Could not allocate one or more participants", r);
10662
10760
  }
10663
10761
  async _cleanupCooldownQueue() {
10664
10762
  let e = {}, t = this._cooldownTimestampByStreamDescription.entries();
@@ -10666,7 +10764,7 @@ var ls = 15, $ = class e extends b {
10666
10764
  let n = t.next();
10667
10765
  if (n.done) break;
10668
10766
  let r = n.value;
10669
- if (r[1] + ss > Date.now()) break;
10767
+ if (r[1] + ms > Date.now()) break;
10670
10768
  let i = r[0];
10671
10769
  await this._stopStreaming(i), e[i] = { stopStream: !0 };
10672
10770
  } while (!0);
@@ -10870,10 +10968,10 @@ var ls = 15, $ = class e extends b {
10870
10968
  throw Error("transport is not initialized");
10871
10969
  }
10872
10970
  _isCallAdmin() {
10873
- return this._conversation ? j.includesOneOf(this._conversation.roles, [Za.ADMIN, Za.CREATOR]) : !1;
10971
+ return this._conversation ? j.includesOneOf(this._conversation.roles, [io.ADMIN, io.CREATOR]) : !1;
10874
10972
  }
10875
10973
  _checkAdminRole() {
10876
- if (this._conversation && !j.includesOneOf(this._conversation.roles, [Za.ADMIN, Za.CREATOR])) throw Error("You don't have the required permission");
10974
+ if (this._conversation && !j.includesOneOf(this._conversation.roles, [io.ADMIN, io.CREATOR])) throw Error("You don't have the required permission");
10877
10975
  }
10878
10976
  _isCalledState() {
10879
10977
  return this._participantState === Z.CALLED;
@@ -10911,21 +11009,21 @@ var ls = 15, $ = class e extends b {
10911
11009
  async changeOptions(e) {
10912
11010
  if (this._signaling.ready && this._conversation) {
10913
11011
  this._checkAdminRole(), await this._signaling.changeOptions(e);
10914
- let t = Ka(this._conversation.options, e);
11012
+ let t = $a(this._conversation.options, e);
10915
11013
  this._onOptionsChanged(t);
10916
11014
  }
10917
11015
  }
10918
11016
  async getWaitingHall(e, t, n) {
10919
11017
  if (!this._signaling) return Promise.reject();
10920
11018
  let r = null;
10921
- if (e && (r = ro(e), r)) {
11019
+ if (e && (r = uo(e), r)) {
10922
11020
  let e = this._api.getDecorativeIdByInitialId(r.id);
10923
11021
  r.id = e ?? r.id;
10924
11022
  }
10925
11023
  let i = await this._signaling.getWaitingHall(r, t, n);
10926
11024
  if (i.error) return Promise.reject(i.message);
10927
11025
  let a = i.participants || [], { externalIds: o } = this._resolveWaitingHallExternalIds(a, "getWaitingHall"), s = null;
10928
- return a.length && i.hasMore && (s = no(a[a.length - 1].id)), {
11026
+ return a.length && i.hasMore && (s = lo(a[a.length - 1].id)), {
10929
11027
  participants: o,
10930
11028
  pageMarker: s,
10931
11029
  totalCount: i.totalCount || 0
@@ -10959,7 +11057,7 @@ var ls = 15, $ = class e extends b {
10959
11057
  }
10960
11058
  async promoteParticipant(e, t) {
10961
11059
  if (this._signaling && this._conversation) try {
10962
- if (!j.includesOneOf(this._conversation.options, [Wa.WAITING_HALL, Wa.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
11060
+ if (!j.includesOneOf(this._conversation.options, [Za.WAITING_HALL, Za.AUDIENCE_MODE])) throw Error("Unable to promote a participant in the conversation with current options");
10963
11061
  if (this._checkAdminRole(), !e && t) throw Error("participantId is required");
10964
11062
  await this._signaling.promoteParticipant(e, t);
10965
11063
  } catch (t) {
@@ -11131,7 +11229,7 @@ var ls = 15, $ = class e extends b {
11131
11229
  let a = this._transport?.getState();
11132
11230
  return n.participants.forEach((e) => {
11133
11231
  let t = j.composeId(e), n = r[t];
11134
- this._updateParticipantExternalId(n, e), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, eo.fromTransportState(a) ?? N.WAITING), n.movieShareInfos = e.movieShareInfos, Object.assign(n.mediaSettings, E(e.mediaSettings)), Object.assign(n.muteStates, e.muteStates), n.unmuteOptions = e.unmuteOptions ?? n.unmuteOptions, this._openTransport([n], !0);
11232
+ this._updateParticipantExternalId(n, e), this._setSessionState(n, this._remoteParticipantSessionState(t, e.sessionState)), n.isOnHold || this._setTransportStatus(n, so.fromTransportState(a) ?? N.WAITING), n.movieShareInfos = e.movieShareInfos, Object.assign(n.mediaSettings, E(e.mediaSettings)), Object.assign(n.muteStates, e.muteStates), n.unmuteOptions = e.unmuteOptions ?? n.unmuteOptions, this._openTransport([n], !0);
11135
11233
  }), this._participantListChunkToExternalChunk(n);
11136
11234
  }
11137
11235
  async _getInitialParticiapntListChunk() {
@@ -11145,7 +11243,7 @@ var ls = 15, $ = class e extends b {
11145
11243
  _onLocalMediaStreamChanged(e) {
11146
11244
  if (!this._conversation || !this._mediaSource) return;
11147
11245
  let t = this._mediaSource.mediaSettings;
11148
- this._debug.debug("Local media stream changed", t), e.kind === k.audio && this._mediaSource && (this._audioFix = new ho(this._mediaSource, this._debug, this._stats.logger)), L.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
11246
+ this._debug.debug("Local media stream changed", t), e.kind === k.audio && this._mediaSource && (this._audioFix = new So(this._mediaSource, this._debug, this._stats.logger)), L.onLocalStreamUpdate(t, e.kind, this.id), !this._conversation?.waitingHall && !this._conversation?.observer && !this._isAudienceModeListener() && this._changeMediaSettings(t);
11149
11247
  }
11150
11248
  _onScreenSharingStatus(e) {
11151
11249
  let t = this.mediaSettings;
@@ -11275,9 +11373,9 @@ var ls = 15, $ = class e extends b {
11275
11373
  for (let n of e.conversation.participants) {
11276
11374
  let e = j.composeId(n), i = n.roles || [];
11277
11375
  if (this._isMe(e)) {
11278
- Qa(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
11376
+ ao(this._conversation.roles, i) || this._onRolesChanged(e, i), t = () => {
11279
11377
  this._registerParticipantLocalMuteState({
11280
- muteStates: co(n),
11378
+ muteStates: go(n),
11281
11379
  unmuteOptions: n.unmuteOptions
11282
11380
  });
11283
11381
  };
@@ -11295,7 +11393,7 @@ var ls = 15, $ = class e extends b {
11295
11393
  let t = E(n.mediaSettings);
11296
11394
  Wt(t, a.mediaSettings) || this._changeRemoteMediaSettings(e, t);
11297
11395
  let r = j.mapParticipantState(n), o = a.participantState;
11298
- j.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), Qa(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? N.ONHOLD : N.CONNECTED));
11396
+ j.isEqualParticipantState(r, o) || await this._changeRemoteParticipantState(e, r), ao(i, a.roles) || this._onRolesChanged(a.id, i), !!n.onHold != !!a.isOnHold && (a.isOnHold = !!n.onHold, this._setParticipantsStatus([a], n.onHold ? N.ONHOLD : N.CONNECTED));
11299
11397
  }
11300
11398
  }
11301
11399
  let i = this._participants;
@@ -11320,7 +11418,7 @@ var ls = 15, $ = class e extends b {
11320
11418
  this._close(new O(D.MISSED), { errorText: "Call accepted on other device" });
11321
11419
  return;
11322
11420
  }
11323
- this._conversation?.direction === Ba.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
11421
+ this._conversation?.direction === qa.OUTGOING && !this._conversation.concurrent && this._stats.lifecycle.markOutgoingAccepted();
11324
11422
  let r = this._getParticipant(t);
11325
11423
  if (!r) {
11326
11424
  let n = this._api.getDecorativeIdByInitialId(t);
@@ -11333,7 +11431,7 @@ var ls = 15, $ = class e extends b {
11333
11431
  let t = Q.fromSignaling(e.externalId, e.deviceIdx);
11334
11432
  r.externalId = t, this._api.cacheExternalId(r.id, t);
11335
11433
  }
11336
- r.state = Z.ACCEPTED, r.mediaSettings = E(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === Ba.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), this._state === "ACTIVE" && this._transport && this._transport.open([r.id], n), this._changeRemoteMediaSettings(t, r.mediaSettings), await this._changeRemoteParticipantState(t);
11434
+ r.state = Z.ACCEPTED, r.mediaSettings = E(e.mediaSettings), this._logWithMediaSettings(C.ACCEPTED_OUTGOING, r.mediaSettings), this._conversation && this._conversation.direction === qa.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);
11337
11435
  let i = Object.keys(r.muteStates);
11338
11436
  if (i.length && this._onMuteParticipant({
11339
11437
  muteStates: r.muteStates,
@@ -11345,7 +11443,7 @@ var ls = 15, $ = class e extends b {
11345
11443
  this._reportMissingExternalIds([t], "ACCEPTED_CALL");
11346
11444
  return;
11347
11445
  }
11348
- L.onAcceptedCall(r.externalId, xa.parseCapabilities(e.capabilities), this.id);
11446
+ L.onAcceptedCall(r.externalId, Oa.parseCapabilities(e.capabilities), this.id);
11349
11447
  }
11350
11448
  }
11351
11449
  async _onHungup(e) {
@@ -11382,7 +11480,7 @@ var ls = 15, $ = class e extends b {
11382
11480
  return;
11383
11481
  }
11384
11482
  if (e.connected) {
11385
- let e = eo.fromTransportState(this._transport?.getState());
11483
+ let e = so.fromTransportState(this._transport?.getState());
11386
11484
  e && this._setTransportStatus(n, e);
11387
11485
  }
11388
11486
  this._setSessionState(n, { connected: e.connected });
@@ -11459,7 +11557,7 @@ var ls = 15, $ = class e extends b {
11459
11557
  isOnHold: !!r.onHold
11460
11558
  }, i), n = this._getParticipant(t);
11461
11559
  }
11462
- this._conversation && this._conversation.direction === Ba.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = Z.ACCEPTED, n.mediaSettings = E(e.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], N.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], N.CONNECTED) : this._setParticipantsStatus([n], N.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._allocateParticipantTransport(n.id, !0), this._transport.open([n.id], null, !!this._conversation?.observer)), L.onParticipantJoined(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
11560
+ this._conversation && this._conversation.direction === qa.OUTGOING && (this._state === "IDLE" || this._state === "PROCESSING") && (this._state = "ACTIVE", this._changeFeatureSet()), n.state = Z.ACCEPTED, n.mediaSettings = E(e.mediaSettings), n.participantState = j.mapParticipantState(e.participant), n.roles = e.participant.roles || [], this._updateParticipantSessionState(n, t, e.participant.sessionState), e.participant.onHold ? (n.isOnHold = !0, this._setParticipantsStatus([n], N.ONHOLD)) : this._transport?.isAllocated(n.id) ? this._setParticipantsStatus([n], N.CONNECTED) : this._setParticipantsStatus([n], N.WAITING), r && this._emitParticipantEffectiveStatusIfSessionOverridesTransport(n), this._state !== "IDLE" && this._transport && (this._transport.isAllocated(n.id) || this._allocateParticipantTransport(n.id, !0), this._transport.open([n.id], null, !!this._conversation?.observer)), L.onParticipantJoined(n.externalId, n.markers, this.id), this._changeRemoteMediaSettings(t, n.mediaSettings), await this._changeRemoteParticipantState(t, n.participantState), this._invokeRolesChangedCallbackIfNeeded(n);
11463
11561
  let i = Object.keys(n.muteStates);
11464
11562
  i.length && this._onMuteParticipant({
11465
11563
  muteStates: n.muteStates,
@@ -11650,15 +11748,15 @@ var ls = 15, $ = class e extends b {
11650
11748
  L.onAsrTranscription(t, e.text, e.timestamp, e.duration, this.id);
11651
11749
  }
11652
11750
  async _onRolesChanged(e, t) {
11653
- if (this._conversation && this._isMe(e) && !Qa(this._conversation.roles, t)) {
11751
+ if (this._conversation && this._isMe(e) && !ao(this._conversation.roles, t)) {
11654
11752
  this._debug.debug(`Local roles changed: ${t}`), this._conversation.roles = t, L.onLocalRolesChanged(t, !1, this.id), this._processMuteState({
11655
- mediaOptions: io(this._getMuteStatesForCurrentRoom(), qa.MUTE_PERMANENT),
11753
+ mediaOptions: fo(this._getMuteStatesForCurrentRoom(), eo.MUTE_PERMANENT),
11656
11754
  stateUpdated: !0
11657
- }), j.includesOneOf(t, [Za.ADMIN, Za.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
11755
+ }), j.includesOneOf(t, [io.ADMIN, io.CREATOR]) ? this._refreshRooms(!0) : t.length || this._onRoomSwitched(null);
11658
11756
  return;
11659
11757
  }
11660
11758
  let n = this._getParticipant(e);
11661
- n && !Qa(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, L.onRolesChanged(n.externalId, t, !1, this.id));
11759
+ n && !ao(n.roles, t) && (this._debug.debug(`Roles for participant [${e}] changed: ${t}`), n.roles = t, L.onRolesChanged(n.externalId, t, !1, this.id));
11662
11760
  }
11663
11761
  async _onMuteParticipant(e, t = !1) {
11664
11762
  if (!this._conversation) return;
@@ -11707,7 +11805,7 @@ var ls = 15, $ = class e extends b {
11707
11805
  let { mediaOptions: t = [], muteAll: n, unmute: r, stateUpdated: i, requestedMedia: a, roomId: o = null, unmuteOptions: s = [] } = e, c = e.adminId ? this._getExternalIdByParticipantId(e.adminId) : null, l = Object.assign({}, e.muteStates ?? this._getMuteStatesForRoomId(o)), u = this._mediaSource.mediaSettings, d = Object.entries(l);
11708
11806
  for (let [e, i] of d) {
11709
11807
  let a = this._isCallAdmin() && n;
11710
- if (!(i !== qa.MUTE && i !== qa.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === qa.MUTE_PERMANENT && !n && (l[e] = qa.MUTE), !(!t.includes(e) || r))) switch (e) {
11808
+ if (!(i !== eo.MUTE && i !== eo.MUTE_PERMANENT || a) && (this._isCallAdmin() && i === eo.MUTE_PERMANENT && !n && (l[e] = eo.MUTE), !(!t.includes(e) || r))) switch (e) {
11711
11809
  case S.VIDEO:
11712
11810
  u.isVideoEnabled && (L.onDeviceSwitched(S.VIDEO, !1, this.id), await this.toggleLocalVideo(!1));
11713
11811
  break;
@@ -11744,7 +11842,7 @@ var ls = 15, $ = class e extends b {
11744
11842
  this._conversation.pinnedParticipantIdByRoom.set(r, t ? null : e);
11745
11843
  }
11746
11844
  _onOptionsChanged(e) {
11747
- this._conversation && !Ga(this._conversation.options, e) && (this._conversation.options = e, L.onOptionsChanged(e, this.id), e.includes(Wa.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && L.onLocalStatus(N.WAITING_HALL, this.id) : e.includes(Wa.WAIT_FOR_ADMIN) && this._conversation.restricted && L.onLocalStatus(N.WAIT_FOR_ADMIN, this.id));
11845
+ this._conversation && !Qa(this._conversation.options, e) && (this._conversation.options = e, L.onOptionsChanged(e, this.id), e.includes(Za.ADMIN_IS_HERE) ? this._conversation.restricted && this._conversation.waitingHall && L.onLocalStatus(N.WAITING_HALL, this.id) : e.includes(Za.WAIT_FOR_ADMIN) && this._conversation.restricted && L.onLocalStatus(N.WAIT_FOR_ADMIN, this.id));
11748
11846
  }
11749
11847
  async _onNetworkStatus(e) {
11750
11848
  if (this._conversation) {
@@ -11754,7 +11852,7 @@ var ls = 15, $ = class e extends b {
11754
11852
  if (this._isMe(r) || r === "") e = this._conversation.networkRating;
11755
11853
  else if (n[r]) e = n[r].networkRating;
11756
11854
  else continue;
11757
- if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i, Zr.getInstance().value = i, L.onLocalNetworkStatusChanged(i, this.id);
11855
+ if (e !== i) if (this._isMe(r) || r === "") this._conversation.networkRating = i, ii.getInstance().value = i, L.onLocalNetworkStatusChanged(i, this.id);
11758
11856
  else {
11759
11857
  let e = n[r];
11760
11858
  e.networkRating = i, t.push({
@@ -11799,7 +11897,7 @@ var ls = 15, $ = class e extends b {
11799
11897
  }
11800
11898
  _changeFeatureSet() {
11801
11899
  if (this._conversation) {
11802
- let e = this._state === "ACTIVE", t = this._conversation.features.includes(Ua.ADD_PARTICIPANT);
11900
+ let e = this._state === "ACTIVE", t = this._conversation.features.includes(Xa.ADD_PARTICIPANT);
11803
11901
  L.onCallState(e, t, this._conversation, this.id);
11804
11902
  }
11805
11903
  }
@@ -11833,7 +11931,7 @@ var ls = 15, $ = class e extends b {
11833
11931
  let n = this._getParticipant(e);
11834
11932
  if (n) {
11835
11933
  if (n.connectionStatus.sessionStateApplicable && n.connectionStatus.sessionState?.connected === !1) {
11836
- let e = eo.fromTransportState(this._transport?.getState());
11934
+ let e = so.fromTransportState(this._transport?.getState());
11837
11935
  e && this._setTransportStatus(n, e), n.connectionStatus.sessionStateConnectedBySpeaker = !0;
11838
11936
  let t = this._setTransportStatus(n, n.connectionStatus.transport);
11839
11937
  this._emitParticipantTransition(n, t);
@@ -11843,7 +11941,7 @@ var ls = 15, $ = class e extends b {
11843
11941
  }
11844
11942
  async _onTransportStateChanged(e, t) {
11845
11943
  this._debug.debug(`Transport state has changed: ${t}`, e);
11846
- let n = eo.fromTransportState(t);
11944
+ let n = so.fromTransportState(t);
11847
11945
  if (!n) return;
11848
11946
  let r = this._participants, i = [], a = e.reduce((e, n) => {
11849
11947
  if (n in r) {
@@ -11877,9 +11975,9 @@ var ls = 15, $ = class e extends b {
11877
11975
  return e.every((e) => t[e]?.isOnHold);
11878
11976
  }
11879
11977
  _onRemoteTrackAdded(e, t, n) {
11880
- if (e.endsWith(qr.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), L.onRemoteMixedAudioStream(t, this.id);
11881
- else if (e.startsWith(qr.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
11882
- else if (e.startsWith(qr.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
11978
+ if (e.endsWith(ei.AUDIO_MIX)) this._debug.debug("Remote audio mix track added"), this._audioOutput.add(e, n), L.onRemoteMixedAudioStream(t, this.id);
11979
+ else if (e.startsWith(ei.TRANSPARENT_AUDIO_TRACK_PREFIX)) this._debug.debug(`Remote transparent audio track added: ${e}`), this._audioOutput.add(e, n);
11980
+ else if (e.startsWith(ei.PARTICIPANT_AGNOSTIC_TRACK_PREFIX)) this._debug.debug(`Participant-agnostic track added: ${e}`), this._streamByStreamId.set(e, t);
11883
11981
  else {
11884
11982
  this._debug.debug(`Remote track added on the participant [${e}]`, { kind: n.kind });
11885
11983
  let r = this._getParticipant(e);
@@ -11906,7 +12004,7 @@ var ls = 15, $ = class e extends b {
11906
12004
  }
11907
12005
  }
11908
12006
  async _removeAudioTrack(e, t, n) {
11909
- if (e !== qr.AUDIO_MIX) {
12007
+ if (e !== ei.AUDIO_MIX) {
11910
12008
  let n = this._getParticipant(e);
11911
12009
  if (!n || n.remoteStream && n.remoteStream !== t) return;
11912
12010
  }
@@ -11921,7 +12019,7 @@ var ls = 15, $ = class e extends b {
11921
12019
  if (this._statFirstMediaReceived.markTopologyChanged(e), e === J.DIRECT && (this._onRemoteSignalledStall([]), this._onAudioMixStall(!1)), this._conversation) {
11922
12020
  this._conversation.topology = e;
11923
12021
  for (let e of Object.values(this._participants)) {
11924
- let t = eo.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
12022
+ let t = so.setSessionStateApplicable(e.connectionStatus, this._isParticipantSessionStateApplicable(e.id));
11925
12023
  this._emitParticipantTransition(e, t);
11926
12024
  }
11927
12025
  this._changeFeatureSet(), this._forceOpenTransportForAloneInCall();
@@ -11977,7 +12075,7 @@ var ls = 15, $ = class e extends b {
11977
12075
  ].includes(t) ? null : this._setTransportStatus(e, t), n);
11978
12076
  }
11979
12077
  _setParticipantsStalled(e, t) {
11980
- this._updateParticipantsStatus(e, (e) => eo.setStalled(e.connectionStatus, t));
12078
+ this._updateParticipantsStatus(e, (e) => so.setStalled(e.connectionStatus, t));
11981
12079
  }
11982
12080
  _updateParticipantsStatus(e, t, n = null) {
11983
12081
  let r = e.reduce((e, n) => {
@@ -11996,7 +12094,7 @@ var ls = 15, $ = class e extends b {
11996
12094
  _onRoomsUpdated(e) {
11997
12095
  if (this._isCalledState()) return;
11998
12096
  let t = {}, n = [], r = [];
11999
- for (let i of Object.keys(Ja)) {
12097
+ for (let i of Object.keys(to)) {
12000
12098
  let a = e.updates[i];
12001
12099
  a && (a?.rooms?.forEach((e) => {
12002
12100
  let { room: t, missingParticipantIds: i } = this._convertRoomToExternal(e);
@@ -12011,7 +12109,7 @@ var ls = 15, $ = class e extends b {
12011
12109
  }
12012
12110
  _onRoomUpdated(e) {
12013
12111
  let { room: t, missingParticipantIds: n } = this._convertRoomToExternal(e.room || null);
12014
- e.events.some((e) => e === Ja.UPDATE) && (e.muteStates !== void 0 && this._setMuteStatesForRoomId(e.muteStates, e.roomId), e.recordInfo !== void 0 && this._conversation?.recordsInfoByRoom.set(e.roomId, e.recordInfo), e.asrInfo !== void 0 && this._conversation?.asrInfoByRoom.set(e.roomId, e.asrInfo)), this._isCalledState() || (this._reportMissingExternalIds(n, "ROOM_UPDATED"), L.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id));
12112
+ e.events.some((e) => e === to.UPDATE) && (e.muteStates !== void 0 && this._setMuteStatesForRoomId(e.muteStates, e.roomId), e.recordInfo !== void 0 && this._conversation?.recordsInfoByRoom.set(e.roomId, e.recordInfo), e.asrInfo !== void 0 && this._conversation?.asrInfoByRoom.set(e.roomId, e.asrInfo)), this._isCalledState() || (this._reportMissingExternalIds(n, "ROOM_UPDATED"), L.onRoomUpdated(e.events, e.roomId, t, e.deactivate || null, this.id));
12015
12113
  }
12016
12114
  _convertRoomToExternal(e) {
12017
12115
  if (!e) return {
@@ -12122,7 +12220,7 @@ var ls = 15, $ = class e extends b {
12122
12220
  n && r.push(n);
12123
12221
  }
12124
12222
  }
12125
- r.length && !this._isCalledState() && L.onRoomsUpdated({ [Ja.UPDATE]: { rooms: r } }, this.id);
12223
+ r.length && !this._isCalledState() && L.onRoomsUpdated({ [to.UPDATE]: { rooms: r } }, this.id);
12126
12224
  }
12127
12225
  _onFeedback(e) {
12128
12226
  let t = [];
@@ -12198,19 +12296,19 @@ var ls = 15, $ = class e extends b {
12198
12296
  _getParticipant(e) {
12199
12297
  return this._participants[e];
12200
12298
  }
12201
- }, us = null, ds = class e extends Error {
12299
+ }, _s = null, vs = class e extends Error {
12202
12300
  constructor(t, n) {
12203
12301
  super(t), h(this, "participantErrors", void 0), Object.setPrototypeOf(this, e.prototype), this.participantErrors = n;
12204
12302
  }
12205
- }, fs = null, ps = null, ms = 64 * 1024;
12206
- function hs() {
12207
- fs = null, ps = null;
12303
+ }, ys = null, bs = null, xs = 64 * 1024;
12304
+ function Ss() {
12305
+ ys = null, bs = null;
12208
12306
  }
12209
- function gs(e) {
12307
+ function Cs(e) {
12210
12308
  return e?.endsWith("/") ? e.slice(0, -1) : e;
12211
12309
  }
12212
- async function _s(e = null, t) {
12213
- let n = gs(e ?? M.apiBaseUrl);
12310
+ async function ws(e = null, t) {
12311
+ let n = Cs(e ?? M.apiBaseUrl);
12214
12312
  if (n) return n;
12215
12313
  if ((t ?? M.apiEnv) !== "AUTO") return M.apiEndpoint(t);
12216
12314
  try {
@@ -12225,25 +12323,25 @@ async function _s(e = null, t) {
12225
12323
  return R.warn("Failed to resolve API endpoint using DNS, default is used", e), M.apiEndpoint(t);
12226
12324
  }
12227
12325
  }
12228
- async function vs() {
12229
- return fs || ps || (ps = _s(), fs = await ps, ps = null, fs);
12326
+ async function Ts() {
12327
+ return ys || bs || (bs = ws(), ys = await bs, bs = null, ys);
12230
12328
  }
12231
- async function ys(e, t = {}, n = !1) {
12329
+ async function Es(e, t = {}, n = !1) {
12232
12330
  if (!window.Blob || !window.navigator.sendBeacon) return;
12233
- await vs();
12234
- let r = Ts(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
12235
- window.navigator.sendBeacon(`${fs}/fb.do`, i);
12331
+ await Ts();
12332
+ let r = Ms(e, t, n), i = new window.Blob([r], { type: "application/x-www-form-urlencoded" });
12333
+ window.navigator.sendBeacon(`${ys}/fb.do`, i);
12236
12334
  }
12237
- async function bs(e, t = {}, n = !1, r) {
12238
- return await vs(), Ss(Ts(e, t, n), r);
12335
+ async function Ds(e, t = {}, n = !1, r) {
12336
+ return await Ts(), ks(Ms(e, t, n), r);
12239
12337
  }
12240
- async function xs(e, t = {}, n = !1) {
12241
- await vs();
12242
- let r = Ts(e, t, n);
12243
- return Ss(r, void 0, new Blob([r]).size <= ms);
12338
+ async function Os(e, t = {}, n = !1) {
12339
+ await Ts();
12340
+ let r = Ms(e, t, n);
12341
+ return ks(r, void 0, new Blob([r]).size <= xs);
12244
12342
  }
12245
- async function Ss(e, t, n = !1) {
12246
- let r = `${t ?? fs}/fb.do`, i = new AbortController(), a = new O(x.NETWORK, { callError: {
12343
+ async function ks(e, t, n = !1) {
12344
+ let r = `${t ?? ys}/fb.do`, i = new AbortController(), a = new O(x.NETWORK, { callError: {
12247
12345
  scope: "network",
12248
12346
  source: "api",
12249
12347
  code: "timeout",
@@ -12262,16 +12360,16 @@ async function Ss(e, t, n = !1) {
12262
12360
  } catch {
12263
12361
  o = { result: a };
12264
12362
  }
12265
- if (!t.ok && !Cs(o)) throw new O(x.API, { callError: {
12363
+ if (!t.ok && !As(o)) throw new O(x.API, { callError: {
12266
12364
  scope: "server",
12267
12365
  source: "api",
12268
12366
  code: `http-${t.status}`,
12269
12367
  description: "http-error"
12270
12368
  } });
12271
- if (Cs(o)) throw o;
12369
+ if (As(o)) throw o;
12272
12370
  return o;
12273
12371
  } catch (e) {
12274
- throw e instanceof O ? e : i.signal.aborted ? a : Cs(e) ? e : new O(x.NETWORK, { callError: {
12372
+ throw e instanceof O ? e : i.signal.aborted ? a : As(e) ? e : new O(x.NETWORK, { callError: {
12275
12373
  scope: "network",
12276
12374
  source: "api",
12277
12375
  code: "fetch-failed",
@@ -12281,12 +12379,12 @@ async function Ss(e, t, n = !1) {
12281
12379
  clearTimeout(o);
12282
12380
  }
12283
12381
  }
12284
- function Cs(e) {
12382
+ function As(e) {
12285
12383
  if (typeof e != "object" || !e) return !1;
12286
12384
  let t = e;
12287
12385
  return typeof t.error_code == "number" && typeof t.error_msg == "string";
12288
12386
  }
12289
- async function ws(e, t) {
12387
+ async function js(e, t) {
12290
12388
  try {
12291
12389
  let n = await fetch(e, {
12292
12390
  method: "POST",
@@ -12299,7 +12397,7 @@ async function ws(e, t) {
12299
12397
  throw R.warn("Failed to send form data", e), e;
12300
12398
  }
12301
12399
  }
12302
- function Ts(e, t = {}, n = !1) {
12400
+ function Ms(e, t = {}, n = !1) {
12303
12401
  t.method = e, t.format = "JSON", t.application_key || (t.application_key = M.apiKey), n || (y.sessionKey ? t.session_key = y.sessionKey : y.accessToken && (t.access_token = y.accessToken));
12304
12402
  for (let [e, n] of Object.entries(t)) typeof n == "object" && (t[e] = JSON.stringify(n));
12305
12403
  let r = "";
@@ -12308,7 +12406,7 @@ function Ts(e, t = {}, n = !1) {
12308
12406
  }
12309
12407
  //#endregion
12310
12408
  //#region src/abstract/BaseApi.ts
12311
- var Es = class {
12409
+ var Ns = class {
12312
12410
  constructor() {
12313
12411
  h(this, "_abortSignal", void 0);
12314
12412
  }
@@ -12345,14 +12443,14 @@ var Es = class {
12345
12443
  async getInbounds() {
12346
12444
  return [];
12347
12445
  }
12348
- }, Ds = class e {
12446
+ }, Ps = class e {
12349
12447
  constructor() {
12350
12448
  h(this, "_participantIdToExternalId", /* @__PURE__ */ new Map()), h(this, "_externalIdToParticipantId", /* @__PURE__ */ new Map()), h(this, "_decorativeIdToInitialId", /* @__PURE__ */ new Map()), h(this, "_initialIdToDecorativeId", /* @__PURE__ */ new Map());
12351
12449
  }
12352
12450
  static _normalizeType(e) {
12353
- return e.type === to.GROUP ? {
12451
+ return e.type === co.GROUP ? {
12354
12452
  ...e,
12355
- type: to.USER
12453
+ type: co.USER
12356
12454
  } : e;
12357
12455
  }
12358
12456
  getExternalId(e) {
@@ -12380,27 +12478,27 @@ var Es = class {
12380
12478
  clear() {
12381
12479
  this._participantIdToExternalId.clear(), this._externalIdToParticipantId.clear(), this._decorativeIdToInitialId.clear(), this._initialIdToDecorativeId.clear();
12382
12480
  }
12383
- }, Os = "anonymLogin:", ks = 700, As = 3e3;
12384
- function js(e) {
12481
+ }, Fs = "anonymLogin:", Is = 700, Ls = 3e3;
12482
+ function Rs(e) {
12385
12483
  let t = e.error_code;
12386
12484
  switch (t) {
12387
- case 2: return Ms(D.SERVICE_UNAVAILABLE, t, "service-unavailable");
12388
- case 4: return e.error_msg.includes("participants.limit.exceeded") ? Ms(D.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : Ms(x.API, t, "request-error");
12389
- case 300: return Ms(D.NOT_FOUND, t, "not-found");
12390
- case 1101: return Ms(D.SERVICE_DISABLED, t, "vchat-service-disabled");
12391
- case 1102: return Ms(D.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
12392
- case 1103: return Ms(D.NOT_FRIENDS, t, "friendship-required");
12393
- case 1104: return Ns(t, "youla-api-error");
12394
- case 1106: return Ns(t, "vk-api-error");
12395
- case 1113: return Ms(D.CALLER_IS_REJECTED, t, "caller-is-rejected");
12485
+ case 2: return zs(D.SERVICE_UNAVAILABLE, t, "service-unavailable");
12486
+ case 4: return e.error_msg.includes("participants.limit.exceeded") ? zs(D.PARTICIPANT_LIMIT_REACHED, t, "participants-limit-exceeded") : zs(x.API, t, "request-error");
12487
+ case 300: return zs(D.NOT_FOUND, t, "not-found");
12488
+ case 1101: return zs(D.SERVICE_DISABLED, t, "vchat-service-disabled");
12489
+ case 1102: return zs(D.CALLEE_IS_OFFLINE, t, "target-user-unavailable");
12490
+ case 1103: return zs(D.NOT_FRIENDS, t, "friendship-required");
12491
+ case 1104: return Bs(t, "youla-api-error");
12492
+ case 1106: return Bs(t, "vk-api-error");
12493
+ case 1113: return zs(D.CALLER_IS_REJECTED, t, "caller-is-rejected");
12396
12494
  case 1114: {
12397
12495
  let n = e.custom_error?.vchat_detailed_api_error?.code, r = n?.startsWith("obsolete_client");
12398
- return Ms(r ? D.OBSOLETE_CLIENT : D.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
12496
+ return zs(r ? D.OBSOLETE_CLIENT : D.VCHAT_DETAILED_ERROR, t, n ?? "detailed-error", r ? n : void 0);
12399
12497
  }
12400
- default: return Ms(x.API, t, "api-error");
12498
+ default: return zs(x.API, t, "api-error");
12401
12499
  }
12402
12500
  }
12403
- function Ms(e, t, n, r) {
12501
+ function zs(e, t, n, r) {
12404
12502
  return {
12405
12503
  type: e,
12406
12504
  callError: {
@@ -12412,7 +12510,7 @@ function Ms(e, t, n, r) {
12412
12510
  message: r
12413
12511
  };
12414
12512
  }
12415
- function Ns(e, t) {
12513
+ function Bs(e, t) {
12416
12514
  return {
12417
12515
  type: D.EXTERNAL_API_ERROR,
12418
12516
  callError: {
@@ -12423,19 +12521,19 @@ function Ns(e, t) {
12423
12521
  }
12424
12522
  };
12425
12523
  }
12426
- var Ps = class extends Es {
12524
+ var Vs = class extends Ns {
12427
12525
  constructor(...e) {
12428
- super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new Ds());
12526
+ super(...e), h(this, "_uuid", void 0), h(this, "_idCache", new Ps());
12429
12527
  }
12430
12528
  async _callUnsafe(e, t = {}, n = !1) {
12431
12529
  let r = async (i) => {
12432
12530
  try {
12433
- return await bs(e, t, n);
12531
+ return await Ds(e, t, n);
12434
12532
  } catch (t) {
12435
12533
  if (!t || typeof t != "object" || !Object.hasOwn(t, "error_msg")) {
12436
12534
  i++;
12437
12535
  let n = t && (typeof t == "object" || typeof t == "function") ? Object.getOwnPropertyNames(t).map((e) => `${e}: ${JSON.stringify(t[e])}`) : [String(t)];
12438
- if (R.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (R.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < M.apiMaxAttempt) return await j.delay(Math.min(i * ks, As), { signal: this._abortSignal }), r(i);
12536
+ if (R.debug(`${e} network error, attempt ${i}: ${n.join("\n ")}`), this._abortSignal?.aborted && (R.debug(`${e} aborted`), this._abortSignal.throwIfAborted()), i < M.apiMaxAttempt) return await j.delay(Math.min(i * Is, Ls), { signal: this._abortSignal }), r(i);
12439
12537
  }
12440
12538
  throw R.warn(e, "error", t), t;
12441
12539
  }
@@ -12458,8 +12556,8 @@ var Ps = class extends Es {
12458
12556
  message: i?.error_msg,
12459
12557
  code: i?.error_code
12460
12558
  };
12461
- if (i.custom_error && (a.custom_error = i.custom_error), Fs(i)) {
12462
- let e = js(i);
12559
+ if (i.custom_error && (a.custom_error = i.custom_error), Hs(i)) {
12560
+ let e = Rs(i);
12463
12561
  throw a.callError = e.callError, a.message = e.message ?? a.message, new O(e.type, a);
12464
12562
  }
12465
12563
  throw new O(x.API, a);
@@ -12489,7 +12587,7 @@ var Ps = class extends Es {
12489
12587
  let t = { session_data: {
12490
12588
  version: 2,
12491
12589
  device_id: this._uuid,
12492
- client_version: M.appVersion,
12590
+ client_version: M.apiClientVersion,
12493
12591
  client_type: "SDK_JS"
12494
12592
  } };
12495
12593
  return M.authToken && (t.session_data.auth_token = M.authToken, t.session_data.version = 3), this._callUnsafe("auth.anonymLogin", t, !0).then((e) => {
@@ -12508,17 +12606,17 @@ var Ps = class extends Es {
12508
12606
  });
12509
12607
  }
12510
12608
  _getAnonymLoginCacheKey() {
12511
- return M.authToken ? `${Os}${M.authToken}` : null;
12609
+ return M.authToken ? `${Fs}${M.authToken}` : null;
12512
12610
  }
12513
12611
  _getCachedAnonymLogin() {
12514
12612
  let e = this._getAnonymLoginCacheKey();
12515
12613
  if (!e) return null;
12516
12614
  let t = at.get(e);
12517
- return Is(t) ? t : (t && at.remove(e), null);
12615
+ return Us(t) ? t : (t && at.remove(e), null);
12518
12616
  }
12519
12617
  _setCachedAnonymLogin(e) {
12520
12618
  let t = this._getAnonymLoginCacheKey();
12521
- !t || !Is(e) || at.set(t, {
12619
+ !t || !Us(e) || at.set(t, {
12522
12620
  session_key: e.session_key,
12523
12621
  session_secret_key: e.session_secret_key,
12524
12622
  uid: e.uid
@@ -12536,7 +12634,7 @@ var Ps = class extends Es {
12536
12634
  }
12537
12635
  async _sendClientStats(e, t = !0) {
12538
12636
  try {
12539
- (await xs("vchat.clientStats", e))?.items_responses?.forEach((e) => {
12637
+ (await Os("vchat.clientStats", e))?.items_responses?.forEach((e) => {
12540
12638
  e.errors && R.error("[vchat.clientStats]", e);
12541
12639
  });
12542
12640
  } catch (n) {
@@ -12547,7 +12645,7 @@ var Ps = class extends Es {
12547
12645
  }
12548
12646
  logClientStats(e) {
12549
12647
  let t = {
12550
- app_version: String(M.appVersion),
12648
+ app_version: M.appVersion,
12551
12649
  sdk_type: "WEB",
12552
12650
  sdk_version: M.sdkVersion,
12553
12651
  version: 1,
@@ -12566,14 +12664,14 @@ var Ps = class extends Es {
12566
12664
  }, a = await this._callUnsafe("vchat.getLogUploadUrl", i), o = new FormData(), s = new Blob([r], { type: "application/json" });
12567
12665
  o.append("file", s, "log.json");
12568
12666
  let c = new URL(a.upload_url);
12569
- return c.searchParams.append("size", s.size.toString()), ws(c.toString(), o);
12667
+ return c.searchParams.append("size", s.size.toString()), js(c.toString(), o);
12570
12668
  }
12571
12669
  async joinConversation(e, t = !1, n) {
12572
12670
  let r = {
12573
12671
  conversationId: e,
12574
12672
  isVideo: t,
12575
12673
  protocolVersion: M.protocolVersion,
12576
- capabilities: xa.getFlags()
12674
+ capabilities: Oa.getFlags()
12577
12675
  };
12578
12676
  return n && (r.chatId = n), this._call("vchat.joinConversation", r);
12579
12677
  }
@@ -12605,13 +12703,13 @@ var Ps = class extends Es {
12605
12703
  externalIds: l
12606
12704
  });
12607
12705
  if (t && t.length) switch (n) {
12608
- case Va.USER:
12706
+ case Ja.USER:
12609
12707
  u.uids = t.join(",");
12610
12708
  break;
12611
- case Va.GROUP:
12709
+ case Ja.GROUP:
12612
12710
  u.gid = t[0];
12613
12711
  break;
12614
- case Va.CHAT:
12712
+ case Ja.CHAT:
12615
12713
  u.chatId = t[0];
12616
12714
  break;
12617
12715
  }
@@ -12654,7 +12752,7 @@ var Ps = class extends Es {
12654
12752
  joinLink: e,
12655
12753
  isVideo: t,
12656
12754
  protocolVersion: M.protocolVersion,
12657
- capabilities: xa.getFlags()
12755
+ capabilities: Oa.getFlags()
12658
12756
  };
12659
12757
  return n?.length && (i.observedIds = n.join(",")), M.anonymToken && (i.anonymToken = M.anonymToken), r && (i.payload = r), this._call("vchat.joinConversationByLink", i);
12660
12758
  }
@@ -12691,7 +12789,7 @@ var Ps = class extends Es {
12691
12789
  conversationId: e,
12692
12790
  reason: t
12693
12791
  };
12694
- M.anonymToken && (r.anonymToken = M.anonymToken), n?.peerId && (r.peerId = n.peerId), ys("vchat.hangupConversation", r);
12792
+ M.anonymToken && (r.anonymToken = M.anonymToken), n?.peerId && (r.peerId = n.peerId), Es("vchat.hangupConversation", r);
12695
12793
  }
12696
12794
  async removeHistoryRecords(e) {
12697
12795
  await this._call("vchat.removeHistoryRecords", { recordIds: e.join(",") });
@@ -12707,19 +12805,19 @@ var Ps = class extends Es {
12707
12805
  return Array.isArray(e?.inbounds) ? e.inbounds : [];
12708
12806
  }
12709
12807
  };
12710
- function Fs(e) {
12808
+ function Hs(e) {
12711
12809
  return typeof e == "object" && !!e && "error_code" in e && "error_msg" in e;
12712
12810
  }
12713
- function Is(e) {
12811
+ function Us(e) {
12714
12812
  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;
12715
12813
  }
12716
12814
  //#endregion
12717
12815
  //#region src/enums/RecordRole.ts
12718
- var Ls = /* @__PURE__ */ function(e) {
12816
+ var Ws = /* @__PURE__ */ function(e) {
12719
12817
  return e.KING = "KING", e.PAWN = "PAWN", e;
12720
- }(Ls || {}), Rs = /* @__PURE__ */ function(e) {
12818
+ }(Ws || {}), Gs = /* @__PURE__ */ function(e) {
12721
12819
  return e.OFF = "0", e.ON = "1", e;
12722
- }({}), zs = class {
12820
+ }({}), Ks = class {
12723
12821
  constructor(e) {
12724
12822
  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;
12725
12823
  }
@@ -12742,21 +12840,21 @@ var Ls = /* @__PURE__ */ function(e) {
12742
12840
  let e = this._queue[this._readCursor];
12743
12841
  return e && (this._moveReadCursor = !1, this._queue[this._readCursor] = null, this._readCursor = this.nextCursor(this._readCursor), --this._left), e;
12744
12842
  }
12745
- }, Bs = class {
12843
+ }, qs = class {
12746
12844
  constructor(e, t, n, r = null) {
12747
12845
  h(this, "_uuid", void 0), h(this, "_apiKey", void 0), h(this, "_callToken", void 0), h(this, "_apiEnv", void 0), h(this, "_baseApiUrl", void 0), h(this, "_sessionKey", void 0), this._uuid = j.uuid(), this._apiKey = t, this._callToken = n, this._apiEnv = e, this._baseApiUrl = r;
12748
12846
  }
12749
12847
  async authorize() {
12750
- let e = await bs("auth.anonymLogin", {
12848
+ let e = await Ds("auth.anonymLogin", {
12751
12849
  session_data: {
12752
12850
  device_id: this._uuid,
12753
- client_version: M.appVersion,
12851
+ client_version: M.apiClientVersion,
12754
12852
  client_type: "SDK_JS",
12755
12853
  auth_token: this._callToken,
12756
12854
  version: 3
12757
12855
  },
12758
12856
  application_key: this._apiKey
12759
- }, !0, await _s(this._baseApiUrl, this._apiEnv));
12857
+ }, !0, await ws(this._baseApiUrl, this._apiEnv));
12760
12858
  return j.isObject(e) && !("error_msg" in e) ? (this._sessionKey = e.session_key, !0) : !1;
12761
12859
  }
12762
12860
  async hangupConversation(e, t) {
@@ -12766,9 +12864,9 @@ var Ls = /* @__PURE__ */ function(e) {
12766
12864
  application_key: this._apiKey,
12767
12865
  session_key: this._sessionKey
12768
12866
  };
12769
- t?.peerId && (n.peerId = t.peerId), await bs("vchat.hangupConversation", n, !0, await _s(this._baseApiUrl, this._apiEnv));
12867
+ t?.peerId && (n.peerId = t.peerId), await Ds("vchat.hangupConversation", n, !0, await ws(this._baseApiUrl, this._apiEnv));
12770
12868
  }
12771
- }, Vs, Hs = null, Us = {
12869
+ }, Js, Ys = null, Xs = {
12772
12870
  getCameras: T.getCameras,
12773
12871
  getMicrophones: T.getMicrophones,
12774
12872
  getOutput: T.getOutput,
@@ -12794,27 +12892,27 @@ var Ls = /* @__PURE__ */ function(e) {
12794
12892
  baseChromeVersion: T.baseChromeVersion,
12795
12893
  getAudioContext: T.getAudioContext,
12796
12894
  isAudioShareSupported: T.isAudioShareSupported
12797
- }, Ws = { participantMarkerCompare: j.participantMarkerCompare };
12798
- function Gs(e) {
12799
- Hs = e;
12895
+ }, Zs = { participantMarkerCompare: j.participantMarkerCompare };
12896
+ function Qs(e) {
12897
+ Ys = e;
12800
12898
  }
12801
- function Ks(e) {
12899
+ function $s(e) {
12802
12900
  M.videoEffects = e;
12803
12901
  }
12804
- function qs(e) {
12902
+ function ec(e) {
12805
12903
  M.audioEffects = e;
12806
12904
  }
12807
- function Js(e, t = {}) {
12905
+ function tc(e, t = {}) {
12808
12906
  M.vad = e, M.vadOptions = t;
12809
12907
  }
12810
- function Ys(e, t = null, n = {}, r = 1) {
12908
+ function nc(e, t = null, n = {}, r = 1) {
12811
12909
  M.vmoji = e, M.vmojiOptions = {
12812
12910
  protocolVersion: r,
12813
12911
  renderingOptions: n
12814
12912
  }, t && e.setSDK(t);
12815
12913
  }
12816
- async function Xs(t) {
12817
- M.set(t), Vs || (Vs = new Ps()), e.disableLog(!M.debug), R.toggle(M.debug), R.log(`Calls SDK ${M.sdkVersion}`, t), await T.init();
12914
+ async function rc(t) {
12915
+ M.set(t), Js || (Js = new Vs()), e.disableLog(!M.debug), R.toggle(M.debug), R.log(`Calls SDK ${M.sdkVersion}`, t), await T.init();
12818
12916
  let n = T.getBrowserSupportFailure();
12819
12917
  if (n) throw new O(x.UNSUPPORTED, { callError: {
12820
12918
  scope: "internal",
@@ -12823,19 +12921,19 @@ async function Xs(t) {
12823
12921
  } });
12824
12922
  R.log("UserAgent:", navigator.userAgent), R.log("Screen resolution:", `${window.screen.width}x${window.screen.height}`), R.log("Permissions:", `Camera: ${T.hasCameraPermission()}, Mic: ${T.hasMicrophonePermission()}`), R.log("Simulcast:", `${t.simulcast} => ${M.simulcast}`);
12825
12923
  }
12826
- async function Zs(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12924
+ async function ic(e, t = [S.AUDIO], n = "", r = !1, i = !1, a, o, s) {
12827
12925
  let c = [];
12828
- return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), $s([], Va.USER, t, n, r, i, a, c, o, s);
12926
+ return Array.isArray(e) ? c = e.length ? e : [] : e && (c = [e]), oc([], Ja.USER, t, n, r, i, a, c, o, s);
12829
12927
  }
12830
- function Qs(e, t = []) {
12928
+ function ac(e, t = []) {
12831
12929
  let n = e.getIncomingCallerExternalId();
12832
12930
  return n ? t.length === 1 && t[0].id === n.id && t[0].type === n.type : !1;
12833
12931
  }
12834
- async function $s(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12932
+ async function oc(e, t = Ja.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12835
12933
  if (!M.hold && z.getActive()) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12836
12934
  let u = z.getAll().find((e) => e.isIncomingRinging);
12837
- if (!M.hold && u && !Qs(u, s)) throw R.error("There is already incoming call"), new O(D.HAS_ACTIVE_CALL);
12838
- return new $(new Ps(), Hs).onStart({
12935
+ if (!M.hold && u && !ac(u, s)) throw R.error("There is already incoming call"), new O(D.HAS_ACTIVE_CALL);
12936
+ return new $(new Vs(), Ys).onStart({
12839
12937
  opponentIds: e,
12840
12938
  opponentType: t,
12841
12939
  mediaOptions: n,
@@ -12848,40 +12946,40 @@ async function $s(e, t = Va.USER, n, r = "", i = !1, a = !1, o, s, c, l) {
12848
12946
  conversationId: l
12849
12947
  });
12850
12948
  }
12851
- async function ec(e, t) {
12852
- return tc(e, A.USER, void 0, t);
12949
+ async function sc(e, t) {
12950
+ return cc(e, A.USER, void 0, t);
12853
12951
  }
12854
- async function tc(e, t = A.USER, n, r, i, a) {
12952
+ async function cc(e, t = A.USER, n, r, i, a) {
12855
12953
  if (e === $.id()) throw Error("Push has already been processed");
12856
- return new $(new Ps(), Hs).onPush(e, t, n, r, i, a);
12954
+ return new $(new Vs(), Ys).onPush(e, t, n, r, i, a);
12857
12955
  }
12858
- async function nc() {
12859
- return Vs.getInbounds();
12956
+ async function lc() {
12957
+ return Js.getInbounds();
12860
12958
  }
12861
- async function rc(e, t) {
12862
- return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, hs()), Vs.authorize();
12959
+ async function uc(e, t) {
12960
+ return e && (M.authToken = e), t !== void 0 && M.apiBaseUrl !== t && (M.apiBaseUrl = t, Ss()), Js.authorize();
12863
12961
  }
12864
- async function ic(e = [S.AUDIO], t) {
12865
- return kl(t).accept(e);
12962
+ async function dc(e = [S.AUDIO], t) {
12963
+ return Il(t).accept(e);
12866
12964
  }
12867
- async function ac(e) {
12868
- let t = El(e?.conversationId);
12965
+ async function fc(e) {
12966
+ let t = Nl(e?.conversationId);
12869
12967
  if (t) return t.decline(e);
12870
12968
  }
12871
- async function oc(e, t = [S.AUDIO]) {
12872
- return sc(e, t);
12969
+ async function pc(e, t = [S.AUDIO]) {
12970
+ return mc(e, t);
12873
12971
  }
12874
- async function sc(e, t, n) {
12972
+ async function mc(e, t, n) {
12875
12973
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12876
- return new $(new Ps(), Hs).onJoin({
12974
+ return new $(new Vs(), Ys).onJoin({
12877
12975
  conversationId: e,
12878
12976
  mediaOptions: t,
12879
12977
  chatId: n
12880
12978
  });
12881
12979
  }
12882
- async function cc(e, t = [S.AUDIO], n, r, i, a) {
12980
+ async function hc(e, t = [S.AUDIO], n, r, i, a) {
12883
12981
  if (!M.hold && z.callsLength > 0) throw R.error("There is already active call"), new O(D.HAS_ACTIVE_CALL);
12884
- return n && (M.anonymToken = n), new $(new Ps(), Hs).onJoin({
12982
+ return n && (M.anonymToken = n), new $(new Vs(), Ys).onJoin({
12885
12983
  joinLink: e,
12886
12984
  mediaOptions: t,
12887
12985
  observedIds: r,
@@ -12890,30 +12988,30 @@ async function cc(e, t = [S.AUDIO], n, r, i, a) {
12890
12988
  anonymous: !!M.anonymToken
12891
12989
  });
12892
12990
  }
12893
- function lc(e) {
12894
- let t = El(e?.conversationId);
12991
+ function gc(e) {
12992
+ let t = Nl(e?.conversationId);
12895
12993
  return t ? t.hangup(e) : ($.hangupAfterInit(e?.onFastHangup), Promise.resolve());
12896
12994
  }
12897
- async function uc(e, t) {
12995
+ async function _c(e, t) {
12898
12996
  let n = Array.isArray(e) ? e : [e], r = $.current();
12899
12997
  r && await r.addParticipant(n, t);
12900
12998
  }
12901
- async function dc(e, t) {
12999
+ async function vc(e, t) {
12902
13000
  let n = $.current();
12903
13001
  if (n) {
12904
13002
  let r = e.map((e) => j.composeUserId(e));
12905
13003
  await n.addParticipantLegacy(r, t);
12906
13004
  }
12907
13005
  }
12908
- async function fc(e, t = !1) {
12909
- let n = Al(e, "removeParticipant");
13006
+ async function yc(e, t = !1) {
13007
+ let n = Ll(e, "removeParticipant");
12910
13008
  if (n) try {
12911
13009
  await n.conversation.removeParticipant(j.decomposeParticipantId(n.participantId).compositeUserId, t);
12912
13010
  } catch (e) {
12913
13011
  R.warn(`Failed to remove participant ${n.participantId}. Perhaps he is no longer on the call. ${e}`);
12914
13012
  }
12915
13013
  }
12916
- async function pc(e, t = !1) {
13014
+ async function bc(e, t = !1) {
12917
13015
  let n = $.current();
12918
13016
  if (n) try {
12919
13017
  await n.removeParticipant(j.composeUserId(e), t);
@@ -12921,13 +13019,13 @@ async function pc(e, t = !1) {
12921
13019
  R.warn(`Failed to remove participant ${e}. Perhaps he is no longer on the call. ${t}`);
12922
13020
  }
12923
13021
  }
12924
- async function mc(e, t) {
13022
+ async function xc(e, t) {
12925
13023
  let n = $.current();
12926
13024
  if (e === "videoinput" && jt.contains(t)) return M.videoFacingMode = t, n ? (T.isMobile() && n.stopVideoTrack(), n.changeDevice(e)) : void 0;
12927
13025
  if (!await T._saveDeviceId(e, t)) throw Error(`Device not found: ${t}`);
12928
13026
  if (n) return n.changeDevice(e);
12929
13027
  }
12930
- async function hc(e, t) {
13028
+ async function Sc(e, t) {
12931
13029
  let n = typeof e == "object" ? {
12932
13030
  ...e,
12933
13031
  fastScreenSharing: e.captureScreen && e.fastScreenSharing,
@@ -12936,40 +13034,40 @@ async function hc(e, t) {
12936
13034
  captureScreen: e,
12937
13035
  fastScreenSharing: !1,
12938
13036
  captureAudio: !1
12939
- }, r = El(t);
13037
+ }, r = Nl(t);
12940
13038
  return r ? r.toggleScreenCapturing(n) : Promise.reject();
12941
13039
  }
12942
- function gc(e) {
13040
+ function Cc(e) {
12943
13041
  let t = $.current();
12944
13042
  t && t.toggleAnimojiCapturing(e);
12945
13043
  }
12946
- async function _c(e, t = !1) {
13044
+ async function wc(e, t = !1) {
12947
13045
  let n = $.current();
12948
13046
  n && await n.setVideoStream(e, t);
12949
13047
  }
12950
- async function vc(e, t) {
12951
- let n = El(t);
13048
+ async function Tc(e, t) {
13049
+ let n = Nl(t);
12952
13050
  n && await n.toggleLocalVideo(e);
12953
13051
  }
12954
- async function yc(e, t) {
12955
- let n = El(t);
13052
+ async function Ec(e, t) {
13053
+ let n = Nl(t);
12956
13054
  n && await n.toggleLocalAudio(e);
12957
13055
  }
12958
- async function bc(e) {
13056
+ async function Dc(e) {
12959
13057
  let t = $.current();
12960
13058
  if (t) return t.setLocalResolution(e);
12961
13059
  }
12962
- async function xc(e) {
13060
+ async function Oc(e) {
12963
13061
  let t = $.current();
12964
13062
  t && await t.changePriorities(e);
12965
13063
  }
12966
- async function Sc(e, t) {
13064
+ async function kc(e, t) {
12967
13065
  let n = $.current();
12968
13066
  if (n) {
12969
13067
  if (t) {
12970
13068
  let r = n.getCachedParticipantIdByExternalId(t);
12971
13069
  if (!r) {
12972
- Dl(t, "changeParticipantState", n);
13070
+ Pl(t, "changeParticipantState", n);
12973
13071
  return;
12974
13072
  }
12975
13073
  await n.changeParticipantState(e, r);
@@ -12978,161 +13076,161 @@ async function Sc(e, t) {
12978
13076
  await n.changeParticipantState(e);
12979
13077
  }
12980
13078
  }
12981
- async function Cc() {
13079
+ async function Ac() {
12982
13080
  let e = $.current();
12983
13081
  e && await e.putHandsDown();
12984
13082
  }
12985
- async function wc(e) {
13083
+ async function jc(e) {
12986
13084
  let t = $.current();
12987
13085
  t && await t.updateDisplayLayout(e);
12988
13086
  }
12989
- async function Tc(e) {
13087
+ async function Mc(e) {
12990
13088
  let t = $.current();
12991
13089
  t && await t.requestDisplayLayout(e);
12992
13090
  }
12993
- async function Ec(e, t, n = !1) {
12994
- let r = Al(e, "grantRoles");
13091
+ async function Nc(e, t, n = !1) {
13092
+ let r = Ll(e, "grantRoles");
12995
13093
  r && await r.conversation.grantRoles(r.participantId, t, n);
12996
13094
  }
12997
- async function Dc(e, t, n, r = !1) {
13095
+ async function Pc(e, t, n, r = !1) {
12998
13096
  let i = $.current();
12999
13097
  i && await i.grantRoles(j.composeParticipantId(e, A.USER, t), n, r);
13000
13098
  }
13001
- async function Oc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
13099
+ async function Fc({ externalId: e = null, muteStates: t, requestedMedia: n = [], roomId: r = null }) {
13002
13100
  if (e) {
13003
- let i = Al(e, "muteParticipant");
13101
+ let i = Ll(e, "muteParticipant");
13004
13102
  return i ? i.conversation.muteParticipant(i.participantId, t, n, r) : void 0;
13005
13103
  }
13006
13104
  let i = $.current();
13007
13105
  i && await i.muteParticipant(null, t, n, r);
13008
13106
  }
13009
- async function kc({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
13107
+ async function Ic({ uid: e = null, muteStates: t, requestedMedia: n = [], deviceIdx: r = 0, roomId: i = null }) {
13010
13108
  let a = $.current();
13011
13109
  if (a) {
13012
13110
  let o = e ? j.composeParticipantId(e, A.USER, r) : null;
13013
13111
  await a.muteParticipant(o, t, n, i);
13014
13112
  }
13015
13113
  }
13016
- async function Ac(e, t = !1, n = null) {
13017
- let r = Al(e, "pinParticipant");
13114
+ async function Lc(e, t = !1, n = null) {
13115
+ let r = Ll(e, "pinParticipant");
13018
13116
  r && await r.conversation.pinParticipant(r.participantId, t, n);
13019
13117
  }
13020
- async function jc(e, t = !1, n = 0, r = null) {
13118
+ async function Rc(e, t = !1, n = 0, r = null) {
13021
13119
  let i = $.current();
13022
13120
  i && await i.pinParticipant(j.composeParticipantId(e, A.USER, n), t, r);
13023
13121
  }
13024
- async function Mc(e) {
13122
+ async function zc(e) {
13025
13123
  let t = $.current();
13026
13124
  t && await t.updateMediaModifiers(e);
13027
13125
  }
13028
- async function Nc(e) {
13126
+ async function Bc(e) {
13029
13127
  let t = $.current();
13030
13128
  t && await t.enableVideoSuspend(e);
13031
13129
  }
13032
- async function Pc(e) {
13130
+ async function Vc(e) {
13033
13131
  let t = $.current();
13034
13132
  t && await t.enableVideoSuspendSuggest(e);
13035
13133
  }
13036
- async function Fc(e) {
13134
+ async function Hc(e) {
13037
13135
  let t = $.current();
13038
13136
  t && await t.changeOptions(e);
13039
13137
  }
13040
- async function Ic(e, t = null) {
13138
+ async function Uc(e, t = null) {
13041
13139
  if (t) {
13042
- let n = Al(t, "chatMessage");
13140
+ let n = Ll(t, "chatMessage");
13043
13141
  return n ? n.conversation.chatMessage(e, j.decomposeParticipantId(n.participantId).compositeUserId) : void 0;
13044
13142
  }
13045
13143
  let n = $.current();
13046
13144
  n && await n.chatMessage(e, null);
13047
13145
  }
13048
- async function Lc(e, t = null) {
13146
+ async function Wc(e, t = null) {
13049
13147
  let n = $.current();
13050
13148
  if (n) {
13051
13149
  let r = t ? j.composeUserId(t) : null;
13052
13150
  await n.chatMessage(e, r);
13053
13151
  }
13054
13152
  }
13055
- async function Rc(e = 10) {
13153
+ async function Gc(e = 10) {
13056
13154
  let t = $.current();
13057
13155
  if (t) return t.chatHistory(e);
13058
13156
  }
13059
- async function zc(e, t = null) {
13157
+ async function Kc(e, t = null) {
13060
13158
  if (t) {
13061
- let n = Al(t, "customData");
13159
+ let n = Ll(t, "customData");
13062
13160
  return n ? n.conversation.customData(e, n.participantId) : void 0;
13063
13161
  }
13064
13162
  let n = $.current();
13065
13163
  n && await n.customData(e, null);
13066
13164
  }
13067
- async function Bc(e, t = null, n = 0) {
13165
+ async function qc(e, t = null, n = 0) {
13068
13166
  let r = $.current();
13069
13167
  if (r) {
13070
13168
  let i = t ? j.composeParticipantId(t, A.USER, n) : null;
13071
13169
  await r.customData(e, i);
13072
13170
  }
13073
13171
  }
13074
- async function Vc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
13075
- return (await Vs.createConversation(a ?? j.uuid(), e, t, {
13172
+ async function Jc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, waitForAdmin: r = !1, closedConversation: i = !1 } = {}, a) {
13173
+ return (await Js.createConversation(a ?? j.uuid(), e, t, {
13076
13174
  onlyAdminCanShareMovie: n,
13077
13175
  waitForAdmin: r,
13078
13176
  closedConversation: i
13079
13177
  })).join_link;
13080
13178
  }
13081
- async function Hc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13179
+ async function Yc(e = "", t = !1, { onlyAdminCanShareMovie: n = !1, audioOnly: r = !1 } = {}, i) {
13082
13180
  let a = i.map((e) => Q.fromId(e));
13083
- return (await Vs.createConversation(j.uuid(), e, t, {
13181
+ return (await Js.createConversation(j.uuid(), e, t, {
13084
13182
  onlyAdminCanShareMovie: n,
13085
13183
  audienceMode: !0,
13086
13184
  audioOnly: r
13087
13185
  }, a)).join_link;
13088
13186
  }
13089
- async function Uc() {
13187
+ async function Xc() {
13090
13188
  let e = $.current();
13091
13189
  return e ? e.createJoinLink() : Promise.reject();
13092
13190
  }
13093
- async function Wc() {
13191
+ async function Zc() {
13094
13192
  let e = $.current();
13095
13193
  return e ? e.removeJoinLink() : Promise.reject();
13096
13194
  }
13097
- async function Gc(e, t) {
13098
- return Vs.getAnonymTokenByLink(e, t);
13195
+ async function Qc(e, t) {
13196
+ return Js.getAnonymTokenByLink(e, t);
13099
13197
  }
13100
- function Kc(e) {
13198
+ function $c(e) {
13101
13199
  let t = $.current();
13102
13200
  t && t.setVolume(e);
13103
13201
  }
13104
- function qc(e) {
13202
+ function el(e) {
13105
13203
  M.forceRelayPolicy = e;
13106
13204
  }
13107
- async function Jc(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13205
+ async function tl(e = !1, t = null, n = null, r = "DIRECT_LINK", i = null, a = null) {
13108
13206
  let o = $.current();
13109
13207
  return o ? o.startStream(e, t, n, r, i, a) : Promise.reject();
13110
13208
  }
13111
- async function Yc(e = null, t) {
13209
+ async function nl(e = null, t) {
13112
13210
  let n = $.current();
13113
13211
  return n ? n.stopStream(e, t) : Promise.reject();
13114
13212
  }
13115
- async function Xc(e = null) {
13213
+ async function rl(e = null) {
13116
13214
  let t = $.current();
13117
13215
  return t ? t.publishStream(e) : Promise.reject();
13118
13216
  }
13119
- async function Zc() {
13217
+ async function il() {
13120
13218
  let e = $.current();
13121
13219
  return e ? e.getStreamInfo() : Promise.reject();
13122
13220
  }
13123
- async function Qc(e) {
13221
+ async function al(e) {
13124
13222
  let t = $.current();
13125
13223
  return t ? t.addMovie(e) : Promise.reject();
13126
13224
  }
13127
- async function $c(e) {
13225
+ async function ol(e) {
13128
13226
  let t = $.current();
13129
13227
  return t ? t.updateMovie(e) : Promise.reject();
13130
13228
  }
13131
- async function el(e) {
13229
+ async function sl(e) {
13132
13230
  let t = $.current();
13133
13231
  return t ? t.removeMovie(e) : Promise.reject();
13134
13232
  }
13135
- async function tl(e, t) {
13233
+ async function cl(e, t) {
13136
13234
  let n = $.current();
13137
13235
  if (n) {
13138
13236
  let r = [], i = [];
@@ -13154,46 +13252,46 @@ async function tl(e, t) {
13154
13252
  });
13155
13253
  }
13156
13254
  if (i.length) {
13157
- Ol(i, "updateRooms", n);
13255
+ Fl(i, "updateRooms", n);
13158
13256
  return;
13159
13257
  }
13160
13258
  return n.updateRooms(r, t);
13161
13259
  }
13162
13260
  return Promise.reject();
13163
13261
  }
13164
- async function nl(e, t) {
13262
+ async function ll(e, t) {
13165
13263
  let n = $.current();
13166
13264
  return n ? n.activateRooms(e, t) : Promise.reject();
13167
13265
  }
13168
- async function rl(e = null, t = null) {
13266
+ async function ul(e = null, t = null) {
13169
13267
  let n = $.current();
13170
13268
  if (!n) return Promise.reject();
13171
13269
  let r;
13172
13270
  if (t && (r = n.getCachedParticipantIdByExternalId(t) ?? void 0, !r)) {
13173
- Dl(t, "switchRoom", n);
13271
+ Pl(t, "switchRoom", n);
13174
13272
  return;
13175
13273
  }
13176
13274
  return n.switchRoom(e, r);
13177
13275
  }
13178
- async function il(e) {
13276
+ async function dl(e) {
13179
13277
  let t = $.current();
13180
13278
  return t ? t.removeRooms(e) : Promise.reject();
13181
13279
  }
13182
- function al(e) {
13280
+ function fl(e) {
13183
13281
  M.statisticsInterval = e;
13184
13282
  let t = $.current();
13185
13283
  if (t) return t.updateStatisticsInterval();
13186
13284
  }
13187
- function ol(t) {
13285
+ function pl(t) {
13188
13286
  e.disableLog(!t), R.toggle(t);
13189
13287
  }
13190
- function sl(e, ...t) {
13288
+ function ml(e, ...t) {
13191
13289
  M.debugLog && ($.debugMessage(e, "[external]", ...t) || R.send(e, "[external]", ...t));
13192
13290
  }
13193
- function cl(e, t, ...n) {
13291
+ function hl(e, t, ...n) {
13194
13292
  M.debugLog && ($.debugMessageWithContext(e, t, "[external]", ...n) || R.send(e, "[external]", ...n));
13195
13293
  }
13196
- var ll = {
13294
+ var gl = {
13197
13295
  list: Ne,
13198
13296
  get: Pe,
13199
13297
  getJson: Fe,
@@ -13201,7 +13299,7 @@ var ll = {
13201
13299
  clear: Le,
13202
13300
  stats: Re
13203
13301
  };
13204
- function ul() {
13302
+ function _l() {
13205
13303
  let e = [
13206
13304
  [`Calls SDK ${M.sdkVersion}`, M.toJSON()],
13207
13305
  ["UserAgent:", navigator.userAgent],
@@ -13218,139 +13316,139 @@ function ul() {
13218
13316
  d: e
13219
13317
  }));
13220
13318
  }
13221
- async function dl() {
13319
+ async function vl() {
13222
13320
  let e = $.id(), t = $.debugSessionId();
13223
13321
  if (!t || !e) throw R.error("[uploadDebugLogs]", "No conversation id found"), Error("No conversation id found");
13224
13322
  let n = await Pe({ sessionId: t });
13225
13323
  if (n.length === 0) throw R.error("[uploadDebugLogs]", "No logs found"), Error("No logs found");
13226
13324
  let r = n[0].t, i = n[n.length - 1].t;
13227
13325
  try {
13228
- return Vs?.uploadDebugLogs(e, r, i, JSON.stringify([...ul(), ...n]));
13326
+ return Js?.uploadDebugLogs(e, r, i, JSON.stringify([..._l(), ...n]));
13229
13327
  } catch (e) {
13230
13328
  throw R.error("[uploadDebugLogs]", "Error while uploading logs", e), Error("Error while uploading logs", { cause: e });
13231
13329
  }
13232
13330
  }
13233
- async function fl(e) {
13331
+ async function yl(e) {
13234
13332
  let t = $.current();
13235
13333
  if (t) return t.videoEffect(e);
13236
13334
  }
13237
- async function pl(e, t) {
13335
+ async function bl(e, t) {
13238
13336
  let n = $.current();
13239
13337
  if (n) return n.audioEffect(e.length > 0 ? e : null, t);
13240
13338
  }
13241
- async function ml(e) {
13339
+ async function xl(e) {
13242
13340
  let t = $.current();
13243
13341
  t && await t.setAudioStream(e);
13244
13342
  }
13245
- async function hl(e, t = null, n = null) {
13343
+ async function Sl(e, t = null, n = null) {
13246
13344
  let r = $.current();
13247
13345
  if (!r) return;
13248
13346
  let i = n ?? t?.id, a = null;
13249
13347
  if (t && (a = r.getCachedParticipantIdByExternalId(t), !a)) {
13250
- Dl(t, "setVmojiSvg", r);
13348
+ Pl(t, "setVmojiSvg", r);
13251
13349
  return;
13252
13350
  }
13253
13351
  r.setAnimojiSvg(e, a, i);
13254
13352
  }
13255
- function gl(e) {
13353
+ function Cl(e) {
13256
13354
  let t = $.current();
13257
13355
  t && t.setAnimojiFill(e);
13258
13356
  }
13259
- async function _l(e = null, t, n = !1) {
13260
- return kl().getWaitingHall(e, t, n);
13357
+ async function wl(e = null, t, n = !1) {
13358
+ return Il().getWaitingHall(e, t, n);
13261
13359
  }
13262
- async function vl() {
13263
- return kl().getAudienceModeHands();
13360
+ async function Tl() {
13361
+ return Il().getAudienceModeHands();
13264
13362
  }
13265
- async function yl(e, t = !1) {
13266
- let n = kl(), r;
13363
+ async function El(e, t = !1) {
13364
+ let n = Il(), r;
13267
13365
  if (e) {
13268
13366
  let t = n.getCachedParticipantIdByExternalId(e);
13269
13367
  if (!t) {
13270
- Dl(e, "promoteParticipant", n);
13368
+ Pl(e, "promoteParticipant", n);
13271
13369
  return;
13272
13370
  }
13273
13371
  r = j.decomposeParticipantId(t).compositeUserId;
13274
13372
  }
13275
13373
  return n.promoteParticipant(r, t);
13276
13374
  }
13277
- async function bl(e = !1) {
13278
- return kl().requestPromotion(e);
13375
+ async function Dl(e = !1) {
13376
+ return Il().requestPromotion(e);
13279
13377
  }
13280
- async function xl(e = !1) {
13281
- return kl().acceptPromotion(e);
13378
+ async function Ol(e = !1) {
13379
+ return Il().acceptPromotion(e);
13282
13380
  }
13283
- async function Sl(e) {
13284
- return kl().getParticipantListChunk(e);
13381
+ async function kl(e) {
13382
+ return Il().getParticipantListChunk(e);
13285
13383
  }
13286
- async function Cl(e) {
13287
- return kl().getParticipants(e);
13384
+ async function Al(e) {
13385
+ return Il().getParticipants(e);
13288
13386
  }
13289
- async function wl(e) {
13290
- return kl().feedback(e);
13387
+ async function jl(e) {
13388
+ return Il().feedback(e);
13291
13389
  }
13292
- async function Tl(e, t, n) {
13293
- return kl(n).enableFeatureForRoles(e, t);
13390
+ async function Ml(e, t, n) {
13391
+ return Il(n).enableFeatureForRoles(e, t);
13294
13392
  }
13295
- function El(e) {
13393
+ function Nl(e) {
13296
13394
  return e ? z.get(e) ?? null : $.current() ?? z.getFirst();
13297
13395
  }
13298
- function Dl(e, t, n) {
13396
+ function Pl(e, t, n) {
13299
13397
  L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external ID "${e.id}" while handling ${t}`), n.id);
13300
13398
  }
13301
- function Ol(e, t, n) {
13399
+ function Fl(e, t, n) {
13302
13400
  let r = Array.from(new Set(e));
13303
13401
  L.onNonFatalError(/* @__PURE__ */ Error(`Participant ID mapping not found for external IDs "${r.join("\", \"")}" while handling ${t}`), n.id);
13304
13402
  }
13305
- function kl(e) {
13306
- let t = El(e);
13403
+ function Il(e) {
13404
+ let t = Nl(e);
13307
13405
  if (!t) throw Error("Conversation not found");
13308
13406
  return t;
13309
13407
  }
13310
- function Al(e, t) {
13408
+ function Ll(e, t) {
13311
13409
  let n = $.current();
13312
13410
  if (!n) return null;
13313
13411
  let r = n.getCachedParticipantIdByExternalId(e);
13314
13412
  return r ? {
13315
13413
  conversation: n,
13316
13414
  participantId: r
13317
- } : (Dl(e, t, n), null);
13415
+ } : (Pl(e, t, n), null);
13318
13416
  }
13319
- async function jl(e) {
13320
- await Vs.removeHistoryRecords(e);
13417
+ async function Rl(e) {
13418
+ await Js.removeHistoryRecords(e);
13321
13419
  }
13322
- async function Ml(e) {
13420
+ async function zl(e) {
13323
13421
  let t = $.current() ?? z.getFirst();
13324
13422
  t && await t.startAsr(e);
13325
13423
  }
13326
- async function Nl(e) {
13424
+ async function Bl(e) {
13327
13425
  let t = $.current() ?? z.getFirst();
13328
13426
  t && await t.stopAsr(e);
13329
13427
  }
13330
- async function Pl(e) {
13428
+ async function Vl(e) {
13331
13429
  let t = $.current() ?? z.getFirst();
13332
13430
  t && await t.requestAsr(e);
13333
13431
  }
13334
- async function Fl(e) {
13432
+ async function Hl(e) {
13335
13433
  let t = $.current();
13336
13434
  return t ? t.startUrlSharing(e) : Promise.reject();
13337
13435
  }
13338
- async function Il() {
13436
+ async function Ul() {
13339
13437
  let e = $.current();
13340
13438
  return e ? e.stopUrlSharing() : Promise.reject();
13341
13439
  }
13342
- async function Ll(e) {
13440
+ async function Wl(e) {
13343
13441
  await z.switchCall(e);
13344
13442
  }
13345
- function Rl() {
13443
+ function Gl() {
13346
13444
  return z.getActiveId();
13347
13445
  }
13348
- function zl() {
13446
+ function Kl() {
13349
13447
  return $.getSyncedTime();
13350
13448
  }
13351
- function Bl() {
13449
+ function ql() {
13352
13450
  return M.sdkVersion;
13353
13451
  }
13354
13452
  typeof window < "u" && (window.__CALLS_SDK = yn);
13355
13453
  //#endregion
13356
- export { Ps as Api, Bs as ApiExternal, zs as ArrayDequeue, y as AuthData, f as BaseLogger, Ba as CallDirection, Va as CallType, Ha as ChatRoomEventType, Ua as ConversationFeature, Wa as ConversationOption, Sn as DebugMessageType, to as ExternalIdType, jt as FacingMode, x as FatalError, O as HangupReason, D as HangupType, S as MediaOption, k as MediaTrackKind, V as MediaType, qa as MuteState, Z as ParticipantState, Rs as ParticipantStateDataValue, N as ParticipantStatus, Ls as RecordRole, Ja as RoomsEventType, za as Signaling, B as SignalingCommandType, vr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, Za as UserRole, A as UserType, To as VolumeDetector, ic as acceptCall, xl as acceptPromotion, nl as activateRooms, Qc as addMovie, uc as addParticipant, dc as addParticipantInternal, rc as authorize, Us as browser, $s as callInternal, Zs as callTo, hc as captureScreen, gc as captureVmoji, pl as changeAudioEffect, Fc as changeConversationOptions, mc as changeDevice, Sc as changeParticipantState, xc as changePriorities, fl as changeVideoEffect, Rc as chatHistory, Ic as chatMessage, Lc as chatMessageInternal, Uc as createJoinLink, zc as customData, Bc as customDataInternal, ol as debug, ll as debugLogs, sl as debugMessage, cl as debugMessageWithContext, ac as declineCall, Tl as enableFeatureForRoles, Nc as enableVideoSuspend, Pc as enableVideoSuspendSuggest, wl as feedback, qc as forceRelayPolicy, Rl as getActiveCallId, Gc as getAnonymTokenByLink, vl as getAudienceModeHands, nc as getInbounds, Sl as getParticipantListChunk, Cl as getParticipants, Zc as getStreamInfo, zl as getSyncedTime, _l as getWaitingHall, Ec as grantRoles, Dc as grantRolesInternal, lc as hangup, Xs as init, oc as joinCall, cc as joinCallByLink, sc as joinCallInternal, Oc as muteParticipant, kc as muteParticipantInternal, Ac as pinParticipant, jc as pinParticipantInternal, ec as processPush, tc as processPushInternal, yl as promoteParticipant, Xc as publishStream, Cc as putHandsDown, jl as removeHistoryRecords, Wc as removeJoinLink, el as removeMovie, fc as removeParticipant, pc as removeParticipantInternal, il as removeRooms, Pl as requestAsr, Tc as requestDisplayLayout, bl as requestPromotion, qs as setAudioEffects, ml as setAudioStream, bc as setLocalResolution, Gs as setLogger, Mc as setMediaModifiers, al as setStatisticsInterval, Js as setVad, Ks as setVideoEffects, _c as setVideoStream, Ys as setVmoji, gl as setVmojiFill, hl as setVmojiSvg, Kc as setVolume, Ml as startAsr, Hc as startAudienceConversation, Vc as startConversation, Jc as startStream, Fl as startUrlSharing, Nl as stopAsr, Yc as stopStream, Il as stopUrlSharing, Ll as switchCall, rl as switchRoom, yc as toggleLocalAudio, vc as toggleLocalVideo, wc as updateDisplayLayout, $c as updateMovie, tl as updateRooms, dl as uploadDebugLogs, Ws as utils, Bl as version };
13454
+ export { Vs as Api, qs as ApiExternal, Ks as ArrayDequeue, y as AuthData, f as BaseLogger, qa as CallDirection, Ja as CallType, Ya as ChatRoomEventType, Xa as ConversationFeature, Za as ConversationOption, Sn as DebugMessageType, co as ExternalIdType, jt as FacingMode, x as FatalError, O as HangupReason, D as HangupType, S as MediaOption, k as MediaTrackKind, V as MediaType, eo as MuteState, Z as ParticipantState, Gs as ParticipantStateDataValue, N as ParticipantStatus, Ws as RecordRole, to as RoomsEventType, Ka as Signaling, B as SignalingCommandType, vr as SignalingConnectionType, K as SignalingNotification, J as TransportTopology, io as UserRole, A as UserType, Mo as VolumeDetector, dc as acceptCall, Ol as acceptPromotion, ll as activateRooms, al as addMovie, _c as addParticipant, vc as addParticipantInternal, uc as authorize, Xs as browser, oc as callInternal, ic as callTo, Sc as captureScreen, Cc as captureVmoji, bl as changeAudioEffect, Hc as changeConversationOptions, xc as changeDevice, kc as changeParticipantState, Oc as changePriorities, yl as changeVideoEffect, Gc as chatHistory, Uc as chatMessage, Wc as chatMessageInternal, Xc as createJoinLink, Kc as customData, qc as customDataInternal, pl as debug, gl as debugLogs, ml as debugMessage, hl as debugMessageWithContext, fc as declineCall, Ml as enableFeatureForRoles, Bc as enableVideoSuspend, Vc as enableVideoSuspendSuggest, jl as feedback, el as forceRelayPolicy, Gl as getActiveCallId, Qc as getAnonymTokenByLink, Tl as getAudienceModeHands, lc as getInbounds, kl as getParticipantListChunk, Al as getParticipants, il as getStreamInfo, Kl as getSyncedTime, wl as getWaitingHall, Nc as grantRoles, Pc as grantRolesInternal, gc as hangup, rc as init, pc as joinCall, hc as joinCallByLink, mc as joinCallInternal, Fc as muteParticipant, Ic as muteParticipantInternal, Lc as pinParticipant, Rc as pinParticipantInternal, sc as processPush, cc as processPushInternal, El as promoteParticipant, rl as publishStream, Ac as putHandsDown, Rl as removeHistoryRecords, Zc as removeJoinLink, sl as removeMovie, yc as removeParticipant, bc as removeParticipantInternal, dl as removeRooms, Vl as requestAsr, Mc as requestDisplayLayout, Dl as requestPromotion, ec as setAudioEffects, xl as setAudioStream, Dc as setLocalResolution, Qs as setLogger, zc as setMediaModifiers, fl as setStatisticsInterval, tc as setVad, $s as setVideoEffects, wc as setVideoStream, nc as setVmoji, Cl as setVmojiFill, Sl as setVmojiSvg, $c as setVolume, zl as startAsr, Yc as startAudienceConversation, Jc as startConversation, tl as startStream, Hl as startUrlSharing, Bl as stopAsr, nl as stopStream, Ul as stopUrlSharing, Wl as switchCall, ul as switchRoom, Ec as toggleLocalAudio, Tc as toggleLocalVideo, jc as updateDisplayLayout, ol as updateMovie, cl as updateRooms, vl as uploadDebugLogs, Zs as utils, ql as version };