@shenyin/embedded-call-widget 3.0.2 → 3.0.3

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,10 +1,10 @@
1
- const kt = "0.21.1";
1
+ const Mt = "0.21.1";
2
2
  class fe extends Error {
3
3
  constructor(e) {
4
4
  super(e), Object.setPrototypeOf(this, new.target.prototype);
5
5
  }
6
6
  }
7
- class Ye extends fe {
7
+ class Je extends fe {
8
8
  constructor(e) {
9
9
  super(e || "Unsupported content type.");
10
10
  }
@@ -15,22 +15,22 @@ class Ee extends fe {
15
15
  super(e || "Request pending.");
16
16
  }
17
17
  }
18
- class Ht extends fe {
18
+ class qt extends fe {
19
19
  constructor(e) {
20
20
  super(e || "Unspecified session description handler error.");
21
21
  }
22
22
  }
23
- class Ue extends fe {
23
+ class Le extends fe {
24
24
  constructor() {
25
25
  super("The session has terminated.");
26
26
  }
27
27
  }
28
- class ve extends fe {
28
+ class Se extends fe {
29
29
  constructor(e) {
30
30
  super(e || "An error occurred during state transition.");
31
31
  }
32
32
  }
33
- class Mt {
33
+ class Ot {
34
34
  /** @internal */
35
35
  constructor(e) {
36
36
  this.incomingAckRequest = e;
@@ -40,7 +40,7 @@ class Mt {
40
40
  return this.incomingAckRequest.message;
41
41
  }
42
42
  }
43
- class qt {
43
+ class Ft {
44
44
  /** @internal */
45
45
  constructor(e) {
46
46
  this.incomingByeRequest = e;
@@ -58,7 +58,7 @@ class qt {
58
58
  return this.incomingByeRequest.reject(e), Promise.resolve();
59
59
  }
60
60
  }
61
- class Ot {
61
+ class Nt {
62
62
  /** @internal */
63
63
  constructor(e) {
64
64
  this.incomingCancelRequest = e;
@@ -130,7 +130,7 @@ class xe {
130
130
  return this.addListener(e, { once: !0 });
131
131
  }
132
132
  }
133
- class Ft {
133
+ class Ut {
134
134
  /** @internal */
135
135
  constructor(e) {
136
136
  this.incomingInfoRequest = e;
@@ -148,7 +148,7 @@ class Ft {
148
148
  return this.incomingInfoRequest.reject(e), Promise.resolve();
149
149
  }
150
150
  }
151
- class mt {
151
+ class bt {
152
152
  constructor(e) {
153
153
  this.parameters = {};
154
154
  for (const t in e)
@@ -174,7 +174,7 @@ class mt {
174
174
  this.parameters = {};
175
175
  }
176
176
  }
177
- class U extends mt {
177
+ class U extends bt {
178
178
  /**
179
179
  * Constructor
180
180
  * @param uri -
@@ -204,7 +204,7 @@ class U extends mt {
204
204
  return e;
205
205
  }
206
206
  }
207
- class ee extends mt {
207
+ class ee extends bt {
208
208
  /**
209
209
  * Constructor
210
210
  * @param scheme -
@@ -333,7 +333,7 @@ class ee extends mt {
333
333
  return t[r] && (r = t[r]), r;
334
334
  }
335
335
  }
336
- function nt(a, e) {
336
+ function at(a, e) {
337
337
  if (a.scheme !== e.scheme || a.user !== e.user || a.host !== e.host || a.port !== e.port)
338
338
  return !1;
339
339
  function t(r, n) {
@@ -352,12 +352,12 @@ function nt(a, e) {
352
352
  }
353
353
  return !0;
354
354
  }
355
- function Le(a, e, t) {
355
+ function Be(a, e, t) {
356
356
  return t = t || " ", a.length > e ? a : (e -= a.length, t += t.repeat(e), a + t.slice(0, e));
357
357
  }
358
- class pe extends Error {
358
+ class me extends Error {
359
359
  constructor(e, t, i, s) {
360
- super(), this.message = e, this.expected = t, this.found = i, this.location = s, this.name = "SyntaxError", typeof Object.setPrototypeOf == "function" ? Object.setPrototypeOf(this, pe.prototype) : this.__proto__ = pe.prototype, typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, pe);
360
+ super(), this.message = e, this.expected = t, this.found = i, this.location = s, this.name = "SyntaxError", typeof Object.setPrototypeOf == "function" ? Object.setPrototypeOf(this, me.prototype) : this.__proto__ = me.prototype, typeof Error.captureStackTrace == "function" && Error.captureStackTrace(this, me);
361
361
  }
362
362
  static buildMessage(e, t) {
363
363
  function i(u) {
@@ -417,12 +417,12 @@ class pe extends Error {
417
417
  }
418
418
  let r = this.location.start, n = this.location.source + ":" + r.line + ":" + r.column;
419
419
  if (i) {
420
- let o = this.location.end, d = Le("", r.line.toString().length, " "), u = i[r.line - 1], h = r.line === o.line ? o.column : u.length + 1;
420
+ let o = this.location.end, d = Be("", r.line.toString().length, " "), u = i[r.line - 1], h = r.line === o.line ? o.column : u.length + 1;
421
421
  t += `
422
422
  --> ` + n + `
423
423
  ` + d + ` |
424
424
  ` + r.line + " | " + u + `
425
- ` + d + " | " + Le("", r.column - 1, " ") + Le("", h - r.column, "^");
425
+ ` + d + " | " + Be("", r.column - 1, " ") + Be("", h - r.column, "^");
426
426
  } else
427
427
  t += `
428
428
  at ` + n;
@@ -430,7 +430,7 @@ class pe extends Error {
430
430
  return t;
431
431
  }
432
432
  }
433
- function Nt(a, e) {
433
+ function Lt(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;
@@ -743,7 +743,7 @@ function Nt(a, e) {
743
743
  }
744
744
  e.data.multi_header.push({
745
745
  position: d,
746
- offset: z().start.offset,
746
+ offset: Y().start.offset,
747
747
  parsed: l
748
748
  });
749
749
  },
@@ -909,7 +909,7 @@ function Nt(a, e) {
909
909
  }
910
910
  e.data.multi_header.push({
911
911
  position: d,
912
- offset: z().start.offset,
912
+ offset: Y().start.offset,
913
913
  parsed: l
914
914
  });
915
915
  },
@@ -943,7 +943,7 @@ function Nt(a, e) {
943
943
  return b;
944
944
  },
945
945
  function(l, b) {
946
- return Dt(l, b);
946
+ return kt(l, b);
947
947
  },
948
948
  function(l) {
949
949
  e = e || { data: {} }, e.startRule === "Require" && (e.data = l || []);
@@ -1330,8 +1330,8 @@ function Nt(a, e) {
1330
1330
  function C() {
1331
1331
  return a.substring(u, d);
1332
1332
  }
1333
- function z() {
1334
- return Ne(u, d);
1333
+ function Y() {
1334
+ return Ue(u, d);
1335
1335
  }
1336
1336
  function p(l, b) {
1337
1337
  return { type: "literal", text: l, ignoreCase: b };
@@ -1339,10 +1339,10 @@ function Nt(a, e) {
1339
1339
  function A(l, b, g) {
1340
1340
  return { type: "class", parts: l, inverted: b, ignoreCase: g };
1341
1341
  }
1342
- function Fe() {
1342
+ function Ne() {
1343
1343
  return { type: "end" };
1344
1344
  }
1345
- function tt(l) {
1345
+ function it(l) {
1346
1346
  let b = h[l], g;
1347
1347
  if (b)
1348
1348
  return b;
@@ -1355,8 +1355,8 @@ function Nt(a, e) {
1355
1355
  a.charCodeAt(g) === 10 ? (b.line++, b.column = 1) : b.column++, g++;
1356
1356
  return h[l] = b, b;
1357
1357
  }
1358
- function Ne(l, b) {
1359
- const g = tt(l), V = tt(b);
1358
+ function Ue(l, b) {
1359
+ const g = it(l), V = it(b);
1360
1360
  return {
1361
1361
  source: i,
1362
1362
  start: {
@@ -1371,22 +1371,22 @@ function Nt(a, e) {
1371
1371
  }
1372
1372
  };
1373
1373
  }
1374
- function it(l) {
1374
+ function st(l) {
1375
1375
  d < m || (d > m && (m = d, S = []), S.push(l));
1376
1376
  }
1377
- function $t(l, b, g) {
1378
- return new pe(pe.buildMessage(l, b), l, b, g);
1377
+ function Pt(l, b, g) {
1378
+ return new me(me.buildMessage(l, b), l, b, g);
1379
1379
  }
1380
1380
  function c(l) {
1381
1381
  return l.split("").map((b) => b.charCodeAt(0) - 32);
1382
1382
  }
1383
- function st(l) {
1383
+ function rt(l) {
1384
1384
  const b = o[l];
1385
1385
  let g = 0;
1386
1386
  const V = [];
1387
1387
  let D = b.length;
1388
- const Y = [], E = [];
1389
- let rt;
1388
+ const J = [], E = [];
1389
+ let nt;
1390
1390
  for (; ; ) {
1391
1391
  for (; g < D; )
1392
1392
  switch (b[g]) {
@@ -1430,28 +1430,28 @@ function Nt(a, e) {
1430
1430
  E.push(a.substring(E.pop(), d)), g++;
1431
1431
  break;
1432
1432
  case 13:
1433
- Y.push(D), V.push(g + 3 + b[g + 1] + b[g + 2]), E[E.length - 1] ? (D = g + 3 + b[g + 1], g += 3) : (D = g + 3 + b[g + 1] + b[g + 2], g += 3 + b[g + 1]);
1433
+ J.push(D), V.push(g + 3 + b[g + 1] + b[g + 2]), E[E.length - 1] ? (D = g + 3 + b[g + 1], g += 3) : (D = g + 3 + b[g + 1] + b[g + 2], g += 3 + b[g + 1]);
1434
1434
  break;
1435
1435
  case 14:
1436
- Y.push(D), V.push(g + 3 + b[g + 1] + b[g + 2]), E[E.length - 1] === t ? (D = g + 3 + b[g + 1], g += 3) : (D = g + 3 + b[g + 1] + b[g + 2], g += 3 + b[g + 1]);
1436
+ J.push(D), V.push(g + 3 + b[g + 1] + b[g + 2]), E[E.length - 1] === t ? (D = g + 3 + b[g + 1], g += 3) : (D = g + 3 + b[g + 1] + b[g + 2], g += 3 + b[g + 1]);
1437
1437
  break;
1438
1438
  case 15:
1439
- Y.push(D), V.push(g + 3 + b[g + 1] + b[g + 2]), E[E.length - 1] !== t ? (D = g + 3 + b[g + 1], g += 3) : (D = g + 3 + b[g + 1] + b[g + 2], g += 3 + b[g + 1]);
1439
+ J.push(D), V.push(g + 3 + b[g + 1] + b[g + 2]), E[E.length - 1] !== t ? (D = g + 3 + b[g + 1], g += 3) : (D = g + 3 + b[g + 1] + b[g + 2], g += 3 + b[g + 1]);
1440
1440
  break;
1441
1441
  case 16:
1442
- E[E.length - 1] !== t ? (Y.push(D), V.push(g), D = g + 2 + b[g + 1], g += 2) : g += 2 + b[g + 1];
1442
+ E[E.length - 1] !== t ? (J.push(D), V.push(g), D = g + 2 + b[g + 1], g += 2) : g += 2 + b[g + 1];
1443
1443
  break;
1444
1444
  case 17:
1445
- Y.push(D), V.push(g + 3 + b[g + 1] + b[g + 2]), a.length > d ? (D = g + 3 + b[g + 1], g += 3) : (D = g + 3 + b[g + 1] + b[g + 2], g += 3 + b[g + 1]);
1445
+ J.push(D), V.push(g + 3 + b[g + 1] + b[g + 2]), a.length > d ? (D = g + 3 + b[g + 1], g += 3) : (D = g + 3 + b[g + 1] + b[g + 2], g += 3 + b[g + 1]);
1446
1446
  break;
1447
1447
  case 18:
1448
- Y.push(D), V.push(g + 4 + b[g + 2] + b[g + 3]), a.substr(d, n[b[g + 1]].length) === n[b[g + 1]] ? (D = g + 4 + b[g + 2], g += 4) : (D = g + 4 + b[g + 2] + b[g + 3], g += 4 + b[g + 2]);
1448
+ J.push(D), V.push(g + 4 + b[g + 2] + b[g + 3]), a.substr(d, n[b[g + 1]].length) === n[b[g + 1]] ? (D = g + 4 + b[g + 2], g += 4) : (D = g + 4 + b[g + 2] + b[g + 3], g += 4 + b[g + 2]);
1449
1449
  break;
1450
1450
  case 19:
1451
- Y.push(D), V.push(g + 4 + b[g + 2] + b[g + 3]), a.substr(d, n[b[g + 1]].length).toLowerCase() === n[b[g + 1]] ? (D = g + 4 + b[g + 2], g += 4) : (D = g + 4 + b[g + 2] + b[g + 3], g += 4 + b[g + 2]);
1451
+ J.push(D), V.push(g + 4 + b[g + 2] + b[g + 3]), a.substr(d, n[b[g + 1]].length).toLowerCase() === n[b[g + 1]] ? (D = g + 4 + b[g + 2], g += 4) : (D = g + 4 + b[g + 2] + b[g + 3], g += 4 + b[g + 2]);
1452
1452
  break;
1453
1453
  case 20:
1454
- Y.push(D), V.push(g + 4 + b[g + 2] + b[g + 3]), n[b[g + 1]].test(a.charAt(d)) ? (D = g + 4 + b[g + 2], g += 4) : (D = g + 4 + b[g + 2] + b[g + 3], g += 4 + b[g + 2]);
1454
+ J.push(D), V.push(g + 4 + b[g + 2] + b[g + 3]), n[b[g + 1]].test(a.charAt(d)) ? (D = g + 4 + b[g + 2], g += 4) : (D = g + 4 + b[g + 2] + b[g + 3], g += 4 + b[g + 2]);
1455
1455
  break;
1456
1456
  case 21:
1457
1457
  E.push(a.substr(d, b[g + 1])), d += b[g + 1], g += 2;
@@ -1460,7 +1460,7 @@ function Nt(a, e) {
1460
1460
  E.push(n[b[g + 1]]), d += n[b[g + 1]].length, g += 2;
1461
1461
  break;
1462
1462
  case 23:
1463
- E.push(t), x === 0 && it(n[b[g + 1]]), g += 2;
1463
+ E.push(t), x === 0 && st(n[b[g + 1]]), g += 2;
1464
1464
  break;
1465
1465
  case 24:
1466
1466
  u = E[E.length - 1 - b[g + 1]], g += 2;
@@ -1469,12 +1469,12 @@ function Nt(a, e) {
1469
1469
  u = d, g++;
1470
1470
  break;
1471
1471
  case 26:
1472
- rt = b.slice(g + 4, g + 4 + b[g + 3]).map(function(Pt) {
1473
- return E[E.length - 1 - Pt];
1474
- }), E.splice(E.length - b[g + 2], b[g + 2], n[b[g + 1]].apply(null, rt)), g += 4 + b[g + 3];
1472
+ nt = b.slice(g + 4, g + 4 + b[g + 3]).map(function(Ht) {
1473
+ return E[E.length - 1 - Ht];
1474
+ }), E.splice(E.length - b[g + 2], b[g + 2], n[b[g + 1]].apply(null, nt)), g += 4 + b[g + 3];
1475
1475
  break;
1476
1476
  case 27:
1477
- E.push(st(b[g + 1])), g += 2;
1477
+ E.push(rt(b[g + 1])), g += 2;
1478
1478
  break;
1479
1479
  case 28:
1480
1480
  x++, g++;
@@ -1485,28 +1485,28 @@ function Nt(a, e) {
1485
1485
  default:
1486
1486
  throw new Error("Invalid opcode: " + b[g] + ".");
1487
1487
  }
1488
- if (Y.length > 0)
1489
- D = Y.pop(), g = V.pop();
1488
+ if (J.length > 0)
1489
+ D = J.pop(), g = V.pop();
1490
1490
  else
1491
1491
  break;
1492
1492
  }
1493
1493
  return E[0];
1494
1494
  }
1495
1495
  e.data = {};
1496
- function Dt(l, b) {
1496
+ function kt(l, b) {
1497
1497
  return [l].concat(b);
1498
1498
  }
1499
- if (_ = st(r), _ !== t && d === a.length)
1499
+ if (_ = rt(r), _ !== t && d === a.length)
1500
1500
  return _;
1501
- throw _ !== t && d < a.length && it(Fe()), $t(S, m < a.length ? a.charAt(m) : null, m < a.length ? Ne(m, m + 1) : Ne(m, m));
1501
+ throw _ !== t && d < a.length && st(Ne()), Pt(S, m < a.length ? a.charAt(m) : null, m < a.length ? Ue(m, m + 1) : Ue(m, m));
1502
1502
  }
1503
- const Ut = Nt;
1503
+ const Bt = Lt;
1504
1504
  var k;
1505
1505
  (function(a) {
1506
1506
  function e(s, r) {
1507
1507
  const n = { startRule: r };
1508
1508
  try {
1509
- Ut(s, n);
1509
+ Bt(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 Lt = {
1527
+ const jt = {
1528
1528
  100: "Trying",
1529
1529
  180: "Ringing",
1530
1530
  181: "Call Is Being Forwarded",
@@ -1605,13 +1605,13 @@ function he(a, e = 32) {
1605
1605
  }
1606
1606
  return t;
1607
1607
  }
1608
- function Me(a) {
1609
- return Lt[a] || "";
1608
+ function qe(a) {
1609
+ return jt[a] || "";
1610
1610
  }
1611
- function qe() {
1611
+ function Oe() {
1612
1612
  return he(10);
1613
1613
  }
1614
- function Z(a) {
1614
+ function X(a) {
1615
1615
  const e = {
1616
1616
  "Call-Id": "Call-ID",
1617
1617
  Cseq: "CSeq",
@@ -1628,7 +1628,7 @@ function Z(a) {
1628
1628
  function _e(a) {
1629
1629
  return encodeURIComponent(a).replace(/%[A-F\d]{2}/g, "U").length;
1630
1630
  }
1631
- class wt {
1631
+ class yt {
1632
1632
  constructor() {
1633
1633
  this.headers = {};
1634
1634
  }
@@ -1640,7 +1640,7 @@ class wt {
1640
1640
  */
1641
1641
  addHeader(e, t) {
1642
1642
  const i = { raw: t };
1643
- e = Z(e), this.headers[e] ? this.headers[e].push(i) : this.headers[e] = [i];
1643
+ e = X(e), this.headers[e] ? this.headers[e].push(i) : this.headers[e] = [i];
1644
1644
  }
1645
1645
  /**
1646
1646
  * Get the value of the given header name at the given position.
@@ -1648,7 +1648,7 @@ class wt {
1648
1648
  * @returns Returns the specified header, undefined if header doesn't exist.
1649
1649
  */
1650
1650
  getHeader(e) {
1651
- const t = this.headers[Z(e)];
1651
+ const t = this.headers[X(e)];
1652
1652
  if (t) {
1653
1653
  if (t[0])
1654
1654
  return t[0].raw;
@@ -1661,7 +1661,7 @@ class wt {
1661
1661
  * @returns Array - with all the headers of the specified name.
1662
1662
  */
1663
1663
  getHeaders(e) {
1664
- const t = this.headers[Z(e)], i = [];
1664
+ const t = this.headers[X(e)], i = [];
1665
1665
  if (!t)
1666
1666
  return [];
1667
1667
  for (const s of t)
@@ -1674,7 +1674,7 @@ class wt {
1674
1674
  * @returns true if header with given name exists, false otherwise
1675
1675
  */
1676
1676
  hasHeader(e) {
1677
- return !!this.headers[Z(e)];
1677
+ return !!this.headers[X(e)];
1678
1678
  }
1679
1679
  /**
1680
1680
  * Parse the given header on the given index.
@@ -1685,7 +1685,7 @@ class wt {
1685
1685
  */
1686
1686
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
1687
1687
  parseHeader(e, t = 0) {
1688
- if (e = Z(e), this.headers[e]) {
1688
+ if (e = X(e), this.headers[e]) {
1689
1689
  if (t >= this.headers[e].length)
1690
1690
  return;
1691
1691
  } else return;
@@ -1719,18 +1719,18 @@ class wt {
1719
1719
  * @param value - header value
1720
1720
  */
1721
1721
  setHeader(e, t) {
1722
- this.headers[Z(e)] = [{ raw: t }];
1722
+ this.headers[X(e)] = [{ raw: t }];
1723
1723
  }
1724
1724
  toString() {
1725
1725
  return this.data;
1726
1726
  }
1727
1727
  }
1728
- class me extends wt {
1728
+ class we extends yt {
1729
1729
  constructor() {
1730
1730
  super();
1731
1731
  }
1732
1732
  }
1733
- class le extends wt {
1733
+ class le extends yt {
1734
1734
  constructor() {
1735
1735
  super();
1736
1736
  }
@@ -1740,7 +1740,7 @@ class ge {
1740
1740
  this.headers = {}, this.extraHeaders = [], this.options = ge.getDefaultOptions(), r && (this.options = Object.assign(Object.assign({}, this.options), r), this.options.optionTags && this.options.optionTags.length && (this.options.optionTags = this.options.optionTags.slice()), this.options.routeSet && this.options.routeSet.length && (this.options.routeSet = this.options.routeSet.slice())), n && n.length && (this.extraHeaders = n.slice()), o && (this.body = {
1741
1741
  body: o.content,
1742
1742
  contentType: o.contentType
1743
- }), this.method = e, this.ruri = t.clone(), this.fromURI = i.clone(), this.fromTag = this.options.fromTag ? this.options.fromTag : qe(), this.from = ge.makeNameAddrHeader(this.fromURI, this.options.fromDisplayName, this.fromTag), this.toURI = s.clone(), this.toTag = this.options.toTag, this.to = ge.makeNameAddrHeader(this.toURI, this.options.toDisplayName, this.toTag), this.callId = this.options.callId ? this.options.callId : this.options.callIdPrefix + he(15), this.cseq = this.options.cseq, this.setHeader("route", this.options.routeSet), this.setHeader("via", ""), this.setHeader("to", this.to.toString()), this.setHeader("from", this.from.toString()), this.setHeader("cseq", this.cseq + " " + this.method), this.setHeader("call-id", this.callId), this.setHeader("max-forwards", "70");
1743
+ }), this.method = e, this.ruri = t.clone(), this.fromURI = i.clone(), this.fromTag = this.options.fromTag ? this.options.fromTag : Oe(), this.from = ge.makeNameAddrHeader(this.fromURI, this.options.fromDisplayName, this.fromTag), this.toURI = s.clone(), this.toTag = this.options.toTag, this.to = ge.makeNameAddrHeader(this.toURI, this.options.toDisplayName, this.toTag), this.callId = this.options.callId ? this.options.callId : this.options.callIdPrefix + he(15), this.cseq = this.options.cseq, this.setHeader("route", this.options.routeSet), this.setHeader("via", ""), this.setHeader("to", this.to.toString()), this.setHeader("from", this.from.toString()), this.setHeader("cseq", this.cseq + " " + this.method), this.setHeader("call-id", this.callId), this.setHeader("max-forwards", "70");
1744
1744
  }
1745
1745
  /** Get a copy of the default options. */
1746
1746
  static getDefaultOptions() {
@@ -1770,7 +1770,7 @@ class ge {
1770
1770
  * @returns Returns the specified header, undefined if header doesn't exist.
1771
1771
  */
1772
1772
  getHeader(e) {
1773
- const t = this.headers[Z(e)];
1773
+ const t = this.headers[X(e)];
1774
1774
  if (t) {
1775
1775
  if (t[0])
1776
1776
  return t[0];
@@ -1787,7 +1787,7 @@ class ge {
1787
1787
  * @returns Array with all the headers of the specified name.
1788
1788
  */
1789
1789
  getHeaders(e) {
1790
- const t = [], i = this.headers[Z(e)];
1790
+ const t = [], i = this.headers[X(e)];
1791
1791
  if (i)
1792
1792
  for (const s of i)
1793
1793
  t.push(s);
@@ -1804,7 +1804,7 @@ class ge {
1804
1804
  * @returns true if header with given name exists, false otherwise
1805
1805
  */
1806
1806
  hasHeader(e) {
1807
- if (this.headers[Z(e)])
1807
+ if (this.headers[X(e)])
1808
1808
  return !0;
1809
1809
  {
1810
1810
  const t = new RegExp("^\\s*" + e + "\\s*:", "i");
@@ -1820,7 +1820,7 @@ class ge {
1820
1820
  * @param value - header value
1821
1821
  */
1822
1822
  setHeader(e, t) {
1823
- this.headers[Z(e)] = t instanceof Array ? t : [t];
1823
+ this.headers[X(e)] = t instanceof Array ? t : [t];
1824
1824
  }
1825
1825
  /**
1826
1826
  * The Via header field indicates the transport used for the transaction
@@ -1870,19 +1870,19 @@ class ge {
1870
1870
  `, e;
1871
1871
  }
1872
1872
  }
1873
- function bt(a) {
1873
+ function vt(a) {
1874
1874
  return a === "application/sdp" ? "session" : "render";
1875
1875
  }
1876
- function Pe(a) {
1876
+ function ke(a) {
1877
1877
  const e = typeof a == "string" ? a : a.body, t = typeof a == "string" ? "application/sdp" : a.contentType;
1878
- return { contentDisposition: bt(t), contentType: t, content: e };
1878
+ return { contentDisposition: vt(t), contentType: t, content: e };
1879
1879
  }
1880
- function yt(a) {
1880
+ function St(a) {
1881
1881
  return a && typeof a.content == "string" && typeof a.contentType == "string" && a.contentDisposition === void 0 ? !0 : typeof a.contentDisposition == "string";
1882
1882
  }
1883
1883
  function Ce(a) {
1884
1884
  let e, t, i;
1885
- if (a instanceof me && a.body) {
1885
+ if (a instanceof we && a.body) {
1886
1886
  const s = a.parseHeader("Content-Disposition");
1887
1887
  e = s ? s.type : void 0, t = a.parseHeader("Content-Type"), i = a.body;
1888
1888
  }
@@ -1900,8 +1900,8 @@ function Ce(a) {
1900
1900
  throw new Error("Header content type header does not equal body content type.");
1901
1901
  t = a.body.contentType, i = a.body.body;
1902
1902
  }
1903
- if (yt(a) && (e = a.contentDisposition, t = a.contentType, i = a.content), !!i) {
1904
- if (t && !e && (e = bt(t)), !e)
1903
+ if (St(a) && (e = a.contentDisposition, t = a.contentType, i = a.content), !!i) {
1904
+ if (t && !e && (e = vt(t)), !e)
1905
1905
  throw new Error("Content disposition undefined.");
1906
1906
  if (!t)
1907
1907
  throw new Error("Content type undefined.");
@@ -1920,16 +1920,16 @@ var y;
1920
1920
  (function(a) {
1921
1921
  a.Initial = "Initial", a.HaveLocalOffer = "HaveLocalOffer", a.HaveRemoteOffer = "HaveRemoteOffer", a.Stable = "Stable", a.Closed = "Closed";
1922
1922
  })(y = y || (y = {}));
1923
- const ie = 500, Bt = 4e3, at = 5e3, q = {
1923
+ const ie = 500, Vt = 4e3, ot = 5e3, q = {
1924
1924
  T1: ie,
1925
- T2: Bt,
1925
+ T2: Vt,
1926
1926
  TIMER_B: 64 * ie,
1927
1927
  TIMER_D: 0 * ie,
1928
1928
  TIMER_F: 64 * ie,
1929
1929
  TIMER_H: 64 * ie,
1930
- TIMER_I: 0 * at,
1930
+ TIMER_I: 0 * ot,
1931
1931
  TIMER_J: 0 * ie,
1932
- TIMER_K: 0 * at,
1932
+ TIMER_K: 0 * ot,
1933
1933
  TIMER_L: 64 * ie,
1934
1934
  TIMER_M: 64 * ie,
1935
1935
  TIMER_N: 64 * ie,
@@ -1959,7 +1959,7 @@ const ce = [
1959
1959
  v.REGISTER,
1960
1960
  v.SUBSCRIBE
1961
1961
  ];
1962
- class vt {
1962
+ class Tt {
1963
1963
  /** @internal */
1964
1964
  constructor(e) {
1965
1965
  this.incomingMessageRequest = e;
@@ -1977,7 +1977,7 @@ class vt {
1977
1977
  return this.incomingMessageRequest.reject(e), Promise.resolve();
1978
1978
  }
1979
1979
  }
1980
- class Je {
1980
+ class Ze {
1981
1981
  /** @internal */
1982
1982
  constructor(e) {
1983
1983
  this.incomingNotifyRequest = e;
@@ -1995,7 +1995,7 @@ class Je {
1995
1995
  return this.incomingNotifyRequest.reject(e), Promise.resolve();
1996
1996
  }
1997
1997
  }
1998
- class jt {
1998
+ class Gt {
1999
1999
  /** @internal */
2000
2000
  constructor(e, t) {
2001
2001
  this.incomingReferRequest = e, this.session = t;
@@ -2053,7 +2053,7 @@ var w;
2053
2053
  (function(a) {
2054
2054
  a.Initial = "Initial", a.Establishing = "Establishing", a.Established = "Established", a.Terminating = "Terminating", a.Terminated = "Terminated";
2055
2055
  })(w = w || (w = {}));
2056
- class we {
2056
+ class be {
2057
2057
  /**
2058
2058
  * Constructor.
2059
2059
  * @param userAgent - User agent. See {@link UserAgent} for details.
@@ -2349,7 +2349,7 @@ class we {
2349
2349
  refer(e, t = {}) {
2350
2350
  if (this.state !== w.Established)
2351
2351
  return this.logger.error("Session.refer() may only be called if established session."), Promise.reject(new Error(`Invalid session state ${this.state}`));
2352
- if (e instanceof we && !e.dialog)
2352
+ if (e instanceof be && !e.dialog)
2353
2353
  return this.logger.error("Session.refer() may only be called with session which is established. You are perhaps attempting to attended transfer to a target for which there is not dialog yet established. Perhaps you are attempting a 'semi-attended' tansfer? Regardless, this is not supported. The recommended approached is to check to see if the target Session is in the Established state before calling refer(); if the state is not Established you may proceed by falling back using a URI as the target (blind transfer)."), Promise.reject(new Error(`Invalid session state ${this.state}`));
2354
2354
  const i = t.requestDelegate, s = this.copyRequestOptions(t.requestOptions);
2355
2355
  return s.extraHeaders = s.extraHeaders ? s.extraHeaders.concat(this.referExtraHeaders(this.referToString(e))) : this.referExtraHeaders(this.referToString(e)), this._refer(t.onNotify, i, s);
@@ -2454,7 +2454,7 @@ class we {
2454
2454
  sessionDescriptionHandlerModifiers: this.pendingReinviteAck ? this._sessionDescriptionHandlerModifiersReInvite : this._sessionDescriptionHandlerModifiers
2455
2455
  };
2456
2456
  if (this.delegate && this.delegate.onAck) {
2457
- const s = new Mt(e);
2457
+ const s = new Ot(e);
2458
2458
  this.delegate.onAck(s);
2459
2459
  }
2460
2460
  switch (this.pendingReinviteAck = !1, t.signalingState) {
@@ -2497,7 +2497,7 @@ class we {
2497
2497
  return;
2498
2498
  }
2499
2499
  if (this.delegate && this.delegate.onBye) {
2500
- const t = new qt(e);
2500
+ const t = new Ft(e);
2501
2501
  this.delegate.onBye(t);
2502
2502
  } else
2503
2503
  e.accept();
@@ -2513,7 +2513,7 @@ class we {
2513
2513
  return;
2514
2514
  }
2515
2515
  if (this.delegate && this.delegate.onInfo) {
2516
- const t = new Ft(e);
2516
+ const t = new Ut(e);
2517
2517
  this.delegate.onInfo(t);
2518
2518
  } else
2519
2519
  e.accept();
@@ -2576,7 +2576,7 @@ class we {
2576
2576
  return;
2577
2577
  }
2578
2578
  if (this.delegate && this.delegate.onMessage) {
2579
- const t = new vt(e);
2579
+ const t = new Tt(e);
2580
2580
  this.delegate.onMessage(t);
2581
2581
  } else
2582
2582
  e.accept();
@@ -2591,12 +2591,12 @@ class we {
2591
2591
  return;
2592
2592
  }
2593
2593
  if (this.onNotify) {
2594
- const t = new Je(e);
2594
+ const t = new Ze(e);
2595
2595
  this.onNotify(t);
2596
2596
  return;
2597
2597
  }
2598
2598
  if (this.delegate && this.delegate.onNotify) {
2599
- const t = new Je(e);
2599
+ const t = new Ze(e);
2600
2600
  this.delegate.onNotify(t);
2601
2601
  } else
2602
2602
  e.accept();
@@ -2626,7 +2626,7 @@ class we {
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 jt(e, this);
2629
+ const t = new Gt(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 we {
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) => Pe(r)).catch((r) => {
2680
+ return t.getDescription(i, s).then((r) => ke(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;
@@ -2716,7 +2716,7 @@ class we {
2716
2716
  const i = this.setupSessionDescriptionHandler(), s = t.sessionDescriptionHandlerOptions, r = t.sessionDescriptionHandlerModifiers;
2717
2717
  try {
2718
2718
  if (!i.hasDescription(e.contentType))
2719
- return Promise.reject(new Ye());
2719
+ return Promise.reject(new Je());
2720
2720
  } catch (n) {
2721
2721
  this.logger.error("Session.setAnswer: SDH hasDescription threw...");
2722
2722
  const o = n instanceof Error ? n : new Error(n);
@@ -2742,14 +2742,14 @@ class we {
2742
2742
  const i = this.setupSessionDescriptionHandler(), s = t.sessionDescriptionHandlerOptions, r = t.sessionDescriptionHandlerModifiers;
2743
2743
  try {
2744
2744
  if (!i.hasDescription(e.contentType))
2745
- return Promise.reject(new Ye());
2745
+ return Promise.reject(new Je());
2746
2746
  } catch (n) {
2747
2747
  this.logger.error("Session.setOfferAndGetAnswer: SDH hasDescription threw...");
2748
2748
  const o = n instanceof Error ? n : new Error(n);
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) => Pe(n)).catch((n) => {
2752
+ return i.setDescription(e.content, s, r).then(() => i.getDescription(s, r)).then((n) => ke(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;
@@ -2819,7 +2819,7 @@ class we {
2819
2819
  }
2820
2820
  getReasonHeaderValue(e, t) {
2821
2821
  const i = e;
2822
- let s = Me(e);
2822
+ let s = qe(e);
2823
2823
  return !s && t && (s = t), "SIP;cause=" + i + ';text="' + s + '"';
2824
2824
  }
2825
2825
  referExtraHeaders(e) {
@@ -2839,11 +2839,11 @@ class we {
2839
2839
  return t;
2840
2840
  }
2841
2841
  }
2842
- var K;
2842
+ var z;
2843
2843
  (function(a) {
2844
2844
  a.Required = "Required", a.Supported = "Supported", a.Unsupported = "Unsupported";
2845
- })(K = K || (K = {}));
2846
- const Vt = {
2845
+ })(z = z || (z = {}));
2846
+ const Wt = {
2847
2847
  "100rel": !0,
2848
2848
  199: !0,
2849
2849
  answermode: !0,
@@ -2879,7 +2879,7 @@ const Vt = {
2879
2879
  uui: !0
2880
2880
  // RFC 7433
2881
2881
  };
2882
- class ue extends we {
2882
+ class ue extends be {
2883
2883
  /** @internal */
2884
2884
  constructor(e, t) {
2885
2885
  super(e), this.incomingInviteRequest = t, this.disposed = !1, this.expiresTimer = void 0, this.isCanceled = !1, this.rel100 = "none", this.rseq = Math.floor(Math.random() * 1e4), this.userNoAnswerTimer = void 0, this.waitingForPrack = !1, this.logger = e.getLogger("sip.Invitation");
@@ -3007,7 +3007,7 @@ class ue extends we {
3007
3007
  if (t < 100 || t > 199)
3008
3008
  throw new TypeError("Invalid statusCode: " + t);
3009
3009
  return e.sessionDescriptionHandlerModifiers && (this.sessionDescriptionHandlerModifiers = e.sessionDescriptionHandlerModifiers), e.sessionDescriptionHandlerOptions && (this.sessionDescriptionHandlerOptions = e.sessionDescriptionHandlerOptions), this.waitingForPrack ? (this.logger.warn("Unexpected call for progress while waiting for prack, ignoring"), Promise.resolve()) : e.statusCode === 100 ? this.sendProgressTrying().then(() => {
3010
- }).catch((i) => this.handleResponseError(i)) : this.rel100 !== "required" && !(this.rel100 === "supported" && e.rel100) && !(this.rel100 === "supported" && this.userAgent.configuration.sipExtension100rel === K.Required) ? this.sendProgress(e).then(() => {
3010
+ }).catch((i) => this.handleResponseError(i)) : this.rel100 !== "required" && !(this.rel100 === "supported" && e.rel100) && !(this.rel100 === "supported" && this.userAgent.configuration.sipExtension100rel === z.Required) ? this.sendProgress(e).then(() => {
3011
3011
  }).catch((i) => this.handleResponseError(i)) : this.sendProgressReliableWaitForPrack(e).then(() => {
3012
3012
  }).catch((i) => this.handleResponseError(i));
3013
3013
  }
@@ -3030,10 +3030,10 @@ class ue extends we {
3030
3030
  const n = new Error(`Invalid session state ${this.state}`);
3031
3031
  return this.logger.error(n.message), Promise.reject(n);
3032
3032
  }
3033
- const t = e.statusCode || 480, i = e.reasonPhrase ? e.reasonPhrase : Me(t), s = e.extraHeaders || [];
3033
+ const t = e.statusCode || 480, i = e.reasonPhrase ? e.reasonPhrase : qe(t), s = e.extraHeaders || [];
3034
3034
  if (t < 300 || t > 699)
3035
3035
  throw new TypeError("Invalid statusCode: " + t);
3036
- const r = e.body ? Pe(e.body) : void 0;
3036
+ const r = e.body ? ke(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(w.Terminated), Promise.resolve();
3038
3038
  }
3039
3039
  /**
@@ -3049,7 +3049,7 @@ class ue extends we {
3049
3049
  return;
3050
3050
  }
3051
3051
  if (this.delegate && this.delegate.onCancel) {
3052
- const t = new Ot(e);
3052
+ const t = new Nt(e);
3053
3053
  this.delegate.onCancel(t);
3054
3054
  }
3055
3055
  this.isCanceled = !0, this.incomingInviteRequest.reject({ statusCode: 487 }), this.stateTransition(w.Terminated);
@@ -3092,7 +3092,7 @@ class ue extends we {
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 Ye ? (this.logger.error("A session description handler occurred while sending response (content type unsupported"), t = 415) : e instanceof Ht ? this.logger.error("A session description handler occurred while sending response") : e instanceof Ue ? this.logger.error("Session ended before response could be formulated and sent (while waiting for PRACK)") : e instanceof oe && this.logger.error("Session changed state before response could be formulated and sent"), this.state === w.Initial || this.state === w.Establishing)
3095
+ if (e instanceof Error ? this.logger.error(e.message) : this.logger.error(e), e instanceof Je ? (this.logger.error("A session description handler occurred while sending response (content type unsupported"), t = 415) : e instanceof qt ? this.logger.error("A session description handler occurred while sending response") : e instanceof Le ? this.logger.error("Session ended before response could be formulated and sent (while waiting for PRACK)") : e instanceof oe && this.logger.error("Session changed state before response could be formulated and sent"), this.state === w.Initial || this.state === w.Establishing)
3096
3096
  try {
3097
3097
  this.incomingInviteRequest.reject({ statusCode: t }), this.stateTransition(w.Terminated);
3098
3098
  } catch (i) {
@@ -3129,7 +3129,7 @@ class ue extends we {
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 ? Pe(e.body) : void 0;
3132
+ const t = e.statusCode || 180, i = e.reasonPhrase, s = (e.extraHeaders || []).slice(), r = e.body ? ke(e.body) : void 0;
3133
3133
  if (t === 183 && !r)
3134
3134
  return this.sendProgressWithSDP(e);
3135
3135
  try {
@@ -3174,17 +3174,17 @@ class ue extends we {
3174
3174
  let h, m;
3175
3175
  u.session.delegate = {
3176
3176
  onPrack: (p) => {
3177
- h = p, clearTimeout(x), clearTimeout(z), this.waitingForPrack && (this.waitingForPrack = !1, this.handlePrackOfferAnswer(h).then((A) => {
3177
+ h = p, clearTimeout(x), clearTimeout(Y), this.waitingForPrack && (this.waitingForPrack = !1, this.handlePrackOfferAnswer(h).then((A) => {
3178
3178
  try {
3179
3179
  m = h.accept({ statusCode: 200, body: A }), this.prackArrived(), o({ prackRequest: h, prackResponse: m, progressResponse: u });
3180
- } catch (Fe) {
3181
- d(Fe);
3180
+ } catch (Ne) {
3181
+ d(Ne);
3182
3182
  }
3183
3183
  }).catch((A) => d(A)));
3184
3184
  }
3185
3185
  };
3186
3186
  const x = setTimeout(() => {
3187
- this.waitingForPrack && (this.waitingForPrack = !1, this.logger.warn("No PRACK received, rejecting INVITE."), clearTimeout(z), this.reject({ statusCode: 504 }).then(() => d(new Ue())).catch((p) => d(p)));
3187
+ this.waitingForPrack && (this.waitingForPrack = !1, this.logger.warn("No PRACK received, rejecting INVITE."), clearTimeout(Y), this.reject({ statusCode: 504 }).then(() => d(new Le())).catch((p) => d(p)));
3188
3188
  }, q.T1 * 64), _ = () => {
3189
3189
  try {
3190
3190
  this.incomingInviteRequest.progress({ statusCode: i, reasonPhrase: s, extraHeaders: r, body: n });
@@ -3192,9 +3192,9 @@ class ue extends we {
3192
3192
  this.waitingForPrack = !1, d(p);
3193
3193
  return;
3194
3194
  }
3195
- z = setTimeout(_, C *= 2);
3195
+ Y = setTimeout(_, C *= 2);
3196
3196
  };
3197
- let C = q.T1, z = setTimeout(_, C);
3197
+ let C = q.T1, Y = setTimeout(_, C);
3198
3198
  }).catch((u) => {
3199
3199
  this.waitingForPrack = !1, d(u);
3200
3200
  });
@@ -3236,10 +3236,10 @@ class ue extends we {
3236
3236
  * the accept to fail and the session to transition to "terminated".
3237
3237
  */
3238
3238
  prackNeverArrived() {
3239
- this.waitingForPrackReject && this.waitingForPrackReject(new Ue()), this.waitingForPrackPromise = void 0, this.waitingForPrackResolve = void 0, this.waitingForPrackReject = void 0;
3239
+ this.waitingForPrackReject && this.waitingForPrackReject(new Le()), this.waitingForPrackPromise = void 0, this.waitingForPrackResolve = void 0, this.waitingForPrackReject = void 0;
3240
3240
  }
3241
3241
  }
3242
- class $e extends we {
3242
+ class De extends be {
3243
3243
  /**
3244
3244
  * Constructs a new instance of the `Inviter` class.
3245
3245
  * @param userAgent - User agent. See {@link UserAgent} for details.
@@ -3247,7 +3247,7 @@ class $e extends we {
3247
3247
  * @param options - Options bucket. See {@link InviterOptions} for details.
3248
3248
  */
3249
3249
  constructor(e, t, i = {}) {
3250
- super(e, i), this.disposed = !1, this.earlyMedia = !1, this.earlyMediaSessionDescriptionHandlers = /* @__PURE__ */ new Map(), this.isCanceled = !1, this.inviteWithoutSdp = !1, this.logger = e.getLogger("sip.Inviter"), this.earlyMedia = i.earlyMedia !== void 0 ? i.earlyMedia : this.earlyMedia, this.fromTag = qe(), this.inviteWithoutSdp = i.inviteWithoutSdp !== void 0 ? i.inviteWithoutSdp : this.inviteWithoutSdp;
3250
+ super(e, i), this.disposed = !1, this.earlyMedia = !1, this.earlyMediaSessionDescriptionHandlers = /* @__PURE__ */ new Map(), this.isCanceled = !1, this.inviteWithoutSdp = !1, this.logger = e.getLogger("sip.Inviter"), this.earlyMedia = i.earlyMedia !== void 0 ? i.earlyMedia : this.earlyMedia, this.fromTag = Oe(), this.inviteWithoutSdp = i.inviteWithoutSdp !== void 0 ? i.inviteWithoutSdp : this.inviteWithoutSdp;
3251
3251
  const s = Object.assign({}, i);
3252
3252
  s.params = Object.assign({}, i.params);
3253
3253
  const r = i.anonymous || !1, n = e.contact.toString({
@@ -3266,7 +3266,7 @@ class $e extends we {
3266
3266
  const u = Object.assign({}, s.params);
3267
3267
  u.fromTag = this.fromTag;
3268
3268
  const h = (s.extraHeaders || []).slice();
3269
- r && e.configuration.uri && (h.push("P-Preferred-Identity: " + e.configuration.uri.toString()), h.push("Privacy: id")), h.push("Contact: " + n), h.push("Allow: " + ["ACK", "CANCEL", "INVITE", "MESSAGE", "BYE", "OPTIONS", "INFO", "NOTIFY", "REFER"].toString()), e.configuration.sipExtension100rel === K.Required && h.push("Require: 100rel"), e.configuration.sipExtensionReplaces === K.Required && h.push("Require: replaces"), s.extraHeaders = h;
3269
+ r && e.configuration.uri && (h.push("P-Preferred-Identity: " + e.configuration.uri.toString()), h.push("Privacy: id")), h.push("Contact: " + n), h.push("Allow: " + ["ACK", "CANCEL", "INVITE", "MESSAGE", "BYE", "OPTIONS", "INFO", "NOTIFY", "REFER"].toString()), e.configuration.sipExtension100rel === z.Required && h.push("Require: 100rel"), e.configuration.sipExtensionReplaces === z.Required && h.push("Require: replaces"), s.extraHeaders = h;
3270
3270
  const m = void 0;
3271
3271
  this.outgoingRequestMessage = e.userAgentCore.makeOutgoingRequestMessage(v.INVITE, t, o, d, u, h, m), this._contact = n, this._referralInviterOptions = s, this._renderbody = i.renderbody, this._rendertype = i.rendertype, i.sessionDescriptionHandlerModifiers && (this.sessionDescriptionHandlerModifiers = i.sessionDescriptionHandlerModifiers), i.sessionDescriptionHandlerOptions && (this.sessionDescriptionHandlerOptions = i.sessionDescriptionHandlerOptions), i.sessionDescriptionHandlerModifiersReInvite && (this.sessionDescriptionHandlerModifiersReInvite = i.sessionDescriptionHandlerModifiersReInvite), i.sessionDescriptionHandlerOptionsReInvite && (this.sessionDescriptionHandlerOptionsReInvite = i.sessionDescriptionHandlerOptionsReInvite), this._id = this.outgoingRequestMessage.callId + this.fromTag, this.userAgent._sessions[this._id] = this;
3272
3272
  }
@@ -3339,7 +3339,7 @@ class $e extends we {
3339
3339
  if (i && i < 200 || i > 699)
3340
3340
  throw new TypeError("Invalid statusCode: " + i);
3341
3341
  if (i) {
3342
- const r = i, n = Me(i) || s;
3342
+ const r = i, n = qe(i) || s;
3343
3343
  return "SIP;cause=" + r + ';text="' + n + '"';
3344
3344
  }
3345
3345
  }
@@ -3531,7 +3531,7 @@ class $e extends we {
3531
3531
  notifyReferer(e) {
3532
3532
  if (!this._referred)
3533
3533
  return;
3534
- if (!(this._referred instanceof we))
3534
+ if (!(this._referred instanceof be))
3535
3535
  throw new Error("Referred session not instance of session");
3536
3536
  if (!this._referred.dialog)
3537
3537
  return;
@@ -3716,7 +3716,7 @@ class $e extends we {
3716
3716
  }
3717
3717
  }
3718
3718
  }
3719
- class Gt {
3719
+ class Kt {
3720
3720
  /**
3721
3721
  * Constructs a new instance of the `Messager` class.
3722
3722
  * @param userAgent - User agent. See {@link UserAgent} for details.
@@ -3751,7 +3751,7 @@ var R;
3751
3751
  (function(a) {
3752
3752
  a.Initial = "Initial", a.Registered = "Registered", a.Unregistered = "Unregistered", a.Terminated = "Terminated";
3753
3753
  })(R = R || (R = {}));
3754
- class X {
3754
+ class Q {
3755
3755
  /**
3756
3756
  * Constructs a new instance of the `Registerer` class.
3757
3757
  * @param userAgent - User agent. See {@link UserAgent} for details.
@@ -3760,16 +3760,16 @@ class X {
3760
3760
  constructor(e, t = {}) {
3761
3761
  this.disposed = !1, this._contacts = [], this._retryAfter = void 0, this._state = R.Initial, this._waiting = !1, this._stateEventEmitter = new xe(), this._waitingEventEmitter = new xe(), this.userAgent = e;
3762
3762
  const i = e.configuration.uri.clone();
3763
- if (i.user = void 0, this.options = Object.assign(Object.assign(Object.assign({}, X.defaultOptions()), { registrar: i }), X.stripUndefinedProperties(t)), this.options.extraContactHeaderParams = (this.options.extraContactHeaderParams || []).slice(), this.options.extraHeaders = (this.options.extraHeaders || []).slice(), !this.options.registrar)
3763
+ if (i.user = void 0, this.options = Object.assign(Object.assign(Object.assign({}, Q.defaultOptions()), { registrar: i }), Q.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.");
3765
3765
  if (this.options.registrar = this.options.registrar.clone(), this.options.regId && !this.options.instanceId ? this.options.instanceId = this.userAgent.instanceId : !this.options.regId && this.options.instanceId && (this.options.regId = 1), this.options.instanceId && k.parse(this.options.instanceId, "uuid") === -1)
3766
3766
  throw new Error("Invalid instanceId.");
3767
3767
  if (this.options.regId && this.options.regId < 0)
3768
3768
  throw new Error("Invalid regId.");
3769
3769
  const s = this.options.registrar, r = this.options.params && this.options.params.fromUri || e.userAgentCore.configuration.aor, n = this.options.params && this.options.params.toUri || e.configuration.uri, o = this.options.params || {}, d = (t.extraHeaders || []).slice();
3770
- if (this.request = e.userAgentCore.makeOutgoingRequestMessage(v.REGISTER, s, r, n, o, d, void 0), this.expires = this.options.expires || X.defaultExpires, this.expires < 0)
3770
+ if (this.request = e.userAgentCore.makeOutgoingRequestMessage(v.REGISTER, s, r, n, o, d, void 0), this.expires = this.options.expires || Q.defaultExpires, this.expires < 0)
3771
3771
  throw new Error("Invalid expires.");
3772
- if (this.refreshFrequency = this.options.refreshFrequency || X.defaultRefreshFrequency, this.refreshFrequency < 50 || this.refreshFrequency > 99)
3772
+ if (this.refreshFrequency = this.options.refreshFrequency || Q.defaultRefreshFrequency, this.refreshFrequency < 50 || this.refreshFrequency > 99)
3773
3773
  throw new Error("Invalid refresh frequency. The value represents a percentage of the expiration time and should be between 50 and 99.");
3774
3774
  this.logger = e.getLogger("sip.Registerer"), this.options.logConfiguration && (this.logger.log("Configuration:"), Object.keys(this.options).forEach((u) => {
3775
3775
  const h = this.options[u];
@@ -3779,7 +3779,7 @@ class X {
3779
3779
  /** Default registerer options. */
3780
3780
  static defaultOptions() {
3781
3781
  return {
3782
- expires: X.defaultExpires,
3782
+ expires: Q.defaultExpires,
3783
3783
  extraContactHeaderParams: [],
3784
3784
  extraHeaders: [],
3785
3785
  logConfiguration: !0,
@@ -3787,7 +3787,7 @@ class X {
3787
3787
  params: {},
3788
3788
  regId: 0,
3789
3789
  registrar: new ee("sip", "anonymous", "anonymous.invalid"),
3790
- refreshFrequency: X.defaultRefreshFrequency
3790
+ refreshFrequency: Q.defaultRefreshFrequency
3791
3791
  };
3792
3792
  }
3793
3793
  /**
@@ -3896,7 +3896,7 @@ class X {
3896
3896
  for (; n--; ) {
3897
3897
  if (o = s.message.parseHeader("contact", n), !o)
3898
3898
  throw new Error("Contact undefined");
3899
- if (this.userAgent.contact.pubGruu && nt(o.uri, this.userAgent.contact.pubGruu)) {
3899
+ if (this.userAgent.contact.pubGruu && at(o.uri, this.userAgent.contact.pubGruu)) {
3900
3900
  r = Number(o.getParam("expires"));
3901
3901
  break;
3902
3902
  }
@@ -3905,7 +3905,7 @@ class X {
3905
3905
  r = Number(o.getParam("expires"));
3906
3906
  break;
3907
3907
  }
3908
- } else if (nt(o.uri, this.userAgent.contact.uri)) {
3908
+ } else if (at(o.uri, this.userAgent.contact.uri)) {
3909
3909
  r = Number(o.getParam("expires"));
3910
3910
  break;
3911
3911
  }
@@ -4084,8 +4084,8 @@ class X {
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
- X.defaultExpires = 600;
4088
- X.defaultRefreshFrequency = 99;
4087
+ Q.defaultExpires = 600;
4088
+ Q.defaultRefreshFrequency = 99;
4089
4089
  var I;
4090
4090
  (function(a) {
4091
4091
  a.Initial = "Initial", a.NotifyWait = "NotifyWait", a.Pending = "Pending", a.Active = "Active", a.Terminated = "Terminated";
@@ -4205,10 +4205,10 @@ H.hexChars = "0123456789abcdef";
4205
4205
  H.hexOut = [];
4206
4206
  H.onePassHasher = new H();
4207
4207
  H.hashStr("hello") !== "5d41402abc4b2a76b9719d911017c592" && console.error("Md5 self test failed.");
4208
- function re(a) {
4208
+ function ne(a) {
4209
4209
  return H.hashStr(a);
4210
4210
  }
4211
- class Wt {
4211
+ class zt {
4212
4212
  /**
4213
4213
  * Constructor.
4214
4214
  * @param loggerFactory - LoggerFactory.
@@ -4268,14 +4268,14 @@ class Wt {
4268
4268
  */
4269
4269
  calculateResponse(e) {
4270
4270
  let t, i;
4271
- t = this.ha1, (t === "" || t === void 0) && (t = re(this.username + ":" + this.realm + ":" + this.password)), this.qop === "auth" ? (i = re(this.method + ":" + this.uri), this.response = re(t + ":" + this.nonce + ":" + this.ncHex + ":" + this.cnonce + ":auth:" + i)) : this.qop === "auth-int" ? (i = re(this.method + ":" + this.uri + ":" + re(e || "")), this.response = re(t + ":" + this.nonce + ":" + this.ncHex + ":" + this.cnonce + ":auth-int:" + i)) : this.qop === void 0 && (i = re(this.method + ":" + this.uri), this.response = re(t + ":" + this.nonce + ":" + i));
4271
+ t = this.ha1, (t === "" || t === void 0) && (t = ne(this.username + ":" + this.realm + ":" + this.password)), this.qop === "auth" ? (i = ne(this.method + ":" + this.uri), this.response = ne(t + ":" + this.nonce + ":" + this.ncHex + ":" + this.cnonce + ":auth:" + i)) : this.qop === "auth-int" ? (i = ne(this.method + ":" + this.uri + ":" + ne(e || "")), this.response = ne(t + ":" + this.nonce + ":" + this.ncHex + ":" + this.cnonce + ":auth-int:" + i)) : this.qop === void 0 && (i = ne(this.method + ":" + this.uri), this.response = ne(t + ":" + this.nonce + ":" + i));
4272
4272
  }
4273
4273
  }
4274
4274
  var M;
4275
4275
  (function(a) {
4276
4276
  a[a.error = 0] = "error", a[a.warn = 1] = "warn", a[a.log = 2] = "log", a[a.debug = 3] = "debug";
4277
4277
  })(M = M || (M = {}));
4278
- class ot {
4278
+ class ct {
4279
4279
  constructor(e, t, i) {
4280
4280
  this.logger = e, this.category = t, this.label = i;
4281
4281
  }
@@ -4301,7 +4301,7 @@ class ot {
4301
4301
  this.logger.level = e;
4302
4302
  }
4303
4303
  }
4304
- class Kt {
4304
+ class Yt {
4305
4305
  constructor() {
4306
4306
  this.builtinEnabled = !0, this._level = M.log, this.loggers = {}, this.logger = this.getLogger("sip:loggerfactory");
4307
4307
  }
@@ -4320,11 +4320,11 @@ class Kt {
4320
4320
  }
4321
4321
  getLogger(e, t) {
4322
4322
  if (t && this.level === 3)
4323
- return new ot(this, e, t);
4323
+ return new ct(this, e, t);
4324
4324
  if (this.loggers[e])
4325
4325
  return this.loggers[e];
4326
4326
  {
4327
- const i = new ot(this, e);
4327
+ const i = new ct(this, e);
4328
4328
  return this.loggers[e] = i, i;
4329
4329
  }
4330
4330
  }
@@ -4354,7 +4354,7 @@ class Kt {
4354
4354
  }
4355
4355
  }
4356
4356
  }
4357
- var De;
4357
+ var Pe;
4358
4358
  (function(a) {
4359
4359
  function e(s, r) {
4360
4360
  let n = r, o = 0, d = 0;
@@ -4460,7 +4460,7 @@ var De;
4460
4460
  if (u === -1) {
4461
4461
  r.warn('error parsing first line of SIP message: "' + d + '"');
4462
4462
  return;
4463
- } else u.status_code ? (h = new le(), h.statusCode = u.status_code, h.reasonPhrase = u.reason_phrase) : (h = new me(), h.method = u.method, h.ruri = u.uri);
4463
+ } else u.status_code ? (h = new le(), h.statusCode = u.status_code, h.reasonPhrase = u.reason_phrase) : (h = new we(), h.method = u.method, h.ruri = u.uri);
4464
4464
  h.data = s, n = o + 2;
4465
4465
  let m;
4466
4466
  for (; ; ) {
@@ -4481,11 +4481,11 @@ var De;
4481
4481
  return h.hasHeader("content-length") ? h.body = s.substr(m, Number(h.getHeader("content-length"))) : h.body = s.substring(m), h;
4482
4482
  }
4483
4483
  a.parseMessage = i;
4484
- })(De = De || (De = {}));
4485
- function St(a, e) {
4484
+ })(Pe = Pe || (Pe = {}));
4485
+ function Ct(a, e) {
4486
4486
  if (e.statusCode < 100 || e.statusCode > 699)
4487
4487
  throw new TypeError("Invalid statusCode: " + e.statusCode);
4488
- const i = e.reasonPhrase ? e.reasonPhrase : Me(e.statusCode);
4488
+ const i = e.reasonPhrase ? e.reasonPhrase : qe(e.statusCode);
4489
4489
  let s = "SIP/2.0 " + e.statusCode + " " + i + `\r
4490
4490
  `;
4491
4491
  e.statusCode >= 100 && e.statusCode < 200, e.statusCode;
@@ -4497,7 +4497,7 @@ function St(a, e) {
4497
4497
  let u = "To: " + a.getHeader("to");
4498
4498
  if (e.statusCode > 100 && !a.parseHeader("to").hasParam("tag")) {
4499
4499
  let x = e.toTag;
4500
- x || (x = qe()), u += ";tag=" + x;
4500
+ x || (x = Oe()), u += ";tag=" + x;
4501
4501
  }
4502
4502
  u += `\r
4503
4503
  `;
@@ -4516,12 +4516,12 @@ function St(a, e) {
4516
4516
  \r
4517
4517
  `, { message: s };
4518
4518
  }
4519
- class Be extends fe {
4519
+ class je extends fe {
4520
4520
  constructor(e) {
4521
4521
  super(e || "Unspecified transport error.");
4522
4522
  }
4523
4523
  }
4524
- class Tt {
4524
+ class Et {
4525
4525
  constructor(e, t, i, s, r) {
4526
4526
  this._transport = e, this._user = t, this._id = i, this._state = s, this.listeners = new Array(), this.logger = t.loggerFactory.getLogger(r, i), this.logger.debug(`Constructing ${this.typeToString()} with id ${this.id}.`);
4527
4527
  }
@@ -4592,10 +4592,10 @@ class Tt {
4592
4592
  */
4593
4593
  send(e) {
4594
4594
  return this.transport.send(e).catch((t) => {
4595
- if (t instanceof Be)
4595
+ if (t instanceof je)
4596
4596
  throw this.onTransportError(t), t;
4597
4597
  let i;
4598
- throw t && typeof t.message == "string" ? i = new Be(t.message) : i = new Be(), this.onTransportError(i), i;
4598
+ throw t && typeof t.message == "string" ? i = new je(t.message) : i = new je(), this.onTransportError(i), i;
4599
4599
  });
4600
4600
  }
4601
4601
  setState(e) {
@@ -4605,7 +4605,7 @@ class Tt {
4605
4605
  return "UnknownType";
4606
4606
  }
4607
4607
  }
4608
- class Ct extends Tt {
4608
+ class xt extends Et {
4609
4609
  constructor(e, t, i, s, r) {
4610
4610
  super(t, i, e.viaBranch, s, r), this._request = e, this.user = i;
4611
4611
  }
@@ -4618,7 +4618,7 @@ var f;
4618
4618
  (function(a) {
4619
4619
  a.Accepted = "Accepted", a.Calling = "Calling", a.Completed = "Completed", a.Confirmed = "Confirmed", a.Proceeding = "Proceeding", a.Terminated = "Terminated", a.Trying = "Trying";
4620
4620
  })(f = f || (f = {}));
4621
- class L extends Ct {
4621
+ class L extends xt {
4622
4622
  /**
4623
4623
  * Constructor.
4624
4624
  * Upon construction, a "100 Trying" reply will be immediately sent.
@@ -4848,9 +4848,9 @@ class L extends Ct {
4848
4848
  this.logger.debug(`Timer L expired for INVITE server transaction ${this.id}.`), this.state === f.Accepted && this.stateTransition(f.Terminated);
4849
4849
  }
4850
4850
  }
4851
- class Oe extends Tt {
4851
+ class Fe extends Et {
4852
4852
  constructor(e, t, i, s, r) {
4853
- super(t, i, Oe.makeId(e), s, r), this._request = e, this.user = i, e.setViaHeader(this.id, t.protocol);
4853
+ super(t, i, Fe.makeId(e), s, r), this._request = e, this.user = i, e.setViaHeader(this.id, t.protocol);
4854
4854
  }
4855
4855
  static makeId(e) {
4856
4856
  if (e.method === "CANCEL") {
@@ -4878,7 +4878,7 @@ class Oe extends Tt {
4878
4878
  this.user.onRequestTimeout && this.user.onRequestTimeout();
4879
4879
  }
4880
4880
  }
4881
- class j extends Oe {
4881
+ class j extends Fe {
4882
4882
  /**
4883
4883
  * Constructor
4884
4884
  * Upon construction, the outgoing request's Via header is updated by calling `setViaHeader`.
@@ -5010,7 +5010,7 @@ class j extends Oe {
5010
5010
  this.state === f.Completed && this.stateTransition(f.Terminated);
5011
5011
  }
5012
5012
  }
5013
- class be {
5013
+ class ye {
5014
5014
  /**
5015
5015
  * Dialog constructor.
5016
5016
  * @param core - User agent core.
@@ -5267,7 +5267,7 @@ class be {
5267
5267
  return e.method === v.ACK ? !0 : this.remoteSequenceNumber && e.cseq <= this.remoteSequenceNumber ? (this.core.replyStateless(e, { statusCode: 500 }), !1) : !0;
5268
5268
  }
5269
5269
  }
5270
- class de extends Oe {
5270
+ class de extends Fe {
5271
5271
  /**
5272
5272
  * Constructor.
5273
5273
  * Upon construction, the outgoing request's Via header is updated by calling `setViaHeader`.
@@ -5653,13 +5653,13 @@ class O {
5653
5653
  this.core.userAgentClients.set(i, this);
5654
5654
  }
5655
5655
  }
5656
- class zt extends O {
5656
+ class Jt extends O {
5657
5657
  constructor(e, t, i) {
5658
5658
  const s = e.createOutgoingRequestMessage(v.BYE, i);
5659
5659
  super(j, e.userAgentCore, s, t), e.dispose();
5660
5660
  }
5661
5661
  }
5662
- class B extends Ct {
5662
+ class B extends xt {
5663
5663
  /**
5664
5664
  * Constructor.
5665
5665
  * After construction the transaction will be in the "trying": state and the transaction
@@ -5800,7 +5800,7 @@ class B extends Ct {
5800
5800
  }
5801
5801
  class te {
5802
5802
  constructor(e, t, i, s) {
5803
- this.transactionConstructor = e, this.core = t, this.message = i, this.delegate = s, this.logger = this.loggerFactory.getLogger("sip.user-agent-server"), this.toTag = i.toTag ? i.toTag : qe(), this.init();
5803
+ this.transactionConstructor = e, this.core = t, this.message = i, this.delegate = s, this.logger = this.loggerFactory.getLogger("sip.user-agent-server"), this.toTag = i.toTag ? i.toTag : Oe(), this.init();
5804
5804
  }
5805
5805
  dispose() {
5806
5806
  this.transaction.dispose();
@@ -5924,7 +5924,7 @@ class te {
5924
5924
  */
5925
5925
  reply(e) {
5926
5926
  !e.toTag && e.statusCode !== 100 && (e.toTag = this.toTag), e.userAgent = e.userAgent || this.core.configuration.userAgentHeaderFieldValue, e.supported = e.supported || this.core.configuration.supportedOptionTagsResponse;
5927
- const t = St(this.message, e);
5927
+ const t = Ct(this.message, e);
5928
5928
  return this.transaction.receiveResponse(e.statusCode, t.message), t;
5929
5929
  }
5930
5930
  init() {
@@ -5942,59 +5942,59 @@ class te {
5942
5942
  this.core.userAgentServers.set(t.id, this);
5943
5943
  }
5944
5944
  }
5945
- class Yt extends te {
5945
+ class Zt extends te {
5946
5946
  constructor(e, t, i) {
5947
5947
  super(B, e.userAgentCore, t, i);
5948
5948
  }
5949
5949
  }
5950
- class Jt extends O {
5950
+ class Xt extends O {
5951
5951
  constructor(e, t, i) {
5952
5952
  const s = e.createOutgoingRequestMessage(v.INFO, i);
5953
5953
  super(j, e.userAgentCore, s, t);
5954
5954
  }
5955
5955
  }
5956
- class Zt extends te {
5956
+ class Qt extends te {
5957
5957
  constructor(e, t, i) {
5958
5958
  super(B, e.userAgentCore, t, i);
5959
5959
  }
5960
5960
  }
5961
- class Et extends O {
5961
+ class _t extends O {
5962
5962
  constructor(e, t, i) {
5963
5963
  super(j, e, t, i);
5964
5964
  }
5965
5965
  }
5966
- class xt extends te {
5966
+ class Rt extends te {
5967
5967
  constructor(e, t, i) {
5968
5968
  super(B, e, t, i);
5969
5969
  }
5970
5970
  }
5971
- class Xt extends O {
5971
+ class ei extends O {
5972
5972
  constructor(e, t, i) {
5973
5973
  const s = e.createOutgoingRequestMessage(v.NOTIFY, i);
5974
5974
  super(j, e.userAgentCore, s, t);
5975
5975
  }
5976
5976
  }
5977
- function Qt(a) {
5977
+ function ti(a) {
5978
5978
  return a.userAgentCore !== void 0;
5979
5979
  }
5980
- class ke extends te {
5980
+ class He extends te {
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 = Qt(e) ? e.userAgentCore : e;
5987
+ const s = ti(e) ? e.userAgentCore : e;
5988
5988
  super(B, s, t, i);
5989
5989
  }
5990
5990
  }
5991
- class ei extends O {
5991
+ class ii extends O {
5992
5992
  constructor(e, t, i) {
5993
5993
  const s = e.createOutgoingRequestMessage(v.PRACK, i);
5994
5994
  super(j, e.userAgentCore, s, t), e.signalingStateTransition(s);
5995
5995
  }
5996
5996
  }
5997
- class ti extends te {
5997
+ class si extends te {
5998
5998
  constructor(e, t, i) {
5999
5999
  super(B, e.userAgentCore, t, i), e.signalingStateTransition(t), this.dialog = e;
6000
6000
  }
@@ -6006,7 +6006,7 @@ class ti extends te {
6006
6006
  return e.body && this.dialog.signalingStateTransition(e.body), super.accept(e);
6007
6007
  }
6008
6008
  }
6009
- class ii extends O {
6009
+ class ri extends O {
6010
6010
  constructor(e, t, i) {
6011
6011
  const s = e.createOutgoingRequestMessage(v.INVITE, i);
6012
6012
  super(de, e.userAgentCore, s, t), this.delegate = t, e.signalingStateTransition(s), e.reinviteUserAgentClient = this, this.dialog = e;
@@ -6049,7 +6049,7 @@ class ii extends O {
6049
6049
  }
6050
6050
  }
6051
6051
  }
6052
- class si extends te {
6052
+ class ni extends te {
6053
6053
  constructor(e, t, i) {
6054
6054
  super(L, e.userAgentCore, t, i), e.reinviteUserAgentServer = this, this.dialog = e;
6055
6055
  }
@@ -6091,27 +6091,27 @@ class si extends te {
6091
6091
  return this.dialog.signalingStateRollback(), this.dialog.reinviteUserAgentServer = void 0, super.reject(e);
6092
6092
  }
6093
6093
  }
6094
- class ri extends O {
6094
+ class ai extends O {
6095
6095
  constructor(e, t, i) {
6096
6096
  const s = e.createOutgoingRequestMessage(v.REFER, i);
6097
6097
  super(j, e.userAgentCore, s, t);
6098
6098
  }
6099
6099
  }
6100
- function ni(a) {
6100
+ function oi(a) {
6101
6101
  return a.userAgentCore !== void 0;
6102
6102
  }
6103
- class _t extends te {
6103
+ class It extends te {
6104
6104
  /**
6105
6105
  * REFER UAS constructor.
6106
6106
  * @param dialogOrCore - Dialog for in dialog REFER, UserAgentCore for out of dialog REFER.
6107
6107
  * @param message - Incoming REFER request message.
6108
6108
  */
6109
6109
  constructor(e, t, i) {
6110
- const s = ni(e) ? e.userAgentCore : e;
6110
+ const s = oi(e) ? e.userAgentCore : e;
6111
6111
  super(B, s, t, i);
6112
6112
  }
6113
6113
  }
6114
- class He extends be {
6114
+ class Me extends ye {
6115
6115
  constructor(e, t, i, s) {
6116
6116
  super(t, i), this.initialTransaction = e, this._signalingState = y.Initial, this.ackWait = !1, this.ackProcessing = !1, this.delegate = s, e instanceof L && (this.ackWait = !0), this.early || this.start2xxRetransmissionTimer(), this.signalingStateTransition(e.request), this.logger = t.loggerFactory.getLogger("sip.invite-dialog"), this.logger.log(`INVITE dialog ${this.id} constructed`);
6117
6117
  }
@@ -6220,7 +6220,7 @@ class He extends be {
6220
6220
  if (this.ackWait && this.initialTransaction.state !== f.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 zt(this, e, t);
6223
+ return new Jt(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 He extends be {
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 Jt(this, e, t);
6238
+ return new Xt(this, e, t);
6239
6239
  }
6240
6240
  /**
6241
6241
  * Modifying an Existing Session
@@ -6265,7 +6265,7 @@ class He extends be {
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 ii(this, e, t);
6268
+ return new ri(this, e, t);
6269
6269
  }
6270
6270
  /**
6271
6271
  * A UAC MAY associate a MESSAGE request with an existing dialog. If a
@@ -6278,7 +6278,7 @@ class He extends be {
6278
6278
  if (this.logger.log(`INVITE dialog ${this.id} sending MESSAGE request`), this.early)
6279
6279
  throw new Error("Dialog not confirmed.");
6280
6280
  const i = this.createOutgoingRequestMessage(v.MESSAGE, t);
6281
- return new Et(this.core, i, e);
6281
+ return new _t(this.core, i, e);
6282
6282
  }
6283
6283
  /**
6284
6284
  * The NOTIFY mechanism defined in [2] MUST be used to inform the agent
@@ -6289,7 +6289,7 @@ class He extends be {
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 Xt(this, e, t);
6292
+ return new ei(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 He extends be {
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 ei(this, e, t);
6305
+ return this.logger.log(`INVITE dialog ${this.id} sending PRACK request`), new ii(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 He extends be {
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 ri(this, e, t);
6316
+ return new ai(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 He extends be {
6391
6391
  switch (e.method) {
6392
6392
  case v.BYE:
6393
6393
  {
6394
- const t = new Yt(this, e);
6394
+ const t = new Zt(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 Zt(this, e);
6400
+ const t = new Qt(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,31 +6406,31 @@ class He extends be {
6406
6406
  break;
6407
6407
  case v.INVITE:
6408
6408
  {
6409
- const t = new si(this, e);
6409
+ const t = new ni(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;
6413
6413
  case v.MESSAGE:
6414
6414
  {
6415
- const t = new xt(this.core, e);
6415
+ const t = new Rt(this.core, e);
6416
6416
  this.delegate && this.delegate.onMessage ? this.delegate.onMessage(t) : t.accept();
6417
6417
  }
6418
6418
  break;
6419
6419
  case v.NOTIFY:
6420
6420
  {
6421
- const t = new ke(this, e);
6421
+ const t = new He(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 ti(this, e);
6427
+ const t = new si(this, e);
6428
6428
  this.delegate && this.delegate.onPrack ? this.delegate.onPrack(t) : t.accept();
6429
6429
  }
6430
6430
  break;
6431
6431
  case v.REFER:
6432
6432
  {
6433
- const t = new _t(this, e);
6433
+ const t = new It(this, e);
6434
6434
  this.delegate && this.delegate.onRefer ? this.delegate.onRefer(t) : t.reject();
6435
6435
  }
6436
6436
  break;
@@ -6471,7 +6471,7 @@ class He extends be {
6471
6471
  signalingStateTransition(e) {
6472
6472
  const t = Ce(e);
6473
6473
  if (!(!t || t.contentDisposition !== "session")) {
6474
- if (this._signalingState === y.Stable && (this._rollbackOffer = this._offer, this._rollbackAnswer = this._answer), e instanceof me)
6474
+ if (this._signalingState === y.Stable && (this._rollbackOffer = this._offer, this._rollbackAnswer = this._answer), e instanceof we)
6475
6475
  switch (this._signalingState) {
6476
6476
  case y.Initial:
6477
6477
  case y.Stable:
@@ -6519,7 +6519,7 @@ class He extends be {
6519
6519
  default:
6520
6520
  throw new Error("Unexpected signaling state.");
6521
6521
  }
6522
- if (yt(e))
6522
+ if (St(e))
6523
6523
  switch (this._signalingState) {
6524
6524
  case y.Initial:
6525
6525
  case y.Stable:
@@ -6575,7 +6575,7 @@ class He extends be {
6575
6575
  }
6576
6576
  }
6577
6577
  }
6578
- class ai extends O {
6578
+ class ci extends O {
6579
6579
  constructor(e, t, i) {
6580
6580
  super(de, e, t, i), this.confirmedDialogAcks = /* @__PURE__ */ new Map(), this.confirmedDialogs = /* @__PURE__ */ new Map(), this.earlyDialogs = /* @__PURE__ */ new Map(), this.delegate = i;
6581
6581
  }
@@ -6617,13 +6617,13 @@ class ai extends O {
6617
6617
  this.logger.error("Non-100 1xx INVITE response received without a Contact header field, dropping.");
6618
6618
  return;
6619
6619
  }
6620
- const s = be.initialDialogStateForUserAgentClient(this.message, e);
6620
+ const s = ye.initialDialogStateForUserAgentClient(this.message, e);
6621
6621
  let r = this.earlyDialogs.get(s.id);
6622
6622
  if (!r) {
6623
6623
  const o = this.transaction;
6624
6624
  if (!(o instanceof de))
6625
6625
  throw new Error("Transaction not instance of InviteClientTransaction.");
6626
- r = new He(o, this.core, s), this.earlyDialogs.set(r.id, r);
6626
+ r = new Me(o, this.core, s), this.earlyDialogs.set(r.id, r);
6627
6627
  }
6628
6628
  if (!r.reliableSequenceGuard(e)) {
6629
6629
  this.logger.warn("1xx INVITE reliable response received out of order or is a retransmission, dropping.");
@@ -6648,7 +6648,7 @@ class ai extends O {
6648
6648
  this.logger.error("2xx INVITE response received without a Contact header field, dropping.");
6649
6649
  return;
6650
6650
  }
6651
- const s = be.initialDialogStateForUserAgentClient(this.message, e);
6651
+ const s = ye.initialDialogStateForUserAgentClient(this.message, e);
6652
6652
  let r = this.confirmedDialogs.get(s.id);
6653
6653
  if (r) {
6654
6654
  const o = this.confirmedDialogAcks.get(s.id);
@@ -6666,7 +6666,7 @@ class ai extends O {
6666
6666
  const o = this.transaction;
6667
6667
  if (!(o instanceof de))
6668
6668
  throw new Error("Transaction not instance of InviteClientTransaction.");
6669
- r = new He(o, this.core, s), this.confirmedDialogs.set(r.id, r);
6669
+ r = new Me(o, this.core, s), this.confirmedDialogs.set(r.id, r);
6670
6670
  }
6671
6671
  (r.signalingState === y.Initial || r.signalingState === y.HaveLocalOffer) && r.signalingStateTransition(e);
6672
6672
  const n = r;
@@ -6696,7 +6696,7 @@ class ai extends O {
6696
6696
  }
6697
6697
  }
6698
6698
  }
6699
- class je extends te {
6699
+ class Ve extends te {
6700
6700
  constructor(e, t, i) {
6701
6701
  super(L, e, t, i), this.core = e;
6702
6702
  }
@@ -6721,8 +6721,8 @@ class je extends te {
6721
6721
  const d = this.transaction;
6722
6722
  if (!(d instanceof L))
6723
6723
  throw new Error("Transaction not instance of InviteClientTransaction.");
6724
- const u = be.initialDialogStateForUserAgentServer(this.message, this.toTag);
6725
- this.confirmedDialog = new He(d, this.core, u);
6724
+ const u = ye.initialDialogStateForUserAgentServer(this.message, this.toTag);
6725
+ this.confirmedDialog = new Me(d, this.core, u);
6726
6726
  }
6727
6727
  const t = this.message.getHeaders("record-route").map((d) => `Record-Route: ${d}`), i = `Contact: ${this.core.configuration.contact.toString()}`, s = "Allow: " + ce.toString();
6728
6728
  if (!e.body) {
@@ -6764,8 +6764,8 @@ class je extends te {
6764
6764
  const o = this.transaction;
6765
6765
  if (!(o instanceof L))
6766
6766
  throw new Error("Transaction not instance of InviteClientTransaction.");
6767
- const d = be.initialDialogStateForUserAgentServer(this.message, this.toTag, !0);
6768
- this.earlyDialog = new He(o, this.core, d);
6767
+ const d = ye.initialDialogStateForUserAgentServer(this.message, this.toTag, !0);
6768
+ this.earlyDialog = new Me(o, this.core, d);
6769
6769
  }
6770
6770
  const t = this.message.getHeaders("record-route").map((o) => `Record-Route: ${o}`), i = `Contact: ${this.core.configuration.contact}`;
6771
6771
  e.extraHeaders = e.extraHeaders || [], e.extraHeaders = e.extraHeaders.concat(t), e.extraHeaders.push(i);
@@ -6799,22 +6799,22 @@ class je extends te {
6799
6799
  return super.reject(e);
6800
6800
  }
6801
6801
  }
6802
- class oi extends O {
6802
+ class di extends O {
6803
6803
  constructor(e, t, i) {
6804
6804
  super(j, e, t, i);
6805
6805
  }
6806
6806
  }
6807
- class ci extends O {
6807
+ class li extends O {
6808
6808
  constructor(e, t, i) {
6809
6809
  super(j, e, t, i);
6810
6810
  }
6811
6811
  }
6812
- class di extends te {
6812
+ class hi extends te {
6813
6813
  constructor(e, t, i) {
6814
6814
  super(B, e, t, i), this.core = e;
6815
6815
  }
6816
6816
  }
6817
- class li extends O {
6817
+ class ui extends O {
6818
6818
  constructor(e, t, i) {
6819
6819
  const s = e.createOutgoingRequestMessage(v.SUBSCRIBE, i);
6820
6820
  super(j, e.userAgentCore, s, t), this.dialog = e;
@@ -6838,7 +6838,7 @@ class li extends O {
6838
6838
  e.statusCode && e.statusCode >= 400 && e.statusCode < 700 && [404, 405, 410, 416, 480, 481, 482, 483, 484, 485, 489, 501, 604].includes(e.statusCode) && this.dialog.terminate(), super.receiveResponse(e);
6839
6839
  }
6840
6840
  }
6841
- class ct extends be {
6841
+ class dt extends ye {
6842
6842
  constructor(e, t, i, s, r, n) {
6843
6843
  super(s, r), this.delegate = n, this._autoRefresh = !1, this._subscriptionEvent = e, this._subscriptionExpires = t, this._subscriptionExpiresInitial = t, this._subscriptionExpiresLastSet = Math.floor(Date.now() / 1e3), this._subscriptionRefresh = void 0, this._subscriptionRefreshLastSet = void 0, this._subscriptionState = i, this.logger = s.loggerFactory.getLogger("sip.subscribe-dialog"), this.logger.log(`SUBSCRIBE dialog ${this.id} constructed`);
6844
6844
  }
@@ -6951,7 +6951,7 @@ class ct extends be {
6951
6951
  if (this.subscriptionState !== I.Pending && this.subscriptionState !== I.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 li(this, e, t);
6954
+ const s = new ui(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(), q.TIMER_N)), s;
6956
6956
  }
6957
6957
  /**
@@ -7004,7 +7004,7 @@ class ct extends be {
7004
7004
  this.logger.warn("Unrecognized subscription state.");
7005
7005
  break;
7006
7006
  }
7007
- const n = new ke(this, e);
7007
+ const n = new He(this, e);
7008
7008
  this.delegate && this.delegate.onNotify ? this.delegate.onNotify(n) : n.accept();
7009
7009
  }
7010
7010
  onRefresh(e) {
@@ -7074,7 +7074,7 @@ class ct extends be {
7074
7074
  this.logger.warn("Timer N expired for SUBSCRIBE dialog. Timed out waiting for NOTIFY."), this.subscriptionState !== I.Terminated && (this.stateTransition(I.Terminated), this.onTerminated());
7075
7075
  }
7076
7076
  }
7077
- class hi extends O {
7077
+ class gi extends O {
7078
7078
  constructor(e, t, i) {
7079
7079
  const s = t.getHeader("Event");
7080
7080
  if (!s)
@@ -7144,8 +7144,8 @@ class hi extends O {
7144
7144
  throw new Error(`Unrecognized state ${s}.`);
7145
7145
  }
7146
7146
  if (this.subscriptionState !== I.Terminated) {
7147
- const r = ct.initialDialogStateForSubscription(this.message, e.message);
7148
- this.dialog = new ct(this.subscriptionEvent, this.subscriptionExpires, this.subscriptionState, this.core, r);
7147
+ const r = dt.initialDialogStateForSubscription(this.message, e.message);
7148
+ this.dialog = new dt(this.subscriptionEvent, this.subscriptionExpires, this.subscriptionState, this.core, r);
7149
7149
  }
7150
7150
  if (this.delegate && this.delegate.onNotify) {
7151
7151
  const r = e, n = this.dialog;
@@ -7191,13 +7191,13 @@ class hi extends O {
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 ui extends te {
7194
+ class fi extends te {
7195
7195
  constructor(e, t, i) {
7196
7196
  super(B, e, t, i), this.core = e;
7197
7197
  }
7198
7198
  }
7199
- const dt = ["application/sdp", "application/dtmf-relay"];
7200
- class gi {
7199
+ const lt = ["application/sdp", "application/dtmf-relay"];
7200
+ class pi {
7201
7201
  /**
7202
7202
  * Constructor.
7203
7203
  * @param configuration - Configuration.
@@ -7231,7 +7231,7 @@ class gi {
7231
7231
  * @param delegate - Request delegate.
7232
7232
  */
7233
7233
  invite(e, t) {
7234
- return new ai(this, e, t);
7234
+ return new ci(this, e, t);
7235
7235
  }
7236
7236
  /**
7237
7237
  * Send MESSAGE.
@@ -7239,7 +7239,7 @@ class gi {
7239
7239
  * @param delegate - Request delegate.
7240
7240
  */
7241
7241
  message(e, t) {
7242
- return new Et(this, e, t);
7242
+ return new _t(this, e, t);
7243
7243
  }
7244
7244
  /**
7245
7245
  * Send PUBLISH.
@@ -7247,7 +7247,7 @@ class gi {
7247
7247
  * @param delegate - Request delegate.
7248
7248
  */
7249
7249
  publish(e, t) {
7250
- return new oi(this, e, t);
7250
+ return new di(this, e, t);
7251
7251
  }
7252
7252
  /**
7253
7253
  * Send REGISTER.
@@ -7255,7 +7255,7 @@ class gi {
7255
7255
  * @param delegate - Request delegate.
7256
7256
  */
7257
7257
  register(e, t) {
7258
- return new ci(this, e, t);
7258
+ return new li(this, e, t);
7259
7259
  }
7260
7260
  /**
7261
7261
  * Send SUBSCRIBE.
@@ -7263,7 +7263,7 @@ class gi {
7263
7263
  * @param delegate - Request delegate.
7264
7264
  */
7265
7265
  subscribe(e, t) {
7266
- return new hi(this, e, t);
7266
+ return new gi(this, e, t);
7267
7267
  }
7268
7268
  /**
7269
7269
  * Send a request.
@@ -7331,7 +7331,7 @@ class gi {
7331
7331
  replyStateless(e, t) {
7332
7332
  const i = this.configuration.userAgentHeaderFieldValue, s = this.configuration.supportedOptionTagsResponse;
7333
7333
  t = Object.assign(Object.assign({}, t), { userAgent: i, supported: s });
7334
- const r = St(e, t);
7334
+ const r = Ct(e, t);
7335
7335
  return this.transport.send(r.message).catch((n) => {
7336
7336
  n instanceof Error && this.logger.error(n.message), this.logger.error(`Transport error occurred sending stateless reply to ${e.method} request.`);
7337
7337
  }), r;
@@ -7350,12 +7350,12 @@ class gi {
7350
7350
  */
7351
7351
  receiveRequestFromTransport(e) {
7352
7352
  const t = e.viaBranch, i = this.userAgentServers.get(t);
7353
- if (e.method === v.ACK && i && i.transaction.state === f.Accepted && i instanceof je) {
7353
+ if (e.method === v.ACK && i && i.transaction.state === f.Accepted && i instanceof Ve) {
7354
7354
  this.logger.warn(`Discarding out of dialog ACK after 2xx response sent on transaction ${t}.`);
7355
7355
  return;
7356
7356
  }
7357
7357
  if (e.method === v.CANCEL) {
7358
- i ? (this.replyStateless(e, { statusCode: 200 }), i.transaction instanceof L && i.transaction.state === f.Proceeding && i instanceof je && i.receiveCancel(e)) : this.replyStateless(e, { statusCode: 481 });
7358
+ i ? (this.replyStateless(e, { statusCode: 200 }), i.transaction instanceof L && i.transaction.state === f.Proceeding && i instanceof Ve && i.receiveCancel(e)) : this.replyStateless(e, { statusCode: 481 });
7359
7359
  return;
7360
7360
  }
7361
7361
  if (i) {
@@ -7428,7 +7428,7 @@ class gi {
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 ke(this, e);
7431
+ const o = new He(this, e);
7432
7432
  n.onNotify(o);
7433
7433
  return;
7434
7434
  }
@@ -7436,7 +7436,7 @@ class gi {
7436
7436
  const t = e.callId + e.toTag + e.fromTag, i = this.dialogs.get(t);
7437
7437
  if (i) {
7438
7438
  if (e.method === v.OPTIONS) {
7439
- const s = "Allow: " + ce.toString(), r = "Accept: " + dt.toString();
7439
+ const s = "Allow: " + ce.toString(), r = "Accept: " + lt.toString();
7440
7440
  this.replyStateless(e, {
7441
7441
  statusCode: 200,
7442
7442
  extraHeaders: [s, r]
@@ -7468,25 +7468,25 @@ class gi {
7468
7468
  break;
7469
7469
  case v.INVITE:
7470
7470
  {
7471
- const t = new je(this, e);
7471
+ const t = new Ve(this, e);
7472
7472
  this.delegate.onInvite ? this.delegate.onInvite(t) : t.reject();
7473
7473
  }
7474
7474
  break;
7475
7475
  case v.MESSAGE:
7476
7476
  {
7477
- const t = new xt(this, e);
7477
+ const t = new Rt(this, e);
7478
7478
  this.delegate.onMessage ? this.delegate.onMessage(t) : t.accept();
7479
7479
  }
7480
7480
  break;
7481
7481
  case v.NOTIFY:
7482
7482
  {
7483
- const t = new ke(this, e);
7483
+ const t = new He(this, e);
7484
7484
  this.delegate.onNotify ? this.delegate.onNotify(t) : t.reject({ statusCode: 405 });
7485
7485
  }
7486
7486
  break;
7487
7487
  case v.OPTIONS:
7488
7488
  {
7489
- const t = "Allow: " + ce.toString(), i = "Accept: " + dt.toString();
7489
+ const t = "Allow: " + ce.toString(), i = "Accept: " + lt.toString();
7490
7490
  this.replyStateless(e, {
7491
7491
  statusCode: 200,
7492
7492
  extraHeaders: [t, i]
@@ -7495,19 +7495,19 @@ class gi {
7495
7495
  break;
7496
7496
  case v.REFER:
7497
7497
  {
7498
- const t = new _t(this, e);
7498
+ const t = new It(this, e);
7499
7499
  this.delegate.onRefer ? this.delegate.onRefer(t) : t.reject({ statusCode: 405 });
7500
7500
  }
7501
7501
  break;
7502
7502
  case v.REGISTER:
7503
7503
  {
7504
- const t = new di(this, e);
7504
+ const t = new hi(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 ui(this, e);
7510
+ const t = new fi(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 gi {
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 fi() {
7536
+ function mi() {
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 pi() {
7539
+ function wi() {
7540
7540
  return {
7541
7541
  bundlePolicy: "balanced",
7542
7542
  certificates: void 0,
@@ -8078,12 +8078,12 @@ class F {
8078
8078
  };
8079
8079
  }
8080
8080
  }
8081
- function mi(a) {
8081
+ function bi(a) {
8082
8082
  return (e, t) => {
8083
- a === void 0 && (a = fi());
8083
+ a === void 0 && (a = mi());
8084
8084
  const s = {
8085
8085
  iceGatheringTimeout: t?.iceGatheringTimeout !== void 0 ? t?.iceGatheringTimeout : 5e3,
8086
- peerConnectionConfiguration: Object.assign(Object.assign({}, pi()), t?.peerConnectionConfiguration)
8086
+ peerConnectionConfiguration: Object.assign(Object.assign({}, wi()), t?.peerConnectionConfiguration)
8087
8087
  }, r = e.userAgent.getLogger("sip.SessionDescriptionHandler");
8088
8088
  return new F(r, a, s);
8089
8089
  };
@@ -8191,7 +8191,7 @@ class Re {
8191
8191
  try {
8192
8192
  this.transitionState(T.Connecting);
8193
8193
  } catch (t) {
8194
- if (t instanceof ve)
8194
+ if (t instanceof Se)
8195
8195
  return Promise.reject(t);
8196
8196
  throw t;
8197
8197
  }
@@ -8202,7 +8202,7 @@ class Re {
8202
8202
  try {
8203
8203
  this.transitionState(T.Connecting);
8204
8204
  } catch (t) {
8205
- if (t instanceof ve)
8205
+ if (t instanceof Se)
8206
8206
  return Promise.reject(t);
8207
8207
  throw t;
8208
8208
  }
@@ -8232,7 +8232,7 @@ class Re {
8232
8232
  try {
8233
8233
  this.transitionState(T.Disconnecting);
8234
8234
  } catch (t) {
8235
- if (t instanceof ve)
8235
+ if (t instanceof Se)
8236
8236
  return Promise.reject(t);
8237
8237
  throw t;
8238
8238
  }
@@ -8243,7 +8243,7 @@ class Re {
8243
8243
  try {
8244
8244
  this.transitionState(T.Disconnecting);
8245
8245
  } catch (t) {
8246
- if (t instanceof ve)
8246
+ if (t instanceof Se)
8247
8247
  return Promise.reject(t);
8248
8248
  throw t;
8249
8249
  }
@@ -8366,7 +8366,7 @@ class Re {
8366
8366
  */
8367
8367
  transitionLoopDetectedError(e) {
8368
8368
  let t = "A state transition loop has been detected.";
8369
- return t += ` An attempt to transition from ${this._state} to ${e} before the prior transition completed.`, t += " Perhaps you are synchronously calling connect() or disconnect() from a callback or state change handler?", this.logger.error(t), new ve("Loop detected.");
8369
+ return t += ` An attempt to transition from ${this._state} to ${e} before the prior transition completed.`, t += " Perhaps you are synchronously calling connect() or disconnect() from a callback or state change handler?", this.logger.error(t), new Se("Loop detected.");
8370
8370
  }
8371
8371
  /**
8372
8372
  * Transition transport state.
@@ -8501,7 +8501,7 @@ class W {
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 Kt(), 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 Yt(), 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 = M.error;
8507
8507
  break;
@@ -8585,16 +8585,16 @@ class W {
8585
8585
  reconnectionAttempts: 0,
8586
8586
  reconnectionDelay: 4,
8587
8587
  sendInitialProvisionalResponse: !0,
8588
- sessionDescriptionHandlerFactory: mi(),
8588
+ sessionDescriptionHandlerFactory: bi(),
8589
8589
  sessionDescriptionHandlerFactoryOptions: {},
8590
- sipExtension100rel: K.Unsupported,
8591
- sipExtensionReplaces: K.Unsupported,
8590
+ sipExtension100rel: z.Unsupported,
8591
+ sipExtensionReplaces: z.Unsupported,
8592
8592
  sipExtensionExtraSupported: [],
8593
8593
  sipjsId: "",
8594
8594
  transportConstructor: Re,
8595
8595
  transportOptions: {},
8596
8596
  uri: new ee("sip", "anonymous", "anonymous.invalid"),
8597
- userAgentString: "SIP.js/" + kt,
8597
+ userAgentString: "SIP.js/" + Mt,
8598
8598
  viaHost: ""
8599
8599
  };
8600
8600
  }
@@ -8769,7 +8769,7 @@ class W {
8769
8769
  * @internal
8770
8770
  */
8771
8771
  _makeInviter(e, t) {
8772
- return new $e(this, e, t);
8772
+ return new De(this, e, t);
8773
8773
  }
8774
8774
  /**
8775
8775
  * Attempt reconnection up to `maxReconnectionAttempts` times.
@@ -8810,7 +8810,7 @@ class W {
8810
8810
  */
8811
8811
  initCore() {
8812
8812
  let e = [];
8813
- e.push("outbound"), this.options.sipExtension100rel === K.Supported && e.push("100rel"), this.options.sipExtensionReplaces === K.Supported && e.push("replaces"), this.options.sipExtensionExtraSupported && e.push(...this.options.sipExtensionExtraSupported), this.options.hackAllowUnregisteredOptionTags || (e = e.filter((r) => Vt[r])), e = Array.from(new Set(e));
8813
+ e.push("outbound"), this.options.sipExtension100rel === z.Supported && e.push("100rel"), this.options.sipExtensionReplaces === z.Supported && e.push("replaces"), this.options.sipExtensionExtraSupported && e.push(...this.options.sipExtensionExtraSupported), this.options.hackAllowUnregisteredOptionTags || (e = e.filter((r) => Wt[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 W {
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 Wt(this.getLoggerFactory(), o, r, n);
8831
+ return new zt(this.getLoggerFactory(), o, r, n);
8832
8832
  },
8833
8833
  transportAccessor: () => this.transport
8834
8834
  }, s = {
@@ -8843,7 +8843,7 @@ class W {
8843
8843
  onTransportError: (d) => {
8844
8844
  this.logger.error("A transport error has occurred while handling an incoming INVITE request.");
8845
8845
  }
8846
- }, r.trying(), this.options.sipExtensionReplaces !== K.Unsupported) {
8846
+ }, r.trying(), this.options.sipExtensionReplaces !== z.Unsupported) {
8847
8847
  const u = r.message.parseHeader("replaces");
8848
8848
  if (u) {
8849
8849
  const h = u.call_id;
@@ -8887,14 +8887,14 @@ class W {
8887
8887
  },
8888
8888
  onMessage: (r) => {
8889
8889
  if (this.delegate && this.delegate.onMessage) {
8890
- const n = new vt(r);
8890
+ const n = new Tt(r);
8891
8891
  this.delegate.onMessage(n);
8892
8892
  } else
8893
8893
  r.accept();
8894
8894
  },
8895
8895
  onNotify: (r) => {
8896
8896
  if (this.delegate && this.delegate.onNotify) {
8897
- const n = new Je(r);
8897
+ const n = new Ze(r);
8898
8898
  this.delegate.onNotify(n);
8899
8899
  } else
8900
8900
  this.options.allowLegacyNotifications ? r.accept() : r.reject({ statusCode: 481 });
@@ -8909,7 +8909,7 @@ class W {
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 gi(i, s);
8912
+ return new pi(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);
@@ -8921,12 +8921,12 @@ class W {
8921
8921
  this.state !== P.Stopped && (this.delegate && this.delegate.onDisconnect && this.delegate.onDisconnect(e), e && this.options.reconnectionAttempts > 0 && this.attemptReconnection());
8922
8922
  }
8923
8923
  onTransportMessage(e) {
8924
- const t = De.parseMessage(e, this.getLogger("sip.Parser"));
8924
+ const t = Pe.parseMessage(e, this.getLogger("sip.Parser"));
8925
8925
  if (!t) {
8926
8926
  this.logger.warn("Failed to parse incoming message. Dropping.");
8927
8927
  return;
8928
8928
  }
8929
- if (this.state === P.Stopped && t instanceof me) {
8929
+ if (this.state === P.Stopped && t instanceof we) {
8930
8930
  this.logger.warn(`Received ${t.method} request while stopped. Dropping.`);
8931
8931
  return;
8932
8932
  }
@@ -8937,7 +8937,7 @@ class W {
8937
8937
  return this.logger.warn(`Missing mandatory header field : ${r}.`), !1;
8938
8938
  return !0;
8939
8939
  };
8940
- if (t instanceof me) {
8940
+ if (t instanceof we) {
8941
8941
  if (!i()) {
8942
8942
  this.logger.warn("Request missing mandatory header field. Dropping.");
8943
8943
  return;
@@ -8971,7 +8971,7 @@ class W {
8971
8971
  return;
8972
8972
  }
8973
8973
  }
8974
- if (t instanceof me) {
8974
+ if (t instanceof we) {
8975
8975
  this.userAgentCore.receiveIncomingRequestFromTransport(t);
8976
8976
  return;
8977
8977
  }
@@ -9002,10 +9002,10 @@ class W {
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 wi() {
9005
+ function yi() {
9006
9006
  return (a, e) => ({ session: e, held: !1, muted: !1 });
9007
9007
  }
9008
- class Qe {
9008
+ class et {
9009
9009
  /**
9010
9010
  * Constructs a new instance of the `SessionManager` class.
9011
9011
  * @param server - SIP WebSocket Server URL.
@@ -9017,7 +9017,7 @@ class Qe {
9017
9017
  autoStop: !0,
9018
9018
  delegate: {},
9019
9019
  iceStopWaitingOnServerReflexive: !1,
9020
- managedSessionFactory: wi(),
9020
+ managedSessionFactory: yi(),
9021
9021
  maxSimultaneousSessions: 2,
9022
9022
  media: {},
9023
9023
  optionsPingInterval: -1,
@@ -9031,7 +9031,7 @@ class Qe {
9031
9031
  registererRegisterOptions: {},
9032
9032
  sendDTMFUsingSessionDescriptionHandler: !1,
9033
9033
  userAgentOptions: {}
9034
- }, Qe.stripUndefinedProperties(t));
9034
+ }, et.stripUndefinedProperties(t));
9035
9035
  const i = Object.assign({}, t.userAgentOptions);
9036
9036
  if (i.transportConstructor || (i.transportConstructor = Re), i.transportOptions || (i.transportOptions = {
9037
9037
  server: e
@@ -9205,7 +9205,7 @@ class Qe {
9205
9205
  * Attempts will be made to re-register as needed.
9206
9206
  */
9207
9207
  async register(e) {
9208
- return this.logger.log("Registering UserAgent..."), this.shouldBeRegistered = !0, e !== void 0 && (this.registererRegisterOptions = Object.assign({}, e)), this.registerer || (this.registerer = new X(this.userAgent, this.registererOptions), this.registerer.stateChange.addListener((t) => {
9208
+ return this.logger.log("Registering UserAgent..."), this.shouldBeRegistered = !0, e !== void 0 && (this.registererRegisterOptions = Object.assign({}, e)), this.registerer || (this.registerer = new Q(this.userAgent, this.registererOptions), this.registerer.stateChange.addListener((t) => {
9209
9209
  switch (t) {
9210
9210
  case R.Initial:
9211
9211
  break;
@@ -9267,7 +9267,7 @@ class Qe {
9267
9267
  }
9268
9268
  };
9269
9269
  });
9270
- const n = new $e(this.userAgent, r, t);
9270
+ const n = new De(this.userAgent, r, t);
9271
9271
  return this.sendInvite(n, t, i).then(() => n);
9272
9272
  }
9273
9273
  /**
@@ -9403,7 +9403,7 @@ Duration=` + 2e3
9403
9403
  * and execute a blind transfer to the target.
9404
9404
  */
9405
9405
  async transfer(e, t, i) {
9406
- if (this.logger.log(`[${e.id}] Referring session...`), t instanceof we)
9406
+ if (this.logger.log(`[${e.id}] Referring session...`), t instanceof be)
9407
9407
  return e.refer(t, i).then(() => {
9408
9408
  });
9409
9409
  const s = W.makeURI(t);
@@ -9419,7 +9419,7 @@ Duration=` + 2e3
9419
9419
  async message(e, t) {
9420
9420
  this.logger.log("Sending message...");
9421
9421
  const i = W.makeURI(e);
9422
- return i ? new Gt(this.userAgent, i, t).message() : Promise.reject(new Error(`Failed to create a valid URI from "${e}"`));
9422
+ return i ? new Kt(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() {
@@ -9749,7 +9749,7 @@ Duration=` + 2e3
9749
9749
  async terminate(e) {
9750
9750
  switch (this.logger.log(`[${e.id}] Terminating...`), e.state) {
9751
9751
  case w.Initial:
9752
- if (e instanceof $e)
9752
+ if (e instanceof De)
9753
9753
  return e.cancel().then(() => {
9754
9754
  this.logger.log(`[${e.id}] Inviter never sent INVITE (canceled)`);
9755
9755
  });
@@ -9759,7 +9759,7 @@ Duration=` + 2e3
9759
9759
  });
9760
9760
  throw new Error("Unknown session type.");
9761
9761
  case w.Establishing:
9762
- if (e instanceof $e)
9762
+ if (e instanceof De)
9763
9763
  return e.cancel().then(() => {
9764
9764
  this.logger.log(`[${e.id}] Inviter canceled (sent CANCEL)`);
9765
9765
  });
@@ -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 bi {
9785
+ class vi {
9786
9786
  /**
9787
9787
  * Constructs a new instance of the `SimpleUser` class.
9788
9788
  * @param server - SIP WebSocket Server URL.
@@ -9846,7 +9846,7 @@ class bi {
9846
9846
  sendDTMFUsingSessionDescriptionHandler: this.options.sendDTMFUsingSessionDescriptionHandler,
9847
9847
  userAgentOptions: this.options.userAgentOptions
9848
9848
  };
9849
- this.sessionManager = new Qe(e, i), this.logger = this.sessionManager.userAgent.getLogger("sip.SimpleUser");
9849
+ this.sessionManager = new et(e, i), this.logger = this.sessionManager.userAgent.getLogger("sip.SimpleUser");
9850
9850
  }
9851
9851
  /**
9852
9852
  * Instance identifier.
@@ -10051,13 +10051,13 @@ class bi {
10051
10051
  return this.logger.log(`[${this.id}] sending message...`), this.sessionManager.message(e, t);
10052
10052
  }
10053
10053
  }
10054
- const yi = 15e3, vi = 15e3, Ve = (a, e, t) => {
10054
+ const Si = 15e3, Ti = 15e3, Ge = (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
- }, Ge = (a) => {
10057
+ }, We = (a) => {
10058
10058
  const e = new Error(a);
10059
10059
  return e.name = "SipClientLifecycleCancelledError", e.code = "sip_client_replaced", e;
10060
- }, Ze = async (a, e = "call") => {
10060
+ }, Xe = async (a, e = "call") => {
10061
10061
  const t = String(a?.name || a?.code || "").trim(), i = String(a?.message || "").trim(), s = `${t} ${i}`.toLowerCase();
10062
10062
  let r = "";
10063
10063
  try {
@@ -10068,30 +10068,30 @@ const yi = 15e3, vi = 15e3, Ve = (a, e, t) => {
10068
10068
  } catch {
10069
10069
  r = "";
10070
10070
  }
10071
- return r === "denied" || t === "NotAllowedError" || t === "SecurityError" || s.includes("notallowederror") || s.includes("permission denied") || s.includes("permission dismissed") || s.includes("microphone permission") || s.includes("getusermedia() no permission") ? Ve(
10071
+ return r === "denied" || t === "NotAllowedError" || t === "SecurityError" || s.includes("notallowederror") || s.includes("permission denied") || s.includes("permission dismissed") || s.includes("microphone permission") || s.includes("getusermedia() no permission") ? Ge(
10072
10072
  a,
10073
10073
  `浏览器未授予麦克风权限,无法${e === "answer" ? "接听来电" : "发起通话"}。请点击地址栏的麦克风权限并选择“允许”,然后刷新页面重试。`,
10074
10074
  "media_permission_denied"
10075
- ) : t === "NotFoundError" || t === "DevicesNotFoundError" || s.includes("notfounderror") || s.includes("requested device not found") || s.includes("no audio input device") ? Ve(
10075
+ ) : t === "NotFoundError" || t === "DevicesNotFoundError" || s.includes("notfounderror") || s.includes("requested device not found") || s.includes("no audio input device") ? Ge(
10076
10076
  a,
10077
10077
  "未检测到可用的麦克风设备,无法建立语音通话。请连接耳麦或启用系统麦克风后重试。",
10078
10078
  "media_device_not_found"
10079
- ) : t === "NotReadableError" || t === "TrackStartError" || s.includes("notreadableerror") || s.includes("could not start audio source") ? Ve(
10079
+ ) : t === "NotReadableError" || t === "TrackStartError" || s.includes("notreadableerror") || s.includes("could not start audio source") ? Ge(
10080
10080
  a,
10081
10081
  "麦克风当前被系统或其他应用占用,无法建立语音通话。请关闭占用麦克风的程序后重试。",
10082
10082
  "media_device_unavailable"
10083
10083
  ) : a;
10084
- }, Si = async (a = "call") => {
10084
+ }, Ci = async (a = "call") => {
10085
10085
  if (typeof navigator > "u" || !navigator.mediaDevices?.getUserMedia)
10086
10086
  return null;
10087
10087
  let e = null;
10088
10088
  try {
10089
10089
  return e = await navigator.mediaDevices.getUserMedia({ audio: !0, video: !1 }), e;
10090
10090
  } catch (t) {
10091
- throw await Ze(t, a);
10091
+ throw await Xe(t, a);
10092
10092
  }
10093
10093
  };
10094
- class Ti {
10094
+ class Ei {
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 Ti {
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) : yi, this.registrationConfirmTimeoutMs = Number.isFinite(Number(t.registrationConfirmTimeoutMs)) ? Number(t.registrationConfirmTimeoutMs) : vi, 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) : Si, this.registrationConfirmTimeoutMs = Number.isFinite(Number(t.registrationConfirmTimeoutMs)) ? Number(t.registrationConfirmTimeoutMs) : Ti, this.peerConnectionDebug = {
10103
10103
  attached: !1,
10104
10104
  events: [],
10105
10105
  iceCandidates: [],
@@ -10323,7 +10323,7 @@ class Ti {
10323
10323
  registererOptions: {
10324
10324
  expires: 1800
10325
10325
  }
10326
- }, m = new bi(d, h);
10326
+ }, m = new vi(d, h);
10327
10327
  return m.delegate = {
10328
10328
  onServerConnect: () => {
10329
10329
  this.connected = !0, this._resolveConnectionWaiters(), this.onStateChange && this.onStateChange("connected", this.getConnectionSnapshot());
@@ -10402,7 +10402,7 @@ class Ti {
10402
10402
  }
10403
10403
  _assertSimpleUserIsCurrent(e, t = "当前操作") {
10404
10404
  if (!(e && this.simpleUser === e && this.account))
10405
- throw Ge(`SIP 客户端已重置,已取消${t}。`);
10405
+ throw We(`SIP 客户端已重置,已取消${t}。`);
10406
10406
  }
10407
10407
  _resolveRegistrationWaiters() {
10408
10408
  if (!this.registrationWaiters.size)
@@ -10599,9 +10599,9 @@ class Ti {
10599
10599
  async _preflightAudioAccess(e = "call") {
10600
10600
  let t = null;
10601
10601
  try {
10602
- t = await Si(e);
10602
+ t = await Ci(e);
10603
10603
  } catch (i) {
10604
- const s = await Ze(i, e);
10604
+ const s = await Xe(i, e);
10605
10605
  throw this.onError && this.onError(s), this.lastFailureMeta = {
10606
10606
  source: "media-preflight",
10607
10607
  code: s?.code || null,
@@ -10660,7 +10660,7 @@ class Ti {
10660
10660
  }
10661
10661
  }
10662
10662
  async _normalizeMediaAccessError(e, t = "call") {
10663
- return Ze(e, t);
10663
+ return Xe(e, t);
10664
10664
  }
10665
10665
  _createInviteRequestDelegate(e) {
10666
10666
  const t = (s, ...r) => {
@@ -10766,7 +10766,7 @@ class Ti {
10766
10766
  }
10767
10767
  }
10768
10768
  async destroy() {
10769
- this._rejectConnectionWaiters(Ge("SIP 客户端已销毁,已取消连接等待。")), this._rejectRegistrationWaiters(Ge("SIP 客户端已销毁,已取消注册等待。")), this.ensureReadyPromise = null;
10769
+ this._rejectConnectionWaiters(We("SIP 客户端已销毁,已取消连接等待。")), this._rejectRegistrationWaiters(We("SIP 客户端已销毁,已取消注册等待。")), this.ensureReadyPromise = null;
10770
10770
  const e = this.simpleUser;
10771
10771
  if (e)
10772
10772
  try {
@@ -11052,73 +11052,73 @@ class Ti {
11052
11052
  this.audioContext = null;
11053
11053
  }
11054
11054
  }
11055
- const Ci = /^[a-z][a-z0-9+.-]*:\/\//i;
11056
- function Ei(a, e = "") {
11055
+ const xi = /^[a-z][a-z0-9+.-]*:\/\//i;
11056
+ function _i(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
- function Rt(a, e = "https://") {
11063
- return Ci.test(a) ? a : `${e}${a.replace(/^\/+/, "")}`;
11062
+ function At(a, e = "https://") {
11063
+ return xi.test(a) ? a : `${e}${a.replace(/^\/+/, "")}`;
11064
11064
  }
11065
- function et(a = "/") {
11065
+ function tt(a = "/") {
11066
11066
  return a.endsWith("/") ? a : `${a}/`;
11067
11067
  }
11068
- function It(a = "/", e = "") {
11069
- const t = et(a || "/"), i = String(e || "").replace(/^\/+/, "");
11068
+ function $t(a = "/", e = "") {
11069
+ const t = tt(a || "/"), i = String(e || "").replace(/^\/+/, "");
11070
11070
  return i ? `${t}${i}` : t;
11071
11071
  }
11072
- function ye(a = "") {
11072
+ function ve(a = "") {
11073
11073
  return String(a || "").replace(/^\/+/, "");
11074
11074
  }
11075
- function At(a = "") {
11075
+ function Dt(a = "") {
11076
11076
  const e = String(a || ""), t = e.indexOf("?");
11077
11077
  return t < 0 ? {
11078
- pathname: ye(e),
11078
+ pathname: ve(e),
11079
11079
  search: ""
11080
11080
  } : {
11081
- pathname: ye(e.slice(0, t)),
11081
+ pathname: ve(e.slice(0, t)),
11082
11082
  search: e.slice(t)
11083
11083
  };
11084
11084
  }
11085
- function xi(a = "/", e = "/") {
11086
- const t = String(a || "/"), i = et(e || "/");
11087
- return i !== "/" && t.startsWith(i) ? ye(t.slice(i.length)) : ye(t);
11085
+ function Ri(a = "/", e = "/") {
11086
+ const t = String(a || "/"), i = tt(e || "/");
11087
+ return i !== "/" && t.startsWith(i) ? ve(t.slice(i.length)) : ve(t);
11088
11088
  }
11089
11089
  function Ie(a, e = "") {
11090
- const t = Rt(Ei(a, e)), i = new URL(t);
11091
- return i.search = "", i.hash = "", i.pathname = et(i.pathname || "/"), i;
11090
+ const t = At(_i(a, e)), i = new URL(t);
11091
+ return i.search = "", i.hash = "", i.pathname = tt(i.pathname || "/"), i;
11092
11092
  }
11093
- function _i(a, e = "") {
11093
+ function Ii(a, e = "") {
11094
11094
  return Ie(a, e).pathname !== "/";
11095
11095
  }
11096
- function J(a, e, t = "") {
11097
- const i = Ie(a, t), s = At(e);
11098
- return i.pathname = It(i.pathname, s.pathname), i.search = s.search, i.href;
11096
+ function Z(a, e, t = "") {
11097
+ const i = Ie(a, t), s = Dt(e);
11098
+ return i.pathname = $t(i.pathname, s.pathname), i.search = s.search, i.href;
11099
11099
  }
11100
- function We(a, e = "ws", t = "") {
11100
+ function Ke(a, e = "ws", t = "") {
11101
11101
  const i = Ie(a, t);
11102
11102
  i.protocol === "https:" ? i.protocol = "wss:" : i.protocol === "http:" ? i.protocol = "ws:" : i.protocol !== "ws:" && i.protocol !== "wss:" && (i.protocol = "wss:");
11103
- const s = At(e);
11104
- return i.pathname = It(i.pathname, s.pathname), i.search = s.search, i.href;
11103
+ const s = Dt(e);
11104
+ return i.pathname = $t(i.pathname, s.pathname), i.search = s.search, i.href;
11105
11105
  }
11106
- function lt(a, e = "", t = "") {
11106
+ function ht(a, e = "", t = "") {
11107
11107
  if (!String(a || "").trim())
11108
- return ye(e);
11109
- const i = new URL(Rt(String(a).trim())), s = String(t || "").trim() ? Ie(t).pathname : "/", r = xi(i.pathname || "/", s), n = String(i.search || "");
11110
- return `${r}${n}` || ye(e);
11108
+ return ve(e);
11109
+ const i = new URL(At(String(a).trim())), s = String(t || "").trim() ? Ie(t).pathname : "/", r = Ri(i.pathname || "/", s), n = String(i.search || "");
11110
+ return `${r}${n}` || ve(e);
11111
11111
  }
11112
- function ht({
11112
+ function ut({
11113
11113
  apiBaseUrl: a,
11114
11114
  transportBaseUrl: e = "",
11115
11115
  transportUrl: t = "",
11116
11116
  fallbackPath: i = "ws"
11117
11117
  }) {
11118
11118
  const s = String(e || "").trim();
11119
- return s ? We(s, lt(t, i, s)) : _i(a) ? We(a, lt(t, i, a)) : String(t || "").trim() ? String(t).trim() : We(a, i);
11119
+ return s ? Ke(s, ht(t, i, s)) : Ii(a) ? Ke(a, ht(t, i, a)) : String(t || "").trim() ? String(t).trim() : Ke(a, i);
11120
11120
  }
11121
- const Ri = `
11121
+ const Ai = `
11122
11122
  :host { all: initial; }
11123
11123
  .widget {
11124
11124
  position: relative;
@@ -11351,41 +11351,41 @@ const Ri = `
11351
11351
  rejected: "本次来电已拒接,widget 仍保持待机。",
11352
11352
  missed: "本次来电未接听,widget 仍保持待机。",
11353
11353
  failed: "本次呼叫失败,请先看下方日志。"
11354
- }, Ke = {
11354
+ }, ze = {
11355
11355
  idle: "准备通话",
11356
11356
  ringing: "来电中",
11357
11357
  dialing: "拨打中",
11358
11358
  connected: "通话中",
11359
11359
  ended: "已结束",
11360
11360
  failed: "当前暂时无法接通"
11361
- }, Ii = "手机网页首次接入时,请允许麦克风权限;若切到后台后再回来,先确认页面仍保持前台活跃。", Ai = 1500, $i = 5e3, Di = 15e3, ut = 2, Se = 3e4, Pi = 1200, ki = 3e4, Hi = 4e3, Mi = "embedded-call-widget:first-hint-dismissed:", ne = {
11361
+ }, $i = "手机网页首次接入时,请允许麦克风权限;若切到后台后再回来,先确认页面仍保持前台活跃。", Di = 1500, Pi = 5e3, ki = 15e3, gt = 2, Te = 3e4, Hi = 1200, Mi = 3e4, qi = 4e3, Oi = "embedded-call-widget:first-hint-dismissed:", Fi = "embedded-call-widget:missed-incoming-count:", ae = {
11362
11362
  ready: "线路可用",
11363
11363
  preparing: "正在准备",
11364
11364
  working: "通话处理中",
11365
11365
  recovering: "正在恢复",
11366
11366
  offline: "当前离线",
11367
11367
  conflicted: "协议冲突"
11368
- }, Te = Object.freeze({
11368
+ }, pe = Object.freeze({
11369
11369
  standby: "widget_standby",
11370
11370
  outbound: "outbound"
11371
- }), gt = Object.freeze({
11371
+ }), ft = Object.freeze({
11372
11372
  standby: "standby",
11373
11373
  outbound: "outbound"
11374
- }), Xe = Object.freeze({
11374
+ }), Qe = Object.freeze({
11375
11375
  keep: "keep",
11376
11376
  restartStandby: "restart_standby"
11377
- }), qi = /* @__PURE__ */ new Set([
11377
+ }), Ni = /* @__PURE__ */ new Set([
11378
11378
  "session_missing_or_terminal",
11379
11379
  "session_binding_changed",
11380
11380
  "session_anchor_changed",
11381
11381
  "browser_lease_lost",
11382
11382
  "anchor_or_browser_conflict"
11383
11383
  ]);
11384
- function Oi(a, e) {
11384
+ function Ui(a, e) {
11385
11385
  return e ? `${a}
11386
11386
  ${JSON.stringify(e, null, 2)}` : a;
11387
11387
  }
11388
- function Fi(a) {
11388
+ function Li(a) {
11389
11389
  if (typeof window > "u" || !a)
11390
11390
  return !1;
11391
11391
  try {
@@ -11394,14 +11394,48 @@ function Fi(a) {
11394
11394
  return !1;
11395
11395
  }
11396
11396
  }
11397
- function Ni(a, e) {
11397
+ function Bi(a, e) {
11398
11398
  if (!(typeof window > "u" || !a))
11399
11399
  try {
11400
11400
  e && window.localStorage.setItem(a, "1");
11401
11401
  } catch {
11402
11402
  }
11403
11403
  }
11404
- const Ui = `
11404
+ function Ae(a, e = "default") {
11405
+ const t = String(a || "").trim();
11406
+ return t ? t.replace(/[^a-zA-Z0-9:_-]+/g, "_") : e;
11407
+ }
11408
+ function ji(a) {
11409
+ return typeof a == "string" && a.trim() ? a.trim() : a instanceof HTMLElement ? a.id ? `#${a.id}` : a.tagName?.toLowerCase?.() || "mount" : "mount";
11410
+ }
11411
+ function Vi(a, e = {}) {
11412
+ const t = typeof window > "u" ? "page" : `${window.location.origin}${window.location.pathname}`, i = re(e) || "default-business", s = [
11413
+ Ae(t, "page"),
11414
+ Ae(e.siteKey || "default", "default"),
11415
+ Ae(i, "default-business"),
11416
+ Ae(ji(e.mount), "mount")
11417
+ ];
11418
+ return `${a}${s.join(":")}`;
11419
+ }
11420
+ function Gi(a) {
11421
+ if (typeof window > "u" || !a)
11422
+ return 0;
11423
+ try {
11424
+ const e = Number(window.localStorage.getItem(a));
11425
+ return !Number.isFinite(e) || e <= 0 ? 0 : Math.floor(e);
11426
+ } catch {
11427
+ return 0;
11428
+ }
11429
+ }
11430
+ function pt(a, e) {
11431
+ if (!(typeof window > "u" || !a))
11432
+ try {
11433
+ const t = Number.isFinite(e) ? Math.max(0, Math.floor(e)) : 0;
11434
+ t > 0 ? window.localStorage.setItem(a, String(t)) : window.localStorage.removeItem(a);
11435
+ } catch {
11436
+ }
11437
+ }
11438
+ const Wi = `
11405
11439
  <svg viewBox="0 0 24 24" aria-hidden="true" focusable="false">
11406
11440
  <path d="M6.84 4.28c.3-.72 1.15-1.1 1.89-.85l2.24.75c.77.26 1.18 1.09.91 1.85l-.64 1.82a1.6 1.6 0 0 1-1.9.99l-.63-.16a12.8 12.8 0 0 0 6.62 6.62l-.16-.63a1.6 1.6 0 0 1 .99-1.9l1.82-.64c.76-.27 1.59.14 1.85.91l.75 2.24c.25.74-.13 1.59-.85 1.89l-1.74.72c-.72.3-1.54.26-2.23-.1A17.94 17.94 0 0 1 4.48 7.23c-.36-.69-.4-1.51-.1-2.23z" fill="currentColor"/>
11407
11441
  </svg>
@@ -11409,11 +11443,11 @@ const Ui = `
11409
11443
  function $(a, e, t) {
11410
11444
  t != null && (typeof t == "string" && t.trim() === "" || (a[e] = t));
11411
11445
  }
11412
- function Q(a) {
11446
+ function K(a) {
11413
11447
  return typeof a == "string" ? a.trim() : "";
11414
11448
  }
11415
- function ft(a, e, t) {
11416
- const i = Q(a?.session_mode);
11449
+ function mt(a, e, t) {
11450
+ const i = K(a?.session_mode);
11417
11451
  if (!i)
11418
11452
  throw N(`${t} 缺少必填字段 session_mode。`, {
11419
11453
  source: t,
@@ -11421,7 +11455,7 @@ function ft(a, e, t) {
11421
11455
  expected_session_mode: e,
11422
11456
  received_session_mode: null
11423
11457
  });
11424
- if (!Object.values(Te).includes(i))
11458
+ if (!Object.values(pe).includes(i))
11425
11459
  throw N(`${t} 返回了未登记的 session_mode。`, {
11426
11460
  source: t,
11427
11461
  session_id: a?.session_id || null,
@@ -11437,8 +11471,8 @@ function ft(a, e, t) {
11437
11471
  });
11438
11472
  return i;
11439
11473
  }
11440
- function Li(a, e = {}) {
11441
- const t = Q(e?.session_action).toLowerCase(), i = Q(e?.session_action_reason) || null, s = Q(e?.session_action_detail) || null, r = Q(e?.resolved_session_id) || null, n = Q(e?.resolved_widget_anchor_number) || null, o = Q(e?.resolved_browser_sip_username) || null, d = {
11474
+ function Ki(a, e = {}) {
11475
+ const t = K(e?.session_action).toLowerCase(), i = K(e?.session_action_reason) || null, s = K(e?.session_action_detail) || null, r = K(e?.resolved_session_id) || null, n = K(e?.resolved_widget_anchor_number) || null, o = K(e?.resolved_browser_sip_username) || null, d = {
11442
11476
  source: a,
11443
11477
  session_action: t || null,
11444
11478
  session_action_reason: i,
@@ -11449,9 +11483,9 @@ function Li(a, e = {}) {
11449
11483
  };
11450
11484
  if (!t)
11451
11485
  throw N("服务端缺少必填字段 session_action。", d);
11452
- if (!Object.values(Xe).includes(t))
11486
+ if (!Object.values(Qe).includes(t))
11453
11487
  throw N("服务端返回了未登记的 session_action。", d);
11454
- if (t === Xe.keep) {
11488
+ if (t === Qe.keep) {
11455
11489
  if (i || s)
11456
11490
  throw N("session_action=keep 时不得携带 session_action_reason 或 session_action_detail。", d);
11457
11491
  return {
@@ -11465,7 +11499,7 @@ function Li(a, e = {}) {
11465
11499
  }
11466
11500
  if (!i)
11467
11501
  throw N("session_action=restart_standby 时必须携带 session_action_reason。", d);
11468
- if (!qi.has(i))
11502
+ if (!Ni.has(i))
11469
11503
  throw N("服务端返回了未登记的 session_action_reason。", d);
11470
11504
  if (!s)
11471
11505
  throw N("session_action=restart_standby 时必须携带非空的 session_action_detail。", d);
@@ -11489,53 +11523,53 @@ function Li(a, e = {}) {
11489
11523
  resolvedBrowserSipUsername: o
11490
11524
  };
11491
11525
  }
11492
- function Bi(a) {
11526
+ function zi(a) {
11493
11527
  return a === "outbound" ? "outbound" : "terminal";
11494
11528
  }
11495
- function ji(a) {
11529
+ function Yi(a) {
11496
11530
  return typeof a == "function";
11497
11531
  }
11498
- function Vi() {
11532
+ function Ji() {
11499
11533
  return typeof window > "u" ? !1 : new URLSearchParams(window.location.search).get("embeddedCallWidgetE2E") === "1";
11500
11534
  }
11501
- function Gi() {
11535
+ function Zi() {
11502
11536
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `widget-${Date.now()}-${Math.random().toString(16).slice(2, 10)}`;
11503
11537
  }
11504
- function ze(a) {
11538
+ function Ye(a) {
11505
11539
  const e = String(a?.message || a || "");
11506
11540
  return /Failed to fetch|NetworkError|Load failed|network/i.test(e);
11507
11541
  }
11508
- function ae(a = {}, e = null) {
11542
+ function re(a = {}, e = null) {
11509
11543
  const t = a?.advanced && typeof a.advanced == "object" ? a.advanced : {}, i = String(t.visitorBusinessKey ?? "").trim();
11510
11544
  if (i)
11511
11545
  return i;
11512
11546
  const s = String(a?.businessKey ?? "").trim();
11513
11547
  return s || "";
11514
11548
  }
11515
- function Wi(a) {
11549
+ function Xi(a) {
11516
11550
  const e = new Error(a);
11517
11551
  return e.name = "EmbeddedCallWidgetLifecycleCancelledError", e.code = "widget_runtime_run_stale", e;
11518
11552
  }
11519
- function pt(a) {
11553
+ function wt(a) {
11520
11554
  return a?.code === "sip_client_replaced" || a?.code === "widget_runtime_run_stale";
11521
11555
  }
11522
11556
  function N(a, e = {}) {
11523
11557
  const t = new Error(a);
11524
11558
  return t.name = "EmbeddedCallWidgetProtocolViolationError", t.code = "widget_protocol_violation", t.detail = e, t;
11525
11559
  }
11526
- function Ae(a) {
11560
+ function $e(a) {
11527
11561
  return a?.code === "widget_protocol_violation";
11528
11562
  }
11529
- class Ki {
11563
+ class Qi {
11530
11564
  constructor({ mount: e, shadowRoot: t, options: i }) {
11531
- this.mountNode = e, this.shadowRoot = t, this.options = i, this.mode = Bi(i.mode), this.legacyOutboundOnly = this.mode === "outbound", this.apiBaseUrl = Ie(i.apiBaseUrl || window.location.origin).href, this.client = null, this.issuedSession = null, this.bootstrap = null, this.turnIceServers = [], this.state = "idle", this.stateDetail = se.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 = Vi(), this.terminalFailureOverride = "", this.presenceId = Gi(), 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.beforeUnloadHandler = null, this.pageHideHandler = null, this.unloadCleanupStarted = !1, this.panelAutoCloseTimer = null, this.transientPanelState = null, this.transientPanelDetail = "", this.missedIncomingCount = 0, this.debugRequested = i.debug === !0, this.debugPanelEnabled = !1, this.hasAccessToken = !!String(i.accessToken || "").trim(), this.triggerHintStorageKey = `${Mi}${String(i.siteKey || "default").trim() || "default"}`, this.triggerHintDismissed = Fi(this.triggerHintStorageKey), this.refs = {};
11565
+ this.mountNode = e, this.shadowRoot = t, this.options = i, this.mode = zi(i.mode), this.legacyOutboundOnly = this.mode === "outbound", this.apiBaseUrl = Ie(i.apiBaseUrl || window.location.origin).href, this.client = null, this.issuedSession = null, this.bootstrap = null, this.turnIceServers = [], this.state = "idle", this.stateDetail = se.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 = Ji(), this.terminalFailureOverride = "", this.presenceId = Zi(), 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.beforeUnloadHandler = null, this.pageHideHandler = null, this.unloadCleanupStarted = !1, this.panelAutoCloseTimer = null, this.transientPanelState = null, this.transientPanelDetail = "", this.missedIncomingCountStorageKey = Vi(Fi, i), this.missedIncomingCount = Gi(this.missedIncomingCountStorageKey), this.debugRequested = i.debug === !0, this.debugPanelEnabled = !1, this.hasAccessToken = !!String(i.accessToken || "").trim(), this.triggerHintStorageKey = `${Oi}${String(i.siteKey || "default").trim() || "default"}`, this.triggerHintDismissed = Li(this.triggerHintStorageKey), this.refs = {};
11532
11566
  }
11533
11567
  async mount() {
11534
11568
  this.isMobileViewport = typeof window < "u" && window.matchMedia("(max-width: 480px)").matches, this.shadowRoot.innerHTML = `
11535
- <style>${Ri}</style>
11569
+ <style>${Ai}</style>
11536
11570
  <section class="widget">
11537
11571
  <button class="trigger" data-role="trigger" type="button" aria-label="${this.options.text || "联系管理员"}">
11538
- ${Ui}
11572
+ ${Wi}
11539
11573
  <span class="trigger-badge" data-role="trigger-badge" hidden></span>
11540
11574
  <span class="sr-only">${this.options.text || "联系管理员"}</span>
11541
11575
  </button>
@@ -11545,7 +11579,7 @@ class Ki {
11545
11579
  <div class="panel-hero">
11546
11580
  <p class="panel-eyebrow" data-role="panel-eyebrow">网页通话</p>
11547
11581
  <h2 class="panel-title" data-role="panel-title">${this.options.text || "联系管理员"}</h2>
11548
- <div class="status" data-role="status">${Ke.idle}</div>
11582
+ <div class="status" data-role="status">${ze.idle}</div>
11549
11583
  <div class="panel-detail" data-role="panel-detail"></div>
11550
11584
  </div>
11551
11585
  <div class="actions" data-role="actions">
@@ -11556,7 +11590,7 @@ class Ki {
11556
11590
  </div>
11557
11591
  <section class="debug-panel" data-role="debug-panel" hidden>
11558
11592
  <div class="availability availability--preparing" data-role="availability">正在准备</div>
11559
- <div class="meta" data-role="meta">站点键:${this.options.siteKey || "等待服务端解析"};访客主动呼叫默认规则:${ae(this.options) || "等待服务端解析"}</div>
11593
+ <div class="meta" data-role="meta">站点键:${this.options.siteKey || "等待服务端解析"};访客主动呼叫默认规则:${re(this.options) || "等待服务端解析"}</div>
11560
11594
  <div class="hint" data-role="hint"></div>
11561
11595
  <div class="logs" data-role="logs"></div>
11562
11596
  </section>
@@ -11610,11 +11644,11 @@ class Ki {
11610
11644
  }
11611
11645
  assertLifecycleRunCurrent(e) {
11612
11646
  if (e !== this.lifecycleRunId)
11613
- throw Wi("网页电话已切换到新的连接流程,旧流程不再继续。");
11647
+ throw Xi("网页电话已切换到新的连接流程,旧流程不再继续。");
11614
11648
  }
11615
11649
  emitHostCallback(e, t) {
11616
11650
  const i = this.options?.[e];
11617
- if (ji(i))
11651
+ if (Yi(i))
11618
11652
  try {
11619
11653
  i(t);
11620
11654
  } catch (s) {
@@ -11635,7 +11669,7 @@ class Ki {
11635
11669
  sessionMode: this.issuedSession?.session_mode || null,
11636
11670
  sessionId: this.issuedSession?.session_id || null,
11637
11671
  siteKey: this.options.siteKey || this.bootstrap?.default_site_key || null,
11638
- businessKey: this.issuedSession?.resolved_business_key || ae(this.options, this.bootstrap) || null,
11672
+ businessKey: this.issuedSession?.resolved_business_key || re(this.options, this.bootstrap) || null,
11639
11673
  standbyMode: this.issuedSession?.standby_mode || null,
11640
11674
  standbyState: this.issuedSession?.standby_state || this.options.standbyState || null,
11641
11675
  widgetSipNumber: this.issuedSession?.widget_anchor_number || null,
@@ -11664,7 +11698,7 @@ class Ki {
11664
11698
  return this.transientPanelState;
11665
11699
  if (this.state === "incoming")
11666
11700
  return "ringing";
11667
- const e = Q(this.issuedSession?.session_mode), t = this.pendingLifecycleMode === "outbound", i = this.state === "registering" && e === "outbound";
11701
+ const e = K(this.issuedSession?.session_mode), t = this.pendingLifecycleMode === "outbound", i = this.state === "registering" && e === "outbound";
11668
11702
  return this.state === "calling" || i || t && ["requesting", "registering"].includes(this.state) ? "dialing" : this.state === "connected" ? "connected" : "idle";
11669
11703
  }
11670
11704
  isPanelVisible() {
@@ -11676,7 +11710,7 @@ class Ki {
11676
11710
  clearTransientPanelState() {
11677
11711
  this.clearPanelAutoClose(), this.transientPanelState = null, this.transientPanelDetail = "", this.render();
11678
11712
  }
11679
- setTransientPanelState(e, t = "", i = Ai) {
11713
+ setTransientPanelState(e, t = "", i = Di) {
11680
11714
  this.clearPanelAutoClose(), this.transientPanelState = e, this.transientPanelDetail = t, this.render(), i > 0 && (this.panelAutoCloseTimer = window.setTimeout(() => {
11681
11715
  this.panelAutoCloseTimer = null, this.transientPanelState = null, this.transientPanelDetail = "", this.render();
11682
11716
  }, i));
@@ -11685,16 +11719,16 @@ class Ki {
11685
11719
  !this.debugRequested || !this.hasAccessToken || !t || this.debugPanelEnabled || (this.debugPanelEnabled = !0, this.appendLog("调试模式门禁已成立,开始展示调试面板。", { source: e }), this.render());
11686
11720
  }
11687
11721
  dismissTriggerHint() {
11688
- this.triggerHintDismissed || (this.triggerHintDismissed = !0, Ni(this.triggerHintStorageKey, !0));
11722
+ this.triggerHintDismissed || (this.triggerHintDismissed = !0, Bi(this.triggerHintStorageKey, !0));
11689
11723
  }
11690
11724
  clearMissedIncomingCount() {
11691
- this.missedIncomingCount && (this.missedIncomingCount = 0);
11725
+ this.missedIncomingCount && (this.missedIncomingCount = 0, pt(this.missedIncomingCountStorageKey, 0));
11692
11726
  }
11693
11727
  incrementMissedIncomingCount() {
11694
- this.missedIncomingCount += 1;
11728
+ this.missedIncomingCount += 1, pt(this.missedIncomingCountStorageKey, this.missedIncomingCount);
11695
11729
  }
11696
11730
  async handleTriggerClick() {
11697
- if (this.dismissTriggerHint(), this.clearMissedIncomingCount(), this.clearTransientPanelState(), this.open(), ["requesting", "registering", "calling", "connected", "incoming"].includes(this.state)) {
11731
+ if (this.dismissTriggerHint(), this.clearTransientPanelState(), this.open(), ["requesting", "registering", "calling", "connected", "incoming"].includes(this.state)) {
11698
11732
  this.render();
11699
11733
  return;
11700
11734
  }
@@ -11717,13 +11751,13 @@ class Ki {
11717
11751
  e2eSimulated: !0
11718
11752
  }, this.clearPanelAutoClose(), this.transientPanelState = null, this.transientPanelDetail = "", this.setAvailabilityState("working", "已有新来电,请直接接听或挂断。"), this.setState("incoming"), this.emitHostCallback("onIncomingCall", this.pendingIncomingCall), this.getSnapshot();
11719
11753
  },
11720
- simulateOutboundDialing: (t = {}) => (this.dismissTriggerHint(), this.clearMissedIncomingCount(), this.clearPanelAutoClose(), this.transientPanelState = null, this.transientPanelDetail = "", this.pendingIncomingCall = t && typeof t == "object" ? { ...t, direction: "outbound", e2eSimulated: !0 } : null, this.setAvailabilityState("working", "测试桥已模拟发起外呼。"), this.setState("calling", t?.message || "测试桥已模拟拨打管理员。"), this.getSnapshot()),
11754
+ simulateOutboundDialing: (t = {}) => (this.dismissTriggerHint(), this.clearPanelAutoClose(), this.transientPanelState = null, this.transientPanelDetail = "", this.pendingIncomingCall = t && typeof t == "object" ? { ...t, direction: "outbound", e2eSimulated: !0 } : null, this.setAvailabilityState("working", "测试桥已模拟发起外呼。"), this.setState("calling", t?.message || "测试桥已模拟拨打管理员。"), this.getSnapshot()),
11721
11755
  simulateOutboundConnected: (t = {}) => (this.clearPanelAutoClose(), this.transientPanelState = null, this.transientPanelDetail = "", t && typeof t == "object" && (this.pendingIncomingCall = {
11722
11756
  ...this.pendingIncomingCall || {},
11723
11757
  ...t,
11724
11758
  direction: "outbound",
11725
11759
  e2eSimulated: !0
11726
- }), this.setAvailabilityState("working", "测试桥已模拟外呼接通。"), this.setState("connected", t?.message || "测试桥已模拟通话接通。"), this.getSnapshot()),
11760
+ }), this.clearMissedIncomingCount(), this.setAvailabilityState("working", "测试桥已模拟外呼接通。"), this.setState("connected", t?.message || "测试桥已模拟通话接通。"), this.getSnapshot()),
11727
11761
  answerIncomingCall: async () => (await this.answerIncomingCall(), this.getSnapshot()),
11728
11762
  declineIncomingCall: async () => (await this.declineIncomingCall(), this.getSnapshot()),
11729
11763
  hangupCall: async () => (await this.hangupCall(), this.getSnapshot()),
@@ -11757,7 +11791,7 @@ class Ki {
11757
11791
  const t = this.issuedSession?.session_mode === "widget_standby" && (this.issuedSession?.browser_sip_username || this.issuedSession?.sip_username) || null;
11758
11792
  !this.legacyOutboundOnly && this.issuedSession?.session_mode === "widget_standby" && (this.appendLog("访客主动呼叫前,先释放当前待机会话并切换到呼叫链路。", {
11759
11793
  widget_anchor_number: this.issuedSession?.widget_anchor_number || null,
11760
- resolved_business_key: this.issuedSession?.resolved_business_key || ae(this.options) || null
11794
+ resolved_business_key: this.issuedSession?.resolved_business_key || re(this.options) || null
11761
11795
  }), await this.disconnectAndCleanup("switch-to-outbound-call", {
11762
11796
  preserveLifecycleRun: !0,
11763
11797
  suppressStateReset: !0,
@@ -11771,18 +11805,18 @@ class Ki {
11771
11805
  route_note: i.routeNote || null
11772
11806
  });
11773
11807
  } catch (t) {
11774
- if (this.pendingLifecycleMode = null, pt(t)) {
11808
+ if (this.pendingLifecycleMode = null, wt(t)) {
11775
11809
  this.appendLog("已忽略过期的网页电话呼叫流程", {
11776
11810
  message: t?.message || String(t)
11777
11811
  });
11778
11812
  return;
11779
11813
  }
11780
- if (Ae(t)) {
11814
+ if ($e(t)) {
11781
11815
  await this.handleProtocolViolation(t);
11782
11816
  return;
11783
11817
  }
11784
11818
  const i = t?.message || String(t);
11785
- if (this.terminalFailureOverride = i, this.setState("failed", i), this.setTransientPanelState("failed", "当前暂时无法接通,请稍后再试。"), ze(t) || this.networkOnline === !1 ? this.setAvailabilityState("offline", this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。") : this.setAvailabilityState("recovering", "呼叫失败,正在准备恢复网页电话待机。"), this.appendLog("连接并呼叫失败", { message: i }), await this.releaseIssuedSession("failed", "connect-and-call-failed"), !this.legacyOutboundOnly) {
11819
+ if (this.terminalFailureOverride = i, this.setState("failed", i), this.setTransientPanelState("failed", "当前暂时无法接通,请稍后再试。"), Ye(t) || this.networkOnline === !1 ? this.setAvailabilityState("offline", this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。") : this.setAvailabilityState("recovering", "呼叫失败,正在准备恢复网页电话待机。"), this.appendLog("连接并呼叫失败", { message: i }), await this.releaseIssuedSession("failed", "connect-and-call-failed"), !this.legacyOutboundOnly) {
11786
11820
  this.appendLog("呼叫失败后,网页电话将恢复待机。", { message: i }), await this.startStandby({ force: !0 });
11787
11821
  return;
11788
11822
  }
@@ -11801,24 +11835,24 @@ class Ki {
11801
11835
  const s = await this.fetchStandbySession();
11802
11836
  this.assertLifecycleRunCurrent(i), await this.ensureClient(s), this.assertLifecycleRunCurrent(i), this.setState("registering", "待机会话已拿到,正在连接并执行 REGISTER。"), await this.client.ensureReady(), this.assertLifecycleRunCurrent(i), this.pendingLifecycleMode = null, this.setState("standby"), this.setAvailabilityState("ready", "当前可被呼叫,也可由访客主动发起呼叫。"), this.appendLog("widget 已进入待机", {
11803
11837
  session_id: this.issuedSession?.session_id || null,
11804
- route_business_key: this.issuedSession?.resolved_business_key || ae(this.options) || null,
11838
+ route_business_key: this.issuedSession?.resolved_business_key || re(this.options) || null,
11805
11839
  standby_mode: this.issuedSession?.standby_mode || null,
11806
11840
  widget_anchor_number: this.issuedSession?.widget_anchor_number || null,
11807
11841
  browser_sip_username: this.issuedSession?.browser_sip_username || this.issuedSession?.sip_username || null
11808
11842
  }), this.emitHostCallback("onStandbyReady", this.getSnapshot());
11809
11843
  } catch (s) {
11810
- if (pt(s)) {
11844
+ if (wt(s)) {
11811
11845
  this.appendLog("已忽略过期的网页电话待机流程", {
11812
11846
  message: s?.message || String(s)
11813
11847
  });
11814
11848
  return;
11815
11849
  }
11816
- if (this.pendingLifecycleMode = null, Ae(s)) {
11850
+ if (this.pendingLifecycleMode = null, $e(s)) {
11817
11851
  await this.handleProtocolViolation(s);
11818
11852
  return;
11819
11853
  }
11820
11854
  const r = s?.message || String(s);
11821
- this.terminalFailureOverride = r, this.setState("failed", r), ze(s) || this.networkOnline === !1 ? this.setAvailabilityState("offline", this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。") : this.setAvailabilityState("recovering", "当前未能完成待机注册,系统会继续自动恢复。"), this.appendLog("进入待机失败", { message: r }), await this.releaseIssuedSession("failed", "standby-start-failed"), this.setState("failed", r), !this.legacyOutboundOnly && this.networkOnline !== !1 && this.scheduleAutoStandbyRecovery("standby-start-failed");
11855
+ this.terminalFailureOverride = r, this.setState("failed", r), Ye(s) || this.networkOnline === !1 ? this.setAvailabilityState("offline", this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。") : this.setAvailabilityState("recovering", "当前未能完成待机注册,系统会继续自动恢复。"), this.appendLog("进入待机失败", { message: r }), await this.releaseIssuedSession("failed", "standby-start-failed"), this.setState("failed", r), !this.legacyOutboundOnly && this.networkOnline !== !1 && this.scheduleAutoStandbyRecovery("standby-start-failed");
11822
11856
  }
11823
11857
  }
11824
11858
  async ensureClient(e) {
@@ -11829,7 +11863,7 @@ class Ki {
11829
11863
  webrtc_url: e.transport,
11830
11864
  ice_servers: this.turnIceServers
11831
11865
  };
11832
- this.client?.matchesAccount(t) || (this.client && await this.client.destroy(), this.client = new Ti(t, {
11866
+ this.client?.matchesAccount(t) || (this.client && await this.client.destroy(), this.client = new Ei(t, {
11833
11867
  remoteAudioElement: this.refs.audio,
11834
11868
  onStateChange: (i, s) => {
11835
11869
  this.handleClientState(i, s);
@@ -11851,9 +11885,10 @@ class Ki {
11851
11885
  return;
11852
11886
  }
11853
11887
  if (e === "answered") {
11888
+ const i = K(this.issuedSession?.session_mode) === pe.outbound;
11854
11889
  this.pendingLifecycleMode = null, this.terminalFailureOverride = "";
11855
- const i = this.pendingIncomingCall || t || null;
11856
- this.clearPanelAutoClose(), this.transientPanelState = null, this.transientPanelDetail = "", this.setState("connected"), this.setAvailabilityState("working", "当前通话已接通。"), this.emitHostCallback("onCallAnswered", i);
11890
+ const s = this.pendingIncomingCall || t || null;
11891
+ this.clearPanelAutoClose(), this.transientPanelState = null, this.transientPanelDetail = "", i && this.clearMissedIncomingCount(), this.setState("connected"), this.setAvailabilityState("working", "当前通话已接通。"), this.emitHostCallback("onCallAnswered", s);
11857
11892
  return;
11858
11893
  }
11859
11894
  if (e === "terminated") {
@@ -11897,10 +11932,10 @@ class Ki {
11897
11932
  const t = this.transportDisconnectContext, i = !!(e && t?.reported && this.sameTransportDisconnectContext(t));
11898
11933
  this.stopTransportDisconnectGrace(), i && (await this.reportIssuedSessionEvent("transport-restored", {
11899
11934
  disconnectDurationMs: Date.now() - (t.startedAt || Date.now()),
11900
- graceMs: Se
11935
+ graceMs: Te
11901
11936
  }, this.state), this.appendLog("网页通话信令已恢复", {
11902
11937
  disconnectDurationMs: Date.now() - (t.startedAt || Date.now()),
11903
- graceMs: Se
11938
+ graceMs: Te
11904
11939
  }));
11905
11940
  }
11906
11941
  scheduleTransportDisconnectGrace(e) {
@@ -11916,12 +11951,12 @@ class Ki {
11916
11951
  this.transportDisconnectContext = t, this.transportDisconnectTimer = window.setTimeout(() => {
11917
11952
  this.transportDisconnectTimer = null, this.sameTransportDisconnectContext(t) && (t.reported = !0, this.reportIssuedSessionEvent("transport-disconnected", {
11918
11953
  state: e,
11919
- graceMs: Se
11954
+ graceMs: Te
11920
11955
  }, this.state), this.appendLog("网页通话信令断开超过宽限窗口", {
11921
- graceMs: Se,
11956
+ graceMs: Te,
11922
11957
  state: e
11923
11958
  }));
11924
- }, Se);
11959
+ }, Te);
11925
11960
  }
11926
11961
  async finalizeAfterTermination(e) {
11927
11962
  if (!this.finalizing) {
@@ -12004,7 +12039,7 @@ class Ki {
12004
12039
  async loadBootstrap() {
12005
12040
  if (this.bootstrap)
12006
12041
  return this.bootstrap;
12007
- const e = await fetch(J(this.apiBaseUrl, "api/sip/embedded-call-demo-bootstrap"), {
12042
+ const e = await fetch(Z(this.apiBaseUrl, "api/sip/embedded-call-demo-bootstrap"), {
12008
12043
  credentials: "include",
12009
12044
  cache: "no-store"
12010
12045
  });
@@ -12013,7 +12048,7 @@ class Ki {
12013
12048
  return this.bootstrap = await e.json(), this.bootstrap;
12014
12049
  }
12015
12050
  async fetchTurnIceServers() {
12016
- const e = await fetch(J(this.apiBaseUrl, "api/sip/webrtc-turn-credentials"), {
12051
+ const e = await fetch(Z(this.apiBaseUrl, "api/sip/webrtc-turn-credentials"), {
12017
12052
  credentials: "include",
12018
12053
  cache: "no-store"
12019
12054
  });
@@ -12025,11 +12060,11 @@ class Ki {
12025
12060
  async fetchIssuedSession(e = {}) {
12026
12061
  const {
12027
12062
  preferredBrowserSipUsername: t = null
12028
- } = e, i = ae(this.options), s = {
12063
+ } = e, i = re(this.options), s = {
12029
12064
  page_url: window.location.href
12030
12065
  };
12031
12066
  $(s, "site_key", this.options.siteKey), $(s, "standby_state", this.options.standbyState), $(s, "selected_primary_account", this.options.selectedPrimaryAccount), $(s, "selected_middle_layer_account", this.options.selectedMiddleLayerAccount), $(s, "preferred_browser_sip_username", t), $(s, "display_name", this.options.displayName), $(s, "access_token", this.options.accessToken), i && (s.business_key = i);
12032
- const r = await fetch(J(this.apiBaseUrl, "api/sip/issue-call-session"), {
12067
+ const r = await fetch(Z(this.apiBaseUrl, "api/sip/issue-call-session"), {
12033
12068
  method: "POST",
12034
12069
  credentials: "include",
12035
12070
  cache: "no-store",
@@ -12040,7 +12075,7 @@ class Ki {
12040
12075
  const d = await r.json().catch(() => ({}));
12041
12076
  throw new Error(d?.detail || `会话签发失败:${r.status}`);
12042
12077
  }
12043
- const n = await r.json(), o = ft(n, Te.outbound, "issue-call-session");
12078
+ const n = await r.json(), o = mt(n, pe.outbound, "issue-call-session");
12044
12079
  return this.markDebugPanelEnabled("issue-call-session", n?.debug_access_granted === !0), this.issuedSession = n, this.reportIssuedSessionEvent("issued-session-fetched", {
12045
12080
  sessionId: n.session_id,
12046
12081
  targetExtension: n.target_extension,
@@ -12060,7 +12095,7 @@ class Ki {
12060
12095
  sipUsername: n.sip_username,
12061
12096
  sipDomain: n.sip_domain,
12062
12097
  password: n.sip_password,
12063
- transport: ht({
12098
+ transport: ut({
12064
12099
  apiBaseUrl: this.apiBaseUrl,
12065
12100
  transportBaseUrl: this.options.transportBaseUrl || "",
12066
12101
  transportUrl: n.ws_server
@@ -12070,11 +12105,11 @@ class Ki {
12070
12105
  };
12071
12106
  }
12072
12107
  async fetchStandbySession() {
12073
- const e = ae(this.options) || null, t = {
12108
+ const e = re(this.options) || null, t = {
12074
12109
  page_url: window.location.href
12075
12110
  };
12076
12111
  $(t, "site_key", this.options.siteKey), $(t, "standby_state", this.options.standbyState), $(t, "selected_primary_account", this.options.selectedPrimaryAccount), $(t, "selected_middle_layer_account", this.options.selectedMiddleLayerAccount), $(t, "display_name", this.options.displayName), $(t, "access_token", this.options.accessToken), e && (t.business_key = e);
12077
- const i = await fetch(J(this.apiBaseUrl, "api/sip/issue-widget-standby-session"), {
12112
+ const i = await fetch(Z(this.apiBaseUrl, "api/sip/issue-widget-standby-session"), {
12078
12113
  method: "POST",
12079
12114
  credentials: "include",
12080
12115
  cache: "no-store",
@@ -12085,7 +12120,7 @@ class Ki {
12085
12120
  const n = await i.json().catch(() => ({}));
12086
12121
  throw new Error(n?.detail || `待机会话签发失败:${i.status}`);
12087
12122
  }
12088
- const s = await i.json(), r = ft(s, Te.standby, "issue-widget-standby-session");
12123
+ const s = await i.json(), r = mt(s, pe.standby, "issue-widget-standby-session");
12089
12124
  return this.markDebugPanelEnabled("issue-widget-standby-session", s?.debug_access_granted === !0), this.issuedSession = s, this.reportIssuedSessionEvent("standby-session-fetched", {
12090
12125
  sessionId: s.session_id,
12091
12126
  resolvedBusinessKey: s.resolved_business_key || null,
@@ -12103,7 +12138,7 @@ class Ki {
12103
12138
  sipUsername: s.sip_username,
12104
12139
  sipDomain: s.sip_domain,
12105
12140
  password: s.sip_password,
12106
- transport: ht({
12141
+ transport: ut({
12107
12142
  apiBaseUrl: this.apiBaseUrl,
12108
12143
  transportBaseUrl: this.options.transportBaseUrl || "",
12109
12144
  transportUrl: s.ws_server
@@ -12116,7 +12151,7 @@ class Ki {
12116
12151
  if (!this.issuedSession?.session_id)
12117
12152
  return;
12118
12153
  const i = this.issuedSession.session_id;
12119
- this.markRecentlyReleasedSession(i, t), this.issuedSession = null, await fetch(J(this.apiBaseUrl, "api/sip/release-call-session"), {
12154
+ this.markRecentlyReleasedSession(i, t), this.issuedSession = null, await fetch(Z(this.apiBaseUrl, "api/sip/release-call-session"), {
12120
12155
  method: "POST",
12121
12156
  credentials: "include",
12122
12157
  cache: "no-store",
@@ -12131,7 +12166,7 @@ class Ki {
12131
12166
  });
12132
12167
  }
12133
12168
  postLifecycleBeacon(e, t) {
12134
- const i = JSON.stringify(t), s = J(this.apiBaseUrl, e);
12169
+ const i = JSON.stringify(t), s = Z(this.apiBaseUrl, e);
12135
12170
  if (typeof navigator < "u" && typeof navigator.sendBeacon == "function")
12136
12171
  try {
12137
12172
  const r = new Blob([i], { type: "application/json" });
@@ -12184,9 +12219,9 @@ class Ki {
12184
12219
  };
12185
12220
  }
12186
12221
  setAvailabilityState(e, t = "") {
12187
- this.availabilityState = e, this.availabilityDetail = t || this.availabilityDetail, this.refs.availability && (this.refs.availability.textContent = t ? `${ne[e] || ne.recovering} · ${t}` : ne[e] || ne.recovering, this.refs.availability.className = `availability availability--${e}`), this.render();
12222
+ this.availabilityState = e, this.availabilityDetail = t || this.availabilityDetail, this.refs.availability && (this.refs.availability.textContent = t ? `${ae[e] || ae.recovering} · ${t}` : ae[e] || ae.recovering, this.refs.availability.className = `availability availability--${e}`), this.render();
12188
12223
  }
12189
- suppressExpectedClientTeardown(e, t = Hi) {
12224
+ suppressExpectedClientTeardown(e, t = qi) {
12190
12225
  this.expectedClientTeardown = {
12191
12226
  reason: e,
12192
12227
  expiresAt: Date.now() + t
@@ -12212,7 +12247,7 @@ class Ki {
12212
12247
  clearAutoStandbyRecovery() {
12213
12248
  this.autoStandbyRecoveryTimer && (window.clearTimeout(this.autoStandbyRecoveryTimer), this.autoStandbyRecoveryTimer = null);
12214
12249
  }
12215
- scheduleAutoStandbyRecovery(e, t = Pi) {
12250
+ scheduleAutoStandbyRecovery(e, t = Hi) {
12216
12251
  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(() => {
12217
12252
  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 })));
12218
12253
  }, t));
@@ -12225,7 +12260,7 @@ class Ki {
12225
12260
  markRecentlyReleasedSession(e, t) {
12226
12261
  e && (this.pruneRecentlyReleasedSessions(), this.recentlyReleasedSessions.set(e, {
12227
12262
  reason: t,
12228
- expiresAt: Date.now() + ki
12263
+ expiresAt: Date.now() + Mi
12229
12264
  }));
12230
12265
  }
12231
12266
  wasSessionRecentlyReleased(e) {
@@ -12288,10 +12323,10 @@ class Ki {
12288
12323
  async handleServerSessionAction(e, t = {}) {
12289
12324
  if (this.legacyOutboundOnly)
12290
12325
  return !1;
12291
- const i = Li(e, t);
12292
- if (i.action !== Xe.restartStandby)
12326
+ const i = Ki(e, t);
12327
+ if (i.action !== Qe.restartStandby)
12293
12328
  return !1;
12294
- const s = Q(this.issuedSession?.session_mode), r = Q(this.pendingLifecycleMode), n = s === Te.outbound || r === gt.outbound, o = s === Te.standby || r === gt.standby;
12329
+ const s = K(this.issuedSession?.session_mode), r = K(this.pendingLifecycleMode), n = s === pe.outbound || r === ft.outbound, o = s === pe.standby || r === ft.standby;
12295
12330
  if (n || !o)
12296
12331
  throw N("非待机协议上下文收到了非法的 restart_standby 指令。", {
12297
12332
  source: e,
@@ -12345,7 +12380,7 @@ class Ki {
12345
12380
  this.networkOnline = typeof navigator > "u" ? !0 : navigator.onLine !== !1, this.pageVisible = typeof document > "u" ? !0 : document.visibilityState === "visible";
12346
12381
  const t = this.availabilityState === "offline";
12347
12382
  try {
12348
- const i = await fetch(J(this.apiBaseUrl, "api/sip/touch-widget-presence"), {
12383
+ const i = await fetch(Z(this.apiBaseUrl, "api/sip/touch-widget-presence"), {
12349
12384
  method: "POST",
12350
12385
  credentials: "include",
12351
12386
  cache: "no-store",
@@ -12360,7 +12395,7 @@ class Ki {
12360
12395
  network_online: this.networkOnline,
12361
12396
  client_summary: this.buildPresenceEvidenceSummary(this.state, { trigger: e })
12362
12397
  };
12363
- return $(n, "site_key", this.options.siteKey), $(n, "requested_business_key", ae(this.options)), $(n, "resolved_business_key", this.issuedSession?.resolved_business_key), $(n, "display_name", this.options.displayName), $(n, "session_id", this.issuedSession?.session_id), $(n, "session_mode", this.issuedSession?.session_mode), $(n, "widget_anchor_number", this.issuedSession?.widget_anchor_number), $(
12398
+ return $(n, "site_key", this.options.siteKey), $(n, "requested_business_key", re(this.options)), $(n, "resolved_business_key", this.issuedSession?.resolved_business_key), $(n, "display_name", this.options.displayName), $(n, "session_id", this.issuedSession?.session_id), $(n, "session_mode", this.issuedSession?.session_mode), $(n, "widget_anchor_number", this.issuedSession?.widget_anchor_number), $(
12364
12399
  n,
12365
12400
  "browser_sip_username",
12366
12401
  this.issuedSession?.browser_sip_username || this.issuedSession?.sip_username
@@ -12376,16 +12411,16 @@ class Ki {
12376
12411
  const s = await i.json().catch(() => ({}));
12377
12412
  this.presenceFailureCount = 0, await this.handleServerSessionAction("touch-widget-presence", s) || this.syncAvailabilityState(), t && await this.restartStandbyAfterConnectivity(`presence-${e}`);
12378
12413
  } catch (i) {
12379
- if (Ae(i)) {
12414
+ if ($e(i)) {
12380
12415
  await this.handleProtocolViolation(i), this.syncAvailabilityState();
12381
12416
  return;
12382
12417
  }
12383
- if (this.presenceFailureCount += 1, this.networkOnline === !1 || ze(i) || this.presenceFailureCount >= ut) {
12418
+ if (this.presenceFailureCount += 1, this.networkOnline === !1 || Ye(i) || this.presenceFailureCount >= gt) {
12384
12419
  const r = this.networkOnline === !1 ? "当前网络连接已断开,正在等待恢复。" : "当前无法连接通话服务,正在自动尝试恢复。";
12385
12420
  this.setAvailabilityState("offline", r);
12386
12421
  } else
12387
12422
  this.setAvailabilityState("recovering", "正在确认后台连接状态。");
12388
- this.presenceFailureCount <= ut && this.appendLog("widget 运行态心跳失败", {
12423
+ this.presenceFailureCount <= gt && this.appendLog("widget 运行态心跳失败", {
12389
12424
  trigger: e,
12390
12425
  failure_count: this.presenceFailureCount,
12391
12426
  message: i?.message || String(i)
@@ -12395,14 +12430,14 @@ class Ki {
12395
12430
  startPresenceTouch() {
12396
12431
  this.legacyOutboundOnly || (this.touchWidgetPresence("mount"), this.presenceTouchTimer || (this.presenceTouchTimer = window.setInterval(() => {
12397
12432
  this.touchWidgetPresence("interval");
12398
- }, Di)));
12433
+ }, ki)));
12399
12434
  }
12400
12435
  async touchIssuedSession(e, t = null) {
12401
12436
  if (!this.issuedSession?.session_id)
12402
12437
  return;
12403
12438
  const i = this.issuedSession.session_id;
12404
12439
  try {
12405
- const s = await fetch(J(this.apiBaseUrl, "api/sip/touch-call-session"), {
12440
+ const s = await fetch(Z(this.apiBaseUrl, "api/sip/touch-call-session"), {
12406
12441
  method: "POST",
12407
12442
  credentials: "include",
12408
12443
  cache: "no-store",
@@ -12421,7 +12456,7 @@ class Ki {
12421
12456
  const r = await s.json().catch(() => ({}));
12422
12457
  await this.handleServerSessionAction("touch-call-session", r);
12423
12458
  } catch (s) {
12424
- if (Ae(s)) {
12459
+ if ($e(s)) {
12425
12460
  await this.handleProtocolViolation(s);
12426
12461
  return;
12427
12462
  }
@@ -12455,7 +12490,7 @@ class Ki {
12455
12490
  const s = this.issuedSession.session_id, r = i || this.state;
12456
12491
  let n = null, o = "";
12457
12492
  try {
12458
- const d = await fetch(J(this.apiBaseUrl, "api/sip/report-call-session-event"), {
12493
+ const d = await fetch(Z(this.apiBaseUrl, "api/sip/report-call-session-event"), {
12459
12494
  method: "POST",
12460
12495
  credentials: "include",
12461
12496
  cache: "no-store",
@@ -12475,7 +12510,7 @@ class Ki {
12475
12510
  throw o = u?.detail ? String(u.detail) : "", new Error(o || `事件留证失败:${d.status}`);
12476
12511
  }
12477
12512
  } catch (d) {
12478
- await fetch(J(this.apiBaseUrl, "api/sip/report-call-session-event-delivery-failure"), {
12513
+ await fetch(Z(this.apiBaseUrl, "api/sip/report-call-session-event-delivery-failure"), {
12479
12514
  method: "POST",
12480
12515
  credentials: "include",
12481
12516
  cache: "no-store",
@@ -12512,7 +12547,7 @@ class Ki {
12512
12547
  }
12513
12548
  this.touchIssuedSession(e), this.sessionTouchTimer || (this.sessionTouchTimer = window.setInterval(() => {
12514
12549
  this.touchIssuedSession(this.state);
12515
- }, $i));
12550
+ }, Pi));
12516
12551
  }
12517
12552
  setState(e, t = "") {
12518
12553
  this.state = e, this.stateDetail = t || se[e] || se.idle, this.syncAvailabilityState(), this.render(), this.emitHostCallback("onStateChange", this.getSnapshot());
@@ -12521,7 +12556,7 @@ class Ki {
12521
12556
  if (!this.refs.logs)
12522
12557
  return;
12523
12558
  const i = document.createElement("div");
12524
- for (i.className = "log", i.textContent = Oi(e, t), this.refs.logs.prepend(i); this.refs.logs.children.length > 8; )
12559
+ for (i.className = "log", i.textContent = Ui(e, t), this.refs.logs.prepend(i); this.refs.logs.children.length > 8; )
12525
12560
  this.refs.logs.lastElementChild?.remove();
12526
12561
  }
12527
12562
  render() {
@@ -12529,22 +12564,22 @@ class Ki {
12529
12564
  let r = "网页通话", n = this.options.text || "联系管理员", o = this.transientPanelDetail || "", d = null, u = null;
12530
12565
  e === "ringing" ? (r = "网页来电", n = i, o = o || "对方正在呼叫你,请选择接听或挂断。", d = { text: "接听", className: "btn btn-primary", disabled: !1 }, u = { text: "挂断", className: "btn btn-danger", disabled: !1 }) : e === "dialing" ? (r = "正在呼叫", o = o || "正在为你接通管理员,请稍候。", u = { text: "挂断", className: "btn btn-danger", disabled: !1 }) : e === "connected" ? (r = "通话进行中", n = this.pendingIncomingCall?.displayName || n, o = o || "通话已接通,如需结束请点击挂断。", u = { text: "挂断", className: "btn btn-danger", disabled: !1 }) : e === "ended" ? (r = "通话已结束", o = o || "本次通话已结束。") : e === "failed" && (r = "暂未接通", o = o || "当前暂时无法接通,请稍后再试。");
12531
12566
  const h = this.missedIncomingCount > 0 ? String(this.missedIncomingCount) : this.triggerHintDismissed ? "" : " ";
12532
- this.refs.trigger.disabled = s, this.refs.triggerBadge.hidden = !h, this.refs.triggerBadge.textContent = h, this.refs.triggerBadge.className = this.missedIncomingCount > 0 ? "trigger-badge" : "trigger-badge trigger-badge--dot", this.refs.panelShell.className = t ? "panel-shell panel-shell--visible" : "panel-shell", this.refs.panel.setAttribute("aria-hidden", t ? "false" : "true"), this.refs.panelEyebrow.textContent = r, this.refs.panelTitle.textContent = n, this.refs.status.textContent = Ke[e] || Ke.idle, this.refs.status.className = e === "failed" ? "status status--failed" : "status", this.refs.panelDetail.textContent = o, this.refs.primary.hidden = !d, d ? (this.refs.primary.textContent = d.text, this.refs.primary.className = d.className, this.refs.primary.disabled = d.disabled) : this.refs.primary.textContent = "", this.refs.secondary.hidden = !u, u ? (this.refs.secondary.textContent = u.text, this.refs.secondary.className = u.className, this.refs.secondary.disabled = u.disabled) : this.refs.secondary.textContent = "";
12567
+ this.refs.trigger.disabled = s, this.refs.triggerBadge.hidden = !h, this.refs.triggerBadge.textContent = h, this.refs.triggerBadge.className = this.missedIncomingCount > 0 ? "trigger-badge" : "trigger-badge trigger-badge--dot", this.refs.panelShell.className = t ? "panel-shell panel-shell--visible" : "panel-shell", this.refs.panel.setAttribute("aria-hidden", t ? "false" : "true"), this.refs.panelEyebrow.textContent = r, this.refs.panelTitle.textContent = n, this.refs.status.textContent = ze[e] || ze.idle, this.refs.status.className = e === "failed" ? "status status--failed" : "status", this.refs.panelDetail.textContent = o, this.refs.primary.hidden = !d, d ? (this.refs.primary.textContent = d.text, this.refs.primary.className = d.className, this.refs.primary.disabled = d.disabled) : this.refs.primary.textContent = "", this.refs.secondary.hidden = !u, u ? (this.refs.secondary.textContent = u.text, this.refs.secondary.className = u.className, this.refs.secondary.disabled = u.disabled) : this.refs.secondary.textContent = "";
12533
12568
  const m = +!!d + +!!u;
12534
12569
  this.refs.actions.className = m <= 1 ? "actions actions--single" : "actions";
12535
- const S = String(this.options.siteKey || "").trim(), x = String(this.bootstrap?.default_site_key || "").trim(), _ = String(ae(this.options) || "").trim(), C = String(this.bootstrap?.default_business_key || "").trim(), z = S || (x ? `${x}(服务端默认站点)` : "等待服务端解析"), p = this.issuedSession?.resolved_business_key || _ || (C ? `${C}(服务端默认规则)` : "等待服务端解析");
12536
- this.legacyOutboundOnly ? this.refs.meta.textContent = `入站规则:${p};站点键:${z}` : this.refs.meta.textContent = `站点键:${z};网页电话会先进入可被叫待机;访客主动呼叫默认规则:${p}`, this.refs.availability.textContent = this.availabilityDetail ? `${ne[this.availabilityState] || ne.recovering} · ${this.availabilityDetail}` : ne[this.availabilityState] || ne.recovering, this.refs.availability.className = `availability availability--${this.availabilityState}`, this.availabilityState === "offline" ? this.refs.hint.textContent = this.networkOnline === !1 ? "当前浏览器网络已断开。系统会在网络恢复后自动尝试重连网页电话。" : "当前无法连接通话服务。系统会继续自动恢复,暂时不要重复点击。" : this.availabilityState === "preparing" ? this.refs.hint.textContent = "当前正在准备待机能力。只要页面在线,系统会自动进入可呼入、可呼出的网页电话状态。" : this.availabilityState === "working" ? this.state === "incoming" ? this.refs.hint.textContent = "当前已有来电,直接接听或拒接即可;处理完成后会自动回到待机。" : this.state === "connected" ? this.refs.hint.textContent = "当前通话已接通,挂断后会自动回到待机,不需要额外刷新页面。" : this.refs.hint.textContent = "当前正在切换到外呼链路,请等待振铃、接通或自动回到待机。" : this.availabilityState === "recovering" ? this.refs.hint.textContent = "当前页面仍在线,系统正在自动恢复可被叫待机,不需要刷新页面或手动切换模式。" : this.availabilityState === "conflicted" ? this.refs.hint.textContent = "检测到前后端协议不一致,当前已停止自动恢复。请先排查版本和协议口径,再继续使用。" : this.refs.hint.textContent = this.isMobileViewport ? Ii : "桌面网页可直接使用;若宿主站点启用了来源白名单或接入令牌,请按站点配置提供对应参数。", this.refs.debugPanel.hidden = !this.debugPanelEnabled;
12570
+ const S = String(this.options.siteKey || "").trim(), x = String(this.bootstrap?.default_site_key || "").trim(), _ = String(re(this.options) || "").trim(), C = String(this.bootstrap?.default_business_key || "").trim(), Y = S || (x ? `${x}(服务端默认站点)` : "等待服务端解析"), p = this.issuedSession?.resolved_business_key || _ || (C ? `${C}(服务端默认规则)` : "等待服务端解析");
12571
+ this.legacyOutboundOnly ? this.refs.meta.textContent = `入站规则:${p};站点键:${Y}` : this.refs.meta.textContent = `站点键:${Y};网页电话会先进入可被叫待机;访客主动呼叫默认规则:${p}`, this.refs.availability.textContent = this.availabilityDetail ? `${ae[this.availabilityState] || ae.recovering} · ${this.availabilityDetail}` : ae[this.availabilityState] || ae.recovering, this.refs.availability.className = `availability availability--${this.availabilityState}`, this.availabilityState === "offline" ? this.refs.hint.textContent = this.networkOnline === !1 ? "当前浏览器网络已断开。系统会在网络恢复后自动尝试重连网页电话。" : "当前无法连接通话服务。系统会继续自动恢复,暂时不要重复点击。" : this.availabilityState === "preparing" ? this.refs.hint.textContent = "当前正在准备待机能力。只要页面在线,系统会自动进入可呼入、可呼出的网页电话状态。" : this.availabilityState === "working" ? this.state === "incoming" ? this.refs.hint.textContent = "当前已有来电,直接接听或拒接即可;处理完成后会自动回到待机。" : this.state === "connected" ? this.refs.hint.textContent = "当前通话已接通,挂断后会自动回到待机,不需要额外刷新页面。" : this.refs.hint.textContent = "当前正在切换到外呼链路,请等待振铃、接通或自动回到待机。" : this.availabilityState === "recovering" ? this.refs.hint.textContent = "当前页面仍在线,系统正在自动恢复可被叫待机,不需要刷新页面或手动切换模式。" : this.availabilityState === "conflicted" ? this.refs.hint.textContent = "检测到前后端协议不一致,当前已停止自动恢复。请先排查版本和协议口径,再继续使用。" : this.refs.hint.textContent = this.isMobileViewport ? $i : "桌面网页可直接使用;若宿主站点启用了来源白名单或接入令牌,请按站点配置提供对应参数。", this.refs.debugPanel.hidden = !this.debugPanelEnabled;
12537
12572
  }
12538
12573
  async destroy() {
12539
12574
  this.clearAutoStandbyRecovery(), this.clearPanelAutoClose(), await this.disconnectAndCleanup("destroy-widget", { suppressStateReset: !0 }), typeof document < "u" && this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null), this.stopSessionTouch(), this.stopPresenceTouch(), this.stopTransportDisconnectGrace(), this.pendingLifecycleMode = null, 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.beforeUnloadHandler && (window.removeEventListener("beforeunload", this.beforeUnloadHandler), this.beforeUnloadHandler = null), this.pageHideHandler && (window.removeEventListener("pagehide", this.pageHideHandler), this.pageHideHandler = null)), this.e2eBridgeEnabled && typeof window < "u" && window.__embeddedCallWidgetE2E__ && delete window.__embeddedCallWidgetE2E__, this.shadowRoot.innerHTML = "";
12540
12575
  }
12541
12576
  }
12542
- function zi(a) {
12543
- return new Ki(a);
12577
+ function es(a) {
12578
+ return new Qi(a);
12544
12579
  }
12545
12580
  typeof window < "u" && (window.__EmbeddedCallWidgetRuntime__ = {
12546
- createEmbeddedCallWidgetRuntime: zi
12581
+ createEmbeddedCallWidgetRuntime: es
12547
12582
  });
12548
12583
  export {
12549
- zi as createEmbeddedCallWidgetRuntime
12584
+ es as createEmbeddedCallWidgetRuntime
12550
12585
  };