sip-connector 19.6.0 → 19.7.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,19 +1,19 @@
1
1
  import { Events as k, TypedEvents as U } from "events-constructor";
2
2
  import x from "debug";
3
- import { CancelableRequest as G, isCanceledError as me } from "@krivega/cancelable-promise";
4
- import { resolveRequesterByTimeout as _e, requesterByTimeoutsWithFailCalls as Me, DelayRequester as ve, hasCanceledError as fe, SetTimeoutRequest as Z } from "@krivega/timeout-requester";
5
- import { hasCanceledError as Pe, repeatedCallsAsync as ee } from "repeated-calls";
6
- import { setup as Oe, createActor as ye } from "xstate";
7
- import { createStackPromises as te, isPromiseIsNotActualError as De } from "stack-promises";
3
+ import { CancelableRequest as G, isCanceledError as _e } from "@krivega/cancelable-promise";
4
+ import { resolveRequesterByTimeout as Me, requesterByTimeoutsWithFailCalls as fe, DelayRequester as ve, hasCanceledError as Pe, SetTimeoutRequest as ee } from "@krivega/timeout-requester";
5
+ import { hasCanceledError as Oe, repeatedCallsAsync as te } from "repeated-calls";
6
+ import { setup as ye, createActor as be } from "xstate";
7
+ import { createStackPromises as ne, isPromiseIsNotActualError as De } from "stack-promises";
8
8
  import "ua-parser-js";
9
9
  import "sequent-promises";
10
- const Q = "sip-connector", d = x(Q), Wn = () => {
10
+ const Q = "sip-connector", c = x(Q), Wn = () => {
11
11
  x.enable(Q);
12
- }, Hn = () => {
12
+ }, xn = () => {
13
13
  x.enable(`-${Q}`);
14
- }, be = "Error decline with 603", we = 1006, Ue = (n) => typeof n == "object" && n !== null && "code" in n && n.code === we, Le = (n) => n.message === be;
15
- var l = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n))(l || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), q = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(q || {}), P = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.RESTART = "application/vinteo.webrtc.restart", n))(P || {}), _ = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(_ || {}), f = /* @__PURE__ */ ((n) => (n.PAUSE_MAIN_CAM = "PAUSEMAINCAM", n.RESUME_MAIN_CAM = "RESUMEMAINCAM", n.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", n.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", n.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", n))(f || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(W || {}), H = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(H || {}), Be = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Be || {}), u = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n.RESTART = "restart", n))(u || {});
16
- const ne = [
14
+ }, we = "Error decline with 603", Ue = 1006, Le = (n) => typeof n == "object" && n !== null && "code" in n && n.code === Ue, Be = (n) => n.message === we;
15
+ var l = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n))(l || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), V = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(V || {}), P = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.RESTART = "application/vinteo.webrtc.restart", n))(P || {}), _ = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(_ || {}), v = /* @__PURE__ */ ((n) => (n.PAUSE_MAIN_CAM = "PAUSEMAINCAM", n.RESUME_MAIN_CAM = "RESUMEMAINCAM", n.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", n.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", n.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", n))(v || {}), H = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(H || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(W || {}), Fe = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Fe || {}), g = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n.RESTART = "restart", n))(g || {});
16
+ const se = [
17
17
  "participation:accepting-word-request",
18
18
  "participation:cancelling-word-request",
19
19
  "participant:move-request-to-stream",
@@ -43,8 +43,8 @@ const ne = [
43
43
  "newDTMF",
44
44
  "restart"
45
45
  ];
46
- var p = /* @__PURE__ */ ((n) => (n.CHANNELS = "channels", n.WEBCAST_STARTED = "WebcastStarted", n.WEBCAST_STOPPED = "WebcastStopped", n.ACCOUNT_CHANGED = "accountChanged", n.ACCOUNT_DELETED = "accountDeleted", n.ADDED_TO_LIST_MODERATORS = "addedToListModerators", n.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", n.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", n.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", n.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", n))(p || {});
47
- class Fe {
46
+ var I = /* @__PURE__ */ ((n) => (n.CHANNELS = "channels", n.WEBCAST_STARTED = "WebcastStarted", n.WEBCAST_STOPPED = "WebcastStopped", n.ACCOUNT_CHANGED = "accountChanged", n.ACCOUNT_DELETED = "accountDeleted", n.ADDED_TO_LIST_MODERATORS = "addedToListModerators", n.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", n.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", n.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", n.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", n))(I || {});
47
+ class ke {
48
48
  events;
49
49
  connectionManager;
50
50
  callManager;
@@ -52,13 +52,13 @@ class Fe {
52
52
  connectionManager: e,
53
53
  callManager: t
54
54
  }) {
55
- this.connectionManager = e, this.callManager = t, this.events = new k(ne), this.subscribe();
55
+ this.connectionManager = e, this.callManager = t, this.events = new k(se), this.subscribe();
56
56
  }
57
57
  async waitChannels() {
58
- return this.wait(u.CHANNELS);
58
+ return this.wait(g.CHANNELS);
59
59
  }
60
60
  async waitSyncMediaState() {
61
- return this.wait(u.ADMIN_FORCE_SYNC_MEDIA_STATE);
61
+ return this.wait(g.ADMIN_FORCE_SYNC_MEDIA_STATE);
62
62
  }
63
63
  async sendDTMF(e) {
64
64
  return new Promise((t, s) => {
@@ -84,7 +84,7 @@ class Fe {
84
84
  return s.sendInfo(_.CHANNELS, void 0, { extraHeaders: a });
85
85
  }
86
86
  async sendMediaState({ cam: e, mic: t }, s = {}) {
87
- const i = this.getEstablishedRTCSessionProtected(), r = `${l.MEDIA_STATE}: currentstate`, a = `${l.MAIN_CAM_STATE}: ${Number(e)}`, o = `${l.MIC_STATE}: ${Number(t)}`, c = [
87
+ const i = this.getEstablishedRTCSessionProtected(), r = `${l.MEDIA_STATE}: currentstate`, a = `${l.MAIN_CAM_STATE}: ${Number(e)}`, o = `${l.MIC_STATE}: ${Number(t)}`, d = [
88
88
  r,
89
89
  a,
90
90
  o
@@ -92,7 +92,7 @@ class Fe {
92
92
  return i.sendInfo(_.MEDIA_STATE, void 0, {
93
93
  noTerminateWhenError: !0,
94
94
  ...s,
95
- extraHeaders: c
95
+ extraHeaders: d
96
96
  });
97
97
  }
98
98
  async sendStats({
@@ -105,11 +105,11 @@ class Fe {
105
105
  });
106
106
  }
107
107
  async sendRefusalToTurnOn(e, t = {}) {
108
- const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${l.MEDIA_TYPE}: ${a}`];
108
+ const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, d = [`${l.MEDIA_TYPE}: ${a}`];
109
109
  return s.sendInfo(_.REFUSAL, void 0, {
110
110
  noTerminateWhenError: !0,
111
111
  ...t,
112
- extraHeaders: c
112
+ extraHeaders: d
113
113
  });
114
114
  }
115
115
  async sendRefusalToTurnOnMic(e = {}) {
@@ -150,7 +150,7 @@ class Fe {
150
150
  ...e,
151
151
  extraHeaders: s
152
152
  }).catch((i) => {
153
- if (Le(i))
153
+ if (Be(i))
154
154
  throw i;
155
155
  });
156
156
  }
@@ -195,66 +195,66 @@ class Fe {
195
195
  this.handleNotify(s);
196
196
  }
197
197
  } catch (t) {
198
- d("error parse notify", t);
198
+ c("error parse notify", t);
199
199
  }
200
200
  };
201
201
  handleNotify = (e) => {
202
202
  switch (e.cmd) {
203
- case p.CHANNELS: {
203
+ case I.CHANNELS: {
204
204
  const t = e;
205
205
  this.triggerChannelsNotify(t);
206
206
  break;
207
207
  }
208
- case p.WEBCAST_STARTED: {
208
+ case I.WEBCAST_STARTED: {
209
209
  const t = e;
210
210
  this.triggerWebcastStartedNotify(t);
211
211
  break;
212
212
  }
213
- case p.WEBCAST_STOPPED: {
213
+ case I.WEBCAST_STOPPED: {
214
214
  const t = e;
215
215
  this.triggerWebcastStoppedNotify(t);
216
216
  break;
217
217
  }
218
- case p.ADDED_TO_LIST_MODERATORS: {
218
+ case I.ADDED_TO_LIST_MODERATORS: {
219
219
  const t = e;
220
220
  this.triggerAddedToListModeratorsNotify(t);
221
221
  break;
222
222
  }
223
- case p.REMOVED_FROM_LIST_MODERATORS: {
223
+ case I.REMOVED_FROM_LIST_MODERATORS: {
224
224
  const t = e;
225
225
  this.triggerRemovedFromListModeratorsNotify(t);
226
226
  break;
227
227
  }
228
- case p.ACCEPTING_WORD_REQUEST: {
228
+ case I.ACCEPTING_WORD_REQUEST: {
229
229
  const t = e;
230
230
  this.triggerParticipationAcceptingWordRequest(t);
231
231
  break;
232
232
  }
233
- case p.CANCELLING_WORD_REQUEST: {
233
+ case I.CANCELLING_WORD_REQUEST: {
234
234
  const t = e;
235
235
  this.triggerParticipationCancellingWordRequest(t);
236
236
  break;
237
237
  }
238
- case p.MOVE_REQUEST_TO_STREAM: {
238
+ case I.MOVE_REQUEST_TO_STREAM: {
239
239
  const t = e;
240
240
  this.triggerParticipantMoveRequestToStream(t);
241
241
  break;
242
242
  }
243
- case p.ACCOUNT_CHANGED: {
243
+ case I.ACCOUNT_CHANGED: {
244
244
  this.triggerAccountChangedNotify();
245
245
  break;
246
246
  }
247
- case p.ACCOUNT_DELETED: {
247
+ case I.ACCOUNT_DELETED: {
248
248
  this.triggerAccountDeletedNotify();
249
249
  break;
250
250
  }
251
- case p.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
251
+ case I.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
252
252
  const t = e;
253
253
  this.triggerConferenceParticipantTokenIssued(t);
254
254
  break;
255
255
  }
256
256
  default:
257
- d("unknown cmd", e);
257
+ c("unknown cmd", e);
258
258
  }
259
259
  };
260
260
  handleNewInfo = (e) => {
@@ -303,7 +303,7 @@ class Fe {
303
303
  inputChannels: t,
304
304
  outputChannels: s
305
305
  };
306
- this.events.trigger(u.CHANNELS_NOTIFY, i);
306
+ this.events.trigger(g.CHANNELS_NOTIFY, i);
307
307
  };
308
308
  triggerWebcastStartedNotify = ({
309
309
  body: { conference: e, type: t }
@@ -312,7 +312,7 @@ class Fe {
312
312
  conference: e,
313
313
  type: t
314
314
  };
315
- this.events.trigger(u.WEBCAST_STARTED, s);
315
+ this.events.trigger(g.WEBCAST_STARTED, s);
316
316
  };
317
317
  triggerWebcastStoppedNotify = ({
318
318
  body: { conference: e, type: t }
@@ -321,7 +321,7 @@ class Fe {
321
321
  conference: e,
322
322
  type: t
323
323
  };
324
- this.events.trigger(u.WEBCAST_STOPPED, s);
324
+ this.events.trigger(g.WEBCAST_STOPPED, s);
325
325
  };
326
326
  triggerAddedToListModeratorsNotify = ({
327
327
  conference: e
@@ -330,7 +330,7 @@ class Fe {
330
330
  conference: e
331
331
  };
332
332
  this.events.trigger(
333
- u.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
333
+ g.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
334
334
  t
335
335
  );
336
336
  };
@@ -341,7 +341,7 @@ class Fe {
341
341
  conference: e
342
342
  };
343
343
  this.events.trigger(
344
- u.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
344
+ g.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
345
345
  t
346
346
  );
347
347
  };
@@ -351,7 +351,7 @@ class Fe {
351
351
  const t = {
352
352
  conference: e
353
353
  };
354
- this.events.trigger(u.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
354
+ this.events.trigger(g.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
355
355
  };
356
356
  triggerParticipationCancellingWordRequest = ({
357
357
  body: { conference: e }
@@ -359,7 +359,7 @@ class Fe {
359
359
  const t = {
360
360
  conference: e
361
361
  };
362
- this.events.trigger(u.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
362
+ this.events.trigger(g.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
363
363
  };
364
364
  triggerParticipantMoveRequestToStream = ({
365
365
  body: { conference: e }
@@ -367,13 +367,13 @@ class Fe {
367
367
  const t = {
368
368
  conference: e
369
369
  };
370
- this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
370
+ this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
371
371
  };
372
372
  triggerAccountChangedNotify = () => {
373
- this.events.trigger(u.ACCOUNT_CHANGED, void 0);
373
+ this.events.trigger(g.ACCOUNT_CHANGED, void 0);
374
374
  };
375
375
  triggerAccountDeletedNotify = () => {
376
- this.events.trigger(u.ACCOUNT_DELETED, void 0);
376
+ this.events.trigger(g.ACCOUNT_DELETED, void 0);
377
377
  };
378
378
  triggerConferenceParticipantTokenIssued = ({
379
379
  body: { conference: e, participant: t, jwt: s }
@@ -384,7 +384,7 @@ class Fe {
384
384
  jwt: s
385
385
  };
386
386
  this.events.trigger(
387
- u.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
387
+ g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
388
388
  i
389
389
  );
390
390
  };
@@ -395,59 +395,59 @@ class Fe {
395
395
  inputChannels: t,
396
396
  outputChannels: s
397
397
  };
398
- this.events.trigger(u.CHANNELS, i);
398
+ this.events.trigger(g.CHANNELS, i);
399
399
  }
400
400
  };
401
401
  triggerEnterRoom = (e) => {
402
402
  const t = e.getHeader(l.CONTENT_ENTER_ROOM), s = e.getHeader(l.PARTICIPANT_NAME);
403
- this.events.trigger(u.ENTER_ROOM, { room: t, participantName: s });
403
+ this.events.trigger(g.ENTER_ROOM, { room: t, participantName: s });
404
404
  };
405
405
  triggerShareState = (e) => {
406
406
  const t = e.getHeader(l.CONTENT_SHARE_STATE);
407
407
  if (t !== void 0)
408
408
  switch (t) {
409
409
  case B.AVAILABLE_SECOND_REMOTE_STREAM: {
410
- this.events.trigger(u.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
410
+ this.events.trigger(g.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
411
411
  break;
412
412
  }
413
413
  case B.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
414
- this.events.trigger(u.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
414
+ this.events.trigger(g.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
415
415
  break;
416
416
  }
417
417
  case B.MUST_STOP_PRESENTATION: {
418
- this.events.trigger(u.MUST_STOP_PRESENTATION, void 0);
418
+ this.events.trigger(g.MUST_STOP_PRESENTATION, void 0);
419
419
  break;
420
420
  }
421
421
  }
422
422
  };
423
423
  maybeTriggerParticipantMoveRequest = (e) => {
424
424
  const t = e.getHeader(l.CONTENT_PARTICIPANT_STATE);
425
- t === q.SPECTATOR && this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === q.PARTICIPANT && this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
425
+ t === V.SPECTATOR && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === V.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
426
426
  };
427
427
  triggerMainCamControl = (e) => {
428
- const t = e.getHeader(l.MAIN_CAM), s = e.getHeader(l.MEDIA_SYNC), i = s === H.ADMIN_SYNC_FORCED;
429
- if (t === f.ADMIN_START_MAIN_CAM) {
430
- this.events.trigger(u.ADMIN_START_MAIN_CAM, { isSyncForced: i });
428
+ const t = e.getHeader(l.MAIN_CAM), s = e.getHeader(l.MEDIA_SYNC), i = s === W.ADMIN_SYNC_FORCED;
429
+ if (t === v.ADMIN_START_MAIN_CAM) {
430
+ this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
431
431
  return;
432
432
  }
433
- if (t === f.ADMIN_STOP_MAIN_CAM) {
434
- this.events.trigger(u.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
433
+ if (t === v.ADMIN_STOP_MAIN_CAM) {
434
+ this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
435
435
  return;
436
436
  }
437
- (t === f.RESUME_MAIN_CAM || t === f.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(u.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
437
+ (t === v.RESUME_MAIN_CAM || t === v.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
438
438
  const r = e.getHeader(l.MAIN_CAM_RESOLUTION);
439
- this.events.trigger(u.MAIN_CAM_CONTROL, {
439
+ this.events.trigger(g.MAIN_CAM_CONTROL, {
440
440
  mainCam: t,
441
441
  resolutionMainCam: r
442
442
  });
443
443
  };
444
444
  triggerMicControl = (e) => {
445
- const t = e.getHeader(l.MIC), i = e.getHeader(l.MEDIA_SYNC) === H.ADMIN_SYNC_FORCED;
446
- t === W.ADMIN_START_MIC ? this.events.trigger(u.ADMIN_START_MIC, { isSyncForced: i }) : t === W.ADMIN_STOP_MIC && this.events.trigger(u.ADMIN_STOP_MIC, { isSyncForced: i });
445
+ const t = e.getHeader(l.MIC), i = e.getHeader(l.MEDIA_SYNC) === W.ADMIN_SYNC_FORCED;
446
+ t === H.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: i }) : t === H.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: i });
447
447
  };
448
448
  triggerUseLicense = (e) => {
449
449
  const t = e.getHeader(l.CONTENT_USE_LICENSE);
450
- this.events.trigger(u.USE_LICENSE, t);
450
+ this.events.trigger(g.USE_LICENSE, t);
451
451
  };
452
452
  triggerRestart = (e) => {
453
453
  const t = e.getHeader(
@@ -457,11 +457,11 @@ class Fe {
457
457
  ), i = Number(
458
458
  e.getHeader(l.VIDEO_TRACK_COUNT)
459
459
  ), r = { tracksDirection: t, audioTrackCount: s, videoTrackCount: i };
460
- this.events.trigger(u.RESTART, r);
460
+ this.events.trigger(g.RESTART, r);
461
461
  };
462
462
  }
463
- var N = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n.CALL_STATUS_CHANGED = "call-status-changed", n))(N || {}), ke = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(ke || {});
464
- const se = [
463
+ var R = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n.CALL_STATUS_CHANGED = "call-status-changed", n))(R || {}), $e = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))($e || {});
464
+ const ie = [
465
465
  "peerconnection",
466
466
  "connecting",
467
467
  "sending",
@@ -488,14 +488,14 @@ const se = [
488
488
  "peerconnection:createanswerfailed",
489
489
  "peerconnection:setlocaldescriptionfailed",
490
490
  "peerconnection:setremotedescriptionfailed"
491
- ], $e = [
491
+ ], qe = [
492
492
  "peerconnection:confirmed",
493
493
  "peerconnection:ontrack",
494
494
  "ended:fromserver",
495
495
  "call-status-changed"
496
- ], ie = [
497
- ...se,
498
- ...$e
496
+ ], re = [
497
+ ...ie,
498
+ ...qe
499
499
  ], Ve = (n, e) => {
500
500
  n.getVideoTracks().forEach((s) => {
501
501
  "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
@@ -510,14 +510,14 @@ const se = [
510
510
  const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
511
511
  return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && Ve(o, s), o;
512
512
  };
513
- function qe(n) {
513
+ function He(n) {
514
514
  return (e) => `sip:${e}@${n}`;
515
515
  }
516
- const We = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, re = (n) => n.trim().replaceAll(" ", "_"), He = We(1e5, 99999999), xe = (n) => n.some((t) => {
516
+ const We = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, ae = (n) => n.trim().replaceAll(" ", "_"), xe = We(1e5, 99999999), Ge = (n) => n.some((t) => {
517
517
  const { kind: s } = t;
518
518
  return s === "video";
519
519
  });
520
- class Ge {
520
+ class Qe {
521
521
  isPendingCall = !1;
522
522
  isPendingAnswer = !1;
523
523
  rtcSession;
@@ -528,8 +528,8 @@ class Ge {
528
528
  this.events = e;
529
529
  }
530
530
  }
531
- var ae = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(ae || {});
532
- class Qe {
531
+ var oe = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(oe || {});
532
+ class Ye {
533
533
  remoteStreams = {};
534
534
  reset() {
535
535
  this.remoteStreams = {};
@@ -550,19 +550,19 @@ class Qe {
550
550
  const r = s, a = e[i - 1];
551
551
  let o;
552
552
  a?.kind === "audio" && (o = a);
553
- const c = this.generateStream(r, o);
554
- t.push(c);
553
+ const d = this.generateStream(r, o);
554
+ t.push(d);
555
555
  }), t;
556
556
  }
557
557
  generateAudioStreams(e) {
558
558
  return e.map((t) => this.generateAudioStream(t));
559
559
  }
560
560
  }
561
- class Ye extends Ge {
562
- remoteStreamsManager = new Qe();
561
+ class ze extends Qe {
562
+ remoteStreamsManager = new Ye();
563
563
  disposers = /* @__PURE__ */ new Set();
564
564
  constructor(e) {
565
- super(e), e.on(N.FAILED, this.handleEnded), e.on(N.ENDED, this.handleEnded);
565
+ super(e), e.on(R.FAILED, this.handleEnded), e.on(R.ENDED, this.handleEnded);
566
566
  }
567
567
  get requested() {
568
568
  return this.isPendingCall || this.isPendingAnswer;
@@ -582,20 +582,20 @@ class Ye extends Ge {
582
582
  extraHeaders: r = [],
583
583
  ontrack: a,
584
584
  iceServers: o,
585
- directionVideo: c,
585
+ directionVideo: d,
586
586
  directionAudio: h,
587
587
  contentHint: T,
588
588
  offerToReceiveAudio: S = !0,
589
- offerToReceiveVideo: g = !0,
589
+ offerToReceiveVideo: u = !0,
590
590
  degradationPreference: E,
591
591
  sendEncodings: m,
592
- onAddedTransceiver: I
593
- }) => (this.isPendingCall = !0, new Promise((R, D) => {
594
- this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(R).catch(($) => {
595
- D($);
592
+ onAddedTransceiver: p
593
+ }) => (this.isPendingCall = !0, new Promise((N, b) => {
594
+ this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(N).catch(($) => {
595
+ b($);
596
596
  }), this.rtcSession = e.call(t(s), {
597
597
  mediaStream: F(i, {
598
- directionVideo: c,
598
+ directionVideo: d,
599
599
  directionAudio: h,
600
600
  contentHint: T
601
601
  }),
@@ -604,18 +604,18 @@ class Ye extends Ge {
604
604
  },
605
605
  rtcOfferConstraints: {
606
606
  offerToReceiveAudio: S,
607
- offerToReceiveVideo: g
607
+ offerToReceiveVideo: u
608
608
  },
609
609
  // необходимо передавать в методе call, чтобы подписаться на события peerconnection,
610
610
  // так как в методе call создается RTCSession
611
611
  // и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
612
612
  eventHandlers: this.events.triggers,
613
613
  extraHeaders: r,
614
- directionVideo: c,
614
+ directionVideo: d,
615
615
  directionAudio: h,
616
616
  degradationPreference: E,
617
617
  sendEncodings: m,
618
- onAddedTransceiver: I
618
+ onAddedTransceiver: p
619
619
  });
620
620
  }).finally(() => {
621
621
  this.isPendingCall = !1;
@@ -624,7 +624,7 @@ class Ye extends Ge {
624
624
  const { rtcSession: e } = this;
625
625
  if (e && !e.isEnded())
626
626
  return e.terminateAsync({
627
- cause: ae.CANCELED
627
+ cause: oe.CANCELED
628
628
  }).finally(() => {
629
629
  this.reset();
630
630
  });
@@ -637,23 +637,23 @@ class Ye extends Ge {
637
637
  iceServers: r,
638
638
  directionVideo: a,
639
639
  directionAudio: o,
640
- offerToReceiveAudio: c,
640
+ offerToReceiveAudio: d,
641
641
  offerToReceiveVideo: h,
642
642
  contentHint: T,
643
643
  degradationPreference: S,
644
- sendEncodings: g,
644
+ sendEncodings: u,
645
645
  onAddedTransceiver: E
646
- }) => (this.isPendingAnswer = !0, new Promise((m, I) => {
646
+ }) => (this.isPendingAnswer = !0, new Promise((m, p) => {
647
647
  try {
648
- const R = e();
649
- this.rtcSession = R, this.subscribeToSessionEvents(R), this.callConfiguration.answer = !0, this.callConfiguration.number = R.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(m).catch((D) => {
650
- I(D);
651
- }), R.answer({
648
+ const N = e();
649
+ this.rtcSession = N, this.subscribeToSessionEvents(N), this.callConfiguration.answer = !0, this.callConfiguration.number = N.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(m).catch((b) => {
650
+ p(b);
651
+ }), N.answer({
652
652
  pcConfig: {
653
653
  iceServers: r
654
654
  },
655
655
  rtcOfferConstraints: {
656
- offerToReceiveAudio: c,
656
+ offerToReceiveAudio: d,
657
657
  offerToReceiveVideo: h
658
658
  },
659
659
  mediaStream: F(t, {
@@ -665,11 +665,11 @@ class Ye extends Ge {
665
665
  directionVideo: a,
666
666
  directionAudio: o,
667
667
  degradationPreference: S,
668
- sendEncodings: g,
668
+ sendEncodings: u,
669
669
  onAddedTransceiver: E
670
670
  });
671
- } catch (R) {
672
- I(R);
671
+ } catch (N) {
672
+ p(N);
673
673
  }
674
674
  }).finally(() => {
675
675
  this.isPendingAnswer = !1;
@@ -684,7 +684,7 @@ class Ye extends Ge {
684
684
  if (!this.connection)
685
685
  return;
686
686
  const t = this.connection.getReceivers().map(({ track: s }) => s);
687
- return xe(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
687
+ return Ge(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
688
688
  }
689
689
  async replaceMediaStream(e, t) {
690
690
  if (!this.rtcSession)
@@ -708,33 +708,33 @@ class Ye extends Ge {
708
708
  ontrack: e
709
709
  }) => new Promise((t, s) => {
710
710
  const i = () => {
711
- this.events.on(N.PEER_CONNECTION, T), this.events.on(N.CONFIRMED, S);
711
+ this.events.on(R.PEER_CONNECTION, T), this.events.on(R.CONFIRMED, S);
712
712
  }, r = () => {
713
- this.events.off(N.PEER_CONNECTION, T), this.events.off(N.CONFIRMED, S);
713
+ this.events.off(R.PEER_CONNECTION, T), this.events.off(R.CONFIRMED, S);
714
714
  }, a = () => {
715
- this.events.on(N.FAILED, c), this.events.on(N.ENDED, c);
715
+ this.events.on(R.FAILED, d), this.events.on(R.ENDED, d);
716
716
  }, o = () => {
717
- this.events.off(N.FAILED, c), this.events.off(N.ENDED, c);
718
- }, c = (g) => {
719
- r(), o(), s(g);
717
+ this.events.off(R.FAILED, d), this.events.off(R.ENDED, d);
718
+ }, d = (u) => {
719
+ r(), o(), s(u);
720
720
  };
721
721
  let h;
722
- const T = ({ peerconnection: g }) => {
723
- h = g;
722
+ const T = ({ peerconnection: u }) => {
723
+ h = u;
724
724
  const E = (m) => {
725
- this.events.trigger(N.PEER_CONNECTION_ONTRACK, m), e && e(m);
725
+ this.events.trigger(R.PEER_CONNECTION_ONTRACK, m), e && e(m);
726
726
  };
727
- g.addEventListener("track", E), this.disposers.add(() => {
728
- g.removeEventListener("track", E);
727
+ u.addEventListener("track", E), this.disposers.add(() => {
728
+ u.removeEventListener("track", E);
729
729
  });
730
730
  }, S = () => {
731
- h !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, h), r(), o(), t(h);
731
+ h !== void 0 && this.events.trigger(R.PEER_CONNECTION_CONFIRMED, h), r(), o(), t(h);
732
732
  };
733
733
  i(), a();
734
734
  });
735
735
  subscribeToSessionEvents(e) {
736
736
  this.events.eachTriggers((t, s) => {
737
- const i = se.find((r) => r === s);
737
+ const i = ie.find((r) => r === s);
738
738
  i && (e.on(i, t), this.disposers.add(() => {
739
739
  e.off(i, t);
740
740
  }));
@@ -747,17 +747,17 @@ class Ye extends Ge {
747
747
  }
748
748
  handleEnded = (e) => {
749
749
  const { originator: t } = e;
750
- t === "remote" && this.events.trigger(N.ENDED_FROM_SERVER, e), this.reset();
750
+ t === "remote" && this.events.trigger(R.ENDED_FROM_SERVER, e), this.reset();
751
751
  };
752
752
  reset = () => {
753
753
  delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
754
754
  };
755
755
  }
756
- class ze {
756
+ class Xe {
757
757
  events;
758
758
  strategy;
759
759
  constructor(e) {
760
- this.events = new U(ie), this.strategy = e ?? new Ye(this.events), this.subscribeCallStatusChange();
760
+ this.events = new U(re), this.strategy = e ?? new ze(this.events), this.subscribeCallStatusChange();
761
761
  }
762
762
  get requested() {
763
763
  return this.strategy.requested;
@@ -803,49 +803,49 @@ class ze {
803
803
  restartIce = async (e) => this.strategy.restartIce(e);
804
804
  subscribeCallStatusChange() {
805
805
  let { isCallActive: e } = this;
806
- const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } = N;
806
+ const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } = R;
807
807
  this.onRace([t, s, i, r], () => {
808
808
  e = this.maybeTriggerCallStatus(e);
809
809
  });
810
810
  }
811
811
  maybeTriggerCallStatus(e) {
812
812
  const t = this.isCallActive;
813
- return t !== e && this.events.trigger(N.CALL_STATUS_CHANGED, { isCallActive: t }), t;
813
+ return t !== e && this.events.trigger(R.CALL_STATUS_CHANGED, { isCallActive: t }), t;
814
814
  }
815
815
  }
816
- const Xe = (n, e) => (n.degradationPreference = e.degradationPreference, n), Je = (n, e) => {
816
+ const Je = (n, e) => (n.degradationPreference = e.degradationPreference, n), Ke = (n, e) => {
817
817
  n.encodings ??= [];
818
818
  for (let t = n.encodings.length; t < e; t += 1)
819
819
  n.encodings.push({});
820
820
  return n;
821
- }, oe = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Ke = oe(), je = (n, e) => {
822
- if (Ke(n, e))
821
+ }, ce = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, je = ce(), Ze = (n, e) => {
822
+ if (je(n, e))
823
823
  return n;
824
- }, Ze = (n, e) => {
825
- const t = n.maxBitrate, s = je(e, t);
824
+ }, et = (n, e) => {
825
+ const t = n.maxBitrate, s = Ze(e, t);
826
826
  return s !== void 0 && (n.maxBitrate = s), n;
827
- }, ce = 1, et = oe(
828
- ce
829
- ), tt = (n, e) => {
830
- const t = n === void 0 ? void 0 : Math.max(n, ce);
831
- if (t !== void 0 && et(
827
+ }, de = 1, tt = ce(
828
+ de
829
+ ), nt = (n, e) => {
830
+ const t = n === void 0 ? void 0 : Math.max(n, de);
831
+ if (t !== void 0 && tt(
832
832
  t,
833
833
  e
834
834
  ))
835
835
  return t;
836
- }, nt = (n, e) => {
837
- const t = n.scaleResolutionDownBy, s = tt(
836
+ }, st = (n, e) => {
837
+ const t = n.scaleResolutionDownBy, s = nt(
838
838
  e,
839
839
  t
840
840
  );
841
841
  return s !== void 0 && (n.scaleResolutionDownBy = s), n;
842
- }, st = (n, e) => {
842
+ }, it = (n, e) => {
843
843
  const t = e.encodings?.length ?? 0;
844
- return Je(n, t), n.encodings.forEach((s, i) => {
844
+ return Ke(n, t), n.encodings.forEach((s, i) => {
845
845
  const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
846
- Ze(s, a), nt(s, o);
846
+ et(s, a), st(s, o);
847
847
  }), n;
848
- }, it = (n, e) => {
848
+ }, rt = (n, e) => {
849
849
  if (n.codecs?.length !== e.codecs?.length)
850
850
  return !0;
851
851
  for (let t = 0; t < (n.codecs?.length ?? 0); t++)
@@ -862,15 +862,15 @@ const Xe = (n, e) => (n.degradationPreference = e.degradationPreference, n), Je
862
862
  if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
863
863
  return !0;
864
864
  return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
865
- }, rt = async (n, e) => {
865
+ }, at = async (n, e) => {
866
866
  const t = n.getParameters(), s = JSON.parse(
867
867
  JSON.stringify(t)
868
868
  );
869
- st(t, e), Xe(t, e);
870
- const i = it(s, t);
869
+ it(t, e), Je(t, e);
870
+ const i = rt(s, t);
871
871
  return i && await n.setParameters(t), { parameters: t, isChanged: i };
872
- }, de = async (n, e, t) => {
873
- const { isChanged: s, parameters: i } = await rt(n, {
872
+ }, he = async (n, e, t) => {
873
+ const { isChanged: s, parameters: i } = await at(n, {
874
874
  encodings: [
875
875
  {
876
876
  scaleResolutionDownBy: e.scaleResolutionDownBy,
@@ -879,20 +879,20 @@ const Xe = (n, e) => (n.degradationPreference = e.degradationPreference, n), Je
879
879
  ]
880
880
  });
881
881
  return s && t && t(i), { isChanged: s, parameters: i };
882
- }, at = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), ot = async (n, e, t) => {
883
- const s = at(n, e);
882
+ }, ot = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), ct = async (n, e, t) => {
883
+ const s = ot(n, e);
884
884
  if (s)
885
- return de(s, { maxBitrate: t });
885
+ return he(s, { maxBitrate: t });
886
886
  };
887
887
  var O = /* @__PURE__ */ ((n) => (n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n))(O || {});
888
- const he = [
888
+ const le = [
889
889
  "presentation:start",
890
890
  "presentation:started",
891
891
  "presentation:end",
892
892
  "presentation:ended",
893
893
  "presentation:failed"
894
- ], ct = 1, xn = (n) => Pe(n);
895
- class dt {
894
+ ], dt = 1, Gn = (n) => Oe(n);
895
+ class ht {
896
896
  events;
897
897
  promisePendingStartPresentation;
898
898
  promisePendingStopPresentation;
@@ -904,7 +904,7 @@ class dt {
904
904
  callManager: e,
905
905
  maxBitrate: t
906
906
  }) {
907
- this.callManager = e, this.maxBitrate = t, this.events = new k(he), this.subscribe();
907
+ this.callManager = e, this.maxBitrate = t, this.events = new k(le), this.subscribe();
908
908
  }
909
909
  get isPendingPresentation() {
910
910
  return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
@@ -916,11 +916,11 @@ class dt {
916
916
  sendEncodings: r,
917
917
  onAddedTransceiver: a
918
918
  } = {}, o) {
919
- const c = this.getRtcSessionProtected();
919
+ const d = this.getRtcSessionProtected();
920
920
  if (this.streamPresentationCurrent)
921
921
  throw new Error("Presentation is already started");
922
922
  return this.sendPresentationWithDuplicatedCalls(e, {
923
- rtcSession: c,
923
+ rtcSession: d,
924
924
  stream: t,
925
925
  presentationOptions: {
926
926
  isNeedReinvite: s,
@@ -999,7 +999,7 @@ class dt {
999
999
  stream: s,
1000
1000
  presentationOptions: i,
1001
1001
  options: r = {
1002
- callLimit: ct
1002
+ callLimit: dt
1003
1003
  }
1004
1004
  }) {
1005
1005
  const a = async () => this.sendPresentation(
@@ -1008,12 +1008,12 @@ class dt {
1008
1008
  s,
1009
1009
  i
1010
1010
  ), o = () => !!this.streamPresentationCurrent;
1011
- return this.cancelableSendPresentationWithRepeatedCalls = ee({
1011
+ return this.cancelableSendPresentationWithRepeatedCalls = te({
1012
1012
  targetFunction: a,
1013
1013
  isComplete: o,
1014
1014
  isRejectAsValid: !0,
1015
1015
  ...r
1016
- }), this.cancelableSendPresentationWithRepeatedCalls.then((c) => c);
1016
+ }), this.cancelableSendPresentationWithRepeatedCalls.then((d) => d);
1017
1017
  }
1018
1018
  // eslint-disable-next-line @typescript-eslint/max-params
1019
1019
  async sendPresentation(e, t, s, {
@@ -1021,7 +1021,7 @@ class dt {
1021
1021
  contentHint: r = "detail",
1022
1022
  degradationPreference: a,
1023
1023
  sendEncodings: o,
1024
- onAddedTransceiver: c
1024
+ onAddedTransceiver: d
1025
1025
  }) {
1026
1026
  const h = F(s, { contentHint: r });
1027
1027
  if (h === void 0)
@@ -1030,7 +1030,7 @@ class dt {
1030
1030
  const T = e().then(async () => t.startPresentation(h, i, {
1031
1031
  degradationPreference: a,
1032
1032
  sendEncodings: o,
1033
- onAddedTransceiver: c
1033
+ onAddedTransceiver: d
1034
1034
  })).then(this.setMaxBitrate).then(() => s).catch((S) => {
1035
1035
  throw this.removeStreamPresentationCurrent(), this.events.trigger(O.FAILED_PRESENTATION, S), S;
1036
1036
  });
@@ -1043,7 +1043,7 @@ class dt {
1043
1043
  if (!e || !t || s === void 0)
1044
1044
  return;
1045
1045
  const i = e.getSenders();
1046
- await ot(i, t, s);
1046
+ await ct(i, t, s);
1047
1047
  };
1048
1048
  getRtcSessionProtected = () => {
1049
1049
  const e = this.callManager.getEstablishedRTCSession();
@@ -1064,7 +1064,7 @@ class dt {
1064
1064
  delete this.streamPresentationCurrent;
1065
1065
  }
1066
1066
  }
1067
- class ht {
1067
+ class lt {
1068
1068
  data;
1069
1069
  getUa;
1070
1070
  constructor(e) {
@@ -1145,7 +1145,7 @@ class ht {
1145
1145
  }
1146
1146
  }
1147
1147
  var C = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.DISCONNECTING = "disconnecting", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n.CONNECT_STARTED = "connect-started", n.CONNECT_SUCCEEDED = "connect-succeeded", n.CONNECT_FAILED = "connect-failed", n.CONNECT_PARAMETERS_RESOLVE_SUCCESS = "connect-parameters-resolve-success", n.CONNECT_PARAMETERS_RESOLVE_FAILED = "connect-parameters-resolve-failed", n))(C || {});
1148
- const le = [
1148
+ const ue = [
1149
1149
  "connecting",
1150
1150
  "connected",
1151
1151
  "disconnected",
@@ -1155,15 +1155,15 @@ const le = [
1155
1155
  "registrationFailed",
1156
1156
  "newMessage",
1157
1157
  "sipEvent"
1158
- ], lt = [
1158
+ ], ut = [
1159
1159
  "disconnecting",
1160
1160
  "connect-started",
1161
1161
  "connect-succeeded",
1162
1162
  "connect-failed",
1163
1163
  "connect-parameters-resolve-success",
1164
1164
  "connect-parameters-resolve-failed"
1165
- ], ge = [...le, ...lt], gt = 3;
1166
- class ut {
1165
+ ], ge = [...ue, ...ut], gt = 3;
1166
+ class Tt {
1167
1167
  cancelableConnectWithRepeatedCalls;
1168
1168
  JsSIP;
1169
1169
  events;
@@ -1189,7 +1189,7 @@ class ut {
1189
1189
  }
1190
1190
  let r = !1;
1191
1191
  const a = this.getConnectionConfiguration();
1192
- e !== void 0 && e !== a?.displayName && (r = i.set("display_name", re(e)), this.updateConnectionConfiguration("displayName", e));
1192
+ e !== void 0 && e !== a?.displayName && (r = i.set("display_name", ae(e)), this.updateConnectionConfiguration("displayName", e));
1193
1193
  const o = r;
1194
1194
  o ? t(o) : s(new Error("nothing changed"));
1195
1195
  });
@@ -1209,10 +1209,10 @@ class ut {
1209
1209
  }
1210
1210
  connectWithDuplicatedCalls = async (e, { callLimit: t = gt } = {}) => {
1211
1211
  const s = async () => this.connectInner(e), i = (r) => {
1212
- const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), h = r != null && !Ue(r);
1213
- return c || h;
1212
+ const d = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), h = r != null && !Le(r);
1213
+ return d || h;
1214
1214
  };
1215
- return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ee({
1215
+ return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = te({
1216
1216
  targetFunction: s,
1217
1217
  isComplete: i,
1218
1218
  callLimit: t,
@@ -1245,31 +1245,31 @@ class ut {
1245
1245
  remoteAddress: r,
1246
1246
  sessionTimers: a,
1247
1247
  registerExpires: o,
1248
- connectionRecoveryMinInterval: c,
1248
+ connectionRecoveryMinInterval: d,
1249
1249
  connectionRecoveryMaxInterval: h,
1250
1250
  userAgent: T,
1251
1251
  displayName: S = "",
1252
- register: g = !1,
1252
+ register: u = !1,
1253
1253
  extraHeaders: E = []
1254
1254
  }) => {
1255
1255
  this.stateMachine.startInitUa(), this.setConnectionConfiguration({
1256
1256
  sipServerUrl: s,
1257
1257
  displayName: S,
1258
- register: g,
1258
+ register: u,
1259
1259
  user: e,
1260
1260
  password: t
1261
1261
  }), this.getUa() && await this.disconnect();
1262
- const { ua: I, helpers: R } = this.uaFactory.createUAWithConfiguration(
1262
+ const { ua: p, helpers: N } = this.uaFactory.createUAWithConfiguration(
1263
1263
  {
1264
1264
  user: e,
1265
1265
  password: t,
1266
1266
  sipServerUrl: s,
1267
1267
  sipWebSocketServerURL: i,
1268
1268
  displayName: S,
1269
- register: g,
1269
+ register: u,
1270
1270
  sessionTimers: a,
1271
1271
  registerExpires: o,
1272
- connectionRecoveryMinInterval: c,
1272
+ connectionRecoveryMinInterval: d,
1273
1273
  connectionRecoveryMaxInterval: h,
1274
1274
  userAgent: T,
1275
1275
  remoteAddress: r,
@@ -1277,7 +1277,7 @@ class ut {
1277
1277
  },
1278
1278
  this.events
1279
1279
  );
1280
- return this.setUa(I), this.setSipServerUrl(R.getSipServerUrl), this.setSocket(R.socket), I;
1280
+ return this.setUa(p), this.setSipServerUrl(N.getSipServerUrl), this.setSocket(N.socket), p;
1281
1281
  };
1282
1282
  start = async () => new Promise((e, t) => {
1283
1283
  const s = this.getUa();
@@ -1286,39 +1286,39 @@ class ut {
1286
1286
  return;
1287
1287
  }
1288
1288
  let i;
1289
- i = ((c, h) => {
1289
+ i = ((d, h) => {
1290
1290
  if (this.getConnectionConfiguration()?.register === !0)
1291
- return this.registrationManager.subscribeToStartEvents(c, h);
1292
- const S = C.CONNECTED, g = [C.DISCONNECTED];
1293
- return this.events.on(S, c), g.forEach((E) => {
1291
+ return this.registrationManager.subscribeToStartEvents(d, h);
1292
+ const S = C.CONNECTED, u = [C.DISCONNECTED];
1293
+ return this.events.on(S, d), u.forEach((E) => {
1294
1294
  this.events.on(E, h);
1295
1295
  }), () => {
1296
- this.events.off(S, c), g.forEach((E) => {
1296
+ this.events.off(S, d), u.forEach((E) => {
1297
1297
  this.events.off(E, h);
1298
1298
  });
1299
1299
  };
1300
1300
  })(() => {
1301
1301
  i?.(), e(s);
1302
- }, (c) => {
1303
- i?.(), t(c);
1302
+ }, (d) => {
1303
+ i?.(), t(d);
1304
1304
  }), s.start();
1305
1305
  });
1306
1306
  cancelConnectWithRepeatedCalls() {
1307
1307
  this.cancelableConnectWithRepeatedCalls?.cancel();
1308
1308
  }
1309
1309
  }
1310
- var ue = /* @__PURE__ */ ((n) => (n.START_CONNECT = "START_CONNECT", n.START_INIT_UA = "START_INIT_UA", n.UA_CONNECTED = "UA_CONNECTED", n.UA_REGISTERED = "UA_REGISTERED", n.UA_UNREGISTERED = "UA_UNREGISTERED", n.UA_DISCONNECTED = "UA_DISCONNECTED", n.CONNECTION_FAILED = "CONNECTION_FAILED", n.RESET = "RESET", n))(ue || {});
1311
- const Tt = Oe({
1310
+ var Te = /* @__PURE__ */ ((n) => (n.START_CONNECT = "START_CONNECT", n.START_INIT_UA = "START_INIT_UA", n.UA_CONNECTED = "UA_CONNECTED", n.UA_REGISTERED = "UA_REGISTERED", n.UA_UNREGISTERED = "UA_UNREGISTERED", n.UA_DISCONNECTED = "UA_DISCONNECTED", n.CONNECTION_FAILED = "CONNECTION_FAILED", n.RESET = "RESET", n))(Te || {});
1311
+ const St = ye({
1312
1312
  types: {
1313
1313
  context: {},
1314
1314
  events: {}
1315
1315
  },
1316
1316
  actions: {
1317
1317
  logTransition: (n, e) => {
1318
- d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1318
+ c(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1319
1319
  },
1320
1320
  logStateChange: (n, e) => {
1321
- d("ConnectionStateMachine state changed", e.state);
1321
+ c("ConnectionStateMachine state changed", e.state);
1322
1322
  }
1323
1323
  }
1324
1324
  }).createMachine({
@@ -1622,14 +1622,14 @@ const Tt = Oe({
1622
1622
  }
1623
1623
  }
1624
1624
  });
1625
- class St {
1625
+ class Ct {
1626
1626
  actor;
1627
1627
  stateChangeListeners = /* @__PURE__ */ new Set();
1628
1628
  events;
1629
1629
  unsubscribeFromEvents;
1630
1630
  actorSubscription;
1631
1631
  constructor(e) {
1632
- this.events = e, this.actor = ye(Tt), this.actorSubscription = this.actor.subscribe((t) => {
1632
+ this.events = e, this.actor = be(St), this.actorSubscription = this.actor.subscribe((t) => {
1633
1633
  const s = t.value;
1634
1634
  this.stateChangeListeners.forEach((i) => {
1635
1635
  i(s);
@@ -1715,7 +1715,7 @@ class St {
1715
1715
  return this.actor.getSnapshot().can({ type: e });
1716
1716
  }
1717
1717
  getValidEvents() {
1718
- return Object.values(ue).filter((e) => this.canTransition(e));
1718
+ return Object.values(Te).filter((e) => this.canTransition(e));
1719
1719
  }
1720
1720
  hasState(e) {
1721
1721
  return this.actor.getSnapshot().matches(e);
@@ -1723,7 +1723,7 @@ class St {
1723
1723
  sendEvent(e) {
1724
1724
  const t = this.actor.getSnapshot(), s = { type: e };
1725
1725
  if (!t.can(s)) {
1726
- d(
1726
+ c(
1727
1727
  `Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
1728
1728
  );
1729
1729
  return;
@@ -1784,7 +1784,7 @@ class St {
1784
1784
  };
1785
1785
  }
1786
1786
  }
1787
- class Ct {
1787
+ class Et {
1788
1788
  events;
1789
1789
  getUaProtected;
1790
1790
  constructor(e) {
@@ -1806,7 +1806,7 @@ class Ct {
1806
1806
  try {
1807
1807
  await this.unregister();
1808
1808
  } catch (e) {
1809
- d("tryRegister", e);
1809
+ c("tryRegister", e);
1810
1810
  }
1811
1811
  return this.register();
1812
1812
  }
@@ -1821,7 +1821,7 @@ class Ct {
1821
1821
  };
1822
1822
  }
1823
1823
  }
1824
- class Et {
1824
+ class At {
1825
1825
  uaFactory;
1826
1826
  getUaProtected;
1827
1827
  constructor(e) {
@@ -1866,7 +1866,7 @@ class Et {
1866
1866
  remoteAddress: r,
1867
1867
  extraHeaders: a
1868
1868
  }) {
1869
- return new Promise((o, c) => {
1869
+ return new Promise((o, d) => {
1870
1870
  const { configuration: h } = this.uaFactory.createConfiguration({
1871
1871
  sipWebSocketServerURL: i,
1872
1872
  displayName: t,
@@ -1874,19 +1874,19 @@ class Et {
1874
1874
  sipServerUrl: s
1875
1875
  }), T = this.uaFactory.createUA({ ...h, remoteAddress: r, extraHeaders: a }), S = () => {
1876
1876
  const E = new Error("Telephony is not available");
1877
- c(E);
1877
+ d(E);
1878
1878
  };
1879
1879
  T.once(C.DISCONNECTED, S);
1880
- const g = () => {
1880
+ const u = () => {
1881
1881
  T.removeAllListeners(), T.once(C.DISCONNECTED, () => {
1882
1882
  o();
1883
1883
  }), T.stop();
1884
1884
  };
1885
- T.once(C.CONNECTED, g), T.start();
1885
+ T.once(C.CONNECTED, u), T.start();
1886
1886
  });
1887
1887
  }
1888
1888
  }
1889
- const At = (n) => {
1889
+ const Rt = (n) => {
1890
1890
  const e = [];
1891
1891
  return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
1892
1892
  };
@@ -1915,10 +1915,10 @@ class y {
1915
1915
  throw new Error("user is required for authorized connection");
1916
1916
  }
1917
1917
  static resolveAuthorizationUser(e, t) {
1918
- return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${He()}`;
1918
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${xe()}`;
1919
1919
  }
1920
1920
  static buildExtraHeaders(e, t) {
1921
- const s = e !== void 0 && e !== "" ? At(e) : [];
1921
+ const s = e !== void 0 && e !== "" ? Rt(e) : [];
1922
1922
  return t === void 0 ? s : [...s, ...t];
1923
1923
  }
1924
1924
  createConfiguration({
@@ -1929,7 +1929,7 @@ class y {
1929
1929
  sipServerUrl: r,
1930
1930
  register: a = !1,
1931
1931
  sessionTimers: o = !1,
1932
- registerExpires: c = 300,
1932
+ registerExpires: d = 300,
1933
1933
  // 5 minutes in sec
1934
1934
  connectionRecoveryMinInterval: h = 2,
1935
1935
  connectionRecoveryMaxInterval: T = 6,
@@ -1942,23 +1942,23 @@ class y {
1942
1942
  sipServerUrl: r,
1943
1943
  sipWebSocketServerURL: s
1944
1944
  });
1945
- const g = y.resolveAuthorizationUser(a, e), E = qe(r), m = E(g), I = new this.JsSIP.WebSocketInterface(s);
1945
+ const u = y.resolveAuthorizationUser(a, e), E = He(r), m = E(u), p = new this.JsSIP.WebSocketInterface(s);
1946
1946
  return {
1947
1947
  configuration: {
1948
1948
  password: t,
1949
1949
  register: a,
1950
1950
  uri: m,
1951
- display_name: re(i),
1951
+ display_name: ae(i),
1952
1952
  user_agent: S,
1953
1953
  sdpSemantics: "unified-plan",
1954
- sockets: [I],
1954
+ sockets: [p],
1955
1955
  session_timers: o,
1956
- register_expires: c,
1956
+ register_expires: d,
1957
1957
  connection_recovery_min_interval: h,
1958
1958
  connection_recovery_max_interval: T
1959
1959
  },
1960
1960
  helpers: {
1961
- socket: I,
1961
+ socket: p,
1962
1962
  getSipServerUrl: E
1963
1963
  }
1964
1964
  };
@@ -1977,13 +1977,13 @@ class y {
1977
1977
  extraHeaders: e.extraHeaders
1978
1978
  });
1979
1979
  return t.eachTriggers((a, o) => {
1980
- const c = le.find((h) => h === o);
1981
- c && r.on(c, a);
1980
+ const d = ue.find((h) => h === o);
1981
+ d && r.on(d, a);
1982
1982
  }), { ua: r, helpers: i };
1983
1983
  }
1984
1984
  }
1985
- const Te = "Not ready for connection", Nt = (n) => n instanceof Error && n.message === Te, Rt = () => new Error(Te), It = async (n) => typeof n == "function" ? n() : n;
1986
- class pt {
1985
+ const Se = "Not ready for connection", Nt = (n) => n instanceof Error && n.message === Se, pt = () => new Error(Se), It = async (n) => typeof n == "function" ? n() : n;
1986
+ class mt {
1987
1987
  events;
1988
1988
  ua;
1989
1989
  socket;
@@ -1995,15 +1995,15 @@ class pt {
1995
1995
  configurationManager;
1996
1996
  JsSIP;
1997
1997
  constructor({ JsSIP: e }) {
1998
- this.JsSIP = e, this.events = new U(ge), this.uaFactory = new y(e), this.registrationManager = new Ct({
1998
+ this.JsSIP = e, this.events = new U(ge), this.uaFactory = new y(e), this.registrationManager = new Et({
1999
1999
  events: this.events,
2000
2000
  getUaProtected: this.getUaProtected
2001
- }), this.stateMachine = new St(this.events), this.configurationManager = new ht({
2001
+ }), this.stateMachine = new Ct(this.events), this.configurationManager = new lt({
2002
2002
  getUa: this.getUa
2003
- }), this.sipOperations = new Et({
2003
+ }), this.sipOperations = new At({
2004
2004
  uaFactory: this.uaFactory,
2005
2005
  getUaProtected: this.getUaProtected
2006
- }), this.connectionFlow = new ut({
2006
+ }), this.connectionFlow = new Tt({
2007
2007
  JsSIP: this.JsSIP,
2008
2008
  events: this.events,
2009
2009
  uaFactory: this.uaFactory,
@@ -2056,7 +2056,7 @@ class pt {
2056
2056
  return this.configurationManager.isRegister();
2057
2057
  }
2058
2058
  connect = async (e, t) => this.disconnect().catch((s) => {
2059
- d("connect: disconnect error", s);
2059
+ c("connect: disconnect error", s);
2060
2060
  }).then(async () => this.connectWithProcessError(e, t));
2061
2061
  set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
2062
2062
  disconnect = async () => {
@@ -2105,7 +2105,7 @@ class pt {
2105
2105
  getUa = () => this.ua;
2106
2106
  connectWithProcessError = async (e, t) => {
2107
2107
  if (!(t?.hasReadyForConnection?.() ?? !0))
2108
- throw Rt();
2108
+ throw pt();
2109
2109
  return this.processConnect(e, t).catch(async (i) => {
2110
2110
  const r = i;
2111
2111
  return this.disconnect().then(() => {
@@ -2124,9 +2124,9 @@ class pt {
2124
2124
  throw this.events.trigger(C.CONNECT_FAILED, i), i;
2125
2125
  }));
2126
2126
  }
2127
- class mt {
2127
+ class _t {
2128
2128
  connectionManager;
2129
- stackPromises = te({
2129
+ stackPromises = ne({
2130
2130
  noRunIsNotActual: !0
2131
2131
  });
2132
2132
  constructor({ connectionManager: e }) {
@@ -2138,11 +2138,11 @@ class mt {
2138
2138
  this.stackPromises.stop();
2139
2139
  }
2140
2140
  }
2141
- const z = 0, _t = 30;
2142
- class Mt {
2141
+ const z = 0, Mt = 30;
2142
+ class ft {
2143
2143
  countInner = z;
2144
2144
  initialCount = z;
2145
- limitInner = _t;
2145
+ limitInner = Mt;
2146
2146
  isInProgress = !1;
2147
2147
  onStatusChange;
2148
2148
  constructor({
@@ -2191,7 +2191,7 @@ class vt {
2191
2191
  onSuccessRequest: t,
2192
2192
  onFailRequest: s
2193
2193
  }) {
2194
- this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = _e({
2194
+ this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = Me({
2195
2195
  isDontStopOnFail: !0,
2196
2196
  requestInterval: this.interval,
2197
2197
  request: async () => {
@@ -2212,7 +2212,7 @@ class vt {
2212
2212
  }
2213
2213
  }
2214
2214
  var M = /* @__PURE__ */ ((n) => (n.BEFORE_ATTEMPT = "before-attempt", n.SUCCESS = "success", n.FAILED_ALL_ATTEMPTS = "failed-all-attempts", n.CANCELLED_ATTEMPTS = "cancelled-attempts", n.CHANGED_ATTEMPT_STATUS = "changed-attempt-status", n.STOP_ATTEMPTS_BY_ERROR = "stop-attempts-by-error", n.LIMIT_REACHED_ATTEMPTS = "limit-reached-attempts", n))(M || {});
2215
- const Se = [
2215
+ const Ce = [
2216
2216
  "before-attempt",
2217
2217
  "success",
2218
2218
  "failed-all-attempts",
@@ -2220,28 +2220,28 @@ const Se = [
2220
2220
  "changed-attempt-status",
2221
2221
  "stop-attempts-by-error",
2222
2222
  "limit-reached-attempts"
2223
- ], ft = 15e3, Pt = 2;
2224
- class Ot {
2223
+ ], Pt = 15e3, Ot = 2;
2224
+ class yt {
2225
2225
  connectionManager;
2226
2226
  pingServerByTimeoutWithFailCalls;
2227
2227
  constructor({ connectionManager: e }) {
2228
- this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Me(Pt, {
2228
+ this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = fe(Ot, {
2229
2229
  whenPossibleRequest: async () => {
2230
2230
  },
2231
- requestInterval: ft,
2232
- request: async () => (d("ping"), this.connectionManager.ping().then(() => {
2233
- d("ping success");
2231
+ requestInterval: Pt,
2232
+ request: async () => (c("ping"), this.connectionManager.ping().then(() => {
2233
+ c("ping success");
2234
2234
  }))
2235
2235
  });
2236
2236
  }
2237
2237
  start({ onFailRequest: e }) {
2238
- this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(d);
2238
+ this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(c);
2239
2239
  }
2240
2240
  stop() {
2241
2241
  this.pingServerByTimeoutWithFailCalls.stop();
2242
2242
  }
2243
2243
  }
2244
- class yt {
2244
+ class bt {
2245
2245
  callManager;
2246
2246
  pingServerRequester;
2247
2247
  disposeCallStatusChange;
@@ -2249,17 +2249,17 @@ class yt {
2249
2249
  connectionManager: e,
2250
2250
  callManager: t
2251
2251
  }) {
2252
- this.callManager = t, this.pingServerRequester = new Ot({
2252
+ this.callManager = t, this.pingServerRequester = new yt({
2253
2253
  connectionManager: e
2254
2254
  });
2255
2255
  }
2256
2256
  start({ onFailRequest: e }) {
2257
- d("start"), this.disposeCallStatusChange = this.callManager.on("call-status-changed", () => {
2257
+ c("start"), this.disposeCallStatusChange = this.callManager.on("call-status-changed", () => {
2258
2258
  this.handleCallStatusChange({ onFailRequest: e });
2259
2259
  }), this.handleCallStatusChange({ onFailRequest: e });
2260
2260
  }
2261
2261
  stop() {
2262
- d("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
2262
+ c("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
2263
2263
  }
2264
2264
  unsubscribeCallStatusChange() {
2265
2265
  this.disposeCallStatusChange?.(), this.disposeCallStatusChange = void 0;
@@ -2302,9 +2302,12 @@ class Dt {
2302
2302
  this.isRegistrationFailed = !1;
2303
2303
  }
2304
2304
  }
2305
- const bt = 3e3, wt = 15e3, Ut = async () => {
2306
- }, Lt = (n) => !0;
2307
- class Bt {
2305
+ const wt = 3e3, Ut = 15e3, X = {
2306
+ LIMIT_REACHED: "Limit reached",
2307
+ FAILED_TO_RECONNECT: "Failed to reconnect"
2308
+ }, Lt = async () => {
2309
+ }, Bt = (n) => !0;
2310
+ class Ft {
2308
2311
  events;
2309
2312
  connectionManager;
2310
2313
  connectionQueueManager;
@@ -2316,36 +2319,34 @@ class Bt {
2316
2319
  cancelableRequestBeforeRetry;
2317
2320
  onBeforeRetry;
2318
2321
  canRetryOnError;
2322
+ networkInterfacesSubscriber;
2323
+ resumeFromSleepModeSubscriber;
2319
2324
  constructor({
2320
2325
  connectionQueueManager: e,
2321
2326
  connectionManager: t,
2322
2327
  callManager: s
2323
2328
  }, i) {
2324
- const r = i?.onBeforeRetry ?? Ut, a = i?.canRetryOnError ?? Lt;
2325
- this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.events = new U(Se), this.checkTelephonyRequester = new vt({
2329
+ const r = i?.onBeforeRetry ?? Lt, a = i?.canRetryOnError ?? Bt;
2330
+ this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = new U(Ce), this.checkTelephonyRequester = new vt({
2326
2331
  connectionManager: t,
2327
- interval: i?.checkTelephonyRequestInterval ?? wt
2328
- }), this.pingServerIfNotActiveCallRequester = new yt({
2332
+ interval: i?.checkTelephonyRequestInterval ?? Ut
2333
+ }), this.pingServerIfNotActiveCallRequester = new bt({
2329
2334
  connectionManager: t,
2330
2335
  callManager: s
2331
2336
  }), this.registrationFailedOutOfCallSubscriber = new Dt({
2332
2337
  connectionManager: t,
2333
2338
  callManager: s
2334
- }), this.attemptsState = new Mt({
2339
+ }), this.attemptsState = new ft({
2335
2340
  onStatusChange: this.emitStatusChange
2336
2341
  }), this.cancelableRequestBeforeRetry = new G(r), this.delayBetweenAttempts = new ve(
2337
- i?.timeoutBetweenAttempts ?? bt
2342
+ i?.timeoutBetweenAttempts ?? wt
2338
2343
  );
2339
2344
  }
2340
2345
  start(e) {
2341
- d("auto connector start"), this.stop(), this.connect(e).catch((t) => {
2342
- d("auto connector failed to connect:", t);
2343
- });
2346
+ c("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToHardwareTriggers(e);
2344
2347
  }
2345
2348
  stop() {
2346
- d("auto connector stop"), this.stopAttempts(), this.stopConnectTriggers(), this.connectionQueueManager.disconnect().catch((e) => {
2347
- d("auto connector disconnect: error", e);
2348
- });
2349
+ c("auto connector stop"), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow();
2349
2350
  }
2350
2351
  on(e, t) {
2351
2352
  return this.events.on(e, t);
@@ -2362,75 +2363,111 @@ class Bt {
2362
2363
  off(e, t) {
2363
2364
  this.events.off(e, t);
2364
2365
  }
2366
+ restartConnectionAttempts(e) {
2367
+ c("auto connector restart connection attempts"), this.stopConnectionFlow(), this.attemptConnection(e).catch((t) => {
2368
+ c("auto connector failed to connect:", t);
2369
+ });
2370
+ }
2371
+ stopConnectionFlow() {
2372
+ c("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), this.connectionQueueManager.disconnect().catch((e) => {
2373
+ c("auto connector disconnect: error", e);
2374
+ });
2375
+ }
2365
2376
  stopAttempts() {
2366
2377
  this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
2367
2378
  }
2368
2379
  stopConnectTriggers() {
2369
- d("stopConnectTriggers"), this.pingServerIfNotActiveCallRequester.stop(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
2380
+ c("stopConnectTriggers"), this.stopPingRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
2370
2381
  }
2371
- runCheckTelephony(e) {
2372
- d("runCheckTelephony"), this.checkTelephonyRequester.start({
2382
+ startCheckTelephony(e) {
2383
+ c("startCheckTelephony"), this.checkTelephonyRequester.start({
2373
2384
  onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
2374
2385
  onSuccessRequest: () => {
2375
- d("runCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
2386
+ c("startCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
2376
2387
  },
2377
2388
  onFailRequest: (t) => {
2378
- d("runCheckTelephony: onFailRequest", t.message);
2389
+ c("startCheckTelephony: onFailRequest", t.message);
2379
2390
  }
2380
2391
  });
2381
2392
  }
2382
- async connect(e) {
2383
- if (d("connect: attempts.count", this.attemptsState.count), this.events.trigger(M.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
2384
- d("connect: isLimitReached!"), this.handleLimitReached(e);
2393
+ async attemptConnection(e) {
2394
+ if (c("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(M.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
2395
+ c("attemptConnection: limit reached"), this.handleLimitReached(e);
2385
2396
  return;
2386
2397
  }
2387
- return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.processConnect(e);
2398
+ return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.executeConnectionAttempt(e);
2388
2399
  }
2389
- async processConnect(e) {
2400
+ async executeConnectionAttempt(e) {
2390
2401
  try {
2391
- await this.connectionQueueManager.connect(e.getParameters, e.options), d("processConnect success"), this.handleSucceededAttempt(e);
2402
+ await this.connectionQueueManager.connect(e.getParameters, e.options), c("executeConnectionAttempt: success"), this.handleSucceededAttempt(e);
2392
2403
  } catch (t) {
2393
- if (Nt(t)) {
2394
- this.attemptsState.finishAttempt(), this.handleSucceededAttempt(e);
2395
- return;
2396
- }
2397
- if (!this.canRetryOnError(t)) {
2398
- d("processConnect: error does not allow retry", t), this.attemptsState.finishAttempt(), this.events.trigger(M.STOP_ATTEMPTS_BY_ERROR, t);
2399
- return;
2400
- }
2401
- if (De(t)) {
2402
- d("processConnect: not actual error", t), this.attemptsState.finishAttempt(), this.events.trigger(M.CANCELLED_ATTEMPTS, t);
2403
- return;
2404
- }
2405
- d("processConnect: error", t), this.reconnect(e);
2404
+ this.handleConnectionError(t, e);
2405
+ }
2406
+ }
2407
+ handleConnectionError(e, t) {
2408
+ if (Nt(e)) {
2409
+ this.attemptsState.finishAttempt(), this.handleSucceededAttempt(t);
2410
+ return;
2411
+ }
2412
+ if (!this.canRetryOnError(e)) {
2413
+ c("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(M.STOP_ATTEMPTS_BY_ERROR, e);
2414
+ return;
2415
+ }
2416
+ if (De(e)) {
2417
+ c("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(M.CANCELLED_ATTEMPTS, e);
2418
+ return;
2406
2419
  }
2420
+ c("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
2407
2421
  }
2408
2422
  handleLimitReached(e) {
2409
- this.attemptsState.finishAttempt(), this.events.trigger(M.LIMIT_REACHED_ATTEMPTS, new Error("Limit reached")), this.runCheckTelephony(e);
2423
+ this.attemptsState.finishAttempt(), this.events.trigger(M.LIMIT_REACHED_ATTEMPTS, new Error(X.LIMIT_REACHED)), this.startCheckTelephony(e);
2410
2424
  }
2411
2425
  handleSucceededAttempt(e) {
2412
- d("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(M.SUCCESS);
2426
+ c("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(M.SUCCESS);
2413
2427
  }
2414
2428
  subscribeToConnectTriggers(e) {
2429
+ this.startPingRequester(e), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
2430
+ c("registrationFailedOutOfCallListener callback"), this.restartConnectionAttempts(e);
2431
+ });
2432
+ }
2433
+ subscribeToHardwareTriggers(e) {
2434
+ this.unsubscribeFromHardwareTriggers(), c("subscribeToHardwareTriggers"), this.networkInterfacesSubscriber?.subscribe({
2435
+ onChange: () => {
2436
+ c("networkInterfacesSubscriber onChange"), this.restartConnectionAttempts(e);
2437
+ },
2438
+ onUnavailable: () => {
2439
+ c("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow();
2440
+ }
2441
+ }), this.resumeFromSleepModeSubscriber?.subscribe({
2442
+ onResume: () => {
2443
+ c("resumeFromSleepModeSubscriber onResume"), this.restartConnectionAttempts(e);
2444
+ }
2445
+ });
2446
+ }
2447
+ unsubscribeFromHardwareTriggers() {
2448
+ c("unsubscribeFromHardwareTriggers"), this.networkInterfacesSubscriber?.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
2449
+ }
2450
+ stopPingRequester() {
2451
+ this.pingServerIfNotActiveCallRequester.stop();
2452
+ }
2453
+ startPingRequester(e) {
2415
2454
  this.pingServerIfNotActiveCallRequester.start({
2416
2455
  onFailRequest: () => {
2417
- d("pingServer onFailRequest"), this.start(e);
2456
+ c("pingRequester: onFailRequest"), this.restartConnectionAttempts(e);
2418
2457
  }
2419
- }), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
2420
- d("registrationFailedOutOfCallListener callback"), this.start(e);
2421
2458
  });
2422
2459
  }
2423
2460
  connectIfDisconnected(e) {
2424
- const t = this.hasFailedOrDisconnectedConnection();
2425
- d("connectIfDisconnected: isFailedOrDisconnected", t), t ? this.start(e) : (this.stopConnectTriggers(), this.events.trigger(M.SUCCESS));
2461
+ const t = this.isConnectionUnavailable();
2462
+ c("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(M.SUCCESS));
2426
2463
  }
2427
- reconnect(e) {
2428
- d("reconnect"), this.delayBetweenAttempts.request().then(async () => (d("reconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (d("reconnect: onBeforeRetry success"), this.connect(e))).catch((t) => {
2429
- const s = t instanceof Error ? t : new Error("Failed to reconnect");
2430
- this.attemptsState.finishAttempt(), me(t) || fe(t) ? this.events.trigger(M.CANCELLED_ATTEMPTS, s) : this.events.trigger(M.FAILED_ALL_ATTEMPTS, s), d("reconnect: error", t);
2464
+ scheduleReconnect(e) {
2465
+ c("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (c("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (c("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
2466
+ const s = t instanceof Error ? t : new Error(X.FAILED_TO_RECONNECT);
2467
+ this.attemptsState.finishAttempt(), _e(t) || Pe(t) ? this.events.trigger(M.CANCELLED_ATTEMPTS, s) : this.events.trigger(M.FAILED_ALL_ATTEMPTS, s), c("scheduleReconnect: error", t);
2431
2468
  });
2432
2469
  }
2433
- hasFailedOrDisconnectedConnection() {
2470
+ isConnectionUnavailable() {
2434
2471
  const { isFailed: e, isDisconnected: t, isIdle: s } = this.connectionManager;
2435
2472
  return e || t || s;
2436
2473
  }
@@ -2439,18 +2476,18 @@ class Bt {
2439
2476
  };
2440
2477
  }
2441
2478
  var w = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(w || {});
2442
- const Ce = [
2479
+ const Ee = [
2443
2480
  "incomingCall",
2444
2481
  "declinedIncomingCall",
2445
2482
  "terminatedIncomingCall",
2446
2483
  "failedIncomingCall"
2447
- ], Ft = 486, kt = 487;
2448
- class $t {
2484
+ ], kt = 486, $t = 487;
2485
+ class qt {
2449
2486
  events;
2450
2487
  incomingRTCSession;
2451
2488
  connectionManager;
2452
2489
  constructor(e) {
2453
- this.connectionManager = e, this.events = new k(Ce), this.start();
2490
+ this.connectionManager = e, this.events = new k(Ee), this.start();
2454
2491
  }
2455
2492
  get remoteCallerData() {
2456
2493
  return {
@@ -2480,7 +2517,7 @@ class $t {
2480
2517
  return this.removeIncomingSession(), e;
2481
2518
  };
2482
2519
  async declineToIncomingCall({
2483
- statusCode: e = kt
2520
+ statusCode: e = $t
2484
2521
  } = {}) {
2485
2522
  return new Promise((t, s) => {
2486
2523
  try {
@@ -2492,7 +2529,7 @@ class $t {
2492
2529
  });
2493
2530
  }
2494
2531
  async busyIncomingCall() {
2495
- return this.declineToIncomingCall({ statusCode: Ft });
2532
+ return this.declineToIncomingCall({ statusCode: kt });
2496
2533
  }
2497
2534
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2498
2535
  on(e, t) {
@@ -2536,9 +2573,9 @@ class $t {
2536
2573
  delete this.incomingRTCSession;
2537
2574
  }
2538
2575
  }
2539
- const b = 1e3;
2576
+ const D = 1e3;
2540
2577
  var A = /* @__PURE__ */ ((n) => (n.INBOUND_RTP = "inbound-rtp", n.REMOTE_OUTBOUND_RTP = "remote-outbound-rtp", n.MEDIA_SOURCE = "media-source", n.OUTBOUND_RTP = "outbound-rtp", n.REMOTE_INBOUND_RTP = "remote-inbound-rtp", n.CODEC = "codec", n.CANDIDATE_PAIR = "candidate-pair", n.CERTIFICATE = "certificate", n.TRANSPORT = "transport", n.LOCAL_CANDIDATE = "local-candidate", n.REMOTE_CANDIDATE = "remote-candidate", n))(A || {});
2541
- const Ee = ["collected"], X = () => "performance" in window ? performance.now() : Date.now(), L = (n) => [...n.keys()].reduce((e, t) => {
2578
+ const Ae = ["collected"], J = () => "performance" in window ? performance.now() : Date.now(), L = (n) => [...n.keys()].reduce((e, t) => {
2542
2579
  const s = n.get(t);
2543
2580
  return s === void 0 ? e : { ...e, [s.type]: s };
2544
2581
  }, {}), Vt = (n) => {
@@ -2556,7 +2593,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
2556
2593
  mediaSource: e[A.MEDIA_SOURCE],
2557
2594
  remoteInboundRtp: e[A.REMOTE_INBOUND_RTP]
2558
2595
  };
2559
- }, J = (n) => {
2596
+ }, K = (n) => {
2560
2597
  if (!n)
2561
2598
  return {
2562
2599
  outboundRtp: void 0,
@@ -2571,7 +2608,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
2571
2608
  mediaSource: e[A.MEDIA_SOURCE],
2572
2609
  remoteInboundRtp: e[A.REMOTE_INBOUND_RTP]
2573
2610
  };
2574
- }, K = ({
2611
+ }, j = ({
2575
2612
  videoReceiversStats: n,
2576
2613
  synchronizationSourcesVideo: e
2577
2614
  }) => {
@@ -2587,7 +2624,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
2587
2624
  codec: t[A.CODEC],
2588
2625
  synchronizationSources: e
2589
2626
  };
2590
- }, qt = ({
2627
+ }, Ht = ({
2591
2628
  audioReceiverStats: n,
2592
2629
  synchronizationSourcesAudio: e
2593
2630
  }) => {
@@ -2605,7 +2642,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
2605
2642
  remoteOutboundRtp: t[A.REMOTE_OUTBOUND_RTP],
2606
2643
  synchronizationSources: e
2607
2644
  };
2608
- }, Ae = (n) => {
2645
+ }, Re = (n) => {
2609
2646
  if (!n)
2610
2647
  return {
2611
2648
  candidatePair: void 0,
@@ -2627,34 +2664,34 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
2627
2664
  videoSenderFirstStats: e,
2628
2665
  videoSenderSecondStats: t
2629
2666
  }) => ({
2630
- video: J(e),
2631
- secondVideo: J(t),
2667
+ video: K(e),
2668
+ secondVideo: K(t),
2632
2669
  audio: Vt(n),
2633
- additional: Ae(
2670
+ additional: Re(
2634
2671
  n ?? e ?? t
2635
2672
  )
2636
- }), Ht = ({
2673
+ }), xt = ({
2637
2674
  audioReceiverStats: n,
2638
2675
  videoReceiverFirstStats: e,
2639
2676
  videoReceiverSecondStats: t,
2640
2677
  synchronizationSources: s
2641
2678
  }) => ({
2642
- video: K({
2679
+ video: j({
2643
2680
  videoReceiversStats: e,
2644
2681
  synchronizationSourcesVideo: s.video
2645
2682
  }),
2646
- secondVideo: K({
2683
+ secondVideo: j({
2647
2684
  videoReceiversStats: t,
2648
2685
  synchronizationSourcesVideo: s.video
2649
2686
  }),
2650
- audio: qt({
2687
+ audio: Ht({
2651
2688
  audioReceiverStats: n,
2652
2689
  synchronizationSourcesAudio: s.audio
2653
2690
  }),
2654
- additional: Ae(
2691
+ additional: Re(
2655
2692
  n ?? e ?? t
2656
2693
  )
2657
- }), xt = ({
2694
+ }), Gt = ({
2658
2695
  audioSenderStats: n,
2659
2696
  videoSenderFirstStats: e,
2660
2697
  videoSenderSecondStats: t,
@@ -2667,7 +2704,7 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
2667
2704
  audioSenderStats: n,
2668
2705
  videoSenderFirstStats: e,
2669
2706
  videoSenderSecondStats: t
2670
- }), c = Ht({
2707
+ }), d = xt({
2671
2708
  audioReceiverStats: s,
2672
2709
  videoReceiverFirstStats: i,
2673
2710
  videoReceiverSecondStats: r,
@@ -2675,15 +2712,15 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
2675
2712
  });
2676
2713
  return {
2677
2714
  outbound: o,
2678
- inbound: c
2715
+ inbound: d
2679
2716
  };
2680
- }, Gt = async (n) => {
2681
- const e = "audio", t = "video", s = n.getSenders(), i = s.find((g) => g.track?.kind === e), r = s.filter((g) => g.track?.kind === t), a = n.getReceivers(), o = a.find((g) => g.track.kind === e), c = a.filter((g) => g.track.kind === t), h = {
2717
+ }, Qt = async (n) => {
2718
+ const e = "audio", t = "video", s = n.getSenders(), i = s.find((u) => u.track?.kind === e), r = s.filter((u) => u.track?.kind === t), a = n.getReceivers(), o = a.find((u) => u.track.kind === e), d = a.filter((u) => u.track.kind === t), h = {
2682
2719
  trackIdentifier: o?.track.id,
2683
2720
  item: o?.getSynchronizationSources()[0]
2684
2721
  }, T = {
2685
- trackIdentifier: c[0]?.track.id,
2686
- item: c[0]?.getSynchronizationSources()[0]
2722
+ trackIdentifier: d[0]?.track.id,
2723
+ item: d[0]?.getSynchronizationSources()[0]
2687
2724
  }, S = {
2688
2725
  audio: h,
2689
2726
  video: T
@@ -2693,43 +2730,43 @@ const Ee = ["collected"], X = () => "performance" in window ? performance.now()
2693
2730
  r[0]?.getStats() ?? Promise.resolve(void 0),
2694
2731
  r[1]?.getStats() ?? Promise.resolve(void 0),
2695
2732
  o?.getStats() ?? Promise.resolve(void 0),
2696
- c[0]?.getStats() ?? Promise.resolve(void 0),
2697
- c[1]?.getStats() ?? Promise.resolve(void 0)
2698
- ]).then((g) => {
2733
+ d[0]?.getStats() ?? Promise.resolve(void 0),
2734
+ d[1]?.getStats() ?? Promise.resolve(void 0)
2735
+ ]).then((u) => {
2699
2736
  const [
2700
2737
  E,
2701
2738
  m,
2702
- I,
2703
- R,
2704
- D,
2739
+ p,
2740
+ N,
2741
+ b,
2705
2742
  $
2706
- ] = g;
2743
+ ] = u;
2707
2744
  return {
2708
2745
  synchronizationSources: S,
2709
2746
  audioSenderStats: E,
2710
2747
  videoSenderFirstStats: m,
2711
- videoSenderSecondStats: I,
2712
- audioReceiverStats: R,
2713
- videoReceiverFirstStats: D,
2748
+ videoSenderSecondStats: p,
2749
+ audioReceiverStats: N,
2750
+ videoReceiverFirstStats: b,
2714
2751
  videoReceiverSecondStats: $
2715
2752
  };
2716
2753
  });
2717
- }, Qt = (n) => {
2718
- d(String(n));
2754
+ }, Yt = (n) => {
2755
+ c(String(n));
2719
2756
  };
2720
- class Yt {
2757
+ class zt {
2721
2758
  events;
2722
2759
  setTimeoutRequest;
2723
- requesterAllStatistics = new G(Gt);
2760
+ requesterAllStatistics = new G(Qt);
2724
2761
  constructor() {
2725
- this.events = new U(Ee), this.setTimeoutRequest = new Z();
2762
+ this.events = new U(Ae), this.setTimeoutRequest = new ee();
2726
2763
  }
2727
2764
  get requested() {
2728
2765
  return this.setTimeoutRequest.requested;
2729
2766
  }
2730
2767
  start(e, {
2731
- interval: t = b,
2732
- onError: s = Qt
2768
+ interval: t = D,
2769
+ onError: s = Yt
2733
2770
  } = {}) {
2734
2771
  this.stop(), this.setTimeoutRequest.request(() => {
2735
2772
  this.collectStatistics(e, {
@@ -2758,12 +2795,12 @@ class Yt {
2758
2795
  collectStatistics = (e, {
2759
2796
  onError: t
2760
2797
  }) => {
2761
- const s = X();
2798
+ const s = J();
2762
2799
  this.requesterAllStatistics.request(e).then((i) => {
2763
- this.events.trigger("collected", xt(i));
2764
- const a = X() - s;
2765
- let o = b;
2766
- a > 48 ? o = b * 4 : a > 32 ? o = b * 3 : a > 16 && (o = b * 2), this.start(e, {
2800
+ this.events.trigger("collected", Gt(i));
2801
+ const a = J() - s;
2802
+ let o = D;
2803
+ a > 48 ? o = D * 4 : a > 32 ? o = D * 3 : a > 16 && (o = D * 2), this.start(e, {
2767
2804
  onError: t,
2768
2805
  interval: o
2769
2806
  });
@@ -2772,7 +2809,7 @@ class Yt {
2772
2809
  });
2773
2810
  };
2774
2811
  }
2775
- class zt {
2812
+ class Xt {
2776
2813
  availableIncomingBitrate;
2777
2814
  statsPeerConnection;
2778
2815
  callManager;
@@ -2782,7 +2819,7 @@ class zt {
2782
2819
  callManager: e,
2783
2820
  apiManager: t
2784
2821
  }) {
2785
- this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Yt(), this.subscribe();
2822
+ this.callManager = e, this.apiManager = t, this.statsPeerConnection = new zt(), this.subscribe();
2786
2823
  }
2787
2824
  get events() {
2788
2825
  return this.statsPeerConnection.events;
@@ -2820,30 +2857,30 @@ class zt {
2820
2857
  };
2821
2858
  maybeSendStats() {
2822
2859
  this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
2823
- d("Failed to send stats", e);
2860
+ c("Failed to send stats", e);
2824
2861
  });
2825
2862
  }
2826
2863
  }
2827
- const Xt = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), Jt = (n) => {
2864
+ const Jt = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), Kt = (n) => {
2828
2865
  const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
2829
- return Xt(s, i);
2830
- }, Kt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
2866
+ return Jt(s, i);
2867
+ }, jt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
2831
2868
  const i = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), a = i === -1 ? Number.MAX_VALUE : i, o = r === -1 ? Number.MAX_VALUE : r;
2832
2869
  return a - o;
2833
- }), jt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Zt = (n, {
2870
+ }), Zt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), en = (n, {
2834
2871
  preferredMimeTypesVideoCodecs: e,
2835
2872
  excludeMimeTypesVideoCodecs: t
2836
2873
  }) => {
2837
2874
  try {
2838
2875
  if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
2839
- const s = Jt("video"), i = jt(s, t), r = Kt(i, e);
2876
+ const s = Kt("video"), i = Zt(s, t), r = jt(i, e);
2840
2877
  n.setCodecPreferences(r);
2841
2878
  }
2842
2879
  } catch (s) {
2843
- d("setCodecPreferences error", s);
2880
+ c("setCodecPreferences error", s);
2844
2881
  }
2845
2882
  };
2846
- class en {
2883
+ class tn {
2847
2884
  /**
2848
2885
  * Хранилище основных transceiver'ов
2849
2886
  */
@@ -2922,10 +2959,10 @@ class en {
2922
2959
  */
2923
2960
  handleRestart = (e) => {
2924
2961
  this.updateTransceivers(e).catch((t) => {
2925
- d("Failed to update transceivers", t);
2962
+ c("Failed to update transceivers", t);
2926
2963
  }).finally(() => {
2927
2964
  this.callManager.restartIce().catch((t) => {
2928
- d("Failed to restart ICE", t);
2965
+ c("Failed to restart ICE", t);
2929
2966
  });
2930
2967
  });
2931
2968
  };
@@ -2937,7 +2974,7 @@ class en {
2937
2974
  t === 2 && (this.getTransceivers().presentationVideo !== void 0 || await this.callManager.addTransceiver("video", {
2938
2975
  direction: "recvonly"
2939
2976
  }).catch((r) => {
2940
- d("Failed to add presentation video transceiver", r);
2977
+ c("Failed to add presentation video transceiver", r);
2941
2978
  }));
2942
2979
  };
2943
2980
  subscribe() {
@@ -2950,15 +2987,15 @@ class en {
2950
2987
  this.clear();
2951
2988
  };
2952
2989
  }
2953
- const tn = (n) => [...n.keys()].map((e) => n.get(e)), nn = (n, e) => tn(n).find((t) => t?.type === e), sn = async (n) => n.getStats().then((e) => nn(e, "codec")?.mimeType);
2954
- class rn {
2990
+ const nn = (n) => [...n.keys()].map((e) => n.get(e)), sn = (n, e) => nn(n).find((t) => t?.type === e), rn = async (n) => n.getStats().then((e) => sn(e, "codec")?.mimeType);
2991
+ class an {
2955
2992
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
2956
2993
  async getCodecFromSender(e) {
2957
- return await sn(e) ?? "";
2994
+ return await rn(e) ?? "";
2958
2995
  }
2959
2996
  }
2960
- class an {
2961
- stackPromises = te({
2997
+ class on {
2998
+ stackPromises = ne({
2962
2999
  noRunIsNotActual: !0
2963
3000
  });
2964
3001
  /**
@@ -2978,34 +3015,34 @@ class an {
2978
3015
  */
2979
3016
  async run() {
2980
3017
  return this.stackPromises().catch((e) => {
2981
- d("TaskQueue: error", e);
3018
+ c("TaskQueue: error", e);
2982
3019
  });
2983
3020
  }
2984
3021
  }
2985
- class on {
3022
+ class cn {
2986
3023
  taskQueue;
2987
3024
  onSetParameters;
2988
3025
  constructor(e) {
2989
- this.onSetParameters = e, this.taskQueue = new an();
3026
+ this.onSetParameters = e, this.taskQueue = new on();
2990
3027
  }
2991
3028
  async setEncodingsToSender(e, t) {
2992
- return this.taskQueue.add(async () => de(e, t, this.onSetParameters));
3029
+ return this.taskQueue.add(async () => he(e, t, this.onSetParameters));
2993
3030
  }
2994
3031
  stop() {
2995
3032
  this.taskQueue.stop();
2996
3033
  }
2997
3034
  }
2998
- const Ne = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), cn = 1e6, v = (n) => n * cn, Re = v(0.06), Ie = v(4), dn = (n) => n <= 64 ? Re : n <= 128 ? v(0.12) : n <= 256 ? v(0.25) : n <= 384 ? v(0.32) : n <= 426 ? v(0.38) : n <= 640 ? v(0.5) : n <= 848 ? v(0.7) : n <= 1280 ? v(1) : n <= 1920 ? v(2) : Ie, hn = "av1", ln = (n) => Ne(n, hn), gn = 0.6, Y = (n, e) => ln(e) ? n * gn : n, un = (n) => Y(Re, n), Tn = (n) => Y(Ie, n), j = (n, e) => {
2999
- const t = dn(n);
3035
+ const Ne = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), dn = 1e6, f = (n) => n * dn, pe = f(0.06), Ie = f(4), hn = (n) => n <= 64 ? pe : n <= 128 ? f(0.12) : n <= 256 ? f(0.25) : n <= 384 ? f(0.32) : n <= 426 ? f(0.38) : n <= 640 ? f(0.5) : n <= 848 ? f(0.7) : n <= 1280 ? f(1) : n <= 1920 ? f(2) : Ie, ln = "av1", un = (n) => Ne(n, ln), gn = 0.6, Y = (n, e) => un(e) ? n * gn : n, Tn = (n) => Y(pe, n), Sn = (n) => Y(Ie, n), Z = (n, e) => {
3036
+ const t = hn(n);
3000
3037
  return Y(t, e);
3001
- }, V = 1, Sn = ({
3038
+ }, q = 1, Cn = ({
3002
3039
  videoTrack: n,
3003
3040
  targetSize: e
3004
3041
  }) => {
3005
- const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? V : s / e.width, a = i === void 0 ? V : i / e.height;
3006
- return Math.max(r, a, V);
3042
+ const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? q : s / e.width, a = i === void 0 ? q : i / e.height;
3043
+ return Math.max(r, a, q);
3007
3044
  };
3008
- class Cn {
3045
+ class En {
3009
3046
  ignoreForCodec;
3010
3047
  senderFinder;
3011
3048
  codecProvider;
@@ -3048,7 +3085,7 @@ class Cn {
3048
3085
  codec: r,
3049
3086
  videoTrack: i.track
3050
3087
  }
3051
- ).then((c) => ({ ...c, sender: i }));
3088
+ ).then((d) => ({ ...d, sender: i }));
3052
3089
  }
3053
3090
  /**
3054
3091
  * Обрабатывает отправитель в зависимости от команды управления
@@ -3058,14 +3095,14 @@ class Cn {
3058
3095
  async processSender(e, t) {
3059
3096
  const { mainCam: s, resolutionMainCam: i } = e;
3060
3097
  switch (s) {
3061
- case f.PAUSE_MAIN_CAM:
3098
+ case v.PAUSE_MAIN_CAM:
3062
3099
  return this.downgradeResolutionSender(t);
3063
- case f.RESUME_MAIN_CAM:
3100
+ case v.RESUME_MAIN_CAM:
3064
3101
  return this.setBitrateByTrackResolution(t);
3065
- case f.MAX_MAIN_CAM_RESOLUTION:
3102
+ case v.MAX_MAIN_CAM_RESOLUTION:
3066
3103
  return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
3067
- case f.ADMIN_STOP_MAIN_CAM:
3068
- case f.ADMIN_START_MAIN_CAM:
3104
+ case v.ADMIN_STOP_MAIN_CAM:
3105
+ case v.ADMIN_START_MAIN_CAM:
3069
3106
  case void 0:
3070
3107
  return this.setBitrateByTrackResolution(t);
3071
3108
  default:
@@ -3080,7 +3117,7 @@ class Cn {
3080
3117
  async downgradeResolutionSender(e) {
3081
3118
  const { sender: t, codec: s } = e, i = {
3082
3119
  scaleResolutionDownBy: 200,
3083
- maxBitrate: un(s)
3120
+ maxBitrate: Tn(s)
3084
3121
  };
3085
3122
  return this.parametersSetter.setEncodingsToSender(t, i);
3086
3123
  }
@@ -3090,7 +3127,7 @@ class Cn {
3090
3127
  * @returns Promise с результатом
3091
3128
  */
3092
3129
  async setBitrateByTrackResolution(e) {
3093
- const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? Tn(i) : j(a, i);
3130
+ const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? Sn(i) : Z(a, i);
3094
3131
  return this.parametersSetter.setEncodingsToSender(t, {
3095
3132
  scaleResolutionDownBy: 1,
3096
3133
  maxBitrate: o
@@ -3103,24 +3140,24 @@ class Cn {
3103
3140
  * @returns Promise с результатом
3104
3141
  */
3105
3142
  async setResolutionSender(e, t) {
3106
- const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
3143
+ const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, d = {
3107
3144
  width: Number(s),
3108
3145
  height: Number(i)
3109
- }, h = Sn({
3146
+ }, h = Cn({
3110
3147
  videoTrack: a,
3111
- targetSize: c
3112
- }), T = j(c.width, o), S = {
3148
+ targetSize: d
3149
+ }), T = Z(d.width, o), S = {
3113
3150
  scaleResolutionDownBy: h,
3114
3151
  maxBitrate: T
3115
3152
  };
3116
3153
  return this.parametersSetter.setEncodingsToSender(r, S);
3117
3154
  }
3118
3155
  }
3119
- const En = (n) => n.find((e) => e.track?.kind === "video");
3120
- class An {
3156
+ const An = (n) => n.find((e) => e.track?.kind === "video");
3157
+ class Rn {
3121
3158
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
3122
3159
  findVideoSender(e) {
3123
- return En(e);
3160
+ return An(e);
3124
3161
  }
3125
3162
  }
3126
3163
  class Nn {
@@ -3136,7 +3173,7 @@ class Nn {
3136
3173
  pollIntervalMs: e = 1e3,
3137
3174
  maxPollIntervalMs: t
3138
3175
  }) {
3139
- this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new Z();
3176
+ this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ee();
3140
3177
  }
3141
3178
  /**
3142
3179
  * Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
@@ -3187,7 +3224,7 @@ class Nn {
3187
3224
  this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
3188
3225
  }
3189
3226
  }
3190
- class Rn {
3227
+ class pn {
3191
3228
  apiManager;
3192
3229
  currentHandler;
3193
3230
  constructor(e) {
@@ -3219,10 +3256,10 @@ class In {
3219
3256
  onSetParameters: i,
3220
3257
  pollIntervalMs: r
3221
3258
  } = {}) {
3222
- this.getConnection = t, this.eventHandler = new Rn(e), this.parametersSetterWithQueue = new on(i), this.senderBalancer = new Cn(
3259
+ this.getConnection = t, this.eventHandler = new pn(e), this.parametersSetterWithQueue = new cn(i), this.senderBalancer = new En(
3223
3260
  {
3224
- senderFinder: new An(),
3225
- codecProvider: new rn(),
3261
+ senderFinder: new Rn(),
3262
+ codecProvider: new an(),
3226
3263
  parametersSetter: this.parametersSetterWithQueue
3227
3264
  },
3228
3265
  {
@@ -3259,7 +3296,7 @@ class In {
3259
3296
  const t = await this.senderBalancer.balance(e, this.serverHeaders);
3260
3297
  return this.trackMonitor.subscribe(t.sender, () => {
3261
3298
  this.balance().catch((s) => {
3262
- d("balance on track change: error", s);
3299
+ c("balance on track change: error", s);
3263
3300
  });
3264
3301
  }), t;
3265
3302
  }
@@ -3269,17 +3306,17 @@ class In {
3269
3306
  */
3270
3307
  handleMainCamControl = (e) => {
3271
3308
  this.serverHeaders = e, this.balance().catch((t) => {
3272
- d("handleMainCamControl: error", t);
3309
+ c("handleMainCamControl: error", t);
3273
3310
  });
3274
3311
  };
3275
3312
  }
3276
- const pe = [
3313
+ const me = [
3277
3314
  "balancing-scheduled",
3278
3315
  "balancing-started",
3279
3316
  "balancing-stopped",
3280
3317
  "parameters-updated"
3281
3318
  ];
3282
- class pn {
3319
+ class mn {
3283
3320
  isBalancingActive = !1;
3284
3321
  events;
3285
3322
  callManager;
@@ -3287,7 +3324,7 @@ class pn {
3287
3324
  videoSendingBalancer;
3288
3325
  startBalancingTimer;
3289
3326
  constructor(e, t, s = {}) {
3290
- this.events = new U(pe), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new In(
3327
+ this.events = new U(me), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new In(
3291
3328
  t,
3292
3329
  () => e.connection,
3293
3330
  {
@@ -3349,7 +3386,7 @@ class pn {
3349
3386
  scheduleBalancingStart() {
3350
3387
  this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
3351
3388
  this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
3352
- d("startBalancing: error", e);
3389
+ c("startBalancing: error", e);
3353
3390
  });
3354
3391
  }, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
3355
3392
  }
@@ -3357,17 +3394,17 @@ class pn {
3357
3394
  this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
3358
3395
  }
3359
3396
  }
3360
- const mn = 1e6, _n = Se.map((n) => `auto-connect:${n}`), Mn = ge.map((n) => `connection:${n}`), vn = ie.map((n) => `call:${n}`), fn = ne.map((n) => `api:${n}`), Pn = Ce.map((n) => `incoming-call:${n}`), On = he.map((n) => `presentation:${n}`), yn = Ee.map((n) => `stats:${n}`), Dn = pe.map((n) => `video-balancer:${n}`), bn = [
3361
- ..._n,
3397
+ const _n = 1e6, Mn = Ce.map((n) => `auto-connect:${n}`), fn = ge.map((n) => `connection:${n}`), vn = re.map((n) => `call:${n}`), Pn = se.map((n) => `api:${n}`), On = Ee.map((n) => `incoming-call:${n}`), yn = le.map((n) => `presentation:${n}`), bn = Ae.map((n) => `stats:${n}`), Dn = me.map((n) => `video-balancer:${n}`), wn = [
3362
3398
  ...Mn,
3363
- ...vn,
3364
3399
  ...fn,
3400
+ ...vn,
3365
3401
  ...Pn,
3366
3402
  ...On,
3367
3403
  ...yn,
3404
+ ...bn,
3368
3405
  ...Dn
3369
3406
  ];
3370
- class Gn {
3407
+ class Qn {
3371
3408
  events;
3372
3409
  connectionManager;
3373
3410
  connectionQueueManager;
@@ -3387,28 +3424,28 @@ class Gn {
3387
3424
  videoBalancerOptions: i,
3388
3425
  autoConnectorOptions: r
3389
3426
  } = {}) {
3390
- this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new k(bn), this.connectionManager = new pt({ JsSIP: e }), this.connectionQueueManager = new mt({
3427
+ this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new k(wn), this.connectionManager = new mt({ JsSIP: e }), this.connectionQueueManager = new _t({
3391
3428
  connectionManager: this.connectionManager
3392
- }), this.callManager = new ze(), this.apiManager = new Fe({
3429
+ }), this.callManager = new Xe(), this.apiManager = new ke({
3393
3430
  connectionManager: this.connectionManager,
3394
3431
  callManager: this.callManager
3395
- }), this.incomingCallManager = new $t(this.connectionManager), this.presentationManager = new dt({
3432
+ }), this.incomingCallManager = new qt(this.connectionManager), this.presentationManager = new ht({
3396
3433
  callManager: this.callManager,
3397
- maxBitrate: mn
3398
- }), this.statsManager = new zt({
3434
+ maxBitrate: _n
3435
+ }), this.statsManager = new Xt({
3399
3436
  callManager: this.callManager,
3400
3437
  apiManager: this.apiManager
3401
- }), this.autoConnectorManager = new Bt(
3438
+ }), this.autoConnectorManager = new Ft(
3402
3439
  {
3403
3440
  connectionQueueManager: this.connectionQueueManager,
3404
3441
  connectionManager: this.connectionManager,
3405
3442
  callManager: this.callManager
3406
3443
  },
3407
3444
  r
3408
- ), this.transceiverManager = new en({
3445
+ ), this.transceiverManager = new tn({
3409
3446
  callManager: this.callManager,
3410
3447
  apiManager: this.apiManager
3411
- }), this.videoSendingBalancerManager = new pn(
3448
+ }), this.videoSendingBalancerManager = new mn(
3412
3449
  this.callManager,
3413
3450
  this.apiManager,
3414
3451
  i
@@ -3593,7 +3630,7 @@ class Gn {
3593
3630
  return this.apiManager.askPermissionToEnableCam(...e);
3594
3631
  }
3595
3632
  setCodecPreferences(e) {
3596
- Zt(e, {
3633
+ en(e, {
3597
3634
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
3598
3635
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
3599
3636
  });
@@ -3613,19 +3650,19 @@ class Gn {
3613
3650
  };
3614
3651
  }
3615
3652
  export {
3616
- ae as E,
3617
- ke as O,
3618
- Gn as S,
3619
- rt as a,
3620
- Be as b,
3621
- xn as c,
3622
- Hn as d,
3653
+ oe as E,
3654
+ $e as O,
3655
+ Qn as S,
3656
+ at as a,
3657
+ Fe as b,
3658
+ Gn as c,
3659
+ xn as d,
3623
3660
  Wn as e,
3624
3661
  A as f,
3625
- Yt as g,
3662
+ zt as g,
3626
3663
  Nt as h,
3627
- sn as i,
3628
- d as l,
3664
+ rn as i,
3665
+ c as l,
3629
3666
  F as p,
3630
- de as s
3667
+ he as s
3631
3668
  };