@aiden-voice/widget 0.1.2 → 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, z, le, B = 0, ue = [], V = n, de = V.__b, fe = V.__r, pe = V.diffed, me = V.__c, he = V.unmount, ge = V.__;
257
- function H(e, t) {
258
- V.__h && V.__h(R, e, B || t), B = 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 U(e) {
266
- return B = 1, _e(we, e);
265
+ function B(e) {
266
+ return R = 1, be(De, e);
267
267
  }
268
- function _e(e, t, n) {
269
- var r = H(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 _e(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 W(e, t) {
302
- var n = H(L++, 3);
303
- !V.__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 G(e) {
306
- return B = 5, ve(function() {
305
+ function H(e) {
306
+ return R = 5, xe(function() {
307
307
  return { current: e };
308
308
  }, []);
309
309
  }
310
- function ve(e, t) {
311
- var n = H(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 ye() {
315
- for (var e; e = ue.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(K), t.__h.some(Se), t.__h = [];
318
+ t.__h.some(U), t.__h.some(Te), t.__h = [];
319
319
  } catch (n) {
320
- t.__h = [], V.__e(n, e.__v);
320
+ t.__h = [], z.__e(n, e.__v);
321
321
  }
322
322
  }
323
323
  }
324
- V.__b = function(e) {
325
- R = null, de && de(e);
326
- }, V.__ = function(e, t) {
327
- e && t.__k && t.__k.__m && (e.__m = t.__k.__m), ge && ge(e, t);
328
- }, V.__r = function(e) {
329
- fe && fe(e), L = 0;
330
- var t = (R = e.__c).__H;
331
- t && (z === 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(K), t.__h.some(Se), t.__h = [], L = 0)), z = R;
334
- }, V.diffed = function(e) {
335
- pe && pe(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 && (ue.push(t) !== 1 && le === V.requestAnimationFrame || ((le = V.requestAnimationFrame) || xe)(ye)), 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
- })), z = R = null;
340
- }, V.__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(K), e.__h = e.__h.filter(function(e) {
344
- return !e.__ || Se(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 = [], V.__e(n, e.__v);
349
+ }), t = [], z.__e(n, e.__v);
350
350
  }
351
- }), me && me(e, t);
352
- }, V.unmount = function(e) {
353
- he && he(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
- K(e);
357
+ U(e);
358
358
  } catch (e) {
359
359
  t = e;
360
360
  }
361
- }), n.__H = void 0, t && V.__e(t, n.__v));
361
+ }), n.__H = void 0, t && z.__e(t, n.__v));
362
362
  };
363
- var be = typeof requestAnimationFrame == "function";
364
- function xe(e) {
363
+ var Ce = typeof requestAnimationFrame == "function";
364
+ function we(e) {
365
365
  var t, n = function() {
366
- clearTimeout(r), be && cancelAnimationFrame(t), setTimeout(e);
366
+ clearTimeout(r), Ce && cancelAnimationFrame(t), setTimeout(e);
367
367
  }, r = setTimeout(n, 35);
368
- be && (t = requestAnimationFrame(n));
368
+ Ce && (t = requestAnimationFrame(n));
369
369
  }
370
- function K(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 Se(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,
@@ -413,8 +413,8 @@ function q(e, t, r, i, a, o) {
413
413
  }
414
414
  //#endregion
415
415
  //#region src/components/icons.tsx
416
- function J({ name: e, size: t, children: n }) {
417
- return /* @__PURE__ */ q("svg", {
416
+ function G({ name: e, size: t, children: n }) {
417
+ return /* @__PURE__ */ W("svg", {
418
418
  "data-icon": e,
419
419
  "aria-hidden": "true",
420
420
  focusable: "false",
@@ -429,76 +429,81 @@ function J({ name: e, size: t, children: n }) {
429
429
  children: n
430
430
  });
431
431
  }
432
- function Ee({ size: e = 26 }) {
433
- return /* @__PURE__ */ q(J, {
432
+ function ke({ size: e = 26 }) {
433
+ return /* @__PURE__ */ W(G, {
434
434
  name: "chat",
435
435
  size: e,
436
- children: [/* @__PURE__ */ q("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__ */ q("path", {
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
437
  d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
438
438
  "stroke-width": "2.5"
439
439
  })]
440
440
  });
441
441
  }
442
- function De({ size: e = 26 }) {
443
- return /* @__PURE__ */ q(J, {
442
+ function Ae({ size: e = 26 }) {
443
+ return /* @__PURE__ */ W(G, {
444
444
  name: "chevron-down",
445
445
  size: e,
446
- children: /* @__PURE__ */ q("path", { d: "M6 9l6 6 6-6" })
446
+ children: /* @__PURE__ */ W("path", { d: "M6 9l6 6 6-6" })
447
447
  });
448
448
  }
449
- function Oe({ size: e = 18 }) {
450
- return /* @__PURE__ */ q(J, {
449
+ function je({ size: e = 18 }) {
450
+ return /* @__PURE__ */ W(G, {
451
451
  name: "close",
452
452
  size: e,
453
- children: /* @__PURE__ */ q("path", { d: "M6 6l12 12M18 6L6 18" })
453
+ children: /* @__PURE__ */ W("path", { d: "M6 6l12 12M18 6L6 18" })
454
454
  });
455
455
  }
456
- var ke = "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 Ae({ size: e = 16 }) {
458
- return /* @__PURE__ */ q(J, {
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
459
  name: "thumb-up",
460
460
  size: e,
461
- children: /* @__PURE__ */ q("path", { d: ke })
461
+ children: /* @__PURE__ */ W("path", { d: Me })
462
462
  });
463
463
  }
464
- function je({ size: e = 16 }) {
465
- return /* @__PURE__ */ q(J, {
464
+ function Pe({ size: e = 16 }) {
465
+ return /* @__PURE__ */ W(G, {
466
466
  name: "thumb-down",
467
467
  size: e,
468
- children: /* @__PURE__ */ q("path", {
469
- d: ke,
468
+ children: /* @__PURE__ */ W("path", {
469
+ d: Me,
470
470
  transform: "matrix(1 0 0 -1 0 24)"
471
471
  })
472
472
  });
473
473
  }
474
474
  //#endregion
475
475
  //#region src/components/Launcher.tsx
476
- function Me({ isOpen: e, onClick: t, logoUrl: n, buttonRef: r }) {
477
- 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", {
478
479
  type: "button",
479
480
  class: "whoo-widget-launcher",
480
481
  onClick: t,
481
482
  "aria-label": e ? "Close chat" : "Open chat",
482
483
  ref: r,
483
- children: e ? /* @__PURE__ */ q(De, {}) : n ? /* @__PURE__ */ q("img", {
484
- 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",
485
486
  src: n,
486
- alt: ""
487
- }) : /* @__PURE__ */ q(Ee, {})
487
+ alt: "",
488
+ referrerpolicy: "no-referrer",
489
+ hidden: !s,
490
+ onLoad: () => a("loaded"),
491
+ onError: () => a("failed")
492
+ }) : null]
488
493
  });
489
494
  }
490
495
  //#endregion
491
496
  //#region src/components/Composer.tsx
492
- function Ne({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
493
- return /* @__PURE__ */ q("div", {
497
+ function Ie({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
498
+ return /* @__PURE__ */ W("div", {
494
499
  class: "whoo-widget-composer",
495
500
  children: [
496
- /* @__PURE__ */ q("label", {
501
+ /* @__PURE__ */ W("label", {
497
502
  class: "whoo-widget-sr-only",
498
503
  for: "whoo-widget-composer-input",
499
504
  children: "Message"
500
505
  }),
501
- /* @__PURE__ */ q("input", {
506
+ /* @__PURE__ */ W("input", {
502
507
  id: "whoo-widget-composer-input",
503
508
  class: "whoo-widget-composer-input",
504
509
  value: e,
@@ -510,7 +515,7 @@ function Ne({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
510
515
  e.key === "Enter" && n();
511
516
  }
512
517
  }),
513
- /* @__PURE__ */ q("button", {
518
+ /* @__PURE__ */ W("button", {
514
519
  type: "button",
515
520
  class: "whoo-widget-composer-send",
516
521
  onClick: n,
@@ -522,8 +527,8 @@ function Ne({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
522
527
  }
523
528
  //#endregion
524
529
  //#region src/components/ErrorBanner.tsx
525
- function Pe({ message: e }) {
526
- return /* @__PURE__ */ q("div", {
530
+ function Le({ message: e }) {
531
+ return /* @__PURE__ */ W("div", {
527
532
  class: "whoo-widget-error-banner",
528
533
  role: "alert",
529
534
  children: e
@@ -531,8 +536,8 @@ function Pe({ message: e }) {
531
536
  }
532
537
  //#endregion
533
538
  //#region src/markdown/tokenizer.ts
534
- var Y = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, X = /\*\*([^*]+)\*\*/y, Z = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, Q = /\*([^*]+)\*/y, Fe = /https?:\/\/\S+/y, Ie = /[.,;:!?)\]}>]+$/;
535
- function Le(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) {
536
541
  let t = [], n = 0, r = 0, i = (n) => {
537
542
  n > r && t.push({
538
543
  type: "text",
@@ -552,56 +557,56 @@ function Le(e) {
552
557
  }
553
558
  }
554
559
  if (e[n - 1] !== "!") {
555
- Y.lastIndex = n;
556
- let a = Y.exec(e);
560
+ K.lastIndex = n;
561
+ let a = K.exec(e);
557
562
  if (a) {
558
563
  i(n), t.push({
559
564
  type: "link",
560
565
  text: a[1],
561
566
  url: a[2],
562
567
  start: n,
563
- end: Y.lastIndex
564
- }), n = Y.lastIndex, r = n;
568
+ end: K.lastIndex
569
+ }), n = K.lastIndex, r = n;
565
570
  continue;
566
571
  }
567
572
  }
568
- X.lastIndex = n;
569
- let a = X.exec(e);
573
+ q.lastIndex = n;
574
+ let a = q.exec(e);
570
575
  if (a) {
571
576
  i(n), t.push({
572
577
  type: "bold",
573
578
  value: a[1],
574
579
  start: n,
575
- end: X.lastIndex
576
- }), n = X.lastIndex, r = n;
580
+ end: q.lastIndex
581
+ }), n = q.lastIndex, r = n;
577
582
  continue;
578
583
  }
579
- Z.lastIndex = n;
580
- let o = Z.exec(e);
584
+ J.lastIndex = n;
585
+ let o = J.exec(e);
581
586
  if (o) {
582
587
  i(n), t.push({
583
588
  type: "italic",
584
589
  value: o[1],
585
590
  start: n,
586
- end: Z.lastIndex
587
- }), n = Z.lastIndex, r = n;
591
+ end: J.lastIndex
592
+ }), n = J.lastIndex, r = n;
588
593
  continue;
589
594
  }
590
- Q.lastIndex = n;
591
- let s = Q.exec(e);
595
+ Y.lastIndex = n;
596
+ let s = Y.exec(e);
592
597
  if (s) {
593
598
  i(n), t.push({
594
599
  type: "italic",
595
600
  value: s[1],
596
601
  start: n,
597
- end: Q.lastIndex
598
- }), n = Q.lastIndex, r = n;
602
+ end: Y.lastIndex
603
+ }), n = Y.lastIndex, r = n;
599
604
  continue;
600
605
  }
601
- Fe.lastIndex = n;
602
- let c = Fe.exec(e);
606
+ Re.lastIndex = n;
607
+ let c = Re.exec(e);
603
608
  if (c) {
604
- let e = c[0].match(Ie), 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];
605
610
  if (a.length > 0) {
606
611
  i(n), t.push({
607
612
  type: "link",
@@ -619,16 +624,16 @@ function Le(e) {
619
624
  }
620
625
  //#endregion
621
626
  //#region src/markdown/render.tsx
622
- function Re(e) {
623
- return Le(e).map((e, t) => {
627
+ function Ve(e) {
628
+ return Be(e).map((e, t) => {
624
629
  switch (e.type) {
625
- case "bold": return /* @__PURE__ */ q("strong", { children: e.value }, t);
626
- case "italic": return /* @__PURE__ */ q("em", { children: e.value }, t);
627
- 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", {
628
633
  href: e.url,
629
634
  target: "_blank",
630
635
  rel: "noopener noreferrer",
631
- children: [e.text, /* @__PURE__ */ q("span", {
636
+ children: [e.text, /* @__PURE__ */ W("span", {
632
637
  class: "whoo-widget-sr-only",
633
638
  children: " (opens in new tab)"
634
639
  })]
@@ -639,7 +644,7 @@ function Re(e) {
639
644
  }
640
645
  //#endregion
641
646
  //#region src/components/MessageFeedback.tsx
642
- var ze = [
647
+ var He = [
643
648
  {
644
649
  value: "",
645
650
  label: "Select a reason (optional)"
@@ -661,50 +666,50 @@ var ze = [
661
666
  label: "Other"
662
667
  }
663
668
  ];
664
- function Be({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancel: a }) {
665
- let [o, s] = U(""), [c, l] = U(""), u = G(e.status);
666
- if (W(() => {
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(() => {
667
672
  let n = u.current;
668
673
  if (u.current = e.status, n === e.status) return;
669
674
  let r = t?.current;
670
675
  if (!r) return;
671
676
  let i = r.getRootNode();
672
677
  r.contains(i.activeElement) || r.focus();
673
- }, [e.status, t]), e.status === "submitted") return /* @__PURE__ */ q("div", {
678
+ }, [e.status, t]), e.status === "submitted") return /* @__PURE__ */ W("div", {
674
679
  class: "whoo-widget-feedback-submitted",
675
680
  role: "status",
676
681
  children: "Thanks for the feedback"
677
682
  });
678
- if (e.status === "expanded") return /* @__PURE__ */ q("div", {
683
+ if (e.status === "expanded") return /* @__PURE__ */ W("div", {
679
684
  class: "whoo-widget-feedback-form",
680
685
  children: [
681
- /* @__PURE__ */ q("label", { children: [/* @__PURE__ */ q("span", {
686
+ /* @__PURE__ */ W("label", { children: [/* @__PURE__ */ W("span", {
682
687
  class: "whoo-widget-sr-only",
683
688
  children: "Additional feedback"
684
- }), /* @__PURE__ */ q("textarea", {
689
+ }), /* @__PURE__ */ W("textarea", {
685
690
  class: "whoo-widget-feedback-textarea",
686
691
  value: o,
687
692
  onInput: (e) => s(e.target.value),
688
693
  placeholder: "What was wrong? (optional)"
689
694
  })] }),
690
- /* @__PURE__ */ q("select", {
695
+ /* @__PURE__ */ W("select", {
691
696
  class: "whoo-widget-feedback-select",
692
697
  "aria-label": "Feedback category",
693
698
  value: c,
694
699
  onChange: (e) => l(e.target.value),
695
- children: ze.map((e) => /* @__PURE__ */ q("option", {
700
+ children: He.map((e) => /* @__PURE__ */ W("option", {
696
701
  value: e.value,
697
702
  children: e.label
698
703
  }, e.value))
699
704
  }),
700
- /* @__PURE__ */ q("div", {
705
+ /* @__PURE__ */ W("div", {
701
706
  class: "whoo-widget-feedback-form-buttons",
702
- children: [/* @__PURE__ */ q("button", {
707
+ children: [/* @__PURE__ */ W("button", {
703
708
  type: "button",
704
709
  class: "whoo-widget-feedback-submit",
705
710
  onClick: () => i(o, c),
706
711
  children: "Submit"
707
- }), /* @__PURE__ */ q("button", {
712
+ }), /* @__PURE__ */ W("button", {
708
713
  type: "button",
709
714
  class: "whoo-widget-feedback-cancel",
710
715
  onClick: a,
@@ -714,24 +719,24 @@ function Be({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
714
719
  ]
715
720
  });
716
721
  let d = e.status === "submitting";
717
- return /* @__PURE__ */ q("div", {
722
+ return /* @__PURE__ */ W("div", {
718
723
  class: "whoo-widget-feedback",
719
- children: [/* @__PURE__ */ q("div", {
724
+ children: [/* @__PURE__ */ W("div", {
720
725
  class: "whoo-widget-feedback-buttons",
721
- children: [/* @__PURE__ */ q("button", {
726
+ children: [/* @__PURE__ */ W("button", {
722
727
  type: "button",
723
728
  "aria-label": "Good response",
724
729
  disabled: d,
725
730
  onClick: n,
726
- children: /* @__PURE__ */ q(Ae, {})
727
- }), /* @__PURE__ */ q("button", {
731
+ children: /* @__PURE__ */ W(Ne, {})
732
+ }), /* @__PURE__ */ W("button", {
728
733
  type: "button",
729
734
  "aria-label": "Bad response",
730
735
  disabled: d,
731
736
  onClick: r,
732
- children: /* @__PURE__ */ q(je, {})
737
+ children: /* @__PURE__ */ W(Pe, {})
733
738
  })]
734
- }), e.status === "error" ? /* @__PURE__ */ q("div", {
739
+ }), e.status === "error" ? /* @__PURE__ */ W("div", {
735
740
  class: "whoo-widget-feedback-error",
736
741
  role: "status",
737
742
  children: "Couldn't send feedback"
@@ -740,39 +745,69 @@ function Be({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
740
745
  }
741
746
  //#endregion
742
747
  //#region src/components/MessageList.tsx
743
- function Ve({ message: e, feedbackState: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancelFeedback: a }) {
744
- let o = G(null), s = e.id;
745
- return /* @__PURE__ */ q("div", {
746
- 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,
747
780
  tabIndex: -1,
748
781
  class: `whoo-widget-message whoo-widget-message--${e.role}`,
749
- children: [Re(e.content), e.role === "assistant" && s ? /* @__PURE__ */ q(Be, {
782
+ children: [n ? /* @__PURE__ */ W(We, { isSlowResponse: r }) : Ve(e.content), e.role === "assistant" && l ? /* @__PURE__ */ W(Ue, {
750
783
  state: t,
751
- containerRef: o,
752
- onThumbsUp: () => n(s),
753
- onThumbsDown: () => r(s),
754
- onSubmitDetailed: (e, t) => i(s, e, t),
755
- 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)
756
789
  }) : null]
757
790
  });
758
791
  }
759
- function He({ messages: e, messageFeedback: t, lastCompletedMessageText: n, onThumbsUp: r, onThumbsDown: i, onSubmitDetailed: a, onCancelFeedback: o }) {
760
- let s = G(null);
761
- return W(() => {
762
- 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;
763
796
  e && (e.scrollTop = e.scrollHeight);
764
- }, [e]), /* @__PURE__ */ q(C, { children: [/* @__PURE__ */ q("div", {
797
+ }, [e, a]), /* @__PURE__ */ W(C, { children: [/* @__PURE__ */ W("div", {
765
798
  class: "whoo-widget-message-list",
766
- ref: s,
767
- children: e.map((e, n) => /* @__PURE__ */ q(Ve, {
768
- message: e,
769
- feedbackState: e.id ? t[e.id] ?? { status: "idle" } : { status: "idle" },
770
- onThumbsUp: r,
771
- onThumbsDown: i,
772
- onSubmitDetailed: a,
773
- onCancelFeedback: o
774
- }, e.id ?? n))
775
- }), /* @__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", {
776
811
  class: "whoo-widget-sr-only",
777
812
  "aria-live": "polite",
778
813
  "aria-atomic": "true",
@@ -781,16 +816,16 @@ function He({ messages: e, messageFeedback: t, lastCompletedMessageText: n, onTh
781
816
  }
782
817
  //#endregion
783
818
  //#region src/components/Panel.tsx
784
- var Ue = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
785
- function We(e) {
786
- return Array.from(e.querySelectorAll(Ue)).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) => {
787
822
  let t = getComputedStyle(e);
788
823
  return t.display !== "none" && t.visibility !== "hidden";
789
824
  });
790
825
  }
791
- function Ge({ state: e, controller: t, greeting: n }) {
792
- let r = G(null), i = G(null);
793
- W(() => {
826
+ function Xe({ state: e, controller: t, greeting: n }) {
827
+ let r = H(null), i = H(null);
828
+ V(() => {
794
829
  i.current?.focus();
795
830
  }, []);
796
831
  let a = (e) => {
@@ -801,7 +836,7 @@ function Ge({ state: e, controller: t, greeting: n }) {
801
836
  if (e.key !== "Tab") return;
802
837
  let n = r.current;
803
838
  if (!n) return;
804
- let i = We(n);
839
+ let i = Ye(n);
805
840
  if (i.length === 0) return;
806
841
  let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
807
842
  if (!n.contains(s)) {
@@ -811,52 +846,58 @@ function Ge({ state: e, controller: t, greeting: n }) {
811
846
  e.shiftKey && s === a ? (e.preventDefault(), o.focus()) : !e.shiftKey && s === o && (e.preventDefault(), a.focus());
812
847
  }, o = () => {
813
848
  let n = e.draft.trim();
814
- !n || e.isStreaming || (t.setDraft(""), t.sendMessage(n));
815
- }, s = e.messages.length === 0 && n ? [{
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 ? [{
816
851
  role: "assistant",
817
852
  content: n,
818
853
  id: null
819
- }] : e.messages;
820
- 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", {
821
859
  class: "whoo-widget-panel",
822
860
  role: "dialog",
823
861
  "aria-modal": "true",
824
- "aria-label": "Chat with Aiden",
862
+ "aria-label": s,
825
863
  ref: r,
826
864
  onKeyDown: a,
827
865
  children: [
828
- /* @__PURE__ */ q("div", {
866
+ /* @__PURE__ */ W("div", {
829
867
  class: "whoo-widget-header",
830
- children: [/* @__PURE__ */ q("h2", {
868
+ children: [/* @__PURE__ */ W("h2", {
831
869
  class: "whoo-widget-header-title",
832
- children: "Chat with Aiden"
833
- }), /* @__PURE__ */ q("div", {
870
+ children: s
871
+ }), /* @__PURE__ */ W("div", {
834
872
  class: "whoo-widget-header-actions",
835
- children: [e.messages.length > 0 && /* @__PURE__ */ q("button", {
873
+ children: [e.messages.length > 0 && /* @__PURE__ */ W("button", {
836
874
  type: "button",
837
875
  class: "whoo-widget-header-reset",
838
876
  onClick: () => t.resetConversation(),
839
877
  children: "New conversation"
840
- }), /* @__PURE__ */ q("button", {
878
+ }), /* @__PURE__ */ W("button", {
841
879
  type: "button",
842
880
  class: "whoo-widget-header-close",
843
881
  "aria-label": "Close chat",
844
882
  onClick: () => t.close(),
845
- children: /* @__PURE__ */ q(Oe, {})
883
+ children: /* @__PURE__ */ W(je, {})
846
884
  })]
847
885
  })]
848
886
  }),
849
- /* @__PURE__ */ q(He, {
850
- messages: s,
887
+ /* @__PURE__ */ W(qe, {
888
+ messages: c,
851
889
  messageFeedback: e.messageFeedback,
852
890
  lastCompletedMessageText: e.lastCompletedMessageText,
891
+ emptyStateImage: u,
892
+ isStreaming: e.isStreaming,
893
+ isSlowResponse: e.isSlowResponse,
853
894
  onThumbsUp: (e) => t.submitFeedback(e, "up"),
854
895
  onThumbsDown: (e) => t.expandFeedback(e),
855
896
  onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
856
897
  onCancelFeedback: (e) => t.cancelFeedback(e)
857
898
  }),
858
- e.runtimeError && /* @__PURE__ */ q(Pe, { message: e.runtimeError }),
859
- /* @__PURE__ */ q(Ne, {
899
+ e.runtimeError && /* @__PURE__ */ W(Le, { message: e.runtimeError }),
900
+ /* @__PURE__ */ W(Ie, {
860
901
  value: e.draft,
861
902
  onChange: (e) => t.setDraft(e),
862
903
  onSend: o,
@@ -868,16 +909,16 @@ function Ge({ state: e, controller: t, greeting: n }) {
868
909
  }
869
910
  //#endregion
870
911
  //#region src/components/App.tsx
871
- function Ke({ controller: e }) {
872
- let [t, n] = U(e.getState()), r = G(null), i = G(t.isOpen);
873
- return W(() => (n(e.getState()), e.subscribe(n)), [e]), W(() => {
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(() => {
874
915
  i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
875
- }, [t.isOpen]), t.initError ? null : /* @__PURE__ */ q(C, { children: [/* @__PURE__ */ q(Me, {
916
+ }, [t.isOpen]), t.initError ? null : /* @__PURE__ */ W(C, { children: [/* @__PURE__ */ W(Fe, {
876
917
  isOpen: t.isOpen,
877
918
  onClick: () => t.isOpen ? e.close() : e.open(),
878
- logoUrl: e.config.logoUrl,
919
+ iconUrl: e.launcherIconUrl,
879
920
  buttonRef: r
880
- }), t.isOpen && /* @__PURE__ */ q(Ge, {
921
+ }), t.isOpen && /* @__PURE__ */ W(Xe, {
881
922
  state: t,
882
923
  controller: e,
883
924
  greeting: e.config.greeting
@@ -885,26 +926,34 @@ function Ke({ controller: e }) {
885
926
  }
886
927
  //#endregion
887
928
  //#region src/api/client.ts
888
- var qe = class extends Error {
929
+ var Qe = class extends Error {
889
930
  status;
890
931
  constructor(e, t) {
891
932
  super(e), this.name = "WidgetApiError", this.status = t;
892
933
  }
893
934
  };
894
- async function Je(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) {
895
941
  let n = await fetch(`${e}/api/v1/widget/session`, {
896
942
  method: "POST",
897
943
  headers: { "Content-Type": "application/json" },
898
944
  body: JSON.stringify({ publishable_key: t })
899
945
  });
900
- if (!n.ok) throw new qe(`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);
901
947
  let r = await n.json();
902
948
  return {
903
949
  token: r.token,
904
- 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)
905
954
  };
906
955
  }
907
- async function Ye(e, t, n) {
956
+ async function tt(e, t, n) {
908
957
  let r = await fetch(`${e}/api/v1/widget/feedback`, {
909
958
  method: "POST",
910
959
  headers: {
@@ -918,11 +967,11 @@ async function Ye(e, t, n) {
918
967
  category: n.category ?? null
919
968
  })
920
969
  });
921
- if (!r.ok) throw new qe(`Feedback submission failed (${r.status})`, r.status);
970
+ if (!r.ok) throw new Qe(`Feedback submission failed (${r.status})`, r.status);
922
971
  }
923
972
  //#endregion
924
973
  //#region src/api/sse.ts
925
- async function* Xe(e, t, n, r, i) {
974
+ async function* nt(e, t, n, r, i) {
926
975
  let a = await fetch(`${e}/api/v1/widget/chat`, {
927
976
  method: "POST",
928
977
  headers: {
@@ -935,7 +984,7 @@ async function* Xe(e, t, n, r, i) {
935
984
  }),
936
985
  signal: i
937
986
  });
938
- if (!a.ok || !a.body) throw new qe(`Chat request failed (${a.status})`, a.status);
987
+ if (!a.ok || !a.body) throw new Qe(`Chat request failed (${a.status})`, a.status);
939
988
  let o = a.body.getReader(), s = new TextDecoder(), c = "";
940
989
  for (;;) {
941
990
  let { done: e, value: t } = await o.read();
@@ -946,11 +995,11 @@ async function* Xe(e, t, n, r, i) {
946
995
  let e = c.slice(0, n);
947
996
  c = c.slice(n + 2);
948
997
  let t = e.split("\n").find((e) => e.startsWith("data: "));
949
- t && (yield Ze(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
998
+ t && (yield rt(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
950
999
  }
951
1000
  }
952
1001
  }
953
- function Ze(e) {
1002
+ function rt(e) {
954
1003
  return typeof e.error == "string" ? {
955
1004
  type: "error",
956
1005
  error: e.error,
@@ -972,17 +1021,28 @@ function Ze(e) {
972
1021
  };
973
1022
  }
974
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
975
1035
  //#region src/markdown/reveal.ts
976
- var Qe = 40, $e = 120;
977
- function et(e) {
1036
+ var at = 40, ot = 120;
1037
+ function st(e) {
978
1038
  let t = [];
979
- for (let n of Le(e)) if (n.type === "text") {
1039
+ for (let n of Be(e)) if (n.type === "text") {
980
1040
  let e = n.value.split(/(\s+)/), r = n.start;
981
1041
  for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
982
1042
  } else t.push(n.end);
983
1043
  return t;
984
1044
  }
985
- function tt(e) {
1045
+ function ct(e) {
986
1046
  let t = null;
987
1047
  return e?.addEventListener("abort", () => {
988
1048
  t?.();
@@ -997,36 +1057,36 @@ function tt(e) {
997
1057
  });
998
1058
  };
999
1059
  }
1000
- async function nt(e, t, n) {
1001
- let r = n?.wordIntervalMs ?? Qe, i = n?.tokenIntervalMs ?? $e, a = n?.signal, o = Le(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = tt(a), l = "";
1002
- for (let n of et(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;
1003
1063
  l !== e && t(e);
1004
1064
  }
1005
1065
  //#endregion
1006
1066
  //#region src/storage.ts
1007
- function rt(e) {
1067
+ function ut(e) {
1008
1068
  return `whoo-aiden-widget:conversation:${e}`;
1009
1069
  }
1010
- function it(e) {
1070
+ function dt(e) {
1011
1071
  try {
1012
- return window.sessionStorage.getItem(rt(e));
1072
+ return window.sessionStorage.getItem(ut(e));
1013
1073
  } catch {
1014
1074
  return null;
1015
1075
  }
1016
1076
  }
1017
- function at(e, t) {
1077
+ function ft(e, t) {
1018
1078
  try {
1019
- window.sessionStorage.setItem(rt(e), t);
1079
+ window.sessionStorage.setItem(ut(e), t);
1020
1080
  } catch {}
1021
1081
  }
1022
- function ot(e) {
1082
+ function pt(e) {
1023
1083
  try {
1024
- window.sessionStorage.removeItem(rt(e));
1084
+ window.sessionStorage.removeItem(ut(e));
1025
1085
  } catch {}
1026
1086
  }
1027
1087
  //#endregion
1028
1088
  //#region src/controller.ts
1029
- var st = class {
1089
+ var mt = 8e3, ht = class {
1030
1090
  config;
1031
1091
  state;
1032
1092
  listeners = /* @__PURE__ */ new Set();
@@ -1034,9 +1094,13 @@ var st = class {
1034
1094
  conversationId = null;
1035
1095
  storageIdentifier;
1036
1096
  activeRequestController = null;
1097
+ slowResponseTimer = null;
1037
1098
  prefersReducedMotion;
1099
+ launcherIconUrl;
1100
+ emptyStateImageUrl;
1101
+ emptyStateImageAlt;
1038
1102
  constructor(e) {
1039
- 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 = {
1040
1104
  isOpen: !1,
1041
1105
  messages: [],
1042
1106
  isStreaming: !1,
@@ -1044,7 +1108,11 @@ var st = class {
1044
1108
  runtimeError: null,
1045
1109
  messageFeedback: {},
1046
1110
  primaryColor: null,
1111
+ agentName: null,
1112
+ accentColor: null,
1113
+ inkColor: null,
1047
1114
  lastCompletedMessageText: null,
1115
+ isSlowResponse: !1,
1048
1116
  draft: ""
1049
1117
  };
1050
1118
  }
@@ -1054,6 +1122,9 @@ var st = class {
1054
1122
  subscribe(e) {
1055
1123
  return this.listeners.add(e), () => this.listeners.delete(e);
1056
1124
  }
1125
+ clearSlowResponse() {
1126
+ this.slowResponseTimer !== null && (clearTimeout(this.slowResponseTimer), this.slowResponseTimer = null), this.state.isSlowResponse && this.setState({ isSlowResponse: !1 });
1127
+ }
1057
1128
  setState(e) {
1058
1129
  this.state = {
1059
1130
  ...this.state,
@@ -1066,20 +1137,25 @@ var st = class {
1066
1137
  try {
1067
1138
  if (this.config.sessionToken) this.sessionToken = this.config.sessionToken;
1068
1139
  else if (this.config.publishableKey) {
1069
- let { token: t, primaryColor: n } = await Je(e, this.config.publishableKey);
1070
- 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
+ });
1071
1147
  } else throw Error("WidgetConfig must include exactly one of publishableKey or sessionToken");
1072
1148
  } catch (e) {
1073
1149
  console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
1074
1150
  return;
1075
1151
  }
1076
- this.conversationId = it(this.storageIdentifier);
1152
+ this.conversationId = dt(this.storageIdentifier);
1077
1153
  }
1078
1154
  open() {
1079
1155
  this.setState({ isOpen: !0 });
1080
1156
  }
1081
1157
  resetConversation() {
1082
- this.activeRequestController?.abort(), this.activeRequestController = null, this.conversationId = null, ot(this.storageIdentifier), this.setState({
1158
+ this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, pt(this.storageIdentifier), this.setState({
1083
1159
  messages: [],
1084
1160
  messageFeedback: {},
1085
1161
  runtimeError: null,
@@ -1091,7 +1167,7 @@ var st = class {
1091
1167
  this.setState({ draft: e });
1092
1168
  }
1093
1169
  close() {
1094
- this.activeRequestController?.abort(), this.activeRequestController = null, this.setState({ isOpen: !1 });
1170
+ this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isOpen: !1 });
1095
1171
  }
1096
1172
  async sendMessage(e) {
1097
1173
  if (!this.sessionToken) return;
@@ -1121,17 +1197,21 @@ var st = class {
1121
1197
  }, this.setState({ messages: t });
1122
1198
  };
1123
1199
  this.activeRequestController = new AbortController();
1124
- 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 = () => {
1125
1205
  this.setState({
1126
1206
  runtimeError: "Something went wrong, please try again.",
1127
1207
  ...this.state.draft === "" ? { draft: e } : {}
1128
1208
  });
1129
1209
  }, s = "";
1130
1210
  try {
1131
- for await (let n of Xe(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, at(this.storageIdentifier, n.conversationId);
1132
- else if (n.type === "delta") n.verbatim && !this.prefersReducedMotion ? (await nt(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
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));
1133
1213
  else if (n.type === "done") {
1134
- if (n.conversationId && (this.conversationId = n.conversationId, at(this.storageIdentifier, n.conversationId)), n.messageId) {
1214
+ if (n.conversationId && (this.conversationId = n.conversationId, ft(this.storageIdentifier, n.conversationId)), n.messageId) {
1135
1215
  let e = [...this.state.messages];
1136
1216
  e[e.length - 1] = {
1137
1217
  ...e[e.length - 1],
@@ -1139,11 +1219,14 @@ var st = class {
1139
1219
  }, this.setState({ messages: e });
1140
1220
  }
1141
1221
  this.setState({ lastCompletedMessageText: s });
1142
- } else n.type === "error" && (console.error("[whoo-aiden-widget] chat error:", n.error), o());
1222
+ } else if (n.type === "error") {
1223
+ console.error("[whoo-aiden-widget] chat error:", n.error), o(), this.activeRequestController?.abort();
1224
+ break;
1225
+ }
1143
1226
  } catch (e) {
1144
1227
  e?.name === "AbortError" || (console.error("[whoo-aiden-widget] chat request failed:", e), o());
1145
1228
  } finally {
1146
- this.activeRequestController = null, this.setState({ isStreaming: !1 });
1229
+ this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isStreaming: !1 });
1147
1230
  }
1148
1231
  }
1149
1232
  expandFeedback(e) {
@@ -1169,7 +1252,7 @@ var st = class {
1169
1252
  }
1170
1253
  } });
1171
1254
  try {
1172
- await Ye(i, this.sessionToken, {
1255
+ await tt(i, this.sessionToken, {
1173
1256
  messageId: e,
1174
1257
  rating: t,
1175
1258
  correction: n,
@@ -1191,107 +1274,117 @@ var st = class {
1191
1274
  } });
1192
1275
  }
1193
1276
  }
1194
- }, ct = ":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-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;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:#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-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;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}";
1195
- //#endregion
1196
- //#region src/theme.ts
1197
- function lt(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;
1198
1280
  let t = document.createElement("div");
1199
1281
  if (t.style.color = e, t.style.color === "") return null;
1200
- document.body.appendChild(t);
1201
- let n = getComputedStyle(t).color;
1202
- document.body.removeChild(t);
1203
- let r = n.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);
1204
- if (!r) return null;
1205
- let i = r[4] === void 0 ? 1 : Number(r[4]);
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]);
1206
1289
  return {
1207
1290
  rgb: [
1208
- Number(r[1]),
1209
- Number(r[2]),
1210
- Number(r[3])
1211
- ].map((e) => Math.round(e * i + 255 * (1 - i))),
1212
- translucent: i < 1
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
1213
1296
  };
1214
1297
  }
1215
- function ut(e) {
1216
- return lt(e)?.rgb ?? null;
1298
+ function vt(e) {
1299
+ return X(e)?.rgb ?? null;
1217
1300
  }
1218
- function $([e, t, n]) {
1301
+ function Z([e, t, n]) {
1219
1302
  let r = (e) => {
1220
1303
  let t = e / 255;
1221
1304
  return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
1222
1305
  };
1223
1306
  return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
1224
1307
  }
1225
- function dt(e, t) {
1308
+ function yt(e, t) {
1226
1309
  let n = Math.max(e, t), r = Math.min(e, t);
1227
1310
  return (n + .05) / (r + .05);
1228
1311
  }
1229
- function ft(e) {
1230
- let t = ut(e);
1312
+ function bt(e) {
1313
+ let t = vt(e);
1231
1314
  if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
1232
- let n = $(t);
1233
- return dt(n, $([
1315
+ let n = Z(t);
1316
+ return yt(n, Z([
1234
1317
  0,
1235
1318
  0,
1236
1319
  0
1237
- ])) >= dt(n, $([
1320
+ ])) >= yt(n, Z([
1238
1321
  255,
1239
1322
  255,
1240
1323
  255
1241
1324
  ])) ? "#000000" : "#ffffff";
1242
1325
  }
1243
- var pt = "#4f46e5", mt = [
1244
- 255,
1245
- 255,
1246
- 255
1247
- ], ht = 4.5;
1248
- function gt([e, t, n]) {
1326
+ var Q = "#4f46e5", xt = "#ffffff", St = "#f0f0f0", Ct = 4.5;
1327
+ function $([e, t, n]) {
1249
1328
  return `#${[
1250
1329
  e,
1251
1330
  t,
1252
1331
  n
1253
1332
  ].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
1254
1333
  }
1255
- function _t(e) {
1256
- let t = ut(e);
1257
- if (!t) return pt;
1258
- let n = $(mt), r = (e) => dt($(e), n) >= ht;
1259
- if (r(t)) return e;
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);
1260
1339
  for (let e = .99; e > 0; e -= .01) {
1261
- let n = t.map((t) => Math.round(t * e));
1262
- if (r(n)) return gt(n);
1340
+ let t = n.map((t) => Math.round(t * e));
1341
+ if (a(t)) return $(t);
1263
1342
  }
1264
1343
  return "#000000";
1265
1344
  }
1266
- function vt(e, t) {
1267
- let n = lt(t), r = n?.translucent ? gt(n.rgb) : t;
1268
- e.style.setProperty("--whoo-widget-color", r), e.style.setProperty("--whoo-widget-text-on-color", ft(r)), e.style.setProperty("--whoo-widget-color-text", _t(r));
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));
1269
1350
  }
1270
- function yt(e, t) {
1271
- vt(e, t.color ?? pt);
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);
1272
1360
  let n = t.position === "bottom-left";
1273
1361
  e.style.setProperty("--whoo-widget-inset-left", n ? "20px" : "auto"), e.style.setProperty("--whoo-widget-inset-right", n ? "auto" : "20px");
1274
1362
  }
1275
1363
  //#endregion
1276
1364
  //#region src/mount.tsx
1277
- function bt(e) {
1365
+ function Ot(e) {
1278
1366
  let t = document.createElement("div");
1279
1367
  t.id = "whoo-aiden-widget-host";
1280
1368
  let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
1281
- r.textContent = ct, n.appendChild(r);
1369
+ r.textContent = gt, n.appendChild(r);
1282
1370
  let i = document.createElement("div");
1283
- n.appendChild(i), yt(i, e);
1284
- let a = new st(e);
1285
- return a.subscribe((e) => {
1286
- e.primaryColor && vt(i, e.primaryColor);
1287
- }), ce(/* @__PURE__ */ q(Ke, { controller: a }), i), a.init(), document.body.appendChild(t), { unmount() {
1288
- 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();
1289
1382
  } };
1290
1383
  }
1291
1384
  //#endregion
1292
1385
  //#region src/index.ts
1293
- function xt(t) {
1294
- return e(t), bt(t);
1386
+ function kt(t) {
1387
+ return e(t), Ot(t);
1295
1388
  }
1296
1389
  //#endregion
1297
- export { xt as init };
1390
+ export { kt as init };