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