@aiden-voice/widget 0.1.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -10
- package/dist/api/client.d.ts +6 -2
- package/dist/components/Launcher.d.ts +2 -2
- package/dist/components/MessageList.d.ts +7 -1
- package/dist/controller.d.ts +10 -0
- package/dist/imageUrl.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/theme.d.ts +37 -2
- package/dist/types.d.ts +19 -1
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +3 -3
- package/dist/widget.js +429 -309
- package/package.json +2 -2
package/dist/widget.js
CHANGED
|
@@ -49,7 +49,7 @@ function T(e, t) {
|
|
|
49
49
|
function E(e) {
|
|
50
50
|
if (e.__P && e.__d) {
|
|
51
51
|
var t = e.__v, r = t.__e, i = [], a = [], o = y({}, t);
|
|
52
|
-
o.__v = t.__v + 1, n.vnode && n.vnode(o),
|
|
52
|
+
o.__v = t.__v + 1, n.vnode && n.vnode(o), ne(e.__P, o, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [r] : null, i, r ?? T(t), !!(32 & t.__u), a), o.__v = t.__v, o.__.__k[o.__i] = o, ie(i, o, a), t.__e = t.__ = null, o.__e != r && D(o);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
function D(e) {
|
|
@@ -69,13 +69,13 @@ function k() {
|
|
|
69
69
|
}
|
|
70
70
|
function ee(e, t, n, r, i, a, o, s, c, l, u) {
|
|
71
71
|
var d, f, p, m, _, v, y = r && r.__k || g, b = t.length;
|
|
72
|
-
for (c = A(n, t, y, c, b), d = 0; d < b; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && y[p.__i] || h, p.__i = d, v =
|
|
72
|
+
for (c = A(n, t, y, c, b), d = 0; d < b; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && y[p.__i] || h, p.__i = d, v = ne(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && se(f.ref, null, p), u.push(p.ref, p.__c || m, p)), _ == null && m != null && (_ = m), 4 & p.__u ? (c = j(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && v !== void 0 ? c = v : m && (c = m.nextSibling), p.__u &= -7);
|
|
73
73
|
return n.__e = _, c;
|
|
74
74
|
}
|
|
75
75
|
function A(e, t, n, r, i) {
|
|
76
76
|
var a, o, s, c, l, u = n.length, d = u, f = 0;
|
|
77
77
|
for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = S(null, o, null, null, null) : v(o) ? o = e.__k[a] = S(C, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = S(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = M(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
|
|
78
|
-
if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = T(s)),
|
|
78
|
+
if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = T(s)), ce(s, s));
|
|
79
79
|
return r;
|
|
80
80
|
}
|
|
81
81
|
function j(e, t, n) {
|
|
@@ -129,14 +129,14 @@ function te(e) {
|
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
|
-
function
|
|
132
|
+
function ne(e, t, r, i, a, o, s, c, l, u) {
|
|
133
133
|
var d, f, p, m, h, _, x, S, E, D, O, k, A, j, M, N, P = t.type;
|
|
134
134
|
if (t.constructor !== void 0) return null;
|
|
135
135
|
128 & r.__u && (l = !!(32 & r.__u), o = [c = t.__e = r.__e]), (d = n.__b) && d(t);
|
|
136
136
|
n: if (typeof P == "function") {
|
|
137
137
|
f = s.length;
|
|
138
138
|
try {
|
|
139
|
-
if (E = t.props, D = P.prototype && P.prototype.render, O = (d = P.contextType) && i[d.__c], k = d ? O ? O.props.value : d.__ : i, r.__c ? S = (p = t.__c = r.__c).__ = p.__E : (D ? t.__c = p = new P(E, k) : (t.__c = p = new w(E, k), p.constructor = P, p.render =
|
|
139
|
+
if (E = t.props, D = P.prototype && P.prototype.render, O = (d = P.contextType) && i[d.__c], k = d ? O ? O.props.value : d.__ : i, r.__c ? S = (p = t.__c = r.__c).__ = p.__E : (D ? t.__c = p = new P(E, k) : (t.__c = p = new w(E, k), p.constructor = P, p.render = le), O && O.sub(p), p.state || (p.state = {}), p.__n = i, m = p.__d = !0, p.__h = [], p._sb = []), D && p.__s == null && (p.__s = p.state), D && P.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = y({}, p.__s)), y(p.__s, P.getDerivedStateFromProps(E, p.__s))), h = p.props, _ = p.state, p.__v = t, m) D && P.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), D && p.componentDidMount != null && p.__h.push(p.componentDidMount);
|
|
140
140
|
else {
|
|
141
141
|
if (D && P.getDerivedStateFromProps == null && E !== h && p.componentWillReceiveProps != null && p.componentWillReceiveProps(E, k), t.__v == r.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(E, p.__s, k)) {
|
|
142
142
|
t.__v != r.__v && (p.props = E, p.state = p.__s, p.__d = !1), t.__e = r.__e, t.__k = r.__k, t.__k.some(function(e) {
|
|
@@ -152,7 +152,7 @@ function F(e, t, r, i, a, o, s, c, l, u) {
|
|
|
152
152
|
else do
|
|
153
153
|
p.__d = !1, A && A(t), d = p.render(p.props, p.state, p.context), p.state = p.__s;
|
|
154
154
|
while (p.__d && ++j < 25);
|
|
155
|
-
p.state = p.__s, p.getChildContext != null && (i = y(y({}, i), p.getChildContext())), D && !m && p.getSnapshotBeforeUpdate != null && (x = p.getSnapshotBeforeUpdate(h, _)), M = d != null && d.type === C && d.key == null ?
|
|
155
|
+
p.state = p.__s, p.getChildContext != null && (i = y(y({}, i), p.getChildContext())), D && !m && p.getSnapshotBeforeUpdate != null && (x = p.getSnapshotBeforeUpdate(h, _)), M = d != null && d.type === C && d.key == null ? ae(d.props.children) : d, c = ee(e, v(M) ? M : [M], t, r, i, a, o, s, c, l, u), p.base = t.__e, t.__u &= -161, p.__h.length && s.push(p), S && (p.__E = p.__ = null);
|
|
156
156
|
} catch (e) {
|
|
157
157
|
if (s.length = f, t.__v = null, l || o != null) {
|
|
158
158
|
if (e.then) {
|
|
@@ -160,16 +160,16 @@ function F(e, t, r, i, a, o, s, c, l, u) {
|
|
|
160
160
|
o != null && (o[o.indexOf(c)] = null), t.__e = c;
|
|
161
161
|
} else if (o != null) for (N = o.length; N--;) b(o[N]);
|
|
162
162
|
} else t.__e = r.__e;
|
|
163
|
-
t.__k ??= r.__k || [], e.then ||
|
|
163
|
+
t.__k ??= r.__k || [], e.then || re(t), n.__e(e, t, r);
|
|
164
164
|
}
|
|
165
|
-
} else o == null && t.__v == r.__v ? (t.__k = r.__k, t.__e = r.__e) : c = t.__e =
|
|
165
|
+
} else o == null && t.__v == r.__v ? (t.__k = r.__k, t.__e = r.__e) : c = t.__e = oe(r.__e, t, r, i, a, o, s, l, u);
|
|
166
166
|
return (d = n.diffed) && d(t), 128 & t.__u ? void 0 : c;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
169
|
-
e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(
|
|
168
|
+
function re(e) {
|
|
169
|
+
e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(re));
|
|
170
170
|
}
|
|
171
|
-
function
|
|
172
|
-
for (var i = 0; i < r.length; i++)
|
|
171
|
+
function ie(e, t, r) {
|
|
172
|
+
for (var i = 0; i < r.length; i++) se(r[i], r[++i], r[++i]);
|
|
173
173
|
n.__c && n.__c(t, e), e.some(function(t) {
|
|
174
174
|
try {
|
|
175
175
|
e = t.__h, t.__h = [], e.some(function(e) {
|
|
@@ -180,10 +180,10 @@ function re(e, t, r) {
|
|
|
180
180
|
}
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
|
-
function
|
|
184
|
-
return typeof e != "object" || !e || e.__b > 0 ? e : v(e) ? e.map(
|
|
183
|
+
function ae(e) {
|
|
184
|
+
return typeof e != "object" || !e || e.__b > 0 ? e : v(e) ? e.map(ae) : e.constructor === void 0 ? y({}, e) : null;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
186
|
+
function oe(e, r, i, a, o, s, c, l, u) {
|
|
187
187
|
var d, f, p, m, g, _, y, x = i.props || h, S = r.props, C = r.type;
|
|
188
188
|
if (C == "svg" ? o = "http://www.w3.org/2000/svg" : C == "math" ? o = "http://www.w3.org/1998/Math/MathML" : o ||= "http://www.w3.org/1999/xhtml", s != null) {
|
|
189
189
|
for (d = 0; d < s.length; d++) if ((g = s[d]) && "setAttribute" in g == !!C && (C ? g.localName == C : g.nodeType == 3)) {
|
|
@@ -206,7 +206,7 @@ function ae(e, r, i, a, o, s, c, l, u) {
|
|
|
206
206
|
}
|
|
207
207
|
return e;
|
|
208
208
|
}
|
|
209
|
-
function
|
|
209
|
+
function se(e, t, r) {
|
|
210
210
|
try {
|
|
211
211
|
if (typeof e == "function") {
|
|
212
212
|
var i = typeof e.__u == "function";
|
|
@@ -216,9 +216,9 @@ function I(e, t, r) {
|
|
|
216
216
|
n.__e(e, r);
|
|
217
217
|
}
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function ce(e, t, r) {
|
|
220
220
|
var i, a;
|
|
221
|
-
if (n.unmount && n.unmount(e), (i = e.ref) && (i.current && i.current != e.__e ||
|
|
221
|
+
if (n.unmount && n.unmount(e), (i = e.ref) && (i.current && i.current != e.__e || se(i, null, t)), (i = e.__c) != null) {
|
|
222
222
|
if (i.componentWillUnmount) try {
|
|
223
223
|
i.componentWillUnmount();
|
|
224
224
|
} catch (e) {
|
|
@@ -226,15 +226,15 @@ function oe(e, t, r) {
|
|
|
226
226
|
}
|
|
227
227
|
i.base = i.__P = i.__n = null;
|
|
228
228
|
}
|
|
229
|
-
if (i = e.__k) for (a = 0; a < i.length; a++) i[a] &&
|
|
229
|
+
if (i = e.__k) for (a = 0; a < i.length; a++) i[a] && ce(i[a], t, r || typeof e.type != "function");
|
|
230
230
|
r || b(e.__e), e.__c = e.__ = e.__e = void 0;
|
|
231
231
|
}
|
|
232
|
-
function
|
|
232
|
+
function le(e, t, n) {
|
|
233
233
|
return this.constructor(e, n);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function ue(e, r, i) {
|
|
236
236
|
var a, o, s, c;
|
|
237
|
-
r == document && (r = document.documentElement), n.__ && n.__(e, r), o = (a = typeof i == "function") ? null : i && i.__k || r.__k, s = [], c = [],
|
|
237
|
+
r == document && (r = document.documentElement), n.__ && n.__(e, r), o = (a = typeof i == "function") ? null : i && i.__k || r.__k, s = [], c = [], ne(r, e = (!a && i || r).__k = x(C, null, [e]), o || h, h, r.namespaceURI, !a && i ? [i] : o ? null : r.firstChild ? t.call(r.childNodes) : null, s, !a && i ? i : o ? o.__e : r.firstChild, a, c), ie(s, e, c), e.props.children = null;
|
|
238
238
|
}
|
|
239
239
|
t = g.slice, n = { __e: function(e, t, n, r) {
|
|
240
240
|
for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
|
|
@@ -253,24 +253,24 @@ t = g.slice, n = { __e: function(e, t, n, r) {
|
|
|
253
253
|
}, k.__r = 0, c = Math.random().toString(8), l = "__d" + c, u = "__a" + c, d = /(PointerCapture)$|Capture$/i, f = 0, p = te(!1), m = te(!0);
|
|
254
254
|
//#endregion
|
|
255
255
|
//#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/hooks/dist/hooks.module.js
|
|
256
|
-
var
|
|
257
|
-
function
|
|
258
|
-
|
|
259
|
-
var n =
|
|
256
|
+
var F, I, de, fe, L = 0, pe = [], R = n, me = R.__b, he = R.__r, ge = R.diffed, _e = R.__c, ve = R.unmount, ye = R.__;
|
|
257
|
+
function be(e, t) {
|
|
258
|
+
R.__h && R.__h(I, e, L || t), L = 0;
|
|
259
|
+
var n = I.__H || (I.__H = {
|
|
260
260
|
__: [],
|
|
261
261
|
__h: []
|
|
262
262
|
});
|
|
263
263
|
return e >= n.__.length && n.__.push({}), n.__[e];
|
|
264
264
|
}
|
|
265
|
-
function
|
|
266
|
-
return
|
|
265
|
+
function z(e) {
|
|
266
|
+
return L = 1, xe(Oe, e);
|
|
267
267
|
}
|
|
268
|
-
function
|
|
269
|
-
var r =
|
|
270
|
-
if (r.t = e, !r.__c && (r.__ = [n ? n(t) :
|
|
268
|
+
function xe(e, t, n) {
|
|
269
|
+
var r = be(F++, 2);
|
|
270
|
+
if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Oe(void 0, t), function(e) {
|
|
271
271
|
var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
|
|
272
272
|
t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
|
|
273
|
-
}], r.__c =
|
|
273
|
+
}], r.__c = I, !I.__f)) {
|
|
274
274
|
var i = function(e, t, n) {
|
|
275
275
|
if (!r.__c.__H) return !0;
|
|
276
276
|
var i = !1, o = r.__c.props !== e;
|
|
@@ -286,108 +286,108 @@ function _e(e, t, n) {
|
|
|
286
286
|
}
|
|
287
287
|
return !i || o;
|
|
288
288
|
};
|
|
289
|
-
|
|
290
|
-
var a =
|
|
291
|
-
|
|
289
|
+
I.__f = !0;
|
|
290
|
+
var a = I.shouldComponentUpdate, o = I.componentWillUpdate;
|
|
291
|
+
I.componentWillUpdate = function(e, t, n) {
|
|
292
292
|
if (this.__e) {
|
|
293
293
|
var r = a;
|
|
294
294
|
a = void 0, i(e, t, n), a = r;
|
|
295
295
|
}
|
|
296
296
|
o && o.call(this, e, t, n);
|
|
297
|
-
},
|
|
297
|
+
}, I.shouldComponentUpdate = i;
|
|
298
298
|
}
|
|
299
299
|
return r.__N || r.__;
|
|
300
300
|
}
|
|
301
|
-
function
|
|
302
|
-
var n =
|
|
303
|
-
!
|
|
301
|
+
function B(e, t) {
|
|
302
|
+
var n = be(F++, 3);
|
|
303
|
+
!R.__s && De(n.__H, t) && (n.__ = e, n.u = t, I.__H.__h.push(n));
|
|
304
304
|
}
|
|
305
|
-
function
|
|
306
|
-
return
|
|
305
|
+
function V(e) {
|
|
306
|
+
return L = 5, Se(function() {
|
|
307
307
|
return { current: e };
|
|
308
308
|
}, []);
|
|
309
309
|
}
|
|
310
|
-
function
|
|
311
|
-
var n =
|
|
312
|
-
return
|
|
310
|
+
function Se(e, t) {
|
|
311
|
+
var n = be(F++, 7);
|
|
312
|
+
return De(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
|
|
313
313
|
}
|
|
314
|
-
function
|
|
315
|
-
for (var e; e =
|
|
314
|
+
function Ce() {
|
|
315
|
+
for (var e; e = pe.shift();) {
|
|
316
316
|
var t = e.__H;
|
|
317
317
|
if (e.__P && t) try {
|
|
318
|
-
t.__h.some(
|
|
318
|
+
t.__h.some(H), t.__h.some(Ee), t.__h = [];
|
|
319
319
|
} catch (n) {
|
|
320
|
-
t.__h = [],
|
|
320
|
+
t.__h = [], R.__e(n, e.__v);
|
|
321
321
|
}
|
|
322
322
|
}
|
|
323
323
|
}
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
},
|
|
327
|
-
e && t.__k && t.__k.__m && (e.__m = t.__k.__m),
|
|
328
|
-
},
|
|
329
|
-
|
|
330
|
-
var t = (
|
|
331
|
-
t && (
|
|
324
|
+
R.__b = function(e) {
|
|
325
|
+
I = null, me && me(e);
|
|
326
|
+
}, R.__ = function(e, t) {
|
|
327
|
+
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), ye && ye(e, t);
|
|
328
|
+
}, R.__r = function(e) {
|
|
329
|
+
he && he(e), F = 0;
|
|
330
|
+
var t = (I = e.__c).__H;
|
|
331
|
+
t && (de === I ? (t.__h = [], I.__h = [], t.__.some(function(e) {
|
|
332
332
|
e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
|
|
333
|
-
})) : (t.__h.some(
|
|
334
|
-
},
|
|
335
|
-
|
|
333
|
+
})) : (t.__h.some(H), t.__h.some(Ee), t.__h = [], F = 0)), de = I;
|
|
334
|
+
}, R.diffed = function(e) {
|
|
335
|
+
ge && ge(e);
|
|
336
336
|
var t = e.__c;
|
|
337
|
-
t && t.__H && (t.__H.__h.length && (
|
|
337
|
+
t && t.__H && (t.__H.__h.length && (pe.push(t) !== 1 && fe === R.requestAnimationFrame || ((fe = R.requestAnimationFrame) || Te)(Ce)), t.__H.__.some(function(e) {
|
|
338
338
|
e.u &&= (e.__H = e.u, void 0);
|
|
339
|
-
})),
|
|
340
|
-
},
|
|
339
|
+
})), de = I = null;
|
|
340
|
+
}, R.__c = function(e, t) {
|
|
341
341
|
t.some(function(e) {
|
|
342
342
|
try {
|
|
343
|
-
e.__h.some(
|
|
344
|
-
return !e.__ ||
|
|
343
|
+
e.__h.some(H), e.__h = e.__h.filter(function(e) {
|
|
344
|
+
return !e.__ || Ee(e);
|
|
345
345
|
});
|
|
346
346
|
} catch (n) {
|
|
347
347
|
t.some(function(e) {
|
|
348
348
|
e.__h &&= [];
|
|
349
|
-
}), t = [],
|
|
349
|
+
}), t = [], R.__e(n, e.__v);
|
|
350
350
|
}
|
|
351
|
-
}),
|
|
352
|
-
},
|
|
353
|
-
|
|
351
|
+
}), _e && _e(e, t);
|
|
352
|
+
}, R.unmount = function(e) {
|
|
353
|
+
ve && ve(e);
|
|
354
354
|
var t, n = e.__c;
|
|
355
355
|
n && n.__H && (n.__H.__.some(function(e) {
|
|
356
356
|
try {
|
|
357
|
-
|
|
357
|
+
H(e);
|
|
358
358
|
} catch (e) {
|
|
359
359
|
t = e;
|
|
360
360
|
}
|
|
361
|
-
}), n.__H = void 0, t &&
|
|
361
|
+
}), n.__H = void 0, t && R.__e(t, n.__v));
|
|
362
362
|
};
|
|
363
|
-
var
|
|
364
|
-
function
|
|
363
|
+
var we = typeof requestAnimationFrame == "function";
|
|
364
|
+
function Te(e) {
|
|
365
365
|
var t, n = function() {
|
|
366
|
-
clearTimeout(r),
|
|
366
|
+
clearTimeout(r), we && cancelAnimationFrame(t), setTimeout(e);
|
|
367
367
|
}, r = setTimeout(n, 35);
|
|
368
|
-
|
|
368
|
+
we && (t = requestAnimationFrame(n));
|
|
369
369
|
}
|
|
370
|
-
function
|
|
371
|
-
var t =
|
|
372
|
-
typeof n == "function" && (e.__c = void 0, n()),
|
|
370
|
+
function H(e) {
|
|
371
|
+
var t = I, n = e.__c;
|
|
372
|
+
typeof n == "function" && (e.__c = void 0, n()), I = t;
|
|
373
373
|
}
|
|
374
|
-
function
|
|
375
|
-
var t =
|
|
376
|
-
e.__c = e.__(),
|
|
374
|
+
function Ee(e) {
|
|
375
|
+
var t = I;
|
|
376
|
+
e.__c = e.__(), I = t;
|
|
377
377
|
}
|
|
378
|
-
function
|
|
378
|
+
function De(e, t) {
|
|
379
379
|
return !e || e.length !== t.length || t.some(function(t, n) {
|
|
380
380
|
return t !== e[n];
|
|
381
381
|
});
|
|
382
382
|
}
|
|
383
|
-
function
|
|
383
|
+
function Oe(e, t) {
|
|
384
384
|
return typeof t == "function" ? t(e) : t;
|
|
385
385
|
}
|
|
386
386
|
//#endregion
|
|
387
387
|
//#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
|
|
388
|
-
var
|
|
388
|
+
var ke = 0;
|
|
389
389
|
Array.isArray;
|
|
390
|
-
function
|
|
390
|
+
function U(e, t, r, i, a, o) {
|
|
391
391
|
t ||= {};
|
|
392
392
|
var s, c, l = t;
|
|
393
393
|
if ("ref" in l) for (c in l = {}, t) c == "ref" ? s = t[c] : l[c] = t[c];
|
|
@@ -402,7 +402,7 @@ function q(e, t, r, i, a, o) {
|
|
|
402
402
|
__e: null,
|
|
403
403
|
__c: null,
|
|
404
404
|
constructor: void 0,
|
|
405
|
-
__v: --
|
|
405
|
+
__v: --ke,
|
|
406
406
|
__i: -1,
|
|
407
407
|
__u: 0,
|
|
408
408
|
__source: a,
|
|
@@ -413,8 +413,8 @@ function q(e, t, r, i, a, o) {
|
|
|
413
413
|
}
|
|
414
414
|
//#endregion
|
|
415
415
|
//#region src/components/icons.tsx
|
|
416
|
-
function
|
|
417
|
-
return /* @__PURE__ */
|
|
416
|
+
function W({ name: e, size: t, children: n }) {
|
|
417
|
+
return /* @__PURE__ */ U("svg", {
|
|
418
418
|
"data-icon": e,
|
|
419
419
|
"aria-hidden": "true",
|
|
420
420
|
focusable: "false",
|
|
@@ -429,76 +429,81 @@ function J({ name: e, size: t, children: n }) {
|
|
|
429
429
|
children: n
|
|
430
430
|
});
|
|
431
431
|
}
|
|
432
|
-
function
|
|
433
|
-
return /* @__PURE__ */
|
|
432
|
+
function Ae({ size: e = 26 }) {
|
|
433
|
+
return /* @__PURE__ */ U(W, {
|
|
434
434
|
name: "chat",
|
|
435
435
|
size: e,
|
|
436
|
-
children: [/* @__PURE__ */
|
|
436
|
+
children: [/* @__PURE__ */ U("path", { d: "M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z" }), /* @__PURE__ */ U("path", {
|
|
437
437
|
d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
|
|
438
438
|
"stroke-width": "2.5"
|
|
439
439
|
})]
|
|
440
440
|
});
|
|
441
441
|
}
|
|
442
|
-
function
|
|
443
|
-
return /* @__PURE__ */
|
|
442
|
+
function je({ size: e = 26 }) {
|
|
443
|
+
return /* @__PURE__ */ U(W, {
|
|
444
444
|
name: "chevron-down",
|
|
445
445
|
size: e,
|
|
446
|
-
children: /* @__PURE__ */
|
|
446
|
+
children: /* @__PURE__ */ U("path", { d: "M6 9l6 6 6-6" })
|
|
447
447
|
});
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
return /* @__PURE__ */
|
|
449
|
+
function Me({ size: e = 18 }) {
|
|
450
|
+
return /* @__PURE__ */ U(W, {
|
|
451
451
|
name: "close",
|
|
452
452
|
size: e,
|
|
453
|
-
children: /* @__PURE__ */
|
|
453
|
+
children: /* @__PURE__ */ U("path", { d: "M6 6l12 12M18 6L6 18" })
|
|
454
454
|
});
|
|
455
455
|
}
|
|
456
|
-
var
|
|
457
|
-
function
|
|
458
|
-
return /* @__PURE__ */
|
|
456
|
+
var Ne = "M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7";
|
|
457
|
+
function Pe({ size: e = 16 }) {
|
|
458
|
+
return /* @__PURE__ */ U(W, {
|
|
459
459
|
name: "thumb-up",
|
|
460
460
|
size: e,
|
|
461
|
-
children: /* @__PURE__ */
|
|
461
|
+
children: /* @__PURE__ */ U("path", { d: Ne })
|
|
462
462
|
});
|
|
463
463
|
}
|
|
464
|
-
function
|
|
465
|
-
return /* @__PURE__ */
|
|
464
|
+
function Fe({ size: e = 16 }) {
|
|
465
|
+
return /* @__PURE__ */ U(W, {
|
|
466
466
|
name: "thumb-down",
|
|
467
467
|
size: e,
|
|
468
|
-
children: /* @__PURE__ */
|
|
469
|
-
d:
|
|
468
|
+
children: /* @__PURE__ */ U("path", {
|
|
469
|
+
d: Ne,
|
|
470
470
|
transform: "matrix(1 0 0 -1 0 24)"
|
|
471
471
|
})
|
|
472
472
|
});
|
|
473
473
|
}
|
|
474
474
|
//#endregion
|
|
475
475
|
//#region src/components/Launcher.tsx
|
|
476
|
-
function
|
|
477
|
-
|
|
476
|
+
function Ie({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
|
|
477
|
+
let [i, a] = z("loading"), o = n !== void 0 && i !== "failed", s = o && !e && i === "loaded";
|
|
478
|
+
return /* @__PURE__ */ U("button", {
|
|
478
479
|
type: "button",
|
|
479
480
|
class: "whoo-widget-launcher",
|
|
480
481
|
onClick: t,
|
|
481
482
|
"aria-label": e ? "Close chat" : "Open chat",
|
|
482
483
|
ref: r,
|
|
483
|
-
children: e ? /* @__PURE__ */
|
|
484
|
-
class: "whoo-widget-launcher-
|
|
484
|
+
children: [e ? /* @__PURE__ */ U(je, {}) : s ? null : /* @__PURE__ */ U(Ae, {}), o ? /* @__PURE__ */ U("img", {
|
|
485
|
+
class: "whoo-widget-launcher-icon-image",
|
|
485
486
|
src: n,
|
|
486
|
-
alt: ""
|
|
487
|
-
|
|
487
|
+
alt: "",
|
|
488
|
+
referrerpolicy: "no-referrer",
|
|
489
|
+
hidden: !s,
|
|
490
|
+
onLoad: () => a("loaded"),
|
|
491
|
+
onError: () => a("failed")
|
|
492
|
+
}) : null]
|
|
488
493
|
});
|
|
489
494
|
}
|
|
490
495
|
//#endregion
|
|
491
496
|
//#region src/components/Composer.tsx
|
|
492
|
-
function
|
|
493
|
-
return /* @__PURE__ */
|
|
497
|
+
function Le({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
498
|
+
return /* @__PURE__ */ U("div", {
|
|
494
499
|
class: "whoo-widget-composer",
|
|
495
500
|
children: [
|
|
496
|
-
/* @__PURE__ */
|
|
501
|
+
/* @__PURE__ */ U("label", {
|
|
497
502
|
class: "whoo-widget-sr-only",
|
|
498
503
|
for: "whoo-widget-composer-input",
|
|
499
504
|
children: "Message"
|
|
500
505
|
}),
|
|
501
|
-
/* @__PURE__ */
|
|
506
|
+
/* @__PURE__ */ U("input", {
|
|
502
507
|
id: "whoo-widget-composer-input",
|
|
503
508
|
class: "whoo-widget-composer-input",
|
|
504
509
|
value: e,
|
|
@@ -510,7 +515,7 @@ function Ne({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
|
510
515
|
e.key === "Enter" && n();
|
|
511
516
|
}
|
|
512
517
|
}),
|
|
513
|
-
/* @__PURE__ */
|
|
518
|
+
/* @__PURE__ */ U("button", {
|
|
514
519
|
type: "button",
|
|
515
520
|
class: "whoo-widget-composer-send",
|
|
516
521
|
onClick: n,
|
|
@@ -522,8 +527,8 @@ function Ne({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
|
522
527
|
}
|
|
523
528
|
//#endregion
|
|
524
529
|
//#region src/components/ErrorBanner.tsx
|
|
525
|
-
function
|
|
526
|
-
return /* @__PURE__ */
|
|
530
|
+
function Re({ message: e }) {
|
|
531
|
+
return /* @__PURE__ */ U("div", {
|
|
527
532
|
class: "whoo-widget-error-banner",
|
|
528
533
|
role: "alert",
|
|
529
534
|
children: e
|
|
@@ -531,8 +536,8 @@ function Pe({ message: e }) {
|
|
|
531
536
|
}
|
|
532
537
|
//#endregion
|
|
533
538
|
//#region src/markdown/tokenizer.ts
|
|
534
|
-
var
|
|
535
|
-
function
|
|
539
|
+
var G = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, K = /\*\*([^*]+)\*\*/y, q = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, J = /\*([^*]+)\*/y, ze = /https?:\/\/\S+/y, Be = /[.,;:!?)\]}>]+$/;
|
|
540
|
+
function Ve(e) {
|
|
536
541
|
let t = [], n = 0, r = 0, i = (n) => {
|
|
537
542
|
n > r && t.push({
|
|
538
543
|
type: "text",
|
|
@@ -552,56 +557,56 @@ function Le(e) {
|
|
|
552
557
|
}
|
|
553
558
|
}
|
|
554
559
|
if (e[n - 1] !== "!") {
|
|
555
|
-
|
|
556
|
-
let a =
|
|
560
|
+
G.lastIndex = n;
|
|
561
|
+
let a = G.exec(e);
|
|
557
562
|
if (a) {
|
|
558
563
|
i(n), t.push({
|
|
559
564
|
type: "link",
|
|
560
565
|
text: a[1],
|
|
561
566
|
url: a[2],
|
|
562
567
|
start: n,
|
|
563
|
-
end:
|
|
564
|
-
}), n =
|
|
568
|
+
end: G.lastIndex
|
|
569
|
+
}), n = G.lastIndex, r = n;
|
|
565
570
|
continue;
|
|
566
571
|
}
|
|
567
572
|
}
|
|
568
|
-
|
|
569
|
-
let a =
|
|
573
|
+
K.lastIndex = n;
|
|
574
|
+
let a = K.exec(e);
|
|
570
575
|
if (a) {
|
|
571
576
|
i(n), t.push({
|
|
572
577
|
type: "bold",
|
|
573
578
|
value: a[1],
|
|
574
579
|
start: n,
|
|
575
|
-
end:
|
|
576
|
-
}), n =
|
|
580
|
+
end: K.lastIndex
|
|
581
|
+
}), n = K.lastIndex, r = n;
|
|
577
582
|
continue;
|
|
578
583
|
}
|
|
579
|
-
|
|
580
|
-
let o =
|
|
584
|
+
q.lastIndex = n;
|
|
585
|
+
let o = q.exec(e);
|
|
581
586
|
if (o) {
|
|
582
587
|
i(n), t.push({
|
|
583
588
|
type: "italic",
|
|
584
589
|
value: o[1],
|
|
585
590
|
start: n,
|
|
586
|
-
end:
|
|
587
|
-
}), n =
|
|
591
|
+
end: q.lastIndex
|
|
592
|
+
}), n = q.lastIndex, r = n;
|
|
588
593
|
continue;
|
|
589
594
|
}
|
|
590
|
-
|
|
591
|
-
let s =
|
|
595
|
+
J.lastIndex = n;
|
|
596
|
+
let s = J.exec(e);
|
|
592
597
|
if (s) {
|
|
593
598
|
i(n), t.push({
|
|
594
599
|
type: "italic",
|
|
595
600
|
value: s[1],
|
|
596
601
|
start: n,
|
|
597
|
-
end:
|
|
598
|
-
}), n =
|
|
602
|
+
end: J.lastIndex
|
|
603
|
+
}), n = J.lastIndex, r = n;
|
|
599
604
|
continue;
|
|
600
605
|
}
|
|
601
|
-
|
|
602
|
-
let c =
|
|
606
|
+
ze.lastIndex = n;
|
|
607
|
+
let c = ze.exec(e);
|
|
603
608
|
if (c) {
|
|
604
|
-
let e = c[0].match(
|
|
609
|
+
let e = c[0].match(Be), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
|
|
605
610
|
if (a.length > 0) {
|
|
606
611
|
i(n), t.push({
|
|
607
612
|
type: "link",
|
|
@@ -619,16 +624,16 @@ function Le(e) {
|
|
|
619
624
|
}
|
|
620
625
|
//#endregion
|
|
621
626
|
//#region src/markdown/render.tsx
|
|
622
|
-
function
|
|
623
|
-
return
|
|
627
|
+
function He(e) {
|
|
628
|
+
return Ve(e).map((e, t) => {
|
|
624
629
|
switch (e.type) {
|
|
625
|
-
case "bold": return /* @__PURE__ */
|
|
626
|
-
case "italic": return /* @__PURE__ */
|
|
627
|
-
case "link": return /* @__PURE__ */
|
|
630
|
+
case "bold": return /* @__PURE__ */ U("strong", { children: e.value }, t);
|
|
631
|
+
case "italic": return /* @__PURE__ */ U("em", { children: e.value }, t);
|
|
632
|
+
case "link": return /* @__PURE__ */ U("a", {
|
|
628
633
|
href: e.url,
|
|
629
634
|
target: "_blank",
|
|
630
635
|
rel: "noopener noreferrer",
|
|
631
|
-
children: [e.text, /* @__PURE__ */
|
|
636
|
+
children: [e.text, /* @__PURE__ */ U("span", {
|
|
632
637
|
class: "whoo-widget-sr-only",
|
|
633
638
|
children: " (opens in new tab)"
|
|
634
639
|
})]
|
|
@@ -639,7 +644,7 @@ function Re(e) {
|
|
|
639
644
|
}
|
|
640
645
|
//#endregion
|
|
641
646
|
//#region src/components/MessageFeedback.tsx
|
|
642
|
-
var
|
|
647
|
+
var Ue = [
|
|
643
648
|
{
|
|
644
649
|
value: "",
|
|
645
650
|
label: "Select a reason (optional)"
|
|
@@ -661,50 +666,50 @@ var ze = [
|
|
|
661
666
|
label: "Other"
|
|
662
667
|
}
|
|
663
668
|
];
|
|
664
|
-
function
|
|
665
|
-
let [o, s] =
|
|
666
|
-
if (
|
|
669
|
+
function We({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancel: a }) {
|
|
670
|
+
let [o, s] = z(""), [c, l] = z(""), u = V(e.status);
|
|
671
|
+
if (B(() => {
|
|
667
672
|
let n = u.current;
|
|
668
673
|
if (u.current = e.status, n === e.status) return;
|
|
669
674
|
let r = t?.current;
|
|
670
675
|
if (!r) return;
|
|
671
676
|
let i = r.getRootNode();
|
|
672
677
|
r.contains(i.activeElement) || r.focus();
|
|
673
|
-
}, [e.status, t]), e.status === "submitted") return /* @__PURE__ */
|
|
678
|
+
}, [e.status, t]), e.status === "submitted") return /* @__PURE__ */ U("div", {
|
|
674
679
|
class: "whoo-widget-feedback-submitted",
|
|
675
680
|
role: "status",
|
|
676
681
|
children: "Thanks for the feedback"
|
|
677
682
|
});
|
|
678
|
-
if (e.status === "expanded") return /* @__PURE__ */
|
|
683
|
+
if (e.status === "expanded") return /* @__PURE__ */ U("div", {
|
|
679
684
|
class: "whoo-widget-feedback-form",
|
|
680
685
|
children: [
|
|
681
|
-
/* @__PURE__ */
|
|
686
|
+
/* @__PURE__ */ U("label", { children: [/* @__PURE__ */ U("span", {
|
|
682
687
|
class: "whoo-widget-sr-only",
|
|
683
688
|
children: "Additional feedback"
|
|
684
|
-
}), /* @__PURE__ */
|
|
689
|
+
}), /* @__PURE__ */ U("textarea", {
|
|
685
690
|
class: "whoo-widget-feedback-textarea",
|
|
686
691
|
value: o,
|
|
687
692
|
onInput: (e) => s(e.target.value),
|
|
688
693
|
placeholder: "What was wrong? (optional)"
|
|
689
694
|
})] }),
|
|
690
|
-
/* @__PURE__ */
|
|
695
|
+
/* @__PURE__ */ U("select", {
|
|
691
696
|
class: "whoo-widget-feedback-select",
|
|
692
697
|
"aria-label": "Feedback category",
|
|
693
698
|
value: c,
|
|
694
699
|
onChange: (e) => l(e.target.value),
|
|
695
|
-
children:
|
|
700
|
+
children: Ue.map((e) => /* @__PURE__ */ U("option", {
|
|
696
701
|
value: e.value,
|
|
697
702
|
children: e.label
|
|
698
703
|
}, e.value))
|
|
699
704
|
}),
|
|
700
|
-
/* @__PURE__ */
|
|
705
|
+
/* @__PURE__ */ U("div", {
|
|
701
706
|
class: "whoo-widget-feedback-form-buttons",
|
|
702
|
-
children: [/* @__PURE__ */
|
|
707
|
+
children: [/* @__PURE__ */ U("button", {
|
|
703
708
|
type: "button",
|
|
704
709
|
class: "whoo-widget-feedback-submit",
|
|
705
710
|
onClick: () => i(o, c),
|
|
706
711
|
children: "Submit"
|
|
707
|
-
}), /* @__PURE__ */
|
|
712
|
+
}), /* @__PURE__ */ U("button", {
|
|
708
713
|
type: "button",
|
|
709
714
|
class: "whoo-widget-feedback-cancel",
|
|
710
715
|
onClick: a,
|
|
@@ -714,24 +719,24 @@ function Be({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
|
|
|
714
719
|
]
|
|
715
720
|
});
|
|
716
721
|
let d = e.status === "submitting";
|
|
717
|
-
return /* @__PURE__ */
|
|
722
|
+
return /* @__PURE__ */ U("div", {
|
|
718
723
|
class: "whoo-widget-feedback",
|
|
719
|
-
children: [/* @__PURE__ */
|
|
724
|
+
children: [/* @__PURE__ */ U("div", {
|
|
720
725
|
class: "whoo-widget-feedback-buttons",
|
|
721
|
-
children: [/* @__PURE__ */
|
|
726
|
+
children: [/* @__PURE__ */ U("button", {
|
|
722
727
|
type: "button",
|
|
723
728
|
"aria-label": "Good response",
|
|
724
729
|
disabled: d,
|
|
725
730
|
onClick: n,
|
|
726
|
-
children: /* @__PURE__ */
|
|
727
|
-
}), /* @__PURE__ */
|
|
731
|
+
children: /* @__PURE__ */ U(Pe, {})
|
|
732
|
+
}), /* @__PURE__ */ U("button", {
|
|
728
733
|
type: "button",
|
|
729
734
|
"aria-label": "Bad response",
|
|
730
735
|
disabled: d,
|
|
731
736
|
onClick: r,
|
|
732
|
-
children: /* @__PURE__ */
|
|
737
|
+
children: /* @__PURE__ */ U(Fe, {})
|
|
733
738
|
})]
|
|
734
|
-
}), e.status === "error" ? /* @__PURE__ */
|
|
739
|
+
}), e.status === "error" ? /* @__PURE__ */ U("div", {
|
|
735
740
|
class: "whoo-widget-feedback-error",
|
|
736
741
|
role: "status",
|
|
737
742
|
children: "Couldn't send feedback"
|
|
@@ -740,39 +745,69 @@ function Be({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
|
|
|
740
745
|
}
|
|
741
746
|
//#endregion
|
|
742
747
|
//#region src/components/MessageList.tsx
|
|
743
|
-
function
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
748
|
+
function Ge({ isSlowResponse: e }) {
|
|
749
|
+
return /* @__PURE__ */ U("div", {
|
|
750
|
+
class: "whoo-widget-pending",
|
|
751
|
+
role: "status",
|
|
752
|
+
children: [/* @__PURE__ */ U("span", {
|
|
753
|
+
class: "whoo-widget-typing",
|
|
754
|
+
"aria-hidden": "true",
|
|
755
|
+
children: [
|
|
756
|
+
/* @__PURE__ */ U("span", {}),
|
|
757
|
+
/* @__PURE__ */ U("span", {}),
|
|
758
|
+
/* @__PURE__ */ U("span", {})
|
|
759
|
+
]
|
|
760
|
+
}), e ? /* @__PURE__ */ U("span", {
|
|
761
|
+
class: "whoo-widget-pending-text",
|
|
762
|
+
children: "Looking that up for you…"
|
|
763
|
+
}) : null]
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
function Ke({ url: e, alt: t }) {
|
|
767
|
+
let [n, r] = z(!1);
|
|
768
|
+
return n ? null : /* @__PURE__ */ U("img", {
|
|
769
|
+
class: "whoo-widget-empty-state-image",
|
|
770
|
+
src: e,
|
|
771
|
+
alt: t,
|
|
772
|
+
referrerpolicy: "no-referrer",
|
|
773
|
+
onError: () => r(!0)
|
|
774
|
+
});
|
|
775
|
+
}
|
|
776
|
+
function qe({ message: e, feedbackState: t, pending: n, isSlowResponse: r, onThumbsUp: i, onThumbsDown: a, onSubmitDetailed: o, onCancelFeedback: s }) {
|
|
777
|
+
let c = V(null), l = e.id;
|
|
778
|
+
return /* @__PURE__ */ U("div", {
|
|
779
|
+
ref: c,
|
|
747
780
|
tabIndex: -1,
|
|
748
781
|
class: `whoo-widget-message whoo-widget-message--${e.role}`,
|
|
749
|
-
children: [
|
|
782
|
+
children: [n ? /* @__PURE__ */ U(Ge, { isSlowResponse: r }) : He(e.content), e.role === "assistant" && l ? /* @__PURE__ */ U(We, {
|
|
750
783
|
state: t,
|
|
751
|
-
containerRef:
|
|
752
|
-
onThumbsUp: () =>
|
|
753
|
-
onThumbsDown: () =>
|
|
754
|
-
onSubmitDetailed: (e, t) =>
|
|
755
|
-
onCancel: () =>
|
|
784
|
+
containerRef: c,
|
|
785
|
+
onThumbsUp: () => i(l),
|
|
786
|
+
onThumbsDown: () => a(l),
|
|
787
|
+
onSubmitDetailed: (e, t) => o(l, e, t),
|
|
788
|
+
onCancel: () => s(l)
|
|
756
789
|
}) : null]
|
|
757
790
|
});
|
|
758
791
|
}
|
|
759
|
-
function
|
|
760
|
-
let
|
|
761
|
-
return
|
|
762
|
-
let e =
|
|
792
|
+
function Je({ messages: e, messageFeedback: t, lastCompletedMessageText: n, emptyStateImage: r, isStreaming: i = !1, isSlowResponse: a = !1, onThumbsUp: o, onThumbsDown: s, onSubmitDetailed: c, onCancelFeedback: l }) {
|
|
793
|
+
let u = V(null);
|
|
794
|
+
return B(() => {
|
|
795
|
+
let e = u.current;
|
|
763
796
|
e && (e.scrollTop = e.scrollHeight);
|
|
764
|
-
}, [e]), /* @__PURE__ */
|
|
797
|
+
}, [e, a]), /* @__PURE__ */ U(C, { children: [/* @__PURE__ */ U("div", {
|
|
765
798
|
class: "whoo-widget-message-list",
|
|
766
|
-
ref:
|
|
767
|
-
children: e.map((
|
|
768
|
-
message:
|
|
769
|
-
feedbackState:
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
799
|
+
ref: u,
|
|
800
|
+
children: [r ? /* @__PURE__ */ U(Ke, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ U(qe, {
|
|
801
|
+
message: n,
|
|
802
|
+
feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
|
|
803
|
+
pending: i && r === e.length - 1 && n.role === "assistant" && n.content === "",
|
|
804
|
+
isSlowResponse: a,
|
|
805
|
+
onThumbsUp: o,
|
|
806
|
+
onThumbsDown: s,
|
|
807
|
+
onSubmitDetailed: c,
|
|
808
|
+
onCancelFeedback: l
|
|
809
|
+
}, n.id ?? r))]
|
|
810
|
+
}), /* @__PURE__ */ U("div", {
|
|
776
811
|
class: "whoo-widget-sr-only",
|
|
777
812
|
"aria-live": "polite",
|
|
778
813
|
"aria-atomic": "true",
|
|
@@ -781,16 +816,16 @@ function He({ messages: e, messageFeedback: t, lastCompletedMessageText: n, onTh
|
|
|
781
816
|
}
|
|
782
817
|
//#endregion
|
|
783
818
|
//#region src/components/Panel.tsx
|
|
784
|
-
var
|
|
785
|
-
function
|
|
786
|
-
return Array.from(e.querySelectorAll(
|
|
819
|
+
var Ye = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
|
|
820
|
+
function Xe(e) {
|
|
821
|
+
return Array.from(e.querySelectorAll(Ye)).filter((e) => {
|
|
787
822
|
let t = getComputedStyle(e);
|
|
788
823
|
return t.display !== "none" && t.visibility !== "hidden";
|
|
789
824
|
});
|
|
790
825
|
}
|
|
791
|
-
function
|
|
792
|
-
let r =
|
|
793
|
-
|
|
826
|
+
function Ze({ state: e, controller: t, greeting: n }) {
|
|
827
|
+
let r = V(null), i = V(null);
|
|
828
|
+
B(() => {
|
|
794
829
|
i.current?.focus();
|
|
795
830
|
}, []);
|
|
796
831
|
let a = (e) => {
|
|
@@ -801,7 +836,7 @@ function Ge({ state: e, controller: t, greeting: n }) {
|
|
|
801
836
|
if (e.key !== "Tab") return;
|
|
802
837
|
let n = r.current;
|
|
803
838
|
if (!n) return;
|
|
804
|
-
let i =
|
|
839
|
+
let i = Xe(n);
|
|
805
840
|
if (i.length === 0) return;
|
|
806
841
|
let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
|
|
807
842
|
if (!n.contains(s)) {
|
|
@@ -811,52 +846,58 @@ function Ge({ state: e, controller: t, greeting: n }) {
|
|
|
811
846
|
e.shiftKey && s === a ? (e.preventDefault(), o.focus()) : !e.shiftKey && s === o && (e.preventDefault(), a.focus());
|
|
812
847
|
}, o = () => {
|
|
813
848
|
let n = e.draft.trim();
|
|
814
|
-
|
|
815
|
-
}, s = e.messages.length === 0 && n ? [{
|
|
849
|
+
n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
|
|
850
|
+
}, s = `Chat with ${e.agentName ?? (t.config.name?.trim() || "Aiden")}`, c = e.messages.length === 0 && n ? [{
|
|
816
851
|
role: "assistant",
|
|
817
852
|
content: n,
|
|
818
853
|
id: null
|
|
819
|
-
}] : e.messages
|
|
820
|
-
|
|
854
|
+
}] : e.messages, l = t.emptyStateImageUrl, u = e.messages.length === 0 && l ? {
|
|
855
|
+
url: l,
|
|
856
|
+
alt: t.emptyStateImageAlt
|
|
857
|
+
} : void 0;
|
|
858
|
+
return /* @__PURE__ */ U("div", {
|
|
821
859
|
class: "whoo-widget-panel",
|
|
822
860
|
role: "dialog",
|
|
823
861
|
"aria-modal": "true",
|
|
824
|
-
"aria-label":
|
|
862
|
+
"aria-label": s,
|
|
825
863
|
ref: r,
|
|
826
864
|
onKeyDown: a,
|
|
827
865
|
children: [
|
|
828
|
-
/* @__PURE__ */
|
|
866
|
+
/* @__PURE__ */ U("div", {
|
|
829
867
|
class: "whoo-widget-header",
|
|
830
|
-
children: [/* @__PURE__ */
|
|
868
|
+
children: [/* @__PURE__ */ U("h2", {
|
|
831
869
|
class: "whoo-widget-header-title",
|
|
832
|
-
children:
|
|
833
|
-
}), /* @__PURE__ */
|
|
870
|
+
children: s
|
|
871
|
+
}), /* @__PURE__ */ U("div", {
|
|
834
872
|
class: "whoo-widget-header-actions",
|
|
835
|
-
children: [e.messages.length > 0 && /* @__PURE__ */
|
|
873
|
+
children: [e.messages.length > 0 && /* @__PURE__ */ U("button", {
|
|
836
874
|
type: "button",
|
|
837
875
|
class: "whoo-widget-header-reset",
|
|
838
876
|
onClick: () => t.resetConversation(),
|
|
839
877
|
children: "New conversation"
|
|
840
|
-
}), /* @__PURE__ */
|
|
878
|
+
}), /* @__PURE__ */ U("button", {
|
|
841
879
|
type: "button",
|
|
842
880
|
class: "whoo-widget-header-close",
|
|
843
881
|
"aria-label": "Close chat",
|
|
844
882
|
onClick: () => t.close(),
|
|
845
|
-
children: /* @__PURE__ */
|
|
883
|
+
children: /* @__PURE__ */ U(Me, {})
|
|
846
884
|
})]
|
|
847
885
|
})]
|
|
848
886
|
}),
|
|
849
|
-
/* @__PURE__ */
|
|
850
|
-
messages:
|
|
887
|
+
/* @__PURE__ */ U(Je, {
|
|
888
|
+
messages: c,
|
|
851
889
|
messageFeedback: e.messageFeedback,
|
|
852
890
|
lastCompletedMessageText: e.lastCompletedMessageText,
|
|
891
|
+
emptyStateImage: u,
|
|
892
|
+
isStreaming: e.isStreaming,
|
|
893
|
+
isSlowResponse: e.isSlowResponse,
|
|
853
894
|
onThumbsUp: (e) => t.submitFeedback(e, "up"),
|
|
854
895
|
onThumbsDown: (e) => t.expandFeedback(e),
|
|
855
896
|
onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
|
|
856
897
|
onCancelFeedback: (e) => t.cancelFeedback(e)
|
|
857
898
|
}),
|
|
858
|
-
e.runtimeError && /* @__PURE__ */
|
|
859
|
-
/* @__PURE__ */
|
|
899
|
+
e.runtimeError && /* @__PURE__ */ U(Re, { message: e.runtimeError }),
|
|
900
|
+
/* @__PURE__ */ U(Le, {
|
|
860
901
|
value: e.draft,
|
|
861
902
|
onChange: (e) => t.setDraft(e),
|
|
862
903
|
onSend: o,
|
|
@@ -868,16 +909,16 @@ function Ge({ state: e, controller: t, greeting: n }) {
|
|
|
868
909
|
}
|
|
869
910
|
//#endregion
|
|
870
911
|
//#region src/components/App.tsx
|
|
871
|
-
function
|
|
872
|
-
let [t, n] =
|
|
873
|
-
return
|
|
912
|
+
function Qe({ controller: e }) {
|
|
913
|
+
let [t, n] = z(e.getState()), r = V(null), i = V(t.isOpen);
|
|
914
|
+
return B(() => (n(e.getState()), e.subscribe(n)), [e]), B(() => {
|
|
874
915
|
i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
|
|
875
|
-
}, [t.isOpen]), t.initError ? null : /* @__PURE__ */
|
|
916
|
+
}, [t.isOpen]), t.initError ? null : /* @__PURE__ */ U(C, { children: [/* @__PURE__ */ U(Ie, {
|
|
876
917
|
isOpen: t.isOpen,
|
|
877
918
|
onClick: () => t.isOpen ? e.close() : e.open(),
|
|
878
|
-
|
|
919
|
+
iconUrl: e.launcherIconUrl,
|
|
879
920
|
buttonRef: r
|
|
880
|
-
}), t.isOpen && /* @__PURE__ */
|
|
921
|
+
}), t.isOpen && /* @__PURE__ */ U(Ze, {
|
|
881
922
|
state: t,
|
|
882
923
|
controller: e,
|
|
883
924
|
greeting: e.config.greeting
|
|
@@ -885,26 +926,34 @@ function Ke({ controller: e }) {
|
|
|
885
926
|
}
|
|
886
927
|
//#endregion
|
|
887
928
|
//#region src/api/client.ts
|
|
888
|
-
var
|
|
929
|
+
var $e = class extends Error {
|
|
889
930
|
status;
|
|
890
931
|
constructor(e, t) {
|
|
891
932
|
super(e), this.name = "WidgetApiError", this.status = t;
|
|
892
933
|
}
|
|
893
934
|
};
|
|
894
|
-
|
|
935
|
+
function et(e) {
|
|
936
|
+
if (typeof e != "string") return null;
|
|
937
|
+
let t = e.trim();
|
|
938
|
+
return t === "" ? null : t;
|
|
939
|
+
}
|
|
940
|
+
async function tt(e, t) {
|
|
895
941
|
let n = await fetch(`${e}/api/v1/widget/session`, {
|
|
896
942
|
method: "POST",
|
|
897
943
|
headers: { "Content-Type": "application/json" },
|
|
898
944
|
body: JSON.stringify({ publishable_key: t })
|
|
899
945
|
});
|
|
900
|
-
if (!n.ok) throw new
|
|
946
|
+
if (!n.ok) throw new $e(`Failed to create widget session (${n.status})`, n.status);
|
|
901
947
|
let r = await n.json();
|
|
902
948
|
return {
|
|
903
949
|
token: r.token,
|
|
904
|
-
primaryColor: r.primary_color ?? null
|
|
950
|
+
primaryColor: r.primary_color ?? null,
|
|
951
|
+
name: et(r.name),
|
|
952
|
+
accentColor: et(r.accent_color),
|
|
953
|
+
inkColor: et(r.ink_color)
|
|
905
954
|
};
|
|
906
955
|
}
|
|
907
|
-
async function
|
|
956
|
+
async function nt(e, t, n) {
|
|
908
957
|
let r = await fetch(`${e}/api/v1/widget/feedback`, {
|
|
909
958
|
method: "POST",
|
|
910
959
|
headers: {
|
|
@@ -918,11 +967,11 @@ async function Ye(e, t, n) {
|
|
|
918
967
|
category: n.category ?? null
|
|
919
968
|
})
|
|
920
969
|
});
|
|
921
|
-
if (!r.ok) throw new
|
|
970
|
+
if (!r.ok) throw new $e(`Feedback submission failed (${r.status})`, r.status);
|
|
922
971
|
}
|
|
923
972
|
//#endregion
|
|
924
973
|
//#region src/api/sse.ts
|
|
925
|
-
async function*
|
|
974
|
+
async function* rt(e, t, n, r, i) {
|
|
926
975
|
let a = await fetch(`${e}/api/v1/widget/chat`, {
|
|
927
976
|
method: "POST",
|
|
928
977
|
headers: {
|
|
@@ -935,7 +984,7 @@ async function* Xe(e, t, n, r, i) {
|
|
|
935
984
|
}),
|
|
936
985
|
signal: i
|
|
937
986
|
});
|
|
938
|
-
if (!a.ok || !a.body) throw new
|
|
987
|
+
if (!a.ok || !a.body) throw new $e(`Chat request failed (${a.status})`, a.status);
|
|
939
988
|
let o = a.body.getReader(), s = new TextDecoder(), c = "";
|
|
940
989
|
for (;;) {
|
|
941
990
|
let { done: e, value: t } = await o.read();
|
|
@@ -946,11 +995,11 @@ async function* Xe(e, t, n, r, i) {
|
|
|
946
995
|
let e = c.slice(0, n);
|
|
947
996
|
c = c.slice(n + 2);
|
|
948
997
|
let t = e.split("\n").find((e) => e.startsWith("data: "));
|
|
949
|
-
t && (yield
|
|
998
|
+
t && (yield it(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
|
|
950
999
|
}
|
|
951
1000
|
}
|
|
952
1001
|
}
|
|
953
|
-
function
|
|
1002
|
+
function it(e) {
|
|
954
1003
|
return typeof e.error == "string" ? {
|
|
955
1004
|
type: "error",
|
|
956
1005
|
error: e.error,
|
|
@@ -972,17 +1021,28 @@ function Ze(e) {
|
|
|
972
1021
|
};
|
|
973
1022
|
}
|
|
974
1023
|
//#endregion
|
|
1024
|
+
//#region src/imageUrl.ts
|
|
1025
|
+
function at(e, t) {
|
|
1026
|
+
if (e != null && e !== "") {
|
|
1027
|
+
if (typeof e == "string") try {
|
|
1028
|
+
let t = new URL(e);
|
|
1029
|
+
if (t.protocol === "https:" || t.protocol === "data:" && t.pathname.toLowerCase().startsWith("image/")) return e;
|
|
1030
|
+
} catch {}
|
|
1031
|
+
console.warn(`whoo-aiden-widget: ignoring \`${t}\` -- only https: and data:image/ URLs are allowed.`);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
//#endregion
|
|
975
1035
|
//#region src/markdown/reveal.ts
|
|
976
|
-
var
|
|
977
|
-
function
|
|
1036
|
+
var ot = 40, st = 120;
|
|
1037
|
+
function ct(e) {
|
|
978
1038
|
let t = [];
|
|
979
|
-
for (let n of
|
|
1039
|
+
for (let n of Ve(e)) if (n.type === "text") {
|
|
980
1040
|
let e = n.value.split(/(\s+)/), r = n.start;
|
|
981
1041
|
for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
|
|
982
1042
|
} else t.push(n.end);
|
|
983
1043
|
return t;
|
|
984
1044
|
}
|
|
985
|
-
function
|
|
1045
|
+
function lt(e) {
|
|
986
1046
|
let t = null;
|
|
987
1047
|
return e?.addEventListener("abort", () => {
|
|
988
1048
|
t?.();
|
|
@@ -997,36 +1057,36 @@ function tt(e) {
|
|
|
997
1057
|
});
|
|
998
1058
|
};
|
|
999
1059
|
}
|
|
1000
|
-
async function
|
|
1001
|
-
let r = n?.wordIntervalMs ??
|
|
1002
|
-
for (let n of
|
|
1060
|
+
async function ut(e, t, n) {
|
|
1061
|
+
let r = n?.wordIntervalMs ?? ot, i = n?.tokenIntervalMs ?? st, a = n?.signal, o = Ve(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = lt(a), l = "";
|
|
1062
|
+
for (let n of ct(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
|
|
1003
1063
|
l !== e && t(e);
|
|
1004
1064
|
}
|
|
1005
1065
|
//#endregion
|
|
1006
1066
|
//#region src/storage.ts
|
|
1007
|
-
function
|
|
1067
|
+
function Y(e) {
|
|
1008
1068
|
return `whoo-aiden-widget:conversation:${e}`;
|
|
1009
1069
|
}
|
|
1010
|
-
function
|
|
1070
|
+
function dt(e) {
|
|
1011
1071
|
try {
|
|
1012
|
-
return window.sessionStorage.getItem(
|
|
1072
|
+
return window.sessionStorage.getItem(Y(e));
|
|
1013
1073
|
} catch {
|
|
1014
1074
|
return null;
|
|
1015
1075
|
}
|
|
1016
1076
|
}
|
|
1017
|
-
function
|
|
1077
|
+
function ft(e, t) {
|
|
1018
1078
|
try {
|
|
1019
|
-
window.sessionStorage.setItem(
|
|
1079
|
+
window.sessionStorage.setItem(Y(e), t);
|
|
1020
1080
|
} catch {}
|
|
1021
1081
|
}
|
|
1022
|
-
function
|
|
1082
|
+
function pt(e) {
|
|
1023
1083
|
try {
|
|
1024
|
-
window.sessionStorage.removeItem(
|
|
1084
|
+
window.sessionStorage.removeItem(Y(e));
|
|
1025
1085
|
} catch {}
|
|
1026
1086
|
}
|
|
1027
1087
|
//#endregion
|
|
1028
1088
|
//#region src/controller.ts
|
|
1029
|
-
var
|
|
1089
|
+
var mt = 8e3, ht = class {
|
|
1030
1090
|
config;
|
|
1031
1091
|
state;
|
|
1032
1092
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -1034,9 +1094,13 @@ var st = class {
|
|
|
1034
1094
|
conversationId = null;
|
|
1035
1095
|
storageIdentifier;
|
|
1036
1096
|
activeRequestController = null;
|
|
1097
|
+
slowResponseTimer = null;
|
|
1037
1098
|
prefersReducedMotion;
|
|
1099
|
+
launcherIconUrl;
|
|
1100
|
+
emptyStateImageUrl;
|
|
1101
|
+
emptyStateImageAlt;
|
|
1038
1102
|
constructor(e) {
|
|
1039
|
-
this.config = e, this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
|
|
1103
|
+
this.config = e, this.launcherIconUrl = at(e.launcherIconUrl, "launcherIconUrl"), this.emptyStateImageUrl = at(e.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof e.emptyStateImageAlt == "string" ? e.emptyStateImageAlt.trim() : "", this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
|
|
1040
1104
|
isOpen: !1,
|
|
1041
1105
|
messages: [],
|
|
1042
1106
|
isStreaming: !1,
|
|
@@ -1044,7 +1108,11 @@ var st = class {
|
|
|
1044
1108
|
runtimeError: null,
|
|
1045
1109
|
messageFeedback: {},
|
|
1046
1110
|
primaryColor: null,
|
|
1111
|
+
agentName: null,
|
|
1112
|
+
accentColor: null,
|
|
1113
|
+
inkColor: null,
|
|
1047
1114
|
lastCompletedMessageText: null,
|
|
1115
|
+
isSlowResponse: !1,
|
|
1048
1116
|
draft: ""
|
|
1049
1117
|
};
|
|
1050
1118
|
}
|
|
@@ -1054,6 +1122,9 @@ var st = class {
|
|
|
1054
1122
|
subscribe(e) {
|
|
1055
1123
|
return this.listeners.add(e), () => this.listeners.delete(e);
|
|
1056
1124
|
}
|
|
1125
|
+
clearSlowResponse() {
|
|
1126
|
+
this.slowResponseTimer !== null && (clearTimeout(this.slowResponseTimer), this.slowResponseTimer = null), this.state.isSlowResponse && this.setState({ isSlowResponse: !1 });
|
|
1127
|
+
}
|
|
1057
1128
|
setState(e) {
|
|
1058
1129
|
this.state = {
|
|
1059
1130
|
...this.state,
|
|
@@ -1066,20 +1137,25 @@ var st = class {
|
|
|
1066
1137
|
try {
|
|
1067
1138
|
if (this.config.sessionToken) this.sessionToken = this.config.sessionToken;
|
|
1068
1139
|
else if (this.config.publishableKey) {
|
|
1069
|
-
let { token: t, primaryColor: n } = await
|
|
1070
|
-
this.sessionToken = t, this.setState({
|
|
1140
|
+
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await tt(e, this.config.publishableKey);
|
|
1141
|
+
this.sessionToken = t, this.setState({
|
|
1142
|
+
primaryColor: n,
|
|
1143
|
+
agentName: r,
|
|
1144
|
+
accentColor: i,
|
|
1145
|
+
inkColor: a
|
|
1146
|
+
});
|
|
1071
1147
|
} else throw Error("WidgetConfig must include exactly one of publishableKey or sessionToken");
|
|
1072
1148
|
} catch (e) {
|
|
1073
1149
|
console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
|
|
1074
1150
|
return;
|
|
1075
1151
|
}
|
|
1076
|
-
this.conversationId =
|
|
1152
|
+
this.conversationId = dt(this.storageIdentifier);
|
|
1077
1153
|
}
|
|
1078
1154
|
open() {
|
|
1079
1155
|
this.setState({ isOpen: !0 });
|
|
1080
1156
|
}
|
|
1081
1157
|
resetConversation() {
|
|
1082
|
-
this.activeRequestController?.abort(), this.activeRequestController = null, this.conversationId = null,
|
|
1158
|
+
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, pt(this.storageIdentifier), this.setState({
|
|
1083
1159
|
messages: [],
|
|
1084
1160
|
messageFeedback: {},
|
|
1085
1161
|
runtimeError: null,
|
|
@@ -1091,7 +1167,7 @@ var st = class {
|
|
|
1091
1167
|
this.setState({ draft: e });
|
|
1092
1168
|
}
|
|
1093
1169
|
close() {
|
|
1094
|
-
this.activeRequestController?.abort(), this.activeRequestController = null, this.setState({ isOpen: !1 });
|
|
1170
|
+
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isOpen: !1 });
|
|
1095
1171
|
}
|
|
1096
1172
|
async sendMessage(e) {
|
|
1097
1173
|
if (!this.sessionToken) return;
|
|
@@ -1121,17 +1197,21 @@ var st = class {
|
|
|
1121
1197
|
}, this.setState({ messages: t });
|
|
1122
1198
|
};
|
|
1123
1199
|
this.activeRequestController = new AbortController();
|
|
1124
|
-
let { signal: a } = this.activeRequestController
|
|
1200
|
+
let { signal: a } = this.activeRequestController;
|
|
1201
|
+
this.slowResponseTimer = setTimeout(() => {
|
|
1202
|
+
this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
|
|
1203
|
+
}, mt);
|
|
1204
|
+
let o = () => {
|
|
1125
1205
|
this.setState({
|
|
1126
1206
|
runtimeError: "Something went wrong, please try again.",
|
|
1127
1207
|
...this.state.draft === "" ? { draft: e } : {}
|
|
1128
1208
|
});
|
|
1129
1209
|
}, s = "";
|
|
1130
1210
|
try {
|
|
1131
|
-
for await (let n of
|
|
1132
|
-
else if (n.type === "delta") n.verbatim && !this.prefersReducedMotion ? (await
|
|
1211
|
+
for await (let n of rt(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, ft(this.storageIdentifier, n.conversationId);
|
|
1212
|
+
else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await ut(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
|
|
1133
1213
|
else if (n.type === "done") {
|
|
1134
|
-
if (n.conversationId && (this.conversationId = n.conversationId,
|
|
1214
|
+
if (n.conversationId && (this.conversationId = n.conversationId, ft(this.storageIdentifier, n.conversationId)), n.messageId) {
|
|
1135
1215
|
let e = [...this.state.messages];
|
|
1136
1216
|
e[e.length - 1] = {
|
|
1137
1217
|
...e[e.length - 1],
|
|
@@ -1139,11 +1219,14 @@ var st = class {
|
|
|
1139
1219
|
}, this.setState({ messages: e });
|
|
1140
1220
|
}
|
|
1141
1221
|
this.setState({ lastCompletedMessageText: s });
|
|
1142
|
-
} else n.type === "error"
|
|
1222
|
+
} else if (n.type === "error") {
|
|
1223
|
+
console.error("[whoo-aiden-widget] chat error:", n.error), o(), this.activeRequestController?.abort();
|
|
1224
|
+
break;
|
|
1225
|
+
}
|
|
1143
1226
|
} catch (e) {
|
|
1144
1227
|
e?.name === "AbortError" || (console.error("[whoo-aiden-widget] chat request failed:", e), o());
|
|
1145
1228
|
} finally {
|
|
1146
|
-
this.activeRequestController = null, this.setState({ isStreaming: !1 });
|
|
1229
|
+
this.activeRequestController = null, this.clearSlowResponse(), this.setState({ isStreaming: !1 });
|
|
1147
1230
|
}
|
|
1148
1231
|
}
|
|
1149
1232
|
expandFeedback(e) {
|
|
@@ -1169,7 +1252,7 @@ var st = class {
|
|
|
1169
1252
|
}
|
|
1170
1253
|
} });
|
|
1171
1254
|
try {
|
|
1172
|
-
await
|
|
1255
|
+
await nt(i, this.sessionToken, {
|
|
1173
1256
|
messageId: e,
|
|
1174
1257
|
rating: t,
|
|
1175
1258
|
correction: n,
|
|
@@ -1191,107 +1274,144 @@ var st = class {
|
|
|
1191
1274
|
} });
|
|
1192
1275
|
}
|
|
1193
1276
|
}
|
|
1194
|
-
},
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
function lt(e) {
|
|
1277
|
+
}, gt = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:20px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:var(--whoo-widget-color,#4f46e5);width:56px;height:56px;color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{display:block}.whoo-widget-launcher-icon-image{object-fit:cover;border-radius:50%;width:32px;height:32px}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:88px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:#fff;border-radius:12px;flex-direction:column;width:360px;max-width:calc(100vw - 40px);height:480px;max-height:calc(100vh - 108px);display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid #e5e5e5;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;padding:8px 8px 8px 16px;display:flex}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);text-overflow:ellipsis;white-space:nowrap;margin:0;font-size:15px;font-weight:600;overflow:hidden}.whoo-widget-header-actions{flex-shrink:0;align-items:center;gap:4px;display:flex}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:#f3f4f6}.whoo-widget-message-list{flex:1;min-height:100px;padding:12px;overflow-y:auto}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{color:var(--whoo-widget-ink,#111);background:#f0f0f0}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:#6b7280;border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{color:#991b1b;background:#fee2e2;padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid #e5e5e5;gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid #6b7280;border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send:disabled,.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:#4b5563;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:#111;background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;resize:vertical;border:1px solid #6b7280;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid #6b7280;border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{color:#111;cursor:pointer;background:#fff;border:1px solid #6b7280;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:#6b7280;margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:#991b1b;font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline-offset:2px;outline:2px solid #111827;box-shadow:0 0 0 4px #fff}", _t = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
|
|
1278
|
+
function vt(e) {
|
|
1279
|
+
if (_t.test(e.trim())) return null;
|
|
1198
1280
|
let t = document.createElement("div");
|
|
1199
1281
|
if (t.style.color = e, t.style.color === "") return null;
|
|
1200
|
-
document.
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1282
|
+
let n = document.createElement("div");
|
|
1283
|
+
n.attachShadow({ mode: "open" }).appendChild(t), document.body.appendChild(n);
|
|
1284
|
+
let r = getComputedStyle(t).color;
|
|
1285
|
+
n.remove();
|
|
1286
|
+
let i = r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);
|
|
1287
|
+
if (!i) return null;
|
|
1288
|
+
let a = i[4] === void 0 ? 1 : Number(i[4]);
|
|
1206
1289
|
return {
|
|
1207
1290
|
rgb: [
|
|
1208
|
-
Number(
|
|
1209
|
-
Number(
|
|
1210
|
-
Number(
|
|
1211
|
-
].map((e) => Math.round(e *
|
|
1212
|
-
translucent:
|
|
1291
|
+
Number(i[1]),
|
|
1292
|
+
Number(i[2]),
|
|
1293
|
+
Number(i[3])
|
|
1294
|
+
].map((e) => Math.round(e * a + 255 * (1 - a))),
|
|
1295
|
+
translucent: a < 1
|
|
1213
1296
|
};
|
|
1214
1297
|
}
|
|
1215
|
-
function
|
|
1216
|
-
return
|
|
1298
|
+
function yt(e) {
|
|
1299
|
+
return vt(e)?.rgb ?? null;
|
|
1217
1300
|
}
|
|
1218
|
-
function
|
|
1301
|
+
function X([e, t, n]) {
|
|
1219
1302
|
let r = (e) => {
|
|
1220
1303
|
let t = e / 255;
|
|
1221
1304
|
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
1222
1305
|
};
|
|
1223
1306
|
return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
|
|
1224
1307
|
}
|
|
1225
|
-
function
|
|
1308
|
+
function bt(e, t) {
|
|
1226
1309
|
let n = Math.max(e, t), r = Math.min(e, t);
|
|
1227
1310
|
return (n + .05) / (r + .05);
|
|
1228
1311
|
}
|
|
1229
|
-
function
|
|
1230
|
-
let t =
|
|
1312
|
+
function xt(e) {
|
|
1313
|
+
let t = yt(e);
|
|
1231
1314
|
if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
|
|
1232
|
-
let n =
|
|
1233
|
-
return
|
|
1315
|
+
let n = X(t);
|
|
1316
|
+
return bt(n, X([
|
|
1234
1317
|
0,
|
|
1235
1318
|
0,
|
|
1236
1319
|
0
|
|
1237
|
-
])) >=
|
|
1320
|
+
])) >= bt(n, X([
|
|
1238
1321
|
255,
|
|
1239
1322
|
255,
|
|
1240
1323
|
255
|
|
1241
1324
|
])) ? "#000000" : "#ffffff";
|
|
1242
1325
|
}
|
|
1243
|
-
var
|
|
1244
|
-
|
|
1245
|
-
255,
|
|
1246
|
-
255
|
|
1247
|
-
], ht = 4.5;
|
|
1248
|
-
function gt([e, t, n]) {
|
|
1326
|
+
var Z = "#4f46e5", St = "#ffffff", Ct = "#f0f0f0", wt = 4.5;
|
|
1327
|
+
function Tt([e, t, n]) {
|
|
1249
1328
|
return `#${[
|
|
1250
1329
|
e,
|
|
1251
1330
|
t,
|
|
1252
1331
|
n
|
|
1253
1332
|
].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
1254
1333
|
}
|
|
1255
|
-
function
|
|
1256
|
-
let
|
|
1257
|
-
if (!
|
|
1258
|
-
let
|
|
1259
|
-
if (
|
|
1334
|
+
function Et(e, t = St) {
|
|
1335
|
+
let n = yt(e), r = yt(t);
|
|
1336
|
+
if (!n || !r) return Z;
|
|
1337
|
+
let i = X(r), a = (e) => bt(X(e), i) >= wt;
|
|
1338
|
+
if (a(n)) return Tt(n);
|
|
1260
1339
|
for (let e = .99; e > 0; e -= .01) {
|
|
1261
|
-
let
|
|
1262
|
-
if (
|
|
1340
|
+
let t = n.map((t) => Math.round(t * e));
|
|
1341
|
+
if (a(t)) return Tt(t);
|
|
1263
1342
|
}
|
|
1264
1343
|
return "#000000";
|
|
1265
1344
|
}
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1345
|
+
var Dt = "#111111", Ot = "#0000ee";
|
|
1346
|
+
function Q(e) {
|
|
1347
|
+
if (!e) return null;
|
|
1348
|
+
let t = vt(e);
|
|
1349
|
+
return t ? Tt(t.rgb) : null;
|
|
1269
1350
|
}
|
|
1270
|
-
function
|
|
1271
|
-
|
|
1351
|
+
function $({ color: e, inkColor: t, accentColor: n }) {
|
|
1352
|
+
let r = Q(e), i = r ?? Z, a = Et(i), o = Q(t), s = o ? Et(o, Ct) : Dt, c = Q(n), l = c ? Et(c, Ct) : Ot;
|
|
1353
|
+
return {
|
|
1354
|
+
primary: i,
|
|
1355
|
+
textOnPrimary: xt(i),
|
|
1356
|
+
primaryAsText: a,
|
|
1357
|
+
ink: s,
|
|
1358
|
+
link: l,
|
|
1359
|
+
adjusted: {
|
|
1360
|
+
primary: r !== null && a !== i,
|
|
1361
|
+
ink: o !== null && s !== o,
|
|
1362
|
+
link: c !== null && l !== c
|
|
1363
|
+
}
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
function kt(e, t, n = Z) {
|
|
1367
|
+
let r = t;
|
|
1368
|
+
Q(t) === null && (console.warn(`[whoo-aiden-widget] Could not use "${t}" as the theme color; falling back to "${n}".`), r = n);
|
|
1369
|
+
let i = $({ color: r });
|
|
1370
|
+
e.style.setProperty("--whoo-widget-color", i.primary), e.style.setProperty("--whoo-widget-text-on-color", i.textOnPrimary), e.style.setProperty("--whoo-widget-color-text", i.primaryAsText);
|
|
1371
|
+
}
|
|
1372
|
+
function At(e, { inkColor: t, accentColor: n }) {
|
|
1373
|
+
let r = $({
|
|
1374
|
+
inkColor: t,
|
|
1375
|
+
accentColor: n
|
|
1376
|
+
});
|
|
1377
|
+
e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
|
|
1378
|
+
}
|
|
1379
|
+
function jt(e, t) {
|
|
1380
|
+
e && Q(e) === null && console.warn(`[whoo-aiden-widget] Could not use "${e}" as the ${t}; using the default.`);
|
|
1381
|
+
}
|
|
1382
|
+
function Mt(e, t) {
|
|
1383
|
+
kt(e, t.color ?? Z), jt(t.inkColor, "ink color"), jt(t.accentColor, "accent color"), At(e, {
|
|
1384
|
+
inkColor: t.inkColor,
|
|
1385
|
+
accentColor: t.accentColor
|
|
1386
|
+
});
|
|
1272
1387
|
let n = t.position === "bottom-left";
|
|
1273
1388
|
e.style.setProperty("--whoo-widget-inset-left", n ? "20px" : "auto"), e.style.setProperty("--whoo-widget-inset-right", n ? "auto" : "20px");
|
|
1274
1389
|
}
|
|
1275
1390
|
//#endregion
|
|
1276
1391
|
//#region src/mount.tsx
|
|
1277
|
-
function
|
|
1392
|
+
function Nt(e) {
|
|
1278
1393
|
let t = document.createElement("div");
|
|
1279
1394
|
t.id = "whoo-aiden-widget-host";
|
|
1280
1395
|
let n = t.attachShadow({ mode: "open" }), r = document.createElement("style");
|
|
1281
|
-
r.textContent =
|
|
1396
|
+
r.textContent = gt, n.appendChild(r);
|
|
1282
1397
|
let i = document.createElement("div");
|
|
1283
|
-
n.appendChild(i),
|
|
1284
|
-
let a = new
|
|
1285
|
-
return a.subscribe((
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1398
|
+
n.appendChild(i), Mt(i, e);
|
|
1399
|
+
let a = new ht(e), o = null, s = "";
|
|
1400
|
+
return a.subscribe((t) => {
|
|
1401
|
+
t.primaryColor && t.primaryColor !== o && (o = t.primaryColor, kt(i, t.primaryColor, e.color));
|
|
1402
|
+
let n = `${t.inkColor}|${t.accentColor}`;
|
|
1403
|
+
(t.inkColor || t.accentColor) && n !== s && (s = n, At(i, {
|
|
1404
|
+
inkColor: Q(t.inkColor) ? t.inkColor : e.inkColor,
|
|
1405
|
+
accentColor: Q(t.accentColor) ? t.accentColor : e.accentColor
|
|
1406
|
+
}));
|
|
1407
|
+
}), ue(/* @__PURE__ */ U(Qe, { controller: a }), i), a.init(), document.body.appendChild(t), { unmount() {
|
|
1408
|
+
ue(null, i), t.remove();
|
|
1289
1409
|
} };
|
|
1290
1410
|
}
|
|
1291
1411
|
//#endregion
|
|
1292
1412
|
//#region src/index.ts
|
|
1293
|
-
function
|
|
1294
|
-
return e(t),
|
|
1413
|
+
function Pt(t) {
|
|
1414
|
+
return e(t), Nt(t);
|
|
1295
1415
|
}
|
|
1296
1416
|
//#endregion
|
|
1297
|
-
export {
|
|
1417
|
+
export { Pt as init, $ as resolveTheme };
|