@aiden-voice/widget 0.7.3 → 0.8.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,5 +1,35 @@
1
+ //#region src/i18n/messages.ts
2
+ var e = {
3
+ openChat: "Open chat",
4
+ closeChat: "Close chat",
5
+ chatWith: "Chat with {name}",
6
+ newConversation: "New conversation",
7
+ conversation: "Conversation",
8
+ you: "You",
9
+ message: "Message",
10
+ send: "Send",
11
+ lookingItUp: "Looking that up for you…",
12
+ goodResponse: "Good response",
13
+ badResponse: "Bad response",
14
+ additionalFeedback: "Additional feedback",
15
+ feedbackPlaceholder: "What was wrong? (optional)",
16
+ feedbackCategory: "Feedback category",
17
+ selectReason: "Select a reason (optional)",
18
+ categoryFactual: "Factual error",
19
+ categoryIncomplete: "Incomplete",
20
+ categoryTone: "Off tone",
21
+ categoryOther: "Other",
22
+ submit: "Submit",
23
+ cancel: "Cancel",
24
+ feedbackThanks: "Thanks for the feedback",
25
+ feedbackFailed: "Couldn't send feedback",
26
+ conversationCleared: "Conversation cleared",
27
+ genericError: "Something went wrong, please try again.",
28
+ sessionExpired: "This chat session has expired. Reload the page to continue."
29
+ }, t = Object.keys(e);
30
+ //#endregion
1
31
  //#region src/imageUrl.ts
2
- function e(e, t) {
32
+ function n(e, t) {
3
33
  if (e != null && e !== "") {
4
34
  if (typeof e == "string") try {
5
35
  let t = new URL(e);
@@ -10,7 +40,7 @@ function e(e, t) {
10
40
  }
11
41
  //#endregion
12
42
  //#region src/themeRoles.ts
13
- var t = [
43
+ var r = [
14
44
  "primary",
15
45
  "onPrimary",
16
46
  "primaryText",
@@ -27,7 +57,7 @@ var t = [
27
57
  "errorText",
28
58
  "inputBorder",
29
59
  "focusRing"
30
- ], n = {
60
+ ], i = {
31
61
  primary: "#4f46e5",
32
62
  onPrimary: "#ffffff",
33
63
  primaryText: "#4f46e5",
@@ -44,7 +74,7 @@ var t = [
44
74
  errorText: "#991b1b",
45
75
  inputBorder: "#6b7280",
46
76
  focusRing: "#111827"
47
- }, r = {
77
+ }, a = {
48
78
  primary: "--whoo-widget-color",
49
79
  onPrimary: "--whoo-widget-text-on-color",
50
80
  primaryText: "--whoo-widget-color-text",
@@ -61,22 +91,36 @@ var t = [
61
91
  errorText: "--whoo-widget-error-text",
62
92
  inputBorder: "--whoo-widget-input-border",
63
93
  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";
94
+ }, o = 2147483e3, s = 2147483647;
69
95
  function c(e) {
96
+ return e === void 0 ? o : Number.isInteger(e) && Math.abs(e) <= s ? e : (console.warn(`whoo-aiden-widget: ignoring zIndex ${String(e)} (expected an integer between -${s} and ${s}); using ${o}.`), o);
97
+ }
98
+ var l = "Aiden";
99
+ function u(e) {
70
100
  return typeof e == "string" ? e.trim() : "";
71
101
  }
72
- function l(e) {
102
+ function d(e) {
73
103
  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.");
74
104
  }
75
- function u(e) {
105
+ function f(e) {
76
106
  console.warn(`whoo-aiden-widget: ${e}`);
77
107
  }
78
- var d = 20;
79
- function f(e) {
108
+ function p(e) {
109
+ let { getSessionToken: t } = e;
110
+ if (t !== void 0) {
111
+ if (typeof t != "function") {
112
+ f("ignoring `getSessionToken` -- expected a function that returns a session token.");
113
+ return;
114
+ }
115
+ if (!e.sessionToken) {
116
+ f("ignoring `getSessionToken` -- it is only used with `sessionToken`; with `publishableKey` the widget renews its session by itself.");
117
+ return;
118
+ }
119
+ return t;
120
+ }
121
+ }
122
+ var m = 20;
123
+ function h(e) {
80
124
  let t = /* @__PURE__ */ new WeakSet(), n = /* @__PURE__ */ new Set();
81
125
  return (r) => {
82
126
  if (typeof r == "object" && r || typeof r == "function") {
@@ -84,120 +128,139 @@ function f(e) {
84
128
  t.add(r);
85
129
  } else {
86
130
  if (n.has(r)) return;
87
- n.size >= d && n.delete(n.values().next().value), n.add(r);
131
+ n.size >= m && n.delete(n.values().next().value), n.add(r);
88
132
  }
89
- u(e);
133
+ f(e);
90
134
  };
91
135
  }
92
- var p = f("ignoring `theme` -- expected an object."), m = f("ignoring `layout` -- expected an object.");
93
- function h(e) {
136
+ var g = h("ignoring `theme` -- expected an object."), _ = h("ignoring `layout` -- expected an object."), v = h("ignoring `messages` -- expected an object.");
137
+ function y(e) {
138
+ if (e == null) return {};
139
+ if (!b(e)) return v(e), {};
140
+ let n = {};
141
+ for (let r of Object.keys(e)) {
142
+ if (!t.includes(r)) {
143
+ f(`ignoring unknown option \`messages.${r}\`.`);
144
+ continue;
145
+ }
146
+ let i = e[r];
147
+ if (typeof i != "string" || i.trim() === "") {
148
+ f(`ignoring \`messages.${r}\` -- expected a non-blank string.`);
149
+ continue;
150
+ }
151
+ r === "chatWith" && !i.includes("{name}") && f("`messages.chatWith` has no {name}, so the agent name is not shown in the title. For a fixed title, use the `title` option."), n[r] = i;
152
+ }
153
+ for (let t in e) Object.hasOwn(e, t) || f(`ignoring inherited option \`messages.${t}\` -- only the object's own keys are used.`);
154
+ return n;
155
+ }
156
+ function b(e) {
94
157
  return typeof e == "object" && !!e && !Array.isArray(e);
95
158
  }
96
- var g = (e) => e == null || e === "";
97
- function _(e, t, n) {
159
+ var x = (e) => e == null || e === "";
160
+ function S(e, t, n) {
98
161
  let r = e[t];
99
- return r == null ? null : h(r) ? r : (u(`ignoring \`${n}\` -- expected an object.`), null);
162
+ return r == null ? null : b(r) ? r : (f(`ignoring \`${n}\` -- expected an object.`), null);
100
163
  }
101
- function v(e, t, n) {
102
- for (let r of Object.keys(e)) t.includes(r) || u(`ignoring unknown option \`${n}.${r}\`.`);
164
+ function C(e, t, n) {
165
+ for (let r of Object.keys(e)) t.includes(r) || f(`ignoring unknown option \`${n}.${r}\`.`);
103
166
  }
104
- function y(e, t, n) {
105
- if (!g(e)) {
167
+ function ee(e, t, n) {
168
+ if (!x(e)) {
106
169
  if (typeof e == "string" && t.includes(e)) return e;
107
- u(`ignoring \`${n}\` -- expected one of ${t.join(", ")}.`);
170
+ f(`ignoring \`${n}\` -- expected one of ${t.join(", ")}.`);
108
171
  }
109
172
  }
110
- var b = 200, x = /url\(|[@;{}\\]/i;
111
- function S(e) {
112
- if (!g(e)) {
173
+ var w = 200, T = /url\(|[@;{}\\]/i;
174
+ function E(e) {
175
+ if (!x(e)) {
113
176
  if (typeof e == "string") {
114
177
  let t = e.trim();
115
- if (t && t.length <= b && !x.test(t)) return t;
178
+ if (t && t.length <= w && !T.test(t)) return t;
116
179
  }
117
- u(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${b} characters, without url(), @, ;, {, } or \\.`);
180
+ f(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${w} characters, without url(), @, ;, {, } or \\.`);
118
181
  }
119
182
  }
120
- var C = [
183
+ var D = [
121
184
  "chat",
122
185
  "message",
123
186
  "sparkle"
124
- ], ee = ["chevron-down", "close"], w = /* @__PURE__ */ new WeakMap();
125
- function T(n) {
126
- let r = {
187
+ ], O = ["chevron-down", "close"], k = /* @__PURE__ */ new WeakMap();
188
+ function te(e) {
189
+ let t = {
127
190
  colors: {},
128
191
  fontFamily: void 0,
129
192
  launcher: {}
130
193
  };
131
- if (n == null) return r;
132
- if (!h(n)) return p(n), r;
133
- let i = w.get(n);
194
+ if (e == null) return t;
195
+ if (!b(e)) return g(e), t;
196
+ let i = k.get(e);
134
197
  if (i) return i;
135
- v(n, [
198
+ C(e, [
136
199
  "colors",
137
200
  "fonts",
138
201
  "launcher"
139
202
  ], "theme");
140
- let a = _(n, "colors", "theme.colors");
203
+ let a = S(e, "colors", "theme.colors");
141
204
  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.`));
205
+ C(a, r, "theme.colors");
206
+ for (let e of r) {
207
+ let n = a[e];
208
+ x(n) || (typeof n == "string" ? t.colors[e] = n : f(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`));
146
209
  }
147
210
  }
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");
211
+ let o = S(e, "fonts", "theme.fonts");
212
+ o && (C(o, ["family"], "theme.fonts"), t.fontFamily = E(o.family));
213
+ let s = S(e, "launcher", "theme.launcher");
151
214
  if (s) {
152
- v(s, [
215
+ C(s, [
153
216
  "icon",
154
217
  "iconUrl",
155
218
  "openIcon",
156
219
  "openIconUrl"
157
220
  ], "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);
221
+ let e = ee(s.icon, D, "theme.launcher.icon"), r = n(s.iconUrl, "theme.launcher.iconUrl"), i = ee(s.openIcon, O, "theme.launcher.openIcon"), a = n(s.openIconUrl, "theme.launcher.openIconUrl");
222
+ e && (t.launcher.icon = e), r && (t.launcher.iconUrl = r), i && (t.launcher.openIcon = i), a && (t.launcher.openIconUrl = a);
160
223
  }
161
- return w.set(n, r), r;
224
+ return k.set(e, t), t;
162
225
  }
163
- var E = {
226
+ var A = {
164
227
  offsetX: 20,
165
228
  offsetY: 20,
166
229
  launcherSize: 56,
167
230
  panelWidth: 360,
168
231
  panelHeight: 480
169
232
  };
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);
233
+ function j(e, t, n) {
234
+ return e == null ? n : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : (f(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`), n);
172
235
  }
173
- function O(e, t, n, r) {
236
+ function ne(e, t, n, r) {
174
237
  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;
238
+ return i !== e && f(`\`${t}\` ${e} is out of range (${r === Infinity ? `at least ${n}` : `${n}-${r}`}); using ${i}.`), i;
176
239
  }
177
- var k = /* @__PURE__ */ new WeakMap();
178
- function te(e) {
179
- let t = { ...E };
240
+ var re = /* @__PURE__ */ new WeakMap();
241
+ function ie(e) {
242
+ let t = { ...A };
180
243
  if (e == null) return t;
181
- if (!h(e)) return m(e), t;
182
- let n = k.get(e);
244
+ if (!b(e)) return _(e), t;
245
+ let n = re.get(e);
183
246
  if (n) return n;
184
- v(e, [
247
+ C(e, [
185
248
  "offset",
186
249
  "launcherSize",
187
250
  "panel"
188
251
  ], "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;
252
+ let r = S(e, "offset", "layout.offset");
253
+ r && (C(r, ["x", "y"], "layout.offset"), t.offsetX = j(r.x, "layout.offset.x", A.offsetX), t.offsetY = j(r.y, "layout.offset.y", A.offsetY)), t.launcherSize = ne(j(e.launcherSize, "layout.launcherSize", A.launcherSize), "layout.launcherSize", 24, 120);
254
+ let i = S(e, "panel", "layout.panel");
255
+ return i && (C(i, ["width", "height"], "layout.panel"), t.panelWidth = ne(j(i.width, "layout.panel.width", A.panelWidth), "layout.panel.width", 280, Infinity), t.panelHeight = ne(j(i.height, "layout.panel.height", A.panelHeight), "layout.panel.height", 320, Infinity)), re.set(e, t), t;
193
256
  }
194
257
  //#endregion
195
258
  //#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/dist/preact.mjs
196
- var A, ne, j, re, M, ie, ae, N, oe, se, ce, le, ue = {}, P = [], de = /^m(i|n|o|s|text|space)$/, fe = Array.isArray, pe = P.slice, F = Object.assign;
197
- function me(e) {
259
+ var M, ae, N, oe, se, ce, le, P, ue, de, fe, pe, me = {}, he = [], ge = /^m(i|n|o|s|text|space)$/, _e = Array.isArray, ve = he.slice, F = Object.assign;
260
+ function ye(e) {
198
261
  e && e.parentNode && e.remove();
199
262
  }
200
- function he(e, t, n, r, i) {
263
+ function be(e, t, n, r, i) {
201
264
  var a = {
202
265
  type: e,
203
266
  props: t,
@@ -209,16 +272,16 @@ function he(e, t, n, r, i) {
209
272
  __e: null,
210
273
  __c: null,
211
274
  constructor: void 0,
212
- __v: i || ++ne,
275
+ __v: i || ++ae,
213
276
  __i: -1,
214
277
  __u: 0
215
278
  };
216
- return !i && A.vnode && A.vnode(a), a;
279
+ return !i && M.vnode && M.vnode(a), a;
217
280
  }
218
281
  function I(e) {
219
282
  return e.children;
220
283
  }
221
- function ge(e, t) {
284
+ function xe(e, t) {
222
285
  this.props = e, this.context = t, this.__g = 0;
223
286
  }
224
287
  function L(e, t) {
@@ -226,30 +289,30 @@ function L(e, t) {
226
289
  for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) && n.__e) return n.__e;
227
290
  return typeof e.type != "function" || e.props.__P ? null : L(e);
228
291
  }
229
- function _e(e) {
292
+ function Se(e) {
230
293
  if ((e = e.__) && e.__c && !e.props.__P) return e.__e = null, e.__k.some(function(t) {
231
294
  return t && (e.__e = t.__e);
232
- }), _e(e);
295
+ }), Se(e);
233
296
  }
234
- function ve(e) {
235
- (8 & e.__g || !(e.__g |= 8) || !j.push(e) || M++) && re == A.debounceRendering || ((re = A.debounceRendering) || queueMicrotask)(ye);
297
+ function Ce(e) {
298
+ (8 & e.__g || !(e.__g |= 8) || !N.push(e) || se++) && oe == M.debounceRendering || ((oe = M.debounceRendering) || queueMicrotask)(we);
236
299
  }
237
- function ye() {
300
+ function we() {
238
301
  var e, t, n, r, i, a, o, s, c;
239
302
  try {
240
- for (t = 1; j.length;) j.length > t && j.sort(ie), 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 = F({ constructor: void 0 }, i)).__v = i.__v + 1, A.vnode && A.vnode(r), De(c, r, i, n.__n, c.namespaceURI, 32 & i.__u ? [a] : null, o, a || L(i), 32 & i.__u, s), r.__v = i.__v, r.__.__k[r.__i] = r, ke(o, r, s), i.__ = i.__e = null, r.__e != a && _e(r)));
303
+ for (t = 1; N.length;) N.length > t && N.sort(ce), e = N.shift(), t = N.length, 8 & e.__g && (r = void 0, i = void 0, a = (i = (n = e).__v).__e, o = [], s = [], (c = n.__P) && ((r = F({ constructor: void 0 }, i)).__v = i.__v + 1, M.vnode && M.vnode(r), Me(c, r, i, n.__n, c.namespaceURI, 32 & i.__u ? [a] : null, o, a || L(i), 32 & i.__u, s), r.__v = i.__v, r.__.__k[r.__i] = r, Pe(o, r, s), i.__ = i.__e = null, r.__e != a && Se(r)));
241
304
  } finally {
242
- j.length = M = 0;
305
+ N.length = se = 0;
243
306
  }
244
307
  }
245
- function be(e, t, n, r, i, a, o, s, c, l, u) {
246
- var d, f, p, m, h, g, _ = r.__k || P, v = t.length;
247
- for (c = xe(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = ~p.__i && _[p.__i] || ue, p.__i = d, g = De(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 && je(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h ||= m, 4 & p.__u ? (c = Se(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);
308
+ function Te(e, t, n, r, i, a, o, s, c, l, u) {
309
+ var d, f, p, m, h, g, _ = r.__k || he, v = t.length;
310
+ for (c = Ee(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = ~p.__i && _[p.__i] || me, p.__i = d, g = Me(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 && Ie(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h ||= m, 4 & p.__u ? (c = De(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);
248
311
  return n.__e = h, c;
249
312
  }
250
- function xe(e, t, n, r, i) {
313
+ function Ee(e, t, n, r, i) {
251
314
  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] = he(null, o) : fe(o) ? o = y[a] = he(I, { children: o }) : o.constructor === void 0 && o.__b ? o = y[a] = he(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 = Ce(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;
315
+ 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] = be(null, o) : _e(o) ? o = y[a] = be(I, { children: o }) : o.constructor === void 0 && o.__b ? o = y[a] = be(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 = Oe(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
316
  if (v) {
254
317
  for (u = [], d = [], a = 0; a < i; a++) if ((o = y[a]) && 2 & o.__u) {
255
318
  for (f = 0, p = u.length; f < p;) u[m = f + p >> 1] < o.__i ? f = m + 1 : p = m;
@@ -257,20 +320,20 @@ function xe(e, t, n, r, i) {
257
320
  }
258
321
  for (_ = u.length; a--;) d[a] && (d[a] == _ ? _-- : y[a].__u |= 4);
259
322
  }
260
- if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r = L(s)), Me(s, s));
323
+ if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r = L(s)), Le(s, s));
261
324
  return r;
262
325
  }
263
- function Se(e, t, n, r) {
326
+ function De(e, t, n, r) {
264
327
  var i, a;
265
328
  if (typeof e.type == "function") {
266
329
  if (e.props.__P) return t;
267
- if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t = Se(i[a], t, n, !1));
330
+ if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t = De(i[a], t, n, !1));
268
331
  return t;
269
332
  }
270
333
  for (t && !t.parentNode && (t = L(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;);
271
334
  return t;
272
335
  }
273
- function Ce(e, t, n, r) {
336
+ function Oe(e, t, n, r) {
274
337
  var i, a, o, s = e.key, c = e.type, l = t[n], u = l && !(2 & l.__u);
275
338
  if (l === null && s == null || u && s == l.key && c == l.type) return n;
276
339
  if (r > +!!u) {
@@ -278,18 +341,18 @@ function Ce(e, t, n, r) {
278
341
  }
279
342
  return -1;
280
343
  }
281
- function we(e, t, n) {
344
+ function ke(e, t, n) {
282
345
  n ??= "", t[0] == "-" ? e.setProperty(t, n) : e[t] = n;
283
346
  }
284
- function Te(e, t, n, r, i) {
347
+ function Ae(e, t, n, r, i) {
285
348
  var a;
286
349
  n: if (t == "style") {
287
350
  if (typeof n == "string") e.style.cssText = n;
288
351
  else {
289
- if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || we(e.style, t, "");
290
- if (n) for (t in n) r && n[t] == r[t] || we(e.style, t, n[t]);
352
+ if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || ke(e.style, t, "");
353
+ if (n) for (t in n) r && n[t] == r[t] || ke(e.style, t, n[t]);
291
354
  }
292
- } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(oe, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()), (e.__e ||= {})[t + a] = n, n ? r ? n[N] = r[N] : (n[N] = se, e.addEventListener(t, a ? le : ce, a)) : e.removeEventListener(t, a ? le : ce, a);
355
+ } else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(ue, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()), (e.__e ||= {})[t + a] = n, n ? r ? n[P] = r[P] : (n[P] = de, e.addEventListener(t, a ? pe : fe, a)) : e.removeEventListener(t, a ? pe : fe, a);
293
356
  else {
294
357
  if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
295
358
  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 {
@@ -299,17 +362,17 @@ function Te(e, t, n, r, i) {
299
362
  typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
300
363
  }
301
364
  }
302
- function Ee(e) {
365
+ function je(e) {
303
366
  return function(t) {
304
367
  if (this.__e) {
305
368
  var n = this.__e[t.type + e];
306
- if (t[ae] == null) t[ae] = se++;
307
- else if (t[ae] < n[N]) return;
308
- return n(A.event ? A.event(t) : t);
369
+ if (t[le] == null) t[le] = de++;
370
+ else if (t[le] < n[P]) return;
371
+ return n(M.event ? M.event(t) : t);
309
372
  }
310
373
  };
311
374
  }
312
- function De(e, t, n, r, i, a, o, s, c, l) {
375
+ function Me(e, t, n, r, i, a, o, s, c, l) {
313
376
  var u, d, f, p, m, h, g, _, v, y, b, x, S, C, ee, w, T, E, D, O, k = t.type;
314
377
  if (t.constructor !== void 0) return null;
315
378
  if (128 & n.__u && (c = 32 & n.__u, u = n.__c.__z)) {
@@ -323,28 +386,28 @@ function De(e, t, n, r, i, a, o, s, c, l) {
323
386
  else a.push(u);
324
387
  s = a[0];
325
388
  }
326
- (u = A.__b) && u(t);
389
+ (u = M.__b) && u(t);
327
390
  n: if (typeof k == "function") {
328
391
  m = o.length;
329
392
  try {
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 ge(y, S), h.constructor = k, h.render = Ne), 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 = F({}, h.__s)), F(h.__s, k.getDerivedStateFromProps(y, h.__s)))), g = h.props, _ = h.state, h.__v = t, n.__c) {
393
+ 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 xe(y, S), h.constructor = k, h.render = Re), 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 = F({}, h.__s)), F(h.__s, k.getDerivedStateFromProps(y, h.__s)))), g = h.props, _ = h.state, h.__v = t, n.__c) {
331
394
  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
395
  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) {
333
396
  e && (e.__ = t);
334
- }), P.push.apply(h.__h, h.__k), h.__k = [], h.__h.length && o.push(h), s = L(n);
397
+ }), he.push.apply(h.__h, h.__k), h.__k = [], h.__h.length && o.push(h), s = L(n);
335
398
  break n;
336
399
  }
337
400
  h.componentWillUpdate && h.componentWillUpdate(y, h.__s, S), b && h.componentDidUpdate && h.__h.push(function() {
338
401
  h.componentDidUpdate(g, _, v);
339
402
  });
340
403
  } 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), P.push.apply(h.__h, h.__k), h.__k = [];
404
+ if (h.context = S, h.props = y, h.__P = e, h.__g &= -5, C = M.__r, ee = 0, b) h.state = h.__s, h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), he.push.apply(h.__h, h.__k), h.__k = [];
342
405
  else do
343
406
  h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), h.state = h.__s;
344
407
  while (8 & h.__g && ++ee < 25);
345
408
  h.state = h.__s, h.getChildContext && (r = F({}, r, h.getChildContext())), b && n.__c && h.getSnapshotBeforeUpdate && (v = h.getSnapshotBeforeUpdate(g, _)), w = u && u.type === I && 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 && Me(e, e);
347
- }), n.__k = null), s = n.__k ? L(n, 0) : null), s = be(e, fe(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(me), h.__h.length && o.push(h), 1 & h.__g && (h.__g &= -4);
409
+ e && Le(e, e);
410
+ }), n.__k = null), s = n.__k ? L(n, 0) : null), s = Te(e, _e(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(ye), h.__h.length && o.push(h), 1 & h.__g && (h.__g &= -4);
348
411
  } catch (e) {
349
412
  if (o.length = m, t.__v = null, c || a) {
350
413
  if (e.then) {
@@ -364,30 +427,30 @@ function De(e, t, n, r, i, a, o, s, c, l) {
364
427
  a && (a[a.indexOf(s)] = null), E = s;
365
428
  }
366
429
  t.__c.__z || (t.__c.__z = E), t.__e = s;
367
- } else a && a.some(me);
430
+ } else a && a.some(ye);
368
431
  } else t.__e = n.__e;
369
- t.__k ||= n.__k || [], e.then || Oe(t), A.__e(e, t, n);
432
+ t.__k ||= n.__k || [], e.then || Ne(t), M.__e(e, t, n);
370
433
  }
371
- } else s = t.__e = Ae(n.__e, t, n, r, i, a, o, c, l, e);
372
- return (u = A.diffed) && u(t), 128 & t.__u ? void 0 : s;
434
+ } else s = t.__e = Fe(n.__e, t, n, r, i, a, o, c, l, e);
435
+ return (u = M.diffed) && u(t), 128 & t.__u ? void 0 : s;
373
436
  }
374
- function Oe(e) {
375
- e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(Oe));
437
+ function Ne(e) {
438
+ e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(Ne));
376
439
  }
377
- function ke(e, t, n) {
378
- for (var r = 0; r < n.length;) je(n[r++], n[r++], n[r++]);
379
- A.__c && A.__c(t, e), e.some(function(t) {
440
+ function Pe(e, t, n) {
441
+ for (var r = 0; r < n.length;) Ie(n[r++], n[r++], n[r++]);
442
+ M.__c && M.__c(t, e), e.some(function(t) {
380
443
  try {
381
444
  e = t.__h, t.__h = [], e.some(function(e) {
382
445
  e.call(t);
383
446
  });
384
447
  } catch (e) {
385
- A.__e(e, t.__v);
448
+ M.__e(e, t.__v);
386
449
  }
387
450
  });
388
451
  }
389
- function Ae(e, t, n, r, i, a, o, s, c, l) {
390
- var u, d, f, p, m, h, g, _, v, y = n.props || ue, b = t.props, x = t.type;
452
+ function Fe(e, t, n, r, i, a, o, s, c, l) {
453
+ var u, d, f, p, m, h, g, _, v, y = n.props || me, b = t.props, x = t.type;
391
454
  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
455
  for (u = 0; u < a.length; u++) if ((m = a[u]) && (x ? m.localName == x : m.nodeType == 3)) {
393
456
  e = m, a[u] = null;
@@ -396,44 +459,44 @@ function Ae(e, t, n, r, i, a, o, s, c, l) {
396
459
  }
397
460
  if (!e) {
398
461
  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;
462
+ e = _.createElementNS(i, x, b.is && b), s &&= (M.__m && M.__m(t, a), !1), a = null;
400
463
  }
401
464
  if (x) {
402
- if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a && pe.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 || Te(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) || Te(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" && de.test(x)) && (i = "http://www.w3.org/1999/xhtml"), be(l, fe(p) ? p : [p], t, n, r, i, a, o, a ? a[0] : n.__k && L(n, 0), s, c), a && a.some(me)), s && x != "textarea" || (u = "value", x == "progress" && h == null ? e.removeAttribute(u) : h == null || h === e[u] && (x != "progress" || h) || Te(e, u, h, y[u], i), u = "checked", g != null && g != e[u] && Te(e, u, g, y[u], i));
465
+ if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a && ve.call(l.childNodes), !s && a) for (y = {}, u = 0; u < e.attributes.length; u++) y[(m = e.attributes[u]).name] = m.value;
466
+ 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 || Ae(e, u, null, m, i);
467
+ 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) || Ae(e, u, m, y[u], i);
468
+ 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" && ge.test(x)) && (i = "http://www.w3.org/1999/xhtml"), Te(l, _e(p) ? p : [p], t, n, r, i, a, o, a ? a[0] : n.__k && L(n, 0), s, c), a && a.some(ye)), s && x != "textarea" || (u = "value", x == "progress" && h == null ? e.removeAttribute(u) : h == null || h === e[u] && (x != "progress" || h) || Ae(e, u, h, y[u], i), u = "checked", g != null && g != e[u] && Ae(e, u, g, y[u], i));
406
469
  } else y === b || s && e.data == b || (e.data = b);
407
470
  return e;
408
471
  }
409
- function je(e, t, n) {
472
+ function Ie(e, t, n) {
410
473
  try {
411
474
  typeof e == "function" ? (typeof e.__u == "function" && e.__u(), (typeof e.__u != "function" || t) && (e.__u = e(t))) : e.current = t;
412
475
  } catch (e) {
413
- A.__e(e, n);
476
+ M.__e(e, n);
414
477
  }
415
478
  }
416
- function Me(e, t, n) {
479
+ function Le(e, t, n) {
417
480
  var r, i;
418
- if (A.unmount && A.unmount(e), !(r = e.ref) || r.current && r.current != e.__e || je(r, null, t), r = e.__c) {
481
+ if (M.unmount && M.unmount(e), !(r = e.ref) || r.current && r.current != e.__e || Ie(r, null, t), r = e.__c) {
419
482
  if (r.componentWillUnmount) try {
420
483
  r.componentWillUnmount();
421
484
  } catch (e) {
422
- A.__e(e, t);
485
+ M.__e(e, t);
423
486
  }
424
487
  r.__P = r.__n = null;
425
488
  }
426
- if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && Me(r[i], t, typeof e.type != "function" || n && !e.props.__P);
427
- (r = e.__e) && (n || me(r), r.__e && (r.__e = null)), e.__e = e.__c = e.__ = null;
489
+ if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && Le(r[i], t, typeof e.type != "function" || n && !e.props.__P);
490
+ (r = e.__e) && (n || ye(r), r.__e && (r.__e = null)), e.__e = e.__c = e.__ = null;
428
491
  }
429
- function Ne(e, t, n) {
492
+ function Re(e, t, n) {
430
493
  return this.constructor(e, n);
431
494
  }
432
- function Pe(e, t) {
495
+ function ze(e, t) {
433
496
  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 = he(I, { children: [e] }), i = [], a = [], De(t, t.__k, r || ue, ue, t.namespaceURI, r ? null : t.firstChild ? pe.call(t.childNodes) : null, i, r ? r.__e : t.firstChild, n, a), ke(i, t.__k, a), t.__k.props.children = null;
497
+ M.__ && M.__(e, t), t.nodeType == 9 && (t = t.documentElement), r = (n = e && 32 & e.__u) ? null : t.__k, t.__k = be(I, { children: [e] }), i = [], a = [], Me(t, t.__k, r || me, me, t.namespaceURI, r ? null : t.firstChild ? ve.call(t.childNodes) : null, i, r ? r.__e : t.firstChild, n, a), Pe(i, t.__k, a), t.__k.props.children = null;
435
498
  }
436
- A = { __e: function(e, t, n, r) {
499
+ M = { __e: function(e, t, n, r) {
437
500
  for (var i, a, o; t = t.__;) if ((i = t.__c) && !(1 & i.__g)) {
438
501
  i.__g |= 4;
439
502
  try {
@@ -442,34 +505,34 @@ A = { __e: function(e, t, n, r) {
442
505
  e = t, o = 0;
443
506
  }
444
507
  }
445
- throw M = 0, e;
446
- } }, ne = 0, ge.prototype.setState = function(e, t) {
508
+ throw se = 0, e;
509
+ } }, ae = 0, xe.prototype.setState = function(e, t) {
447
510
  var n = this.__s;
448
- n && n != this.state || (n = this.__s = F({}, this.state)), typeof e == "function" && (e = e(F({}, n), this.props)), e && (F(n, e), this.__v && (t && this.__k.push(t), ve(this)));
449
- }, ge.prototype.forceUpdate = function(e) {
450
- this.__v && (this.__g |= 4, e && this.__h.push(e), ve(this));
451
- }, ge.prototype.render = I, j = [], M = 0, ie = function(e, t) {
511
+ n && n != this.state || (n = this.__s = F({}, this.state)), typeof e == "function" && (e = e(F({}, n), this.props)), e && (F(n, e), this.__v && (t && this.__k.push(t), Ce(this)));
512
+ }, xe.prototype.forceUpdate = function(e) {
513
+ this.__v && (this.__g |= 4, e && this.__h.push(e), Ce(this));
514
+ }, xe.prototype.render = I, N = [], se = 0, ce = function(e, t) {
452
515
  return e.__v.__b - t.__v.__b;
453
- }, ae = Symbol(), N = Symbol(), oe = /(PointerCapture)$|Capture$/i, se = 0, ce = Ee(!1), le = Ee(!0);
516
+ }, le = Symbol(), P = Symbol(), ue = /(PointerCapture)$|Capture$/i, de = 0, fe = je(!1), pe = je(!0);
454
517
  //#endregion
455
518
  //#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/hooks/dist/hooks.mjs
456
- var R, z, Fe, Ie, Le = Object.is, B = 0, Re = [], ze = [], V = A, Be = V.__b, Ve = V.__r, He = V.diffed, Ue = V.__c, We = V.unmount, Ge = V.__;
457
- function Ke(e, t) {
458
- V.__h && V.__h(z, e, B || t), B = 0;
519
+ var R, z, Be, Ve, He = Object.is, Ue = 0, We = [], Ge = [], B = M, Ke = B.__b, qe = B.__r, Je = B.diffed, Ye = B.__c, Xe = B.unmount, Ze = B.__;
520
+ function Qe(e, t) {
521
+ B.__h && B.__h(z, e, Ue || t), Ue = 0;
459
522
  var n = z.__H || (z.__H = {
460
523
  __: [],
461
524
  __h: []
462
525
  });
463
526
  return e >= n.__.length && n.__.push({}), n.__[e];
464
527
  }
465
- function qe(e) {
466
- return B = 1, Je(nt, e);
528
+ function $e(e) {
529
+ return Ue = 1, et(ut, e);
467
530
  }
468
- function Je(e, t, n) {
469
- var r = Ke(R++, 2);
470
- if (r.t = e, !r.__c && (r.__ = [n ? n(t) : nt(void 0, t), function(e) {
531
+ function et(e, t, n) {
532
+ var r = Qe(R++, 2);
533
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : ut(void 0, t), function(e) {
471
534
  var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
472
- Le(t, n) || (r.__N = [n, r.__[1]], r.__c.setState({}));
535
+ He(t, n) || (r.__N = [n, r.__[1]], r.__c.setState({}));
473
536
  }], r.__c = z, !z.__f)) {
474
537
  z.__f = !0;
475
538
  var i = z.shouldComponentUpdate;
@@ -478,7 +541,7 @@ function Je(e, t, n) {
478
541
  if (!r) return !0;
479
542
  var a = !1, o = this.props != e;
480
543
  if (r.__.some(function(e) {
481
- e.__N && (a = !0, Le(e.__[0], e.__N[0]) || (o = !0));
544
+ e.__N && (a = !0, He(e.__[0], e.__N[0]) || (o = !0));
482
545
  }), i) {
483
546
  var s = i.call(this, e, t, n);
484
547
  return a ? s || o : s;
@@ -488,67 +551,71 @@ function Je(e, t, n) {
488
551
  }
489
552
  return r.__;
490
553
  }
491
- function H(e, t) {
492
- var n = Ke(R++, 3);
493
- !V.__s && tt(n.__H, t) && (n.__P = !0, n.__ = e, n.u = t, z.__H.__h.push(n));
554
+ function tt(e, t) {
555
+ var n = Qe(R++, 3);
556
+ !B.__s && lt(n.__H, t) && (n.__P = !0, n.__ = e, n.u = t, z.__H.__h.push(n));
557
+ }
558
+ function nt(e, t) {
559
+ var n = Qe(R++, 4);
560
+ !B.__s && lt(n.__H, t) && (n.__P = !1, n.__ = e, n.u = t, z.__h.push(n));
494
561
  }
495
- function U(e) {
496
- return B = 5, Ye(function() {
562
+ function V(e) {
563
+ return Ue = 5, rt(function() {
497
564
  return { current: e };
498
565
  }, []);
499
566
  }
500
- function Ye(e, t) {
501
- var n = Ke(R++, 7);
502
- return tt(n.__H, t) && (n.__ = e(), n.__H = t), n.__;
567
+ function rt(e, t) {
568
+ var n = Qe(R++, 7);
569
+ return lt(n.__H, t) && (n.__ = e(), n.__H = t), n.__;
503
570
  }
504
- function Xe() {
571
+ function it() {
505
572
  var e;
506
573
  do {
507
- for (; e = ze.shift();) try {
508
- W(e);
574
+ for (; e = Ge.shift();) try {
575
+ H(e);
509
576
  } catch (t) {
510
- V.__e(t, { __: (e = e.__P) && e.__v });
577
+ B.__e(t, { __: (e = e.__P) && e.__v });
511
578
  }
512
- for (; e = Re.shift();) {
579
+ for (; e = We.shift();) {
513
580
  var t = e.__H;
514
581
  if (e.__P && t) try {
515
- t.__h.some(W), t.__h.some(et), t.__h = [];
582
+ t.__h.some(H), t.__h.some(ct), t.__h = [];
516
583
  } catch (n) {
517
- t.__h = [], V.__e(n, e.__v);
584
+ t.__h = [], B.__e(n, e.__v);
518
585
  }
519
586
  }
520
- } while (ze.length);
521
- }
522
- V.__b = function(e) {
523
- z = null, Be && Be(e);
524
- }, V.__ = function(e, t) {
525
- e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Ge && Ge(e, t);
526
- }, V.__r = function(e) {
527
- Ve && Ve(e), R = 0;
587
+ } while (Ge.length);
588
+ }
589
+ B.__b = function(e) {
590
+ z = null, Ke && Ke(e);
591
+ }, B.__ = function(e, t) {
592
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Ze && Ze(e, t);
593
+ }, B.__r = function(e) {
594
+ qe && qe(e), R = 0;
528
595
  var t = (z = e.__c).__H;
529
- t && (Fe == z ? z.__h = [] : (t.__h.some(W), t.__h.some(et), R = 0), t.__h = [], t.__.some(function(e) {
596
+ t && (Be == z ? z.__h = [] : (t.__h.some(H), t.__h.some(ct), R = 0), t.__h = [], t.__.some(function(e) {
530
597
  e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
531
- })), Fe = z;
532
- }, V.diffed = function(e) {
533
- He && He(e);
598
+ })), Be = z;
599
+ }, B.diffed = function(e) {
600
+ Je && Je(e);
534
601
  var t = e.__c;
535
- t && t.__H && (t.__H.__h.length && $e(Re.push(t)), t.__H.__.some(function(e) {
602
+ t && t.__H && (t.__H.__h.length && st(We.push(t)), t.__H.__.some(function(e) {
536
603
  e.u && (e.__H = e.u);
537
- })), Fe = z = null;
538
- }, V.__c = function(e, t) {
604
+ })), Be = z = null;
605
+ }, B.__c = function(e, t) {
539
606
  t.some(function(e) {
540
607
  try {
541
- e.__h.some(W), e.__h = e.__h.filter(function(e) {
542
- return !e.__ || et(e);
608
+ e.__h.some(H), e.__h = e.__h.filter(function(e) {
609
+ return !e.__ || ct(e);
543
610
  });
544
611
  } catch (n) {
545
612
  t.some(function(e) {
546
613
  e.__h &&= [];
547
- }), t = [], V.__e(n, e.__v);
614
+ }), t = [], B.__e(n, e.__v);
548
615
  }
549
- }), Ue && Ue(e, t);
550
- }, V.unmount = function(e) {
551
- We && We(e);
616
+ }), Ye && Ye(e, t);
617
+ }, B.unmount = function(e) {
618
+ Xe && Xe(e);
552
619
  var t, n, r = e.__c;
553
620
  r && r.__H && (r.__H.__.some(function(r) {
554
621
  try {
@@ -557,44 +624,44 @@ V.__b = function(e) {
557
624
  for (n = e.__; n && (!n.__c || !n.__c.__P);) n = n.__;
558
625
  n &&= n.__c;
559
626
  }
560
- r.__P = n, $e(ze.push(r));
561
- } else W(r);
627
+ r.__P = n, st(Ge.push(r));
628
+ } else H(r);
562
629
  } catch (e) {
563
630
  t = e;
564
631
  }
565
- }), r.__H = void 0, t && V.__e(t, r.__v));
632
+ }), r.__H = void 0, t && B.__e(t, r.__v));
566
633
  };
567
- var Ze = typeof requestAnimationFrame == "function";
568
- function Qe(e) {
634
+ var at = typeof requestAnimationFrame == "function";
635
+ function ot(e) {
569
636
  var t, n = function() {
570
- clearTimeout(r), Ze && cancelAnimationFrame(t), setTimeout(e);
637
+ clearTimeout(r), at && cancelAnimationFrame(t), setTimeout(e);
571
638
  }, r = setTimeout(n, 35);
572
- Ze && (t = requestAnimationFrame(n));
639
+ at && (t = requestAnimationFrame(n));
573
640
  }
574
- function $e(e) {
575
- e != 1 && Ie == V.requestAnimationFrame || ((Ie = V.requestAnimationFrame) || Qe)(Xe);
641
+ function st(e) {
642
+ e != 1 && Ve == B.requestAnimationFrame || ((Ve = B.requestAnimationFrame) || ot)(it);
576
643
  }
577
- function W(e) {
644
+ function H(e) {
578
645
  var t = z, n = e.__c;
579
646
  typeof n == "function" && (e.__c = void 0, n()), z = t;
580
647
  }
581
- function et(e) {
648
+ function ct(e) {
582
649
  var t = z;
583
650
  e.__c = e.__(), z = t;
584
651
  }
585
- function tt(e, t) {
652
+ function lt(e, t) {
586
653
  return !e || e.length != t.length || t.some(function(t, n) {
587
- return !Le(t, e[n]);
654
+ return !He(t, e[n]);
588
655
  });
589
656
  }
590
- function nt(e, t) {
657
+ function ut(e, t) {
591
658
  return typeof t == "function" ? t(e) : t;
592
659
  }
593
660
  //#endregion
594
661
  //#region node_modules/.pnpm/preact@11.0.0/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
595
- var rt = 0;
662
+ var dt = 0;
596
663
  Array.isArray;
597
- function G(e, t, n, r, i, a) {
664
+ function U(e, t, n, r, i, a) {
598
665
  t ||= {};
599
666
  var o, s, c = t;
600
667
  if ("ref" in c && typeof e != "function") for (s in c = {}, t) s == "ref" ? o = t[s] : c[s] = t[s];
@@ -609,16 +676,16 @@ function G(e, t, n, r, i, a) {
609
676
  __e: null,
610
677
  __c: null,
611
678
  constructor: void 0,
612
- __v: --rt,
679
+ __v: --dt,
613
680
  __i: -1,
614
681
  __u: 0
615
682
  };
616
- return (i || a) && (l.__source = i, l.__self = a), A.vnode && A.vnode(l), l;
683
+ return (i || a) && (l.__source = i, l.__self = a), M.vnode && M.vnode(l), l;
617
684
  }
618
685
  //#endregion
619
686
  //#region src/components/icons.tsx
620
- function K({ name: e, size: t, children: n }) {
621
- return /* @__PURE__ */ G("svg", {
687
+ function W({ name: e, size: t, children: n }) {
688
+ return /* @__PURE__ */ U("svg", {
622
689
  "data-icon": e,
623
690
  "aria-hidden": "true",
624
691
  focusable: "false",
@@ -633,180 +700,505 @@ function K({ name: e, size: t, children: n }) {
633
700
  children: n
634
701
  });
635
702
  }
636
- function it({ size: e = 26 }) {
637
- return /* @__PURE__ */ G(K, {
703
+ function ft({ size: e = 26 }) {
704
+ return /* @__PURE__ */ U(W, {
638
705
  name: "chat",
639
706
  size: e,
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", {
707
+ children: [/* @__PURE__ */ U("path", { d: "M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z" }), /* @__PURE__ */ U("path", {
641
708
  d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
642
709
  "stroke-width": "2.5"
643
710
  })]
644
711
  });
645
712
  }
646
- function at({ size: e = 26 }) {
647
- return /* @__PURE__ */ G(K, {
713
+ function pt({ size: e = 26 }) {
714
+ return /* @__PURE__ */ U(W, {
648
715
  name: "message",
649
716
  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" })
717
+ children: /* @__PURE__ */ U("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
718
  });
652
719
  }
653
- function ot({ size: e = 26 }) {
654
- return /* @__PURE__ */ G(K, {
720
+ function mt({ size: e = 26 }) {
721
+ return /* @__PURE__ */ U(W, {
655
722
  name: "sparkle",
656
723
  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" })]
724
+ children: [/* @__PURE__ */ U("path", { d: "M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z" }), /* @__PURE__ */ U("path", { d: "M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z" })]
658
725
  });
659
726
  }
660
- function st({ size: e = 26 }) {
661
- return /* @__PURE__ */ G(K, {
727
+ function ht({ size: e = 26 }) {
728
+ return /* @__PURE__ */ U(W, {
662
729
  name: "chevron-down",
663
730
  size: e,
664
- children: /* @__PURE__ */ G("path", { d: "M6 9l6 6 6-6" })
731
+ children: /* @__PURE__ */ U("path", { d: "M6 9l6 6 6-6" })
665
732
  });
666
733
  }
667
- function ct({ size: e = 18 }) {
668
- return /* @__PURE__ */ G(K, {
734
+ function gt({ size: e = 18 }) {
735
+ return /* @__PURE__ */ U(W, {
669
736
  name: "close",
670
737
  size: e,
671
- children: /* @__PURE__ */ G("path", { d: "M6 6l12 12M18 6L6 18" })
738
+ children: /* @__PURE__ */ U("path", { d: "M6 6l12 12M18 6L6 18" })
672
739
  });
673
740
  }
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, {
741
+ var _t = "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";
742
+ function vt({ size: e = 16 }) {
743
+ return /* @__PURE__ */ U(W, {
677
744
  name: "thumb-up",
678
745
  size: e,
679
- children: /* @__PURE__ */ G("path", { d: lt })
746
+ children: /* @__PURE__ */ U("path", { d: _t })
680
747
  });
681
748
  }
682
- function dt({ size: e = 16 }) {
683
- return /* @__PURE__ */ G(K, {
749
+ function yt({ size: e = 16 }) {
750
+ return /* @__PURE__ */ U(W, {
684
751
  name: "thumb-down",
685
752
  size: e,
686
- children: /* @__PURE__ */ G("path", {
687
- d: lt,
753
+ children: /* @__PURE__ */ U("path", {
754
+ d: _t,
688
755
  transform: "matrix(1 0 0 -1 0 24)"
689
756
  })
690
757
  });
691
758
  }
692
759
  //#endregion
693
760
  //#region src/components/Launcher.tsx
694
- var ft = {
695
- chat: it,
696
- message: at,
697
- sparkle: ot
698
- }, pt = {
699
- "chevron-down": st,
700
- close: ct
761
+ var bt = {
762
+ chat: ft,
763
+ message: pt,
764
+ sparkle: mt
765
+ }, xt = {
766
+ "chevron-down": ht,
767
+ close: gt
701
768
  };
702
- function mt({ isOpen: e, onClick: t, iconUrl: n, icon: r = "chat", openIconUrl: i, openIcon: a = "chevron-down", buttonRef: o }) {
703
- let [s, c] = qe("loading"), [l, u] = qe("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", {
769
+ function St({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl: a, openIcon: o = "chevron-down", buttonRef: s, text: c = e }) {
770
+ let [l, u] = $e("loading"), [d, f] = $e("loading"), p = r !== void 0 && l !== "failed", m = a !== void 0 && d !== "failed", h = p && !t && l === "loaded", g = m && t && d === "loaded", _ = bt[i] ?? ft, v = xt[o] ?? ht;
771
+ return /* @__PURE__ */ U("button", {
705
772
  type: "button",
706
773
  class: "whoo-widget-launcher",
707
- onClick: t,
708
- "aria-label": e ? "Close chat" : "Open chat",
709
- ref: o,
774
+ onClick: n,
775
+ "aria-label": t ? c.closeChat : c.openChat,
776
+ ref: s,
710
777
  children: [
711
- e ? m ? null : /* @__PURE__ */ G(g, {}) : p ? null : /* @__PURE__ */ G(h, {}),
712
- d ? /* @__PURE__ */ G("img", {
778
+ t ? g ? null : /* @__PURE__ */ U(v, {}) : h ? null : /* @__PURE__ */ U(_, {}),
779
+ p ? /* @__PURE__ */ U("img", {
713
780
  class: "whoo-widget-launcher-icon-image",
714
- src: n,
781
+ src: r,
715
782
  alt: "",
716
783
  referrerpolicy: "no-referrer",
717
- hidden: !p,
718
- onLoad: () => c("loaded"),
719
- onError: () => c("failed")
784
+ hidden: !h,
785
+ onLoad: () => u("loaded"),
786
+ onError: () => u("failed")
720
787
  }) : null,
721
- f ? /* @__PURE__ */ G("img", {
788
+ m ? /* @__PURE__ */ U("img", {
722
789
  class: "whoo-widget-launcher-icon-image",
723
- src: i,
790
+ src: a,
724
791
  alt: "",
725
792
  referrerpolicy: "no-referrer",
726
- hidden: !m,
727
- onLoad: () => u("loaded"),
728
- onError: () => u("failed")
793
+ hidden: !g,
794
+ onLoad: () => f("loaded"),
795
+ onError: () => f("failed")
729
796
  }) : null
730
797
  ]
731
798
  });
732
799
  }
733
800
  //#endregion
801
+ //#region src/i18n/index.ts
802
+ var Ct = {
803
+ en: e,
804
+ fr: {
805
+ openChat: "Ouvrir le chat",
806
+ closeChat: "Fermer le chat",
807
+ chatWith: "Discuter avec {name}",
808
+ newConversation: "Nouvelle conversation",
809
+ conversation: "Conversation",
810
+ you: "Vous",
811
+ message: "Message",
812
+ send: "Envoyer",
813
+ lookingItUp: "Je recherche l’information pour vous…",
814
+ goodResponse: "Réponse utile",
815
+ badResponse: "Réponse peu utile",
816
+ additionalFeedback: "Commentaire supplémentaire",
817
+ feedbackPlaceholder: "Qu’est-ce qui n’allait pas ? (facultatif)",
818
+ feedbackCategory: "Catégorie du commentaire",
819
+ selectReason: "Choisissez un motif (facultatif)",
820
+ categoryFactual: "Erreur factuelle",
821
+ categoryIncomplete: "Réponse incomplète",
822
+ categoryTone: "Ton inapproprié",
823
+ categoryOther: "Autre",
824
+ submit: "Envoyer le commentaire",
825
+ cancel: "Annuler",
826
+ feedbackThanks: "Merci pour votre commentaire",
827
+ feedbackFailed: "Impossible d’envoyer votre commentaire",
828
+ conversationCleared: "Conversation effacée",
829
+ genericError: "Une erreur s’est produite. Veuillez réessayer.",
830
+ sessionExpired: "Cette session de chat a expiré. Rechargez la page pour continuer."
831
+ },
832
+ es: {
833
+ openChat: "Abrir chat",
834
+ closeChat: "Cerrar chat",
835
+ chatWith: "Chat con {name}",
836
+ newConversation: "Nueva conversación",
837
+ conversation: "Conversación",
838
+ you: "Usted",
839
+ message: "Mensaje",
840
+ send: "Enviar",
841
+ lookingItUp: "Estoy buscando esa información…",
842
+ goodResponse: "Buena respuesta",
843
+ badResponse: "Mala respuesta",
844
+ additionalFeedback: "Comentarios adicionales",
845
+ feedbackPlaceholder: "¿Qué estuvo mal? (opcional)",
846
+ feedbackCategory: "Tipo de problema",
847
+ selectReason: "Seleccione un motivo (opcional)",
848
+ categoryFactual: "Información incorrecta",
849
+ categoryIncomplete: "Respuesta incompleta",
850
+ categoryTone: "Tono inadecuado",
851
+ categoryOther: "Otro",
852
+ submit: "Enviar comentarios",
853
+ cancel: "Cancelar",
854
+ feedbackThanks: "Gracias por sus comentarios",
855
+ feedbackFailed: "No se pudieron enviar sus comentarios",
856
+ conversationCleared: "Se inició una nueva conversación",
857
+ genericError: "Algo salió mal. Inténtelo de nuevo.",
858
+ sessionExpired: "Esta sesión de chat expiró. Vuelva a cargar la página para continuar."
859
+ },
860
+ pt: {
861
+ openChat: "Abrir chat",
862
+ closeChat: "Fechar chat",
863
+ chatWith: "Conversa com {name}",
864
+ newConversation: "Nova conversa",
865
+ conversation: "Conversa",
866
+ you: "Você",
867
+ message: "Mensagem",
868
+ send: "Enviar",
869
+ lookingItUp: "Estou buscando essa informação…",
870
+ goodResponse: "Boa resposta",
871
+ badResponse: "Resposta ruim",
872
+ additionalFeedback: "Comentários adicionais",
873
+ feedbackPlaceholder: "O que estava errado? (opcional)",
874
+ feedbackCategory: "Categoria do feedback",
875
+ selectReason: "Selecione um motivo (opcional)",
876
+ categoryFactual: "Informação incorreta",
877
+ categoryIncomplete: "Resposta incompleta",
878
+ categoryTone: "Tom inadequado",
879
+ categoryOther: "Outro",
880
+ submit: "Enviar feedback",
881
+ cancel: "Cancelar",
882
+ feedbackThanks: "Agradecemos seu feedback",
883
+ feedbackFailed: "Não foi possível enviar o feedback",
884
+ conversationCleared: "Nova conversa iniciada",
885
+ genericError: "Algo deu errado. Tente novamente.",
886
+ sessionExpired: "Esta sessão de chat expirou. Recarregue a página para continuar."
887
+ },
888
+ de: {
889
+ openChat: "Chat öffnen",
890
+ closeChat: "Chat schließen",
891
+ chatWith: "Chat mit {name}",
892
+ newConversation: "Neue Unterhaltung",
893
+ conversation: "Unterhaltung",
894
+ you: "Sie",
895
+ message: "Nachricht",
896
+ send: "Senden",
897
+ lookingItUp: "Ich suche die Informationen für Sie heraus…",
898
+ goodResponse: "Gute Antwort",
899
+ badResponse: "Schlechte Antwort",
900
+ additionalFeedback: "Zusätzliches Feedback",
901
+ feedbackPlaceholder: "Was war falsch? (optional)",
902
+ feedbackCategory: "Feedback-Kategorie",
903
+ selectReason: "Grund auswählen (optional)",
904
+ categoryFactual: "Faktenfehler",
905
+ categoryIncomplete: "Unvollständig",
906
+ categoryTone: "Unpassender Ton",
907
+ categoryOther: "Sonstiges",
908
+ submit: "Absenden",
909
+ cancel: "Abbrechen",
910
+ feedbackThanks: "Danke für Ihr Feedback",
911
+ feedbackFailed: "Feedback konnte nicht gesendet werden",
912
+ conversationCleared: "Neue Unterhaltung gestartet",
913
+ genericError: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.",
914
+ sessionExpired: "Diese Chat-Sitzung ist abgelaufen. Laden Sie die Seite neu, um fortzufahren."
915
+ },
916
+ it: {
917
+ openChat: "Apri la chat",
918
+ closeChat: "Chiudi la chat",
919
+ chatWith: "Chat con {name}",
920
+ newConversation: "Nuova conversazione",
921
+ conversation: "Conversazione",
922
+ you: "Tu",
923
+ message: "Messaggio",
924
+ send: "Invia",
925
+ lookingItUp: "Sto cercando le informazioni richieste…",
926
+ goodResponse: "Risposta utile",
927
+ badResponse: "Risposta non utile",
928
+ additionalFeedback: "Commenti aggiuntivi",
929
+ feedbackPlaceholder: "Che cosa non andava? (facoltativo)",
930
+ feedbackCategory: "Categoria del feedback",
931
+ selectReason: "Seleziona un motivo (facoltativo)",
932
+ categoryFactual: "Informazione errata",
933
+ categoryIncomplete: "Risposta incompleta",
934
+ categoryTone: "Tono non adeguato",
935
+ categoryOther: "Altro",
936
+ submit: "Invia feedback",
937
+ cancel: "Annulla",
938
+ feedbackThanks: "Grazie per il feedback",
939
+ feedbackFailed: "Impossibile inviare il feedback",
940
+ conversationCleared: "Nuova conversazione avviata",
941
+ genericError: "Si è verificato un errore. Riprovi.",
942
+ sessionExpired: "Questa sessione di chat è scaduta. Ricarichi la pagina per continuare."
943
+ },
944
+ ja: {
945
+ openChat: "チャットを開く",
946
+ closeChat: "チャットを閉じる",
947
+ chatWith: "{name}とチャット",
948
+ newConversation: "新しい会話",
949
+ conversation: "会話",
950
+ you: "あなた",
951
+ message: "メッセージ",
952
+ send: "送信",
953
+ lookingItUp: "確認しています…",
954
+ goodResponse: "良い回答",
955
+ badResponse: "良くない回答",
956
+ additionalFeedback: "追加のフィードバック",
957
+ feedbackPlaceholder: "何が問題でしたか?(任意)",
958
+ feedbackCategory: "フィードバックの種類",
959
+ selectReason: "理由を選択(任意)",
960
+ categoryFactual: "事実の誤り",
961
+ categoryIncomplete: "回答が不十分",
962
+ categoryTone: "不適切な口調",
963
+ categoryOther: "その他",
964
+ submit: "フィードバックを送信",
965
+ cancel: "キャンセル",
966
+ feedbackThanks: "フィードバックありがとうございます",
967
+ feedbackFailed: "フィードバックを送信できませんでした",
968
+ conversationCleared: "会話を消去しました",
969
+ genericError: "エラーが発生しました。もう一度お試しください。",
970
+ sessionExpired: "このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。"
971
+ },
972
+ zh: {
973
+ openChat: "打开聊天",
974
+ closeChat: "关闭聊天",
975
+ chatWith: "与{name}聊天",
976
+ newConversation: "新对话",
977
+ conversation: "对话",
978
+ you: "您",
979
+ message: "消息",
980
+ send: "发送",
981
+ lookingItUp: "正在为您查找……",
982
+ goodResponse: "回答很好",
983
+ badResponse: "回答不好",
984
+ additionalFeedback: "补充反馈",
985
+ feedbackPlaceholder: "哪里有问题?(可选)",
986
+ feedbackCategory: "反馈类别",
987
+ selectReason: "选择原因(可选)",
988
+ categoryFactual: "事实错误",
989
+ categoryIncomplete: "回答不完整",
990
+ categoryTone: "语气不当",
991
+ categoryOther: "其他",
992
+ submit: "提交",
993
+ cancel: "取消",
994
+ feedbackThanks: "感谢您的反馈",
995
+ feedbackFailed: "反馈提交失败",
996
+ conversationCleared: "对话已清除",
997
+ genericError: "出了点问题,请重试。",
998
+ sessionExpired: "此聊天会话已过期。请刷新页面后继续。"
999
+ },
1000
+ ru: {
1001
+ openChat: "Открыть чат",
1002
+ closeChat: "Закрыть чат",
1003
+ chatWith: "Чат с ассистентом {name}",
1004
+ newConversation: "Новый диалог",
1005
+ conversation: "Диалог",
1006
+ you: "Вы",
1007
+ message: "Сообщение",
1008
+ send: "Отправить",
1009
+ lookingItUp: "Ищу информацию…",
1010
+ goodResponse: "Хороший ответ",
1011
+ badResponse: "Плохой ответ",
1012
+ additionalFeedback: "Дополнительный комментарий",
1013
+ feedbackPlaceholder: "Что было не так? (необязательно)",
1014
+ feedbackCategory: "Категория отзыва",
1015
+ selectReason: "Выберите причину (необязательно)",
1016
+ categoryFactual: "Фактическая ошибка",
1017
+ categoryIncomplete: "Неполный ответ",
1018
+ categoryTone: "Неподходящий тон",
1019
+ categoryOther: "Другое",
1020
+ submit: "Отправить отзыв",
1021
+ cancel: "Отмена",
1022
+ feedbackThanks: "Спасибо за отзыв",
1023
+ feedbackFailed: "Не удалось отправить отзыв",
1024
+ conversationCleared: "Диалог очищен",
1025
+ genericError: "Что-то пошло не так. Попробуйте ещё раз.",
1026
+ sessionExpired: "Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить."
1027
+ },
1028
+ hi: {
1029
+ openChat: "चैट खोलें",
1030
+ closeChat: "चैट बंद करें",
1031
+ chatWith: "{name} से चैट करें",
1032
+ newConversation: "नई बातचीत",
1033
+ conversation: "बातचीत",
1034
+ you: "आप",
1035
+ message: "संदेश",
1036
+ send: "भेजें",
1037
+ lookingItUp: "आपके लिए जानकारी खोजी जा रही है…",
1038
+ goodResponse: "अच्छा जवाब",
1039
+ badResponse: "ख़राब जवाब",
1040
+ additionalFeedback: "अतिरिक्त फ़ीडबैक",
1041
+ feedbackPlaceholder: "क्या ग़लत था? (वैकल्पिक)",
1042
+ feedbackCategory: "फ़ीडबैक की श्रेणी",
1043
+ selectReason: "कारण चुनें (वैकल्पिक)",
1044
+ categoryFactual: "तथ्यात्मक त्रुटि",
1045
+ categoryIncomplete: "अधूरा जवाब",
1046
+ categoryTone: "अनुचित लहजा",
1047
+ categoryOther: "अन्य",
1048
+ submit: "सबमिट करें",
1049
+ cancel: "रद्द करें",
1050
+ feedbackThanks: "आपके फ़ीडबैक के लिए धन्यवाद",
1051
+ feedbackFailed: "फ़ीडबैक नहीं भेजा जा सका",
1052
+ conversationCleared: "बातचीत मिटा दी गई",
1053
+ genericError: "कुछ ग़लत हो गया। कृपया फिर से कोशिश करें।",
1054
+ sessionExpired: "यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।"
1055
+ },
1056
+ ar: {
1057
+ openChat: "فتح الدردشة",
1058
+ closeChat: "إغلاق الدردشة",
1059
+ chatWith: "الدردشة مع {name}",
1060
+ newConversation: "محادثة جديدة",
1061
+ conversation: "المحادثة",
1062
+ you: "أنت",
1063
+ message: "الرسالة",
1064
+ send: "إرسال",
1065
+ lookingItUp: "جارٍ البحث عن المعلومات…",
1066
+ goodResponse: "إجابة جيدة",
1067
+ badResponse: "إجابة سيئة",
1068
+ additionalFeedback: "ملاحظات إضافية",
1069
+ feedbackPlaceholder: "ما المشكلة؟ (اختياري)",
1070
+ feedbackCategory: "فئة الملاحظات",
1071
+ selectReason: "اختر سببًا (اختياري)",
1072
+ categoryFactual: "معلومات غير صحيحة",
1073
+ categoryIncomplete: "إجابة غير مكتملة",
1074
+ categoryTone: "أسلوب غير مناسب",
1075
+ categoryOther: "أخرى",
1076
+ submit: "إرسال الملاحظات",
1077
+ cancel: "إلغاء",
1078
+ feedbackThanks: "شكرًا على ملاحظاتك",
1079
+ feedbackFailed: "تعذّر إرسال الملاحظات",
1080
+ conversationCleared: "تم مسح المحادثة",
1081
+ genericError: "حدث خطأ ما. يُرجى المحاولة مرة أخرى.",
1082
+ sessionExpired: "انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة."
1083
+ }
1084
+ }, wt = Object.freeze(Object.keys(Ct)), Tt = {
1085
+ pt: "pt-BR",
1086
+ es: "es-419",
1087
+ zh: "zh-Hans"
1088
+ }, Et = /* @__PURE__ */ new Set(["ar"]), Dt = /^[a-z]{2,8}([-_][a-z0-9]{1,8})*$/i, Ot = /^zh[-_](hant|tw|hk|mo)(?=$|[-_])/i;
1089
+ function kt(e) {
1090
+ return Ct[e];
1091
+ }
1092
+ function At(e) {
1093
+ let t = e.trim();
1094
+ if (!Dt.test(t) || Ot.test(t)) return null;
1095
+ let n = t.split(/[-_]/)[0].toLowerCase();
1096
+ return Object.hasOwn(Ct, n) ? n : null;
1097
+ }
1098
+ function jt(e, t) {
1099
+ let n = null;
1100
+ return e != null && e !== "" && (n = typeof e == "string" ? At(e) : null, n || console.warn(`whoo-aiden-widget: ignoring \`language\` ${Mt(e)} -- expected one of ${wt.join(", ")} (or a regional tag like pt-BR). Using the page's language instead.`)), n ??= typeof t == "string" ? At(t) : null, n ??= "en", {
1101
+ language: n,
1102
+ tag: Tt[n] ?? n,
1103
+ dir: Et.has(n) ? "rtl" : "ltr"
1104
+ };
1105
+ }
1106
+ function Mt(e) {
1107
+ return typeof e == "string" ? JSON.stringify(e) : `(a ${typeof e})`;
1108
+ }
1109
+ function Nt(e, t) {
1110
+ return e.split("{name}").join(t.name);
1111
+ }
1112
+ //#endregion
734
1113
  //#region src/viewport.ts
735
- var ht = "(max-width: 400px), (max-height: 420px)", gt = "data-fit-visible", _t = 40;
736
- function vt(e) {
1114
+ var Pt = "(max-width: 400px), (max-height: 420px)", Ft = "data-fit-visible", It = 40;
1115
+ function Lt(e) {
737
1116
  let t = typeof window < "u" ? window.visualViewport : null;
738
1117
  if (!t) return () => {};
739
1118
  let n = () => {
740
- e.removeAttribute(gt), e.style.removeProperty("--whoo-widget-visible-top"), e.style.removeProperty("--whoo-widget-visible-height");
1119
+ e.removeAttribute(Ft), e.style.removeProperty("--whoo-widget-visible-top"), e.style.removeProperty("--whoo-widget-visible-height");
741
1120
  }, r = () => {
742
1121
  let r = document.documentElement.clientHeight, i = Math.abs(t.scale - 1) > .01, a = r - t.height;
743
- if (i || r === 0 || a < _t) {
1122
+ if (i || r === 0 || a < It) {
744
1123
  n();
745
1124
  return;
746
1125
  }
747
- e.setAttribute(gt, ""), e.style.setProperty("--whoo-widget-visible-top", `${Math.max(0, t.offsetTop)}px`), e.style.setProperty("--whoo-widget-visible-height", `${t.height}px`);
1126
+ e.setAttribute(Ft, ""), e.style.setProperty("--whoo-widget-visible-top", `${Math.max(0, t.offsetTop)}px`), e.style.setProperty("--whoo-widget-visible-height", `${t.height}px`);
748
1127
  };
749
1128
  return r(), t.addEventListener("resize", r), t.addEventListener("scroll", r), () => {
750
1129
  t.removeEventListener("resize", r), t.removeEventListener("scroll", r), n();
751
1130
  };
752
1131
  }
753
- var yt = 0, bt = "";
754
- function xt() {
755
- yt++ === 0 && (bt = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden");
1132
+ function Rt(e, t) {
1133
+ return typeof e.addEventListener == "function" ? (e.addEventListener("change", t), () => e.removeEventListener("change", t)) : typeof e.addListener == "function" ? (e.addListener(t), () => e.removeListener(t)) : () => {};
1134
+ }
1135
+ var zt = 0, Bt = "";
1136
+ function Vt() {
1137
+ zt++ === 0 && (Bt = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden");
756
1138
  }
757
- function St() {
758
- --yt === 0 && (document.documentElement.style.overflow = bt);
1139
+ function Ht() {
1140
+ --zt === 0 && (document.documentElement.style.overflow = Bt);
759
1141
  }
760
- function Ct() {
1142
+ function Ut() {
761
1143
  if (typeof window > "u" || typeof window.matchMedia != "function") return () => {};
762
- let e = window.matchMedia(ht), t = !1, n = () => {
763
- e.matches && !t ? (t = !0, xt()) : !e.matches && t && (t = !1, St());
764
- }, r = (t) => {
765
- typeof e.addEventListener == "function" ? t ? e.addEventListener("change", n) : e.removeEventListener("change", n) : typeof e.addListener == "function" && (t ? e.addListener(n) : e.removeListener(n));
1144
+ let e = window.matchMedia(Pt), t = !1, n = () => {
1145
+ e.matches && !t ? (t = !0, Vt()) : !e.matches && t && (t = !1, Ht());
766
1146
  };
767
- return n(), r(!0), () => {
768
- r(!1), t && (t = !1, St());
1147
+ n();
1148
+ let r = Rt(e, n);
1149
+ return () => {
1150
+ r(), t && (t = !1, Ht());
769
1151
  };
770
1152
  }
1153
+ function Wt(e) {
1154
+ if (typeof window > "u" || typeof window.matchMedia != "function" || typeof e.showModal != "function") return () => {};
1155
+ let t = window.matchMedia(Pt), n = !1, r = () => {
1156
+ if (t.matches === n || !e.isConnected) return;
1157
+ n = t.matches;
1158
+ let r = e.getRootNode().activeElement;
1159
+ e.close(), n ? e.showModal() : e.show(), r && e.contains(r) && r.focus({ preventScroll: !0 });
1160
+ };
1161
+ return r(), Rt(t, r);
1162
+ }
771
1163
  //#endregion
772
1164
  //#region src/components/Composer.tsx
773
- function wt({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
774
- return /* @__PURE__ */ G("div", {
1165
+ function Gt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text: o = e }) {
1166
+ return /* @__PURE__ */ U("div", {
775
1167
  class: "whoo-widget-composer",
776
1168
  children: [
777
- /* @__PURE__ */ G("label", {
1169
+ /* @__PURE__ */ U("label", {
778
1170
  class: "whoo-widget-sr-only",
779
1171
  for: "whoo-widget-composer-input",
780
- children: "Message"
1172
+ children: o.message
781
1173
  }),
782
- /* @__PURE__ */ G("input", {
1174
+ /* @__PURE__ */ U("input", {
783
1175
  id: "whoo-widget-composer-input",
784
1176
  class: "whoo-widget-composer-input",
785
- value: e,
786
- readOnly: r,
787
- "aria-disabled": r,
788
- ref: i,
789
- onInput: (e) => t(e.target.value),
1177
+ value: t,
1178
+ readOnly: i,
1179
+ "aria-disabled": i,
1180
+ ref: a,
1181
+ onInput: (e) => n(e.target.value),
790
1182
  onKeyDown: (e) => {
791
- e.key === "Enter" && n();
1183
+ e.key === "Enter" && r();
792
1184
  }
793
1185
  }),
794
- /* @__PURE__ */ G("button", {
1186
+ /* @__PURE__ */ U("button", {
795
1187
  type: "button",
796
1188
  class: "whoo-widget-composer-send",
797
- "aria-disabled": r,
1189
+ "aria-disabled": i,
798
1190
  onClick: () => {
799
- r || n();
1191
+ i || r();
800
1192
  },
801
- children: "Send"
1193
+ children: o.send
802
1194
  })
803
1195
  ]
804
1196
  });
805
1197
  }
806
1198
  //#endregion
807
1199
  //#region src/components/ErrorBanner.tsx
808
- function Tt({ message: e }) {
809
- return /* @__PURE__ */ G("div", {
1200
+ function Kt({ message: e }) {
1201
+ return /* @__PURE__ */ U("div", {
810
1202
  class: "whoo-widget-error-banner",
811
1203
  role: "alert",
812
1204
  children: e
@@ -814,8 +1206,8 @@ function Tt({ message: e }) {
814
1206
  }
815
1207
  //#endregion
816
1208
  //#region src/markdown/tokenizer.ts
817
- var Et = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, Dt = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, Ot = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, kt = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, At = /[ \t]*[*+-][ \t]+/y, jt = /https?:\/\/\S+/y, Mt = /[.,;:!?)\]}>]+$/;
818
- function Nt(e) {
1209
+ var qt = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, Jt = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, Yt = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, Xt = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, Zt = /[ \t]*[*+-][ \t]+/y, Qt = /https?:\/\/\S+/y, $t = /[.,;:!?)\]}>]+$/;
1210
+ function en(e) {
819
1211
  let t = [], n = 0, r = 0, i = (n) => {
820
1212
  n > r && t.push({
821
1213
  type: "text",
@@ -825,13 +1217,13 @@ function Nt(e) {
825
1217
  });
826
1218
  };
827
1219
  for (; n < e.length;) {
828
- if ((n === 0 || e[n - 1] === "\n") && (At.lastIndex = n, At.exec(e))) {
1220
+ if ((n === 0 || e[n - 1] === "\n") && (Zt.lastIndex = n, Zt.exec(e))) {
829
1221
  i(n), t.push({
830
1222
  type: "text",
831
1223
  value: "• ",
832
1224
  start: n,
833
- end: At.lastIndex
834
- }), n = At.lastIndex, r = n;
1225
+ end: Zt.lastIndex
1226
+ }), n = Zt.lastIndex, r = n;
835
1227
  continue;
836
1228
  }
837
1229
  if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
@@ -844,56 +1236,56 @@ function Nt(e) {
844
1236
  }
845
1237
  }
846
1238
  if (e[n - 1] !== "!") {
847
- Et.lastIndex = n;
848
- let a = Et.exec(e);
1239
+ qt.lastIndex = n;
1240
+ let a = qt.exec(e);
849
1241
  if (a) {
850
1242
  i(n), t.push({
851
1243
  type: "link",
852
1244
  text: a[1],
853
1245
  url: a[2],
854
1246
  start: n,
855
- end: Et.lastIndex
856
- }), n = Et.lastIndex, r = n;
1247
+ end: qt.lastIndex
1248
+ }), n = qt.lastIndex, r = n;
857
1249
  continue;
858
1250
  }
859
1251
  }
860
- Dt.lastIndex = n;
861
- let a = Dt.exec(e);
1252
+ Jt.lastIndex = n;
1253
+ let a = Jt.exec(e);
862
1254
  if (a) {
863
1255
  i(n), t.push({
864
1256
  type: "bold",
865
1257
  value: a[1],
866
1258
  start: n,
867
- end: Dt.lastIndex
868
- }), n = Dt.lastIndex, r = n;
1259
+ end: Jt.lastIndex
1260
+ }), n = Jt.lastIndex, r = n;
869
1261
  continue;
870
1262
  }
871
- Ot.lastIndex = n;
872
- let o = Ot.exec(e);
1263
+ Yt.lastIndex = n;
1264
+ let o = Yt.exec(e);
873
1265
  if (o) {
874
1266
  i(n), t.push({
875
1267
  type: "italic",
876
1268
  value: o[1],
877
1269
  start: n,
878
- end: Ot.lastIndex
879
- }), n = Ot.lastIndex, r = n;
1270
+ end: Yt.lastIndex
1271
+ }), n = Yt.lastIndex, r = n;
880
1272
  continue;
881
1273
  }
882
- kt.lastIndex = n;
883
- let s = kt.exec(e);
1274
+ Xt.lastIndex = n;
1275
+ let s = Xt.exec(e);
884
1276
  if (s) {
885
1277
  i(n), t.push({
886
1278
  type: "italic",
887
1279
  value: s[1],
888
1280
  start: n,
889
- end: kt.lastIndex
890
- }), n = kt.lastIndex, r = n;
1281
+ end: Xt.lastIndex
1282
+ }), n = Xt.lastIndex, r = n;
891
1283
  continue;
892
1284
  }
893
- jt.lastIndex = n;
894
- let c = jt.exec(e);
1285
+ Qt.lastIndex = n;
1286
+ let c = Qt.exec(e);
895
1287
  if (c) {
896
- let e = c[0].match(Mt), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
1288
+ let e = c[0].match($t), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
897
1289
  if (a.length > 0) {
898
1290
  i(n), t.push({
899
1291
  type: "link",
@@ -911,8 +1303,8 @@ function Nt(e) {
911
1303
  }
912
1304
  //#endregion
913
1305
  //#region src/markdown/render.tsx
914
- var Pt = /^[ \t]*[*+-][ \t]+(.*)$/;
915
- function Ft(e) {
1306
+ var tn = /^[ \t]*[*+-][ \t]+(.*)$/;
1307
+ function nn(e) {
916
1308
  let t = [], n = [], r = [], i = () => {
917
1309
  n.length > 0 && t.push({
918
1310
  type: "text",
@@ -925,7 +1317,7 @@ function Ft(e) {
925
1317
  }), r = [];
926
1318
  };
927
1319
  for (let t of e.split("\n")) {
928
- let e = t.match(Pt);
1320
+ let e = t.match(tn);
929
1321
  e ? (i(), r.push(e[1])) : (a(), n.push(t));
930
1322
  }
931
1323
  return i(), a(), t.some((e) => e.type === "list") ? t.flatMap((e, n) => {
@@ -937,16 +1329,16 @@ function Ft(e) {
937
1329
  }];
938
1330
  }) : null;
939
1331
  }
940
- function q(e) {
941
- return Nt(e).map((e, t) => {
1332
+ function G(e) {
1333
+ return en(e).map((e, t) => {
942
1334
  switch (e.type) {
943
- case "bold": return /* @__PURE__ */ G("strong", { children: q(e.value) }, t);
944
- case "italic": return /* @__PURE__ */ G("em", { children: q(e.value) }, t);
945
- case "link": return /* @__PURE__ */ G("a", {
1335
+ case "bold": return /* @__PURE__ */ U("strong", { children: G(e.value) }, t);
1336
+ case "italic": return /* @__PURE__ */ U("em", { children: G(e.value) }, t);
1337
+ case "link": return /* @__PURE__ */ U("a", {
946
1338
  href: e.url,
947
1339
  target: "_blank",
948
1340
  rel: "noopener noreferrer",
949
- children: [e.text, /* @__PURE__ */ G("span", {
1341
+ children: [e.text, /* @__PURE__ */ U("span", {
950
1342
  class: "whoo-widget-sr-only",
951
1343
  children: " (opens in new tab)"
952
1344
  })]
@@ -955,142 +1347,144 @@ function q(e) {
955
1347
  }
956
1348
  });
957
1349
  }
958
- function It(e) {
959
- let t = e.replace(/\r\n?/g, "\n"), n = Ft(t);
960
- return n ? n.map((e, t) => e.type === "list" ? /* @__PURE__ */ G("ul", {
1350
+ function rn(e) {
1351
+ let t = e.replace(/\r\n?/g, "\n"), n = nn(t);
1352
+ return n ? n.map((e, t) => e.type === "list" ? /* @__PURE__ */ U("ul", {
961
1353
  class: "whoo-widget-list",
962
- children: e.items.map((e, t) => /* @__PURE__ */ G("li", { children: q(e) }, t))
963
- }, t) : /* @__PURE__ */ G("span", { children: q(e.text) }, t)) : q(t);
1354
+ children: e.items.map((e, t) => /* @__PURE__ */ U("li", { children: G(e) }, t))
1355
+ }, t) : /* @__PURE__ */ U("span", { children: G(e.text) }, t)) : G(t);
964
1356
  }
965
1357
  //#endregion
966
1358
  //#region src/components/MessageFeedback.tsx
967
- var Lt = [
968
- {
969
- value: "",
970
- label: "Select a reason (optional)"
971
- },
972
- {
973
- value: "factual",
974
- label: "Factual error"
975
- },
976
- {
977
- value: "incomplete",
978
- label: "Incomplete"
979
- },
980
- {
981
- value: "tone",
982
- label: "Off tone"
983
- },
984
- {
985
- value: "other",
986
- label: "Other"
987
- }
988
- ];
989
- function Rt({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraftChange: i, onSubmitDetailed: a, onCancel: o }) {
990
- let s = e.correction ?? "", c = e.category ?? "", l = U(e.status), u = U(null), d = U(null);
991
- if (H(() => {
992
- let n = l.current;
993
- if (l.current = e.status, n === e.status) return;
994
- if (e.status === "expanded") {
995
- u.current?.focus();
1359
+ function an(e) {
1360
+ return [
1361
+ {
1362
+ value: "",
1363
+ label: e.selectReason
1364
+ },
1365
+ {
1366
+ value: "factual",
1367
+ label: e.categoryFactual
1368
+ },
1369
+ {
1370
+ value: "incomplete",
1371
+ label: e.categoryIncomplete
1372
+ },
1373
+ {
1374
+ value: "tone",
1375
+ label: e.categoryTone
1376
+ },
1377
+ {
1378
+ value: "other",
1379
+ label: e.categoryOther
1380
+ }
1381
+ ];
1382
+ }
1383
+ function on({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraftChange: a, onSubmitDetailed: o, onCancel: s, text: c = e }) {
1384
+ let l = t.correction ?? "", u = t.category ?? "", d = V(t.status), f = V(null), p = V(null);
1385
+ if (nt(() => {
1386
+ let e = d.current;
1387
+ if (d.current = t.status, e === t.status) return;
1388
+ if (t.status === "expanded") {
1389
+ f.current?.focus();
996
1390
  return;
997
1391
  }
998
- if (n === "expanded" && e.status === "idle") {
999
- d.current?.focus();
1392
+ if (e === "expanded" && t.status === "idle") {
1393
+ p.current?.focus();
1000
1394
  return;
1001
1395
  }
1002
- let r = t?.current;
1396
+ let r = n?.current;
1003
1397
  if (!r) return;
1004
1398
  let i = r.getRootNode();
1005
1399
  r.contains(i.activeElement) || r.focus();
1006
- }, [e.status, t]), e.status === "expanded") return /* @__PURE__ */ G("div", {
1400
+ }, [t.status, n]), t.status === "expanded") return /* @__PURE__ */ U("div", {
1007
1401
  class: "whoo-widget-feedback-form",
1008
1402
  children: [
1009
- /* @__PURE__ */ G("label", { children: [/* @__PURE__ */ G("span", {
1403
+ /* @__PURE__ */ U("label", { children: [/* @__PURE__ */ U("span", {
1010
1404
  class: "whoo-widget-sr-only",
1011
- children: "Additional feedback"
1012
- }), /* @__PURE__ */ G("textarea", {
1013
- ref: u,
1405
+ children: c.additionalFeedback
1406
+ }), /* @__PURE__ */ U("textarea", {
1407
+ ref: f,
1014
1408
  class: "whoo-widget-feedback-textarea",
1015
- value: s,
1016
- onInput: (e) => i(e.target.value, c),
1017
- placeholder: "What was wrong? (optional)"
1409
+ value: l,
1410
+ onInput: (e) => a(e.target.value, u),
1411
+ placeholder: c.feedbackPlaceholder
1018
1412
  })] }),
1019
- /* @__PURE__ */ G("select", {
1413
+ /* @__PURE__ */ U("select", {
1020
1414
  class: "whoo-widget-feedback-select",
1021
- "aria-label": "Feedback category",
1022
- value: c,
1023
- onChange: (e) => i(s, e.target.value),
1024
- children: Lt.map((e) => /* @__PURE__ */ G("option", {
1415
+ "aria-label": c.feedbackCategory,
1416
+ value: u,
1417
+ onChange: (e) => a(l, e.target.value),
1418
+ children: an(c).map((e) => /* @__PURE__ */ U("option", {
1025
1419
  value: e.value,
1026
1420
  children: e.label
1027
1421
  }, e.value))
1028
1422
  }),
1029
- /* @__PURE__ */ G("div", {
1423
+ /* @__PURE__ */ U("div", {
1030
1424
  class: "whoo-widget-feedback-form-buttons",
1031
- children: [/* @__PURE__ */ G("button", {
1425
+ children: [/* @__PURE__ */ U("button", {
1032
1426
  type: "button",
1033
1427
  class: "whoo-widget-feedback-submit",
1034
- onClick: () => a(s, c),
1035
- children: "Submit"
1036
- }), /* @__PURE__ */ G("button", {
1428
+ onClick: () => o(l, u),
1429
+ children: c.submit
1430
+ }), /* @__PURE__ */ U("button", {
1037
1431
  type: "button",
1038
1432
  class: "whoo-widget-feedback-cancel",
1039
- onClick: o,
1040
- children: "Cancel"
1433
+ onClick: s,
1434
+ children: c.cancel
1041
1435
  })]
1042
1436
  })
1043
1437
  ]
1044
1438
  });
1045
- let f = e.status === "submitting", p = e.status === "submitted";
1046
- return /* @__PURE__ */ G("div", {
1439
+ let m = t.status === "submitting", h = t.status === "submitted";
1440
+ return /* @__PURE__ */ U("div", {
1047
1441
  class: "whoo-widget-feedback",
1048
- children: [p ? null : /* @__PURE__ */ G("div", {
1442
+ children: [h ? null : /* @__PURE__ */ U("div", {
1049
1443
  class: "whoo-widget-feedback-buttons",
1050
- children: [/* @__PURE__ */ G("button", {
1444
+ children: [/* @__PURE__ */ U("button", {
1051
1445
  type: "button",
1052
- "aria-label": "Good response",
1053
- disabled: f,
1054
- onClick: n,
1055
- children: /* @__PURE__ */ G(ut, {})
1056
- }), /* @__PURE__ */ G("button", {
1057
- ref: d,
1058
- type: "button",
1059
- "aria-label": "Bad response",
1060
- disabled: f,
1446
+ "aria-label": c.goodResponse,
1447
+ disabled: m,
1061
1448
  onClick: r,
1062
- children: /* @__PURE__ */ G(dt, {})
1449
+ children: /* @__PURE__ */ U(vt, {})
1450
+ }), /* @__PURE__ */ U("button", {
1451
+ ref: p,
1452
+ type: "button",
1453
+ "aria-label": c.badResponse,
1454
+ disabled: m,
1455
+ onClick: i,
1456
+ children: /* @__PURE__ */ U(yt, {})
1063
1457
  })]
1064
- }), /* @__PURE__ */ G("div", {
1458
+ }), /* @__PURE__ */ U("div", {
1065
1459
  role: "status",
1066
- class: p ? "whoo-widget-feedback-submitted" : e.status === "error" ? "whoo-widget-feedback-error" : void 0,
1067
- children: p ? "Thanks for the feedback" : e.status === "error" ? "Couldn't send feedback" : null
1460
+ class: h ? "whoo-widget-feedback-submitted" : t.status === "error" ? "whoo-widget-feedback-error" : void 0,
1461
+ children: h ? c.feedbackThanks : t.status === "error" ? c.feedbackFailed : null
1068
1462
  })]
1069
1463
  });
1070
1464
  }
1071
1465
  //#endregion
1072
1466
  //#region src/components/MessageList.tsx
1073
- function zt({ isSlowResponse: e }) {
1074
- return /* @__PURE__ */ G("div", {
1467
+ function sn({ isSlowResponse: e, text: t }) {
1468
+ return /* @__PURE__ */ U("div", {
1075
1469
  class: "whoo-widget-pending",
1076
1470
  role: "status",
1077
- children: [/* @__PURE__ */ G("span", {
1471
+ children: [/* @__PURE__ */ U("span", {
1078
1472
  class: "whoo-widget-typing",
1079
1473
  "aria-hidden": "true",
1080
1474
  children: [
1081
- /* @__PURE__ */ G("span", {}),
1082
- /* @__PURE__ */ G("span", {}),
1083
- /* @__PURE__ */ G("span", {})
1475
+ /* @__PURE__ */ U("span", {}),
1476
+ /* @__PURE__ */ U("span", {}),
1477
+ /* @__PURE__ */ U("span", {})
1084
1478
  ]
1085
- }), e ? /* @__PURE__ */ G("span", {
1479
+ }), e ? /* @__PURE__ */ U("span", {
1086
1480
  class: "whoo-widget-pending-text",
1087
- children: "Looking that up for you…"
1481
+ children: t.lookingItUp
1088
1482
  }) : null]
1089
1483
  });
1090
1484
  }
1091
- function Bt({ url: e, alt: t }) {
1092
- let [n, r] = qe(!1);
1093
- return n ? null : /* @__PURE__ */ G("img", {
1485
+ function cn({ url: e, alt: t }) {
1486
+ let [n, r] = $e(!1);
1487
+ return n ? null : /* @__PURE__ */ U("img", {
1094
1488
  class: "whoo-widget-empty-state-image",
1095
1489
  src: e,
1096
1490
  alt: t,
@@ -1098,88 +1492,97 @@ function Bt({ url: e, alt: t }) {
1098
1492
  onError: () => r(!0)
1099
1493
  });
1100
1494
  }
1101
- function Vt({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u }) {
1102
- let d = U(null), f = e.id;
1103
- return /* @__PURE__ */ G("div", {
1104
- ref: d,
1495
+ function ln({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u, text: d }) {
1496
+ let f = V(null), p = e.id;
1497
+ return /* @__PURE__ */ U("div", {
1498
+ ref: f,
1105
1499
  tabIndex: -1,
1106
1500
  class: `whoo-widget-message whoo-widget-message--${e.role}`,
1107
1501
  children: [
1108
- /* @__PURE__ */ G("span", {
1502
+ /* @__PURE__ */ U("span", {
1109
1503
  class: "whoo-widget-sr-only",
1110
1504
  children: [t, ": "]
1111
1505
  }),
1112
- i ? /* @__PURE__ */ G(zt, { isSlowResponse: a }) : It(e.content),
1113
- r && e.role === "assistant" && f ? /* @__PURE__ */ G(Rt, {
1506
+ i ? /* @__PURE__ */ U(sn, {
1507
+ isSlowResponse: a,
1508
+ text: d
1509
+ }) : /* @__PURE__ */ U("div", {
1510
+ class: "whoo-widget-message-text",
1511
+ dir: "auto",
1512
+ children: rn(e.content)
1513
+ }),
1514
+ r && e.role === "assistant" && p ? /* @__PURE__ */ U(on, {
1114
1515
  state: n,
1115
- containerRef: d,
1116
- onThumbsUp: () => o(f),
1117
- onThumbsDown: () => s(f),
1118
- onDraftChange: (e, t) => c(f, e, t),
1119
- onSubmitDetailed: (e, t) => l(f, e, t),
1120
- onCancel: () => u(f)
1516
+ containerRef: f,
1517
+ onThumbsUp: () => o(p),
1518
+ onThumbsDown: () => s(p),
1519
+ onDraftChange: (e, t) => c(p, e, t),
1520
+ onSubmitDetailed: (e, t) => l(p, e, t),
1521
+ onCancel: () => u(p),
1522
+ text: d
1121
1523
  }) : null
1122
1524
  ]
1123
1525
  });
1124
1526
  }
1125
- function Ht({ 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 }) {
1126
- let m = U(null);
1127
- return H(() => {
1128
- let e = m.current;
1527
+ function un({ messages: t, messageFeedback: n, announcement: r, emptyStateImage: i, agentName: a = l, showFeedback: o = !1, isStreaming: s = !1, isSlowResponse: c = !1, onThumbsUp: u, onThumbsDown: d, onDraftChange: f = () => {}, onSubmitDetailed: p, onCancelFeedback: m, text: h = e }) {
1528
+ let g = V(null);
1529
+ return tt(() => {
1530
+ let e = g.current;
1129
1531
  e && (e.scrollTop = e.scrollHeight);
1130
- }, [e, c]), /* @__PURE__ */ G(I, { children: [/* @__PURE__ */ G("section", {
1532
+ }, [t, c]), /* @__PURE__ */ U(I, { children: [/* @__PURE__ */ U("section", {
1131
1533
  class: "whoo-widget-message-list",
1132
- ref: m,
1133
- "aria-label": "Conversation",
1534
+ ref: g,
1535
+ "aria-label": h.conversation,
1134
1536
  tabIndex: 0,
1135
- children: [r ? /* @__PURE__ */ G(Bt, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ G(Vt, {
1136
- message: n,
1137
- speaker: n.role === "user" ? "You" : i,
1138
- showFeedback: a,
1139
- feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
1140
- pending: o && r === e.length - 1 && n.role === "assistant" && n.content === "",
1537
+ children: [i ? /* @__PURE__ */ U(cn, { ...i }) : null, t.map((e, r) => /* @__PURE__ */ U(ln, {
1538
+ message: e,
1539
+ speaker: e.role === "user" ? h.you : a,
1540
+ showFeedback: o,
1541
+ feedbackState: e.id ? n[e.id] ?? { status: "idle" } : { status: "idle" },
1542
+ pending: s && r === t.length - 1 && e.role === "assistant" && e.content === "",
1141
1543
  isSlowResponse: c,
1142
- onThumbsUp: l,
1143
- onThumbsDown: u,
1144
- onDraftChange: d,
1145
- onSubmitDetailed: f,
1146
- onCancelFeedback: p
1147
- }, n.id ?? r))]
1148
- }), /* @__PURE__ */ G("div", {
1544
+ onThumbsUp: u,
1545
+ onThumbsDown: d,
1546
+ onDraftChange: f,
1547
+ onSubmitDetailed: p,
1548
+ onCancelFeedback: m,
1549
+ text: h
1550
+ }, e.id ?? r))]
1551
+ }), /* @__PURE__ */ U("div", {
1149
1552
  class: "whoo-widget-sr-only",
1150
1553
  "aria-live": "polite",
1151
1554
  "aria-atomic": "true",
1152
- children: n ?? ""
1555
+ children: r ?? ""
1153
1556
  })] });
1154
1557
  }
1155
1558
  //#endregion
1156
1559
  //#region src/components/Panel.tsx
1157
- var Ut = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
1158
- function Wt(e) {
1159
- return Array.from(e.querySelectorAll(Ut)).filter((e) => {
1560
+ var dn = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
1561
+ function fn(e) {
1562
+ return Array.from(e.querySelectorAll(dn)).filter((e) => {
1160
1563
  let t = getComputedStyle(e);
1161
1564
  return t.display !== "none" && t.visibility !== "hidden";
1162
1565
  });
1163
1566
  }
1164
- function Gt({ state: e, controller: t, greeting: n }) {
1165
- let r = U(null), i = U(null);
1166
- H(() => {
1567
+ function pn({ state: e, controller: t, greeting: n }) {
1568
+ let r = V(null), i = V(null);
1569
+ nt(() => {
1167
1570
  i.current?.focus();
1168
- }, []), H(() => {
1169
- let e = r.current, t = e ? vt(e) : () => {}, n = Ct();
1571
+ }, []), nt(() => {
1572
+ let e = r.current, t = e ? Lt(e) : () => {}, n = e ? Wt(e) : () => {}, i = Ut();
1170
1573
  return () => {
1171
- t(), n();
1574
+ t(), n(), i();
1172
1575
  };
1173
1576
  }, []);
1174
1577
  let a = (e) => {
1175
1578
  if (e.key === "Escape") {
1176
- t.close();
1579
+ e.preventDefault(), t.close();
1177
1580
  return;
1178
1581
  }
1179
1582
  if (e.key !== "Tab") return;
1180
1583
  let n = r.current;
1181
1584
  if (!n) return;
1182
- let i = Wt(n);
1585
+ let i = fn(n);
1183
1586
  if (i.length === 0) return;
1184
1587
  let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
1185
1588
  if (!n.contains(s)) {
@@ -1190,7 +1593,7 @@ function Gt({ state: e, controller: t, greeting: n }) {
1190
1593
  }, o = () => {
1191
1594
  let n = e.draft.trim();
1192
1595
  n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
1193
- }, s = c(t.config.name) || e.agentName || "Aiden", l = c(t.config.title) || `Chat with ${s}`, u = e.messages.length === 0 && n ? [{
1596
+ }, s = u(t.config.name) || e.agentName || "Aiden", c = u(t.config.title) || Nt(t.text.chatWith, { name: s }), l = e.messages.length === 0 && n ? [{
1194
1597
  role: "assistant",
1195
1598
  content: n,
1196
1599
  id: null
@@ -1198,39 +1601,42 @@ function Gt({ state: e, controller: t, greeting: n }) {
1198
1601
  url: d,
1199
1602
  alt: t.emptyStateImageAlt
1200
1603
  } : void 0;
1201
- return /* @__PURE__ */ G("div", {
1604
+ return /* @__PURE__ */ U("dialog", {
1605
+ open: !0,
1202
1606
  class: "whoo-widget-panel",
1203
- role: "dialog",
1204
1607
  "aria-modal": "true",
1205
- "aria-label": l,
1608
+ "aria-label": c,
1206
1609
  ref: r,
1207
1610
  onKeyDown: a,
1611
+ onCancel: (e) => {
1612
+ e.preventDefault(), t.close();
1613
+ },
1208
1614
  children: [
1209
- /* @__PURE__ */ G("div", {
1615
+ /* @__PURE__ */ U("div", {
1210
1616
  class: "whoo-widget-header",
1211
- children: [/* @__PURE__ */ G("h2", {
1617
+ children: [/* @__PURE__ */ U("h2", {
1212
1618
  class: "whoo-widget-header-title",
1213
- children: l
1214
- }), /* @__PURE__ */ G("div", {
1619
+ children: c
1620
+ }), /* @__PURE__ */ U("div", {
1215
1621
  class: "whoo-widget-header-actions",
1216
- children: [e.messages.length > 0 && /* @__PURE__ */ G("button", {
1622
+ children: [e.messages.length > 0 && /* @__PURE__ */ U("button", {
1217
1623
  type: "button",
1218
1624
  class: "whoo-widget-header-reset",
1219
1625
  onClick: () => {
1220
1626
  t.resetConversation(), i.current?.focus();
1221
1627
  },
1222
- children: "New conversation"
1223
- }), /* @__PURE__ */ G("button", {
1628
+ children: t.text.newConversation
1629
+ }), /* @__PURE__ */ U("button", {
1224
1630
  type: "button",
1225
1631
  class: "whoo-widget-header-close",
1226
- "aria-label": "Close chat",
1632
+ "aria-label": t.text.closeChat,
1227
1633
  onClick: () => t.close(),
1228
- children: /* @__PURE__ */ G(ct, {})
1634
+ children: /* @__PURE__ */ U(gt, {})
1229
1635
  })]
1230
1636
  })]
1231
1637
  }),
1232
- /* @__PURE__ */ G(Ht, {
1233
- messages: u,
1638
+ /* @__PURE__ */ U(un, {
1639
+ messages: l,
1234
1640
  messageFeedback: e.messageFeedback,
1235
1641
  announcement: e.announcement,
1236
1642
  emptyStateImage: f,
@@ -1242,34 +1648,37 @@ function Gt({ state: e, controller: t, greeting: n }) {
1242
1648
  onThumbsDown: (e) => t.expandFeedback(e),
1243
1649
  onDraftChange: (e, n, r) => t.setFeedbackDraft(e, n, r),
1244
1650
  onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
1245
- onCancelFeedback: (e) => t.cancelFeedback(e)
1651
+ onCancelFeedback: (e) => t.cancelFeedback(e),
1652
+ text: t.text
1246
1653
  }),
1247
- e.runtimeError && /* @__PURE__ */ G(Tt, { message: e.runtimeError }),
1248
- /* @__PURE__ */ G(wt, {
1654
+ e.runtimeError && /* @__PURE__ */ U(Kt, { message: e.runtimeError }),
1655
+ /* @__PURE__ */ U(Gt, {
1249
1656
  value: e.draft,
1250
1657
  onChange: (e) => t.setDraft(e),
1251
1658
  onSend: o,
1252
1659
  disabled: e.isStreaming,
1253
- inputRef: i
1660
+ inputRef: i,
1661
+ text: t.text
1254
1662
  })
1255
1663
  ]
1256
1664
  });
1257
1665
  }
1258
1666
  //#endregion
1259
1667
  //#region src/components/App.tsx
1260
- function Kt({ controller: e }) {
1261
- let [t, n] = qe(e.getState()), r = U(null), i = U(t.isOpen);
1262
- return H(() => (n(e.getState()), e.subscribe(n)), [e]), H(() => {
1668
+ function mn({ controller: e }) {
1669
+ let [t, n] = $e(e.getState()), r = V(null), i = V(t.isOpen);
1670
+ return tt(() => (n(e.getState()), e.subscribe(n)), [e]), tt(() => {
1263
1671
  i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
1264
- }, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ G(I, { children: [/* @__PURE__ */ G(mt, {
1672
+ }, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ U(I, { children: [/* @__PURE__ */ U(St, {
1265
1673
  isOpen: t.isOpen,
1266
1674
  onClick: () => t.isOpen ? e.close() : e.open(),
1267
1675
  iconUrl: e.launcher.iconUrl,
1268
1676
  icon: e.launcher.icon,
1269
1677
  openIconUrl: e.launcher.openIconUrl,
1270
1678
  openIcon: e.launcher.openIcon,
1271
- buttonRef: r
1272
- }), t.isOpen && /* @__PURE__ */ G(Gt, {
1679
+ buttonRef: r,
1680
+ text: e.text
1681
+ }), t.isOpen && /* @__PURE__ */ U(pn, {
1273
1682
  state: t,
1274
1683
  controller: e,
1275
1684
  greeting: e.config.greeting
@@ -1277,44 +1686,44 @@ function Kt({ controller: e }) {
1277
1686
  }
1278
1687
  //#endregion
1279
1688
  //#region src/api/client.ts
1280
- var qt = class extends Error {
1689
+ var hn = class extends Error {
1281
1690
  status;
1282
1691
  constructor(e, t) {
1283
1692
  super(e), this.name = "WidgetApiError", this.status = t;
1284
1693
  }
1285
1694
  };
1286
- function Jt(e) {
1695
+ function gn(e) {
1287
1696
  if (typeof e != "string") return null;
1288
1697
  let t = e.trim();
1289
1698
  return t === "" ? null : t;
1290
1699
  }
1291
- async function Yt(e, t) {
1700
+ async function _n(e, t) {
1292
1701
  let n = await fetch(`${e}/api/v1/widget/session`, {
1293
1702
  method: "POST",
1294
1703
  headers: { "Content-Type": "application/json" },
1295
1704
  body: JSON.stringify({ publishable_key: t })
1296
1705
  });
1297
- if (!n.ok) throw new qt(`Failed to create widget session (${n.status})`, n.status);
1706
+ if (!n.ok) throw new hn(`Failed to create widget session (${n.status})`, n.status);
1298
1707
  let r = await n.json();
1299
1708
  return {
1300
1709
  token: r.token,
1301
- ...Xt(r)
1710
+ ...vn(r)
1302
1711
  };
1303
1712
  }
1304
- function Xt(e) {
1713
+ function vn(e) {
1305
1714
  return {
1306
- primaryColor: Jt(e.primary_color),
1307
- name: Jt(e.name),
1308
- accentColor: Jt(e.accent_color),
1309
- inkColor: Jt(e.ink_color)
1715
+ primaryColor: gn(e.primary_color),
1716
+ name: gn(e.name),
1717
+ accentColor: gn(e.accent_color),
1718
+ inkColor: gn(e.ink_color)
1310
1719
  };
1311
1720
  }
1312
- async function Zt(e, t) {
1721
+ async function yn(e, t) {
1313
1722
  let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
1314
- if (!n.ok) throw new qt(`Failed to load widget branding (${n.status})`, n.status);
1315
- return Xt(await n.json());
1723
+ if (!n.ok) throw new hn(`Failed to load widget branding (${n.status})`, n.status);
1724
+ return vn(await n.json());
1316
1725
  }
1317
- async function Qt(e, t, n) {
1726
+ async function bn(e, t, n) {
1318
1727
  let r = await fetch(`${e}/api/v1/widget/feedback`, {
1319
1728
  method: "POST",
1320
1729
  headers: {
@@ -1328,11 +1737,11 @@ async function Qt(e, t, n) {
1328
1737
  category: n.category ?? null
1329
1738
  })
1330
1739
  });
1331
- if (!r.ok) throw new qt(`Feedback submission failed (${r.status})`, r.status);
1740
+ if (!r.ok) throw new hn(`Feedback submission failed (${r.status})`, r.status);
1332
1741
  }
1333
1742
  //#endregion
1334
1743
  //#region src/api/sse.ts
1335
- async function* $t(e, t, n, r, i) {
1744
+ async function* xn(e, t, n, r, i) {
1336
1745
  let a = await fetch(`${e}/api/v1/widget/chat`, {
1337
1746
  method: "POST",
1338
1747
  headers: {
@@ -1345,7 +1754,7 @@ async function* $t(e, t, n, r, i) {
1345
1754
  }),
1346
1755
  signal: i
1347
1756
  });
1348
- if (!a.ok || !a.body) throw new qt(`Chat request failed (${a.status})`, a.status);
1757
+ if (!a.ok || !a.body) throw new hn(`Chat request failed (${a.status})`, a.status);
1349
1758
  let o = a.body.getReader(), s = new TextDecoder(), c = "";
1350
1759
  for (;;) {
1351
1760
  let { done: e, value: t } = await o.read();
@@ -1356,11 +1765,11 @@ async function* $t(e, t, n, r, i) {
1356
1765
  let e = c.slice(0, n);
1357
1766
  c = c.slice(n + 2);
1358
1767
  let t = e.split("\n").find((e) => e.startsWith("data: "));
1359
- t && (yield en(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1768
+ t && (yield Sn(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
1360
1769
  }
1361
1770
  }
1362
1771
  }
1363
- function en(e) {
1772
+ function Sn(e) {
1364
1773
  return typeof e.error == "string" ? {
1365
1774
  type: "error",
1366
1775
  error: e.error,
@@ -1383,11 +1792,11 @@ function en(e) {
1383
1792
  }
1384
1793
  //#endregion
1385
1794
  //#region src/markdown/plainText.ts
1386
- function tn(e) {
1387
- return Nt(e.replace(/\r\n?/g, "\n")).map((e) => {
1795
+ function Cn(e) {
1796
+ return en(e.replace(/\r\n?/g, "\n")).map((e) => {
1388
1797
  switch (e.type) {
1389
1798
  case "bold":
1390
- case "italic": return tn(e.value);
1799
+ case "italic": return Cn(e.value);
1391
1800
  case "link": return e.text;
1392
1801
  default: return e.value;
1393
1802
  }
@@ -1395,16 +1804,16 @@ function tn(e) {
1395
1804
  }
1396
1805
  //#endregion
1397
1806
  //#region src/markdown/reveal.ts
1398
- var nn = 40, rn = 120;
1399
- function an(e) {
1807
+ var wn = 40, Tn = 120;
1808
+ function En(e) {
1400
1809
  let t = [];
1401
- for (let n of Nt(e)) if (n.type === "text") {
1810
+ for (let n of en(e)) if (n.type === "text") {
1402
1811
  let e = n.value.split(/(\s+)/), r = n.start;
1403
1812
  for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
1404
1813
  } else t.push(n.end);
1405
1814
  return t;
1406
1815
  }
1407
- function on(e) {
1816
+ function Dn(e) {
1408
1817
  let t = null;
1409
1818
  return e?.addEventListener("abort", () => {
1410
1819
  t?.();
@@ -1419,51 +1828,66 @@ function on(e) {
1419
1828
  });
1420
1829
  };
1421
1830
  }
1422
- async function sn(e, t, n) {
1423
- let r = n?.wordIntervalMs ?? nn, i = n?.tokenIntervalMs ?? rn, a = n?.signal, o = Nt(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = on(a), l = "";
1424
- for (let n of an(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1831
+ async function On(e, t, n) {
1832
+ let r = n?.wordIntervalMs ?? wn, i = n?.tokenIntervalMs ?? Tn, a = n?.signal, o = en(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = Dn(a), l = "";
1833
+ for (let n of En(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
1425
1834
  l !== e && t(e);
1426
1835
  }
1427
1836
  //#endregion
1428
1837
  //#region src/sessionToken.ts
1429
- function cn(e, t = Date.now()) {
1430
- let n = e.split(".");
1431
- if (n.length !== 3 || n.some((e) => e === "")) return !1;
1432
- let r = n[1];
1838
+ function kn(e) {
1839
+ let t = e.split(".");
1840
+ if (t.length !== 3 || t.some((e) => e === "")) return null;
1841
+ let n = t[1];
1433
1842
  try {
1434
- let e = r.replace(/-/g, "+").replace(/_/g, "/"), n = JSON.parse(atob(e.padEnd(Math.ceil(e.length / 4) * 4, "=")))?.exp;
1435
- return typeof n == "number" && Number.isFinite(n) && n * 1e3 <= t;
1843
+ let e = n.replace(/-/g, "+").replace(/_/g, "/"), t = JSON.parse(atob(e.padEnd(Math.ceil(e.length / 4) * 4, "="))), r = (e) => typeof e == "number" && Number.isFinite(e) ? e : null, { exp: i, iat: a } = t ?? {};
1844
+ return {
1845
+ exp: r(i),
1846
+ iat: r(a)
1847
+ };
1436
1848
  } catch {
1437
- return !1;
1849
+ return null;
1438
1850
  }
1439
1851
  }
1852
+ function An(e) {
1853
+ let t = kn(e)?.exp;
1854
+ return typeof t == "number" ? t * 1e3 : null;
1855
+ }
1856
+ function jn(e, t = Date.now()) {
1857
+ let n = An(e);
1858
+ return n !== null && n <= t;
1859
+ }
1860
+ function Mn(e, t = Date.now()) {
1861
+ let n = kn(e);
1862
+ return n?.exp == null ? null : n.iat != null && n.exp > n.iat ? t + (n.exp - n.iat) * 1e3 : n.exp * 1e3;
1863
+ }
1440
1864
  //#endregion
1441
1865
  //#region src/storage.ts
1442
- function ln(e) {
1866
+ function Nn(e) {
1443
1867
  return `whoo-aiden-widget:conversation:${e}`;
1444
1868
  }
1445
- function un(e) {
1869
+ function Pn(e) {
1446
1870
  try {
1447
- return window.sessionStorage.getItem(ln(e));
1871
+ return window.sessionStorage.getItem(Nn(e));
1448
1872
  } catch {
1449
1873
  return null;
1450
1874
  }
1451
1875
  }
1452
- function dn(e, t) {
1876
+ function Fn(e, t) {
1453
1877
  try {
1454
- window.sessionStorage.setItem(ln(e), t);
1878
+ window.sessionStorage.setItem(Nn(e), t);
1455
1879
  } catch {}
1456
1880
  }
1457
- function fn(e) {
1881
+ function In(e) {
1458
1882
  try {
1459
- window.sessionStorage.removeItem(ln(e));
1883
+ window.sessionStorage.removeItem(Nn(e));
1460
1884
  } catch {}
1461
1885
  }
1462
1886
  //#endregion
1463
1887
  //#region src/theme.ts
1464
- var pn = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1465
- function mn(e) {
1466
- if (pn.test(e.trim())) return null;
1888
+ var Ln = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
1889
+ function Rn(e) {
1890
+ if (Ln.test(e.trim())) return null;
1467
1891
  let t = document.createElement("div");
1468
1892
  if (t.style.color = e, t.style.color === "") return null;
1469
1893
  let n = document.createElement("div");
@@ -1482,69 +1906,69 @@ function mn(e) {
1482
1906
  translucent: a < 1
1483
1907
  };
1484
1908
  }
1485
- function J(e) {
1486
- return mn(e)?.rgb ?? null;
1909
+ function K(e) {
1910
+ return Rn(e)?.rgb ?? null;
1487
1911
  }
1488
- function Y([e, t, n]) {
1912
+ function q([e, t, n]) {
1489
1913
  let r = (e) => {
1490
1914
  let t = e / 255;
1491
1915
  return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
1492
1916
  };
1493
1917
  return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
1494
1918
  }
1495
- function hn(e, t) {
1919
+ function zn(e, t) {
1496
1920
  let n = Math.max(e, t), r = Math.min(e, t);
1497
1921
  return (n + .05) / (r + .05);
1498
1922
  }
1499
- function gn(e) {
1500
- let t = J(e);
1923
+ function Bn(e) {
1924
+ let t = K(e);
1501
1925
  if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
1502
- let n = Y(t);
1503
- return hn(n, Y([
1926
+ let n = q(t);
1927
+ return zn(n, q([
1504
1928
  0,
1505
1929
  0,
1506
1930
  0
1507
- ])) >= hn(n, Y([
1931
+ ])) >= zn(n, q([
1508
1932
  255,
1509
1933
  255,
1510
1934
  255
1511
1935
  ])) ? "#000000" : "#ffffff";
1512
1936
  }
1513
- function _n(e, t) {
1514
- let n = J(e), r = J(t);
1515
- return !n || !r ? NaN : hn(Y(n), Y(r));
1937
+ function Vn(e, t) {
1938
+ let n = K(e), r = K(t);
1939
+ return !n || !r ? NaN : zn(q(n), q(r));
1516
1940
  }
1517
- var vn = n.primary, yn = n.panel, bn = n.assistantBubble, xn = n.headerHover, Sn = 4.5;
1518
- function Cn([e, t, n]) {
1941
+ var Hn = i.primary, Un = i.panel, Wn = i.assistantBubble, Gn = i.headerHover, Kn = 4.5;
1942
+ function J([e, t, n]) {
1519
1943
  return `#${[
1520
1944
  e,
1521
1945
  t,
1522
1946
  n
1523
1947
  ].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
1524
1948
  }
1525
- function wn(e, t = yn) {
1526
- let n = J(e), r = J(t);
1527
- if (!n || !r) return vn;
1528
- let i = Y(r), a = (e) => hn(Y(e), i) >= Sn;
1529
- if (a(n)) return Cn(n);
1949
+ function qn(e, t = Un) {
1950
+ let n = K(e), r = K(t);
1951
+ if (!n || !r) return Hn;
1952
+ let i = q(r), a = (e) => zn(q(e), i) >= Kn;
1953
+ if (a(n)) return J(n);
1530
1954
  for (let e = .99; e > 0; e -= .01) {
1531
1955
  let t = n.map((t) => Math.round(t * e));
1532
- if (a(t)) return Cn(t);
1956
+ if (a(t)) return J(t);
1533
1957
  }
1534
1958
  return "#000000";
1535
1959
  }
1536
- var Tn = n.ink, En = n.link;
1537
- function X(e) {
1960
+ var Jn = i.ink, Yn = i.link;
1961
+ function Y(e) {
1538
1962
  if (typeof e != "string" || !e) return null;
1539
- let t = mn(e);
1540
- return t ? Cn(t.rgb) : null;
1963
+ let t = Rn(e);
1964
+ return t ? J(t.rgb) : null;
1541
1965
  }
1542
- function Dn(e) {
1966
+ function Xn(e) {
1543
1967
  if (typeof e != "string" || !e) return null;
1544
- let t = mn(e);
1545
- return t ? t.translucent ? e.trim() : Cn(t.rgb) : null;
1968
+ let t = Rn(e);
1969
+ return t ? t.translucent ? e.trim() : J(t.rgb) : null;
1546
1970
  }
1547
- var On = [
1971
+ var Zn = [
1548
1972
  {
1549
1973
  role: "onPrimary",
1550
1974
  against: ["primary"],
@@ -1596,8 +2020,8 @@ var On = [
1596
2020
  required: 3
1597
2021
  }
1598
2022
  ];
1599
- function Z({ color: e, inkColor: r, accentColor: i, overrides: a }) {
1600
- let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => Dn(o[e]), c = X(e), l = s("primary"), u = l ?? c ?? vn, d = s("primaryText"), f = d ?? wn(u, xn), p = s("onPrimary") ?? gn(u), m = X(r), h = s("ink") ?? (m ? wn(m, bn) : Tn), g = X(i), _ = s("link") ?? (g ? wn(g, bn) : En), v = (e) => s(e) ?? n[e], y = {
2023
+ function X({ color: e, inkColor: t, accentColor: n, overrides: a }) {
2024
+ let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => Xn(o[e]), c = Y(e), l = s("primary"), u = l ?? c ?? Hn, d = s("primaryText"), f = d ?? qn(u, Gn), p = s("onPrimary") ?? Bn(u), m = Y(t), h = s("ink") ?? (m ? qn(m, Wn) : Jn), g = Y(n), _ = s("link") ?? (g ? qn(g, Wn) : Yn), v = (e) => s(e) ?? i[e], y = {
1601
2025
  primary: u,
1602
2026
  onPrimary: p,
1603
2027
  primaryText: f,
@@ -1614,10 +2038,10 @@ function Z({ color: e, inkColor: r, accentColor: i, overrides: a }) {
1614
2038
  errorText: v("errorText"),
1615
2039
  inputBorder: v("inputBorder"),
1616
2040
  focusRing: v("focusRing")
1617
- }, b = Object.fromEntries(t.map((e) => [e, s(e) !== null])), x = [];
1618
- for (let { role: e, against: t, required: n } of On) for (let r of t) {
2041
+ }, b = Object.fromEntries(r.map((e) => [e, s(e) !== null])), x = [];
2042
+ for (let { role: e, against: t, required: n } of Zn) for (let r of t) {
1619
2043
  if (!b[e] && !b[r]) continue;
1620
- let t = _n(y[e], y[r]);
2044
+ let t = Vn(y[e], y[r]);
1621
2045
  Number.isFinite(t) && t < n && x.push({
1622
2046
  role: e,
1623
2047
  against: r,
@@ -1643,63 +2067,71 @@ function Z({ color: e, inkColor: r, accentColor: i, overrides: a }) {
1643
2067
  contrastWarnings: x
1644
2068
  };
1645
2069
  }
1646
- function Q(e) {
2070
+ function Z(e) {
1647
2071
  return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
1648
2072
  }
1649
- function kn(e, t, n = vn) {
2073
+ function Qn(e, t, n = Hn) {
1650
2074
  let r = t;
1651
- X(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as the theme color; falling back to ${Q(n)}.`), r = n);
1652
- let i = Z({ color: r });
2075
+ Y(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Z(t)} as the theme color; falling back to ${Z(n)}.`), r = n);
2076
+ let i = X({ color: r });
1653
2077
  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);
1654
2078
  }
1655
- function An(e, { inkColor: t, accentColor: n }) {
1656
- let r = Z({
2079
+ function $n(e, { inkColor: t, accentColor: n }) {
2080
+ let r = X({
1657
2081
  inkColor: t,
1658
2082
  accentColor: n
1659
2083
  });
1660
2084
  e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
1661
2085
  }
1662
- function jn(e, n) {
1663
- let i = Z({ overrides: n });
1664
- for (let n of t) {
1665
- let t = i.overridden.primary && (n === "onPrimary" || n === "primaryText");
1666
- (i.overridden[n] || t) && e.style.setProperty(r[n], i.roles[n]);
2086
+ function er(e, t) {
2087
+ let n = X({ overrides: t });
2088
+ for (let t of r) {
2089
+ let r = n.overridden.primary && (t === "onPrimary" || t === "primaryText");
2090
+ (n.overridden[t] || r) && e.style.setProperty(a[t], n.roles[t]);
1667
2091
  }
1668
2092
  }
1669
- function Mn(e, t) {
1670
- e && X(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`);
2093
+ function tr(e, t) {
2094
+ e && Y(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Z(e)} as the ${t}; using the default.`);
1671
2095
  }
1672
- function Nn(e, n, r) {
1673
- for (let e of t) {
1674
- let t = n[e];
1675
- t && X(t) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as theme.colors.${e}; using the calculated color.`);
2096
+ function nr(e, t, n) {
2097
+ for (let e of r) {
2098
+ let n = t[e];
2099
+ n && Y(n) === null && console.warn(`[whoo-aiden-widget] Could not use ${Z(n)} as theme.colors.${e}; using the calculated color.`);
1676
2100
  }
1677
- let i = n.primary;
1678
- typeof i == "string" && mn(i)?.translucent && console.warn(`[whoo-aiden-widget] theme.colors.primary ${Q(i)} is translucent. The launcher shows your page through it, so its icon may be unreadable over dark content; pass a solid color.`), Pn({
2101
+ let i = t.primary;
2102
+ typeof i == "string" && Rn(i)?.translucent && console.warn(`[whoo-aiden-widget] theme.colors.primary ${Z(i)} is translucent. The launcher shows your page through it, so its icon may be unreadable over dark content; pass a solid color.`), rr({
1679
2103
  color: e.color,
1680
2104
  inkColor: e.inkColor,
1681
2105
  accentColor: e.accentColor,
1682
- overrides: n
1683
- }, r);
2106
+ overrides: t
2107
+ }, n);
1684
2108
  }
1685
- function Pn(e, t) {
1686
- for (let n of Z(e).contrastWarnings) {
2109
+ function rr(e, t) {
2110
+ for (let n of X(e).contrastWarnings) {
1687
2111
  let { role: e, against: r, value: i, ratio: a, required: o, overridden: s } = n, c = `${e}|${r}|${i}`;
1688
2112
  t.has(c) || (t.add(c), console.warn(s ? `[whoo-aiden-widget] theme.colors.${e} (${i}) has ${a.toFixed(2)}:1 contrast against the ${r} color; ${o}:1 is recommended. Using it as given.` : `[whoo-aiden-widget] the ${e} color (${i}) has ${a.toFixed(2)}:1 contrast against your theme.colors.${r}; ${o}:1 is recommended. Override theme.colors.${e} too.`));
1689
2113
  }
1690
2114
  }
1691
- function Fn(e, t, n = /* @__PURE__ */ new Set()) {
1692
- kn(e, t.color ?? vn), Mn(t.inkColor, "ink color"), Mn(t.accentColor, "accent color"), An(e, {
2115
+ function ir(e, t, n = /* @__PURE__ */ new Set()) {
2116
+ Qn(e, t.color ?? Hn), tr(t.inkColor, "ink color"), tr(t.accentColor, "accent color"), $n(e, {
1693
2117
  inkColor: t.inkColor,
1694
2118
  accentColor: t.accentColor
1695
2119
  });
1696
- let r = T(t.theme);
1697
- Nn(t, r.colors, n), jn(e, r.colors), r.fontFamily && (e.style.setProperty("--whoo-widget-font", r.fontFamily), e.setAttribute("data-whoo-custom-font", ""));
2120
+ let r = te(t.theme);
2121
+ nr(t, r.colors, n), er(e, r.colors), r.fontFamily && e.style.setProperty("--whoo-widget-font", r.fontFamily);
1698
2122
  }
1699
2123
  //#endregion
1700
2124
  //#region src/controller.ts
1701
- var In = 8e3, Ln = 3e3;
1702
- function Rn(e, t) {
2125
+ var ar = 8e3, or = 3e3, Q = class extends Error {
2126
+ name = "SessionExpiredError";
2127
+ constructor(e) {
2128
+ super(e instanceof Error ? e.message : "The session has expired.");
2129
+ }
2130
+ };
2131
+ function sr(e) {
2132
+ return e?.status === 401;
2133
+ }
2134
+ function cr(e, t) {
1703
2135
  return new Promise((n) => {
1704
2136
  let r = setTimeout(n, t);
1705
2137
  e.then(() => {
@@ -1707,11 +2139,14 @@ function Rn(e, t) {
1707
2139
  });
1708
2140
  });
1709
2141
  }
1710
- var zn = class {
2142
+ var lr = class {
1711
2143
  config;
1712
2144
  state;
1713
2145
  listeners = /* @__PURE__ */ new Set();
1714
2146
  sessionToken = null;
2147
+ sessionTokenExpiresAt = null;
2148
+ tokenRenewal = null;
2149
+ getSessionToken;
1715
2150
  conversationId = null;
1716
2151
  storageIdentifier;
1717
2152
  activeRequestController = null;
@@ -1722,13 +2157,22 @@ var zn = class {
1722
2157
  emptyStateImageUrl;
1723
2158
  emptyStateImageAlt;
1724
2159
  showFeedback;
1725
- constructor(t) {
1726
- this.config = t;
1727
- let n = T(t.theme).launcher, r = n.iconUrl ?? e(t.launcherIconUrl, "launcherIconUrl");
2160
+ text;
2161
+ language;
2162
+ languageTag;
2163
+ dir;
2164
+ constructor(e) {
2165
+ this.config = e;
2166
+ let t = te(e.theme).launcher, r = t.iconUrl ?? n(e.launcherIconUrl, "launcherIconUrl");
1728
2167
  this.launcher = {
1729
- ...n,
2168
+ ...t,
1730
2169
  ...r ? { iconUrl: r } : {}
1731
- }, 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 = {
2170
+ }, this.launcherIconUrl = r, this.emptyStateImageUrl = n(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.getSessionToken = p(e);
2171
+ let { language: i, tag: a, dir: o } = jt(e.language, typeof document > "u" ? void 0 : document.documentElement.lang);
2172
+ this.language = i, this.languageTag = a, this.dir = o, this.text = {
2173
+ ...kt(i),
2174
+ ...y(e.messages)
2175
+ }, this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
1732
2176
  isOpen: !1,
1733
2177
  messages: [],
1734
2178
  isStreaming: !1,
@@ -1773,11 +2217,12 @@ var zn = class {
1773
2217
  let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
1774
2218
  try {
1775
2219
  if (this.config.sessionToken) {
1776
- if (cn(this.config.sessionToken)) throw Error("The sessionToken has expired.");
1777
- this.sessionToken = this.config.sessionToken;
2220
+ if (jn(this.config.sessionToken)) {
2221
+ if (!await this.renewToken()) throw Error("The sessionToken has expired.");
2222
+ } else this.sessionToken = this.config.sessionToken, this.sessionTokenExpiresAt = An(this.config.sessionToken);
1778
2223
  } else if (this.config.publishableKey) {
1779
- let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await Yt(e, this.config.publishableKey);
1780
- this.sessionToken = t, this.setState({
2224
+ let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await _n(e, this.config.publishableKey);
2225
+ this.sessionToken = t, this.sessionTokenExpiresAt = Mn(t), this.setState({
1781
2226
  primaryColor: n,
1782
2227
  agentName: r,
1783
2228
  accentColor: i,
@@ -1788,34 +2233,34 @@ var zn = class {
1788
2233
  console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
1789
2234
  return;
1790
2235
  }
1791
- this.conversationId = un(this.storageIdentifier), this.config.sessionToken && await Rn(this.loadBranding(e, this.config.sessionToken), Ln);
2236
+ this.conversationId = Pn(this.storageIdentifier), this.config.sessionToken && await cr(this.loadBranding(e), or);
1792
2237
  }
1793
- async loadBranding(e, t) {
2238
+ async loadBranding(e) {
1794
2239
  try {
1795
- let n = this.config;
1796
- if (X(n.color) && X(n.inkColor) && X(n.accentColor) && c(n.name)) return;
1797
- let { primaryColor: r, name: i, accentColor: a, inkColor: o } = await Zt(e, t);
2240
+ let t = this.config;
2241
+ if (Y(t.color) && Y(t.inkColor) && Y(t.accentColor) && u(t.name)) return;
2242
+ let { primaryColor: n, name: r, accentColor: i, inkColor: a } = await this.withSession((t) => yn(e, t));
1798
2243
  this.setState({
1799
- primaryColor: r,
1800
- agentName: i,
1801
- accentColor: a,
1802
- inkColor: o
2244
+ primaryColor: n,
2245
+ agentName: r,
2246
+ accentColor: i,
2247
+ inkColor: a
1803
2248
  });
1804
2249
  } catch (e) {
1805
2250
  let t = e?.status;
1806
- (t === 401 || t === 403) && (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) }));
2251
+ (e instanceof Q || t === 401 || t === 403) && (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) }));
1807
2252
  }
1808
2253
  }
1809
2254
  open() {
1810
2255
  this.setState({ isOpen: !0 });
1811
2256
  }
1812
2257
  resetConversation() {
1813
- this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, fn(this.storageIdentifier), this.setState({
2258
+ this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, In(this.storageIdentifier), this.setState({
1814
2259
  messages: [],
1815
2260
  messageFeedback: {},
1816
2261
  runtimeError: null,
1817
2262
  isStreaming: !1,
1818
- announcement: "Conversation cleared"
2263
+ announcement: this.text.conversationCleared
1819
2264
  });
1820
2265
  }
1821
2266
  setDraft(e) {
@@ -1856,23 +2301,33 @@ var zn = class {
1856
2301
  let { signal: s } = this.activeRequestController;
1857
2302
  this.slowResponseTimer = setTimeout(() => {
1858
2303
  this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
1859
- }, In);
1860
- let c = () => {
2304
+ }, ar);
2305
+ let c = (t = this.text.genericError) => {
1861
2306
  this.setState({
1862
- runtimeError: "Something went wrong, please try again.",
2307
+ runtimeError: t,
1863
2308
  ...this.state.draft === "" ? { draft: e } : {}
1864
2309
  });
1865
2310
  }, l = "";
1866
2311
  try {
1867
- for await (let n of $t(t, this.sessionToken, this.conversationId, e, s)) if (n.type === "conversation_id") this.conversationId = n.conversationId, dn(this.storageIdentifier, n.conversationId);
1868
- else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await sn(n.delta, (e) => o(e), { signal: s }), l = n.delta) : n.verbatim ? (l = n.delta, o(l)) : (l += n.delta, o(l));
1869
- else if (n.type === "done") n.conversationId && (this.conversationId = n.conversationId, dn(this.storageIdentifier, n.conversationId)), n.messageId && a({ id: n.messageId }), this.setState({ announcement: tn(l) });
1870
- else if (n.type === "error") {
1871
- console.error("[whoo-aiden-widget] chat error:", n.error), c(), this.activeRequestController?.abort();
1872
- break;
2312
+ let { stream: n, first: r } = await this.withSession(async (n) => {
2313
+ let r = xn(t, n, this.conversationId, e, s);
2314
+ return {
2315
+ stream: r,
2316
+ first: await r.next()
2317
+ };
2318
+ });
2319
+ for (let e = r; !e.done; e = await n.next()) {
2320
+ let t = e.value;
2321
+ if (t.type === "conversation_id") this.conversationId = t.conversationId, Fn(this.storageIdentifier, t.conversationId);
2322
+ else if (t.type === "delta") this.clearSlowResponse(), t.verbatim && !this.prefersReducedMotion ? (await On(t.delta, (e) => o(e), { signal: s }), l = t.delta) : t.verbatim ? (l = t.delta, o(l)) : (l += t.delta, o(l));
2323
+ else if (t.type === "done") t.conversationId && (this.conversationId = t.conversationId, Fn(this.storageIdentifier, t.conversationId)), t.messageId && a({ id: t.messageId }), this.setState({ announcement: Cn(l) });
2324
+ else if (t.type === "error") {
2325
+ console.error("[whoo-aiden-widget] chat error:", t.error), c(), this.activeRequestController?.abort();
2326
+ break;
2327
+ }
1873
2328
  }
1874
2329
  } catch (e) {
1875
- e?.name === "AbortError" || (console.error("[whoo-aiden-widget] chat request failed:", e), c());
2330
+ e?.name === "AbortError" || (e instanceof Q ? (console.error("[whoo-aiden-widget] chat request failed: the session has expired.", e), c(this.text.sessionExpired)) : (console.error("[whoo-aiden-widget] chat request failed:", e), c()));
1876
2331
  } finally {
1877
2332
  this.activeRequestController = null, this.clearSlowResponse();
1878
2333
  let e = i.id === null && i.content.trim() === "" ? this.state.messages.filter((e) => e !== i) : this.state.messages;
@@ -1920,12 +2375,12 @@ var zn = class {
1920
2375
  }
1921
2376
  } });
1922
2377
  try {
1923
- await Qt(i, this.sessionToken, {
2378
+ await this.withSession((a) => bn(i, a, {
1924
2379
  messageId: e,
1925
2380
  rating: t,
1926
2381
  correction: n,
1927
2382
  category: r
1928
- }), this.setState({ messageFeedback: {
2383
+ })), this.setState({ messageFeedback: {
1929
2384
  ...this.state.messageFeedback,
1930
2385
  [e]: {
1931
2386
  status: "submitted",
@@ -1944,53 +2399,93 @@ var zn = class {
1944
2399
  } });
1945
2400
  }
1946
2401
  }
1947
- }, $ = 20, Bn = 12, Vn = 300, Hn = 352;
1948
- function Un() {
2402
+ async currentToken() {
2403
+ let e = this.sessionToken, t = this.sessionTokenExpiresAt;
2404
+ return e && (t === null || t - Date.now() > 6e4) ? e : this.renewToken();
2405
+ }
2406
+ renewToken() {
2407
+ return this.tokenRenewal ??= this.fetchNewToken().finally(() => {
2408
+ this.tokenRenewal = null;
2409
+ }), this.tokenRenewal;
2410
+ }
2411
+ async fetchNewToken() {
2412
+ let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
2413
+ try {
2414
+ let t;
2415
+ if (this.config.publishableKey) t = (await _n(e, this.config.publishableKey)).token;
2416
+ else if (this.getSessionToken) t = await this.getSessionToken();
2417
+ else return null;
2418
+ let n = typeof t == "string" ? Mn(t) : null;
2419
+ return typeof t != "string" || t === "" || n !== null && n <= Date.now() ? (console.error("[whoo-aiden-widget] could not renew the session: no usable token was returned."), null) : (this.sessionToken = t, this.sessionTokenExpiresAt = n, t);
2420
+ } catch (e) {
2421
+ return console.error("[whoo-aiden-widget] could not renew the session:", e), null;
2422
+ }
2423
+ }
2424
+ async withSession(e) {
2425
+ let t = await this.currentToken();
2426
+ if (!t) throw new Q();
2427
+ try {
2428
+ return await e(t);
2429
+ } catch (n) {
2430
+ if (!sr(n)) throw n;
2431
+ let r = this.sessionToken && this.sessionToken !== t ? this.sessionToken : await this.renewToken();
2432
+ if (!r) throw new Q(n);
2433
+ try {
2434
+ return await e(r);
2435
+ } catch (e) {
2436
+ throw sr(e) ? new Q(e) : e;
2437
+ }
2438
+ }
2439
+ }
2440
+ }, $ = 20, ur = 12, dr = 300, fr = 352;
2441
+ function pr() {
1949
2442
  try {
1950
2443
  return typeof CSS < "u" && CSS.supports?.("height", "100dvh") ? "dvh" : "vh";
1951
2444
  } catch {
1952
2445
  return "vh";
1953
2446
  }
1954
2447
  }
1955
- function Wn(e, t) {
1956
- let { offsetX: n, offsetY: r, launcherSize: i, panelWidth: a, panelHeight: o } = te(t.layout), s = (e) => typeof t.layout?.offset?.[e] == "number";
2448
+ function mr(e, t) {
2449
+ let { offsetX: n, offsetY: r, launcherSize: i, panelWidth: a, panelHeight: o } = ie(t.layout), s = (e) => typeof t.layout?.offset?.[e] == "number";
1957
2450
  if (typeof window < "u" && window.innerWidth > 0 && window.innerHeight > 0) {
1958
- let e = Math.max($, window.innerWidth - Vn), t = Math.max($, window.innerHeight - i - Hn);
2451
+ let e = Math.max($, window.innerWidth - dr), t = Math.max($, window.innerHeight - i - fr);
1959
2452
  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.`);
1960
2453
  }
1961
- let c = `100${Un()}`, l = `min(${n}px, max(${$}px, calc(100vw - ${Vn}px)), calc(100vw - ${i}px))`, u = `min(${r}px, max(${$}px, calc(${c} - ${i + Hn}px)), calc(${c} - ${i}px))`, d = `calc(${u} + ${i}px + ${Bn}px)`, f = t.position === "bottom-left", p = (t, n) => e.style.setProperty(t, n);
2454
+ let c = `100${pr()}`, l = `min(${n}px, max(${$}px, calc(100vw - ${dr}px)), calc(100vw - ${i}px))`, u = `min(${r}px, max(${$}px, calc(${c} - ${i + fr}px)), calc(${c} - ${i}px))`, d = `calc(${u} + ${i}px + ${ur}px)`, f = t.position === "bottom-left", p = (t, n) => e.style.setProperty(t, n);
1962
2455
  p("--whoo-widget-inset-left", f ? l : "auto"), p("--whoo-widget-inset-right", f ? "auto" : l), p("--whoo-widget-inset-bottom", u), p("--whoo-widget-launcher-size", `${i}px`), p("--whoo-widget-panel-bottom", d), p("--whoo-widget-panel-width", `${a}px`), p("--whoo-widget-panel-height", `${o}px`), p("--whoo-widget-panel-max-width", `calc(100vw - ${l} - ${$}px)`), p("--whoo-widget-panel-max-height", `calc(${c} - ${d} - ${$}px)`);
1963
2456
  }
1964
2457
  //#endregion
1965
2458
  //#region src/styles.css?inline
1966
- var Gn = ":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-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + max(8px, var(--whoo-widget-visible-height,100%) - 8px - var(--whoo-widget-panel-height,480px)));height:min(var(--whoo-widget-panel-height,480px), calc(var(--whoo-widget-visible-height,100%) - 16px));max-height:none;bottom:auto}@media (width<=400px),(height<=420px){.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + 8px);height:calc(var(--whoo-widget-visible-height,100%) - 16px)}}.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{overscroll-behavior:contain;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;min-width:0;padding:8px;font-size:16px}.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:16px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;height:2em;min-height:24px;padding:4px;font-size:16px}.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}}";
2459
+ var hr = ":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);color:inherit;border:none;border-radius:12px;flex-direction:column;margin:0;padding:0;display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}button,input,textarea,select{font-family:inherit}.whoo-widget-panel::backdrop{background:0 0}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + max(8px, var(--whoo-widget-visible-height,100%) - 8px - var(--whoo-widget-panel-height,480px)));height:min(var(--whoo-widget-panel-height,480px), calc(var(--whoo-widget-visible-height,100%) - 16px));max-height:none;bottom:auto}@media (width<=400px),(height<=420px){.whoo-widget-panel[data-fit-visible]{top:calc(var(--whoo-widget-visible-top,0px) + 8px);height:calc(var(--whoo-widget-visible-height,100%) - 16px)}}.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-block:8px;padding-inline:16px 8px;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-inline-start: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{overscroll-behavior:contain;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-inline-start:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-inline-start: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);unicode-bidi:plaintext;border-radius:6px;flex:1;min-width:0;padding:8px;font-size:16px}.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;unicode-bidi:plaintext;border-radius:6px;width:100%;padding:6px;font-size:16px}.whoo-widget-feedback-select{border:1px solid var(--whoo-widget-input-border,#6b7280);border-radius:6px;height:2em;min-height:24px;padding:4px;font-size:16px}.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}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}}";
1967
2460
  //#endregion
1968
2461
  //#region src/mount.tsx
1969
- function Kn(e) {
2462
+ function gr(e) {
1970
2463
  let t = document.createElement("div");
1971
- t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(o(e.zIndex));
2464
+ t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(c(e.zIndex));
1972
2465
  let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
1973
- r.textContent = Gn, n.appendChild(r);
2466
+ r.textContent = hr, n.appendChild(r);
1974
2467
  let i = document.createElement("div");
1975
2468
  n.appendChild(i);
1976
2469
  let a = /* @__PURE__ */ new Set();
1977
- Fn(i, e, a), Wn(i, e);
1978
- let s = new zn(e), c = X(e.color) !== null, l = null, u = "", d = T(e.theme).colors, f = Object.keys(d).length > 0, p = {
2470
+ ir(i, e, a), mr(i, e);
2471
+ let o = new lr(e);
2472
+ i.setAttribute("lang", o.languageTag), i.setAttribute("dir", o.dir);
2473
+ let s = Y(e.color) !== null, l = null, u = "", d = te(e.theme).colors, f = Object.keys(d).length > 0, p = {
1979
2474
  color: e.color,
1980
2475
  inkColor: e.inkColor,
1981
2476
  accentColor: e.accentColor
1982
2477
  };
1983
- return s.subscribe((t) => {
2478
+ return o.subscribe((t) => {
1984
2479
  let n = !1;
1985
- !c && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor, kn(i, t.primaryColor, e.color), X(t.primaryColor) && (p = {
2480
+ !s && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor, Qn(i, t.primaryColor, e.color), Y(t.primaryColor) && (p = {
1986
2481
  ...p,
1987
2482
  color: t.primaryColor
1988
2483
  }), n = !0);
1989
2484
  let r = `${t.inkColor}|${t.accentColor}`;
1990
2485
  if ((t.inkColor || t.accentColor) && r !== u) {
1991
2486
  u = r;
1992
- let a = X(e.inkColor) ? e.inkColor : t.inkColor, o = X(e.accentColor) ? e.accentColor : t.accentColor;
1993
- An(i, {
2487
+ let a = Y(e.inkColor) ? e.inkColor : t.inkColor, o = Y(e.accentColor) ? e.accentColor : t.accentColor;
2488
+ $n(i, {
1994
2489
  inkColor: a,
1995
2490
  accentColor: o
1996
2491
  }), p = {
@@ -1999,18 +2494,18 @@ function Kn(e) {
1999
2494
  accentColor: o
2000
2495
  }, n = !0;
2001
2496
  }
2002
- n && (jn(i, d), f && Pn({
2497
+ n && (er(i, d), f && rr({
2003
2498
  ...p,
2004
2499
  overrides: d
2005
2500
  }, a));
2006
- }), s.init(), Pe(/* @__PURE__ */ G(Kt, { controller: s }), i), document.body.appendChild(t), { unmount() {
2007
- Pe(null, i), t.remove();
2501
+ }), o.init(), ze(/* @__PURE__ */ U(mn, { controller: o }), i), document.body.appendChild(t), { unmount() {
2502
+ ze(null, i), t.remove();
2008
2503
  } };
2009
2504
  }
2010
2505
  //#endregion
2011
2506
  //#region src/index.ts
2012
- function qn(e) {
2013
- return l(e), Kn(e);
2507
+ function _r(e) {
2508
+ return d(e), gr(e);
2014
2509
  }
2015
2510
  //#endregion
2016
- export { qn as init, Z as resolveTheme };
2511
+ export { wt as SUPPORTED_LANGUAGES, _r as init, X as resolveTheme };