sip-connector 8.0.0 → 8.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,169 +1,168 @@
1
- var gt = Object.defineProperty;
2
- var At = (r, e, t) => e in r ? gt(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
- var i = (r, e, t) => At(r, typeof e != "symbol" ? e + "" : e, t);
4
- import { CancelableRequest as C, isCanceledError as Rt } from "@krivega/cancelable-promise";
5
- import Oe from "events-constructor";
6
- import { repeatedCallsAsync as It } from "repeated-calls";
7
- import F from "debug";
8
- const mt = "Connection Error", be = "Request Timeout", ft = "SIP Failure Code", Ot = "Internal Error", pt = "Busy", Ue = "Rejected", Pt = "Redirected", Dt = "Unavailable", Mt = "Not Found", vt = "Address Incomplete", yt = "Incompatible SDP", wt = "Missing SDP", bt = "Authentication Error", Le = "Terminated", Ut = "WebRTC Error", He = "Canceled", Lt = "No Answer", Ht = "Expires", Wt = "No ACK", kt = "Dialog Error", qt = "User Denied Media Access", Ft = "Bad Media Description", Bt = "RTP Timeout", Zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1
+ var At = Object.defineProperty;
2
+ var Rt = (r, e, t) => e in r ? At(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
3
+ var i = (r, e, t) => Rt(r, typeof e != "symbol" ? e + "" : e, t);
4
+ import { CancelableRequest as N, isCanceledError as It } from "@krivega/cancelable-promise";
5
+ import Pe from "events-constructor";
6
+ import { repeatedCallsAsync as Oe } from "repeated-calls";
7
+ import B from "debug";
8
+ const mt = "Connection Error", Ue = "Request Timeout", ft = "SIP Failure Code", pt = "Internal Error", Pt = "Busy", Le = "Rejected", Ot = "Redirected", Dt = "Unavailable", Mt = "Not Found", vt = "Address Incomplete", yt = "Incompatible SDP", bt = "Missing SDP", wt = "Authentication Error", He = "Terminated", Ut = "WebRTC Error", We = "Canceled", Lt = "No Answer", Ht = "Expires", Wt = "No ACK", kt = "Dialog Error", qt = "User Denied Media Access", Ft = "Bad Media Description", Bt = "RTP Timeout", ts = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9
9
  __proto__: null,
10
10
  ADDRESS_INCOMPLETE: vt,
11
- AUTHENTICATION_ERROR: bt,
11
+ AUTHENTICATION_ERROR: wt,
12
12
  BAD_MEDIA_DESCRIPTION: Ft,
13
- BUSY: pt,
14
- BYE: Le,
15
- CANCELED: He,
13
+ BUSY: Pt,
14
+ BYE: He,
15
+ CANCELED: We,
16
16
  CONNECTION_ERROR: mt,
17
17
  DIALOG_ERROR: kt,
18
18
  EXPIRES: Ht,
19
19
  INCOMPATIBLE_SDP: yt,
20
- INTERNAL_ERROR: Ot,
21
- MISSING_SDP: wt,
20
+ INTERNAL_ERROR: pt,
21
+ MISSING_SDP: bt,
22
22
  NOT_FOUND: Mt,
23
23
  NO_ACK: Wt,
24
24
  NO_ANSWER: Lt,
25
- REDIRECTED: Pt,
26
- REJECTED: Ue,
27
- REQUEST_TIMEOUT: be,
25
+ REDIRECTED: Ot,
26
+ REJECTED: Le,
27
+ REQUEST_TIMEOUT: Ue,
28
28
  RTP_TIMEOUT: Bt,
29
29
  SIP_FAILURE_CODE: ft,
30
30
  UNAVAILABLE: Dt,
31
31
  USER_DENIED_MEDIA_ACCESS: qt,
32
32
  WEBRTC_ERROR: Ut
33
- }, Symbol.toStringTag, { value: "Module" })), B = "incomingCall", V = "declinedIncomingCall", Y = "failedIncomingCall", x = "terminatedIncomingCall", L = "connecting", m = "connected", S = "disconnected", D = "newRTCSession", f = "registered", G = "unregistered", O = "registrationFailed", We = "newMessage", $ = "sipEvent", X = "availableSecondRemoteStream", J = "notAvailableSecondRemoteStream", z = "mustStopPresentation", M = "shareState", Q = "enterRoom", j = "useLicense", K = "peerconnection:confirmed", Z = "peerconnection:ontrack", v = "channels", ee = "channels:notify", te = "ended:fromserver", se = "main-cam-control", ne = "admin-stop-main-cam", ie = "admin-start-main-cam", re = "admin-stop-mic", oe = "admin-start-mic", y = "admin-force-sync-media-state", ae = "participant:added-to-list-moderators", ce = "participant:removed-from-list-moderators", Ee = "participant:move-request-to-stream", _e = "participant:move-request-to-spectators", he = "participation:accepting-word-request", de = "participation:cancelling-word-request", le = "webcast:started", Te = "webcast:stopped", Se = "account:changed", ue = "account:deleted", Ne = "conference:participant-token-issued", p = "ended", ke = "sending", qe = "reinvite", Fe = "replaces", Be = "refer", Ve = "progress", Ye = "accepted", w = "confirmed", b = "peerconnection", A = "failed", xe = "muted", Ge = "unmuted", Ce = "newDTMF", ge = "newInfo", $e = "hold", Xe = "unhold", Je = "update", ze = "sdp", Qe = "icecandidate", je = "getusermediafailed", Ke = "peerconnection:createofferfailed", Ze = "peerconnection:createanswerfailed", et = "peerconnection:setlocaldescriptionfailed", tt = "peerconnection:setremotedescriptionfailed", st = "presentation:start", nt = "presentation:started", it = "presentation:end", Ae = "presentation:ended", U = "presentation:failed", rt = "SPECTATOR", en = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
33
+ }, Symbol.toStringTag, { value: "Module" })), V = "incomingCall", Y = "declinedIncomingCall", x = "failedIncomingCall", G = "terminatedIncomingCall", L = "connecting", m = "connected", S = "disconnected", D = "newRTCSession", f = "registered", $ = "unregistered", p = "registrationFailed", ke = "newMessage", X = "sipEvent", J = "availableSecondRemoteStream", z = "notAvailableSecondRemoteStream", Q = "mustStopPresentation", M = "shareState", j = "enterRoom", K = "useLicense", Z = "peerconnection:confirmed", ee = "peerconnection:ontrack", v = "channels", te = "channels:notify", ne = "ended:fromserver", se = "main-cam-control", ie = "admin-stop-main-cam", re = "admin-start-main-cam", oe = "admin-stop-mic", ae = "admin-start-mic", y = "admin-force-sync-media-state", ce = "participant:added-to-list-moderators", _e = "participant:removed-from-list-moderators", Ee = "participant:move-request-to-stream", he = "participant:move-request-to-spectators", le = "participation:accepting-word-request", de = "participation:cancelling-word-request", Te = "webcast:started", Se = "webcast:stopped", ue = "account:changed", Ce = "account:deleted", Ne = "conference:participant-token-issued", P = "ended", qe = "sending", Fe = "reinvite", Be = "replaces", Ve = "refer", Ye = "progress", xe = "accepted", b = "confirmed", w = "peerconnection", A = "failed", Ge = "muted", $e = "unmuted", ge = "newDTMF", Ae = "newInfo", Xe = "hold", Je = "unhold", ze = "update", Qe = "sdp", je = "icecandidate", Ke = "getusermediafailed", Ze = "peerconnection:createofferfailed", et = "peerconnection:createanswerfailed", tt = "peerconnection:setlocaldescriptionfailed", nt = "peerconnection:setremotedescriptionfailed", st = "presentation:start", it = "presentation:started", rt = "presentation:end", Re = "presentation:ended", U = "presentation:failed", ot = "SPECTATOR", ns = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
34
34
  __proto__: null,
35
- ACCEPTED: Ye,
36
- ACCOUNT_CHANGED: Se,
37
- ACCOUNT_DELETED: ue,
35
+ ACCEPTED: xe,
36
+ ACCOUNT_CHANGED: ue,
37
+ ACCOUNT_DELETED: Ce,
38
38
  ADMIN_FORCE_SYNC_MEDIA_STATE: y,
39
- ADMIN_START_MAIN_CAM: ie,
40
- ADMIN_START_MIC: oe,
41
- ADMIN_STOP_MAIN_CAM: ne,
42
- ADMIN_STOP_MIC: re,
43
- AVAILABLE_SECOND_REMOTE_STREAM_EVENT: X,
39
+ ADMIN_START_MAIN_CAM: re,
40
+ ADMIN_START_MIC: ae,
41
+ ADMIN_STOP_MAIN_CAM: ie,
42
+ ADMIN_STOP_MIC: oe,
43
+ AVAILABLE_SECOND_REMOTE_STREAM_EVENT: J,
44
44
  CHANNELS: v,
45
- CHANNELS_NOTIFY: ee,
45
+ CHANNELS_NOTIFY: te,
46
46
  CONFERENCE_PARTICIPANT_TOKEN_ISSUED: Ne,
47
- CONFIRMED: w,
47
+ CONFIRMED: b,
48
48
  CONNECTED: m,
49
49
  CONNECTING: L,
50
- DECLINED_INCOMING_CALL: V,
50
+ DECLINED_INCOMING_CALL: Y,
51
51
  DISCONNECTED: S,
52
- ENDED: p,
53
- ENDED_FROM_SERVER: te,
54
- ENTER_ROOM: Q,
52
+ ENDED: P,
53
+ ENDED_FROM_SERVER: ne,
54
+ ENTER_ROOM: j,
55
55
  FAILED: A,
56
- FAILED_INCOMING_CALL: Y,
57
- GET_USER_MEDIA_FAILED: je,
58
- HOLD: $e,
59
- ICE_CANDIDATE: Qe,
60
- INCOMING_CALL: B,
56
+ FAILED_INCOMING_CALL: x,
57
+ GET_USER_MEDIA_FAILED: Ke,
58
+ HOLD: Xe,
59
+ ICE_CANDIDATE: je,
60
+ INCOMING_CALL: V,
61
61
  MAIN_CAM_CONTROL: se,
62
- MUST_STOP_PRESENTATION_EVENT: z,
63
- MUTED: xe,
64
- NEW_DTMF: Ce,
65
- NEW_INFO: ge,
66
- NEW_MESSAGE: We,
62
+ MUST_STOP_PRESENTATION_EVENT: Q,
63
+ MUTED: Ge,
64
+ NEW_DTMF: ge,
65
+ NEW_INFO: Ae,
66
+ NEW_MESSAGE: ke,
67
67
  NEW_RTC_SESSION: D,
68
- NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT: J,
69
- PARTICIPANT_ADDED_TO_LIST_MODERATORS: ae,
70
- PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS: _e,
68
+ NOT_AVAILABLE_SECOND_REMOTE_STREAM_EVENT: z,
69
+ PARTICIPANT_ADDED_TO_LIST_MODERATORS: ce,
70
+ PARTICIPANT_MOVE_REQUEST_TO_SPECTATORS: he,
71
71
  PARTICIPANT_MOVE_REQUEST_TO_STREAM: Ee,
72
- PARTICIPANT_REMOVED_FROM_LIST_MODERATORS: ce,
73
- PARTICIPATION_ACCEPTING_WORD_REQUEST: he,
72
+ PARTICIPANT_REMOVED_FROM_LIST_MODERATORS: _e,
73
+ PARTICIPATION_ACCEPTING_WORD_REQUEST: le,
74
74
  PARTICIPATION_CANCELLING_WORD_REQUEST: de,
75
- PEER_CONNECTION: b,
76
- PEER_CONNECTION_CONFIRMED: K,
77
- PEER_CONNECTION_CREATE_ANSWER_FAILED: Ze,
78
- PEER_CONNECTION_CREATE_OFFER_FAILED: Ke,
79
- PEER_CONNECTION_ONTRACK: Z,
80
- PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED: et,
81
- PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED: tt,
82
- PRESENTATION_END: it,
83
- PRESENTATION_ENDED: Ae,
75
+ PEER_CONNECTION: w,
76
+ PEER_CONNECTION_CONFIRMED: Z,
77
+ PEER_CONNECTION_CREATE_ANSWER_FAILED: et,
78
+ PEER_CONNECTION_CREATE_OFFER_FAILED: Ze,
79
+ PEER_CONNECTION_ONTRACK: ee,
80
+ PEER_CONNECTION_SET_LOCAL_DESCRIPTION_FAILED: tt,
81
+ PEER_CONNECTION_SET_REMOTE_DESCRIPTION_FAILED: nt,
82
+ PRESENTATION_END: rt,
83
+ PRESENTATION_ENDED: Re,
84
84
  PRESENTATION_FAILED: U,
85
85
  PRESENTATION_START: st,
86
- PRESENTATION_STARTED: nt,
87
- PROGRESS: Ve,
88
- REFER: Be,
86
+ PRESENTATION_STARTED: it,
87
+ PROGRESS: Ye,
88
+ REFER: Ve,
89
89
  REGISTERED: f,
90
- REGISTRATION_FAILED: O,
91
- REINVITE: qe,
92
- REPLACES: Fe,
93
- SDP: ze,
94
- SENDING: ke,
90
+ REGISTRATION_FAILED: p,
91
+ REINVITE: Fe,
92
+ REPLACES: Be,
93
+ SDP: Qe,
94
+ SENDING: qe,
95
95
  SHARE_STATE: M,
96
- SIP_EVENT: $,
97
- SPECTATOR: rt,
98
- TERMINATED_INCOMING_CALL: x,
99
- UNHOLD: Xe,
100
- UNMUTED: Ge,
101
- UNREGISTERED: G,
102
- UPDATE: Je,
103
- USE_LICENSE: j,
104
- WEBCAST_STARTED: le,
105
- WEBCAST_STOPPED: Te
106
- }, Symbol.toStringTag, { value: "Module" })), ot = [
107
- B,
96
+ SIP_EVENT: X,
97
+ SPECTATOR: ot,
98
+ TERMINATED_INCOMING_CALL: G,
99
+ UNHOLD: Je,
100
+ UNMUTED: $e,
101
+ UNREGISTERED: $,
102
+ UPDATE: ze,
103
+ USE_LICENSE: K,
104
+ WEBCAST_STARTED: Te,
105
+ WEBCAST_STOPPED: Se
106
+ }, Symbol.toStringTag, { value: "Module" })), at = [
108
107
  V,
109
- x,
110
108
  Y,
111
- he,
109
+ G,
110
+ x,
111
+ le,
112
112
  de,
113
113
  Ee,
114
- ee,
114
+ te,
115
115
  Ne,
116
- Se,
117
116
  ue,
118
- le,
117
+ Ce,
119
118
  Te,
120
- ae,
121
- ce
122
- ], Re = [
119
+ Se,
120
+ ce,
121
+ _e
122
+ ], Ie = [
123
123
  L,
124
124
  m,
125
125
  S,
126
126
  D,
127
127
  f,
128
- G,
129
- O,
130
- We,
131
- $
132
- ], at = [
133
- X,
128
+ $,
129
+ p,
130
+ ke,
131
+ X
132
+ ], ct = [
134
133
  J,
135
134
  z,
136
- M,
137
135
  Q,
136
+ M,
138
137
  j,
139
138
  K,
140
139
  Z,
140
+ ee,
141
141
  v,
142
- te,
143
- se,
144
- ie,
145
142
  ne,
143
+ se,
146
144
  re,
145
+ ie,
147
146
  oe,
147
+ ae,
148
148
  y,
149
- _e
150
- ], Ie = [
151
- p,
149
+ he
150
+ ], me = [
151
+ P,
152
152
  L,
153
- ke,
154
153
  qe,
155
154
  Fe,
156
155
  Be,
157
156
  Ve,
158
157
  Ye,
159
- w,
158
+ xe,
160
159
  b,
160
+ w,
161
161
  A,
162
- xe,
163
162
  Ge,
164
- Ce,
165
- ge,
166
163
  $e,
164
+ ge,
165
+ Ae,
167
166
  Xe,
168
167
  Je,
169
168
  ze,
@@ -173,77 +172,78 @@ const mt = "Connection Error", be = "Request Timeout", ft = "SIP Failure Code",
173
172
  Ze,
174
173
  et,
175
174
  tt,
176
- st,
177
175
  nt,
176
+ st,
178
177
  it,
179
- Ae,
178
+ rt,
179
+ Re,
180
180
  U
181
- ], ct = [...Re, ...ot], Et = [
182
- ...Ie,
183
- ...at
184
- ], tn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
181
+ ], _t = [...Ie, ...at], Et = [
182
+ ...me,
183
+ ...ct
184
+ ], ss = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
185
185
  __proto__: null,
186
186
  SESSION_EVENT_NAMES: Et,
187
- SESSION_JSSIP_EVENT_NAMES: Ie,
188
- SESSION_SYNTHETICS_EVENT_NAMES: at,
189
- UA_EVENT_NAMES: ct,
190
- UA_JSSIP_EVENT_NAMES: Re,
191
- UA_SYNTHETICS_EVENT_NAMES: ot
187
+ SESSION_JSSIP_EVENT_NAMES: me,
188
+ SESSION_SYNTHETICS_EVENT_NAMES: ct,
189
+ UA_EVENT_NAMES: _t,
190
+ UA_JSSIP_EVENT_NAMES: Ie,
191
+ UA_SYNTHETICS_EVENT_NAMES: at
192
192
  }, Symbol.toStringTag, { value: "Module" })), Vt = (r) => {
193
193
  const e = [];
194
194
  return r && e.push(`X-Vinteo-Remote: ${r}`), e;
195
- }, Yt = "content-type", xt = "x-webrtc-enter-room", P = "application/vinteo.webrtc.sharedesktop", Gt = "application/vinteo.webrtc.roomname", $t = "application/vinteo.webrtc.channels", Xt = "application/vinteo.webrtc.mediastate", Jt = "application/vinteo.webrtc.refusal", pe = "application/vinteo.webrtc.maincam", zt = "application/vinteo.webrtc.mic", Qt = "application/vinteo.webrtc.uselic", jt = "X-WEBRTC-USE-LICENSE", Kt = "X-WEBRTC-PARTICIPANT-NAME", Pe = "X-WEBRTC-INPUT-CHANNELS", De = "X-WEBRTC-OUTPUT-CHANNELS", Zt = "X-WEBRTC-MAINCAM", es = "X-WEBRTC-MIC", Me = "X-WEBRTC-SYNC", ts = "X-WEBRTC-MAINCAM-RESOLUTION", ss = "X-WEBRTC-MEDIA-STATE", ns = "X-Vinteo-Media-Type", is = "X-Vinteo-MainCam-State", rs = "X-Vinteo-Mic-State", os = "application/vinteo.webrtc.partstate", as = "X-WEBRTC-PARTSTATE", cs = "application/vinteo.webrtc.notify", Es = "X-VINTEO-NOTIFY", R = "x-webrtc-share-state", _s = `${R}: LETMESTARTPRESENTATION`, hs = `${R}: STOPPRESENTATION`, _t = "YOUCANRECEIVECONTENT", ht = "CONTENTEND", dt = "YOUMUSTSTOPSENDCONTENT", ds = `${R}: ${dt}`, ls = `${R}: ${_t}`, Ts = `${R}: ${ht}`, Ss = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", us = `${Ss}: LETMESTARTMAINCAM`, me = "sip-connector", ve = F(me), sn = () => {
196
- F.enable(me);
197
- }, nn = () => {
198
- F.enable(`-${me}`);
195
+ }, Yt = "content-type", xt = "x-webrtc-enter-room", O = "application/vinteo.webrtc.sharedesktop", Gt = "application/vinteo.webrtc.roomname", $t = "application/vinteo.webrtc.channels", Xt = "application/vinteo.webrtc.mediastate", Jt = "application/vinteo.webrtc.refusal", De = "application/vinteo.webrtc.maincam", zt = "application/vinteo.webrtc.mic", Qt = "application/vinteo.webrtc.uselic", jt = "X-WEBRTC-USE-LICENSE", Kt = "X-WEBRTC-PARTICIPANT-NAME", Me = "X-WEBRTC-INPUT-CHANNELS", ve = "X-WEBRTC-OUTPUT-CHANNELS", Zt = "X-WEBRTC-MAINCAM", en = "X-WEBRTC-MIC", ye = "X-WEBRTC-SYNC", tn = "X-WEBRTC-MAINCAM-RESOLUTION", nn = "X-WEBRTC-MEDIA-STATE", sn = "X-Vinteo-Media-Type", rn = "X-Vinteo-MainCam-State", on = "X-Vinteo-Mic-State", an = "application/vinteo.webrtc.partstate", cn = "X-WEBRTC-PARTSTATE", _n = "application/vinteo.webrtc.notify", En = "X-VINTEO-NOTIFY", R = "x-webrtc-share-state", hn = `${R}: LETMESTARTPRESENTATION`, ln = `${R}: STOPPRESENTATION`, ht = "YOUCANRECEIVECONTENT", lt = "CONTENTEND", dt = "YOUMUSTSTOPSENDCONTENT", dn = `${R}: ${dt}`, Tn = `${R}: ${ht}`, Sn = `${R}: ${lt}`, un = "X-WEBRTC-REQUEST-ENABLE-MEDIA-DEVICE", Cn = `${un}: LETMESTARTMAINCAM`, fe = "sip-connector", H = B(fe), is = () => {
196
+ B.enable(fe);
197
+ }, rs = () => {
198
+ B.enable(`-${fe}`);
199
199
  };
200
- var I = /* @__PURE__ */ ((r) => (r.PAUSE_MAIN_CAM = "PAUSEMAINCAM", r.RESUME_MAIN_CAM = "RESUMEMAINCAM", r.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", r.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", r.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", r))(I || {}), W = /* @__PURE__ */ ((r) => (r.ADMIN_STOP_MIC = "ADMINSTOPMIC", r.ADMIN_START_MIC = "ADMINSTARTMIC", r))(W || {}), k = /* @__PURE__ */ ((r) => (r.ADMIN_SYNC_FORCED = "1", r.ADMIN_SYNC_NOT_FORCED = "0", r))(k || {}), Ns = /* @__PURE__ */ ((r) => (r.AUDIO = "AUDIO", r.VIDEO = "VIDEO", r.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", r))(Ns || {});
201
- function Cs(r) {
200
+ var I = /* @__PURE__ */ ((r) => (r.PAUSE_MAIN_CAM = "PAUSEMAINCAM", r.RESUME_MAIN_CAM = "RESUMEMAINCAM", r.MAX_MAIN_CAM_RESOLUTION = "MAXMAINCAMRESOLUTION", r.ADMIN_STOP_MAIN_CAM = "ADMINSTOPMAINCAM", r.ADMIN_START_MAIN_CAM = "ADMINSTARTMAINCAM", r))(I || {}), k = /* @__PURE__ */ ((r) => (r.ADMIN_STOP_MIC = "ADMINSTOPMIC", r.ADMIN_START_MIC = "ADMINSTARTMIC", r))(k || {}), q = /* @__PURE__ */ ((r) => (r.ADMIN_SYNC_FORCED = "1", r.ADMIN_SYNC_NOT_FORCED = "0", r))(q || {}), Nn = /* @__PURE__ */ ((r) => (r.AUDIO = "AUDIO", r.VIDEO = "VIDEO", r.AUDIOPLUSPRESENTATION = "AUDIOPLUSPRESENTATION", r))(Nn || {});
201
+ function gn(r) {
202
202
  return (e) => `sip:${e}@${r}`;
203
203
  }
204
- const gs = (r, e) => () => Math.floor(Math.random() * (e - r)) + r, ye = (r) => r.trim().replaceAll(" ", "_"), As = gs(1e5, 99999999), H = (r, {
204
+ const An = (r, e) => () => Math.floor(Math.random() * (e - r)) + r, be = (r) => r.trim().replaceAll(" ", "_"), Rn = An(1e5, 99999999), W = (r, {
205
205
  videoMode: e,
206
206
  audioMode: t
207
207
  } = {}) => {
208
208
  if (!r || e === "recvonly" && t === "recvonly")
209
209
  return;
210
- const s = t === "recvonly" ? [] : r.getAudioTracks(), n = e === "recvonly" ? [] : r.getVideoTracks(), o = [...s, ...n], a = new MediaStream(o);
210
+ const n = t === "recvonly" ? [] : r.getAudioTracks(), s = e === "recvonly" ? [] : r.getVideoTracks(), o = [...n, ...s], a = new MediaStream(o);
211
211
  return a.getTracks = () => [...a.getAudioTracks(), ...a.getVideoTracks()], a;
212
- }, Rs = (r) => r.some((t) => {
213
- const { kind: s } = t;
214
- return s === "video";
215
- }), Is = "Error decline with 603", ms = 1006, fs = (r) => typeof r == "object" && r !== null && "code" in r && r.code === ms, Os = (r) => r.message === Is, ps = (r, e) => r.find((t) => t.track && e.getTracks().includes(t.track)), lt = 1, Tt = (r) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== r, Ps = Tt(
216
- lt
217
- ), Ds = (r, e) => {
218
- const t = r === void 0 ? void 0 : Math.max(r, lt);
219
- if (t !== void 0 && Ps(
212
+ }, In = (r) => r.some((t) => {
213
+ const { kind: n } = t;
214
+ return n === "video";
215
+ }), mn = "Error decline with 603", fn = 1006, pn = (r) => typeof r == "object" && r !== null && "code" in r && r.code === fn, Pn = (r) => r.message === mn, On = (r, e) => r.find((t) => t.track && e.getTracks().includes(t.track)), Tt = 1, St = (r) => (e, t) => t !== void 0 && e !== t || t === void 0 && e !== r, Dn = St(
216
+ Tt
217
+ ), Mn = (r, e) => {
218
+ const t = r === void 0 ? void 0 : Math.max(r, Tt);
219
+ if (t !== void 0 && Dn(
220
220
  t,
221
221
  e
222
222
  ))
223
223
  return t;
224
- }, Ms = Tt(), vs = (r, e) => {
225
- if (Ms(r, e))
224
+ }, vn = St(), yn = (r, e) => {
225
+ if (vn(r, e))
226
226
  return r;
227
- }, ys = async (r, e, t) => {
228
- const s = r.getParameters();
229
- (s.encodings === void 0 || s.encodings.length === 0) && (s.encodings = [{}]);
230
- const [n] = s.encodings, o = n.scaleResolutionDownBy, a = Ds(
227
+ }, bn = async (r, e, t) => {
228
+ const n = r.getParameters();
229
+ (n.encodings === void 0 || n.encodings.length === 0) && (n.encodings = [{}]);
230
+ const [s] = n.encodings, o = s.scaleResolutionDownBy, a = Mn(
231
231
  e.scaleResolutionDownBy,
232
232
  o
233
233
  );
234
234
  let c = !1;
235
- a !== void 0 && (s.encodings[0].scaleResolutionDownBy = a, c = !0);
236
- const E = n.maxBitrate, _ = vs(e.maxBitrate, E);
237
- return _ !== void 0 && (s.encodings[0].maxBitrate = _, c = !0), c ? (t && t(s), r.setParameters(s).then(() => ({ parameters: s, isChanged: c }))) : { parameters: s, isChanged: c };
238
- }, ws = async (r, e, t) => {
239
- const s = ps(r, e);
240
- if (s)
241
- return ys(s, { maxBitrate: t });
242
- }, bs = 486, Us = 487, q = "local", we = "remote", Ls = 3, rn = (r = new Error()) => {
235
+ a !== void 0 && (n.encodings[0].scaleResolutionDownBy = a, c = !0);
236
+ const _ = s.maxBitrate, E = yn(e.maxBitrate, _);
237
+ return E !== void 0 && (n.encodings[0].maxBitrate = E, c = !0), c ? (t && t(n), r.setParameters(n).then(() => ({ parameters: n, isChanged: c }))) : { parameters: n, isChanged: c };
238
+ }, wn = async (r, e, t) => {
239
+ const n = On(r, e);
240
+ if (n)
241
+ return bn(n, { maxBitrate: t });
242
+ }, Un = 486, Ln = 487, F = "local", we = "remote", Hn = 3, Wn = 1, os = (r = new Error()) => {
243
243
  const { originator: e, cause: t } = r;
244
- return Rt(r) ? !0 : typeof t == "string" ? t === be || t === Ue || e === q && (t === He || t === Le) : !1;
245
- }, g = "SipConnector", Hs = "channels", Ws = "WebcastStarted", ks = "WebcastStopped", qs = "accountChanged", Fs = "accountDeleted", Bs = "addedToListModerators", Vs = "removedFromListModerators", Ys = "ParticipationRequestAccepted", xs = "ParticipationRequestRejected", Gs = "ParticipantMovedToWebcast", $s = "ConferenceParticipantTokenIssued";
246
- class on {
244
+ return It(r) ? !0 : typeof t == "string" ? t === Ue || t === Le || e === F && (t === We || t === He) : !1;
245
+ }, g = "SipConnector", kn = "channels", qn = "WebcastStarted", Fn = "WebcastStopped", Bn = "accountChanged", Vn = "accountDeleted", Yn = "addedToListModerators", xn = "removedFromListModerators", Gn = "ParticipationRequestAccepted", $n = "ParticipationRequestRejected", Xn = "ParticipantMovedToWebcast", Jn = "ConferenceParticipantTokenIssued";
246
+ class as {
247
247
  constructor({ JsSIP: e }) {
248
248
  i(this, "_isRegisterConfig", !1);
249
249
  i(this, "_connectionConfiguration", {});
@@ -253,6 +253,7 @@ class on {
253
253
  i(this, "_uaEvents");
254
254
  i(this, "_cancelableConnect");
255
255
  i(this, "_cancelableConnectWithRepeatedCalls");
256
+ i(this, "_cancelableSendPresentationWithRepeatedCalls");
256
257
  i(this, "_cancelableInitUa");
257
258
  i(this, "_cancelableDisconnect");
258
259
  i(this, "_cancelableSet");
@@ -282,31 +283,31 @@ class on {
282
283
  try {
283
284
  await this.unregister();
284
285
  } catch (e) {
285
- ve("tryRegister", e);
286
+ H("tryRegister", e);
286
287
  }
287
288
  return this.register();
288
289
  });
289
- i(this, "declineToIncomingCall", async ({ statusCode: e = Us } = {}) => new Promise((t, s) => {
290
+ i(this, "declineToIncomingCall", async ({ statusCode: e = Ln } = {}) => new Promise((t, n) => {
290
291
  if (!this.isAvailableIncomingCall) {
291
- s(new Error("no incomingSession"));
292
+ n(new Error("no incomingSession"));
292
293
  return;
293
294
  }
294
- const n = this.incomingSession, o = this.remoteCallerData;
295
- this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest(), this.removeIncomingSession(), this._uaEvents.trigger(V, o), t(n.terminate({ status_code: e }));
295
+ const s = this.incomingSession, o = this.remoteCallerData;
296
+ this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest(), this.removeIncomingSession(), this._uaEvents.trigger(Y, o), t(s.terminate({ status_code: e }));
296
297
  }));
297
- i(this, "busyIncomingCall", async () => this.declineToIncomingCall({ statusCode: bs }));
298
+ i(this, "busyIncomingCall", async () => this.declineToIncomingCall({ statusCode: Un }));
298
299
  i(this, "removeIncomingSession", () => {
299
300
  delete this.incomingSession;
300
301
  });
301
- i(this, "_connectWithDuplicatedCalls", async (e, { callLimit: t = Ls } = {}) => {
302
- let s = !0;
303
- const n = async () => (s = !1, this._cancelableConnect.request(e)), o = (a) => {
302
+ i(this, "_connectWithDuplicatedCalls", async (e, { callLimit: t = Hn } = {}) => {
303
+ let n = !0;
304
+ const s = async () => (n = !1, this._cancelableConnect.request(e)), o = (a) => {
304
305
  var h;
305
- const c = !!((h = this.ua) != null && h.isConnected()), E = !s && c && this.hasEqualConnectionConfiguration(e), _ = !!a && !fs(a);
306
- return E || _;
306
+ const c = !!((h = this.ua) != null && h.isConnected()), _ = !n && c && this.hasEqualConnectionConfiguration(e), E = !!a && !pn(a);
307
+ return _ || E;
307
308
  };
308
- return this._cancelableConnectWithRepeatedCalls = It({
309
- targetFunction: n,
309
+ return this._cancelableConnectWithRepeatedCalls = Oe({
310
+ targetFunction: s,
310
311
  isComplete: o,
311
312
  callLimit: t,
312
313
  isRejectAsValid: !0,
@@ -322,95 +323,95 @@ class on {
322
323
  i(this, "handleNewRTCSession", ({ originator: e, session: t }) => {
323
324
  if (e === we) {
324
325
  this.incomingSession = t;
325
- const s = this.remoteCallerData;
326
- t.on(A, (n) => {
327
- this.removeIncomingSession(), n.originator === q ? this._uaEvents.trigger(x, s) : this._uaEvents.trigger(Y, s);
328
- }), this._uaEvents.trigger(B, s);
326
+ const n = this.remoteCallerData;
327
+ t.on(A, (s) => {
328
+ this.removeIncomingSession(), s.originator === F ? this._uaEvents.trigger(G, n) : this._uaEvents.trigger(x, n);
329
+ }), this._uaEvents.trigger(V, n);
329
330
  }
330
331
  });
331
332
  i(this, "_connect", async (e) => this.initUa(e).then(async () => this._start()));
332
333
  i(this, "_initUa", async ({
333
334
  user: e,
334
335
  password: t,
335
- sipServerUrl: s,
336
- sipWebSocketServerURL: n,
336
+ sipServerUrl: n,
337
+ sipWebSocketServerURL: s,
337
338
  remoteAddress: o,
338
339
  sessionTimers: a,
339
340
  registerExpires: c,
340
- connectionRecoveryMinInterval: E,
341
- connectionRecoveryMaxInterval: _,
341
+ connectionRecoveryMinInterval: _,
342
+ connectionRecoveryMaxInterval: E,
342
343
  userAgent: h,
343
- displayName: l = "",
344
- register: d = !1,
344
+ displayName: d = "",
345
+ register: l = !1,
345
346
  extraHeaders: T = []
346
347
  }) => {
347
- if (!s)
348
- throw new Error("sipServerUrl is required");
349
348
  if (!n)
349
+ throw new Error("sipServerUrl is required");
350
+ if (!s)
350
351
  throw new Error("sipWebSocketServerURL is required");
351
- if (d && !e)
352
+ if (l && !e)
352
353
  throw new Error("user is required for authorized connection");
353
- if (d && !t)
354
+ if (l && !t)
354
355
  throw new Error("password is required for authorized connection");
355
356
  this._connectionConfiguration = {
356
- sipServerUrl: s,
357
- displayName: l,
358
- register: d,
357
+ sipServerUrl: n,
358
+ displayName: d,
359
+ register: l,
359
360
  user: e,
360
361
  password: t
361
362
  };
362
- const { configuration: u, helpers: N } = this.createUaConfiguration({
363
+ const { configuration: u, helpers: C } = this.createUaConfiguration({
363
364
  user: e,
364
- sipServerUrl: s,
365
- sipWebSocketServerURL: n,
365
+ sipServerUrl: n,
366
+ sipWebSocketServerURL: s,
366
367
  password: t,
367
- displayName: l,
368
- register: d,
368
+ displayName: d,
369
+ register: l,
369
370
  sessionTimers: a,
370
371
  registerExpires: c,
371
- connectionRecoveryMinInterval: E,
372
- connectionRecoveryMaxInterval: _,
372
+ connectionRecoveryMinInterval: _,
373
+ connectionRecoveryMaxInterval: E,
373
374
  userAgent: h
374
375
  });
375
- this.getSipServerUrl = N.getSipServerUrl, this.socket = N.socket, this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!d, this.ua = this._createUa(u), this._uaEvents.eachTriggers((ut, Nt) => {
376
- const fe = Re.find((Ct) => Ct === Nt);
377
- fe && this.ua && this.ua.on(fe, ut);
376
+ this.getSipServerUrl = C.getSipServerUrl, this.socket = C.socket, this.ua && await this._disconnectWithoutCancelRequests(), this._isRegisterConfig = !!l, this.ua = this._createUa(u), this._uaEvents.eachTriggers((Ct, Nt) => {
377
+ const pe = Ie.find((gt) => gt === Nt);
378
+ pe && this.ua && this.ua.on(pe, Ct);
378
379
  });
379
- const St = [...Vt(o), ...T];
380
- return this.ua.registrator().setExtraHeaders(St), this.ua;
380
+ const ut = [...Vt(o), ...T];
381
+ return this.ua.registrator().setExtraHeaders(ut), this.ua;
381
382
  });
382
383
  i(this, "_createUa", (e) => new this.JsSIP.UA(e));
383
384
  i(this, "_start", async () => new Promise((e, t) => {
384
- const { ua: s } = this;
385
- if (!s) {
385
+ const { ua: n } = this;
386
+ if (!n) {
386
387
  t(new Error("this.ua is not initialized"));
387
388
  return;
388
389
  }
389
- const n = () => {
390
- c(), e(s);
391
- }, o = (E) => {
392
- c(), t(E);
390
+ const s = () => {
391
+ c(), e(n);
392
+ }, o = (_) => {
393
+ c(), t(_);
393
394
  }, a = () => {
394
- this.isRegisterConfig ? (this.on(f, n), this.on(O, o)) : this.on(m, n), this.on(S, o);
395
+ this.isRegisterConfig ? (this.on(f, s), this.on(p, o)) : this.on(m, s), this.on(S, o);
395
396
  }, c = () => {
396
- this.off(f, n), this.off(O, o), this.off(m, n), this.off(S, o);
397
+ this.off(f, s), this.off(p, o), this.off(m, s), this.off(S, o);
397
398
  };
398
- a(), this.on(D, this.handleNewRTCSession), s.start();
399
+ a(), this.on(D, this.handleNewRTCSession), n.start();
399
400
  }));
400
- i(this, "_set", async ({ displayName: e, password: t }) => new Promise((s, n) => {
401
+ i(this, "_set", async ({ displayName: e, password: t }) => new Promise((n, s) => {
401
402
  const { ua: o } = this;
402
403
  if (!o) {
403
- n(new Error("this.ua is not initialized"));
404
+ s(new Error("this.ua is not initialized"));
404
405
  return;
405
406
  }
406
407
  let a = !1, c = !1;
407
- e !== void 0 && e !== this._connectionConfiguration.displayName && (a = o.set("display_name", ye(e)), this._connectionConfiguration.displayName = e), t !== void 0 && t !== this._connectionConfiguration.password && (c = o.set("password", t), this._connectionConfiguration.password = t);
408
- const E = a || c;
408
+ e !== void 0 && e !== this._connectionConfiguration.displayName && (a = o.set("display_name", be(e)), this._connectionConfiguration.displayName = e), t !== void 0 && t !== this._connectionConfiguration.password && (c = o.set("password", t), this._connectionConfiguration.password = t);
409
+ const _ = a || c;
409
410
  c && this.isRegisterConfig ? this.register().then(() => {
410
- s(E);
411
- }).catch((_) => {
412
411
  n(_);
413
- }) : E ? s(E) : n(new Error("nothing changed"));
412
+ }).catch((E) => {
413
+ s(E);
414
+ }) : _ ? n(_) : s(new Error("nothing changed"));
414
415
  }));
415
416
  i(this, "_disconnectWithoutCancelRequests", async () => this._cancelableDisconnect.request());
416
417
  i(this, "_disconnect", async () => {
@@ -425,37 +426,37 @@ class on {
425
426
  i(this, "_call", async ({
426
427
  number: e,
427
428
  mediaStream: t,
428
- extraHeaders: s = [],
429
- ontrack: n,
429
+ extraHeaders: n = [],
430
+ ontrack: s,
430
431
  iceServers: o,
431
432
  videoMode: a,
432
433
  audioMode: c,
433
- degradationPreference: E,
434
- offerToReceiveAudio: _ = !0,
434
+ degradationPreference: _,
435
+ offerToReceiveAudio: E = !0,
435
436
  offerToReceiveVideo: h = !0
436
- }) => new Promise((l, d) => {
437
+ }) => new Promise((d, l) => {
437
438
  const { ua: T } = this;
438
439
  if (!T) {
439
- d(new Error("this.ua is not initialized"));
440
+ l(new Error("this.ua is not initialized"));
440
441
  return;
441
442
  }
442
- this._connectionConfiguration.number = e, this._connectionConfiguration.answer = !1, this._handleCall({ ontrack: n }).then(l).catch((u) => {
443
- d(u);
443
+ this._connectionConfiguration.number = e, this._connectionConfiguration.answer = !1, this._handleCall({ ontrack: s }).then(d).catch((u) => {
444
+ l(u);
444
445
  }), this.session = T.call(this.getSipServerUrl(e), {
445
- extraHeaders: s,
446
- mediaStream: H(t, {
446
+ extraHeaders: n,
447
+ mediaStream: W(t, {
447
448
  videoMode: a,
448
449
  audioMode: c
449
450
  }),
450
451
  eventHandlers: this._sessionEvents.triggers,
451
452
  videoMode: a,
452
453
  audioMode: c,
453
- degradationPreference: E,
454
+ degradationPreference: _,
454
455
  pcConfig: {
455
456
  iceServers: o
456
457
  },
457
458
  rtcOfferConstraints: {
458
- offerToReceiveAudio: _,
459
+ offerToReceiveAudio: E,
459
460
  offerToReceiveVideo: h
460
461
  }
461
462
  });
@@ -463,77 +464,77 @@ class on {
463
464
  i(this, "_answer", async ({
464
465
  mediaStream: e,
465
466
  ontrack: t,
466
- extraHeaders: s = [],
467
- iceServers: n,
467
+ extraHeaders: n = [],
468
+ iceServers: s,
468
469
  videoMode: o,
469
470
  audioMode: a,
470
471
  degradationPreference: c
471
- }) => new Promise((E, _) => {
472
+ }) => new Promise((_, E) => {
472
473
  if (!this.isAvailableIncomingCall) {
473
- _(new Error("no incomingSession"));
474
+ E(new Error("no incomingSession"));
474
475
  return;
475
476
  }
476
477
  this.session = this.incomingSession, this.removeIncomingSession();
477
478
  const { session: h } = this;
478
479
  if (!h) {
479
- _(new Error("No session established"));
480
+ E(new Error("No session established"));
480
481
  return;
481
482
  }
482
- this._sessionEvents.eachTriggers((d, T) => {
483
- const u = Ie.find((N) => N === T);
484
- u && h.on(u, d);
485
- }), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number = h.remote_identity.uri.user, this._handleCall({ ontrack: t }).then(E).catch((d) => {
486
- _(d);
483
+ this._sessionEvents.eachTriggers((l, T) => {
484
+ const u = me.find((C) => C === T);
485
+ u && h.on(u, l);
486
+ }), this._connectionConfiguration.answer = !0, this._connectionConfiguration.number = h.remote_identity.uri.user, this._handleCall({ ontrack: t }).then(_).catch((l) => {
487
+ E(l);
487
488
  });
488
- const l = H(e, {
489
+ const d = W(e, {
489
490
  videoMode: o,
490
491
  audioMode: a
491
492
  });
492
493
  h.answer({
493
- extraHeaders: s,
494
+ extraHeaders: n,
494
495
  videoMode: o,
495
496
  audioMode: a,
496
497
  degradationPreference: c,
497
- mediaStream: l,
498
+ mediaStream: d,
498
499
  pcConfig: {
499
- iceServers: n
500
+ iceServers: s
500
501
  }
501
502
  });
502
503
  }));
503
- i(this, "_handleCall", async ({ ontrack: e }) => new Promise((t, s) => {
504
- const n = () => {
505
- this.onSession(b, h), this.onSession(w, l);
504
+ i(this, "_handleCall", async ({ ontrack: e }) => new Promise((t, n) => {
505
+ const s = () => {
506
+ this.onSession(w, h), this.onSession(b, d);
506
507
  }, o = () => {
507
- this.offSession(b, h), this.offSession(w, l);
508
+ this.offSession(w, h), this.offSession(b, d);
508
509
  }, a = () => {
509
- this.onSession(A, E), this.onSession(p, E);
510
+ this.onSession(A, _), this.onSession(P, _);
510
511
  }, c = () => {
511
- this.offSession(A, E), this.offSession(p, E);
512
- }, E = (d) => {
513
- o(), c(), s(d);
512
+ this.offSession(A, _), this.offSession(P, _);
513
+ }, _ = (l) => {
514
+ o(), c(), n(l);
514
515
  };
515
- let _;
516
- const h = ({ peerconnection: d }) => {
517
- _ = d, _.ontrack = (T) => {
518
- this._sessionEvents.trigger(Z, _), e && e(T);
516
+ let E;
517
+ const h = ({ peerconnection: l }) => {
518
+ E = l, E.ontrack = (T) => {
519
+ this._sessionEvents.trigger(ee, E), e && e(T);
519
520
  };
520
- }, l = () => {
521
- _ && this._sessionEvents.trigger(K, _), o(), c(), t(_);
521
+ }, d = () => {
522
+ E && this._sessionEvents.trigger(Z, E), o(), c(), t(E);
522
523
  };
523
- n(), a();
524
+ s(), a();
524
525
  }));
525
526
  i(this, "_restoreSession", () => {
526
- this._resetPresentation(), delete this._connectionConfiguration.number, delete this.session, this._remoteStreams = {};
527
+ this._cancelRequestsAndResetPresentation(), delete this._connectionConfiguration.number, delete this.session, this._remoteStreams = {};
527
528
  });
528
- i(this, "_sendDTMF", async (e) => new Promise((t, s) => {
529
- const { session: n } = this;
530
- if (!n) {
531
- s(new Error("No session established"));
529
+ i(this, "_sendDTMF", async (e) => new Promise((t, n) => {
530
+ const { session: s } = this;
531
+ if (!s) {
532
+ n(new Error("No session established"));
532
533
  return;
533
534
  }
534
- this.onceSession(Ce, ({ originator: o }) => {
535
- o === q && t();
536
- }), n.sendDTMF(e, {
535
+ this.onceSession(ge, ({ originator: o }) => {
536
+ o === F && t();
537
+ }), s.sendDTMF(e, {
537
538
  duration: 120,
538
539
  interToneGap: 600
539
540
  });
@@ -541,93 +542,99 @@ class on {
541
542
  i(this, "_hangUpWithoutCancelRequests", async () => {
542
543
  if (this.ua && this.session) {
543
544
  const { session: e } = this;
544
- if (this._streamPresentationCurrent && await this.stopPresentation(), this._restoreSession(), !e.isEnded())
545
+ if (this._streamPresentationCurrent)
546
+ try {
547
+ await this.stopPresentation();
548
+ } catch (t) {
549
+ H("error stop presentation: ", t);
550
+ }
551
+ if (this._restoreSession(), !e.isEnded())
545
552
  return e.terminateAsync();
546
553
  }
547
554
  });
548
555
  i(this, "_handleShareState", (e) => {
549
556
  switch (e) {
550
- case _t: {
551
- this._sessionEvents.trigger(X, void 0);
552
- break;
553
- }
554
557
  case ht: {
555
558
  this._sessionEvents.trigger(J, void 0);
556
559
  break;
557
560
  }
558
- case dt: {
561
+ case lt: {
559
562
  this._sessionEvents.trigger(z, void 0);
560
563
  break;
561
564
  }
565
+ case dt: {
566
+ this._sessionEvents.trigger(Q, void 0);
567
+ break;
568
+ }
562
569
  }
563
570
  });
564
571
  i(this, "_maybeTriggerChannels", (e) => {
565
- const t = e.getHeader(Pe), s = e.getHeader(De);
566
- if (t && s) {
567
- const n = {
572
+ const t = e.getHeader(Me), n = e.getHeader(ve);
573
+ if (t && n) {
574
+ const s = {
568
575
  inputChannels: t,
569
- outputChannels: s
576
+ outputChannels: n
570
577
  };
571
- this._sessionEvents.trigger(v, n);
578
+ this._sessionEvents.trigger(v, s);
572
579
  }
573
580
  });
574
581
  i(this, "_handleNotify", (e) => {
575
582
  switch (e.cmd) {
576
- case Hs: {
583
+ case kn: {
577
584
  const t = e;
578
585
  this._triggerChannelsNotify(t);
579
586
  break;
580
587
  }
581
- case Ws: {
588
+ case qn: {
582
589
  const t = e;
583
590
  this._triggerWebcastStartedNotify(t);
584
591
  break;
585
592
  }
586
- case ks: {
593
+ case Fn: {
587
594
  const t = e;
588
595
  this._triggerWebcastStoppedNotify(t);
589
596
  break;
590
597
  }
591
- case Bs: {
598
+ case Yn: {
592
599
  const t = e;
593
600
  this._triggerAddedToListModeratorsNotify(t);
594
601
  break;
595
602
  }
596
- case Vs: {
603
+ case xn: {
597
604
  const t = e;
598
605
  this._triggerRemovedFromListModeratorsNotify(t);
599
606
  break;
600
607
  }
601
- case Ys: {
608
+ case Gn: {
602
609
  const t = e;
603
610
  this._triggerParticipationAcceptingWordRequest(t);
604
611
  break;
605
612
  }
606
- case xs: {
613
+ case $n: {
607
614
  const t = e;
608
615
  this._triggerParticipationCancellingWordRequest(t);
609
616
  break;
610
617
  }
611
- case Gs: {
618
+ case Xn: {
612
619
  const t = e;
613
620
  this._triggerParticipantMoveRequestToStream(t);
614
621
  break;
615
622
  }
616
- case qs: {
623
+ case Bn: {
617
624
  this._triggerAccountChangedNotify();
618
625
  break;
619
626
  }
620
- case Fs: {
627
+ case Vn: {
621
628
  this._triggerAccountDeletedNotify();
622
629
  break;
623
630
  }
624
- case $s: {
631
+ case Jn: {
625
632
  const t = e;
626
633
  this._triggerConferenceParticipantTokenIssued(t);
627
634
  break;
628
635
  }
629
636
  default:
630
- ve("unknown cmd", e.cmd);
637
+ H("unknown cmd", e.cmd);
631
638
  }
632
639
  });
633
640
  i(this, "_triggerRemovedFromListModeratorsNotify", ({
@@ -637,7 +644,7 @@ class on {
637
644
  conference: e
638
645
  };
639
646
  this._uaEvents.trigger(
640
- ce,
647
+ _e,
641
648
  t
642
649
  );
643
650
  });
@@ -645,47 +652,47 @@ class on {
645
652
  const t = {
646
653
  conference: e
647
654
  };
648
- this._uaEvents.trigger(ae, t);
655
+ this._uaEvents.trigger(ce, t);
649
656
  });
650
657
  i(this, "_triggerWebcastStartedNotify", ({ body: { conference: e, type: t } }) => {
651
- const s = {
658
+ const n = {
652
659
  conference: e,
653
660
  type: t
654
661
  };
655
- this._uaEvents.trigger(le, s);
662
+ this._uaEvents.trigger(Te, n);
656
663
  });
657
664
  i(this, "_triggerWebcastStoppedNotify", ({ body: { conference: e, type: t } }) => {
658
- const s = {
665
+ const n = {
659
666
  conference: e,
660
667
  type: t
661
668
  };
662
- this._uaEvents.trigger(Te, s);
669
+ this._uaEvents.trigger(Se, n);
663
670
  });
664
671
  i(this, "_triggerAccountChangedNotify", () => {
665
- this._uaEvents.trigger(Se, void 0);
672
+ this._uaEvents.trigger(ue, void 0);
666
673
  });
667
674
  i(this, "_triggerAccountDeletedNotify", () => {
668
- this._uaEvents.trigger(ue, void 0);
675
+ this._uaEvents.trigger(Ce, void 0);
669
676
  });
670
677
  i(this, "_triggerConferenceParticipantTokenIssued", ({
671
- body: { conference: e, participant: t, jwt: s }
678
+ body: { conference: e, participant: t, jwt: n }
672
679
  }) => {
673
- const n = {
680
+ const s = {
674
681
  conference: e,
675
682
  participant: t,
676
- jwt: s
683
+ jwt: n
677
684
  };
678
685
  this._uaEvents.trigger(
679
686
  Ne,
680
- n
687
+ s
681
688
  );
682
689
  });
683
690
  i(this, "_triggerChannelsNotify", (e) => {
684
- const t = e.input, s = e.output, n = {
691
+ const t = e.input, n = e.output, s = {
685
692
  inputChannels: t,
686
- outputChannels: s
693
+ outputChannels: n
687
694
  };
688
- this._uaEvents.trigger(ee, n);
695
+ this._uaEvents.trigger(te, s);
689
696
  });
690
697
  i(this, "_triggerParticipationAcceptingWordRequest", ({
691
698
  body: { conference: e }
@@ -693,7 +700,7 @@ class on {
693
700
  const t = {
694
701
  conference: e
695
702
  };
696
- this._uaEvents.trigger(he, t);
703
+ this._uaEvents.trigger(le, t);
697
704
  });
698
705
  i(this, "_triggerParticipationCancellingWordRequest", ({
699
706
  body: { conference: e }
@@ -712,74 +719,74 @@ class on {
712
719
  this._uaEvents.trigger(Ee, t);
713
720
  });
714
721
  i(this, "_triggerEnterRoom", (e) => {
715
- const t = e.getHeader(xt), s = e.getHeader(Kt);
716
- this._sessionEvents.trigger(Q, { room: t, participantName: s });
722
+ const t = e.getHeader(xt), n = e.getHeader(Kt);
723
+ this._sessionEvents.trigger(j, { room: t, participantName: n });
717
724
  });
718
725
  i(this, "_triggerShareState", (e) => {
719
726
  const t = e.getHeader(R);
720
727
  this._sessionEvents.trigger(M, t);
721
728
  });
722
729
  i(this, "_maybeTriggerParticipantMoveRequestToSpectators", (e) => {
723
- e.getHeader(as) === rt && this._sessionEvents.trigger(_e, void 0);
730
+ e.getHeader(cn) === ot && this._sessionEvents.trigger(he, void 0);
724
731
  });
725
732
  i(this, "_triggerMainCamControl", (e) => {
726
- const t = e.getHeader(Zt), s = e.getHeader(Me), n = s === k.ADMIN_SYNC_FORCED;
733
+ const t = e.getHeader(Zt), n = e.getHeader(ye), s = n === q.ADMIN_SYNC_FORCED;
727
734
  if (t === I.ADMIN_START_MAIN_CAM) {
728
- this._sessionEvents.trigger(ie, { isSyncForced: n });
735
+ this._sessionEvents.trigger(re, { isSyncForced: s });
729
736
  return;
730
737
  }
731
738
  if (t === I.ADMIN_STOP_MAIN_CAM) {
732
- this._sessionEvents.trigger(ne, { isSyncForced: n });
739
+ this._sessionEvents.trigger(ie, { isSyncForced: s });
733
740
  return;
734
741
  }
735
- (t === I.RESUME_MAIN_CAM || t === I.PAUSE_MAIN_CAM) && s && this._sessionEvents.trigger(y, { isSyncForced: n });
736
- const o = e.getHeader(ts);
742
+ (t === I.RESUME_MAIN_CAM || t === I.PAUSE_MAIN_CAM) && n && this._sessionEvents.trigger(y, { isSyncForced: s });
743
+ const o = e.getHeader(tn);
737
744
  this._sessionEvents.trigger(se, {
738
745
  mainCam: t,
739
746
  resolutionMainCam: o
740
747
  });
741
748
  });
742
749
  i(this, "_triggerMicControl", (e) => {
743
- const t = e.getHeader(es), n = e.getHeader(Me) === k.ADMIN_SYNC_FORCED;
744
- t === W.ADMIN_START_MIC ? this._sessionEvents.trigger(oe, { isSyncForced: n }) : t === W.ADMIN_STOP_MIC && this._sessionEvents.trigger(re, { isSyncForced: n });
750
+ const t = e.getHeader(en), s = e.getHeader(ye) === q.ADMIN_SYNC_FORCED;
751
+ t === k.ADMIN_START_MIC ? this._sessionEvents.trigger(ae, { isSyncForced: s }) : t === k.ADMIN_STOP_MIC && this._sessionEvents.trigger(oe, { isSyncForced: s });
745
752
  });
746
753
  i(this, "_triggerUseLicense", (e) => {
747
754
  const t = e.getHeader(jt);
748
- this._sessionEvents.trigger(j, t);
755
+ this._sessionEvents.trigger(K, t);
749
756
  });
750
757
  i(this, "_handleNewInfo", (e) => {
751
758
  const { originator: t } = e;
752
759
  if (t !== "remote")
753
760
  return;
754
- const { request: s } = e, n = s.getHeader(Yt);
755
- if (n)
756
- switch (n) {
761
+ const { request: n } = e, s = n.getHeader(Yt);
762
+ if (s)
763
+ switch (s) {
757
764
  case Gt: {
758
- this._triggerEnterRoom(s), this._maybeTriggerChannels(s);
765
+ this._triggerEnterRoom(n), this._maybeTriggerChannels(n);
759
766
  break;
760
767
  }
761
- case cs: {
762
- this._maybeHandleNotify(s);
768
+ case _n: {
769
+ this._maybeHandleNotify(n);
763
770
  break;
764
771
  }
765
- case P: {
766
- this._triggerShareState(s);
772
+ case O: {
773
+ this._triggerShareState(n);
767
774
  break;
768
775
  }
769
- case pe: {
770
- this._triggerMainCamControl(s);
776
+ case De: {
777
+ this._triggerMainCamControl(n);
771
778
  break;
772
779
  }
773
780
  case zt: {
774
- this._triggerMicControl(s);
781
+ this._triggerMicControl(n);
775
782
  break;
776
783
  }
777
784
  case Qt: {
778
- this._triggerUseLicense(s);
785
+ this._triggerUseLicense(n);
779
786
  break;
780
787
  }
781
- case os: {
782
- this._maybeTriggerParticipantMoveRequestToSpectators(s);
788
+ case an: {
789
+ this._maybeTriggerParticipantMoveRequestToSpectators(n);
783
790
  break;
784
791
  }
785
792
  }
@@ -788,17 +795,17 @@ class on {
788
795
  this._maybeHandleNotify(e);
789
796
  });
790
797
  i(this, "_maybeHandleNotify", (e) => {
791
- const t = e.getHeader(Es);
798
+ const t = e.getHeader(En);
792
799
  if (t) {
793
- const s = JSON.parse(t);
794
- this._handleNotify(s);
800
+ const n = JSON.parse(t);
801
+ this._handleNotify(n);
795
802
  }
796
803
  });
797
804
  i(this, "_handleEnded", (e) => {
798
805
  const { originator: t } = e;
799
- t === we && this._sessionEvents.trigger(te, e), this._restoreSession();
806
+ t === we && this._sessionEvents.trigger(ne, e), this._restoreSession();
800
807
  });
801
- this.JsSIP = e, this._sessionEvents = new Oe(Et), this._uaEvents = new Oe(ct), this._cancelableConnect = new C(
808
+ this.JsSIP = e, this._sessionEvents = new Pe(Et), this._uaEvents = new Pe(_t), this._cancelableConnect = new N(
802
809
  this._connect,
803
810
  {
804
811
  moduleName: g,
@@ -806,39 +813,39 @@ class on {
806
813
  this._cancelableInitUa.cancelRequest(), this._cancelableDisconnect.cancelRequest();
807
814
  }
808
815
  }
809
- ), this._cancelableInitUa = new C(
816
+ ), this._cancelableInitUa = new N(
810
817
  this._initUa,
811
818
  { moduleName: g }
812
- ), this._cancelableDisconnect = new C(
819
+ ), this._cancelableDisconnect = new N(
813
820
  this._disconnect,
814
821
  { moduleName: g }
815
- ), this._cancelableSet = new C(this._set, {
822
+ ), this._cancelableSet = new N(this._set, {
816
823
  moduleName: g
817
- }), this._cancelableCall = new C(
824
+ }), this._cancelableCall = new N(
818
825
  this._call,
819
826
  { moduleName: g }
820
- ), this._cancelableAnswer = new C(this._answer, { moduleName: g }), this._cancelableSendDTMF = new C(this._sendDTMF, { moduleName: g }), this.onSession(M, this._handleShareState), this.onSession(ge, this._handleNewInfo), this.on($, this._handleSipEvent), this.onSession(A, this._handleEnded), this.onSession(p, this._handleEnded);
827
+ ), this._cancelableAnswer = new N(this._answer, { moduleName: g }), this._cancelableSendDTMF = new N(this._sendDTMF, { moduleName: g }), this.onSession(M, this._handleShareState), this.onSession(Ae, this._handleNewInfo), this.on(X, this._handleSipEvent), this.onSession(A, this._handleEnded), this.onSession(P, this._handleEnded);
821
828
  }
822
829
  async register() {
823
830
  return new Promise((e, t) => {
824
- this.isRegisterConfig && this.ua ? (this.ua.on(f, e), this.ua.on(O, t), this.ua.register()) : t(new Error("Config is not registered"));
831
+ this.isRegisterConfig && this.ua ? (this.ua.on(f, e), this.ua.on(p, t), this.ua.register()) : t(new Error("Config is not registered"));
825
832
  });
826
833
  }
827
834
  async unregister() {
828
835
  return new Promise((e, t) => {
829
- this.isRegistered && this.ua ? (this.ua.on(G, e), this.ua.unregister()) : t(new Error("ua is not registered"));
836
+ this.isRegistered && this.ua ? (this.ua.on($, e), this.ua.unregister()) : t(new Error("ua is not registered"));
830
837
  });
831
838
  }
832
- async sendOptions(e, t, s) {
839
+ async sendOptions(e, t, n) {
833
840
  if (!this.ua)
834
841
  throw new Error("is not connected");
835
- return new Promise((n, o) => {
842
+ return new Promise((s, o) => {
836
843
  try {
837
844
  this.ua.sendOptions(e, t, {
838
- extraHeaders: s,
845
+ extraHeaders: n,
839
846
  eventHandlers: {
840
847
  succeeded: () => {
841
- n();
848
+ s();
842
849
  },
843
850
  failed: o
844
851
  }
@@ -849,33 +856,33 @@ class on {
849
856
  });
850
857
  }
851
858
  async ping(e, t) {
852
- var n;
853
- if (!((n = this.ua) != null && n.configuration.uri))
859
+ var s;
860
+ if (!((s = this.ua) != null && s.configuration.uri))
854
861
  throw new Error("is not connected");
855
- const s = this.ua.configuration.uri;
856
- return this.sendOptions(s, e, t);
862
+ const n = this.ua.configuration.uri;
863
+ return this.sendOptions(n, e, t);
857
864
  }
858
865
  async checkTelephony({
859
866
  userAgent: e,
860
867
  displayName: t,
861
- sipServerUrl: s,
862
- sipWebSocketServerURL: n
868
+ sipServerUrl: n,
869
+ sipWebSocketServerURL: s
863
870
  }) {
864
871
  return new Promise((o, a) => {
865
872
  const { configuration: c } = this.createUaConfiguration({
866
- sipWebSocketServerURL: n,
873
+ sipWebSocketServerURL: s,
867
874
  displayName: t,
868
875
  userAgent: e,
869
- sipServerUrl: s
870
- }), E = this._createUa(c), _ = () => {
871
- const l = new Error("Telephony is not available");
872
- a(l);
876
+ sipServerUrl: n
877
+ }), _ = this._createUa(c), E = () => {
878
+ const d = new Error("Telephony is not available");
879
+ a(d);
873
880
  };
874
- E.once(S, _);
881
+ _.once(S, E);
875
882
  const h = () => {
876
- E.removeAllListeners(), E.once(S, o), E.stop();
883
+ _.removeAllListeners(), _.once(S, o), _.stop();
877
884
  };
878
- E.once(m, h), E.start();
885
+ _.once(m, h), _.start();
879
886
  });
880
887
  }
881
888
  async replaceMediaStream(e, t) {
@@ -886,129 +893,155 @@ class on {
886
893
  async askPermissionToEnableCam(e = {}) {
887
894
  if (!this.session)
888
895
  throw new Error("No session established");
889
- const t = [us];
890
- return this.session.sendInfo(pe, void 0, {
896
+ const t = [Cn];
897
+ return this.session.sendInfo(De, void 0, {
891
898
  noTerminateWhenError: !0,
892
899
  ...e,
893
900
  extraHeaders: t
894
- }).catch((s) => {
895
- if (Os(s))
896
- throw s;
901
+ }).catch((n) => {
902
+ if (Pn(n))
903
+ throw n;
897
904
  });
898
905
  }
899
906
  get isPendingPresentation() {
900
907
  return !!this.promisePendingStartPresentation || !!this.promisePendingStopPresentation;
901
908
  }
909
+ async _sendPresentationWithDuplicatedCalls({
910
+ session: e,
911
+ stream: t,
912
+ presentationOptions: n,
913
+ options: s = {
914
+ callLimit: Wn
915
+ }
916
+ }) {
917
+ const o = async () => this._sendPresentation(e, t, n), a = () => !!this._streamPresentationCurrent;
918
+ return this._cancelableSendPresentationWithRepeatedCalls = Oe({
919
+ targetFunction: o,
920
+ isComplete: a,
921
+ isRejectAsValid: !0,
922
+ ...s
923
+ }), this._cancelableSendPresentationWithRepeatedCalls.then((c) => {
924
+ if (c instanceof MediaStream)
925
+ return c;
926
+ throw c;
927
+ });
928
+ }
902
929
  hasEqualConnectionConfiguration(e) {
903
- var n;
904
- const { configuration: t } = this.createUaConfiguration(e), s = (n = this.ua) == null ? void 0 : n.configuration;
905
- return (s == null ? void 0 : s.password) === t.password && (s == null ? void 0 : s.register) === t.register && (s == null ? void 0 : s.uri.toString()) === t.uri && (s == null ? void 0 : s.display_name) === t.display_name && (s == null ? void 0 : s.user_agent) === t.user_agent && (s == null ? void 0 : s.sockets) === t.sockets && (s == null ? void 0 : s.session_timers) === t.session_timers && (s == null ? void 0 : s.register_expires) === t.register_expires && (s == null ? void 0 : s.connection_recovery_min_interval) === t.connection_recovery_min_interval && (s == null ? void 0 : s.connection_recovery_max_interval) === t.connection_recovery_max_interval;
930
+ var s;
931
+ const { configuration: t } = this.createUaConfiguration(e), n = (s = this.ua) == null ? void 0 : s.configuration;
932
+ return (n == null ? void 0 : n.password) === t.password && (n == null ? void 0 : n.register) === t.register && (n == null ? void 0 : n.uri.toString()) === t.uri && (n == null ? void 0 : n.display_name) === t.display_name && (n == null ? void 0 : n.user_agent) === t.user_agent && (n == null ? void 0 : n.sockets) === t.sockets && (n == null ? void 0 : n.session_timers) === t.session_timers && (n == null ? void 0 : n.register_expires) === t.register_expires && (n == null ? void 0 : n.connection_recovery_min_interval) === t.connection_recovery_min_interval && (n == null ? void 0 : n.connection_recovery_max_interval) === t.connection_recovery_max_interval;
906
933
  }
907
934
  createUaConfiguration({
908
935
  user: e,
909
936
  password: t,
910
- sipWebSocketServerURL: s,
911
- displayName: n = "",
937
+ sipWebSocketServerURL: n,
938
+ displayName: s = "",
912
939
  sipServerUrl: o,
913
940
  register: a = !1,
914
941
  sessionTimers: c = !1,
915
- registerExpires: E = 60 * 5,
942
+ registerExpires: _ = 60 * 5,
916
943
  // 5 minutes in sec
917
- connectionRecoveryMinInterval: _ = 2,
944
+ connectionRecoveryMinInterval: E = 2,
918
945
  connectionRecoveryMaxInterval: h = 6,
919
- userAgent: l
946
+ userAgent: d
920
947
  }) {
921
948
  if (a && !t)
922
949
  throw new Error("password is required for authorized connection");
923
- const d = a && e ? e.trim() : `${As()}`, T = Cs(o), u = T(d), N = new this.JsSIP.WebSocketInterface(s);
950
+ const l = a && e ? e.trim() : `${Rn()}`, T = gn(o), u = T(l), C = new this.JsSIP.WebSocketInterface(n);
924
951
  return {
925
952
  configuration: {
926
953
  password: t,
927
954
  register: a,
928
955
  uri: u,
929
- display_name: ye(n),
930
- user_agent: l,
956
+ display_name: be(s),
957
+ user_agent: d,
931
958
  sdp_semantics: "unified-plan",
932
- sockets: [N],
959
+ sockets: [C],
933
960
  session_timers: c,
934
- register_expires: E,
935
- connection_recovery_min_interval: _,
961
+ register_expires: _,
962
+ connection_recovery_min_interval: E,
936
963
  connection_recovery_max_interval: h
937
964
  },
938
965
  helpers: {
939
- socket: N,
966
+ socket: C,
940
967
  getSipServerUrl: T
941
968
  }
942
969
  };
943
970
  }
944
971
  async _sendPresentation(e, t, {
945
- maxBitrate: s,
946
- degradationPreference: n,
972
+ maxBitrate: n,
973
+ degradationPreference: s,
947
974
  isNeedReinvite: o = !0,
948
975
  isP2P: a = !1
949
976
  }) {
950
- const c = H(t);
977
+ const c = W(t);
951
978
  this._streamPresentationCurrent = c;
952
- const E = a ? [ls] : [_s], _ = e.sendInfo(P, void 0, {
953
- extraHeaders: E
979
+ const _ = a ? [Tn] : [hn], E = e.sendInfo(O, void 0, {
980
+ extraHeaders: _
954
981
  }).then(async () => e.startPresentation(
955
982
  c,
956
983
  o,
957
- n
984
+ s
958
985
  )).then(async () => {
959
986
  const { connection: h } = this;
960
- if (!h || s === void 0)
987
+ if (!h || n === void 0)
961
988
  return;
962
- const l = h.getSenders();
963
- await ws(l, t, s);
989
+ const d = h.getSenders();
990
+ await wn(d, t, n);
964
991
  }).then(() => t).catch((h) => {
965
- throw this._sessionEvents.trigger(U, h), h;
992
+ throw this._removeStreamPresentationCurrent(), this._sessionEvents.trigger(U, h), h;
966
993
  });
967
- return this.promisePendingStartPresentation = _, _.finally(() => {
994
+ return this.promisePendingStartPresentation = E, E.finally(() => {
968
995
  this.promisePendingStartPresentation = void 0;
969
996
  });
970
997
  }
971
998
  async startPresentation(e, {
972
999
  isNeedReinvite: t = !0,
973
- isP2P: s = !1,
974
- maxBitrate: n,
1000
+ isP2P: n = !1,
1001
+ maxBitrate: s,
975
1002
  degradationPreference: o
976
- } = {}) {
977
- const a = this.establishedSession;
978
- if (!a)
1003
+ } = {}, a) {
1004
+ const c = this.establishedSession;
1005
+ if (!c)
979
1006
  throw new Error("No session established");
980
1007
  if (this._streamPresentationCurrent)
981
1008
  throw new Error("Presentation is already started");
982
- return s && await this.sendMustStopPresentation(a), this._sendPresentation(a, e, {
983
- isNeedReinvite: t,
984
- isP2P: s,
985
- maxBitrate: n,
986
- degradationPreference: o
1009
+ return n && await this.sendMustStopPresentation(c), this._sendPresentationWithDuplicatedCalls({
1010
+ session: c,
1011
+ stream: e,
1012
+ presentationOptions: {
1013
+ isNeedReinvite: t,
1014
+ isP2P: n,
1015
+ maxBitrate: s,
1016
+ degradationPreference: o
1017
+ },
1018
+ options: a
987
1019
  });
988
1020
  }
989
1021
  async sendMustStopPresentation(e) {
990
- await e.sendInfo(P, void 0, {
991
- extraHeaders: [ds]
1022
+ await e.sendInfo(O, void 0, {
1023
+ extraHeaders: [dn]
992
1024
  });
993
1025
  }
994
1026
  async stopPresentation({
995
1027
  isP2P: e = !1
996
1028
  } = {}) {
1029
+ this._cancelSendPresentationWithRepeatedCalls();
997
1030
  const t = this._streamPresentationCurrent;
998
- let s = this.promisePendingStartPresentation ?? Promise.resolve();
999
- const n = e ? [Ts] : [hs], o = this.establishedSession;
1000
- return o && t && (s = s.then(async () => o.sendInfo(P, void 0, {
1001
- extraHeaders: n
1031
+ let n = this.promisePendingStartPresentation ?? Promise.resolve();
1032
+ const s = e ? [Sn] : [ln], o = this.establishedSession;
1033
+ return o && t && (n = n.then(async () => o.sendInfo(O, void 0, {
1034
+ extraHeaders: s
1002
1035
  })).then(async () => o.stopPresentation(t)).catch((a) => {
1003
1036
  throw this._sessionEvents.trigger(U, a), a;
1004
- })), !o && t && this._sessionEvents.trigger(Ae, t), this.promisePendingStopPresentation = s, s.finally(() => {
1037
+ })), !o && t && this._sessionEvents.trigger(Re, t), this.promisePendingStopPresentation = n, n.finally(() => {
1005
1038
  this._resetPresentation();
1006
1039
  });
1007
1040
  }
1008
1041
  async updatePresentation(e, {
1009
1042
  isP2P: t = !1,
1010
- maxBitrate: s,
1011
- degradationPreference: n
1043
+ maxBitrate: n,
1044
+ degradationPreference: s
1012
1045
  } = {}) {
1013
1046
  const o = this.establishedSession;
1014
1047
  if (!o)
@@ -1017,13 +1050,19 @@ class on {
1017
1050
  throw new Error("Presentation has not started yet");
1018
1051
  return this.promisePendingStartPresentation && await this.promisePendingStartPresentation, this._sendPresentation(o, e, {
1019
1052
  isP2P: t,
1020
- maxBitrate: s,
1021
- degradationPreference: n,
1053
+ maxBitrate: n,
1054
+ degradationPreference: s,
1022
1055
  isNeedReinvite: !1
1023
1056
  });
1024
1057
  }
1058
+ _removeStreamPresentationCurrent() {
1059
+ delete this._streamPresentationCurrent;
1060
+ }
1025
1061
  _resetPresentation() {
1026
- delete this._streamPresentationCurrent, this.promisePendingStartPresentation = void 0, this.promisePendingStopPresentation = void 0;
1062
+ this._removeStreamPresentationCurrent(), this.promisePendingStartPresentation = void 0, this.promisePendingStopPresentation = void 0;
1063
+ }
1064
+ _cancelRequestsAndResetPresentation() {
1065
+ this._cancelSendPresentationWithRepeatedCalls(), this._resetPresentation();
1027
1066
  }
1028
1067
  on(e, t) {
1029
1068
  return this._uaEvents.on(e, t);
@@ -1064,18 +1103,18 @@ class on {
1064
1103
  getRemoteStreams() {
1065
1104
  if (!this.connection)
1066
1105
  return;
1067
- const t = this.connection.getReceivers().map(({ track: s }) => s);
1068
- return Rs(t) ? this._generateStreams(t) : this._generateAudioStreams(t);
1106
+ const t = this.connection.getReceivers().map(({ track: n }) => n);
1107
+ return In(t) ? this._generateStreams(t) : this._generateAudioStreams(t);
1069
1108
  }
1070
1109
  get connection() {
1071
1110
  var t;
1072
1111
  return (t = this.session) == null ? void 0 : t.connection;
1073
1112
  }
1074
1113
  get remoteCallerData() {
1075
- var e, t, s, n, o, a;
1114
+ var e, t, n, s, o, a;
1076
1115
  return {
1077
1116
  displayName: (t = (e = this.incomingSession) == null ? void 0 : e.remote_identity) == null ? void 0 : t.display_name,
1078
- host: (n = (s = this.incomingSession) == null ? void 0 : s.remote_identity) == null ? void 0 : n.uri.host,
1117
+ host: (s = (n = this.incomingSession) == null ? void 0 : n.remote_identity) == null ? void 0 : s.uri.host,
1079
1118
  incomingNumber: (a = (o = this.incomingSession) == null ? void 0 : o.remote_identity) == null ? void 0 : a.uri.user,
1080
1119
  session: this.incomingSession
1081
1120
  };
@@ -1100,27 +1139,27 @@ class on {
1100
1139
  return !!this.incomingSession;
1101
1140
  }
1102
1141
  _generateStream(e, t) {
1103
- const { id: s } = e, n = this._remoteStreams[s] || new MediaStream();
1104
- return t && n.addTrack(t), n.addTrack(e), this._remoteStreams[s] = n, n;
1142
+ const { id: n } = e, s = this._remoteStreams[n] || new MediaStream();
1143
+ return t && s.addTrack(t), s.addTrack(e), this._remoteStreams[n] = s, s;
1105
1144
  }
1106
1145
  _generateAudioStream(e) {
1107
- const { id: t } = e, s = this._remoteStreams[t] || new MediaStream();
1108
- return s.addTrack(e), this._remoteStreams[t] = s, s;
1146
+ const { id: t } = e, n = this._remoteStreams[t] || new MediaStream();
1147
+ return n.addTrack(e), this._remoteStreams[t] = n, n;
1109
1148
  }
1110
1149
  _generateStreams(e) {
1111
1150
  const t = [];
1112
- return e.forEach((s, n) => {
1113
- if (s.kind === "audio")
1151
+ return e.forEach((n, s) => {
1152
+ if (n.kind === "audio")
1114
1153
  return;
1115
- const o = s, a = e[n - 1];
1154
+ const o = n, a = e[s - 1];
1116
1155
  let c;
1117
1156
  a && a.kind === "audio" && (c = a);
1118
- const E = this._generateStream(o, c);
1119
- t.push(E);
1157
+ const _ = this._generateStream(o, c);
1158
+ t.push(_);
1120
1159
  }), t;
1121
1160
  }
1122
1161
  _generateAudioStreams(e) {
1123
- return e.map((s) => this._generateAudioStream(s));
1162
+ return e.map((n) => this._generateAudioStream(n));
1124
1163
  }
1125
1164
  _cancelRequests() {
1126
1165
  this._cancelActionsRequests(), this._cancelCallRequests(), this._cancelConnectWithRepeatedCalls();
@@ -1129,6 +1168,10 @@ class on {
1129
1168
  var e;
1130
1169
  (e = this._cancelableConnectWithRepeatedCalls) == null || e.cancel();
1131
1170
  }
1171
+ _cancelSendPresentationWithRepeatedCalls() {
1172
+ var e;
1173
+ (e = this._cancelableSendPresentationWithRepeatedCalls) == null || e.cancel();
1174
+ }
1132
1175
  _cancelCallRequests() {
1133
1176
  this._cancelableCall.cancelRequest(), this._cancelableAnswer.cancelRequest();
1134
1177
  }
@@ -1144,30 +1187,30 @@ class on {
1144
1187
  async sendChannels({ inputChannels: e, outputChannels: t }) {
1145
1188
  if (!this.session)
1146
1189
  throw new Error("No session established");
1147
- const s = `${Pe}: ${e}`, n = `${De}: ${t}`, o = [
1148
- s,
1149
- n
1190
+ const n = `${Me}: ${e}`, s = `${ve}: ${t}`, o = [
1191
+ n,
1192
+ s
1150
1193
  ];
1151
1194
  return this.session.sendInfo($t, void 0, { extraHeaders: o });
1152
1195
  }
1153
- async sendMediaState({ cam: e, mic: t }, s = {}) {
1196
+ async sendMediaState({ cam: e, mic: t }, n = {}) {
1154
1197
  if (!this.session)
1155
1198
  throw new Error("No session established");
1156
- const n = `${ss}: currentstate`, o = `${is}: ${Number(e)}`, a = `${rs}: ${Number(t)}`, c = [
1157
- n,
1199
+ const s = `${nn}: currentstate`, o = `${rn}: ${Number(e)}`, a = `${on}: ${Number(t)}`, c = [
1200
+ s,
1158
1201
  o,
1159
1202
  a
1160
1203
  ];
1161
1204
  return this.session.sendInfo(Xt, void 0, {
1162
1205
  noTerminateWhenError: !0,
1163
- ...s,
1206
+ ...n,
1164
1207
  extraHeaders: c
1165
1208
  });
1166
1209
  }
1167
1210
  async _sendRefusalToTurnOn(e, t = {}) {
1168
1211
  if (!this.session)
1169
1212
  throw new Error("No session established");
1170
- const c = [`${ns}: ${e === "mic" ? 0 : 1}`];
1213
+ const c = [`${sn}: ${e === "mic" ? 0 : 1}`];
1171
1214
  return this.session.sendInfo(Jt, void 0, {
1172
1215
  noTerminateWhenError: !0,
1173
1216
  ...t,
@@ -1189,19 +1232,19 @@ export {
1189
1232
  Ft as B,
1190
1233
  I as E,
1191
1234
  Mt as N,
1192
- Ue as R,
1193
- on as S,
1194
- ct as U,
1195
- en as a,
1196
- sn as b,
1197
- Zs as c,
1198
- nn as d,
1199
- tn as e,
1200
- W as f,
1201
- k as g,
1202
- rn as h,
1203
- Ns as i,
1235
+ Le as R,
1236
+ as as S,
1237
+ _t as U,
1238
+ ns as a,
1239
+ is as b,
1240
+ ts as c,
1241
+ rs as d,
1242
+ ss as e,
1243
+ k as f,
1244
+ q as g,
1245
+ os as h,
1246
+ Nn as i,
1204
1247
  Et as j,
1205
- ve as l,
1206
- ys as s
1248
+ H as l,
1249
+ bn as s
1207
1250
  };