@aiden-voice/widget 0.1.1 → 0.2.0

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
@@ -49,7 +49,7 @@ function T(e, t) {
49
49
  function E(e) {
50
50
  if (e.__P && e.__d) {
51
51
  var t = e.__v, r = t.__e, i = [], a = [], o = y({}, t);
52
- o.__v = t.__v + 1, n.vnode && n.vnode(o), F(e.__P, o, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [r] : null, i, r ?? T(t), !!(32 & t.__u), a), o.__v = t.__v, o.__.__k[o.__i] = o, re(i, o, a), t.__e = t.__ = null, o.__e != r && D(o);
52
+ o.__v = t.__v + 1, n.vnode && n.vnode(o), ne(e.__P, o, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [r] : null, i, r ?? T(t), !!(32 & t.__u), a), o.__v = t.__v, o.__.__k[o.__i] = o, ie(i, o, a), t.__e = t.__ = null, o.__e != r && D(o);
53
53
  }
54
54
  }
55
55
  function D(e) {
@@ -69,13 +69,13 @@ function k() {
69
69
  }
70
70
  function ee(e, t, n, r, i, a, o, s, c, l, u) {
71
71
  var d, f, p, m, _, v, y = r && r.__k || g, b = t.length;
72
- for (c = A(n, t, y, c, b), d = 0; d < b; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && y[p.__i] || h, p.__i = d, v = F(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && I(f.ref, null, p), u.push(p.ref, p.__c || m, p)), _ == null && m != null && (_ = m), 4 & p.__u ? (c = j(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && v !== void 0 ? c = v : m && (c = m.nextSibling), p.__u &= -7);
72
+ for (c = A(n, t, y, c, b), d = 0; d < b; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && y[p.__i] || h, p.__i = d, v = ne(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && F(f.ref, null, p), u.push(p.ref, p.__c || m, p)), _ == null && m != null && (_ = m), 4 & p.__u ? (c = j(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && v !== void 0 ? c = v : m && (c = m.nextSibling), p.__u &= -7);
73
73
  return n.__e = _, c;
74
74
  }
75
75
  function A(e, t, n, r, i) {
76
76
  var a, o, s, c, l, u = n.length, d = u, f = 0;
77
77
  for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = S(null, o, null, null, null) : v(o) ? o = e.__k[a] = S(C, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = S(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = M(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
78
- if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = T(s)), oe(s, s));
78
+ if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = T(s)), se(s, s));
79
79
  return r;
80
80
  }
81
81
  function j(e, t, n) {
@@ -129,14 +129,14 @@ function te(e) {
129
129
  }
130
130
  };
131
131
  }
132
- function F(e, t, r, i, a, o, s, c, l, u) {
132
+ function ne(e, t, r, i, a, o, s, c, l, u) {
133
133
  var d, f, p, m, h, _, x, S, E, D, O, k, A, j, M, N, P = t.type;
134
134
  if (t.constructor !== void 0) return null;
135
135
  128 & r.__u && (l = !!(32 & r.__u), o = [c = t.__e = r.__e]), (d = n.__b) && d(t);
136
136
  n: if (typeof P == "function") {
137
137
  f = s.length;
138
138
  try {
139
- if (E = t.props, D = P.prototype && P.prototype.render, O = (d = P.contextType) && i[d.__c], k = d ? O ? O.props.value : d.__ : i, r.__c ? S = (p = t.__c = r.__c).__ = p.__E : (D ? t.__c = p = new P(E, k) : (t.__c = p = new w(E, k), p.constructor = P, p.render = se), O && O.sub(p), p.state || (p.state = {}), p.__n = i, m = p.__d = !0, p.__h = [], p._sb = []), D && p.__s == null && (p.__s = p.state), D && P.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = y({}, p.__s)), y(p.__s, P.getDerivedStateFromProps(E, p.__s))), h = p.props, _ = p.state, p.__v = t, m) D && P.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), D && p.componentDidMount != null && p.__h.push(p.componentDidMount);
139
+ if (E = t.props, D = P.prototype && P.prototype.render, O = (d = P.contextType) && i[d.__c], k = d ? O ? O.props.value : d.__ : i, r.__c ? S = (p = t.__c = r.__c).__ = p.__E : (D ? t.__c = p = new P(E, k) : (t.__c = p = new w(E, k), p.constructor = P, p.render = ce), O && O.sub(p), p.state || (p.state = {}), p.__n = i, m = p.__d = !0, p.__h = [], p._sb = []), D && p.__s == null && (p.__s = p.state), D && P.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = y({}, p.__s)), y(p.__s, P.getDerivedStateFromProps(E, p.__s))), h = p.props, _ = p.state, p.__v = t, m) D && P.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), D && p.componentDidMount != null && p.__h.push(p.componentDidMount);
140
140
  else {
141
141
  if (D && P.getDerivedStateFromProps == null && E !== h && p.componentWillReceiveProps != null && p.componentWillReceiveProps(E, k), t.__v == r.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(E, p.__s, k)) {
142
142
  t.__v != r.__v && (p.props = E, p.state = p.__s, p.__d = !1), t.__e = r.__e, t.__k = r.__k, t.__k.some(function(e) {
@@ -152,7 +152,7 @@ function F(e, t, r, i, a, o, s, c, l, u) {
152
152
  else do
153
153
  p.__d = !1, A && A(t), d = p.render(p.props, p.state, p.context), p.state = p.__s;
154
154
  while (p.__d && ++j < 25);
155
- p.state = p.__s, p.getChildContext != null && (i = y(y({}, i), p.getChildContext())), D && !m && p.getSnapshotBeforeUpdate != null && (x = p.getSnapshotBeforeUpdate(h, _)), M = d != null && d.type === C && d.key == null ? ie(d.props.children) : d, c = ee(e, v(M) ? M : [M], t, r, i, a, o, s, c, l, u), p.base = t.__e, t.__u &= -161, p.__h.length && s.push(p), S && (p.__E = p.__ = null);
155
+ p.state = p.__s, p.getChildContext != null && (i = y(y({}, i), p.getChildContext())), D && !m && p.getSnapshotBeforeUpdate != null && (x = p.getSnapshotBeforeUpdate(h, _)), M = d != null && d.type === C && d.key == null ? ae(d.props.children) : d, c = ee(e, v(M) ? M : [M], t, r, i, a, o, s, c, l, u), p.base = t.__e, t.__u &= -161, p.__h.length && s.push(p), S && (p.__E = p.__ = null);
156
156
  } catch (e) {
157
157
  if (s.length = f, t.__v = null, l || o != null) {
158
158
  if (e.then) {
@@ -160,16 +160,16 @@ function F(e, t, r, i, a, o, s, c, l, u) {
160
160
  o != null && (o[o.indexOf(c)] = null), t.__e = c;
161
161
  } else if (o != null) for (N = o.length; N--;) b(o[N]);
162
162
  } else t.__e = r.__e;
163
- t.__k ??= r.__k || [], e.then || ne(t), n.__e(e, t, r);
163
+ t.__k ??= r.__k || [], e.then || re(t), n.__e(e, t, r);
164
164
  }
165
- } else o == null && t.__v == r.__v ? (t.__k = r.__k, t.__e = r.__e) : c = t.__e = ae(r.__e, t, r, i, a, o, s, l, u);
165
+ } else o == null && t.__v == r.__v ? (t.__k = r.__k, t.__e = r.__e) : c = t.__e = oe(r.__e, t, r, i, a, o, s, l, u);
166
166
  return (d = n.diffed) && d(t), 128 & t.__u ? void 0 : c;
167
167
  }
168
- function ne(e) {
169
- e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(ne));
168
+ function re(e) {
169
+ e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(re));
170
170
  }
171
- function re(e, t, r) {
172
- for (var i = 0; i < r.length; i++) I(r[i], r[++i], r[++i]);
171
+ function ie(e, t, r) {
172
+ for (var i = 0; i < r.length; i++) F(r[i], r[++i], r[++i]);
173
173
  n.__c && n.__c(t, e), e.some(function(t) {
174
174
  try {
175
175
  e = t.__h, t.__h = [], e.some(function(e) {
@@ -180,10 +180,10 @@ function re(e, t, r) {
180
180
  }
181
181
  });
182
182
  }
183
- function ie(e) {
184
- return typeof e != "object" || !e || e.__b > 0 ? e : v(e) ? e.map(ie) : e.constructor === void 0 ? y({}, e) : null;
183
+ function ae(e) {
184
+ return typeof e != "object" || !e || e.__b > 0 ? e : v(e) ? e.map(ae) : e.constructor === void 0 ? y({}, e) : null;
185
185
  }
186
- function ae(e, r, i, a, o, s, c, l, u) {
186
+ function oe(e, r, i, a, o, s, c, l, u) {
187
187
  var d, f, p, m, g, _, y, x = i.props || h, S = r.props, C = r.type;
188
188
  if (C == "svg" ? o = "http://www.w3.org/2000/svg" : C == "math" ? o = "http://www.w3.org/1998/Math/MathML" : o ||= "http://www.w3.org/1999/xhtml", s != null) {
189
189
  for (d = 0; d < s.length; d++) if ((g = s[d]) && "setAttribute" in g == !!C && (C ? g.localName == C : g.nodeType == 3)) {
@@ -206,7 +206,7 @@ function ae(e, r, i, a, o, s, c, l, u) {
206
206
  }
207
207
  return e;
208
208
  }
209
- function I(e, t, r) {
209
+ function F(e, t, r) {
210
210
  try {
211
211
  if (typeof e == "function") {
212
212
  var i = typeof e.__u == "function";
@@ -216,9 +216,9 @@ function I(e, t, r) {
216
216
  n.__e(e, r);
217
217
  }
218
218
  }
219
- function oe(e, t, r) {
219
+ function se(e, t, r) {
220
220
  var i, a;
221
- if (n.unmount && n.unmount(e), (i = e.ref) && (i.current && i.current != e.__e || I(i, null, t)), (i = e.__c) != null) {
221
+ if (n.unmount && n.unmount(e), (i = e.ref) && (i.current && i.current != e.__e || F(i, null, t)), (i = e.__c) != null) {
222
222
  if (i.componentWillUnmount) try {
223
223
  i.componentWillUnmount();
224
224
  } catch (e) {
@@ -226,15 +226,15 @@ function oe(e, t, r) {
226
226
  }
227
227
  i.base = i.__P = i.__n = null;
228
228
  }
229
- if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && oe(i[a], t, r || typeof e.type != "function");
229
+ if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && se(i[a], t, r || typeof e.type != "function");
230
230
  r || b(e.__e), e.__c = e.__ = e.__e = void 0;
231
231
  }
232
- function se(e, t, n) {
232
+ function ce(e, t, n) {
233
233
  return this.constructor(e, n);
234
234
  }
235
- function ce(e, r, i) {
235
+ function le(e, r, i) {
236
236
  var a, o, s, c;
237
- r == document && (r = document.documentElement), n.__ && n.__(e, r), o = (a = typeof i == "function") ? null : i && i.__k || r.__k, s = [], c = [], F(r, e = (!a && i || r).__k = x(C, null, [e]), o || h, h, r.namespaceURI, !a && i ? [i] : o ? null : r.firstChild ? t.call(r.childNodes) : null, s, !a && i ? i : o ? o.__e : r.firstChild, a, c), re(s, e, c), e.props.children = null;
237
+ r == document && (r = document.documentElement), n.__ && n.__(e, r), o = (a = typeof i == "function") ? null : i && i.__k || r.__k, s = [], c = [], ne(r, e = (!a && i || r).__k = x(C, null, [e]), o || h, h, r.namespaceURI, !a && i ? [i] : o ? null : r.firstChild ? t.call(r.childNodes) : null, s, !a && i ? i : o ? o.__e : r.firstChild, a, c), ie(s, e, c), e.props.children = null;
238
238
  }
239
239
  t = g.slice, n = { __e: function(e, t, n, r) {
240
240
  for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
@@ -253,24 +253,24 @@ t = g.slice, n = { __e: function(e, t, n, r) {
253
253
  }, k.__r = 0, c = Math.random().toString(8), l = "__d" + c, u = "__a" + c, d = /(PointerCapture)$|Capture$/i, f = 0, p = te(!1), m = te(!0);
254
254
  //#endregion
255
255
  //#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/hooks/dist/hooks.module.js
256
- var L, R, le, ue, z = 0, de = [], B = n, fe = B.__b, pe = B.__r, me = B.diffed, he = B.__c, ge = B.unmount, _e = B.__;
257
- function V(e, t) {
258
- B.__h && B.__h(R, e, z || t), z = 0;
259
- var n = R.__H || (R.__H = {
256
+ var I, L, ue, de, R = 0, fe = [], z = n, pe = z.__b, me = z.__r, he = z.diffed, ge = z.__c, _e = z.unmount, ve = z.__;
257
+ function ye(e, t) {
258
+ z.__h && z.__h(L, e, R || t), R = 0;
259
+ var n = L.__H || (L.__H = {
260
260
  __: [],
261
261
  __h: []
262
262
  });
263
263
  return e >= n.__.length && n.__.push({}), n.__[e];
264
264
  }
265
- function H(e) {
266
- return z = 1, ve(we, e);
265
+ function B(e) {
266
+ return R = 1, be(De, e);
267
267
  }
268
- function ve(e, t, n) {
269
- var r = V(L++, 2);
270
- if (r.t = e, !r.__c && (r.__ = [n ? n(t) : we(void 0, t), function(e) {
268
+ function be(e, t, n) {
269
+ var r = ye(I++, 2);
270
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : De(void 0, t), function(e) {
271
271
  var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
272
272
  t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
273
- }], r.__c = R, !R.__f)) {
273
+ }], r.__c = L, !L.__f)) {
274
274
  var i = function(e, t, n) {
275
275
  if (!r.__c.__H) return !0;
276
276
  var i = !1, o = r.__c.props !== e;
@@ -286,108 +286,108 @@ function ve(e, t, n) {
286
286
  }
287
287
  return !i || o;
288
288
  };
289
- R.__f = !0;
290
- var a = R.shouldComponentUpdate, o = R.componentWillUpdate;
291
- R.componentWillUpdate = function(e, t, n) {
289
+ L.__f = !0;
290
+ var a = L.shouldComponentUpdate, o = L.componentWillUpdate;
291
+ L.componentWillUpdate = function(e, t, n) {
292
292
  if (this.__e) {
293
293
  var r = a;
294
294
  a = void 0, i(e, t, n), a = r;
295
295
  }
296
296
  o && o.call(this, e, t, n);
297
- }, R.shouldComponentUpdate = i;
297
+ }, L.shouldComponentUpdate = i;
298
298
  }
299
299
  return r.__N || r.__;
300
300
  }
301
- function U(e, t) {
302
- var n = V(L++, 3);
303
- !B.__s && Ce(n.__H, t) && (n.__ = e, n.u = t, R.__H.__h.push(n));
301
+ function V(e, t) {
302
+ var n = ye(I++, 3);
303
+ !z.__s && Ee(n.__H, t) && (n.__ = e, n.u = t, L.__H.__h.push(n));
304
304
  }
305
- function W(e) {
306
- return z = 5, ye(function() {
305
+ function H(e) {
306
+ return R = 5, xe(function() {
307
307
  return { current: e };
308
308
  }, []);
309
309
  }
310
- function ye(e, t) {
311
- var n = V(L++, 7);
312
- return Ce(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
310
+ function xe(e, t) {
311
+ var n = ye(I++, 7);
312
+ return Ee(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
313
313
  }
314
- function be() {
315
- for (var e; e = de.shift();) {
314
+ function Se() {
315
+ for (var e; e = fe.shift();) {
316
316
  var t = e.__H;
317
317
  if (e.__P && t) try {
318
- t.__h.some(G), t.__h.some(K), t.__h = [];
318
+ t.__h.some(U), t.__h.some(Te), t.__h = [];
319
319
  } catch (n) {
320
- t.__h = [], B.__e(n, e.__v);
320
+ t.__h = [], z.__e(n, e.__v);
321
321
  }
322
322
  }
323
323
  }
324
- B.__b = function(e) {
325
- R = null, fe && fe(e);
326
- }, B.__ = function(e, t) {
327
- e && t.__k && t.__k.__m && (e.__m = t.__k.__m), _e && _e(e, t);
328
- }, B.__r = function(e) {
329
- pe && pe(e), L = 0;
330
- var t = (R = e.__c).__H;
331
- t && (le === R ? (t.__h = [], R.__h = [], t.__.some(function(e) {
324
+ z.__b = function(e) {
325
+ L = null, pe && pe(e);
326
+ }, z.__ = function(e, t) {
327
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), ve && ve(e, t);
328
+ }, z.__r = function(e) {
329
+ me && me(e), I = 0;
330
+ var t = (L = e.__c).__H;
331
+ t && (ue === L ? (t.__h = [], L.__h = [], t.__.some(function(e) {
332
332
  e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
333
- })) : (t.__h.some(G), t.__h.some(K), t.__h = [], L = 0)), le = R;
334
- }, B.diffed = function(e) {
335
- me && me(e);
333
+ })) : (t.__h.some(U), t.__h.some(Te), t.__h = [], I = 0)), ue = L;
334
+ }, z.diffed = function(e) {
335
+ he && he(e);
336
336
  var t = e.__c;
337
- t && t.__H && (t.__H.__h.length && (de.push(t) !== 1 && ue === B.requestAnimationFrame || ((ue = B.requestAnimationFrame) || Se)(be)), t.__H.__.some(function(e) {
337
+ t && t.__H && (t.__H.__h.length && (fe.push(t) !== 1 && de === z.requestAnimationFrame || ((de = z.requestAnimationFrame) || we)(Se)), t.__H.__.some(function(e) {
338
338
  e.u &&= (e.__H = e.u, void 0);
339
- })), le = R = null;
340
- }, B.__c = function(e, t) {
339
+ })), ue = L = null;
340
+ }, z.__c = function(e, t) {
341
341
  t.some(function(e) {
342
342
  try {
343
- e.__h.some(G), e.__h = e.__h.filter(function(e) {
344
- return !e.__ || K(e);
343
+ e.__h.some(U), e.__h = e.__h.filter(function(e) {
344
+ return !e.__ || Te(e);
345
345
  });
346
346
  } catch (n) {
347
347
  t.some(function(e) {
348
348
  e.__h &&= [];
349
- }), t = [], B.__e(n, e.__v);
349
+ }), t = [], z.__e(n, e.__v);
350
350
  }
351
- }), he && he(e, t);
352
- }, B.unmount = function(e) {
353
- ge && ge(e);
351
+ }), ge && ge(e, t);
352
+ }, z.unmount = function(e) {
353
+ _e && _e(e);
354
354
  var t, n = e.__c;
355
355
  n && n.__H && (n.__H.__.some(function(e) {
356
356
  try {
357
- G(e);
357
+ U(e);
358
358
  } catch (e) {
359
359
  t = e;
360
360
  }
361
- }), n.__H = void 0, t && B.__e(t, n.__v));
361
+ }), n.__H = void 0, t && z.__e(t, n.__v));
362
362
  };
363
- var xe = typeof requestAnimationFrame == "function";
364
- function Se(e) {
363
+ var Ce = typeof requestAnimationFrame == "function";
364
+ function we(e) {
365
365
  var t, n = function() {
366
- clearTimeout(r), xe && cancelAnimationFrame(t), setTimeout(e);
366
+ clearTimeout(r), Ce && cancelAnimationFrame(t), setTimeout(e);
367
367
  }, r = setTimeout(n, 35);
368
- xe && (t = requestAnimationFrame(n));
368
+ Ce && (t = requestAnimationFrame(n));
369
369
  }
370
- function G(e) {
371
- var t = R, n = e.__c;
372
- typeof n == "function" && (e.__c = void 0, n()), R = t;
370
+ function U(e) {
371
+ var t = L, n = e.__c;
372
+ typeof n == "function" && (e.__c = void 0, n()), L = t;
373
373
  }
374
- function K(e) {
375
- var t = R;
376
- e.__c = e.__(), R = t;
374
+ function Te(e) {
375
+ var t = L;
376
+ e.__c = e.__(), L = t;
377
377
  }
378
- function Ce(e, t) {
378
+ function Ee(e, t) {
379
379
  return !e || e.length !== t.length || t.some(function(t, n) {
380
380
  return t !== e[n];
381
381
  });
382
382
  }
383
- function we(e, t) {
383
+ function De(e, t) {
384
384
  return typeof t == "function" ? t(e) : t;
385
385
  }
386
386
  //#endregion
387
387
  //#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
388
- var Te = 0;
388
+ var Oe = 0;
389
389
  Array.isArray;
390
- function q(e, t, r, i, a, o) {
390
+ function W(e, t, r, i, a, o) {
391
391
  t ||= {};
392
392
  var s, c, l = t;
393
393
  if ("ref" in l) for (c in l = {}, t) c == "ref" ? s = t[c] : l[c] = t[c];
@@ -402,7 +402,7 @@ function q(e, t, r, i, a, o) {
402
402
  __e: null,
403
403
  __c: null,
404
404
  constructor: void 0,
405
- __v: --Te,
405
+ __v: --Oe,
406
406
  __i: -1,
407
407
  __u: 0,
408
408
  __source: a,
@@ -412,39 +412,98 @@ function q(e, t, r, i, a, o) {
412
412
  return n.vnode && n.vnode(u), u;
413
413
  }
414
414
  //#endregion
415
+ //#region src/components/icons.tsx
416
+ function G({ name: e, size: t, children: n }) {
417
+ return /* @__PURE__ */ W("svg", {
418
+ "data-icon": e,
419
+ "aria-hidden": "true",
420
+ focusable: "false",
421
+ width: t,
422
+ height: t,
423
+ viewBox: "0 0 24 24",
424
+ fill: "none",
425
+ stroke: "currentColor",
426
+ "stroke-width": "2",
427
+ "stroke-linecap": "round",
428
+ "stroke-linejoin": "round",
429
+ children: n
430
+ });
431
+ }
432
+ function ke({ size: e = 26 }) {
433
+ return /* @__PURE__ */ W(G, {
434
+ name: "chat",
435
+ size: e,
436
+ children: [/* @__PURE__ */ W("path", { d: "M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z" }), /* @__PURE__ */ W("path", {
437
+ d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
438
+ "stroke-width": "2.5"
439
+ })]
440
+ });
441
+ }
442
+ function Ae({ size: e = 26 }) {
443
+ return /* @__PURE__ */ W(G, {
444
+ name: "chevron-down",
445
+ size: e,
446
+ children: /* @__PURE__ */ W("path", { d: "M6 9l6 6 6-6" })
447
+ });
448
+ }
449
+ function je({ size: e = 18 }) {
450
+ return /* @__PURE__ */ W(G, {
451
+ name: "close",
452
+ size: e,
453
+ children: /* @__PURE__ */ W("path", { d: "M6 6l12 12M18 6L6 18" })
454
+ });
455
+ }
456
+ var Me = "M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7";
457
+ function Ne({ size: e = 16 }) {
458
+ return /* @__PURE__ */ W(G, {
459
+ name: "thumb-up",
460
+ size: e,
461
+ children: /* @__PURE__ */ W("path", { d: Me })
462
+ });
463
+ }
464
+ function Pe({ size: e = 16 }) {
465
+ return /* @__PURE__ */ W(G, {
466
+ name: "thumb-down",
467
+ size: e,
468
+ children: /* @__PURE__ */ W("path", {
469
+ d: Me,
470
+ transform: "matrix(1 0 0 -1 0 24)"
471
+ })
472
+ });
473
+ }
474
+ //#endregion
415
475
  //#region src/components/Launcher.tsx
416
- function Ee({ isOpen: e, onClick: t, logoUrl: n, buttonRef: r }) {
417
- return /* @__PURE__ */ q("button", {
476
+ function Fe({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
477
+ let [i, a] = B("loading"), o = n !== void 0 && i !== "failed", s = o && !e && i === "loaded";
478
+ return /* @__PURE__ */ W("button", {
418
479
  type: "button",
419
480
  class: "whoo-widget-launcher",
420
481
  onClick: t,
421
482
  "aria-label": e ? "Close chat" : "Open chat",
422
483
  ref: r,
423
- children: e ? /* @__PURE__ */ q("span", {
424
- "aria-hidden": "true",
425
- children: "✕"
426
- }) : n ? /* @__PURE__ */ q("img", {
427
- class: "whoo-widget-launcher-logo",
484
+ children: [e ? /* @__PURE__ */ W(Ae, {}) : s ? null : /* @__PURE__ */ W(ke, {}), o ? /* @__PURE__ */ W("img", {
485
+ class: "whoo-widget-launcher-icon-image",
428
486
  src: n,
429
- alt: ""
430
- }) : /* @__PURE__ */ q("span", {
431
- "aria-hidden": "true",
432
- children: "💬"
433
- })
487
+ alt: "",
488
+ referrerpolicy: "no-referrer",
489
+ hidden: !s,
490
+ onLoad: () => a("loaded"),
491
+ onError: () => a("failed")
492
+ }) : null]
434
493
  });
435
494
  }
436
495
  //#endregion
437
496
  //#region src/components/Composer.tsx
438
- function De({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
439
- return /* @__PURE__ */ q("div", {
497
+ function Ie({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
498
+ return /* @__PURE__ */ W("div", {
440
499
  class: "whoo-widget-composer",
441
500
  children: [
442
- /* @__PURE__ */ q("label", {
501
+ /* @__PURE__ */ W("label", {
443
502
  class: "whoo-widget-sr-only",
444
503
  for: "whoo-widget-composer-input",
445
504
  children: "Message"
446
505
  }),
447
- /* @__PURE__ */ q("input", {
506
+ /* @__PURE__ */ W("input", {
448
507
  id: "whoo-widget-composer-input",
449
508
  class: "whoo-widget-composer-input",
450
509
  value: e,
@@ -456,7 +515,7 @@ function De({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
456
515
  e.key === "Enter" && n();
457
516
  }
458
517
  }),
459
- /* @__PURE__ */ q("button", {
518
+ /* @__PURE__ */ W("button", {
460
519
  type: "button",
461
520
  class: "whoo-widget-composer-send",
462
521
  onClick: n,
@@ -468,8 +527,8 @@ function De({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
468
527
  }
469
528
  //#endregion
470
529
  //#region src/components/ErrorBanner.tsx
471
- function Oe({ message: e }) {
472
- return /* @__PURE__ */ q("div", {
530
+ function Le({ message: e }) {
531
+ return /* @__PURE__ */ W("div", {
473
532
  class: "whoo-widget-error-banner",
474
533
  role: "alert",
475
534
  children: e
@@ -477,8 +536,8 @@ function Oe({ message: e }) {
477
536
  }
478
537
  //#endregion
479
538
  //#region src/markdown/tokenizer.ts
480
- var J = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, Y = /\*\*([^*]+)\*\*/y, X = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, Z = /\*([^*]+)\*/y, ke = /https?:\/\/\S+/y, Ae = /[.,;:!?)\]}>]+$/;
481
- function Q(e) {
539
+ var K = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, q = /\*\*([^*]+)\*\*/y, J = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, Y = /\*([^*]+)\*/y, Re = /https?:\/\/\S+/y, ze = /[.,;:!?)\]}>]+$/;
540
+ function Be(e) {
482
541
  let t = [], n = 0, r = 0, i = (n) => {
483
542
  n > r && t.push({
484
543
  type: "text",
@@ -498,56 +557,56 @@ function Q(e) {
498
557
  }
499
558
  }
500
559
  if (e[n - 1] !== "!") {
501
- J.lastIndex = n;
502
- let a = J.exec(e);
560
+ K.lastIndex = n;
561
+ let a = K.exec(e);
503
562
  if (a) {
504
563
  i(n), t.push({
505
564
  type: "link",
506
565
  text: a[1],
507
566
  url: a[2],
508
567
  start: n,
509
- end: J.lastIndex
510
- }), n = J.lastIndex, r = n;
568
+ end: K.lastIndex
569
+ }), n = K.lastIndex, r = n;
511
570
  continue;
512
571
  }
513
572
  }
514
- Y.lastIndex = n;
515
- let a = Y.exec(e);
573
+ q.lastIndex = n;
574
+ let a = q.exec(e);
516
575
  if (a) {
517
576
  i(n), t.push({
518
577
  type: "bold",
519
578
  value: a[1],
520
579
  start: n,
521
- end: Y.lastIndex
522
- }), n = Y.lastIndex, r = n;
580
+ end: q.lastIndex
581
+ }), n = q.lastIndex, r = n;
523
582
  continue;
524
583
  }
525
- X.lastIndex = n;
526
- let o = X.exec(e);
584
+ J.lastIndex = n;
585
+ let o = J.exec(e);
527
586
  if (o) {
528
587
  i(n), t.push({
529
588
  type: "italic",
530
589
  value: o[1],
531
590
  start: n,
532
- end: X.lastIndex
533
- }), n = X.lastIndex, r = n;
591
+ end: J.lastIndex
592
+ }), n = J.lastIndex, r = n;
534
593
  continue;
535
594
  }
536
- Z.lastIndex = n;
537
- let s = Z.exec(e);
595
+ Y.lastIndex = n;
596
+ let s = Y.exec(e);
538
597
  if (s) {
539
598
  i(n), t.push({
540
599
  type: "italic",
541
600
  value: s[1],
542
601
  start: n,
543
- end: Z.lastIndex
544
- }), n = Z.lastIndex, r = n;
602
+ end: Y.lastIndex
603
+ }), n = Y.lastIndex, r = n;
545
604
  continue;
546
605
  }
547
- ke.lastIndex = n;
548
- let c = ke.exec(e);
606
+ Re.lastIndex = n;
607
+ let c = Re.exec(e);
549
608
  if (c) {
550
- let e = c[0].match(Ae), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
609
+ let e = c[0].match(ze), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
551
610
  if (a.length > 0) {
552
611
  i(n), t.push({
553
612
  type: "link",
@@ -565,16 +624,16 @@ function Q(e) {
565
624
  }
566
625
  //#endregion
567
626
  //#region src/markdown/render.tsx
568
- function je(e) {
569
- return Q(e).map((e, t) => {
627
+ function Ve(e) {
628
+ return Be(e).map((e, t) => {
570
629
  switch (e.type) {
571
- case "bold": return /* @__PURE__ */ q("strong", { children: e.value }, t);
572
- case "italic": return /* @__PURE__ */ q("em", { children: e.value }, t);
573
- case "link": return /* @__PURE__ */ q("a", {
630
+ case "bold": return /* @__PURE__ */ W("strong", { children: e.value }, t);
631
+ case "italic": return /* @__PURE__ */ W("em", { children: e.value }, t);
632
+ case "link": return /* @__PURE__ */ W("a", {
574
633
  href: e.url,
575
634
  target: "_blank",
576
635
  rel: "noopener noreferrer",
577
- children: [e.text, /* @__PURE__ */ q("span", {
636
+ children: [e.text, /* @__PURE__ */ W("span", {
578
637
  class: "whoo-widget-sr-only",
579
638
  children: " (opens in new tab)"
580
639
  })]
@@ -585,7 +644,7 @@ function je(e) {
585
644
  }
586
645
  //#endregion
587
646
  //#region src/components/MessageFeedback.tsx
588
- var Me = [
647
+ var He = [
589
648
  {
590
649
  value: "",
591
650
  label: "Select a reason (optional)"
@@ -607,50 +666,50 @@ var Me = [
607
666
  label: "Other"
608
667
  }
609
668
  ];
610
- function Ne({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancel: a }) {
611
- let [o, s] = H(""), [c, l] = H(""), u = W(e.status);
612
- if (U(() => {
669
+ function Ue({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancel: a }) {
670
+ let [o, s] = B(""), [c, l] = B(""), u = H(e.status);
671
+ if (V(() => {
613
672
  let n = u.current;
614
673
  if (u.current = e.status, n === e.status) return;
615
674
  let r = t?.current;
616
675
  if (!r) return;
617
676
  let i = r.getRootNode();
618
677
  r.contains(i.activeElement) || r.focus();
619
- }, [e.status, t]), e.status === "submitted") return /* @__PURE__ */ q("div", {
678
+ }, [e.status, t]), e.status === "submitted") return /* @__PURE__ */ W("div", {
620
679
  class: "whoo-widget-feedback-submitted",
621
680
  role: "status",
622
681
  children: "Thanks for the feedback"
623
682
  });
624
- if (e.status === "expanded") return /* @__PURE__ */ q("div", {
683
+ if (e.status === "expanded") return /* @__PURE__ */ W("div", {
625
684
  class: "whoo-widget-feedback-form",
626
685
  children: [
627
- /* @__PURE__ */ q("label", { children: [/* @__PURE__ */ q("span", {
686
+ /* @__PURE__ */ W("label", { children: [/* @__PURE__ */ W("span", {
628
687
  class: "whoo-widget-sr-only",
629
688
  children: "Additional feedback"
630
- }), /* @__PURE__ */ q("textarea", {
689
+ }), /* @__PURE__ */ W("textarea", {
631
690
  class: "whoo-widget-feedback-textarea",
632
691
  value: o,
633
692
  onInput: (e) => s(e.target.value),
634
693
  placeholder: "What was wrong? (optional)"
635
694
  })] }),
636
- /* @__PURE__ */ q("select", {
695
+ /* @__PURE__ */ W("select", {
637
696
  class: "whoo-widget-feedback-select",
638
697
  "aria-label": "Feedback category",
639
698
  value: c,
640
699
  onChange: (e) => l(e.target.value),
641
- children: Me.map((e) => /* @__PURE__ */ q("option", {
700
+ children: He.map((e) => /* @__PURE__ */ W("option", {
642
701
  value: e.value,
643
702
  children: e.label
644
703
  }, e.value))
645
704
  }),
646
- /* @__PURE__ */ q("div", {
705
+ /* @__PURE__ */ W("div", {
647
706
  class: "whoo-widget-feedback-form-buttons",
648
- children: [/* @__PURE__ */ q("button", {
707
+ children: [/* @__PURE__ */ W("button", {
649
708
  type: "button",
650
709
  class: "whoo-widget-feedback-submit",
651
710
  onClick: () => i(o, c),
652
711
  children: "Submit"
653
- }), /* @__PURE__ */ q("button", {
712
+ }), /* @__PURE__ */ W("button", {
654
713
  type: "button",
655
714
  class: "whoo-widget-feedback-cancel",
656
715
  onClick: a,
@@ -660,24 +719,24 @@ function Ne({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
660
719
  ]
661
720
  });
662
721
  let d = e.status === "submitting";
663
- return /* @__PURE__ */ q("div", {
722
+ return /* @__PURE__ */ W("div", {
664
723
  class: "whoo-widget-feedback",
665
- children: [/* @__PURE__ */ q("div", {
724
+ children: [/* @__PURE__ */ W("div", {
666
725
  class: "whoo-widget-feedback-buttons",
667
- children: [/* @__PURE__ */ q("button", {
726
+ children: [/* @__PURE__ */ W("button", {
668
727
  type: "button",
669
728
  "aria-label": "Good response",
670
729
  disabled: d,
671
730
  onClick: n,
672
- children: "👍"
673
- }), /* @__PURE__ */ q("button", {
731
+ children: /* @__PURE__ */ W(Ne, {})
732
+ }), /* @__PURE__ */ W("button", {
674
733
  type: "button",
675
734
  "aria-label": "Bad response",
676
735
  disabled: d,
677
736
  onClick: r,
678
- children: "👎"
737
+ children: /* @__PURE__ */ W(Pe, {})
679
738
  })]
680
- }), e.status === "error" ? /* @__PURE__ */ q("div", {
739
+ }), e.status === "error" ? /* @__PURE__ */ W("div", {
681
740
  class: "whoo-widget-feedback-error",
682
741
  role: "status",
683
742
  children: "Couldn't send feedback"
@@ -686,39 +745,69 @@ function Ne({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
686
745
  }
687
746
  //#endregion
688
747
  //#region src/components/MessageList.tsx
689
- function Pe({ message: e, feedbackState: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancelFeedback: a }) {
690
- let o = W(null), s = e.id;
691
- return /* @__PURE__ */ q("div", {
692
- ref: o,
748
+ function We({ isSlowResponse: e }) {
749
+ return /* @__PURE__ */ W("div", {
750
+ class: "whoo-widget-pending",
751
+ role: "status",
752
+ children: [/* @__PURE__ */ W("span", {
753
+ class: "whoo-widget-typing",
754
+ "aria-hidden": "true",
755
+ children: [
756
+ /* @__PURE__ */ W("span", {}),
757
+ /* @__PURE__ */ W("span", {}),
758
+ /* @__PURE__ */ W("span", {})
759
+ ]
760
+ }), e ? /* @__PURE__ */ W("span", {
761
+ class: "whoo-widget-pending-text",
762
+ children: "Looking that up for you…"
763
+ }) : null]
764
+ });
765
+ }
766
+ function Ge({ url: e, alt: t }) {
767
+ let [n, r] = B(!1);
768
+ return n ? null : /* @__PURE__ */ W("img", {
769
+ class: "whoo-widget-empty-state-image",
770
+ src: e,
771
+ alt: t,
772
+ referrerpolicy: "no-referrer",
773
+ onError: () => r(!0)
774
+ });
775
+ }
776
+ function Ke({ message: e, feedbackState: t, pending: n, isSlowResponse: r, onThumbsUp: i, onThumbsDown: a, onSubmitDetailed: o, onCancelFeedback: s }) {
777
+ let c = H(null), l = e.id;
778
+ return /* @__PURE__ */ W("div", {
779
+ ref: c,
693
780
  tabIndex: -1,
694
781
  class: `whoo-widget-message whoo-widget-message--${e.role}`,
695
- children: [je(e.content), e.role === "assistant" && s ? /* @__PURE__ */ q(Ne, {
782
+ children: [n ? /* @__PURE__ */ W(We, { isSlowResponse: r }) : Ve(e.content), e.role === "assistant" && l ? /* @__PURE__ */ W(Ue, {
696
783
  state: t,
697
- containerRef: o,
698
- onThumbsUp: () => n(s),
699
- onThumbsDown: () => r(s),
700
- onSubmitDetailed: (e, t) => i(s, e, t),
701
- onCancel: () => a(s)
784
+ containerRef: c,
785
+ onThumbsUp: () => i(l),
786
+ onThumbsDown: () => a(l),
787
+ onSubmitDetailed: (e, t) => o(l, e, t),
788
+ onCancel: () => s(l)
702
789
  }) : null]
703
790
  });
704
791
  }
705
- function Fe({ messages: e, messageFeedback: t, lastCompletedMessageText: n, onThumbsUp: r, onThumbsDown: i, onSubmitDetailed: a, onCancelFeedback: o }) {
706
- let s = W(null);
707
- return U(() => {
708
- let e = s.current;
792
+ function qe({ messages: e, messageFeedback: t, lastCompletedMessageText: n, emptyStateImage: r, isStreaming: i = !1, isSlowResponse: a = !1, onThumbsUp: o, onThumbsDown: s, onSubmitDetailed: c, onCancelFeedback: l }) {
793
+ let u = H(null);
794
+ return V(() => {
795
+ let e = u.current;
709
796
  e && (e.scrollTop = e.scrollHeight);
710
- }, [e]), /* @__PURE__ */ q(C, { children: [/* @__PURE__ */ q("div", {
797
+ }, [e, a]), /* @__PURE__ */ W(C, { children: [/* @__PURE__ */ W("div", {
711
798
  class: "whoo-widget-message-list",
712
- ref: s,
713
- children: e.map((e, n) => /* @__PURE__ */ q(Pe, {
714
- message: e,
715
- feedbackState: e.id ? t[e.id] ?? { status: "idle" } : { status: "idle" },
716
- onThumbsUp: r,
717
- onThumbsDown: i,
718
- onSubmitDetailed: a,
719
- onCancelFeedback: o
720
- }, e.id ?? n))
721
- }), /* @__PURE__ */ q("div", {
799
+ ref: u,
800
+ children: [r ? /* @__PURE__ */ W(Ge, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ W(Ke, {
801
+ message: n,
802
+ feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
803
+ pending: i && r === e.length - 1 && n.role === "assistant" && n.content === "",
804
+ isSlowResponse: a,
805
+ onThumbsUp: o,
806
+ onThumbsDown: s,
807
+ onSubmitDetailed: c,
808
+ onCancelFeedback: l
809
+ }, n.id ?? r))]
810
+ }), /* @__PURE__ */ W("div", {
722
811
  class: "whoo-widget-sr-only",
723
812
  "aria-live": "polite",
724
813
  "aria-atomic": "true",
@@ -727,96 +816,109 @@ function Fe({ messages: e, messageFeedback: t, lastCompletedMessageText: n, onTh
727
816
  }
728
817
  //#endregion
729
818
  //#region src/components/Panel.tsx
730
- var Ie = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
731
- function Le(e) {
732
- return Array.from(e.querySelectorAll(Ie)).filter((e) => {
819
+ var Je = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
820
+ function Ye(e) {
821
+ return Array.from(e.querySelectorAll(Je)).filter((e) => {
733
822
  let t = getComputedStyle(e);
734
823
  return t.display !== "none" && t.visibility !== "hidden";
735
824
  });
736
825
  }
737
- function Re({ state: e, controller: t, greeting: n }) {
738
- let [r, i] = H(""), a = W(null), o = W(null);
739
- U(() => {
740
- o.current?.focus();
826
+ function Xe({ state: e, controller: t, greeting: n }) {
827
+ let r = H(null), i = H(null);
828
+ V(() => {
829
+ i.current?.focus();
741
830
  }, []);
742
- let s = (e) => {
831
+ let a = (e) => {
743
832
  if (e.key === "Escape") {
744
833
  t.close();
745
834
  return;
746
835
  }
747
836
  if (e.key !== "Tab") return;
748
- let n = a.current;
837
+ let n = r.current;
749
838
  if (!n) return;
750
- let r = Le(n);
751
- if (r.length === 0) return;
752
- let i = r[0], o = r[r.length - 1], s = n.getRootNode().activeElement;
839
+ let i = Ye(n);
840
+ if (i.length === 0) return;
841
+ let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
753
842
  if (!n.contains(s)) {
754
- e.preventDefault(), i.focus();
843
+ e.preventDefault(), a.focus();
755
844
  return;
756
845
  }
757
- e.shiftKey && s === i ? (e.preventDefault(), o.focus()) : !e.shiftKey && s === o && (e.preventDefault(), i.focus());
758
- }, c = () => {
759
- let n = r.trim();
760
- !n || e.isStreaming || (i(""), t.sendMessage(n));
761
- }, l = e.messages.length === 0 && n ? [{
846
+ e.shiftKey && s === a ? (e.preventDefault(), o.focus()) : !e.shiftKey && s === o && (e.preventDefault(), a.focus());
847
+ }, o = () => {
848
+ let n = e.draft.trim();
849
+ n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
850
+ }, s = `Chat with ${e.agentName ?? (t.config.name?.trim() || "Aiden")}`, c = e.messages.length === 0 && n ? [{
762
851
  role: "assistant",
763
852
  content: n,
764
853
  id: null
765
- }] : e.messages;
766
- return /* @__PURE__ */ q("div", {
854
+ }] : e.messages, l = t.emptyStateImageUrl, u = e.messages.length === 0 && l ? {
855
+ url: l,
856
+ alt: t.emptyStateImageAlt
857
+ } : void 0;
858
+ return /* @__PURE__ */ W("div", {
767
859
  class: "whoo-widget-panel",
768
860
  role: "dialog",
769
861
  "aria-modal": "true",
770
- "aria-label": "Chat with Aiden",
771
- ref: a,
772
- onKeyDown: s,
862
+ "aria-label": s,
863
+ ref: r,
864
+ onKeyDown: a,
773
865
  children: [
774
- /* @__PURE__ */ q("div", {
866
+ /* @__PURE__ */ W("div", {
775
867
  class: "whoo-widget-header",
776
- children: [/* @__PURE__ */ q("button", {
777
- type: "button",
778
- class: "whoo-widget-header-close",
779
- onClick: () => t.close(),
780
- children: "Close chat"
781
- }), e.messages.length > 0 && /* @__PURE__ */ q("button", {
782
- type: "button",
783
- class: "whoo-widget-header-reset",
784
- onClick: () => t.resetConversation(),
785
- children: "New conversation"
868
+ children: [/* @__PURE__ */ W("h2", {
869
+ class: "whoo-widget-header-title",
870
+ children: s
871
+ }), /* @__PURE__ */ W("div", {
872
+ class: "whoo-widget-header-actions",
873
+ children: [e.messages.length > 0 && /* @__PURE__ */ W("button", {
874
+ type: "button",
875
+ class: "whoo-widget-header-reset",
876
+ onClick: () => t.resetConversation(),
877
+ children: "New conversation"
878
+ }), /* @__PURE__ */ W("button", {
879
+ type: "button",
880
+ class: "whoo-widget-header-close",
881
+ "aria-label": "Close chat",
882
+ onClick: () => t.close(),
883
+ children: /* @__PURE__ */ W(je, {})
884
+ })]
786
885
  })]
787
886
  }),
788
- /* @__PURE__ */ q(Fe, {
789
- messages: l,
887
+ /* @__PURE__ */ W(qe, {
888
+ messages: c,
790
889
  messageFeedback: e.messageFeedback,
791
890
  lastCompletedMessageText: e.lastCompletedMessageText,
891
+ emptyStateImage: u,
892
+ isStreaming: e.isStreaming,
893
+ isSlowResponse: e.isSlowResponse,
792
894
  onThumbsUp: (e) => t.submitFeedback(e, "up"),
793
895
  onThumbsDown: (e) => t.expandFeedback(e),
794
896
  onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
795
897
  onCancelFeedback: (e) => t.cancelFeedback(e)
796
898
  }),
797
- e.runtimeError && /* @__PURE__ */ q(Oe, { message: e.runtimeError }),
798
- /* @__PURE__ */ q(De, {
799
- value: r,
800
- onChange: i,
801
- onSend: c,
899
+ e.runtimeError && /* @__PURE__ */ W(Le, { message: e.runtimeError }),
900
+ /* @__PURE__ */ W(Ie, {
901
+ value: e.draft,
902
+ onChange: (e) => t.setDraft(e),
903
+ onSend: o,
802
904
  disabled: e.isStreaming,
803
- inputRef: o
905
+ inputRef: i
804
906
  })
805
907
  ]
806
908
  });
807
909
  }
808
910
  //#endregion
809
911
  //#region src/components/App.tsx
810
- function ze({ controller: e }) {
811
- let [t, n] = H(e.getState()), r = W(null), i = W(t.isOpen);
812
- return U(() => (n(e.getState()), e.subscribe(n)), [e]), U(() => {
912
+ function Ze({ controller: e }) {
913
+ let [t, n] = B(e.getState()), r = H(null), i = H(t.isOpen);
914
+ return V(() => (n(e.getState()), e.subscribe(n)), [e]), V(() => {
813
915
  i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
814
- }, [t.isOpen]), t.initError ? null : /* @__PURE__ */ q(C, { children: [/* @__PURE__ */ q(Ee, {
916
+ }, [t.isOpen]), t.initError ? null : /* @__PURE__ */ W(C, { children: [/* @__PURE__ */ W(Fe, {
815
917
  isOpen: t.isOpen,
816
918
  onClick: () => t.isOpen ? e.close() : e.open(),
817
- logoUrl: e.config.logoUrl,
919
+ iconUrl: e.launcherIconUrl,
818
920
  buttonRef: r
819
- }), t.isOpen && /* @__PURE__ */ q(Re, {
921
+ }), t.isOpen && /* @__PURE__ */ W(Xe, {
820
922
  state: t,
821
923
  controller: e,
822
924
  greeting: e.config.greeting
@@ -824,26 +926,34 @@ function ze({ controller: e }) {
824
926
  }
825
927
  //#endregion
826
928
  //#region src/api/client.ts
827
- var Be = class extends Error {
929
+ var Qe = class extends Error {
828
930
  status;
829
931
  constructor(e, t) {
830
932
  super(e), this.name = "WidgetApiError", this.status = t;
831
933
  }
832
934
  };
833
- async function Ve(e, t) {
935
+ function $e(e) {
936
+ if (typeof e != "string") return null;
937
+ let t = e.trim();
938
+ return t === "" ? null : t;
939
+ }
940
+ async function et(e, t) {
834
941
  let n = await fetch(`${e}/api/v1/widget/session`, {
835
942
  method: "POST",
836
943
  headers: { "Content-Type": "application/json" },
837
944
  body: JSON.stringify({ publishable_key: t })
838
945
  });
839
- if (!n.ok) throw new Be(`Failed to create widget session (${n.status})`, n.status);
946
+ if (!n.ok) throw new Qe(`Failed to create widget session (${n.status})`, n.status);
840
947
  let r = await n.json();
841
948
  return {
842
949
  token: r.token,
843
- primaryColor: r.primary_color ?? null
950
+ primaryColor: r.primary_color ?? null,
951
+ name: $e(r.name),
952
+ accentColor: $e(r.accent_color),
953
+ inkColor: $e(r.ink_color)
844
954
  };
845
955
  }
846
- async function He(e, t, n) {
956
+ async function tt(e, t, n) {
847
957
  let r = await fetch(`${e}/api/v1/widget/feedback`, {
848
958
  method: "POST",
849
959
  headers: {
@@ -857,11 +967,11 @@ async function He(e, t, n) {
857
967
  category: n.category ?? null
858
968
  })
859
969
  });
860
- if (!r.ok) throw new Be(`Feedback submission failed (${r.status})`, r.status);
970
+ if (!r.ok) throw new Qe(`Feedback submission failed (${r.status})`, r.status);
861
971
  }
862
972
  //#endregion
863
973
  //#region src/api/sse.ts
864
- async function* Ue(e, t, n, r, i) {
974
+ async function* nt(e, t, n, r, i) {
865
975
  let a = await fetch(`${e}/api/v1/widget/chat`, {
866
976
  method: "POST",
867
977
  headers: {
@@ -874,7 +984,7 @@ async function* Ue(e, t, n, r, i) {
874
984
  }),
875
985
  signal: i
876
986
  });
877
- if (!a.ok || !a.body) throw new Be(`Chat request failed (${a.status})`, a.status);
987
+ if (!a.ok || !a.body) throw new Qe(`Chat request failed (${a.status})`, a.status);
878
988
  let o = a.body.getReader(), s = new TextDecoder(), c = "";
879
989
  for (;;) {
880
990
  let { done: e, value: t } = await o.read();
@@ -885,11 +995,11 @@ async function* Ue(e, t, n, r, i) {
885
995
  let e = c.slice(0, n);
886
996
  c = c.slice(n + 2);
887
997
  let t = e.split("\n").find((e) => e.startsWith("data: "));
888
- t && (yield We(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
998
+ t && (yield rt(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
889
999
  }
890
1000
  }
891
1001
  }
892
- function We(e) {
1002
+ function rt(e) {
893
1003
  return typeof e.error == "string" ? {
894
1004
  type: "error",
895
1005
  error: e.error,
@@ -911,17 +1021,28 @@ function We(e) {
911
1021
  };
912
1022
  }
913
1023
  //#endregion
1024
+ //#region src/imageUrl.ts
1025
+ function it(e, t) {
1026
+ if (e != null && e !== "") {
1027
+ if (typeof e == "string") try {
1028
+ let t = new URL(e);
1029
+ if (t.protocol === "https:" || t.protocol === "data:" && t.pathname.toLowerCase().startsWith("image/")) return e;
1030
+ } catch {}
1031
+ console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`);
1032
+ }
1033
+ }
1034
+ //#endregion
914
1035
  //#region src/markdown/reveal.ts
915
- var Ge = 40, Ke = 120;
916
- function qe(e) {
1036
+ var at = 40, ot = 120;
1037
+ function st(e) {
917
1038
  let t = [];
918
- for (let n of Q(e)) if (n.type === "text") {
1039
+ for (let n of Be(e)) if (n.type === "text") {
919
1040
  let e = n.value.split(/(\s+)/), r = n.start;
920
1041
  for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
921
1042
  } else t.push(n.end);
922
1043
  return t;
923
1044
  }
924
- function Je(e) {
1045
+ function ct(e) {
925
1046
  let t = null;
926
1047
  return e?.addEventListener("abort", () => {
927
1048
  t?.();
@@ -936,36 +1057,36 @@ function Je(e) {
936
1057
  });
937
1058
  };
938
1059
  }
939
- async function Ye(e, t, n) {
940
- let r = n?.wordIntervalMs ?? Ge, i = n?.tokenIntervalMs ?? Ke, a = n?.signal, o = Q(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = Je(a), l = "";
941
- for (let n of qe(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1060
+ async function lt(e, t, n) {
1061
+ let r = n?.wordIntervalMs ?? at, i = n?.tokenIntervalMs ?? ot, a = n?.signal, o = Be(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = ct(a), l = "";
1062
+ for (let n of st(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
942
1063
  l !== e && t(e);
943
1064
  }
944
1065
  //#endregion
945
1066
  //#region src/storage.ts
946
- function Xe(e) {
1067
+ function ut(e) {
947
1068
  return `whoo-aiden-widget:conversation:${e}`;
948
1069
  }
949
- function Ze(e) {
1070
+ function dt(e) {
950
1071
  try {
951
- return window.sessionStorage.getItem(Xe(e));
1072
+ return window.sessionStorage.getItem(ut(e));
952
1073
  } catch {
953
1074
  return null;
954
1075
  }
955
1076
  }
956
- function Qe(e, t) {
1077
+ function ft(e, t) {
957
1078
  try {
958
- window.sessionStorage.setItem(Xe(e), t);
1079
+ window.sessionStorage.setItem(ut(e), t);
959
1080
  } catch {}
960
1081
  }
961
- function $e(e) {
1082
+ function pt(e) {
962
1083
  try {
963
- window.sessionStorage.removeItem(Xe(e));
1084
+ window.sessionStorage.removeItem(ut(e));
964
1085
  } catch {}
965
1086
  }
966
1087
  //#endregion
967
1088
  //#region src/controller.ts
968
- var et = class {
1089
+ var mt = 8e3, ht = class {
969
1090
  config;
970
1091
  state;
971
1092
  listeners = /* @__PURE__ */ new Set();
@@ -973,9 +1094,13 @@ var et = class {
973
1094
  conversationId = null;
974
1095
  storageIdentifier;
975
1096
  activeRequestController = null;
1097
+ slowResponseTimer = null;
976
1098
  prefersReducedMotion;
1099
+ launcherIconUrl;
1100
+ emptyStateImageUrl;
1101
+ emptyStateImageAlt;
977
1102
  constructor(e) {
978
- this.config = e, this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
1103
+ this.config = e, this.launcherIconUrl = it(e.launcherIconUrl, "launcherIconUrl"), this.emptyStateImageUrl = it(e.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof e.emptyStateImageAlt == "string" ? e.emptyStateImageAlt.trim() : "", this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
979
1104
  isOpen: !1,
980
1105
  messages: [],
981
1106
  isStreaming: !1,
@@ -983,7 +1108,12 @@ var et = class {
983
1108
  runtimeError: null,
984
1109
  messageFeedback: {},
985
1110
  primaryColor: null,
986
- lastCompletedMessageText: null
1111
+ agentName: null,
1112
+ accentColor: null,
1113
+ inkColor: null,
1114
+ lastCompletedMessageText: null,
1115
+ isSlowResponse: !1,
1116
+ draft: ""
987
1117
  };
988
1118
  }
989
1119
  getState() {
@@ -992,6 +1122,9 @@ var et = class {
992
1122
  subscribe(e) {
993
1123
  return this.listeners.add(e), () => this.listeners.delete(e);
994
1124
  }
1125
+ clearSlowResponse() {
1126
+ this.slowResponseTimer !== null && (clearTimeout(this.slowResponseTimer), this.slowResponseTimer = null), this.state.isSlowResponse && this.setState({ isSlowResponse: !1 });
1127
+ }
995
1128
  setState(e) {
996
1129
  this.state = {
997
1130
  ...this.state,
@@ -1004,20 +1137,25 @@ var et = class {
1004
1137
  try {
1005
1138
  if (this.config.sessionToken) this.sessionToken = this.config.sessionToken;
1006
1139
  else if (this.config.publishableKey) {
1007
- let { token: t, primaryColor: n } = await Ve(e, this.config.publishableKey);
1008
- this.sessionToken = t, this.setState({ primaryColor: n });
1140
+ let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await et(e, this.config.publishableKey);
1141
+ this.sessionToken = t, this.setState({
1142
+ primaryColor: n,
1143
+ agentName: r,
1144
+ accentColor: i,
1145
+ inkColor: a
1146
+ });
1009
1147
  } else throw Error("WidgetConfig must include exactly one of publishableKey or sessionToken");
1010
1148
  } catch (e) {
1011
1149
  console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
1012
1150
  return;
1013
1151
  }
1014
- this.conversationId = Ze(this.storageIdentifier);
1152
+ this.conversationId = dt(this.storageIdentifier);
1015
1153
  }
1016
1154
  open() {
1017
1155
  this.setState({ isOpen: !0 });
1018
1156
  }
1019
1157
  resetConversation() {
1020
- this.activeRequestController?.abort(), this.activeRequestController = null, this.conversationId = null, $e(this.storageIdentifier), this.setState({
1158
+ this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, pt(this.storageIdentifier), this.setState({
1021
1159
  messages: [],
1022
1160
  messageFeedback: {},
1023
1161
  runtimeError: null,
@@ -1025,8 +1163,11 @@ var et = class {
1025
1163
  lastCompletedMessageText: null
1026
1164
  });
1027
1165
  }
1166
+ setDraft(e) {
1167
+ this.setState({ draft: e });
1168
+ }
1028
1169
  close() {
1029
- this.activeRequestController?.abort(), this.activeRequestController = null, this.setState({ isOpen: !1 });
1170
+ this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isOpen: !1 });
1030
1171
  }
1031
1172
  async sendMessage(e) {
1032
1173
  if (!this.sessionToken) return;
@@ -1056,24 +1197,36 @@ var et = class {
1056
1197
  }, this.setState({ messages: t });
1057
1198
  };
1058
1199
  this.activeRequestController = new AbortController();
1059
- let { signal: a } = this.activeRequestController, o = "";
1200
+ let { signal: a } = this.activeRequestController;
1201
+ this.slowResponseTimer = setTimeout(() => {
1202
+ this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
1203
+ }, mt);
1204
+ let o = () => {
1205
+ this.setState({
1206
+ runtimeError: "Something went wrong, please try again.",
1207
+ ...this.state.draft === "" ? { draft: e } : {}
1208
+ });
1209
+ }, s = "";
1060
1210
  try {
1061
- for await (let n of Ue(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, Qe(this.storageIdentifier, n.conversationId);
1062
- else if (n.type === "delta") n.verbatim && !this.prefersReducedMotion ? (await Ye(n.delta, (e) => i(e), { signal: a }), o = n.delta) : n.verbatim ? (o = n.delta, i(o)) : (o += n.delta, i(o));
1211
+ for await (let n of nt(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, ft(this.storageIdentifier, n.conversationId);
1212
+ else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await lt(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
1063
1213
  else if (n.type === "done") {
1064
- if (n.conversationId && (this.conversationId = n.conversationId, Qe(this.storageIdentifier, n.conversationId)), n.messageId) {
1214
+ if (n.conversationId && (this.conversationId = n.conversationId, ft(this.storageIdentifier, n.conversationId)), n.messageId) {
1065
1215
  let e = [...this.state.messages];
1066
1216
  e[e.length - 1] = {
1067
1217
  ...e[e.length - 1],
1068
1218
  id: n.messageId
1069
1219
  }, this.setState({ messages: e });
1070
1220
  }
1071
- this.setState({ lastCompletedMessageText: o });
1072
- } else n.type === "error" && (console.error("[whoo-aiden-widget] chat error:", n.error), this.setState({ runtimeError: "Something went wrong, please try again." }));
1221
+ this.setState({ lastCompletedMessageText: s });
1222
+ } else if (n.type === "error") {
1223
+ console.error("[whoo-aiden-widget] chat error:", n.error), o(), this.activeRequestController?.abort();
1224
+ break;
1225
+ }
1073
1226
  } catch (e) {
1074
- e?.name === "AbortError" || (console.error("[whoo-aiden-widget] chat request failed:", e), this.setState({ runtimeError: "Something went wrong, please try again." }));
1227
+ e?.name === "AbortError" || (console.error("[whoo-aiden-widget] chat request failed:", e), o());
1075
1228
  } finally {
1076
- this.activeRequestController = null, this.setState({ isStreaming: !1 });
1229
+ this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isStreaming: !1 });
1077
1230
  }
1078
1231
  }
1079
1232
  expandFeedback(e) {
@@ -1099,7 +1252,7 @@ var et = class {
1099
1252
  }
1100
1253
  } });
1101
1254
  try {
1102
- await He(i, this.sessionToken, {
1255
+ await tt(i, this.sessionToken, {
1103
1256
  messageId: e,
1104
1257
  rating: t,
1105
1258
  correction: n,
@@ -1121,73 +1274,117 @@ var et = class {
1121
1274
  } });
1122
1275
  }
1123
1276
  }
1124
- }, tt = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:20px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:var(--whoo-widget-color,#4f46e5);width:56px;height:56px;color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher-logo{object-fit:cover;border-radius:50%;width:32px;height:32px}.whoo-widget-panel{bottom:88px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:#fff;border-radius:12px;flex-direction:column;width:360px;height:480px;max-height:90vh;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}.whoo-widget-header{flex-shrink:0;justify-content:space-between;align-items:center;padding:8px 12px 0;display:flex}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color,#4f46e5);cursor:pointer;background:0 0;border:none;padding:4px 6px;font-size:12px}.whoo-widget-message-list{flex:1;min-height:100px;padding:12px;overflow-y:auto}.whoo-widget-message{border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--assistant{color:#111;background:#f0f0f0}.whoo-widget-error-banner{color:#991b1b;background:#fee2e2;padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid #e5e5e5;gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid #6b7280;border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send:disabled,.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;opacity:.6;background:0 0;border:none;padding:2px 4px;font-size:14px}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;resize:vertical;border:1px solid #6b7280;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid #6b7280;border-radius:6px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{color:#111;cursor:pointer;background:#fff;border:1px solid #6b7280;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:#6b7280;margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:#991b1b;font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline-offset:2px;outline:2px solid #111827;box-shadow:0 0 0 4px #fff}";
1125
- //#endregion
1126
- //#region src/theme.ts
1127
- function nt(e) {
1277
+ }, gt = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:20px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:var(--whoo-widget-color,#4f46e5);width:56px;height:56px;color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{display:block}.whoo-widget-launcher-icon-image{object-fit:cover;border-radius:50%;width:32px;height:32px}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:88px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:#fff;border-radius:12px;flex-direction:column;width:360px;max-width:calc(100vw - 40px);height:480px;max-height:calc(100vh - 108px);display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid #e5e5e5;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;display:flex}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:15px;font-weight:600;overflow:hidden}.whoo-widget-header-actions{flex-shrink:0;align-items:center;gap:4px;display:flex}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:#f3f4f6}.whoo-widget-message-list{flex:1;min-height:100px;padding:12px;overflow-y:auto}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{color:var(--whoo-widget-ink,#111);background:#f0f0f0}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,LinkText)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:#6b7280;border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{color:#991b1b;background:#fee2e2;padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid #e5e5e5;gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid #6b7280;border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send:disabled,.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:#4b5563;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:#111;background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;resize:vertical;border:1px solid #6b7280;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid #6b7280;border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{color:#111;cursor:pointer;background:#fff;border:1px solid #6b7280;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:#6b7280;margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:#991b1b;font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline-offset:2px;outline:2px solid #111827;box-shadow:0 0 0 4px #fff}", _t = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1278
+ function X(e) {
1279
+ if (_t.test(e.trim())) return null;
1128
1280
  let t = document.createElement("div");
1129
1281
  if (t.style.color = e, t.style.color === "") return null;
1130
- document.body.appendChild(t);
1131
- let n = getComputedStyle(t).color;
1132
- document.body.removeChild(t);
1133
- let r = n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
1134
- return r ? [
1135
- Number(r[1]),
1136
- Number(r[2]),
1137
- Number(r[3])
1138
- ] : null;
1282
+ let n = document.createElement("div");
1283
+ n.attachShadow({ mode: "open" }).appendChild(t), document.body.appendChild(n);
1284
+ let r = getComputedStyle(t).color;
1285
+ n.remove();
1286
+ let i = r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);
1287
+ if (!i) return null;
1288
+ let a = i[4] === void 0 ? 1 : Number(i[4]);
1289
+ return {
1290
+ rgb: [
1291
+ Number(i[1]),
1292
+ Number(i[2]),
1293
+ Number(i[3])
1294
+ ].map((e) => Math.round(e * a + 255 * (1 - a))),
1295
+ translucent: a < 1
1296
+ };
1139
1297
  }
1140
- function $([e, t, n]) {
1298
+ function vt(e) {
1299
+ return X(e)?.rgb ?? null;
1300
+ }
1301
+ function Z([e, t, n]) {
1141
1302
  let r = (e) => {
1142
1303
  let t = e / 255;
1143
1304
  return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
1144
1305
  };
1145
1306
  return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
1146
1307
  }
1147
- function rt(e, t) {
1308
+ function yt(e, t) {
1148
1309
  let n = Math.max(e, t), r = Math.min(e, t);
1149
1310
  return (n + .05) / (r + .05);
1150
1311
  }
1151
- function it(e) {
1152
- let t = nt(e);
1312
+ function bt(e) {
1313
+ let t = vt(e);
1153
1314
  if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
1154
- let n = $(t);
1155
- return rt(n, $([
1315
+ let n = Z(t);
1316
+ return yt(n, Z([
1156
1317
  0,
1157
1318
  0,
1158
1319
  0
1159
- ])) >= rt(n, $([
1320
+ ])) >= yt(n, Z([
1160
1321
  255,
1161
1322
  255,
1162
1323
  255
1163
1324
  ])) ? "#000000" : "#ffffff";
1164
1325
  }
1165
- function at(e, t) {
1166
- let n = t.color ?? "#4f46e5";
1167
- e.style.setProperty("--whoo-widget-color", n), e.style.setProperty("--whoo-widget-text-on-color", it(n));
1168
- let r = t.position === "bottom-left";
1169
- e.style.setProperty("--whoo-widget-inset-left", r ? "20px" : "auto"), e.style.setProperty("--whoo-widget-inset-right", r ? "auto" : "20px");
1326
+ var Q = "#4f46e5", xt = "#ffffff", St = "#f0f0f0", Ct = 4.5;
1327
+ function $([e, t, n]) {
1328
+ return `#${[
1329
+ e,
1330
+ t,
1331
+ n
1332
+ ].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
1333
+ }
1334
+ function wt(e, t = xt) {
1335
+ let n = vt(e), r = vt(t);
1336
+ if (!n || !r) return Q;
1337
+ let i = Z(r), a = (e) => yt(Z(e), i) >= Ct;
1338
+ if (a(n)) return $(n);
1339
+ for (let e = .99; e > 0; e -= .01) {
1340
+ let t = n.map((t) => Math.round(t * e));
1341
+ if (a(t)) return $(t);
1342
+ }
1343
+ return "#000000";
1344
+ }
1345
+ function Tt(e, t, n = Q) {
1346
+ let r = X(t);
1347
+ r ||= (console.warn(`[whoo-aiden-widget] Could not use "${t}" as the theme color; falling back to "${n}".`), X(n));
1348
+ let i = r ? $(r.rgb) : Q;
1349
+ e.style.setProperty("--whoo-widget-color", i), e.style.setProperty("--whoo-widget-text-on-color", bt(i)), e.style.setProperty("--whoo-widget-color-text", wt(i));
1350
+ }
1351
+ function Et(e, { inkColor: t, accentColor: n }) {
1352
+ let r = (e) => {
1353
+ let t = e === null ? null : X(e);
1354
+ return t ? wt($(t.rgb), St) : null;
1355
+ }, i = r(t), a = r(n);
1356
+ i && e.style.setProperty("--whoo-widget-ink", i), a && e.style.setProperty("--whoo-widget-link-color", a);
1357
+ }
1358
+ function Dt(e, t) {
1359
+ Tt(e, t.color ?? Q);
1360
+ let n = t.position === "bottom-left";
1361
+ e.style.setProperty("--whoo-widget-inset-left", n ? "20px" : "auto"), e.style.setProperty("--whoo-widget-inset-right", n ? "auto" : "20px");
1170
1362
  }
1171
1363
  //#endregion
1172
1364
  //#region src/mount.tsx
1173
- function ot(e) {
1365
+ function Ot(e) {
1174
1366
  let t = document.createElement("div");
1175
1367
  t.id = "whoo-aiden-widget-host";
1176
1368
  let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
1177
- r.textContent = tt, n.appendChild(r);
1369
+ r.textContent = gt, n.appendChild(r);
1178
1370
  let i = document.createElement("div");
1179
- n.appendChild(i), at(i, e);
1180
- let a = new et(e);
1181
- return a.subscribe((e) => {
1182
- e.primaryColor && (i.style.setProperty("--whoo-widget-color", e.primaryColor), i.style.setProperty("--whoo-widget-text-on-color", it(e.primaryColor)));
1183
- }), ce(/* @__PURE__ */ q(ze, { controller: a }), i), a.init(), document.body.appendChild(t), { unmount() {
1184
- ce(null, i), t.remove();
1371
+ n.appendChild(i), Dt(i, e);
1372
+ let a = new ht(e), o = null, s = "";
1373
+ return a.subscribe((t) => {
1374
+ t.primaryColor && t.primaryColor !== o && (o = t.primaryColor, Tt(i, t.primaryColor, e.color));
1375
+ let n = `${t.inkColor}|${t.accentColor}`;
1376
+ (t.inkColor || t.accentColor) && n !== s && (s = n, Et(i, {
1377
+ inkColor: t.inkColor,
1378
+ accentColor: t.accentColor
1379
+ }));
1380
+ }), le(/* @__PURE__ */ W(Ze, { controller: a }), i), a.init(), document.body.appendChild(t), { unmount() {
1381
+ le(null, i), t.remove();
1185
1382
  } };
1186
1383
  }
1187
1384
  //#endregion
1188
1385
  //#region src/index.ts
1189
- function st(t) {
1190
- return e(t), ot(t);
1386
+ function kt(t) {
1387
+ return e(t), Ot(t);
1191
1388
  }
1192
1389
  //#endregion
1193
- export { st as init };
1390
+ export { kt as init };