sip-connector 28.9.2 → 28.10.1

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.
@@ -1,22 +1,22 @@
1
- import { C as Z, NameAddrHeader as In, URI as fn, SessionStatus as vn, IncomingResponse as vt } from "@krivega/jssip";
2
- import { MediaStreamTrackMock as Mn, createAudioMediaStreamTrackMock as On, createVideoMediaStreamTrackMock as _n } from "webrtc-mock";
3
- import { TypedEvents as G, EventEmitterProxy as w, Events as bn } from "events-constructor";
4
- import Ve from "debug";
5
- import { resolveRequesterByTimeout as yn, requesterByTimeoutsWithFailCalls as Dn, DelayRequester as Mt, hasCanceledError as Ot, SetTimeoutRequest as _t } from "@krivega/timeout-requester";
1
+ import { C as Z, NameAddrHeader as fn, URI as vn, SessionStatus as Mn, IncomingResponse as vt } from "@krivega/jssip";
2
+ import { MediaStreamTrackMock as On, createAudioMediaStreamTrackMock as _n, createVideoMediaStreamTrackMock as bn } from "webrtc-mock";
3
+ import { TypedEvents as G, EventEmitterProxy as w, Events as yn } from "events-constructor";
4
+ import xe from "debug";
5
+ import { resolveRequesterByTimeout as Mt, DelayRequester as Ot, hasCanceledError as _t, SetTimeoutRequest as bt } from "@krivega/timeout-requester";
6
6
  import { CancelableRequest as me, isCanceledError as qe } from "@krivega/cancelable-promise";
7
- import { createActor as Pn, setup as ee, assign as A, fromPromise as ae } from "xstate";
8
- import { repeatedCallsAsync as He, hasCanceledError as Ln } from "repeated-calls";
9
- import { createStackPromises as bt, isPromiseIsNotActualError as yt } from "stack-promises";
10
- import { UAParser as wn } from "ua-parser-js";
7
+ import { createActor as Dn, setup as ee, assign as A, fromPromise as ae } from "xstate";
8
+ import { repeatedCallsAsync as Ve, hasCanceledError as Pn } from "repeated-calls";
9
+ import { createStackPromises as yt, isPromiseIsNotActualError as Dt } from "stack-promises";
10
+ import { UAParser as Ln } from "ua-parser-js";
11
11
  import "sequent-promises";
12
- import Gn, { isEqual as Je } from "lodash";
13
- const We = "sip-connector", kn = Ve(We), Rl = () => {
14
- Ve.enable(`${We}:*`);
15
- }, Nl = () => {
16
- Ve.enable(`-${We}:*`);
17
- }, I = (t) => kn.extend(t), Fn = "Error decline with 603", Un = 1006, Bn = (t) => typeof t == "object" && t !== null && "code" in t && t.code === Un, $n = (t) => t.message === Fn;
18
- var Ne = /* @__PURE__ */ ((t) => (t.SPECTATOR = "SPECTATOR", t.PARTICIPANT = "PARTICIPANT", t))(Ne || {}), W = /* @__PURE__ */ ((t) => (t.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", t.MAIN_CAM = "application/vinteo.webrtc.maincam", t.ENTER_ROOM = "application/vinteo.webrtc.roomname", t.MIC = "application/vinteo.webrtc.mic", t.USE_LICENSE = "application/vinteo.webrtc.uselic", t.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", t.NOTIFY = "application/vinteo.webrtc.notify", t))(W || {}), q = /* @__PURE__ */ ((t) => (t.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", t.MAIN_CAM = "application/vinteo.webrtc.maincam", t.CHANNELS = "application/vinteo.webrtc.channels", t.MEDIA_STATE = "application/vinteo.webrtc.mediastate", t.REFUSAL = "application/vinteo.webrtc.refusal", t.STATS = "application/vinteo.webrtc.stats", t))(q || {}), $ = /* @__PURE__ */ ((t) => (t.PAUSE_MAIN_CAM = "PAUSEMAINCAM", t.RESUME_MAIN_CAM = "RESUMEMAINCAM", t.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", t.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", t.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", t))($ || {}), Ae = /* @__PURE__ */ ((t) => (t.ADMIN_STOP_MIC = "ADMINSTOPMIC", t.ADMIN_START_MIC = "ADMINSTARTMIC", t))(Ae || {}), Dt = /* @__PURE__ */ ((t) => (t.H264 = "H264", t.VP8 = "VP8", t.VP9 = "VP9", t.AV1 = "AV1", t))(Dt || {}), E = /* @__PURE__ */ ((t) => (t.CONTENT_TYPE = "content-type", t.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", t.CONTENT_USE_LICENSE = "x-webrtc-use-license", t.PARTICIPANT_NAME = "x-webrtc-participant-name", t.INPUT_CHANNELS = "x-webrtc-input-channels", t.OUTPUT_CHANNELS = "x-webrtc-output-channels", t.MAIN_CAM = "x-webrtc-maincam", t.MIC = "x-webrtc-mic", t.MEDIA_SYNC = "x-webrtc-sync", t.MAIN_CAM_RESOLUTION = "x-webrtc-maincam-resolution", t.MEDIA_STATE = "x-webrtc-media-state", t.MEDIA_TYPE = "x-vinteo-media-type", t.MAIN_CAM_STATE = "x-vinteo-maincam-state", t.MIC_STATE = "x-vinteo-mic-state", t.CONTENT_PARTICIPANT_STATE = "x-webrtc-partstate", t.AUDIO_ID = "x-webrtc-audioid", t.SPECTATOR_MODE = "x-webrtc-spectator-mode", t.NOTIFY = "x-vinteo-notify", t.CONTENT_ENABLE_MEDIA_DEVICE = "x-webrtc-request-enable-media-device", t.CONTENTED_STREAM_STATE = "x-webrtc-share-state", t.CONTENTED_STREAM_CODEC = "x-webrtc-share-codec", t.AVAILABLE_INCOMING_BITRATE = "x-webrtc-available-incoming-bitrate", t.AUDIO_TRACK_COUNT = "x-webrtc-audio-track-count", t.VIDEO_TRACK_COUNT = "x-webrtc-video-track-count", t.TRACKS_DIRECTION = "x-webrtc-tracks-direction", t.BEARER_TOKEN = "x-bearer-token", t.IS_DIRECT_PEER_TO_PEER = "x-webrtc-is-direct-p2p", t))(E || {}), ue = /* @__PURE__ */ ((t) => (t.AVAILABLE_CONTENTED_STREAM = "YOUCANRECEIVECONTENT", t.NOT_AVAILABLE_CONTENTED_STREAM = "CONTENTEND", t.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", t))(ue || {}), ie = /* @__PURE__ */ ((t) => (t.AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: YOUCANRECEIVECONTENT", t.NOT_AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: CONTENTEND", t.ACK_PERMISSION_TO_START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", t.STOPPED_CLIENT_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", t.ENABLE_MAIN_CAM = "x-webrtc-request-enable-media-device: LETMESTARTMAINCAM", t))(ie || {}), Ie = /* @__PURE__ */ ((t) => (t.ADMIN_SYNC_FORCED = "1", t.ADMIN_SYNC_NOT_FORCED = "0", t))(Ie || {}), Qe = /* @__PURE__ */ ((t) => (t.SPECTATOR_MANUAL = "0", t.BY_STATE_CAM = "1", t.SPECTATOR_FORCED = "2", t))(Qe || {}), Ye = /* @__PURE__ */ ((t) => (t.AUDIO = "AUDIO", t.VIDEO = "VIDEO", t.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", t))(Ye || {});
19
- const x = (t) => typeof t == "string" && t.trim().length > 0, ke = (t) => typeof t == "number" && !Number.isNaN(t) && Number.isFinite(t), xn = (t) => typeof t == "object" && t !== null && !Array.isArray(t), Pt = (t) => typeof t == "boolean", Vn = (t) => Array.isArray(t) && t.every(x), Lt = [
12
+ import wn, { isEqual as ze } from "lodash";
13
+ const He = "sip-connector", Gn = xe(He), Cl = () => {
14
+ xe.enable(`${He}:*`);
15
+ }, Rl = () => {
16
+ xe.enable(`-${He}:*`);
17
+ }, I = (t) => Gn.extend(t), kn = "Error decline with 603", Fn = 1006, Un = (t) => typeof t == "object" && t !== null && "code" in t && t.code === Fn, Bn = (t) => t.message === kn;
18
+ var Ne = /* @__PURE__ */ ((t) => (t.SPECTATOR = "SPECTATOR", t.PARTICIPANT = "PARTICIPANT", t))(Ne || {}), W = /* @__PURE__ */ ((t) => (t.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", t.MAIN_CAM = "application/vinteo.webrtc.maincam", t.ENTER_ROOM = "application/vinteo.webrtc.roomname", t.MIC = "application/vinteo.webrtc.mic", t.USE_LICENSE = "application/vinteo.webrtc.uselic", t.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", t.NOTIFY = "application/vinteo.webrtc.notify", t))(W || {}), V = /* @__PURE__ */ ((t) => (t.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", t.MAIN_CAM = "application/vinteo.webrtc.maincam", t.CHANNELS = "application/vinteo.webrtc.channels", t.MEDIA_STATE = "application/vinteo.webrtc.mediastate", t.REFUSAL = "application/vinteo.webrtc.refusal", t.STATS = "application/vinteo.webrtc.stats", t))(V || {}), $ = /* @__PURE__ */ ((t) => (t.PAUSE_MAIN_CAM = "PAUSEMAINCAM", t.RESUME_MAIN_CAM = "RESUMEMAINCAM", t.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", t.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", t.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", t))($ || {}), Ae = /* @__PURE__ */ ((t) => (t.ADMIN_STOP_MIC = "ADMINSTOPMIC", t.ADMIN_START_MIC = "ADMINSTARTMIC", t))(Ae || {}), Pt = /* @__PURE__ */ ((t) => (t.H264 = "H264", t.VP8 = "VP8", t.VP9 = "VP9", t.AV1 = "AV1", t))(Pt || {}), E = /* @__PURE__ */ ((t) => (t.CONTENT_TYPE = "content-type", t.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", t.CONTENT_USE_LICENSE = "x-webrtc-use-license", t.PARTICIPANT_NAME = "x-webrtc-participant-name", t.INPUT_CHANNELS = "x-webrtc-input-channels", t.OUTPUT_CHANNELS = "x-webrtc-output-channels", t.MAIN_CAM = "x-webrtc-maincam", t.MIC = "x-webrtc-mic", t.MEDIA_SYNC = "x-webrtc-sync", t.MAIN_CAM_RESOLUTION = "x-webrtc-maincam-resolution", t.MEDIA_STATE = "x-webrtc-media-state", t.MEDIA_TYPE = "x-vinteo-media-type", t.MAIN_CAM_STATE = "x-vinteo-maincam-state", t.MIC_STATE = "x-vinteo-mic-state", t.CONTENT_PARTICIPANT_STATE = "x-webrtc-partstate", t.AUDIO_ID = "x-webrtc-audioid", t.SPECTATOR_MODE = "x-webrtc-spectator-mode", t.NOTIFY = "x-vinteo-notify", t.CONTENT_ENABLE_MEDIA_DEVICE = "x-webrtc-request-enable-media-device", t.CONTENTED_STREAM_STATE = "x-webrtc-share-state", t.CONTENTED_STREAM_CODEC = "x-webrtc-share-codec", t.AVAILABLE_INCOMING_BITRATE = "x-webrtc-available-incoming-bitrate", t.AUDIO_TRACK_COUNT = "x-webrtc-audio-track-count", t.VIDEO_TRACK_COUNT = "x-webrtc-video-track-count", t.TRACKS_DIRECTION = "x-webrtc-tracks-direction", t.BEARER_TOKEN = "x-bearer-token", t.IS_DIRECT_PEER_TO_PEER = "x-webrtc-is-direct-p2p", t))(E || {}), ue = /* @__PURE__ */ ((t) => (t.AVAILABLE_CONTENTED_STREAM = "YOUCANRECEIVECONTENT", t.NOT_AVAILABLE_CONTENTED_STREAM = "CONTENTEND", t.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", t))(ue || {}), ie = /* @__PURE__ */ ((t) => (t.AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: YOUCANRECEIVECONTENT", t.NOT_AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: CONTENTEND", t.ACK_PERMISSION_TO_START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", t.STOPPED_CLIENT_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", t.ENABLE_MAIN_CAM = "x-webrtc-request-enable-media-device: LETMESTARTMAINCAM", t))(ie || {}), Ie = /* @__PURE__ */ ((t) => (t.ADMIN_SYNC_FORCED = "1", t.ADMIN_SYNC_NOT_FORCED = "0", t))(Ie || {}), We = /* @__PURE__ */ ((t) => (t.SPECTATOR_MANUAL = "0", t.BY_STATE_CAM = "1", t.SPECTATOR_FORCED = "2", t))(We || {}), Qe = /* @__PURE__ */ ((t) => (t.AUDIO = "AUDIO", t.VIDEO = "VIDEO", t.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", t))(Qe || {});
19
+ const x = (t) => typeof t == "string" && t.trim().length > 0, Ge = (t) => typeof t == "number" && !Number.isNaN(t) && Number.isFinite(t), $n = (t) => typeof t == "object" && t !== null && !Array.isArray(t), Lt = (t) => typeof t == "boolean", xn = (t) => Array.isArray(t) && t.every(x), wt = [
20
20
  "enter-room",
21
21
  "main-cam-control",
22
22
  "use-license",
@@ -46,13 +46,13 @@ const x = (t) => typeof t == "string" && t.trim().length > 0, ke = (t) => typeof
46
46
  "admin:stop-mic",
47
47
  "admin:force-sync-media-state",
48
48
  "failed-send-room-direct-p2p"
49
- ], qn = () => new G(Lt), Hn = (t) => !(!xn(t) || !x(t.conference) || !x(t.participant) || !x(t.jwt)), j = (t, e) => {
49
+ ], qn = () => new G(wt), Vn = (t) => !(!$n(t) || !x(t.conference) || !x(t.participant) || !x(t.jwt)), j = (t, e) => {
50
50
  const n = e.toLowerCase(), s = Object.entries(t).find(([, r]) => typeof r == "string" && r.toLowerCase() === n);
51
51
  return s ? s[1] : void 0;
52
- }, Wn = (t) => typeof t == "string" && !Number.isNaN(Number(t)) && Number.isFinite(Number(t)), Qn = (t) => {
53
- if (Wn(t))
52
+ }, Hn = (t) => typeof t == "string" && !Number.isNaN(Number(t)) && Number.isFinite(Number(t)), Wn = (t) => {
53
+ if (Hn(t))
54
54
  return Number(t);
55
- }, Yn = (t) => {
55
+ }, Qn = (t) => {
56
56
  const e = t.toLowerCase();
57
57
  if (e === "true" || e === "1")
58
58
  return !0;
@@ -83,13 +83,13 @@ const x = (t) => typeof t == "string" && t.trim().length > 0, ke = (t) => typeof
83
83
  case E.AVAILABLE_INCOMING_BITRATE:
84
84
  case E.AUDIO_TRACK_COUNT:
85
85
  case E.VIDEO_TRACK_COUNT:
86
- return Qn(s);
86
+ return Wn(s);
87
87
  case E.CONTENTED_STREAM_CODEC:
88
- return j(Dt, s);
88
+ return j(Pt, s);
89
89
  case E.CONTENT_TYPE:
90
90
  return j(W, s);
91
91
  case E.CONTENT_USE_LICENSE:
92
- return j(Ye, s);
92
+ return j(Qe, s);
93
93
  case E.MAIN_CAM:
94
94
  return j($, s);
95
95
  case E.MIC:
@@ -99,18 +99,18 @@ const x = (t) => typeof t == "string" && t.trim().length > 0, ke = (t) => typeof
99
99
  case E.CONTENT_PARTICIPANT_STATE:
100
100
  return j(Ne, s);
101
101
  case E.SPECTATOR_MODE:
102
- return j(Qe, s);
102
+ return j(We, s);
103
103
  case E.CONTENTED_STREAM_STATE:
104
104
  return j(ue, s);
105
105
  case E.IS_DIRECT_PEER_TO_PEER:
106
- return Yn(s);
106
+ return Qn(s);
107
107
  default:
108
108
  return;
109
109
  }
110
110
  };
111
111
  var U = /* @__PURE__ */ ((t) => (t.CHANNELS = "channels", t.WEBCAST_STARTED = "WebcastStarted", t.WEBCAST_STOPPED = "WebcastStopped", t.ACCOUNT_CHANGED = "accountChanged", t.ACCOUNT_DELETED = "accountDeleted", t.ADDED_TO_LIST_MODERATORS = "addedToListModerators", t.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", t.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", t.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", t.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", t.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", t))(U || {});
112
- const Ke = I("ApiManager");
113
- class jn extends w {
112
+ const Je = I("ApiManager");
113
+ class Yn extends w {
114
114
  callManager;
115
115
  constructor() {
116
116
  super(qn());
@@ -150,7 +150,7 @@ class jn extends w {
150
150
  r,
151
151
  i
152
152
  ];
153
- return s.sendInfo(q.CHANNELS, void 0, { extraHeaders: a });
153
+ return s.sendInfo(V.CHANNELS, void 0, { extraHeaders: a });
154
154
  }
155
155
  sendEnterRoom(e) {
156
156
  this.sendEnterRoomProtected(e).catch((n) => {
@@ -163,7 +163,7 @@ class jn extends w {
163
163
  a,
164
164
  o
165
165
  ];
166
- return r.sendInfo(q.MEDIA_STATE, void 0, {
166
+ return r.sendInfo(V.MEDIA_STATE, void 0, {
167
167
  noTerminateWhenError: !0,
168
168
  ...s,
169
169
  extraHeaders: c
@@ -173,14 +173,14 @@ class jn extends w {
173
173
  availableIncomingBitrate: e
174
174
  }) {
175
175
  const n = this.getEstablishedRTCSessionProtected(), r = [`${E.AVAILABLE_INCOMING_BITRATE}: ${e}`];
176
- return n.sendInfo(q.STATS, void 0, {
176
+ return n.sendInfo(V.STATS, void 0, {
177
177
  noTerminateWhenError: !0,
178
178
  extraHeaders: r
179
179
  });
180
180
  }
181
181
  async sendRefusalToTurnOn(e, n = {}) {
182
182
  const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${E.MEDIA_TYPE}: ${a}`];
183
- return s.sendInfo(q.REFUSAL, void 0, {
183
+ return s.sendInfo(V.REFUSAL, void 0, {
184
184
  noTerminateWhenError: !0,
185
185
  ...n,
186
186
  extraHeaders: c
@@ -193,33 +193,33 @@ class jn extends w {
193
193
  return this.sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
194
194
  }
195
195
  async sendAvailableContentedStream() {
196
- await this.getEstablishedRTCSessionProtected().sendInfo(q.SHARE_STATE, void 0, {
196
+ await this.getEstablishedRTCSessionProtected().sendInfo(V.SHARE_STATE, void 0, {
197
197
  extraHeaders: [ie.AVAILABLE_CONTENTED_STREAM]
198
198
  });
199
199
  }
200
200
  async askPermissionToStartPresentation() {
201
- await this.getEstablishedRTCSessionProtected().sendInfo(q.SHARE_STATE, void 0, {
201
+ await this.getEstablishedRTCSessionProtected().sendInfo(V.SHARE_STATE, void 0, {
202
202
  extraHeaders: [ie.ACK_PERMISSION_TO_START_PRESENTATION]
203
203
  });
204
204
  }
205
205
  async sendStoppedPresentation() {
206
- await this.getEstablishedRTCSessionProtected().sendInfo(q.SHARE_STATE, void 0, {
206
+ await this.getEstablishedRTCSessionProtected().sendInfo(V.SHARE_STATE, void 0, {
207
207
  extraHeaders: [ie.STOPPED_CLIENT_PRESENTATION]
208
208
  });
209
209
  }
210
210
  async sendNotAvailableContentedStream() {
211
- await this.getEstablishedRTCSessionProtected().sendInfo(q.SHARE_STATE, void 0, {
211
+ await this.getEstablishedRTCSessionProtected().sendInfo(V.SHARE_STATE, void 0, {
212
212
  extraHeaders: [ie.NOT_AVAILABLE_CONTENTED_STREAM]
213
213
  });
214
214
  }
215
215
  async askPermissionToEnableCam(e = {}) {
216
216
  const n = this.getEstablishedRTCSessionProtected(), s = [ie.ENABLE_MAIN_CAM];
217
- return n.sendInfo(q.MAIN_CAM, void 0, {
217
+ return n.sendInfo(V.MAIN_CAM, void 0, {
218
218
  noTerminateWhenError: !0,
219
219
  ...e,
220
220
  extraHeaders: s
221
221
  }).catch((r) => {
222
- if ($n(r))
222
+ if (Bn(r))
223
223
  throw r;
224
224
  });
225
225
  }
@@ -240,7 +240,7 @@ class jn extends w {
240
240
  this.handleNotify(s);
241
241
  }
242
242
  } catch (n) {
243
- Ke("error parse notify", n);
243
+ Je("error parse notify", n);
244
244
  }
245
245
  };
246
246
  handleNotify = (e) => {
@@ -290,7 +290,7 @@ class jn extends w {
290
290
  break;
291
291
  }
292
292
  default:
293
- Ke("unknown cmd", e);
293
+ Je("unknown cmd", e);
294
294
  }
295
295
  };
296
296
  handleNewInfo = (e) => {
@@ -412,7 +412,7 @@ class jn extends w {
412
412
  participant: n,
413
413
  jwt: s
414
414
  };
415
- Hn(r) && this.events.trigger(
415
+ Vn(r) && this.events.trigger(
416
416
  "conference:participant-token-issued",
417
417
  r
418
418
  );
@@ -458,7 +458,7 @@ class jn extends w {
458
458
  maybeTriggerParticipantMoveRequest = (e) => {
459
459
  const n = P(e, E.CONTENT_PARTICIPANT_STATE), s = P(e, E.AUDIO_ID), r = P(e, E.SPECTATOR_MODE);
460
460
  if (n === Ne.SPECTATOR) {
461
- const i = r === Qe.BY_STATE_CAM;
461
+ const i = r === We.BY_STATE_CAM;
462
462
  s === void 0 ? (this.events.trigger("participant:move-request-to-spectators-synthetic", {
463
463
  isAvailableSendingMedia: i
464
464
  }), this.events.trigger("participant:move-request-to-spectators", {
@@ -504,11 +504,11 @@ class jn extends w {
504
504
  return this.getEstablishedRTCSessionProtected().sendInfo(W.ENTER_ROOM, void 0, { extraHeaders: e });
505
505
  }
506
506
  }
507
- const Xe = 0, zn = 30;
508
- let Jn = class {
509
- countInner = Xe;
510
- initialCount = Xe;
511
- limitInner = zn;
507
+ const Ke = 0, jn = 30;
508
+ let zn = class {
509
+ countInner = Ke;
510
+ initialCount = Ke;
511
+ limitInner = jn;
512
512
  isInProgress = !1;
513
513
  onStatusChange;
514
514
  constructor({
@@ -541,7 +541,7 @@ let Jn = class {
541
541
  this.countInner = this.initialCount, this.finishAttempt();
542
542
  }
543
543
  };
544
- class Kn {
544
+ class Jn {
545
545
  connectionManager;
546
546
  interval;
547
547
  checkTelephonyByTimeout = void 0;
@@ -556,7 +556,7 @@ class Kn {
556
556
  onSuccessRequest: n,
557
557
  onFailRequest: s
558
558
  }) {
559
- this.stop(), this.cancelableGetParameters = new me(e), this.checkTelephonyByTimeout = yn({
559
+ this.stop(), this.cancelableGetParameters = new me(e), this.checkTelephonyByTimeout = Mt({
560
560
  isDontStopOnFail: !0,
561
561
  requestInterval: this.interval,
562
562
  request: async () => {
@@ -576,28 +576,39 @@ class Kn {
576
576
  this.checkTelephonyByTimeout?.stop(), this.checkTelephonyByTimeout = void 0, this.cancelableGetParameters?.cancelRequest(), this.cancelableGetParameters = void 0;
577
577
  }
578
578
  }
579
- const Xn = 15e3, Zn = 2, Oe = I("PingServerRequester");
580
- class es {
579
+ const Kn = 15e3, Xn = 2, Xe = I("AutoConnectorManager: PingServerRequester");
580
+ class Zn {
581
581
  connectionManager;
582
- pingServerByTimeoutWithFailCalls;
582
+ pingServerByTimeout = void 0;
583
+ failRequestsCount = 0;
584
+ isFailRequestReported = !1;
583
585
  constructor({ connectionManager: e }) {
584
- this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Dn(Zn, {
585
- whenPossibleRequest: async () => {
586
- },
587
- requestInterval: Xn,
588
- request: async () => (Oe("ping"), this.connectionManager.ping().then(() => {
589
- Oe("ping success");
590
- }))
591
- });
586
+ this.connectionManager = e;
592
587
  }
593
588
  start({ onFailRequest: e }) {
594
- this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(Oe);
589
+ this.stop(), this.pingServerByTimeout = Mt({
590
+ isDontStopOnFail: !0,
591
+ requestInterval: Kn,
592
+ request: async () => (Xe("ping"), this.connectionManager.ping().then(() => {
593
+ Xe("ping success");
594
+ }))
595
+ }), this.pingServerByTimeout.start(void 0, {
596
+ onSuccessRequest: () => {
597
+ this.resetFailRequests();
598
+ },
599
+ onFailRequest: () => {
600
+ this.failRequestsCount += 1, !(this.failRequestsCount < Xn || this.isFailRequestReported) && (this.isFailRequestReported = !0, e());
601
+ }
602
+ });
595
603
  }
596
604
  stop() {
597
- this.pingServerByTimeoutWithFailCalls.stop();
605
+ this.pingServerByTimeout?.stop(), this.pingServerByTimeout = void 0, this.resetFailRequests();
606
+ }
607
+ resetFailRequests() {
608
+ this.failRequestsCount = 0, this.isFailRequestReported = !1;
598
609
  }
599
610
  }
600
- class ts {
611
+ class es {
601
612
  callManager;
602
613
  disposers = [];
603
614
  constructor({ callManager: e }) {
@@ -622,7 +633,7 @@ class ts {
622
633
  this.callManager.isCallActive ? e?.() : n();
623
634
  }
624
635
  }
625
- class ns {
636
+ class ts {
626
637
  connectionManager;
627
638
  isRegistrationFailed = !1;
628
639
  disposers = [];
@@ -631,7 +642,7 @@ class ns {
631
642
  connectionManager: e,
632
643
  callManager: n
633
644
  }) {
634
- this.connectionManager = e, this.notActiveCallSubscriber = new ts({ callManager: n });
645
+ this.connectionManager = e, this.notActiveCallSubscriber = new es({ callManager: n });
635
646
  }
636
647
  subscribe(e) {
637
648
  this.unsubscribe(), this.disposers.push(
@@ -658,7 +669,7 @@ class ns {
658
669
  this.isRegistrationFailed = !1;
659
670
  }
660
671
  }
661
- const ss = {
672
+ const ns = {
662
673
  baseRetryDelayMs: 1e3,
663
674
  maxRetryDelayMs: 3e4,
664
675
  warningThreshold: 3,
@@ -668,14 +679,14 @@ const ss = {
668
679
  warning: 1,
669
680
  critical: 2
670
681
  };
671
- class rs {
682
+ class ss {
672
683
  failCount = 0;
673
684
  nextRetryAtMs = 0;
674
685
  escalationLevel = "none";
675
686
  options;
676
687
  constructor(e) {
677
688
  this.options = {
678
- ...ss,
689
+ ...ns,
679
690
  ...e
680
691
  };
681
692
  }
@@ -714,7 +725,26 @@ class rs {
714
725
  );
715
726
  }
716
727
  }
717
- const F = I("AutoConnectorRuntime"), is = 3e3, as = 15e3;
728
+ const K = {
729
+ START: "start",
730
+ MANUAL_RESTART: "manual-restart",
731
+ REGISTRATION_FAILED_OUT_OF_CALL: "registration-failed-out-of-call",
732
+ TELEPHONY_DISCONNECTED: "telephony-disconnected",
733
+ TELEPHONY_CHECK_FAILED: "telephony-check-failed",
734
+ /** Порог неуспешных периодических SIP OPTIONS (`PingServerRequester`) в `connectedMonitoring`. */
735
+ PERIODIC_PING_FAILED: "periodic-ping-failed",
736
+ NETWORK_ONLINE: "network-online",
737
+ NETWORK_CHANGE: "network-change"
738
+ }, rs = {
739
+ [K.START]: 0,
740
+ [K.TELEPHONY_DISCONNECTED]: 1,
741
+ [K.TELEPHONY_CHECK_FAILED]: 1,
742
+ [K.PERIODIC_PING_FAILED]: 2,
743
+ [K.REGISTRATION_FAILED_OUT_OF_CALL]: 3,
744
+ [K.MANUAL_RESTART]: 4,
745
+ [K.NETWORK_ONLINE]: 4,
746
+ [K.NETWORK_CHANGE]: 4
747
+ }, et = (t) => rs[t], F = I("AutoConnectorManager: AutoConnectorRuntime"), is = 3e3, as = 15e3;
718
748
  class os {
719
749
  connectionManager;
720
750
  connectionQueueManager;
@@ -727,17 +757,17 @@ class os {
727
757
  emitters;
728
758
  reconnectActions;
729
759
  constructor(e) {
730
- this.connectionManager = e.connectionManager, this.connectionQueueManager = e.connectionQueueManager, this.emitters = e.emitters, this.reconnectActions = e.reconnectActions, this.checkTelephonyRequester = new Kn({
760
+ this.connectionManager = e.connectionManager, this.connectionQueueManager = e.connectionQueueManager, this.emitters = e.emitters, this.reconnectActions = e.reconnectActions, this.checkTelephonyRequester = new Jn({
731
761
  connectionManager: this.connectionManager,
732
762
  interval: e.options?.checkTelephonyRequestInterval ?? as
733
- }), this.pingServerRequester = new es({
763
+ }), this.pingServerRequester = new Zn({
734
764
  connectionManager: this.connectionManager
735
- }), this.registrationFailedOutOfCallSubscriber = new ns({
765
+ }), this.registrationFailedOutOfCallSubscriber = new ts({
736
766
  connectionManager: this.connectionManager,
737
767
  callManager: e.callManager
738
- }), this.delayBetweenAttempts = new Mt(
768
+ }), this.delayBetweenAttempts = new Ot(
739
769
  e.options?.timeoutBetweenAttempts ?? is
740
- ), this.telephonyFailPolicy = new rs(e.options?.telephonyFailPolicy), this.attemptsState = new Jn({
770
+ ), this.telephonyFailPolicy = new ss(e.options?.telephonyFailPolicy), this.attemptsState = new zn({
741
771
  onStatusChange: this.emitters.emitStatusChange
742
772
  });
743
773
  }
@@ -826,7 +856,7 @@ class os {
826
856
  subscribeToConnectTriggers(e) {
827
857
  this.pingServerRequester.start({
828
858
  onFailRequest: () => {
829
- F("pingRequester: onFailRequest");
859
+ F("pingRequester: onFailRequest"), this.reconnectActions.requestReconnect(e, K.PERIODIC_PING_FAILED);
830
860
  }
831
861
  }), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
832
862
  F("registrationFailedOutOfCallListener callback"), this.reconnectActions.requestReconnect(e, "registration-failed-out-of-call");
@@ -842,7 +872,7 @@ class te {
842
872
  subscriptions = [];
843
873
  stateChangeListeners = /* @__PURE__ */ new Set();
844
874
  constructor(e) {
845
- this.actor = Pn(e), this.actor.start(), this.addSubscription(
875
+ this.actor = Dn(e), this.actor.start(), this.addSubscription(
846
876
  this.subscribe((n) => {
847
877
  const s = n.value;
848
878
  this.stateChangeListeners.forEach((r) => {
@@ -884,7 +914,7 @@ class te {
884
914
  return this.subscriptions.push(n), n;
885
915
  }
886
916
  }
887
- const wt = "Not ready for connection", cs = (t) => t instanceof Error && t.message === wt, ls = () => new Error(wt), ds = async (t) => typeof t == "function" ? t() : t, hs = 3;
917
+ const Gt = "Not ready for connection", cs = (t) => t instanceof Error && t.message === Gt, ls = () => new Error(Gt), ds = async (t) => typeof t == "function" ? t() : t, hs = 3;
888
918
  class us {
889
919
  resolveParametersRequester = new me(ds);
890
920
  cancelableConnectWithRepeatedCalls;
@@ -919,10 +949,10 @@ class us {
919
949
  }
920
950
  connectWithDuplicatedCalls = async (e, { numberOfConnectionAttempts: n = this.numberOfConnectionAttempts } = {}) => {
921
951
  const s = async () => this.connectInner(e), r = (i) => {
922
- const c = this.dependencies.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), g = i != null && !Bn(i);
952
+ const c = this.dependencies.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), g = i != null && !Un(i);
923
953
  return c || g;
924
954
  };
925
- return this.cancelableConnectWithRepeatedCalls = He({
955
+ return this.cancelableConnectWithRepeatedCalls = Ve({
926
956
  targetFunction: s,
927
957
  isComplete: r,
928
958
  callLimit: n,
@@ -953,10 +983,10 @@ class us {
953
983
  userAgent: f,
954
984
  displayName: y = "",
955
985
  register: _ = !1,
956
- extraHeaders: V = []
986
+ extraHeaders: q = []
957
987
  }) => {
958
988
  this.dependencies.getUa() && await this.disconnect({ cancelRequests: !1 });
959
- const { ua: K, helpers: ne } = this.dependencies.uaFactory.createUAWithConfiguration(
989
+ const { ua: X, helpers: ne } = this.dependencies.uaFactory.createUAWithConfiguration(
960
990
  {
961
991
  user: e,
962
992
  password: n,
@@ -970,13 +1000,13 @@ class us {
970
1000
  connectionRecoveryMaxInterval: C,
971
1001
  userAgent: f,
972
1002
  remoteAddress: i,
973
- extraHeaders: V
1003
+ extraHeaders: q
974
1004
  },
975
1005
  this.dependencies.events
976
1006
  );
977
- this.dependencies.setUa(K), this.dependencies.setGetUri(ne.getUri), this.dependencies.setSocket(ne.socket);
978
- const Me = K.configuration.uri.user;
979
- return { ua: K, configuration: {
1007
+ this.dependencies.setUa(X), this.dependencies.setGetUri(ne.getUri), this.dependencies.setSocket(ne.socket);
1008
+ const Me = X.configuration.uri.user;
1009
+ return { ua: X, configuration: {
980
1010
  sipServerIp: s,
981
1011
  sipServerUrl: r,
982
1012
  remoteAddress: i,
@@ -1023,11 +1053,11 @@ class us {
1023
1053
  }
1024
1054
  }
1025
1055
  var l = /* @__PURE__ */ ((t) => (t.IDLE = "connection:idle", t.PREPARING = "connection:preparing", t.CONNECTING = "connection:connecting", t.CONNECTED = "connection:connected", t.REGISTERED = "connection:registered", t.ESTABLISHED = "connection:established", t.DISCONNECTING = "connection:disconnecting", t.DISCONNECTED = "connection:disconnected", t))(l || {}), N = /* @__PURE__ */ ((t) => (t.LOG_TRANSITION = "logTransition", t.LOG_STATE_CHANGE = "logStateChange", t.SET_CONNECTION_CONFIGURATION = "setConnectionConfiguration", t.CLEAR_CONNECTION_CONFIGURATION = "clearConnectionConfiguration", t))(N || {}), m = /* @__PURE__ */ ((t) => (t.START_CONNECT = "START_CONNECT", t.START_UA = "START_UA", t.START_DISCONNECT = "START_DISCONNECT", t.UA_CONNECTED = "UA_CONNECTED", t.UA_CONNECTING = "UA_CONNECTING", t.UA_REGISTERED = "UA_REGISTERED", t.UA_UNREGISTERED = "UA_UNREGISTERED", t.UA_DISCONNECTED = "UA_DISCONNECTED", t.RESET = "RESET", t))(m || {});
1026
- const Gt = {
1056
+ const kt = {
1027
1057
  connectionConfiguration: void 0
1028
- }, et = I("ConnectionStateMachine"), gs = () => ee({
1058
+ }, tt = I("ConnectionManager: createConnectionMachineSetup"), gs = () => ee({
1029
1059
  types: {
1030
- context: Gt,
1060
+ context: kt,
1031
1061
  events: {}
1032
1062
  },
1033
1063
  guards: {
@@ -1041,16 +1071,16 @@ const Gt = {
1041
1071
  connectionConfiguration: void 0
1042
1072
  })),
1043
1073
  [N.LOG_TRANSITION]: (t, e) => {
1044
- et(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1074
+ tt(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1045
1075
  },
1046
1076
  [N.LOG_STATE_CHANGE]: (t, e) => {
1047
- et("ConnectionStateMachine state changed", e.state);
1077
+ tt("ConnectionStateMachine state changed", e.state);
1048
1078
  }
1049
1079
  }
1050
1080
  }), Es = () => gs().createMachine({
1051
1081
  id: "connection",
1052
1082
  initial: l.IDLE,
1053
- context: Gt,
1083
+ context: kt,
1054
1084
  states: {
1055
1085
  [l.IDLE]: {
1056
1086
  entry: [
@@ -1370,7 +1400,7 @@ const Gt = {
1370
1400
  }
1371
1401
  }
1372
1402
  }
1373
- }), ms = Es(), Ts = I("ConnectionStateMachine");
1403
+ }), ms = Es(), Ts = I("ConnectionManager: ConnectionStateMachine");
1374
1404
  class ps extends te {
1375
1405
  events;
1376
1406
  unsubscribeFromEvents;
@@ -1471,7 +1501,7 @@ class ps extends te {
1471
1501
  };
1472
1502
  }
1473
1503
  }
1474
- const kt = [
1504
+ const Ft = [
1475
1505
  "connecting",
1476
1506
  "connected",
1477
1507
  "disconnected",
@@ -1489,7 +1519,7 @@ const kt = [
1489
1519
  "connect-parameters-resolve-success",
1490
1520
  "connect-parameters-resolve-failed",
1491
1521
  "connected-with-configuration"
1492
- ], Ft = [...kt, ...Ss], Cs = () => new G(Ft), Rs = I("RegistrationManager");
1522
+ ], Ut = [...Ft, ...Ss], Cs = () => new G(Ut), Rs = I("ConnectionManager: RegistrationManager");
1493
1523
  class Ns {
1494
1524
  events;
1495
1525
  getUaProtected;
@@ -1654,12 +1684,12 @@ class oe {
1654
1684
  sipServerIp: i,
1655
1685
  sipServerUrl: s
1656
1686
  });
1657
- const y = oe.resolveAuthorizationUser(a, e), _ = fs(i), V = _(y), B = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
1687
+ const y = oe.resolveAuthorizationUser(a, e), _ = fs(i), q = _(y), B = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
1658
1688
  return {
1659
1689
  configuration: {
1660
1690
  password: n,
1661
1691
  register: a,
1662
- uri: V,
1692
+ uri: q,
1663
1693
  display_name: Ms(r),
1664
1694
  user_agent: f,
1665
1695
  sockets: [B],
@@ -1688,7 +1718,7 @@ class oe {
1688
1718
  extraHeaders: e.extraHeaders
1689
1719
  });
1690
1720
  return n.eachTriggers((a, o) => {
1691
- const c = kt.find((g) => g === o);
1721
+ const c = Ft.find((g) => g === o);
1692
1722
  c && i.on(c, a);
1693
1723
  }), { ua: i, helpers: r };
1694
1724
  }
@@ -1812,7 +1842,7 @@ class ys extends w {
1812
1842
  }
1813
1843
  class Ds {
1814
1844
  connectionManager;
1815
- stackPromises = bt({
1845
+ stackPromises = yt({
1816
1846
  noRunIsNotActual: !0
1817
1847
  });
1818
1848
  constructor({ connectionManager: e }) {
@@ -1827,7 +1857,7 @@ class Ds {
1827
1857
  const z = (t) => {
1828
1858
  if (t !== null && typeof t == "object" && "error" in t)
1829
1859
  return t.error;
1830
- }, b = I("AutoConnectorMachine"), tt = (t) => t.parameters, Ps = (t) => ee({
1860
+ }, b = I("AutoConnectorManager: createAutoConnectorMachineSetup"), nt = (t) => t.parameters, Ps = (t) => ee({
1831
1861
  types: {
1832
1862
  context: {},
1833
1863
  events: {}
@@ -1883,12 +1913,12 @@ const z = (t) => {
1883
1913
  },
1884
1914
  /** Промис коннекта снят очередью (`stack-promises`) — отмена попыток. */
1885
1915
  isNotActualPromise: ({ event: e }) => {
1886
- const n = yt(z(e));
1916
+ const n = Dt(z(e));
1887
1917
  return b("isNotActualPromise:", n), n;
1888
1918
  },
1889
1919
  /** Отмена задержки (cancelable / timeout-requester). */
1890
1920
  isWaitRetryCancelled: ({ event: e }) => {
1891
- const n = z(e), s = qe(n) || Ot(n);
1921
+ const n = z(e), s = qe(n) || _t(n);
1892
1922
  return b("isWaitRetryCancelled:", s), s;
1893
1923
  }
1894
1924
  },
@@ -1923,11 +1953,11 @@ const z = (t) => {
1923
1953
  },
1924
1954
  /** Лимит: завершить попытку, событие лимита, запуск опроса телефонии. */
1925
1955
  onLimitReachedTransition: ({ context: e }) => {
1926
- b("onLimitReachedTransition"), t.onLimitReached(tt(e));
1956
+ b("onLimitReachedTransition"), t.onLimitReached(nt(e));
1927
1957
  },
1928
1958
  /** Успешный invoke `connect`. */
1929
1959
  onConnectDone: ({ context: e }) => {
1930
- b("onConnectDone"), t.onConnectSucceeded(tt(e));
1960
+ b("onConnectDone"), t.onConnectSucceeded(nt(e));
1931
1961
  },
1932
1962
  assignHaltedError: A({
1933
1963
  stopReason: () => "halted",
@@ -2197,7 +2227,7 @@ const Ls = () => ({
2197
2227
  on: ce()
2198
2228
  }
2199
2229
  }
2200
- }), Gs = I("AutoConnectorStateMachine");
2230
+ }), Gs = I("AutoConnectorManager: AutoConnectorStateMachine");
2201
2231
  class ks extends te {
2202
2232
  constructor(e) {
2203
2233
  super(e);
@@ -2235,14 +2265,14 @@ const Fs = (t) => new ks(ws(t)), Us = /* @__PURE__ */ new Set([401, 403]), Bs =
2235
2265
  return !1;
2236
2266
  const e = t.response?.status_code;
2237
2267
  return typeof e == "number" && Us.has(e);
2238
- }, xs = (t) => !$s(t), Vs = (t) => {
2268
+ }, xs = (t) => !$s(t), qs = (t) => {
2239
2269
  if (!(typeof window > "u"))
2240
2270
  return window;
2241
- }, qs = (t) => {
2271
+ }, Vs = (t) => {
2242
2272
  if (!(typeof navigator > "u"))
2243
2273
  return navigator;
2244
2274
  }, Hs = (t) => {
2245
- const e = Vs(), n = qs();
2275
+ const e = qs(), n = Vs();
2246
2276
  if (!e)
2247
2277
  return;
2248
2278
  let s = [];
@@ -2277,11 +2307,11 @@ const Fs = (t) => new ks(ws(t)), Us = /* @__PURE__ */ new Set([401, 403]), Bs =
2277
2307
  },
2278
2308
  unsubscribe: r
2279
2309
  };
2280
- }, Ws = "Failed to reconnect", nt = (t) => t instanceof Error ? t : new Error(Ws), Qs = (t) => {
2310
+ }, Ws = "Failed to reconnect", st = (t) => t instanceof Error ? t : new Error(Ws), Qs = (t) => {
2281
2311
  const e = (s) => t.baseCanRetryOnError(s) ? t.canRetryOnError?.(s) ?? !0 : !1, n = ({
2282
2312
  stopReason: s,
2283
2313
  lastError: r
2284
- }) => s === "cancelled" && !yt(r) || s === "failed" ? nt(r) : r;
2314
+ }) => s === "cancelled" && !Dt(r) || s === "failed" ? st(r) : r;
2285
2315
  return {
2286
2316
  canRetryOnError: e,
2287
2317
  shouldDisconnectBeforeAttempt: () => t.runtime.shouldDisconnectBeforeAttempt(),
@@ -2318,7 +2348,7 @@ const Fs = (t) => new ks(ws(t)), Us = /* @__PURE__ */ new Set([401, 403]), Bs =
2318
2348
  t.runtime.onTelephonyStillConnected();
2319
2349
  }
2320
2350
  };
2321
- }, Ut = [
2351
+ }, Bt = [
2322
2352
  "before-attempt",
2323
2353
  "success",
2324
2354
  "failed-all-attempts",
@@ -2328,7 +2358,7 @@ const Fs = (t) => new ks(ws(t)), Us = /* @__PURE__ */ new Set([401, 403]), Bs =
2328
2358
  "limit-reached-attempts",
2329
2359
  "telephony-check-failure",
2330
2360
  "telephony-check-escalated"
2331
- ], Ys = () => new G(Ut), J = I("NetworkEventsReconnector"), js = 2e3, st = "probe", zs = "network-online", Js = "network-change";
2361
+ ], Ys = () => new G(Bt), J = I("AutoConnectorManager: NetworkEventsReconnector"), js = 2e3, rt = "probe", zs = "network-online", Js = "network-change";
2332
2362
  class Ks {
2333
2363
  subscriber;
2334
2364
  offlineGraceMs;
@@ -2352,7 +2382,7 @@ class Ks {
2352
2382
  requestReconnect: a,
2353
2383
  stopConnection: o
2354
2384
  }) {
2355
- this.subscriber = e, this.offlineGraceMs = n ?? js, this.onChangePolicy = s ?? st, this.onOnlinePolicy = r ?? st, this.probe = i, this.requestReconnect = a, this.stopConnection = o;
2385
+ this.subscriber = e, this.offlineGraceMs = n ?? js, this.onChangePolicy = s ?? rt, this.onOnlinePolicy = r ?? rt, this.probe = i, this.requestReconnect = a, this.stopConnection = o;
2356
2386
  }
2357
2387
  start(e) {
2358
2388
  this.parameters = e, !this.isSubscribed && (this.subscriber.subscribe({
@@ -2410,24 +2440,7 @@ class Ks {
2410
2440
  this.offlineTimer !== void 0 && (clearTimeout(this.offlineTimer), this.offlineTimer = void 0);
2411
2441
  }
2412
2442
  }
2413
- const X = {
2414
- START: "start",
2415
- MANUAL_RESTART: "manual-restart",
2416
- REGISTRATION_FAILED_OUT_OF_CALL: "registration-failed-out-of-call",
2417
- TELEPHONY_DISCONNECTED: "telephony-disconnected",
2418
- TELEPHONY_CHECK_FAILED: "telephony-check-failed",
2419
- NETWORK_ONLINE: "network-online",
2420
- NETWORK_CHANGE: "network-change"
2421
- }, Xs = {
2422
- [X.START]: 0,
2423
- [X.TELEPHONY_DISCONNECTED]: 1,
2424
- [X.TELEPHONY_CHECK_FAILED]: 1,
2425
- [X.REGISTRATION_FAILED_OUT_OF_CALL]: 3,
2426
- [X.MANUAL_RESTART]: 4,
2427
- [X.NETWORK_ONLINE]: 4,
2428
- [X.NETWORK_CHANGE]: 4
2429
- }, rt = (t) => Xs[t];
2430
- class Zs {
2443
+ class Xs {
2431
2444
  generation = 0;
2432
2445
  lastRequest;
2433
2446
  coalesceWindowMs;
@@ -2435,9 +2448,9 @@ class Zs {
2435
2448
  this.coalesceWindowMs = e;
2436
2449
  }
2437
2450
  register(e) {
2438
- const n = Date.now(), s = rt(e), { lastRequest: r } = this;
2451
+ const n = Date.now(), s = et(e), { lastRequest: r } = this;
2439
2452
  if (r !== void 0 && n - r.timestamp < this.coalesceWindowMs) {
2440
- const a = rt(r.reason);
2453
+ const a = et(r.reason);
2441
2454
  if (s <= a)
2442
2455
  return {
2443
2456
  shouldRequest: !1,
@@ -2460,15 +2473,15 @@ class Zs {
2460
2473
  this.lastRequest = void 0;
2461
2474
  }
2462
2475
  }
2463
- const er = 250, tr = {
2476
+ const Zs = 250, er = {
2464
2477
  LIMIT_REACHED: "Limit reached"
2465
- }, k = I("AutoConnectorManager"), nr = "start", sr = "manual-restart";
2466
- class rr extends w {
2478
+ }, k = I("AutoConnectorManager"), tr = "start", nr = "manual-restart";
2479
+ class sr extends w {
2467
2480
  stateMachine;
2468
2481
  runtime;
2469
2482
  connectionManager;
2470
- reconnectCoalescer = new Zs({
2471
- coalesceWindowMs: er
2483
+ reconnectCoalescer = new Xs({
2484
+ coalesceWindowMs: Zs
2472
2485
  });
2473
2486
  networkEventsReconnector;
2474
2487
  constructor({
@@ -2486,7 +2499,7 @@ class rr extends w {
2486
2499
  this.events.trigger("before-attempt", {});
2487
2500
  },
2488
2501
  emitLimitReachedAttempts: () => {
2489
- this.events.trigger("limit-reached-attempts", new Error(tr.LIMIT_REACHED));
2502
+ this.events.trigger("limit-reached-attempts", new Error(er.LIMIT_REACHED));
2490
2503
  },
2491
2504
  emitSuccess: () => {
2492
2505
  k("handleSucceededAttempt"), this.events.trigger("success");
@@ -2536,8 +2549,45 @@ class rr extends w {
2536
2549
  }
2537
2550
  }));
2538
2551
  }
2539
- start(e) {
2540
- k("auto connector start"), this.networkEventsReconnector?.start(e), this.requestReconnect(e, nr);
2552
+ async start(e) {
2553
+ return k("auto connector start"), this.networkEventsReconnector?.start(e), this.requestReconnect(e, tr) ? new Promise((s) => {
2554
+ const r = this.events.onceRace(
2555
+ ["success", "failed-all-attempts", "stop-attempts-by-error", "limit-reached-attempts"],
2556
+ (i, a) => {
2557
+ if (r(), a === "success") {
2558
+ s({
2559
+ isSuccess: !0,
2560
+ reason: "started"
2561
+ });
2562
+ return;
2563
+ }
2564
+ if (a === "failed-all-attempts") {
2565
+ s({
2566
+ isSuccess: !1,
2567
+ reason: "failed-all-attempts",
2568
+ error: i
2569
+ });
2570
+ return;
2571
+ }
2572
+ if (a === "stop-attempts-by-error") {
2573
+ s({
2574
+ isSuccess: !1,
2575
+ reason: "stop-attempts-by-error",
2576
+ error: i
2577
+ });
2578
+ return;
2579
+ }
2580
+ s({
2581
+ isSuccess: !1,
2582
+ reason: "limit-reached-attempts",
2583
+ error: i
2584
+ });
2585
+ }
2586
+ );
2587
+ }) : {
2588
+ isSuccess: !1,
2589
+ reason: "coalesced"
2590
+ };
2541
2591
  }
2542
2592
  restart() {
2543
2593
  k("auto connector restart");
@@ -2546,7 +2596,7 @@ class rr extends w {
2546
2596
  k("auto connector restart skipped: no parameters in context");
2547
2597
  return;
2548
2598
  }
2549
- this.requestReconnect(e, sr);
2599
+ this.requestReconnect(e, nr);
2550
2600
  }
2551
2601
  stop() {
2552
2602
  k("auto connector stop"), this.networkEventsReconnector?.stop(), this.resetReconnectCoalescingState(), this.stateMachine.toStop();
@@ -2557,10 +2607,10 @@ class rr extends w {
2557
2607
  }
2558
2608
  requestReconnect = (e, n) => {
2559
2609
  const s = this.shouldRequestReconnect(n);
2560
- k("auto connector requestReconnect", {
2610
+ return k("auto connector requestReconnect", {
2561
2611
  isAvailableToRestart: s,
2562
2612
  reason: n
2563
- }), s && (this.networkEventsReconnector?.setParameters(e), this.stateMachine.toRestart(e));
2613
+ }), s ? (this.networkEventsReconnector?.setParameters(e), this.stateMachine.toRestart(e), !0) : !1;
2564
2614
  };
2565
2615
  // Адаптивный probe под состояние машины. Возвращаемое значение трактуется
2566
2616
  // вызывающей стороной единообразно: `true` — reconnect не нужен, `false` —
@@ -2614,8 +2664,8 @@ class rr extends w {
2614
2664
  this.reconnectCoalescer.reset();
2615
2665
  }
2616
2666
  }
2617
- const it = 0, ir = 0;
2618
- class ar {
2667
+ const it = 0, rr = 0;
2668
+ class ir {
2619
2669
  countInner = it;
2620
2670
  initialCount = it;
2621
2671
  limitInner;
@@ -2634,7 +2684,7 @@ class ar {
2634
2684
  return this.isInProgress;
2635
2685
  }
2636
2686
  hasLimitReached() {
2637
- return this.limitInner === ir ? !1 : this.countInner >= this.limitInner;
2687
+ return this.limitInner === rr ? !1 : this.countInner >= this.limitInner;
2638
2688
  }
2639
2689
  startAttempt() {
2640
2690
  this.isInProgress || (this.isInProgress = !0, this.onStatusChange({ isInProgress: this.isInProgress }));
@@ -2649,43 +2699,43 @@ class ar {
2649
2699
  this.countInner = this.initialCount, this.finishAttempt();
2650
2700
  }
2651
2701
  }
2652
- const at = 1, or = (t) => t < at ? at : t, cr = (t, e) => {
2653
- const { baseBackoffMs: n, maxBackoffMs: s, backoffFactor: r } = e, i = or(t), a = n * r ** (i - 1);
2702
+ const at = 1, ar = (t) => t < at ? at : t, or = (t, e) => {
2703
+ const { baseBackoffMs: n, maxBackoffMs: s, backoffFactor: r } = e, i = ar(t), a = n * r ** (i - 1);
2654
2704
  return Math.min(s, a);
2655
- }, lr = (t, e, n) => {
2705
+ }, cr = (t, e, n) => {
2656
2706
  if (e === "none")
2657
2707
  return t;
2658
2708
  if (e === "full")
2659
2709
  return n() * t;
2660
2710
  const s = t / 2;
2661
2711
  return s + n() * s;
2662
- }, dr = (t, e, n = Math.random) => {
2663
- const s = cr(t, e);
2664
- return lr(s, e.jitter, n);
2665
- }, hr = /* @__PURE__ */ new Set([
2712
+ }, lr = (t, e, n = Math.random) => {
2713
+ const s = or(t, e);
2714
+ return cr(s, e.jitter, n);
2715
+ }, dr = /* @__PURE__ */ new Set([
2666
2716
  Z.causes.CONNECTION_ERROR,
2667
2717
  Z.causes.REQUEST_TIMEOUT,
2668
2718
  Z.causes.RTP_TIMEOUT,
2669
2719
  Z.causes.ADDRESS_INCOMPLETE
2670
- ]), ur = (t) => {
2720
+ ]), hr = (t) => {
2671
2721
  const { cause: e, originator: n } = t;
2672
- return n === "local" ? !1 : !!(hr.has(e) || e === Z.causes.INTERNAL_ERROR && n === "system");
2673
- }, gr = (t) => t ?? ur, ot = I("CallReconnectRuntime"), se = {
2722
+ return n === "local" ? !1 : !!(dr.has(e) || e === Z.causes.INTERNAL_ERROR && n === "system");
2723
+ }, ur = (t) => t ?? hr, ot = I("CallReconnectRuntime"), se = {
2674
2724
  maxAttempts: 5,
2675
2725
  baseBackoffMs: 1e3,
2676
2726
  maxBackoffMs: 3e4,
2677
2727
  backoffFactor: 2,
2678
2728
  jitter: "equal",
2679
2729
  waitSignalingTimeoutMs: 2e4
2680
- }, Er = (t) => ({
2730
+ }, gr = (t) => ({
2681
2731
  maxAttempts: t?.maxAttempts ?? se.maxAttempts,
2682
2732
  baseBackoffMs: t?.baseBackoffMs ?? se.baseBackoffMs,
2683
2733
  maxBackoffMs: t?.maxBackoffMs ?? se.maxBackoffMs,
2684
2734
  backoffFactor: t?.backoffFactor ?? se.backoffFactor,
2685
2735
  jitter: t?.jitter ?? se.jitter,
2686
2736
  waitSignalingTimeoutMs: t?.waitSignalingTimeoutMs ?? se.waitSignalingTimeoutMs
2687
- }), mr = (t) => !0;
2688
- class Tr {
2737
+ }), Er = (t) => !0;
2738
+ class mr {
2689
2739
  resolvedOptions;
2690
2740
  callManager;
2691
2741
  connectionManager;
@@ -2696,7 +2746,7 @@ class Tr {
2696
2746
  canRetryOnErrorFn;
2697
2747
  unsubscribeConnectionWait;
2698
2748
  constructor(e) {
2699
- this.resolvedOptions = Er(e.options), this.callManager = e.callManager, this.connectionManager = e.connectionManager, this.isNetworkFailureFn = gr(e.options?.isNetworkFailure), this.canRetryOnErrorFn = e.options?.canRetryOnError ?? mr, this.delayRequester = new Mt(this.resolvedOptions.baseBackoffMs), this.performCall = new me(
2749
+ this.resolvedOptions = gr(e.options), this.callManager = e.callManager, this.connectionManager = e.connectionManager, this.isNetworkFailureFn = ur(e.options?.isNetworkFailure), this.canRetryOnErrorFn = e.options?.canRetryOnError ?? Er, this.delayRequester = new Ot(this.resolvedOptions.baseBackoffMs), this.performCall = new me(
2700
2750
  async (n) => {
2701
2751
  const s = await n.getCallParameters();
2702
2752
  await this.callManager.startCall(
@@ -2705,7 +2755,7 @@ class Tr {
2705
2755
  s
2706
2756
  );
2707
2757
  }
2708
- ), this.attemptsState = new ar({
2758
+ ), this.attemptsState = new ir({
2709
2759
  limit: this.resolvedOptions.maxAttempts,
2710
2760
  onStatusChange: ({ isInProgress: n }) => {
2711
2761
  e.emitters.emitStatusChange({ isReconnecting: n });
@@ -2725,7 +2775,7 @@ class Tr {
2725
2775
  return this.attemptsState.hasLimitReached();
2726
2776
  }
2727
2777
  computeNextDelayMs(e) {
2728
- return dr(e, {
2778
+ return lr(e, {
2729
2779
  baseBackoffMs: this.resolvedOptions.baseBackoffMs,
2730
2780
  maxBackoffMs: this.resolvedOptions.maxBackoffMs,
2731
2781
  backoffFactor: this.resolvedOptions.backoffFactor,
@@ -2773,7 +2823,7 @@ class Tr {
2773
2823
  const pe = (t) => {
2774
2824
  if (t !== null && typeof t == "object" && "error" in t)
2775
2825
  return t.error;
2776
- }, _e = I("CallReconnectMachine"), pr = (t) => t.parameters, Sr = (t) => ee({
2826
+ }, Oe = I("CallReconnectMachine"), Tr = (t) => t.parameters, pr = (t) => ee({
2777
2827
  types: {
2778
2828
  context: {},
2779
2829
  events: {}
@@ -2781,16 +2831,16 @@ const pe = (t) => {
2781
2831
  actors: {
2782
2832
  /** Invoke в `backoff`: таймаут задержки перед следующей попыткой. */
2783
2833
  delayBeforeAttempt: ae(async ({ input: e }) => {
2784
- _e("delayBeforeAttempt", e), await t.delayBeforeAttempt(e);
2834
+ Oe("delayBeforeAttempt", e), await t.delayBeforeAttempt(e);
2785
2835
  }),
2786
2836
  /** Invoke в `waitingSignaling`: ожидание готовности сигнализации с таймаутом. */
2787
2837
  waitSignalingReady: ae(async () => {
2788
- _e("waitSignalingReady"), await t.waitSignalingReady();
2838
+ Oe("waitSignalingReady"), await t.waitSignalingReady();
2789
2839
  }),
2790
2840
  /** Invoke в `attempting`: реальный `startCall`. */
2791
2841
  performAttempt: ae(
2792
2842
  async ({ input: e }) => {
2793
- if (_e("performAttempt"), !e)
2843
+ if (Oe("performAttempt"), !e)
2794
2844
  throw new Error("CallReconnect parameters missing in attempting state");
2795
2845
  await t.performAttempt(e);
2796
2846
  }
@@ -2806,7 +2856,7 @@ const pe = (t) => {
2806
2856
  isNoRetryPolicy: ({ event: e }) => !t.canRetryOnError(pe(e)),
2807
2857
  isAttemptCancelled: ({ event: e }) => {
2808
2858
  const n = pe(e);
2809
- return qe(n) || Ot(n);
2859
+ return qe(n) || _t(n);
2810
2860
  }
2811
2861
  },
2812
2862
  actions: {
@@ -2904,17 +2954,17 @@ const pe = (t) => {
2904
2954
  }
2905
2955
  });
2906
2956
  var v = /* @__PURE__ */ ((t) => (t.IDLE = "idle", t.ARMED = "armed", t.EVALUATING = "evaluating", t.BACKOFF = "backoff", t.WAITING_SIGNALING = "waitingSignaling", t.ATTEMPTING = "attempting", t.LIMIT_REACHED = "limitReached", t.ERROR_TERMINAL = "errorTerminal", t))(v || {});
2907
- const Cr = () => ({
2957
+ const Sr = () => ({
2908
2958
  parameters: void 0,
2909
2959
  attempt: 0,
2910
2960
  nextDelayMs: 0,
2911
2961
  lastError: void 0,
2912
2962
  lastFailureCause: void 0,
2913
2963
  cancelledReason: void 0
2914
- }), Rr = (t) => Sr(t).createMachine({
2964
+ }), Cr = (t) => pr(t).createMachine({
2915
2965
  id: "callReconnect",
2916
2966
  initial: v.IDLE,
2917
- context: Cr,
2967
+ context: Sr,
2918
2968
  on: {
2919
2969
  /**
2920
2970
  * Глобальный `RECONNECT.ARM`: из любого состояния возвращает армированный цикл
@@ -3038,7 +3088,7 @@ const Cr = () => ({
3038
3088
  invoke: {
3039
3089
  id: "performAttempt",
3040
3090
  src: "performAttempt",
3041
- input: ({ context: e }) => pr(e),
3091
+ input: ({ context: e }) => Tr(e),
3042
3092
  onDone: {
3043
3093
  target: v.ARMED,
3044
3094
  actions: [
@@ -3083,14 +3133,14 @@ const Cr = () => ({
3083
3133
  }
3084
3134
  }
3085
3135
  }
3086
- }), Nr = I("CallReconnectStateMachine");
3087
- class Ar extends te {
3136
+ }), Rr = I("CallReconnectStateMachine");
3137
+ class Nr extends te {
3088
3138
  constructor(e) {
3089
3139
  super(e);
3090
3140
  }
3091
3141
  send(e) {
3092
3142
  if (!this.actor.getSnapshot().can(e)) {
3093
- Nr(
3143
+ Rr(
3094
3144
  `[CallReconnectStateMachine] Invalid transition: ${e.type} from ${String(this.state)}. Event cannot be processed in current state.`
3095
3145
  );
3096
3146
  return;
@@ -3098,7 +3148,7 @@ class Ar extends te {
3098
3148
  super.send(e);
3099
3149
  }
3100
3150
  }
3101
- const Ir = (t) => new Ar(Rr(t)), fr = (t) => {
3151
+ const Ar = (t) => new Nr(Cr(t)), Ir = (t) => {
3102
3152
  const { runtime: e, events: n } = t;
3103
3153
  return {
3104
3154
  isNetworkFailure: (s) => e.isNetworkFailure(s),
@@ -3159,7 +3209,7 @@ const Ir = (t) => new Ar(Rr(t)), fr = (t) => {
3159
3209
  },
3160
3210
  getWaitSignalingTimeoutMs: () => e.getWaitSignalingTimeoutMs()
3161
3211
  };
3162
- }, Bt = [
3212
+ }, $t = [
3163
3213
  "armed",
3164
3214
  "disarmed",
3165
3215
  "failure-detected",
@@ -3171,8 +3221,8 @@ const Ir = (t) => new Ar(Rr(t)), fr = (t) => {
3171
3221
  "limit-reached",
3172
3222
  "cancelled",
3173
3223
  "status-changed"
3174
- ], vr = () => new G(Bt), be = I("CallReconnectManager");
3175
- class Mr extends w {
3224
+ ], fr = () => new G($t), _e = I("CallReconnectManager");
3225
+ class vr extends w {
3176
3226
  stateMachine;
3177
3227
  runtime;
3178
3228
  callManager;
@@ -3182,7 +3232,7 @@ class Mr extends w {
3182
3232
  callManager: e,
3183
3233
  connectionManager: n
3184
3234
  }, s) {
3185
- super(vr()), this.callManager = e, this.connectionManager = n, this.runtime = new Tr({
3235
+ super(fr()), this.callManager = e, this.connectionManager = n, this.runtime = new mr({
3186
3236
  callManager: e,
3187
3237
  connectionManager: n,
3188
3238
  options: s,
@@ -3191,8 +3241,8 @@ class Mr extends w {
3191
3241
  this.events.trigger("status-changed", r);
3192
3242
  }
3193
3243
  }
3194
- }), this.stateMachine = Ir(
3195
- fr({ runtime: this.runtime, events: this.events })
3244
+ }), this.stateMachine = Ar(
3245
+ Ir({ runtime: this.runtime, events: this.events })
3196
3246
  ), this.subscribeToManagers();
3197
3247
  }
3198
3248
  get isReconnecting() {
@@ -3208,17 +3258,17 @@ class Mr extends w {
3208
3258
  * с событием `cancelled('spectator-role')`.
3209
3259
  */
3210
3260
  arm(e) {
3211
- if (be("arm"), this.callManager.hasSpectator()) {
3261
+ if (_e("arm"), this.callManager.hasSpectator()) {
3212
3262
  this.events.trigger("cancelled", { reason: "spectator-role" });
3213
3263
  return;
3214
3264
  }
3215
3265
  this.stateMachine.send({ type: "RECONNECT.ARM", parameters: e });
3216
3266
  }
3217
3267
  disarm(e = "disarm") {
3218
- be("disarm", e), this.stateMachine.send({ type: "RECONNECT.DISARM", reason: e });
3268
+ _e("disarm", e), this.stateMachine.send({ type: "RECONNECT.DISARM", reason: e });
3219
3269
  }
3220
3270
  forceReconnect() {
3221
- be("forceReconnect"), this.stateMachine.send({ type: "RECONNECT.FORCE" });
3271
+ _e("forceReconnect"), this.stateMachine.send({ type: "RECONNECT.FORCE" });
3222
3272
  }
3223
3273
  cancelCurrentAttempt() {
3224
3274
  this.runtime.cancelAll();
@@ -3268,53 +3318,54 @@ class Mr extends w {
3268
3318
  );
3269
3319
  }
3270
3320
  }
3271
- const Or = "incomingCall", _r = "declinedIncomingCall", br = "failedIncomingCall", yr = "terminatedIncomingCall", $t = "connecting", Dr = "connected", Pr = "disconnected", Lr = "newRTCSession", wr = "registered", Gr = "unregistered", kr = "registrationFailed", Fr = "newMessage", Ur = "sipEvent", Br = "availableSecondRemoteStream", $r = "notAvailableSecondRemoteStream", xr = "mustStopPresentation", Vr = "enterRoom", qr = "useLicense", Hr = "peerconnection:confirmed", Wr = "peerconnection:ontrack", Qr = "channels", Yr = "channels:notify", jr = "ended:fromserver", zr = "main-cam-control", Jr = "admin:stop-main-cam", Kr = "admin:start-main-cam", Xr = "admin:stop-mic", Zr = "admin:start-mic", ei = "admin:force-sync-media-state", ti = "participant:added-to-list-moderators", ni = "participant:removed-from-list-moderators", si = "participant:move-request-to-stream", ri = "participant:move-request-to-spectators", ii = "participant:move-request-to-participants", ai = "participation:accepting-word-request", oi = "participation:cancelling-word-request", ci = "webcast:started", li = "webcast:stopped", di = "account:changed", hi = "account:deleted", ui = "conference:participant-token-issued", gi = "ended", Ei = "sending", mi = "reinvite", Ti = "replaces", pi = "refer", Si = "progress", Ci = "accepted", Ri = "confirmed", Ni = "peerconnection", Ai = "failed", Ii = "muted", fi = "unmuted", vi = "newDTMF", Mi = "newInfo", Oi = "hold", _i = "unhold", bi = "update", yi = "sdp", Di = "icecandidate", Pi = "getusermediafailed", Li = "peerconnection:createofferfailed", wi = "peerconnection:createanswerfailed", Gi = "peerconnection:setlocaldescriptionfailed", ki = "peerconnection:setremotedescriptionfailed", Fi = "presentation:start", Ui = "presentation:started", Bi = "presentation:end", $i = "presentation:ended", xi = "presentation:failed", Vi = [
3321
+ const Mr = "incomingCall", Or = "declinedIncomingCall", _r = "failedIncomingCall", br = "terminatedIncomingCall", xt = "connecting", yr = "connected", Dr = "disconnected", Pr = "newRTCSession", Lr = "registered", wr = "unregistered", Gr = "registrationFailed", kr = "newMessage", Fr = "sipEvent", Ur = "availableSecondRemoteStream", Br = "notAvailableSecondRemoteStream", $r = "mustStopPresentation", xr = "enterRoom", qr = "useLicense", Vr = "peerconnection:confirmed", Hr = "peerconnection:ontrack", Wr = "channels", Qr = "channels:notify", Yr = "ended:fromserver", jr = "main-cam-control", zr = "admin:stop-main-cam", Jr = "admin:start-main-cam", Kr = "admin:stop-mic", Xr = "admin:start-mic", Zr = "admin:force-sync-media-state", ei = "participant:added-to-list-moderators", ti = "participant:removed-from-list-moderators", ni = "participant:move-request-to-stream", si = "participant:move-request-to-spectators", ri = "participant:move-request-to-participants", ii = "participation:accepting-word-request", ai = "participation:cancelling-word-request", oi = "webcast:started", ci = "webcast:stopped", li = "account:changed", di = "account:deleted", hi = "conference:participant-token-issued", ui = "ended", gi = "sending", Ei = "reinvite", mi = "replaces", Ti = "refer", pi = "progress", Si = "accepted", Ci = "confirmed", Ri = "peerconnection", Ni = "failed", Ai = "muted", Ii = "unmuted", fi = "newDTMF", vi = "newInfo", Mi = "hold", Oi = "unhold", _i = "update", bi = "sdp", yi = "icecandidate", Di = "getusermediafailed", Pi = "peerconnection:createofferfailed", Li = "peerconnection:createanswerfailed", wi = "peerconnection:setlocaldescriptionfailed", Gi = "peerconnection:setremotedescriptionfailed", ki = "presentation:start", Fi = "presentation:started", Ui = "presentation:end", Bi = "presentation:ended", $i = "presentation:failed", xi = [
3322
+ Mr,
3272
3323
  Or,
3273
- _r,
3274
- yr,
3275
3324
  br,
3325
+ _r,
3326
+ ii,
3276
3327
  ai,
3277
- oi,
3278
- si,
3279
- Yr,
3280
- ui,
3281
- di,
3328
+ ni,
3329
+ Qr,
3282
3330
  hi,
3283
- ci,
3284
3331
  li,
3285
- ti,
3286
- ni
3332
+ di,
3333
+ oi,
3334
+ ci,
3335
+ ei,
3336
+ ti
3287
3337
  ], qi = [
3288
- $t,
3338
+ xt,
3339
+ yr,
3289
3340
  Dr,
3290
3341
  Pr,
3291
3342
  Lr,
3292
3343
  wr,
3293
3344
  Gr,
3294
3345
  kr,
3295
- Fr,
3296
- Ur
3297
- ], Hi = [
3346
+ Fr
3347
+ ], Vi = [
3348
+ Ur,
3298
3349
  Br,
3299
3350
  $r,
3300
3351
  xr,
3301
- Vr,
3302
3352
  qr,
3353
+ Vr,
3303
3354
  Hr,
3304
3355
  Wr,
3305
- Qr,
3356
+ Yr,
3306
3357
  jr,
3358
+ Jr,
3307
3359
  zr,
3308
3360
  Kr,
3309
- Jr,
3310
3361
  Xr,
3311
3362
  Zr,
3312
- ei,
3313
- ri,
3314
- ii
3315
- ], Fe = [
3363
+ si,
3364
+ ri
3365
+ ], ke = [
3366
+ ui,
3367
+ xt,
3316
3368
  gi,
3317
- $t,
3318
3369
  Ei,
3319
3370
  mi,
3320
3371
  Ti,
@@ -3341,16 +3392,15 @@ const Or = "incomingCall", _r = "declinedIncomingCall", br = "failedIncomingCall
3341
3392
  Fi,
3342
3393
  Ui,
3343
3394
  Bi,
3344
- $i,
3345
- xi
3395
+ $i
3346
3396
  ];
3347
- [...qi, ...Vi];
3397
+ [...qi, ...xi];
3348
3398
  [
3349
- ...Fe,
3350
- ...Hi
3399
+ ...ke,
3400
+ ...Vi
3351
3401
  ];
3352
- const Wi = I("BaseSession.mock");
3353
- class Qi {
3402
+ const Hi = I("BaseSession.mock");
3403
+ class Wi {
3354
3404
  originator;
3355
3405
  connection;
3356
3406
  events;
@@ -3364,7 +3414,7 @@ class Qi {
3364
3414
  eventHandlers: n,
3365
3415
  remoteIdentity: s
3366
3416
  }) {
3367
- this.originator = e, this.events = new bn(Fe), this.initEvents(n), this.remote_identity = s;
3417
+ this.originator = e, this.events = new yn(ke), this.initEvents(n), this.remote_identity = s;
3368
3418
  }
3369
3419
  get contact() {
3370
3420
  throw new Error("Method not implemented.");
@@ -3460,7 +3510,7 @@ class Qi {
3460
3510
  return this.events.off(e, n), this;
3461
3511
  }
3462
3512
  removeAllListeners(e) {
3463
- return Wi("Method not implemented. Event:", e), this;
3513
+ return Hi("Method not implemented. Event:", e), this;
3464
3514
  }
3465
3515
  setMaxListeners(e) {
3466
3516
  throw new Error("Method not implemented.");
@@ -3495,7 +3545,7 @@ class Qi {
3495
3545
  });
3496
3546
  }
3497
3547
  // @ts-expect-error
3498
- on = (e, n) => (Fe.includes(e) && this.events.on(e, n), this);
3548
+ on = (e, n) => (ke.includes(e) && this.events.on(e, n), this);
3499
3549
  trigger(e, n) {
3500
3550
  this.events.trigger(e, n);
3501
3551
  }
@@ -3580,7 +3630,7 @@ class lt {
3580
3630
  stop() {
3581
3631
  }
3582
3632
  }
3583
- class Yi extends EventTarget {
3633
+ class Qi extends EventTarget {
3584
3634
  senders = [];
3585
3635
  receivers = [];
3586
3636
  canTrickleIceCandidates;
@@ -3674,7 +3724,7 @@ class Yi extends EventTarget {
3674
3724
  return n === void 0 ? r.mid = e.kind === "audio" ? "0" : "1" : r.mid = n, this.senders.push(s), this.dispatchTrackInternal(e), s;
3675
3725
  };
3676
3726
  dispatchTrack(e) {
3677
- this.dispatchTrackInternal(new Mn(e));
3727
+ this.dispatchTrackInternal(new On(e));
3678
3728
  }
3679
3729
  dispatchTrackInternal(e, ...n) {
3680
3730
  const s = new Event(
@@ -3688,13 +3738,13 @@ class Yi extends EventTarget {
3688
3738
  }), this.dispatchEvent(s);
3689
3739
  }
3690
3740
  }
3691
- function ji(t) {
3741
+ function Yi(t) {
3692
3742
  const e = t.match(/(purgatory)|[\d.]+/g);
3693
3743
  if (!e)
3694
3744
  throw new Error("wrong sip url");
3695
3745
  return e[0];
3696
3746
  }
3697
- var xt = /* @__PURE__ */ ((t) => (t.LOCAL = "local", t.REMOTE = "remote", t.SYSTEM = "system", t))(xt || {});
3747
+ var qt = /* @__PURE__ */ ((t) => (t.LOCAL = "local", t.REMOTE = "remote", t.SYSTEM = "system", t))(qt || {});
3698
3748
  const Vt = [
3699
3749
  "peerconnection",
3700
3750
  "connecting",
@@ -3726,7 +3776,7 @@ const Vt = [
3726
3776
  "peerconnection:createanswerfailed",
3727
3777
  "peerconnection:setlocaldescriptionfailed",
3728
3778
  "peerconnection:setremotedescriptionfailed"
3729
- ], zi = [
3779
+ ], ji = [
3730
3780
  "start-call",
3731
3781
  "end-call",
3732
3782
  "peerconnection:confirmed",
@@ -3738,11 +3788,11 @@ const Vt = [
3738
3788
  "recv-session-started",
3739
3789
  "recv-session-ended",
3740
3790
  "recv-quality-changed"
3741
- ], qt = [
3791
+ ], Ht = [
3742
3792
  ...Vt,
3743
- ...zi
3744
- ], Ji = () => new G(qt), dt = 400, Ki = "777", Xi = (t) => t.getVideoTracks().length > 0;
3745
- class H extends Qi {
3793
+ ...ji
3794
+ ], zi = () => new G(Ht), dt = 400, Ji = "777", Ki = (t) => t.getVideoTracks().length > 0;
3795
+ class H extends Wi {
3746
3796
  static presentationError;
3747
3797
  static startPresentationError;
3748
3798
  static countStartPresentationError = Number.POSITIVE_INFINITY;
@@ -3786,8 +3836,8 @@ class H extends Qi {
3786
3836
  constructor({
3787
3837
  eventHandlers: e,
3788
3838
  originator: n,
3789
- remoteIdentity: s = new In(
3790
- new fn("sip", "caller1", "test1.com", 5060),
3839
+ remoteIdentity: s = new fn(
3840
+ new vn("sip", "caller1", "test1.com", 5060),
3791
3841
  "Test Caller 1"
3792
3842
  ),
3793
3843
  delayStartPresentation: r = 0
@@ -3795,7 +3845,7 @@ class H extends Qi {
3795
3845
  super({ originator: n, eventHandlers: e, remoteIdentity: s }), this.delayStartPresentation = r;
3796
3846
  }
3797
3847
  static get C() {
3798
- return vn;
3848
+ return Mn;
3799
3849
  }
3800
3850
  static setPresentationError(e) {
3801
3851
  this.presentationError = e;
@@ -3831,25 +3881,25 @@ class H extends Qi {
3831
3881
  return e ? (this.createPeerconnection(e), !0) : !1;
3832
3882
  }
3833
3883
  createPeerconnection(e) {
3834
- const n = On();
3884
+ const n = _n();
3835
3885
  n.id = "mainaudio1";
3836
3886
  const s = [n];
3837
- if (Xi(e)) {
3838
- const i = _n();
3887
+ if (Ki(e)) {
3888
+ const i = bn();
3839
3889
  i.id = "mainvideo1", s.push(i);
3840
3890
  }
3841
- this.connection = new Yi(void 0, s), this.trigger("peerconnection", { peerconnection: this.connection }), this.addStream(e);
3891
+ this.connection = new Qi(void 0, s), this.trigger("peerconnection", { peerconnection: this.connection }), this.addStream(e);
3842
3892
  }
3843
3893
  connect(e, { mediaStream: n } = {}) {
3844
- const s = ji(e);
3894
+ const s = Yi(e);
3845
3895
  return this.initPeerconnection(n), this.timeoutConnect = setTimeout(() => {
3846
- e.includes(Ki) ? this.trigger("failed", {
3896
+ e.includes(Ji) ? this.trigger("failed", {
3847
3897
  originator: "remote",
3848
3898
  message: "IncomingResponse",
3849
3899
  cause: "Rejected"
3850
3900
  }) : (this.trigger("connecting"), this.timeoutNewInfo = setTimeout(() => {
3851
3901
  this.newInfo({
3852
- originator: xt.REMOTE,
3902
+ originator: qt.REMOTE,
3853
3903
  // @ts-expect-error
3854
3904
  request: {
3855
3905
  getHeader: (r) => r === "content-type" ? "application/vinteo.webrtc.roomname" : r === "x-webrtc-enter-room" ? s : r === "x-webrtc-participant-name" ? "Test Caller 1" : ""
@@ -3921,22 +3971,22 @@ class H extends Qi {
3921
3971
  clearTimeout(this.timeoutStartPresentation), clearTimeout(this.timeoutConnect), clearTimeout(this.timeoutNewInfo), clearTimeout(this.timeoutAccepted), clearTimeout(this.timeoutConfirmed);
3922
3972
  }
3923
3973
  }
3924
- const Zi = ["snapshot-changed"], ea = () => new G(Zi), ta = (t) => t.type === "participant", Ee = (t) => t.type === "spectator_synthetic", Y = (t) => t.type === "spectator", na = (t, e) => Y(t) && !Y(e), sa = (t, e) => Y(e), ra = (t, e) => {
3974
+ const Xi = ["snapshot-changed"], Zi = () => new G(Xi), ea = (t) => t.type === "participant", Ee = (t) => t.type === "spectator_synthetic", Y = (t) => t.type === "spectator", ta = (t, e) => Y(t) && !Y(e), na = (t, e) => Y(e), sa = (t, e) => {
3925
3975
  const n = Y(t) || Ee(t), s = Y(e) || Ee(e);
3926
3976
  return n && !s;
3927
- }, ia = (t, e) => {
3977
+ }, ra = (t, e) => {
3928
3978
  const n = Y(t) || Ee(t), s = Y(e) || Ee(e);
3929
3979
  return !n && s;
3930
- }, ye = {
3980
+ }, be = {
3931
3981
  type: "participant"
3932
- }, aa = {
3982
+ }, ia = {
3933
3983
  type: "spectator_synthetic"
3934
- }, oa = (t) => ({
3984
+ }, aa = (t) => ({
3935
3985
  type: "spectator",
3936
3986
  recvParams: t
3937
3987
  });
3938
- class ca {
3939
- role = ye;
3988
+ class oa {
3989
+ role = be;
3940
3990
  isAvailableSendingMedia = !0;
3941
3991
  onRoleChanged;
3942
3992
  listeners = /* @__PURE__ */ new Set();
@@ -3950,13 +4000,13 @@ class ca {
3950
4000
  return this.isAvailableSendingMedia;
3951
4001
  }
3952
4002
  setCallRoleParticipant() {
3953
- this.isAvailableSendingMedia = !0, this.changeRole(ye);
4003
+ this.isAvailableSendingMedia = !0, this.changeRole(be);
3954
4004
  }
3955
4005
  setCallRoleSpectatorSynthetic(e = !0) {
3956
- this.isAvailableSendingMedia = e, this.changeRole(aa);
4006
+ this.isAvailableSendingMedia = e, this.changeRole(ia);
3957
4007
  }
3958
4008
  setCallRoleSpectator(e, n = !0) {
3959
- this.isAvailableSendingMedia = n, this.changeRole(oa(e));
4009
+ this.isAvailableSendingMedia = n, this.changeRole(aa(e));
3960
4010
  }
3961
4011
  changeRole(e) {
3962
4012
  const n = this.role;
@@ -3967,10 +4017,10 @@ class ca {
3967
4017
  Y(e) && Y(n) && n.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
3968
4018
  }
3969
4019
  reset() {
3970
- this.role = ye, this.isAvailableSendingMedia = !0;
4020
+ this.role = be, this.isAvailableSendingMedia = !0;
3971
4021
  }
3972
4022
  hasParticipant() {
3973
- return ta(this.role);
4023
+ return ea(this.role);
3974
4024
  }
3975
4025
  hasSpectatorSynthetic() {
3976
4026
  return Ee(this.role);
@@ -3990,7 +4040,7 @@ class ca {
3990
4040
  });
3991
4041
  }
3992
4042
  }
3993
- const la = (t, e) => t.type !== e.type ? !1 : t.type !== "spectator" ? !0 : e.type === "spectator" && t.recvParams.audioId === e.recvParams.audioId, da = (t, e) => t.license === e.license && t.isDuplexSendingMediaMode === e.isDuplexSendingMediaMode && la(t.role, e.role) && t.derived.isAvailableSendingMedia === e.derived.isAvailableSendingMedia, ht = (t, e, n) => {
4043
+ const ca = (t, e) => t.type !== e.type ? !1 : t.type !== "spectator" ? !0 : e.type === "spectator" && t.recvParams.audioId === e.recvParams.audioId, la = (t, e) => t.license === e.license && t.isDuplexSendingMediaMode === e.isDuplexSendingMediaMode && ca(t.role, e.role) && t.derived.isAvailableSendingMedia === e.derived.isAvailableSendingMedia, ht = (t, e, n) => {
3994
4044
  const s = t.getRole(), r = s.type === "spectator" || s.type === "spectator_synthetic";
3995
4045
  return {
3996
4046
  license: n,
@@ -4002,16 +4052,16 @@ const la = (t, e) => t.type !== e.type ? !1 : t.type !== "spectator" ? !0 : e.ty
4002
4052
  isAvailableSendingMedia: t.getIsAvailableSendingMedia()
4003
4053
  }
4004
4054
  };
4005
- }, ut = Ye.VIDEO;
4006
- class ha extends w {
4007
- roleManager = new ca();
4055
+ }, ut = Qe.VIDEO;
4056
+ class da extends w {
4057
+ roleManager = new oa();
4008
4058
  license = ut;
4009
4059
  isDuplexSendingMediaMode = !1;
4010
4060
  currentSnapshot;
4011
4061
  subscriptions = [];
4012
4062
  dedupedTotal = 0;
4013
4063
  constructor() {
4014
- super(ea()), this.currentSnapshot = ht(
4064
+ super(Zi()), this.currentSnapshot = ht(
4015
4065
  this.roleManager,
4016
4066
  this.isDuplexSendingMediaMode,
4017
4067
  this.license
@@ -4078,7 +4128,7 @@ class ha extends w {
4078
4128
  }
4079
4129
  notifySubscribers = () => {
4080
4130
  const { previousSnapshot: e, currentSnapshot: n } = this.updateCurrentSnapshot();
4081
- if (da(e, n)) {
4131
+ if (la(e, n)) {
4082
4132
  this.dedupedTotal += 1;
4083
4133
  return;
4084
4134
  }
@@ -4105,10 +4155,10 @@ class ha extends w {
4105
4155
  this.isDuplexSendingMediaMode = e, this.notifySubscribers();
4106
4156
  };
4107
4157
  }
4108
- const ua = (t, e) => {
4158
+ const ha = (t, e) => {
4109
4159
  const n = e.major === t.major, s = e.minor === t.minor, r = e.major > t.major, i = n && e.minor > t.minor, a = n && s && e.patch > t.patch;
4110
4160
  return r || i || a;
4111
- }, ga = (t) => t.major !== void 0 && t.minor !== void 0 && t.patch !== void 0, Ea = (t) => (e) => ga(t) && ua(t, e), ma = (t = "") => {
4161
+ }, ua = (t) => t.major !== void 0 && t.minor !== void 0 && t.patch !== void 0, ga = (t) => (e) => ua(t) && ha(t, e), Ea = (t = "") => {
4112
4162
  const e = t.split(".");
4113
4163
  if (e.length <= 1)
4114
4164
  return {
@@ -4118,10 +4168,10 @@ const ua = (t, e) => {
4118
4168
  };
4119
4169
  const [n, s, r] = e.map((i) => Number.parseInt(i, 10));
4120
4170
  return { major: n, minor: s, patch: r };
4121
- }, Ta = () => globalThis.process?.versions?.electron !== void 0, Ht = () => {
4122
- const t = new wn(), { name: e, version: n } = t.getBrowser(), { name: s } = t.getOS(), { type: r } = t.getDevice(), i = Ta(), a = r === "mobile", o = ma(n);
4171
+ }, ma = () => globalThis.process?.versions?.electron !== void 0, Wt = () => {
4172
+ const t = new Ln(), { name: e, version: n } = t.getBrowser(), { name: s } = t.getOS(), { type: r } = t.getDevice(), i = ma(), a = r === "mobile", o = Ea(n);
4123
4173
  return {
4124
- hasGreaterThanBrowserVersion: Ea(o),
4174
+ hasGreaterThanBrowserVersion: ga(o),
4125
4175
  isMobileDevice: a,
4126
4176
  isChrome: e === "Chrome" || i,
4127
4177
  isYandexBrowser: e === "Yandex",
@@ -4129,15 +4179,15 @@ const ua = (t, e) => {
4129
4179
  isOpera: e === "Opera",
4130
4180
  isWindows: s === "Windows"
4131
4181
  };
4132
- }, pa = I("stringifyMessage"), Il = (t) => {
4182
+ }, Ta = I("stringifyMessage"), Al = (t) => {
4133
4183
  let e = "";
4134
4184
  try {
4135
4185
  e = JSON.stringify(t);
4136
4186
  } catch (n) {
4137
- pa("failed to stringify message", n);
4187
+ Ta("failed to stringify message", n);
4138
4188
  }
4139
4189
  return e;
4140
- }, Sa = /^p2p.+to.+$/i, Ue = (t) => t !== void 0 && t.length > 0 && Sa.test(t), Ca = "purgatory", fe = (t) => t === Ca, Ra = (t, e) => {
4190
+ }, pa = /^p2p.+to.+$/i, Fe = (t) => t !== void 0 && t.length > 0 && pa.test(t), Sa = "purgatory", fe = (t) => t === Sa, Ca = (t, e) => {
4141
4191
  t.getVideoTracks().forEach((s) => {
4142
4192
  "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
4143
4193
  });
@@ -4149,8 +4199,8 @@ const ua = (t, e) => {
4149
4199
  if (!t || e === "recvonly" && n === "recvonly")
4150
4200
  return;
4151
4201
  const r = n === "recvonly" ? [] : t.getAudioTracks(), i = e === "recvonly" ? [] : t.getVideoTracks(), a = [...r, ...i], o = new MediaStream(a);
4152
- return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && Ra(o, s), o;
4153
- }, Na = "api/v2/rtp2webrtc/offer", Aa = async ({
4202
+ return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && Ca(o, s), o;
4203
+ }, Ra = "api/v2/rtp2webrtc/offer", Na = async ({
4154
4204
  serverUrl: t,
4155
4205
  conferenceNumber: e,
4156
4206
  quality: n,
@@ -4159,7 +4209,7 @@ const ua = (t, e) => {
4159
4209
  token: i
4160
4210
  }) => {
4161
4211
  const a = new URL(
4162
- `https://${t.replace(/\/$/, "")}/${Na}/${encodeURIComponent(e)}`
4212
+ `https://${t.replace(/\/$/, "")}/${Ra}/${encodeURIComponent(e)}`
4163
4213
  );
4164
4214
  a.searchParams.set("quality", n), a.searchParams.set("audio", String(s));
4165
4215
  const o = {
@@ -4181,39 +4231,39 @@ const ua = (t, e) => {
4181
4231
  return g;
4182
4232
  }
4183
4233
  };
4184
- }, Ia = (t, e) => (t.degradationPreference = e.degradationPreference, t), fa = (t, e) => {
4234
+ }, Aa = (t, e) => (t.degradationPreference = e.degradationPreference, t), Ia = (t, e) => {
4185
4235
  t.encodings ??= [];
4186
4236
  for (let n = t.encodings.length; n < e; n += 1)
4187
4237
  t.encodings.push({});
4188
4238
  return t;
4189
- }, Wt = (t) => (e, n) => n !== void 0 && e !== n || n === void 0 && e !== t, va = Wt(), Ma = (t, e) => {
4190
- if (va(t, e))
4239
+ }, Qt = (t) => (e, n) => n !== void 0 && e !== n || n === void 0 && e !== t, fa = Qt(), va = (t, e) => {
4240
+ if (fa(t, e))
4191
4241
  return t;
4192
- }, Oa = (t, e, { isResetAllowed: n = !1 } = {}) => {
4193
- const s = t.maxBitrate, r = Ma(e, s);
4242
+ }, Ma = (t, e, { isResetAllowed: n = !1 } = {}) => {
4243
+ const s = t.maxBitrate, r = va(e, s);
4194
4244
  return (r !== void 0 || n) && (t.maxBitrate = r ?? e), t;
4195
- }, Qt = 1, _a = Wt(
4196
- Qt
4197
- ), ba = (t, e) => {
4198
- const n = t === void 0 ? void 0 : Math.max(t, Qt);
4199
- if (n !== void 0 && _a(
4245
+ }, Yt = 1, Oa = Qt(
4246
+ Yt
4247
+ ), _a = (t, e) => {
4248
+ const n = t === void 0 ? void 0 : Math.max(t, Yt);
4249
+ if (n !== void 0 && Oa(
4200
4250
  n,
4201
4251
  e
4202
4252
  ))
4203
4253
  return n;
4204
- }, ya = (t, e) => {
4205
- const n = t.scaleResolutionDownBy, s = ba(
4254
+ }, ba = (t, e) => {
4255
+ const n = t.scaleResolutionDownBy, s = _a(
4206
4256
  e,
4207
4257
  n
4208
4258
  );
4209
4259
  return s !== void 0 && (t.scaleResolutionDownBy = s), t;
4210
- }, Da = (t, e, { isResetAllowed: n } = {}) => {
4260
+ }, ya = (t, e, { isResetAllowed: n } = {}) => {
4211
4261
  const s = e.encodings?.length ?? 0;
4212
- return fa(t, s), t.encodings.forEach((r, i) => {
4262
+ return Ia(t, s), t.encodings.forEach((r, i) => {
4213
4263
  const a = (e?.encodings ?? [])[i], o = a?.maxBitrate, c = a?.scaleResolutionDownBy;
4214
- Oa(r, o, { isResetAllowed: n }), ya(r, c);
4264
+ Ma(r, o, { isResetAllowed: n }), ba(r, c);
4215
4265
  }), t;
4216
- }, Pa = (t, e) => {
4266
+ }, Da = (t, e) => {
4217
4267
  if (t.codecs?.length !== e.codecs?.length)
4218
4268
  return !0;
4219
4269
  for (let n = 0; n < (t.codecs?.length ?? 0); n++)
@@ -4230,15 +4280,15 @@ const ua = (t, e) => {
4230
4280
  if (JSON.stringify(t.encodings[n]) !== JSON.stringify(e.encodings[n]))
4231
4281
  return !0;
4232
4282
  return t.rtcp?.cname !== e.rtcp?.cname || t.rtcp?.reducedSize !== e.rtcp?.reducedSize || t.degradationPreference !== e.degradationPreference;
4233
- }, Be = async (t, e, { isResetAllowed: n } = {}) => {
4283
+ }, Ue = async (t, e, { isResetAllowed: n } = {}) => {
4234
4284
  const s = t.getParameters(), r = JSON.parse(
4235
4285
  JSON.stringify(s)
4236
4286
  );
4237
- Da(s, e, { isResetAllowed: n }), Ia(s, e);
4238
- const i = Pa(r, s);
4287
+ ya(s, e, { isResetAllowed: n }), Aa(s, e);
4288
+ const i = Da(r, s);
4239
4289
  return i && await t.setParameters(s), { parameters: s, isChanged: i };
4240
- }, Yt = async (t, e, n) => {
4241
- const { isChanged: s, parameters: r } = await Be(t, {
4290
+ }, jt = async (t, e, n) => {
4291
+ const { isChanged: s, parameters: r } = await Ue(t, {
4242
4292
  encodings: [
4243
4293
  {
4244
4294
  scaleResolutionDownBy: e.scaleResolutionDownBy,
@@ -4247,12 +4297,12 @@ const ua = (t, e) => {
4247
4297
  ]
4248
4298
  });
4249
4299
  return s && n && n(r), { isChanged: s, parameters: r };
4250
- }, La = (t, e) => t.find((n) => n.track !== null && e.getTracks().includes(n.track)), wa = async (t, e, n) => {
4251
- const s = La(t, e);
4300
+ }, Pa = (t, e) => t.find((n) => n.track !== null && e.getTracks().includes(n.track)), La = async (t, e, n) => {
4301
+ const s = Pa(t, e);
4252
4302
  if (s)
4253
- return Yt(s, { maxBitrate: n });
4254
- }, Ga = I("resolveOnStartMainCam"), fl = (t) => (n) => (Ga("onStartMainCam"), t.on("api:admin:start-main-cam", n)), ka = I("resolveOnStartMic"), vl = (t) => (n) => (ka("onStartMic"), t.on("api:admin:start-mic", n)), Fa = I("resolveOnStopMainCam"), Ml = (t) => (n) => (Fa("onStopMainCam"), t.on("api:admin:stop-main-cam", n)), Ua = I("resolveOnStopMic"), Ol = (t) => (n) => (Ua("onStopMic"), t.on("api:admin:stop-mic", n));
4255
- class Ba {
4303
+ return jt(s, { maxBitrate: n });
4304
+ }, wa = I("resolveOnStartMainCam"), Il = (t) => (n) => (wa("onStartMainCam"), t.on("api:admin:start-main-cam", n)), Ga = I("resolveOnStartMic"), fl = (t) => (n) => (Ga("onStartMic"), t.on("api:admin:start-mic", n)), ka = I("resolveOnStopMainCam"), vl = (t) => (n) => (ka("onStopMainCam"), t.on("api:admin:stop-main-cam", n)), Fa = I("resolveOnStopMic"), Ml = (t) => (n) => (Fa("onStopMic"), t.on("api:admin:stop-mic", n));
4305
+ class Ua {
4256
4306
  command = void 0;
4257
4307
  unsubscribe;
4258
4308
  options;
@@ -4270,12 +4320,12 @@ class Ba {
4270
4320
  }
4271
4321
  const M = "evaluate";
4272
4322
  var u = /* @__PURE__ */ ((t) => (t.IDLE = "call:idle", t.CONNECTING = "call:connecting", t.PRESENTATION_CALL = "call:presentationCall", t.ROOM_PENDING_AUTH = "call:roomPendingAuth", t.PURGATORY = "call:purgatory", t.P2P_ROOM = "call:p2pRoom", t.DIRECT_P2P_ROOM = "call:directP2pRoom", t.IN_ROOM = "call:inRoom", t.DISCONNECTING = "call:disconnecting", t))(u || {});
4273
- const jt = {
4323
+ const zt = {
4274
4324
  raw: {},
4275
4325
  state: {}
4276
- }, zt = (t) => "number" in t && x(t.number) && Pt(t.answer), Jt = (t) => "room" in t && x(t.room) && x(t.participantName) && ke(t.startedTimestamp), $a = (t) => "token" in t && x(t.token), Kt = (t) => $a(t) && "conferenceForToken" in t && x(t.conferenceForToken), he = (t) => zt(t) && Jt(t), Xt = (t) => !Kt(t) || !Jt(t) ? !1 : t.conferenceForToken === t.room, Zt = ({
4326
+ }, Jt = (t) => "number" in t && x(t.number) && Lt(t.answer), Kt = (t) => "room" in t && x(t.room) && x(t.participantName) && Ge(t.startedTimestamp), Ba = (t) => "token" in t && x(t.token), Xt = (t) => Ba(t) && "conferenceForToken" in t && x(t.conferenceForToken), he = (t) => Jt(t) && Kt(t), Zt = (t) => !Xt(t) || !Kt(t) ? !1 : t.conferenceForToken === t.room, en = ({
4277
4327
  isDirectPeerToPeer: t
4278
- }) => t === !0, De = (t) => "isDirectPeerToPeer" in t && Zt(t), xa = "x-vinteo-presentation-call: yes", Va = (t) => Vn(t) && t.some((e) => e.trim().toLowerCase() === xa), qa = (t) => "extraHeaders" in t && Va(t.extraHeaders) && "isConfirmed" in t && t.isConfirmed === !0, Se = (t) => he(t) && !fe(t.room) && Kt(t) && Xt(t), le = (t) => {
4328
+ }) => t === !0, ye = (t) => "isDirectPeerToPeer" in t && en(t), $a = "x-vinteo-presentation-call: yes", xa = (t) => xn(t) && t.some((e) => e.trim().toLowerCase() === $a), qa = (t) => "extraHeaders" in t && xa(t.extraHeaders) && "isConfirmed" in t && t.isConfirmed === !0, Se = (t) => he(t) && !fe(t.room) && Xt(t) && Zt(t), le = (t) => {
4279
4329
  const e = t;
4280
4330
  return {
4281
4331
  number: e.number,
@@ -4290,7 +4340,7 @@ const jt = {
4290
4340
  buildContext: () => ({})
4291
4341
  },
4292
4342
  [u.CONNECTING]: {
4293
- guard: zt,
4343
+ guard: Jt,
4294
4344
  buildContext: (t) => {
4295
4345
  const { number: e, answer: n, extraHeaders: s } = t;
4296
4346
  return { number: e, answer: n, extraHeaders: s };
@@ -4304,7 +4354,7 @@ const jt = {
4304
4354
  }
4305
4355
  },
4306
4356
  [u.ROOM_PENDING_AUTH]: {
4307
- guard: (t) => he(t) && !fe(t.room) && !Ue(t.room) && !De(t) && !Xt(t),
4357
+ guard: (t) => he(t) && !fe(t.room) && !Fe(t.room) && !ye(t) && !Zt(t),
4308
4358
  buildContext: le
4309
4359
  },
4310
4360
  /** Токен из TOKEN_ISSUED может уже лежать в context — это не переводит в IN_ROOM. */
@@ -4313,11 +4363,11 @@ const jt = {
4313
4363
  buildContext: le
4314
4364
  },
4315
4365
  [u.P2P_ROOM]: {
4316
- guard: (t) => he(t) && Ue(t.room) && !De(t) && !Se(t),
4366
+ guard: (t) => he(t) && Fe(t.room) && !ye(t) && !Se(t),
4317
4367
  buildContext: le
4318
4368
  },
4319
4369
  [u.DIRECT_P2P_ROOM]: {
4320
- guard: (t) => he(t) && De(t) && !Se(t),
4370
+ guard: (t) => he(t) && ye(t) && !Se(t),
4321
4371
  buildContext: (t) => ({ ...le(t), isDirectPeerToPeer: !0 })
4322
4372
  },
4323
4373
  /** IN_ROOM только если `conferenceForToken === room` (в т.ч. после enter-room с bearer, где conference задаётся как room). */
@@ -4332,15 +4382,15 @@ const jt = {
4332
4382
  guard: (t) => t.pendingDisconnect === !0,
4333
4383
  buildContext: () => ({})
4334
4384
  }
4335
- }, Ha = (t) => fe(t.room) || Ue(t.room) || Zt(t), Pe = () => ({}), Wa = () => ee({
4385
+ }, Va = (t) => fe(t.room) || Fe(t.room) || en(t), De = () => ({}), Ha = () => ee({
4336
4386
  types: {
4337
- context: jt,
4387
+ context: zt,
4338
4388
  events: {}
4339
4389
  },
4340
4390
  actions: {
4341
4391
  setConnecting: A(({ event: t, context: e }) => t.type !== "CALL.CONNECTING" ? e : {
4342
4392
  raw: {
4343
- ...Pe(),
4393
+ ...De(),
4344
4394
  number: t.number,
4345
4395
  answer: t.answer,
4346
4396
  extraHeaders: t.extraHeaders
@@ -4353,8 +4403,8 @@ const jt = {
4353
4403
  room: t.room,
4354
4404
  participantName: t.participantName
4355
4405
  };
4356
- x(t.token) ? (n.token = t.token, n.conferenceForToken = t.room) : Ha(t) && (n.token = void 0, n.conferenceForToken = void 0), Pt(t.isDirectPeerToPeer) && (n.isDirectPeerToPeer = t.isDirectPeerToPeer);
4357
- const r = e.raw.startedTimestamp, i = ke(r) ? r : Date.now();
4406
+ x(t.token) ? (n.token = t.token, n.conferenceForToken = t.room) : Va(t) && (n.token = void 0, n.conferenceForToken = void 0), Lt(t.isDirectPeerToPeer) && (n.isDirectPeerToPeer = t.isDirectPeerToPeer);
4407
+ const r = e.raw.startedTimestamp, i = Ge(r) ? r : Date.now();
4358
4408
  return {
4359
4409
  raw: {
4360
4410
  ...e.raw,
@@ -4374,7 +4424,7 @@ const jt = {
4374
4424
  setConfirmed: A(({ event: t, context: e }) => {
4375
4425
  if (t.type !== "CALL.PRESENTATION_CALL")
4376
4426
  return e;
4377
- const s = e.raw.startedTimestamp, r = ke(s) ? s : Date.now();
4427
+ const s = e.raw.startedTimestamp, r = Ge(s) ? s : Date.now();
4378
4428
  return {
4379
4429
  raw: {
4380
4430
  ...e.raw,
@@ -4383,18 +4433,18 @@ const jt = {
4383
4433
  }
4384
4434
  };
4385
4435
  }),
4386
- reset: A(() => ({ raw: Pe() })),
4436
+ reset: A(() => ({ raw: De() })),
4387
4437
  prepareDisconnect: A(() => ({
4388
4438
  raw: {
4389
- ...Pe(),
4439
+ ...De(),
4390
4440
  pendingDisconnect: !0
4391
4441
  }
4392
4442
  }))
4393
4443
  }
4394
- }), Qa = () => Wa().createMachine({
4444
+ }), Wa = () => Ha().createMachine({
4395
4445
  id: "call",
4396
4446
  initial: u.IDLE,
4397
- context: jt,
4447
+ context: zt,
4398
4448
  states: {
4399
4449
  [u.IDLE]: {
4400
4450
  entry: A(() => ({ state: L[u.IDLE].buildContext() })),
@@ -4598,11 +4648,11 @@ const jt = {
4598
4648
  }
4599
4649
  }
4600
4650
  });
4601
- function Ya(t) {
4651
+ function Qa(t) {
4602
4652
  return t !== M;
4603
4653
  }
4604
- const ja = I("CallStateMachine");
4605
- class za extends te {
4654
+ const Ya = I("CallManager: CallStateMachine");
4655
+ class ja extends te {
4606
4656
  constructor(e, n) {
4607
4657
  super(e), this.subscribeToEvents(n);
4608
4658
  }
@@ -4745,7 +4795,7 @@ class za extends te {
4745
4795
  (o !== a.token || c !== a.conferenceForToken) && (n = a, e(a));
4746
4796
  return;
4747
4797
  }
4748
- Ya(r.value) && (n = void 0);
4798
+ Qa(r.value) && (n = void 0);
4749
4799
  });
4750
4800
  return () => {
4751
4801
  s.unsubscribe();
@@ -4756,7 +4806,7 @@ class za extends te {
4756
4806
  }
4757
4807
  send(e) {
4758
4808
  if (!this.actor.getSnapshot().can(e)) {
4759
- ja(
4809
+ Ya(
4760
4810
  `[CallStateMachine] Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
4761
4811
  );
4762
4812
  return;
@@ -4812,16 +4862,16 @@ class za extends te {
4812
4862
  );
4813
4863
  }
4814
4864
  }
4815
- const Ja = (t) => new za(Qa(), t), Ka = (t) => [...t.keys()].map((e) => t.get(e)), Xa = (t, e) => Ka(t).find((n) => n?.type === e), en = async (t) => t.getStats().then((e) => Xa(e, "codec")?.mimeType);
4816
- class Za {
4865
+ const za = (t) => new ja(Wa(), t), Ja = (t) => [...t.keys()].map((e) => t.get(e)), Ka = (t, e) => Ja(t).find((n) => n?.type === e), tn = async (t) => t.getStats().then((e) => Ka(e, "codec")?.mimeType);
4866
+ class Xa {
4817
4867
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
4818
4868
  async getCodecFromSender(e) {
4819
- return await en(e) ?? "";
4869
+ return await tn(e) ?? "";
4820
4870
  }
4821
4871
  }
4822
- const eo = I("TaskQueue");
4823
- class to {
4824
- stackPromises = bt({
4872
+ const Za = I("TaskQueue");
4873
+ class eo {
4874
+ stackPromises = yt({
4825
4875
  noRunIsNotActual: !0
4826
4876
  });
4827
4877
  /**
@@ -4841,34 +4891,34 @@ class to {
4841
4891
  */
4842
4892
  async run() {
4843
4893
  return this.stackPromises().catch((e) => {
4844
- eo("TaskQueue: error", e);
4894
+ Za("TaskQueue: error", e);
4845
4895
  });
4846
4896
  }
4847
4897
  }
4848
- class no {
4898
+ class to {
4849
4899
  taskQueue;
4850
4900
  onSetParameters;
4851
4901
  constructor(e) {
4852
- this.onSetParameters = e, this.taskQueue = new to();
4902
+ this.onSetParameters = e, this.taskQueue = new eo();
4853
4903
  }
4854
4904
  async setEncodingsToSender(e, n) {
4855
- return this.taskQueue.add(async () => Yt(e, n, this.onSetParameters));
4905
+ return this.taskQueue.add(async () => jt(e, n, this.onSetParameters));
4856
4906
  }
4857
4907
  stop() {
4858
4908
  this.taskQueue.stop();
4859
4909
  }
4860
4910
  }
4861
- const $e = (t, e) => t !== void 0 && e !== void 0 && t.toLowerCase().includes(e.toLowerCase()), so = 1e6, Q = (t) => t * so, tn = Q(0.06), nn = Q(4), ro = (t) => t <= 64 ? tn : t <= 128 ? Q(0.12) : t <= 256 ? Q(0.25) : t <= 384 ? Q(0.32) : t <= 426 ? Q(0.38) : t <= 640 ? Q(0.5) : t <= 848 ? Q(0.7) : t <= 1280 ? Q(1) : t <= 1920 ? Q(2) : nn, io = "av1", ao = (t) => $e(t, io), oo = 0.6, je = (t, e) => ao(e) ? t * oo : t, sn = (t) => je(tn, t), rn = (t) => je(nn, t), gt = (t, e) => {
4862
- const n = ro(t);
4863
- return je(n, e);
4864
- }, Le = 1, co = ({
4911
+ const Be = (t, e) => t !== void 0 && e !== void 0 && t.toLowerCase().includes(e.toLowerCase()), no = 1e6, Q = (t) => t * no, nn = Q(0.06), sn = Q(4), so = (t) => t <= 64 ? nn : t <= 128 ? Q(0.12) : t <= 256 ? Q(0.25) : t <= 384 ? Q(0.32) : t <= 426 ? Q(0.38) : t <= 640 ? Q(0.5) : t <= 848 ? Q(0.7) : t <= 1280 ? Q(1) : t <= 1920 ? Q(2) : sn, ro = "av1", io = (t) => Be(t, ro), ao = 0.6, Ye = (t, e) => io(e) ? t * ao : t, rn = (t) => Ye(nn, t), an = (t) => Ye(sn, t), gt = (t, e) => {
4912
+ const n = so(t);
4913
+ return Ye(n, e);
4914
+ }, Pe = 1, oo = ({
4865
4915
  videoTrack: t,
4866
4916
  targetSize: e
4867
4917
  }) => {
4868
- const n = t.getSettings(), s = n.width, r = n.height, i = s === void 0 ? Le : s / e.width, a = r === void 0 ? Le : r / e.height;
4869
- return Math.max(i, a, Le);
4918
+ const n = t.getSettings(), s = n.width, r = n.height, i = s === void 0 ? Pe : s / e.width, a = r === void 0 ? Pe : r / e.height;
4919
+ return Math.max(i, a, Pe);
4870
4920
  };
4871
- class lo {
4921
+ class co {
4872
4922
  ignoreForCodec;
4873
4923
  senderFinder;
4874
4924
  codecProvider;
@@ -4901,7 +4951,7 @@ class lo {
4901
4951
  if (!r?.track)
4902
4952
  return { ...this.resultNoChanged, sender: r };
4903
4953
  const i = await this.codecProvider.getCodecFromSender(r);
4904
- if ($e(i, this.ignoreForCodec))
4954
+ if (Be(i, this.ignoreForCodec))
4905
4955
  return { ...this.resultNoChanged, sender: r };
4906
4956
  const { mainCam: a, resolutionMainCam: o } = n ?? {};
4907
4957
  return this.processSender(
@@ -4923,7 +4973,7 @@ class lo {
4923
4973
  if (!s?.track)
4924
4974
  return { ...this.resultNoChanged, sender: s };
4925
4975
  const r = await this.codecProvider.getCodecFromSender(s);
4926
- if ($e(r, this.ignoreForCodec))
4976
+ if (Be(r, this.ignoreForCodec))
4927
4977
  return { ...this.resultNoChanged, sender: s };
4928
4978
  const i = {
4929
4979
  sender: s,
@@ -4962,7 +5012,7 @@ class lo {
4962
5012
  async downgradeResolutionSender(e) {
4963
5013
  const { sender: n, codec: s } = e, r = {
4964
5014
  scaleResolutionDownBy: 200,
4965
- maxBitrate: sn(s)
5015
+ maxBitrate: rn(s)
4966
5016
  };
4967
5017
  return this.parametersSetter.setEncodingsToSender(n, r);
4968
5018
  }
@@ -4972,7 +5022,7 @@ class lo {
4972
5022
  * @returns Promise с результатом
4973
5023
  */
4974
5024
  async setBitrateByTrackResolution(e) {
4975
- const { sender: n, videoTrack: s, codec: r } = e, a = s.getSettings().width, o = a === void 0 ? rn(r) : gt(a, r);
5025
+ const { sender: n, videoTrack: s, codec: r } = e, a = s.getSettings().width, o = a === void 0 ? an(r) : gt(a, r);
4976
5026
  return this.parametersSetter.setEncodingsToSender(n, {
4977
5027
  scaleResolutionDownBy: 1,
4978
5028
  maxBitrate: o
@@ -4988,7 +5038,7 @@ class lo {
4988
5038
  const [s, r] = e.split("x"), { sender: i, videoTrack: a, codec: o } = n, c = {
4989
5039
  width: Number(s),
4990
5040
  height: Number(r)
4991
- }, g = co({
5041
+ }, g = oo({
4992
5042
  videoTrack: a,
4993
5043
  targetSize: c
4994
5044
  }), C = gt(c.width, o), f = {
@@ -4998,14 +5048,14 @@ class lo {
4998
5048
  return this.parametersSetter.setEncodingsToSender(i, f);
4999
5049
  }
5000
5050
  }
5001
- const ho = (t) => t.find((e) => e.track?.kind === "video");
5002
- class uo {
5051
+ const lo = (t) => t.find((e) => e.track?.kind === "video");
5052
+ class ho {
5003
5053
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
5004
5054
  findVideoSender(e) {
5005
- return ho(e);
5055
+ return lo(e);
5006
5056
  }
5007
5057
  }
5008
- class go {
5058
+ class uo {
5009
5059
  currentSender;
5010
5060
  originalReplaceTrack;
5011
5061
  lastWidth;
@@ -5018,7 +5068,7 @@ class go {
5018
5068
  pollIntervalMs: e = 1e3,
5019
5069
  maxPollIntervalMs: n
5020
5070
  }) {
5021
- this.pollIntervalMs = e, this.maxPollIntervalMs = n ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new _t();
5071
+ this.pollIntervalMs = e, this.maxPollIntervalMs = n ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new bt();
5022
5072
  }
5023
5073
  /**
5024
5074
  * Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
@@ -5069,7 +5119,7 @@ class go {
5069
5119
  this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
5070
5120
  }
5071
5121
  }
5072
- class Eo {
5122
+ class go {
5073
5123
  apiManager;
5074
5124
  currentHandler;
5075
5125
  constructor(e) {
@@ -5089,8 +5139,8 @@ class Eo {
5089
5139
  this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
5090
5140
  }
5091
5141
  }
5092
- const we = I("VideoSendingBalancer");
5093
- class mo {
5142
+ const Le = I("VideoSendingBalancer");
5143
+ class Eo {
5094
5144
  eventHandler;
5095
5145
  senderBalancer;
5096
5146
  parametersSetterWithQueue;
@@ -5102,16 +5152,16 @@ class mo {
5102
5152
  onSetParameters: r,
5103
5153
  pollIntervalMs: i
5104
5154
  } = {}) {
5105
- this.getConnection = n, this.eventHandler = new Eo(e), this.parametersSetterWithQueue = new no(r), this.senderBalancer = new lo(
5155
+ this.getConnection = n, this.eventHandler = new go(e), this.parametersSetterWithQueue = new to(r), this.senderBalancer = new co(
5106
5156
  {
5107
- senderFinder: new uo(),
5108
- codecProvider: new Za(),
5157
+ senderFinder: new ho(),
5158
+ codecProvider: new Xa(),
5109
5159
  parametersSetter: this.parametersSetterWithQueue
5110
5160
  },
5111
5161
  {
5112
5162
  ignoreForCodec: s
5113
5163
  }
5114
- ), this.trackMonitor = new go({ pollIntervalMs: i });
5164
+ ), this.trackMonitor = new uo({ pollIntervalMs: i });
5115
5165
  }
5116
5166
  /**
5117
5167
  * Подписывается на события управления главной камерой
@@ -5132,7 +5182,7 @@ class mo {
5132
5182
  this.clearState();
5133
5183
  const e = this.getConnection();
5134
5184
  e ? this.senderBalancer.reset(e).catch((n) => {
5135
- we("reset sender encodings: error", n);
5185
+ Le("reset sender encodings: error", n);
5136
5186
  }).finally(() => {
5137
5187
  this.parametersSetterWithQueue.stop();
5138
5188
  }) : this.parametersSetterWithQueue.stop();
@@ -5148,7 +5198,7 @@ class mo {
5148
5198
  const n = await this.senderBalancer.balance(e, this.serverHeaders);
5149
5199
  return this.trackMonitor.subscribe(n.sender, () => {
5150
5200
  this.balance().catch((s) => {
5151
- we("balance on track change: error", s);
5201
+ Le("balance on track change: error", s);
5152
5202
  });
5153
5203
  }), n;
5154
5204
  }
@@ -5161,12 +5211,12 @@ class mo {
5161
5211
  */
5162
5212
  handleMainCamControl = (e) => {
5163
5213
  this.serverHeaders = e, this.balance().catch((n) => {
5164
- we("handleMainCamControl: error", n);
5214
+ Le("handleMainCamControl: error", n);
5165
5215
  });
5166
5216
  };
5167
5217
  }
5168
- const To = 6e3, po = 52e4, Ce = (t, e) => t.getSenders().filter((n) => n.track?.kind === e), So = (t, e) => t === "audio" ? To : sn(e), Co = (t) => t.track !== null;
5169
- class Ro {
5218
+ const mo = 6e3, To = 52e4, Ce = (t, e) => t.getSenders().filter((n) => n.track?.kind === e), po = (t, e) => t === "audio" ? mo : rn(e), So = (t) => t.track !== null;
5219
+ class Co {
5170
5220
  previousBitrates = /* @__PURE__ */ new Map();
5171
5221
  /**
5172
5222
  * Устанавливает минимальный битрейт для указанных типов потоков
@@ -5178,17 +5228,17 @@ class Ro {
5178
5228
  if (!e)
5179
5229
  return;
5180
5230
  (n === "audio" || n === "all") && s.push(...Ce(e, "audio")), (n === "video" || n === "all") && s.push(...Ce(e, "video"));
5181
- const r = s.filter(Co).map(async (i) => {
5231
+ const r = s.filter(So).map(async (i) => {
5182
5232
  const a = i.getParameters();
5183
5233
  this.saveCurrentBitrate(i, a);
5184
5234
  const o = {
5185
5235
  ...a,
5186
5236
  encodings: a.encodings.map((c) => ({
5187
5237
  ...c,
5188
- maxBitrate: So(i.track.kind)
5238
+ maxBitrate: po(i.track.kind)
5189
5239
  }))
5190
5240
  };
5191
- await Be(i, o);
5241
+ await Ue(i, o);
5192
5242
  });
5193
5243
  await Promise.all(r);
5194
5244
  }
@@ -5205,10 +5255,10 @@ class Ro {
5205
5255
  const r = s.map(async (i) => {
5206
5256
  const a = this.getSavedBitrate(i);
5207
5257
  if (a) {
5208
- const o = i.getParameters(), c = i.track?.kind === "video", g = c ? await en(i) : void 0, C = {
5258
+ const o = i.getParameters(), c = i.track?.kind === "video", g = c ? await tn(i) : void 0, C = {
5209
5259
  ...o,
5210
5260
  encodings: a.map((f) => {
5211
- const y = c ? rn(g) : po;
5261
+ const y = c ? an(g) : To;
5212
5262
  return {
5213
5263
  ...f,
5214
5264
  // В Safari и некоторых браузерах encodings изначально не содержат maxBitrate.
@@ -5220,7 +5270,7 @@ class Ro {
5220
5270
  };
5221
5271
  })
5222
5272
  };
5223
- await Be(i, C, { isResetAllowed: !0 }), this.clearSavedBitrate(i);
5273
+ await Ue(i, C, { isResetAllowed: !0 }), this.clearSavedBitrate(i);
5224
5274
  }
5225
5275
  });
5226
5276
  await Promise.all(r);
@@ -5263,15 +5313,15 @@ class Ro {
5263
5313
  this.previousBitrates.set(e, s);
5264
5314
  }
5265
5315
  }
5266
- var an = /* @__PURE__ */ ((t) => (t.BYE = "Terminated", t.WEBRTC_ERROR = "WebRTC Error", t.CANCELED = "Canceled", t.REQUEST_TIMEOUT = "Request Timeout", t.REJECTED = "Rejected", t.REDIRECTED = "Redirected", t.UNAVAILABLE = "Unavailable", t.NOT_FOUND = "Not Found", t.ADDRESS_INCOMPLETE = "Address Incomplete", t.INCOMPATIBLE_SDP = "Incompatible SDP", t.BAD_MEDIA_DESCRIPTION = "Bad Media Description", t))(an || {});
5267
- const Et = I("MCUSession");
5268
- class No {
5316
+ var on = /* @__PURE__ */ ((t) => (t.BYE = "Terminated", t.WEBRTC_ERROR = "WebRTC Error", t.CANCELED = "Canceled", t.REQUEST_TIMEOUT = "Request Timeout", t.REJECTED = "Rejected", t.REDIRECTED = "Redirected", t.UNAVAILABLE = "Unavailable", t.NOT_FOUND = "Not Found", t.ADDRESS_INCOMPLETE = "Address Incomplete", t.INCOMPATIBLE_SDP = "Incompatible SDP", t.BAD_MEDIA_DESCRIPTION = "Bad Media Description", t))(on || {});
5317
+ const Et = I("CallManager: MCUSession");
5318
+ class Ro {
5269
5319
  events;
5270
5320
  rtcSession;
5271
5321
  disposers = /* @__PURE__ */ new Set();
5272
5322
  pcConfig;
5273
5323
  // Менеджер состояния битрейта
5274
- bitrateStateManager = new Ro();
5324
+ bitrateStateManager = new Co();
5275
5325
  constructor(e) {
5276
5326
  this.events = e, e.on("failed", this.handleEnded), e.on("ended", this.handleEnded);
5277
5327
  }
@@ -5302,10 +5352,10 @@ class No {
5302
5352
  offerToReceiveVideo: f = !0,
5303
5353
  degradationPreference: y,
5304
5354
  sendEncodings: _,
5305
- onAddedTransceiver: V
5306
- }) => new Promise((B, K) => {
5355
+ onAddedTransceiver: q
5356
+ }) => new Promise((B, X) => {
5307
5357
  this.handleCall().then(B).catch((ne) => {
5308
- K(ne);
5358
+ X(ne);
5309
5359
  }), this.pcConfig = { iceServers: a }, this.rtcSession = e.call(n(s), {
5310
5360
  mediaStream: Re(r, {
5311
5361
  directionVideo: o,
@@ -5328,14 +5378,14 @@ class No {
5328
5378
  directionAudio: c,
5329
5379
  degradationPreference: y,
5330
5380
  sendEncodings: _,
5331
- onAddedTransceiver: V
5381
+ onAddedTransceiver: q
5332
5382
  });
5333
5383
  });
5334
5384
  async endCall() {
5335
5385
  const { rtcSession: e } = this;
5336
5386
  if (e && !e.isEnded())
5337
5387
  return e.terminateAsync({
5338
- cause: an.CANCELED
5388
+ cause: on.CANCELED
5339
5389
  });
5340
5390
  }
5341
5391
  answerToIncomingCall = async (e, {
@@ -5350,10 +5400,10 @@ class No {
5350
5400
  degradationPreference: C,
5351
5401
  sendEncodings: f,
5352
5402
  onAddedTransceiver: y
5353
- }) => new Promise((_, V) => {
5403
+ }) => new Promise((_, q) => {
5354
5404
  try {
5355
5405
  this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(_).catch((B) => {
5356
- V(B);
5406
+ q(B);
5357
5407
  }), this.pcConfig = { iceServers: r }, e.answer({
5358
5408
  pcConfig: {
5359
5409
  iceServers: r
@@ -5375,7 +5425,7 @@ class No {
5375
5425
  onAddedTransceiver: y
5376
5426
  });
5377
5427
  } catch (B) {
5378
- V(B);
5428
+ q(B);
5379
5429
  }
5380
5430
  });
5381
5431
  async replaceMediaStream(e, n) {
@@ -5456,8 +5506,8 @@ class No {
5456
5506
  n === "remote" && this.events.trigger("ended:fromserver", e);
5457
5507
  };
5458
5508
  }
5459
- const xe = (t) => t === "auto" ? "high" : t, Ao = 10, Io = 500, fo = 5e3;
5460
- class vo {
5509
+ const $e = (t) => t === "auto" ? "high" : t, No = 10, Ao = 500, Io = 5e3;
5510
+ class fo {
5461
5511
  /**
5462
5512
  * Текущая операция отправки offer с повторными попытками при ошибках.
5463
5513
  * Может быть отменена при новом renegotiate для предотвращения конфликтов.
@@ -5478,7 +5528,7 @@ class vo {
5478
5528
  this.config = {
5479
5529
  ...e,
5480
5530
  quality: s,
5481
- effectiveQuality: xe(s)
5531
+ effectiveQuality: $e(s)
5482
5532
  }, this.tools = n, this.connection = new RTCPeerConnection(e.pcConfig), this.addTransceivers();
5483
5533
  }
5484
5534
  get settings() {
@@ -5507,7 +5557,7 @@ class vo {
5507
5557
  async setQuality(e) {
5508
5558
  if (!this.lastCallParams)
5509
5559
  return !1;
5510
- const n = this.config.effectiveQuality, s = this.config.quality, r = xe(e);
5560
+ const n = this.config.effectiveQuality, s = this.config.quality, r = $e(e);
5511
5561
  return e === s && r === n ? !1 : (this.config.quality = e, this.config.effectiveQuality = r, r !== n && await this.renegotiate(this.lastCallParams), !0);
5512
5562
  }
5513
5563
  async applyQuality(e) {
@@ -5583,11 +5633,11 @@ class vo {
5583
5633
  },
5584
5634
  s
5585
5635
  ), i = (o) => !(o instanceof Error);
5586
- this.cancelableSendOfferWithRepeatedCalls = He({
5636
+ this.cancelableSendOfferWithRepeatedCalls = Ve({
5587
5637
  targetFunction: r,
5588
5638
  isComplete: i,
5589
- callLimit: Ao,
5590
- delay: Io,
5639
+ callLimit: No,
5640
+ delay: Ao,
5591
5641
  isRejectAsValid: !0,
5592
5642
  isCheckBeforeCall: !1
5593
5643
  });
@@ -5681,7 +5731,7 @@ class vo {
5681
5731
  c(
5682
5732
  new Error("Timed out waiting for stable signaling state and ready connection state")
5683
5733
  );
5684
- }, fo), this.connection.addEventListener("signalingstatechange", g), this.connection.addEventListener("connectionstatechange", g), g();
5734
+ }, Io), this.connection.addEventListener("signalingstatechange", g), this.connection.addEventListener("connectionstatechange", g), g();
5685
5735
  });
5686
5736
  }
5687
5737
  async waitForTracks() {
@@ -5714,14 +5764,14 @@ class vo {
5714
5764
  this.cancelableSendOfferWithRepeatedCalls?.cancel();
5715
5765
  }
5716
5766
  }
5717
- const on = (t) => t.getSettings(), Mo = (t, e) => {
5718
- const n = on(t);
5767
+ const cn = (t) => t.getSettings(), vo = (t, e) => {
5768
+ const n = cn(t);
5719
5769
  let s = e;
5720
5770
  s ??= t.label;
5721
5771
  let r = n?.msid;
5722
5772
  return r ??= s, r ??= t.id, r;
5723
- }, Oo = (t, e) => {
5724
- const n = on(t);
5773
+ }, Mo = (t, e) => {
5774
+ const n = cn(t);
5725
5775
  let s = e;
5726
5776
  return s ??= n?.msid, s ??= t.label, (s && s.length > 0 ? s : void 0) ?? t.id;
5727
5777
  };
@@ -5742,7 +5792,7 @@ class mt {
5742
5792
  onRemoved: n,
5743
5793
  streamHint: s
5744
5794
  } = {}) {
5745
- const r = Oo(e, s), i = Mo(e, s);
5795
+ const r = Mo(e, s), i = vo(e, s);
5746
5796
  if (this.trackToGroup.has(e.id))
5747
5797
  return { isAddedTrack: !1, isAddedStream: !1 };
5748
5798
  const a = this.getParticipantGroups(r), o = a.get(i), c = !o;
@@ -5810,13 +5860,13 @@ class mt {
5810
5860
  return this.participantGroups.set(e, s), s;
5811
5861
  }
5812
5862
  }
5813
- const _o = (t, e) => {
5863
+ const Oo = (t, e) => {
5814
5864
  if (!t || !e)
5815
5865
  return t === e;
5816
5866
  const n = t.mainStream?.id, s = e.mainStream?.id, r = t.contentedStream?.id, i = e.contentedStream?.id;
5817
5867
  return n === s && r === i;
5818
5868
  };
5819
- class bo {
5869
+ class _o {
5820
5870
  lastEmittedStreams;
5821
5871
  /**
5822
5872
  * Проверяет, изменились ли streams с последнего сохраненного состояния
@@ -5824,7 +5874,7 @@ class bo {
5824
5874
  * @returns true, если streams изменились
5825
5875
  */
5826
5876
  hasChanged(e) {
5827
- return !_o(this.lastEmittedStreams, e);
5877
+ return !Oo(this.lastEmittedStreams, e);
5828
5878
  }
5829
5879
  /**
5830
5880
  * Сохраняет текущие streams как последнее эмитнутое состояние
@@ -5847,8 +5897,8 @@ class bo {
5847
5897
  this.lastEmittedStreams = void 0;
5848
5898
  }
5849
5899
  }
5850
- const yo = "default", Do = "dual", Po = "content_", Lo = (t) => `${Po}${t.toLowerCase()}`, wo = (t) => [...t.getTracks()].some((e) => e.label.includes(Do));
5851
- class Go {
5900
+ const bo = "default", yo = "dual", Do = "content_", Po = (t) => `${Do}${t.toLowerCase()}`, Lo = (t) => [...t.getTracks()].some((e) => e.label.includes(yo));
5901
+ class wo {
5852
5902
  mainRemoteStreamsManager;
5853
5903
  recvRemoteStreamsManager;
5854
5904
  constructor(e, n) {
@@ -5865,7 +5915,7 @@ class Go {
5865
5915
  }) {
5866
5916
  const n = this.mainRemoteStreamsManager;
5867
5917
  return { manager: n, getRemoteStreams: () => {
5868
- const r = n.getStreams(), i = r.find((o) => !wo(o)), a = e.isAvailable ? r.find((o) => o !== i) : void 0;
5918
+ const r = n.getStreams(), i = r.find((o) => !Lo(o)), a = e.isAvailable ? r.find((o) => o !== i) : void 0;
5869
5919
  return { mainStream: i, contentedStream: a };
5870
5920
  } };
5871
5921
  }
@@ -5874,7 +5924,7 @@ class Go {
5874
5924
  }) {
5875
5925
  const n = this.recvRemoteStreamsManager;
5876
5926
  return { manager: n, getRemoteStreams: () => {
5877
- const i = n.getStreams(yo)[0], a = this.getRecvRemoteContentedStream({ stateInfo: e });
5927
+ const i = n.getStreams(bo)[0], a = this.getRecvRemoteContentedStream({ stateInfo: e });
5878
5928
  return { mainStream: i, contentedStream: a };
5879
5929
  } };
5880
5930
  }
@@ -5883,15 +5933,15 @@ class Go {
5883
5933
  }) {
5884
5934
  if (!e.isAvailable || e.codec === void 0)
5885
5935
  return;
5886
- const n = Lo(e.codec);
5936
+ const n = Po(e.codec);
5887
5937
  return this.recvRemoteStreamsManager.getStreams(n)[0];
5888
5938
  }
5889
5939
  }
5890
- const ko = "udp", Fo = (t) => t.transport?.iceTransport ? t.transport.iceTransport.getLocalCandidates() : [], Uo = (t) => t.getReceivers().flatMap(Fo), Bo = (t) => {
5891
- const s = Uo(t).filter(({ protocol: r, port: i }) => i !== null && ko === r).map(({ port: r }) => r);
5940
+ const Go = "udp", ko = (t) => t.transport?.iceTransport ? t.transport.iceTransport.getLocalCandidates() : [], Fo = (t) => t.getReceivers().flatMap(ko), Uo = (t) => {
5941
+ const s = Fo(t).filter(({ protocol: r, port: i }) => i !== null && Go === r).map(({ port: r }) => r);
5892
5942
  return [...new Set(s)];
5893
5943
  }, Tt = (t) => t.streams[0]?.id;
5894
- class $o extends w {
5944
+ class Bo extends w {
5895
5945
  stateMachine;
5896
5946
  sessionState;
5897
5947
  isPendingCall = !1;
@@ -5912,12 +5962,12 @@ class $o extends w {
5912
5962
  disposeRecvSessionTrackListener;
5913
5963
  disposeInRoomCredentialsListener;
5914
5964
  deferredStartRecvSessionRunner;
5915
- streamsChangeTracker = new bo();
5965
+ streamsChangeTracker = new _o();
5916
5966
  constructor({ contentedStreamManager: e }, n, { callSessionState: s }) {
5917
- super(Ji()), this.contentedStreamManager = e, this.tools = n, this.mcuSession = new No(this.events), this.stateMachine = Ja(this.events), this.sessionState = s, this.sessionState.subscribeRoleChanges(this.onRoleChanged), this.streamsManagerProvider = new Go(
5967
+ super(zi()), this.contentedStreamManager = e, this.tools = n, this.mcuSession = new Ro(this.events), this.stateMachine = za(this.events), this.sessionState = s, this.sessionState.subscribeRoleChanges(this.onRoleChanged), this.streamsManagerProvider = new wo(
5918
5968
  this.mainRemoteStreamsManager,
5919
5969
  this.recvRemoteStreamsManager
5920
- ), this.deferredStartRecvSessionRunner = new Ba({
5970
+ ), this.deferredStartRecvSessionRunner = new Ua({
5921
5971
  subscribe: (r) => this.stateMachine.onStateChange(r),
5922
5972
  isReady: (r) => r === u.IN_ROOM,
5923
5973
  isCancelled: (r) => r === u.IDLE,
@@ -5953,7 +6003,7 @@ class $o extends w {
5953
6003
  }
5954
6004
  get localPorts() {
5955
6005
  const e = this.getActivePeerConnection();
5956
- return e ? Bo(e) : [];
6006
+ return e ? Uo(e) : [];
5957
6007
  }
5958
6008
  // For testing purposes
5959
6009
  getStreamsManagerProvider() {
@@ -6035,7 +6085,7 @@ class $o extends w {
6035
6085
  const { recvSession: n } = this;
6036
6086
  if (!this.hasSpectator() || !n)
6037
6087
  return !1;
6038
- const s = n.getQuality(), r = n.getEffectiveQuality(), i = n.getAudioChannel(), a = xe(e);
6088
+ const s = n.getQuality(), r = n.getEffectiveQuality(), i = n.getAudioChannel(), a = $e(e);
6039
6089
  if (e === s && a === r)
6040
6090
  return !1;
6041
6091
  if (a === r)
@@ -6177,7 +6227,7 @@ class $o extends w {
6177
6227
  audioChannel: e,
6178
6228
  quality: n,
6179
6229
  pcConfig: this.mcuSession.getPcConfig()
6180
- }, a = new vo(i, { sendOffer: this.tools.sendOffer });
6230
+ }, a = new fo(i, { sendOffer: this.tools.sendOffer });
6181
6231
  return this.recvSession = a, this.recvRemoteStreamsManager.reset(), this.attachRecvSessionTracks(a), a.call({
6182
6232
  conferenceNumber: r.conferenceForToken,
6183
6233
  token: r.token
@@ -6202,14 +6252,14 @@ class $o extends w {
6202
6252
  previous: e,
6203
6253
  next: n
6204
6254
  }) => {
6205
- if (na(e, n) && (this.stopRecvSession(), this.deferredStartRecvSessionRunner.cancel(), this.emitEventChangedRemoteStreamsConnected()), sa(e, n)) {
6255
+ if (ta(e, n) && (this.stopRecvSession(), this.deferredStartRecvSessionRunner.cancel(), this.emitEventChangedRemoteStreamsConnected()), na(e, n)) {
6206
6256
  const s = n.recvParams;
6207
6257
  this.stateMachine.getInRoomCredentials() === void 0 ? this.deferredStartRecvSessionRunner.set({
6208
6258
  audioId: s.audioId
6209
6259
  }) : this.startRecvSession({ audioChannel: s.audioId }).catch(() => {
6210
6260
  });
6211
6261
  }
6212
- ra(e, n) && this.mcuSession.restoreBitrateForSenders(), ia(e, n) && this.mcuSession.setMinBitrateForSenders();
6262
+ sa(e, n) && this.mcuSession.restoreBitrateForSenders(), ra(e, n) && this.mcuSession.setMinBitrateForSenders();
6213
6263
  };
6214
6264
  subscribeContentedStreamEvents() {
6215
6265
  this.contentedStreamManager.on("available", this.emitEventChangedRemoteStreamsConnected), this.contentedStreamManager.on("not-available", this.emitEventChangedRemoteStreamsConnected);
@@ -6225,19 +6275,19 @@ class $o extends w {
6225
6275
  return this.mcuSession.renegotiate();
6226
6276
  }
6227
6277
  }
6228
- const cn = [
6278
+ const ln = [
6229
6279
  "presentation:start",
6230
6280
  "presentation:started",
6231
6281
  "presentation:end",
6232
6282
  "presentation:ended",
6233
6283
  "presentation:failed"
6234
- ], xo = () => new G(cn);
6284
+ ], $o = () => new G(ln);
6235
6285
  var h = /* @__PURE__ */ ((t) => (t.IDLE = "presentation:idle", t.STARTING = "presentation:starting", t.ACTIVE = "presentation:active", t.STOPPING = "presentation:stopping", t.FAILED = "presentation:failed", t))(h || {}), p = /* @__PURE__ */ ((t) => (t.LOG_TRANSITION = "logTransition", t.LOG_STATE_CHANGE = "logStateChange", t.SET_ERROR = "setError", t.CLEAR_ERROR = "clearError", t))(p || {}), T = /* @__PURE__ */ ((t) => (t.SCREEN_STARTING = "SCREEN.STARTING", t.SCREEN_STARTED = "SCREEN.STARTED", t.SCREEN_ENDING = "SCREEN.ENDING", t.SCREEN_ENDED = "SCREEN.ENDED", t.SCREEN_FAILED = "SCREEN.FAILED", t.CALL_ENDED = "CALL.ENDED", t.CALL_FAILED = "CALL.FAILED", t.PRESENTATION_RESET = "PRESENTATION.RESET", t))(T || {});
6236
- const ln = {
6286
+ const dn = {
6237
6287
  lastError: void 0
6238
- }, pt = I("PresentationStateMachine"), Vo = (t) => t instanceof Error ? t : new Error(JSON.stringify(t)), qo = () => ee({
6288
+ }, pt = I("PresentationStateMachine"), xo = (t) => t instanceof Error ? t : new Error(JSON.stringify(t)), qo = () => ee({
6239
6289
  types: {
6240
- context: ln,
6290
+ context: dn,
6241
6291
  events: {}
6242
6292
  },
6243
6293
  actions: {
@@ -6248,16 +6298,16 @@ const ln = {
6248
6298
  pt("PresentationStateMachine state changed", e.state);
6249
6299
  },
6250
6300
  [p.SET_ERROR]: A(({ event: t }) => "error" in t && t.error !== void 0 ? {
6251
- lastError: Vo(t.error)
6301
+ lastError: xo(t.error)
6252
6302
  } : { lastError: void 0 }),
6253
6303
  [p.CLEAR_ERROR]: A(() => ({
6254
6304
  lastError: void 0
6255
6305
  }))
6256
6306
  }
6257
- }), Ho = () => qo().createMachine({
6307
+ }), Vo = () => qo().createMachine({
6258
6308
  id: "presentation",
6259
6309
  initial: h.IDLE,
6260
- context: ln,
6310
+ context: dn,
6261
6311
  states: {
6262
6312
  [h.IDLE]: {
6263
6313
  entry: {
@@ -6546,10 +6596,10 @@ const ln = {
6546
6596
  }
6547
6597
  }
6548
6598
  }
6549
- }), Wo = Ho(), Qo = I("PresentationStateMachine");
6550
- class Yo extends te {
6599
+ }), Ho = Vo(), Wo = I("PresentationStateMachine");
6600
+ class Qo extends te {
6551
6601
  constructor(e) {
6552
- super(Wo), this.subscribeCallEvents(e);
6602
+ super(Ho), this.subscribeCallEvents(e);
6553
6603
  }
6554
6604
  get isIdle() {
6555
6605
  return this.hasState(h.IDLE);
@@ -6586,7 +6636,7 @@ class Yo extends te {
6586
6636
  }
6587
6637
  sendEvent(e) {
6588
6638
  if (!this.actor.getSnapshot().can(e)) {
6589
- Qo(
6639
+ Wo(
6590
6640
  `[PresentationStateMachine] Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
6591
6641
  );
6592
6642
  return;
@@ -6625,14 +6675,14 @@ class Yo extends te {
6625
6675
  );
6626
6676
  }
6627
6677
  }
6628
- const jo = 1, zo = [
6678
+ const Yo = 1, jo = [
6629
6679
  "presentation:start",
6630
6680
  "presentation:started",
6631
6681
  "presentation:end",
6632
6682
  "presentation:ended",
6633
6683
  "presentation:failed"
6634
- ], Jo = (t) => t instanceof Error ? t : new Error(String(t)), _l = (t) => Ln(t);
6635
- class Ko extends w {
6684
+ ], zo = (t) => t instanceof Error ? t : new Error(String(t)), Ol = (t) => Pn(t);
6685
+ class Jo extends w {
6636
6686
  stateMachine;
6637
6687
  promisePendingStartPresentation;
6638
6688
  promisePendingStopPresentation;
@@ -6644,7 +6694,7 @@ class Ko extends w {
6644
6694
  callManager: e,
6645
6695
  maxBitrate: n
6646
6696
  }) {
6647
- super(xo()), this.callManager = e, this.maxBitrate = n, this.stateMachine = new Yo(this.callManager.events), this.subscribe();
6697
+ super($o()), this.callManager = e, this.maxBitrate = n, this.stateMachine = new Qo(this.callManager.events), this.subscribe();
6648
6698
  }
6649
6699
  get isPendingPresentation() {
6650
6700
  return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
@@ -6697,7 +6747,7 @@ class Ko extends w {
6697
6747
  this.cancelableSendPresentationWithRepeatedCalls?.stopRepeatedCalls();
6698
6748
  }
6699
6749
  subscribe() {
6700
- zo.forEach((e) => {
6750
+ jo.forEach((e) => {
6701
6751
  this.callManager.on(e, (n) => {
6702
6752
  this.events.trigger(e, n);
6703
6753
  });
@@ -6708,7 +6758,7 @@ class Ko extends w {
6708
6758
  stream: s,
6709
6759
  presentationOptions: r,
6710
6760
  options: i = {
6711
- callLimit: jo
6761
+ callLimit: Yo
6712
6762
  }
6713
6763
  }) {
6714
6764
  const a = async () => this.sendPresentation(
@@ -6717,7 +6767,7 @@ class Ko extends w {
6717
6767
  s,
6718
6768
  r
6719
6769
  ), o = () => !!this.streamPresentationCurrent;
6720
- return this.cancelableSendPresentationWithRepeatedCalls = He({
6770
+ return this.cancelableSendPresentationWithRepeatedCalls = Ve({
6721
6771
  targetFunction: a,
6722
6772
  isComplete: o,
6723
6773
  isRejectAsValid: !0,
@@ -6752,7 +6802,7 @@ class Ko extends w {
6752
6802
  if (!e || !n || s === void 0)
6753
6803
  return;
6754
6804
  const r = e.getSenders();
6755
- await wa(r, n, s);
6805
+ await La(r, n, s);
6756
6806
  };
6757
6807
  getRtcSessionProtected = () => {
6758
6808
  const e = this.callManager.getEstablishedRTCSession();
@@ -6773,10 +6823,10 @@ class Ko extends w {
6773
6823
  delete this.streamPresentationCurrent;
6774
6824
  }
6775
6825
  notifyPresentationFailed(e) {
6776
- this.events.trigger("presentation:failed", Jo(e));
6826
+ this.events.trigger("presentation:failed", zo(e));
6777
6827
  }
6778
6828
  }
6779
- const Xo = I("ContentedStreamStateMachine"), Zo = ee({
6829
+ const Ko = I("ContentedStreamStateMachine"), Xo = ee({
6780
6830
  types: {
6781
6831
  context: {},
6782
6832
  events: {}
@@ -6817,9 +6867,9 @@ const Xo = I("ContentedStreamStateMachine"), Zo = ee({
6817
6867
  }
6818
6868
  }
6819
6869
  });
6820
- class ec extends te {
6870
+ class Zo extends te {
6821
6871
  constructor() {
6822
- super(Zo);
6872
+ super(Xo);
6823
6873
  }
6824
6874
  get isAvailable() {
6825
6875
  return this.state === "contented-stream:available";
@@ -6841,7 +6891,7 @@ class ec extends te {
6841
6891
  }
6842
6892
  send(e) {
6843
6893
  if (!this.actor.getSnapshot().can(e)) {
6844
- Xo(
6894
+ Ko(
6845
6895
  `[ContentedStreamStateMachine] Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
6846
6896
  );
6847
6897
  return;
@@ -6860,15 +6910,15 @@ class ec extends te {
6860
6910
  );
6861
6911
  }
6862
6912
  }
6863
- const tc = [
6913
+ const ec = [
6864
6914
  "available",
6865
6915
  "not-available"
6866
6916
  /* NOT_AVAILABLE */
6867
- ], nc = () => new G(tc);
6868
- class sc extends w {
6917
+ ], tc = () => new G(ec);
6918
+ class nc extends w {
6869
6919
  stateMachine;
6870
6920
  constructor() {
6871
- super(nc()), this.stateMachine = new ec(), this.proxyEvents();
6921
+ super(tc()), this.stateMachine = new Zo(), this.proxyEvents();
6872
6922
  }
6873
6923
  get isAvailable() {
6874
6924
  return this.stateMachine.isAvailable;
@@ -6892,19 +6942,19 @@ class sc extends w {
6892
6942
  });
6893
6943
  }
6894
6944
  }
6895
- const dn = [
6945
+ const hn = [
6896
6946
  "ringing",
6897
6947
  "declinedIncomingCall",
6898
6948
  "terminatedIncomingCall",
6899
6949
  "failedIncomingCall"
6900
- ], rc = () => new G(dn);
6950
+ ], sc = () => new G(hn);
6901
6951
  var d = /* @__PURE__ */ ((t) => (t.IDLE = "incoming:idle", t.RINGING = "incoming:ringing", t.CONSUMED = "incoming:consumed", t.DECLINED = "incoming:declined", t.TERMINATED = "incoming:terminated", t.FAILED = "incoming:failed", t))(d || {}), S = /* @__PURE__ */ ((t) => (t.LOG_TRANSITION = "logTransition", t.LOG_STATE_CHANGE = "logStateChange", t.REMEMBER_INCOMING = "rememberIncoming", t.REMEMBER_REASON = "rememberReason", t.CLEAR_INCOMING = "clearIncoming", t))(S || {}), R = /* @__PURE__ */ ((t) => (t.RINGING = "INCOMING.RINGING", t.CONSUMED = "INCOMING.CONSUMED", t.DECLINED = "INCOMING.DECLINED", t.TERMINATED = "INCOMING.TERMINATED", t.FAILED = "INCOMING.FAILED", t.CLEAR = "INCOMING.CLEAR", t))(R || {});
6902
- const hn = {
6952
+ const un = {
6903
6953
  remoteCallerData: void 0,
6904
6954
  lastReason: void 0
6905
- }, St = I("IncomingCallStateMachine"), ic = () => ee({
6955
+ }, St = I("IncomingCallManager: createIncomingCallMachineSetup"), rc = () => ee({
6906
6956
  types: {
6907
- context: hn,
6957
+ context: un,
6908
6958
  events: {}
6909
6959
  },
6910
6960
  actions: {
@@ -6936,10 +6986,10 @@ const hn = {
6936
6986
  lastReason: void 0
6937
6987
  }))
6938
6988
  }
6939
- }), ac = () => ic().createMachine({
6989
+ }), ic = () => rc().createMachine({
6940
6990
  id: "incoming",
6941
6991
  initial: d.IDLE,
6942
- context: hn,
6992
+ context: un,
6943
6993
  states: {
6944
6994
  [d.IDLE]: {
6945
6995
  entry: {
@@ -7214,10 +7264,10 @@ const hn = {
7214
7264
  }
7215
7265
  }
7216
7266
  }
7217
- }), oc = ac(), cc = I("IncomingCallStateMachine");
7218
- class lc extends te {
7267
+ }), ac = ic(), oc = I("IncomingCallStateMachine");
7268
+ class cc extends te {
7219
7269
  constructor({ incomingEvents: e, connectionEvents: n }) {
7220
- super(oc), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(n);
7270
+ super(ac), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(n);
7221
7271
  }
7222
7272
  get isIdle() {
7223
7273
  return this.hasState(d.IDLE);
@@ -7263,7 +7313,7 @@ class lc extends te {
7263
7313
  }
7264
7314
  sendEvent(e) {
7265
7315
  if (!this.actor.getSnapshot().can(e)) {
7266
- cc(
7316
+ oc(
7267
7317
  `[IncomingCallStateMachine] Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
7268
7318
  );
7269
7319
  return;
@@ -7336,25 +7386,25 @@ class lc extends te {
7336
7386
  this.sendEvent({ type: R.CLEAR });
7337
7387
  };
7338
7388
  }
7339
- const dc = 486, hc = 487, Ge = (t) => ({
7389
+ const lc = 486, dc = 487, we = (t) => ({
7340
7390
  displayName: t.remote_identity.display_name,
7341
7391
  host: t.remote_identity.uri.host,
7342
7392
  incomingNumber: t.remote_identity.uri.user,
7343
7393
  rtcSession: t
7344
7394
  });
7345
- class uc extends w {
7395
+ class hc extends w {
7346
7396
  stateMachine;
7347
7397
  incomingRTCSession;
7348
7398
  connectionManager;
7349
7399
  constructor(e) {
7350
- super(rc()), this.connectionManager = e, this.stateMachine = new lc({
7400
+ super(sc()), this.connectionManager = e, this.stateMachine = new cc({
7351
7401
  incomingEvents: this.events,
7352
7402
  connectionEvents: this.connectionManager.events
7353
7403
  }), this.start();
7354
7404
  }
7355
7405
  get remoteCallerData() {
7356
7406
  if (this.incomingRTCSession)
7357
- return Ge(this.incomingRTCSession);
7407
+ return we(this.incomingRTCSession);
7358
7408
  }
7359
7409
  get isAvailableIncomingCall() {
7360
7410
  return !!this.incomingRTCSession;
@@ -7376,11 +7426,11 @@ class uc extends w {
7376
7426
  return this.stateMachine.toConsumed(), this.removeIncomingSession(), e;
7377
7427
  };
7378
7428
  async declineToIncomingCall({
7379
- statusCode: e = hc
7429
+ statusCode: e = dc
7380
7430
  } = {}) {
7381
7431
  return new Promise((n, s) => {
7382
7432
  try {
7383
- const r = this.getIncomingRTCSession(), i = Ge(r);
7433
+ const r = this.getIncomingRTCSession(), i = we(r);
7384
7434
  this.removeIncomingSession(), this.events.trigger("declinedIncomingCall", i), r.terminate({ status_code: e }), n();
7385
7435
  } catch (r) {
7386
7436
  s(r);
@@ -7388,7 +7438,7 @@ class uc extends w {
7388
7438
  });
7389
7439
  }
7390
7440
  async busyIncomingCall() {
7391
- return this.declineToIncomingCall({ statusCode: dc });
7441
+ return this.declineToIncomingCall({ statusCode: lc });
7392
7442
  }
7393
7443
  subscribe() {
7394
7444
  this.connectionManager.on("newRTCSession", this.handleNewRTCSession);
@@ -7404,7 +7454,7 @@ class uc extends w {
7404
7454
  };
7405
7455
  setIncomingSession(e) {
7406
7456
  this.incomingRTCSession = e;
7407
- const n = Ge(e);
7457
+ const n = we(e);
7408
7458
  e.on("failed", (s) => {
7409
7459
  this.removeIncomingSession(), s.originator === "local" ? this.events.trigger("terminatedIncomingCall", n) : this.events.trigger("failedIncomingCall", n);
7410
7460
  }), this.events.trigger("ringing", n);
@@ -7413,7 +7463,7 @@ class uc extends w {
7413
7463
  delete this.incomingRTCSession;
7414
7464
  }
7415
7465
  }
7416
- class gc {
7466
+ class uc {
7417
7467
  apiManager;
7418
7468
  connectionManager;
7419
7469
  callManager;
@@ -7449,10 +7499,10 @@ class gc {
7449
7499
  s.sendEnterRoom(r);
7450
7500
  };
7451
7501
  }
7452
- const un = ["snapshot-changed"], Ec = () => new G(un), mc = (t, e) => Object.is(t, e), Ct = (t, e) => t.connection.value === e.connection.value && // Call: full snapshot so room/context updates without a state `value` change still emit snapshot-changed
7453
- Je(t.call, e.call) && // Incoming: value only — repeated RINGING with different callee metadata must not emit again
7502
+ const gn = ["snapshot-changed"], gc = () => new G(gn), Ec = (t, e) => Object.is(t, e), Ct = (t, e) => t.connection.value === e.connection.value && // Call: full snapshot so room/context updates without a state `value` change still emit snapshot-changed
7503
+ ze(t.call, e.call) && // Incoming: value only — repeated RINGING with different callee metadata must not emit again
7454
7504
  t.incoming.value === e.incoming.value && t.presentation.value === e.presentation.value && t.autoConnector.value === e.autoConnector.value && // CallReconnect: full snapshot so attempt/delay context updates без смены `value` тоже эмитят событие
7455
- Je(t.callReconnect, e.callReconnect), Rt = (t) => ({
7505
+ ze(t.callReconnect, e.callReconnect), Rt = (t) => ({
7456
7506
  connection: t.connection.getSnapshot(),
7457
7507
  call: t.call.getSnapshot(),
7458
7508
  incoming: t.incoming.getSnapshot(),
@@ -7460,13 +7510,13 @@ Je(t.callReconnect, e.callReconnect), Rt = (t) => ({
7460
7510
  autoConnector: t.autoConnector.getSnapshot(),
7461
7511
  callReconnect: t.callReconnect.getSnapshot()
7462
7512
  });
7463
- class Tc extends w {
7513
+ class mc extends w {
7464
7514
  machines;
7465
7515
  currentSnapshot;
7466
7516
  subscribers = /* @__PURE__ */ new Set();
7467
7517
  actorSubscriptions = [];
7468
7518
  constructor(e) {
7469
- super(Ec()), this.machines = {
7519
+ super(gc()), this.machines = {
7470
7520
  connection: e.connectionManager.stateMachine,
7471
7521
  call: e.callManager.stateMachine,
7472
7522
  incoming: e.incomingCallManager.stateMachine,
@@ -7486,7 +7536,7 @@ class Tc extends w {
7486
7536
  return this.currentSnapshot;
7487
7537
  }
7488
7538
  subscribe(e, n, s) {
7489
- const r = typeof n == "function", i = r ? e : (f) => f, a = r ? n : e, c = r ? s ?? mc : Ct, g = i(this.currentSnapshot), C = {
7539
+ const r = typeof n == "function", i = r ? e : (f) => f, a = r ? n : e, c = r ? s ?? Ec : Ct, g = i(this.currentSnapshot), C = {
7490
7540
  selector: i,
7491
7541
  listener: a,
7492
7542
  equals: c,
@@ -7517,10 +7567,10 @@ class Tc extends w {
7517
7567
  }
7518
7568
  const de = 1e3;
7519
7569
  var D = /* @__PURE__ */ ((t) => (t.INBOUND_RTP = "inbound-rtp", t.REMOTE_OUTBOUND_RTP = "remote-outbound-rtp", t.MEDIA_SOURCE = "media-source", t.OUTBOUND_RTP = "outbound-rtp", t.REMOTE_INBOUND_RTP = "remote-inbound-rtp", t.CODEC = "codec", t.CANDIDATE_PAIR = "candidate-pair", t.CERTIFICATE = "certificate", t.TRANSPORT = "transport", t.LOCAL_CANDIDATE = "local-candidate", t.REMOTE_CANDIDATE = "remote-candidate", t))(D || {});
7520
- const gn = ["collected", "stopped"], pc = () => new G(gn), Nt = () => "performance" in window ? performance.now() : Date.now(), Te = (t) => [...t.keys()].reduce((e, n) => {
7570
+ const En = ["collected", "stopped"], Tc = () => new G(En), Nt = () => "performance" in window ? performance.now() : Date.now(), Te = (t) => [...t.keys()].reduce((e, n) => {
7521
7571
  const s = t.get(n);
7522
7572
  return s === void 0 ? e : { ...e, [s.type]: s };
7523
- }, {}), Sc = (t) => {
7573
+ }, {}), pc = (t) => {
7524
7574
  if (!t)
7525
7575
  return {
7526
7576
  outboundRtp: void 0,
@@ -7566,7 +7616,7 @@ const gn = ["collected", "stopped"], pc = () => new G(gn), Nt = () => "performan
7566
7616
  codec: n[D.CODEC],
7567
7617
  synchronizationSources: e
7568
7618
  };
7569
- }, Cc = ({
7619
+ }, Sc = ({
7570
7620
  audioReceiverStats: t,
7571
7621
  synchronizationSourcesAudio: e
7572
7622
  }) => {
@@ -7584,7 +7634,7 @@ const gn = ["collected", "stopped"], pc = () => new G(gn), Nt = () => "performan
7584
7634
  remoteOutboundRtp: n[D.REMOTE_OUTBOUND_RTP],
7585
7635
  synchronizationSources: e
7586
7636
  };
7587
- }, En = (t) => {
7637
+ }, mn = (t) => {
7588
7638
  if (!t)
7589
7639
  return {
7590
7640
  candidatePair: void 0,
@@ -7601,18 +7651,18 @@ const gn = ["collected", "stopped"], pc = () => new G(gn), Nt = () => "performan
7601
7651
  remoteCandidate: e[D.REMOTE_CANDIDATE],
7602
7652
  transport: e[D.TRANSPORT]
7603
7653
  };
7604
- }, Rc = ({
7654
+ }, Cc = ({
7605
7655
  audioSenderStats: t,
7606
7656
  videoSenderFirstStats: e,
7607
7657
  videoSenderSecondStats: n
7608
7658
  }) => ({
7609
7659
  video: At(e),
7610
7660
  secondVideo: At(n),
7611
- audio: Sc(t),
7612
- additional: En(
7661
+ audio: pc(t),
7662
+ additional: mn(
7613
7663
  t ?? e ?? n
7614
7664
  )
7615
- }), Nc = ({
7665
+ }), Rc = ({
7616
7666
  audioReceiverStats: t,
7617
7667
  videoReceiverFirstStats: e,
7618
7668
  videoReceiverSecondStats: n,
@@ -7626,14 +7676,14 @@ const gn = ["collected", "stopped"], pc = () => new G(gn), Nt = () => "performan
7626
7676
  videoReceiversStats: n,
7627
7677
  synchronizationSourcesVideo: s.secondVideo ?? s.video
7628
7678
  }),
7629
- audio: Cc({
7679
+ audio: Sc({
7630
7680
  audioReceiverStats: t,
7631
7681
  synchronizationSourcesAudio: s.audio
7632
7682
  }),
7633
- additional: En(
7683
+ additional: mn(
7634
7684
  t ?? e ?? n
7635
7685
  )
7636
- }), Ac = ({
7686
+ }), Nc = ({
7637
7687
  audioSenderStats: t,
7638
7688
  videoSenderFirstStats: e,
7639
7689
  videoSenderSecondStats: n,
@@ -7642,11 +7692,11 @@ const gn = ["collected", "stopped"], pc = () => new G(gn), Nt = () => "performan
7642
7692
  videoReceiverSecondStats: i,
7643
7693
  synchronizationSources: a
7644
7694
  }) => {
7645
- const o = Rc({
7695
+ const o = Cc({
7646
7696
  audioSenderStats: t,
7647
7697
  videoSenderFirstStats: e,
7648
7698
  videoSenderSecondStats: n
7649
- }), c = Nc({
7699
+ }), c = Rc({
7650
7700
  audioReceiverStats: s,
7651
7701
  videoReceiverFirstStats: r,
7652
7702
  videoReceiverSecondStats: i,
@@ -7656,7 +7706,7 @@ const gn = ["collected", "stopped"], pc = () => new G(gn), Nt = () => "performan
7656
7706
  outbound: o,
7657
7707
  inbound: c
7658
7708
  };
7659
- }, Ic = async (t) => {
7709
+ }, Ac = async (t) => {
7660
7710
  const e = "audio", n = "video", s = t.getSenders(), r = s.find((_) => _.track?.kind === e), i = s.filter((_) => _.track?.kind === n), a = t.getReceivers(), o = a.find((_) => _.track.kind === e), c = a.filter((_) => _.track.kind === n), g = {
7661
7711
  trackIdentifier: o?.track.id,
7662
7712
  item: o?.getSynchronizationSources()[0]
@@ -7680,36 +7730,36 @@ const gn = ["collected", "stopped"], pc = () => new G(gn), Nt = () => "performan
7680
7730
  c[1]?.getStats() ?? Promise.resolve(void 0)
7681
7731
  ]).then((_) => {
7682
7732
  const [
7683
- V,
7733
+ q,
7684
7734
  B,
7685
- K,
7735
+ X,
7686
7736
  ne,
7687
7737
  Me,
7688
- ze
7738
+ je
7689
7739
  ] = _;
7690
7740
  return {
7691
7741
  synchronizationSources: y,
7692
- audioSenderStats: V,
7742
+ audioSenderStats: q,
7693
7743
  videoSenderFirstStats: B,
7694
- videoSenderSecondStats: K,
7744
+ videoSenderSecondStats: X,
7695
7745
  audioReceiverStats: ne,
7696
7746
  videoReceiverFirstStats: Me,
7697
- videoReceiverSecondStats: ze
7747
+ videoReceiverSecondStats: je
7698
7748
  };
7699
7749
  });
7700
- }, fc = I("StatsPeerConnection");
7701
- class vc extends w {
7750
+ }, Ic = I("StatsPeerConnection");
7751
+ class fc extends w {
7702
7752
  setTimeoutRequest;
7703
- requesterAllStatistics = new me(Ic);
7753
+ requesterAllStatistics = new me(Ac);
7704
7754
  constructor() {
7705
- super(pc()), this.setTimeoutRequest = new _t();
7755
+ super(Tc()), this.setTimeoutRequest = new bt();
7706
7756
  }
7707
7757
  get requested() {
7708
7758
  return this.setTimeoutRequest.requested;
7709
7759
  }
7710
7760
  start(e, {
7711
7761
  interval: n = de,
7712
- onError: s = fc
7762
+ onError: s = Ic
7713
7763
  } = {}) {
7714
7764
  this.setTimeoutRequest.request(() => {
7715
7765
  this.collectStatistics(e, {
@@ -7734,7 +7784,7 @@ class vc extends w {
7734
7784
  }) => {
7735
7785
  const r = Nt();
7736
7786
  this.requestAllStatistics(e).then((i) => {
7737
- this.events.trigger("collected", Ac(i));
7787
+ this.events.trigger("collected", Nc(i));
7738
7788
  const o = Nt() - r;
7739
7789
  let c = de;
7740
7790
  o > 48 ? c = de * 4 : o > 32 ? c = de * 3 : o > 16 && (c = de * 2), s({ interval: c });
@@ -7749,8 +7799,8 @@ class vc extends w {
7749
7799
  return this.requesterAllStatistics.request(n);
7750
7800
  };
7751
7801
  }
7752
- const Mc = 500, Oc = I("StatsManager");
7753
- class _c extends w {
7802
+ const vc = 500, Mc = I("StatsManager");
7803
+ class Oc extends w {
7754
7804
  statsPeerConnection;
7755
7805
  availableStats;
7756
7806
  previousAvailableStats;
@@ -7760,7 +7810,7 @@ class _c extends w {
7760
7810
  callManager: e,
7761
7811
  apiManager: n
7762
7812
  }) {
7763
- const s = new vc();
7813
+ const s = new fc();
7764
7814
  super(s.events), this.statsPeerConnection = s, this.callManager = e, this.apiManager = n, this.subscribe();
7765
7815
  }
7766
7816
  get availableIncomingBitrate() {
@@ -7823,7 +7873,7 @@ class _c extends w {
7823
7873
  return this.previousInboundRtp?.bytesReceived;
7824
7874
  }
7825
7875
  get isReceivingPackets() {
7826
- const e = this.packetsReceived !== void 0 && this.packetsReceived >= Mc, n = this.packetsReceived !== this.previousPacketsReceived;
7876
+ const e = this.packetsReceived !== void 0 && this.packetsReceived >= vc, n = this.packetsReceived !== this.previousPacketsReceived;
7827
7877
  return e && n;
7828
7878
  }
7829
7879
  hasAvailableIncomingBitrateChangedQuarter() {
@@ -7859,42 +7909,42 @@ class _c extends w {
7859
7909
  };
7860
7910
  maybeSendStats() {
7861
7911
  this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
7862
- Oc("Failed to send stats", e);
7912
+ Mc("Failed to send stats", e);
7863
7913
  });
7864
7914
  }
7865
7915
  }
7866
- const bc = I("setCodecPreferences"), yc = (t, e) => t.filter((s) => e.some((r) => r.clockRate === s.clockRate && r.mimeType === s.mimeType && r.channels === s.channels && r.sdpFmtpLine === s.sdpFmtpLine)), Dc = (t) => {
7916
+ const _c = I("setCodecPreferences"), bc = (t, e) => t.filter((s) => e.some((r) => r.clockRate === s.clockRate && r.mimeType === s.mimeType && r.channels === s.channels && r.sdpFmtpLine === s.sdpFmtpLine)), yc = (t) => {
7867
7917
  const e = RTCRtpSender.getCapabilities(t), n = RTCRtpReceiver.getCapabilities(t), s = e === null ? [] : e.codecs, r = n === null ? [] : n.codecs;
7868
- return yc(s, r);
7869
- }, Pc = (t, e) => e === void 0 || e.length === 0 ? t : t.sort((n, s) => {
7918
+ return bc(s, r);
7919
+ }, Dc = (t, e) => e === void 0 || e.length === 0 ? t : t.sort((n, s) => {
7870
7920
  const r = e.indexOf(n.mimeType), i = e.indexOf(s.mimeType), a = r === -1 ? Number.MAX_VALUE : r, o = i === -1 ? Number.MAX_VALUE : i;
7871
7921
  return a - o;
7872
- }), Lc = (t, e) => e === void 0 || e.length === 0 ? t : t.filter((n) => !e.includes(n.mimeType)), wc = (t, {
7922
+ }), Pc = (t, e) => e === void 0 || e.length === 0 ? t : t.filter((n) => !e.includes(n.mimeType)), Lc = (t, {
7873
7923
  preferredMimeTypesVideoCodecs: e,
7874
7924
  excludeMimeTypesVideoCodecs: n
7875
7925
  }) => {
7876
7926
  try {
7877
7927
  if (typeof t.setCodecPreferences == "function" && t.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || n !== void 0 && n.length > 0)) {
7878
- const s = Dc("video"), r = Lc(s, n), i = Pc(r, e);
7928
+ const s = yc("video"), r = Pc(s, n), i = Dc(r, e);
7879
7929
  t.setCodecPreferences(i);
7880
7930
  }
7881
7931
  } catch (s) {
7882
- bc("setCodecPreferences error", s);
7932
+ _c("setCodecPreferences error", s);
7883
7933
  }
7884
- }, mn = [
7934
+ }, Tn = [
7885
7935
  "balancing-scheduled",
7886
7936
  "balancing-started",
7887
7937
  "balancing-stopped",
7888
7938
  "parameters-updated"
7889
- ], Gc = () => new G(mn), kc = I("VideoSendingBalancerManager");
7890
- class Fc extends w {
7939
+ ], wc = () => new G(Tn), Gc = I("VideoSendingBalancerManager");
7940
+ class kc extends w {
7891
7941
  isBalancingActive = !1;
7892
7942
  callManager;
7893
7943
  balancingStartDelay;
7894
7944
  videoSendingBalancer;
7895
7945
  startBalancingTimer;
7896
7946
  constructor(e, n, s = {}) {
7897
- super(Gc()), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new mo(
7947
+ super(wc()), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new Eo(
7898
7948
  n,
7899
7949
  () => e.connection,
7900
7950
  {
@@ -7950,7 +8000,7 @@ class Fc extends w {
7950
8000
  scheduleBalancingStart() {
7951
8001
  this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
7952
8002
  this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
7953
- kc("startBalancing: error", e);
8003
+ Gc("startBalancing: error", e);
7954
8004
  });
7955
8005
  }, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
7956
8006
  }
@@ -7958,12 +8008,12 @@ class Fc extends w {
7958
8008
  this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
7959
8009
  }
7960
8010
  }
7961
- const Tn = "health-snapshot", pn = "inbound-video-problem-detected", Sn = "inbound-video-problem-resolved", Cn = "inbound-video-problem-reset", Rn = [
7962
- Tn,
8011
+ const pn = "health-snapshot", Sn = "inbound-video-problem-detected", Cn = "inbound-video-problem-resolved", Rn = "inbound-video-problem-reset", Nn = [
7963
8012
  pn,
7964
8013
  Sn,
7965
- Cn
7966
- ], Uc = () => new G(Rn), Bc = 3;
8014
+ Cn,
8015
+ Rn
8016
+ ], Fc = () => new G(Nn), Uc = 3;
7967
8017
  class ge extends w {
7968
8018
  statsManager;
7969
8019
  callManager;
@@ -7971,8 +8021,8 @@ class ge extends w {
7971
8021
  consecutiveProblemSamplesCount = 0;
7972
8022
  currentProblemReason;
7973
8023
  hasEmittedCurrentProblem = !1;
7974
- constructor(e, n, s = Bc) {
7975
- super(Uc()), this.statsManager = e, this.callManager = n, ge.assertValidMinConsecutiveProblemSamplesCount(
8024
+ constructor(e, n, s = Uc) {
8025
+ super(Fc()), this.statsManager = e, this.callManager = n, ge.assertValidMinConsecutiveProblemSamplesCount(
7976
8026
  s
7977
8027
  ), this.minConsecutiveProblemSamplesCount = s, this.subscribe();
7978
8028
  }
@@ -8019,13 +8069,13 @@ class ge extends w {
8019
8069
  }
8020
8070
  handleStatsCollected = () => {
8021
8071
  const { healthSnapshot: e } = this;
8022
- this.events.trigger(Tn, e);
8072
+ this.events.trigger(pn, e);
8023
8073
  const n = ge.resolveProblemReason(e);
8024
8074
  if (n === void 0) {
8025
8075
  this.maybeEmitResolvedProblem(e), this.resetProblemDetectionState();
8026
8076
  return;
8027
8077
  }
8028
- this.updateProblemDetectionState(n), this.consecutiveProblemSamplesCount >= this.minConsecutiveProblemSamplesCount && !this.hasEmittedCurrentProblem && (this.events.trigger(pn, {
8078
+ this.updateProblemDetectionState(n), this.consecutiveProblemSamplesCount >= this.minConsecutiveProblemSamplesCount && !this.hasEmittedCurrentProblem && (this.events.trigger(Sn, {
8029
8079
  ...e,
8030
8080
  consecutiveProblemSamplesCount: this.consecutiveProblemSamplesCount,
8031
8081
  reason: n
@@ -8045,7 +8095,7 @@ class ge extends w {
8045
8095
  this.currentProblemReason = e, this.consecutiveProblemSamplesCount = 1, this.hasEmittedCurrentProblem = !1;
8046
8096
  };
8047
8097
  maybeEmitResolvedProblem = (e) => {
8048
- !this.hasEmittedCurrentProblem || this.currentProblemReason === void 0 || this.events.trigger(Sn, {
8098
+ !this.hasEmittedCurrentProblem || this.currentProblemReason === void 0 || this.events.trigger(Cn, {
8049
8099
  ...e,
8050
8100
  reason: this.currentProblemReason
8051
8101
  });
@@ -8054,7 +8104,7 @@ class ge extends w {
8054
8104
  this.maybeEmitResetProblem(e), this.resetProblemDetectionState();
8055
8105
  };
8056
8106
  maybeEmitResetProblem = (e) => {
8057
- !this.hasEmittedCurrentProblem || this.currentProblemReason === void 0 || this.events.trigger(Cn, {
8107
+ !this.hasEmittedCurrentProblem || this.currentProblemReason === void 0 || this.events.trigger(Rn, {
8058
8108
  reason: this.currentProblemReason,
8059
8109
  resetCause: e
8060
8110
  });
@@ -8063,12 +8113,12 @@ class ge extends w {
8063
8113
  this.currentProblemReason = void 0, this.consecutiveProblemSamplesCount = 0, this.hasEmittedCurrentProblem = !1;
8064
8114
  };
8065
8115
  }
8066
- const re = I("MainStreamRecovery"), $c = 4e3;
8116
+ const re = I("MainStreamRecovery"), Bc = 4e3;
8067
8117
  class ve {
8068
8118
  renegotiateRequester;
8069
8119
  renegotiateThrottled;
8070
8120
  callManager;
8071
- constructor(e, n = $c) {
8121
+ constructor(e, n = Bc) {
8072
8122
  this.callManager = e, this.renegotiateRequester = new me(e.renegotiate.bind(e)), this.renegotiateThrottled = this.createRenegotiateThrottled(n), this.subscribe();
8073
8123
  }
8074
8124
  static assertValidThrottleRecoveryTimeout(e) {
@@ -8095,7 +8145,7 @@ class ve {
8095
8145
  });
8096
8146
  };
8097
8147
  createRenegotiateThrottled(e) {
8098
- return ve.assertValidThrottleRecoveryTimeout(e), Gn.throttle(this.requestRenegotiate.bind(this), e);
8148
+ return ve.assertValidThrottleRecoveryTimeout(e), wn.throttle(this.requestRenegotiate.bind(this), e);
8099
8149
  }
8100
8150
  // На завершение вызова: отменяем throttling и (если есть) in-flight renegotiate.
8101
8151
  subscribe() {
@@ -8108,36 +8158,37 @@ class ve {
8108
8158
  re("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
8109
8159
  }
8110
8160
  }
8111
- var Nn = /* @__PURE__ */ ((t) => (t.VP8 = "video/VP8", t.VP9 = "video/VP9", t.H264 = "video/H264", t.AV1 = "video/AV1", t.rtx = "video/rtx", t.red = "video/red", t.flexfec03 = "video/flexfec-03", t))(Nn || {});
8112
- const xc = {
8161
+ var An = /* @__PURE__ */ ((t) => (t.VP8 = "video/VP8", t.VP9 = "video/VP9", t.H264 = "video/H264", t.AV1 = "video/AV1", t.rtx = "video/rtx", t.red = "video/red", t.flexfec03 = "video/flexfec-03", t))(An || {});
8162
+ const $c = {
8113
8163
  major: 25,
8114
8164
  minor: 8,
8115
8165
  patch: 0
8116
- }, Vc = ({
8166
+ }, xc = ({
8117
8167
  isYandexBrowser: t,
8118
8168
  hasGreaterThanBrowserVersion: e
8119
8169
  }) => {
8120
8170
  const n = e(
8121
- xc
8171
+ $c
8122
8172
  );
8123
8173
  return t && n;
8124
8174
  }, qc = () => {
8125
- const t = Ht();
8126
- if (Vc(t))
8127
- return [Nn.VP8];
8128
- }, Hc = () => {
8129
- const { isMobileDevice: t, isSafari: e, isOpera: n, isWindows: s } = Ht();
8175
+ const t = Wt();
8176
+ if (xc(t))
8177
+ return [An.VP8];
8178
+ }, Vc = () => {
8179
+ const { isMobileDevice: t, isSafari: e, isOpera: n, isWindows: s } = Wt();
8130
8180
  return t || e || n && s;
8131
8181
  };
8132
- let An;
8133
- Hc() && (An = "h264");
8134
- const Wc = {
8135
- ignoreForCodec: An
8136
- }, Qc = qc(), Yc = 1e6, jc = Ut.map((t) => `auto-connect:${t}`), zc = Bt.map((t) => `call-reconnect:${t}`), Jc = Ft.map((t) => `connection:${t}`), Kc = qt.map((t) => `call:${t}`), Xc = Lt.map((t) => `api:${t}`), Zc = dn.map((t) => `incoming-call:${t}`), el = cn.map((t) => `presentation:${t}`), tl = gn.map((t) => `stats:${t}`), nl = mn.map((t) => `video-balancer:${t}`), sl = Rn.map((t) => `main-stream-health:${t}`), rl = un.map((t) => `session:${t}`), il = [
8182
+ let In;
8183
+ Vc() && (In = "h264");
8184
+ const Hc = {
8185
+ ignoreForCodec: In
8186
+ }, Wc = qc(), Qc = 1e6, Yc = Bt.map((t) => `auto-connect:${t}`), jc = $t.map((t) => `call-reconnect:${t}`), zc = Ut.map((t) => `connection:${t}`), Jc = Ht.map((t) => `call:${t}`), Kc = wt.map((t) => `api:${t}`), Xc = hn.map((t) => `incoming-call:${t}`), Zc = ln.map((t) => `presentation:${t}`), el = En.map((t) => `stats:${t}`), tl = Tn.map((t) => `video-balancer:${t}`), nl = Nn.map((t) => `main-stream-health:${t}`), sl = gn.map((t) => `session:${t}`), rl = [
8137
8187
  "disconnected-from-out-of-call",
8138
8188
  "connected-with-configuration-from-out-of-call",
8139
8189
  "stopped-presentation-by-server-command"
8140
- ], al = [
8190
+ ], il = [
8191
+ ...Yc,
8141
8192
  ...jc,
8142
8193
  ...zc,
8143
8194
  ...Jc,
@@ -8148,10 +8199,9 @@ const Wc = {
8148
8199
  ...tl,
8149
8200
  ...nl,
8150
8201
  ...sl,
8151
- ...rl,
8152
- ...il
8153
- ], ol = () => new G(al), ft = I("SipConnector");
8154
- class bl extends w {
8202
+ ...rl
8203
+ ], al = () => new G(il), ft = I("SipConnector");
8204
+ class _l extends w {
8155
8205
  connectionManager;
8156
8206
  connectionQueueManager;
8157
8207
  contentedStreamManager;
@@ -8180,40 +8230,40 @@ class bl extends w {
8180
8230
  minConsecutiveProblemSamplesCount: c,
8181
8231
  throttleRecoveryTimeout: g
8182
8232
  } = {}) {
8183
- super(ol()), this.preferredMimeTypesVideoCodecs = n ?? Qc, this.excludeMimeTypesVideoCodecs = s, this.apiManager = new jn(), this.connectionManager = new ys({ JsSIP: e }, { numberOfConnectionAttempts: o }), this.connectionQueueManager = new Ds({
8233
+ super(al()), this.preferredMimeTypesVideoCodecs = n ?? Wc, this.excludeMimeTypesVideoCodecs = s, this.apiManager = new Yn(), this.connectionManager = new ys({ JsSIP: e }, { numberOfConnectionAttempts: o }), this.connectionQueueManager = new Ds({
8184
8234
  connectionManager: this.connectionManager
8185
- }), this.contentedStreamManager = new sc(), this.callSessionState = new ha(), this.callManager = new $o(
8235
+ }), this.contentedStreamManager = new nc(), this.callSessionState = new da(), this.callManager = new Bo(
8186
8236
  { contentedStreamManager: this.contentedStreamManager },
8187
8237
  { sendOffer: this.sendOffer },
8188
8238
  { callSessionState: this.callSessionState }
8189
- ), this.incomingCallManager = new uc(this.connectionManager), this.presentationManager = new Ko({
8239
+ ), this.incomingCallManager = new hc(this.connectionManager), this.presentationManager = new Jo({
8190
8240
  callManager: this.callManager,
8191
- maxBitrate: Yc
8192
- }), this.statsManager = new _c({
8241
+ maxBitrate: Qc
8242
+ }), this.statsManager = new Oc({
8193
8243
  callManager: this.callManager,
8194
8244
  apiManager: this.apiManager
8195
- }), this.autoConnectorManager = new rr(
8245
+ }), this.autoConnectorManager = new sr(
8196
8246
  {
8197
8247
  connectionQueueManager: this.connectionQueueManager,
8198
8248
  connectionManager: this.connectionManager,
8199
8249
  callManager: this.callManager
8200
8250
  },
8201
8251
  i
8202
- ), this.callReconnectManager = new Mr(
8252
+ ), this.callReconnectManager = new vr(
8203
8253
  {
8204
8254
  callManager: this.callManager,
8205
8255
  connectionManager: this.connectionManager
8206
8256
  },
8207
8257
  a
8208
- ), this.videoSendingBalancerManager = new Fc(
8258
+ ), this.videoSendingBalancerManager = new kc(
8209
8259
  this.callManager,
8210
8260
  this.apiManager,
8211
- r ?? Wc
8261
+ r ?? Hc
8212
8262
  ), this.mainStreamHealthMonitor = new ge(
8213
8263
  this.statsManager,
8214
8264
  this.callManager,
8215
8265
  c
8216
- ), this.mainStreamRecovery = new ve(this.callManager, g), this.sessionManager = new Tc({
8266
+ ), this.mainStreamRecovery = new ve(this.callManager, g), this.sessionManager = new mc({
8217
8267
  connectionManager: this.connectionManager,
8218
8268
  callManager: this.callManager,
8219
8269
  incomingCallManager: this.incomingCallManager,
@@ -8223,7 +8273,7 @@ class bl extends w {
8223
8273
  }), this.callManager.subscribeToApiEvents(this.apiManager), this.contentedStreamManager.subscribeToApiEvents(this.apiManager), this.apiManager.subscribe({
8224
8274
  connectionManager: this.connectionManager,
8225
8275
  callManager: this.callManager
8226
- }), this.peerToPeerManager = new gc(), this.peerToPeerManager.subscribe({
8276
+ }), this.peerToPeerManager = new uc(), this.peerToPeerManager.subscribe({
8227
8277
  connectionManager: this.connectionManager,
8228
8278
  callManager: this.callManager,
8229
8279
  apiManager: this.apiManager
@@ -8288,9 +8338,7 @@ class bl extends w {
8288
8338
  isConfigured = () => this.connectionManager.isConfigured();
8289
8339
  getConnectionConfiguration = () => this.connectionManager.getConnectionConfiguration();
8290
8340
  getUri = (e) => this.connectionManager.getUri(e);
8291
- startAutoConnect = (...e) => {
8292
- this.autoConnectorManager.start(...e);
8293
- };
8341
+ startAutoConnect = async (...e) => this.autoConnectorManager.start(...e);
8294
8342
  stopAutoConnect = () => {
8295
8343
  this.autoConnectorManager.stop();
8296
8344
  };
@@ -8443,7 +8491,7 @@ class bl extends w {
8443
8491
  const r = this.connectionManager.getConnectionConfiguration()?.sipServerUrl;
8444
8492
  if (r === void 0)
8445
8493
  throw new Error("No sipServerUrl for sendOffer");
8446
- return Aa({
8494
+ return Na({
8447
8495
  serverUrl: r,
8448
8496
  offer: n,
8449
8497
  token: e.token,
@@ -8453,7 +8501,7 @@ class bl extends w {
8453
8501
  });
8454
8502
  };
8455
8503
  setCodecPreferences(e) {
8456
- wc(e, {
8504
+ Lc(e, {
8457
8505
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
8458
8506
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
8459
8507
  });
@@ -8478,61 +8526,61 @@ class bl extends w {
8478
8526
  };
8479
8527
  }
8480
8528
  export {
8481
- ra as $,
8529
+ sa as $,
8482
8530
  h as A,
8483
8531
  D as B,
8484
- ha as C,
8485
- Ba as D,
8486
- an as E,
8487
- Yo as F,
8488
- bl as G,
8489
- vc as H,
8490
- lc as I,
8532
+ da as C,
8533
+ Ua as D,
8534
+ on as E,
8535
+ Qo as F,
8536
+ _l as G,
8537
+ fc as H,
8538
+ cc as I,
8491
8539
  Fs as J,
8492
- Ji as K,
8493
- Ir as L,
8494
- Ja as M,
8540
+ zi as K,
8541
+ Ar as L,
8542
+ za as M,
8495
8543
  Cs as N,
8496
- rc as O,
8497
- Ca as P,
8498
- Nl as Q,
8544
+ sc as O,
8545
+ Sa as P,
8546
+ Rl as Q,
8499
8547
  H as R,
8500
- Tc as S,
8501
- Rl as T,
8502
- en as U,
8503
- _l as V,
8504
- ta as W,
8548
+ mc as S,
8549
+ Cl as T,
8550
+ tn as U,
8551
+ Ol as V,
8552
+ ea as W,
8505
8553
  Y as X,
8506
8554
  Ee as Y,
8507
- ia as Z,
8508
- sa as _,
8509
- Ml as a,
8510
- na as a0,
8555
+ ra as Z,
8556
+ na as _,
8557
+ vl as a,
8558
+ ta as a0,
8511
8559
  qi as a1,
8512
- Ki as a2,
8513
- vl as b,
8514
- Ol as c,
8515
- Ht as d,
8560
+ Ji as a2,
8561
+ fl as b,
8562
+ Ml as c,
8563
+ Wt as d,
8516
8564
  fe as e,
8517
- Aa as f,
8518
- Yt as g,
8519
- Ue as h,
8520
- Be as i,
8565
+ Na as f,
8566
+ jt as g,
8567
+ Fe as h,
8568
+ Ue as i,
8521
8569
  u as j,
8522
8570
  l as k,
8523
8571
  O as l,
8524
8572
  I as m,
8525
8573
  cs as n,
8526
- Bt as o,
8574
+ $t as o,
8527
8575
  Re as p,
8528
8576
  ps as q,
8529
- fl as r,
8530
- Il as s,
8577
+ Il as r,
8578
+ Al as s,
8531
8579
  v as t,
8532
8580
  m as u,
8533
- Ye as v,
8581
+ Qe as v,
8534
8582
  R as w,
8535
8583
  d as x,
8536
- Nn as y,
8584
+ An as y,
8537
8585
  T as z
8538
8586
  };