sip-connector 20.3.0 → 20.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
- import z from "debug";
2
- import { TypedEvents as O } from "events-constructor";
3
- import { CancelableRequest as G, isCanceledError as we } from "@krivega/cancelable-promise";
4
- import { resolveRequesterByTimeout as Ue, requesterByTimeoutsWithFailCalls as Fe, DelayRequester as Be, hasCanceledError as ke, SetTimeoutRequest as oe } from "@krivega/timeout-requester";
5
- import { hasCanceledError as Ge, repeatedCallsAsync as ce } from "repeated-calls";
6
- import { createActor as $e, setup as $, assign as b } from "xstate";
7
- import { createStackPromises as le, isPromiseIsNotActualError as qe } from "stack-promises";
1
+ import X from "debug";
2
+ import { TypedEvents as M } from "events-constructor";
3
+ import { CancelableRequest as G, isCanceledError as Ue } from "@krivega/cancelable-promise";
4
+ import { resolveRequesterByTimeout as Fe, requesterByTimeoutsWithFailCalls as Be, DelayRequester as ke, hasCanceledError as Ge, SetTimeoutRequest as ce } from "@krivega/timeout-requester";
5
+ import { hasCanceledError as $e, repeatedCallsAsync as de } from "repeated-calls";
6
+ import { createActor as qe, setup as $, assign as b } from "xstate";
7
+ import { createStackPromises as le, isPromiseIsNotActualError as Ve } from "stack-promises";
8
8
  import "ua-parser-js";
9
9
  import "sequent-promises";
10
- import Ve from "lodash";
11
- const X = "sip-connector", l = z(X), Ds = () => {
12
- z.enable(X);
13
- }, ys = () => {
14
- z.enable(`-${X}`);
15
- }, He = "Error decline with 603", We = 1006, xe = (n) => typeof n == "object" && n !== null && "code" in n && n.code === We, Qe = (n) => n.message === He;
16
- var E = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n.AUDIO_ID = "X-WEBRTC-AUDIOID", n))(E || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), x = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(x || {}), y = /* @__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))(y || {}), I = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(I || {}), v = /* @__PURE__ */ ((n) => (n.PAUSE_MAIN_CAM = "PAUSEMAINCAM", n.RESUME_MAIN_CAM = "RESUMEMAINCAM", n.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", n.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", n.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", n))(v || {}), Q = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(Q || {}), Y = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(Y || {}), Ye = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Ye || {}), g = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n))(g || {});
17
- const de = [
10
+ import He from "lodash";
11
+ const J = "sip-connector", d = X(J), Us = () => {
12
+ X.enable(J);
13
+ }, Fs = () => {
14
+ X.enable(`-${J}`);
15
+ }, We = "Error decline with 603", xe = 1006, Qe = (n) => typeof n == "object" && n !== null && "code" in n && n.code === xe, Ye = (n) => n.message === We;
16
+ var E = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n.AUDIO_TRACK_COUNT = "X-WEBRTC-AUDIO-TRACK-COUNT", n.VIDEO_TRACK_COUNT = "X-WEBRTC-VIDEO-TRACK-COUNT", n.TRACKS_DIRECTION = "X-WEBRTC-TRACKS-DIRECTION", n.AUDIO_ID = "X-WEBRTC-AUDIOID", n))(E || {}), B = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(B || {}), x = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(x || {}), y = /* @__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))(y || {}), I = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(I || {}), _ = /* @__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))(_ || {}), Q = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(Q || {}), Y = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(Y || {}), ze = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(ze || {}), g = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n))(g || {});
17
+ const he = [
18
18
  "participation:accepting-word-request",
19
19
  "participation:cancelling-word-request",
20
20
  "participant:move-request-to-stream",
@@ -44,9 +44,9 @@ const de = [
44
44
  "notAvailableSecondRemoteStream",
45
45
  "mustStopPresentation",
46
46
  "newDTMF"
47
- ], ze = () => new O(de);
47
+ ], Xe = () => new M(he);
48
48
  var R = /* @__PURE__ */ ((n) => (n.CHANNELS = "channels", n.WEBCAST_STARTED = "WebcastStarted", n.WEBCAST_STOPPED = "WebcastStopped", n.ACCOUNT_CHANGED = "accountChanged", n.ACCOUNT_DELETED = "accountDeleted", n.ADDED_TO_LIST_MODERATORS = "addedToListModerators", n.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", n.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", n.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", n.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", n))(R || {});
49
- class Xe {
49
+ class Je {
50
50
  events;
51
51
  connectionManager;
52
52
  callManager;
@@ -54,7 +54,7 @@ class Xe {
54
54
  connectionManager: e,
55
55
  callManager: t
56
56
  }) {
57
- this.connectionManager = e, this.callManager = t, this.events = ze(), this.subscribe();
57
+ this.connectionManager = e, this.callManager = t, this.events = Xe(), this.subscribe();
58
58
  }
59
59
  async waitChannels() {
60
60
  return this.wait(g.CHANNELS);
@@ -79,17 +79,17 @@ class Xe {
79
79
  });
80
80
  }
81
81
  async sendChannels({ inputChannels: e, outputChannels: t }) {
82
- const s = this.getEstablishedRTCSessionProtected(), i = `${E.INPUT_CHANNELS}: ${e}`, r = `${E.OUTPUT_CHANNELS}: ${t}`, o = [
82
+ const s = this.getEstablishedRTCSessionProtected(), i = `${E.INPUT_CHANNELS}: ${e}`, r = `${E.OUTPUT_CHANNELS}: ${t}`, a = [
83
83
  i,
84
84
  r
85
85
  ];
86
- return s.sendInfo(I.CHANNELS, void 0, { extraHeaders: o });
86
+ return s.sendInfo(I.CHANNELS, void 0, { extraHeaders: a });
87
87
  }
88
88
  async sendMediaState({ cam: e, mic: t }, s = {}) {
89
- const i = this.getEstablishedRTCSessionProtected(), r = `${E.MEDIA_STATE}: currentstate`, o = `${E.MAIN_CAM_STATE}: ${Number(e)}`, a = `${E.MIC_STATE}: ${Number(t)}`, c = [
89
+ const i = this.getEstablishedRTCSessionProtected(), r = `${E.MEDIA_STATE}: currentstate`, a = `${E.MAIN_CAM_STATE}: ${Number(e)}`, o = `${E.MIC_STATE}: ${Number(t)}`, c = [
90
90
  r,
91
- o,
92
- a
91
+ a,
92
+ o
93
93
  ];
94
94
  return i.sendInfo(I.MEDIA_STATE, void 0, {
95
95
  noTerminateWhenError: !0,
@@ -107,7 +107,7 @@ class Xe {
107
107
  });
108
108
  }
109
109
  async sendRefusalToTurnOn(e, t = {}) {
110
- const s = this.getEstablishedRTCSessionProtected(), o = e === "mic" ? 0 : 1, c = [`${E.MEDIA_TYPE}: ${o}`];
110
+ const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${E.MEDIA_TYPE}: ${a}`];
111
111
  return s.sendInfo(I.REFUSAL, void 0, {
112
112
  noTerminateWhenError: !0,
113
113
  ...t,
@@ -152,7 +152,7 @@ class Xe {
152
152
  ...e,
153
153
  extraHeaders: s
154
154
  }).catch((i) => {
155
- if (Qe(i))
155
+ if (Ye(i))
156
156
  throw i;
157
157
  });
158
158
  }
@@ -193,7 +193,7 @@ class Xe {
193
193
  this.handleNotify(s);
194
194
  }
195
195
  } catch (t) {
196
- l("error parse notify", t);
196
+ d("error parse notify", t);
197
197
  }
198
198
  };
199
199
  handleNotify = (e) => {
@@ -252,7 +252,7 @@ class Xe {
252
252
  break;
253
253
  }
254
254
  default:
255
- l("unknown cmd", e);
255
+ d("unknown cmd", e);
256
256
  }
257
257
  };
258
258
  handleNewInfo = (e) => {
@@ -425,15 +425,15 @@ class Xe {
425
425
  };
426
426
  triggerMainCamControl = (e) => {
427
427
  const t = e.getHeader(E.MAIN_CAM), s = e.getHeader(E.MEDIA_SYNC), i = s === Y.ADMIN_SYNC_FORCED;
428
- if (t === v.ADMIN_START_MAIN_CAM) {
428
+ if (t === _.ADMIN_START_MAIN_CAM) {
429
429
  this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
430
430
  return;
431
431
  }
432
- if (t === v.ADMIN_STOP_MAIN_CAM) {
432
+ if (t === _.ADMIN_STOP_MAIN_CAM) {
433
433
  this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
434
434
  return;
435
435
  }
436
- (t === v.RESUME_MAIN_CAM || t === v.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
436
+ (t === _.RESUME_MAIN_CAM || t === _.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
437
437
  const r = e.getHeader(E.MAIN_CAM_RESOLUTION);
438
438
  this.events.trigger(g.MAIN_CAM_CONTROL, {
439
439
  mainCam: t,
@@ -453,7 +453,7 @@ class q {
453
453
  actor;
454
454
  subscriptions = [];
455
455
  constructor(e) {
456
- this.actor = $e(e), this.actor.start();
456
+ this.actor = qe(e), this.actor.start();
457
457
  }
458
458
  get actorRef() {
459
459
  return this.actor;
@@ -483,8 +483,8 @@ class q {
483
483
  return this.subscriptions.push(t), t;
484
484
  }
485
485
  }
486
- var Je = /* @__PURE__ */ ((n) => (n.IDLE = "call:idle", n.CONNECTING = "call:connecting", n.RINGING = "call:ringing", n.ACCEPTED = "call:accepted", n.IN_CALL = "call:inCall", n.ENDED = "call:ended", n.FAILED = "call:failed", n))(Je || {});
487
- const Ke = $({
486
+ var Ke = /* @__PURE__ */ ((n) => (n.IDLE = "call:idle", n.CONNECTING = "call:connecting", n.RINGING = "call:ringing", n.ACCEPTED = "call:accepted", n.IN_CALL = "call:inCall", n.ENDED = "call:ended", n.FAILED = "call:failed", n))(Ke || {});
487
+ const je = $({
488
488
  types: {
489
489
  context: {},
490
490
  events: {}
@@ -584,9 +584,9 @@ const Ke = $({
584
584
  }
585
585
  }
586
586
  });
587
- class je extends q {
587
+ class Ze extends q {
588
588
  constructor(e) {
589
- super(Ke), this.subscribeToEvents(e);
589
+ super(je), this.subscribeToEvents(e);
590
590
  }
591
591
  get isIdle() {
592
592
  return this.state === "call:idle";
@@ -658,8 +658,8 @@ class je extends q {
658
658
  );
659
659
  }
660
660
  }
661
- var C = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n.CALL_STATUS_CHANGED = "call-status-changed", n.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n))(C || {}), Ze = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(Ze || {});
662
- const he = [
661
+ var C = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n.CALL_STATUS_CHANGED = "call-status-changed", n.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n))(C || {}), et = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(et || {});
662
+ const ge = [
663
663
  "peerconnection",
664
664
  "connecting",
665
665
  "sending",
@@ -686,16 +686,16 @@ const he = [
686
686
  "peerconnection:createanswerfailed",
687
687
  "peerconnection:setlocaldescriptionfailed",
688
688
  "peerconnection:setremotedescriptionfailed"
689
- ], et = [
689
+ ], tt = [
690
690
  "peerconnection:confirmed",
691
691
  "peerconnection:ontrack",
692
692
  "ended:fromserver",
693
693
  "call-status-changed",
694
694
  "remote-streams-changed"
695
- ], ge = [
696
- ...he,
697
- ...et
698
- ], tt = () => new O(ge), nt = (n, e) => {
695
+ ], ue = [
696
+ ...ge,
697
+ ...tt
698
+ ], nt = () => new M(ue), st = (n, e) => {
699
699
  n.getVideoTracks().forEach((s) => {
700
700
  "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
701
701
  });
@@ -706,11 +706,11 @@ const he = [
706
706
  } = {}) => {
707
707
  if (!n || e === "recvonly" && t === "recvonly")
708
708
  return;
709
- const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), o = [...i, ...r], a = new MediaStream(o);
710
- return a.getTracks = () => [...a.getAudioTracks(), ...a.getVideoTracks()], s && s !== "none" && nt(a, s), a;
709
+ const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
710
+ return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && st(o, s), o;
711
711
  };
712
- var ue = /* @__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))(ue || {});
713
- class st {
712
+ var Te = /* @__PURE__ */ ((n) => (n.BYE = "Terminated", n.WEBRTC_ERROR = "WebRTC Error", n.CANCELED = "Canceled", n.REQUEST_TIMEOUT = "Request Timeout", n.REJECTED = "Rejected", n.REDIRECTED = "Redirected", n.UNAVAILABLE = "Unavailable", n.NOT_FOUND = "Not Found", n.ADDRESS_INCOMPLETE = "Address Incomplete", n.INCOMPATIBLE_SDP = "Incompatible SDP", n.BAD_MEDIA_DESCRIPTION = "Bad Media Description", n))(Te || {});
713
+ class it {
714
714
  events;
715
715
  rtcSession;
716
716
  disposers = /* @__PURE__ */ new Set();
@@ -734,10 +734,10 @@ class st {
734
734
  number: s,
735
735
  mediaStream: i,
736
736
  extraHeaders: r = [],
737
- iceServers: o,
738
- directionVideo: a,
737
+ iceServers: a,
738
+ directionVideo: o,
739
739
  directionAudio: c,
740
- contentHint: d,
740
+ contentHint: l,
741
741
  offerToReceiveAudio: T = !0,
742
742
  offerToReceiveVideo: h = !0,
743
743
  degradationPreference: u,
@@ -748,12 +748,12 @@ class st {
748
748
  D(V);
749
749
  }), this.rtcSession = e.call(t(s), {
750
750
  mediaStream: k(i, {
751
- directionVideo: a,
751
+ directionVideo: o,
752
752
  directionAudio: c,
753
- contentHint: d
753
+ contentHint: l
754
754
  }),
755
755
  pcConfig: {
756
- iceServers: o
756
+ iceServers: a
757
757
  },
758
758
  rtcOfferConstraints: {
759
759
  offerToReceiveAudio: T,
@@ -764,7 +764,7 @@ class st {
764
764
  // и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
765
765
  eventHandlers: this.events.triggers,
766
766
  extraHeaders: r,
767
- directionVideo: a,
767
+ directionVideo: o,
768
768
  directionAudio: c,
769
769
  degradationPreference: u,
770
770
  sendEncodings: p,
@@ -775,7 +775,7 @@ class st {
775
775
  const { rtcSession: e } = this;
776
776
  if (e && !e.isEnded())
777
777
  return e.terminateAsync({
778
- cause: ue.CANCELED
778
+ cause: Te.CANCELED
779
779
  }).finally(() => {
780
780
  this.reset();
781
781
  });
@@ -786,10 +786,10 @@ class st {
786
786
  extraHeaders: s = [],
787
787
  iceServers: i,
788
788
  directionVideo: r,
789
- directionAudio: o,
790
- offerToReceiveAudio: a,
789
+ directionAudio: a,
790
+ offerToReceiveAudio: o,
791
791
  offerToReceiveVideo: c,
792
- contentHint: d,
792
+ contentHint: l,
793
793
  degradationPreference: T,
794
794
  sendEncodings: h,
795
795
  onAddedTransceiver: u
@@ -802,17 +802,17 @@ class st {
802
802
  iceServers: i
803
803
  },
804
804
  rtcOfferConstraints: {
805
- offerToReceiveAudio: a,
805
+ offerToReceiveAudio: o,
806
806
  offerToReceiveVideo: c
807
807
  },
808
808
  mediaStream: k(t, {
809
809
  directionVideo: r,
810
- directionAudio: o,
811
- contentHint: d
810
+ directionAudio: a,
811
+ contentHint: l
812
812
  }),
813
813
  extraHeaders: s,
814
814
  directionVideo: r,
815
- directionAudio: o,
815
+ directionAudio: a,
816
816
  degradationPreference: T,
817
817
  sendEncodings: h,
818
818
  onAddedTransceiver: u
@@ -836,18 +836,18 @@ class st {
836
836
  }
837
837
  handleCall = async () => new Promise((e, t) => {
838
838
  const s = () => {
839
- this.events.on(C.PEER_CONNECTION, d), this.events.on(C.CONFIRMED, T);
839
+ this.events.on(C.PEER_CONNECTION, l), this.events.on(C.CONFIRMED, T);
840
840
  }, i = () => {
841
- this.events.off(C.PEER_CONNECTION, d), this.events.off(C.CONFIRMED, T);
841
+ this.events.off(C.PEER_CONNECTION, l), this.events.off(C.CONFIRMED, T);
842
842
  }, r = () => {
843
- this.events.on(C.FAILED, a), this.events.on(C.ENDED, a);
844
- }, o = () => {
845
- this.events.off(C.FAILED, a), this.events.off(C.ENDED, a);
846
- }, a = (h) => {
847
- i(), o(), t(h);
843
+ this.events.on(C.FAILED, o), this.events.on(C.ENDED, o);
844
+ }, a = () => {
845
+ this.events.off(C.FAILED, o), this.events.off(C.ENDED, o);
846
+ }, o = (h) => {
847
+ i(), a(), t(h);
848
848
  };
849
849
  let c;
850
- const d = ({ peerconnection: h }) => {
850
+ const l = ({ peerconnection: h }) => {
851
851
  c = h;
852
852
  const u = (p) => {
853
853
  this.events.trigger(C.PEER_CONNECTION_ONTRACK, p);
@@ -856,13 +856,13 @@ class st {
856
856
  h.removeEventListener("track", u);
857
857
  });
858
858
  }, T = () => {
859
- c !== void 0 && this.events.trigger(C.PEER_CONNECTION_CONFIRMED, c), i(), o(), e(c);
859
+ c !== void 0 && this.events.trigger(C.PEER_CONNECTION_CONFIRMED, c), i(), a(), e(c);
860
860
  };
861
861
  s(), r();
862
862
  });
863
863
  subscribeToSessionEvents(e) {
864
864
  this.events.eachTriggers((t, s) => {
865
- const i = he.find((r) => r === s);
865
+ const i = ge.find((r) => r === s);
866
866
  i && (e.on(i, t), this.disposers.add(() => {
867
867
  e.off(i, t);
868
868
  }));
@@ -881,7 +881,7 @@ class st {
881
881
  delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.onReset();
882
882
  };
883
883
  }
884
- class it {
884
+ class rt {
885
885
  config;
886
886
  tools;
887
887
  connection;
@@ -930,18 +930,18 @@ class it {
930
930
  return this.connection.addTransceiver(e, t);
931
931
  }
932
932
  }
933
- const Te = (n) => n.getSettings(), rt = (n, e) => {
934
- const t = Te(n);
933
+ const Ee = (n) => n.getSettings(), at = (n, e) => {
934
+ const t = Ee(n);
935
935
  let s = e;
936
936
  s ??= n.label;
937
937
  let i = t?.msid;
938
938
  return i ??= s, i ??= n.id, i;
939
- }, at = (n, e) => {
940
- const t = Te(n);
939
+ }, ot = (n, e) => {
940
+ const t = Ee(n);
941
941
  let s = e;
942
942
  return s ??= t?.msid, s ??= n.label, (s && s.length > 0 ? s : void 0) ?? n.id;
943
943
  };
944
- class j {
944
+ class Z {
945
945
  participantGroups = /* @__PURE__ */ new Map();
946
946
  trackToGroup = /* @__PURE__ */ new Map();
947
947
  trackDisposers = /* @__PURE__ */ new Map();
@@ -958,17 +958,17 @@ class j {
958
958
  onRemoved: t,
959
959
  streamHint: s
960
960
  } = {}) {
961
- const i = at(e, s), r = rt(e, s);
961
+ const i = ot(e, s), r = at(e, s);
962
962
  if (this.trackToGroup.has(e.id))
963
963
  return { isAdded: !1 };
964
- const o = this.getParticipantGroups(i);
965
- let a = o.get(r);
966
- a || (a = {
964
+ const a = this.getParticipantGroups(i);
965
+ let o = a.get(r);
966
+ o || (o = {
967
967
  participantId: i,
968
968
  groupId: r,
969
969
  stream: new MediaStream(),
970
970
  trackIds: /* @__PURE__ */ new Set()
971
- }, o.set(r, a)), a.stream.addTrack(e), a.trackIds.add(e.id), this.trackToGroup.set(e.id, { participantId: i, groupId: r });
971
+ }, a.set(r, o)), o.stream.addTrack(e), o.trackIds.add(e.id), this.trackToGroup.set(e.id, { participantId: i, groupId: r });
972
972
  const c = () => {
973
973
  this.disposeTrackListener(e.id), this.removeTrack(e.id) && t?.({ trackId: e.id, participantId: i });
974
974
  };
@@ -981,21 +981,21 @@ class j {
981
981
  const t = this.trackToGroup.get(e);
982
982
  if (!t)
983
983
  return !1;
984
- const { participantId: s, groupId: i } = t, r = this.participantGroups.get(s), o = r?.get(i);
985
- if (!o)
984
+ const { participantId: s, groupId: i } = t, r = this.participantGroups.get(s), a = r?.get(i);
985
+ if (!a)
986
986
  return this.trackToGroup.delete(e), !1;
987
- const a = o.stream.getTracks().find((c) => c.id === e);
988
- return a && o.stream.removeTrack(a), o.trackIds.delete(e), this.trackToGroup.delete(e), o.trackIds.size === 0 && (r?.delete(i), r?.size === 0 && this.participantGroups.delete(s)), !0;
987
+ const o = a.stream.getTracks().find((c) => c.id === e);
988
+ return o && a.stream.removeTrack(o), a.trackIds.delete(e), this.trackToGroup.delete(e), a.trackIds.size === 0 && (r?.delete(i), r?.size === 0 && this.participantGroups.delete(s)), !0;
989
989
  }
990
990
  removeStaleTracks(e, t) {
991
991
  const s = this.participantGroups.get(e);
992
992
  if (!s)
993
993
  return !1;
994
994
  let i = !1;
995
- return [...s.values()].forEach((o) => {
996
- [...o.trackIds].filter((c) => !t.includes(c)).forEach((c) => {
997
- const d = this.removeTrack(c);
998
- i ||= d;
995
+ return [...s.values()].forEach((a) => {
996
+ [...a.trackIds].filter((c) => !t.includes(c)).forEach((c) => {
997
+ const l = this.removeTrack(c);
998
+ i ||= l;
999
999
  });
1000
1000
  }), i;
1001
1001
  }
@@ -1020,13 +1020,13 @@ class j {
1020
1020
  }
1021
1021
  const H = {
1022
1022
  type: "participant"
1023
- }, ot = {
1023
+ }, ct = {
1024
1024
  type: "spectator_synthetic"
1025
- }, ct = (n) => ({
1025
+ }, dt = (n) => ({
1026
1026
  type: "spectator",
1027
1027
  recvParams: n
1028
1028
  });
1029
- class _ {
1029
+ class O {
1030
1030
  role = H;
1031
1031
  mainManager;
1032
1032
  recvManager;
@@ -1053,10 +1053,10 @@ class _ {
1053
1053
  this.changeRole(H);
1054
1054
  }
1055
1055
  setCallRoleSpectatorSynthetic() {
1056
- this.changeRole(ot);
1056
+ this.changeRole(ct);
1057
1057
  }
1058
1058
  setCallRoleSpectator(e) {
1059
- this.changeRole(ct(e));
1059
+ this.changeRole(dt(e));
1060
1060
  }
1061
1061
  changeRole(e) {
1062
1062
  const t = this.role;
@@ -1064,7 +1064,7 @@ class _ {
1064
1064
  this.setRole(e);
1065
1065
  return;
1066
1066
  }
1067
- _.hasSpectator(e) && _.hasSpectator(t) && t.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
1067
+ O.hasSpectator(e) && O.hasSpectator(t) && t.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
1068
1068
  }
1069
1069
  reset() {
1070
1070
  this.role = H, this.recvManager.reset();
@@ -1073,30 +1073,30 @@ class _ {
1073
1073
  return this.hasSpectator() ? this.recvManager : this.mainManager;
1074
1074
  }
1075
1075
  hasParticipant() {
1076
- return _.hasParticipant(this.role);
1076
+ return O.hasParticipant(this.role);
1077
1077
  }
1078
1078
  hasSpectatorSynthetic() {
1079
- return _.hasSpectatorSynthetic(this.role);
1079
+ return O.hasSpectatorSynthetic(this.role);
1080
1080
  }
1081
1081
  hasSpectator() {
1082
- return _.hasSpectator(this.role);
1082
+ return O.hasSpectator(this.role);
1083
1083
  }
1084
1084
  setRole(e) {
1085
1085
  const t = this.role;
1086
1086
  this.role = e, this.onRoleChanged?.({ previous: t, next: e });
1087
1087
  }
1088
1088
  }
1089
- const Z = (n) => n.streams[0]?.id;
1089
+ const ee = (n) => n.streams[0]?.id;
1090
1090
  class lt {
1091
1091
  events;
1092
1092
  callStateMachine;
1093
1093
  isPendingCall = !1;
1094
1094
  isPendingAnswer = !1;
1095
1095
  rtcSession;
1096
- callConfiguration = {};
1097
- mainRemoteStreamsManager = new j();
1098
- recvRemoteStreamsManager = new j();
1099
- roleManager = new _(
1096
+ conferenceStateManager;
1097
+ mainRemoteStreamsManager = new Z();
1098
+ recvRemoteStreamsManager = new Z();
1099
+ roleManager = new O(
1100
1100
  { mainManager: this.mainRemoteStreamsManager, recvManager: this.recvRemoteStreamsManager },
1101
1101
  (e) => {
1102
1102
  this.onRoleChanged(e);
@@ -1105,8 +1105,8 @@ class lt {
1105
1105
  mcuSession;
1106
1106
  recvSession;
1107
1107
  disposeRecvSessionTrackListener;
1108
- constructor() {
1109
- this.events = tt(), this.mcuSession = new st(this.events, { onReset: this.reset }), this.callStateMachine = new je(this.events), this.subscribeCallStatusChange(), this.subscribeMcuRemoteTrackEvents();
1108
+ constructor(e) {
1109
+ this.conferenceStateManager = e, this.events = nt(), this.mcuSession = new it(this.events, { onReset: this.reset }), this.callStateMachine = new Ze(this.events), this.subscribeCallStatusChange(), this.subscribeMcuRemoteTrackEvents();
1110
1110
  }
1111
1111
  get callActor() {
1112
1112
  return this.callStateMachine.actorRef;
@@ -1139,7 +1139,7 @@ class lt {
1139
1139
  off(e, t) {
1140
1140
  this.events.off(e, t);
1141
1141
  }
1142
- startCall = async (e, t, s) => (this.isPendingCall = !0, this.callConfiguration.number = s.number, this.callConfiguration.answer = !1, this.mcuSession.startCall(e, t, s).finally(() => {
1142
+ startCall = async (e, t, s) => (this.isPendingCall = !0, this.conferenceStateManager.updateState({ number: s.number, answer: !1 }), this.mcuSession.startCall(e, t, s).finally(() => {
1143
1143
  this.isPendingCall = !1;
1144
1144
  }));
1145
1145
  async endCall() {
@@ -1151,13 +1151,13 @@ class lt {
1151
1151
  answerToIncomingCall = async (e, t) => {
1152
1152
  this.isPendingAnswer = !0;
1153
1153
  const s = e();
1154
- return this.callConfiguration.answer = !0, this.callConfiguration.number = s.remote_identity.uri.user, this.mcuSession.answerToIncomingCall(s, t).finally(() => {
1154
+ return this.conferenceStateManager.updateState({
1155
+ answer: !0,
1156
+ number: s.remote_identity.uri.user
1157
+ }), this.mcuSession.answerToIncomingCall(s, t).finally(() => {
1155
1158
  this.isPendingAnswer = !1;
1156
1159
  });
1157
1160
  };
1158
- getCallConfiguration() {
1159
- return { ...this.callConfiguration };
1160
- }
1161
1161
  getMainStream() {
1162
1162
  return this.getActiveStreamsManager().mainStream;
1163
1163
  }
@@ -1180,7 +1180,7 @@ class lt {
1180
1180
  return this.mcuSession.restartIce(e);
1181
1181
  }
1182
1182
  reset = () => {
1183
- this.mainRemoteStreamsManager.reset(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1, this.roleManager.reset(), this.stopRecvSession();
1183
+ this.mainRemoteStreamsManager.reset(), this.conferenceStateManager.updateState({ number: void 0, answer: !1 }), this.roleManager.reset(), this.stopRecvSession();
1184
1184
  };
1185
1185
  subscribeCallStatusChange() {
1186
1186
  let { isCallActive: e } = this;
@@ -1195,7 +1195,7 @@ class lt {
1195
1195
  }
1196
1196
  subscribeMcuRemoteTrackEvents() {
1197
1197
  this.on(C.PEER_CONNECTION_ONTRACK, (e) => {
1198
- this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, Z(e));
1198
+ this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, ee(e));
1199
1199
  });
1200
1200
  }
1201
1201
  addRemoteTrack(e, t, s) {
@@ -1217,12 +1217,12 @@ class lt {
1217
1217
  const r = this.getActiveStreamsManager();
1218
1218
  if (e !== r)
1219
1219
  return;
1220
- const o = [...r.getStreams()];
1220
+ const a = [...r.getStreams()];
1221
1221
  this.events.trigger(C.REMOTE_STREAMS_CHANGED, {
1222
1222
  participantId: i,
1223
1223
  changeType: t,
1224
1224
  trackId: s,
1225
- streams: o
1225
+ streams: a
1226
1226
  });
1227
1227
  }
1228
1228
  getActiveStreamsManager() {
@@ -1230,21 +1230,21 @@ class lt {
1230
1230
  }
1231
1231
  attachRecvSessionTracks(e) {
1232
1232
  const { peerConnection: t } = e, s = (i) => {
1233
- this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, Z(i));
1233
+ this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, ee(i));
1234
1234
  };
1235
1235
  t.addEventListener("track", s), this.disposeRecvSessionTrackListener = () => {
1236
1236
  t.removeEventListener("track", s);
1237
1237
  };
1238
1238
  }
1239
1239
  startRecvSession(e, t) {
1240
- const { number: s } = this.callConfiguration;
1240
+ const s = this.conferenceStateManager.getNumber();
1241
1241
  if (s === void 0)
1242
1242
  return;
1243
1243
  this.stopRecvSession();
1244
1244
  const i = {
1245
1245
  quality: "high",
1246
1246
  audioChannel: e
1247
- }, r = new it(i, { sendOffer: t });
1247
+ }, r = new rt(i, { sendOffer: t });
1248
1248
  this.recvSession = r, this.recvRemoteStreamsManager.reset(), this.attachRecvSessionTracks(r), r.call(s).catch(() => {
1249
1249
  this.stopRecvSession();
1250
1250
  });
@@ -1256,45 +1256,45 @@ class lt {
1256
1256
  previous: e,
1257
1257
  next: t
1258
1258
  }) => {
1259
- if (_.hasSpectator(e) && !_.hasSpectator(t) && this.stopRecvSession(), _.hasSpectator(t)) {
1259
+ if (O.hasSpectator(e) && !O.hasSpectator(t) && this.stopRecvSession(), O.hasSpectator(t)) {
1260
1260
  const s = t.recvParams;
1261
1261
  this.startRecvSession(s.audioId, s.sendOffer);
1262
1262
  }
1263
1263
  };
1264
1264
  }
1265
- const dt = (n, e) => (n.degradationPreference = e.degradationPreference, n), ht = (n, e) => {
1265
+ const ht = (n, e) => (n.degradationPreference = e.degradationPreference, n), gt = (n, e) => {
1266
1266
  n.encodings ??= [];
1267
1267
  for (let t = n.encodings.length; t < e; t += 1)
1268
1268
  n.encodings.push({});
1269
1269
  return n;
1270
- }, Ee = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, gt = Ee(), ut = (n, e) => {
1271
- if (gt(n, e))
1270
+ }, Ce = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, ut = Ce(), Tt = (n, e) => {
1271
+ if (ut(n, e))
1272
1272
  return n;
1273
- }, Tt = (n, e) => {
1274
- const t = n.maxBitrate, s = ut(e, t);
1273
+ }, Et = (n, e) => {
1274
+ const t = n.maxBitrate, s = Tt(e, t);
1275
1275
  return s !== void 0 && (n.maxBitrate = s), n;
1276
- }, Ce = 1, Et = Ee(
1277
- Ce
1278
- ), Ct = (n, e) => {
1279
- const t = n === void 0 ? void 0 : Math.max(n, Ce);
1280
- if (t !== void 0 && Et(
1276
+ }, Se = 1, Ct = Ce(
1277
+ Se
1278
+ ), St = (n, e) => {
1279
+ const t = n === void 0 ? void 0 : Math.max(n, Se);
1280
+ if (t !== void 0 && Ct(
1281
1281
  t,
1282
1282
  e
1283
1283
  ))
1284
1284
  return t;
1285
- }, St = (n, e) => {
1286
- const t = n.scaleResolutionDownBy, s = Ct(
1285
+ }, pt = (n, e) => {
1286
+ const t = n.scaleResolutionDownBy, s = St(
1287
1287
  e,
1288
1288
  t
1289
1289
  );
1290
1290
  return s !== void 0 && (n.scaleResolutionDownBy = s), n;
1291
- }, pt = (n, e) => {
1291
+ }, mt = (n, e) => {
1292
1292
  const t = e.encodings?.length ?? 0;
1293
- return ht(n, t), n.encodings.forEach((s, i) => {
1294
- const r = (e?.encodings ?? [])[i], o = r?.maxBitrate, a = r?.scaleResolutionDownBy;
1295
- Tt(s, o), St(s, a);
1293
+ return gt(n, t), n.encodings.forEach((s, i) => {
1294
+ const r = (e?.encodings ?? [])[i], a = r?.maxBitrate, o = r?.scaleResolutionDownBy;
1295
+ Et(s, a), pt(s, o);
1296
1296
  }), n;
1297
- }, mt = (n, e) => {
1297
+ }, Nt = (n, e) => {
1298
1298
  if (n.codecs?.length !== e.codecs?.length)
1299
1299
  return !0;
1300
1300
  for (let t = 0; t < (n.codecs?.length ?? 0); t++)
@@ -1311,15 +1311,15 @@ const dt = (n, e) => (n.degradationPreference = e.degradationPreference, n), ht
1311
1311
  if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
1312
1312
  return !0;
1313
1313
  return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
1314
- }, Nt = async (n, e) => {
1314
+ }, Rt = async (n, e) => {
1315
1315
  const t = n.getParameters(), s = JSON.parse(
1316
1316
  JSON.stringify(t)
1317
1317
  );
1318
- pt(t, e), dt(t, e);
1319
- const i = mt(s, t);
1318
+ mt(t, e), ht(t, e);
1319
+ const i = Nt(s, t);
1320
1320
  return i && await n.setParameters(t), { parameters: t, isChanged: i };
1321
- }, Se = async (n, e, t) => {
1322
- const { isChanged: s, parameters: i } = await Nt(n, {
1321
+ }, pe = async (n, e, t) => {
1322
+ const { isChanged: s, parameters: i } = await Rt(n, {
1323
1323
  encodings: [
1324
1324
  {
1325
1325
  scaleResolutionDownBy: e.scaleResolutionDownBy,
@@ -1328,31 +1328,31 @@ const dt = (n, e) => (n.degradationPreference = e.degradationPreference, n), ht
1328
1328
  ]
1329
1329
  });
1330
1330
  return s && t && t(i), { isChanged: s, parameters: i };
1331
- }, Rt = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), At = async (n, e, t) => {
1332
- const s = Rt(n, e);
1331
+ }, At = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), It = async (n, e, t) => {
1332
+ const s = At(n, e);
1333
1333
  if (s)
1334
- return Se(s, { maxBitrate: t });
1334
+ return pe(s, { maxBitrate: t });
1335
1335
  };
1336
1336
  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 || {});
1337
- const pe = [
1337
+ const me = [
1338
1338
  "presentation:start",
1339
1339
  "presentation:started",
1340
1340
  "presentation:end",
1341
1341
  "presentation:ended",
1342
1342
  "presentation:failed"
1343
- ], It = () => new O(pe);
1344
- var ft = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(ft || {});
1345
- const Mt = $({
1343
+ ], ft = () => new M(me);
1344
+ var Mt = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(Mt || {});
1345
+ const vt = $({
1346
1346
  types: {
1347
1347
  context: {},
1348
1348
  events: {}
1349
1349
  },
1350
1350
  actions: {
1351
1351
  logTransition: (n, e) => {
1352
- l(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1352
+ d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1353
1353
  },
1354
1354
  logStateChange: (n, e) => {
1355
- l("PresentationStateMachine state changed", e.state);
1355
+ d("PresentationStateMachine state changed", e.state);
1356
1356
  },
1357
1357
  setError: b(({ event: n }) => "error" in n && n.error !== void 0 ? {
1358
1358
  lastError: n.error instanceof Error ? n.error : new Error(JSON.stringify(n.error))
@@ -1667,9 +1667,9 @@ const Mt = $({
1667
1667
  }
1668
1668
  }
1669
1669
  });
1670
- class vt extends q {
1670
+ class _t extends q {
1671
1671
  constructor(e) {
1672
- super(Mt), this.subscribeCallEvents(e);
1672
+ super(vt), this.subscribeCallEvents(e);
1673
1673
  }
1674
1674
  get isIdle() {
1675
1675
  return this.state === "presentation:idle";
@@ -1739,8 +1739,8 @@ class vt extends q {
1739
1739
  );
1740
1740
  }
1741
1741
  }
1742
- const _t = 1, Ls = (n) => Ge(n);
1743
- class Ot {
1742
+ const Ot = 1, Bs = (n) => $e(n);
1743
+ class Pt {
1744
1744
  events;
1745
1745
  presentationStateMachine;
1746
1746
  promisePendingStartPresentation;
@@ -1753,7 +1753,7 @@ class Ot {
1753
1753
  callManager: e,
1754
1754
  maxBitrate: t
1755
1755
  }) {
1756
- this.callManager = e, this.maxBitrate = t, this.events = It(), this.presentationStateMachine = new vt(this.callManager.events), this.subscribe();
1756
+ this.callManager = e, this.maxBitrate = t, this.events = ft(), this.presentationStateMachine = new _t(this.callManager.events), this.subscribe();
1757
1757
  }
1758
1758
  get presentationActor() {
1759
1759
  return this.presentationStateMachine.actorRef;
@@ -1769,8 +1769,8 @@ class Ot {
1769
1769
  isNeedReinvite: s,
1770
1770
  contentHint: i,
1771
1771
  sendEncodings: r,
1772
- onAddedTransceiver: o
1773
- } = {}, a) {
1772
+ onAddedTransceiver: a
1773
+ } = {}, o) {
1774
1774
  const c = this.getRtcSessionProtected();
1775
1775
  if (this.streamPresentationCurrent)
1776
1776
  throw new Error("Presentation is already started");
@@ -1781,9 +1781,9 @@ class Ot {
1781
1781
  isNeedReinvite: s,
1782
1782
  contentHint: i,
1783
1783
  sendEncodings: r,
1784
- onAddedTransceiver: o
1784
+ onAddedTransceiver: a
1785
1785
  },
1786
- options: a
1786
+ options: o
1787
1787
  });
1788
1788
  }
1789
1789
  async stopPresentation(e) {
@@ -1794,8 +1794,8 @@ class Ot {
1794
1794
  });
1795
1795
  const i = this.callManager.getEstablishedRTCSession();
1796
1796
  return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
1797
- const o = r instanceof Error ? r : new Error(String(r));
1798
- throw this.events.trigger(P.FAILED_PRESENTATION, o), r;
1797
+ const a = r instanceof Error ? r : new Error(String(r));
1798
+ throw this.events.trigger(P.FAILED_PRESENTATION, a), r;
1799
1799
  }) : t && this.events.trigger(P.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
1800
1800
  this.resetPresentation();
1801
1801
  });
@@ -1805,15 +1805,15 @@ class Ot {
1805
1805
  sendEncodings: i,
1806
1806
  onAddedTransceiver: r
1807
1807
  } = {}) {
1808
- const o = this.getRtcSessionProtected();
1808
+ const a = this.getRtcSessionProtected();
1809
1809
  if (!this.streamPresentationCurrent)
1810
1810
  throw new Error("Presentation has not started yet");
1811
- return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e, o, t, {
1811
+ return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this.sendPresentation(e, a, t, {
1812
1812
  contentHint: s,
1813
1813
  isNeedReinvite: !1,
1814
1814
  sendEncodings: i,
1815
1815
  onAddedTransceiver: r
1816
- }).then(async (a) => (await this.setMaxBitrate(), a));
1816
+ }).then(async (o) => (await this.setMaxBitrate(), o));
1817
1817
  }
1818
1818
  cancelSendPresentationWithRepeatedCalls() {
1819
1819
  this.cancelableSendPresentationWithRepeatedCalls?.stopRepeatedCalls();
@@ -1851,18 +1851,18 @@ class Ot {
1851
1851
  stream: s,
1852
1852
  presentationOptions: i,
1853
1853
  options: r = {
1854
- callLimit: _t
1854
+ callLimit: Ot
1855
1855
  }
1856
1856
  }) {
1857
- const o = async () => this.sendPresentation(
1857
+ const a = async () => this.sendPresentation(
1858
1858
  e,
1859
1859
  t,
1860
1860
  s,
1861
1861
  i
1862
- ), a = () => !!this.streamPresentationCurrent;
1863
- return this.cancelableSendPresentationWithRepeatedCalls = ce({
1864
- targetFunction: o,
1865
- isComplete: a,
1862
+ ), o = () => !!this.streamPresentationCurrent;
1863
+ return this.cancelableSendPresentationWithRepeatedCalls = de({
1864
+ targetFunction: a,
1865
+ isComplete: o,
1866
1866
  isRejectAsValid: !0,
1867
1867
  ...r
1868
1868
  }), this.cancelableSendPresentationWithRepeatedCalls.then((c) => c);
@@ -1871,17 +1871,17 @@ class Ot {
1871
1871
  async sendPresentation(e, t, s, {
1872
1872
  isNeedReinvite: i = !0,
1873
1873
  contentHint: r = "detail",
1874
- degradationPreference: o,
1875
- sendEncodings: a,
1874
+ degradationPreference: a,
1875
+ sendEncodings: o,
1876
1876
  onAddedTransceiver: c
1877
1877
  }) {
1878
- const d = k(s, { contentHint: r });
1879
- if (d === void 0)
1878
+ const l = k(s, { contentHint: r });
1879
+ if (l === void 0)
1880
1880
  throw new Error("No streamPresentationTarget");
1881
- this.streamPresentationCurrent = d;
1882
- const T = e().then(async () => t.startPresentation(d, i, {
1883
- degradationPreference: o,
1884
- sendEncodings: a,
1881
+ this.streamPresentationCurrent = l;
1882
+ const T = e().then(async () => t.startPresentation(l, i, {
1883
+ degradationPreference: a,
1884
+ sendEncodings: o,
1885
1885
  onAddedTransceiver: c
1886
1886
  })).then(this.setMaxBitrate).then(() => s).catch((h) => {
1887
1887
  this.removeStreamPresentationCurrent();
@@ -1897,7 +1897,7 @@ class Ot {
1897
1897
  if (!e || !t || s === void 0)
1898
1898
  return;
1899
1899
  const i = e.getSenders();
1900
- await At(i, t, s);
1900
+ await It(i, t, s);
1901
1901
  };
1902
1902
  getRtcSessionProtected = () => {
1903
1903
  const e = this.callManager.getEstablishedRTCSession();
@@ -1918,7 +1918,7 @@ class Ot {
1918
1918
  delete this.streamPresentationCurrent;
1919
1919
  }
1920
1920
  }
1921
- class Pt {
1921
+ class bt {
1922
1922
  data;
1923
1923
  getUa;
1924
1924
  constructor(e) {
@@ -2005,7 +2005,7 @@ class Pt {
2005
2005
  }
2006
2006
  }
2007
2007
  var S = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.DISCONNECTING = "disconnecting", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n.CONNECT_STARTED = "connect-started", n.CONNECT_SUCCEEDED = "connect-succeeded", n.CONNECT_FAILED = "connect-failed", n.CONNECT_PARAMETERS_RESOLVE_SUCCESS = "connect-parameters-resolve-success", n.CONNECT_PARAMETERS_RESOLVE_FAILED = "connect-parameters-resolve-failed", n.CONNECTED_WITH_CONFIGURATION = "connected-with-configuration", n))(S || {});
2008
- const me = [
2008
+ const Ne = [
2009
2009
  "connecting",
2010
2010
  "connected",
2011
2011
  "disconnected",
@@ -2015,7 +2015,7 @@ const me = [
2015
2015
  "registrationFailed",
2016
2016
  "newMessage",
2017
2017
  "sipEvent"
2018
- ], bt = [
2018
+ ], Dt = [
2019
2019
  "disconnecting",
2020
2020
  "connect-started",
2021
2021
  "connect-succeeded",
@@ -2023,12 +2023,12 @@ const me = [
2023
2023
  "connect-parameters-resolve-success",
2024
2024
  "connect-parameters-resolve-failed",
2025
2025
  "connected-with-configuration"
2026
- ], Ne = [...me, ...bt], Dt = () => new O(Ne);
2027
- function yt(n) {
2026
+ ], Re = [...Ne, ...Dt], yt = () => new M(Re);
2027
+ function Lt(n) {
2028
2028
  return (e) => `sip:${e}@${n}`;
2029
2029
  }
2030
- const Lt = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Re = (n) => n.trim().replaceAll(" ", "_"), wt = Lt(1e5, 99999999), Ut = 3;
2031
- class Ft {
2030
+ const wt = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, Ae = (n) => n.trim().replaceAll(" ", "_"), Ut = wt(1e5, 99999999), Ft = 3;
2031
+ class Bt {
2032
2032
  cancelableConnectWithRepeatedCalls;
2033
2033
  JsSIP;
2034
2034
  events;
@@ -2053,10 +2053,10 @@ class Ft {
2053
2053
  return;
2054
2054
  }
2055
2055
  let r = !1;
2056
- const o = this.getConnectionConfiguration();
2057
- e !== void 0 && e !== o?.displayName && (r = i.set("display_name", Re(e)), this.updateConnectionConfiguration("displayName", e));
2058
- const a = r;
2059
- a ? t(a) : s(new Error("nothing changed"));
2056
+ const a = this.getConnectionConfiguration();
2057
+ e !== void 0 && e !== a?.displayName && (r = i.set("display_name", Ae(e)), this.updateConnectionConfiguration("displayName", e));
2058
+ const o = r;
2059
+ o ? t(o) : s(new Error("nothing changed"));
2060
2060
  });
2061
2061
  disconnect = async () => {
2062
2062
  this.events.trigger(S.DISCONNECTING, {});
@@ -2072,12 +2072,12 @@ class Ft {
2072
2072
  cancelRequests() {
2073
2073
  this.cancelConnectWithRepeatedCalls();
2074
2074
  }
2075
- connectWithDuplicatedCalls = async (e, { callLimit: t = Ut } = {}) => {
2075
+ connectWithDuplicatedCalls = async (e, { callLimit: t = Ft } = {}) => {
2076
2076
  const s = async () => this.connectInner(e), i = (r) => {
2077
- const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), d = r != null && !xe(r);
2078
- return c || d;
2077
+ const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), l = r != null && !Qe(r);
2078
+ return c || l;
2079
2079
  };
2080
- return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ce({
2080
+ return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = de({
2081
2081
  targetFunction: s,
2082
2082
  isComplete: i,
2083
2083
  callLimit: t,
@@ -2108,10 +2108,10 @@ class Ft {
2108
2108
  sipServerIp: s,
2109
2109
  sipServerUrl: i,
2110
2110
  remoteAddress: r,
2111
- sessionTimers: o,
2112
- registerExpires: a,
2111
+ sessionTimers: a,
2112
+ registerExpires: o,
2113
2113
  connectionRecoveryMinInterval: c,
2114
- connectionRecoveryMaxInterval: d,
2114
+ connectionRecoveryMaxInterval: l,
2115
2115
  userAgent: T,
2116
2116
  displayName: h = "",
2117
2117
  register: u = !1,
@@ -2133,10 +2133,10 @@ class Ft {
2133
2133
  sipServerUrl: i,
2134
2134
  displayName: h,
2135
2135
  register: u,
2136
- sessionTimers: o,
2137
- registerExpires: a,
2136
+ sessionTimers: a,
2137
+ registerExpires: o,
2138
2138
  connectionRecoveryMinInterval: c,
2139
- connectionRecoveryMaxInterval: d,
2139
+ connectionRecoveryMaxInterval: l,
2140
2140
  userAgent: T,
2141
2141
  remoteAddress: r,
2142
2142
  extraHeaders: p
@@ -2152,15 +2152,15 @@ class Ft {
2152
2152
  return;
2153
2153
  }
2154
2154
  let i;
2155
- i = ((c, d) => {
2155
+ i = ((c, l) => {
2156
2156
  if (this.getConnectionConfiguration()?.register === !0)
2157
- return this.registrationManager.subscribeToStartEvents(c, d);
2157
+ return this.registrationManager.subscribeToStartEvents(c, l);
2158
2158
  const h = S.CONNECTED, u = [S.DISCONNECTED];
2159
2159
  return this.events.on(h, c), u.forEach((p) => {
2160
- this.events.on(p, d);
2160
+ this.events.on(p, l);
2161
2161
  }), () => {
2162
2162
  this.events.off(h, c), u.forEach((p) => {
2163
- this.events.off(p, d);
2163
+ this.events.off(p, l);
2164
2164
  });
2165
2165
  };
2166
2166
  })(() => {
@@ -2182,20 +2182,20 @@ class Ft {
2182
2182
  });
2183
2183
  }
2184
2184
  }
2185
- var Ae = /* @__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))(Ae || {});
2186
- const Bt = Object.values(Ae);
2187
- var kt = /* @__PURE__ */ ((n) => (n.IDLE = "connection:idle", n.CONNECTING = "connection:connecting", n.INITIALIZING = "connection:initializing", n.CONNECTED = "connection:connected", n.REGISTERED = "connection:registered", n.DISCONNECTED = "connection:disconnected", n.FAILED = "connection:failed", n))(kt || {});
2188
- const Gt = $({
2185
+ var Ie = /* @__PURE__ */ ((n) => (n.START_CONNECT = "START_CONNECT", n.START_INIT_UA = "START_INIT_UA", n.UA_CONNECTED = "UA_CONNECTED", n.UA_REGISTERED = "UA_REGISTERED", n.UA_UNREGISTERED = "UA_UNREGISTERED", n.UA_DISCONNECTED = "UA_DISCONNECTED", n.CONNECTION_FAILED = "CONNECTION_FAILED", n.RESET = "RESET", n))(Ie || {});
2186
+ const kt = Object.values(Ie);
2187
+ var Gt = /* @__PURE__ */ ((n) => (n.IDLE = "connection:idle", n.CONNECTING = "connection:connecting", n.INITIALIZING = "connection:initializing", n.CONNECTED = "connection:connected", n.REGISTERED = "connection:registered", n.DISCONNECTED = "connection:disconnected", n.FAILED = "connection:failed", n))(Gt || {});
2188
+ const $t = $({
2189
2189
  types: {
2190
2190
  context: {},
2191
2191
  events: {}
2192
2192
  },
2193
2193
  actions: {
2194
2194
  logTransition: (n, e) => {
2195
- l(`State transition: ${e.from} -> ${e.to} (${e.event})`);
2195
+ d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
2196
2196
  },
2197
2197
  logStateChange: (n, e) => {
2198
- l("ConnectionStateMachine state changed", e.state);
2198
+ d("ConnectionStateMachine state changed", e.state);
2199
2199
  },
2200
2200
  setError: b({
2201
2201
  error: ({ event: n }) => {
@@ -2544,12 +2544,12 @@ const Gt = $({
2544
2544
  }
2545
2545
  }
2546
2546
  });
2547
- class $t extends q {
2547
+ class qt extends q {
2548
2548
  stateChangeListeners = /* @__PURE__ */ new Set();
2549
2549
  events;
2550
2550
  unsubscribeFromEvents;
2551
2551
  constructor(e) {
2552
- super(Gt), this.events = e, this.addSubscription(
2552
+ super($t), this.events = e, this.addSubscription(
2553
2553
  this.subscribe((t) => {
2554
2554
  const s = t.value;
2555
2555
  this.stateChangeListeners.forEach((i) => {
@@ -2637,14 +2637,14 @@ class $t extends q {
2637
2637
  return this.getSnapshot().can({ type: e });
2638
2638
  }
2639
2639
  getValidEvents() {
2640
- return Bt.filter((e) => this.canTransition(e));
2640
+ return kt.filter((e) => this.canTransition(e));
2641
2641
  }
2642
2642
  hasState(e) {
2643
2643
  return this.getSnapshot().matches(e);
2644
2644
  }
2645
2645
  sendEvent(e) {
2646
2646
  if (!this.getSnapshot().can(e)) {
2647
- l(
2647
+ d(
2648
2648
  `Invalid transition: ${e.type} from ${this.state}. Event cannot be processed in current state.`
2649
2649
  );
2650
2650
  return;
@@ -2709,7 +2709,7 @@ class $t extends q {
2709
2709
  this.toFailed(e instanceof Error ? e : void 0);
2710
2710
  };
2711
2711
  }
2712
- class qt {
2712
+ class Vt {
2713
2713
  events;
2714
2714
  getUaProtected;
2715
2715
  constructor(e) {
@@ -2731,7 +2731,7 @@ class qt {
2731
2731
  try {
2732
2732
  await this.unregister();
2733
2733
  } catch (e) {
2734
- l("tryRegister", e);
2734
+ d("tryRegister", e);
2735
2735
  }
2736
2736
  return this.register();
2737
2737
  }
@@ -2746,7 +2746,7 @@ class qt {
2746
2746
  };
2747
2747
  }
2748
2748
  }
2749
- class Vt {
2749
+ class Ht {
2750
2750
  uaFactory;
2751
2751
  getUaProtected;
2752
2752
  constructor(e) {
@@ -2757,7 +2757,7 @@ class Vt {
2757
2757
  */
2758
2758
  async sendOptions(e, t, s) {
2759
2759
  const i = this.getUaProtected();
2760
- return new Promise((r, o) => {
2760
+ return new Promise((r, a) => {
2761
2761
  try {
2762
2762
  i.sendOptions(e, t, {
2763
2763
  extraHeaders: s,
@@ -2765,11 +2765,11 @@ class Vt {
2765
2765
  succeeded: () => {
2766
2766
  r();
2767
2767
  },
2768
- failed: o
2768
+ failed: a
2769
2769
  }
2770
2770
  });
2771
- } catch (a) {
2772
- o(a);
2771
+ } catch (o) {
2772
+ a(o);
2773
2773
  }
2774
2774
  });
2775
2775
  }
@@ -2789,29 +2789,29 @@ class Vt {
2789
2789
  sipServerIp: s,
2790
2790
  sipServerUrl: i,
2791
2791
  remoteAddress: r,
2792
- extraHeaders: o
2792
+ extraHeaders: a
2793
2793
  }) {
2794
- return new Promise((a, c) => {
2795
- const { configuration: d } = this.uaFactory.createConfiguration({
2794
+ return new Promise((o, c) => {
2795
+ const { configuration: l } = this.uaFactory.createConfiguration({
2796
2796
  sipServerUrl: i,
2797
2797
  displayName: t,
2798
2798
  userAgent: e,
2799
2799
  sipServerIp: s
2800
- }), T = this.uaFactory.createUA({ ...d, remoteAddress: r, extraHeaders: o }), h = () => {
2800
+ }), T = this.uaFactory.createUA({ ...l, remoteAddress: r, extraHeaders: a }), h = () => {
2801
2801
  const p = new Error("Telephony is not available");
2802
2802
  c(p);
2803
2803
  };
2804
2804
  T.once(S.DISCONNECTED, h);
2805
2805
  const u = () => {
2806
2806
  T.removeAllListeners(), T.once(S.DISCONNECTED, () => {
2807
- a();
2807
+ o();
2808
2808
  }), T.stop();
2809
2809
  };
2810
2810
  T.once(S.CONNECTED, u), T.start();
2811
2811
  });
2812
2812
  }
2813
2813
  }
2814
- const Ht = (n) => {
2814
+ const Wt = (n) => {
2815
2815
  const e = [];
2816
2816
  return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
2817
2817
  };
@@ -2840,10 +2840,10 @@ class L {
2840
2840
  throw new Error("user is required for authorized connection");
2841
2841
  }
2842
2842
  static resolveAuthorizationUser(e, t) {
2843
- return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${wt()}`;
2843
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${Ut()}`;
2844
2844
  }
2845
2845
  static buildExtraHeaders(e, t) {
2846
- const s = e !== void 0 && e !== "" ? Ht(e) : [];
2846
+ const s = e !== void 0 && e !== "" ? Wt(e) : [];
2847
2847
  return t === void 0 ? s : [...s, ...t];
2848
2848
  }
2849
2849
  createConfiguration({
@@ -2852,34 +2852,34 @@ class L {
2852
2852
  sipServerUrl: s,
2853
2853
  displayName: i = "",
2854
2854
  sipServerIp: r,
2855
- register: o = !1,
2856
- sessionTimers: a = !1,
2855
+ register: a = !1,
2856
+ sessionTimers: o = !1,
2857
2857
  registerExpires: c = 300,
2858
2858
  // 5 minutes in sec
2859
- connectionRecoveryMinInterval: d = 2,
2859
+ connectionRecoveryMinInterval: l = 2,
2860
2860
  connectionRecoveryMaxInterval: T = 6,
2861
2861
  userAgent: h
2862
2862
  }) {
2863
2863
  L.validateParametersConnection({
2864
- register: o,
2864
+ register: a,
2865
2865
  password: t,
2866
2866
  user: e,
2867
2867
  sipServerIp: r,
2868
2868
  sipServerUrl: s
2869
2869
  });
2870
- const u = L.resolveAuthorizationUser(o, e), p = yt(r), A = p(u), N = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
2870
+ const u = L.resolveAuthorizationUser(a, e), p = Lt(r), A = p(u), N = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
2871
2871
  return {
2872
2872
  configuration: {
2873
2873
  password: t,
2874
- register: o,
2874
+ register: a,
2875
2875
  uri: A,
2876
- display_name: Re(i),
2876
+ display_name: Ae(i),
2877
2877
  user_agent: h,
2878
2878
  sdpSemantics: "unified-plan",
2879
2879
  sockets: [N],
2880
- session_timers: a,
2880
+ session_timers: o,
2881
2881
  register_expires: c,
2882
- connection_recovery_min_interval: d,
2882
+ connection_recovery_min_interval: l,
2883
2883
  connection_recovery_max_interval: T
2884
2884
  },
2885
2885
  helpers: {
@@ -2901,14 +2901,14 @@ class L {
2901
2901
  remoteAddress: e.remoteAddress,
2902
2902
  extraHeaders: e.extraHeaders
2903
2903
  });
2904
- return t.eachTriggers((o, a) => {
2905
- const c = me.find((d) => d === a);
2906
- c && r.on(c, o);
2904
+ return t.eachTriggers((a, o) => {
2905
+ const c = Ne.find((l) => l === o);
2906
+ c && r.on(c, a);
2907
2907
  }), { ua: r, helpers: i };
2908
2908
  }
2909
2909
  }
2910
- const Ie = "Not ready for connection", Wt = (n) => n instanceof Error && n.message === Ie, xt = () => new Error(Ie), Qt = async (n) => typeof n == "function" ? n() : n;
2911
- class Yt {
2910
+ const fe = "Not ready for connection", xt = (n) => n instanceof Error && n.message === fe, Qt = () => new Error(fe), Yt = async (n) => typeof n == "function" ? n() : n;
2911
+ class zt {
2912
2912
  events;
2913
2913
  ua;
2914
2914
  socket;
@@ -2920,15 +2920,15 @@ class Yt {
2920
2920
  configurationManager;
2921
2921
  JsSIP;
2922
2922
  constructor({ JsSIP: e }) {
2923
- this.JsSIP = e, this.events = Dt(), this.uaFactory = new L(e), this.registrationManager = new qt({
2923
+ this.JsSIP = e, this.events = yt(), this.uaFactory = new L(e), this.registrationManager = new Vt({
2924
2924
  events: this.events,
2925
2925
  getUaProtected: this.getUaProtected
2926
- }), this.stateMachine = new $t(this.events), this.configurationManager = new Pt({
2926
+ }), this.stateMachine = new qt(this.events), this.configurationManager = new bt({
2927
2927
  getUa: this.getUa
2928
- }), this.sipOperations = new Vt({
2928
+ }), this.sipOperations = new Ht({
2929
2929
  uaFactory: this.uaFactory,
2930
2930
  getUaProtected: this.getUaProtected
2931
- }), this.connectionFlow = new Ft({
2931
+ }), this.connectionFlow = new Bt({
2932
2932
  JsSIP: this.JsSIP,
2933
2933
  events: this.events,
2934
2934
  uaFactory: this.uaFactory,
@@ -2984,7 +2984,7 @@ class Yt {
2984
2984
  return this.configurationManager.isRegister();
2985
2985
  }
2986
2986
  connect = async (e, t) => this.disconnect().catch((s) => {
2987
- l("connect: disconnect error", s);
2987
+ d("connect: disconnect error", s);
2988
2988
  }).then(async () => this.connectWithProcessError(e, t));
2989
2989
  set = async ({ displayName: e }) => this.connectionFlow.set({ displayName: e });
2990
2990
  disconnect = async () => {
@@ -3033,7 +3033,7 @@ class Yt {
3033
3033
  getUa = () => this.ua;
3034
3034
  connectWithProcessError = async (e, t) => {
3035
3035
  if (!(t?.hasReadyForConnection?.() ?? !0))
3036
- throw xt();
3036
+ throw Qt();
3037
3037
  return this.processConnect(e, t).catch(async (i) => {
3038
3038
  const r = i;
3039
3039
  return this.disconnect().then(() => {
@@ -3043,7 +3043,7 @@ class Yt {
3043
3043
  });
3044
3044
  });
3045
3045
  };
3046
- processConnect = async (e, t) => (this.events.trigger(S.CONNECT_STARTED, {}), Qt(e).then((s) => (this.events.trigger(S.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
3046
+ processConnect = async (e, t) => (this.events.trigger(S.CONNECT_STARTED, {}), Yt(e).then((s) => (this.events.trigger(S.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
3047
3047
  throw this.events.trigger(S.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
3048
3048
  }).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(S.CONNECT_SUCCEEDED, {
3049
3049
  ...s
@@ -3052,7 +3052,7 @@ class Yt {
3052
3052
  throw this.events.trigger(S.CONNECT_FAILED, i), i;
3053
3053
  }));
3054
3054
  }
3055
- class zt {
3055
+ class Xt {
3056
3056
  connectionManager;
3057
3057
  stackPromises = le({
3058
3058
  noRunIsNotActual: !0
@@ -3066,11 +3066,11 @@ class zt {
3066
3066
  this.stackPromises.stop();
3067
3067
  }
3068
3068
  }
3069
- const ee = 0, Xt = 30;
3070
- class Jt {
3071
- countInner = ee;
3072
- initialCount = ee;
3073
- limitInner = Xt;
3069
+ const te = 0, Jt = 30;
3070
+ class Kt {
3071
+ countInner = te;
3072
+ initialCount = te;
3073
+ limitInner = Jt;
3074
3074
  isInProgress = !1;
3075
3075
  onStatusChange;
3076
3076
  constructor({
@@ -3103,7 +3103,7 @@ class Jt {
3103
3103
  this.countInner = this.initialCount, this.finishAttempt();
3104
3104
  }
3105
3105
  }
3106
- class Kt {
3106
+ class jt {
3107
3107
  connectionManager;
3108
3108
  interval;
3109
3109
  checkTelephonyByTimeout = void 0;
@@ -3119,7 +3119,7 @@ class Kt {
3119
3119
  onSuccessRequest: t,
3120
3120
  onFailRequest: s
3121
3121
  }) {
3122
- this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = Ue({
3122
+ this.stop(), this.cancelableBeforeRequest = new G(e), this.checkTelephonyByTimeout = Fe({
3123
3123
  isDontStopOnFail: !0,
3124
3124
  requestInterval: this.interval,
3125
3125
  request: async () => {
@@ -3140,7 +3140,7 @@ class Kt {
3140
3140
  }
3141
3141
  }
3142
3142
  var f = /* @__PURE__ */ ((n) => (n.BEFORE_ATTEMPT = "before-attempt", n.SUCCESS = "success", n.FAILED_ALL_ATTEMPTS = "failed-all-attempts", n.CANCELLED_ATTEMPTS = "cancelled-attempts", n.CHANGED_ATTEMPT_STATUS = "changed-attempt-status", n.STOP_ATTEMPTS_BY_ERROR = "stop-attempts-by-error", n.LIMIT_REACHED_ATTEMPTS = "limit-reached-attempts", n))(f || {});
3143
- const fe = [
3143
+ const Me = [
3144
3144
  "before-attempt",
3145
3145
  "success",
3146
3146
  "failed-all-attempts",
@@ -3148,8 +3148,8 @@ const fe = [
3148
3148
  "changed-attempt-status",
3149
3149
  "stop-attempts-by-error",
3150
3150
  "limit-reached-attempts"
3151
- ], jt = () => new O(fe);
3152
- class J {
3151
+ ], Zt = () => new M(Me);
3152
+ class K {
3153
3153
  callManager;
3154
3154
  disposers = [];
3155
3155
  constructor({ callManager: e }) {
@@ -3174,40 +3174,40 @@ class J {
3174
3174
  this.callManager.isCallActive ? e?.() : t();
3175
3175
  }
3176
3176
  }
3177
- const Zt = 15e3, en = 2;
3178
- class tn {
3177
+ const en = 15e3, tn = 2;
3178
+ class nn {
3179
3179
  connectionManager;
3180
3180
  pingServerByTimeoutWithFailCalls;
3181
3181
  constructor({ connectionManager: e }) {
3182
- this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Fe(en, {
3182
+ this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = Be(tn, {
3183
3183
  whenPossibleRequest: async () => {
3184
3184
  },
3185
- requestInterval: Zt,
3186
- request: async () => (l("ping"), this.connectionManager.ping().then(() => {
3187
- l("ping success");
3185
+ requestInterval: en,
3186
+ request: async () => (d("ping"), this.connectionManager.ping().then(() => {
3187
+ d("ping success");
3188
3188
  }))
3189
3189
  });
3190
3190
  }
3191
3191
  start({ onFailRequest: e }) {
3192
- this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(l);
3192
+ this.pingServerByTimeoutWithFailCalls.start(void 0, { onFailRequest: e }).catch(d);
3193
3193
  }
3194
3194
  stop() {
3195
3195
  this.pingServerByTimeoutWithFailCalls.stop();
3196
3196
  }
3197
3197
  }
3198
- class nn {
3198
+ class sn {
3199
3199
  pingServerRequester;
3200
3200
  notActiveCallSubscriber;
3201
3201
  constructor({
3202
3202
  connectionManager: e,
3203
3203
  callManager: t
3204
3204
  }) {
3205
- this.pingServerRequester = new tn({
3205
+ this.pingServerRequester = new nn({
3206
3206
  connectionManager: e
3207
- }), this.notActiveCallSubscriber = new J({ callManager: t });
3207
+ }), this.notActiveCallSubscriber = new K({ callManager: t });
3208
3208
  }
3209
3209
  start({ onFailRequest: e }) {
3210
- l("start"), this.notActiveCallSubscriber.subscribe({
3210
+ d("start"), this.notActiveCallSubscriber.subscribe({
3211
3211
  onActive: () => {
3212
3212
  this.pingServerRequester.stop();
3213
3213
  },
@@ -3217,13 +3217,13 @@ class nn {
3217
3217
  });
3218
3218
  }
3219
3219
  stop() {
3220
- l("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
3220
+ d("stop"), this.pingServerRequester.stop(), this.unsubscribeCallStatusChange();
3221
3221
  }
3222
3222
  unsubscribeCallStatusChange() {
3223
3223
  this.notActiveCallSubscriber.unsubscribe();
3224
3224
  }
3225
3225
  }
3226
- class sn {
3226
+ class rn {
3227
3227
  connectionManager;
3228
3228
  isRegistrationFailed = !1;
3229
3229
  disposers = [];
@@ -3232,7 +3232,7 @@ class sn {
3232
3232
  connectionManager: e,
3233
3233
  callManager: t
3234
3234
  }) {
3235
- this.connectionManager = e, this.notActiveCallSubscriber = new J({ callManager: t });
3235
+ this.connectionManager = e, this.notActiveCallSubscriber = new K({ callManager: t });
3236
3236
  }
3237
3237
  subscribe(e) {
3238
3238
  this.unsubscribe(), this.disposers.push(
@@ -3259,11 +3259,11 @@ class sn {
3259
3259
  this.isRegistrationFailed = !1;
3260
3260
  }
3261
3261
  }
3262
- const rn = 3e3, an = 15e3, te = {
3262
+ const an = 3e3, on = 15e3, ne = {
3263
3263
  LIMIT_REACHED: "Limit reached",
3264
3264
  FAILED_TO_RECONNECT: "Failed to reconnect"
3265
- }, on = async () => {
3266
- }, cn = (n) => !0;
3265
+ }, cn = async () => {
3266
+ }, dn = (n) => !0;
3267
3267
  class ln {
3268
3268
  events;
3269
3269
  connectionManager;
@@ -3284,28 +3284,28 @@ class ln {
3284
3284
  connectionManager: t,
3285
3285
  callManager: s
3286
3286
  }, i) {
3287
- const r = i?.onBeforeRetry ?? on, o = i?.canRetryOnError ?? cn;
3288
- this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = o, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = jt(), this.checkTelephonyRequester = new Kt({
3287
+ const r = i?.onBeforeRetry ?? cn, a = i?.canRetryOnError ?? dn;
3288
+ this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = Zt(), this.checkTelephonyRequester = new jt({
3289
3289
  connectionManager: t,
3290
- interval: i?.checkTelephonyRequestInterval ?? an
3291
- }), this.pingServerIfNotActiveCallRequester = new nn({
3290
+ interval: i?.checkTelephonyRequestInterval ?? on
3291
+ }), this.pingServerIfNotActiveCallRequester = new sn({
3292
3292
  connectionManager: t,
3293
3293
  callManager: s
3294
- }), this.registrationFailedOutOfCallSubscriber = new sn({
3294
+ }), this.registrationFailedOutOfCallSubscriber = new rn({
3295
3295
  connectionManager: t,
3296
3296
  callManager: s
3297
- }), this.attemptsState = new Jt({
3297
+ }), this.attemptsState = new Kt({
3298
3298
  onStatusChange: this.emitStatusChange
3299
- }), this.cancelableRequestBeforeRetry = new G(r), this.delayBetweenAttempts = new Be(
3300
- i?.timeoutBetweenAttempts ?? rn
3301
- ), this.notActiveCallSubscriber = new J({ callManager: s });
3299
+ }), this.cancelableRequestBeforeRetry = new G(r), this.delayBetweenAttempts = new ke(
3300
+ i?.timeoutBetweenAttempts ?? an
3301
+ ), this.notActiveCallSubscriber = new K({ callManager: s });
3302
3302
  }
3303
3303
  start(e) {
3304
- l("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToNotActiveCall(e);
3304
+ d("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToNotActiveCall(e);
3305
3305
  }
3306
3306
  stop() {
3307
- l("auto connector stop"), this.unsubscribeFromNotActiveCall(), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow().catch((e) => {
3308
- l("auto connector stop from stop method: error", e);
3307
+ d("auto connector stop"), this.unsubscribeFromNotActiveCall(), this.unsubscribeFromHardwareTriggers(), this.stopConnectionFlow().catch((e) => {
3308
+ d("auto connector stop from stop method: error", e);
3309
3309
  });
3310
3310
  }
3311
3311
  on(e, t) {
@@ -3324,77 +3324,77 @@ class ln {
3324
3324
  this.events.off(e, t);
3325
3325
  }
3326
3326
  restartConnectionAttempts(e) {
3327
- l("auto connector restart connection attempts"), this.stopConnectionFlow().then(async () => this.attemptConnection(e)).catch((t) => {
3328
- l("auto connector failed to restart connection attempts:", t);
3327
+ d("auto connector restart connection attempts"), this.stopConnectionFlow().then(async () => this.attemptConnection(e)).catch((t) => {
3328
+ d("auto connector failed to restart connection attempts:", t);
3329
3329
  });
3330
3330
  }
3331
3331
  async stopConnectionFlow() {
3332
- l("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), await this.connectionQueueManager.disconnect();
3332
+ d("stopConnectionFlow"), this.stopAttempts(), this.stopConnectTriggers(), await this.connectionQueueManager.disconnect();
3333
3333
  }
3334
3334
  stopAttempts() {
3335
3335
  this.attemptsState.isAttemptInProgress && this.connectionQueueManager.stop(), this.delayBetweenAttempts.cancelRequest(), this.cancelableRequestBeforeRetry.cancelRequest(), this.attemptsState.reset();
3336
3336
  }
3337
3337
  stopConnectTriggers() {
3338
- l("stopConnectTriggers"), this.stopPingRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
3338
+ d("stopConnectTriggers"), this.stopPingRequester(), this.checkTelephonyRequester.stop(), this.registrationFailedOutOfCallSubscriber.unsubscribe();
3339
3339
  }
3340
3340
  startCheckTelephony(e) {
3341
- l("startCheckTelephony"), this.checkTelephonyRequester.start({
3341
+ d("startCheckTelephony"), this.checkTelephonyRequester.start({
3342
3342
  onBeforeRequest: async () => (await this.onBeforeRetry(), e.getParameters()),
3343
3343
  onSuccessRequest: () => {
3344
- l("startCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
3344
+ d("startCheckTelephony: onSuccessRequest"), this.connectIfDisconnected(e);
3345
3345
  },
3346
3346
  onFailRequest: (t) => {
3347
- l("startCheckTelephony: onFailRequest", t.message);
3347
+ d("startCheckTelephony: onFailRequest", t.message);
3348
3348
  }
3349
3349
  });
3350
3350
  }
3351
3351
  async attemptConnection(e) {
3352
- if (l("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(f.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
3353
- l("attemptConnection: limit reached"), this.handleLimitReached(e);
3352
+ if (d("attemptConnection: attempts.count", this.attemptsState.count), this.events.trigger(f.BEFORE_ATTEMPT, {}), this.stopConnectTriggers(), this.attemptsState.hasLimitReached()) {
3353
+ d("attemptConnection: limit reached"), this.handleLimitReached(e);
3354
3354
  return;
3355
3355
  }
3356
3356
  return this.attemptsState.startAttempt(), this.attemptsState.increment(), this.executeConnectionAttempt(e);
3357
3357
  }
3358
3358
  async executeConnectionAttempt(e) {
3359
3359
  try {
3360
- await this.connectionQueueManager.connect(e.getParameters, e.options), l("executeConnectionAttempt: success"), this.handleSucceededAttempt(e);
3360
+ await this.connectionQueueManager.connect(e.getParameters, e.options), d("executeConnectionAttempt: success"), this.handleSucceededAttempt(e);
3361
3361
  } catch (t) {
3362
3362
  this.handleConnectionError(t, e);
3363
3363
  }
3364
3364
  }
3365
3365
  handleConnectionError(e, t) {
3366
- if (Wt(e)) {
3366
+ if (xt(e)) {
3367
3367
  this.attemptsState.finishAttempt(), this.events.trigger(f.STOP_ATTEMPTS_BY_ERROR, e);
3368
3368
  return;
3369
3369
  }
3370
3370
  if (!this.canRetryOnError(e)) {
3371
- l("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(f.STOP_ATTEMPTS_BY_ERROR, e);
3371
+ d("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(f.STOP_ATTEMPTS_BY_ERROR, e);
3372
3372
  return;
3373
3373
  }
3374
- if (qe(e)) {
3375
- l("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(f.CANCELLED_ATTEMPTS, e);
3374
+ if (Ve(e)) {
3375
+ d("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(f.CANCELLED_ATTEMPTS, e);
3376
3376
  return;
3377
3377
  }
3378
- l("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
3378
+ d("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
3379
3379
  }
3380
3380
  handleLimitReached(e) {
3381
- this.attemptsState.finishAttempt(), this.events.trigger(f.LIMIT_REACHED_ATTEMPTS, new Error(te.LIMIT_REACHED)), this.startCheckTelephony(e);
3381
+ this.attemptsState.finishAttempt(), this.events.trigger(f.LIMIT_REACHED_ATTEMPTS, new Error(ne.LIMIT_REACHED)), this.startCheckTelephony(e);
3382
3382
  }
3383
3383
  handleSucceededAttempt(e) {
3384
- l("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(f.SUCCESS);
3384
+ d("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(f.SUCCESS);
3385
3385
  }
3386
3386
  subscribeToConnectTriggers(e) {
3387
3387
  this.startPingRequester(e), this.registrationFailedOutOfCallSubscriber.subscribe(() => {
3388
- l("registrationFailedOutOfCallListener callback"), this.restartConnectionAttempts(e);
3388
+ d("registrationFailedOutOfCallListener callback"), this.restartConnectionAttempts(e);
3389
3389
  });
3390
3390
  }
3391
3391
  subscribeToNotActiveCall(e) {
3392
3392
  this.notActiveCallSubscriber.subscribe({
3393
3393
  onActive: () => {
3394
- l("subscribeToNotActiveCall onActive"), this.unsubscribeFromHardwareTriggers();
3394
+ d("subscribeToNotActiveCall onActive"), this.unsubscribeFromHardwareTriggers();
3395
3395
  },
3396
3396
  onInactive: () => {
3397
- l("subscribeToNotActiveCall onInactive"), this.subscribeToHardwareTriggers(e);
3397
+ d("subscribeToNotActiveCall onInactive"), this.subscribeToHardwareTriggers(e);
3398
3398
  }
3399
3399
  });
3400
3400
  }
@@ -3402,13 +3402,13 @@ class ln {
3402
3402
  this.notActiveCallSubscriber.unsubscribe();
3403
3403
  }
3404
3404
  subscribeToHardwareTriggers(e) {
3405
- this.unsubscribeFromHardwareTriggers(), l("subscribeToHardwareTriggers"), this.networkInterfacesSubscriber?.subscribe({
3405
+ this.unsubscribeFromHardwareTriggers(), d("subscribeToHardwareTriggers"), this.networkInterfacesSubscriber?.subscribe({
3406
3406
  onChange: () => {
3407
- l("networkInterfacesSubscriber onChange"), this.restartConnectionAttempts(e);
3407
+ d("networkInterfacesSubscriber onChange"), this.restartConnectionAttempts(e);
3408
3408
  },
3409
3409
  onUnavailable: () => {
3410
- l("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow().catch((t) => {
3411
- l(
3410
+ d("networkInterfacesSubscriber onUnavailable"), this.stopConnectionFlow().catch((t) => {
3411
+ d(
3412
3412
  "auto connector stop from networkInterfacesSubscriber onUnavailable: error",
3413
3413
  t
3414
3414
  );
@@ -3416,12 +3416,12 @@ class ln {
3416
3416
  }
3417
3417
  }), this.resumeFromSleepModeSubscriber?.subscribe({
3418
3418
  onResume: () => {
3419
- l("resumeFromSleepModeSubscriber onResume"), this.restartConnectionAttempts(e);
3419
+ d("resumeFromSleepModeSubscriber onResume"), this.restartConnectionAttempts(e);
3420
3420
  }
3421
3421
  });
3422
3422
  }
3423
3423
  unsubscribeFromHardwareTriggers() {
3424
- l("unsubscribeFromHardwareTriggers"), this.networkInterfacesSubscriber?.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
3424
+ d("unsubscribeFromHardwareTriggers"), this.networkInterfacesSubscriber?.unsubscribe(), this.resumeFromSleepModeSubscriber?.unsubscribe();
3425
3425
  }
3426
3426
  stopPingRequester() {
3427
3427
  this.pingServerIfNotActiveCallRequester.stop();
@@ -3429,18 +3429,18 @@ class ln {
3429
3429
  startPingRequester(e) {
3430
3430
  this.pingServerIfNotActiveCallRequester.start({
3431
3431
  onFailRequest: () => {
3432
- l("pingRequester: onFailRequest"), this.restartConnectionAttempts(e);
3432
+ d("pingRequester: onFailRequest"), this.restartConnectionAttempts(e);
3433
3433
  }
3434
3434
  });
3435
3435
  }
3436
3436
  connectIfDisconnected(e) {
3437
3437
  const t = this.isConnectionUnavailable();
3438
- l("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(f.SUCCESS));
3438
+ d("connectIfDisconnected: isUnavailable", t), t ? this.restartConnectionAttempts(e) : (this.stopConnectTriggers(), this.events.trigger(f.SUCCESS));
3439
3439
  }
3440
3440
  scheduleReconnect(e) {
3441
- l("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (l("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (l("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
3442
- const s = t instanceof Error ? t : new Error(te.FAILED_TO_RECONNECT);
3443
- this.attemptsState.finishAttempt(), we(t) || ke(t) ? this.events.trigger(f.CANCELLED_ATTEMPTS, s) : this.events.trigger(f.FAILED_ALL_ATTEMPTS, s), l("scheduleReconnect: error", t);
3441
+ d("scheduleReconnect"), this.delayBetweenAttempts.request().then(async () => (d("scheduleReconnect: delayBetweenAttempts success"), this.cancelableRequestBeforeRetry.request())).then(async () => (d("scheduleReconnect: onBeforeRetry success"), this.attemptConnection(e))).catch((t) => {
3442
+ const s = t instanceof Error ? t : new Error(ne.FAILED_TO_RECONNECT);
3443
+ this.attemptsState.finishAttempt(), Ue(t) || Ge(t) ? this.events.trigger(f.CANCELLED_ATTEMPTS, s) : this.events.trigger(f.FAILED_ALL_ATTEMPTS, s), d("scheduleReconnect: error", t);
3444
3444
  });
3445
3445
  }
3446
3446
  isConnectionUnavailable() {
@@ -3451,25 +3451,81 @@ class ln {
3451
3451
  this.events.trigger(f.CHANGED_ATTEMPT_STATUS, { isInProgress: e });
3452
3452
  };
3453
3453
  }
3454
+ var z = /* @__PURE__ */ ((n) => (n.STATE_CHANGED = "state-changed", n.STATE_RESET = "state-reset", n))(z || {});
3455
+ const hn = ["state-changed", "state-reset"], gn = () => new M(hn);
3456
+ class un {
3457
+ events;
3458
+ state = {};
3459
+ constructor() {
3460
+ this.events = gn();
3461
+ }
3462
+ getState() {
3463
+ return { ...this.state };
3464
+ }
3465
+ updateState(e) {
3466
+ const t = { ...this.state };
3467
+ this.state = { ...this.state, ...e }, this.events.trigger(z.STATE_CHANGED, {
3468
+ previous: t,
3469
+ current: this.state,
3470
+ updates: e
3471
+ });
3472
+ }
3473
+ reset() {
3474
+ this.state = {}, this.events.trigger(z.STATE_RESET, {});
3475
+ }
3476
+ getToken() {
3477
+ return this.state.token;
3478
+ }
3479
+ getRoom() {
3480
+ return this.state.room;
3481
+ }
3482
+ getParticipantName() {
3483
+ return this.state.participantName;
3484
+ }
3485
+ getChannels() {
3486
+ return this.state.channels;
3487
+ }
3488
+ getConference() {
3489
+ return this.state.conference;
3490
+ }
3491
+ getParticipant() {
3492
+ return this.state.participant;
3493
+ }
3494
+ getNumber() {
3495
+ return this.state.number;
3496
+ }
3497
+ getAnswer() {
3498
+ return this.state.answer;
3499
+ }
3500
+ on(e, t) {
3501
+ return this.events.on(e, t);
3502
+ }
3503
+ once(e, t) {
3504
+ return this.events.once(e, t);
3505
+ }
3506
+ off(e, t) {
3507
+ this.events.off(e, t);
3508
+ }
3509
+ }
3454
3510
  var U = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(U || {});
3455
- const Me = [
3511
+ const ve = [
3456
3512
  "incomingCall",
3457
3513
  "declinedIncomingCall",
3458
3514
  "terminatedIncomingCall",
3459
3515
  "failedIncomingCall"
3460
- ], dn = () => new O(Me);
3461
- var hn = /* @__PURE__ */ ((n) => (n.IDLE = "incoming:idle", n.RINGING = "incoming:ringing", n.CONSUMED = "incoming:consumed", n.DECLINED = "incoming:declined", n.TERMINATED = "incoming:terminated", n.FAILED = "incoming:failed", n))(hn || {});
3462
- const gn = $({
3516
+ ], Tn = () => new M(ve);
3517
+ var En = /* @__PURE__ */ ((n) => (n.IDLE = "incoming:idle", n.RINGING = "incoming:ringing", n.CONSUMED = "incoming:consumed", n.DECLINED = "incoming:declined", n.TERMINATED = "incoming:terminated", n.FAILED = "incoming:failed", n))(En || {});
3518
+ const Cn = $({
3463
3519
  types: {
3464
3520
  context: {},
3465
3521
  events: {}
3466
3522
  },
3467
3523
  actions: {
3468
3524
  logTransition: (n, e) => {
3469
- l(`State transition: ${e.from} -> ${e.to} (${e.event})`);
3525
+ d(`State transition: ${e.from} -> ${e.to} (${e.event})`);
3470
3526
  },
3471
3527
  logStateChange: (n, e) => {
3472
- l("IncomingCallStateMachine state changed", e.state);
3528
+ d("IncomingCallStateMachine state changed", e.state);
3473
3529
  },
3474
3530
  rememberIncoming: b(({ event: n }) => {
3475
3531
  const { data: e } = n;
@@ -3791,9 +3847,9 @@ const gn = $({
3791
3847
  }
3792
3848
  }
3793
3849
  });
3794
- class un extends q {
3850
+ class Sn extends q {
3795
3851
  constructor({ incomingEvents: e, connectionEvents: t }) {
3796
- super(gn), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
3852
+ super(Cn), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
3797
3853
  }
3798
3854
  get isIdle() {
3799
3855
  return this.state === "incoming:idle";
@@ -3878,14 +3934,14 @@ class un extends q {
3878
3934
  this.send({ type: "INCOMING.CLEAR" });
3879
3935
  }
3880
3936
  }
3881
- const Tn = 486, En = 487;
3882
- class Cn {
3937
+ const pn = 486, mn = 487;
3938
+ class Nn {
3883
3939
  events;
3884
3940
  incomingStateMachine;
3885
3941
  incomingRTCSession;
3886
3942
  connectionManager;
3887
3943
  constructor(e) {
3888
- this.connectionManager = e, this.events = dn(), this.incomingStateMachine = new un({
3944
+ this.connectionManager = e, this.events = Tn(), this.incomingStateMachine = new Sn({
3889
3945
  incomingEvents: this.events,
3890
3946
  connectionEvents: this.connectionManager.events
3891
3947
  }), this.start();
@@ -3921,7 +3977,7 @@ class Cn {
3921
3977
  return this.incomingStateMachine.toConsumed(), this.removeIncomingSession(), e;
3922
3978
  };
3923
3979
  async declineToIncomingCall({
3924
- statusCode: e = En
3980
+ statusCode: e = mn
3925
3981
  } = {}) {
3926
3982
  return new Promise((t, s) => {
3927
3983
  try {
@@ -3933,7 +3989,7 @@ class Cn {
3933
3989
  });
3934
3990
  }
3935
3991
  async busyIncomingCall() {
3936
- return this.declineToIncomingCall({ statusCode: Tn });
3992
+ return this.declineToIncomingCall({ statusCode: pn });
3937
3993
  }
3938
3994
  on(e, t) {
3939
3995
  return this.events.on(e, t);
@@ -3973,24 +4029,24 @@ class Cn {
3973
4029
  delete this.incomingRTCSession;
3974
4030
  }
3975
4031
  }
3976
- const Sn = (n, e) => Object.is(n, e), ne = (n) => ({
4032
+ const Rn = (n, e) => Object.is(n, e), se = (n) => ({
3977
4033
  connection: n.connection.getSnapshot(),
3978
4034
  call: n.call.getSnapshot(),
3979
4035
  incoming: n.incoming.getSnapshot(),
3980
4036
  presentation: n.presentation.getSnapshot()
3981
- }), pn = (n) => {
4037
+ }), An = (n) => {
3982
4038
  const e = {
3983
4039
  connection: n.connectionManager.connectionActor,
3984
4040
  call: n.callManager.callActor,
3985
4041
  incoming: n.incomingCallManager.incomingActor,
3986
4042
  presentation: n.presentationManager.presentationActor
3987
4043
  };
3988
- let t = ne(e);
4044
+ let t = se(e);
3989
4045
  const s = /* @__PURE__ */ new Set(), i = () => {
3990
- t = ne(e);
3991
- for (const a of s) {
3992
- const c = a.selector(t);
3993
- a.equals(a.current, c) || (a.current = c, a.listener(c));
4046
+ t = se(e);
4047
+ for (const o of s) {
4048
+ const c = o.selector(t);
4049
+ o.equals(o.current, c) || (o.current = c, o.listener(c));
3994
4050
  }
3995
4051
  }, r = [
3996
4052
  e.connection.subscribe(i),
@@ -3998,8 +4054,8 @@ const Sn = (n, e) => Object.is(n, e), ne = (n) => ({
3998
4054
  e.incoming.subscribe(i),
3999
4055
  e.presentation.subscribe(i)
4000
4056
  ];
4001
- function o(a, c, d) {
4002
- const T = typeof c == "function", h = T ? a : (D) => D, u = T ? c : a, p = (T ? d : void 0) ?? Sn, A = h(t), N = {
4057
+ function a(o, c, l) {
4058
+ const T = typeof c == "function", h = T ? o : (D) => D, u = T ? c : o, p = (T ? l : void 0) ?? Rn, A = h(t), N = {
4003
4059
  selector: h,
4004
4060
  listener: u,
4005
4061
  equals: p,
@@ -4013,48 +4069,51 @@ const Sn = (n, e) => Object.is(n, e), ne = (n) => ({
4013
4069
  actor: e,
4014
4070
  actors: e,
4015
4071
  getSnapshot: () => t,
4016
- subscribe: o,
4072
+ subscribe: a,
4017
4073
  stop: () => {
4018
- s.clear(), r.forEach((a) => {
4019
- a.unsubscribe();
4074
+ s.clear(), r.forEach((o) => {
4075
+ o.unsubscribe();
4020
4076
  });
4021
4077
  }
4022
4078
  };
4023
4079
  }, w = 1e3;
4024
4080
  var m = /* @__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))(m || {});
4025
- const ve = ["collected"], mn = () => new O(ve), Nn = "api/v2/rtp2webrtc/offer", Rn = async ({
4081
+ const _e = ["collected"], In = () => new M(_e), fn = "api/v2/rtp2webrtc/offer", Mn = async ({
4026
4082
  serverUrl: n,
4027
4083
  conferenceNumber: e,
4028
4084
  quality: t,
4029
4085
  audio: s,
4030
- offer: i
4086
+ offer: i,
4087
+ token: r
4031
4088
  }) => {
4032
- const r = new URL(
4033
- `https://${n.replace(/\/$/, "")}/${Nn}/${encodeURIComponent(e)}`
4089
+ const a = new URL(
4090
+ `https://${n.replace(/\/$/, "")}/${fn}/${encodeURIComponent(e)}`
4034
4091
  );
4035
- r.searchParams.set("quality", t), r.searchParams.set("audio", String(s));
4036
- const o = await fetch(r.toString(), {
4092
+ a.searchParams.set("quality", t), a.searchParams.set("audio", String(s));
4093
+ const o = {
4094
+ "Content-Type": "application/json"
4095
+ };
4096
+ r !== void 0 && r !== "" && (o.Authorization = `Bearer ${r}`);
4097
+ const c = await fetch(a.toString(), {
4037
4098
  method: "POST",
4038
- headers: {
4039
- "Content-Type": "application/json"
4040
- },
4099
+ headers: o,
4041
4100
  credentials: "same-origin",
4042
4101
  body: JSON.stringify(i)
4043
4102
  });
4044
- if (!o.ok)
4045
- throw new Error(`sendOffer failed with status ${o.status}`);
4046
- const a = await o.json();
4103
+ if (!c.ok)
4104
+ throw new Error(`sendOffer failed with status ${c.status}`);
4105
+ const l = await c.json();
4047
4106
  return {
4048
- type: a.type,
4049
- sdp: a.sdp,
4107
+ type: l.type,
4108
+ sdp: l.sdp,
4050
4109
  toJSON() {
4051
- return a;
4110
+ return l;
4052
4111
  }
4053
4112
  };
4054
- }, se = () => "performance" in window ? performance.now() : Date.now(), F = (n) => [...n.keys()].reduce((e, t) => {
4113
+ }, ie = () => "performance" in window ? performance.now() : Date.now(), F = (n) => [...n.keys()].reduce((e, t) => {
4055
4114
  const s = n.get(t);
4056
4115
  return s === void 0 ? e : { ...e, [s.type]: s };
4057
- }, {}), An = (n) => {
4116
+ }, {}), vn = (n) => {
4058
4117
  if (!n)
4059
4118
  return {
4060
4119
  outboundRtp: void 0,
@@ -4069,7 +4128,7 @@ const ve = ["collected"], mn = () => new O(ve), Nn = "api/v2/rtp2webrtc/offer",
4069
4128
  mediaSource: e[m.MEDIA_SOURCE],
4070
4129
  remoteInboundRtp: e[m.REMOTE_INBOUND_RTP]
4071
4130
  };
4072
- }, ie = (n) => {
4131
+ }, re = (n) => {
4073
4132
  if (!n)
4074
4133
  return {
4075
4134
  outboundRtp: void 0,
@@ -4084,7 +4143,7 @@ const ve = ["collected"], mn = () => new O(ve), Nn = "api/v2/rtp2webrtc/offer",
4084
4143
  mediaSource: e[m.MEDIA_SOURCE],
4085
4144
  remoteInboundRtp: e[m.REMOTE_INBOUND_RTP]
4086
4145
  };
4087
- }, re = ({
4146
+ }, ae = ({
4088
4147
  videoReceiversStats: n,
4089
4148
  synchronizationSourcesVideo: e
4090
4149
  }) => {
@@ -4100,7 +4159,7 @@ const ve = ["collected"], mn = () => new O(ve), Nn = "api/v2/rtp2webrtc/offer",
4100
4159
  codec: t[m.CODEC],
4101
4160
  synchronizationSources: e
4102
4161
  };
4103
- }, In = ({
4162
+ }, _n = ({
4104
4163
  audioReceiverStats: n,
4105
4164
  synchronizationSourcesAudio: e
4106
4165
  }) => {
@@ -4118,7 +4177,7 @@ const ve = ["collected"], mn = () => new O(ve), Nn = "api/v2/rtp2webrtc/offer",
4118
4177
  remoteOutboundRtp: t[m.REMOTE_OUTBOUND_RTP],
4119
4178
  synchronizationSources: e
4120
4179
  };
4121
- }, _e = (n) => {
4180
+ }, Oe = (n) => {
4122
4181
  if (!n)
4123
4182
  return {
4124
4183
  candidatePair: void 0,
@@ -4135,77 +4194,77 @@ const ve = ["collected"], mn = () => new O(ve), Nn = "api/v2/rtp2webrtc/offer",
4135
4194
  remoteCandidate: e[m.REMOTE_CANDIDATE],
4136
4195
  transport: e[m.TRANSPORT]
4137
4196
  };
4138
- }, fn = ({
4197
+ }, On = ({
4139
4198
  audioSenderStats: n,
4140
4199
  videoSenderFirstStats: e,
4141
4200
  videoSenderSecondStats: t
4142
4201
  }) => ({
4143
- video: ie(e),
4144
- secondVideo: ie(t),
4145
- audio: An(n),
4146
- additional: _e(
4202
+ video: re(e),
4203
+ secondVideo: re(t),
4204
+ audio: vn(n),
4205
+ additional: Oe(
4147
4206
  n ?? e ?? t
4148
4207
  )
4149
- }), Mn = ({
4208
+ }), Pn = ({
4150
4209
  audioReceiverStats: n,
4151
4210
  videoReceiverFirstStats: e,
4152
4211
  videoReceiverSecondStats: t,
4153
4212
  synchronizationSources: s
4154
4213
  }) => ({
4155
- video: re({
4214
+ video: ae({
4156
4215
  videoReceiversStats: e,
4157
4216
  synchronizationSourcesVideo: s.video
4158
4217
  }),
4159
- secondVideo: re({
4218
+ secondVideo: ae({
4160
4219
  videoReceiversStats: t,
4161
4220
  synchronizationSourcesVideo: s.video
4162
4221
  }),
4163
- audio: In({
4222
+ audio: _n({
4164
4223
  audioReceiverStats: n,
4165
4224
  synchronizationSourcesAudio: s.audio
4166
4225
  }),
4167
- additional: _e(
4226
+ additional: Oe(
4168
4227
  n ?? e ?? t
4169
4228
  )
4170
- }), vn = ({
4229
+ }), bn = ({
4171
4230
  audioSenderStats: n,
4172
4231
  videoSenderFirstStats: e,
4173
4232
  videoSenderSecondStats: t,
4174
4233
  audioReceiverStats: s,
4175
4234
  videoReceiverFirstStats: i,
4176
4235
  videoReceiverSecondStats: r,
4177
- synchronizationSources: o
4236
+ synchronizationSources: a
4178
4237
  }) => {
4179
- const a = fn({
4238
+ const o = On({
4180
4239
  audioSenderStats: n,
4181
4240
  videoSenderFirstStats: e,
4182
4241
  videoSenderSecondStats: t
4183
- }), c = Mn({
4242
+ }), c = Pn({
4184
4243
  audioReceiverStats: s,
4185
4244
  videoReceiverFirstStats: i,
4186
4245
  videoReceiverSecondStats: r,
4187
- synchronizationSources: o
4246
+ synchronizationSources: a
4188
4247
  });
4189
4248
  return {
4190
- outbound: a,
4249
+ outbound: o,
4191
4250
  inbound: c
4192
4251
  };
4193
- }, _n = async (n) => {
4194
- const e = "audio", t = "video", s = n.getSenders(), i = s.find((u) => u.track?.kind === e), r = s.filter((u) => u.track?.kind === t), o = n.getReceivers(), a = o.find((u) => u.track.kind === e), c = o.filter((u) => u.track.kind === t), d = {
4195
- trackIdentifier: a?.track.id,
4196
- item: a?.getSynchronizationSources()[0]
4252
+ }, Dn = async (n) => {
4253
+ const e = "audio", t = "video", s = n.getSenders(), i = s.find((u) => u.track?.kind === e), r = s.filter((u) => u.track?.kind === t), a = n.getReceivers(), o = a.find((u) => u.track.kind === e), c = a.filter((u) => u.track.kind === t), l = {
4254
+ trackIdentifier: o?.track.id,
4255
+ item: o?.getSynchronizationSources()[0]
4197
4256
  }, T = {
4198
4257
  trackIdentifier: c[0]?.track.id,
4199
4258
  item: c[0]?.getSynchronizationSources()[0]
4200
4259
  }, h = {
4201
- audio: d,
4260
+ audio: l,
4202
4261
  video: T
4203
4262
  };
4204
4263
  return Promise.all([
4205
4264
  i?.getStats() ?? Promise.resolve(void 0),
4206
4265
  r[0]?.getStats() ?? Promise.resolve(void 0),
4207
4266
  r[1]?.getStats() ?? Promise.resolve(void 0),
4208
- a?.getStats() ?? Promise.resolve(void 0),
4267
+ o?.getStats() ?? Promise.resolve(void 0),
4209
4268
  c[0]?.getStats() ?? Promise.resolve(void 0),
4210
4269
  c[1]?.getStats() ?? Promise.resolve(void 0)
4211
4270
  ]).then((u) => {
@@ -4215,7 +4274,7 @@ const ve = ["collected"], mn = () => new O(ve), Nn = "api/v2/rtp2webrtc/offer",
4215
4274
  N,
4216
4275
  D,
4217
4276
  V,
4218
- Le
4277
+ we
4219
4278
  ] = u;
4220
4279
  return {
4221
4280
  synchronizationSources: h,
@@ -4224,25 +4283,25 @@ const ve = ["collected"], mn = () => new O(ve), Nn = "api/v2/rtp2webrtc/offer",
4224
4283
  videoSenderSecondStats: N,
4225
4284
  audioReceiverStats: D,
4226
4285
  videoReceiverFirstStats: V,
4227
- videoReceiverSecondStats: Le
4286
+ videoReceiverSecondStats: we
4228
4287
  };
4229
4288
  });
4230
- }, On = (n) => {
4231
- l(String(n));
4289
+ }, yn = (n) => {
4290
+ d(String(n));
4232
4291
  };
4233
- class Pn {
4292
+ class Ln {
4234
4293
  events;
4235
4294
  setTimeoutRequest;
4236
- requesterAllStatistics = new G(_n);
4295
+ requesterAllStatistics = new G(Dn);
4237
4296
  constructor() {
4238
- this.events = mn(), this.setTimeoutRequest = new oe();
4297
+ this.events = In(), this.setTimeoutRequest = new ce();
4239
4298
  }
4240
4299
  get requested() {
4241
4300
  return this.setTimeoutRequest.requested;
4242
4301
  }
4243
4302
  start(e, {
4244
4303
  interval: t = w,
4245
- onError: s = On
4304
+ onError: s = yn
4246
4305
  } = {}) {
4247
4306
  this.stop(), this.setTimeoutRequest.request(() => {
4248
4307
  this.collectStatistics(e, {
@@ -4271,21 +4330,21 @@ class Pn {
4271
4330
  collectStatistics = (e, {
4272
4331
  onError: t
4273
4332
  }) => {
4274
- const s = se();
4333
+ const s = ie();
4275
4334
  this.requesterAllStatistics.request(e).then((i) => {
4276
- this.events.trigger("collected", vn(i));
4277
- const o = se() - s;
4278
- let a = w;
4279
- o > 48 ? a = w * 4 : o > 32 ? a = w * 3 : o > 16 && (a = w * 2), this.start(e, {
4335
+ this.events.trigger("collected", bn(i));
4336
+ const a = ie() - s;
4337
+ let o = w;
4338
+ a > 48 ? o = w * 4 : a > 32 ? o = w * 3 : a > 16 && (o = w * 2), this.start(e, {
4280
4339
  onError: t,
4281
- interval: a
4340
+ interval: o
4282
4341
  });
4283
4342
  }).catch((i) => {
4284
4343
  t && t(i);
4285
4344
  });
4286
4345
  };
4287
4346
  }
4288
- class bn {
4347
+ class wn {
4289
4348
  statsPeerConnection;
4290
4349
  availableStats;
4291
4350
  previousAvailableStats;
@@ -4295,7 +4354,7 @@ class bn {
4295
4354
  callManager: e,
4296
4355
  apiManager: t
4297
4356
  }) {
4298
- this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Pn(), this.subscribe();
4357
+ this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Ln(), this.subscribe();
4299
4358
  }
4300
4359
  get events() {
4301
4360
  return this.statsPeerConnection.events;
@@ -4368,36 +4427,36 @@ class bn {
4368
4427
  };
4369
4428
  maybeSendStats() {
4370
4429
  this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
4371
- l("Failed to send stats", e);
4430
+ d("Failed to send stats", e);
4372
4431
  });
4373
4432
  }
4374
4433
  }
4375
- const Dn = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), yn = (n) => {
4434
+ const Un = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), Fn = (n) => {
4376
4435
  const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
4377
- return Dn(s, i);
4378
- }, Ln = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
4379
- const i = e.indexOf(t.mimeType), r = e.indexOf(s.mimeType), o = i === -1 ? Number.MAX_VALUE : i, a = r === -1 ? Number.MAX_VALUE : r;
4380
- return o - a;
4381
- }), wn = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Un = (n, {
4436
+ return Un(s, i);
4437
+ }, Bn = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
4438
+ 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;
4439
+ return a - o;
4440
+ }), kn = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Gn = (n, {
4382
4441
  preferredMimeTypesVideoCodecs: e,
4383
4442
  excludeMimeTypesVideoCodecs: t
4384
4443
  }) => {
4385
4444
  try {
4386
4445
  if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
4387
- const s = yn("video"), i = wn(s, t), r = Ln(i, e);
4446
+ const s = Fn("video"), i = kn(s, t), r = Bn(i, e);
4388
4447
  n.setCodecPreferences(r);
4389
4448
  }
4390
4449
  } catch (s) {
4391
- l("setCodecPreferences error", s);
4450
+ d("setCodecPreferences error", s);
4392
4451
  }
4393
- }, Fn = (n) => [...n.keys()].map((e) => n.get(e)), Bn = (n, e) => Fn(n).find((t) => t?.type === e), kn = async (n) => n.getStats().then((e) => Bn(e, "codec")?.mimeType);
4394
- class Gn {
4452
+ }, $n = (n) => [...n.keys()].map((e) => n.get(e)), qn = (n, e) => $n(n).find((t) => t?.type === e), Vn = async (n) => n.getStats().then((e) => qn(e, "codec")?.mimeType);
4453
+ class Hn {
4395
4454
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
4396
4455
  async getCodecFromSender(e) {
4397
- return await kn(e) ?? "";
4456
+ return await Vn(e) ?? "";
4398
4457
  }
4399
4458
  }
4400
- class $n {
4459
+ class Wn {
4401
4460
  stackPromises = le({
4402
4461
  noRunIsNotActual: !0
4403
4462
  });
@@ -4418,34 +4477,34 @@ class $n {
4418
4477
  */
4419
4478
  async run() {
4420
4479
  return this.stackPromises().catch((e) => {
4421
- l("TaskQueue: error", e);
4480
+ d("TaskQueue: error", e);
4422
4481
  });
4423
4482
  }
4424
4483
  }
4425
- class qn {
4484
+ class xn {
4426
4485
  taskQueue;
4427
4486
  onSetParameters;
4428
4487
  constructor(e) {
4429
- this.onSetParameters = e, this.taskQueue = new $n();
4488
+ this.onSetParameters = e, this.taskQueue = new Wn();
4430
4489
  }
4431
4490
  async setEncodingsToSender(e, t) {
4432
- return this.taskQueue.add(async () => Se(e, t, this.onSetParameters));
4491
+ return this.taskQueue.add(async () => pe(e, t, this.onSetParameters));
4433
4492
  }
4434
4493
  stop() {
4435
4494
  this.taskQueue.stop();
4436
4495
  }
4437
4496
  }
4438
- const Oe = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Vn = 1e6, M = (n) => n * Vn, Pe = M(0.06), be = M(4), Hn = (n) => n <= 64 ? Pe : 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) : be, Wn = "av1", xn = (n) => Oe(n, Wn), Qn = 0.6, K = (n, e) => xn(e) ? n * Qn : n, Yn = (n) => K(Pe, n), zn = (n) => K(be, n), ae = (n, e) => {
4439
- const t = Hn(n);
4440
- return K(t, e);
4441
- }, W = 1, Xn = ({
4497
+ const Pe = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Qn = 1e6, v = (n) => n * Qn, be = v(0.06), De = v(4), Yn = (n) => n <= 64 ? be : n <= 128 ? v(0.12) : n <= 256 ? v(0.25) : n <= 384 ? v(0.32) : n <= 426 ? v(0.38) : n <= 640 ? v(0.5) : n <= 848 ? v(0.7) : n <= 1280 ? v(1) : n <= 1920 ? v(2) : De, zn = "av1", Xn = (n) => Pe(n, zn), Jn = 0.6, j = (n, e) => Xn(e) ? n * Jn : n, Kn = (n) => j(be, n), jn = (n) => j(De, n), oe = (n, e) => {
4498
+ const t = Yn(n);
4499
+ return j(t, e);
4500
+ }, W = 1, Zn = ({
4442
4501
  videoTrack: n,
4443
4502
  targetSize: e
4444
4503
  }) => {
4445
- const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? W : s / e.width, o = i === void 0 ? W : i / e.height;
4446
- return Math.max(r, o, W);
4504
+ const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? W : s / e.width, a = i === void 0 ? W : i / e.height;
4505
+ return Math.max(r, a, W);
4447
4506
  };
4448
- class Jn {
4507
+ class es {
4449
4508
  ignoreForCodec;
4450
4509
  senderFinder;
4451
4510
  codecProvider;
@@ -4478,11 +4537,11 @@ class Jn {
4478
4537
  if (!i?.track)
4479
4538
  return { ...this.resultNoChanged, sender: i };
4480
4539
  const r = await this.codecProvider.getCodecFromSender(i);
4481
- if (Oe(r, this.ignoreForCodec))
4540
+ if (Pe(r, this.ignoreForCodec))
4482
4541
  return { ...this.resultNoChanged, sender: i };
4483
- const { mainCam: o, resolutionMainCam: a } = t ?? {};
4542
+ const { mainCam: a, resolutionMainCam: o } = t ?? {};
4484
4543
  return this.processSender(
4485
- { mainCam: o, resolutionMainCam: a },
4544
+ { mainCam: a, resolutionMainCam: o },
4486
4545
  {
4487
4546
  sender: i,
4488
4547
  codec: r,
@@ -4498,14 +4557,14 @@ class Jn {
4498
4557
  async processSender(e, t) {
4499
4558
  const { mainCam: s, resolutionMainCam: i } = e;
4500
4559
  switch (s) {
4501
- case v.PAUSE_MAIN_CAM:
4560
+ case _.PAUSE_MAIN_CAM:
4502
4561
  return this.downgradeResolutionSender(t);
4503
- case v.RESUME_MAIN_CAM:
4562
+ case _.RESUME_MAIN_CAM:
4504
4563
  return this.setBitrateByTrackResolution(t);
4505
- case v.MAX_MAIN_CAM_RESOLUTION:
4564
+ case _.MAX_MAIN_CAM_RESOLUTION:
4506
4565
  return i !== void 0 ? this.setResolutionSender(i, t) : this.setBitrateByTrackResolution(t);
4507
- case v.ADMIN_STOP_MAIN_CAM:
4508
- case v.ADMIN_START_MAIN_CAM:
4566
+ case _.ADMIN_STOP_MAIN_CAM:
4567
+ case _.ADMIN_START_MAIN_CAM:
4509
4568
  case void 0:
4510
4569
  return this.setBitrateByTrackResolution(t);
4511
4570
  default:
@@ -4520,7 +4579,7 @@ class Jn {
4520
4579
  async downgradeResolutionSender(e) {
4521
4580
  const { sender: t, codec: s } = e, i = {
4522
4581
  scaleResolutionDownBy: 200,
4523
- maxBitrate: Yn(s)
4582
+ maxBitrate: Kn(s)
4524
4583
  };
4525
4584
  return this.parametersSetter.setEncodingsToSender(t, i);
4526
4585
  }
@@ -4530,10 +4589,10 @@ class Jn {
4530
4589
  * @returns Promise с результатом
4531
4590
  */
4532
4591
  async setBitrateByTrackResolution(e) {
4533
- const { sender: t, videoTrack: s, codec: i } = e, o = s.getSettings().width, a = o === void 0 ? zn(i) : ae(o, i);
4592
+ const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? jn(i) : oe(a, i);
4534
4593
  return this.parametersSetter.setEncodingsToSender(t, {
4535
4594
  scaleResolutionDownBy: 1,
4536
- maxBitrate: a
4595
+ maxBitrate: o
4537
4596
  });
4538
4597
  }
4539
4598
  /**
@@ -4543,27 +4602,27 @@ class Jn {
4543
4602
  * @returns Promise с результатом
4544
4603
  */
4545
4604
  async setResolutionSender(e, t) {
4546
- const [s, i] = e.split("x"), { sender: r, videoTrack: o, codec: a } = t, c = {
4605
+ const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
4547
4606
  width: Number(s),
4548
4607
  height: Number(i)
4549
- }, d = Xn({
4550
- videoTrack: o,
4608
+ }, l = Zn({
4609
+ videoTrack: a,
4551
4610
  targetSize: c
4552
- }), T = ae(c.width, a), h = {
4553
- scaleResolutionDownBy: d,
4611
+ }), T = oe(c.width, o), h = {
4612
+ scaleResolutionDownBy: l,
4554
4613
  maxBitrate: T
4555
4614
  };
4556
4615
  return this.parametersSetter.setEncodingsToSender(r, h);
4557
4616
  }
4558
4617
  }
4559
- const Kn = (n) => n.find((e) => e.track?.kind === "video");
4560
- class jn {
4618
+ const ts = (n) => n.find((e) => e.track?.kind === "video");
4619
+ class ns {
4561
4620
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
4562
4621
  findVideoSender(e) {
4563
- return Kn(e);
4622
+ return ts(e);
4564
4623
  }
4565
4624
  }
4566
- class Zn {
4625
+ class ss {
4567
4626
  currentSender;
4568
4627
  originalReplaceTrack;
4569
4628
  lastWidth;
@@ -4576,7 +4635,7 @@ class Zn {
4576
4635
  pollIntervalMs: e = 1e3,
4577
4636
  maxPollIntervalMs: t
4578
4637
  }) {
4579
- this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new oe();
4638
+ this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ce();
4580
4639
  }
4581
4640
  /**
4582
4641
  * Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
@@ -4627,7 +4686,7 @@ class Zn {
4627
4686
  this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
4628
4687
  }
4629
4688
  }
4630
- class es {
4689
+ class is {
4631
4690
  apiManager;
4632
4691
  currentHandler;
4633
4692
  constructor(e) {
@@ -4647,7 +4706,7 @@ class es {
4647
4706
  this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
4648
4707
  }
4649
4708
  }
4650
- class ts {
4709
+ class rs {
4651
4710
  eventHandler;
4652
4711
  senderBalancer;
4653
4712
  parametersSetterWithQueue;
@@ -4659,16 +4718,16 @@ class ts {
4659
4718
  onSetParameters: i,
4660
4719
  pollIntervalMs: r
4661
4720
  } = {}) {
4662
- this.getConnection = t, this.eventHandler = new es(e), this.parametersSetterWithQueue = new qn(i), this.senderBalancer = new Jn(
4721
+ this.getConnection = t, this.eventHandler = new is(e), this.parametersSetterWithQueue = new xn(i), this.senderBalancer = new es(
4663
4722
  {
4664
- senderFinder: new jn(),
4665
- codecProvider: new Gn(),
4723
+ senderFinder: new ns(),
4724
+ codecProvider: new Hn(),
4666
4725
  parametersSetter: this.parametersSetterWithQueue
4667
4726
  },
4668
4727
  {
4669
4728
  ignoreForCodec: s
4670
4729
  }
4671
- ), this.trackMonitor = new Zn({ pollIntervalMs: r });
4730
+ ), this.trackMonitor = new ss({ pollIntervalMs: r });
4672
4731
  }
4673
4732
  /**
4674
4733
  * Подписывается на события управления главной камерой
@@ -4699,7 +4758,7 @@ class ts {
4699
4758
  const t = await this.senderBalancer.balance(e, this.serverHeaders);
4700
4759
  return this.trackMonitor.subscribe(t.sender, () => {
4701
4760
  this.balance().catch((s) => {
4702
- l("balance on track change: error", s);
4761
+ d("balance on track change: error", s);
4703
4762
  });
4704
4763
  }), t;
4705
4764
  }
@@ -4709,17 +4768,17 @@ class ts {
4709
4768
  */
4710
4769
  handleMainCamControl = (e) => {
4711
4770
  this.serverHeaders = e, this.balance().catch((t) => {
4712
- l("handleMainCamControl: error", t);
4771
+ d("handleMainCamControl: error", t);
4713
4772
  });
4714
4773
  };
4715
4774
  }
4716
- const De = [
4775
+ const ye = [
4717
4776
  "balancing-scheduled",
4718
4777
  "balancing-started",
4719
4778
  "balancing-stopped",
4720
4779
  "parameters-updated"
4721
- ], ns = () => new O(De);
4722
- class ss {
4780
+ ], as = () => new M(ye);
4781
+ class os {
4723
4782
  isBalancingActive = !1;
4724
4783
  events;
4725
4784
  callManager;
@@ -4727,7 +4786,7 @@ class ss {
4727
4786
  videoSendingBalancer;
4728
4787
  startBalancingTimer;
4729
4788
  constructor(e, t, s = {}) {
4730
- this.events = ns(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new ts(
4789
+ this.events = as(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new rs(
4731
4790
  t,
4732
4791
  () => e.connection,
4733
4792
  {
@@ -4789,7 +4848,7 @@ class ss {
4789
4848
  scheduleBalancingStart() {
4790
4849
  this.clearStartTimer(), this.startBalancingTimer = setTimeout(() => {
4791
4850
  this.startBalancingTimer = void 0, this.startBalancing().catch((e) => {
4792
- l("startBalancing: error", e);
4851
+ d("startBalancing: error", e);
4793
4852
  });
4794
4853
  }, this.balancingStartDelay), this.events.trigger("balancing-scheduled", { delay: this.balancingStartDelay });
4795
4854
  }
@@ -4797,13 +4856,13 @@ class ss {
4797
4856
  this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
4798
4857
  }
4799
4858
  }
4800
- const ye = "no-inbound-frames", is = [ye], rs = () => new O(is);
4801
- class as {
4859
+ const Le = "no-inbound-frames", cs = [Le], ds = () => new M(cs);
4860
+ class ls {
4802
4861
  events;
4803
4862
  statsManager;
4804
4863
  callManager;
4805
4864
  constructor(e, t) {
4806
- this.statsManager = e, this.callManager = t, this.events = rs(), this.subscribe();
4865
+ this.statsManager = e, this.callManager = t, this.events = ds(), this.subscribe();
4807
4866
  }
4808
4867
  get mainVideoTrack() {
4809
4868
  return this.callManager.getMainStream()?.getVideoTracks()[0];
@@ -4816,36 +4875,36 @@ class as {
4816
4875
  return this.events.on(e, t);
4817
4876
  }
4818
4877
  handleStatsCollected = () => {
4819
- this.hasNoIncomingFrames() && this.events.trigger(ye, {});
4878
+ this.hasNoIncomingFrames() && this.events.trigger(Le, {});
4820
4879
  };
4821
4880
  hasNoIncomingFrames = () => this.statsManager.isNotValidFramesStats && this.isMutedMainVideoTrack;
4822
4881
  subscribe() {
4823
4882
  this.statsManager.on("collected", this.handleStatsCollected);
4824
4883
  }
4825
4884
  }
4826
- const os = 3e3;
4827
- class cs {
4885
+ const hs = 3e3;
4886
+ class gs {
4828
4887
  renegotiateRequester;
4829
4888
  renegotiateThrottled;
4830
4889
  callManager;
4831
- constructor(e, t = os) {
4832
- this.callManager = e, this.renegotiateRequester = new G(e.renegotiate.bind(e)), this.renegotiateThrottled = Ve.throttle(
4890
+ constructor(e, t = hs) {
4891
+ this.callManager = e, this.renegotiateRequester = new G(e.renegotiate.bind(e)), this.renegotiateThrottled = He.throttle(
4833
4892
  this.requestRenegotiate.bind(this),
4834
4893
  t
4835
4894
  ), this.subscribe();
4836
4895
  }
4837
4896
  recover() {
4838
- l("trying to recover main stream"), this.renegotiateThrottled();
4897
+ d("trying to recover main stream"), this.renegotiateThrottled();
4839
4898
  }
4840
4899
  requestRenegotiate = () => {
4841
- if (l("trying to renegotiate"), this.renegotiateRequester.requested) {
4842
- l("previous renegotiate is not finished yet");
4900
+ if (d("trying to renegotiate"), this.renegotiateRequester.requested) {
4901
+ d("previous renegotiate is not finished yet");
4843
4902
  return;
4844
4903
  }
4845
4904
  this.renegotiateRequester.request().then(() => {
4846
- l("renegotiate has successful");
4905
+ d("renegotiate has successful");
4847
4906
  }).catch((e) => {
4848
- l("failed to renegotiate main media stream", e);
4907
+ d("failed to renegotiate main media stream", e);
4849
4908
  });
4850
4909
  };
4851
4910
  subscribe() {
@@ -4854,28 +4913,29 @@ class cs {
4854
4913
  });
4855
4914
  }
4856
4915
  cancel() {
4857
- l("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
4916
+ d("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
4858
4917
  }
4859
4918
  }
4860
- const ls = 1e6, ds = fe.map((n) => `auto-connect:${n}`), hs = Ne.map((n) => `connection:${n}`), gs = ge.map((n) => `call:${n}`), us = de.map((n) => `api:${n}`), Ts = Me.map((n) => `incoming-call:${n}`), Es = pe.map((n) => `presentation:${n}`), Cs = ve.map((n) => `stats:${n}`), Ss = De.map((n) => `video-balancer:${n}`), ps = [
4919
+ const us = 1e6, Ts = Me.map((n) => `auto-connect:${n}`), Es = Re.map((n) => `connection:${n}`), Cs = ue.map((n) => `call:${n}`), Ss = he.map((n) => `api:${n}`), ps = ve.map((n) => `incoming-call:${n}`), ms = me.map((n) => `presentation:${n}`), Ns = _e.map((n) => `stats:${n}`), Rs = ye.map((n) => `video-balancer:${n}`), As = [
4861
4920
  "disconnected-from-out-of-call",
4862
4921
  "connected-with-configuration-from-out-of-call",
4863
4922
  "stopped-presentation-by-server-command"
4864
- ], ms = [
4865
- ...ds,
4866
- ...hs,
4867
- ...gs,
4868
- ...us,
4923
+ ], Is = [
4869
4924
  ...Ts,
4870
4925
  ...Es,
4871
4926
  ...Cs,
4872
4927
  ...Ss,
4873
- ...ps
4874
- ], Ns = () => new O(ms);
4875
- class ws {
4928
+ ...ps,
4929
+ ...ms,
4930
+ ...Ns,
4931
+ ...Rs,
4932
+ ...As
4933
+ ], fs = () => new M(Is);
4934
+ class ks {
4876
4935
  events;
4877
4936
  connectionManager;
4878
4937
  connectionQueueManager;
4938
+ conferenceStateManager;
4879
4939
  callManager;
4880
4940
  autoConnectorManager;
4881
4941
  apiManager;
@@ -4894,15 +4954,15 @@ class ws {
4894
4954
  videoBalancerOptions: i,
4895
4955
  autoConnectorOptions: r
4896
4956
  } = {}) {
4897
- this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = Ns(), this.connectionManager = new Yt({ JsSIP: e }), this.connectionQueueManager = new zt({
4957
+ this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = fs(), this.connectionManager = new zt({ JsSIP: e }), this.connectionQueueManager = new Xt({
4898
4958
  connectionManager: this.connectionManager
4899
- }), this.callManager = new lt(), this.apiManager = new Xe({
4959
+ }), this.conferenceStateManager = new un(), this.callManager = new lt(this.conferenceStateManager), this.apiManager = new Je({
4900
4960
  connectionManager: this.connectionManager,
4901
4961
  callManager: this.callManager
4902
- }), this.incomingCallManager = new Cn(this.connectionManager), this.presentationManager = new Ot({
4962
+ }), this.incomingCallManager = new Nn(this.connectionManager), this.presentationManager = new Pt({
4903
4963
  callManager: this.callManager,
4904
- maxBitrate: ls
4905
- }), this.statsManager = new bn({
4964
+ maxBitrate: us
4965
+ }), this.statsManager = new wn({
4906
4966
  callManager: this.callManager,
4907
4967
  apiManager: this.apiManager
4908
4968
  }), this.autoConnectorManager = new ln(
@@ -4912,11 +4972,11 @@ class ws {
4912
4972
  callManager: this.callManager
4913
4973
  },
4914
4974
  r
4915
- ), this.videoSendingBalancerManager = new ss(
4975
+ ), this.videoSendingBalancerManager = new os(
4916
4976
  this.callManager,
4917
4977
  this.apiManager,
4918
4978
  i
4919
- ), this.mainStreamHealthMonitor = new as(this.statsManager, this.callManager), this.mainStreamRecovery = new cs(this.callManager), this.session = pn({
4979
+ ), this.mainStreamHealthMonitor = new ls(this.statsManager, this.callManager), this.mainStreamRecovery = new gs(this.callManager), this.session = An({
4920
4980
  connectionManager: this.connectionManager,
4921
4981
  callManager: this.callManager,
4922
4982
  incomingCallManager: this.incomingCallManager,
@@ -5012,18 +5072,24 @@ class ws {
5012
5072
  };
5013
5073
  declineToIncomingCall = async (...e) => this.incomingCallManager.declineToIncomingCall(...e);
5014
5074
  getEstablishedRTCSession = () => this.callManager.getEstablishedRTCSession();
5015
- getCallConfiguration = () => this.callManager.getCallConfiguration();
5075
+ getCallConfiguration = () => {
5076
+ const e = this.conferenceStateManager.getState();
5077
+ return {
5078
+ number: e.number,
5079
+ answer: e.answer
5080
+ };
5081
+ };
5016
5082
  getRemoteStreams = () => this.callManager.getRemoteStreams();
5017
5083
  replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
5018
5084
  async startPresentation(e, t = {}) {
5019
- const { isP2P: s, callLimit: i, onAddedTransceiver: r, ...o } = t;
5085
+ const { isP2P: s, callLimit: i, onAddedTransceiver: r, ...a } = t;
5020
5086
  return this.presentationManager.startPresentation(
5021
5087
  async () => {
5022
5088
  s === !0 ? (await this.apiManager.sendMustStopPresentationP2P(), await this.apiManager.askPermissionToStartPresentationP2P()) : await this.apiManager.askPermissionToStartPresentation();
5023
5089
  },
5024
5090
  e,
5025
5091
  {
5026
- ...o,
5092
+ ...a,
5027
5093
  onAddedTransceiver: this.resolveHandleAddTransceiver(r)
5028
5094
  },
5029
5095
  i === void 0 ? void 0 : { callLimit: i }
@@ -5113,22 +5179,33 @@ class ws {
5113
5179
  this.callManager.setCallRoleSpectator({ audioId: e, sendOffer: this.sendOffer }), this.mayBeStopPresentationAndNotify();
5114
5180
  }), this.apiManager.on("mustStopPresentation", () => {
5115
5181
  this.mayBeStopPresentationAndNotify();
5182
+ }), this.apiManager.on("enterRoom", ({ room: e, participantName: t }) => {
5183
+ this.conferenceStateManager.updateState({ room: e, participantName: t });
5184
+ }), this.apiManager.on(
5185
+ "conference:participant-token-issued",
5186
+ ({ jwt: e, conference: t, participant: s }) => {
5187
+ this.conferenceStateManager.updateState({ token: e, conference: t, participant: s });
5188
+ }
5189
+ ), this.apiManager.on("channels", (e) => {
5190
+ this.conferenceStateManager.updateState({ channels: e });
5116
5191
  });
5117
5192
  }
5118
5193
  sendOffer = async (e, t) => {
5119
5194
  const i = this.connectionManager.getConnectionConfiguration()?.sipServerUrl;
5120
5195
  if (i === void 0)
5121
5196
  throw new Error("No sipServerUrl for sendOffer");
5122
- return Rn({
5197
+ const r = this.conferenceStateManager.getToken();
5198
+ return Mn({
5123
5199
  serverUrl: i,
5124
5200
  offer: t,
5201
+ token: r,
5125
5202
  conferenceNumber: e.conferenceNumber,
5126
5203
  quality: e.quality,
5127
5204
  audio: e.audioChannel
5128
5205
  });
5129
5206
  };
5130
5207
  setCodecPreferences(e) {
5131
- Un(e, {
5208
+ Gn(e, {
5132
5209
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
5133
5210
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
5134
5211
  });
@@ -5153,24 +5230,24 @@ class ws {
5153
5230
  };
5154
5231
  }
5155
5232
  export {
5156
- ue as E,
5157
- Ze as O,
5158
- ws as S,
5159
- Je as a,
5160
- hn as b,
5161
- Se as c,
5162
- Nt as d,
5163
- Ye as e,
5164
- ys as f,
5165
- Ds as g,
5166
- Wt as h,
5167
- Ls as i,
5233
+ Te as E,
5234
+ et as O,
5235
+ ks as S,
5236
+ Ke as a,
5237
+ En as b,
5238
+ pe as c,
5239
+ Rt as d,
5240
+ ze as e,
5241
+ Fs as f,
5242
+ Us as g,
5243
+ xt as h,
5244
+ Bs as i,
5168
5245
  m as j,
5169
- Pn as k,
5170
- l,
5171
- kn as m,
5172
- kt as n,
5173
- ft as o,
5246
+ Ln as k,
5247
+ d as l,
5248
+ Vn as m,
5249
+ Gt as n,
5250
+ Mt as o,
5174
5251
  k as p,
5175
- Rn as s
5252
+ Mn as s
5176
5253
  };