sip-connector 25.3.0 → 25.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,23 @@
1
- import ie from "debug";
2
- import { TypedEvents as f } from "events-constructor";
3
- import { CancelableRequest as X, isCanceledError as st } from "@krivega/cancelable-promise";
4
- import { resolveRequesterByTimeout as it, requesterByTimeoutsWithFailCalls as rt, DelayRequester as at, hasCanceledError as ot, SetTimeoutRequest as Ae } from "@krivega/timeout-requester";
5
- import { repeatedCallsAsync as re, hasCanceledError as ct } from "repeated-calls";
6
- import { createActor as dt, setup as V, assign as I } from "xstate";
7
- import { createStackPromises as Ie, isPromiseIsNotActualError as ht } from "stack-promises";
1
+ import { IncomingResponse as rt, C as at } from "@krivega/jssip";
2
+ import oe from "debug";
3
+ import { TypedEvents as M } from "events-constructor";
4
+ import { CancelableRequest as X, isCanceledError as ot } from "@krivega/cancelable-promise";
5
+ import { resolveRequesterByTimeout as ct, requesterByTimeoutsWithFailCalls as dt, DelayRequester as ht, hasCanceledError as lt, SetTimeoutRequest as ve } from "@krivega/timeout-requester";
6
+ import { repeatedCallsAsync as ce, hasCanceledError as ut } from "repeated-calls";
7
+ import { createActor as gt, setup as V, assign as v } from "xstate";
8
+ import { createStackPromises as fe, isPromiseIsNotActualError as Tt } from "stack-promises";
8
9
  import "ua-parser-js";
9
10
  import "sequent-promises";
10
- import lt from "lodash";
11
- const ae = "sip-connector", d = ie(ae), he = (n, e) => {
11
+ import Et from "lodash";
12
+ const de = "sip-connector", d = oe(de), ue = (n, e) => {
12
13
  d(`${n}:`, e);
13
- }, bi = () => {
14
- ie.enable(ae);
15
- }, Oi = () => {
16
- ie.enable(`-${ae}`);
17
- }, ut = "Error decline with 603", gt = 1006, Tt = (n) => typeof n == "object" && n !== null && "code" in n && n.code === gt, Et = (n) => n.message === ut;
18
- var Y = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(Y || {}), w = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", 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))(w || {}), O = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.STATS = "application/vinteo.webrtc.stats", n))(O || {}), b = /* @__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))(b || {}), z = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(z || {}), ve = /* @__PURE__ */ ((n) => (n.H264 = "H264", n.VP8 = "VP8", n.VP9 = "VP9", n.AV1 = "AV1", n))(ve || {}), h = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "x-webrtc-use-license", n.PARTICIPANT_NAME = "x-webrtc-participant-name", n.INPUT_CHANNELS = "x-webrtc-input-channels", n.OUTPUT_CHANNELS = "x-webrtc-output-channels", n.MAIN_CAM = "x-webrtc-maincam", n.MIC = "x-webrtc-mic", n.MEDIA_SYNC = "x-webrtc-sync", n.MAIN_CAM_RESOLUTION = "x-webrtc-maincam-resolution", n.MEDIA_STATE = "x-webrtc-media-state", n.MEDIA_TYPE = "x-vinteo-media-type", n.MAIN_CAM_STATE = "x-vinteo-maincam-state", n.MIC_STATE = "x-vinteo-mic-state", n.CONTENT_PARTICIPANT_STATE = "x-webrtc-partstate", n.NOTIFY = "x-vinteo-notify", n.CONTENT_ENABLE_MEDIA_DEVICE = "x-webrtc-request-enable-media-device", n.CONTENTED_STREAM_STATE = "x-webrtc-share-state", n.CONTENTED_STREAM_CODEC = "x-webrtc-share-codec", 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.BEARER_TOKEN = "x-bearer-token", n))(h || {}), q = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(q || {}), F = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: CONTENTEND", n.ACK_PERMISSION_TO_START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.STOPPED_CLIENT_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.ENABLE_MAIN_CAM = "x-webrtc-request-enable-media-device: LETMESTARTMAINCAM", n))(F || {}), J = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(J || {}), fe = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(fe || {}), u = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "enter-room", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "use-license", n.NEW_DTMF = "new-dtmf", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CONTENTED_STREAM_AVAILABLE = "contented-stream:available", n.CONTENTED_STREAM_NOT_AVAILABLE = "contented-stream:not-available", n.PRESENTATION_MUST_STOP = "presentation:must-stop", n.CHANNELS_ALL = "channels:all", n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.ADMIN_START_MAIN_CAM = "admin:start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin:stop-main-cam", n.ADMIN_START_MIC = "admin:start-mic", n.ADMIN_STOP_MIC = "admin:stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin:force-sync-media-state", n))(u || {});
19
- const Me = [
14
+ }, Gi = () => {
15
+ oe.enable(de);
16
+ }, qi = () => {
17
+ oe.enable(`-${de}`);
18
+ }, St = "Error decline with 603", mt = 1006, pt = (n) => typeof n == "object" && n !== null && "code" in n && n.code === mt, Ct = (n) => n.message === St;
19
+ var z = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n))(z || {}), P = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", 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))(P || {}), O = /* @__PURE__ */ ((n) => (n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.STATS = "application/vinteo.webrtc.stats", n))(O || {}), b = /* @__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))(b || {}), J = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(J || {}), Me = /* @__PURE__ */ ((n) => (n.H264 = "H264", n.VP8 = "VP8", n.VP9 = "VP9", n.AV1 = "AV1", n))(Me || {}), h = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "x-webrtc-use-license", n.PARTICIPANT_NAME = "x-webrtc-participant-name", n.INPUT_CHANNELS = "x-webrtc-input-channels", n.OUTPUT_CHANNELS = "x-webrtc-output-channels", n.MAIN_CAM = "x-webrtc-maincam", n.MIC = "x-webrtc-mic", n.MEDIA_SYNC = "x-webrtc-sync", n.MAIN_CAM_RESOLUTION = "x-webrtc-maincam-resolution", n.MEDIA_STATE = "x-webrtc-media-state", n.MEDIA_TYPE = "x-vinteo-media-type", n.MAIN_CAM_STATE = "x-vinteo-maincam-state", n.MIC_STATE = "x-vinteo-mic-state", n.CONTENT_PARTICIPANT_STATE = "x-webrtc-partstate", n.NOTIFY = "x-vinteo-notify", n.CONTENT_ENABLE_MEDIA_DEVICE = "x-webrtc-request-enable-media-device", n.CONTENTED_STREAM_STATE = "x-webrtc-share-state", n.CONTENTED_STREAM_CODEC = "x-webrtc-share-codec", 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.BEARER_TOKEN = "x-bearer-token", n.IS_DIRECT_PEER_TO_PEER = "x-webrtc-is-direct-p2p", n))(h || {}), q = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(q || {}), F = /* @__PURE__ */ ((n) => (n.AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_CONTENTED_STREAM = "x-webrtc-share-state: CONTENTEND", n.ACK_PERMISSION_TO_START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.STOPPED_CLIENT_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.ENABLE_MAIN_CAM = "x-webrtc-request-enable-media-device: LETMESTARTMAINCAM", n))(F || {}), j = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(j || {}), _e = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(_e || {}), u = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "enter-room", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "use-license", n.NEW_DTMF = "new-dtmf", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CONTENTED_STREAM_AVAILABLE = "contented-stream:available", n.CONTENTED_STREAM_NOT_AVAILABLE = "contented-stream:not-available", n.PRESENTATION_MUST_STOP = "presentation:must-stop", n.CHANNELS_ALL = "channels:all", n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC = "participant:move-request-to-spectators-synthetic", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID = "participant:move-request-to-spectators-with-audio-id", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.ADMIN_START_MAIN_CAM = "admin:start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin:stop-main-cam", n.ADMIN_START_MIC = "admin:start-mic", n.ADMIN_STOP_MIC = "admin:stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin:force-sync-media-state", n.FAILED_SEND_ROOM_DIRECT_P2P = "failed-send-room-direct-p2p", n))(u || {});
20
+ const be = [
20
21
  "enter-room",
21
22
  "main-cam-control",
22
23
  "use-license",
@@ -44,16 +45,23 @@ const Me = [
44
45
  "admin:stop-main-cam",
45
46
  "admin:start-mic",
46
47
  "admin:stop-mic",
47
- "admin:force-sync-media-state"
48
- ], St = () => new f(Me), pt = (n) => typeof n == "string" && n.trim().length > 0, L = (n, e) => {
48
+ "admin:force-sync-media-state",
49
+ "failed-send-room-direct-p2p"
50
+ ], Rt = () => new M(be), Nt = (n) => typeof n == "string" && n.trim().length > 0, w = (n, e) => {
49
51
  const t = e.toLowerCase(), s = Object.entries(n).find(([, i]) => typeof i == "string" && i.toLowerCase() === t);
50
52
  return s ? s[1] : void 0;
51
- }, mt = (n) => typeof n == "string" && !Number.isNaN(Number(n)) && Number.isFinite(Number(n)), Ct = (n) => {
52
- if (mt(n))
53
+ }, At = (n) => typeof n == "string" && !Number.isNaN(Number(n)) && Number.isFinite(Number(n)), It = (n) => {
54
+ if (At(n))
53
55
  return Number(n);
54
- }, R = (n, e) => {
56
+ }, vt = (n) => {
57
+ const e = n.toLowerCase();
58
+ if (e === "true" || e === "1")
59
+ return !0;
60
+ if (e === "false" || e === "0")
61
+ return !1;
62
+ }, N = (n, e) => {
55
63
  const t = n.getHeader(e.toLowerCase());
56
- if (!pt(t))
64
+ if (!Nt(t))
57
65
  return;
58
66
  const s = t.toLowerCase();
59
67
  switch (e) {
@@ -76,33 +84,35 @@ const Me = [
76
84
  case h.AVAILABLE_INCOMING_BITRATE:
77
85
  case h.AUDIO_TRACK_COUNT:
78
86
  case h.VIDEO_TRACK_COUNT:
79
- return Ct(s);
87
+ return It(s);
80
88
  case h.CONTENTED_STREAM_CODEC:
81
- return L(ve, s);
89
+ return w(Me, s);
82
90
  case h.CONTENT_TYPE:
83
- return L(w, s);
91
+ return w(P, s);
84
92
  case h.CONTENT_USE_LICENSE:
85
- return L(fe, s);
93
+ return w(_e, s);
86
94
  case h.MAIN_CAM:
87
- return L(b, s);
95
+ return w(b, s);
88
96
  case h.MIC:
89
- return L(z, s);
97
+ return w(J, s);
90
98
  case h.MEDIA_SYNC:
91
- return L(J, s);
99
+ return w(j, s);
92
100
  case h.CONTENT_PARTICIPANT_STATE:
93
- return L(Y, s);
101
+ return w(z, s);
94
102
  case h.CONTENTED_STREAM_STATE:
95
- return L(q, s);
103
+ return w(q, s);
104
+ case h.IS_DIRECT_PEER_TO_PEER:
105
+ return vt(s);
96
106
  default:
97
107
  return;
98
108
  }
99
109
  };
100
- var v = /* @__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))(v || {});
101
- class Nt {
110
+ var f = /* @__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))(f || {});
111
+ class ft {
102
112
  events;
103
113
  callManager;
104
114
  constructor() {
105
- this.events = St();
115
+ this.events = Rt();
106
116
  }
107
117
  subscribe({
108
118
  connectionManager: e,
@@ -141,6 +151,11 @@ class Nt {
141
151
  ];
142
152
  return s.sendInfo(O.CHANNELS, void 0, { extraHeaders: a });
143
153
  }
154
+ sendEnterRoom(e) {
155
+ this.sendEnterRoomProtected(e).catch((t) => {
156
+ this.events.trigger(u.FAILED_SEND_ROOM_DIRECT_P2P, { error: t });
157
+ });
158
+ }
144
159
  async sendMediaState({ cam: e, mic: t }, s = {}) {
145
160
  const i = this.getEstablishedRTCSessionProtected(), r = `${h.MEDIA_STATE}: currentstate`, a = `${h.MAIN_CAM_STATE}: ${Number(e)}`, o = `${h.MIC_STATE}: ${Number(t)}`, c = [
146
161
  r,
@@ -203,7 +218,7 @@ class Nt {
203
218
  ...e,
204
219
  extraHeaders: s
205
220
  }).catch((i) => {
206
- if (Et(i))
221
+ if (Ct(i))
207
222
  throw i;
208
223
  });
209
224
  }
@@ -244,55 +259,55 @@ class Nt {
244
259
  };
245
260
  handleNotify = (e) => {
246
261
  switch (e.cmd) {
247
- case v.CHANNELS: {
262
+ case f.CHANNELS: {
248
263
  const t = e;
249
264
  this.triggerChannelsNotify(t);
250
265
  break;
251
266
  }
252
- case v.WEBCAST_STARTED: {
267
+ case f.WEBCAST_STARTED: {
253
268
  const t = e;
254
269
  this.triggerWebcastStartedNotify(t);
255
270
  break;
256
271
  }
257
- case v.WEBCAST_STOPPED: {
272
+ case f.WEBCAST_STOPPED: {
258
273
  const t = e;
259
274
  this.triggerWebcastStoppedNotify(t);
260
275
  break;
261
276
  }
262
- case v.ADDED_TO_LIST_MODERATORS: {
277
+ case f.ADDED_TO_LIST_MODERATORS: {
263
278
  const t = e;
264
279
  this.triggerAddedToListModeratorsNotify(t);
265
280
  break;
266
281
  }
267
- case v.REMOVED_FROM_LIST_MODERATORS: {
282
+ case f.REMOVED_FROM_LIST_MODERATORS: {
268
283
  const t = e;
269
284
  this.triggerRemovedFromListModeratorsNotify(t);
270
285
  break;
271
286
  }
272
- case v.ACCEPTING_WORD_REQUEST: {
287
+ case f.ACCEPTING_WORD_REQUEST: {
273
288
  const t = e;
274
289
  this.triggerParticipationAcceptingWordRequest(t);
275
290
  break;
276
291
  }
277
- case v.CANCELLING_WORD_REQUEST: {
292
+ case f.CANCELLING_WORD_REQUEST: {
278
293
  const t = e;
279
294
  this.triggerParticipationCancellingWordRequest(t);
280
295
  break;
281
296
  }
282
- case v.MOVE_REQUEST_TO_STREAM: {
297
+ case f.MOVE_REQUEST_TO_STREAM: {
283
298
  const t = e;
284
299
  this.triggerParticipantMoveRequestToStream(t);
285
300
  break;
286
301
  }
287
- case v.ACCOUNT_CHANGED: {
302
+ case f.ACCOUNT_CHANGED: {
288
303
  this.triggerAccountChangedNotify();
289
304
  break;
290
305
  }
291
- case v.ACCOUNT_DELETED: {
306
+ case f.ACCOUNT_DELETED: {
292
307
  this.triggerAccountDeletedNotify();
293
308
  break;
294
309
  }
295
- case v.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
310
+ case f.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
296
311
  const t = e;
297
312
  this.triggerConferenceParticipantTokenIssued(t);
298
313
  break;
@@ -305,34 +320,34 @@ class Nt {
305
320
  const { originator: t } = e;
306
321
  if (t !== "remote")
307
322
  return;
308
- const { request: s } = e, i = s, r = R(i, h.CONTENT_TYPE);
323
+ const { request: s } = e, i = s, r = N(i, h.CONTENT_TYPE);
309
324
  if (r !== void 0)
310
325
  switch (r) {
311
- case w.ENTER_ROOM: {
326
+ case P.ENTER_ROOM: {
312
327
  this.triggerEnterRoom(i), this.maybeTriggerChannels(i);
313
328
  break;
314
329
  }
315
- case w.NOTIFY: {
330
+ case P.NOTIFY: {
316
331
  this.maybeHandleNotify(i);
317
332
  break;
318
333
  }
319
- case w.SHARE_STATE: {
334
+ case P.SHARE_STATE: {
320
335
  this.triggerContentedStreamState(i);
321
336
  break;
322
337
  }
323
- case w.MAIN_CAM: {
338
+ case P.MAIN_CAM: {
324
339
  this.triggerMainCamControl(i);
325
340
  break;
326
341
  }
327
- case w.MIC: {
342
+ case P.MIC: {
328
343
  this.triggerMicControl(i);
329
344
  break;
330
345
  }
331
- case w.USE_LICENSE: {
346
+ case P.USE_LICENSE: {
332
347
  this.triggerUseLicense(i);
333
348
  break;
334
349
  }
335
- case w.PARTICIPANT_STATE: {
350
+ case P.PARTICIPANT_STATE: {
336
351
  this.maybeTriggerParticipantMoveRequest(i);
337
352
  break;
338
353
  }
@@ -429,7 +444,7 @@ class Nt {
429
444
  );
430
445
  };
431
446
  maybeTriggerChannels = (e) => {
432
- const t = R(e, h.INPUT_CHANNELS), s = R(e, h.OUTPUT_CHANNELS);
447
+ const t = N(e, h.INPUT_CHANNELS), s = N(e, h.OUTPUT_CHANNELS);
433
448
  if (t !== void 0 && s !== void 0) {
434
449
  const i = {
435
450
  inputChannels: t,
@@ -439,15 +454,20 @@ class Nt {
439
454
  }
440
455
  };
441
456
  triggerEnterRoom = (e) => {
442
- const t = R(e, h.CONTENT_ENTER_ROOM), s = R(e, h.PARTICIPANT_NAME), i = R(e, h.BEARER_TOKEN);
443
- t !== void 0 && s !== void 0 && this.events.trigger(u.ENTER_ROOM, { room: t, participantName: s, bearerToken: i });
457
+ const t = N(e, h.CONTENT_ENTER_ROOM), s = N(e, h.PARTICIPANT_NAME), i = N(e, h.BEARER_TOKEN), r = N(e, h.IS_DIRECT_PEER_TO_PEER);
458
+ t !== void 0 && s !== void 0 && this.events.trigger(u.ENTER_ROOM, {
459
+ room: t,
460
+ participantName: s,
461
+ bearerToken: i,
462
+ isDirectPeerToPeer: r
463
+ });
444
464
  };
445
465
  triggerContentedStreamState = (e) => {
446
- const t = R(e, h.CONTENTED_STREAM_STATE);
466
+ const t = N(e, h.CONTENTED_STREAM_STATE);
447
467
  if (t !== void 0)
448
468
  switch (t) {
449
469
  case q.AVAILABLE_CONTENTED_STREAM: {
450
- const s = R(e, h.CONTENTED_STREAM_CODEC);
470
+ const s = N(e, h.CONTENTED_STREAM_CODEC);
451
471
  this.events.trigger(u.CONTENTED_STREAM_AVAILABLE, { codec: s });
452
472
  break;
453
473
  }
@@ -462,16 +482,16 @@ class Nt {
462
482
  }
463
483
  };
464
484
  maybeTriggerParticipantMoveRequest = (e) => {
465
- const t = R(e, h.CONTENT_PARTICIPANT_STATE), s = R(e, h.AUDIO_ID);
466
- t === Y.SPECTATOR && (s === void 0 ? (this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC, {}), this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, { isSynthetic: !0 })) : (this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID, {
485
+ const t = N(e, h.CONTENT_PARTICIPANT_STATE), s = N(e, h.AUDIO_ID);
486
+ t === z.SPECTATOR && (s === void 0 ? (this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_SYNTHETIC, {}), this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, { isSynthetic: !0 })) : (this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_WITH_AUDIO_ID, {
467
487
  audioId: s
468
488
  }), this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, {
469
489
  isSynthetic: !1,
470
490
  audioId: s
471
- }))), t === Y.PARTICIPANT && this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, {});
491
+ }))), t === z.PARTICIPANT && this.events.trigger(u.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, {});
472
492
  };
473
493
  triggerMainCamControl = (e) => {
474
- const t = R(e, h.MAIN_CAM), s = R(e, h.MEDIA_SYNC), i = s === J.ADMIN_SYNC_FORCED;
494
+ const t = N(e, h.MAIN_CAM), s = N(e, h.MEDIA_SYNC), i = s === j.ADMIN_SYNC_FORCED;
475
495
  if (t === b.ADMIN_START_MAIN_CAM) {
476
496
  this.events.trigger(u.ADMIN_START_MAIN_CAM, { isSyncForced: i });
477
497
  return;
@@ -481,26 +501,29 @@ class Nt {
481
501
  return;
482
502
  }
483
503
  (t === b.RESUME_MAIN_CAM || t === b.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(u.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
484
- const r = R(e, h.MAIN_CAM_RESOLUTION);
504
+ const r = N(e, h.MAIN_CAM_RESOLUTION);
485
505
  this.events.trigger(u.MAIN_CAM_CONTROL, {
486
506
  mainCam: t,
487
507
  resolutionMainCam: r
488
508
  });
489
509
  };
490
510
  triggerMicControl = (e) => {
491
- const t = R(e, h.MIC), i = R(e, h.MEDIA_SYNC) === J.ADMIN_SYNC_FORCED;
492
- t === z.ADMIN_START_MIC ? this.events.trigger(u.ADMIN_START_MIC, { isSyncForced: i }) : t === z.ADMIN_STOP_MIC && this.events.trigger(u.ADMIN_STOP_MIC, { isSyncForced: i });
511
+ const t = N(e, h.MIC), i = N(e, h.MEDIA_SYNC) === j.ADMIN_SYNC_FORCED;
512
+ t === J.ADMIN_START_MIC ? this.events.trigger(u.ADMIN_START_MIC, { isSyncForced: i }) : t === J.ADMIN_STOP_MIC && this.events.trigger(u.ADMIN_STOP_MIC, { isSyncForced: i });
493
513
  };
494
514
  triggerUseLicense = (e) => {
495
- const t = R(e, h.CONTENT_USE_LICENSE);
515
+ const t = N(e, h.CONTENT_USE_LICENSE);
496
516
  t !== void 0 && this.events.trigger(u.USE_LICENSE, t);
497
517
  };
518
+ async sendEnterRoomProtected(e) {
519
+ return this.getEstablishedRTCSessionProtected().sendInfo(P.ENTER_ROOM, void 0, { extraHeaders: e });
520
+ }
498
521
  }
499
- const Rt = "purgatory", _e = (n) => n === Rt, At = (n, e) => {
522
+ const Mt = /^p2p.+to.+$/i, Oe = (n) => n !== void 0 && n.length > 0 && Mt.test(n), _t = "purgatory", Pe = (n) => n === _t, bt = (n, e) => {
500
523
  n.getVideoTracks().forEach((s) => {
501
524
  "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
502
525
  });
503
- }, W = (n, {
526
+ }, Y = (n, {
504
527
  directionVideo: e,
505
528
  directionAudio: t,
506
529
  contentHint: s
@@ -508,8 +531,8 @@ const Rt = "purgatory", _e = (n) => n === Rt, At = (n, e) => {
508
531
  if (!n || e === "recvonly" && t === "recvonly")
509
532
  return;
510
533
  const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
511
- return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && At(o, s), o;
512
- }, It = "api/v2/rtp2webrtc/offer", vt = async ({
534
+ return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && bt(o, s), o;
535
+ }, Ot = "api/v2/rtp2webrtc/offer", Pt = async ({
513
536
  serverUrl: n,
514
537
  conferenceNumber: e,
515
538
  quality: t,
@@ -518,7 +541,7 @@ const Rt = "purgatory", _e = (n) => n === Rt, At = (n, e) => {
518
541
  token: r
519
542
  }) => {
520
543
  const a = new URL(
521
- `https://${n.replace(/\/$/, "")}/${It}/${encodeURIComponent(e)}`
544
+ `https://${n.replace(/\/$/, "")}/${Ot}/${encodeURIComponent(e)}`
522
545
  );
523
546
  a.searchParams.set("quality", t), a.searchParams.set("audio", String(s));
524
547
  const o = {
@@ -540,39 +563,39 @@ const Rt = "purgatory", _e = (n) => n === Rt, At = (n, e) => {
540
563
  return l;
541
564
  }
542
565
  };
543
- }, ft = (n, e) => (n.degradationPreference = e.degradationPreference, n), Mt = (n, e) => {
566
+ }, yt = (n, e) => (n.degradationPreference = e.degradationPreference, n), Dt = (n, e) => {
544
567
  n.encodings ??= [];
545
568
  for (let t = n.encodings.length; t < e; t += 1)
546
569
  n.encodings.push({});
547
570
  return n;
548
- }, be = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, _t = be(), bt = (n, e) => {
549
- if (_t(n, e))
571
+ }, ye = (n) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== n, Lt = ye(), wt = (n, e) => {
572
+ if (Lt(n, e))
550
573
  return n;
551
- }, Ot = (n, e, { isResetAllowed: t = !1 } = {}) => {
552
- const s = n.maxBitrate, i = bt(e, s);
574
+ }, Ut = (n, e, { isResetAllowed: t = !1 } = {}) => {
575
+ const s = n.maxBitrate, i = wt(e, s);
553
576
  return (i !== void 0 || t) && (n.maxBitrate = i), n;
554
- }, Oe = 1, yt = be(
555
- Oe
556
- ), Dt = (n, e) => {
557
- const t = n === void 0 ? void 0 : Math.max(n, Oe);
558
- if (t !== void 0 && yt(
577
+ }, De = 1, Ft = ye(
578
+ De
579
+ ), kt = (n, e) => {
580
+ const t = n === void 0 ? void 0 : Math.max(n, De);
581
+ if (t !== void 0 && Ft(
559
582
  t,
560
583
  e
561
584
  ))
562
585
  return t;
563
- }, Pt = (n, e) => {
564
- const t = n.scaleResolutionDownBy, s = Dt(
586
+ }, Bt = (n, e) => {
587
+ const t = n.scaleResolutionDownBy, s = kt(
565
588
  e,
566
589
  t
567
590
  );
568
591
  return s !== void 0 && (n.scaleResolutionDownBy = s), n;
569
- }, wt = (n, e, { isResetAllowed: t } = {}) => {
592
+ }, $t = (n, e, { isResetAllowed: t } = {}) => {
570
593
  const s = e.encodings?.length ?? 0;
571
- return Mt(n, s), n.encodings.forEach((i, r) => {
594
+ return Dt(n, s), n.encodings.forEach((i, r) => {
572
595
  const a = (e?.encodings ?? [])[r], o = a?.maxBitrate, c = a?.scaleResolutionDownBy;
573
- Ot(i, o, { isResetAllowed: t }), Pt(i, c);
596
+ Ut(i, o, { isResetAllowed: t }), Bt(i, c);
574
597
  }), n;
575
- }, Lt = (n, e) => {
598
+ }, Gt = (n, e) => {
576
599
  if (n.codecs?.length !== e.codecs?.length)
577
600
  return !0;
578
601
  for (let t = 0; t < (n.codecs?.length ?? 0); t++)
@@ -589,15 +612,15 @@ const Rt = "purgatory", _e = (n) => n === Rt, At = (n, e) => {
589
612
  if (JSON.stringify(n.encodings[t]) !== JSON.stringify(e.encodings[t]))
590
613
  return !0;
591
614
  return n.rtcp?.cname !== e.rtcp?.cname || n.rtcp?.reducedSize !== e.rtcp?.reducedSize || n.degradationPreference !== e.degradationPreference;
592
- }, te = async (n, e, { isResetAllowed: t } = {}) => {
615
+ }, ie = async (n, e, { isResetAllowed: t } = {}) => {
593
616
  const s = n.getParameters(), i = JSON.parse(
594
617
  JSON.stringify(s)
595
618
  );
596
- wt(s, e, { isResetAllowed: t }), ft(s, e);
597
- const r = Lt(i, s);
619
+ $t(s, e, { isResetAllowed: t }), yt(s, e);
620
+ const r = Gt(i, s);
598
621
  return r && await n.setParameters(s), { parameters: s, isChanged: r };
599
- }, ye = async (n, e, t) => {
600
- const { isChanged: s, parameters: i } = await te(n, {
622
+ }, Le = async (n, e, t) => {
623
+ const { isChanged: s, parameters: i } = await ie(n, {
601
624
  encodings: [
602
625
  {
603
626
  scaleResolutionDownBy: e.scaleResolutionDownBy,
@@ -606,12 +629,12 @@ const Rt = "purgatory", _e = (n) => n === Rt, At = (n, e) => {
606
629
  ]
607
630
  });
608
631
  return s && t && t(i), { isChanged: s, parameters: i };
609
- }, Ut = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), Ft = async (n, e, t) => {
610
- const s = Ut(n, e);
632
+ }, qt = (n, e) => n.find((t) => t.track !== null && e.getTracks().includes(t.track)), Vt = async (n, e, t) => {
633
+ const s = qt(n, e);
611
634
  if (s)
612
- return ye(s, { maxBitrate: t });
635
+ return Le(s, { maxBitrate: t });
613
636
  };
614
- class kt {
637
+ class xt {
615
638
  command = void 0;
616
639
  unsubscribe;
617
640
  options;
@@ -632,7 +655,7 @@ class x {
632
655
  subscriptions = [];
633
656
  stateChangeListeners = /* @__PURE__ */ new Set();
634
657
  constructor(e) {
635
- this.actor = dt(e), this.actor.start(), this.addSubscription(
658
+ this.actor = gt(e), this.actor.start(), this.addSubscription(
636
659
  this.subscribe((t) => {
637
660
  const s = t.value;
638
661
  this.stateChangeListeners.forEach((i) => {
@@ -674,37 +697,38 @@ class x {
674
697
  return this.subscriptions.push(t), t;
675
698
  }
676
699
  }
677
- var ne = /* @__PURE__ */ ((n) => (n.IDLE = "call:idle", n.CONNECTING = "call:connecting", n.PURGATORY = "call:purgatory", n.IN_ROOM = "call:inRoom", n))(ne || {});
678
- const M = "evaluate", j = (n) => typeof n == "string" && n.length > 0, oe = (n) => "number" in n && j(n.number) && typeof n.answer == "boolean", De = (n) => "room" in n && j(n.room) && j(n.participantName), Pe = (n) => "token" in n && j(n.token), Bt = (n) => oe(n) && De(n) && !Pe(n) && "room" in n && _e(n.room), we = (n) => oe(n) && De(n) && Pe(n), $t = {}, le = () => ({
700
+ var re = /* @__PURE__ */ ((n) => (n.IDLE = "call:idle", n.CONNECTING = "call:connecting", n.PURGATORY = "call:purgatory", n.P2P_ROOM = "call:p2pRoom", n.DIRECT_P2P_ROOM = "call:directP2pRoom", n.IN_ROOM = "call:inRoom", n))(re || {});
701
+ const A = "evaluate", K = (n) => typeof n == "string" && n.length > 0, H = (n) => "number" in n && K(n.number) && typeof n.answer == "boolean", Z = (n) => "room" in n && K(n.room) && K(n.participantName), ee = (n) => "token" in n && K(n.token), we = ({ isDirectPeerToPeer: n }) => n === !0, Ht = (n) => Pe(n.room) || Oe(n.room) || we(n), Wt = (n) => H(n) && Z(n) && !ee(n) && "room" in n && Pe(n.room), Qt = (n) => H(n) && Z(n) && !ee(n) && "room" in n && Oe(n.room), Yt = (n) => "isDirectPeerToPeer" in n && we(n), zt = (n) => H(n) && Z(n) && !ee(n) && "room" in n && Yt(n), Ue = (n) => H(n) && Z(n) && ee(n), Jt = {}, ge = () => ({
679
702
  number: void 0,
680
703
  answer: void 0,
681
704
  room: void 0,
682
705
  participantName: void 0,
683
- token: void 0
684
- }), Gt = V({
706
+ token: void 0,
707
+ isDirectPeerToPeer: void 0
708
+ }), jt = V({
685
709
  types: {
686
- context: $t,
710
+ context: Jt,
687
711
  events: {}
688
712
  },
689
713
  actions: {
690
- setConnecting: I(({ event: n, context: e }) => n.type !== "CALL.CONNECTING" ? e : {
691
- ...le(),
714
+ setConnecting: v(({ event: n, context: e }) => n.type !== "CALL.CONNECTING" ? e : {
715
+ ...ge(),
692
716
  number: n.number,
693
717
  answer: n.answer
694
718
  }),
695
- setRoomInfo: I(({ event: n, context: e }) => {
719
+ setRoomInfo: v(({ event: n, context: e }) => {
696
720
  if (n.type !== "CALL.ENTER_ROOM")
697
721
  return e;
698
722
  const t = {
699
723
  room: n.room,
700
724
  participantName: n.participantName
701
725
  };
702
- return n.token !== void 0 ? t.token = n.token : _e(n.room) && (t.token = void 0), t;
726
+ return n.token !== void 0 ? t.token = n.token : Ht(n) && (t.token = void 0), n.isDirectPeerToPeer !== void 0 && (t.isDirectPeerToPeer = n.isDirectPeerToPeer), t;
703
727
  }),
704
- setTokenInfo: I(({ event: n, context: e }) => n.type !== "CALL.TOKEN_ISSUED" ? e : {
728
+ setTokenInfo: v(({ event: n, context: e }) => n.type !== "CALL.TOKEN_ISSUED" ? e : {
705
729
  token: n.token
706
730
  }),
707
- reset: I(le())
731
+ reset: v(ge())
708
732
  }
709
733
  }).createMachine({
710
734
  id: "call",
@@ -714,7 +738,7 @@ const M = "evaluate", j = (n) => typeof n == "string" && n.length > 0, oe = (n)
714
738
  "call:idle": {
715
739
  on: {
716
740
  "CALL.CONNECTING": {
717
- target: M,
741
+ target: A,
718
742
  actions: "setConnecting"
719
743
  }
720
744
  }
@@ -722,15 +746,15 @@ const M = "evaluate", j = (n) => typeof n == "string" && n.length > 0, oe = (n)
722
746
  "call:connecting": {
723
747
  on: {
724
748
  "CALL.ENTER_ROOM": {
725
- target: M,
749
+ target: A,
726
750
  actions: "setRoomInfo"
727
751
  },
728
752
  "CALL.TOKEN_ISSUED": {
729
- target: M,
753
+ target: A,
730
754
  actions: "setTokenInfo"
731
755
  },
732
756
  "CALL.RESET": {
733
- target: M,
757
+ target: A,
734
758
  actions: "reset"
735
759
  }
736
760
  }
@@ -738,32 +762,40 @@ const M = "evaluate", j = (n) => typeof n == "string" && n.length > 0, oe = (n)
738
762
  "call:inRoom": {
739
763
  on: {
740
764
  "CALL.ENTER_ROOM": {
741
- target: M,
765
+ target: A,
742
766
  actions: "setRoomInfo"
743
767
  },
744
768
  "CALL.TOKEN_ISSUED": {
745
- target: M,
769
+ target: A,
746
770
  actions: "setTokenInfo"
747
771
  },
748
772
  "CALL.RESET": {
749
- target: M,
773
+ target: A,
750
774
  actions: "reset"
751
775
  }
752
776
  }
753
777
  },
754
- [M]: {
778
+ [A]: {
755
779
  always: [
756
780
  {
757
781
  target: "call:inRoom",
758
- guard: ({ context: n }) => we(n)
782
+ guard: ({ context: n }) => Ue(n)
783
+ },
784
+ {
785
+ target: "call:directP2pRoom",
786
+ guard: ({ context: n }) => zt(n)
787
+ },
788
+ {
789
+ target: "call:p2pRoom",
790
+ guard: ({ context: n }) => Qt(n)
759
791
  },
760
792
  {
761
793
  target: "call:purgatory",
762
- guard: ({ context: n }) => Bt(n)
794
+ guard: ({ context: n }) => Wt(n)
763
795
  },
764
796
  {
765
797
  target: "call:connecting",
766
- guard: ({ context: n }) => oe(n)
798
+ guard: ({ context: n }) => H(n)
767
799
  },
768
800
  {
769
801
  target: "call:idle"
@@ -774,24 +806,56 @@ const M = "evaluate", j = (n) => typeof n == "string" && n.length > 0, oe = (n)
774
806
  "call:purgatory": {
775
807
  on: {
776
808
  "CALL.ENTER_ROOM": {
777
- target: M,
809
+ target: A,
810
+ actions: "setRoomInfo"
811
+ },
812
+ "CALL.TOKEN_ISSUED": {
813
+ target: A,
814
+ actions: "setTokenInfo"
815
+ },
816
+ "CALL.RESET": {
817
+ target: A,
818
+ actions: "reset"
819
+ }
820
+ }
821
+ },
822
+ "call:p2pRoom": {
823
+ on: {
824
+ "CALL.ENTER_ROOM": {
825
+ target: A,
778
826
  actions: "setRoomInfo"
779
827
  },
780
828
  "CALL.TOKEN_ISSUED": {
781
- target: M,
829
+ target: A,
782
830
  actions: "setTokenInfo"
783
831
  },
784
832
  "CALL.RESET": {
785
- target: M,
833
+ target: A,
834
+ actions: "reset"
835
+ }
836
+ }
837
+ },
838
+ "call:directP2pRoom": {
839
+ on: {
840
+ "CALL.ENTER_ROOM": {
841
+ target: A,
842
+ actions: "setRoomInfo"
843
+ },
844
+ "CALL.TOKEN_ISSUED": {
845
+ target: A,
846
+ actions: "setTokenInfo"
847
+ },
848
+ "CALL.RESET": {
849
+ target: A,
786
850
  actions: "reset"
787
851
  }
788
852
  }
789
853
  }
790
854
  }
791
855
  });
792
- class qt extends x {
856
+ class Kt extends x {
793
857
  constructor(e) {
794
- super(Gt), this.subscribeToEvents(e);
858
+ super(jt), this.subscribeToEvents(e);
795
859
  }
796
860
  get isIdle() {
797
861
  return this.state === "call:idle";
@@ -802,16 +866,22 @@ class qt extends x {
802
866
  get isInPurgatory() {
803
867
  return this.state === "call:purgatory";
804
868
  }
869
+ get isP2PRoom() {
870
+ return this.state === "call:p2pRoom";
871
+ }
872
+ get isDirectP2PRoom() {
873
+ return this.state === "call:directP2pRoom";
874
+ }
805
875
  get isInRoom() {
806
876
  return this.state === "call:inRoom";
807
877
  }
808
878
  /** Контекст в состоянии IN_ROOM; undefined в остальных состояниях. Использовать вместо каста context. */
809
879
  get inRoomContext() {
810
880
  const { context: e } = this;
811
- return we(e) ? e : void 0;
881
+ return Ue(e) ? e : void 0;
812
882
  }
813
883
  get isActive() {
814
- return this.isInRoom || this.isInPurgatory;
884
+ return this.isInRoom || this.isInPurgatory || this.isP2PRoom || this.isDirectP2PRoom;
815
885
  }
816
886
  get isPending() {
817
887
  return this.isConnecting;
@@ -826,6 +896,13 @@ class qt extends x {
826
896
  if ("token" in e)
827
897
  return e.token;
828
898
  }
899
+ get isCallInitiator() {
900
+ return !this.isCallAnswerer;
901
+ }
902
+ get isCallAnswerer() {
903
+ const { context: e } = this;
904
+ return "answer" in e ? e.answer : !1;
905
+ }
829
906
  reset() {
830
907
  this.send({ type: "CALL.RESET" });
831
908
  }
@@ -840,8 +917,14 @@ class qt extends x {
840
917
  }
841
918
  subscribeToApiEvents(e) {
842
919
  this.addSubscription(
843
- e.on("enter-room", ({ room: t, participantName: s, bearerToken: i }) => {
844
- this.send({ type: "CALL.ENTER_ROOM", room: t, participantName: s, token: i });
920
+ e.on("enter-room", ({ room: t, participantName: s, bearerToken: i, isDirectPeerToPeer: r }) => {
921
+ this.send({
922
+ type: "CALL.ENTER_ROOM",
923
+ room: t,
924
+ participantName: s,
925
+ token: i,
926
+ isDirectPeerToPeer: r
927
+ });
845
928
  })
846
929
  ), this.addSubscription(
847
930
  e.on("conference:participant-token-issued", ({ jwt: t }) => {
@@ -865,8 +948,8 @@ class qt extends x {
865
948
  );
866
949
  }
867
950
  }
868
- var S = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.START_CALL = "start-call", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n.CALL_STATUS_CHANGED = "call-status-changed", n.REMOTE_TRACKS_CHANGED = "remote-tracks-changed", n.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n.RECV_QUALITY_REQUESTED = "recv-quality-requested", n.RECV_QUALITY_CHANGED = "recv-quality-changed", n))(S || {}), Vt = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(Vt || {});
869
- const Le = [
951
+ var E = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.START_CALL = "start-call", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n.CALL_STATUS_CHANGED = "call-status-changed", n.REMOTE_TRACKS_CHANGED = "remote-tracks-changed", n.REMOTE_STREAMS_CHANGED = "remote-streams-changed", n.RECV_SESSION_STARTED = "recv-session-started", n.RECV_SESSION_ENDED = "recv-session-ended", n.RECV_QUALITY_CHANGED = "recv-quality-changed", n))(E || {}), Xt = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(Xt || {});
952
+ const Fe = [
870
953
  "peerconnection",
871
954
  "connecting",
872
955
  "sending",
@@ -897,7 +980,7 @@ const Le = [
897
980
  "peerconnection:createanswerfailed",
898
981
  "peerconnection:setlocaldescriptionfailed",
899
982
  "peerconnection:setremotedescriptionfailed"
900
- ], xt = [
983
+ ], Zt = [
901
984
  "start-call",
902
985
  "peerconnection:confirmed",
903
986
  "peerconnection:ontrack",
@@ -905,13 +988,14 @@ const Le = [
905
988
  "call-status-changed",
906
989
  "remote-tracks-changed",
907
990
  "remote-streams-changed",
908
- "recv-quality-requested",
991
+ "recv-session-started",
992
+ "recv-session-ended",
909
993
  "recv-quality-changed"
910
- ], Ue = [
911
- ...Le,
912
- ...xt
913
- ], Ht = () => new f(Ue), Qt = 6e3, Wt = 1e3, Q = (n, e) => n.getSenders().filter((t) => t.track?.kind === e), Yt = (n) => n === "audio" ? Qt : Wt, zt = (n) => n.track !== null;
914
- class Jt {
994
+ ], ke = [
995
+ ...Fe,
996
+ ...Zt
997
+ ], en = () => new M(ke), tn = 6e3, nn = 1e3, Q = (n, e) => n.getSenders().filter((t) => t.track?.kind === e), sn = (n) => n === "audio" ? tn : nn, rn = (n) => n.track !== null;
998
+ class an {
915
999
  previousBitrates = /* @__PURE__ */ new Map();
916
1000
  /**
917
1001
  * Устанавливает минимальный битрейт для указанных типов потоков
@@ -923,17 +1007,17 @@ class Jt {
923
1007
  if (!e)
924
1008
  return;
925
1009
  (t === "audio" || t === "all") && s.push(...Q(e, "audio")), (t === "video" || t === "all") && s.push(...Q(e, "video"));
926
- const i = s.filter(zt).map(async (r) => {
1010
+ const i = s.filter(rn).map(async (r) => {
927
1011
  const a = r.getParameters();
928
1012
  this.saveCurrentBitrate(r, a);
929
1013
  const o = {
930
1014
  ...a,
931
1015
  encodings: a.encodings.map((c) => ({
932
1016
  ...c,
933
- maxBitrate: Yt(r.track.kind)
1017
+ maxBitrate: sn(r.track.kind)
934
1018
  }))
935
1019
  };
936
- await te(r, o);
1020
+ await ie(r, o);
937
1021
  });
938
1022
  await Promise.all(i);
939
1023
  }
@@ -954,7 +1038,7 @@ class Jt {
954
1038
  ...r.getParameters(),
955
1039
  encodings: a
956
1040
  };
957
- await te(r, c, { isResetAllowed: !0 }), this.clearSavedBitrate(r);
1041
+ await ie(r, c, { isResetAllowed: !0 }), this.clearSavedBitrate(r);
958
1042
  }
959
1043
  });
960
1044
  await Promise.all(i);
@@ -997,16 +1081,16 @@ class Jt {
997
1081
  this.previousBitrates.set(e, s);
998
1082
  }
999
1083
  }
1000
- var Fe = /* @__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))(Fe || {});
1001
- class jt {
1084
+ var Be = /* @__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))(Be || {});
1085
+ class on {
1002
1086
  events;
1003
1087
  rtcSession;
1004
1088
  disposers = /* @__PURE__ */ new Set();
1005
1089
  onReset;
1006
1090
  // Менеджер состояния битрейта
1007
- bitrateStateManager = new Jt();
1091
+ bitrateStateManager = new an();
1008
1092
  constructor(e, { onReset: t }) {
1009
- this.events = e, this.onReset = t, e.on(S.FAILED, this.handleEnded), e.on(S.ENDED, this.handleEnded);
1093
+ this.events = e, this.onReset = t, e.on(E.FAILED, this.handleEnded), e.on(E.ENDED, this.handleEnded);
1010
1094
  }
1011
1095
  get connection() {
1012
1096
  return this.rtcSession?.connection;
@@ -1030,14 +1114,14 @@ class jt {
1030
1114
  contentHint: l,
1031
1115
  offerToReceiveAudio: T = !0,
1032
1116
  offerToReceiveVideo: g = !0,
1033
- degradationPreference: E,
1034
- sendEncodings: N,
1117
+ degradationPreference: S,
1118
+ sendEncodings: R,
1035
1119
  onAddedTransceiver: D
1036
- }) => new Promise((A, U) => {
1037
- this.handleCall().then(A).catch((B) => {
1120
+ }) => new Promise((I, U) => {
1121
+ this.handleCall().then(I).catch((B) => {
1038
1122
  U(B);
1039
1123
  }), this.rtcSession = e.call(t(s), {
1040
- mediaStream: W(i, {
1124
+ mediaStream: Y(i, {
1041
1125
  directionVideo: o,
1042
1126
  directionAudio: c,
1043
1127
  contentHint: l
@@ -1056,8 +1140,8 @@ class jt {
1056
1140
  extraHeaders: r,
1057
1141
  directionVideo: o,
1058
1142
  directionAudio: c,
1059
- degradationPreference: E,
1060
- sendEncodings: N,
1143
+ degradationPreference: S,
1144
+ sendEncodings: R,
1061
1145
  onAddedTransceiver: D
1062
1146
  });
1063
1147
  });
@@ -1065,7 +1149,7 @@ class jt {
1065
1149
  const { rtcSession: e } = this;
1066
1150
  if (e && !e.isEnded())
1067
1151
  return e.terminateAsync({
1068
- cause: Fe.CANCELED
1152
+ cause: Be.CANCELED
1069
1153
  }).finally(() => {
1070
1154
  this.reset();
1071
1155
  });
@@ -1082,11 +1166,11 @@ class jt {
1082
1166
  contentHint: l,
1083
1167
  degradationPreference: T,
1084
1168
  sendEncodings: g,
1085
- onAddedTransceiver: E
1086
- }) => new Promise((N, D) => {
1169
+ onAddedTransceiver: S
1170
+ }) => new Promise((R, D) => {
1087
1171
  try {
1088
- this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(N).catch((A) => {
1089
- D(A);
1172
+ this.rtcSession = e, this.subscribeToSessionEvents(e), this.handleCall().then(R).catch((I) => {
1173
+ D(I);
1090
1174
  }), e.answer({
1091
1175
  pcConfig: {
1092
1176
  iceServers: i
@@ -1095,7 +1179,7 @@ class jt {
1095
1179
  offerToReceiveAudio: o,
1096
1180
  offerToReceiveVideo: c
1097
1181
  },
1098
- mediaStream: W(t, {
1182
+ mediaStream: Y(t, {
1099
1183
  directionVideo: r,
1100
1184
  directionAudio: a,
1101
1185
  contentHint: l
@@ -1105,16 +1189,16 @@ class jt {
1105
1189
  directionAudio: a,
1106
1190
  degradationPreference: T,
1107
1191
  sendEncodings: g,
1108
- onAddedTransceiver: E
1192
+ onAddedTransceiver: S
1109
1193
  });
1110
- } catch (A) {
1111
- D(A);
1194
+ } catch (I) {
1195
+ D(I);
1112
1196
  }
1113
1197
  });
1114
1198
  async replaceMediaStream(e, t) {
1115
1199
  if (!this.rtcSession)
1116
1200
  throw new Error("No rtcSession established");
1117
- const { contentHint: s } = t ?? {}, i = W(e, { contentHint: s });
1201
+ const { contentHint: s } = t ?? {}, i = Y(e, { contentHint: s });
1118
1202
  if (i === void 0)
1119
1203
  throw new Error("No preparedMediaStream");
1120
1204
  return this.rtcSession.replaceMediaStream(i, t);
@@ -1130,7 +1214,7 @@ class jt {
1130
1214
  */
1131
1215
  setMinBitrateForSenders(e = "all") {
1132
1216
  this.bitrateStateManager.setMinBitrateForSenders(this.connection, e).catch((t) => {
1133
- he("MCUSession.setMinBitrateForSenders", t);
1217
+ ue("MCUSession.setMinBitrateForSenders", t);
1134
1218
  });
1135
1219
  }
1136
1220
  /**
@@ -1139,38 +1223,38 @@ class jt {
1139
1223
  */
1140
1224
  restoreBitrateForSenders(e = "all") {
1141
1225
  this.bitrateStateManager.restoreBitrateForSenders(this.connection, e).catch((t) => {
1142
- he("MCUSession.restoreBitrateForSenders", t);
1226
+ ue("MCUSession.restoreBitrateForSenders", t);
1143
1227
  });
1144
1228
  }
1145
1229
  handleCall = async () => new Promise((e, t) => {
1146
1230
  const s = () => {
1147
- this.events.on(S.PEER_CONNECTION, l), this.events.on(S.CONFIRMED, T);
1231
+ this.events.on(E.PEER_CONNECTION, l), this.events.on(E.CONFIRMED, T);
1148
1232
  }, i = () => {
1149
- this.events.off(S.PEER_CONNECTION, l), this.events.off(S.CONFIRMED, T);
1233
+ this.events.off(E.PEER_CONNECTION, l), this.events.off(E.CONFIRMED, T);
1150
1234
  }, r = () => {
1151
- this.events.on(S.FAILED, o), this.events.on(S.ENDED, o);
1235
+ this.events.on(E.FAILED, o), this.events.on(E.ENDED, o);
1152
1236
  }, a = () => {
1153
- this.events.off(S.FAILED, o), this.events.off(S.ENDED, o);
1237
+ this.events.off(E.FAILED, o), this.events.off(E.ENDED, o);
1154
1238
  }, o = (g) => {
1155
1239
  i(), a(), t(g);
1156
1240
  };
1157
1241
  let c;
1158
1242
  const l = ({ peerconnection: g }) => {
1159
1243
  c = g;
1160
- const E = (N) => {
1161
- this.events.trigger(S.PEER_CONNECTION_ONTRACK, N);
1244
+ const S = (R) => {
1245
+ this.events.trigger(E.PEER_CONNECTION_ONTRACK, R);
1162
1246
  };
1163
- g.addEventListener("track", E), this.disposers.add(() => {
1164
- g.removeEventListener("track", E);
1247
+ g.addEventListener("track", S), this.disposers.add(() => {
1248
+ g.removeEventListener("track", S);
1165
1249
  });
1166
1250
  }, T = () => {
1167
- c !== void 0 && this.events.trigger(S.PEER_CONNECTION_CONFIRMED, c), i(), a(), e(c);
1251
+ c !== void 0 && this.events.trigger(E.PEER_CONNECTION_CONFIRMED, c), i(), a(), e(c);
1168
1252
  };
1169
1253
  s(), r();
1170
1254
  });
1171
1255
  subscribeToSessionEvents(e) {
1172
1256
  this.events.eachTriggers((t, s) => {
1173
- const i = Le.find((r) => r === s);
1257
+ const i = Fe.find((r) => r === s);
1174
1258
  i && (e.on(i, t), this.disposers.add(() => {
1175
1259
  e.off(i, t);
1176
1260
  }));
@@ -1183,23 +1267,25 @@ class jt {
1183
1267
  }
1184
1268
  handleEnded = (e) => {
1185
1269
  const { originator: t } = e;
1186
- t === "remote" && this.events.trigger(S.ENDED_FROM_SERVER, e), this.reset();
1270
+ t === "remote" && this.events.trigger(E.ENDED_FROM_SERVER, e), this.reset();
1187
1271
  };
1188
1272
  reset = () => {
1189
1273
  delete this.rtcSession, this.unsubscribeFromSessionEvents(), this.bitrateStateManager.clearAll(), this.onReset();
1190
1274
  };
1191
1275
  }
1192
- const ue = (n) => n === "auto" ? "high" : n, Xt = 10, Kt = 100;
1193
- class Zt {
1276
+ const Te = (n) => n === "auto" ? "high" : n, cn = 10, dn = 100;
1277
+ class hn {
1194
1278
  cancelableSendOfferWithRepeatedCalls;
1195
1279
  config;
1196
1280
  tools;
1197
1281
  connection;
1198
1282
  lastCallParams;
1199
1283
  constructor(e, t) {
1284
+ const s = e.quality ?? "auto";
1200
1285
  this.config = {
1201
1286
  ...e,
1202
- effectiveQuality: ue(e.quality)
1287
+ quality: s,
1288
+ effectiveQuality: Te(s)
1203
1289
  }, this.tools = t, this.connection = new RTCPeerConnection(e.pcConfig), this.addTransceivers();
1204
1290
  }
1205
1291
  get settings() {
@@ -1215,8 +1301,10 @@ class Zt {
1215
1301
  return this.config.effectiveQuality;
1216
1302
  }
1217
1303
  async setQuality(e) {
1218
- const t = this.config.effectiveQuality;
1219
- return this.config.quality = e, this.config.effectiveQuality = ue(e), this.config.effectiveQuality === t || !this.lastCallParams ? !1 : (await this.renegotiate(this.lastCallParams), !0);
1304
+ if (!this.lastCallParams)
1305
+ return !1;
1306
+ const t = this.config.effectiveQuality, s = this.config.quality, i = Te(e);
1307
+ return e === s && i === t ? !1 : (this.config.quality = e, this.config.effectiveQuality = i, i !== t && await this.renegotiate(this.lastCallParams), !0);
1220
1308
  }
1221
1309
  async applyQuality(e) {
1222
1310
  const t = await this.setQuality(e), s = this.getEffectiveQuality();
@@ -1240,11 +1328,11 @@ class Zt {
1240
1328
  },
1241
1329
  s
1242
1330
  ), r = (o) => !(o instanceof Error);
1243
- this.cancelableSendOfferWithRepeatedCalls = re({
1331
+ this.cancelableSendOfferWithRepeatedCalls = ce({
1244
1332
  targetFunction: i,
1245
1333
  isComplete: r,
1246
- callLimit: Xt,
1247
- delay: Kt,
1334
+ callLimit: cn,
1335
+ delay: dn,
1248
1336
  isRejectAsValid: !0,
1249
1337
  isCheckBeforeCall: !1
1250
1338
  });
@@ -1282,18 +1370,18 @@ class Zt {
1282
1370
  this.cancelableSendOfferWithRepeatedCalls?.cancel();
1283
1371
  }
1284
1372
  }
1285
- const ke = (n) => n.getSettings(), en = (n, e) => {
1286
- const t = ke(n);
1373
+ const $e = (n) => n.getSettings(), ln = (n, e) => {
1374
+ const t = $e(n);
1287
1375
  let s = e;
1288
1376
  s ??= n.label;
1289
1377
  let i = t?.msid;
1290
1378
  return i ??= s, i ??= n.id, i;
1291
- }, tn = (n, e) => {
1292
- const t = ke(n);
1379
+ }, un = (n, e) => {
1380
+ const t = $e(n);
1293
1381
  let s = e;
1294
1382
  return s ??= t?.msid, s ??= n.label, (s && s.length > 0 ? s : void 0) ?? n.id;
1295
1383
  };
1296
- class ge {
1384
+ class Ee {
1297
1385
  participantGroups = /* @__PURE__ */ new Map();
1298
1386
  trackToGroup = /* @__PURE__ */ new Map();
1299
1387
  trackDisposers = /* @__PURE__ */ new Map();
@@ -1310,7 +1398,7 @@ class ge {
1310
1398
  onRemoved: t,
1311
1399
  streamHint: s
1312
1400
  } = {}) {
1313
- const i = tn(e, s), r = en(e, s);
1401
+ const i = un(e, s), r = ln(e, s);
1314
1402
  if (this.trackToGroup.has(e.id))
1315
1403
  return { isAddedTrack: !1, isAddedStream: !1 };
1316
1404
  const a = this.getParticipantGroups(i), o = a.get(r), c = !o;
@@ -1378,16 +1466,16 @@ class ge {
1378
1466
  return this.participantGroups.set(e, s), s;
1379
1467
  }
1380
1468
  }
1381
- const K = {
1469
+ const te = {
1382
1470
  type: "participant"
1383
- }, nn = {
1471
+ }, gn = {
1384
1472
  type: "spectator_synthetic"
1385
- }, sn = (n) => ({
1473
+ }, Tn = (n) => ({
1386
1474
  type: "spectator",
1387
1475
  recvParams: n
1388
1476
  });
1389
- class m {
1390
- role = K;
1477
+ class p {
1478
+ role = te;
1391
1479
  onRoleChanged;
1392
1480
  constructor(e) {
1393
1481
  this.onRoleChanged = e;
@@ -1402,30 +1490,30 @@ class m {
1402
1490
  return e.type === "spectator";
1403
1491
  }
1404
1492
  static isExitingSpectatorRole(e, t) {
1405
- return m.hasSpectator(e) && !m.hasSpectator(t);
1493
+ return p.hasSpectator(e) && !p.hasSpectator(t);
1406
1494
  }
1407
1495
  static isEnteringSpectatorRole(e, t) {
1408
- return m.hasSpectator(t);
1496
+ return p.hasSpectator(t);
1409
1497
  }
1410
1498
  static isExitingAnySpectatorRole(e, t) {
1411
- const s = m.hasSpectator(e) || m.hasSpectatorSynthetic(e), i = m.hasSpectator(t) || m.hasSpectatorSynthetic(t);
1499
+ const s = p.hasSpectator(e) || p.hasSpectatorSynthetic(e), i = p.hasSpectator(t) || p.hasSpectatorSynthetic(t);
1412
1500
  return s && !i;
1413
1501
  }
1414
1502
  static isEnteringAnySpectatorRole(e, t) {
1415
- const s = m.hasSpectator(e) || m.hasSpectatorSynthetic(e), i = m.hasSpectator(t) || m.hasSpectatorSynthetic(t);
1503
+ const s = p.hasSpectator(e) || p.hasSpectatorSynthetic(e), i = p.hasSpectator(t) || p.hasSpectatorSynthetic(t);
1416
1504
  return !s && i;
1417
1505
  }
1418
1506
  getRole() {
1419
1507
  return this.role;
1420
1508
  }
1421
1509
  setCallRoleParticipant() {
1422
- this.changeRole(K);
1510
+ this.changeRole(te);
1423
1511
  }
1424
1512
  setCallRoleSpectatorSynthetic() {
1425
- this.changeRole(nn);
1513
+ this.changeRole(gn);
1426
1514
  }
1427
1515
  setCallRoleSpectator(e) {
1428
- this.changeRole(sn(e));
1516
+ this.changeRole(Tn(e));
1429
1517
  }
1430
1518
  changeRole(e) {
1431
1519
  const t = this.role;
@@ -1433,32 +1521,32 @@ class m {
1433
1521
  this.setRole(e);
1434
1522
  return;
1435
1523
  }
1436
- m.hasSpectator(e) && m.hasSpectator(t) && t.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
1524
+ p.hasSpectator(e) && p.hasSpectator(t) && t.recvParams.audioId !== e.recvParams.audioId && this.setRole(e);
1437
1525
  }
1438
1526
  reset() {
1439
- this.role = K;
1527
+ this.role = te;
1440
1528
  }
1441
1529
  hasParticipant() {
1442
- return m.hasParticipant(this.role);
1530
+ return p.hasParticipant(this.role);
1443
1531
  }
1444
1532
  hasSpectatorSynthetic() {
1445
- return m.hasSpectatorSynthetic(this.role);
1533
+ return p.hasSpectatorSynthetic(this.role);
1446
1534
  }
1447
1535
  hasSpectator() {
1448
- return m.hasSpectator(this.role);
1536
+ return p.hasSpectator(this.role);
1449
1537
  }
1450
1538
  setRole(e) {
1451
1539
  const t = this.role;
1452
1540
  this.role = e, this.onRoleChanged?.({ previous: t, next: e });
1453
1541
  }
1454
1542
  }
1455
- const rn = (n, e) => {
1543
+ const En = (n, e) => {
1456
1544
  if (!n || !e)
1457
1545
  return n === e;
1458
1546
  const t = n.mainStream?.id, s = e.mainStream?.id, i = n.contentedStream?.id, r = e.contentedStream?.id;
1459
1547
  return t === s && i === r;
1460
1548
  };
1461
- class an {
1549
+ class Sn {
1462
1550
  lastEmittedStreams;
1463
1551
  /**
1464
1552
  * Проверяет, изменились ли streams с последнего сохраненного состояния
@@ -1466,7 +1554,7 @@ class an {
1466
1554
  * @returns true, если streams изменились
1467
1555
  */
1468
1556
  hasChanged(e) {
1469
- return !rn(this.lastEmittedStreams, e);
1557
+ return !En(this.lastEmittedStreams, e);
1470
1558
  }
1471
1559
  /**
1472
1560
  * Сохраняет текущие streams как последнее эмитнутое состояние
@@ -1489,8 +1577,8 @@ class an {
1489
1577
  this.lastEmittedStreams = void 0;
1490
1578
  }
1491
1579
  }
1492
- const on = "default", cn = "dual", dn = "content_", hn = (n) => `${dn}${n.toLowerCase()}`, ln = (n) => [...n.getTracks()].some((e) => e.label.includes(cn));
1493
- class un {
1580
+ const mn = "default", pn = "dual", Cn = "content_", Rn = (n) => `${Cn}${n.toLowerCase()}`, Nn = (n) => [...n.getTracks()].some((e) => e.label.includes(pn));
1581
+ class An {
1494
1582
  mainRemoteStreamsManager;
1495
1583
  recvRemoteStreamsManager;
1496
1584
  constructor(e, t) {
@@ -1507,7 +1595,7 @@ class un {
1507
1595
  }) {
1508
1596
  const t = this.mainRemoteStreamsManager;
1509
1597
  return { manager: t, getRemoteStreams: () => {
1510
- const i = t.getStreams(), r = i.find((o) => !ln(o)), a = e.isAvailable ? i.find((o) => o !== r) : void 0;
1598
+ const i = t.getStreams(), r = i.find((o) => !Nn(o)), a = e.isAvailable ? i.find((o) => o !== r) : void 0;
1511
1599
  return { mainStream: r, contentedStream: a };
1512
1600
  } };
1513
1601
  }
@@ -1516,7 +1604,7 @@ class un {
1516
1604
  }) {
1517
1605
  const t = this.recvRemoteStreamsManager;
1518
1606
  return { manager: t, getRemoteStreams: () => {
1519
- const r = t.getStreams(on)[0], a = this.getRecvRemoteContentedStream({ stateInfo: e });
1607
+ const r = t.getStreams(mn)[0], a = this.getRecvRemoteContentedStream({ stateInfo: e });
1520
1608
  return { mainStream: r, contentedStream: a };
1521
1609
  } };
1522
1610
  }
@@ -1525,12 +1613,12 @@ class un {
1525
1613
  }) {
1526
1614
  if (!e.isAvailable || e.codec === void 0)
1527
1615
  return;
1528
- const t = hn(e.codec);
1616
+ const t = Rn(e.codec);
1529
1617
  return this.recvRemoteStreamsManager.getStreams(t)[0];
1530
1618
  }
1531
1619
  }
1532
- const Te = (n) => n.streams[0]?.id;
1533
- function gn(n) {
1620
+ const Se = (n) => n.streams[0]?.id;
1621
+ function In(n) {
1534
1622
  const { inRoomContext: e } = n;
1535
1623
  if (e === void 0)
1536
1624
  throw new Error(
@@ -1538,34 +1626,33 @@ function gn(n) {
1538
1626
  );
1539
1627
  return e.token;
1540
1628
  }
1541
- class Tn {
1629
+ class vn {
1542
1630
  events;
1543
1631
  stateMachine;
1544
1632
  isPendingCall = !1;
1545
1633
  isPendingAnswer = !1;
1546
- mainRemoteStreamsManager = new ge();
1547
- recvRemoteStreamsManager = new ge();
1634
+ mainRemoteStreamsManager = new Ee();
1635
+ recvRemoteStreamsManager = new Ee();
1548
1636
  streamsManagerProvider;
1549
1637
  contentedStreamManager;
1550
- roleManager = new m((e) => {
1638
+ roleManager = new p((e) => {
1551
1639
  this.onRoleChanged(e);
1552
1640
  });
1553
1641
  mcuSession;
1554
1642
  recvSession;
1555
1643
  disposeRecvSessionTrackListener;
1556
- recvQuality = "auto";
1557
1644
  deferredStartRecvSessionRunner;
1558
- streamsChangeTracker = new an();
1645
+ streamsChangeTracker = new Sn();
1559
1646
  constructor(e) {
1560
- this.contentedStreamManager = e, this.events = Ht(), this.mcuSession = new jt(this.events, { onReset: this.reset }), this.stateMachine = new qt(this.events), this.streamsManagerProvider = new un(
1647
+ this.contentedStreamManager = e, this.events = en(), this.mcuSession = new on(this.events, { onReset: this.reset }), this.stateMachine = new Kt(this.events), this.streamsManagerProvider = new An(
1561
1648
  this.mainRemoteStreamsManager,
1562
1649
  this.recvRemoteStreamsManager
1563
- ), this.deferredStartRecvSessionRunner = new kt({
1650
+ ), this.deferredStartRecvSessionRunner = new xt({
1564
1651
  subscribe: (t) => this.stateMachine.onStateChange(t),
1565
- isReady: (t) => t === ne.IN_ROOM,
1566
- isCancelled: (t) => t === ne.IDLE,
1652
+ isReady: (t) => t === re.IN_ROOM,
1653
+ isCancelled: (t) => t === re.IDLE,
1567
1654
  onExecute: (t) => {
1568
- const s = gn(this.stateMachine);
1655
+ const s = In(this.stateMachine);
1569
1656
  this.startRecvSession(t.audioId, {
1570
1657
  sendOffer: t.sendOffer,
1571
1658
  token: s
@@ -1582,6 +1669,15 @@ class Tn {
1582
1669
  get isCallActive() {
1583
1670
  return this.mcuSession.isCallActive;
1584
1671
  }
1672
+ get number() {
1673
+ return this.stateMachine.number;
1674
+ }
1675
+ get isCallInitiator() {
1676
+ return this.stateMachine.isCallInitiator;
1677
+ }
1678
+ get isDirectP2PRoom() {
1679
+ return this.stateMachine.isDirectP2PRoom;
1680
+ }
1585
1681
  // For testing purposes
1586
1682
  getStreamsManagerProvider() {
1587
1683
  return this.streamsManagerProvider;
@@ -1611,7 +1707,7 @@ class Tn {
1611
1707
  subscribeToApiEvents(e) {
1612
1708
  this.stateMachine.subscribeToApiEvents(e.events);
1613
1709
  }
1614
- startCall = async (e, t, s) => (this.isPendingCall = !0, this.events.emit("start-call", {
1710
+ startCall = async (e, t, s) => (this.isPendingCall = !0, this.events.emit(E.START_CALL, {
1615
1711
  number: s.number,
1616
1712
  answer: !1
1617
1713
  }), this.mcuSession.startCall(e, t, s).finally(() => {
@@ -1626,7 +1722,7 @@ class Tn {
1626
1722
  answerToIncomingCall = async (e, t) => {
1627
1723
  this.isPendingAnswer = !0;
1628
1724
  const s = e();
1629
- return this.events.emit("start-call", {
1725
+ return this.events.emit(E.START_CALL, {
1630
1726
  answer: !0,
1631
1727
  number: s.remote_identity.uri.user
1632
1728
  }), this.mcuSession.answerToIncomingCall(s, t).finally(() => {
@@ -1645,10 +1741,13 @@ class Tn {
1645
1741
  return this.stateMachine.token;
1646
1742
  }
1647
1743
  getRecvQuality() {
1648
- const e = this.recvSession?.getEffectiveQuality();
1744
+ const { recvSession: e } = this;
1745
+ if (e === void 0)
1746
+ return;
1747
+ const t = e.getEffectiveQuality();
1649
1748
  return {
1650
- recvQuality: this.recvQuality,
1651
- effectiveQuality: e
1749
+ quality: e.getQuality(),
1750
+ effectiveQuality: t
1652
1751
  };
1653
1752
  }
1654
1753
  getActivePeerConnection = () => this.roleManager.hasSpectator() ? this.recvSession?.peerConnection : this.mcuSession.connection;
@@ -1668,60 +1767,27 @@ class Tn {
1668
1767
  return this.mcuSession.restartIce(e);
1669
1768
  }
1670
1769
  async setRecvQuality(e) {
1671
- const t = this.recvQuality;
1672
- if (this.recvQuality = e, this.emitRecvQualityRequested(e, t), !this.roleManager.hasSpectator())
1673
- return this.emitRecvQualityChanged(t, e, {
1674
- applied: !1,
1675
- reason: "not-spectator"
1676
- }), !1;
1677
- const { recvSession: s } = this;
1678
- if (!s)
1679
- return this.emitRecvQualityChanged(t, e, {
1680
- applied: !1,
1681
- reason: "no-session"
1682
- }), !1;
1683
- try {
1684
- const i = await s.applyQuality(e);
1685
- return this.emitRecvQualityChanged(
1686
- t,
1687
- e,
1688
- i.applied ? { applied: !0, effectiveQuality: i.effectiveQuality } : {
1689
- applied: !1,
1690
- reason: "no-effective-change",
1691
- effectiveQuality: i.effectiveQuality
1692
- }
1693
- ), i.applied;
1694
- } catch (i) {
1695
- const r = s.getEffectiveQuality();
1696
- throw this.emitRecvQualityChanged(t, e, {
1697
- applied: !1,
1698
- reason: "renegotiate-failed",
1699
- effectiveQuality: r
1700
- }), i;
1701
- }
1702
- }
1703
- emitRecvQualityRequested(e, t) {
1704
- this.events.trigger(S.RECV_QUALITY_REQUESTED, {
1770
+ const { recvSession: t } = this;
1771
+ if (!this.roleManager.hasSpectator() || !t)
1772
+ return !1;
1773
+ const s = t.getQuality(), i = await t.applyQuality(e);
1774
+ return i.applied && this.events.trigger(E.RECV_QUALITY_CHANGED, {
1775
+ previousQuality: s,
1705
1776
  quality: e,
1706
- previous: t,
1707
- source: "api"
1708
- });
1777
+ effectiveQuality: i.effectiveQuality
1778
+ }), i.applied;
1709
1779
  }
1710
- emitRecvQualityChanged(e, t, s) {
1711
- const i = s.applied ? { previous: e, next: t, applied: !0, effectiveQuality: s.effectiveQuality } : {
1712
- previous: e,
1713
- next: t,
1714
- applied: !1,
1715
- reason: s.reason,
1716
- effectiveQuality: s.effectiveQuality
1717
- };
1718
- this.events.trigger(S.RECV_QUALITY_CHANGED, i);
1780
+ async failed(e, t) {
1781
+ this.emitFailedCall(e, t), await this.endCall();
1782
+ }
1783
+ emitFailedCall(e, t) {
1784
+ this.events.trigger(E.FAILED, { message: e, cause: t, originator: "local" });
1719
1785
  }
1720
1786
  reset = () => {
1721
1787
  this.mainRemoteStreamsManager.reset(), this.roleManager.reset(), this.recvRemoteStreamsManager.reset(), this.stopRecvSession(), this.deferredStartRecvSessionRunner.cancel(), this.streamsChangeTracker.reset();
1722
1788
  };
1723
1789
  subscribeCallStatusChange() {
1724
- const { ACCEPTED: e, CONFIRMED: t, ENDED: s, FAILED: i } = S, r = this.createCallStatusChangeListener();
1790
+ const { ACCEPTED: e, CONFIRMED: t, ENDED: s, FAILED: i } = E, r = this.createCallStatusChangeListener();
1725
1791
  this.onRace([e, t, s, i], r);
1726
1792
  }
1727
1793
  /** Хранит prev/next и эмитит CALL_STATUS_CHANGED только при реальном изменении. */
@@ -1729,12 +1795,12 @@ class Tn {
1729
1795
  let e = this.isCallActive;
1730
1796
  return () => {
1731
1797
  const t = this.isCallActive;
1732
- t !== e && this.events.trigger(S.CALL_STATUS_CHANGED, { isCallActive: t }), e = t;
1798
+ t !== e && this.events.trigger(E.CALL_STATUS_CHANGED, { isCallActive: t }), e = t;
1733
1799
  };
1734
1800
  }
1735
1801
  subscribeMcuRemoteTrackEvents() {
1736
- this.on(S.PEER_CONNECTION_ONTRACK, (e) => {
1737
- this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, Te(e));
1802
+ this.on(E.PEER_CONNECTION_ONTRACK, (e) => {
1803
+ this.addRemoteTrack(this.mainRemoteStreamsManager, e.track, Se(e));
1738
1804
  });
1739
1805
  }
1740
1806
  addRemoteTrack(e, t, s) {
@@ -1769,7 +1835,7 @@ class Tn {
1769
1835
  this.emitEventChangedRemoteTracks(c, t, { trackId: s, participantId: i }), (a || r) && this.emitEventChangedRemoteStreams(c);
1770
1836
  }
1771
1837
  emitEventChangedRemoteTracks(e, t, { trackId: s, participantId: i }) {
1772
- this.events.trigger(S.REMOTE_TRACKS_CHANGED, {
1838
+ this.events.trigger(E.REMOTE_TRACKS_CHANGED, {
1773
1839
  streams: e,
1774
1840
  changeType: t,
1775
1841
  trackId: s,
@@ -1780,7 +1846,7 @@ class Tn {
1780
1846
  this.emitEventChangedRemoteStreams(this.getRemoteStreams());
1781
1847
  };
1782
1848
  emitEventChangedRemoteStreams(e) {
1783
- this.streamsChangeTracker.hasChanged(e) && (this.streamsChangeTracker.updateLastEmittedStreams(e), this.events.trigger(S.REMOTE_STREAMS_CHANGED, { streams: e }));
1849
+ this.streamsChangeTracker.hasChanged(e) && (this.streamsChangeTracker.updateLastEmittedStreams(e), this.events.trigger(E.REMOTE_STREAMS_CHANGED, { streams: e }));
1784
1850
  }
1785
1851
  getActiveStreamsManagerTools() {
1786
1852
  return this.streamsManagerProvider.getActiveStreamsManagerTools({
@@ -1790,7 +1856,7 @@ class Tn {
1790
1856
  }
1791
1857
  attachRecvSessionTracks(e) {
1792
1858
  const { peerConnection: t } = e, s = (i) => {
1793
- this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, Te(i));
1859
+ this.addRemoteTrack(this.recvRemoteStreamsManager, i.track, Se(i));
1794
1860
  };
1795
1861
  t.addEventListener("track", s), this.disposeRecvSessionTrackListener = () => {
1796
1862
  t.removeEventListener("track", s);
@@ -1801,22 +1867,23 @@ class Tn {
1801
1867
  if (i === void 0)
1802
1868
  return;
1803
1869
  this.stopRecvSession();
1804
- const a = {
1805
- quality: this.recvQuality,
1870
+ const r = {
1806
1871
  audioChannel: e
1807
- }, o = new Zt(a, { sendOffer: t });
1808
- this.recvSession = o, this.recvRemoteStreamsManager.reset(), this.attachRecvSessionTracks(o), o.call({ conferenceNumber: i, token: s }).catch(() => {
1872
+ }, a = new hn(r, { sendOffer: t });
1873
+ this.recvSession = a, this.recvRemoteStreamsManager.reset(), this.attachRecvSessionTracks(a), a.call({ conferenceNumber: i, token: s }).then(() => {
1874
+ this.events.emit("recv-session-started");
1875
+ }).catch(() => {
1809
1876
  this.stopRecvSession();
1810
1877
  });
1811
1878
  }
1812
1879
  stopRecvSession() {
1813
- this.recvSession?.close(), this.recvSession = void 0, this.disposeRecvSessionTrackListener?.(), this.disposeRecvSessionTrackListener = void 0, this.recvRemoteStreamsManager.reset();
1880
+ this.recvSession?.close(), this.recvSession = void 0, this.disposeRecvSessionTrackListener?.(), this.disposeRecvSessionTrackListener = void 0, this.recvRemoteStreamsManager.reset(), this.events.emit("recv-session-ended");
1814
1881
  }
1815
1882
  onRoleChanged = ({
1816
1883
  previous: e,
1817
1884
  next: t
1818
1885
  }) => {
1819
- if (m.isExitingSpectatorRole(e, t) && (this.stopRecvSession(), this.deferredStartRecvSessionRunner.cancel(), this.emitEventChangedRemoteStreamsConnected()), m.isEnteringSpectatorRole(e, t)) {
1886
+ if (p.isExitingSpectatorRole(e, t) && (this.stopRecvSession(), this.deferredStartRecvSessionRunner.cancel(), this.emitEventChangedRemoteStreamsConnected()), p.isEnteringSpectatorRole(e, t)) {
1820
1887
  const s = t.recvParams, { token: i } = this.stateMachine;
1821
1888
  i === void 0 ? this.deferredStartRecvSessionRunner.set({
1822
1889
  audioId: s.audioId,
@@ -1826,7 +1893,7 @@ class Tn {
1826
1893
  sendOffer: s.sendOffer
1827
1894
  });
1828
1895
  }
1829
- m.isExitingAnySpectatorRole(e, t) && this.mcuSession.restoreBitrateForSenders(), m.isEnteringAnySpectatorRole(e, t) && this.mcuSession.setMinBitrateForSenders();
1896
+ p.isExitingAnySpectatorRole(e, t) && this.mcuSession.restoreBitrateForSenders(), p.isEnteringAnySpectatorRole(e, t) && this.mcuSession.setMinBitrateForSenders();
1830
1897
  };
1831
1898
  subscribeContentedStreamEvents() {
1832
1899
  this.contentedStreamManager.on("available", this.emitEventChangedRemoteStreamsConnected), this.contentedStreamManager.on("not-available", this.emitEventChangedRemoteStreamsConnected);
@@ -1839,16 +1906,16 @@ class Tn {
1839
1906
  return this.mcuSession.renegotiate();
1840
1907
  }
1841
1908
  }
1842
- 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 || {});
1843
- const Be = [
1909
+ var L = /* @__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))(L || {});
1910
+ const Ge = [
1844
1911
  "presentation:start",
1845
1912
  "presentation:started",
1846
1913
  "presentation:end",
1847
1914
  "presentation:ended",
1848
1915
  "presentation:failed"
1849
- ], En = () => new f(Be);
1850
- var Sn = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(Sn || {});
1851
- const pn = V({
1916
+ ], fn = () => new M(Ge);
1917
+ var Mn = /* @__PURE__ */ ((n) => (n.IDLE = "presentation:idle", n.STARTING = "presentation:starting", n.ACTIVE = "presentation:active", n.STOPPING = "presentation:stopping", n.FAILED = "presentation:failed", n))(Mn || {});
1918
+ const _n = V({
1852
1919
  types: {
1853
1920
  context: {},
1854
1921
  events: {}
@@ -1860,10 +1927,10 @@ const pn = V({
1860
1927
  logStateChange: (n, e) => {
1861
1928
  d("PresentationStateMachine state changed", e.state);
1862
1929
  },
1863
- setError: I(({ event: n }) => "error" in n && n.error !== void 0 ? {
1930
+ setError: v(({ event: n }) => "error" in n && n.error !== void 0 ? {
1864
1931
  lastError: n.error instanceof Error ? n.error : new Error(JSON.stringify(n.error))
1865
1932
  } : { lastError: void 0 }),
1866
- clearError: I({ lastError: void 0 })
1933
+ clearError: v({ lastError: void 0 })
1867
1934
  }
1868
1935
  }).createMachine({
1869
1936
  id: "presentation",
@@ -2173,9 +2240,9 @@ const pn = V({
2173
2240
  }
2174
2241
  }
2175
2242
  });
2176
- class mn extends x {
2243
+ class bn extends x {
2177
2244
  constructor(e) {
2178
- super(pn), this.subscribeCallEvents(e);
2245
+ super(_n), this.subscribeCallEvents(e);
2179
2246
  }
2180
2247
  get isIdle() {
2181
2248
  return this.state === "presentation:idle";
@@ -2215,38 +2282,38 @@ class mn extends x {
2215
2282
  }
2216
2283
  subscribeCallEvents(e) {
2217
2284
  this.addSubscription(
2218
- e.on(S.START_PRESENTATION, () => {
2285
+ e.on(E.START_PRESENTATION, () => {
2219
2286
  this.send({ type: "SCREEN.STARTING" });
2220
2287
  })
2221
2288
  ), this.addSubscription(
2222
- e.on(S.STARTED_PRESENTATION, () => {
2289
+ e.on(E.STARTED_PRESENTATION, () => {
2223
2290
  this.send({ type: "SCREEN.STARTED" });
2224
2291
  })
2225
2292
  ), this.addSubscription(
2226
- e.on(S.END_PRESENTATION, () => {
2293
+ e.on(E.END_PRESENTATION, () => {
2227
2294
  this.send({ type: "SCREEN.ENDING" });
2228
2295
  })
2229
2296
  ), this.addSubscription(
2230
- e.on(S.ENDED_PRESENTATION, () => {
2297
+ e.on(E.ENDED_PRESENTATION, () => {
2231
2298
  this.send({ type: "SCREEN.ENDED" });
2232
2299
  })
2233
2300
  ), this.addSubscription(
2234
- e.on(S.FAILED_PRESENTATION, (t) => {
2301
+ e.on(E.FAILED_PRESENTATION, (t) => {
2235
2302
  this.send({ type: "SCREEN.FAILED", error: t });
2236
2303
  })
2237
2304
  ), this.addSubscription(
2238
- e.on(S.ENDED, () => {
2305
+ e.on(E.ENDED, () => {
2239
2306
  this.send({ type: "CALL.ENDED" });
2240
2307
  })
2241
2308
  ), this.addSubscription(
2242
- e.on(S.FAILED, (t) => {
2309
+ e.on(E.FAILED, (t) => {
2243
2310
  this.send({ type: "CALL.FAILED", error: t });
2244
2311
  })
2245
2312
  );
2246
2313
  }
2247
2314
  }
2248
- const Cn = 1, yi = (n) => ct(n);
2249
- class Nn {
2315
+ const On = 1, Vi = (n) => ut(n);
2316
+ class Pn {
2250
2317
  events;
2251
2318
  stateMachine;
2252
2319
  promisePendingStartPresentation;
@@ -2259,7 +2326,7 @@ class Nn {
2259
2326
  callManager: e,
2260
2327
  maxBitrate: t
2261
2328
  }) {
2262
- this.callManager = e, this.maxBitrate = t, this.events = En(), this.stateMachine = new mn(this.callManager.events), this.subscribe();
2329
+ this.callManager = e, this.maxBitrate = t, this.events = fn(), this.stateMachine = new bn(this.callManager.events), this.subscribe();
2263
2330
  }
2264
2331
  get isPendingPresentation() {
2265
2332
  return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
@@ -2298,8 +2365,8 @@ class Nn {
2298
2365
  const i = this.callManager.getEstablishedRTCSession();
2299
2366
  return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
2300
2367
  const a = r instanceof Error ? r : new Error(String(r));
2301
- throw this.events.trigger(P.FAILED_PRESENTATION, a), r;
2302
- }) : t && this.events.trigger(P.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
2368
+ throw this.events.trigger(L.FAILED_PRESENTATION, a), r;
2369
+ }) : t && this.events.trigger(L.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
2303
2370
  this.resetPresentation();
2304
2371
  });
2305
2372
  }
@@ -2338,15 +2405,15 @@ class Nn {
2338
2405
  }
2339
2406
  subscribe() {
2340
2407
  this.callManager.on("presentation:start", (e) => {
2341
- this.events.trigger(P.START_PRESENTATION, e);
2408
+ this.events.trigger(L.START_PRESENTATION, e);
2342
2409
  }), this.callManager.on("presentation:started", (e) => {
2343
- this.events.trigger(P.STARTED_PRESENTATION, e);
2410
+ this.events.trigger(L.STARTED_PRESENTATION, e);
2344
2411
  }), this.callManager.on("presentation:end", (e) => {
2345
- this.events.trigger(P.END_PRESENTATION, e);
2412
+ this.events.trigger(L.END_PRESENTATION, e);
2346
2413
  }), this.callManager.on("presentation:ended", (e) => {
2347
- this.events.trigger(P.ENDED_PRESENTATION, e);
2414
+ this.events.trigger(L.ENDED_PRESENTATION, e);
2348
2415
  }), this.callManager.on("presentation:failed", (e) => {
2349
- this.events.trigger(P.FAILED_PRESENTATION, e);
2416
+ this.events.trigger(L.FAILED_PRESENTATION, e);
2350
2417
  }), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
2351
2418
  }
2352
2419
  async sendPresentationWithDuplicatedCalls(e, {
@@ -2354,7 +2421,7 @@ class Nn {
2354
2421
  stream: s,
2355
2422
  presentationOptions: i,
2356
2423
  options: r = {
2357
- callLimit: Cn
2424
+ callLimit: On
2358
2425
  }
2359
2426
  }) {
2360
2427
  const a = async () => this.sendPresentation(
@@ -2363,7 +2430,7 @@ class Nn {
2363
2430
  s,
2364
2431
  i
2365
2432
  ), o = () => !!this.streamPresentationCurrent;
2366
- return this.cancelableSendPresentationWithRepeatedCalls = re({
2433
+ return this.cancelableSendPresentationWithRepeatedCalls = ce({
2367
2434
  targetFunction: a,
2368
2435
  isComplete: o,
2369
2436
  isRejectAsValid: !0,
@@ -2378,7 +2445,7 @@ class Nn {
2378
2445
  sendEncodings: o,
2379
2446
  onAddedTransceiver: c
2380
2447
  }) {
2381
- const l = W(s, { contentHint: r });
2448
+ const l = Y(s, { contentHint: r });
2382
2449
  if (l === void 0)
2383
2450
  throw new Error("No streamPresentationTarget");
2384
2451
  this.streamPresentationCurrent = l;
@@ -2388,8 +2455,8 @@ class Nn {
2388
2455
  onAddedTransceiver: c
2389
2456
  })).then(this.setMaxBitrate).then(() => s).catch((g) => {
2390
2457
  this.removeStreamPresentationCurrent();
2391
- const E = g instanceof Error ? g : new Error(String(g));
2392
- throw this.events.trigger(P.FAILED_PRESENTATION, E), g;
2458
+ const S = g instanceof Error ? g : new Error(String(g));
2459
+ throw this.events.trigger(L.FAILED_PRESENTATION, S), g;
2393
2460
  });
2394
2461
  return this.promisePendingStartPresentation = T, T.finally(() => {
2395
2462
  this.promisePendingStartPresentation = void 0;
@@ -2400,7 +2467,7 @@ class Nn {
2400
2467
  if (!e || !t || s === void 0)
2401
2468
  return;
2402
2469
  const i = e.getSenders();
2403
- await Ft(i, t, s);
2470
+ await Vt(i, t, s);
2404
2471
  };
2405
2472
  getRtcSessionProtected = () => {
2406
2473
  const e = this.callManager.getEstablishedRTCSession();
@@ -2421,7 +2488,7 @@ class Nn {
2421
2488
  delete this.streamPresentationCurrent;
2422
2489
  }
2423
2490
  }
2424
- class Rn {
2491
+ class yn {
2425
2492
  data;
2426
2493
  getUa;
2427
2494
  constructor(e) {
@@ -2507,8 +2574,8 @@ class Rn {
2507
2574
  return this.data?.register === !0;
2508
2575
  }
2509
2576
  }
2510
- var p = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.DISCONNECTING = "disconnecting", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n.CONNECT_STARTED = "connect-started", n.CONNECT_SUCCEEDED = "connect-succeeded", n.CONNECT_FAILED = "connect-failed", n.CONNECT_PARAMETERS_RESOLVE_SUCCESS = "connect-parameters-resolve-success", n.CONNECT_PARAMETERS_RESOLVE_FAILED = "connect-parameters-resolve-failed", n.CONNECTED_WITH_CONFIGURATION = "connected-with-configuration", n))(p || {});
2511
- const $e = [
2577
+ var m = /* @__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))(m || {});
2578
+ const qe = [
2512
2579
  "connecting",
2513
2580
  "connected",
2514
2581
  "disconnected",
@@ -2518,7 +2585,7 @@ const $e = [
2518
2585
  "registrationFailed",
2519
2586
  "newMessage",
2520
2587
  "sipEvent"
2521
- ], An = [
2588
+ ], Dn = [
2522
2589
  "disconnecting",
2523
2590
  "connect-started",
2524
2591
  "connect-succeeded",
@@ -2526,12 +2593,12 @@ const $e = [
2526
2593
  "connect-parameters-resolve-success",
2527
2594
  "connect-parameters-resolve-failed",
2528
2595
  "connected-with-configuration"
2529
- ], Ge = [...$e, ...An], In = () => new f(Ge);
2530
- function vn(n) {
2596
+ ], Ve = [...qe, ...Dn], Ln = () => new M(Ve);
2597
+ function wn(n) {
2531
2598
  return (e) => `sip:${e}@${n}`;
2532
2599
  }
2533
- const fn = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, qe = (n) => n.trim().replaceAll(" ", "_"), Mn = fn(1e5, 99999999), _n = 3;
2534
- class bn {
2600
+ const Un = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, xe = (n) => n.trim().replaceAll(" ", "_"), Fn = Un(1e5, 99999999), kn = 3;
2601
+ class Bn {
2535
2602
  cancelableConnectWithRepeatedCalls;
2536
2603
  events;
2537
2604
  uaFactory;
@@ -2556,30 +2623,30 @@ class bn {
2556
2623
  }
2557
2624
  let r = !1;
2558
2625
  const a = this.getConnectionConfiguration();
2559
- e !== void 0 && e !== a?.displayName && (r = i.set("display_name", qe(e)), this.updateConnectionConfiguration("displayName", e));
2626
+ e !== void 0 && e !== a?.displayName && (r = i.set("display_name", xe(e)), this.updateConnectionConfiguration("displayName", e));
2560
2627
  const o = r;
2561
2628
  o ? t(o) : s(new Error("nothing changed"));
2562
2629
  });
2563
2630
  disconnect = async () => {
2564
- this.events.trigger(p.DISCONNECTING, {});
2631
+ this.events.trigger(m.DISCONNECTING, {});
2565
2632
  const e = new Promise((s) => {
2566
- this.events.once(p.DISCONNECTED, () => {
2633
+ this.events.once(m.DISCONNECTED, () => {
2567
2634
  s();
2568
2635
  });
2569
2636
  }), t = this.getUa();
2570
- return t ? t.stop() : this.events.trigger(p.DISCONNECTED, { socket: {}, error: !1 }), e.finally(() => {
2637
+ return t ? t.stop() : this.events.trigger(m.DISCONNECTED, { socket: {}, error: !1 }), e.finally(() => {
2571
2638
  t?.removeAllListeners(), this.setUa(void 0), this.stateMachine.reset();
2572
2639
  });
2573
2640
  };
2574
2641
  cancelRequests() {
2575
2642
  this.cancelConnectWithRepeatedCalls();
2576
2643
  }
2577
- connectWithDuplicatedCalls = async (e, { callLimit: t = _n } = {}) => {
2644
+ connectWithDuplicatedCalls = async (e, { callLimit: t = kn } = {}) => {
2578
2645
  const s = async () => this.connectInner(e), i = (r) => {
2579
- const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), l = r != null && !Tt(r);
2646
+ const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), l = r != null && !pt(r);
2580
2647
  return c || l;
2581
2648
  };
2582
- return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = re({
2649
+ return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = ce({
2583
2650
  targetFunction: s,
2584
2651
  isComplete: i,
2585
2652
  callLimit: t,
@@ -2613,37 +2680,37 @@ class bn {
2613
2680
  connectionRecoveryMaxInterval: l,
2614
2681
  userAgent: T,
2615
2682
  displayName: g = "",
2616
- register: E = !1,
2617
- extraHeaders: N = []
2683
+ register: S = !1,
2684
+ extraHeaders: R = []
2618
2685
  }) => {
2619
2686
  this.stateMachine.startInitUa(), this.getUa() && await this.disconnect();
2620
- const { ua: A, helpers: U } = this.uaFactory.createUAWithConfiguration(
2687
+ const { ua: I, helpers: U } = this.uaFactory.createUAWithConfiguration(
2621
2688
  {
2622
2689
  user: e,
2623
2690
  password: t,
2624
2691
  sipServerIp: s,
2625
2692
  sipServerUrl: i,
2626
2693
  displayName: g,
2627
- register: E,
2694
+ register: S,
2628
2695
  sessionTimers: a,
2629
2696
  registerExpires: o,
2630
2697
  connectionRecoveryMinInterval: c,
2631
2698
  connectionRecoveryMaxInterval: l,
2632
2699
  userAgent: T,
2633
2700
  remoteAddress: r,
2634
- extraHeaders: N
2701
+ extraHeaders: R
2635
2702
  },
2636
2703
  this.events
2637
- ), B = A.configuration.uri.user;
2704
+ ), B = I.configuration.uri.user;
2638
2705
  return this.setConnectionConfiguration({
2639
2706
  sipServerIp: s,
2640
2707
  sipServerUrl: i,
2641
2708
  displayName: g,
2642
2709
  authorizationUser: B,
2643
- register: E,
2710
+ register: S,
2644
2711
  user: e,
2645
2712
  password: t
2646
- }), this.setUa(A), this.setGetUri(U.getUri), this.setSocket(U.socket), A;
2713
+ }), this.setUa(I), this.setGetUri(U.getUri), this.setSocket(U.socket), I;
2647
2714
  };
2648
2715
  start = async () => new Promise((e, t) => {
2649
2716
  const s = this.getUa();
@@ -2655,12 +2722,12 @@ class bn {
2655
2722
  i = ((c, l) => {
2656
2723
  if (this.getConnectionConfiguration()?.register === !0)
2657
2724
  return this.registrationManager.subscribeToStartEvents(c, l);
2658
- const g = p.CONNECTED, E = [p.DISCONNECTED];
2659
- return this.events.on(g, c), E.forEach((N) => {
2660
- this.events.on(N, l);
2725
+ const g = m.CONNECTED, S = [m.DISCONNECTED];
2726
+ return this.events.on(g, c), S.forEach((R) => {
2727
+ this.events.on(R, l);
2661
2728
  }), () => {
2662
- this.events.off(g, c), E.forEach((N) => {
2663
- this.events.off(N, l);
2729
+ this.events.off(g, c), S.forEach((R) => {
2730
+ this.events.off(R, l);
2664
2731
  });
2665
2732
  };
2666
2733
  })(() => {
@@ -2673,14 +2740,14 @@ class bn {
2673
2740
  this.cancelableConnectWithRepeatedCalls?.cancel();
2674
2741
  }
2675
2742
  proxyEvents() {
2676
- this.events.on(p.CONNECTED, () => {
2743
+ this.events.on(m.CONNECTED, () => {
2677
2744
  const e = this.getConnectionConfiguration();
2678
- e !== void 0 && this.events.trigger(p.CONNECTED_WITH_CONFIGURATION, e);
2745
+ e !== void 0 && this.events.trigger(m.CONNECTED_WITH_CONFIGURATION, e);
2679
2746
  });
2680
2747
  }
2681
2748
  }
2682
- var On = /* @__PURE__ */ ((n) => (n.IDLE = "connection:idle", n.PREPARING = "connection:preparing", n.CONNECTING = "connection:connecting", n.CONNECTED = "connection:connected", n.REGISTERED = "connection:registered", n.ESTABLISHED = "connection:established", n.DISCONNECTED = "connection:disconnected", n.FAILED = "connection:failed", n))(On || {}), Ve = /* @__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))(Ve || {});
2683
- const yn = Object.values(Ve), Dn = V({
2749
+ var $n = /* @__PURE__ */ ((n) => (n.IDLE = "connection:idle", n.PREPARING = "connection:preparing", n.CONNECTING = "connection:connecting", n.CONNECTED = "connection:connected", n.REGISTERED = "connection:registered", n.ESTABLISHED = "connection:established", n.DISCONNECTED = "connection:disconnected", n.FAILED = "connection:failed", n))($n || {}), He = /* @__PURE__ */ ((n) => (n.START_CONNECT = "START_CONNECT", n.START_INIT_UA = "START_INIT_UA", n.UA_CONNECTED = "UA_CONNECTED", n.UA_REGISTERED = "UA_REGISTERED", n.UA_UNREGISTERED = "UA_UNREGISTERED", n.UA_DISCONNECTED = "UA_DISCONNECTED", n.CONNECTION_FAILED = "CONNECTION_FAILED", n.RESET = "RESET", n))(He || {});
2750
+ const Gn = Object.values(He), qn = V({
2684
2751
  types: {
2685
2752
  context: {},
2686
2753
  events: {}
@@ -2692,13 +2759,13 @@ const yn = Object.values(Ve), Dn = V({
2692
2759
  logStateChange: (n, e) => {
2693
2760
  d("ConnectionStateMachine state changed", e.state);
2694
2761
  },
2695
- setError: I({
2762
+ setError: v({
2696
2763
  error: ({ event: n }) => {
2697
2764
  if (n.type === "CONNECTION_FAILED" && "error" in n)
2698
2765
  return n.error;
2699
2766
  }
2700
2767
  }),
2701
- clearError: I({
2768
+ clearError: v({
2702
2769
  error: () => {
2703
2770
  }
2704
2771
  })
@@ -3060,11 +3127,11 @@ const yn = Object.values(Ve), Dn = V({
3060
3127
  }
3061
3128
  }
3062
3129
  });
3063
- class Pn extends x {
3130
+ class Vn extends x {
3064
3131
  events;
3065
3132
  unsubscribeFromEvents;
3066
3133
  constructor(e) {
3067
- super(Dn), this.events = e, this.subscribeToEvents();
3134
+ super(qn), this.events = e, this.subscribeToEvents();
3068
3135
  }
3069
3136
  get isIdle() {
3070
3137
  return this.hasState(
@@ -3146,7 +3213,7 @@ class Pn extends x {
3146
3213
  return this.actor.getSnapshot().can({ type: e });
3147
3214
  }
3148
3215
  getValidEvents() {
3149
- return yn.filter((e) => this.canTransition(e));
3216
+ return Gn.filter((e) => this.canTransition(e));
3150
3217
  }
3151
3218
  hasState(e) {
3152
3219
  return this.actor.getSnapshot().matches(e);
@@ -3218,7 +3285,7 @@ class Pn extends x {
3218
3285
  this.toFailed(e instanceof Error ? e : void 0);
3219
3286
  };
3220
3287
  }
3221
- class wn {
3288
+ class xn {
3222
3289
  events;
3223
3290
  getUaProtected;
3224
3291
  constructor(e) {
@@ -3227,13 +3294,13 @@ class wn {
3227
3294
  async register() {
3228
3295
  const e = this.getUaProtected();
3229
3296
  return new Promise((t, s) => {
3230
- e.on(p.REGISTERED, t), e.on(p.REGISTRATION_FAILED, s), e.register();
3297
+ e.on(m.REGISTERED, t), e.on(m.REGISTRATION_FAILED, s), e.register();
3231
3298
  });
3232
3299
  }
3233
3300
  async unregister() {
3234
3301
  const e = this.getUaProtected();
3235
3302
  return new Promise((t) => {
3236
- e.on(p.UNREGISTERED, t), e.unregister();
3303
+ e.on(m.UNREGISTERED, t), e.unregister();
3237
3304
  });
3238
3305
  }
3239
3306
  async tryRegister() {
@@ -3245,7 +3312,7 @@ class wn {
3245
3312
  return this.register();
3246
3313
  }
3247
3314
  subscribeToStartEvents(e, t) {
3248
- const s = p.REGISTERED, i = [p.REGISTRATION_FAILED, p.DISCONNECTED];
3315
+ const s = m.REGISTERED, i = [m.REGISTRATION_FAILED, m.DISCONNECTED];
3249
3316
  return this.events.on(s, e), i.forEach((r) => {
3250
3317
  this.events.on(r, t);
3251
3318
  }), () => {
@@ -3255,7 +3322,7 @@ class wn {
3255
3322
  };
3256
3323
  }
3257
3324
  }
3258
- class Ln {
3325
+ class Hn {
3259
3326
  uaFactory;
3260
3327
  getUaProtected;
3261
3328
  constructor(e) {
@@ -3307,20 +3374,20 @@ class Ln {
3307
3374
  userAgent: e,
3308
3375
  sipServerIp: s
3309
3376
  }), T = this.uaFactory.createUA({ ...l, remoteAddress: r, extraHeaders: a }), g = () => {
3310
- const N = new Error("Telephony is not available");
3311
- c(N);
3377
+ const R = new Error("Telephony is not available");
3378
+ c(R);
3312
3379
  };
3313
- T.once(p.DISCONNECTED, g);
3314
- const E = () => {
3315
- T.removeAllListeners(), T.once(p.DISCONNECTED, () => {
3380
+ T.once(m.DISCONNECTED, g);
3381
+ const S = () => {
3382
+ T.removeAllListeners(), T.once(m.DISCONNECTED, () => {
3316
3383
  o();
3317
3384
  }), T.stop();
3318
3385
  };
3319
- T.once(p.CONNECTED, E), T.start();
3386
+ T.once(m.CONNECTED, S), T.start();
3320
3387
  });
3321
3388
  }
3322
3389
  }
3323
- const Un = (n) => {
3390
+ const Wn = (n) => {
3324
3391
  const e = [];
3325
3392
  return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
3326
3393
  };
@@ -3349,10 +3416,10 @@ class k {
3349
3416
  throw new Error("user is required for authorized connection");
3350
3417
  }
3351
3418
  static resolveAuthorizationUser(e, t) {
3352
- return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${Mn()}`;
3419
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${Fn()}`;
3353
3420
  }
3354
3421
  static buildExtraHeaders(e, t) {
3355
- const s = e !== void 0 && e !== "" ? Un(e) : [];
3422
+ const s = e !== void 0 && e !== "" ? Wn(e) : [];
3356
3423
  return t === void 0 ? s : [...s, ...t];
3357
3424
  }
3358
3425
  createConfiguration({
@@ -3376,24 +3443,24 @@ class k {
3376
3443
  sipServerIp: r,
3377
3444
  sipServerUrl: s
3378
3445
  });
3379
- const E = k.resolveAuthorizationUser(a, e), N = vn(r), D = N(E), A = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
3446
+ const S = k.resolveAuthorizationUser(a, e), R = wn(r), D = R(S), I = new this.JsSIP.WebSocketInterface(`wss://${s}/webrtc/wss/`);
3380
3447
  return {
3381
3448
  configuration: {
3382
3449
  password: t,
3383
3450
  register: a,
3384
3451
  uri: D,
3385
- display_name: qe(i),
3452
+ display_name: xe(i),
3386
3453
  user_agent: g,
3387
3454
  sdpSemantics: "unified-plan",
3388
- sockets: [A],
3455
+ sockets: [I],
3389
3456
  session_timers: o,
3390
3457
  register_expires: c,
3391
3458
  connection_recovery_min_interval: l,
3392
3459
  connection_recovery_max_interval: T
3393
3460
  },
3394
3461
  helpers: {
3395
- socket: A,
3396
- getUri: N
3462
+ socket: I,
3463
+ getUri: R
3397
3464
  }
3398
3465
  };
3399
3466
  }
@@ -3411,13 +3478,13 @@ class k {
3411
3478
  extraHeaders: e.extraHeaders
3412
3479
  });
3413
3480
  return t.eachTriggers((a, o) => {
3414
- const c = $e.find((l) => l === o);
3481
+ const c = qe.find((l) => l === o);
3415
3482
  c && r.on(c, a);
3416
3483
  }), { ua: r, helpers: i };
3417
3484
  }
3418
3485
  }
3419
- const xe = "Not ready for connection", Fn = (n) => n instanceof Error && n.message === xe, kn = () => new Error(xe), Bn = async (n) => typeof n == "function" ? n() : n;
3420
- class $n {
3486
+ const We = "Not ready for connection", Qn = (n) => n instanceof Error && n.message === We, Yn = () => new Error(We), zn = async (n) => typeof n == "function" ? n() : n;
3487
+ class Jn {
3421
3488
  events;
3422
3489
  stateMachine;
3423
3490
  ua;
@@ -3428,15 +3495,15 @@ class $n {
3428
3495
  sipOperations;
3429
3496
  configurationManager;
3430
3497
  constructor({ JsSIP: e }) {
3431
- this.events = In(), this.uaFactory = new k(e), this.registrationManager = new wn({
3498
+ this.events = Ln(), this.uaFactory = new k(e), this.registrationManager = new xn({
3432
3499
  events: this.events,
3433
3500
  getUaProtected: this.getUaProtected
3434
- }), this.stateMachine = new Pn(this.events), this.configurationManager = new Rn({
3501
+ }), this.stateMachine = new Vn(this.events), this.configurationManager = new yn({
3435
3502
  getUa: this.getUa
3436
- }), this.sipOperations = new Ln({
3503
+ }), this.sipOperations = new Hn({
3437
3504
  uaFactory: this.uaFactory,
3438
3505
  getUaProtected: this.getUaProtected
3439
- }), this.connectionFlow = new bn({
3506
+ }), this.connectionFlow = new Bn({
3440
3507
  events: this.events,
3441
3508
  uaFactory: this.uaFactory,
3442
3509
  stateMachine: this.stateMachine,
@@ -3529,6 +3596,13 @@ class $n {
3529
3596
  }
3530
3597
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
3531
3598
  getUri = (e) => e;
3599
+ getUser() {
3600
+ try {
3601
+ return this.getUaProtected().configuration.uri.user;
3602
+ } catch {
3603
+ return;
3604
+ }
3605
+ }
3532
3606
  getUaProtected = () => {
3533
3607
  if (!this.ua)
3534
3608
  throw new Error("UA not initialized");
@@ -3537,7 +3611,7 @@ class $n {
3537
3611
  getUa = () => this.ua;
3538
3612
  connectWithProcessError = async (e, t) => {
3539
3613
  if (!(t?.hasReadyForConnection?.() ?? !0))
3540
- throw kn();
3614
+ throw Yn();
3541
3615
  return this.processConnect(e, t).catch(async (i) => {
3542
3616
  const r = i;
3543
3617
  return this.disconnect().then(() => {
@@ -3547,18 +3621,18 @@ class $n {
3547
3621
  });
3548
3622
  });
3549
3623
  };
3550
- processConnect = async (e, t) => (this.events.trigger(p.CONNECT_STARTED, {}), Bn(e).then((s) => (this.events.trigger(p.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
3551
- throw this.events.trigger(p.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
3552
- }).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(p.CONNECT_SUCCEEDED, {
3624
+ processConnect = async (e, t) => (this.events.trigger(m.CONNECT_STARTED, {}), zn(e).then((s) => (this.events.trigger(m.CONNECT_PARAMETERS_RESOLVE_SUCCESS, s), s)).catch((s) => {
3625
+ throw this.events.trigger(m.CONNECT_PARAMETERS_RESOLVE_FAILED, s), s;
3626
+ }).then(async (s) => this.connectionFlow.connect(s, t)).then((s) => (this.events.trigger(m.CONNECT_SUCCEEDED, {
3553
3627
  ...s
3554
3628
  }), s)).catch((s) => {
3555
3629
  const i = s ?? new Error("Failed to connect to server");
3556
- throw this.events.trigger(p.CONNECT_FAILED, i), i;
3630
+ throw this.events.trigger(m.CONNECT_FAILED, i), i;
3557
3631
  }));
3558
3632
  }
3559
- class Gn {
3633
+ class jn {
3560
3634
  connectionManager;
3561
- stackPromises = Ie({
3635
+ stackPromises = fe({
3562
3636
  noRunIsNotActual: !0
3563
3637
  });
3564
3638
  constructor({ connectionManager: e }) {
@@ -3570,11 +3644,11 @@ class Gn {
3570
3644
  this.stackPromises.stop();
3571
3645
  }
3572
3646
  }
3573
- const Ee = 0, qn = 30;
3574
- class Vn {
3575
- countInner = Ee;
3576
- initialCount = Ee;
3577
- limitInner = qn;
3647
+ const me = 0, Kn = 30;
3648
+ class Xn {
3649
+ countInner = me;
3650
+ initialCount = me;
3651
+ limitInner = Kn;
3578
3652
  isInProgress = !1;
3579
3653
  onStatusChange;
3580
3654
  constructor({
@@ -3607,7 +3681,7 @@ class Vn {
3607
3681
  this.countInner = this.initialCount, this.finishAttempt();
3608
3682
  }
3609
3683
  }
3610
- class xn {
3684
+ class Zn {
3611
3685
  connectionManager;
3612
3686
  interval;
3613
3687
  checkTelephonyByTimeout = void 0;
@@ -3623,7 +3697,7 @@ class xn {
3623
3697
  onSuccessRequest: t,
3624
3698
  onFailRequest: s
3625
3699
  }) {
3626
- this.stop(), this.cancelableBeforeRequest = new X(e), this.checkTelephonyByTimeout = it({
3700
+ this.stop(), this.cancelableBeforeRequest = new X(e), this.checkTelephonyByTimeout = ct({
3627
3701
  isDontStopOnFail: !0,
3628
3702
  requestInterval: this.interval,
3629
3703
  request: async () => {
@@ -3644,7 +3718,7 @@ class xn {
3644
3718
  }
3645
3719
  }
3646
3720
  var _ = /* @__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))(_ || {});
3647
- const He = [
3721
+ const Qe = [
3648
3722
  "before-attempt",
3649
3723
  "success",
3650
3724
  "failed-all-attempts",
@@ -3652,8 +3726,8 @@ const He = [
3652
3726
  "changed-attempt-status",
3653
3727
  "stop-attempts-by-error",
3654
3728
  "limit-reached-attempts"
3655
- ], Hn = () => new f(He);
3656
- class ce {
3729
+ ], es = () => new M(Qe);
3730
+ class he {
3657
3731
  callManager;
3658
3732
  disposers = [];
3659
3733
  constructor({ callManager: e }) {
@@ -3678,15 +3752,15 @@ class ce {
3678
3752
  this.callManager.isCallActive ? e?.() : t();
3679
3753
  }
3680
3754
  }
3681
- const Qn = 15e3, Wn = 2;
3682
- class Yn {
3755
+ const ts = 15e3, ns = 2;
3756
+ class ss {
3683
3757
  connectionManager;
3684
3758
  pingServerByTimeoutWithFailCalls;
3685
3759
  constructor({ connectionManager: e }) {
3686
- this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = rt(Wn, {
3760
+ this.connectionManager = e, this.pingServerByTimeoutWithFailCalls = dt(ns, {
3687
3761
  whenPossibleRequest: async () => {
3688
3762
  },
3689
- requestInterval: Qn,
3763
+ requestInterval: ts,
3690
3764
  request: async () => (d("ping"), this.connectionManager.ping().then(() => {
3691
3765
  d("ping success");
3692
3766
  }))
@@ -3699,16 +3773,16 @@ class Yn {
3699
3773
  this.pingServerByTimeoutWithFailCalls.stop();
3700
3774
  }
3701
3775
  }
3702
- class zn {
3776
+ class is {
3703
3777
  pingServerRequester;
3704
3778
  notActiveCallSubscriber;
3705
3779
  constructor({
3706
3780
  connectionManager: e,
3707
3781
  callManager: t
3708
3782
  }) {
3709
- this.pingServerRequester = new Yn({
3783
+ this.pingServerRequester = new ss({
3710
3784
  connectionManager: e
3711
- }), this.notActiveCallSubscriber = new ce({ callManager: t });
3785
+ }), this.notActiveCallSubscriber = new he({ callManager: t });
3712
3786
  }
3713
3787
  start({ onFailRequest: e }) {
3714
3788
  d("start"), this.notActiveCallSubscriber.subscribe({
@@ -3727,7 +3801,7 @@ class zn {
3727
3801
  this.notActiveCallSubscriber.unsubscribe();
3728
3802
  }
3729
3803
  }
3730
- class Jn {
3804
+ class rs {
3731
3805
  connectionManager;
3732
3806
  isRegistrationFailed = !1;
3733
3807
  disposers = [];
@@ -3736,7 +3810,7 @@ class Jn {
3736
3810
  connectionManager: e,
3737
3811
  callManager: t
3738
3812
  }) {
3739
- this.connectionManager = e, this.notActiveCallSubscriber = new ce({ callManager: t });
3813
+ this.connectionManager = e, this.notActiveCallSubscriber = new he({ callManager: t });
3740
3814
  }
3741
3815
  subscribe(e) {
3742
3816
  this.unsubscribe(), this.disposers.push(
@@ -3763,12 +3837,12 @@ class Jn {
3763
3837
  this.isRegistrationFailed = !1;
3764
3838
  }
3765
3839
  }
3766
- const jn = 3e3, Xn = 15e3, Se = {
3840
+ const as = 3e3, os = 15e3, pe = {
3767
3841
  LIMIT_REACHED: "Limit reached",
3768
3842
  FAILED_TO_RECONNECT: "Failed to reconnect"
3769
- }, Kn = async () => {
3770
- }, Zn = (n) => !0;
3771
- class es {
3843
+ }, cs = async () => {
3844
+ }, ds = (n) => !0;
3845
+ class hs {
3772
3846
  events;
3773
3847
  connectionManager;
3774
3848
  connectionQueueManager;
@@ -3788,21 +3862,21 @@ class es {
3788
3862
  connectionManager: t,
3789
3863
  callManager: s
3790
3864
  }, i) {
3791
- const r = i?.onBeforeRetry ?? Kn, a = i?.canRetryOnError ?? Zn;
3792
- this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = Hn(), this.checkTelephonyRequester = new xn({
3865
+ const r = i?.onBeforeRetry ?? cs, a = i?.canRetryOnError ?? ds;
3866
+ this.connectionQueueManager = e, this.connectionManager = t, this.onBeforeRetry = r, this.canRetryOnError = a, this.networkInterfacesSubscriber = i?.networkInterfacesSubscriber, this.resumeFromSleepModeSubscriber = i?.resumeFromSleepModeSubscriber, this.events = es(), this.checkTelephonyRequester = new Zn({
3793
3867
  connectionManager: t,
3794
- interval: i?.checkTelephonyRequestInterval ?? Xn
3795
- }), this.pingServerIfNotActiveCallRequester = new zn({
3868
+ interval: i?.checkTelephonyRequestInterval ?? os
3869
+ }), this.pingServerIfNotActiveCallRequester = new is({
3796
3870
  connectionManager: t,
3797
3871
  callManager: s
3798
- }), this.registrationFailedOutOfCallSubscriber = new Jn({
3872
+ }), this.registrationFailedOutOfCallSubscriber = new rs({
3799
3873
  connectionManager: t,
3800
3874
  callManager: s
3801
- }), this.attemptsState = new Vn({
3875
+ }), this.attemptsState = new Xn({
3802
3876
  onStatusChange: this.emitStatusChange
3803
- }), this.cancelableRequestBeforeRetry = new X(r), this.delayBetweenAttempts = new at(
3804
- i?.timeoutBetweenAttempts ?? jn
3805
- ), this.notActiveCallSubscriber = new ce({ callManager: s });
3877
+ }), this.cancelableRequestBeforeRetry = new X(r), this.delayBetweenAttempts = new ht(
3878
+ i?.timeoutBetweenAttempts ?? as
3879
+ ), this.notActiveCallSubscriber = new he({ callManager: s });
3806
3880
  }
3807
3881
  start(e) {
3808
3882
  d("auto connector start"), this.restartConnectionAttempts(e), this.subscribeToNotActiveCall(e);
@@ -3867,7 +3941,7 @@ class es {
3867
3941
  }
3868
3942
  }
3869
3943
  handleConnectionError(e, t) {
3870
- if (Fn(e)) {
3944
+ if (Qn(e)) {
3871
3945
  this.attemptsState.finishAttempt(), this.events.trigger(_.STOP_ATTEMPTS_BY_ERROR, e);
3872
3946
  return;
3873
3947
  }
@@ -3875,14 +3949,14 @@ class es {
3875
3949
  d("executeConnectionAttempt: error does not allow retry", e), this.attemptsState.finishAttempt(), this.events.trigger(_.STOP_ATTEMPTS_BY_ERROR, e);
3876
3950
  return;
3877
3951
  }
3878
- if (ht(e)) {
3952
+ if (Tt(e)) {
3879
3953
  d("executeConnectionAttempt: not actual error", e), this.attemptsState.finishAttempt(), this.events.trigger(_.CANCELLED_ATTEMPTS, e);
3880
3954
  return;
3881
3955
  }
3882
3956
  d("executeConnectionAttempt: error", e), this.scheduleReconnect(t);
3883
3957
  }
3884
3958
  handleLimitReached(e) {
3885
- this.attemptsState.finishAttempt(), this.events.trigger(_.LIMIT_REACHED_ATTEMPTS, new Error(Se.LIMIT_REACHED)), this.startCheckTelephony(e);
3959
+ this.attemptsState.finishAttempt(), this.events.trigger(_.LIMIT_REACHED_ATTEMPTS, new Error(pe.LIMIT_REACHED)), this.startCheckTelephony(e);
3886
3960
  }
3887
3961
  handleSucceededAttempt(e) {
3888
3962
  d("handleSucceededAttempt"), this.subscribeToConnectTriggers(e), this.events.trigger(_.SUCCESS);
@@ -3943,8 +4017,8 @@ class es {
3943
4017
  }
3944
4018
  scheduleReconnect(e) {
3945
4019
  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) => {
3946
- const s = t instanceof Error ? t : new Error(Se.FAILED_TO_RECONNECT);
3947
- this.attemptsState.finishAttempt(), st(t) || ot(t) ? this.events.trigger(_.CANCELLED_ATTEMPTS, s) : this.events.trigger(_.FAILED_ALL_ATTEMPTS, s), d("scheduleReconnect: error", t);
4020
+ const s = t instanceof Error ? t : new Error(pe.FAILED_TO_RECONNECT);
4021
+ this.attemptsState.finishAttempt(), ot(t) || lt(t) ? this.events.trigger(_.CANCELLED_ATTEMPTS, s) : this.events.trigger(_.FAILED_ALL_ATTEMPTS, s), d("scheduleReconnect: error", t);
3948
4022
  });
3949
4023
  }
3950
4024
  isConnectionUnavailable() {
@@ -3955,14 +4029,14 @@ class es {
3955
4029
  this.events.trigger(_.CHANGED_ATTEMPT_STATUS, { isInProgress: e });
3956
4030
  };
3957
4031
  }
3958
- const ts = V({
4032
+ const ls = V({
3959
4033
  types: {
3960
4034
  context: {},
3961
4035
  events: {}
3962
4036
  },
3963
4037
  actions: {
3964
- setCodec: I(({ event: n }) => "codec" in n ? { codec: n.codec } : {}),
3965
- clearCodec: I({ codec: void 0 })
4038
+ setCodec: v(({ event: n }) => "codec" in n ? { codec: n.codec } : {}),
4039
+ clearCodec: v({ codec: void 0 })
3966
4040
  }
3967
4041
  }).createMachine({
3968
4042
  id: "contented-stream",
@@ -3996,9 +4070,9 @@ const ts = V({
3996
4070
  }
3997
4071
  }
3998
4072
  });
3999
- class ns extends x {
4073
+ class us extends x {
4000
4074
  constructor() {
4001
- super(ts);
4075
+ super(ls);
4002
4076
  }
4003
4077
  get isAvailable() {
4004
4078
  return this.state === "contented-stream:available";
@@ -4039,17 +4113,17 @@ class ns extends x {
4039
4113
  );
4040
4114
  }
4041
4115
  }
4042
- var se = /* @__PURE__ */ ((n) => (n.AVAILABLE = "available", n.NOT_AVAILABLE = "not-available", n))(se || {});
4043
- const ss = [
4116
+ var ae = /* @__PURE__ */ ((n) => (n.AVAILABLE = "available", n.NOT_AVAILABLE = "not-available", n))(ae || {});
4117
+ const gs = [
4044
4118
  "available",
4045
4119
  "not-available"
4046
4120
  /* NOT_AVAILABLE */
4047
- ], is = () => new f(ss);
4048
- class rs {
4121
+ ], Ts = () => new M(gs);
4122
+ class Es {
4049
4123
  events;
4050
4124
  stateMachine;
4051
4125
  constructor() {
4052
- this.events = is(), this.stateMachine = new ns(), this.proxyEvents();
4126
+ this.events = Ts(), this.stateMachine = new us(), this.proxyEvents();
4053
4127
  }
4054
4128
  get isAvailable() {
4055
4129
  return this.stateMachine.isAvailable;
@@ -4078,19 +4152,19 @@ class rs {
4078
4152
  proxyEvents() {
4079
4153
  this.stateMachine.onStateChange(() => {
4080
4154
  const e = this.getStateInfo();
4081
- e.isAvailable ? this.events.trigger(se.AVAILABLE, { codec: e.codec }) : this.events.trigger(se.NOT_AVAILABLE, {});
4155
+ e.isAvailable ? this.events.trigger(ae.AVAILABLE, { codec: e.codec }) : this.events.trigger(ae.NOT_AVAILABLE, {});
4082
4156
  });
4083
4157
  }
4084
4158
  }
4085
4159
  var G = /* @__PURE__ */ ((n) => (n.RINGING = "ringing", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(G || {});
4086
- const Qe = [
4160
+ const Ye = [
4087
4161
  "ringing",
4088
4162
  "declinedIncomingCall",
4089
4163
  "terminatedIncomingCall",
4090
4164
  "failedIncomingCall"
4091
- ], as = () => new f(Qe);
4092
- var os = /* @__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))(os || {});
4093
- const cs = V({
4165
+ ], Ss = () => new M(Ye);
4166
+ var ms = /* @__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))(ms || {});
4167
+ const ps = V({
4094
4168
  types: {
4095
4169
  context: {},
4096
4170
  events: {}
@@ -4102,11 +4176,11 @@ const cs = V({
4102
4176
  logStateChange: (n, e) => {
4103
4177
  d("IncomingCallStateMachine state changed", e.state);
4104
4178
  },
4105
- rememberIncoming: I(({ event: n }) => {
4179
+ rememberIncoming: v(({ event: n }) => {
4106
4180
  const { data: e } = n;
4107
4181
  return { remoteCallerData: e, lastReason: void 0 };
4108
4182
  }),
4109
- rememberReason: I(({ event: n, context: e }) => n.type === "INCOMING.CONSUMED" ? {
4183
+ rememberReason: v(({ event: n, context: e }) => n.type === "INCOMING.CONSUMED" ? {
4110
4184
  remoteCallerData: e.remoteCallerData,
4111
4185
  lastReason: "incoming:consumed"
4112
4186
  /* CONSUMED */
@@ -4123,7 +4197,7 @@ const cs = V({
4123
4197
  lastReason: "incoming:failed"
4124
4198
  /* FAILED */
4125
4199
  }),
4126
- clearIncoming: I(() => ({ remoteCallerData: void 0, lastReason: void 0 }))
4200
+ clearIncoming: v(() => ({ remoteCallerData: void 0, lastReason: void 0 }))
4127
4201
  }
4128
4202
  }).createMachine({
4129
4203
  id: "incoming",
@@ -4422,9 +4496,9 @@ const cs = V({
4422
4496
  }
4423
4497
  }
4424
4498
  });
4425
- class ds extends x {
4499
+ class Cs extends x {
4426
4500
  constructor({ incomingEvents: e, connectionEvents: t }) {
4427
- super(cs), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
4501
+ super(ps), this.subscribeIncomingEvents(e), this.subscribeConnectionEvents(t);
4428
4502
  }
4429
4503
  get isIdle() {
4430
4504
  return this.state === "incoming:idle";
@@ -4492,15 +4566,15 @@ class ds extends x {
4492
4566
  }
4493
4567
  subscribeConnectionEvents(e) {
4494
4568
  this.addSubscription(
4495
- e.on(p.DISCONNECTED, () => {
4569
+ e.on(m.DISCONNECTED, () => {
4496
4570
  this.toClearIncoming();
4497
4571
  })
4498
4572
  ), this.addSubscription(
4499
- e.on(p.REGISTRATION_FAILED, () => {
4573
+ e.on(m.REGISTRATION_FAILED, () => {
4500
4574
  this.toClearIncoming();
4501
4575
  })
4502
4576
  ), this.addSubscription(
4503
- e.on(p.CONNECT_FAILED, () => {
4577
+ e.on(m.CONNECT_FAILED, () => {
4504
4578
  this.toClearIncoming();
4505
4579
  })
4506
4580
  );
@@ -4509,26 +4583,26 @@ class ds extends x {
4509
4583
  this.send({ type: "INCOMING.CLEAR" });
4510
4584
  }
4511
4585
  }
4512
- const hs = 486, ls = 487, Z = (n) => ({
4586
+ const Rs = 486, Ns = 487, ne = (n) => ({
4513
4587
  displayName: n.remote_identity.display_name,
4514
4588
  host: n.remote_identity.uri.host,
4515
4589
  incomingNumber: n.remote_identity.uri.user,
4516
4590
  rtcSession: n
4517
4591
  });
4518
- class us {
4592
+ class As {
4519
4593
  events;
4520
4594
  stateMachine;
4521
4595
  incomingRTCSession;
4522
4596
  connectionManager;
4523
4597
  constructor(e) {
4524
- this.connectionManager = e, this.events = as(), this.stateMachine = new ds({
4598
+ this.connectionManager = e, this.events = Ss(), this.stateMachine = new Cs({
4525
4599
  incomingEvents: this.events,
4526
4600
  connectionEvents: this.connectionManager.events
4527
4601
  }), this.start();
4528
4602
  }
4529
4603
  get remoteCallerData() {
4530
4604
  if (this.incomingRTCSession)
4531
- return Z(this.incomingRTCSession);
4605
+ return ne(this.incomingRTCSession);
4532
4606
  }
4533
4607
  get isAvailableIncomingCall() {
4534
4608
  return !!this.incomingRTCSession;
@@ -4550,11 +4624,11 @@ class us {
4550
4624
  return this.stateMachine.toConsumed(), this.removeIncomingSession(), e;
4551
4625
  };
4552
4626
  async declineToIncomingCall({
4553
- statusCode: e = ls
4627
+ statusCode: e = Ns
4554
4628
  } = {}) {
4555
4629
  return new Promise((t, s) => {
4556
4630
  try {
4557
- const i = this.getIncomingRTCSession(), r = Z(i);
4631
+ const i = this.getIncomingRTCSession(), r = ne(i);
4558
4632
  this.removeIncomingSession(), this.events.trigger(G.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
4559
4633
  } catch (i) {
4560
4634
  s(i);
@@ -4562,7 +4636,7 @@ class us {
4562
4636
  });
4563
4637
  }
4564
4638
  async busyIncomingCall() {
4565
- return this.declineToIncomingCall({ statusCode: hs });
4639
+ return this.declineToIncomingCall({ statusCode: Rs });
4566
4640
  }
4567
4641
  on(e, t) {
4568
4642
  return this.events.on(e, t);
@@ -4593,7 +4667,7 @@ class us {
4593
4667
  };
4594
4668
  setIncomingSession(e) {
4595
4669
  this.incomingRTCSession = e;
4596
- const t = Z(e);
4670
+ const t = ne(e);
4597
4671
  e.on("failed", (s) => {
4598
4672
  this.removeIncomingSession(), s.originator === "local" ? this.events.trigger(G.TERMINATED_INCOMING_CALL, t) : this.events.trigger(G.FAILED_INCOMING_CALL, t);
4599
4673
  }), this.events.trigger(G.RINGING, t);
@@ -4602,26 +4676,62 @@ class us {
4602
4676
  delete this.incomingRTCSession;
4603
4677
  }
4604
4678
  }
4605
- var We = /* @__PURE__ */ ((n) => (n.SNAPSHOT_CHANGED = "snapshot-changed", n))(We || {});
4606
- const Ye = ["snapshot-changed"], gs = () => new f(Ye), Ts = (n, e) => Object.is(n, e), pe = (n) => ({
4679
+ class Is {
4680
+ apiManager;
4681
+ connectionManager;
4682
+ callManager;
4683
+ get user() {
4684
+ return this.connectionManager?.getUser();
4685
+ }
4686
+ get number() {
4687
+ return this.callManager?.number;
4688
+ }
4689
+ get isCallInitiator() {
4690
+ return !!this.callManager?.isCallInitiator;
4691
+ }
4692
+ get peerToPeerRoom() {
4693
+ if (!(this.user === void 0 || this.number === void 0))
4694
+ return this.isCallInitiator ? `p2p${this.user}to${this.number}` : `p2p${this.number}to${this.user}`;
4695
+ }
4696
+ subscribe({
4697
+ apiManager: e,
4698
+ connectionManager: t,
4699
+ callManager: s
4700
+ }) {
4701
+ this.apiManager = e, this.connectionManager = t, this.callManager = s, s.on("confirmed", this.maybeSendDirectPeerToPeerRoom);
4702
+ }
4703
+ maybeSendDirectPeerToPeerRoom = () => {
4704
+ const { peerToPeerRoom: e, number: t, apiManager: s } = this;
4705
+ if (e === void 0 || t === void 0 || s === void 0)
4706
+ return;
4707
+ const i = [
4708
+ `${h.CONTENT_ENTER_ROOM}: ${this.peerToPeerRoom}`,
4709
+ `${h.PARTICIPANT_NAME}: ${this.number}`,
4710
+ `${h.IS_DIRECT_PEER_TO_PEER}: true`
4711
+ ];
4712
+ s.sendEnterRoom(i);
4713
+ };
4714
+ }
4715
+ var ze = /* @__PURE__ */ ((n) => (n.SNAPSHOT_CHANGED = "snapshot-changed", n))(ze || {});
4716
+ const Je = ["snapshot-changed"], vs = () => new M(Je), fs = (n, e) => Object.is(n, e), Ce = (n) => ({
4607
4717
  connection: n.connection.getSnapshot(),
4608
4718
  call: n.call.getSnapshot(),
4609
4719
  incoming: n.incoming.getSnapshot(),
4610
4720
  presentation: n.presentation.getSnapshot()
4611
4721
  });
4612
- class Es {
4722
+ class Ms {
4613
4723
  events;
4614
4724
  machines;
4615
4725
  currentSnapshot;
4616
4726
  subscribers = /* @__PURE__ */ new Set();
4617
4727
  actorSubscriptions = [];
4618
4728
  constructor(e) {
4619
- this.events = gs(), this.machines = {
4729
+ this.events = vs(), this.machines = {
4620
4730
  connection: e.connectionManager.stateMachine,
4621
4731
  call: e.callManager.stateMachine,
4622
4732
  incoming: e.incomingCallManager.stateMachine,
4623
4733
  presentation: e.presentationManager.stateMachine
4624
- }, this.currentSnapshot = pe(this.machines), this.actorSubscriptions.push(
4734
+ }, this.currentSnapshot = Ce(this.machines), this.actorSubscriptions.push(
4625
4735
  this.machines.connection.subscribe(this.notifySubscribers),
4626
4736
  this.machines.call.subscribe(this.notifySubscribers),
4627
4737
  this.machines.incoming.subscribe(this.notifySubscribers),
@@ -4632,7 +4742,7 @@ class Es {
4632
4742
  return this.currentSnapshot;
4633
4743
  }
4634
4744
  subscribe(e, t, s) {
4635
- const i = typeof t == "function", r = i ? e : (T) => T, a = i ? t : e, o = (i ? s : void 0) ?? Ts, c = r(this.currentSnapshot), l = {
4745
+ const i = typeof t == "function", r = i ? e : (T) => T, a = i ? t : e, o = (i ? s : void 0) ?? fs, c = r(this.currentSnapshot), l = {
4636
4746
  selector: r,
4637
4747
  listener: a,
4638
4748
  equals: o,
@@ -4655,12 +4765,12 @@ class Es {
4655
4765
  }
4656
4766
  notifySubscribers = () => {
4657
4767
  const e = this.currentSnapshot;
4658
- this.currentSnapshot = pe(this.machines);
4768
+ this.currentSnapshot = Ce(this.machines);
4659
4769
  for (const t of this.subscribers) {
4660
4770
  const s = t.selector(this.currentSnapshot);
4661
4771
  t.equals(t.current, s) || (t.current = s, t.listener(s));
4662
4772
  }
4663
- this.events.trigger(We.SNAPSHOT_CHANGED, {
4773
+ this.events.trigger(ze.SNAPSHOT_CHANGED, {
4664
4774
  previous: e,
4665
4775
  current: this.currentSnapshot
4666
4776
  });
@@ -4668,10 +4778,10 @@ class Es {
4668
4778
  }
4669
4779
  const $ = 1e3;
4670
4780
  var C = /* @__PURE__ */ ((n) => (n.INBOUND_RTP = "inbound-rtp", n.REMOTE_OUTBOUND_RTP = "remote-outbound-rtp", n.MEDIA_SOURCE = "media-source", n.OUTBOUND_RTP = "outbound-rtp", n.REMOTE_INBOUND_RTP = "remote-inbound-rtp", n.CODEC = "codec", n.CANDIDATE_PAIR = "candidate-pair", n.CERTIFICATE = "certificate", n.TRANSPORT = "transport", n.LOCAL_CANDIDATE = "local-candidate", n.REMOTE_CANDIDATE = "remote-candidate", n))(C || {});
4671
- const ze = ["collected"], Ss = () => new f(ze), me = () => "performance" in window ? performance.now() : Date.now(), H = (n) => [...n.keys()].reduce((e, t) => {
4781
+ const je = ["collected"], _s = () => new M(je), Re = () => "performance" in window ? performance.now() : Date.now(), W = (n) => [...n.keys()].reduce((e, t) => {
4672
4782
  const s = n.get(t);
4673
4783
  return s === void 0 ? e : { ...e, [s.type]: s };
4674
- }, {}), ps = (n) => {
4784
+ }, {}), bs = (n) => {
4675
4785
  if (!n)
4676
4786
  return {
4677
4787
  outboundRtp: void 0,
@@ -4679,14 +4789,14 @@ const ze = ["collected"], Ss = () => new f(ze), me = () => "performance" in wind
4679
4789
  mediaSource: void 0,
4680
4790
  remoteInboundRtp: void 0
4681
4791
  };
4682
- const e = H(n);
4792
+ const e = W(n);
4683
4793
  return {
4684
4794
  outboundRtp: e[C.OUTBOUND_RTP],
4685
4795
  codec: e[C.CODEC],
4686
4796
  mediaSource: e[C.MEDIA_SOURCE],
4687
4797
  remoteInboundRtp: e[C.REMOTE_INBOUND_RTP]
4688
4798
  };
4689
- }, Ce = (n) => {
4799
+ }, Ne = (n) => {
4690
4800
  if (!n)
4691
4801
  return {
4692
4802
  outboundRtp: void 0,
@@ -4694,14 +4804,14 @@ const ze = ["collected"], Ss = () => new f(ze), me = () => "performance" in wind
4694
4804
  mediaSource: void 0,
4695
4805
  remoteInboundRtp: void 0
4696
4806
  };
4697
- const e = H(n);
4807
+ const e = W(n);
4698
4808
  return {
4699
4809
  outboundRtp: e[C.OUTBOUND_RTP],
4700
4810
  codec: e[C.CODEC],
4701
4811
  mediaSource: e[C.MEDIA_SOURCE],
4702
4812
  remoteInboundRtp: e[C.REMOTE_INBOUND_RTP]
4703
4813
  };
4704
- }, Ne = ({
4814
+ }, Ae = ({
4705
4815
  videoReceiversStats: n,
4706
4816
  synchronizationSourcesVideo: e
4707
4817
  }) => {
@@ -4711,13 +4821,13 @@ const ze = ["collected"], Ss = () => new f(ze), me = () => "performance" in wind
4711
4821
  codec: void 0,
4712
4822
  synchronizationSources: e
4713
4823
  };
4714
- const t = H(n);
4824
+ const t = W(n);
4715
4825
  return {
4716
4826
  inboundRtp: t[C.INBOUND_RTP],
4717
4827
  codec: t[C.CODEC],
4718
4828
  synchronizationSources: e
4719
4829
  };
4720
- }, ms = ({
4830
+ }, Os = ({
4721
4831
  audioReceiverStats: n,
4722
4832
  synchronizationSourcesAudio: e
4723
4833
  }) => {
@@ -4728,14 +4838,14 @@ const ze = ["collected"], Ss = () => new f(ze), me = () => "performance" in wind
4728
4838
  remoteOutboundRtp: void 0,
4729
4839
  synchronizationSources: e
4730
4840
  };
4731
- const t = H(n);
4841
+ const t = W(n);
4732
4842
  return {
4733
4843
  inboundRtp: t[C.INBOUND_RTP],
4734
4844
  codec: t[C.CODEC],
4735
4845
  remoteOutboundRtp: t[C.REMOTE_OUTBOUND_RTP],
4736
4846
  synchronizationSources: e
4737
4847
  };
4738
- }, Je = (n) => {
4848
+ }, Ke = (n) => {
4739
4849
  if (!n)
4740
4850
  return {
4741
4851
  candidatePair: void 0,
@@ -4744,7 +4854,7 @@ const ze = ["collected"], Ss = () => new f(ze), me = () => "performance" in wind
4744
4854
  remoteCandidate: void 0,
4745
4855
  transport: void 0
4746
4856
  };
4747
- const e = H(n);
4857
+ const e = W(n);
4748
4858
  return {
4749
4859
  candidatePair: e[C.CANDIDATE_PAIR],
4750
4860
  certificate: e[C.CERTIFICATE],
@@ -4752,39 +4862,39 @@ const ze = ["collected"], Ss = () => new f(ze), me = () => "performance" in wind
4752
4862
  remoteCandidate: e[C.REMOTE_CANDIDATE],
4753
4863
  transport: e[C.TRANSPORT]
4754
4864
  };
4755
- }, Cs = ({
4865
+ }, Ps = ({
4756
4866
  audioSenderStats: n,
4757
4867
  videoSenderFirstStats: e,
4758
4868
  videoSenderSecondStats: t
4759
4869
  }) => ({
4760
- video: Ce(e),
4761
- secondVideo: Ce(t),
4762
- audio: ps(n),
4763
- additional: Je(
4870
+ video: Ne(e),
4871
+ secondVideo: Ne(t),
4872
+ audio: bs(n),
4873
+ additional: Ke(
4764
4874
  n ?? e ?? t
4765
4875
  )
4766
- }), Ns = ({
4876
+ }), ys = ({
4767
4877
  audioReceiverStats: n,
4768
4878
  videoReceiverFirstStats: e,
4769
4879
  videoReceiverSecondStats: t,
4770
4880
  synchronizationSources: s
4771
4881
  }) => ({
4772
- video: Ne({
4882
+ video: Ae({
4773
4883
  videoReceiversStats: e,
4774
4884
  synchronizationSourcesVideo: s.video
4775
4885
  }),
4776
- secondVideo: Ne({
4886
+ secondVideo: Ae({
4777
4887
  videoReceiversStats: t,
4778
4888
  synchronizationSourcesVideo: s.video
4779
4889
  }),
4780
- audio: ms({
4890
+ audio: Os({
4781
4891
  audioReceiverStats: n,
4782
4892
  synchronizationSourcesAudio: s.audio
4783
4893
  }),
4784
- additional: Je(
4894
+ additional: Ke(
4785
4895
  n ?? e ?? t
4786
4896
  )
4787
- }), Rs = ({
4897
+ }), Ds = ({
4788
4898
  audioSenderStats: n,
4789
4899
  videoSenderFirstStats: e,
4790
4900
  videoSenderSecondStats: t,
@@ -4793,11 +4903,11 @@ const ze = ["collected"], Ss = () => new f(ze), me = () => "performance" in wind
4793
4903
  videoReceiverSecondStats: r,
4794
4904
  synchronizationSources: a
4795
4905
  }) => {
4796
- const o = Cs({
4906
+ const o = Ps({
4797
4907
  audioSenderStats: n,
4798
4908
  videoSenderFirstStats: e,
4799
4909
  videoSenderSecondStats: t
4800
- }), c = Ns({
4910
+ }), c = ys({
4801
4911
  audioReceiverStats: s,
4802
4912
  videoReceiverFirstStats: i,
4803
4913
  videoReceiverSecondStats: r,
@@ -4807,8 +4917,8 @@ const ze = ["collected"], Ss = () => new f(ze), me = () => "performance" in wind
4807
4917
  outbound: o,
4808
4918
  inbound: c
4809
4919
  };
4810
- }, As = async (n) => {
4811
- const e = "audio", t = "video", s = n.getSenders(), i = s.find((E) => E.track?.kind === e), r = s.filter((E) => E.track?.kind === t), a = n.getReceivers(), o = a.find((E) => E.track.kind === e), c = a.filter((E) => E.track.kind === t), l = {
4920
+ }, Ls = async (n) => {
4921
+ const e = "audio", t = "video", s = n.getSenders(), i = s.find((S) => S.track?.kind === e), r = s.filter((S) => S.track?.kind === t), a = n.getReceivers(), o = a.find((S) => S.track.kind === e), c = a.filter((S) => S.track.kind === t), l = {
4812
4922
  trackIdentifier: o?.track.id,
4813
4923
  item: o?.getSynchronizationSources()[0]
4814
4924
  }, T = {
@@ -4825,41 +4935,41 @@ const ze = ["collected"], Ss = () => new f(ze), me = () => "performance" in wind
4825
4935
  o?.getStats() ?? Promise.resolve(void 0),
4826
4936
  c[0]?.getStats() ?? Promise.resolve(void 0),
4827
4937
  c[1]?.getStats() ?? Promise.resolve(void 0)
4828
- ]).then((E) => {
4938
+ ]).then((S) => {
4829
4939
  const [
4830
- N,
4940
+ R,
4831
4941
  D,
4832
- A,
4942
+ I,
4833
4943
  U,
4834
4944
  B,
4835
- nt
4836
- ] = E;
4945
+ it
4946
+ ] = S;
4837
4947
  return {
4838
4948
  synchronizationSources: g,
4839
- audioSenderStats: N,
4949
+ audioSenderStats: R,
4840
4950
  videoSenderFirstStats: D,
4841
- videoSenderSecondStats: A,
4951
+ videoSenderSecondStats: I,
4842
4952
  audioReceiverStats: U,
4843
4953
  videoReceiverFirstStats: B,
4844
- videoReceiverSecondStats: nt
4954
+ videoReceiverSecondStats: it
4845
4955
  };
4846
4956
  });
4847
- }, Is = (n) => {
4957
+ }, ws = (n) => {
4848
4958
  d(String(n));
4849
4959
  };
4850
- class vs {
4960
+ class Us {
4851
4961
  events;
4852
4962
  setTimeoutRequest;
4853
- requesterAllStatistics = new X(As);
4963
+ requesterAllStatistics = new X(Ls);
4854
4964
  constructor() {
4855
- this.events = Ss(), this.setTimeoutRequest = new Ae();
4965
+ this.events = _s(), this.setTimeoutRequest = new ve();
4856
4966
  }
4857
4967
  get requested() {
4858
4968
  return this.setTimeoutRequest.requested;
4859
4969
  }
4860
4970
  start(e, {
4861
4971
  interval: t = $,
4862
- onError: s = Is
4972
+ onError: s = ws
4863
4973
  } = {}) {
4864
4974
  this.stop(), this.setTimeoutRequest.request(() => {
4865
4975
  this.collectStatistics(e, {
@@ -4888,10 +4998,10 @@ class vs {
4888
4998
  collectStatistics = (e, {
4889
4999
  onError: t
4890
5000
  }) => {
4891
- const s = me();
5001
+ const s = Re();
4892
5002
  this.requestAllStatistics(e).then((i) => {
4893
- this.events.trigger("collected", Rs(i));
4894
- const a = me() - s;
5003
+ this.events.trigger("collected", Ds(i));
5004
+ const a = Re() - s;
4895
5005
  let o = $;
4896
5006
  a > 48 ? o = $ * 4 : a > 32 ? o = $ * 3 : a > 16 && (o = $ * 2), this.start(e, {
4897
5007
  onError: t,
@@ -4908,8 +5018,8 @@ class vs {
4908
5018
  return this.requesterAllStatistics.request(t);
4909
5019
  };
4910
5020
  }
4911
- const fs = 500;
4912
- class Ms {
5021
+ const Fs = 500;
5022
+ class ks {
4913
5023
  statsPeerConnection;
4914
5024
  availableStats;
4915
5025
  previousAvailableStats;
@@ -4919,7 +5029,7 @@ class Ms {
4919
5029
  callManager: e,
4920
5030
  apiManager: t
4921
5031
  }) {
4922
- this.callManager = e, this.apiManager = t, this.statsPeerConnection = new vs(), this.subscribe();
5032
+ this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Us(), this.subscribe();
4923
5033
  }
4924
5034
  get events() {
4925
5035
  return this.statsPeerConnection.events;
@@ -4969,7 +5079,7 @@ class Ms {
4969
5079
  return this.previousInboundRtp?.packetsReceived;
4970
5080
  }
4971
5081
  get isReceivingPackets() {
4972
- const e = this.packetsReceived !== void 0 && this.packetsReceived >= fs, t = this.packetsReceived !== this.previousPacketsReceived;
5082
+ const e = this.packetsReceived !== void 0 && this.packetsReceived >= Fs, t = this.packetsReceived !== this.previousPacketsReceived;
4973
5083
  return e && t;
4974
5084
  }
4975
5085
  on(e, t) {
@@ -5009,33 +5119,33 @@ class Ms {
5009
5119
  });
5010
5120
  }
5011
5121
  }
5012
- const _s = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), bs = (n) => {
5122
+ const Bs = (n, e) => n.filter((s) => e.some((i) => i.clockRate === s.clockRate && i.mimeType === s.mimeType && i.channels === s.channels && i.sdpFmtpLine === s.sdpFmtpLine)), $s = (n) => {
5013
5123
  const e = RTCRtpSender.getCapabilities(n), t = RTCRtpReceiver.getCapabilities(n), s = e === null ? [] : e.codecs, i = t === null ? [] : t.codecs;
5014
- return _s(s, i);
5015
- }, Os = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
5124
+ return Bs(s, i);
5125
+ }, Gs = (n, e) => e === void 0 || e.length === 0 ? n : n.sort((t, s) => {
5016
5126
  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;
5017
5127
  return a - o;
5018
- }), ys = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Ds = (n, {
5128
+ }), qs = (n, e) => e === void 0 || e.length === 0 ? n : n.filter((t) => !e.includes(t.mimeType)), Vs = (n, {
5019
5129
  preferredMimeTypesVideoCodecs: e,
5020
5130
  excludeMimeTypesVideoCodecs: t
5021
5131
  }) => {
5022
5132
  try {
5023
5133
  if (typeof n.setCodecPreferences == "function" && n.sender.track?.kind === "video" && (e !== void 0 && e.length > 0 || t !== void 0 && t.length > 0)) {
5024
- const s = bs("video"), i = ys(s, t), r = Os(i, e);
5134
+ const s = $s("video"), i = qs(s, t), r = Gs(i, e);
5025
5135
  n.setCodecPreferences(r);
5026
5136
  }
5027
5137
  } catch (s) {
5028
5138
  d("setCodecPreferences error", s);
5029
5139
  }
5030
- }, Ps = (n) => [...n.keys()].map((e) => n.get(e)), ws = (n, e) => Ps(n).find((t) => t?.type === e), Ls = async (n) => n.getStats().then((e) => ws(e, "codec")?.mimeType);
5031
- class Us {
5140
+ }, xs = (n) => [...n.keys()].map((e) => n.get(e)), Hs = (n, e) => xs(n).find((t) => t?.type === e), Ws = async (n) => n.getStats().then((e) => Hs(e, "codec")?.mimeType);
5141
+ class Qs {
5032
5142
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
5033
5143
  async getCodecFromSender(e) {
5034
- return await Ls(e) ?? "";
5144
+ return await Ws(e) ?? "";
5035
5145
  }
5036
5146
  }
5037
- class Fs {
5038
- stackPromises = Ie({
5147
+ class Ys {
5148
+ stackPromises = fe({
5039
5149
  noRunIsNotActual: !0
5040
5150
  });
5041
5151
  /**
@@ -5059,30 +5169,30 @@ class Fs {
5059
5169
  });
5060
5170
  }
5061
5171
  }
5062
- class ks {
5172
+ class zs {
5063
5173
  taskQueue;
5064
5174
  onSetParameters;
5065
5175
  constructor(e) {
5066
- this.onSetParameters = e, this.taskQueue = new Fs();
5176
+ this.onSetParameters = e, this.taskQueue = new Ys();
5067
5177
  }
5068
5178
  async setEncodingsToSender(e, t) {
5069
- return this.taskQueue.add(async () => ye(e, t, this.onSetParameters));
5179
+ return this.taskQueue.add(async () => Le(e, t, this.onSetParameters));
5070
5180
  }
5071
5181
  stop() {
5072
5182
  this.taskQueue.stop();
5073
5183
  }
5074
5184
  }
5075
- const je = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Bs = 1e6, y = (n) => n * Bs, Xe = y(0.06), Ke = y(4), $s = (n) => n <= 64 ? Xe : n <= 128 ? y(0.12) : n <= 256 ? y(0.25) : n <= 384 ? y(0.32) : n <= 426 ? y(0.38) : n <= 640 ? y(0.5) : n <= 848 ? y(0.7) : n <= 1280 ? y(1) : n <= 1920 ? y(2) : Ke, Gs = "av1", qs = (n) => je(n, Gs), Vs = 0.6, de = (n, e) => qs(e) ? n * Vs : n, xs = (n) => de(Xe, n), Hs = (n) => de(Ke, n), Re = (n, e) => {
5076
- const t = $s(n);
5077
- return de(t, e);
5078
- }, ee = 1, Qs = ({
5185
+ const Xe = (n, e) => n !== void 0 && e !== void 0 && n.toLowerCase().includes(e.toLowerCase()), Js = 1e6, y = (n) => n * Js, Ze = y(0.06), et = y(4), js = (n) => n <= 64 ? Ze : n <= 128 ? y(0.12) : n <= 256 ? y(0.25) : n <= 384 ? y(0.32) : n <= 426 ? y(0.38) : n <= 640 ? y(0.5) : n <= 848 ? y(0.7) : n <= 1280 ? y(1) : n <= 1920 ? y(2) : et, Ks = "av1", Xs = (n) => Xe(n, Ks), Zs = 0.6, le = (n, e) => Xs(e) ? n * Zs : n, ei = (n) => le(Ze, n), ti = (n) => le(et, n), Ie = (n, e) => {
5186
+ const t = js(n);
5187
+ return le(t, e);
5188
+ }, se = 1, ni = ({
5079
5189
  videoTrack: n,
5080
5190
  targetSize: e
5081
5191
  }) => {
5082
- const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? ee : s / e.width, a = i === void 0 ? ee : i / e.height;
5083
- return Math.max(r, a, ee);
5192
+ const t = n.getSettings(), s = t.width, i = t.height, r = s === void 0 ? se : s / e.width, a = i === void 0 ? se : i / e.height;
5193
+ return Math.max(r, a, se);
5084
5194
  };
5085
- class Ws {
5195
+ class si {
5086
5196
  ignoreForCodec;
5087
5197
  senderFinder;
5088
5198
  codecProvider;
@@ -5115,7 +5225,7 @@ class Ws {
5115
5225
  if (!i?.track)
5116
5226
  return { ...this.resultNoChanged, sender: i };
5117
5227
  const r = await this.codecProvider.getCodecFromSender(i);
5118
- if (je(r, this.ignoreForCodec))
5228
+ if (Xe(r, this.ignoreForCodec))
5119
5229
  return { ...this.resultNoChanged, sender: i };
5120
5230
  const { mainCam: a, resolutionMainCam: o } = t ?? {};
5121
5231
  return this.processSender(
@@ -5157,7 +5267,7 @@ class Ws {
5157
5267
  async downgradeResolutionSender(e) {
5158
5268
  const { sender: t, codec: s } = e, i = {
5159
5269
  scaleResolutionDownBy: 200,
5160
- maxBitrate: xs(s)
5270
+ maxBitrate: ei(s)
5161
5271
  };
5162
5272
  return this.parametersSetter.setEncodingsToSender(t, i);
5163
5273
  }
@@ -5167,7 +5277,7 @@ class Ws {
5167
5277
  * @returns Promise с результатом
5168
5278
  */
5169
5279
  async setBitrateByTrackResolution(e) {
5170
- const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? Hs(i) : Re(a, i);
5280
+ const { sender: t, videoTrack: s, codec: i } = e, a = s.getSettings().width, o = a === void 0 ? ti(i) : Ie(a, i);
5171
5281
  return this.parametersSetter.setEncodingsToSender(t, {
5172
5282
  scaleResolutionDownBy: 1,
5173
5283
  maxBitrate: o
@@ -5183,24 +5293,24 @@ class Ws {
5183
5293
  const [s, i] = e.split("x"), { sender: r, videoTrack: a, codec: o } = t, c = {
5184
5294
  width: Number(s),
5185
5295
  height: Number(i)
5186
- }, l = Qs({
5296
+ }, l = ni({
5187
5297
  videoTrack: a,
5188
5298
  targetSize: c
5189
- }), T = Re(c.width, o), g = {
5299
+ }), T = Ie(c.width, o), g = {
5190
5300
  scaleResolutionDownBy: l,
5191
5301
  maxBitrate: T
5192
5302
  };
5193
5303
  return this.parametersSetter.setEncodingsToSender(r, g);
5194
5304
  }
5195
5305
  }
5196
- const Ys = (n) => n.find((e) => e.track?.kind === "video");
5197
- class zs {
5306
+ const ii = (n) => n.find((e) => e.track?.kind === "video");
5307
+ class ri {
5198
5308
  // eslint-disable-next-line @typescript-eslint/class-methods-use-this
5199
5309
  findVideoSender(e) {
5200
- return Ys(e);
5310
+ return ii(e);
5201
5311
  }
5202
5312
  }
5203
- class Js {
5313
+ class ai {
5204
5314
  currentSender;
5205
5315
  originalReplaceTrack;
5206
5316
  lastWidth;
@@ -5213,7 +5323,7 @@ class Js {
5213
5323
  pollIntervalMs: e = 1e3,
5214
5324
  maxPollIntervalMs: t
5215
5325
  }) {
5216
- this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new Ae();
5326
+ this.pollIntervalMs = e, this.maxPollIntervalMs = t ?? e * 16, this.currentPollIntervalMs = this.pollIntervalMs, this.setTimeoutRequest = new ve();
5217
5327
  }
5218
5328
  /**
5219
5329
  * Проверяет актуальный video-sender и (при необходимости) перенастраивает наблюдение.
@@ -5264,7 +5374,7 @@ class Js {
5264
5374
  this.setTimeoutRequest.cancelRequest(), this.lastWidth = void 0, this.lastHeight = void 0;
5265
5375
  }
5266
5376
  }
5267
- class js {
5377
+ class oi {
5268
5378
  apiManager;
5269
5379
  currentHandler;
5270
5380
  constructor(e) {
@@ -5284,7 +5394,7 @@ class js {
5284
5394
  this.currentHandler && (this.apiManager.off("main-cam-control", this.currentHandler), this.currentHandler = void 0);
5285
5395
  }
5286
5396
  }
5287
- class Xs {
5397
+ class ci {
5288
5398
  eventHandler;
5289
5399
  senderBalancer;
5290
5400
  parametersSetterWithQueue;
@@ -5296,16 +5406,16 @@ class Xs {
5296
5406
  onSetParameters: i,
5297
5407
  pollIntervalMs: r
5298
5408
  } = {}) {
5299
- this.getConnection = t, this.eventHandler = new js(e), this.parametersSetterWithQueue = new ks(i), this.senderBalancer = new Ws(
5409
+ this.getConnection = t, this.eventHandler = new oi(e), this.parametersSetterWithQueue = new zs(i), this.senderBalancer = new si(
5300
5410
  {
5301
- senderFinder: new zs(),
5302
- codecProvider: new Us(),
5411
+ senderFinder: new ri(),
5412
+ codecProvider: new Qs(),
5303
5413
  parametersSetter: this.parametersSetterWithQueue
5304
5414
  },
5305
5415
  {
5306
5416
  ignoreForCodec: s
5307
5417
  }
5308
- ), this.trackMonitor = new Js({ pollIntervalMs: r });
5418
+ ), this.trackMonitor = new ai({ pollIntervalMs: r });
5309
5419
  }
5310
5420
  /**
5311
5421
  * Подписывается на события управления главной камерой
@@ -5350,13 +5460,13 @@ class Xs {
5350
5460
  });
5351
5461
  };
5352
5462
  }
5353
- const Ze = [
5463
+ const tt = [
5354
5464
  "balancing-scheduled",
5355
5465
  "balancing-started",
5356
5466
  "balancing-stopped",
5357
5467
  "parameters-updated"
5358
- ], Ks = () => new f(Ze);
5359
- class Zs {
5468
+ ], di = () => new M(tt);
5469
+ class hi {
5360
5470
  isBalancingActive = !1;
5361
5471
  events;
5362
5472
  callManager;
@@ -5364,7 +5474,7 @@ class Zs {
5364
5474
  videoSendingBalancer;
5365
5475
  startBalancingTimer;
5366
5476
  constructor(e, t, s = {}) {
5367
- this.events = Ks(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new Xs(
5477
+ this.events = di(), this.callManager = e, this.balancingStartDelay = s.balancingStartDelay ?? 1e4, this.videoSendingBalancer = new ci(
5368
5478
  t,
5369
5479
  () => e.connection,
5370
5480
  {
@@ -5434,13 +5544,13 @@ class Zs {
5434
5544
  this.startBalancingTimer && (clearTimeout(this.startBalancingTimer), this.startBalancingTimer = void 0);
5435
5545
  }
5436
5546
  }
5437
- const et = "no-inbound-frames", tt = [et], ei = () => new f(tt);
5438
- class ti {
5547
+ const nt = "no-inbound-frames", st = [nt], li = () => new M(st);
5548
+ class ui {
5439
5549
  events;
5440
5550
  statsManager;
5441
5551
  callManager;
5442
5552
  constructor(e, t) {
5443
- this.statsManager = e, this.callManager = t, this.events = ei(), this.subscribe();
5553
+ this.statsManager = e, this.callManager = t, this.events = li(), this.subscribe();
5444
5554
  }
5445
5555
  get mainVideoTrack() {
5446
5556
  return this.callManager.getMainRemoteStream()?.getVideoTracks()[0];
@@ -5453,20 +5563,20 @@ class ti {
5453
5563
  return this.events.on(e, t);
5454
5564
  }
5455
5565
  handleStatsCollected = () => {
5456
- this.hasNoIncomingFrames() && this.events.trigger(et, {});
5566
+ this.hasNoIncomingFrames() && this.events.trigger(nt, {});
5457
5567
  };
5458
5568
  hasNoIncomingFrames = () => this.statsManager.isInvalidInboundFrames && this.isMutedMainVideoTrack;
5459
5569
  subscribe() {
5460
5570
  this.statsManager.on("collected", this.handleStatsCollected);
5461
5571
  }
5462
5572
  }
5463
- const ni = 3e3;
5464
- class si {
5573
+ const gi = 3e3;
5574
+ class Ti {
5465
5575
  renegotiateRequester;
5466
5576
  renegotiateThrottled;
5467
5577
  callManager;
5468
- constructor(e, t = ni) {
5469
- this.callManager = e, this.renegotiateRequester = new X(e.renegotiate.bind(e)), this.renegotiateThrottled = lt.throttle(
5578
+ constructor(e, t = gi) {
5579
+ this.callManager = e, this.renegotiateRequester = new X(e.renegotiate.bind(e)), this.renegotiateThrottled = Et.throttle(
5470
5580
  this.requestRenegotiate.bind(this),
5471
5581
  t
5472
5582
  ), this.subscribe();
@@ -5494,24 +5604,24 @@ class si {
5494
5604
  d("cancel recover main stream"), this.renegotiateThrottled.cancel(), this.renegotiateRequester.cancelRequest();
5495
5605
  }
5496
5606
  }
5497
- const ii = 1e6, ri = He.map((n) => `auto-connect:${n}`), ai = Ge.map((n) => `connection:${n}`), oi = Ue.map((n) => `call:${n}`), ci = Me.map((n) => `api:${n}`), di = Qe.map((n) => `incoming-call:${n}`), hi = Be.map((n) => `presentation:${n}`), li = ze.map((n) => `stats:${n}`), ui = Ze.map((n) => `video-balancer:${n}`), gi = tt.map((n) => `main-stream-health:${n}`), Ti = Ye.map((n) => `session:${n}`), Ei = [
5607
+ const Ei = 1e6, Si = Qe.map((n) => `auto-connect:${n}`), mi = Ve.map((n) => `connection:${n}`), pi = ke.map((n) => `call:${n}`), Ci = be.map((n) => `api:${n}`), Ri = Ye.map((n) => `incoming-call:${n}`), Ni = Ge.map((n) => `presentation:${n}`), Ai = je.map((n) => `stats:${n}`), Ii = tt.map((n) => `video-balancer:${n}`), vi = st.map((n) => `main-stream-health:${n}`), fi = Je.map((n) => `session:${n}`), Mi = [
5498
5608
  "disconnected-from-out-of-call",
5499
5609
  "connected-with-configuration-from-out-of-call",
5500
5610
  "stopped-presentation-by-server-command"
5501
- ], Si = [
5502
- ...ri,
5503
- ...ai,
5504
- ...oi,
5505
- ...ci,
5506
- ...di,
5507
- ...hi,
5508
- ...li,
5509
- ...ui,
5510
- ...gi,
5511
- ...Ti,
5512
- ...Ei
5513
- ], pi = () => new f(Si);
5514
- class Di {
5611
+ ], _i = [
5612
+ ...Si,
5613
+ ...mi,
5614
+ ...pi,
5615
+ ...Ci,
5616
+ ...Ri,
5617
+ ...Ni,
5618
+ ...Ai,
5619
+ ...Ii,
5620
+ ...vi,
5621
+ ...fi,
5622
+ ...Mi
5623
+ ], bi = () => new M(_i);
5624
+ class xi {
5515
5625
  events;
5516
5626
  connectionManager;
5517
5627
  connectionQueueManager;
@@ -5525,6 +5635,7 @@ class Di {
5525
5635
  videoSendingBalancerManager;
5526
5636
  sessionManager;
5527
5637
  mainStreamHealthMonitor;
5638
+ peerToPeerManager;
5528
5639
  mainStreamRecovery;
5529
5640
  preferredMimeTypesVideoCodecs;
5530
5641
  excludeMimeTypesVideoCodecs;
@@ -5534,26 +5645,26 @@ class Di {
5534
5645
  videoBalancerOptions: i,
5535
5646
  autoConnectorOptions: r
5536
5647
  } = {}) {
5537
- this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = pi(), this.apiManager = new Nt(), this.connectionManager = new $n({ JsSIP: e }), this.connectionQueueManager = new Gn({
5648
+ this.preferredMimeTypesVideoCodecs = t, this.excludeMimeTypesVideoCodecs = s, this.events = bi(), this.apiManager = new ft(), this.connectionManager = new Jn({ JsSIP: e }), this.connectionQueueManager = new jn({
5538
5649
  connectionManager: this.connectionManager
5539
- }), this.contentedStreamManager = new rs(), this.callManager = new Tn(this.contentedStreamManager), this.incomingCallManager = new us(this.connectionManager), this.presentationManager = new Nn({
5650
+ }), this.contentedStreamManager = new Es(), this.callManager = new vn(this.contentedStreamManager), this.incomingCallManager = new As(this.connectionManager), this.presentationManager = new Pn({
5540
5651
  callManager: this.callManager,
5541
- maxBitrate: ii
5542
- }), this.statsManager = new Ms({
5652
+ maxBitrate: Ei
5653
+ }), this.statsManager = new ks({
5543
5654
  callManager: this.callManager,
5544
5655
  apiManager: this.apiManager
5545
- }), this.autoConnectorManager = new es(
5656
+ }), this.autoConnectorManager = new hs(
5546
5657
  {
5547
5658
  connectionQueueManager: this.connectionQueueManager,
5548
5659
  connectionManager: this.connectionManager,
5549
5660
  callManager: this.callManager
5550
5661
  },
5551
5662
  r
5552
- ), this.videoSendingBalancerManager = new Zs(
5663
+ ), this.videoSendingBalancerManager = new hi(
5553
5664
  this.callManager,
5554
5665
  this.apiManager,
5555
5666
  i
5556
- ), this.mainStreamHealthMonitor = new ti(this.statsManager, this.callManager), this.mainStreamRecovery = new si(this.callManager), this.sessionManager = new Es({
5667
+ ), this.mainStreamHealthMonitor = new ui(this.statsManager, this.callManager), this.mainStreamRecovery = new Ti(this.callManager), this.sessionManager = new Ms({
5557
5668
  connectionManager: this.connectionManager,
5558
5669
  callManager: this.callManager,
5559
5670
  incomingCallManager: this.incomingCallManager,
@@ -5561,6 +5672,10 @@ class Di {
5561
5672
  }), this.callManager.subscribeToApiEvents(this.apiManager), this.contentedStreamManager.subscribeToApiEvents(this.apiManager), this.apiManager.subscribe({
5562
5673
  connectionManager: this.connectionManager,
5563
5674
  callManager: this.callManager
5675
+ }), this.peerToPeerManager = new Is(), this.peerToPeerManager.subscribe({
5676
+ connectionManager: this.connectionManager,
5677
+ callManager: this.callManager,
5678
+ apiManager: this.apiManager
5564
5679
  }), this.subscribe();
5565
5680
  }
5566
5681
  get requestedConnection() {
@@ -5599,6 +5714,9 @@ class Di {
5599
5714
  get isAvailableIncomingCall() {
5600
5715
  return this.incomingCallManager.isAvailableIncomingCall;
5601
5716
  }
5717
+ get isDirectP2PRoom() {
5718
+ return this.callManager.isDirectP2PRoom;
5719
+ }
5602
5720
  on(e, t) {
5603
5721
  return this.events.on(e, t);
5604
5722
  }
@@ -5657,35 +5775,34 @@ class Di {
5657
5775
  setRecvQuality = async (e) => this.callManager.setRecvQuality(e);
5658
5776
  replaceMediaStream = async (...e) => this.callManager.replaceMediaStream(...e);
5659
5777
  async startPresentation(e, t = {}) {
5660
- const { isP2P: s, callLimit: i, onAddedTransceiver: r, ...a } = t;
5778
+ const { callLimit: s, onAddedTransceiver: i, ...r } = t;
5661
5779
  return this.presentationManager.startPresentation(
5662
5780
  async () => {
5663
- await (s === !0 ? this.apiManager.sendAvailableContentedStream() : this.apiManager.askPermissionToStartPresentation());
5781
+ await (this.isDirectP2PRoom ? this.apiManager.sendAvailableContentedStream() : this.apiManager.askPermissionToStartPresentation());
5664
5782
  },
5665
5783
  e,
5666
5784
  {
5667
- ...a,
5668
- onAddedTransceiver: this.resolveHandleAddTransceiver(r)
5785
+ ...r,
5786
+ onAddedTransceiver: this.resolveHandleAddTransceiver(i)
5669
5787
  },
5670
- i === void 0 ? void 0 : { callLimit: i }
5788
+ s === void 0 ? void 0 : { callLimit: s }
5671
5789
  );
5672
5790
  }
5673
- async stopPresentation(e = {}) {
5674
- const { isP2P: t } = e;
5791
+ async stopPresentation() {
5675
5792
  return this.presentationManager.stopPresentation(async () => {
5676
- await (t === !0 ? this.apiManager.sendNotAvailableContentedStream() : this.apiManager.sendStoppedPresentation());
5793
+ await (this.isDirectP2PRoom ? this.apiManager.sendNotAvailableContentedStream() : this.apiManager.sendStoppedPresentation());
5677
5794
  });
5678
5795
  }
5679
5796
  async updatePresentation(e, t = {}) {
5680
- const { isP2P: s, onAddedTransceiver: i, ...r } = t;
5797
+ const { onAddedTransceiver: s, ...i } = t;
5681
5798
  return this.presentationManager.updatePresentation(
5682
5799
  async () => {
5683
- await (s === !0 ? this.apiManager.sendAvailableContentedStream() : this.apiManager.askPermissionToStartPresentation());
5800
+ await (this.isDirectP2PRoom ? this.apiManager.sendAvailableContentedStream() : this.apiManager.askPermissionToStartPresentation());
5684
5801
  },
5685
5802
  e,
5686
5803
  {
5687
- ...r,
5688
- onAddedTransceiver: this.resolveHandleAddTransceiver(i)
5804
+ ...i,
5805
+ onAddedTransceiver: this.resolveHandleAddTransceiver(s)
5689
5806
  }
5690
5807
  );
5691
5808
  }
@@ -5739,13 +5856,20 @@ class Di {
5739
5856
  this.callManager.setCallRoleSpectator({ audioId: e, sendOffer: this.sendOffer }), this.mayBeStopPresentationAndNotify();
5740
5857
  }), this.apiManager.on("presentation:must-stop", () => {
5741
5858
  this.mayBeStopPresentationAndNotify();
5859
+ }), this.apiManager.on("failed-send-room-direct-p2p", ({ error: e }) => {
5860
+ const t = new rt();
5861
+ t.body = e instanceof Error ? e.message : String(e);
5862
+ const s = at.causes.INTERNAL_ERROR;
5863
+ this.callManager.failed(t, s).catch((i) => {
5864
+ d("Failed to end call after failed:", i);
5865
+ });
5742
5866
  });
5743
5867
  }
5744
5868
  sendOffer = async (e, t) => {
5745
5869
  const i = this.connectionManager.getConnectionConfiguration()?.sipServerUrl;
5746
5870
  if (i === void 0)
5747
5871
  throw new Error("No sipServerUrl for sendOffer");
5748
- return vt({
5872
+ return Pt({
5749
5873
  serverUrl: i,
5750
5874
  offer: t,
5751
5875
  token: e.token,
@@ -5755,7 +5879,7 @@ class Di {
5755
5879
  });
5756
5880
  };
5757
5881
  setCodecPreferences(e) {
5758
- Ds(e, {
5882
+ Vs(e, {
5759
5883
  preferredMimeTypesVideoCodecs: this.preferredMimeTypesVideoCodecs,
5760
5884
  excludeMimeTypesVideoCodecs: this.excludeMimeTypesVideoCodecs
5761
5885
  });
@@ -5780,27 +5904,28 @@ class Di {
5780
5904
  };
5781
5905
  }
5782
5906
  export {
5783
- kt as D,
5784
- Fe as E,
5785
- Vt as O,
5786
- Rt as P,
5787
- Di as S,
5788
- ye as a,
5789
- te as b,
5790
- ne as c,
5791
- On as d,
5792
- os as e,
5793
- Fn as f,
5794
- fe as g,
5795
- _e as h,
5796
- Sn as i,
5797
- C as j,
5798
- vs as k,
5907
+ xt as D,
5908
+ Be as E,
5909
+ Xt as O,
5910
+ _t as P,
5911
+ xi as S,
5912
+ Pe as a,
5913
+ Le as b,
5914
+ ie as c,
5915
+ re as d,
5916
+ $n as e,
5917
+ ms as f,
5918
+ Qn as g,
5919
+ Oe as h,
5920
+ _e as i,
5921
+ Mn as j,
5922
+ C as k,
5799
5923
  d as l,
5800
- Oi as m,
5801
- bi as n,
5802
- Ls as o,
5803
- W as p,
5804
- yi as q,
5805
- vt as s
5924
+ Us as m,
5925
+ qi as n,
5926
+ Gi as o,
5927
+ Y as p,
5928
+ Ws as q,
5929
+ Vi as r,
5930
+ Pt as s
5806
5931
  };