@aiden-voice/widget 0.2.0 → 0.3.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
@@ -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 = 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);
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 && se(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)), se(s, s));
78
+ if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = T(s)), ce(s, s));
79
79
  return r;
80
80
  }
81
81
  function j(e, t, n) {
@@ -136,7 +136,7 @@ function ne(e, t, r, i, a, o, s, c, l, u) {
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 = 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);
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 = le), 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) {
@@ -169,7 +169,7 @@ function re(e) {
169
169
  e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(re));
170
170
  }
171
171
  function ie(e, t, r) {
172
- for (var i = 0; i < r.length; i++) F(r[i], r[++i], r[++i]);
172
+ for (var i = 0; i < r.length; i++) se(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) {
@@ -206,7 +206,7 @@ function oe(e, r, i, a, o, s, c, l, u) {
206
206
  }
207
207
  return e;
208
208
  }
209
- function F(e, t, r) {
209
+ function se(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 F(e, t, r) {
216
216
  n.__e(e, r);
217
217
  }
218
218
  }
219
- function se(e, t, r) {
219
+ function ce(e, t, r) {
220
220
  var i, a;
221
- if (n.unmount && n.unmount(e), (i = e.ref) && (i.current && i.current != e.__e || F(i, null, t)), (i = e.__c) != null) {
221
+ if (n.unmount && n.unmount(e), (i = e.ref) && (i.current && i.current != e.__e || se(i, null, t)), (i = e.__c) != null) {
222
222
  if (i.componentWillUnmount) try {
223
223
  i.componentWillUnmount();
224
224
  } catch (e) {
@@ -226,13 +226,13 @@ function se(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] && se(i[a], t, r || typeof e.type != "function");
229
+ if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && ce(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 ce(e, t, n) {
232
+ function le(e, t, n) {
233
233
  return this.constructor(e, n);
234
234
  }
235
- function le(e, r, i) {
235
+ function ue(e, r, i) {
236
236
  var a, o, s, c;
237
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
  }
@@ -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 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 = {
256
+ var F, I, de, fe, L = 0, pe = [], R = n, me = R.__b, he = R.__r, ge = R.diffed, _e = R.__c, ve = R.unmount, ye = R.__;
257
+ function be(e, t) {
258
+ R.__h && R.__h(I, e, L || t), L = 0;
259
+ var n = I.__H || (I.__H = {
260
260
  __: [],
261
261
  __h: []
262
262
  });
263
263
  return e >= n.__.length && n.__.push({}), n.__[e];
264
264
  }
265
- function B(e) {
266
- return R = 1, be(De, e);
265
+ function z(e) {
266
+ return L = 1, xe(Oe, e);
267
267
  }
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) {
268
+ function xe(e, t, n) {
269
+ var r = be(F++, 2);
270
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Oe(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 = L, !L.__f)) {
273
+ }], r.__c = I, !I.__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 be(e, t, n) {
286
286
  }
287
287
  return !i || o;
288
288
  };
289
- L.__f = !0;
290
- var a = L.shouldComponentUpdate, o = L.componentWillUpdate;
291
- L.componentWillUpdate = function(e, t, n) {
289
+ I.__f = !0;
290
+ var a = I.shouldComponentUpdate, o = I.componentWillUpdate;
291
+ I.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
- }, L.shouldComponentUpdate = i;
297
+ }, I.shouldComponentUpdate = i;
298
298
  }
299
299
  return r.__N || r.__;
300
300
  }
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));
301
+ function B(e, t) {
302
+ var n = be(F++, 3);
303
+ !R.__s && De(n.__H, t) && (n.__ = e, n.u = t, I.__H.__h.push(n));
304
304
  }
305
- function H(e) {
306
- return R = 5, xe(function() {
305
+ function V(e) {
306
+ return L = 5, Se(function() {
307
307
  return { current: e };
308
308
  }, []);
309
309
  }
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.__;
310
+ function Se(e, t) {
311
+ var n = be(F++, 7);
312
+ return De(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
313
313
  }
314
- function Se() {
315
- for (var e; e = fe.shift();) {
314
+ function Ce() {
315
+ for (var e; e = pe.shift();) {
316
316
  var t = e.__H;
317
317
  if (e.__P && t) try {
318
- t.__h.some(U), t.__h.some(Te), t.__h = [];
318
+ t.__h.some(H), t.__h.some(Ee), t.__h = [];
319
319
  } catch (n) {
320
- t.__h = [], z.__e(n, e.__v);
320
+ t.__h = [], R.__e(n, e.__v);
321
321
  }
322
322
  }
323
323
  }
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) {
324
+ R.__b = function(e) {
325
+ I = null, me && me(e);
326
+ }, R.__ = function(e, t) {
327
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), ye && ye(e, t);
328
+ }, R.__r = function(e) {
329
+ he && he(e), F = 0;
330
+ var t = (I = e.__c).__H;
331
+ t && (de === I ? (t.__h = [], I.__h = [], t.__.some(function(e) {
332
332
  e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
333
- })) : (t.__h.some(U), t.__h.some(Te), t.__h = [], I = 0)), ue = L;
334
- }, z.diffed = function(e) {
335
- he && he(e);
333
+ })) : (t.__h.some(H), t.__h.some(Ee), t.__h = [], F = 0)), de = I;
334
+ }, R.diffed = function(e) {
335
+ ge && ge(e);
336
336
  var t = e.__c;
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) {
337
+ t && t.__H && (t.__H.__h.length && (pe.push(t) !== 1 && fe === R.requestAnimationFrame || ((fe = R.requestAnimationFrame) || Te)(Ce)), t.__H.__.some(function(e) {
338
338
  e.u &&= (e.__H = e.u, void 0);
339
- })), ue = L = null;
340
- }, z.__c = function(e, t) {
339
+ })), de = I = null;
340
+ }, R.__c = function(e, t) {
341
341
  t.some(function(e) {
342
342
  try {
343
- e.__h.some(U), e.__h = e.__h.filter(function(e) {
344
- return !e.__ || Te(e);
343
+ e.__h.some(H), e.__h = e.__h.filter(function(e) {
344
+ return !e.__ || Ee(e);
345
345
  });
346
346
  } catch (n) {
347
347
  t.some(function(e) {
348
348
  e.__h &&= [];
349
- }), t = [], z.__e(n, e.__v);
349
+ }), t = [], R.__e(n, e.__v);
350
350
  }
351
- }), ge && ge(e, t);
352
- }, z.unmount = function(e) {
353
- _e && _e(e);
351
+ }), _e && _e(e, t);
352
+ }, R.unmount = function(e) {
353
+ ve && ve(e);
354
354
  var t, n = e.__c;
355
355
  n && n.__H && (n.__H.__.some(function(e) {
356
356
  try {
357
- U(e);
357
+ H(e);
358
358
  } catch (e) {
359
359
  t = e;
360
360
  }
361
- }), n.__H = void 0, t && z.__e(t, n.__v));
361
+ }), n.__H = void 0, t && R.__e(t, n.__v));
362
362
  };
363
- var Ce = typeof requestAnimationFrame == "function";
364
- function we(e) {
363
+ var we = typeof requestAnimationFrame == "function";
364
+ function Te(e) {
365
365
  var t, n = function() {
366
- clearTimeout(r), Ce && cancelAnimationFrame(t), setTimeout(e);
366
+ clearTimeout(r), we && cancelAnimationFrame(t), setTimeout(e);
367
367
  }, r = setTimeout(n, 35);
368
- Ce && (t = requestAnimationFrame(n));
368
+ we && (t = requestAnimationFrame(n));
369
369
  }
370
- function U(e) {
371
- var t = L, n = e.__c;
372
- typeof n == "function" && (e.__c = void 0, n()), L = t;
370
+ function H(e) {
371
+ var t = I, n = e.__c;
372
+ typeof n == "function" && (e.__c = void 0, n()), I = t;
373
373
  }
374
- function Te(e) {
375
- var t = L;
376
- e.__c = e.__(), L = t;
374
+ function Ee(e) {
375
+ var t = I;
376
+ e.__c = e.__(), I = t;
377
377
  }
378
- function Ee(e, t) {
378
+ function De(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 De(e, t) {
383
+ function Oe(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 Oe = 0;
388
+ var ke = 0;
389
389
  Array.isArray;
390
- function W(e, t, r, i, a, o) {
390
+ function U(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 W(e, t, r, i, a, o) {
402
402
  __e: null,
403
403
  __c: null,
404
404
  constructor: void 0,
405
- __v: --Oe,
405
+ __v: --ke,
406
406
  __i: -1,
407
407
  __u: 0,
408
408
  __source: a,
@@ -413,8 +413,8 @@ function W(e, t, r, i, a, o) {
413
413
  }
414
414
  //#endregion
415
415
  //#region src/components/icons.tsx
416
- function G({ name: e, size: t, children: n }) {
417
- return /* @__PURE__ */ W("svg", {
416
+ function W({ name: e, size: t, children: n }) {
417
+ return /* @__PURE__ */ U("svg", {
418
418
  "data-icon": e,
419
419
  "aria-hidden": "true",
420
420
  focusable: "false",
@@ -429,59 +429,59 @@ function G({ name: e, size: t, children: n }) {
429
429
  children: n
430
430
  });
431
431
  }
432
- function ke({ size: e = 26 }) {
433
- return /* @__PURE__ */ W(G, {
432
+ function Ae({ size: e = 26 }) {
433
+ return /* @__PURE__ */ U(W, {
434
434
  name: "chat",
435
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", {
436
+ children: [/* @__PURE__ */ U("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__ */ U("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 Ae({ size: e = 26 }) {
443
- return /* @__PURE__ */ W(G, {
442
+ function je({ size: e = 26 }) {
443
+ return /* @__PURE__ */ U(W, {
444
444
  name: "chevron-down",
445
445
  size: e,
446
- children: /* @__PURE__ */ W("path", { d: "M6 9l6 6 6-6" })
446
+ children: /* @__PURE__ */ U("path", { d: "M6 9l6 6 6-6" })
447
447
  });
448
448
  }
449
- function je({ size: e = 18 }) {
450
- return /* @__PURE__ */ W(G, {
449
+ function Me({ size: e = 18 }) {
450
+ return /* @__PURE__ */ U(W, {
451
451
  name: "close",
452
452
  size: e,
453
- children: /* @__PURE__ */ W("path", { d: "M6 6l12 12M18 6L6 18" })
453
+ children: /* @__PURE__ */ U("path", { d: "M6 6l12 12M18 6L6 18" })
454
454
  });
455
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, {
456
+ var Ne = "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 Pe({ size: e = 16 }) {
458
+ return /* @__PURE__ */ U(W, {
459
459
  name: "thumb-up",
460
460
  size: e,
461
- children: /* @__PURE__ */ W("path", { d: Me })
461
+ children: /* @__PURE__ */ U("path", { d: Ne })
462
462
  });
463
463
  }
464
- function Pe({ size: e = 16 }) {
465
- return /* @__PURE__ */ W(G, {
464
+ function Fe({ size: e = 16 }) {
465
+ return /* @__PURE__ */ U(W, {
466
466
  name: "thumb-down",
467
467
  size: e,
468
- children: /* @__PURE__ */ W("path", {
469
- d: Me,
468
+ children: /* @__PURE__ */ U("path", {
469
+ d: Ne,
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 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", {
476
+ function Ie({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
477
+ let [i, a] = z("loading"), o = n !== void 0 && i !== "failed", s = o && !e && i === "loaded";
478
+ return /* @__PURE__ */ U("button", {
479
479
  type: "button",
480
480
  class: "whoo-widget-launcher",
481
481
  onClick: t,
482
482
  "aria-label": e ? "Close chat" : "Open chat",
483
483
  ref: r,
484
- children: [e ? /* @__PURE__ */ W(Ae, {}) : s ? null : /* @__PURE__ */ W(ke, {}), o ? /* @__PURE__ */ W("img", {
484
+ children: [e ? /* @__PURE__ */ U(je, {}) : s ? null : /* @__PURE__ */ U(Ae, {}), o ? /* @__PURE__ */ U("img", {
485
485
  class: "whoo-widget-launcher-icon-image",
486
486
  src: n,
487
487
  alt: "",
@@ -494,16 +494,16 @@ function Fe({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
494
494
  }
495
495
  //#endregion
496
496
  //#region src/components/Composer.tsx
497
- function Ie({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
498
- return /* @__PURE__ */ W("div", {
497
+ function Le({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
498
+ return /* @__PURE__ */ U("div", {
499
499
  class: "whoo-widget-composer",
500
500
  children: [
501
- /* @__PURE__ */ W("label", {
501
+ /* @__PURE__ */ U("label", {
502
502
  class: "whoo-widget-sr-only",
503
503
  for: "whoo-widget-composer-input",
504
504
  children: "Message"
505
505
  }),
506
- /* @__PURE__ */ W("input", {
506
+ /* @__PURE__ */ U("input", {
507
507
  id: "whoo-widget-composer-input",
508
508
  class: "whoo-widget-composer-input",
509
509
  value: e,
@@ -515,7 +515,7 @@ function Ie({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
515
515
  e.key === "Enter" && n();
516
516
  }
517
517
  }),
518
- /* @__PURE__ */ W("button", {
518
+ /* @__PURE__ */ U("button", {
519
519
  type: "button",
520
520
  class: "whoo-widget-composer-send",
521
521
  onClick: n,
@@ -527,8 +527,8 @@ function Ie({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
527
527
  }
528
528
  //#endregion
529
529
  //#region src/components/ErrorBanner.tsx
530
- function Le({ message: e }) {
531
- return /* @__PURE__ */ W("div", {
530
+ function Re({ message: e }) {
531
+ return /* @__PURE__ */ U("div", {
532
532
  class: "whoo-widget-error-banner",
533
533
  role: "alert",
534
534
  children: e
@@ -536,8 +536,8 @@ function Le({ message: e }) {
536
536
  }
537
537
  //#endregion
538
538
  //#region src/markdown/tokenizer.ts
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) {
539
+ var G = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, K = /\*\*([^*]+)\*\*/y, q = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, J = /\*([^*]+)\*/y, ze = /https?:\/\/\S+/y, Be = /[.,;:!?)\]}>]+$/;
540
+ function Ve(e) {
541
541
  let t = [], n = 0, r = 0, i = (n) => {
542
542
  n > r && t.push({
543
543
  type: "text",
@@ -557,56 +557,56 @@ function Be(e) {
557
557
  }
558
558
  }
559
559
  if (e[n - 1] !== "!") {
560
- K.lastIndex = n;
561
- let a = K.exec(e);
560
+ G.lastIndex = n;
561
+ let a = G.exec(e);
562
562
  if (a) {
563
563
  i(n), t.push({
564
564
  type: "link",
565
565
  text: a[1],
566
566
  url: a[2],
567
567
  start: n,
568
- end: K.lastIndex
569
- }), n = K.lastIndex, r = n;
568
+ end: G.lastIndex
569
+ }), n = G.lastIndex, r = n;
570
570
  continue;
571
571
  }
572
572
  }
573
- q.lastIndex = n;
574
- let a = q.exec(e);
573
+ K.lastIndex = n;
574
+ let a = K.exec(e);
575
575
  if (a) {
576
576
  i(n), t.push({
577
577
  type: "bold",
578
578
  value: a[1],
579
579
  start: n,
580
- end: q.lastIndex
581
- }), n = q.lastIndex, r = n;
580
+ end: K.lastIndex
581
+ }), n = K.lastIndex, r = n;
582
582
  continue;
583
583
  }
584
- J.lastIndex = n;
585
- let o = J.exec(e);
584
+ q.lastIndex = n;
585
+ let o = q.exec(e);
586
586
  if (o) {
587
587
  i(n), t.push({
588
588
  type: "italic",
589
589
  value: o[1],
590
590
  start: n,
591
- end: J.lastIndex
592
- }), n = J.lastIndex, r = n;
591
+ end: q.lastIndex
592
+ }), n = q.lastIndex, r = n;
593
593
  continue;
594
594
  }
595
- Y.lastIndex = n;
596
- let s = Y.exec(e);
595
+ J.lastIndex = n;
596
+ let s = J.exec(e);
597
597
  if (s) {
598
598
  i(n), t.push({
599
599
  type: "italic",
600
600
  value: s[1],
601
601
  start: n,
602
- end: Y.lastIndex
603
- }), n = Y.lastIndex, r = n;
602
+ end: J.lastIndex
603
+ }), n = J.lastIndex, r = n;
604
604
  continue;
605
605
  }
606
- Re.lastIndex = n;
607
- let c = Re.exec(e);
606
+ ze.lastIndex = n;
607
+ let c = ze.exec(e);
608
608
  if (c) {
609
- let e = c[0].match(ze), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
609
+ let e = c[0].match(Be), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
610
610
  if (a.length > 0) {
611
611
  i(n), t.push({
612
612
  type: "link",
@@ -624,16 +624,16 @@ function Be(e) {
624
624
  }
625
625
  //#endregion
626
626
  //#region src/markdown/render.tsx
627
- function Ve(e) {
628
- return Be(e).map((e, t) => {
627
+ function He(e) {
628
+ return Ve(e).map((e, t) => {
629
629
  switch (e.type) {
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", {
630
+ case "bold": return /* @__PURE__ */ U("strong", { children: e.value }, t);
631
+ case "italic": return /* @__PURE__ */ U("em", { children: e.value }, t);
632
+ case "link": return /* @__PURE__ */ U("a", {
633
633
  href: e.url,
634
634
  target: "_blank",
635
635
  rel: "noopener noreferrer",
636
- children: [e.text, /* @__PURE__ */ W("span", {
636
+ children: [e.text, /* @__PURE__ */ U("span", {
637
637
  class: "whoo-widget-sr-only",
638
638
  children: " (opens in new tab)"
639
639
  })]
@@ -644,7 +644,7 @@ function Ve(e) {
644
644
  }
645
645
  //#endregion
646
646
  //#region src/components/MessageFeedback.tsx
647
- var He = [
647
+ var Ue = [
648
648
  {
649
649
  value: "",
650
650
  label: "Select a reason (optional)"
@@ -666,50 +666,50 @@ var He = [
666
666
  label: "Other"
667
667
  }
668
668
  ];
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(() => {
669
+ function We({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancel: a }) {
670
+ let [o, s] = z(""), [c, l] = z(""), u = V(e.status);
671
+ if (B(() => {
672
672
  let n = u.current;
673
673
  if (u.current = e.status, n === e.status) return;
674
674
  let r = t?.current;
675
675
  if (!r) return;
676
676
  let i = r.getRootNode();
677
677
  r.contains(i.activeElement) || r.focus();
678
- }, [e.status, t]), e.status === "submitted") return /* @__PURE__ */ W("div", {
678
+ }, [e.status, t]), e.status === "submitted") return /* @__PURE__ */ U("div", {
679
679
  class: "whoo-widget-feedback-submitted",
680
680
  role: "status",
681
681
  children: "Thanks for the feedback"
682
682
  });
683
- if (e.status === "expanded") return /* @__PURE__ */ W("div", {
683
+ if (e.status === "expanded") return /* @__PURE__ */ U("div", {
684
684
  class: "whoo-widget-feedback-form",
685
685
  children: [
686
- /* @__PURE__ */ W("label", { children: [/* @__PURE__ */ W("span", {
686
+ /* @__PURE__ */ U("label", { children: [/* @__PURE__ */ U("span", {
687
687
  class: "whoo-widget-sr-only",
688
688
  children: "Additional feedback"
689
- }), /* @__PURE__ */ W("textarea", {
689
+ }), /* @__PURE__ */ U("textarea", {
690
690
  class: "whoo-widget-feedback-textarea",
691
691
  value: o,
692
692
  onInput: (e) => s(e.target.value),
693
693
  placeholder: "What was wrong? (optional)"
694
694
  })] }),
695
- /* @__PURE__ */ W("select", {
695
+ /* @__PURE__ */ U("select", {
696
696
  class: "whoo-widget-feedback-select",
697
697
  "aria-label": "Feedback category",
698
698
  value: c,
699
699
  onChange: (e) => l(e.target.value),
700
- children: He.map((e) => /* @__PURE__ */ W("option", {
700
+ children: Ue.map((e) => /* @__PURE__ */ U("option", {
701
701
  value: e.value,
702
702
  children: e.label
703
703
  }, e.value))
704
704
  }),
705
- /* @__PURE__ */ W("div", {
705
+ /* @__PURE__ */ U("div", {
706
706
  class: "whoo-widget-feedback-form-buttons",
707
- children: [/* @__PURE__ */ W("button", {
707
+ children: [/* @__PURE__ */ U("button", {
708
708
  type: "button",
709
709
  class: "whoo-widget-feedback-submit",
710
710
  onClick: () => i(o, c),
711
711
  children: "Submit"
712
- }), /* @__PURE__ */ W("button", {
712
+ }), /* @__PURE__ */ U("button", {
713
713
  type: "button",
714
714
  class: "whoo-widget-feedback-cancel",
715
715
  onClick: a,
@@ -719,24 +719,24 @@ function Ue({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
719
719
  ]
720
720
  });
721
721
  let d = e.status === "submitting";
722
- return /* @__PURE__ */ W("div", {
722
+ return /* @__PURE__ */ U("div", {
723
723
  class: "whoo-widget-feedback",
724
- children: [/* @__PURE__ */ W("div", {
724
+ children: [/* @__PURE__ */ U("div", {
725
725
  class: "whoo-widget-feedback-buttons",
726
- children: [/* @__PURE__ */ W("button", {
726
+ children: [/* @__PURE__ */ U("button", {
727
727
  type: "button",
728
728
  "aria-label": "Good response",
729
729
  disabled: d,
730
730
  onClick: n,
731
- children: /* @__PURE__ */ W(Ne, {})
732
- }), /* @__PURE__ */ W("button", {
731
+ children: /* @__PURE__ */ U(Pe, {})
732
+ }), /* @__PURE__ */ U("button", {
733
733
  type: "button",
734
734
  "aria-label": "Bad response",
735
735
  disabled: d,
736
736
  onClick: r,
737
- children: /* @__PURE__ */ W(Pe, {})
737
+ children: /* @__PURE__ */ U(Fe, {})
738
738
  })]
739
- }), e.status === "error" ? /* @__PURE__ */ W("div", {
739
+ }), e.status === "error" ? /* @__PURE__ */ U("div", {
740
740
  class: "whoo-widget-feedback-error",
741
741
  role: "status",
742
742
  children: "Couldn't send feedback"
@@ -745,27 +745,27 @@ function Ue({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
745
745
  }
746
746
  //#endregion
747
747
  //#region src/components/MessageList.tsx
748
- function We({ isSlowResponse: e }) {
749
- return /* @__PURE__ */ W("div", {
748
+ function Ge({ isSlowResponse: e }) {
749
+ return /* @__PURE__ */ U("div", {
750
750
  class: "whoo-widget-pending",
751
751
  role: "status",
752
- children: [/* @__PURE__ */ W("span", {
752
+ children: [/* @__PURE__ */ U("span", {
753
753
  class: "whoo-widget-typing",
754
754
  "aria-hidden": "true",
755
755
  children: [
756
- /* @__PURE__ */ W("span", {}),
757
- /* @__PURE__ */ W("span", {}),
758
- /* @__PURE__ */ W("span", {})
756
+ /* @__PURE__ */ U("span", {}),
757
+ /* @__PURE__ */ U("span", {}),
758
+ /* @__PURE__ */ U("span", {})
759
759
  ]
760
- }), e ? /* @__PURE__ */ W("span", {
760
+ }), e ? /* @__PURE__ */ U("span", {
761
761
  class: "whoo-widget-pending-text",
762
762
  children: "Looking that up for you…"
763
763
  }) : null]
764
764
  });
765
765
  }
766
- function Ge({ url: e, alt: t }) {
767
- let [n, r] = B(!1);
768
- return n ? null : /* @__PURE__ */ W("img", {
766
+ function Ke({ url: e, alt: t }) {
767
+ let [n, r] = z(!1);
768
+ return n ? null : /* @__PURE__ */ U("img", {
769
769
  class: "whoo-widget-empty-state-image",
770
770
  src: e,
771
771
  alt: t,
@@ -773,13 +773,13 @@ function Ge({ url: e, alt: t }) {
773
773
  onError: () => r(!0)
774
774
  });
775
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", {
776
+ function qe({ message: e, feedbackState: t, pending: n, isSlowResponse: r, onThumbsUp: i, onThumbsDown: a, onSubmitDetailed: o, onCancelFeedback: s }) {
777
+ let c = V(null), l = e.id;
778
+ return /* @__PURE__ */ U("div", {
779
779
  ref: c,
780
780
  tabIndex: -1,
781
781
  class: `whoo-widget-message whoo-widget-message--${e.role}`,
782
- children: [n ? /* @__PURE__ */ W(We, { isSlowResponse: r }) : Ve(e.content), e.role === "assistant" && l ? /* @__PURE__ */ W(Ue, {
782
+ children: [n ? /* @__PURE__ */ U(Ge, { isSlowResponse: r }) : He(e.content), e.role === "assistant" && l ? /* @__PURE__ */ U(We, {
783
783
  state: t,
784
784
  containerRef: c,
785
785
  onThumbsUp: () => i(l),
@@ -789,15 +789,15 @@ function Ke({ message: e, feedbackState: t, pending: n, isSlowResponse: r, onThu
789
789
  }) : null]
790
790
  });
791
791
  }
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(() => {
792
+ function Je({ 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 = V(null);
794
+ return B(() => {
795
795
  let e = u.current;
796
796
  e && (e.scrollTop = e.scrollHeight);
797
- }, [e, a]), /* @__PURE__ */ W(C, { children: [/* @__PURE__ */ W("div", {
797
+ }, [e, a]), /* @__PURE__ */ U(C, { children: [/* @__PURE__ */ U("div", {
798
798
  class: "whoo-widget-message-list",
799
799
  ref: u,
800
- children: [r ? /* @__PURE__ */ W(Ge, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ W(Ke, {
800
+ children: [r ? /* @__PURE__ */ U(Ke, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ U(qe, {
801
801
  message: n,
802
802
  feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
803
803
  pending: i && r === e.length - 1 && n.role === "assistant" && n.content === "",
@@ -807,7 +807,7 @@ function qe({ messages: e, messageFeedback: t, lastCompletedMessageText: n, empt
807
807
  onSubmitDetailed: c,
808
808
  onCancelFeedback: l
809
809
  }, n.id ?? r))]
810
- }), /* @__PURE__ */ W("div", {
810
+ }), /* @__PURE__ */ U("div", {
811
811
  class: "whoo-widget-sr-only",
812
812
  "aria-live": "polite",
813
813
  "aria-atomic": "true",
@@ -816,16 +816,16 @@ function qe({ messages: e, messageFeedback: t, lastCompletedMessageText: n, empt
816
816
  }
817
817
  //#endregion
818
818
  //#region src/components/Panel.tsx
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) => {
819
+ var Ye = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
820
+ function Xe(e) {
821
+ return Array.from(e.querySelectorAll(Ye)).filter((e) => {
822
822
  let t = getComputedStyle(e);
823
823
  return t.display !== "none" && t.visibility !== "hidden";
824
824
  });
825
825
  }
826
- function Xe({ state: e, controller: t, greeting: n }) {
827
- let r = H(null), i = H(null);
828
- V(() => {
826
+ function Ze({ state: e, controller: t, greeting: n }) {
827
+ let r = V(null), i = V(null);
828
+ B(() => {
829
829
  i.current?.focus();
830
830
  }, []);
831
831
  let a = (e) => {
@@ -836,7 +836,7 @@ function Xe({ state: e, controller: t, greeting: n }) {
836
836
  if (e.key !== "Tab") return;
837
837
  let n = r.current;
838
838
  if (!n) return;
839
- let i = Ye(n);
839
+ let i = Xe(n);
840
840
  if (i.length === 0) return;
841
841
  let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
842
842
  if (!n.contains(s)) {
@@ -855,7 +855,7 @@ function Xe({ state: e, controller: t, greeting: n }) {
855
855
  url: l,
856
856
  alt: t.emptyStateImageAlt
857
857
  } : void 0;
858
- return /* @__PURE__ */ W("div", {
858
+ return /* @__PURE__ */ U("div", {
859
859
  class: "whoo-widget-panel",
860
860
  role: "dialog",
861
861
  "aria-modal": "true",
@@ -863,28 +863,28 @@ function Xe({ state: e, controller: t, greeting: n }) {
863
863
  ref: r,
864
864
  onKeyDown: a,
865
865
  children: [
866
- /* @__PURE__ */ W("div", {
866
+ /* @__PURE__ */ U("div", {
867
867
  class: "whoo-widget-header",
868
- children: [/* @__PURE__ */ W("h2", {
868
+ children: [/* @__PURE__ */ U("h2", {
869
869
  class: "whoo-widget-header-title",
870
870
  children: s
871
- }), /* @__PURE__ */ W("div", {
871
+ }), /* @__PURE__ */ U("div", {
872
872
  class: "whoo-widget-header-actions",
873
- children: [e.messages.length > 0 && /* @__PURE__ */ W("button", {
873
+ children: [e.messages.length > 0 && /* @__PURE__ */ U("button", {
874
874
  type: "button",
875
875
  class: "whoo-widget-header-reset",
876
876
  onClick: () => t.resetConversation(),
877
877
  children: "New conversation"
878
- }), /* @__PURE__ */ W("button", {
878
+ }), /* @__PURE__ */ U("button", {
879
879
  type: "button",
880
880
  class: "whoo-widget-header-close",
881
881
  "aria-label": "Close chat",
882
882
  onClick: () => t.close(),
883
- children: /* @__PURE__ */ W(je, {})
883
+ children: /* @__PURE__ */ U(Me, {})
884
884
  })]
885
885
  })]
886
886
  }),
887
- /* @__PURE__ */ W(qe, {
887
+ /* @__PURE__ */ U(Je, {
888
888
  messages: c,
889
889
  messageFeedback: e.messageFeedback,
890
890
  lastCompletedMessageText: e.lastCompletedMessageText,
@@ -896,8 +896,8 @@ function Xe({ state: e, controller: t, greeting: n }) {
896
896
  onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
897
897
  onCancelFeedback: (e) => t.cancelFeedback(e)
898
898
  }),
899
- e.runtimeError && /* @__PURE__ */ W(Le, { message: e.runtimeError }),
900
- /* @__PURE__ */ W(Ie, {
899
+ e.runtimeError && /* @__PURE__ */ U(Re, { message: e.runtimeError }),
900
+ /* @__PURE__ */ U(Le, {
901
901
  value: e.draft,
902
902
  onChange: (e) => t.setDraft(e),
903
903
  onSend: o,
@@ -909,16 +909,16 @@ function Xe({ state: e, controller: t, greeting: n }) {
909
909
  }
910
910
  //#endregion
911
911
  //#region src/components/App.tsx
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(() => {
912
+ function Qe({ controller: e }) {
913
+ let [t, n] = z(e.getState()), r = V(null), i = V(t.isOpen);
914
+ return B(() => (n(e.getState()), e.subscribe(n)), [e]), B(() => {
915
915
  i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
916
- }, [t.isOpen]), t.initError ? null : /* @__PURE__ */ W(C, { children: [/* @__PURE__ */ W(Fe, {
916
+ }, [t.isOpen]), t.initError ? null : /* @__PURE__ */ U(C, { children: [/* @__PURE__ */ U(Ie, {
917
917
  isOpen: t.isOpen,
918
918
  onClick: () => t.isOpen ? e.close() : e.open(),
919
919
  iconUrl: e.launcherIconUrl,
920
920
  buttonRef: r
921
- }), t.isOpen && /* @__PURE__ */ W(Xe, {
921
+ }), t.isOpen && /* @__PURE__ */ U(Ze, {
922
922
  state: t,
923
923
  controller: e,
924
924
  greeting: e.config.greeting
@@ -926,34 +926,34 @@ function Ze({ controller: e }) {
926
926
  }
927
927
  //#endregion
928
928
  //#region src/api/client.ts
929
- var Qe = class extends Error {
929
+ var $e = class extends Error {
930
930
  status;
931
931
  constructor(e, t) {
932
932
  super(e), this.name = "WidgetApiError", this.status = t;
933
933
  }
934
934
  };
935
- function $e(e) {
935
+ function et(e) {
936
936
  if (typeof e != "string") return null;
937
937
  let t = e.trim();
938
938
  return t === "" ? null : t;
939
939
  }
940
- async function et(e, t) {
940
+ async function tt(e, t) {
941
941
  let n = await fetch(`${e}/api/v1/widget/session`, {
942
942
  method: "POST",
943
943
  headers: { "Content-Type": "application/json" },
944
944
  body: JSON.stringify({ publishable_key: t })
945
945
  });
946
- if (!n.ok) throw new Qe(`Failed to create widget session (${n.status})`, n.status);
946
+ if (!n.ok) throw new $e(`Failed to create widget session (${n.status})`, n.status);
947
947
  let r = await n.json();
948
948
  return {
949
949
  token: r.token,
950
950
  primaryColor: r.primary_color ?? null,
951
- name: $e(r.name),
952
- accentColor: $e(r.accent_color),
953
- inkColor: $e(r.ink_color)
951
+ name: et(r.name),
952
+ accentColor: et(r.accent_color),
953
+ inkColor: et(r.ink_color)
954
954
  };
955
955
  }
956
- async function tt(e, t, n) {
956
+ async function nt(e, t, n) {
957
957
  let r = await fetch(`${e}/api/v1/widget/feedback`, {
958
958
  method: "POST",
959
959
  headers: {
@@ -967,11 +967,11 @@ async function tt(e, t, n) {
967
967
  category: n.category ?? null
968
968
  })
969
969
  });
970
- if (!r.ok) throw new Qe(`Feedback submission failed (${r.status})`, r.status);
970
+ if (!r.ok) throw new $e(`Feedback submission failed (${r.status})`, r.status);
971
971
  }
972
972
  //#endregion
973
973
  //#region src/api/sse.ts
974
- async function* nt(e, t, n, r, i) {
974
+ async function* rt(e, t, n, r, i) {
975
975
  let a = await fetch(`${e}/api/v1/widget/chat`, {
976
976
  method: "POST",
977
977
  headers: {
@@ -984,7 +984,7 @@ async function* nt(e, t, n, r, i) {
984
984
  }),
985
985
  signal: i
986
986
  });
987
- if (!a.ok || !a.body) throw new Qe(`Chat request failed (${a.status})`, a.status);
987
+ if (!a.ok || !a.body) throw new $e(`Chat request failed (${a.status})`, a.status);
988
988
  let o = a.body.getReader(), s = new TextDecoder(), c = "";
989
989
  for (;;) {
990
990
  let { done: e, value: t } = await o.read();
@@ -995,11 +995,11 @@ async function* nt(e, t, n, r, i) {
995
995
  let e = c.slice(0, n);
996
996
  c = c.slice(n + 2);
997
997
  let t = e.split("\n").find((e) => e.startsWith("data: "));
998
- t && (yield rt(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
998
+ t && (yield it(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
999
999
  }
1000
1000
  }
1001
1001
  }
1002
- function rt(e) {
1002
+ function it(e) {
1003
1003
  return typeof e.error == "string" ? {
1004
1004
  type: "error",
1005
1005
  error: e.error,
@@ -1022,7 +1022,7 @@ function rt(e) {
1022
1022
  }
1023
1023
  //#endregion
1024
1024
  //#region src/imageUrl.ts
1025
- function it(e, t) {
1025
+ function at(e, t) {
1026
1026
  if (e != null && e !== "") {
1027
1027
  if (typeof e == "string") try {
1028
1028
  let t = new URL(e);
@@ -1033,16 +1033,16 @@ function it(e, t) {
1033
1033
  }
1034
1034
  //#endregion
1035
1035
  //#region src/markdown/reveal.ts
1036
- var at = 40, ot = 120;
1037
- function st(e) {
1036
+ var ot = 40, st = 120;
1037
+ function ct(e) {
1038
1038
  let t = [];
1039
- for (let n of Be(e)) if (n.type === "text") {
1039
+ for (let n of Ve(e)) if (n.type === "text") {
1040
1040
  let e = n.value.split(/(\s+)/), r = n.start;
1041
1041
  for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
1042
1042
  } else t.push(n.end);
1043
1043
  return t;
1044
1044
  }
1045
- function ct(e) {
1045
+ function lt(e) {
1046
1046
  let t = null;
1047
1047
  return e?.addEventListener("abort", () => {
1048
1048
  t?.();
@@ -1057,31 +1057,31 @@ function ct(e) {
1057
1057
  });
1058
1058
  };
1059
1059
  }
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;
1060
+ async function ut(e, t, n) {
1061
+ let r = n?.wordIntervalMs ?? ot, i = n?.tokenIntervalMs ?? st, a = n?.signal, o = Ve(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = lt(a), l = "";
1062
+ for (let n of ct(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1063
1063
  l !== e && t(e);
1064
1064
  }
1065
1065
  //#endregion
1066
1066
  //#region src/storage.ts
1067
- function ut(e) {
1067
+ function Y(e) {
1068
1068
  return `whoo-aiden-widget:conversation:${e}`;
1069
1069
  }
1070
1070
  function dt(e) {
1071
1071
  try {
1072
- return window.sessionStorage.getItem(ut(e));
1072
+ return window.sessionStorage.getItem(Y(e));
1073
1073
  } catch {
1074
1074
  return null;
1075
1075
  }
1076
1076
  }
1077
1077
  function ft(e, t) {
1078
1078
  try {
1079
- window.sessionStorage.setItem(ut(e), t);
1079
+ window.sessionStorage.setItem(Y(e), t);
1080
1080
  } catch {}
1081
1081
  }
1082
1082
  function pt(e) {
1083
1083
  try {
1084
- window.sessionStorage.removeItem(ut(e));
1084
+ window.sessionStorage.removeItem(Y(e));
1085
1085
  } catch {}
1086
1086
  }
1087
1087
  //#endregion
@@ -1100,7 +1100,7 @@ var mt = 8e3, ht = class {
1100
1100
  emptyStateImageUrl;
1101
1101
  emptyStateImageAlt;
1102
1102
  constructor(e) {
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 = {
1103
+ this.config = e, this.launcherIconUrl = at(e.launcherIconUrl, "launcherIconUrl"), this.emptyStateImageUrl = at(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 = {
1104
1104
  isOpen: !1,
1105
1105
  messages: [],
1106
1106
  isStreaming: !1,
@@ -1137,7 +1137,7 @@ var mt = 8e3, ht = class {
1137
1137
  try {
1138
1138
  if (this.config.sessionToken) this.sessionToken = this.config.sessionToken;
1139
1139
  else if (this.config.publishableKey) {
1140
- let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await et(e, this.config.publishableKey);
1140
+ let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await tt(e, this.config.publishableKey);
1141
1141
  this.sessionToken = t, this.setState({
1142
1142
  primaryColor: n,
1143
1143
  agentName: r,
@@ -1208,8 +1208,8 @@ var mt = 8e3, ht = class {
1208
1208
  });
1209
1209
  }, s = "";
1210
1210
  try {
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));
1211
+ for await (let n of rt(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 ut(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
1213
1213
  else if (n.type === "done") {
1214
1214
  if (n.conversationId && (this.conversationId = n.conversationId, ft(this.storageIdentifier, n.conversationId)), n.messageId) {
1215
1215
  let e = [...this.state.messages];
@@ -1252,7 +1252,7 @@ var mt = 8e3, ht = class {
1252
1252
  }
1253
1253
  } });
1254
1254
  try {
1255
- await tt(i, this.sessionToken, {
1255
+ await nt(i, this.sessionToken, {
1256
1256
  messageId: e,
1257
1257
  rating: t,
1258
1258
  correction: n,
@@ -1274,8 +1274,8 @@ var mt = 8e3, ht = class {
1274
1274
  } });
1275
1275
  }
1276
1276
  }
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) {
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,#00e)}.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 vt(e) {
1279
1279
  if (_t.test(e.trim())) return null;
1280
1280
  let t = document.createElement("div");
1281
1281
  if (t.style.color = e, t.style.color === "") return null;
@@ -1295,96 +1295,123 @@ function X(e) {
1295
1295
  translucent: a < 1
1296
1296
  };
1297
1297
  }
1298
- function vt(e) {
1299
- return X(e)?.rgb ?? null;
1298
+ function yt(e) {
1299
+ return vt(e)?.rgb ?? null;
1300
1300
  }
1301
- function Z([e, t, n]) {
1301
+ function X([e, t, n]) {
1302
1302
  let r = (e) => {
1303
1303
  let t = e / 255;
1304
1304
  return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
1305
1305
  };
1306
1306
  return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
1307
1307
  }
1308
- function yt(e, t) {
1308
+ function bt(e, t) {
1309
1309
  let n = Math.max(e, t), r = Math.min(e, t);
1310
1310
  return (n + .05) / (r + .05);
1311
1311
  }
1312
- function bt(e) {
1313
- let t = vt(e);
1312
+ function xt(e) {
1313
+ let t = yt(e);
1314
1314
  if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
1315
- let n = Z(t);
1316
- return yt(n, Z([
1315
+ let n = X(t);
1316
+ return bt(n, X([
1317
1317
  0,
1318
1318
  0,
1319
1319
  0
1320
- ])) >= yt(n, Z([
1320
+ ])) >= bt(n, X([
1321
1321
  255,
1322
1322
  255,
1323
1323
  255
1324
1324
  ])) ? "#000000" : "#ffffff";
1325
1325
  }
1326
- var Q = "#4f46e5", xt = "#ffffff", St = "#f0f0f0", Ct = 4.5;
1327
- function $([e, t, n]) {
1326
+ var Z = "#4f46e5", St = "#ffffff", Ct = "#f0f0f0", wt = 4.5;
1327
+ function Tt([e, t, n]) {
1328
1328
  return `#${[
1329
1329
  e,
1330
1330
  t,
1331
1331
  n
1332
1332
  ].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
1333
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);
1334
+ function Et(e, t = St) {
1335
+ let n = yt(e), r = yt(t);
1336
+ if (!n || !r) return Z;
1337
+ let i = X(r), a = (e) => bt(X(e), i) >= wt;
1338
+ if (a(n)) return Tt(n);
1339
1339
  for (let e = .99; e > 0; e -= .01) {
1340
1340
  let t = n.map((t) => Math.round(t * e));
1341
- if (a(t)) return $(t);
1341
+ if (a(t)) return Tt(t);
1342
1342
  }
1343
1343
  return "#000000";
1344
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));
1345
+ var Dt = "#111111", Ot = "#0000ee";
1346
+ function Q(e) {
1347
+ if (!e) return null;
1348
+ let t = vt(e);
1349
+ return t ? Tt(t.rgb) : null;
1350
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);
1351
+ function $({ color: e, inkColor: t, accentColor: n }) {
1352
+ let r = Q(e), i = r ?? Z, a = Et(i), o = Q(t), s = o ? Et(o, Ct) : Dt, c = Q(n), l = c ? Et(c, Ct) : Ot;
1353
+ return {
1354
+ primary: i,
1355
+ textOnPrimary: xt(i),
1356
+ primaryAsText: a,
1357
+ ink: s,
1358
+ link: l,
1359
+ adjusted: {
1360
+ primary: r !== null && a !== i,
1361
+ ink: o !== null && s !== o,
1362
+ link: c !== null && l !== c
1363
+ }
1364
+ };
1357
1365
  }
1358
- function Dt(e, t) {
1359
- Tt(e, t.color ?? Q);
1366
+ function kt(e, t, n = Z) {
1367
+ let r = t;
1368
+ Q(t) === null && (console.warn(`[whoo-aiden-widget] Could not use "${t}" as the theme color; falling back to "${n}".`), r = n);
1369
+ let i = $({ color: r });
1370
+ e.style.setProperty("--whoo-widget-color", i.primary), e.style.setProperty("--whoo-widget-text-on-color", i.textOnPrimary), e.style.setProperty("--whoo-widget-color-text", i.primaryAsText);
1371
+ }
1372
+ function At(e, { inkColor: t, accentColor: n }) {
1373
+ let r = $({
1374
+ inkColor: t,
1375
+ accentColor: n
1376
+ });
1377
+ e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
1378
+ }
1379
+ function jt(e, t) {
1380
+ e && Q(e) === null && console.warn(`[whoo-aiden-widget] Could not use "${e}" as the ${t}; using the default.`);
1381
+ }
1382
+ function Mt(e, t) {
1383
+ kt(e, t.color ?? Z), jt(t.inkColor, "ink color"), jt(t.accentColor, "accent color"), At(e, {
1384
+ inkColor: t.inkColor,
1385
+ accentColor: t.accentColor
1386
+ });
1360
1387
  let n = t.position === "bottom-left";
1361
1388
  e.style.setProperty("--whoo-widget-inset-left", n ? "20px" : "auto"), e.style.setProperty("--whoo-widget-inset-right", n ? "auto" : "20px");
1362
1389
  }
1363
1390
  //#endregion
1364
1391
  //#region src/mount.tsx
1365
- function Ot(e) {
1392
+ function Nt(e) {
1366
1393
  let t = document.createElement("div");
1367
1394
  t.id = "whoo-aiden-widget-host";
1368
1395
  let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
1369
1396
  r.textContent = gt, n.appendChild(r);
1370
1397
  let i = document.createElement("div");
1371
- n.appendChild(i), Dt(i, e);
1398
+ n.appendChild(i), Mt(i, e);
1372
1399
  let a = new ht(e), o = null, s = "";
1373
1400
  return a.subscribe((t) => {
1374
- t.primaryColor && t.primaryColor !== o && (o = t.primaryColor, Tt(i, t.primaryColor, e.color));
1401
+ t.primaryColor && t.primaryColor !== o && (o = t.primaryColor, kt(i, t.primaryColor, e.color));
1375
1402
  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
1403
+ (t.inkColor || t.accentColor) && n !== s && (s = n, At(i, {
1404
+ inkColor: Q(t.inkColor) ? t.inkColor : e.inkColor,
1405
+ accentColor: Q(t.accentColor) ? t.accentColor : e.accentColor
1379
1406
  }));
1380
- }), le(/* @__PURE__ */ W(Ze, { controller: a }), i), a.init(), document.body.appendChild(t), { unmount() {
1381
- le(null, i), t.remove();
1407
+ }), ue(/* @__PURE__ */ U(Qe, { controller: a }), i), a.init(), document.body.appendChild(t), { unmount() {
1408
+ ue(null, i), t.remove();
1382
1409
  } };
1383
1410
  }
1384
1411
  //#endregion
1385
1412
  //#region src/index.ts
1386
- function kt(t) {
1387
- return e(t), Ot(t);
1413
+ function Pt(t) {
1414
+ return e(t), Nt(t);
1388
1415
  }
1389
1416
  //#endregion
1390
- export { kt as init };
1417
+ export { Pt as init, $ as resolveTheme };