@shenyin/embedded-call-widget 2.6.3 → 2.6.5

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,4 +1,4 @@
1
- const Ct = "0.21.1";
1
+ const Tt = "0.21.1";
2
2
  class le extends Error {
3
3
  constructor(e) {
4
4
  super(e), Object.setPrototypeOf(this, new.target.prototype);
@@ -15,7 +15,7 @@ class ye extends le {
15
15
  super(e || "Request pending.");
16
16
  }
17
17
  }
18
- class Et extends le {
18
+ class Ct extends le {
19
19
  constructor(e) {
20
20
  super(e || "Unspecified session description handler error.");
21
21
  }
@@ -30,7 +30,7 @@ class pe extends le {
30
30
  super(e || "An error occurred during state transition.");
31
31
  }
32
32
  }
33
- class Rt {
33
+ class Et {
34
34
  /** @internal */
35
35
  constructor(e) {
36
36
  this.incomingAckRequest = e;
@@ -58,7 +58,7 @@ class xt {
58
58
  return this.incomingByeRequest.reject(e), Promise.resolve();
59
59
  }
60
60
  }
61
- class It {
61
+ class Rt {
62
62
  /** @internal */
63
63
  constructor(e) {
64
64
  this.incomingCancelRequest = e;
@@ -130,7 +130,7 @@ class be {
130
130
  return this.addListener(e, { once: !0 });
131
131
  }
132
132
  }
133
- class _t {
133
+ class It {
134
134
  /** @internal */
135
135
  constructor(e) {
136
136
  this.incomingInfoRequest = e;
@@ -430,7 +430,7 @@ class he extends Error {
430
430
  return t;
431
431
  }
432
432
  }
433
- function At(a, e) {
433
+ function _t(a, e) {
434
434
  e = e !== void 0 ? e : {};
435
435
  const t = {}, i = e.grammarSource, s = { Contact: 119, Name_Addr_Header: 156, Record_Route: 176, Request_Response: 81, SIP_URI: 45, Subscription_State: 186, Supported: 191, Require: 182, Via: 194, absoluteURI: 84, Call_ID: 118, Content_Disposition: 130, Content_Length: 135, Content_Type: 136, CSeq: 146, displayName: 122, Event: 149, From: 151, host: 52, Max_Forwards: 154, Min_SE: 213, Proxy_Authenticate: 157, quoted_string: 40, Refer_To: 178, Replaces: 179, Session_Expires: 210, stun_URI: 217, To: 192, turn_URI: 223, uuid: 226, WWW_Authenticate: 209, challenge: 158, sipfrag: 230, Referred_By: 231 };
436
436
  let r = 119;
@@ -943,7 +943,7 @@ function At(a, e) {
943
943
  return y;
944
944
  },
945
945
  function(l, y) {
946
- return St(l, y);
946
+ return vt(l, y);
947
947
  },
948
948
  function(l) {
949
949
  e = e || { data: {} }, e.startRule === "Require" && (e.data = l || []);
@@ -1374,7 +1374,7 @@ function At(a, e) {
1374
1374
  function Ke(l) {
1375
1375
  d < w || (d > w && (w = d, S = []), S.push(l));
1376
1376
  }
1377
- function vt(l, y, h) {
1377
+ function bt(l, y, h) {
1378
1378
  return new he(he.buildMessage(l, y), l, y, h);
1379
1379
  }
1380
1380
  function c(l) {
@@ -1469,8 +1469,8 @@ function At(a, e) {
1469
1469
  p = d, h++;
1470
1470
  break;
1471
1471
  case 26:
1472
- Ye = y.slice(h + 4, h + 4 + y[h + 3]).map(function(Tt) {
1473
- return C[C.length - 1 - Tt];
1472
+ Ye = y.slice(h + 4, h + 4 + y[h + 3]).map(function(St) {
1473
+ return C[C.length - 1 - St];
1474
1474
  }), C.splice(C.length - y[h + 2], y[h + 2], n[y[h + 1]].apply(null, Ye)), h += 4 + y[h + 3];
1475
1475
  break;
1476
1476
  case 27:
@@ -1493,20 +1493,20 @@ function At(a, e) {
1493
1493
  return C[0];
1494
1494
  }
1495
1495
  e.data = {};
1496
- function St(l, y) {
1496
+ function vt(l, y) {
1497
1497
  return [l].concat(y);
1498
1498
  }
1499
1499
  if (_ = ze(r), _ !== t && d === a.length)
1500
1500
  return _;
1501
- throw _ !== t && d < a.length && Ke(ke()), vt(S, w < a.length ? a.charAt(w) : null, w < a.length ? Pe(w, w + 1) : Pe(w, w));
1501
+ throw _ !== t && d < a.length && Ke(ke()), bt(S, w < a.length ? a.charAt(w) : null, w < a.length ? Pe(w, w + 1) : Pe(w, w));
1502
1502
  }
1503
- const $t = At;
1503
+ const At = _t;
1504
1504
  var k;
1505
1505
  (function(a) {
1506
1506
  function e(s, r) {
1507
1507
  const n = { startRule: r };
1508
1508
  try {
1509
- $t(s, n);
1509
+ At(s, n);
1510
1510
  } catch {
1511
1511
  n.data = -1;
1512
1512
  }
@@ -1524,7 +1524,7 @@ var k;
1524
1524
  }
1525
1525
  a.URIParse = i;
1526
1526
  })(k = k || (k = {}));
1527
- const Dt = {
1527
+ const $t = {
1528
1528
  100: "Trying",
1529
1529
  180: "Ringing",
1530
1530
  181: "Call Is Being Forwarded",
@@ -1606,7 +1606,7 @@ function oe(a, e = 32) {
1606
1606
  return t;
1607
1607
  }
1608
1608
  function _e(a) {
1609
- return Dt[a] || "";
1609
+ return $t[a] || "";
1610
1610
  }
1611
1611
  function Ae() {
1612
1612
  return oe(10);
@@ -1873,7 +1873,7 @@ class de {
1873
1873
  function ot(a) {
1874
1874
  return a === "application/sdp" ? "session" : "render";
1875
1875
  }
1876
- function Re(a) {
1876
+ function xe(a) {
1877
1877
  const e = typeof a == "string" ? a : a.body, t = typeof a == "string" ? "application/sdp" : a.contentType;
1878
1878
  return { contentDisposition: ot(t), contentType: t, content: e };
1879
1879
  }
@@ -1920,9 +1920,9 @@ var b;
1920
1920
  (function(a) {
1921
1921
  a.Initial = "Initial", a.HaveLocalOffer = "HaveLocalOffer", a.HaveRemoteOffer = "HaveRemoteOffer", a.Stable = "Stable", a.Closed = "Closed";
1922
1922
  })(b = b || (b = {}));
1923
- const Z = 500, kt = 4e3, Ze = 5e3, M = {
1923
+ const Z = 500, Dt = 4e3, Ze = 5e3, M = {
1924
1924
  T1: Z,
1925
- T2: kt,
1925
+ T2: Dt,
1926
1926
  TIMER_B: 64 * Z,
1927
1927
  TIMER_D: 0 * Z,
1928
1928
  TIMER_F: 64 * Z,
@@ -1995,7 +1995,7 @@ class je {
1995
1995
  return this.incomingNotifyRequest.reject(e), Promise.resolve();
1996
1996
  }
1997
1997
  }
1998
- class Pt {
1998
+ class kt {
1999
1999
  /** @internal */
2000
2000
  constructor(e, t) {
2001
2001
  this.incomingReferRequest = e, this.session = t;
@@ -2454,7 +2454,7 @@ class ge {
2454
2454
  sessionDescriptionHandlerModifiers: this.pendingReinviteAck ? this._sessionDescriptionHandlerModifiersReInvite : this._sessionDescriptionHandlerModifiers
2455
2455
  };
2456
2456
  if (this.delegate && this.delegate.onAck) {
2457
- const s = new Rt(e);
2457
+ const s = new Et(e);
2458
2458
  this.delegate.onAck(s);
2459
2459
  }
2460
2460
  switch (this.pendingReinviteAck = !1, t.signalingState) {
@@ -2513,7 +2513,7 @@ class ge {
2513
2513
  return;
2514
2514
  }
2515
2515
  if (this.delegate && this.delegate.onInfo) {
2516
- const t = new _t(e);
2516
+ const t = new It(e);
2517
2517
  this.delegate.onInfo(t);
2518
2518
  } else
2519
2519
  e.accept();
@@ -2626,7 +2626,7 @@ class ge {
2626
2626
  this.logger.warn("Invalid REFER packet. A refer-to header is required. Rejecting."), e.reject();
2627
2627
  return;
2628
2628
  }
2629
- const t = new Pt(e, this);
2629
+ const t = new kt(e, this);
2630
2630
  this.delegate && this.delegate.onRefer ? this.delegate.onRefer(t) : (this.logger.log("No delegate available to handle REFER, automatically accepting and following."), t.accept().then(() => t.makeInviter(this._referralInviterOptions).invite()).catch((i) => {
2631
2631
  this.logger.error(i.message);
2632
2632
  }));
@@ -2677,7 +2677,7 @@ class ge {
2677
2677
  getOffer(e) {
2678
2678
  const t = this.setupSessionDescriptionHandler(), i = e.sessionDescriptionHandlerOptions, s = e.sessionDescriptionHandlerModifiers;
2679
2679
  try {
2680
- return t.getDescription(i, s).then((r) => Re(r)).catch((r) => {
2680
+ return t.getDescription(i, s).then((r) => xe(r)).catch((r) => {
2681
2681
  this.logger.error("Session.getOffer: SDH getDescription rejected...");
2682
2682
  const n = r instanceof Error ? r : new Error("Session.getOffer unknown error.");
2683
2683
  throw this.logger.error(n.message), n;
@@ -2749,7 +2749,7 @@ class ge {
2749
2749
  return this.logger.error(o.message), Promise.reject(o);
2750
2750
  }
2751
2751
  try {
2752
- return i.setDescription(e.content, s, r).then(() => i.getDescription(s, r)).then((n) => Re(n)).catch((n) => {
2752
+ return i.setDescription(e.content, s, r).then(() => i.getDescription(s, r)).then((n) => xe(n)).catch((n) => {
2753
2753
  this.logger.error("Session.setOfferAndGetAnswer: SDH setDescription or getDescription rejected...");
2754
2754
  const o = n instanceof Error ? n : new Error("Session.setOfferAndGetAnswer unknown error.");
2755
2755
  throw this.logger.error(o.message), o;
@@ -2843,7 +2843,7 @@ var G;
2843
2843
  (function(a) {
2844
2844
  a.Required = "Required", a.Supported = "Supported", a.Unsupported = "Unsupported";
2845
2845
  })(G = G || (G = {}));
2846
- const Ht = {
2846
+ const Pt = {
2847
2847
  "100rel": !0,
2848
2848
  199: !0,
2849
2849
  answermode: !0,
@@ -3033,7 +3033,7 @@ class ce extends ge {
3033
3033
  const t = e.statusCode || 480, i = e.reasonPhrase ? e.reasonPhrase : _e(t), s = e.extraHeaders || [];
3034
3034
  if (t < 300 || t > 699)
3035
3035
  throw new TypeError("Invalid statusCode: " + t);
3036
- const r = e.body ? Re(e.body) : void 0;
3036
+ const r = e.body ? xe(e.body) : void 0;
3037
3037
  return t < 400 ? this.incomingInviteRequest.redirect([], { statusCode: t, reasonPhrase: i, extraHeaders: s, body: r }) : this.incomingInviteRequest.reject({ statusCode: t, reasonPhrase: i, extraHeaders: s, body: r }), this.stateTransition(m.Terminated), Promise.resolve();
3038
3038
  }
3039
3039
  /**
@@ -3049,7 +3049,7 @@ class ce extends ge {
3049
3049
  return;
3050
3050
  }
3051
3051
  if (this.delegate && this.delegate.onCancel) {
3052
- const t = new It(e);
3052
+ const t = new Rt(e);
3053
3053
  this.delegate.onCancel(t);
3054
3054
  }
3055
3055
  this.isCanceled = !0, this.incomingInviteRequest.reject({ statusCode: 487 }), this.stateTransition(m.Terminated);
@@ -3092,7 +3092,7 @@ class ce extends ge {
3092
3092
  */
3093
3093
  handleResponseError(e) {
3094
3094
  let t = 480;
3095
- if (e instanceof Error ? this.logger.error(e.message) : this.logger.error(e), e instanceof Be ? (this.logger.error("A session description handler occurred while sending response (content type unsupported"), t = 415) : e instanceof Et ? this.logger.error("A session description handler occurred while sending response") : e instanceof He ? this.logger.error("Session ended before response could be formulated and sent (while waiting for PRACK)") : e instanceof ie && this.logger.error("Session changed state before response could be formulated and sent"), this.state === m.Initial || this.state === m.Establishing)
3095
+ if (e instanceof Error ? this.logger.error(e.message) : this.logger.error(e), e instanceof Be ? (this.logger.error("A session description handler occurred while sending response (content type unsupported"), t = 415) : e instanceof Ct ? this.logger.error("A session description handler occurred while sending response") : e instanceof He ? this.logger.error("Session ended before response could be formulated and sent (while waiting for PRACK)") : e instanceof ie && this.logger.error("Session changed state before response could be formulated and sent"), this.state === m.Initial || this.state === m.Establishing)
3096
3096
  try {
3097
3097
  this.incomingInviteRequest.reject({ statusCode: t }), this.stateTransition(m.Terminated);
3098
3098
  } catch (i) {
@@ -3129,7 +3129,7 @@ class ce extends ge {
3129
3129
  * @param options - Options bucket.
3130
3130
  */
3131
3131
  sendProgress(e = {}) {
3132
- const t = e.statusCode || 180, i = e.reasonPhrase, s = (e.extraHeaders || []).slice(), r = e.body ? Re(e.body) : void 0;
3132
+ const t = e.statusCode || 180, i = e.reasonPhrase, s = (e.extraHeaders || []).slice(), r = e.body ? xe(e.body) : void 0;
3133
3133
  if (t === 183 && !r)
3134
3134
  return this.sendProgressWithSDP(e);
3135
3135
  try {
@@ -3716,7 +3716,7 @@ class Ce extends ge {
3716
3716
  }
3717
3717
  }
3718
3718
  }
3719
- class Mt {
3719
+ class Ht {
3720
3720
  /**
3721
3721
  * Constructs a new instance of the `Messager` class.
3722
3722
  * @param userAgent - User agent. See {@link UserAgent} for details.
@@ -3747,10 +3747,10 @@ class Mt {
3747
3747
  return this.userAgent.userAgentCore.request(this.request, e.requestDelegate), Promise.resolve();
3748
3748
  }
3749
3749
  }
3750
- var R;
3750
+ var x;
3751
3751
  (function(a) {
3752
3752
  a.Initial = "Initial", a.Registered = "Registered", a.Unregistered = "Unregistered", a.Terminated = "Terminated";
3753
- })(R = R || (R = {}));
3753
+ })(x = x || (x = {}));
3754
3754
  class z {
3755
3755
  /**
3756
3756
  * Constructs a new instance of the `Registerer` class.
@@ -3758,7 +3758,7 @@ class z {
3758
3758
  * @param options - Options bucket. See {@link RegistererOptions} for details.
3759
3759
  */
3760
3760
  constructor(e, t = {}) {
3761
- this.disposed = !1, this._contacts = [], this._retryAfter = void 0, this._state = R.Initial, this._waiting = !1, this._stateEventEmitter = new be(), this._waitingEventEmitter = new be(), this.userAgent = e;
3761
+ this.disposed = !1, this._contacts = [], this._retryAfter = void 0, this._state = x.Initial, this._waiting = !1, this._stateEventEmitter = new be(), this._waitingEventEmitter = new be(), this.userAgent = e;
3762
3762
  const i = e.configuration.uri.clone();
3763
3763
  if (i.user = void 0, this.options = Object.assign(Object.assign(Object.assign({}, z.defaultOptions()), { registrar: i }), z.stripUndefinedProperties(t)), this.options.extraContactHeaderParams = (this.options.extraContactHeaderParams || []).slice(), this.options.extraHeaders = (this.options.extraHeaders || []).slice(), !this.options.registrar)
3764
3764
  throw new Error("Registrar undefined.");
@@ -3851,7 +3851,7 @@ class z {
3851
3851
  dispose() {
3852
3852
  return this.disposed ? Promise.resolve() : (this.disposed = !0, this.logger.log(`Registerer ${this.id} in state ${this.state} is being disposed`), delete this.userAgent._registerers[this.id], new Promise((e) => {
3853
3853
  const t = () => {
3854
- if (!this.waiting && this._state === R.Registered) {
3854
+ if (!this.waiting && this._state === x.Registered) {
3855
3855
  this.stateChange.addListener(() => {
3856
3856
  this.terminated(), e();
3857
3857
  }, { once: !0 }), this.unregister();
@@ -3871,7 +3871,7 @@ class z {
3871
3871
  * Rejects with `RequestPendingError` if a REGISTER request is already in progress.
3872
3872
  */
3873
3873
  register(e = {}) {
3874
- if (this.state === R.Terminated)
3874
+ if (this.state === x.Terminated)
3875
3875
  throw this.stateError(), new Error("Registerer terminated. Unable to register.");
3876
3876
  if (this.disposed)
3877
3877
  throw this.stateError(), new Error("Registerer disposed. Unable to register.");
@@ -3964,16 +3964,16 @@ class z {
3964
3964
  * Rejects with `RequestPendingError` if a REGISTER request is already in progress.
3965
3965
  */
3966
3966
  unregister(e = {}) {
3967
- if (this.state === R.Terminated)
3967
+ if (this.state === x.Terminated)
3968
3968
  throw this.stateError(), new Error("Registerer terminated. Unable to register.");
3969
- if (this.disposed && this.state !== R.Registered)
3969
+ if (this.disposed && this.state !== x.Registered)
3970
3970
  throw this.stateError(), new Error("Registerer disposed. Unable to register.");
3971
3971
  if (this.waiting) {
3972
3972
  this.waitingWarning();
3973
3973
  const s = new ye("REGISTER request already in progress, waiting for final response");
3974
3974
  return Promise.reject(s);
3975
3975
  }
3976
- this._state !== R.Registered && !e.all && this.logger.warn("Not currently registered, but sending an unregister anyway.");
3976
+ this._state !== x.Registered && !e.all && this.logger.warn("Not currently registered, but sending an unregister anyway.");
3977
3977
  const t = (e.requestOptions && e.requestOptions.extraHeaders || []).slice();
3978
3978
  this.request.extraHeaders = t, e.all ? (t.push("Contact: *"), t.push("Expires: 0")) : t.push("Contact: " + this.generateContactHeader(0)), this.request.cseq++, this.request.setHeader("cseq", this.request.cseq + " REGISTER"), this.registrationTimer !== void 0 && (clearTimeout(this.registrationTimer), this.registrationTimer = void 0), this.waitingToggle(!0);
3979
3979
  const i = this.userAgent.userAgentCore.register(this.request, {
@@ -4018,19 +4018,19 @@ class z {
4018
4018
  this.registrationTimer = void 0, this.register();
4019
4019
  }, this.refreshFrequency / 100 * e * 1e3), this.registrationExpiredTimer = setTimeout(() => {
4020
4020
  this.logger.warn("Registration expired"), this.unregistered();
4021
- }, e * 1e3), this._state !== R.Registered && this.stateTransition(R.Registered);
4021
+ }, e * 1e3), this._state !== x.Registered && this.stateTransition(x.Registered);
4022
4022
  }
4023
4023
  /**
4024
4024
  * Helper function, called when unregistered.
4025
4025
  */
4026
4026
  unregistered() {
4027
- this.clearTimers(), this._state !== R.Unregistered && this.stateTransition(R.Unregistered);
4027
+ this.clearTimers(), this._state !== x.Unregistered && this.stateTransition(x.Unregistered);
4028
4028
  }
4029
4029
  /**
4030
4030
  * Helper function, called when terminated.
4031
4031
  */
4032
4032
  terminated() {
4033
- this.clearTimers(), this._state !== R.Terminated && this.stateTransition(R.Terminated);
4033
+ this.clearTimers(), this._state !== x.Terminated && this.stateTransition(x.Terminated);
4034
4034
  }
4035
4035
  /**
4036
4036
  * Transition registration state.
@@ -4040,22 +4040,22 @@ class z {
4040
4040
  throw new Error(`Invalid state transition from ${this._state} to ${e}`);
4041
4041
  };
4042
4042
  switch (this._state) {
4043
- case R.Initial:
4044
- e !== R.Registered && e !== R.Unregistered && e !== R.Terminated && t();
4043
+ case x.Initial:
4044
+ e !== x.Registered && e !== x.Unregistered && e !== x.Terminated && t();
4045
4045
  break;
4046
- case R.Registered:
4047
- e !== R.Unregistered && e !== R.Terminated && t();
4046
+ case x.Registered:
4047
+ e !== x.Unregistered && e !== x.Terminated && t();
4048
4048
  break;
4049
- case R.Unregistered:
4050
- e !== R.Registered && e !== R.Terminated && t();
4049
+ case x.Unregistered:
4050
+ e !== x.Registered && e !== x.Terminated && t();
4051
4051
  break;
4052
- case R.Terminated:
4052
+ case x.Terminated:
4053
4053
  t();
4054
4054
  break;
4055
4055
  default:
4056
4056
  throw new Error("Unrecognized state.");
4057
4057
  }
4058
- this._state = e, this.logger.log(`Registration transitioned to state ${this._state}`), this._stateEventEmitter.emit(this._state), e === R.Terminated && this.dispose();
4058
+ this._state = e, this.logger.log(`Registration transitioned to state ${this._state}`), this._stateEventEmitter.emit(this._state), e === x.Terminated && this.dispose();
4059
4059
  }
4060
4060
  /** True if the registerer is currently waiting for final response to a REGISTER request. */
4061
4061
  get waiting() {
@@ -4080,16 +4080,16 @@ class z {
4080
4080
  }
4081
4081
  /** Hopefully helpful as the standard behavior has been found to be unexpected. */
4082
4082
  stateError() {
4083
- let t = `An attempt was made to send a REGISTER request when the Registerer ${this.state === R.Terminated ? "is in 'Terminated' state" : "has been disposed"}.`;
4083
+ let t = `An attempt was made to send a REGISTER request when the Registerer ${this.state === x.Terminated ? "is in 'Terminated' state" : "has been disposed"}.`;
4084
4084
  t += " The Registerer transitions to 'Terminated' when Registerer.dispose() is called.", t += " Perhaps you called UserAgent.stop() which dipsoses of all Registerers?", this.logger.error(t);
4085
4085
  }
4086
4086
  }
4087
4087
  z.defaultExpires = 600;
4088
4088
  z.defaultRefreshFrequency = 99;
4089
- var x;
4089
+ var R;
4090
4090
  (function(a) {
4091
4091
  a.Initial = "Initial", a.NotifyWait = "NotifyWait", a.Pending = "Pending", a.Active = "Active", a.Terminated = "Terminated";
4092
- })(x = x || (x = {}));
4092
+ })(R = R || (R = {}));
4093
4093
  var T;
4094
4094
  (function(a) {
4095
4095
  a.Connecting = "Connecting", a.Connected = "Connected", a.Disconnecting = "Disconnecting", a.Disconnected = "Disconnected";
@@ -4208,7 +4208,7 @@ P.hashStr("hello") !== "5d41402abc4b2a76b9719d911017c592" && console.error("Md5
4208
4208
  function ee(a) {
4209
4209
  return P.hashStr(a);
4210
4210
  }
4211
- class qt {
4211
+ class Mt {
4212
4212
  /**
4213
4213
  * Constructor.
4214
4214
  * @param loggerFactory - LoggerFactory.
@@ -4301,7 +4301,7 @@ class Xe {
4301
4301
  this.logger.level = e;
4302
4302
  }
4303
4303
  }
4304
- class Ot {
4304
+ class qt {
4305
4305
  constructor() {
4306
4306
  this.builtinEnabled = !0, this._level = H.log, this.loggers = {}, this.logger = this.getLogger("sip:loggerfactory");
4307
4307
  }
@@ -5653,7 +5653,7 @@ class q {
5653
5653
  this.core.userAgentClients.set(i, this);
5654
5654
  }
5655
5655
  }
5656
- class Ft extends q {
5656
+ class Ot extends q {
5657
5657
  constructor(e, t, i) {
5658
5658
  const s = e.createOutgoingRequestMessage(v.BYE, i);
5659
5659
  super(L, e.userAgentCore, s, t), e.dispose();
@@ -5942,18 +5942,18 @@ class J {
5942
5942
  this.core.userAgentServers.set(t.id, this);
5943
5943
  }
5944
5944
  }
5945
- class Nt extends J {
5945
+ class Ft extends J {
5946
5946
  constructor(e, t, i) {
5947
5947
  super(U, e.userAgentCore, t, i);
5948
5948
  }
5949
5949
  }
5950
- class Ut extends q {
5950
+ class Nt extends q {
5951
5951
  constructor(e, t, i) {
5952
5952
  const s = e.createOutgoingRequestMessage(v.INFO, i);
5953
5953
  super(L, e.userAgentCore, s, t);
5954
5954
  }
5955
5955
  }
5956
- class Lt extends J {
5956
+ class Ut extends J {
5957
5957
  constructor(e, t, i) {
5958
5958
  super(U, e.userAgentCore, t, i);
5959
5959
  }
@@ -5968,33 +5968,33 @@ class ft extends J {
5968
5968
  super(U, e, t, i);
5969
5969
  }
5970
5970
  }
5971
- class Bt extends q {
5971
+ class Lt extends q {
5972
5972
  constructor(e, t, i) {
5973
5973
  const s = e.createOutgoingRequestMessage(v.NOTIFY, i);
5974
5974
  super(L, e.userAgentCore, s, t);
5975
5975
  }
5976
5976
  }
5977
- function jt(a) {
5977
+ function Bt(a) {
5978
5978
  return a.userAgentCore !== void 0;
5979
5979
  }
5980
- class xe extends J {
5980
+ class Re extends J {
5981
5981
  /**
5982
5982
  * NOTIFY UAS constructor.
5983
5983
  * @param dialogOrCore - Dialog for in dialog NOTIFY, UserAgentCore for out of dialog NOTIFY (deprecated).
5984
5984
  * @param message - Incoming NOTIFY request message.
5985
5985
  */
5986
5986
  constructor(e, t, i) {
5987
- const s = jt(e) ? e.userAgentCore : e;
5987
+ const s = Bt(e) ? e.userAgentCore : e;
5988
5988
  super(U, s, t, i);
5989
5989
  }
5990
5990
  }
5991
- class Vt extends q {
5991
+ class jt extends q {
5992
5992
  constructor(e, t, i) {
5993
5993
  const s = e.createOutgoingRequestMessage(v.PRACK, i);
5994
5994
  super(L, e.userAgentCore, s, t), e.signalingStateTransition(s);
5995
5995
  }
5996
5996
  }
5997
- class Gt extends J {
5997
+ class Vt extends J {
5998
5998
  constructor(e, t, i) {
5999
5999
  super(U, e.userAgentCore, t, i), e.signalingStateTransition(t), this.dialog = e;
6000
6000
  }
@@ -6006,7 +6006,7 @@ class Gt extends J {
6006
6006
  return e.body && this.dialog.signalingStateTransition(e.body), super.accept(e);
6007
6007
  }
6008
6008
  }
6009
- class Wt extends q {
6009
+ class Gt extends q {
6010
6010
  constructor(e, t, i) {
6011
6011
  const s = e.createOutgoingRequestMessage(v.INVITE, i);
6012
6012
  super(re, e.userAgentCore, s, t), this.delegate = t, e.signalingStateTransition(s), e.reinviteUserAgentClient = this, this.dialog = e;
@@ -6049,7 +6049,7 @@ class Wt extends q {
6049
6049
  }
6050
6050
  }
6051
6051
  }
6052
- class Kt extends J {
6052
+ class Wt extends J {
6053
6053
  constructor(e, t, i) {
6054
6054
  super(N, e.userAgentCore, t, i), e.reinviteUserAgentServer = this, this.dialog = e;
6055
6055
  }
@@ -6091,13 +6091,13 @@ class Kt extends J {
6091
6091
  return this.dialog.signalingStateRollback(), this.dialog.reinviteUserAgentServer = void 0, super.reject(e);
6092
6092
  }
6093
6093
  }
6094
- class zt extends q {
6094
+ class Kt extends q {
6095
6095
  constructor(e, t, i) {
6096
6096
  const s = e.createOutgoingRequestMessage(v.REFER, i);
6097
6097
  super(L, e.userAgentCore, s, t);
6098
6098
  }
6099
6099
  }
6100
- function Yt(a) {
6100
+ function zt(a) {
6101
6101
  return a.userAgentCore !== void 0;
6102
6102
  }
6103
6103
  class pt extends J {
@@ -6107,7 +6107,7 @@ class pt extends J {
6107
6107
  * @param message - Incoming REFER request message.
6108
6108
  */
6109
6109
  constructor(e, t, i) {
6110
- const s = Yt(e) ? e.userAgentCore : e;
6110
+ const s = zt(e) ? e.userAgentCore : e;
6111
6111
  super(U, s, t, i);
6112
6112
  }
6113
6113
  }
@@ -6220,7 +6220,7 @@ class Ie extends fe {
6220
6220
  if (this.ackWait && this.initialTransaction.state !== g.Terminated)
6221
6221
  throw new Error("UAS MUST NOT send a BYE on a confirmed dialog until it has received an ACK for its 2xx response or until the server transaction times out.");
6222
6222
  }
6223
- return new Ft(this, e, t);
6223
+ return new Ot(this, e, t);
6224
6224
  }
6225
6225
  /**
6226
6226
  * An INFO request can be associated with an Info Package (see
@@ -6235,7 +6235,7 @@ class Ie extends fe {
6235
6235
  info(e, t) {
6236
6236
  if (this.logger.log(`INVITE dialog ${this.id} sending INFO request`), this.early)
6237
6237
  throw new Error("Dialog not confirmed.");
6238
- return new Ut(this, e, t);
6238
+ return new Nt(this, e, t);
6239
6239
  }
6240
6240
  /**
6241
6241
  * Modifying an Existing Session
@@ -6265,7 +6265,7 @@ class Ie extends fe {
6265
6265
  throw new Error("There is an ongoing re-INVITE client transaction.");
6266
6266
  if (this.reinviteUserAgentServer)
6267
6267
  throw new Error("There is an ongoing re-INVITE server transaction.");
6268
- return new Wt(this, e, t);
6268
+ return new Gt(this, e, t);
6269
6269
  }
6270
6270
  /**
6271
6271
  * A UAC MAY associate a MESSAGE request with an existing dialog. If a
@@ -6289,7 +6289,7 @@ class Ie extends fe {
6289
6289
  notify(e, t) {
6290
6290
  if (this.logger.log(`INVITE dialog ${this.id} sending NOTIFY request`), this.early)
6291
6291
  throw new Error("Dialog not confirmed.");
6292
- return new Bt(this, e, t);
6292
+ return new Lt(this, e, t);
6293
6293
  }
6294
6294
  /**
6295
6295
  * Assuming the response is to be transmitted reliably, the UAC MUST
@@ -6302,7 +6302,7 @@ class Ie extends fe {
6302
6302
  * @param options - Options bucket.
6303
6303
  */
6304
6304
  prack(e, t) {
6305
- return this.logger.log(`INVITE dialog ${this.id} sending PRACK request`), new Vt(this, e, t);
6305
+ return this.logger.log(`INVITE dialog ${this.id} sending PRACK request`), new jt(this, e, t);
6306
6306
  }
6307
6307
  /**
6308
6308
  * REFER is a SIP request and is constructed as defined in [1]. A REFER
@@ -6313,7 +6313,7 @@ class Ie extends fe {
6313
6313
  refer(e, t) {
6314
6314
  if (this.logger.log(`INVITE dialog ${this.id} sending REFER request`), this.early)
6315
6315
  throw new Error("Dialog not confirmed.");
6316
- return new zt(this, e, t);
6316
+ return new Kt(this, e, t);
6317
6317
  }
6318
6318
  /**
6319
6319
  * Requests sent within a dialog, as any other requests, are atomic. If
@@ -6391,13 +6391,13 @@ class Ie extends fe {
6391
6391
  switch (e.method) {
6392
6392
  case v.BYE:
6393
6393
  {
6394
- const t = new Nt(this, e);
6394
+ const t = new Ft(this, e);
6395
6395
  this.delegate && this.delegate.onBye ? this.delegate.onBye(t) : t.accept(), this.dispose();
6396
6396
  }
6397
6397
  break;
6398
6398
  case v.INFO:
6399
6399
  {
6400
- const t = new Lt(this, e);
6400
+ const t = new Ut(this, e);
6401
6401
  this.delegate && this.delegate.onInfo ? this.delegate.onInfo(t) : t.reject({
6402
6402
  statusCode: 469,
6403
6403
  extraHeaders: ["Recv-Info:"]
@@ -6406,7 +6406,7 @@ class Ie extends fe {
6406
6406
  break;
6407
6407
  case v.INVITE:
6408
6408
  {
6409
- const t = new Kt(this, e);
6409
+ const t = new Wt(this, e);
6410
6410
  this.signalingStateTransition(e), this.delegate && this.delegate.onInvite ? this.delegate.onInvite(t) : t.reject({ statusCode: 488 });
6411
6411
  }
6412
6412
  break;
@@ -6418,13 +6418,13 @@ class Ie extends fe {
6418
6418
  break;
6419
6419
  case v.NOTIFY:
6420
6420
  {
6421
- const t = new xe(this, e);
6421
+ const t = new Re(this, e);
6422
6422
  this.delegate && this.delegate.onNotify ? this.delegate.onNotify(t) : t.accept();
6423
6423
  }
6424
6424
  break;
6425
6425
  case v.PRACK:
6426
6426
  {
6427
- const t = new Gt(this, e);
6427
+ const t = new Vt(this, e);
6428
6428
  this.delegate && this.delegate.onPrack ? this.delegate.onPrack(t) : t.accept();
6429
6429
  }
6430
6430
  break;
@@ -6575,7 +6575,7 @@ class Ie extends fe {
6575
6575
  }
6576
6576
  }
6577
6577
  }
6578
- class Jt extends q {
6578
+ class Yt extends q {
6579
6579
  constructor(e, t, i) {
6580
6580
  super(re, e, t, i), this.confirmedDialogAcks = /* @__PURE__ */ new Map(), this.confirmedDialogs = /* @__PURE__ */ new Map(), this.earlyDialogs = /* @__PURE__ */ new Map(), this.delegate = i;
6581
6581
  }
@@ -6799,22 +6799,22 @@ class Oe extends J {
6799
6799
  return super.reject(e);
6800
6800
  }
6801
6801
  }
6802
- class Zt extends q {
6802
+ class Jt extends q {
6803
6803
  constructor(e, t, i) {
6804
6804
  super(L, e, t, i);
6805
6805
  }
6806
6806
  }
6807
- class Xt extends q {
6807
+ class Zt extends q {
6808
6808
  constructor(e, t, i) {
6809
6809
  super(L, e, t, i);
6810
6810
  }
6811
6811
  }
6812
- class Qt extends J {
6812
+ class Xt extends J {
6813
6813
  constructor(e, t, i) {
6814
6814
  super(U, e, t, i), this.core = e;
6815
6815
  }
6816
6816
  }
6817
- class ei extends q {
6817
+ class Qt extends q {
6818
6818
  constructor(e, t, i) {
6819
6819
  const s = e.createOutgoingRequestMessage(v.SUBSCRIBE, i);
6820
6820
  super(L, e.userAgentCore, s, t), this.dialog = e;
@@ -6948,10 +6948,10 @@ class Qe extends fe {
6948
6948
  */
6949
6949
  subscribe(e, t = {}) {
6950
6950
  var i;
6951
- if (this.subscriptionState !== x.Pending && this.subscriptionState !== x.Active)
6951
+ if (this.subscriptionState !== R.Pending && this.subscriptionState !== R.Active)
6952
6952
  throw new Error(`Invalid state ${this.subscriptionState}. May only re-subscribe while in state "pending" or "active".`);
6953
6953
  this.logger.log(`SUBSCRIBE dialog ${this.id} sending SUBSCRIBE request`);
6954
- const s = new ei(this, e, t);
6954
+ const s = new Qt(this, e, t);
6955
6955
  return this.N && (clearTimeout(this.N), this.N = void 0), !((i = t.extraHeaders) === null || i === void 0) && i.includes("Expires: 0") || (this.N = setTimeout(() => this.timerN(), M.TIMER_N)), s;
6956
6956
  }
6957
6957
  /**
@@ -6962,7 +6962,7 @@ class Qe extends fe {
6962
6962
  * https://tools.ietf.org/html/rfc6665#section-4.4.1
6963
6963
  */
6964
6964
  terminate() {
6965
- this.stateTransition(x.Terminated), this.onTerminated();
6965
+ this.stateTransition(R.Terminated), this.onTerminated();
6966
6966
  }
6967
6967
  /**
6968
6968
  * 4.1.2.3. Unsubscribing
@@ -6992,19 +6992,19 @@ class Qe extends fe {
6992
6992
  const s = i.state, r = i.expires ? Math.max(i.expires, 0) : void 0;
6993
6993
  switch (s) {
6994
6994
  case "pending":
6995
- this.stateTransition(x.Pending, r);
6995
+ this.stateTransition(R.Pending, r);
6996
6996
  break;
6997
6997
  case "active":
6998
- this.stateTransition(x.Active, r);
6998
+ this.stateTransition(R.Active, r);
6999
6999
  break;
7000
7000
  case "terminated":
7001
- this.stateTransition(x.Terminated, r);
7001
+ this.stateTransition(R.Terminated, r);
7002
7002
  break;
7003
7003
  default:
7004
7004
  this.logger.warn("Unrecognized subscription state.");
7005
7005
  break;
7006
7006
  }
7007
- const n = new xe(this, e);
7007
+ const n = new Re(this, e);
7008
7008
  this.delegate && this.delegate.onNotify ? this.delegate.onNotify(n) : n.accept();
7009
7009
  }
7010
7010
  onRefresh(e) {
@@ -7029,26 +7029,26 @@ class Qe extends fe {
7029
7029
  this.logger.warn(`Invalid subscription state transition from ${this.subscriptionState} to ${e}`);
7030
7030
  };
7031
7031
  switch (e) {
7032
- case x.Initial:
7032
+ case R.Initial:
7033
7033
  i();
7034
7034
  return;
7035
- case x.NotifyWait:
7035
+ case R.NotifyWait:
7036
7036
  i();
7037
7037
  return;
7038
- case x.Pending:
7039
- if (this.subscriptionState !== x.NotifyWait && this.subscriptionState !== x.Pending) {
7038
+ case R.Pending:
7039
+ if (this.subscriptionState !== R.NotifyWait && this.subscriptionState !== R.Pending) {
7040
7040
  i();
7041
7041
  return;
7042
7042
  }
7043
7043
  break;
7044
- case x.Active:
7045
- if (this.subscriptionState !== x.NotifyWait && this.subscriptionState !== x.Pending && this.subscriptionState !== x.Active) {
7044
+ case R.Active:
7045
+ if (this.subscriptionState !== R.NotifyWait && this.subscriptionState !== R.Pending && this.subscriptionState !== R.Active) {
7046
7046
  i();
7047
7047
  return;
7048
7048
  }
7049
7049
  break;
7050
- case x.Terminated:
7051
- if (this.subscriptionState !== x.NotifyWait && this.subscriptionState !== x.Pending && this.subscriptionState !== x.Active) {
7050
+ case R.Terminated:
7051
+ if (this.subscriptionState !== R.NotifyWait && this.subscriptionState !== R.Pending && this.subscriptionState !== R.Active) {
7052
7052
  i();
7053
7053
  return;
7054
7054
  }
@@ -7057,7 +7057,7 @@ class Qe extends fe {
7057
7057
  i();
7058
7058
  return;
7059
7059
  }
7060
- e === x.Pending && t && (this.subscriptionExpires = t), e === x.Active && t && (this.subscriptionExpires = t), e === x.Terminated && this.dispose(), this._subscriptionState = e;
7060
+ e === R.Pending && t && (this.subscriptionExpires = t), e === R.Active && t && (this.subscriptionExpires = t), e === R.Terminated && this.dispose(), this._subscriptionState = e;
7061
7061
  }
7062
7062
  /**
7063
7063
  * When refreshing a subscription, a subscriber starts Timer N, set to
@@ -7071,10 +7071,10 @@ class Qe extends fe {
7071
7071
  * https://tools.ietf.org/html/rfc6665#section-4.1.2.2
7072
7072
  */
7073
7073
  timerN() {
7074
- this.logger.warn("Timer N expired for SUBSCRIBE dialog. Timed out waiting for NOTIFY."), this.subscriptionState !== x.Terminated && (this.stateTransition(x.Terminated), this.onTerminated());
7074
+ this.logger.warn("Timer N expired for SUBSCRIBE dialog. Timed out waiting for NOTIFY."), this.subscriptionState !== R.Terminated && (this.stateTransition(R.Terminated), this.onTerminated());
7075
7075
  }
7076
7076
  }
7077
- class ti extends q {
7077
+ class ei extends q {
7078
7078
  constructor(e, t, i) {
7079
7079
  const s = t.getHeader("Event");
7080
7080
  if (!s)
@@ -7082,7 +7082,7 @@ class ti extends q {
7082
7082
  const r = t.getHeader("Expires");
7083
7083
  if (!r)
7084
7084
  throw new Error("Expires undefined");
7085
- super(L, e, t, i), this.delegate = i, this.subscriberId = t.callId + t.fromTag + s, this.subscriptionExpiresRequested = this.subscriptionExpires = Number(r), this.subscriptionEvent = s, this.subscriptionState = x.NotifyWait, this.waitNotifyStart();
7085
+ super(L, e, t, i), this.delegate = i, this.subscriberId = t.callId + t.fromTag + s, this.subscriptionExpiresRequested = this.subscriptionExpires = Number(r), this.subscriptionEvent = s, this.subscriptionState = R.NotifyWait, this.waitNotifyStart();
7086
7086
  }
7087
7087
  /**
7088
7088
  * Destructor.
@@ -7132,18 +7132,18 @@ class ti extends q {
7132
7132
  throw new Error("Dialog already created. This implementation only supports install of single subscriptions.");
7133
7133
  switch (this.waitNotifyStop(), this.subscriptionExpires = i.expires ? Math.min(this.subscriptionExpires, Math.max(i.expires, 0)) : this.subscriptionExpires, s) {
7134
7134
  case "pending":
7135
- this.subscriptionState = x.Pending;
7135
+ this.subscriptionState = R.Pending;
7136
7136
  break;
7137
7137
  case "active":
7138
- this.subscriptionState = x.Active;
7138
+ this.subscriptionState = R.Active;
7139
7139
  break;
7140
7140
  case "terminated":
7141
- this.subscriptionState = x.Terminated;
7141
+ this.subscriptionState = R.Terminated;
7142
7142
  break;
7143
7143
  default:
7144
7144
  throw new Error(`Unrecognized state ${s}.`);
7145
7145
  }
7146
- if (this.subscriptionState !== x.Terminated) {
7146
+ if (this.subscriptionState !== R.Terminated) {
7147
7147
  const r = Qe.initialDialogStateForSubscription(this.message, e.message);
7148
7148
  this.dialog = new Qe(this.subscriptionEvent, this.subscriptionExpires, this.subscriptionState, this.core, r);
7149
7149
  }
@@ -7191,13 +7191,13 @@ class ti extends q {
7191
7191
  this.logger.warn("Timer N expired for SUBSCRIBE user agent client. Timed out waiting for NOTIFY."), this.waitNotifyStop(), this.delegate && this.delegate.onNotifyTimeout && this.delegate.onNotifyTimeout();
7192
7192
  }
7193
7193
  }
7194
- class ii extends J {
7194
+ class ti extends J {
7195
7195
  constructor(e, t, i) {
7196
7196
  super(U, e, t, i), this.core = e;
7197
7197
  }
7198
7198
  }
7199
7199
  const et = ["application/sdp", "application/dtmf-relay"];
7200
- class si {
7200
+ class ii {
7201
7201
  /**
7202
7202
  * Constructor.
7203
7203
  * @param configuration - Configuration.
@@ -7231,7 +7231,7 @@ class si {
7231
7231
  * @param delegate - Request delegate.
7232
7232
  */
7233
7233
  invite(e, t) {
7234
- return new Jt(this, e, t);
7234
+ return new Yt(this, e, t);
7235
7235
  }
7236
7236
  /**
7237
7237
  * Send MESSAGE.
@@ -7247,7 +7247,7 @@ class si {
7247
7247
  * @param delegate - Request delegate.
7248
7248
  */
7249
7249
  publish(e, t) {
7250
- return new Zt(this, e, t);
7250
+ return new Jt(this, e, t);
7251
7251
  }
7252
7252
  /**
7253
7253
  * Send REGISTER.
@@ -7255,7 +7255,7 @@ class si {
7255
7255
  * @param delegate - Request delegate.
7256
7256
  */
7257
7257
  register(e, t) {
7258
- return new Xt(this, e, t);
7258
+ return new Zt(this, e, t);
7259
7259
  }
7260
7260
  /**
7261
7261
  * Send SUBSCRIBE.
@@ -7263,7 +7263,7 @@ class si {
7263
7263
  * @param delegate - Request delegate.
7264
7264
  */
7265
7265
  subscribe(e, t) {
7266
- return new ti(this, e, t);
7266
+ return new ei(this, e, t);
7267
7267
  }
7268
7268
  /**
7269
7269
  * Send a request.
@@ -7428,7 +7428,7 @@ class si {
7428
7428
  }
7429
7429
  const r = e.callId + e.toTag + s.event, n = this.subscribers.get(r);
7430
7430
  if (n) {
7431
- const o = new xe(this, e);
7431
+ const o = new Re(this, e);
7432
7432
  n.onNotify(o);
7433
7433
  return;
7434
7434
  }
@@ -7480,7 +7480,7 @@ class si {
7480
7480
  break;
7481
7481
  case v.NOTIFY:
7482
7482
  {
7483
- const t = new xe(this, e);
7483
+ const t = new Re(this, e);
7484
7484
  this.delegate.onNotify ? this.delegate.onNotify(t) : t.reject({ statusCode: 405 });
7485
7485
  }
7486
7486
  break;
@@ -7501,13 +7501,13 @@ class si {
7501
7501
  break;
7502
7502
  case v.REGISTER:
7503
7503
  {
7504
- const t = new Qt(this, e);
7504
+ const t = new Xt(this, e);
7505
7505
  this.delegate.onRegister ? this.delegate.onRegister(t) : t.reject({ statusCode: 405 });
7506
7506
  }
7507
7507
  break;
7508
7508
  case v.SUBSCRIBE:
7509
7509
  {
7510
- const t = new ii(this, e);
7510
+ const t = new ti(this, e);
7511
7511
  this.delegate.onSubscribe ? this.delegate.onSubscribe(t) : t.reject({ statusCode: 480 });
7512
7512
  }
7513
7513
  break;
@@ -7533,10 +7533,10 @@ class si {
7533
7533
  i ? i.transaction.receiveResponse(e) : this.logger.warn(`Discarding unmatched ${e.statusCode} response to ${e.method} ${t}.`);
7534
7534
  }
7535
7535
  }
7536
- function ri() {
7536
+ function si() {
7537
7537
  return (a) => !a.audio && !a.video ? Promise.resolve(new MediaStream()) : navigator.mediaDevices === void 0 ? Promise.reject(new Error("Media devices not available in insecure contexts.")) : navigator.mediaDevices.getUserMedia.call(navigator.mediaDevices, a);
7538
7538
  }
7539
- function ni() {
7539
+ function ri() {
7540
7540
  return {
7541
7541
  bundlePolicy: "balanced",
7542
7542
  certificates: void 0,
@@ -8078,12 +8078,12 @@ class O {
8078
8078
  };
8079
8079
  }
8080
8080
  }
8081
- function ai(a) {
8081
+ function ni(a) {
8082
8082
  return (e, t) => {
8083
- a === void 0 && (a = ri());
8083
+ a === void 0 && (a = si());
8084
8084
  const s = {
8085
8085
  iceGatheringTimeout: t?.iceGatheringTimeout !== void 0 ? t?.iceGatheringTimeout : 5e3,
8086
- peerConnectionConfiguration: Object.assign(Object.assign({}, ni()), t?.peerConnectionConfiguration)
8086
+ peerConnectionConfiguration: Object.assign(Object.assign({}, ri()), t?.peerConnectionConfiguration)
8087
8087
  }, r = e.userAgent.getLogger("sip.SessionDescriptionHandler");
8088
8088
  return new O(r, a, s);
8089
8089
  };
@@ -8501,7 +8501,7 @@ class V {
8501
8501
  const s = Math.floor(Math.random() * 254 + 1);
8502
8502
  this.options.viaHost = "192.0.2." + s;
8503
8503
  } else this.options.hackIpInContact && (this.options.viaHost = this.options.hackIpInContact);
8504
- switch (this.loggerFactory = new Ot(), this.logger = this.loggerFactory.getLogger("sip.UserAgent"), this.loggerFactory.builtinEnabled = this.options.logBuiltinEnabled, this.loggerFactory.connector = this.options.logConnector, this.options.logLevel) {
8504
+ switch (this.loggerFactory = new qt(), this.logger = this.loggerFactory.getLogger("sip.UserAgent"), this.loggerFactory.builtinEnabled = this.options.logBuiltinEnabled, this.loggerFactory.connector = this.options.logConnector, this.options.logLevel) {
8505
8505
  case "error":
8506
8506
  this.loggerFactory.level = H.error;
8507
8507
  break;
@@ -8585,7 +8585,7 @@ class V {
8585
8585
  reconnectionAttempts: 0,
8586
8586
  reconnectionDelay: 4,
8587
8587
  sendInitialProvisionalResponse: !0,
8588
- sessionDescriptionHandlerFactory: ai(),
8588
+ sessionDescriptionHandlerFactory: ni(),
8589
8589
  sessionDescriptionHandlerFactoryOptions: {},
8590
8590
  sipExtension100rel: G.Unsupported,
8591
8591
  sipExtensionReplaces: G.Unsupported,
@@ -8594,7 +8594,7 @@ class V {
8594
8594
  transportConstructor: Se,
8595
8595
  transportOptions: {},
8596
8596
  uri: new Y("sip", "anonymous", "anonymous.invalid"),
8597
- userAgentString: "SIP.js/" + Ct,
8597
+ userAgentString: "SIP.js/" + Tt,
8598
8598
  viaHost: ""
8599
8599
  };
8600
8600
  }
@@ -8810,7 +8810,7 @@ class V {
8810
8810
  */
8811
8811
  initCore() {
8812
8812
  let e = [];
8813
- e.push("outbound"), this.options.sipExtension100rel === G.Supported && e.push("100rel"), this.options.sipExtensionReplaces === G.Supported && e.push("replaces"), this.options.sipExtensionExtraSupported && e.push(...this.options.sipExtensionExtraSupported), this.options.hackAllowUnregisteredOptionTags || (e = e.filter((r) => Ht[r])), e = Array.from(new Set(e));
8813
+ e.push("outbound"), this.options.sipExtension100rel === G.Supported && e.push("100rel"), this.options.sipExtensionReplaces === G.Supported && e.push("replaces"), this.options.sipExtensionExtraSupported && e.push(...this.options.sipExtensionExtraSupported), this.options.hackAllowUnregisteredOptionTags || (e = e.filter((r) => Pt[r])), e = Array.from(new Set(e));
8814
8814
  const t = e.slice();
8815
8815
  (this.contact.pubGruu || this.contact.tempGruu) && t.push("gruu");
8816
8816
  const i = {
@@ -8828,7 +8828,7 @@ class V {
8828
8828
  viaHost: this.options.viaHost,
8829
8829
  authenticationFactory: () => {
8830
8830
  const r = this.options.authorizationUsername ? this.options.authorizationUsername : this.options.uri.user, n = this.options.authorizationPassword ? this.options.authorizationPassword : void 0, o = this.options.authorizationHa1 ? this.options.authorizationHa1 : void 0;
8831
- return new qt(this.getLoggerFactory(), o, r, n);
8831
+ return new Mt(this.getLoggerFactory(), o, r, n);
8832
8832
  },
8833
8833
  transportAccessor: () => this.transport
8834
8834
  }, s = {
@@ -8909,7 +8909,7 @@ class V {
8909
8909
  this.logger.warn("Received an out of dialog SUBSCRIBE request"), this.delegate && this.delegate.onSubscribeRequest ? this.delegate.onSubscribeRequest(r) : r.reject({ statusCode: 405 });
8910
8910
  }
8911
8911
  };
8912
- return new si(i, s);
8912
+ return new ii(i, s);
8913
8913
  }
8914
8914
  initTransportCallbacks() {
8915
8915
  this.transport.onConnect = () => this.onTransportConnect(), this.transport.onDisconnect = (e) => this.onTransportDisconnect(e), this.transport.onMessage = (e) => this.onTransportMessage(e);
@@ -9002,7 +9002,7 @@ class V {
9002
9002
  this.logger.log(`Transitioned from ${this._state} to ${e}`), this._state = e, this._stateEventEmitter.emit(this._state);
9003
9003
  }
9004
9004
  }
9005
- function oi() {
9005
+ function ai() {
9006
9006
  return (a, e) => ({ session: e, held: !1, muted: !1 });
9007
9007
  }
9008
9008
  class Ge {
@@ -9017,7 +9017,7 @@ class Ge {
9017
9017
  autoStop: !0,
9018
9018
  delegate: {},
9019
9019
  iceStopWaitingOnServerReflexive: !1,
9020
- managedSessionFactory: oi(),
9020
+ managedSessionFactory: ai(),
9021
9021
  maxSimultaneousSessions: 2,
9022
9022
  media: {},
9023
9023
  optionsPingInterval: -1,
@@ -9207,15 +9207,15 @@ class Ge {
9207
9207
  async register(e) {
9208
9208
  return this.logger.log("Registering UserAgent..."), this.shouldBeRegistered = !0, e !== void 0 && (this.registererRegisterOptions = Object.assign({}, e)), this.registerer || (this.registerer = new z(this.userAgent, this.registererOptions), this.registerer.stateChange.addListener((t) => {
9209
9209
  switch (t) {
9210
- case R.Initial:
9210
+ case x.Initial:
9211
9211
  break;
9212
- case R.Registered:
9212
+ case x.Registered:
9213
9213
  this.delegate && this.delegate.onRegistered && this.delegate.onRegistered();
9214
9214
  break;
9215
- case R.Unregistered:
9215
+ case x.Unregistered:
9216
9216
  this.delegate && this.delegate.onUnregistered && this.delegate.onUnregistered(), this.shouldBeRegistered && this.attemptRegistration();
9217
9217
  break;
9218
- case R.Terminated:
9218
+ case x.Terminated:
9219
9219
  break;
9220
9220
  default:
9221
9221
  throw new Error("Unknown registerer state.");
@@ -9419,7 +9419,7 @@ Duration=` + 2e3
9419
9419
  async message(e, t) {
9420
9420
  this.logger.log("Sending message...");
9421
9421
  const i = V.makeURI(e);
9422
- return i ? new Mt(this.userAgent, i, t).message() : Promise.reject(new Error(`Failed to create a valid URI from "${e}"`));
9422
+ return i ? new Ht(this.userAgent, i, t).message() : Promise.reject(new Error(`Failed to create a valid URI from "${e}"`));
9423
9423
  }
9424
9424
  /** Media constraints. */
9425
9425
  get constraints() {
@@ -9782,7 +9782,7 @@ Duration=` + 2e3
9782
9782
  return this.logger.log(`[${e.id}] Terminating in state ${e.state}, no action taken`), Promise.resolve();
9783
9783
  }
9784
9784
  }
9785
- class ci {
9785
+ class oi {
9786
9786
  /**
9787
9787
  * Constructs a new instance of the `SimpleUser` class.
9788
9788
  * @param server - SIP WebSocket Server URL.
@@ -10051,7 +10051,7 @@ class ci {
10051
10051
  return this.logger.log(`[${this.id}] sending message...`), this.sessionManager.message(e, t);
10052
10052
  }
10053
10053
  }
10054
- const di = 15e3, li = 15e3, Fe = (a, e, t) => {
10054
+ const ci = 15e3, di = 15e3, Fe = (a, e, t) => {
10055
10055
  const i = String(a?.name || a?.code || "").trim(), s = new Error(e);
10056
10056
  return s.name = i || "MediaAccessError", s.code = t, s.cause = a, s;
10057
10057
  }, Ne = (a) => {
@@ -10081,7 +10081,7 @@ const di = 15e3, li = 15e3, Fe = (a, e, t) => {
10081
10081
  "麦克风当前被系统或其他应用占用,无法建立语音通话。请关闭占用麦克风的程序后重试。",
10082
10082
  "media_device_unavailable"
10083
10083
  ) : a;
10084
- }, hi = async (a = "call") => {
10084
+ }, li = async (a = "call") => {
10085
10085
  if (typeof navigator > "u" || !navigator.mediaDevices?.getUserMedia)
10086
10086
  return null;
10087
10087
  let e = null;
@@ -10091,7 +10091,7 @@ const di = 15e3, li = 15e3, Fe = (a, e, t) => {
10091
10091
  throw await Ve(t, a);
10092
10092
  }
10093
10093
  };
10094
- class ui {
10094
+ class hi {
10095
10095
  constructor(e, t = {}) {
10096
10096
  this.account = { ...e }, this.remoteAudioElementId = t.remoteAudioElementId || "sipRemoteAudio", this.remoteAudioElement = t.remoteAudioElement || null, this.onStateChange = t.onStateChange, this.onError = t.onError, this.onAudioLevel = t.onAudioLevel, this.onAudioFrame = t.onAudioFrame, this.simpleUser = null, this.connected = !1, this.registered = !1, this.active = !1, this.lastFailureMeta = null, this.audioContext = null, this.audioMonitors = {
10097
10097
  local: null,
@@ -10099,7 +10099,7 @@ class ui {
10099
10099
  }, this.audioTrackMeta = {
10100
10100
  local: null,
10101
10101
  remote: null
10102
- }, this.ringbackAudio = null, this.ringbackPlaying = !1, this.incomingAudio = null, this.incomingPlaying = !1, this.hangupInitiatedByLocal = !1, this.ringbackToneUrl = this._resolveToneUrl(t.ringbackTone || "ringback1.wav"), this.incomingToneUrl = this._resolveToneUrl(t.incomingTone || "ring1.wav"), this.pendingPlaybackTasks = /* @__PURE__ */ new Map(), this.audioUnlockHandler = null, this.lastSessionMeta = null, this.ensureReadyPromise = null, this.connectionWaiters = /* @__PURE__ */ new Set(), this.registrationWaiters = /* @__PURE__ */ new Set(), this.connectionConfirmTimeoutMs = Number.isFinite(Number(t.connectionConfirmTimeoutMs)) ? Number(t.connectionConfirmTimeoutMs) : di, this.registrationConfirmTimeoutMs = Number.isFinite(Number(t.registrationConfirmTimeoutMs)) ? Number(t.registrationConfirmTimeoutMs) : li, this.peerConnectionDebug = {
10102
+ }, this.ringbackAudio = null, this.ringbackPlaying = !1, this.incomingAudio = null, this.incomingPlaying = !1, this.hangupInitiatedByLocal = !1, this.ringbackToneUrl = this._resolveToneUrl(t.ringbackTone || "ringback1.wav"), this.incomingToneUrl = this._resolveToneUrl(t.incomingTone || "ring1.wav"), this.pendingPlaybackTasks = /* @__PURE__ */ new Map(), this.audioUnlockHandler = null, this.lastSessionMeta = null, this.ensureReadyPromise = null, this.connectionWaiters = /* @__PURE__ */ new Set(), this.registrationWaiters = /* @__PURE__ */ new Set(), this.connectionConfirmTimeoutMs = Number.isFinite(Number(t.connectionConfirmTimeoutMs)) ? Number(t.connectionConfirmTimeoutMs) : ci, this.registrationConfirmTimeoutMs = Number.isFinite(Number(t.registrationConfirmTimeoutMs)) ? Number(t.registrationConfirmTimeoutMs) : di, this.peerConnectionDebug = {
10103
10103
  attached: !1,
10104
10104
  events: [],
10105
10105
  iceCandidates: [],
@@ -10323,7 +10323,7 @@ class ui {
10323
10323
  registererOptions: {
10324
10324
  expires: 1800
10325
10325
  }
10326
- }, w = new ci(d, u);
10326
+ }, w = new oi(d, u);
10327
10327
  return w.delegate = {
10328
10328
  onServerConnect: () => {
10329
10329
  this.connected = !0, this._resolveConnectionWaiters(), this.onStateChange && this.onStateChange("connected", this.getConnectionSnapshot());
@@ -10599,7 +10599,7 @@ class ui {
10599
10599
  async _preflightAudioAccess(e = "call") {
10600
10600
  let t = null;
10601
10601
  try {
10602
- t = await hi(e);
10602
+ t = await li(e);
10603
10603
  } catch (i) {
10604
10604
  const s = await Ve(i, e);
10605
10605
  throw this.onError && this.onError(s), this.lastFailureMeta = {
@@ -11052,15 +11052,15 @@ class ui {
11052
11052
  this.audioContext = null;
11053
11053
  }
11054
11054
  }
11055
- const gi = /^[a-z][a-z0-9+.-]*:\/\//i;
11056
- function fi(a, e = "") {
11055
+ const ui = /^[a-z][a-z0-9+.-]*:\/\//i;
11056
+ function gi(a, e = "") {
11057
11057
  const t = String(a || e || "").trim();
11058
11058
  if (!t)
11059
11059
  throw new Error("缺少统一服务基址");
11060
11060
  return t;
11061
11061
  }
11062
11062
  function mt(a, e = "https://") {
11063
- return gi.test(a) ? a : `${e}${a.replace(/^\/+/, "")}`;
11063
+ return ui.test(a) ? a : `${e}${a.replace(/^\/+/, "")}`;
11064
11064
  }
11065
11065
  function wt(a = "/") {
11066
11066
  return a.endsWith("/") ? a : `${a}/`;
@@ -11070,10 +11070,10 @@ function yt(a = "/", e = "") {
11070
11070
  return i ? `${t}${i}` : t;
11071
11071
  }
11072
11072
  function De(a, e = "") {
11073
- const t = mt(fi(a, e)), i = new URL(t);
11073
+ const t = mt(gi(a, e)), i = new URL(t);
11074
11074
  return i.search = "", i.hash = "", i.pathname = wt(i.pathname || "/"), i;
11075
11075
  }
11076
- function pi(a, e = "") {
11076
+ function fi(a, e = "") {
11077
11077
  return De(a, e).pathname !== "/";
11078
11078
  }
11079
11079
  function X(a, e, t = "") {
@@ -11097,9 +11097,9 @@ function it({
11097
11097
  fallbackPath: i = "ws"
11098
11098
  }) {
11099
11099
  const s = String(e || "").trim();
11100
- return s ? Ue(s, tt(t, i)) : pi(a) ? Ue(a, tt(t, i)) : String(t || "").trim() ? String(t).trim() : Ue(a, i);
11100
+ return s ? Ue(s, tt(t, i)) : fi(a) ? Ue(a, tt(t, i)) : String(t || "").trim() ? String(t).trim() : Ue(a, i);
11101
11101
  }
11102
- const mi = `
11102
+ const pi = `
11103
11103
  :host { all: initial; }
11104
11104
  .widget { font-family: "Noto Sans SC", "PingFang SC", sans-serif; color: #16302b; }
11105
11105
  .panel { width: min(360px, 92vw); border-radius: 24px; overflow: hidden; background: linear-gradient(180deg, #fffdf6, #f4efe4); box-shadow: 0 22px 54px rgba(17, 30, 28, 0.22); border: 1px solid rgba(28, 78, 67, 0.12); }
@@ -11147,27 +11147,27 @@ const mi = `
11147
11147
  rejected: "本次来电已拒接,widget 仍保持待机。",
11148
11148
  missed: "本次来电未接听,widget 仍保持待机。",
11149
11149
  failed: "本次呼叫失败,请先看下方日志。"
11150
- }, wi = "手机网页首次接入时,请允许麦克风权限;若切到后台后再回来,先确认页面仍保持前台活跃。", bt = 15e3, yi = 15e3, st = 2, bi = 2, me = bt * bi, vi = 1200, Si = 3e4, Ti = 4e3, Te = {
11150
+ }, mi = "手机网页首次接入时,请允许麦克风权限;若切到后台后再回来,先确认页面仍保持前台活跃。", wi = 5e3, yi = 15e3, st = 2, me = 3e4, bi = 1200, vi = 3e4, Si = 4e3, Te = {
11151
11151
  ready: "线路可用",
11152
11152
  preparing: "正在准备",
11153
11153
  working: "正在呼叫",
11154
11154
  recovering: "正在恢复",
11155
11155
  offline: "当前离线"
11156
11156
  };
11157
- function Ci(a, e) {
11157
+ function Ti(a, e) {
11158
11158
  return e ? `${a}
11159
11159
  ${JSON.stringify(e, null, 2)}` : a;
11160
11160
  }
11161
- function Ei(a) {
11161
+ function Ci(a) {
11162
11162
  return a === "outbound" ? "outbound" : "terminal";
11163
11163
  }
11164
- function Ri(a) {
11164
+ function Ei(a) {
11165
11165
  return typeof a == "function";
11166
11166
  }
11167
11167
  function xi() {
11168
11168
  return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("embeddedCallWidgetE2E") === "1";
11169
11169
  }
11170
- function Ii() {
11170
+ function Ri() {
11171
11171
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `widget-${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
11172
11172
  }
11173
11173
  function Le(a) {
@@ -11181,20 +11181,20 @@ function te(a = {}, e = null) {
11181
11181
  const s = String(a?.businessKey ?? "").trim();
11182
11182
  return s || String(e?.default_business_key ?? "").trim();
11183
11183
  }
11184
- function _i(a) {
11184
+ function Ii(a) {
11185
11185
  const e = new Error(a);
11186
11186
  return e.name = "EmbeddedCallWidgetLifecycleCancelledError", e.code = "widget_runtime_run_stale", e;
11187
11187
  }
11188
11188
  function rt(a) {
11189
11189
  return a?.code === "sip_client_replaced" || a?.code === "widget_runtime_run_stale";
11190
11190
  }
11191
- class Ai {
11191
+ class _i {
11192
11192
  constructor({ mount: e, shadowRoot: t, options: i }) {
11193
- this.mountNode = e, this.shadowRoot = t, this.options = i, this.mode = Ei(i.mode), this.legacyOutboundOnly = this.mode === "outbound", this.apiBaseUrl = De(i.apiBaseUrl || window.location.origin).href, this.client = null, this.issuedSession = null, this.bootstrap = null, this.turnIceServers = [], this.state = "idle", this.finalizing = !1, this.isMobileViewport = !1, this.pendingIncomingCall = null, this.visibilityHandler = null, this.sessionTouchTimer = null, this.sessionRecoveryInFlight = null, this.transportDisconnectTimer = null, this.transportDisconnectContext = null, this.e2eBridgeEnabled = xi(), this.terminalFailureOverride = "", this.presenceId = Ii(), this.presenceTouchTimer = null, this.presenceFailureCount = 0, this.availabilityState = "preparing", this.availabilityDetail = "正在连接后台并准备网页电话待机。", this.connectivityRecoveryInFlight = null, this.lifecycleRunId = 0, this.pendingLifecycleMode = null, this.expectedClientTeardown = null, this.autoStandbyRecoveryTimer = null, this.recentlyReleasedSessions = /* @__PURE__ */ new Map(), this.networkOnline = typeof navigator > "u" ? !0 : navigator.onLine !== !1, this.pageVisible = typeof document > "u" ? !0 : document.visibilityState === "visible", this.onlineHandler = null, this.offlineHandler = null, this.refs = {};
11193
+ this.mountNode = e, this.shadowRoot = t, this.options = i, this.mode = Ci(i.mode), this.legacyOutboundOnly = this.mode === "outbound", this.apiBaseUrl = De(i.apiBaseUrl || window.location.origin).href, this.client = null, this.issuedSession = null, this.bootstrap = null, this.turnIceServers = [], this.state = "idle", this.finalizing = !1, this.isMobileViewport = !1, this.pendingIncomingCall = null, this.visibilityHandler = null, this.sessionTouchTimer = null, this.sessionRecoveryInFlight = null, this.transportDisconnectTimer = null, this.transportDisconnectContext = null, this.e2eBridgeEnabled = xi(), this.terminalFailureOverride = "", this.presenceId = Ri(), this.presenceTouchTimer = null, this.presenceFailureCount = 0, this.availabilityState = "preparing", this.availabilityDetail = "正在连接后台并准备网页电话待机。", this.connectivityRecoveryInFlight = null, this.lifecycleRunId = 0, this.pendingLifecycleMode = null, this.expectedClientTeardown = null, this.expectedTermination = null, this.autoStandbyRecoveryTimer = null, this.recentlyReleasedSessions = /* @__PURE__ */ new Map(), this.networkOnline = typeof navigator > "u" ? !0 : navigator.onLine !== !1, this.pageVisible = typeof document > "u" ? !0 : document.visibilityState === "visible", this.onlineHandler = null, this.offlineHandler = null, this.refs = {};
11194
11194
  }
11195
11195
  async mount() {
11196
11196
  this.isMobileViewport = typeof window < "u" && window.matchMedia("(max-width: 480px)").matches, this.shadowRoot.innerHTML = `
11197
- <style>${mi}</style>
11197
+ <style>${pi}</style>
11198
11198
  <section class="widget">
11199
11199
  <div class="panel">
11200
11200
  <div class="hero">
@@ -11255,11 +11255,11 @@ class Ai {
11255
11255
  }
11256
11256
  assertLifecycleRunCurrent(e) {
11257
11257
  if (e !== this.lifecycleRunId)
11258
- throw _i("网页电话已切换到新的连接流程,旧流程不再继续。");
11258
+ throw Ii("网页电话已切换到新的连接流程,旧流程不再继续。");
11259
11259
  }
11260
11260
  emitHostCallback(e, t) {
11261
11261
  const i = this.options?.[e];
11262
- if (Ri(i))
11262
+ if (Ei(i))
11263
11263
  try {
11264
11264
  i(t);
11265
11265
  } catch (s) {
@@ -11422,7 +11422,7 @@ class Ai {
11422
11422
  webrtc_url: e.transport,
11423
11423
  ice_servers: this.turnIceServers
11424
11424
  };
11425
- this.client?.matchesAccount(t) || (this.client && await this.client.destroy(), this.client = new ui(t, {
11425
+ this.client?.matchesAccount(t) || (this.client && await this.client.destroy(), this.client = new hi(t, {
11426
11426
  remoteAudioElement: this.refs.audio,
11427
11427
  onStateChange: (i, s) => {
11428
11428
  this.handleClientState(i, s);
@@ -11464,7 +11464,7 @@ class Ai {
11464
11464
  return;
11465
11465
  }
11466
11466
  if (e === "disconnected" || e === "unregistered") {
11467
- if (this.isExpectedClientTeardown())
11467
+ if (this.isExpectedClientTeardown() || this.isExpectedTermination() || !this.issuedSession?.session_id && this.pendingLifecycleMode === "standby")
11468
11468
  return;
11469
11469
  if (this.stopSessionTouch(), ["calling", "connected"].includes(this.state)) {
11470
11470
  this.setState("connected", "SIP 信令短暂中断,正在等待恢复。"), this.setAvailabilityState("recovering", "通话信令短暂中断,正在等待恢复。"), this.scheduleTransportDisconnectGrace(e);
@@ -11521,7 +11521,7 @@ class Ai {
11521
11521
  this.beginLifecycleRun(), this.finalizing = !0;
11522
11522
  try {
11523
11523
  if (this.pendingLifecycleMode = null, this.stopSessionTouch(), this.stopTransportDisconnectGrace(), await this.releaseIssuedSession("released", e), this.client && (await this.client.destroy(), this.client = null), !this.legacyOutboundOnly) {
11524
- this.setState("idle", "上一通通话已结束,正在恢复网页电话待机。"), this.setAvailabilityState("recovering", "上一通通话已结束,正在恢复网页电话待机。"), this.appendLog("通话已结束,网页电话正在恢复待机。", { reason: e }), await this.startStandby({ force: !0 });
11524
+ this.pendingLifecycleMode = "standby", this.setState("standbyRequesting", "上一通通话已结束,正在自动回到待机。"), this.setAvailabilityState("preparing", "页面仍在线,正在自动回到待机。"), this.appendLog("通话已结束,网页电话正在自动回到待机。", { reason: e }), await this.startStandby({ force: !0 });
11525
11525
  return;
11526
11526
  }
11527
11527
  const t = this.terminalFailureOverride || (this.state === "failed" ? this.refs.status?.textContent?.trim() || Q.failed : "");
@@ -11578,7 +11578,7 @@ class Ai {
11578
11578
  this.legacyOutboundOnly ? this.setState("ended") : this.setState("standby", "测试桥已模拟挂断,网页电话已恢复待机。"), this.pendingIncomingCall = null;
11579
11579
  return;
11580
11580
  }
11581
- this.client && await this.client.hangup();
11581
+ this.client && (this.expectTermination("hangup-call"), this.suppressExpectedClientTeardown("hangup-call"), await this.client.hangup());
11582
11582
  }
11583
11583
  async disconnectAndCleanup(e, t = {}) {
11584
11584
  const {
@@ -11761,12 +11761,25 @@ class Ai {
11761
11761
  setAvailabilityState(e, t = "") {
11762
11762
  this.availabilityState = e, this.availabilityDetail = t || this.availabilityDetail, this.refs.availability && (this.refs.availability.textContent = t ? `${Te[e] || Te.recovering} · ${t}` : Te[e] || Te.recovering, this.refs.availability.className = `availability availability--${e}`), this.render();
11763
11763
  }
11764
- suppressExpectedClientTeardown(e, t = Ti) {
11764
+ suppressExpectedClientTeardown(e, t = Si) {
11765
11765
  this.expectedClientTeardown = {
11766
11766
  reason: e,
11767
11767
  expiresAt: Date.now() + t
11768
11768
  };
11769
11769
  }
11770
+ expectTermination(e, t = 1e4) {
11771
+ this.expectedTermination = {
11772
+ reason: e,
11773
+ expiresAt: Date.now() + t
11774
+ };
11775
+ }
11776
+ clearExpectedTermination() {
11777
+ this.expectedTermination = null;
11778
+ }
11779
+ isExpectedTermination() {
11780
+ const e = this.expectedTermination;
11781
+ return e ? e.expiresAt <= Date.now() ? (this.expectedTermination = null, !1) : !0 : !1;
11782
+ }
11770
11783
  isExpectedClientTeardown() {
11771
11784
  const e = this.expectedClientTeardown;
11772
11785
  return e ? e.expiresAt <= Date.now() ? (this.expectedClientTeardown = null, !1) : !0 : !1;
@@ -11774,7 +11787,7 @@ class Ai {
11774
11787
  clearAutoStandbyRecovery() {
11775
11788
  this.autoStandbyRecoveryTimer && (window.clearTimeout(this.autoStandbyRecoveryTimer), this.autoStandbyRecoveryTimer = null);
11776
11789
  }
11777
- scheduleAutoStandbyRecovery(e, t = vi) {
11790
+ scheduleAutoStandbyRecovery(e, t = bi) {
11778
11791
  this.legacyOutboundOnly || this.networkOnline === !1 || this.autoStandbyRecoveryTimer || this.client || this.issuedSession?.session_id || this.finalizing || this.pendingLifecycleMode === "outbound" || this.sessionRecoveryInFlight || this.connectivityRecoveryInFlight || ["requesting", "standbyRequesting", "registering", "calling", "incoming", "connected"].includes(this.state) || (this.autoStandbyRecoveryTimer = window.setTimeout(() => {
11779
11792
  this.autoStandbyRecoveryTimer = null, !(this.legacyOutboundOnly || this.networkOnline === !1) && (this.client || this.issuedSession?.session_id || this.finalizing || this.pendingLifecycleMode === "outbound" || (this.appendLog("检测到页面当前不在通话中,开始自动恢复待机。", { reason: e }), this.startStandby({ force: !0 })));
11780
11793
  }, t));
@@ -11787,7 +11800,7 @@ class Ai {
11787
11800
  markRecentlyReleasedSession(e, t) {
11788
11801
  e && (this.pruneRecentlyReleasedSessions(), this.recentlyReleasedSessions.set(e, {
11789
11802
  reason: t,
11790
- expiresAt: Date.now() + Si
11803
+ expiresAt: Date.now() + vi
11791
11804
  }));
11792
11805
  }
11793
11806
  wasSessionRecentlyReleased(e) {
@@ -12015,14 +12028,14 @@ class Ai {
12015
12028
  }
12016
12029
  this.touchIssuedSession(e), this.sessionTouchTimer || (this.sessionTouchTimer = window.setInterval(() => {
12017
12030
  this.touchIssuedSession(this.state);
12018
- }, bt));
12031
+ }, wi));
12019
12032
  }
12020
12033
  setState(e, t = "") {
12021
- this.state = e, this.refs.status.textContent = t || Q[e] || Q.idle, this.emitHostCallback("onStateChange", this.getSnapshot()), this.syncAvailabilityState(), this.render();
12034
+ this.state = e, this.refs.status.textContent = t || Q[e] || Q.idle, this.syncAvailabilityState(), this.render(), this.emitHostCallback("onStateChange", this.getSnapshot());
12022
12035
  }
12023
12036
  appendLog(e, t) {
12024
12037
  const i = document.createElement("div");
12025
- for (i.className = "log", i.textContent = Ci(e, t), this.refs.logs.prepend(i); this.refs.logs.children.length > 8; )
12038
+ for (i.className = "log", i.textContent = Ti(e, t), this.refs.logs.prepend(i); this.refs.logs.children.length > 8; )
12026
12039
  this.refs.logs.lastElementChild?.remove();
12027
12040
  }
12028
12041
  render() {
@@ -12030,20 +12043,20 @@ class Ai {
12030
12043
  this.refs.status && (this.refs.status.className = [
12031
12044
  "status",
12032
12045
  this.availabilityState === "offline" ? "status--offline" : this.availabilityState === "recovering" ? "status--recovering" : ""
12033
- ].filter(Boolean).join(" ")), this.legacyOutboundOnly ? (this.refs.primary.disabled = e, this.refs.primary.textContent = t ? "通话进行中" : "连接并呼叫", this.refs.secondary.disabled = !t && !i, this.refs.secondary.textContent = t ? "挂断并清理" : "断开并清理") : (this.refs.primary.disabled = e || s || this.state === "connected", this.state === "incoming" ? this.refs.primary.textContent = "接听来电" : e || s ? this.availabilityState === "working" ? this.refs.primary.textContent = "正在建立呼叫" : this.availabilityState === "preparing" ? this.refs.primary.textContent = "正在准备网页电话" : this.refs.primary.textContent = this.state === "calling" ? "通话进行中" : "正在恢复网页电话" : this.availabilityState === "offline" ? this.refs.primary.textContent = "网络恢复后再试" : !i || ["idle", "failed", "ended"].includes(this.state) ? this.refs.primary.textContent = "恢复网页电话待机" : this.refs.primary.textContent = "呼叫管理员", this.refs.secondary.disabled = !i, this.refs.secondary.textContent = this.state === "incoming" ? "拒接来电" : this.state === "connected" ? "挂断并恢复待机" : "断开电话");
12046
+ ].filter(Boolean).join(" ")), this.legacyOutboundOnly ? (this.refs.primary.disabled = e, this.refs.primary.textContent = t ? "通话进行中" : "连接并呼叫", this.refs.secondary.disabled = !t && !i, this.refs.secondary.textContent = t ? "挂断并清理" : "断开并清理") : (this.refs.primary.disabled = e || s || this.state === "connected", this.state === "incoming" ? this.refs.primary.textContent = "接听来电" : this.state === "connected" ? this.refs.primary.textContent = "通话进行中" : e || s ? this.availabilityState === "working" ? this.refs.primary.textContent = "正在建立呼叫" : this.availabilityState === "preparing" ? this.refs.primary.textContent = "正在准备网页电话" : this.refs.primary.textContent = this.state === "calling" ? "通话进行中" : "正在恢复网页电话" : this.availabilityState === "offline" ? this.refs.primary.textContent = "网络恢复后再试" : !i || ["idle", "failed", "ended"].includes(this.state) ? this.refs.primary.textContent = "恢复网页电话待机" : this.refs.primary.textContent = "呼叫管理员", this.refs.secondary.disabled = !i, this.refs.secondary.textContent = this.state === "incoming" ? "拒接来电" : this.state === "connected" ? "挂断并恢复待机" : "断开电话");
12034
12047
  const r = this.options.siteKey || this.bootstrap?.default_site_key || "等待服务端返回", n = this.issuedSession?.resolved_business_key || te(this.options, this.bootstrap) || "等待服务端返回";
12035
- this.legacyOutboundOnly ? this.refs.meta.textContent = `入站规则:${n};站点键:${r}` : this.refs.meta.textContent = `站点键:${r};网页电话会先进入可被叫待机;访客主动呼叫默认规则:${n}`, this.availabilityState === "offline" ? this.refs.hint.textContent = this.networkOnline === !1 ? "当前浏览器网络已断开。系统会在网络恢复后自动尝试重连网页电话。" : "当前无法连接通话服务。系统会继续自动恢复,暂时不要重复点击。" : this.availabilityState === "preparing" ? this.refs.hint.textContent = "当前正在准备待机能力。只要页面在线,系统会自动进入可呼入、可呼出的网页电话状态。" : this.availabilityState === "working" ? this.refs.hint.textContent = "当前正在切换到外呼链路,请等待振铃、接通或自动回到待机。" : this.availabilityState === "recovering" ? this.refs.hint.textContent = "当前页面仍在线,系统正在自动恢复可被叫待机,不需要刷新页面或手动切换模式。" : this.refs.hint.textContent = this.isMobileViewport ? wi : "桌面网页可直接使用;若宿主站点启用了来源白名单或接入令牌,请按站点配置提供对应参数。";
12048
+ this.legacyOutboundOnly ? this.refs.meta.textContent = `入站规则:${n};站点键:${r}` : this.refs.meta.textContent = `站点键:${r};网页电话会先进入可被叫待机;访客主动呼叫默认规则:${n}`, this.availabilityState === "offline" ? this.refs.hint.textContent = this.networkOnline === !1 ? "当前浏览器网络已断开。系统会在网络恢复后自动尝试重连网页电话。" : "当前无法连接通话服务。系统会继续自动恢复,暂时不要重复点击。" : this.availabilityState === "preparing" ? this.refs.hint.textContent = "当前正在准备待机能力。只要页面在线,系统会自动进入可呼入、可呼出的网页电话状态。" : this.availabilityState === "working" ? this.refs.hint.textContent = "当前正在切换到外呼链路,请等待振铃、接通或自动回到待机。" : this.availabilityState === "recovering" ? this.refs.hint.textContent = "当前页面仍在线,系统正在自动恢复可被叫待机,不需要刷新页面或手动切换模式。" : this.refs.hint.textContent = this.isMobileViewport ? mi : "桌面网页可直接使用;若宿主站点启用了来源白名单或接入令牌,请按站点配置提供对应参数。";
12036
12049
  }
12037
12050
  async destroy() {
12038
12051
  await this.disconnectAndCleanup("destroy-widget"), typeof document < "u" && this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.stopSessionTouch(), this.stopPresenceTouch(), this.stopTransportDisconnectGrace(), this.pendingIncomingCall = null, typeof window < "u" && (this.onlineHandler && (window.removeEventListener("online", this.onlineHandler), this.onlineHandler = null), this.offlineHandler && (window.removeEventListener("offline", this.offlineHandler), this.offlineHandler = null)), this.e2eBridgeEnabled && typeof window < "u" && window.__embeddedCallWidgetE2E__ && delete window.__embeddedCallWidgetE2E__, this.shadowRoot.innerHTML = "";
12039
12052
  }
12040
12053
  }
12041
- function $i(a) {
12042
- return new Ai(a);
12054
+ function Ai(a) {
12055
+ return new _i(a);
12043
12056
  }
12044
12057
  typeof window < "u" && (window.__EmbeddedCallWidgetRuntime__ = {
12045
- createEmbeddedCallWidgetRuntime: $i
12058
+ createEmbeddedCallWidgetRuntime: Ai
12046
12059
  });
12047
12060
  export {
12048
- $i as createEmbeddedCallWidgetRuntime
12061
+ Ai as createEmbeddedCallWidgetRuntime
12049
12062
  };