@telnyx/ai-agent-lib 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -17,7 +17,7 @@ function D(t, e, n, i) {
17
17
  c(f);
18
18
  }
19
19
  }
20
- function l(p) {
20
+ function d(p) {
21
21
  try {
22
22
  h(i.throw(p));
23
23
  } catch (f) {
@@ -28,7 +28,7 @@ function D(t, e, n, i) {
28
28
  var f;
29
29
  p.done ? s(p.value) : (f = p.value, f instanceof n ? f : new n(function(b) {
30
30
  b(f);
31
- })).then(a, l);
31
+ })).then(a, d);
32
32
  }
33
33
  h((i = i.apply(t, [])).next());
34
34
  });
@@ -44,7 +44,7 @@ function pe(t, e, n) {
44
44
  typeof t == "string" && (e = t === "binary" ? new Array(16) : null, t = null);
45
45
  var s = (t = t || {}).random || (t.rng || wn)();
46
46
  if (s[6] = 15 & s[6] | 64, s[8] = 63 & s[8] | 128, e) for (var c = 0; c < 16; ++c) e[i + c] = s[c];
47
- return e || function(a, l) {
47
+ return e || function(a, d) {
48
48
  var h = 0, p = Wt;
49
49
  return [p[a[h++]], p[a[h++]], p[a[h++]], p[a[h++]], "-", p[a[h++]], p[a[h++]], "-", p[a[h++]], p[a[h++]], "-", p[a[h++]], p[a[h++]], "-", p[a[h++]], p[a[h++]], p[a[h++]], p[a[h++]], p[a[h++]], p[a[h++]]].join("");
50
50
  }(s);
@@ -63,7 +63,7 @@ var En = zt(function(t) {
63
63
  e = In, n = function() {
64
64
  var i = function() {
65
65
  }, s = "undefined", c = typeof window !== s && typeof window.navigator !== s && /Trident\/|MSIE /.test(window.navigator.userAgent), a = ["trace", "debug", "info", "warn", "error"];
66
- function l(m, A) {
66
+ function d(m, A) {
67
67
  var M = m[A];
68
68
  if (typeof M.bind == "function") return M.bind(m);
69
69
  try {
@@ -91,7 +91,7 @@ var En = zt(function(t) {
91
91
  }
92
92
  function b(m, A, M) {
93
93
  return function(x) {
94
- return x === "debug" && (x = "log"), typeof console !== s && (x === "trace" && c ? h : console[x] !== void 0 ? l(console, x) : console.log !== void 0 ? l(console, "log") : i);
94
+ return x === "debug" && (x = "log"), typeof console !== s && (x === "trace" && c ? h : console[x] !== void 0 ? d(console, x) : console.log !== void 0 ? d(console, "log") : i);
95
95
  }(m) || f.apply(this, arguments);
96
96
  }
97
97
  function C(m, A, M) {
@@ -118,14 +118,14 @@ var En = zt(function(t) {
118
118
  }, V.setLevel = function(E, o) {
119
119
  if (typeof E == "string" && V.levels[E.toUpperCase()] !== void 0 && (E = V.levels[E.toUpperCase()]), !(typeof E == "number" && E >= 0 && E <= V.levels.SILENT)) throw "log.setLevel() called with invalid level: " + E;
120
120
  if (x = E, o !== !1 && function(r) {
121
- var d = (a[r] || "silent").toUpperCase();
121
+ var l = (a[r] || "silent").toUpperCase();
122
122
  if (typeof window !== s && G) {
123
123
  try {
124
- return void (window.localStorage[G] = d);
124
+ return void (window.localStorage[G] = l);
125
125
  } catch {
126
126
  }
127
127
  try {
128
- window.document.cookie = encodeURIComponent(G) + "=" + d + ";";
128
+ window.document.cookie = encodeURIComponent(G) + "=" + l + ";";
129
129
  } catch {
130
130
  }
131
131
  }
@@ -178,13 +178,13 @@ L.methodFactory = (t, e, n) => {
178
178
  }, L.setLevel(L.getLevel());
179
179
  const ft = (t) => Object.keys(t).length === 0, xe = (t) => {
180
180
  const [e, n, i, s, c, a] = t;
181
- let l = {};
181
+ let d = {};
182
182
  try {
183
- l = JSON.parse(c.replace(/ID"/g, 'Id"'));
183
+ d = JSON.parse(c.replace(/ID"/g, 'Id"'));
184
184
  } catch {
185
185
  L.warn("Verto LA invalid media JSON string:", c);
186
186
  }
187
- return { participantId: Number(e), participantNumber: n, participantName: i, codec: s, media: l, participantData: a };
187
+ return { participantId: Number(e), participantNumber: n, participantName: i, codec: s, media: d, participantData: a };
188
188
  }, Jt = (t) => {
189
189
  if (typeof t != "string") return t;
190
190
  try {
@@ -197,12 +197,12 @@ const ft = (t) => Object.keys(t).length === 0, xe = (t) => {
197
197
  if (i) return { error: i };
198
198
  const { result: s = null } = n;
199
199
  if (s === null) return e !== null && (n.node_id = e), { result: n };
200
- const { code: c = null, node_id: a = null, result: l = null } = s;
201
- return c && c !== "200" ? { error: s } : l ? Ht(l, a) : { result: s };
200
+ const { code: c = null, node_id: a = null, result: d = null } = s;
201
+ return c && c !== "200" ? { error: s } : d ? Ht(d, a) : { result: s };
202
202
  }, Kt = (t, e) => Math.floor(Math.random() * (e - t + 1) + t), et = ({ login: t, passwd: e, password: n, login_token: i }) => !!(t && (e || n) || i), Me = ({ anonymous_login: t }) => !!t && !!t.target_id && !!t.target_type, at = (t) => {
203
203
  var e, n, i, s, c, a;
204
- let l = "", h = "";
205
- return !((n = (e = t?.result) === null || e === void 0 ? void 0 : e.params) === null || n === void 0) && n.state && (l = (s = (i = t?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state), !((c = t?.params) === null || c === void 0) && c.state && (h = (a = t?.params) === null || a === void 0 ? void 0 : a.state), l || h;
204
+ let d = "", h = "";
205
+ return !((n = (e = t?.result) === null || e === void 0 ? void 0 : e.params) === null || n === void 0) && n.state && (d = (s = (i = t?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state), !((c = t?.params) === null || c === void 0) && c.state && (h = (a = t?.params) === null || a === void 0 ? void 0 : a.state), d || h;
206
206
  };
207
207
  function gt({ debounceTime: t }) {
208
208
  let e, n;
@@ -244,14 +244,14 @@ var j, Se, Q, se, K;
244
244
  }(se || (se = {})), function(t) {
245
245
  t.REGED = "REGED", t.UNREGED = "UNREGED", t.NOREG = "NOREG", t.FAILED = "FAILED", t.FAIL_WAIT = "FAIL_WAIT", t.REGISTER = "REGISTER", t.TRYING = "TRYING", t.EXPIRED = "EXPIRED", t.UNREGISTER = "UNREGISTER";
246
246
  }(K || (K = {}));
247
- const ge = "GLOBAL", X = {}, ke = (t, e) => `${t}|${e}`, Qt = (t, e = ge) => ke(t, e) in X, le = (t, e, n = ge) => {
247
+ const ge = "GLOBAL", X = {}, ke = (t, e) => `${t}|${e}`, Qt = (t, e = ge) => ke(t, e) in X, de = (t, e, n = ge) => {
248
248
  const i = ke(t, n);
249
249
  i in X || (X[i] = []), X[i].push(e);
250
250
  }, Xt = (t, e, n = ge) => {
251
251
  const i = function(s) {
252
252
  ue(t, i, n), e(s);
253
253
  };
254
- return i.prototype.targetRef = e, le(t, i, n);
254
+ return i.prototype.targetRef = e, de(t, i, n);
255
255
  }, ue = (t, e, n = ge) => {
256
256
  if (!Qt(t, n)) return !1;
257
257
  const i = ke(t, n);
@@ -267,7 +267,7 @@ const ge = "GLOBAL", X = {}, ke = (t, e) => `${t}|${e}`, Qt = (t, e = ge) => ke(
267
267
  if (!Qt(t, n)) return s && U(t, e), !1;
268
268
  const c = ke(t, n), a = X[c].length;
269
269
  if (!a) return s && U(t, e), !1;
270
- for (let l = a - 1; l >= 0; l--) X[c][l](e);
270
+ for (let d = a - 1; d >= 0; d--) X[c][d](e);
271
271
  return s && U(t, e), !0;
272
272
  }, Ye = (t) => {
273
273
  const e = ke(t, "");
@@ -304,9 +304,9 @@ class vt {
304
304
  n && e.searchParams.set("voice_sdk_id", n), this._wsClient = new An(e.toString()), this._wsClient.onopen = (i) => U(O.SocketOpen, i, this.session.uuid), this._wsClient.onclose = (i) => U(O.SocketClose, i, this.session.uuid), this._wsClient.onerror = (i) => U(O.SocketError, { error: i, sessionId: this.session.sessionid }, this.session.uuid), this._wsClient.onmessage = (i) => {
305
305
  var s, c;
306
306
  const a = Jt(i.data);
307
- var l;
307
+ var d;
308
308
  if (typeof a != "string") {
309
- if (a.voice_sdk_id && (l = a.voice_sdk_id, sessionStorage.setItem(ct, l)), this._unsetTimer(a.id), L.debug(`RECV:
309
+ if (a.voice_sdk_id && (d = a.voice_sdk_id, sessionStorage.setItem(ct, d)), this._unsetTimer(a.id), L.debug(`RECV:
310
310
  `, JSON.stringify(a, null, 2), `
311
311
  `), K[`${(c = (s = a?.result) === null || s === void 0 ? void 0 : s.params) === null || c === void 0 ? void 0 : c.state}`] || !U(a.id, a)) {
312
312
  const h = at(a);
@@ -322,8 +322,8 @@ class vt {
322
322
  const { request: n } = e, i = new Promise((s, c) => {
323
323
  if (n.hasOwnProperty("result")) return s();
324
324
  Xt(n.id, (a) => {
325
- const { result: l, error: h } = Ht(a);
326
- return h ? c(h) : s(l);
325
+ const { result: d, error: h } = Ht(a);
326
+ return h ? c(h) : s(d);
327
327
  });
328
328
  });
329
329
  return L.debug(`SEND:
@@ -413,7 +413,7 @@ class Pn {
413
413
  });
414
414
  }
415
415
  on(e, n) {
416
- return le(e, n, this.uuid), this;
416
+ return de(e, n, this.uuid), this;
417
417
  }
418
418
  off(e, n) {
419
419
  return ue(e, n, this.uuid), this;
@@ -441,7 +441,7 @@ class Pn {
441
441
  this._existsSubscription(e, n) && (n ? (delete this.subscriptions[e][n], ue(e, null, n)) : (delete this.subscriptions[e], Ye(e)));
442
442
  }
443
443
  _addSubscription(e, n = null, i) {
444
- this._existsSubscription(e, i) || (this._existsSubscription(e) || (this.subscriptions[e] = {}), this.subscriptions[e][i] = {}, fe(n) && le(e, n, i));
444
+ this._existsSubscription(e, i) || (this._existsSubscription(e) || (this.subscriptions[e] = {}), this.subscriptions[e][i] = {}, fe(n) && de(e, n, i));
445
445
  }
446
446
  _existsSubscription(e, n) {
447
447
  return !(!this.subscriptions.hasOwnProperty(e) || !(!n || n && this.subscriptions[e].hasOwnProperty(n)));
@@ -464,7 +464,7 @@ class Pn {
464
464
  this._doKeepAlive === !0 && (this._pong = !1, this._keepAliveTimeout = setTimeout(() => this._keepAlive(), 3e4));
465
465
  }
466
466
  static on(e, n) {
467
- le(e, n);
467
+ de(e, n);
468
468
  }
469
469
  static off(e) {
470
470
  ue(e);
@@ -603,8 +603,8 @@ function Un() {
603
603
  return { browserInfo: navigator.userAgent, name: b, version: C, supportAudio: !0, supportVideo: !0 };
604
604
  }
605
605
  throw new Error("This browser does not support @telnyx/webrtc. To see browser support list: `TelnyxRTC.webRTCSupportedBrowserList()`");
606
- }(), c = window.RTCPeerConnection, a = window.RTCSessionDescription, l = window.RTCIceCandidate, h = window.navigator && window.navigator.mediaDevices, p = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia || navigator.mozGetUserMedia;
607
- return { browserInfo: t, browserName: e, browserVersion: n, supportWebRTC: !!(c && a && l && h && p), supportWebRTCAudio: i, supportWebRTCVideo: s, supportRTCPeerConnection: !!c, supportSessionDescription: !!a, supportIceCandidate: !!l, supportMediaDevices: !!h, supportGetUserMedia: !!je };
606
+ }(), c = window.RTCPeerConnection, a = window.RTCSessionDescription, d = window.RTCIceCandidate, h = window.navigator && window.navigator.mediaDevices, p = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.msGetUserMedia || navigator.mozGetUserMedia;
607
+ return { browserInfo: t, browserName: e, browserVersion: n, supportWebRTC: !!(c && a && d && h && p), supportWebRTCAudio: i, supportWebRTCVideo: s, supportRTCPeerConnection: !!c, supportSessionDescription: !!a, supportIceCandidate: !!d, supportMediaDevices: !!h, supportGetUserMedia: !!je };
608
608
  } catch (t) {
609
609
  return t.message;
610
610
  }
@@ -636,12 +636,12 @@ function kt(t) {
636
636
  (function(t) {
637
637
  t.not_supported = "not supported", t.full = "full", t.partial = "partial";
638
638
  })(q || (q = {}));
639
- var tn = "2.22.15", dt = tn;
639
+ var tn = "2.22.16", lt = tn;
640
640
  class $n extends Z {
641
641
  constructor(e, n, i, s, c = {}, a) {
642
642
  super(), this.method = "login";
643
- const l = { login: e, passwd: n, login_token: i, userVariables: c, reconnection: a, loginParams: {}, "User-Agent": { sdkVersion: dt, data: navigator.userAgent } };
644
- s && (l.sessid = s), this.buildRequest({ method: this.method, params: l });
643
+ const d = { login: e, passwd: n, login_token: i, userVariables: c, reconnection: a, loginParams: {}, "User-Agent": { sdkVersion: lt, data: navigator.userAgent } };
644
+ s && (d.sessid = s), this.buildRequest({ method: this.method, params: d });
645
645
  }
646
646
  }
647
647
  class Vn extends Z {
@@ -695,22 +695,22 @@ class zn extends Z {
695
695
  }
696
696
  }
697
697
  class Jn extends Te {
698
- constructor(e) {
699
- super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: pe(), type: "message", role: "user", content: [{ type: "input_text", text: e }] } } });
698
+ constructor(e, n) {
699
+ super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: pe(), type: "message", role: "user", content: [{ type: "input_text", text: e }, ...n?.map((i) => ({ type: "image_url", image_url: { url: i } }))] } } });
700
700
  }
701
701
  }
702
702
  const nn = (t, e) => {
703
703
  const { contentType: n, canvasType: i, callID: s, canvasInfo: c = null, currentLayerIdx: a = -1 } = e;
704
704
  c && i !== "mcu-personal-canvas" && delete c.memberID;
705
- const l = { type: ie.conferenceUpdate, call: t.calls[s], canvasInfo: Hn(c), currentLayerIdx: a };
705
+ const d = { type: ie.conferenceUpdate, call: t.calls[s], canvasInfo: Hn(c), currentLayerIdx: a };
706
706
  switch (n) {
707
707
  case "layer-info": {
708
- const h = Object.assign({ action: Q.LayerInfo }, l);
708
+ const h = Object.assign({ action: Q.LayerInfo }, d);
709
709
  U(O.Notification, h, t.uuid);
710
710
  break;
711
711
  }
712
712
  case "layout-info": {
713
- const h = Object.assign({ action: Q.LayoutInfo }, l);
713
+ const h = Object.assign({ action: Q.LayoutInfo }, d);
714
714
  U(O.Notification, h, t.uuid);
715
715
  break;
716
716
  }
@@ -729,39 +729,39 @@ var Ae, sn = zt(function(t, e) {
729
729
  function c(o) {
730
730
  return o._maxListeners === void 0 ? s.defaultMaxListeners : o._maxListeners;
731
731
  }
732
- function a(o, r, d, u) {
732
+ function a(o, r, l, u) {
733
733
  var g, y, _;
734
- if (typeof d != "function") throw new TypeError('"listener" argument must be a function');
735
- if ((y = o._events) ? (y.newListener && (o.emit("newListener", r, d.listener ? d.listener : d), y = o._events), _ = y[r]) : (y = o._events = new i(), o._eventsCount = 0), _) {
736
- if (typeof _ == "function" ? _ = y[r] = u ? [d, _] : [_, d] : u ? _.unshift(d) : _.push(d), !_.warned && (g = c(o)) && 0 < g && _.length > g) {
734
+ if (typeof l != "function") throw new TypeError('"listener" argument must be a function');
735
+ if ((y = o._events) ? (y.newListener && (o.emit("newListener", r, l.listener ? l.listener : l), y = o._events), _ = y[r]) : (y = o._events = new i(), o._eventsCount = 0), _) {
736
+ if (typeof _ == "function" ? _ = y[r] = u ? [l, _] : [_, l] : u ? _.unshift(l) : _.push(l), !_.warned && (g = c(o)) && 0 < g && _.length > g) {
737
737
  _.warned = !0;
738
738
  var k = new Error("Possible EventEmitter memory leak detected. " + _.length + " " + r + " listeners added. Use emitter.setMaxListeners() to increase limit");
739
739
  k.name = "MaxListenersExceededWarning", k.emitter = o, k.type = r, k.count = _.length, function(T) {
740
740
  typeof console.warn == "function" ? console.warn(T) : console.log(T);
741
741
  }(k);
742
742
  }
743
- } else _ = y[r] = d, ++o._eventsCount;
743
+ } else _ = y[r] = l, ++o._eventsCount;
744
744
  return o;
745
745
  }
746
- function l(o, r, d) {
746
+ function d(o, r, l) {
747
747
  function u() {
748
- o.removeListener(r, u), g || (g = !0, d.apply(o, arguments));
748
+ o.removeListener(r, u), g || (g = !0, l.apply(o, arguments));
749
749
  }
750
750
  var g = !1;
751
- return u.listener = d, u;
751
+ return u.listener = l, u;
752
752
  }
753
753
  function h(o) {
754
754
  var r = this._events;
755
755
  if (r) {
756
- var d = r[o];
757
- if (typeof d == "function") return 1;
758
- if (d) return d.length;
756
+ var l = r[o];
757
+ if (typeof l == "function") return 1;
758
+ if (l) return l.length;
759
759
  }
760
760
  return 0;
761
761
  }
762
762
  function p(o, r) {
763
- for (var d = Array(r); r--; ) d[r] = o[r];
764
- return d;
763
+ for (var l = Array(r); r--; ) l[r] = o[r];
764
+ return l;
765
765
  }
766
766
  Object.defineProperty(e, "__esModule", { value: !0 }), i.prototype = /* @__PURE__ */ Object.create(null), s.EventEmitter = s, s.usingDomains = !1, s.prototype.domain = void 0, s.prototype._events = void 0, s.prototype._maxListeners = void 0, s.defaultMaxListeners = 10, s.init = function() {
767
767
  this.domain = null, s.usingDomains && n.active && !(this instanceof n.Domain) && (this.domain = n.active), this._events && this._events !== Object.getPrototypeOf(this)._events || (this._events = new i(), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0;
@@ -771,7 +771,7 @@ var Ae, sn = zt(function(t, e) {
771
771
  }, s.prototype.getMaxListeners = function() {
772
772
  return c(this);
773
773
  }, s.prototype.emit = function(o) {
774
- var r, d, u, g, y, _, k, T = o === "error";
774
+ var r, l, u, g, y, _, k, T = o === "error";
775
775
  if (_ = this._events) T = T && _.error == null;
776
776
  else if (!T) return !1;
777
777
  if (k = this.domain, T) {
@@ -782,39 +782,39 @@ var Ae, sn = zt(function(t, e) {
782
782
  }
783
783
  return r || (r = new Error('Uncaught, unspecified "error" event')), r.domainEmitter = this, r.domain = k, r.domainThrown = !1, k.emit("error", r), !1;
784
784
  }
785
- if (!(d = _[o])) return !1;
786
- var J = typeof d == "function";
785
+ if (!(l = _[o])) return !1;
786
+ var J = typeof l == "function";
787
787
  switch (u = arguments.length) {
788
788
  case 1:
789
789
  (function(v, N, P) {
790
790
  if (N) v.call(P);
791
791
  else for (var $ = v.length, W = p(v, $), B = 0; B < $; ++B) W[B].call(P);
792
- })(d, J, this);
792
+ })(l, J, this);
793
793
  break;
794
794
  case 2:
795
795
  (function(v, N, P, $) {
796
796
  if (N) v.call(P, $);
797
797
  else for (var W = v.length, B = p(v, W), H = 0; H < W; ++H) B[H].call(P, $);
798
- })(d, J, this, arguments[1]);
798
+ })(l, J, this, arguments[1]);
799
799
  break;
800
800
  case 3:
801
801
  (function(v, N, P, $, W) {
802
802
  if (N) v.call(P, $, W);
803
803
  else for (var B = v.length, H = p(v, B), oe = 0; oe < B; ++oe) H[oe].call(P, $, W);
804
- })(d, J, this, arguments[1], arguments[2]);
804
+ })(l, J, this, arguments[1], arguments[2]);
805
805
  break;
806
806
  case 4:
807
807
  (function(v, N, P, $, W, B) {
808
808
  if (N) v.call(P, $, W, B);
809
809
  else for (var H = v.length, oe = p(v, H), z = 0; z < H; ++z) oe[z].call(P, $, W, B);
810
- })(d, J, this, arguments[1], arguments[2], arguments[3]);
810
+ })(l, J, this, arguments[1], arguments[2], arguments[3]);
811
811
  break;
812
812
  default:
813
813
  for (g = Array(u - 1), y = 1; y < u; y++) g[y - 1] = arguments[y];
814
814
  (function(v, N, P, $) {
815
815
  if (N) v.apply(P, $);
816
816
  else for (var W = v.length, B = p(v, W), H = 0; H < W; ++H) B[H].apply(P, $);
817
- })(d, J, this, g);
817
+ })(l, J, this, g);
818
818
  }
819
819
  return !0;
820
820
  }, s.prototype.addListener = function(o, r) {
@@ -823,51 +823,51 @@ var Ae, sn = zt(function(t, e) {
823
823
  return a(this, o, r, !0);
824
824
  }, s.prototype.once = function(o, r) {
825
825
  if (typeof r != "function") throw new TypeError('"listener" argument must be a function');
826
- return this.on(o, l(this, o, r)), this;
826
+ return this.on(o, d(this, o, r)), this;
827
827
  }, s.prototype.prependOnceListener = function(o, r) {
828
828
  if (typeof r != "function") throw new TypeError('"listener" argument must be a function');
829
- return this.prependListener(o, l(this, o, r)), this;
829
+ return this.prependListener(o, d(this, o, r)), this;
830
830
  }, s.prototype.removeListener = function(o, r) {
831
- var d, u, g, y, _;
831
+ var l, u, g, y, _;
832
832
  if (typeof r != "function") throw new TypeError('"listener" argument must be a function');
833
833
  if (!(u = this._events)) return this;
834
- if (!(d = u[o])) return this;
835
- if (d === r || d.listener && d.listener === r) --this._eventsCount == 0 ? this._events = new i() : (delete u[o], u.removeListener && this.emit("removeListener", o, d.listener || r));
836
- else if (typeof d != "function") {
837
- for (g = -1, y = d.length; 0 < y--; ) if (d[y] === r || d[y].listener && d[y].listener === r) {
838
- _ = d[y].listener, g = y;
834
+ if (!(l = u[o])) return this;
835
+ if (l === r || l.listener && l.listener === r) --this._eventsCount == 0 ? this._events = new i() : (delete u[o], u.removeListener && this.emit("removeListener", o, l.listener || r));
836
+ else if (typeof l != "function") {
837
+ for (g = -1, y = l.length; 0 < y--; ) if (l[y] === r || l[y].listener && l[y].listener === r) {
838
+ _ = l[y].listener, g = y;
839
839
  break;
840
840
  }
841
841
  if (0 > g) return this;
842
- if (d.length === 1) {
843
- if (d[0] = void 0, --this._eventsCount == 0) return this._events = new i(), this;
842
+ if (l.length === 1) {
843
+ if (l[0] = void 0, --this._eventsCount == 0) return this._events = new i(), this;
844
844
  delete u[o];
845
845
  } else (function(k, T) {
846
846
  for (var Y = T, J = Y + 1, v = k.length; J < v; Y += 1, J += 1) k[Y] = k[J];
847
847
  k.pop();
848
- })(d, g);
848
+ })(l, g);
849
849
  u.removeListener && this.emit("removeListener", o, _ || r);
850
850
  }
851
851
  return this;
852
852
  }, s.prototype.removeAllListeners = function(o) {
853
- var r, d;
854
- if (!(d = this._events)) return this;
855
- if (!d.removeListener) return arguments.length === 0 ? (this._events = new i(), this._eventsCount = 0) : d[o] && (--this._eventsCount == 0 ? this._events = new i() : delete d[o]), this;
853
+ var r, l;
854
+ if (!(l = this._events)) return this;
855
+ if (!l.removeListener) return arguments.length === 0 ? (this._events = new i(), this._eventsCount = 0) : l[o] && (--this._eventsCount == 0 ? this._events = new i() : delete l[o]), this;
856
856
  if (arguments.length === 0) {
857
- for (var u, g = Object.keys(d), y = 0; y < g.length; ++y) (u = g[y]) !== "removeListener" && this.removeAllListeners(u);
857
+ for (var u, g = Object.keys(l), y = 0; y < g.length; ++y) (u = g[y]) !== "removeListener" && this.removeAllListeners(u);
858
858
  return this.removeAllListeners("removeListener"), this._events = new i(), this._eventsCount = 0, this;
859
859
  }
860
- if (typeof (r = d[o]) == "function") this.removeListener(o, r);
860
+ if (typeof (r = l[o]) == "function") this.removeListener(o, r);
861
861
  else if (r) do
862
862
  this.removeListener(o, r[r.length - 1]);
863
863
  while (r[0]);
864
864
  return this;
865
865
  }, s.prototype.listeners = function(o) {
866
- var r, d, u = this._events;
867
- return u ? d = (r = u[o]) ? typeof r == "function" ? [r.listener || r] : function(g) {
866
+ var r, l, u = this._events;
867
+ return u ? l = (r = u[o]) ? typeof r == "function" ? [r.listener || r] : function(g) {
868
868
  for (var y = Array(g.length), _ = 0; _ < y.length; ++_) y[_] = g[_].listener || g[_];
869
869
  return y;
870
- }(r) : [] : d = [], d;
870
+ }(r) : [] : l = [], l;
871
871
  }, s.listenerCount = function(o, r) {
872
872
  return typeof o.listenerCount == "function" ? o.listenerCount(r) : h.call(o, r);
873
873
  }, s.prototype.listenerCount = h, s.prototype.eventNames = function() {
@@ -880,46 +880,46 @@ var Ae, sn = zt(function(t, e) {
880
880
  }
881
881
  for (var I = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i, w = [], R = 0; 256 > R; ++R) w.push((R + 256).toString(16).substr(1));
882
882
  function m(o) {
883
- var r = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0, d = (w[o[r + 0]] + w[o[r + 1]] + w[o[r + 2]] + w[o[r + 3]] + "-" + w[o[r + 4]] + w[o[r + 5]] + "-" + w[o[r + 6]] + w[o[r + 7]] + "-" + w[o[r + 8]] + w[o[r + 9]] + "-" + w[o[r + 10]] + w[o[r + 11]] + w[o[r + 12]] + w[o[r + 13]] + w[o[r + 14]] + w[o[r + 15]]).toLowerCase();
883
+ var r = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0, l = (w[o[r + 0]] + w[o[r + 1]] + w[o[r + 2]] + w[o[r + 3]] + "-" + w[o[r + 4]] + w[o[r + 5]] + "-" + w[o[r + 6]] + w[o[r + 7]] + "-" + w[o[r + 8]] + w[o[r + 9]] + "-" + w[o[r + 10]] + w[o[r + 11]] + w[o[r + 12]] + w[o[r + 13]] + w[o[r + 14]] + w[o[r + 15]]).toLowerCase();
884
884
  if (!function(u) {
885
885
  return typeof u == "string" && I.test(u);
886
- }(d)) throw TypeError("Stringified UUID is invalid");
887
- return d;
886
+ }(l)) throw TypeError("Stringified UUID is invalid");
887
+ return l;
888
888
  }
889
- function A(o, r, d) {
889
+ function A(o, r, l) {
890
890
  var u = (o = o || {}).random || (o.rng || C)();
891
891
  return u[6] = 64 | 15 & u[6], u[8] = 128 | 63 & u[8], m(u);
892
892
  }
893
893
  function M(o, r) {
894
894
  if (!o || !r) return {};
895
- const d = { ...o };
896
- if (d.localCandidateId) {
897
- const u = r.get(d.localCandidateId);
898
- d.local = { ...u };
895
+ const l = { ...o };
896
+ if (l.localCandidateId) {
897
+ const u = r.get(l.localCandidateId);
898
+ l.local = { ...u };
899
899
  }
900
- if (d.remoteCandidateId) {
901
- const u = r.get(d.remoteCandidateId);
902
- d.remote = { ...u };
900
+ if (l.remoteCandidateId) {
901
+ const u = r.get(l.remoteCandidateId);
902
+ l.remote = { ...u };
903
903
  }
904
- return d;
904
+ return l;
905
905
  }
906
- function x(o, r, d) {
906
+ function x(o, r, l) {
907
907
  return 8 * function(u, g, y) {
908
908
  const _ = u[y], k = g ? g[y] : null;
909
909
  return _ === null || k === null ? null : (_ - k) / (u.timestamp - g.timestamp) * 1e3;
910
- }(o, r, d);
910
+ }(o, r, l);
911
911
  }
912
912
  function V(o) {
913
913
  if (!o.entries) return o;
914
914
  const r = {};
915
- return o.forEach(function(d, u) {
916
- r[u] = d;
915
+ return o.forEach(function(l, u) {
916
+ r[u] = l;
917
917
  }), r;
918
918
  }
919
- function G(o, r, d = {}) {
919
+ function G(o, r, l = {}) {
920
920
  if (!o) return null;
921
921
  let u = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] }, connection: { inbound: [], outbound: [] } };
922
- d.remote && (u.remote = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] } });
922
+ l.remote && (u.remote = { audio: { inbound: [], outbound: [] }, video: { inbound: [], outbound: [] } });
923
923
  for (const g of o.values()) switch (g.type) {
924
924
  case "outbound-rtp": {
925
925
  const y = g.mediaType || g.kind, _ = {};
@@ -958,7 +958,7 @@ var Ae, sn = zt(function(t, e) {
958
958
  u.connection.dataChannelsClosed = g.dataChannelsClosed, u.connection.dataChannelsOpened = g.dataChannelsOpened;
959
959
  break;
960
960
  case "remote-inbound-rtp": {
961
- if (!d.remote) break;
961
+ if (!l.remote) break;
962
962
  let y = g.mediaType || g.kind;
963
963
  const _ = {};
964
964
  if (!["audio", "video"].includes(y)) if (g.id.includes("Video")) y = "video";
@@ -981,7 +981,7 @@ var Ae, sn = zt(function(t, e) {
981
981
  break;
982
982
  }
983
983
  case "remote-outbound-rtp": {
984
- if (!d.remote) break;
984
+ if (!l.remote) break;
985
985
  const y = g.mediaType || g.kind, _ = {};
986
986
  if (!["audio", "video"].includes(y)) continue;
987
987
  if (g.codecId) {
@@ -1020,31 +1020,31 @@ var Ae, sn = zt(function(t, e) {
1020
1020
  return console.warn("The addPeer() method has been deprecated, please use addConnection()"), this.addConnection({ peerId: o, pc: r });
1021
1021
  }
1022
1022
  async addConnection(o) {
1023
- const { pc: r, peerId: d } = o;
1023
+ const { pc: r, peerId: l } = o;
1024
1024
  let { connectionId: u, remote: g } = o;
1025
1025
  if (g = typeof g == "boolean" ? g : this.remote, !(r && r instanceof RTCPeerConnection)) throw new Error("Missing argument 'pc' or is not of instance RTCPeerConnection");
1026
- if (!d) throw new Error("Missing argument peerId");
1026
+ if (!l) throw new Error("Missing argument peerId");
1027
1027
  if (this.isEdge) throw new Error("Can't monitor peers in Edge at this time.");
1028
- if (this.peersToMonitor[d]) {
1029
- if (u && u in this.peersToMonitor[d]) throw new Error(`We are already monitoring connection with id ${u}.`);
1030
- for (let _ in this.peersToMonitor[d]) {
1031
- const k = this.peersToMonitor[d][_];
1032
- if (k.pc === r) throw new Error(`We are already monitoring peer with id ${d}.`);
1028
+ if (this.peersToMonitor[l]) {
1029
+ if (u && u in this.peersToMonitor[l]) throw new Error(`We are already monitoring connection with id ${u}.`);
1030
+ for (let _ in this.peersToMonitor[l]) {
1031
+ const k = this.peersToMonitor[l][_];
1032
+ if (k.pc === r) throw new Error(`We are already monitoring peer with id ${l}.`);
1033
1033
  k.pc.connectionState === "closed" && this.removeConnection({ pc: k.pc });
1034
1034
  }
1035
1035
  }
1036
1036
  const y = r.getConfiguration();
1037
1037
  return y.iceServers && y.iceServers.forEach(function(_) {
1038
1038
  delete _.credential;
1039
- }), u || (u = A()), this.emitEvent({ event: "addConnection", tag: "peer", peerId: d, connectionId: u, data: { options: o, peerConfiguration: y } }), this.monitorPeer({ peerId: d, connectionId: u, pc: r, remote: g }), { connectionId: u };
1039
+ }), u || (u = A()), this.emitEvent({ event: "addConnection", tag: "peer", peerId: l, connectionId: u, data: { options: o, peerConfiguration: y } }), this.monitorPeer({ peerId: l, connectionId: u, pc: r, remote: g }), { connectionId: u };
1040
1040
  }
1041
1041
  getTimeline(o) {
1042
- return this.timeline = this.timeline.sort((r, d) => r.timestamp.getTime() - d.timestamp.getTime()), o ? this.timeline.filter((r) => r.tag === o) : this.timeline;
1042
+ return this.timeline = this.timeline.sort((r, l) => r.timestamp.getTime() - l.timestamp.getTime()), o ? this.timeline.filter((r) => r.tag === o) : this.timeline;
1043
1043
  }
1044
1044
  get logger() {
1045
1045
  const o = (r) => {
1046
- const d = ["none", "error", "warn", "info", "debug"];
1047
- return d.slice(0, d.indexOf(this.logLevel) + 1).indexOf(r) > -1;
1046
+ const l = ["none", "error", "warn", "info", "debug"];
1047
+ return l.slice(0, l.indexOf(this.logLevel) + 1).indexOf(r) > -1;
1048
1048
  };
1049
1049
  return { error(...r) {
1050
1050
  this.debug && o("error") && console.error("[webrtc-stats][error] ", ...r);
@@ -1057,17 +1057,17 @@ var Ae, sn = zt(function(t, e) {
1057
1057
  } };
1058
1058
  }
1059
1059
  removeConnection(o) {
1060
- let r, { connectionId: d, pc: u } = o;
1061
- if (!u && !d) throw new Error("Missing arguments. You need to either send pc or a connectionId.");
1062
- if (d) {
1063
- if (typeof d != "string") throw new Error("connectionId must be a string.");
1064
- for (let g in this.peersToMonitor) d in this.peersToMonitor[g] && (u = this.peersToMonitor[g][d].pc, r = g);
1060
+ let r, { connectionId: l, pc: u } = o;
1061
+ if (!u && !l) throw new Error("Missing arguments. You need to either send pc or a connectionId.");
1062
+ if (l) {
1063
+ if (typeof l != "string") throw new Error("connectionId must be a string.");
1064
+ for (let g in this.peersToMonitor) l in this.peersToMonitor[g] && (u = this.peersToMonitor[g][l].pc, r = g);
1065
1065
  } else if (u) {
1066
1066
  if (!(u instanceof RTCPeerConnection)) throw new Error("pc must be an instance of RTCPeerConnection.");
1067
- for (let g in this.peersToMonitor) for (let y in this.peersToMonitor[g]) this.peersToMonitor[g][y].pc === u && (d = y, r = g);
1067
+ for (let g in this.peersToMonitor) for (let y in this.peersToMonitor[g]) this.peersToMonitor[g][y].pc === u && (l = y, r = g);
1068
1068
  }
1069
- if (!u || !d) throw new Error("Could not find the desired connection.");
1070
- return this.removePeerConnectionEventListeners(d, u), delete this.peersToMonitor[r][d], Object.values(this.peersToMonitor[r]).length === 0 && delete this.peersToMonitor[r], { connectionId: d };
1069
+ if (!u || !l) throw new Error("Could not find the desired connection.");
1070
+ return this.removePeerConnectionEventListeners(l, u), delete this.peersToMonitor[r][l], Object.values(this.peersToMonitor[r]).length === 0 && delete this.peersToMonitor[r], { connectionId: l };
1071
1071
  }
1072
1072
  removeAllPeers() {
1073
1073
  for (let o in this.peersToMonitor) this.removePeer(o);
@@ -1075,8 +1075,8 @@ var Ae, sn = zt(function(t, e) {
1075
1075
  removePeer(o) {
1076
1076
  if (this.logger.info(`Removing PeerConnection with id ${o}.`), this.peersToMonitor[o]) {
1077
1077
  for (let r in this.peersToMonitor[o]) {
1078
- let d = this.peersToMonitor[o][r].pc;
1079
- this.removePeerConnectionEventListeners(r, d);
1078
+ let l = this.peersToMonitor[o][r].pc;
1079
+ this.removePeerConnectionEventListeners(r, l);
1080
1080
  }
1081
1081
  delete this.peersToMonitor[o];
1082
1082
  }
@@ -1087,14 +1087,14 @@ var Ae, sn = zt(function(t, e) {
1087
1087
  }), E = [], this.shouldWrapGetUserMedia && ee && (navigator.mediaDevices.getUserMedia = ee);
1088
1088
  }
1089
1089
  monitorPeer(o) {
1090
- let { peerId: r, connectionId: d, pc: u, remote: g } = o;
1090
+ let { peerId: r, connectionId: l, pc: u, remote: g } = o;
1091
1091
  if (!u) return void this.logger.warn("Did not receive pc argument when calling monitorPeer()");
1092
- const y = { pc: u, connectionId: d, stream: null, stats: { parsed: null, raw: null }, options: { remote: g } };
1092
+ const y = { pc: u, connectionId: l, stream: null, stats: { parsed: null, raw: null }, options: { remote: g } };
1093
1093
  if (this.peersToMonitor[r]) {
1094
- if (d in this.peersToMonitor[r]) return void this.logger.warn(`Already watching connection with ID ${d}`);
1095
- this.peersToMonitor[r][d] = y;
1096
- } else this.peersToMonitor[r] = { [d]: y };
1097
- this.addPeerConnectionEventListeners(r, d, u), this.numberOfMonitoredPeers === 1 && (this.startStatsMonitoring(), this.startConnectionStateMonitoring());
1094
+ if (l in this.peersToMonitor[r]) return void this.logger.warn(`Already watching connection with ID ${l}`);
1095
+ this.peersToMonitor[r][l] = y;
1096
+ } else this.peersToMonitor[r] = { [l]: y };
1097
+ this.addPeerConnectionEventListeners(r, l, u), this.numberOfMonitoredPeers === 1 && (this.startStatsMonitoring(), this.startConnectionStateMonitoring());
1098
1098
  }
1099
1099
  startStatsMonitoring() {
1100
1100
  this.monitoringSetInterval || (this.monitoringSetInterval = window.setInterval(() => {
@@ -1115,35 +1115,35 @@ var Ae, sn = zt(function(t, e) {
1115
1115
  if (!this.peersToMonitor[o]) throw new Error(`Cannot get stats. Peer with id ${o} does not exist`);
1116
1116
  r[o] = this.peersToMonitor[o];
1117
1117
  } else r = this.peersToMonitor;
1118
- let d = [];
1118
+ let l = [];
1119
1119
  for (const u in r) for (const g in r[u]) {
1120
1120
  const y = r[u][g], _ = y.pc;
1121
1121
  if (_ && !this.checkIfConnectionIsClosed(u, g, _)) try {
1122
1122
  const k = this.getTimestamp(), T = _.getStats(null);
1123
1123
  if (T) {
1124
1124
  const Y = await T, J = this.getTimestamp(), v = V(Y), N = { remote: y.options.remote }, P = G(Y, y.stats.parsed, N), $ = { event: "stats", tag: "stats", peerId: u, connectionId: g, timeTaken: J - k, data: P };
1125
- this.rawStats === !0 && ($.rawStats = Y), this.statsObject === !0 && ($.statsObject = v), this.filteredStats === !0 && ($.filteredStats = this.filteroutStats(v)), d.push($), y.stats.parsed = P;
1125
+ this.rawStats === !0 && ($.rawStats = Y), this.statsObject === !0 && ($.statsObject = v), this.filteredStats === !0 && ($.filteredStats = this.filteroutStats(v)), l.push($), y.stats.parsed = P;
1126
1126
  } else this.logger.error(`PeerConnection from peer ${u} did not return any stats data`);
1127
1127
  } catch (k) {
1128
1128
  this.logger.error(k);
1129
1129
  }
1130
1130
  }
1131
- return d;
1131
+ return l;
1132
1132
  }
1133
1133
  startConnectionStateMonitoring() {
1134
1134
  this.connectionMonitoringSetInterval = window.setInterval(() => {
1135
1135
  this.numberOfMonitoredPeers || this.stopConnectionStateMonitoring();
1136
1136
  for (const o in this.peersToMonitor) for (const r in this.peersToMonitor[o]) {
1137
- const d = this.peersToMonitor[o][r].pc;
1138
- this.checkIfConnectionIsClosed(o, r, d);
1137
+ const l = this.peersToMonitor[o][r].pc;
1138
+ this.checkIfConnectionIsClosed(o, r, l);
1139
1139
  }
1140
1140
  }, this.connectionMonitoringInterval);
1141
1141
  }
1142
- checkIfConnectionIsClosed(o, r, d) {
1143
- const u = this.isConnectionClosed(d);
1142
+ checkIfConnectionIsClosed(o, r, l) {
1143
+ const u = this.isConnectionClosed(l);
1144
1144
  if (u) {
1145
- this.removeConnection({ pc: d });
1146
- let g = d.connectionState === "closed" ? "onconnectionstatechange" : "oniceconnectionstatechange";
1145
+ this.removeConnection({ pc: l });
1146
+ let g = l.connectionState === "closed" ? "onconnectionstatechange" : "oniceconnectionstatechange";
1147
1147
  this.emitEvent({ event: g, peerId: o, connectionId: r, tag: "connection", data: "closed" });
1148
1148
  }
1149
1149
  return u;
@@ -1165,54 +1165,54 @@ var Ae, sn = zt(function(t, e) {
1165
1165
  filteroutStats(o = {}) {
1166
1166
  const r = { ...o };
1167
1167
  for (const u in r) {
1168
- var d = r[u];
1169
- this.statsToMonitor.includes(d.type) || delete r[u];
1168
+ var l = r[u];
1169
+ this.statsToMonitor.includes(l.type) || delete r[u];
1170
1170
  }
1171
1171
  return r;
1172
1172
  }
1173
1173
  get peerConnectionListeners() {
1174
- return { icecandidate: (o, r, d, u) => {
1174
+ return { icecandidate: (o, r, l, u) => {
1175
1175
  this.logger.debug("[pc-event] icecandidate | peerId: ${peerId}", u), this.emitEvent({ event: "onicecandidate", tag: "connection", peerId: o, connectionId: r, data: u.candidate });
1176
- }, track: (o, r, d, u) => {
1176
+ }, track: (o, r, l, u) => {
1177
1177
  this.logger.debug(`[pc-event] track | peerId: ${o}`, u);
1178
1178
  const g = u.track, y = u.streams[0];
1179
1179
  o in this.peersToMonitor && r in this.peersToMonitor[o] && (this.peersToMonitor[o][r].stream = y), this.addTrackEventListeners(g, r), this.emitEvent({ event: "ontrack", tag: "track", peerId: o, connectionId: r, data: { stream: y ? this.getStreamDetails(y) : null, track: g ? this.getMediaTrackDetails(g) : null, title: u.track.kind + ":" + u.track.id + " " + u.streams.map(function(_) {
1180
1180
  return "stream:" + _.id;
1181
1181
  }) } });
1182
- }, signalingstatechange: (o, r, d) => {
1183
- this.logger.debug(`[pc-event] signalingstatechange | peerId: ${o}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: o, connectionId: r, data: { signalingState: d.signalingState, localDescription: d.localDescription, remoteDescription: d.remoteDescription } });
1184
- }, iceconnectionstatechange: (o, r, d) => {
1185
- this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${o}`), this.emitEvent({ event: "oniceconnectionstatechange", tag: "connection", peerId: o, connectionId: r, data: d.iceConnectionState });
1186
- }, icegatheringstatechange: (o, r, d) => {
1187
- this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${o}`), this.emitEvent({ event: "onicegatheringstatechange", tag: "connection", peerId: o, connectionId: r, data: d.iceGatheringState });
1188
- }, icecandidateerror: (o, r, d, u) => {
1182
+ }, signalingstatechange: (o, r, l) => {
1183
+ this.logger.debug(`[pc-event] signalingstatechange | peerId: ${o}`), this.emitEvent({ event: "onsignalingstatechange", tag: "connection", peerId: o, connectionId: r, data: { signalingState: l.signalingState, localDescription: l.localDescription, remoteDescription: l.remoteDescription } });
1184
+ }, iceconnectionstatechange: (o, r, l) => {
1185
+ this.logger.debug(`[pc-event] iceconnectionstatechange | peerId: ${o}`), this.emitEvent({ event: "oniceconnectionstatechange", tag: "connection", peerId: o, connectionId: r, data: l.iceConnectionState });
1186
+ }, icegatheringstatechange: (o, r, l) => {
1187
+ this.logger.debug(`[pc-event] icegatheringstatechange | peerId: ${o}`), this.emitEvent({ event: "onicegatheringstatechange", tag: "connection", peerId: o, connectionId: r, data: l.iceGatheringState });
1188
+ }, icecandidateerror: (o, r, l, u) => {
1189
1189
  this.logger.debug(`[pc-event] icecandidateerror | peerId: ${o}`), this.emitEvent({ event: "onicecandidateerror", tag: "connection", peerId: o, connectionId: r, error: { errorCode: u.errorCode } });
1190
- }, connectionstatechange: (o, r, d) => {
1191
- this.logger.debug(`[pc-event] connectionstatechange | peerId: ${o}`), this.emitEvent({ event: "onconnectionstatechange", tag: "connection", peerId: o, connectionId: r, data: d.connectionState });
1192
- }, negotiationneeded: (o, r, d) => {
1190
+ }, connectionstatechange: (o, r, l) => {
1191
+ this.logger.debug(`[pc-event] connectionstatechange | peerId: ${o}`), this.emitEvent({ event: "onconnectionstatechange", tag: "connection", peerId: o, connectionId: r, data: l.connectionState });
1192
+ }, negotiationneeded: (o, r, l) => {
1193
1193
  this.logger.debug(`[pc-event] negotiationneeded | peerId: ${o}`), this.emitEvent({ event: "onnegotiationneeded", tag: "connection", peerId: o, connectionId: r });
1194
- }, datachannel: (o, r, d, u) => {
1194
+ }, datachannel: (o, r, l, u) => {
1195
1195
  this.logger.debug(`[pc-event] datachannel | peerId: ${o}`, u), this.emitEvent({ event: "ondatachannel", tag: "datachannel", peerId: o, connectionId: r, data: u.channel });
1196
1196
  } };
1197
1197
  }
1198
- addPeerConnectionEventListeners(o, r, d) {
1198
+ addPeerConnectionEventListeners(o, r, l) {
1199
1199
  this.logger.debug(`Adding event listeners for peer ${o} and connection ${r}.`), S[r] = {}, Object.keys(this.peerConnectionListeners).forEach((u) => {
1200
- S[r][u] = this.peerConnectionListeners[u].bind(this, o, r, d), d.addEventListener(u, S[r][u], !1);
1200
+ S[r][u] = this.peerConnectionListeners[u].bind(this, o, r, l), l.addEventListener(u, S[r][u], !1);
1201
1201
  });
1202
1202
  }
1203
1203
  parseGetUserMedia(o) {
1204
1204
  try {
1205
1205
  const r = { event: "getUserMedia", tag: "getUserMedia", data: { ...o } };
1206
- o.stream && (r.data.details = this.parseStream(o.stream), o.stream.getTracks().map((d) => {
1207
- this.addTrackEventListeners(d), E.push(d);
1206
+ o.stream && (r.data.details = this.parseStream(o.stream), o.stream.getTracks().map((l) => {
1207
+ this.addTrackEventListeners(l), E.push(l);
1208
1208
  })), this.emitEvent(r);
1209
1209
  } catch {
1210
1210
  }
1211
1211
  }
1212
1212
  parseStream(o) {
1213
1213
  const r = { audio: [], video: [] };
1214
- return o.getTracks().forEach((d) => {
1215
- r[d.kind].push(this.getMediaTrackDetails(d));
1214
+ return o.getTracks().forEach((l) => {
1215
+ r[l.kind].push(this.getMediaTrackDetails(l));
1216
1216
  }), r;
1217
1217
  }
1218
1218
  getMediaTrackDetails(o) {
@@ -1234,9 +1234,9 @@ var Ae, sn = zt(function(t, e) {
1234
1234
  }
1235
1235
  addTrackEventListeners(o, r) {
1236
1236
  S[o.id] = {};
1237
- const d = this.getTrackEventObject(r);
1238
- Object.keys(d).forEach((u) => {
1239
- S[o.id][u] = d[u].bind(this), o.addEventListener(u, S[o.id][u]);
1237
+ const l = this.getTrackEventObject(r);
1238
+ Object.keys(l).forEach((u) => {
1239
+ S[o.id][u] = l[u].bind(this), o.addEventListener(u, S[o.id][u]);
1240
1240
  }), S[o.id].readyState = setInterval(() => {
1241
1241
  if (o.readyState === "ended") {
1242
1242
  let u = new CustomEvent("ended", { detail: { check: "readyState" } });
@@ -1247,8 +1247,8 @@ var Ae, sn = zt(function(t, e) {
1247
1247
  removeTrackEventListeners(o) {
1248
1248
  if (o.id in S) {
1249
1249
  const r = this.getTrackEventObject();
1250
- Object.keys(r).forEach((d) => {
1251
- o.removeEventListener(d, S[o.id][d]);
1250
+ Object.keys(r).forEach((l) => {
1251
+ o.removeEventListener(l, S[o.id][l]);
1252
1252
  }), clearInterval(S[o.id].readyState), delete S[o.id];
1253
1253
  }
1254
1254
  }
@@ -1267,12 +1267,12 @@ var Ae, sn = zt(function(t, e) {
1267
1267
  return Object.keys(this.peersToMonitor).length;
1268
1268
  }
1269
1269
  removePeerConnectionEventListeners(o, r) {
1270
- o in S && (Object.keys(this.peerConnectionListeners).forEach((d) => {
1271
- r.removeEventListener(d, S[o][d], !1);
1272
- }), delete S[o]), r.getSenders().forEach((d) => {
1273
- d.track && this.removeTrackEventListeners(d.track);
1274
- }), r.getReceivers().forEach((d) => {
1275
- d.track && this.removeTrackEventListeners(d.track);
1270
+ o in S && (Object.keys(this.peerConnectionListeners).forEach((l) => {
1271
+ r.removeEventListener(l, S[o][l], !1);
1272
+ }), delete S[o]), r.getSenders().forEach((l) => {
1273
+ l.track && this.removeTrackEventListeners(l.track);
1274
+ }), r.getReceivers().forEach((l) => {
1275
+ l.track && this.removeTrackEventListeners(l.track);
1276
1276
  });
1277
1277
  }
1278
1278
  getTimestamp() {
@@ -1281,14 +1281,14 @@ var Ae, sn = zt(function(t, e) {
1281
1281
  wrapGetDisplayMedia() {
1282
1282
  const o = this;
1283
1283
  if (navigator.mediaDevices && navigator.mediaDevices.getDisplayMedia) {
1284
- const r = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices), d = function() {
1284
+ const r = navigator.mediaDevices.getDisplayMedia.bind(navigator.mediaDevices), l = function() {
1285
1285
  return o.debug("navigator.mediaDevices.getDisplayMedia", null, arguments[0]), r.apply(navigator.mediaDevices, arguments).then(function(u) {
1286
1286
  return u;
1287
1287
  }, function(u) {
1288
1288
  return o.debug("navigator.mediaDevices.getDisplayMediaOnFailure", null, u.name), Promise.reject(u);
1289
1289
  });
1290
1290
  };
1291
- navigator.mediaDevices.getDisplayMedia = d.bind(navigator.mediaDevices);
1291
+ navigator.mediaDevices.getDisplayMedia = l.bind(navigator.mediaDevices);
1292
1292
  }
1293
1293
  }
1294
1294
  };
@@ -1302,7 +1302,7 @@ function Qn(t) {
1302
1302
  }({ rtt: s, jitter: i }), a = function(p) {
1303
1303
  const { packetsLost: f, packetsReceived: b } = p, C = f / (b + f) * 100;
1304
1304
  return 20 * Math.log(1 + C);
1305
- }({ packetsLost: e, packetsReceived: n }), l = 93.2 - c - a + 0, h = 1 + 0.035 * l + 7e-6 * l * (l - 60) * (100 - l);
1305
+ }({ packetsLost: e, packetsReceived: n }), d = 93.2 - c - a + 0, h = 1 + 0.035 * d + 7e-6 * d * (d - 60) * (100 - d);
1306
1306
  return Math.min(Math.max(h, 1), 5);
1307
1307
  }
1308
1308
  function Xn(t) {
@@ -1326,18 +1326,18 @@ class ti extends Te {
1326
1326
  function ni(t) {
1327
1327
  const e = pe(), n = new Kn({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), i = (s) => D(this, void 0, void 0, function* () {
1328
1328
  s.event === "stats" && U(O.StatsFrame, function({ data: c }) {
1329
- var a, l, h, p, f, b, C, I;
1330
- const { audio: w, remote: R } = c, { audio: m } = R, A = (l = (a = m.inbound[0]) === null || a === void 0 ? void 0 : a.jitter) !== null && l !== void 0 ? l : 1 / 0, M = (p = (h = m.inbound[0]) === null || h === void 0 ? void 0 : h.roundTripTime) !== null && p !== void 0 ? p : 1 / 0, x = (b = (f = w.inbound[0]) === null || f === void 0 ? void 0 : f.packetsReceived) !== null && b !== void 0 ? b : -1, V = (I = (C = w.inbound[0]) === null || C === void 0 ? void 0 : C.packetsLost) !== null && I !== void 0 ? I : -1, G = Qn({ jitter: 1e3 * A, rtt: 1e3 * M, packetsLost: V, packetsReceived: x });
1329
+ var a, d, h, p, f, b, C, I;
1330
+ const { audio: w, remote: R } = c, { audio: m } = R, A = (d = (a = m.inbound[0]) === null || a === void 0 ? void 0 : a.jitter) !== null && d !== void 0 ? d : 1 / 0, M = (p = (h = m.inbound[0]) === null || h === void 0 ? void 0 : h.roundTripTime) !== null && p !== void 0 ? p : 1 / 0, x = (b = (f = w.inbound[0]) === null || f === void 0 ? void 0 : f.packetsReceived) !== null && b !== void 0 ? b : -1, V = (I = (C = w.inbound[0]) === null || C === void 0 ? void 0 : C.packetsLost) !== null && I !== void 0 ? I : -1, G = Qn({ jitter: 1e3 * A, rtt: 1e3 * M, packetsLost: V, packetsReceived: x });
1331
1331
  return { jitter: A, rtt: M, mos: G, quality: Xn(G), inboundAudio: w.inbound[0], outboundAudio: w.outbound[0], remoteInboundAudio: m.inbound[0], remoteOutboundAudio: m.outbound[0] };
1332
1332
  }(s), t.uuid), yield t.execute(new ti(e, s));
1333
1333
  });
1334
1334
  return { start: (s, c, a) => D(this, void 0, void 0, function* () {
1335
- yield t.execute(new Zn(e)), n.on("timeline", i), yield new Promise((l) => setTimeout(l, 500)), n.addConnection({ pc: s, peerId: c, connectionId: a });
1335
+ yield t.execute(new Zn(e)), n.on("timeline", i), yield new Promise((d) => setTimeout(d, 500)), n.addConnection({ pc: s, peerId: c, connectionId: a });
1336
1336
  }), stop: (s) => D(this, void 0, void 0, function* () {
1337
1337
  const c = n.getTimeline();
1338
- U(O.StatsReport, c, t.uuid), s === "file" && function(a, l) {
1338
+ U(O.StatsReport, c, t.uuid), s === "file" && function(a, d) {
1339
1339
  const h = new Blob([JSON.stringify(a)], { type: "application/json" }), p = URL.createObjectURL(h), f = document.createElement("a");
1340
- f.href = p, f.download = `${l}.json`, f.click(), URL.revokeObjectURL(p);
1340
+ f.href = p, f.download = `${d}.json`, f.click(), URL.revokeObjectURL(p);
1341
1341
  }(c, `webrtc-stats-${e}-${Date.now()}`), yield t.execute(new ei(e)), n.removeAllPeers(), n.destroy();
1342
1342
  }) };
1343
1343
  }
@@ -1418,21 +1418,21 @@ class Rt {
1418
1418
  L.info("Local audio tracks: ", c);
1419
1419
  const a = i.getVideoTracks();
1420
1420
  if (L.info("Local video tracks: ", a), this.isOffer && typeof this.instance.addTransceiver == "function") {
1421
- const l = { direction: "sendrecv", streams: [i] };
1421
+ const d = { direction: "sendrecv", streams: [i] };
1422
1422
  c.forEach((h) => {
1423
1423
  this.options.userVariables.microphoneLabel = h.label;
1424
- const p = this.instance.addTransceiver(h, l);
1424
+ const p = this.instance.addTransceiver(h, d);
1425
1425
  this._setAudioCodec(p);
1426
- }), console.debug("Applying video transceiverParams", l), a.forEach((h) => {
1427
- this.options.userVariables.cameraLabel = h.label, this.instance.addTransceiver(h, l);
1426
+ }), console.debug("Applying video transceiverParams", d), a.forEach((h) => {
1427
+ this.options.userVariables.cameraLabel = h.label, this.instance.addTransceiver(h, d);
1428
1428
  });
1429
- } else typeof this.instance.addTrack == "function" ? (c.forEach((l) => {
1430
- this.options.userVariables.microphoneLabel = l.label, this.instance.addTrack(l, i);
1431
- }), this.instance.getTransceivers().forEach((l) => this._setAudioCodec(l)), a.forEach((l) => {
1432
- this.options.userVariables.cameraLabel = l.label, this.instance.addTrack(l, i);
1429
+ } else typeof this.instance.addTrack == "function" ? (c.forEach((d) => {
1430
+ this.options.userVariables.microphoneLabel = d.label, this.instance.addTrack(d, i);
1431
+ }), this.instance.getTransceivers().forEach((d) => this._setAudioCodec(d)), a.forEach((d) => {
1432
+ this.options.userVariables.cameraLabel = d.label, this.instance.addTrack(d, i);
1433
1433
  })) : this.instance.addStream(i);
1434
- s === !1 && (((l) => {
1435
- const h = Ce(l);
1434
+ s === !1 && (((d) => {
1435
+ const h = Ce(d);
1436
1436
  h && (h.muted = !0);
1437
1437
  })(n), Pe(n, i));
1438
1438
  }
@@ -1470,10 +1470,10 @@ class Rt {
1470
1470
  _setLocalDescription(e) {
1471
1471
  return D(this, void 0, void 0, function* () {
1472
1472
  const { useStereo: n, googleMaxBitrate: i, googleMinBitrate: s, googleStartBitrate: c, mediaSettings: a } = this.options;
1473
- n && (e.sdp = ((l) => {
1474
- const p = l.split(`\r
1473
+ n && (e.sdp = ((d) => {
1474
+ const p = d.split(`\r
1475
1475
  `), f = p.findIndex((w) => /^a=rtpmap/.test(w) && /opus\/48000/.test(w));
1476
- if (f < 0) return l;
1476
+ if (f < 0) return d;
1477
1477
  const b = ((w) => {
1478
1478
  const R = new RegExp("a=rtpmap:(\\d+) \\w+\\/\\d+"), m = w.match(R);
1479
1479
  return m && m.length == 2 ? m[1] : null;
@@ -1481,19 +1481,19 @@ class Rt {
1481
1481
  return I >= 0 ? /stereo=1;/.test(p[I]) || (p[I] += "; stereo=1; sprop-stereo=1") : p[f] += `\r
1482
1482
  a=fmtp:${b} stereo=1; sprop-stereo=1`, p.join(`\r
1483
1483
  `);
1484
- })(e.sdp)), i && s && c && (e.sdp = ((l, h, p, f) => {
1485
- const b = l.split(`\r
1484
+ })(e.sdp)), i && s && c && (e.sdp = ((d, h, p, f) => {
1485
+ const b = d.split(`\r
1486
1486
  `);
1487
1487
  return b.forEach((C, I) => {
1488
1488
  /^a=fmtp:\d*/.test(C) ? b[I] += `;x-google-max-bitrate=${h};x-google-min-bitrate=${p};x-google-start-bitrate=${f}` : /^a=mid:(1|video)/.test(C) && (b[I] += `\r
1489
1489
  b=AS:${h}`);
1490
1490
  }), b.join(`\r
1491
1491
  `);
1492
- })(e.sdp, i, s, c)), a && a.useSdpASBandwidthKbps && a.sdpASBandwidthKbps !== null && (e.sdp = ((l, h) => {
1492
+ })(e.sdp, i, s, c)), a && a.useSdpASBandwidthKbps && a.sdpASBandwidthKbps !== null && (e.sdp = ((d, h) => {
1493
1493
  let p = "AS", f = h;
1494
- return !navigator.userAgent.match(/firefox/gim) || navigator.userAgent.match(/OPR\/[0-9]{2}/gi) || navigator.userAgent.match(/edg/gim) || (p = "TIAS", f = 1e3 * (h >>> 0)), l.indexOf("b=" + p + ":") === -1 ? l.replace(/c=IN (.*)\r\n/, `c=IN $1\r
1494
+ return !navigator.userAgent.match(/firefox/gim) || navigator.userAgent.match(/OPR\/[0-9]{2}/gi) || navigator.userAgent.match(/edg/gim) || (p = "TIAS", f = 1e3 * (h >>> 0)), d.indexOf("b=" + p + ":") === -1 ? d.replace(/c=IN (.*)\r\n/, `c=IN $1\r
1495
1495
  b=` + p + ":" + f + `\r
1496
- `) : l.replace(new RegExp("b=" + p + `:.*\r
1496
+ `) : d.replace(new RegExp("b=" + p + `:.*\r
1497
1497
  `), "b=" + p + ":" + f + `\r
1498
1498
  `);
1499
1499
  })(e.sdp, a.sdpASBandwidthKbps)), yield this.instance.setLocalDescription(e);
@@ -1509,9 +1509,9 @@ b=` + p + ":" + f + `\r
1509
1509
  let { audio: i = !0, micId: s } = n;
1510
1510
  const { micLabel: c = "" } = n;
1511
1511
  s && (s = yield Ue(s, c, se.AudioIn).catch((p) => null), s && (typeof i == "boolean" && (i = {}), i.deviceId = { exact: s }));
1512
- let { camId: a } = n, l = n.video;
1512
+ let { camId: a } = n, d = n.video;
1513
1513
  const { camLabel: h = "" } = n;
1514
- return a && (a = yield Ue(a, h, se.Video).catch((p) => null), a && (typeof l == "boolean" && (l = {}), l.deviceId = { exact: a })), { audio: i, video: l };
1514
+ return a && (a = yield Ue(a, h, se.Video).catch((p) => null), a && (typeof d == "boolean" && (d = {}), d.deviceId = { exact: a })), { audio: i, video: d };
1515
1515
  }));
1516
1516
  var n;
1517
1517
  return je(e);
@@ -1534,7 +1534,7 @@ b=` + p + ":" + f + `\r
1534
1534
  });
1535
1535
  }
1536
1536
  }
1537
- const ii = dt;
1537
+ const ii = lt;
1538
1538
  class on {
1539
1539
  constructor(e, n) {
1540
1540
  this.session = e, this.id = "", this.state = j[j.New], this.prevState = "", this.channels = [], this.role = Se.Participant, this.extension = null, this._state = j.New, this._prevState = j.New, this.gotAnswer = !1, this.gotEarly = !1, this._lastSerno = 0, this._targetNodeId = null, this._iceTimeout = null, this._iceDone = !1, this._statsBindings = [], this._statsIntervalId = null, this._checkConferenceSerno = (m) => {
@@ -1554,8 +1554,8 @@ class on {
1554
1554
  });
1555
1555
  });
1556
1556
  };
1557
- const { iceServers: i, speaker: s, micId: c, micLabel: a, camId: l, camLabel: h, localElement: p, remoteElement: f, options: b, mediaConstraints: { audio: C, video: I }, ringtoneFile: w, ringbackFile: R } = e;
1558
- this.options = Object.assign({}, xn, { audio: C, video: I, iceServers: i, localElement: p, remoteElement: f, micId: c, micLabel: a, camId: l, camLabel: h, speakerId: s, ringtoneFile: w, ringbackFile: R, debug: b.debug, debugOutput: b.debugOutput }, n), this._onMediaError = this._onMediaError.bind(this), this._init(), this.options && (this._ringtone = It(this.options.ringtoneFile, "_ringtone"), this._ringback = It(this.options.ringbackFile, "_ringback"));
1557
+ const { iceServers: i, speaker: s, micId: c, micLabel: a, camId: d, camLabel: h, localElement: p, remoteElement: f, options: b, mediaConstraints: { audio: C, video: I }, ringtoneFile: w, ringbackFile: R } = e;
1558
+ this.options = Object.assign({}, xn, { audio: C, video: I, iceServers: i, localElement: p, remoteElement: f, micId: c, micLabel: a, camId: d, camLabel: h, speakerId: s, ringtoneFile: w, ringbackFile: R, debug: b.debug, debugOutput: b.debugOutput }, n), this._onMediaError = this._onMediaError.bind(this), this._init(), this.options && (this._ringtone = It(this.options.ringtoneFile, "_ringtone"), this._ringback = It(this.options.ringbackFile, "_ringback"));
1559
1559
  }
1560
1560
  get nodeId() {
1561
1561
  return this._targetNodeId;
@@ -1596,13 +1596,13 @@ class on {
1596
1596
  }
1597
1597
  hangup(e, n) {
1598
1598
  var i, s, c;
1599
- let a = e || {}, l = n !== !1;
1599
+ let a = e || {}, d = n !== !1;
1600
1600
  this.cause = a.cause || "NORMAL_CLEARING", this.causeCode = a.causeCode || 16, this.sipCode = a.sipCode || null, this.sipReason = a.sipReason || null, this.sipCallId = a.sip_call_id || null, this.options.customHeaders = [...(i = this.options.customHeaders) !== null && i !== void 0 ? i : [], ...(c = (s = a?.dialogParams) === null || s === void 0 ? void 0 : s.customHeaders) !== null && c !== void 0 ? c : []], this.setState(j.Hangup);
1601
1601
  const h = () => {
1602
1602
  var p;
1603
1603
  return (p = this.peer) === null || p === void 0 || p.close(), this.setState(j.Destroy);
1604
1604
  };
1605
- if (this.stopRingtone(), this.stopRingback(), l) {
1605
+ if (this.stopRingtone(), this.stopRingback(), d) {
1606
1606
  const p = new Wn({ sessid: this.session.sessionid, dialogParams: this.options, cause: "USER_BUSY", causeCode: 17 });
1607
1607
  this._execute(p).catch((f) => {
1608
1608
  L.error("telnyx_rtc.bye failed!", f), U(O.Error, { error: f, sessionId: this.session.sessionid }, this.session.uuid);
@@ -1645,7 +1645,7 @@ class on {
1645
1645
  const s = yield nt({ audio: { deviceId: { exact: e } } }), c = s.getAudioTracks()[0];
1646
1646
  i.replaceTrack(c), this.options.micId = e;
1647
1647
  const { localStream: a } = this.options;
1648
- a.getAudioTracks().forEach((l) => l.stop()), a.getVideoTracks().forEach((l) => s.addTrack(l)), this.options.localStream = s;
1648
+ a.getAudioTracks().forEach((d) => d.stop()), a.getVideoTracks().forEach((d) => s.addTrack(d)), this.options.localStream = s;
1649
1649
  }
1650
1650
  });
1651
1651
  }
@@ -1667,8 +1667,8 @@ class on {
1667
1667
  if (i) {
1668
1668
  const s = yield nt({ video: { deviceId: { exact: e } } }), c = s.getVideoTracks()[0];
1669
1669
  i.replaceTrack(c);
1670
- const { localElement: a, localStream: l } = this.options;
1671
- Pe(a, s), this.options.camId = e, l.getAudioTracks().forEach((h) => s.addTrack(h)), l.getVideoTracks().forEach((h) => h.stop()), this.options.localStream = s;
1670
+ const { localElement: a, localStream: d } = this.options;
1671
+ Pe(a, s), this.options.camId = e, d.getAudioTracks().forEach((h) => s.addTrack(h)), d.getVideoTracks().forEach((h) => h.stop()), this.options.localStream = s;
1672
1672
  }
1673
1673
  });
1674
1674
  }
@@ -1691,7 +1691,7 @@ class on {
1691
1691
  const a = c.getParameters();
1692
1692
  a.encodings || (a.encodings = [{ rid: "h" }]), L.info("Parameters: ", a), L.info("Setting max ", n === "audio" ? "audio" : "video", " bandwidth to: ", e, " [bps]"), a.encodings[0].maxBitrate = e, yield c.setParameters(a).then(() => {
1693
1693
  L.info(n === "audio" ? "New audio" : "New video", " bandwidth settings in use: ", c.getParameters());
1694
- }).catch((l) => console.error(l));
1694
+ }).catch((d) => console.error(d));
1695
1695
  } else L.error("Could not set bandwidth (reason: no " + n + " sender). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
1696
1696
  });
1697
1697
  }
@@ -1734,9 +1734,9 @@ class on {
1734
1734
  break;
1735
1735
  case F.Display:
1736
1736
  case F.Attach: {
1737
- const { display_name: c, display_number: a, display_direction: l } = i;
1737
+ const { display_name: c, display_number: a, display_direction: d } = i;
1738
1738
  this.extension = a;
1739
- const h = l === re.Inbound ? re.Outbound : re.Inbound, p = { type: ie[n], call: this, displayName: c, displayNumber: a, displayDirection: h };
1739
+ const h = d === re.Inbound ? re.Outbound : re.Inbound, p = { type: ie[n], call: this, displayName: c, displayNumber: a, displayDirection: h };
1740
1740
  U(O.Notification, p, this.id) || U(O.Notification, p, this.session.uuid);
1741
1741
  break;
1742
1742
  }
@@ -1761,8 +1761,8 @@ class on {
1761
1761
  switch (i) {
1762
1762
  case "bootObj": {
1763
1763
  this._lastSerno = 0;
1764
- const { chatChannel: l, infoChannel: h, modChannel: p, laName: f, conferenceMemberID: b, role: C } = n;
1765
- this._dispatchConferenceUpdate({ action: Q.Join, conferenceName: f, participantId: Number(b), role: C }), l && (yield this._subscribeConferenceChat(l)), h && (yield this._subscribeConferenceInfo(h)), p && C === Se.Moderator && (yield this._subscribeConferenceModerator(p));
1764
+ const { chatChannel: d, infoChannel: h, modChannel: p, laName: f, conferenceMemberID: b, role: C } = n;
1765
+ this._dispatchConferenceUpdate({ action: Q.Join, conferenceName: f, participantId: Number(b), role: C }), d && (yield this._subscribeConferenceChat(d)), h && (yield this._subscribeConferenceInfo(h)), p && C === Se.Moderator && (yield this._subscribeConferenceModerator(p));
1766
1766
  const I = [];
1767
1767
  for (const w in s) I.push(Object.assign({ callId: s[w][0], index: Number(w) }, xe(s[w][1])));
1768
1768
  this._dispatchConferenceUpdate({ action: Q.Bootstrap, participants: I });
@@ -1793,8 +1793,8 @@ class on {
1793
1793
  _subscribeConferenceChat(e) {
1794
1794
  return D(this, void 0, void 0, function* () {
1795
1795
  const n = { nodeId: this.nodeId, channels: [e], handler: (s) => {
1796
- const { direction: c, from: a, fromDisplay: l, message: h, type: p } = s.data;
1797
- this._dispatchConferenceUpdate({ action: Q.ChatMessage, direction: c, participantNumber: a, participantName: l, messageText: h, messageType: p, messageId: s.eventSerno });
1796
+ const { direction: c, from: a, fromDisplay: d, message: h, type: p } = s.data;
1797
+ this._dispatchConferenceUpdate({ action: Q.ChatMessage, direction: c, participantNumber: a, participantName: d, messageText: h, messageType: p, messageId: s.eventSerno });
1798
1798
  } }, i = yield this.session.vertoSubscribe(n).catch((s) => {
1799
1799
  L.error("ConfChat subscription error:", s);
1800
1800
  });
@@ -1820,20 +1820,20 @@ class on {
1820
1820
  }
1821
1821
  _subscribeConferenceModerator(e) {
1822
1822
  return D(this, void 0, void 0, function* () {
1823
- const n = (a, l = null, h = null) => {
1824
- const p = parseInt(l) || null;
1823
+ const n = (a, d = null, h = null) => {
1824
+ const p = parseInt(d) || null;
1825
1825
  this._confControl(e, { command: a, id: p, value: h });
1826
1826
  }, i = () => {
1827
1827
  const { video: a } = this.options;
1828
1828
  if (typeof a == "boolean" && !a || typeof a == "object" && ft(a)) throw `Conference ${this.id} has no video!`;
1829
1829
  }, s = { nodeId: this.nodeId, channels: [e], handler: (a) => {
1830
- const { data: l } = a;
1831
- if (l["conf-command"] === "list-videoLayouts") {
1832
- if (l.responseData) {
1833
- const h = JSON.stringify(l.responseData).replace(/IDS"/g, 'Ids"');
1830
+ const { data: d } = a;
1831
+ if (d["conf-command"] === "list-videoLayouts") {
1832
+ if (d.responseData) {
1833
+ const h = JSON.stringify(d.responseData).replace(/IDS"/g, 'Ids"');
1834
1834
  this._dispatchConferenceUpdate({ action: Q.LayoutList, layouts: JSON.parse(h) });
1835
1835
  }
1836
- } else this._dispatchConferenceUpdate({ action: Q.ModCmdResponse, command: l["conf-command"], response: l.response });
1836
+ } else this._dispatchConferenceUpdate({ action: Q.ModCmdResponse, command: d["conf-command"], response: d.response });
1837
1837
  } }, c = yield this.session.vertoSubscribe(s).catch((a) => {
1838
1838
  L.error("ConfMod subscription error:", a);
1839
1839
  });
@@ -1853,8 +1853,8 @@ class on {
1853
1853
  n("recording", null, ["stop", "all"]);
1854
1854
  } }, snapshot: { configurable: !0, value: (a) => {
1855
1855
  i(), n("vid-write-png", null, a);
1856
- } }, setVideoLayout: { configurable: !0, value: (a, l) => {
1857
- i(), n("vid-layout", null, l ? [a, l] : a);
1856
+ } }, setVideoLayout: { configurable: !0, value: (a, d) => {
1857
+ i(), n("vid-layout", null, d ? [a, d] : a);
1858
1858
  } }, kick: { configurable: !0, value: (a) => {
1859
1859
  n("kick", a);
1860
1860
  } }, muteMic: { configurable: !0, value: (a) => {
@@ -1865,8 +1865,8 @@ class on {
1865
1865
  i(), n("vid-res-id", a, "presenter");
1866
1866
  } }, videoFloor: { configurable: !0, value: (a) => {
1867
1867
  i(), n("vid-floor", a, "force");
1868
- } }, banner: { configurable: !0, value: (a, l) => {
1869
- i(), n("vid-banner", a, encodeURI(l));
1868
+ } }, banner: { configurable: !0, value: (a, d) => {
1869
+ i(), n("vid-banner", a, encodeURI(d));
1870
1870
  } }, volumeDown: { configurable: !0, value: (a) => {
1871
1871
  n("volume_out", a, "down");
1872
1872
  } }, volumeUp: { configurable: !0, value: (a) => {
@@ -1875,8 +1875,8 @@ class on {
1875
1875
  n("volume_in", a, "down");
1876
1876
  } }, gainUp: { configurable: !0, value: (a) => {
1877
1877
  n("volume_in", a, "up");
1878
- } }, transfer: { configurable: !0, value: (a, l) => {
1879
- n("transfer", a, l);
1878
+ } }, transfer: { configurable: !0, value: (a, d) => {
1879
+ n("transfer", a, d);
1880
1880
  } } }));
1881
1881
  });
1882
1882
  }
@@ -1907,13 +1907,13 @@ class on {
1907
1907
  `), void this._requestAnotherLocalDescription();
1908
1908
  (i = (n = this.peer) === null || n === void 0 ? void 0 : n.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce);
1909
1909
  let a = null;
1910
- const l = { sessid: this.session.sessionid, sdp: s, dialogParams: this.options, "User-Agent": `Web-${ii}` };
1910
+ const d = { sessid: this.session.sessionid, sdp: s, dialogParams: this.options, "User-Agent": `Web-${ii}` };
1911
1911
  switch (c) {
1912
1912
  case te.Offer:
1913
- this.setState(j.Requesting), a = new Fn(l);
1913
+ this.setState(j.Requesting), a = new Fn(d);
1914
1914
  break;
1915
1915
  case te.Answer:
1916
- this.setState(j.Answering), a = this.options.attach === !0 ? new Bn(l) : new Gn(l);
1916
+ this.setState(j.Answering), a = this.options.attach === !0 ? new Bn(d) : new Gn(d);
1917
1917
  break;
1918
1918
  default:
1919
1919
  return L.error(`${this.id} - Unknown local SDP type:`, e), this.hangup({}, !1);
@@ -1955,7 +1955,7 @@ class on {
1955
1955
  }
1956
1956
  _init() {
1957
1957
  const { id: e, userVariables: n, remoteCallerNumber: i, onNotification: s } = this.options;
1958
- e || (this.options.id = pe()), this.id = this.options.id, n && !ft(n) || (this.options.userVariables = this.session.options.userVariables || {}), i || (this.options.remoteCallerNumber = this.options.destinationNumber), this.session.calls[this.id] = this, le(O.MediaError, this._onMediaError, this.id), fe(s) && le(O.Notification, s.bind(this), this.id), this.setState(j.New), L.info("New Call with Options:", this.options);
1958
+ e || (this.options.id = pe()), this.id = this.options.id, n && !ft(n) || (this.options.userVariables = this.session.options.userVariables || {}), i || (this.options.remoteCallerNumber = this.options.destinationNumber), this.session.calls[this.id] = this, de(O.MediaError, this._onMediaError, this.id), fe(s) && de(O.Notification, s.bind(this), this.id), this.setState(j.New), L.info("New Call with Options:", this.options);
1959
1959
  }
1960
1960
  _finalize() {
1961
1961
  this._stopStats(), this.peer && this.peer.instance && (this.peer.instance.close(), this.peer = null);
@@ -1999,7 +1999,7 @@ on.setStateTelnyx = (t) => {
1999
1999
  };
2000
2000
  class ae extends on {
2001
2001
  constructor() {
2002
- super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e) => this.session.execute(new Jn(e));
2002
+ super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, n) => this.session.execute(new Jn(e, n));
2003
2003
  }
2004
2004
  hangup(e = {}, n = !0) {
2005
2005
  this.screenShare instanceof ae && this.screenShare.hangup(e, n), super.hangup(e, n);
@@ -2013,7 +2013,7 @@ class ae extends on {
2013
2013
  this.screenShare && this.screenShare.hangup();
2014
2014
  });
2015
2015
  });
2016
- const { remoteCallerName: s, remoteCallerNumber: c, callerName: a, callerNumber: l } = this.options, h = Object.assign({ screenShare: !0, localStream: n, destinationNumber: `${this.extension}-screen`, remoteCallerName: s, remoteCallerNumber: `${c}-screen`, callerName: `${a} (Screen)`, callerNumber: `${l} (Screen)` }, e);
2016
+ const { remoteCallerName: s, remoteCallerNumber: c, callerName: a, callerNumber: d } = this.options, h = Object.assign({ screenShare: !0, localStream: n, destinationNumber: `${this.extension}-screen`, remoteCallerName: s, remoteCallerNumber: `${c}-screen`, callerName: `${a} (Screen)`, callerNumber: `${d} (Screen)` }, e);
2017
2017
  return this.screenShare = new ae(this.session, h), this.screenShare.invite(), this.screenShare;
2018
2018
  });
2019
2019
  }
@@ -2039,8 +2039,8 @@ class ae extends on {
2039
2039
  n.forEach((a) => {
2040
2040
  s.includes(a.type) || (i += `
2041
2041
  ${a.type}
2042
- `, Object.keys(a).forEach((l) => {
2043
- c.includes(l) || (i += ` ${l}: ${a[l]}
2042
+ `, Object.keys(a).forEach((d) => {
2043
+ c.includes(d) || (i += ` ${d}: ${a[d]}
2044
2044
  `);
2045
2045
  }));
2046
2046
  }), L.info(i);
@@ -2082,8 +2082,8 @@ class si extends Pn {
2082
2082
  speedTest(e) {
2083
2083
  return new Promise((n, i) => {
2084
2084
  if (Xt(O.SpeedTest, (a) => {
2085
- const { upDur: l, downDur: h } = a, p = h ? 8 * e / (h / 1e3) / 1024 : 0;
2086
- n({ upDur: l, downDur: h, upKps: (l ? 8 * e / (l / 1e3) / 1024 : 0).toFixed(0), downKps: p.toFixed(0) });
2085
+ const { upDur: d, downDur: h } = a, p = h ? 8 * e / (h / 1e3) / 1024 : 0;
2086
+ n({ upDur: d, downDur: h, upKps: (d ? 8 * e / (d / 1e3) / 1024 : 0).toFixed(0), downKps: p.toFixed(0) });
2087
2087
  }, this.uuid), !(e = Number(e))) return i(`Invalid parameter 'bytes': ${e}`);
2088
2088
  this.executeRaw(`#SPU ${e}`);
2089
2089
  let s = e / 1024;
@@ -2114,8 +2114,8 @@ class si extends Pn {
2114
2114
  return yield ((n) => D(void 0, void 0, void 0, function* () {
2115
2115
  const i = [], s = yield je({ video: { deviceId: { exact: n } } }), c = s.getVideoTracks()[0];
2116
2116
  for (let a = 0; a < bt.length; a++) {
2117
- const [l, h] = bt[a];
2118
- (yield c.applyConstraints({ width: { exact: l }, height: { exact: h } }).then(() => !0).catch(() => !1)) && i.push({ resolution: `${l}x${h}`, width: l, height: h });
2117
+ const [d, h] = bt[a];
2118
+ (yield c.applyConstraints({ width: { exact: d }, height: { exact: h } }).then(() => !0).catch(() => !1)) && i.push({ resolution: `${d}x${h}`, width: d, height: h });
2119
2119
  }
2120
2120
  return Ie(s), i;
2121
2121
  }))(e);
@@ -2188,17 +2188,17 @@ class si extends Pn {
2188
2188
  if (!(n = n.filter((h) => h && !this._existsSubscription(this.relayProtocol, h))).length) return {};
2189
2189
  const s = new Yn({ sessid: this.sessionid, eventChannel: n });
2190
2190
  e && (s.targetNodeId = e);
2191
- const c = yield this.execute(s), { unauthorized: a = [], subscribed: l = [] } = it(c);
2192
- return a.length && a.forEach((h) => this._removeSubscription(this.relayProtocol, h)), l.forEach((h) => this._addSubscription(this.relayProtocol, i, h)), c;
2191
+ const c = yield this.execute(s), { unauthorized: a = [], subscribed: d = [] } = it(c);
2192
+ return a.length && a.forEach((h) => this._removeSubscription(this.relayProtocol, h)), d.forEach((h) => this._addSubscription(this.relayProtocol, i, h)), c;
2193
2193
  });
2194
2194
  }
2195
2195
  vertoUnsubscribe({ nodeId: e, channels: n = [] }) {
2196
2196
  return D(this, void 0, void 0, function* () {
2197
- if (!(n = n.filter((l) => l && this._existsSubscription(this.relayProtocol, l))).length) return {};
2197
+ if (!(n = n.filter((d) => d && this._existsSubscription(this.relayProtocol, d))).length) return {};
2198
2198
  const i = new zn({ sessid: this.sessionid, eventChannel: n });
2199
2199
  e && (i.targetNodeId = e);
2200
2200
  const s = yield this.execute(i), { unsubscribed: c = [], notSubscribed: a = [] } = it(s);
2201
- return c.forEach((l) => this._removeSubscription(this.relayProtocol, l)), a.forEach((l) => this._removeSubscription(this.relayProtocol, l)), s;
2201
+ return c.forEach((d) => this._removeSubscription(this.relayProtocol, d)), a.forEach((d) => this._removeSubscription(this.relayProtocol, d)), s;
2202
2202
  });
2203
2203
  }
2204
2204
  static telnyxStateCall(e) {
@@ -2227,7 +2227,7 @@ class ne {
2227
2227
  return 1e3 * Kt(2, 6);
2228
2228
  }
2229
2229
  handleMessage(e) {
2230
- const { session: n } = this, { id: i, method: s, params: c = {} } = e, a = c?.callID, l = c?.eventChannel, h = c?.eventType, p = s === F.Attach;
2230
+ const { session: n } = this, { id: i, method: s, params: c = {} } = e, a = c?.callID, d = c?.eventChannel, h = c?.eventType, p = s === F.Attach;
2231
2231
  if (h === "channelPvtData") return this._handlePvtEvent(c.pvtData);
2232
2232
  if (a && n.calls.hasOwnProperty(a)) {
2233
2233
  if (!p) return n.calls[a].handleMessage(e), void this._ack(i, s);
@@ -2259,9 +2259,9 @@ class ne {
2259
2259
  }
2260
2260
  case F.Event:
2261
2261
  case "webrtc.event":
2262
- if (!l) return void L.error("Verto received an unknown event:", c);
2263
- const I = n.relayProtocol, w = l.split(".")[0];
2264
- n._existsSubscription(I, l) ? U(I, c, l) : l === n.sessionid ? this._handleSessionEvent(c.eventData) : n._existsSubscription(I, w) ? U(I, c, w) : n.calls.hasOwnProperty(l) ? n.calls[l].handleMessage(e) : U(O.Notification, c, n.uuid);
2262
+ if (!d) return void L.error("Verto received an unknown event:", c);
2263
+ const I = n.relayProtocol, w = d.split(".")[0];
2264
+ n._existsSubscription(I, d) ? U(I, c, d) : d === n.sessionid ? this._handleSessionEvent(c.eventData) : n._existsSubscription(I, w) ? U(I, c, w) : n.calls.hasOwnProperty(d) ? n.calls[d].handleMessage(e) : U(O.Notification, c, n.uuid);
2265
2265
  break;
2266
2266
  case F.Info:
2267
2267
  c.type = ie.generic, U(O.Notification, c, n.uuid);
@@ -2325,7 +2325,7 @@ class ne {
2325
2325
  }
2326
2326
  _handlePvtEvent(e) {
2327
2327
  return D(this, void 0, void 0, function* () {
2328
- const { session: n } = this, i = n.relayProtocol, { action: s, laChannel: c, laName: a, chatChannel: l, infoChannel: h, modChannel: p, conferenceMemberID: f, role: b, callID: C } = e;
2328
+ const { session: n } = this, i = n.relayProtocol, { action: s, laChannel: c, laName: a, chatChannel: d, infoChannel: h, modChannel: p, conferenceMemberID: f, role: b, callID: C } = e;
2329
2329
  switch (s) {
2330
2330
  case "conference-liveArray-join": {
2331
2331
  const I = () => {
@@ -2353,7 +2353,7 @@ class ne {
2353
2353
  U(O.Notification, m, R, !1) || U(O.Notification, m, n.uuid), I === null && ue(O.Notification, null, R);
2354
2354
  }
2355
2355
  }
2356
- const w = [c, l, h, p];
2356
+ const w = [c, d, h, p];
2357
2357
  n.vertoUnsubscribe({ nodeId: this.nodeId, channels: w }).then(({ unsubscribedChannels: R = [] }) => {
2358
2358
  I && (I.channels = I.channels.filter((m) => !R.includes(m)));
2359
2359
  }).catch((R) => {
@@ -2382,7 +2382,7 @@ ne.retriedConnect = 0, ne.retriedRegister = 0;
2382
2382
  class ri extends Z {
2383
2383
  constructor(e) {
2384
2384
  super(), this.method = "anonymous_login";
2385
- const { target_type: n, target_id: i, target_version_id: s, userVariables: c, sessionId: a, reconnection: l } = e, h = { target_type: n, target_id: i, userVariables: c, reconnection: l, "User-Agent": { sdkVersion: dt, data: navigator.userAgent } };
2385
+ const { target_type: n, target_id: i, target_version_id: s, userVariables: c, sessionId: a, reconnection: d } = e, h = { target_type: n, target_id: i, userVariables: c, reconnection: d, "User-Agent": { sdkVersion: lt, data: navigator.userAgent } };
2386
2386
  a && (h.sessid = a), s && (h.target_version_id = s), this.buildRequest({ method: this.method, params: h });
2387
2387
  }
2388
2388
  }
@@ -2390,8 +2390,8 @@ class ai extends si {
2390
2390
  constructor(e) {
2391
2391
  super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => D(this, void 0, void 0, function* () {
2392
2392
  this._idle = !1;
2393
- const { login: n, password: i, passwd: s, login_token: c, userVariables: a, autoReconnect: l = !0 } = this.options, h = new $n(n, i || s, c, this.sessionid, a, !!tt()), p = yield this.execute(h).catch(this._handleLoginError);
2394
- p && (this._autoReconnect = l, this.sessionid = p.sessid);
2393
+ const { login: n, password: i, passwd: s, login_token: c, userVariables: a, autoReconnect: d = !0 } = this.options, h = new $n(n, i || s, c, this.sessionid, a, !!tt()), p = yield this.execute(h).catch(this._handleLoginError);
2394
+ p && (this._autoReconnect = d, this.sessionid = p.sessid);
2395
2395
  }), this.handleAnonymousLoginOnSocketOpen = () => D(this, void 0, void 0, function* () {
2396
2396
  this._idle = !1;
2397
2397
  const { anonymous_login: n } = this.options, i = new ri({ target_id: n.target_id, target_type: n.target_type, target_version_id: n.target_version_id, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!tt() }), s = yield this.execute(i).catch(this._handleLoginError);
@@ -2446,11 +2446,11 @@ class ci extends ai {
2446
2446
  return [{ operationSystem: "Android", supported: [{ browserName: "Chrome", features: ["audio"], supported: q.full }, { browserName: "Firefox", features: ["audio"], supported: q.partial }, { browserName: "Safari", supported: q.not_supported }, { browserName: "Edge", supported: q.not_supported }] }, { operationSystem: "iOS", supported: [{ browserName: "Chrome", supported: q.not_supported }, { browserName: "Firefox", supported: q.not_supported }, { browserName: "Safari", features: ["video", "audio"], supported: q.full }, { browserName: "Edge", supported: q.not_supported }] }, { operationSystem: "Linux", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: q.full }, { browserName: "Firefox", features: ["audio"], supported: q.partial }, { browserName: "Safari", supported: q.not_supported }, { browserName: "Edge", supported: q.not_supported }] }, { operationSystem: "MacOS", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: q.full }, { browserName: "Firefox", features: ["audio"], supported: q.partial }, { browserName: "Safari", features: ["video", "audio"], supported: q.full }, { browserName: "Edge", features: ["audio"], supported: q.partial }] }, { operationSystem: "Windows", supported: [{ browserName: "Chrome", features: ["video", "audio"], supported: q.full }, { browserName: "Firefox", features: ["audio"], supported: q.partial }, { browserName: "Safari", supported: q.not_supported }, { browserName: "Edge", features: ["audio"], supported: q.partial }] }];
2447
2447
  }
2448
2448
  }
2449
- function di(t) {
2449
+ function li(t) {
2450
2450
  return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
2451
2451
  }
2452
2452
  var Je = { exports: {} }, At;
2453
- function li() {
2453
+ function di() {
2454
2454
  return At || (At = 1, function(t) {
2455
2455
  var e = Object.prototype.hasOwnProperty, n = "~";
2456
2456
  function i() {
@@ -2468,26 +2468,26 @@ function li() {
2468
2468
  function a(h, p) {
2469
2469
  --h._eventsCount === 0 ? h._events = new i() : delete h._events[p];
2470
2470
  }
2471
- function l() {
2471
+ function d() {
2472
2472
  this._events = new i(), this._eventsCount = 0;
2473
2473
  }
2474
- l.prototype.eventNames = function() {
2474
+ d.prototype.eventNames = function() {
2475
2475
  var p = [], f, b;
2476
2476
  if (this._eventsCount === 0) return p;
2477
2477
  for (b in f = this._events)
2478
2478
  e.call(f, b) && p.push(n ? b.slice(1) : b);
2479
2479
  return Object.getOwnPropertySymbols ? p.concat(Object.getOwnPropertySymbols(f)) : p;
2480
- }, l.prototype.listeners = function(p) {
2480
+ }, d.prototype.listeners = function(p) {
2481
2481
  var f = n ? n + p : p, b = this._events[f];
2482
2482
  if (!b) return [];
2483
2483
  if (b.fn) return [b.fn];
2484
2484
  for (var C = 0, I = b.length, w = new Array(I); C < I; C++)
2485
2485
  w[C] = b[C].fn;
2486
2486
  return w;
2487
- }, l.prototype.listenerCount = function(p) {
2487
+ }, d.prototype.listenerCount = function(p) {
2488
2488
  var f = n ? n + p : p, b = this._events[f];
2489
2489
  return b ? b.fn ? 1 : b.length : 0;
2490
- }, l.prototype.emit = function(p, f, b, C, I, w) {
2490
+ }, d.prototype.emit = function(p, f, b, C, I, w) {
2491
2491
  var R = n ? n + p : p;
2492
2492
  if (!this._events[R]) return !1;
2493
2493
  var m = this._events[R], A = arguments.length, M, x;
@@ -2532,11 +2532,11 @@ function li() {
2532
2532
  }
2533
2533
  }
2534
2534
  return !0;
2535
- }, l.prototype.on = function(p, f, b) {
2535
+ }, d.prototype.on = function(p, f, b) {
2536
2536
  return c(this, p, f, b, !1);
2537
- }, l.prototype.once = function(p, f, b) {
2537
+ }, d.prototype.once = function(p, f, b) {
2538
2538
  return c(this, p, f, b, !0);
2539
- }, l.prototype.removeListener = function(p, f, b, C) {
2539
+ }, d.prototype.removeListener = function(p, f, b, C) {
2540
2540
  var I = n ? n + p : p;
2541
2541
  if (!this._events[I]) return this;
2542
2542
  if (!f)
@@ -2550,14 +2550,14 @@ function li() {
2550
2550
  m.length ? this._events[I] = m.length === 1 ? m[0] : m : a(this, I);
2551
2551
  }
2552
2552
  return this;
2553
- }, l.prototype.removeAllListeners = function(p) {
2553
+ }, d.prototype.removeAllListeners = function(p) {
2554
2554
  var f;
2555
2555
  return p ? (f = n ? n + p : p, this._events[f] && a(this, f)) : (this._events = new i(), this._eventsCount = 0), this;
2556
- }, l.prototype.off = l.prototype.removeListener, l.prototype.addListener = l.prototype.on, l.prefixed = n, l.EventEmitter = l, t.exports = l;
2556
+ }, d.prototype.off = d.prototype.removeListener, d.prototype.addListener = d.prototype.on, d.prefixed = n, d.EventEmitter = d, t.exports = d;
2557
2557
  }(Je)), Je.exports;
2558
2558
  }
2559
- var ui = li();
2560
- const lt = /* @__PURE__ */ di(ui), Ee = new lt();
2559
+ var ui = di();
2560
+ const dt = /* @__PURE__ */ li(ui), Ee = new dt();
2561
2561
  function hi(t) {
2562
2562
  if (!t || typeof t != "object")
2563
2563
  return !1;
@@ -2585,14 +2585,18 @@ function gi(t) {
2585
2585
  } : null;
2586
2586
  }
2587
2587
  function vi(t) {
2588
- return !fi(t) || t.params.item.role !== "user" || t.params.item.status !== "completed" ? null : {
2589
- id: `${t.params.item.id}-${Date.now()}`,
2588
+ if (!fi(t) || t.params.item.role !== "user" || t.params.item.status !== "completed")
2589
+ return null;
2590
+ let e = "", n = [];
2591
+ return Array.isArray(t.params.item.content) ? (e = t.params.item.content.reduce((i, s) => (s.type === "text" && (i += s.text), i), ""), n = t.params.item.content.reduce((i, s) => (s.type === "image_url" && s.image_url.url && i.push({ type: "image", url: s.image_url.url }), i), [])) : e = t.params.item.content, {
2592
+ id: t.params.item.id,
2590
2593
  role: t.params.item.role,
2591
- content: t.params.item.content.map((e) => e.transcript).join(" "),
2592
- timestamp: /* @__PURE__ */ new Date()
2594
+ timestamp: /* @__PURE__ */ new Date(),
2595
+ content: e,
2596
+ attachments: n
2593
2597
  };
2594
2598
  }
2595
- class mi extends lt {
2599
+ class mi extends dt {
2596
2600
  telnyxRTC;
2597
2601
  transcript = [];
2598
2602
  constructor(e) {
@@ -2647,7 +2651,7 @@ class _i {
2647
2651
  this.animationFrameId = requestAnimationFrame(n);
2648
2652
  }
2649
2653
  }
2650
- class Ot extends lt {
2654
+ class Ot extends dt {
2651
2655
  telnyxRTC;
2652
2656
  transcription;
2653
2657
  agentId;
@@ -2738,8 +2742,8 @@ function wi() {
2738
2742
  var a = null;
2739
2743
  if (c !== void 0 && (a = "" + c), s.key !== void 0 && (a = "" + s.key), "key" in s) {
2740
2744
  c = {};
2741
- for (var l in s)
2742
- l !== "key" && (c[l] = s[l]);
2745
+ for (var d in s)
2746
+ d !== "key" && (c[d] = s[d]);
2743
2747
  } else c = s;
2744
2748
  return s = c.ref, {
2745
2749
  $$typeof: t,
@@ -2839,7 +2843,7 @@ function Si() {
2839
2843
  }
2840
2844
  }
2841
2845
  function s() {
2842
- var v = d.A;
2846
+ var v = l.A;
2843
2847
  return v === null ? null : v.getOwner();
2844
2848
  }
2845
2849
  function c() {
@@ -2852,7 +2856,7 @@ function Si() {
2852
2856
  }
2853
2857
  return v.key !== void 0;
2854
2858
  }
2855
- function l(v, N) {
2859
+ function d(v, N) {
2856
2860
  function P() {
2857
2861
  _ || (_ = !0, console.error(
2858
2862
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
@@ -2917,10 +2921,10 @@ function Si() {
2917
2921
  else b(z);
2918
2922
  if (u.call(N, "key")) {
2919
2923
  z = t(v);
2920
- var de = Object.keys(N).filter(function(gn) {
2924
+ var le = Object.keys(N).filter(function(gn) {
2921
2925
  return gn !== "key";
2922
2926
  });
2923
- $ = 0 < de.length ? "{key: someKey, " + de.join(": ..., ") + ": ...}" : "{key: someKey}", J[z + $] || (de = 0 < de.length ? "{" + de.join(": ..., ") + ": ...}" : "{}", console.error(
2927
+ $ = 0 < le.length ? "{key: someKey, " + le.join(": ..., ") + ": ...}" : "{key: someKey}", J[z + $] || (le = 0 < le.length ? "{" + le.join(": ..., ") + ": ...}" : "{}", console.error(
2924
2928
  `A props object containing a "key" prop is being spread into JSX:
2925
2929
  let props = %s;
2926
2930
  <%s {...props} />
@@ -2929,7 +2933,7 @@ React keys must be passed directly to JSX without using spread:
2929
2933
  <%s key={someKey} {...props} />`,
2930
2934
  $,
2931
2935
  z,
2932
- de,
2936
+ le,
2933
2937
  z
2934
2938
  ), J[z + $] = !0);
2935
2939
  }
@@ -2938,7 +2942,7 @@ React keys must be passed directly to JSX without using spread:
2938
2942
  for (var qe in N)
2939
2943
  qe !== "key" && (P[qe] = N[qe]);
2940
2944
  } else P = N;
2941
- return z && l(
2945
+ return z && d(
2942
2946
  P,
2943
2947
  typeof v == "function" ? v.displayName || v.name || "Unknown" : v
2944
2948
  ), p(
@@ -2955,7 +2959,7 @@ React keys must be passed directly to JSX without using spread:
2955
2959
  function b(v) {
2956
2960
  typeof v == "object" && v !== null && v.$$typeof === I && v._store && (v._store.validated = 1);
2957
2961
  }
2958
- var C = rt, I = Symbol.for("react.transitional.element"), w = Symbol.for("react.portal"), R = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), A = Symbol.for("react.profiler"), M = Symbol.for("react.consumer"), x = Symbol.for("react.context"), V = Symbol.for("react.forward_ref"), G = Symbol.for("react.suspense"), ee = Symbol.for("react.suspense_list"), S = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), o = Symbol.for("react.activity"), r = Symbol.for("react.client.reference"), d = C.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, u = Object.prototype.hasOwnProperty, g = Array.isArray, y = console.createTask ? console.createTask : function() {
2962
+ var C = rt, I = Symbol.for("react.transitional.element"), w = Symbol.for("react.portal"), R = Symbol.for("react.fragment"), m = Symbol.for("react.strict_mode"), A = Symbol.for("react.profiler"), M = Symbol.for("react.consumer"), x = Symbol.for("react.context"), V = Symbol.for("react.forward_ref"), G = Symbol.for("react.suspense"), ee = Symbol.for("react.suspense_list"), S = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), o = Symbol.for("react.activity"), r = Symbol.for("react.client.reference"), l = C.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, u = Object.prototype.hasOwnProperty, g = Array.isArray, y = console.createTask ? console.createTask : function() {
2959
2963
  return null;
2960
2964
  };
2961
2965
  C = {
@@ -2968,7 +2972,7 @@ React keys must be passed directly to JSX without using spread:
2968
2972
  c
2969
2973
  )(), Y = y(i(c)), J = {};
2970
2974
  me.Fragment = R, me.jsx = function(v, N, P, $, W) {
2971
- var B = 1e4 > d.recentlyCreatedOwnerStacks++;
2975
+ var B = 1e4 > l.recentlyCreatedOwnerStacks++;
2972
2976
  return f(
2973
2977
  v,
2974
2978
  N,
@@ -2980,7 +2984,7 @@ React keys must be passed directly to JSX without using spread:
2980
2984
  B ? y(i(v)) : Y
2981
2985
  );
2982
2986
  }, me.jsxs = function(v, N, P, $, W) {
2983
- var B = 1e4 > d.recentlyCreatedOwnerStacks++;
2987
+ var B = 1e4 > l.recentlyCreatedOwnerStacks++;
2984
2988
  return f(
2985
2989
  v,
2986
2990
  N,
@@ -3062,7 +3066,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3062
3066
  a?.delete(s), a.size || e.delete(c);
3063
3067
  };
3064
3068
  }, n;
3065
- }, ki = (t) => (t.c || (t.c = Qe()), t.m || (t.m = Qe()), t.u || (t.u = Qe()), t.f || (t.f = Ei()), t), Ti = Symbol(), Ri = (t = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), a = {}, l = (C, ...I) => C.read(...I), h = (C, ...I) => C.write(...I), p = (C, I) => {
3069
+ }, ki = (t) => (t.c || (t.c = Qe()), t.m || (t.m = Qe()), t.u || (t.u = Qe()), t.f || (t.f = Ei()), t), Ti = Symbol(), Ri = (t = /* @__PURE__ */ new WeakMap(), e = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), c = /* @__PURE__ */ new Set(), a = {}, d = (C, ...I) => C.read(...I), h = (C, ...I) => C.write(...I), p = (C, I) => {
3066
3070
  var w;
3067
3071
  return (w = C.unstable_onInit) == null ? void 0 : w.call(C, I);
3068
3072
  }, f = (C, I) => {
@@ -3085,9 +3089,9 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3085
3089
  do {
3086
3090
  a.f && E(a.f);
3087
3091
  const o = /* @__PURE__ */ new Set(), r = o.add.bind(o);
3088
- i.forEach((d) => {
3092
+ i.forEach((l) => {
3089
3093
  var u;
3090
- return (u = e.get(d)) == null ? void 0 : u.l.forEach(r);
3094
+ return (u = e.get(l)) == null ? void 0 : u.l.forEach(r);
3091
3095
  }), i.clear(), c.forEach(r), c.clear(), s.forEach(r), s.clear(), o.forEach(E), i.size && w();
3092
3096
  } while (i.size || c.size || s.size);
3093
3097
  if (S.length)
@@ -3095,25 +3099,25 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3095
3099
  }), w = b[2] || (() => {
3096
3100
  const S = [], E = /* @__PURE__ */ new WeakSet(), o = /* @__PURE__ */ new WeakSet(), r = Array.from(i);
3097
3101
  for (; r.length; ) {
3098
- const d = r[r.length - 1], u = C(d);
3099
- if (o.has(d)) {
3102
+ const l = r[r.length - 1], u = C(l);
3103
+ if (o.has(l)) {
3100
3104
  r.pop();
3101
3105
  continue;
3102
3106
  }
3103
- if (E.has(d)) {
3104
- if (n.get(d) === u.n)
3105
- S.push([d, u]);
3106
- else if ((we ? "production" : void 0) !== "production" && n.has(d))
3107
+ if (E.has(l)) {
3108
+ if (n.get(l) === u.n)
3109
+ S.push([l, u]);
3110
+ else if ((we ? "production" : void 0) !== "production" && n.has(l))
3107
3111
  throw new Error("[Bug] invalidated atom exists");
3108
- o.add(d), r.pop();
3112
+ o.add(l), r.pop();
3109
3113
  continue;
3110
3114
  }
3111
- E.add(d);
3112
- for (const g of $t(d, u, e))
3115
+ E.add(l);
3116
+ for (const g of $t(l, u, e))
3113
3117
  E.has(g) || r.push(g);
3114
3118
  }
3115
- for (let d = S.length - 1; d >= 0; --d) {
3116
- const [u, g] = S[d];
3119
+ for (let l = S.length - 1; l >= 0; --l) {
3120
+ const [u, g] = S[l];
3117
3121
  let y = !1;
3118
3122
  for (const _ of g.d.keys())
3119
3123
  if (_ !== u && i.has(_)) {
@@ -3135,7 +3139,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3135
3139
  return o;
3136
3140
  o.d.clear();
3137
3141
  let r = !0;
3138
- const d = () => {
3142
+ const l = () => {
3139
3143
  e.has(S) && (M(S), w(), I());
3140
3144
  }, u = (T) => {
3141
3145
  var Y;
@@ -3152,7 +3156,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3152
3156
  try {
3153
3157
  return Le(J);
3154
3158
  } finally {
3155
- o.d.set(T, J.n), Ut(o.v) && an(S, o.v, J), (Y = e.get(T)) == null || Y.t.add(S), r || d();
3159
+ o.d.set(T, J.n), Ut(o.v) && an(S, o.v, J), (Y = e.get(T)) == null || Y.t.add(S), r || l();
3156
3160
  }
3157
3161
  };
3158
3162
  let g, y;
@@ -3172,10 +3176,10 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3172
3176
  }
3173
3177
  }, k = o.n;
3174
3178
  try {
3175
- const T = l(S, u, _);
3179
+ const T = d(S, u, _);
3176
3180
  return Ke(S, T, C), Ve(T) && (rn(T, () => g?.abort()), T.then(
3177
- d,
3178
- d
3181
+ l,
3182
+ l
3179
3183
  )), o;
3180
3184
  } catch (T) {
3181
3185
  return delete o.v, o.e = T, ++o.n, o;
@@ -3186,14 +3190,14 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3186
3190
  const E = [S];
3187
3191
  for (; E.length; ) {
3188
3192
  const o = E.pop(), r = C(o);
3189
- for (const d of $t(o, r, e)) {
3190
- const u = C(d);
3191
- n.set(d, u.n), E.push(d);
3193
+ for (const l of $t(o, r, e)) {
3194
+ const u = C(l);
3195
+ n.set(l, u.n), E.push(l);
3192
3196
  }
3193
3197
  }
3194
3198
  }), A = b[5] || ((S, ...E) => {
3195
3199
  let o = !0;
3196
- const r = (u) => Le(R(u)), d = (u, ...g) => {
3200
+ const r = (u) => Le(R(u)), l = (u, ...g) => {
3197
3201
  var y;
3198
3202
  const _ = C(u);
3199
3203
  try {
@@ -3210,7 +3214,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3210
3214
  }
3211
3215
  };
3212
3216
  try {
3213
- return h(S, r, d, ...E);
3217
+ return h(S, r, l, ...E);
3214
3218
  } finally {
3215
3219
  o = !1;
3216
3220
  }
@@ -3218,15 +3222,15 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3218
3222
  var E;
3219
3223
  const o = C(S), r = e.get(S);
3220
3224
  if (r && !Ut(o.v)) {
3221
- for (const [d, u] of o.d)
3222
- if (!r.d.has(d)) {
3223
- const g = C(d);
3224
- x(d).t.add(S), r.d.add(d), u !== g.n && (i.add(d), (E = a.c) == null || E.call(a, d), m(d));
3225
+ for (const [l, u] of o.d)
3226
+ if (!r.d.has(l)) {
3227
+ const g = C(l);
3228
+ x(l).t.add(S), r.d.add(l), u !== g.n && (i.add(l), (E = a.c) == null || E.call(a, l), m(l));
3225
3229
  }
3226
- for (const d of r.d || [])
3227
- if (!o.d.has(d)) {
3228
- r.d.delete(d);
3229
- const u = V(d);
3230
+ for (const l of r.d || [])
3231
+ if (!o.d.has(l)) {
3232
+ r.d.delete(l);
3233
+ const u = V(l);
3230
3234
  u?.t.delete(S);
3231
3235
  }
3232
3236
  }
@@ -3236,14 +3240,14 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3236
3240
  let r = e.get(S);
3237
3241
  if (!r) {
3238
3242
  R(S);
3239
- for (const d of o.d.keys())
3240
- x(d).t.add(S);
3243
+ for (const l of o.d.keys())
3244
+ x(l).t.add(S);
3241
3245
  if (r = {
3242
3246
  l: /* @__PURE__ */ new Set(),
3243
3247
  d: new Set(o.d.keys()),
3244
3248
  t: /* @__PURE__ */ new Set()
3245
3249
  }, e.set(S, r), (E = a.m) == null || E.call(a, S), He(S)) {
3246
- const d = () => {
3250
+ const l = () => {
3247
3251
  let u = !0;
3248
3252
  const g = (...y) => {
3249
3253
  try {
@@ -3266,7 +3270,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3266
3270
  u = !1;
3267
3271
  }
3268
3272
  };
3269
- s.add(d);
3273
+ s.add(l);
3270
3274
  }
3271
3275
  }
3272
3276
  return r;
@@ -3274,13 +3278,13 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3274
3278
  var E;
3275
3279
  const o = C(S);
3276
3280
  let r = e.get(S);
3277
- if (r && !r.l.size && !Array.from(r.t).some((d) => {
3281
+ if (r && !r.l.size && !Array.from(r.t).some((l) => {
3278
3282
  var u;
3279
- return (u = e.get(d)) == null ? void 0 : u.d.has(S);
3283
+ return (u = e.get(l)) == null ? void 0 : u.d.has(S);
3280
3284
  })) {
3281
3285
  r.u && c.add(r.u), r = void 0, e.delete(S), (E = a.u) == null || E.call(a, S);
3282
- for (const d of o.d.keys()) {
3283
- const u = V(d);
3286
+ for (const l of o.d.keys()) {
3287
+ const u = V(l);
3284
3288
  u?.t.delete(S);
3285
3289
  }
3286
3290
  return;
@@ -3296,7 +3300,7 @@ const we = {}, Dt = (t, e) => t.unstable_is ? t.unstable_is(e) : e === t, Pt = (
3296
3300
  c,
3297
3301
  a,
3298
3302
  // atom interceptors
3299
- l,
3303
+ d,
3300
3304
  h,
3301
3305
  p,
3302
3306
  f,
@@ -3357,27 +3361,27 @@ const Mi = () => {
3357
3361
  void 0,
3358
3362
  e,
3359
3363
  void 0,
3360
- (l, h, p, ...f) => t ? p(l, ...f) : l.write(h, p, ...f)
3364
+ (d, h, p, ...f) => t ? p(d, ...f) : d.write(h, p, ...f)
3361
3365
  ), c = /* @__PURE__ */ new Set();
3362
- return e.m.add(void 0, (l) => {
3363
- c.add(l);
3364
- const h = n.get(l);
3365
- h.m = i.get(l);
3366
- }), e.u.add(void 0, (l) => {
3367
- c.delete(l);
3368
- const h = n.get(l);
3366
+ return e.m.add(void 0, (d) => {
3367
+ c.add(d);
3368
+ const h = n.get(d);
3369
+ h.m = i.get(d);
3370
+ }), e.u.add(void 0, (d) => {
3371
+ c.delete(d);
3372
+ const h = n.get(d);
3369
3373
  delete h.m;
3370
3374
  }), Object.assign(s, {
3371
3375
  // store dev methods (these are tentative and subject to change without notice)
3372
3376
  dev4_get_internal_weak_map: () => (console.log("Deprecated: Use devstore from the devtools library"), n),
3373
3377
  dev4_get_mounted_atoms: () => c,
3374
- dev4_restore_atoms: (l) => {
3378
+ dev4_restore_atoms: (d) => {
3375
3379
  const h = {
3376
3380
  read: () => null,
3377
3381
  write: (p, f) => {
3378
3382
  ++t;
3379
3383
  try {
3380
- for (const [b, C] of l)
3384
+ for (const [b, C] of d)
3381
3385
  "init" in b && f(b, C);
3382
3386
  } finally {
3383
3387
  --t;
@@ -3400,7 +3404,7 @@ function Di() {
3400
3404
  const Pi = {}, ji = Bt(
3401
3405
  void 0
3402
3406
  );
3403
- function dn(t) {
3407
+ function ln(t) {
3404
3408
  return Gt(ji) || Di();
3405
3409
  }
3406
3410
  const st = (t) => typeof t?.then == "function", ot = (t) => {
@@ -3425,21 +3429,21 @@ const st = (t) => typeof t?.then == "function", ot = (t) => {
3425
3429
  let c = t;
3426
3430
  const a = (p) => (f) => {
3427
3431
  c === p && i(f);
3428
- }, l = (p) => (f) => {
3432
+ }, d = (p) => (f) => {
3429
3433
  c === p && s(f);
3430
3434
  }, h = () => {
3431
3435
  try {
3432
3436
  const p = e();
3433
- st(p) ? (Xe.set(p, n), c = p, p.then(a(p), l(p)), Vt(p, h)) : i(p);
3437
+ st(p) ? (Xe.set(p, n), c = p, p.then(a(p), d(p)), Vt(p, h)) : i(p);
3434
3438
  } catch (p) {
3435
3439
  s(p);
3436
3440
  }
3437
3441
  };
3438
- t.then(a(t), l(t)), Vt(t, h);
3442
+ t.then(a(t), d(t)), Vt(t, h);
3439
3443
  }), Xe.set(t, n)), n;
3440
3444
  };
3441
3445
  function Ge(t, e) {
3442
- const { delay: n, unstable_promiseStatus: i = !rt.use } = {}, s = dn(), [[c, a, l], h] = vn(
3446
+ const { delay: n, unstable_promiseStatus: i = !rt.use } = {}, s = ln(), [[c, a, d], h] = vn(
3443
3447
  (f) => {
3444
3448
  const b = s.get(t);
3445
3449
  return Object.is(f[0], b) && f[1] === s && f[2] === t ? f : [b, s, t];
@@ -3448,7 +3452,7 @@ function Ge(t, e) {
3448
3452
  () => [s.get(t), s, t]
3449
3453
  );
3450
3454
  let p = c;
3451
- if ((a !== s || l !== t) && (h(), p = s.get(t)), ce(() => {
3455
+ if ((a !== s || d !== t) && (h(), p = s.get(t)), ce(() => {
3452
3456
  const f = s.sub(t, () => {
3453
3457
  if (i)
3454
3458
  try {
@@ -3472,7 +3476,7 @@ function Ge(t, e) {
3472
3476
  return p;
3473
3477
  }
3474
3478
  function Be(t, e) {
3475
- const n = dn();
3479
+ const n = ln();
3476
3480
  return bn(
3477
3481
  (...s) => {
3478
3482
  if ((Pi ? "production" : void 0) !== "production" && !("write" in t))
@@ -3482,12 +3486,12 @@ function Be(t, e) {
3482
3486
  [n, t]
3483
3487
  );
3484
3488
  }
3485
- const ln = Fe([]);
3489
+ const dn = Fe([]);
3486
3490
  function Ji() {
3487
- return Ge(ln);
3491
+ return Ge(dn);
3488
3492
  }
3489
3493
  function $i() {
3490
- return Be(ln);
3494
+ return Be(dn);
3491
3495
  }
3492
3496
  const We = () => {
3493
3497
  const t = Gt(fn);