@ariaflowagents/widget 0.6.3 → 0.6.4

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/widget.js CHANGED
@@ -1,5 +1,5 @@
1
- var B, m, Te, R, me, He, Pe, Ie, ce, re, le, q = {}, Re = [], st = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, te = Array.isArray;
2
- function E(t, e) {
1
+ var B, m, Ee, R, me, Te, He, Ie, ce, re, ae, q = {}, Re = [], at = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, te = Array.isArray;
2
+ function P(t, e) {
3
3
  for (var n in e) t[n] = e[n];
4
4
  return t;
5
5
  }
@@ -7,13 +7,13 @@ function ue(t) {
7
7
  t && t.parentNode && t.parentNode.removeChild(t);
8
8
  }
9
9
  function D(t, e, n) {
10
- var o, s, i, l = {};
11
- for (i in e) i == "key" ? o = e[i] : i == "ref" ? s = e[i] : l[i] = e[i];
12
- if (arguments.length > 2 && (l.children = arguments.length > 3 ? B.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (i in t.defaultProps) l[i] === void 0 && (l[i] = t.defaultProps[i]);
13
- return Q(t, l, o, s, null);
10
+ var o, s, i, a = {};
11
+ for (i in e) i == "key" ? o = e[i] : i == "ref" ? s = e[i] : a[i] = e[i];
12
+ if (arguments.length > 2 && (a.children = arguments.length > 3 ? B.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (i in t.defaultProps) a[i] === void 0 && (a[i] = t.defaultProps[i]);
13
+ return Q(t, a, o, s, null);
14
14
  }
15
15
  function Q(t, e, n, o, s) {
16
- var i = { type: t, props: e, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: s ?? ++Te, __i: -1, __u: 0 };
16
+ var i = { type: t, props: e, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: s ?? ++Ee, __i: -1, __u: 0 };
17
17
  return s == null && m.vnode != null && m.vnode(i), i;
18
18
  }
19
19
  function U(t) {
@@ -37,22 +37,22 @@ function Ue(t) {
37
37
  return Ue(t);
38
38
  }
39
39
  }
40
- function ye(t) {
41
- (!t.__d && (t.__d = !0) && R.push(t) && !Y.__r++ || me != m.debounceRendering) && ((me = m.debounceRendering) || He)(Y);
40
+ function we(t) {
41
+ (!t.__d && (t.__d = !0) && R.push(t) && !Y.__r++ || me != m.debounceRendering) && ((me = m.debounceRendering) || Te)(Y);
42
42
  }
43
43
  function Y() {
44
- for (var t, e, n, o, s, i, l, _ = 1; R.length; ) R.length > _ && R.sort(Pe), t = R.shift(), _ = R.length, t.__d && (n = void 0, o = void 0, s = (o = (e = t).__v).__e, i = [], l = [], e.__P && ((n = E({}, o)).__v = o.__v + 1, m.vnode && m.vnode(n), de(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [s] : null, i, s ?? O(o), !!(32 & o.__u), l), n.__v = o.__v, n.__.__k[n.__i] = n, Le(i, n, l), o.__e = o.__ = null, n.__e != s && Ue(n)));
44
+ for (var t, e, n, o, s, i, a, _ = 1; R.length; ) R.length > _ && R.sort(He), t = R.shift(), _ = R.length, t.__d && (n = void 0, o = void 0, s = (o = (e = t).__v).__e, i = [], a = [], e.__P && ((n = P({}, o)).__v = o.__v + 1, m.vnode && m.vnode(n), ge(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [s] : null, i, s ?? O(o), !!(32 & o.__u), a), n.__v = o.__v, n.__.__k[n.__i] = n, Le(i, n, a), o.__e = o.__ = null, n.__e != s && Ue(n)));
45
45
  Y.__r = 0;
46
46
  }
47
- function De(t, e, n, o, s, i, l, _, c, a, u) {
48
- var r, f, d, b, A, w, p, h = o && o.__k || Re, x = e.length;
49
- for (c = rt(n, e, h, c, x), r = 0; r < x; r++) (d = n.__k[r]) != null && (f = d.__i == -1 ? q : h[d.__i] || q, d.__i = r, w = de(t, d, f, s, i, l, _, c, a, u), b = d.__e, d.ref && f.ref != d.ref && (f.ref && ge(f.ref, null, d), u.push(d.ref, d.__c || b, d)), A == null && b != null && (A = b), (p = !!(4 & d.__u)) || f.__k === d.__k ? c = Oe(d, c, t, p) : typeof d.type == "function" && w !== void 0 ? c = w : b && (c = b.nextSibling), d.__u &= -7);
50
- return n.__e = A, c;
47
+ function De(t, e, n, o, s, i, a, _, c, l, g) {
48
+ var r, f, d, b, S, y, p, h = o && o.__k || Re, M = e.length;
49
+ for (c = lt(n, e, h, c, M), r = 0; r < M; r++) (d = n.__k[r]) != null && (f = d.__i == -1 ? q : h[d.__i] || q, d.__i = r, y = ge(t, d, f, s, i, a, _, c, l, g), b = d.__e, d.ref && f.ref != d.ref && (f.ref && de(f.ref, null, d), g.push(d.ref, d.__c || b, d)), S == null && b != null && (S = b), (p = !!(4 & d.__u)) || f.__k === d.__k ? c = Oe(d, c, t, p) : typeof d.type == "function" && y !== void 0 ? c = y : b && (c = b.nextSibling), d.__u &= -7);
50
+ return n.__e = S, c;
51
51
  }
52
- function rt(t, e, n, o, s) {
53
- var i, l, _, c, a, u = n.length, r = u, f = 0;
54
- for (t.__k = new Array(s), i = 0; i < s; i++) (l = e[i]) != null && typeof l != "boolean" && typeof l != "function" ? (typeof l == "string" || typeof l == "number" || typeof l == "bigint" || l.constructor == String ? l = t.__k[i] = Q(null, l, null, null, null) : te(l) ? l = t.__k[i] = Q(U, { children: l }, null, null, null) : l.constructor === void 0 && l.__b > 0 ? l = t.__k[i] = Q(l.type, l.props, l.key, l.ref ? l.ref : null, l.__v) : t.__k[i] = l, c = i + f, l.__ = t, l.__b = t.__b + 1, _ = null, (a = l.__i = lt(l, n, c, r)) != -1 && (r--, (_ = n[a]) && (_.__u |= 2)), _ == null || _.__v == null ? (a == -1 && (s > u ? f-- : s < u && f++), typeof l.type != "function" && (l.__u |= 4)) : a != c && (a == c - 1 ? f-- : a == c + 1 ? f++ : (a > c ? f-- : f++, l.__u |= 4))) : t.__k[i] = null;
55
- if (r) for (i = 0; i < u; i++) (_ = n[i]) != null && !(2 & _.__u) && (_.__e == o && (o = O(_)), qe(_, _));
52
+ function lt(t, e, n, o, s) {
53
+ var i, a, _, c, l, g = n.length, r = g, f = 0;
54
+ for (t.__k = new Array(s), i = 0; i < s; i++) (a = e[i]) != null && typeof a != "boolean" && typeof a != "function" ? (typeof a == "string" || typeof a == "number" || typeof a == "bigint" || a.constructor == String ? a = t.__k[i] = Q(null, a, null, null, null) : te(a) ? a = t.__k[i] = Q(U, { children: a }, null, null, null) : a.constructor === void 0 && a.__b > 0 ? a = t.__k[i] = Q(a.type, a.props, a.key, a.ref ? a.ref : null, a.__v) : t.__k[i] = a, c = i + f, a.__ = t, a.__b = t.__b + 1, _ = null, (l = a.__i = _t(a, n, c, r)) != -1 && (r--, (_ = n[l]) && (_.__u |= 2)), _ == null || _.__v == null ? (l == -1 && (s > g ? f-- : s < g && f++), typeof a.type != "function" && (a.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, a.__u |= 4))) : t.__k[i] = null;
55
+ if (r) for (i = 0; i < g; i++) (_ = n[i]) != null && !(2 & _.__u) && (_.__e == o && (o = O(_)), qe(_, _));
56
56
  return o;
57
57
  }
58
58
  function Oe(t, e, n, o) {
@@ -67,25 +67,25 @@ function Oe(t, e, n, o) {
67
67
  while (e != null && e.nodeType == 8);
68
68
  return e;
69
69
  }
70
- function lt(t, e, n, o) {
71
- var s, i, l, _ = t.key, c = t.type, a = e[n], u = a != null && (2 & a.__u) == 0;
72
- if (a === null && _ == null || u && _ == a.key && c == a.type) return n;
73
- if (o > (u ? 1 : 0)) {
74
- for (s = n - 1, i = n + 1; s >= 0 || i < e.length; ) if ((a = e[l = s >= 0 ? s-- : i++]) != null && !(2 & a.__u) && _ == a.key && c == a.type) return l;
70
+ function _t(t, e, n, o) {
71
+ var s, i, a, _ = t.key, c = t.type, l = e[n], g = l != null && (2 & l.__u) == 0;
72
+ if (l === null && _ == null || g && _ == l.key && c == l.type) return n;
73
+ if (o > (g ? 1 : 0)) {
74
+ for (s = n - 1, i = n + 1; s >= 0 || i < e.length; ) if ((l = e[a = s >= 0 ? s-- : i++]) != null && !(2 & l.__u) && _ == l.key && c == l.type) return a;
75
75
  }
76
76
  return -1;
77
77
  }
78
- function we(t, e, n) {
79
- e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || st.test(e) ? n : n + "px";
78
+ function ye(t, e, n) {
79
+ e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || at.test(e) ? n : n + "px";
80
80
  }
81
81
  function J(t, e, n, o, s) {
82
- var i, l;
82
+ var i, a;
83
83
  e: if (e == "style") if (typeof n == "string") t.style.cssText = n;
84
84
  else {
85
- if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || we(t.style, e, "");
86
- if (n) for (e in n) o && n[e] == o[e] || we(t.style, e, n[e]);
85
+ if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || ye(t.style, e, "");
86
+ if (n) for (e in n) o && n[e] == o[e] || ye(t.style, e, n[e]);
87
87
  }
88
- else if (e[0] == "o" && e[1] == "n") i = e != (e = e.replace(Ie, "$1")), l = e.toLowerCase(), e = l in t || e == "onFocusOut" || e == "onFocusIn" ? l.slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + i] = n, n ? o ? n.u = o.u : (n.u = ce, t.addEventListener(e, i ? le : re, i)) : t.removeEventListener(e, i ? le : re, i);
88
+ else if (e[0] == "o" && e[1] == "n") i = e != (e = e.replace(Ie, "$1")), a = e.toLowerCase(), e = a in t || e == "onFocusOut" || e == "onFocusIn" ? a.slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + i] = n, n ? o ? n.u = o.u : (n.u = ce, t.addEventListener(e, i ? ae : re, i)) : t.removeEventListener(e, i ? ae : re, i);
89
89
  else {
90
90
  if (s == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
91
91
  else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in t) try {
@@ -106,50 +106,50 @@ function ve(t) {
106
106
  }
107
107
  };
108
108
  }
109
- function de(t, e, n, o, s, i, l, _, c, a) {
110
- var u, r, f, d, b, A, w, p, h, x, $, H, S, z, k, P, I, W = e.type;
109
+ function ge(t, e, n, o, s, i, a, _, c, l) {
110
+ var g, r, f, d, b, S, y, p, h, M, W, T, $, z, A, H, I, N = e.type;
111
111
  if (e.constructor !== void 0) return null;
112
- 128 & n.__u && (c = !!(32 & n.__u), i = [_ = e.__e = n.__e]), (u = m.__b) && u(e);
113
- e: if (typeof W == "function") try {
114
- if (p = e.props, h = "prototype" in W && W.prototype.render, x = (u = W.contextType) && o[u.__c], $ = u ? x ? x.props.value : u.__ : o, n.__c ? w = (r = e.__c = n.__c).__ = r.__E : (h ? e.__c = r = new W(p, $) : (e.__c = r = new G(p, $), r.constructor = W, r.render = _t), x && x.sub(r), r.state || (r.state = {}), r.__n = o, f = r.__d = !0, r.__h = [], r._sb = []), h && r.__s == null && (r.__s = r.state), h && W.getDerivedStateFromProps != null && (r.__s == r.state && (r.__s = E({}, r.__s)), E(r.__s, W.getDerivedStateFromProps(p, r.__s))), d = r.props, b = r.state, r.__v = e, f) h && W.getDerivedStateFromProps == null && r.componentWillMount != null && r.componentWillMount(), h && r.componentDidMount != null && r.__h.push(r.componentDidMount);
112
+ 128 & n.__u && (c = !!(32 & n.__u), i = [_ = e.__e = n.__e]), (g = m.__b) && g(e);
113
+ e: if (typeof N == "function") try {
114
+ if (p = e.props, h = "prototype" in N && N.prototype.render, M = (g = N.contextType) && o[g.__c], W = g ? M ? M.props.value : g.__ : o, n.__c ? y = (r = e.__c = n.__c).__ = r.__E : (h ? e.__c = r = new N(p, W) : (e.__c = r = new G(p, W), r.constructor = N, r.render = ut), M && M.sub(r), r.state || (r.state = {}), r.__n = o, f = r.__d = !0, r.__h = [], r._sb = []), h && r.__s == null && (r.__s = r.state), h && N.getDerivedStateFromProps != null && (r.__s == r.state && (r.__s = P({}, r.__s)), P(r.__s, N.getDerivedStateFromProps(p, r.__s))), d = r.props, b = r.state, r.__v = e, f) h && N.getDerivedStateFromProps == null && r.componentWillMount != null && r.componentWillMount(), h && r.componentDidMount != null && r.__h.push(r.componentDidMount);
115
115
  else {
116
- if (h && W.getDerivedStateFromProps == null && p !== d && r.componentWillReceiveProps != null && r.componentWillReceiveProps(p, $), e.__v == n.__v || !r.__e && r.shouldComponentUpdate != null && r.shouldComponentUpdate(p, r.__s, $) === !1) {
117
- for (e.__v != n.__v && (r.props = p, r.state = r.__s, r.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(F) {
118
- F && (F.__ = e);
119
- }), H = 0; H < r._sb.length; H++) r.__h.push(r._sb[H]);
120
- r._sb = [], r.__h.length && l.push(r);
116
+ if (h && N.getDerivedStateFromProps == null && p !== d && r.componentWillReceiveProps != null && r.componentWillReceiveProps(p, W), e.__v == n.__v || !r.__e && r.shouldComponentUpdate != null && r.shouldComponentUpdate(p, r.__s, W) === !1) {
117
+ for (e.__v != n.__v && (r.props = p, r.state = r.__s, r.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(x) {
118
+ x && (x.__ = e);
119
+ }), T = 0; T < r._sb.length; T++) r.__h.push(r._sb[T]);
120
+ r._sb = [], r.__h.length && a.push(r);
121
121
  break e;
122
122
  }
123
- r.componentWillUpdate != null && r.componentWillUpdate(p, r.__s, $), h && r.componentDidUpdate != null && r.__h.push(function() {
124
- r.componentDidUpdate(d, b, A);
123
+ r.componentWillUpdate != null && r.componentWillUpdate(p, r.__s, W), h && r.componentDidUpdate != null && r.__h.push(function() {
124
+ r.componentDidUpdate(d, b, S);
125
125
  });
126
126
  }
127
- if (r.context = $, r.props = p, r.__P = t, r.__e = !1, S = m.__r, z = 0, h) {
128
- for (r.state = r.__s, r.__d = !1, S && S(e), u = r.render(r.props, r.state, r.context), k = 0; k < r._sb.length; k++) r.__h.push(r._sb[k]);
127
+ if (r.context = W, r.props = p, r.__P = t, r.__e = !1, $ = m.__r, z = 0, h) {
128
+ for (r.state = r.__s, r.__d = !1, $ && $(e), g = r.render(r.props, r.state, r.context), A = 0; A < r._sb.length; A++) r.__h.push(r._sb[A]);
129
129
  r._sb = [];
130
130
  } else do
131
- r.__d = !1, S && S(e), u = r.render(r.props, r.state, r.context), r.state = r.__s;
131
+ r.__d = !1, $ && $(e), g = r.render(r.props, r.state, r.context), r.state = r.__s;
132
132
  while (r.__d && ++z < 25);
133
- r.state = r.__s, r.getChildContext != null && (o = E(E({}, o), r.getChildContext())), h && !f && r.getSnapshotBeforeUpdate != null && (A = r.getSnapshotBeforeUpdate(d, b)), P = u, u != null && u.type === U && u.key == null && (P = Qe(u.props.children)), _ = De(t, te(P) ? P : [P], e, n, o, s, i, l, _, c, a), r.base = e.__e, e.__u &= -161, r.__h.length && l.push(r), w && (r.__E = r.__ = null);
134
- } catch (F) {
135
- if (e.__v = null, c || i != null) if (F.then) {
133
+ r.state = r.__s, r.getChildContext != null && (o = P(P({}, o), r.getChildContext())), h && !f && r.getSnapshotBeforeUpdate != null && (S = r.getSnapshotBeforeUpdate(d, b)), H = g, g != null && g.type === U && g.key == null && (H = Qe(g.props.children)), _ = De(t, te(H) ? H : [H], e, n, o, s, i, a, _, c, l), r.base = e.__e, e.__u &= -161, r.__h.length && a.push(r), y && (r.__E = r.__ = null);
134
+ } catch (x) {
135
+ if (e.__v = null, c || i != null) if (x.then) {
136
136
  for (e.__u |= c ? 160 : 128; _ && _.nodeType == 8 && _.nextSibling; ) _ = _.nextSibling;
137
137
  i[i.indexOf(_)] = null, e.__e = _;
138
138
  } else {
139
139
  for (I = i.length; I--; ) ue(i[I]);
140
- ae(e);
140
+ le(e);
141
141
  }
142
- else e.__e = n.__e, e.__k = n.__k, F.then || ae(e);
143
- m.__e(F, e, n);
142
+ else e.__e = n.__e, e.__k = n.__k, x.then || le(e);
143
+ m.__e(x, e, n);
144
144
  }
145
- else i == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : _ = e.__e = at(n.__e, e, n, o, s, i, l, c, a);
146
- return (u = m.diffed) && u(e), 128 & e.__u ? void 0 : _;
145
+ else i == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : _ = e.__e = ct(n.__e, e, n, o, s, i, a, c, l);
146
+ return (g = m.diffed) && g(e), 128 & e.__u ? void 0 : _;
147
147
  }
148
- function ae(t) {
149
- t && t.__c && (t.__c.__e = !0), t && t.__k && t.__k.forEach(ae);
148
+ function le(t) {
149
+ t && t.__c && (t.__c.__e = !0), t && t.__k && t.__k.forEach(le);
150
150
  }
151
151
  function Le(t, e, n) {
152
- for (var o = 0; o < n.length; o++) ge(n[o], n[++o], n[++o]);
152
+ for (var o = 0; o < n.length; o++) de(n[o], n[++o], n[++o]);
153
153
  m.__c && m.__c(e, t), t.some(function(s) {
154
154
  try {
155
155
  t = s.__h, s.__h = [], t.some(function(i) {
@@ -161,13 +161,13 @@ function Le(t, e, n) {
161
161
  });
162
162
  }
163
163
  function Qe(t) {
164
- return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : te(t) ? t.map(Qe) : E({}, t);
164
+ return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : te(t) ? t.map(Qe) : P({}, t);
165
165
  }
166
- function at(t, e, n, o, s, i, l, _, c) {
167
- var a, u, r, f, d, b, A, w = n.props || q, p = e.props, h = e.type;
166
+ function ct(t, e, n, o, s, i, a, _, c) {
167
+ var l, g, r, f, d, b, S, y = n.props || q, p = e.props, h = e.type;
168
168
  if (h == "svg" ? s = "http://www.w3.org/2000/svg" : h == "math" ? s = "http://www.w3.org/1998/Math/MathML" : s || (s = "http://www.w3.org/1999/xhtml"), i != null) {
169
- for (a = 0; a < i.length; a++) if ((d = i[a]) && "setAttribute" in d == !!h && (h ? d.localName == h : d.nodeType == 3)) {
170
- t = d, i[a] = null;
169
+ for (l = 0; l < i.length; l++) if ((d = i[l]) && "setAttribute" in d == !!h && (h ? d.localName == h : d.nodeType == 3)) {
170
+ t = d, i[l] = null;
171
171
  break;
172
172
  }
173
173
  }
@@ -175,24 +175,24 @@ function at(t, e, n, o, s, i, l, _, c) {
175
175
  if (h == null) return document.createTextNode(p);
176
176
  t = document.createElementNS(s, h, p.is && p), _ && (m.__m && m.__m(e, i), _ = !1), i = null;
177
177
  }
178
- if (h == null) w === p || _ && t.data == p || (t.data = p);
178
+ if (h == null) y === p || _ && t.data == p || (t.data = p);
179
179
  else {
180
- if (i = i && B.call(t.childNodes), !_ && i != null) for (w = {}, a = 0; a < t.attributes.length; a++) w[(d = t.attributes[a]).name] = d.value;
181
- for (a in w) if (d = w[a], a != "children") {
182
- if (a == "dangerouslySetInnerHTML") r = d;
183
- else if (!(a in p)) {
184
- if (a == "value" && "defaultValue" in p || a == "checked" && "defaultChecked" in p) continue;
185
- J(t, a, null, d, s);
180
+ if (i = i && B.call(t.childNodes), !_ && i != null) for (y = {}, l = 0; l < t.attributes.length; l++) y[(d = t.attributes[l]).name] = d.value;
181
+ for (l in y) if (d = y[l], l != "children") {
182
+ if (l == "dangerouslySetInnerHTML") r = d;
183
+ else if (!(l in p)) {
184
+ if (l == "value" && "defaultValue" in p || l == "checked" && "defaultChecked" in p) continue;
185
+ J(t, l, null, d, s);
186
186
  }
187
187
  }
188
- for (a in p) d = p[a], a == "children" ? f = d : a == "dangerouslySetInnerHTML" ? u = d : a == "value" ? b = d : a == "checked" ? A = d : _ && typeof d != "function" || w[a] === d || J(t, a, d, w[a], s);
189
- if (u) _ || r && (u.__html == r.__html || u.__html == t.innerHTML) || (t.innerHTML = u.__html), e.__k = [];
190
- else if (r && (t.innerHTML = ""), De(e.type == "template" ? t.content : t, te(f) ? f : [f], e, n, o, h == "foreignObject" ? "http://www.w3.org/1999/xhtml" : s, i, l, i ? i[0] : n.__k && O(n, 0), _, c), i != null) for (a = i.length; a--; ) ue(i[a]);
191
- _ || (a = "value", h == "progress" && b == null ? t.removeAttribute("value") : b != null && (b !== t[a] || h == "progress" && !b || h == "option" && b != w[a]) && J(t, a, b, w[a], s), a = "checked", A != null && A != t[a] && J(t, a, A, w[a], s));
188
+ for (l in p) d = p[l], l == "children" ? f = d : l == "dangerouslySetInnerHTML" ? g = d : l == "value" ? b = d : l == "checked" ? S = d : _ && typeof d != "function" || y[l] === d || J(t, l, d, y[l], s);
189
+ if (g) _ || r && (g.__html == r.__html || g.__html == t.innerHTML) || (t.innerHTML = g.__html), e.__k = [];
190
+ else if (r && (t.innerHTML = ""), De(e.type == "template" ? t.content : t, te(f) ? f : [f], e, n, o, h == "foreignObject" ? "http://www.w3.org/1999/xhtml" : s, i, a, i ? i[0] : n.__k && O(n, 0), _, c), i != null) for (l = i.length; l--; ) ue(i[l]);
191
+ _ || (l = "value", h == "progress" && b == null ? t.removeAttribute("value") : b != null && (b !== t[l] || h == "progress" && !b || h == "option" && b != y[l]) && J(t, l, b, y[l], s), l = "checked", S != null && S != t[l] && J(t, l, S, y[l], s));
192
192
  }
193
193
  return t;
194
194
  }
195
- function ge(t, e, n) {
195
+ function de(t, e, n) {
196
196
  try {
197
197
  if (typeof t == "function") {
198
198
  var o = typeof t.__u == "function";
@@ -204,7 +204,7 @@ function ge(t, e, n) {
204
204
  }
205
205
  function qe(t, e, n) {
206
206
  var o, s;
207
- if (m.unmount && m.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || ge(o, null, e)), (o = t.__c) != null) {
207
+ if (m.unmount && m.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || de(o, null, e)), (o = t.__c) != null) {
208
208
  if (o.componentWillUnmount) try {
209
209
  o.componentWillUnmount();
210
210
  } catch (i) {
@@ -215,36 +215,36 @@ function qe(t, e, n) {
215
215
  if (o = t.__k) for (s = 0; s < o.length; s++) o[s] && qe(o[s], e, n || typeof t.type != "function");
216
216
  n || ue(t.__e), t.__c = t.__ = t.__e = void 0;
217
217
  }
218
- function _t(t, e, n) {
218
+ function ut(t, e, n) {
219
219
  return this.constructor(t, n);
220
220
  }
221
221
  function ne(t, e, n) {
222
- var o, s, i, l;
223
- e == document && (e = document.documentElement), m.__ && m.__(t, e), s = (o = typeof n == "function") ? null : n && n.__k || e.__k, i = [], l = [], de(e, t = (!o && n || e).__k = D(U, null, [t]), s || q, q, e.namespaceURI, !o && n ? [n] : s ? null : e.firstChild ? B.call(e.childNodes) : null, i, !o && n ? n : s ? s.__e : e.firstChild, o, l), Le(i, t, l);
222
+ var o, s, i, a;
223
+ e == document && (e = document.documentElement), m.__ && m.__(t, e), s = (o = typeof n == "function") ? null : n && n.__k || e.__k, i = [], a = [], ge(e, t = (!o && n || e).__k = D(U, null, [t]), s || q, q, e.namespaceURI, !o && n ? [n] : s ? null : e.firstChild ? B.call(e.childNodes) : null, i, !o && n ? n : s ? s.__e : e.firstChild, o, a), Le(i, t, a);
224
224
  }
225
225
  function je(t, e) {
226
226
  ne(t, e, je);
227
227
  }
228
228
  function Be(t, e, n) {
229
- var o, s, i, l, _ = E({}, t.props);
230
- for (i in t.type && t.type.defaultProps && (l = t.type.defaultProps), e) i == "key" ? o = e[i] : i == "ref" ? s = e[i] : _[i] = e[i] === void 0 && l != null ? l[i] : e[i];
229
+ var o, s, i, a, _ = P({}, t.props);
230
+ for (i in t.type && t.type.defaultProps && (a = t.type.defaultProps), e) i == "key" ? o = e[i] : i == "ref" ? s = e[i] : _[i] = e[i] === void 0 && a != null ? a[i] : e[i];
231
231
  return arguments.length > 2 && (_.children = arguments.length > 3 ? B.call(arguments, 2) : n), Q(t.type, _, o || t.key, s || t.ref, null);
232
232
  }
233
233
  B = Re.slice, m = { __e: function(t, e, n, o) {
234
- for (var s, i, l; e = e.__; ) if ((s = e.__c) && !s.__) try {
235
- if ((i = s.constructor) && i.getDerivedStateFromError != null && (s.setState(i.getDerivedStateFromError(t)), l = s.__d), s.componentDidCatch != null && (s.componentDidCatch(t, o || {}), l = s.__d), l) return s.__E = s;
234
+ for (var s, i, a; e = e.__; ) if ((s = e.__c) && !s.__) try {
235
+ if ((i = s.constructor) && i.getDerivedStateFromError != null && (s.setState(i.getDerivedStateFromError(t)), a = s.__d), s.componentDidCatch != null && (s.componentDidCatch(t, o || {}), a = s.__d), a) return s.__E = s;
236
236
  } catch (_) {
237
237
  t = _;
238
238
  }
239
239
  throw t;
240
- } }, Te = 0, G.prototype.setState = function(t, e) {
240
+ } }, Ee = 0, G.prototype.setState = function(t, e) {
241
241
  var n;
242
- n = this.__s != null && this.__s != this.state ? this.__s : this.__s = E({}, this.state), typeof t == "function" && (t = t(E({}, n), this.props)), t && E(n, t), t != null && this.__v && (e && this._sb.push(e), ye(this));
242
+ n = this.__s != null && this.__s != this.state ? this.__s : this.__s = P({}, this.state), typeof t == "function" && (t = t(P({}, n), this.props)), t && P(n, t), t != null && this.__v && (e && this._sb.push(e), we(this));
243
243
  }, G.prototype.forceUpdate = function(t) {
244
- this.__v && (this.__e = !0, t && this.__h.push(t), ye(this));
245
- }, G.prototype.render = U, R = [], He = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, Pe = function(t, e) {
244
+ this.__v && (this.__e = !0, t && this.__h.push(t), we(this));
245
+ }, G.prototype.render = U, R = [], Te = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, He = function(t, e) {
246
246
  return t.__v.__b - e.__v.__b;
247
- }, Y.__r = 0, Ie = /(PointerCapture)$|Capture$/i, ce = 0, re = ve(!1), le = ve(!0);
247
+ }, Y.__r = 0, Ie = /(PointerCapture)$|Capture$/i, ce = 0, re = ve(!1), ae = ve(!0);
248
248
  function Z() {
249
249
  return Z = Object.assign ? Object.assign.bind() : function(t) {
250
250
  for (var e = 1; e < arguments.length; e++) {
@@ -260,77 +260,77 @@ function ze(t, e) {
260
260
  for (o = 0; o < i.length; o++) e.indexOf(n = i[o]) >= 0 || (s[n] = t[n]);
261
261
  return s;
262
262
  }
263
- var ct = ["context", "children"], ut = ["useFragment"];
264
- function dt(t, e, n, o) {
263
+ var gt = ["context", "children"], dt = ["useFragment"];
264
+ function ht(t, e, n, o) {
265
265
  function s() {
266
266
  var i = Reflect.construct(HTMLElement, [], s);
267
267
  return i._vdomComponent = t, i._root = i, i;
268
268
  }
269
269
  return (s.prototype = Object.create(HTMLElement.prototype)).constructor = s, s.prototype.connectedCallback = function() {
270
- ht.call(this, o);
271
- }, s.prototype.attributeChangedCallback = ft, s.prototype.disconnectedCallback = pt, n = n || t.observedAttributes || Object.keys(t.propTypes || {}), s.observedAttributes = n, t.formAssociated && (s.formAssociated = !0), n.forEach(function(i) {
270
+ pt.call(this, o);
271
+ }, s.prototype.attributeChangedCallback = mt, s.prototype.disconnectedCallback = wt, n = n || t.observedAttributes || Object.keys(t.propTypes || {}), s.observedAttributes = n, t.formAssociated && (s.formAssociated = !0), n.forEach(function(i) {
272
272
  Object.defineProperty(s.prototype, i, { get: function() {
273
273
  return this._vdom ? this._vdom.props[i] : this._props[i];
274
- }, set: function(l) {
275
- this._vdom ? this.attributeChangedCallback(i, null, l) : (this._props || (this._props = {}), this._props[i] = l);
276
- var _ = typeof l;
277
- l != null && _ !== "string" && _ !== "boolean" && _ !== "number" || this.setAttribute(i, l);
274
+ }, set: function(a) {
275
+ this._vdom ? this.attributeChangedCallback(i, null, a) : (this._props || (this._props = {}), this._props[i] = a);
276
+ var _ = typeof a;
277
+ a != null && _ !== "string" && _ !== "boolean" && _ !== "number" || this.setAttribute(i, a);
278
278
  } });
279
279
  }), customElements.define(e, s), s;
280
280
  }
281
- function gt(t) {
281
+ function ft(t) {
282
282
  this.getChildContext = function() {
283
283
  return t.context;
284
284
  };
285
- var e = t.children, n = ze(t, ct);
285
+ var e = t.children, n = ze(t, gt);
286
286
  return Be(e, n);
287
287
  }
288
- function ht(t) {
288
+ function pt(t) {
289
289
  var e = new CustomEvent("_preact", { detail: {}, bubbles: !0, cancelable: !0 });
290
- this.dispatchEvent(e), this._vdom = D(gt, Z({}, this._props, { context: e.detail.context }), Je(this, this._vdomComponent, t)), (this.hasAttribute("hydrate") ? je : ne)(this._vdom, this._root);
290
+ this.dispatchEvent(e), this._vdom = D(ft, Z({}, this._props, { context: e.detail.context }), Je(this, this._vdomComponent, t)), (this.hasAttribute("hydrate") ? je : ne)(this._vdom, this._root);
291
291
  }
292
292
  function Ve(t) {
293
293
  return t.replace(/-(\w)/g, function(e, n) {
294
294
  return n ? n.toUpperCase() : "";
295
295
  });
296
296
  }
297
- function ft(t, e, n) {
297
+ function mt(t, e, n) {
298
298
  if (this._vdom) {
299
299
  var o = {};
300
300
  o[t] = n = n ?? void 0, o[Ve(t)] = n, this._vdom = Be(this._vdom, o), ne(this._vdom, this._root);
301
301
  }
302
302
  }
303
- function pt() {
303
+ function wt() {
304
304
  ne(this._vdom = null, this._root);
305
305
  }
306
306
  function be(t, e) {
307
- var n = this, o = t.useFragment, s = ze(t, ut);
307
+ var n = this, o = t.useFragment, s = ze(t, dt);
308
308
  return D(o ? U : "slot", Z({}, s, { ref: function(i) {
309
- i ? (n.ref = i, n._listener || (n._listener = function(l) {
310
- l.stopPropagation(), l.detail.context = e;
309
+ i ? (n.ref = i, n._listener || (n._listener = function(a) {
310
+ a.stopPropagation(), a.detail.context = e;
311
311
  }, i.addEventListener("_preact", n._listener))) : n.ref.removeEventListener("_preact", n._listener);
312
312
  } }));
313
313
  }
314
314
  function Je(t, e, n) {
315
315
  if (t.nodeType === 3) return t.data;
316
316
  if (t.nodeType !== 1) return null;
317
- var o = [], s = {}, i = 0, l = t.attributes, _ = t.childNodes;
318
- for (i = l.length; i--; ) l[i].name !== "slot" && (s[l[i].name] = l[i].value, s[Ve(l[i].name)] = l[i].value);
317
+ var o = [], s = {}, i = 0, a = t.attributes, _ = t.childNodes;
318
+ for (i = a.length; i--; ) a[i].name !== "slot" && (s[a[i].name] = a[i].value, s[Ve(a[i].name)] = a[i].value);
319
319
  for (i = _.length; i--; ) {
320
- var c = Je(_[i], null, n), a = _[i].slot;
321
- a ? s[a] = D(be, { name: a }, c) : o[i] = c;
320
+ var c = Je(_[i], null, n), l = _[i].slot;
321
+ l ? s[l] = D(be, { name: l }, c) : o[i] = c;
322
322
  }
323
- var u = !(!n || !n.shadow), r = e ? D(be, { useFragment: !u }, o) : o;
324
- return !u && e && (t.innerHTML = ""), D(e || t.nodeName.toLowerCase(), s, r);
323
+ var g = !(!n || !n.shadow), r = e ? D(be, { useFragment: !g }, o) : o;
324
+ return !g && e && (t.innerHTML = ""), D(e || t.nodeName.toLowerCase(), s, r);
325
325
  }
326
- var mt = 0;
327
- function g(t, e, n, o, s, i) {
326
+ var yt = 0;
327
+ function u(t, e, n, o, s, i) {
328
328
  e || (e = {});
329
- var l, _, c = e;
330
- if ("ref" in c) for (_ in c = {}, e) _ == "ref" ? l = e[_] : c[_] = e[_];
331
- var a = { type: t, props: c, key: n, ref: l, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --mt, __i: -1, __u: 0, __source: s, __self: i };
332
- if (typeof t == "function" && (l = t.defaultProps)) for (_ in l) c[_] === void 0 && (c[_] = l[_]);
333
- return m.vnode && m.vnode(a), a;
329
+ var a, _, c = e;
330
+ if ("ref" in c) for (_ in c = {}, e) _ == "ref" ? a = e[_] : c[_] = e[_];
331
+ var l = { type: t, props: c, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --yt, __i: -1, __u: 0, __source: s, __self: i };
332
+ if (typeof t == "function" && (a = t.defaultProps)) for (_ in a) c[_] === void 0 && (c[_] = a[_]);
333
+ return m.vnode && m.vnode(l), l;
334
334
  }
335
335
  var j, v, ie, Ce, ee = 0, Ke = [], C = m, ke = C.__b, Ae = C.__r, Se = C.diffed, $e = C.__c, We = C.unmount, Ne = C.__;
336
336
  function he(t, e) {
@@ -338,39 +338,39 @@ function he(t, e) {
338
338
  var n = v.__H || (v.__H = { __: [], __h: [] });
339
339
  return t >= n.__.length && n.__.push({}), n.__[t];
340
340
  }
341
- function T(t) {
342
- return ee = 1, yt(Xe, t);
341
+ function E(t) {
342
+ return ee = 1, vt(Xe, t);
343
343
  }
344
- function yt(t, e, n) {
344
+ function vt(t, e, n) {
345
345
  var o = he(j++, 2);
346
346
  if (o.t = t, !o.__c && (o.__ = [Xe(void 0, e), function(_) {
347
- var c = o.__N ? o.__N[0] : o.__[0], a = o.t(c, _);
348
- c !== a && (o.__N = [a, o.__[1]], o.__c.setState({}));
347
+ var c = o.__N ? o.__N[0] : o.__[0], l = o.t(c, _);
348
+ c !== l && (o.__N = [l, o.__[1]], o.__c.setState({}));
349
349
  }], o.__c = v, !v.__f)) {
350
- var s = function(_, c, a) {
350
+ var s = function(_, c, l) {
351
351
  if (!o.__c.__H) return !0;
352
- var u = o.__c.__H.__.filter(function(f) {
352
+ var g = o.__c.__H.__.filter(function(f) {
353
353
  return !!f.__c;
354
354
  });
355
- if (u.every(function(f) {
355
+ if (g.every(function(f) {
356
356
  return !f.__N;
357
- })) return !i || i.call(this, _, c, a);
357
+ })) return !i || i.call(this, _, c, l);
358
358
  var r = o.__c.props !== _;
359
- return u.forEach(function(f) {
359
+ return g.forEach(function(f) {
360
360
  if (f.__N) {
361
361
  var d = f.__[0];
362
362
  f.__ = f.__N, f.__N = void 0, d !== f.__[0] && (r = !0);
363
363
  }
364
- }), i && i.call(this, _, c, a) || r;
364
+ }), i && i.call(this, _, c, l) || r;
365
365
  };
366
366
  v.__f = !0;
367
- var i = v.shouldComponentUpdate, l = v.componentWillUpdate;
368
- v.componentWillUpdate = function(_, c, a) {
367
+ var i = v.shouldComponentUpdate, a = v.componentWillUpdate;
368
+ v.componentWillUpdate = function(_, c, l) {
369
369
  if (this.__e) {
370
- var u = i;
371
- i = void 0, s(_, c, a), i = u;
370
+ var g = i;
371
+ i = void 0, s(_, c, l), i = g;
372
372
  }
373
- l && l.call(this, _, c, a);
373
+ a && a.call(this, _, c, l);
374
374
  }, v.shouldComponentUpdate = s;
375
375
  }
376
376
  return o.__N || o.__;
@@ -380,15 +380,15 @@ function xe(t, e) {
380
380
  !C.__s && Ge(n.__H, e) && (n.__ = t, n.u = e, v.__H.__h.push(n));
381
381
  }
382
382
  function Fe(t) {
383
- return ee = 5, wt(function() {
383
+ return ee = 5, bt(function() {
384
384
  return { current: t };
385
385
  }, []);
386
386
  }
387
- function wt(t, e) {
387
+ function bt(t, e) {
388
388
  var n = he(j++, 7);
389
389
  return Ge(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
390
390
  }
391
- function vt() {
391
+ function Ct() {
392
392
  for (var t; t = Ke.shift(); ) if (t.__P && t.__H) try {
393
393
  t.__H.__h.forEach(X), t.__H.__h.forEach(_e), t.__H.__h = [];
394
394
  } catch (e) {
@@ -408,7 +408,7 @@ C.__b = function(t) {
408
408
  }, C.diffed = function(t) {
409
409
  Se && Se(t);
410
410
  var e = t.__c;
411
- e && e.__H && (e.__H.__h.length && (Ke.push(e) !== 1 && Ce === C.requestAnimationFrame || ((Ce = C.requestAnimationFrame) || bt)(vt)), e.__H.__.forEach(function(n) {
411
+ e && e.__H && (e.__H.__h.length && (Ke.push(e) !== 1 && Ce === C.requestAnimationFrame || ((Ce = C.requestAnimationFrame) || kt)(Ct)), e.__H.__.forEach(function(n) {
412
412
  n.u && (n.__H = n.u), n.u = void 0;
413
413
  })), ie = v = null;
414
414
  }, C.__c = function(t, e) {
@@ -435,7 +435,7 @@ C.__b = function(t) {
435
435
  }), n.__H = void 0, e && C.__e(e, n.__v));
436
436
  };
437
437
  var Me = typeof requestAnimationFrame == "function";
438
- function bt(t) {
438
+ function kt(t) {
439
439
  var e, n = function() {
440
440
  clearTimeout(o), Me && cancelAnimationFrame(e), setTimeout(t);
441
441
  }, o = setTimeout(n, 35);
@@ -457,16 +457,16 @@ function Ge(t, e) {
457
457
  function Xe(t, e) {
458
458
  return typeof e == "function" ? e(t) : e;
459
459
  }
460
- const Ct = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
460
+ const At = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
461
461
  let K = (t = 21) => {
462
462
  let e = "", n = crypto.getRandomValues(new Uint8Array(t |= 0));
463
463
  for (; t--; )
464
- e += Ct[n[t] & 63];
464
+ e += At[n[t] & 63];
465
465
  return e;
466
466
  };
467
- class kt {
467
+ class St {
468
468
  constructor(e, n) {
469
- this.agentUrl = e, this.agentId = n, this.agentConfig = null, this.ws = null, this.messageCallbacks = /* @__PURE__ */ new Set(), this.connectionCallbacks = /* @__PURE__ */ new Set(), this.streamingCallbacks = /* @__PURE__ */ new Set(), this.queueCallbacks = /* @__PURE__ */ new Set(), this.messages = [], this.reconnectAttempts = 0, this.maxReconnectAttempts = 5, this.reconnectDelay = 1e3, this.isAgentStreaming = !1, this.messageQueue = [];
469
+ this.agentUrl = e, this.agentId = n, this.agentConfig = null, this.ws = null, this.messageCallbacks = /* @__PURE__ */ new Set(), this.connectionCallbacks = /* @__PURE__ */ new Set(), this.streamingCallbacks = /* @__PURE__ */ new Set(), this.processingCallbacks = /* @__PURE__ */ new Set(), this.queueCallbacks = /* @__PURE__ */ new Set(), this.messages = [], this.reconnectAttempts = 0, this.maxReconnectAttempts = 5, this.reconnectDelay = 1e3, this.isAgentStreaming = !1, this.isAgentProcessing = !1, this.messageQueue = [];
470
470
  }
471
471
  /**
472
472
  * Initialize the widget by fetching agent configuration
@@ -533,13 +533,24 @@ class kt {
533
533
  });
534
534
  }
535
535
  /**
536
- * Handle incoming WebSocket messages from the agent
536
+ * Register a callback for processing state changes
537
537
  */
538
+ onProcessingChange(e) {
539
+ return this.processingCallbacks.add(e), () => {
540
+ this.processingCallbacks.delete(e);
541
+ };
542
+ }
543
+ /**
544
+ * Notify all processing callbacks
545
+ */
546
+ notifyProcessingChange(e) {
547
+ this.isAgentProcessing = e, this.processingCallbacks.forEach((n) => n(e));
548
+ }
538
549
  handleMessage(e) {
539
550
  try {
540
551
  const n = JSON.parse(e.data);
541
552
  if (n.type === "text-delta")
542
- this.setMessages((o) => {
553
+ this.isAgentProcessing && this.notifyProcessingChange(!1), this.setMessages((o) => {
543
554
  const s = o[o.length - 1];
544
555
  return s && s.role === "assistant" && s.isStreaming ? [
545
556
  ...o.slice(0, -1),
@@ -556,7 +567,7 @@ class kt {
556
567
  ];
557
568
  });
558
569
  else if (n.type === "done")
559
- console.log("[Widget] Response complete"), this.setMessages((o) => {
570
+ console.log("[Widget] Response complete"), this.notifyProcessingChange(!1), this.setMessages((o) => {
560
571
  const s = o[o.length - 1];
561
572
  return s && s.role === "assistant" && s.isStreaming ? [
562
573
  ...o.slice(0, -1),
@@ -564,11 +575,11 @@ class kt {
564
575
  ] : o;
565
576
  }), this.isAgentStreaming = !1, this.notifyStreamingChange(!1), this.processMessageQueue();
566
577
  else if (n.type === "step-start" || n.type === "agent-start")
567
- console.log(`[Widget] ${n.type} received:`, n.agentId || ""), this.isAgentStreaming = !0, this.notifyStreamingChange(!0);
578
+ console.log(`[Widget] ${n.type} received:`, n.agentId || ""), this.isAgentStreaming = !0, this.notifyStreamingChange(!0), this.notifyProcessingChange(!0);
568
579
  else if (n.type === "step-end" || n.type === "agent-end")
569
- console.log(`[Widget] ${n.type} received`);
580
+ console.log(`[Widget] ${n.type} received`), n.type === "agent-end" && this.notifyProcessingChange(!1);
570
581
  else if (n.type === "tool-call") {
571
- console.log("[Widget] Tool call:", n.tool);
582
+ console.log("[Widget] Tool call:", n.tool), this.notifyProcessingChange(!0);
572
583
  const o = {
573
584
  id: K(),
574
585
  role: "tool",
@@ -580,9 +591,9 @@ class kt {
580
591
  }
581
592
  };
582
593
  this.setMessages((s) => [...s, o]), n.tool.name === "suggest_options" && n.tool.arguments?.options && this.setMessages((s) => {
583
- const i = [...s].reverse().find((l) => l.role === "assistant");
594
+ const i = [...s].reverse().find((a) => a.role === "assistant");
584
595
  return i ? s.map(
585
- (l) => l.id === i.id ? { ...l, suggestions: n.tool.arguments.options } : l
596
+ (a) => a.id === i.id ? { ...a, suggestions: n.tool.arguments.options } : a
586
597
  ) : s;
587
598
  });
588
599
  } else n.type === "tool-result" ? (console.log("[Widget] Tool result:", n.result), this.setMessages((o) => {
@@ -736,7 +747,7 @@ const se = {
736
747
  medium: "0.75rem",
737
748
  large: "1rem"
738
749
  };
739
- function At({
750
+ function $t({
740
751
  agentUrl: t,
741
752
  agentId: e,
742
753
  // Legacy props for backward compatibility
@@ -744,35 +755,37 @@ function At({
744
755
  apiUrl: o,
745
756
  mode: s = "chat",
746
757
  theme: i = "light",
747
- position: l = "bottom-right",
758
+ position: a = "bottom-right",
748
759
  size: _ = "full",
749
760
  radius: c = "medium",
750
- baseColor: a,
751
- accentColor: u = "#14B8A6",
761
+ baseColor: l,
762
+ accentColor: g = "#14B8A6",
752
763
  buttonBaseColor: r = "#000000",
753
764
  buttonAccentColor: f = "#FFFFFF",
754
765
  title: d,
755
766
  subtitle: b,
756
- emptyChatMessage: A
767
+ emptyChatMessage: S
757
768
  }) {
758
- const [w, p] = T(!1), [h, x] = T([]), [$, H] = T(""), [S, z] = T(!1), [k, P] = T(!1), [I, W] = T(null), [F, Ye] = T(!1), [oe, Ze] = T(0), V = Fe(null), fe = Fe(null);
769
+ const [y, p] = E(!1), [h, M] = E([]), [W, T] = E(""), [$, z] = E(!1), [A, H] = E(!1), [I, N] = E(null), [x, Ye] = E(!1), [Ze, et] = E(!1), [oe, tt] = E(0), V = Fe(null), fe = Fe(null);
759
770
  xe(() => ((async () => {
760
771
  if (t && e) {
761
772
  console.log("[AriaFlow Widget] Using new agent resolution:", { agentUrl: t, agentId: e });
762
- const M = new kt(t, e);
763
- V.current = M;
773
+ const F = new St(t, e);
774
+ V.current = F;
764
775
  try {
765
- M.onMessages((N) => {
766
- console.log("[AriaFlow Widget] Messages updated:", N.length), x(N);
767
- }), M.onConnectionChange((N) => {
768
- console.log("[AriaFlow Widget] Connection state:", N), z(N), N && P(!0);
769
- }), M.onStreamingChange((N) => {
770
- console.log("[AriaFlow Widget] Streaming state:", N), Ye(N);
771
- }), M.onQueueChange((N) => {
772
- console.log("[AriaFlow Widget] Queue count:", N), Ze(N);
776
+ F.onMessages((k) => {
777
+ console.log("[AriaFlow Widget] Messages updated:", k.length), M(k);
778
+ }), F.onConnectionChange((k) => {
779
+ console.log("[AriaFlow Widget] Connection state:", k), z(k), k && H(!0);
780
+ }), F.onStreamingChange((k) => {
781
+ console.log("[AriaFlow Widget] Streaming state:", k), Ye(k);
782
+ }), F.onQueueChange((k) => {
783
+ console.log("[AriaFlow Widget] Queue count:", k), tt(k);
784
+ }), F.onProcessingChange((k) => {
785
+ console.log("[AriaFlow Widget] Processing state:", k), et(k);
773
786
  });
774
- const L = await M.initWidget();
775
- console.log("[AriaFlow Widget] Agent config received:", L), L ? (W(L), console.log("[AriaFlow Widget] Widget initialized successfully")) : console.error("[AriaFlow Widget] Agent config fetch failed");
787
+ const L = await F.initWidget();
788
+ console.log("[AriaFlow Widget] Agent config received:", L), L ? (N(L), console.log("[AriaFlow Widget] Widget initialized successfully")) : console.error("[AriaFlow Widget] Agent config fetch failed");
776
789
  } catch (L) {
777
790
  console.error("[AriaFlow Widget] Initialization error:", L);
778
791
  }
@@ -783,30 +796,30 @@ function At({
783
796
  fe.current?.scrollIntoView({ behavior: "smooth" });
784
797
  }, [h]);
785
798
  const pe = async () => {
786
- if (!$.trim() || !S) return;
787
- const y = $.trim();
788
- H("");
799
+ if (!W.trim() || !$) return;
800
+ const w = W.trim();
801
+ T("");
789
802
  try {
790
- await V.current?.sendMessage(y);
791
- } catch (M) {
792
- console.error("Failed to send message:", M);
803
+ await V.current?.sendMessage(w);
804
+ } catch (F) {
805
+ console.error("Failed to send message:", F);
793
806
  }
794
- }, et = (y) => {
795
- y.key === "Enter" && !y.shiftKey && (y.preventDefault(), pe());
796
- }, tt = (y) => {
797
- !S || F || V.current?.sendMessage(y);
798
- }, nt = d || I?.config.title || "Ninewells Hospital", ot = b || I?.config.subtitle || "How can we help you today?", it = A || I?.config.emptyChatMessage || "Start a conversation with Ninewells...";
799
- return console.log("[AriaFlow Widget] Rendering widget component", { isInitialized: k, isOpen: w, position: l }), /* @__PURE__ */ g(
807
+ }, nt = (w) => {
808
+ w.key === "Enter" && !w.shiftKey && (w.preventDefault(), pe());
809
+ }, ot = (w) => {
810
+ !$ || x || V.current?.sendMessage(w);
811
+ }, it = d || I?.config.title || "Ninewells Hospital", st = b || I?.config.subtitle || "How can we help you today?", rt = S || I?.config.emptyChatMessage || "Start a conversation with Ninewells...";
812
+ return console.log("[AriaFlow Widget] Rendering widget component", { isInitialized: A, isOpen: y, position: a }), /* @__PURE__ */ u(
800
813
  "div",
801
814
  {
802
- className: `ariaflow-widget-container ariaflow-widget-${l} ariaflow-widget-${_} ariaflow-widget-radius-${c}`,
815
+ className: `ariaflow-widget-container ariaflow-widget-${a} ariaflow-widget-${_} ariaflow-widget-radius-${c}`,
803
816
  "data-theme": i,
804
817
  style: {
805
- "--ariaflow-accent-color": u,
806
- "--ariaflow-base-color": a
818
+ "--ariaflow-accent-color": g,
819
+ "--ariaflow-base-color": l
807
820
  },
808
821
  children: [
809
- !w && /* @__PURE__ */ g(
822
+ !y && /* @__PURE__ */ u(
810
823
  "button",
811
824
  {
812
825
  className: "ariaflow-widget-launcher",
@@ -814,15 +827,15 @@ function At({
814
827
  style: {
815
828
  backgroundColor: r,
816
829
  color: f,
817
- opacity: k ? 1 : 0.8,
818
- cursor: k ? "pointer" : "wait",
830
+ opacity: A ? 1 : 0.8,
831
+ cursor: A ? "pointer" : "wait",
819
832
  position: "relative"
820
833
  },
821
- "aria-label": k ? "Open chat" : "Connecting to agent...",
822
- disabled: !k,
823
- title: k ? "Click to start chat" : "Connecting to agent...",
834
+ "aria-label": A ? "Open chat" : "Connecting to agent...",
835
+ disabled: !A,
836
+ title: A ? "Click to start chat" : "Connecting to agent...",
824
837
  children: [
825
- !k && /* @__PURE__ */ g(
838
+ !A && /* @__PURE__ */ u(
826
839
  "div",
827
840
  {
828
841
  className: "ariaflow-widget-launcher-loading",
@@ -840,7 +853,7 @@ function At({
840
853
  }
841
854
  }
842
855
  ),
843
- k && /* @__PURE__ */ g(
856
+ A && /* @__PURE__ */ u(
844
857
  "svg",
845
858
  {
846
859
  width: "24",
@@ -849,41 +862,41 @@ function At({
849
862
  fill: "none",
850
863
  stroke: "currentColor",
851
864
  strokeWidth: "2",
852
- children: /* @__PURE__ */ g("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
865
+ children: /* @__PURE__ */ u("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
853
866
  }
854
867
  )
855
868
  ]
856
869
  }
857
870
  ),
858
- w && k && /* @__PURE__ */ g(
871
+ y && A && /* @__PURE__ */ u(
859
872
  "div",
860
873
  {
861
874
  className: "ariaflow-widget-window",
862
875
  style: {
863
- backgroundColor: i === "dark" && a ? a : void 0,
876
+ backgroundColor: i === "dark" && l ? l : void 0,
864
877
  borderRadius: se[c]
865
878
  },
866
879
  children: [
867
- /* @__PURE__ */ g(
880
+ /* @__PURE__ */ u(
868
881
  "div",
869
882
  {
870
883
  className: "ariaflow-widget-header",
871
884
  style: {
872
- backgroundColor: u,
885
+ backgroundColor: g,
873
886
  borderRadius: c === "none" ? "0" : `${se[c]} ${se[c]} 0 0`
874
887
  },
875
888
  children: [
876
- /* @__PURE__ */ g("div", { className: "ariaflow-widget-header-content", children: /* @__PURE__ */ g("div", { className: "ariaflow-widget-title-group", children: [
877
- /* @__PURE__ */ g("h3", { className: "ariaflow-widget-title", children: nt }),
878
- /* @__PURE__ */ g("p", { className: "ariaflow-widget-subtitle", children: ot })
889
+ /* @__PURE__ */ u("div", { className: "ariaflow-widget-header-content", children: /* @__PURE__ */ u("div", { className: "ariaflow-widget-title-group", children: [
890
+ /* @__PURE__ */ u("h3", { className: "ariaflow-widget-title", children: it }),
891
+ /* @__PURE__ */ u("p", { className: "ariaflow-widget-subtitle", children: st })
879
892
  ] }) }),
880
- /* @__PURE__ */ g(
893
+ /* @__PURE__ */ u(
881
894
  "button",
882
895
  {
883
896
  className: "ariaflow-widget-close",
884
897
  onClick: () => p(!1),
885
898
  "aria-label": "Close chat",
886
- children: /* @__PURE__ */ g(
899
+ children: /* @__PURE__ */ u(
887
900
  "svg",
888
901
  {
889
902
  width: "20",
@@ -893,8 +906,8 @@ function At({
893
906
  stroke: "currentColor",
894
907
  strokeWidth: "2",
895
908
  children: [
896
- /* @__PURE__ */ g("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
897
- /* @__PURE__ */ g("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
909
+ /* @__PURE__ */ u("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
910
+ /* @__PURE__ */ u("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
898
911
  ]
899
912
  }
900
913
  )
@@ -903,81 +916,86 @@ function At({
903
916
  ]
904
917
  }
905
918
  ),
906
- !S && /* @__PURE__ */ g("div", { className: "ariaflow-widget-status", children: [
907
- /* @__PURE__ */ g("span", { className: "ariaflow-widget-status-dot" }),
919
+ !$ && /* @__PURE__ */ u("div", { className: "ariaflow-widget-status", children: [
920
+ /* @__PURE__ */ u("span", { className: "ariaflow-widget-status-dot" }),
908
921
  "Connecting..."
909
922
  ] }),
910
- /* @__PURE__ */ g("div", { className: "ariaflow-widget-messages", children: h.length === 0 ? /* @__PURE__ */ g("div", { className: "ariaflow-widget-empty", children: /* @__PURE__ */ g("p", { children: S ? it : "Connecting to agent..." }) }) : /* @__PURE__ */ g(U, { children: [
911
- h.map((y, M) => (h.length - 1, /* @__PURE__ */ g(
923
+ /* @__PURE__ */ u("div", { className: "ariaflow-widget-messages", children: h.length === 0 ? /* @__PURE__ */ u("div", { className: "ariaflow-widget-empty", children: /* @__PURE__ */ u("p", { children: $ ? rt : "Connecting to agent..." }) }) : /* @__PURE__ */ u(U, { children: [
924
+ h.map((w, F) => (h.length - 1, /* @__PURE__ */ u(
912
925
  "div",
913
926
  {
914
- className: `ariaflow-widget-message ariaflow-widget-message-${y.role}`,
915
- children: /* @__PURE__ */ g("div", { className: "ariaflow-widget-message-bubble", children: y.role === "tool" ? /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-message", children: [
916
- /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-header", children: [
927
+ className: `ariaflow-widget-message ariaflow-widget-message-${w.role}`,
928
+ children: /* @__PURE__ */ u("div", { className: "ariaflow-widget-message-bubble", children: w.role === "tool" ? /* @__PURE__ */ u("div", { className: "ariaflow-widget-tool-message", children: [
929
+ /* @__PURE__ */ u("div", { className: "ariaflow-widget-tool-header", children: [
917
930
  "🔧 ",
918
- y.toolCall?.name
931
+ w.toolCall?.name
919
932
  ] }),
920
- /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-content", children: [
921
- y.toolCall && /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-args", children: [
922
- /* @__PURE__ */ g("strong", { children: "Arguments:" }),
933
+ /* @__PURE__ */ u("div", { className: "ariaflow-widget-tool-content", children: [
934
+ w.toolCall && /* @__PURE__ */ u("div", { className: "ariaflow-widget-tool-args", children: [
935
+ /* @__PURE__ */ u("strong", { children: "Arguments:" }),
923
936
  " ",
924
- JSON.stringify(y.toolCall.arguments, null, 2)
937
+ JSON.stringify(w.toolCall.arguments, null, 2)
925
938
  ] }),
926
- y.toolResult && /* @__PURE__ */ g("div", { className: "ariaflow-widget-tool-result", children: [
927
- /* @__PURE__ */ g("strong", { children: "Result:" }),
939
+ w.toolResult && /* @__PURE__ */ u("div", { className: "ariaflow-widget-tool-result", children: [
940
+ /* @__PURE__ */ u("strong", { children: "Result:" }),
928
941
  " ",
929
- JSON.stringify(y.toolResult, null, 2)
942
+ JSON.stringify(w.toolResult, null, 2)
930
943
  ] })
931
944
  ] })
932
- ] }) : /* @__PURE__ */ g(U, { children: [
933
- y.content,
934
- y.isStreaming && /* @__PURE__ */ g("span", { className: "ariaflow-widget-typing-indicator", children: [
935
- /* @__PURE__ */ g("span", { children: "•" }),
936
- /* @__PURE__ */ g("span", { children: "•" }),
937
- /* @__PURE__ */ g("span", { children: "•" })
945
+ ] }) : /* @__PURE__ */ u(U, { children: [
946
+ w.content,
947
+ w.isStreaming && /* @__PURE__ */ u("span", { className: "ariaflow-widget-typing-indicator", children: [
948
+ /* @__PURE__ */ u("span", { children: "•" }),
949
+ /* @__PURE__ */ u("span", { children: "•" }),
950
+ /* @__PURE__ */ u("span", { children: "•" })
938
951
  ] })
939
952
  ] }) })
940
953
  },
941
- y.id
954
+ w.id
942
955
  ))),
943
- /* @__PURE__ */ g("div", { ref: fe })
956
+ /* @__PURE__ */ u("div", { ref: fe }),
957
+ Ze && !x && /* @__PURE__ */ u("div", { className: "ariaflow-widget-message ariaflow-widget-message-assistant", children: /* @__PURE__ */ u("div", { className: "ariaflow-widget-message-bubble", children: /* @__PURE__ */ u("span", { className: "ariaflow-widget-typing-indicator", children: [
958
+ /* @__PURE__ */ u("span", { children: "•" }),
959
+ /* @__PURE__ */ u("span", { children: "•" }),
960
+ /* @__PURE__ */ u("span", { children: "•" })
961
+ ] }) }) })
944
962
  ] }) }),
945
- !F && h.length > 0 && h[h.length - 1].role === "assistant" && h[h.length - 1].suggestions && h[h.length - 1].suggestions.length > 0 && /* @__PURE__ */ g("div", { className: "ariaflow-widget-suggestions", children: h[h.length - 1].suggestions.map((y) => /* @__PURE__ */ g(
963
+ !x && h.length > 0 && h[h.length - 1].role === "assistant" && h[h.length - 1].suggestions && h[h.length - 1].suggestions.length > 0 && /* @__PURE__ */ u("div", { className: "ariaflow-widget-suggestions", children: h[h.length - 1].suggestions.map((w) => /* @__PURE__ */ u(
946
964
  "button",
947
965
  {
948
966
  className: "ariaflow-widget-chip",
949
- onClick: () => tt(y),
967
+ onClick: () => ot(w),
950
968
  style: {
951
- borderColor: u,
952
- color: u,
969
+ borderColor: g,
970
+ color: g,
953
971
  backgroundColor: "rgba(255, 255, 255, 0.95)",
954
972
  backdropFilter: "blur(4px)"
955
973
  },
956
- children: y
974
+ children: w
957
975
  },
958
- y
976
+ w
959
977
  )) }),
960
- /* @__PURE__ */ g("div", { className: "ariaflow-widget-input", children: [
961
- /* @__PURE__ */ g(
978
+ /* @__PURE__ */ u("div", { className: "ariaflow-widget-input", children: [
979
+ /* @__PURE__ */ u(
962
980
  "textarea",
963
981
  {
964
- value: $,
965
- onInput: (y) => H(y.target.value),
966
- onKeyDown: et,
967
- placeholder: S ? F ? oe > 0 ? `Agent is responding... (${oe} message${oe > 1 ? "s" : ""} queued)` : "Agent is responding..." : "Type your message..." : "Connecting...",
982
+ value: W,
983
+ onInput: (w) => T(w.target.value),
984
+ onKeyDown: nt,
985
+ placeholder: $ ? x ? oe > 0 ? `Agent is responding... (${oe} message${oe > 1 ? "s" : ""} queued)` : "Agent is responding..." : "Type your message..." : "Connecting...",
968
986
  rows: 1,
969
- disabled: !S
987
+ disabled: !$
970
988
  }
971
989
  ),
972
- /* @__PURE__ */ g(
990
+ /* @__PURE__ */ u(
973
991
  "button",
974
992
  {
975
993
  className: "ariaflow-widget-send",
976
994
  onClick: pe,
977
- disabled: !$.trim() || !S,
978
- style: { backgroundColor: u },
995
+ disabled: !W.trim() || !$,
996
+ style: { backgroundColor: g },
979
997
  "aria-label": "Send message",
980
- children: /* @__PURE__ */ g(
998
+ children: /* @__PURE__ */ u(
981
999
  "svg",
982
1000
  {
983
1001
  width: "18",
@@ -987,8 +1005,8 @@ function At({
987
1005
  stroke: "currentColor",
988
1006
  strokeWidth: "2",
989
1007
  children: [
990
- /* @__PURE__ */ g("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
991
- /* @__PURE__ */ g("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
1008
+ /* @__PURE__ */ u("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
1009
+ /* @__PURE__ */ u("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
992
1010
  ]
993
1011
  }
994
1012
  )
@@ -1002,8 +1020,8 @@ function At({
1002
1020
  }
1003
1021
  );
1004
1022
  }
1005
- dt(
1006
- At,
1023
+ ht(
1024
+ $t,
1007
1025
  "ariaflow-widget",
1008
1026
  // Properties to observe from HTML attributes (mirror Vapi's naming convention)
1009
1027
  [
@@ -1029,12 +1047,12 @@ dt(
1029
1047
  // Shadow DOM (optional, set to false for light DOM)
1030
1048
  !1
1031
1049
  );
1032
- typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", Ee) : Ee());
1033
- function Ee() {
1050
+ typeof document < "u" && (document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", Pe) : Pe());
1051
+ function Pe() {
1034
1052
  const t = document.querySelectorAll("ariaflow-widget");
1035
1053
  console.log(`[AriaFlow] Initializing ${t.length} widget(s)`);
1036
1054
  }
1037
1055
  export {
1038
- At as Widget,
1039
- kt as WidgetClient
1056
+ $t as Widget,
1057
+ St as WidgetClient
1040
1058
  };
@@ -1,4 +1,4 @@
1
- (function(P,T){typeof exports=="object"&&typeof module<"u"?T(exports):typeof define=="function"&&define.amd?define(["exports"],T):(P=typeof globalThis<"u"?globalThis:P||self,T(P.AriaFlowWidget={}))})(this,function(P){"use strict";var T,m,pe,I,me,ye,we,ve,ie,se,re,q={},be=[],tt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,V=Array.isArray;function x(t,e){for(var n in e)t[n]=e[n];return t}function le(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function L(t,e,n){var o,s,i,l={};for(i in e)i=="key"?o=e[i]:i=="ref"?s=e[i]:l[i]=e[i];if(arguments.length>2&&(l.children=arguments.length>3?T.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)l[i]===void 0&&(l[i]=t.defaultProps[i]);return j(t,l,o,s,null)}function j(t,e,n,o,s){var i={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++pe,__i:-1,__u:0};return s==null&&m.vnode!=null&&m.vnode(i),i}function R(t){return t.children}function J(t,e){this.props=t,this.context=e}function Q(t,e){if(e==null)return t.__?Q(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Q(t):null}function Ce(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Ce(t)}}function ke(t){(!t.__d&&(t.__d=!0)&&I.push(t)&&!K.__r++||me!=m.debounceRendering)&&((me=m.debounceRendering)||ye)(K)}function K(){for(var t,e,n,o,s,i,l,_=1;I.length;)I.length>_&&I.sort(we),t=I.shift(),_=I.length,t.__d&&(n=void 0,o=void 0,s=(o=(e=t).__v).__e,i=[],l=[],e.__P&&((n=x({},o)).__v=o.__v+1,m.vnode&&m.vnode(n),ae(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[s]:null,i,s??Q(o),!!(32&o.__u),l),n.__v=o.__v,n.__.__k[n.__i]=n,Ne(i,n,l),o.__e=o.__=null,n.__e!=s&&Ce(n)));K.__r=0}function Ae(t,e,n,o,s,i,l,_,c,a,u){var r,f,d,C,A,v,p,h=o&&o.__k||be,F=e.length;for(c=nt(n,e,h,c,F),r=0;r<F;r++)(d=n.__k[r])!=null&&(f=d.__i==-1?q:h[d.__i]||q,d.__i=r,v=ae(t,d,f,s,i,l,_,c,a,u),C=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&ce(f.ref,null,d),u.push(d.ref,d.__c||C,d)),A==null&&C!=null&&(A=C),(p=!!(4&d.__u))||f.__k===d.__k?c=Se(d,c,t,p):typeof d.type=="function"&&v!==void 0?c=v:C&&(c=C.nextSibling),d.__u&=-7);return n.__e=A,c}function nt(t,e,n,o,s){var i,l,_,c,a,u=n.length,r=u,f=0;for(t.__k=new Array(s),i=0;i<s;i++)(l=e[i])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=t.__k[i]=j(null,l,null,null,null):V(l)?l=t.__k[i]=j(R,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=t.__k[i]=j(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):t.__k[i]=l,c=i+f,l.__=t,l.__b=t.__b+1,_=null,(a=l.__i=ot(l,n,c,r))!=-1&&(r--,(_=n[a])&&(_.__u|=2)),_==null||_.__v==null?(a==-1&&(s>u?f--:s<u&&f++),typeof l.type!="function"&&(l.__u|=4)):a!=c&&(a==c-1?f--:a==c+1?f++:(a>c?f--:f++,l.__u|=4))):t.__k[i]=null;if(r)for(i=0;i<u;i++)(_=n[i])!=null&&!(2&_.__u)&&(_.__e==o&&(o=Q(_)),Fe(_,_));return o}function Se(t,e,n,o){var s,i;if(typeof t.type=="function"){for(s=t.__k,i=0;s&&i<s.length;i++)s[i]&&(s[i].__=t,e=Se(s[i],e,n,o));return e}t.__e!=e&&(o&&(e&&t.type&&!e.parentNode&&(e=Q(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ot(t,e,n,o){var s,i,l,_=t.key,c=t.type,a=e[n],u=a!=null&&(2&a.__u)==0;if(a===null&&_==null||u&&_==a.key&&c==a.type)return n;if(o>(u?1:0)){for(s=n-1,i=n+1;s>=0||i<e.length;)if((a=e[l=s>=0?s--:i++])!=null&&!(2&a.__u)&&_==a.key&&c==a.type)return l}return-1}function $e(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||tt.test(e)?n:n+"px"}function G(t,e,n,o,s){var i,l;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||$e(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||$e(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(ve,"$1")),l=e.toLowerCase(),e=l in t||e=="onFocusOut"||e=="onFocusIn"?l.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=n,n?o?n.u=o.u:(n.u=ie,t.addEventListener(e,i?re:se,i)):t.removeEventListener(e,i?re:se,i);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function We(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ie++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function ae(t,e,n,o,s,i,l,_,c,a){var u,r,f,d,C,A,v,p,h,F,$,U,S,ne,k,D,O,W=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),i=[_=e.__e=n.__e]),(u=m.__b)&&u(e);e:if(typeof W=="function")try{if(p=e.props,h="prototype"in W&&W.prototype.render,F=(u=W.contextType)&&o[u.__c],$=u?F?F.props.value:u.__:o,n.__c?v=(r=e.__c=n.__c).__=r.__E:(h?e.__c=r=new W(p,$):(e.__c=r=new J(p,$),r.constructor=W,r.render=st),F&&F.sub(r),r.state||(r.state={}),r.__n=o,f=r.__d=!0,r.__h=[],r._sb=[]),h&&r.__s==null&&(r.__s=r.state),h&&W.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=x({},r.__s)),x(r.__s,W.getDerivedStateFromProps(p,r.__s))),d=r.props,C=r.state,r.__v=e,f)h&&W.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),h&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(h&&W.getDerivedStateFromProps==null&&p!==d&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(p,$),e.__v==n.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(p,r.__s,$)===!1){for(e.__v!=n.__v&&(r.props=p,r.state=r.__s,r.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(M){M&&(M.__=e)}),U=0;U<r._sb.length;U++)r.__h.push(r._sb[U]);r._sb=[],r.__h.length&&l.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(p,r.__s,$),h&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(d,C,A)})}if(r.context=$,r.props=p,r.__P=t,r.__e=!1,S=m.__r,ne=0,h){for(r.state=r.__s,r.__d=!1,S&&S(e),u=r.render(r.props,r.state,r.context),k=0;k<r._sb.length;k++)r.__h.push(r._sb[k]);r._sb=[]}else do r.__d=!1,S&&S(e),u=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++ne<25);r.state=r.__s,r.getChildContext!=null&&(o=x(x({},o),r.getChildContext())),h&&!f&&r.getSnapshotBeforeUpdate!=null&&(A=r.getSnapshotBeforeUpdate(d,C)),D=u,u!=null&&u.type===R&&u.key==null&&(D=xe(u.props.children)),_=Ae(t,V(D)?D:[D],e,n,o,s,i,l,_,c,a),r.base=e.__e,e.__u&=-161,r.__h.length&&l.push(r),v&&(r.__E=r.__=null)}catch(M){if(e.__v=null,c||i!=null)if(M.then){for(e.__u|=c?160:128;_&&_.nodeType==8&&_.nextSibling;)_=_.nextSibling;i[i.indexOf(_)]=null,e.__e=_}else{for(O=i.length;O--;)le(i[O]);_e(e)}else e.__e=n.__e,e.__k=n.__k,M.then||_e(e);m.__e(M,e,n)}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):_=e.__e=it(n.__e,e,n,o,s,i,l,c,a);return(u=m.diffed)&&u(e),128&e.__u?void 0:_}function _e(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(_e)}function Ne(t,e,n){for(var o=0;o<n.length;o++)ce(n[o],n[++o],n[++o]);m.__c&&m.__c(e,t),t.some(function(s){try{t=s.__h,s.__h=[],t.some(function(i){i.call(s)})}catch(i){m.__e(i,s.__v)}})}function xe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:V(t)?t.map(xe):x({},t)}function it(t,e,n,o,s,i,l,_,c){var a,u,r,f,d,C,A,v=n.props||q,p=e.props,h=e.type;if(h=="svg"?s="http://www.w3.org/2000/svg":h=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),i!=null){for(a=0;a<i.length;a++)if((d=i[a])&&"setAttribute"in d==!!h&&(h?d.localName==h:d.nodeType==3)){t=d,i[a]=null;break}}if(t==null){if(h==null)return document.createTextNode(p);t=document.createElementNS(s,h,p.is&&p),_&&(m.__m&&m.__m(e,i),_=!1),i=null}if(h==null)v===p||_&&t.data==p||(t.data=p);else{if(i=i&&T.call(t.childNodes),!_&&i!=null)for(v={},a=0;a<t.attributes.length;a++)v[(d=t.attributes[a]).name]=d.value;for(a in v)if(d=v[a],a!="children"){if(a=="dangerouslySetInnerHTML")r=d;else if(!(a in p)){if(a=="value"&&"defaultValue"in p||a=="checked"&&"defaultChecked"in p)continue;G(t,a,null,d,s)}}for(a in p)d=p[a],a=="children"?f=d:a=="dangerouslySetInnerHTML"?u=d:a=="value"?C=d:a=="checked"?A=d:_&&typeof d!="function"||v[a]===d||G(t,a,d,v[a],s);if(u)_||r&&(u.__html==r.__html||u.__html==t.innerHTML)||(t.innerHTML=u.__html),e.__k=[];else if(r&&(t.innerHTML=""),Ae(e.type=="template"?t.content:t,V(f)?f:[f],e,n,o,h=="foreignObject"?"http://www.w3.org/1999/xhtml":s,i,l,i?i[0]:n.__k&&Q(n,0),_,c),i!=null)for(a=i.length;a--;)le(i[a]);_||(a="value",h=="progress"&&C==null?t.removeAttribute("value"):C!=null&&(C!==t[a]||h=="progress"&&!C||h=="option"&&C!=v[a])&&G(t,a,C,v[a],s),a="checked",A!=null&&A!=t[a]&&G(t,a,A,v[a],s))}return t}function ce(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(s){m.__e(s,n)}}function Fe(t,e,n){var o,s;if(m.unmount&&m.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||ce(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(i){m.__e(i,e)}o.base=o.__P=null}if(o=t.__k)for(s=0;s<o.length;s++)o[s]&&Fe(o[s],e,n||typeof t.type!="function");n||le(t.__e),t.__c=t.__=t.__e=void 0}function st(t,e,n){return this.constructor(t,n)}function X(t,e,n){var o,s,i,l;e==document&&(e=document.documentElement),m.__&&m.__(t,e),s=(o=typeof n=="function")?null:n&&n.__k||e.__k,i=[],l=[],ae(e,t=(!o&&n||e).__k=L(R,null,[t]),s||q,q,e.namespaceURI,!o&&n?[n]:s?null:e.firstChild?T.call(e.childNodes):null,i,!o&&n?n:s?s.__e:e.firstChild,o,l),Ne(i,t,l)}function Me(t,e){X(t,e,Me)}function Ee(t,e,n){var o,s,i,l,_=x({},t.props);for(i in t.type&&t.type.defaultProps&&(l=t.type.defaultProps),e)i=="key"?o=e[i]:i=="ref"?s=e[i]:_[i]=e[i]===void 0&&l!=null?l[i]:e[i];return arguments.length>2&&(_.children=arguments.length>3?T.call(arguments,2):n),j(t.type,_,o||t.key,s||t.ref,null)}T=be.slice,m={__e:function(t,e,n,o){for(var s,i,l;e=e.__;)if((s=e.__c)&&!s.__)try{if((i=s.constructor)&&i.getDerivedStateFromError!=null&&(s.setState(i.getDerivedStateFromError(t)),l=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(t,o||{}),l=s.__d),l)return s.__E=s}catch(_){t=_}throw t}},pe=0,J.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=x({},this.state),typeof t=="function"&&(t=t(x({},n),this.props)),t&&x(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ke(this))},J.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ke(this))},J.prototype.render=R,I=[],ye=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,we=function(t,e){return t.__v.__b-e.__v.__b},K.__r=0,ve=/(PointerCapture)$|Capture$/i,ie=0,se=We(!1),re=We(!0);function Y(){return Y=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Y.apply(this,arguments)}function Te(t,e){if(t==null)return{};var n,o,s={},i=Object.keys(t);for(o=0;o<i.length;o++)e.indexOf(n=i[o])>=0||(s[n]=t[n]);return s}var rt=["context","children"],lt=["useFragment"];function at(t,e,n,o){function s(){var i=Reflect.construct(HTMLElement,[],s);return i._vdomComponent=t,i._root=i,i}return(s.prototype=Object.create(HTMLElement.prototype)).constructor=s,s.prototype.connectedCallback=function(){ct.call(this,o)},s.prototype.attributeChangedCallback=ut,s.prototype.disconnectedCallback=dt,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),s.observedAttributes=n,t.formAssociated&&(s.formAssociated=!0),n.forEach(function(i){Object.defineProperty(s.prototype,i,{get:function(){return this._vdom?this._vdom.props[i]:this._props[i]},set:function(l){this._vdom?this.attributeChangedCallback(i,null,l):(this._props||(this._props={}),this._props[i]=l);var _=typeof l;l!=null&&_!=="string"&&_!=="boolean"&&_!=="number"||this.setAttribute(i,l)}})}),customElements.define(e,s),s}function _t(t){this.getChildContext=function(){return t.context};var e=t.children,n=Te(t,rt);return Ee(e,n)}function ct(t){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=L(_t,Y({},this._props,{context:e.detail.context}),Ie(this,this._vdomComponent,t)),(this.hasAttribute("hydrate")?Me:X)(this._vdom,this._root)}function He(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function ut(t,e,n){if(this._vdom){var o={};o[t]=n=n??void 0,o[He(t)]=n,this._vdom=Ee(this._vdom,o),X(this._vdom,this._root)}}function dt(){X(this._vdom=null,this._root)}function Pe(t,e){var n=this,o=t.useFragment,s=Te(t,lt);return L(o?R:"slot",Y({},s,{ref:function(i){i?(n.ref=i,n._listener||(n._listener=function(l){l.stopPropagation(),l.detail.context=e},i.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function Ie(t,e,n){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var o=[],s={},i=0,l=t.attributes,_=t.childNodes;for(i=l.length;i--;)l[i].name!=="slot"&&(s[l[i].name]=l[i].value,s[He(l[i].name)]=l[i].value);for(i=_.length;i--;){var c=Ie(_[i],null,n),a=_[i].slot;a?s[a]=L(Pe,{name:a},c):o[i]=c}var u=!(!n||!n.shadow),r=e?L(Pe,{useFragment:!u},o):o;return!u&&e&&(t.innerHTML=""),L(e||t.nodeName.toLowerCase(),s,r)}var gt=0;function g(t,e,n,o,s,i){e||(e={});var l,_,c=e;if("ref"in c)for(_ in c={},e)_=="ref"?l=e[_]:c[_]=e[_];var a={type:t,props:c,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--gt,__i:-1,__u:0,__source:s,__self:i};if(typeof t=="function"&&(l=t.defaultProps))for(_ in l)c[_]===void 0&&(c[_]=l[_]);return m.vnode&&m.vnode(a),a}var B,w,ue,Re,Z=0,Ue=[],b=m,De=b.__b,Oe=b.__r,Le=b.diffed,Qe=b.__c,qe=b.unmount,je=b.__;function de(t,e){b.__h&&b.__h(w,t,Z||e),Z=0;var n=w.__H||(w.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function H(t){return Z=1,ht(Ke,t)}function ht(t,e,n){var o=de(B++,2);if(o.t=t,!o.__c&&(o.__=[Ke(void 0,e),function(_){var c=o.__N?o.__N[0]:o.__[0],a=o.t(c,_);c!==a&&(o.__N=[a,o.__[1]],o.__c.setState({}))}],o.__c=w,!w.__f)){var s=function(_,c,a){if(!o.__c.__H)return!0;var u=o.__c.__H.__.filter(function(f){return!!f.__c});if(u.every(function(f){return!f.__N}))return!i||i.call(this,_,c,a);var r=o.__c.props!==_;return u.forEach(function(f){if(f.__N){var d=f.__[0];f.__=f.__N,f.__N=void 0,d!==f.__[0]&&(r=!0)}}),i&&i.call(this,_,c,a)||r};w.__f=!0;var i=w.shouldComponentUpdate,l=w.componentWillUpdate;w.componentWillUpdate=function(_,c,a){if(this.__e){var u=i;i=void 0,s(_,c,a),i=u}l&&l.call(this,_,c,a)},w.shouldComponentUpdate=s}return o.__N||o.__}function Be(t,e){var n=de(B++,3);!b.__s&&Je(n.__H,e)&&(n.__=t,n.u=e,w.__H.__h.push(n))}function ze(t){return Z=5,ft(function(){return{current:t}},[])}function ft(t,e){var n=de(B++,7);return Je(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function pt(){for(var t;t=Ue.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ee),t.__H.__h.forEach(ge),t.__H.__h=[]}catch(e){t.__H.__h=[],b.__e(e,t.__v)}}b.__b=function(t){w=null,De&&De(t)},b.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),je&&je(t,e)},b.__r=function(t){Oe&&Oe(t),B=0;var e=(w=t.__c).__H;e&&(ue===w?(e.__h=[],w.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ee),e.__h.forEach(ge),e.__h=[],B=0)),ue=w},b.diffed=function(t){Le&&Le(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Ue.push(e)!==1&&Re===b.requestAnimationFrame||((Re=b.requestAnimationFrame)||mt)(pt)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ue=w=null},b.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ee),n.__h=n.__h.filter(function(o){return!o.__||ge(o)})}catch(o){e.some(function(s){s.__h&&(s.__h=[])}),e=[],b.__e(o,n.__v)}}),Qe&&Qe(t,e)},b.unmount=function(t){qe&&qe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{ee(o)}catch(s){e=s}}),n.__H=void 0,e&&b.__e(e,n.__v))};var Ve=typeof requestAnimationFrame=="function";function mt(t){var e,n=function(){clearTimeout(o),Ve&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,35);Ve&&(e=requestAnimationFrame(n))}function ee(t){var e=w,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),w=e}function ge(t){var e=w;t.__c=t.__(),w=e}function Je(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function Ke(t,e){return typeof e=="function"?e(t):e}const yt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let te=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=yt[n[t]&63];return e};class Ge{constructor(e,n){this.agentUrl=e,this.agentId=n,this.agentConfig=null,this.ws=null,this.messageCallbacks=new Set,this.connectionCallbacks=new Set,this.streamingCallbacks=new Set,this.queueCallbacks=new Set,this.messages=[],this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3,this.isAgentStreaming=!1,this.messageQueue=[]}async initWidget(){try{console.log("[AriaFlow Widget] Fetching agent config...",{agentUrl:this.agentUrl,agentId:this.agentId});try{const n=await fetch(`${this.agentUrl}/api/agent/${this.agentId}`);if(n.ok){const o=await n.json();return console.log("[AriaFlow Widget] Agent config received:",o),!o||o.status!=="active"?(console.error("Agent not found or inactive"),null):(this.agentConfig=o,this.maxReconnectAttempts=o.config.maxRetries||5,this.reconnectDelay=o.config.reconnectDelay||1e3,await this.connectToAgent(),o)}}catch{console.warn("[AriaFlow Widget] Agent config endpoint not available, trying fallback")}console.log("[AriaFlow Widget] Using fallback config for Railway deployment");const e={id:this.agentId,name:this.agentId==="hospital"?"Hospital Support":"Support Agent",wsUrl:`${this.agentUrl.replace(/^https/,"wss")}/ws`,status:"active",capabilities:["chat","streaming"],config:{primaryColor:"#14B8A6",position:"bottom-right",theme:"light",title:this.agentId==="hospital"?"Hospital Support":"Chat Support",subtitle:"We're here to help!",maxRetries:3,reconnectDelay:1e3}};return this.agentConfig=e,await this.connectToAgent(),e}catch(e){return console.error("Failed to initialize widget:",e),null}}async connectToAgent(){if(!this.agentConfig?.wsUrl)throw new Error("No agent WebSocket URL configured");const e=this.getSessionId(),n=`${this.agentConfig.wsUrl}/${e}`;return console.log("[AriaFlow Widget] Connecting to WebSocket:",n),new Promise((o,s)=>{try{this.ws=new WebSocket(n),this.ws.onopen=()=>{console.log("[Widget] Connected to agent"),this.reconnectAttempts=0,this.notifyConnectionChange(!0),o()},this.ws.onmessage=i=>{this.handleMessage(i)},this.ws.onclose=()=>{if(console.log("[Widget] Disconnected from agent"),this.notifyConnectionChange(!1),this.reconnectAttempts<this.maxReconnectAttempts){this.reconnectAttempts++;const i=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.log(`[Widget] Reconnecting in ${i}ms... (attempt ${this.reconnectAttempts})`),setTimeout(()=>this.connectToAgent(),i)}},this.ws.onerror=i=>{console.error("[Widget] WebSocket error:",i),s(i)}}catch(i){s(i)}})}handleMessage(e){try{const n=JSON.parse(e.data);if(n.type==="text-delta")this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,content:s.content+n.text}]:[...o,{id:te(),role:"assistant",content:n.text,timestamp:Date.now(),isStreaming:!0}]});else if(n.type==="done")console.log("[Widget] Response complete"),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,isStreaming:!1}]:o}),this.isAgentStreaming=!1,this.notifyStreamingChange(!1),this.processMessageQueue();else if(n.type==="step-start"||n.type==="agent-start")console.log(`[Widget] ${n.type} received:`,n.agentId||""),this.isAgentStreaming=!0,this.notifyStreamingChange(!0);else if(n.type==="step-end"||n.type==="agent-end")console.log(`[Widget] ${n.type} received`);else if(n.type==="tool-call"){console.log("[Widget] Tool call:",n.tool);const o={id:te(),role:"tool",content:`Calling tool: ${n.tool.name}`,timestamp:Date.now(),toolCall:{name:n.tool.name,arguments:n.tool.arguments}};this.setMessages(s=>[...s,o]),n.tool.name==="suggest_options"&&n.tool.arguments?.options&&this.setMessages(s=>{const i=[...s].reverse().find(l=>l.role==="assistant");return i?s.map(l=>l.id===i.id?{...l,suggestions:n.tool.arguments.options}:l):s})}else n.type==="tool-result"?(console.log("[Widget] Tool result:",n.result),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="tool"&&!s.toolResult?[...o.slice(0,-1),{...s,content:s.content+`
1
+ (function(H,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(H=typeof globalThis<"u"?globalThis:H||self,E(H.AriaFlowWidget={}))})(this,function(H){"use strict";var E,m,pe,I,me,ye,we,ve,ie,se,re,q={},be=[],tt=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,V=Array.isArray;function M(t,e){for(var n in e)t[n]=e[n];return t}function ae(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function L(t,e,n){var o,s,i,a={};for(i in e)i=="key"?o=e[i]:i=="ref"?s=e[i]:a[i]=e[i];if(arguments.length>2&&(a.children=arguments.length>3?E.call(arguments,2):n),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)a[i]===void 0&&(a[i]=t.defaultProps[i]);return j(t,a,o,s,null)}function j(t,e,n,o,s){var i={type:t,props:e,key:n,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++pe,__i:-1,__u:0};return s==null&&m.vnode!=null&&m.vnode(i),i}function R(t){return t.children}function J(t,e){this.props=t,this.context=e}function Q(t,e){if(e==null)return t.__?Q(t.__,t.__i+1):null;for(var n;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null)return n.__e;return typeof t.type=="function"?Q(t):null}function Ce(t){var e,n;if((t=t.__)!=null&&t.__c!=null){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if((n=t.__k[e])!=null&&n.__e!=null){t.__e=t.__c.base=n.__e;break}return Ce(t)}}function ke(t){(!t.__d&&(t.__d=!0)&&I.push(t)&&!K.__r++||me!=m.debounceRendering)&&((me=m.debounceRendering)||ye)(K)}function K(){for(var t,e,n,o,s,i,a,_=1;I.length;)I.length>_&&I.sort(we),t=I.shift(),_=I.length,t.__d&&(n=void 0,o=void 0,s=(o=(e=t).__v).__e,i=[],a=[],e.__P&&((n=M({},o)).__v=o.__v+1,m.vnode&&m.vnode(n),le(e.__P,n,o,e.__n,e.__P.namespaceURI,32&o.__u?[s]:null,i,s??Q(o),!!(32&o.__u),a),n.__v=o.__v,n.__.__k[n.__i]=n,Ne(i,n,a),o.__e=o.__=null,n.__e!=s&&Ce(n)));K.__r=0}function Ae(t,e,n,o,s,i,a,_,c,l,g){var r,f,d,C,S,v,p,h=o&&o.__k||be,P=e.length;for(c=nt(n,e,h,c,P),r=0;r<P;r++)(d=n.__k[r])!=null&&(f=d.__i==-1?q:h[d.__i]||q,d.__i=r,v=le(t,d,f,s,i,a,_,c,l,g),C=d.__e,d.ref&&f.ref!=d.ref&&(f.ref&&ce(f.ref,null,d),g.push(d.ref,d.__c||C,d)),S==null&&C!=null&&(S=C),(p=!!(4&d.__u))||f.__k===d.__k?c=Se(d,c,t,p):typeof d.type=="function"&&v!==void 0?c=v:C&&(c=C.nextSibling),d.__u&=-7);return n.__e=S,c}function nt(t,e,n,o,s){var i,a,_,c,l,g=n.length,r=g,f=0;for(t.__k=new Array(s),i=0;i<s;i++)(a=e[i])!=null&&typeof a!="boolean"&&typeof a!="function"?(typeof a=="string"||typeof a=="number"||typeof a=="bigint"||a.constructor==String?a=t.__k[i]=j(null,a,null,null,null):V(a)?a=t.__k[i]=j(R,{children:a},null,null,null):a.constructor===void 0&&a.__b>0?a=t.__k[i]=j(a.type,a.props,a.key,a.ref?a.ref:null,a.__v):t.__k[i]=a,c=i+f,a.__=t,a.__b=t.__b+1,_=null,(l=a.__i=ot(a,n,c,r))!=-1&&(r--,(_=n[l])&&(_.__u|=2)),_==null||_.__v==null?(l==-1&&(s>g?f--:s<g&&f++),typeof a.type!="function"&&(a.__u|=4)):l!=c&&(l==c-1?f--:l==c+1?f++:(l>c?f--:f++,a.__u|=4))):t.__k[i]=null;if(r)for(i=0;i<g;i++)(_=n[i])!=null&&!(2&_.__u)&&(_.__e==o&&(o=Q(_)),Fe(_,_));return o}function Se(t,e,n,o){var s,i;if(typeof t.type=="function"){for(s=t.__k,i=0;s&&i<s.length;i++)s[i]&&(s[i].__=t,e=Se(s[i],e,n,o));return e}t.__e!=e&&(o&&(e&&t.type&&!e.parentNode&&(e=Q(t)),n.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function ot(t,e,n,o){var s,i,a,_=t.key,c=t.type,l=e[n],g=l!=null&&(2&l.__u)==0;if(l===null&&_==null||g&&_==l.key&&c==l.type)return n;if(o>(g?1:0)){for(s=n-1,i=n+1;s>=0||i<e.length;)if((l=e[a=s>=0?s--:i++])!=null&&!(2&l.__u)&&_==l.key&&c==l.type)return a}return-1}function $e(t,e,n){e[0]=="-"?t.setProperty(e,n??""):t[e]=n==null?"":typeof n!="number"||tt.test(e)?n:n+"px"}function G(t,e,n,o,s){var i,a;e:if(e=="style")if(typeof n=="string")t.style.cssText=n;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)n&&e in n||$e(t.style,e,"");if(n)for(e in n)o&&n[e]==o[e]||$e(t.style,e,n[e])}else if(e[0]=="o"&&e[1]=="n")i=e!=(e=e.replace(ve,"$1")),a=e.toLowerCase(),e=a in t||e=="onFocusOut"||e=="onFocusIn"?a.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+i]=n,n?o?n.u=o.u:(n.u=ie,t.addEventListener(e,i?re:se,i)):t.removeEventListener(e,i?re:se,i);else{if(s=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&n==1?"":n))}}function We(t){return function(e){if(this.l){var n=this.l[e.type+t];if(e.t==null)e.t=ie++;else if(e.t<n.u)return;return n(m.event?m.event(e):e)}}}function le(t,e,n,o,s,i,a,_,c,l){var g,r,f,d,C,S,v,p,h,P,W,U,$,ne,A,D,O,N=e.type;if(e.constructor!==void 0)return null;128&n.__u&&(c=!!(32&n.__u),i=[_=e.__e=n.__e]),(g=m.__b)&&g(e);e:if(typeof N=="function")try{if(p=e.props,h="prototype"in N&&N.prototype.render,P=(g=N.contextType)&&o[g.__c],W=g?P?P.props.value:g.__:o,n.__c?v=(r=e.__c=n.__c).__=r.__E:(h?e.__c=r=new N(p,W):(e.__c=r=new J(p,W),r.constructor=N,r.render=st),P&&P.sub(r),r.state||(r.state={}),r.__n=o,f=r.__d=!0,r.__h=[],r._sb=[]),h&&r.__s==null&&(r.__s=r.state),h&&N.getDerivedStateFromProps!=null&&(r.__s==r.state&&(r.__s=M({},r.__s)),M(r.__s,N.getDerivedStateFromProps(p,r.__s))),d=r.props,C=r.state,r.__v=e,f)h&&N.getDerivedStateFromProps==null&&r.componentWillMount!=null&&r.componentWillMount(),h&&r.componentDidMount!=null&&r.__h.push(r.componentDidMount);else{if(h&&N.getDerivedStateFromProps==null&&p!==d&&r.componentWillReceiveProps!=null&&r.componentWillReceiveProps(p,W),e.__v==n.__v||!r.__e&&r.shouldComponentUpdate!=null&&r.shouldComponentUpdate(p,r.__s,W)===!1){for(e.__v!=n.__v&&(r.props=p,r.state=r.__s,r.__d=!1),e.__e=n.__e,e.__k=n.__k,e.__k.some(function(x){x&&(x.__=e)}),U=0;U<r._sb.length;U++)r.__h.push(r._sb[U]);r._sb=[],r.__h.length&&a.push(r);break e}r.componentWillUpdate!=null&&r.componentWillUpdate(p,r.__s,W),h&&r.componentDidUpdate!=null&&r.__h.push(function(){r.componentDidUpdate(d,C,S)})}if(r.context=W,r.props=p,r.__P=t,r.__e=!1,$=m.__r,ne=0,h){for(r.state=r.__s,r.__d=!1,$&&$(e),g=r.render(r.props,r.state,r.context),A=0;A<r._sb.length;A++)r.__h.push(r._sb[A]);r._sb=[]}else do r.__d=!1,$&&$(e),g=r.render(r.props,r.state,r.context),r.state=r.__s;while(r.__d&&++ne<25);r.state=r.__s,r.getChildContext!=null&&(o=M(M({},o),r.getChildContext())),h&&!f&&r.getSnapshotBeforeUpdate!=null&&(S=r.getSnapshotBeforeUpdate(d,C)),D=g,g!=null&&g.type===R&&g.key==null&&(D=xe(g.props.children)),_=Ae(t,V(D)?D:[D],e,n,o,s,i,a,_,c,l),r.base=e.__e,e.__u&=-161,r.__h.length&&a.push(r),v&&(r.__E=r.__=null)}catch(x){if(e.__v=null,c||i!=null)if(x.then){for(e.__u|=c?160:128;_&&_.nodeType==8&&_.nextSibling;)_=_.nextSibling;i[i.indexOf(_)]=null,e.__e=_}else{for(O=i.length;O--;)ae(i[O]);_e(e)}else e.__e=n.__e,e.__k=n.__k,x.then||_e(e);m.__e(x,e,n)}else i==null&&e.__v==n.__v?(e.__k=n.__k,e.__e=n.__e):_=e.__e=it(n.__e,e,n,o,s,i,a,c,l);return(g=m.diffed)&&g(e),128&e.__u?void 0:_}function _e(t){t&&t.__c&&(t.__c.__e=!0),t&&t.__k&&t.__k.forEach(_e)}function Ne(t,e,n){for(var o=0;o<n.length;o++)ce(n[o],n[++o],n[++o]);m.__c&&m.__c(e,t),t.some(function(s){try{t=s.__h,s.__h=[],t.some(function(i){i.call(s)})}catch(i){m.__e(i,s.__v)}})}function xe(t){return typeof t!="object"||t==null||t.__b&&t.__b>0?t:V(t)?t.map(xe):M({},t)}function it(t,e,n,o,s,i,a,_,c){var l,g,r,f,d,C,S,v=n.props||q,p=e.props,h=e.type;if(h=="svg"?s="http://www.w3.org/2000/svg":h=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),i!=null){for(l=0;l<i.length;l++)if((d=i[l])&&"setAttribute"in d==!!h&&(h?d.localName==h:d.nodeType==3)){t=d,i[l]=null;break}}if(t==null){if(h==null)return document.createTextNode(p);t=document.createElementNS(s,h,p.is&&p),_&&(m.__m&&m.__m(e,i),_=!1),i=null}if(h==null)v===p||_&&t.data==p||(t.data=p);else{if(i=i&&E.call(t.childNodes),!_&&i!=null)for(v={},l=0;l<t.attributes.length;l++)v[(d=t.attributes[l]).name]=d.value;for(l in v)if(d=v[l],l!="children"){if(l=="dangerouslySetInnerHTML")r=d;else if(!(l in p)){if(l=="value"&&"defaultValue"in p||l=="checked"&&"defaultChecked"in p)continue;G(t,l,null,d,s)}}for(l in p)d=p[l],l=="children"?f=d:l=="dangerouslySetInnerHTML"?g=d:l=="value"?C=d:l=="checked"?S=d:_&&typeof d!="function"||v[l]===d||G(t,l,d,v[l],s);if(g)_||r&&(g.__html==r.__html||g.__html==t.innerHTML)||(t.innerHTML=g.__html),e.__k=[];else if(r&&(t.innerHTML=""),Ae(e.type=="template"?t.content:t,V(f)?f:[f],e,n,o,h=="foreignObject"?"http://www.w3.org/1999/xhtml":s,i,a,i?i[0]:n.__k&&Q(n,0),_,c),i!=null)for(l=i.length;l--;)ae(i[l]);_||(l="value",h=="progress"&&C==null?t.removeAttribute("value"):C!=null&&(C!==t[l]||h=="progress"&&!C||h=="option"&&C!=v[l])&&G(t,l,C,v[l],s),l="checked",S!=null&&S!=t[l]&&G(t,l,S,v[l],s))}return t}function ce(t,e,n){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(s){m.__e(s,n)}}function Fe(t,e,n){var o,s;if(m.unmount&&m.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||ce(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(i){m.__e(i,e)}o.base=o.__P=null}if(o=t.__k)for(s=0;s<o.length;s++)o[s]&&Fe(o[s],e,n||typeof t.type!="function");n||ae(t.__e),t.__c=t.__=t.__e=void 0}function st(t,e,n){return this.constructor(t,n)}function X(t,e,n){var o,s,i,a;e==document&&(e=document.documentElement),m.__&&m.__(t,e),s=(o=typeof n=="function")?null:n&&n.__k||e.__k,i=[],a=[],le(e,t=(!o&&n||e).__k=L(R,null,[t]),s||q,q,e.namespaceURI,!o&&n?[n]:s?null:e.firstChild?E.call(e.childNodes):null,i,!o&&n?n:s?s.__e:e.firstChild,o,a),Ne(i,t,a)}function Me(t,e){X(t,e,Me)}function Pe(t,e,n){var o,s,i,a,_=M({},t.props);for(i in t.type&&t.type.defaultProps&&(a=t.type.defaultProps),e)i=="key"?o=e[i]:i=="ref"?s=e[i]:_[i]=e[i]===void 0&&a!=null?a[i]:e[i];return arguments.length>2&&(_.children=arguments.length>3?E.call(arguments,2):n),j(t.type,_,o||t.key,s||t.ref,null)}E=be.slice,m={__e:function(t,e,n,o){for(var s,i,a;e=e.__;)if((s=e.__c)&&!s.__)try{if((i=s.constructor)&&i.getDerivedStateFromError!=null&&(s.setState(i.getDerivedStateFromError(t)),a=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(t,o||{}),a=s.__d),a)return s.__E=s}catch(_){t=_}throw t}},pe=0,J.prototype.setState=function(t,e){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=M({},this.state),typeof t=="function"&&(t=t(M({},n),this.props)),t&&M(n,t),t!=null&&this.__v&&(e&&this._sb.push(e),ke(this))},J.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),ke(this))},J.prototype.render=R,I=[],ye=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,we=function(t,e){return t.__v.__b-e.__v.__b},K.__r=0,ve=/(PointerCapture)$|Capture$/i,ie=0,se=We(!1),re=We(!0);function Y(){return Y=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t},Y.apply(this,arguments)}function Ee(t,e){if(t==null)return{};var n,o,s={},i=Object.keys(t);for(o=0;o<i.length;o++)e.indexOf(n=i[o])>=0||(s[n]=t[n]);return s}var rt=["context","children"],at=["useFragment"];function lt(t,e,n,o){function s(){var i=Reflect.construct(HTMLElement,[],s);return i._vdomComponent=t,i._root=i,i}return(s.prototype=Object.create(HTMLElement.prototype)).constructor=s,s.prototype.connectedCallback=function(){ct.call(this,o)},s.prototype.attributeChangedCallback=ut,s.prototype.disconnectedCallback=gt,n=n||t.observedAttributes||Object.keys(t.propTypes||{}),s.observedAttributes=n,t.formAssociated&&(s.formAssociated=!0),n.forEach(function(i){Object.defineProperty(s.prototype,i,{get:function(){return this._vdom?this._vdom.props[i]:this._props[i]},set:function(a){this._vdom?this.attributeChangedCallback(i,null,a):(this._props||(this._props={}),this._props[i]=a);var _=typeof a;a!=null&&_!=="string"&&_!=="boolean"&&_!=="number"||this.setAttribute(i,a)}})}),customElements.define(e,s),s}function _t(t){this.getChildContext=function(){return t.context};var e=t.children,n=Ee(t,rt);return Pe(e,n)}function ct(t){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=L(_t,Y({},this._props,{context:e.detail.context}),Ie(this,this._vdomComponent,t)),(this.hasAttribute("hydrate")?Me:X)(this._vdom,this._root)}function Te(t){return t.replace(/-(\w)/g,function(e,n){return n?n.toUpperCase():""})}function ut(t,e,n){if(this._vdom){var o={};o[t]=n=n??void 0,o[Te(t)]=n,this._vdom=Pe(this._vdom,o),X(this._vdom,this._root)}}function gt(){X(this._vdom=null,this._root)}function He(t,e){var n=this,o=t.useFragment,s=Ee(t,at);return L(o?R:"slot",Y({},s,{ref:function(i){i?(n.ref=i,n._listener||(n._listener=function(a){a.stopPropagation(),a.detail.context=e},i.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function Ie(t,e,n){if(t.nodeType===3)return t.data;if(t.nodeType!==1)return null;var o=[],s={},i=0,a=t.attributes,_=t.childNodes;for(i=a.length;i--;)a[i].name!=="slot"&&(s[a[i].name]=a[i].value,s[Te(a[i].name)]=a[i].value);for(i=_.length;i--;){var c=Ie(_[i],null,n),l=_[i].slot;l?s[l]=L(He,{name:l},c):o[i]=c}var g=!(!n||!n.shadow),r=e?L(He,{useFragment:!g},o):o;return!g&&e&&(t.innerHTML=""),L(e||t.nodeName.toLowerCase(),s,r)}var dt=0;function u(t,e,n,o,s,i){e||(e={});var a,_,c=e;if("ref"in c)for(_ in c={},e)_=="ref"?a=e[_]:c[_]=e[_];var l={type:t,props:c,key:n,ref:a,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--dt,__i:-1,__u:0,__source:s,__self:i};if(typeof t=="function"&&(a=t.defaultProps))for(_ in a)c[_]===void 0&&(c[_]=a[_]);return m.vnode&&m.vnode(l),l}var B,w,ue,Re,Z=0,Ue=[],b=m,De=b.__b,Oe=b.__r,Le=b.diffed,Qe=b.__c,qe=b.unmount,je=b.__;function ge(t,e){b.__h&&b.__h(w,t,Z||e),Z=0;var n=w.__H||(w.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function T(t){return Z=1,ht(Ke,t)}function ht(t,e,n){var o=ge(B++,2);if(o.t=t,!o.__c&&(o.__=[Ke(void 0,e),function(_){var c=o.__N?o.__N[0]:o.__[0],l=o.t(c,_);c!==l&&(o.__N=[l,o.__[1]],o.__c.setState({}))}],o.__c=w,!w.__f)){var s=function(_,c,l){if(!o.__c.__H)return!0;var g=o.__c.__H.__.filter(function(f){return!!f.__c});if(g.every(function(f){return!f.__N}))return!i||i.call(this,_,c,l);var r=o.__c.props!==_;return g.forEach(function(f){if(f.__N){var d=f.__[0];f.__=f.__N,f.__N=void 0,d!==f.__[0]&&(r=!0)}}),i&&i.call(this,_,c,l)||r};w.__f=!0;var i=w.shouldComponentUpdate,a=w.componentWillUpdate;w.componentWillUpdate=function(_,c,l){if(this.__e){var g=i;i=void 0,s(_,c,l),i=g}a&&a.call(this,_,c,l)},w.shouldComponentUpdate=s}return o.__N||o.__}function Be(t,e){var n=ge(B++,3);!b.__s&&Je(n.__H,e)&&(n.__=t,n.u=e,w.__H.__h.push(n))}function ze(t){return Z=5,ft(function(){return{current:t}},[])}function ft(t,e){var n=ge(B++,7);return Je(n.__H,e)&&(n.__=t(),n.__H=e,n.__h=t),n.__}function pt(){for(var t;t=Ue.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(ee),t.__H.__h.forEach(de),t.__H.__h=[]}catch(e){t.__H.__h=[],b.__e(e,t.__v)}}b.__b=function(t){w=null,De&&De(t)},b.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),je&&je(t,e)},b.__r=function(t){Oe&&Oe(t),B=0;var e=(w=t.__c).__H;e&&(ue===w?(e.__h=[],w.__h=[],e.__.forEach(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(e.__h.forEach(ee),e.__h.forEach(de),e.__h=[],B=0)),ue=w},b.diffed=function(t){Le&&Le(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Ue.push(e)!==1&&Re===b.requestAnimationFrame||((Re=b.requestAnimationFrame)||mt)(pt)),e.__H.__.forEach(function(n){n.u&&(n.__H=n.u),n.u=void 0})),ue=w=null},b.__c=function(t,e){e.some(function(n){try{n.__h.forEach(ee),n.__h=n.__h.filter(function(o){return!o.__||de(o)})}catch(o){e.some(function(s){s.__h&&(s.__h=[])}),e=[],b.__e(o,n.__v)}}),Qe&&Qe(t,e)},b.unmount=function(t){qe&&qe(t);var e,n=t.__c;n&&n.__H&&(n.__H.__.forEach(function(o){try{ee(o)}catch(s){e=s}}),n.__H=void 0,e&&b.__e(e,n.__v))};var Ve=typeof requestAnimationFrame=="function";function mt(t){var e,n=function(){clearTimeout(o),Ve&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(n,35);Ve&&(e=requestAnimationFrame(n))}function ee(t){var e=w,n=t.__c;typeof n=="function"&&(t.__c=void 0,n()),w=e}function de(t){var e=w;t.__c=t.__(),w=e}function Je(t,e){return!t||t.length!==e.length||e.some(function(n,o){return n!==t[o]})}function Ke(t,e){return typeof e=="function"?e(t):e}const yt="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let te=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=yt[n[t]&63];return e};class Ge{constructor(e,n){this.agentUrl=e,this.agentId=n,this.agentConfig=null,this.ws=null,this.messageCallbacks=new Set,this.connectionCallbacks=new Set,this.streamingCallbacks=new Set,this.processingCallbacks=new Set,this.queueCallbacks=new Set,this.messages=[],this.reconnectAttempts=0,this.maxReconnectAttempts=5,this.reconnectDelay=1e3,this.isAgentStreaming=!1,this.isAgentProcessing=!1,this.messageQueue=[]}async initWidget(){try{console.log("[AriaFlow Widget] Fetching agent config...",{agentUrl:this.agentUrl,agentId:this.agentId});try{const n=await fetch(`${this.agentUrl}/api/agent/${this.agentId}`);if(n.ok){const o=await n.json();return console.log("[AriaFlow Widget] Agent config received:",o),!o||o.status!=="active"?(console.error("Agent not found or inactive"),null):(this.agentConfig=o,this.maxReconnectAttempts=o.config.maxRetries||5,this.reconnectDelay=o.config.reconnectDelay||1e3,await this.connectToAgent(),o)}}catch{console.warn("[AriaFlow Widget] Agent config endpoint not available, trying fallback")}console.log("[AriaFlow Widget] Using fallback config for Railway deployment");const e={id:this.agentId,name:this.agentId==="hospital"?"Hospital Support":"Support Agent",wsUrl:`${this.agentUrl.replace(/^https/,"wss")}/ws`,status:"active",capabilities:["chat","streaming"],config:{primaryColor:"#14B8A6",position:"bottom-right",theme:"light",title:this.agentId==="hospital"?"Hospital Support":"Chat Support",subtitle:"We're here to help!",maxRetries:3,reconnectDelay:1e3}};return this.agentConfig=e,await this.connectToAgent(),e}catch(e){return console.error("Failed to initialize widget:",e),null}}async connectToAgent(){if(!this.agentConfig?.wsUrl)throw new Error("No agent WebSocket URL configured");const e=this.getSessionId(),n=`${this.agentConfig.wsUrl}/${e}`;return console.log("[AriaFlow Widget] Connecting to WebSocket:",n),new Promise((o,s)=>{try{this.ws=new WebSocket(n),this.ws.onopen=()=>{console.log("[Widget] Connected to agent"),this.reconnectAttempts=0,this.notifyConnectionChange(!0),o()},this.ws.onmessage=i=>{this.handleMessage(i)},this.ws.onclose=()=>{if(console.log("[Widget] Disconnected from agent"),this.notifyConnectionChange(!1),this.reconnectAttempts<this.maxReconnectAttempts){this.reconnectAttempts++;const i=this.reconnectDelay*Math.pow(2,this.reconnectAttempts-1);console.log(`[Widget] Reconnecting in ${i}ms... (attempt ${this.reconnectAttempts})`),setTimeout(()=>this.connectToAgent(),i)}},this.ws.onerror=i=>{console.error("[Widget] WebSocket error:",i),s(i)}}catch(i){s(i)}})}onProcessingChange(e){return this.processingCallbacks.add(e),()=>{this.processingCallbacks.delete(e)}}notifyProcessingChange(e){this.isAgentProcessing=e,this.processingCallbacks.forEach(n=>n(e))}handleMessage(e){try{const n=JSON.parse(e.data);if(n.type==="text-delta")this.isAgentProcessing&&this.notifyProcessingChange(!1),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,content:s.content+n.text}]:[...o,{id:te(),role:"assistant",content:n.text,timestamp:Date.now(),isStreaming:!0}]});else if(n.type==="done")console.log("[Widget] Response complete"),this.notifyProcessingChange(!1),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="assistant"&&s.isStreaming?[...o.slice(0,-1),{...s,isStreaming:!1}]:o}),this.isAgentStreaming=!1,this.notifyStreamingChange(!1),this.processMessageQueue();else if(n.type==="step-start"||n.type==="agent-start")console.log(`[Widget] ${n.type} received:`,n.agentId||""),this.isAgentStreaming=!0,this.notifyStreamingChange(!0),this.notifyProcessingChange(!0);else if(n.type==="step-end"||n.type==="agent-end")console.log(`[Widget] ${n.type} received`),n.type==="agent-end"&&this.notifyProcessingChange(!1);else if(n.type==="tool-call"){console.log("[Widget] Tool call:",n.tool),this.notifyProcessingChange(!0);const o={id:te(),role:"tool",content:`Calling tool: ${n.tool.name}`,timestamp:Date.now(),toolCall:{name:n.tool.name,arguments:n.tool.arguments}};this.setMessages(s=>[...s,o]),n.tool.name==="suggest_options"&&n.tool.arguments?.options&&this.setMessages(s=>{const i=[...s].reverse().find(a=>a.role==="assistant");return i?s.map(a=>a.id===i.id?{...a,suggestions:n.tool.arguments.options}:a):s})}else n.type==="tool-result"?(console.log("[Widget] Tool result:",n.result),this.setMessages(o=>{const s=o[o.length-1];return s&&s.role==="tool"&&!s.toolResult?[...o.slice(0,-1),{...s,content:s.content+`
2
2
  Result: ${JSON.stringify(n.result)}`,toolResult:n.result}]:o})):n.type==="agent-start"?(console.log(`[Widget] Agent started: ${n.agentId}`),this.isAgentStreaming=!0,this.notifyStreamingChange(!0)):n.type==="handoff"?console.log(`[Widget] Handoff: ${n.from} -> ${n.to}: ${n.reason}`):n.type==="suggested-questions"?(console.log("[Widget] Suggestions received:",n.suggestions),this.setMessages(o=>{const s=[...o].reverse().find(i=>i.role==="assistant");return s?o.map(i=>i.id===s.id?{...i,suggestions:n.suggestions}:i):o})):console.log("[Widget] Unknown message type:",n.type)}catch(n){console.error("[Widget] Error parsing message:",e.data,n)}}async sendMessage(e){if(!this.ws||this.ws.readyState!==WebSocket.OPEN)throw new Error("Not connected to agent");const n={id:te(),role:"user",content:e,timestamp:Date.now()};if(this.setMessages(o=>[...o,n]),this.isAgentStreaming){console.log("[Widget] Agent is streaming, queuing message"),this.messageQueue.push(e),this.notifyQueueChange(this.messageQueue.length);return}this.sendToAgent(e)}async sendToAgent(e){const n=this.getSessionId();this.ws.send(JSON.stringify({message:e,sessionId:n}))}async processMessageQueue(){if(this.messageQueue.length!==0){if(this.messageQueue.length===1){const e=this.messageQueue.shift();console.log("[Widget] Sending queued message:",e),this.sendToAgent(e)}else{const e=this.messageQueue.join(`
3
3
 
4
- `);this.messageQueue.length=0,console.log("[Widget] Sending combined queued messages:",e),this.sendToAgent(e)}this.notifyQueueChange(this.messageQueue.length)}}getSessionId(){let e=sessionStorage.getItem("ariaflow_session_id");return e||(e=te(),sessionStorage.setItem("ariaflow_session_id",e)),e}setMessages(e){this.messages=e(this.messages),this.messageCallbacks.forEach(n=>n(this.messages))}onMessages(e){return this.messageCallbacks.add(e),e(this.messages),()=>{this.messageCallbacks.delete(e)}}onConnectionChange(e){return this.connectionCallbacks.add(e),()=>{this.connectionCallbacks.delete(e)}}onStreamingChange(e){return this.streamingCallbacks.add(e),()=>{this.streamingCallbacks.delete(e)}}onQueueChange(e){return this.queueCallbacks.add(e),()=>{this.queueCallbacks.delete(e)}}notifyConnectionChange(e){this.connectionCallbacks.forEach(n=>n(e))}notifyStreamingChange(e){this.streamingCallbacks.forEach(n=>n(e))}notifyQueueChange(e){this.queueCallbacks.forEach(n=>n(e))}getMessages(){return this.messages}getConfig(){return this.agentConfig}isConnected(){return this.ws?.readyState===WebSocket.OPEN}dispose(){this.ws&&(this.ws.close(),this.ws=null),this.messageCallbacks.clear(),this.connectionCallbacks.clear()}}const he={none:"0",small:"0.375rem",medium:"0.75rem",large:"1rem"};function Xe({agentUrl:t,agentId:e,widgetId:n,apiUrl:o,mode:s="chat",theme:i="light",position:l="bottom-right",size:_="full",radius:c="medium",baseColor:a,accentColor:u="#14B8A6",buttonBaseColor:r="#000000",buttonAccentColor:f="#FFFFFF",title:d,subtitle:C,emptyChatMessage:A}){const[v,p]=H(!1),[h,F]=H([]),[$,U]=H(""),[S,ne]=H(!1),[k,D]=H(!1),[O,W]=H(null),[M,wt]=H(!1),[fe,vt]=H(0),oe=ze(null),Ze=ze(null);Be(()=>((async()=>{if(t&&e){console.log("[AriaFlow Widget] Using new agent resolution:",{agentUrl:t,agentId:e});const E=new Ge(t,e);oe.current=E;try{E.onMessages(N=>{console.log("[AriaFlow Widget] Messages updated:",N.length),F(N)}),E.onConnectionChange(N=>{console.log("[AriaFlow Widget] Connection state:",N),ne(N),N&&D(!0)}),E.onStreamingChange(N=>{console.log("[AriaFlow Widget] Streaming state:",N),wt(N)}),E.onQueueChange(N=>{console.log("[AriaFlow Widget] Queue count:",N),vt(N)});const z=await E.initWidget();console.log("[AriaFlow Widget] Agent config received:",z),z?(W(z),console.log("[AriaFlow Widget] Widget initialized successfully")):console.error("[AriaFlow Widget] Agent config fetch failed")}catch(z){console.error("[AriaFlow Widget] Initialization error:",z)}}else t&&!e?(console.warn("[AriaFlow Widget] Direct WebSocket URLs are deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: agent-id is required")):o&&n?(console.warn("[AriaFlow Widget] Legacy widget config is deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: use agent-url + agent-id instead")):console.error("[AriaFlow Widget] Invalid configuration. Provide agent-url and agent-id.")})(),()=>{oe.current?.dispose()}),[t,e,n,o]),Be(()=>{Ze.current?.scrollIntoView({behavior:"smooth"})},[h]);const et=async()=>{if(!$.trim()||!S)return;const y=$.trim();U("");try{await oe.current?.sendMessage(y)}catch(E){console.error("Failed to send message:",E)}},bt=y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),et())},Ct=y=>{!S||M||oe.current?.sendMessage(y)},kt=d||O?.config.title||"Ninewells Hospital",At=C||O?.config.subtitle||"How can we help you today?",St=A||O?.config.emptyChatMessage||"Start a conversation with Ninewells...";return console.log("[AriaFlow Widget] Rendering widget component",{isInitialized:k,isOpen:v,position:l}),g("div",{className:`ariaflow-widget-container ariaflow-widget-${l} ariaflow-widget-${_} ariaflow-widget-radius-${c}`,"data-theme":i,style:{"--ariaflow-accent-color":u,"--ariaflow-base-color":a},children:[!v&&g("button",{className:"ariaflow-widget-launcher",onClick:()=>p(!0),style:{backgroundColor:r,color:f,opacity:k?1:.8,cursor:k?"pointer":"wait",position:"relative"},"aria-label":k?"Open chat":"Connecting to agent...",disabled:!k,title:k?"Click to start chat":"Connecting to agent...",children:[!k&&g("div",{className:"ariaflow-widget-launcher-loading",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"20px",height:"20px",border:`2px solid ${f}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),k&&g("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:g("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})]}),v&&k&&g("div",{className:"ariaflow-widget-window",style:{backgroundColor:i==="dark"&&a?a:void 0,borderRadius:he[c]},children:[g("div",{className:"ariaflow-widget-header",style:{backgroundColor:u,borderRadius:c==="none"?"0":`${he[c]} ${he[c]} 0 0`},children:[g("div",{className:"ariaflow-widget-header-content",children:g("div",{className:"ariaflow-widget-title-group",children:[g("h3",{className:"ariaflow-widget-title",children:kt}),g("p",{className:"ariaflow-widget-subtitle",children:At})]})}),g("button",{className:"ariaflow-widget-close",onClick:()=>p(!1),"aria-label":"Close chat",children:g("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[g("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),g("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),!S&&g("div",{className:"ariaflow-widget-status",children:[g("span",{className:"ariaflow-widget-status-dot"}),"Connecting..."]}),g("div",{className:"ariaflow-widget-messages",children:h.length===0?g("div",{className:"ariaflow-widget-empty",children:g("p",{children:S?St:"Connecting to agent..."})}):g(R,{children:[h.map((y,E)=>(h.length-1,g("div",{className:`ariaflow-widget-message ariaflow-widget-message-${y.role}`,children:g("div",{className:"ariaflow-widget-message-bubble",children:y.role==="tool"?g("div",{className:"ariaflow-widget-tool-message",children:[g("div",{className:"ariaflow-widget-tool-header",children:["🔧 ",y.toolCall?.name]}),g("div",{className:"ariaflow-widget-tool-content",children:[y.toolCall&&g("div",{className:"ariaflow-widget-tool-args",children:[g("strong",{children:"Arguments:"})," ",JSON.stringify(y.toolCall.arguments,null,2)]}),y.toolResult&&g("div",{className:"ariaflow-widget-tool-result",children:[g("strong",{children:"Result:"})," ",JSON.stringify(y.toolResult,null,2)]})]})]}):g(R,{children:[y.content,y.isStreaming&&g("span",{className:"ariaflow-widget-typing-indicator",children:[g("span",{children:"•"}),g("span",{children:"•"}),g("span",{children:"•"})]})]})})},y.id))),g("div",{ref:Ze})]})}),!M&&h.length>0&&h[h.length-1].role==="assistant"&&h[h.length-1].suggestions&&h[h.length-1].suggestions.length>0&&g("div",{className:"ariaflow-widget-suggestions",children:h[h.length-1].suggestions.map(y=>g("button",{className:"ariaflow-widget-chip",onClick:()=>Ct(y),style:{borderColor:u,color:u,backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(4px)"},children:y},y))}),g("div",{className:"ariaflow-widget-input",children:[g("textarea",{value:$,onInput:y=>U(y.target.value),onKeyDown:bt,placeholder:S?M?fe>0?`Agent is responding... (${fe} message${fe>1?"s":""} queued)`:"Agent is responding...":"Type your message...":"Connecting...",rows:1,disabled:!S}),g("button",{className:"ariaflow-widget-send",onClick:et,disabled:!$.trim()||!S,style:{backgroundColor:u},"aria-label":"Send message",children:g("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[g("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),g("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})]})}at(Xe,"ariaflow-widget",["agent-url","agent-id","widget-id","api-url","mode","theme","position","size","radius","base-color","accent-color","button-base-color","button-accent-color","title","subtitle","empty-chat-message"],!1),typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ye):Ye());function Ye(){const t=document.querySelectorAll("ariaflow-widget");console.log(`[AriaFlow] Initializing ${t.length} widget(s)`)}P.Widget=Xe,P.WidgetClient=Ge,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})});
4
+ `);this.messageQueue.length=0,console.log("[Widget] Sending combined queued messages:",e),this.sendToAgent(e)}this.notifyQueueChange(this.messageQueue.length)}}getSessionId(){let e=sessionStorage.getItem("ariaflow_session_id");return e||(e=te(),sessionStorage.setItem("ariaflow_session_id",e)),e}setMessages(e){this.messages=e(this.messages),this.messageCallbacks.forEach(n=>n(this.messages))}onMessages(e){return this.messageCallbacks.add(e),e(this.messages),()=>{this.messageCallbacks.delete(e)}}onConnectionChange(e){return this.connectionCallbacks.add(e),()=>{this.connectionCallbacks.delete(e)}}onStreamingChange(e){return this.streamingCallbacks.add(e),()=>{this.streamingCallbacks.delete(e)}}onQueueChange(e){return this.queueCallbacks.add(e),()=>{this.queueCallbacks.delete(e)}}notifyConnectionChange(e){this.connectionCallbacks.forEach(n=>n(e))}notifyStreamingChange(e){this.streamingCallbacks.forEach(n=>n(e))}notifyQueueChange(e){this.queueCallbacks.forEach(n=>n(e))}getMessages(){return this.messages}getConfig(){return this.agentConfig}isConnected(){return this.ws?.readyState===WebSocket.OPEN}dispose(){this.ws&&(this.ws.close(),this.ws=null),this.messageCallbacks.clear(),this.connectionCallbacks.clear()}}const he={none:"0",small:"0.375rem",medium:"0.75rem",large:"1rem"};function Xe({agentUrl:t,agentId:e,widgetId:n,apiUrl:o,mode:s="chat",theme:i="light",position:a="bottom-right",size:_="full",radius:c="medium",baseColor:l,accentColor:g="#14B8A6",buttonBaseColor:r="#000000",buttonAccentColor:f="#FFFFFF",title:d,subtitle:C,emptyChatMessage:S}){const[v,p]=T(!1),[h,P]=T([]),[W,U]=T(""),[$,ne]=T(!1),[A,D]=T(!1),[O,N]=T(null),[x,wt]=T(!1),[vt,bt]=T(!1),[fe,Ct]=T(0),oe=ze(null),Ze=ze(null);Be(()=>((async()=>{if(t&&e){console.log("[AriaFlow Widget] Using new agent resolution:",{agentUrl:t,agentId:e});const F=new Ge(t,e);oe.current=F;try{F.onMessages(k=>{console.log("[AriaFlow Widget] Messages updated:",k.length),P(k)}),F.onConnectionChange(k=>{console.log("[AriaFlow Widget] Connection state:",k),ne(k),k&&D(!0)}),F.onStreamingChange(k=>{console.log("[AriaFlow Widget] Streaming state:",k),wt(k)}),F.onQueueChange(k=>{console.log("[AriaFlow Widget] Queue count:",k),Ct(k)}),F.onProcessingChange(k=>{console.log("[AriaFlow Widget] Processing state:",k),bt(k)});const z=await F.initWidget();console.log("[AriaFlow Widget] Agent config received:",z),z?(N(z),console.log("[AriaFlow Widget] Widget initialized successfully")):console.error("[AriaFlow Widget] Agent config fetch failed")}catch(z){console.error("[AriaFlow Widget] Initialization error:",z)}}else t&&!e?(console.warn("[AriaFlow Widget] Direct WebSocket URLs are deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: agent-id is required")):o&&n?(console.warn("[AriaFlow Widget] Legacy widget config is deprecated. Use agent-url + agent-id instead."),console.error("[AriaFlow Widget] Configuration error: use agent-url + agent-id instead")):console.error("[AriaFlow Widget] Invalid configuration. Provide agent-url and agent-id.")})(),()=>{oe.current?.dispose()}),[t,e,n,o]),Be(()=>{Ze.current?.scrollIntoView({behavior:"smooth"})},[h]);const et=async()=>{if(!W.trim()||!$)return;const y=W.trim();U("");try{await oe.current?.sendMessage(y)}catch(F){console.error("Failed to send message:",F)}},kt=y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),et())},At=y=>{!$||x||oe.current?.sendMessage(y)},St=d||O?.config.title||"Ninewells Hospital",$t=C||O?.config.subtitle||"How can we help you today?",Wt=S||O?.config.emptyChatMessage||"Start a conversation with Ninewells...";return console.log("[AriaFlow Widget] Rendering widget component",{isInitialized:A,isOpen:v,position:a}),u("div",{className:`ariaflow-widget-container ariaflow-widget-${a} ariaflow-widget-${_} ariaflow-widget-radius-${c}`,"data-theme":i,style:{"--ariaflow-accent-color":g,"--ariaflow-base-color":l},children:[!v&&u("button",{className:"ariaflow-widget-launcher",onClick:()=>p(!0),style:{backgroundColor:r,color:f,opacity:A?1:.8,cursor:A?"pointer":"wait",position:"relative"},"aria-label":A?"Open chat":"Connecting to agent...",disabled:!A,title:A?"Click to start chat":"Connecting to agent...",children:[!A&&u("div",{className:"ariaflow-widget-launcher-loading",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"20px",height:"20px",border:`2px solid ${f}`,borderTop:"2px solid transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),A&&u("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:u("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})]}),v&&A&&u("div",{className:"ariaflow-widget-window",style:{backgroundColor:i==="dark"&&l?l:void 0,borderRadius:he[c]},children:[u("div",{className:"ariaflow-widget-header",style:{backgroundColor:g,borderRadius:c==="none"?"0":`${he[c]} ${he[c]} 0 0`},children:[u("div",{className:"ariaflow-widget-header-content",children:u("div",{className:"ariaflow-widget-title-group",children:[u("h3",{className:"ariaflow-widget-title",children:St}),u("p",{className:"ariaflow-widget-subtitle",children:$t})]})}),u("button",{className:"ariaflow-widget-close",onClick:()=>p(!1),"aria-label":"Close chat",children:u("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),u("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),!$&&u("div",{className:"ariaflow-widget-status",children:[u("span",{className:"ariaflow-widget-status-dot"}),"Connecting..."]}),u("div",{className:"ariaflow-widget-messages",children:h.length===0?u("div",{className:"ariaflow-widget-empty",children:u("p",{children:$?Wt:"Connecting to agent..."})}):u(R,{children:[h.map((y,F)=>(h.length-1,u("div",{className:`ariaflow-widget-message ariaflow-widget-message-${y.role}`,children:u("div",{className:"ariaflow-widget-message-bubble",children:y.role==="tool"?u("div",{className:"ariaflow-widget-tool-message",children:[u("div",{className:"ariaflow-widget-tool-header",children:["🔧 ",y.toolCall?.name]}),u("div",{className:"ariaflow-widget-tool-content",children:[y.toolCall&&u("div",{className:"ariaflow-widget-tool-args",children:[u("strong",{children:"Arguments:"})," ",JSON.stringify(y.toolCall.arguments,null,2)]}),y.toolResult&&u("div",{className:"ariaflow-widget-tool-result",children:[u("strong",{children:"Result:"})," ",JSON.stringify(y.toolResult,null,2)]})]})]}):u(R,{children:[y.content,y.isStreaming&&u("span",{className:"ariaflow-widget-typing-indicator",children:[u("span",{children:"•"}),u("span",{children:"•"}),u("span",{children:"•"})]})]})})},y.id))),u("div",{ref:Ze}),vt&&!x&&u("div",{className:"ariaflow-widget-message ariaflow-widget-message-assistant",children:u("div",{className:"ariaflow-widget-message-bubble",children:u("span",{className:"ariaflow-widget-typing-indicator",children:[u("span",{children:"•"}),u("span",{children:"•"}),u("span",{children:"•"})]})})})]})}),!x&&h.length>0&&h[h.length-1].role==="assistant"&&h[h.length-1].suggestions&&h[h.length-1].suggestions.length>0&&u("div",{className:"ariaflow-widget-suggestions",children:h[h.length-1].suggestions.map(y=>u("button",{className:"ariaflow-widget-chip",onClick:()=>At(y),style:{borderColor:g,color:g,backgroundColor:"rgba(255, 255, 255, 0.95)",backdropFilter:"blur(4px)"},children:y},y))}),u("div",{className:"ariaflow-widget-input",children:[u("textarea",{value:W,onInput:y=>U(y.target.value),onKeyDown:kt,placeholder:$?x?fe>0?`Agent is responding... (${fe} message${fe>1?"s":""} queued)`:"Agent is responding...":"Type your message...":"Connecting...",rows:1,disabled:!$}),u("button",{className:"ariaflow-widget-send",onClick:et,disabled:!W.trim()||!$,style:{backgroundColor:g},"aria-label":"Send message",children:u("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[u("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),u("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})})]})]})]})}lt(Xe,"ariaflow-widget",["agent-url","agent-id","widget-id","api-url","mode","theme","position","size","radius","base-color","accent-color","button-base-color","button-accent-color","title","subtitle","empty-chat-message"],!1),typeof document<"u"&&(document.readyState==="loading"?document.addEventListener("DOMContentLoaded",Ye):Ye());function Ye(){const t=document.querySelectorAll("ariaflow-widget");console.log(`[AriaFlow] Initializing ${t.length} widget(s)`)}H.Widget=Xe,H.WidgetClient=Ge,Object.defineProperty(H,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ariaflowagents/widget",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "type": "module",
5
5
  "description": "Embeddable chat widget for AriaFlow Universal Inbox",
6
6
  "main": "./dist/widget.js",