sip-connector 15.1.0 → 15.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +160 -11
  2. package/dist/@SipConnector-DV4Ywba-.cjs +1 -0
  3. package/dist/{@SipConnector-G96OmJEP.js → @SipConnector-Gt9XLkRE.js} +577 -266
  4. package/dist/ApiManager/@ApiManager.d.ts +3 -0
  5. package/dist/ApiManager/constants.d.ts +4 -2
  6. package/dist/SipConnector/@SipConnector.d.ts +2 -0
  7. package/dist/SipConnector/eventNames.d.ts +1 -1
  8. package/dist/SipConnectorFacade/SipConnectorFacade.d.ts +3 -0
  9. package/dist/StatsManager/@StatsManager.d.ts +27 -0
  10. package/dist/StatsManager/eventNames.d.ts +2 -0
  11. package/dist/StatsManager/index.d.ts +2 -0
  12. package/dist/StatsPeerConnection/StatsPeerConnection.d.ts +20 -0
  13. package/dist/StatsPeerConnection/__fixtures__/callStaticsState.d.ts +3923 -0
  14. package/dist/StatsPeerConnection/constants.d.ts +14 -0
  15. package/dist/StatsPeerConnection/eventNames.d.ts +10 -0
  16. package/dist/StatsPeerConnection/index.d.ts +4 -0
  17. package/dist/StatsPeerConnection/parseStatsReports.d.ts +14 -0
  18. package/dist/StatsPeerConnection/requestAllStatistics.d.ts +11 -0
  19. package/dist/StatsPeerConnection/typings.d.ts +194 -0
  20. package/dist/StatsPeerConnection/utils/hasAvailableStats.d.ts +2 -0
  21. package/dist/StatsPeerConnection/utils/index.d.ts +3 -0
  22. package/dist/StatsPeerConnection/utils/now.d.ts +2 -0
  23. package/dist/StatsPeerConnection/utils/statsReportToObject.d.ts +4 -0
  24. package/dist/{videoSendingBalancer → VideoSendingBalancer}/ParametersSetterWithQueue.d.ts +2 -2
  25. package/dist/{videoSendingBalancer → VideoSendingBalancer}/SenderBalancer.d.ts +2 -2
  26. package/dist/{videoSendingBalancer → VideoSendingBalancer}/VideoSendingBalancer.d.ts +2 -2
  27. package/dist/{videoSendingBalancer → VideoSendingBalancer}/types.d.ts +2 -2
  28. package/dist/doMock.cjs +1 -1
  29. package/dist/doMock.js +4 -4
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.d.ts +2 -2
  32. package/dist/index.js +270 -255
  33. package/dist/tools/createUaParser/createUaParser.d.ts +4 -0
  34. package/dist/tools/createUaParser/index.d.ts +1 -0
  35. package/dist/tools/createUaParser/isElectronEnvironment.d.ts +2 -0
  36. package/dist/tools/index.d.ts +4 -0
  37. package/dist/{setParametersToSender → tools/setParametersToSender}/configureDegradationPreference.d.ts +1 -1
  38. package/dist/{setParametersToSender → tools/setParametersToSender}/configureEncodings.d.ts +1 -1
  39. package/dist/{setParametersToSender → tools/setParametersToSender}/index.d.ts +1 -1
  40. package/dist/{setParametersToSender → tools/setParametersToSender}/setEncodingsToSender.d.ts +2 -2
  41. package/dist/{setParametersToSender → tools/setParametersToSender}/setMaxBitrateToSender.d.ts +1 -1
  42. package/dist/tools/setParametersToSender/setParametersToSender.d.ts +4 -0
  43. package/dist/{setParametersToSender → tools/setParametersToSender}/types.d.ts +1 -1
  44. package/package.json +9 -15
  45. package/dist/@SipConnector-BBhQzo-W.cjs +0 -1
  46. package/dist/setParametersToSender/setParametersToSender.d.ts +0 -4
  47. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/CodecProvider.d.ts +0 -0
  48. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/SenderFinder.d.ts +0 -0
  49. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/TaskQueue.d.ts +0 -0
  50. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/VideoSendingEventHandler.d.ts +0 -0
  51. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/calcBitrate/calcMaxBitrateByWidth.d.ts +0 -0
  52. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/calcBitrate/calcMaxBitrateByWidthAndCodec.d.ts +0 -0
  53. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/calcBitrate/hasAv1Codec.d.ts +0 -0
  54. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/calcBitrate/index.d.ts +0 -0
  55. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/calcBitrate/scaleBitrateByCodec.d.ts +0 -0
  56. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/calcResolution/calcScaleResolutionDownBy.d.ts +0 -0
  57. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/calcResolution/index.d.ts +0 -0
  58. /package/dist/{videoSendingBalancer → VideoSendingBalancer}/index.d.ts +0 -0
  59. /package/dist/{setParametersToSender → tools/setParametersToSender}/configureEmptyEncodings.d.ts +0 -0
  60. /package/dist/{setParametersToSender → tools/setParametersToSender}/configureMaxBitrate.d.ts +0 -0
  61. /package/dist/{setParametersToSender → tools/setParametersToSender}/configureScaleResolutionDownBy.d.ts +0 -0
  62. /package/dist/{setParametersToSender → tools/setParametersToSender}/hasChangedRTCRtpSendParameters.d.ts +0 -0
  63. /package/dist/{setParametersToSender → tools/setParametersToSender}/resolveHasNeedToUpdateItemEncoding.d.ts +0 -0
@@ -1,10 +1,13 @@
1
- import { Events as O } from "events-constructor";
2
- import "@krivega/cancelable-promise";
3
- import k from "debug";
4
- import { hasCanceledError as K, repeatedCallsAsync as V } from "repeated-calls";
5
- import { setup as j, createActor as Z } from "xstate";
6
- var N = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n))(N || {}), b = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(b || {});
7
- const H = [
1
+ import { Events as f, TypedEvents as ae } from "events-constructor";
2
+ import { CancelableRequest as oe } from "@krivega/cancelable-promise";
3
+ import B from "debug";
4
+ import { hasCanceledError as ce, repeatedCallsAsync as Y } from "repeated-calls";
5
+ import { setup as ge, createActor as de } from "xstate";
6
+ import { SetTimeoutRequest as Te } from "@krivega/timeout-requester";
7
+ import "ua-parser-js";
8
+ import "sequent-promises";
9
+ var N = /* @__PURE__ */ ((n) => (n.PEER_CONNECTION = "peerconnection", n.CONNECTING = "connecting", n.SENDING = "sending", n.PROGRESS = "progress", n.ACCEPTED = "accepted", n.CONFIRMED = "confirmed", n.ENDED = "ended", n.FAILED = "failed", n.NEW_DTMF = "newDTMF", n.NEW_INFO = "newInfo", n.HOLD = "hold", n.UNHOLD = "unhold", n.MUTED = "muted", n.UNMUTED = "unmuted", n.REINVITE = "reinvite", n.UPDATE = "update", n.REFER = "refer", n.REPLACES = "replaces", n.SDP = "sdp", n.ICE_CANDIDATE = "icecandidate", n.GET_USER_MEDIA_FAILED = "getusermediafailed", n.PEER_CONNECTION_CREATE_OFFER_FAILED = "peerconnection:createofferfailed", n.PEER_CONNECTION_CREATE_ANSWER_FAILED = "peerconnection:createanswerfailed", n.PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED = "peerconnection:setlocaldescriptionfailed", n.PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED = "peerconnection:setremotedescriptionfailed", n.START_PRESENTATION = "presentation:start", n.STARTED_PRESENTATION = "presentation:started", n.END_PRESENTATION = "presentation:end", n.ENDED_PRESENTATION = "presentation:ended", n.FAILED_PRESENTATION = "presentation:failed", n.PEER_CONNECTION_CONFIRMED = "peerconnection:confirmed", n.PEER_CONNECTION_ONTRACK = "peerconnection:ontrack", n.ENDED_FROM_SERVER = "ended:fromserver", n))(N || {}), $ = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))($ || {});
10
+ const z = [
8
11
  "peerconnection",
9
12
  "connecting",
10
13
  "sending",
@@ -31,18 +34,18 @@ const H = [
31
34
  "peerconnection:createanswerfailed",
32
35
  "peerconnection:setlocaldescriptionfailed",
33
36
  "peerconnection:setremotedescriptionfailed"
34
- ], ee = [
37
+ ], he = [
35
38
  "peerconnection:confirmed",
36
39
  "peerconnection:ontrack",
37
40
  "ended:fromserver"
38
- ], G = [
39
- ...H,
40
- ...ee
41
- ], te = (n, e) => {
41
+ ], Q = [
42
+ ...z,
43
+ ...he
44
+ ], le = (n, e) => {
42
45
  n.getVideoTracks().forEach((s) => {
43
46
  "contentHint" in s && s.contentHint !== e && (s.contentHint = e);
44
47
  });
45
- }, v = (n, {
48
+ }, w = (n, {
46
49
  directionVideo: e,
47
50
  directionAudio: t,
48
51
  contentHint: s
@@ -50,16 +53,16 @@ const H = [
50
53
  if (!n || e === "recvonly" && t === "recvonly")
51
54
  return;
52
55
  const i = t === "recvonly" ? [] : n.getAudioTracks(), r = e === "recvonly" ? [] : n.getVideoTracks(), a = [...i, ...r], o = new MediaStream(a);
53
- return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && te(o, s), o;
56
+ return o.getTracks = () => [...o.getAudioTracks(), ...o.getVideoTracks()], s && s !== "none" && le(o, s), o;
54
57
  };
55
- function ne(n) {
58
+ function Se(n) {
56
59
  return (e) => `sip:${e}@${n}`;
57
60
  }
58
- const se = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, B = (n) => n.trim().replaceAll(" ", "_"), ie = se(1e5, 99999999), re = (n) => n.some((t) => {
61
+ const Ee = (n, e) => () => Math.floor(Math.random() * (e - n)) + n, X = (n) => n.trim().replaceAll(" ", "_"), ue = Ee(1e5, 99999999), Ce = (n) => n.some((t) => {
59
62
  const { kind: s } = t;
60
63
  return s === "video";
61
64
  });
62
- class ae {
65
+ class Ne {
63
66
  isPendingCall = !1;
64
67
  isPendingAnswer = !1;
65
68
  rtcSession;
@@ -70,8 +73,8 @@ class ae {
70
73
  this.events = e;
71
74
  }
72
75
  }
73
- var x = /* @__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))(x || {});
74
- class oe {
76
+ var J = /* @__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))(J || {});
77
+ class Ae {
75
78
  remoteStreams = {};
76
79
  reset() {
77
80
  this.remoteStreams = {};
@@ -100,8 +103,8 @@ class oe {
100
103
  return e.map((t) => this.generateAudioStream(t));
101
104
  }
102
105
  }
103
- class ce extends ae {
104
- remoteStreamsManager = new oe();
106
+ class Re extends Ne {
107
+ remoteStreamsManager = new Ae();
105
108
  disposers = /* @__PURE__ */ new Set();
106
109
  constructor(e) {
107
110
  super(e), e.on(N.FAILED, this.handleEnded), e.on(N.ENDED, this.handleEnded);
@@ -125,37 +128,37 @@ class ce extends ae {
125
128
  ontrack: a,
126
129
  iceServers: o,
127
130
  directionVideo: c,
128
- directionAudio: T,
129
- contentHint: d,
130
- offerToReceiveAudio: l = !0,
131
- offerToReceiveVideo: E = !0,
131
+ directionAudio: g,
132
+ contentHint: l,
133
+ offerToReceiveAudio: u = !0,
134
+ offerToReceiveVideo: d = !0,
132
135
  sendEncodings: S,
133
- onAddedTransceiver: R
136
+ onAddedTransceiver: _
134
137
  }) => (this.isPendingCall = !0, new Promise((C, p) => {
135
- this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(C).catch((w) => {
136
- p(w);
138
+ this.callConfiguration.number = s, this.callConfiguration.answer = !1, this.handleCall({ ontrack: a }).then(C).catch((v) => {
139
+ p(v);
137
140
  }), this.rtcSession = e.call(t(s), {
138
141
  extraHeaders: r,
139
- mediaStream: v(i, {
142
+ mediaStream: w(i, {
140
143
  directionVideo: c,
141
- directionAudio: T,
142
- contentHint: d
144
+ directionAudio: g,
145
+ contentHint: l
143
146
  }),
144
147
  // необходимо передавать в методе call, чтобы подписаться на события peerconnection,
145
148
  // так как в методе call создается RTCSession
146
149
  // и после создания нет возможности подписаться на события peerconnection через subscribeToSessionEvents
147
150
  eventHandlers: this.events.triggers,
148
151
  directionVideo: c,
149
- directionAudio: T,
152
+ directionAudio: g,
150
153
  pcConfig: {
151
154
  iceServers: o
152
155
  },
153
156
  rtcOfferConstraints: {
154
- offerToReceiveAudio: l,
155
- offerToReceiveVideo: E
157
+ offerToReceiveAudio: u,
158
+ offerToReceiveVideo: d
156
159
  },
157
160
  sendEncodings: S,
158
- onAddedTransceiver: R
161
+ onAddedTransceiver: _
159
162
  });
160
163
  }).finally(() => {
161
164
  this.isPendingCall = !1;
@@ -164,7 +167,7 @@ class ce extends ae {
164
167
  const { rtcSession: e } = this;
165
168
  if (e && !e.isEnded())
166
169
  return e.terminateAsync({
167
- cause: x.CANCELED
170
+ cause: J.CANCELED
168
171
  }).finally(() => {
169
172
  this.reset();
170
173
  });
@@ -178,20 +181,20 @@ class ce extends ae {
178
181
  directionVideo: a,
179
182
  directionAudio: o,
180
183
  offerToReceiveAudio: c,
181
- offerToReceiveVideo: T,
182
- contentHint: d,
183
- sendEncodings: l,
184
- onAddedTransceiver: E
185
- }) => (this.isPendingAnswer = !0, new Promise((S, R) => {
184
+ offerToReceiveVideo: g,
185
+ contentHint: l,
186
+ sendEncodings: u,
187
+ onAddedTransceiver: d
188
+ }) => (this.isPendingAnswer = !0, new Promise((S, _) => {
186
189
  try {
187
190
  const C = e();
188
- this.rtcSession = C, this.subscribeToSessionEvents(C), this.callConfiguration.answer = !0, this.callConfiguration.number = C.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(S).catch((w) => {
189
- R(w);
191
+ this.rtcSession = C, this.subscribeToSessionEvents(C), this.callConfiguration.answer = !0, this.callConfiguration.number = C.remote_identity.uri.user, this.handleCall({ ontrack: s }).then(S).catch((v) => {
192
+ _(v);
190
193
  });
191
- const p = v(t, {
194
+ const p = w(t, {
192
195
  directionVideo: a,
193
196
  directionAudio: o,
194
- contentHint: d
197
+ contentHint: l
195
198
  });
196
199
  C.answer({
197
200
  extraHeaders: i,
@@ -203,13 +206,13 @@ class ce extends ae {
203
206
  },
204
207
  rtcOfferConstraints: {
205
208
  offerToReceiveAudio: c,
206
- offerToReceiveVideo: T
209
+ offerToReceiveVideo: g
207
210
  },
208
- sendEncodings: l,
209
- onAddedTransceiver: E
211
+ sendEncodings: u,
212
+ onAddedTransceiver: d
210
213
  });
211
214
  } catch (C) {
212
- R(C);
215
+ _(C);
213
216
  }
214
217
  }).finally(() => {
215
218
  this.isPendingAnswer = !1;
@@ -224,12 +227,12 @@ class ce extends ae {
224
227
  if (!this.connection)
225
228
  return;
226
229
  const t = this.connection.getReceivers().map(({ track: s }) => s);
227
- return re(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
230
+ return Ce(t) ? this.remoteStreamsManager.generateStreams(t) : this.remoteStreamsManager.generateAudioStreams(t);
228
231
  }
229
232
  async replaceMediaStream(e, t) {
230
233
  if (!this.rtcSession)
231
234
  throw new Error("No rtcSession established");
232
- const { contentHint: s } = t ?? {}, i = v(e, { contentHint: s });
235
+ const { contentHint: s } = t ?? {}, i = w(e, { contentHint: s });
233
236
  if (i === void 0)
234
237
  throw new Error("No preparedMediaStream");
235
238
  return this.rtcSession.replaceMediaStream(i, t);
@@ -238,33 +241,33 @@ class ce extends ae {
238
241
  ontrack: e
239
242
  }) => new Promise((t, s) => {
240
243
  const i = () => {
241
- this.events.on(N.PEER_CONNECTION, d), this.events.on(N.CONFIRMED, l);
244
+ this.events.on(N.PEER_CONNECTION, l), this.events.on(N.CONFIRMED, u);
242
245
  }, r = () => {
243
- this.events.off(N.PEER_CONNECTION, d), this.events.off(N.CONFIRMED, l);
246
+ this.events.off(N.PEER_CONNECTION, l), this.events.off(N.CONFIRMED, u);
244
247
  }, a = () => {
245
248
  this.events.on(N.FAILED, c), this.events.on(N.ENDED, c);
246
249
  }, o = () => {
247
250
  this.events.off(N.FAILED, c), this.events.off(N.ENDED, c);
248
- }, c = (E) => {
249
- r(), o(), s(E);
251
+ }, c = (d) => {
252
+ r(), o(), s(d);
250
253
  };
251
- let T;
252
- const d = ({ peerconnection: E }) => {
253
- T = E;
254
- const S = (R) => {
255
- this.events.trigger(N.PEER_CONNECTION_ONTRACK, E), e && e(R);
254
+ let g;
255
+ const l = ({ peerconnection: d }) => {
256
+ g = d;
257
+ const S = (_) => {
258
+ this.events.trigger(N.PEER_CONNECTION_ONTRACK, d), e && e(_);
256
259
  };
257
- E.addEventListener("track", S), this.disposers.add(() => {
258
- E.removeEventListener("track", S);
260
+ d.addEventListener("track", S), this.disposers.add(() => {
261
+ d.removeEventListener("track", S);
259
262
  });
260
- }, l = () => {
261
- T !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, T), r(), o(), t(T);
263
+ }, u = () => {
264
+ g !== void 0 && this.events.trigger(N.PEER_CONNECTION_CONFIRMED, g), r(), o(), t(g);
262
265
  };
263
266
  i(), a();
264
267
  });
265
268
  subscribeToSessionEvents(e) {
266
269
  this.events.eachTriggers((t, s) => {
267
- const i = H.find((r) => r === s);
270
+ const i = z.find((r) => r === s);
268
271
  i && (e.on(i, t), this.disposers.add(() => {
269
272
  e.off(i, t);
270
273
  }));
@@ -277,17 +280,17 @@ class ce extends ae {
277
280
  }
278
281
  handleEnded = (e) => {
279
282
  const { originator: t } = e;
280
- t === b.REMOTE && this.events.trigger(N.ENDED_FROM_SERVER, e), this.reset();
283
+ t === $.REMOTE && this.events.trigger(N.ENDED_FROM_SERVER, e), this.reset();
281
284
  };
282
285
  reset = () => {
283
286
  delete this.rtcSession, this.remoteStreamsManager.reset(), this.unsubscribeFromSessionEvents(), this.callConfiguration.number = void 0, this.callConfiguration.answer = !1;
284
287
  };
285
288
  }
286
- class ge {
289
+ class _e {
287
290
  events;
288
291
  strategy;
289
292
  constructor(e) {
290
- this.events = new O(G), this.strategy = e ?? new ce(this.events);
293
+ this.events = new f(Q), this.strategy = e ?? new Re(this.events);
291
294
  }
292
295
  get requested() {
293
296
  return this.strategy.requested;
@@ -331,13 +334,13 @@ class ge {
331
334
  getRemoteStreams = () => this.strategy.getRemoteStreams();
332
335
  replaceMediaStream = async (...e) => this.strategy.replaceMediaStream(...e);
333
336
  }
334
- const W = "sip-connector", m = k(W), He = () => {
335
- k.enable(W);
336
- }, Ge = () => {
337
- k.enable(`-${W}`);
338
- }, Te = "Error decline with 603", he = 1006, de = (n) => typeof n == "object" && n !== null && "code" in n && n.code === he, Ee = (n) => n.message === Te;
339
- var h = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n))(h || {}), y = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(y || {}), U = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n.SPECTATOR_OVER_SFU = "SPECTATOROVERSFU", n))(U || {}), M = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n))(M || {}), _ = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n))(_ || {}), f = /* @__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))(f || {}), L = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(L || {}), F = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(F || {}), Se = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Se || {}), g = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_OVER_SFU = "participant:move-request-to-spectators-over-sfu", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n))(g || {});
340
- const q = [
337
+ const G = "sip-connector", P = B(G), ht = () => {
338
+ B.enable(G);
339
+ }, lt = () => {
340
+ B.enable(`-${G}`);
341
+ }, Ie = "Error decline with 603", Me = 1006, pe = (n) => typeof n == "object" && n !== null && "code" in n && n.code === Me, me = (n) => n.message === Ie;
342
+ var h = /* @__PURE__ */ ((n) => (n.CONTENT_TYPE = "content-type", n.CONTENT_ENTER_ROOM = "x-webrtc-enter-room", n.CONTENT_USE_LICENSE = "X-WEBRTC-USE-LICENSE", n.PARTICIPANT_NAME = "X-WEBRTC-PARTICIPANT-NAME", n.INPUT_CHANNELS = "X-WEBRTC-INPUT-CHANNELS", n.OUTPUT_CHANNELS = "X-WEBRTC-OUTPUT-CHANNELS", n.MAIN_CAM = "X-WEBRTC-MAINCAM", n.MIC = "X-WEBRTC-MIC", n.MEDIA_SYNC = "X-WEBRTC-SYNC", n.MAIN_CAM_RESOLUTION = "X-WEBRTC-MAINCAM-RESOLUTION", n.MEDIA_STATE = "X-WEBRTC-MEDIA-STATE", n.MEDIA_TYPE = "X-Vinteo-Media-Type", n.MAIN_CAM_STATE = "X-Vinteo-MainCam-State", n.MIC_STATE = "X-Vinteo-Mic-State", n.CONTENT_PARTICIPANT_STATE = "X-WEBRTC-PARTSTATE", n.NOTIFY = "X-VINTEO-NOTIFY", n.CONTENT_ENABLE_MEDIA_DEVICE = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", n.CONTENT_SHARE_STATE = "x-webrtc-share-state", n.MUST_STOP_PRESENTATION_P2P = "x-webrtc-share-state: YOUMUSTSTOPSENDCONTENT", n.START_PRESENTATION_P2P = "x-webrtc-share-state: YOUCANRECEIVECONTENT", n.STOP_PRESENTATION_P2P = "x-webrtc-share-state: CONTENTEND", n.STOP_PRESENTATION = "x-webrtc-share-state: STOPPRESENTATION", n.START_PRESENTATION = "x-webrtc-share-state: LETMESTARTPRESENTATION", n.ENABLE_MAIN_CAM = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE: LETMESTARTMAINCAM", n.AVAILABLE_INCOMING_BITRATE = "X-WEBRTC-AVAILABLE-INCOMING-BITRATE", n))(h || {}), L = /* @__PURE__ */ ((n) => (n.AVAILABLE_SECOND_REMOTE_STREAM = "YOUCANRECEIVECONTENT", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "CONTENTEND", n.MUST_STOP_PRESENTATION = "YOUMUSTSTOPSENDCONTENT", n))(L || {}), F = /* @__PURE__ */ ((n) => (n.SPECTATOR = "SPECTATOR", n.PARTICIPANT = "PARTICIPANT", n.SPECTATOR_OVER_SFU = "SPECTATOROVERSFU", n))(F || {}), m = /* @__PURE__ */ ((n) => (n.ENTER_ROOM = "application/vinteo.webrtc.roomname", n.MIC = "application/vinteo.webrtc.mic", n.USE_LICENSE = "application/vinteo.webrtc.uselic", n.PARTICIPANT_STATE = "application/vinteo.webrtc.partstate", n.NOTIFY = "application/vinteo.webrtc.notify", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n))(m || {}), I = /* @__PURE__ */ ((n) => (n.CHANNELS = "application/vinteo.webrtc.channels", n.MEDIA_STATE = "application/vinteo.webrtc.mediastate", n.REFUSAL = "application/vinteo.webrtc.refusal", n.SHARE_STATE = "application/vinteo.webrtc.sharedesktop", n.MAIN_CAM = "application/vinteo.webrtc.maincam", n.STATS = "application/vinteo.webrtc.stats", n))(I || {}), y = /* @__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))(y || {}), k = /* @__PURE__ */ ((n) => (n.ADMIN_STOP_MIC = "ADMINSTOPMIC", n.ADMIN_START_MIC = "ADMINSTARTMIC", n))(k || {}), W = /* @__PURE__ */ ((n) => (n.ADMIN_SYNC_FORCED = "1", n.ADMIN_SYNC_NOT_FORCED = "0", n))(W || {}), Pe = /* @__PURE__ */ ((n) => (n.AUDIO = "AUDIO", n.VIDEO = "VIDEO", n.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", n))(Pe || {}), T = /* @__PURE__ */ ((n) => (n.CHANNELS_NOTIFY = "channels:notify", n.PARTICIPANT_ADDED_TO_LIST_MODERATORS = "participant:added-to-list-moderators", n.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS = "participant:removed-from-list-moderators", n.PARTICIPANT_MOVE_REQUEST_TO_STREAM = "participant:move-request-to-stream", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS = "participant:move-request-to-spectators", n.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS = "participant:move-request-to-participants", n.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_OVER_SFU = "participant:move-request-to-spectators-over-sfu", n.PARTICIPATION_ACCEPTING_WORD_REQUEST = "participation:accepting-word-request", n.PARTICIPATION_CANCELLING_WORD_REQUEST = "participation:cancelling-word-request", n.WEBCAST_STARTED = "webcast:started", n.WEBCAST_STOPPED = "webcast:stopped", n.ACCOUNT_CHANGED = "account:changed", n.ACCOUNT_DELETED = "account:deleted", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "conference:participant-token-issued", n.CHANNELS = "channels", n.ENTER_ROOM = "enterRoom", n.SHARE_STATE = "shareState", n.MAIN_CAM_CONTROL = "main-cam-control", n.USE_LICENSE = "useLicense", n.ADMIN_START_MAIN_CAM = "admin-start-main-cam", n.ADMIN_STOP_MAIN_CAM = "admin-stop-main-cam", n.ADMIN_START_MIC = "admin-start-mic", n.ADMIN_STOP_MIC = "admin-stop-mic", n.ADMIN_FORCE_SYNC_MEDIA_STATE = "admin-force-sync-media-state", n.AVAILABLE_SECOND_REMOTE_STREAM = "availableSecondRemoteStream", n.NOT_AVAILABLE_SECOND_REMOTE_STREAM = "notAvailableSecondRemoteStream", n.MUST_STOP_PRESENTATION = "mustStopPresentation", n.NEW_DTMF = "newDTMF", n))(T || {});
343
+ const j = [
341
344
  "participation:accepting-word-request",
342
345
  "participation:cancelling-word-request",
343
346
  "participant:move-request-to-stream",
@@ -367,8 +370,8 @@ const q = [
367
370
  "mustStopPresentation",
368
371
  "newDTMF"
369
372
  ];
370
- var A = /* @__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))(A || {});
371
- class le {
373
+ var R = /* @__PURE__ */ ((n) => (n.CHANNELS = "channels", n.WEBCAST_STARTED = "WebcastStarted", n.WEBCAST_STOPPED = "WebcastStopped", n.ACCOUNT_CHANGED = "accountChanged", n.ACCOUNT_DELETED = "accountDeleted", n.ADDED_TO_LIST_MODERATORS = "addedToListModerators", n.REMOVED_FROM_LIST_MODERATORS = "removedFromListModerators", n.ACCEPTING_WORD_REQUEST = "ParticipationRequestAccepted", n.CANCELLING_WORD_REQUEST = "ParticipationRequestRejected", n.MOVE_REQUEST_TO_STREAM = "ParticipantMovedToWebcast", n.CONFERENCE_PARTICIPANT_TOKEN_ISSUED = "ConferenceParticipantTokenIssued", n))(R || {});
374
+ class Oe {
372
375
  events;
373
376
  connectionManager;
374
377
  callManager;
@@ -376,13 +379,13 @@ class le {
376
379
  connectionManager: e,
377
380
  callManager: t
378
381
  }) {
379
- this.connectionManager = e, this.callManager = t, this.events = new O(q), this.subscribe();
382
+ this.connectionManager = e, this.callManager = t, this.events = new f(j), this.subscribe();
380
383
  }
381
384
  async waitChannels() {
382
- return this.wait(g.CHANNELS);
385
+ return this.wait(T.CHANNELS);
383
386
  }
384
387
  async waitSyncMediaState() {
385
- return this.wait(g.ADMIN_FORCE_SYNC_MEDIA_STATE);
388
+ return this.wait(T.ADMIN_FORCE_SYNC_MEDIA_STATE);
386
389
  }
387
390
  async sendDTMF(e) {
388
391
  return new Promise((t, s) => {
@@ -393,7 +396,7 @@ class le {
393
396
  s(r);
394
397
  }
395
398
  i && (this.callManager.once("newDTMF", ({ originator: r }) => {
396
- r === b.LOCAL && t();
399
+ r === $.LOCAL && t();
397
400
  }), i.sendDTMF(e, {
398
401
  duration: 120,
399
402
  interToneGap: 600
@@ -405,7 +408,7 @@ class le {
405
408
  i,
406
409
  r
407
410
  ];
408
- return s.sendInfo(_.CHANNELS, void 0, { extraHeaders: a });
411
+ return s.sendInfo(I.CHANNELS, void 0, { extraHeaders: a });
409
412
  }
410
413
  async sendMediaState({ cam: e, mic: t }, s = {}) {
411
414
  const i = this.getEstablishedRTCSessionProtected(), r = `${h.MEDIA_STATE}: currentstate`, a = `${h.MAIN_CAM_STATE}: ${Number(e)}`, o = `${h.MIC_STATE}: ${Number(t)}`, c = [
@@ -413,15 +416,24 @@ class le {
413
416
  a,
414
417
  o
415
418
  ];
416
- return i.sendInfo(_.MEDIA_STATE, void 0, {
419
+ return i.sendInfo(I.MEDIA_STATE, void 0, {
417
420
  noTerminateWhenError: !0,
418
421
  ...s,
419
422
  extraHeaders: c
420
423
  });
421
424
  }
425
+ async sendStats({
426
+ availableIncomingBitrate: e
427
+ }) {
428
+ const t = this.getEstablishedRTCSessionProtected(), i = [`${h.AVAILABLE_INCOMING_BITRATE}: ${e}`];
429
+ return t.sendInfo(I.STATS, void 0, {
430
+ noTerminateWhenError: !0,
431
+ extraHeaders: i
432
+ });
433
+ }
422
434
  async sendRefusalToTurnOn(e, t = {}) {
423
435
  const s = this.getEstablishedRTCSessionProtected(), a = e === "mic" ? 0 : 1, c = [`${h.MEDIA_TYPE}: ${a}`];
424
- return s.sendInfo(_.REFUSAL, void 0, {
436
+ return s.sendInfo(I.REFUSAL, void 0, {
425
437
  noTerminateWhenError: !0,
426
438
  ...t,
427
439
  extraHeaders: c
@@ -434,38 +446,38 @@ class le {
434
446
  return this.sendRefusalToTurnOn("cam", { noTerminateWhenError: !0, ...e });
435
447
  }
436
448
  async sendMustStopPresentationP2P() {
437
- await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
449
+ await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
438
450
  extraHeaders: [h.MUST_STOP_PRESENTATION_P2P]
439
451
  });
440
452
  }
441
453
  async sendStoppedPresentationP2P() {
442
- await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
454
+ await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
443
455
  extraHeaders: [h.STOP_PRESENTATION_P2P]
444
456
  });
445
457
  }
446
458
  async sendStoppedPresentation() {
447
- await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
459
+ await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
448
460
  extraHeaders: [h.STOP_PRESENTATION]
449
461
  });
450
462
  }
451
463
  async askPermissionToStartPresentationP2P() {
452
- await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
464
+ await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
453
465
  extraHeaders: [h.START_PRESENTATION_P2P]
454
466
  });
455
467
  }
456
468
  async askPermissionToStartPresentation() {
457
- await this.getEstablishedRTCSessionProtected().sendInfo(_.SHARE_STATE, void 0, {
469
+ await this.getEstablishedRTCSessionProtected().sendInfo(I.SHARE_STATE, void 0, {
458
470
  extraHeaders: [h.START_PRESENTATION]
459
471
  });
460
472
  }
461
473
  async askPermissionToEnableCam(e = {}) {
462
474
  const t = this.getEstablishedRTCSessionProtected(), s = [h.ENABLE_MAIN_CAM];
463
- return t.sendInfo(_.MAIN_CAM, void 0, {
475
+ return t.sendInfo(I.MAIN_CAM, void 0, {
464
476
  noTerminateWhenError: !0,
465
477
  ...e,
466
478
  extraHeaders: s
467
479
  }).catch((i) => {
468
- if (Ee(i))
480
+ if (me(i))
469
481
  throw i;
470
482
  });
471
483
  }
@@ -510,100 +522,100 @@ class le {
510
522
  this.handleNotify(s);
511
523
  }
512
524
  } catch (t) {
513
- m("error parse notify", t);
525
+ P("error parse notify", t);
514
526
  }
515
527
  };
516
528
  handleNotify = (e) => {
517
529
  switch (e.cmd) {
518
- case A.CHANNELS: {
530
+ case R.CHANNELS: {
519
531
  const t = e;
520
532
  this.triggerChannelsNotify(t);
521
533
  break;
522
534
  }
523
- case A.WEBCAST_STARTED: {
535
+ case R.WEBCAST_STARTED: {
524
536
  const t = e;
525
537
  this.triggerWebcastStartedNotify(t);
526
538
  break;
527
539
  }
528
- case A.WEBCAST_STOPPED: {
540
+ case R.WEBCAST_STOPPED: {
529
541
  const t = e;
530
542
  this.triggerWebcastStoppedNotify(t);
531
543
  break;
532
544
  }
533
- case A.ADDED_TO_LIST_MODERATORS: {
545
+ case R.ADDED_TO_LIST_MODERATORS: {
534
546
  const t = e;
535
547
  this.triggerAddedToListModeratorsNotify(t);
536
548
  break;
537
549
  }
538
- case A.REMOVED_FROM_LIST_MODERATORS: {
550
+ case R.REMOVED_FROM_LIST_MODERATORS: {
539
551
  const t = e;
540
552
  this.triggerRemovedFromListModeratorsNotify(t);
541
553
  break;
542
554
  }
543
- case A.ACCEPTING_WORD_REQUEST: {
555
+ case R.ACCEPTING_WORD_REQUEST: {
544
556
  const t = e;
545
557
  this.triggerParticipationAcceptingWordRequest(t);
546
558
  break;
547
559
  }
548
- case A.CANCELLING_WORD_REQUEST: {
560
+ case R.CANCELLING_WORD_REQUEST: {
549
561
  const t = e;
550
562
  this.triggerParticipationCancellingWordRequest(t);
551
563
  break;
552
564
  }
553
- case A.MOVE_REQUEST_TO_STREAM: {
565
+ case R.MOVE_REQUEST_TO_STREAM: {
554
566
  const t = e;
555
567
  this.triggerParticipantMoveRequestToStream(t);
556
568
  break;
557
569
  }
558
- case A.ACCOUNT_CHANGED: {
570
+ case R.ACCOUNT_CHANGED: {
559
571
  this.triggerAccountChangedNotify();
560
572
  break;
561
573
  }
562
- case A.ACCOUNT_DELETED: {
574
+ case R.ACCOUNT_DELETED: {
563
575
  this.triggerAccountDeletedNotify();
564
576
  break;
565
577
  }
566
- case A.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
578
+ case R.CONFERENCE_PARTICIPANT_TOKEN_ISSUED: {
567
579
  const t = e;
568
580
  this.triggerConferenceParticipantTokenIssued(t);
569
581
  break;
570
582
  }
571
583
  default:
572
- m("unknown cmd", e);
584
+ P("unknown cmd", e);
573
585
  }
574
586
  };
575
587
  handleNewInfo = (e) => {
576
588
  const { originator: t } = e;
577
- if (t !== b.REMOTE)
589
+ if (t !== $.REMOTE)
578
590
  return;
579
591
  const { request: s } = e, i = s.getHeader(h.CONTENT_TYPE);
580
592
  if (i !== void 0)
581
593
  switch (i) {
582
- case M.ENTER_ROOM: {
594
+ case m.ENTER_ROOM: {
583
595
  this.triggerEnterRoom(s), this.maybeTriggerChannels(s);
584
596
  break;
585
597
  }
586
- case M.NOTIFY: {
598
+ case m.NOTIFY: {
587
599
  this.maybeHandleNotify(s);
588
600
  break;
589
601
  }
590
- case M.SHARE_STATE: {
602
+ case m.SHARE_STATE: {
591
603
  this.triggerShareState(s);
592
604
  break;
593
605
  }
594
- case M.MAIN_CAM: {
606
+ case m.MAIN_CAM: {
595
607
  this.triggerMainCamControl(s);
596
608
  break;
597
609
  }
598
- case M.MIC: {
610
+ case m.MIC: {
599
611
  this.triggerMicControl(s);
600
612
  break;
601
613
  }
602
- case M.USE_LICENSE: {
614
+ case m.USE_LICENSE: {
603
615
  this.triggerUseLicense(s);
604
616
  break;
605
617
  }
606
- case M.PARTICIPANT_STATE: {
618
+ case m.PARTICIPANT_STATE: {
607
619
  this.maybeTriggerParticipantMoveRequest(s);
608
620
  break;
609
621
  }
@@ -614,7 +626,7 @@ class le {
614
626
  inputChannels: t,
615
627
  outputChannels: s
616
628
  };
617
- this.events.trigger(g.CHANNELS_NOTIFY, i);
629
+ this.events.trigger(T.CHANNELS_NOTIFY, i);
618
630
  };
619
631
  triggerWebcastStartedNotify = ({
620
632
  body: { conference: e, type: t }
@@ -623,7 +635,7 @@ class le {
623
635
  conference: e,
624
636
  type: t
625
637
  };
626
- this.events.trigger(g.WEBCAST_STARTED, s);
638
+ this.events.trigger(T.WEBCAST_STARTED, s);
627
639
  };
628
640
  triggerWebcastStoppedNotify = ({
629
641
  body: { conference: e, type: t }
@@ -632,7 +644,7 @@ class le {
632
644
  conference: e,
633
645
  type: t
634
646
  };
635
- this.events.trigger(g.WEBCAST_STOPPED, s);
647
+ this.events.trigger(T.WEBCAST_STOPPED, s);
636
648
  };
637
649
  triggerAddedToListModeratorsNotify = ({
638
650
  conference: e
@@ -641,7 +653,7 @@ class le {
641
653
  conference: e
642
654
  };
643
655
  this.events.trigger(
644
- g.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
656
+ T.PARTICIPANT_ADDED_TO_LIST_MODERATORS,
645
657
  t
646
658
  );
647
659
  };
@@ -652,7 +664,7 @@ class le {
652
664
  conference: e
653
665
  };
654
666
  this.events.trigger(
655
- g.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
667
+ T.PARTICIPANT_REMOVED_FROM_LIST_MODERATORS,
656
668
  t
657
669
  );
658
670
  };
@@ -662,7 +674,7 @@ class le {
662
674
  const t = {
663
675
  conference: e
664
676
  };
665
- this.events.trigger(g.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
677
+ this.events.trigger(T.PARTICIPATION_ACCEPTING_WORD_REQUEST, t);
666
678
  };
667
679
  triggerParticipationCancellingWordRequest = ({
668
680
  body: { conference: e }
@@ -670,7 +682,7 @@ class le {
670
682
  const t = {
671
683
  conference: e
672
684
  };
673
- this.events.trigger(g.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
685
+ this.events.trigger(T.PARTICIPATION_CANCELLING_WORD_REQUEST, t);
674
686
  };
675
687
  triggerParticipantMoveRequestToStream = ({
676
688
  body: { conference: e }
@@ -678,13 +690,13 @@ class le {
678
690
  const t = {
679
691
  conference: e
680
692
  };
681
- this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
693
+ this.events.trigger(T.PARTICIPANT_MOVE_REQUEST_TO_STREAM, t);
682
694
  };
683
695
  triggerAccountChangedNotify = () => {
684
- this.events.trigger(g.ACCOUNT_CHANGED, void 0);
696
+ this.events.trigger(T.ACCOUNT_CHANGED, void 0);
685
697
  };
686
698
  triggerAccountDeletedNotify = () => {
687
- this.events.trigger(g.ACCOUNT_DELETED, void 0);
699
+ this.events.trigger(T.ACCOUNT_DELETED, void 0);
688
700
  };
689
701
  triggerConferenceParticipantTokenIssued = ({
690
702
  body: { conference: e, participant: t, jwt: s }
@@ -695,7 +707,7 @@ class le {
695
707
  jwt: s
696
708
  };
697
709
  this.events.trigger(
698
- g.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
710
+ T.CONFERENCE_PARTICIPANT_TOKEN_ISSUED,
699
711
  i
700
712
  );
701
713
  };
@@ -706,70 +718,70 @@ class le {
706
718
  inputChannels: t,
707
719
  outputChannels: s
708
720
  };
709
- this.events.trigger(g.CHANNELS, i);
721
+ this.events.trigger(T.CHANNELS, i);
710
722
  }
711
723
  };
712
724
  triggerEnterRoom = (e) => {
713
725
  const t = e.getHeader(h.CONTENT_ENTER_ROOM), s = e.getHeader(h.PARTICIPANT_NAME);
714
- this.events.trigger(g.ENTER_ROOM, { room: t, participantName: s });
726
+ this.events.trigger(T.ENTER_ROOM, { room: t, participantName: s });
715
727
  };
716
728
  triggerShareState = (e) => {
717
729
  const t = e.getHeader(h.CONTENT_SHARE_STATE);
718
730
  if (t !== void 0)
719
731
  switch (t) {
720
- case y.AVAILABLE_SECOND_REMOTE_STREAM: {
721
- this.events.trigger(g.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
732
+ case L.AVAILABLE_SECOND_REMOTE_STREAM: {
733
+ this.events.trigger(T.AVAILABLE_SECOND_REMOTE_STREAM, void 0);
722
734
  break;
723
735
  }
724
- case y.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
725
- this.events.trigger(g.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
736
+ case L.NOT_AVAILABLE_SECOND_REMOTE_STREAM: {
737
+ this.events.trigger(T.NOT_AVAILABLE_SECOND_REMOTE_STREAM, void 0);
726
738
  break;
727
739
  }
728
- case y.MUST_STOP_PRESENTATION: {
729
- this.events.trigger(g.MUST_STOP_PRESENTATION, void 0);
740
+ case L.MUST_STOP_PRESENTATION: {
741
+ this.events.trigger(T.MUST_STOP_PRESENTATION, void 0);
730
742
  break;
731
743
  }
732
744
  }
733
745
  };
734
746
  maybeTriggerParticipantMoveRequest = (e) => {
735
747
  const t = e.getHeader(h.CONTENT_PARTICIPANT_STATE);
736
- t === U.SPECTATOR && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === U.PARTICIPANT && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0), t === U.SPECTATOR_OVER_SFU && this.events.trigger(g.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_OVER_SFU, void 0);
748
+ t === F.SPECTATOR && this.events.trigger(T.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS, void 0), t === F.PARTICIPANT && this.events.trigger(T.PARTICIPANT_MOVE_REQUEST_TO_PARTICIPANTS, void 0), t === F.SPECTATOR_OVER_SFU && this.events.trigger(T.PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS_OVER_SFU, void 0);
737
749
  };
738
750
  triggerMainCamControl = (e) => {
739
- const t = e.getHeader(h.MAIN_CAM), s = e.getHeader(h.MEDIA_SYNC), i = s === F.ADMIN_SYNC_FORCED;
740
- if (t === f.ADMIN_START_MAIN_CAM) {
741
- this.events.trigger(g.ADMIN_START_MAIN_CAM, { isSyncForced: i });
751
+ const t = e.getHeader(h.MAIN_CAM), s = e.getHeader(h.MEDIA_SYNC), i = s === W.ADMIN_SYNC_FORCED;
752
+ if (t === y.ADMIN_START_MAIN_CAM) {
753
+ this.events.trigger(T.ADMIN_START_MAIN_CAM, { isSyncForced: i });
742
754
  return;
743
755
  }
744
- if (t === f.ADMIN_STOP_MAIN_CAM) {
745
- this.events.trigger(g.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
756
+ if (t === y.ADMIN_STOP_MAIN_CAM) {
757
+ this.events.trigger(T.ADMIN_STOP_MAIN_CAM, { isSyncForced: i });
746
758
  return;
747
759
  }
748
- (t === f.RESUME_MAIN_CAM || t === f.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(g.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
760
+ (t === y.RESUME_MAIN_CAM || t === y.PAUSE_MAIN_CAM) && s !== void 0 && this.events.trigger(T.ADMIN_FORCE_SYNC_MEDIA_STATE, { isSyncForced: i });
749
761
  const r = e.getHeader(h.MAIN_CAM_RESOLUTION);
750
- this.events.trigger(g.MAIN_CAM_CONTROL, {
762
+ this.events.trigger(T.MAIN_CAM_CONTROL, {
751
763
  mainCam: t,
752
764
  resolutionMainCam: r
753
765
  });
754
766
  };
755
767
  triggerMicControl = (e) => {
756
- const t = e.getHeader(h.MIC), i = e.getHeader(h.MEDIA_SYNC) === F.ADMIN_SYNC_FORCED;
757
- t === L.ADMIN_START_MIC ? this.events.trigger(g.ADMIN_START_MIC, { isSyncForced: i }) : t === L.ADMIN_STOP_MIC && this.events.trigger(g.ADMIN_STOP_MIC, { isSyncForced: i });
768
+ const t = e.getHeader(h.MIC), i = e.getHeader(h.MEDIA_SYNC) === W.ADMIN_SYNC_FORCED;
769
+ t === k.ADMIN_START_MIC ? this.events.trigger(T.ADMIN_START_MIC, { isSyncForced: i }) : t === k.ADMIN_STOP_MIC && this.events.trigger(T.ADMIN_STOP_MIC, { isSyncForced: i });
758
770
  };
759
771
  triggerUseLicense = (e) => {
760
772
  const t = e.getHeader(h.CONTENT_USE_LICENSE);
761
- this.events.trigger(g.USE_LICENSE, t);
773
+ this.events.trigger(T.USE_LICENSE, t);
762
774
  };
763
775
  }
764
- var I = /* @__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))(I || {});
765
- const Y = [
776
+ var M = /* @__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))(M || {});
777
+ const K = [
766
778
  "presentation:start",
767
779
  "presentation:started",
768
780
  "presentation:end",
769
781
  "presentation:ended",
770
782
  "presentation:failed"
771
- ], Ce = 1, Be = (n) => K(n);
772
- class Ne {
783
+ ], fe = 1, St = (n) => ce(n);
784
+ class ve {
773
785
  events;
774
786
  promisePendingStartPresentation;
775
787
  promisePendingStopPresentation;
@@ -777,7 +789,7 @@ class Ne {
777
789
  cancelableSendPresentationWithRepeatedCalls;
778
790
  callManager;
779
791
  constructor({ callManager: e }) {
780
- this.callManager = e, this.events = new O(Y), this.subscribe();
792
+ this.callManager = e, this.events = new f(K), this.subscribe();
781
793
  }
782
794
  get isPendingPresentation() {
783
795
  return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
@@ -790,11 +802,11 @@ class Ne {
790
802
  sendEncodings: a,
791
803
  onAddedTransceiver: o
792
804
  } = {}, c) {
793
- const T = this.getRtcSessionProtected();
805
+ const g = this.getRtcSessionProtected();
794
806
  if (this.streamPresentationCurrent)
795
807
  throw new Error("Presentation is already started");
796
808
  return this.sendPresentationWithDuplicatedCalls(e, {
797
- rtcSession: T,
809
+ rtcSession: g,
798
810
  stream: t,
799
811
  presentationOptions: {
800
812
  isNeedReinvite: s,
@@ -812,8 +824,8 @@ class Ne {
812
824
  let s = this.promisePendingStartPresentation ?? Promise.resolve(void 0);
813
825
  const i = this.callManager.getEstablishedRTCSession();
814
826
  return i && t ? s = e().then(async () => i.stopPresentation(t)).catch((r) => {
815
- throw this.events.trigger(I.FAILED_PRESENTATION, r), r;
816
- }) : t && this.events.trigger(I.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
827
+ throw this.events.trigger(M.FAILED_PRESENTATION, r), r;
828
+ }) : t && this.events.trigger(M.ENDED_PRESENTATION, t), this.promisePendingStopPresentation = s, s.finally(() => {
817
829
  this.resetPresentation();
818
830
  });
819
831
  }
@@ -858,15 +870,15 @@ class Ne {
858
870
  }
859
871
  subscribe() {
860
872
  this.callManager.on("presentation:start", (e) => {
861
- this.events.trigger(I.START_PRESENTATION, e);
873
+ this.events.trigger(M.START_PRESENTATION, e);
862
874
  }), this.callManager.on("presentation:started", (e) => {
863
- this.events.trigger(I.STARTED_PRESENTATION, e);
875
+ this.events.trigger(M.STARTED_PRESENTATION, e);
864
876
  }), this.callManager.on("presentation:end", (e) => {
865
- this.events.trigger(I.END_PRESENTATION, e);
877
+ this.events.trigger(M.END_PRESENTATION, e);
866
878
  }), this.callManager.on("presentation:ended", (e) => {
867
- this.events.trigger(I.ENDED_PRESENTATION, e);
879
+ this.events.trigger(M.ENDED_PRESENTATION, e);
868
880
  }), this.callManager.on("presentation:failed", (e) => {
869
- this.events.trigger(I.FAILED_PRESENTATION, e);
881
+ this.events.trigger(M.FAILED_PRESENTATION, e);
870
882
  }), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded);
871
883
  }
872
884
  async sendPresentationWithDuplicatedCalls(e, {
@@ -874,7 +886,7 @@ class Ne {
874
886
  stream: s,
875
887
  presentationOptions: i,
876
888
  options: r = {
877
- callLimit: Ce
889
+ callLimit: fe
878
890
  }
879
891
  }) {
880
892
  const a = async () => this.sendPresentation(
@@ -883,7 +895,7 @@ class Ne {
883
895
  s,
884
896
  i
885
897
  ), o = () => !!this.streamPresentationCurrent;
886
- return this.cancelableSendPresentationWithRepeatedCalls = V({
898
+ return this.cancelableSendPresentationWithRepeatedCalls = Y({
887
899
  targetFunction: a,
888
900
  isComplete: o,
889
901
  isRejectAsValid: !0,
@@ -898,17 +910,17 @@ class Ne {
898
910
  sendEncodings: a,
899
911
  onAddedTransceiver: o
900
912
  }) {
901
- const c = v(s, { contentHint: r });
913
+ const c = w(s, { contentHint: r });
902
914
  if (c === void 0)
903
915
  throw new Error("No streamPresentationTarget");
904
916
  this.streamPresentationCurrent = c;
905
- const T = e().then(async () => t.startPresentation(c, i, {
917
+ const g = e().then(async () => t.startPresentation(c, i, {
906
918
  sendEncodings: a,
907
919
  onAddedTransceiver: o
908
- })).then(() => s).catch((d) => {
909
- throw this.removeStreamPresentationCurrent(), this.events.trigger(I.FAILED_PRESENTATION, d), d;
920
+ })).then(() => s).catch((l) => {
921
+ throw this.removeStreamPresentationCurrent(), this.events.trigger(M.FAILED_PRESENTATION, l), l;
910
922
  });
911
- return this.promisePendingStartPresentation = T, T.finally(() => {
923
+ return this.promisePendingStartPresentation = g, g.finally(() => {
912
924
  this.promisePendingStartPresentation = void 0;
913
925
  });
914
926
  }
@@ -931,7 +943,7 @@ class Ne {
931
943
  delete this.streamPresentationCurrent;
932
944
  }
933
945
  }
934
- class ue {
946
+ class De {
935
947
  data = {};
936
948
  getUa;
937
949
  constructor(e) {
@@ -1004,8 +1016,8 @@ class ue {
1004
1016
  return this.data.register === !0;
1005
1017
  }
1006
1018
  }
1007
- var u = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n))(u || {});
1008
- const Q = [
1019
+ var A = /* @__PURE__ */ ((n) => (n.CONNECTING = "connecting", n.CONNECTED = "connected", n.DISCONNECTED = "disconnected", n.NEW_RTC_SESSION = "newRTCSession", n.REGISTERED = "registered", n.UNREGISTERED = "unregistered", n.REGISTRATION_FAILED = "registrationFailed", n.NEW_MESSAGE = "newMessage", n.SIP_EVENT = "sipEvent", n))(A || {});
1020
+ const Z = [
1009
1021
  "connecting",
1010
1022
  "connected",
1011
1023
  "disconnected",
@@ -1015,8 +1027,8 @@ const Q = [
1015
1027
  "registrationFailed",
1016
1028
  "newMessage",
1017
1029
  "sipEvent"
1018
- ], z = [...Q], Ae = 3;
1019
- class _e {
1030
+ ], ee = [...Z], ye = 3;
1031
+ class be {
1020
1032
  cancelableConnectWithRepeatedCalls;
1021
1033
  JsSIP;
1022
1034
  events;
@@ -1042,29 +1054,29 @@ class _e {
1042
1054
  }
1043
1055
  let r = !1;
1044
1056
  const a = this.getConnectionConfiguration();
1045
- e !== void 0 && e !== a.displayName && (r = i.set("display_name", B(e)), this.updateConnectionConfiguration("displayName", e));
1057
+ e !== void 0 && e !== a.displayName && (r = i.set("display_name", X(e)), this.updateConnectionConfiguration("displayName", e));
1046
1058
  const o = r;
1047
1059
  o ? t(o) : s(new Error("nothing changed"));
1048
1060
  });
1049
1061
  disconnect = async () => {
1050
1062
  const e = new Promise((s) => {
1051
- this.events.once(u.DISCONNECTED, () => {
1063
+ this.events.once(A.DISCONNECTED, () => {
1052
1064
  s();
1053
1065
  });
1054
1066
  }), t = this.getUa();
1055
- return t ? t.stop() : this.events.trigger(u.DISCONNECTED, void 0), e.finally(() => {
1067
+ return t ? t.stop() : this.events.trigger(A.DISCONNECTED, void 0), e.finally(() => {
1056
1068
  this.setUa(void 0), this.stateMachine.reset();
1057
1069
  });
1058
1070
  };
1059
1071
  cancelRequests() {
1060
1072
  this.cancelConnectWithRepeatedCalls();
1061
1073
  }
1062
- connectWithDuplicatedCalls = async (e, { callLimit: t = Ae } = {}) => {
1074
+ connectWithDuplicatedCalls = async (e, { callLimit: t = ye } = {}) => {
1063
1075
  const s = async () => this.connectInner(e), i = (r) => {
1064
- const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), T = r != null && !de(r);
1065
- return c || T;
1076
+ const c = this.getUa()?.isConnected() === !0 && this.hasEqualConnectionConfiguration(e), g = r != null && !pe(r);
1077
+ return c || g;
1066
1078
  };
1067
- return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = V({
1079
+ return this.stateMachine.startConnect(), this.cancelableConnectWithRepeatedCalls = Y({
1068
1080
  targetFunction: s,
1069
1081
  isComplete: i,
1070
1082
  callLimit: t,
@@ -1090,16 +1102,16 @@ class _e {
1090
1102
  sessionTimers: a,
1091
1103
  registerExpires: o,
1092
1104
  connectionRecoveryMinInterval: c,
1093
- connectionRecoveryMaxInterval: T,
1094
- userAgent: d,
1095
- displayName: l = "",
1096
- register: E = !1,
1105
+ connectionRecoveryMaxInterval: g,
1106
+ userAgent: l,
1107
+ displayName: u = "",
1108
+ register: d = !1,
1097
1109
  extraHeaders: S = []
1098
1110
  }) => {
1099
1111
  this.stateMachine.startInitUa(), this.setConnectionConfiguration({
1100
1112
  sipServerUrl: s,
1101
- displayName: l,
1102
- register: E,
1113
+ displayName: u,
1114
+ register: d,
1103
1115
  user: e,
1104
1116
  password: t
1105
1117
  }), this.getUa() && await this.disconnect();
@@ -1109,13 +1121,13 @@ class _e {
1109
1121
  password: t,
1110
1122
  sipServerUrl: s,
1111
1123
  sipWebSocketServerURL: i,
1112
- displayName: l,
1113
- register: E,
1124
+ displayName: u,
1125
+ register: d,
1114
1126
  sessionTimers: a,
1115
1127
  registerExpires: o,
1116
1128
  connectionRecoveryMinInterval: c,
1117
- connectionRecoveryMaxInterval: T,
1118
- userAgent: d,
1129
+ connectionRecoveryMaxInterval: g,
1130
+ userAgent: l,
1119
1131
  remoteAddress: r,
1120
1132
  extraHeaders: S
1121
1133
  },
@@ -1130,15 +1142,15 @@ class _e {
1130
1142
  return;
1131
1143
  }
1132
1144
  let i;
1133
- i = ((c, T) => {
1145
+ i = ((c, g) => {
1134
1146
  if (this.getConnectionConfiguration().register === !0)
1135
- return this.registrationManager.subscribeToStartEvents(c, T);
1136
- const l = u.CONNECTED, E = [u.DISCONNECTED];
1137
- return this.events.on(l, c), E.forEach((S) => {
1138
- this.events.on(S, T);
1147
+ return this.registrationManager.subscribeToStartEvents(c, g);
1148
+ const u = A.CONNECTED, d = [A.DISCONNECTED];
1149
+ return this.events.on(u, c), d.forEach((S) => {
1150
+ this.events.on(S, g);
1139
1151
  }), () => {
1140
- this.events.off(l, c), E.forEach((S) => {
1141
- this.events.off(S, T);
1152
+ this.events.off(u, c), d.forEach((S) => {
1153
+ this.events.off(S, g);
1142
1154
  });
1143
1155
  };
1144
1156
  })(() => {
@@ -1151,18 +1163,18 @@ class _e {
1151
1163
  this.cancelableConnectWithRepeatedCalls?.cancel();
1152
1164
  }
1153
1165
  }
1154
- var X = /* @__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))(X || {});
1155
- const Re = j({
1166
+ var te = /* @__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))(te || {});
1167
+ const Ue = ge({
1156
1168
  types: {
1157
1169
  context: {},
1158
1170
  events: {}
1159
1171
  },
1160
1172
  actions: {
1161
1173
  logTransition: (n, e) => {
1162
- m(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1174
+ P(`State transition: ${e.from} -> ${e.to} (${e.event})`);
1163
1175
  },
1164
1176
  logStateChange: (n, e) => {
1165
- m("ConnectionStateMachine state changed", e.state);
1177
+ P("ConnectionStateMachine state changed", e.state);
1166
1178
  }
1167
1179
  }
1168
1180
  }).createMachine({
@@ -1466,14 +1478,14 @@ const Re = j({
1466
1478
  }
1467
1479
  }
1468
1480
  });
1469
- class Ie {
1481
+ class we {
1470
1482
  actor;
1471
1483
  stateChangeListeners = /* @__PURE__ */ new Set();
1472
1484
  events;
1473
1485
  unsubscribeFromEvents;
1474
1486
  actorSubscription;
1475
1487
  constructor(e) {
1476
- this.events = e, this.actor = Z(Re), this.actorSubscription = this.actor.subscribe((t) => {
1488
+ this.events = e, this.actor = de(Ue), this.actorSubscription = this.actor.subscribe((t) => {
1477
1489
  const s = t.value;
1478
1490
  this.stateChangeListeners.forEach((i) => {
1479
1491
  i(s);
@@ -1559,7 +1571,7 @@ class Ie {
1559
1571
  return this.actor.getSnapshot().can({ type: e });
1560
1572
  }
1561
1573
  getValidEvents() {
1562
- return Object.values(X).filter((e) => this.canTransition(e));
1574
+ return Object.values(te).filter((e) => this.canTransition(e));
1563
1575
  }
1564
1576
  hasState(e) {
1565
1577
  return this.actor.getSnapshot().matches(e);
@@ -1567,7 +1579,7 @@ class Ie {
1567
1579
  sendEvent(e) {
1568
1580
  const t = this.actor.getSnapshot(), s = { type: e };
1569
1581
  if (!t.can(s)) {
1570
- m(
1582
+ P(
1571
1583
  `Invalid transition: ${s.type} from ${this.state}. Event cannot be processed in current state.`
1572
1584
  );
1573
1585
  return;
@@ -1628,7 +1640,7 @@ class Ie {
1628
1640
  };
1629
1641
  }
1630
1642
  }
1631
- class Me {
1643
+ class Le {
1632
1644
  events;
1633
1645
  getUaProtected;
1634
1646
  constructor(e) {
@@ -1637,25 +1649,25 @@ class Me {
1637
1649
  async register() {
1638
1650
  const e = this.getUaProtected();
1639
1651
  return new Promise((t, s) => {
1640
- e.on(u.REGISTERED, t), e.on(u.REGISTRATION_FAILED, s), e.register();
1652
+ e.on(A.REGISTERED, t), e.on(A.REGISTRATION_FAILED, s), e.register();
1641
1653
  });
1642
1654
  }
1643
1655
  async unregister() {
1644
1656
  const e = this.getUaProtected();
1645
1657
  return new Promise((t) => {
1646
- e.on(u.UNREGISTERED, t), e.unregister();
1658
+ e.on(A.UNREGISTERED, t), e.unregister();
1647
1659
  });
1648
1660
  }
1649
1661
  async tryRegister() {
1650
1662
  try {
1651
1663
  await this.unregister();
1652
1664
  } catch (e) {
1653
- m("tryRegister", e);
1665
+ P("tryRegister", e);
1654
1666
  }
1655
1667
  return this.register();
1656
1668
  }
1657
1669
  subscribeToStartEvents(e, t) {
1658
- const s = u.REGISTERED, i = [u.REGISTRATION_FAILED, u.DISCONNECTED];
1670
+ const s = A.REGISTERED, i = [A.REGISTRATION_FAILED, A.DISCONNECTED];
1659
1671
  return this.events.on(s, e), i.forEach((r) => {
1660
1672
  this.events.on(r, t);
1661
1673
  }), () => {
@@ -1665,7 +1677,7 @@ class Me {
1665
1677
  };
1666
1678
  }
1667
1679
  }
1668
- class pe {
1680
+ class Fe {
1669
1681
  uaFactory;
1670
1682
  getUaProtected;
1671
1683
  constructor(e) {
@@ -1711,30 +1723,30 @@ class pe {
1711
1723
  extraHeaders: a
1712
1724
  }) {
1713
1725
  return new Promise((o, c) => {
1714
- const { configuration: T } = this.uaFactory.createConfiguration({
1726
+ const { configuration: g } = this.uaFactory.createConfiguration({
1715
1727
  sipWebSocketServerURL: i,
1716
1728
  displayName: t,
1717
1729
  userAgent: e,
1718
1730
  sipServerUrl: s
1719
- }), d = this.uaFactory.createUA({ ...T, remoteAddress: r, extraHeaders: a }), l = () => {
1731
+ }), l = this.uaFactory.createUA({ ...g, remoteAddress: r, extraHeaders: a }), u = () => {
1720
1732
  const S = new Error("Telephony is not available");
1721
1733
  c(S);
1722
1734
  };
1723
- d.once(u.DISCONNECTED, l);
1724
- const E = () => {
1725
- d.removeAllListeners(), d.once(u.DISCONNECTED, () => {
1735
+ l.once(A.DISCONNECTED, u);
1736
+ const d = () => {
1737
+ l.removeAllListeners(), l.once(A.DISCONNECTED, () => {
1726
1738
  o();
1727
- }), d.stop();
1739
+ }), l.stop();
1728
1740
  };
1729
- d.once(u.CONNECTED, E), d.start();
1741
+ l.once(A.CONNECTED, d), l.start();
1730
1742
  });
1731
1743
  }
1732
1744
  }
1733
- const Pe = (n) => {
1745
+ const $e = (n) => {
1734
1746
  const e = [];
1735
1747
  return n !== void 0 && n !== "" && e.push(`X-Vinteo-Remote: ${n}`), e;
1736
1748
  };
1737
- class P {
1749
+ class O {
1738
1750
  JsSIP;
1739
1751
  constructor(e) {
1740
1752
  this.JsSIP = e;
@@ -1759,10 +1771,10 @@ class P {
1759
1771
  throw new Error("user is required for authorized connection");
1760
1772
  }
1761
1773
  static resolveAuthorizationUser(e, t) {
1762
- return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${ie()}`;
1774
+ return e && t !== void 0 && t.trim() !== "" ? t.trim() : `${ue()}`;
1763
1775
  }
1764
1776
  static buildExtraHeaders(e, t) {
1765
- const s = e !== void 0 && e !== "" ? Pe(e) : [];
1777
+ const s = e !== void 0 && e !== "" ? $e(e) : [];
1766
1778
  return t === void 0 ? s : [...s, ...t];
1767
1779
  }
1768
1780
  createConfiguration({
@@ -1775,31 +1787,31 @@ class P {
1775
1787
  sessionTimers: o = !1,
1776
1788
  registerExpires: c = 300,
1777
1789
  // 5 minutes in sec
1778
- connectionRecoveryMinInterval: T = 2,
1779
- connectionRecoveryMaxInterval: d = 6,
1780
- userAgent: l
1790
+ connectionRecoveryMinInterval: g = 2,
1791
+ connectionRecoveryMaxInterval: l = 6,
1792
+ userAgent: u
1781
1793
  }) {
1782
- P.validateConfiguration({
1794
+ O.validateConfiguration({
1783
1795
  register: a,
1784
1796
  password: t,
1785
1797
  user: e,
1786
1798
  sipServerUrl: r,
1787
1799
  sipWebSocketServerURL: s
1788
1800
  });
1789
- const E = P.resolveAuthorizationUser(a, e), S = ne(r), R = S(E), C = new this.JsSIP.WebSocketInterface(s);
1801
+ const d = O.resolveAuthorizationUser(a, e), S = Se(r), _ = S(d), C = new this.JsSIP.WebSocketInterface(s);
1790
1802
  return {
1791
1803
  configuration: {
1792
1804
  password: t,
1793
1805
  register: a,
1794
- uri: R,
1795
- display_name: B(i),
1796
- user_agent: l,
1806
+ uri: _,
1807
+ display_name: X(i),
1808
+ user_agent: u,
1797
1809
  sdpSemantics: "unified-plan",
1798
1810
  sockets: [C],
1799
1811
  session_timers: o,
1800
1812
  register_expires: c,
1801
- connection_recovery_min_interval: T,
1802
- connection_recovery_max_interval: d
1813
+ connection_recovery_min_interval: g,
1814
+ connection_recovery_max_interval: l
1803
1815
  },
1804
1816
  helpers: {
1805
1817
  socket: C,
@@ -1808,7 +1820,7 @@ class P {
1808
1820
  };
1809
1821
  }
1810
1822
  createUA({ remoteAddress: e, extraHeaders: t, ...s }) {
1811
- const i = new this.JsSIP.UA(s), r = P.buildExtraHeaders(e, t);
1823
+ const i = new this.JsSIP.UA(s), r = O.buildExtraHeaders(e, t);
1812
1824
  return r.length > 0 && i.registrator().setExtraHeaders(r), i;
1813
1825
  }
1814
1826
  /**
@@ -1821,12 +1833,12 @@ class P {
1821
1833
  extraHeaders: e.extraHeaders
1822
1834
  });
1823
1835
  return t.eachTriggers((a, o) => {
1824
- const c = Q.find((T) => T === o);
1836
+ const c = Z.find((g) => g === o);
1825
1837
  c && r.on(c, a);
1826
1838
  }), { ua: r, helpers: i };
1827
1839
  }
1828
1840
  }
1829
- class me {
1841
+ class ke {
1830
1842
  events;
1831
1843
  ua;
1832
1844
  socket;
@@ -1838,15 +1850,15 @@ class me {
1838
1850
  configurationManager;
1839
1851
  JsSIP;
1840
1852
  constructor({ JsSIP: e }) {
1841
- this.JsSIP = e, this.events = new O(z), this.uaFactory = new P(e), this.registrationManager = new Me({
1853
+ this.JsSIP = e, this.events = new f(ee), this.uaFactory = new O(e), this.registrationManager = new Le({
1842
1854
  events: this.events,
1843
1855
  getUaProtected: this.getUaProtected
1844
- }), this.stateMachine = new Ie(this.events), this.configurationManager = new ue({
1856
+ }), this.stateMachine = new we(this.events), this.configurationManager = new De({
1845
1857
  getUa: this.getUa
1846
- }), this.sipOperations = new pe({
1858
+ }), this.sipOperations = new Fe({
1847
1859
  uaFactory: this.uaFactory,
1848
1860
  getUaProtected: this.getUaProtected
1849
- }), this.connectionFlow = new _e({
1861
+ }), this.connectionFlow = new be({
1850
1862
  JsSIP: this.JsSIP,
1851
1863
  events: this.events,
1852
1864
  uaFactory: this.uaFactory,
@@ -1884,7 +1896,7 @@ class me {
1884
1896
  return this.stateMachine.state;
1885
1897
  }
1886
1898
  get isRegistered() {
1887
- return P.isRegisteredUA(this.ua);
1899
+ return O.isRegisteredUA(this.ua);
1888
1900
  }
1889
1901
  get isRegisterConfig() {
1890
1902
  return this.configurationManager.isRegister();
@@ -1928,7 +1940,7 @@ class me {
1928
1940
  destroy() {
1929
1941
  this.stateMachine.destroy();
1930
1942
  }
1931
- // eslint-disable-next-line class-methods-use-this
1943
+ // eslint-disable-next-line @typescript-eslint/class-methods-use-this
1932
1944
  getSipServerUrl = (e) => e;
1933
1945
  getUaProtected = () => {
1934
1946
  if (!this.ua)
@@ -1937,19 +1949,19 @@ class me {
1937
1949
  };
1938
1950
  getUa = () => this.ua;
1939
1951
  }
1940
- var D = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(D || {}), $ = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))($ || {});
1941
- const J = [
1952
+ var b = /* @__PURE__ */ ((n) => (n.INCOMING_CALL = "incomingCall", n.DECLINED_INCOMING_CALL = "declinedIncomingCall", n.TERMINATED_INCOMING_CALL = "terminatedIncomingCall", n.FAILED_INCOMING_CALL = "failedIncomingCall", n))(b || {}), V = /* @__PURE__ */ ((n) => (n.LOCAL = "local", n.REMOTE = "remote", n.SYSTEM = "system", n))(V || {});
1953
+ const ne = [
1942
1954
  "incomingCall",
1943
1955
  "declinedIncomingCall",
1944
1956
  "terminatedIncomingCall",
1945
1957
  "failedIncomingCall"
1946
- ], Oe = 486, fe = 487;
1947
- class De {
1958
+ ], We = 486, Ve = 487;
1959
+ class Be {
1948
1960
  events;
1949
1961
  incomingRTCSession;
1950
1962
  connectionManager;
1951
1963
  constructor(e) {
1952
- this.connectionManager = e, this.events = new O(J), this.start();
1964
+ this.connectionManager = e, this.events = new f(ne), this.start();
1953
1965
  }
1954
1966
  get remoteCallerData() {
1955
1967
  return {
@@ -1979,19 +1991,19 @@ class De {
1979
1991
  return this.removeIncomingSession(), e;
1980
1992
  };
1981
1993
  async declineToIncomingCall({
1982
- statusCode: e = fe
1994
+ statusCode: e = Ve
1983
1995
  } = {}) {
1984
1996
  return new Promise((t, s) => {
1985
1997
  try {
1986
1998
  const i = this.getIncomingRTCSession(), r = this.remoteCallerData;
1987
- this.removeIncomingSession(), this.events.trigger(D.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
1999
+ this.removeIncomingSession(), this.events.trigger(b.DECLINED_INCOMING_CALL, r), i.terminate({ status_code: e }), t();
1988
2000
  } catch (i) {
1989
2001
  s(i);
1990
2002
  }
1991
2003
  });
1992
2004
  }
1993
2005
  async busyIncomingCall() {
1994
- return this.declineToIncomingCall({ statusCode: Oe });
2006
+ return this.declineToIncomingCall({ statusCode: We });
1995
2007
  }
1996
2008
  // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
1997
2009
  on(e, t) {
@@ -2022,39 +2034,331 @@ class De {
2022
2034
  originator: e,
2023
2035
  session: t
2024
2036
  }) => {
2025
- e === $.REMOTE && this.setIncomingSession(t);
2037
+ e === V.REMOTE && this.setIncomingSession(t);
2026
2038
  };
2027
2039
  setIncomingSession(e) {
2028
2040
  this.incomingRTCSession = e;
2029
2041
  const t = this.remoteCallerData;
2030
2042
  e.on("failed", (s) => {
2031
- this.removeIncomingSession(), s.originator === $.LOCAL ? this.events.trigger(D.TERMINATED_INCOMING_CALL, t) : this.events.trigger(D.FAILED_INCOMING_CALL, t);
2032
- }), this.events.trigger(D.INCOMING_CALL, t);
2043
+ this.removeIncomingSession(), s.originator === V.LOCAL ? this.events.trigger(b.TERMINATED_INCOMING_CALL, t) : this.events.trigger(b.FAILED_INCOMING_CALL, t);
2044
+ }), this.events.trigger(b.INCOMING_CALL, t);
2033
2045
  }
2034
2046
  removeIncomingSession() {
2035
2047
  delete this.incomingRTCSession;
2036
2048
  }
2037
2049
  }
2038
- const ve = z.map((n) => `connection:${n}`), ye = G.map((n) => `call:${n}`), Ue = q.map((n) => `api:${n}`), be = J.map((n) => `incoming-call:${n}`), we = Y.map((n) => `presentation:${n}`), Le = [
2039
- ...ve,
2040
- ...ye,
2041
- ...Ue,
2042
- ...be,
2043
- ...we
2050
+ const D = 1e3;
2051
+ var E = /* @__PURE__ */ ((n) => (n.INBOUND_RTP = "inbound-rtp", n.REMOTE_OUTBOUND_RTP = "remote-outbound-rtp", n.MEDIA_SOURCE = "media-source", n.OUTBOUND_RTP = "outbound-rtp", n.REMOTE_INBOUND_RTP = "remote-inbound-rtp", n.CODEC = "codec", n.CANDIDATE_PAIR = "candidate-pair", n.CERTIFICATE = "certificate", n.TRANSPORT = "transport", n.LOCAL_CANDIDATE = "local-candidate", n.REMOTE_CANDIDATE = "remote-candidate", n))(E || {});
2052
+ const se = ["collected"], H = () => "performance" in window ? performance.now() : Date.now(), U = (n) => [...n.keys()].reduce((e, t) => {
2053
+ const s = n.get(t);
2054
+ return s === void 0 ? e : { ...e, [s.type]: s };
2055
+ }, {}), Ge = (n) => {
2056
+ if (!n)
2057
+ return {
2058
+ outboundRtp: void 0,
2059
+ codec: void 0,
2060
+ mediaSource: void 0,
2061
+ remoteInboundRtp: void 0
2062
+ };
2063
+ const e = U(n);
2064
+ return {
2065
+ outboundRtp: e[E.OUTBOUND_RTP],
2066
+ codec: e[E.CODEC],
2067
+ mediaSource: e[E.MEDIA_SOURCE],
2068
+ remoteInboundRtp: e[E.REMOTE_INBOUND_RTP]
2069
+ };
2070
+ }, q = (n) => {
2071
+ if (!n)
2072
+ return {
2073
+ outboundRtp: void 0,
2074
+ codec: void 0,
2075
+ mediaSource: void 0,
2076
+ remoteInboundRtp: void 0
2077
+ };
2078
+ const e = U(n);
2079
+ return {
2080
+ outboundRtp: e[E.OUTBOUND_RTP],
2081
+ codec: e[E.CODEC],
2082
+ mediaSource: e[E.MEDIA_SOURCE],
2083
+ remoteInboundRtp: e[E.REMOTE_INBOUND_RTP]
2084
+ };
2085
+ }, x = ({
2086
+ videoReceiversStats: n,
2087
+ synchronizationSourcesVideo: e
2088
+ }) => {
2089
+ if (!n)
2090
+ return {
2091
+ inboundRtp: void 0,
2092
+ codec: void 0,
2093
+ synchronizationSources: e
2094
+ };
2095
+ const t = U(n);
2096
+ return {
2097
+ inboundRtp: t[E.INBOUND_RTP],
2098
+ codec: t[E.CODEC],
2099
+ synchronizationSources: e
2100
+ };
2101
+ }, He = ({
2102
+ audioReceiverStats: n,
2103
+ synchronizationSourcesAudio: e
2104
+ }) => {
2105
+ if (!n)
2106
+ return {
2107
+ inboundRtp: void 0,
2108
+ codec: void 0,
2109
+ remoteOutboundRtp: void 0,
2110
+ synchronizationSources: e
2111
+ };
2112
+ const t = U(n);
2113
+ return {
2114
+ inboundRtp: t[E.INBOUND_RTP],
2115
+ codec: t[E.CODEC],
2116
+ remoteOutboundRtp: t[E.REMOTE_OUTBOUND_RTP],
2117
+ synchronizationSources: e
2118
+ };
2119
+ }, ie = (n) => {
2120
+ if (!n)
2121
+ return {
2122
+ candidatePair: void 0,
2123
+ certificate: void 0,
2124
+ localCandidate: void 0,
2125
+ remoteCandidate: void 0,
2126
+ transport: void 0
2127
+ };
2128
+ const e = U(n);
2129
+ return {
2130
+ candidatePair: e[E.CANDIDATE_PAIR],
2131
+ certificate: e[E.CERTIFICATE],
2132
+ localCandidate: e[E.LOCAL_CANDIDATE],
2133
+ remoteCandidate: e[E.REMOTE_CANDIDATE],
2134
+ transport: e[E.TRANSPORT]
2135
+ };
2136
+ }, qe = ({
2137
+ audioSenderStats: n,
2138
+ videoSenderFirstStats: e,
2139
+ videoSenderSecondStats: t
2140
+ }) => ({
2141
+ video: q(e),
2142
+ secondVideo: q(t),
2143
+ audio: Ge(n),
2144
+ additional: ie(
2145
+ n ?? e ?? t
2146
+ )
2147
+ }), xe = ({
2148
+ audioReceiverStats: n,
2149
+ videoReceiverFirstStats: e,
2150
+ videoReceiverSecondStats: t,
2151
+ synchronizationSources: s
2152
+ }) => ({
2153
+ video: x({
2154
+ videoReceiversStats: e,
2155
+ synchronizationSourcesVideo: s.video
2156
+ }),
2157
+ secondVideo: x({
2158
+ videoReceiversStats: t,
2159
+ synchronizationSourcesVideo: s.video
2160
+ }),
2161
+ audio: He({
2162
+ audioReceiverStats: n,
2163
+ synchronizationSourcesAudio: s.audio
2164
+ }),
2165
+ additional: ie(
2166
+ n ?? e ?? t
2167
+ )
2168
+ }), Ye = ({
2169
+ audioSenderStats: n,
2170
+ videoSenderFirstStats: e,
2171
+ videoSenderSecondStats: t,
2172
+ audioReceiverStats: s,
2173
+ videoReceiverFirstStats: i,
2174
+ videoReceiverSecondStats: r,
2175
+ synchronizationSources: a
2176
+ }) => {
2177
+ const o = qe({
2178
+ audioSenderStats: n,
2179
+ videoSenderFirstStats: e,
2180
+ videoSenderSecondStats: t
2181
+ }), c = xe({
2182
+ audioReceiverStats: s,
2183
+ videoReceiverFirstStats: i,
2184
+ videoReceiverSecondStats: r,
2185
+ synchronizationSources: a
2186
+ });
2187
+ return {
2188
+ outbound: o,
2189
+ inbound: c
2190
+ };
2191
+ }, ze = async (n) => {
2192
+ const e = "audio", t = "video", s = n.getSenders(), i = s.find((d) => d.track?.kind === e), r = s.filter((d) => d.track?.kind === t), a = n.getReceivers(), o = a.find((d) => d.track.kind === e), c = a.filter((d) => d.track.kind === t), g = {
2193
+ trackIdentifier: o?.track.id,
2194
+ item: o?.getSynchronizationSources()[0]
2195
+ }, l = {
2196
+ trackIdentifier: c[0]?.track.id,
2197
+ item: c[0]?.getSynchronizationSources()[0]
2198
+ }, u = {
2199
+ audio: g,
2200
+ video: l
2201
+ };
2202
+ return Promise.all([
2203
+ i?.getStats(),
2204
+ r[0]?.getStats(),
2205
+ r[1]?.getStats(),
2206
+ o?.getStats(),
2207
+ c[0]?.getStats(),
2208
+ c[1]?.getStats()
2209
+ ]).then((d) => {
2210
+ const [
2211
+ S,
2212
+ _,
2213
+ C,
2214
+ p,
2215
+ v,
2216
+ re
2217
+ ] = d;
2218
+ return {
2219
+ synchronizationSources: u,
2220
+ audioSenderStats: S,
2221
+ videoSenderFirstStats: _,
2222
+ videoSenderSecondStats: C,
2223
+ audioReceiverStats: p,
2224
+ videoReceiverFirstStats: v,
2225
+ videoReceiverSecondStats: re
2226
+ };
2227
+ });
2228
+ }, Qe = (n) => {
2229
+ P(String(n));
2230
+ };
2231
+ class Xe {
2232
+ events;
2233
+ setTimeoutRequest;
2234
+ requesterAllStatistics = new oe(ze);
2235
+ constructor() {
2236
+ this.events = new ae(se), this.setTimeoutRequest = new Te();
2237
+ }
2238
+ get requested() {
2239
+ return this.setTimeoutRequest.requested;
2240
+ }
2241
+ start(e, {
2242
+ interval: t = D,
2243
+ onError: s = Qe
2244
+ } = {}) {
2245
+ const i = this.resolveCollectStatistics(e, {
2246
+ onError: s
2247
+ });
2248
+ this.stop(), this.setTimeoutRequest.request(i, t);
2249
+ }
2250
+ stop() {
2251
+ this.setTimeoutRequest.cancelRequest(), this.requesterAllStatistics.cancelRequest();
2252
+ }
2253
+ on(e, t) {
2254
+ return this.events.on(e, t);
2255
+ }
2256
+ once(e, t) {
2257
+ return this.events.once(e, t);
2258
+ }
2259
+ onceRace(e, t) {
2260
+ return this.events.onceRace(e, t);
2261
+ }
2262
+ async wait(e) {
2263
+ return this.events.wait(e);
2264
+ }
2265
+ off(e, t) {
2266
+ this.events.off(e, t);
2267
+ }
2268
+ resolveCollectStatistics = (e, {
2269
+ onError: t
2270
+ }) => () => {
2271
+ const s = H();
2272
+ this.requesterAllStatistics.request(e).then((i) => {
2273
+ this.events.trigger("collected", Ye(i));
2274
+ const a = H() - s;
2275
+ let o = D;
2276
+ a > 48 ? o = D * 4 : a > 32 ? o = D * 3 : a > 16 && (o = D * 2), this.start(e, {
2277
+ onError: t,
2278
+ interval: o
2279
+ });
2280
+ }).catch((i) => {
2281
+ t && t(i);
2282
+ });
2283
+ };
2284
+ }
2285
+ class Je {
2286
+ availableIncomingBitrate;
2287
+ statsPeerConnection;
2288
+ callManager;
2289
+ apiManager;
2290
+ previousAvailableIncomingBitrate;
2291
+ constructor({
2292
+ callManager: e,
2293
+ apiManager: t
2294
+ }) {
2295
+ this.callManager = e, this.apiManager = t, this.statsPeerConnection = new Xe(), this.subscribe();
2296
+ }
2297
+ get events() {
2298
+ return this.statsPeerConnection.events;
2299
+ }
2300
+ on(e, t) {
2301
+ return this.statsPeerConnection.on(e, t);
2302
+ }
2303
+ once(e, t) {
2304
+ return this.statsPeerConnection.once(e, t);
2305
+ }
2306
+ onceRace(e, t) {
2307
+ return this.statsPeerConnection.onceRace(e, t);
2308
+ }
2309
+ async wait(e) {
2310
+ return this.statsPeerConnection.wait(e);
2311
+ }
2312
+ off(e, t) {
2313
+ this.statsPeerConnection.off(e, t);
2314
+ }
2315
+ hasAvailableIncomingBitrateChangedQuarter() {
2316
+ const e = this.previousAvailableIncomingBitrate, t = this.availableIncomingBitrate;
2317
+ return e === void 0 || t === void 0 ? !1 : e === 0 ? t > 0 : Math.abs(t - e) / e >= 0.25;
2318
+ }
2319
+ subscribe() {
2320
+ this.callManager.on("peerconnection:confirmed", this.handleStarted), this.callManager.on("failed", this.handleEnded), this.callManager.on("ended", this.handleEnded), this.statsPeerConnection.on("collected", this.handleStatsCollected);
2321
+ }
2322
+ handleStatsCollected = (e) => {
2323
+ this.previousAvailableIncomingBitrate = this.availableIncomingBitrate, this.availableIncomingBitrate = e.inbound.additional.candidatePair?.availableIncomingBitrate, this.maybeSendStats();
2324
+ };
2325
+ handleStarted = (e) => {
2326
+ this.statsPeerConnection.start(e);
2327
+ };
2328
+ handleEnded = () => {
2329
+ this.statsPeerConnection.stop(), this.availableIncomingBitrate = void 0, this.previousAvailableIncomingBitrate = void 0;
2330
+ };
2331
+ maybeSendStats() {
2332
+ this.availableIncomingBitrate !== void 0 && this.hasAvailableIncomingBitrateChangedQuarter() && this.apiManager.sendStats({ availableIncomingBitrate: this.availableIncomingBitrate }).catch((e) => {
2333
+ P("Failed to send stats", e);
2334
+ });
2335
+ }
2336
+ }
2337
+ const je = ee.map((n) => `connection:${n}`), Ke = Q.map((n) => `call:${n}`), Ze = j.map((n) => `api:${n}`), et = ne.map((n) => `incoming-call:${n}`), tt = K.map((n) => `presentation:${n}`), nt = se.map((n) => `stats:${n}`), st = [
2338
+ ...je,
2339
+ ...Ke,
2340
+ ...Ze,
2341
+ ...et,
2342
+ ...tt,
2343
+ ...nt
2044
2344
  ];
2045
- class xe {
2345
+ class Et {
2046
2346
  events;
2047
2347
  connectionManager;
2048
2348
  callManager;
2049
2349
  apiManager;
2050
2350
  incomingCallManager;
2051
2351
  presentationManager;
2352
+ statsManager;
2052
2353
  constructor({ JsSIP: e }) {
2053
- this.events = new O(Le), this.connectionManager = new me({ JsSIP: e }), this.callManager = new ge(), this.apiManager = new le({
2354
+ this.events = new f(st), this.connectionManager = new ke({ JsSIP: e }), this.callManager = new _e(), this.apiManager = new Oe({
2054
2355
  connectionManager: this.connectionManager,
2055
2356
  callManager: this.callManager
2056
- }), this.incomingCallManager = new De(this.connectionManager), this.presentationManager = new Ne({
2357
+ }), this.incomingCallManager = new Be(this.connectionManager), this.presentationManager = new ve({
2057
2358
  callManager: this.callManager
2359
+ }), this.statsManager = new Je({
2360
+ callManager: this.callManager,
2361
+ apiManager: this.apiManager
2058
2362
  }), this.subscribe();
2059
2363
  }
2060
2364
  get requestedConnection() {
@@ -2156,7 +2460,7 @@ class xe {
2156
2460
  async stopPresentation(e = {}) {
2157
2461
  const { isP2P: t } = e;
2158
2462
  return this.presentationManager.stopPresentation(async () => {
2159
- t === !0 ? await this.apiManager.sendMustStopPresentationP2P() : await this.apiManager.sendStoppedPresentation();
2463
+ await (t === !0 ? this.apiManager.sendMustStopPresentationP2P() : this.apiManager.sendStoppedPresentation());
2160
2464
  });
2161
2465
  }
2162
2466
  async updatePresentation(e, t = {}) {
@@ -2232,17 +2536,24 @@ class xe {
2232
2536
  this.presentationManager.on(t, (s) => {
2233
2537
  this.events.trigger(`presentation:${t}`, s);
2234
2538
  });
2539
+ }), this.statsManager.events.eachTriggers((e, t) => {
2540
+ this.statsManager.on(t, (s) => {
2541
+ this.events.trigger(`stats:${t}`, s);
2542
+ });
2235
2543
  });
2236
2544
  }
2237
2545
  }
2238
2546
  export {
2239
- x as E,
2240
- b as O,
2241
- xe as S,
2242
- f as a,
2243
- Se as b,
2244
- Ge as d,
2245
- He as e,
2246
- Be as h,
2247
- m as l
2547
+ J as E,
2548
+ $ as O,
2549
+ Et as S,
2550
+ y as a,
2551
+ Pe as b,
2552
+ E as c,
2553
+ lt as d,
2554
+ ht as e,
2555
+ Xe as f,
2556
+ St as h,
2557
+ P as l,
2558
+ w as p
2248
2559
  };