@16x/webphone-sdk 3.1.4 → 3.1.6

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,5 +1,5 @@
1
1
  import { i as e, t } from "./SharedWorkerProtocol-DKVQ5-po.js";
2
- import { r as n, t as r } from "./Diagnostics-BlstRMt3.js";
2
+ import { r as n, t as r } from "./Diagnostics-D4metmcj.js";
3
3
  //#region src/events/TypedEventBus.ts
4
4
  var i = class {
5
5
  handlers = /* @__PURE__ */ new Map();
@@ -282,7 +282,7 @@ var c = class extends e {
282
282
  retryable: !1
283
283
  };
284
284
  }
285
- }, m = [
285
+ }, ee = [
286
286
  "progress",
287
287
  "accepted",
288
288
  "confirmed",
@@ -290,7 +290,7 @@ var c = class extends e {
290
290
  "failed",
291
291
  "hold",
292
292
  "unhold"
293
- ], h = 3e4, g = class {
293
+ ], te = 3e4, m = class {
294
294
  options;
295
295
  currentState = "new";
296
296
  sessionUnsubscribers = [];
@@ -306,7 +306,7 @@ var c = class extends e {
306
306
  constructor(t) {
307
307
  this.options = t, this.id = t.id, this.destination = t.destination, this.platform = t.platform, this.capabilities = t.capabilities ?? /* @__PURE__ */ new Set();
308
308
  try {
309
- m.forEach((e) => {
309
+ ee.forEach((e) => {
310
310
  this.sessionUnsubscribers.push(t.session.on(e, (t) => this.handleSessionEvent(e, t)));
311
311
  });
312
312
  } catch (n) {
@@ -342,6 +342,7 @@ var c = class extends e {
342
342
  } catch (e) {
343
343
  throw this.incomingOperation = void 0, this.finishFailedIncomingOperation(e), this.operationError(e);
344
344
  }
345
+ this.transitionIfAllowed("connecting", void 0, "accepted");
345
346
  }
346
347
  async reject(e = {}, t) {
347
348
  this.assertNotDisposed(), this.assertOwner(t), this.assertIncomingCall(), this.assertIncomingOperationAvailable(), this.incomingOperation = "reject";
@@ -366,13 +367,13 @@ var c = class extends e {
366
367
  this.assertState("active"), this.assertCapability("dtmf"), this.invoke(() => this.options.session.sendDtmf(e));
367
368
  }
368
369
  async transfer(e, t) {
369
- if (this.assertNotDisposed(), this.assertOwner(t), this.assertTransferCapability(), this.assertState("active"), this.assertCapability("blind_transfer"), !v(e) || e.target.trim() === "") throw this.operationError();
370
+ if (this.assertNotDisposed(), this.assertOwner(t), this.assertTransferCapability(), this.assertState("active"), this.assertCapability("blind_transfer"), !ne(e) || e.target.trim() === "") throw this.operationError();
370
371
  this.invoke(() => this.options.session.refer(e.target.trim()));
371
372
  }
372
373
  async hangup(e) {
373
- if (this.assertNotDisposed(), this.assertOwner(e), _(this.currentState)) throw this.operationError();
374
+ if (this.assertNotDisposed(), this.assertOwner(e), h(this.currentState)) throw this.operationError();
374
375
  try {
375
- this.options.session.terminate(), this.transitionTo("ended");
376
+ this.options.session.terminate(), h(this.currentState) || this.transitionTo("ended");
376
377
  } catch (e) {
377
378
  throw this.operationError(e);
378
379
  }
@@ -400,7 +401,7 @@ var c = class extends e {
400
401
  }
401
402
  dispose() {
402
403
  if (!this.disposed) {
403
- if (this.rejectPendingOperation(), this.incomingOperation = void 0, this.disposed = !0, !_(this.currentState)) try {
404
+ if (this.rejectPendingOperation(), this.incomingOperation = void 0, this.disposed = !0, !h(this.currentState)) try {
404
405
  this.options.session.terminate();
405
406
  } catch (e) {
406
407
  this.reportOperationError(e);
@@ -412,7 +413,7 @@ var c = class extends e {
412
413
  }
413
414
  }
414
415
  handleSessionEvent(e, t) {
415
- if ((e === "accepted" || e === "confirmed" || e === "ended" || e === "failed") && (this.incomingOperation = void 0), !(this.disposed || _(this.currentState))) switch (e) {
416
+ if ((e === "accepted" || e === "confirmed" || e === "ended" || e === "failed") && (this.incomingOperation = void 0), !(this.disposed || h(this.currentState))) switch (e) {
416
417
  case "progress":
417
418
  this.transitionIfAllowed("ringing", t, e);
418
419
  break;
@@ -447,7 +448,7 @@ var c = class extends e {
447
448
  if (this.currentState === e) return;
448
449
  if (!o(this.currentState, e)) throw this.operationError();
449
450
  let n = this.currentState;
450
- this.currentState = e, _(e) && this.rejectPendingOperation();
451
+ this.currentState = e, h(e) && this.rejectPendingOperation();
451
452
  try {
452
453
  this.options.onStateChanged?.({
453
454
  callId: this.id,
@@ -455,7 +456,7 @@ var c = class extends e {
455
456
  to: e
456
457
  }, t);
457
458
  } catch {} finally {
458
- _(e) && this.dispose();
459
+ h(e) && this.dispose();
459
460
  }
460
461
  }
461
462
  startPendingOperation(e, t, n) {
@@ -467,7 +468,7 @@ var c = class extends e {
467
468
  resolve: r,
468
469
  reject: i
469
470
  };
470
- this.pendingOperation = a, a.timer = setTimeout(() => this.timeoutPendingOperation(a), h);
471
+ this.pendingOperation = a, a.timer = setTimeout(() => this.timeoutPendingOperation(a), te);
471
472
  let o;
472
473
  try {
473
474
  o = n();
@@ -480,7 +481,7 @@ var c = class extends e {
480
481
  }
481
482
  resolvePendingOperation(e) {
482
483
  if (this.pendingOperation === e) {
483
- if (this.clearPendingTimer(e), this.pendingOperation = void 0, this.disposed || _(this.currentState)) {
484
+ if (this.clearPendingTimer(e), this.pendingOperation = void 0, this.disposed || h(this.currentState)) {
484
485
  e.reject(this.operationError());
485
486
  return;
486
487
  }
@@ -515,6 +516,7 @@ var c = class extends e {
515
516
  } catch {}
516
517
  }
517
518
  finishFailedIncomingOperation(e) {
519
+ this.reportOperationError(e);
518
520
  try {
519
521
  this.options.session.terminate();
520
522
  } catch (t) {
@@ -579,22 +581,32 @@ var c = class extends e {
579
581
  });
580
582
  }
581
583
  };
582
- function _(e) {
584
+ function h(e) {
583
585
  return e === "ended" || e === "failed";
584
586
  }
585
- function v(e) {
587
+ function ne(e) {
586
588
  return typeof e == "object" && !!e && e.type === "blind" && typeof e.target == "string";
587
589
  }
588
590
  //#endregion
589
591
  //#region src/core/callId.ts
590
- var y = 0;
591
- function b() {
592
- return y += 1, `call_${Date.now().toString(36)}_${y.toString(36)}`;
592
+ var g = 0;
593
+ function _() {
594
+ return g += 1, `call_${Date.now().toString(36)}_${g.toString(36)}`;
595
+ }
596
+ //#endregion
597
+ //#region src/core/userData.ts
598
+ var re = "X-User-Data", v = /[^\x20-\x7E]/, y = "userdata 只能是可见 ASCII(不能有换行/制表/中文):换行会构成 SIP 头注入;要传中文或 JSON 请调用方先 encodeURIComponent / base64,再在平台侧解回来";
599
+ function b(t) {
600
+ if (typeof t != "string") return [];
601
+ let n = t.trim();
602
+ if (n === "") return [];
603
+ if (v.test(n)) throw new e("CALL_INVALID_USERDATA", "call", !1, { cause: y });
604
+ return [`${re}: ${n}`];
593
605
  }
594
606
  //#endregion
595
607
  //#region src/core/CallManager.ts
596
608
  var x = class {
597
- events = new ee();
609
+ events = new ie();
598
610
  calls = /* @__PURE__ */ new Map();
599
611
  options;
600
612
  incomingUnsubscribe;
@@ -627,53 +639,54 @@ var x = class {
627
639
  this.assertNotDisposed();
628
640
  let r = this.operationGeneration, i = t.destination.trim();
629
641
  if (i === "") throw new e("CALL_INVALID_DESTINATION", "call", !1);
642
+ let a = b(t.userdata);
630
643
  this.requireCapability(n, "outbound");
631
- let a = this.callLimit(n);
632
- if (this.options.platform === "mobile-web" && this.calls.size + this.pendingDialCount >= a) throw this.capabilityError();
633
- if (this.calls.size + this.pendingDialCount >= a || this.pendingDestinations.has(i) || [...this.calls.values()].some((e) => e.destination === i)) throw new e("CALL_ALREADY_EXISTS", "call", !1);
644
+ let o = this.callLimit(n);
645
+ if (this.options.platform === "mobile-web" && this.calls.size + this.pendingDialCount >= o) throw this.capabilityError();
646
+ if (this.calls.size + this.pendingDialCount >= o || this.pendingDestinations.has(i) || [...this.calls.values()].some((e) => e.destination === i)) throw new e("CALL_ALREADY_EXISTS", "call", !1);
634
647
  this.pendingDialCount += 1, this.pendingDestinations.add(i);
635
- let o = b(), s;
648
+ let s = _(), c;
636
649
  try {
637
- s = await this.holdActiveCallForNewCall(), this.assertGeneration(r, o);
650
+ c = await this.holdActiveCallForNewCall(), this.assertGeneration(r, s);
638
651
  let e;
639
652
  try {
640
- e = this.options.sip.dial(i, this.dialOptions(o, n, t.type));
653
+ e = this.options.sip.dial(i, this.dialOptions(s, n, t.type, a));
641
654
  } catch (e) {
642
- throw this.dialError(e, o);
655
+ throw this.dialError(e, s);
643
656
  }
644
- this.assertGeneration(r, o);
645
- let a;
657
+ this.assertGeneration(r, s);
658
+ let o;
646
659
  try {
647
- a = new g({
648
- id: o,
660
+ o = new m({
661
+ id: s,
649
662
  destination: i,
650
663
  platform: this.options.platform,
651
664
  capabilities: this.effectiveCapabilities(n),
652
665
  session: e,
653
- onStateChanged: (e, t) => this.handleStateChanged(a, e, t),
666
+ onStateChanged: (e, t) => this.handleStateChanged(o, e, t),
654
667
  onError: (e) => this.events.emit("error", { error: e }),
655
- onDisposed: () => this.handleDisposed(a)
668
+ onDisposed: () => this.handleDisposed(o)
656
669
  });
657
670
  } catch (e) {
658
- throw this.dialError(e, o);
671
+ throw this.dialError(e, s);
659
672
  }
660
- if (!this.isCurrentGeneration(r)) throw a.dispose(), this.callOperationError(a.id);
661
- this.calls.set(a.id, a), this.callSessions.set(a.id, e), this.options.onCallCreated?.(a.id, e);
673
+ if (!this.isCurrentGeneration(r)) throw o.dispose(), this.callOperationError(o.id);
674
+ this.calls.set(o.id, o), this.callSessions.set(o.id, e), this.options.onCallCreated?.(o.id, e);
662
675
  try {
663
- a.beginOutbound();
676
+ o.beginOutbound();
664
677
  } catch (e) {
665
- throw a.dispose(), this.calls.delete(a.id), this.callSessions.delete(a.id), this.dialError(e, a.id);
678
+ throw o.dispose(), this.calls.delete(o.id), this.callSessions.delete(o.id), this.dialError(e, o.id);
666
679
  }
667
- if (!this.isCurrentGeneration(r)) throw a.dispose(), this.calls.delete(a.id), this.callSessions.delete(a.id), this.callOperationError(a.id);
680
+ if (!this.isCurrentGeneration(r)) throw o.dispose(), this.calls.delete(o.id), this.callSessions.delete(o.id), this.callOperationError(o.id);
668
681
  return this.events.emit("call.created", {
669
- callId: a.id,
670
- state: a.state
671
- }), a;
682
+ callId: o.id,
683
+ state: o.state
684
+ }), o;
672
685
  } catch (e) {
673
- if (this.isCurrentGeneration(r) && s !== void 0 && this.isManagedCall(s) && s.state === "held") try {
674
- await s.resume();
686
+ if (this.isCurrentGeneration(r) && c !== void 0 && this.isManagedCall(c) && c.state === "held") try {
687
+ await c.resume();
675
688
  } catch (t) {
676
- throw this.compensationError(s.id, void 0, e, t);
689
+ throw this.compensationError(c.id, void 0, e, t);
677
690
  }
678
691
  throw e;
679
692
  } finally {
@@ -826,10 +839,10 @@ var x = class {
826
839
  }
827
840
  t.to === "held" && this.activeCallId === e.id && this.automaticActiveTransition?.previous.id !== e.id && (this.activeCallId = null, this.events.emit("call.activeChanged", { callId: null })), (t.to === "ended" || t.to === "failed") && (this.calls.delete(e.id), this.callSessions.delete(e.id), this.callOwners.delete(e.id), this.ownerLostCalls.delete(e.id), this.activeCallId === e.id && this.automaticActiveTransition?.previous.id !== e.id && (this.activeCallId = null, this.events.emit("call.activeChanged", { callId: null })), this.notifyCallTerminal(e.id), t.to === "ended" ? this.events.emit("call.ended", {
828
841
  callId: e.id,
829
- reason: te(n)
842
+ reason: ae(n)
830
843
  }) : this.events.emit("call.failed", {
831
844
  callId: e.id,
832
- error: ne(n, e.id)
845
+ error: oe(n, e.id)
833
846
  }));
834
847
  }
835
848
  async switchAutomaticActiveCall(e, t, n) {
@@ -895,7 +908,7 @@ var x = class {
895
908
  }
896
909
  handleIncoming(t) {
897
910
  if (this.disposed) return;
898
- let n = b(), r = this.incomingSessionSnapshot;
911
+ let n = _(), r = this.incomingSessionSnapshot;
899
912
  if (r === void 0 || !r.policy.incomingEnabled || !this.effectiveCapabilities(r).has("inbound")) {
900
913
  this.terminateUnsupportedIncoming(t), this.events.emit("error", { error: this.capabilityError(n) });
901
914
  return;
@@ -907,7 +920,7 @@ var x = class {
907
920
  }
908
921
  let a;
909
922
  try {
910
- a = new g({
923
+ a = new m({
911
924
  id: n,
912
925
  destination: i,
913
926
  platform: this.options.platform,
@@ -1015,10 +1028,14 @@ var x = class {
1015
1028
  let t = this.options.platform === "mobile-web" ? 1 : 2, n = this.options.maxConcurrentCalls ?? t;
1016
1029
  return Math.min(t, Math.max(1, n), Math.max(1, e.policy.maxConcurrentCalls));
1017
1030
  }
1018
- dialOptions(e, t, n) {
1031
+ dialOptions(e, t, n, r = []) {
1019
1032
  return {
1020
1033
  iceServers: t.iceServers,
1021
- extraHeaders: [`X-XCall-Call-ID: ${e}`, `X-XCall-Session-ID: ${t.sessionId}`],
1034
+ extraHeaders: [
1035
+ `X-XCall-Call-ID: ${e}`,
1036
+ `X-XCall-Session-ID: ${t.sessionId}`,
1037
+ ...r
1038
+ ],
1022
1039
  ...n === void 0 ? {} : { type: n }
1023
1040
  };
1024
1041
  }
@@ -1032,7 +1049,7 @@ var x = class {
1032
1049
  cause: t
1033
1050
  });
1034
1051
  }
1035
- }, ee = class {
1052
+ }, ie = class {
1036
1053
  handlers = /* @__PURE__ */ new Map();
1037
1054
  on(e, t) {
1038
1055
  let n = this.handlers.get(e) ?? /* @__PURE__ */ new Set(), r = t;
@@ -1057,12 +1074,12 @@ var x = class {
1057
1074
  this.handlers.clear();
1058
1075
  }
1059
1076
  };
1060
- function te(e) {
1077
+ function ae(e) {
1061
1078
  if (typeof e != "object" || !e || !("reason" in e)) return "ended";
1062
1079
  let t = e.reason;
1063
1080
  return typeof t == "string" && t !== "" ? t : "ended";
1064
1081
  }
1065
- function ne(t, n) {
1082
+ function oe(t, n) {
1066
1083
  if (t instanceof e) return new e(t.code, t.category, t.retryable, {
1067
1084
  requestId: t.requestId,
1068
1085
  callId: n,
@@ -1087,7 +1104,7 @@ function ne(t, n) {
1087
1104
  }
1088
1105
  //#endregion
1089
1106
  //#region src/shared/SharedWorkerClient.ts
1090
- var S = class {
1107
+ var se = class {
1091
1108
  port;
1092
1109
  timeoutMs;
1093
1110
  pending = /* @__PURE__ */ new Map();
@@ -1124,13 +1141,13 @@ var S = class {
1124
1141
  try {
1125
1142
  let n = t(e);
1126
1143
  if (n.type === "event") {
1127
- n.event === "connection.stateChanged" && re(n.payload) && (this.lifecycleState = n.payload.state), this.eventHandlers.forEach((e) => e(n));
1144
+ n.event === "connection.stateChanged" && ce(n.payload) && (this.lifecycleState = n.payload.state), this.eventHandlers.forEach((e) => e(n));
1128
1145
  return;
1129
1146
  }
1130
1147
  if (n.type !== "response") return;
1131
1148
  let r = this.pending.get(n.requestId);
1132
1149
  if (r === void 0) return;
1133
- this.pending.delete(n.requestId), clearTimeout(r.timer), n.ok ? r.resolve(n.result) : r.reject(C(n));
1150
+ this.pending.delete(n.requestId), clearTimeout(r.timer), n.ok ? r.resolve(n.result) : r.reject(le(n));
1134
1151
  } catch (e) {
1135
1152
  this.pending.forEach((t) => {
1136
1153
  clearTimeout(t.timer), t.reject(e);
@@ -1138,10 +1155,10 @@ var S = class {
1138
1155
  }
1139
1156
  }
1140
1157
  };
1141
- function re(e) {
1158
+ function ce(e) {
1142
1159
  return typeof e == "object" && !!e && "state" in e && (e.state === "connected" || e.state === "reconnecting");
1143
1160
  }
1144
- function C(t) {
1161
+ function le(t) {
1145
1162
  let n = t.error;
1146
1163
  return new e(n?.code ?? "SDK_INTERNAL_ERROR", n?.category ?? "internal", n?.retryable ?? !1, {
1147
1164
  requestId: t.requestId,
@@ -1152,12 +1169,12 @@ function C(t) {
1152
1169
  }
1153
1170
  //#endregion
1154
1171
  //#region src/shared/SharedWorkerFactory.ts
1155
- function w(t = {}) {
1172
+ function S(t = {}) {
1156
1173
  if ((t.enabled ?? "auto") === !1) return {
1157
1174
  mode: "single-tab",
1158
1175
  reason: "disabled"
1159
1176
  };
1160
- let n = t.locationHref ?? E(), r = T(t.url, n), i = (n) => {
1177
+ let n = t.locationHref ?? w(), r = C(t.url, n), i = (n) => {
1161
1178
  if (t.fallback === "error") throw new e("CONFIG_INVALID", "configuration", !1, { cause: n });
1162
1179
  return {
1163
1180
  mode: "single-tab",
@@ -1165,8 +1182,8 @@ function w(t = {}) {
1165
1182
  };
1166
1183
  };
1167
1184
  if (r === void 0) return i("SharedWorker URL is unavailable");
1168
- if (!O(r, n)) return i("SharedWorker URL must be same-origin");
1169
- let a = t.workerCtor ?? D();
1185
+ if (!de(r, n)) return i("SharedWorker URL must be same-origin");
1186
+ let a = t.workerCtor ?? ue();
1170
1187
  if (a === void 0) return i("SharedWorker is not supported");
1171
1188
  let o;
1172
1189
  try {
@@ -1174,10 +1191,10 @@ function w(t = {}) {
1174
1191
  } catch (e) {
1175
1192
  return i(`SharedWorker construction failed: ${e instanceof Error ? e.message : String(e)}`);
1176
1193
  }
1177
- let s = t.tabId ?? ie(), c = new S(o.port), l = {
1194
+ let s = t.tabId ?? T(), c = new se(o.port), l = {
1178
1195
  version: 1,
1179
1196
  type: "attach",
1180
- requestId: ae(),
1197
+ requestId: E(),
1181
1198
  tabId: s
1182
1199
  }, u = c.request(l).then(() => void 0).catch((e) => {
1183
1200
  throw c.close(), e;
@@ -1191,20 +1208,20 @@ function w(t = {}) {
1191
1208
  ready: u
1192
1209
  };
1193
1210
  }
1194
- function T(e, t = E()) {
1211
+ function C(e, t = w()) {
1195
1212
  try {
1196
1213
  return t === void 0 ? void 0 : new URL(e ?? "./shared-worker.js", t).toString();
1197
1214
  } catch {
1198
1215
  return;
1199
1216
  }
1200
1217
  }
1201
- function E() {
1218
+ function w() {
1202
1219
  return typeof location > "u" ? void 0 : location.href;
1203
1220
  }
1204
- function D() {
1221
+ function ue() {
1205
1222
  if (typeof SharedWorker == "function") return SharedWorker;
1206
1223
  }
1207
- function O(e, t) {
1224
+ function de(e, t) {
1208
1225
  if (t === void 0) return !0;
1209
1226
  try {
1210
1227
  return new URL(e, t).origin === new URL(t).origin;
@@ -1212,15 +1229,15 @@ function O(e, t) {
1212
1229
  return !1;
1213
1230
  }
1214
1231
  }
1215
- function ie() {
1232
+ function T() {
1216
1233
  return `tab-${typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : Math.random().toString(36).slice(2)}`;
1217
1234
  }
1218
- function ae() {
1235
+ function E() {
1219
1236
  return `attach-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
1220
1237
  }
1221
1238
  //#endregion
1222
1239
  //#region src/media/DeviceManager.ts
1223
- var oe = class {
1240
+ var D = class {
1224
1241
  mediaDevices;
1225
1242
  createAudioElement;
1226
1243
  outputCapability;
@@ -1228,23 +1245,23 @@ var oe = class {
1228
1245
  outputGeneration = 0;
1229
1246
  outputTail;
1230
1247
  constructor(e = {}) {
1231
- this.mediaDevices = e.mediaDevices === null ? void 0 : e.mediaDevices ?? k(), this.createAudioElement = e.createAudioElement;
1248
+ this.mediaDevices = e.mediaDevices === null ? void 0 : e.mediaDevices ?? O(), this.createAudioElement = e.createAudioElement;
1232
1249
  }
1233
1250
  async requestPermission(e = {}) {
1234
1251
  let t = this.requireMediaDevices(), n;
1235
1252
  try {
1236
1253
  n = await t.getUserMedia({ audio: e });
1237
1254
  } catch (e) {
1238
- throw M(e);
1255
+ throw j(e);
1239
1256
  }
1240
- A(n);
1257
+ k(n);
1241
1258
  }
1242
1259
  async getDevices() {
1243
1260
  if (this.mediaDevices === void 0) return [];
1244
1261
  try {
1245
1262
  return (await this.mediaDevices.enumerateDevices()).filter((e) => e.kind === "audioinput" || e.kind === "audiooutput" && this.supportsOutputSelection());
1246
1263
  } catch (e) {
1247
- throw N(e);
1264
+ throw M(e);
1248
1265
  }
1249
1266
  }
1250
1267
  getCapabilities() {
@@ -1282,7 +1299,7 @@ var oe = class {
1282
1299
  try {
1283
1300
  await r.setSinkId(t);
1284
1301
  } catch (e) {
1285
- throw P(e);
1302
+ throw N(e);
1286
1303
  }
1287
1304
  }
1288
1305
  enqueueOutput(e) {
@@ -1296,7 +1313,7 @@ var oe = class {
1296
1313
  try {
1297
1314
  return await t.getUserMedia({ audio: { deviceId: { exact: e } } });
1298
1315
  } catch (e) {
1299
- throw j(e);
1316
+ throw A(e);
1300
1317
  }
1301
1318
  }
1302
1319
  requireMediaDevices() {
@@ -1316,10 +1333,10 @@ var oe = class {
1316
1333
  }
1317
1334
  }
1318
1335
  };
1319
- function k() {
1336
+ function O() {
1320
1337
  return globalThis.navigator?.mediaDevices;
1321
1338
  }
1322
- function A(e) {
1339
+ function k(e) {
1323
1340
  let t;
1324
1341
  try {
1325
1342
  t = e.getTracks();
@@ -1332,57 +1349,57 @@ function A(e) {
1332
1349
  } catch {}
1333
1350
  });
1334
1351
  }
1335
- function j(t) {
1336
- let n = F(t);
1352
+ function A(t) {
1353
+ let n = P(t);
1337
1354
  return n === "NotFoundError" || n === "OverconstrainedError" ? new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { cause: t }) : n === "NotReadableError" || n === "AbortError" ? new e("MEDIA_DEVICE_IN_USE", "media", !0, { cause: t }) : n === "NotAllowedError" || n === "SecurityError" ? new e("MEDIA_PERMISSION_DENIED", "media", !1, { cause: t }) : new e("SDK_INTERNAL_ERROR", "internal", !1, { cause: t });
1338
1355
  }
1339
- function M(t) {
1340
- let n = F(t);
1356
+ function j(t) {
1357
+ let n = P(t);
1341
1358
  return n === "NotFoundError" || n === "OverconstrainedError" ? new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { cause: t }) : n === "NotReadableError" || n === "AbortError" ? new e("MEDIA_DEVICE_IN_USE", "media", !0, { cause: t }) : n === "NotAllowedError" || n === "SecurityError" ? new e("MEDIA_PERMISSION_DENIED", "media", !1, { cause: t }) : new e("SDK_INTERNAL_ERROR", "internal", !1, { cause: t });
1342
1359
  }
1343
- function N(t) {
1344
- let n = F(t);
1360
+ function M(t) {
1361
+ let n = P(t);
1345
1362
  return n === "NotFoundError" ? new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { cause: t }) : n === "NotAllowedError" || n === "SecurityError" ? new e("MEDIA_PERMISSION_DENIED", "media", !1, { cause: t }) : n === "AbortError" || n === "NotReadableError" ? new e("MEDIA_DEVICE_IN_USE", "media", !0, { cause: t }) : new e("SDK_INTERNAL_ERROR", "internal", !1, { cause: t });
1346
1363
  }
1347
- function P(t) {
1348
- let n = F(t);
1364
+ function N(t) {
1365
+ let n = P(t);
1349
1366
  return n === "NotFoundError" ? new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { cause: t }) : n === "NotAllowedError" || n === "SecurityError" ? new e("MEDIA_PERMISSION_DENIED", "media", !1, { cause: t }) : n === "AbortError" || n === "NotReadableError" ? new e("MEDIA_DEVICE_IN_USE", "media", !0, { cause: t }) : new e("SDK_INTERNAL_ERROR", "internal", !1, { cause: t });
1350
1367
  }
1351
- function F(e) {
1368
+ function P(e) {
1352
1369
  if (typeof e != "object" || !e || !("name" in e)) return;
1353
1370
  let t = e.name;
1354
1371
  return typeof t == "string" ? t : void 0;
1355
1372
  }
1356
1373
  //#endregion
1357
1374
  //#region src/media/RemoteAudio.ts
1358
- var I = class {
1375
+ var F = class {
1359
1376
  createAudioElement;
1360
1377
  bindings = /* @__PURE__ */ new Map();
1361
1378
  audioOwners = /* @__PURE__ */ new Map();
1362
1379
  trackOwners = /* @__PURE__ */ new Map();
1363
1380
  generations = /* @__PURE__ */ new Map();
1364
1381
  pendingPlays = /* @__PURE__ */ new Map();
1365
- constructor(e = L) {
1382
+ constructor(e = I) {
1366
1383
  this.createAudioElement = e;
1367
1384
  }
1368
1385
  async bind(t, n) {
1369
1386
  let r = this.bindings.get(t);
1370
1387
  if (r?.stream === n) return;
1371
- let i = R(t, n), a;
1388
+ let i = L(t, n), a;
1372
1389
  try {
1373
1390
  a = this.createAudioElement();
1374
1391
  } catch (n) {
1375
- throw z(i, this.trackOwners), new e("CAPABILITY_NOT_SUPPORTED", "capability", !1, {
1392
+ throw R(i, this.trackOwners), new e("CAPABILITY_NOT_SUPPORTED", "capability", !1, {
1376
1393
  callId: t,
1377
1394
  cause: n
1378
1395
  });
1379
1396
  }
1380
1397
  let o = this.audioOwners.get(a);
1381
- if (o !== void 0 && o !== t) throw z(i, this.trackOwners), new e("CALL_OPERATION_NOT_ALLOWED", "call", !1, { callId: t });
1398
+ if (o !== void 0 && o !== t) throw R(i, this.trackOwners), new e("CALL_OPERATION_NOT_ALLOWED", "call", !1, { callId: t });
1382
1399
  try {
1383
1400
  a.autoplay = !0, a.playsInline = !0;
1384
1401
  } catch (n) {
1385
- throw z(i, this.trackOwners), new e("SDK_INTERNAL_ERROR", "internal", !1, {
1402
+ throw R(i, this.trackOwners), new e("SDK_INTERNAL_ERROR", "internal", !1, {
1386
1403
  callId: t,
1387
1404
  cause: n
1388
1405
  });
@@ -1390,7 +1407,7 @@ var I = class {
1390
1407
  try {
1391
1408
  a.srcObject = n;
1392
1409
  } catch (n) {
1393
- throw z(i, this.trackOwners), new e("SDK_INTERNAL_ERROR", "internal", !1, {
1410
+ throw R(i, this.trackOwners), new e("SDK_INTERNAL_ERROR", "internal", !1, {
1394
1411
  callId: t,
1395
1412
  cause: n
1396
1413
  });
@@ -1466,7 +1483,7 @@ var I = class {
1466
1483
  releaseTrack(e) {
1467
1484
  let t = this.trackOwners.get(e);
1468
1485
  if (t === void 0 || t <= 1) {
1469
- this.trackOwners.delete(e), V(e);
1486
+ this.trackOwners.delete(e), B(e);
1470
1487
  return;
1471
1488
  }
1472
1489
  this.trackOwners.set(e, t - 1);
@@ -1489,42 +1506,42 @@ var I = class {
1489
1506
  return this.generations.get(e) === t && this.bindings.get(e)?.generation === t;
1490
1507
  }
1491
1508
  };
1492
- function L() {
1509
+ function I() {
1493
1510
  if (typeof document > "u") throw new e("CAPABILITY_NOT_SUPPORTED", "capability", !1);
1494
1511
  return document.createElement("audio");
1495
1512
  }
1496
- function R(t, n) {
1513
+ function L(t, n) {
1497
1514
  try {
1498
1515
  return [...new Set(n.getAudioTracks())].filter((e) => e.kind === "audio");
1499
1516
  } catch (r) {
1500
1517
  try {
1501
1518
  return [...new Set(n.getTracks())].filter((e) => e.kind === "audio");
1502
1519
  } catch (i) {
1503
- throw B(n), new e("SDK_INTERNAL_ERROR", "internal", !1, {
1520
+ throw z(n), new e("SDK_INTERNAL_ERROR", "internal", !1, {
1504
1521
  callId: t,
1505
1522
  cause: r ?? i
1506
1523
  });
1507
1524
  }
1508
1525
  }
1509
1526
  }
1510
- function z(e, t) {
1527
+ function R(e, t) {
1511
1528
  e.forEach((e) => {
1512
- (t.get(e) ?? 0) === 0 && V(e);
1529
+ (t.get(e) ?? 0) === 0 && B(e);
1513
1530
  });
1514
1531
  }
1515
- function B(e) {
1532
+ function z(e) {
1516
1533
  try {
1517
- [...new Set(e.getTracks())].filter((e) => e.kind === "audio").forEach(V);
1534
+ [...new Set(e.getTracks())].filter((e) => e.kind === "audio").forEach(B);
1518
1535
  } catch {}
1519
1536
  }
1520
- function V(e) {
1537
+ function B(e) {
1521
1538
  try {
1522
1539
  e.stop();
1523
1540
  } catch {}
1524
1541
  }
1525
1542
  //#endregion
1526
1543
  //#region src/media/MediaManager.ts
1527
- var H = class {
1544
+ var V = class {
1528
1545
  deviceManager;
1529
1546
  remoteAudio;
1530
1547
  getActiveCall;
@@ -1545,7 +1562,7 @@ var H = class {
1545
1562
  mediaDevices: e.mediaDevices,
1546
1563
  createAudioElement: e.createAudioElement
1547
1564
  };
1548
- this.deviceManager = new oe(t), this.remoteAudio = new I(e.createAudioElement), this.getActiveCall = e.getActiveCall, this.createRemoteStream = e.createRemoteStream ?? se;
1565
+ this.deviceManager = new D(t), this.remoteAudio = new F(e.createAudioElement), this.getActiveCall = e.getActiveCall, this.createRemoteStream = e.createRemoteStream ?? pe;
1549
1566
  }
1550
1567
  requestPermission(e) {
1551
1568
  return this.assertNotDisposed(), this.deviceManager.requestPermission(e);
@@ -1565,7 +1582,7 @@ var H = class {
1565
1582
  n !== void 0 && this.releaseResource(n).catch((e) => {
1566
1583
  this.releaseErrors.set(n, e);
1567
1584
  });
1568
- let r = U(t) ? t : { peerConnection: t }, i = {
1585
+ let r = H(t) ? t : { peerConnection: t }, i = {
1569
1586
  callId: e,
1570
1587
  peerConnection: r.peerConnection,
1571
1588
  senders: /* @__PURE__ */ new Map(),
@@ -1665,14 +1682,14 @@ var H = class {
1665
1682
  if (n.forEach((e) => {
1666
1683
  if (e.cause !== void 0) {
1667
1684
  o.push(e.cause);
1668
- let t = W(e.senderResource.sender);
1685
+ let t = U(e.senderResource.sender);
1669
1686
  t?.kind === "audio" && a.add(t);
1670
1687
  return;
1671
1688
  }
1672
- let t = W(e.senderResource.sender);
1689
+ let t = U(e.senderResource.sender);
1673
1690
  t?.kind === "audio" && i.add(t);
1674
1691
  }), i.forEach((e) => {
1675
- a.has(e) || J(e);
1692
+ a.has(e) || q(e);
1676
1693
  }), o.length > 0) throw t.localTracks.clear(), t.pendingTracks.clear(), a.forEach((e) => t.localTracks.add(e)), new e("SDK_INTERNAL_ERROR", "internal", !0, {
1677
1694
  callId: r,
1678
1695
  cause: o[0]
@@ -1680,7 +1697,7 @@ var H = class {
1680
1697
  if (!t.peerClosed && t.peerConnection.close !== void 0) try {
1681
1698
  await t.peerConnection.close(), t.peerClosed = !0;
1682
1699
  } catch (n) {
1683
- let i = [...t.senders.values()].map((e) => W(e.sender)).find((e) => e?.kind === "audio");
1700
+ let i = [...t.senders.values()].map((e) => U(e.sender)).find((e) => e?.kind === "audio");
1684
1701
  throw t.localTracks.clear(), t.pendingTracks.clear(), i != null && t.localTracks.add(i), new e("SDK_INTERNAL_ERROR", "internal", !0, {
1685
1702
  callId: r,
1686
1703
  cause: n
@@ -1748,11 +1765,11 @@ var H = class {
1748
1765
  }
1749
1766
  async performInputSwitch(t, n, r) {
1750
1767
  if (this.assertActiveCall(n), this.assertDeviceSelectionCapability(n), !this.isCurrentResource(r) || n.peerConnection !== r.peerConnection) throw this.callOperationError(n.callId);
1751
- let i = this.findAudioSender(r), a = W(i.sender), o = r.generation, s = await this.deviceManager.openInputStream(t), c;
1768
+ let i = this.findAudioSender(r), a = U(i.sender), o = r.generation, s = await this.deviceManager.openInputStream(t), c;
1752
1769
  try {
1753
1770
  c = s.getTracks();
1754
1771
  } catch (t) {
1755
- throw K(s), new e("SDK_INTERNAL_ERROR", "internal", !1, {
1772
+ throw fe(s), new e("SDK_INTERNAL_ERROR", "internal", !1, {
1756
1773
  callId: n.callId,
1757
1774
  cause: t
1758
1775
  });
@@ -1761,26 +1778,26 @@ var H = class {
1761
1778
  try {
1762
1779
  l = s.getAudioTracks();
1763
1780
  } catch (t) {
1764
- throw q(c), new e("SDK_INTERNAL_ERROR", "internal", !1, {
1781
+ throw K(c), new e("SDK_INTERNAL_ERROR", "internal", !1, {
1765
1782
  callId: n.callId,
1766
1783
  cause: t
1767
1784
  });
1768
1785
  }
1769
1786
  let u = l[0];
1770
- if (u === void 0) throw q(c), new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { callId: n.callId });
1771
- if (!this.canCommitInputSwitch(n, r, i, a, o)) throw q(c), this.callOperationError(n.callId);
1787
+ if (u === void 0) throw K(c), new e("MEDIA_DEVICE_NOT_FOUND", "media", !1, { callId: n.callId });
1788
+ if (!this.canCommitInputSwitch(n, r, i, a, o)) throw K(c), this.callOperationError(n.callId);
1772
1789
  c.forEach((e) => r.pendingTracks.add(e)), r.pendingTracks.add(u);
1773
1790
  try {
1774
1791
  await this.enqueueSender(r, i, () => i.sender.replaceTrack(u));
1775
1792
  } catch (t) {
1776
- throw r.released ? this.callOperationError(n.callId) : (r.released || (c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), await this.rollbackSender(r, i, a, u), q(c)), new e("MEDIA_DEVICE_IN_USE", "media", !0, {
1793
+ throw r.released ? this.callOperationError(n.callId) : (r.released || (c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), await this.rollbackSender(r, i, a, u), K(c)), new e("MEDIA_DEVICE_IN_USE", "media", !0, {
1777
1794
  callId: n.callId,
1778
1795
  cause: t
1779
1796
  }));
1780
1797
  }
1781
1798
  if (!this.canCommitInputSwitch(n, r, i, u, o)) {
1782
1799
  if (!r.released) try {
1783
- await this.enqueueSender(r, i, () => W(i.sender) === u ? G(i.sender) : Promise.resolve()), c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), q(c);
1800
+ await this.enqueueSender(r, i, () => U(i.sender) === u ? G(i.sender) : Promise.resolve()), c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), K(c);
1784
1801
  } catch (t) {
1785
1802
  throw new e("SDK_INTERNAL_ERROR", "internal", !0, {
1786
1803
  callId: n.callId,
@@ -1789,8 +1806,8 @@ var H = class {
1789
1806
  }
1790
1807
  throw this.callOperationError(n.callId);
1791
1808
  }
1792
- c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), r.localTracks.add(u), a !== null && a !== u && (r.localTracks.delete(a), J(a)), c.forEach((e) => {
1793
- e !== u && J(e);
1809
+ c.forEach((e) => r.pendingTracks.delete(e)), r.pendingTracks.delete(u), r.localTracks.add(u), a !== null && a !== u && (r.localTracks.delete(a), q(a)), c.forEach((e) => {
1810
+ e !== u && q(e);
1794
1811
  });
1795
1812
  }
1796
1813
  ensureCallMedia(e) {
@@ -1813,7 +1830,7 @@ var H = class {
1813
1830
  });
1814
1831
  }
1815
1832
  r.forEach((r) => {
1816
- let i = W(r), a;
1833
+ let i = U(r), a;
1817
1834
  try {
1818
1835
  a = n?.(r) ?? r.senderKind ?? r.kind;
1819
1836
  } catch (n) {
@@ -1830,7 +1847,7 @@ var H = class {
1830
1847
  });
1831
1848
  }
1832
1849
  findAudioSender(e) {
1833
- let t = [...e.senders.values()].find((e) => e.audio && (W(e.sender)?.kind === "audio" || W(e.sender) === null));
1850
+ let t = [...e.senders.values()].find((e) => e.audio && (U(e.sender)?.kind === "audio" || U(e.sender) === null));
1834
1851
  if (t === void 0) throw this.capabilityError(e.callId);
1835
1852
  return t;
1836
1853
  }
@@ -1846,7 +1863,7 @@ var H = class {
1846
1863
  } catch {
1847
1864
  return !1;
1848
1865
  }
1849
- return W(n.sender) === r;
1866
+ return U(n.sender) === r;
1850
1867
  }
1851
1868
  enqueueSender(e, t, n, r = !1) {
1852
1869
  t.queue.pending += 1;
@@ -1875,7 +1892,7 @@ var H = class {
1875
1892
  });
1876
1893
  }
1877
1894
  async rollbackSender(e, t, n, r) {
1878
- e.released || W(t.sender) !== r || await this.enqueueSender(e, t, () => t.sender.replaceTrack(n)).catch(() => void 0);
1895
+ e.released || U(t.sender) !== r || await this.enqueueSender(e, t, () => t.sender.replaceTrack(n)).catch(() => void 0);
1879
1896
  }
1880
1897
  isCurrentResource(e, t = e.generation) {
1881
1898
  return !this.disposed && this.calls.get(e.callId) === e && e.generation === t;
@@ -1902,37 +1919,42 @@ var H = class {
1902
1919
  if (this.disposed || this.disposing) throw new e("SDK_ALREADY_DISPOSED", "internal", !1);
1903
1920
  }
1904
1921
  };
1905
- function U(e) {
1922
+ function H(e) {
1906
1923
  return "peerConnection" in e;
1907
1924
  }
1908
- function W(e) {
1925
+ function U(e) {
1909
1926
  try {
1910
1927
  return e.track;
1911
1928
  } catch {
1912
1929
  return null;
1913
1930
  }
1914
1931
  }
1932
+ function W(e) {
1933
+ return typeof e == "object" && !!e && e.name === "InvalidStateError";
1934
+ }
1915
1935
  function G(e) {
1916
1936
  try {
1917
- return e.replaceTrack(null);
1937
+ return e.replaceTrack(null).catch((e) => {
1938
+ if (!W(e)) throw e;
1939
+ });
1918
1940
  } catch (e) {
1919
- return Promise.reject(e);
1941
+ return W(e) ? Promise.resolve() : Promise.reject(e);
1920
1942
  }
1921
1943
  }
1922
- function K(e) {
1944
+ function fe(e) {
1923
1945
  try {
1924
- q(e.getTracks());
1946
+ K(e.getTracks());
1925
1947
  } catch {}
1926
1948
  }
1927
- function q(e) {
1928
- e.forEach(J);
1949
+ function K(e) {
1950
+ e.forEach(q);
1929
1951
  }
1930
- function J(e) {
1952
+ function q(e) {
1931
1953
  try {
1932
1954
  e.stop();
1933
1955
  } catch {}
1934
1956
  }
1935
- function se(e) {
1957
+ function pe(e) {
1936
1958
  if (typeof MediaStream < "u") try {
1937
1959
  return new MediaStream([e]);
1938
1960
  } catch {
@@ -1941,8 +1963,8 @@ function se(e) {
1941
1963
  }
1942
1964
  //#endregion
1943
1965
  //#region src/core/mediaBridge.ts
1944
- function ce(t, n = {}) {
1945
- let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = n.ownershipRequired === !0, s = !1, c = !1, l, u = () => t(), d = new H({ getActiveCall: u });
1966
+ function me(t, n = {}) {
1967
+ let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Set(), o = n.ownershipRequired === !0, s = !1, c = !1, l, u = () => t(), d = new V({ getActiveCall: u });
1946
1968
  return {
1947
1969
  publicMedia: {
1948
1970
  requestPermission: () => (f(), d.requestPermission()),
@@ -1955,7 +1977,7 @@ function ce(t, n = {}) {
1955
1977
  releaseAll: () => (f(), d.releaseAll())
1956
1978
  },
1957
1979
  registerCall(e, t) {
1958
- s || c || !Y(t) || (i.set(e, t), (!o || a.has(e)) && p(e, t));
1980
+ s || c || !J(t) || (i.set(e, t), (!o || a.has(e)) && p(e, t));
1959
1981
  },
1960
1982
  async setCallOwnership(e, t) {
1961
1983
  if (s) return;
@@ -1998,9 +2020,9 @@ function ce(t, n = {}) {
1998
2020
  if (s) throw new e("SDK_ALREADY_DISPOSED", "internal", !1);
1999
2021
  }
2000
2022
  function p(e, t) {
2001
- if (!Y(t) || typeof t.getMediaRegistration != "function") return;
2023
+ if (!J(t) || typeof t.getMediaRegistration != "function") return;
2002
2024
  let n = t.getMediaRegistration();
2003
- if (le(n) && r.get(e)?.peerConnection !== n.peerConnection) {
2025
+ if (he(n) && r.get(e)?.peerConnection !== n.peerConnection) {
2004
2026
  r.set(e, n);
2005
2027
  try {
2006
2028
  d.registerCallMedia(e, n);
@@ -2010,22 +2032,22 @@ function ce(t, n = {}) {
2010
2032
  }
2011
2033
  }
2012
2034
  }
2013
- function Y(e) {
2035
+ function J(e) {
2014
2036
  return typeof e == "object" && !!e;
2015
2037
  }
2016
- function le(e) {
2038
+ function he(e) {
2017
2039
  return typeof e == "object" && !!e && "peerConnection" in e && typeof e.peerConnection == "object" && e.peerConnection !== null;
2018
2040
  }
2019
2041
  //#endregion
2020
2042
  //#region src/reconnect/backoff.ts
2021
- var ue = 1e3, de = 3e4;
2022
- function fe(e, t = Math.random) {
2023
- let n = Math.min(de, ue * 2 ** Math.max(0, Math.floor(e))), r = Math.min(1, Math.max(0, t()));
2043
+ var ge = 1e3, _e = 3e4;
2044
+ function ve(e, t = Math.random) {
2045
+ let n = Math.min(_e, ge * 2 ** Math.max(0, Math.floor(e))), r = Math.min(1, Math.max(0, t()));
2024
2046
  return Math.round(n * (1 + r * .2));
2025
2047
  }
2026
2048
  //#endregion
2027
2049
  //#region src/reconnect/ReconnectManager.ts
2028
- var pe = class {
2050
+ var ye = class {
2029
2051
  recover;
2030
2052
  random;
2031
2053
  isOnline;
@@ -2042,7 +2064,7 @@ var pe = class {
2042
2064
  }
2043
2065
  start() {
2044
2066
  if (this.disposed || !this.online || !this.isOnline() || this.pendingTimer !== void 0 || this.running) return;
2045
- let e = this.generation, t = fe(this.attempt, this.random);
2067
+ let e = this.generation, t = ve(this.attempt, this.random);
2046
2068
  this.pendingTimer = setTimeout(() => {
2047
2069
  this.pendingTimer = void 0, this.run(e);
2048
2070
  }, t);
@@ -2084,7 +2106,7 @@ var pe = class {
2084
2106
  clearPendingTimer() {
2085
2107
  this.pendingTimer !== void 0 && (clearTimeout(this.pendingTimer), this.pendingTimer = void 0);
2086
2108
  }
2087
- }, me = class t {
2109
+ }, be = class t {
2088
2110
  media;
2089
2111
  options;
2090
2112
  api;
@@ -2129,7 +2151,7 @@ var pe = class {
2129
2151
  this.api = t.api === void 0 ? t.sessionProvider === void 0 ? new p({
2130
2152
  baseUrl: t.baseUrl ?? "",
2131
2153
  tokenProvider: i
2132
- }) : X(_e(t.sessionProvider)) : X(t.api), this.suppliedSip = t.sip === void 0 ? void 0 : ve(t.sip), this.mediaBridge = ce(() => this.getActiveMediaContext()), this.media = this.mediaBridge.publicMedia, this.reconnect = new pe({
2154
+ }) : Y(Ce(t.sessionProvider)) : Y(t.api), this.suppliedSip = t.sip === void 0 ? void 0 : X(t.sip), this.mediaBridge = me(() => this.getActiveMediaContext()), this.media = this.mediaBridge.publicMedia, this.reconnect = new ye({
2133
2155
  recover: () => this.recoverConnection(),
2134
2156
  onAttempt: (e) => {
2135
2157
  this.disposed || this.events.emit("connection.reconnecting", { attempt: e });
@@ -2141,13 +2163,13 @@ var pe = class {
2141
2163
  }), this.sharedWorkerSelection = t.sharedWorker === void 0 ? {
2142
2164
  mode: "single-tab",
2143
2165
  reason: "disabled"
2144
- } : w({
2166
+ } : S({
2145
2167
  ...t.sharedWorker,
2146
2168
  ...t.sharedWorkerHost ?? {}
2147
2169
  });
2148
2170
  }
2149
2171
  static async checkSupport() {
2150
- let e = typeof navigator < "u" && navigator.mediaDevices !== void 0, t = typeof WebSocket < "u", n = ge(typeof navigator < "u" ? navigator.userAgent : "");
2172
+ let e = typeof navigator < "u" && navigator.mediaDevices !== void 0, t = typeof WebSocket < "u", n = Se(typeof navigator < "u" ? navigator.userAgent : "");
2151
2173
  return {
2152
2174
  supported: e && t,
2153
2175
  platform: n,
@@ -2254,7 +2276,7 @@ var pe = class {
2254
2276
  sdkVersion: n,
2255
2277
  platform: a === "mobile-web" ? "mobile_web" : "web",
2256
2278
  ...this.options.locale === void 0 ? {} : { locale: this.options.locale },
2257
- requestedCapabilities: [...this.options.requestedCapabilities ?? Se(a)]
2279
+ requestedCapabilities: [...this.options.requestedCapabilities ?? De(a)]
2258
2280
  }), this.ownedSessionIds.add(t.sessionId), this.assertGeneration(e), r = await this.getSip(), this.assertGeneration(e), this.session = t;
2259
2281
  let o = this.callManager ?? this.createCallManager(r, t, a);
2260
2282
  this.callManager === void 0 && (i = o), o.updateSession(t), this.callManager = o, this.attachSipListener(r), this.attachNetworkListeners(), await r.connect(t), this.assertGeneration(e), this.setConnectionState("connected"), this.events.emit("connection.registered", { registered: !0 }), this.scheduleRefresh(t);
@@ -2360,7 +2382,7 @@ var pe = class {
2360
2382
  try {
2361
2383
  await this.media.releaseAll();
2362
2384
  } catch (t) {
2363
- ye(t) || (e ??= t);
2385
+ we(t) || (e ??= t);
2364
2386
  }
2365
2387
  try {
2366
2388
  await this.mediaBridge.dispose();
@@ -2560,7 +2582,7 @@ var pe = class {
2560
2582
  destination: e.destination
2561
2583
  })),
2562
2584
  permission: this.support?.hasMediaDevices === !1 ? "unsupported" : "unknown",
2563
- ice: he(e),
2585
+ ice: xe(e),
2564
2586
  wss: {
2565
2587
  configured: e !== void 0,
2566
2588
  secure: e?.transport.wssUrl.toLowerCase().startsWith("wss://") ?? !1,
@@ -2677,7 +2699,7 @@ var pe = class {
2677
2699
  return new e("SDK_ALREADY_DISPOSED", "internal", !1);
2678
2700
  }
2679
2701
  };
2680
- function he(e) {
2702
+ function xe(e) {
2681
2703
  if (e === void 0) return {
2682
2704
  configured: !1,
2683
2705
  serverCount: 0,
@@ -2695,14 +2717,14 @@ function he(e) {
2695
2717
  turnServerCount: n
2696
2718
  };
2697
2719
  }
2698
- function ge(e) {
2720
+ function Se(e) {
2699
2721
  return e === "" ? "unknown" : /iPhone|iPad|Android/i.test(e) ? "mobile-web" : "web";
2700
2722
  }
2701
- function X(t) {
2723
+ function Y(t) {
2702
2724
  if (typeof t != "object" || !t) throw new e("CONFIG_INVALID", "configuration", !1);
2703
2725
  return t;
2704
2726
  }
2705
- function _e(t) {
2727
+ function Ce(t) {
2706
2728
  let r = {
2707
2729
  createSession: (e) => t.createSession(e),
2708
2730
  refreshSession: (e) => t.refreshSession === void 0 ? t.createSession({
@@ -2716,7 +2738,7 @@ function _e(t) {
2716
2738
  }, i = t.invalidateToken;
2717
2739
  return i !== void 0 && (r.invalidateToken = () => i()), r;
2718
2740
  }
2719
- function ve(t) {
2741
+ function X(t) {
2720
2742
  if (typeof t != "object" || !t) throw new e("CONFIG_INVALID", "configuration", !1);
2721
2743
  return t;
2722
2744
  }
@@ -2735,13 +2757,13 @@ function Z(t, n, r, i, a) {
2735
2757
  function Q(t) {
2736
2758
  return t instanceof e ? t.status !== void 0 && t.status >= 400 && t.status < 500 || t.serverCode === "SESSION_NOT_FOUND" || t.serverCode === "SESSION_EXPIRED" || t.serverCode === "TOKEN_INVALID" || t.serverCode === "TOKEN_EXPIRED" || t.code === "AUTH_TOKEN_UNAVAILABLE" || t.code === "AUTH_TOKEN_EXPIRED" : !1;
2737
2759
  }
2738
- function ye(t) {
2760
+ function we(t) {
2739
2761
  return t instanceof e && t.code === "SDK_ALREADY_DISPOSED";
2740
2762
  }
2741
2763
  function $(t) {
2742
2764
  return t instanceof e && (t.code === "SDK_ALREADY_DISPOSED" || t.code === "CALL_NOT_CONNECTED");
2743
2765
  }
2744
- var be = [
2766
+ var Te = [
2745
2767
  "outbound",
2746
2768
  "inbound",
2747
2769
  "mute",
@@ -2749,13 +2771,13 @@ var be = [
2749
2771
  "dtmf",
2750
2772
  "blind_transfer",
2751
2773
  "device_selection"
2752
- ], xe = [
2774
+ ], Ee = [
2753
2775
  "outbound",
2754
2776
  "mute",
2755
2777
  "dtmf"
2756
2778
  ];
2757
- function Se(e) {
2758
- return e === "mobile-web" ? xe : be;
2779
+ function De(e) {
2780
+ return e === "mobile-web" ? Ee : Te;
2759
2781
  }
2760
2782
  //#endregion
2761
- export { g as a, c, l as d, a as f, x as i, s as l, w as n, p as o, i as p, T as r, d as s, me as t, o as u };
2783
+ export { m as a, c, l as d, a as f, x as i, s as l, S as n, p as o, i as p, C as r, d as s, be as t, o as u };