sip-connector 6.22.0 → 6.22.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.
package/dist/index.js CHANGED
@@ -1,137 +1,138 @@
1
- import { l as c, B as x, N as V, E as P, s as z, S as en } from "./SipConnector-_AhwhWtL.js";
2
- import { f as un, g as ln, i as Sn, c as dn, a as mn, d as fn, b as Cn, e as En, h as gn } from "./SipConnector-_AhwhWtL.js";
1
+ import { l as o, B as V, N as $, E as B, s as z, S as Ye } from "./SipConnector-Hg44qtgr.js";
2
+ import { f as sn, g as rn, i as on, c as an, a as cn, d as un, b as ln, e as Sn, h as mn } from "./SipConnector-Hg44qtgr.js";
3
3
  import { debounce as q } from "ts-debounce";
4
4
  import { isCanceledError as J } from "@krivega/cancelable-promise";
5
- import { default as hn } from "debug";
5
+ import Q from "stack-promises";
6
+ import { default as fn } from "debug";
6
7
  import "events-constructor";
7
- const $ = "purgatory", A = (e) => e === $, B = (e) => () => (c("getRemoteStreams"), e.getRemoteStreams()), Q = ({ kind: e, readyState: n }) => e === "video" && n === "live", G = (e) => ({ track: n }) => {
8
- Q(n) && e();
9
- }, k = ({
8
+ const x = "purgatory", A = (e) => e === x, w = (e) => () => (o("getRemoteStreams"), e.getRemoteStreams()), Z = ({ kind: e, readyState: n }) => e === "video" && n === "live", G = (e) => ({ track: n }) => {
9
+ Z(n) && e();
10
+ }, D = ({
10
11
  getRemoteStreams: e,
11
12
  setRemoteStreams: n
12
13
  }) => q(() => {
13
14
  const t = e();
14
- c("remoteStreams", t), t && n(t);
15
- }, 200), Z = (e) => async (t) => {
15
+ o("remoteStreams", t), t && n(t);
16
+ }, 200), ee = (e) => async (t) => {
16
17
  const {
17
18
  mediaStream: s,
18
19
  extraHeaders: r,
19
- iceServers: o,
20
- degradationPreference: a,
21
- setRemoteStreams: u,
22
- onBeforeProgressCall: m,
23
- onSuccessProgressCall: E,
24
- onEnterPurgatory: C,
25
- onEnterConference: f,
26
- onFailProgressCall: T,
27
- onFinishProgressCall: h,
28
- onEndedCall: y
29
- } = t, g = k({
30
- setRemoteStreams: u,
31
- getRemoteStreams: B(e)
32
- }), _ = G(g);
33
- c("answerIncomingCall", t);
34
- const v = async () => e.answerToIncomingCall({
20
+ iceServers: a,
21
+ degradationPreference: c,
22
+ setRemoteStreams: i,
23
+ onBeforeProgressCall: u,
24
+ onSuccessProgressCall: m,
25
+ onEnterPurgatory: d,
26
+ onEnterConference: l,
27
+ onFailProgressCall: R,
28
+ onFinishProgressCall: f,
29
+ onEndedCall: C
30
+ } = t, g = D({
31
+ setRemoteStreams: i,
32
+ getRemoteStreams: w(e)
33
+ }), y = G(g);
34
+ o("answerIncomingCall", t);
35
+ const h = async () => e.answerToIncomingCall({
35
36
  mediaStream: s,
36
37
  extraHeaders: r,
37
- iceServers: o,
38
- degradationPreference: a,
39
- ontrack: _
40
- }), p = () => {
41
- const { remoteCallerData: d } = e;
42
- return d.incomingNumber;
38
+ iceServers: a,
39
+ degradationPreference: c,
40
+ ontrack: y
41
+ }), b = () => {
42
+ const { remoteCallerData: S } = e;
43
+ return S.incomingNumber;
43
44
  };
44
- let M = !1, i;
45
- const l = (c("subscribeEnterConference: onEnterConference", f), C ?? f ? e.onSession("enterRoom", (d) => {
46
- c("enterRoom", { _room: d, isSuccessProgressCall: M }), i = d, A(i) ? C && C() : f && f({ isSuccessProgressCall: M });
45
+ let T = !1, M;
46
+ const _ = (o("subscribeEnterConference: onEnterConference", l), d ?? l ? e.onSession("enterRoom", (S) => {
47
+ o("enterRoom", { _room: S, isSuccessProgressCall: T }), M = S, A(M) ? d && d() : l && l({ isSuccessProgressCall: T });
47
48
  }) : () => {
48
- }), R = (d) => (c("onSuccess"), M = !0, g(), E && E({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
49
- l(), y && y();
50
- }), d), b = (d) => {
51
- throw c("onFail"), T && T(), l(), d;
52
- }, O = () => {
53
- c("onFinish"), h && h();
49
+ }), O = (S) => (o("onSuccess"), T = !0, g(), m && m({ isPurgatory: A(M) }), e.onceRaceSession(["ended", "failed"], () => {
50
+ _(), C && C();
51
+ }), S), N = (S) => {
52
+ throw o("onFail"), R && R(), _(), S;
53
+ }, v = () => {
54
+ o("onFinish"), f && f();
54
55
  };
55
- if (c("onBeforeProgressCall"), m) {
56
- const d = p();
57
- m(d);
56
+ if (o("onBeforeProgressCall"), u) {
57
+ const S = b();
58
+ u(S);
58
59
  }
59
- return v().then(R).catch(b).finally(O);
60
- }, ee = (e) => async (t) => {
60
+ return h().then(O).catch(N).finally(v);
61
+ }, ne = (e) => async (t) => {
61
62
  const {
62
63
  conference: s,
63
64
  mediaStream: r,
64
- extraHeaders: o,
65
- iceServers: a,
66
- degradationPreference: u,
67
- setRemoteStreams: m,
68
- onBeforeProgressCall: E,
69
- onSuccessProgressCall: C,
70
- onEnterPurgatory: f,
71
- onEnterConference: T,
72
- onFailProgressCall: h,
73
- onFinishProgressCall: y,
65
+ extraHeaders: a,
66
+ iceServers: c,
67
+ degradationPreference: i,
68
+ setRemoteStreams: u,
69
+ onBeforeProgressCall: m,
70
+ onSuccessProgressCall: d,
71
+ onEnterPurgatory: l,
72
+ onEnterConference: R,
73
+ onFailProgressCall: f,
74
+ onFinishProgressCall: C,
74
75
  onEndedCall: g
75
- } = t, _ = k({
76
- setRemoteStreams: m,
77
- getRemoteStreams: B(e)
78
- }), v = G(_);
79
- c("callToServer", t);
80
- const p = async () => (c("startCall"), e.call({
76
+ } = t, y = D({
77
+ setRemoteStreams: u,
78
+ getRemoteStreams: w(e)
79
+ }), h = G(y);
80
+ o("callToServer", t);
81
+ const b = async () => (o("startCall"), e.call({
81
82
  mediaStream: r,
82
- extraHeaders: o,
83
- iceServers: a,
84
- degradationPreference: u,
83
+ extraHeaders: a,
84
+ iceServers: c,
85
+ degradationPreference: i,
85
86
  number: s,
86
- ontrack: v
87
+ ontrack: h
87
88
  }));
88
- let M = !1, i;
89
- const l = (c("subscribeEnterConference: onEnterConference", T), f ?? T ? e.onSession("enterRoom", (d) => {
90
- c("enterRoom", { _room: d, isSuccessProgressCall: M }), i = d, A(i) ? f && f() : T && T({ isSuccessProgressCall: M });
89
+ let T = !1, M;
90
+ const _ = (o("subscribeEnterConference: onEnterConference", R), l ?? R ? e.onSession("enterRoom", (S) => {
91
+ o("enterRoom", { _room: S, isSuccessProgressCall: T }), M = S, A(M) ? l && l() : R && R({ isSuccessProgressCall: T });
91
92
  }) : () => {
92
- }), R = (d) => (c("onSuccess"), M = !0, _(), C && C({ isPurgatory: A(i) }), e.onceRaceSession(["ended", "failed"], () => {
93
- l(), g && g();
94
- }), d), b = (d) => {
95
- throw c("onFail"), h && h(), l(), d;
96
- }, O = () => {
97
- c("onFinish"), y && y();
93
+ }), O = (S) => (o("onSuccess"), T = !0, y(), d && d({ isPurgatory: A(M) }), e.onceRaceSession(["ended", "failed"], () => {
94
+ _(), g && g();
95
+ }), S), N = (S) => {
96
+ throw o("onFail"), f && f(), _(), S;
97
+ }, v = () => {
98
+ o("onFinish"), C && C();
98
99
  };
99
- return c("onBeforeProgressCall"), E && E(s), p().then(R).catch(b).finally(O);
100
- }, w = (e) => {
100
+ return o("onBeforeProgressCall"), m && m(s), b().then(O).catch(N).finally(v);
101
+ }, P = (e) => {
101
102
  if (!J(e))
102
103
  throw e;
103
104
  return !1;
104
- }, ne = (e) => async (t) => {
105
+ }, te = (e) => async (t) => {
105
106
  const {
106
107
  userAgent: s,
107
108
  sipWebSocketServerURL: r,
108
- sipServerUrl: o,
109
- remoteAddress: a,
110
- displayName: u,
111
- name: m,
112
- password: E,
113
- isRegisteredUser: C,
114
- sdpSemantics: f,
115
- isDisconnectOnFail: T
109
+ sipServerUrl: a,
110
+ remoteAddress: c,
111
+ displayName: i,
112
+ name: u,
113
+ password: m,
114
+ isRegisteredUser: d,
115
+ sdpSemantics: l,
116
+ isDisconnectOnFail: R
116
117
  } = t;
117
- return c("connectToServer", t), e.connect({
118
+ return o("connectToServer", t), e.connect({
118
119
  userAgent: s,
119
- sdpSemantics: f,
120
+ sdpSemantics: l,
120
121
  sipWebSocketServerURL: r,
121
- sipServerUrl: o,
122
- remoteAddress: a,
123
- displayName: u,
124
- password: E,
125
- user: m,
126
- register: C
127
- }).then(() => (c("connectToServer then"), !0)).catch(async (h) => (c("connectToServer catch: error", h), T === !0 ? e.disconnect().then(() => w(h)).catch(() => w(h)) : w(h)));
128
- }, te = (e) => async () => (c("disconnectFromServer"), e.disconnect().then(() => (c("disconnectFromServer: then"), !1)).catch((n) => (c("disconnectFromServer: catch", n), !1))), D = (e) => {
122
+ sipServerUrl: a,
123
+ remoteAddress: c,
124
+ displayName: i,
125
+ password: m,
126
+ user: u,
127
+ register: d
128
+ }).then(() => (o("connectToServer then"), !0)).catch(async (f) => (o("connectToServer catch: error", f), R === !0 ? e.disconnect().then(() => P(f)).catch(() => P(f)) : P(f)));
129
+ }, se = (e) => async () => (o("disconnectFromServer"), e.disconnect().then(() => (o("disconnectFromServer: then"), !1)).catch((n) => (o("disconnectFromServer: catch", n), !1))), F = (e) => {
129
130
  const { url: n, cause: t } = e;
130
131
  let s = n;
131
- return (t === x || t === V) && (s = `${e.message.to.uri.user}@${e.message.to.uri.host}`), s;
132
+ return (t === V || t === $) && (s = `${e.message.to.uri.user}@${e.message.to.uri.host}`), s;
132
133
  };
133
- var j = /* @__PURE__ */ ((e) => (e.CONNECT_SERVER_FAILED = "CONNECT_SERVER_FAILED", e.WRONG_USER_OR_PASSWORD = "WRONG_USER_OR_PASSWORD", e.BAD_MEDIA_ERROR = "BAD_MEDIA_ERROR", e.NOT_FOUND_ERROR = "NOT_FOUND_ERROR", e.WS_CONNECTION_FAILED = "WS_CONNECTION_FAILED", e.CONNECT_SERVER_FAILED_BY_LINK = "CONNECT_SERVER_FAILED_BY_LINK", e))(j || {});
134
- const se = (e = new Error()) => {
134
+ var X = /* @__PURE__ */ ((e) => (e.CONNECT_SERVER_FAILED = "CONNECT_SERVER_FAILED", e.WRONG_USER_OR_PASSWORD = "WRONG_USER_OR_PASSWORD", e.BAD_MEDIA_ERROR = "BAD_MEDIA_ERROR", e.NOT_FOUND_ERROR = "NOT_FOUND_ERROR", e.WS_CONNECTION_FAILED = "WS_CONNECTION_FAILED", e.CONNECT_SERVER_FAILED_BY_LINK = "CONNECT_SERVER_FAILED_BY_LINK", e))(X || {});
135
+ const re = (e = new Error()) => {
135
136
  var r;
136
137
  const { cause: n, socket: t } = e;
137
138
  let s = "CONNECT_SERVER_FAILED";
@@ -140,38 +141,38 @@ const se = (e = new Error()) => {
140
141
  s = "WRONG_USER_OR_PASSWORD";
141
142
  break;
142
143
  }
143
- case x: {
144
+ case V: {
144
145
  s = "BAD_MEDIA_ERROR";
145
146
  break;
146
147
  }
147
- case V: {
148
+ case $: {
148
149
  s = "NOT_FOUND_ERROR";
149
150
  break;
150
151
  }
151
152
  default:
152
- t && ((r = t == null ? void 0 : t._ws) == null ? void 0 : r.readyState) === 3 ? s = "WS_CONNECTION_FAILED" : D(e) && (s = "CONNECT_SERVER_FAILED_BY_LINK");
153
+ t && ((r = t == null ? void 0 : t._ws) == null ? void 0 : r.readyState) === 3 ? s = "WS_CONNECTION_FAILED" : F(e) && (s = "CONNECT_SERVER_FAILED_BY_LINK");
153
154
  }
154
155
  return s;
155
- }, re = (e = new Error()) => {
156
- const { code: n, cause: t, message: s } = e, r = D(e), o = {};
157
- return s && (o.message = s), r && (o.link = r), n && (o.code = n), t && (o.cause = t), o;
158
- }, oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
156
+ }, oe = (e = new Error()) => {
157
+ const { code: n, cause: t, message: s } = e, r = F(e), a = {};
158
+ return s && (a.message = s), r && (a.link = r), n && (a.code = n), t && (a.cause = t), a;
159
+ }, ae = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
159
160
  __proto__: null,
160
- EErrorTypes: j,
161
- getLinkError: D,
162
- getTypeFromError: se,
163
- getValuesFromError: re
161
+ EErrorTypes: X,
162
+ getLinkError: F,
163
+ getTypeFromError: re,
164
+ getValuesFromError: oe
164
165
  }, Symbol.toStringTag, { value: "Module" })), ce = ({
165
166
  sessionId: e,
166
167
  remoteAddress: n,
167
168
  isMutedAudio: t,
168
169
  isMutedVideo: s,
169
170
  isRegistered: r,
170
- isPresentationCall: o
171
+ isPresentationCall: a
171
172
  }) => {
172
- const a = [], u = t ? "0" : "1", m = s ? "0" : "1";
173
- return a.push(`X-Vinteo-Mic-State: ${u}`, `X-Vinteo-MainCam-State: ${m}`), r || a.push("X-Vinteo-Purgatory-Call: yes"), e && a.push(`X-Vinteo-Session: ${e}`), o && a.push("X-Vinteo-Presentation-Call: yes"), n && a.push(`X-Vinteo-Remote: ${n}`), a;
174
- }, ae = ({
173
+ const c = [], i = t ? "0" : "1", u = s ? "0" : "1";
174
+ return c.push(`X-Vinteo-Mic-State: ${i}`, `X-Vinteo-MainCam-State: ${u}`), r || c.push("X-Vinteo-Purgatory-Call: yes"), e && c.push(`X-Vinteo-Session: ${e}`), a && c.push("X-Vinteo-Presentation-Call: yes"), n && c.push(`X-Vinteo-Remote: ${n}`), c;
175
+ }, ie = ({
175
176
  appName: e,
176
177
  appVersion: n,
177
178
  browserName: t,
@@ -179,65 +180,65 @@ const se = (e = new Error()) => {
179
180
  }) => {
180
181
  const r = `${e} ${n}`;
181
182
  return `ChromeNew - ${t ? `${t} ${s}, ${r}` : r}`;
182
- }, ie = ({
183
+ }, ue = ({
183
184
  isUnifiedSdpSemantic: e,
184
185
  appVersion: n,
185
186
  browserName: t,
186
187
  browserVersion: s,
187
188
  appName: r
188
- }) => e ? ae({ appVersion: n, browserName: t, browserVersion: s, appName: r }) : "Chrome", ue = (e) => async () => {
189
+ }) => e ? ie({ appVersion: n, browserName: t, browserVersion: s, appName: r }) : "Chrome", le = (e) => async () => {
189
190
  if (e.isCallActive)
190
- return c("askPermissionToEnableCam"), e.askPermissionToEnableCam();
191
- }, le = (e) => (t) => (c("onMustStopPresentation"), e.onSession("mustStopPresentation", t)), Se = (e) => (t) => (c("onUseLicense"), e.onSession("useLicense", t)), de = (e) => async ({
191
+ return o("askPermissionToEnableCam"), e.askPermissionToEnableCam();
192
+ }, Se = (e) => (t) => (o("onMustStopPresentation"), e.onSession("mustStopPresentation", t)), me = (e) => (t) => (o("onUseLicense"), e.onSession("useLicense", t)), de = (e) => async ({
192
193
  isEnabledCam: t,
193
194
  isEnabledMic: s
194
195
  }) => {
195
196
  if (e.isCallActive)
196
- return c("sendMediaState"), e.sendMediaState({ cam: t, mic: s });
197
- }, me = (e) => async () => {
197
+ return o("sendMediaState"), e.sendMediaState({ cam: t, mic: s });
198
+ }, fe = (e) => async () => {
198
199
  if (e.isCallActive)
199
- return c("sendRefusalToTurnOnCam"), e.sendRefusalToTurnOnCam().catch((t) => {
200
- c("sendRefusalToTurnOnCam: error", t);
200
+ return o("sendRefusalToTurnOnCam"), e.sendRefusalToTurnOnCam().catch((t) => {
201
+ o("sendRefusalToTurnOnCam: error", t);
201
202
  });
202
- }, fe = (e) => async () => {
203
+ }, Ce = (e) => async () => {
203
204
  if (e.isCallActive)
204
- return c("sendRefusalToTurnOnMic"), e.sendRefusalToTurnOnMic().catch((t) => {
205
- c("sendRefusalToTurnOnMic: error", t);
205
+ return o("sendRefusalToTurnOnMic"), e.sendRefusalToTurnOnMic().catch((t) => {
206
+ o("sendRefusalToTurnOnMic: error", t);
206
207
  });
207
- }, Ce = 1e6, Ee = ({
208
- maxBitrate: e = Ce,
208
+ }, Re = 1e6, Ee = ({
209
+ maxBitrate: e = Re,
209
210
  sipConnector: n
210
211
  }) => async ({
211
212
  mediaStream: s,
212
213
  isP2P: r = !1
213
- }) => (c("startPresentation"), n.startPresentation(s, {
214
+ }) => (o("startPresentation"), n.startPresentation(s, {
214
215
  isP2P: r,
215
216
  maxBitrate: e
216
- })), ge = ({ sipConnector: e }) => async ({ isP2P: t = !1 } = {}) => (c("stopShareSipConnector"), e.stopPresentation({
217
+ })), ge = ({ sipConnector: e }) => async ({ isP2P: t = !1 } = {}) => (o("stopShareSipConnector"), e.stopPresentation({
217
218
  isP2P: t
218
- }).catch(c)), Re = 1e6, he = ({
219
+ }).catch(o)), Te = 1e6, Me = ({
219
220
  sipConnector: e,
220
- maxBitrate: n = Re
221
+ maxBitrate: n = Te
221
222
  }) => async ({
222
223
  mediaStream: s,
223
224
  isP2P: r = !1
224
- }) => (c("updatePresentation"), e.updatePresentation(s, {
225
+ }) => (o("updatePresentation"), e.updatePresentation(s, {
225
226
  isP2P: r,
226
227
  maxBitrate: n
227
- })), ye = "ERROR_NOT_RUNNING", Te = (e) => {
228
+ })), ye = "ERROR_NOT_RUNNING", _e = (e) => {
228
229
  const n = new Error("Promise was not running");
229
230
  return n.basePromise = e, n.id = ye, n.name = "Not running", n;
230
- }, _e = async (e, n) => e.reduce(
231
- async (t, s) => t.then(async ({ success: r, errors: o, results: a }) => (!n || n(s) ? s() : Promise.reject(Te(s))).then((u) => ({
232
- errors: o,
233
- success: [...r, u],
234
- results: [...a, u],
231
+ }, he = async (e, n) => e.reduce(
232
+ async (t, s) => t.then(async ({ success: r, errors: a, results: c }) => (!n || n(s) ? s() : Promise.reject(_e(s))).then((i) => ({
233
+ errors: a,
234
+ success: [...r, i],
235
+ results: [...c, i],
235
236
  isSuccessful: !0,
236
237
  isError: !1
237
- })).catch((u) => ({
238
+ })).catch((i) => ({
238
239
  success: r,
239
- errors: [...o, u],
240
- results: [...a, u],
240
+ errors: [...a, i],
241
+ results: [...c, i],
241
242
  isSuccessful: !1,
242
243
  isError: !0
243
244
  }))),
@@ -248,246 +249,149 @@ const se = (e = new Error()) => {
248
249
  isSuccessful: !1,
249
250
  isError: !1
250
251
  })
251
- ), Me = (e) => (n) => [...n].map((s) => async () => e(s)), be = async ({
252
+ ), be = (e) => (n) => [...n].map((s) => async () => e(s)), Oe = async ({
252
253
  accumulatedKeys: e,
253
254
  sendKey: n,
254
255
  canRunTask: t
255
256
  }) => {
256
- const r = Me(n)(e);
257
- return _e(r, t);
258
- }, Ne = (e) => (t) => (c("onStartMainCam"), e.onSession("admin-start-main-cam", t)), Oe = (e) => (t) => (c("onStartMic"), e.onSession("admin-start-mic", t)), ve = (e) => (t) => (c("onStopMainCam"), e.onSession("admin-stop-main-cam", t)), pe = (e) => (t) => (c("onStopMic"), e.onSession("admin-stop-mic", t)), Ae = ({ sipConnector: e }) => {
259
- const n = (y, g) => ({ isSyncForced: _ = !1 }) => {
260
- if (_) {
261
- y();
257
+ const r = be(n)(e);
258
+ return he(r, t);
259
+ }, Ne = (e) => (t) => (o("onStartMainCam"), e.onSession("admin-start-main-cam", t)), ve = (e) => (t) => (o("onStartMic"), e.onSession("admin-start-mic", t)), Ae = (e) => (t) => (o("onStopMainCam"), e.onSession("admin-stop-main-cam", t)), pe = (e) => (t) => (o("onStopMic"), e.onSession("admin-stop-mic", t)), Be = ({ sipConnector: e }) => {
260
+ const n = (C, g) => ({ isSyncForced: y = !1 }) => {
261
+ if (y) {
262
+ C();
262
263
  return;
263
264
  }
264
265
  g();
265
- }, t = Ne(e), s = ve(e), r = Oe(e), o = pe(e);
266
- let a = () => {
266
+ }, t = Ne(e), s = Ae(e), r = ve(e), a = pe(e);
267
+ let c = () => {
268
+ }, i = () => {
267
269
  }, u = () => {
268
270
  }, m = () => {
269
- }, E = () => {
270
271
  };
271
- const C = ({
272
- onStartMainCamForced: y,
272
+ const d = ({
273
+ onStartMainCamForced: C,
273
274
  onStartMainCamNotForced: g,
274
- onStopMainCamForced: _,
275
- onStopMainCamNotForced: v,
276
- onStartMicForced: p,
277
- onStartMicNotForced: M,
278
- onStopMicForced: i,
279
- onStopMicNotForced: S
275
+ onStopMainCamForced: y,
276
+ onStopMainCamNotForced: h,
277
+ onStartMicForced: b,
278
+ onStartMicNotForced: T,
279
+ onStopMicForced: M,
280
+ onStopMicNotForced: p
280
281
  }) => {
281
- const l = n(
282
- y,
282
+ const _ = n(
283
+ C,
283
284
  g
284
285
  );
285
- a = t(l);
286
- const R = n(
287
- _,
288
- v
286
+ c = t(_);
287
+ const O = n(
288
+ y,
289
+ h
289
290
  );
290
- u = s(R);
291
- const b = n(p, M);
292
- m = r(b);
293
- const O = n(i, S);
294
- E = o(O);
295
- }, f = () => {
296
- a(), u(), m(), E();
291
+ i = s(O);
292
+ const N = n(b, T);
293
+ u = r(N);
294
+ const v = n(M, p);
295
+ m = a(v);
296
+ }, l = () => {
297
+ c(), i(), u(), m();
297
298
  };
298
299
  return {
299
- start: (y) => {
300
- C(y);
300
+ start: (C) => {
301
+ d(C);
301
302
  },
302
303
  stop: () => {
303
- f();
304
+ l();
304
305
  }
305
306
  };
306
- }, rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
307
+ }, Ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
307
308
  __proto__: null,
308
- PURGATORY_CONFERENCE_NUMBER: $,
309
- createSyncMediaState: Ae,
310
- error: oe,
309
+ PURGATORY_CONFERENCE_NUMBER: x,
310
+ createSyncMediaState: Be,
311
+ error: ae,
311
312
  getExtraHeaders: ce,
312
- getUserAgent: ie,
313
+ getUserAgent: ue,
313
314
  hasPurgatory: A,
314
- resolveAnswerIncomingCall: Z,
315
- resolveAskPermissionToEnableCam: ue,
316
- resolveCallToServer: ee,
317
- resolveConnectToServer: ne,
318
- resolveDisconnectFromServer: te,
319
- resolveGetRemoteStreams: B,
320
- resolveOnMustStopPresentation: le,
321
- resolveOnUseLicense: Se,
315
+ resolveAnswerIncomingCall: ee,
316
+ resolveAskPermissionToEnableCam: le,
317
+ resolveCallToServer: ne,
318
+ resolveConnectToServer: te,
319
+ resolveDisconnectFromServer: se,
320
+ resolveGetRemoteStreams: w,
321
+ resolveOnMustStopPresentation: Se,
322
+ resolveOnUseLicense: me,
322
323
  resolveSendMediaState: de,
323
- resolveSendRefusalToTurnOnCam: me,
324
- resolveSendRefusalToTurnOnMic: fe,
324
+ resolveSendRefusalToTurnOnCam: fe,
325
+ resolveSendRefusalToTurnOnMic: Ce,
325
326
  resolveStartPresentation: Ee,
326
327
  resolveStopShareSipConnector: ge,
327
- resolveUpdatePresentation: he,
328
- resolveUpdateRemoteStreams: k,
329
- sendDTMFAccumulated: be
330
- }, Symbol.toStringTag, { value: "Module" })), Pe = (e) => [...e.keys()].map((n) => e.get(n)), we = (e, n) => Pe(e).find((t) => t.type === n), Ie = async (e) => e.getStats().then((n) => {
331
- const t = we(n, "codec");
328
+ resolveUpdatePresentation: Me,
329
+ resolveUpdateRemoteStreams: D,
330
+ sendDTMFAccumulated: Oe
331
+ }, Symbol.toStringTag, { value: "Module" })), Pe = (e) => [...e.keys()].map((n) => e.get(n)), Ie = (e, n) => Pe(e).find((t) => t.type === n), we = async (e) => e.getStats().then((n) => {
332
+ const t = Ie(n, "codec");
332
333
  return t == null ? void 0 : t.mimeType;
333
- }), Be = (e) => e.find((n) => {
334
+ }), De = (e) => e.find((n) => {
334
335
  var t;
335
336
  return ((t = n == null ? void 0 : n.track) == null ? void 0 : t.kind) === "video";
336
- }), X = (e, n) => e !== void 0 && n !== void 0 && e.toLowerCase().includes(n.toLowerCase()), ke = "ERROR_NOT_RUNNING", De = (e) => {
337
- const n = new Error("Promise was not running");
338
- return n.basePromise = e, n.id = ke, n.name = "Not running", n;
339
- }, Fe = async (e, n) => e.reduce(
340
- async (t, s) => t.then(async ({ success: r, errors: o, results: a }) => (!n || n(s) ? s() : Promise.reject(De(s))).then((u) => ({
341
- errors: o,
342
- success: [...r, u],
343
- results: [...a, u],
344
- isSuccessful: !0,
345
- isError: !1
346
- })).catch((u) => ({
347
- success: r,
348
- errors: [...o, u],
349
- results: [...a, u],
350
- isSuccessful: !1,
351
- isError: !0
352
- }))),
353
- Promise.resolve({
354
- success: [],
355
- errors: [],
356
- results: [],
357
- isSuccessful: !1,
358
- isError: !1
359
- })
360
- ), Ue = new Error("Stack is empty"), Le = new Error("Promise is not actual"), xe = new Error(
361
- "stackPromises only works with functions that returns a Promise"
362
- ), Ve = ({
363
- noRejectIsNotActual: e = !1,
364
- noRunIsNotActual: n = !1
365
- } = {}) => {
366
- const t = [], s = [], r = ({ task: i, index: S }) => {
367
- s.push({ task: i, index: S });
368
- }, o = (i, { task: S, index: l }) => {
369
- const R = s.find(({ task: b, index: O }) => S === b && l === O);
370
- if (!R)
371
- throw new Error("Task not found");
372
- if (R.promise)
373
- throw new Error("Task is already running");
374
- R.promise = i;
375
- }, a = ({
376
- task: i,
377
- index: S
378
- }) => {
379
- const l = s.find(({ task: R, index: b }) => i === R && S === b);
380
- if (l)
381
- return l.promise;
382
- }, u = ({ task: i }) => {
383
- const S = s.at(-1);
384
- return (S == null ? void 0 : S.task) === i;
385
- }, m = ({ task: i, index: S }) => (r({ task: i, index: S }), async () => {
386
- let l = a({ task: i, index: S });
387
- const R = u({ task: i });
388
- return !l && n && !R ? Promise.resolve() : (l || (l = i({ isActual: R }), o(l, { task: i, index: S })), l);
389
- }), E = ({
390
- resolve: i,
391
- reject: S
392
- }) => ({ results: l, isSuccessful: R }) => {
393
- const b = l.length, O = t.length;
394
- if (b === O) {
395
- const d = l.at(-1);
396
- if (R) {
397
- i(d);
398
- return;
399
- }
400
- S(d);
401
- return;
402
- }
403
- if (e) {
404
- const d = l.at(-1);
405
- i(d);
406
- return;
407
- }
408
- S(Le);
409
- };
410
- let C = !1;
411
- const f = () => {
412
- C = !0;
413
- }, T = () => {
414
- C = !1;
415
- }, h = () => C, y = async () => (f(), Fe(t, h)), g = async () => {
416
- if (t.length === 0)
417
- throw Ue;
418
- return new Promise((i, S) => {
419
- const l = E({ resolve: i, reject: S });
420
- y().then(l).catch(l);
421
- });
422
- }, _ = (i) => {
423
- if (typeof i != "function")
424
- throw xe;
425
- const S = t.length;
426
- return t.push(m({ task: i, index: S })), g;
427
- }, v = async (i) => (_(i), g()), p = () => {
428
- t.length = 0, s.length = 0;
429
- }, M = () => {
430
- T(), p();
431
- };
432
- return g.add = _, g.run = v, g.stop = M, g;
433
- }, $e = 1e6, N = (e) => e * $e, K = N(0.06), Ge = N(4), je = (e) => e <= 64 ? K : e <= 128 ? N(0.12) : e <= 256 ? N(0.25) : e <= 384 ? N(0.32) : e <= 426 ? N(0.38) : e <= 640 ? N(0.5) : e <= 848 ? N(0.7) : e <= 1280 ? N(1) : e <= 1920 ? N(2) : Ge, Xe = "av1", Ke = (e) => X(e, Xe), We = 0.6, W = (e, n) => Ke(n) ? e * We : e, He = (e) => W(K, e), H = (e, n) => {
434
- const t = je(e);
435
- return W(t, n);
436
- }, Y = Ve(), Ye = async () => Y().catch((e) => {
437
- c("videoSendingBalancer: error", e);
438
- }), ze = async (e) => (Y.add(e), Ye()), F = async ({
337
+ }), K = (e, n) => e !== void 0 && n !== void 0 && e.toLowerCase().includes(n.toLowerCase()), Fe = 1e6, E = (e) => e * Fe, W = E(0.06), ke = E(4), Ue = (e) => e <= 64 ? W : e <= 128 ? E(0.12) : e <= 256 ? E(0.25) : e <= 384 ? E(0.32) : e <= 426 ? E(0.38) : e <= 640 ? E(0.5) : e <= 848 ? E(0.7) : e <= 1280 ? E(1) : e <= 1920 ? E(2) : ke, Le = "av1", Ve = (e) => K(e, Le), $e = 0.6, j = (e, n) => Ve(n) ? e * $e : e, xe = (e) => j(W, e), H = (e, n) => {
338
+ const t = Ue(e);
339
+ return j(t, n);
340
+ }, Y = Q(), Ge = async () => Y().catch((e) => {
341
+ o("videoSendingBalancer: error", e);
342
+ }), Xe = async (e) => (Y.add(e), Ge()), k = async ({
439
343
  sender: e,
440
344
  scaleResolutionDownBy: n,
441
345
  maxBitrate: t,
442
346
  onSetParameters: s
443
- }) => ze(async () => z(e, { scaleResolutionDownBy: n, maxBitrate: t }, s)), qe = async ({ sender: e, codec: n }, t) => {
444
- const r = He(n);
445
- return F({
347
+ }) => Xe(async () => z(e, { scaleResolutionDownBy: n, maxBitrate: t }, s)), Ke = async ({ sender: e, codec: n }, t) => {
348
+ const r = xe(n);
349
+ return k({
446
350
  sender: e,
447
351
  maxBitrate: r,
448
352
  onSetParameters: t,
449
353
  scaleResolutionDownBy: 200
450
354
  });
451
355
  }, I = async ({ sender: e, track: n, codec: t }, s) => {
452
- const a = n.getSettings().width, u = H(a, t);
453
- return F({
356
+ const c = n.getSettings().width, i = H(c, t);
357
+ return k({
454
358
  sender: e,
455
- maxBitrate: u,
359
+ maxBitrate: i,
456
360
  onSetParameters: s,
457
361
  scaleResolutionDownBy: 1
458
362
  });
459
- }, Je = async ({
363
+ }, We = async ({
460
364
  sender: e,
461
365
  track: n,
462
366
  resolution: t,
463
367
  codec: s
464
368
  }, r) => {
465
- const o = n.getSettings(), a = o.width, u = o.height, [m, E] = t.split("x"), C = a / Number(m), f = u / Number(E), h = Math.max(C, f, 1), y = H(Number(m), s);
466
- return F({
369
+ const a = n.getSettings(), c = a.width, i = a.height, [u, m] = t.split("x"), d = c / Number(u), l = i / Number(m), f = Math.max(d, l, 1), C = H(Number(u), s);
370
+ return k({
467
371
  sender: e,
468
- maxBitrate: y,
372
+ maxBitrate: C,
469
373
  onSetParameters: r,
470
- scaleResolutionDownBy: h
374
+ scaleResolutionDownBy: f
471
375
  });
472
- }, Qe = async ({
376
+ }, je = async ({
473
377
  mainCam: e,
474
378
  resolutionMainCam: n,
475
379
  sender: t,
476
380
  track: s,
477
381
  codec: r
478
- }, o) => {
382
+ }, a) => {
479
383
  switch (e) {
480
- case P.PAUSE_MAIN_CAM:
481
- return qe({ sender: t, codec: r }, o);
482
- case P.RESUME_MAIN_CAM:
483
- return I({ sender: t, track: s, codec: r }, o);
484
- case P.MAX_MAIN_CAM_RESOLUTION:
485
- return n !== void 0 ? Je(
384
+ case B.PAUSE_MAIN_CAM:
385
+ return Ke({ sender: t, codec: r }, a);
386
+ case B.RESUME_MAIN_CAM:
387
+ return I({ sender: t, track: s, codec: r }, a);
388
+ case B.MAX_MAIN_CAM_RESOLUTION:
389
+ return n !== void 0 ? We(
486
390
  { sender: t, track: s, codec: r, resolution: n },
487
- o
488
- ) : I({ sender: t, track: s, codec: r }, o);
391
+ a
392
+ ) : I({ sender: t, track: s, codec: r }, a);
489
393
  default:
490
- return I({ sender: t, track: s, codec: r }, o);
394
+ return I({ sender: t, track: s, codec: r }, a);
491
395
  }
492
396
  }, U = {
493
397
  isChanged: !1,
@@ -505,47 +409,47 @@ const se = (e = new Error()) => {
505
409
  onSetParameters: s,
506
410
  ignoreForCodec: r
507
411
  }) => {
508
- const o = t.getSenders(), a = Be(o);
509
- if (!(a != null && a.track))
412
+ const a = t.getSenders(), c = De(a);
413
+ if (!(c != null && c.track))
510
414
  return U;
511
- const u = await Ie(a);
512
- return X(u, r) ? U : Qe(
513
- { mainCam: e, resolutionMainCam: n, sender: a, codec: u, track: a.track },
415
+ const i = await we(c);
416
+ return K(i, r) ? U : je(
417
+ { mainCam: e, resolutionMainCam: n, sender: c, codec: i, track: c.track },
514
418
  s
515
419
  );
516
- }, on = (e, {
420
+ }, en = (e, {
517
421
  ignoreForCodec: n,
518
422
  onSetParameters: t
519
423
  } = {}) => {
520
424
  const s = async () => {
521
- const { connection: m } = e;
522
- if (!m)
425
+ const { connection: u } = e;
426
+ if (!u)
523
427
  throw new Error("connection is not exist");
524
428
  return L({
525
- connection: m,
429
+ connection: u,
526
430
  onSetParameters: t,
527
431
  ignoreForCodec: n
528
432
  });
529
433
  };
530
434
  let r = s;
531
- const o = async (m) => (r = async () => {
532
- const { mainCam: E, resolutionMainCam: C } = m, { connection: f } = e;
533
- if (!f)
435
+ const a = async (u) => (r = async () => {
436
+ const { mainCam: m, resolutionMainCam: d } = u, { connection: l } = e;
437
+ if (!l)
534
438
  throw new Error("connection is not exist");
535
439
  return L({
536
- mainCam: E,
537
- resolutionMainCam: C,
538
- connection: f,
440
+ mainCam: m,
441
+ resolutionMainCam: d,
442
+ connection: l,
539
443
  onSetParameters: t,
540
444
  ignoreForCodec: n
541
445
  });
542
446
  }, r());
543
447
  return {
544
448
  subscribe: () => {
545
- e.onSession("main-cam-control", o);
449
+ e.onSession("main-cam-control", a);
546
450
  },
547
451
  unsubscribe: () => {
548
- e.offSession("main-cam-control", o);
452
+ e.offSession("main-cam-control", a);
549
453
  },
550
454
  balanceByTrack: s,
551
455
  resetMainCamControl() {
@@ -557,19 +461,19 @@ const se = (e = new Error()) => {
557
461
  };
558
462
  };
559
463
  export {
560
- P as EEventsMainCAM,
561
- un as EEventsMic,
562
- ln as EEventsSyncMediaState,
563
- Sn as EUseLicense,
564
- dn as causes,
565
- mn as constants,
566
- hn as debug,
567
- en as default,
568
- fn as disableDebug,
569
- Cn as enableDebug,
570
- En as eventNames,
571
- Ie as getCodecFromSender,
572
- gn as hasCanceledCallError,
573
- on as resolveVideoSendingBalancer,
574
- rn as tools
464
+ B as EEventsMainCAM,
465
+ sn as EEventsMic,
466
+ rn as EEventsSyncMediaState,
467
+ on as EUseLicense,
468
+ an as causes,
469
+ cn as constants,
470
+ fn as debug,
471
+ Ye as default,
472
+ un as disableDebug,
473
+ ln as enableDebug,
474
+ Sn as eventNames,
475
+ we as getCodecFromSender,
476
+ mn as hasCanceledCallError,
477
+ en as resolveVideoSendingBalancer,
478
+ Ze as tools
575
479
  };