@aiden-voice/widget 0.5.2 → 0.6.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
@@ -1,30 +1,203 @@
1
- var e = 2147483e3, t = 2147483647;
2
- function n(n) {
3
- return n === void 0 ? e : Number.isInteger(n) && Math.abs(n) <= t ? n : (console.warn(`whoo-aiden-widget: ignoring zIndex ${String(n)} (expected an integer between -${t} and ${t}); using ${e}.`), e);
1
+ //#region src/imageUrl.ts
2
+ function e(e, t) {
3
+ if (e != null && e !== "") {
4
+ if (typeof e == "string") try {
5
+ let t = new URL(e);
6
+ if (t.protocol === "https:" || t.protocol === "data:" && t.pathname.toLowerCase().startsWith("image/")) return e;
7
+ } catch {}
8
+ console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`);
9
+ }
4
10
  }
5
- function r(e) {
11
+ //#endregion
12
+ //#region src/themeRoles.ts
13
+ var t = [
14
+ "primary",
15
+ "onPrimary",
16
+ "primaryText",
17
+ "ink",
18
+ "link",
19
+ "text",
20
+ "panel",
21
+ "border",
22
+ "headerHover",
23
+ "assistantBubble",
24
+ "muted",
25
+ "typingDots",
26
+ "errorBackground",
27
+ "errorText",
28
+ "inputBorder",
29
+ "focusRing"
30
+ ], n = {
31
+ primary: "#4f46e5",
32
+ onPrimary: "#ffffff",
33
+ primaryText: "#4f46e5",
34
+ ink: "#111111",
35
+ link: "#0000ee",
36
+ text: "#111111",
37
+ panel: "#ffffff",
38
+ border: "#e5e5e5",
39
+ headerHover: "#f3f4f6",
40
+ assistantBubble: "#f0f0f0",
41
+ muted: "#4b5563",
42
+ typingDots: "#6b7280",
43
+ errorBackground: "#fee2e2",
44
+ errorText: "#991b1b",
45
+ inputBorder: "#6b7280",
46
+ focusRing: "#111827"
47
+ }, r = {
48
+ primary: "--whoo-widget-color",
49
+ onPrimary: "--whoo-widget-text-on-color",
50
+ primaryText: "--whoo-widget-color-text",
51
+ ink: "--whoo-widget-ink",
52
+ link: "--whoo-widget-link-color",
53
+ text: "--whoo-widget-text",
54
+ panel: "--whoo-widget-panel",
55
+ border: "--whoo-widget-border",
56
+ headerHover: "--whoo-widget-header-hover",
57
+ assistantBubble: "--whoo-widget-assistant-bubble",
58
+ muted: "--whoo-widget-muted",
59
+ typingDots: "--whoo-widget-typing-dots",
60
+ errorBackground: "--whoo-widget-error-bg",
61
+ errorText: "--whoo-widget-error-text",
62
+ inputBorder: "--whoo-widget-input-border",
63
+ focusRing: "--whoo-widget-focus-ring"
64
+ }, i = 2147483e3, a = 2147483647;
65
+ function o(e) {
66
+ return e === void 0 ? i : Number.isInteger(e) && Math.abs(e) <= a ? e : (console.warn(`whoo-aiden-widget: ignoring zIndex ${String(e)} (expected an integer between -${a} and ${a}); using ${i}.`), i);
67
+ }
68
+ var s = "Aiden";
69
+ function c(e) {
6
70
  return typeof e == "string" ? e.trim() : "";
7
71
  }
8
- function i(e) {
72
+ function l(e) {
9
73
  if ((typeof e.publishableKey == "string" && e.publishableKey.length > 0) == (typeof e.sessionToken == "string" && e.sessionToken.length > 0)) throw Error("whoo-aiden-widget: init() requires exactly one of `publishableKey` or `sessionToken`, not both or neither.");
10
74
  }
11
- //#endregion
12
- //#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/dist/preact.module.js
13
- var a, o, s, c, l, u, d, f, p, m, h, g, _, v, y = {}, b = [], x = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, S = Array.isArray;
14
- function C(e, t) {
15
- for (var n in t) e[n] = t[n];
16
- return e;
75
+ function u(e) {
76
+ console.warn(`whoo-aiden-widget: ${e}`);
77
+ }
78
+ var d = 20;
79
+ function f(e) {
80
+ let t = /* @__PURE__ */ new WeakSet(), n = /* @__PURE__ */ new Set();
81
+ return (r) => {
82
+ if (typeof r == "object" && r || typeof r == "function") {
83
+ if (t.has(r)) return;
84
+ t.add(r);
85
+ } else {
86
+ if (n.has(r)) return;
87
+ n.size >= d && n.delete(n.values().next().value), n.add(r);
88
+ }
89
+ u(e);
90
+ };
91
+ }
92
+ var p = f("ignoring `theme` -- expected an object."), m = f("ignoring `layout` -- expected an object.");
93
+ function h(e) {
94
+ return typeof e == "object" && !!e && !Array.isArray(e);
17
95
  }
18
- function ee(e) {
19
- e && e.parentNode && e.parentNode.removeChild(e);
96
+ var g = (e) => e == null || e === "";
97
+ function _(e, t, n) {
98
+ let r = e[t];
99
+ return r == null ? null : h(r) ? r : (u(`ignoring \`${n}\` -- expected an object.`), null);
20
100
  }
21
- function w(e, t, n) {
22
- var r, i, o, s = {};
23
- for (o in t) o == "key" ? r = t[o] : o == "ref" ? i = t[o] : s[o] = t[o];
24
- if (arguments.length > 2 && (s.children = arguments.length > 3 ? a.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (o in e.defaultProps) s[o] === void 0 && (s[o] = e.defaultProps[o]);
25
- return T(e, s, r, i, null);
101
+ function v(e, t, n) {
102
+ for (let r of Object.keys(e)) t.includes(r) || u(`ignoring unknown option \`${n}.${r}\`.`);
103
+ }
104
+ function y(e, t, n) {
105
+ if (!g(e)) {
106
+ if (typeof e == "string" && t.includes(e)) return e;
107
+ u(`ignoring \`${n}\` -- expected one of ${t.join(", ")}.`);
108
+ }
26
109
  }
27
- function T(e, t, n, r, i) {
110
+ var b = 200, x = /url\(|[@;{}\\]/i;
111
+ function S(e) {
112
+ if (!g(e)) {
113
+ if (typeof e == "string") {
114
+ let t = e.trim();
115
+ if (t && t.length <= b && !x.test(t)) return t;
116
+ }
117
+ u(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${b} characters, without url(), @, ;, {, } or \\.`);
118
+ }
119
+ }
120
+ var C = [
121
+ "chat",
122
+ "message",
123
+ "sparkle"
124
+ ], ee = ["chevron-down", "close"], w = /* @__PURE__ */ new WeakMap();
125
+ function T(n) {
126
+ let r = {
127
+ colors: {},
128
+ fontFamily: void 0,
129
+ launcher: {}
130
+ };
131
+ if (n == null) return r;
132
+ if (!h(n)) return p(n), r;
133
+ let i = w.get(n);
134
+ if (i) return i;
135
+ v(n, [
136
+ "colors",
137
+ "fonts",
138
+ "launcher"
139
+ ], "theme");
140
+ let a = _(n, "colors", "theme.colors");
141
+ if (a) {
142
+ v(a, t, "theme.colors");
143
+ for (let e of t) {
144
+ let t = a[e];
145
+ g(t) || (typeof t == "string" ? r.colors[e] = t : u(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`));
146
+ }
147
+ }
148
+ let o = _(n, "fonts", "theme.fonts");
149
+ o && (v(o, ["family"], "theme.fonts"), r.fontFamily = S(o.family));
150
+ let s = _(n, "launcher", "theme.launcher");
151
+ if (s) {
152
+ v(s, [
153
+ "icon",
154
+ "iconUrl",
155
+ "openIcon",
156
+ "openIconUrl"
157
+ ], "theme.launcher");
158
+ let t = y(s.icon, C, "theme.launcher.icon"), n = e(s.iconUrl, "theme.launcher.iconUrl"), i = y(s.openIcon, ee, "theme.launcher.openIcon"), a = e(s.openIconUrl, "theme.launcher.openIconUrl");
159
+ t && (r.launcher.icon = t), n && (r.launcher.iconUrl = n), i && (r.launcher.openIcon = i), a && (r.launcher.openIconUrl = a);
160
+ }
161
+ return w.set(n, r), r;
162
+ }
163
+ var E = {
164
+ offsetX: 20,
165
+ offsetY: 20,
166
+ launcherSize: 56,
167
+ panelWidth: 360,
168
+ panelHeight: 480
169
+ };
170
+ function D(e, t, n) {
171
+ return e == null ? n : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : (u(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`), n);
172
+ }
173
+ function O(e, t, n, r) {
174
+ let i = Math.min(r, Math.max(n, e));
175
+ return i !== e && u(`\`${t}\` ${e} is out of range (${r === Infinity ? `at least ${n}` : `${n}-${r}`}); using ${i}.`), i;
176
+ }
177
+ var k = /* @__PURE__ */ new WeakMap();
178
+ function te(e) {
179
+ let t = { ...E };
180
+ if (e == null) return t;
181
+ if (!h(e)) return m(e), t;
182
+ let n = k.get(e);
183
+ if (n) return n;
184
+ v(e, [
185
+ "offset",
186
+ "launcherSize",
187
+ "panel"
188
+ ], "layout");
189
+ let r = _(e, "offset", "layout.offset");
190
+ r && (v(r, ["x", "y"], "layout.offset"), t.offsetX = D(r.x, "layout.offset.x", E.offsetX), t.offsetY = D(r.y, "layout.offset.y", E.offsetY)), t.launcherSize = O(D(e.launcherSize, "layout.launcherSize", E.launcherSize), "layout.launcherSize", 24, 120);
191
+ let i = _(e, "panel", "layout.panel");
192
+ return i && (v(i, ["width", "height"], "layout.panel"), t.panelWidth = O(D(i.width, "layout.panel.width", E.panelWidth), "layout.panel.width", 280, Infinity), t.panelHeight = O(D(i.height, "layout.panel.height", E.panelHeight), "layout.panel.height", 320, Infinity)), k.set(e, t), t;
193
+ }
194
+ //#endregion
195
+ //#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/dist/preact.mjs
196
+ var A, ne, j, re, ie, ae, oe, M, se, ce, le, ue, N = {}, de = [], fe = /^m(i|n|o|s|text|space)$/, pe = Array.isArray, me = de.slice, P = Object.assign;
197
+ function he(e) {
198
+ e && e.parentNode && e.remove();
199
+ }
200
+ function ge(e, t, n, r, i) {
28
201
  var a = {
29
202
  type: e,
30
203
  props: t,
@@ -36,87 +209,87 @@ function T(e, t, n, r, i) {
36
209
  __e: null,
37
210
  __c: null,
38
211
  constructor: void 0,
39
- __v: i ?? ++s,
212
+ __v: i || ++ne,
40
213
  __i: -1,
41
214
  __u: 0
42
215
  };
43
- return i == null && o.vnode != null && o.vnode(a), a;
216
+ return !i && A.vnode && A.vnode(a), a;
44
217
  }
45
- function E(e) {
218
+ function F(e) {
46
219
  return e.children;
47
220
  }
48
- function te(e, t) {
49
- this.props = e, this.context = t;
221
+ function _e(e, t) {
222
+ this.props = e, this.context = t, this.__g = 0;
50
223
  }
51
- function D(e, t) {
52
- if (t == null) return e.__ ? D(e.__, e.__i + 1) : null;
53
- for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
54
- return typeof e.type == "function" ? D(e) : null;
224
+ function I(e, t) {
225
+ if (t == null) return e.__ ? I(e.__, e.__i + 1) : null;
226
+ for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) && n.__e) return n.__e;
227
+ return typeof e.type != "function" || e.props.__P ? null : I(e);
55
228
  }
56
- function O(e) {
57
- if (e.__P && e.__d) {
58
- var t = e.__v, n = t.__e, r = [], i = [], a = C({}, t);
59
- a.__v = t.__v + 1, o.vnode && o.vnode(a), se(e.__P, a, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? D(t), !!(32 & t.__u), i), a.__v = t.__v, a.__.__k[a.__i] = a, le(r, a, i), t.__e = t.__ = null, a.__e != n && k(a);
60
- }
229
+ function ve(e) {
230
+ if ((e = e.__) && e.__c && !e.props.__P) return e.__e = null, e.__k.some(function(t) {
231
+ return t && (e.__e = t.__e);
232
+ }), ve(e);
61
233
  }
62
- function k(e) {
63
- if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) {
64
- if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e;
65
- }), k(e);
234
+ function ye(e) {
235
+ (8 & e.__g || !(e.__g |= 8) || !j.push(e) || ie++) && re == A.debounceRendering || ((re = A.debounceRendering) || queueMicrotask)(be);
66
236
  }
67
- function A(e) {
68
- (!e.__d && (e.__d = !0) && c.push(e) && !j.__r++ || l != o.debounceRendering) && ((l = o.debounceRendering) || u)(j);
69
- }
70
- function j() {
237
+ function be() {
238
+ var e, t, n, r, i, a, o, s, c;
71
239
  try {
72
- for (var e, t = 1; c.length;) c.length > t && c.sort(d), e = c.shift(), t = c.length, O(e);
240
+ for (t = 1; j.length;) j.length > t && j.sort(ae), e = j.shift(), t = j.length, 8 & e.__g && (r = void 0, i = void 0, a = (i = (n = e).__v).__e, o = [], s = [], (c = n.__P) && ((r = P({ constructor: void 0 }, i)).__v = i.__v + 1, A.vnode && A.vnode(r), Oe(c, r, i, n.__n, c.namespaceURI, 32 & i.__u ? [a] : null, o, a || I(i), 32 & i.__u, s), r.__v = i.__v, r.__.__k[r.__i] = r, Ae(o, r, s), i.__ = i.__e = null, r.__e != a && ve(r)));
73
241
  } finally {
74
- c.length = j.__r = 0;
242
+ j.length = ie = 0;
75
243
  }
76
244
  }
77
- function ne(e, t, n, r, i, a, o, s, c, l, u) {
78
- var d, f, p, m, h, g, _ = r && r.__k || b, v = t.length;
79
- for (c = M(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || y, p.__i = d, g = se(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && fe(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = re(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
245
+ function xe(e, t, n, r, i, a, o, s, c, l, u) {
246
+ var d, f, p, m, h, g, _ = r.__k || de, v = t.length;
247
+ for (c = Se(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = ~p.__i && _[p.__i] || N, p.__i = d, g = Oe(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && (f.ref != p.ref || 8 & f.__u) && (f.ref != p.ref && f.ref && Me(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h ||= m, 4 & p.__u ? (c = Ce(p, c, e, !f.__v), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
80
248
  return n.__e = h, c;
81
249
  }
82
- function M(e, t, n, r, i) {
83
- var a, o, s, c, l, u = n.length, d = u, f = 0;
84
- 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] = T(null, o, null, null, null) : S(o) ? o = e.__k[a] = T(E, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = T(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 = ie(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;
85
- if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = D(s)), pe(s, s));
250
+ function Se(e, t, n, r, i) {
251
+ var a, o, s, c, l, u, d, f, p, m, h = n.length, g = h, _ = 0, v = !1, y = e.__k = Array(i);
252
+ for (a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o != "object" || o.constructor == String ? o = y[a] = ge(null, o) : pe(o) ? o = y[a] = ge(F, { children: o }) : o.constructor === void 0 && o.__b ? o = y[a] = ge(o.type, o.props, o.key, o.ref, o.__v) : y[a] = o, c = a + _, o.__ = e, o.__b = e.__b + 1, s = null, ~(l = o.__i = we(o, n, c, g)) && (g--, (s = n[l]) && (s.__u |= 2)), s && s.__v ? (o.__u |= 2, l == c - 1 ? _-- : l == c + 1 ? _++ : l != c && (l > c ? _-- : _++, v = !0)) : (~l || (i > h ? _-- : i < h && _++), typeof o.type != "function" && (o.__u |= 4))) : y[a] = null;
253
+ if (v) {
254
+ for (u = [], d = [], a = 0; a < i; a++) if ((o = y[a]) && 2 & o.__u) {
255
+ for (f = 0, p = u.length; f < p;) u[m = f + p >> 1] < o.__i ? f = m + 1 : p = m;
256
+ u[f] = o.__i, d[a] = f + 1;
257
+ }
258
+ for (_ = u.length; a--;) d[a] && (d[a] == _ ? _-- : y[a].__u |= 4);
259
+ }
260
+ if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r = I(s)), Ne(s, s));
86
261
  return r;
87
262
  }
88
- function re(e, t, n) {
89
- var r, i;
263
+ function Ce(e, t, n, r) {
264
+ var i, a;
90
265
  if (typeof e.type == "function") {
91
- for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t = re(r[i], t, n));
266
+ if (e.props.__P) return t;
267
+ if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t = Ce(i[a], t, n, !1));
92
268
  return t;
93
269
  }
94
- e.__e != t && (t && e.type && !t.parentNode && (t = D(e)), t = n.insertBefore(e.__e, t || null));
95
- do
96
- t &&= t.nextSibling;
97
- while (t != null && t.nodeType == 8);
270
+ for (t && !t.parentNode && (t = I(e)) && !t.parentNode && (t = null), e.__e != t && (!r && n.moveBefore && e.__e.parentNode ? n.moveBefore(e.__e, t) : n.insertBefore(e.__e, t || null)), t = e.__e; (t &&= t.nextSibling) && t.nodeType == 8;);
98
271
  return t;
99
272
  }
100
- function ie(e, t, n, r) {
101
- var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && !(2 & l.__u);
273
+ function we(e, t, n, r) {
274
+ var i, a, o, s = e.key, c = e.type, l = t[n], u = l && !(2 & l.__u);
102
275
  if (l === null && s == null || u && s == l.key && c == l.type) return n;
103
276
  if (r > +!!u) {
104
- for (i = n - 1, a = n + 1; i >= 0 || a < t.length;) if ((l = t[o = i >= 0 ? i-- : a++]) != null && !(2 & l.__u) && s == l.key && c == l.type) return o;
277
+ for (i = n - 1, a = n + 1; i >= 0 || a < t.length;) if ((l = t[o = i >= 0 ? i-- : a++]) && !(2 & l.__u) && s == l.key && c == l.type) return o;
105
278
  }
106
279
  return -1;
107
280
  }
108
- function ae(e, t, n) {
109
- t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || x.test(t) ? n : n + "px";
281
+ function Te(e, t, n) {
282
+ n ??= "", t[0] == "-" ? e.setProperty(t, n) : e[t] = n;
110
283
  }
111
- function N(e, t, n, r, i) {
112
- var a, o;
284
+ function Ee(e, t, n, r, i) {
285
+ var a;
113
286
  n: if (t == "style") {
114
287
  if (typeof n == "string") e.style.cssText = n;
115
288
  else {
116
- if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || ae(e.style, t, "");
117
- if (n) for (t in n) r && n[t] == r[t] || ae(e.style, t, n[t]);
289
+ if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || Te(e.style, t, "");
290
+ if (n) for (t in n) r && n[t] == r[t] || Te(e.style, t, n[t]);
118
291
  }
119
- } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(h, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[m] = r[m] : (n[m] = g, e.addEventListener(t, a ? v : _, a)) : e.removeEventListener(t, a ? v : _, a);
292
+ } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(se, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()), (e.__e ||= {})[t + a] = n, n ? r ? n[M] = r[M] : (n[M] = ce, e.addEventListener(t, a ? ue : le, a)) : e.removeEventListener(t, a ? ue : le, a);
120
293
  else {
121
294
  if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
122
295
  else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
@@ -126,302 +299,326 @@ function N(e, t, n, r, i) {
126
299
  typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
127
300
  }
128
301
  }
129
- function oe(e) {
302
+ function De(e) {
130
303
  return function(t) {
131
- if (this.l) {
132
- var n = this.l[t.type + e];
133
- if (t[p] == null) t[p] = g++;
134
- else if (t[p] < n[m]) return;
135
- return n(o.event ? o.event(t) : t);
304
+ if (this.__e) {
305
+ var n = this.__e[t.type + e];
306
+ if (t[oe] == null) t[oe] = ce++;
307
+ else if (t[oe] < n[M]) return;
308
+ return n(A.event ? A.event(t) : t);
136
309
  }
137
310
  };
138
311
  }
139
- function se(e, t, n, r, i, a, s, c, l, u) {
140
- var d, f, p, m, h, g, _, v, y, x, w, T, O, k, A, j, M = t.type;
312
+ function Oe(e, t, n, r, i, a, o, s, c, l) {
313
+ var u, d, f, p, m, h, g, _, v, y, b, x, S, C, ee, w, T, E, D, O, k = t.type;
141
314
  if (t.constructor !== void 0) return null;
142
- 128 & n.__u && (l = !!(32 & n.__u), a = [c = t.__e = n.__e]), (d = o.__b) && d(t);
143
- n: if (typeof M == "function") {
144
- f = s.length;
315
+ if (128 & n.__u && (c = 32 & n.__u, u = n.__c.__z)) {
316
+ if (t.__u |= c, d = a = [], u.nodeType == 8) for (f = 1, p = u.nextSibling; p; p = p.nextSibling) {
317
+ if (p.nodeType == 8) {
318
+ if (p.data.startsWith("$s")) f++;
319
+ else if (p.data.startsWith("/$s") && !--f) break;
320
+ }
321
+ a.push(p);
322
+ }
323
+ else a.push(u);
324
+ s = a[0];
325
+ }
326
+ (u = A.__b) && u(t);
327
+ n: if (typeof k == "function") {
328
+ m = o.length;
145
329
  try {
146
- if (y = t.props, x = M.prototype && M.prototype.render, w = (d = M.contextType) && r[d.__c], T = d ? w ? w.props.value : d.__ : r, n.__c ? v = (p = t.__c = n.__c).__ = p.__E : (x ? t.__c = p = new M(y, T) : (t.__c = p = new te(y, T), p.constructor = M, p.render = me), w && w.sub(p), p.state || (p.state = {}), p.__n = r, m = p.__d = !0, p.__h = [], p._sb = []), x && p.__s == null && (p.__s = p.state), x && M.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = C({}, p.__s)), C(p.__s, M.getDerivedStateFromProps(y, p.__s))), h = p.props, g = p.state, p.__v = t, m) x && M.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), x && p.componentDidMount != null && p.__h.push(p.componentDidMount);
147
- else {
148
- if (x && M.getDerivedStateFromProps == null && y !== h && p.componentWillReceiveProps != null && p.componentWillReceiveProps(y, T), t.__v == n.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(y, p.__s, T)) {
149
- t.__v != n.__v && (p.props = y, p.state = p.__s, p.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
330
+ if (y = t.props, b = (u = k.prototype) && u.render, x = (u = k.contextType) && r[u.__c], S = u ? x ? x.props.value : u.__ : r, n.__c ? 2 & (h = t.__c = n.__c).__g && (h.__g |= 1) : (b ? t.__c = h = new k(y, S) : (t.__c = h = new _e(y, S), h.constructor = k, h.render = Pe), x && x.sub(h), h.state || (h.state = {}), h.__n = r, h.__g |= 8, h.__h = [], h.__k = []), b && (h.__s || (h.__s = h.state), k.getDerivedStateFromProps && (h.__s == h.state && (h.__s = P({}, h.__s)), P(h.__s, k.getDerivedStateFromProps(y, h.__s)))), g = h.props, _ = h.state, h.__v = t, n.__c) {
331
+ if (b && !k.getDerivedStateFromProps && y !== g && h.componentWillReceiveProps && h.componentWillReceiveProps(y, S), t.__v == n.__v && !(8 & h.__g) || !(4 & h.__g) && h.shouldComponentUpdate && !1 === h.shouldComponentUpdate(y, h.__s, S)) {
332
+ t.__v != n.__v && (h.props = y, h.state = h.__s, h.__g &= -9), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
150
333
  e && (e.__ = t);
151
- }), b.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && s.push(p), c = D(n);
334
+ }), de.push.apply(h.__h, h.__k), h.__k = [], h.__h.length && o.push(h), s = I(n);
152
335
  break n;
153
336
  }
154
- p.componentWillUpdate != null && p.componentWillUpdate(y, p.__s, T), x && p.componentDidUpdate != null && p.__h.push(function() {
155
- p.componentDidUpdate(h, g, _);
337
+ h.componentWillUpdate && h.componentWillUpdate(y, h.__s, S), b && h.componentDidUpdate && h.__h.push(function() {
338
+ h.componentDidUpdate(g, _, v);
156
339
  });
157
- }
158
- if (p.context = T, p.props = y, p.__P = e, p.__e = !1, O = o.__r, k = 0, x) p.state = p.__s, p.__d = !1, O && O(t), d = p.render(p.props, p.state, p.context), b.push.apply(p.__h, p._sb), p._sb = [];
340
+ } else b && !k.getDerivedStateFromProps && h.componentWillMount && h.componentWillMount(), b && h.componentDidMount && h.__h.push(h.componentDidMount);
341
+ if (h.context = S, h.props = y, h.__P = e, h.__g &= -5, C = A.__r, ee = 0, b) h.state = h.__s, h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), de.push.apply(h.__h, h.__k), h.__k = [];
159
342
  else do
160
- p.__d = !1, O && O(t), d = p.render(p.props, p.state, p.context), p.state = p.__s;
161
- while (p.__d && ++k < 25);
162
- p.state = p.__s, p.getChildContext != null && (r = C(C({}, r), p.getChildContext())), x && !m && p.getSnapshotBeforeUpdate != null && (_ = p.getSnapshotBeforeUpdate(h, g)), A = d != null && d.type === E && d.key == null ? ue(d.props.children) : d, c = ne(e, S(A) ? A : [A], t, n, r, i, a, s, c, l, u), p.base = t.__e, t.__u &= -161, p.__h.length && s.push(p), v && (p.__E = p.__ = null);
343
+ h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), h.state = h.__s;
344
+ while (8 & h.__g && ++ee < 25);
345
+ h.state = h.__s, h.getChildContext && (r = P({}, r, h.getChildContext())), b && n.__c && h.getSnapshotBeforeUpdate && (v = h.getSnapshotBeforeUpdate(g, _)), w = u && u.type === F && u.key == null ? u.props.children : u, y.__P && (u = s, i = (e = y.__P).namespaceURI, c = a = null, n.props && n.props.__P != e && (n.__k.some(function(e) {
346
+ e && Ne(e, e);
347
+ }), n.__k = null), s = n.__k ? I(n, 0) : null), s = xe(e, pe(w) ? w : [w], t, n, r, i, a, o, s, c, l), y.__P && (t.__e = null, s = u), t.__u &= -161, 128 & n.__u && (h.__z = null), d && d.some(he), h.__h.length && o.push(h), 1 & h.__g && (h.__g &= -4);
163
348
  } catch (e) {
164
- if (s.length = f, t.__v = null, l || a != null) {
349
+ if (o.length = m, t.__v = null, c || a) {
165
350
  if (e.then) {
166
- for (t.__u |= l ? 160 : 128; c && c.nodeType == 8 && c.nextSibling;) c = c.nextSibling;
167
- a != null && (a[a.indexOf(c)] = null), t.__e = c;
168
- } else if (a != null) for (j = a.length; j--;) ee(a[j]);
351
+ if (T = 0, t.__u |= c ? 160 : 128, a) {
352
+ for (D = 0; D < a.length; D++) if (O = a[D]) {
353
+ if (O.nodeType == 8) {
354
+ if (a[D] = null, O.data.startsWith("$s")) T++ || (E = O);
355
+ else if (O.data.startsWith("/$s") && !--T) {
356
+ s = O;
357
+ break;
358
+ }
359
+ } else T && (a[D] = null);
360
+ }
361
+ }
362
+ if (!E) {
363
+ for (; s && s.nodeType == 8 && s.nextSibling;) s = s.nextSibling;
364
+ a && (a[a.indexOf(s)] = null), E = s;
365
+ }
366
+ t.__c.__z || (t.__c.__z = E), t.__e = s;
367
+ } else a && a.some(he);
169
368
  } else t.__e = n.__e;
170
- t.__k ??= n.__k || [], e.then || ce(t), o.__e(e, t, n);
369
+ t.__k ||= n.__k || [], e.then || ke(t), A.__e(e, t, n);
171
370
  }
172
- } else a == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : c = t.__e = de(n.__e, t, n, r, i, a, s, l, u);
173
- return (d = o.diffed) && d(t), 128 & t.__u ? void 0 : c;
371
+ } else s = t.__e = je(n.__e, t, n, r, i, a, o, c, l, e);
372
+ return (u = A.diffed) && u(t), 128 & t.__u ? void 0 : s;
174
373
  }
175
- function ce(e) {
176
- e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(ce));
374
+ function ke(e) {
375
+ e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(ke));
177
376
  }
178
- function le(e, t, n) {
179
- for (var r = 0; r < n.length; r++) fe(n[r], n[++r], n[++r]);
180
- o.__c && o.__c(t, e), e.some(function(t) {
377
+ function Ae(e, t, n) {
378
+ for (var r = 0; r < n.length;) Me(n[r++], n[r++], n[r++]);
379
+ A.__c && A.__c(t, e), e.some(function(t) {
181
380
  try {
182
381
  e = t.__h, t.__h = [], e.some(function(e) {
183
382
  e.call(t);
184
383
  });
185
384
  } catch (e) {
186
- o.__e(e, t.__v);
385
+ A.__e(e, t.__v);
187
386
  }
188
387
  });
189
388
  }
190
- function ue(e) {
191
- return typeof e != "object" || !e || e.__b > 0 ? e : S(e) ? e.map(ue) : e.constructor === void 0 ? C({}, e) : null;
192
- }
193
- function de(e, t, n, r, i, s, c, l, u) {
194
- var d, f, p, m, h, g, _, v = n.props || y, b = t.props, x = t.type;
195
- if (x == "svg" ? i = "http://www.w3.org/2000/svg" : x == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i ||= "http://www.w3.org/1999/xhtml", s != null) {
196
- for (d = 0; d < s.length; d++) if ((h = s[d]) && "setAttribute" in h == !!x && (x ? h.localName == x : h.nodeType == 3)) {
197
- e = h, s[d] = null;
389
+ function je(e, t, n, r, i, a, o, s, c, l) {
390
+ var u, d, f, p, m, h, g, _, v, y = n.props || N, b = t.props, x = t.type;
391
+ if (x == "svg" ? i = "http://www.w3.org/2000/svg" : x == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i ||= "http://www.w3.org/1999/xhtml", a) {
392
+ for (u = 0; u < a.length; u++) if ((m = a[u]) && (x ? m.localName == x : m.nodeType == 3)) {
393
+ e = m, a[u] = null;
198
394
  break;
199
395
  }
200
396
  }
201
- if (e == null) {
202
- if (x == null) return document.createTextNode(b);
203
- e = document.createElementNS(i, x, b.is && b), l &&= (o.__m && o.__m(t, s), !1), s = null;
204
- }
205
- if (x == null) v === b || l && e.data == b || (e.data = b);
206
- else {
207
- if (s = x == "textarea" && b.defaultValue != null ? null : s && a.call(e.childNodes), !l && s != null) for (v = {}, d = 0; d < e.attributes.length; d++) v[(h = e.attributes[d]).name] = h.value;
208
- for (d in v) h = v[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in b || d == "value" && "defaultValue" in b || d == "checked" && "defaultChecked" in b || N(e, d, null, h, i);
209
- for (d in b) h = b[d], d == "children" ? m = h : d == "dangerouslySetInnerHTML" ? f = h : d == "value" ? g = h : d == "checked" ? _ = h : l && typeof h != "function" || v[d] === h || N(e, d, h, v[d], i);
210
- if (f) l || p && (f.__html == p.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), t.__k = [];
211
- else if (p && (e.innerHTML = ""), ne(t.type == "template" ? e.content : e, S(m) ? m : [m], t, n, r, x == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, c, s ? s[0] : n.__k && D(n, 0), l, u), s != null) for (d = s.length; d--;) ee(s[d]);
212
- l && x != "textarea" || (d = "value", x == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[d] || x == "progress" && !g || x == "option" && g != v[d]) && N(e, d, g, v[d], i), d = "checked", _ != null && _ != e[d] && N(e, d, _, v[d], i));
397
+ if (!e) {
398
+ if (_ = l.ownerDocument || document, !x) return _.createTextNode(b);
399
+ e = _.createElementNS(i, x, b.is && b), s &&= (A.__m && A.__m(t, a), !1), a = null;
213
400
  }
401
+ if (x) {
402
+ if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a && me.call(l.childNodes), !s && a) for (y = {}, u = 0; u < e.attributes.length; u++) y[(m = e.attributes[u]).name] = m.value;
403
+ for (u in y) m = y[u], u == "dangerouslySetInnerHTML" ? f = m : u == "children" || u in b || u == "value" && "defaultValue" in b || u == "checked" && "defaultChecked" in b || Ee(e, u, null, m, i);
404
+ for (u in v = 1 & n.__u, b) m = b[u], u == "children" ? p = m : u == "dangerouslySetInnerHTML" ? d = m : u == "value" ? h = m : u == "checked" ? g = m : s && typeof m != "function" || !(y[u] !== m || v && m != null) || Ee(e, u, m, y[u], i);
405
+ d ? (s || f && (d.__html == f.__html || d.__html == e.innerHTML) || (e.innerHTML = d.__html), t.__k = []) : (f && (e.textContent = ""), (x == "foreignObject" || i == "http://www.w3.org/1998/Math/MathML" && fe.test(x)) && (i = "http://www.w3.org/1999/xhtml"), xe(l, pe(p) ? p : [p], t, n, r, i, a, o, a ? a[0] : n.__k && I(n, 0), s, c), a && a.some(he)), s && x != "textarea" || (u = "value", x == "progress" && h == null ? e.removeAttribute(u) : h == null || h === e[u] && (x != "progress" || h) || Ee(e, u, h, y[u], i), u = "checked", g != null && g != e[u] && Ee(e, u, g, y[u], i));
406
+ } else y === b || s && e.data == b || (e.data = b);
214
407
  return e;
215
408
  }
216
- function fe(e, t, n) {
409
+ function Me(e, t, n) {
217
410
  try {
218
- if (typeof e == "function") {
219
- var r = typeof e.__u == "function";
220
- r && e.__u(), r && t == null || (e.__u = e(t));
221
- } else e.current = t;
411
+ typeof e == "function" ? (typeof e.__u == "function" && e.__u(), (typeof e.__u != "function" || t) && (e.__u = e(t))) : e.current = t;
222
412
  } catch (e) {
223
- o.__e(e, n);
413
+ A.__e(e, n);
224
414
  }
225
415
  }
226
- function pe(e, t, n) {
416
+ function Ne(e, t, n) {
227
417
  var r, i;
228
- if (o.unmount && o.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || fe(r, null, t)), (r = e.__c) != null) {
418
+ if (A.unmount && A.unmount(e), !(r = e.ref) || r.current && r.current != e.__e || Me(r, null, t), r = e.__c) {
229
419
  if (r.componentWillUnmount) try {
230
420
  r.componentWillUnmount();
231
421
  } catch (e) {
232
- o.__e(e, t);
422
+ A.__e(e, t);
233
423
  }
234
- r.base = r.__P = r.__n = null;
424
+ r.__P = r.__n = null;
235
425
  }
236
- if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && pe(r[i], t, n || typeof e.type != "function");
237
- n || ee(e.__e), e.__c = e.__ = e.__e = void 0;
426
+ if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && Ne(r[i], t, typeof e.type != "function" || n && !e.props.__P);
427
+ (r = e.__e) && (n || he(r), r.__e && (r.__e = null)), e.__e = e.__c = e.__ = null;
238
428
  }
239
- function me(e, t, n) {
429
+ function Pe(e, t, n) {
240
430
  return this.constructor(e, n);
241
431
  }
242
- function he(e, t, n) {
243
- var r, i, s, c;
244
- t == document && (t = document.documentElement), o.__ && o.__(e, t), i = (r = typeof n == "function") ? null : n && n.__k || t.__k, s = [], c = [], se(t, e = (!r && n || t).__k = w(E, null, [e]), i || y, y, t.namespaceURI, !r && n ? [n] : i ? null : t.firstChild ? a.call(t.childNodes) : null, s, !r && n ? n : i ? i.__e : t.firstChild, r, c), le(s, e, c), e.props.children = null;
432
+ function Fe(e, t) {
433
+ var n, r, i, a;
434
+ A.__ && A.__(e, t), t.nodeType == 9 && (t = t.documentElement), r = (n = e && 32 & e.__u) ? null : t.__k, t.__k = ge(F, { children: [e] }), i = [], a = [], Oe(t, t.__k, r || N, N, t.namespaceURI, r ? null : t.firstChild ? me.call(t.childNodes) : null, i, r ? r.__e : t.firstChild, n, a), Ae(i, t.__k, a), t.__k.props.children = null;
245
435
  }
246
- a = b.slice, o = { __e: function(e, t, n, r) {
247
- for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
248
- if ((a = i.constructor) && a.getDerivedStateFromError != null && (i.setState(a.getDerivedStateFromError(e)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, r || {}), o = i.__d), o) return i.__E = i;
249
- } catch (t) {
250
- e = t;
436
+ A = { __e: function(e, t, n, r) {
437
+ for (var i, a, o; t = t.__;) if ((i = t.__c) && !(1 & i.__g)) {
438
+ i.__g |= 4;
439
+ try {
440
+ if ((a = i.constructor) && a.getDerivedStateFromError && (i.setState(a.getDerivedStateFromError(e)), o = 8 & i.__g), i.componentDidCatch && (i.componentDidCatch(e, r || {}), o = 8 & i.__g), o) return void (i.__g |= 2);
441
+ } catch (t) {
442
+ e = t, o = 0;
443
+ }
251
444
  }
252
- throw e;
253
- } }, s = 0, te.prototype.setState = function(e, t) {
254
- var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = C({}, this.state);
255
- typeof e == "function" && (e = e(C({}, n), this.props)), e && C(n, e), e != null && this.__v && (t && this._sb.push(t), A(this));
256
- }, te.prototype.forceUpdate = function(e) {
257
- this.__v && (this.__e = !0, e && this.__h.push(e), A(this));
258
- }, te.prototype.render = E, c = [], u = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, d = function(e, t) {
445
+ throw ie = 0, e;
446
+ } }, ne = 0, _e.prototype.setState = function(e, t) {
447
+ var n = this.__s;
448
+ n && n != this.state || (n = this.__s = P({}, this.state)), typeof e == "function" && (e = e(P({}, n), this.props)), e && (P(n, e), this.__v && (t && this.__k.push(t), ye(this)));
449
+ }, _e.prototype.forceUpdate = function(e) {
450
+ this.__v && (this.__g |= 4, e && this.__h.push(e), ye(this));
451
+ }, _e.prototype.render = F, j = [], ie = 0, ae = function(e, t) {
259
452
  return e.__v.__b - t.__v.__b;
260
- }, j.__r = 0, f = Math.random().toString(8), p = "__d" + f, m = "__a" + f, h = /(PointerCapture)$|Capture$/i, g = 0, _ = oe(!1), v = oe(!0);
453
+ }, oe = Symbol(), M = Symbol(), se = /(PointerCapture)$|Capture$/i, ce = 0, le = De(!1), ue = De(!0);
261
454
  //#endregion
262
- //#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/hooks/dist/hooks.module.js
263
- var P, F, ge, _e, I = 0, ve = [], L = o, ye = L.__b, be = L.__r, xe = L.diffed, Se = L.__c, Ce = L.unmount, we = L.__;
264
- function Te(e, t) {
265
- L.__h && L.__h(F, e, I || t), I = 0;
266
- var n = F.__H || (F.__H = {
455
+ //#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/hooks/dist/hooks.mjs
456
+ var L, R, Ie, Le, Re = Object.is, z = 0, ze = [], Be = [], B = A, Ve = B.__b, He = B.__r, Ue = B.diffed, We = B.__c, Ge = B.unmount, Ke = B.__;
457
+ function qe(e, t) {
458
+ B.__h && B.__h(R, e, z || t), z = 0;
459
+ var n = R.__H || (R.__H = {
267
460
  __: [],
268
461
  __h: []
269
462
  });
270
463
  return e >= n.__.length && n.__.push({}), n.__[e];
271
464
  }
272
- function Ee(e) {
273
- return I = 1, De(Pe, e);
465
+ function V(e) {
466
+ return z = 1, Je(nt, e);
274
467
  }
275
- function De(e, t, n) {
276
- var r = Te(P++, 2);
277
- if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Pe(void 0, t), function(e) {
468
+ function Je(e, t, n) {
469
+ var r = qe(L++, 2);
470
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : nt(void 0, t), function(e) {
278
471
  var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
279
- t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
280
- }], r.__c = F, !F.__f)) {
281
- var i = function(e, t, n) {
282
- if (!r.__c.__H) return !0;
283
- var i = !1, o = r.__c.props !== e;
284
- if (r.__c.__H.__.some(function(e) {
285
- if (e.__N) {
286
- i = !0;
287
- var t = e.__[0];
288
- e.__ = e.__N, e.__N = void 0, t !== e.__[0] && (o = !0);
289
- }
290
- }), a) {
291
- var s = a.call(this, e, t, n);
292
- return i ? s || o : s;
472
+ Re(t, n) || (r.__N = [n, r.__[1]], r.__c.setState({}));
473
+ }], r.__c = R, !R.__f)) {
474
+ R.__f = !0;
475
+ var i = R.shouldComponentUpdate;
476
+ R.shouldComponentUpdate = function(e, t, n) {
477
+ var r = this.__H;
478
+ if (!r) return !0;
479
+ var a = !1, o = this.props != e;
480
+ if (r.__.some(function(e) {
481
+ e.__N && (a = !0, Re(e.__[0], e.__N[0]) || (o = !0));
482
+ }), i) {
483
+ var s = i.call(this, e, t, n);
484
+ return a ? s || o : s;
293
485
  }
294
- return !i || o;
486
+ return !a || o;
295
487
  };
296
- F.__f = !0;
297
- var a = F.shouldComponentUpdate, o = F.componentWillUpdate;
298
- F.componentWillUpdate = function(e, t, n) {
299
- if (this.__e) {
300
- var r = a;
301
- a = void 0, i(e, t, n), a = r;
302
- }
303
- o && o.call(this, e, t, n);
304
- }, F.shouldComponentUpdate = i;
305
488
  }
306
- return r.__N || r.__;
489
+ return r.__;
307
490
  }
308
- function R(e, t) {
309
- var n = Te(P++, 3);
310
- !L.__s && Ne(n.__H, t) && (n.__ = e, n.u = t, F.__H.__h.push(n));
491
+ function H(e, t) {
492
+ var n = qe(L++, 3);
493
+ !B.__s && tt(n.__H, t) && (n.__P = !0, n.__ = e, n.u = t, R.__H.__h.push(n));
311
494
  }
312
- function z(e) {
313
- return I = 5, Oe(function() {
495
+ function U(e) {
496
+ return z = 5, Ye(function() {
314
497
  return { current: e };
315
498
  }, []);
316
499
  }
317
- function Oe(e, t) {
318
- var n = Te(P++, 7);
319
- return Ne(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
320
- }
321
- function ke() {
322
- for (var e; e = ve.shift();) {
323
- var t = e.__H;
324
- if (e.__P && t) try {
325
- t.__h.some(B), t.__h.some(Me), t.__h = [];
326
- } catch (n) {
327
- t.__h = [], L.__e(n, e.__v);
500
+ function Ye(e, t) {
501
+ var n = qe(L++, 7);
502
+ return tt(n.__H, t) && (n.__ = e(), n.__H = t), n.__;
503
+ }
504
+ function Xe() {
505
+ var e;
506
+ do {
507
+ for (; e = Be.shift();) try {
508
+ W(e);
509
+ } catch (t) {
510
+ B.__e(t, { __: (e = e.__P) && e.__v });
328
511
  }
329
- }
330
- }
331
- L.__b = function(e) {
332
- F = null, ye && ye(e);
333
- }, L.__ = function(e, t) {
334
- e && t.__k && t.__k.__m && (e.__m = t.__k.__m), we && we(e, t);
335
- }, L.__r = function(e) {
336
- be && be(e), P = 0;
337
- var t = (F = e.__c).__H;
338
- t && (ge === F ? (t.__h = [], F.__h = [], t.__.some(function(e) {
512
+ for (; e = ze.shift();) {
513
+ var t = e.__H;
514
+ if (e.__P && t) try {
515
+ t.__h.some(W), t.__h.some(et), t.__h = [];
516
+ } catch (n) {
517
+ t.__h = [], B.__e(n, e.__v);
518
+ }
519
+ }
520
+ } while (Be.length);
521
+ }
522
+ B.__b = function(e) {
523
+ R = null, Ve && Ve(e);
524
+ }, B.__ = function(e, t) {
525
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Ke && Ke(e, t);
526
+ }, B.__r = function(e) {
527
+ He && He(e), L = 0;
528
+ var t = (R = e.__c).__H;
529
+ t && (Ie == R ? R.__h = [] : (t.__h.some(W), t.__h.some(et), L = 0), t.__h = [], t.__.some(function(e) {
339
530
  e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
340
- })) : (t.__h.some(B), t.__h.some(Me), t.__h = [], P = 0)), ge = F;
341
- }, L.diffed = function(e) {
342
- xe && xe(e);
531
+ })), Ie = R;
532
+ }, B.diffed = function(e) {
533
+ Ue && Ue(e);
343
534
  var t = e.__c;
344
- t && t.__H && (t.__H.__h.length && (ve.push(t) !== 1 && _e === L.requestAnimationFrame || ((_e = L.requestAnimationFrame) || je)(ke)), t.__H.__.some(function(e) {
345
- e.u &&= (e.__H = e.u, void 0);
346
- })), ge = F = null;
347
- }, L.__c = function(e, t) {
535
+ t && t.__H && (t.__H.__h.length && $e(ze.push(t)), t.__H.__.some(function(e) {
536
+ e.u && (e.__H = e.u);
537
+ })), Ie = R = null;
538
+ }, B.__c = function(e, t) {
348
539
  t.some(function(e) {
349
540
  try {
350
- e.__h.some(B), e.__h = e.__h.filter(function(e) {
351
- return !e.__ || Me(e);
541
+ e.__h.some(W), e.__h = e.__h.filter(function(e) {
542
+ return !e.__ || et(e);
352
543
  });
353
544
  } catch (n) {
354
545
  t.some(function(e) {
355
546
  e.__h &&= [];
356
- }), t = [], L.__e(n, e.__v);
547
+ }), t = [], B.__e(n, e.__v);
357
548
  }
358
- }), Se && Se(e, t);
359
- }, L.unmount = function(e) {
360
- Ce && Ce(e);
361
- var t, n = e.__c;
362
- n && n.__H && (n.__H.__.some(function(e) {
549
+ }), We && We(e, t);
550
+ }, B.unmount = function(e) {
551
+ Ge && Ge(e);
552
+ var t, n, r = e.__c;
553
+ r && r.__H && (r.__H.__.some(function(r) {
363
554
  try {
364
- B(e);
555
+ if (r.__P && r.__c) {
556
+ if (n === void 0) {
557
+ for (n = e.__; n && (!n.__c || !n.__c.__P);) n = n.__;
558
+ n &&= n.__c;
559
+ }
560
+ r.__P = n, $e(Be.push(r));
561
+ } else W(r);
365
562
  } catch (e) {
366
563
  t = e;
367
564
  }
368
- }), n.__H = void 0, t && L.__e(t, n.__v));
565
+ }), r.__H = void 0, t && B.__e(t, r.__v));
369
566
  };
370
- var Ae = typeof requestAnimationFrame == "function";
371
- function je(e) {
567
+ var Ze = typeof requestAnimationFrame == "function";
568
+ function Qe(e) {
372
569
  var t, n = function() {
373
- clearTimeout(r), Ae && cancelAnimationFrame(t), setTimeout(e);
570
+ clearTimeout(r), Ze && cancelAnimationFrame(t), setTimeout(e);
374
571
  }, r = setTimeout(n, 35);
375
- Ae && (t = requestAnimationFrame(n));
572
+ Ze && (t = requestAnimationFrame(n));
376
573
  }
377
- function B(e) {
378
- var t = F, n = e.__c;
379
- typeof n == "function" && (e.__c = void 0, n()), F = t;
574
+ function $e(e) {
575
+ e != 1 && Le == B.requestAnimationFrame || ((Le = B.requestAnimationFrame) || Qe)(Xe);
380
576
  }
381
- function Me(e) {
382
- var t = F;
383
- e.__c = e.__(), F = t;
577
+ function W(e) {
578
+ var t = R, n = e.__c;
579
+ typeof n == "function" && (e.__c = void 0, n()), R = t;
384
580
  }
385
- function Ne(e, t) {
386
- return !e || e.length !== t.length || t.some(function(t, n) {
387
- return t !== e[n];
581
+ function et(e) {
582
+ var t = R;
583
+ e.__c = e.__(), R = t;
584
+ }
585
+ function tt(e, t) {
586
+ return !e || e.length != t.length || t.some(function(t, n) {
587
+ return !Re(t, e[n]);
388
588
  });
389
589
  }
390
- function Pe(e, t) {
590
+ function nt(e, t) {
391
591
  return typeof t == "function" ? t(e) : t;
392
592
  }
393
593
  //#endregion
394
- //#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
395
- var Fe = 0;
594
+ //#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
595
+ var rt = 0;
396
596
  Array.isArray;
397
- function V(e, t, n, r, i, a) {
597
+ function G(e, t, n, r, i, a) {
398
598
  t ||= {};
399
- var s, c, l = t;
400
- if ("ref" in l) for (c in l = {}, t) c == "ref" ? s = t[c] : l[c] = t[c];
401
- var u = {
599
+ var o, s, c = t;
600
+ if ("ref" in c && typeof e != "function") for (s in c = {}, t) s == "ref" ? o = t[s] : c[s] = t[s];
601
+ var l = {
402
602
  type: e,
403
- props: l,
603
+ props: c,
404
604
  key: n,
405
- ref: s,
605
+ ref: o,
406
606
  __k: null,
407
607
  __: null,
408
608
  __b: 0,
409
609
  __e: null,
410
610
  __c: null,
411
611
  constructor: void 0,
412
- __v: --Fe,
612
+ __v: --rt,
413
613
  __i: -1,
414
- __u: 0,
415
- __source: i,
416
- __self: a
614
+ __u: 0
417
615
  };
418
- if (typeof e == "function" && (s = e.defaultProps)) for (c in s) l[c] === void 0 && (l[c] = s[c]);
419
- return o.vnode && o.vnode(u), u;
616
+ return (i || a) && (l.__source = i, l.__self = a), A.vnode && A.vnode(l), l;
420
617
  }
421
618
  //#endregion
422
619
  //#region src/components/icons.tsx
423
- function H({ name: e, size: t, children: n }) {
424
- return /* @__PURE__ */ V("svg", {
620
+ function K({ name: e, size: t, children: n }) {
621
+ return /* @__PURE__ */ G("svg", {
425
622
  "data-icon": e,
426
623
  "aria-hidden": "true",
427
624
  focusable: "false",
@@ -436,81 +633,115 @@ function H({ name: e, size: t, children: n }) {
436
633
  children: n
437
634
  });
438
635
  }
439
- function Ie({ size: e = 26 }) {
440
- return /* @__PURE__ */ V(H, {
636
+ function it({ size: e = 26 }) {
637
+ return /* @__PURE__ */ G(K, {
441
638
  name: "chat",
442
639
  size: e,
443
- children: [/* @__PURE__ */ V("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__ */ V("path", {
640
+ children: [/* @__PURE__ */ G("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__ */ G("path", {
444
641
  d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
445
642
  "stroke-width": "2.5"
446
643
  })]
447
644
  });
448
645
  }
449
- function Le({ size: e = 26 }) {
450
- return /* @__PURE__ */ V(H, {
646
+ function at({ size: e = 26 }) {
647
+ return /* @__PURE__ */ G(K, {
648
+ name: "message",
649
+ size: e,
650
+ children: /* @__PURE__ */ G("path", { d: "M21 11.5a8.5 8.5 0 0 1-12.4 7.5L3 20.5l1.6-5.1A8.5 8.5 0 1 1 21 11.5z" })
651
+ });
652
+ }
653
+ function ot({ size: e = 26 }) {
654
+ return /* @__PURE__ */ G(K, {
655
+ name: "sparkle",
656
+ size: e,
657
+ children: [/* @__PURE__ */ G("path", { d: "M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z" }), /* @__PURE__ */ G("path", { d: "M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z" })]
658
+ });
659
+ }
660
+ function st({ size: e = 26 }) {
661
+ return /* @__PURE__ */ G(K, {
451
662
  name: "chevron-down",
452
663
  size: e,
453
- children: /* @__PURE__ */ V("path", { d: "M6 9l6 6 6-6" })
664
+ children: /* @__PURE__ */ G("path", { d: "M6 9l6 6 6-6" })
454
665
  });
455
666
  }
456
- function Re({ size: e = 18 }) {
457
- return /* @__PURE__ */ V(H, {
667
+ function ct({ size: e = 18 }) {
668
+ return /* @__PURE__ */ G(K, {
458
669
  name: "close",
459
670
  size: e,
460
- children: /* @__PURE__ */ V("path", { d: "M6 6l12 12M18 6L6 18" })
671
+ children: /* @__PURE__ */ G("path", { d: "M6 6l12 12M18 6L6 18" })
461
672
  });
462
673
  }
463
- var ze = "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";
464
- function Be({ size: e = 16 }) {
465
- return /* @__PURE__ */ V(H, {
674
+ var lt = "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";
675
+ function ut({ size: e = 16 }) {
676
+ return /* @__PURE__ */ G(K, {
466
677
  name: "thumb-up",
467
678
  size: e,
468
- children: /* @__PURE__ */ V("path", { d: ze })
679
+ children: /* @__PURE__ */ G("path", { d: lt })
469
680
  });
470
681
  }
471
- function Ve({ size: e = 16 }) {
472
- return /* @__PURE__ */ V(H, {
682
+ function dt({ size: e = 16 }) {
683
+ return /* @__PURE__ */ G(K, {
473
684
  name: "thumb-down",
474
685
  size: e,
475
- children: /* @__PURE__ */ V("path", {
476
- d: ze,
686
+ children: /* @__PURE__ */ G("path", {
687
+ d: lt,
477
688
  transform: "matrix(1 0 0 -1 0 24)"
478
689
  })
479
690
  });
480
691
  }
481
692
  //#endregion
482
693
  //#region src/components/Launcher.tsx
483
- function He({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
484
- let [i, a] = Ee("loading"), o = n !== void 0 && i !== "failed", s = o && !e && i === "loaded";
485
- return /* @__PURE__ */ V("button", {
694
+ var ft = {
695
+ chat: it,
696
+ message: at,
697
+ sparkle: ot
698
+ }, pt = {
699
+ "chevron-down": st,
700
+ close: ct
701
+ };
702
+ function mt({ isOpen: e, onClick: t, iconUrl: n, icon: r = "chat", openIconUrl: i, openIcon: a = "chevron-down", buttonRef: o }) {
703
+ let [s, c] = V("loading"), [l, u] = V("loading"), d = n !== void 0 && s !== "failed", f = i !== void 0 && l !== "failed", p = d && !e && s === "loaded", m = f && e && l === "loaded", h = ft[r] ?? it, g = pt[a] ?? st;
704
+ return /* @__PURE__ */ G("button", {
486
705
  type: "button",
487
706
  class: "whoo-widget-launcher",
488
707
  onClick: t,
489
708
  "aria-label": e ? "Close chat" : "Open chat",
490
- ref: r,
491
- children: [e ? /* @__PURE__ */ V(Le, {}) : s ? null : /* @__PURE__ */ V(Ie, {}), o ? /* @__PURE__ */ V("img", {
492
- class: "whoo-widget-launcher-icon-image",
493
- src: n,
494
- alt: "",
495
- referrerpolicy: "no-referrer",
496
- hidden: !s,
497
- onLoad: () => a("loaded"),
498
- onError: () => a("failed")
499
- }) : null]
709
+ ref: o,
710
+ children: [
711
+ e ? m ? null : /* @__PURE__ */ G(g, {}) : p ? null : /* @__PURE__ */ G(h, {}),
712
+ d ? /* @__PURE__ */ G("img", {
713
+ class: "whoo-widget-launcher-icon-image",
714
+ src: n,
715
+ alt: "",
716
+ referrerpolicy: "no-referrer",
717
+ hidden: !p,
718
+ onLoad: () => c("loaded"),
719
+ onError: () => c("failed")
720
+ }) : null,
721
+ f ? /* @__PURE__ */ G("img", {
722
+ class: "whoo-widget-launcher-icon-image",
723
+ src: i,
724
+ alt: "",
725
+ referrerpolicy: "no-referrer",
726
+ hidden: !m,
727
+ onLoad: () => u("loaded"),
728
+ onError: () => u("failed")
729
+ }) : null
730
+ ]
500
731
  });
501
732
  }
502
733
  //#endregion
503
734
  //#region src/components/Composer.tsx
504
- function Ue({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
505
- return /* @__PURE__ */ V("div", {
735
+ function ht({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
736
+ return /* @__PURE__ */ G("div", {
506
737
  class: "whoo-widget-composer",
507
738
  children: [
508
- /* @__PURE__ */ V("label", {
739
+ /* @__PURE__ */ G("label", {
509
740
  class: "whoo-widget-sr-only",
510
741
  for: "whoo-widget-composer-input",
511
742
  children: "Message"
512
743
  }),
513
- /* @__PURE__ */ V("input", {
744
+ /* @__PURE__ */ G("input", {
514
745
  id: "whoo-widget-composer-input",
515
746
  class: "whoo-widget-composer-input",
516
747
  value: e,
@@ -522,7 +753,7 @@ function Ue({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
522
753
  e.key === "Enter" && n();
523
754
  }
524
755
  }),
525
- /* @__PURE__ */ V("button", {
756
+ /* @__PURE__ */ G("button", {
526
757
  type: "button",
527
758
  class: "whoo-widget-composer-send",
528
759
  "aria-disabled": r,
@@ -536,8 +767,8 @@ function Ue({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
536
767
  }
537
768
  //#endregion
538
769
  //#region src/components/ErrorBanner.tsx
539
- function We({ message: e }) {
540
- return /* @__PURE__ */ V("div", {
770
+ function gt({ message: e }) {
771
+ return /* @__PURE__ */ G("div", {
541
772
  class: "whoo-widget-error-banner",
542
773
  role: "alert",
543
774
  children: e
@@ -545,8 +776,8 @@ function We({ message: e }) {
545
776
  }
546
777
  //#endregion
547
778
  //#region src/markdown/tokenizer.ts
548
- var U = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, W = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, G = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, K = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, q = /[ \t]*[*+-][ \t]+/y, Ge = /https?:\/\/\S+/y, Ke = /[.,;:!?)\]}>]+$/;
549
- function J(e) {
779
+ var _t = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, vt = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, yt = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, bt = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, xt = /[ \t]*[*+-][ \t]+/y, St = /https?:\/\/\S+/y, Ct = /[.,;:!?)\]}>]+$/;
780
+ function wt(e) {
550
781
  let t = [], n = 0, r = 0, i = (n) => {
551
782
  n > r && t.push({
552
783
  type: "text",
@@ -556,13 +787,13 @@ function J(e) {
556
787
  });
557
788
  };
558
789
  for (; n < e.length;) {
559
- if ((n === 0 || e[n - 1] === "\n") && (q.lastIndex = n, q.exec(e))) {
790
+ if ((n === 0 || e[n - 1] === "\n") && (xt.lastIndex = n, xt.exec(e))) {
560
791
  i(n), t.push({
561
792
  type: "text",
562
793
  value: "• ",
563
794
  start: n,
564
- end: q.lastIndex
565
- }), n = q.lastIndex, r = n;
795
+ end: xt.lastIndex
796
+ }), n = xt.lastIndex, r = n;
566
797
  continue;
567
798
  }
568
799
  if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
@@ -575,56 +806,56 @@ function J(e) {
575
806
  }
576
807
  }
577
808
  if (e[n - 1] !== "!") {
578
- U.lastIndex = n;
579
- let a = U.exec(e);
809
+ _t.lastIndex = n;
810
+ let a = _t.exec(e);
580
811
  if (a) {
581
812
  i(n), t.push({
582
813
  type: "link",
583
814
  text: a[1],
584
815
  url: a[2],
585
816
  start: n,
586
- end: U.lastIndex
587
- }), n = U.lastIndex, r = n;
817
+ end: _t.lastIndex
818
+ }), n = _t.lastIndex, r = n;
588
819
  continue;
589
820
  }
590
821
  }
591
- W.lastIndex = n;
592
- let a = W.exec(e);
822
+ vt.lastIndex = n;
823
+ let a = vt.exec(e);
593
824
  if (a) {
594
825
  i(n), t.push({
595
826
  type: "bold",
596
827
  value: a[1],
597
828
  start: n,
598
- end: W.lastIndex
599
- }), n = W.lastIndex, r = n;
829
+ end: vt.lastIndex
830
+ }), n = vt.lastIndex, r = n;
600
831
  continue;
601
832
  }
602
- G.lastIndex = n;
603
- let o = G.exec(e);
833
+ yt.lastIndex = n;
834
+ let o = yt.exec(e);
604
835
  if (o) {
605
836
  i(n), t.push({
606
837
  type: "italic",
607
838
  value: o[1],
608
839
  start: n,
609
- end: G.lastIndex
610
- }), n = G.lastIndex, r = n;
840
+ end: yt.lastIndex
841
+ }), n = yt.lastIndex, r = n;
611
842
  continue;
612
843
  }
613
- K.lastIndex = n;
614
- let s = K.exec(e);
844
+ bt.lastIndex = n;
845
+ let s = bt.exec(e);
615
846
  if (s) {
616
847
  i(n), t.push({
617
848
  type: "italic",
618
849
  value: s[1],
619
850
  start: n,
620
- end: K.lastIndex
621
- }), n = K.lastIndex, r = n;
851
+ end: bt.lastIndex
852
+ }), n = bt.lastIndex, r = n;
622
853
  continue;
623
854
  }
624
- Ge.lastIndex = n;
625
- let c = Ge.exec(e);
855
+ St.lastIndex = n;
856
+ let c = St.exec(e);
626
857
  if (c) {
627
- let e = c[0].match(Ke), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
858
+ let e = c[0].match(Ct), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
628
859
  if (a.length > 0) {
629
860
  i(n), t.push({
630
861
  type: "link",
@@ -642,8 +873,8 @@ function J(e) {
642
873
  }
643
874
  //#endregion
644
875
  //#region src/markdown/render.tsx
645
- var qe = /^[ \t]*[*+-][ \t]+(.*)$/;
646
- function Je(e) {
876
+ var Tt = /^[ \t]*[*+-][ \t]+(.*)$/;
877
+ function Et(e) {
647
878
  let t = [], n = [], r = [], i = () => {
648
879
  n.length > 0 && t.push({
649
880
  type: "text",
@@ -656,7 +887,7 @@ function Je(e) {
656
887
  }), r = [];
657
888
  };
658
889
  for (let t of e.split("\n")) {
659
- let e = t.match(qe);
890
+ let e = t.match(Tt);
660
891
  e ? (i(), r.push(e[1])) : (a(), n.push(t));
661
892
  }
662
893
  return i(), a(), t.some((e) => e.type === "list") ? t.flatMap((e, n) => {
@@ -668,16 +899,16 @@ function Je(e) {
668
899
  }];
669
900
  }) : null;
670
901
  }
671
- function Y(e) {
672
- return J(e).map((e, t) => {
902
+ function q(e) {
903
+ return wt(e).map((e, t) => {
673
904
  switch (e.type) {
674
- case "bold": return /* @__PURE__ */ V("strong", { children: Y(e.value) }, t);
675
- case "italic": return /* @__PURE__ */ V("em", { children: Y(e.value) }, t);
676
- case "link": return /* @__PURE__ */ V("a", {
905
+ case "bold": return /* @__PURE__ */ G("strong", { children: q(e.value) }, t);
906
+ case "italic": return /* @__PURE__ */ G("em", { children: q(e.value) }, t);
907
+ case "link": return /* @__PURE__ */ G("a", {
677
908
  href: e.url,
678
909
  target: "_blank",
679
910
  rel: "noopener noreferrer",
680
- children: [e.text, /* @__PURE__ */ V("span", {
911
+ children: [e.text, /* @__PURE__ */ G("span", {
681
912
  class: "whoo-widget-sr-only",
682
913
  children: " (opens in new tab)"
683
914
  })]
@@ -686,16 +917,16 @@ function Y(e) {
686
917
  }
687
918
  });
688
919
  }
689
- function Ye(e) {
690
- let t = e.replace(/\r\n?/g, "\n"), n = Je(t);
691
- return n ? n.map((e, t) => e.type === "list" ? /* @__PURE__ */ V("ul", {
920
+ function Dt(e) {
921
+ let t = e.replace(/\r\n?/g, "\n"), n = Et(t);
922
+ return n ? n.map((e, t) => e.type === "list" ? /* @__PURE__ */ G("ul", {
692
923
  class: "whoo-widget-list",
693
- children: e.items.map((e, t) => /* @__PURE__ */ V("li", { children: Y(e) }, t))
694
- }, t) : /* @__PURE__ */ V("span", { children: Y(e.text) }, t)) : Y(t);
924
+ children: e.items.map((e, t) => /* @__PURE__ */ G("li", { children: q(e) }, t))
925
+ }, t) : /* @__PURE__ */ G("span", { children: q(e.text) }, t)) : q(t);
695
926
  }
696
927
  //#endregion
697
928
  //#region src/components/MessageFeedback.tsx
698
- var Xe = [
929
+ var Ot = [
699
930
  {
700
931
  value: "",
701
932
  label: "Select a reason (optional)"
@@ -717,45 +948,45 @@ var Xe = [
717
948
  label: "Other"
718
949
  }
719
950
  ];
720
- function Ze({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraftChange: i, onSubmitDetailed: a, onCancel: o }) {
721
- let s = e.correction ?? "", c = e.category ?? "", l = z(e.status);
722
- if (R(() => {
951
+ function kt({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraftChange: i, onSubmitDetailed: a, onCancel: o }) {
952
+ let s = e.correction ?? "", c = e.category ?? "", l = U(e.status);
953
+ if (H(() => {
723
954
  let n = l.current;
724
955
  if (l.current = e.status, n === e.status) return;
725
956
  let r = t?.current;
726
957
  if (!r) return;
727
958
  let i = r.getRootNode();
728
959
  r.contains(i.activeElement) || r.focus();
729
- }, [e.status, t]), e.status === "expanded") return /* @__PURE__ */ V("div", {
960
+ }, [e.status, t]), e.status === "expanded") return /* @__PURE__ */ G("div", {
730
961
  class: "whoo-widget-feedback-form",
731
962
  children: [
732
- /* @__PURE__ */ V("label", { children: [/* @__PURE__ */ V("span", {
963
+ /* @__PURE__ */ G("label", { children: [/* @__PURE__ */ G("span", {
733
964
  class: "whoo-widget-sr-only",
734
965
  children: "Additional feedback"
735
- }), /* @__PURE__ */ V("textarea", {
966
+ }), /* @__PURE__ */ G("textarea", {
736
967
  class: "whoo-widget-feedback-textarea",
737
968
  value: s,
738
969
  onInput: (e) => i(e.target.value, c),
739
970
  placeholder: "What was wrong? (optional)"
740
971
  })] }),
741
- /* @__PURE__ */ V("select", {
972
+ /* @__PURE__ */ G("select", {
742
973
  class: "whoo-widget-feedback-select",
743
974
  "aria-label": "Feedback category",
744
975
  value: c,
745
976
  onChange: (e) => i(s, e.target.value),
746
- children: Xe.map((e) => /* @__PURE__ */ V("option", {
977
+ children: Ot.map((e) => /* @__PURE__ */ G("option", {
747
978
  value: e.value,
748
979
  children: e.label
749
980
  }, e.value))
750
981
  }),
751
- /* @__PURE__ */ V("div", {
982
+ /* @__PURE__ */ G("div", {
752
983
  class: "whoo-widget-feedback-form-buttons",
753
- children: [/* @__PURE__ */ V("button", {
984
+ children: [/* @__PURE__ */ G("button", {
754
985
  type: "button",
755
986
  class: "whoo-widget-feedback-submit",
756
987
  onClick: () => a(s, c),
757
988
  children: "Submit"
758
- }), /* @__PURE__ */ V("button", {
989
+ }), /* @__PURE__ */ G("button", {
759
990
  type: "button",
760
991
  class: "whoo-widget-feedback-cancel",
761
992
  onClick: o,
@@ -765,24 +996,24 @@ function Ze({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraft
765
996
  ]
766
997
  });
767
998
  let u = e.status === "submitting", d = e.status === "submitted";
768
- return /* @__PURE__ */ V("div", {
999
+ return /* @__PURE__ */ G("div", {
769
1000
  class: "whoo-widget-feedback",
770
- children: [d ? null : /* @__PURE__ */ V("div", {
1001
+ children: [d ? null : /* @__PURE__ */ G("div", {
771
1002
  class: "whoo-widget-feedback-buttons",
772
- children: [/* @__PURE__ */ V("button", {
1003
+ children: [/* @__PURE__ */ G("button", {
773
1004
  type: "button",
774
1005
  "aria-label": "Good response",
775
1006
  disabled: u,
776
1007
  onClick: n,
777
- children: /* @__PURE__ */ V(Be, {})
778
- }), /* @__PURE__ */ V("button", {
1008
+ children: /* @__PURE__ */ G(ut, {})
1009
+ }), /* @__PURE__ */ G("button", {
779
1010
  type: "button",
780
1011
  "aria-label": "Bad response",
781
1012
  disabled: u,
782
1013
  onClick: r,
783
- children: /* @__PURE__ */ V(Ve, {})
1014
+ children: /* @__PURE__ */ G(dt, {})
784
1015
  })]
785
- }), /* @__PURE__ */ V("div", {
1016
+ }), /* @__PURE__ */ G("div", {
786
1017
  role: "status",
787
1018
  class: d ? "whoo-widget-feedback-submitted" : e.status === "error" ? "whoo-widget-feedback-error" : void 0,
788
1019
  children: d ? "Thanks for the feedback" : e.status === "error" ? "Couldn't send feedback" : null
@@ -791,27 +1022,27 @@ function Ze({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraft
791
1022
  }
792
1023
  //#endregion
793
1024
  //#region src/components/MessageList.tsx
794
- function Qe({ isSlowResponse: e }) {
795
- return /* @__PURE__ */ V("div", {
1025
+ function At({ isSlowResponse: e }) {
1026
+ return /* @__PURE__ */ G("div", {
796
1027
  class: "whoo-widget-pending",
797
1028
  role: "status",
798
- children: [/* @__PURE__ */ V("span", {
1029
+ children: [/* @__PURE__ */ G("span", {
799
1030
  class: "whoo-widget-typing",
800
1031
  "aria-hidden": "true",
801
1032
  children: [
802
- /* @__PURE__ */ V("span", {}),
803
- /* @__PURE__ */ V("span", {}),
804
- /* @__PURE__ */ V("span", {})
1033
+ /* @__PURE__ */ G("span", {}),
1034
+ /* @__PURE__ */ G("span", {}),
1035
+ /* @__PURE__ */ G("span", {})
805
1036
  ]
806
- }), e ? /* @__PURE__ */ V("span", {
1037
+ }), e ? /* @__PURE__ */ G("span", {
807
1038
  class: "whoo-widget-pending-text",
808
1039
  children: "Looking that up for you…"
809
1040
  }) : null]
810
1041
  });
811
1042
  }
812
- function $e({ url: e, alt: t }) {
813
- let [n, r] = Ee(!1);
814
- return n ? null : /* @__PURE__ */ V("img", {
1043
+ function jt({ url: e, alt: t }) {
1044
+ let [n, r] = V(!1);
1045
+ return n ? null : /* @__PURE__ */ G("img", {
815
1046
  class: "whoo-widget-empty-state-image",
816
1047
  src: e,
817
1048
  alt: t,
@@ -819,19 +1050,19 @@ function $e({ url: e, alt: t }) {
819
1050
  onError: () => r(!0)
820
1051
  });
821
1052
  }
822
- function et({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u }) {
823
- let d = z(null), f = e.id;
824
- return /* @__PURE__ */ V("div", {
1053
+ function Mt({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u }) {
1054
+ let d = U(null), f = e.id;
1055
+ return /* @__PURE__ */ G("div", {
825
1056
  ref: d,
826
1057
  tabIndex: -1,
827
1058
  class: `whoo-widget-message whoo-widget-message--${e.role}`,
828
1059
  children: [
829
- /* @__PURE__ */ V("span", {
1060
+ /* @__PURE__ */ G("span", {
830
1061
  class: "whoo-widget-sr-only",
831
1062
  children: [t, ": "]
832
1063
  }),
833
- i ? /* @__PURE__ */ V(Qe, { isSlowResponse: a }) : Ye(e.content),
834
- r && e.role === "assistant" && f ? /* @__PURE__ */ V(Ze, {
1064
+ i ? /* @__PURE__ */ G(At, { isSlowResponse: a }) : Dt(e.content),
1065
+ r && e.role === "assistant" && f ? /* @__PURE__ */ G(kt, {
835
1066
  state: n,
836
1067
  containerRef: d,
837
1068
  onThumbsUp: () => o(f),
@@ -843,30 +1074,30 @@ function et({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending
843
1074
  ]
844
1075
  });
845
1076
  }
846
- function tt({ messages: e, messageFeedback: t, announcement: n, emptyStateImage: r, agentName: i = "Aiden", showFeedback: a = !1, isStreaming: o = !1, isSlowResponse: s = !1, onThumbsUp: c, onThumbsDown: l, onDraftChange: u = () => {}, onSubmitDetailed: d, onCancelFeedback: f }) {
847
- let p = z(null);
848
- return R(() => {
849
- let e = p.current;
1077
+ function Nt({ messages: e, messageFeedback: t, announcement: n, emptyStateImage: r, agentName: i = s, showFeedback: a = !1, isStreaming: o = !1, isSlowResponse: c = !1, onThumbsUp: l, onThumbsDown: u, onDraftChange: d = () => {}, onSubmitDetailed: f, onCancelFeedback: p }) {
1078
+ let m = U(null);
1079
+ return H(() => {
1080
+ let e = m.current;
850
1081
  e && (e.scrollTop = e.scrollHeight);
851
- }, [e, s]), /* @__PURE__ */ V(E, { children: [/* @__PURE__ */ V("section", {
1082
+ }, [e, c]), /* @__PURE__ */ G(F, { children: [/* @__PURE__ */ G("section", {
852
1083
  class: "whoo-widget-message-list",
853
- ref: p,
1084
+ ref: m,
854
1085
  "aria-label": "Conversation",
855
1086
  tabIndex: 0,
856
- children: [r ? /* @__PURE__ */ V($e, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ V(et, {
1087
+ children: [r ? /* @__PURE__ */ G(jt, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ G(Mt, {
857
1088
  message: n,
858
1089
  speaker: n.role === "user" ? "You" : i,
859
1090
  showFeedback: a,
860
1091
  feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
861
1092
  pending: o && r === e.length - 1 && n.role === "assistant" && n.content === "",
862
- isSlowResponse: s,
863
- onThumbsUp: c,
864
- onThumbsDown: l,
865
- onDraftChange: u,
866
- onSubmitDetailed: d,
867
- onCancelFeedback: f
1093
+ isSlowResponse: c,
1094
+ onThumbsUp: l,
1095
+ onThumbsDown: u,
1096
+ onDraftChange: d,
1097
+ onSubmitDetailed: f,
1098
+ onCancelFeedback: p
868
1099
  }, n.id ?? r))]
869
- }), /* @__PURE__ */ V("div", {
1100
+ }), /* @__PURE__ */ G("div", {
870
1101
  class: "whoo-widget-sr-only",
871
1102
  "aria-live": "polite",
872
1103
  "aria-atomic": "true",
@@ -875,38 +1106,38 @@ function tt({ messages: e, messageFeedback: t, announcement: n, emptyStateImage:
875
1106
  }
876
1107
  //#endregion
877
1108
  //#region src/components/Panel.tsx
878
- var nt = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
879
- function rt(e) {
880
- return Array.from(e.querySelectorAll(nt)).filter((e) => {
1109
+ var Pt = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
1110
+ function Ft(e) {
1111
+ return Array.from(e.querySelectorAll(Pt)).filter((e) => {
881
1112
  let t = getComputedStyle(e);
882
1113
  return t.display !== "none" && t.visibility !== "hidden";
883
1114
  });
884
1115
  }
885
- function it({ state: e, controller: t, greeting: n }) {
886
- let i = z(null), a = z(null);
887
- R(() => {
888
- a.current?.focus();
1116
+ function It({ state: e, controller: t, greeting: n }) {
1117
+ let r = U(null), i = U(null);
1118
+ H(() => {
1119
+ i.current?.focus();
889
1120
  }, []);
890
- let o = (e) => {
1121
+ let a = (e) => {
891
1122
  if (e.key === "Escape") {
892
1123
  t.close();
893
1124
  return;
894
1125
  }
895
1126
  if (e.key !== "Tab") return;
896
- let n = i.current;
1127
+ let n = r.current;
897
1128
  if (!n) return;
898
- let r = rt(n);
899
- if (r.length === 0) return;
900
- let a = r[0], o = r[r.length - 1], s = n.getRootNode().activeElement;
1129
+ let i = Ft(n);
1130
+ if (i.length === 0) return;
1131
+ let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
901
1132
  if (!n.contains(s)) {
902
1133
  e.preventDefault(), a.focus();
903
1134
  return;
904
1135
  }
905
1136
  e.shiftKey && s === a ? (e.preventDefault(), o.focus()) : !e.shiftKey && s === o && (e.preventDefault(), a.focus());
906
- }, s = () => {
1137
+ }, o = () => {
907
1138
  let n = e.draft.trim();
908
1139
  n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
909
- }, c = r(t.config.name) || e.agentName || "Aiden", l = `Chat with ${c}`, u = e.messages.length === 0 && n ? [{
1140
+ }, s = c(t.config.name) || e.agentName || "Aiden", l = `Chat with ${s}`, u = e.messages.length === 0 && n ? [{
910
1141
  role: "assistant",
911
1142
  content: n,
912
1143
  id: null
@@ -914,43 +1145,43 @@ function it({ state: e, controller: t, greeting: n }) {
914
1145
  url: d,
915
1146
  alt: t.emptyStateImageAlt
916
1147
  } : void 0;
917
- return /* @__PURE__ */ V("div", {
1148
+ return /* @__PURE__ */ G("div", {
918
1149
  class: "whoo-widget-panel",
919
1150
  role: "dialog",
920
1151
  "aria-modal": "true",
921
1152
  "aria-label": l,
922
- ref: i,
923
- onKeyDown: o,
1153
+ ref: r,
1154
+ onKeyDown: a,
924
1155
  children: [
925
- /* @__PURE__ */ V("div", {
1156
+ /* @__PURE__ */ G("div", {
926
1157
  class: "whoo-widget-header",
927
- children: [/* @__PURE__ */ V("h2", {
1158
+ children: [/* @__PURE__ */ G("h2", {
928
1159
  class: "whoo-widget-header-title",
929
1160
  children: l
930
- }), /* @__PURE__ */ V("div", {
1161
+ }), /* @__PURE__ */ G("div", {
931
1162
  class: "whoo-widget-header-actions",
932
- children: [e.messages.length > 0 && /* @__PURE__ */ V("button", {
1163
+ children: [e.messages.length > 0 && /* @__PURE__ */ G("button", {
933
1164
  type: "button",
934
1165
  class: "whoo-widget-header-reset",
935
1166
  onClick: () => {
936
- t.resetConversation(), a.current?.focus();
1167
+ t.resetConversation(), i.current?.focus();
937
1168
  },
938
1169
  children: "New conversation"
939
- }), /* @__PURE__ */ V("button", {
1170
+ }), /* @__PURE__ */ G("button", {
940
1171
  type: "button",
941
1172
  class: "whoo-widget-header-close",
942
1173
  "aria-label": "Close chat",
943
1174
  onClick: () => t.close(),
944
- children: /* @__PURE__ */ V(Re, {})
1175
+ children: /* @__PURE__ */ G(ct, {})
945
1176
  })]
946
1177
  })]
947
1178
  }),
948
- /* @__PURE__ */ V(tt, {
1179
+ /* @__PURE__ */ G(Nt, {
949
1180
  messages: u,
950
1181
  messageFeedback: e.messageFeedback,
951
1182
  announcement: e.announcement,
952
1183
  emptyStateImage: f,
953
- agentName: c,
1184
+ agentName: s,
954
1185
  showFeedback: t.showFeedback,
955
1186
  isStreaming: e.isStreaming,
956
1187
  isSlowResponse: e.isSlowResponse,
@@ -960,29 +1191,32 @@ function it({ state: e, controller: t, greeting: n }) {
960
1191
  onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
961
1192
  onCancelFeedback: (e) => t.cancelFeedback(e)
962
1193
  }),
963
- e.runtimeError && /* @__PURE__ */ V(We, { message: e.runtimeError }),
964
- /* @__PURE__ */ V(Ue, {
1194
+ e.runtimeError && /* @__PURE__ */ G(gt, { message: e.runtimeError }),
1195
+ /* @__PURE__ */ G(ht, {
965
1196
  value: e.draft,
966
1197
  onChange: (e) => t.setDraft(e),
967
- onSend: s,
1198
+ onSend: o,
968
1199
  disabled: e.isStreaming,
969
- inputRef: a
1200
+ inputRef: i
970
1201
  })
971
1202
  ]
972
1203
  });
973
1204
  }
974
1205
  //#endregion
975
1206
  //#region src/components/App.tsx
976
- function at({ controller: e }) {
977
- let [t, n] = Ee(e.getState()), r = z(null), i = z(t.isOpen);
978
- return R(() => (n(e.getState()), e.subscribe(n)), [e]), R(() => {
1207
+ function Lt({ controller: e }) {
1208
+ let [t, n] = V(e.getState()), r = U(null), i = U(t.isOpen);
1209
+ return H(() => (n(e.getState()), e.subscribe(n)), [e]), H(() => {
979
1210
  i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
980
- }, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ V(E, { children: [/* @__PURE__ */ V(He, {
1211
+ }, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ G(F, { children: [/* @__PURE__ */ G(mt, {
981
1212
  isOpen: t.isOpen,
982
1213
  onClick: () => t.isOpen ? e.close() : e.open(),
983
- iconUrl: e.launcherIconUrl,
1214
+ iconUrl: e.launcher.iconUrl,
1215
+ icon: e.launcher.icon,
1216
+ openIconUrl: e.launcher.openIconUrl,
1217
+ openIcon: e.launcher.openIcon,
984
1218
  buttonRef: r
985
- }), t.isOpen && /* @__PURE__ */ V(it, {
1219
+ }), t.isOpen && /* @__PURE__ */ G(It, {
986
1220
  state: t,
987
1221
  controller: e,
988
1222
  greeting: e.config.greeting
@@ -990,44 +1224,44 @@ function at({ controller: e }) {
990
1224
  }
991
1225
  //#endregion
992
1226
  //#region src/api/client.ts
993
- var X = class extends Error {
1227
+ var Rt = class extends Error {
994
1228
  status;
995
1229
  constructor(e, t) {
996
1230
  super(e), this.name = "WidgetApiError", this.status = t;
997
1231
  }
998
1232
  };
999
- function Z(e) {
1233
+ function zt(e) {
1000
1234
  if (typeof e != "string") return null;
1001
1235
  let t = e.trim();
1002
1236
  return t === "" ? null : t;
1003
1237
  }
1004
- async function ot(e, t) {
1238
+ async function Bt(e, t) {
1005
1239
  let n = await fetch(`${e}/api/v1/widget/session`, {
1006
1240
  method: "POST",
1007
1241
  headers: { "Content-Type": "application/json" },
1008
1242
  body: JSON.stringify({ publishable_key: t })
1009
1243
  });
1010
- if (!n.ok) throw new X(`Failed to create widget session (${n.status})`, n.status);
1244
+ if (!n.ok) throw new Rt(`Failed to create widget session (${n.status})`, n.status);
1011
1245
  let r = await n.json();
1012
1246
  return {
1013
1247
  token: r.token,
1014
- ...st(r)
1248
+ ...Vt(r)
1015
1249
  };
1016
1250
  }
1017
- function st(e) {
1251
+ function Vt(e) {
1018
1252
  return {
1019
- primaryColor: Z(e.primary_color),
1020
- name: Z(e.name),
1021
- accentColor: Z(e.accent_color),
1022
- inkColor: Z(e.ink_color)
1253
+ primaryColor: zt(e.primary_color),
1254
+ name: zt(e.name),
1255
+ accentColor: zt(e.accent_color),
1256
+ inkColor: zt(e.ink_color)
1023
1257
  };
1024
1258
  }
1025
- async function ct(e, t) {
1259
+ async function Ht(e, t) {
1026
1260
  let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
1027
- if (!n.ok) throw new X(`Failed to load widget branding (${n.status})`, n.status);
1028
- return st(await n.json());
1261
+ if (!n.ok) throw new Rt(`Failed to load widget branding (${n.status})`, n.status);
1262
+ return Vt(await n.json());
1029
1263
  }
1030
- async function lt(e, t, n) {
1264
+ async function Ut(e, t, n) {
1031
1265
  let r = await fetch(`${e}/api/v1/widget/feedback`, {
1032
1266
  method: "POST",
1033
1267
  headers: {
@@ -1041,11 +1275,11 @@ async function lt(e, t, n) {
1041
1275
  category: n.category ?? null
1042
1276
  })
1043
1277
  });
1044
- if (!r.ok) throw new X(`Feedback submission failed (${r.status})`, r.status);
1278
+ if (!r.ok) throw new Rt(`Feedback submission failed (${r.status})`, r.status);
1045
1279
  }
1046
1280
  //#endregion
1047
1281
  //#region src/api/sse.ts
1048
- async function* ut(e, t, n, r, i) {
1282
+ async function* Wt(e, t, n, r, i) {
1049
1283
  let a = await fetch(`${e}/api/v1/widget/chat`, {
1050
1284
  method: "POST",
1051
1285
  headers: {
@@ -1058,7 +1292,7 @@ async function* ut(e, t, n, r, i) {
1058
1292
  }),
1059
1293
  signal: i
1060
1294
  });
1061
- if (!a.ok || !a.body) throw new X(`Chat request failed (${a.status})`, a.status);
1295
+ if (!a.ok || !a.body) throw new Rt(`Chat request failed (${a.status})`, a.status);
1062
1296
  let o = a.body.getReader(), s = new TextDecoder(), c = "";
1063
1297
  for (;;) {
1064
1298
  let { done: e, value: t } = await o.read();
@@ -1069,11 +1303,11 @@ async function* ut(e, t, n, r, i) {
1069
1303
  let e = c.slice(0, n);
1070
1304
  c = c.slice(n + 2);
1071
1305
  let t = e.split("\n").find((e) => e.startsWith("data: "));
1072
- t && (yield dt(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1306
+ t && (yield Gt(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1073
1307
  }
1074
1308
  }
1075
1309
  }
1076
- function dt(e) {
1310
+ function Gt(e) {
1077
1311
  return typeof e.error == "string" ? {
1078
1312
  type: "error",
1079
1313
  error: e.error,
@@ -1095,23 +1329,12 @@ function dt(e) {
1095
1329
  };
1096
1330
  }
1097
1331
  //#endregion
1098
- //#region src/imageUrl.ts
1099
- function ft(e, t) {
1100
- if (e != null && e !== "") {
1101
- if (typeof e == "string") try {
1102
- let t = new URL(e);
1103
- if (t.protocol === "https:" || t.protocol === "data:" && t.pathname.toLowerCase().startsWith("image/")) return e;
1104
- } catch {}
1105
- console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`);
1106
- }
1107
- }
1108
- //#endregion
1109
1332
  //#region src/markdown/plainText.ts
1110
- function pt(e) {
1111
- return J(e.replace(/\r\n?/g, "\n")).map((e) => {
1333
+ function Kt(e) {
1334
+ return wt(e.replace(/\r\n?/g, "\n")).map((e) => {
1112
1335
  switch (e.type) {
1113
1336
  case "bold":
1114
- case "italic": return pt(e.value);
1337
+ case "italic": return Kt(e.value);
1115
1338
  case "link": return e.text;
1116
1339
  default: return e.value;
1117
1340
  }
@@ -1119,16 +1342,16 @@ function pt(e) {
1119
1342
  }
1120
1343
  //#endregion
1121
1344
  //#region src/markdown/reveal.ts
1122
- var mt = 40, ht = 120;
1123
- function gt(e) {
1345
+ var qt = 40, Jt = 120;
1346
+ function Yt(e) {
1124
1347
  let t = [];
1125
- for (let n of J(e)) if (n.type === "text") {
1348
+ for (let n of wt(e)) if (n.type === "text") {
1126
1349
  let e = n.value.split(/(\s+)/), r = n.start;
1127
1350
  for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
1128
1351
  } else t.push(n.end);
1129
1352
  return t;
1130
1353
  }
1131
- function _t(e) {
1354
+ function Xt(e) {
1132
1355
  let t = null;
1133
1356
  return e?.addEventListener("abort", () => {
1134
1357
  t?.();
@@ -1143,14 +1366,14 @@ function _t(e) {
1143
1366
  });
1144
1367
  };
1145
1368
  }
1146
- async function vt(e, t, n) {
1147
- let r = n?.wordIntervalMs ?? mt, i = n?.tokenIntervalMs ?? ht, a = n?.signal, o = J(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = _t(a), l = "";
1148
- for (let n of gt(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1369
+ async function Zt(e, t, n) {
1370
+ let r = n?.wordIntervalMs ?? qt, i = n?.tokenIntervalMs ?? Jt, a = n?.signal, o = wt(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = Xt(a), l = "";
1371
+ for (let n of Yt(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1149
1372
  l !== e && t(e);
1150
1373
  }
1151
1374
  //#endregion
1152
1375
  //#region src/sessionToken.ts
1153
- function yt(e, t = Date.now()) {
1376
+ function Qt(e, t = Date.now()) {
1154
1377
  let n = e.split(".");
1155
1378
  if (n.length !== 3 || n.some((e) => e === "")) return !1;
1156
1379
  let r = n[1];
@@ -1163,31 +1386,31 @@ function yt(e, t = Date.now()) {
1163
1386
  }
1164
1387
  //#endregion
1165
1388
  //#region src/storage.ts
1166
- function bt(e) {
1389
+ function $t(e) {
1167
1390
  return `whoo-aiden-widget:conversation:${e}`;
1168
1391
  }
1169
- function xt(e) {
1392
+ function en(e) {
1170
1393
  try {
1171
- return window.sessionStorage.getItem(bt(e));
1394
+ return window.sessionStorage.getItem($t(e));
1172
1395
  } catch {
1173
1396
  return null;
1174
1397
  }
1175
1398
  }
1176
- function St(e, t) {
1399
+ function tn(e, t) {
1177
1400
  try {
1178
- window.sessionStorage.setItem(bt(e), t);
1401
+ window.sessionStorage.setItem($t(e), t);
1179
1402
  } catch {}
1180
1403
  }
1181
- function Ct(e) {
1404
+ function nn(e) {
1182
1405
  try {
1183
- window.sessionStorage.removeItem(bt(e));
1406
+ window.sessionStorage.removeItem($t(e));
1184
1407
  } catch {}
1185
1408
  }
1186
1409
  //#endregion
1187
1410
  //#region src/theme.ts
1188
- var wt = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1189
- function Tt(e) {
1190
- if (wt.test(e.trim())) return null;
1411
+ var rn = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1412
+ function an(e) {
1413
+ if (rn.test(e.trim())) return null;
1191
1414
  let t = document.createElement("div");
1192
1415
  if (t.style.color = e, t.style.color === "") return null;
1193
1416
  let n = document.createElement("div");
@@ -1206,105 +1429,216 @@ function Tt(e) {
1206
1429
  translucent: a < 1
1207
1430
  };
1208
1431
  }
1209
- function Et(e) {
1210
- return Tt(e)?.rgb ?? null;
1432
+ function J(e) {
1433
+ return an(e)?.rgb ?? null;
1211
1434
  }
1212
- function Q([e, t, n]) {
1435
+ function Y([e, t, n]) {
1213
1436
  let r = (e) => {
1214
1437
  let t = e / 255;
1215
1438
  return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
1216
1439
  };
1217
1440
  return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
1218
1441
  }
1219
- function Dt(e, t) {
1442
+ function on(e, t) {
1220
1443
  let n = Math.max(e, t), r = Math.min(e, t);
1221
1444
  return (n + .05) / (r + .05);
1222
1445
  }
1223
- function Ot(e) {
1224
- let t = Et(e);
1446
+ function sn(e) {
1447
+ let t = J(e);
1225
1448
  if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
1226
- let n = Q(t);
1227
- return Dt(n, Q([
1449
+ let n = Y(t);
1450
+ return on(n, Y([
1228
1451
  0,
1229
1452
  0,
1230
1453
  0
1231
- ])) >= Dt(n, Q([
1454
+ ])) >= on(n, Y([
1232
1455
  255,
1233
1456
  255,
1234
1457
  255
1235
1458
  ])) ? "#000000" : "#ffffff";
1236
1459
  }
1237
- var kt = "#4f46e5", At = "#ffffff", jt = "#f0f0f0", Mt = "#f3f4f6", Nt = 4.5;
1238
- function Pt([e, t, n]) {
1460
+ function cn(e, t) {
1461
+ let n = J(e), r = J(t);
1462
+ return !n || !r ? NaN : on(Y(n), Y(r));
1463
+ }
1464
+ var ln = n.primary, un = n.panel, dn = n.assistantBubble, fn = n.headerHover, pn = 4.5;
1465
+ function mn([e, t, n]) {
1239
1466
  return `#${[
1240
1467
  e,
1241
1468
  t,
1242
1469
  n
1243
1470
  ].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
1244
1471
  }
1245
- function Ft(e, t = At) {
1246
- let n = Et(e), r = Et(t);
1247
- if (!n || !r) return kt;
1248
- let i = Q(r), a = (e) => Dt(Q(e), i) >= Nt;
1249
- if (a(n)) return Pt(n);
1472
+ function hn(e, t = un) {
1473
+ let n = J(e), r = J(t);
1474
+ if (!n || !r) return ln;
1475
+ let i = Y(r), a = (e) => on(Y(e), i) >= pn;
1476
+ if (a(n)) return mn(n);
1250
1477
  for (let e = .99; e > 0; e -= .01) {
1251
1478
  let t = n.map((t) => Math.round(t * e));
1252
- if (a(t)) return Pt(t);
1479
+ if (a(t)) return mn(t);
1253
1480
  }
1254
1481
  return "#000000";
1255
1482
  }
1256
- var It = "#111111", Lt = "#0000ee";
1257
- function $(e) {
1483
+ var gn = n.ink, _n = n.link;
1484
+ function X(e) {
1258
1485
  if (typeof e != "string" || !e) return null;
1259
- let t = Tt(e);
1260
- return t ? Pt(t.rgb) : null;
1486
+ let t = an(e);
1487
+ return t ? mn(t.rgb) : null;
1261
1488
  }
1262
- function Rt({ color: e, inkColor: t, accentColor: n }) {
1263
- let r = $(e), i = r ?? kt, a = Ft(i, Mt), o = $(t), s = o ? Ft(o, jt) : It, c = $(n), l = c ? Ft(c, jt) : Lt;
1489
+ function vn(e) {
1490
+ if (typeof e != "string" || !e) return null;
1491
+ let t = an(e);
1492
+ return t ? t.translucent ? e.trim() : mn(t.rgb) : null;
1493
+ }
1494
+ var yn = [
1495
+ {
1496
+ role: "onPrimary",
1497
+ against: ["primary"],
1498
+ required: 4.5
1499
+ },
1500
+ {
1501
+ role: "primaryText",
1502
+ against: ["panel", "headerHover"],
1503
+ required: 4.5
1504
+ },
1505
+ {
1506
+ role: "ink",
1507
+ against: ["assistantBubble", "panel"],
1508
+ required: 4.5
1509
+ },
1510
+ {
1511
+ role: "link",
1512
+ against: ["assistantBubble"],
1513
+ required: 4.5
1514
+ },
1515
+ {
1516
+ role: "muted",
1517
+ against: ["assistantBubble"],
1518
+ required: 4.5
1519
+ },
1520
+ {
1521
+ role: "text",
1522
+ against: ["panel", "assistantBubble"],
1523
+ required: 4.5
1524
+ },
1525
+ {
1526
+ role: "errorText",
1527
+ against: ["errorBackground"],
1528
+ required: 4.5
1529
+ },
1530
+ {
1531
+ role: "typingDots",
1532
+ against: ["assistantBubble"],
1533
+ required: 3
1534
+ },
1535
+ {
1536
+ role: "inputBorder",
1537
+ against: ["panel"],
1538
+ required: 3
1539
+ },
1540
+ {
1541
+ role: "focusRing",
1542
+ against: ["panel"],
1543
+ required: 3
1544
+ }
1545
+ ];
1546
+ function Z({ color: e, inkColor: r, accentColor: i, overrides: a }) {
1547
+ let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => vn(o[e]), c = X(e), l = s("primary"), u = l ?? c ?? ln, d = s("primaryText"), f = d ?? hn(u, fn), p = s("onPrimary") ?? sn(u), m = X(r), h = s("ink") ?? (m ? hn(m, dn) : gn), g = X(i), _ = s("link") ?? (g ? hn(g, dn) : _n), v = (e) => s(e) ?? n[e], y = {
1548
+ primary: u,
1549
+ onPrimary: p,
1550
+ primaryText: f,
1551
+ ink: h,
1552
+ link: _,
1553
+ text: v("text"),
1554
+ panel: v("panel"),
1555
+ border: v("border"),
1556
+ headerHover: v("headerHover"),
1557
+ assistantBubble: v("assistantBubble"),
1558
+ muted: v("muted"),
1559
+ typingDots: v("typingDots"),
1560
+ errorBackground: v("errorBackground"),
1561
+ errorText: v("errorText"),
1562
+ inputBorder: v("inputBorder"),
1563
+ focusRing: v("focusRing")
1564
+ }, b = Object.fromEntries(t.map((e) => [e, s(e) !== null])), x = [];
1565
+ for (let { role: e, against: t, required: n } of yn) if (b[e]) for (let r of t) {
1566
+ let t = cn(y[e], y[r]);
1567
+ Number.isFinite(t) && t < n && x.push({
1568
+ role: e,
1569
+ against: r,
1570
+ value: y[e],
1571
+ ratio: t,
1572
+ required: n
1573
+ });
1574
+ }
1264
1575
  return {
1265
- primary: i,
1266
- textOnPrimary: Ot(i),
1267
- primaryAsText: a,
1268
- ink: s,
1269
- link: l,
1576
+ primary: u,
1577
+ textOnPrimary: p,
1578
+ primaryAsText: f,
1579
+ ink: h,
1580
+ link: _,
1270
1581
  adjusted: {
1271
- primary: r !== null && a !== i,
1272
- ink: o !== null && s !== o,
1273
- link: c !== null && l !== c
1274
- }
1582
+ primary: l === null && d === null && c !== null && f !== u,
1583
+ ink: !b.ink && m !== null && h !== m,
1584
+ link: !b.link && g !== null && _ !== g
1585
+ },
1586
+ roles: y,
1587
+ overridden: b,
1588
+ contrastWarnings: x
1275
1589
  };
1276
1590
  }
1277
- function zt(e) {
1591
+ function Q(e) {
1278
1592
  return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
1279
1593
  }
1280
- function Bt(e, t, n = kt) {
1594
+ function bn(e, t, n = ln) {
1281
1595
  let r = t;
1282
- $(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${zt(t)} as the theme color; falling back to ${zt(n)}.`), r = n);
1283
- let i = Rt({ color: r });
1596
+ X(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as the theme color; falling back to ${Q(n)}.`), r = n);
1597
+ let i = Z({ color: r });
1284
1598
  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);
1285
1599
  }
1286
- function Vt(e, { inkColor: t, accentColor: n }) {
1287
- let r = Rt({
1600
+ function xn(e, { inkColor: t, accentColor: n }) {
1601
+ let r = Z({
1288
1602
  inkColor: t,
1289
1603
  accentColor: n
1290
1604
  });
1291
1605
  e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
1292
1606
  }
1293
- function Ht(e, t) {
1294
- e && $(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${zt(e)} as the ${t}; using the default.`);
1607
+ function Sn(e, n) {
1608
+ let i = Z({ overrides: n });
1609
+ for (let n of t) {
1610
+ let t = i.overridden.primary && (n === "onPrimary" || n === "primaryText");
1611
+ (i.overridden[n] || t) && e.style.setProperty(r[n], i.roles[n]);
1612
+ }
1613
+ }
1614
+ function Cn(e, t) {
1615
+ e && X(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`);
1295
1616
  }
1296
- function Ut(e, t) {
1297
- Bt(e, t.color ?? kt), Ht(t.inkColor, "ink color"), Ht(t.accentColor, "accent color"), Vt(e, {
1617
+ function wn(e, n) {
1618
+ for (let e of t) {
1619
+ let t = n[e];
1620
+ t && X(t) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as theme.colors.${e}; using the calculated color.`);
1621
+ }
1622
+ let { contrastWarnings: r } = Z({
1623
+ color: e.color,
1624
+ inkColor: e.inkColor,
1625
+ accentColor: e.accentColor,
1626
+ overrides: n
1627
+ });
1628
+ for (let { role: e, against: t, value: n, ratio: i, required: a } of r) console.warn(`[whoo-aiden-widget] theme.colors.${e} (${n}) has ${i.toFixed(2)}:1 contrast against the ${t} color; ${a}:1 is recommended. Using it as given.`);
1629
+ }
1630
+ function Tn(e, t) {
1631
+ bn(e, t.color ?? ln), Cn(t.inkColor, "ink color"), Cn(t.accentColor, "accent color"), xn(e, {
1298
1632
  inkColor: t.inkColor,
1299
1633
  accentColor: t.accentColor
1300
1634
  });
1301
- let n = t.position === "bottom-left";
1302
- e.style.setProperty("--whoo-widget-inset-left", n ? "20px" : "auto"), e.style.setProperty("--whoo-widget-inset-right", n ? "auto" : "20px");
1635
+ let n = T(t.theme);
1636
+ wn(t, n.colors), Sn(e, n.colors), n.fontFamily && (e.style.setProperty("--whoo-widget-font", n.fontFamily), e.setAttribute("data-whoo-custom-font", ""));
1303
1637
  }
1304
1638
  //#endregion
1305
1639
  //#region src/controller.ts
1306
- var Wt = 8e3, Gt = 3e3;
1307
- function Kt(e, t) {
1640
+ var En = 8e3, Dn = 3e3;
1641
+ function On(e, t) {
1308
1642
  return new Promise((n) => {
1309
1643
  let r = setTimeout(n, t);
1310
1644
  e.then(() => {
@@ -1312,7 +1646,7 @@ function Kt(e, t) {
1312
1646
  });
1313
1647
  });
1314
1648
  }
1315
- var qt = class {
1649
+ var kn = class {
1316
1650
  config;
1317
1651
  state;
1318
1652
  listeners = /* @__PURE__ */ new Set();
@@ -1322,12 +1656,18 @@ var qt = class {
1322
1656
  activeRequestController = null;
1323
1657
  slowResponseTimer = null;
1324
1658
  prefersReducedMotion;
1659
+ launcher;
1325
1660
  launcherIconUrl;
1326
1661
  emptyStateImageUrl;
1327
1662
  emptyStateImageAlt;
1328
1663
  showFeedback;
1329
- constructor(e) {
1330
- this.config = e, this.launcherIconUrl = ft(e.launcherIconUrl, "launcherIconUrl"), this.emptyStateImageUrl = ft(e.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof e.emptyStateImageAlt == "string" ? e.emptyStateImageAlt.trim() : "", this.showFeedback = e.showFeedback === !0, this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
1664
+ constructor(t) {
1665
+ this.config = t;
1666
+ let n = T(t.theme).launcher, r = n.iconUrl ?? e(t.launcherIconUrl, "launcherIconUrl");
1667
+ this.launcher = {
1668
+ ...n,
1669
+ ...r ? { iconUrl: r } : {}
1670
+ }, this.launcherIconUrl = r, this.emptyStateImageUrl = e(t.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof t.emptyStateImageAlt == "string" ? t.emptyStateImageAlt.trim() : "", this.showFeedback = t.showFeedback === !0, this.storageIdentifier = t.publishableKey ?? "session-token-mode", this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
1331
1671
  isOpen: !1,
1332
1672
  messages: [],
1333
1673
  isStreaming: !1,
@@ -1372,10 +1712,10 @@ var qt = class {
1372
1712
  let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
1373
1713
  try {
1374
1714
  if (this.config.sessionToken) {
1375
- if (yt(this.config.sessionToken)) throw Error("The sessionToken has expired.");
1715
+ if (Qt(this.config.sessionToken)) throw Error("The sessionToken has expired.");
1376
1716
  this.sessionToken = this.config.sessionToken;
1377
1717
  } else if (this.config.publishableKey) {
1378
- let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await ot(e, this.config.publishableKey);
1718
+ let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await Bt(e, this.config.publishableKey);
1379
1719
  this.sessionToken = t, this.setState({
1380
1720
  primaryColor: n,
1381
1721
  agentName: r,
@@ -1387,18 +1727,18 @@ var qt = class {
1387
1727
  console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
1388
1728
  return;
1389
1729
  }
1390
- this.conversationId = xt(this.storageIdentifier), this.config.sessionToken && await Kt(this.loadBranding(e, this.config.sessionToken), Gt);
1730
+ this.conversationId = en(this.storageIdentifier), this.config.sessionToken && await On(this.loadBranding(e, this.config.sessionToken), Dn);
1391
1731
  }
1392
1732
  async loadBranding(e, t) {
1393
1733
  try {
1394
1734
  let n = this.config;
1395
- if ($(n.color) && $(n.inkColor) && $(n.accentColor) && r(n.name)) return;
1396
- let { primaryColor: i, name: a, accentColor: o, inkColor: s } = await ct(e, t);
1735
+ if (X(n.color) && X(n.inkColor) && X(n.accentColor) && c(n.name)) return;
1736
+ let { primaryColor: r, name: i, accentColor: a, inkColor: o } = await Ht(e, t);
1397
1737
  this.setState({
1398
- primaryColor: i,
1399
- agentName: a,
1400
- accentColor: o,
1401
- inkColor: s
1738
+ primaryColor: r,
1739
+ agentName: i,
1740
+ accentColor: a,
1741
+ inkColor: o
1402
1742
  });
1403
1743
  } catch (e) {
1404
1744
  let t = e?.status;
@@ -1409,7 +1749,7 @@ var qt = class {
1409
1749
  this.setState({ isOpen: !0 });
1410
1750
  }
1411
1751
  resetConversation() {
1412
- this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, Ct(this.storageIdentifier), this.setState({
1752
+ this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, nn(this.storageIdentifier), this.setState({
1413
1753
  messages: [],
1414
1754
  messageFeedback: {},
1415
1755
  runtimeError: null,
@@ -1455,7 +1795,7 @@ var qt = class {
1455
1795
  let { signal: a } = this.activeRequestController;
1456
1796
  this.slowResponseTimer = setTimeout(() => {
1457
1797
  this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
1458
- }, Wt);
1798
+ }, En);
1459
1799
  let o = () => {
1460
1800
  this.setState({
1461
1801
  runtimeError: "Something went wrong, please try again.",
@@ -1463,17 +1803,17 @@ var qt = class {
1463
1803
  });
1464
1804
  }, s = "";
1465
1805
  try {
1466
- for await (let n of ut(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, St(this.storageIdentifier, n.conversationId);
1467
- else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await vt(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
1806
+ for await (let n of Wt(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, tn(this.storageIdentifier, n.conversationId);
1807
+ else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await Zt(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
1468
1808
  else if (n.type === "done") {
1469
- if (n.conversationId && (this.conversationId = n.conversationId, St(this.storageIdentifier, n.conversationId)), n.messageId) {
1809
+ if (n.conversationId && (this.conversationId = n.conversationId, tn(this.storageIdentifier, n.conversationId)), n.messageId) {
1470
1810
  let e = [...this.state.messages];
1471
1811
  e[e.length - 1] = {
1472
1812
  ...e[e.length - 1],
1473
1813
  id: n.messageId
1474
1814
  }, this.setState({ messages: e });
1475
1815
  }
1476
- this.setState({ announcement: pt(s) });
1816
+ this.setState({ announcement: Kt(s) });
1477
1817
  } else if (n.type === "error") {
1478
1818
  console.error("[whoo-aiden-widget] chat error:", n.error), o(), this.activeRequestController?.abort();
1479
1819
  break;
@@ -1522,7 +1862,7 @@ var qt = class {
1522
1862
  }
1523
1863
  } });
1524
1864
  try {
1525
- await lt(i, this.sessionToken, {
1865
+ await Ut(i, this.sessionToken, {
1526
1866
  messageId: e,
1527
1867
  rating: t,
1528
1868
  correction: n,
@@ -1546,32 +1886,45 @@ var qt = class {
1546
1886
  } });
1547
1887
  }
1548
1888
  }
1549
- }, Jt = ":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-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding:8px 8px 8px 16px;display:flex;overflow-y:auto}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;flex:auto;min-width:0;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-actions{background:#fff;flex-shrink:0;align-items:center;gap:4px;margin-left:auto;display:flex;position:sticky;bottom:0}.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:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline-offset:-2px;outline:2px solid #111827;box-shadow:inset 0 0 0 4px #fff}.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{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-list{margin:4px 0;padding-left:20px}.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[aria-disabled=true],.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:#4b5563;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}@media (forced-colors:active){.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
1889
+ }, $ = 20, An = 12, jn = 300, Mn = 352;
1890
+ function Nn(e, t) {
1891
+ let { offsetX: n, offsetY: r, launcherSize: i, panelWidth: a, panelHeight: o } = te(t.layout), s = (e) => typeof t.layout?.offset?.[e] == "number";
1892
+ if (typeof window < "u" && window.innerWidth > 0 && window.innerHeight > 0) {
1893
+ let e = Math.max($, window.innerWidth - jn), t = Math.max($, window.innerHeight - i - Mn);
1894
+ s("x") && (n > e || n > window.innerWidth - i) && console.warn(`whoo-aiden-widget: \`layout.offset.x\` ${n} leaves no room for the launcher and panel in this viewport; it is held back.`), s("y") && (r > t || r > window.innerHeight - i) && console.warn(`whoo-aiden-widget: \`layout.offset.y\` ${r} leaves no room for the launcher and panel in this viewport; it is held back.`);
1895
+ }
1896
+ let c = `min(${n}px, max(${$}px, calc(100vw - ${jn}px)), calc(100vw - ${i}px))`, l = `min(${r}px, max(${$}px, calc(100vh - ${i + Mn}px)), calc(100vh - ${i}px))`, u = `calc(${l} + ${i}px + ${An}px)`, d = t.position === "bottom-left", f = (t, n) => e.style.setProperty(t, n);
1897
+ f("--whoo-widget-inset-left", d ? c : "auto"), f("--whoo-widget-inset-right", d ? "auto" : c), f("--whoo-widget-inset-bottom", l), f("--whoo-widget-launcher-size", `${i}px`), f("--whoo-widget-panel-bottom", u), f("--whoo-widget-panel-width", `${a}px`), f("--whoo-widget-panel-height", `${o}px`), f("--whoo-widget-panel-max-width", `calc(100vw - ${c} - ${$}px)`), f("--whoo-widget-panel-max-height", `calc(100vh - ${u} - ${$}px)`);
1898
+ }
1899
+ //#endregion
1900
+ //#region src/styles.css?inline
1901
+ var Pn = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:var(--whoo-widget-inset-bottom,20px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-launcher-size,56px);height:var(--whoo-widget-launcher-size,56px);background:var(--whoo-widget-color,#4f46e5);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{width:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);height:calc(var(--whoo-widget-launcher-size,56px) * 13 / 28);display:block}.whoo-widget-launcher-icon-image{width:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);height:calc(var(--whoo-widget-launcher-size,56px) * 4 / 7);object-fit:cover;border-radius:50%}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:var(--whoo-widget-panel-bottom,88px);left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);width:var(--whoo-widget-panel-width,360px);height:var(--whoo-widget-panel-height,480px);max-width:var(--whoo-widget-panel-max-width,calc(100vw - 40px));max-height:var(--whoo-widget-panel-max-height,calc(100vh - 108px));background:var(--whoo-widget-panel,#fff);font-family:var(--whoo-widget-font,-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif);border-radius:12px;flex-direction:column;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 var(--whoo-widget-border,#e5e5e5);flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding:8px 8px 8px 16px;display:flex;overflow-y:auto}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;flex:auto;min-width:0;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-actions{background:var(--whoo-widget-panel,#fff);flex-shrink:0;align-items:center;gap:4px;margin-left:auto;display:flex;position:sticky;bottom:0}.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:var(--whoo-widget-header-hover,#f3f4f6)}.whoo-widget-message-list{flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:-2px;box-shadow:inset 0 0 0 4px var(--whoo-widget-panel,#fff)}.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{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-list{margin:4px 0;padding-left:20px}.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{background:var(--whoo-widget-assistant-bubble,#f0f0f0);color:var(--whoo-widget-ink,#111)}.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:var(--whoo-widget-typing-dots,#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{background:var(--whoo-widget-error-bg,#fee2e2);color:var(--whoo-widget-error-text,#991b1b);padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid var(--whoo-widget-border,#e5e5e5);gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid var(--whoo-widget-input-border,#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[aria-disabled=true],.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:var(--whoo-widget-muted,#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:var(--whoo-widget-text,#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;border:1px solid var(--whoo-widget-input-border,#6b7280);resize:vertical;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#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{border:1px solid var(--whoo-widget-input-border,#6b7280);background:var(--whoo-widget-panel,#fff);color:var(--whoo-widget-text,#111);cursor:pointer;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:var(--whoo-widget-muted,#4b5563);margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:var(--whoo-widget-error-text,#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}[data-whoo-custom-font] button,[data-whoo-custom-font] input,[data-whoo-custom-font] textarea,[data-whoo-custom-font] select{font-family:inherit}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline:2px solid var(--whoo-widget-focus-ring,#111827);outline-offset:2px;box-shadow:0 0 0 4px var(--whoo-widget-panel,#fff)}@media (forced-colors:active){.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
1550
1902
  //#endregion
1551
1903
  //#region src/mount.tsx
1552
- function Yt(e) {
1904
+ function Fn(e) {
1553
1905
  let t = document.createElement("div");
1554
- t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(n(e.zIndex));
1555
- let r = t.attachShadow({ mode: "open" }), i = document.createElement("style");
1556
- i.textContent = Jt, r.appendChild(i);
1557
- let a = document.createElement("div");
1558
- r.appendChild(a), Ut(a, e);
1559
- let o = new qt(e), s = $(e.color) !== null, c = null, l = "";
1560
- return o.subscribe((t) => {
1561
- !s && t.primaryColor && t.primaryColor !== c && (c = t.primaryColor, Bt(a, t.primaryColor, e.color));
1562
- let n = `${t.inkColor}|${t.accentColor}`;
1563
- (t.inkColor || t.accentColor) && n !== l && (l = n, Vt(a, {
1564
- inkColor: $(e.inkColor) ? e.inkColor : t.inkColor,
1565
- accentColor: $(e.accentColor) ? e.accentColor : t.accentColor
1566
- }));
1567
- }), o.init(), he(/* @__PURE__ */ V(at, { controller: o }), a), document.body.appendChild(t), { unmount() {
1568
- he(null, a), t.remove();
1906
+ t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(o(e.zIndex));
1907
+ let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
1908
+ r.textContent = Pn, n.appendChild(r);
1909
+ let i = document.createElement("div");
1910
+ n.appendChild(i), Tn(i, e), Nn(i, e);
1911
+ let a = new kn(e), s = X(e.color) !== null, c = null, l = "", u = T(e.theme).colors;
1912
+ return a.subscribe((t) => {
1913
+ let n = !1;
1914
+ !s && t.primaryColor && t.primaryColor !== c && (c = t.primaryColor, bn(i, t.primaryColor, e.color), n = !0);
1915
+ let r = `${t.inkColor}|${t.accentColor}`;
1916
+ (t.inkColor || t.accentColor) && r !== l && (l = r, xn(i, {
1917
+ inkColor: X(e.inkColor) ? e.inkColor : t.inkColor,
1918
+ accentColor: X(e.accentColor) ? e.accentColor : t.accentColor
1919
+ }), n = !0), n && Sn(i, u);
1920
+ }), a.init(), Fe(/* @__PURE__ */ G(Lt, { controller: a }), i), document.body.appendChild(t), { unmount() {
1921
+ Fe(null, i), t.remove();
1569
1922
  } };
1570
1923
  }
1571
1924
  //#endregion
1572
1925
  //#region src/index.ts
1573
- function Xt(e) {
1574
- return i(e), Yt(e);
1926
+ function In(e) {
1927
+ return l(e), Fn(e);
1575
1928
  }
1576
1929
  //#endregion
1577
- export { Xt as init, Rt as resolveTheme };
1930
+ export { In as init, Z as resolveTheme };