@telnyx/ai-agent-lib 0.3.1-beta.1 → 0.3.1-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import ht, { useReducer as Ln, useEffect as fe, useDebugValue as On, useCallback as Mn, useContext as Jt, createContext as zt, useState as Pn } from "react";
1
+ import ht, { useReducer as On, useEffect as fe, useDebugValue as Mn, useCallback as Pn, useContext as zt, createContext as Kt, useState as Dn } from "react";
2
2
  function Ne(n, e) {
3
3
  var t = {};
4
4
  for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && e.indexOf(i) < 0 && (t[i] = n[i]);
@@ -33,68 +33,68 @@ function O(n, e, t, i) {
33
33
  c((i = i.apply(n, [])).next());
34
34
  }));
35
35
  }
36
- var mt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), Dn = new Uint8Array(16);
37
- function Nn() {
36
+ var mt = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto < "u" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), Nn = new Uint8Array(16);
37
+ function jn() {
38
38
  if (!mt) throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
39
- return mt(Dn);
39
+ return mt(Nn);
40
40
  }
41
- for (var Kt = [], xe = 0; xe < 256; ++xe) Kt[xe] = (xe + 256).toString(16).substr(1);
41
+ for (var Xt = [], xe = 0; xe < 256; ++xe) Xt[xe] = (xe + 256).toString(16).substr(1);
42
42
  function me(n, e, t) {
43
43
  var i = e && t || 0;
44
44
  typeof n == "string" && (e = n === "binary" ? new Array(16) : null, n = null);
45
- var s = (n = n || {}).random || (n.rng || Nn)();
45
+ var s = (n = n || {}).random || (n.rng || jn)();
46
46
  if (s[6] = 15 & s[6] | 64, s[8] = 63 & s[8] | 128, e) for (var o = 0; o < 16; ++o) e[i + o] = s[o];
47
47
  return e || (function(r, l) {
48
- var c = 0, u = Kt;
48
+ var c = 0, u = Xt;
49
49
  return [u[r[c++]], u[r[c++]], u[r[c++]], u[r[c++]], "-", u[r[c++]], u[r[c++]], "-", u[r[c++]], u[r[c++]], "-", u[r[c++]], u[r[c++]], "-", u[r[c++]], u[r[c++]], u[r[c++]], u[r[c++]], u[r[c++]], u[r[c++]]].join("");
50
50
  })(s);
51
51
  }
52
- const yt = "wss://rtc.telnyx.com", jn = 1006, Xt = { urls: "stun:stun.l.google.com:19302" }, Un = [{ urls: "stun:stun.telnyx.com:3478" }, Xt, { urls: "turn:turn.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turn.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }], Fn = [{ urls: "stun:stundev.telnyx.com:3478" }, Xt, { urls: "turn:turndev.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turndev.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }];
52
+ const yt = "wss://rtc.telnyx.com", Un = 1006, Qt = { urls: "stun:stun.l.google.com:19302" }, Fn = [{ urls: "stun:stun.telnyx.com:3478" }, Qt, { urls: "turn:turn.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turn.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }], $n = [{ urls: "stun:stundev.telnyx.com:3478" }, Qt, { urls: "turn:turndev.telnyx.com:3478?transport=udp", username: "testuser", credential: "testpassword" }, { urls: "turn:turndev.telnyx.com:3478?transport=tcp", username: "testuser", credential: "testpassword" }];
53
53
  var x;
54
54
  (function(n) {
55
55
  n.SocketOpen = "telnyx.socket.open", n.SocketClose = "telnyx.socket.close", n.SocketError = "telnyx.socket.error", n.SocketMessage = "telnyx.socket.message", n.SpeedTest = "telnyx.internal.speedtest", n.Ready = "telnyx.ready", n.Error = "telnyx.error", n.Notification = "telnyx.notification", n.StatsFrame = "telnyx.stats.frame", n.StatsReport = "telnyx.stats.report", n.Messages = "telnyx.messages", n.Calls = "telnyx.calls", n.MediaError = "telnyx.rtc.mediaError", n.PeerConnectionFailureError = "telnyx.rtc.peerConnectionFailureError", n.PeerConnectionSignalingStateClosed = "telnyx.rtc.peerConnectionSignalingStateClosed";
56
56
  })(x || (x = {}));
57
- var $n = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
58
- function Qt(n, e) {
57
+ var Bn = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
58
+ function Zt(n, e) {
59
59
  return n(e = { exports: {} }, e.exports), e.exports;
60
60
  }
61
- var Bn = Qt((function(n) {
61
+ var Vn = Zt((function(n) {
62
62
  var e, t;
63
- e = $n, t = function() {
63
+ e = Bn, t = function() {
64
64
  var i = function() {
65
65
  }, s = "undefined", o = typeof window !== s && typeof window.navigator !== s && /Trident\/|MSIE /.test(window.navigator.userAgent), r = ["trace", "debug", "info", "warn", "error"];
66
- function l(g, w) {
67
- var R = g[w];
68
- if (typeof R.bind == "function") return R.bind(g);
66
+ function l(v, w) {
67
+ var R = v[w];
68
+ if (typeof R.bind == "function") return R.bind(v);
69
69
  try {
70
- return Function.prototype.bind.call(R, g);
70
+ return Function.prototype.bind.call(R, v);
71
71
  } catch {
72
72
  return function() {
73
- return Function.prototype.apply.apply(R, [g, arguments]);
73
+ return Function.prototype.apply.apply(R, [v, arguments]);
74
74
  };
75
75
  }
76
76
  }
77
77
  function c() {
78
78
  console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
79
79
  }
80
- function u(g, w) {
80
+ function u(v, w) {
81
81
  for (var R = 0; R < r.length; R++) {
82
82
  var T = r[R];
83
- this[T] = R < g ? i : this.methodFactory(T, g, w);
83
+ this[T] = R < v ? i : this.methodFactory(T, v, w);
84
84
  }
85
85
  this.log = this.debug;
86
86
  }
87
- function p(g, w, R) {
87
+ function p(v, w, R) {
88
88
  return function() {
89
- typeof console !== s && (u.call(this, w, R), this[g].apply(this, arguments));
89
+ typeof console !== s && (u.call(this, w, R), this[v].apply(this, arguments));
90
90
  };
91
91
  }
92
- function f(g, w, R) {
92
+ function f(v, w, R) {
93
93
  return (function(T) {
94
94
  return T === "debug" && (T = "log"), typeof console !== s && (T === "trace" && o ? c : console[T] !== void 0 ? l(console, T) : console.log !== void 0 ? l(console, "log") : i);
95
- })(g) || p.apply(this, arguments);
95
+ })(v) || p.apply(this, arguments);
96
96
  }
97
- function C(g, w, R) {
97
+ function C(v, w, R) {
98
98
  var T, A = this;
99
99
  w = w ?? "WARN";
100
100
  var D = "loglevel";
@@ -113,7 +113,7 @@ var Bn = Qt((function(n) {
113
113
  return A.levels[M] === void 0 && (M = void 0), M;
114
114
  }
115
115
  }
116
- typeof g == "string" ? D += ":" + g : typeof g == "symbol" && (D = void 0), A.name = g, A.levels = { TRACE: 0, DEBUG: 1, INFO: 2, WARN: 3, ERROR: 4, SILENT: 5 }, A.methodFactory = R || f, A.getLevel = function() {
116
+ typeof v == "string" ? D += ":" + v : typeof v == "symbol" && (D = void 0), A.name = v, A.levels = { TRACE: 0, DEBUG: 1, INFO: 2, WARN: 3, ERROR: 4, SILENT: 5 }, A.methodFactory = R || f, A.getLevel = function() {
117
117
  return T;
118
118
  }, A.setLevel = function(M, a) {
119
119
  if (typeof M == "string" && A.levels[M.toUpperCase()] !== void 0 && (M = A.levels[M.toUpperCase()]), !(typeof M == "number" && M >= 0 && M <= A.levels.SILENT)) throw "log.setLevel() called with invalid level: " + M;
@@ -129,7 +129,7 @@ var Bn = Qt((function(n) {
129
129
  } catch {
130
130
  }
131
131
  }
132
- })(M), u.call(A, M, g), typeof console === s && M < A.levels.SILENT) return "No console available for logging";
132
+ })(M), u.call(A, M, v), typeof console === s && M < A.levels.SILENT) return "No console available for logging";
133
133
  }, A.setDefaultLevel = function(M) {
134
134
  w = M, W() || A.setLevel(M, !1);
135
135
  }, A.resetLevel = function() {
@@ -154,10 +154,10 @@ var Bn = Qt((function(n) {
154
154
  B == null && (B = w), A.setLevel(B, !1);
155
155
  }
156
156
  var b = new C(), y = {};
157
- b.getLogger = function(g) {
158
- if (typeof g != "symbol" && typeof g != "string" || g === "") throw new TypeError("You must supply a name when creating a logger.");
159
- var w = y[g];
160
- return w || (w = y[g] = new C(g, b.getLevel(), b.methodFactory)), w;
157
+ b.getLogger = function(v) {
158
+ if (typeof v != "symbol" && typeof v != "string" || v === "") throw new TypeError("You must supply a name when creating a logger.");
159
+ var w = y[v];
160
+ return w || (w = y[v] = new C(v, b.getLevel(), b.methodFactory)), w;
161
161
  };
162
162
  var I = typeof window !== s ? window.log : void 0;
163
163
  return b.noConflict = function() {
@@ -168,7 +168,7 @@ var Bn = Qt((function(n) {
168
168
  }, n.exports ? n.exports = t() : e.log = t();
169
169
  }));
170
170
  const bt = { debug: 0, info: 1, warn: 2, error: 3 };
171
- class Vn {
171
+ class Gn {
172
172
  constructor(e = {}) {
173
173
  var t, i, s;
174
174
  this.buffer = [], this.isCapturing = !1, this.options = { enabled: (t = e.enabled) !== null && t !== void 0 && t, level: (i = e.level) !== null && i !== void 0 ? i : "debug", maxEntries: (s = e.maxEntries) !== null && s !== void 0 ? s : 1e3 };
@@ -204,15 +204,15 @@ class Vn {
204
204
  return this.options.enabled;
205
205
  }
206
206
  }
207
- let Zt = null;
208
- function en() {
209
- return Zt;
207
+ let en = null;
208
+ function tn() {
209
+ return en;
210
210
  }
211
211
  function St(n) {
212
- Zt = n;
212
+ en = n;
213
213
  }
214
- const v = Bn.getLogger("telnyx"), je = { trace: 0, debug: 1, info: 2, warn: 3, error: 4 };
215
- let tn = je.info;
214
+ const g = Vn.getLogger("telnyx"), je = { trace: 0, debug: 1, info: 2, warn: 3, error: 4 };
215
+ let nn = je.info;
216
216
  function _t(n) {
217
217
  if (n == null || typeof n != "object") return n;
218
218
  try {
@@ -234,47 +234,47 @@ function _t(n) {
234
234
  }
235
235
  return Object.keys(e).length > 0 ? e : { value: String(n) };
236
236
  }
237
- const Gn = v.methodFactory;
238
- v.methodFactory = (n, e, t) => {
239
- const i = Gn(n, e, t);
237
+ const Hn = g.methodFactory;
238
+ g.methodFactory = (n, e, t) => {
239
+ const i = Hn(n, e, t);
240
240
  return function(...s) {
241
- if (je[n] >= tn) {
241
+ if (je[n] >= nn) {
242
242
  const r = [(/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), "-"];
243
243
  for (const l of s) r.push(l);
244
244
  i(...r);
245
245
  }
246
- const o = en();
246
+ const o = tn();
247
247
  if (o?.isActive()) {
248
248
  const [r, ...l] = s, c = typeof r == "string" ? r : JSON.stringify(r);
249
249
  let u;
250
250
  l.length > 0 && (u = l.length === 1 && typeof l[0] == "object" && l[0] !== null ? _t(l[0]) : { args: l.map(_t) }), o.addEntry(n, c, u);
251
251
  }
252
252
  };
253
- }, v.setLevel("debug", !1);
253
+ }, g.setLevel("debug", !1);
254
254
  const Le = (n) => {
255
255
  const [e, t, i, s, o, r] = n;
256
256
  let l = {};
257
257
  try {
258
258
  l = JSON.parse(o.replace(/ID"/g, 'Id"'));
259
259
  } catch {
260
- v.warn("Verto LA invalid media JSON string:", o);
260
+ g.warn("Verto LA invalid media JSON string:", o);
261
261
  }
262
262
  return { participantId: Number(e), participantNumber: t, participantName: i, codec: s, media: l, participantData: r };
263
- }, nn = (n) => {
263
+ }, sn = (n) => {
264
264
  if (typeof n != "string") return n;
265
265
  try {
266
266
  return JSON.parse(n);
267
267
  } catch {
268
268
  return n;
269
269
  }
270
- }, ye = (n) => n instanceof Function || typeof n == "function", Ue = (n) => typeof document == "object" && "getElementById" in document ? typeof n == "string" ? document.getElementById(n) || null : typeof n == "function" ? n() : n instanceof HTMLMediaElement ? n : null : null, Hn = /^(ws|wss):\/\//, sn = (n, e = null) => {
270
+ }, ye = (n) => n instanceof Function || typeof n == "function", Ue = (n) => typeof document == "object" && "getElementById" in document ? typeof n == "string" ? document.getElementById(n) || null : typeof n == "function" ? n() : n instanceof HTMLMediaElement ? n : null : null, Wn = /^(ws|wss):\/\//, on = (n, e = null) => {
271
271
  const { result: t = {}, error: i } = n;
272
272
  if (i) return { error: i };
273
273
  const { result: s = null } = t;
274
274
  if (s === null) return e !== null && (t.node_id = e), { result: t };
275
275
  const { code: o = null, node_id: r = null, result: l = null } = s;
276
- return o && o !== "200" ? { error: s } : l ? sn(l, r) : { result: s };
277
- }, on = (n, e) => Math.floor(Math.random() * (e - n + 1) + n), Fe = ({ login: n, passwd: e, password: t, login_token: i }) => !!(n && (e || t) || i), ke = ({ anonymous_login: n }) => !!n && !!n.target_id && !!n.target_type, pt = (n) => {
276
+ return o && o !== "200" ? { error: s } : l ? on(l, r) : { result: s };
277
+ }, rn = (n, e) => Math.floor(Math.random() * (e - n + 1) + n), Fe = ({ login: n, passwd: e, password: t, login_token: i }) => !!(n && (e || t) || i), ke = ({ anonymous_login: n }) => !!n && !!n.target_id && !!n.target_type, pt = (n) => {
278
278
  var e, t, i, s, o, r;
279
279
  let l = "", c = "";
280
280
  return !((t = (e = n?.result) === null || e === void 0 ? void 0 : e.params) === null || t === void 0) && t.state && (l = (s = (i = n?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state), !((o = n?.params) === null || o === void 0) && o.state && (c = (r = n?.params) === null || r === void 0 ? void 0 : r.state), l || c;
@@ -282,10 +282,10 @@ const Le = (n) => {
282
282
  function Ct({ debounceTime: n }) {
283
283
  let e, t;
284
284
  return { promise: new Promise(((i, s) => {
285
- e = n ? Wn(i, n) : i, t = s;
285
+ e = n ? qn(i, n) : i, t = s;
286
286
  })), resolve: e, reject: t };
287
287
  }
288
- const Wn = (n, e) => {
288
+ const qn = (n, e) => {
289
289
  let t;
290
290
  return (...i) => {
291
291
  clearTimeout(t), t = window.setTimeout((() => {
@@ -296,7 +296,7 @@ const Wn = (n, e) => {
296
296
  function he() {
297
297
  return sessionStorage.getItem(ft);
298
298
  }
299
- var z, re, $;
299
+ var z, re, F;
300
300
  typeof window < "u" && window.addEventListener("beforeunload", (() => {
301
301
  sessionStorage.removeItem(ft);
302
302
  })), (function(n) {
@@ -305,8 +305,8 @@ typeof window < "u" && window.addEventListener("beforeunload", (() => {
305
305
  n.Inbound = "inbound", n.Outbound = "outbound";
306
306
  })(re || (re = {})), (function(n) {
307
307
  n.Invite = "telnyx_rtc.invite", n.Attach = "telnyx_rtc.attach", n.Answer = "telnyx_rtc.answer", n.Info = "telnyx_rtc.info", n.Candidate = "telnyx_rtc.candidate", n.EndOfCandidates = "telnyx_rtc.endOfCandidates", n.Display = "telnyx_rtc.display", n.Media = "telnyx_rtc.media", n.Event = "telnyx_rtc.event", n.Bye = "telnyx_rtc.bye", n.Punt = "telnyx_rtc.punt", n.Broadcast = "telnyx_rtc.broadcast", n.Subscribe = "telnyx_rtc.subscribe", n.Unsubscribe = "telnyx_rtc.unsubscribe", n.ClientReady = "telnyx_rtc.clientReady", n.Modify = "telnyx_rtc.modify", n.Ringing = "telnyx_rtc.ringing", n.GatewayState = "telnyx_rtc.gatewayState", n.Ping = "telnyx_rtc.ping", n.Pong = "telnyx_rtc.pong";
308
- })($ || ($ = {}));
309
- const se = { generic: "event", [$.Display]: "participantData", [$.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError", peerConnectionFailureError: "peerConnectionFailureError", signalingStateClosed: "signalingStateClosed" }, qn = { invalidCredentialsOptions: "InvalidCredentialsOptions" }, Yn = { destinationNumber: "", remoteCallerName: "Outbound Call", remoteCallerNumber: "", callerName: "", callerNumber: "", audio: !0, useStereo: !1, debug: !1, debugOutput: "socket", attach: !1, screenShare: !1, userVariables: {}, mediaSettings: { useSdpASBandwidthKbps: !1, sdpASBandwidthKbps: 0 }, mutedMicOnStart: !1, prefetchIceCandidates: !0 };
308
+ })(F || (F = {}));
309
+ const se = { generic: "event", [F.Display]: "participantData", [F.Attach]: "participantData", conferenceUpdate: "conferenceUpdate", callUpdate: "callUpdate", vertoClientReady: "vertoClientReady", userMediaError: "userMediaError", peerConnectionFailureError: "peerConnectionFailureError", signalingStateClosed: "signalingStateClosed" }, Yn = { invalidCredentialsOptions: "InvalidCredentialsOptions" }, Jn = { destinationNumber: "", remoteCallerName: "Outbound Call", remoteCallerNumber: "", callerName: "", callerNumber: "", audio: !0, useStereo: !1, debug: !1, debugOutput: "socket", attach: !1, screenShare: !1, userVariables: {}, mediaSettings: { useSdpASBandwidthKbps: !1, sdpASBandwidthKbps: 0 }, mutedMicOnStart: !1, prefetchIceCandidates: !0 };
310
310
  var N, it, ie, ae, ee;
311
311
  (function(n) {
312
312
  n[n.New = 0] = "New", n[n.Requesting = 1] = "Requesting", n[n.Trying = 2] = "Trying", n[n.Recovering = 3] = "Recovering", n[n.Ringing = 4] = "Ringing", n[n.Answering = 5] = "Answering", n[n.Early = 6] = "Early", n[n.Active = 7] = "Active", n[n.Held = 8] = "Held", n[n.Hangup = 9] = "Hangup", n[n.Destroy = 10] = "Destroy", n[n.Purge = 11] = "Purge";
@@ -319,16 +319,16 @@ var N, it, ie, ae, ee;
319
319
  })(ae || (ae = {})), (function(n) {
320
320
  n.REGED = "REGED", n.UNREGED = "UNREGED", n.NOREG = "NOREG", n.FAILED = "FAILED", n.FAIL_WAIT = "FAIL_WAIT", n.REGISTER = "REGISTER", n.TRYING = "TRYING", n.EXPIRED = "EXPIRED", n.UNREGISTER = "UNREGISTER";
321
321
  })(ee || (ee = {}));
322
- const be = "GLOBAL", ne = {}, Re = (n, e) => `${n}|${e}`, rn = (n, e = be) => Re(n, e) in ne, de = (n, e, t = be) => {
322
+ const be = "GLOBAL", ne = {}, Re = (n, e) => `${n}|${e}`, an = (n, e = be) => Re(n, e) in ne, de = (n, e, t = be) => {
323
323
  const i = Re(n, t);
324
324
  i in ne || (ne[i] = []), ne[i].push(e);
325
- }, an = (n, e, t = be) => {
325
+ }, cn = (n, e, t = be) => {
326
326
  const i = function(s) {
327
327
  ue(n, i, t), e(s);
328
328
  };
329
329
  return i.prototype.targetRef = e, de(n, i, t);
330
330
  }, ue = (n, e, t = be) => {
331
- if (!rn(n, t)) return !1;
331
+ if (!an(n, t)) return !1;
332
332
  const i = Re(n, t);
333
333
  if (ye(e))
334
334
  for (let s = ne[i].length - 1; s >= 0; s--) {
@@ -339,7 +339,7 @@ const be = "GLOBAL", ne = {}, Re = (n, e) => `${n}|${e}`, rn = (n, e = be) => Re
339
339
  return ne[i].length === 0 && delete ne[i], !0;
340
340
  }, j = (n, e, t = be, i = !0) => {
341
341
  const s = i && t !== be;
342
- if (!rn(n, t)) return s && j(n, e), !1;
342
+ if (!an(n, t)) return s && j(n, e), !1;
343
343
  const o = Re(n, t), r = ne[o].length;
344
344
  if (!r) return s && j(n, e), !1;
345
345
  for (let l = r - 1; l >= 0; l--) ne[o][l](e);
@@ -348,22 +348,22 @@ const be = "GLOBAL", ne = {}, Re = (n, e) => `${n}|${e}`, rn = (n, e = be) => Re
348
348
  const e = Re(n, "");
349
349
  Object.keys(ne).filter(((t) => t.indexOf(e) === 0)).forEach(((t) => delete ne[t]));
350
350
  };
351
- let Jn = typeof WebSocket < "u" ? WebSocket : null;
352
- const zn = 0, Kn = 1, Xn = 2, wt = 3;
351
+ let zn = typeof WebSocket < "u" ? WebSocket : null;
352
+ const Kn = 0, Xn = 1, Qn = 2, wt = 3;
353
353
  class It {
354
354
  constructor(e) {
355
355
  this.session = e, this.previousGatewayState = "", this._wsClient = null, this._host = yt, this._timers = {}, this._useCanaryRtcServer = !1, this._hasCanaryBeenUsed = !1, this._safetyTimeoutId = null, this.upDur = null, this.downDur = null;
356
356
  const { host: t, env: i, region: s, useCanaryRtcServer: o } = e.options;
357
- i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : yt), t && (this._host = ((r) => `${Hn.test(r) ? "" : "wss://"}${r}`)(t)), s && (this._host = this._host.replace(/rtc(dev)?/, `${s}.rtc$1`)), o && (this._useCanaryRtcServer = !0);
357
+ i && (this._host = i === "development" ? "wss://rtcdev.telnyx.com" : yt), t && (this._host = ((r) => `${Wn.test(r) ? "" : "wss://"}${r}`)(t)), s && (this._host = this._host.replace(/rtc(dev)?/, `${s}.rtc$1`)), o && (this._useCanaryRtcServer = !0);
358
358
  }
359
359
  get connected() {
360
- return !!this._wsClient && this._wsClient.readyState === Kn;
360
+ return !!this._wsClient && this._wsClient.readyState === Xn;
361
361
  }
362
362
  get connecting() {
363
- return !!this._wsClient && this._wsClient.readyState === zn;
363
+ return !!this._wsClient && this._wsClient.readyState === Kn;
364
364
  }
365
365
  get closing() {
366
- return !!this._wsClient && this._wsClient.readyState === Xn;
366
+ return !!this._wsClient && this._wsClient.readyState === Qn;
367
367
  }
368
368
  get closed() {
369
369
  return !!this._wsClient && this._wsClient.readyState === wt;
@@ -380,12 +380,12 @@ class It {
380
380
  connect() {
381
381
  const e = new URL(this._host);
382
382
  let t = he();
383
- this.session.options.rtcIp && this.session.options.rtcPort && (t = null, this._useCanaryRtcServer = !1, e.searchParams.set("rtc_ip", this.session.options.rtcIp), e.searchParams.set("rtc_port", this.session.options.rtcPort.toString())), t && e.searchParams.set("voice_sdk_id", t), this._useCanaryRtcServer && (e.searchParams.set("canary", "true"), t && !this._hasCanaryBeenUsed && (e.searchParams.delete("voice_sdk_id"), v.debug("first canary connection. Refreshing voice_sdk_id")), this._hasCanaryBeenUsed = !0);
383
+ this.session.options.rtcIp && this.session.options.rtcPort && (t = null, this._useCanaryRtcServer = !1, e.searchParams.set("rtc_ip", this.session.options.rtcIp), e.searchParams.set("rtc_port", this.session.options.rtcPort.toString())), t && e.searchParams.set("voice_sdk_id", t), this._useCanaryRtcServer && (e.searchParams.set("canary", "true"), t && !this._hasCanaryBeenUsed && (e.searchParams.delete("voice_sdk_id"), g.debug("first canary connection. Refreshing voice_sdk_id")), this._hasCanaryBeenUsed = !0);
384
384
  try {
385
- this._wsClient = new Jn(e.toString()), this._registerSocketEvents(this._wsClient);
385
+ this._wsClient = new zn(e.toString()), this._registerSocketEvents(this._wsClient);
386
386
  } catch (i) {
387
387
  const s = i instanceof Error ? i : new Error(`Failed to create WebSocket: ${String(i)}`);
388
- j(x.Error, { error: s }, this.session.uuid), v.error("WebSocket connection failed:", s);
388
+ j(x.Error, { error: s }, this.session.uuid), g.error("WebSocket connection failed:", s);
389
389
  }
390
390
  }
391
391
  sendRawText(e) {
@@ -396,12 +396,12 @@ class It {
396
396
  var t;
397
397
  const { request: i } = e, s = new Promise(((o, r) => {
398
398
  if (i.hasOwnProperty("result")) return o();
399
- an(i.id, ((l) => {
400
- const { result: c, error: u } = sn(l);
399
+ cn(i.id, ((l) => {
400
+ const { result: c, error: u } = on(l);
401
401
  return u ? r(u) : o(c);
402
402
  }));
403
403
  }));
404
- return v.debug(`SEND:
404
+ return g.debug(`SEND:
405
405
  `, JSON.stringify(i, null, 2), `
406
406
  `), (t = this._wsClient) === null || t === void 0 || t.send(JSON.stringify(i)), s;
407
407
  }
@@ -413,10 +413,10 @@ class It {
413
413
  _registerSocketEvents(e) {
414
414
  e.onopen = (t) => j(x.SocketOpen, t, this.session.uuid), e.onclose = (t) => (this._clearSafetyTimeout(), this._safetyCleanupSocket(e, "close"), j(x.SocketClose, t, this.session.uuid)), e.onerror = (t) => (this._clearSafetyTimeout(), this._safetyCleanupSocket(e, "error"), j(x.SocketError, { error: t, sessionId: this.session.sessionid }, this.session.uuid)), e.onmessage = (t) => {
415
415
  var i, s;
416
- const o = nn(t.data);
416
+ const o = sn(t.data);
417
417
  var r;
418
418
  if (typeof o != "string") {
419
- if (o.voice_sdk_id && (r = o.voice_sdk_id, sessionStorage.setItem(ft, r)), this._unsetTimer(o.id), v.debug(`RECV:
419
+ if (o.voice_sdk_id && (r = o.voice_sdk_id, sessionStorage.setItem(ft, r)), this._unsetTimer(o.id), g.debug(`RECV:
420
420
  `, JSON.stringify(o, null, 2), `
421
421
  `), ee[`${(s = (i = o?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.state}`] || !j(o.id, o)) {
422
422
  const l = pt(o);
@@ -429,13 +429,13 @@ class It {
429
429
  e.onopen = null, e.onclose = null, e.onerror = null, e.onmessage = null;
430
430
  }
431
431
  _handleCloseTimeout(e) {
432
- this._safetyTimeoutId = null, e && e.readyState !== wt ? (v.warn("Socket stuck in CLOSING after 5s — forcefully cleaning up"), this._deregisterSocketEvents(e), this._safetyCleanupSocket(e, "timeout"), this._wsClient && this._wsClient !== e || j(x.SocketClose, { code: jn, reason: "STUCK_WS_TIMEOUT: Socket got stuck in CLOSING state and was forcefully cleaned up by safety timeout", wasClean: !1 }, this.session.uuid)) : v.warn("Safety timeout fired but socket is already closed or cleaned up");
432
+ this._safetyTimeoutId = null, e && e.readyState !== wt ? (g.warn("Socket stuck in CLOSING after 5s — forcefully cleaning up"), this._deregisterSocketEvents(e), this._safetyCleanupSocket(e, "timeout"), this._wsClient && this._wsClient !== e || j(x.SocketClose, { code: Un, reason: "STUCK_WS_TIMEOUT: Socket got stuck in CLOSING state and was forcefully cleaned up by safety timeout", wasClean: !1 }, this.session.uuid)) : g.warn("Safety timeout fired but socket is already closed or cleaned up");
433
433
  }
434
434
  _clearSafetyTimeout() {
435
- this._safetyTimeoutId && (v.debug("Clearing safety timeout"), clearTimeout(this._safetyTimeoutId), this._safetyTimeoutId = null);
435
+ this._safetyTimeoutId && (g.debug("Clearing safety timeout"), clearTimeout(this._safetyTimeoutId), this._safetyTimeoutId = null);
436
436
  }
437
437
  _safetyCleanupSocket(e, t) {
438
- this._wsClient === e ? (v.debug(`Nulling socket reference (reason: ${t})`), this._wsClient = null) : v.debug(`Skipping socket cleanup - old socket already replaced (reason: ${t})`);
438
+ this._wsClient === e ? (g.debug(`Nulling socket reference (reason: ${t})`), this._wsClient = null) : g.debug(`Skipping socket cleanup - old socket already replaced (reason: ${t})`);
439
439
  }
440
440
  _unsetTimer(e) {
441
441
  clearTimeout(this._timers[e]), delete this._timers[e];
@@ -448,7 +448,7 @@ class It {
448
448
  case "D":
449
449
  this.downDur = parseInt(e.substring(4)), j(x.SpeedTest, { upDur: this.upDur, downDur: this.downDur }, this.session.uuid);
450
450
  }
451
- else v.warn("Unknown message from socket", e);
451
+ else g.warn("Unknown message from socket", e);
452
452
  }
453
453
  }
454
454
  class Ae {
@@ -467,111 +467,111 @@ class Q extends Ae {
467
467
  this.buildRequest({ method: this.toString(), params: e });
468
468
  }
469
469
  }
470
- class cn extends Q {
470
+ class ln extends Q {
471
471
  constructor(e) {
472
- super(), this.method = $.GatewayState, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
472
+ super(), this.method = F.GatewayState, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
473
473
  }
474
474
  }
475
- class Qn {
475
+ class Zn {
476
476
  constructor(e) {
477
477
  this.pendingRequestId = null, this.onSocketMessage = (t) => O(this, void 0, void 0, (function* () {
478
478
  t.id === this.pendingRequestId && this.gatewayStateTask.resolve(pt(t));
479
479
  })), this.getIsRegistered = () => O(this, void 0, void 0, (function* () {
480
- const t = new cn(he());
480
+ const t = new ln(he());
481
481
  this.pendingRequestId = t.request.id, this.gatewayStateTask = Ct({}), this.session.execute(t);
482
482
  const i = yield this.gatewayStateTask.promise;
483
483
  return !!i && [ee.REGISTER, ee.REGED].includes(i);
484
484
  })), this.session = e, this.gatewayStateTask = Ct({}), this.session.on("telnyx.socket.message", this.onSocketMessage);
485
485
  }
486
486
  }
487
- class ln extends Q {
487
+ class dn extends Q {
488
488
  constructor(e) {
489
- super(), this.method = $.Ping, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
489
+ super(), this.method = F.Ping, this.buildRequest({ method: this.method, voice_sdk_id: e, params: {} });
490
490
  }
491
491
  }
492
- var dn = "2.25.24", gt = dn;
493
- class Zn extends Q {
492
+ var un = "2.25.25", gt = un;
493
+ class ei extends Q {
494
494
  constructor(e, t, i, s, o = {}, r) {
495
495
  super(), this.method = "login";
496
496
  const l = { login: e, passwd: t, login_token: i, userVariables: o, reconnection: r, loginParams: {}, "User-Agent": { sdkVersion: gt, data: navigator.userAgent } };
497
497
  s && (l.sessid = s), this.buildRequest({ method: this.method, params: l });
498
498
  }
499
499
  }
500
- class ei extends Q {
500
+ class ti extends Q {
501
501
  constructor(e, t) {
502
502
  super(), this.buildRequest({ id: e, result: { method: t } });
503
503
  }
504
504
  }
505
505
  class Et extends Q {
506
506
  toString() {
507
- return $.Invite;
507
+ return F.Invite;
508
508
  }
509
509
  }
510
510
  class Tt extends Q {
511
511
  toString() {
512
- return $.Answer;
512
+ return F.Answer;
513
513
  }
514
514
  }
515
515
  class Rt extends Q {
516
516
  toString() {
517
- return $.Attach;
518
- }
519
- }
520
- class ti extends Q {
521
- toString() {
522
- return $.Bye;
517
+ return F.Attach;
523
518
  }
524
519
  }
525
520
  class ni extends Q {
526
521
  toString() {
527
- return $.Candidate;
522
+ return F.Bye;
528
523
  }
529
524
  }
530
525
  class ii extends Q {
531
526
  toString() {
532
- return $.EndOfCandidates;
527
+ return F.Candidate;
533
528
  }
534
529
  }
535
- class et extends Q {
530
+ class si extends Q {
536
531
  toString() {
537
- return $.Modify;
532
+ return F.EndOfCandidates;
538
533
  }
539
534
  }
540
- class At extends Q {
535
+ class et extends Q {
541
536
  toString() {
542
- return $.Info;
537
+ return F.Modify;
543
538
  }
544
539
  }
545
- class si extends Q {
540
+ class At extends Q {
546
541
  toString() {
547
- return $.Broadcast;
542
+ return F.Info;
548
543
  }
549
544
  }
550
545
  class oi extends Q {
551
546
  toString() {
552
- return $.Subscribe;
547
+ return F.Broadcast;
553
548
  }
554
549
  }
555
550
  class ri extends Q {
556
551
  toString() {
557
- return $.Unsubscribe;
552
+ return F.Subscribe;
558
553
  }
559
554
  }
560
555
  class ai extends Q {
556
+ toString() {
557
+ return F.Unsubscribe;
558
+ }
559
+ }
560
+ class ci extends Q {
561
561
  constructor(e) {
562
562
  super(), this.method = "anonymous_login";
563
- const { target_type: t, target_id: i, target_version_id: s, userVariables: o, sessionId: r, reconnection: l } = e, c = { target_type: t, target_id: i, userVariables: o, reconnection: l, "User-Agent": { sdkVersion: gt, data: navigator.userAgent } };
564
- r && (c.sessid = r), s && (c.target_version_id = s), this.buildRequest({ method: this.method, params: c });
563
+ const { target_type: t, target_id: i, target_version_id: s, target_params: o, userVariables: r, sessionId: l, reconnection: c } = e, u = { target_type: t, target_id: i, userVariables: r, reconnection: c, "User-Agent": { sdkVersion: gt, data: navigator.userAgent } };
564
+ l && (u.sessid = l), s && (u.target_version_id = s), o && (u.target_params = o), this.buildRequest({ method: this.method, params: u });
565
565
  }
566
566
  }
567
- class ci {
567
+ class li {
568
568
  constructor(e) {
569
569
  if (this.options = e, this.uuid = me(), this.sessionid = "", this.subscriptions = {}, this.signature = null, this.relayProtocol = null, this.contexts = [], this.timeoutErrorCode = -32e3, this.invalidMethodErrorCode = -32601, this.authenticationRequiredErrorCode = -32e3, this.callReportId = null, this.connection = null, this._jwtAuth = !1, this._autoReconnect = !0, this._idle = !1, this._executeQueue = [], !this.validateOptions()) throw new Error("Invalid init options");
570
570
  var t, i;
571
- t = e.debug ? "debug" : "info", tn = (i = je[t]) !== null && i !== void 0 ? i : je.info, this._onSocketOpen = this._onSocketOpen.bind(this), this.onNetworkClose = this.onNetworkClose.bind(this), this._onSocketMessage = this._onSocketMessage.bind(this), this._handleLoginError = this._handleLoginError.bind(this), this._attachListeners(), this.connection = new It(this), this.registerAgent = new Qn(this);
571
+ t = e.debug ? "debug" : "info", nn = (i = je[t]) !== null && i !== void 0 ? i : je.info, this._onSocketOpen = this._onSocketOpen.bind(this), this.onNetworkClose = this.onNetworkClose.bind(this), this._onSocketMessage = this._onSocketMessage.bind(this), this._handleLoginError = this._handleLoginError.bind(this), this._attachListeners(), this.connection = new It(this), this.registerAgent = new Zn(this);
572
572
  }
573
573
  get __logger() {
574
- return v;
574
+ return g;
575
575
  }
576
576
  get connected() {
577
577
  return this.connection && this.connection.connected;
@@ -582,11 +582,11 @@ class ci {
582
582
  }));
583
583
  }
584
584
  get reconnectDelay() {
585
- return 1e3 * on(2, 6);
585
+ return 1e3 * rn(2, 6);
586
586
  }
587
587
  execute(e) {
588
588
  return this._idle ? new Promise(((t) => this._executeQueue.push({ resolve: t, msg: e }))) : this.connected ? this.connection.send(e) : new Promise(((t) => {
589
- this._executeQueue.push({ resolve: t, msg: e }), v.debug("Calling connect from execute since not currently connected."), this.connect();
589
+ this._executeQueue.push({ resolve: t, msg: e }), g.debug("Calling connect from execute since not currently connected."), this.connect();
590
590
  }));
591
591
  }
592
592
  executeRaw(e) {
@@ -599,7 +599,7 @@ class ci {
599
599
  }
600
600
  disconnect() {
601
601
  return O(this, void 0, void 0, (function* () {
602
- clearTimeout(this._reconnectTimeout), this.subscriptions = {}, this._autoReconnect = !1, this.relayProtocol = null, this._closeConnection(), yield sessionStorage.removeItem(this.signature), this._executeQueue = [], this._detachListeners(), v.debug("Session disconnected. Cleaned up all listeners and subscriptions, closed connection, disabled auto-reconnect.");
602
+ clearTimeout(this._reconnectTimeout), this.subscriptions = {}, this._autoReconnect = !1, this.relayProtocol = null, this._closeConnection(), yield sessionStorage.removeItem(this.signature), this._executeQueue = [], this._detachListeners(), g.debug("Session disconnected. Cleaned up all listeners and subscriptions, closed connection, disabled auto-reconnect.");
603
603
  }));
604
604
  }
605
605
  on(e, t) {
@@ -610,7 +610,7 @@ class ci {
610
610
  }
611
611
  connect() {
612
612
  return O(this, void 0, void 0, (function* () {
613
- this.connection || (v.debug("No existing connection found, creating a new one."), this.connection = new It(this)), this._attachListeners(), this._autoReconnect = !0, this.connection.isAlive || (v.debug("Initiating connection to the server..."), this.connection.connect()), v.debug("Connect method called. Connection initiated.");
613
+ this.connection || (g.debug("No existing connection found, creating a new one."), this.connection = new It(this)), this._attachListeners(), this._autoReconnect = !0, this.connection.isAlive || (g.debug("Initiating connection to the server..."), this.connection.connect()), g.debug("Connect method called. Connection initiated.");
614
614
  }));
615
615
  }
616
616
  _handleLoginError(e) {
@@ -623,7 +623,7 @@ class ci {
623
623
  if (ke(this.options)) return this._login({ type: "anonymous_login", onSuccess: t, onError: i });
624
624
  {
625
625
  const s = "Invalid login options provided for authentication.";
626
- return v.error(s), void j(x.Error, { error: new Error(s), type: qn.invalidCredentialsOptions, sessionId: this.sessionid }, this.uuid);
626
+ return g.error(s), void j(x.Error, { error: new Error(s), type: Yn.invalidCredentialsOptions, sessionId: this.sessionid }, this.uuid);
627
627
  }
628
628
  }
629
629
  }));
@@ -631,7 +631,7 @@ class ci {
631
631
  _login({ type: e, onSuccess: t, onError: i }) {
632
632
  return O(this, void 0, void 0, (function* () {
633
633
  let s;
634
- s = e === "login" ? new Zn(this.options.login, this.options.password || this.options.passwd, this.options.login_token, this.sessionid, this.options.userVariables, !!he()) : new ai({ target_id: this.options.anonymous_login.target_id, target_type: this.options.anonymous_login.target_type, target_version_id: this.options.anonymous_login.target_version_id, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!he() });
634
+ s = e === "login" ? new ei(this.options.login, this.options.password || this.options.passwd, this.options.login_token, this.sessionid, this.options.userVariables, !!he()) : new ci({ target_id: this.options.anonymous_login.target_id, target_type: this.options.anonymous_login.target_type, target_version_id: this.options.anonymous_login.target_version_id, target_params: this.options.anonymous_login.target_params, sessionId: this.sessionid, userVariables: this.options.userVariables, reconnection: !!he() });
635
635
  const o = yield this.execute(s).catch(((r) => {
636
636
  this._handleLoginError(r), i && i(r);
637
637
  }));
@@ -646,7 +646,7 @@ class ci {
646
646
  this.relayProtocol && Ze(this.relayProtocol);
647
647
  for (const e in this.subscriptions) Ze(e);
648
648
  this.subscriptions = {}, this.contexts = [], clearTimeout(this._keepAliveTimeout), clearTimeout(this._reconnectTimeout), this.connection && (this.connection.previousGatewayState = ""), this._autoReconnect && (this._reconnectTimeout = setTimeout((() => {
649
- v.debug("Calling connect due to network close and auto-reconnect enabled."), this.connect();
649
+ g.debug("Calling connect due to network close and auto-reconnect enabled."), this.connect();
650
650
  }), this.reconnectDelay));
651
651
  }
652
652
  _onSocketMessage(e) {
@@ -675,13 +675,13 @@ class ci {
675
675
  this._idle = !0, clearTimeout(this._keepAliveTimeout), this.connection && this.connection.close();
676
676
  }
677
677
  _resetKeepAlive() {
678
- this._pong === !1 && (v.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new ln(he()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
678
+ this._pong === !1 && (g.warn("No ping/pong received, forcing PING ACK to keep alive"), this.execute(new dn(he()))), clearTimeout(this._keepAliveTimeout), this._triggerKeepAliveTimeoutCheck();
679
679
  }
680
680
  _triggerKeepAliveTimeoutCheck() {
681
681
  this._pong = !1, this._keepAliveTimeout = setTimeout((() => this._resetKeepAlive()), 35e3);
682
682
  }
683
683
  setPingReceived() {
684
- v.debug("Ping received"), this._pong = !0;
684
+ g.debug("Ping received"), this._pong = !0;
685
685
  }
686
686
  static on(e, t) {
687
687
  de(e, t);
@@ -702,27 +702,27 @@ class ci {
702
702
  const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n instanceof MediaStream, Ee = (n, e) => {
703
703
  const t = Ue(n);
704
704
  t !== null && (t.getAttribute("autoplay") || t.setAttribute("autoplay", "autoplay"), t.getAttribute("playsinline") || t.setAttribute("playsinline", "playsinline"), t.srcObject = e);
705
- }, un = (n, e) => O(void 0, void 0, void 0, (function* () {
705
+ }, hn = (n, e) => O(void 0, void 0, void 0, (function* () {
706
706
  const t = Ue(n);
707
- if (t === null) return v.info("No HTMLMediaElement to attach the speakerId"), !1;
708
- if (typeof e != "string") return v.info(`Invalid speaker deviceId: '${e}'`), !1;
707
+ if (t === null) return g.info("No HTMLMediaElement to attach the speakerId"), !1;
708
+ if (typeof e != "string") return g.info(`Invalid speaker deviceId: '${e}'`), !1;
709
709
  try {
710
710
  return yield t.setSinkId(e), !0;
711
711
  } catch {
712
712
  return !1;
713
713
  }
714
- })), li = (n) => {
714
+ })), di = (n) => {
715
715
  n && n.readyState === "live" && n.stop();
716
716
  }, Te = (n) => {
717
- ge(n) && n.getTracks().forEach(li), n = null;
717
+ ge(n) && n.getTracks().forEach(di), n = null;
718
718
  }, Be = (n) => O(void 0, void 0, void 0, (function* () {
719
- v.info("RTCService.getUserMedia", n);
719
+ g.info("RTCService.getUserMedia", n);
720
720
  const { audio: e, video: t } = n;
721
721
  if (!e && !t) return null;
722
722
  try {
723
723
  return yield $e(n);
724
724
  } catch (i) {
725
- if (v.error("getUserMedia error: ", i), ((s) => s.name === "NotReadableError" || s.name === "NotFoundError" || s.name === "OverconstrainedError")(i)) {
725
+ if (g.error("getUserMedia error: ", i), ((s) => s.name === "NotReadableError" || s.name === "NotFoundError" || s.name === "OverconstrainedError")(i)) {
726
726
  const s = ((o) => {
727
727
  const { audio: r, video: l } = o;
728
728
  let c = !1, u = r, p = l;
@@ -739,11 +739,11 @@ const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n ins
739
739
  return c ? { audio: u, video: p } : null;
740
740
  })(n);
741
741
  if (s) {
742
- v.warn("Device not found or not readable, falling back to default device");
742
+ g.warn("Device not found or not readable, falling back to default device");
743
743
  try {
744
744
  return yield $e(s);
745
745
  } catch (o) {
746
- throw v.error("Fallback getUserMedia also failed: ", o), i;
746
+ throw g.error("Fallback getUserMedia also failed: ", o), i;
747
747
  }
748
748
  }
749
749
  }
@@ -751,7 +751,7 @@ const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n ins
751
751
  }
752
752
  })), Ie = (n = null, e = !1) => O(void 0, void 0, void 0, (function* () {
753
753
  let t = [];
754
- const i = yield navigator.mediaDevices.getUserMedia(((s = null) => ({ audio: !s || s === ae.AudioIn || s === ae.AudioOut, video: !s || s === ae.Video }))(n)).catch(((s) => (v.error(s), null)));
754
+ const i = yield navigator.mediaDevices.getUserMedia(((s = null) => ({ audio: !s || s === ae.AudioIn || s === ae.AudioOut, video: !s || s === ae.Video }))(n)).catch(((s) => (g.error(s), null)));
755
755
  if (i) {
756
756
  if (Te(i), t = yield navigator.mediaDevices.enumerateDevices(), n && (t = t.filter(((o) => o.kind === n))), e === !0) return t;
757
757
  const s = [];
@@ -769,7 +769,7 @@ const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n ins
769
769
  if (n === o || e === r) return o;
770
770
  }
771
771
  return null;
772
- })), di = (n) => {
772
+ })), ui = (n) => {
773
773
  const e = navigator.mediaDevices.getSupportedConstraints();
774
774
  Object.keys(n).map(((t) => {
775
775
  e.hasOwnProperty(t) && n[t] !== null && n[t] !== void 0 || delete n[t];
@@ -816,7 +816,7 @@ const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n ins
816
816
  ve(n, "audio", !1);
817
817
  }, Ot = (n) => {
818
818
  ve(n, "audio", null);
819
- }, ui = (n) => ((e, t = null) => {
819
+ }, hi = (n) => ((e, t = null) => {
820
820
  if (!ge(e)) return null;
821
821
  let i = [];
822
822
  switch (t) {
@@ -831,7 +831,7 @@ const $e = (n) => navigator.mediaDevices.getUserMedia(n), ge = (n) => n && n ins
831
831
  }
832
832
  return i.some(((s) => s.enabled));
833
833
  })(n, "audio");
834
- function hi() {
834
+ function pi() {
835
835
  try {
836
836
  const { browserInfo: n, name: e, version: t, supportAudio: i, supportVideo: s } = (function() {
837
837
  if (!window || !window.navigator || !window.navigator.userAgent) throw new Error("You should use @telnyx/webrtc in a web browser such as Chrome|Firefox|Safari");
@@ -872,7 +872,7 @@ function Pt(n) {
872
872
  n && (n._playFulfilled = !1, n._promise = n.play(), n._promise.then((() => {
873
873
  n._playFulfilled = !0;
874
874
  })).catch(((e) => {
875
- v.error("playAudio", e), n._playFulfilled = !0;
875
+ g.error("playAudio", e), n._playFulfilled = !0;
876
876
  })));
877
877
  }
878
878
  function Dt(n) {
@@ -885,7 +885,14 @@ function Dt(n) {
885
885
  (function(n) {
886
886
  n.not_supported = "not supported", n.full = "full", n.partial = "partial";
887
887
  })(q || (q = {}));
888
- class pi extends Ae {
888
+ const Nt = (n) => {
889
+ const e = [], t = [];
890
+ return n && n.length !== 0 ? (n.forEach(((i) => {
891
+ const s = i.mimeType.toLocaleLowerCase();
892
+ s.startsWith("audio/") ? e.push(i) : s.startsWith("video/") && t.push(i);
893
+ })), { audioCodecs: e, videoCodecs: t }) : { audioCodecs: e, videoCodecs: t };
894
+ };
895
+ class fi extends Ae {
889
896
  constructor(e, t) {
890
897
  super(), this.method = "ai_conversation", this.buildRequest({ method: this.method, params: { type: "conversation.item.create", previous_item_id: null, item: { id: me(), type: "message", role: "user", content: [{ type: "input_text", text: e }, ...t?.map(((i) => ({ type: "image_url", image_url: { url: i } })))] } } });
891
898
  }
@@ -893,12 +900,12 @@ class pi extends Ae {
893
900
  class ce {
894
901
  constructor(e, t) {
895
902
  this.peerConnection = null, this.intervalId = null, this.statsBuffer = [], this.intervalStartTime = null, this.callEndTime = null, this.logCollector = null, this.intervalAudioLevels = { outbound: [], inbound: [] }, this.intervalJitters = [], this.intervalRTTs = [], this.intervalBitrates = { outbound: [], inbound: [] }, this.previousStats = {}, this.previousCandidatePairId = null, this.MAX_BUFFER_SIZE = 360, this.onFlushNeeded = null, this._segmentIndex = 0, this._flushing = !1, this.options = e, this.logCollectorOptions = t || { enabled: !1, level: "debug", maxEntries: 1e3 }, this.callStartTime = /* @__PURE__ */ new Date(), this.logCollectorOptions.enabled && (this.logCollector = (function(i) {
896
- return new Vn(i);
903
+ return new Gn(i);
897
904
  })(this.logCollectorOptions), this.logCollector.start(), St(this.logCollector));
898
905
  }
899
906
  start(e) {
900
907
  var t, i;
901
- this.options.enabled && (this.peerConnection = e, this.intervalStartTime = /* @__PURE__ */ new Date(), v.info("CallReportCollector: Starting stats collection", { interval: this.options.interval, logCollectorActive: (i = (t = this.logCollector) === null || t === void 0 ? void 0 : t.isActive()) !== null && i !== void 0 && i }), this.intervalId = setInterval((() => {
908
+ this.options.enabled && (this.peerConnection = e, this.intervalStartTime = /* @__PURE__ */ new Date(), g.info("CallReportCollector: Starting stats collection", { interval: this.options.interval, logCollectorActive: (i = (t = this.logCollector) === null || t === void 0 ? void 0 : t.isActive()) !== null && i !== void 0 && i }), this.intervalId = setInterval((() => {
902
909
  this._collectStats();
903
910
  }), this.options.interval));
904
911
  }
@@ -907,7 +914,7 @@ class ce {
907
914
  return O(this, void 0, void 0, (function* () {
908
915
  this.intervalId && (clearInterval(this.intervalId), this.intervalId = null), this.callEndTime = /* @__PURE__ */ new Date(), this.peerConnection && this.intervalStartTime && (yield this._collectStats(!0));
909
916
  const i = (t = (e = this.logCollector) === null || e === void 0 ? void 0 : e.getLogCount()) !== null && t !== void 0 ? t : 0;
910
- this.logCollector && this.logCollector.stop(), v.info("CallReportCollector: Stopped stats collection", { totalIntervals: this.statsBuffer.length, totalLogs: i, duration: this.callEndTime.getTime() - this.callStartTime.getTime() });
917
+ this.logCollector && this.logCollector.stop(), g.info("CallReportCollector: Stopped stats collection", { totalIntervals: this.statsBuffer.length, totalLogs: i, duration: this.callEndTime.getTime() - this.callStartTime.getTime() });
911
918
  }));
912
919
  }
913
920
  flush(e) {
@@ -918,7 +925,7 @@ class ce {
918
925
  const s = this._segmentIndex++, o = this.statsBuffer;
919
926
  this.statsBuffer = [];
920
927
  const r = (i = (t = this.logCollector) === null || t === void 0 ? void 0 : t.drain()) !== null && i !== void 0 ? i : [], l = /* @__PURE__ */ new Date(), c = Object.assign(Object.assign({ summary: Object.assign(Object.assign({}, e), { durationSeconds: (l.getTime() - this.callStartTime.getTime()) / 1e3, startTimestamp: this.callStartTime.toISOString(), endTimestamp: l.toISOString() }), stats: o }, r.length > 0 ? { logs: r } : {}), { segment: s });
921
- return v.info("CallReportCollector: Flushed intermediate segment", { segment: s, intervals: o.length, logEntries: r.length, callId: e.callId }), c;
928
+ return g.info("CallReportCollector: Flushed intermediate segment", { segment: s, intervals: o.length, logEntries: r.length, callId: e.callId }), c;
922
929
  } finally {
923
930
  this._flushing = !1;
924
931
  }
@@ -927,8 +934,8 @@ class ce {
927
934
  var o, r;
928
935
  return O(this, void 0, void 0, (function* () {
929
936
  const l = (o = this.logCollector) === null || o === void 0 ? void 0 : o.getLogs(), c = l && l.length > 0;
930
- if (!this.options.enabled) return void v.info("CallReportCollector: Skipping report — call reports disabled");
931
- if (this.statsBuffer.length === 0 && !c) return void v.info("CallReportCollector: Skipping report — no stats or logs collected");
937
+ if (!this.options.enabled) return void g.info("CallReportCollector: Skipping report — call reports disabled");
938
+ if (this.statsBuffer.length === 0 && !c) return void g.info("CallReportCollector: Skipping report — no stats or logs collected");
932
939
  const u = this._segmentIndex > 0, p = this._segmentIndex, f = Object.assign(Object.assign({ summary: Object.assign(Object.assign({}, e), { durationSeconds: this.callEndTime && this.callStartTime ? (this.callEndTime.getTime() - this.callStartTime.getTime()) / 1e3 : void 0, startTimestamp: this.callStartTime.toISOString(), endTimestamp: (r = this.callEndTime) === null || r === void 0 ? void 0 : r.toISOString() }), stats: this.statsBuffer }, l && l.length > 0 ? { logs: l } : {}), u ? { segment: p } : {});
933
940
  yield this._sendPayload(f, t, i, s);
934
941
  }));
@@ -943,28 +950,28 @@ class ce {
943
950
  return O(this, void 0, void 0, (function* () {
944
951
  try {
945
952
  const l = new URL(i), c = `${l.protocol.replace(/^ws/, "http")}//${l.host}/call_report`, u = e.segment !== void 0 && !e.summary.endTimestamp ? `intermediate segment ${e.segment}` : "final report";
946
- v.info(`CallReportCollector: Posting ${u}`, { endpoint: c, intervals: e.stats.length, logEntries: (r = (o = e.logs) === null || o === void 0 ? void 0 : o.length) !== null && r !== void 0 ? r : 0, callId: e.summary.callId, segment: e.segment });
953
+ g.info(`CallReportCollector: Posting ${u}`, { endpoint: c, intervals: e.stats.length, logEntries: (r = (o = e.logs) === null || o === void 0 ? void 0 : o.length) !== null && r !== void 0 ? r : 0, callId: e.summary.callId, segment: e.segment });
947
954
  const p = { "Content-Type": "application/json", "x-call-report-id": t, "x-call-id": e.summary.callId };
948
955
  s && (p["x-voice-sdk-id"] = s);
949
956
  const f = JSON.stringify(e), C = () => fetch(c, { method: "POST", headers: p, body: f }), b = yield C();
950
- if (b.ok) v.info(`CallReportCollector: Successfully posted ${u}`);
957
+ if (b.ok) g.info(`CallReportCollector: Successfully posted ${u}`);
951
958
  else {
952
959
  const y = yield b.text();
953
- v.error(`CallReportCollector: Failed to post ${u}`, { status: b.status, error: y });
960
+ g.error(`CallReportCollector: Failed to post ${u}`, { status: b.status, error: y });
954
961
  }
955
962
  } catch (l) {
956
- v.warn(`CallReportCollector: Network error posting call report, retrying in ${ce.RETRY_DELAY_MS}ms`, { error: l }), yield new Promise(((c) => setTimeout(c, ce.RETRY_DELAY_MS)));
963
+ g.warn(`CallReportCollector: Network error posting call report, retrying in ${ce.RETRY_DELAY_MS}ms`, { error: l }), yield new Promise(((c) => setTimeout(c, ce.RETRY_DELAY_MS)));
957
964
  try {
958
965
  const c = new URL(i), u = `${c.protocol.replace(/^ws/, "http")}//${c.host}/call_report`, p = { "Content-Type": "application/json", "x-call-report-id": t, "x-call-id": e.summary.callId };
959
966
  s && (p["x-voice-sdk-id"] = s);
960
967
  const f = yield fetch(u, { method: "POST", headers: p, body: JSON.stringify(e) });
961
- if (f.ok) v.info("CallReportCollector: Successfully posted call report on retry");
968
+ if (f.ok) g.info("CallReportCollector: Successfully posted call report on retry");
962
969
  else {
963
970
  const C = yield f.text();
964
- v.error("CallReportCollector: Failed to post call report on retry", { status: f.status, error: C });
971
+ g.error("CallReportCollector: Failed to post call report on retry", { status: f.status, error: C });
965
972
  }
966
973
  } catch (c) {
967
- v.error("CallReportCollector: Retry also failed, giving up", { error: c });
974
+ g.error("CallReportCollector: Retry also failed, giving up", { error: c });
968
975
  }
969
976
  }
970
977
  }));
@@ -977,7 +984,7 @@ class ce {
977
984
  return (t = (e = this.logCollector) === null || e === void 0 ? void 0 : e.getLogs()) !== null && t !== void 0 ? t : [];
978
985
  }
979
986
  cleanup() {
980
- this.logCollector && (this.logCollector.clear(), en() === this.logCollector && St(null), this.logCollector = null);
987
+ this.logCollector && (this.logCollector.clear(), tn() === this.logCollector && St(null), this.logCollector = null);
981
988
  }
982
989
  _collectStats(e = !1) {
983
990
  var t, i, s;
@@ -1002,9 +1009,9 @@ class ce {
1002
1009
  })), u) {
1003
1010
  const y = this._getOutboundAudioLevel(o, u);
1004
1011
  if (y !== null && this.intervalAudioLevels.outbound.push(y), this.previousStats.outboundBytes !== void 0 && this.previousStats.timestamp !== void 0) {
1005
- const I = (u.bytesSent || 0) - this.previousStats.outboundBytes, g = (u.timestamp || r.getTime()) - this.previousStats.timestamp;
1006
- if (g > 0) {
1007
- const w = 8 * I * 1e3 / g;
1012
+ const I = (u.bytesSent || 0) - this.previousStats.outboundBytes, v = (u.timestamp || r.getTime()) - this.previousStats.timestamp;
1013
+ if (v > 0) {
1014
+ const w = 8 * I * 1e3 / v;
1008
1015
  this.intervalBitrates.outbound.push(w);
1009
1016
  }
1010
1017
  }
@@ -1013,33 +1020,33 @@ class ce {
1013
1020
  if (p) {
1014
1021
  const y = this._getInboundAudioLevel(o, p);
1015
1022
  if (y !== null && this.intervalAudioLevels.inbound.push(y), p.jitter !== void 0 && this.intervalJitters.push(1e3 * p.jitter), this.previousStats.inboundBytes !== void 0 && this.previousStats.timestamp !== void 0) {
1016
- const I = (p.bytesReceived || 0) - this.previousStats.inboundBytes, g = (p.timestamp || r.getTime()) - this.previousStats.timestamp;
1017
- if (g > 0) {
1018
- const w = 8 * I * 1e3 / g;
1023
+ const I = (p.bytesReceived || 0) - this.previousStats.inboundBytes, v = (p.timestamp || r.getTime()) - this.previousStats.timestamp;
1024
+ if (v > 0) {
1025
+ const w = 8 * I * 1e3 / v;
1019
1026
  this.intervalBitrates.inbound.push(w);
1020
1027
  }
1021
1028
  }
1022
1029
  this.previousStats.inboundBytes = p.bytesReceived;
1023
1030
  }
1024
- f && (f.currentRoundTripTime !== void 0 && this.intervalRTTs.push(f.currentRoundTripTime), this.previousCandidatePairId !== null && f.id !== this.previousCandidatePairId && v.debug("CallReportCollector: ICE candidate pair changed mid-call", { previous: this.previousCandidatePairId, current: f.id }), this.previousCandidatePairId = (t = f.id) !== null && t !== void 0 ? t : null), f && (l = this._resolveCandidate(o, f.localCandidateId), c = this._resolveCandidate(o, f.remoteCandidateId)), this.previousStats.timestamp = r.getTime();
1031
+ f && (f.currentRoundTripTime !== void 0 && this.intervalRTTs.push(f.currentRoundTripTime), this.previousCandidatePairId !== null && f.id !== this.previousCandidatePairId && g.debug("CallReportCollector: ICE candidate pair changed mid-call", { previous: this.previousCandidatePairId, current: f.id }), this.previousCandidatePairId = (t = f.id) !== null && t !== void 0 ? t : null), f && (l = this._resolveCandidate(o, f.localCandidateId), c = this._resolveCandidate(o, f.remoteCandidateId)), this.previousStats.timestamp = r.getTime();
1025
1032
  const b = r.getTime() - this.intervalStartTime.getTime();
1026
1033
  if (e || b >= this.options.interval) {
1027
1034
  const y = this._createStatsEntry(this.intervalStartTime, r, u, p, f, l, c, C);
1028
- if (this.statsBuffer.push(y), this.statsBuffer.length > this.MAX_BUFFER_SIZE && (this.statsBuffer.shift(), v.warn("CallReportCollector: Buffer size limit reached, removing oldest entry")), this.onFlushNeeded && !this._flushing) {
1029
- const I = this.statsBuffer.length, g = (s = (i = this.logCollector) === null || i === void 0 ? void 0 : i.getLogCount()) !== null && s !== void 0 ? s : 0;
1030
- if (I >= ce.STATS_FLUSH_THRESHOLD || g >= ce.LOGS_FLUSH_THRESHOLD) {
1031
- v.info("CallReportCollector: Approaching buffer limits, requesting flush", { statsIntervals: I, logEntries: g });
1035
+ if (this.statsBuffer.push(y), this.statsBuffer.length > this.MAX_BUFFER_SIZE && (this.statsBuffer.shift(), g.warn("CallReportCollector: Buffer size limit reached, removing oldest entry")), this.onFlushNeeded && !this._flushing) {
1036
+ const I = this.statsBuffer.length, v = (s = (i = this.logCollector) === null || i === void 0 ? void 0 : i.getLogCount()) !== null && s !== void 0 ? s : 0;
1037
+ if (I >= ce.STATS_FLUSH_THRESHOLD || v >= ce.LOGS_FLUSH_THRESHOLD) {
1038
+ g.info("CallReportCollector: Approaching buffer limits, requesting flush", { statsIntervals: I, logEntries: v });
1032
1039
  try {
1033
1040
  this.onFlushNeeded();
1034
1041
  } catch (w) {
1035
- v.error("CallReportCollector: onFlushNeeded callback error", { error: w });
1042
+ g.error("CallReportCollector: onFlushNeeded callback error", { error: w });
1036
1043
  }
1037
1044
  }
1038
1045
  }
1039
1046
  this.intervalStartTime = r, this._resetIntervalAccumulators();
1040
1047
  }
1041
1048
  } catch (o) {
1042
- v.error("CallReportCollector: Error collecting stats", { error: o });
1049
+ g.error("CallReportCollector: Error collecting stats", { error: o });
1043
1050
  }
1044
1051
  }));
1045
1052
  }
@@ -1048,12 +1055,12 @@ class ce {
1048
1055
  return i && (u.audio.outbound = { packetsSent: i.packetsSent, bytesSent: i.bytesSent, audioLevelAvg: this._average(this.intervalAudioLevels.outbound), bitrateAvg: this._average(this.intervalBitrates.outbound) }), s && (u.audio.inbound = { packetsReceived: s.packetsReceived, bytesReceived: s.bytesReceived, packetsLost: s.packetsLost, packetsDiscarded: s.packetsDiscarded, jitterBufferDelay: s.jitterBufferDelay, jitterBufferEmittedCount: s.jitterBufferEmittedCount, totalSamplesReceived: s.totalSamplesReceived, concealedSamples: s.concealedSamples, concealmentEvents: s.concealmentEvents, audioLevelAvg: this._average(this.intervalAudioLevels.inbound), jitterAvg: this._average(this.intervalJitters), bitrateAvg: this._average(this.intervalBitrates.inbound) }), o && (u.connection = { roundTripTimeAvg: this._average(this.intervalRTTs), packetsSent: o.packetsSent, packetsReceived: o.packetsReceived, bytesSent: o.bytesSent, bytesReceived: o.bytesReceived }, u.ice = Object.assign(Object.assign({ id: o.id, state: o.state, nominated: o.nominated, writable: o.writable, requestsSent: o.requestsSent, responsesReceived: o.responsesReceived }, r ? { local: r } : {}), l ? { remote: l } : {})), c && (u.transport = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, c.iceState !== void 0 ? { iceState: c.iceState } : {}), c.dtlsState !== void 0 ? { dtlsState: c.dtlsState } : {}), c.srtpCipher !== void 0 ? { srtpCipher: c.srtpCipher } : {}), c.tlsVersion !== void 0 ? { tlsVersion: c.tlsVersion } : {}), c.selectedCandidatePairChanges !== void 0 ? { selectedCandidatePairChanges: c.selectedCandidatePairChanges } : {})), u;
1049
1056
  }
1050
1057
  _resolveCandidate(e, t) {
1051
- if (!t) return void v.debug("CallReportCollector: candidateId is empty, skipping resolve");
1058
+ if (!t) return void g.debug("CallReportCollector: candidateId is empty, skipping resolve");
1052
1059
  const i = e.get(t);
1053
- if (!i) return void v.debug("CallReportCollector: candidate not found in stats report", { candidateId: t });
1060
+ if (!i) return void g.debug("CallReportCollector: candidate not found in stats report", { candidateId: t });
1054
1061
  const s = {};
1055
1062
  if (i.address !== void 0 && (s.address = i.address), i.port !== void 0 && (s.port = i.port), i.candidateType !== void 0 && (s.candidateType = i.candidateType), i.protocol !== void 0 && (s.protocol = i.protocol), i.networkType !== void 0 && (s.networkType = i.networkType), Object.keys(s).length !== 0) return s;
1056
- v.debug("CallReportCollector: candidate report has no usable fields", { candidateId: t });
1063
+ g.debug("CallReportCollector: candidate report has no usable fields", { candidateId: t });
1057
1064
  }
1058
1065
  _getOutboundAudioLevel(e, t) {
1059
1066
  let i;
@@ -1096,7 +1103,7 @@ class ce {
1096
1103
  }
1097
1104
  }
1098
1105
  ce.STATS_FLUSH_THRESHOLD = 300, ce.LOGS_FLUSH_THRESHOLD = 800, ce.RETRY_DELAY_MS = 500;
1099
- var Oe, hn = Qt((function(n, e) {
1106
+ var Oe, pn = Zt((function(n, e) {
1100
1107
  var t;
1101
1108
  function i() {
1102
1109
  }
@@ -1113,8 +1120,8 @@ var Oe, hn = Qt((function(n, e) {
1113
1120
  if (typeof k == "function" ? k = E[d] = m ? [h, k] : [k, h] : m ? k.unshift(h) : k.push(h), !k.warned && (_ = o(a)) && 0 < _ && k.length > _) {
1114
1121
  k.warned = !0;
1115
1122
  var L = new Error("Possible EventEmitter memory leak detected. " + k.length + " " + d + " listeners added. Use emitter.setMaxListeners() to increase limit");
1116
- L.name = "MaxListenersExceededWarning", L.emitter = a, L.type = d, L.count = k.length, (function(F) {
1117
- typeof console.warn == "function" ? console.warn(F) : console.log(F);
1123
+ L.name = "MaxListenersExceededWarning", L.emitter = a, L.type = d, L.count = k.length, (function($) {
1124
+ typeof console.warn == "function" ? console.warn($) : console.log($);
1118
1125
  })(L);
1119
1126
  }
1120
1127
  } else k = E[d] = h, ++a._eventsCount;
@@ -1148,10 +1155,10 @@ var Oe, hn = Qt((function(n, e) {
1148
1155
  }, s.prototype.getMaxListeners = function() {
1149
1156
  return o(this);
1150
1157
  }, s.prototype.emit = function(a) {
1151
- var d, h, m, _, E, k, L, F = a === "error";
1152
- if (k = this._events) F = F && k.error == null;
1153
- else if (!F) return !1;
1154
- if (L = this.domain, F) {
1158
+ var d, h, m, _, E, k, L, $ = a === "error";
1159
+ if (k = this._events) $ = $ && k.error == null;
1160
+ else if (!$) return !1;
1161
+ if (L = this.domain, $) {
1155
1162
  if (d = arguments[1], !L) {
1156
1163
  if (d instanceof Error) throw d;
1157
1164
  var Z = new Error('Uncaught, unspecified "error" event. (' + d + ")");
@@ -1219,8 +1226,8 @@ var Oe, hn = Qt((function(n, e) {
1219
1226
  if (h.length === 1) {
1220
1227
  if (h[0] = void 0, --this._eventsCount == 0) return this._events = new i(), this;
1221
1228
  delete m[a];
1222
- } else (function(L, F) {
1223
- for (var Z = F, te = Z + 1, G = L.length; te < G; Z += 1, te += 1) L[Z] = L[te];
1229
+ } else (function(L, $) {
1230
+ for (var Z = $, te = Z + 1, G = L.length; te < G; Z += 1, te += 1) L[Z] = L[te];
1224
1231
  L.pop();
1225
1232
  })(h, _);
1226
1233
  m.removeListener && this.emit("removeListener", a, k || d);
@@ -1256,7 +1263,7 @@ var Oe, hn = Qt((function(n, e) {
1256
1263
  return p(f);
1257
1264
  }
1258
1265
  for (var b = /^(?:[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, y = [], I = 0; 256 > I; ++I) y.push((I + 256).toString(16).substr(1));
1259
- function g(a) {
1266
+ function v(a) {
1260
1267
  var d = 1 < arguments.length && arguments[1] !== void 0 ? arguments[1] : 0, h = (y[a[d + 0]] + y[a[d + 1]] + y[a[d + 2]] + y[a[d + 3]] + "-" + y[a[d + 4]] + y[a[d + 5]] + "-" + y[a[d + 6]] + y[a[d + 7]] + "-" + y[a[d + 8]] + y[a[d + 9]] + "-" + y[a[d + 10]] + y[a[d + 11]] + y[a[d + 12]] + y[a[d + 13]] + y[a[d + 14]] + y[a[d + 15]]).toLowerCase();
1261
1268
  if (!(function(m) {
1262
1269
  return typeof m == "string" && b.test(m);
@@ -1265,7 +1272,7 @@ var Oe, hn = Qt((function(n, e) {
1265
1272
  }
1266
1273
  function w(a, d, h) {
1267
1274
  var m = (a = a || {}).random || (a.rng || C)();
1268
- return m[6] = 64 | 15 & m[6], m[8] = 128 | 63 & m[8], g(m);
1275
+ return m[6] = 64 | 15 & m[6], m[8] = 128 | 63 & m[8], v(m);
1269
1276
  }
1270
1277
  function R(a, d) {
1271
1278
  if (!a || !d) return {};
@@ -1303,8 +1310,8 @@ var Oe, hn = Qt((function(n, e) {
1303
1310
  let L = {};
1304
1311
  if (!["audio", "video"].includes(E)) continue;
1305
1312
  if (_.codecId) {
1306
- const F = a.get(_.codecId);
1307
- F && (k.clockRate = F.clockRate, k.mimeType = F.mimeType, k.payloadType = F.payloadType);
1313
+ const $ = a.get(_.codecId);
1314
+ $ && (k.clockRate = $.clockRate, k.mimeType = $.mimeType, k.payloadType = $.payloadType);
1308
1315
  }
1309
1316
  L = a.get(_.mediaSourceId) || a.get(_.trackId) || {}, m[E].outbound.push({ ..._, ...k, track: { ...L } });
1310
1317
  break;
@@ -1318,13 +1325,13 @@ var Oe, hn = Qt((function(n, e) {
1318
1325
  E = "audio";
1319
1326
  }
1320
1327
  if (_.codecId) {
1321
- const F = a.get(_.codecId);
1322
- F && (L.clockRate = F.clockRate, L.mimeType = F.mimeType, L.payloadType = F.payloadType);
1328
+ const $ = a.get(_.codecId);
1329
+ $ && (L.clockRate = $.clockRate, L.mimeType = $.mimeType, L.payloadType = $.payloadType);
1323
1330
  }
1324
1331
  if (!m.connection.id && _.transportId) {
1325
- const F = a.get(_.transportId);
1326
- if (F && F.selectedCandidatePairId) {
1327
- const Z = a.get(F.selectedCandidatePairId);
1332
+ const $ = a.get(_.transportId);
1333
+ if ($ && $.selectedCandidatePairId) {
1334
+ const Z = a.get($.selectedCandidatePairId);
1328
1335
  m.connection = R(Z, a);
1329
1336
  }
1330
1337
  }
@@ -1350,8 +1357,8 @@ var Oe, hn = Qt((function(n, e) {
1350
1357
  if (!m.connection.id && _.transportId) {
1351
1358
  const L = a.get(_.transportId);
1352
1359
  if (L && L.selectedCandidatePairId) {
1353
- const F = a.get(L.selectedCandidatePairId);
1354
- m.connection = R(F, a);
1360
+ const $ = a.get(L.selectedCandidatePairId);
1361
+ m.connection = R($, a);
1355
1362
  }
1356
1363
  }
1357
1364
  m.remote[E].inbound.push({ ..._, ...k });
@@ -1372,16 +1379,16 @@ var Oe, hn = Qt((function(n, e) {
1372
1379
  if (!m.connection.id) for (const _ of a.values()) _.type === "candidate-pair" && _.nominated && _.state === "succeeded" && (m.connection = R(_, a));
1373
1380
  return m = (function(_, E) {
1374
1381
  return E && (_.audio.inbound.map(((k) => {
1375
- let L = E.audio.inbound.find(((F) => F.id === k.id));
1382
+ let L = E.audio.inbound.find((($) => $.id === k.id));
1376
1383
  k.bitrate = T(k, L, "bytesReceived"), k.packetRate = T(k, L, "packetsReceived");
1377
1384
  })), _.audio.outbound.map(((k) => {
1378
- let L = E.audio.outbound.find(((F) => F.id === k.id));
1385
+ let L = E.audio.outbound.find((($) => $.id === k.id));
1379
1386
  k.bitrate = T(k, L, "bytesSent"), k.packetRate = T(k, L, "packetsSent");
1380
1387
  })), _.video.inbound.map(((k) => {
1381
- let L = E.video.inbound.find(((F) => F.id === k.id));
1388
+ let L = E.video.inbound.find((($) => $.id === k.id));
1382
1389
  k.bitrate = T(k, L, "bytesReceived"), k.packetRate = T(k, L, "packetsReceived");
1383
1390
  })), _.video.outbound.map(((k) => {
1384
- let L = E.video.outbound.find(((F) => F.id === k.id));
1391
+ let L = E.video.outbound.find((($) => $.id === k.id));
1385
1392
  k.bitrate = T(k, L, "bytesSent"), k.packetRate = T(k, L, "packetsSent");
1386
1393
  }))), _;
1387
1394
  })(m, d), m;
@@ -1496,9 +1503,9 @@ var Oe, hn = Qt((function(n, e) {
1496
1503
  for (const m in d) for (const _ in d[m]) {
1497
1504
  const E = d[m][_], k = E.pc;
1498
1505
  if (k && !this.checkIfConnectionIsClosed(m, _, k)) try {
1499
- const L = this.getTimestamp(), F = k.getStats(null);
1500
- if (F) {
1501
- const Z = await F, te = this.getTimestamp(), G = A(Z), S = { remote: E.options.remote }, P = D(Z, E.stats.parsed, S), U = { event: "stats", tag: "stats", peerId: m, connectionId: _, timeTaken: te - L, data: P };
1506
+ const L = this.getTimestamp(), $ = k.getStats(null);
1507
+ if ($) {
1508
+ const Z = await $, te = this.getTimestamp(), G = A(Z), S = { remote: E.options.remote }, P = D(Z, E.stats.parsed, S), U = { event: "stats", tag: "stats", peerId: m, connectionId: _, timeTaken: te - L, data: P };
1502
1509
  this.rawStats === !0 && (U.rawStats = Z), this.statsObject === !0 && (U.statsObject = G), this.filteredStats === !0 && (U.filteredStats = this.filteroutStats(G)), h.push(U), E.stats.parsed = P;
1503
1510
  } else this.logger.error(`PeerConnection from peer ${m} did not return any stats data`);
1504
1511
  } catch (L) {
@@ -1670,9 +1677,9 @@ var Oe, hn = Qt((function(n, e) {
1670
1677
  }
1671
1678
  };
1672
1679
  }));
1673
- (Oe = hn) && Oe.__esModule && Object.prototype.hasOwnProperty.call(Oe, "default") && Oe.default;
1674
- var fi = hn.WebRTCStats;
1675
- function gi(n) {
1680
+ (Oe = pn) && Oe.__esModule && Object.prototype.hasOwnProperty.call(Oe, "default") && Oe.default;
1681
+ var gi = pn.WebRTCStats;
1682
+ function vi(n) {
1676
1683
  const { packetsLost: e, packetsReceived: t, jitter: i, rtt: s } = n, o = (function(u) {
1677
1684
  const { jitter: p, rtt: f } = u, C = p + f / 2;
1678
1685
  return 0.024 * C + 0.11 * (C - 177.3) * (C > 177.3 ? 1 : 0);
@@ -1682,48 +1689,48 @@ function gi(n) {
1682
1689
  })({ packetsLost: e, packetsReceived: t }), l = 93.2 - o - r + 0, c = 1 + 0.035 * l + 7e-6 * l * (l - 60) * (100 - l);
1683
1690
  return Math.min(Math.max(c, 1), 5);
1684
1691
  }
1685
- function vi(n) {
1692
+ function mi(n) {
1686
1693
  return isNaN(n) ? null : n > 4.2 ? "excellent" : n >= 4.1 && n <= 4.2 ? "good" : n >= 3.7 && n <= 4 ? "fair" : n >= 3.1 && n <= 3.6 ? "poor" : "bad";
1687
1694
  }
1688
- class mi extends Ae {
1695
+ class yi extends Ae {
1689
1696
  constructor(e, t) {
1690
1697
  super(), this.buildRequest({ type: "debug_report_start", debug_report_id: e, debug_report_version: 1, call_id: t });
1691
1698
  }
1692
1699
  }
1693
- class yi extends Ae {
1700
+ class bi extends Ae {
1694
1701
  constructor(e, t) {
1695
1702
  super(), this.buildRequest({ type: "debug_report_stop", debug_report_id: e, debug_report_version: 1, call_id: t });
1696
1703
  }
1697
1704
  }
1698
- class bi extends Ae {
1705
+ class Si extends Ae {
1699
1706
  constructor(e, t) {
1700
1707
  super(), this.buildRequest({ type: "debug_report_data", debug_report_id: e, debug_report_version: 1, debug_report_data: t });
1701
1708
  }
1702
1709
  }
1703
- function Nt(n, e) {
1710
+ function jt(n, e) {
1704
1711
  var t, i;
1705
1712
  return { errorCode: n.errorCode, errorText: n.errorText, url: n.url, address: n.address, port: n.port, connectionState: e.connectionState, iceConnectionState: e.iceConnectionState, iceGatheringState: e.iceGatheringState, signalingState: e.signalingState, localDescriptionType: (t = e.localDescription) === null || t === void 0 ? void 0 : t.type, remoteDescriptionType: (i = e.remoteDescription) === null || i === void 0 ? void 0 : i.type };
1706
1713
  }
1707
- function Si(n, e) {
1714
+ function _i(n, e) {
1708
1715
  const t = me();
1709
1716
  let i = !1;
1710
- const s = new fi({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), o = (r) => O(this, void 0, void 0, (function* () {
1717
+ const s = new gi({ getStatsInterval: 1e3, rawStats: !1, statsObject: !0, filteredStats: !1, remote: !0, debug: !1, logLevel: "warn" }), o = (r) => O(this, void 0, void 0, (function* () {
1711
1718
  r.event === "stats" && j(x.StatsFrame, (function({ data: l }) {
1712
1719
  var c, u, p, f, C, b, y, I;
1713
- const { audio: g, remote: w } = l, { audio: R } = w, T = (u = (c = R.inbound[0]) === null || c === void 0 ? void 0 : c.jitter) !== null && u !== void 0 ? u : 1 / 0, A = (f = (p = R.inbound[0]) === null || p === void 0 ? void 0 : p.roundTripTime) !== null && f !== void 0 ? f : 1 / 0, D = (b = (C = g.inbound[0]) === null || C === void 0 ? void 0 : C.packetsReceived) !== null && b !== void 0 ? b : -1, W = (I = (y = g.inbound[0]) === null || y === void 0 ? void 0 : y.packetsLost) !== null && I !== void 0 ? I : -1, B = gi({ jitter: 1e3 * T, rtt: 1e3 * A, packetsLost: W, packetsReceived: D });
1714
- return { jitter: T, rtt: A, mos: B, quality: vi(B), inboundAudio: g.inbound[0], outboundAudio: g.outbound[0], remoteInboundAudio: R.inbound[0], remoteOutboundAudio: R.outbound[0] };
1715
- })(r), n.uuid), yield n.execute(new bi(t, r));
1720
+ const { audio: v, remote: w } = l, { audio: R } = w, T = (u = (c = R.inbound[0]) === null || c === void 0 ? void 0 : c.jitter) !== null && u !== void 0 ? u : 1 / 0, A = (f = (p = R.inbound[0]) === null || p === void 0 ? void 0 : p.roundTripTime) !== null && f !== void 0 ? f : 1 / 0, D = (b = (C = v.inbound[0]) === null || C === void 0 ? void 0 : C.packetsReceived) !== null && b !== void 0 ? b : -1, W = (I = (y = v.inbound[0]) === null || y === void 0 ? void 0 : y.packetsLost) !== null && I !== void 0 ? I : -1, B = vi({ jitter: 1e3 * T, rtt: 1e3 * A, packetsLost: W, packetsReceived: D });
1721
+ return { jitter: T, rtt: A, mos: B, quality: mi(B), inboundAudio: v.inbound[0], outboundAudio: v.outbound[0], remoteInboundAudio: R.inbound[0], remoteOutboundAudio: R.outbound[0] };
1722
+ })(r), n.uuid), yield n.execute(new Si(t, r));
1716
1723
  }));
1717
1724
  return { get isRunning() {
1718
1725
  return i;
1719
1726
  }, start: (r, l, c) => O(this, void 0, void 0, (function* () {
1720
- if (i) v.debug(`[${e}] Stats reporter already running, skipping start`);
1727
+ if (i) g.debug(`[${e}] Stats reporter already running, skipping start`);
1721
1728
  else {
1722
- yield n.execute(new mi(t, e)), s.on("timeline", o);
1729
+ yield n.execute(new yi(t, e)), s.on("timeline", o);
1723
1730
  try {
1724
1731
  yield s.addConnection({ pc: r, peerId: l, connectionId: c }), i = !0;
1725
1732
  } catch (u) {
1726
- v.error(`[${e}] Failed to start stats reporter:`, u), s.removeAllPeers(), s.destroy();
1733
+ g.error(`[${e}] Failed to start stats reporter:`, u), s.removeAllPeers(), s.destroy();
1727
1734
  }
1728
1735
  }
1729
1736
  })), stop: (r) => O(this, void 0, void 0, (function* () {
@@ -1731,7 +1738,7 @@ function Si(n, e) {
1731
1738
  j(x.StatsReport, l, n.uuid), r === "file" && (function(c, u) {
1732
1739
  const p = new Blob([JSON.stringify(c)], { type: "application/json" }), f = URL.createObjectURL(p), C = document.createElement("a");
1733
1740
  C.href = f, C.download = `${u}.json`, C.click(), URL.revokeObjectURL(f);
1734
- })(l, `webrtc-stats-${t}-${Date.now()}`), yield n.execute(new yi(t, e)), s.removeAllPeers(), s.destroy(), i = !1;
1741
+ })(l, `webrtc-stats-${t}-${Date.now()}`), yield n.execute(new bi(t, e)), s.removeAllPeers(), s.destroy(), i = !1;
1735
1742
  })), reportConnectionStateChange: (r) => {
1736
1743
  const l = { event: "connectionstatechange-detailed", tag: "connection", timestamp: (/* @__PURE__ */ new Date()).toISOString(), data: r };
1737
1744
  o(l);
@@ -1740,10 +1747,10 @@ function Si(n, e) {
1740
1747
  o(l);
1741
1748
  } };
1742
1749
  }
1743
- const pn = (n, e) => {
1750
+ const fn = (n, e) => {
1744
1751
  const { contentType: t, canvasType: i, callID: s, canvasInfo: o = null, currentLayerIdx: r = -1 } = e;
1745
1752
  o && i !== "mcu-personal-canvas" && delete o.memberID;
1746
- const l = { type: se.conferenceUpdate, call: n.calls[s], canvasInfo: _i(o), currentLayerIdx: r };
1753
+ const l = { type: se.conferenceUpdate, call: n.calls[s], canvasInfo: Ci(o), currentLayerIdx: r };
1747
1754
  switch (t) {
1748
1755
  case "layer-info": {
1749
1756
  const c = Object.assign({ action: ie.LayerInfo }, l);
@@ -1756,15 +1763,15 @@ const pn = (n, e) => {
1756
1763
  break;
1757
1764
  }
1758
1765
  }
1759
- }, _i = (n) => {
1766
+ }, Ci = (n) => {
1760
1767
  const e = JSON.stringify(n).replace(/memberID/g, "participantId").replace(/ID"/g, 'Id"').replace(/POS"/g, 'Pos"');
1761
- return nn(e);
1768
+ return sn(e);
1762
1769
  };
1763
- class jt {
1770
+ class Ut {
1764
1771
  constructor(e, t, i, s, o) {
1765
1772
  this.type = e, this.options = t, this.onSdpReadyTwice = null, this.statsReporter = null, this._negotiating = !1, this._prevConnectionState = null, this._restartedIceOnConnectionStateFailed = !1, this._sleepWakeupIntervalId = null, this.handleConnectionStateChange = () => O(this, void 0, void 0, (function* () {
1766
1773
  const { connectionState: r } = this.instance;
1767
- if (v.info(`[${(/* @__PURE__ */ new Date()).toISOString()}] Connection State changed: ${this._prevConnectionState} -> ${r}`), r === "failed" || r === "disconnected") {
1774
+ if (g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}] Connection State changed: ${this._prevConnectionState} -> ${r}`), r === "failed" || r === "disconnected") {
1768
1775
  const l = () => O(this, void 0, void 0, (function* () {
1769
1776
  if (this.isDebugEnabled && this.statsReporter) {
1770
1777
  const c = yield (function(u, p) {
@@ -1783,7 +1790,7 @@ class jt {
1783
1790
  }))), y.type === "transport" && (f.dtlsCipher = y.dtlsCipher, f.srtpCipher = y.srtpCipher, f.tlsVersion = y.tlsVersion, y.dtlsState && (f.dtlsState = y.dtlsState));
1784
1791
  }));
1785
1792
  } catch (b) {
1786
- v.error("Error gathering connection state details:", b);
1793
+ g.error("Error gathering connection state details:", b);
1787
1794
  }
1788
1795
  return f;
1789
1796
  }));
@@ -1796,12 +1803,12 @@ class jt {
1796
1803
  }
1797
1804
  r === "failed" && j(x.PeerConnectionFailureError, { error: new Error(`Peer Connection failed. previous state: ${this._prevConnectionState}, current state: ${r}`), sessionId: this._session.sessionid }, this.options.id), this._prevConnectionState = r, this._isTrickleIce() && (r === "connecting" && performance.mark("peer-connection-connecting"), r === "connected" && (performance.mark("peer-connection-connected"), console.group("Performance Metrics"), console.table(this.trickleIcePerformanceMetrics), console.groupEnd(), performance.clearMarks()));
1798
1805
  })), this._handleIceConnectionStateChange = () => {
1799
- v.debug(`[${(/* @__PURE__ */ new Date()).toISOString()}] ICE Connection State`, this.instance.iceConnectionState);
1806
+ g.debug(`[${(/* @__PURE__ */ new Date()).toISOString()}] ICE Connection State`, this.instance.iceConnectionState);
1800
1807
  }, this._handleIceGatheringStateChange = () => {
1801
- v.debug(`[${(/* @__PURE__ */ new Date()).toISOString()}] ICE Gathering State`, this.instance.iceGatheringState);
1808
+ g.debug(`[${(/* @__PURE__ */ new Date()).toISOString()}] ICE Gathering State`, this.instance.iceGatheringState);
1802
1809
  }, this._setCodecs = (r, l) => {
1803
1810
  if (r.setCodecPreferences) return r.setCodecPreferences(l);
1804
- }, v.debug("New Peer with type:", this.type, "Options:", this.options), this._constraints = { offerToReceiveAudio: !0, offerToReceiveVideo: !!t.video }, this._sdpReady = this._sdpReady.bind(this), this.handleSignalingStateChangeEvent = this.handleSignalingStateChangeEvent.bind(this), this.handleNegotiationNeededEvent = this.handleNegotiationNeededEvent.bind(this), this.handleTrackEvent = this.handleTrackEvent.bind(this), this.createPeerConnection = this.createPeerConnection.bind(this), this._session = i, this._trickleIceSdpFn = s, this._registerPeerEvents = o;
1811
+ }, g.debug("New Peer with type:", this.type, "Options:", this.options), this._constraints = { offerToReceiveAudio: !0, offerToReceiveVideo: !!t.video }, this._sdpReady = this._sdpReady.bind(this), this.handleSignalingStateChangeEvent = this.handleSignalingStateChangeEvent.bind(this), this.handleNegotiationNeededEvent = this.handleNegotiationNeededEvent.bind(this), this.handleTrackEvent = this.handleTrackEvent.bind(this), this.createPeerConnection = this.createPeerConnection.bind(this), this._session = i, this._trickleIceSdpFn = s, this._registerPeerEvents = o;
1805
1812
  }
1806
1813
  get isOffer() {
1807
1814
  return this.type === z.Offer;
@@ -1830,28 +1837,28 @@ class jt {
1830
1837
  }));
1831
1838
  }
1832
1839
  _logTransceivers() {
1833
- this.instance ? (v.info("Number of transceivers:", this.instance.getTransceivers().length), this.instance.getTransceivers().forEach(((e, t) => {
1834
- v.info(`>> Transceiver [${t}]:`, e.mid, e.direction, e.stopped), v.info(`>> Sender Params [${t}]:`, JSON.stringify(e.sender.getParameters(), null, 2));
1835
- }))) : v.warn("Cannot log transceivers: peer connection is null");
1840
+ this.instance ? (g.info("Number of transceivers:", this.instance.getTransceivers().length), this.instance.getTransceivers().forEach(((e, t) => {
1841
+ g.info(`>> Transceiver [${t}]:`, e.mid, e.direction, e.stopped), g.info(`>> Sender Params [${t}]:`, JSON.stringify(e.sender.getParameters(), null, 2));
1842
+ }))) : g.warn("Cannot log transceivers: peer connection is null");
1836
1843
  }
1837
1844
  get trickleIcePerformanceMetrics() {
1838
1845
  const e = performance.measure("new-call", "new-call-start", "new-call-end"), t = performance.measure("peer-creation", "peer-creation-start", "peer-creation-end"), i = performance.measure("ice-gathering", "ice-gathering-start", "ice-gathering-end"), s = performance.measure("sdp-send", "sdp-send-start", "sdp-send-end"), o = performance.measure("invite-send", "new-call-start", "sdp-send-start"), r = performance.measure("total-duration", "peer-creation-start", "sdp-send-end"), l = (c) => `${c.toFixed(2)}ms`;
1839
1846
  return { "New Call": { duration: l(e.duration) }, "Peer Creation": { duration: l(t.duration) }, "ICE Gathering": { duration: l(i.duration) }, [this._isOffer() ? "Invite Send" : "Answer Send"]: { duration: l(o.duration) }, "SDP Send": { duration: l(s.duration) }, "Total Duration": { duration: l(r.duration) } };
1840
1847
  }
1841
1848
  handleSignalingStateChangeEvent() {
1842
- switch (v.info("signalingState:", this.instance.signalingState), this.instance.signalingState) {
1849
+ switch (g.info("signalingState:", this.instance.signalingState), this.instance.signalingState) {
1843
1850
  case "stable":
1844
1851
  this._negotiating = !1;
1845
1852
  break;
1846
1853
  case "closed":
1847
- j(x.PeerConnectionSignalingStateClosed, { sessionId: this._session.sessionid }, this.options.id), this.instance && (v.debug(`[${this.options.id}] Closing peer due to signalingState closed`), this.close());
1854
+ j(x.PeerConnectionSignalingStateClosed, { sessionId: this._session.sessionid }, this.options.id), this.instance && (g.debug(`[${this.options.id}] Closing peer due to signalingState closed`), this.close());
1848
1855
  break;
1849
1856
  default:
1850
1857
  this._negotiating = !0;
1851
1858
  }
1852
1859
  }
1853
1860
  handleNegotiationNeededEvent() {
1854
- v.info("Negotiation needed event"), this.instance.signalingState !== "stable" || this._negotiating ? v.debug("Skipping negotiation, state:", this.instance.signalingState, "negotiating:", this._negotiating) : this._isTrickleIce() ? this.startTrickleIceNegotiation() : this.startNegotiation();
1861
+ g.info("Negotiation needed event"), this.instance.signalingState !== "stable" || this._negotiating ? g.debug("Skipping negotiation, state:", this.instance.signalingState, "negotiating:", this._negotiating) : this._isTrickleIce() ? this.startTrickleIceNegotiation() : this.startNegotiation();
1855
1862
  }
1856
1863
  handleTrackEvent(e) {
1857
1864
  const { streams: [t] } = e, { remoteElement: i, screenShare: s } = this.options;
@@ -1862,32 +1869,26 @@ class jt {
1862
1869
  var e;
1863
1870
  this.instance = (e = this._config(), new window.RTCPeerConnection(e)), this.instance.onsignalingstatechange = this.handleSignalingStateChangeEvent, this.instance.onnegotiationneeded = this.handleNegotiationNeededEvent, this.instance.ontrack = this.handleTrackEvent, this.instance.addEventListener("connectionstatechange", this.handleConnectionStateChange), this.instance.addEventListener("iceconnectionstatechange", this._handleIceConnectionStateChange), this.instance.addEventListener("icegatheringstatechange", this._handleIceGatheringStateChange), this.instance.addEventListener("addstream", ((t) => {
1864
1871
  this.options.remoteStream = t.stream;
1865
- })), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: z.Offer })), this.options.localStream = yield this._retrieveLocalStream().catch(((t) => (j(x.MediaError, t, this.options.id), null))), this.options.mutedMicOnStart && ge(this.options.localStream) && (v.info("Muting local audio tracks on start"), rt(this.options.localStream)), this.options.localStream || (v.warn("No local media stream available"), !this.options.audio) ? performance.mark("peer-creation-end") : v.warn("Audio is required but no local stream — skipping negotiation");
1872
+ })), this._registerPeerEvents(this.instance), this._prevConnectionState = this.instance.connectionState, this.isAnswer && (yield this._setRemoteDescription({ sdp: this.options.remoteSdp, type: z.Offer })), this.options.localStream = yield this._retrieveLocalStream().catch(((t) => (j(x.MediaError, t, this.options.id), null))), this.options.mutedMicOnStart && ge(this.options.localStream) && (g.info("Muting local audio tracks on start"), rt(this.options.localStream)), this.options.localStream || (g.warn("No local media stream available"), !this.options.audio) ? performance.mark("peer-creation-end") : g.warn("Audio is required but no local stream — skipping negotiation");
1866
1873
  }));
1867
1874
  }
1868
1875
  init() {
1869
1876
  var e;
1870
1877
  return O(this, void 0, void 0, (function* () {
1871
- yield this.createPeerConnection(), this.isDebugEnabled && (this.statsReporter = Si(this._session, this.options.id), yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.start(this.instance, this._session.sessionid, this._session.sessionid));
1878
+ yield this.createPeerConnection(), this.isDebugEnabled && (this.statsReporter = _i(this._session, this.options.id), yield (e = this.statsReporter) === null || e === void 0 ? void 0 : e.start(this.instance, this._session.sessionid, this._session.sessionid));
1872
1879
  const { localElement: t, localStream: i = null, screenShare: s = !1 } = this.options;
1873
1880
  if (ge(i)) {
1874
1881
  const o = i.getAudioTracks();
1875
1882
  let r = [...o];
1876
- if (v.info("Local audio tracks: ", o), typeof this.options.audio == "object" && o.forEach(((u) => {
1877
- v.info("Local audio tracks constraints: ", u.getConstraints());
1883
+ if (g.info("Local audio tracks: ", o), typeof this.options.audio == "object" && o.forEach(((u) => {
1884
+ g.info("Local audio tracks constraints: ", u.getConstraints());
1878
1885
  })), this.options.video) {
1879
1886
  const u = i.getVideoTracks();
1880
- r = [...o, ...u], v.info("Local video tracks: ", u), typeof this.options.video == "object" && u.forEach(((p) => {
1881
- v.info("Local video tracks constraints: ", p.getConstraints());
1887
+ r = [...o, ...u], g.info("Local video tracks: ", u), typeof this.options.video == "object" && u.forEach(((p) => {
1888
+ g.info("Local video tracks constraints: ", p.getConstraints());
1882
1889
  }));
1883
1890
  }
1884
- const { audioCodecs: l, videoCodecs: c } = ((u) => {
1885
- const p = [], f = [];
1886
- return u && u.length !== 0 ? (u.forEach(((C) => {
1887
- const b = C.mimeType.toLocaleLowerCase();
1888
- b.startsWith("audio/") ? p.push(C) : b.startsWith("video/") && f.push(C);
1889
- })), { audioCodecs: p, videoCodecs: f }) : { audioCodecs: p, videoCodecs: f };
1890
- })(this.options.preferred_codecs);
1891
+ const { audioCodecs: l, videoCodecs: c } = Nt(this.options.preferred_codecs);
1891
1892
  if (this.isOffer && typeof this.instance.addTransceiver == "function") {
1892
1893
  const u = { direction: "sendrecv", streams: [i] };
1893
1894
  r.forEach(((p) => {
@@ -1901,6 +1902,11 @@ class jt {
1901
1902
  u.receiver.track.kind === "audio" && l.length > 0 && this._setCodecs(u, l), u.receiver.track.kind === "video" && c.length > 0 && this._setCodecs(u, c);
1902
1903
  }))) : this.instance.addStream(i);
1903
1904
  s === !1 && Ee(t, i);
1905
+ } else if (this.options.receiveOnlyAudio && typeof this.instance.addTransceiver == "function") {
1906
+ const o = this.instance.addTransceiver("audio", { direction: "recvonly" });
1907
+ g.info("Added recvonly audio transceiver for receive-only mode", o);
1908
+ const { audioCodecs: r } = Nt(this.options.preferred_codecs);
1909
+ r.length > 0 && this._setCodecs(o, r);
1904
1910
  }
1905
1911
  this.isOffer ? (this.options.negotiateAudio && this._checkMediaToNegotiate("audio"), this.options.negotiateVideo && this._checkMediaToNegotiate("video")) : this._isTrickleIce() || this.startNegotiation(), this._isTrickleIce() && this.startTrickleIceNegotiation(), this._logTransceivers();
1906
1912
  }));
@@ -1911,37 +1917,37 @@ class jt {
1911
1917
  _checkMediaToNegotiate(e) {
1912
1918
  if (!this._getSenderByKind(e)) {
1913
1919
  const t = this.instance.addTransceiver(e);
1914
- v.info("Add transceiver", e, t);
1920
+ g.info("Add transceiver", e, t);
1915
1921
  }
1916
1922
  }
1917
1923
  _createOffer() {
1918
1924
  return O(this, void 0, void 0, (function* () {
1919
1925
  if (this._isOffer()) {
1920
- this._constraints.offerToReceiveAudio = this.options.audio !== !1, this._constraints.offerToReceiveVideo = !!this.options.video, v.info("_createOffer - this._constraints", this._constraints);
1926
+ this._constraints.offerToReceiveAudio = this.options.audio !== !1 || !!this.options.receiveOnlyAudio, this._constraints.offerToReceiveVideo = !!this.options.video, g.info("_createOffer - this._constraints", this._constraints);
1921
1927
  try {
1922
1928
  const e = yield this.instance.createOffer(this._constraints);
1923
1929
  return yield this._setLocalDescription(e), this._isTrickleIce() || this._sdpReady(), e;
1924
1930
  } catch (e) {
1925
- v.error("Peer _createOffer error:", e);
1931
+ g.error("Peer _createOffer error:", e);
1926
1932
  }
1927
1933
  }
1928
1934
  }));
1929
1935
  }
1930
1936
  _setRemoteDescription(e) {
1931
1937
  return O(this, void 0, void 0, (function* () {
1932
- v.debug("Setting remote description", e), yield this.instance.setRemoteDescription(e);
1938
+ g.debug("Setting remote description", e), yield this.instance.setRemoteDescription(e);
1933
1939
  }));
1934
1940
  }
1935
1941
  _createAnswer() {
1936
1942
  return O(this, void 0, void 0, (function* () {
1937
1943
  if (this._isAnswer()) {
1938
- if (this.instance.signalingState !== "stable" && this.instance.signalingState !== "have-remote-offer") return v.debug("Skipping negotiation, state:", this.instance.signalingState), v.debug(" - But the signaling state isn't stable, so triggering rollback"), void (yield Promise.all([this.instance.setLocalDescription({ type: "rollback" }), this.instance.setRemoteDescription({ sdp: this.options.remoteSdp, type: z.Offer })]));
1944
+ if (this.instance.signalingState !== "stable" && this.instance.signalingState !== "have-remote-offer") return g.debug("Skipping negotiation, state:", this.instance.signalingState), g.debug(" - But the signaling state isn't stable, so triggering rollback"), void (yield Promise.all([this.instance.setLocalDescription({ type: "rollback" }), this.instance.setRemoteDescription({ sdp: this.options.remoteSdp, type: z.Offer })]));
1939
1945
  this._logTransceivers();
1940
1946
  try {
1941
1947
  const e = yield this.instance.createAnswer();
1942
1948
  return yield this._setLocalDescription(e), e;
1943
1949
  } catch (e) {
1944
- v.error("Peer _createAnswer error:", e);
1950
+ g.error("Peer _createAnswer error:", e);
1945
1951
  }
1946
1952
  }
1947
1953
  }));
@@ -1977,11 +1983,11 @@ class jt {
1977
1983
  }
1978
1984
  _config() {
1979
1985
  const { prefetchIceCandidates: e, forceRelayCandidate: t, iceServers: i } = this.options, s = { bundlePolicy: "balanced", iceCandidatePoolSize: e ? 10 : 0, iceServers: i, iceTransportPolicy: t ? "relay" : "all" };
1980
- return v.info("RTC config", s), s;
1986
+ return g.info("RTC config", s), s;
1981
1987
  }
1982
1988
  restartStatsReporter() {
1983
1989
  return O(this, void 0, void 0, (function* () {
1984
- this.isDebugEnabled && this.statsReporter && (this.instance ? this.statsReporter.isRunning ? v.debug(`[${this.options.id}] Stats reporter already running, skipping restart`) : (v.debug(`[${this.options.id}] Restarting stats reporter after reconnect`), yield this.statsReporter.start(this.instance, this._session.sessionid, this._session.sessionid)) : v.debug(`[${this.options.id}] Cannot restart stats reporter - no peer connection instance`));
1990
+ this.isDebugEnabled && this.statsReporter && (this.instance ? this.statsReporter.isRunning ? g.debug(`[${this.options.id}] Stats reporter already running, skipping restart`) : (g.debug(`[${this.options.id}] Restarting stats reporter after reconnect`), yield this.statsReporter.start(this.instance, this._session.sessionid, this._session.sessionid)) : g.debug(`[${this.options.id}] Cannot restart stats reporter - no peer connection instance`));
1985
1991
  }));
1986
1992
  }
1987
1993
  close() {
@@ -1991,7 +1997,7 @@ class jt {
1991
1997
  }
1992
1998
  }
1993
1999
  const Me = gt;
1994
- class fn {
2000
+ class gn {
1995
2001
  constructor(e, t, i = !1) {
1996
2002
  this.session = e, this._isRecovering = i, this._callReportCollector = null, this.id = "", this.state = N[N.New], this.prevState = "", this.channels = [], this.role = it.Participant, this.extension = null, this._state = N.New, this._prevState = N.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._pendingIceCandidates = [], this._isRemoteDescriptionSet = !1, this._signalingStateClosed = !1, this._creatingPeer = !1, this._checkConferenceSerno = (w) => {
1997
2003
  const R = w < 0 || !this._lastSerno || this._lastSerno && w === this._lastSerno + 1;
@@ -2010,8 +2016,8 @@ class fn {
2010
2016
  }));
2011
2017
  }));
2012
2018
  };
2013
- const { iceServers: s, speaker: o, micId: r, micLabel: l, camId: c, camLabel: u, localElement: p, remoteElement: f, options: C, mediaConstraints: { audio: b, video: y }, ringtoneFile: I, ringbackFile: g } = e;
2014
- this.options = Object.assign({}, Yn, { audio: b, video: y, iceServers: t?.iceServers && Array.isArray(t.iceServers) ? t.iceServers : s, localElement: p, remoteElement: f, micId: r, micLabel: l, camId: c, camLabel: u, speakerId: o, ringtoneFile: I, ringbackFile: g, debug: C.debug, debugOutput: C.debugOutput, trickleIce: C.trickleIce, prefetchIceCandidates: C.prefetchIceCandidates, forceRelayCandidate: C.forceRelayCandidate, keepConnectionAliveOnSocketClose: C.keepConnectionAliveOnSocketClose, mutedMicOnStart: C.mutedMicOnStart }, t), this._onMediaError = this._onMediaError.bind(this), this._onPeerConnectionFailureError = this._onPeerConnectionFailureError.bind(this), this._onPeerConnectionSignalingStateClosed = this._onPeerConnectionSignalingStateClosed.bind(this), this._onTrickleIceSdp = this._onTrickleIceSdp.bind(this), this._registerPeerEvents = this._registerPeerEvents.bind(this), this._registerTrickleIcePeerEvents = this._registerTrickleIcePeerEvents.bind(this), this._init(), this.options && (this._ringtone = Mt(this.options.ringtoneFile, "_ringtone"), this._ringback = Mt(this.options.ringbackFile, "_ringback"));
2019
+ const { iceServers: s, speaker: o, micId: r, micLabel: l, camId: c, camLabel: u, localElement: p, remoteElement: f, options: C, mediaConstraints: { audio: b, video: y }, ringtoneFile: I, ringbackFile: v } = e;
2020
+ this.options = Object.assign({}, Jn, { audio: b, video: y, iceServers: t?.iceServers && Array.isArray(t.iceServers) ? t.iceServers : s, localElement: p, remoteElement: f, micId: r, micLabel: l, camId: c, camLabel: u, speakerId: o, ringtoneFile: I, ringbackFile: v, debug: C.debug, debugOutput: C.debugOutput, trickleIce: C.trickleIce, prefetchIceCandidates: C.prefetchIceCandidates, forceRelayCandidate: C.forceRelayCandidate, keepConnectionAliveOnSocketClose: C.keepConnectionAliveOnSocketClose, mutedMicOnStart: C.mutedMicOnStart }, t), this._onMediaError = this._onMediaError.bind(this), this._onPeerConnectionFailureError = this._onPeerConnectionFailureError.bind(this), this._onPeerConnectionSignalingStateClosed = this._onPeerConnectionSignalingStateClosed.bind(this), this._onTrickleIceSdp = this._onTrickleIceSdp.bind(this), this._registerPeerEvents = this._registerPeerEvents.bind(this), this._registerTrickleIcePeerEvents = this._registerTrickleIcePeerEvents.bind(this), this._init(), this.options && (this._ringtone = Mt(this.options.ringtoneFile, "_ringtone"), this._ringback = Mt(this.options.ringbackFile, "_ringback"));
2015
2021
  }
2016
2022
  get creatingPeer() {
2017
2023
  return this._creatingPeer;
@@ -2045,17 +2051,17 @@ class fn {
2045
2051
  return `conference-member.${this.id}`;
2046
2052
  }
2047
2053
  get isAudioMuted() {
2048
- return !ui(this.options.localStream);
2054
+ return !hi(this.options.localStream);
2049
2055
  }
2050
2056
  invite() {
2051
2057
  return O(this, void 0, void 0, (function* () {
2052
- this._creatingPeer = !0, this.direction = re.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new jt(z.Offer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents), yield this.peer.init(), this._creatingPeer = !1;
2058
+ this._creatingPeer = !0, this.direction = re.Outbound, this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new Ut(z.Offer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents), yield this.peer.init(), this._creatingPeer = !1;
2053
2059
  }));
2054
2060
  }
2055
2061
  answer(e = {}) {
2056
2062
  var t;
2057
2063
  return O(this, void 0, void 0, (function* () {
2058
- this._creatingPeer = !0, performance.mark("new-call-start"), this.stopRingtone(), this.direction = re.Inbound, ((t = e?.customHeaders) === null || t === void 0 ? void 0 : t.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new jt(z.Answer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents), yield this.peer.init(), performance.mark("new-call-end"), this._creatingPeer = !1;
2064
+ this._creatingPeer = !0, performance.mark("new-call-start"), this.stopRingtone(), this.direction = re.Inbound, ((t = e?.customHeaders) === null || t === void 0 ? void 0 : t.length) > 0 && (this.options = Object.assign(Object.assign({}, this.options), { customHeaders: e.customHeaders })), this.options.trickleIce && this._resetTrickleIceCandidateState(), performance.mark("peer-creation-start"), this.peer = new Ut(z.Answer, this.options, this.session, this._onTrickleIceSdp, this.options.trickleIce ? this._registerTrickleIcePeerEvents : this._registerPeerEvents), yield this.peer.init(), performance.mark("new-call-end"), this._creatingPeer = !1;
2059
2065
  }));
2060
2066
  }
2061
2067
  playRingtone() {
@@ -2077,12 +2083,12 @@ class fn {
2077
2083
  this.setState(N.Hangup);
2078
2084
  const u = () => {
2079
2085
  var p;
2080
- v.debug(`[${this.id}] Closing peer from hangup`), (p = this.peer) === null || p === void 0 || p.close(), this.setState(N.Destroy);
2086
+ g.debug(`[${this.id}] Closing peer from hangup`), (p = this.peer) === null || p === void 0 || p.close(), this.setState(N.Destroy);
2081
2087
  };
2082
2088
  if (this.stopRingtone(), this.stopRingback(), l) {
2083
- const p = new ti({ sipCode: this.sipCode, sip_call_id: this.sipCallId, sessid: this.session.sessionid, dialogParams: this.options, cause: this.cause, causeCode: this.causeCode });
2089
+ const p = new ni({ sipCode: this.sipCode, sip_call_id: this.sipCallId, sessid: this.session.sessionid, dialogParams: this.options, cause: this.cause, causeCode: this.causeCode });
2084
2090
  this._execute(p).catch(((f) => {
2085
- v.error("telnyx_rtc.bye failed!", f), j(x.Error, { error: f, sessionId: this.session.sessionid }, this.session.uuid);
2091
+ g.error("telnyx_rtc.bye failed!", f), j(x.Error, { error: f, sessionId: this.session.sessionid }, this.session.uuid);
2086
2092
  })).then(u.bind(this));
2087
2093
  } else u();
2088
2094
  }
@@ -2160,16 +2166,16 @@ class fn {
2160
2166
  }
2161
2167
  setBandwidthEncodingsMaxBps(e, t) {
2162
2168
  return O(this, void 0, void 0, (function* () {
2163
- if (!this || !this.peer) return void v.error("Could not set bandwidth (reason: no peer connection). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
2169
+ if (!this || !this.peer) return void g.error("Could not set bandwidth (reason: no peer connection). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
2164
2170
  const { instance: i } = this.peer, s = i.getSenders();
2165
- if (!s) return void v.error("Could not set bandwidth (reason: no senders). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
2171
+ if (!s) return void g.error("Could not set bandwidth (reason: no senders). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
2166
2172
  const o = s.find((({ track: { kind: r } }) => r === t));
2167
2173
  if (o) {
2168
2174
  const r = o.getParameters();
2169
- r.encodings || (r.encodings = [{ rid: "h" }]), v.info("Parameters: ", r), v.info("Setting max ", t === "audio" ? "audio" : "video", " bandwidth to: ", e, " [bps]"), r.encodings[0].maxBitrate = e, yield o.setParameters(r).then((() => {
2170
- v.info(t === "audio" ? "New audio" : "New video", " bandwidth settings in use: ", o.getParameters());
2171
- })).catch(((l) => v.error(l)));
2172
- } else v.error("Could not set bandwidth (reason: no " + t + " sender). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
2175
+ r.encodings || (r.encodings = [{ rid: "h" }]), g.info("Parameters: ", r), g.info("Setting max ", t === "audio" ? "audio" : "video", " bandwidth to: ", e, " [bps]"), r.encodings[0].maxBitrate = e, yield o.setParameters(r).then((() => {
2176
+ g.info(t === "audio" ? "New audio" : "New video", " bandwidth settings in use: ", o.getParameters());
2177
+ })).catch(((l) => g.error(l)));
2178
+ } else g.error("Could not set bandwidth (reason: no " + t + " sender). Dynamic bandwidth can only be set when there is a call running - is there any call running?)");
2173
2179
  }));
2174
2180
  }
2175
2181
  setAudioBandwidthEncodingsMaxBps(e) {
@@ -2185,14 +2191,14 @@ class fn {
2185
2191
  }
2186
2192
  setState(e) {
2187
2193
  var t;
2188
- switch (this._prevState = this._state, this._state = e, this.state = N[this._state].toLowerCase(), this.prevState = N[this._prevState].toLowerCase(), v.debug(`Call ${this.id} state change from ${this.prevState} to ${this.state}`), this._dispatchNotification({ type: se.callUpdate, call: this }), e) {
2194
+ switch (this._prevState = this._state, this._state = e, this.state = N[this._state].toLowerCase(), this.prevState = N[this._prevState].toLowerCase(), g.debug(`Call ${this.id} state change from ${this.prevState} to ${this.state}`), this._dispatchNotification({ type: se.callUpdate, call: this }), e) {
2189
2195
  case N.Purge:
2190
- v.debug(`Call ${this.id} hangup call due to purge state`), this.hangup({ cause: "PURGE", causeCode: 1 }, !1);
2196
+ g.debug(`Call ${this.id} hangup call due to purge state`), this.hangup({ cause: "PURGE", causeCode: 1 }, !1);
2191
2197
  break;
2192
2198
  case N.Active:
2193
- this._isRecovering && (this._isRecovering = !1, v.debug(`[${this.id}] Recovery complete, call is active`)), setTimeout((() => {
2199
+ this._isRecovering && (this._isRecovering = !1, g.debug(`[${this.id}] Recovery complete, call is active`)), setTimeout((() => {
2194
2200
  const { remoteElement: i, speakerId: s } = this.options;
2195
- i && s && un(i, s);
2201
+ i && s && hn(i, s);
2196
2202
  }), 0), this._callReportCollector && (!((t = this.peer) === null || t === void 0) && t.instance) && this.session.callReportId && this._callReportCollector.start(this.peer.instance);
2197
2203
  break;
2198
2204
  case N.Destroy:
@@ -2202,41 +2208,41 @@ class fn {
2202
2208
  handleMessage(e) {
2203
2209
  const { method: t, params: i } = e;
2204
2210
  switch (t) {
2205
- case $.Answer:
2206
- if (this.gotAnswer = !0, this._state >= N.Active) return;
2211
+ case F.Answer:
2212
+ if (this.gotAnswer = !0, i.telnyx_call_control_id && (this.options.telnyxCallControlId = i.telnyx_call_control_id), i.telnyx_session_id && (this.options.telnyxSessionId = i.telnyx_session_id), i.telnyx_leg_id && (this.options.telnyxLegId = i.telnyx_leg_id), this._state >= N.Active) return;
2207
2213
  this._state >= N.Early && this.setState(N.Active), this.gotEarly || this._onRemoteSdp(i.sdp), this.stopRingback(), this.stopRingtone();
2208
2214
  break;
2209
- case $.Media:
2215
+ case F.Media:
2210
2216
  if (this._state >= N.Early) return;
2211
2217
  this.gotEarly = !0, this._onRemoteSdp(i.sdp);
2212
2218
  break;
2213
- case $.Display: {
2219
+ case F.Display: {
2214
2220
  const { display_name: o, display_number: r, display_direction: l } = i;
2215
2221
  this.extension = r;
2216
2222
  const c = l === re.Inbound ? re.Outbound : re.Inbound, u = { type: se[t], call: this, displayName: o, displayNumber: r, displayDirection: c };
2217
2223
  j(x.Notification, u, this.id) || j(x.Notification, u, this.session.uuid);
2218
2224
  break;
2219
2225
  }
2220
- case $.Candidate:
2226
+ case F.Candidate:
2221
2227
  this._addIceCandidate(i);
2222
2228
  break;
2223
- case $.Info:
2224
- case $.Event: {
2229
+ case F.Info:
2230
+ case F.Event: {
2225
2231
  const o = Object.assign(Object.assign({}, i), { type: se.generic, call: this });
2226
2232
  j(x.Notification, o, this.id) || j(x.Notification, o, this.session.uuid);
2227
2233
  break;
2228
2234
  }
2229
- case $.Ringing:
2235
+ case F.Ringing:
2230
2236
  this.playRingback(), i.telnyx_call_control_id && (this.options.telnyxCallControlId = i.telnyx_call_control_id), i.telnyx_session_id && (this.options.telnyxSessionId = i.telnyx_session_id), i.telnyx_leg_id && (this.options.telnyxLegId = i.telnyx_leg_id);
2231
2237
  break;
2232
- case $.Bye:
2238
+ case F.Bye:
2233
2239
  const s = i.client_state || i.clientState;
2234
2240
  s && (this.options.clientState = s), this.stopRingback(), this.stopRingtone(), this.hangup(i, !1);
2235
2241
  }
2236
2242
  }
2237
2243
  handleConferenceUpdate(e, t) {
2238
2244
  return O(this, void 0, void 0, (function* () {
2239
- if (!this._checkConferenceSerno(e.wireSerno) && e.name !== t.laName) return v.error("ConferenceUpdate invalid wireSerno or packet name:", e), "INVALID_PACKET";
2245
+ if (!this._checkConferenceSerno(e.wireSerno) && e.name !== t.laName) return g.error("ConferenceUpdate invalid wireSerno or packet name:", e), "INVALID_PACKET";
2240
2246
  const { action: i, data: s, hashKey: o = String(this._lastSerno), arrIndex: r } = e;
2241
2247
  switch (i) {
2242
2248
  case "bootObj": {
@@ -2276,7 +2282,7 @@ class fn {
2276
2282
  const { direction: o, from: r, fromDisplay: l, message: c, type: u } = s.data;
2277
2283
  this._dispatchConferenceUpdate({ action: ie.ChatMessage, direction: o, participantNumber: r, participantName: l, messageText: c, messageType: u, messageId: s.eventSerno });
2278
2284
  } }, i = yield this.session.vertoSubscribe(t).catch(((s) => {
2279
- v.error("ConfChat subscription error:", s);
2285
+ g.error("ConfChat subscription error:", s);
2280
2286
  }));
2281
2287
  st(i, e) && (this._addChannel(e), Object.defineProperties(this, { sendChatMessage: { configurable: !0, value: (s, o) => {
2282
2288
  this.session.vertoBroadcast({ nodeId: this.nodeId, channel: e, data: { action: "send", message: s, type: o } });
@@ -2287,9 +2293,9 @@ class fn {
2287
2293
  return O(this, void 0, void 0, (function* () {
2288
2294
  const t = { nodeId: this.nodeId, channels: [e], handler: (s) => {
2289
2295
  const { eventData: o } = s;
2290
- o.contentType === "layout-info" ? (o.callID = this.id, pn(this.session, o)) : v.error("Conference-Info unknown contentType", s);
2296
+ o.contentType === "layout-info" ? (o.callID = this.id, fn(this.session, o)) : g.error("Conference-Info unknown contentType", s);
2291
2297
  } }, i = yield this.session.vertoSubscribe(t).catch(((s) => {
2292
- v.error("ConfInfo subscription error:", s);
2298
+ g.error("ConfInfo subscription error:", s);
2293
2299
  }));
2294
2300
  st(i, e) && this._addChannel(e);
2295
2301
  }));
@@ -2302,7 +2308,7 @@ class fn {
2302
2308
  return e.holdState === "active" ? this.setState(N.Active) : this.setState(N.Held), !0;
2303
2309
  }
2304
2310
  _handleChangeHoldStateError(e) {
2305
- return v.error(`Failed to ${e.action} on call ${this.id}`), !1;
2311
+ return g.error(`Failed to ${e.action} on call ${this.id}`), !1;
2306
2312
  }
2307
2313
  _onRemoteSdp(e) {
2308
2314
  return O(this, void 0, void 0, (function* () {
@@ -2310,7 +2316,7 @@ class fn {
2310
2316
  yield this.peer.instance.setRemoteDescription(t).then((() => {
2311
2317
  this.options.trickleIce && (this._isRemoteDescriptionSet = !0, this._flushPendingTrickleIceCandidates()), this.gotEarly && this.setState(N.Early), this.gotAnswer && this.setState(N.Active);
2312
2318
  })).catch(((i) => {
2313
- v.error("Call setRemoteDescription Error: ", i), this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
2319
+ g.error("Call setRemoteDescription Error: ", i), this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
2314
2320
  }));
2315
2321
  }));
2316
2322
  }
@@ -2321,7 +2327,7 @@ class fn {
2321
2327
  var t, i;
2322
2328
  this._iceTimeout && clearTimeout(this._iceTimeout), this._iceTimeout = null, this._iceDone = !0;
2323
2329
  const { sdp: s, type: o } = e;
2324
- if (s.indexOf("candidate") === -1) return v.info(`No candidate - retry
2330
+ if (s.indexOf("candidate") === -1) return g.info(`No candidate - retry
2325
2331
  `), void this._requestAnotherLocalDescription();
2326
2332
  (i = (t = this.peer) === null || t === void 0 ? void 0 : t.instance) === null || i === void 0 || i.removeEventListener("icecandidate", this._onIce), performance.mark("ice-gathering-end");
2327
2333
  let r = null;
@@ -2334,19 +2340,19 @@ class fn {
2334
2340
  this._isRecovering || this.setState(N.Answering), r = this.options.attach === !0 ? new Rt(l) : new Tt(l);
2335
2341
  break;
2336
2342
  default:
2337
- return v.error(`${this.id} - Unknown local SDP type:`, e), this.hangup({}, !1);
2343
+ return g.error(`${this.id} - Unknown local SDP type:`, e), this.hangup({}, !1);
2338
2344
  }
2339
2345
  performance.mark("sdp-send-start"), this._execute(r).then(((c) => {
2340
2346
  const { node_id: u = null } = c;
2341
2347
  this._targetNodeId = u, o === z.Offer ? this.setState(N.Trying) : this.setState(N.Active);
2342
2348
  })).catch(((c) => {
2343
- v.error(`${this.id} - Sending ${o} error:`, c), this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
2349
+ g.error(`${this.id} - Sending ${o} error:`, c), this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
2344
2350
  })).finally((() => {
2345
2351
  performance.mark("sdp-send-end"), console.group("Performance Metrics"), console.table(this.performanceMetrics), console.groupEnd(), performance.clearMarks();
2346
2352
  }));
2347
2353
  }
2348
2354
  _onTrickleIceSdp(e) {
2349
- if (!e) return v.error("No SDP data provided"), this.hangup({}, !1);
2355
+ if (!e) return g.error("No SDP data provided"), this.hangup({}, !1);
2350
2356
  const { sdp: t, type: i } = e;
2351
2357
  let s = null;
2352
2358
  const o = { sessid: this.session.sessionid, sdp: t, dialogParams: this.options, trickle: !0, "User-Agent": `Web-${Me}` };
@@ -2358,42 +2364,46 @@ class fn {
2358
2364
  this._isRecovering || this.setState(N.Answering), s = this.options.attach === !0 ? new Rt(o) : new Tt(o);
2359
2365
  break;
2360
2366
  default:
2361
- return v.error(`${this.id} - Unknown local SDP type:`, e), this.hangup({}, !1);
2367
+ return g.error(`${this.id} - Unknown local SDP type:`, e), this.hangup({}, !1);
2362
2368
  }
2363
2369
  performance.mark("sdp-send-start"), this._execute(s).then(((r) => {
2364
2370
  const { node_id: l = null } = r;
2365
2371
  this._targetNodeId = l, i === z.Offer ? this.setState(N.Trying) : this.setState(N.Active);
2366
2372
  })).catch(((r) => {
2367
- v.error(`${this.id} - Sending ${i} error:`, r), this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
2373
+ g.error(`${this.id} - Sending ${i} error:`, r), this.hangup({ cause: "USER_BUSY", causeCode: 17 }, !0);
2368
2374
  })).finally((() => {
2369
2375
  performance.mark("sdp-send-end");
2370
2376
  }));
2371
2377
  }
2372
2378
  _onIce(e) {
2373
2379
  const { instance: t } = this.peer;
2374
- this._iceTimeout === null && (this._iceTimeout = setTimeout((() => this._onIceSdp(t.localDescription)), 1e3)), e.candidate ? v.debug("RTCPeer Candidate:", e.candidate) : this._onIceSdp(t.localDescription);
2380
+ if (this._iceTimeout === null) {
2381
+ const i = this.options.attach ? 5e3 : 1e3;
2382
+ this._iceTimeout = setTimeout((() => this._onIceSdp(t.localDescription)), i);
2383
+ }
2384
+ e.candidate ? g.debug("RTCPeer Candidate:", e.candidate) : this._onIceSdp(t.localDescription);
2375
2385
  }
2376
2386
  _onTrickleIce(e) {
2377
- e.candidate && e.candidate.candidate ? (v.debug("RTCPeer Candidate:", e.candidate), this._sendIceCandidate(e.candidate)) : this._sendEndOfCandidates();
2387
+ e.candidate && e.candidate.candidate ? (g.debug("RTCPeer Candidate:", e.candidate), this._sendIceCandidate(e.candidate)) : this._sendEndOfCandidates();
2378
2388
  }
2379
2389
  _sendIceCandidate(e) {
2380
- const t = new ni({ sessid: this.session.sessionid, candidate: e.candidate, sdpMLineIndex: e.sdpMLineIndex, sdpMid: e.sdpMid, dialogParams: this.options });
2390
+ const t = new ii({ sessid: this.session.sessionid, candidate: e.candidate, sdpMLineIndex: e.sdpMLineIndex, sdpMid: e.sdpMid, dialogParams: this.options });
2381
2391
  this._execute(t);
2382
2392
  }
2383
2393
  _addIceCandidate(e) {
2384
- if (!this._isRemoteDescriptionSet) return v.debug("Remote description not set. Queued ICE candidate.", e), void this._pendingIceCandidates.push(e);
2394
+ if (!this._isRemoteDescriptionSet) return g.debug("Remote description not set. Queued ICE candidate.", e), void this._pendingIceCandidates.push(e);
2385
2395
  this._addIceCandidateToPeer(e);
2386
2396
  }
2387
2397
  _addIceCandidateToPeer(e) {
2388
2398
  const t = this.peer.instance.addIceCandidate(e);
2389
2399
  Promise.resolve(t).then((() => {
2390
- v.debug("Successfully added ICE candidate:", e);
2400
+ g.debug("Successfully added ICE candidate:", e);
2391
2401
  })).catch(((i) => {
2392
- v.error("Failed to add ICE candidate:", i, e);
2402
+ g.error("Failed to add ICE candidate:", i, e);
2393
2403
  }));
2394
2404
  }
2395
2405
  _sendEndOfCandidates() {
2396
- const e = new ii({ sessid: this.session.sessionid, endOfCandidates: !0, dialogParams: this.options });
2406
+ const e = new si({ sessid: this.session.sessionid, endOfCandidates: !0, dialogParams: this.options });
2397
2407
  this._execute(e), performance.mark("ice-gathering-end");
2398
2408
  }
2399
2409
  _resetTrickleIceCandidateState() {
@@ -2411,8 +2421,8 @@ class fn {
2411
2421
  this._iceDone || this._onIce(t);
2412
2422
  }, e.onicecandidateerror = (t) => {
2413
2423
  var i;
2414
- if (v.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
2415
- const s = Nt(t, e);
2424
+ if (g.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
2425
+ const s = jt(t, e);
2416
2426
  this.peer.statsReporter.reportIceCandidateError(s);
2417
2427
  }
2418
2428
  }, e.addEventListener("addstream", ((t) => {
@@ -2427,11 +2437,11 @@ class fn {
2427
2437
  e.onicecandidate = (t) => {
2428
2438
  this._onTrickleIce(t);
2429
2439
  }, e.onicegatheringstatechange = (t) => {
2430
- v.debug("ICE gathering state changed:", e.iceGatheringState), e.iceGatheringState === "complete" && v.debug("Finished gathering candidates");
2440
+ g.debug("ICE gathering state changed:", e.iceGatheringState), e.iceGatheringState === "complete" && g.debug("Finished gathering candidates");
2431
2441
  }, e.onicecandidateerror = (t) => {
2432
2442
  var i;
2433
- if (v.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
2434
- const s = Nt(t, e);
2443
+ if (g.debug("ICE candidate error:", t), (i = this.peer) === null || i === void 0 ? void 0 : i.statsReporter) {
2444
+ const s = jt(t, e);
2435
2445
  this.peer.statsReporter.reportIceCandidateError(s);
2436
2446
  }
2437
2447
  }, e.addEventListener("addstream", ((t) => {
@@ -2444,13 +2454,13 @@ class fn {
2444
2454
  }
2445
2455
  _onMediaError(e) {
2446
2456
  const t = e?.name || "UnknownError", i = e?.message || "Unknown media error";
2447
- this._dispatchNotification({ type: se.userMediaError, error: e, call: this, errorName: t, errorMessage: i }), v.error(`Media error (${t}): ${i}`, e), this.hangup({}, !1);
2457
+ this._dispatchNotification({ type: se.userMediaError, error: e, call: this, errorName: t, errorMessage: i }), g.error(`Media error (${t}): ${i}`, e), this.hangup({}, !1);
2448
2458
  }
2449
2459
  _onPeerConnectionFailureError(e) {
2450
- this._dispatchNotification({ type: se.peerConnectionFailureError, error: e }), v.error("Peer connection failure error");
2460
+ this._dispatchNotification({ type: se.peerConnectionFailureError, error: e }), g.error("Peer connection failure error");
2451
2461
  }
2452
2462
  _onPeerConnectionSignalingStateClosed(e) {
2453
- this._signalingStateClosed = !0, this._dispatchNotification(Object.assign({ type: se.signalingStateClosed }, e)), v.debug("Peer connection signaling state closed, call is not recoverable");
2463
+ this._signalingStateClosed = !0, this._dispatchNotification(Object.assign({ type: se.signalingStateClosed }, e)), g.debug("Peer connection signaling state closed, call is not recoverable");
2454
2464
  }
2455
2465
  _dispatchConferenceUpdate(e) {
2456
2466
  this._dispatchNotification(Object.assign({ type: se.conferenceUpdate, call: this }, e));
@@ -2468,42 +2478,42 @@ class fn {
2468
2478
  const r = this.session.options.enableCallReports !== !1, l = this.session.options.callReportInterval || 5e3, c = this.session.options.debugLogLevel || "debug", u = this.session.options.debugLogMaxEntries || 1e3;
2469
2479
  r && (this._callReportCollector = new ce({ enabled: !0, interval: l }, { enabled: !0, level: c, maxEntries: u }), this._callReportCollector.onFlushNeeded = () => {
2470
2480
  this._flushIntermediateReport();
2471
- }), this._isRecovering ? this.setState(N.Recovering) : this.setState(N.New), v.info("New Call with Options:", this.options);
2481
+ }), this._isRecovering ? this.setState(N.Recovering) : this.setState(N.New), g.info("New Call with Options:", this.options);
2472
2482
  }
2473
2483
  _finalize() {
2474
2484
  var e;
2475
- this._stopStats(), v.debug(`[${this.id}] Closing peer from _finalize`), (e = this.peer) === null || e === void 0 || e.close();
2485
+ this._stopStats(), g.debug(`[${this.id}] Closing peer from _finalize`), (e = this.peer) === null || e === void 0 || e.close();
2476
2486
  const { remoteStream: t, localStream: i } = this.options;
2477
2487
  Te(t), Te(i), ue(x.MediaError, null, this.id), ue(x.PeerConnectionFailureError, null, this.id), ue(x.PeerConnectionSignalingStateClosed, null, this.id), this.session.calls[this.id] = null, delete this.session.calls[this.id], this._postCallReport().catch(((s) => {
2478
- v.error("Unexpected error in _postCallReport", { error: s });
2488
+ g.error("Unexpected error in _postCallReport", { error: s });
2479
2489
  }));
2480
2490
  }
2481
2491
  _flushIntermediateReport() {
2482
2492
  var e;
2483
2493
  if (!this._callReportCollector) return;
2484
2494
  const t = this.session.callReportId;
2485
- if (!t) return void v.debug("Cannot flush intermediate report: call_report_id not available");
2495
+ if (!t) return void g.debug("Cannot flush intermediate report: call_report_id not available");
2486
2496
  const i = (e = this.session.connection) === null || e === void 0 ? void 0 : e.host;
2487
- if (!i) return void v.debug("Cannot flush intermediate report: connection host not available");
2497
+ if (!i) return void g.debug("Cannot flush intermediate report: connection host not available");
2488
2498
  const s = { callId: this.id, destinationNumber: this.options.destinationNumber, callerNumber: this.options.callerNumber, direction: this.direction === re.Inbound ? "inbound" : "outbound", state: this.state, telnyxSessionId: this.options.telnyxSessionId, telnyxLegId: this.options.telnyxLegId, sdkVersion: Me }, o = this._callReportCollector.flush(s);
2489
2499
  if (!o) return;
2490
2500
  const r = he() || void 0;
2491
2501
  this._callReportCollector.sendPayload(o, t, i, r).catch(((l) => {
2492
- v.error("Failed to post intermediate call report segment", { error: l });
2502
+ g.error("Failed to post intermediate call report segment", { error: l });
2493
2503
  }));
2494
2504
  }
2495
2505
  _postCallReport() {
2496
2506
  var e;
2497
2507
  return O(this, void 0, void 0, (function* () {
2498
- if (!this._callReportCollector) return void v.warn("Call report collector not initialized");
2508
+ if (!this._callReportCollector) return void g.warn("Call report collector not initialized");
2499
2509
  yield this._callReportCollector.stop();
2500
2510
  const t = this.session.callReportId;
2501
- if (!t) return v.debug("Cannot post call report: call_report_id not available"), void this._callReportCollector.cleanup();
2511
+ if (!t) return g.debug("Cannot post call report: call_report_id not available"), void this._callReportCollector.cleanup();
2502
2512
  const i = { callId: this.id, destinationNumber: this.options.destinationNumber, callerNumber: this.options.callerNumber, direction: this.direction === re.Inbound ? "inbound" : "outbound", state: this.state, telnyxSessionId: this.options.telnyxSessionId, telnyxLegId: this.options.telnyxLegId, sdkVersion: Me }, s = (e = this.session.connection) === null || e === void 0 ? void 0 : e.host;
2503
- if (!s) return void v.error("Cannot post call report: connection host not available");
2513
+ if (!s) return void g.error("Cannot post call report: connection host not available");
2504
2514
  const o = he() || void 0;
2505
2515
  this._callReportCollector.postReport(i, t, s, o).catch(((r) => {
2506
- v.error("Failed to post call report", { error: r });
2516
+ g.error("Failed to post call report", { error: r });
2507
2517
  })).finally((() => {
2508
2518
  var r;
2509
2519
  (r = this._callReportCollector) === null || r === void 0 || r.cleanup();
@@ -2511,13 +2521,13 @@ class fn {
2511
2521
  }));
2512
2522
  }
2513
2523
  _startStats(e) {
2514
- this._statsIntervalId = setInterval(this._doStats, e), v.info("Stats started");
2524
+ this._statsIntervalId = setInterval(this._doStats, e), g.info("Stats started");
2515
2525
  }
2516
2526
  _stopStats() {
2517
- this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), v.debug("Stats stopped");
2527
+ this._statsIntervalId && (clearInterval(this._statsIntervalId), this._statsIntervalId = null), g.debug("Stats stopped");
2518
2528
  }
2519
2529
  }
2520
- fn.setStateTelnyx = (n) => {
2530
+ gn.setStateTelnyx = (n) => {
2521
2531
  if (n) {
2522
2532
  switch (n._state) {
2523
2533
  case N.Recovering:
@@ -2547,9 +2557,9 @@ fn.setStateTelnyx = (n) => {
2547
2557
  return n;
2548
2558
  }
2549
2559
  };
2550
- class pe extends fn {
2560
+ class pe extends gn {
2551
2561
  constructor() {
2552
- super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, t) => this.session.execute(new pi(e, t));
2562
+ super(...arguments), this._statsInterval = null, this.sendConversationMessage = (e, t) => this.session.execute(new fi(e, t));
2553
2563
  }
2554
2564
  hangup(e = {}, t = !0) {
2555
2565
  this.screenShare instanceof pe && this.screenShare.hangup(e, t), super.hangup(e, t);
@@ -2574,7 +2584,7 @@ class pe extends fn {
2574
2584
  return O(this, void 0, void 0, (function* () {
2575
2585
  this.options.speakerId = e;
2576
2586
  const { remoteElement: t, speakerId: i } = this.options;
2577
- return !(!t || !i) && un(t, i);
2587
+ return !(!t || !i) && hn(t, i);
2578
2588
  }));
2579
2589
  }
2580
2590
  _finalize() {
@@ -2593,11 +2603,11 @@ ${r.type}
2593
2603
  o.includes(l) || (i += ` ${l}: ${r[l]}
2594
2604
  `);
2595
2605
  })));
2596
- })), v.info(i);
2606
+ })), g.info(i);
2597
2607
  }))), 2e3);
2598
2608
  }
2599
2609
  }
2600
- class Ci extends ci {
2610
+ class wi extends li {
2601
2611
  constructor(e) {
2602
2612
  super(e), this.calls = {}, this.autoRecoverCalls = !0, this._iceServers = [], this._localElement = null, this._remoteElement = null, this._jwtAuth = !0, this._audioConstraints = !0, this._previousAudioConstraints = !0, this._videoConstraints = !1, this._speaker = null, this._onlineHandler = null, this._offlineHandler = null, this._wasOffline = !1, this._videoConstraints = e.video || !1, this.iceServers = e.iceServers, this.ringtoneFile = e.ringtoneFile, this.ringbackFile = e.ringbackFile, this._setupNetworkListeners();
2603
2613
  }
@@ -2643,7 +2653,7 @@ class Ci extends ci {
2643
2653
  }
2644
2654
  speedTest(e) {
2645
2655
  return new Promise(((t, i) => {
2646
- if (an(x.SpeedTest, ((r) => {
2656
+ if (cn(x.SpeedTest, ((r) => {
2647
2657
  const { upDur: l, downDur: c } = r, u = c ? 8 * e / (c / 1e3) / 1024 : 0;
2648
2658
  t({ upDur: l, downDur: c, upKps: (l ? 8 * e / (l / 1e3) / 1024 : 0).toFixed(0), downKps: u.toFixed(0) });
2649
2659
  }), this.uuid), !(e = Number(e))) return i(`Invalid parameter 'bytes': ${e}`);
@@ -2665,7 +2675,7 @@ class Ci extends ci {
2665
2675
  return Ie(ae.AudioIn).catch(((e) => (j(x.MediaError, e, this.uuid), [])));
2666
2676
  }
2667
2677
  getAudioOutDevices() {
2668
- return Ie(ae.AudioOut).catch(((e) => (v.error("getAudioOutDevices", e), j(x.MediaError, e, this.uuid), [])));
2678
+ return Ie(ae.AudioOut).catch(((e) => (g.error("getAudioOutDevices", e), j(x.MediaError, e, this.uuid), [])));
2669
2679
  }
2670
2680
  validateDeviceId(e, t, i) {
2671
2681
  return Ve(e, t, i);
@@ -2693,7 +2703,7 @@ class Ci extends ci {
2693
2703
  return O(this, void 0, void 0, (function* () {
2694
2704
  if (!e) throw new Error("You need to provide the settings object");
2695
2705
  const { micId: t, micLabel: i } = e, s = Ne(e, ["micId", "micLabel"]);
2696
- return di(s), this._audioConstraints = yield ((o, r, l, c) => O(void 0, void 0, void 0, (function* () {
2706
+ return ui(s), this._audioConstraints = yield ((o, r, l, c) => O(void 0, void 0, void 0, (function* () {
2697
2707
  const { deviceId: u } = c;
2698
2708
  if (u === void 0 && (o || r)) {
2699
2709
  const p = yield Ve(o, r, l).catch(((f) => null));
@@ -2713,7 +2723,7 @@ class Ci extends ci {
2713
2723
  if (e && Array.isArray(e)) this._iceServers = e;
2714
2724
  else {
2715
2725
  const t = this.options.env === "development";
2716
- this._iceServers = t ? Fn : Un;
2726
+ this._iceServers = t ? $n : Fn;
2717
2727
  }
2718
2728
  }
2719
2729
  get iceServers() {
@@ -2739,13 +2749,13 @@ class Ci extends ci {
2739
2749
  }
2740
2750
  vertoBroadcast({ nodeId: e, channel: t = "", data: i }) {
2741
2751
  if (!t) throw new Error(`Invalid channel for broadcast: ${t}`);
2742
- const s = new si({ sessid: this.sessionid, eventChannel: t, data: i });
2752
+ const s = new oi({ sessid: this.sessionid, eventChannel: t, data: i });
2743
2753
  e && (s.targetNodeId = e), this.execute(s).catch(((o) => o));
2744
2754
  }
2745
2755
  vertoSubscribe({ nodeId: e, channels: t = [], handler: i }) {
2746
2756
  return O(this, void 0, void 0, (function* () {
2747
2757
  if (!(t = t.filter(((c) => c && !this._existsSubscription(this.relayProtocol, c)))).length) return {};
2748
- const s = new oi({ sessid: this.sessionid, eventChannel: t });
2758
+ const s = new ri({ sessid: this.sessionid, eventChannel: t });
2749
2759
  e && (s.targetNodeId = e);
2750
2760
  const o = yield this.execute(s), { unauthorized: r = [], subscribed: l = [] } = ot(o);
2751
2761
  return r.length && r.forEach(((c) => this._removeSubscription(this.relayProtocol, c))), l.forEach(((c) => this._addSubscription(this.relayProtocol, i, c))), o;
@@ -2754,7 +2764,7 @@ class Ci extends ci {
2754
2764
  vertoUnsubscribe({ nodeId: e, channels: t = [] }) {
2755
2765
  return O(this, void 0, void 0, (function* () {
2756
2766
  if (!(t = t.filter(((l) => l && this._existsSubscription(this.relayProtocol, l)))).length) return {};
2757
- const i = new ri({ sessid: this.sessionid, eventChannel: t });
2767
+ const i = new ai({ sessid: this.sessionid, eventChannel: t });
2758
2768
  e && (i.targetNodeId = e);
2759
2769
  const s = yield this.execute(i), { unsubscribed: o = [], notSubscribed: r = [] } = ot(s);
2760
2770
  return o.forEach(((l) => this._removeSubscription(this.relayProtocol, l))), r.forEach(((l) => this._removeSubscription(this.relayProtocol, l))), s;
@@ -2762,9 +2772,9 @@ class Ci extends ci {
2762
2772
  }
2763
2773
  _setupNetworkListeners() {
2764
2774
  typeof window < "u" && (this._onlineHandler = () => {
2765
- this._wasOffline && (v.debug(`Network connectivity restored for session ${this.sessionid}. Reconnecting...`), this._wasOffline = !1, this._autoReconnect = !0, this.socketDisconnect());
2775
+ this._wasOffline && (g.debug(`Network connectivity restored for session ${this.sessionid}. Reconnecting...`), this._wasOffline = !1, this._autoReconnect = !0, this.socketDisconnect());
2766
2776
  }, this._offlineHandler = () => {
2767
- this._wasOffline = !0, v.debug(`Network connectivity lost for session ${this.sessionid}`);
2777
+ this._wasOffline = !0, g.debug(`Network connectivity lost for session ${this.sessionid}`);
2768
2778
  }, window.addEventListener("online", this._onlineHandler), window.addEventListener("offline", this._offlineHandler));
2769
2779
  }
2770
2780
  _cleanupNetworkListeners() {
@@ -2774,21 +2784,21 @@ class Ci extends ci {
2774
2784
  return pe.setStateTelnyx(e);
2775
2785
  }
2776
2786
  }
2777
- class Ut {
2787
+ class Ft {
2778
2788
  constructor(e, t) {
2779
2789
  this.code = t, this.message = e;
2780
2790
  }
2781
2791
  }
2782
- class wi {
2792
+ class Ii {
2783
2793
  constructor(e) {
2784
2794
  this.session = e, this.retriedConnect = 0, this.retriedRegister = 0, this.receivedAuthenticationRequired = 0;
2785
2795
  }
2786
2796
  _ack(e, t) {
2787
- const i = new ei(e, t);
2797
+ const i = new ti(e, t);
2788
2798
  this.nodeId && (i.targetNodeId = this.nodeId), this.session.execute(i);
2789
2799
  }
2790
2800
  reconnectDelay() {
2791
- return 1e3 * on(2, 6);
2801
+ return 1e3 * rn(2, 6);
2792
2802
  }
2793
2803
  handleMessage(e) {
2794
2804
  var t, i, s;
@@ -2796,54 +2806,54 @@ class wi {
2796
2806
  if (C === "channelPvtData") return this._handlePvtEvent(c.pvtData);
2797
2807
  const I = (R = !1) => {
2798
2808
  var T, A, D, W, B, M;
2799
- const a = { audio: !0, video: o.options.video, remoteSdp: c.sdp, destinationNumber: c.callee_id_number, remoteCallerName: c.caller_id_name, remoteCallerNumber: c.caller_id_number, callerName: c.callee_id_name, callerNumber: c.callee_id_number, attach: l === $.Attach, mediaSettings: c.mediaSettings, debug: (T = o.options.debug) !== null && T !== void 0 && T, debugOutput: (A = o.options.debugOutput) !== null && A !== void 0 ? A : "socket", trickleIce: (D = o.options.trickleIce) !== null && D !== void 0 && D, prefetchIceCandidates: (W = o.options.prefetchIceCandidates) === null || W === void 0 || W, forceRelayCandidate: (B = o.options.forceRelayCandidate) !== null && B !== void 0 && B, keepConnectionAliveOnSocketClose: (M = o.options.keepConnectionAliveOnSocketClose) !== null && M !== void 0 && M };
2809
+ const a = { audio: !0, video: o.options.video, remoteSdp: c.sdp, destinationNumber: c.callee_id_number, remoteCallerName: c.caller_id_name, remoteCallerNumber: c.caller_id_number, callerName: c.callee_id_name, callerNumber: c.callee_id_number, attach: l === F.Attach, mediaSettings: c.mediaSettings, debug: (T = o.options.debug) !== null && T !== void 0 && T, debugOutput: (A = o.options.debugOutput) !== null && A !== void 0 ? A : "socket", trickleIce: l !== F.Attach && (D = o.options.trickleIce) !== null && D !== void 0 && D, prefetchIceCandidates: (W = o.options.prefetchIceCandidates) === null || W === void 0 || W, forceRelayCandidate: (B = o.options.forceRelayCandidate) !== null && B !== void 0 && B, keepConnectionAliveOnSocketClose: (M = o.options.keepConnectionAliveOnSocketClose) !== null && M !== void 0 && M };
2800
2810
  p && (a.id = p), c.telnyx_call_control_id && (a.telnyxCallControlId = c.telnyx_call_control_id), c.telnyx_session_id && (a.telnyxSessionId = c.telnyx_session_id), c.telnyx_leg_id && (a.telnyxLegId = c.telnyx_leg_id), c.client_state && (a.clientState = c.client_state), c.dialogParams && c.dialogParams.custom_headers && c.dialogParams.custom_headers.length && (a.customHeaders = c.dialogParams.custom_headers);
2801
2811
  const d = new pe(o, a, R);
2802
2812
  return d.nodeId = this.nodeId, d;
2803
- }, g = new cn(u), w = new ln(u);
2813
+ }, v = new ln(u), w = new dn(u);
2804
2814
  switch (l) {
2805
- case $.Answer:
2806
- case $.Display:
2807
- case $.Candidate:
2808
- case $.Ringing:
2809
- case $.Bye:
2810
- case $.Media:
2811
- if (!p || !b) return void v.error(`Received ${l} for non existing call:`, c);
2815
+ case F.Answer:
2816
+ case F.Display:
2817
+ case F.Candidate:
2818
+ case F.Ringing:
2819
+ case F.Bye:
2820
+ case F.Media:
2821
+ if (!p || !b) return void g.error(`Received ${l} for non existing call:`, c);
2812
2822
  b.handleMessage(e), this._ack(r, l);
2813
2823
  break;
2814
- case $.Ping:
2824
+ case F.Ping:
2815
2825
  this.session.setPingReceived(), this.session.execute(w).then((() => {
2816
2826
  this.receivedAuthenticationRequired = 0;
2817
2827
  })).catch(((A) => O(this, void 0, void 0, (function* () {
2818
- A.code === this.session.authenticationRequiredErrorCode && this.receivedAuthenticationRequired >= 0 && (this.receivedAuthenticationRequired += 1, this.receivedAuthenticationRequired > 1 && this.session.hasAutoReconnect() && (v.warn("Ping failed twice with Authentication Required. Re-logging in..."), this.session.login(), this.receivedAuthenticationRequired = -1));
2828
+ A.code === this.session.authenticationRequiredErrorCode && this.receivedAuthenticationRequired >= 0 && (this.receivedAuthenticationRequired += 1, this.receivedAuthenticationRequired > 1 && this.session.hasAutoReconnect() && (g.warn("Ping failed twice with Authentication Required. Re-logging in..."), this.session.login(), this.receivedAuthenticationRequired = -1));
2819
2829
  }))));
2820
2830
  break;
2821
- case $.Punt:
2822
- o.options.keepConnectionAliveOnSocketClose && y ? (v.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${p}] keeping session calls alive due to PUNT and keepConnectionAliveOnSocketClose. Disconnecting base session...`), o.socketDisconnect(), this._ack(r, l)) : o.disconnect();
2831
+ case F.Punt:
2832
+ o.options.keepConnectionAliveOnSocketClose && y ? (g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${p}] keeping session calls alive due to PUNT and keepConnectionAliveOnSocketClose. Disconnecting base session...`), o.socketDisconnect(), this._ack(r, l)) : o.disconnect();
2823
2833
  break;
2824
- case $.Invite: {
2834
+ case F.Invite: {
2825
2835
  const A = I();
2826
2836
  A.direction = re.Inbound, A.playRingtone(), A.setState(N.Ringing), this._ack(r, l);
2827
2837
  break;
2828
2838
  }
2829
- case $.Attach: {
2839
+ case F.Attach: {
2830
2840
  if (!b)
2831
2841
  return I().answer(), void this._ack(r, l);
2832
2842
  const A = !!b;
2833
- v.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${p}] closing existing call on ATTACH.`), b.hangup({ isRecovering: A }, !1), v.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${p}] Attach: Creating new call for recovery`), I(A).answer(), this._ack(r, l);
2843
+ g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${p}] closing existing call on ATTACH.`), b.hangup({ isRecovering: A }, !1), g.info(`[${(/* @__PURE__ */ new Date()).toISOString()}][${p}] Attach: Creating new call for recovery`), I(A).answer(), this._ack(r, l);
2834
2844
  break;
2835
2845
  }
2836
- case $.Event:
2846
+ case F.Event:
2837
2847
  case "webrtc.event":
2838
- if (!f) return void v.error("Verto received an unknown event:", c);
2848
+ if (!f) return void g.error("Verto received an unknown event:", c);
2839
2849
  const R = o.relayProtocol, T = f.split(".")[0];
2840
2850
  o._existsSubscription(R, f) ? j(R, c, f) : f === o.sessionid ? this._handleSessionEvent(c.eventData) : o._existsSubscription(R, T) ? j(R, c, T) : o.calls.hasOwnProperty(f) ? o.calls[f].handleMessage(e) : j(x.Notification, c, o.uuid);
2841
2851
  break;
2842
- case $.Info:
2852
+ case F.Info:
2843
2853
  c.type = se.generic, j(x.Notification, c, o.uuid);
2844
2854
  break;
2845
- case $.ClientReady:
2846
- this.session.execute(g);
2855
+ case F.ClientReady:
2856
+ this.session.execute(v);
2847
2857
  break;
2848
2858
  default: {
2849
2859
  const A = pt(e);
@@ -2854,24 +2864,24 @@ class wi {
2854
2864
  if (o.connection.previousGatewayState !== ee.REGED && o.connection.previousGatewayState !== ee.REGISTER) {
2855
2865
  this.session._triggerKeepAliveTimeoutCheck(), this.retriedRegister = 0;
2856
2866
  const D = (s = (i = e?.result) === null || i === void 0 ? void 0 : i.params) === null || s === void 0 ? void 0 : s.call_report_id;
2857
- D && (o.callReportId = D, v.debug("Captured call_report_id from REGED:", D)), c.type = se.vertoClientReady, j(x.Ready, c, o.uuid);
2867
+ D && (o.callReportId = D, g.debug("Captured call_report_id from REGED:", D)), c.type = se.vertoClientReady, j(x.Ready, c, o.uuid);
2858
2868
  }
2859
2869
  break;
2860
2870
  case ee.UNREGED:
2861
2871
  case ee.NOREG:
2862
2872
  if (this.retriedRegister += 1, this.retriedRegister === 5) {
2863
- this.retriedRegister = 0, j(x.Error, { error: new Ut("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), sessionId: o.sessionid }, o.uuid);
2873
+ this.retriedRegister = 0, j(x.Error, { error: new Ft("Fail to register the user, the server tried 5 times", "UNREGED|NOREG"), sessionId: o.sessionid }, o.uuid);
2864
2874
  break;
2865
2875
  }
2866
2876
  setTimeout((() => {
2867
- this.session.execute(g);
2877
+ this.session.execute(v);
2868
2878
  }), this.reconnectDelay());
2869
2879
  break;
2870
2880
  case ee.FAILED:
2871
2881
  case ee.FAIL_WAIT:
2872
2882
  if (o.connection.previousGatewayState !== ee.FAILED && o.connection.previousGatewayState !== ee.FAIL_WAIT) {
2873
2883
  if (!this.session.hasAutoReconnect()) {
2874
- this.retriedConnect = 0, j(x.Error, { error: new Ut("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), sessionId: o.sessionid }, o.uuid);
2884
+ this.retriedConnect = 0, j(x.Error, { error: new Ft("Fail to connect the server, the server tried 5 times", "FAILED|FAIL_WAIT"), sessionId: o.sessionid }, o.uuid);
2875
2885
  break;
2876
2886
  }
2877
2887
  if (this.retriedConnect += 1, this.retriedConnect === 5) {
@@ -2879,12 +2889,12 @@ class wi {
2879
2889
  break;
2880
2890
  }
2881
2891
  setTimeout((() => {
2882
- if (v.debug(`Reconnecting... Retry ${this.retriedConnect} of 5`), this.session.options.keepConnectionAliveOnSocketClose) {
2892
+ if (g.debug(`Reconnecting... Retry ${this.retriedConnect} of 5`), this.session.options.keepConnectionAliveOnSocketClose) {
2883
2893
  if (Object.values(o.calls).some(((W) => {
2884
2894
  var B;
2885
2895
  return ((B = W.peer) === null || B === void 0 ? void 0 : B.instance) && !W.signalingStateClosed;
2886
- }))) return v.debug("Reconnecting by keeping the existing session due to keepConnectionAliveOnSocketClose option being set."), void this.session.socketDisconnect();
2887
- v.debug("keepConnectionAliveOnSocketClose is set but all peer connections have signalingState closed, doing full reconnect");
2896
+ }))) return g.debug("Reconnecting by keeping the existing session due to keepConnectionAliveOnSocketClose option being set."), void this.session.socketDisconnect();
2897
+ g.debug("keepConnectionAliveOnSocketClose is set but all peer connections have signalingState closed, doing full reconnect");
2888
2898
  }
2889
2899
  this.session.disconnect().then((() => {
2890
2900
  this.session.clearConnection(), this.session.connect();
@@ -2893,11 +2903,11 @@ class wi {
2893
2903
  }
2894
2904
  break;
2895
2905
  default:
2896
- v.warn("GatewayState message unknown method:", e);
2906
+ g.warn("GatewayState message unknown method:", e);
2897
2907
  }
2898
2908
  break;
2899
2909
  }
2900
- v.debug("Verto message unknown method:", e);
2910
+ g.debug("Verto message unknown method:", e);
2901
2911
  break;
2902
2912
  }
2903
2913
  }
@@ -2917,16 +2927,16 @@ class wi {
2917
2927
  case "conference-liveArray-join": {
2918
2928
  const b = () => {
2919
2929
  t.vertoBroadcast({ nodeId: this.nodeId, channel: o, data: { liveArray: { command: "bootstrap", context: o, name: r } } });
2920
- }, y = { nodeId: this.nodeId, channels: [o], handler: ({ data: g }) => {
2921
- const w = C || this._retrieveCallId(g, o);
2930
+ }, y = { nodeId: this.nodeId, channels: [o], handler: ({ data: v }) => {
2931
+ const w = C || this._retrieveCallId(v, o);
2922
2932
  if (w && t.calls.hasOwnProperty(w)) {
2923
2933
  const R = t.calls[w];
2924
- R._addChannel(o), R.extension = r, R.handleConferenceUpdate(g, e).then(((T) => {
2934
+ R._addChannel(o), R.extension = r, R.handleConferenceUpdate(v, e).then(((T) => {
2925
2935
  T === "INVALID_PACKET" && b();
2926
2936
  }));
2927
2937
  }
2928
- } }, I = yield t.vertoSubscribe(y).catch(((g) => {
2929
- v.error("liveArray subscription error:", g);
2938
+ } }, I = yield t.vertoSubscribe(y).catch(((v) => {
2939
+ g.error("liveArray subscription error:", v);
2930
2940
  }));
2931
2941
  st(I, o) && b();
2932
2942
  break;
@@ -2936,15 +2946,15 @@ class wi {
2936
2946
  if (o && t._existsSubscription(i, o)) {
2937
2947
  const { callId: I = null } = t.subscriptions[i][o];
2938
2948
  if (b = t.calls[I] || null, I !== null) {
2939
- const g = { type: se.conferenceUpdate, action: ie.Leave, conferenceName: r, participantId: Number(p), role: f };
2940
- j(x.Notification, g, I, !1) || j(x.Notification, g, t.uuid), b === null && ue(x.Notification, null, I);
2949
+ const v = { type: se.conferenceUpdate, action: ie.Leave, conferenceName: r, participantId: Number(p), role: f };
2950
+ j(x.Notification, v, I, !1) || j(x.Notification, v, t.uuid), b === null && ue(x.Notification, null, I);
2941
2951
  }
2942
2952
  }
2943
2953
  const y = [o, l, c, u];
2944
2954
  t.vertoUnsubscribe({ nodeId: this.nodeId, channels: y }).then((({ unsubscribedChannels: I = [] }) => {
2945
- b && (b.channels = b.channels.filter(((g) => !I.includes(g))));
2955
+ b && (b.channels = b.channels.filter(((v) => !I.includes(v))));
2946
2956
  })).catch(((I) => {
2947
- v.error("liveArray unsubscribe error:", I);
2957
+ g.error("liveArray unsubscribe error:", I);
2948
2958
  }));
2949
2959
  break;
2950
2960
  }
@@ -2955,7 +2965,7 @@ class wi {
2955
2965
  switch (e.contentType) {
2956
2966
  case "layout-info":
2957
2967
  case "layer-info":
2958
- pn(this.session, e);
2968
+ fn(this.session, e);
2959
2969
  break;
2960
2970
  case "logo-info": {
2961
2971
  const t = { type: se.conferenceUpdate, action: ie.LogoInfo, logo: e.logoURL };
@@ -2965,7 +2975,7 @@ class wi {
2965
2975
  }
2966
2976
  }
2967
2977
  }
2968
- class Ii extends Ci {
2978
+ class ki extends wi {
2969
2979
  constructor(e) {
2970
2980
  super(e), this.relayProtocol = "verto-protocol", this.timeoutErrorCode = -329990, this.handleLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
2971
2981
  this._idle = !1;
@@ -2975,9 +2985,9 @@ class Ii extends Ci {
2975
2985
  } });
2976
2986
  })), this.handleAnonymousLoginOnSocketOpen = () => O(this, void 0, void 0, (function* () {
2977
2987
  this._idle = !1, yield this.login();
2978
- })), this._vertoHandler = new wi(this), window.addEventListener("beforeunload", ((t) => {
2988
+ })), this._vertoHandler = new Ii(this), window.addEventListener("beforeunload", ((t) => {
2979
2989
  this.calls && Object.keys(this.calls).forEach(((i) => {
2980
- this.calls[i] && (v.info(`Hanging up call due to window unload: ${i}`), this.calls[i].hangup({}, !0));
2990
+ this.calls[i] && (g.info(`Hanging up call due to window unload: ${i}`), this.calls[i].hangup({}, !0));
2981
2991
  }));
2982
2992
  }));
2983
2993
  }
@@ -3011,26 +3021,26 @@ class Ii extends Ci {
3011
3021
  this._vertoHandler.handleMessage(e);
3012
3022
  }
3013
3023
  }
3014
- class ki extends Ii {
3024
+ class Ei extends ki {
3015
3025
  constructor(e) {
3016
- super(e), v.info(`SDK version: ${dn}`);
3026
+ super(e), g.info(`SDK version: ${un}`);
3017
3027
  }
3018
3028
  newCall(e) {
3019
3029
  return super.newCall(e);
3020
3030
  }
3021
3031
  static webRTCInfo() {
3022
- return hi();
3032
+ return pi();
3023
3033
  }
3024
3034
  static webRTCSupportedBrowserList() {
3025
3035
  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 }] }];
3026
3036
  }
3027
3037
  }
3028
- function gn(n) {
3038
+ function vn(n) {
3029
3039
  return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
3030
3040
  }
3031
- var tt = { exports: {} }, Ft;
3032
- function Ei() {
3033
- return Ft || (Ft = 1, (function(n) {
3041
+ var tt = { exports: {} }, $t;
3042
+ function Ti() {
3043
+ return $t || ($t = 1, (function(n) {
3034
3044
  var e = Object.prototype.hasOwnProperty, t = "~";
3035
3045
  function i() {
3036
3046
  }
@@ -3069,45 +3079,45 @@ function Ei() {
3069
3079
  }, l.prototype.emit = function(u, p, f, C, b, y) {
3070
3080
  var I = t ? t + u : u;
3071
3081
  if (!this._events[I]) return !1;
3072
- var g = this._events[I], w = arguments.length, R, T;
3073
- if (g.fn) {
3074
- switch (g.once && this.removeListener(u, g.fn, void 0, !0), w) {
3082
+ var v = this._events[I], w = arguments.length, R, T;
3083
+ if (v.fn) {
3084
+ switch (v.once && this.removeListener(u, v.fn, void 0, !0), w) {
3075
3085
  case 1:
3076
- return g.fn.call(g.context), !0;
3086
+ return v.fn.call(v.context), !0;
3077
3087
  case 2:
3078
- return g.fn.call(g.context, p), !0;
3088
+ return v.fn.call(v.context, p), !0;
3079
3089
  case 3:
3080
- return g.fn.call(g.context, p, f), !0;
3090
+ return v.fn.call(v.context, p, f), !0;
3081
3091
  case 4:
3082
- return g.fn.call(g.context, p, f, C), !0;
3092
+ return v.fn.call(v.context, p, f, C), !0;
3083
3093
  case 5:
3084
- return g.fn.call(g.context, p, f, C, b), !0;
3094
+ return v.fn.call(v.context, p, f, C, b), !0;
3085
3095
  case 6:
3086
- return g.fn.call(g.context, p, f, C, b, y), !0;
3096
+ return v.fn.call(v.context, p, f, C, b, y), !0;
3087
3097
  }
3088
3098
  for (T = 1, R = new Array(w - 1); T < w; T++)
3089
3099
  R[T - 1] = arguments[T];
3090
- g.fn.apply(g.context, R);
3100
+ v.fn.apply(v.context, R);
3091
3101
  } else {
3092
- var A = g.length, D;
3102
+ var A = v.length, D;
3093
3103
  for (T = 0; T < A; T++)
3094
- switch (g[T].once && this.removeListener(u, g[T].fn, void 0, !0), w) {
3104
+ switch (v[T].once && this.removeListener(u, v[T].fn, void 0, !0), w) {
3095
3105
  case 1:
3096
- g[T].fn.call(g[T].context);
3106
+ v[T].fn.call(v[T].context);
3097
3107
  break;
3098
3108
  case 2:
3099
- g[T].fn.call(g[T].context, p);
3109
+ v[T].fn.call(v[T].context, p);
3100
3110
  break;
3101
3111
  case 3:
3102
- g[T].fn.call(g[T].context, p, f);
3112
+ v[T].fn.call(v[T].context, p, f);
3103
3113
  break;
3104
3114
  case 4:
3105
- g[T].fn.call(g[T].context, p, f, C);
3115
+ v[T].fn.call(v[T].context, p, f, C);
3106
3116
  break;
3107
3117
  default:
3108
3118
  if (!R) for (D = 1, R = new Array(w - 1); D < w; D++)
3109
3119
  R[D - 1] = arguments[D];
3110
- g[T].fn.apply(g[T].context, R);
3120
+ v[T].fn.apply(v[T].context, R);
3111
3121
  }
3112
3122
  }
3113
3123
  return !0;
@@ -3124,9 +3134,9 @@ function Ei() {
3124
3134
  if (y.fn)
3125
3135
  y.fn === p && (!C || y.once) && (!f || y.context === f) && r(this, b);
3126
3136
  else {
3127
- for (var I = 0, g = [], w = y.length; I < w; I++)
3128
- (y[I].fn !== p || C && !y[I].once || f && y[I].context !== f) && g.push(y[I]);
3129
- g.length ? this._events[b] = g.length === 1 ? g[0] : g : r(this, b);
3137
+ for (var I = 0, v = [], w = y.length; I < w; I++)
3138
+ (y[I].fn !== p || C && !y[I].once || f && y[I].context !== f) && v.push(y[I]);
3139
+ v.length ? this._events[b] = v.length === 1 ? v[0] : v : r(this, b);
3130
3140
  }
3131
3141
  return this;
3132
3142
  }, l.prototype.removeAllListeners = function(u) {
@@ -3135,14 +3145,14 @@ function Ei() {
3135
3145
  }, l.prototype.off = l.prototype.removeListener, l.prototype.addListener = l.prototype.on, l.prefixed = t, l.EventEmitter = l, n.exports = l;
3136
3146
  })(tt)), tt.exports;
3137
3147
  }
3138
- var Ti = Ei();
3139
- const vt = /* @__PURE__ */ gn(Ti), Ge = new vt();
3140
- var De = { exports: {} }, Ri = De.exports, $t;
3141
- function Ai() {
3142
- return $t || ($t = 1, (function(n) {
3148
+ var Ri = Ti();
3149
+ const vt = /* @__PURE__ */ vn(Ri), Ge = new vt();
3150
+ var De = { exports: {} }, Ai = De.exports, Bt;
3151
+ function xi() {
3152
+ return Bt || (Bt = 1, (function(n) {
3143
3153
  (function(e, t) {
3144
3154
  n.exports ? n.exports = t() : e.log = t();
3145
- })(Ri, function() {
3155
+ })(Ai, function() {
3146
3156
  var e = function() {
3147
3157
  }, t = "undefined", i = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), s = [
3148
3158
  "trace",
@@ -3151,8 +3161,8 @@ function Ai() {
3151
3161
  "warn",
3152
3162
  "error"
3153
3163
  ], o = {}, r = null;
3154
- function l(I, g) {
3155
- var w = I[g];
3164
+ function l(I, v) {
3165
+ var w = I[v];
3156
3166
  if (typeof w.bind == "function")
3157
3167
  return w.bind(I);
3158
3168
  try {
@@ -3170,9 +3180,9 @@ function Ai() {
3170
3180
  return I === "debug" && (I = "log"), typeof console === t ? !1 : I === "trace" && i ? c : console[I] !== void 0 ? l(console, I) : console.log !== void 0 ? l(console, "log") : e;
3171
3181
  }
3172
3182
  function p() {
3173
- for (var I = this.getLevel(), g = 0; g < s.length; g++) {
3174
- var w = s[g];
3175
- this[w] = g < I ? e : this.methodFactory(w, I, this.name);
3183
+ for (var I = this.getLevel(), v = 0; v < s.length; v++) {
3184
+ var w = s[v];
3185
+ this[w] = v < I ? e : this.methodFactory(w, I, this.name);
3176
3186
  }
3177
3187
  if (this.log = this.debug, typeof console === t && I < this.levels.SILENT)
3178
3188
  return "No console available for logging";
@@ -3182,10 +3192,10 @@ function Ai() {
3182
3192
  typeof console !== t && (p.call(this), this[I].apply(this, arguments));
3183
3193
  };
3184
3194
  }
3185
- function C(I, g, w) {
3195
+ function C(I, v, w) {
3186
3196
  return u(I) || f.apply(this, arguments);
3187
3197
  }
3188
- function b(I, g) {
3198
+ function b(I, v) {
3189
3199
  var w = this, R, T, A, D = "loglevel";
3190
3200
  typeof I == "string" ? D += ":" + I : typeof I == "symbol" && (D = void 0);
3191
3201
  function W(h) {
@@ -3245,7 +3255,7 @@ function Ai() {
3245
3255
  WARN: 3,
3246
3256
  ERROR: 4,
3247
3257
  SILENT: 5
3248
- }, w.methodFactory = g || C, w.getLevel = function() {
3258
+ }, w.methodFactory = v || C, w.getLevel = function() {
3249
3259
  return A ?? T ?? R;
3250
3260
  }, w.setLevel = function(h, m) {
3251
3261
  return A = a(h), m !== !1 && W(A), p.call(w);
@@ -3267,12 +3277,12 @@ function Ai() {
3267
3277
  var d = B();
3268
3278
  d != null && (A = a(d)), p.call(w);
3269
3279
  }
3270
- r = new b(), r.getLogger = function(g) {
3271
- if (typeof g != "symbol" && typeof g != "string" || g === "")
3280
+ r = new b(), r.getLogger = function(v) {
3281
+ if (typeof v != "symbol" && typeof v != "string" || v === "")
3272
3282
  throw new TypeError("You must supply a name when creating a logger.");
3273
- var w = o[g];
3274
- return w || (w = o[g] = new b(
3275
- g,
3283
+ var w = o[v];
3284
+ return w || (w = o[v] = new b(
3285
+ v,
3276
3286
  r.methodFactory
3277
3287
  )), w;
3278
3288
  };
@@ -3285,24 +3295,24 @@ function Ai() {
3285
3295
  });
3286
3296
  })(De)), De.exports;
3287
3297
  }
3288
- var xi = Ai();
3289
- const Li = /* @__PURE__ */ gn(xi), Oi = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), J = Li.getLogger("telnyx-ai-agent"), Mi = J.methodFactory;
3298
+ var Li = xi();
3299
+ const Oi = /* @__PURE__ */ vn(Li), Mi = () => (/* @__PURE__ */ new Date()).toISOString().replace("T", " ").replace("Z", ""), J = Oi.getLogger("telnyx-ai-agent"), Pi = J.methodFactory;
3290
3300
  J.methodFactory = (n, e, t) => {
3291
- const i = Mi(n, e, t);
3301
+ const i = Pi(n, e, t);
3292
3302
  return function(...s) {
3293
- i(Oi(), "-", ...s);
3303
+ i(Mi(), "-", ...s);
3294
3304
  };
3295
3305
  };
3296
3306
  J.setLevel("info");
3297
- function Pi(n, e) {
3307
+ function Di(n, e) {
3298
3308
  let t = 0;
3299
3309
  return (...i) => {
3300
3310
  const s = Date.now();
3301
3311
  s - t >= e && (t = s, n(...i));
3302
3312
  };
3303
3313
  }
3304
- const Di = 10, Ni = 500, ji = 100, Bt = 20;
3305
- class Ui {
3314
+ const Ni = 10, ji = 500, Ui = 100, Vt = 20;
3315
+ class Fi {
3306
3316
  remoteIntervalId = null;
3307
3317
  localIntervalId = null;
3308
3318
  remoteStream = null;
@@ -3329,9 +3339,9 @@ class Ui {
3329
3339
  minSpeechDurationMs;
3330
3340
  maxLatencyMs;
3331
3341
  constructor(e) {
3332
- this.volumeThreshold = e?.volumeThreshold ?? Di, this.silenceDurationMs = e?.silenceDurationMs ?? Ni, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? ji, this.maxLatencyMs = e?.maxLatencyMs;
3342
+ this.volumeThreshold = e?.volumeThreshold ?? Ni, this.silenceDurationMs = e?.silenceDurationMs ?? ji, this.minSpeechDurationMs = e?.minSpeechDurationMs ?? Ui, this.maxLatencyMs = e?.maxLatencyMs;
3333
3343
  }
3334
- updateAgentState = Pi((e) => {
3344
+ updateAgentState = Di((e) => {
3335
3345
  J.debug("AudioStreamMonitor updateAgentState", e), J.debug("Previous state:", this.lastState), e.state !== this.lastState && (this.lastState = e.state, Ge.emit("conversation.agent.state", e));
3336
3346
  }, 100);
3337
3347
  /**
@@ -3402,7 +3412,7 @@ class Ui {
3402
3412
  this.thinkingStartTime === null && this.updateAgentState({ state: "listening" });
3403
3413
  i = r;
3404
3414
  };
3405
- this.remoteIntervalId = window.setInterval(s, Bt);
3415
+ this.remoteIntervalId = window.setInterval(s, Vt);
3406
3416
  }
3407
3417
  /**
3408
3418
  * Monitor local stream (user's microphone) for VAD
@@ -3427,46 +3437,46 @@ class Ui {
3427
3437
  this.updateAgentState({ state: "thinking", thinkingStartedAt: l });
3428
3438
  }
3429
3439
  };
3430
- this.localIntervalId = window.setInterval(t, Bt);
3440
+ this.localIntervalId = window.setInterval(t, Vt);
3431
3441
  }
3432
3442
  destroy() {
3433
3443
  this.stopAudioStreamMonitor();
3434
3444
  }
3435
3445
  }
3436
- function Fi(n) {
3446
+ function $i(n) {
3437
3447
  if (!n || typeof n != "object")
3438
3448
  return !1;
3439
3449
  const e = n;
3440
3450
  return e.method === "ai_conversation" && typeof e.params == "object";
3441
3451
  }
3442
- function $i(n) {
3452
+ function Bi(n) {
3443
3453
  if (!n || typeof n != "object")
3444
3454
  return !1;
3445
3455
  const e = n;
3446
3456
  return e.params.type !== "response.text.delta" ? !1 : !!e.params.delta;
3447
3457
  }
3448
- function Bi(n) {
3458
+ function Vi(n) {
3449
3459
  if (!n || typeof n != "object")
3450
3460
  return !1;
3451
3461
  const e = n;
3452
3462
  return e.params.type !== "conversation.item.created" ? !1 : !!e.params.item.content;
3453
3463
  }
3454
- function Vi(n) {
3464
+ function Gi(n) {
3455
3465
  if (!n || typeof n != "object")
3456
3466
  return !1;
3457
3467
  const e = n;
3458
3468
  return e.params?.type !== "conversation.item.deleted" ? !1 : !!e.params.item_id;
3459
3469
  }
3460
- function Gi(n) {
3461
- return $i(n) ? {
3470
+ function Hi(n) {
3471
+ return Bi(n) ? {
3462
3472
  id: `${n.params.item_id}-${Date.now()}`,
3463
3473
  role: "assistant",
3464
3474
  content: n.params.delta,
3465
3475
  timestamp: /* @__PURE__ */ new Date()
3466
3476
  } : null;
3467
3477
  }
3468
- function Hi(n) {
3469
- if (!Bi(n) || n.params.item.role !== "user" || n.params.item.status !== "completed")
3478
+ function Wi(n) {
3479
+ if (!Vi(n) || n.params.item.role !== "user" || n.params.item.status !== "completed")
3470
3480
  return null;
3471
3481
  let e = "", t = [];
3472
3482
  return Array.isArray(n.params.item.content) ? (e = n.params.item.content.reduce((i, s) => (s.type === "text" && (i += s.text), i), ""), t = n.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 = n.params.item.content, {
@@ -3477,29 +3487,29 @@ function Hi(n) {
3477
3487
  attachments: t
3478
3488
  };
3479
3489
  }
3480
- class Wi extends vt {
3490
+ class qi extends vt {
3481
3491
  telnyxRTC;
3482
3492
  transcript = [];
3483
3493
  constructor(e) {
3484
3494
  super(), this.telnyxRTC = e, this.telnyxRTC.on(x.SocketMessage, this.onSocketMessage);
3485
3495
  }
3486
3496
  onSocketMessage = (e) => {
3487
- if (Fi(e))
3497
+ if ($i(e))
3488
3498
  switch (e.params.type) {
3489
3499
  case "response.text.delta": {
3490
- const t = Gi(e);
3500
+ const t = Hi(e);
3491
3501
  t && (this.transcript.push(t), this.emit("transcript.item", t), Ge.emit("conversation.agent.state", { state: "listening" }));
3492
3502
  return;
3493
3503
  }
3494
3504
  case "conversation.item.deleted": {
3495
- if (Vi(e)) {
3505
+ if (Gi(e)) {
3496
3506
  const t = e.params.item_id, i = this.transcript.findIndex((s) => s.id === t);
3497
3507
  i !== -1 && this.transcript.splice(i, 1);
3498
3508
  }
3499
3509
  return;
3500
3510
  }
3501
3511
  case "conversation.item.created": {
3502
- const t = Hi(e);
3512
+ const t = Wi(e);
3503
3513
  if (t) {
3504
3514
  const i = this.transcript.findIndex(
3505
3515
  (s) => s.id === t.id
@@ -3511,7 +3521,7 @@ class Wi extends vt {
3511
3521
  }
3512
3522
  };
3513
3523
  }
3514
- class Vt extends vt {
3524
+ class Gt extends vt {
3515
3525
  telnyxRTC;
3516
3526
  transcription;
3517
3527
  agentId;
@@ -3534,15 +3544,16 @@ class Vt extends vt {
3534
3544
  };
3535
3545
  e.conversationId && (t.target_params = {
3536
3546
  conversation_id: e.conversationId
3537
- }), this.telnyxRTC = new ki({
3547
+ }), this.telnyxRTC = new Ei({
3538
3548
  env: e.environment || "production",
3539
3549
  anonymous_login: t,
3540
3550
  debug: e.debug || !1,
3541
- trickleIce: e.trickleIce
3542
- }), this.telnyxRTC.on(x.Ready, this.onClientReady), this.telnyxRTC.on(x.Error, this.onClientOrSocketError), this.telnyxRTC.on(x.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(x.Notification, this.onNotification), this.transcription = new Wi(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), Ge.addListener(
3551
+ trickleIce: e.trickleIce,
3552
+ region: e.region
3553
+ }), this.telnyxRTC.on(x.Ready, this.onClientReady), this.telnyxRTC.on(x.Error, this.onClientOrSocketError), this.telnyxRTC.on(x.SocketError, this.onClientOrSocketError), this.telnyxRTC.on(x.Notification, this.onNotification), this.transcription = new qi(this.telnyxRTC), this.transcription.addListener("transcript.item", this.onTranscriptItem), Ge.addListener(
3543
3554
  "conversation.agent.state",
3544
3555
  this.onAgentStateChange
3545
- ), this.audioStreamMonitor = new Ui(e.vad);
3556
+ ), this.audioStreamMonitor = new Fi(e.vad);
3546
3557
  }
3547
3558
  /**
3548
3559
  * Connects to the Telnyx WebRTC service and establishes a session with the AI agent.
@@ -3676,10 +3687,10 @@ class Vt extends vt {
3676
3687
  };
3677
3688
  }
3678
3689
  var Pe = { exports: {} }, Se = {};
3679
- var Gt;
3680
- function qi() {
3681
- if (Gt) return Se;
3682
- Gt = 1;
3690
+ var Ht;
3691
+ function Yi() {
3692
+ if (Ht) return Se;
3693
+ Ht = 1;
3683
3694
  var n = Symbol.for("react.transitional.element"), e = Symbol.for("react.fragment");
3684
3695
  function t(i, s, o) {
3685
3696
  var r = null;
@@ -3699,16 +3710,16 @@ function qi() {
3699
3710
  return Se.Fragment = e, Se.jsx = t, Se.jsxs = t, Se;
3700
3711
  }
3701
3712
  var _e = {};
3702
- var Ht;
3703
- function Yi() {
3704
- return Ht || (Ht = 1, process.env.NODE_ENV !== "production" && (function() {
3713
+ var Wt;
3714
+ function Ji() {
3715
+ return Wt || (Wt = 1, process.env.NODE_ENV !== "production" && (function() {
3705
3716
  function n(S) {
3706
3717
  if (S == null) return null;
3707
3718
  if (typeof S == "function")
3708
3719
  return S.$$typeof === h ? null : S.displayName || S.name || null;
3709
3720
  if (typeof S == "string") return S;
3710
3721
  switch (S) {
3711
- case g:
3722
+ case v:
3712
3723
  return "Fragment";
3713
3724
  case R:
3714
3725
  return "Profiler";
@@ -3766,7 +3777,7 @@ function Yi() {
3766
3777
  }
3767
3778
  }
3768
3779
  function i(S) {
3769
- if (S === g) return "<>";
3780
+ if (S === v) return "<>";
3770
3781
  if (typeof S == "object" && S !== null && S.$$typeof === a)
3771
3782
  return "<...>";
3772
3783
  try {
@@ -3804,7 +3815,7 @@ function Yi() {
3804
3815
  }
3805
3816
  function c() {
3806
3817
  var S = n(this.type);
3807
- return F[S] || (F[S] = !0, console.error(
3818
+ return $[S] || ($[S] = !0, console.error(
3808
3819
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
3809
3820
  )), S = this.props.ref, S !== void 0 ? S : null;
3810
3821
  }
@@ -3856,8 +3867,8 @@ function Yi() {
3856
3867
  else f(H);
3857
3868
  if (_.call(P, "key")) {
3858
3869
  H = n(S);
3859
- var oe = Object.keys(P).filter(function(xn) {
3860
- return xn !== "key";
3870
+ var oe = Object.keys(P).filter(function(Ln) {
3871
+ return Ln !== "key";
3861
3872
  });
3862
3873
  V = 0 < oe.length ? "{key: someKey, " + oe.join(": ..., ") + ": ...}" : "{key: someKey}", G[H + V] || (oe = 0 < oe.length ? "{" + oe.join(": ..., ") + ": ...}" : "{}", console.error(
3863
3874
  `A props object containing a "key" prop is being spread into JSX:
@@ -3895,7 +3906,7 @@ React keys must be passed directly to JSX without using spread:
3895
3906
  function C(S) {
3896
3907
  return typeof S == "object" && S !== null && S.$$typeof === y;
3897
3908
  }
3898
- var b = ht, y = Symbol.for("react.transitional.element"), I = Symbol.for("react.portal"), g = Symbol.for("react.fragment"), w = Symbol.for("react.strict_mode"), R = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), A = Symbol.for("react.context"), D = Symbol.for("react.forward_ref"), W = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), M = Symbol.for("react.memo"), a = Symbol.for("react.lazy"), d = Symbol.for("react.activity"), h = Symbol.for("react.client.reference"), m = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, _ = Object.prototype.hasOwnProperty, E = Array.isArray, k = console.createTask ? console.createTask : function() {
3909
+ var b = ht, y = Symbol.for("react.transitional.element"), I = Symbol.for("react.portal"), v = Symbol.for("react.fragment"), w = Symbol.for("react.strict_mode"), R = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), A = Symbol.for("react.context"), D = Symbol.for("react.forward_ref"), W = Symbol.for("react.suspense"), B = Symbol.for("react.suspense_list"), M = Symbol.for("react.memo"), a = Symbol.for("react.lazy"), d = Symbol.for("react.activity"), h = Symbol.for("react.client.reference"), m = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, _ = Object.prototype.hasOwnProperty, E = Array.isArray, k = console.createTask ? console.createTask : function() {
3899
3910
  return null;
3900
3911
  };
3901
3912
  b = {
@@ -3903,11 +3914,11 @@ React keys must be passed directly to JSX without using spread:
3903
3914
  return S();
3904
3915
  }
3905
3916
  };
3906
- var L, F = {}, Z = b.react_stack_bottom_frame.bind(
3917
+ var L, $ = {}, Z = b.react_stack_bottom_frame.bind(
3907
3918
  b,
3908
3919
  o
3909
3920
  )(), te = k(i(o)), G = {};
3910
- _e.Fragment = g, _e.jsx = function(S, P, U) {
3921
+ _e.Fragment = v, _e.jsx = function(S, P, U) {
3911
3922
  var V = 1e4 > m.recentlyCreatedOwnerStacks++;
3912
3923
  return p(
3913
3924
  S,
@@ -3930,19 +3941,19 @@ React keys must be passed directly to JSX without using spread:
3930
3941
  };
3931
3942
  })()), _e;
3932
3943
  }
3933
- var Wt;
3934
- function Ji() {
3935
- return Wt || (Wt = 1, process.env.NODE_ENV === "production" ? Pe.exports = qi() : Pe.exports = Yi()), Pe.exports;
3944
+ var qt;
3945
+ function zi() {
3946
+ return qt || (qt = 1, process.env.NODE_ENV === "production" ? Pe.exports = Yi() : Pe.exports = Ji()), Pe.exports;
3936
3947
  }
3937
- var Ce = Ji();
3948
+ var Ce = zi();
3938
3949
  const le = { BASE_URL: "/", DEV: !1, MODE: "production", PROD: !0, SSR: !1 };
3939
- function vn(n) {
3950
+ function mn(n) {
3940
3951
  return "init" in n;
3941
3952
  }
3942
3953
  function at(n) {
3943
3954
  return !!n.write;
3944
3955
  }
3945
- function qt(n) {
3956
+ function Yt(n) {
3946
3957
  return "v" in n || "e" in n;
3947
3958
  }
3948
3959
  function He(n) {
@@ -3953,11 +3964,11 @@ function He(n) {
3953
3964
  return n.v;
3954
3965
  }
3955
3966
  const We = /* @__PURE__ */ new WeakMap();
3956
- function mn(n) {
3967
+ function yn(n) {
3957
3968
  var e;
3958
3969
  return qe(n) && !!((e = We.get(n)) != null && e[0]);
3959
3970
  }
3960
- function zi(n) {
3971
+ function Ki(n) {
3961
3972
  const e = We.get(n);
3962
3973
  e?.[0] && (e[0] = !1, e[1].forEach((t) => t()));
3963
3974
  }
@@ -3975,14 +3986,14 @@ function ct(n, e) {
3975
3986
  function qe(n) {
3976
3987
  return typeof n?.then == "function";
3977
3988
  }
3978
- function yn(n, e, t) {
3989
+ function bn(n, e, t) {
3979
3990
  if (!t.p.has(n)) {
3980
3991
  t.p.add(n);
3981
3992
  const i = () => t.p.delete(n);
3982
3993
  e.then(i, i);
3983
3994
  }
3984
3995
  }
3985
- function bn(n, e, t) {
3996
+ function Sn(n, e, t) {
3986
3997
  var i;
3987
3998
  const s = /* @__PURE__ */ new Set();
3988
3999
  for (const o of ((i = t.get(n)) == null ? void 0 : i.t) || [])
@@ -3991,24 +4002,24 @@ function bn(n, e, t) {
3991
4002
  s.add(o);
3992
4003
  return s;
3993
4004
  }
3994
- const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi = (n, e) => {
4005
+ const Xi = (n, e, ...t) => e.read(...t), Qi = (n, e, ...t) => e.write(...t), Zi = (n, e) => {
3995
4006
  if (e.INTERNAL_onInit)
3996
4007
  return e.INTERNAL_onInit(n);
3997
4008
  if (e.unstable_onInit)
3998
4009
  return console.warn(
3999
4010
  "[DEPRECATED] atom.unstable_onInit is renamed to atom.INTERNAL_onInit."
4000
4011
  ), e.unstable_onInit(n);
4001
- }, Zi = (n, e, t) => {
4012
+ }, es = (n, e, t) => {
4002
4013
  var i;
4003
4014
  return (i = e.onMount) == null ? void 0 : i.call(e, t);
4004
- }, es = (n, e) => {
4015
+ }, ts = (n, e) => {
4005
4016
  var t;
4006
4017
  const i = X(n), s = i[0], o = i[6], r = i[9];
4007
4018
  if ((le ? "production" : void 0) !== "production" && !e)
4008
4019
  throw new Error("Atom is undefined or null");
4009
4020
  let l = s.get(e);
4010
4021
  return l || (l = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, s.set(e, l), (t = o.i) == null || t.call(o, e), r?.(n, e)), l;
4011
- }, ts = (n) => {
4022
+ }, ns = (n) => {
4012
4023
  const e = X(n), t = e[1], i = e[3], s = e[4], o = e[5], r = e[6], l = e[13], c = [], u = (p) => {
4013
4024
  try {
4014
4025
  p();
@@ -4026,7 +4037,7 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
4026
4037
  } while (i.size || o.size || s.size);
4027
4038
  if (c.length)
4028
4039
  throw new AggregateError(c);
4029
- }, ns = (n) => {
4040
+ }, is = (n) => {
4030
4041
  const e = X(n), t = e[1], i = e[2], s = e[3], o = e[11], r = e[14], l = e[17], c = [], u = /* @__PURE__ */ new WeakSet(), p = /* @__PURE__ */ new WeakSet(), f = Array.from(s);
4031
4042
  for (; f.length; ) {
4032
4043
  const C = f[f.length - 1], b = o(n, C);
@@ -4043,35 +4054,35 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
4043
4054
  continue;
4044
4055
  }
4045
4056
  u.add(C);
4046
- for (const y of bn(C, b, t))
4057
+ for (const y of Sn(C, b, t))
4047
4058
  u.has(y) || f.push(y);
4048
4059
  }
4049
4060
  for (let C = c.length - 1; C >= 0; --C) {
4050
4061
  const [b, y] = c[C];
4051
4062
  let I = !1;
4052
- for (const g of y.d.keys())
4053
- if (g !== b && s.has(g)) {
4063
+ for (const v of y.d.keys())
4064
+ if (v !== b && s.has(v)) {
4054
4065
  I = !0;
4055
4066
  break;
4056
4067
  }
4057
4068
  I && (r(n, b), l(n, b)), i.delete(b);
4058
4069
  }
4059
- }, lt = /* @__PURE__ */ new WeakSet(), is = (n, e) => {
4070
+ }, lt = /* @__PURE__ */ new WeakSet(), ss = (n, e) => {
4060
4071
  var t, i;
4061
- const s = X(n), o = s[1], r = s[2], l = s[3], c = s[6], u = s[7], p = s[11], f = s[12], C = s[13], b = s[14], y = s[16], I = s[17], g = p(n, e);
4062
- if (qt(g)) {
4063
- if (o.has(e) && r.get(e) !== g.n)
4064
- return g;
4072
+ const s = X(n), o = s[1], r = s[2], l = s[3], c = s[6], u = s[7], p = s[11], f = s[12], C = s[13], b = s[14], y = s[16], I = s[17], v = p(n, e);
4073
+ if (Yt(v)) {
4074
+ if (o.has(e) && r.get(e) !== v.n)
4075
+ return v;
4065
4076
  let M = !1;
4066
- for (const [a, d] of g.d)
4077
+ for (const [a, d] of v.d)
4067
4078
  if (b(n, a).n !== d) {
4068
4079
  M = !0;
4069
4080
  break;
4070
4081
  }
4071
4082
  if (!M)
4072
- return g;
4083
+ return v;
4073
4084
  }
4074
- g.d.clear();
4085
+ v.d.clear();
4075
4086
  let w = !0;
4076
4087
  function R() {
4077
4088
  o.has(e) && (I(n, e), C(n), f(n));
@@ -4080,8 +4091,8 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
4080
4091
  var a;
4081
4092
  if (M === e) {
4082
4093
  const h = p(n, M);
4083
- if (!qt(h))
4084
- if (vn(M))
4094
+ if (!Yt(h))
4095
+ if (mn(M))
4085
4096
  Ye(n, M, M.init);
4086
4097
  else
4087
4098
  throw new Error("no atom init");
@@ -4091,7 +4102,7 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
4091
4102
  try {
4092
4103
  return He(d);
4093
4104
  } finally {
4094
- g.d.set(M, d.n), mn(g.v) && yn(e, g.v, d), o.has(e) && ((a = o.get(M)) == null || a.t.add(e)), w || R();
4105
+ v.d.set(M, d.n), yn(v.v) && bn(e, v.v, d), o.has(e) && ((a = o.get(M)) == null || a.t.add(e)), w || R();
4095
4106
  }
4096
4107
  }
4097
4108
  let A, D;
@@ -4109,43 +4120,43 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
4109
4120
  }
4110
4121
  }), D;
4111
4122
  }
4112
- }, B = g.n;
4123
+ }, B = v.n;
4113
4124
  try {
4114
4125
  (le ? "production" : void 0) !== "production" && lt.delete(n);
4115
4126
  const M = u(n, e, T, W);
4116
4127
  return (le ? "production" : void 0) !== "production" && lt.has(n) && console.warn(
4117
4128
  "Detected store mutation during atom read. This is not supported."
4118
- ), Ye(n, e, M), qe(M) && (ct(M, () => A?.abort()), M.then(R, R)), (t = c.r) == null || t.call(c, e), g;
4129
+ ), Ye(n, e, M), qe(M) && (ct(M, () => A?.abort()), M.then(R, R)), (t = c.r) == null || t.call(c, e), v;
4119
4130
  } catch (M) {
4120
- return delete g.v, g.e = M, ++g.n, g;
4131
+ return delete v.v, v.e = M, ++v.n, v;
4121
4132
  } finally {
4122
- w = !1, B !== g.n && r.get(e) === B && (r.set(e, g.n), l.add(e), (i = c.c) == null || i.call(c, e));
4133
+ w = !1, B !== v.n && r.get(e) === B && (r.set(e, v.n), l.add(e), (i = c.c) == null || i.call(c, e));
4123
4134
  }
4124
- }, ss = (n, e) => {
4135
+ }, os = (n, e) => {
4125
4136
  const t = X(n), i = t[1], s = t[2], o = t[11], r = [e];
4126
4137
  for (; r.length; ) {
4127
4138
  const l = r.pop(), c = o(n, l);
4128
- for (const u of bn(l, c, i)) {
4139
+ for (const u of Sn(l, c, i)) {
4129
4140
  const p = o(n, u);
4130
4141
  s.set(u, p.n), r.push(u);
4131
4142
  }
4132
4143
  }
4133
- }, Sn = (n, e, ...t) => {
4144
+ }, _n = (n, e, ...t) => {
4134
4145
  const i = X(n), s = i[3], o = i[6], r = i[8], l = i[11], c = i[12], u = i[13], p = i[14], f = i[15], C = i[17];
4135
4146
  let b = !0;
4136
- const y = (g) => He(p(n, g)), I = (g, ...w) => {
4147
+ const y = (v) => He(p(n, v)), I = (v, ...w) => {
4137
4148
  var R;
4138
- const T = l(n, g);
4149
+ const T = l(n, v);
4139
4150
  try {
4140
- if (g === e) {
4141
- if (!vn(g))
4151
+ if (v === e) {
4152
+ if (!mn(v))
4142
4153
  throw new Error("atom not writable");
4143
4154
  (le ? "production" : void 0) !== "production" && lt.add(n);
4144
4155
  const A = T.n, D = w[0];
4145
- Ye(n, g, D), C(n, g), A !== T.n && (s.add(g), f(n, g), (R = o.c) == null || R.call(o, g));
4156
+ Ye(n, v, D), C(n, v), A !== T.n && (s.add(v), f(n, v), (R = o.c) == null || R.call(o, v));
4146
4157
  return;
4147
4158
  } else
4148
- return Sn(n, g, ...w);
4159
+ return _n(n, v, ...w);
4149
4160
  } finally {
4150
4161
  b || (u(n), c(n));
4151
4162
  }
@@ -4155,10 +4166,10 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
4155
4166
  } finally {
4156
4167
  b = !1;
4157
4168
  }
4158
- }, os = (n, e) => {
4169
+ }, rs = (n, e) => {
4159
4170
  var t;
4160
4171
  const i = X(n), s = i[1], o = i[3], r = i[6], l = i[11], c = i[15], u = i[18], p = i[19], f = l(n, e), C = s.get(e);
4161
- if (C && !mn(f.v)) {
4172
+ if (C && !yn(f.v)) {
4162
4173
  for (const [b, y] of f.d)
4163
4174
  if (!C.d.has(b)) {
4164
4175
  const I = l(n, b);
@@ -4171,40 +4182,40 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
4171
4182
  y?.t.delete(e);
4172
4183
  }
4173
4184
  }
4174
- }, _n = (n, e) => {
4185
+ }, Cn = (n, e) => {
4175
4186
  var t;
4176
4187
  const i = X(n), s = i[1], o = i[4], r = i[6], l = i[10], c = i[11], u = i[12], p = i[13], f = i[14], C = i[16], b = c(n, e);
4177
4188
  let y = s.get(e);
4178
4189
  if (!y) {
4179
4190
  f(n, e);
4180
4191
  for (const I of b.d.keys())
4181
- _n(n, I).t.add(e);
4192
+ Cn(n, I).t.add(e);
4182
4193
  if (y = {
4183
4194
  l: /* @__PURE__ */ new Set(),
4184
4195
  d: new Set(b.d.keys()),
4185
4196
  t: /* @__PURE__ */ new Set()
4186
4197
  }, s.set(e, y), at(e)) {
4187
4198
  const I = () => {
4188
- let g = !0;
4199
+ let v = !0;
4189
4200
  const w = (...R) => {
4190
4201
  try {
4191
4202
  return C(n, e, ...R);
4192
4203
  } finally {
4193
- g || (p(n), u(n));
4204
+ v || (p(n), u(n));
4194
4205
  }
4195
4206
  };
4196
4207
  try {
4197
4208
  const R = l(n, e, w);
4198
4209
  R && (y.u = () => {
4199
- g = !0;
4210
+ v = !0;
4200
4211
  try {
4201
4212
  R();
4202
4213
  } finally {
4203
- g = !1;
4214
+ v = !1;
4204
4215
  }
4205
4216
  });
4206
4217
  } finally {
4207
- g = !1;
4218
+ v = !1;
4208
4219
  }
4209
4220
  };
4210
4221
  o.add(I);
@@ -4212,7 +4223,7 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
4212
4223
  (t = r.m) == null || t.call(r, e);
4213
4224
  }
4214
4225
  return y;
4215
- }, rs = (n, e) => {
4226
+ }, as = (n, e) => {
4216
4227
  var t, i;
4217
4228
  const s = X(n), o = s[1], r = s[5], l = s[6], c = s[11], u = s[19], p = c(n, e);
4218
4229
  let f = o.get(e);
@@ -4238,36 +4249,36 @@ const Ki = (n, e, ...t) => e.read(...t), Xi = (n, e, ...t) => e.write(...t), Qi
4238
4249
  const i = X(n)[11], s = i(n, e), o = "v" in s, r = s.v;
4239
4250
  if (qe(t))
4240
4251
  for (const l of s.d.keys())
4241
- yn(
4252
+ bn(
4242
4253
  e,
4243
4254
  t,
4244
4255
  i(n, l)
4245
4256
  );
4246
- s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n, qe(r) && zi(r));
4247
- }, as = (n, e) => {
4257
+ s.v = t, delete s.e, (!o || !Object.is(r, s.v)) && (++s.n, qe(r) && Ki(r));
4258
+ }, cs = (n, e) => {
4248
4259
  const t = X(n)[14];
4249
4260
  return He(t(n, e));
4250
- }, cs = (n, e, ...t) => {
4261
+ }, ls = (n, e, ...t) => {
4251
4262
  const i = X(n), s = i[12], o = i[13], r = i[16];
4252
4263
  try {
4253
4264
  return r(n, e, ...t);
4254
4265
  } finally {
4255
4266
  o(n), s(n);
4256
4267
  }
4257
- }, ls = (n, e, t) => {
4268
+ }, ds = (n, e, t) => {
4258
4269
  const i = X(n), s = i[12], o = i[18], r = i[19], c = o(n, e).l;
4259
4270
  return c.add(t), s(n), () => {
4260
4271
  c.delete(t), r(n, e), s(n);
4261
4272
  };
4262
- }, Cn = /* @__PURE__ */ new WeakMap(), X = (n) => {
4263
- const e = Cn.get(n);
4273
+ }, wn = /* @__PURE__ */ new WeakMap(), X = (n) => {
4274
+ const e = wn.get(n);
4264
4275
  if ((le ? "production" : void 0) !== "production" && !e)
4265
4276
  throw new Error(
4266
4277
  "Store must be created by buildStore to read its building blocks"
4267
4278
  );
4268
4279
  return e;
4269
4280
  };
4270
- function ds(...n) {
4281
+ function us(...n) {
4271
4282
  const e = {
4272
4283
  get(i) {
4273
4284
  const s = X(e)[21];
@@ -4298,61 +4309,61 @@ function ds(...n) {
4298
4309
  {},
4299
4310
  // storeHooks
4300
4311
  // atom interceptors
4301
- Ki,
4302
4312
  Xi,
4303
4313
  Qi,
4304
4314
  Zi,
4305
- // building-block functions
4306
4315
  es,
4316
+ // building-block functions
4307
4317
  ts,
4308
4318
  ns,
4309
4319
  is,
4310
4320
  ss,
4311
- Sn,
4312
4321
  os,
4313
4322
  _n,
4314
4323
  rs,
4315
- Ye,
4324
+ Cn,
4316
4325
  as,
4326
+ Ye,
4317
4327
  cs,
4318
4328
  ls,
4329
+ ds,
4319
4330
  void 0
4320
4331
  ].map((i, s) => n[s] || i);
4321
- return Cn.set(e, Object.freeze(t)), e;
4332
+ return wn.set(e, Object.freeze(t)), e;
4322
4333
  }
4323
- const wn = {};
4324
- let us = 0;
4334
+ const In = {};
4335
+ let hs = 0;
4325
4336
  function Je(n, e) {
4326
- const t = `atom${++us}`, i = {
4337
+ const t = `atom${++hs}`, i = {
4327
4338
  toString() {
4328
- return (wn ? "production" : void 0) !== "production" && this.debugLabel ? t + ":" + this.debugLabel : t;
4339
+ return (In ? "production" : void 0) !== "production" && this.debugLabel ? t + ":" + this.debugLabel : t;
4329
4340
  }
4330
4341
  };
4331
- return typeof n == "function" ? i.read = n : (i.init = n, i.read = hs, i.write = ps), i;
4342
+ return typeof n == "function" ? i.read = n : (i.init = n, i.read = ps, i.write = fs), i;
4332
4343
  }
4333
- function hs(n) {
4344
+ function ps(n) {
4334
4345
  return n(this);
4335
4346
  }
4336
- function ps(n, e, t) {
4347
+ function fs(n, e, t) {
4337
4348
  return e(
4338
4349
  this,
4339
4350
  typeof t == "function" ? t(n(this)) : t
4340
4351
  );
4341
4352
  }
4342
- function fs() {
4343
- return ds();
4353
+ function gs() {
4354
+ return us();
4344
4355
  }
4345
4356
  let we;
4346
- function gs() {
4347
- return we || (we = fs(), (wn ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = we), globalThis.__JOTAI_DEFAULT_STORE__ !== we && console.warn(
4357
+ function vs() {
4358
+ return we || (we = gs(), (In ? "production" : void 0) !== "production" && (globalThis.__JOTAI_DEFAULT_STORE__ || (globalThis.__JOTAI_DEFAULT_STORE__ = we), globalThis.__JOTAI_DEFAULT_STORE__ !== we && console.warn(
4348
4359
  "Detected multiple Jotai instances. It may cause unexpected behavior with the default store. https://github.com/pmndrs/jotai/discussions/2044"
4349
4360
  ))), we;
4350
4361
  }
4351
- const vs = {}, ms = zt(
4362
+ const ms = {}, ys = Kt(
4352
4363
  void 0
4353
4364
  );
4354
- function In(n) {
4355
- return Jt(ms) || gs();
4365
+ function kn(n) {
4366
+ return zt(ys) || vs();
4356
4367
  }
4357
4368
  const dt = (n) => typeof n?.then == "function", ut = (n) => {
4358
4369
  n.status || (n.status = "pending", n.then(
@@ -4363,14 +4374,14 @@ const dt = (n) => typeof n?.then == "function", ut = (n) => {
4363
4374
  n.status = "rejected", n.reason = e;
4364
4375
  }
4365
4376
  ));
4366
- }, ys = ht.use || // A shim for older React versions
4377
+ }, bs = ht.use || // A shim for older React versions
4367
4378
  ((n) => {
4368
4379
  if (n.status === "pending")
4369
4380
  throw n;
4370
4381
  if (n.status === "fulfilled")
4371
4382
  return n.value;
4372
4383
  throw n.status === "rejected" ? n.reason : (ut(n), n);
4373
- }), nt = /* @__PURE__ */ new WeakMap(), Yt = (n, e) => {
4384
+ }), nt = /* @__PURE__ */ new WeakMap(), Jt = (n, e) => {
4374
4385
  let t = nt.get(n);
4375
4386
  return t || (t = new Promise((i, s) => {
4376
4387
  let o = n;
@@ -4390,7 +4401,7 @@ const dt = (n) => typeof n?.then == "function", ut = (n) => {
4390
4401
  }), nt.set(n, t)), t;
4391
4402
  };
4392
4403
  function ze(n, e) {
4393
- const { delay: t, unstable_promiseStatus: i = !ht.use } = {}, s = In(), [[o, r, l], c] = Ln(
4404
+ const { delay: t, unstable_promiseStatus: i = !ht.use } = {}, s = kn(), [[o, r, l], c] = On(
4394
4405
  (p) => {
4395
4406
  const f = s.get(n);
4396
4407
  return Object.is(p[0], f) && p[1] === s && p[2] === n ? p : [f, s, n];
@@ -4405,7 +4416,7 @@ function ze(n, e) {
4405
4416
  try {
4406
4417
  const f = s.get(n);
4407
4418
  dt(f) && ut(
4408
- Yt(f, () => s.get(n))
4419
+ Jt(f, () => s.get(n))
4409
4420
  );
4410
4421
  } catch {
4411
4422
  }
@@ -4416,38 +4427,38 @@ function ze(n, e) {
4416
4427
  c();
4417
4428
  });
4418
4429
  return c(), p;
4419
- }, [s, n, t, i]), On(u), dt(u)) {
4420
- const p = Yt(u, () => s.get(n));
4421
- return i && ut(p), ys(p);
4430
+ }, [s, n, t, i]), Mn(u), dt(u)) {
4431
+ const p = Jt(u, () => s.get(n));
4432
+ return i && ut(p), bs(p);
4422
4433
  }
4423
4434
  return u;
4424
4435
  }
4425
4436
  function Ke(n, e) {
4426
- const t = In();
4427
- return Mn(
4437
+ const t = kn();
4438
+ return Pn(
4428
4439
  (...s) => {
4429
- if ((vs ? "production" : void 0) !== "production" && !("write" in n))
4440
+ if ((ms ? "production" : void 0) !== "production" && !("write" in n))
4430
4441
  throw new Error("not writable atom");
4431
4442
  return t.set(n, ...s);
4432
4443
  },
4433
4444
  [t, n]
4434
4445
  );
4435
4446
  }
4436
- const kn = Je([]);
4437
- function Rs() {
4438
- return ze(kn);
4447
+ const En = Je([]);
4448
+ function As() {
4449
+ return ze(En);
4439
4450
  }
4440
- function bs() {
4441
- return Ke(kn);
4451
+ function Ss() {
4452
+ return Ke(En);
4442
4453
  }
4443
4454
  const Xe = () => {
4444
- const n = Jt(An);
4455
+ const n = zt(xn);
4445
4456
  if (!n)
4446
4457
  throw new Error("useClient must be used within a TelnyxAIAgentProvider");
4447
4458
  return n;
4448
4459
  };
4449
- function Ss() {
4450
- const n = Xe(), e = bs();
4460
+ function _s() {
4461
+ const n = Xe(), e = Ss();
4451
4462
  return fe(() => {
4452
4463
  const t = (i) => e((s) => [...s, i]);
4453
4464
  return n.addListener("transcript.item", t), () => {
@@ -4455,15 +4466,15 @@ function Ss() {
4455
4466
  };
4456
4467
  }, [n, e]), null;
4457
4468
  }
4458
- const En = Je("connecting");
4459
- function As() {
4460
- return ze(En);
4461
- }
4462
- function _s() {
4463
- return Ke(En);
4469
+ const Tn = Je("connecting");
4470
+ function xs() {
4471
+ return ze(Tn);
4464
4472
  }
4465
4473
  function Cs() {
4466
- const n = Xe(), e = _s();
4474
+ return Ke(Tn);
4475
+ }
4476
+ function ws() {
4477
+ const n = Xe(), e = Cs();
4467
4478
  return fe(() => {
4468
4479
  const t = () => e("connected"), i = () => e("disconnected"), s = () => e("error");
4469
4480
  return n.addListener("agent.connected", t), n.addListener("agent.disconnected", i), n.addListener("agent.error", s), () => {
@@ -4471,15 +4482,15 @@ function Cs() {
4471
4482
  };
4472
4483
  }, [n, e]), null;
4473
4484
  }
4474
- const Tn = Je(null);
4475
- function xs() {
4476
- return ze(Tn);
4485
+ const Rn = Je(null);
4486
+ function Ls() {
4487
+ return ze(Rn);
4477
4488
  }
4478
- function ws() {
4479
- return Ke(Tn);
4489
+ function Is() {
4490
+ return Ke(Rn);
4480
4491
  }
4481
- const Is = () => {
4482
- const n = Xe(), e = ws();
4492
+ const ks = () => {
4493
+ const n = Xe(), e = Is();
4483
4494
  return fe(() => {
4484
4495
  const t = (i) => {
4485
4496
  e(i);
@@ -4488,15 +4499,15 @@ const Is = () => {
4488
4499
  n.removeListener("conversation.update", t);
4489
4500
  };
4490
4501
  }, [n, e]), null;
4491
- }, Rn = Je({ state: "listening" });
4492
- function Ls() {
4493
- return ze(Rn);
4494
- }
4495
- function ks() {
4496
- return Ke(Rn);
4502
+ }, An = Je({ state: "listening" });
4503
+ function Os() {
4504
+ return ze(An);
4497
4505
  }
4498
4506
  function Es() {
4499
- const n = Xe(), e = ks();
4507
+ return Ke(An);
4508
+ }
4509
+ function Ts() {
4510
+ const n = Xe(), e = Es();
4500
4511
  return fe(() => {
4501
4512
  const t = (i) => {
4502
4513
  e(i);
@@ -4506,7 +4517,7 @@ function Es() {
4506
4517
  };
4507
4518
  }, [n, e]), null;
4508
4519
  }
4509
- const An = zt(null), Os = ({
4520
+ const xn = Kt(null), Ms = ({
4510
4521
  children: n,
4511
4522
  agentId: e,
4512
4523
  environment: t,
@@ -4514,36 +4525,36 @@ const An = zt(null), Os = ({
4514
4525
  debug: s,
4515
4526
  vad: o
4516
4527
  }) => {
4517
- const [r, l] = Pn(() => new Vt({ agentId: e, environment: t, versionId: i, debug: s, vad: o }));
4528
+ const [r, l] = Dn(() => new Gt({ agentId: e, environment: t, versionId: i, debug: s, vad: o }));
4518
4529
  return fe(() => {
4519
4530
  if (!r) {
4520
- const c = new Vt({ agentId: e, environment: t, versionId: i, vad: o });
4531
+ const c = new Gt({ agentId: e, environment: t, versionId: i, vad: o });
4521
4532
  return l(c), () => {
4522
4533
  c.disconnect();
4523
4534
  };
4524
4535
  }
4525
4536
  }, [e, r, t, i, o]), fe(() => {
4526
4537
  r?.connect();
4527
- }, [r]), /* @__PURE__ */ Ce.jsxs(An.Provider, { value: r, children: [
4528
- /* @__PURE__ */ Ce.jsx(Ss, {}),
4529
- /* @__PURE__ */ Ce.jsx(Cs, {}),
4530
- /* @__PURE__ */ Ce.jsx(Is, {}),
4531
- /* @__PURE__ */ Ce.jsx(Es, {}),
4538
+ }, [r]), /* @__PURE__ */ Ce.jsxs(xn.Provider, { value: r, children: [
4539
+ /* @__PURE__ */ Ce.jsx(_s, {}),
4540
+ /* @__PURE__ */ Ce.jsx(ws, {}),
4541
+ /* @__PURE__ */ Ce.jsx(ks, {}),
4542
+ /* @__PURE__ */ Ce.jsx(Ts, {}),
4532
4543
  n
4533
4544
  ] });
4534
4545
  };
4535
4546
  export {
4536
- An as ClientContext,
4547
+ xn as ClientContext,
4537
4548
  x as SwEvent,
4538
- Vt as TelnyxAIAgent,
4539
- Os as TelnyxAIAgentProvider,
4540
- Ls as useAgentState,
4549
+ Gt as TelnyxAIAgent,
4550
+ Ms as TelnyxAIAgentProvider,
4551
+ Os as useAgentState,
4541
4552
  Xe as useClient,
4542
- As as useConnectionState,
4543
- xs as useConversation,
4544
- ks as useSetAgentState,
4545
- _s as useSetConnectionState,
4546
- ws as useSetConversation,
4547
- bs as useSetTranscript,
4548
- Rs as useTranscript
4553
+ xs as useConnectionState,
4554
+ Ls as useConversation,
4555
+ Es as useSetAgentState,
4556
+ Cs as useSetConnectionState,
4557
+ Is as useSetConversation,
4558
+ Ss as useSetTranscript,
4559
+ As as useTranscript
4549
4560
  };