sip-connector 20.6.0 → 21.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
1
  import J from "debug";
2
2
  import { TypedEvents as A } from "events-constructor";
3
- import { CancelableRequest as $, isCanceledError as $e } from "@krivega/cancelable-promise";
4
- import { resolveRequesterByTimeout as Ge, requesterByTimeoutsWithFailCalls as qe, DelayRequester as He, hasCanceledError as Ve, SetTimeoutRequest as ce } from "@krivega/timeout-requester";
5
- import { hasCanceledError as We, repeatedCallsAsync as he } from "repeated-calls";
6
- import { createActor as xe, setup as G, assign as P } from "xstate";
7
- import { createStackPromises as de, isPromiseIsNotActualError as Qe } from "stack-promises";
3
+ import { CancelableRequest as G, isCanceledError as $e } from "@krivega/cancelable-promise";
4
+ import { resolveRequesterByTimeout as qe, requesterByTimeoutsWithFailCalls as He, DelayRequester as Ve, hasCanceledError as We, SetTimeoutRequest as de } from "@krivega/timeout-requester";
5
+ import { hasCanceledError as xe, repeatedCallsAsync as he } from "repeated-calls";
6
+ import { createActor as Qe, setup as $, assign as b } from "xstate";
7
+ import { createStackPromises as le, isPromiseIsNotActualError as Ye } from "stack-promises";
8
8
  import "ua-parser-js";
9
9
  import "sequent-promises";
10
- import Ye from "lodash";
11
- const z = "sip-connector", h = J(z), Hs = () => {
10
+ import Xe from "lodash";
11
+ const z = "sip-connector", d = J(z), Qs = () => {
12
12
  J.enable(z);
13
- }, Vs = () => {
13
+ }, Ys = () => {
14
14
  J.enable(`-${z}`);
15
- }, Xe = "Error decline with 603", Je = 1006, ze = (n) => typeof n == "object" && n !== null && "code" in n && n.code === Je, Ke = (n) => n.message === Xe;
16
- var g = /* @__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.AUDIO_ID = "X-WEBRTC-AUDIOID", n))(g || {}), k = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(k || {}), x = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(x || {}), D = /* @__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))(D || {}), I = /* @__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))(I || {}), 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 || {}), Q = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(Q || {}), Y = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(Y || {}), je = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(je || {}), l = /* @__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_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", 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))(l || {});
17
- const le = [
15
+ }, Je = "Error decline with 603", ze = 1006, Ke = (n) => typeof n == "object" && n !== null && "code" in n && n.code === ze, je = (n) => n.message === Je;
16
+ var T = /* @__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.AUDIO_ID = "X-WEBRTC-AUDIOID", n))(T || {}), k = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(k || {}), x = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(x || {}), D = /* @__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))(D || {}), I = /* @__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))(I || {}), M = /* @__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))(M || {}), Q = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(Q || {}), Y = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(Y || {}), Ze = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Ze || {}), 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_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", 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))(g || {});
17
+ const ge = [
18
18
  "participation:accepting-word-request",
19
19
  "participation:cancelling-word-request",
20
20
  "participant:move-request-to-stream",
@@ -44,9 +44,9 @@ const le = [
44
44
  "notAvailableSecondRemoteStream",
45
45
  "mustStopPresentation",
46
46
  "newDTMF"
47
- ], Ze = () => new A(le);
47
+ ], et = () => new A(ge);
48
48
  var R = /* @__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))(R || {});
49
- class et {
49
+ class tt {
50
50
  events;
51
51
  connectionManager;
52
52
  callManager;
@@ -54,13 +54,13 @@ class et {
54
54
  connectionManager: e,
55
55
  callManager: t
56
56
  }) {
57
- this.connectionManager = e, this.callManager = t, this.events = Ze(), this.subscribe();
57
+ this.connectionManager = e, this.callManager = t, this.events = et(), this.subscribe();
58
58
  }
59
59
  async waitChannels() {
60
- return this.wait(l.CHANNELS);
60
+ return this.wait(g.CHANNELS);
61
61
  }
62
62
  async waitSyncMediaState() {
63
- return this.wait(l.ADMIN_FORCE_SYNC_MEDIA_STATE);
63
+ return this.wait(g.ADMIN_FORCE_SYNC_MEDIA_STATE);
64
64
  }
65
65
  async sendDTMF(e) {
66
66
  return new Promise((t, s) => {
@@ -79,14 +79,14 @@ class et {
79
79
  });
80
80
  }
81
81
  async sendChannels({ inputChannels: e, outputChannels: t }) {
82
- const s = this.getEstablishedRTCSessionProtected(), i = `${g.INPUT_CHANNELS}: ${e}`, r = `${g.OUTPUT_CHANNELS}: ${t}`, a = [
82
+ const s = this.getEstablishedRTCSessionProtected(), i = `${T.INPUT_CHANNELS}: ${e}`, r = `${T.OUTPUT_CHANNELS}: ${t}`, a = [
83
83
  i,
84
84
  r
85
85
  ];
86
86
  return s.sendInfo(I.CHANNELS, void 0, { extraHeaders: a });
87
87
  }
88
88
  async sendMediaState({ cam: e, mic: t }, s = {}) {
89
- const i = this.getEstablishedRTCSessionProtected(), r = `${g.MEDIA_STATE}: currentstate`, a = `${g.MAIN_CAM_STATE}: ${Number(e)}`, o = `${g.MIC_STATE}: ${Number(t)}`, c = [
89
+ const i = this.getEstablishedRTCSessionProtected(), r = `${T.MEDIA_STATE}: currentstate`, a = `${T.MAIN_CAM_STATE}: ${Number(e)}`, o = `${T.MIC_STATE}: ${Number(t)}`, c = [
90
90
  r,
91
91
  a,
92
92
  o
@@ -100,14 +100,14 @@ class et {
100
100
  async sendStats({
101
101
  availableIncomingBitrate: e
102
102
  }) {
103
- const t = this.getEstablishedRTCSessionProtected(), i = [`${g.AVAILABLE_INCOMING_BITRATE}: ${e}`];
103
+ const t = this.getEstablishedRTCSessionProtected(), i = [`${T.AVAILABLE_INCOMING_BITRATE}: ${e}`];
104
104
  return t.sendInfo(I.STATS, void 0, {
105
105
  noTerminateWhenError: !0,
106
106
  extraHeaders: i
107
107
  });
108
108
  }
109
109
  async sendRefusalToTurnOn(e, t = {}) {
110
- const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${g.MEDIA_TYPE}: ${a}`];
110
+ const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${T.MEDIA_TYPE}: ${a}`];
111
111
  return s.sendInfo(I.REFUSAL, void 0, {
112
112
  noTerminateWhenError: !0,
113
113
  ...t,
@@ -122,37 +122,37 @@ class et {
122
122
  }
123
123
  async sendMustStopPresentationP2P() {
124
124
  await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
125
- extraHeaders: [g.MUST_STOP_PRESENTATION_P2P]
125
+ extraHeaders: [T.MUST_STOP_PRESENTATION_P2P]
126
126
  });
127
127
  }
128
128
  async sendStoppedPresentationP2P() {
129
129
  await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
130
- extraHeaders: [g.STOP_PRESENTATION_P2P]
130
+ extraHeaders: [T.STOP_PRESENTATION_P2P]
131
131
  });
132
132
  }
133
133
  async sendStoppedPresentation() {
134
134
  await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
135
- extraHeaders: [g.STOP_PRESENTATION]
135
+ extraHeaders: [T.STOP_PRESENTATION]
136
136
  });
137
137
  }
138
138
  async askPermissionToStartPresentationP2P() {
139
139
  await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
140
- extraHeaders: [g.START_PRESENTATION_P2P]
140
+ extraHeaders: [T.START_PRESENTATION_P2P]
141
141
  });
142
142
  }
143
143
  async askPermissionToStartPresentation() {
144
144
  await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
145
- extraHeaders: [g.START_PRESENTATION]
145
+ extraHeaders: [T.START_PRESENTATION]
146
146
  });
147
147
  }
148
148
  async askPermissionToEnableCam(e = {}) {
149
- const t = this.getEstablishedRTCSessionProtected(), s = [g.ENABLE_MAIN_CAM];
149
+ const t = this.getEstablishedRTCSessionProtected(), s = [T.ENABLE_MAIN_CAM];
150
150
  return t.sendInfo(I.MAIN_CAM, void 0, {
151
151
  noTerminateWhenError: !0,
152
152
  ...e,
153
153
  extraHeaders: s
154
154
  }).catch((i) => {
155
- if (Ke(i))
155
+ if (je(i))
156
156
  throw i;
157
157
  });
158
158
  }
@@ -187,13 +187,13 @@ class et {
187
187
  };
188
188
  maybeHandleNotify = (e) => {
189
189
  try {
190
- const t = e.getHeader(g.NOTIFY);
190
+ const t = e.getHeader(T.NOTIFY);
191
191
  if (t) {
192
192
  const s = JSON.parse(t);
193
193
  this.handleNotify(s);
194
194
  }
195
195
  } catch (t) {
196
- h("error parse notify", t);
196
+ d("error parse notify", t);
197
197
  }
198
198
  };
199
199
  handleNotify = (e) => {
@@ -252,14 +252,14 @@ class et {
252
252
  break;
253
253
  }
254
254
  default:
255
- h("unknown cmd", e);
255
+ d("unknown cmd", e);
256
256
  }
257
257
  };
258
258
  handleNewInfo = (e) => {
259
259
  const { originator: t } = e;
260
260
  if (t !== "remote")
261
261
  return;
262
- const { request: s } = e, i = s, r = i.getHeader(g.CONTENT_TYPE);
262
+ const { request: s } = e, i = s, r = i.getHeader(T.CONTENT_TYPE);
263
263
  if (r !== void 0)
264
264
  switch (r) {
265
265
  case D.ENTER_ROOM: {
@@ -297,7 +297,7 @@ class et {
297
297
  inputChannels: t,
298
298
  outputChannels: s
299
299
  };
300
- this.events.trigger(l.CHANNELS_NOTIFY, i);
300
+ this.events.trigger(g.CHANNELS_NOTIFY, i);
301
301
  };
302
302
  triggerWebcastStartedNotify = ({
303
303
  body: { conference: e, type: t }
@@ -306,7 +306,7 @@ class et {
306
306
  conference: e,
307
307
  type: t
308
308
  };
309
- this.events.trigger(l.WEBCAST_STARTED, s);
309
+ this.events.trigger(g.WEBCAST_STARTED, s);
310
310
  };
311
311
  triggerWebcastStoppedNotify = ({
312
312
  body: { conference: e, type: t }
@@ -315,7 +315,7 @@ class et {
315
315
  conference: e,
316
316
  type: t
317
317
  };
318
- this.events.trigger(l.WEBCAST_STOPPED, s);
318
+ this.events.trigger(g.WEBCAST_STOPPED, s);
319
319
  };
320
320
  triggerAddedToListModeratorsNotify = ({
321
321
  conference: e
@@ -324,7 +324,7 @@ class et {
324
324
  conference: e
325
325
  };
326
326
  this.events.trigger(
327
- l.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
327
+ g.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
328
328
  t
329
329
  );
330
330
  };
@@ -335,7 +335,7 @@ class et {
335
335
  conference: e
336
336
  };
337
337
  this.events.trigger(
338
- l.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
338
+ g.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
339
339
  t
340
340
  );
341
341
  };
@@ -345,7 +345,7 @@ class et {
345
345
  const t = {
346
346
  conference: e
347
347
  };
348
- this.events.trigger(l.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
348
+ this.events.trigger(g.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
349
349
  };
350
350
  triggerParticipationCancellingWordRequest = ({
351
351
  body: { conference: e }
@@ -353,7 +353,7 @@ class et {
353
353
  const t = {
354
354
  conference: e
355
355
  };
356
- this.events.trigger(l.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
356
+ this.events.trigger(g.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
357
357
  };
358
358
  triggerParticipantMoveRequestToStream = ({
359
359
  body: { conference: e }
@@ -361,13 +361,13 @@ class et {
361
361
  const t = {
362
362
  conference: e
363
363
  };
364
- this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
364
+ this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
365
365
  };
366
366
  triggerAccountChangedNotify = () => {
367
- this.events.trigger(l.ACCOUNT_CHANGED, {});
367
+ this.events.trigger(g.ACCOUNT_CHANGED, {});
368
368
  };
369
369
  triggerAccountDeletedNotify = () => {
370
- this.events.trigger(l.ACCOUNT_DELETED, {});
370
+ this.events.trigger(g.ACCOUNT_DELETED, {});
371
371
  };
372
372
  triggerConferenceParticipantTokenIssued = ({
373
373
  body: { conference: e, participant: t, jwt: s }
@@ -378,82 +378,82 @@ class et {
378
378
  jwt: s
379
379
  };
380
380
  this.events.trigger(
381
- l.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
381
+ g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
382
382
  i
383
383
  );
384
384
  };
385
385
  maybeTriggerChannels = (e) => {
386
- const t = e.getHeader(g.INPUT_CHANNELS), s = e.getHeader(g.OUTPUT_CHANNELS);
386
+ const t = e.getHeader(T.INPUT_CHANNELS), s = e.getHeader(T.OUTPUT_CHANNELS);
387
387
  if (t && s) {
388
388
  const i = {
389
389
  inputChannels: t,
390
390
  outputChannels: s
391
391
  };
392
- this.events.trigger(l.CHANNELS, i);
392
+ this.events.trigger(g.CHANNELS, i);
393
393
  }
394
394
  };
395
395
  triggerEnterRoom = (e) => {
396
- const t = e.getHeader(g.CONTENT_ENTER_ROOM), s = e.getHeader(g.PARTICIPANT_NAME);
397
- this.events.trigger(l.ENTER_ROOM, { room: t, participantName: s });
396
+ const t = e.getHeader(T.CONTENT_ENTER_ROOM), s = e.getHeader(T.PARTICIPANT_NAME);
397
+ this.events.trigger(g.ENTER_ROOM, { room: t, participantName: s });
398
398
  };
399
399
  triggerShareState = (e) => {
400
- const t = e.getHeader(g.CONTENT_SHARE_STATE);
400
+ const t = e.getHeader(T.CONTENT_SHARE_STATE);
401
401
  if (t !== void 0)
402
402
  switch (t) {
403
403
  case k.AVAILABLE_SECOND_REMOTE_STREAM: {
404
- this.events.trigger(l.AVAILABLE_SECOND_REMOTE_STREAM, {});
404
+ this.events.trigger(g.AVAILABLE_SECOND_REMOTE_STREAM, {});
405
405
  break;
406
406
  }
407
407
  case k.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
408
- this.events.trigger(l.NOT_AVAILABLE_SECOND_REMOTE_STREAM, {});
408
+ this.events.trigger(g.NOT_AVAILABLE_SECOND_REMOTE_STREAM, {});
409
409
  break;
410
410
  }
411
411
  case k.MUST_STOP_PRESENTATION: {
412
- this.events.trigger(l.MUST_STOP_PRESENTATION, {});
412
+ this.events.trigger(g.MUST_STOP_PRESENTATION, {});
413
413
  break;
414
414
  }
415
415
  }
416
416
  };
417
417
  maybeTriggerParticipantMoveRequest = (e) => {
418
- const t = e.getHeader(g.CONTENT_PARTICIPANT_STATE), s = e.getHeader(g.AUDIO_ID);
419
- t === x.SPECTATOR && (s ? (this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID, {
418
+ const t = e.getHeader(T.CONTENT_PARTICIPANT_STATE), s = e.getHeader(T.AUDIO_ID);
419
+ t === x.SPECTATOR && (s ? (this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID, {
420
420
  audioId: s
421
- }), this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, {
421
+ }), this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, {
422
422
  isSynthetic: !1,
423
423
  audioId: s
424
- })) : (this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC, {}), this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, { isSynthetic: !0 }))), t === x.PARTICIPANT && this.events.trigger(l.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, {});
424
+ })) : (this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC, {}), this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, { isSynthetic: !0 }))), t === x.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, {});
425
425
  };
426
426
  triggerMainCamControl = (e) => {
427
- const t = e.getHeader(g.MAIN_CAM), s = e.getHeader(g.MEDIA_SYNC), i = s === Y.ADMIN_SYNC_FORCED;
428
- if (t === v.ADMIN_START_MAIN_CAM) {
429
- this.events.trigger(l.ADMIN_START_MAIN_CAM, { isSyncForced: i });
427
+ const t = e.getHeader(T.MAIN_CAM), s = e.getHeader(T.MEDIA_SYNC), i = s === Y.ADMIN_SYNC_FORCED;
428
+ if (t === M.ADMIN_START_MAIN_CAM) {
429
+ this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
430
430
  return;
431
431
  }
432
- if (t === v.ADMIN_STOP_MAIN_CAM) {
433
- this.events.trigger(l.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
432
+ if (t === M.ADMIN_STOP_MAIN_CAM) {
433
+ this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
434
434
  return;
435
435
  }
436
- (t === v.RESUME_MAIN_CAM || t === v.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(l.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
437
- const r = e.getHeader(g.MAIN_CAM_RESOLUTION);
438
- this.events.trigger(l.MAIN_CAM_CONTROL, {
436
+ (t === M.RESUME_MAIN_CAM || t === M.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
437
+ const r = e.getHeader(T.MAIN_CAM_RESOLUTION);
438
+ this.events.trigger(g.MAIN_CAM_CONTROL, {
439
439
  mainCam: t,
440
440
  resolutionMainCam: r
441
441
  });
442
442
  };
443
443
  triggerMicControl = (e) => {
444
- const t = e.getHeader(g.MIC), i = e.getHeader(g.MEDIA_SYNC) === Y.ADMIN_SYNC_FORCED;
445
- t === Q.ADMIN_START_MIC ? this.events.trigger(l.ADMIN_START_MIC, { isSyncForced: i }) : t === Q.ADMIN_STOP_MIC && this.events.trigger(l.ADMIN_STOP_MIC, { isSyncForced: i });
444
+ const t = e.getHeader(T.MIC), i = e.getHeader(T.MEDIA_SYNC) === Y.ADMIN_SYNC_FORCED;
445
+ t === Q.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: i }) : t === Q.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: i });
446
446
  };
447
447
  triggerUseLicense = (e) => {
448
- const t = e.getHeader(g.CONTENT_USE_LICENSE);
449
- this.events.trigger(l.USE_LICENSE, t);
448
+ const t = e.getHeader(T.CONTENT_USE_LICENSE);
449
+ this.events.trigger(g.USE_LICENSE, t);
450
450
  };
451
451
  }
452
452
  class q {
453
453
  actor;
454
454
  subscriptions = [];
455
455
  constructor(e) {
456
- this.actor = xe(e), this.actor.start();
456
+ this.actor = Qe(e), this.actor.start();
457
457
  }
458
458
  get actorRef() {
459
459
  return this.actor;
@@ -483,17 +483,17 @@ class q {
483
483
  return this.subscriptions.push(t), t;
484
484
  }
485
485
  }
486
- var tt = /* @__PURE__ */ ((n) => (n.IDLE = "call:idle", n.CONNECTING = "call:connecting", n.ACCEPTED = "call:accepted", n.IN_CALL = "call:inCall", n.ENDED = "call:ended", n.FAILED = "call:failed", n))(tt || {});
487
- const nt = G({
486
+ var nt = /* @__PURE__ */ ((n) => (n.IDLE = "call:idle", n.CONNECTING = "call:connecting", n.ACCEPTED = "call:accepted", n.IN_CALL = "call:inCall", n.ENDED = "call:ended", n.FAILED = "call:failed", n))(nt || {});
487
+ const st = $({
488
488
  types: {
489
489
  context: {},
490
490
  events: {}
491
491
  },
492
492
  actions: {
493
- rememberError: P(({ event: n }) => "error" in n && n.error !== void 0 ? {
493
+ rememberError: b(({ event: n }) => "error" in n && n.error !== void 0 ? {
494
494
  lastError: n.error instanceof Error ? n.error : new Error(JSON.stringify(n.error))
495
495
  } : { lastError: void 0 }),
496
- resetError: P({ lastError: void 0 })
496
+ resetError: b({ lastError: void 0 })
497
497
  }
498
498
  }).createMachine({
499
499
  id: "call",
@@ -567,9 +567,9 @@ const nt = G({
567
567
  }
568
568
  }
569
569
  });
570
- class st extends q {
570
+ class it extends q {
571
571
  constructor(e) {
572
- super(nt), this.subscribeToEvents(e);
572
+ super(st), this.subscribeToEvents(e);
573
573
  }
574
574
  get isIdle() {
575
575
  return this.state === "call:idle";
@@ -634,8 +634,8 @@ class st extends q {
634
634
  );
635
635
  }
636
636
  }
637
- var S = /* @__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.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n))(S || {}), it = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(it || {});
638
- const ge = [
637
+ var E = /* @__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.REMOTE_TRACKS_CHANGED = "remote-tracks-changed", n.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n))(E || {}), rt = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(rt || {});
638
+ const ue = [
639
639
  "peerconnection",
640
640
  "connecting",
641
641
  "sending",
@@ -666,16 +666,17 @@ const ge = [
666
666
  "peerconnection:createanswerfailed",
667
667
  "peerconnection:setlocaldescriptionfailed",
668
668
  "peerconnection:setremotedescriptionfailed"
669
- ], rt = [
669
+ ], at = [
670
670
  "peerconnection:confirmed",
671
671
  "peerconnection:ontrack",
672
672
  "ended:fromserver",
673
673
  "call-status-changed",
674
+ "remote-tracks-changed",
674
675
  "remote-streams-changed"
675
- ], ue = [
676
- ...ge,
677
- ...rt
678
- ], at = () => new A(ue), ot = (n, e) => {
676
+ ], Te = [
677
+ ...ue,
678
+ ...at
679
+ ], ot = () => new A(Te), ct = (n, e) => {
679
680
  n.getVideoTracks().forEach((s) => {
680
681
  "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
681
682
  });
@@ -687,16 +688,16 @@ const ge = [
687
688
  if (!n || e === "recvonly" && t === "recvonly")
688
689
  return;
689
690
  const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
690
- return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && ot(o, s), o;
691
+ return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && ct(o, s), o;
691
692
  };
692
- var Te = /* @__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))(Te || {});
693
- class ct {
693
+ var Se = /* @__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))(Se || {});
694
+ class dt {
694
695
  events;
695
696
  rtcSession;
696
697
  disposers = /* @__PURE__ */ new Set();
697
698
  onReset;
698
699
  constructor(e, { onReset: t }) {
699
- this.events = e, this.onReset = t, e.on(S.FAILED, this.handleEnded), e.on(S.ENDED, this.handleEnded);
700
+ this.events = e, this.onReset = t, e.on(E.FAILED, this.handleEnded), e.on(E.ENDED, this.handleEnded);
700
701
  }
701
702
  get connection() {
702
703
  return this.rtcSession?.connection;
@@ -717,10 +718,10 @@ class ct {
717
718
  iceServers: a,
718
719
  directionVideo: o,
719
720
  directionAudio: c,
720
- contentHint: d,
721
- offerToReceiveAudio: E = !0,
722
- offerToReceiveVideo: u = !0,
723
- degradationPreference: T,
721
+ contentHint: h,
722
+ offerToReceiveAudio: u = !0,
723
+ offerToReceiveVideo: l = !0,
724
+ degradationPreference: S,
724
725
  sendEncodings: m,
725
726
  onAddedTransceiver: O
726
727
  }) => new Promise((N, y) => {
@@ -730,14 +731,14 @@ class ct {
730
731
  mediaStream: B(i, {
731
732
  directionVideo: o,
732
733
  directionAudio: c,
733
- contentHint: d
734
+ contentHint: h
734
735
  }),
735
736
  pcConfig: {
736
737
  iceServers: a
737
738
  },
738
739
  rtcOfferConstraints: {
739
- offerToReceiveAudio: E,
740
- offerToReceiveVideo: u
740
+ offerToReceiveAudio: u,
741
+ offerToReceiveVideo: l
741
742
  },
742
743
  // необходимо передавать в методе call, чтобы подписаться на события peerconnection,
743
744
  // так как в методе call создается RTCSession
@@ -746,7 +747,7 @@ class ct {
746
747
  extraHeaders: r,
747
748
  directionVideo: o,
748
749
  directionAudio: c,
749
- degradationPreference: T,
750
+ degradationPreference: S,
750
751
  sendEncodings: m,
751
752
  onAddedTransceiver: O
752
753
  });
@@ -755,7 +756,7 @@ class ct {
755
756
  const { rtcSession: e } = this;
756
757
  if (e && !e.isEnded())
757
758
  return e.terminateAsync({
758
- cause: Te.CANCELED
759
+ cause: Se.CANCELED
759
760
  }).finally(() => {
760
761
  this.reset();
761
762
  });
@@ -769,10 +770,10 @@ class ct {
769
770
  directionAudio: a,
770
771
  offerToReceiveAudio: o,
771
772
  offerToReceiveVideo: c,
772
- contentHint: d,
773
- degradationPreference: E,
774
- sendEncodings: u,
775
- onAddedTransceiver: T
773
+ contentHint: h,
774
+ degradationPreference: u,
775
+ sendEncodings: l,
776
+ onAddedTransceiver: S
776
777
  }) => new Promise((m, O) => {
777
778
  try {
778
779
  this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(m).catch((N) => {
@@ -788,14 +789,14 @@ class ct {
788
789
  mediaStream: B(t, {
789
790
  directionVideo: r,
790
791
  directionAudio: a,
791
- contentHint: d
792
+ contentHint: h
792
793
  }),
793
794
  extraHeaders: s,
794
795
  directionVideo: r,
795
796
  directionAudio: a,
796
- degradationPreference: E,
797
- sendEncodings: u,
798
- onAddedTransceiver: T
797
+ degradationPreference: u,
798
+ sendEncodings: l,
799
+ onAddedTransceiver: S
799
800
  });
800
801
  } catch (N) {
801
802
  O(N);
@@ -816,33 +817,33 @@ class ct {
816
817
  }
817
818
  handleCall = async () => new Promise((e, t) => {
818
819
  const s = () => {
819
- this.events.on(S.PEER_CONNECTION, d), this.events.on(S.CONFIRMED, E);
820
+ this.events.on(E.PEER_CONNECTION, h), this.events.on(E.CONFIRMED, u);
820
821
  }, i = () => {
821
- this.events.off(S.PEER_CONNECTION, d), this.events.off(S.CONFIRMED, E);
822
+ this.events.off(E.PEER_CONNECTION, h), this.events.off(E.CONFIRMED, u);
822
823
  }, r = () => {
823
- this.events.on(S.FAILED, o), this.events.on(S.ENDED, o);
824
+ this.events.on(E.FAILED, o), this.events.on(E.ENDED, o);
824
825
  }, a = () => {
825
- this.events.off(S.FAILED, o), this.events.off(S.ENDED, o);
826
- }, o = (u) => {
827
- i(), a(), t(u);
826
+ this.events.off(E.FAILED, o), this.events.off(E.ENDED, o);
827
+ }, o = (l) => {
828
+ i(), a(), t(l);
828
829
  };
829
830
  let c;
830
- const d = ({ peerconnection: u }) => {
831
- c = u;
832
- const T = (m) => {
833
- this.events.trigger(S.PEER_CONNECTION_ONTRACK, m);
831
+ const h = ({ peerconnection: l }) => {
832
+ c = l;
833
+ const S = (m) => {
834
+ this.events.trigger(E.PEER_CONNECTION_ONTRACK, m);
834
835
  };
835
- u.addEventListener("track", T), this.disposers.add(() => {
836
- u.removeEventListener("track", T);
836
+ l.addEventListener("track", S), this.disposers.add(() => {
837
+ l.removeEventListener("track", S);
837
838
  });
838
- }, E = () => {
839
- c !== void 0 && this.events.trigger(S.PEER_CONNECTION_CONFIRMED, c), i(), a(), e(c);
839
+ }, u = () => {
840
+ c !== void 0 && this.events.trigger(E.PEER_CONNECTION_CONFIRMED, c), i(), a(), e(c);
840
841
  };
841
842
  s(), r();
842
843
  });
843
844
  subscribeToSessionEvents(e) {
844
845
  this.events.eachTriggers((t, s) => {
845
- const i = ge.find((r) => r === s);
846
+ const i = ue.find((r) => r === s);
846
847
  i && (e.on(i, t), this.disposers.add(() => {
847
848
  e.off(i, t);
848
849
  }));
@@ -855,7 +856,7 @@ class ct {
855
856
  }
856
857
  handleEnded = (e) => {
857
858
  const { originator: t } = e;
858
- t === "remote" && this.events.trigger(S.ENDED_FROM_SERVER, e), this.reset();
859
+ t === "remote" && this.events.trigger(E.ENDED_FROM_SERVER, e), this.reset();
859
860
  };
860
861
  reset = () => {
861
862
  delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.onReset();
@@ -910,13 +911,13 @@ class ht {
910
911
  return this.connection.addTransceiver(e, t);
911
912
  }
912
913
  }
913
- const Ee = (n) => n.getSettings(), dt = (n, e) => {
914
+ const Ee = (n) => n.getSettings(), lt = (n, e) => {
914
915
  const t = Ee(n);
915
916
  let s = e;
916
917
  s ??= n.label;
917
918
  let i = t?.msid;
918
919
  return i ??= s, i ??= n.id, i;
919
- }, lt = (n, e) => {
920
+ }, gt = (n, e) => {
920
921
  const t = Ee(n);
921
922
  let s = e;
922
923
  return s ??= t?.msid, s ??= n.label, (s && s.length > 0 ? s : void 0) ?? n.id;
@@ -938,34 +939,42 @@ class Z {
938
939
  onRemoved: t,
939
940
  streamHint: s
940
941
  } = {}) {
941
- const i = lt(e, s), r = dt(e, s);
942
+ const i = gt(e, s), r = lt(e, s);
942
943
  if (this.trackToGroup.has(e.id))
943
- return { isAdded: !1 };
944
- const a = this.getParticipantGroups(i);
945
- let o = a.get(r);
946
- o || (o = {
944
+ return { isAddedTrack: !1, isAddedStream: !1 };
945
+ const a = this.getParticipantGroups(i), o = a.get(r), c = !o;
946
+ let h = o;
947
+ h || (h = {
947
948
  participantId: i,
948
949
  groupId: r,
949
950
  stream: new MediaStream(),
950
951
  trackIds: /* @__PURE__ */ new Set()
951
- }, a.set(r, o)), o.stream.addTrack(e), o.trackIds.add(e.id), this.trackToGroup.set(e.id, { participantId: i, groupId: r });
952
- const c = () => {
953
- this.disposeTrackListener(e.id), this.removeTrack(e.id) && t?.({ trackId: e.id, participantId: i });
952
+ }, a.set(r, h)), h.stream.addTrack(e), h.trackIds.add(e.id), this.trackToGroup.set(e.id, { participantId: i, groupId: r });
953
+ const u = () => {
954
+ this.disposeTrackListener(e.id);
955
+ const l = this.removeTrack(e.id);
956
+ l.isRemovedTrack && t?.({
957
+ participantId: i,
958
+ trackId: e.id,
959
+ isRemovedStream: l.isRemovedStream
960
+ });
954
961
  };
955
- return e.addEventListener("ended", c), this.trackDisposers.set(e.id, () => {
956
- e.removeEventListener("ended", c);
957
- }), { isAdded: !0, participantId: i };
962
+ return e.addEventListener("ended", u), this.trackDisposers.set(e.id, () => {
963
+ e.removeEventListener("ended", u);
964
+ }), { isAddedTrack: !0, isAddedStream: c, participantId: i };
958
965
  }
959
966
  removeTrack(e) {
960
967
  this.disposeTrackListener(e);
961
968
  const t = this.trackToGroup.get(e);
962
969
  if (!t)
963
- return !1;
970
+ return { isRemovedTrack: !1, isRemovedStream: !1 };
964
971
  const { participantId: s, groupId: i } = t, r = this.participantGroups.get(s), a = r?.get(i);
965
972
  if (!a)
966
- return this.trackToGroup.delete(e), !1;
967
- const o = a.stream.getTracks().find((c) => c.id === e);
968
- return o && a.stream.removeTrack(o), a.trackIds.delete(e), this.trackToGroup.delete(e), a.trackIds.size === 0 && (r?.delete(i), r?.size === 0 && this.participantGroups.delete(s)), !0;
973
+ return this.trackToGroup.delete(e), { isRemovedTrack: !1, isRemovedStream: !1 };
974
+ const o = a.stream.getTracks().find((h) => h.id === e);
975
+ o && a.stream.removeTrack(o), a.trackIds.delete(e), this.trackToGroup.delete(e);
976
+ const c = a.trackIds.size === 0;
977
+ return c && (r?.delete(i), r?.size === 0 && this.participantGroups.delete(s)), { isRemovedTrack: !0, isRemovedStream: c };
969
978
  }
970
979
  removeStaleTracks(e, t) {
971
980
  const s = this.participantGroups.get(e);
@@ -974,8 +983,8 @@ class Z {
974
983
  let i = !1;
975
984
  return [...s.values()].forEach((a) => {
976
985
  [...a.trackIds].filter((c) => !t.includes(c)).forEach((c) => {
977
- const d = this.removeTrack(c);
978
- i ||= d;
986
+ const h = this.removeTrack(c);
987
+ i ||= h.isRemovedTrack;
979
988
  });
980
989
  }), i;
981
990
  }
@@ -1000,22 +1009,17 @@ class Z {
1000
1009
  }
1001
1010
  const V = {
1002
1011
  type: "participant"
1003
- }, gt = {
1012
+ }, ut = {
1004
1013
  type: "spectator_synthetic"
1005
- }, ut = (n) => ({
1014
+ }, Tt = (n) => ({
1006
1015
  type: "spectator",
1007
1016
  recvParams: n
1008
1017
  });
1009
1018
  class _ {
1010
1019
  role = V;
1011
- mainManager;
1012
- recvManager;
1013
1020
  onRoleChanged;
1014
- constructor({
1015
- mainManager: e,
1016
- recvManager: t
1017
- }, s) {
1018
- this.mainManager = e, this.recvManager = t, this.onRoleChanged = s;
1021
+ constructor(e) {
1022
+ this.onRoleChanged = e;
1019
1023
  }
1020
1024
  static hasParticipant(e) {
1021
1025
  return e.type === "participant";
@@ -1033,10 +1037,10 @@ class _ {
1033
1037
  this.changeRole(V);
1034
1038
  }
1035
1039
  setCallRoleSpectatorSynthetic() {
1036
- this.changeRole(gt);
1040
+ this.changeRole(ut);
1037
1041
  }
1038
1042
  setCallRoleSpectator(e) {
1039
- this.changeRole(ut(e));
1043
+ this.changeRole(Tt(e));
1040
1044
  }
1041
1045
  changeRole(e) {
1042
1046
  const t = this.role;
@@ -1047,10 +1051,7 @@ class _ {
1047
1051
  _.hasSpectator(e) && _.hasSpectator(t) && t.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
1048
1052
  }
1049
1053
  reset() {
1050
- this.role = V, this.recvManager.reset();
1051
- }
1052
- getActiveManager() {
1053
- return this.hasSpectator() ? this.recvManager : this.mainManager;
1054
+ this.role = V;
1054
1055
  }
1055
1056
  hasParticipant() {
1056
1057
  return _.hasParticipant(this.role);
@@ -1066,8 +1067,30 @@ class _ {
1066
1067
  this.role = e, this.onRoleChanged?.({ previous: t, next: e });
1067
1068
  }
1068
1069
  }
1069
- const ee = (n) => n.streams[0]?.id;
1070
- class Tt {
1070
+ const St = "default", Et = "dual", ee = (n) => [...n.getTracks()].some((e) => e.label.includes(Et));
1071
+ class Ct {
1072
+ mainRemoteStreamsManager;
1073
+ recvRemoteStreamsManager;
1074
+ constructor(e, t) {
1075
+ this.mainRemoteStreamsManager = e, this.recvRemoteStreamsManager = t;
1076
+ }
1077
+ getActiveStreamsManagerTools(e) {
1078
+ return e ? this.getRecvRemoteStreamsManagerTools() : this.getMainRemoteStreamsManagerTools();
1079
+ }
1080
+ getMainRemoteStreamsManagerTools() {
1081
+ const e = this.mainRemoteStreamsManager;
1082
+ return { manager: e, getRemoteStreams: () => {
1083
+ const s = e.getStreams(), i = s.find((a) => !ee(a)), r = s.find((a) => ee(a));
1084
+ return { mainStream: i, contentedStream: r };
1085
+ } };
1086
+ }
1087
+ getRecvRemoteStreamsManagerTools() {
1088
+ const e = this.recvRemoteStreamsManager;
1089
+ return { manager: e, getRemoteStreams: () => ({ mainStream: e.getStreams(St)[0], contentedStream: void 0 }) };
1090
+ }
1091
+ }
1092
+ const te = (n) => n.streams[0]?.id;
1093
+ class pt {
1071
1094
  events;
1072
1095
  callStateMachine;
1073
1096
  isPendingCall = !1;
@@ -1076,17 +1099,18 @@ class Tt {
1076
1099
  conferenceStateManager;
1077
1100
  mainRemoteStreamsManager = new Z();
1078
1101
  recvRemoteStreamsManager = new Z();
1079
- roleManager = new _(
1080
- { mainManager: this.mainRemoteStreamsManager, recvManager: this.recvRemoteStreamsManager },
1081
- (e) => {
1082
- this.onRoleChanged(e);
1083
- }
1084
- );
1102
+ streamsManagerProvider;
1103
+ roleManager = new _((e) => {
1104
+ this.onRoleChanged(e);
1105
+ });
1085
1106
  mcuSession;
1086
1107
  recvSession;
1087
1108
  disposeRecvSessionTrackListener;
1088
1109
  constructor(e) {
1089
- this.conferenceStateManager = e, this.events = at(), this.mcuSession = new ct(this.events, { onReset: this.reset }), this.callStateMachine = new st(this.events), this.subscribeCallStatusChange(), this.subscribeMcuRemoteTrackEvents();
1110
+ this.conferenceStateManager = e, this.events = ot(), this.mcuSession = new dt(this.events, { onReset: this.reset }), this.callStateMachine = new it(this.events), this.streamsManagerProvider = new Ct(
1111
+ this.mainRemoteStreamsManager,
1112
+ this.recvRemoteStreamsManager
1113
+ ), this.subscribeCallStatusChange(), this.subscribeMcuRemoteTrackEvents();
1090
1114
  }
1091
1115
  get callActor() {
1092
1116
  return this.callStateMachine.actorRef;
@@ -1100,6 +1124,10 @@ class Tt {
1100
1124
  get isCallActive() {
1101
1125
  return this.mcuSession.isCallActive;
1102
1126
  }
1127
+ // For testing purposes
1128
+ getStreamsManagerProvider() {
1129
+ return this.streamsManagerProvider;
1130
+ }
1103
1131
  getEstablishedRTCSession = () => this.mcuSession.getEstablishedRTCSession();
1104
1132
  on(e, t) {
1105
1133
  return this.events.on(e, t);
@@ -1138,11 +1166,13 @@ class Tt {
1138
1166
  this.isPendingAnswer = !1;
1139
1167
  });
1140
1168
  };
1141
- getMainStream() {
1142
- return this.getActiveStreamsManager().mainStream;
1169
+ getMainRemoteStream() {
1170
+ const { mainStream: e } = this.getRemoteStreams();
1171
+ return e;
1143
1172
  }
1144
1173
  getRemoteStreams() {
1145
- return this.getActiveStreamsManager().getStreams();
1174
+ const { getRemoteStreams: e } = this.getActiveStreamsManagerTools();
1175
+ return e();
1146
1176
  }
1147
1177
  setCallRoleParticipant() {
1148
1178
  this.roleManager.setCallRoleParticipant();
@@ -1160,57 +1190,74 @@ class Tt {
1160
1190
  return this.mcuSession.restartIce(e);
1161
1191
  }
1162
1192
  reset = () => {
1163
- this.mainRemoteStreamsManager.reset(), this.conferenceStateManager.updateState({ number: void 0, answer: !1 }), this.roleManager.reset(), this.stopRecvSession();
1193
+ this.mainRemoteStreamsManager.reset(), this.conferenceStateManager.updateState({ number: void 0, answer: !1 }), this.roleManager.reset(), this.recvRemoteStreamsManager.reset(), this.stopRecvSession();
1164
1194
  };
1165
1195
  subscribeCallStatusChange() {
1166
1196
  let { isCallActive: e } = this;
1167
- const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } = S;
1197
+ const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } = E;
1168
1198
  this.onRace([t, s, i, r], () => {
1169
1199
  e = this.maybeTriggerCallStatus(e);
1170
1200
  });
1171
1201
  }
1172
1202
  maybeTriggerCallStatus(e) {
1173
1203
  const t = this.isCallActive;
1174
- return t !== e && this.events.trigger(S.CALL_STATUS_CHANGED, { isCallActive: t }), t;
1204
+ return t !== e && this.events.trigger(E.CALL_STATUS_CHANGED, { isCallActive: t }), t;
1175
1205
  }
1176
1206
  subscribeMcuRemoteTrackEvents() {
1177
- this.on(S.PEER_CONNECTION_ONTRACK, (e) => {
1178
- this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, ee(e));
1207
+ this.on(E.PEER_CONNECTION_ONTRACK, (e) => {
1208
+ this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, te(e));
1179
1209
  });
1180
1210
  }
1181
1211
  addRemoteTrack(e, t, s) {
1182
1212
  const i = e.addTrack(t, {
1183
1213
  streamHint: s,
1184
1214
  onRemoved: (r) => {
1185
- this.emitRemoteStreamsChanged(e, "removed", {
1215
+ this.handleChangedRemoteTracks(e, "removed", {
1216
+ isRemovedStream: r.isRemovedStream,
1217
+ isAddedStream: !1,
1186
1218
  trackId: r.trackId,
1187
1219
  participantId: r.participantId
1188
1220
  });
1189
1221
  }
1190
1222
  });
1191
- i.isAdded && this.emitRemoteStreamsChanged(e, "added", {
1223
+ i.isAddedTrack && this.handleChangedRemoteTracks(e, "added", {
1224
+ isRemovedStream: !1,
1225
+ isAddedStream: i.isAddedStream,
1192
1226
  trackId: t.id,
1193
1227
  participantId: i.participantId
1194
1228
  });
1195
1229
  }
1196
- emitRemoteStreamsChanged(e, t, { trackId: s, participantId: i }) {
1197
- const r = this.getActiveStreamsManager();
1198
- if (e !== r)
1230
+ handleChangedRemoteTracks(e, t, {
1231
+ trackId: s,
1232
+ participantId: i,
1233
+ isRemovedStream: r,
1234
+ isAddedStream: a
1235
+ }) {
1236
+ const o = this.getActiveStreamsManagerTools();
1237
+ if (e !== o.manager)
1199
1238
  return;
1200
- const a = [...r.getStreams()];
1201
- this.events.trigger(S.REMOTE_STREAMS_CHANGED, {
1202
- participantId: i,
1239
+ const c = o.getRemoteStreams();
1240
+ this.emitEventChangedRemoteTracks(c, t, { trackId: s, participantId: i }), (a || r) && this.emitEventChangedRemoteStreams(c);
1241
+ }
1242
+ emitEventChangedRemoteTracks(e, t, { trackId: s, participantId: i }) {
1243
+ this.events.trigger(E.REMOTE_TRACKS_CHANGED, {
1244
+ streams: e,
1203
1245
  changeType: t,
1204
1246
  trackId: s,
1205
- streams: a
1247
+ participantId: i
1206
1248
  });
1207
1249
  }
1208
- getActiveStreamsManager() {
1209
- return this.roleManager.getActiveManager();
1250
+ emitEventChangedRemoteStreams(e) {
1251
+ this.events.trigger(E.REMOTE_STREAMS_CHANGED, { streams: e });
1252
+ }
1253
+ getActiveStreamsManagerTools() {
1254
+ return this.streamsManagerProvider.getActiveStreamsManagerTools(
1255
+ this.roleManager.hasSpectator()
1256
+ );
1210
1257
  }
1211
1258
  attachRecvSessionTracks(e) {
1212
1259
  const { peerConnection: t } = e, s = (i) => {
1213
- this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, ee(i));
1260
+ this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, te(i));
1214
1261
  };
1215
1262
  t.addEventListener("track", s), this.disposeRecvSessionTrackListener = () => {
1216
1263
  t.removeEventListener("track", s);
@@ -1236,45 +1283,45 @@ class Tt {
1236
1283
  previous: e,
1237
1284
  next: t
1238
1285
  }) => {
1239
- if (_.hasSpectator(e) && !_.hasSpectator(t) && this.stopRecvSession(), _.hasSpectator(t)) {
1286
+ if (_.hasSpectator(e) && !_.hasSpectator(t) && (this.stopRecvSession(), this.emitEventChangedRemoteStreams(this.getRemoteStreams())), _.hasSpectator(t)) {
1240
1287
  const s = t.recvParams;
1241
1288
  this.startRecvSession(s.audioId, s.sendOffer);
1242
1289
  }
1243
1290
  };
1244
1291
  }
1245
- const Et = (n, e) => (n.degradationPreference = e.degradationPreference, n), St = (n, e) => {
1292
+ const mt = (n, e) => (n.degradationPreference = e.degradationPreference, n), Nt = (n, e) => {
1246
1293
  n.encodings ??= [];
1247
1294
  for (let t = n.encodings.length; t < e; t += 1)
1248
1295
  n.encodings.push({});
1249
1296
  return n;
1250
- }, Se = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, pt = Se(), Ct = (n, e) => {
1251
- if (pt(n, e))
1297
+ }, Ce = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Rt = Ce(), At = (n, e) => {
1298
+ if (Rt(n, e))
1252
1299
  return n;
1253
- }, mt = (n, e) => {
1254
- const t = n.maxBitrate, s = Ct(e, t);
1300
+ }, It = (n, e) => {
1301
+ const t = n.maxBitrate, s = At(e, t);
1255
1302
  return s !== void 0 && (n.maxBitrate = s), n;
1256
- }, pe = 1, Nt = Se(
1303
+ }, pe = 1, ft = Ce(
1257
1304
  pe
1258
- ), Rt = (n, e) => {
1305
+ ), vt = (n, e) => {
1259
1306
  const t = n === void 0 ? void 0 : Math.max(n, pe);
1260
- if (t !== void 0 && Nt(
1307
+ if (t !== void 0 && ft(
1261
1308
  t,
1262
1309
  e
1263
1310
  ))
1264
1311
  return t;
1265
- }, At = (n, e) => {
1266
- const t = n.scaleResolutionDownBy, s = Rt(
1312
+ }, Mt = (n, e) => {
1313
+ const t = n.scaleResolutionDownBy, s = vt(
1267
1314
  e,
1268
1315
  t
1269
1316
  );
1270
1317
  return s !== void 0 && (n.scaleResolutionDownBy = s), n;
1271
- }, It = (n, e) => {
1318
+ }, _t = (n, e) => {
1272
1319
  const t = e.encodings?.length ?? 0;
1273
- return St(n, t), n.encodings.forEach((s, i) => {
1320
+ return Nt(n, t), n.encodings.forEach((s, i) => {
1274
1321
  const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
1275
- mt(s, a), At(s, o);
1322
+ It(s, a), Mt(s, o);
1276
1323
  }), n;
1277
- }, ft = (n, e) => {
1324
+ }, Ot = (n, e) => {
1278
1325
  if (n.codecs?.length !== e.codecs?.length)
1279
1326
  return !0;
1280
1327
  for (let t = 0; t < (n.codecs?.length ?? 0); t++)
@@ -1291,15 +1338,15 @@ const Et = (n, e) => (n.degradationPreference = e.degradationPreference, n), St
1291
1338
  if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
1292
1339
  return !0;
1293
1340
  return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
1294
- }, Mt = async (n, e) => {
1341
+ }, Pt = async (n, e) => {
1295
1342
  const t = n.getParameters(), s = JSON.parse(
1296
1343
  JSON.stringify(t)
1297
1344
  );
1298
- It(t, e), Et(t, e);
1299
- const i = ft(s, t);
1345
+ _t(t, e), mt(t, e);
1346
+ const i = Ot(s, t);
1300
1347
  return i && await n.setParameters(t), { parameters: t, isChanged: i };
1301
- }, Ce = async (n, e, t) => {
1302
- const { isChanged: s, parameters: i } = await Mt(n, {
1348
+ }, me = async (n, e, t) => {
1349
+ const { isChanged: s, parameters: i } = await Pt(n, {
1303
1350
  encodings: [
1304
1351
  {
1305
1352
  scaleResolutionDownBy: e.scaleResolutionDownBy,
@@ -1308,36 +1355,36 @@ const Et = (n, e) => (n.degradationPreference = e.degradationPreference, n), St
1308
1355
  ]
1309
1356
  });
1310
1357
  return s && t && t(i), { isChanged: s, parameters: i };
1311
- }, vt = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), _t = async (n, e, t) => {
1312
- const s = vt(n, e);
1358
+ }, bt = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), Dt = async (n, e, t) => {
1359
+ const s = bt(n, e);
1313
1360
  if (s)
1314
- return Ce(s, { maxBitrate: t });
1361
+ return me(s, { maxBitrate: t });
1315
1362
  };
1316
- var b = /* @__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))(b || {});
1317
- const me = [
1363
+ var P = /* @__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))(P || {});
1364
+ const Ne = [
1318
1365
  "presentation:start",
1319
1366
  "presentation:started",
1320
1367
  "presentation:end",
1321
1368
  "presentation:ended",
1322
1369
  "presentation:failed"
1323
- ], Ot = () => new A(me);
1324
- var bt = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(bt || {});
1325
- const Pt = G({
1370
+ ], yt = () => new A(Ne);
1371
+ var wt = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(wt || {});
1372
+ const Lt = $({
1326
1373
  types: {
1327
1374
  context: {},
1328
1375
  events: {}
1329
1376
  },
1330
1377
  actions: {
1331
1378
  logTransition: (n, e) => {
1332
- h(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1379
+ d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1333
1380
  },
1334
1381
  logStateChange: (n, e) => {
1335
- h("PresentationStateMachine state changed", e.state);
1382
+ d("PresentationStateMachine state changed", e.state);
1336
1383
  },
1337
- setError: P(({ event: n }) => "error" in n && n.error !== void 0 ? {
1384
+ setError: b(({ event: n }) => "error" in n && n.error !== void 0 ? {
1338
1385
  lastError: n.error instanceof Error ? n.error : new Error(JSON.stringify(n.error))
1339
1386
  } : { lastError: void 0 }),
1340
- clearError: P({ lastError: void 0 })
1387
+ clearError: b({ lastError: void 0 })
1341
1388
  }
1342
1389
  }).createMachine({
1343
1390
  id: "presentation",
@@ -1647,9 +1694,9 @@ const Pt = G({
1647
1694
  }
1648
1695
  }
1649
1696
  });
1650
- class Dt extends q {
1697
+ class Ut extends q {
1651
1698
  constructor(e) {
1652
- super(Pt), this.subscribeCallEvents(e);
1699
+ super(Lt), this.subscribeCallEvents(e);
1653
1700
  }
1654
1701
  get isIdle() {
1655
1702
  return this.state === "presentation:idle";
@@ -1689,38 +1736,38 @@ class Dt extends q {
1689
1736
  }
1690
1737
  subscribeCallEvents(e) {
1691
1738
  this.addSubscription(
1692
- e.on(S.START_PRESENTATION, () => {
1739
+ e.on(E.START_PRESENTATION, () => {
1693
1740
  this.send({ type: "SCREEN.STARTING" });
1694
1741
  })
1695
1742
  ), this.addSubscription(
1696
- e.on(S.STARTED_PRESENTATION, () => {
1743
+ e.on(E.STARTED_PRESENTATION, () => {
1697
1744
  this.send({ type: "SCREEN.STARTED" });
1698
1745
  })
1699
1746
  ), this.addSubscription(
1700
- e.on(S.END_PRESENTATION, () => {
1747
+ e.on(E.END_PRESENTATION, () => {
1701
1748
  this.send({ type: "SCREEN.ENDING" });
1702
1749
  })
1703
1750
  ), this.addSubscription(
1704
- e.on(S.ENDED_PRESENTATION, () => {
1751
+ e.on(E.ENDED_PRESENTATION, () => {
1705
1752
  this.send({ type: "SCREEN.ENDED" });
1706
1753
  })
1707
1754
  ), this.addSubscription(
1708
- e.on(S.FAILED_PRESENTATION, (t) => {
1755
+ e.on(E.FAILED_PRESENTATION, (t) => {
1709
1756
  this.send({ type: "SCREEN.FAILED", error: t });
1710
1757
  })
1711
1758
  ), this.addSubscription(
1712
- e.on(S.ENDED, () => {
1759
+ e.on(E.ENDED, () => {
1713
1760
  this.send({ type: "CALL.ENDED" });
1714
1761
  })
1715
1762
  ), this.addSubscription(
1716
- e.on(S.FAILED, (t) => {
1763
+ e.on(E.FAILED, (t) => {
1717
1764
  this.send({ type: "CALL.FAILED", error: t });
1718
1765
  })
1719
1766
  );
1720
1767
  }
1721
1768
  }
1722
- const yt = 1, Ws = (n) => We(n);
1723
- class wt {
1769
+ const Ft = 1, Xs = (n) => xe(n);
1770
+ class kt {
1724
1771
  events;
1725
1772
  presentationStateMachine;
1726
1773
  promisePendingStartPresentation;
@@ -1733,7 +1780,7 @@ class wt {
1733
1780
  callManager: e,
1734
1781
  maxBitrate: t
1735
1782
  }) {
1736
- this.callManager = e, this.maxBitrate = t, this.events = Ot(), this.presentationStateMachine = new Dt(this.callManager.events), this.subscribe();
1783
+ this.callManager = e, this.maxBitrate = t, this.events = yt(), this.presentationStateMachine = new Ut(this.callManager.events), this.subscribe();
1737
1784
  }
1738
1785
  get presentationActor() {
1739
1786
  return this.presentationStateMachine.actorRef;
@@ -1775,8 +1822,8 @@ class wt {
1775
1822
  const i = this.callManager.getEstablishedRTCSession();
1776
1823
  return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
1777
1824
  const a = r instanceof Error ? r : new Error(String(r));
1778
- throw this.events.trigger(b.FAILED_PRESENTATION, a), r;
1779
- }) : t && this.events.trigger(b.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
1825
+ throw this.events.trigger(P.FAILED_PRESENTATION, a), r;
1826
+ }) : t && this.events.trigger(P.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
1780
1827
  this.resetPresentation();
1781
1828
  });
1782
1829
  }
@@ -1815,15 +1862,15 @@ class wt {
1815
1862
  }
1816
1863
  subscribe() {
1817
1864
  this.callManager.on("presentation:start", (e) => {
1818
- this.events.trigger(b.START_PRESENTATION, e);
1865
+ this.events.trigger(P.START_PRESENTATION, e);
1819
1866
  }), this.callManager.on("presentation:started", (e) => {
1820
- this.events.trigger(b.STARTED_PRESENTATION, e);
1867
+ this.events.trigger(P.STARTED_PRESENTATION, e);
1821
1868
  }), this.callManager.on("presentation:end", (e) => {
1822
- this.events.trigger(b.END_PRESENTATION, e);
1869
+ this.events.trigger(P.END_PRESENTATION, e);
1823
1870
  }), this.callManager.on("presentation:ended", (e) => {
1824
- this.events.trigger(b.ENDED_PRESENTATION, e);
1871
+ this.events.trigger(P.ENDED_PRESENTATION, e);
1825
1872
  }), this.callManager.on("presentation:failed", (e) => {
1826
- this.events.trigger(b.FAILED_PRESENTATION, e);
1873
+ this.events.trigger(P.FAILED_PRESENTATION, e);
1827
1874
  }), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
1828
1875
  }
1829
1876
  async sendPresentationWithDuplicatedCalls(e, {
@@ -1831,7 +1878,7 @@ class wt {
1831
1878
  stream: s,
1832
1879
  presentationOptions: i,
1833
1880
  options: r = {
1834
- callLimit: yt
1881
+ callLimit: Ft
1835
1882
  }
1836
1883
  }) {
1837
1884
  const a = async () => this.sendPresentation(
@@ -1855,20 +1902,20 @@ class wt {
1855
1902
  sendEncodings: o,
1856
1903
  onAddedTransceiver: c
1857
1904
  }) {
1858
- const d = B(s, { contentHint: r });
1859
- if (d === void 0)
1905
+ const h = B(s, { contentHint: r });
1906
+ if (h === void 0)
1860
1907
  throw new Error("No streamPresentationTarget");
1861
- this.streamPresentationCurrent = d;
1862
- const E = e().then(async () => t.startPresentation(d, i, {
1908
+ this.streamPresentationCurrent = h;
1909
+ const u = e().then(async () => t.startPresentation(h, i, {
1863
1910
  degradationPreference: a,
1864
1911
  sendEncodings: o,
1865
1912
  onAddedTransceiver: c
1866
- })).then(this.setMaxBitrate).then(() => s).catch((u) => {
1913
+ })).then(this.setMaxBitrate).then(() => s).catch((l) => {
1867
1914
  this.removeStreamPresentationCurrent();
1868
- const T = u instanceof Error ? u : new Error(String(u));
1869
- throw this.events.trigger(b.FAILED_PRESENTATION, T), u;
1915
+ const S = l instanceof Error ? l : new Error(String(l));
1916
+ throw this.events.trigger(P.FAILED_PRESENTATION, S), l;
1870
1917
  });
1871
- return this.promisePendingStartPresentation = E, E.finally(() => {
1918
+ return this.promisePendingStartPresentation = u, u.finally(() => {
1872
1919
  this.promisePendingStartPresentation = void 0;
1873
1920
  });
1874
1921
  }
@@ -1877,7 +1924,7 @@ class wt {
1877
1924
  if (!e || !t || s === void 0)
1878
1925
  return;
1879
1926
  const i = e.getSenders();
1880
- await _t(i, t, s);
1927
+ await Dt(i, t, s);
1881
1928
  };
1882
1929
  getRtcSessionProtected = () => {
1883
1930
  const e = this.callManager.getEstablishedRTCSession();
@@ -1898,7 +1945,7 @@ class wt {
1898
1945
  delete this.streamPresentationCurrent;
1899
1946
  }
1900
1947
  }
1901
- class Lt {
1948
+ class Bt {
1902
1949
  data;
1903
1950
  getUa;
1904
1951
  constructor(e) {
@@ -1984,8 +2031,8 @@ class Lt {
1984
2031
  return this.data?.register === !0;
1985
2032
  }
1986
2033
  }
1987
- var p = /* @__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.CONNECTED_WITH_CONFIGURATION = "connected-with-configuration", n))(p || {});
1988
- const Ne = [
2034
+ 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.CONNECTED_WITH_CONFIGURATION = "connected-with-configuration", n))(C || {});
2035
+ const Re = [
1989
2036
  "connecting",
1990
2037
  "connected",
1991
2038
  "disconnected",
@@ -1995,7 +2042,7 @@ const Ne = [
1995
2042
  "registrationFailed",
1996
2043
  "newMessage",
1997
2044
  "sipEvent"
1998
- ], Ut = [
2045
+ ], Gt = [
1999
2046
  "disconnecting",
2000
2047
  "connect-started",
2001
2048
  "connect-succeeded",
@@ -2003,12 +2050,12 @@ const Ne = [
2003
2050
  "connect-parameters-resolve-success",
2004
2051
  "connect-parameters-resolve-failed",
2005
2052
  "connected-with-configuration"
2006
- ], Re = [...Ne, ...Ut], Ft = () => new A(Re);
2007
- function kt(n) {
2053
+ ], Ae = [...Re, ...Gt], $t = () => new A(Ae);
2054
+ function qt(n) {
2008
2055
  return (e) => `sip:${e}@${n}`;
2009
2056
  }
2010
- const Bt = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Ae = (n) => n.trim().replaceAll(" ", "_"), $t = Bt(1e5, 99999999), Gt = 3;
2011
- class qt {
2057
+ const Ht = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Ie = (n) => n.trim().replaceAll(" ", "_"), Vt = Ht(1e5, 99999999), Wt = 3;
2058
+ class xt {
2012
2059
  cancelableConnectWithRepeatedCalls;
2013
2060
  JsSIP;
2014
2061
  events;
@@ -2034,28 +2081,28 @@ class qt {
2034
2081
  }
2035
2082
  let r = !1;
2036
2083
  const a = this.getConnectionConfiguration();
2037
- e !== void 0 && e !== a?.displayName && (r = i.set("display_name", Ae(e)), this.updateConnectionConfiguration("displayName", e));
2084
+ e !== void 0 && e !== a?.displayName && (r = i.set("display_name", Ie(e)), this.updateConnectionConfiguration("displayName", e));
2038
2085
  const o = r;
2039
2086
  o ? t(o) : s(new Error("nothing changed"));
2040
2087
  });
2041
2088
  disconnect = async () => {
2042
- this.events.trigger(p.DISCONNECTING, {});
2089
+ this.events.trigger(C.DISCONNECTING, {});
2043
2090
  const e = new Promise((s) => {
2044
- this.events.once(p.DISCONNECTED, () => {
2091
+ this.events.once(C.DISCONNECTED, () => {
2045
2092
  s();
2046
2093
  });
2047
2094
  }), t = this.getUa();
2048
- return t ? t.stop() : this.events.trigger(p.DISCONNECTED, { socket: {}, error: !1 }), e.finally(() => {
2095
+ return t ? t.stop() : this.events.trigger(C.DISCONNECTED, { socket: {}, error: !1 }), e.finally(() => {
2049
2096
  t?.removeAllListeners(), this.setUa(void 0), this.stateMachine.reset();
2050
2097
  });
2051
2098
  };
2052
2099
  cancelRequests() {
2053
2100
  this.cancelConnectWithRepeatedCalls();
2054
2101
  }
2055
- connectWithDuplicatedCalls = async (e, { callLimit: t = Gt } = {}) => {
2102
+ connectWithDuplicatedCalls = async (e, { callLimit: t = Wt } = {}) => {
2056
2103
  const s = async () => this.connectInner(e), i = (r) => {
2057
- const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = r != null && !ze(r);
2058
- return c || d;
2104
+ const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), h = r != null && !Ke(r);
2105
+ return c || h;
2059
2106
  };
2060
2107
  return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = he({
2061
2108
  targetFunction: s,
@@ -2091,17 +2138,17 @@ class qt {
2091
2138
  sessionTimers: a,
2092
2139
  registerExpires: o,
2093
2140
  connectionRecoveryMinInterval: c,
2094
- connectionRecoveryMaxInterval: d,
2095
- userAgent: E,
2096
- displayName: u = "",
2097
- register: T = !1,
2141
+ connectionRecoveryMaxInterval: h,
2142
+ userAgent: u,
2143
+ displayName: l = "",
2144
+ register: S = !1,
2098
2145
  extraHeaders: m = []
2099
2146
  }) => {
2100
2147
  this.stateMachine.startInitUa(), this.setConnectionConfiguration({
2101
2148
  sipServerIp: s,
2102
2149
  sipServerUrl: i,
2103
- displayName: u,
2104
- register: T,
2150
+ displayName: l,
2151
+ register: S,
2105
2152
  user: e,
2106
2153
  password: t
2107
2154
  }), this.getUa() && await this.disconnect();
@@ -2111,13 +2158,13 @@ class qt {
2111
2158
  password: t,
2112
2159
  sipServerIp: s,
2113
2160
  sipServerUrl: i,
2114
- displayName: u,
2115
- register: T,
2161
+ displayName: l,
2162
+ register: S,
2116
2163
  sessionTimers: a,
2117
2164
  registerExpires: o,
2118
2165
  connectionRecoveryMinInterval: c,
2119
- connectionRecoveryMaxInterval: d,
2120
- userAgent: E,
2166
+ connectionRecoveryMaxInterval: h,
2167
+ userAgent: u,
2121
2168
  remoteAddress: r,
2122
2169
  extraHeaders: m
2123
2170
  },
@@ -2132,15 +2179,15 @@ class qt {
2132
2179
  return;
2133
2180
  }
2134
2181
  let i;
2135
- i = ((c, d) => {
2182
+ i = ((c, h) => {
2136
2183
  if (this.getConnectionConfiguration()?.register === !0)
2137
- return this.registrationManager.subscribeToStartEvents(c, d);
2138
- const u = p.CONNECTED, T = [p.DISCONNECTED];
2139
- return this.events.on(u, c), T.forEach((m) => {
2140
- this.events.on(m, d);
2184
+ return this.registrationManager.subscribeToStartEvents(c, h);
2185
+ const l = C.CONNECTED, S = [C.DISCONNECTED];
2186
+ return this.events.on(l, c), S.forEach((m) => {
2187
+ this.events.on(m, h);
2141
2188
  }), () => {
2142
- this.events.off(u, c), T.forEach((m) => {
2143
- this.events.off(m, d);
2189
+ this.events.off(l, c), S.forEach((m) => {
2190
+ this.events.off(m, h);
2144
2191
  });
2145
2192
  };
2146
2193
  })(() => {
@@ -2153,35 +2200,35 @@ class qt {
2153
2200
  this.cancelableConnectWithRepeatedCalls?.cancel();
2154
2201
  }
2155
2202
  proxyEvents() {
2156
- this.events.on(p.CONNECTED, () => {
2203
+ this.events.on(C.CONNECTED, () => {
2157
2204
  const e = this.getConnectionConfiguration(), t = this.getUa();
2158
- e !== void 0 && t !== void 0 && this.events.trigger(p.CONNECTED_WITH_CONFIGURATION, {
2205
+ e !== void 0 && t !== void 0 && this.events.trigger(C.CONNECTED_WITH_CONFIGURATION, {
2159
2206
  ...e,
2160
2207
  ua: t
2161
2208
  });
2162
2209
  });
2163
2210
  }
2164
2211
  }
2165
- var Ht = /* @__PURE__ */ ((n) => (n.IDLE = "connection:idle", n.PREPARING = "connection:preparing", n.CONNECTING = "connection:connecting", n.CONNECTED = "connection:connected", n.REGISTERED = "connection:registered", n.ESTABLISHED = "connection:established", n.DISCONNECTED = "connection:disconnected", n.FAILED = "connection:failed", n))(Ht || {}), Ie = /* @__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))(Ie || {});
2166
- const Vt = Object.values(Ie), Wt = G({
2212
+ var Qt = /* @__PURE__ */ ((n) => (n.IDLE = "connection:idle", n.PREPARING = "connection:preparing", n.CONNECTING = "connection:connecting", n.CONNECTED = "connection:connected", n.REGISTERED = "connection:registered", n.ESTABLISHED = "connection:established", n.DISCONNECTED = "connection:disconnected", n.FAILED = "connection:failed", n))(Qt || {}), fe = /* @__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))(fe || {});
2213
+ const Yt = Object.values(fe), Xt = $({
2167
2214
  types: {
2168
2215
  context: {},
2169
2216
  events: {}
2170
2217
  },
2171
2218
  actions: {
2172
2219
  logTransition: (n, e) => {
2173
- h(`State transition: ${e.from} -> ${e.to} (${e.event})`);
2220
+ d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
2174
2221
  },
2175
2222
  logStateChange: (n, e) => {
2176
- h("ConnectionStateMachine state changed", e.state);
2223
+ d("ConnectionStateMachine state changed", e.state);
2177
2224
  },
2178
- setError: P({
2225
+ setError: b({
2179
2226
  error: ({ event: n }) => {
2180
2227
  if (n.type === "CONNECTION_FAILED" && "error" in n)
2181
2228
  return n.error;
2182
2229
  }
2183
2230
  }),
2184
- clearError: P({
2231
+ clearError: b({
2185
2232
  error: () => {
2186
2233
  }
2187
2234
  })
@@ -2543,12 +2590,12 @@ const Vt = Object.values(Ie), Wt = G({
2543
2590
  }
2544
2591
  }
2545
2592
  });
2546
- class xt extends q {
2593
+ class Jt extends q {
2547
2594
  stateChangeListeners = /* @__PURE__ */ new Set();
2548
2595
  events;
2549
2596
  unsubscribeFromEvents;
2550
2597
  constructor(e) {
2551
- super(Wt), this.events = e, this.addSubscription(
2598
+ super(Xt), this.events = e, this.addSubscription(
2552
2599
  this.subscribe((t) => {
2553
2600
  const s = t.value;
2554
2601
  this.stateChangeListeners.forEach((i) => {
@@ -2642,14 +2689,14 @@ class xt extends q {
2642
2689
  return this.getSnapshot().can({ type: e });
2643
2690
  }
2644
2691
  getValidEvents() {
2645
- return Vt.filter((e) => this.canTransition(e));
2692
+ return Yt.filter((e) => this.canTransition(e));
2646
2693
  }
2647
2694
  hasState(e) {
2648
2695
  return this.getSnapshot().matches(e);
2649
2696
  }
2650
2697
  sendEvent(e) {
2651
2698
  if (!this.getSnapshot().can(e)) {
2652
- h(
2699
+ d(
2653
2700
  `Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
2654
2701
  );
2655
2702
  return;
@@ -2707,14 +2754,14 @@ class xt extends q {
2707
2754
  };
2708
2755
  }
2709
2756
  handleRegistrationFailed = (e) => {
2710
- const { response: t } = e, s = t.status_code || "Unknown", i = t.reason_phrase || "Registration failed", r = new Error(`Registration failed: ${s} ${i}`);
2711
- this.toFailed(r);
2757
+ const t = e.response?.status_code ?? "Unknown", s = e.response?.reason_phrase ?? "Registration failed", i = new Error(`Registration failed: ${t} ${s}`);
2758
+ this.toFailed(i);
2712
2759
  };
2713
2760
  handleConnectFailed = (e) => {
2714
2761
  this.toFailed(e instanceof Error ? e : void 0);
2715
2762
  };
2716
2763
  }
2717
- class Qt {
2764
+ class zt {
2718
2765
  events;
2719
2766
  getUaProtected;
2720
2767
  constructor(e) {
@@ -2723,25 +2770,25 @@ class Qt {
2723
2770
  async register() {
2724
2771
  const e = this.getUaProtected();
2725
2772
  return new Promise((t, s) => {
2726
- e.on(p.REGISTERED, t), e.on(p.REGISTRATION_FAILED, s), e.register();
2773
+ e.on(C.REGISTERED, t), e.on(C.REGISTRATION_FAILED, s), e.register();
2727
2774
  });
2728
2775
  }
2729
2776
  async unregister() {
2730
2777
  const e = this.getUaProtected();
2731
2778
  return new Promise((t) => {
2732
- e.on(p.UNREGISTERED, t), e.unregister();
2779
+ e.on(C.UNREGISTERED, t), e.unregister();
2733
2780
  });
2734
2781
  }
2735
2782
  async tryRegister() {
2736
2783
  try {
2737
2784
  await this.unregister();
2738
2785
  } catch (e) {
2739
- h("tryRegister", e);
2786
+ d("tryRegister", e);
2740
2787
  }
2741
2788
  return this.register();
2742
2789
  }
2743
2790
  subscribeToStartEvents(e, t) {
2744
- const s = p.REGISTERED, i = [p.REGISTRATION_FAILED, p.DISCONNECTED];
2791
+ const s = C.REGISTERED, i = [C.REGISTRATION_FAILED, C.DISCONNECTED];
2745
2792
  return this.events.on(s, e), i.forEach((r) => {
2746
2793
  this.events.on(r, t);
2747
2794
  }), () => {
@@ -2751,7 +2798,7 @@ class Qt {
2751
2798
  };
2752
2799
  }
2753
2800
  }
2754
- class Yt {
2801
+ class Kt {
2755
2802
  uaFactory;
2756
2803
  getUaProtected;
2757
2804
  constructor(e) {
@@ -2797,26 +2844,26 @@ class Yt {
2797
2844
  extraHeaders: a
2798
2845
  }) {
2799
2846
  return new Promise((o, c) => {
2800
- const { configuration: d } = this.uaFactory.createConfiguration({
2847
+ const { configuration: h } = this.uaFactory.createConfiguration({
2801
2848
  sipServerUrl: i,
2802
2849
  displayName: t,
2803
2850
  userAgent: e,
2804
2851
  sipServerIp: s
2805
- }), E = this.uaFactory.createUA({ ...d, remoteAddress: r, extraHeaders: a }), u = () => {
2852
+ }), u = this.uaFactory.createUA({ ...h, remoteAddress: r, extraHeaders: a }), l = () => {
2806
2853
  const m = new Error("Telephony is not available");
2807
2854
  c(m);
2808
2855
  };
2809
- E.once(p.DISCONNECTED, u);
2810
- const T = () => {
2811
- E.removeAllListeners(), E.once(p.DISCONNECTED, () => {
2856
+ u.once(C.DISCONNECTED, l);
2857
+ const S = () => {
2858
+ u.removeAllListeners(), u.once(C.DISCONNECTED, () => {
2812
2859
  o();
2813
- }), E.stop();
2860
+ }), u.stop();
2814
2861
  };
2815
- E.once(p.CONNECTED, T), E.start();
2862
+ u.once(C.CONNECTED, S), u.start();
2816
2863
  });
2817
2864
  }
2818
2865
  }
2819
- const Xt = (n) => {
2866
+ const jt = (n) => {
2820
2867
  const e = [];
2821
2868
  return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
2822
2869
  };
@@ -2845,10 +2892,10 @@ class w {
2845
2892
  throw new Error("user is required for authorized connection");
2846
2893
  }
2847
2894
  static resolveAuthorizationUser(e, t) {
2848
- return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${$t()}`;
2895
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${Vt()}`;
2849
2896
  }
2850
2897
  static buildExtraHeaders(e, t) {
2851
- const s = e !== void 0 && e !== "" ? Xt(e) : [];
2898
+ const s = e !== void 0 && e !== "" ? jt(e) : [];
2852
2899
  return t === void 0 ? s : [...s, ...t];
2853
2900
  }
2854
2901
  createConfiguration({
@@ -2861,9 +2908,9 @@ class w {
2861
2908
  sessionTimers: o = !1,
2862
2909
  registerExpires: c = 300,
2863
2910
  // 5 minutes in sec
2864
- connectionRecoveryMinInterval: d = 2,
2865
- connectionRecoveryMaxInterval: E = 6,
2866
- userAgent: u
2911
+ connectionRecoveryMinInterval: h = 2,
2912
+ connectionRecoveryMaxInterval: u = 6,
2913
+ userAgent: l
2867
2914
  }) {
2868
2915
  w.validateParametersConnection({
2869
2916
  register: a,
@@ -2872,20 +2919,20 @@ class w {
2872
2919
  sipServerIp: r,
2873
2920
  sipServerUrl: s
2874
2921
  });
2875
- const T = w.resolveAuthorizationUser(a, e), m = kt(r), O = m(T), N = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
2922
+ const S = w.resolveAuthorizationUser(a, e), m = qt(r), O = m(S), N = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
2876
2923
  return {
2877
2924
  configuration: {
2878
2925
  password: t,
2879
2926
  register: a,
2880
2927
  uri: O,
2881
- display_name: Ae(i),
2882
- user_agent: u,
2928
+ display_name: Ie(i),
2929
+ user_agent: l,
2883
2930
  sdpSemantics: "unified-plan",
2884
2931
  sockets: [N],
2885
2932
  session_timers: o,
2886
2933
  register_expires: c,
2887
- connection_recovery_min_interval: d,
2888
- connection_recovery_max_interval: E
2934
+ connection_recovery_min_interval: h,
2935
+ connection_recovery_max_interval: u
2889
2936
  },
2890
2937
  helpers: {
2891
2938
  socket: N,
@@ -2907,13 +2954,13 @@ class w {
2907
2954
  extraHeaders: e.extraHeaders
2908
2955
  });
2909
2956
  return t.eachTriggers((a, o) => {
2910
- const c = Ne.find((d) => d === o);
2957
+ const c = Re.find((h) => h === o);
2911
2958
  c && r.on(c, a);
2912
2959
  }), { ua: r, helpers: i };
2913
2960
  }
2914
2961
  }
2915
- const fe = "Not ready for connection", Jt = (n) => n instanceof Error && n.message === fe, zt = () => new Error(fe), Kt = async (n) => typeof n == "function" ? n() : n;
2916
- class jt {
2962
+ const ve = "Not ready for connection", Zt = (n) => n instanceof Error && n.message === ve, en = () => new Error(ve), tn = async (n) => typeof n == "function" ? n() : n;
2963
+ class nn {
2917
2964
  events;
2918
2965
  ua;
2919
2966
  socket;
@@ -2925,15 +2972,15 @@ class jt {
2925
2972
  configurationManager;
2926
2973
  JsSIP;
2927
2974
  constructor({ JsSIP: e }) {
2928
- this.JsSIP = e, this.events = Ft(), this.uaFactory = new w(e), this.registrationManager = new Qt({
2975
+ this.JsSIP = e, this.events = $t(), this.uaFactory = new w(e), this.registrationManager = new zt({
2929
2976
  events: this.events,
2930
2977
  getUaProtected: this.getUaProtected
2931
- }), this.stateMachine = new xt(this.events), this.configurationManager = new Lt({
2978
+ }), this.stateMachine = new Jt(this.events), this.configurationManager = new Bt({
2932
2979
  getUa: this.getUa
2933
- }), this.sipOperations = new Yt({
2980
+ }), this.sipOperations = new Kt({
2934
2981
  uaFactory: this.uaFactory,
2935
2982
  getUaProtected: this.getUaProtected
2936
- }), this.connectionFlow = new qt({
2983
+ }), this.connectionFlow = new xt({
2937
2984
  JsSIP: this.JsSIP,
2938
2985
  events: this.events,
2939
2986
  uaFactory: this.uaFactory,
@@ -2989,7 +3036,7 @@ class jt {
2989
3036
  return this.configurationManager.isRegister();
2990
3037
  }
2991
3038
  connect = async (e, t) => this.disconnect().catch((s) => {
2992
- h("connect: disconnect error", s);
3039
+ d("connect: disconnect error", s);
2993
3040
  }).then(async () => this.connectWithProcessError(e, t));
2994
3041
  set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
2995
3042
  disconnect = async () => {
@@ -3038,7 +3085,7 @@ class jt {
3038
3085
  getUa = () => this.ua;
3039
3086
  connectWithProcessError = async (e, t) => {
3040
3087
  if (!(t?.hasReadyForConnection?.() ?? !0))
3041
- throw zt();
3088
+ throw en();
3042
3089
  return this.processConnect(e, t).catch(async (i) => {
3043
3090
  const r = i;
3044
3091
  return this.disconnect().then(() => {
@@ -3048,18 +3095,18 @@ class jt {
3048
3095
  });
3049
3096
  });
3050
3097
  };
3051
- processConnect = async (e, t) => (this.events.trigger(p.CONNECT_STARTED, {}), Kt(e).then((s) => (this.events.trigger(p.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
3052
- throw this.events.trigger(p.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
3053
- }).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(p.CONNECT_SUCCEEDED, {
3098
+ processConnect = async (e, t) => (this.events.trigger(C.CONNECT_STARTED, {}), tn(e).then((s) => (this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
3099
+ throw this.events.trigger(C.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
3100
+ }).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(C.CONNECT_SUCCEEDED, {
3054
3101
  ...s
3055
3102
  }), s)).catch((s) => {
3056
3103
  const i = s ?? new Error("Failed to connect to server");
3057
- throw this.events.trigger(p.CONNECT_FAILED, i), i;
3104
+ throw this.events.trigger(C.CONNECT_FAILED, i), i;
3058
3105
  }));
3059
3106
  }
3060
- class Zt {
3107
+ class sn {
3061
3108
  connectionManager;
3062
- stackPromises = de({
3109
+ stackPromises = le({
3063
3110
  noRunIsNotActual: !0
3064
3111
  });
3065
3112
  constructor({ connectionManager: e }) {
@@ -3071,11 +3118,11 @@ class Zt {
3071
3118
  this.stackPromises.stop();
3072
3119
  }
3073
3120
  }
3074
- const te = 0, en = 30;
3075
- class tn {
3076
- countInner = te;
3077
- initialCount = te;
3078
- limitInner = en;
3121
+ const ne = 0, rn = 30;
3122
+ class an {
3123
+ countInner = ne;
3124
+ initialCount = ne;
3125
+ limitInner = rn;
3079
3126
  isInProgress = !1;
3080
3127
  onStatusChange;
3081
3128
  constructor({
@@ -3108,7 +3155,7 @@ class tn {
3108
3155
  this.countInner = this.initialCount, this.finishAttempt();
3109
3156
  }
3110
3157
  }
3111
- class nn {
3158
+ class on {
3112
3159
  connectionManager;
3113
3160
  interval;
3114
3161
  checkTelephonyByTimeout = void 0;
@@ -3124,7 +3171,7 @@ class nn {
3124
3171
  onSuccessRequest: t,
3125
3172
  onFailRequest: s
3126
3173
  }) {
3127
- this.stop(), this.cancelableBeforeRequest = new $(e), this.checkTelephonyByTimeout = Ge({
3174
+ this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = qe({
3128
3175
  isDontStopOnFail: !0,
3129
3176
  requestInterval: this.interval,
3130
3177
  request: async () => {
@@ -3153,7 +3200,7 @@ const Me = [
3153
3200
  "changed-attempt-status",
3154
3201
  "stop-attempts-by-error",
3155
3202
  "limit-reached-attempts"
3156
- ], sn = () => new A(Me);
3203
+ ], cn = () => new A(Me);
3157
3204
  class K {
3158
3205
  callManager;
3159
3206
  disposers = [];
@@ -3179,40 +3226,40 @@ class K {
3179
3226
  this.callManager.isCallActive ? e?.() : t();
3180
3227
  }
3181
3228
  }
3182
- const rn = 15e3, an = 2;
3183
- class on {
3229
+ const dn = 15e3, hn = 2;
3230
+ class ln {
3184
3231
  connectionManager;
3185
3232
  pingServerByTimeoutWithFailCalls;
3186
3233
  constructor({ connectionManager: e }) {
3187
- this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = qe(an, {
3234
+ this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = He(hn, {
3188
3235
  whenPossibleRequest: async () => {
3189
3236
  },
3190
- requestInterval: rn,
3191
- request: async () => (h("ping"), this.connectionManager.ping().then(() => {
3192
- h("ping success");
3237
+ requestInterval: dn,
3238
+ request: async () => (d("ping"), this.connectionManager.ping().then(() => {
3239
+ d("ping success");
3193
3240
  }))
3194
3241
  });
3195
3242
  }
3196
3243
  start({ onFailRequest: e }) {
3197
- this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(h);
3244
+ this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(d);
3198
3245
  }
3199
3246
  stop() {
3200
3247
  this.pingServerByTimeoutWithFailCalls.stop();
3201
3248
  }
3202
3249
  }
3203
- class cn {
3250
+ class gn {
3204
3251
  pingServerRequester;
3205
3252
  notActiveCallSubscriber;
3206
3253
  constructor({
3207
3254
  connectionManager: e,
3208
3255
  callManager: t
3209
3256
  }) {
3210
- this.pingServerRequester = new on({
3257
+ this.pingServerRequester = new ln({
3211
3258
  connectionManager: e
3212
3259
  }), this.notActiveCallSubscriber = new K({ callManager: t });
3213
3260
  }
3214
3261
  start({ onFailRequest: e }) {
3215
- h("start"), this.notActiveCallSubscriber.subscribe({
3262
+ d("start"), this.notActiveCallSubscriber.subscribe({
3216
3263
  onActive: () => {
3217
3264
  this.pingServerRequester.stop();
3218
3265
  },
@@ -3222,13 +3269,13 @@ class cn {
3222
3269
  });
3223
3270
  }
3224
3271
  stop() {
3225
- h("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
3272
+ d("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
3226
3273
  }
3227
3274
  unsubscribeCallStatusChange() {
3228
3275
  this.notActiveCallSubscriber.unsubscribe();
3229
3276
  }
3230
3277
  }
3231
- class hn {
3278
+ class un {
3232
3279
  connectionManager;
3233
3280
  isRegistrationFailed = !1;
3234
3281
  disposers = [];
@@ -3264,12 +3311,12 @@ class hn {
3264
3311
  this.isRegistrationFailed = !1;
3265
3312
  }
3266
3313
  }
3267
- const dn = 3e3, ln = 15e3, ne = {
3314
+ const Tn = 3e3, Sn = 15e3, se = {
3268
3315
  LIMIT_REACHED: "Limit reached",
3269
3316
  FAILED_TO_RECONNECT: "Failed to reconnect"
3270
- }, gn = async () => {
3271
- }, un = (n) => !0;
3272
- class Tn {
3317
+ }, En = async () => {
3318
+ }, Cn = (n) => !0;
3319
+ class pn {
3273
3320
  events;
3274
3321
  connectionManager;
3275
3322
  connectionQueueManager;
@@ -3289,28 +3336,28 @@ class Tn {
3289
3336
  connectionManager: t,
3290
3337
  callManager: s
3291
3338
  }, i) {
3292
- const r = i?.onBeforeRetry ?? gn, a = i?.canRetryOnError ?? un;
3293
- this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = sn(), this.checkTelephonyRequester = new nn({
3339
+ const r = i?.onBeforeRetry ?? En, a = i?.canRetryOnError ?? Cn;
3340
+ this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = cn(), this.checkTelephonyRequester = new on({
3294
3341
  connectionManager: t,
3295
- interval: i?.checkTelephonyRequestInterval ?? ln
3296
- }), this.pingServerIfNotActiveCallRequester = new cn({
3342
+ interval: i?.checkTelephonyRequestInterval ?? Sn
3343
+ }), this.pingServerIfNotActiveCallRequester = new gn({
3297
3344
  connectionManager: t,
3298
3345
  callManager: s
3299
- }), this.registrationFailedOutOfCallSubscriber = new hn({
3346
+ }), this.registrationFailedOutOfCallSubscriber = new un({
3300
3347
  connectionManager: t,
3301
3348
  callManager: s
3302
- }), this.attemptsState = new tn({
3349
+ }), this.attemptsState = new an({
3303
3350
  onStatusChange: this.emitStatusChange
3304
- }), this.cancelableRequestBeforeRetry = new $(r), this.delayBetweenAttempts = new He(
3305
- i?.timeoutBetweenAttempts ?? dn
3351
+ }), this.cancelableRequestBeforeRetry = new G(r), this.delayBetweenAttempts = new Ve(
3352
+ i?.timeoutBetweenAttempts ?? Tn
3306
3353
  ), this.notActiveCallSubscriber = new K({ callManager: s });
3307
3354
  }
3308
3355
  start(e) {
3309
- h("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToNotActiveCall(e);
3356
+ d("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToNotActiveCall(e);
3310
3357
  }
3311
3358
  stop() {
3312
- h("auto connector stop"), this.unsubscribeFromNotActiveCall(), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow().catch((e) => {
3313
- h("auto connector stop from stop method: error", e);
3359
+ d("auto connector stop"), this.unsubscribeFromNotActiveCall(), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow().catch((e) => {
3360
+ d("auto connector stop from stop method: error", e);
3314
3361
  });
3315
3362
  }
3316
3363
  on(e, t) {
@@ -3329,77 +3376,77 @@ class Tn {
3329
3376
  this.events.off(e, t);
3330
3377
  }
3331
3378
  restartConnectionAttempts(e) {
3332
- h("auto connector restart connection attempts"), this.stopConnectionFlow().then(async () => this.attemptConnection(e)).catch((t) => {
3333
- h("auto connector failed to restart connection attempts:", t);
3379
+ d("auto connector restart connection attempts"), this.stopConnectionFlow().then(async () => this.attemptConnection(e)).catch((t) => {
3380
+ d("auto connector failed to restart connection attempts:", t);
3334
3381
  });
3335
3382
  }
3336
3383
  async stopConnectionFlow() {
3337
- h("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), await this.connectionQueueManager.disconnect();
3384
+ d("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), await this.connectionQueueManager.disconnect();
3338
3385
  }
3339
3386
  stopAttempts() {
3340
3387
  this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
3341
3388
  }
3342
3389
  stopConnectTriggers() {
3343
- h("stopConnectTriggers"), this.stopPingRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
3390
+ d("stopConnectTriggers"), this.stopPingRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
3344
3391
  }
3345
3392
  startCheckTelephony(e) {
3346
- h("startCheckTelephony"), this.checkTelephonyRequester.start({
3393
+ d("startCheckTelephony"), this.checkTelephonyRequester.start({
3347
3394
  onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
3348
3395
  onSuccessRequest: () => {
3349
- h("startCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
3396
+ d("startCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
3350
3397
  },
3351
3398
  onFailRequest: (t) => {
3352
- h("startCheckTelephony: onFailRequest", t.message);
3399
+ d("startCheckTelephony: onFailRequest", t.message);
3353
3400
  }
3354
3401
  });
3355
3402
  }
3356
3403
  async attemptConnection(e) {
3357
- if (h("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(f.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
3358
- h("attemptConnection: limit reached"), this.handleLimitReached(e);
3404
+ if (d("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(f.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
3405
+ d("attemptConnection: limit reached"), this.handleLimitReached(e);
3359
3406
  return;
3360
3407
  }
3361
3408
  return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.executeConnectionAttempt(e);
3362
3409
  }
3363
3410
  async executeConnectionAttempt(e) {
3364
3411
  try {
3365
- await this.connectionQueueManager.connect(e.getParameters, e.options), h("executeConnectionAttempt: success"), this.handleSucceededAttempt(e);
3412
+ await this.connectionQueueManager.connect(e.getParameters, e.options), d("executeConnectionAttempt: success"), this.handleSucceededAttempt(e);
3366
3413
  } catch (t) {
3367
3414
  this.handleConnectionError(t, e);
3368
3415
  }
3369
3416
  }
3370
3417
  handleConnectionError(e, t) {
3371
- if (Jt(e)) {
3418
+ if (Zt(e)) {
3372
3419
  this.attemptsState.finishAttempt(), this.events.trigger(f.STOP_ATTEMPTS_BY_ERROR, e);
3373
3420
  return;
3374
3421
  }
3375
3422
  if (!this.canRetryOnError(e)) {
3376
- h("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(f.STOP_ATTEMPTS_BY_ERROR, e);
3423
+ d("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(f.STOP_ATTEMPTS_BY_ERROR, e);
3377
3424
  return;
3378
3425
  }
3379
- if (Qe(e)) {
3380
- h("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(f.CANCELLED_ATTEMPTS, e);
3426
+ if (Ye(e)) {
3427
+ d("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(f.CANCELLED_ATTEMPTS, e);
3381
3428
  return;
3382
3429
  }
3383
- h("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
3430
+ d("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
3384
3431
  }
3385
3432
  handleLimitReached(e) {
3386
- this.attemptsState.finishAttempt(), this.events.trigger(f.LIMIT_REACHED_ATTEMPTS, new Error(ne.LIMIT_REACHED)), this.startCheckTelephony(e);
3433
+ this.attemptsState.finishAttempt(), this.events.trigger(f.LIMIT_REACHED_ATTEMPTS, new Error(se.LIMIT_REACHED)), this.startCheckTelephony(e);
3387
3434
  }
3388
3435
  handleSucceededAttempt(e) {
3389
- h("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(f.SUCCESS);
3436
+ d("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(f.SUCCESS);
3390
3437
  }
3391
3438
  subscribeToConnectTriggers(e) {
3392
3439
  this.startPingRequester(e), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
3393
- h("registrationFailedOutOfCallListener callback"), this.restartConnectionAttempts(e);
3440
+ d("registrationFailedOutOfCallListener callback"), this.restartConnectionAttempts(e);
3394
3441
  });
3395
3442
  }
3396
3443
  subscribeToNotActiveCall(e) {
3397
3444
  this.notActiveCallSubscriber.subscribe({
3398
3445
  onActive: () => {
3399
- h("subscribeToNotActiveCall onActive"), this.unsubscribeFromHardwareTriggers();
3446
+ d("subscribeToNotActiveCall onActive"), this.unsubscribeFromHardwareTriggers();
3400
3447
  },
3401
3448
  onInactive: () => {
3402
- h("subscribeToNotActiveCall onInactive"), this.subscribeToHardwareTriggers(e);
3449
+ d("subscribeToNotActiveCall onInactive"), this.subscribeToHardwareTriggers(e);
3403
3450
  }
3404
3451
  });
3405
3452
  }
@@ -3407,13 +3454,13 @@ class Tn {
3407
3454
  this.notActiveCallSubscriber.unsubscribe();
3408
3455
  }
3409
3456
  subscribeToHardwareTriggers(e) {
3410
- this.unsubscribeFromHardwareTriggers(), h("subscribeToHardwareTriggers"), this.networkInterfacesSubscriber?.subscribe({
3457
+ this.unsubscribeFromHardwareTriggers(), d("subscribeToHardwareTriggers"), this.networkInterfacesSubscriber?.subscribe({
3411
3458
  onChange: () => {
3412
- h("networkInterfacesSubscriber onChange"), this.restartConnectionAttempts(e);
3459
+ d("networkInterfacesSubscriber onChange"), this.restartConnectionAttempts(e);
3413
3460
  },
3414
3461
  onUnavailable: () => {
3415
- h("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow().catch((t) => {
3416
- h(
3462
+ d("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow().catch((t) => {
3463
+ d(
3417
3464
  "auto connector stop from networkInterfacesSubscriber onUnavailable: error",
3418
3465
  t
3419
3466
  );
@@ -3421,12 +3468,12 @@ class Tn {
3421
3468
  }
3422
3469
  }), this.resumeFromSleepModeSubscriber?.subscribe({
3423
3470
  onResume: () => {
3424
- h("resumeFromSleepModeSubscriber onResume"), this.restartConnectionAttempts(e);
3471
+ d("resumeFromSleepModeSubscriber onResume"), this.restartConnectionAttempts(e);
3425
3472
  }
3426
3473
  });
3427
3474
  }
3428
3475
  unsubscribeFromHardwareTriggers() {
3429
- h("unsubscribeFromHardwareTriggers"), this.networkInterfacesSubscriber?.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
3476
+ d("unsubscribeFromHardwareTriggers"), this.networkInterfacesSubscriber?.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
3430
3477
  }
3431
3478
  stopPingRequester() {
3432
3479
  this.pingServerIfNotActiveCallRequester.stop();
@@ -3434,18 +3481,18 @@ class Tn {
3434
3481
  startPingRequester(e) {
3435
3482
  this.pingServerIfNotActiveCallRequester.start({
3436
3483
  onFailRequest: () => {
3437
- h("pingRequester: onFailRequest"), this.restartConnectionAttempts(e);
3484
+ d("pingRequester: onFailRequest"), this.restartConnectionAttempts(e);
3438
3485
  }
3439
3486
  });
3440
3487
  }
3441
3488
  connectIfDisconnected(e) {
3442
3489
  const t = this.isConnectionUnavailable();
3443
- h("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(f.SUCCESS));
3490
+ d("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(f.SUCCESS));
3444
3491
  }
3445
3492
  scheduleReconnect(e) {
3446
- h("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (h("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (h("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
3447
- const s = t instanceof Error ? t : new Error(ne.FAILED_TO_RECONNECT);
3448
- this.attemptsState.finishAttempt(), $e(t) || Ve(t) ? this.events.trigger(f.CANCELLED_ATTEMPTS, s) : this.events.trigger(f.FAILED_ALL_ATTEMPTS, s), h("scheduleReconnect: error", t);
3493
+ d("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (d("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (d("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
3494
+ const s = t instanceof Error ? t : new Error(se.FAILED_TO_RECONNECT);
3495
+ this.attemptsState.finishAttempt(), $e(t) || We(t) ? this.events.trigger(f.CANCELLED_ATTEMPTS, s) : this.events.trigger(f.FAILED_ALL_ATTEMPTS, s), d("scheduleReconnect: error", t);
3449
3496
  });
3450
3497
  }
3451
3498
  isConnectionUnavailable() {
@@ -3457,12 +3504,12 @@ class Tn {
3457
3504
  };
3458
3505
  }
3459
3506
  var X = /* @__PURE__ */ ((n) => (n.STATE_CHANGED = "state-changed", n.STATE_RESET = "state-reset", n))(X || {});
3460
- const ve = ["state-changed", "state-reset"], En = () => new A(ve);
3461
- class Sn {
3507
+ const _e = ["state-changed", "state-reset"], mn = () => new A(_e);
3508
+ class Nn {
3462
3509
  events;
3463
3510
  state = {};
3464
3511
  constructor() {
3465
- this.events = En();
3512
+ this.events = mn();
3466
3513
  }
3467
3514
  getState() {
3468
3515
  return { ...this.state };
@@ -3513,30 +3560,30 @@ class Sn {
3513
3560
  }
3514
3561
  }
3515
3562
  var U = /* @__PURE__ */ ((n) => (n.RINGING = "ringing", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(U || {});
3516
- const _e = [
3563
+ const Oe = [
3517
3564
  "ringing",
3518
3565
  "declinedIncomingCall",
3519
3566
  "terminatedIncomingCall",
3520
3567
  "failedIncomingCall"
3521
- ], pn = () => new A(_e);
3522
- var Cn = /* @__PURE__ */ ((n) => (n.IDLE = "incoming:idle", n.RINGING = "incoming:ringing", n.CONSUMED = "incoming:consumed", n.DECLINED = "incoming:declined", n.TERMINATED = "incoming:terminated", n.FAILED = "incoming:failed", n))(Cn || {});
3523
- const mn = G({
3568
+ ], Rn = () => new A(Oe);
3569
+ var An = /* @__PURE__ */ ((n) => (n.IDLE = "incoming:idle", n.RINGING = "incoming:ringing", n.CONSUMED = "incoming:consumed", n.DECLINED = "incoming:declined", n.TERMINATED = "incoming:terminated", n.FAILED = "incoming:failed", n))(An || {});
3570
+ const In = $({
3524
3571
  types: {
3525
3572
  context: {},
3526
3573
  events: {}
3527
3574
  },
3528
3575
  actions: {
3529
3576
  logTransition: (n, e) => {
3530
- h(`State transition: ${e.from} -> ${e.to} (${e.event})`);
3577
+ d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
3531
3578
  },
3532
3579
  logStateChange: (n, e) => {
3533
- h("IncomingCallStateMachine state changed", e.state);
3580
+ d("IncomingCallStateMachine state changed", e.state);
3534
3581
  },
3535
- rememberIncoming: P(({ event: n }) => {
3582
+ rememberIncoming: b(({ event: n }) => {
3536
3583
  const { data: e } = n;
3537
3584
  return { remoteCallerData: e, lastReason: void 0 };
3538
3585
  }),
3539
- rememberReason: P(({ event: n, context: e }) => n.type === "INCOMING.CONSUMED" ? {
3586
+ rememberReason: b(({ event: n, context: e }) => n.type === "INCOMING.CONSUMED" ? {
3540
3587
  remoteCallerData: e.remoteCallerData,
3541
3588
  lastReason: "incoming:consumed"
3542
3589
  /* CONSUMED */
@@ -3553,7 +3600,7 @@ const mn = G({
3553
3600
  lastReason: "incoming:failed"
3554
3601
  /* FAILED */
3555
3602
  }),
3556
- clearIncoming: P(() => ({ remoteCallerData: void 0, lastReason: void 0 }))
3603
+ clearIncoming: b(() => ({ remoteCallerData: void 0, lastReason: void 0 }))
3557
3604
  }
3558
3605
  }).createMachine({
3559
3606
  id: "incoming",
@@ -3852,9 +3899,9 @@ const mn = G({
3852
3899
  }
3853
3900
  }
3854
3901
  });
3855
- class Nn extends q {
3902
+ class fn extends q {
3856
3903
  constructor({ incomingEvents: e, connectionEvents: t }) {
3857
- super(mn), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
3904
+ super(In), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
3858
3905
  }
3859
3906
  get isIdle() {
3860
3907
  return this.state === "incoming:idle";
@@ -3922,15 +3969,15 @@ class Nn extends q {
3922
3969
  }
3923
3970
  subscribeConnectionEvents(e) {
3924
3971
  this.addSubscription(
3925
- e.on(p.DISCONNECTED, () => {
3972
+ e.on(C.DISCONNECTED, () => {
3926
3973
  this.toClearIncoming();
3927
3974
  })
3928
3975
  ), this.addSubscription(
3929
- e.on(p.REGISTRATION_FAILED, () => {
3976
+ e.on(C.REGISTRATION_FAILED, () => {
3930
3977
  this.toClearIncoming();
3931
3978
  })
3932
3979
  ), this.addSubscription(
3933
- e.on(p.CONNECT_FAILED, () => {
3980
+ e.on(C.CONNECT_FAILED, () => {
3934
3981
  this.toClearIncoming();
3935
3982
  })
3936
3983
  );
@@ -3939,14 +3986,14 @@ class Nn extends q {
3939
3986
  this.send({ type: "INCOMING.CLEAR" });
3940
3987
  }
3941
3988
  }
3942
- const Rn = 486, An = 487;
3943
- class In {
3989
+ const vn = 486, Mn = 487;
3990
+ class _n {
3944
3991
  events;
3945
3992
  incomingStateMachine;
3946
3993
  incomingRTCSession;
3947
3994
  connectionManager;
3948
3995
  constructor(e) {
3949
- this.connectionManager = e, this.events = pn(), this.incomingStateMachine = new Nn({
3996
+ this.connectionManager = e, this.events = Rn(), this.incomingStateMachine = new fn({
3950
3997
  incomingEvents: this.events,
3951
3998
  connectionEvents: this.connectionManager.events
3952
3999
  }), this.start();
@@ -3982,7 +4029,7 @@ class In {
3982
4029
  return this.incomingStateMachine.toConsumed(), this.removeIncomingSession(), e;
3983
4030
  };
3984
4031
  async declineToIncomingCall({
3985
- statusCode: e = An
4032
+ statusCode: e = Mn
3986
4033
  } = {}) {
3987
4034
  return new Promise((t, s) => {
3988
4035
  try {
@@ -3994,7 +4041,7 @@ class In {
3994
4041
  });
3995
4042
  }
3996
4043
  async busyIncomingCall() {
3997
- return this.declineToIncomingCall({ statusCode: Rn });
4044
+ return this.declineToIncomingCall({ statusCode: vn });
3998
4045
  }
3999
4046
  on(e, t) {
4000
4047
  return this.events.on(e, t);
@@ -4034,26 +4081,26 @@ class In {
4034
4081
  delete this.incomingRTCSession;
4035
4082
  }
4036
4083
  }
4037
- var Oe = /* @__PURE__ */ ((n) => (n.SNAPSHOT_CHANGED = "snapshot-changed", n))(Oe || {});
4038
- const be = ["snapshot-changed"], fn = () => new A(be), Mn = (n, e) => Object.is(n, e), se = (n) => ({
4084
+ var Pe = /* @__PURE__ */ ((n) => (n.SNAPSHOT_CHANGED = "snapshot-changed", n))(Pe || {});
4085
+ const be = ["snapshot-changed"], On = () => new A(be), Pn = (n, e) => Object.is(n, e), ie = (n) => ({
4039
4086
  connection: n.connection.getSnapshot(),
4040
4087
  call: n.call.getSnapshot(),
4041
4088
  incoming: n.incoming.getSnapshot(),
4042
4089
  presentation: n.presentation.getSnapshot()
4043
4090
  });
4044
- class vn {
4091
+ class bn {
4045
4092
  events;
4046
4093
  actors;
4047
4094
  currentSnapshot;
4048
4095
  subscribers = /* @__PURE__ */ new Set();
4049
4096
  actorSubscriptions = [];
4050
4097
  constructor(e) {
4051
- this.events = fn(), this.actors = {
4098
+ this.events = On(), this.actors = {
4052
4099
  connection: e.connectionManager.connectionActor,
4053
4100
  call: e.callManager.callActor,
4054
4101
  incoming: e.incomingCallManager.incomingActor,
4055
4102
  presentation: e.presentationManager.presentationActor
4056
- }, this.currentSnapshot = se(this.actors), this.actorSubscriptions.push(
4103
+ }, this.currentSnapshot = ie(this.actors), this.actorSubscriptions.push(
4057
4104
  this.actors.connection.subscribe(this.notifySubscribers),
4058
4105
  this.actors.call.subscribe(this.notifySubscribers),
4059
4106
  this.actors.incoming.subscribe(this.notifySubscribers),
@@ -4064,14 +4111,14 @@ class vn {
4064
4111
  return this.currentSnapshot;
4065
4112
  }
4066
4113
  subscribe(e, t, s) {
4067
- const i = typeof t == "function", r = i ? e : (E) => E, a = i ? t : e, o = (i ? s : void 0) ?? Mn, c = r(this.currentSnapshot), d = {
4114
+ const i = typeof t == "function", r = i ? e : (u) => u, a = i ? t : e, o = (i ? s : void 0) ?? Pn, c = r(this.currentSnapshot), h = {
4068
4115
  selector: r,
4069
4116
  listener: a,
4070
4117
  equals: o,
4071
4118
  current: c
4072
4119
  };
4073
- return this.subscribers.add(d), () => {
4074
- this.subscribers.delete(d);
4120
+ return this.subscribers.add(h), () => {
4121
+ this.subscribers.delete(h);
4075
4122
  };
4076
4123
  }
4077
4124
  stop() {
@@ -4087,20 +4134,20 @@ class vn {
4087
4134
  }
4088
4135
  notifySubscribers = () => {
4089
4136
  const e = this.currentSnapshot;
4090
- this.currentSnapshot = se(this.actors);
4137
+ this.currentSnapshot = ie(this.actors);
4091
4138
  for (const t of this.subscribers) {
4092
4139
  const s = t.selector(this.currentSnapshot);
4093
4140
  t.equals(t.current, s) || (t.current = s, t.listener(s));
4094
4141
  }
4095
- this.events.trigger(Oe.SNAPSHOT_CHANGED, {
4142
+ this.events.trigger(Pe.SNAPSHOT_CHANGED, {
4096
4143
  previous: e,
4097
4144
  current: this.currentSnapshot
4098
4145
  });
4099
4146
  };
4100
4147
  }
4101
4148
  const L = 1e3;
4102
- var C = /* @__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))(C || {});
4103
- const Pe = ["collected"], _n = () => new A(Pe), On = "api/v2/rtp2webrtc/offer", bn = async ({
4149
+ var p = /* @__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))(p || {});
4150
+ const De = ["collected"], Dn = () => new A(De), yn = "api/v2/rtp2webrtc/offer", wn = async ({
4104
4151
  serverUrl: n,
4105
4152
  conferenceNumber: e,
4106
4153
  quality: t,
@@ -4109,7 +4156,7 @@ const Pe = ["collected"], _n = () => new A(Pe), On = "api/v2/rtp2webrtc/offer",
4109
4156
  token: r
4110
4157
  }) => {
4111
4158
  const a = new URL(
4112
- `https://${n.replace(/\/$/, "")}/${On}/${encodeURIComponent(e)}`
4159
+ `https://${n.replace(/\/$/, "")}/${yn}/${encodeURIComponent(e)}`
4113
4160
  );
4114
4161
  a.searchParams.set("quality", t), a.searchParams.set("audio", String(s));
4115
4162
  const o = {
@@ -4124,18 +4171,18 @@ const Pe = ["collected"], _n = () => new A(Pe), On = "api/v2/rtp2webrtc/offer",
4124
4171
  });
4125
4172
  if (!c.ok)
4126
4173
  throw new Error(`sendOffer failed with status ${c.status}`);
4127
- const d = await c.json();
4174
+ const h = await c.json();
4128
4175
  return {
4129
- type: d.type,
4130
- sdp: d.sdp,
4176
+ type: h.type,
4177
+ sdp: h.sdp,
4131
4178
  toJSON() {
4132
- return d;
4179
+ return h;
4133
4180
  }
4134
4181
  };
4135
- }, ie = () => "performance" in window ? performance.now() : Date.now(), F = (n) => [...n.keys()].reduce((e, t) => {
4182
+ }, re = () => "performance" in window ? performance.now() : Date.now(), F = (n) => [...n.keys()].reduce((e, t) => {
4136
4183
  const s = n.get(t);
4137
4184
  return s === void 0 ? e : { ...e, [s.type]: s };
4138
- }, {}), Pn = (n) => {
4185
+ }, {}), Ln = (n) => {
4139
4186
  if (!n)
4140
4187
  return {
4141
4188
  outboundRtp: void 0,
@@ -4145,12 +4192,12 @@ const Pe = ["collected"], _n = () => new A(Pe), On = "api/v2/rtp2webrtc/offer",
4145
4192
  };
4146
4193
  const e = F(n);
4147
4194
  return {
4148
- outboundRtp: e[C.OUTBOUND_RTP],
4149
- codec: e[C.CODEC],
4150
- mediaSource: e[C.MEDIA_SOURCE],
4151
- remoteInboundRtp: e[C.REMOTE_INBOUND_RTP]
4195
+ outboundRtp: e[p.OUTBOUND_RTP],
4196
+ codec: e[p.CODEC],
4197
+ mediaSource: e[p.MEDIA_SOURCE],
4198
+ remoteInboundRtp: e[p.REMOTE_INBOUND_RTP]
4152
4199
  };
4153
- }, re = (n) => {
4200
+ }, ae = (n) => {
4154
4201
  if (!n)
4155
4202
  return {
4156
4203
  outboundRtp: void 0,
@@ -4160,12 +4207,12 @@ const Pe = ["collected"], _n = () => new A(Pe), On = "api/v2/rtp2webrtc/offer",
4160
4207
  };
4161
4208
  const e = F(n);
4162
4209
  return {
4163
- outboundRtp: e[C.OUTBOUND_RTP],
4164
- codec: e[C.CODEC],
4165
- mediaSource: e[C.MEDIA_SOURCE],
4166
- remoteInboundRtp: e[C.REMOTE_INBOUND_RTP]
4210
+ outboundRtp: e[p.OUTBOUND_RTP],
4211
+ codec: e[p.CODEC],
4212
+ mediaSource: e[p.MEDIA_SOURCE],
4213
+ remoteInboundRtp: e[p.REMOTE_INBOUND_RTP]
4167
4214
  };
4168
- }, ae = ({
4215
+ }, oe = ({
4169
4216
  videoReceiversStats: n,
4170
4217
  synchronizationSourcesVideo: e
4171
4218
  }) => {
@@ -4177,11 +4224,11 @@ const Pe = ["collected"], _n = () => new A(Pe), On = "api/v2/rtp2webrtc/offer",
4177
4224
  };
4178
4225
  const t = F(n);
4179
4226
  return {
4180
- inboundRtp: t[C.INBOUND_RTP],
4181
- codec: t[C.CODEC],
4227
+ inboundRtp: t[p.INBOUND_RTP],
4228
+ codec: t[p.CODEC],
4182
4229
  synchronizationSources: e
4183
4230
  };
4184
- }, Dn = ({
4231
+ }, Un = ({
4185
4232
  audioReceiverStats: n,
4186
4233
  synchronizationSourcesAudio: e
4187
4234
  }) => {
@@ -4194,12 +4241,12 @@ const Pe = ["collected"], _n = () => new A(Pe), On = "api/v2/rtp2webrtc/offer",
4194
4241
  };
4195
4242
  const t = F(n);
4196
4243
  return {
4197
- inboundRtp: t[C.INBOUND_RTP],
4198
- codec: t[C.CODEC],
4199
- remoteOutboundRtp: t[C.REMOTE_OUTBOUND_RTP],
4244
+ inboundRtp: t[p.INBOUND_RTP],
4245
+ codec: t[p.CODEC],
4246
+ remoteOutboundRtp: t[p.REMOTE_OUTBOUND_RTP],
4200
4247
  synchronizationSources: e
4201
4248
  };
4202
- }, De = (n) => {
4249
+ }, ye = (n) => {
4203
4250
  if (!n)
4204
4251
  return {
4205
4252
  candidatePair: void 0,
@@ -4210,45 +4257,45 @@ const Pe = ["collected"], _n = () => new A(Pe), On = "api/v2/rtp2webrtc/offer",
4210
4257
  };
4211
4258
  const e = F(n);
4212
4259
  return {
4213
- candidatePair: e[C.CANDIDATE_PAIR],
4214
- certificate: e[C.CERTIFICATE],
4215
- localCandidate: e[C.LOCAL_CANDIDATE],
4216
- remoteCandidate: e[C.REMOTE_CANDIDATE],
4217
- transport: e[C.TRANSPORT]
4260
+ candidatePair: e[p.CANDIDATE_PAIR],
4261
+ certificate: e[p.CERTIFICATE],
4262
+ localCandidate: e[p.LOCAL_CANDIDATE],
4263
+ remoteCandidate: e[p.REMOTE_CANDIDATE],
4264
+ transport: e[p.TRANSPORT]
4218
4265
  };
4219
- }, yn = ({
4266
+ }, Fn = ({
4220
4267
  audioSenderStats: n,
4221
4268
  videoSenderFirstStats: e,
4222
4269
  videoSenderSecondStats: t
4223
4270
  }) => ({
4224
- video: re(e),
4225
- secondVideo: re(t),
4226
- audio: Pn(n),
4227
- additional: De(
4271
+ video: ae(e),
4272
+ secondVideo: ae(t),
4273
+ audio: Ln(n),
4274
+ additional: ye(
4228
4275
  n ?? e ?? t
4229
4276
  )
4230
- }), wn = ({
4277
+ }), kn = ({
4231
4278
  audioReceiverStats: n,
4232
4279
  videoReceiverFirstStats: e,
4233
4280
  videoReceiverSecondStats: t,
4234
4281
  synchronizationSources: s
4235
4282
  }) => ({
4236
- video: ae({
4283
+ video: oe({
4237
4284
  videoReceiversStats: e,
4238
4285
  synchronizationSourcesVideo: s.video
4239
4286
  }),
4240
- secondVideo: ae({
4287
+ secondVideo: oe({
4241
4288
  videoReceiversStats: t,
4242
4289
  synchronizationSourcesVideo: s.video
4243
4290
  }),
4244
- audio: Dn({
4291
+ audio: Un({
4245
4292
  audioReceiverStats: n,
4246
4293
  synchronizationSourcesAudio: s.audio
4247
4294
  }),
4248
- additional: De(
4295
+ additional: ye(
4249
4296
  n ?? e ?? t
4250
4297
  )
4251
- }), Ln = ({
4298
+ }), Bn = ({
4252
4299
  audioSenderStats: n,
4253
4300
  videoSenderFirstStats: e,
4254
4301
  videoSenderSecondStats: t,
@@ -4257,11 +4304,11 @@ const Pe = ["collected"], _n = () => new A(Pe), On = "api/v2/rtp2webrtc/offer",
4257
4304
  videoReceiverSecondStats: r,
4258
4305
  synchronizationSources: a
4259
4306
  }) => {
4260
- const o = yn({
4307
+ const o = Fn({
4261
4308
  audioSenderStats: n,
4262
4309
  videoSenderFirstStats: e,
4263
4310
  videoSenderSecondStats: t
4264
- }), c = wn({
4311
+ }), c = kn({
4265
4312
  audioReceiverStats: s,
4266
4313
  videoReceiverFirstStats: i,
4267
4314
  videoReceiverSecondStats: r,
@@ -4271,16 +4318,16 @@ const Pe = ["collected"], _n = () => new A(Pe), On = "api/v2/rtp2webrtc/offer",
4271
4318
  outbound: o,
4272
4319
  inbound: c
4273
4320
  };
4274
- }, Un = async (n) => {
4275
- const e = "audio", t = "video", s = n.getSenders(), i = s.find((T) => T.track?.kind === e), r = s.filter((T) => T.track?.kind === t), a = n.getReceivers(), o = a.find((T) => T.track.kind === e), c = a.filter((T) => T.track.kind === t), d = {
4321
+ }, Gn = async (n) => {
4322
+ const e = "audio", t = "video", s = n.getSenders(), i = s.find((S) => S.track?.kind === e), r = s.filter((S) => S.track?.kind === t), a = n.getReceivers(), o = a.find((S) => S.track.kind === e), c = a.filter((S) => S.track.kind === t), h = {
4276
4323
  trackIdentifier: o?.track.id,
4277
4324
  item: o?.getSynchronizationSources()[0]
4278
- }, E = {
4325
+ }, u = {
4279
4326
  trackIdentifier: c[0]?.track.id,
4280
4327
  item: c[0]?.getSynchronizationSources()[0]
4281
- }, u = {
4282
- audio: d,
4283
- video: E
4328
+ }, l = {
4329
+ audio: h,
4330
+ video: u
4284
4331
  };
4285
4332
  return Promise.all([
4286
4333
  i?.getStats() ?? Promise.resolve(void 0),
@@ -4289,41 +4336,41 @@ const Pe = ["collected"], _n = () => new A(Pe), On = "api/v2/rtp2webrtc/offer",
4289
4336
  o?.getStats() ?? Promise.resolve(void 0),
4290
4337
  c[0]?.getStats() ?? Promise.resolve(void 0),
4291
4338
  c[1]?.getStats() ?? Promise.resolve(void 0)
4292
- ]).then((T) => {
4339
+ ]).then((S) => {
4293
4340
  const [
4294
4341
  m,
4295
4342
  O,
4296
4343
  N,
4297
4344
  y,
4298
4345
  H,
4299
- Be
4300
- ] = T;
4346
+ Ge
4347
+ ] = S;
4301
4348
  return {
4302
- synchronizationSources: u,
4349
+ synchronizationSources: l,
4303
4350
  audioSenderStats: m,
4304
4351
  videoSenderFirstStats: O,
4305
4352
  videoSenderSecondStats: N,
4306
4353
  audioReceiverStats: y,
4307
4354
  videoReceiverFirstStats: H,
4308
- videoReceiverSecondStats: Be
4355
+ videoReceiverSecondStats: Ge
4309
4356
  };
4310
4357
  });
4311
- }, Fn = (n) => {
4312
- h(String(n));
4358
+ }, $n = (n) => {
4359
+ d(String(n));
4313
4360
  };
4314
- class kn {
4361
+ class qn {
4315
4362
  events;
4316
4363
  setTimeoutRequest;
4317
- requesterAllStatistics = new $(Un);
4364
+ requesterAllStatistics = new G(Gn);
4318
4365
  constructor() {
4319
- this.events = _n(), this.setTimeoutRequest = new ce();
4366
+ this.events = Dn(), this.setTimeoutRequest = new de();
4320
4367
  }
4321
4368
  get requested() {
4322
4369
  return this.setTimeoutRequest.requested;
4323
4370
  }
4324
4371
  start(e, {
4325
4372
  interval: t = L,
4326
- onError: s = Fn
4373
+ onError: s = $n
4327
4374
  } = {}) {
4328
4375
  this.stop(), this.setTimeoutRequest.request(() => {
4329
4376
  this.collectStatistics(e, {
@@ -4352,10 +4399,10 @@ class kn {
4352
4399
  collectStatistics = (e, {
4353
4400
  onError: t
4354
4401
  }) => {
4355
- const s = ie();
4402
+ const s = re();
4356
4403
  this.requesterAllStatistics.request(e).then((i) => {
4357
- this.events.trigger("collected", Ln(i));
4358
- const a = ie() - s;
4404
+ this.events.trigger("collected", Bn(i));
4405
+ const a = re() - s;
4359
4406
  let o = L;
4360
4407
  a > 48 ? o = L * 4 : a > 32 ? o = L * 3 : a > 16 && (o = L * 2), this.start(e, {
4361
4408
  onError: t,
@@ -4366,8 +4413,8 @@ class kn {
4366
4413
  });
4367
4414
  };
4368
4415
  }
4369
- const Bn = 500;
4370
- class $n {
4416
+ const Hn = 500;
4417
+ class Vn {
4371
4418
  statsPeerConnection;
4372
4419
  availableStats;
4373
4420
  previousAvailableStats;
@@ -4377,7 +4424,7 @@ class $n {
4377
4424
  callManager: e,
4378
4425
  apiManager: t
4379
4426
  }) {
4380
- this.callManager = e, this.apiManager = t, this.statsPeerConnection = new kn(), this.subscribe();
4427
+ this.callManager = e, this.apiManager = t, this.statsPeerConnection = new qn(), this.subscribe();
4381
4428
  }
4382
4429
  get events() {
4383
4430
  return this.statsPeerConnection.events;
@@ -4427,7 +4474,7 @@ class $n {
4427
4474
  return this.previousInboundRtp?.packetsReceived;
4428
4475
  }
4429
4476
  get isReceivingPackets() {
4430
- const e = this.packetsReceived !== void 0 && this.packetsReceived >= Bn, t = this.packetsReceived !== this.previousPacketsReceived;
4477
+ const e = this.packetsReceived !== void 0 && this.packetsReceived >= Hn, t = this.packetsReceived !== this.previousPacketsReceived;
4431
4478
  return e && t;
4432
4479
  }
4433
4480
  on(e, t) {
@@ -4463,37 +4510,37 @@ class $n {
4463
4510
  };
4464
4511
  maybeSendStats() {
4465
4512
  this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
4466
- h("Failed to send stats", e);
4513
+ d("Failed to send stats", e);
4467
4514
  });
4468
4515
  }
4469
4516
  }
4470
- const Gn = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), qn = (n) => {
4517
+ const Wn = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), xn = (n) => {
4471
4518
  const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
4472
- return Gn(s, i);
4473
- }, Hn = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
4519
+ return Wn(s, i);
4520
+ }, Qn = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
4474
4521
  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;
4475
4522
  return a - o;
4476
- }), Vn = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Wn = (n, {
4523
+ }), Yn = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Xn = (n, {
4477
4524
  preferredMimeTypesVideoCodecs: e,
4478
4525
  excludeMimeTypesVideoCodecs: t
4479
4526
  }) => {
4480
4527
  try {
4481
4528
  if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
4482
- const s = qn("video"), i = Vn(s, t), r = Hn(i, e);
4529
+ const s = xn("video"), i = Yn(s, t), r = Qn(i, e);
4483
4530
  n.setCodecPreferences(r);
4484
4531
  }
4485
4532
  } catch (s) {
4486
- h("setCodecPreferences error", s);
4533
+ d("setCodecPreferences error", s);
4487
4534
  }
4488
- }, xn = (n) => [...n.keys()].map((e) => n.get(e)), Qn = (n, e) => xn(n).find((t) => t?.type === e), Yn = async (n) => n.getStats().then((e) => Qn(e, "codec")?.mimeType);
4489
- class Xn {
4535
+ }, Jn = (n) => [...n.keys()].map((e) => n.get(e)), zn = (n, e) => Jn(n).find((t) => t?.type === e), Kn = async (n) => n.getStats().then((e) => zn(e, "codec")?.mimeType);
4536
+ class jn {
4490
4537
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
4491
4538
  async getCodecFromSender(e) {
4492
- return await Yn(e) ?? "";
4539
+ return await Kn(e) ?? "";
4493
4540
  }
4494
4541
  }
4495
- class Jn {
4496
- stackPromises = de({
4542
+ class Zn {
4543
+ stackPromises = le({
4497
4544
  noRunIsNotActual: !0
4498
4545
  });
4499
4546
  /**
@@ -4513,34 +4560,34 @@ class Jn {
4513
4560
  */
4514
4561
  async run() {
4515
4562
  return this.stackPromises().catch((e) => {
4516
- h("TaskQueue: error", e);
4563
+ d("TaskQueue: error", e);
4517
4564
  });
4518
4565
  }
4519
4566
  }
4520
- class zn {
4567
+ class es {
4521
4568
  taskQueue;
4522
4569
  onSetParameters;
4523
4570
  constructor(e) {
4524
- this.onSetParameters = e, this.taskQueue = new Jn();
4571
+ this.onSetParameters = e, this.taskQueue = new Zn();
4525
4572
  }
4526
4573
  async setEncodingsToSender(e, t) {
4527
- return this.taskQueue.add(async () => Ce(e, t, this.onSetParameters));
4574
+ return this.taskQueue.add(async () => me(e, t, this.onSetParameters));
4528
4575
  }
4529
4576
  stop() {
4530
4577
  this.taskQueue.stop();
4531
4578
  }
4532
4579
  }
4533
- const ye = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Kn = 1e6, M = (n) => n * Kn, we = M(0.06), Le = M(4), jn = (n) => n <= 64 ? we : n <= 128 ? M(0.12) : n <= 256 ? M(0.25) : n <= 384 ? M(0.32) : n <= 426 ? M(0.38) : n <= 640 ? M(0.5) : n <= 848 ? M(0.7) : n <= 1280 ? M(1) : n <= 1920 ? M(2) : Le, Zn = "av1", es = (n) => ye(n, Zn), ts = 0.6, j = (n, e) => es(e) ? n * ts : n, ns = (n) => j(we, n), ss = (n) => j(Le, n), oe = (n, e) => {
4534
- const t = jn(n);
4580
+ const we = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), ts = 1e6, v = (n) => n * ts, Le = v(0.06), Ue = v(4), ns = (n) => n <= 64 ? Le : 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) : Ue, ss = "av1", is = (n) => we(n, ss), rs = 0.6, j = (n, e) => is(e) ? n * rs : n, as = (n) => j(Le, n), os = (n) => j(Ue, n), ce = (n, e) => {
4581
+ const t = ns(n);
4535
4582
  return j(t, e);
4536
- }, W = 1, is = ({
4583
+ }, W = 1, cs = ({
4537
4584
  videoTrack: n,
4538
4585
  targetSize: e
4539
4586
  }) => {
4540
4587
  const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? W : s / e.width, a = i === void 0 ? W : i / e.height;
4541
4588
  return Math.max(r, a, W);
4542
4589
  };
4543
- class rs {
4590
+ class ds {
4544
4591
  ignoreForCodec;
4545
4592
  senderFinder;
4546
4593
  codecProvider;
@@ -4573,7 +4620,7 @@ class rs {
4573
4620
  if (!i?.track)
4574
4621
  return { ...this.resultNoChanged, sender: i };
4575
4622
  const r = await this.codecProvider.getCodecFromSender(i);
4576
- if (ye(r, this.ignoreForCodec))
4623
+ if (we(r, this.ignoreForCodec))
4577
4624
  return { ...this.resultNoChanged, sender: i };
4578
4625
  const { mainCam: a, resolutionMainCam: o } = t ?? {};
4579
4626
  return this.processSender(
@@ -4593,14 +4640,14 @@ class rs {
4593
4640
  async processSender(e, t) {
4594
4641
  const { mainCam: s, resolutionMainCam: i } = e;
4595
4642
  switch (s) {
4596
- case v.PAUSE_MAIN_CAM:
4643
+ case M.PAUSE_MAIN_CAM:
4597
4644
  return this.downgradeResolutionSender(t);
4598
- case v.RESUME_MAIN_CAM:
4645
+ case M.RESUME_MAIN_CAM:
4599
4646
  return this.setBitrateByTrackResolution(t);
4600
- case v.MAX_MAIN_CAM_RESOLUTION:
4647
+ case M.MAX_MAIN_CAM_RESOLUTION:
4601
4648
  return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
4602
- case v.ADMIN_STOP_MAIN_CAM:
4603
- case v.ADMIN_START_MAIN_CAM:
4649
+ case M.ADMIN_STOP_MAIN_CAM:
4650
+ case M.ADMIN_START_MAIN_CAM:
4604
4651
  case void 0:
4605
4652
  return this.setBitrateByTrackResolution(t);
4606
4653
  default:
@@ -4615,7 +4662,7 @@ class rs {
4615
4662
  async downgradeResolutionSender(e) {
4616
4663
  const { sender: t, codec: s } = e, i = {
4617
4664
  scaleResolutionDownBy: 200,
4618
- maxBitrate: ns(s)
4665
+ maxBitrate: as(s)
4619
4666
  };
4620
4667
  return this.parametersSetter.setEncodingsToSender(t, i);
4621
4668
  }
@@ -4625,7 +4672,7 @@ class rs {
4625
4672
  * @returns Promise с результатом
4626
4673
  */
4627
4674
  async setBitrateByTrackResolution(e) {
4628
- const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? ss(i) : oe(a, i);
4675
+ const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? os(i) : ce(a, i);
4629
4676
  return this.parametersSetter.setEncodingsToSender(t, {
4630
4677
  scaleResolutionDownBy: 1,
4631
4678
  maxBitrate: o
@@ -4641,24 +4688,24 @@ class rs {
4641
4688
  const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
4642
4689
  width: Number(s),
4643
4690
  height: Number(i)
4644
- }, d = is({
4691
+ }, h = cs({
4645
4692
  videoTrack: a,
4646
4693
  targetSize: c
4647
- }), E = oe(c.width, o), u = {
4648
- scaleResolutionDownBy: d,
4649
- maxBitrate: E
4694
+ }), u = ce(c.width, o), l = {
4695
+ scaleResolutionDownBy: h,
4696
+ maxBitrate: u
4650
4697
  };
4651
- return this.parametersSetter.setEncodingsToSender(r, u);
4698
+ return this.parametersSetter.setEncodingsToSender(r, l);
4652
4699
  }
4653
4700
  }
4654
- const as = (n) => n.find((e) => e.track?.kind === "video");
4655
- class os {
4701
+ const hs = (n) => n.find((e) => e.track?.kind === "video");
4702
+ class ls {
4656
4703
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
4657
4704
  findVideoSender(e) {
4658
- return as(e);
4705
+ return hs(e);
4659
4706
  }
4660
4707
  }
4661
- class cs {
4708
+ class gs {
4662
4709
  currentSender;
4663
4710
  originalReplaceTrack;
4664
4711
  lastWidth;
@@ -4671,7 +4718,7 @@ class cs {
4671
4718
  pollIntervalMs: e = 1e3,
4672
4719
  maxPollIntervalMs: t
4673
4720
  }) {
4674
- this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ce();
4721
+ this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new de();
4675
4722
  }
4676
4723
  /**
4677
4724
  * Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
@@ -4722,7 +4769,7 @@ class cs {
4722
4769
  this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
4723
4770
  }
4724
4771
  }
4725
- class hs {
4772
+ class us {
4726
4773
  apiManager;
4727
4774
  currentHandler;
4728
4775
  constructor(e) {
@@ -4742,7 +4789,7 @@ class hs {
4742
4789
  this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
4743
4790
  }
4744
4791
  }
4745
- class ds {
4792
+ class Ts {
4746
4793
  eventHandler;
4747
4794
  senderBalancer;
4748
4795
  parametersSetterWithQueue;
@@ -4754,16 +4801,16 @@ class ds {
4754
4801
  onSetParameters: i,
4755
4802
  pollIntervalMs: r
4756
4803
  } = {}) {
4757
- this.getConnection = t, this.eventHandler = new hs(e), this.parametersSetterWithQueue = new zn(i), this.senderBalancer = new rs(
4804
+ this.getConnection = t, this.eventHandler = new us(e), this.parametersSetterWithQueue = new es(i), this.senderBalancer = new ds(
4758
4805
  {
4759
- senderFinder: new os(),
4760
- codecProvider: new Xn(),
4806
+ senderFinder: new ls(),
4807
+ codecProvider: new jn(),
4761
4808
  parametersSetter: this.parametersSetterWithQueue
4762
4809
  },
4763
4810
  {
4764
4811
  ignoreForCodec: s
4765
4812
  }
4766
- ), this.trackMonitor = new cs({ pollIntervalMs: r });
4813
+ ), this.trackMonitor = new gs({ pollIntervalMs: r });
4767
4814
  }
4768
4815
  /**
4769
4816
  * Подписывается на события управления главной камерой
@@ -4794,7 +4841,7 @@ class ds {
4794
4841
  const t = await this.senderBalancer.balance(e, this.serverHeaders);
4795
4842
  return this.trackMonitor.subscribe(t.sender, () => {
4796
4843
  this.balance().catch((s) => {
4797
- h("balance on track change: error", s);
4844
+ d("balance on track change: error", s);
4798
4845
  });
4799
4846
  }), t;
4800
4847
  }
@@ -4804,17 +4851,17 @@ class ds {
4804
4851
  */
4805
4852
  handleMainCamControl = (e) => {
4806
4853
  this.serverHeaders = e, this.balance().catch((t) => {
4807
- h("handleMainCamControl: error", t);
4854
+ d("handleMainCamControl: error", t);
4808
4855
  });
4809
4856
  };
4810
4857
  }
4811
- const Ue = [
4858
+ const Fe = [
4812
4859
  "balancing-scheduled",
4813
4860
  "balancing-started",
4814
4861
  "balancing-stopped",
4815
4862
  "parameters-updated"
4816
- ], ls = () => new A(Ue);
4817
- class gs {
4863
+ ], Ss = () => new A(Fe);
4864
+ class Es {
4818
4865
  isBalancingActive = !1;
4819
4866
  events;
4820
4867
  callManager;
@@ -4822,7 +4869,7 @@ class gs {
4822
4869
  videoSendingBalancer;
4823
4870
  startBalancingTimer;
4824
4871
  constructor(e, t, s = {}) {
4825
- this.events = ls(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new ds(
4872
+ this.events = Ss(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new Ts(
4826
4873
  t,
4827
4874
  () => e.connection,
4828
4875
  {
@@ -4884,7 +4931,7 @@ class gs {
4884
4931
  scheduleBalancingStart() {
4885
4932
  this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
4886
4933
  this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
4887
- h("startBalancing: error", e);
4934
+ d("startBalancing: error", e);
4888
4935
  });
4889
4936
  }, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
4890
4937
  }
@@ -4892,16 +4939,16 @@ class gs {
4892
4939
  this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
4893
4940
  }
4894
4941
  }
4895
- const Fe = "no-inbound-frames", ke = [Fe], us = () => new A(ke);
4896
- class Ts {
4942
+ const ke = "no-inbound-frames", Be = [ke], Cs = () => new A(Be);
4943
+ class ps {
4897
4944
  events;
4898
4945
  statsManager;
4899
4946
  callManager;
4900
4947
  constructor(e, t) {
4901
- this.statsManager = e, this.callManager = t, this.events = us(), this.subscribe();
4948
+ this.statsManager = e, this.callManager = t, this.events = Cs(), this.subscribe();
4902
4949
  }
4903
4950
  get mainVideoTrack() {
4904
- return this.callManager.getMainStream()?.getVideoTracks()[0];
4951
+ return this.callManager.getMainRemoteStream()?.getVideoTracks()[0];
4905
4952
  }
4906
4953
  get isMutedMainVideoTrack() {
4907
4954
  const { mainVideoTrack: e } = this;
@@ -4911,36 +4958,36 @@ class Ts {
4911
4958
  return this.events.on(e, t);
4912
4959
  }
4913
4960
  handleStatsCollected = () => {
4914
- this.hasNoIncomingFrames() && this.events.trigger(Fe, {});
4961
+ this.hasNoIncomingFrames() && this.events.trigger(ke, {});
4915
4962
  };
4916
4963
  hasNoIncomingFrames = () => this.statsManager.isInvalidInboundFrames && this.isMutedMainVideoTrack;
4917
4964
  subscribe() {
4918
4965
  this.statsManager.on("collected", this.handleStatsCollected);
4919
4966
  }
4920
4967
  }
4921
- const Es = 3e3;
4922
- class Ss {
4968
+ const ms = 3e3;
4969
+ class Ns {
4923
4970
  renegotiateRequester;
4924
4971
  renegotiateThrottled;
4925
4972
  callManager;
4926
- constructor(e, t = Es) {
4927
- this.callManager = e, this.renegotiateRequester = new $(e.renegotiate.bind(e)), this.renegotiateThrottled = Ye.throttle(
4973
+ constructor(e, t = ms) {
4974
+ this.callManager = e, this.renegotiateRequester = new G(e.renegotiate.bind(e)), this.renegotiateThrottled = Xe.throttle(
4928
4975
  this.requestRenegotiate.bind(this),
4929
4976
  t
4930
4977
  ), this.subscribe();
4931
4978
  }
4932
4979
  recover() {
4933
- h("trying to recover main stream"), this.renegotiateThrottled();
4980
+ d("trying to recover main stream"), this.renegotiateThrottled();
4934
4981
  }
4935
4982
  requestRenegotiate = () => {
4936
- if (h("trying to renegotiate"), this.renegotiateRequester.requested) {
4937
- h("previous renegotiate is not finished yet");
4983
+ if (d("trying to renegotiate"), this.renegotiateRequester.requested) {
4984
+ d("previous renegotiate is not finished yet");
4938
4985
  return;
4939
4986
  }
4940
4987
  this.renegotiateRequester.request().then(() => {
4941
- h("renegotiate has successful");
4988
+ d("renegotiate has successful");
4942
4989
  }).catch((e) => {
4943
- h("failed to renegotiate main media stream", e);
4990
+ d("failed to renegotiate main media stream", e);
4944
4991
  });
4945
4992
  };
4946
4993
  subscribe() {
@@ -4949,28 +4996,28 @@ class Ss {
4949
4996
  });
4950
4997
  }
4951
4998
  cancel() {
4952
- h("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
4999
+ d("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
4953
5000
  }
4954
5001
  }
4955
- const ps = 1e6, Cs = Me.map((n) => `auto-connect:${n}`), ms = Re.map((n) => `connection:${n}`), Ns = ue.map((n) => `call:${n}`), Rs = ve.map((n) => `conference-state:${n}`), As = le.map((n) => `api:${n}`), Is = _e.map((n) => `incoming-call:${n}`), fs = me.map((n) => `presentation:${n}`), Ms = Pe.map((n) => `stats:${n}`), vs = Ue.map((n) => `video-balancer:${n}`), _s = ke.map((n) => `main-stream-health:${n}`), Os = be.map((n) => `session:${n}`), bs = [
5002
+ const Rs = 1e6, As = Me.map((n) => `auto-connect:${n}`), Is = Ae.map((n) => `connection:${n}`), fs = Te.map((n) => `call:${n}`), vs = _e.map((n) => `conference-state:${n}`), Ms = ge.map((n) => `api:${n}`), _s = Oe.map((n) => `incoming-call:${n}`), Os = Ne.map((n) => `presentation:${n}`), Ps = De.map((n) => `stats:${n}`), bs = Fe.map((n) => `video-balancer:${n}`), Ds = Be.map((n) => `main-stream-health:${n}`), ys = be.map((n) => `session:${n}`), ws = [
4956
5003
  "disconnected-from-out-of-call",
4957
5004
  "connected-with-configuration-from-out-of-call",
4958
5005
  "stopped-presentation-by-server-command"
4959
- ], Ps = [
4960
- ...Cs,
4961
- ...ms,
4962
- ...Ns,
4963
- ...Rs,
5006
+ ], Ls = [
4964
5007
  ...As,
4965
5008
  ...Is,
4966
5009
  ...fs,
4967
- ...Ms,
4968
5010
  ...vs,
5011
+ ...Ms,
4969
5012
  ..._s,
4970
5013
  ...Os,
4971
- ...bs
4972
- ], Ds = () => new A(Ps);
4973
- class xs {
5014
+ ...Ps,
5015
+ ...bs,
5016
+ ...Ds,
5017
+ ...ys,
5018
+ ...ws
5019
+ ], Us = () => new A(Ls);
5020
+ class Js {
4974
5021
  events;
4975
5022
  connectionManager;
4976
5023
  connectionQueueManager;
@@ -4993,29 +5040,29 @@ class xs {
4993
5040
  videoBalancerOptions: i,
4994
5041
  autoConnectorOptions: r
4995
5042
  } = {}) {
4996
- this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = Ds(), this.connectionManager = new jt({ JsSIP: e }), this.connectionQueueManager = new Zt({
5043
+ this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = Us(), this.connectionManager = new nn({ JsSIP: e }), this.connectionQueueManager = new sn({
4997
5044
  connectionManager: this.connectionManager
4998
- }), this.conferenceStateManager = new Sn(), this.callManager = new Tt(this.conferenceStateManager), this.apiManager = new et({
5045
+ }), this.conferenceStateManager = new Nn(), this.callManager = new pt(this.conferenceStateManager), this.apiManager = new tt({
4999
5046
  connectionManager: this.connectionManager,
5000
5047
  callManager: this.callManager
5001
- }), this.incomingCallManager = new In(this.connectionManager), this.presentationManager = new wt({
5048
+ }), this.incomingCallManager = new _n(this.connectionManager), this.presentationManager = new kt({
5002
5049
  callManager: this.callManager,
5003
- maxBitrate: ps
5004
- }), this.statsManager = new $n({
5050
+ maxBitrate: Rs
5051
+ }), this.statsManager = new Vn({
5005
5052
  callManager: this.callManager,
5006
5053
  apiManager: this.apiManager
5007
- }), this.autoConnectorManager = new Tn(
5054
+ }), this.autoConnectorManager = new pn(
5008
5055
  {
5009
5056
  connectionQueueManager: this.connectionQueueManager,
5010
5057
  connectionManager: this.connectionManager,
5011
5058
  callManager: this.callManager
5012
5059
  },
5013
5060
  r
5014
- ), this.videoSendingBalancerManager = new gs(
5061
+ ), this.videoSendingBalancerManager = new Es(
5015
5062
  this.callManager,
5016
5063
  this.apiManager,
5017
5064
  i
5018
- ), this.mainStreamHealthMonitor = new Ts(this.statsManager, this.callManager), this.mainStreamRecovery = new Ss(this.callManager), this.sessionManager = new vn({
5065
+ ), this.mainStreamHealthMonitor = new ps(this.statsManager, this.callManager), this.mainStreamRecovery = new Ns(this.callManager), this.sessionManager = new bn({
5019
5066
  connectionManager: this.connectionManager,
5020
5067
  callManager: this.callManager,
5021
5068
  incomingCallManager: this.incomingCallManager,
@@ -5234,7 +5281,7 @@ class xs {
5234
5281
  if (i === void 0)
5235
5282
  throw new Error("No sipServerUrl for sendOffer");
5236
5283
  const r = this.conferenceStateManager.getToken();
5237
- return bn({
5284
+ return wn({
5238
5285
  serverUrl: i,
5239
5286
  offer: t,
5240
5287
  token: r,
@@ -5244,7 +5291,7 @@ class xs {
5244
5291
  });
5245
5292
  };
5246
5293
  setCodecPreferences(e) {
5247
- Wn(e, {
5294
+ Xn(e, {
5248
5295
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
5249
5296
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
5250
5297
  });
@@ -5269,24 +5316,24 @@ class xs {
5269
5316
  };
5270
5317
  }
5271
5318
  export {
5272
- Te as E,
5273
- it as O,
5274
- xs as S,
5275
- Ht as a,
5276
- tt as b,
5277
- Cn as c,
5278
- Ce as d,
5279
- Mt as e,
5280
- je as f,
5281
- Vs as g,
5282
- Jt as h,
5283
- Hs as i,
5284
- Ws as j,
5285
- C as k,
5286
- h as l,
5287
- kn as m,
5288
- Yn as n,
5289
- bt as o,
5319
+ Se as E,
5320
+ rt as O,
5321
+ Js as S,
5322
+ Qt as a,
5323
+ nt as b,
5324
+ An as c,
5325
+ me as d,
5326
+ Pt as e,
5327
+ Ze as f,
5328
+ Ys as g,
5329
+ Zt as h,
5330
+ Qs as i,
5331
+ Xs as j,
5332
+ p as k,
5333
+ d as l,
5334
+ qn as m,
5335
+ Kn as n,
5336
+ wt as o,
5290
5337
  B as p,
5291
- bn as s
5338
+ wn as s
5292
5339
  };