sip-connector 18.0.0 → 19.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +123 -29
  2. package/dist/{@SipConnector-UTHCoMXw.js → @SipConnector-DC8z6npa.js} +835 -473
  3. package/dist/@SipConnector-eNxG0NqG.cjs +1 -0
  4. package/dist/AutoConnectorManager/@AutoConnectorManager.d.ts +41 -0
  5. package/dist/AutoConnectorManager/AttemptsState.d.ts +21 -0
  6. package/dist/AutoConnectorManager/CheckTelephonyRequester.d.ts +19 -0
  7. package/dist/AutoConnectorManager/PingServerIfNotActiveCallRequester.d.ts +18 -0
  8. package/dist/AutoConnectorManager/PingServerRequester.d.ts +13 -0
  9. package/dist/AutoConnectorManager/RegistrationFailedOutOfCallSubscriber.d.ts +18 -0
  10. package/dist/AutoConnectorManager/eventNames.d.ts +18 -0
  11. package/dist/AutoConnectorManager/index.d.ts +3 -0
  12. package/dist/AutoConnectorManager/types.d.ts +22 -0
  13. package/dist/AutoConnectorManager/utils/errors.d.ts +2 -0
  14. package/dist/AutoConnectorManager/utils/index.d.ts +1 -0
  15. package/dist/CallManager/@CallManager.d.ts +3 -0
  16. package/dist/CallManager/eventNames.d.ts +6 -2
  17. package/dist/ConnectionManager/@ConnectionManager.d.ts +11 -1
  18. package/dist/ConnectionManager/eventNames.d.ts +6 -2
  19. package/dist/ConnectionManager/index.d.ts +1 -0
  20. package/dist/ConnectionManager/utils/errors.d.ts +2 -0
  21. package/dist/ConnectionManager/utils/index.d.ts +2 -0
  22. package/dist/ConnectionManager/utils/resolveParameters.d.ts +2 -0
  23. package/dist/ConnectionQueueManager/@ConnectionQueueManager.d.ts +1 -7
  24. package/dist/ConnectionQueueManager/index.d.ts +1 -0
  25. package/dist/SipConnector/@SipConnector.d.ts +8 -4
  26. package/dist/SipConnector/eventNames.d.ts +1 -1
  27. package/dist/SipConnectorFacade/@SipConnectorFacade.d.ts +16 -10
  28. package/dist/doMock.cjs +1 -1
  29. package/dist/doMock.js +1 -1
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.js +227 -213
  33. package/package.json +10 -10
  34. package/dist/@SipConnector-CFYT0HQB.cjs +0 -1
@@ -1,19 +1,19 @@
1
- import { Events as w, TypedEvents as H } from "events-constructor";
1
+ import { Events as U, TypedEvents as k } from "events-constructor";
2
2
  import x from "debug";
3
- import { hasCanceledError as Ne, repeatedCallsAsync as J } from "repeated-calls";
4
- import { setup as Ae, createActor as Re } from "xstate";
5
- import { createStackPromises as K } from "stack-promises";
6
- import { CancelableRequest as Ie } from "@krivega/cancelable-promise";
7
- import { SetTimeoutRequest as j } from "@krivega/timeout-requester";
3
+ import { CancelableRequest as G, isCanceledError as _e } from "@krivega/cancelable-promise";
4
+ import { resolveRequesterByTimeout as Me, requesterByTimeoutsWithFailCalls as ve, DelayRequester as fe, hasCanceledError as Pe, SetTimeoutRequest as Z } from "@krivega/timeout-requester";
5
+ import { hasCanceledError as Oe, repeatedCallsAsync as ee } from "repeated-calls";
6
+ import { setup as De, createActor as ye } from "xstate";
7
+ import { createStackPromises as te, isPromiseIsNotActualError as be } from "stack-promises";
8
8
  import "ua-parser-js";
9
9
  import "sequent-promises";
10
- const q = "sip-connector", E = x(q), Tn = () => {
11
- x.enable(q);
12
- }, Sn = () => {
13
- x.enable(`-${q}`);
14
- }, _e = "Error decline with 603", me = 1006, Me = (n) => typeof n == "object" && n !== null && "code" in n && n.code === me, pe = (n) => n.message === _e;
15
- var h = /* @__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))(h || {}), L = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(L || {}), $ = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))($ || {}), v = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.RESTART = "application/vinteo.webrtc.restart", n))(v || {}), M = /* @__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))(M || {}), P = /* @__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))(P || {}), V = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(V || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(W || {}), Pe = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Pe || {}), g = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n.RESTART = "restart", n))(g || {});
16
- const Z = [
10
+ const Q = "sip-connector", d = x(Q), Hn = () => {
11
+ x.enable(Q);
12
+ }, xn = () => {
13
+ x.enable(`-${Q}`);
14
+ }, we = "Error decline with 603", Ue = 1006, Le = (n) => typeof n == "object" && n !== null && "code" in n && n.code === Ue, Be = (n) => n.message === we;
15
+ var l = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n))(l || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), q = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(q || {}), f = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.RESTART = "application/vinteo.webrtc.restart", n))(f || {}), _ = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(_ || {}), v = /* @__PURE__ */ ((n) => (n.PAUSE_MAIN_CAM = "PAUSEMAINCAM", n.RESUME_MAIN_CAM = "RESUMEMAINCAM", n.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", n.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", n.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", n))(v || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(W || {}), H = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(H || {}), Fe = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Fe || {}), u = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n.RESTART = "restart", n))(u || {});
16
+ const ne = [
17
17
  "participation:accepting-word-request",
18
18
  "participation:cancelling-word-request",
19
19
  "participant:move-request-to-stream",
@@ -43,8 +43,8 @@ const Z = [
43
43
  "newDTMF",
44
44
  "restart"
45
45
  ];
46
- var _ = /* @__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))(_ || {});
47
- class ve {
46
+ var p = /* @__PURE__ */ ((n) => (n.CHANNELS = "channels", n.WEBCAST_STARTED = "WebcastStarted", n.WEBCAST_STOPPED = "WebcastStopped", n.ACCOUNT_CHANGED = "accountChanged", n.ACCOUNT_DELETED = "accountDeleted", n.ADDED_TO_LIST_MODERATORS = "addedToListModerators", n.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", n.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", n.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", n.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", n))(p || {});
47
+ class ke {
48
48
  events;
49
49
  connectionManager;
50
50
  callManager;
@@ -52,13 +52,13 @@ class ve {
52
52
  connectionManager: e,
53
53
  callManager: t
54
54
  }) {
55
- this.connectionManager = e, this.callManager = t, this.events = new w(Z), this.subscribe();
55
+ this.connectionManager = e, this.callManager = t, this.events = new U(ne), this.subscribe();
56
56
  }
57
57
  async waitChannels() {
58
- return this.wait(g.CHANNELS);
58
+ return this.wait(u.CHANNELS);
59
59
  }
60
60
  async waitSyncMediaState() {
61
- return this.wait(g.ADMIN_FORCE_SYNC_MEDIA_STATE);
61
+ return this.wait(u.ADMIN_FORCE_SYNC_MEDIA_STATE);
62
62
  }
63
63
  async sendDTMF(e) {
64
64
  return new Promise((t, s) => {
@@ -77,19 +77,19 @@ class ve {
77
77
  });
78
78
  }
79
79
  async sendChannels({ inputChannels: e, outputChannels: t }) {
80
- const s = this.getEstablishedRTCSessionProtected(), i = `${h.INPUT_CHANNELS}: ${e}`, r = `${h.OUTPUT_CHANNELS}: ${t}`, a = [
80
+ const s = this.getEstablishedRTCSessionProtected(), i = `${l.INPUT_CHANNELS}: ${e}`, r = `${l.OUTPUT_CHANNELS}: ${t}`, a = [
81
81
  i,
82
82
  r
83
83
  ];
84
- return s.sendInfo(M.CHANNELS, void 0, { extraHeaders: a });
84
+ return s.sendInfo(_.CHANNELS, void 0, { extraHeaders: a });
85
85
  }
86
86
  async sendMediaState({ cam: e, mic: t }, s = {}) {
87
- const i = this.getEstablishedRTCSessionProtected(), r = `${h.MEDIA_STATE}: currentstate`, a = `${h.MAIN_CAM_STATE}: ${Number(e)}`, o = `${h.MIC_STATE}: ${Number(t)}`, c = [
87
+ const i = this.getEstablishedRTCSessionProtected(), r = `${l.MEDIA_STATE}: currentstate`, a = `${l.MAIN_CAM_STATE}: ${Number(e)}`, o = `${l.MIC_STATE}: ${Number(t)}`, c = [
88
88
  r,
89
89
  a,
90
90
  o
91
91
  ];
92
- return i.sendInfo(M.MEDIA_STATE, void 0, {
92
+ return i.sendInfo(_.MEDIA_STATE, void 0, {
93
93
  noTerminateWhenError: !0,
94
94
  ...s,
95
95
  extraHeaders: c
@@ -98,15 +98,15 @@ class ve {
98
98
  async sendStats({
99
99
  availableIncomingBitrate: e
100
100
  }) {
101
- const t = this.getEstablishedRTCSessionProtected(), i = [`${h.AVAILABLE_INCOMING_BITRATE}: ${e}`];
102
- return t.sendInfo(M.STATS, void 0, {
101
+ const t = this.getEstablishedRTCSessionProtected(), i = [`${l.AVAILABLE_INCOMING_BITRATE}: ${e}`];
102
+ return t.sendInfo(_.STATS, void 0, {
103
103
  noTerminateWhenError: !0,
104
104
  extraHeaders: i
105
105
  });
106
106
  }
107
107
  async sendRefusalToTurnOn(e, t = {}) {
108
- const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${h.MEDIA_TYPE}: ${a}`];
109
- return s.sendInfo(M.REFUSAL, void 0, {
108
+ const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${l.MEDIA_TYPE}: ${a}`];
109
+ return s.sendInfo(_.REFUSAL, void 0, {
110
110
  noTerminateWhenError: !0,
111
111
  ...t,
112
112
  extraHeaders: c
@@ -119,38 +119,38 @@ class ve {
119
119
  return this.sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
120
120
  }
121
121
  async sendMustStopPresentationP2P() {
122
- await this.getEstablishedRTCSessionProtected().sendInfo(M.SHARE_STATE, void 0, {
123
- extraHeaders: [h.MUST_STOP_PRESENTATION_P2P]
122
+ await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
123
+ extraHeaders: [l.MUST_STOP_PRESENTATION_P2P]
124
124
  });
125
125
  }
126
126
  async sendStoppedPresentationP2P() {
127
- await this.getEstablishedRTCSessionProtected().sendInfo(M.SHARE_STATE, void 0, {
128
- extraHeaders: [h.STOP_PRESENTATION_P2P]
127
+ await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
128
+ extraHeaders: [l.STOP_PRESENTATION_P2P]
129
129
  });
130
130
  }
131
131
  async sendStoppedPresentation() {
132
- await this.getEstablishedRTCSessionProtected().sendInfo(M.SHARE_STATE, void 0, {
133
- extraHeaders: [h.STOP_PRESENTATION]
132
+ await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
133
+ extraHeaders: [l.STOP_PRESENTATION]
134
134
  });
135
135
  }
136
136
  async askPermissionToStartPresentationP2P() {
137
- await this.getEstablishedRTCSessionProtected().sendInfo(M.SHARE_STATE, void 0, {
138
- extraHeaders: [h.START_PRESENTATION_P2P]
137
+ await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
138
+ extraHeaders: [l.START_PRESENTATION_P2P]
139
139
  });
140
140
  }
141
141
  async askPermissionToStartPresentation() {
142
- await this.getEstablishedRTCSessionProtected().sendInfo(M.SHARE_STATE, void 0, {
143
- extraHeaders: [h.START_PRESENTATION]
142
+ await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
143
+ extraHeaders: [l.START_PRESENTATION]
144
144
  });
145
145
  }
146
146
  async askPermissionToEnableCam(e = {}) {
147
- const t = this.getEstablishedRTCSessionProtected(), s = [h.ENABLE_MAIN_CAM];
148
- return t.sendInfo(M.MAIN_CAM, void 0, {
147
+ const t = this.getEstablishedRTCSessionProtected(), s = [l.ENABLE_MAIN_CAM];
148
+ return t.sendInfo(_.MAIN_CAM, void 0, {
149
149
  noTerminateWhenError: !0,
150
150
  ...e,
151
151
  extraHeaders: s
152
152
  }).catch((i) => {
153
- if (pe(i))
153
+ if (Be(i))
154
154
  throw i;
155
155
  });
156
156
  }
@@ -189,110 +189,110 @@ class ve {
189
189
  };
190
190
  maybeHandleNotify = (e) => {
191
191
  try {
192
- const t = e.getHeader(h.NOTIFY);
192
+ const t = e.getHeader(l.NOTIFY);
193
193
  if (t) {
194
194
  const s = JSON.parse(t);
195
195
  this.handleNotify(s);
196
196
  }
197
197
  } catch (t) {
198
- E("error parse notify", t);
198
+ d("error parse notify", t);
199
199
  }
200
200
  };
201
201
  handleNotify = (e) => {
202
202
  switch (e.cmd) {
203
- case _.CHANNELS: {
203
+ case p.CHANNELS: {
204
204
  const t = e;
205
205
  this.triggerChannelsNotify(t);
206
206
  break;
207
207
  }
208
- case _.WEBCAST_STARTED: {
208
+ case p.WEBCAST_STARTED: {
209
209
  const t = e;
210
210
  this.triggerWebcastStartedNotify(t);
211
211
  break;
212
212
  }
213
- case _.WEBCAST_STOPPED: {
213
+ case p.WEBCAST_STOPPED: {
214
214
  const t = e;
215
215
  this.triggerWebcastStoppedNotify(t);
216
216
  break;
217
217
  }
218
- case _.ADDED_TO_LIST_MODERATORS: {
218
+ case p.ADDED_TO_LIST_MODERATORS: {
219
219
  const t = e;
220
220
  this.triggerAddedToListModeratorsNotify(t);
221
221
  break;
222
222
  }
223
- case _.REMOVED_FROM_LIST_MODERATORS: {
223
+ case p.REMOVED_FROM_LIST_MODERATORS: {
224
224
  const t = e;
225
225
  this.triggerRemovedFromListModeratorsNotify(t);
226
226
  break;
227
227
  }
228
- case _.ACCEPTING_WORD_REQUEST: {
228
+ case p.ACCEPTING_WORD_REQUEST: {
229
229
  const t = e;
230
230
  this.triggerParticipationAcceptingWordRequest(t);
231
231
  break;
232
232
  }
233
- case _.CANCELLING_WORD_REQUEST: {
233
+ case p.CANCELLING_WORD_REQUEST: {
234
234
  const t = e;
235
235
  this.triggerParticipationCancellingWordRequest(t);
236
236
  break;
237
237
  }
238
- case _.MOVE_REQUEST_TO_STREAM: {
238
+ case p.MOVE_REQUEST_TO_STREAM: {
239
239
  const t = e;
240
240
  this.triggerParticipantMoveRequestToStream(t);
241
241
  break;
242
242
  }
243
- case _.ACCOUNT_CHANGED: {
243
+ case p.ACCOUNT_CHANGED: {
244
244
  this.triggerAccountChangedNotify();
245
245
  break;
246
246
  }
247
- case _.ACCOUNT_DELETED: {
247
+ case p.ACCOUNT_DELETED: {
248
248
  this.triggerAccountDeletedNotify();
249
249
  break;
250
250
  }
251
- case _.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
251
+ case p.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
252
252
  const t = e;
253
253
  this.triggerConferenceParticipantTokenIssued(t);
254
254
  break;
255
255
  }
256
256
  default:
257
- E("unknown cmd", e);
257
+ d("unknown cmd", e);
258
258
  }
259
259
  };
260
260
  handleNewInfo = (e) => {
261
261
  const { originator: t } = e;
262
262
  if (t !== "remote")
263
263
  return;
264
- const { request: s } = e, i = s, r = i.getHeader(h.CONTENT_TYPE);
264
+ const { request: s } = e, i = s, r = i.getHeader(l.CONTENT_TYPE);
265
265
  if (r !== void 0)
266
266
  switch (r) {
267
- case v.ENTER_ROOM: {
267
+ case f.ENTER_ROOM: {
268
268
  this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
269
269
  break;
270
270
  }
271
- case v.NOTIFY: {
271
+ case f.NOTIFY: {
272
272
  this.maybeHandleNotify(i);
273
273
  break;
274
274
  }
275
- case v.SHARE_STATE: {
275
+ case f.SHARE_STATE: {
276
276
  this.triggerShareState(i);
277
277
  break;
278
278
  }
279
- case v.MAIN_CAM: {
279
+ case f.MAIN_CAM: {
280
280
  this.triggerMainCamControl(i);
281
281
  break;
282
282
  }
283
- case v.MIC: {
283
+ case f.MIC: {
284
284
  this.triggerMicControl(i);
285
285
  break;
286
286
  }
287
- case v.USE_LICENSE: {
287
+ case f.USE_LICENSE: {
288
288
  this.triggerUseLicense(i);
289
289
  break;
290
290
  }
291
- case v.PARTICIPANT_STATE: {
291
+ case f.PARTICIPANT_STATE: {
292
292
  this.maybeTriggerParticipantMoveRequest(i);
293
293
  break;
294
294
  }
295
- case v.RESTART: {
295
+ case f.RESTART: {
296
296
  this.triggerRestart(i);
297
297
  break;
298
298
  }
@@ -303,7 +303,7 @@ class ve {
303
303
  inputChannels: t,
304
304
  outputChannels: s
305
305
  };
306
- this.events.trigger(g.CHANNELS_NOTIFY, i);
306
+ this.events.trigger(u.CHANNELS_NOTIFY, i);
307
307
  };
308
308
  triggerWebcastStartedNotify = ({
309
309
  body: { conference: e, type: t }
@@ -312,7 +312,7 @@ class ve {
312
312
  conference: e,
313
313
  type: t
314
314
  };
315
- this.events.trigger(g.WEBCAST_STARTED, s);
315
+ this.events.trigger(u.WEBCAST_STARTED, s);
316
316
  };
317
317
  triggerWebcastStoppedNotify = ({
318
318
  body: { conference: e, type: t }
@@ -321,7 +321,7 @@ class ve {
321
321
  conference: e,
322
322
  type: t
323
323
  };
324
- this.events.trigger(g.WEBCAST_STOPPED, s);
324
+ this.events.trigger(u.WEBCAST_STOPPED, s);
325
325
  };
326
326
  triggerAddedToListModeratorsNotify = ({
327
327
  conference: e
@@ -330,7 +330,7 @@ class ve {
330
330
  conference: e
331
331
  };
332
332
  this.events.trigger(
333
- g.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
333
+ u.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
334
334
  t
335
335
  );
336
336
  };
@@ -341,7 +341,7 @@ class ve {
341
341
  conference: e
342
342
  };
343
343
  this.events.trigger(
344
- g.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
344
+ u.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
345
345
  t
346
346
  );
347
347
  };
@@ -351,7 +351,7 @@ class ve {
351
351
  const t = {
352
352
  conference: e
353
353
  };
354
- this.events.trigger(g.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
354
+ this.events.trigger(u.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
355
355
  };
356
356
  triggerParticipationCancellingWordRequest = ({
357
357
  body: { conference: e }
@@ -359,7 +359,7 @@ class ve {
359
359
  const t = {
360
360
  conference: e
361
361
  };
362
- this.events.trigger(g.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
362
+ this.events.trigger(u.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
363
363
  };
364
364
  triggerParticipantMoveRequestToStream = ({
365
365
  body: { conference: e }
@@ -367,13 +367,13 @@ class ve {
367
367
  const t = {
368
368
  conference: e
369
369
  };
370
- this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
370
+ this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
371
371
  };
372
372
  triggerAccountChangedNotify = () => {
373
- this.events.trigger(g.ACCOUNT_CHANGED, void 0);
373
+ this.events.trigger(u.ACCOUNT_CHANGED, void 0);
374
374
  };
375
375
  triggerAccountDeletedNotify = () => {
376
- this.events.trigger(g.ACCOUNT_DELETED, void 0);
376
+ this.events.trigger(u.ACCOUNT_DELETED, void 0);
377
377
  };
378
378
  triggerConferenceParticipantTokenIssued = ({
379
379
  body: { conference: e, participant: t, jwt: s }
@@ -384,84 +384,84 @@ class ve {
384
384
  jwt: s
385
385
  };
386
386
  this.events.trigger(
387
- g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
387
+ u.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
388
388
  i
389
389
  );
390
390
  };
391
391
  maybeTriggerChannels = (e) => {
392
- const t = e.getHeader(h.INPUT_CHANNELS), s = e.getHeader(h.OUTPUT_CHANNELS);
392
+ const t = e.getHeader(l.INPUT_CHANNELS), s = e.getHeader(l.OUTPUT_CHANNELS);
393
393
  if (t && s) {
394
394
  const i = {
395
395
  inputChannels: t,
396
396
  outputChannels: s
397
397
  };
398
- this.events.trigger(g.CHANNELS, i);
398
+ this.events.trigger(u.CHANNELS, i);
399
399
  }
400
400
  };
401
401
  triggerEnterRoom = (e) => {
402
- const t = e.getHeader(h.CONTENT_ENTER_ROOM), s = e.getHeader(h.PARTICIPANT_NAME);
403
- this.events.trigger(g.ENTER_ROOM, { room: t, participantName: s });
402
+ const t = e.getHeader(l.CONTENT_ENTER_ROOM), s = e.getHeader(l.PARTICIPANT_NAME);
403
+ this.events.trigger(u.ENTER_ROOM, { room: t, participantName: s });
404
404
  };
405
405
  triggerShareState = (e) => {
406
- const t = e.getHeader(h.CONTENT_SHARE_STATE);
406
+ const t = e.getHeader(l.CONTENT_SHARE_STATE);
407
407
  if (t !== void 0)
408
408
  switch (t) {
409
- case L.AVAILABLE_SECOND_REMOTE_STREAM: {
410
- this.events.trigger(g.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
409
+ case B.AVAILABLE_SECOND_REMOTE_STREAM: {
410
+ this.events.trigger(u.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
411
411
  break;
412
412
  }
413
- case L.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
414
- this.events.trigger(g.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
413
+ case B.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
414
+ this.events.trigger(u.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
415
415
  break;
416
416
  }
417
- case L.MUST_STOP_PRESENTATION: {
418
- this.events.trigger(g.MUST_STOP_PRESENTATION, void 0);
417
+ case B.MUST_STOP_PRESENTATION: {
418
+ this.events.trigger(u.MUST_STOP_PRESENTATION, void 0);
419
419
  break;
420
420
  }
421
421
  }
422
422
  };
423
423
  maybeTriggerParticipantMoveRequest = (e) => {
424
- const t = e.getHeader(h.CONTENT_PARTICIPANT_STATE);
425
- t === $.SPECTATOR && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === $.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
424
+ const t = e.getHeader(l.CONTENT_PARTICIPANT_STATE);
425
+ t === q.SPECTATOR && this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === q.PARTICIPANT && this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0);
426
426
  };
427
427
  triggerMainCamControl = (e) => {
428
- const t = e.getHeader(h.MAIN_CAM), s = e.getHeader(h.MEDIA_SYNC), i = s === W.ADMIN_SYNC_FORCED;
429
- if (t === P.ADMIN_START_MAIN_CAM) {
430
- this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
428
+ const t = e.getHeader(l.MAIN_CAM), s = e.getHeader(l.MEDIA_SYNC), i = s === H.ADMIN_SYNC_FORCED;
429
+ if (t === v.ADMIN_START_MAIN_CAM) {
430
+ this.events.trigger(u.ADMIN_START_MAIN_CAM, { isSyncForced: i });
431
431
  return;
432
432
  }
433
- if (t === P.ADMIN_STOP_MAIN_CAM) {
434
- this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
433
+ if (t === v.ADMIN_STOP_MAIN_CAM) {
434
+ this.events.trigger(u.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
435
435
  return;
436
436
  }
437
- (t === P.RESUME_MAIN_CAM || t === P.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
438
- const r = e.getHeader(h.MAIN_CAM_RESOLUTION);
439
- this.events.trigger(g.MAIN_CAM_CONTROL, {
437
+ (t === v.RESUME_MAIN_CAM || t === v.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(u.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
438
+ const r = e.getHeader(l.MAIN_CAM_RESOLUTION);
439
+ this.events.trigger(u.MAIN_CAM_CONTROL, {
440
440
  mainCam: t,
441
441
  resolutionMainCam: r
442
442
  });
443
443
  };
444
444
  triggerMicControl = (e) => {
445
- const t = e.getHeader(h.MIC), i = e.getHeader(h.MEDIA_SYNC) === W.ADMIN_SYNC_FORCED;
446
- t === V.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: i }) : t === V.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: i });
445
+ const t = e.getHeader(l.MIC), i = e.getHeader(l.MEDIA_SYNC) === H.ADMIN_SYNC_FORCED;
446
+ t === W.ADMIN_START_MIC ? this.events.trigger(u.ADMIN_START_MIC, { isSyncForced: i }) : t === W.ADMIN_STOP_MIC && this.events.trigger(u.ADMIN_STOP_MIC, { isSyncForced: i });
447
447
  };
448
448
  triggerUseLicense = (e) => {
449
- const t = e.getHeader(h.CONTENT_USE_LICENSE);
450
- this.events.trigger(g.USE_LICENSE, t);
449
+ const t = e.getHeader(l.CONTENT_USE_LICENSE);
450
+ this.events.trigger(u.USE_LICENSE, t);
451
451
  };
452
452
  triggerRestart = (e) => {
453
453
  const t = e.getHeader(
454
- h.TRACKS_DIRECTION
454
+ l.TRACKS_DIRECTION
455
455
  ), s = Number(
456
- e.getHeader(h.AUDIO_TRACK_COUNT)
456
+ e.getHeader(l.AUDIO_TRACK_COUNT)
457
457
  ), i = Number(
458
- e.getHeader(h.VIDEO_TRACK_COUNT)
458
+ e.getHeader(l.VIDEO_TRACK_COUNT)
459
459
  ), r = { tracksDirection: t, audioTrackCount: s, videoTrackCount: i };
460
- this.events.trigger(g.RESTART, r);
460
+ this.events.trigger(u.RESTART, r);
461
461
  };
462
462
  }
463
- var N = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n))(N || {}), fe = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(fe || {});
464
- const ee = [
463
+ var N = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n.CALL_STATUS_CHANGED = "call-status-changed", n))(N || {}), $e = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))($e || {});
464
+ const se = [
465
465
  "peerconnection",
466
466
  "connecting",
467
467
  "sending",
@@ -488,18 +488,19 @@ const ee = [
488
488
  "peerconnection:createanswerfailed",
489
489
  "peerconnection:setlocaldescriptionfailed",
490
490
  "peerconnection:setremotedescriptionfailed"
491
- ], Oe = [
491
+ ], Ve = [
492
492
  "peerconnection:confirmed",
493
493
  "peerconnection:ontrack",
494
- "ended:fromserver"
495
- ], te = [
496
- ...ee,
497
- ...Oe
498
- ], De = (n, e) => {
494
+ "ended:fromserver",
495
+ "call-status-changed"
496
+ ], ie = [
497
+ ...se,
498
+ ...Ve
499
+ ], qe = (n, e) => {
499
500
  n.getVideoTracks().forEach((s) => {
500
501
  "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
501
502
  });
502
- }, B = (n, {
503
+ }, F = (n, {
503
504
  directionVideo: e,
504
505
  directionAudio: t,
505
506
  contentHint: s
@@ -507,16 +508,16 @@ const ee = [
507
508
  if (!n || e === "recvonly" && t === "recvonly")
508
509
  return;
509
510
  const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
510
- return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && De(o, s), o;
511
+ return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && qe(o, s), o;
511
512
  };
512
- function ye(n) {
513
+ function We(n) {
513
514
  return (e) => `sip:${e}@${n}`;
514
515
  }
515
- const be = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, ne = (n) => n.trim().replaceAll(" ", "_"), we = be(1e5, 99999999), Ue = (n) => n.some((t) => {
516
+ const He = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, re = (n) => n.trim().replaceAll(" ", "_"), xe = He(1e5, 99999999), Ge = (n) => n.some((t) => {
516
517
  const { kind: s } = t;
517
518
  return s === "video";
518
519
  });
519
- class Le {
520
+ class Qe {
520
521
  isPendingCall = !1;
521
522
  isPendingAnswer = !1;
522
523
  rtcSession;
@@ -527,8 +528,8 @@ class Le {
527
528
  this.events = e;
528
529
  }
529
530
  }
530
- var se = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(se || {});
531
- class Be {
531
+ var ae = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(ae || {});
532
+ class Ye {
532
533
  remoteStreams = {};
533
534
  reset() {
534
535
  this.remoteStreams = {};
@@ -557,8 +558,8 @@ class Be {
557
558
  return e.map((t) => this.generateAudioStream(t));
558
559
  }
559
560
  }
560
- class ke extends Le {
561
- remoteStreamsManager = new Be();
561
+ class ze extends Qe {
562
+ remoteStreamsManager = new Ye();
562
563
  disposers = /* @__PURE__ */ new Set();
563
564
  constructor(e) {
564
565
  super(e), e.on(N.FAILED, this.handleEnded), e.on(N.ENDED, this.handleEnded);
@@ -582,28 +583,28 @@ class ke extends Le {
582
583
  ontrack: a,
583
584
  iceServers: o,
584
585
  directionVideo: c,
585
- directionAudio: d,
586
- contentHint: u,
587
- offerToReceiveAudio: T = !0,
588
- offerToReceiveVideo: l = !0,
589
- degradationPreference: S,
586
+ directionAudio: h,
587
+ contentHint: T,
588
+ offerToReceiveAudio: S = !0,
589
+ offerToReceiveVideo: g = !0,
590
+ degradationPreference: C,
590
591
  sendEncodings: m,
591
592
  onAddedTransceiver: I
592
- }) => (this.isPendingCall = !0, new Promise((R, D) => {
593
- this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(R).catch((k) => {
594
- D(k);
593
+ }) => (this.isPendingCall = !0, new Promise((R, y) => {
594
+ this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(R).catch(($) => {
595
+ y($);
595
596
  }), this.rtcSession = e.call(t(s), {
596
- mediaStream: B(i, {
597
+ mediaStream: F(i, {
597
598
  directionVideo: c,
598
- directionAudio: d,
599
- contentHint: u
599
+ directionAudio: h,
600
+ contentHint: T
600
601
  }),
601
602
  pcConfig: {
602
603
  iceServers: o
603
604
  },
604
605
  rtcOfferConstraints: {
605
- offerToReceiveAudio: T,
606
- offerToReceiveVideo: l
606
+ offerToReceiveAudio: S,
607
+ offerToReceiveVideo: g
607
608
  },
608
609
  // необходимо передавать в методе call, чтобы подписаться на события peerconnection,
609
610
  // так как в методе call создается RTCSession
@@ -611,8 +612,8 @@ class ke extends Le {
611
612
  eventHandlers: this.events.triggers,
612
613
  extraHeaders: r,
613
614
  directionVideo: c,
614
- directionAudio: d,
615
- degradationPreference: S,
615
+ directionAudio: h,
616
+ degradationPreference: C,
616
617
  sendEncodings: m,
617
618
  onAddedTransceiver: I
618
619
  });
@@ -623,7 +624,7 @@ class ke extends Le {
623
624
  const { rtcSession: e } = this;
624
625
  if (e && !e.isEnded())
625
626
  return e.terminateAsync({
626
- cause: se.CANCELED
627
+ cause: ae.CANCELED
627
628
  }).finally(() => {
628
629
  this.reset();
629
630
  });
@@ -637,35 +638,35 @@ class ke extends Le {
637
638
  directionVideo: a,
638
639
  directionAudio: o,
639
640
  offerToReceiveAudio: c,
640
- offerToReceiveVideo: d,
641
- contentHint: u,
642
- degradationPreference: T,
643
- sendEncodings: l,
644
- onAddedTransceiver: S
641
+ offerToReceiveVideo: h,
642
+ contentHint: T,
643
+ degradationPreference: S,
644
+ sendEncodings: g,
645
+ onAddedTransceiver: C
645
646
  }) => (this.isPendingAnswer = !0, new Promise((m, I) => {
646
647
  try {
647
648
  const R = e();
648
- this.rtcSession = R, this.subscribeToSessionEvents(R), this.callConfiguration.answer = !0, this.callConfiguration.number = R.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(m).catch((D) => {
649
- I(D);
649
+ this.rtcSession = R, this.subscribeToSessionEvents(R), this.callConfiguration.answer = !0, this.callConfiguration.number = R.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(m).catch((y) => {
650
+ I(y);
650
651
  }), R.answer({
651
652
  pcConfig: {
652
653
  iceServers: r
653
654
  },
654
655
  rtcOfferConstraints: {
655
656
  offerToReceiveAudio: c,
656
- offerToReceiveVideo: d
657
+ offerToReceiveVideo: h
657
658
  },
658
- mediaStream: B(t, {
659
+ mediaStream: F(t, {
659
660
  directionVideo: a,
660
661
  directionAudio: o,
661
- contentHint: u
662
+ contentHint: T
662
663
  }),
663
664
  extraHeaders: i,
664
665
  directionVideo: a,
665
666
  directionAudio: o,
666
- degradationPreference: T,
667
- sendEncodings: l,
668
- onAddedTransceiver: S
667
+ degradationPreference: S,
668
+ sendEncodings: g,
669
+ onAddedTransceiver: C
669
670
  });
670
671
  } catch (R) {
671
672
  I(R);
@@ -683,12 +684,12 @@ class ke extends Le {
683
684
  if (!this.connection)
684
685
  return;
685
686
  const t = this.connection.getReceivers().map(({ track: s }) => s);
686
- return Ue(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
687
+ return Ge(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
687
688
  }
688
689
  async replaceMediaStream(e, t) {
689
690
  if (!this.rtcSession)
690
691
  throw new Error("No rtcSession established");
691
- const { contentHint: s } = t ?? {}, i = B(e, { contentHint: s });
692
+ const { contentHint: s } = t ?? {}, i = F(e, { contentHint: s });
692
693
  if (i === void 0)
693
694
  throw new Error("No preparedMediaStream");
694
695
  return this.rtcSession.replaceMediaStream(i, t);
@@ -707,33 +708,33 @@ class ke extends Le {
707
708
  ontrack: e
708
709
  }) => new Promise((t, s) => {
709
710
  const i = () => {
710
- this.events.on(N.PEER_CONNECTION, u), this.events.on(N.CONFIRMED, T);
711
+ this.events.on(N.PEER_CONNECTION, T), this.events.on(N.CONFIRMED, S);
711
712
  }, r = () => {
712
- this.events.off(N.PEER_CONNECTION, u), this.events.off(N.CONFIRMED, T);
713
+ this.events.off(N.PEER_CONNECTION, T), this.events.off(N.CONFIRMED, S);
713
714
  }, a = () => {
714
715
  this.events.on(N.FAILED, c), this.events.on(N.ENDED, c);
715
716
  }, o = () => {
716
717
  this.events.off(N.FAILED, c), this.events.off(N.ENDED, c);
717
- }, c = (l) => {
718
- r(), o(), s(l);
718
+ }, c = (g) => {
719
+ r(), o(), s(g);
719
720
  };
720
- let d;
721
- const u = ({ peerconnection: l }) => {
722
- d = l;
723
- const S = (m) => {
721
+ let h;
722
+ const T = ({ peerconnection: g }) => {
723
+ h = g;
724
+ const C = (m) => {
724
725
  this.events.trigger(N.PEER_CONNECTION_ONTRACK, m), e && e(m);
725
726
  };
726
- l.addEventListener("track", S), this.disposers.add(() => {
727
- l.removeEventListener("track", S);
727
+ g.addEventListener("track", C), this.disposers.add(() => {
728
+ g.removeEventListener("track", C);
728
729
  });
729
- }, T = () => {
730
- d !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, d), r(), o(), t(d);
730
+ }, S = () => {
731
+ h !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, h), r(), o(), t(h);
731
732
  };
732
733
  i(), a();
733
734
  });
734
735
  subscribeToSessionEvents(e) {
735
736
  this.events.eachTriggers((t, s) => {
736
- const i = ee.find((r) => r === s);
737
+ const i = se.find((r) => r === s);
737
738
  i && (e.on(i, t), this.disposers.add(() => {
738
739
  e.off(i, t);
739
740
  }));
@@ -752,11 +753,11 @@ class ke extends Le {
752
753
  delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
753
754
  };
754
755
  }
755
- class Fe {
756
+ class Xe {
756
757
  events;
757
758
  strategy;
758
759
  constructor(e) {
759
- this.events = new H(te), this.strategy = e ?? new ke(this.events);
760
+ this.events = new k(ie), this.strategy = e ?? new ze(this.events), this.subscribeCallStatusChange();
760
761
  }
761
762
  get requested() {
762
763
  return this.strategy.requested;
@@ -773,6 +774,9 @@ class Fe {
773
774
  on(e, t) {
774
775
  return this.events.on(e, t);
775
776
  }
777
+ onRace(e, t) {
778
+ return this.events.onRace(e, t);
779
+ }
776
780
  once(e, t) {
777
781
  return this.events.once(e, t);
778
782
  }
@@ -797,40 +801,51 @@ class Fe {
797
801
  addTransceiver = async (...e) => this.strategy.addTransceiver(...e);
798
802
  replaceMediaStream = async (...e) => this.strategy.replaceMediaStream(...e);
799
803
  restartIce = async (e) => this.strategy.restartIce(e);
804
+ subscribeCallStatusChange() {
805
+ let { isCallActive: e } = this;
806
+ const { ACCEPTED: t, CONFIRMED: s, ENDED: i, FAILED: r } = N;
807
+ this.onRace([t, s, i, r], () => {
808
+ e = this.maybeTriggerCallStatus(e);
809
+ });
810
+ }
811
+ maybeTriggerCallStatus(e) {
812
+ const t = this.isCallActive;
813
+ return t !== e && this.events.trigger(N.CALL_STATUS_CHANGED, { isCallActive: t }), t;
814
+ }
800
815
  }
801
- const $e = (n, e) => (n.degradationPreference = e.degradationPreference, n), Ve = (n, e) => {
816
+ const Je = (n, e) => (n.degradationPreference = e.degradationPreference, n), Ke = (n, e) => {
802
817
  n.encodings ??= [];
803
818
  for (let t = n.encodings.length; t < e; t += 1)
804
819
  n.encodings.push({});
805
820
  return n;
806
- }, ie = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, We = ie(), He = (n, e) => {
807
- if (We(n, e))
821
+ }, oe = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, je = oe(), Ze = (n, e) => {
822
+ if (je(n, e))
808
823
  return n;
809
- }, xe = (n, e) => {
810
- const t = n.maxBitrate, s = He(e, t);
824
+ }, et = (n, e) => {
825
+ const t = n.maxBitrate, s = Ze(e, t);
811
826
  return s !== void 0 && (n.maxBitrate = s), n;
812
- }, re = 1, qe = ie(
813
- re
814
- ), Ge = (n, e) => {
815
- const t = n === void 0 ? void 0 : Math.max(n, re);
816
- if (t !== void 0 && qe(
827
+ }, ce = 1, tt = oe(
828
+ ce
829
+ ), nt = (n, e) => {
830
+ const t = n === void 0 ? void 0 : Math.max(n, ce);
831
+ if (t !== void 0 && tt(
817
832
  t,
818
833
  e
819
834
  ))
820
835
  return t;
821
- }, Qe = (n, e) => {
822
- const t = n.scaleResolutionDownBy, s = Ge(
836
+ }, st = (n, e) => {
837
+ const t = n.scaleResolutionDownBy, s = nt(
823
838
  e,
824
839
  t
825
840
  );
826
841
  return s !== void 0 && (n.scaleResolutionDownBy = s), n;
827
- }, Ye = (n, e) => {
842
+ }, it = (n, e) => {
828
843
  const t = e.encodings?.length ?? 0;
829
- return Ve(n, t), n.encodings.forEach((s, i) => {
844
+ return Ke(n, t), n.encodings.forEach((s, i) => {
830
845
  const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
831
- xe(s, a), Qe(s, o);
846
+ et(s, a), st(s, o);
832
847
  }), n;
833
- }, ze = (n, e) => {
848
+ }, rt = (n, e) => {
834
849
  if (n.codecs?.length !== e.codecs?.length)
835
850
  return !0;
836
851
  for (let t = 0; t < (n.codecs?.length ?? 0); t++)
@@ -847,15 +862,15 @@ const $e = (n, e) => (n.degradationPreference = e.degradationPreference, n), Ve
847
862
  if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
848
863
  return !0;
849
864
  return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
850
- }, Xe = async (n, e) => {
865
+ }, at = async (n, e) => {
851
866
  const t = n.getParameters(), s = JSON.parse(
852
867
  JSON.stringify(t)
853
868
  );
854
- Ye(t, e), $e(t, e);
855
- const i = ze(s, t);
869
+ it(t, e), Je(t, e);
870
+ const i = rt(s, t);
856
871
  return i && await n.setParameters(t), { parameters: t, isChanged: i };
857
- }, ae = async (n, e, t) => {
858
- const { isChanged: s, parameters: i } = await Xe(n, {
872
+ }, de = async (n, e, t) => {
873
+ const { isChanged: s, parameters: i } = await at(n, {
859
874
  encodings: [
860
875
  {
861
876
  scaleResolutionDownBy: e.scaleResolutionDownBy,
@@ -864,20 +879,20 @@ const $e = (n, e) => (n.degradationPreference = e.degradationPreference, n), Ve
864
879
  ]
865
880
  });
866
881
  return s && t && t(i), { isChanged: s, parameters: i };
867
- }, Je = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), Ke = async (n, e, t) => {
868
- const s = Je(n, e);
882
+ }, ot = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), ct = async (n, e, t) => {
883
+ const s = ot(n, e);
869
884
  if (s)
870
- return ae(s, { maxBitrate: t });
885
+ return de(s, { maxBitrate: t });
871
886
  };
872
- var f = /* @__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))(f || {});
873
- const oe = [
887
+ 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 || {});
888
+ const he = [
874
889
  "presentation:start",
875
890
  "presentation:started",
876
891
  "presentation:end",
877
892
  "presentation:ended",
878
893
  "presentation:failed"
879
- ], je = 1, Cn = (n) => Ne(n);
880
- class Ze {
894
+ ], dt = 1, Gn = (n) => Oe(n);
895
+ class ht {
881
896
  events;
882
897
  promisePendingStartPresentation;
883
898
  promisePendingStopPresentation;
@@ -889,7 +904,7 @@ class Ze {
889
904
  callManager: e,
890
905
  maxBitrate: t
891
906
  }) {
892
- this.callManager = e, this.maxBitrate = t, this.events = new w(oe), this.subscribe();
907
+ this.callManager = e, this.maxBitrate = t, this.events = new U(he), this.subscribe();
893
908
  }
894
909
  get isPendingPresentation() {
895
910
  return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
@@ -924,8 +939,8 @@ class Ze {
924
939
  });
925
940
  const i = this.callManager.getEstablishedRTCSession();
926
941
  return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
927
- throw this.events.trigger(f.FAILED_PRESENTATION, r), r;
928
- }) : t && this.events.trigger(f.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
942
+ throw this.events.trigger(P.FAILED_PRESENTATION, r), r;
943
+ }) : t && this.events.trigger(P.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
929
944
  this.resetPresentation();
930
945
  });
931
946
  }
@@ -968,15 +983,15 @@ class Ze {
968
983
  }
969
984
  subscribe() {
970
985
  this.callManager.on("presentation:start", (e) => {
971
- this.events.trigger(f.START_PRESENTATION, e);
986
+ this.events.trigger(P.START_PRESENTATION, e);
972
987
  }), this.callManager.on("presentation:started", (e) => {
973
- this.events.trigger(f.STARTED_PRESENTATION, e);
988
+ this.events.trigger(P.STARTED_PRESENTATION, e);
974
989
  }), this.callManager.on("presentation:end", (e) => {
975
- this.events.trigger(f.END_PRESENTATION, e);
990
+ this.events.trigger(P.END_PRESENTATION, e);
976
991
  }), this.callManager.on("presentation:ended", (e) => {
977
- this.events.trigger(f.ENDED_PRESENTATION, e);
992
+ this.events.trigger(P.ENDED_PRESENTATION, e);
978
993
  }), this.callManager.on("presentation:failed", (e) => {
979
- this.events.trigger(f.FAILED_PRESENTATION, e);
994
+ this.events.trigger(P.FAILED_PRESENTATION, e);
980
995
  }), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
981
996
  }
982
997
  async sendPresentationWithDuplicatedCalls(e, {
@@ -984,7 +999,7 @@ class Ze {
984
999
  stream: s,
985
1000
  presentationOptions: i,
986
1001
  options: r = {
987
- callLimit: je
1002
+ callLimit: dt
988
1003
  }
989
1004
  }) {
990
1005
  const a = async () => this.sendPresentation(
@@ -993,7 +1008,7 @@ class Ze {
993
1008
  s,
994
1009
  i
995
1010
  ), o = () => !!this.streamPresentationCurrent;
996
- return this.cancelableSendPresentationWithRepeatedCalls = J({
1011
+ return this.cancelableSendPresentationWithRepeatedCalls = ee({
997
1012
  targetFunction: a,
998
1013
  isComplete: o,
999
1014
  isRejectAsValid: !0,
@@ -1008,18 +1023,18 @@ class Ze {
1008
1023
  sendEncodings: o,
1009
1024
  onAddedTransceiver: c
1010
1025
  }) {
1011
- const d = B(s, { contentHint: r });
1012
- if (d === void 0)
1026
+ const h = F(s, { contentHint: r });
1027
+ if (h === void 0)
1013
1028
  throw new Error("No streamPresentationTarget");
1014
- this.streamPresentationCurrent = d;
1015
- const u = e().then(async () => t.startPresentation(d, i, {
1029
+ this.streamPresentationCurrent = h;
1030
+ const T = e().then(async () => t.startPresentation(h, i, {
1016
1031
  degradationPreference: a,
1017
1032
  sendEncodings: o,
1018
1033
  onAddedTransceiver: c
1019
- })).then(this.setMaxBitrate).then(() => s).catch((T) => {
1020
- throw this.removeStreamPresentationCurrent(), this.events.trigger(f.FAILED_PRESENTATION, T), T;
1034
+ })).then(this.setMaxBitrate).then(() => s).catch((S) => {
1035
+ throw this.removeStreamPresentationCurrent(), this.events.trigger(P.FAILED_PRESENTATION, S), S;
1021
1036
  });
1022
- return this.promisePendingStartPresentation = u, u.finally(() => {
1037
+ return this.promisePendingStartPresentation = T, T.finally(() => {
1023
1038
  this.promisePendingStartPresentation = void 0;
1024
1039
  });
1025
1040
  }
@@ -1028,7 +1043,7 @@ class Ze {
1028
1043
  if (!e || !t || s === void 0)
1029
1044
  return;
1030
1045
  const i = e.getSenders();
1031
- await Ke(i, t, s);
1046
+ await ct(i, t, s);
1032
1047
  };
1033
1048
  getRtcSessionProtected = () => {
1034
1049
  const e = this.callManager.getEstablishedRTCSession();
@@ -1049,7 +1064,7 @@ class Ze {
1049
1064
  delete this.streamPresentationCurrent;
1050
1065
  }
1051
1066
  }
1052
- class et {
1067
+ class lt {
1053
1068
  data = {};
1054
1069
  getUa;
1055
1070
  constructor(e) {
@@ -1122,8 +1137,8 @@ class et {
1122
1137
  return this.data.register === !0;
1123
1138
  }
1124
1139
  }
1125
- var A = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n))(A || {});
1126
- const ce = [
1140
+ var A = /* @__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))(A || {});
1141
+ const le = [
1127
1142
  "connecting",
1128
1143
  "connected",
1129
1144
  "disconnected",
@@ -1133,8 +1148,13 @@ const ce = [
1133
1148
  "registrationFailed",
1134
1149
  "newMessage",
1135
1150
  "sipEvent"
1136
- ], de = [...ce], tt = 3;
1137
- class nt {
1151
+ ], gt = [
1152
+ "disconnecting",
1153
+ "connect-started",
1154
+ "connect-succeeded",
1155
+ "connect-failed"
1156
+ ], ge = [...le, ...gt], ut = 3;
1157
+ class Tt {
1138
1158
  cancelableConnectWithRepeatedCalls;
1139
1159
  JsSIP;
1140
1160
  events;
@@ -1160,11 +1180,12 @@ class nt {
1160
1180
  }
1161
1181
  let r = !1;
1162
1182
  const a = this.getConnectionConfiguration();
1163
- e !== void 0 && e !== a.displayName && (r = i.set("display_name", ne(e)), this.updateConnectionConfiguration("displayName", e));
1183
+ e !== void 0 && e !== a.displayName && (r = i.set("display_name", re(e)), this.updateConnectionConfiguration("displayName", e));
1164
1184
  const o = r;
1165
1185
  o ? t(o) : s(new Error("nothing changed"));
1166
1186
  });
1167
1187
  disconnect = async () => {
1188
+ this.events.trigger(A.DISCONNECTING, void 0);
1168
1189
  const e = new Promise((s) => {
1169
1190
  this.events.once(A.DISCONNECTED, () => {
1170
1191
  s();
@@ -1177,12 +1198,12 @@ class nt {
1177
1198
  cancelRequests() {
1178
1199
  this.cancelConnectWithRepeatedCalls();
1179
1200
  }
1180
- connectWithDuplicatedCalls = async (e, { callLimit: t = tt } = {}) => {
1201
+ connectWithDuplicatedCalls = async (e, { callLimit: t = ut } = {}) => {
1181
1202
  const s = async () => this.connectInner(e), i = (r) => {
1182
- const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = r != null && !Me(r);
1183
- return c || d;
1203
+ const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), h = r != null && !Le(r);
1204
+ return c || h;
1184
1205
  };
1185
- return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = J({
1206
+ return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ee({
1186
1207
  targetFunction: s,
1187
1208
  isComplete: i,
1188
1209
  callLimit: t,
@@ -1208,16 +1229,16 @@ class nt {
1208
1229
  sessionTimers: a,
1209
1230
  registerExpires: o,
1210
1231
  connectionRecoveryMinInterval: c,
1211
- connectionRecoveryMaxInterval: d,
1212
- userAgent: u,
1213
- displayName: T = "",
1214
- register: l = !1,
1215
- extraHeaders: S = []
1232
+ connectionRecoveryMaxInterval: h,
1233
+ userAgent: T,
1234
+ displayName: S = "",
1235
+ register: g = !1,
1236
+ extraHeaders: C = []
1216
1237
  }) => {
1217
1238
  this.stateMachine.startInitUa(), this.setConnectionConfiguration({
1218
1239
  sipServerUrl: s,
1219
- displayName: T,
1220
- register: l,
1240
+ displayName: S,
1241
+ register: g,
1221
1242
  user: e,
1222
1243
  password: t
1223
1244
  }), this.getUa() && await this.disconnect();
@@ -1227,15 +1248,15 @@ class nt {
1227
1248
  password: t,
1228
1249
  sipServerUrl: s,
1229
1250
  sipWebSocketServerURL: i,
1230
- displayName: T,
1231
- register: l,
1251
+ displayName: S,
1252
+ register: g,
1232
1253
  sessionTimers: a,
1233
1254
  registerExpires: o,
1234
1255
  connectionRecoveryMinInterval: c,
1235
- connectionRecoveryMaxInterval: d,
1236
- userAgent: u,
1256
+ connectionRecoveryMaxInterval: h,
1257
+ userAgent: T,
1237
1258
  remoteAddress: r,
1238
- extraHeaders: S
1259
+ extraHeaders: C
1239
1260
  },
1240
1261
  this.events
1241
1262
  );
@@ -1248,15 +1269,15 @@ class nt {
1248
1269
  return;
1249
1270
  }
1250
1271
  let i;
1251
- i = ((c, d) => {
1272
+ i = ((c, h) => {
1252
1273
  if (this.getConnectionConfiguration().register === !0)
1253
- return this.registrationManager.subscribeToStartEvents(c, d);
1254
- const T = A.CONNECTED, l = [A.DISCONNECTED];
1255
- return this.events.on(T, c), l.forEach((S) => {
1256
- this.events.on(S, d);
1274
+ return this.registrationManager.subscribeToStartEvents(c, h);
1275
+ const S = A.CONNECTED, g = [A.DISCONNECTED];
1276
+ return this.events.on(S, c), g.forEach((C) => {
1277
+ this.events.on(C, h);
1257
1278
  }), () => {
1258
- this.events.off(T, c), l.forEach((S) => {
1259
- this.events.off(S, d);
1279
+ this.events.off(S, c), g.forEach((C) => {
1280
+ this.events.off(C, h);
1260
1281
  });
1261
1282
  };
1262
1283
  })(() => {
@@ -1269,18 +1290,18 @@ class nt {
1269
1290
  this.cancelableConnectWithRepeatedCalls?.cancel();
1270
1291
  }
1271
1292
  }
1272
- var he = /* @__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))(he || {});
1273
- const st = Ae({
1293
+ var ue = /* @__PURE__ */ ((n) => (n.START_CONNECT = "START_CONNECT", n.START_INIT_UA = "START_INIT_UA", n.UA_CONNECTED = "UA_CONNECTED", n.UA_REGISTERED = "UA_REGISTERED", n.UA_UNREGISTERED = "UA_UNREGISTERED", n.UA_DISCONNECTED = "UA_DISCONNECTED", n.CONNECTION_FAILED = "CONNECTION_FAILED", n.RESET = "RESET", n))(ue || {});
1294
+ const St = De({
1274
1295
  types: {
1275
1296
  context: {},
1276
1297
  events: {}
1277
1298
  },
1278
1299
  actions: {
1279
1300
  logTransition: (n, e) => {
1280
- E(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1301
+ d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1281
1302
  },
1282
1303
  logStateChange: (n, e) => {
1283
- E("ConnectionStateMachine state changed", e.state);
1304
+ d("ConnectionStateMachine state changed", e.state);
1284
1305
  }
1285
1306
  }
1286
1307
  }).createMachine({
@@ -1584,14 +1605,14 @@ const st = Ae({
1584
1605
  }
1585
1606
  }
1586
1607
  });
1587
- class it {
1608
+ class Ct {
1588
1609
  actor;
1589
1610
  stateChangeListeners = /* @__PURE__ */ new Set();
1590
1611
  events;
1591
1612
  unsubscribeFromEvents;
1592
1613
  actorSubscription;
1593
1614
  constructor(e) {
1594
- this.events = e, this.actor = Re(st), this.actorSubscription = this.actor.subscribe((t) => {
1615
+ this.events = e, this.actor = ye(St), this.actorSubscription = this.actor.subscribe((t) => {
1595
1616
  const s = t.value;
1596
1617
  this.stateChangeListeners.forEach((i) => {
1597
1618
  i(s);
@@ -1677,7 +1698,7 @@ class it {
1677
1698
  return this.actor.getSnapshot().can({ type: e });
1678
1699
  }
1679
1700
  getValidEvents() {
1680
- return Object.values(he).filter((e) => this.canTransition(e));
1701
+ return Object.values(ue).filter((e) => this.canTransition(e));
1681
1702
  }
1682
1703
  hasState(e) {
1683
1704
  return this.actor.getSnapshot().matches(e);
@@ -1685,7 +1706,7 @@ class it {
1685
1706
  sendEvent(e) {
1686
1707
  const t = this.actor.getSnapshot(), s = { type: e };
1687
1708
  if (!t.can(s)) {
1688
- E(
1709
+ d(
1689
1710
  `Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
1690
1711
  );
1691
1712
  return;
@@ -1746,7 +1767,7 @@ class it {
1746
1767
  };
1747
1768
  }
1748
1769
  }
1749
- class rt {
1770
+ class Et {
1750
1771
  events;
1751
1772
  getUaProtected;
1752
1773
  constructor(e) {
@@ -1768,7 +1789,7 @@ class rt {
1768
1789
  try {
1769
1790
  await this.unregister();
1770
1791
  } catch (e) {
1771
- E("tryRegister", e);
1792
+ d("tryRegister", e);
1772
1793
  }
1773
1794
  return this.register();
1774
1795
  }
@@ -1783,7 +1804,7 @@ class rt {
1783
1804
  };
1784
1805
  }
1785
1806
  }
1786
- class at {
1807
+ class At {
1787
1808
  uaFactory;
1788
1809
  getUaProtected;
1789
1810
  constructor(e) {
@@ -1829,30 +1850,30 @@ class at {
1829
1850
  extraHeaders: a
1830
1851
  }) {
1831
1852
  return new Promise((o, c) => {
1832
- const { configuration: d } = this.uaFactory.createConfiguration({
1853
+ const { configuration: h } = this.uaFactory.createConfiguration({
1833
1854
  sipWebSocketServerURL: i,
1834
1855
  displayName: t,
1835
1856
  userAgent: e,
1836
1857
  sipServerUrl: s
1837
- }), u = this.uaFactory.createUA({ ...d, remoteAddress: r, extraHeaders: a }), T = () => {
1838
- const S = new Error("Telephony is not available");
1839
- c(S);
1858
+ }), T = this.uaFactory.createUA({ ...h, remoteAddress: r, extraHeaders: a }), S = () => {
1859
+ const C = new Error("Telephony is not available");
1860
+ c(C);
1840
1861
  };
1841
- u.once(A.DISCONNECTED, T);
1842
- const l = () => {
1843
- u.removeAllListeners(), u.once(A.DISCONNECTED, () => {
1862
+ T.once(A.DISCONNECTED, S);
1863
+ const g = () => {
1864
+ T.removeAllListeners(), T.once(A.DISCONNECTED, () => {
1844
1865
  o();
1845
- }), u.stop();
1866
+ }), T.stop();
1846
1867
  };
1847
- u.once(A.CONNECTED, l), u.start();
1868
+ T.once(A.CONNECTED, g), T.start();
1848
1869
  });
1849
1870
  }
1850
1871
  }
1851
- const ot = (n) => {
1872
+ const Nt = (n) => {
1852
1873
  const e = [];
1853
1874
  return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
1854
1875
  };
1855
- class O {
1876
+ class D {
1856
1877
  JsSIP;
1857
1878
  constructor(e) {
1858
1879
  this.JsSIP = e;
@@ -1877,10 +1898,10 @@ class O {
1877
1898
  throw new Error("user is required for authorized connection");
1878
1899
  }
1879
1900
  static resolveAuthorizationUser(e, t) {
1880
- return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${we()}`;
1901
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${xe()}`;
1881
1902
  }
1882
1903
  static buildExtraHeaders(e, t) {
1883
- const s = e !== void 0 && e !== "" ? ot(e) : [];
1904
+ const s = e !== void 0 && e !== "" ? Nt(e) : [];
1884
1905
  return t === void 0 ? s : [...s, ...t];
1885
1906
  }
1886
1907
  createConfiguration({
@@ -1893,40 +1914,40 @@ class O {
1893
1914
  sessionTimers: o = !1,
1894
1915
  registerExpires: c = 300,
1895
1916
  // 5 minutes in sec
1896
- connectionRecoveryMinInterval: d = 2,
1897
- connectionRecoveryMaxInterval: u = 6,
1898
- userAgent: T
1917
+ connectionRecoveryMinInterval: h = 2,
1918
+ connectionRecoveryMaxInterval: T = 6,
1919
+ userAgent: S
1899
1920
  }) {
1900
- O.validateConfiguration({
1921
+ D.validateConfiguration({
1901
1922
  register: a,
1902
1923
  password: t,
1903
1924
  user: e,
1904
1925
  sipServerUrl: r,
1905
1926
  sipWebSocketServerURL: s
1906
1927
  });
1907
- const l = O.resolveAuthorizationUser(a, e), S = ye(r), m = S(l), I = new this.JsSIP.WebSocketInterface(s);
1928
+ const g = D.resolveAuthorizationUser(a, e), C = We(r), m = C(g), I = new this.JsSIP.WebSocketInterface(s);
1908
1929
  return {
1909
1930
  configuration: {
1910
1931
  password: t,
1911
1932
  register: a,
1912
1933
  uri: m,
1913
- display_name: ne(i),
1914
- user_agent: T,
1934
+ display_name: re(i),
1935
+ user_agent: S,
1915
1936
  sdpSemantics: "unified-plan",
1916
1937
  sockets: [I],
1917
1938
  session_timers: o,
1918
1939
  register_expires: c,
1919
- connection_recovery_min_interval: d,
1920
- connection_recovery_max_interval: u
1940
+ connection_recovery_min_interval: h,
1941
+ connection_recovery_max_interval: T
1921
1942
  },
1922
1943
  helpers: {
1923
1944
  socket: I,
1924
- getSipServerUrl: S
1945
+ getSipServerUrl: C
1925
1946
  }
1926
1947
  };
1927
1948
  }
1928
1949
  createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
1929
- const i = new this.JsSIP.UA(s), r = O.buildExtraHeaders(e, t);
1950
+ const i = new this.JsSIP.UA(s), r = D.buildExtraHeaders(e, t);
1930
1951
  return r.length > 0 && i.registrator().setExtraHeaders(r), i;
1931
1952
  }
1932
1953
  /**
@@ -1939,12 +1960,13 @@ class O {
1939
1960
  extraHeaders: e.extraHeaders
1940
1961
  });
1941
1962
  return t.eachTriggers((a, o) => {
1942
- const c = ce.find((d) => d === o);
1963
+ const c = le.find((h) => h === o);
1943
1964
  c && r.on(c, a);
1944
1965
  }), { ua: r, helpers: i };
1945
1966
  }
1946
1967
  }
1947
- class ct {
1968
+ const Te = "Not ready for connection", Rt = (n) => n instanceof Error && n.message === Te, It = () => new Error(Te), pt = async (n) => typeof n == "function" ? n() : n;
1969
+ class mt {
1948
1970
  events;
1949
1971
  ua;
1950
1972
  socket;
@@ -1956,15 +1978,15 @@ class ct {
1956
1978
  configurationManager;
1957
1979
  JsSIP;
1958
1980
  constructor({ JsSIP: e }) {
1959
- this.JsSIP = e, this.events = new w(de), this.uaFactory = new O(e), this.registrationManager = new rt({
1981
+ this.JsSIP = e, this.events = new U(ge), this.uaFactory = new D(e), this.registrationManager = new Et({
1960
1982
  events: this.events,
1961
1983
  getUaProtected: this.getUaProtected
1962
- }), this.stateMachine = new it(this.events), this.configurationManager = new et({
1984
+ }), this.stateMachine = new Ct(this.events), this.configurationManager = new lt({
1963
1985
  getUa: this.getUa
1964
- }), this.sipOperations = new at({
1986
+ }), this.sipOperations = new At({
1965
1987
  uaFactory: this.uaFactory,
1966
1988
  getUaProtected: this.getUaProtected
1967
- }), this.connectionFlow = new nt({
1989
+ }), this.connectionFlow = new Tt({
1968
1990
  JsSIP: this.JsSIP,
1969
1991
  events: this.events,
1970
1992
  uaFactory: this.uaFactory,
@@ -1998,18 +2020,32 @@ class ct {
1998
2020
  get isPendingInitUa() {
1999
2021
  return this.stateMachine.isPendingInitUa;
2000
2022
  }
2023
+ get isIdle() {
2024
+ return this.stateMachine.isIdle;
2025
+ }
2026
+ get isDisconnected() {
2027
+ return this.stateMachine.isDisconnected;
2028
+ }
2029
+ get isFailed() {
2030
+ return this.stateMachine.isFailed;
2031
+ }
2001
2032
  get connectionState() {
2002
2033
  return this.stateMachine.state;
2003
2034
  }
2004
2035
  get isRegistered() {
2005
- return O.isRegisteredUA(this.ua);
2036
+ return D.isRegisteredUA(this.ua);
2006
2037
  }
2007
2038
  get isRegisterConfig() {
2008
2039
  return this.configurationManager.isRegister();
2009
2040
  }
2010
- connect = async (e, t) => this.connectionFlow.connect(e, t);
2041
+ connect = async (e, t) => this.disconnect().catch((s) => {
2042
+ d("connect: disconnect error", s);
2043
+ }).then(async () => this.connectWithProcessError(e, t));
2011
2044
  set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
2012
- disconnect = async () => this.connectionFlow.disconnect();
2045
+ disconnect = async () => {
2046
+ if (this.isConfigured())
2047
+ return this.connectionFlow.disconnect();
2048
+ };
2013
2049
  async register() {
2014
2050
  return this.registrationManager.register();
2015
2051
  }
@@ -2054,10 +2090,26 @@ class ct {
2054
2090
  return this.ua;
2055
2091
  };
2056
2092
  getUa = () => this.ua;
2093
+ connectWithProcessError = async (e, t) => {
2094
+ if (!(t?.hasReadyForConnection?.() ?? !0))
2095
+ throw It();
2096
+ return this.processConnect(e, t).catch(async (i) => {
2097
+ const r = i;
2098
+ return this.disconnect().then(() => {
2099
+ throw r;
2100
+ }).catch(() => {
2101
+ throw r;
2102
+ });
2103
+ });
2104
+ };
2105
+ processConnect = async (e, t) => (this.events.trigger(A.CONNECT_STARTED, {}), pt(e).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(A.CONNECT_SUCCEEDED, { ua: s }), s)).catch((s) => {
2106
+ const i = s ?? new Error("Failed to connect to server");
2107
+ throw this.events.trigger(A.CONNECT_FAILED, i), i;
2108
+ }));
2057
2109
  }
2058
- class dt {
2110
+ class _t {
2059
2111
  connectionManager;
2060
- stackPromises = K({
2112
+ stackPromises = te({
2061
2113
  noRunIsNotActual: !0
2062
2114
  });
2063
2115
  constructor({ connectionManager: e }) {
@@ -2065,27 +2117,318 @@ class dt {
2065
2117
  }
2066
2118
  connect = async (...e) => this.stackPromises.run(async () => this.connectionManager.connect(...e));
2067
2119
  disconnect = async () => this.stackPromises.run(async () => this.connectionManager.disconnect());
2068
- register = async () => this.stackPromises.run(async () => this.connectionManager.register());
2069
- unregister = async () => this.stackPromises.run(async () => this.connectionManager.unregister());
2070
- tryRegister = async () => this.stackPromises.run(async () => this.connectionManager.tryRegister());
2071
- checkTelephony = async (...e) => this.stackPromises.run(async () => this.connectionManager.checkTelephony(...e));
2072
- sendOptions = async (...e) => this.stackPromises.run(async () => this.connectionManager.sendOptions(...e));
2073
- ping = async (...e) => this.stackPromises.run(async () => this.connectionManager.ping(...e));
2074
- set = async (...e) => this.stackPromises.run(async () => this.connectionManager.set(...e));
2120
+ stop() {
2121
+ this.stackPromises.stop();
2122
+ }
2075
2123
  }
2076
- var b = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(b || {});
2077
- const le = [
2124
+ var O = /* @__PURE__ */ ((n) => (n.BEFORE_ATTEMPT = "before-attempt", n.SUCCEEDED_ATTEMPT = "succeeded-attempt", n.FAILED_ATTEMPT = "failed-attempt", n.CANCELLED_ATTEMPT = "cancelled-attempt", n.CHANGED_ATTEMPT_STATUS = "changed-attempt-status", n))(O || {});
2125
+ const Se = [
2126
+ "before-attempt",
2127
+ "succeeded-attempt",
2128
+ "failed-attempt",
2129
+ "cancelled-attempt",
2130
+ "changed-attempt-status"
2131
+ ], z = 0, Mt = 30;
2132
+ class vt {
2133
+ events;
2134
+ countInner = z;
2135
+ initialCount = z;
2136
+ limitInner = Mt;
2137
+ isInProgress = !1;
2138
+ constructor({ events: e }) {
2139
+ this.events = e;
2140
+ }
2141
+ get count() {
2142
+ return this.countInner;
2143
+ }
2144
+ get limit() {
2145
+ return this.limitInner;
2146
+ }
2147
+ get isAttemptInProgress() {
2148
+ return this.isInProgress;
2149
+ }
2150
+ hasLimitReached() {
2151
+ return this.countInner >= this.limitInner;
2152
+ }
2153
+ startAttempt() {
2154
+ this.isInProgress || (this.isInProgress = !0, this.emitStatusChange());
2155
+ }
2156
+ finishAttempt() {
2157
+ this.isInProgress && (this.isInProgress = !1, this.emitStatusChange());
2158
+ }
2159
+ increment() {
2160
+ this.count < this.limit && (this.countInner += 1);
2161
+ }
2162
+ reset() {
2163
+ this.countInner = this.initialCount, this.finishAttempt();
2164
+ }
2165
+ emitStatusChange() {
2166
+ this.events.trigger(O.CHANGED_ATTEMPT_STATUS, { isInProgress: this.isInProgress });
2167
+ }
2168
+ }
2169
+ class ft {
2170
+ connectionManager;
2171
+ interval;
2172
+ checkTelephonyByTimeout = void 0;
2173
+ cancelableBeforeRequest = void 0;
2174
+ constructor({
2175
+ connectionManager: e,
2176
+ interval: t
2177
+ }) {
2178
+ this.connectionManager = e, this.interval = t;
2179
+ }
2180
+ start({
2181
+ onBeforeRequest: e,
2182
+ onSuccessRequest: t,
2183
+ onFailRequest: s
2184
+ }) {
2185
+ this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = Me({
2186
+ isDontStopOnFail: !0,
2187
+ requestInterval: this.interval,
2188
+ request: async () => {
2189
+ if (!this.cancelableBeforeRequest)
2190
+ throw new Error("cancelableBeforeRequest is not defined");
2191
+ const i = await this.cancelableBeforeRequest.request();
2192
+ return this.connectionManager.checkTelephony(i);
2193
+ }
2194
+ }), this.checkTelephonyByTimeout.start(void 0, {
2195
+ onFailRequest: s,
2196
+ onSuccessRequest: () => {
2197
+ this.stop(), t();
2198
+ }
2199
+ });
2200
+ }
2201
+ stop() {
2202
+ this.checkTelephonyByTimeout?.stop(), this.checkTelephonyByTimeout = void 0, this.cancelableBeforeRequest?.cancelRequest(), this.cancelableBeforeRequest = void 0;
2203
+ }
2204
+ }
2205
+ const Pt = 15e3, Ot = 2;
2206
+ class Dt {
2207
+ connectionManager;
2208
+ pingServerByTimeoutWithFailCalls;
2209
+ constructor({ connectionManager: e }) {
2210
+ this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = ve(Ot, {
2211
+ whenPossibleRequest: async () => {
2212
+ },
2213
+ requestInterval: Pt,
2214
+ request: async () => (d("ping"), this.connectionManager.ping().then(() => {
2215
+ d("ping success");
2216
+ }))
2217
+ });
2218
+ }
2219
+ start({ onFailRequest: e }) {
2220
+ this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(d);
2221
+ }
2222
+ stop() {
2223
+ this.pingServerByTimeoutWithFailCalls.stop();
2224
+ }
2225
+ }
2226
+ class yt {
2227
+ callManager;
2228
+ pingServerRequester;
2229
+ disposeCallStatusChange;
2230
+ constructor({
2231
+ connectionManager: e,
2232
+ callManager: t
2233
+ }) {
2234
+ this.callManager = t, this.pingServerRequester = new Dt({
2235
+ connectionManager: e
2236
+ });
2237
+ }
2238
+ start({ onFailRequest: e }) {
2239
+ d("start"), this.disposeCallStatusChange = this.callManager.on("call-status-changed", () => {
2240
+ this.handleCallStatusChange({ onFailRequest: e });
2241
+ }), this.handleCallStatusChange({ onFailRequest: e });
2242
+ }
2243
+ stop() {
2244
+ d("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
2245
+ }
2246
+ unsubscribeCallStatusChange() {
2247
+ this.disposeCallStatusChange?.(), this.disposeCallStatusChange = void 0;
2248
+ }
2249
+ handleCallStatusChange({ onFailRequest: e }) {
2250
+ this.callManager.isCallActive ? this.pingServerRequester.stop() : this.pingServerRequester.start({ onFailRequest: e });
2251
+ }
2252
+ }
2253
+ class bt {
2254
+ connectionManager;
2255
+ callManager;
2256
+ isRegistrationFailed = !1;
2257
+ disposers = [];
2258
+ constructor({
2259
+ connectionManager: e,
2260
+ callManager: t
2261
+ }) {
2262
+ this.connectionManager = e, this.callManager = t;
2263
+ }
2264
+ subscribe(e) {
2265
+ this.unsubscribe(), this.disposers.push(
2266
+ this.connectionManager.on("registrationFailed", () => {
2267
+ this.setIsRegistrationFailed();
2268
+ })
2269
+ ), this.disposers.push(
2270
+ this.callManager.on("call-status-changed", ({ isCallActive: t }) => {
2271
+ !t && this.isRegistrationFailed && e();
2272
+ })
2273
+ );
2274
+ }
2275
+ unsubscribe() {
2276
+ this.disposers.forEach((e) => {
2277
+ e();
2278
+ }), this.disposers = [], this.resetIsRegistrationFailed();
2279
+ }
2280
+ setIsRegistrationFailed() {
2281
+ this.isRegistrationFailed = !0;
2282
+ }
2283
+ resetIsRegistrationFailed() {
2284
+ this.isRegistrationFailed = !1;
2285
+ }
2286
+ }
2287
+ const Ce = "Parameters are missing", wt = (n) => n instanceof Error && n.message === Ce, Qn = () => new Error(Ce), Ut = 3e3, Lt = 15e3, Bt = async () => {
2288
+ };
2289
+ class Ft {
2290
+ events;
2291
+ connectionManager;
2292
+ connectionQueueManager;
2293
+ checkTelephonyRequester;
2294
+ pingServerIfNotActiveCallRequester;
2295
+ registrationFailedOutOfCallSubscriber;
2296
+ attemptsState;
2297
+ delayBetweenAttempts;
2298
+ cancelableRequestBeforeRetry;
2299
+ onBeforeRetry;
2300
+ constructor({
2301
+ connectionQueueManager: e,
2302
+ connectionManager: t,
2303
+ callManager: s
2304
+ }, i) {
2305
+ const r = i?.onBeforeRetry ?? Bt;
2306
+ this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.events = new k(Se), this.checkTelephonyRequester = new ft({
2307
+ connectionManager: t,
2308
+ interval: i?.checkTelephonyRequestInterval ?? Lt
2309
+ }), this.pingServerIfNotActiveCallRequester = new yt({
2310
+ connectionManager: t,
2311
+ callManager: s
2312
+ }), this.registrationFailedOutOfCallSubscriber = new bt({
2313
+ connectionManager: t,
2314
+ callManager: s
2315
+ }), this.attemptsState = new vt({
2316
+ events: this.events
2317
+ }), this.cancelableRequestBeforeRetry = new G(r), this.delayBetweenAttempts = new fe(
2318
+ i?.timeoutBetweenAttempts ?? Ut
2319
+ );
2320
+ }
2321
+ start(e) {
2322
+ d("auto connector start"), this.stop(), this.connect(e).catch((t) => {
2323
+ d("auto connector failed to connect:", t);
2324
+ });
2325
+ }
2326
+ stop() {
2327
+ d("auto connector stop"), this.stopAttempts(), this.stopConnectTriggers(), this.connectionQueueManager.disconnect().catch((e) => {
2328
+ d("auto connector disconnect: error", e);
2329
+ });
2330
+ }
2331
+ on(e, t) {
2332
+ return this.events.on(e, t);
2333
+ }
2334
+ once(e, t) {
2335
+ return this.events.once(e, t);
2336
+ }
2337
+ onceRace(e, t) {
2338
+ return this.events.onceRace(e, t);
2339
+ }
2340
+ async wait(e) {
2341
+ return this.events.wait(e);
2342
+ }
2343
+ off(e, t) {
2344
+ this.events.off(e, t);
2345
+ }
2346
+ stopAttempts() {
2347
+ this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
2348
+ }
2349
+ stopConnectTriggers() {
2350
+ d("stopConnectTriggers"), this.pingServerIfNotActiveCallRequester.stop(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
2351
+ }
2352
+ runCheckTelephony(e) {
2353
+ d("runCheckTelephony"), this.checkTelephonyRequester.start({
2354
+ onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
2355
+ onSuccessRequest: () => {
2356
+ d("runCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
2357
+ },
2358
+ onFailRequest: (t) => {
2359
+ d("runCheckTelephony: onFailRequest", t.message);
2360
+ }
2361
+ });
2362
+ }
2363
+ async connect(e) {
2364
+ if (d("connect: attempts.count", this.attemptsState.count), this.events.trigger(O.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
2365
+ d("connect: isLimitReached!"), this.handleLimitReached(e);
2366
+ return;
2367
+ }
2368
+ return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.processConnect(e);
2369
+ }
2370
+ async processConnect(e) {
2371
+ try {
2372
+ await this.connectionQueueManager.connect(e.getParameters, e.options), d("processConnect success"), this.handleSucceededAttempt(e);
2373
+ } catch (t) {
2374
+ if (Rt(t)) {
2375
+ this.handleSucceededAttempt(e);
2376
+ return;
2377
+ }
2378
+ if (wt(t)) {
2379
+ d("processConnect: parameters not exist error", t);
2380
+ return;
2381
+ }
2382
+ if (be(t)) {
2383
+ d("processConnect: not actual error", t), this.events.trigger(O.CANCELLED_ATTEMPT, t);
2384
+ return;
2385
+ }
2386
+ d("processConnect: error", t), this.reconnect(e);
2387
+ }
2388
+ }
2389
+ handleLimitReached(e) {
2390
+ this.attemptsState.finishAttempt(), this.events.trigger(O.FAILED_ATTEMPT, new Error("Limit reached")), this.runCheckTelephony(e);
2391
+ }
2392
+ handleSucceededAttempt(e) {
2393
+ d("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(O.SUCCEEDED_ATTEMPT, {});
2394
+ }
2395
+ subscribeToConnectTriggers(e) {
2396
+ this.pingServerIfNotActiveCallRequester.start({
2397
+ onFailRequest: () => {
2398
+ d("pingServer onFailRequest"), this.start(e);
2399
+ }
2400
+ }), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
2401
+ d("registrationFailedOutOfCallListener callback"), this.start(e);
2402
+ });
2403
+ }
2404
+ connectIfDisconnected(e) {
2405
+ const t = this.hasFailedOrDisconnectedConnection();
2406
+ d("connectIfDisconnected: isFailedOrDisconnected", t), t ? this.start(e) : (this.stopConnectTriggers(), this.events.trigger(O.SUCCEEDED_ATTEMPT, {}));
2407
+ }
2408
+ reconnect(e) {
2409
+ d("reconnect"), this.delayBetweenAttempts.request().then(async () => (d("reconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (d("reconnect: onBeforeRetry success"), this.connect(e))).catch((t) => {
2410
+ const s = t instanceof Error ? t : new Error("Failed to reconnect");
2411
+ _e(t) || Pe(t) ? this.events.trigger(O.CANCELLED_ATTEMPT, s) : this.events.trigger(O.FAILED_ATTEMPT, s), d("reconnect: error", t);
2412
+ });
2413
+ }
2414
+ hasFailedOrDisconnectedConnection() {
2415
+ const { isFailed: e, isDisconnected: t, isIdle: s } = this.connectionManager;
2416
+ return e || t || s;
2417
+ }
2418
+ }
2419
+ var w = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(w || {});
2420
+ const Ee = [
2078
2421
  "incomingCall",
2079
2422
  "declinedIncomingCall",
2080
2423
  "terminatedIncomingCall",
2081
2424
  "failedIncomingCall"
2082
- ], ht = 486, lt = 487;
2083
- class gt {
2425
+ ], kt = 486, $t = 487;
2426
+ class Vt {
2084
2427
  events;
2085
2428
  incomingRTCSession;
2086
2429
  connectionManager;
2087
2430
  constructor(e) {
2088
- this.connectionManager = e, this.events = new w(le), this.start();
2431
+ this.connectionManager = e, this.events = new U(Ee), this.start();
2089
2432
  }
2090
2433
  get remoteCallerData() {
2091
2434
  return {
@@ -2115,19 +2458,19 @@ class gt {
2115
2458
  return this.removeIncomingSession(), e;
2116
2459
  };
2117
2460
  async declineToIncomingCall({
2118
- statusCode: e = lt
2461
+ statusCode: e = $t
2119
2462
  } = {}) {
2120
2463
  return new Promise((t, s) => {
2121
2464
  try {
2122
2465
  const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
2123
- this.removeIncomingSession(), this.events.trigger(b.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
2466
+ this.removeIncomingSession(), this.events.trigger(w.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
2124
2467
  } catch (i) {
2125
2468
  s(i);
2126
2469
  }
2127
2470
  });
2128
2471
  }
2129
2472
  async busyIncomingCall() {
2130
- return this.declineToIncomingCall({ statusCode: ht });
2473
+ return this.declineToIncomingCall({ statusCode: kt });
2131
2474
  }
2132
2475
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
2133
2476
  on(e, t) {
@@ -2164,19 +2507,19 @@ class gt {
2164
2507
  this.incomingRTCSession = e;
2165
2508
  const t = this.remoteCallerData;
2166
2509
  e.on("failed", (s) => {
2167
- this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(b.TERMINATED_INCOMING_CALL, t) : this.events.trigger(b.FAILED_INCOMING_CALL, t);
2168
- }), this.events.trigger(b.INCOMING_CALL, t);
2510
+ this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(w.TERMINATED_INCOMING_CALL, t) : this.events.trigger(w.FAILED_INCOMING_CALL, t);
2511
+ }), this.events.trigger(w.INCOMING_CALL, t);
2169
2512
  }
2170
2513
  removeIncomingSession() {
2171
2514
  delete this.incomingRTCSession;
2172
2515
  }
2173
2516
  }
2174
- const y = 1e3;
2175
- 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 || {});
2176
- const ge = ["collected"], Q = () => "performance" in window ? performance.now() : Date.now(), U = (n) => [...n.keys()].reduce((e, t) => {
2517
+ const b = 1e3;
2518
+ var E = /* @__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))(E || {});
2519
+ const Ae = ["collected"], X = () => "performance" in window ? performance.now() : Date.now(), L = (n) => [...n.keys()].reduce((e, t) => {
2177
2520
  const s = n.get(t);
2178
2521
  return s === void 0 ? e : { ...e, [s.type]: s };
2179
- }, {}), ut = (n) => {
2522
+ }, {}), qt = (n) => {
2180
2523
  if (!n)
2181
2524
  return {
2182
2525
  outboundRtp: void 0,
@@ -2184,14 +2527,14 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
2184
2527
  mediaSource: void 0,
2185
2528
  remoteInboundRtp: void 0
2186
2529
  };
2187
- const e = U(n);
2530
+ const e = L(n);
2188
2531
  return {
2189
- outboundRtp: e[C.OUTBOUND_RTP],
2190
- codec: e[C.CODEC],
2191
- mediaSource: e[C.MEDIA_SOURCE],
2192
- remoteInboundRtp: e[C.REMOTE_INBOUND_RTP]
2532
+ outboundRtp: e[E.OUTBOUND_RTP],
2533
+ codec: e[E.CODEC],
2534
+ mediaSource: e[E.MEDIA_SOURCE],
2535
+ remoteInboundRtp: e[E.REMOTE_INBOUND_RTP]
2193
2536
  };
2194
- }, Y = (n) => {
2537
+ }, J = (n) => {
2195
2538
  if (!n)
2196
2539
  return {
2197
2540
  outboundRtp: void 0,
@@ -2199,14 +2542,14 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
2199
2542
  mediaSource: void 0,
2200
2543
  remoteInboundRtp: void 0
2201
2544
  };
2202
- const e = U(n);
2545
+ const e = L(n);
2203
2546
  return {
2204
- outboundRtp: e[C.OUTBOUND_RTP],
2205
- codec: e[C.CODEC],
2206
- mediaSource: e[C.MEDIA_SOURCE],
2207
- remoteInboundRtp: e[C.REMOTE_INBOUND_RTP]
2547
+ outboundRtp: e[E.OUTBOUND_RTP],
2548
+ codec: e[E.CODEC],
2549
+ mediaSource: e[E.MEDIA_SOURCE],
2550
+ remoteInboundRtp: e[E.REMOTE_INBOUND_RTP]
2208
2551
  };
2209
- }, z = ({
2552
+ }, K = ({
2210
2553
  videoReceiversStats: n,
2211
2554
  synchronizationSourcesVideo: e
2212
2555
  }) => {
@@ -2216,13 +2559,13 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
2216
2559
  codec: void 0,
2217
2560
  synchronizationSources: e
2218
2561
  };
2219
- const t = U(n);
2562
+ const t = L(n);
2220
2563
  return {
2221
- inboundRtp: t[C.INBOUND_RTP],
2222
- codec: t[C.CODEC],
2564
+ inboundRtp: t[E.INBOUND_RTP],
2565
+ codec: t[E.CODEC],
2223
2566
  synchronizationSources: e
2224
2567
  };
2225
- }, Tt = ({
2568
+ }, Wt = ({
2226
2569
  audioReceiverStats: n,
2227
2570
  synchronizationSourcesAudio: e
2228
2571
  }) => {
@@ -2233,14 +2576,14 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
2233
2576
  remoteOutboundRtp: void 0,
2234
2577
  synchronizationSources: e
2235
2578
  };
2236
- const t = U(n);
2579
+ const t = L(n);
2237
2580
  return {
2238
- inboundRtp: t[C.INBOUND_RTP],
2239
- codec: t[C.CODEC],
2240
- remoteOutboundRtp: t[C.REMOTE_OUTBOUND_RTP],
2581
+ inboundRtp: t[E.INBOUND_RTP],
2582
+ codec: t[E.CODEC],
2583
+ remoteOutboundRtp: t[E.REMOTE_OUTBOUND_RTP],
2241
2584
  synchronizationSources: e
2242
2585
  };
2243
- }, ue = (n) => {
2586
+ }, Ne = (n) => {
2244
2587
  if (!n)
2245
2588
  return {
2246
2589
  candidatePair: void 0,
@@ -2249,47 +2592,47 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
2249
2592
  remoteCandidate: void 0,
2250
2593
  transport: void 0
2251
2594
  };
2252
- const e = U(n);
2595
+ const e = L(n);
2253
2596
  return {
2254
- candidatePair: e[C.CANDIDATE_PAIR],
2255
- certificate: e[C.CERTIFICATE],
2256
- localCandidate: e[C.LOCAL_CANDIDATE],
2257
- remoteCandidate: e[C.REMOTE_CANDIDATE],
2258
- transport: e[C.TRANSPORT]
2597
+ candidatePair: e[E.CANDIDATE_PAIR],
2598
+ certificate: e[E.CERTIFICATE],
2599
+ localCandidate: e[E.LOCAL_CANDIDATE],
2600
+ remoteCandidate: e[E.REMOTE_CANDIDATE],
2601
+ transport: e[E.TRANSPORT]
2259
2602
  };
2260
- }, St = ({
2603
+ }, Ht = ({
2261
2604
  audioSenderStats: n,
2262
2605
  videoSenderFirstStats: e,
2263
2606
  videoSenderSecondStats: t
2264
2607
  }) => ({
2265
- video: Y(e),
2266
- secondVideo: Y(t),
2267
- audio: ut(n),
2268
- additional: ue(
2608
+ video: J(e),
2609
+ secondVideo: J(t),
2610
+ audio: qt(n),
2611
+ additional: Ne(
2269
2612
  n ?? e ?? t
2270
2613
  )
2271
- }), Ct = ({
2614
+ }), xt = ({
2272
2615
  audioReceiverStats: n,
2273
2616
  videoReceiverFirstStats: e,
2274
2617
  videoReceiverSecondStats: t,
2275
2618
  synchronizationSources: s
2276
2619
  }) => ({
2277
- video: z({
2620
+ video: K({
2278
2621
  videoReceiversStats: e,
2279
2622
  synchronizationSourcesVideo: s.video
2280
2623
  }),
2281
- secondVideo: z({
2624
+ secondVideo: K({
2282
2625
  videoReceiversStats: t,
2283
2626
  synchronizationSourcesVideo: s.video
2284
2627
  }),
2285
- audio: Tt({
2628
+ audio: Wt({
2286
2629
  audioReceiverStats: n,
2287
2630
  synchronizationSourcesAudio: s.audio
2288
2631
  }),
2289
- additional: ue(
2632
+ additional: Ne(
2290
2633
  n ?? e ?? t
2291
2634
  )
2292
- }), Et = ({
2635
+ }), Gt = ({
2293
2636
  audioSenderStats: n,
2294
2637
  videoSenderFirstStats: e,
2295
2638
  videoSenderSecondStats: t,
@@ -2298,11 +2641,11 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
2298
2641
  videoReceiverSecondStats: r,
2299
2642
  synchronizationSources: a
2300
2643
  }) => {
2301
- const o = St({
2644
+ const o = Ht({
2302
2645
  audioSenderStats: n,
2303
2646
  videoSenderFirstStats: e,
2304
2647
  videoSenderSecondStats: t
2305
- }), c = Ct({
2648
+ }), c = xt({
2306
2649
  audioReceiverStats: s,
2307
2650
  videoReceiverFirstStats: i,
2308
2651
  videoReceiverSecondStats: r,
@@ -2312,16 +2655,16 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
2312
2655
  outbound: o,
2313
2656
  inbound: c
2314
2657
  };
2315
- }, Nt = async (n) => {
2316
- const e = "audio", t = "video", s = n.getSenders(), i = s.find((l) => l.track?.kind === e), r = s.filter((l) => l.track?.kind === t), a = n.getReceivers(), o = a.find((l) => l.track.kind === e), c = a.filter((l) => l.track.kind === t), d = {
2658
+ }, Qt = async (n) => {
2659
+ const e = "audio", t = "video", s = n.getSenders(), i = s.find((g) => g.track?.kind === e), r = s.filter((g) => g.track?.kind === t), a = n.getReceivers(), o = a.find((g) => g.track.kind === e), c = a.filter((g) => g.track.kind === t), h = {
2317
2660
  trackIdentifier: o?.track.id,
2318
2661
  item: o?.getSynchronizationSources()[0]
2319
- }, u = {
2662
+ }, T = {
2320
2663
  trackIdentifier: c[0]?.track.id,
2321
2664
  item: c[0]?.getSynchronizationSources()[0]
2322
- }, T = {
2323
- audio: d,
2324
- video: u
2665
+ }, S = {
2666
+ audio: h,
2667
+ video: T
2325
2668
  };
2326
2669
  return Promise.all([
2327
2670
  i?.getStats() ?? Promise.resolve(void 0),
@@ -2330,41 +2673,41 @@ const ge = ["collected"], Q = () => "performance" in window ? performance.now()
2330
2673
  o?.getStats() ?? Promise.resolve(void 0),
2331
2674
  c[0]?.getStats() ?? Promise.resolve(void 0),
2332
2675
  c[1]?.getStats() ?? Promise.resolve(void 0)
2333
- ]).then((l) => {
2676
+ ]).then((g) => {
2334
2677
  const [
2335
- S,
2678
+ C,
2336
2679
  m,
2337
2680
  I,
2338
2681
  R,
2339
- D,
2340
- k
2341
- ] = l;
2682
+ y,
2683
+ $
2684
+ ] = g;
2342
2685
  return {
2343
- synchronizationSources: T,
2344
- audioSenderStats: S,
2686
+ synchronizationSources: S,
2687
+ audioSenderStats: C,
2345
2688
  videoSenderFirstStats: m,
2346
2689
  videoSenderSecondStats: I,
2347
2690
  audioReceiverStats: R,
2348
- videoReceiverFirstStats: D,
2349
- videoReceiverSecondStats: k
2691
+ videoReceiverFirstStats: y,
2692
+ videoReceiverSecondStats: $
2350
2693
  };
2351
2694
  });
2352
- }, At = (n) => {
2353
- E(String(n));
2695
+ }, Yt = (n) => {
2696
+ d(String(n));
2354
2697
  };
2355
- class Rt {
2698
+ class zt {
2356
2699
  events;
2357
2700
  setTimeoutRequest;
2358
- requesterAllStatistics = new Ie(Nt);
2701
+ requesterAllStatistics = new G(Qt);
2359
2702
  constructor() {
2360
- this.events = new H(ge), this.setTimeoutRequest = new j();
2703
+ this.events = new k(Ae), this.setTimeoutRequest = new Z();
2361
2704
  }
2362
2705
  get requested() {
2363
2706
  return this.setTimeoutRequest.requested;
2364
2707
  }
2365
2708
  start(e, {
2366
- interval: t = y,
2367
- onError: s = At
2709
+ interval: t = b,
2710
+ onError: s = Yt
2368
2711
  } = {}) {
2369
2712
  this.stop(), this.setTimeoutRequest.request(() => {
2370
2713
  this.collectStatistics(e, {
@@ -2393,12 +2736,12 @@ class Rt {
2393
2736
  collectStatistics = (e, {
2394
2737
  onError: t
2395
2738
  }) => {
2396
- const s = Q();
2739
+ const s = X();
2397
2740
  this.requesterAllStatistics.request(e).then((i) => {
2398
- this.events.trigger("collected", Et(i));
2399
- const a = Q() - s;
2400
- let o = y;
2401
- a > 48 ? o = y * 4 : a > 32 ? o = y * 3 : a > 16 && (o = y * 2), this.start(e, {
2741
+ this.events.trigger("collected", Gt(i));
2742
+ const a = X() - s;
2743
+ let o = b;
2744
+ a > 48 ? o = b * 4 : a > 32 ? o = b * 3 : a > 16 && (o = b * 2), this.start(e, {
2402
2745
  onError: t,
2403
2746
  interval: o
2404
2747
  });
@@ -2407,7 +2750,7 @@ class Rt {
2407
2750
  });
2408
2751
  };
2409
2752
  }
2410
- class It {
2753
+ class Xt {
2411
2754
  availableIncomingBitrate;
2412
2755
  statsPeerConnection;
2413
2756
  callManager;
@@ -2417,7 +2760,7 @@ class It {
2417
2760
  callManager: e,
2418
2761
  apiManager: t
2419
2762
  }) {
2420
- this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Rt(), this.subscribe();
2763
+ this.callManager = e, this.apiManager = t, this.statsPeerConnection = new zt(), this.subscribe();
2421
2764
  }
2422
2765
  get events() {
2423
2766
  return this.statsPeerConnection.events;
@@ -2455,30 +2798,30 @@ class It {
2455
2798
  };
2456
2799
  maybeSendStats() {
2457
2800
  this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
2458
- E("Failed to send stats", e);
2801
+ d("Failed to send stats", e);
2459
2802
  });
2460
2803
  }
2461
2804
  }
2462
- const _t = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), mt = (n) => {
2805
+ const Jt = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), Kt = (n) => {
2463
2806
  const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
2464
- return _t(s, i);
2465
- }, Mt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
2807
+ return Jt(s, i);
2808
+ }, jt = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
2466
2809
  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;
2467
2810
  return a - o;
2468
- }), pt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Pt = (n, {
2811
+ }), Zt = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), en = (n, {
2469
2812
  preferredMimeTypesVideoCodecs: e,
2470
2813
  excludeMimeTypesVideoCodecs: t
2471
2814
  }) => {
2472
2815
  try {
2473
2816
  if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
2474
- const s = mt("video"), i = pt(s, t), r = Mt(i, e);
2817
+ const s = Kt("video"), i = Zt(s, t), r = jt(i, e);
2475
2818
  n.setCodecPreferences(r);
2476
2819
  }
2477
2820
  } catch (s) {
2478
- E("setCodecPreferences error", s);
2821
+ d("setCodecPreferences error", s);
2479
2822
  }
2480
2823
  };
2481
- class vt {
2824
+ class tn {
2482
2825
  /**
2483
2826
  * Хранилище основных transceiver'ов
2484
2827
  */
@@ -2557,10 +2900,10 @@ class vt {
2557
2900
  */
2558
2901
  handleRestart = (e) => {
2559
2902
  this.updateTransceivers(e).catch((t) => {
2560
- E("Failed to update transceivers", t);
2903
+ d("Failed to update transceivers", t);
2561
2904
  }).finally(() => {
2562
2905
  this.callManager.restartIce().catch((t) => {
2563
- E("Failed to restart ICE", t);
2906
+ d("Failed to restart ICE", t);
2564
2907
  });
2565
2908
  });
2566
2909
  };
@@ -2572,7 +2915,7 @@ class vt {
2572
2915
  t === 2 && (this.getTransceivers().presentationVideo !== void 0 || await this.callManager.addTransceiver("video", {
2573
2916
  direction: "recvonly"
2574
2917
  }).catch((r) => {
2575
- E("Failed to add presentation video transceiver", r);
2918
+ d("Failed to add presentation video transceiver", r);
2576
2919
  }));
2577
2920
  };
2578
2921
  subscribe() {
@@ -2585,15 +2928,15 @@ class vt {
2585
2928
  this.clear();
2586
2929
  };
2587
2930
  }
2588
- const ft = (n) => [...n.keys()].map((e) => n.get(e)), Ot = (n, e) => ft(n).find((t) => t?.type === e), Dt = async (n) => n.getStats().then((e) => Ot(e, "codec")?.mimeType);
2589
- class yt {
2931
+ const nn = (n) => [...n.keys()].map((e) => n.get(e)), sn = (n, e) => nn(n).find((t) => t?.type === e), rn = async (n) => n.getStats().then((e) => sn(e, "codec")?.mimeType);
2932
+ class an {
2590
2933
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
2591
2934
  async getCodecFromSender(e) {
2592
- return await Dt(e) ?? "";
2935
+ return await rn(e) ?? "";
2593
2936
  }
2594
2937
  }
2595
- class bt {
2596
- stackPromises = K({
2938
+ class on {
2939
+ stackPromises = te({
2597
2940
  noRunIsNotActual: !0
2598
2941
  });
2599
2942
  /**
@@ -2613,34 +2956,34 @@ class bt {
2613
2956
  */
2614
2957
  async run() {
2615
2958
  return this.stackPromises().catch((e) => {
2616
- E("TaskQueue: error", e);
2959
+ d("TaskQueue: error", e);
2617
2960
  });
2618
2961
  }
2619
2962
  }
2620
- class wt {
2963
+ class cn {
2621
2964
  taskQueue;
2622
2965
  onSetParameters;
2623
2966
  constructor(e) {
2624
- this.onSetParameters = e, this.taskQueue = new bt();
2967
+ this.onSetParameters = e, this.taskQueue = new on();
2625
2968
  }
2626
2969
  async setEncodingsToSender(e, t) {
2627
- return this.taskQueue.add(async () => ae(e, t, this.onSetParameters));
2970
+ return this.taskQueue.add(async () => de(e, t, this.onSetParameters));
2628
2971
  }
2629
2972
  stop() {
2630
2973
  this.taskQueue.stop();
2631
2974
  }
2632
2975
  }
2633
- const Te = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Ut = 1e6, p = (n) => n * Ut, Se = p(0.06), Ce = p(4), Lt = (n) => n <= 64 ? Se : n <= 128 ? p(0.12) : n <= 256 ? p(0.25) : n <= 384 ? p(0.32) : n <= 426 ? p(0.38) : n <= 640 ? p(0.5) : n <= 848 ? p(0.7) : n <= 1280 ? p(1) : n <= 1920 ? p(2) : Ce, Bt = "av1", kt = (n) => Te(n, Bt), Ft = 0.6, G = (n, e) => kt(e) ? n * Ft : n, $t = (n) => G(Se, n), Vt = (n) => G(Ce, n), X = (n, e) => {
2634
- const t = Lt(n);
2635
- return G(t, e);
2636
- }, F = 1, Wt = ({
2976
+ const Re = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), dn = 1e6, M = (n) => n * dn, Ie = M(0.06), pe = M(4), hn = (n) => n <= 64 ? Ie : 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) : pe, ln = "av1", gn = (n) => Re(n, ln), un = 0.6, Y = (n, e) => gn(e) ? n * un : n, Tn = (n) => Y(Ie, n), Sn = (n) => Y(pe, n), j = (n, e) => {
2977
+ const t = hn(n);
2978
+ return Y(t, e);
2979
+ }, V = 1, Cn = ({
2637
2980
  videoTrack: n,
2638
2981
  targetSize: e
2639
2982
  }) => {
2640
- const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? F : s / e.width, a = i === void 0 ? F : i / e.height;
2641
- return Math.max(r, a, F);
2983
+ const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? V : s / e.width, a = i === void 0 ? V : i / e.height;
2984
+ return Math.max(r, a, V);
2642
2985
  };
2643
- class Ht {
2986
+ class En {
2644
2987
  ignoreForCodec;
2645
2988
  senderFinder;
2646
2989
  codecProvider;
@@ -2673,7 +3016,7 @@ class Ht {
2673
3016
  if (!i?.track)
2674
3017
  return { ...this.resultNoChanged, sender: i };
2675
3018
  const r = await this.codecProvider.getCodecFromSender(i);
2676
- if (Te(r, this.ignoreForCodec))
3019
+ if (Re(r, this.ignoreForCodec))
2677
3020
  return { ...this.resultNoChanged, sender: i };
2678
3021
  const { mainCam: a, resolutionMainCam: o } = t ?? {};
2679
3022
  return this.processSender(
@@ -2693,14 +3036,14 @@ class Ht {
2693
3036
  async processSender(e, t) {
2694
3037
  const { mainCam: s, resolutionMainCam: i } = e;
2695
3038
  switch (s) {
2696
- case P.PAUSE_MAIN_CAM:
3039
+ case v.PAUSE_MAIN_CAM:
2697
3040
  return this.downgradeResolutionSender(t);
2698
- case P.RESUME_MAIN_CAM:
3041
+ case v.RESUME_MAIN_CAM:
2699
3042
  return this.setBitrateByTrackResolution(t);
2700
- case P.MAX_MAIN_CAM_RESOLUTION:
3043
+ case v.MAX_MAIN_CAM_RESOLUTION:
2701
3044
  return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
2702
- case P.ADMIN_STOP_MAIN_CAM:
2703
- case P.ADMIN_START_MAIN_CAM:
3045
+ case v.ADMIN_STOP_MAIN_CAM:
3046
+ case v.ADMIN_START_MAIN_CAM:
2704
3047
  case void 0:
2705
3048
  return this.setBitrateByTrackResolution(t);
2706
3049
  default:
@@ -2715,7 +3058,7 @@ class Ht {
2715
3058
  async downgradeResolutionSender(e) {
2716
3059
  const { sender: t, codec: s } = e, i = {
2717
3060
  scaleResolutionDownBy: 200,
2718
- maxBitrate: $t(s)
3061
+ maxBitrate: Tn(s)
2719
3062
  };
2720
3063
  return this.parametersSetter.setEncodingsToSender(t, i);
2721
3064
  }
@@ -2725,7 +3068,7 @@ class Ht {
2725
3068
  * @returns Promise с результатом
2726
3069
  */
2727
3070
  async setBitrateByTrackResolution(e) {
2728
- const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? Vt(i) : X(a, i);
3071
+ const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? Sn(i) : j(a, i);
2729
3072
  return this.parametersSetter.setEncodingsToSender(t, {
2730
3073
  scaleResolutionDownBy: 1,
2731
3074
  maxBitrate: o
@@ -2741,24 +3084,24 @@ class Ht {
2741
3084
  const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
2742
3085
  width: Number(s),
2743
3086
  height: Number(i)
2744
- }, d = Wt({
3087
+ }, h = Cn({
2745
3088
  videoTrack: a,
2746
3089
  targetSize: c
2747
- }), u = X(c.width, o), T = {
2748
- scaleResolutionDownBy: d,
2749
- maxBitrate: u
3090
+ }), T = j(c.width, o), S = {
3091
+ scaleResolutionDownBy: h,
3092
+ maxBitrate: T
2750
3093
  };
2751
- return this.parametersSetter.setEncodingsToSender(r, T);
3094
+ return this.parametersSetter.setEncodingsToSender(r, S);
2752
3095
  }
2753
3096
  }
2754
- const xt = (n) => n.find((e) => e.track?.kind === "video");
2755
- class qt {
3097
+ const An = (n) => n.find((e) => e.track?.kind === "video");
3098
+ class Nn {
2756
3099
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
2757
3100
  findVideoSender(e) {
2758
- return xt(e);
3101
+ return An(e);
2759
3102
  }
2760
3103
  }
2761
- class Gt {
3104
+ class Rn {
2762
3105
  currentSender;
2763
3106
  originalReplaceTrack;
2764
3107
  lastWidth;
@@ -2771,7 +3114,7 @@ class Gt {
2771
3114
  pollIntervalMs: e = 1e3,
2772
3115
  maxPollIntervalMs: t
2773
3116
  }) {
2774
- this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new j();
3117
+ this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new Z();
2775
3118
  }
2776
3119
  /**
2777
3120
  * Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
@@ -2822,7 +3165,7 @@ class Gt {
2822
3165
  this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
2823
3166
  }
2824
3167
  }
2825
- class Qt {
3168
+ class In {
2826
3169
  apiManager;
2827
3170
  currentHandler;
2828
3171
  constructor(e) {
@@ -2842,7 +3185,7 @@ class Qt {
2842
3185
  this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
2843
3186
  }
2844
3187
  }
2845
- class Yt {
3188
+ class pn {
2846
3189
  eventHandler;
2847
3190
  senderBalancer;
2848
3191
  parametersSetterWithQueue;
@@ -2854,16 +3197,16 @@ class Yt {
2854
3197
  onSetParameters: i,
2855
3198
  pollIntervalMs: r
2856
3199
  } = {}) {
2857
- this.getConnection = t, this.eventHandler = new Qt(e), this.parametersSetterWithQueue = new wt(i), this.senderBalancer = new Ht(
3200
+ this.getConnection = t, this.eventHandler = new In(e), this.parametersSetterWithQueue = new cn(i), this.senderBalancer = new En(
2858
3201
  {
2859
- senderFinder: new qt(),
2860
- codecProvider: new yt(),
3202
+ senderFinder: new Nn(),
3203
+ codecProvider: new an(),
2861
3204
  parametersSetter: this.parametersSetterWithQueue
2862
3205
  },
2863
3206
  {
2864
3207
  ignoreForCodec: s
2865
3208
  }
2866
- ), this.trackMonitor = new Gt({ pollIntervalMs: r });
3209
+ ), this.trackMonitor = new Rn({ pollIntervalMs: r });
2867
3210
  }
2868
3211
  /**
2869
3212
  * Подписывается на события управления главной камерой
@@ -2894,7 +3237,7 @@ class Yt {
2894
3237
  const t = await this.senderBalancer.balance(e, this.serverHeaders);
2895
3238
  return this.trackMonitor.subscribe(t.sender, () => {
2896
3239
  this.balance().catch((s) => {
2897
- E("balance on track change: error", s);
3240
+ d("balance on track change: error", s);
2898
3241
  });
2899
3242
  }), t;
2900
3243
  }
@@ -2904,17 +3247,17 @@ class Yt {
2904
3247
  */
2905
3248
  handleMainCamControl = (e) => {
2906
3249
  this.serverHeaders = e, this.balance().catch((t) => {
2907
- E("handleMainCamControl: error", t);
3250
+ d("handleMainCamControl: error", t);
2908
3251
  });
2909
3252
  };
2910
3253
  }
2911
- const Ee = [
3254
+ const me = [
2912
3255
  "balancing-scheduled",
2913
3256
  "balancing-started",
2914
3257
  "balancing-stopped",
2915
3258
  "parameters-updated"
2916
3259
  ];
2917
- class zt {
3260
+ class mn {
2918
3261
  isBalancingActive = !1;
2919
3262
  events;
2920
3263
  callManager;
@@ -2922,7 +3265,7 @@ class zt {
2922
3265
  videoSendingBalancer;
2923
3266
  startBalancingTimer;
2924
3267
  constructor(e, t, s = {}) {
2925
- this.events = new H(Ee), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new Yt(
3268
+ this.events = new k(me), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new pn(
2926
3269
  t,
2927
3270
  () => e.connection,
2928
3271
  {
@@ -2984,7 +3327,7 @@ class zt {
2984
3327
  scheduleBalancingStart() {
2985
3328
  this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
2986
3329
  this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
2987
- E("startBalancing: error", e);
3330
+ d("startBalancing: error", e);
2988
3331
  });
2989
3332
  }, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
2990
3333
  }
@@ -2992,20 +3335,22 @@ class zt {
2992
3335
  this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
2993
3336
  }
2994
3337
  }
2995
- const Xt = 1e6, Jt = de.map((n) => `connection:${n}`), Kt = te.map((n) => `call:${n}`), jt = Z.map((n) => `api:${n}`), Zt = le.map((n) => `incoming-call:${n}`), en = oe.map((n) => `presentation:${n}`), tn = ge.map((n) => `stats:${n}`), nn = Ee.map((n) => `video-balancer:${n}`), sn = [
2996
- ...Jt,
2997
- ...Kt,
2998
- ...jt,
2999
- ...Zt,
3000
- ...en,
3001
- ...tn,
3002
- ...nn
3338
+ const _n = 1e6, Mn = Se.map((n) => `auto-connect:${n}`), vn = ge.map((n) => `connection:${n}`), fn = ie.map((n) => `call:${n}`), Pn = ne.map((n) => `api:${n}`), On = Ee.map((n) => `incoming-call:${n}`), Dn = he.map((n) => `presentation:${n}`), yn = Ae.map((n) => `stats:${n}`), bn = me.map((n) => `video-balancer:${n}`), wn = [
3339
+ ...Mn,
3340
+ ...vn,
3341
+ ...fn,
3342
+ ...Pn,
3343
+ ...On,
3344
+ ...Dn,
3345
+ ...yn,
3346
+ ...bn
3003
3347
  ];
3004
- class En {
3348
+ class Yn {
3005
3349
  events;
3006
3350
  connectionManager;
3007
3351
  connectionQueueManager;
3008
3352
  callManager;
3353
+ autoConnectorManager;
3009
3354
  apiManager;
3010
3355
  incomingCallManager;
3011
3356
  presentationManager;
@@ -3017,23 +3362,31 @@ class En {
3017
3362
  constructor({ JsSIP: e }, {
3018
3363
  preferredMimeTypesVideoCodecs: t,
3019
3364
  excludeMimeTypesVideoCodecs: s,
3020
- videoBalancerOptions: i
3365
+ videoBalancerOptions: i,
3366
+ autoConnectorOptions: r
3021
3367
  } = {}) {
3022
- this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new w(sn), this.connectionManager = new ct({ JsSIP: e }), this.connectionQueueManager = new dt({
3368
+ this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = new U(wn), this.connectionManager = new mt({ JsSIP: e }), this.connectionQueueManager = new _t({
3023
3369
  connectionManager: this.connectionManager
3024
- }), this.callManager = new Fe(), this.apiManager = new ve({
3370
+ }), this.callManager = new Xe(), this.apiManager = new ke({
3025
3371
  connectionManager: this.connectionManager,
3026
3372
  callManager: this.callManager
3027
- }), this.incomingCallManager = new gt(this.connectionManager), this.presentationManager = new Ze({
3373
+ }), this.incomingCallManager = new Vt(this.connectionManager), this.presentationManager = new ht({
3028
3374
  callManager: this.callManager,
3029
- maxBitrate: Xt
3030
- }), this.statsManager = new It({
3375
+ maxBitrate: _n
3376
+ }), this.statsManager = new Xt({
3031
3377
  callManager: this.callManager,
3032
3378
  apiManager: this.apiManager
3033
- }), this.transceiverManager = new vt({
3379
+ }), this.autoConnectorManager = new Ft(
3380
+ {
3381
+ connectionQueueManager: this.connectionQueueManager,
3382
+ connectionManager: this.connectionManager,
3383
+ callManager: this.callManager
3384
+ },
3385
+ r
3386
+ ), this.transceiverManager = new tn({
3034
3387
  callManager: this.callManager,
3035
3388
  apiManager: this.apiManager
3036
- }), this.videoSendingBalancerManager = new zt(
3389
+ }), this.videoSendingBalancerManager = new mn(
3037
3390
  this.callManager,
3038
3391
  this.apiManager,
3039
3392
  i
@@ -3098,17 +3451,23 @@ class En {
3098
3451
  this.events.off(e, t);
3099
3452
  }
3100
3453
  connect = async (...e) => this.connectionQueueManager.connect(...e);
3101
- set = async (...e) => this.connectionQueueManager.set(...e);
3102
3454
  disconnect = async () => this.connectionQueueManager.disconnect();
3103
- register = async () => this.connectionQueueManager.register();
3104
- unregister = async () => this.connectionQueueManager.unregister();
3105
- tryRegister = async () => this.connectionQueueManager.tryRegister();
3106
- sendOptions = async (e, t, s) => this.connectionQueueManager.sendOptions(e, t, s);
3107
- ping = async (e, t) => this.connectionQueueManager.ping(e, t);
3108
- checkTelephony = async (e) => this.connectionQueueManager.checkTelephony(e);
3455
+ register = async () => this.connectionManager.register();
3456
+ unregister = async () => this.connectionManager.unregister();
3457
+ tryRegister = async () => this.connectionManager.tryRegister();
3458
+ set = async (...e) => this.connectionManager.set(...e);
3459
+ sendOptions = async (e, t, s) => this.connectionManager.sendOptions(e, t, s);
3460
+ ping = async (e, t) => this.connectionManager.ping(e, t);
3461
+ checkTelephony = async (e) => this.connectionManager.checkTelephony(e);
3109
3462
  isConfigured = () => this.connectionManager.isConfigured();
3110
3463
  getConnectionConfiguration = () => this.connectionManager.getConnectionConfiguration();
3111
3464
  getSipServerUrl = (e) => this.connectionManager.getSipServerUrl(e);
3465
+ startAutoConnect = (...e) => {
3466
+ this.autoConnectorManager.start(...e);
3467
+ };
3468
+ stopAutoConnect = () => {
3469
+ this.autoConnectorManager.stop();
3470
+ };
3112
3471
  call = async (e) => {
3113
3472
  const { onAddedTransceiver: t, ...s } = e;
3114
3473
  return this.callManager.startCall(
@@ -3212,13 +3571,13 @@ class En {
3212
3571
  return this.apiManager.askPermissionToEnableCam(...e);
3213
3572
  }
3214
3573
  setCodecPreferences(e) {
3215
- Pt(e, {
3574
+ en(e, {
3216
3575
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
3217
3576
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
3218
3577
  });
3219
3578
  }
3220
3579
  subscribe() {
3221
- this.bridgeEvents("connection", this.connectionManager), this.bridgeEvents("call", this.callManager), this.bridgeEvents("api", this.apiManager), this.bridgeEvents("incoming-call", this.incomingCallManager), this.bridgeEvents("presentation", this.presentationManager), this.bridgeEvents("stats", this.statsManager), this.bridgeEvents("video-balancer", this.videoSendingBalancerManager);
3580
+ this.bridgeEvents("auto-connect", this.autoConnectorManager), this.bridgeEvents("connection", this.connectionManager), this.bridgeEvents("call", this.callManager), this.bridgeEvents("api", this.apiManager), this.bridgeEvents("incoming-call", this.incomingCallManager), this.bridgeEvents("presentation", this.presentationManager), this.bridgeEvents("stats", this.statsManager), this.bridgeEvents("video-balancer", this.videoSendingBalancerManager);
3222
3581
  }
3223
3582
  bridgeEvents = (e, t) => {
3224
3583
  t.events.eachTriggers((s, i) => {
@@ -3232,18 +3591,21 @@ class En {
3232
3591
  };
3233
3592
  }
3234
3593
  export {
3235
- se as E,
3236
- fe as O,
3237
- En as S,
3238
- Xe as a,
3239
- Pe as b,
3240
- C as c,
3241
- Sn as d,
3242
- Tn as e,
3243
- Rt as f,
3244
- Dt as g,
3245
- Cn as h,
3246
- E as l,
3247
- B as p,
3248
- ae as s
3594
+ ae as E,
3595
+ $e as O,
3596
+ Yn as S,
3597
+ at as a,
3598
+ Fe as b,
3599
+ Gn as c,
3600
+ xn as d,
3601
+ Hn as e,
3602
+ E as f,
3603
+ zt as g,
3604
+ Rt as h,
3605
+ rn as i,
3606
+ Qn as j,
3607
+ d as l,
3608
+ F as p,
3609
+ pt as r,
3610
+ de as s
3249
3611
  };