@anam-ai/agent-widget 0.6.0 → 0.6.1

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
- var Ye, L, Ii, bi, ye, Jt, wi, Ri, Ai, Mt, It, bt, Ge = {}, Oi = [], Cn = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, lt = Array.isArray;
1
+ var Ye, M, Ii, bi, ye, Jt, wi, Ri, Ai, Mt, It, bt, Ge = {}, Oi = [], Cn = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, lt = Array.isArray;
2
2
  function le(t, e) {
3
3
  for (var i in e) t[i] = e[i];
4
4
  return t;
@@ -14,7 +14,7 @@ function xe(t, e, i) {
14
14
  }
15
15
  function We(t, e, i, n, a) {
16
16
  var s = { type: t, props: e, key: i, ref: n, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: a ?? ++Ii, __i: -1, __u: 0 };
17
- return a == null && L.vnode != null && L.vnode(s), s;
17
+ return a == null && M.vnode != null && M.vnode(s), s;
18
18
  }
19
19
  function Ce(t) {
20
20
  return t.children;
@@ -38,21 +38,21 @@ function xi(t) {
38
38
  }
39
39
  }
40
40
  function Xt(t) {
41
- (!t.__d && (t.__d = !0) && ye.push(t) && !rt.__r++ || Jt != L.debounceRendering) && ((Jt = L.debounceRendering) || wi)(rt);
41
+ (!t.__d && (t.__d = !0) && ye.push(t) && !rt.__r++ || Jt != M.debounceRendering) && ((Jt = M.debounceRendering) || wi)(rt);
42
42
  }
43
43
  function rt() {
44
- for (var t, e, i, n, a, s, c, l = 1; ye.length; ) ye.length > l && ye.sort(Ri), t = ye.shift(), l = ye.length, t.__d && (i = void 0, n = void 0, a = (n = (e = t).__v).__e, s = [], c = [], e.__P && ((i = le({}, n)).__v = n.__v + 1, L.vnode && L.vnode(i), Ut(e.__P, i, n, e.__n, e.__P.namespaceURI, 32 & n.__u ? [a] : null, s, a ?? Le(n), !!(32 & n.__u), c), i.__v = n.__v, i.__.__k[i.__i] = i, Li(s, i, c), n.__e = n.__ = null, i.__e != a && xi(i)));
44
+ for (var t, e, i, n, a, s, c, l = 1; ye.length; ) ye.length > l && ye.sort(Ri), t = ye.shift(), l = ye.length, t.__d && (i = void 0, n = void 0, a = (n = (e = t).__v).__e, s = [], c = [], e.__P && ((i = le({}, n)).__v = n.__v + 1, M.vnode && M.vnode(i), Ut(e.__P, i, n, e.__n, e.__P.namespaceURI, 32 & n.__u ? [a] : null, s, a ?? Le(n), !!(32 & n.__u), c), i.__v = n.__v, i.__.__k[i.__i] = i, Li(s, i, c), n.__e = n.__ = null, i.__e != a && xi(i)));
45
45
  rt.__r = 0;
46
46
  }
47
- function Ni(t, e, i, n, a, s, c, l, m, p, f) {
48
- var u, T, E, S, y, I, w, b = n && n.__k || Oi, O = e.length;
49
- for (m = Sn(i, e, b, m, O), u = 0; u < O; u++) (E = i.__k[u]) != null && (T = E.__i == -1 ? Ge : b[E.__i] || Ge, E.__i = u, I = Ut(t, E, T, a, s, c, l, m, p, f), S = E.__e, E.ref && T.ref != E.ref && (T.ref && Pt(T.ref, null, E), f.push(E.ref, E.__c || S, E)), y == null && S != null && (y = S), (w = !!(4 & E.__u)) || T.__k === E.__k ? m = ki(E, m, t, w) : typeof E.type == "function" && I !== void 0 ? m = I : S && (m = S.nextSibling), E.__u &= -7);
50
- return i.__e = y, m;
47
+ function Ni(t, e, i, n, a, s, c, l, m, f, p) {
48
+ var u, y, E, T, I, w, A, R = n && n.__k || Oi, b = e.length;
49
+ for (m = Sn(i, e, R, m, b), u = 0; u < b; u++) (E = i.__k[u]) != null && (y = E.__i == -1 ? Ge : R[E.__i] || Ge, E.__i = u, w = Ut(t, E, y, a, s, c, l, m, f, p), T = E.__e, E.ref && y.ref != E.ref && (y.ref && Pt(y.ref, null, E), p.push(E.ref, E.__c || T, E)), I == null && T != null && (I = T), (A = !!(4 & E.__u)) || y.__k === E.__k ? m = ki(E, m, t, A) : typeof E.type == "function" && w !== void 0 ? m = w : T && (m = T.nextSibling), E.__u &= -7);
50
+ return i.__e = I, m;
51
51
  }
52
52
  function Sn(t, e, i, n, a) {
53
- var s, c, l, m, p, f = i.length, u = f, T = 0;
54
- for (t.__k = new Array(a), s = 0; s < a; s++) (c = e[s]) != null && typeof c != "boolean" && typeof c != "function" ? (typeof c == "string" || typeof c == "number" || typeof c == "bigint" || c.constructor == String ? c = t.__k[s] = We(null, c, null, null, null) : lt(c) ? c = t.__k[s] = We(Ce, { children: c }, null, null, null) : c.constructor === void 0 && c.__b > 0 ? c = t.__k[s] = We(c.type, c.props, c.key, c.ref ? c.ref : null, c.__v) : t.__k[s] = c, m = s + T, c.__ = t, c.__b = t.__b + 1, l = null, (p = c.__i = Tn(c, i, m, u)) != -1 && (u--, (l = i[p]) && (l.__u |= 2)), l == null || l.__v == null ? (p == -1 && (a > f ? T-- : a < f && T++), typeof c.type != "function" && (c.__u |= 4)) : p != m && (p == m - 1 ? T-- : p == m + 1 ? T++ : (p > m ? T-- : T++, c.__u |= 4))) : t.__k[s] = null;
55
- if (u) for (s = 0; s < f; s++) (l = i[s]) != null && (2 & l.__u) == 0 && (l.__e == n && (n = Le(l)), Di(l, l));
53
+ var s, c, l, m, f, p = i.length, u = p, y = 0;
54
+ for (t.__k = new Array(a), s = 0; s < a; s++) (c = e[s]) != null && typeof c != "boolean" && typeof c != "function" ? (typeof c == "string" || typeof c == "number" || typeof c == "bigint" || c.constructor == String ? c = t.__k[s] = We(null, c, null, null, null) : lt(c) ? c = t.__k[s] = We(Ce, { children: c }, null, null, null) : c.constructor === void 0 && c.__b > 0 ? c = t.__k[s] = We(c.type, c.props, c.key, c.ref ? c.ref : null, c.__v) : t.__k[s] = c, m = s + y, c.__ = t, c.__b = t.__b + 1, l = null, (f = c.__i = Tn(c, i, m, u)) != -1 && (u--, (l = i[f]) && (l.__u |= 2)), l == null || l.__v == null ? (f == -1 && (a > p ? y-- : a < p && y++), typeof c.type != "function" && (c.__u |= 4)) : f != m && (f == m - 1 ? y-- : f == m + 1 ? y++ : (f > m ? y-- : y++, c.__u |= 4))) : t.__k[s] = null;
55
+ if (u) for (s = 0; s < p; s++) (l = i[s]) != null && (2 & l.__u) == 0 && (l.__e == n && (n = Le(l)), Di(l, l));
56
56
  return n;
57
57
  }
58
58
  function ki(t, e, i, n) {
@@ -68,10 +68,10 @@ function ki(t, e, i, n) {
68
68
  return e;
69
69
  }
70
70
  function Tn(t, e, i, n) {
71
- var a, s, c, l = t.key, m = t.type, p = e[i], f = p != null && (2 & p.__u) == 0;
72
- if (p === null && l == null || f && l == p.key && m == p.type) return i;
73
- if (n > (f ? 1 : 0)) {
74
- for (a = i - 1, s = i + 1; a >= 0 || s < e.length; ) if ((p = e[c = a >= 0 ? a-- : s++]) != null && (2 & p.__u) == 0 && l == p.key && m == p.type) return c;
71
+ var a, s, c, l = t.key, m = t.type, f = e[i], p = f != null && (2 & f.__u) == 0;
72
+ if (f === null && l == null || p && l == f.key && m == f.type) return i;
73
+ if (n > (p ? 1 : 0)) {
74
+ for (a = i - 1, s = i + 1; a >= 0 || s < e.length; ) if ((f = e[c = a >= 0 ? a-- : s++]) != null && (2 & f.__u) == 0 && l == f.key && m == f.type) return c;
75
75
  }
76
76
  return -1;
77
77
  }
@@ -102,61 +102,61 @@ function Qt(t) {
102
102
  var i = this.l[e.type + t];
103
103
  if (e.t == null) e.t = Mt++;
104
104
  else if (e.t < i.u) return;
105
- return i(L.event ? L.event(e) : e);
105
+ return i(M.event ? M.event(e) : e);
106
106
  }
107
107
  };
108
108
  }
109
- function Ut(t, e, i, n, a, s, c, l, m, p) {
110
- var f, u, T, E, S, y, I, w, b, O, N, R, Z, G, re, te, oe, z = e.type;
109
+ function Ut(t, e, i, n, a, s, c, l, m, f) {
110
+ var p, u, y, E, T, I, w, A, R, b, N, S, k, U, z, Y, oe, K = e.type;
111
111
  if (e.constructor !== void 0) return null;
112
- 128 & i.__u && (m = !!(32 & i.__u), s = [l = e.__e = i.__e]), (f = L.__b) && f(e);
113
- e: if (typeof z == "function") try {
114
- if (w = e.props, b = "prototype" in z && z.prototype.render, O = (f = z.contextType) && n[f.__c], N = f ? O ? O.props.value : f.__ : n, i.__c ? I = (u = e.__c = i.__c).__ = u.__E : (b ? e.__c = u = new z(w, N) : (e.__c = u = new Ne(w, N), u.constructor = z, u.render = In), O && O.sub(u), u.state || (u.state = {}), u.__n = n, T = u.__d = !0, u.__h = [], u._sb = []), b && u.__s == null && (u.__s = u.state), b && z.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = le({}, u.__s)), le(u.__s, z.getDerivedStateFromProps(w, u.__s))), E = u.props, S = u.state, u.__v = e, T) b && z.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), b && u.componentDidMount != null && u.__h.push(u.componentDidMount);
112
+ 128 & i.__u && (m = !!(32 & i.__u), s = [l = e.__e = i.__e]), (p = M.__b) && p(e);
113
+ e: if (typeof K == "function") try {
114
+ if (A = e.props, R = "prototype" in K && K.prototype.render, b = (p = K.contextType) && n[p.__c], N = p ? b ? b.props.value : p.__ : n, i.__c ? w = (u = e.__c = i.__c).__ = u.__E : (R ? e.__c = u = new K(A, N) : (e.__c = u = new Ne(A, N), u.constructor = K, u.render = In), b && b.sub(u), u.state || (u.state = {}), u.__n = n, y = u.__d = !0, u.__h = [], u._sb = []), R && u.__s == null && (u.__s = u.state), R && K.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = le({}, u.__s)), le(u.__s, K.getDerivedStateFromProps(A, u.__s))), E = u.props, T = u.state, u.__v = e, y) R && K.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), R && u.componentDidMount != null && u.__h.push(u.componentDidMount);
115
115
  else {
116
- if (b && z.getDerivedStateFromProps == null && w !== E && u.componentWillReceiveProps != null && u.componentWillReceiveProps(w, N), e.__v == i.__v || !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(w, u.__s, N) === !1) {
117
- for (e.__v != i.__v && (u.props = w, u.state = u.__s, u.__d = !1), e.__e = i.__e, e.__k = i.__k, e.__k.some(function(Q) {
118
- Q && (Q.__ = e);
119
- }), R = 0; R < u._sb.length; R++) u.__h.push(u._sb[R]);
116
+ if (R && K.getDerivedStateFromProps == null && A !== E && u.componentWillReceiveProps != null && u.componentWillReceiveProps(A, N), e.__v == i.__v || !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(A, u.__s, N) === !1) {
117
+ for (e.__v != i.__v && (u.props = A, u.state = u.__s, u.__d = !1), e.__e = i.__e, e.__k = i.__k, e.__k.some(function(te) {
118
+ te && (te.__ = e);
119
+ }), S = 0; S < u._sb.length; S++) u.__h.push(u._sb[S]);
120
120
  u._sb = [], u.__h.length && c.push(u);
121
121
  break e;
122
122
  }
123
- u.componentWillUpdate != null && u.componentWillUpdate(w, u.__s, N), b && u.componentDidUpdate != null && u.__h.push(function() {
124
- u.componentDidUpdate(E, S, y);
123
+ u.componentWillUpdate != null && u.componentWillUpdate(A, u.__s, N), R && u.componentDidUpdate != null && u.__h.push(function() {
124
+ u.componentDidUpdate(E, T, I);
125
125
  });
126
126
  }
127
- if (u.context = N, u.props = w, u.__P = t, u.__e = !1, Z = L.__r, G = 0, b) {
128
- for (u.state = u.__s, u.__d = !1, Z && Z(e), f = u.render(u.props, u.state, u.context), re = 0; re < u._sb.length; re++) u.__h.push(u._sb[re]);
127
+ if (u.context = N, u.props = A, u.__P = t, u.__e = !1, k = M.__r, U = 0, R) {
128
+ for (u.state = u.__s, u.__d = !1, k && k(e), p = u.render(u.props, u.state, u.context), z = 0; z < u._sb.length; z++) u.__h.push(u._sb[z]);
129
129
  u._sb = [];
130
130
  } else do
131
- u.__d = !1, Z && Z(e), f = u.render(u.props, u.state, u.context), u.state = u.__s;
132
- while (u.__d && ++G < 25);
133
- u.state = u.__s, u.getChildContext != null && (n = le(le({}, n), u.getChildContext())), b && !T && u.getSnapshotBeforeUpdate != null && (y = u.getSnapshotBeforeUpdate(E, S)), te = f, f != null && f.type === Ce && f.key == null && (te = Mi(f.props.children)), l = Ni(t, lt(te) ? te : [te], e, i, n, a, s, c, l, m, p), u.base = e.__e, e.__u &= -161, u.__h.length && c.push(u), I && (u.__E = u.__ = null);
134
- } catch (Q) {
135
- if (e.__v = null, m || s != null) if (Q.then) {
131
+ u.__d = !1, k && k(e), p = u.render(u.props, u.state, u.context), u.state = u.__s;
132
+ while (u.__d && ++U < 25);
133
+ u.state = u.__s, u.getChildContext != null && (n = le(le({}, n), u.getChildContext())), R && !y && u.getSnapshotBeforeUpdate != null && (I = u.getSnapshotBeforeUpdate(E, T)), Y = p, p != null && p.type === Ce && p.key == null && (Y = Mi(p.props.children)), l = Ni(t, lt(Y) ? Y : [Y], e, i, n, a, s, c, l, m, f), u.base = e.__e, e.__u &= -161, u.__h.length && c.push(u), w && (u.__E = u.__ = null);
134
+ } catch (te) {
135
+ if (e.__v = null, m || s != null) if (te.then) {
136
136
  for (e.__u |= m ? 160 : 128; l && l.nodeType == 8 && l.nextSibling; ) l = l.nextSibling;
137
137
  s[s.indexOf(l)] = null, e.__e = l;
138
138
  } else {
139
139
  for (oe = s.length; oe--; ) Dt(s[oe]);
140
140
  wt(e);
141
141
  }
142
- else e.__e = i.__e, e.__k = i.__k, Q.then || wt(e);
143
- L.__e(Q, e, i);
142
+ else e.__e = i.__e, e.__k = i.__k, te.then || wt(e);
143
+ M.__e(te, e, i);
144
144
  }
145
- else s == null && e.__v == i.__v ? (e.__k = i.__k, e.__e = i.__e) : l = e.__e = yn(i.__e, e, i, n, a, s, c, m, p);
146
- return (f = L.diffed) && f(e), 128 & e.__u ? void 0 : l;
145
+ else s == null && e.__v == i.__v ? (e.__k = i.__k, e.__e = i.__e) : l = e.__e = yn(i.__e, e, i, n, a, s, c, m, f);
146
+ return (p = M.diffed) && p(e), 128 & e.__u ? void 0 : l;
147
147
  }
148
148
  function wt(t) {
149
149
  t && t.__c && (t.__c.__e = !0), t && t.__k && t.__k.forEach(wt);
150
150
  }
151
151
  function Li(t, e, i) {
152
152
  for (var n = 0; n < i.length; n++) Pt(i[n], i[++n], i[++n]);
153
- L.__c && L.__c(e, t), t.some(function(a) {
153
+ M.__c && M.__c(e, t), t.some(function(a) {
154
154
  try {
155
155
  t = a.__h, a.__h = [], t.some(function(s) {
156
156
  s.call(a);
157
157
  });
158
158
  } catch (s) {
159
- L.__e(s, a.__v);
159
+ M.__e(s, a.__v);
160
160
  }
161
161
  });
162
162
  }
@@ -164,31 +164,31 @@ function Mi(t) {
164
164
  return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : lt(t) ? t.map(Mi) : le({}, t);
165
165
  }
166
166
  function yn(t, e, i, n, a, s, c, l, m) {
167
- var p, f, u, T, E, S, y, I = i.props || Ge, w = e.props, b = e.type;
168
- if (b == "svg" ? a = "http://www.w3.org/2000/svg" : b == "math" ? a = "http://www.w3.org/1998/Math/MathML" : a || (a = "http://www.w3.org/1999/xhtml"), s != null) {
169
- for (p = 0; p < s.length; p++) if ((E = s[p]) && "setAttribute" in E == !!b && (b ? E.localName == b : E.nodeType == 3)) {
170
- t = E, s[p] = null;
167
+ var f, p, u, y, E, T, I, w = i.props || Ge, A = e.props, R = e.type;
168
+ if (R == "svg" ? a = "http://www.w3.org/2000/svg" : R == "math" ? a = "http://www.w3.org/1998/Math/MathML" : a || (a = "http://www.w3.org/1999/xhtml"), s != null) {
169
+ for (f = 0; f < s.length; f++) if ((E = s[f]) && "setAttribute" in E == !!R && (R ? E.localName == R : E.nodeType == 3)) {
170
+ t = E, s[f] = null;
171
171
  break;
172
172
  }
173
173
  }
174
174
  if (t == null) {
175
- if (b == null) return document.createTextNode(w);
176
- t = document.createElementNS(a, b, w.is && w), l && (L.__m && L.__m(e, s), l = !1), s = null;
175
+ if (R == null) return document.createTextNode(A);
176
+ t = document.createElementNS(a, R, A.is && A), l && (M.__m && M.__m(e, s), l = !1), s = null;
177
177
  }
178
- if (b == null) I === w || l && t.data == w || (t.data = w);
178
+ if (R == null) w === A || l && t.data == A || (t.data = A);
179
179
  else {
180
- if (s = s && Ye.call(t.childNodes), !l && s != null) for (I = {}, p = 0; p < t.attributes.length; p++) I[(E = t.attributes[p]).name] = E.value;
181
- for (p in I) if (E = I[p], p != "children") {
182
- if (p == "dangerouslySetInnerHTML") u = E;
183
- else if (!(p in w)) {
184
- if (p == "value" && "defaultValue" in w || p == "checked" && "defaultChecked" in w) continue;
185
- Ze(t, p, null, E, a);
180
+ if (s = s && Ye.call(t.childNodes), !l && s != null) for (w = {}, f = 0; f < t.attributes.length; f++) w[(E = t.attributes[f]).name] = E.value;
181
+ for (f in w) if (E = w[f], f != "children") {
182
+ if (f == "dangerouslySetInnerHTML") u = E;
183
+ else if (!(f in A)) {
184
+ if (f == "value" && "defaultValue" in A || f == "checked" && "defaultChecked" in A) continue;
185
+ Ze(t, f, null, E, a);
186
186
  }
187
187
  }
188
- for (p in w) E = w[p], p == "children" ? T = E : p == "dangerouslySetInnerHTML" ? f = E : p == "value" ? S = E : p == "checked" ? y = E : l && typeof E != "function" || I[p] === E || Ze(t, p, E, I[p], a);
189
- if (f) l || u && (f.__html == u.__html || f.__html == t.innerHTML) || (t.innerHTML = f.__html), e.__k = [];
190
- else if (u && (t.innerHTML = ""), Ni(e.type == "template" ? t.content : t, lt(T) ? T : [T], e, i, n, b == "foreignObject" ? "http://www.w3.org/1999/xhtml" : a, s, c, s ? s[0] : i.__k && Le(i, 0), l, m), s != null) for (p = s.length; p--; ) Dt(s[p]);
191
- l || (p = "value", b == "progress" && S == null ? t.removeAttribute("value") : S != null && (S !== t[p] || b == "progress" && !S || b == "option" && S != I[p]) && Ze(t, p, S, I[p], a), p = "checked", y != null && y != t[p] && Ze(t, p, y, I[p], a));
188
+ for (f in A) E = A[f], f == "children" ? y = E : f == "dangerouslySetInnerHTML" ? p = E : f == "value" ? T = E : f == "checked" ? I = E : l && typeof E != "function" || w[f] === E || Ze(t, f, E, w[f], a);
189
+ if (p) l || u && (p.__html == u.__html || p.__html == t.innerHTML) || (t.innerHTML = p.__html), e.__k = [];
190
+ else if (u && (t.innerHTML = ""), Ni(e.type == "template" ? t.content : t, lt(y) ? y : [y], e, i, n, R == "foreignObject" ? "http://www.w3.org/1999/xhtml" : a, s, c, s ? s[0] : i.__k && Le(i, 0), l, m), s != null) for (f = s.length; f--; ) Dt(s[f]);
191
+ l || (f = "value", R == "progress" && T == null ? t.removeAttribute("value") : T != null && (T !== t[f] || R == "progress" && !T || R == "option" && T != w[f]) && Ze(t, f, T, w[f], a), f = "checked", I != null && I != t[f] && Ze(t, f, I, w[f], a));
192
192
  }
193
193
  return t;
194
194
  }
@@ -199,16 +199,16 @@ function Pt(t, e, i) {
199
199
  n && t.__u(), n && e == null || (t.__u = t(e));
200
200
  } else t.current = e;
201
201
  } catch (a) {
202
- L.__e(a, i);
202
+ M.__e(a, i);
203
203
  }
204
204
  }
205
205
  function Di(t, e, i) {
206
206
  var n, a;
207
- if (L.unmount && L.unmount(t), (n = t.ref) && (n.current && n.current != t.__e || Pt(n, null, e)), (n = t.__c) != null) {
207
+ if (M.unmount && M.unmount(t), (n = t.ref) && (n.current && n.current != t.__e || Pt(n, null, e)), (n = t.__c) != null) {
208
208
  if (n.componentWillUnmount) try {
209
209
  n.componentWillUnmount();
210
210
  } catch (s) {
211
- L.__e(s, e);
211
+ M.__e(s, e);
212
212
  }
213
213
  n.base = n.__P = null;
214
214
  }
@@ -220,7 +220,7 @@ function In(t, e, i) {
220
220
  }
221
221
  function ct(t, e, i) {
222
222
  var n, a, s, c;
223
- e == document && (e = document.documentElement), L.__ && L.__(t, e), a = (n = typeof i == "function") ? null : i && i.__k || e.__k, s = [], c = [], Ut(e, t = (!n && i || e).__k = xe(Ce, null, [t]), a || Ge, Ge, e.namespaceURI, !n && i ? [i] : a ? null : e.firstChild ? Ye.call(e.childNodes) : null, s, !n && i ? i : a ? a.__e : e.firstChild, n, c), Li(s, t, c);
223
+ e == document && (e = document.documentElement), M.__ && M.__(t, e), a = (n = typeof i == "function") ? null : i && i.__k || e.__k, s = [], c = [], Ut(e, t = (!n && i || e).__k = xe(Ce, null, [t]), a || Ge, Ge, e.namespaceURI, !n && i ? [i] : a ? null : e.firstChild ? Ye.call(e.childNodes) : null, s, !n && i ? i : a ? a.__e : e.firstChild, n, c), Li(s, t, c);
224
224
  }
225
225
  function Ui(t, e) {
226
226
  ct(t, e, Ui);
@@ -230,7 +230,7 @@ function Pi(t, e, i) {
230
230
  for (s in t.type && t.type.defaultProps && (c = t.type.defaultProps), e) s == "key" ? n = e[s] : s == "ref" ? a = e[s] : l[s] = e[s] === void 0 && c != null ? c[s] : e[s];
231
231
  return arguments.length > 2 && (l.children = arguments.length > 3 ? Ye.call(arguments, 2) : i), We(t.type, l, n || t.key, a || t.ref, null);
232
232
  }
233
- Ye = Oi.slice, L = { __e: function(t, e, i, n) {
233
+ Ye = Oi.slice, M = { __e: function(t, e, i, n) {
234
234
  for (var a, s, c; e = e.__; ) if ((a = e.__c) && !a.__) try {
235
235
  if ((s = a.constructor) && s.getDerivedStateFromError != null && (a.setState(s.getDerivedStateFromError(t)), c = a.__d), a.componentDidCatch != null && (a.componentDidCatch(t, n || {}), c = a.__d), c) return a.__E = a;
236
236
  } catch (l) {
@@ -319,25 +319,25 @@ function $i(t, e, i) {
319
319
  var n = [], a = {}, s = 0, c = t.attributes, l = t.childNodes;
320
320
  for (s = c.length; s--; ) c[s].name !== "slot" && (a[c[s].name] = c[s].value, a[Fi(c[s].name)] = c[s].value);
321
321
  for (s = l.length; s--; ) {
322
- var m = $i(l[s], null, i), p = l[s].slot;
323
- p ? a[p] = xe(ei, { name: p }, m) : n[s] = m;
322
+ var m = $i(l[s], null, i), f = l[s].slot;
323
+ f ? a[f] = xe(ei, { name: f }, m) : n[s] = m;
324
324
  }
325
- var f = !(!i || !i.shadow), u = e ? xe(ei, { useFragment: !f }, n) : n;
326
- return !f && e && (t.innerHTML = ""), xe(e || t.nodeName.toLowerCase(), a, u);
325
+ var p = !(!i || !i.shadow), u = e ? xe(ei, { useFragment: !p }, n) : n;
326
+ return !p && e && (t.innerHTML = ""), xe(e || t.nodeName.toLowerCase(), a, u);
327
327
  }
328
328
  var kn = 0;
329
329
  function C(t, e, i, n, a, s) {
330
330
  e || (e = {});
331
331
  var c, l, m = e;
332
332
  if ("ref" in m) for (l in m = {}, e) l == "ref" ? c = e[l] : m[l] = e[l];
333
- var p = { type: t, props: m, key: i, ref: c, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --kn, __i: -1, __u: 0, __source: a, __self: s };
333
+ var f = { type: t, props: m, key: i, ref: c, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --kn, __i: -1, __u: 0, __source: a, __self: s };
334
334
  if (typeof t == "function" && (c = t.defaultProps)) for (l in c) m[l] === void 0 && (m[l] = c[l]);
335
- return L.vnode && L.vnode(p), p;
335
+ return M.vnode && M.vnode(f), f;
336
336
  }
337
- var He, $, _t, ti, ze = 0, Vi = [], V = L, ii = V.__b, ni = V.__r, ri = V.diffed, oi = V.__c, si = V.unmount, ai = V.__;
337
+ var He, W, _t, ti, ze = 0, Vi = [], j = M, ii = j.__b, ni = j.__r, ri = j.diffed, oi = j.__c, si = j.unmount, ai = j.__;
338
338
  function Bt(t, e) {
339
- V.__h && V.__h($, t, ze || e), ze = 0;
340
- var i = $.__H || ($.__H = { __: [], __h: [] });
339
+ j.__h && j.__h(W, t, ze || e), ze = 0;
340
+ var i = W.__H || (W.__H = { __: [], __h: [] });
341
341
  return t >= i.__.length && i.__.push({}), i.__[t];
342
342
  }
343
343
  function Rt(t) {
@@ -346,40 +346,40 @@ function Rt(t) {
346
346
  function Ln(t, e, i) {
347
347
  var n = Bt(He++, 2);
348
348
  if (n.t = t, !n.__c && (n.__ = [ji(void 0, e), function(l) {
349
- var m = n.__N ? n.__N[0] : n.__[0], p = n.t(m, l);
350
- m !== p && (n.__N = [p, n.__[1]], n.__c.setState({}));
351
- }], n.__c = $, !$.__f)) {
352
- var a = function(l, m, p) {
349
+ var m = n.__N ? n.__N[0] : n.__[0], f = n.t(m, l);
350
+ m !== f && (n.__N = [f, n.__[1]], n.__c.setState({}));
351
+ }], n.__c = W, !W.__f)) {
352
+ var a = function(l, m, f) {
353
353
  if (!n.__c.__H) return !0;
354
- var f = n.__c.__H.__.filter(function(T) {
355
- return !!T.__c;
354
+ var p = n.__c.__H.__.filter(function(y) {
355
+ return !!y.__c;
356
356
  });
357
- if (f.every(function(T) {
358
- return !T.__N;
359
- })) return !s || s.call(this, l, m, p);
357
+ if (p.every(function(y) {
358
+ return !y.__N;
359
+ })) return !s || s.call(this, l, m, f);
360
360
  var u = n.__c.props !== l;
361
- return f.forEach(function(T) {
362
- if (T.__N) {
363
- var E = T.__[0];
364
- T.__ = T.__N, T.__N = void 0, E !== T.__[0] && (u = !0);
361
+ return p.forEach(function(y) {
362
+ if (y.__N) {
363
+ var E = y.__[0];
364
+ y.__ = y.__N, y.__N = void 0, E !== y.__[0] && (u = !0);
365
365
  }
366
- }), s && s.call(this, l, m, p) || u;
366
+ }), s && s.call(this, l, m, f) || u;
367
367
  };
368
- $.__f = !0;
369
- var s = $.shouldComponentUpdate, c = $.componentWillUpdate;
370
- $.componentWillUpdate = function(l, m, p) {
368
+ W.__f = !0;
369
+ var s = W.shouldComponentUpdate, c = W.componentWillUpdate;
370
+ W.componentWillUpdate = function(l, m, f) {
371
371
  if (this.__e) {
372
- var f = s;
373
- s = void 0, a(l, m, p), s = f;
372
+ var p = s;
373
+ s = void 0, a(l, m, f), s = p;
374
374
  }
375
- c && c.call(this, l, m, p);
376
- }, $.shouldComponentUpdate = a;
375
+ c && c.call(this, l, m, f);
376
+ }, W.shouldComponentUpdate = a;
377
377
  }
378
378
  return n.__N || n.__;
379
379
  }
380
380
  function Ie(t, e) {
381
381
  var i = Bt(He++, 3);
382
- !V.__s && Wi(i.__H, e) && (i.__ = t, i.u = e, $.__H.__h.push(i));
382
+ !j.__s && Wi(i.__H, e) && (i.__ = t, i.u = e, W.__H.__h.push(i));
383
383
  }
384
384
  function qe(t) {
385
385
  return ze = 5, ke(function() {
@@ -399,26 +399,26 @@ function Mn() {
399
399
  for (var t; t = Vi.shift(); ) if (t.__P && t.__H) try {
400
400
  t.__H.__h.forEach(it), t.__H.__h.forEach(At), t.__H.__h = [];
401
401
  } catch (e) {
402
- t.__H.__h = [], V.__e(e, t.__v);
402
+ t.__H.__h = [], j.__e(e, t.__v);
403
403
  }
404
404
  }
405
- V.__b = function(t) {
406
- $ = null, ii && ii(t);
407
- }, V.__ = function(t, e) {
405
+ j.__b = function(t) {
406
+ W = null, ii && ii(t);
407
+ }, j.__ = function(t, e) {
408
408
  t && e.__k && e.__k.__m && (t.__m = e.__k.__m), ai && ai(t, e);
409
- }, V.__r = function(t) {
409
+ }, j.__r = function(t) {
410
410
  ni && ni(t), He = 0;
411
- var e = ($ = t.__c).__H;
412
- e && (_t === $ ? (e.__h = [], $.__h = [], e.__.forEach(function(i) {
411
+ var e = (W = t.__c).__H;
412
+ e && (_t === W ? (e.__h = [], W.__h = [], e.__.forEach(function(i) {
413
413
  i.__N && (i.__ = i.__N), i.u = i.__N = void 0;
414
- })) : (e.__h.forEach(it), e.__h.forEach(At), e.__h = [], He = 0)), _t = $;
415
- }, V.diffed = function(t) {
414
+ })) : (e.__h.forEach(it), e.__h.forEach(At), e.__h = [], He = 0)), _t = W;
415
+ }, j.diffed = function(t) {
416
416
  ri && ri(t);
417
417
  var e = t.__c;
418
- e && e.__H && (e.__H.__h.length && (Vi.push(e) !== 1 && ti === V.requestAnimationFrame || ((ti = V.requestAnimationFrame) || Dn)(Mn)), e.__H.__.forEach(function(i) {
418
+ e && e.__H && (e.__H.__h.length && (Vi.push(e) !== 1 && ti === j.requestAnimationFrame || ((ti = j.requestAnimationFrame) || Dn)(Mn)), e.__H.__.forEach(function(i) {
419
419
  i.u && (i.__H = i.u), i.u = void 0;
420
- })), _t = $ = null;
421
- }, V.__c = function(t, e) {
420
+ })), _t = W = null;
421
+ }, j.__c = function(t, e) {
422
422
  e.some(function(i) {
423
423
  try {
424
424
  i.__h.forEach(it), i.__h = i.__h.filter(function(n) {
@@ -427,10 +427,10 @@ V.__b = function(t) {
427
427
  } catch (n) {
428
428
  e.some(function(a) {
429
429
  a.__h && (a.__h = []);
430
- }), e = [], V.__e(n, i.__v);
430
+ }), e = [], j.__e(n, i.__v);
431
431
  }
432
432
  }), oi && oi(t, e);
433
- }, V.unmount = function(t) {
433
+ }, j.unmount = function(t) {
434
434
  si && si(t);
435
435
  var e, i = t.__c;
436
436
  i && i.__H && (i.__H.__.forEach(function(n) {
@@ -439,7 +439,7 @@ V.__b = function(t) {
439
439
  } catch (a) {
440
440
  e = a;
441
441
  }
442
- }), i.__H = void 0, e && V.__e(e, i.__v));
442
+ }), i.__H = void 0, e && j.__e(e, i.__v));
443
443
  };
444
444
  var li = typeof requestAnimationFrame == "function";
445
445
  function Dn(t) {
@@ -449,12 +449,12 @@ function Dn(t) {
449
449
  li && (e = requestAnimationFrame(i));
450
450
  }
451
451
  function it(t) {
452
- var e = $, i = t.__c;
453
- typeof i == "function" && (t.__c = void 0, i()), $ = e;
452
+ var e = W, i = t.__c;
453
+ typeof i == "function" && (t.__c = void 0, i()), W = e;
454
454
  }
455
455
  function At(t) {
456
- var e = $;
457
- t.__c = t.__(), $ = e;
456
+ var e = W;
457
+ t.__c = t.__(), W = e;
458
458
  }
459
459
  function Wi(t, e) {
460
460
  return !t || t.length !== e.length || e.some(function(i, n) {
@@ -493,41 +493,41 @@ function Pn(t) {
493
493
  dt();
494
494
  }
495
495
  }
496
- var k = void 0;
496
+ var L = void 0;
497
497
  function Gi(t) {
498
- var e = k;
499
- k = void 0;
498
+ var e = L;
499
+ L = void 0;
500
500
  try {
501
501
  return t();
502
502
  } finally {
503
- k = e;
503
+ L = e;
504
504
  }
505
505
  }
506
506
  var je = void 0, ge = 0, Ot = 0, st = 0;
507
507
  function Hi(t) {
508
- if (k !== void 0) {
508
+ if (L !== void 0) {
509
509
  var e = t.n;
510
- if (e === void 0 || e.t !== k)
511
- return e = { i: 0, S: t, p: k.s, n: void 0, t: k, e: void 0, x: void 0, r: e }, k.s !== void 0 && (k.s.n = e), k.s = e, t.n = e, 32 & k.f && t.S(e), e;
510
+ if (e === void 0 || e.t !== L)
511
+ return e = { i: 0, S: t, p: L.s, n: void 0, t: L, e: void 0, x: void 0, r: e }, L.s !== void 0 && (L.s.n = e), L.s = e, t.n = e, 32 & L.f && t.S(e), e;
512
512
  if (e.i === -1)
513
- return e.i = 0, e.n !== void 0 && (e.n.p = e.p, e.p !== void 0 && (e.p.n = e.n), e.p = k.s, e.n = void 0, k.s.n = e, k.s = e), e;
513
+ return e.i = 0, e.n !== void 0 && (e.n.p = e.p, e.p !== void 0 && (e.p.n = e.n), e.p = L.s, e.n = void 0, L.s.n = e, L.s = e), e;
514
514
  }
515
515
  }
516
- function Y(t, e) {
516
+ function X(t, e) {
517
517
  this.v = t, this.i = 0, this.n = void 0, this.t = void 0, this.W = e?.watched, this.Z = e?.unwatched, this.name = e?.name;
518
518
  }
519
- Y.prototype.brand = Un;
520
- Y.prototype.h = function() {
519
+ X.prototype.brand = Un;
520
+ X.prototype.h = function() {
521
521
  return !0;
522
522
  };
523
- Y.prototype.S = function(t) {
523
+ X.prototype.S = function(t) {
524
524
  var e = this, i = this.t;
525
525
  i !== t && t.e === void 0 && (t.x = i, this.t = t, i !== void 0 ? i.e = t : Gi(function() {
526
526
  var n;
527
527
  (n = e.W) == null || n.call(e);
528
528
  }));
529
529
  };
530
- Y.prototype.U = function(t) {
530
+ X.prototype.U = function(t) {
531
531
  var e = this;
532
532
  if (this.t !== void 0) {
533
533
  var i = t.e, n = t.x;
@@ -537,37 +537,37 @@ Y.prototype.U = function(t) {
537
537
  }));
538
538
  }
539
539
  };
540
- Y.prototype.subscribe = function(t) {
540
+ X.prototype.subscribe = function(t) {
541
541
  var e = this;
542
542
  return Ke(function() {
543
- var i = e.value, n = k;
544
- k = void 0;
543
+ var i = e.value, n = L;
544
+ L = void 0;
545
545
  try {
546
546
  t(i);
547
547
  } finally {
548
- k = n;
548
+ L = n;
549
549
  }
550
550
  }, { name: "sub" });
551
551
  };
552
- Y.prototype.valueOf = function() {
552
+ X.prototype.valueOf = function() {
553
553
  return this.value;
554
554
  };
555
- Y.prototype.toString = function() {
555
+ X.prototype.toString = function() {
556
556
  return this.value + "";
557
557
  };
558
- Y.prototype.toJSON = function() {
558
+ X.prototype.toJSON = function() {
559
559
  return this.value;
560
560
  };
561
- Y.prototype.peek = function() {
562
- var t = k;
563
- k = void 0;
561
+ X.prototype.peek = function() {
562
+ var t = L;
563
+ L = void 0;
564
564
  try {
565
565
  return this.value;
566
566
  } finally {
567
- k = t;
567
+ L = t;
568
568
  }
569
569
  };
570
- Object.defineProperty(Y.prototype, "value", { get: function() {
570
+ Object.defineProperty(X.prototype, "value", { get: function() {
571
571
  var t = Hi(this);
572
572
  return t !== void 0 && (t.i = this.i), this.v;
573
573
  }, set: function(t) {
@@ -581,8 +581,8 @@ Object.defineProperty(Y.prototype, "value", { get: function() {
581
581
  }
582
582
  }
583
583
  } });
584
- function H(t, e) {
585
- return new Y(t, e);
584
+ function q(t, e) {
585
+ return new X(t, e);
586
586
  }
587
587
  function zi(t) {
588
588
  for (var e = t.s; e !== void 0; e = e.n) if (e.S.i !== e.i || !e.S.h() || e.S.i !== e.i) return !0;
@@ -605,33 +605,33 @@ function Yi(t) {
605
605
  t.s = i;
606
606
  }
607
607
  function be(t, e) {
608
- Y.call(this, void 0), this.x = t, this.s = void 0, this.g = st - 1, this.f = 4, this.W = e?.watched, this.Z = e?.unwatched, this.name = e?.name;
608
+ X.call(this, void 0), this.x = t, this.s = void 0, this.g = st - 1, this.f = 4, this.W = e?.watched, this.Z = e?.unwatched, this.name = e?.name;
609
609
  }
610
- be.prototype = new Y();
610
+ be.prototype = new X();
611
611
  be.prototype.h = function() {
612
612
  if (this.f &= -3, 1 & this.f) return !1;
613
613
  if ((36 & this.f) == 32 || (this.f &= -5, this.g === st)) return !0;
614
614
  if (this.g = st, this.f |= 1, this.i > 0 && !zi(this))
615
615
  return this.f &= -2, !0;
616
- var t = k;
616
+ var t = L;
617
617
  try {
618
- qi(this), k = this;
618
+ qi(this), L = this;
619
619
  var e = this.x();
620
620
  (16 & this.f || this.v !== e || this.i === 0) && (this.v = e, this.f &= -17, this.i++);
621
621
  } catch (i) {
622
622
  this.v = i, this.f |= 16, this.i++;
623
623
  }
624
- return k = t, Yi(this), this.f &= -2, !0;
624
+ return L = t, Yi(this), this.f &= -2, !0;
625
625
  };
626
626
  be.prototype.S = function(t) {
627
627
  if (this.t === void 0) {
628
628
  this.f |= 36;
629
629
  for (var e = this.s; e !== void 0; e = e.n) e.S.S(e);
630
630
  }
631
- Y.prototype.S.call(this, t);
631
+ X.prototype.S.call(this, t);
632
632
  };
633
633
  be.prototype.U = function(t) {
634
- if (this.t !== void 0 && (Y.prototype.U.call(this, t), this.t === void 0)) {
634
+ if (this.t !== void 0 && (X.prototype.U.call(this, t), this.t === void 0)) {
635
635
  this.f &= -33;
636
636
  for (var e = this.s; e !== void 0; e = e.n) e.S.U(e);
637
637
  }
@@ -655,14 +655,14 @@ function Ki(t) {
655
655
  var e = t.u;
656
656
  if (t.u = void 0, typeof e == "function") {
657
657
  ge++;
658
- var i = k;
659
- k = void 0;
658
+ var i = L;
659
+ L = void 0;
660
660
  try {
661
661
  e();
662
662
  } catch (n) {
663
663
  throw t.f &= -2, t.f |= 8, Ft(t), n;
664
664
  } finally {
665
- k = i, dt();
665
+ L = i, dt();
666
666
  }
667
667
  }
668
668
  }
@@ -671,8 +671,8 @@ function Ft(t) {
671
671
  t.x = void 0, t.s = void 0, Ki(t);
672
672
  }
673
673
  function Bn(t) {
674
- if (k !== this) throw new Error("Out-of-order effect");
675
- Yi(this), k = t, this.f &= -2, 8 & this.f && Ft(this), dt();
674
+ if (L !== this) throw new Error("Out-of-order effect");
675
+ Yi(this), L = t, this.f &= -2, 8 & this.f && Ft(this), dt();
676
676
  }
677
677
  function De(t, e) {
678
678
  this.x = t, this.u = void 0, this.s = void 0, this.o = void 0, this.f = 32, this.name = e?.name;
@@ -690,8 +690,8 @@ De.prototype.c = function() {
690
690
  De.prototype.S = function() {
691
691
  if (1 & this.f) throw new Error("Cycle detected");
692
692
  this.f |= 1, this.f &= -9, Ki(this), qi(this), ge++;
693
- var t = k;
694
- return k = this, Bn.bind(this, t);
693
+ var t = L;
694
+ return L = this, Bn.bind(this, t);
695
695
  };
696
696
  De.prototype.N = function() {
697
697
  2 & this.f || (this.f |= 2, this.o = je, je = this);
@@ -717,7 +717,7 @@ Ke(function() {
717
717
  Ji = this.N;
718
718
  })();
719
719
  function Ue(t, e) {
720
- L[t] = e.bind(null, L[t] || function() {
720
+ M[t] = e.bind(null, M[t] || function() {
721
721
  });
722
722
  }
723
723
  function at(t) {
@@ -731,25 +731,25 @@ function Zi(t) {
731
731
  m.__c.__$f |= 4;
732
732
  break;
733
733
  }
734
- var p = ci(function() {
734
+ var f = ci(function() {
735
735
  var E = n.value.value;
736
736
  return E === 0 ? 0 : E === !0 ? "" : E || "";
737
- }), f = ci(function() {
738
- return !Array.isArray(p.value) && !bi(p.value);
737
+ }), p = ci(function() {
738
+ return !Array.isArray(f.value) && !bi(f.value);
739
739
  }), u = Ke(function() {
740
- if (this.N = en, f.value) {
741
- var E = p.value;
740
+ if (this.N = en, p.value) {
741
+ var E = f.value;
742
742
  l.__v && l.__v.__e && l.__v.__e.nodeType === 3 && (l.__v.__e.data = E);
743
743
  }
744
- }), T = e.__$u.d;
744
+ }), y = e.__$u.d;
745
745
  return e.__$u.d = function() {
746
- u(), T.call(this);
747
- }, [f, p];
746
+ u(), y.call(this);
747
+ }, [p, f];
748
748
  }, []), s = a[0], c = a[1];
749
749
  return s.value ? c.peek() : c.value;
750
750
  }
751
751
  Zi.displayName = "ReactiveTextNode";
752
- Object.defineProperties(Y.prototype, { constructor: { configurable: !0, value: void 0 }, type: { configurable: !0, value: Zi }, props: { configurable: !0, get: function() {
752
+ Object.defineProperties(X.prototype, { constructor: { configurable: !0, value: void 0 }, type: { configurable: !0, value: Zi }, props: { configurable: !0, get: function() {
753
753
  return { data: this };
754
754
  } }, __b: { configurable: !0, value: 1 } });
755
755
  Ue("__b", function(t, e) {
@@ -757,7 +757,7 @@ Ue("__b", function(t, e) {
757
757
  var i, n = e.props;
758
758
  for (var a in n) if (a !== "children") {
759
759
  var s = n[a];
760
- s instanceof Y && (i || (e.__np = i = {}), i[a] = s, n[a] = s.peek());
760
+ s instanceof X && (i || (e.__np = i = {}), i[a] = s, n[a] = s.peek());
761
761
  }
762
762
  }
763
763
  t(e);
@@ -795,15 +795,15 @@ Ue("diffed", function(t, e) {
795
795
  else
796
796
  s = {}, i.U = s;
797
797
  for (var m in n) {
798
- var p = s[m], f = n[m];
799
- p === void 0 ? (p = $n(i, m, f, a), s[m] = p) : p.o(f, a);
798
+ var f = s[m], p = n[m];
799
+ f === void 0 ? (f = $n(i, m, p, a), s[m] = f) : f.o(p, a);
800
800
  }
801
801
  }
802
802
  }
803
803
  t(e);
804
804
  });
805
805
  function $n(t, e, i, n) {
806
- var a = e in t && t.ownerSVGElement === void 0, s = H(i);
806
+ var a = e in t && t.ownerSVGElement === void 0, s = q(i);
807
807
  return { o: function(c, l) {
808
808
  s.value = c, n = l;
809
809
  }, d: Ke(function() {
@@ -851,7 +851,7 @@ Ne.prototype.shouldComponentUpdate = function(t, e) {
851
851
  };
852
852
  function Qi(t, e) {
853
853
  return Rt(function() {
854
- return H(t, e);
854
+ return q(t, e);
855
855
  })[0];
856
856
  }
857
857
  var Vn = function(t) {
@@ -865,7 +865,7 @@ function Wn() {
865
865
  });
866
866
  }
867
867
  function en() {
868
- Xi.push(this) === 1 && (L.requestAnimationFrame || Vn)(Wn);
868
+ Xi.push(this) === 1 && (M.requestAnimationFrame || Vn)(Wn);
869
869
  }
870
870
  const di = {
871
871
  layout: "floating",
@@ -912,48 +912,48 @@ function Gn(t) {
912
912
  var gt = {}, Be = {}, ui;
913
913
  function Hn() {
914
914
  if (ui) return Be;
915
- ui = 1, Be.byteLength = l, Be.toByteArray = p, Be.fromByteArray = T;
915
+ ui = 1, Be.byteLength = l, Be.toByteArray = f, Be.fromByteArray = y;
916
916
  for (var t = [], e = [], i = typeof Uint8Array < "u" ? Uint8Array : Array, n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", a = 0, s = n.length; a < s; ++a)
917
917
  t[a] = n[a], e[n.charCodeAt(a)] = a;
918
918
  e[45] = 62, e[95] = 63;
919
919
  function c(E) {
920
- var S = E.length;
921
- if (S % 4 > 0)
920
+ var T = E.length;
921
+ if (T % 4 > 0)
922
922
  throw new Error("Invalid string. Length must be a multiple of 4");
923
- var y = E.indexOf("=");
924
- y === -1 && (y = S);
925
- var I = y === S ? 0 : 4 - y % 4;
926
- return [y, I];
923
+ var I = E.indexOf("=");
924
+ I === -1 && (I = T);
925
+ var w = I === T ? 0 : 4 - I % 4;
926
+ return [I, w];
927
927
  }
928
928
  function l(E) {
929
- var S = c(E), y = S[0], I = S[1];
930
- return (y + I) * 3 / 4 - I;
929
+ var T = c(E), I = T[0], w = T[1];
930
+ return (I + w) * 3 / 4 - w;
931
931
  }
932
- function m(E, S, y) {
933
- return (S + y) * 3 / 4 - y;
934
- }
935
- function p(E) {
936
- var S, y = c(E), I = y[0], w = y[1], b = new i(m(E, I, w)), O = 0, N = w > 0 ? I - 4 : I, R;
937
- for (R = 0; R < N; R += 4)
938
- S = e[E.charCodeAt(R)] << 18 | e[E.charCodeAt(R + 1)] << 12 | e[E.charCodeAt(R + 2)] << 6 | e[E.charCodeAt(R + 3)], b[O++] = S >> 16 & 255, b[O++] = S >> 8 & 255, b[O++] = S & 255;
939
- return w === 2 && (S = e[E.charCodeAt(R)] << 2 | e[E.charCodeAt(R + 1)] >> 4, b[O++] = S & 255), w === 1 && (S = e[E.charCodeAt(R)] << 10 | e[E.charCodeAt(R + 1)] << 4 | e[E.charCodeAt(R + 2)] >> 2, b[O++] = S >> 8 & 255, b[O++] = S & 255), b;
932
+ function m(E, T, I) {
933
+ return (T + I) * 3 / 4 - I;
940
934
  }
941
935
  function f(E) {
936
+ var T, I = c(E), w = I[0], A = I[1], R = new i(m(E, w, A)), b = 0, N = A > 0 ? w - 4 : w, S;
937
+ for (S = 0; S < N; S += 4)
938
+ T = e[E.charCodeAt(S)] << 18 | e[E.charCodeAt(S + 1)] << 12 | e[E.charCodeAt(S + 2)] << 6 | e[E.charCodeAt(S + 3)], R[b++] = T >> 16 & 255, R[b++] = T >> 8 & 255, R[b++] = T & 255;
939
+ return A === 2 && (T = e[E.charCodeAt(S)] << 2 | e[E.charCodeAt(S + 1)] >> 4, R[b++] = T & 255), A === 1 && (T = e[E.charCodeAt(S)] << 10 | e[E.charCodeAt(S + 1)] << 4 | e[E.charCodeAt(S + 2)] >> 2, R[b++] = T >> 8 & 255, R[b++] = T & 255), R;
940
+ }
941
+ function p(E) {
942
942
  return t[E >> 18 & 63] + t[E >> 12 & 63] + t[E >> 6 & 63] + t[E & 63];
943
943
  }
944
- function u(E, S, y) {
945
- for (var I, w = [], b = S; b < y; b += 3)
946
- I = (E[b] << 16 & 16711680) + (E[b + 1] << 8 & 65280) + (E[b + 2] & 255), w.push(f(I));
947
- return w.join("");
944
+ function u(E, T, I) {
945
+ for (var w, A = [], R = T; R < I; R += 3)
946
+ w = (E[R] << 16 & 16711680) + (E[R + 1] << 8 & 65280) + (E[R + 2] & 255), A.push(p(w));
947
+ return A.join("");
948
948
  }
949
- function T(E) {
950
- for (var S, y = E.length, I = y % 3, w = [], b = 16383, O = 0, N = y - I; O < N; O += b)
951
- w.push(u(E, O, O + b > N ? N : O + b));
952
- return I === 1 ? (S = E[y - 1], w.push(
953
- t[S >> 2] + t[S << 4 & 63] + "=="
954
- )) : I === 2 && (S = (E[y - 2] << 8) + E[y - 1], w.push(
955
- t[S >> 10] + t[S >> 4 & 63] + t[S << 2 & 63] + "="
956
- )), w.join("");
949
+ function y(E) {
950
+ for (var T, I = E.length, w = I % 3, A = [], R = 16383, b = 0, N = I - w; b < N; b += R)
951
+ A.push(u(E, b, b + R > N ? N : b + R));
952
+ return w === 1 ? (T = E[I - 1], A.push(
953
+ t[T >> 2] + t[T << 4 & 63] + "=="
954
+ )) : w === 2 && (T = (E[I - 2] << 8) + E[I - 1], A.push(
955
+ t[T >> 10] + t[T >> 4 & 63] + t[T << 2 & 63] + "="
956
+ )), A.join("");
957
957
  }
958
958
  return Be;
959
959
  }
@@ -961,33 +961,33 @@ var et = {};
961
961
  var hi;
962
962
  function zn() {
963
963
  return hi || (hi = 1, et.read = function(t, e, i, n, a) {
964
- var s, c, l = a * 8 - n - 1, m = (1 << l) - 1, p = m >> 1, f = -7, u = i ? a - 1 : 0, T = i ? -1 : 1, E = t[e + u];
965
- for (u += T, s = E & (1 << -f) - 1, E >>= -f, f += l; f > 0; s = s * 256 + t[e + u], u += T, f -= 8)
964
+ var s, c, l = a * 8 - n - 1, m = (1 << l) - 1, f = m >> 1, p = -7, u = i ? a - 1 : 0, y = i ? -1 : 1, E = t[e + u];
965
+ for (u += y, s = E & (1 << -p) - 1, E >>= -p, p += l; p > 0; s = s * 256 + t[e + u], u += y, p -= 8)
966
966
  ;
967
- for (c = s & (1 << -f) - 1, s >>= -f, f += n; f > 0; c = c * 256 + t[e + u], u += T, f -= 8)
967
+ for (c = s & (1 << -p) - 1, s >>= -p, p += n; p > 0; c = c * 256 + t[e + u], u += y, p -= 8)
968
968
  ;
969
969
  if (s === 0)
970
- s = 1 - p;
970
+ s = 1 - f;
971
971
  else {
972
972
  if (s === m)
973
973
  return c ? NaN : (E ? -1 : 1) * (1 / 0);
974
- c = c + Math.pow(2, n), s = s - p;
974
+ c = c + Math.pow(2, n), s = s - f;
975
975
  }
976
976
  return (E ? -1 : 1) * c * Math.pow(2, s - n);
977
977
  }, et.write = function(t, e, i, n, a, s) {
978
- var c, l, m, p = s * 8 - a - 1, f = (1 << p) - 1, u = f >> 1, T = a === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, E = n ? 0 : s - 1, S = n ? 1 : -1, y = e < 0 || e === 0 && 1 / e < 0 ? 1 : 0;
979
- for (e = Math.abs(e), isNaN(e) || e === 1 / 0 ? (l = isNaN(e) ? 1 : 0, c = f) : (c = Math.floor(Math.log(e) / Math.LN2), e * (m = Math.pow(2, -c)) < 1 && (c--, m *= 2), c + u >= 1 ? e += T / m : e += T * Math.pow(2, 1 - u), e * m >= 2 && (c++, m /= 2), c + u >= f ? (l = 0, c = f) : c + u >= 1 ? (l = (e * m - 1) * Math.pow(2, a), c = c + u) : (l = e * Math.pow(2, u - 1) * Math.pow(2, a), c = 0)); a >= 8; t[i + E] = l & 255, E += S, l /= 256, a -= 8)
978
+ var c, l, m, f = s * 8 - a - 1, p = (1 << f) - 1, u = p >> 1, y = a === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, E = n ? 0 : s - 1, T = n ? 1 : -1, I = e < 0 || e === 0 && 1 / e < 0 ? 1 : 0;
979
+ for (e = Math.abs(e), isNaN(e) || e === 1 / 0 ? (l = isNaN(e) ? 1 : 0, c = p) : (c = Math.floor(Math.log(e) / Math.LN2), e * (m = Math.pow(2, -c)) < 1 && (c--, m *= 2), c + u >= 1 ? e += y / m : e += y * Math.pow(2, 1 - u), e * m >= 2 && (c++, m /= 2), c + u >= p ? (l = 0, c = p) : c + u >= 1 ? (l = (e * m - 1) * Math.pow(2, a), c = c + u) : (l = e * Math.pow(2, u - 1) * Math.pow(2, a), c = 0)); a >= 8; t[i + E] = l & 255, E += T, l /= 256, a -= 8)
980
980
  ;
981
- for (c = c << a | l, p += a; p > 0; t[i + E] = c & 255, E += S, c /= 256, p -= 8)
981
+ for (c = c << a | l, f += a; f > 0; t[i + E] = c & 255, E += T, c /= 256, f -= 8)
982
982
  ;
983
- t[i + E - S] |= y * 128;
983
+ t[i + E - T] |= I * 128;
984
984
  }), et;
985
985
  }
986
986
  var fi;
987
987
  function qn() {
988
988
  return fi || (fi = 1, (function(t) {
989
989
  const e = Hn(), i = zn(), n = typeof Symbol == "function" && typeof Symbol.for == "function" ? /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom") : null;
990
- t.Buffer = l, t.SlowBuffer = b, t.INSPECT_MAX_BYTES = 50;
990
+ t.Buffer = l, t.SlowBuffer = R, t.INSPECT_MAX_BYTES = 50;
991
991
  const a = 2147483647;
992
992
  t.kMaxLength = a, l.TYPED_ARRAY_SUPPORT = s(), !l.TYPED_ARRAY_SUPPORT && typeof console < "u" && typeof console.error == "function" && console.error(
993
993
  "This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."
@@ -1034,15 +1034,15 @@ function qn() {
1034
1034
  l.poolSize = 8192;
1035
1035
  function m(d, r, o) {
1036
1036
  if (typeof d == "string")
1037
- return T(d, r);
1037
+ return y(d, r);
1038
1038
  if (ArrayBuffer.isView(d))
1039
- return S(d);
1039
+ return T(d);
1040
1040
  if (d == null)
1041
1041
  throw new TypeError(
1042
1042
  "The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type " + typeof d
1043
1043
  );
1044
1044
  if (ae(d, ArrayBuffer) || d && ae(d.buffer, ArrayBuffer) || typeof SharedArrayBuffer < "u" && (ae(d, SharedArrayBuffer) || d && ae(d.buffer, SharedArrayBuffer)))
1045
- return y(d, r, o);
1045
+ return I(d, r, o);
1046
1046
  if (typeof d == "number")
1047
1047
  throw new TypeError(
1048
1048
  'The "value" argument must not be of type number. Received type number'
@@ -1050,7 +1050,7 @@ function qn() {
1050
1050
  const h = d.valueOf && d.valueOf();
1051
1051
  if (h != null && h !== d)
1052
1052
  return l.from(h, r, o);
1053
- const _ = I(d);
1053
+ const _ = w(d);
1054
1054
  if (_) return _;
1055
1055
  if (typeof Symbol < "u" && Symbol.toPrimitive != null && typeof d[Symbol.toPrimitive] == "function")
1056
1056
  return l.from(d[Symbol.toPrimitive]("string"), r, o);
@@ -1061,48 +1061,48 @@ function qn() {
1061
1061
  l.from = function(d, r, o) {
1062
1062
  return m(d, r, o);
1063
1063
  }, Object.setPrototypeOf(l.prototype, Uint8Array.prototype), Object.setPrototypeOf(l, Uint8Array);
1064
- function p(d) {
1064
+ function f(d) {
1065
1065
  if (typeof d != "number")
1066
1066
  throw new TypeError('"size" argument must be of type number');
1067
1067
  if (d < 0)
1068
1068
  throw new RangeError('The value "' + d + '" is invalid for option "size"');
1069
1069
  }
1070
- function f(d, r, o) {
1071
- return p(d), d <= 0 ? c(d) : r !== void 0 ? typeof o == "string" ? c(d).fill(r, o) : c(d).fill(r) : c(d);
1070
+ function p(d, r, o) {
1071
+ return f(d), d <= 0 ? c(d) : r !== void 0 ? typeof o == "string" ? c(d).fill(r, o) : c(d).fill(r) : c(d);
1072
1072
  }
1073
1073
  l.alloc = function(d, r, o) {
1074
- return f(d, r, o);
1074
+ return p(d, r, o);
1075
1075
  };
1076
1076
  function u(d) {
1077
- return p(d), c(d < 0 ? 0 : w(d) | 0);
1077
+ return f(d), c(d < 0 ? 0 : A(d) | 0);
1078
1078
  }
1079
1079
  l.allocUnsafe = function(d) {
1080
1080
  return u(d);
1081
1081
  }, l.allocUnsafeSlow = function(d) {
1082
1082
  return u(d);
1083
1083
  };
1084
- function T(d, r) {
1084
+ function y(d, r) {
1085
1085
  if ((typeof r != "string" || r === "") && (r = "utf8"), !l.isEncoding(r))
1086
1086
  throw new TypeError("Unknown encoding: " + r);
1087
- const o = O(d, r) | 0;
1087
+ const o = b(d, r) | 0;
1088
1088
  let h = c(o);
1089
1089
  const _ = h.write(d, r);
1090
1090
  return _ !== o && (h = h.slice(0, _)), h;
1091
1091
  }
1092
1092
  function E(d) {
1093
- const r = d.length < 0 ? 0 : w(d.length) | 0, o = c(r);
1093
+ const r = d.length < 0 ? 0 : A(d.length) | 0, o = c(r);
1094
1094
  for (let h = 0; h < r; h += 1)
1095
1095
  o[h] = d[h] & 255;
1096
1096
  return o;
1097
1097
  }
1098
- function S(d) {
1098
+ function T(d) {
1099
1099
  if (ae(d, Uint8Array)) {
1100
1100
  const r = new Uint8Array(d);
1101
- return y(r.buffer, r.byteOffset, r.byteLength);
1101
+ return I(r.buffer, r.byteOffset, r.byteLength);
1102
1102
  }
1103
1103
  return E(d);
1104
1104
  }
1105
- function y(d, r, o) {
1105
+ function I(d, r, o) {
1106
1106
  if (r < 0 || d.byteLength < r)
1107
1107
  throw new RangeError('"offset" is outside of buffer bounds');
1108
1108
  if (d.byteLength < r + (o || 0))
@@ -1110,9 +1110,9 @@ function qn() {
1110
1110
  let h;
1111
1111
  return r === void 0 && o === void 0 ? h = new Uint8Array(d) : o === void 0 ? h = new Uint8Array(d, r) : h = new Uint8Array(d, r, o), Object.setPrototypeOf(h, l.prototype), h;
1112
1112
  }
1113
- function I(d) {
1113
+ function w(d) {
1114
1114
  if (l.isBuffer(d)) {
1115
- const r = w(d.length) | 0, o = c(r);
1115
+ const r = A(d.length) | 0, o = c(r);
1116
1116
  return o.length === 0 || d.copy(o, 0, 0, r), o;
1117
1117
  }
1118
1118
  if (d.length !== void 0)
@@ -1120,12 +1120,12 @@ function qn() {
1120
1120
  if (d.type === "Buffer" && Array.isArray(d.data))
1121
1121
  return E(d.data);
1122
1122
  }
1123
- function w(d) {
1123
+ function A(d) {
1124
1124
  if (d >= a)
1125
1125
  throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x" + a.toString(16) + " bytes");
1126
1126
  return d | 0;
1127
1127
  }
1128
- function b(d) {
1128
+ function R(d) {
1129
1129
  return +d != d && (d = 0), l.alloc(+d);
1130
1130
  }
1131
1131
  l.isBuffer = function(r) {
@@ -1187,7 +1187,7 @@ function qn() {
1187
1187
  }
1188
1188
  return _;
1189
1189
  };
1190
- function O(d, r) {
1190
+ function b(d, r) {
1191
1191
  if (l.isBuffer(d))
1192
1192
  return d.length;
1193
1193
  if (ArrayBuffer.isView(d) || ae(d, ArrayBuffer))
@@ -1223,7 +1223,7 @@ function qn() {
1223
1223
  r = ("" + r).toLowerCase(), _ = !0;
1224
1224
  }
1225
1225
  }
1226
- l.byteLength = O;
1226
+ l.byteLength = b;
1227
1227
  function N(d, r, o) {
1228
1228
  let h = !1;
1229
1229
  if ((r === void 0 || r < 0) && (r = 0), r > this.length || ((o === void 0 || o > this.length) && (o = this.length), o <= 0) || (o >>>= 0, r >>>= 0, o <= r))
@@ -1236,7 +1236,7 @@ function qn() {
1236
1236
  case "utf-8":
1237
1237
  return ue(this, r, o);
1238
1238
  case "ascii":
1239
- return ne(this, r, o);
1239
+ return re(this, r, o);
1240
1240
  case "latin1":
1241
1241
  case "binary":
1242
1242
  return ut(this, r, o);
@@ -1246,14 +1246,14 @@ function qn() {
1246
1246
  case "ucs-2":
1247
1247
  case "utf16le":
1248
1248
  case "utf-16le":
1249
- return W(this, r, o);
1249
+ return G(this, r, o);
1250
1250
  default:
1251
1251
  if (h) throw new TypeError("Unknown encoding: " + d);
1252
1252
  d = (d + "").toLowerCase(), h = !0;
1253
1253
  }
1254
1254
  }
1255
1255
  l.prototype._isBuffer = !0;
1256
- function R(d, r, o) {
1256
+ function S(d, r, o) {
1257
1257
  const h = d[r];
1258
1258
  d[r] = d[o], d[o] = h;
1259
1259
  }
@@ -1262,21 +1262,21 @@ function qn() {
1262
1262
  if (r % 2 !== 0)
1263
1263
  throw new RangeError("Buffer size must be a multiple of 16-bits");
1264
1264
  for (let o = 0; o < r; o += 2)
1265
- R(this, o, o + 1);
1265
+ S(this, o, o + 1);
1266
1266
  return this;
1267
1267
  }, l.prototype.swap32 = function() {
1268
1268
  const r = this.length;
1269
1269
  if (r % 4 !== 0)
1270
1270
  throw new RangeError("Buffer size must be a multiple of 32-bits");
1271
1271
  for (let o = 0; o < r; o += 4)
1272
- R(this, o, o + 3), R(this, o + 1, o + 2);
1272
+ S(this, o, o + 3), S(this, o + 1, o + 2);
1273
1273
  return this;
1274
1274
  }, l.prototype.swap64 = function() {
1275
1275
  const r = this.length;
1276
1276
  if (r % 8 !== 0)
1277
1277
  throw new RangeError("Buffer size must be a multiple of 64-bits");
1278
1278
  for (let o = 0; o < r; o += 8)
1279
- R(this, o, o + 7), R(this, o + 1, o + 6), R(this, o + 2, o + 5), R(this, o + 3, o + 4);
1279
+ S(this, o, o + 7), S(this, o + 1, o + 6), S(this, o + 2, o + 5), S(this, o + 3, o + 4);
1280
1280
  return this;
1281
1281
  }, l.prototype.toString = function() {
1282
1282
  const r = this.length;
@@ -1303,15 +1303,15 @@ function qn() {
1303
1303
  return 1;
1304
1304
  if (o >>>= 0, h >>>= 0, _ >>>= 0, g >>>= 0, this === r) return 0;
1305
1305
  let v = g - _, x = h - o;
1306
- const P = Math.min(v, x), D = this.slice(_, g), B = r.slice(o, h);
1307
- for (let M = 0; M < P; ++M)
1308
- if (D[M] !== B[M]) {
1309
- v = D[M], x = B[M];
1306
+ const F = Math.min(v, x), P = this.slice(_, g), $ = r.slice(o, h);
1307
+ for (let D = 0; D < F; ++D)
1308
+ if (P[D] !== $[D]) {
1309
+ v = P[D], x = $[D];
1310
1310
  break;
1311
1311
  }
1312
1312
  return v < x ? -1 : x < v ? 1 : 0;
1313
1313
  };
1314
- function Z(d, r, o, h, _) {
1314
+ function k(d, r, o, h, _) {
1315
1315
  if (d.length === 0) return -1;
1316
1316
  if (typeof o == "string" ? (h = o, o = 0) : o > 2147483647 ? o = 2147483647 : o < -2147483648 && (o = -2147483648), o = +o, pt(o) && (o = _ ? 0 : d.length - 1), o < 0 && (o = d.length + o), o >= d.length) {
1317
1317
  if (_) return -1;
@@ -1320,49 +1320,49 @@ function qn() {
1320
1320
  if (_) o = 0;
1321
1321
  else return -1;
1322
1322
  if (typeof r == "string" && (r = l.from(r, h)), l.isBuffer(r))
1323
- return r.length === 0 ? -1 : G(d, r, o, h, _);
1323
+ return r.length === 0 ? -1 : U(d, r, o, h, _);
1324
1324
  if (typeof r == "number")
1325
- return r = r & 255, typeof Uint8Array.prototype.indexOf == "function" ? _ ? Uint8Array.prototype.indexOf.call(d, r, o) : Uint8Array.prototype.lastIndexOf.call(d, r, o) : G(d, [r], o, h, _);
1325
+ return r = r & 255, typeof Uint8Array.prototype.indexOf == "function" ? _ ? Uint8Array.prototype.indexOf.call(d, r, o) : Uint8Array.prototype.lastIndexOf.call(d, r, o) : U(d, [r], o, h, _);
1326
1326
  throw new TypeError("val must be string, number or Buffer");
1327
1327
  }
1328
- function G(d, r, o, h, _) {
1328
+ function U(d, r, o, h, _) {
1329
1329
  let g = 1, v = d.length, x = r.length;
1330
1330
  if (h !== void 0 && (h = String(h).toLowerCase(), h === "ucs2" || h === "ucs-2" || h === "utf16le" || h === "utf-16le")) {
1331
1331
  if (d.length < 2 || r.length < 2)
1332
1332
  return -1;
1333
1333
  g = 2, v /= 2, x /= 2, o /= 2;
1334
1334
  }
1335
- function P(B, M) {
1336
- return g === 1 ? B[M] : B.readUInt16BE(M * g);
1335
+ function F($, D) {
1336
+ return g === 1 ? $[D] : $.readUInt16BE(D * g);
1337
1337
  }
1338
- let D;
1338
+ let P;
1339
1339
  if (_) {
1340
- let B = -1;
1341
- for (D = o; D < v; D++)
1342
- if (P(d, D) === P(r, B === -1 ? 0 : D - B)) {
1343
- if (B === -1 && (B = D), D - B + 1 === x) return B * g;
1340
+ let $ = -1;
1341
+ for (P = o; P < v; P++)
1342
+ if (F(d, P) === F(r, $ === -1 ? 0 : P - $)) {
1343
+ if ($ === -1 && ($ = P), P - $ + 1 === x) return $ * g;
1344
1344
  } else
1345
- B !== -1 && (D -= D - B), B = -1;
1345
+ $ !== -1 && (P -= P - $), $ = -1;
1346
1346
  } else
1347
- for (o + x > v && (o = v - x), D = o; D >= 0; D--) {
1348
- let B = !0;
1349
- for (let M = 0; M < x; M++)
1350
- if (P(d, D + M) !== P(r, M)) {
1351
- B = !1;
1347
+ for (o + x > v && (o = v - x), P = o; P >= 0; P--) {
1348
+ let $ = !0;
1349
+ for (let D = 0; D < x; D++)
1350
+ if (F(d, P + D) !== F(r, D)) {
1351
+ $ = !1;
1352
1352
  break;
1353
1353
  }
1354
- if (B) return D;
1354
+ if ($) return P;
1355
1355
  }
1356
1356
  return -1;
1357
1357
  }
1358
1358
  l.prototype.includes = function(r, o, h) {
1359
1359
  return this.indexOf(r, o, h) !== -1;
1360
1360
  }, l.prototype.indexOf = function(r, o, h) {
1361
- return Z(this, r, o, h, !0);
1361
+ return k(this, r, o, h, !0);
1362
1362
  }, l.prototype.lastIndexOf = function(r, o, h) {
1363
- return Z(this, r, o, h, !1);
1363
+ return k(this, r, o, h, !1);
1364
1364
  };
1365
- function re(d, r, o, h) {
1365
+ function z(d, r, o, h) {
1366
1366
  o = Number(o) || 0;
1367
1367
  const _ = d.length - o;
1368
1368
  h ? (h = Number(h), h > _ && (h = _)) : h = _;
@@ -1376,16 +1376,16 @@ function qn() {
1376
1376
  }
1377
1377
  return v;
1378
1378
  }
1379
- function te(d, r, o, h) {
1379
+ function Y(d, r, o, h) {
1380
1380
  return Xe(ft(r, d.length - o), d, o, h);
1381
1381
  }
1382
1382
  function oe(d, r, o, h) {
1383
1383
  return Xe(mn(r), d, o, h);
1384
1384
  }
1385
- function z(d, r, o, h) {
1385
+ function K(d, r, o, h) {
1386
1386
  return Xe(Kt(r), d, o, h);
1387
1387
  }
1388
- function Q(d, r, o, h) {
1388
+ function te(d, r, o, h) {
1389
1389
  return Xe(gn(r, d.length - o), d, o, h);
1390
1390
  }
1391
1391
  l.prototype.write = function(r, o, h, _) {
@@ -1407,21 +1407,21 @@ function qn() {
1407
1407
  for (; ; )
1408
1408
  switch (_) {
1409
1409
  case "hex":
1410
- return re(this, r, o, h);
1410
+ return z(this, r, o, h);
1411
1411
  case "utf8":
1412
1412
  case "utf-8":
1413
- return te(this, r, o, h);
1413
+ return Y(this, r, o, h);
1414
1414
  case "ascii":
1415
1415
  case "latin1":
1416
1416
  case "binary":
1417
1417
  return oe(this, r, o, h);
1418
1418
  case "base64":
1419
- return z(this, r, o, h);
1419
+ return K(this, r, o, h);
1420
1420
  case "ucs2":
1421
1421
  case "ucs-2":
1422
1422
  case "utf16le":
1423
1423
  case "utf-16le":
1424
- return Q(this, r, o, h);
1424
+ return te(this, r, o, h);
1425
1425
  default:
1426
1426
  if (v) throw new TypeError("Unknown encoding: " + _);
1427
1427
  _ = ("" + _).toLowerCase(), v = !0;
@@ -1443,19 +1443,19 @@ function qn() {
1443
1443
  const g = d[_];
1444
1444
  let v = null, x = g > 239 ? 4 : g > 223 ? 3 : g > 191 ? 2 : 1;
1445
1445
  if (_ + x <= o) {
1446
- let P, D, B, M;
1446
+ let F, P, $, D;
1447
1447
  switch (x) {
1448
1448
  case 1:
1449
1449
  g < 128 && (v = g);
1450
1450
  break;
1451
1451
  case 2:
1452
- P = d[_ + 1], (P & 192) === 128 && (M = (g & 31) << 6 | P & 63, M > 127 && (v = M));
1452
+ F = d[_ + 1], (F & 192) === 128 && (D = (g & 31) << 6 | F & 63, D > 127 && (v = D));
1453
1453
  break;
1454
1454
  case 3:
1455
- P = d[_ + 1], D = d[_ + 2], (P & 192) === 128 && (D & 192) === 128 && (M = (g & 15) << 12 | (P & 63) << 6 | D & 63, M > 2047 && (M < 55296 || M > 57343) && (v = M));
1455
+ F = d[_ + 1], P = d[_ + 2], (F & 192) === 128 && (P & 192) === 128 && (D = (g & 15) << 12 | (F & 63) << 6 | P & 63, D > 2047 && (D < 55296 || D > 57343) && (v = D));
1456
1456
  break;
1457
1457
  case 4:
1458
- P = d[_ + 1], D = d[_ + 2], B = d[_ + 3], (P & 192) === 128 && (D & 192) === 128 && (B & 192) === 128 && (M = (g & 15) << 18 | (P & 63) << 12 | (D & 63) << 6 | B & 63, M > 65535 && M < 1114112 && (v = M));
1458
+ F = d[_ + 1], P = d[_ + 2], $ = d[_ + 3], (F & 192) === 128 && (P & 192) === 128 && ($ & 192) === 128 && (D = (g & 15) << 18 | (F & 63) << 12 | (P & 63) << 6 | $ & 63, D > 65535 && D < 1114112 && (v = D));
1459
1459
  }
1460
1460
  }
1461
1461
  v === null ? (v = 65533, x = 1) : v > 65535 && (v -= 65536, h.push(v >>> 10 & 1023 | 55296), v = 56320 | v & 1023), h.push(v), _ += x;
@@ -1475,7 +1475,7 @@ function qn() {
1475
1475
  );
1476
1476
  return o;
1477
1477
  }
1478
- function ne(d, r, o) {
1478
+ function re(d, r, o) {
1479
1479
  let h = "";
1480
1480
  o = Math.min(d.length, o);
1481
1481
  for (let _ = r; _ < o; ++_)
@@ -1497,7 +1497,7 @@ function qn() {
1497
1497
  _ += En[d[g]];
1498
1498
  return _;
1499
1499
  }
1500
- function W(d, r, o) {
1500
+ function G(d, r, o) {
1501
1501
  const h = d.slice(r, o);
1502
1502
  let _ = "";
1503
1503
  for (let g = 0; g < h.length - 1; g += 2)
@@ -1510,32 +1510,32 @@ function qn() {
1510
1510
  const _ = this.subarray(r, o);
1511
1511
  return Object.setPrototypeOf(_, l.prototype), _;
1512
1512
  };
1513
- function j(d, r, o) {
1513
+ function H(d, r, o) {
1514
1514
  if (d % 1 !== 0 || d < 0) throw new RangeError("offset is not uint");
1515
1515
  if (d + r > o) throw new RangeError("Trying to access beyond buffer length");
1516
1516
  }
1517
1517
  l.prototype.readUintLE = l.prototype.readUIntLE = function(r, o, h) {
1518
- r = r >>> 0, o = o >>> 0, h || j(r, o, this.length);
1518
+ r = r >>> 0, o = o >>> 0, h || H(r, o, this.length);
1519
1519
  let _ = this[r], g = 1, v = 0;
1520
1520
  for (; ++v < o && (g *= 256); )
1521
1521
  _ += this[r + v] * g;
1522
1522
  return _;
1523
1523
  }, l.prototype.readUintBE = l.prototype.readUIntBE = function(r, o, h) {
1524
- r = r >>> 0, o = o >>> 0, h || j(r, o, this.length);
1524
+ r = r >>> 0, o = o >>> 0, h || H(r, o, this.length);
1525
1525
  let _ = this[r + --o], g = 1;
1526
1526
  for (; o > 0 && (g *= 256); )
1527
1527
  _ += this[r + --o] * g;
1528
1528
  return _;
1529
1529
  }, l.prototype.readUint8 = l.prototype.readUInt8 = function(r, o) {
1530
- return r = r >>> 0, o || j(r, 1, this.length), this[r];
1530
+ return r = r >>> 0, o || H(r, 1, this.length), this[r];
1531
1531
  }, l.prototype.readUint16LE = l.prototype.readUInt16LE = function(r, o) {
1532
- return r = r >>> 0, o || j(r, 2, this.length), this[r] | this[r + 1] << 8;
1532
+ return r = r >>> 0, o || H(r, 2, this.length), this[r] | this[r + 1] << 8;
1533
1533
  }, l.prototype.readUint16BE = l.prototype.readUInt16BE = function(r, o) {
1534
- return r = r >>> 0, o || j(r, 2, this.length), this[r] << 8 | this[r + 1];
1534
+ return r = r >>> 0, o || H(r, 2, this.length), this[r] << 8 | this[r + 1];
1535
1535
  }, l.prototype.readUint32LE = l.prototype.readUInt32LE = function(r, o) {
1536
- return r = r >>> 0, o || j(r, 4, this.length), (this[r] | this[r + 1] << 8 | this[r + 2] << 16) + this[r + 3] * 16777216;
1536
+ return r = r >>> 0, o || H(r, 4, this.length), (this[r] | this[r + 1] << 8 | this[r + 2] << 16) + this[r + 3] * 16777216;
1537
1537
  }, l.prototype.readUint32BE = l.prototype.readUInt32BE = function(r, o) {
1538
- return r = r >>> 0, o || j(r, 4, this.length), this[r] * 16777216 + (this[r + 1] << 16 | this[r + 2] << 8 | this[r + 3]);
1538
+ return r = r >>> 0, o || H(r, 4, this.length), this[r] * 16777216 + (this[r + 1] << 16 | this[r + 2] << 8 | this[r + 3]);
1539
1539
  }, l.prototype.readBigUInt64LE = he(function(r) {
1540
1540
  r = r >>> 0, Re(r, "offset");
1541
1541
  const o = this[r], h = this[r + 7];
@@ -1549,31 +1549,31 @@ function qn() {
1549
1549
  const _ = o * 2 ** 24 + this[++r] * 2 ** 16 + this[++r] * 2 ** 8 + this[++r], g = this[++r] * 2 ** 24 + this[++r] * 2 ** 16 + this[++r] * 2 ** 8 + h;
1550
1550
  return (BigInt(_) << BigInt(32)) + BigInt(g);
1551
1551
  }), l.prototype.readIntLE = function(r, o, h) {
1552
- r = r >>> 0, o = o >>> 0, h || j(r, o, this.length);
1552
+ r = r >>> 0, o = o >>> 0, h || H(r, o, this.length);
1553
1553
  let _ = this[r], g = 1, v = 0;
1554
1554
  for (; ++v < o && (g *= 256); )
1555
1555
  _ += this[r + v] * g;
1556
1556
  return g *= 128, _ >= g && (_ -= Math.pow(2, 8 * o)), _;
1557
1557
  }, l.prototype.readIntBE = function(r, o, h) {
1558
- r = r >>> 0, o = o >>> 0, h || j(r, o, this.length);
1558
+ r = r >>> 0, o = o >>> 0, h || H(r, o, this.length);
1559
1559
  let _ = o, g = 1, v = this[r + --_];
1560
1560
  for (; _ > 0 && (g *= 256); )
1561
1561
  v += this[r + --_] * g;
1562
1562
  return g *= 128, v >= g && (v -= Math.pow(2, 8 * o)), v;
1563
1563
  }, l.prototype.readInt8 = function(r, o) {
1564
- return r = r >>> 0, o || j(r, 1, this.length), this[r] & 128 ? (255 - this[r] + 1) * -1 : this[r];
1564
+ return r = r >>> 0, o || H(r, 1, this.length), this[r] & 128 ? (255 - this[r] + 1) * -1 : this[r];
1565
1565
  }, l.prototype.readInt16LE = function(r, o) {
1566
- r = r >>> 0, o || j(r, 2, this.length);
1566
+ r = r >>> 0, o || H(r, 2, this.length);
1567
1567
  const h = this[r] | this[r + 1] << 8;
1568
1568
  return h & 32768 ? h | 4294901760 : h;
1569
1569
  }, l.prototype.readInt16BE = function(r, o) {
1570
- r = r >>> 0, o || j(r, 2, this.length);
1570
+ r = r >>> 0, o || H(r, 2, this.length);
1571
1571
  const h = this[r + 1] | this[r] << 8;
1572
1572
  return h & 32768 ? h | 4294901760 : h;
1573
1573
  }, l.prototype.readInt32LE = function(r, o) {
1574
- return r = r >>> 0, o || j(r, 4, this.length), this[r] | this[r + 1] << 8 | this[r + 2] << 16 | this[r + 3] << 24;
1574
+ return r = r >>> 0, o || H(r, 4, this.length), this[r] | this[r + 1] << 8 | this[r + 2] << 16 | this[r + 3] << 24;
1575
1575
  }, l.prototype.readInt32BE = function(r, o) {
1576
- return r = r >>> 0, o || j(r, 4, this.length), this[r] << 24 | this[r + 1] << 16 | this[r + 2] << 8 | this[r + 3];
1576
+ return r = r >>> 0, o || H(r, 4, this.length), this[r] << 24 | this[r + 1] << 16 | this[r + 2] << 8 | this[r + 3];
1577
1577
  }, l.prototype.readBigInt64LE = he(function(r) {
1578
1578
  r = r >>> 0, Re(r, "offset");
1579
1579
  const o = this[r], h = this[r + 7];
@@ -1588,15 +1588,15 @@ function qn() {
1588
1588
  this[++r] * 2 ** 16 + this[++r] * 2 ** 8 + this[++r];
1589
1589
  return (BigInt(_) << BigInt(32)) + BigInt(this[++r] * 2 ** 24 + this[++r] * 2 ** 16 + this[++r] * 2 ** 8 + h);
1590
1590
  }), l.prototype.readFloatLE = function(r, o) {
1591
- return r = r >>> 0, o || j(r, 4, this.length), i.read(this, r, !0, 23, 4);
1591
+ return r = r >>> 0, o || H(r, 4, this.length), i.read(this, r, !0, 23, 4);
1592
1592
  }, l.prototype.readFloatBE = function(r, o) {
1593
- return r = r >>> 0, o || j(r, 4, this.length), i.read(this, r, !1, 23, 4);
1593
+ return r = r >>> 0, o || H(r, 4, this.length), i.read(this, r, !1, 23, 4);
1594
1594
  }, l.prototype.readDoubleLE = function(r, o) {
1595
- return r = r >>> 0, o || j(r, 8, this.length), i.read(this, r, !0, 52, 8);
1595
+ return r = r >>> 0, o || H(r, 8, this.length), i.read(this, r, !0, 52, 8);
1596
1596
  }, l.prototype.readDoubleBE = function(r, o) {
1597
- return r = r >>> 0, o || j(r, 8, this.length), i.read(this, r, !1, 52, 8);
1597
+ return r = r >>> 0, o || H(r, 8, this.length), i.read(this, r, !1, 52, 8);
1598
1598
  };
1599
- function ie(d, r, o, h, _, g) {
1599
+ function ne(d, r, o, h, _, g) {
1600
1600
  if (!l.isBuffer(d)) throw new TypeError('"buffer" argument must be a Buffer instance');
1601
1601
  if (r > _ || r < g) throw new RangeError('"value" argument is out of bounds');
1602
1602
  if (o + h > d.length) throw new RangeError("Index out of range");
@@ -1604,7 +1604,7 @@ function qn() {
1604
1604
  l.prototype.writeUintLE = l.prototype.writeUIntLE = function(r, o, h, _) {
1605
1605
  if (r = +r, o = o >>> 0, h = h >>> 0, !_) {
1606
1606
  const x = Math.pow(2, 8 * h) - 1;
1607
- ie(this, r, o, h, x, 0);
1607
+ ne(this, r, o, h, x, 0);
1608
1608
  }
1609
1609
  let g = 1, v = 0;
1610
1610
  for (this[o] = r & 255; ++v < h && (g *= 256); )
@@ -1613,22 +1613,22 @@ function qn() {
1613
1613
  }, l.prototype.writeUintBE = l.prototype.writeUIntBE = function(r, o, h, _) {
1614
1614
  if (r = +r, o = o >>> 0, h = h >>> 0, !_) {
1615
1615
  const x = Math.pow(2, 8 * h) - 1;
1616
- ie(this, r, o, h, x, 0);
1616
+ ne(this, r, o, h, x, 0);
1617
1617
  }
1618
1618
  let g = h - 1, v = 1;
1619
1619
  for (this[o + g] = r & 255; --g >= 0 && (v *= 256); )
1620
1620
  this[o + g] = r / v & 255;
1621
1621
  return o + h;
1622
1622
  }, l.prototype.writeUint8 = l.prototype.writeUInt8 = function(r, o, h) {
1623
- return r = +r, o = o >>> 0, h || ie(this, r, o, 1, 255, 0), this[o] = r & 255, o + 1;
1623
+ return r = +r, o = o >>> 0, h || ne(this, r, o, 1, 255, 0), this[o] = r & 255, o + 1;
1624
1624
  }, l.prototype.writeUint16LE = l.prototype.writeUInt16LE = function(r, o, h) {
1625
- return r = +r, o = o >>> 0, h || ie(this, r, o, 2, 65535, 0), this[o] = r & 255, this[o + 1] = r >>> 8, o + 2;
1625
+ return r = +r, o = o >>> 0, h || ne(this, r, o, 2, 65535, 0), this[o] = r & 255, this[o + 1] = r >>> 8, o + 2;
1626
1626
  }, l.prototype.writeUint16BE = l.prototype.writeUInt16BE = function(r, o, h) {
1627
- return r = +r, o = o >>> 0, h || ie(this, r, o, 2, 65535, 0), this[o] = r >>> 8, this[o + 1] = r & 255, o + 2;
1627
+ return r = +r, o = o >>> 0, h || ne(this, r, o, 2, 65535, 0), this[o] = r >>> 8, this[o + 1] = r & 255, o + 2;
1628
1628
  }, l.prototype.writeUint32LE = l.prototype.writeUInt32LE = function(r, o, h) {
1629
- return r = +r, o = o >>> 0, h || ie(this, r, o, 4, 4294967295, 0), this[o + 3] = r >>> 24, this[o + 2] = r >>> 16, this[o + 1] = r >>> 8, this[o] = r & 255, o + 4;
1629
+ return r = +r, o = o >>> 0, h || ne(this, r, o, 4, 4294967295, 0), this[o + 3] = r >>> 24, this[o + 2] = r >>> 16, this[o + 1] = r >>> 8, this[o] = r & 255, o + 4;
1630
1630
  }, l.prototype.writeUint32BE = l.prototype.writeUInt32BE = function(r, o, h) {
1631
- return r = +r, o = o >>> 0, h || ie(this, r, o, 4, 4294967295, 0), this[o] = r >>> 24, this[o + 1] = r >>> 16, this[o + 2] = r >>> 8, this[o + 3] = r & 255, o + 4;
1631
+ return r = +r, o = o >>> 0, h || ne(this, r, o, 4, 4294967295, 0), this[o] = r >>> 24, this[o + 1] = r >>> 16, this[o + 2] = r >>> 8, this[o + 3] = r & 255, o + 4;
1632
1632
  };
1633
1633
  function Wt(d, r, o, h, _) {
1634
1634
  Yt(r, h, _, d, o, 7);
@@ -1650,8 +1650,8 @@ function qn() {
1650
1650
  return jt(this, r, o, BigInt(0), BigInt("0xffffffffffffffff"));
1651
1651
  }), l.prototype.writeIntLE = function(r, o, h, _) {
1652
1652
  if (r = +r, o = o >>> 0, !_) {
1653
- const P = Math.pow(2, 8 * h - 1);
1654
- ie(this, r, o, h, P - 1, -P);
1653
+ const F = Math.pow(2, 8 * h - 1);
1654
+ ne(this, r, o, h, F - 1, -F);
1655
1655
  }
1656
1656
  let g = 0, v = 1, x = 0;
1657
1657
  for (this[o] = r & 255; ++g < h && (v *= 256); )
@@ -1659,23 +1659,23 @@ function qn() {
1659
1659
  return o + h;
1660
1660
  }, l.prototype.writeIntBE = function(r, o, h, _) {
1661
1661
  if (r = +r, o = o >>> 0, !_) {
1662
- const P = Math.pow(2, 8 * h - 1);
1663
- ie(this, r, o, h, P - 1, -P);
1662
+ const F = Math.pow(2, 8 * h - 1);
1663
+ ne(this, r, o, h, F - 1, -F);
1664
1664
  }
1665
1665
  let g = h - 1, v = 1, x = 0;
1666
1666
  for (this[o + g] = r & 255; --g >= 0 && (v *= 256); )
1667
1667
  r < 0 && x === 0 && this[o + g + 1] !== 0 && (x = 1), this[o + g] = (r / v >> 0) - x & 255;
1668
1668
  return o + h;
1669
1669
  }, l.prototype.writeInt8 = function(r, o, h) {
1670
- return r = +r, o = o >>> 0, h || ie(this, r, o, 1, 127, -128), r < 0 && (r = 255 + r + 1), this[o] = r & 255, o + 1;
1670
+ return r = +r, o = o >>> 0, h || ne(this, r, o, 1, 127, -128), r < 0 && (r = 255 + r + 1), this[o] = r & 255, o + 1;
1671
1671
  }, l.prototype.writeInt16LE = function(r, o, h) {
1672
- return r = +r, o = o >>> 0, h || ie(this, r, o, 2, 32767, -32768), this[o] = r & 255, this[o + 1] = r >>> 8, o + 2;
1672
+ return r = +r, o = o >>> 0, h || ne(this, r, o, 2, 32767, -32768), this[o] = r & 255, this[o + 1] = r >>> 8, o + 2;
1673
1673
  }, l.prototype.writeInt16BE = function(r, o, h) {
1674
- return r = +r, o = o >>> 0, h || ie(this, r, o, 2, 32767, -32768), this[o] = r >>> 8, this[o + 1] = r & 255, o + 2;
1674
+ return r = +r, o = o >>> 0, h || ne(this, r, o, 2, 32767, -32768), this[o] = r >>> 8, this[o + 1] = r & 255, o + 2;
1675
1675
  }, l.prototype.writeInt32LE = function(r, o, h) {
1676
- return r = +r, o = o >>> 0, h || ie(this, r, o, 4, 2147483647, -2147483648), this[o] = r & 255, this[o + 1] = r >>> 8, this[o + 2] = r >>> 16, this[o + 3] = r >>> 24, o + 4;
1676
+ return r = +r, o = o >>> 0, h || ne(this, r, o, 4, 2147483647, -2147483648), this[o] = r & 255, this[o + 1] = r >>> 8, this[o + 2] = r >>> 16, this[o + 3] = r >>> 24, o + 4;
1677
1677
  }, l.prototype.writeInt32BE = function(r, o, h) {
1678
- return r = +r, o = o >>> 0, h || ie(this, r, o, 4, 2147483647, -2147483648), r < 0 && (r = 4294967295 + r + 1), this[o] = r >>> 24, this[o + 1] = r >>> 16, this[o + 2] = r >>> 8, this[o + 3] = r & 255, o + 4;
1678
+ return r = +r, o = o >>> 0, h || ne(this, r, o, 4, 2147483647, -2147483648), r < 0 && (r = 4294967295 + r + 1), this[o] = r >>> 24, this[o + 1] = r >>> 16, this[o + 2] = r >>> 8, this[o + 3] = r & 255, o + 4;
1679
1679
  }, l.prototype.writeBigInt64LE = he(function(r, o = 0) {
1680
1680
  return Wt(this, r, o, -BigInt("0x8000000000000000"), BigInt("0x7fffffffffffffff"));
1681
1681
  }), l.prototype.writeBigInt64BE = he(function(r, o = 0) {
@@ -1936,24 +1936,24 @@ var nn = function(t, e, i, n) {
1936
1936
  });
1937
1937
  }
1938
1938
  return new (i || (i = Promise))(function(s, c) {
1939
- function l(f) {
1939
+ function l(p) {
1940
1940
  try {
1941
- p(n.next(f));
1941
+ f(n.next(p));
1942
1942
  } catch (u) {
1943
1943
  c(u);
1944
1944
  }
1945
1945
  }
1946
- function m(f) {
1946
+ function m(p) {
1947
1947
  try {
1948
- p(n.throw(f));
1948
+ f(n.throw(p));
1949
1949
  } catch (u) {
1950
1950
  c(u);
1951
1951
  }
1952
1952
  }
1953
- function p(f) {
1954
- f.done ? s(f.value) : a(f.value).then(l, m);
1953
+ function f(p) {
1954
+ p.done ? s(p.value) : a(p.value).then(l, m);
1955
1955
  }
1956
- p((n = n.apply(t, e || [])).next());
1956
+ f((n = n.apply(t, e || [])).next());
1957
1957
  });
1958
1958
  };
1959
1959
  const rn = "https://api.anam.ai", $t = "/v1";
@@ -2018,63 +2018,63 @@ const Fe = (t) => {
2018
2018
  issues: []
2019
2019
  }, l = ((i = s["inbound-rtp"]) === null || i === void 0 ? void 0 : i.filter((u) => u.kind === "video")) || [];
2020
2020
  l.length > 0 && (c.personaVideoStream = [], l.forEach((u) => {
2021
- var T, E, S, y, I;
2022
- const w = {
2023
- framesReceived: (T = u.framesReceived) !== null && T !== void 0 ? T : "unknown",
2021
+ var y, E, T, I, w;
2022
+ const A = {
2023
+ framesReceived: (y = u.framesReceived) !== null && y !== void 0 ? y : "unknown",
2024
2024
  framesDropped: (E = u.framesDropped) !== null && E !== void 0 ? E : "unknown",
2025
- framesPerSecond: (S = u.framesPerSecond) !== null && S !== void 0 ? S : "unknown",
2026
- packetsReceived: (y = u.packetsReceived) !== null && y !== void 0 ? y : "unknown",
2027
- packetsLost: (I = u.packetsLost) !== null && I !== void 0 ? I : "unknown",
2025
+ framesPerSecond: (T = u.framesPerSecond) !== null && T !== void 0 ? T : "unknown",
2026
+ packetsReceived: (I = u.packetsReceived) !== null && I !== void 0 ? I : "unknown",
2027
+ packetsLost: (w = u.packetsLost) !== null && w !== void 0 ? w : "unknown",
2028
2028
  resolution: u.frameWidth && u.frameHeight ? `${u.frameWidth}x${u.frameHeight}` : void 0,
2029
2029
  jitter: u.jitter !== void 0 ? u.jitter : void 0
2030
2030
  };
2031
- c.personaVideoStream.push(w);
2031
+ c.personaVideoStream.push(A);
2032
2032
  }));
2033
2033
  const m = ((n = s["inbound-rtp"]) === null || n === void 0 ? void 0 : n.filter((u) => u.kind === "audio")) || [];
2034
2034
  m.length > 0 && (c.personaAudioStream = [], m.forEach((u) => {
2035
- var T, E, S;
2036
- const y = {
2037
- packetsReceived: (T = u.packetsReceived) !== null && T !== void 0 ? T : "unknown",
2035
+ var y, E, T;
2036
+ const I = {
2037
+ packetsReceived: (y = u.packetsReceived) !== null && y !== void 0 ? y : "unknown",
2038
2038
  packetsLost: (E = u.packetsLost) !== null && E !== void 0 ? E : "unknown",
2039
- audioLevel: (S = u.audioLevel) !== null && S !== void 0 ? S : "unknown",
2039
+ audioLevel: (T = u.audioLevel) !== null && T !== void 0 ? T : "unknown",
2040
2040
  jitter: u.jitter !== void 0 ? u.jitter : void 0,
2041
2041
  totalAudioEnergy: u.totalAudioEnergy !== void 0 ? u.totalAudioEnergy : void 0
2042
2042
  };
2043
- c.personaAudioStream.push(y);
2043
+ c.personaAudioStream.push(I);
2044
2044
  }));
2045
- const p = ((a = s["outbound-rtp"]) === null || a === void 0 ? void 0 : a.filter((u) => u.kind === "audio")) || [];
2046
- p.length > 0 && (c.userAudioInput = [], p.forEach((u) => {
2047
- var T, E;
2048
- const S = {
2049
- packetsSent: (T = u.packetsSent) !== null && T !== void 0 ? T : "unknown",
2045
+ const f = ((a = s["outbound-rtp"]) === null || a === void 0 ? void 0 : a.filter((u) => u.kind === "audio")) || [];
2046
+ f.length > 0 && (c.userAudioInput = [], f.forEach((u) => {
2047
+ var y, E;
2048
+ const T = {
2049
+ packetsSent: (y = u.packetsSent) !== null && y !== void 0 ? y : "unknown",
2050
2050
  retransmittedPackets: (E = u.retransmittedPacketsSent) !== null && E !== void 0 ? E : void 0,
2051
2051
  avgPacketSendDelay: u.totalPacketSendDelay !== void 0 ? u.totalPacketSendDelay / (u.packetsSent || 1) * 1e3 : void 0
2052
2052
  };
2053
- c.userAudioInput.push(S);
2053
+ c.userAudioInput.push(T);
2054
2054
  })), s.codec && (c.codecs = [], s.codec.forEach((u) => {
2055
- const T = {
2055
+ const y = {
2056
2056
  status: u.payloadType ? "Active" : "Available",
2057
2057
  mimeType: u.mimeType || "Unknown",
2058
2058
  payloadType: u.payloadType || "N/A",
2059
2059
  clockRate: u.clockRate || void 0,
2060
2060
  channels: u.channels || void 0
2061
2061
  };
2062
- c.codecs.push(T);
2062
+ c.codecs.push(y);
2063
2063
  })), s.transport && (c.transportLayer = [], s.transport.forEach((u) => {
2064
- const T = {
2064
+ const y = {
2065
2065
  dtlsState: u.dtlsState || "unknown",
2066
2066
  iceState: u.iceState || "unknown",
2067
2067
  bytesSent: u.bytesSent || void 0,
2068
2068
  bytesReceived: u.bytesReceived || void 0
2069
2069
  };
2070
- c.transportLayer.push(T);
2070
+ c.transportLayer.push(y);
2071
2071
  }));
2072
- const f = [];
2072
+ const p = [];
2073
2073
  if (l.forEach((u) => {
2074
- typeof u.framesDropped == "number" && u.framesDropped > 0 && f.push(`Video: ${u.framesDropped} frames dropped`), typeof u.packetsLost == "number" && u.packetsLost > 0 && f.push(`Video: ${u.packetsLost} packets lost`), typeof u.framesPerSecond == "number" && u.framesPerSecond < 23 && f.push(`Video: Low frame rate (${u.framesPerSecond} fps)`);
2074
+ typeof u.framesDropped == "number" && u.framesDropped > 0 && p.push(`Video: ${u.framesDropped} frames dropped`), typeof u.packetsLost == "number" && u.packetsLost > 0 && p.push(`Video: ${u.packetsLost} packets lost`), typeof u.framesPerSecond == "number" && u.framesPerSecond < 23 && p.push(`Video: Low frame rate (${u.framesPerSecond} fps)`);
2075
2075
  }), m.forEach((u) => {
2076
- typeof u.packetsLost == "number" && u.packetsLost > 0 && f.push(`Audio: ${u.packetsLost} packets lost`), typeof u.jitter == "number" && u.jitter > 0.1 && f.push(`Audio: High jitter (${(u.jitter * 1e3).toFixed(1)}ms)`);
2077
- }), c.issues = f, e === "json")
2076
+ typeof u.packetsLost == "number" && u.packetsLost > 0 && p.push(`Audio: ${u.packetsLost} packets lost`), typeof u.jitter == "number" && u.jitter > 0.1 && p.push(`Audio: High jitter (${(u.jitter * 1e3).toFixed(1)}ms)`);
2077
+ }), c.issues = p, e === "json")
2078
2078
  return c;
2079
2079
  console.group("📊 WebRTC Session Statistics Report"), c.personaVideoStream && c.personaVideoStream.length > 0 && (console.group("📹 Persona Video Stream (Inbound)"), c.personaVideoStream.forEach((u) => {
2080
2080
  console.log(`Frames Received: ${u.framesReceived}`), console.log(`Frames Dropped: ${u.framesDropped}`), console.log(`Frames Per Second: ${u.framesPerSecond}`), console.log(`Packets Received: ${typeof u.packetsReceived == "number" ? u.packetsReceived.toLocaleString() : u.packetsReceived}`), console.log(`Packets Lost: ${u.packetsLost}`), u.resolution && console.log(`Resolution: ${u.resolution}`), u.jitter !== void 0 && console.log(`Jitter: ${u.jitter.toFixed(5)}ms`);
@@ -2088,13 +2088,13 @@ const Fe = (t) => {
2088
2088
  console.log(`DTLS State: ${u.dtlsState}`), console.log(`ICE State: ${u.iceState}`), (u.bytesReceived || u.bytesSent) && console.log(`Data Transfer (bytes) - Sent: ${(u.bytesSent || 0).toLocaleString()}, Received: ${(u.bytesReceived || 0).toLocaleString()}`);
2089
2089
  }), console.groupEnd()), c.issues.length > 0 ? (console.group("⚠️ Potential Issues Detected"), c.issues.forEach((u) => console.warn(u)), console.groupEnd()) : console.log("✅ No significant issues detected"), console.groupEnd();
2090
2090
  };
2091
- var q;
2091
+ var J;
2092
2092
  (function(t) {
2093
2093
  t.CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED = "CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED", t.CLIENT_ERROR_CODE_SPEND_CAP_REACHED = "CLIENT_ERROR_CODE_SPEND_CAP_REACHED", t.CLIENT_ERROR_CODE_VALIDATION_ERROR = "CLIENT_ERROR_CODE_VALIDATION_ERROR", t.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR = "CLIENT_ERROR_CODE_AUTHENTICATION_ERROR", t.CLIENT_ERROR_CODE_SERVER_ERROR = "CLIENT_ERROR_CODE_SERVER_ERROR", t.CLIENT_ERROR_CODE_MAX_CONCURRENT_SESSIONS_REACHED = "CLIENT_ERROR_CODE_MAX_CONCURRENT_SESSIONS_REACHED", t.CLIENT_ERROR_CODE_SERVICE_BUSY = "CLIENT_ERROR_CODE_SERVICE_BUSY", t.CLIENT_ERROR_CODE_NO_PLAN_FOUND = "CLIENT_ERROR_CODE_NO_PLAN_FOUND", t.CLIENT_ERROR_CODE_UNKNOWN_ERROR = "CLIENT_ERROR_CODE_UNKNOWN_ERROR", t.CLIENT_ERROR_CODE_CONFIGURATION_ERROR = "CLIENT_ERROR_CODE_CONFIGURATION_ERROR";
2094
- })(q || (q = {}));
2095
- class F extends Error {
2094
+ })(J || (J = {}));
2095
+ class V extends Error {
2096
2096
  constructor(e, i, n = 500, a) {
2097
- super(e), this.name = "ClientError", this.code = i, this.statusCode = n, this.details = a, Object.setPrototypeOf(this, F.prototype), Me(ce.CLIENT_METRIC_MEASUREMENT_ERROR, i, {
2097
+ super(e), this.name = "ClientError", this.code = i, this.statusCode = n, this.details = a, Object.setPrototypeOf(this, V.prototype), Me(ce.CLIENT_METRIC_MEASUREMENT_ERROR, i, {
2098
2098
  details: a,
2099
2099
  statusCode: n
2100
2100
  });
@@ -2204,10 +2204,10 @@ function ur(t) {
2204
2204
  return "API Gateway wsPath must start with /";
2205
2205
  }
2206
2206
  }
2207
- var J;
2207
+ var Q;
2208
2208
  (function(t) {
2209
2209
  t.OFFER = "offer", t.ANSWER = "answer", t.ICE_CANDIDATE = "icecandidate", t.END_SESSION = "endsession", t.HEARTBEAT = "heartbeat", t.WARNING = "warning", t.TALK_STREAM_INTERRUPTED = "talkinputstreaminterrupted", t.TALK_STREAM_INPUT = "talkstream", t.SESSION_READY = "sessionready", t.AGENT_AUDIO_INPUT = "agentaudioinput", t.AGENT_AUDIO_INPUT_END = "agentaudioinputend";
2210
- })(J || (J = {}));
2210
+ })(Q || (Q = {}));
2211
2211
  var se;
2212
2212
  (function(t) {
2213
2213
  t.SPEECH_TEXT = "speechText", t.CLIENT_TOOL_EVENT = "clientToolEvent", t.TOOL_CALL_STARTED_EVENT = "toolCallStarted", t.TOOL_CALL_COMPLETED_EVENT = "toolCallCompleted", t.TOOL_CALL_FAILED_EVENT = "toolCallFailed", t.REASONING_TEXT = "reasoningText", t.USER_SPEECH_STARTED = "userSpeechStarted", t.USER_SPEECH_ENDED = "userSpeechEnded", t.DIRECTOR_NOTE_CUE_APPLIED = "directorNoteCueApplied";
@@ -2220,14 +2220,14 @@ var ve;
2220
2220
  (function(t) {
2221
2221
  t.USER = "user", t.PERSONA = "persona";
2222
2222
  })(ve || (ve = {}));
2223
- var A;
2223
+ var O;
2224
2224
  (function(t) {
2225
2225
  t.MESSAGE_HISTORY_UPDATED = "MESSAGE_HISTORY_UPDATED", t.MESSAGE_STREAM_EVENT_RECEIVED = "MESSAGE_STREAM_EVENT_RECEIVED", t.CONNECTION_ESTABLISHED = "CONNECTION_ESTABLISHED", t.CONNECTION_CLOSED = "CONNECTION_CLOSED", t.INPUT_AUDIO_STREAM_STARTED = "INPUT_AUDIO_STREAM_STARTED", t.VIDEO_STREAM_STARTED = "VIDEO_STREAM_STARTED", t.VIDEO_PLAY_STARTED = "VIDEO_PLAY_STARTED", t.AUDIO_STREAM_STARTED = "AUDIO_STREAM_STARTED", t.TALK_STREAM_INTERRUPTED = "TALK_STREAM_INTERRUPTED", t.SESSION_READY = "SESSION_READY", t.SERVER_WARNING = "SERVER_WARNING", t.MIC_PERMISSION_PENDING = "MIC_PERMISSION_PENDING", t.MIC_PERMISSION_GRANTED = "MIC_PERMISSION_GRANTED", t.MIC_PERMISSION_DENIED = "MIC_PERMISSION_DENIED", t.INPUT_AUDIO_DEVICE_CHANGED = "INPUT_AUDIO_DEVICE_CHANGED", t.CLIENT_TOOL_EVENT_RECEIVED = "CLIENT_TOOL_EVENT_RECEIVED", t.TOOL_CALL_STARTED = "TOOL_CALL_STARTED", t.TOOL_CALL_COMPLETED = "TOOL_CALL_COMPLETED", t.TOOL_CALL_FAILED = "TOOL_CALL_FAILED", t.REASONING_HISTORY_UPDATED = "REASONING_HISTORY_UPDATED", t.REASONING_STREAM_EVENT_RECEIVED = "REASONING_STREAM_EVENT_RECEIVED", t.USER_SPEECH_STARTED = "USER_SPEECH_STARTED", t.USER_SPEECH_ENDED = "USER_SPEECH_ENDED", t.DIRECTOR_NOTE_CUE_APPLIED = "DIRECTOR_NOTE_CUE_APPLIED";
2226
- })(A || (A = {}));
2227
- var U;
2226
+ })(O || (O = {}));
2227
+ var B;
2228
2228
  (function(t) {
2229
2229
  t.WEB_SOCKET_OPEN = "WEB_SOCKET_OPEN", t.SIGNAL_MESSAGE_RECEIVED = "SIGNAL_MESSAGE_RECEIVED", t.WEBRTC_CHAT_MESSAGE_RECEIVED = "WEBRTC_CHAT_MESSAGE_RECEIVED", t.WEBRTC_CLIENT_TOOL_EVENT_RECEIVED = "WEBRTC_CLIENT_TOOL_EVENT_RECEIVED", t.WEBRTC_TOOL_CALL_STARTED_EVENT_RECEIVED = "WEBRTC_TOOL_CALL_STARTED_EVENT_RECEIVED", t.WEBRTC_TOOL_CALL_COMPLETED_EVENT_RECEIVED = "WEBRTC_TOOL_CALL_COMPLETED_EVENT_RECEIVED", t.WEBRTC_TOOL_CALL_FAILED_EVENT_RECEIVED = "WEBRTC_TOOL_CALL_FAILED_EVENT_RECEIVED", t.WEBRTC_REASONING_TEXT_MESSAGE_RECEIVED = "WEBRTC_REASONING_TEXT_MESSAGE_RECEIVED", t.TOOL_CALL_RESULT_READY = "TOOL_CALL_RESULT_READY";
2230
- })(U || (U = {}));
2230
+ })(B || (B = {}));
2231
2231
  var Ee;
2232
2232
  (function(t) {
2233
2233
  t.NORMAL = "CONNECTION_CLOSED_CODE_NORMAL", t.MICROPHONE_PERMISSION_DENIED = "CONNECTION_CLOSED_CODE_MICROPHONE_PERMISSION_DENIED", t.SIGNALLING_CLIENT_CONNECTION_FAILURE = "CONNECTION_CLOSED_CODE_SIGNALLING_CLIENT_CONNECTION_FAILURE", t.WEBRTC_FAILURE = "CONNECTION_CLOSED_CODE_WEBRTC_FAILURE", t.SERVER_CLOSED_CONNECTION = "CONNECTION_CLOSED_CODE_SERVER_CLOSED_CONNECTION";
@@ -2281,44 +2281,44 @@ var Ae = function(t, e, i, n) {
2281
2281
  });
2282
2282
  }
2283
2283
  return new (i || (i = Promise))(function(s, c) {
2284
- function l(f) {
2284
+ function l(p) {
2285
2285
  try {
2286
- p(n.next(f));
2286
+ f(n.next(p));
2287
2287
  } catch (u) {
2288
2288
  c(u);
2289
2289
  }
2290
2290
  }
2291
- function m(f) {
2291
+ function m(p) {
2292
2292
  try {
2293
- p(n.throw(f));
2293
+ f(n.throw(p));
2294
2294
  } catch (u) {
2295
2295
  c(u);
2296
2296
  }
2297
2297
  }
2298
- function p(f) {
2299
- f.done ? s(f.value) : a(f.value).then(l, m);
2298
+ function f(p) {
2299
+ p.done ? s(p.value) : a(p.value).then(l, m);
2300
2300
  }
2301
- p((n = n.apply(t, e || [])).next());
2301
+ f((n = n.apply(t, e || [])).next());
2302
2302
  });
2303
2303
  };
2304
2304
  const fr = 5, pr = 5, _r = 24;
2305
2305
  class mr {
2306
2306
  constructor(e, i, n, a, s, c) {
2307
- var l, m, p, f, u;
2307
+ var l, m, f, p, u;
2308
2308
  if (this.stopSignal = !1, this.sendingBuffer = [], this.wsConnectionAttempts = 0, this.socket = null, this.permanentlyClosed = !1, this.iceRestartReconnectInProgress = !1, this.heartBeatIntervalRef = null, this.reconnectTimer = null, this.publicEventEmitter = n, this.internalEventEmitter = a, this.apiGatewayConfig = s, this.connectionMilestones = c, !e)
2309
2309
  throw new Error("Signalling Client: sessionId is required");
2310
2310
  this.sessionId = e;
2311
- const { heartbeatIntervalSeconds: T, maxWsReconnectionAttempts: E, url: S } = i;
2312
- if (this.heartbeatIntervalSeconds = T || fr, this.maxWsReconnectionAttempts = E || pr, !S.baseUrl)
2311
+ const { heartbeatIntervalSeconds: y, maxWsReconnectionAttempts: E, url: T } = i;
2312
+ if (this.heartbeatIntervalSeconds = y || fr, this.maxWsReconnectionAttempts = E || pr, !T.baseUrl)
2313
2313
  throw new Error("Signalling Client: baseUrl is required");
2314
2314
  if (!((l = this.apiGatewayConfig) === null || l === void 0) && l.enabled && (!((m = this.apiGatewayConfig) === null || m === void 0) && m.baseUrl)) {
2315
- const y = new URL(this.apiGatewayConfig.baseUrl), I = (p = this.apiGatewayConfig.wsPath) !== null && p !== void 0 ? p : "/ws";
2316
- y.protocol = y.protocol.replace("http", "ws"), y.pathname = I, this.url = y;
2317
- const w = S.protocol || "https", b = w === "http" ? "ws" : "wss", O = `${w}://${S.baseUrl}`, N = (f = S.signallingPath) !== null && f !== void 0 ? f : "/ws", R = new URL(O);
2318
- R.protocol = b === "ws" ? "ws:" : "wss:", S.port && (R.port = S.port), R.pathname = N, R.searchParams.append("session_id", e), this.url.searchParams.append("target_url", R.href);
2315
+ const I = new URL(this.apiGatewayConfig.baseUrl), w = (f = this.apiGatewayConfig.wsPath) !== null && f !== void 0 ? f : "/ws";
2316
+ I.protocol = I.protocol.replace("http", "ws"), I.pathname = w, this.url = I;
2317
+ const A = T.protocol || "https", R = A === "http" ? "ws" : "wss", b = `${A}://${T.baseUrl}`, N = (p = T.signallingPath) !== null && p !== void 0 ? p : "/ws", S = new URL(b);
2318
+ S.protocol = R === "ws" ? "ws:" : "wss:", T.port && (S.port = T.port), S.pathname = N, S.searchParams.append("session_id", e), this.url.searchParams.append("target_url", S.href);
2319
2319
  } else {
2320
- const I = `${S.protocol || "https"}://${S.baseUrl}`;
2321
- this.url = new URL(I), this.url.protocol = S.protocol === "http" ? "ws:" : "wss:", S.port && (this.url.port = S.port), this.url.pathname = (u = S.signallingPath) !== null && u !== void 0 ? u : "/ws", this.url.searchParams.append("session_id", e);
2320
+ const w = `${T.protocol || "https"}://${T.baseUrl}`;
2321
+ this.url = new URL(w), this.url.protocol = T.protocol === "http" ? "ws:" : "wss:", T.port && (this.url.port = T.port), this.url.pathname = (u = T.signallingPath) !== null && u !== void 0 ? u : "/ws", this.url.searchParams.append("session_id", e);
2322
2322
  }
2323
2323
  }
2324
2324
  stop() {
@@ -2383,7 +2383,7 @@ class mr {
2383
2383
  userUid: this.sessionId
2384
2384
  // TODO: this should be renamed to session ID on the server
2385
2385
  }, n = {
2386
- actionType: J.OFFER,
2386
+ actionType: Q.OFFER,
2387
2387
  sessionId: this.sessionId,
2388
2388
  payload: i
2389
2389
  };
@@ -2393,7 +2393,7 @@ class mr {
2393
2393
  sendIceCandidate(e) {
2394
2394
  return Ae(this, void 0, void 0, function* () {
2395
2395
  const i = {
2396
- actionType: J.ICE_CANDIDATE,
2396
+ actionType: Q.ICE_CANDIDATE,
2397
2397
  sessionId: this.sessionId,
2398
2398
  payload: e.toJSON()
2399
2399
  };
@@ -2414,7 +2414,7 @@ class mr {
2414
2414
  sendTalkMessage(e) {
2415
2415
  return Ae(this, void 0, void 0, function* () {
2416
2416
  const i = {
2417
- actionType: J.TALK_STREAM_INPUT,
2417
+ actionType: Q.TALK_STREAM_INPUT,
2418
2418
  sessionId: this.sessionId,
2419
2419
  payload: e
2420
2420
  };
@@ -2423,7 +2423,7 @@ class mr {
2423
2423
  }
2424
2424
  sendAgentAudioInput(e) {
2425
2425
  const i = {
2426
- actionType: J.AGENT_AUDIO_INPUT,
2426
+ actionType: Q.AGENT_AUDIO_INPUT,
2427
2427
  sessionId: this.sessionId,
2428
2428
  payload: e
2429
2429
  };
@@ -2431,7 +2431,7 @@ class mr {
2431
2431
  }
2432
2432
  sendAgentAudioInputEnd() {
2433
2433
  const e = {
2434
- actionType: J.AGENT_AUDIO_INPUT_END,
2434
+ actionType: Q.AGENT_AUDIO_INPUT_END,
2435
2435
  sessionId: this.sessionId,
2436
2436
  payload: {}
2437
2437
  };
@@ -2447,9 +2447,9 @@ class mr {
2447
2447
  try {
2448
2448
  (i = this.connectionMilestones) === null || i === void 0 || i.record("websocket_open", {
2449
2449
  attemptNumber: this.wsConnectionAttempts + 1
2450
- }), this.wsConnectionAttempts = 0, this.flushSendingBuffer(), e.onmessage = this.onMessage.bind(this), this.startSendingHeartBeats(), this.internalEventEmitter.emit(U.WEB_SOCKET_OPEN);
2450
+ }), this.wsConnectionAttempts = 0, this.flushSendingBuffer(), e.onmessage = this.onMessage.bind(this), this.startSendingHeartBeats(), this.internalEventEmitter.emit(B.WEB_SOCKET_OPEN);
2451
2451
  } catch (n) {
2452
- console.error("SignallingClient - onOpen: error in onOpen", n), this.publicEventEmitter.emit(A.CONNECTION_CLOSED, Ee.SIGNALLING_CLIENT_CONNECTION_FAILURE), this.permanentlyClosed = !0;
2452
+ console.error("SignallingClient - onOpen: error in onOpen", n), this.publicEventEmitter.emit(O.CONNECTION_CLOSED, Ee.SIGNALLING_CLIENT_CONNECTION_FAILURE), this.permanentlyClosed = !0;
2453
2453
  }
2454
2454
  });
2455
2455
  }
@@ -2478,7 +2478,7 @@ class mr {
2478
2478
  this.clearReconnectTimer(), this.heartBeatIntervalRef && (clearInterval(this.heartBeatIntervalRef), this.heartBeatIntervalRef = null), (s = this.connectionMilestones) === null || s === void 0 || s.publishFailure({
2479
2479
  failureStage: "websocket",
2480
2480
  closeCode: i?.code
2481
- }), this.publicEventEmitter.emit(A.CONNECTION_CLOSED, Ee.SIGNALLING_CLIENT_CONNECTION_FAILURE), this.iceRestartReconnectInProgress = !1, this.permanentlyClosed = !0;
2481
+ }), this.publicEventEmitter.emit(O.CONNECTION_CLOSED, Ee.SIGNALLING_CLIENT_CONNECTION_FAILURE), this.iceRestartReconnectInProgress = !1, this.permanentlyClosed = !0;
2482
2482
  });
2483
2483
  }
2484
2484
  getMaxReconnectionAttempts() {
@@ -2500,7 +2500,7 @@ class mr {
2500
2500
  onMessage(e) {
2501
2501
  return Ae(this, void 0, void 0, function* () {
2502
2502
  const i = JSON.parse(e.data);
2503
- this.internalEventEmitter.emit(U.SIGNAL_MESSAGE_RECEIVED, i);
2503
+ this.internalEventEmitter.emit(B.SIGNAL_MESSAGE_RECEIVED, i);
2504
2504
  });
2505
2505
  }
2506
2506
  startSendingHeartBeats() {
@@ -2508,7 +2508,7 @@ class mr {
2508
2508
  throw new Error("SignallingClient - startSendingHeartBeats: socket is null");
2509
2509
  this.heartBeatIntervalRef && console.warn("SignallingClient - startSendingHeartBeats: heartbeat interval already set");
2510
2510
  const e = this.heartbeatIntervalSeconds * 1e3, i = {
2511
- actionType: J.HEARTBEAT,
2511
+ actionType: Q.HEARTBEAT,
2512
2512
  sessionId: this.sessionId,
2513
2513
  payload: ""
2514
2514
  }, n = JSON.stringify(i);
@@ -2528,24 +2528,24 @@ var Et = function(t, e, i, n) {
2528
2528
  });
2529
2529
  }
2530
2530
  return new (i || (i = Promise))(function(s, c) {
2531
- function l(f) {
2531
+ function l(p) {
2532
2532
  try {
2533
- p(n.next(f));
2533
+ f(n.next(p));
2534
2534
  } catch (u) {
2535
2535
  c(u);
2536
2536
  }
2537
2537
  }
2538
- function m(f) {
2538
+ function m(p) {
2539
2539
  try {
2540
- p(n.throw(f));
2540
+ f(n.throw(p));
2541
2541
  } catch (u) {
2542
2542
  c(u);
2543
2543
  }
2544
2544
  }
2545
- function p(f) {
2546
- f.done ? s(f.value) : a(f.value).then(l, m);
2545
+ function f(p) {
2546
+ p.done ? s(p.value) : a(p.value).then(l, m);
2547
2547
  }
2548
- p((n = n.apply(t, e || [])).next());
2548
+ f((n = n.apply(t, e || [])).next());
2549
2549
  });
2550
2550
  };
2551
2551
  class Er {
@@ -2572,7 +2572,7 @@ class Er {
2572
2572
  return Et(this, void 0, void 0, function* () {
2573
2573
  if (!this.sessionToken) {
2574
2574
  if (!e)
2575
- throw new F("Persona configuration must be provided when using apiKey", q.CLIENT_ERROR_CODE_VALIDATION_ERROR, 400);
2575
+ throw new V("Persona configuration must be provided when using apiKey", J.CLIENT_ERROR_CODE_VALIDATION_ERROR, 400);
2576
2576
  this.sessionToken = yield this.unsafe_getSessionToken(e);
2577
2577
  }
2578
2578
  e && "brainType" in e && console.warn("Warning: brainType is deprecated and will be removed in a future version. Please use llmId instead.");
@@ -2605,28 +2605,28 @@ class Er {
2605
2605
  clientMetadata: tn
2606
2606
  }),
2607
2607
  signal: n?.signal
2608
- }), p = yield m.json(), f = p.error;
2608
+ }), f = yield m.json(), p = f.error;
2609
2609
  switch (m.status) {
2610
2610
  case 200:
2611
2611
  case 201:
2612
- return p;
2612
+ return f;
2613
2613
  case 400:
2614
- throw new F("Invalid request to start session", q.CLIENT_ERROR_CODE_VALIDATION_ERROR, 400, { cause: p.message });
2614
+ throw new V("Invalid request to start session", J.CLIENT_ERROR_CODE_VALIDATION_ERROR, 400, { cause: f.message });
2615
2615
  case 401:
2616
- throw new F("Authentication failed when starting session", q.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR, 401, { cause: p.message });
2616
+ throw new V("Authentication failed when starting session", J.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR, 401, { cause: f.message });
2617
2617
  case 402:
2618
- throw new F("Please sign up for a plan to start a session", q.CLIENT_ERROR_CODE_NO_PLAN_FOUND, 402, { cause: p.message });
2618
+ throw new V("Please sign up for a plan to start a session", J.CLIENT_ERROR_CODE_NO_PLAN_FOUND, 402, { cause: f.message });
2619
2619
  case 403:
2620
- throw new F("Authentication failed when starting session", q.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR, 403, { cause: p.message });
2620
+ throw new V("Authentication failed when starting session", J.CLIENT_ERROR_CODE_AUTHENTICATION_ERROR, 403, { cause: f.message });
2621
2621
  case 429:
2622
- throw f === "Concurrent session limit reached" ? new F("Concurrency limit reached, please upgrade your plan", q.CLIENT_ERROR_CODE_MAX_CONCURRENT_SESSIONS_REACHED, 429, { cause: p.message }) : f === "Spend cap reached" ? new F("Spend cap reached, please upgrade your plan", q.CLIENT_ERROR_CODE_SPEND_CAP_REACHED, 429, { cause: p.message }) : new F("Usage limit reached, please upgrade your plan", q.CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED, 429, { cause: p.message });
2622
+ throw p === "Concurrent session limit reached" ? new V("Concurrency limit reached, please upgrade your plan", J.CLIENT_ERROR_CODE_MAX_CONCURRENT_SESSIONS_REACHED, 429, { cause: f.message }) : p === "Spend cap reached" ? new V("Spend cap reached, please upgrade your plan", J.CLIENT_ERROR_CODE_SPEND_CAP_REACHED, 429, { cause: f.message }) : new V("Usage limit reached, please upgrade your plan", J.CLIENT_ERROR_CODE_USAGE_LIMIT_REACHED, 429, { cause: f.message });
2623
2623
  case 503:
2624
- throw new F("There are no available personas, please try again later", q.CLIENT_ERROR_CODE_SERVICE_BUSY, 503, { cause: p.message });
2624
+ throw new V("There are no available personas, please try again later", J.CLIENT_ERROR_CODE_SERVICE_BUSY, 503, { cause: f.message });
2625
2625
  default:
2626
- throw new F("Unknown error when starting session", q.CLIENT_ERROR_CODE_SERVER_ERROR, m.status, { cause: p.message });
2626
+ throw new V("Unknown error when starting session", J.CLIENT_ERROR_CODE_SERVER_ERROR, m.status, { cause: f.message });
2627
2627
  }
2628
2628
  } catch (s) {
2629
- throw s instanceof F ? s : new F("Failed to start session", q.CLIENT_ERROR_CODE_SERVER_ERROR, 500, { cause: s instanceof Error ? s.message : String(s) });
2629
+ throw s instanceof V ? s : new V("Failed to start session", J.CLIENT_ERROR_CODE_SERVER_ERROR, 500, { cause: s instanceof Error ? s.message : String(s) });
2630
2630
  } finally {
2631
2631
  a !== void 0 && clearTimeout(a);
2632
2632
  }
@@ -2672,7 +2672,7 @@ function nt(t, e) {
2672
2672
  return typeof t == "number" && Number.isFinite(t) ? t : e;
2673
2673
  }
2674
2674
  function Cr(t) {
2675
- return t instanceof F ? t.statusCode >= 500 && t.statusCode < 600 : !0;
2675
+ return t instanceof V ? t.statusCode >= 500 && t.statusCode < 600 : !0;
2676
2676
  }
2677
2677
  function Sr(t) {
2678
2678
  return new Promise((e) => setTimeout(e, t));
@@ -2684,24 +2684,24 @@ var Tr = function(t, e, i, n) {
2684
2684
  });
2685
2685
  }
2686
2686
  return new (i || (i = Promise))(function(s, c) {
2687
- function l(f) {
2687
+ function l(p) {
2688
2688
  try {
2689
- p(n.next(f));
2689
+ f(n.next(p));
2690
2690
  } catch (u) {
2691
2691
  c(u);
2692
2692
  }
2693
2693
  }
2694
- function m(f) {
2694
+ function m(p) {
2695
2695
  try {
2696
- p(n.throw(f));
2696
+ f(n.throw(p));
2697
2697
  } catch (u) {
2698
2698
  c(u);
2699
2699
  }
2700
2700
  }
2701
- function p(f) {
2702
- f.done ? s(f.value) : a(f.value).then(l, m);
2701
+ function f(p) {
2702
+ p.done ? s(p.value) : a(p.value).then(l, m);
2703
2703
  }
2704
- p((n = n.apply(t, e || [])).next());
2704
+ f((n = n.apply(t, e || [])).next());
2705
2705
  });
2706
2706
  };
2707
2707
  class yr {
@@ -2718,8 +2718,8 @@ class yr {
2718
2718
  const c = "/talk", l = `?session_id=${this.sessionId}`;
2719
2719
  if (!((i = this.apiGatewayConfig) === null || i === void 0) && i.enabled && (!((n = this.apiGatewayConfig) === null || n === void 0) && n.baseUrl)) {
2720
2720
  a = `${this.apiGatewayConfig.baseUrl}${c}${l}`;
2721
- const p = new URL(`${this.baseUrl}${c}${l}`);
2722
- s["X-Anam-Target-Url"] = p.href;
2721
+ const f = new URL(`${this.baseUrl}${c}${l}`);
2722
+ s["X-Anam-Target-Url"] = f.href;
2723
2723
  } else
2724
2724
  a = `${this.baseUrl}${c}${l}`;
2725
2725
  const m = yield fetch(a, {
@@ -2755,7 +2755,7 @@ class Ir {
2755
2755
  }
2756
2756
  class br {
2757
2757
  constructor(e, i) {
2758
- this.messages = [], this.publicEventEmitter = e, this.internalEventEmitter = i, this.internalEventEmitter.addListener(U.WEBRTC_CHAT_MESSAGE_RECEIVED, this.processWebRtcTextMessageEvent.bind(this));
2758
+ this.messages = [], this.publicEventEmitter = e, this.internalEventEmitter = i, this.internalEventEmitter.addListener(B.WEBRTC_CHAT_MESSAGE_RECEIVED, this.processWebRtcTextMessageEvent.bind(this));
2759
2759
  }
2760
2760
  webRtcTextMessageEventToMessageStreamEvent(e) {
2761
2761
  return Object.assign({ id: `${e.role}::${e.message_id}`, content: e.content, role: e.role, endOfSpeech: e.end_of_speech, interrupted: e.interrupted }, e.cue_tag ? { cueTag: e.cue_tag } : {});
@@ -2783,7 +2783,7 @@ class br {
2783
2783
  }
2784
2784
  processWebRtcTextMessageEvent(e) {
2785
2785
  const i = this.webRtcTextMessageEventToMessageStreamEvent(e);
2786
- switch (this.publicEventEmitter.emit(A.MESSAGE_STREAM_EVENT_RECEIVED, i), i.role) {
2786
+ switch (this.publicEventEmitter.emit(O.MESSAGE_STREAM_EVENT_RECEIVED, i), i.role) {
2787
2787
  case ve.USER:
2788
2788
  this.processUserMessage(i);
2789
2789
  break;
@@ -2791,7 +2791,7 @@ class br {
2791
2791
  this.processPersonaMessage(i);
2792
2792
  break;
2793
2793
  }
2794
- i.endOfSpeech && this.publicEventEmitter.emit(A.MESSAGE_HISTORY_UPDATED, this.messages);
2794
+ i.endOfSpeech && this.publicEventEmitter.emit(O.MESSAGE_HISTORY_UPDATED, this.messages);
2795
2795
  }
2796
2796
  }
2797
2797
  class wr {
@@ -2805,7 +2805,7 @@ class wr {
2805
2805
  this.listeners[e] && this.listeners[e].delete(i);
2806
2806
  }
2807
2807
  emit(e, ...i) {
2808
- if (e === A.CONNECTION_ESTABLISHED && Me(ce.CLIENT_METRIC_MEASUREMENT_CONNECTION_ESTABLISHED, "1"), e === A.CONNECTION_CLOSED) {
2808
+ if (e === O.CONNECTION_ESTABLISHED && Me(ce.CLIENT_METRIC_MEASUREMENT_CONNECTION_ESTABLISHED, "1"), e === O.CONNECTION_CLOSED) {
2809
2809
  const [n, a] = i;
2810
2810
  Me(ce.CLIENT_METRIC_MEASUREMENT_CONNECTION_CLOSED, n, a ? { details: a } : void 0);
2811
2811
  }
@@ -2814,10 +2814,10 @@ class wr {
2814
2814
  });
2815
2815
  }
2816
2816
  }
2817
- var ee;
2817
+ var ie;
2818
2818
  (function(t) {
2819
2819
  t[t.UNSTARTED = 0] = "UNSTARTED", t[t.STREAMING = 1] = "STREAMING", t[t.INTERRUPTED = 2] = "INTERRUPTED", t[t.ENDED = 3] = "ENDED";
2820
- })(ee || (ee = {}));
2820
+ })(ie || (ie = {}));
2821
2821
  var vt = function(t, e, i, n) {
2822
2822
  function a(s) {
2823
2823
  return s instanceof i ? s : new i(function(c) {
@@ -2825,45 +2825,45 @@ var vt = function(t, e, i, n) {
2825
2825
  });
2826
2826
  }
2827
2827
  return new (i || (i = Promise))(function(s, c) {
2828
- function l(f) {
2828
+ function l(p) {
2829
2829
  try {
2830
- p(n.next(f));
2830
+ f(n.next(p));
2831
2831
  } catch (u) {
2832
2832
  c(u);
2833
2833
  }
2834
2834
  }
2835
- function m(f) {
2835
+ function m(p) {
2836
2836
  try {
2837
- p(n.throw(f));
2837
+ f(n.throw(p));
2838
2838
  } catch (u) {
2839
2839
  c(u);
2840
2840
  }
2841
2841
  }
2842
- function p(f) {
2843
- f.done ? s(f.value) : a(f.value).then(l, m);
2842
+ function f(p) {
2843
+ p.done ? s(p.value) : a(p.value).then(l, m);
2844
2844
  }
2845
- p((n = n.apply(t, e || [])).next());
2845
+ f((n = n.apply(t, e || [])).next());
2846
2846
  });
2847
2847
  };
2848
2848
  class Rr {
2849
2849
  constructor(e, i, n) {
2850
- this.state = ee.UNSTARTED, this.correlationId = e, this.internalEventEmitter = i, this.signallingClient = n, this.internalEventEmitter.addListener(U.SIGNAL_MESSAGE_RECEIVED, this.onSignalMessage.bind(this));
2850
+ this.state = ie.UNSTARTED, this.correlationId = e, this.internalEventEmitter = i, this.signallingClient = n, this.internalEventEmitter.addListener(B.SIGNAL_MESSAGE_RECEIVED, this.onSignalMessage.bind(this));
2851
2851
  }
2852
2852
  onDeactivate() {
2853
- this.internalEventEmitter.removeListener(U.SIGNAL_MESSAGE_RECEIVED, this.onSignalMessage.bind(this));
2853
+ this.internalEventEmitter.removeListener(B.SIGNAL_MESSAGE_RECEIVED, this.onSignalMessage.bind(this));
2854
2854
  }
2855
2855
  onSignalMessage(e) {
2856
2856
  return vt(this, void 0, void 0, function* () {
2857
- e.actionType === J.TALK_STREAM_INTERRUPTED && e.payload.correlationId === this.correlationId && (this.state = ee.INTERRUPTED, this.onDeactivate());
2857
+ e.actionType === Q.TALK_STREAM_INTERRUPTED && e.payload.correlationId === this.correlationId && (this.state = ie.INTERRUPTED, this.onDeactivate());
2858
2858
  });
2859
2859
  }
2860
2860
  endMessage() {
2861
2861
  return vt(this, void 0, void 0, function* () {
2862
- if (this.state === ee.ENDED) {
2862
+ if (this.state === ie.ENDED) {
2863
2863
  console.warn("Talk stream is already ended via end of speech. No need to call endMessage.");
2864
2864
  return;
2865
2865
  }
2866
- if (this.state !== ee.STREAMING) {
2866
+ if (this.state !== ie.STREAMING) {
2867
2867
  console.warn("Talk stream is not in an active state: " + this.state);
2868
2868
  return;
2869
2869
  }
@@ -2873,27 +2873,27 @@ class Rr {
2873
2873
  endOfSpeech: !0,
2874
2874
  correlationId: this.correlationId
2875
2875
  };
2876
- yield this.signallingClient.sendTalkMessage(e), this.state = ee.ENDED, this.onDeactivate();
2876
+ yield this.signallingClient.sendTalkMessage(e), this.state = ie.ENDED, this.onDeactivate();
2877
2877
  });
2878
2878
  }
2879
2879
  streamMessageChunk(e, i) {
2880
2880
  return vt(this, void 0, void 0, function* () {
2881
- if (this.state !== ee.STREAMING && this.state !== ee.UNSTARTED)
2881
+ if (this.state !== ie.STREAMING && this.state !== ie.UNSTARTED)
2882
2882
  throw new Error("Talk stream is not in an active state: " + this.state);
2883
2883
  const n = {
2884
2884
  content: e,
2885
- startOfSpeech: this.state === ee.UNSTARTED,
2885
+ startOfSpeech: this.state === ie.UNSTARTED,
2886
2886
  endOfSpeech: i,
2887
2887
  correlationId: this.correlationId
2888
2888
  };
2889
- this.state = i ? ee.ENDED : ee.STREAMING, this.state === ee.ENDED && this.onDeactivate(), yield this.signallingClient.sendTalkMessage(n);
2889
+ this.state = i ? ie.ENDED : ie.STREAMING, this.state === ie.ENDED && this.onDeactivate(), yield this.signallingClient.sendTalkMessage(n);
2890
2890
  });
2891
2891
  }
2892
2892
  getCorrelationId() {
2893
2893
  return this.correlationId;
2894
2894
  }
2895
2895
  isActive() {
2896
- return this.state === ee.STREAMING || this.state === ee.UNSTARTED;
2896
+ return this.state === ie.STREAMING || this.state === ie.UNSTARTED;
2897
2897
  }
2898
2898
  getState() {
2899
2899
  return this.state;
@@ -2906,24 +2906,24 @@ var Ct = function(t, e, i, n) {
2906
2906
  });
2907
2907
  }
2908
2908
  return new (i || (i = Promise))(function(s, c) {
2909
- function l(f) {
2909
+ function l(p) {
2910
2910
  try {
2911
- p(n.next(f));
2911
+ f(n.next(p));
2912
2912
  } catch (u) {
2913
2913
  c(u);
2914
2914
  }
2915
2915
  }
2916
- function m(f) {
2916
+ function m(p) {
2917
2917
  try {
2918
- p(n.throw(f));
2918
+ f(n.throw(p));
2919
2919
  } catch (u) {
2920
2920
  c(u);
2921
2921
  }
2922
2922
  }
2923
- function p(f) {
2924
- f.done ? s(f.value) : a(f.value).then(l, m);
2923
+ function f(p) {
2924
+ p.done ? s(p.value) : a(p.value).then(l, m);
2925
2925
  }
2926
- p((n = n.apply(t, e || [])).next());
2926
+ f((n = n.apply(t, e || [])).next());
2927
2927
  });
2928
2928
  };
2929
2929
  const mi = (t, e) => {
@@ -3006,7 +3006,7 @@ class un {
3006
3006
  return;
3007
3007
  const c = this.handlers[i];
3008
3008
  if (c.onComplete) {
3009
- e.tool_type === "client" && this.publicEventEmitter.emit(A.TOOL_CALL_COMPLETED, s);
3009
+ e.tool_type === "client" && this.publicEventEmitter.emit(O.TOOL_CALL_COMPLETED, s);
3010
3010
  try {
3011
3011
  yield c.onComplete(s);
3012
3012
  } catch (l) {
@@ -3026,7 +3026,7 @@ class un {
3026
3026
  return;
3027
3027
  const c = this.handlers[i];
3028
3028
  if (c.onFail) {
3029
- e.tool_type === "client" && this.publicEventEmitter.emit(A.TOOL_CALL_FAILED, s);
3029
+ e.tool_type === "client" && this.publicEventEmitter.emit(O.TOOL_CALL_FAILED, s);
3030
3030
  try {
3031
3031
  yield c.onFail(s);
3032
3032
  } catch (l) {
@@ -3049,7 +3049,7 @@ class un {
3049
3049
  userActionCorrelationId: e.userActionCorrelationId,
3050
3050
  timestampUserAction: e.timestampUserAction
3051
3051
  };
3052
- this.internalEventEmitter.emit(U.TOOL_CALL_RESULT_READY, i);
3052
+ this.internalEventEmitter.emit(B.TOOL_CALL_RESULT_READY, i);
3053
3053
  }
3054
3054
  /**
3055
3055
  * Converts a WebRtcClientToolEvent to a ClientToolEvent
@@ -3125,43 +3125,43 @@ class un {
3125
3125
  };
3126
3126
  }
3127
3127
  }
3128
- var K = function(t, e, i, n) {
3128
+ var Z = function(t, e, i, n) {
3129
3129
  function a(s) {
3130
3130
  return s instanceof i ? s : new i(function(c) {
3131
3131
  c(s);
3132
3132
  });
3133
3133
  }
3134
3134
  return new (i || (i = Promise))(function(s, c) {
3135
- function l(f) {
3135
+ function l(p) {
3136
3136
  try {
3137
- p(n.next(f));
3137
+ f(n.next(p));
3138
3138
  } catch (u) {
3139
3139
  c(u);
3140
3140
  }
3141
3141
  }
3142
- function m(f) {
3142
+ function m(p) {
3143
3143
  try {
3144
- p(n.throw(f));
3144
+ f(n.throw(p));
3145
3145
  } catch (u) {
3146
3146
  c(u);
3147
3147
  }
3148
3148
  }
3149
- function p(f) {
3150
- f.done ? s(f.value) : a(f.value).then(l, m);
3149
+ function f(p) {
3150
+ p.done ? s(p.value) : a(p.value).then(l, m);
3151
3151
  }
3152
- p((n = n.apply(t, e || [])).next());
3152
+ f((n = n.apply(t, e || [])).next());
3153
3153
  });
3154
3154
  };
3155
3155
  const St = 15e3, Ar = 5e3, gi = 2, Or = 3, xr = 2e3, Tt = 3e3, Nr = 5e3;
3156
3156
  class kr {
3157
3157
  constructor(e, i, n, a, s, c) {
3158
- var l, m, p, f;
3158
+ var l, m, f, p;
3159
3159
  this.peerConnection = null, this.connectionEstablishedEmitted = !1, this.iceRestartInProgress = !1, this.iceRestartAttempts = 0, this.iceRestartAwaitedAnswer = !1, this.iceRestartEpisodeStartMs = null, this.iceRestartEpisodeTrigger = null, this.iceRestartStopped = !1, this.iceDisconnectedGraceTimer = null, this.iceRestartWatchdogTimer = null, this.pendingWsOpenListener = null, this.pendingWsOpenTimeout = null, this.pendingWsOpenReject = null, this.connectionReceivedAnswer = !1, this.remoteIceCandidateBuffer = [], this.iceRestartCandidateBuffer = null, this.inputAudioStream = null, this.dataChannel = null, this.videoElement = null, this.videoStream = null, this.audioStream = null, this.inputAudioState = {
3160
3160
  isMuted: !1,
3161
3161
  permissionState: me.NOT_REQUESTED
3162
3162
  }, this.successMetricPoller = null, this.successMetricFired = !1, this.showPeerConnectionStatsReport = !1, this.peerConnectionStatsReportOutputFormat = "console", this.statsCollectionInterval = null, this.agentAudioInputStream = null, this.firstLocalIceCandidateSent = !1, this.firstRemoteIceCandidateReceived = !1, this.firstRemoteIceCandidateApplied = !1, this.connectionEstablishedMilestoneRecorded = !1, this.publicEventEmitter = n, this.internalEventEmitter = a, this.toolCallManager = s, this.connectionMilestones = c, this.apiGatewayConfig = i.apiGateway;
3163
3163
  const { inputAudio: u } = i;
3164
- this.inputAudioState = u.inputAudioState, i.inputAudio.userProvidedMediaStream && (this.inputAudioStream = i.inputAudio.userProvidedMediaStream), this.disableInputAudio = i.inputAudio.disableInputAudio === !0, this.internalEventEmitter.addListener(U.WEB_SOCKET_OPEN, this.onSignallingClientConnected.bind(this)), this.internalEventEmitter.addListener(U.SIGNAL_MESSAGE_RECEIVED, this.onSignalMessage.bind(this)), this.internalEventEmitter.addListener(U.WEBRTC_TOOL_CALL_STARTED_EVENT_RECEIVED, this.toolCallManager.processToolCallStartedEvent.bind(this.toolCallManager)), this.internalEventEmitter.addListener(U.WEBRTC_TOOL_CALL_COMPLETED_EVENT_RECEIVED, this.toolCallManager.processToolCallCompletedEvent.bind(this.toolCallManager)), this.internalEventEmitter.addListener(U.WEBRTC_TOOL_CALL_FAILED_EVENT_RECEIVED, this.toolCallManager.processToolCallFailedEvent.bind(this.toolCallManager)), this.internalEventEmitter.addListener(U.TOOL_CALL_RESULT_READY, this.onToolCallResultReceived.bind(this)), this.iceServers = i.iceServers, this.iceTransportPolicy = i.iceTransportPolicy, this.rtcConfiguration = i.rtcConfiguration, this.signallingClient = new mr(e, i.signalling, this.publicEventEmitter, this.internalEventEmitter, this.apiGatewayConfig, this.connectionMilestones), this.engineApiRestClient = new yr(i.engine.baseUrl, e, this.apiGatewayConfig), this.audioDeviceId = i.inputAudio.audioDeviceId, this.showPeerConnectionStatsReport = (m = (l = i.metrics) === null || l === void 0 ? void 0 : l.showPeerConnectionStatsReport) !== null && m !== void 0 ? m : !1, this.peerConnectionStatsReportOutputFormat = (f = (p = i.metrics) === null || p === void 0 ? void 0 : p.peerConnectionStatsReportOutputFormat) !== null && f !== void 0 ? f : "console";
3164
+ this.inputAudioState = u.inputAudioState, i.inputAudio.userProvidedMediaStream && (this.inputAudioStream = i.inputAudio.userProvidedMediaStream), this.disableInputAudio = i.inputAudio.disableInputAudio === !0, this.internalEventEmitter.addListener(B.WEB_SOCKET_OPEN, this.onSignallingClientConnected.bind(this)), this.internalEventEmitter.addListener(B.SIGNAL_MESSAGE_RECEIVED, this.onSignalMessage.bind(this)), this.internalEventEmitter.addListener(B.WEBRTC_TOOL_CALL_STARTED_EVENT_RECEIVED, this.toolCallManager.processToolCallStartedEvent.bind(this.toolCallManager)), this.internalEventEmitter.addListener(B.WEBRTC_TOOL_CALL_COMPLETED_EVENT_RECEIVED, this.toolCallManager.processToolCallCompletedEvent.bind(this.toolCallManager)), this.internalEventEmitter.addListener(B.WEBRTC_TOOL_CALL_FAILED_EVENT_RECEIVED, this.toolCallManager.processToolCallFailedEvent.bind(this.toolCallManager)), this.internalEventEmitter.addListener(B.TOOL_CALL_RESULT_READY, this.onToolCallResultReceived.bind(this)), this.iceServers = i.iceServers, this.iceTransportPolicy = i.iceTransportPolicy, this.rtcConfiguration = i.rtcConfiguration, this.signallingClient = new mr(e, i.signalling, this.publicEventEmitter, this.internalEventEmitter, this.apiGatewayConfig, this.connectionMilestones), this.engineApiRestClient = new yr(i.engine.baseUrl, e, this.apiGatewayConfig), this.audioDeviceId = i.inputAudio.audioDeviceId, this.showPeerConnectionStatsReport = (m = (l = i.metrics) === null || l === void 0 ? void 0 : l.showPeerConnectionStatsReport) !== null && m !== void 0 ? m : !1, this.peerConnectionStatsReportOutputFormat = (p = (f = i.metrics) === null || f === void 0 ? void 0 : f.peerConnectionStatsReportOutputFormat) !== null && p !== void 0 ? p : "console";
3165
3165
  }
3166
3166
  onInputAudioStateChange(e, i) {
3167
3167
  e.isMuted !== i.isMuted && (i.isMuted ? this.muteAllAudioTracks() : this.unmuteAllAudioTracks());
@@ -3179,7 +3179,7 @@ class kr {
3179
3179
  });
3180
3180
  }
3181
3181
  startStatsCollection() {
3182
- this.statsCollectionInterval || (this.statsCollectionInterval = setInterval(() => K(this, void 0, void 0, function* () {
3182
+ this.statsCollectionInterval || (this.statsCollectionInterval = setInterval(() => Z(this, void 0, void 0, function* () {
3183
3183
  if (!(!this.peerConnection || !this.dataChannel || this.dataChannel.readyState !== "open"))
3184
3184
  try {
3185
3185
  const e = yield this.peerConnection.getStats();
@@ -3218,7 +3218,7 @@ class kr {
3218
3218
  timeoutMs: St
3219
3219
  }), console.warn("No video frames received, there is a problem with the connection."), clearInterval(this.successMetricPoller), this.successMetricPoller = null);
3220
3220
  }, St);
3221
- this.successMetricPoller = setInterval(() => K(this, void 0, void 0, function* () {
3221
+ this.successMetricPoller = setInterval(() => Z(this, void 0, void 0, function* () {
3222
3222
  if (!this.peerConnection || this.successMetricFired) {
3223
3223
  this.successMetricPoller && clearInterval(this.successMetricPoller), clearTimeout(e);
3224
3224
  return;
@@ -3249,7 +3249,7 @@ class kr {
3249
3249
  return this.peerConnection;
3250
3250
  }
3251
3251
  changeAudioInputDevice(e) {
3252
- return K(this, void 0, void 0, function* () {
3252
+ return Z(this, void 0, void 0, function* () {
3253
3253
  if (!this.peerConnection)
3254
3254
  throw new Error("StreamingClient - changeAudioInputDevice: peer connection is not initialized. Start streaming first.");
3255
3255
  if (e == null)
@@ -3267,7 +3267,7 @@ class kr {
3267
3267
  };
3268
3268
  this.inputAudioStream = yield navigator.mediaDevices.getUserMedia({
3269
3269
  audio: n
3270
- }), this.audioDeviceId = e, yield this.setupAudioTrack(), i && this.muteAllAudioTracks(), this.publicEventEmitter.emit(A.INPUT_AUDIO_DEVICE_CHANGED, e);
3270
+ }), this.audioDeviceId = e, yield this.setupAudioTrack(), i && this.muteAllAudioTracks(), this.publicEventEmitter.emit(O.INPUT_AUDIO_DEVICE_CHANGED, e);
3271
3271
  } catch (n) {
3272
3272
  throw console.error("Failed to change audio input device:", n), new Error(`StreamingClient - changeAudioInputDevice: ${n instanceof Error ? n.message : String(n)}`);
3273
3273
  }
@@ -3319,12 +3319,12 @@ class kr {
3319
3319
  this.firstLocalIceCandidateSent = !1, this.firstRemoteIceCandidateReceived = !1, this.firstRemoteIceCandidateApplied = !1, this.connectionEstablishedMilestoneRecorded = !1;
3320
3320
  }
3321
3321
  stopConnection() {
3322
- return K(this, void 0, void 0, function* () {
3322
+ return Z(this, void 0, void 0, function* () {
3323
3323
  yield this.shutdown();
3324
3324
  });
3325
3325
  }
3326
3326
  sendTalkCommand(e) {
3327
- return K(this, void 0, void 0, function* () {
3327
+ return Z(this, void 0, void 0, function* () {
3328
3328
  if (!this.peerConnection)
3329
3329
  throw new Error("StreamingClient - sendTalkCommand: peer connection is null");
3330
3330
  yield this.engineApiRestClient.sendTalkCommand(e);
@@ -3340,8 +3340,8 @@ class kr {
3340
3340
  return this.agentAudioInputStream;
3341
3341
  }
3342
3342
  initPeerConnection() {
3343
- return K(this, void 0, void 0, function* () {
3344
- var e, i, n, a, s, c, l, m, p, f;
3343
+ return Z(this, void 0, void 0, function* () {
3344
+ var e, i, n, a, s, c, l, m, f, p;
3345
3345
  (e = this.connectionMilestones) === null || e === void 0 || e.record("peer_connection_creating"), this.peerConnection = new RTCPeerConnection(Object.assign(Object.assign({
3346
3346
  // SDK default first (caller's rtcConfiguration may override it)
3347
3347
  iceCandidatePoolSize: gi
@@ -3353,9 +3353,9 @@ class kr {
3353
3353
  iceCandidatePoolSize: gi,
3354
3354
  iceServerCount: this.iceServers.length,
3355
3355
  iceTransportPolicy: (m = (l = (c = this.rtcConfiguration) === null || c === void 0 ? void 0 : c.iceTransportPolicy) !== null && l !== void 0 ? l : this.iceTransportPolicy) !== null && m !== void 0 ? m : "all"
3356
- }), this.peerConnection.onicecandidate = this.onIceCandidate.bind(this), this.peerConnection.oniceconnectionstatechange = this.onIceConnectionStateChange.bind(this), this.peerConnection.onconnectionstatechange = this.onConnectionStateChange.bind(this), this.peerConnection.addEventListener("track", this.onTrackEventHandler.bind(this)), yield this.setupDataChannels(), this.peerConnection.addTransceiver("video", { direction: "recvonly" }), this.disableInputAudio ? ((p = this.connectionMilestones) === null || p === void 0 || p.record("microphone_permission_skipped", {
3356
+ }), this.peerConnection.onicecandidate = this.onIceCandidate.bind(this), this.peerConnection.oniceconnectionstatechange = this.onIceConnectionStateChange.bind(this), this.peerConnection.onconnectionstatechange = this.onConnectionStateChange.bind(this), this.peerConnection.addEventListener("track", this.onTrackEventHandler.bind(this)), yield this.setupDataChannels(), this.peerConnection.addTransceiver("video", { direction: "recvonly" }), this.disableInputAudio ? ((f = this.connectionMilestones) === null || f === void 0 || f.record("microphone_permission_skipped", {
3357
3357
  reason: "input_audio_disabled"
3358
- }), this.peerConnection.addTransceiver("audio", { direction: "recvonly" })) : (this.peerConnection.addTransceiver("audio", { direction: "sendrecv" }), this.inputAudioStream ? ((f = this.connectionMilestones) === null || f === void 0 || f.record("input_audio_stream_provided", {
3358
+ }), this.peerConnection.addTransceiver("audio", { direction: "recvonly" })) : (this.peerConnection.addTransceiver("audio", { direction: "sendrecv" }), this.inputAudioStream ? ((p = this.connectionMilestones) === null || p === void 0 || p.record("input_audio_stream_provided", {
3359
3359
  audioTrackCount: this.inputAudioStream.getAudioTracks().length
3360
3360
  }), yield this.setupAudioTrack()) : this.requestMicrophonePermissionAsync().catch((u) => {
3361
3361
  console.error("Async microphone permission request failed:", u);
@@ -3363,20 +3363,20 @@ class kr {
3363
3363
  });
3364
3364
  }
3365
3365
  onSignalMessage(e) {
3366
- return K(this, void 0, void 0, function* () {
3366
+ return Z(this, void 0, void 0, function* () {
3367
3367
  var i, n, a, s;
3368
3368
  if (!this.peerConnection) {
3369
3369
  console.error("StreamingClient - onSignalMessage: peerConnection is not initialized");
3370
3370
  return;
3371
3371
  }
3372
3372
  switch (e.actionType) {
3373
- case J.ANSWER: {
3373
+ case Q.ANSWER: {
3374
3374
  (i = this.connectionMilestones) === null || i === void 0 || i.record("answer_received");
3375
- const f = e.payload;
3375
+ const p = e.payload;
3376
3376
  if (this.peerConnection.signalingState !== "have-local-offer")
3377
3377
  break;
3378
3378
  try {
3379
- yield this.peerConnection.setRemoteDescription(f);
3379
+ yield this.peerConnection.setRemoteDescription(p);
3380
3380
  } catch (u) {
3381
3381
  console.error("StreamingClient - setRemoteDescription(answer) failed", u), !this.connectionEstablishedEmitted && !this.isAwaitingRestartAnswer() && this.handleWebrtcFailure(u);
3382
3382
  break;
@@ -3384,30 +3384,30 @@ class kr {
3384
3384
  (n = this.connectionMilestones) === null || n === void 0 || n.record("remote_description_set"), this.connectionReceivedAnswer = !0, this.onAnswerAccepted(), yield this.flushRemoteIceCandidateBuffer();
3385
3385
  break;
3386
3386
  }
3387
- case J.ICE_CANDIDATE: {
3388
- const f = e.payload, u = new RTCIceCandidate(f);
3387
+ case Q.ICE_CANDIDATE: {
3388
+ const p = e.payload, u = new RTCIceCandidate(p);
3389
3389
  this.firstRemoteIceCandidateReceived || (this.firstRemoteIceCandidateReceived = !0, (a = this.connectionMilestones) === null || a === void 0 || a.record("first_remote_ice_candidate_received", yt(u))), this.connectionReceivedAnswer ? yield this.addRemoteIceCandidate(u) : this.remoteIceCandidateBuffer.push(u);
3390
3390
  break;
3391
3391
  }
3392
- case J.END_SESSION:
3392
+ case Q.END_SESSION:
3393
3393
  const c = e.payload;
3394
3394
  this.sendIceRestartMetric("aborted"), (s = this.connectionMilestones) === null || s === void 0 || s.publishFailure({
3395
3395
  failureStage: "server_closed_connection"
3396
- }), this.publicEventEmitter.emit(A.CONNECTION_CLOSED, Ee.SERVER_CLOSED_CONNECTION, c), this.shutdown();
3396
+ }), this.publicEventEmitter.emit(O.CONNECTION_CLOSED, Ee.SERVER_CLOSED_CONNECTION, c), this.shutdown();
3397
3397
  break;
3398
- case J.WARNING:
3398
+ case Q.WARNING:
3399
3399
  const l = e.payload;
3400
- console.warn("Warning received from server: " + l), this.publicEventEmitter.emit(A.SERVER_WARNING, l);
3400
+ console.warn("Warning received from server: " + l), this.publicEventEmitter.emit(O.SERVER_WARNING, l);
3401
3401
  break;
3402
- case J.TALK_STREAM_INTERRUPTED:
3402
+ case Q.TALK_STREAM_INTERRUPTED:
3403
3403
  const m = e.payload;
3404
- this.publicEventEmitter.emit(A.TALK_STREAM_INTERRUPTED, m.correlationId);
3404
+ this.publicEventEmitter.emit(O.TALK_STREAM_INTERRUPTED, m.correlationId);
3405
3405
  break;
3406
- case J.SESSION_READY:
3407
- const p = e.sessionId;
3408
- this.publicEventEmitter.emit(A.SESSION_READY, p);
3406
+ case Q.SESSION_READY:
3407
+ const f = e.sessionId;
3408
+ this.publicEventEmitter.emit(O.SESSION_READY, f);
3409
3409
  break;
3410
- case J.HEARTBEAT:
3410
+ case Q.HEARTBEAT:
3411
3411
  break;
3412
3412
  default:
3413
3413
  console.warn("StreamingClient - onSignalMessage: unknown signal message action type. Is your @anam-ai/js-sdk version up to date?", e);
@@ -3415,7 +3415,7 @@ class kr {
3415
3415
  });
3416
3416
  }
3417
3417
  onSignallingClientConnected() {
3418
- return K(this, void 0, void 0, function* () {
3418
+ return Z(this, void 0, void 0, function* () {
3419
3419
  if (!this.peerConnection)
3420
3420
  try {
3421
3421
  yield this.initPeerConnectionAndSendOffer();
@@ -3425,7 +3425,7 @@ class kr {
3425
3425
  });
3426
3426
  }
3427
3427
  flushRemoteIceCandidateBuffer() {
3428
- return K(this, void 0, void 0, function* () {
3428
+ return Z(this, void 0, void 0, function* () {
3429
3429
  const e = [...this.remoteIceCandidateBuffer];
3430
3430
  this.remoteIceCandidateBuffer = [];
3431
3431
  for (const i of e)
@@ -3441,7 +3441,7 @@ class kr {
3441
3441
  * genuine, successful add.
3442
3442
  */
3443
3443
  addRemoteIceCandidate(e) {
3444
- return K(this, void 0, void 0, function* () {
3444
+ return Z(this, void 0, void 0, function* () {
3445
3445
  if (this.peerConnection)
3446
3446
  try {
3447
3447
  yield this.peerConnection.addIceCandidate(e), this.recordFirstRemoteIceCandidateApplied(e);
@@ -3480,7 +3480,7 @@ class kr {
3480
3480
  case "completed":
3481
3481
  this.clearIceDisconnectedGraceTimer(), this.clearIceRestartWatchdog(), this.iceRestartInProgress = !1, this.sendIceRestartMetric("recovered"), this.iceRestartAttempts = 0, this.signallingClient.endIceRestartReconnect(), this.connectionEstablishedMilestoneRecorded || (this.connectionEstablishedMilestoneRecorded = !0, (n = this.connectionMilestones) === null || n === void 0 || n.record("client_connection_established", {
3482
3482
  iceConnectionState: a
3483
- })), this.connectionEstablishedEmitted || (this.connectionEstablishedEmitted = !0, this.publicEventEmitter.emit(A.CONNECTION_ESTABLISHED)), this.startStatsCollection();
3483
+ })), this.connectionEstablishedEmitted || (this.connectionEstablishedEmitted = !0, this.publicEventEmitter.emit(O.CONNECTION_ESTABLISHED)), this.startStatsCollection();
3484
3484
  break;
3485
3485
  case "disconnected":
3486
3486
  this.scheduleIceRestartAfterGrace();
@@ -3526,7 +3526,7 @@ class kr {
3526
3526
  }
3527
3527
  // Clears the pending ensureSignallingConnected wait (timeout + listener).
3528
3528
  clearPendingWsOpenWait() {
3529
- this.pendingWsOpenTimeout && (clearTimeout(this.pendingWsOpenTimeout), this.pendingWsOpenTimeout = null), this.pendingWsOpenListener && (this.internalEventEmitter.removeListener(U.WEB_SOCKET_OPEN, this.pendingWsOpenListener), this.pendingWsOpenListener = null), this.pendingWsOpenReject = null;
3529
+ this.pendingWsOpenTimeout && (clearTimeout(this.pendingWsOpenTimeout), this.pendingWsOpenTimeout = null), this.pendingWsOpenListener && (this.internalEventEmitter.removeListener(B.WEB_SOCKET_OPEN, this.pendingWsOpenListener), this.pendingWsOpenListener = null), this.pendingWsOpenReject = null;
3530
3530
  }
3531
3531
  // Stops all restart activity: timers, pending WS wait, and the in-progress gate.
3532
3532
  cancelIceRestart() {
@@ -3565,7 +3565,7 @@ class kr {
3565
3565
  const n = () => {
3566
3566
  this.clearPendingWsOpenWait(), e();
3567
3567
  };
3568
- this.pendingWsOpenListener = n, this.internalEventEmitter.addListener(U.WEB_SOCKET_OPEN, n);
3568
+ this.pendingWsOpenListener = n, this.internalEventEmitter.addListener(B.WEB_SOCKET_OPEN, n);
3569
3569
  });
3570
3570
  }
3571
3571
  /**
@@ -3574,7 +3574,7 @@ class kr {
3574
3574
  * exhaustion or terminal signalling, falls back to the WebRTC-failure path.
3575
3575
  */
3576
3576
  restartIce() {
3577
- return K(this, void 0, void 0, function* () {
3577
+ return Z(this, void 0, void 0, function* () {
3578
3578
  var e, i;
3579
3579
  if (!(!this.peerConnection || this.iceRestartInProgress || this.iceRestartStopped)) {
3580
3580
  if (this.signallingClient.isPermanentlyClosed()) {
@@ -3651,7 +3651,7 @@ class kr {
3651
3651
  }
3652
3652
  handleWebrtcFailure(e) {
3653
3653
  var i, n;
3654
- (i = this.connectionMilestones) === null || i === void 0 || i.record("webrtc_failure", $e(e)), (n = this.connectionMilestones) === null || n === void 0 || n.publishFailure(Object.assign({ failureStage: "webrtc" }, $e(e))), console.error({ message: "StreamingClient - handleWebrtcFailure: ", err: e }), e.name === "NotAllowedError" && e.message === "Permission denied" ? this.publicEventEmitter.emit(A.CONNECTION_CLOSED, Ee.MICROPHONE_PERMISSION_DENIED) : this.publicEventEmitter.emit(A.CONNECTION_CLOSED, Ee.WEBRTC_FAILURE);
3654
+ (i = this.connectionMilestones) === null || i === void 0 || i.record("webrtc_failure", $e(e)), (n = this.connectionMilestones) === null || n === void 0 || n.publishFailure(Object.assign({ failureStage: "webrtc" }, $e(e))), console.error({ message: "StreamingClient - handleWebrtcFailure: ", err: e }), e.name === "NotAllowedError" && e.message === "Permission denied" ? this.publicEventEmitter.emit(O.CONNECTION_CLOSED, Ee.MICROPHONE_PERMISSION_DENIED) : this.publicEventEmitter.emit(O.CONNECTION_CLOSED, Ee.WEBRTC_FAILURE);
3655
3655
  try {
3656
3656
  this.stopConnection();
3657
3657
  } catch (a) {
@@ -3661,20 +3661,20 @@ class kr {
3661
3661
  onTrackEventHandler(e) {
3662
3662
  var i, n;
3663
3663
  if (e.track.kind === "video") {
3664
- if ((i = this.connectionMilestones) === null || i === void 0 || i.record("video_track_received"), this.startSuccessMetricPolling(), this.videoStream = e.streams[0], this.publicEventEmitter.emit(A.VIDEO_STREAM_STARTED, this.videoStream), this.videoElement) {
3664
+ if ((i = this.connectionMilestones) === null || i === void 0 || i.record("video_track_received"), this.startSuccessMetricPolling(), this.videoStream = e.streams[0], this.publicEventEmitter.emit(O.VIDEO_STREAM_STARTED, this.videoStream), this.videoElement) {
3665
3665
  this.videoElement.srcObject = this.videoStream;
3666
3666
  const a = this.videoElement.requestVideoFrameCallback(() => {
3667
3667
  var s;
3668
- (s = this.videoElement) === null || s === void 0 || s.cancelVideoFrameCallback(a), this.publicEventEmitter.emit(A.VIDEO_PLAY_STARTED), this.recordSessionSuccess("videoElement");
3668
+ (s = this.videoElement) === null || s === void 0 || s.cancelVideoFrameCallback(a), this.publicEventEmitter.emit(O.VIDEO_PLAY_STARTED), this.recordSessionSuccess("videoElement");
3669
3669
  });
3670
3670
  }
3671
- } else e.track.kind === "audio" && ((n = this.connectionMilestones) === null || n === void 0 || n.record("audio_track_received"), this.audioStream = e.streams[0], this.publicEventEmitter.emit(A.AUDIO_STREAM_STARTED, this.audioStream));
3671
+ } else e.track.kind === "audio" && ((n = this.connectionMilestones) === null || n === void 0 || n.record("audio_track_received"), this.audioStream = e.streams[0], this.publicEventEmitter.emit(O.AUDIO_STREAM_STARTED, this.audioStream));
3672
3672
  }
3673
3673
  /**
3674
3674
  * Set up the data channels for sending and receiving messages
3675
3675
  */
3676
3676
  setupDataChannels() {
3677
- return K(this, void 0, void 0, function* () {
3677
+ return Z(this, void 0, void 0, function* () {
3678
3678
  var e;
3679
3679
  if (!this.peerConnection) {
3680
3680
  console.error("StreamingClient - setupDataChannels: peer connection is not initialized");
@@ -3692,53 +3692,53 @@ class kr {
3692
3692
  var n;
3693
3693
  (n = this.connectionMilestones) === null || n === void 0 || n.record("data_channel_closed");
3694
3694
  }, i.onmessage = (n) => {
3695
- var a, s, c, l, m, p;
3695
+ var a, s, c, l, m, f;
3696
3696
  try {
3697
- const f = JSON.parse(n.data);
3698
- switch (f.messageType) {
3697
+ const p = JSON.parse(n.data);
3698
+ switch (p.messageType) {
3699
3699
  case se.SPEECH_TEXT:
3700
- this.internalEventEmitter.emit(U.WEBRTC_CHAT_MESSAGE_RECEIVED, f.data);
3700
+ this.internalEventEmitter.emit(B.WEBRTC_CHAT_MESSAGE_RECEIVED, p.data);
3701
3701
  break;
3702
3702
  case se.CLIENT_TOOL_EVENT:
3703
- const u = f.data;
3704
- this.internalEventEmitter.emit(U.WEBRTC_CLIENT_TOOL_EVENT_RECEIVED, u);
3705
- const T = un.WebRTCClientToolEventToClientToolEvent(u);
3706
- this.publicEventEmitter.emit(A.CLIENT_TOOL_EVENT_RECEIVED, T);
3703
+ const u = p.data;
3704
+ this.internalEventEmitter.emit(B.WEBRTC_CLIENT_TOOL_EVENT_RECEIVED, u);
3705
+ const y = un.WebRTCClientToolEventToClientToolEvent(u);
3706
+ this.publicEventEmitter.emit(O.CLIENT_TOOL_EVENT_RECEIVED, y);
3707
3707
  break;
3708
3708
  case se.TOOL_CALL_STARTED_EVENT:
3709
- const E = f.data;
3710
- this.publicEventEmitter.emit(A.TOOL_CALL_STARTED, this.toolCallManager.WebRTCToolCallStartedEventToToolCallStartedPayload(E)), this.internalEventEmitter.emit(U.WEBRTC_TOOL_CALL_STARTED_EVENT_RECEIVED, E);
3709
+ const E = p.data;
3710
+ this.publicEventEmitter.emit(O.TOOL_CALL_STARTED, this.toolCallManager.WebRTCToolCallStartedEventToToolCallStartedPayload(E)), this.internalEventEmitter.emit(B.WEBRTC_TOOL_CALL_STARTED_EVENT_RECEIVED, E);
3711
3711
  break;
3712
3712
  case se.TOOL_CALL_COMPLETED_EVENT:
3713
- const S = f.data;
3714
- this.publicEventEmitter.emit(A.TOOL_CALL_COMPLETED, this.toolCallManager.webRTCToolCallCompletedEventToToolCallCompletedPayload(S)), this.internalEventEmitter.emit(U.WEBRTC_TOOL_CALL_COMPLETED_EVENT_RECEIVED, S);
3713
+ const T = p.data;
3714
+ this.publicEventEmitter.emit(O.TOOL_CALL_COMPLETED, this.toolCallManager.webRTCToolCallCompletedEventToToolCallCompletedPayload(T)), this.internalEventEmitter.emit(B.WEBRTC_TOOL_CALL_COMPLETED_EVENT_RECEIVED, T);
3715
3715
  break;
3716
3716
  case se.TOOL_CALL_FAILED_EVENT:
3717
- const y = f.data;
3718
- this.publicEventEmitter.emit(A.TOOL_CALL_FAILED, this.toolCallManager.webRTCToolCallFailedEventToToolCallFailedPayload(y)), this.internalEventEmitter.emit(U.WEBRTC_TOOL_CALL_FAILED_EVENT_RECEIVED, y);
3717
+ const I = p.data;
3718
+ this.publicEventEmitter.emit(O.TOOL_CALL_FAILED, this.toolCallManager.webRTCToolCallFailedEventToToolCallFailedPayload(I)), this.internalEventEmitter.emit(B.WEBRTC_TOOL_CALL_FAILED_EVENT_RECEIVED, I);
3719
3719
  break;
3720
3720
  case se.REASONING_TEXT:
3721
- this.internalEventEmitter.emit(U.WEBRTC_REASONING_TEXT_MESSAGE_RECEIVED, f.data);
3721
+ this.internalEventEmitter.emit(B.WEBRTC_REASONING_TEXT_MESSAGE_RECEIVED, p.data);
3722
3722
  break;
3723
3723
  case se.USER_SPEECH_STARTED:
3724
- this.publicEventEmitter.emit(A.USER_SPEECH_STARTED, (s = (a = f.data) === null || a === void 0 ? void 0 : a.user_action_correlation_id) !== null && s !== void 0 ? s : "unknown");
3724
+ this.publicEventEmitter.emit(O.USER_SPEECH_STARTED, (s = (a = p.data) === null || a === void 0 ? void 0 : a.user_action_correlation_id) !== null && s !== void 0 ? s : "unknown");
3725
3725
  break;
3726
3726
  case se.USER_SPEECH_ENDED:
3727
- this.publicEventEmitter.emit(A.USER_SPEECH_ENDED, (l = (c = f.data) === null || c === void 0 ? void 0 : c.user_action_correlation_id) !== null && l !== void 0 ? l : "unknown");
3727
+ this.publicEventEmitter.emit(O.USER_SPEECH_ENDED, (l = (c = p.data) === null || c === void 0 ? void 0 : c.user_action_correlation_id) !== null && l !== void 0 ? l : "unknown");
3728
3728
  break;
3729
3729
  case se.DIRECTOR_NOTE_CUE_APPLIED:
3730
- const I = f.data;
3731
- this.publicEventEmitter.emit(A.DIRECTOR_NOTE_CUE_APPLIED, {
3732
- cueTag: (m = I?.cue_tag) !== null && m !== void 0 ? m : "unknown",
3733
- correlationId: (p = I?.user_action_correlation_id) !== null && p !== void 0 ? p : "unknown"
3730
+ const w = p.data;
3731
+ this.publicEventEmitter.emit(O.DIRECTOR_NOTE_CUE_APPLIED, {
3732
+ cueTag: (m = w?.cue_tag) !== null && m !== void 0 ? m : "unknown",
3733
+ correlationId: (f = w?.user_action_correlation_id) !== null && f !== void 0 ? f : "unknown"
3734
3734
  });
3735
3735
  break;
3736
3736
  // Unknown message types are silently ignored to maintain forward compatibility
3737
3737
  default:
3738
3738
  break;
3739
3739
  }
3740
- } catch (f) {
3741
- console.error("Failed to parse data channel message:", f);
3740
+ } catch (p) {
3741
+ console.error("Failed to parse data channel message:", p);
3742
3742
  }
3743
3743
  };
3744
3744
  });
@@ -3747,23 +3747,29 @@ class kr {
3747
3747
  * Request microphone permission asynchronously without blocking connection
3748
3748
  */
3749
3749
  requestMicrophonePermissionAsync() {
3750
- return K(this, void 0, void 0, function* () {
3750
+ return Z(this, void 0, void 0, function* () {
3751
3751
  var e, i, n;
3752
3752
  if (this.inputAudioState.permissionState !== me.PENDING) {
3753
- this.inputAudioState = Object.assign(Object.assign({}, this.inputAudioState), { permissionState: me.PENDING }), (e = this.connectionMilestones) === null || e === void 0 || e.record("microphone_permission_pending"), this.publicEventEmitter.emit(A.MIC_PERMISSION_PENDING);
3753
+ this.inputAudioState = Object.assign(Object.assign({}, this.inputAudioState), { permissionState: me.PENDING }), (e = this.connectionMilestones) === null || e === void 0 || e.record("microphone_permission_pending"), this.publicEventEmitter.emit(O.MIC_PERMISSION_PENDING);
3754
3754
  try {
3755
3755
  const a = {
3756
3756
  echoCancellation: !0
3757
3757
  };
3758
3758
  this.audioDeviceId && (a.deviceId = {
3759
3759
  exact: this.audioDeviceId
3760
- }), this.inputAudioStream = yield navigator.mediaDevices.getUserMedia({
3760
+ });
3761
+ const s = yield navigator.mediaDevices.getUserMedia({
3761
3762
  audio: a
3762
- }), this.inputAudioState = Object.assign(Object.assign({}, this.inputAudioState), { permissionState: me.GRANTED }), (i = this.connectionMilestones) === null || i === void 0 || i.record("microphone_permission_granted"), this.publicEventEmitter.emit(A.MIC_PERMISSION_GRANTED), yield this.setupAudioTrack();
3763
+ });
3764
+ if (this.iceRestartStopped || !this.peerConnection) {
3765
+ s.getTracks().forEach((c) => c.stop());
3766
+ return;
3767
+ }
3768
+ this.inputAudioStream = s, this.inputAudioState = Object.assign(Object.assign({}, this.inputAudioState), { permissionState: me.GRANTED }), (i = this.connectionMilestones) === null || i === void 0 || i.record("microphone_permission_granted"), this.publicEventEmitter.emit(O.MIC_PERMISSION_GRANTED), yield this.setupAudioTrack();
3763
3769
  } catch (a) {
3764
3770
  console.error("Failed to get microphone permission:", a), this.inputAudioState = Object.assign(Object.assign({}, this.inputAudioState), { permissionState: me.DENIED }), (n = this.connectionMilestones) === null || n === void 0 || n.record("microphone_permission_denied", Object.assign({}, $e(a)));
3765
3771
  const s = a instanceof Error ? a.message : String(a);
3766
- this.publicEventEmitter.emit(A.MIC_PERMISSION_DENIED, s);
3772
+ this.publicEventEmitter.emit(O.MIC_PERMISSION_DENIED, s);
3767
3773
  }
3768
3774
  }
3769
3775
  });
@@ -3772,7 +3778,7 @@ class kr {
3772
3778
  * Set up audio track and add it to the peer connection using replaceTrack
3773
3779
  */
3774
3780
  setupAudioTrack() {
3775
- return K(this, void 0, void 0, function* () {
3781
+ return Z(this, void 0, void 0, function* () {
3776
3782
  var e;
3777
3783
  if (!this.peerConnection || !this.inputAudioStream)
3778
3784
  return;
@@ -3795,11 +3801,11 @@ class kr {
3795
3801
  this.peerConnection.addTrack(i, this.inputAudioStream);
3796
3802
  (e = this.connectionMilestones) === null || e === void 0 || e.record("input_audio_stream_started", {
3797
3803
  audioTrackCount: this.inputAudioStream.getAudioTracks().length
3798
- }), this.publicEventEmitter.emit(A.INPUT_AUDIO_STREAM_STARTED, this.inputAudioStream);
3804
+ }), this.publicEventEmitter.emit(O.INPUT_AUDIO_STREAM_STARTED, this.inputAudioStream);
3799
3805
  });
3800
3806
  }
3801
3807
  initPeerConnectionAndSendOffer() {
3802
- return K(this, void 0, void 0, function* () {
3808
+ return Z(this, void 0, void 0, function* () {
3803
3809
  var e, i, n, a, s, c;
3804
3810
  if (yield this.initPeerConnection(), !this.peerConnection) {
3805
3811
  console.error("StreamingClient - initPeerConnectionAndSendOffer: peer connection is not initialized");
@@ -3818,7 +3824,7 @@ class kr {
3818
3824
  });
3819
3825
  }
3820
3826
  shutdown() {
3821
- return K(this, void 0, void 0, function* () {
3827
+ return Z(this, void 0, void 0, function* () {
3822
3828
  var e;
3823
3829
  if (this.iceRestartStopped = !0, this.cancelIceRestart(), this.showPeerConnectionStatsReport) {
3824
3830
  const i = yield (e = this.peerConnection) === null || e === void 0 ? void 0 : e.getStats();
@@ -3876,7 +3882,7 @@ const yt = (t) => {
3876
3882
  };
3877
3883
  class Lr {
3878
3884
  constructor(e, i) {
3879
- this.reasoning_messages = [], this.publicEventEmitter = e, this.internalEventEmitter = i, this.internalEventEmitter.addListener(U.WEBRTC_REASONING_TEXT_MESSAGE_RECEIVED, this.processWebRtcReasoningTextMessageEvent.bind(this));
3885
+ this.reasoning_messages = [], this.publicEventEmitter = e, this.internalEventEmitter = i, this.internalEventEmitter.addListener(B.WEBRTC_REASONING_TEXT_MESSAGE_RECEIVED, this.processWebRtcReasoningTextMessageEvent.bind(this));
3880
3886
  }
3881
3887
  webRtcTextMessageEventToReasoningStreamEvent(e) {
3882
3888
  return {
@@ -3888,7 +3894,7 @@ class Lr {
3888
3894
  }
3889
3895
  processWebRtcReasoningTextMessageEvent(e) {
3890
3896
  const i = this.webRtcTextMessageEventToReasoningStreamEvent(e);
3891
- this.publicEventEmitter.emit(A.REASONING_STREAM_EVENT_RECEIVED, i);
3897
+ this.publicEventEmitter.emit(O.REASONING_STREAM_EVENT_RECEIVED, i);
3892
3898
  const n = {
3893
3899
  id: i.id,
3894
3900
  content: i.content,
@@ -3899,7 +3905,7 @@ class Lr {
3899
3905
  s.content += n.content, this.reasoning_messages[a] = s;
3900
3906
  } else
3901
3907
  this.reasoning_messages.push(n);
3902
- i.endOfThought && this.publicEventEmitter.emit(A.REASONING_HISTORY_UPDATED, this.reasoning_messages);
3908
+ i.endOfThought && this.publicEventEmitter.emit(O.REASONING_HISTORY_UPDATED, this.reasoning_messages);
3903
3909
  }
3904
3910
  }
3905
3911
  var fe = function(t, e, i, n) {
@@ -3909,24 +3915,24 @@ var fe = function(t, e, i, n) {
3909
3915
  });
3910
3916
  }
3911
3917
  return new (i || (i = Promise))(function(s, c) {
3912
- function l(f) {
3918
+ function l(p) {
3913
3919
  try {
3914
- p(n.next(f));
3920
+ f(n.next(p));
3915
3921
  } catch (u) {
3916
3922
  c(u);
3917
3923
  }
3918
3924
  }
3919
- function m(f) {
3925
+ function m(p) {
3920
3926
  try {
3921
- p(n.throw(f));
3927
+ f(n.throw(p));
3922
3928
  } catch (u) {
3923
3929
  c(u);
3924
3930
  }
3925
3931
  }
3926
- function p(f) {
3927
- f.done ? s(f.value) : a(f.value).then(l, m);
3932
+ function f(p) {
3933
+ p.done ? s(p.value) : a(p.value).then(l, m);
3928
3934
  }
3929
- p((n = n.apply(t, e || [])).next());
3935
+ f((n = n.apply(t, e || [])).next());
3930
3936
  });
3931
3937
  };
3932
3938
  class Mr {
@@ -3936,9 +3942,9 @@ class Mr {
3936
3942
  isMuted: !1,
3937
3943
  permissionState: me.NOT_REQUESTED
3938
3944
  }, this.sessionId = null, this.organizationId = null, this.streamingClient = null, this._isStreaming = !1;
3939
- const p = this.validateClientConfig(e, i, n);
3940
- if (p)
3941
- throw new F(p, q.CLIENT_ERROR_CODE_CONFIGURATION_ERROR, 400);
3945
+ const f = this.validateClientConfig(e, i, n);
3946
+ if (f)
3947
+ throw new V(f, J.CLIENT_ERROR_CODE_CONFIGURATION_ERROR, 400);
3942
3948
  this.personaConfig = i, this.clientOptions = n, (!((a = n?.api) === null || a === void 0) && a.baseUrl || !((s = n?.api) === null || s === void 0) && s.apiVersion) && tr(n.api.baseUrl || rn, n.api.apiVersion || $t), !((l = (c = n?.api) === null || c === void 0 ? void 0 : c.apiGateway) === null || l === void 0) && l.enabled && ir(n.api.apiGateway), !((m = n?.metrics) === null || m === void 0) && m.disableClientMetrics && nr(!0), this.publicEventEmitter = new wr(), this.internalEventEmitter = new Ir(), this.toolCallManager = new un(this.publicEventEmitter, this.internalEventEmitter), this.apiClient = new Er(e, n?.apiKey, n?.api), this.messageHistoryClient = new br(this.publicEventEmitter, this.internalEventEmitter), this.reasoningHistoryClient = new Lr(this.publicEventEmitter, this.internalEventEmitter);
3943
3949
  }
3944
3950
  decodeJwt(e) {
@@ -4008,17 +4014,17 @@ class Mr {
4008
4014
  }
4009
4015
  startSession(e, i) {
4010
4016
  return fe(this, void 0, void 0, function* () {
4011
- var n, a, s, c, l, m, p, f, u, T, E, S, y, I, w, b, O;
4012
- const N = this.personaConfig, R = this.buildStartSessionOptionsForClient();
4017
+ var n, a, s, c, l, m, f, p, u, y, E, T, I, w, A, R, b;
4018
+ const N = this.personaConfig, S = this.buildStartSessionOptionsForClient();
4013
4019
  i?.record("start_session_request_started");
4014
- let Z;
4020
+ let k;
4015
4021
  try {
4016
- Z = yield this.apiClient.startSession(N, R), i?.record("start_session_request_completed");
4017
- } catch (ne) {
4018
- throw i?.record("start_session_request_failed", Object.assign({}, Oe(ne))), i?.publishFailure(Object.assign({ failureStage: "start_session_request" }, Oe(ne))), ne;
4022
+ k = yield this.apiClient.startSession(N, S), i?.record("start_session_request_completed");
4023
+ } catch (re) {
4024
+ throw i?.record("start_session_request_failed", Object.assign({}, Oe(re))), i?.publishFailure(Object.assign({ failureStage: "start_session_request" }, Oe(re))), re;
4019
4025
  }
4020
- const { sessionId: G, clientConfig: re, engineHost: te, engineProtocol: oe, signallingEndpoint: z } = Z, { heartbeatIntervalSeconds: Q, maxWsReconnectionAttempts: de, iceServers: ue, iceTransportPolicy: Se } = re;
4021
- this.sessionId = G, this.toolCallManager.setActiveSession(G), Fe({
4026
+ const { sessionId: U, clientConfig: z, engineHost: Y, engineProtocol: oe, signallingEndpoint: K } = k, { heartbeatIntervalSeconds: te, maxWsReconnectionAttempts: de, iceServers: ue, iceTransportPolicy: Se } = z;
4027
+ this.sessionId = U, this.toolCallManager.setActiveSession(U), Fe({
4022
4028
  sessionId: this.sessionId
4023
4029
  }), i?.updateContext({
4024
4030
  sessionId: this.sessionId,
@@ -4026,17 +4032,17 @@ class Mr {
4026
4032
  });
4027
4033
  const Te = (l = (a = (n = this.clientOptions) === null || n === void 0 ? void 0 : n.iceServers) !== null && a !== void 0 ? a : (c = (s = this.clientOptions) === null || s === void 0 ? void 0 : s.rtcConfiguration) === null || c === void 0 ? void 0 : c.iceServers) !== null && l !== void 0 ? l : ue;
4028
4034
  try {
4029
- this.streamingClient = new kr(G, {
4035
+ this.streamingClient = new kr(U, {
4030
4036
  engine: {
4031
- baseUrl: `${oe}://${te}`
4037
+ baseUrl: `${oe}://${Y}`
4032
4038
  },
4033
4039
  signalling: {
4034
- heartbeatIntervalSeconds: Q,
4040
+ heartbeatIntervalSeconds: te,
4035
4041
  maxWsReconnectionAttempts: de,
4036
4042
  url: {
4037
- baseUrl: te,
4043
+ baseUrl: Y,
4038
4044
  protocol: oe,
4039
- signallingPath: z
4045
+ signallingPath: K
4040
4046
  }
4041
4047
  },
4042
4048
  iceServers: Te,
@@ -4044,25 +4050,25 @@ class Mr {
4044
4050
  rtcConfiguration: (m = this.clientOptions) === null || m === void 0 ? void 0 : m.rtcConfiguration,
4045
4051
  inputAudio: {
4046
4052
  inputAudioState: this.inputAudioState,
4047
- userProvidedMediaStream: !((p = this.clientOptions) === null || p === void 0) && p.disableInputAudio ? void 0 : e,
4048
- audioDeviceId: (f = this.clientOptions) === null || f === void 0 ? void 0 : f.audioDeviceId,
4053
+ userProvidedMediaStream: !((f = this.clientOptions) === null || f === void 0) && f.disableInputAudio ? void 0 : e,
4054
+ audioDeviceId: (p = this.clientOptions) === null || p === void 0 ? void 0 : p.audioDeviceId,
4049
4055
  disableInputAudio: (u = this.clientOptions) === null || u === void 0 ? void 0 : u.disableInputAudio
4050
4056
  },
4051
- apiGateway: (E = (T = this.clientOptions) === null || T === void 0 ? void 0 : T.api) === null || E === void 0 ? void 0 : E.apiGateway,
4057
+ apiGateway: (E = (y = this.clientOptions) === null || y === void 0 ? void 0 : y.api) === null || E === void 0 ? void 0 : E.apiGateway,
4052
4058
  metrics: {
4053
- showPeerConnectionStatsReport: (I = (y = (S = this.clientOptions) === null || S === void 0 ? void 0 : S.metrics) === null || y === void 0 ? void 0 : y.showPeerConnectionStatsReport) !== null && I !== void 0 ? I : !1,
4054
- peerConnectionStatsReportOutputFormat: (O = (b = (w = this.clientOptions) === null || w === void 0 ? void 0 : w.metrics) === null || b === void 0 ? void 0 : b.peerConnectionStatsReportOutputFormat) !== null && O !== void 0 ? O : "console"
4059
+ showPeerConnectionStatsReport: (w = (I = (T = this.clientOptions) === null || T === void 0 ? void 0 : T.metrics) === null || I === void 0 ? void 0 : I.showPeerConnectionStatsReport) !== null && w !== void 0 ? w : !1,
4060
+ peerConnectionStatsReportOutputFormat: (b = (R = (A = this.clientOptions) === null || A === void 0 ? void 0 : A.metrics) === null || R === void 0 ? void 0 : R.peerConnectionStatsReportOutputFormat) !== null && b !== void 0 ? b : "console"
4055
4061
  }
4056
4062
  }, this.publicEventEmitter, this.internalEventEmitter, this.toolCallManager, i);
4057
- } catch (ne) {
4058
- throw i?.publishFailure(Object.assign({ failureStage: "streaming_client_initialization" }, Oe(ne))), this.toolCallManager.clearSessionState(), Fe({
4063
+ } catch (re) {
4064
+ throw i?.publishFailure(Object.assign({ failureStage: "streaming_client_initialization" }, Oe(re))), this.toolCallManager.clearSessionState(), Fe({
4059
4065
  sessionId: null
4060
- }), new F("Failed to initialize streaming client", q.CLIENT_ERROR_CODE_SERVER_ERROR, 500, {
4061
- cause: ne instanceof Error ? ne.message : String(ne),
4062
- sessionId: G
4066
+ }), new V("Failed to initialize streaming client", J.CLIENT_ERROR_CODE_SERVER_ERROR, 500, {
4067
+ cause: re instanceof Error ? re.message : String(re),
4068
+ sessionId: U
4063
4069
  });
4064
4070
  }
4065
- return G;
4071
+ return U;
4066
4072
  });
4067
4073
  }
4068
4074
  startSessionIfNeeded(e, i) {
@@ -4070,7 +4076,7 @@ class Mr {
4070
4076
  if ((!this.sessionId || !this.streamingClient) && (yield this.startSession(e, i), !this.sessionId || !this.streamingClient))
4071
4077
  throw i?.publishFailure({
4072
4078
  failureStage: "start_session_validation"
4073
- }), new F("Session ID or streaming client is not available after starting session", q.CLIENT_ERROR_CODE_SERVER_ERROR, 500, {
4079
+ }), new V("Session ID or streaming client is not available after starting session", J.CLIENT_ERROR_CODE_SERVER_ERROR, 500, {
4074
4080
  cause: "Failed to initialize session properly"
4075
4081
  });
4076
4082
  });
@@ -4091,10 +4097,10 @@ class Mr {
4091
4097
  var s;
4092
4098
  const c = [];
4093
4099
  let l = !1, m = !1;
4094
- this.publicEventEmitter.addListener(A.VIDEO_STREAM_STARTED, (p) => {
4095
- c.push(p), l = !0, m && a(c);
4096
- }), this.publicEventEmitter.addListener(A.AUDIO_STREAM_STARTED, (p) => {
4097
- c.push(p), m = !0, l && a(c);
4100
+ this.publicEventEmitter.addListener(O.VIDEO_STREAM_STARTED, (f) => {
4101
+ c.push(f), l = !0, m && a(c);
4102
+ }), this.publicEventEmitter.addListener(O.AUDIO_STREAM_STARTED, (f) => {
4103
+ c.push(f), m = !0, l && a(c);
4098
4104
  }), (s = this.streamingClient) === null || s === void 0 || s.startConnection();
4099
4105
  });
4100
4106
  });
@@ -4115,7 +4121,7 @@ class Mr {
4115
4121
  try {
4116
4122
  yield this.startSessionIfNeeded(i, a);
4117
4123
  } catch (s) {
4118
- throw a.publishFailure(Object.assign({ failureStage: "start_session" }, Oe(s))), s instanceof F ? s : new F("Failed to start session", q.CLIENT_ERROR_CODE_SERVER_ERROR, 500, {
4124
+ throw a.publishFailure(Object.assign({ failureStage: "start_session" }, Oe(s))), s instanceof V ? s : new V("Failed to start session", J.CLIENT_ERROR_CODE_SERVER_ERROR, 500, {
4119
4125
  cause: s instanceof Error ? s.message : String(s),
4120
4126
  sessionId: this.sessionId
4121
4127
  });
@@ -4215,7 +4221,7 @@ class Mr {
4215
4221
  }
4216
4222
  stopStreaming() {
4217
4223
  return fe(this, void 0, void 0, function* () {
4218
- this.streamingClient && (this.publicEventEmitter.emit(A.CONNECTION_CLOSED, Ee.NORMAL), this.toolCallManager.clearSessionState(), yield this.streamingClient.stopConnection(), this.streamingClient = null, this.sessionId = null, Fe({
4224
+ this.streamingClient && (this.publicEventEmitter.emit(O.CONNECTION_CLOSED, Ee.NORMAL), this.toolCallManager.clearSessionState(), yield this.streamingClient.stopConnection(), this.streamingClient = null, this.sessionId = null, Fe({
4219
4225
  attemptCorrelationId: null,
4220
4226
  sessionId: null,
4221
4227
  organizationId: this.organizationId
@@ -4283,7 +4289,7 @@ class Mr {
4283
4289
  return this.toolCallManager.registerHandler(e, i);
4284
4290
  }
4285
4291
  }
4286
- const Oe = (t) => t instanceof F ? {
4292
+ const Oe = (t) => t instanceof V ? {
4287
4293
  errorName: t.name,
4288
4294
  errorCode: t.code,
4289
4295
  httpStatusCode: t.statusCode
@@ -4360,7 +4366,7 @@ const Br = () => /* @__PURE__ */ C("svg", { width: "14", height: "14", viewBox:
4360
4366
  function Vr(t) {
4361
4367
  return $r[t.kind](t.data);
4362
4368
  }
4363
- const X = {
4369
+ const ee = {
4364
4370
  SESSION_STARTED: "anam-agent:session-started",
4365
4371
  SESSION_ENDED: "anam-agent:session-ended",
4366
4372
  MESSAGE_RECEIVED: "anam-agent:message-received",
@@ -4392,31 +4398,32 @@ function jr(t, e) {
4392
4398
  }
4393
4399
  function Gr() {
4394
4400
  return {
4395
- client: H(null),
4396
- connectionStatus: H("idle"),
4397
- isStreaming: H(!1),
4398
- isMuted: H(!1),
4399
- messages: H([]),
4401
+ client: q(null),
4402
+ connectionStatus: q("idle"),
4403
+ isStreaming: q(!1),
4404
+ isMuted: q(!1),
4405
+ messages: q([]),
4400
4406
  messageTimes: /* @__PURE__ */ new Map(),
4401
4407
  pendingSent: [],
4402
4408
  messageSeq: /* @__PURE__ */ new Map(),
4403
4409
  seqCounter: 0,
4404
4410
  localIdCounter: 0,
4405
- toolBlocks: H([]),
4411
+ toolBlocks: q([]),
4406
4412
  seenToolCallIds: /* @__PURE__ */ new Set(),
4407
- caption: H(null),
4413
+ caption: q(null),
4408
4414
  captionTimer: null,
4409
- sentCaption: H(null),
4415
+ sentCaption: q(null),
4410
4416
  sentCaptionTimer: null,
4411
- error: H(null),
4412
- sessionId: H(null),
4413
- avatarThumbnailUrl: H(null),
4414
- avatarVideoUrl: H(null),
4415
- personaName: H(null),
4416
- serverConfig: H(null),
4417
- isConfigured: H(!1),
4418
- isReady: H(!1),
4417
+ error: q(null),
4418
+ sessionId: q(null),
4419
+ avatarThumbnailUrl: q(null),
4420
+ avatarVideoUrl: q(null),
4421
+ personaName: q(null),
4422
+ serverConfig: q(null),
4423
+ isConfigured: q(!1),
4424
+ isReady: q(!1),
4419
4425
  generation: 0,
4426
+ stopAttempt: null,
4420
4427
  prevMessageCount: 0,
4421
4428
  dispatch: null
4422
4429
  };
@@ -4462,128 +4469,163 @@ async function qr(t, e, i, n, a) {
4462
4469
  return;
4463
4470
  const s = ++t.generation;
4464
4471
  Vt(t), t.connectionStatus.value = "connecting", t.error.value = null;
4465
- let c;
4472
+ let c, l = null, m = "", f = !1, p = null, u, y;
4473
+ const E = new AbortController(), T = () => {
4474
+ clearInterval(u), clearTimeout(y), u = void 0;
4475
+ }, I = () => {
4476
+ if (!l) return !1;
4477
+ const b = l.getActiveSessionId();
4478
+ try {
4479
+ l.stopStreaming().catch(() => {
4480
+ });
4481
+ } catch {
4482
+ }
4483
+ if (b && !f && p !== b) {
4484
+ p = b;
4485
+ try {
4486
+ fetch(`${i.replace(/\/$/, "")}/api/sessions/${encodeURIComponent(b)}/release`, {
4487
+ method: "POST",
4488
+ credentials: "same-origin",
4489
+ keepalive: !0,
4490
+ headers: { Authorization: `Bearer ${m}` }
4491
+ }).catch(() => {
4492
+ });
4493
+ } catch {
4494
+ }
4495
+ }
4496
+ return !!b;
4497
+ }, w = () => {
4498
+ if (clearTimeout(R), E.abort(), I()) {
4499
+ T();
4500
+ return;
4501
+ }
4502
+ l && !u && !p && (u = setInterval(() => {
4503
+ l?.getActiveSessionId() && I() && T();
4504
+ }, 100), y = setTimeout(T, 45e3));
4505
+ }, A = (b, N = "SESSION_ERROR") => {
4506
+ s === t.generation && (t.generation++, t.stopAttempt = null, w(), t.client.value = null, t.isStreaming.value = !1, t.sessionId.value = null, t.error.value = b, t.connectionStatus.value = "error", t.dispatch?.(ee.ERROR, { code: N, message: b }));
4507
+ }, R = setTimeout(() => A(
4508
+ "Taking too long to connect. Check your network and try again.",
4509
+ "STARTUP_TIMEOUT"
4510
+ ), 45e3);
4511
+ t.stopAttempt = w;
4466
4512
  try {
4467
- let l;
4468
4513
  if (a)
4469
- l = a;
4514
+ m = a;
4470
4515
  else {
4471
4516
  if (!hn(e))
4472
4517
  throw new Error("Invalid agent ID format");
4473
- const f = await fetch(`${i}/v1/auth/widget`, {
4518
+ const S = await fetch(`${i}/v1/auth/widget`, {
4474
4519
  method: "POST",
4475
4520
  headers: { "Content-Type": "application/json" },
4476
- body: JSON.stringify({ agentId: e })
4521
+ body: JSON.stringify({ agentId: e }),
4522
+ signal: E.signal
4477
4523
  });
4478
4524
  if (s !== t.generation) return;
4479
- if (c = f.status, !f.ok) {
4480
- const T = await f.json().catch(() => ({}));
4481
- throw new Error(T.error || `HTTP ${f.status}`);
4525
+ if (c = S.status, !S.ok) {
4526
+ const U = await S.json().catch(() => ({}));
4527
+ throw new Error(U.error || `HTTP ${S.status}`);
4482
4528
  }
4483
- l = (await f.json()).sessionToken;
4529
+ m = (await S.json()).sessionToken;
4484
4530
  }
4485
4531
  if (s !== t.generation) return;
4486
- const m = Dr(l, {
4532
+ const b = Dr(m, {
4487
4533
  api: i ? { baseUrl: i } : void 0,
4488
4534
  metrics: { disableClientMetrics: !0 }
4489
4535
  });
4490
- m.addListener(A.CONNECTION_ESTABLISHED, () => {
4536
+ l = b, t.client.value = b, b.addListener(O.CONNECTION_ESTABLISHED, () => {
4491
4537
  s === t.generation && (t.connectionStatus.value = "connected");
4492
- }), m.addListener(A.VIDEO_STREAM_STARTED, () => {
4493
- s === t.generation && (t.isStreaming.value = !0);
4494
- }), m.addListener(A.AUDIO_STREAM_STARTED, () => {
4495
- }), m.addListener(A.MESSAGE_HISTORY_UPDATED, (f) => {
4538
+ }), b.addListener(O.AUDIO_STREAM_STARTED, () => {
4539
+ }), b.addListener(O.MESSAGE_HISTORY_UPDATED, (S) => {
4496
4540
  if (s !== t.generation) return;
4497
- for (let E = t.prevMessageCount; E < f.length; E++) {
4498
- const S = f[E];
4499
- t.dispatch?.(X.MESSAGE_RECEIVED, {
4500
- role: S.role === "persona" ? "agent" : "user",
4501
- content: S.content
4541
+ for (let z = t.prevMessageCount; z < S.length; z++) {
4542
+ const Y = S[z];
4543
+ t.dispatch?.(ee.MESSAGE_RECEIVED, {
4544
+ role: Y.role === "persona" ? "agent" : "user",
4545
+ content: Y.content
4502
4546
  });
4503
4547
  }
4504
- t.prevMessageCount = f.length;
4505
- const u = Hr(t, f), T = (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
4506
- for (const E of u)
4507
- t.messageTimes.has(E.id) || t.messageTimes.set(E.id, T);
4508
- t.messages.value = u;
4509
- }), m.addListener(A.MESSAGE_STREAM_EVENT_RECEIVED, (f) => {
4548
+ t.prevMessageCount = S.length;
4549
+ const k = Hr(t, S), U = (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
4550
+ for (const z of k)
4551
+ t.messageTimes.has(z.id) || t.messageTimes.set(z.id, U);
4552
+ t.messages.value = k;
4553
+ }), b.addListener(O.MESSAGE_STREAM_EVENT_RECEIVED, (S) => {
4510
4554
  if (s !== t.generation) return;
4511
4555
  t.captionTimer && (clearTimeout(t.captionTimer), t.captionTimer = null);
4512
- const u = t.caption.value, T = f.role === ve.PERSONA && u?.id === f.id ? u.content + f.content : f.content;
4513
- t.caption.value = { id: f.id, role: f.role, content: T, at: Date.now() }, f.endOfSpeech && (t.captionTimer = window.setTimeout(() => {
4556
+ const k = t.caption.value, U = S.role === ve.PERSONA && k?.id === S.id ? k.content + S.content : S.content;
4557
+ t.caption.value = { id: S.id, role: S.role, content: U, at: Date.now() }, S.endOfSpeech && (t.captionTimer = window.setTimeout(() => {
4514
4558
  t.caption.value = null, t.captionTimer = null;
4515
4559
  }, 4e3));
4516
- }), m.addListener(A.TOOL_CALL_STARTED, (f) => {
4560
+ }), b.addListener(O.TOOL_CALL_STARTED, (S) => {
4517
4561
  if (s !== t.generation) return;
4518
- t.dispatch?.(X.TOOL_CALL_STARTED, {
4519
- toolName: f.toolName,
4520
- toolCallId: f.toolCallId,
4521
- toolType: f.toolType,
4522
- toolSubtype: f.toolSubtype,
4523
- arguments: f.arguments
4562
+ t.dispatch?.(ee.TOOL_CALL_STARTED, {
4563
+ toolName: S.toolName,
4564
+ toolCallId: S.toolCallId,
4565
+ toolType: S.toolType,
4566
+ toolSubtype: S.toolSubtype,
4567
+ arguments: S.arguments
4524
4568
  });
4525
- const u = Pr(f.toolName, f.toolCallId, f.arguments);
4526
- u && !t.seenToolCallIds.has(f.toolCallId) && (t.seenToolCallIds.add(f.toolCallId), t.messageSeq.set(u.id, t.seqCounter++), t.messageTimes.set(u.id, (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })), t.toolBlocks.value = [...t.toolBlocks.value, u]);
4527
- }), m.addListener(A.TOOL_CALL_COMPLETED, (f) => {
4528
- s === t.generation && t.dispatch?.(X.TOOL_CALL_COMPLETED, {
4529
- toolName: f.toolName,
4530
- toolCallId: f.toolCallId,
4531
- toolType: f.toolType,
4532
- toolSubtype: f.toolSubtype,
4533
- result: f.result,
4534
- executionTime: f.executionTime,
4535
- documentsAccessed: f.documentsAccessed
4569
+ const k = Pr(S.toolName, S.toolCallId, S.arguments);
4570
+ k && !t.seenToolCallIds.has(S.toolCallId) && (t.seenToolCallIds.add(S.toolCallId), t.messageSeq.set(k.id, t.seqCounter++), t.messageTimes.set(k.id, (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })), t.toolBlocks.value = [...t.toolBlocks.value, k]);
4571
+ }), b.addListener(O.TOOL_CALL_COMPLETED, (S) => {
4572
+ s === t.generation && t.dispatch?.(ee.TOOL_CALL_COMPLETED, {
4573
+ toolName: S.toolName,
4574
+ toolCallId: S.toolCallId,
4575
+ toolType: S.toolType,
4576
+ toolSubtype: S.toolSubtype,
4577
+ result: S.result,
4578
+ executionTime: S.executionTime,
4579
+ documentsAccessed: S.documentsAccessed
4536
4580
  });
4537
- }), m.addListener(A.TOOL_CALL_FAILED, (f) => {
4538
- s === t.generation && t.dispatch?.(X.TOOL_CALL_FAILED, {
4539
- toolName: f.toolName,
4540
- toolCallId: f.toolCallId,
4541
- toolType: f.toolType,
4542
- toolSubtype: f.toolSubtype,
4543
- errorMessage: f.errorMessage,
4544
- executionTime: f.executionTime
4581
+ }), b.addListener(O.TOOL_CALL_FAILED, (S) => {
4582
+ s === t.generation && t.dispatch?.(ee.TOOL_CALL_FAILED, {
4583
+ toolName: S.toolName,
4584
+ toolCallId: S.toolCallId,
4585
+ toolType: S.toolType,
4586
+ toolSubtype: S.toolSubtype,
4587
+ errorMessage: S.errorMessage,
4588
+ executionTime: S.executionTime
4545
4589
  });
4546
- }), m.addListener(A.CONNECTION_CLOSED, (f, u) => {
4590
+ }), b.addListener(O.CONNECTION_CLOSED, (S, k) => {
4547
4591
  if (s !== t.generation) return;
4548
- const T = t.sessionId.value;
4549
- t.connectionStatus.value = "idle", t.isStreaming.value = !1, t.sessionId.value = null, t.dispatch?.(X.SESSION_ENDED, {
4550
- sessionId: T ?? "",
4551
- reason: u ?? f
4592
+ if (!t.isStreaming.value) {
4593
+ A("The connection ended before playback. Please try again.");
4594
+ return;
4595
+ }
4596
+ const U = t.sessionId.value;
4597
+ t.generation++, t.stopAttempt = null, w(), t.client.value = null, t.connectionStatus.value = "idle", t.isStreaming.value = !1, t.sessionId.value = null, t.dispatch?.(ee.SESSION_ENDED, {
4598
+ sessionId: U ?? "",
4599
+ reason: k ?? S
4552
4600
  });
4553
- }), m.addListener(A.SESSION_READY, (f) => {
4554
- s === t.generation && (t.sessionId.value = f, t.dispatch?.(X.SESSION_STARTED, { sessionId: f }));
4601
+ }), b.addListener(O.SESSION_READY, (S) => {
4602
+ s === t.generation && (f = !0, t.sessionId.value = S, t.dispatch?.(ee.SESSION_STARTED, { sessionId: S }));
4555
4603
  });
4556
- const p = await m.stream();
4604
+ const N = await b.stream();
4557
4605
  if (s !== t.generation) {
4558
- try {
4559
- await m.stopStreaming();
4560
- } catch {
4561
- }
4606
+ w();
4562
4607
  return;
4563
4608
  }
4564
- if (t.client.value = m, n && p.length > 0) {
4565
- const f = p.find((u) => u.getVideoTracks().length > 0);
4566
- f && (n.srcObject = f);
4609
+ if (n && N.length > 0) {
4610
+ const S = N.find((k) => k.getVideoTracks().length > 0);
4611
+ if (S) {
4612
+ if (n.srcObject = S, await n.play(), s !== t.generation) return;
4613
+ t.isStreaming.value = !0, clearTimeout(R);
4614
+ }
4567
4615
  }
4568
- } catch (l) {
4569
- if (s !== t.generation) return;
4570
- console.error("[AnamWidget] Failed to start session:", l);
4571
- const m = jr(l, c);
4572
- t.error.value = m, t.connectionStatus.value = "error", t.client.value = null, t.dispatch?.(X.ERROR, {
4573
- code: c ? `HTTP_${c}` : "SESSION_ERROR",
4574
- message: m
4575
- });
4616
+ } catch (b) {
4617
+ if (s !== t.generation) {
4618
+ w();
4619
+ return;
4620
+ }
4621
+ A(jr(b, c), c ? `HTTP_${c}` : "SESSION_ERROR");
4576
4622
  }
4577
4623
  }
4578
4624
  async function Yr(t) {
4579
4625
  const e = t.sessionId.value, i = t.connectionStatus.value !== "idle";
4580
- if (t.generation++, t.client.value)
4581
- try {
4582
- await t.client.value.stopStreaming();
4583
- } catch (n) {
4584
- console.error("[AnamWidget] Failed to stop session:", n);
4585
- }
4586
- t.client.value = null, t.connectionStatus.value = "idle", t.isStreaming.value = !1, t.isMuted.value = !1, Vt(t), t.captionTimer && clearTimeout(t.captionTimer), t.captionTimer = null, t.caption.value = null, t.sentCaptionTimer && clearTimeout(t.sentCaptionTimer), t.sentCaptionTimer = null, t.sentCaption.value = null, t.sessionId.value = null, i && t.dispatch?.(X.SESSION_ENDED, {
4626
+ t.generation++;
4627
+ const n = t.stopAttempt;
4628
+ t.stopAttempt = null, t.client.value = null, t.connectionStatus.value = "idle", t.isStreaming.value = !1, t.isMuted.value = !1, Vt(t), t.captionTimer && clearTimeout(t.captionTimer), t.captionTimer = null, t.caption.value = null, t.sentCaptionTimer && clearTimeout(t.sentCaptionTimer), t.sentCaptionTimer = null, t.sentCaption.value = null, t.sessionId.value = null, n?.(), i && t.dispatch?.(ee.SESSION_ENDED, {
4587
4629
  sessionId: e ?? "",
4588
4630
  reason: "USER_ENDED"
4589
4631
  });
@@ -4598,13 +4640,13 @@ function Kr(t, e) {
4598
4640
  };
4599
4641
  t.messageSeq.set(i.id, t.seqCounter++), t.messageTimes.set(i.id, (/* @__PURE__ */ new Date()).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" })), t.pendingSent.push(i), t.messages.value = [...t.messages.value, i], t.sentCaptionTimer && clearTimeout(t.sentCaptionTimer), t.sentCaption.value = { id: i.id, role: ve.USER, content: e, at: Date.now() }, t.sentCaptionTimer = window.setTimeout(() => {
4600
4642
  t.sentCaption.value = null, t.sentCaptionTimer = null;
4601
- }, 4e3), t.dispatch?.(X.MESSAGE_SENT, { content: e });
4643
+ }, 4e3), t.dispatch?.(ee.MESSAGE_SENT, { content: e });
4602
4644
  }
4603
4645
  function Jr(t) {
4604
- t.client.value && (t.isMuted.value ? (t.client.value.unmuteInputAudio(), t.isMuted.value = !1, t.dispatch?.(X.MIC_UNMUTED, {})) : (t.client.value.muteInputAudio(), t.isMuted.value = !0, t.dispatch?.(X.MIC_MUTED, {})));
4646
+ t.client.value && (t.isMuted.value ? (t.client.value.unmuteInputAudio(), t.isMuted.value = !1, t.dispatch?.(ee.MIC_UNMUTED, {})) : (t.client.value.muteInputAudio(), t.isMuted.value = !0, t.dispatch?.(ee.MIC_MUTED, {})));
4605
4647
  }
4606
4648
  function Xr(t) {
4607
- t.generation++, t.client.value?.isStreaming() && t.client.value.stopStreaming(), t.client.value = null, t.connectionStatus.value = "idle", t.isStreaming.value = !1, t.isMuted.value = !1, Vt(t), t.captionTimer && clearTimeout(t.captionTimer), t.captionTimer = null, t.caption.value = null, t.sentCaptionTimer && clearTimeout(t.sentCaptionTimer), t.sentCaptionTimer = null, t.sentCaption.value = null, t.error.value = null, t.sessionId.value = null, t.avatarThumbnailUrl.value = null, t.avatarVideoUrl.value = null, t.personaName.value = null, t.serverConfig.value = null;
4649
+ t.generation++, t.stopAttempt?.(), t.stopAttempt = null, t.client.value = null, t.connectionStatus.value = "idle", t.isStreaming.value = !1, t.isMuted.value = !1, Vt(t), t.captionTimer && clearTimeout(t.captionTimer), t.captionTimer = null, t.caption.value = null, t.sentCaptionTimer && clearTimeout(t.sentCaptionTimer), t.sentCaptionTimer = null, t.sentCaption.value = null, t.error.value = null, t.sessionId.value = null, t.avatarThumbnailUrl.value = null, t.avatarVideoUrl.value = null, t.personaName.value = null, t.serverConfig.value = null;
4608
4650
  }
4609
4651
  function Zr(t, e, i, n) {
4610
4652
  const a = qe();
@@ -4638,15 +4680,15 @@ function Zr(t, e, i, n) {
4638
4680
  return;
4639
4681
  }
4640
4682
  if (i) {
4641
- const f = Si(i).widgetConfig;
4642
- f && (typeof f.personaName == "string" && f.personaName && (s.personaName.value = f.personaName), typeof f.avatarImageUrl == "string" && f.avatarImageUrl && (s.avatarThumbnailUrl.value = f.avatarImageUrl), typeof f.avatarVideoUrl == "string" && f.avatarVideoUrl && (s.avatarVideoUrl.value = f.avatarVideoUrl), f.removeWatermark === !0 && (s.serverConfig.value = { removeWatermark: !0 })), s.isReady.value = !0;
4683
+ const p = Si(i).widgetConfig;
4684
+ p && (typeof p.personaName == "string" && p.personaName && (s.personaName.value = p.personaName), typeof p.avatarImageUrl == "string" && p.avatarImageUrl && (s.avatarThumbnailUrl.value = p.avatarImageUrl), typeof p.avatarVideoUrl == "string" && p.avatarVideoUrl && (s.avatarVideoUrl.value = p.avatarVideoUrl), p.removeWatermark === !0 && (s.serverConfig.value = { removeWatermark: !0 })), s.isReady.value = !0;
4643
4685
  return;
4644
4686
  }
4645
4687
  s.isReady.value = !0;
4646
4688
  },
4647
- startSession: (p) => !c && !i ? (s.error.value = "No agent ID or session token configured", Promise.resolve()) : qr(s, c || "", m, p, i),
4689
+ startSession: (f) => !c && !i ? (s.error.value = "No agent ID or session token configured", Promise.resolve()) : qr(s, c || "", m, f, i),
4648
4690
  stopSession: () => Yr(s),
4649
- sendMessage: (p) => Kr(s, p),
4691
+ sendMessage: (f) => Kr(s, f),
4650
4692
  toggleMute: () => Jr(s),
4651
4693
  cleanup: () => Xr(s)
4652
4694
  };
@@ -4754,45 +4796,45 @@ function ho({
4754
4796
  agentName: c,
4755
4797
  onCollapse: l,
4756
4798
  onStop: m,
4757
- dispatch: p
4799
+ dispatch: f
4758
4800
  }) {
4759
- const f = qe(null), [u, T] = Rt(""), E = e.connectionStatus.value === "connected", S = e.connectionStatus.value === "connecting", y = e.connectionStatus.value === "error", I = e.isStreaming.value, w = !S && !E && !y, b = E || I, O = t.orientation ?? "landscape", N = t.showTranscript && b, [R, Z] = Rt(!1), G = qe(null), re = c || "Agent", te = Ve(() => {
4760
- const W = !R;
4761
- Z(W), p(
4762
- W ? X.TRANSCRIPT_OPENED : X.TRANSCRIPT_CLOSED,
4801
+ const p = qe(null), [u, y] = Rt(""), E = e.connectionStatus.value === "connected", T = e.connectionStatus.value === "connecting", I = e.connectionStatus.value === "error", w = e.isStreaming.value, A = !T && !E && !I, R = E || w, b = t.orientation ?? "landscape", N = t.showTranscript && R, [S, k] = Rt(!1), U = qe(null), z = c || "Agent", Y = Ve(() => {
4802
+ const G = !S;
4803
+ k(G), f(
4804
+ G ? ee.TRANSCRIPT_OPENED : ee.TRANSCRIPT_CLOSED,
4763
4805
  {}
4764
4806
  );
4765
- }, [R, p]);
4807
+ }, [S, f]);
4766
4808
  Ie(() => {
4767
- b || Z(!1);
4768
- }, [b]);
4809
+ R || k(!1);
4810
+ }, [R]);
4769
4811
  const oe = e.toolBlocks.value.length;
4770
4812
  Ie(() => {
4771
- oe > 0 && b && N && !R && (Z(!0), p(X.TRANSCRIPT_OPENED, {}));
4813
+ oe > 0 && R && N && !S && (k(!0), f(ee.TRANSCRIPT_OPENED, {}));
4772
4814
  }, [oe]), Ie(() => {
4773
- R && G.current && (G.current.scrollTop = G.current.scrollHeight);
4774
- }, [R]), Ie(() => {
4775
- const W = G.current;
4776
- if (!W || !R) return;
4777
- W.scrollHeight - W.scrollTop - W.clientHeight < 160 && (W.scrollTop = W.scrollHeight);
4778
- }, [e.messages.value, e.toolBlocks.value, R]);
4779
- const z = N && R && O === "landscape", Q = t.showCaptions ? e.caption.value : null, de = e.sentCaption.value, ue = Q && de ? Q.at >= de.at ? Q : de : Q ?? de, Se = Ve(async () => {
4815
+ S && U.current && (U.current.scrollTop = U.current.scrollHeight);
4816
+ }, [S]), Ie(() => {
4817
+ const G = U.current;
4818
+ if (!G || !S) return;
4819
+ G.scrollHeight - G.scrollTop - G.clientHeight < 160 && (G.scrollTop = G.scrollHeight);
4820
+ }, [e.messages.value, e.toolBlocks.value, S]);
4821
+ const K = N && S && b === "landscape", te = t.showCaptions ? e.caption.value : null, de = e.sentCaption.value, ue = te && de ? te.at >= de.at ? te : de : te ?? de, Se = Ve(async () => {
4780
4822
  i.current && await e.startSession(i.current);
4781
4823
  }, [e.startSession]), Te = Ve(() => {
4782
- u.trim() && (e.sendMessage(u.trim()), T(""), f.current?.focus());
4783
- }, [u]), ne = Ve((W) => {
4784
- W.key === "Enter" && !W.shiftKey && (W.preventDefault(), Te());
4824
+ u.trim() && (e.sendMessage(u.trim()), y(""), p.current?.focus());
4825
+ }, [u]), re = Ve((G) => {
4826
+ G.key === "Enter" && !G.shiftKey && (G.preventDefault(), Te());
4785
4827
  }, [Te]), ut = t.showTextInput ? /* @__PURE__ */ C("div", { class: "anam-ctl-input-wrap", children: [
4786
4828
  /* @__PURE__ */ C(
4787
4829
  "input",
4788
4830
  {
4789
- ref: f,
4831
+ ref: p,
4790
4832
  type: "text",
4791
4833
  class: "anam-ctl-input",
4792
4834
  placeholder: "Type a message...",
4793
4835
  value: u,
4794
- onInput: (W) => T(W.target.value),
4795
- onKeyDown: ne,
4836
+ onInput: (G) => y(G.target.value),
4837
+ onKeyDown: re,
4796
4838
  disabled: !E
4797
4839
  }
4798
4840
  ),
@@ -4817,13 +4859,13 @@ function ho({
4817
4859
  }
4818
4860
  ),
4819
4861
  ut,
4820
- N && O === "landscape" && /* @__PURE__ */ C(
4862
+ N && b === "landscape" && /* @__PURE__ */ C(
4821
4863
  "button",
4822
4864
  {
4823
4865
  class: "anam-ctl-btn anam-transcript-toggle",
4824
- onClick: te,
4825
- "aria-expanded": R,
4826
- "aria-label": R ? "Hide transcript" : "Show transcript",
4866
+ onClick: Y,
4867
+ "aria-expanded": S,
4868
+ "aria-label": S ? "Hide transcript" : "Show transcript",
4827
4869
  children: /* @__PURE__ */ C(lo, {})
4828
4870
  }
4829
4871
  )
@@ -4832,23 +4874,23 @@ function ho({
4832
4874
  "div",
4833
4875
  {
4834
4876
  class: "anam-sheet",
4835
- "data-orientation": O,
4836
- "data-transcript": R ? "open" : "closed",
4877
+ "data-orientation": b,
4878
+ "data-transcript": S ? "open" : "closed",
4837
4879
  children: [
4838
- N && O === "portrait" && /* @__PURE__ */ C("div", { class: "anam-transcript-rail", children: /* @__PURE__ */ C("div", { class: "anam-transcript-rail-inner", children: [
4880
+ N && b === "portrait" && /* @__PURE__ */ C("div", { class: "anam-transcript-rail", children: /* @__PURE__ */ C("div", { class: "anam-transcript-rail-inner", children: [
4839
4881
  /* @__PURE__ */ C("div", { class: "anam-transcript-head", children: [
4840
4882
  /* @__PURE__ */ C("span", { class: "anam-transcript-title", children: "Transcript" }),
4841
4883
  /* @__PURE__ */ C(
4842
4884
  "button",
4843
4885
  {
4844
4886
  class: "anam-transcript-collapse",
4845
- onClick: te,
4887
+ onClick: Y,
4846
4888
  "aria-label": "Hide transcript",
4847
4889
  children: /* @__PURE__ */ C(co, {})
4848
4890
  }
4849
4891
  )
4850
4892
  ] }),
4851
- /* @__PURE__ */ C(Ti, { session: e, agentLabel: re, rowsRef: G })
4893
+ /* @__PURE__ */ C(Ti, { session: e, agentLabel: z, rowsRef: U })
4852
4894
  ] }) }),
4853
4895
  /* @__PURE__ */ C("div", { class: "anam-video-region", children: [
4854
4896
  /* @__PURE__ */ C(
@@ -4858,10 +4900,10 @@ function ho({
4858
4900
  class: "anam-video",
4859
4901
  autoplay: !0,
4860
4902
  playsinline: !0,
4861
- "data-hidden": I ? void 0 : "true"
4903
+ "data-hidden": w ? void 0 : "true"
4862
4904
  }
4863
4905
  ),
4864
- w && (e.isConfigured.value ? (
4906
+ A && (e.isConfigured.value ? (
4865
4907
  /* Has agent-id: show avatar or placeholder + CTA pill */
4866
4908
  /* @__PURE__ */ C("div", { class: "anam-overlay-idle", children: [
4867
4909
  a ? /* @__PURE__ */ C(
@@ -4873,8 +4915,8 @@ function ho({
4873
4915
  muted: !0,
4874
4916
  playsinline: !0,
4875
4917
  class: "anam-preview-video",
4876
- onError: (W) => {
4877
- W.target.style.display = "none";
4918
+ onError: (G) => {
4919
+ G.target.style.display = "none";
4878
4920
  }
4879
4921
  }
4880
4922
  ) : null,
@@ -4899,15 +4941,15 @@ function ho({
4899
4941
  /* @__PURE__ */ C("span", { children: "Agent not configured" })
4900
4942
  ] })
4901
4943
  )),
4902
- S && /* @__PURE__ */ C("div", { class: "anam-overlay-loading", children: [
4944
+ T && /* @__PURE__ */ C("div", { class: "anam-overlay-loading", children: [
4903
4945
  /* @__PURE__ */ C("span", { class: "anam-spinner" }),
4904
4946
  /* @__PURE__ */ C("span", { children: "Starting your conversation..." })
4905
4947
  ] }),
4906
- y && /* @__PURE__ */ C("div", { class: "anam-overlay-error", children: [
4948
+ I && /* @__PURE__ */ C("div", { class: "anam-overlay-error", children: [
4907
4949
  /* @__PURE__ */ C("div", { class: "anam-overlay-error-text", children: e.error.value || "Something went wrong" }),
4908
4950
  /* @__PURE__ */ C("button", { class: "anam-retry-btn", onClick: Se, children: "Try Again" })
4909
4951
  ] }),
4910
- (l || m && (E || S || I)) && /* @__PURE__ */ C(
4952
+ (l || m && (E || T || w)) && /* @__PURE__ */ C(
4911
4953
  "button",
4912
4954
  {
4913
4955
  class: "anam-close-btn",
@@ -4916,7 +4958,7 @@ function ho({
4916
4958
  children: /* @__PURE__ */ C(no, {})
4917
4959
  }
4918
4960
  ),
4919
- b && /* @__PURE__ */ C(Ce, { children: [
4961
+ R && /* @__PURE__ */ C(Ce, { children: [
4920
4962
  /* @__PURE__ */ C("div", { class: "anam-scrim" }),
4921
4963
  ue && /* @__PURE__ */ C(
4922
4964
  "div",
@@ -4925,12 +4967,12 @@ function ho({
4925
4967
  children: ue.content
4926
4968
  }
4927
4969
  ),
4928
- !z && Je,
4929
- N && O === "portrait" && !R && /* @__PURE__ */ C(
4970
+ !K && Je,
4971
+ N && b === "portrait" && !S && /* @__PURE__ */ C(
4930
4972
  "button",
4931
4973
  {
4932
4974
  class: "anam-transcript-tab",
4933
- onClick: te,
4975
+ onClick: Y,
4934
4976
  "aria-label": "Show transcript",
4935
4977
  children: /* @__PURE__ */ C(uo, {})
4936
4978
  }
@@ -4952,9 +4994,9 @@ function ho({
4952
4994
  }
4953
4995
  )
4954
4996
  ] }),
4955
- N && O === "landscape" && /* @__PURE__ */ C("div", { class: "anam-transcript-pane", children: [
4956
- /* @__PURE__ */ C(Ti, { session: e, agentLabel: re, rowsRef: G }),
4957
- z && /* @__PURE__ */ C("div", { class: "anam-transcript-footer", children: Je })
4997
+ N && b === "landscape" && /* @__PURE__ */ C("div", { class: "anam-transcript-pane", children: [
4998
+ /* @__PURE__ */ C(Ti, { session: e, agentLabel: z, rowsRef: U }),
4999
+ K && /* @__PURE__ */ C("div", { class: "anam-transcript-footer", children: Je })
4958
5000
  ] })
4959
5001
  ]
4960
5002
  }
@@ -4967,9 +5009,9 @@ function fo(t) {
4967
5009
  ] });
4968
5010
  }
4969
5011
  function po(t) {
4970
- const e = qe(null), i = qe(null), n = Ve((O, N) => {
4971
- const R = i.current?.getRootNode();
4972
- R && R instanceof ShadowRoot && Qr(R.host, O, N);
5012
+ const e = qe(null), i = qe(null), n = Ve((b, N) => {
5013
+ const S = i.current?.getRootNode();
5014
+ S && S instanceof ShadowRoot && Qr(S.host, b, N);
4973
5015
  }, []);
4974
5016
  t["agent-id"] && t["session-token"] && console.warn("[AnamWidget] Both agent-id and session-token are set. Use one or the other. Ignoring agent-id.");
4975
5017
  const a = t["session-token"] ? void 0 : t["agent-id"], s = Zr(a, t["api-base-url"], t["session-token"], n);
@@ -4980,8 +5022,8 @@ function po(t) {
4980
5022
  () => io(t),
4981
5023
  [t.layout, t["initial-state"], t.position, t["ui-mute-button"], t["ui-text-input"], t["ui-captions"], t["ui-transcript"], t["call-to-action"]]
4982
5024
  ), l = ke(() => {
4983
- const O = s.serverConfig.value;
4984
- return kt(kt({ ...di }, O ?? {}), c);
5025
+ const b = s.serverConfig.value;
5026
+ return kt(kt({ ...di }, b ?? {}), c);
4985
5027
  }, [s.serverConfig.value, c]), m = Qi(
4986
5028
  l.layout === "floating" ? l.initialState : "expanded"
4987
5029
  );
@@ -4990,15 +5032,15 @@ function po(t) {
4990
5032
  }, [l.layout, l.initialState]), Ie(() => {
4991
5033
  s.fetchWidgetConfig();
4992
5034
  }, [a, t["api-base-url"], t["session-token"]]);
4993
- const p = t["avatar-url"] || s.avatarThumbnailUrl.value || null, f = t["avatar-video-url"] || s.avatarVideoUrl.value || null, T = t["agent-name"] || s.personaName.value, E = l.callToAction === di.callToAction && T ? `Talk to ${T}` : l.callToAction, S = ke(() => {
5035
+ const f = t["avatar-url"] || s.avatarThumbnailUrl.value || null, p = t["avatar-video-url"] || s.avatarVideoUrl.value || null, y = t["agent-name"] || s.personaName.value, E = l.callToAction === di.callToAction && y ? `Talk to ${y}` : l.callToAction, T = ke(() => {
4994
5036
  if (l.layout === "inline") return "";
4995
- const O = Gn(l.position);
4996
- return Object.entries(O).map(([N, R]) => `${N}: ${R}`).join("; ");
4997
- }, [l.layout, l.position]), y = l.layout === "floating", I = () => {
4998
- m.value = "expanded", n(X.EXPANDED, {});
4999
- }, w = async () => {
5000
- s.connectionStatus.value !== "idle" && await s.stopSession(), m.value = "minimized", n(X.COLLAPSED, {});
5001
- }, b = y ? m.value === "expanded" : !0;
5037
+ const b = Gn(l.position);
5038
+ return Object.entries(b).map(([N, S]) => `${N}: ${S}`).join("; ");
5039
+ }, [l.layout, l.position]), I = l.layout === "floating", w = () => {
5040
+ m.value = "expanded", n(ee.EXPANDED, {});
5041
+ }, A = async () => {
5042
+ s.connectionStatus.value !== "idle" && await s.stopSession(), m.value = "minimized", n(ee.COLLAPSED, {});
5043
+ }, R = I ? m.value === "expanded" : !0;
5002
5044
  return s.isReady.value ? /* @__PURE__ */ C(
5003
5045
  "div",
5004
5046
  {
@@ -5006,29 +5048,29 @@ function po(t) {
5006
5048
  class: "anam-widget",
5007
5049
  "data-layout": l.layout,
5008
5050
  "data-state": m.value,
5009
- style: S,
5051
+ style: T,
5010
5052
  children: [
5011
- y && m.value === "minimized" && /* @__PURE__ */ C(
5053
+ I && m.value === "minimized" && /* @__PURE__ */ C(
5012
5054
  "button",
5013
5055
  {
5014
5056
  class: "anam-trigger",
5015
- onClick: I,
5057
+ onClick: w,
5016
5058
  "aria-label": E,
5017
- children: p ? /* @__PURE__ */ C("img", { src: p, alt: "Avatar" }) : /* @__PURE__ */ C(Lt, {})
5059
+ children: f ? /* @__PURE__ */ C("img", { src: f, alt: "Avatar" }) : /* @__PURE__ */ C(Lt, {})
5018
5060
  }
5019
5061
  ),
5020
- b && /* @__PURE__ */ C(
5062
+ R && /* @__PURE__ */ C(
5021
5063
  ho,
5022
5064
  {
5023
5065
  config: l,
5024
5066
  session: s,
5025
5067
  videoRef: e,
5026
- avatarSrc: p,
5027
- avatarVideoSrc: f,
5068
+ avatarSrc: f,
5069
+ avatarVideoSrc: p,
5028
5070
  displayCta: E,
5029
- agentName: T || null,
5030
- onCollapse: y ? w : null,
5031
- onStop: y ? null : () => s.stopSession(),
5071
+ agentName: y || null,
5072
+ onCollapse: I ? A : null,
5073
+ onStop: I ? null : () => s.stopSession(),
5032
5074
  dispatch: n
5033
5075
  }
5034
5076
  )
@@ -5074,6 +5116,6 @@ function yi(t = "anam-agent") {
5074
5116
  typeof window < "u" && typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", () => yi()) : yi());
5075
5117
  export {
5076
5118
  di as DefaultConfig,
5077
- X as WidgetEventNames,
5119
+ ee as WidgetEventNames,
5078
5120
  yi as registerWidget
5079
5121
  };