@aiden-voice/widget 0.9.0 → 0.9.1
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/README.md +26 -1
- package/dist/components/MessageList.d.ts +3 -1
- package/dist/config.d.ts +1 -0
- package/dist/controller.d.ts +4 -0
- package/dist/i18n/messages.d.ts +1 -0
- package/dist/storage.d.ts +2 -0
- package/dist/types.d.ts +16 -1
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +7 -7
- package/dist/widget.js +579 -505
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -26,7 +26,8 @@ var e = {
|
|
|
26
26
|
conversationCleared: "Conversation cleared",
|
|
27
27
|
genericError: "Something went wrong, please try again.",
|
|
28
28
|
sessionExpired: "This chat session has expired. Reload the page to continue.",
|
|
29
|
-
opensInNewTab: "(opens in new tab)"
|
|
29
|
+
opensInNewTab: "(opens in new tab)",
|
|
30
|
+
agreeToNotice: "I agree"
|
|
30
31
|
}, t = Object.keys(e);
|
|
31
32
|
//#endregion
|
|
32
33
|
//#region src/imageUrl.ts
|
|
@@ -101,27 +102,24 @@ function u(e) {
|
|
|
101
102
|
return typeof e == "string" ? e.trim() : "";
|
|
102
103
|
}
|
|
103
104
|
function d(e) {
|
|
104
|
-
|
|
105
|
+
return /^[\p{White_Space}\p{Cf}\p{M}]*$/u.test(e);
|
|
105
106
|
}
|
|
106
107
|
function f(e) {
|
|
107
|
-
|
|
108
|
+
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.");
|
|
108
109
|
}
|
|
109
110
|
function p(e) {
|
|
111
|
+
console.warn(`whoo-aiden-widget: ${e}`);
|
|
112
|
+
}
|
|
113
|
+
function m(e) {
|
|
110
114
|
let { getSessionToken: t } = e;
|
|
111
115
|
if (t !== void 0) {
|
|
112
|
-
if (typeof t != "function")
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
116
|
-
if (!e.sessionToken) {
|
|
117
|
-
f("ignoring `getSessionToken` -- it is only used with `sessionToken`; with `publishableKey` the widget renews its session by itself.");
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
return t;
|
|
116
|
+
if (typeof t != "function") p("ignoring `getSessionToken` -- expected a function that returns a session token.");
|
|
117
|
+
else if (!e.sessionToken) p("ignoring `getSessionToken` -- it is only used with `sessionToken`; with `publishableKey` the widget renews its session by itself.");
|
|
118
|
+
else return t;
|
|
121
119
|
}
|
|
122
120
|
}
|
|
123
|
-
var
|
|
124
|
-
function
|
|
121
|
+
var h = 20;
|
|
122
|
+
function g(e) {
|
|
125
123
|
let t = /* @__PURE__ */ new WeakSet(), n = /* @__PURE__ */ new Set();
|
|
126
124
|
return (r) => {
|
|
127
125
|
if (typeof r == "object" && r || typeof r == "function") {
|
|
@@ -129,63 +127,59 @@ function h(e) {
|
|
|
129
127
|
t.add(r);
|
|
130
128
|
} else {
|
|
131
129
|
if (n.has(r)) return;
|
|
132
|
-
n.size >=
|
|
130
|
+
n.size >= h && n.delete(n.values().next().value), n.add(r);
|
|
133
131
|
}
|
|
134
|
-
|
|
132
|
+
p(e);
|
|
135
133
|
};
|
|
136
134
|
}
|
|
137
|
-
var
|
|
138
|
-
function
|
|
135
|
+
var _ = g("ignoring `theme` -- expected an object."), v = g("ignoring `layout` -- expected an object."), y = g("ignoring `messages` -- expected an object.");
|
|
136
|
+
function b(e) {
|
|
139
137
|
if (e == null) return {};
|
|
140
|
-
if (!
|
|
138
|
+
if (!x(e)) return y(e), {};
|
|
141
139
|
let n = {};
|
|
142
140
|
for (let r of Object.keys(e)) {
|
|
143
141
|
if (!t.includes(r)) {
|
|
144
|
-
|
|
142
|
+
p(`ignoring unknown option \`messages.${r}\`.`);
|
|
145
143
|
continue;
|
|
146
144
|
}
|
|
147
145
|
let i = e[r];
|
|
148
|
-
|
|
149
|
-
f(`ignoring \`messages.${r}\` -- expected a non-blank string.`);
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
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;
|
|
146
|
+
typeof i != "string" || d(i) ? p(`ignoring \`messages.${r}\` -- expected a non-blank string.`) : (r === "chatWith" && !i.includes("{name}") && p("`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);
|
|
153
147
|
}
|
|
154
|
-
for (let t in e) Object.hasOwn(e, t) ||
|
|
148
|
+
for (let t in e) Object.hasOwn(e, t) || p(`ignoring inherited option \`messages.${t}\` -- only the object's own keys are used.`);
|
|
155
149
|
return n;
|
|
156
150
|
}
|
|
157
|
-
function
|
|
151
|
+
function x(e) {
|
|
158
152
|
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
159
153
|
}
|
|
160
|
-
var
|
|
161
|
-
function
|
|
154
|
+
var S = (e) => e == null || e === "";
|
|
155
|
+
function C(e, t, n) {
|
|
162
156
|
let r = e[t];
|
|
163
|
-
return r == null ? null :
|
|
157
|
+
return r == null ? null : x(r) ? r : (p(`ignoring \`${n}\` -- expected an object.`), null);
|
|
164
158
|
}
|
|
165
|
-
function
|
|
166
|
-
for (let r of Object.keys(e)) t.includes(r) ||
|
|
159
|
+
function w(e, t, n) {
|
|
160
|
+
for (let r of Object.keys(e)) t.includes(r) || p(`ignoring unknown option \`${n}.${r}\`.`);
|
|
167
161
|
}
|
|
168
|
-
function
|
|
169
|
-
if (!
|
|
162
|
+
function T(e, t, n) {
|
|
163
|
+
if (!S(e)) {
|
|
170
164
|
if (typeof e == "string" && t.includes(e)) return e;
|
|
171
|
-
|
|
165
|
+
p(`ignoring \`${n}\` -- expected one of ${t.join(", ")}.`);
|
|
172
166
|
}
|
|
173
167
|
}
|
|
174
|
-
var
|
|
175
|
-
function
|
|
176
|
-
if (!
|
|
168
|
+
var E = 200, D = /url\(|[@;{}\\]/i;
|
|
169
|
+
function O(e) {
|
|
170
|
+
if (!S(e)) {
|
|
177
171
|
if (typeof e == "string") {
|
|
178
172
|
let t = e.trim();
|
|
179
|
-
if (t && t.length <=
|
|
173
|
+
if (t && t.length <= E && !D.test(t)) return t;
|
|
180
174
|
}
|
|
181
|
-
|
|
175
|
+
p(`ignoring \`theme.fonts.family\` -- expected a font-family stack of at most ${E} characters, without url(), @, ;, {, } or \\.`);
|
|
182
176
|
}
|
|
183
177
|
}
|
|
184
|
-
var
|
|
178
|
+
var k = [
|
|
185
179
|
"chat",
|
|
186
180
|
"message",
|
|
187
181
|
"sparkle"
|
|
188
|
-
],
|
|
182
|
+
], A = ["chevron-down", "close"], ee = /* @__PURE__ */ new WeakMap();
|
|
189
183
|
function te(e) {
|
|
190
184
|
let t = {
|
|
191
185
|
colors: {},
|
|
@@ -193,75 +187,75 @@ function te(e) {
|
|
|
193
187
|
launcher: {}
|
|
194
188
|
};
|
|
195
189
|
if (e == null) return t;
|
|
196
|
-
if (!
|
|
197
|
-
let i =
|
|
190
|
+
if (!x(e)) return _(e), t;
|
|
191
|
+
let i = ee.get(e);
|
|
198
192
|
if (i) return i;
|
|
199
|
-
|
|
193
|
+
w(e, [
|
|
200
194
|
"colors",
|
|
201
195
|
"fonts",
|
|
202
196
|
"launcher"
|
|
203
197
|
], "theme");
|
|
204
|
-
let a =
|
|
198
|
+
let a = C(e, "colors", "theme.colors");
|
|
205
199
|
if (a) {
|
|
206
|
-
|
|
200
|
+
w(a, r, "theme.colors");
|
|
207
201
|
for (let e of r) {
|
|
208
202
|
let n = a[e];
|
|
209
|
-
|
|
203
|
+
S(n) || (typeof n == "string" ? t.colors[e] = n : p(`ignoring \`theme.colors.${e}\` -- expected a CSS color string.`));
|
|
210
204
|
}
|
|
211
205
|
}
|
|
212
|
-
let o =
|
|
213
|
-
o && (
|
|
214
|
-
let s =
|
|
206
|
+
let o = C(e, "fonts", "theme.fonts");
|
|
207
|
+
o && (w(o, ["family"], "theme.fonts"), t.fontFamily = O(o.family));
|
|
208
|
+
let s = C(e, "launcher", "theme.launcher");
|
|
215
209
|
if (s) {
|
|
216
|
-
|
|
210
|
+
w(s, [
|
|
217
211
|
"icon",
|
|
218
212
|
"iconUrl",
|
|
219
213
|
"openIcon",
|
|
220
214
|
"openIconUrl"
|
|
221
215
|
], "theme.launcher");
|
|
222
|
-
let e =
|
|
216
|
+
let e = T(s.icon, k, "theme.launcher.icon"), r = n(s.iconUrl, "theme.launcher.iconUrl"), i = T(s.openIcon, A, "theme.launcher.openIcon"), a = n(s.openIconUrl, "theme.launcher.openIconUrl");
|
|
223
217
|
e && (t.launcher.icon = e), r && (t.launcher.iconUrl = r), i && (t.launcher.openIcon = i), a && (t.launcher.openIconUrl = a);
|
|
224
218
|
}
|
|
225
|
-
return
|
|
219
|
+
return ee.set(e, t), t;
|
|
226
220
|
}
|
|
227
|
-
var
|
|
221
|
+
var j = {
|
|
228
222
|
offsetX: 20,
|
|
229
223
|
offsetY: 20,
|
|
230
224
|
launcherSize: 56,
|
|
231
225
|
panelWidth: 360,
|
|
232
226
|
panelHeight: 480
|
|
233
227
|
};
|
|
234
|
-
function
|
|
235
|
-
return e == null ? n : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : (
|
|
228
|
+
function M(e, t, n) {
|
|
229
|
+
return e == null ? n : typeof e == "number" && Number.isFinite(e) && e >= 0 ? e : (p(`ignoring \`${t}\` -- expected a non-negative number of pixels; using ${n}.`), n);
|
|
236
230
|
}
|
|
237
231
|
function ne(e, t, n, r) {
|
|
238
232
|
let i = Math.min(r, Math.max(n, e));
|
|
239
|
-
return i !== e &&
|
|
233
|
+
return i !== e && p(`\`${t}\` ${e} is out of range (${r === Infinity ? `at least ${n}` : `${n}-${r}`}); using ${i}.`), i;
|
|
240
234
|
}
|
|
241
235
|
var re = /* @__PURE__ */ new WeakMap();
|
|
242
236
|
function ie(e) {
|
|
243
|
-
let t = { ...
|
|
237
|
+
let t = { ...j };
|
|
244
238
|
if (e == null) return t;
|
|
245
|
-
if (!
|
|
239
|
+
if (!x(e)) return v(e), t;
|
|
246
240
|
let n = re.get(e);
|
|
247
241
|
if (n) return n;
|
|
248
|
-
|
|
242
|
+
w(e, [
|
|
249
243
|
"offset",
|
|
250
244
|
"launcherSize",
|
|
251
245
|
"panel"
|
|
252
246
|
], "layout");
|
|
253
|
-
let r =
|
|
254
|
-
r && (
|
|
255
|
-
let i =
|
|
256
|
-
return i && (
|
|
247
|
+
let r = C(e, "offset", "layout.offset");
|
|
248
|
+
r && (w(r, ["x", "y"], "layout.offset"), t.offsetX = M(r.x, "layout.offset.x", j.offsetX), t.offsetY = M(r.y, "layout.offset.y", j.offsetY)), t.launcherSize = ne(M(e.launcherSize, "layout.launcherSize", j.launcherSize), "layout.launcherSize", 24, 120);
|
|
249
|
+
let i = C(e, "panel", "layout.panel");
|
|
250
|
+
return i && (w(i, ["width", "height"], "layout.panel"), t.panelWidth = ne(M(i.width, "layout.panel.width", j.panelWidth), "layout.panel.width", 280, Infinity), t.panelHeight = ne(M(i.height, "layout.panel.height", j.panelHeight), "layout.panel.height", 320, Infinity)), re.set(e, t), t;
|
|
257
251
|
}
|
|
258
252
|
//#endregion
|
|
259
|
-
//#region node_modules/.pnpm/preact@11.0.
|
|
260
|
-
var
|
|
261
|
-
function
|
|
253
|
+
//#region node_modules/.pnpm/preact@11.0.1/node_modules/preact/dist/preact.mjs
|
|
254
|
+
var N, ae, P, oe, se, ce, le, ue, de, fe, pe = {}, me = [], he = /^m(i|n|o|s|text|space)$/, ge = Array.isArray, _e = me.slice, F = Object.assign;
|
|
255
|
+
function ve(e) {
|
|
262
256
|
e && e.parentNode && e.remove();
|
|
263
257
|
}
|
|
264
|
-
function
|
|
258
|
+
function ye(e, t, n, r, i) {
|
|
265
259
|
var a = {
|
|
266
260
|
type: e,
|
|
267
261
|
props: t,
|
|
@@ -277,12 +271,12 @@ function be(e, t, n, r, i) {
|
|
|
277
271
|
__i: -1,
|
|
278
272
|
__u: 0
|
|
279
273
|
};
|
|
280
|
-
return !i &&
|
|
274
|
+
return !i && N.vnode && N.vnode(a), a;
|
|
281
275
|
}
|
|
282
276
|
function I(e) {
|
|
283
277
|
return e.children;
|
|
284
278
|
}
|
|
285
|
-
function
|
|
279
|
+
function be(e, t) {
|
|
286
280
|
this.props = e, this.context = t, this.__g = 0;
|
|
287
281
|
}
|
|
288
282
|
function L(e, t) {
|
|
@@ -290,30 +284,30 @@ function L(e, t) {
|
|
|
290
284
|
for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) && n.__e) return n.__e;
|
|
291
285
|
return typeof e.type != "function" || e.props.__P ? null : L(e);
|
|
292
286
|
}
|
|
293
|
-
function
|
|
287
|
+
function xe(e) {
|
|
294
288
|
if ((e = e.__) && e.__c && !e.props.__P) return e.__e = null, e.__k.some(function(t) {
|
|
295
289
|
return t && (e.__e = t.__e);
|
|
296
|
-
}),
|
|
290
|
+
}), xe(e);
|
|
297
291
|
}
|
|
298
|
-
function
|
|
299
|
-
(8 & e.__g || !(e.__g |= 8) || !
|
|
292
|
+
function Se(e) {
|
|
293
|
+
(8 & e.__g || !(e.__g |= 8) || !P.push(e) || se++) && oe == N.debounceRendering || ((oe = N.debounceRendering) || queueMicrotask)(Ce);
|
|
300
294
|
}
|
|
301
|
-
function
|
|
295
|
+
function Ce() {
|
|
302
296
|
var e, t, n, r, i, a, o, s, c;
|
|
303
297
|
try {
|
|
304
|
-
for (t = 1;
|
|
298
|
+
for (t = 1; P.length;) P.length > t && P.sort(ce), e = P.shift(), t = P.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, N.vnode && N.vnode(r), je(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, Ne(o, r, s), i.__ = i.__e = null, r.__e != a && xe(r)));
|
|
305
299
|
} finally {
|
|
306
|
-
|
|
300
|
+
P.length = se = 0;
|
|
307
301
|
}
|
|
308
302
|
}
|
|
309
|
-
function
|
|
310
|
-
var d, f, p, m, h, g, _ = r.__k ||
|
|
311
|
-
for (c =
|
|
303
|
+
function we(e, t, n, r, i, a, o, s, c, l, u) {
|
|
304
|
+
var d, f, p, m, h, g, _ = r.__k || me, v = t.length;
|
|
305
|
+
for (c = Te(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = ~p.__i && _[p.__i] || pe, p.__i = d, g = je(e, p, f, i, a, o, s, c, l, u), m = p.__e, (f.ref != p.ref || 8 & f.__u) && (f.ref && Fe(f.ref, null, p, f), p.ref && u.push(p.ref, p.__c || m, p)), h ||= m, 4 & p.__u ? (c = Ee(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);
|
|
312
306
|
return n.__e = h, c;
|
|
313
307
|
}
|
|
314
|
-
function
|
|
308
|
+
function Te(e, t, n, r, i) {
|
|
315
309
|
var a, o, s, c, l, u, d, f, p, m, h = n.length, g = h, _ = 0, v = !1, y = e.__k = Array(i);
|
|
316
|
-
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] =
|
|
310
|
+
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] = ye(null, o) : ge(o) ? o = y[a] = ye(I, { children: o }) : o.constructor === void 0 && o.__b ? o = y[a] = ye(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 = De(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;
|
|
317
311
|
if (v) {
|
|
318
312
|
for (u = [], d = [], a = 0; a < i; a++) if ((o = y[a]) && 2 & o.__u) {
|
|
319
313
|
for (f = 0, p = u.length; f < p;) u[m = f + p >> 1] < o.__i ? f = m + 1 : p = m;
|
|
@@ -321,20 +315,21 @@ function Ee(e, t, n, r, i) {
|
|
|
321
315
|
}
|
|
322
316
|
for (_ = u.length; a--;) d[a] && (d[a] == _ ? _-- : y[a].__u |= 4);
|
|
323
317
|
}
|
|
324
|
-
if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r = L(s)),
|
|
318
|
+
if (g) for (a = 0; a < h; a++) !(s = n[a]) || 2 & s.__u || (s.__e == r && (r = L(s)), Ie(s, s));
|
|
325
319
|
return r;
|
|
326
320
|
}
|
|
327
|
-
function
|
|
328
|
-
var i, a;
|
|
321
|
+
function Ee(e, t, n, r) {
|
|
322
|
+
var i, a, o;
|
|
329
323
|
if (typeof e.type == "function") {
|
|
330
324
|
if (e.props.__P) return t;
|
|
331
|
-
if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t =
|
|
325
|
+
if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && (i[a].__ = e, t = Ee(i[a], t, n, !1));
|
|
332
326
|
return t;
|
|
333
327
|
}
|
|
334
|
-
for (t && !t.parentNode && (t = L(e)) && !t.parentNode && (t = null),
|
|
328
|
+
for (t && !t.parentNode && (t = L(e)) && !t.parentNode && (t = null), o = t; o && o.nodeType == 8;) o = o.nextSibling;
|
|
329
|
+
for (e.__e != o && (!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;);
|
|
335
330
|
return t;
|
|
336
331
|
}
|
|
337
|
-
function
|
|
332
|
+
function De(e, t, n, r) {
|
|
338
333
|
var i, a, o, s = e.key, c = e.type, l = t[n], u = l && !(2 & l.__u);
|
|
339
334
|
if (l === null && s == null || u && s == l.key && c == l.type) return n;
|
|
340
335
|
if (r > +!!u) {
|
|
@@ -342,18 +337,18 @@ function Oe(e, t, n, r) {
|
|
|
342
337
|
}
|
|
343
338
|
return -1;
|
|
344
339
|
}
|
|
345
|
-
function
|
|
340
|
+
function Oe(e, t, n) {
|
|
346
341
|
n ??= "", t[0] == "-" ? e.setProperty(t, n) : e[t] = n;
|
|
347
342
|
}
|
|
348
|
-
function
|
|
349
|
-
var a;
|
|
343
|
+
function ke(e, t, n, r, i) {
|
|
344
|
+
var a, o;
|
|
350
345
|
n: if (t == "style") {
|
|
351
346
|
if (typeof n == "string") e.style.cssText = n;
|
|
352
347
|
else {
|
|
353
|
-
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n ||
|
|
354
|
-
if (n) for (t in n) r && n[t] == r[t] ||
|
|
348
|
+
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || Oe(e.style, t, "");
|
|
349
|
+
if (n) for (t in n) r && n[t] == r[t] || Oe(e.style, t, n[t]);
|
|
355
350
|
}
|
|
356
|
-
} else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(ue, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()),
|
|
351
|
+
} else if (t[0] == "o" && t[1] == "n") (e.__e ||= {})[t] = n, n && r || (o = fe[t] || (fe[t] = Ae(t)), (e.__a ||= {})[t] = de, a = t != (t = t.replace(ue, "$1")), (t = t.slice(2))[0] < "a" && (t = t.toLowerCase()), n ? e.addEventListener(t, o, a) : e.removeEventListener(t, o, a));
|
|
357
352
|
else {
|
|
358
353
|
if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
359
354
|
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 {
|
|
@@ -363,18 +358,18 @@ function Ae(e, t, n, r, i) {
|
|
|
363
358
|
typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
|
|
364
359
|
}
|
|
365
360
|
}
|
|
366
|
-
function
|
|
361
|
+
function Ae(e) {
|
|
367
362
|
return function(t) {
|
|
368
363
|
if (this.__e) {
|
|
369
|
-
var n = this.__e[
|
|
364
|
+
var n = this.__e[e];
|
|
370
365
|
if (t[le] == null) t[le] = de++;
|
|
371
|
-
else if (t[le] <
|
|
372
|
-
return n(
|
|
366
|
+
else if (t[le] < this.__a[e]) return;
|
|
367
|
+
return n(N.event ? N.event(t) : t);
|
|
373
368
|
}
|
|
374
369
|
};
|
|
375
370
|
}
|
|
376
|
-
function
|
|
377
|
-
var u, d, f, p, m, h, g, _, v, y, b, x, S, C,
|
|
371
|
+
function je(e, t, n, r, i, a, o, s, c, l) {
|
|
372
|
+
var u, d, f, p, m, h, g, _, v, y, b, x, S, C, w, T, E, D, O, k, A = t.type;
|
|
378
373
|
if (t.constructor !== void 0) return null;
|
|
379
374
|
if (128 & n.__u && (c = 32 & n.__u, u = n.__c.__z)) {
|
|
380
375
|
if (t.__u |= c, d = a = [], u.nodeType == 8) for (f = 1, p = u.nextSibling; p; p = p.nextSibling) {
|
|
@@ -387,71 +382,72 @@ function Me(e, t, n, r, i, a, o, s, c, l) {
|
|
|
387
382
|
else a.push(u);
|
|
388
383
|
s = a[0];
|
|
389
384
|
}
|
|
390
|
-
(u =
|
|
391
|
-
n: if (typeof
|
|
385
|
+
(u = N.__b) && u(t);
|
|
386
|
+
n: if (typeof A == "function") {
|
|
392
387
|
m = o.length;
|
|
393
388
|
try {
|
|
394
|
-
if (y = t.props, b = (u =
|
|
395
|
-
if (b && !
|
|
389
|
+
if (y = t.props, b = (u = A.prototype) && u.render, x = (u = A.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 A(y, S) : (t.__c = h = new be(y, S), h.constructor = A, h.render = Le), 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), A.getDerivedStateFromProps && (h.__s == h.state && (h.__s = F({}, h.__s)), F(h.__s, A.getDerivedStateFromProps(y, h.__s)))), g = h.props, _ = h.state, h.__v = t, n.__c) {
|
|
390
|
+
if (b && !A.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)) {
|
|
396
391
|
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) {
|
|
397
392
|
e && (e.__ = t);
|
|
398
|
-
}),
|
|
393
|
+
}), me.push.apply(h.__h, h.__k), h.__k = [], h.__h.length && o.push(h), s = L(n);
|
|
399
394
|
break n;
|
|
400
395
|
}
|
|
401
396
|
h.componentWillUpdate && h.componentWillUpdate(y, h.__s, S), b && h.componentDidUpdate && h.__h.push(function() {
|
|
402
397
|
h.componentDidUpdate(g, _, v);
|
|
403
398
|
});
|
|
404
|
-
} else b && !
|
|
405
|
-
if (h.context = S, h.props = y, h.__P = e, h.__g &= -5, C =
|
|
399
|
+
} else b && !A.getDerivedStateFromProps && h.componentWillMount && h.componentWillMount(), b && h.componentDidMount && h.__h.push(h.componentDidMount);
|
|
400
|
+
if (h.context = S, h.props = y, h.__P = e, h.__g &= -5, C = N.__r, w = 0, b) h.state = h.__s, h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), me.push.apply(h.__h, h.__k), h.__k = [];
|
|
406
401
|
else do
|
|
407
402
|
h.__g &= -9, C && C(t), u = h.render(h.props, h.state, h.context), h.state = h.__s;
|
|
408
|
-
while (8 & h.__g && ++
|
|
409
|
-
h.state = h.__s, h.getChildContext && (r = F({}, r, h.getChildContext())), b && n.__c && h.getSnapshotBeforeUpdate && (v = h.getSnapshotBeforeUpdate(g, _)),
|
|
410
|
-
e &&
|
|
411
|
-
}), n.__k = null), s = n.__k ? L(n, 0) : null), s =
|
|
403
|
+
while (8 & h.__g && ++w < 25);
|
|
404
|
+
h.state = h.__s, h.getChildContext && (r = F({}, r, h.getChildContext())), b && n.__c && h.getSnapshotBeforeUpdate && (v = h.getSnapshotBeforeUpdate(g, _)), T = 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) {
|
|
405
|
+
e && Ie(e, e);
|
|
406
|
+
}), n.__k = null), s = n.__k ? L(n, 0) : null), s = we(e, ge(T) ? T : [T], 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(ve), h.__h.length && o.push(h), 1 & h.__g && (h.__g &= -4);
|
|
412
407
|
} catch (e) {
|
|
413
408
|
if (o.length = m, t.__v = null, c || a) {
|
|
414
409
|
if (e.then) {
|
|
415
|
-
if (
|
|
416
|
-
for (
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
410
|
+
if (E = 0, t.__u |= c ? 160 : 128, a) {
|
|
411
|
+
for (~(O = a.indexOf(s || void 0)) || (O = a.length); (k = a[O - 1]) && k.nodeType == 8;) O--;
|
|
412
|
+
for (; O < a.length; O++) if (k = a[O]) {
|
|
413
|
+
if (a[O] = null, k.nodeType == 8) {
|
|
414
|
+
if (k.data.startsWith("$s")) E++ || (D = k);
|
|
415
|
+
else if (E && k.data.startsWith("/$s") && !--E) {
|
|
416
|
+
s = k;
|
|
421
417
|
break;
|
|
422
418
|
}
|
|
423
|
-
} else
|
|
419
|
+
} else if (!E) break;
|
|
424
420
|
}
|
|
425
421
|
}
|
|
426
|
-
if (!
|
|
422
|
+
if (!D) {
|
|
427
423
|
for (; s && s.nodeType == 8 && s.nextSibling;) s = s.nextSibling;
|
|
428
|
-
|
|
424
|
+
D = s;
|
|
429
425
|
}
|
|
430
|
-
t.__c.__z || (t.__c.__z =
|
|
431
|
-
} else a && a.some(
|
|
426
|
+
t.__c.__z || (t.__c.__z = D), t.__e = s;
|
|
427
|
+
} else a && a.some(ve);
|
|
432
428
|
} else t.__e = n.__e;
|
|
433
|
-
t.__k ||= n.__k || [], e.then ||
|
|
429
|
+
t.__k ||= n.__k || [], e.then || Me(t), N.__e(e, t, n);
|
|
434
430
|
}
|
|
435
|
-
} else s = t.__e =
|
|
436
|
-
return (u =
|
|
431
|
+
} else s = t.__e = Pe(n.__e, t, n, r, i, a, o, c, l, e);
|
|
432
|
+
return (u = N.diffed) && u(t), 128 & t.__u ? void 0 : s;
|
|
437
433
|
}
|
|
438
|
-
function
|
|
439
|
-
e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(
|
|
434
|
+
function Me(e) {
|
|
435
|
+
e && (e.__c && (e.__c.__g |= 4), e.__k && e.__k.some(Me));
|
|
440
436
|
}
|
|
441
|
-
function
|
|
442
|
-
for (var r = 0; r < n.length;)
|
|
443
|
-
|
|
437
|
+
function Ne(e, t, n) {
|
|
438
|
+
for (var r = 0; r < n.length;) Fe(n[r++], n[r++], n[r++]);
|
|
439
|
+
N.__c && N.__c(t, e), e.some(function(t) {
|
|
444
440
|
try {
|
|
445
441
|
e = t.__h, t.__h = [], e.some(function(e) {
|
|
446
442
|
e.call(t);
|
|
447
443
|
});
|
|
448
444
|
} catch (e) {
|
|
449
|
-
|
|
445
|
+
N.__e(e, t.__v);
|
|
450
446
|
}
|
|
451
447
|
});
|
|
452
448
|
}
|
|
453
|
-
function
|
|
454
|
-
var u, d, f, p, m, h, g, _, v, y = n.props ||
|
|
449
|
+
function Pe(e, t, n, r, i, a, o, s, c, l) {
|
|
450
|
+
var u, d, f, p, m, h, g, _, v, y = n.props || pe, b = t.props, x = t.type;
|
|
455
451
|
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) {
|
|
456
452
|
for (u = 0; u < a.length; u++) if ((m = a[u]) && (x ? m.localName == x : m.nodeType == 3)) {
|
|
457
453
|
e = m, a[u] = null;
|
|
@@ -460,44 +456,44 @@ function Fe(e, t, n, r, i, a, o, s, c, l) {
|
|
|
460
456
|
}
|
|
461
457
|
if (!e) {
|
|
462
458
|
if (_ = l.ownerDocument || document, !x) return _.createTextNode(b);
|
|
463
|
-
e = _.createElementNS(i, x, b.is && b), s &&= (
|
|
459
|
+
e = _.createElementNS(i, x, b.is && b), s &&= (N.__m && N.__m(t, a), !1), a = null;
|
|
464
460
|
}
|
|
465
461
|
if (x) {
|
|
466
|
-
if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a &&
|
|
467
|
-
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 ||
|
|
468
|
-
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) ||
|
|
469
|
-
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" &&
|
|
462
|
+
if (l = x == "template" ? e.content : e, a = x == "textarea" && b.defaultValue != null ? null : a && _e.call(l.childNodes), !s && a) for (y = {}, u = 0; u < e.attributes.length; u++) y[(m = e.attributes[u]).name] = m.value;
|
|
463
|
+
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 || ke(e, u, null, m, i);
|
|
464
|
+
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) || ke(e, u, m, y[u], i);
|
|
465
|
+
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" && he.test(x)) && (i = "http://www.w3.org/1999/xhtml"), we(l, ge(p) ? p : [p], t, n, r, i, a, o, a ? a[0] : n.__k && L(n, 0), s, c), a && a.some(ve)), s && x != "textarea" || (u = "value", x == "progress" && h == null ? e.removeAttribute(u) : h == null || h === e[u] && (x != "progress" || h) || ke(e, u, h, y[u], i), u = "checked", g != null && g != e[u] && ke(e, u, g, y[u], i));
|
|
470
466
|
} else y === b || s && e.data == b || (e.data = b);
|
|
471
467
|
return e;
|
|
472
468
|
}
|
|
473
|
-
function
|
|
469
|
+
function Fe(e, t, n, r) {
|
|
474
470
|
try {
|
|
475
|
-
typeof e == "function" ? (
|
|
471
|
+
typeof e == "function" ? t ? t.__x = e(t) || 1 : (r &&= r.__c || r.__e) && (t = r.__x) && (r.__x = null, typeof t == "function" ? t() : e(null)) : e.current = t;
|
|
476
472
|
} catch (e) {
|
|
477
|
-
|
|
473
|
+
N.__e(e, n);
|
|
478
474
|
}
|
|
479
475
|
}
|
|
480
|
-
function
|
|
476
|
+
function Ie(e, t, n) {
|
|
481
477
|
var r, i;
|
|
482
|
-
if (
|
|
478
|
+
if (N.unmount && N.unmount(e), !(r = e.ref) || r.current && r.current != e.__e || Fe(r, null, t, e), r = e.__c) {
|
|
483
479
|
if (r.componentWillUnmount) try {
|
|
484
480
|
r.componentWillUnmount();
|
|
485
481
|
} catch (e) {
|
|
486
|
-
|
|
482
|
+
N.__e(e, t);
|
|
487
483
|
}
|
|
488
484
|
r.__P = r.__n = null;
|
|
489
485
|
}
|
|
490
|
-
if (r = e.__k) for (i = 0; i < r.length; i++) r[i] &&
|
|
491
|
-
(r = e.__e) && (n ||
|
|
486
|
+
if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && Ie(r[i], t, typeof e.type != "function" || n && !e.props.__P);
|
|
487
|
+
(r = e.__e) && (n || ve(r), r.__e && (r.__e = null)), e.__e = e.__c = e.__ = null;
|
|
492
488
|
}
|
|
493
|
-
function
|
|
489
|
+
function Le(e, t, n) {
|
|
494
490
|
return this.constructor(e, n);
|
|
495
491
|
}
|
|
496
|
-
function
|
|
492
|
+
function Re(e, t) {
|
|
497
493
|
var n, r, i, a;
|
|
498
|
-
|
|
494
|
+
N.__ && N.__(e, t), t.nodeType == 9 && (t = t.documentElement), r = (n = e && 32 & e.__u) ? null : t.__k, t.__k = ye(I, { children: [e] }), i = [], a = [], je(t, t.__k, r || pe, pe, t.namespaceURI, r ? null : t.firstChild ? _e.call(t.childNodes) : null, i, r ? r.__e : t.firstChild, n, a), Ne(i, t.__k, a), t.__k.props.children = null;
|
|
499
495
|
}
|
|
500
|
-
|
|
496
|
+
N = { __e: function(e, t, n, r) {
|
|
501
497
|
for (var i, a, o; t = t.__;) if ((i = t.__c) && !(1 & i.__g)) {
|
|
502
498
|
i.__g |= 4;
|
|
503
499
|
try {
|
|
@@ -507,33 +503,33 @@ M = { __e: function(e, t, n, r) {
|
|
|
507
503
|
}
|
|
508
504
|
}
|
|
509
505
|
throw se = 0, e;
|
|
510
|
-
} }, ae = 0,
|
|
506
|
+
} }, ae = 0, be.prototype.setState = function(e, t) {
|
|
511
507
|
var n = this.__s;
|
|
512
|
-
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),
|
|
513
|
-
},
|
|
514
|
-
this.__v && (this.__g |= 4, e && this.__h.push(e),
|
|
515
|
-
},
|
|
508
|
+
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), Se(this)));
|
|
509
|
+
}, be.prototype.forceUpdate = function(e) {
|
|
510
|
+
this.__v && (this.__g |= 4, e && this.__h.push(e), Se(this));
|
|
511
|
+
}, be.prototype.render = I, P = [], se = 0, ce = function(e, t) {
|
|
516
512
|
return e.__v.__b - t.__v.__b;
|
|
517
|
-
}, le = Symbol(),
|
|
513
|
+
}, le = Symbol(), ue = /(PointerCapture)$|Capture$/i, de = 0, fe = {};
|
|
518
514
|
//#endregion
|
|
519
|
-
//#region node_modules/.pnpm/preact@11.0.
|
|
520
|
-
var R, z, Be, Ve
|
|
521
|
-
function
|
|
522
|
-
B.__h && B.__h(z, e,
|
|
515
|
+
//#region node_modules/.pnpm/preact@11.0.1/node_modules/preact/hooks/dist/hooks.mjs
|
|
516
|
+
var R, z, ze, Be, Ve = Object.is, He = 0, Ue = [], We = [], B = N, Ge = B.__b, Ke = B.__r, qe = B.diffed, Je = B.__c, Ye = B.unmount, Xe = B.__;
|
|
517
|
+
function Ze(e, t) {
|
|
518
|
+
B.__h && B.__h(z, e, He || t), He = 0;
|
|
523
519
|
var n = z.__H || (z.__H = {
|
|
524
520
|
__: [],
|
|
525
521
|
__h: []
|
|
526
522
|
});
|
|
527
523
|
return e >= n.__.length && n.__.push({}), n.__[e];
|
|
528
524
|
}
|
|
529
|
-
function
|
|
530
|
-
return
|
|
525
|
+
function Qe(e) {
|
|
526
|
+
return He = 1, $e(ct, e);
|
|
531
527
|
}
|
|
532
528
|
function $e(e, t, n) {
|
|
533
|
-
var r =
|
|
534
|
-
if (r.t = e, !r.__c && (r.__ = [n ? n(t) :
|
|
529
|
+
var r = Ze(R++, 2);
|
|
530
|
+
if (r.t = e, !r.__c && (r.__ = [n ? n(t) : ct(void 0, t), function(e) {
|
|
535
531
|
var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
|
|
536
|
-
|
|
532
|
+
Ve(t, n) || (r.__N = [n, r.__[1]], r.__c.setState({}));
|
|
537
533
|
}], r.__c = z, !z.__f)) {
|
|
538
534
|
z.__f = !0;
|
|
539
535
|
var i = z.shouldComponentUpdate;
|
|
@@ -542,7 +538,7 @@ function $e(e, t, n) {
|
|
|
542
538
|
if (!r) return !0;
|
|
543
539
|
var a = !1, o = this.props != e;
|
|
544
540
|
if (r.__.some(function(e) {
|
|
545
|
-
e.__N && (a = !0,
|
|
541
|
+
e.__N && (a = !0, Ve(e.__[0], e.__N[0]) || (o = !0));
|
|
546
542
|
}), i) {
|
|
547
543
|
var s = i.call(this, e, t, n);
|
|
548
544
|
return a ? s || o : s;
|
|
@@ -553,70 +549,70 @@ function $e(e, t, n) {
|
|
|
553
549
|
return r.__;
|
|
554
550
|
}
|
|
555
551
|
function et(e, t) {
|
|
556
|
-
var n =
|
|
557
|
-
!B.__s &&
|
|
552
|
+
var n = Ze(R++, 3);
|
|
553
|
+
!B.__s && st(n.__H, t) && (n.__P = !0, n.__ = e, n.u = t, z.__H.__h.push(n));
|
|
558
554
|
}
|
|
559
|
-
function
|
|
560
|
-
var n =
|
|
561
|
-
!B.__s &&
|
|
555
|
+
function V(e, t) {
|
|
556
|
+
var n = Ze(R++, 4);
|
|
557
|
+
!B.__s && st(n.__H, t) && (n.__P = !1, n.__ = e, n.u = t, z.__h.push(n));
|
|
562
558
|
}
|
|
563
559
|
function H(e) {
|
|
564
|
-
return
|
|
560
|
+
return He = 5, tt(function() {
|
|
565
561
|
return { current: e };
|
|
566
562
|
}, []);
|
|
567
563
|
}
|
|
568
|
-
function
|
|
569
|
-
var n =
|
|
570
|
-
return
|
|
564
|
+
function tt(e, t) {
|
|
565
|
+
var n = Ze(R++, 7);
|
|
566
|
+
return st(n.__H, t) && (n.__ = e(), n.__H = t), n.__;
|
|
571
567
|
}
|
|
572
|
-
function
|
|
568
|
+
function nt() {
|
|
573
569
|
var e;
|
|
574
570
|
do {
|
|
575
|
-
for (; e =
|
|
571
|
+
for (; e = We.shift();) try {
|
|
576
572
|
U(e);
|
|
577
573
|
} catch (t) {
|
|
578
574
|
B.__e(t, { __: (e = e.__P) && e.__v });
|
|
579
575
|
}
|
|
580
|
-
for (; e =
|
|
576
|
+
for (; e = Ue.shift();) {
|
|
581
577
|
var t = e.__H;
|
|
582
578
|
if (e.__P && t) try {
|
|
583
|
-
t.__h.some(U), t.__h.some(
|
|
579
|
+
t.__h.some(U), t.__h.some(ot), t.__h = [];
|
|
584
580
|
} catch (n) {
|
|
585
581
|
t.__h = [], B.__e(n, e.__v);
|
|
586
582
|
}
|
|
587
583
|
}
|
|
588
|
-
} while (
|
|
584
|
+
} while (We.length);
|
|
589
585
|
}
|
|
590
586
|
B.__b = function(e) {
|
|
591
|
-
z = null,
|
|
587
|
+
z = null, Ge && Ge(e);
|
|
592
588
|
}, B.__ = function(e, t) {
|
|
593
|
-
e && t.__k && t.__k.__m && (e.__m = t.__k.__m),
|
|
589
|
+
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Xe && Xe(e, t);
|
|
594
590
|
}, B.__r = function(e) {
|
|
595
|
-
|
|
591
|
+
Ke && Ke(e), R = 0;
|
|
596
592
|
var t = (z = e.__c).__H;
|
|
597
|
-
t && (
|
|
593
|
+
t && (ze == z ? z.__h = [] : (t.__h.some(U), t.__h.some(ot), R = 0), t.__h = [], t.__.some(function(e) {
|
|
598
594
|
e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
|
|
599
|
-
})),
|
|
595
|
+
})), ze = z;
|
|
600
596
|
}, B.diffed = function(e) {
|
|
601
|
-
|
|
597
|
+
qe && qe(e);
|
|
602
598
|
var t = e.__c;
|
|
603
|
-
t && t.__H && (t.__H.__h.length &&
|
|
599
|
+
t && t.__H && (t.__H.__h.length && at(Ue.push(t)), t.__H.__.some(function(e) {
|
|
604
600
|
e.u && (e.__H = e.u);
|
|
605
|
-
})),
|
|
601
|
+
})), ze = z = null;
|
|
606
602
|
}, B.__c = function(e, t) {
|
|
607
603
|
t.some(function(e) {
|
|
608
604
|
try {
|
|
609
605
|
e.__h.some(U), e.__h = e.__h.filter(function(e) {
|
|
610
|
-
return !e.__ ||
|
|
606
|
+
return !e.__ || ot(e);
|
|
611
607
|
});
|
|
612
608
|
} catch (n) {
|
|
613
609
|
t.some(function(e) {
|
|
614
610
|
e.__h &&= [];
|
|
615
611
|
}), t = [], B.__e(n, e.__v);
|
|
616
612
|
}
|
|
617
|
-
}),
|
|
613
|
+
}), Je && Je(e, t);
|
|
618
614
|
}, B.unmount = function(e) {
|
|
619
|
-
|
|
615
|
+
Ye && Ye(e);
|
|
620
616
|
var t, n, r = e.__c;
|
|
621
617
|
r && r.__H && (r.__H.__.some(function(r) {
|
|
622
618
|
try {
|
|
@@ -625,42 +621,42 @@ B.__b = function(e) {
|
|
|
625
621
|
for (n = e.__; n && (!n.__c || !n.__c.__P);) n = n.__;
|
|
626
622
|
n &&= n.__c;
|
|
627
623
|
}
|
|
628
|
-
r.__P = n,
|
|
624
|
+
r.__P = n, at(We.push(r));
|
|
629
625
|
} else U(r);
|
|
630
626
|
} catch (e) {
|
|
631
627
|
t = e;
|
|
632
628
|
}
|
|
633
629
|
}), r.__H = void 0, t && B.__e(t, r.__v));
|
|
634
630
|
};
|
|
635
|
-
var
|
|
636
|
-
function
|
|
631
|
+
var rt = typeof requestAnimationFrame == "function";
|
|
632
|
+
function it(e) {
|
|
637
633
|
var t, n = function() {
|
|
638
|
-
clearTimeout(r),
|
|
634
|
+
clearTimeout(r), rt && cancelAnimationFrame(t), setTimeout(e);
|
|
639
635
|
}, r = setTimeout(n, 35);
|
|
640
|
-
|
|
636
|
+
rt && (t = requestAnimationFrame(n));
|
|
641
637
|
}
|
|
642
|
-
function
|
|
643
|
-
e != 1 &&
|
|
638
|
+
function at(e) {
|
|
639
|
+
e != 1 && Be == B.requestAnimationFrame || ((Be = B.requestAnimationFrame) || it)(nt);
|
|
644
640
|
}
|
|
645
641
|
function U(e) {
|
|
646
642
|
var t = z, n = e.__c;
|
|
647
643
|
typeof n == "function" && (e.__c = void 0, n()), z = t;
|
|
648
644
|
}
|
|
649
|
-
function
|
|
645
|
+
function ot(e) {
|
|
650
646
|
var t = z;
|
|
651
647
|
e.__c = e.__(), z = t;
|
|
652
648
|
}
|
|
653
|
-
function
|
|
649
|
+
function st(e, t) {
|
|
654
650
|
return !e || e.length != t.length || t.some(function(t, n) {
|
|
655
|
-
return !
|
|
651
|
+
return !Ve(t, e[n]);
|
|
656
652
|
});
|
|
657
653
|
}
|
|
658
|
-
function
|
|
654
|
+
function ct(e, t) {
|
|
659
655
|
return typeof t == "function" ? t(e) : t;
|
|
660
656
|
}
|
|
661
657
|
//#endregion
|
|
662
|
-
//#region node_modules/.pnpm/preact@11.0.
|
|
663
|
-
var
|
|
658
|
+
//#region node_modules/.pnpm/preact@11.0.1/node_modules/preact/jsx-runtime/dist/jsxRuntime.mjs
|
|
659
|
+
var lt = 0;
|
|
664
660
|
Array.isArray;
|
|
665
661
|
function W(e, t, n, r, i, a) {
|
|
666
662
|
t ||= {};
|
|
@@ -677,11 +673,11 @@ function W(e, t, n, r, i, a) {
|
|
|
677
673
|
__e: null,
|
|
678
674
|
__c: null,
|
|
679
675
|
constructor: void 0,
|
|
680
|
-
__v: --
|
|
676
|
+
__v: --lt,
|
|
681
677
|
__i: -1,
|
|
682
678
|
__u: 0
|
|
683
679
|
};
|
|
684
|
-
return (i || a) && (l.__source = i, l.__self = a),
|
|
680
|
+
return (i || a) && (l.__source = i, l.__self = a), N.vnode && N.vnode(l), l;
|
|
685
681
|
}
|
|
686
682
|
//#endregion
|
|
687
683
|
//#region src/components/icons.tsx
|
|
@@ -701,7 +697,7 @@ function G({ name: e, size: t, children: n }) {
|
|
|
701
697
|
children: n
|
|
702
698
|
});
|
|
703
699
|
}
|
|
704
|
-
function
|
|
700
|
+
function ut({ size: e = 26 }) {
|
|
705
701
|
return /* @__PURE__ */ W(G, {
|
|
706
702
|
name: "chat",
|
|
707
703
|
size: e,
|
|
@@ -711,64 +707,64 @@ function dt({ size: e = 26 }) {
|
|
|
711
707
|
})]
|
|
712
708
|
});
|
|
713
709
|
}
|
|
714
|
-
function
|
|
710
|
+
function dt({ size: e = 26 }) {
|
|
715
711
|
return /* @__PURE__ */ W(G, {
|
|
716
712
|
name: "message",
|
|
717
713
|
size: e,
|
|
718
714
|
children: /* @__PURE__ */ W("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" })
|
|
719
715
|
});
|
|
720
716
|
}
|
|
721
|
-
function
|
|
717
|
+
function ft({ size: e = 26 }) {
|
|
722
718
|
return /* @__PURE__ */ W(G, {
|
|
723
719
|
name: "sparkle",
|
|
724
720
|
size: e,
|
|
725
721
|
children: [/* @__PURE__ */ W("path", { d: "M11 3l1.9 5.1L18 10l-5.1 1.9L11 17l-1.9-5.1L4 10l5.1-1.9z" }), /* @__PURE__ */ W("path", { d: "M19 15l.7 1.8 1.8.7-1.8.7L19 20l-.7-1.8-1.8-.7 1.8-.7z" })]
|
|
726
722
|
});
|
|
727
723
|
}
|
|
728
|
-
function
|
|
724
|
+
function pt({ size: e = 26 }) {
|
|
729
725
|
return /* @__PURE__ */ W(G, {
|
|
730
726
|
name: "chevron-down",
|
|
731
727
|
size: e,
|
|
732
728
|
children: /* @__PURE__ */ W("path", { d: "M6 9l6 6 6-6" })
|
|
733
729
|
});
|
|
734
730
|
}
|
|
735
|
-
function
|
|
731
|
+
function mt({ size: e = 18 }) {
|
|
736
732
|
return /* @__PURE__ */ W(G, {
|
|
737
733
|
name: "close",
|
|
738
734
|
size: e,
|
|
739
735
|
children: /* @__PURE__ */ W("path", { d: "M6 6l12 12M18 6L6 18" })
|
|
740
736
|
});
|
|
741
737
|
}
|
|
742
|
-
var
|
|
743
|
-
function
|
|
738
|
+
var ht = "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";
|
|
739
|
+
function gt({ size: e = 16 }) {
|
|
744
740
|
return /* @__PURE__ */ W(G, {
|
|
745
741
|
name: "thumb-up",
|
|
746
742
|
size: e,
|
|
747
|
-
children: /* @__PURE__ */ W("path", { d:
|
|
743
|
+
children: /* @__PURE__ */ W("path", { d: ht })
|
|
748
744
|
});
|
|
749
745
|
}
|
|
750
|
-
function
|
|
746
|
+
function _t({ size: e = 16 }) {
|
|
751
747
|
return /* @__PURE__ */ W(G, {
|
|
752
748
|
name: "thumb-down",
|
|
753
749
|
size: e,
|
|
754
750
|
children: /* @__PURE__ */ W("path", {
|
|
755
|
-
d:
|
|
751
|
+
d: ht,
|
|
756
752
|
transform: "matrix(1 0 0 -1 0 24)"
|
|
757
753
|
})
|
|
758
754
|
});
|
|
759
755
|
}
|
|
760
756
|
//#endregion
|
|
761
757
|
//#region src/components/Launcher.tsx
|
|
762
|
-
var
|
|
763
|
-
chat:
|
|
764
|
-
message:
|
|
765
|
-
sparkle:
|
|
766
|
-
},
|
|
767
|
-
"chevron-down":
|
|
768
|
-
close:
|
|
758
|
+
var vt = {
|
|
759
|
+
chat: ut,
|
|
760
|
+
message: dt,
|
|
761
|
+
sparkle: ft
|
|
762
|
+
}, yt = {
|
|
763
|
+
"chevron-down": pt,
|
|
764
|
+
close: mt
|
|
769
765
|
};
|
|
770
|
-
function
|
|
771
|
-
let [l, u] =
|
|
766
|
+
function bt({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl: a, openIcon: o = "chevron-down", buttonRef: s, text: c = e }) {
|
|
767
|
+
let [l, u] = Qe("loading"), [d, f] = Qe("loading"), p = r !== void 0 && l !== "failed", m = a !== void 0 && d !== "failed", h = p && !t && l === "loaded", g = m && t && d === "loaded", _ = vt[i] ?? ut, v = yt[o] ?? pt;
|
|
772
768
|
return /* @__PURE__ */ W("button", {
|
|
773
769
|
type: "button",
|
|
774
770
|
class: "whoo-widget-launcher",
|
|
@@ -800,7 +796,7 @@ function xt({ isOpen: t, onClick: n, iconUrl: r, icon: i = "chat", openIconUrl:
|
|
|
800
796
|
}
|
|
801
797
|
//#endregion
|
|
802
798
|
//#region src/i18n/index.ts
|
|
803
|
-
var
|
|
799
|
+
var xt = {
|
|
804
800
|
en: e,
|
|
805
801
|
fr: {
|
|
806
802
|
openChat: "Ouvrir le chat",
|
|
@@ -829,7 +825,8 @@ var St = {
|
|
|
829
825
|
conversationCleared: "Conversation effacée",
|
|
830
826
|
genericError: "Une erreur s’est produite. Veuillez réessayer.",
|
|
831
827
|
sessionExpired: "Cette session de chat a expiré. Rechargez la page pour continuer.",
|
|
832
|
-
opensInNewTab: "(s’ouvre dans un nouvel onglet)"
|
|
828
|
+
opensInNewTab: "(s’ouvre dans un nouvel onglet)",
|
|
829
|
+
agreeToNotice: "J’accepte"
|
|
833
830
|
},
|
|
834
831
|
es: {
|
|
835
832
|
openChat: "Abrir chat",
|
|
@@ -858,7 +855,8 @@ var St = {
|
|
|
858
855
|
conversationCleared: "Se inició una nueva conversación",
|
|
859
856
|
genericError: "Algo salió mal. Inténtelo de nuevo.",
|
|
860
857
|
sessionExpired: "Esta sesión de chat expiró. Vuelva a cargar la página para continuar.",
|
|
861
|
-
opensInNewTab: "(se abre en una pestaña nueva)"
|
|
858
|
+
opensInNewTab: "(se abre en una pestaña nueva)",
|
|
859
|
+
agreeToNotice: "Acepto"
|
|
862
860
|
},
|
|
863
861
|
pt: {
|
|
864
862
|
openChat: "Abrir chat",
|
|
@@ -887,7 +885,8 @@ var St = {
|
|
|
887
885
|
conversationCleared: "Nova conversa iniciada",
|
|
888
886
|
genericError: "Algo deu errado. Tente novamente.",
|
|
889
887
|
sessionExpired: "Esta sessão de chat expirou. Recarregue a página para continuar.",
|
|
890
|
-
opensInNewTab: "(abre em uma nova aba)"
|
|
888
|
+
opensInNewTab: "(abre em uma nova aba)",
|
|
889
|
+
agreeToNotice: "Concordo"
|
|
891
890
|
},
|
|
892
891
|
de: {
|
|
893
892
|
openChat: "Chat öffnen",
|
|
@@ -916,7 +915,8 @@ var St = {
|
|
|
916
915
|
conversationCleared: "Neue Unterhaltung gestartet",
|
|
917
916
|
genericError: "Etwas ist schiefgelaufen. Bitte versuchen Sie es erneut.",
|
|
918
917
|
sessionExpired: "Diese Chat-Sitzung ist abgelaufen. Laden Sie die Seite neu, um fortzufahren.",
|
|
919
|
-
opensInNewTab: "(öffnet sich in neuem Tab)"
|
|
918
|
+
opensInNewTab: "(öffnet sich in neuem Tab)",
|
|
919
|
+
agreeToNotice: "Ich stimme zu"
|
|
920
920
|
},
|
|
921
921
|
it: {
|
|
922
922
|
openChat: "Apri la chat",
|
|
@@ -945,7 +945,8 @@ var St = {
|
|
|
945
945
|
conversationCleared: "Nuova conversazione avviata",
|
|
946
946
|
genericError: "Si è verificato un errore. Riprovi.",
|
|
947
947
|
sessionExpired: "Questa sessione di chat è scaduta. Ricarichi la pagina per continuare.",
|
|
948
|
-
opensInNewTab: "(si apre in una nuova scheda)"
|
|
948
|
+
opensInNewTab: "(si apre in una nuova scheda)",
|
|
949
|
+
agreeToNotice: "Accetto"
|
|
949
950
|
},
|
|
950
951
|
ja: {
|
|
951
952
|
openChat: "チャットを開く",
|
|
@@ -974,7 +975,8 @@ var St = {
|
|
|
974
975
|
conversationCleared: "会話を消去しました",
|
|
975
976
|
genericError: "エラーが発生しました。もう一度お試しください。",
|
|
976
977
|
sessionExpired: "このチャットセッションの有効期限が切れました。続けるにはページを再読み込みしてください。",
|
|
977
|
-
opensInNewTab: "(新しいタブで開きます)"
|
|
978
|
+
opensInNewTab: "(新しいタブで開きます)",
|
|
979
|
+
agreeToNotice: "同意する"
|
|
978
980
|
},
|
|
979
981
|
zh: {
|
|
980
982
|
openChat: "打开聊天",
|
|
@@ -1003,7 +1005,8 @@ var St = {
|
|
|
1003
1005
|
conversationCleared: "对话已清除",
|
|
1004
1006
|
genericError: "出了点问题,请重试。",
|
|
1005
1007
|
sessionExpired: "此聊天会话已过期。请刷新页面后继续。",
|
|
1006
|
-
opensInNewTab: "(将在新标签页中打开)"
|
|
1008
|
+
opensInNewTab: "(将在新标签页中打开)",
|
|
1009
|
+
agreeToNotice: "我同意"
|
|
1007
1010
|
},
|
|
1008
1011
|
ru: {
|
|
1009
1012
|
openChat: "Открыть чат",
|
|
@@ -1032,7 +1035,8 @@ var St = {
|
|
|
1032
1035
|
conversationCleared: "Диалог очищен",
|
|
1033
1036
|
genericError: "Что-то пошло не так. Попробуйте ещё раз.",
|
|
1034
1037
|
sessionExpired: "Срок действия сеанса чата истёк. Перезагрузите страницу, чтобы продолжить.",
|
|
1035
|
-
opensInNewTab: "(откроется в новой вкладке)"
|
|
1038
|
+
opensInNewTab: "(откроется в новой вкладке)",
|
|
1039
|
+
agreeToNotice: "Принимаю"
|
|
1036
1040
|
},
|
|
1037
1041
|
hi: {
|
|
1038
1042
|
openChat: "चैट खोलें",
|
|
@@ -1061,7 +1065,8 @@ var St = {
|
|
|
1061
1065
|
conversationCleared: "बातचीत मिटा दी गई",
|
|
1062
1066
|
genericError: "कुछ ग़लत हो गया। कृपया फिर से कोशिश करें।",
|
|
1063
1067
|
sessionExpired: "यह चैट सत्र समाप्त हो गया है। जारी रखने के लिए पेज को फिर से लोड करें।",
|
|
1064
|
-
opensInNewTab: "(नए टैब में खुलता है)"
|
|
1068
|
+
opensInNewTab: "(नए टैब में खुलता है)",
|
|
1069
|
+
agreeToNotice: "मैं सहमत हूँ"
|
|
1065
1070
|
},
|
|
1066
1071
|
ar: {
|
|
1067
1072
|
openChat: "فتح الدردشة",
|
|
@@ -1090,47 +1095,48 @@ var St = {
|
|
|
1090
1095
|
conversationCleared: "تم مسح المحادثة",
|
|
1091
1096
|
genericError: "حدث خطأ ما. يُرجى المحاولة مرة أخرى.",
|
|
1092
1097
|
sessionExpired: "انتهت صلاحية جلسة الدردشة هذه. يُرجى إعادة تحميل الصفحة للمتابعة.",
|
|
1093
|
-
opensInNewTab: "(يُفتح في علامة تبويب جديدة)"
|
|
1098
|
+
opensInNewTab: "(يُفتح في علامة تبويب جديدة)",
|
|
1099
|
+
agreeToNotice: "أوافق"
|
|
1094
1100
|
}
|
|
1095
|
-
},
|
|
1101
|
+
}, St = Object.freeze(Object.keys(xt)), Ct = {
|
|
1096
1102
|
pt: "pt-BR",
|
|
1097
1103
|
es: "es-419",
|
|
1098
1104
|
zh: "zh-Hans"
|
|
1099
|
-
},
|
|
1100
|
-
function
|
|
1101
|
-
return
|
|
1105
|
+
}, wt = /* @__PURE__ */ new Set(["ar"]), Tt = /^[a-z]{2,8}([-_][a-z0-9]{1,8})*$/i, Et = /^zh[-_](hant|tw|hk|mo)(?=$|[-_])/i;
|
|
1106
|
+
function Dt(e) {
|
|
1107
|
+
return xt[e];
|
|
1102
1108
|
}
|
|
1103
|
-
function
|
|
1109
|
+
function Ot(e) {
|
|
1104
1110
|
let t = e.trim();
|
|
1105
|
-
if (!
|
|
1111
|
+
if (!Tt.test(t) || Et.test(t)) return null;
|
|
1106
1112
|
let n = t.split(/[-_]/)[0].toLowerCase();
|
|
1107
|
-
return Object.hasOwn(
|
|
1113
|
+
return Object.hasOwn(xt, n) ? n : null;
|
|
1108
1114
|
}
|
|
1109
|
-
function
|
|
1115
|
+
function kt(e, t) {
|
|
1110
1116
|
let n = null;
|
|
1111
|
-
return e != null && e !== "" && (n = typeof e == "string" ?
|
|
1117
|
+
return e != null && e !== "" && (n = typeof e == "string" ? Ot(e) : null, n || console.warn(`whoo-aiden-widget: ignoring \`language\` ${At(e)} -- expected one of ${St.join(", ")} (or a regional tag like pt-BR). Using the page's language instead.`)), n ??= typeof t == "string" ? Ot(t) : null, n ??= "en", {
|
|
1112
1118
|
language: n,
|
|
1113
|
-
tag:
|
|
1114
|
-
dir:
|
|
1119
|
+
tag: Ct[n] ?? n,
|
|
1120
|
+
dir: wt.has(n) ? "rtl" : "ltr"
|
|
1115
1121
|
};
|
|
1116
1122
|
}
|
|
1117
|
-
function
|
|
1123
|
+
function At(e) {
|
|
1118
1124
|
return typeof e == "string" ? JSON.stringify(e) : `(a ${typeof e})`;
|
|
1119
1125
|
}
|
|
1120
|
-
function
|
|
1126
|
+
function jt(e) {
|
|
1121
1127
|
if (typeof e != "string") return null;
|
|
1122
1128
|
let t = e.trim().replace(/_/g, "-");
|
|
1123
|
-
return
|
|
1129
|
+
return Tt.test(t) ? t : null;
|
|
1124
1130
|
}
|
|
1125
|
-
function
|
|
1131
|
+
function Mt(e, t, n) {
|
|
1126
1132
|
if (e != null && e !== "") {
|
|
1127
|
-
let t =
|
|
1133
|
+
let t = jt(e);
|
|
1128
1134
|
if (t) return t;
|
|
1129
|
-
console.warn(`whoo-aiden-widget: ignoring \`contentLanguage\` ${
|
|
1135
|
+
console.warn(`whoo-aiden-widget: ignoring \`contentLanguage\` ${At(e)} -- expected a language tag such as 'nl' or 'pt-BR'. Using the page's language instead.`);
|
|
1130
1136
|
}
|
|
1131
|
-
return
|
|
1137
|
+
return jt(t) ?? jt(n) ?? "";
|
|
1132
1138
|
}
|
|
1133
|
-
function
|
|
1139
|
+
function Nt(e) {
|
|
1134
1140
|
let t = e.indexOf("{name}");
|
|
1135
1141
|
return t === -1 ? {
|
|
1136
1142
|
before: e,
|
|
@@ -1144,19 +1150,19 @@ function Pt(e) {
|
|
|
1144
1150
|
}
|
|
1145
1151
|
//#endregion
|
|
1146
1152
|
//#region src/viewport.ts
|
|
1147
|
-
var
|
|
1148
|
-
function
|
|
1153
|
+
var Pt = "(max-width: 400px), (max-height: 420px)", Ft = "data-fit-visible", It = 40;
|
|
1154
|
+
function Lt(e) {
|
|
1149
1155
|
let t = typeof window < "u" ? window.visualViewport : null;
|
|
1150
1156
|
if (!t) return () => {};
|
|
1151
1157
|
let n = () => {
|
|
1152
|
-
e.removeAttribute(
|
|
1158
|
+
e.removeAttribute(Ft), e.style.removeProperty("--whoo-widget-visible-top"), e.style.removeProperty("--whoo-widget-visible-height");
|
|
1153
1159
|
}, r = () => {
|
|
1154
1160
|
let r = document.documentElement.clientHeight, i = Math.abs(t.scale - 1) > .01, a = r - t.height;
|
|
1155
|
-
if (i || r === 0 || a <
|
|
1161
|
+
if (i || r === 0 || a < It) {
|
|
1156
1162
|
n();
|
|
1157
1163
|
return;
|
|
1158
1164
|
}
|
|
1159
|
-
e.setAttribute(
|
|
1165
|
+
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`);
|
|
1160
1166
|
let o = e.getRootNode().activeElement;
|
|
1161
1167
|
o && e.contains(o) && typeof o.scrollIntoView == "function" && o.scrollIntoView({ block: "nearest" });
|
|
1162
1168
|
};
|
|
@@ -1164,43 +1170,43 @@ function Rt(e) {
|
|
|
1164
1170
|
t.removeEventListener("resize", r), t.removeEventListener("scroll", r), n();
|
|
1165
1171
|
};
|
|
1166
1172
|
}
|
|
1167
|
-
function
|
|
1173
|
+
function Rt(e, t) {
|
|
1168
1174
|
return typeof e.addEventListener == "function" ? (e.addEventListener("change", t), () => e.removeEventListener("change", t)) : typeof e.addListener == "function" ? (e.addListener(t), () => e.removeListener(t)) : () => {};
|
|
1169
1175
|
}
|
|
1170
|
-
var
|
|
1176
|
+
var zt = 0, Bt = "";
|
|
1177
|
+
function Vt() {
|
|
1178
|
+
zt++ === 0 && (Bt = document.documentElement.style.overflow, document.documentElement.style.overflow = "hidden");
|
|
1179
|
+
}
|
|
1171
1180
|
function Ht() {
|
|
1172
|
-
|
|
1181
|
+
--zt === 0 && (document.documentElement.style.overflow = Bt);
|
|
1173
1182
|
}
|
|
1174
1183
|
function Ut() {
|
|
1175
|
-
--Bt === 0 && (document.documentElement.style.overflow = Vt);
|
|
1176
|
-
}
|
|
1177
|
-
function Wt() {
|
|
1178
1184
|
if (typeof window > "u" || typeof window.matchMedia != "function") return () => {};
|
|
1179
|
-
let e = window.matchMedia(
|
|
1180
|
-
e.matches && !t ? (t = !0,
|
|
1185
|
+
let e = window.matchMedia(Pt), t = !1, n = () => {
|
|
1186
|
+
e.matches && !t ? (t = !0, Vt()) : !e.matches && t && (t = !1, Ht());
|
|
1181
1187
|
};
|
|
1182
1188
|
n();
|
|
1183
|
-
let r =
|
|
1189
|
+
let r = Rt(e, n);
|
|
1184
1190
|
return () => {
|
|
1185
|
-
r(), t && (t = !1,
|
|
1191
|
+
r(), t && (t = !1, Ht());
|
|
1186
1192
|
};
|
|
1187
1193
|
}
|
|
1188
|
-
function
|
|
1194
|
+
function Wt(e) {
|
|
1189
1195
|
if (typeof window > "u" || typeof window.matchMedia != "function" || typeof e.showModal != "function") return () => {};
|
|
1190
|
-
let t = window.matchMedia(
|
|
1196
|
+
let t = window.matchMedia(Pt), n = !1, r = () => {
|
|
1191
1197
|
if (t.matches === n || !e.isConnected) return;
|
|
1192
1198
|
n = t.matches;
|
|
1193
1199
|
let r = e.getRootNode().activeElement;
|
|
1194
1200
|
e.close(), n ? e.showModal() : e.show(), r && e.contains(r) && r.focus({ preventScroll: !0 });
|
|
1195
1201
|
};
|
|
1196
|
-
return r(),
|
|
1202
|
+
return r(), Rt(t, r);
|
|
1197
1203
|
}
|
|
1198
1204
|
//#endregion
|
|
1199
1205
|
//#region src/components/Composer.tsx
|
|
1200
|
-
function
|
|
1206
|
+
function Gt(e) {
|
|
1201
1207
|
return e.isComposing || e.keyCode === 229;
|
|
1202
1208
|
}
|
|
1203
|
-
function
|
|
1209
|
+
function Kt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text: o = e, contentLanguage: s }) {
|
|
1204
1210
|
return /* @__PURE__ */ W("div", {
|
|
1205
1211
|
class: "whoo-widget-composer",
|
|
1206
1212
|
children: [
|
|
@@ -1220,7 +1226,7 @@ function qt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text:
|
|
|
1220
1226
|
ref: a,
|
|
1221
1227
|
onInput: (e) => n(e.target.value),
|
|
1222
1228
|
onKeyDown: (e) => {
|
|
1223
|
-
e.key === "Enter" && !
|
|
1229
|
+
e.key === "Enter" && !Gt(e) && r();
|
|
1224
1230
|
}
|
|
1225
1231
|
}),
|
|
1226
1232
|
/* @__PURE__ */ W("button", {
|
|
@@ -1237,7 +1243,7 @@ function qt({ value: t, onChange: n, onSend: r, disabled: i, inputRef: a, text:
|
|
|
1237
1243
|
}
|
|
1238
1244
|
//#endregion
|
|
1239
1245
|
//#region src/components/ErrorBanner.tsx
|
|
1240
|
-
function
|
|
1246
|
+
function qt({ message: e }) {
|
|
1241
1247
|
return /* @__PURE__ */ W("div", {
|
|
1242
1248
|
class: "whoo-widget-error-banner",
|
|
1243
1249
|
role: "alert",
|
|
@@ -1246,7 +1252,7 @@ function Jt({ message: e }) {
|
|
|
1246
1252
|
}
|
|
1247
1253
|
//#endregion
|
|
1248
1254
|
//#region src/markdown/tokenizer.ts
|
|
1249
|
-
var
|
|
1255
|
+
var Jt = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, Yt = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, Xt = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, Zt = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, Qt = /[ \t]*[*+-][ \t]+/y, $t = /https?:\/\/\S+/y, en = /[.,;:!?)\]}>]+$/;
|
|
1250
1256
|
function tn(e) {
|
|
1251
1257
|
let t = [], n = 0, r = 0, i = (n) => {
|
|
1252
1258
|
n > r && t.push({
|
|
@@ -1276,28 +1282,28 @@ function tn(e) {
|
|
|
1276
1282
|
}
|
|
1277
1283
|
}
|
|
1278
1284
|
if (e[n - 1] !== "!") {
|
|
1279
|
-
|
|
1280
|
-
let a =
|
|
1285
|
+
Jt.lastIndex = n;
|
|
1286
|
+
let a = Jt.exec(e);
|
|
1281
1287
|
if (a) {
|
|
1282
1288
|
i(n), t.push({
|
|
1283
1289
|
type: "link",
|
|
1284
1290
|
text: a[1],
|
|
1285
1291
|
url: a[2],
|
|
1286
1292
|
start: n,
|
|
1287
|
-
end:
|
|
1288
|
-
}), n =
|
|
1293
|
+
end: Jt.lastIndex
|
|
1294
|
+
}), n = Jt.lastIndex, r = n;
|
|
1289
1295
|
continue;
|
|
1290
1296
|
}
|
|
1291
1297
|
}
|
|
1292
|
-
|
|
1293
|
-
let a =
|
|
1298
|
+
Yt.lastIndex = n;
|
|
1299
|
+
let a = Yt.exec(e);
|
|
1294
1300
|
if (a) {
|
|
1295
1301
|
i(n), t.push({
|
|
1296
1302
|
type: "bold",
|
|
1297
1303
|
value: a[1],
|
|
1298
1304
|
start: n,
|
|
1299
|
-
end:
|
|
1300
|
-
}), n =
|
|
1305
|
+
end: Yt.lastIndex
|
|
1306
|
+
}), n = Yt.lastIndex, r = n;
|
|
1301
1307
|
continue;
|
|
1302
1308
|
}
|
|
1303
1309
|
Xt.lastIndex = n;
|
|
@@ -1373,11 +1379,11 @@ function on(e) {
|
|
|
1373
1379
|
}];
|
|
1374
1380
|
}) : null;
|
|
1375
1381
|
}
|
|
1376
|
-
function
|
|
1382
|
+
function K(e, t = {}) {
|
|
1377
1383
|
return tn(e).map((e, n) => {
|
|
1378
1384
|
switch (e.type) {
|
|
1379
|
-
case "bold": return /* @__PURE__ */ W("strong", { children:
|
|
1380
|
-
case "italic": return /* @__PURE__ */ W("em", { children:
|
|
1385
|
+
case "bold": return /* @__PURE__ */ W("strong", { children: K(e.value, t) }, n);
|
|
1386
|
+
case "italic": return /* @__PURE__ */ W("em", { children: K(e.value, t) }, n);
|
|
1381
1387
|
case "link": return /* @__PURE__ */ W("a", {
|
|
1382
1388
|
href: e.url,
|
|
1383
1389
|
target: "_blank",
|
|
@@ -1399,9 +1405,9 @@ function sn(e, t = {}) {
|
|
|
1399
1405
|
dir: an(e.items.find((e) => an(e)) ?? ""),
|
|
1400
1406
|
children: e.items.map((e, n) => /* @__PURE__ */ W("li", {
|
|
1401
1407
|
dir: an(e),
|
|
1402
|
-
children:
|
|
1408
|
+
children: K(e, t)
|
|
1403
1409
|
}, n))
|
|
1404
|
-
}, n) : /* @__PURE__ */ W("span", { children:
|
|
1410
|
+
}, n) : /* @__PURE__ */ W("span", { children: K(e.text, t) }, n)) : K(n, t);
|
|
1405
1411
|
}
|
|
1406
1412
|
//#endregion
|
|
1407
1413
|
//#region src/components/MessageFeedback.tsx
|
|
@@ -1431,7 +1437,7 @@ function cn(e) {
|
|
|
1431
1437
|
}
|
|
1432
1438
|
function ln({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraftChange: a, onSubmitDetailed: o, onCancel: s, text: c = e, contentLanguage: l }) {
|
|
1433
1439
|
let u = t.correction ?? "", d = t.category ?? "", f = H(t.status), p = H(null), m = H(null);
|
|
1434
|
-
if (
|
|
1440
|
+
if (V(() => {
|
|
1435
1441
|
let e = f.current;
|
|
1436
1442
|
if (f.current = t.status, e === t.status) return;
|
|
1437
1443
|
if (t.status === "expanded") {
|
|
@@ -1498,7 +1504,7 @@ function ln({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraft
|
|
|
1498
1504
|
onClick: () => {
|
|
1499
1505
|
h || r();
|
|
1500
1506
|
},
|
|
1501
|
-
children: /* @__PURE__ */ W(
|
|
1507
|
+
children: /* @__PURE__ */ W(gt, {})
|
|
1502
1508
|
}), /* @__PURE__ */ W("button", {
|
|
1503
1509
|
ref: m,
|
|
1504
1510
|
type: "button",
|
|
@@ -1507,7 +1513,7 @@ function ln({ state: t, containerRef: n, onThumbsUp: r, onThumbsDown: i, onDraft
|
|
|
1507
1513
|
onClick: () => {
|
|
1508
1514
|
h || i();
|
|
1509
1515
|
},
|
|
1510
|
-
children: /* @__PURE__ */ W(
|
|
1516
|
+
children: /* @__PURE__ */ W(_t, {})
|
|
1511
1517
|
})]
|
|
1512
1518
|
}), /* @__PURE__ */ W("div", {
|
|
1513
1519
|
role: "status",
|
|
@@ -1537,7 +1543,7 @@ function un({ isSlowResponse: e, text: t }) {
|
|
|
1537
1543
|
});
|
|
1538
1544
|
}
|
|
1539
1545
|
function dn({ url: e, alt: t, lang: n }) {
|
|
1540
|
-
let [r, i] =
|
|
1546
|
+
let [r, i] = Qe(!1);
|
|
1541
1547
|
return r ? null : /* @__PURE__ */ W("img", {
|
|
1542
1548
|
class: "whoo-widget-empty-state-image",
|
|
1543
1549
|
src: e,
|
|
@@ -1547,7 +1553,24 @@ function dn({ url: e, alt: t, lang: n }) {
|
|
|
1547
1553
|
onError: () => i(!0)
|
|
1548
1554
|
});
|
|
1549
1555
|
}
|
|
1550
|
-
|
|
1556
|
+
var fn = "whoo-widget-notice";
|
|
1557
|
+
function pn({ notice: e, text: t, contentLanguage: n, languageTag: r }) {
|
|
1558
|
+
return /* @__PURE__ */ W("div", {
|
|
1559
|
+
id: fn,
|
|
1560
|
+
class: "whoo-widget-notice",
|
|
1561
|
+
role: "note",
|
|
1562
|
+
children: /* @__PURE__ */ W("div", {
|
|
1563
|
+
class: "whoo-widget-message-text",
|
|
1564
|
+
dir: "auto",
|
|
1565
|
+
lang: n,
|
|
1566
|
+
children: sn(e, {
|
|
1567
|
+
linkCue: t.opensInNewTab,
|
|
1568
|
+
linkCueLang: r
|
|
1569
|
+
})
|
|
1570
|
+
})
|
|
1571
|
+
});
|
|
1572
|
+
}
|
|
1573
|
+
function mn({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u, text: d, contentLanguage: f, languageTag: p }) {
|
|
1551
1574
|
let m = H(null), h = e.id;
|
|
1552
1575
|
return /* @__PURE__ */ W("div", {
|
|
1553
1576
|
ref: m,
|
|
@@ -1591,75 +1614,90 @@ function fn({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending
|
|
|
1591
1614
|
]
|
|
1592
1615
|
});
|
|
1593
1616
|
}
|
|
1594
|
-
function
|
|
1595
|
-
let
|
|
1617
|
+
function hn({ messages: t, messageFeedback: n, announcement: r, emptyStateImage: i, notice: a, agentName: o = l, showFeedback: s = !1, isStreaming: c = !1, isSlowResponse: u = !1, onThumbsUp: d, onThumbsDown: f, onDraftChange: p = () => {}, onSubmitDetailed: m, onCancelFeedback: h, text: g = e, contentLanguage: _, languageTag: v, announcementIsContent: y = !1 }) {
|
|
1618
|
+
let b = H(null), x = !!a && !t.some((e) => e.role === "user");
|
|
1596
1619
|
return et(() => {
|
|
1597
|
-
let e =
|
|
1598
|
-
e && (e.scrollTop = e.scrollHeight);
|
|
1599
|
-
}, [
|
|
1620
|
+
let e = b.current;
|
|
1621
|
+
e && (e.scrollTop = x ? 0 : e.scrollHeight);
|
|
1622
|
+
}, [
|
|
1623
|
+
t,
|
|
1624
|
+
u,
|
|
1625
|
+
x
|
|
1626
|
+
]), /* @__PURE__ */ W(I, { children: [/* @__PURE__ */ W("section", {
|
|
1600
1627
|
class: "whoo-widget-message-list",
|
|
1601
|
-
ref:
|
|
1602
|
-
"aria-label":
|
|
1628
|
+
ref: b,
|
|
1629
|
+
"aria-label": g.conversation,
|
|
1603
1630
|
tabIndex: 0,
|
|
1604
|
-
children: [
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1631
|
+
children: [
|
|
1632
|
+
i ? /* @__PURE__ */ W(dn, {
|
|
1633
|
+
...i,
|
|
1634
|
+
lang: _
|
|
1635
|
+
}) : null,
|
|
1636
|
+
a ? /* @__PURE__ */ W(pn, {
|
|
1637
|
+
notice: a,
|
|
1638
|
+
text: g,
|
|
1639
|
+
contentLanguage: _,
|
|
1640
|
+
languageTag: v
|
|
1641
|
+
}) : null,
|
|
1642
|
+
t.map((e, r) => /* @__PURE__ */ W(mn, {
|
|
1643
|
+
message: e,
|
|
1644
|
+
speaker: e.role === "user" ? g.you : o,
|
|
1645
|
+
showFeedback: s,
|
|
1646
|
+
feedbackState: e.id ? n[e.id] ?? { status: "idle" } : { status: "idle" },
|
|
1647
|
+
pending: c && r === t.length - 1 && e.role === "assistant" && e.content === "",
|
|
1648
|
+
isSlowResponse: u,
|
|
1649
|
+
onThumbsUp: d,
|
|
1650
|
+
onThumbsDown: f,
|
|
1651
|
+
onDraftChange: p,
|
|
1652
|
+
onSubmitDetailed: m,
|
|
1653
|
+
onCancelFeedback: h,
|
|
1654
|
+
text: g,
|
|
1655
|
+
contentLanguage: _,
|
|
1656
|
+
languageTag: v
|
|
1657
|
+
}, e.id ?? r))
|
|
1658
|
+
]
|
|
1623
1659
|
}), /* @__PURE__ */ W("div", {
|
|
1624
1660
|
class: "whoo-widget-sr-only",
|
|
1625
1661
|
"aria-live": "polite",
|
|
1626
1662
|
"aria-atomic": "true",
|
|
1627
|
-
lang:
|
|
1663
|
+
lang: y ? _ : v,
|
|
1628
1664
|
children: r ?? ""
|
|
1629
1665
|
})] });
|
|
1630
1666
|
}
|
|
1631
1667
|
//#endregion
|
|
1632
1668
|
//#region src/components/Panel.tsx
|
|
1633
|
-
var
|
|
1634
|
-
function
|
|
1635
|
-
return Array.from(e.querySelectorAll(
|
|
1669
|
+
var gn = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
|
|
1670
|
+
function _n(e) {
|
|
1671
|
+
return Array.from(e.querySelectorAll(gn)).filter((e) => {
|
|
1636
1672
|
let t = getComputedStyle(e);
|
|
1637
1673
|
return t.display !== "none" && t.visibility !== "hidden";
|
|
1638
1674
|
});
|
|
1639
1675
|
}
|
|
1640
|
-
function
|
|
1641
|
-
let r = H(null), i = H(null);
|
|
1642
|
-
|
|
1643
|
-
i.current?.focus();
|
|
1644
|
-
}, []),
|
|
1645
|
-
|
|
1676
|
+
function vn({ state: e, controller: t, greeting: n }) {
|
|
1677
|
+
let r = H(null), i = H(null), a = H(null), o = H(!1);
|
|
1678
|
+
V(() => {
|
|
1679
|
+
(a.current ?? i.current)?.focus();
|
|
1680
|
+
}, []), V(() => {
|
|
1681
|
+
e.noticeAgreed && o.current && (o.current = !1, i.current?.focus());
|
|
1682
|
+
}, [e.noticeAgreed]), V(() => {
|
|
1683
|
+
let e = r.current, n = e ? Lt(e) : () => {}, i = e ? Wt(e) : () => {}, a = () => {
|
|
1646
1684
|
e && !e.open && t.close();
|
|
1647
1685
|
};
|
|
1648
1686
|
e?.addEventListener("close", a);
|
|
1649
|
-
let o =
|
|
1687
|
+
let o = Ut();
|
|
1650
1688
|
return () => {
|
|
1651
1689
|
n(), i(), e?.removeEventListener("close", a), o();
|
|
1652
1690
|
};
|
|
1653
1691
|
}, []);
|
|
1654
|
-
let
|
|
1655
|
-
if (e.key === "Escape" && !
|
|
1692
|
+
let s = (e) => {
|
|
1693
|
+
if (e.key === "Escape" && !Gt(e)) {
|
|
1656
1694
|
e.preventDefault(), t.close();
|
|
1657
1695
|
return;
|
|
1658
1696
|
}
|
|
1659
1697
|
if (e.key !== "Tab") return;
|
|
1660
1698
|
let n = r.current;
|
|
1661
1699
|
if (!n) return;
|
|
1662
|
-
let i =
|
|
1700
|
+
let i = _n(n);
|
|
1663
1701
|
if (i.length === 0) return;
|
|
1664
1702
|
let a = n.getRootNode().activeElement;
|
|
1665
1703
|
e.preventDefault();
|
|
@@ -1670,15 +1708,15 @@ function gn({ state: e, controller: t, greeting: n }) {
|
|
|
1670
1708
|
s = e.shiftKey ? t <= 0 ? o : t - 1 : t === -1 ? 0 : t;
|
|
1671
1709
|
} else s = e.shiftKey ? o : 0;
|
|
1672
1710
|
i[s].focus();
|
|
1673
|
-
},
|
|
1711
|
+
}, c = () => {
|
|
1674
1712
|
let n = e.draft.trim();
|
|
1675
1713
|
n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
|
|
1676
|
-
},
|
|
1714
|
+
}, l = u(t.config.name) || e.agentName || "Aiden", d = u(t.config.title), { before: f, after: p, hasName: m } = Nt(t.text.chatWith), h = e.messages.length === 0 && n ? [{
|
|
1677
1715
|
role: "assistant",
|
|
1678
1716
|
content: n,
|
|
1679
1717
|
id: null
|
|
1680
|
-
}] : e.messages,
|
|
1681
|
-
url:
|
|
1718
|
+
}] : e.messages, g = t.emptyStateImageUrl, _ = e.messages.length === 0 && g ? {
|
|
1719
|
+
url: g,
|
|
1682
1720
|
alt: t.emptyStateImageAlt
|
|
1683
1721
|
} : void 0;
|
|
1684
1722
|
return /* @__PURE__ */ W("dialog", {
|
|
@@ -1686,30 +1724,31 @@ function gn({ state: e, controller: t, greeting: n }) {
|
|
|
1686
1724
|
class: "whoo-widget-panel",
|
|
1687
1725
|
"aria-modal": "true",
|
|
1688
1726
|
"aria-labelledby": "whoo-widget-title",
|
|
1727
|
+
"aria-describedby": t.notice && e.noticeAgreed && e.messages.length === 0 ? fn : void 0,
|
|
1689
1728
|
ref: r,
|
|
1690
|
-
onKeyDown:
|
|
1729
|
+
onKeyDown: s,
|
|
1691
1730
|
onCancel: (e) => {
|
|
1692
1731
|
e.preventDefault(), t.close();
|
|
1693
1732
|
},
|
|
1694
1733
|
children: [
|
|
1695
1734
|
/* @__PURE__ */ W("div", {
|
|
1696
1735
|
class: "whoo-widget-header",
|
|
1697
|
-
children: [
|
|
1736
|
+
children: [d ? /* @__PURE__ */ W("h2", {
|
|
1698
1737
|
id: "whoo-widget-title",
|
|
1699
1738
|
class: "whoo-widget-header-title",
|
|
1700
1739
|
lang: t.contentLanguage,
|
|
1701
1740
|
dir: "auto",
|
|
1702
|
-
children:
|
|
1741
|
+
children: d
|
|
1703
1742
|
}) : /* @__PURE__ */ W("h2", {
|
|
1704
1743
|
id: "whoo-widget-title",
|
|
1705
1744
|
class: "whoo-widget-header-title",
|
|
1706
1745
|
children: [
|
|
1707
|
-
|
|
1708
|
-
|
|
1746
|
+
f,
|
|
1747
|
+
m ? /* @__PURE__ */ W("bdi", {
|
|
1709
1748
|
lang: t.contentLanguage,
|
|
1710
|
-
children:
|
|
1749
|
+
children: l
|
|
1711
1750
|
}) : null,
|
|
1712
|
-
|
|
1751
|
+
p
|
|
1713
1752
|
]
|
|
1714
1753
|
}), /* @__PURE__ */ W("div", {
|
|
1715
1754
|
class: "whoo-widget-header-actions",
|
|
@@ -1725,16 +1764,17 @@ function gn({ state: e, controller: t, greeting: n }) {
|
|
|
1725
1764
|
class: "whoo-widget-header-close",
|
|
1726
1765
|
"aria-label": t.text.closeChat,
|
|
1727
1766
|
onClick: () => t.close(),
|
|
1728
|
-
children: /* @__PURE__ */ W(
|
|
1767
|
+
children: /* @__PURE__ */ W(mt, {})
|
|
1729
1768
|
})]
|
|
1730
1769
|
})]
|
|
1731
1770
|
}),
|
|
1732
|
-
/* @__PURE__ */ W(
|
|
1733
|
-
messages:
|
|
1771
|
+
/* @__PURE__ */ W(hn, {
|
|
1772
|
+
messages: h,
|
|
1734
1773
|
messageFeedback: e.messageFeedback,
|
|
1735
1774
|
announcement: e.announcement,
|
|
1736
|
-
emptyStateImage:
|
|
1737
|
-
|
|
1775
|
+
emptyStateImage: _,
|
|
1776
|
+
notice: t.notice,
|
|
1777
|
+
agentName: l,
|
|
1738
1778
|
showFeedback: t.showFeedback,
|
|
1739
1779
|
isStreaming: e.isStreaming,
|
|
1740
1780
|
isSlowResponse: e.isSlowResponse,
|
|
@@ -1748,26 +1788,39 @@ function gn({ state: e, controller: t, greeting: n }) {
|
|
|
1748
1788
|
languageTag: t.languageTag,
|
|
1749
1789
|
announcementIsContent: e.announcementIsContent
|
|
1750
1790
|
}),
|
|
1751
|
-
e.runtimeError && /* @__PURE__ */ W(
|
|
1752
|
-
/* @__PURE__ */ W(
|
|
1791
|
+
e.runtimeError && /* @__PURE__ */ W(qt, { message: e.runtimeError }),
|
|
1792
|
+
e.noticeAgreed ? /* @__PURE__ */ W(Kt, {
|
|
1753
1793
|
value: e.draft,
|
|
1754
1794
|
onChange: (e) => t.setDraft(e),
|
|
1755
|
-
onSend:
|
|
1795
|
+
onSend: c,
|
|
1756
1796
|
disabled: e.isStreaming,
|
|
1757
1797
|
inputRef: i,
|
|
1758
1798
|
text: t.text,
|
|
1759
1799
|
contentLanguage: t.contentLanguage
|
|
1800
|
+
}) : /* @__PURE__ */ W("div", {
|
|
1801
|
+
class: "whoo-widget-agreement",
|
|
1802
|
+
children: /* @__PURE__ */ W("button", {
|
|
1803
|
+
type: "button",
|
|
1804
|
+
class: "whoo-widget-agreement-button",
|
|
1805
|
+
ref: a,
|
|
1806
|
+
"aria-describedby": fn,
|
|
1807
|
+
autoFocus: !0,
|
|
1808
|
+
onClick: () => {
|
|
1809
|
+
o.current = !0, t.agreeToNotice();
|
|
1810
|
+
},
|
|
1811
|
+
children: t.text.agreeToNotice
|
|
1812
|
+
})
|
|
1760
1813
|
})
|
|
1761
1814
|
]
|
|
1762
1815
|
});
|
|
1763
1816
|
}
|
|
1764
1817
|
//#endregion
|
|
1765
1818
|
//#region src/components/App.tsx
|
|
1766
|
-
function
|
|
1767
|
-
let [t, n] =
|
|
1768
|
-
return et(() => (n(e.getState()), e.subscribe(n)), [e]),
|
|
1819
|
+
function yn({ controller: e }) {
|
|
1820
|
+
let [t, n] = Qe(e.getState()), r = H(null), i = H(t.isOpen);
|
|
1821
|
+
return et(() => (n(e.getState()), e.subscribe(n)), [e]), V(() => {
|
|
1769
1822
|
i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
|
|
1770
|
-
}, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ W(I, { children: [/* @__PURE__ */ W(
|
|
1823
|
+
}, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ W(I, { children: [/* @__PURE__ */ W(bt, {
|
|
1771
1824
|
isOpen: t.isOpen,
|
|
1772
1825
|
onClick: () => t.isOpen ? e.close() : e.open(),
|
|
1773
1826
|
iconUrl: e.launcher.iconUrl,
|
|
@@ -1776,7 +1829,7 @@ function _n({ controller: e }) {
|
|
|
1776
1829
|
openIcon: e.launcher.openIcon,
|
|
1777
1830
|
buttonRef: r,
|
|
1778
1831
|
text: e.text
|
|
1779
|
-
}), t.isOpen && /* @__PURE__ */ W(
|
|
1832
|
+
}), t.isOpen && /* @__PURE__ */ W(vn, {
|
|
1780
1833
|
state: t,
|
|
1781
1834
|
controller: e,
|
|
1782
1835
|
greeting: e.config.greeting
|
|
@@ -1784,44 +1837,44 @@ function _n({ controller: e }) {
|
|
|
1784
1837
|
}
|
|
1785
1838
|
//#endregion
|
|
1786
1839
|
//#region src/api/client.ts
|
|
1787
|
-
var
|
|
1840
|
+
var bn = class extends Error {
|
|
1788
1841
|
status;
|
|
1789
1842
|
constructor(e, t) {
|
|
1790
1843
|
super(e), this.name = "WidgetApiError", this.status = t;
|
|
1791
1844
|
}
|
|
1792
1845
|
};
|
|
1793
|
-
function
|
|
1846
|
+
function xn(e) {
|
|
1794
1847
|
if (typeof e != "string") return null;
|
|
1795
1848
|
let t = e.trim();
|
|
1796
1849
|
return t === "" ? null : t;
|
|
1797
1850
|
}
|
|
1798
|
-
async function
|
|
1851
|
+
async function Sn(e, t) {
|
|
1799
1852
|
let n = await fetch(`${e}/api/v1/widget/session`, {
|
|
1800
1853
|
method: "POST",
|
|
1801
1854
|
headers: { "Content-Type": "application/json" },
|
|
1802
1855
|
body: JSON.stringify({ publishable_key: t })
|
|
1803
1856
|
});
|
|
1804
|
-
if (!n.ok) throw new
|
|
1857
|
+
if (!n.ok) throw new bn(`Failed to create widget session (${n.status})`, n.status);
|
|
1805
1858
|
let r = await n.json();
|
|
1806
1859
|
return {
|
|
1807
1860
|
token: r.token,
|
|
1808
|
-
...
|
|
1861
|
+
...Cn(r)
|
|
1809
1862
|
};
|
|
1810
1863
|
}
|
|
1811
|
-
function
|
|
1864
|
+
function Cn(e) {
|
|
1812
1865
|
return {
|
|
1813
|
-
primaryColor:
|
|
1814
|
-
name:
|
|
1815
|
-
accentColor:
|
|
1816
|
-
inkColor:
|
|
1866
|
+
primaryColor: xn(e.primary_color),
|
|
1867
|
+
name: xn(e.name),
|
|
1868
|
+
accentColor: xn(e.accent_color),
|
|
1869
|
+
inkColor: xn(e.ink_color)
|
|
1817
1870
|
};
|
|
1818
1871
|
}
|
|
1819
|
-
async function
|
|
1872
|
+
async function wn(e, t) {
|
|
1820
1873
|
let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
|
|
1821
|
-
if (!n.ok) throw new
|
|
1822
|
-
return
|
|
1874
|
+
if (!n.ok) throw new bn(`Failed to load widget branding (${n.status})`, n.status);
|
|
1875
|
+
return Cn(await n.json());
|
|
1823
1876
|
}
|
|
1824
|
-
async function
|
|
1877
|
+
async function Tn(e, t, n) {
|
|
1825
1878
|
let r = await fetch(`${e}/api/v1/widget/feedback`, {
|
|
1826
1879
|
method: "POST",
|
|
1827
1880
|
headers: {
|
|
@@ -1835,11 +1888,11 @@ async function Cn(e, t, n) {
|
|
|
1835
1888
|
category: n.category ?? null
|
|
1836
1889
|
})
|
|
1837
1890
|
});
|
|
1838
|
-
if (!r.ok) throw new
|
|
1891
|
+
if (!r.ok) throw new bn(`Feedback submission failed (${r.status})`, r.status);
|
|
1839
1892
|
}
|
|
1840
1893
|
//#endregion
|
|
1841
1894
|
//#region src/api/sse.ts
|
|
1842
|
-
async function*
|
|
1895
|
+
async function* En(e, t, n, r, i) {
|
|
1843
1896
|
let a = await fetch(`${e}/api/v1/widget/chat`, {
|
|
1844
1897
|
method: "POST",
|
|
1845
1898
|
headers: {
|
|
@@ -1852,7 +1905,7 @@ async function* wn(e, t, n, r, i) {
|
|
|
1852
1905
|
}),
|
|
1853
1906
|
signal: i
|
|
1854
1907
|
});
|
|
1855
|
-
if (!a.ok || !a.body) throw new
|
|
1908
|
+
if (!a.ok || !a.body) throw new bn(`Chat request failed (${a.status})`, a.status);
|
|
1856
1909
|
let o = a.body.getReader(), s = new TextDecoder(), c = "";
|
|
1857
1910
|
for (;;) {
|
|
1858
1911
|
let { done: e, value: t } = await o.read();
|
|
@@ -1864,11 +1917,11 @@ async function* wn(e, t, n, r, i) {
|
|
|
1864
1917
|
c = c.slice(n + 2);
|
|
1865
1918
|
let t = e.split("\n").find((e) => e.startsWith("data: "));
|
|
1866
1919
|
if (i?.aborted) return;
|
|
1867
|
-
t && (yield
|
|
1920
|
+
t && (yield Dn(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
|
|
1868
1921
|
}
|
|
1869
1922
|
}
|
|
1870
1923
|
}
|
|
1871
|
-
function
|
|
1924
|
+
function Dn(e) {
|
|
1872
1925
|
return typeof e.error == "string" ? {
|
|
1873
1926
|
type: "error",
|
|
1874
1927
|
error: e.error,
|
|
@@ -1891,11 +1944,11 @@ function Tn(e) {
|
|
|
1891
1944
|
}
|
|
1892
1945
|
//#endregion
|
|
1893
1946
|
//#region src/markdown/plainText.ts
|
|
1894
|
-
function
|
|
1947
|
+
function On(e) {
|
|
1895
1948
|
return tn(e.replace(/\r\n?/g, "\n")).map((e) => {
|
|
1896
1949
|
switch (e.type) {
|
|
1897
1950
|
case "bold":
|
|
1898
|
-
case "italic": return
|
|
1951
|
+
case "italic": return On(e.value);
|
|
1899
1952
|
case "link": return e.text;
|
|
1900
1953
|
default: return e.value;
|
|
1901
1954
|
}
|
|
@@ -1903,8 +1956,8 @@ function En(e) {
|
|
|
1903
1956
|
}
|
|
1904
1957
|
//#endregion
|
|
1905
1958
|
//#region src/markdown/reveal.ts
|
|
1906
|
-
var
|
|
1907
|
-
function
|
|
1959
|
+
var kn = 40, An = 120;
|
|
1960
|
+
function jn(e) {
|
|
1908
1961
|
let t = [];
|
|
1909
1962
|
for (let n of tn(e)) if (n.type === "text") {
|
|
1910
1963
|
let e = n.value.split(/(\s+)/), r = n.start;
|
|
@@ -1912,7 +1965,7 @@ function kn(e) {
|
|
|
1912
1965
|
} else t.push(n.end);
|
|
1913
1966
|
return t;
|
|
1914
1967
|
}
|
|
1915
|
-
function
|
|
1968
|
+
function Mn(e) {
|
|
1916
1969
|
let t = null;
|
|
1917
1970
|
return e?.addEventListener("abort", () => {
|
|
1918
1971
|
t?.();
|
|
@@ -1927,14 +1980,14 @@ function An(e) {
|
|
|
1927
1980
|
});
|
|
1928
1981
|
};
|
|
1929
1982
|
}
|
|
1930
|
-
async function
|
|
1931
|
-
let r = n?.wordIntervalMs ??
|
|
1932
|
-
for (let n of
|
|
1983
|
+
async function Nn(e, t, n) {
|
|
1984
|
+
let r = n?.wordIntervalMs ?? kn, i = n?.tokenIntervalMs ?? An, a = n?.signal, o = tn(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = Mn(a), l = "";
|
|
1985
|
+
for (let n of jn(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
|
|
1933
1986
|
l !== e && t(e);
|
|
1934
1987
|
}
|
|
1935
1988
|
//#endregion
|
|
1936
1989
|
//#region src/sessionToken.ts
|
|
1937
|
-
function
|
|
1990
|
+
function Pn(e) {
|
|
1938
1991
|
let t = e.split(".");
|
|
1939
1992
|
if (t.length !== 3 || t.some((e) => e === "")) return null;
|
|
1940
1993
|
let n = t[1];
|
|
@@ -1948,45 +2001,60 @@ function Mn(e) {
|
|
|
1948
2001
|
return null;
|
|
1949
2002
|
}
|
|
1950
2003
|
}
|
|
1951
|
-
function
|
|
1952
|
-
let t =
|
|
2004
|
+
function Fn(e) {
|
|
2005
|
+
let t = Pn(e)?.exp;
|
|
1953
2006
|
return typeof t == "number" ? t * 1e3 : null;
|
|
1954
2007
|
}
|
|
1955
|
-
function
|
|
1956
|
-
let n =
|
|
2008
|
+
function In(e, t = Date.now()) {
|
|
2009
|
+
let n = Fn(e);
|
|
1957
2010
|
return n !== null && n <= t;
|
|
1958
2011
|
}
|
|
1959
|
-
function
|
|
1960
|
-
let n =
|
|
2012
|
+
function Ln(e, t = Date.now()) {
|
|
2013
|
+
let n = Pn(e);
|
|
1961
2014
|
return n?.exp == null ? null : n.iat != null && n.exp > n.iat ? t + (n.exp - n.iat) * 1e3 : n.exp * 1e3;
|
|
1962
2015
|
}
|
|
1963
2016
|
//#endregion
|
|
1964
2017
|
//#region src/storage.ts
|
|
1965
|
-
function
|
|
2018
|
+
function Rn(e) {
|
|
1966
2019
|
return `whoo-aiden-widget:conversation:${e}`;
|
|
1967
2020
|
}
|
|
1968
|
-
function
|
|
2021
|
+
function zn(e) {
|
|
1969
2022
|
try {
|
|
1970
|
-
return window.sessionStorage.getItem(
|
|
2023
|
+
return window.sessionStorage.getItem(Rn(e));
|
|
1971
2024
|
} catch {
|
|
1972
2025
|
return null;
|
|
1973
2026
|
}
|
|
1974
2027
|
}
|
|
1975
|
-
function
|
|
2028
|
+
function Bn(e, t) {
|
|
1976
2029
|
try {
|
|
1977
|
-
window.sessionStorage.setItem(
|
|
2030
|
+
window.sessionStorage.setItem(Rn(e), t);
|
|
1978
2031
|
} catch {}
|
|
1979
2032
|
}
|
|
1980
|
-
function
|
|
2033
|
+
function Vn(e) {
|
|
2034
|
+
return `whoo-aiden-widget:notice-agreed:${e}`;
|
|
2035
|
+
}
|
|
2036
|
+
function Hn(e, t) {
|
|
1981
2037
|
try {
|
|
1982
|
-
window.sessionStorage.
|
|
2038
|
+
return window.sessionStorage.getItem(Vn(e)) === t;
|
|
2039
|
+
} catch {
|
|
2040
|
+
return !1;
|
|
2041
|
+
}
|
|
2042
|
+
}
|
|
2043
|
+
function Un(e, t) {
|
|
2044
|
+
try {
|
|
2045
|
+
window.sessionStorage.setItem(Vn(e), t);
|
|
2046
|
+
} catch {}
|
|
2047
|
+
}
|
|
2048
|
+
function Wn(e) {
|
|
2049
|
+
try {
|
|
2050
|
+
window.sessionStorage.removeItem(Rn(e));
|
|
1983
2051
|
} catch {}
|
|
1984
2052
|
}
|
|
1985
2053
|
//#endregion
|
|
1986
2054
|
//#region src/theme.ts
|
|
1987
|
-
var
|
|
1988
|
-
function
|
|
1989
|
-
if (
|
|
2055
|
+
var Gn = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
|
|
2056
|
+
function Kn(e) {
|
|
2057
|
+
if (Gn.test(e.trim())) return null;
|
|
1990
2058
|
let t = document.createElement("div");
|
|
1991
2059
|
if (t.style.color = e, t.style.color === "") return null;
|
|
1992
2060
|
let n = document.createElement("div");
|
|
@@ -2005,69 +2073,69 @@ function Vn(e) {
|
|
|
2005
2073
|
translucent: a < 1
|
|
2006
2074
|
};
|
|
2007
2075
|
}
|
|
2008
|
-
function
|
|
2009
|
-
return
|
|
2076
|
+
function q(e) {
|
|
2077
|
+
return Kn(e)?.rgb ?? null;
|
|
2010
2078
|
}
|
|
2011
|
-
function
|
|
2079
|
+
function J([e, t, n]) {
|
|
2012
2080
|
let r = (e) => {
|
|
2013
2081
|
let t = e / 255;
|
|
2014
2082
|
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
2015
2083
|
};
|
|
2016
2084
|
return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
|
|
2017
2085
|
}
|
|
2018
|
-
function
|
|
2086
|
+
function qn(e, t) {
|
|
2019
2087
|
let n = Math.max(e, t), r = Math.min(e, t);
|
|
2020
2088
|
return (n + .05) / (r + .05);
|
|
2021
2089
|
}
|
|
2022
|
-
function
|
|
2023
|
-
let t =
|
|
2090
|
+
function Jn(e) {
|
|
2091
|
+
let t = q(e);
|
|
2024
2092
|
if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
|
|
2025
|
-
let n =
|
|
2026
|
-
return
|
|
2093
|
+
let n = J(t);
|
|
2094
|
+
return qn(n, J([
|
|
2027
2095
|
0,
|
|
2028
2096
|
0,
|
|
2029
2097
|
0
|
|
2030
|
-
])) >=
|
|
2098
|
+
])) >= qn(n, J([
|
|
2031
2099
|
255,
|
|
2032
2100
|
255,
|
|
2033
2101
|
255
|
|
2034
2102
|
])) ? "#000000" : "#ffffff";
|
|
2035
2103
|
}
|
|
2036
|
-
function
|
|
2037
|
-
let n =
|
|
2038
|
-
return !n || !r ? NaN :
|
|
2104
|
+
function Yn(e, t) {
|
|
2105
|
+
let n = q(e), r = q(t);
|
|
2106
|
+
return !n || !r ? NaN : qn(J(n), J(r));
|
|
2039
2107
|
}
|
|
2040
|
-
var
|
|
2041
|
-
function
|
|
2108
|
+
var Y = i.primary, Xn = i.panel, Zn = i.assistantBubble, Qn = i.headerHover, $n = 4.5;
|
|
2109
|
+
function er([e, t, n]) {
|
|
2042
2110
|
return `#${[
|
|
2043
2111
|
e,
|
|
2044
2112
|
t,
|
|
2045
2113
|
n
|
|
2046
2114
|
].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
2047
2115
|
}
|
|
2048
|
-
function
|
|
2049
|
-
let n =
|
|
2050
|
-
if (!n || !r) return
|
|
2051
|
-
let i =
|
|
2052
|
-
if (a(n)) return
|
|
2116
|
+
function tr(e, t = Xn) {
|
|
2117
|
+
let n = q(e), r = q(t);
|
|
2118
|
+
if (!n || !r) return Y;
|
|
2119
|
+
let i = J(r), a = (e) => qn(J(e), i) >= $n;
|
|
2120
|
+
if (a(n)) return er(n);
|
|
2053
2121
|
for (let e = .99; e > 0; e -= .01) {
|
|
2054
2122
|
let t = n.map((t) => Math.round(t * e));
|
|
2055
|
-
if (a(t)) return
|
|
2123
|
+
if (a(t)) return er(t);
|
|
2056
2124
|
}
|
|
2057
2125
|
return "#000000";
|
|
2058
2126
|
}
|
|
2059
|
-
var
|
|
2127
|
+
var nr = i.ink, rr = i.link;
|
|
2060
2128
|
function X(e) {
|
|
2061
2129
|
if (typeof e != "string" || !e) return null;
|
|
2062
|
-
let t =
|
|
2063
|
-
return t ?
|
|
2130
|
+
let t = Kn(e);
|
|
2131
|
+
return t ? er(t.rgb) : null;
|
|
2064
2132
|
}
|
|
2065
|
-
function
|
|
2133
|
+
function ir(e) {
|
|
2066
2134
|
if (typeof e != "string" || !e) return null;
|
|
2067
|
-
let t =
|
|
2068
|
-
return t ? t.translucent ? e.trim() :
|
|
2135
|
+
let t = Kn(e);
|
|
2136
|
+
return t ? t.translucent ? e.trim() : er(t.rgb) : null;
|
|
2069
2137
|
}
|
|
2070
|
-
var
|
|
2138
|
+
var ar = [
|
|
2071
2139
|
{
|
|
2072
2140
|
role: "onPrimary",
|
|
2073
2141
|
against: ["primary"],
|
|
@@ -2120,7 +2188,7 @@ var tr = [
|
|
|
2120
2188
|
}
|
|
2121
2189
|
];
|
|
2122
2190
|
function Z({ color: e, inkColor: t, accentColor: n, overrides: a }) {
|
|
2123
|
-
let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) =>
|
|
2191
|
+
let o = typeof a == "object" && a && !Array.isArray(a) ? a : {}, s = (e) => ir(o[e]), c = X(e), l = s("primary"), u = l ?? c ?? Y, d = s("primaryText"), f = d ?? tr(u, Qn), p = s("onPrimary") ?? Jn(u), m = X(t), h = s("ink") ?? (m ? tr(m, Zn) : nr), g = X(n), _ = s("link") ?? (g ? tr(g, Zn) : rr), v = (e) => s(e) ?? i[e], y = {
|
|
2124
2192
|
primary: u,
|
|
2125
2193
|
onPrimary: p,
|
|
2126
2194
|
primaryText: f,
|
|
@@ -2138,9 +2206,9 @@ function Z({ color: e, inkColor: t, accentColor: n, overrides: a }) {
|
|
|
2138
2206
|
inputBorder: v("inputBorder"),
|
|
2139
2207
|
focusRing: v("focusRing")
|
|
2140
2208
|
}, b = Object.fromEntries(r.map((e) => [e, s(e) !== null])), x = [];
|
|
2141
|
-
for (let { role: e, against: t, required: n } of
|
|
2209
|
+
for (let { role: e, against: t, required: n } of ar) for (let r of t) {
|
|
2142
2210
|
if (!b[e] && !b[r]) continue;
|
|
2143
|
-
let t =
|
|
2211
|
+
let t = Yn(y[e], y[r]);
|
|
2144
2212
|
Number.isFinite(t) && t < n && x.push({
|
|
2145
2213
|
role: e,
|
|
2146
2214
|
against: r,
|
|
@@ -2169,62 +2237,62 @@ function Z({ color: e, inkColor: t, accentColor: n, overrides: a }) {
|
|
|
2169
2237
|
function Q(e) {
|
|
2170
2238
|
return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
|
|
2171
2239
|
}
|
|
2172
|
-
function
|
|
2240
|
+
function or(e, t, n = Y) {
|
|
2173
2241
|
let r = t;
|
|
2174
2242
|
X(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Q(t)} as the theme color; falling back to ${Q(n)}.`), r = n);
|
|
2175
2243
|
let i = Z({ color: r });
|
|
2176
2244
|
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);
|
|
2177
2245
|
}
|
|
2178
|
-
function
|
|
2246
|
+
function sr(e, { inkColor: t, accentColor: n }) {
|
|
2179
2247
|
let r = Z({
|
|
2180
2248
|
inkColor: t,
|
|
2181
2249
|
accentColor: n
|
|
2182
2250
|
});
|
|
2183
2251
|
e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
|
|
2184
2252
|
}
|
|
2185
|
-
function
|
|
2253
|
+
function cr(e, t) {
|
|
2186
2254
|
let n = Z({ overrides: t });
|
|
2187
2255
|
for (let t of r) {
|
|
2188
2256
|
let r = n.overridden.primary && (t === "onPrimary" || t === "primaryText");
|
|
2189
2257
|
(n.overridden[t] || r) && e.style.setProperty(a[t], n.roles[t]);
|
|
2190
2258
|
}
|
|
2191
2259
|
}
|
|
2192
|
-
function
|
|
2260
|
+
function lr(e, t) {
|
|
2193
2261
|
e && X(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(e)} as the ${t}; using the default.`);
|
|
2194
2262
|
}
|
|
2195
|
-
function
|
|
2263
|
+
function ur(e, t, n) {
|
|
2196
2264
|
for (let e of r) {
|
|
2197
2265
|
let n = t[e];
|
|
2198
2266
|
n && X(n) === null && console.warn(`[whoo-aiden-widget] Could not use ${Q(n)} as theme.colors.${e}; using the calculated color.`);
|
|
2199
2267
|
}
|
|
2200
2268
|
let i = t.primary;
|
|
2201
|
-
typeof i == "string" &&
|
|
2269
|
+
typeof i == "string" && Kn(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.`), dr({
|
|
2202
2270
|
color: e.color,
|
|
2203
2271
|
inkColor: e.inkColor,
|
|
2204
2272
|
accentColor: e.accentColor,
|
|
2205
2273
|
overrides: t
|
|
2206
2274
|
}, n);
|
|
2207
2275
|
}
|
|
2208
|
-
function
|
|
2276
|
+
function dr(e, t) {
|
|
2209
2277
|
for (let n of Z(e).contrastWarnings) {
|
|
2210
2278
|
let { role: e, against: r, value: i, ratio: a, required: o, overridden: s } = n, c = `${e}|${r}|${i}`;
|
|
2211
2279
|
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.`));
|
|
2212
2280
|
}
|
|
2213
2281
|
}
|
|
2214
|
-
function
|
|
2215
|
-
|
|
2282
|
+
function fr(e, t, n = /* @__PURE__ */ new Set()) {
|
|
2283
|
+
or(e, t.color ?? Y), lr(t.inkColor, "ink color"), lr(t.accentColor, "accent color"), sr(e, {
|
|
2216
2284
|
inkColor: t.inkColor,
|
|
2217
2285
|
accentColor: t.accentColor
|
|
2218
2286
|
});
|
|
2219
2287
|
let r = te(t.theme);
|
|
2220
|
-
|
|
2288
|
+
ur(t, r.colors, n), cr(e, r.colors), r.fontFamily && e.style.setProperty("--whoo-widget-font", r.fontFamily);
|
|
2221
2289
|
}
|
|
2222
2290
|
//#endregion
|
|
2223
2291
|
//#region src/controller.ts
|
|
2224
|
-
var
|
|
2292
|
+
var pr = 8e3, mr = 3e3, hr = 15e3, gr = class extends Error {
|
|
2225
2293
|
name = "SessionUnavailableError";
|
|
2226
2294
|
};
|
|
2227
|
-
function
|
|
2295
|
+
function _r(e, t) {
|
|
2228
2296
|
return t ? new Promise((n, r) => {
|
|
2229
2297
|
let i = () => r(new DOMException("Aborted", "AbortError"));
|
|
2230
2298
|
if (t.aborted) return i();
|
|
@@ -2235,23 +2303,23 @@ function pr(e, t) {
|
|
|
2235
2303
|
});
|
|
2236
2304
|
}) : e;
|
|
2237
2305
|
}
|
|
2238
|
-
function
|
|
2239
|
-
return e === "refused" ? new
|
|
2306
|
+
function vr(e, t) {
|
|
2307
|
+
return e === "refused" ? new br(t) : new gr();
|
|
2240
2308
|
}
|
|
2241
|
-
function
|
|
2309
|
+
function yr(e) {
|
|
2242
2310
|
let t = e?.status;
|
|
2243
2311
|
return t === 401 || t === 403 || t === 404;
|
|
2244
2312
|
}
|
|
2245
|
-
var
|
|
2313
|
+
var br = class extends Error {
|
|
2246
2314
|
name = "SessionExpiredError";
|
|
2247
2315
|
constructor(e) {
|
|
2248
2316
|
super(e instanceof Error ? e.message : "The session has expired.");
|
|
2249
2317
|
}
|
|
2250
2318
|
};
|
|
2251
|
-
function
|
|
2319
|
+
function xr(e) {
|
|
2252
2320
|
return e?.status === 401;
|
|
2253
2321
|
}
|
|
2254
|
-
function
|
|
2322
|
+
function Sr(e, t) {
|
|
2255
2323
|
return new Promise((n) => {
|
|
2256
2324
|
let r = setTimeout(n, t);
|
|
2257
2325
|
e.then(() => {
|
|
@@ -2259,7 +2327,7 @@ function vr(e, t) {
|
|
|
2259
2327
|
});
|
|
2260
2328
|
});
|
|
2261
2329
|
}
|
|
2262
|
-
var
|
|
2330
|
+
var Cr = class {
|
|
2263
2331
|
config;
|
|
2264
2332
|
state;
|
|
2265
2333
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -2278,6 +2346,8 @@ var yr = class {
|
|
|
2278
2346
|
launcherIconUrl;
|
|
2279
2347
|
emptyStateImageUrl;
|
|
2280
2348
|
emptyStateImageAlt;
|
|
2349
|
+
notice;
|
|
2350
|
+
requireNoticeAgreement;
|
|
2281
2351
|
showFeedback;
|
|
2282
2352
|
text;
|
|
2283
2353
|
language;
|
|
@@ -2290,11 +2360,11 @@ var yr = class {
|
|
|
2290
2360
|
this.launcher = {
|
|
2291
2361
|
...t,
|
|
2292
2362
|
...r ? { iconUrl: r } : {}
|
|
2293
|
-
}, 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 =
|
|
2294
|
-
let { language: i, tag: a, dir: o } =
|
|
2295
|
-
this.language = i, this.languageTag = a, this.dir = o, this.contentLanguage =
|
|
2296
|
-
...
|
|
2297
|
-
...
|
|
2363
|
+
}, this.launcherIconUrl = r, this.emptyStateImageUrl = n(e.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof e.emptyStateImageAlt == "string" ? e.emptyStateImageAlt.trim() : "", this.notice = typeof e.notice == "string" && !d(e.notice) ? e.notice.trim() : "", this.requireNoticeAgreement = e.requireNoticeAgreement === !0 && this.notice !== "", e.requireNoticeAgreement === !0 && !this.notice && console.warn("whoo-aiden-widget: `requireNoticeAgreement` has no effect without a `notice`, so it is ignored."), this.showFeedback = e.showFeedback === !0, this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.getSessionToken = m(e);
|
|
2364
|
+
let { language: i, tag: a, dir: o } = kt(e.language, typeof document > "u" ? void 0 : document.documentElement.lang);
|
|
2365
|
+
this.language = i, this.languageTag = a, this.dir = o, this.contentLanguage = Mt(e.contentLanguage, typeof document > "u" ? void 0 : document.documentElement.lang, e.language), this.text = {
|
|
2366
|
+
...Dt(i),
|
|
2367
|
+
...b(e.messages)
|
|
2298
2368
|
}, this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
|
|
2299
2369
|
isOpen: !1,
|
|
2300
2370
|
messages: [],
|
|
@@ -2310,6 +2380,7 @@ var yr = class {
|
|
|
2310
2380
|
announcement: null,
|
|
2311
2381
|
announcementIsContent: !1,
|
|
2312
2382
|
isSlowResponse: !1,
|
|
2383
|
+
noticeAgreed: !this.requireNoticeAgreement || Hn(this.storageIdentifier, this.notice),
|
|
2313
2384
|
draft: ""
|
|
2314
2385
|
};
|
|
2315
2386
|
}
|
|
@@ -2341,12 +2412,12 @@ var yr = class {
|
|
|
2341
2412
|
let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
|
|
2342
2413
|
try {
|
|
2343
2414
|
if (this.config.sessionToken) {
|
|
2344
|
-
if (
|
|
2415
|
+
if (In(this.config.sessionToken)) {
|
|
2345
2416
|
if (!("token" in await this.renewToken())) throw Error("The sessionToken has expired.");
|
|
2346
|
-
} else this.sessionToken = this.config.sessionToken, this.sessionTokenExpiresAt =
|
|
2417
|
+
} else this.sessionToken = this.config.sessionToken, this.sessionTokenExpiresAt = Fn(this.config.sessionToken);
|
|
2347
2418
|
} else if (this.config.publishableKey) {
|
|
2348
|
-
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await
|
|
2349
|
-
this.sessionToken = t, this.sessionTokenExpiresAt =
|
|
2419
|
+
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await Sn(e, this.config.publishableKey);
|
|
2420
|
+
this.sessionToken = t, this.sessionTokenExpiresAt = Ln(t), this.setState({
|
|
2350
2421
|
primaryColor: n,
|
|
2351
2422
|
agentName: r,
|
|
2352
2423
|
accentColor: i,
|
|
@@ -2357,13 +2428,13 @@ var yr = class {
|
|
|
2357
2428
|
console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
|
|
2358
2429
|
return;
|
|
2359
2430
|
}
|
|
2360
|
-
this.conversationId =
|
|
2431
|
+
this.conversationId = zn(this.storageIdentifier), this.config.sessionToken && await Sr(this.loadBranding(e), mr);
|
|
2361
2432
|
}
|
|
2362
2433
|
async loadBranding(e) {
|
|
2363
2434
|
try {
|
|
2364
2435
|
let t = this.config;
|
|
2365
2436
|
if (X(t.color) && X(t.inkColor) && X(t.accentColor) && u(t.name)) return;
|
|
2366
|
-
let { primaryColor: n, name: r, accentColor: i, inkColor: a } = await this.withSession((t) =>
|
|
2437
|
+
let { primaryColor: n, name: r, accentColor: i, inkColor: a } = await this.withSession((t) => wn(e, t));
|
|
2367
2438
|
this.setState({
|
|
2368
2439
|
primaryColor: n,
|
|
2369
2440
|
agentName: r,
|
|
@@ -2372,14 +2443,14 @@ var yr = class {
|
|
|
2372
2443
|
});
|
|
2373
2444
|
} catch (e) {
|
|
2374
2445
|
let t = e?.status;
|
|
2375
|
-
(e instanceof
|
|
2446
|
+
(e instanceof br || t === 401 || t === 403) && (this.state.isInitializing ? (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) })) : (console.error("[whoo-aiden-widget] the session was refused after start-up:", e), this.setState({ runtimeError: this.text.sessionExpired })));
|
|
2376
2447
|
}
|
|
2377
2448
|
}
|
|
2378
2449
|
open() {
|
|
2379
2450
|
this.setState({ isOpen: !0 });
|
|
2380
2451
|
}
|
|
2381
2452
|
resetConversation() {
|
|
2382
|
-
this.sendEpoch += 1, this.activeRequestController?.abort("reset"), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null,
|
|
2453
|
+
this.sendEpoch += 1, this.activeRequestController?.abort("reset"), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, Wn(this.storageIdentifier), this.setState({
|
|
2383
2454
|
messages: [],
|
|
2384
2455
|
messageFeedback: {},
|
|
2385
2456
|
runtimeError: null,
|
|
@@ -2388,6 +2459,9 @@ var yr = class {
|
|
|
2388
2459
|
announcementIsContent: !1
|
|
2389
2460
|
});
|
|
2390
2461
|
}
|
|
2462
|
+
agreeToNotice() {
|
|
2463
|
+
this.state.noticeAgreed || (Un(this.storageIdentifier, this.notice), this.setState({ noticeAgreed: !0 }));
|
|
2464
|
+
}
|
|
2391
2465
|
setDraft(e) {
|
|
2392
2466
|
this.setState({ draft: e });
|
|
2393
2467
|
}
|
|
@@ -2395,7 +2469,7 @@ var yr = class {
|
|
|
2395
2469
|
this.activeRequestController?.abort("close"), this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isOpen: !1 });
|
|
2396
2470
|
}
|
|
2397
2471
|
async sendMessage(e) {
|
|
2398
|
-
if (!this.sessionToken) return;
|
|
2472
|
+
if (!this.sessionToken || !this.state.noticeAgreed) return;
|
|
2399
2473
|
let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
|
|
2400
2474
|
this.sendEpoch += 1;
|
|
2401
2475
|
let n = this.sendEpoch, r = () => n === this.sendEpoch, i = {
|
|
@@ -2428,7 +2502,7 @@ var yr = class {
|
|
|
2428
2502
|
let { signal: u } = l, d = !1;
|
|
2429
2503
|
this.slowResponseTimer = setTimeout(() => {
|
|
2430
2504
|
this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
|
|
2431
|
-
},
|
|
2505
|
+
}, pr);
|
|
2432
2506
|
let f = !1, p = () => {
|
|
2433
2507
|
this.state.draft === "" && (f = !0, this.setState({ draft: e }));
|
|
2434
2508
|
}, m = (e = this.text.genericError) => {
|
|
@@ -2437,7 +2511,7 @@ var yr = class {
|
|
|
2437
2511
|
try {
|
|
2438
2512
|
let { stream: n, first: i } = await this.withSession(async (n) => {
|
|
2439
2513
|
d = !0;
|
|
2440
|
-
let r =
|
|
2514
|
+
let r = En(t, n, this.conversationId, e, u);
|
|
2441
2515
|
return {
|
|
2442
2516
|
stream: r,
|
|
2443
2517
|
first: await r.next()
|
|
@@ -2445,22 +2519,22 @@ var yr = class {
|
|
|
2445
2519
|
}, u);
|
|
2446
2520
|
for (let e = i; !e.done && !u.aborted && r(); e = await n.next()) {
|
|
2447
2521
|
let t = e.value;
|
|
2448
|
-
if (t.type === "conversation_id") this.conversationId = t.conversationId,
|
|
2449
|
-
else if (t.type === "delta") this.clearSlowResponse(), t.verbatim && !this.prefersReducedMotion ? (await
|
|
2450
|
-
else if (t.type === "done") t.conversationId && (this.conversationId = t.conversationId,
|
|
2451
|
-
announcement:
|
|
2522
|
+
if (t.type === "conversation_id") this.conversationId = t.conversationId, Bn(this.storageIdentifier, t.conversationId);
|
|
2523
|
+
else if (t.type === "delta") this.clearSlowResponse(), t.verbatim && !this.prefersReducedMotion ? (await Nn(t.delta, (e) => c(e), { signal: u }), h = t.delta) : t.verbatim ? (h = t.delta, c(h)) : (h += t.delta, c(h));
|
|
2524
|
+
else if (t.type === "done") t.conversationId && (this.conversationId = t.conversationId, Bn(this.storageIdentifier, t.conversationId)), t.messageId && s({ id: t.messageId }), r() && this.setState({
|
|
2525
|
+
announcement: On(h),
|
|
2452
2526
|
announcementIsContent: !0
|
|
2453
2527
|
});
|
|
2454
2528
|
else if (t.type === "error") {
|
|
2455
2529
|
console.error("[whoo-aiden-widget] chat error:", t.error), h.trim() !== "" && r() && this.setState({
|
|
2456
|
-
announcement:
|
|
2530
|
+
announcement: On(h),
|
|
2457
2531
|
announcementIsContent: !0
|
|
2458
2532
|
}), m(), l.abort();
|
|
2459
2533
|
break;
|
|
2460
2534
|
}
|
|
2461
2535
|
}
|
|
2462
2536
|
} catch (e) {
|
|
2463
|
-
u.aborted ? u.reason === "close" && r() && !d && p() : e instanceof
|
|
2537
|
+
u.aborted ? u.reason === "close" && r() && !d && p() : e instanceof br ? (console.error("[whoo-aiden-widget] chat request failed: the session has expired.", e), m(this.text.sessionExpired)) : e instanceof gr ? (console.error("[whoo-aiden-widget] chat request failed: no session could be had."), m()) : (console.error("[whoo-aiden-widget] chat request failed:", e), m());
|
|
2464
2538
|
} finally {
|
|
2465
2539
|
let e = o.id === null && o.content.trim() === "", t = this.state.messages.filter((t) => !(e && t === o) && !(e && f && t === i)), n = t.length !== this.state.messages.length;
|
|
2466
2540
|
r() ? (this.activeRequestController = null, this.clearSlowResponse(), this.setState({
|
|
@@ -2507,7 +2581,7 @@ var yr = class {
|
|
|
2507
2581
|
}
|
|
2508
2582
|
} });
|
|
2509
2583
|
try {
|
|
2510
|
-
await this.withSession((a) =>
|
|
2584
|
+
await this.withSession((a) => Tn(i, a, {
|
|
2511
2585
|
messageId: e,
|
|
2512
2586
|
rating: t,
|
|
2513
2587
|
correction: n,
|
|
@@ -2533,7 +2607,7 @@ var yr = class {
|
|
|
2533
2607
|
}
|
|
2534
2608
|
async currentToken(e) {
|
|
2535
2609
|
let t = this.sessionToken, n = this.sessionTokenExpiresAt;
|
|
2536
|
-
return t && (n === null || n - Date.now() > 6e4) ? { token: t } :
|
|
2610
|
+
return t && (n === null || n - Date.now() > 6e4) ? { token: t } : _r(this.renewToken(), e);
|
|
2537
2611
|
}
|
|
2538
2612
|
renewToken() {
|
|
2539
2613
|
return this.tokenRenewal ??= this.fetchNewToken().finally(() => {
|
|
@@ -2544,7 +2618,7 @@ var yr = class {
|
|
|
2544
2618
|
let e = ++this.renewalGeneration, t, n = new Promise((e) => {
|
|
2545
2619
|
t = setTimeout(() => {
|
|
2546
2620
|
console.error("[whoo-aiden-widget] could not renew the session: it took too long."), e({ failure: "unavailable" });
|
|
2547
|
-
},
|
|
2621
|
+
}, hr);
|
|
2548
2622
|
});
|
|
2549
2623
|
try {
|
|
2550
2624
|
return await Promise.race([this.obtainToken(e), n]);
|
|
@@ -2555,64 +2629,64 @@ var yr = class {
|
|
|
2555
2629
|
async obtainToken(e) {
|
|
2556
2630
|
let t = this.config.apiBaseUrl ?? "https://api.aidenvoice.com", n;
|
|
2557
2631
|
try {
|
|
2558
|
-
if (this.config.publishableKey) n = (await
|
|
2632
|
+
if (this.config.publishableKey) n = (await Sn(t, this.config.publishableKey)).token;
|
|
2559
2633
|
else if (this.getSessionToken) n = await this.getSessionToken();
|
|
2560
2634
|
else return { failure: "refused" };
|
|
2561
2635
|
} catch (e) {
|
|
2562
|
-
return console.error("[whoo-aiden-widget] could not renew the session:", e), { failure: this.config.publishableKey &&
|
|
2636
|
+
return console.error("[whoo-aiden-widget] could not renew the session:", e), { failure: this.config.publishableKey && yr(e) ? "refused" : "unavailable" };
|
|
2563
2637
|
}
|
|
2564
|
-
let r = typeof n == "string" ?
|
|
2638
|
+
let r = typeof n == "string" ? Ln(n) : null;
|
|
2565
2639
|
return typeof n != "string" || n === "" || r !== null && r <= Date.now() ? (console.error("[whoo-aiden-widget] could not renew the session: no usable token was returned."), { failure: "refused" }) : (e === this.renewalGeneration && (this.sessionToken = n, this.sessionTokenExpiresAt = r), { token: n });
|
|
2566
2640
|
}
|
|
2567
2641
|
async withSession(e, t) {
|
|
2568
2642
|
let n = await this.currentToken(t);
|
|
2569
|
-
if (!("token" in n)) throw
|
|
2643
|
+
if (!("token" in n)) throw vr(n.failure);
|
|
2570
2644
|
let { token: r } = n;
|
|
2571
2645
|
try {
|
|
2572
2646
|
return await e(r);
|
|
2573
2647
|
} catch (n) {
|
|
2574
|
-
if (!
|
|
2575
|
-
let i = this.sessionToken && this.sessionToken !== r ? { token: this.sessionToken } : await
|
|
2576
|
-
if (!("token" in i)) throw
|
|
2648
|
+
if (!xr(n)) throw n;
|
|
2649
|
+
let i = this.sessionToken && this.sessionToken !== r ? { token: this.sessionToken } : await _r(this.renewToken(), t);
|
|
2650
|
+
if (!("token" in i)) throw vr(i.failure, n);
|
|
2577
2651
|
try {
|
|
2578
2652
|
return await e(i.token);
|
|
2579
2653
|
} catch (e) {
|
|
2580
|
-
throw
|
|
2654
|
+
throw xr(e) ? new br(e) : e;
|
|
2581
2655
|
}
|
|
2582
2656
|
}
|
|
2583
2657
|
}
|
|
2584
|
-
}, $ = 20,
|
|
2585
|
-
function
|
|
2658
|
+
}, $ = 20, wr = 12, Tr = 300, Er = 352;
|
|
2659
|
+
function Dr() {
|
|
2586
2660
|
try {
|
|
2587
2661
|
return typeof CSS < "u" && CSS.supports?.("height", "100dvh") ? "dvh" : "vh";
|
|
2588
2662
|
} catch {
|
|
2589
2663
|
return "vh";
|
|
2590
2664
|
}
|
|
2591
2665
|
}
|
|
2592
|
-
function
|
|
2666
|
+
function Or(e, t) {
|
|
2593
2667
|
let { offsetX: n, offsetY: r, launcherSize: i, panelWidth: a, panelHeight: o } = ie(t.layout), s = (e) => typeof t.layout?.offset?.[e] == "number";
|
|
2594
2668
|
if (typeof window < "u" && window.innerWidth > 0 && window.innerHeight > 0) {
|
|
2595
|
-
let e = Math.max($, window.innerWidth -
|
|
2669
|
+
let e = Math.max($, window.innerWidth - Tr), t = Math.max($, window.innerHeight - i - Er);
|
|
2596
2670
|
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.`);
|
|
2597
2671
|
}
|
|
2598
|
-
let c = `100${
|
|
2672
|
+
let c = `100${Dr()}`, l = `min(${n}px, max(${$}px, calc(100vw - ${Tr}px)), calc(100vw - ${i}px))`, u = `min(${r}px, max(${$}px, calc(${c} - ${i + Er}px)), calc(${c} - ${i}px))`, d = `calc(${u} + ${i}px + ${wr}px)`, f = t.position === "bottom-left", p = (t, n) => e.style.setProperty(t, n);
|
|
2599
2673
|
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)`);
|
|
2600
2674
|
}
|
|
2601
2675
|
//#endregion
|
|
2602
2676
|
//#region src/styles.css?inline
|
|
2603
|
-
var
|
|
2677
|
+
var kr = ":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:not([open]){display:none}.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-notice{border:1px solid var(--whoo-widget-border,#e5e5e5);color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;margin-bottom:12px;padding:8px 12px}.whoo-widget-notice a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message-text,.whoo-widget-message-text li{unicode-bidi:plaintext}.whoo-widget-list{margin:4px 0;padding-inline-start:0}.whoo-widget-list li{margin-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-agreement{border-top:1px solid var(--whoo-widget-border,#e5e5e5);padding:12px}.whoo-widget-agreement-button{background:var(--whoo-widget-color,#4f46e5);width:100%;min-height:44px;color:var(--whoo-widget-text-on-color,#fff);overflow-wrap:anywhere;cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-weight:600;display:block}.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[aria-disabled=true]{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-message{border:1px solid canvastext}.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-agreement-button,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
|
|
2604
2678
|
//#endregion
|
|
2605
2679
|
//#region src/mount.tsx
|
|
2606
|
-
function
|
|
2680
|
+
function Ar(e) {
|
|
2607
2681
|
let t = document.createElement("div");
|
|
2608
2682
|
t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(c(e.zIndex));
|
|
2609
2683
|
let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
|
|
2610
|
-
r.textContent =
|
|
2684
|
+
r.textContent = kr, n.appendChild(r);
|
|
2611
2685
|
let i = document.createElement("div");
|
|
2612
2686
|
n.appendChild(i);
|
|
2613
2687
|
let a = /* @__PURE__ */ new Set();
|
|
2614
|
-
|
|
2615
|
-
let o = new
|
|
2688
|
+
fr(i, e, a), Or(i, e);
|
|
2689
|
+
let o = new Cr(e);
|
|
2616
2690
|
i.setAttribute("lang", o.languageTag), i.setAttribute("dir", o.dir);
|
|
2617
2691
|
let s = X(e.color) !== null, l = null, u = "", d = te(e.theme).colors, f = Object.keys(d).length > 0, p = {
|
|
2618
2692
|
color: e.color,
|
|
@@ -2621,7 +2695,7 @@ function Er(e) {
|
|
|
2621
2695
|
};
|
|
2622
2696
|
return o.subscribe((t) => {
|
|
2623
2697
|
let n = !1;
|
|
2624
|
-
!s && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor,
|
|
2698
|
+
!s && t.primaryColor && t.primaryColor !== l && (l = t.primaryColor, or(i, t.primaryColor, e.color), X(t.primaryColor) && (p = {
|
|
2625
2699
|
...p,
|
|
2626
2700
|
color: t.primaryColor
|
|
2627
2701
|
}), n = !0);
|
|
@@ -2629,7 +2703,7 @@ function Er(e) {
|
|
|
2629
2703
|
if ((t.inkColor || t.accentColor) && r !== u) {
|
|
2630
2704
|
u = r;
|
|
2631
2705
|
let a = X(e.inkColor) ? e.inkColor : t.inkColor, o = X(e.accentColor) ? e.accentColor : t.accentColor;
|
|
2632
|
-
|
|
2706
|
+
sr(i, {
|
|
2633
2707
|
inkColor: a,
|
|
2634
2708
|
accentColor: o
|
|
2635
2709
|
}), p = {
|
|
@@ -2638,18 +2712,18 @@ function Er(e) {
|
|
|
2638
2712
|
accentColor: o
|
|
2639
2713
|
}, n = !0;
|
|
2640
2714
|
}
|
|
2641
|
-
n && (
|
|
2715
|
+
n && (cr(i, d), f && dr({
|
|
2642
2716
|
...p,
|
|
2643
2717
|
overrides: d
|
|
2644
2718
|
}, a));
|
|
2645
|
-
}), o.init(),
|
|
2646
|
-
|
|
2719
|
+
}), o.init(), Re(/* @__PURE__ */ W(yn, { controller: o }), i), document.body.appendChild(t), { unmount() {
|
|
2720
|
+
Re(null, i), t.remove();
|
|
2647
2721
|
} };
|
|
2648
2722
|
}
|
|
2649
2723
|
//#endregion
|
|
2650
2724
|
//#region src/index.ts
|
|
2651
|
-
function
|
|
2652
|
-
return
|
|
2725
|
+
function jr(e) {
|
|
2726
|
+
return f(e), Ar(e);
|
|
2653
2727
|
}
|
|
2654
2728
|
//#endregion
|
|
2655
|
-
export {
|
|
2729
|
+
export { St as SUPPORTED_LANGUAGES, jr as init, Z as resolveTheme };
|