@aiden-voice/widget 0.5.0 → 0.5.2
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 +58 -17
- package/dist/components/MessageFeedback.d.ts +2 -1
- package/dist/components/MessageList.d.ts +8 -3
- package/dist/config.d.ts +1 -0
- package/dist/controller.d.ts +7 -1
- package/dist/markdown/plainText.d.ts +1 -0
- package/dist/markdown/render.d.ts +1 -1
- package/dist/sessionToken.d.ts +1 -0
- package/dist/theme.d.ts +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +8 -4
- package/dist/widget.js +456 -344
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -45,59 +45,59 @@ function T(e, t, n, r, i) {
|
|
|
45
45
|
function E(e) {
|
|
46
46
|
return e.children;
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function te(e, t) {
|
|
49
49
|
this.props = e, this.context = t;
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
if (t == null) return e.__ ?
|
|
51
|
+
function D(e, t) {
|
|
52
|
+
if (t == null) return e.__ ? D(e.__, e.__i + 1) : null;
|
|
53
53
|
for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
|
|
54
|
-
return typeof e.type == "function" ?
|
|
54
|
+
return typeof e.type == "function" ? D(e) : null;
|
|
55
55
|
}
|
|
56
|
-
function
|
|
56
|
+
function O(e) {
|
|
57
57
|
if (e.__P && e.__d) {
|
|
58
58
|
var t = e.__v, n = t.__e, r = [], i = [], a = C({}, t);
|
|
59
|
-
a.__v = t.__v + 1, o.vnode && o.vnode(a), se(e.__P, a, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ??
|
|
59
|
+
a.__v = t.__v + 1, o.vnode && o.vnode(a), se(e.__P, a, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? D(t), !!(32 & t.__u), i), a.__v = t.__v, a.__.__k[a.__i] = a, le(r, a, i), t.__e = t.__ = null, a.__e != n && k(a);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
function
|
|
62
|
+
function k(e) {
|
|
63
63
|
if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) {
|
|
64
64
|
if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e;
|
|
65
|
-
}),
|
|
65
|
+
}), k(e);
|
|
66
66
|
}
|
|
67
|
-
function
|
|
68
|
-
(!e.__d && (e.__d = !0) && c.push(e) && !
|
|
67
|
+
function A(e) {
|
|
68
|
+
(!e.__d && (e.__d = !0) && c.push(e) && !j.__r++ || l != o.debounceRendering) && ((l = o.debounceRendering) || u)(j);
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function j() {
|
|
71
71
|
try {
|
|
72
|
-
for (var e, t = 1; c.length;) c.length > t && c.sort(d), e = c.shift(), t = c.length,
|
|
72
|
+
for (var e, t = 1; c.length;) c.length > t && c.sort(d), e = c.shift(), t = c.length, O(e);
|
|
73
73
|
} finally {
|
|
74
|
-
c.length =
|
|
74
|
+
c.length = j.__r = 0;
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function ne(e, t, n, r, i, a, o, s, c, l, u) {
|
|
78
78
|
var d, f, p, m, h, g, _ = r && r.__k || b, v = t.length;
|
|
79
|
-
for (c =
|
|
79
|
+
for (c = M(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || y, p.__i = d, g = se(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && fe(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = re(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
|
|
80
80
|
return n.__e = h, c;
|
|
81
81
|
}
|
|
82
|
-
function
|
|
82
|
+
function M(e, t, n, r, i) {
|
|
83
83
|
var a, o, s, c, l, u = n.length, d = u, f = 0;
|
|
84
|
-
for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = T(null, o, null, null, null) : S(o) ? o = e.__k[a] = T(E, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = T(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i =
|
|
85
|
-
if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r =
|
|
84
|
+
for (e.__k = Array(i), a = 0; a < i; a++) (o = t[a]) != null && typeof o != "boolean" && typeof o != "function" ? (typeof o == "string" || typeof o == "number" || typeof o == "bigint" || o.constructor == String ? o = e.__k[a] = T(null, o, null, null, null) : S(o) ? o = e.__k[a] = T(E, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = T(o.type, o.props, o.key, o.ref ? o.ref : null, o.__v) : e.__k[a] = o, c = a + f, o.__ = e, o.__b = e.__b + 1, s = null, (l = o.__i = ie(o, n, c, d)) != -1 && (d--, (s = n[l]) && (s.__u |= 2)), s == null || s.__v == null ? (l == -1 && (i > u ? f-- : i < u && f++), typeof o.type != "function" && (o.__u |= 4)) : l != c && (l == c - 1 ? f-- : l == c + 1 ? f++ : (l > c ? f-- : f++, o.__u |= 4))) : e.__k[a] = null;
|
|
85
|
+
if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = D(s)), pe(s, s));
|
|
86
86
|
return r;
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function re(e, t, n) {
|
|
89
89
|
var r, i;
|
|
90
90
|
if (typeof e.type == "function") {
|
|
91
|
-
for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t =
|
|
91
|
+
for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t = re(r[i], t, n));
|
|
92
92
|
return t;
|
|
93
93
|
}
|
|
94
|
-
e.__e != t && (t && e.type && !t.parentNode && (t =
|
|
94
|
+
e.__e != t && (t && e.type && !t.parentNode && (t = D(e)), t = n.insertBefore(e.__e, t || null));
|
|
95
95
|
do
|
|
96
96
|
t &&= t.nextSibling;
|
|
97
97
|
while (t != null && t.nodeType == 8);
|
|
98
98
|
return t;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function ie(e, t, n, r) {
|
|
101
101
|
var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && !(2 & l.__u);
|
|
102
102
|
if (l === null && s == null || u && s == l.key && c == l.type) return n;
|
|
103
103
|
if (r > +!!u) {
|
|
@@ -105,16 +105,16 @@ function re(e, t, n, r) {
|
|
|
105
105
|
}
|
|
106
106
|
return -1;
|
|
107
107
|
}
|
|
108
|
-
function
|
|
108
|
+
function ae(e, t, n) {
|
|
109
109
|
t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || x.test(t) ? n : n + "px";
|
|
110
110
|
}
|
|
111
|
-
function
|
|
111
|
+
function N(e, t, n, r, i) {
|
|
112
112
|
var a, o;
|
|
113
113
|
n: if (t == "style") {
|
|
114
114
|
if (typeof n == "string") e.style.cssText = n;
|
|
115
115
|
else {
|
|
116
|
-
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n ||
|
|
117
|
-
if (n) for (t in n) r && n[t] == r[t] ||
|
|
116
|
+
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || ae(e.style, t, "");
|
|
117
|
+
if (n) for (t in n) r && n[t] == r[t] || ae(e.style, t, n[t]);
|
|
118
118
|
}
|
|
119
119
|
} else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(h, "$1")), o = t.toLowerCase(), t = o in e || t == "onFocusOut" || t == "onFocusIn" ? o.slice(2) : t.slice(2), e.l ||= {}, e.l[t + a] = n, n ? r ? n[m] = r[m] : (n[m] = g, e.addEventListener(t, a ? v : _, a)) : e.removeEventListener(t, a ? v : _, a);
|
|
120
120
|
else {
|
|
@@ -137,35 +137,35 @@ function oe(e) {
|
|
|
137
137
|
};
|
|
138
138
|
}
|
|
139
139
|
function se(e, t, n, r, i, a, s, c, l, u) {
|
|
140
|
-
var d, f, p, m, h, g, _, v, y, x, w, T, k, A, j, M
|
|
140
|
+
var d, f, p, m, h, g, _, v, y, x, w, T, O, k, A, j, M = t.type;
|
|
141
141
|
if (t.constructor !== void 0) return null;
|
|
142
142
|
128 & n.__u && (l = !!(32 & n.__u), a = [c = t.__e = n.__e]), (d = o.__b) && d(t);
|
|
143
|
-
n: if (typeof
|
|
143
|
+
n: if (typeof M == "function") {
|
|
144
144
|
f = s.length;
|
|
145
145
|
try {
|
|
146
|
-
if (y = t.props, x =
|
|
146
|
+
if (y = t.props, x = M.prototype && M.prototype.render, w = (d = M.contextType) && r[d.__c], T = d ? w ? w.props.value : d.__ : r, n.__c ? v = (p = t.__c = n.__c).__ = p.__E : (x ? t.__c = p = new M(y, T) : (t.__c = p = new te(y, T), p.constructor = M, p.render = me), w && w.sub(p), p.state || (p.state = {}), p.__n = r, m = p.__d = !0, p.__h = [], p._sb = []), x && p.__s == null && (p.__s = p.state), x && M.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = C({}, p.__s)), C(p.__s, M.getDerivedStateFromProps(y, p.__s))), h = p.props, g = p.state, p.__v = t, m) x && M.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), x && p.componentDidMount != null && p.__h.push(p.componentDidMount);
|
|
147
147
|
else {
|
|
148
|
-
if (x &&
|
|
148
|
+
if (x && M.getDerivedStateFromProps == null && y !== h && p.componentWillReceiveProps != null && p.componentWillReceiveProps(y, T), t.__v == n.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(y, p.__s, T)) {
|
|
149
149
|
t.__v != n.__v && (p.props = y, p.state = p.__s, p.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
|
|
150
150
|
e && (e.__ = t);
|
|
151
|
-
}), b.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && s.push(p), c =
|
|
151
|
+
}), b.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && s.push(p), c = D(n);
|
|
152
152
|
break n;
|
|
153
153
|
}
|
|
154
154
|
p.componentWillUpdate != null && p.componentWillUpdate(y, p.__s, T), x && p.componentDidUpdate != null && p.__h.push(function() {
|
|
155
155
|
p.componentDidUpdate(h, g, _);
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
-
if (p.context = T, p.props = y, p.__P = e, p.__e = !1,
|
|
158
|
+
if (p.context = T, p.props = y, p.__P = e, p.__e = !1, O = o.__r, k = 0, x) p.state = p.__s, p.__d = !1, O && O(t), d = p.render(p.props, p.state, p.context), b.push.apply(p.__h, p._sb), p._sb = [];
|
|
159
159
|
else do
|
|
160
|
-
p.__d = !1,
|
|
161
|
-
while (p.__d && ++
|
|
162
|
-
p.state = p.__s, p.getChildContext != null && (r = C(C({}, r), p.getChildContext())), x && !m && p.getSnapshotBeforeUpdate != null && (_ = p.getSnapshotBeforeUpdate(h, g)),
|
|
160
|
+
p.__d = !1, O && O(t), d = p.render(p.props, p.state, p.context), p.state = p.__s;
|
|
161
|
+
while (p.__d && ++k < 25);
|
|
162
|
+
p.state = p.__s, p.getChildContext != null && (r = C(C({}, r), p.getChildContext())), x && !m && p.getSnapshotBeforeUpdate != null && (_ = p.getSnapshotBeforeUpdate(h, g)), A = d != null && d.type === E && d.key == null ? ue(d.props.children) : d, c = ne(e, S(A) ? A : [A], t, n, r, i, a, s, c, l, u), p.base = t.__e, t.__u &= -161, p.__h.length && s.push(p), v && (p.__E = p.__ = null);
|
|
163
163
|
} catch (e) {
|
|
164
164
|
if (s.length = f, t.__v = null, l || a != null) {
|
|
165
165
|
if (e.then) {
|
|
166
166
|
for (t.__u |= l ? 160 : 128; c && c.nodeType == 8 && c.nextSibling;) c = c.nextSibling;
|
|
167
167
|
a != null && (a[a.indexOf(c)] = null), t.__e = c;
|
|
168
|
-
} else if (a != null) for (
|
|
168
|
+
} else if (a != null) for (j = a.length; j--;) ee(a[j]);
|
|
169
169
|
} else t.__e = n.__e;
|
|
170
170
|
t.__k ??= n.__k || [], e.then || ce(t), o.__e(e, t, n);
|
|
171
171
|
}
|
|
@@ -205,11 +205,11 @@ function de(e, t, n, r, i, s, c, l, u) {
|
|
|
205
205
|
if (x == null) v === b || l && e.data == b || (e.data = b);
|
|
206
206
|
else {
|
|
207
207
|
if (s = x == "textarea" && b.defaultValue != null ? null : s && a.call(e.childNodes), !l && s != null) for (v = {}, d = 0; d < e.attributes.length; d++) v[(h = e.attributes[d]).name] = h.value;
|
|
208
|
-
for (d in v) h = v[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in b || d == "value" && "defaultValue" in b || d == "checked" && "defaultChecked" in b ||
|
|
209
|
-
for (d in b) h = b[d], d == "children" ? m = h : d == "dangerouslySetInnerHTML" ? f = h : d == "value" ? g = h : d == "checked" ? _ = h : l && typeof h != "function" || v[d] === h ||
|
|
208
|
+
for (d in v) h = v[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in b || d == "value" && "defaultValue" in b || d == "checked" && "defaultChecked" in b || N(e, d, null, h, i);
|
|
209
|
+
for (d in b) h = b[d], d == "children" ? m = h : d == "dangerouslySetInnerHTML" ? f = h : d == "value" ? g = h : d == "checked" ? _ = h : l && typeof h != "function" || v[d] === h || N(e, d, h, v[d], i);
|
|
210
210
|
if (f) l || p && (f.__html == p.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), t.__k = [];
|
|
211
|
-
else if (p && (e.innerHTML = ""),
|
|
212
|
-
l && x != "textarea" || (d = "value", x == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[d] || x == "progress" && !g || x == "option" && g != v[d]) &&
|
|
211
|
+
else if (p && (e.innerHTML = ""), ne(t.type == "template" ? e.content : e, S(m) ? m : [m], t, n, r, x == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, c, s ? s[0] : n.__k && D(n, 0), l, u), s != null) for (d = s.length; d--;) ee(s[d]);
|
|
212
|
+
l && x != "textarea" || (d = "value", x == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[d] || x == "progress" && !g || x == "option" && g != v[d]) && N(e, d, g, v[d], i), d = "checked", _ != null && _ != e[d] && N(e, d, _, v[d], i));
|
|
213
213
|
}
|
|
214
214
|
return e;
|
|
215
215
|
}
|
|
@@ -250,14 +250,14 @@ a = b.slice, o = { __e: function(e, t, n, r) {
|
|
|
250
250
|
e = t;
|
|
251
251
|
}
|
|
252
252
|
throw e;
|
|
253
|
-
} }, s = 0,
|
|
253
|
+
} }, s = 0, te.prototype.setState = function(e, t) {
|
|
254
254
|
var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = C({}, this.state);
|
|
255
|
-
typeof e == "function" && (e = e(C({}, n), this.props)), e && C(n, e), e != null && this.__v && (t && this._sb.push(t),
|
|
256
|
-
},
|
|
257
|
-
this.__v && (this.__e = !0, e && this.__h.push(e),
|
|
258
|
-
},
|
|
255
|
+
typeof e == "function" && (e = e(C({}, n), this.props)), e && C(n, e), e != null && this.__v && (t && this._sb.push(t), A(this));
|
|
256
|
+
}, te.prototype.forceUpdate = function(e) {
|
|
257
|
+
this.__v && (this.__e = !0, e && this.__h.push(e), A(this));
|
|
258
|
+
}, te.prototype.render = E, c = [], u = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, d = function(e, t) {
|
|
259
259
|
return e.__v.__b - t.__v.__b;
|
|
260
|
-
},
|
|
260
|
+
}, j.__r = 0, f = Math.random().toString(8), p = "__d" + f, m = "__a" + f, h = /(PointerCapture)$|Capture$/i, g = 0, _ = oe(!1), v = oe(!0);
|
|
261
261
|
//#endregion
|
|
262
262
|
//#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/hooks/dist/hooks.module.js
|
|
263
263
|
var P, F, ge, _e, I = 0, ve = [], L = o, ye = L.__b, be = L.__r, xe = L.diffed, Se = L.__c, Ce = L.unmount, we = L.__;
|
|
@@ -269,12 +269,12 @@ function Te(e, t) {
|
|
|
269
269
|
});
|
|
270
270
|
return e >= n.__.length && n.__.push({}), n.__[e];
|
|
271
271
|
}
|
|
272
|
-
function
|
|
273
|
-
return I = 1,
|
|
272
|
+
function Ee(e) {
|
|
273
|
+
return I = 1, De(Pe, e);
|
|
274
274
|
}
|
|
275
|
-
function
|
|
275
|
+
function De(e, t, n) {
|
|
276
276
|
var r = Te(P++, 2);
|
|
277
|
-
if (r.t = e, !r.__c && (r.__ = [n ? n(t) :
|
|
277
|
+
if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Pe(void 0, t), function(e) {
|
|
278
278
|
var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
|
|
279
279
|
t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
|
|
280
280
|
}], r.__c = F, !F.__f)) {
|
|
@@ -305,24 +305,24 @@ function Ee(e, t, n) {
|
|
|
305
305
|
}
|
|
306
306
|
return r.__N || r.__;
|
|
307
307
|
}
|
|
308
|
-
function
|
|
308
|
+
function R(e, t) {
|
|
309
309
|
var n = Te(P++, 3);
|
|
310
|
-
!L.__s &&
|
|
310
|
+
!L.__s && Ne(n.__H, t) && (n.__ = e, n.u = t, F.__H.__h.push(n));
|
|
311
311
|
}
|
|
312
|
-
function
|
|
313
|
-
return I = 5,
|
|
312
|
+
function z(e) {
|
|
313
|
+
return I = 5, Oe(function() {
|
|
314
314
|
return { current: e };
|
|
315
315
|
}, []);
|
|
316
316
|
}
|
|
317
|
-
function
|
|
317
|
+
function Oe(e, t) {
|
|
318
318
|
var n = Te(P++, 7);
|
|
319
|
-
return
|
|
319
|
+
return Ne(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
|
|
320
320
|
}
|
|
321
|
-
function
|
|
321
|
+
function ke() {
|
|
322
322
|
for (var e; e = ve.shift();) {
|
|
323
323
|
var t = e.__H;
|
|
324
324
|
if (e.__P && t) try {
|
|
325
|
-
t.__h.some(
|
|
325
|
+
t.__h.some(B), t.__h.some(Me), t.__h = [];
|
|
326
326
|
} catch (n) {
|
|
327
327
|
t.__h = [], L.__e(n, e.__v);
|
|
328
328
|
}
|
|
@@ -337,18 +337,18 @@ L.__b = function(e) {
|
|
|
337
337
|
var t = (F = e.__c).__H;
|
|
338
338
|
t && (ge === F ? (t.__h = [], F.__h = [], t.__.some(function(e) {
|
|
339
339
|
e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
|
|
340
|
-
})) : (t.__h.some(
|
|
340
|
+
})) : (t.__h.some(B), t.__h.some(Me), t.__h = [], P = 0)), ge = F;
|
|
341
341
|
}, L.diffed = function(e) {
|
|
342
342
|
xe && xe(e);
|
|
343
343
|
var t = e.__c;
|
|
344
|
-
t && t.__H && (t.__H.__h.length && (ve.push(t) !== 1 && _e === L.requestAnimationFrame || ((_e = L.requestAnimationFrame) ||
|
|
344
|
+
t && t.__H && (t.__H.__h.length && (ve.push(t) !== 1 && _e === L.requestAnimationFrame || ((_e = L.requestAnimationFrame) || je)(ke)), t.__H.__.some(function(e) {
|
|
345
345
|
e.u &&= (e.__H = e.u, void 0);
|
|
346
346
|
})), ge = F = null;
|
|
347
347
|
}, L.__c = function(e, t) {
|
|
348
348
|
t.some(function(e) {
|
|
349
349
|
try {
|
|
350
|
-
e.__h.some(
|
|
351
|
-
return !e.__ ||
|
|
350
|
+
e.__h.some(B), e.__h = e.__h.filter(function(e) {
|
|
351
|
+
return !e.__ || Me(e);
|
|
352
352
|
});
|
|
353
353
|
} catch (n) {
|
|
354
354
|
t.some(function(e) {
|
|
@@ -361,40 +361,40 @@ L.__b = function(e) {
|
|
|
361
361
|
var t, n = e.__c;
|
|
362
362
|
n && n.__H && (n.__H.__.some(function(e) {
|
|
363
363
|
try {
|
|
364
|
-
|
|
364
|
+
B(e);
|
|
365
365
|
} catch (e) {
|
|
366
366
|
t = e;
|
|
367
367
|
}
|
|
368
368
|
}), n.__H = void 0, t && L.__e(t, n.__v));
|
|
369
369
|
};
|
|
370
|
-
var
|
|
371
|
-
function
|
|
370
|
+
var Ae = typeof requestAnimationFrame == "function";
|
|
371
|
+
function je(e) {
|
|
372
372
|
var t, n = function() {
|
|
373
|
-
clearTimeout(r),
|
|
373
|
+
clearTimeout(r), Ae && cancelAnimationFrame(t), setTimeout(e);
|
|
374
374
|
}, r = setTimeout(n, 35);
|
|
375
|
-
|
|
375
|
+
Ae && (t = requestAnimationFrame(n));
|
|
376
376
|
}
|
|
377
|
-
function
|
|
377
|
+
function B(e) {
|
|
378
378
|
var t = F, n = e.__c;
|
|
379
379
|
typeof n == "function" && (e.__c = void 0, n()), F = t;
|
|
380
380
|
}
|
|
381
|
-
function
|
|
381
|
+
function Me(e) {
|
|
382
382
|
var t = F;
|
|
383
383
|
e.__c = e.__(), F = t;
|
|
384
384
|
}
|
|
385
|
-
function
|
|
385
|
+
function Ne(e, t) {
|
|
386
386
|
return !e || e.length !== t.length || t.some(function(t, n) {
|
|
387
387
|
return t !== e[n];
|
|
388
388
|
});
|
|
389
389
|
}
|
|
390
|
-
function
|
|
390
|
+
function Pe(e, t) {
|
|
391
391
|
return typeof t == "function" ? t(e) : t;
|
|
392
392
|
}
|
|
393
393
|
//#endregion
|
|
394
394
|
//#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
|
|
395
|
-
var
|
|
395
|
+
var Fe = 0;
|
|
396
396
|
Array.isArray;
|
|
397
|
-
function
|
|
397
|
+
function V(e, t, n, r, i, a) {
|
|
398
398
|
t ||= {};
|
|
399
399
|
var s, c, l = t;
|
|
400
400
|
if ("ref" in l) for (c in l = {}, t) c == "ref" ? s = t[c] : l[c] = t[c];
|
|
@@ -409,7 +409,7 @@ function H(e, t, n, r, i, a) {
|
|
|
409
409
|
__e: null,
|
|
410
410
|
__c: null,
|
|
411
411
|
constructor: void 0,
|
|
412
|
-
__v: --
|
|
412
|
+
__v: --Fe,
|
|
413
413
|
__i: -1,
|
|
414
414
|
__u: 0,
|
|
415
415
|
__source: i,
|
|
@@ -420,8 +420,8 @@ function H(e, t, n, r, i, a) {
|
|
|
420
420
|
}
|
|
421
421
|
//#endregion
|
|
422
422
|
//#region src/components/icons.tsx
|
|
423
|
-
function
|
|
424
|
-
return /* @__PURE__ */
|
|
423
|
+
function H({ name: e, size: t, children: n }) {
|
|
424
|
+
return /* @__PURE__ */ V("svg", {
|
|
425
425
|
"data-icon": e,
|
|
426
426
|
"aria-hidden": "true",
|
|
427
427
|
focusable: "false",
|
|
@@ -436,59 +436,59 @@ function U({ name: e, size: t, children: n }) {
|
|
|
436
436
|
children: n
|
|
437
437
|
});
|
|
438
438
|
}
|
|
439
|
-
function
|
|
440
|
-
return /* @__PURE__ */ H
|
|
439
|
+
function Ie({ size: e = 26 }) {
|
|
440
|
+
return /* @__PURE__ */ V(H, {
|
|
441
441
|
name: "chat",
|
|
442
442
|
size: e,
|
|
443
|
-
children: [/* @__PURE__ */
|
|
443
|
+
children: [/* @__PURE__ */ V("path", { d: "M4 5.5A2.5 2.5 0 0 1 6.5 3h11A2.5 2.5 0 0 1 20 5.5v8a2.5 2.5 0 0 1-2.5 2.5H10l-4.5 4v-4h0A1.5 1.5 0 0 1 4 14.5z" }), /* @__PURE__ */ V("path", {
|
|
444
444
|
d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
|
|
445
445
|
"stroke-width": "2.5"
|
|
446
446
|
})]
|
|
447
447
|
});
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
return /* @__PURE__ */ H
|
|
449
|
+
function Le({ size: e = 26 }) {
|
|
450
|
+
return /* @__PURE__ */ V(H, {
|
|
451
451
|
name: "chevron-down",
|
|
452
452
|
size: e,
|
|
453
|
-
children: /* @__PURE__ */
|
|
453
|
+
children: /* @__PURE__ */ V("path", { d: "M6 9l6 6 6-6" })
|
|
454
454
|
});
|
|
455
455
|
}
|
|
456
|
-
function
|
|
457
|
-
return /* @__PURE__ */ H
|
|
456
|
+
function Re({ size: e = 18 }) {
|
|
457
|
+
return /* @__PURE__ */ V(H, {
|
|
458
458
|
name: "close",
|
|
459
459
|
size: e,
|
|
460
|
-
children: /* @__PURE__ */
|
|
460
|
+
children: /* @__PURE__ */ V("path", { d: "M6 6l12 12M18 6L6 18" })
|
|
461
461
|
});
|
|
462
462
|
}
|
|
463
|
-
var
|
|
464
|
-
function
|
|
465
|
-
return /* @__PURE__ */ H
|
|
463
|
+
var ze = "M7 11v9M7 11l3.5-7.2A1.8 1.8 0 0 1 14 4.6V9h4.6a2 2 0 0 1 2 2.3l-1.2 7A2 2 0 0 1 17.4 20H7M7 11H4.5A1.5 1.5 0 0 0 3 12.5v6A1.5 1.5 0 0 0 4.5 20H7";
|
|
464
|
+
function Be({ size: e = 16 }) {
|
|
465
|
+
return /* @__PURE__ */ V(H, {
|
|
466
466
|
name: "thumb-up",
|
|
467
467
|
size: e,
|
|
468
|
-
children: /* @__PURE__ */
|
|
468
|
+
children: /* @__PURE__ */ V("path", { d: ze })
|
|
469
469
|
});
|
|
470
470
|
}
|
|
471
|
-
function
|
|
472
|
-
return /* @__PURE__ */ H
|
|
471
|
+
function Ve({ size: e = 16 }) {
|
|
472
|
+
return /* @__PURE__ */ V(H, {
|
|
473
473
|
name: "thumb-down",
|
|
474
474
|
size: e,
|
|
475
|
-
children: /* @__PURE__ */
|
|
476
|
-
d:
|
|
475
|
+
children: /* @__PURE__ */ V("path", {
|
|
476
|
+
d: ze,
|
|
477
477
|
transform: "matrix(1 0 0 -1 0 24)"
|
|
478
478
|
})
|
|
479
479
|
});
|
|
480
480
|
}
|
|
481
481
|
//#endregion
|
|
482
482
|
//#region src/components/Launcher.tsx
|
|
483
|
-
function
|
|
484
|
-
let [i, a] =
|
|
485
|
-
return /* @__PURE__ */
|
|
483
|
+
function He({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
|
|
484
|
+
let [i, a] = Ee("loading"), o = n !== void 0 && i !== "failed", s = o && !e && i === "loaded";
|
|
485
|
+
return /* @__PURE__ */ V("button", {
|
|
486
486
|
type: "button",
|
|
487
487
|
class: "whoo-widget-launcher",
|
|
488
488
|
onClick: t,
|
|
489
489
|
"aria-label": e ? "Close chat" : "Open chat",
|
|
490
490
|
ref: r,
|
|
491
|
-
children: [e ? /* @__PURE__ */
|
|
491
|
+
children: [e ? /* @__PURE__ */ V(Le, {}) : s ? null : /* @__PURE__ */ V(Ie, {}), o ? /* @__PURE__ */ V("img", {
|
|
492
492
|
class: "whoo-widget-launcher-icon-image",
|
|
493
493
|
src: n,
|
|
494
494
|
alt: "",
|
|
@@ -501,16 +501,16 @@ function Ve({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
|
|
|
501
501
|
}
|
|
502
502
|
//#endregion
|
|
503
503
|
//#region src/components/Composer.tsx
|
|
504
|
-
function
|
|
505
|
-
return /* @__PURE__ */
|
|
504
|
+
function Ue({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
505
|
+
return /* @__PURE__ */ V("div", {
|
|
506
506
|
class: "whoo-widget-composer",
|
|
507
507
|
children: [
|
|
508
|
-
/* @__PURE__ */
|
|
508
|
+
/* @__PURE__ */ V("label", {
|
|
509
509
|
class: "whoo-widget-sr-only",
|
|
510
510
|
for: "whoo-widget-composer-input",
|
|
511
511
|
children: "Message"
|
|
512
512
|
}),
|
|
513
|
-
/* @__PURE__ */
|
|
513
|
+
/* @__PURE__ */ V("input", {
|
|
514
514
|
id: "whoo-widget-composer-input",
|
|
515
515
|
class: "whoo-widget-composer-input",
|
|
516
516
|
value: e,
|
|
@@ -522,11 +522,13 @@ function He({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
|
522
522
|
e.key === "Enter" && n();
|
|
523
523
|
}
|
|
524
524
|
}),
|
|
525
|
-
/* @__PURE__ */
|
|
525
|
+
/* @__PURE__ */ V("button", {
|
|
526
526
|
type: "button",
|
|
527
527
|
class: "whoo-widget-composer-send",
|
|
528
|
-
|
|
529
|
-
|
|
528
|
+
"aria-disabled": r,
|
|
529
|
+
onClick: () => {
|
|
530
|
+
r || n();
|
|
531
|
+
},
|
|
530
532
|
children: "Send"
|
|
531
533
|
})
|
|
532
534
|
]
|
|
@@ -534,8 +536,8 @@ function He({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
|
534
536
|
}
|
|
535
537
|
//#endregion
|
|
536
538
|
//#region src/components/ErrorBanner.tsx
|
|
537
|
-
function
|
|
538
|
-
return /* @__PURE__ */
|
|
539
|
+
function We({ message: e }) {
|
|
540
|
+
return /* @__PURE__ */ V("div", {
|
|
539
541
|
class: "whoo-widget-error-banner",
|
|
540
542
|
role: "alert",
|
|
541
543
|
children: e
|
|
@@ -543,8 +545,8 @@ function Ue({ message: e }) {
|
|
|
543
545
|
}
|
|
544
546
|
//#endregion
|
|
545
547
|
//#region src/markdown/tokenizer.ts
|
|
546
|
-
var
|
|
547
|
-
function
|
|
548
|
+
var U = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, W = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, G = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, K = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, q = /[ \t]*[*+-][ \t]+/y, Ge = /https?:\/\/\S+/y, Ke = /[.,;:!?)\]}>]+$/;
|
|
549
|
+
function J(e) {
|
|
548
550
|
let t = [], n = 0, r = 0, i = (n) => {
|
|
549
551
|
n > r && t.push({
|
|
550
552
|
type: "text",
|
|
@@ -554,13 +556,13 @@ function Ke(e) {
|
|
|
554
556
|
});
|
|
555
557
|
};
|
|
556
558
|
for (; n < e.length;) {
|
|
557
|
-
if ((n === 0 || e[n - 1] === "\n") && (
|
|
559
|
+
if ((n === 0 || e[n - 1] === "\n") && (q.lastIndex = n, q.exec(e))) {
|
|
558
560
|
i(n), t.push({
|
|
559
561
|
type: "text",
|
|
560
562
|
value: "• ",
|
|
561
563
|
start: n,
|
|
562
|
-
end:
|
|
563
|
-
}), n =
|
|
564
|
+
end: q.lastIndex
|
|
565
|
+
}), n = q.lastIndex, r = n;
|
|
564
566
|
continue;
|
|
565
567
|
}
|
|
566
568
|
if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
|
|
@@ -573,56 +575,56 @@ function Ke(e) {
|
|
|
573
575
|
}
|
|
574
576
|
}
|
|
575
577
|
if (e[n - 1] !== "!") {
|
|
576
|
-
|
|
577
|
-
let a =
|
|
578
|
+
U.lastIndex = n;
|
|
579
|
+
let a = U.exec(e);
|
|
578
580
|
if (a) {
|
|
579
581
|
i(n), t.push({
|
|
580
582
|
type: "link",
|
|
581
583
|
text: a[1],
|
|
582
584
|
url: a[2],
|
|
583
585
|
start: n,
|
|
584
|
-
end:
|
|
585
|
-
}), n =
|
|
586
|
+
end: U.lastIndex
|
|
587
|
+
}), n = U.lastIndex, r = n;
|
|
586
588
|
continue;
|
|
587
589
|
}
|
|
588
590
|
}
|
|
589
|
-
|
|
590
|
-
let a =
|
|
591
|
+
W.lastIndex = n;
|
|
592
|
+
let a = W.exec(e);
|
|
591
593
|
if (a) {
|
|
592
594
|
i(n), t.push({
|
|
593
595
|
type: "bold",
|
|
594
596
|
value: a[1],
|
|
595
597
|
start: n,
|
|
596
|
-
end:
|
|
597
|
-
}), n =
|
|
598
|
+
end: W.lastIndex
|
|
599
|
+
}), n = W.lastIndex, r = n;
|
|
598
600
|
continue;
|
|
599
601
|
}
|
|
600
|
-
|
|
601
|
-
let o =
|
|
602
|
+
G.lastIndex = n;
|
|
603
|
+
let o = G.exec(e);
|
|
602
604
|
if (o) {
|
|
603
605
|
i(n), t.push({
|
|
604
606
|
type: "italic",
|
|
605
607
|
value: o[1],
|
|
606
608
|
start: n,
|
|
607
|
-
end:
|
|
608
|
-
}), n =
|
|
609
|
+
end: G.lastIndex
|
|
610
|
+
}), n = G.lastIndex, r = n;
|
|
609
611
|
continue;
|
|
610
612
|
}
|
|
611
|
-
|
|
612
|
-
let s =
|
|
613
|
+
K.lastIndex = n;
|
|
614
|
+
let s = K.exec(e);
|
|
613
615
|
if (s) {
|
|
614
616
|
i(n), t.push({
|
|
615
617
|
type: "italic",
|
|
616
618
|
value: s[1],
|
|
617
619
|
start: n,
|
|
618
|
-
end:
|
|
619
|
-
}), n =
|
|
620
|
+
end: K.lastIndex
|
|
621
|
+
}), n = K.lastIndex, r = n;
|
|
620
622
|
continue;
|
|
621
623
|
}
|
|
622
|
-
|
|
623
|
-
let c =
|
|
624
|
+
Ge.lastIndex = n;
|
|
625
|
+
let c = Ge.exec(e);
|
|
624
626
|
if (c) {
|
|
625
|
-
let e = c[0].match(
|
|
627
|
+
let e = c[0].match(Ke), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
|
|
626
628
|
if (a.length > 0) {
|
|
627
629
|
i(n), t.push({
|
|
628
630
|
type: "link",
|
|
@@ -640,16 +642,42 @@ function Ke(e) {
|
|
|
640
642
|
}
|
|
641
643
|
//#endregion
|
|
642
644
|
//#region src/markdown/render.tsx
|
|
643
|
-
|
|
644
|
-
|
|
645
|
+
var qe = /^[ \t]*[*+-][ \t]+(.*)$/;
|
|
646
|
+
function Je(e) {
|
|
647
|
+
let t = [], n = [], r = [], i = () => {
|
|
648
|
+
n.length > 0 && t.push({
|
|
649
|
+
type: "text",
|
|
650
|
+
text: n.join("\n")
|
|
651
|
+
}), n = [];
|
|
652
|
+
}, a = () => {
|
|
653
|
+
r.length > 0 && t.push({
|
|
654
|
+
type: "list",
|
|
655
|
+
items: r
|
|
656
|
+
}), r = [];
|
|
657
|
+
};
|
|
658
|
+
for (let t of e.split("\n")) {
|
|
659
|
+
let e = t.match(qe);
|
|
660
|
+
e ? (i(), r.push(e[1])) : (a(), n.push(t));
|
|
661
|
+
}
|
|
662
|
+
return i(), a(), t.some((e) => e.type === "list") ? t.flatMap((e, n) => {
|
|
663
|
+
if (e.type === "list") return [e];
|
|
664
|
+
let { text: r } = e;
|
|
665
|
+
return t[n - 1]?.type === "list" && (r = r.replace(/^(?:[ \t]*\n)+/, "")), t[n + 1]?.type === "list" && (r = r.replace(/(?:\n[ \t]*)+$/, "")), r.trim() === "" ? [] : [{
|
|
666
|
+
type: "text",
|
|
667
|
+
text: r
|
|
668
|
+
}];
|
|
669
|
+
}) : null;
|
|
670
|
+
}
|
|
671
|
+
function Y(e) {
|
|
672
|
+
return J(e).map((e, t) => {
|
|
645
673
|
switch (e.type) {
|
|
646
|
-
case "bold": return /* @__PURE__ */
|
|
647
|
-
case "italic": return /* @__PURE__ */
|
|
648
|
-
case "link": return /* @__PURE__ */
|
|
674
|
+
case "bold": return /* @__PURE__ */ V("strong", { children: Y(e.value) }, t);
|
|
675
|
+
case "italic": return /* @__PURE__ */ V("em", { children: Y(e.value) }, t);
|
|
676
|
+
case "link": return /* @__PURE__ */ V("a", {
|
|
649
677
|
href: e.url,
|
|
650
678
|
target: "_blank",
|
|
651
679
|
rel: "noopener noreferrer",
|
|
652
|
-
children: [e.text, /* @__PURE__ */
|
|
680
|
+
children: [e.text, /* @__PURE__ */ V("span", {
|
|
653
681
|
class: "whoo-widget-sr-only",
|
|
654
682
|
children: " (opens in new tab)"
|
|
655
683
|
})]
|
|
@@ -658,9 +686,16 @@ function qe(e) {
|
|
|
658
686
|
}
|
|
659
687
|
});
|
|
660
688
|
}
|
|
689
|
+
function Ye(e) {
|
|
690
|
+
let t = e.replace(/\r\n?/g, "\n"), n = Je(t);
|
|
691
|
+
return n ? n.map((e, t) => e.type === "list" ? /* @__PURE__ */ V("ul", {
|
|
692
|
+
class: "whoo-widget-list",
|
|
693
|
+
children: e.items.map((e, t) => /* @__PURE__ */ V("li", { children: Y(e) }, t))
|
|
694
|
+
}, t) : /* @__PURE__ */ V("span", { children: Y(e.text) }, t)) : Y(t);
|
|
695
|
+
}
|
|
661
696
|
//#endregion
|
|
662
697
|
//#region src/components/MessageFeedback.tsx
|
|
663
|
-
var
|
|
698
|
+
var Xe = [
|
|
664
699
|
{
|
|
665
700
|
value: "",
|
|
666
701
|
label: "Select a reason (optional)"
|
|
@@ -682,106 +717,101 @@ var Je = [
|
|
|
682
717
|
label: "Other"
|
|
683
718
|
}
|
|
684
719
|
];
|
|
685
|
-
function
|
|
686
|
-
let
|
|
687
|
-
if (
|
|
688
|
-
let n =
|
|
689
|
-
if (
|
|
720
|
+
function Ze({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onDraftChange: i, onSubmitDetailed: a, onCancel: o }) {
|
|
721
|
+
let s = e.correction ?? "", c = e.category ?? "", l = z(e.status);
|
|
722
|
+
if (R(() => {
|
|
723
|
+
let n = l.current;
|
|
724
|
+
if (l.current = e.status, n === e.status) return;
|
|
690
725
|
let r = t?.current;
|
|
691
726
|
if (!r) return;
|
|
692
727
|
let i = r.getRootNode();
|
|
693
728
|
r.contains(i.activeElement) || r.focus();
|
|
694
|
-
}, [e.status, t]), e.status === "
|
|
695
|
-
class: "whoo-widget-feedback-submitted",
|
|
696
|
-
role: "status",
|
|
697
|
-
children: "Thanks for the feedback"
|
|
698
|
-
});
|
|
699
|
-
if (e.status === "expanded") return /* @__PURE__ */ H("div", {
|
|
729
|
+
}, [e.status, t]), e.status === "expanded") return /* @__PURE__ */ V("div", {
|
|
700
730
|
class: "whoo-widget-feedback-form",
|
|
701
731
|
children: [
|
|
702
|
-
/* @__PURE__ */
|
|
732
|
+
/* @__PURE__ */ V("label", { children: [/* @__PURE__ */ V("span", {
|
|
703
733
|
class: "whoo-widget-sr-only",
|
|
704
734
|
children: "Additional feedback"
|
|
705
|
-
}), /* @__PURE__ */
|
|
735
|
+
}), /* @__PURE__ */ V("textarea", {
|
|
706
736
|
class: "whoo-widget-feedback-textarea",
|
|
707
|
-
value:
|
|
708
|
-
onInput: (e) =>
|
|
737
|
+
value: s,
|
|
738
|
+
onInput: (e) => i(e.target.value, c),
|
|
709
739
|
placeholder: "What was wrong? (optional)"
|
|
710
740
|
})] }),
|
|
711
|
-
/* @__PURE__ */
|
|
741
|
+
/* @__PURE__ */ V("select", {
|
|
712
742
|
class: "whoo-widget-feedback-select",
|
|
713
743
|
"aria-label": "Feedback category",
|
|
714
744
|
value: c,
|
|
715
|
-
onChange: (e) =>
|
|
716
|
-
children:
|
|
745
|
+
onChange: (e) => i(s, e.target.value),
|
|
746
|
+
children: Xe.map((e) => /* @__PURE__ */ V("option", {
|
|
717
747
|
value: e.value,
|
|
718
748
|
children: e.label
|
|
719
749
|
}, e.value))
|
|
720
750
|
}),
|
|
721
|
-
/* @__PURE__ */
|
|
751
|
+
/* @__PURE__ */ V("div", {
|
|
722
752
|
class: "whoo-widget-feedback-form-buttons",
|
|
723
|
-
children: [/* @__PURE__ */
|
|
753
|
+
children: [/* @__PURE__ */ V("button", {
|
|
724
754
|
type: "button",
|
|
725
755
|
class: "whoo-widget-feedback-submit",
|
|
726
|
-
onClick: () =>
|
|
756
|
+
onClick: () => a(s, c),
|
|
727
757
|
children: "Submit"
|
|
728
|
-
}), /* @__PURE__ */
|
|
758
|
+
}), /* @__PURE__ */ V("button", {
|
|
729
759
|
type: "button",
|
|
730
760
|
class: "whoo-widget-feedback-cancel",
|
|
731
|
-
onClick:
|
|
761
|
+
onClick: o,
|
|
732
762
|
children: "Cancel"
|
|
733
763
|
})]
|
|
734
764
|
})
|
|
735
765
|
]
|
|
736
766
|
});
|
|
737
|
-
let
|
|
738
|
-
return /* @__PURE__ */
|
|
767
|
+
let u = e.status === "submitting", d = e.status === "submitted";
|
|
768
|
+
return /* @__PURE__ */ V("div", {
|
|
739
769
|
class: "whoo-widget-feedback",
|
|
740
|
-
children: [/* @__PURE__ */
|
|
770
|
+
children: [d ? null : /* @__PURE__ */ V("div", {
|
|
741
771
|
class: "whoo-widget-feedback-buttons",
|
|
742
|
-
children: [/* @__PURE__ */
|
|
772
|
+
children: [/* @__PURE__ */ V("button", {
|
|
743
773
|
type: "button",
|
|
744
774
|
"aria-label": "Good response",
|
|
745
|
-
disabled:
|
|
775
|
+
disabled: u,
|
|
746
776
|
onClick: n,
|
|
747
|
-
children: /* @__PURE__ */
|
|
748
|
-
}), /* @__PURE__ */
|
|
777
|
+
children: /* @__PURE__ */ V(Be, {})
|
|
778
|
+
}), /* @__PURE__ */ V("button", {
|
|
749
779
|
type: "button",
|
|
750
780
|
"aria-label": "Bad response",
|
|
751
|
-
disabled:
|
|
781
|
+
disabled: u,
|
|
752
782
|
onClick: r,
|
|
753
|
-
children: /* @__PURE__ */
|
|
783
|
+
children: /* @__PURE__ */ V(Ve, {})
|
|
754
784
|
})]
|
|
755
|
-
}),
|
|
756
|
-
class: "whoo-widget-feedback-error",
|
|
785
|
+
}), /* @__PURE__ */ V("div", {
|
|
757
786
|
role: "status",
|
|
758
|
-
|
|
759
|
-
|
|
787
|
+
class: d ? "whoo-widget-feedback-submitted" : e.status === "error" ? "whoo-widget-feedback-error" : void 0,
|
|
788
|
+
children: d ? "Thanks for the feedback" : e.status === "error" ? "Couldn't send feedback" : null
|
|
789
|
+
})]
|
|
760
790
|
});
|
|
761
791
|
}
|
|
762
792
|
//#endregion
|
|
763
793
|
//#region src/components/MessageList.tsx
|
|
764
|
-
function
|
|
765
|
-
return /* @__PURE__ */
|
|
794
|
+
function Qe({ isSlowResponse: e }) {
|
|
795
|
+
return /* @__PURE__ */ V("div", {
|
|
766
796
|
class: "whoo-widget-pending",
|
|
767
797
|
role: "status",
|
|
768
|
-
children: [/* @__PURE__ */
|
|
798
|
+
children: [/* @__PURE__ */ V("span", {
|
|
769
799
|
class: "whoo-widget-typing",
|
|
770
800
|
"aria-hidden": "true",
|
|
771
801
|
children: [
|
|
772
|
-
/* @__PURE__ */
|
|
773
|
-
/* @__PURE__ */
|
|
774
|
-
/* @__PURE__ */
|
|
802
|
+
/* @__PURE__ */ V("span", {}),
|
|
803
|
+
/* @__PURE__ */ V("span", {}),
|
|
804
|
+
/* @__PURE__ */ V("span", {})
|
|
775
805
|
]
|
|
776
|
-
}), e ? /* @__PURE__ */
|
|
806
|
+
}), e ? /* @__PURE__ */ V("span", {
|
|
777
807
|
class: "whoo-widget-pending-text",
|
|
778
808
|
children: "Looking that up for you…"
|
|
779
809
|
}) : null]
|
|
780
810
|
});
|
|
781
811
|
}
|
|
782
|
-
function
|
|
783
|
-
let [n, r] =
|
|
784
|
-
return n ? null : /* @__PURE__ */
|
|
812
|
+
function $e({ url: e, alt: t }) {
|
|
813
|
+
let [n, r] = Ee(!1);
|
|
814
|
+
return n ? null : /* @__PURE__ */ V("img", {
|
|
785
815
|
class: "whoo-widget-empty-state-image",
|
|
786
816
|
src: e,
|
|
787
817
|
alt: t,
|
|
@@ -789,42 +819,54 @@ function Ze({ url: e, alt: t }) {
|
|
|
789
819
|
onError: () => r(!0)
|
|
790
820
|
});
|
|
791
821
|
}
|
|
792
|
-
function
|
|
793
|
-
let
|
|
794
|
-
return /* @__PURE__ */
|
|
795
|
-
ref:
|
|
822
|
+
function et({ message: e, speaker: t, feedbackState: n, showFeedback: r, pending: i, isSlowResponse: a, onThumbsUp: o, onThumbsDown: s, onDraftChange: c, onSubmitDetailed: l, onCancelFeedback: u }) {
|
|
823
|
+
let d = z(null), f = e.id;
|
|
824
|
+
return /* @__PURE__ */ V("div", {
|
|
825
|
+
ref: d,
|
|
796
826
|
tabIndex: -1,
|
|
797
827
|
class: `whoo-widget-message whoo-widget-message--${e.role}`,
|
|
798
|
-
children: [
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
828
|
+
children: [
|
|
829
|
+
/* @__PURE__ */ V("span", {
|
|
830
|
+
class: "whoo-widget-sr-only",
|
|
831
|
+
children: [t, ": "]
|
|
832
|
+
}),
|
|
833
|
+
i ? /* @__PURE__ */ V(Qe, { isSlowResponse: a }) : Ye(e.content),
|
|
834
|
+
r && e.role === "assistant" && f ? /* @__PURE__ */ V(Ze, {
|
|
835
|
+
state: n,
|
|
836
|
+
containerRef: d,
|
|
837
|
+
onThumbsUp: () => o(f),
|
|
838
|
+
onThumbsDown: () => s(f),
|
|
839
|
+
onDraftChange: (e, t) => c(f, e, t),
|
|
840
|
+
onSubmitDetailed: (e, t) => l(f, e, t),
|
|
841
|
+
onCancel: () => u(f)
|
|
842
|
+
}) : null
|
|
843
|
+
]
|
|
806
844
|
});
|
|
807
845
|
}
|
|
808
|
-
function
|
|
809
|
-
let
|
|
810
|
-
return
|
|
811
|
-
let e =
|
|
846
|
+
function tt({ messages: e, messageFeedback: t, announcement: n, emptyStateImage: r, agentName: i = "Aiden", showFeedback: a = !1, isStreaming: o = !1, isSlowResponse: s = !1, onThumbsUp: c, onThumbsDown: l, onDraftChange: u = () => {}, onSubmitDetailed: d, onCancelFeedback: f }) {
|
|
847
|
+
let p = z(null);
|
|
848
|
+
return R(() => {
|
|
849
|
+
let e = p.current;
|
|
812
850
|
e && (e.scrollTop = e.scrollHeight);
|
|
813
|
-
}, [e,
|
|
851
|
+
}, [e, s]), /* @__PURE__ */ V(E, { children: [/* @__PURE__ */ V("section", {
|
|
814
852
|
class: "whoo-widget-message-list",
|
|
815
|
-
ref:
|
|
816
|
-
|
|
853
|
+
ref: p,
|
|
854
|
+
"aria-label": "Conversation",
|
|
855
|
+
tabIndex: 0,
|
|
856
|
+
children: [r ? /* @__PURE__ */ V($e, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ V(et, {
|
|
817
857
|
message: n,
|
|
818
|
-
|
|
858
|
+
speaker: n.role === "user" ? "You" : i,
|
|
859
|
+
showFeedback: a,
|
|
819
860
|
feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
|
|
820
|
-
pending:
|
|
821
|
-
isSlowResponse:
|
|
822
|
-
onThumbsUp:
|
|
823
|
-
onThumbsDown:
|
|
824
|
-
|
|
825
|
-
|
|
861
|
+
pending: o && r === e.length - 1 && n.role === "assistant" && n.content === "",
|
|
862
|
+
isSlowResponse: s,
|
|
863
|
+
onThumbsUp: c,
|
|
864
|
+
onThumbsDown: l,
|
|
865
|
+
onDraftChange: u,
|
|
866
|
+
onSubmitDetailed: d,
|
|
867
|
+
onCancelFeedback: f
|
|
826
868
|
}, n.id ?? r))]
|
|
827
|
-
}), /* @__PURE__ */
|
|
869
|
+
}), /* @__PURE__ */ V("div", {
|
|
828
870
|
class: "whoo-widget-sr-only",
|
|
829
871
|
"aria-live": "polite",
|
|
830
872
|
"aria-atomic": "true",
|
|
@@ -833,16 +875,16 @@ function $e({ messages: e, messageFeedback: t, lastCompletedMessageText: n, empt
|
|
|
833
875
|
}
|
|
834
876
|
//#endregion
|
|
835
877
|
//#region src/components/Panel.tsx
|
|
836
|
-
var
|
|
837
|
-
function
|
|
838
|
-
return Array.from(e.querySelectorAll(
|
|
878
|
+
var nt = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
|
|
879
|
+
function rt(e) {
|
|
880
|
+
return Array.from(e.querySelectorAll(nt)).filter((e) => {
|
|
839
881
|
let t = getComputedStyle(e);
|
|
840
882
|
return t.display !== "none" && t.visibility !== "hidden";
|
|
841
883
|
});
|
|
842
884
|
}
|
|
843
|
-
function
|
|
844
|
-
let i =
|
|
845
|
-
|
|
885
|
+
function it({ state: e, controller: t, greeting: n }) {
|
|
886
|
+
let i = z(null), a = z(null);
|
|
887
|
+
R(() => {
|
|
846
888
|
a.current?.focus();
|
|
847
889
|
}, []);
|
|
848
890
|
let o = (e) => {
|
|
@@ -853,7 +895,7 @@ function nt({ state: e, controller: t, greeting: n }) {
|
|
|
853
895
|
if (e.key !== "Tab") return;
|
|
854
896
|
let n = i.current;
|
|
855
897
|
if (!n) return;
|
|
856
|
-
let r =
|
|
898
|
+
let r = rt(n);
|
|
857
899
|
if (r.length === 0) return;
|
|
858
900
|
let a = r[0], o = r[r.length - 1], s = n.getRootNode().activeElement;
|
|
859
901
|
if (!n.contains(s)) {
|
|
@@ -864,58 +906,62 @@ function nt({ state: e, controller: t, greeting: n }) {
|
|
|
864
906
|
}, s = () => {
|
|
865
907
|
let n = e.draft.trim();
|
|
866
908
|
n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
|
|
867
|
-
}, c =
|
|
909
|
+
}, c = r(t.config.name) || e.agentName || "Aiden", l = `Chat with ${c}`, u = e.messages.length === 0 && n ? [{
|
|
868
910
|
role: "assistant",
|
|
869
911
|
content: n,
|
|
870
912
|
id: null
|
|
871
|
-
}] : e.messages,
|
|
872
|
-
url:
|
|
913
|
+
}] : e.messages, d = t.emptyStateImageUrl, f = e.messages.length === 0 && d ? {
|
|
914
|
+
url: d,
|
|
873
915
|
alt: t.emptyStateImageAlt
|
|
874
916
|
} : void 0;
|
|
875
|
-
return /* @__PURE__ */
|
|
917
|
+
return /* @__PURE__ */ V("div", {
|
|
876
918
|
class: "whoo-widget-panel",
|
|
877
919
|
role: "dialog",
|
|
878
920
|
"aria-modal": "true",
|
|
879
|
-
"aria-label":
|
|
921
|
+
"aria-label": l,
|
|
880
922
|
ref: i,
|
|
881
923
|
onKeyDown: o,
|
|
882
924
|
children: [
|
|
883
|
-
/* @__PURE__ */
|
|
925
|
+
/* @__PURE__ */ V("div", {
|
|
884
926
|
class: "whoo-widget-header",
|
|
885
|
-
children: [/* @__PURE__ */
|
|
927
|
+
children: [/* @__PURE__ */ V("h2", {
|
|
886
928
|
class: "whoo-widget-header-title",
|
|
887
|
-
children:
|
|
888
|
-
}), /* @__PURE__ */
|
|
929
|
+
children: l
|
|
930
|
+
}), /* @__PURE__ */ V("div", {
|
|
889
931
|
class: "whoo-widget-header-actions",
|
|
890
|
-
children: [e.messages.length > 0 && /* @__PURE__ */
|
|
932
|
+
children: [e.messages.length > 0 && /* @__PURE__ */ V("button", {
|
|
891
933
|
type: "button",
|
|
892
934
|
class: "whoo-widget-header-reset",
|
|
893
|
-
onClick: () =>
|
|
935
|
+
onClick: () => {
|
|
936
|
+
t.resetConversation(), a.current?.focus();
|
|
937
|
+
},
|
|
894
938
|
children: "New conversation"
|
|
895
|
-
}), /* @__PURE__ */
|
|
939
|
+
}), /* @__PURE__ */ V("button", {
|
|
896
940
|
type: "button",
|
|
897
941
|
class: "whoo-widget-header-close",
|
|
898
942
|
"aria-label": "Close chat",
|
|
899
943
|
onClick: () => t.close(),
|
|
900
|
-
children: /* @__PURE__ */
|
|
944
|
+
children: /* @__PURE__ */ V(Re, {})
|
|
901
945
|
})]
|
|
902
946
|
})]
|
|
903
947
|
}),
|
|
904
|
-
/* @__PURE__ */
|
|
905
|
-
messages:
|
|
948
|
+
/* @__PURE__ */ V(tt, {
|
|
949
|
+
messages: u,
|
|
906
950
|
messageFeedback: e.messageFeedback,
|
|
907
|
-
|
|
908
|
-
emptyStateImage:
|
|
951
|
+
announcement: e.announcement,
|
|
952
|
+
emptyStateImage: f,
|
|
953
|
+
agentName: c,
|
|
909
954
|
showFeedback: t.showFeedback,
|
|
910
955
|
isStreaming: e.isStreaming,
|
|
911
956
|
isSlowResponse: e.isSlowResponse,
|
|
912
957
|
onThumbsUp: (e) => t.submitFeedback(e, "up"),
|
|
913
958
|
onThumbsDown: (e) => t.expandFeedback(e),
|
|
959
|
+
onDraftChange: (e, n, r) => t.setFeedbackDraft(e, n, r),
|
|
914
960
|
onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
|
|
915
961
|
onCancelFeedback: (e) => t.cancelFeedback(e)
|
|
916
962
|
}),
|
|
917
|
-
e.runtimeError && /* @__PURE__ */
|
|
918
|
-
/* @__PURE__ */
|
|
963
|
+
e.runtimeError && /* @__PURE__ */ V(We, { message: e.runtimeError }),
|
|
964
|
+
/* @__PURE__ */ V(Ue, {
|
|
919
965
|
value: e.draft,
|
|
920
966
|
onChange: (e) => t.setDraft(e),
|
|
921
967
|
onSend: s,
|
|
@@ -927,16 +973,16 @@ function nt({ state: e, controller: t, greeting: n }) {
|
|
|
927
973
|
}
|
|
928
974
|
//#endregion
|
|
929
975
|
//#region src/components/App.tsx
|
|
930
|
-
function
|
|
931
|
-
let [t, n] =
|
|
932
|
-
return
|
|
976
|
+
function at({ controller: e }) {
|
|
977
|
+
let [t, n] = Ee(e.getState()), r = z(null), i = z(t.isOpen);
|
|
978
|
+
return R(() => (n(e.getState()), e.subscribe(n)), [e]), R(() => {
|
|
933
979
|
i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
|
|
934
|
-
}, [t.isOpen]), t.initError ? null : /* @__PURE__ */
|
|
980
|
+
}, [t.isOpen]), t.initError || t.isInitializing ? null : /* @__PURE__ */ V(E, { children: [/* @__PURE__ */ V(He, {
|
|
935
981
|
isOpen: t.isOpen,
|
|
936
982
|
onClick: () => t.isOpen ? e.close() : e.open(),
|
|
937
983
|
iconUrl: e.launcherIconUrl,
|
|
938
984
|
buttonRef: r
|
|
939
|
-
}), t.isOpen && /* @__PURE__ */
|
|
985
|
+
}), t.isOpen && /* @__PURE__ */ V(it, {
|
|
940
986
|
state: t,
|
|
941
987
|
controller: e,
|
|
942
988
|
greeting: e.config.greeting
|
|
@@ -944,44 +990,44 @@ function rt({ controller: e }) {
|
|
|
944
990
|
}
|
|
945
991
|
//#endregion
|
|
946
992
|
//#region src/api/client.ts
|
|
947
|
-
var
|
|
993
|
+
var X = class extends Error {
|
|
948
994
|
status;
|
|
949
995
|
constructor(e, t) {
|
|
950
996
|
super(e), this.name = "WidgetApiError", this.status = t;
|
|
951
997
|
}
|
|
952
998
|
};
|
|
953
|
-
function
|
|
999
|
+
function Z(e) {
|
|
954
1000
|
if (typeof e != "string") return null;
|
|
955
1001
|
let t = e.trim();
|
|
956
1002
|
return t === "" ? null : t;
|
|
957
1003
|
}
|
|
958
|
-
async function
|
|
1004
|
+
async function ot(e, t) {
|
|
959
1005
|
let n = await fetch(`${e}/api/v1/widget/session`, {
|
|
960
1006
|
method: "POST",
|
|
961
1007
|
headers: { "Content-Type": "application/json" },
|
|
962
1008
|
body: JSON.stringify({ publishable_key: t })
|
|
963
1009
|
});
|
|
964
|
-
if (!n.ok) throw new
|
|
1010
|
+
if (!n.ok) throw new X(`Failed to create widget session (${n.status})`, n.status);
|
|
965
1011
|
let r = await n.json();
|
|
966
1012
|
return {
|
|
967
1013
|
token: r.token,
|
|
968
|
-
...
|
|
1014
|
+
...st(r)
|
|
969
1015
|
};
|
|
970
1016
|
}
|
|
971
|
-
function
|
|
1017
|
+
function st(e) {
|
|
972
1018
|
return {
|
|
973
|
-
primaryColor:
|
|
974
|
-
name:
|
|
975
|
-
accentColor:
|
|
976
|
-
inkColor:
|
|
1019
|
+
primaryColor: Z(e.primary_color),
|
|
1020
|
+
name: Z(e.name),
|
|
1021
|
+
accentColor: Z(e.accent_color),
|
|
1022
|
+
inkColor: Z(e.ink_color)
|
|
977
1023
|
};
|
|
978
1024
|
}
|
|
979
|
-
async function
|
|
1025
|
+
async function ct(e, t) {
|
|
980
1026
|
let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
|
|
981
|
-
if (!n.ok) throw new
|
|
982
|
-
return
|
|
1027
|
+
if (!n.ok) throw new X(`Failed to load widget branding (${n.status})`, n.status);
|
|
1028
|
+
return st(await n.json());
|
|
983
1029
|
}
|
|
984
|
-
async function
|
|
1030
|
+
async function lt(e, t, n) {
|
|
985
1031
|
let r = await fetch(`${e}/api/v1/widget/feedback`, {
|
|
986
1032
|
method: "POST",
|
|
987
1033
|
headers: {
|
|
@@ -995,11 +1041,11 @@ async function st(e, t, n) {
|
|
|
995
1041
|
category: n.category ?? null
|
|
996
1042
|
})
|
|
997
1043
|
});
|
|
998
|
-
if (!r.ok) throw new
|
|
1044
|
+
if (!r.ok) throw new X(`Feedback submission failed (${r.status})`, r.status);
|
|
999
1045
|
}
|
|
1000
1046
|
//#endregion
|
|
1001
1047
|
//#region src/api/sse.ts
|
|
1002
|
-
async function*
|
|
1048
|
+
async function* ut(e, t, n, r, i) {
|
|
1003
1049
|
let a = await fetch(`${e}/api/v1/widget/chat`, {
|
|
1004
1050
|
method: "POST",
|
|
1005
1051
|
headers: {
|
|
@@ -1012,7 +1058,7 @@ async function* ct(e, t, n, r, i) {
|
|
|
1012
1058
|
}),
|
|
1013
1059
|
signal: i
|
|
1014
1060
|
});
|
|
1015
|
-
if (!a.ok || !a.body) throw new
|
|
1061
|
+
if (!a.ok || !a.body) throw new X(`Chat request failed (${a.status})`, a.status);
|
|
1016
1062
|
let o = a.body.getReader(), s = new TextDecoder(), c = "";
|
|
1017
1063
|
for (;;) {
|
|
1018
1064
|
let { done: e, value: t } = await o.read();
|
|
@@ -1023,11 +1069,11 @@ async function* ct(e, t, n, r, i) {
|
|
|
1023
1069
|
let e = c.slice(0, n);
|
|
1024
1070
|
c = c.slice(n + 2);
|
|
1025
1071
|
let t = e.split("\n").find((e) => e.startsWith("data: "));
|
|
1026
|
-
t && (yield
|
|
1072
|
+
t && (yield dt(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
|
|
1027
1073
|
}
|
|
1028
1074
|
}
|
|
1029
1075
|
}
|
|
1030
|
-
function
|
|
1076
|
+
function dt(e) {
|
|
1031
1077
|
return typeof e.error == "string" ? {
|
|
1032
1078
|
type: "error",
|
|
1033
1079
|
error: e.error,
|
|
@@ -1050,7 +1096,7 @@ function lt(e) {
|
|
|
1050
1096
|
}
|
|
1051
1097
|
//#endregion
|
|
1052
1098
|
//#region src/imageUrl.ts
|
|
1053
|
-
function
|
|
1099
|
+
function ft(e, t) {
|
|
1054
1100
|
if (e != null && e !== "") {
|
|
1055
1101
|
if (typeof e == "string") try {
|
|
1056
1102
|
let t = new URL(e);
|
|
@@ -1060,17 +1106,29 @@ function ut(e, t) {
|
|
|
1060
1106
|
}
|
|
1061
1107
|
}
|
|
1062
1108
|
//#endregion
|
|
1063
|
-
//#region src/markdown/
|
|
1064
|
-
var dt = 40, ft = 120;
|
|
1109
|
+
//#region src/markdown/plainText.ts
|
|
1065
1110
|
function pt(e) {
|
|
1111
|
+
return J(e.replace(/\r\n?/g, "\n")).map((e) => {
|
|
1112
|
+
switch (e.type) {
|
|
1113
|
+
case "bold":
|
|
1114
|
+
case "italic": return pt(e.value);
|
|
1115
|
+
case "link": return e.text;
|
|
1116
|
+
default: return e.value;
|
|
1117
|
+
}
|
|
1118
|
+
}).join("");
|
|
1119
|
+
}
|
|
1120
|
+
//#endregion
|
|
1121
|
+
//#region src/markdown/reveal.ts
|
|
1122
|
+
var mt = 40, ht = 120;
|
|
1123
|
+
function gt(e) {
|
|
1066
1124
|
let t = [];
|
|
1067
|
-
for (let n of
|
|
1125
|
+
for (let n of J(e)) if (n.type === "text") {
|
|
1068
1126
|
let e = n.value.split(/(\s+)/), r = n.start;
|
|
1069
1127
|
for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
|
|
1070
1128
|
} else t.push(n.end);
|
|
1071
1129
|
return t;
|
|
1072
1130
|
}
|
|
1073
|
-
function
|
|
1131
|
+
function _t(e) {
|
|
1074
1132
|
let t = null;
|
|
1075
1133
|
return e?.addEventListener("abort", () => {
|
|
1076
1134
|
t?.();
|
|
@@ -1085,38 +1143,51 @@ function mt(e) {
|
|
|
1085
1143
|
});
|
|
1086
1144
|
};
|
|
1087
1145
|
}
|
|
1088
|
-
async function
|
|
1089
|
-
let r = n?.wordIntervalMs ??
|
|
1090
|
-
for (let n of
|
|
1146
|
+
async function vt(e, t, n) {
|
|
1147
|
+
let r = n?.wordIntervalMs ?? mt, i = n?.tokenIntervalMs ?? ht, a = n?.signal, o = J(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = _t(a), l = "";
|
|
1148
|
+
for (let n of gt(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
|
|
1091
1149
|
l !== e && t(e);
|
|
1092
1150
|
}
|
|
1093
1151
|
//#endregion
|
|
1152
|
+
//#region src/sessionToken.ts
|
|
1153
|
+
function yt(e, t = Date.now()) {
|
|
1154
|
+
let n = e.split(".");
|
|
1155
|
+
if (n.length !== 3 || n.some((e) => e === "")) return !1;
|
|
1156
|
+
let r = n[1];
|
|
1157
|
+
try {
|
|
1158
|
+
let e = r.replace(/-/g, "+").replace(/_/g, "/"), n = JSON.parse(atob(e.padEnd(Math.ceil(e.length / 4) * 4, "=")))?.exp;
|
|
1159
|
+
return typeof n == "number" && Number.isFinite(n) && n * 1e3 <= t;
|
|
1160
|
+
} catch {
|
|
1161
|
+
return !1;
|
|
1162
|
+
}
|
|
1163
|
+
}
|
|
1164
|
+
//#endregion
|
|
1094
1165
|
//#region src/storage.ts
|
|
1095
|
-
function
|
|
1166
|
+
function bt(e) {
|
|
1096
1167
|
return `whoo-aiden-widget:conversation:${e}`;
|
|
1097
1168
|
}
|
|
1098
|
-
function
|
|
1169
|
+
function xt(e) {
|
|
1099
1170
|
try {
|
|
1100
|
-
return window.sessionStorage.getItem(
|
|
1171
|
+
return window.sessionStorage.getItem(bt(e));
|
|
1101
1172
|
} catch {
|
|
1102
1173
|
return null;
|
|
1103
1174
|
}
|
|
1104
1175
|
}
|
|
1105
|
-
function
|
|
1176
|
+
function St(e, t) {
|
|
1106
1177
|
try {
|
|
1107
|
-
window.sessionStorage.setItem(
|
|
1178
|
+
window.sessionStorage.setItem(bt(e), t);
|
|
1108
1179
|
} catch {}
|
|
1109
1180
|
}
|
|
1110
|
-
function
|
|
1181
|
+
function Ct(e) {
|
|
1111
1182
|
try {
|
|
1112
|
-
window.sessionStorage.removeItem(
|
|
1183
|
+
window.sessionStorage.removeItem(bt(e));
|
|
1113
1184
|
} catch {}
|
|
1114
1185
|
}
|
|
1115
1186
|
//#endregion
|
|
1116
1187
|
//#region src/theme.ts
|
|
1117
|
-
var
|
|
1118
|
-
function
|
|
1119
|
-
if (
|
|
1188
|
+
var wt = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
|
|
1189
|
+
function Tt(e) {
|
|
1190
|
+
if (wt.test(e.trim())) return null;
|
|
1120
1191
|
let t = document.createElement("div");
|
|
1121
1192
|
if (t.style.color = e, t.style.color === "") return null;
|
|
1122
1193
|
let n = document.createElement("div");
|
|
@@ -1135,64 +1206,64 @@ function xt(e) {
|
|
|
1135
1206
|
translucent: a < 1
|
|
1136
1207
|
};
|
|
1137
1208
|
}
|
|
1138
|
-
function
|
|
1139
|
-
return
|
|
1209
|
+
function Et(e) {
|
|
1210
|
+
return Tt(e)?.rgb ?? null;
|
|
1140
1211
|
}
|
|
1141
|
-
function
|
|
1212
|
+
function Q([e, t, n]) {
|
|
1142
1213
|
let r = (e) => {
|
|
1143
1214
|
let t = e / 255;
|
|
1144
1215
|
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
1145
1216
|
};
|
|
1146
1217
|
return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
|
|
1147
1218
|
}
|
|
1148
|
-
function
|
|
1219
|
+
function Dt(e, t) {
|
|
1149
1220
|
let n = Math.max(e, t), r = Math.min(e, t);
|
|
1150
1221
|
return (n + .05) / (r + .05);
|
|
1151
1222
|
}
|
|
1152
|
-
function
|
|
1153
|
-
let t =
|
|
1223
|
+
function Ot(e) {
|
|
1224
|
+
let t = Et(e);
|
|
1154
1225
|
if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
|
|
1155
|
-
let n =
|
|
1156
|
-
return
|
|
1226
|
+
let n = Q(t);
|
|
1227
|
+
return Dt(n, Q([
|
|
1157
1228
|
0,
|
|
1158
1229
|
0,
|
|
1159
1230
|
0
|
|
1160
|
-
])) >=
|
|
1231
|
+
])) >= Dt(n, Q([
|
|
1161
1232
|
255,
|
|
1162
1233
|
255,
|
|
1163
1234
|
255
|
|
1164
1235
|
])) ? "#000000" : "#ffffff";
|
|
1165
1236
|
}
|
|
1166
|
-
var
|
|
1167
|
-
function
|
|
1237
|
+
var kt = "#4f46e5", At = "#ffffff", jt = "#f0f0f0", Mt = "#f3f4f6", Nt = 4.5;
|
|
1238
|
+
function Pt([e, t, n]) {
|
|
1168
1239
|
return `#${[
|
|
1169
1240
|
e,
|
|
1170
1241
|
t,
|
|
1171
1242
|
n
|
|
1172
1243
|
].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
1173
1244
|
}
|
|
1174
|
-
function
|
|
1175
|
-
let n =
|
|
1176
|
-
if (!n || !r) return
|
|
1177
|
-
let i =
|
|
1178
|
-
if (a(n)) return
|
|
1245
|
+
function Ft(e, t = At) {
|
|
1246
|
+
let n = Et(e), r = Et(t);
|
|
1247
|
+
if (!n || !r) return kt;
|
|
1248
|
+
let i = Q(r), a = (e) => Dt(Q(e), i) >= Nt;
|
|
1249
|
+
if (a(n)) return Pt(n);
|
|
1179
1250
|
for (let e = .99; e > 0; e -= .01) {
|
|
1180
1251
|
let t = n.map((t) => Math.round(t * e));
|
|
1181
|
-
if (a(t)) return
|
|
1252
|
+
if (a(t)) return Pt(t);
|
|
1182
1253
|
}
|
|
1183
1254
|
return "#000000";
|
|
1184
1255
|
}
|
|
1185
|
-
var
|
|
1256
|
+
var It = "#111111", Lt = "#0000ee";
|
|
1186
1257
|
function $(e) {
|
|
1187
1258
|
if (typeof e != "string" || !e) return null;
|
|
1188
|
-
let t =
|
|
1189
|
-
return t ?
|
|
1259
|
+
let t = Tt(e);
|
|
1260
|
+
return t ? Pt(t.rgb) : null;
|
|
1190
1261
|
}
|
|
1191
|
-
function
|
|
1192
|
-
let r = $(e), i = r ??
|
|
1262
|
+
function Rt({ color: e, inkColor: t, accentColor: n }) {
|
|
1263
|
+
let r = $(e), i = r ?? kt, a = Ft(i, Mt), o = $(t), s = o ? Ft(o, jt) : It, c = $(n), l = c ? Ft(c, jt) : Lt;
|
|
1193
1264
|
return {
|
|
1194
1265
|
primary: i,
|
|
1195
|
-
textOnPrimary:
|
|
1266
|
+
textOnPrimary: Ot(i),
|
|
1196
1267
|
primaryAsText: a,
|
|
1197
1268
|
ink: s,
|
|
1198
1269
|
link: l,
|
|
@@ -1203,27 +1274,27 @@ function Mt({ color: e, inkColor: t, accentColor: n }) {
|
|
|
1203
1274
|
}
|
|
1204
1275
|
};
|
|
1205
1276
|
}
|
|
1206
|
-
function
|
|
1277
|
+
function zt(e) {
|
|
1207
1278
|
return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
|
|
1208
1279
|
}
|
|
1209
|
-
function
|
|
1280
|
+
function Bt(e, t, n = kt) {
|
|
1210
1281
|
let r = t;
|
|
1211
|
-
$(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${
|
|
1212
|
-
let i =
|
|
1282
|
+
$(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${zt(t)} as the theme color; falling back to ${zt(n)}.`), r = n);
|
|
1283
|
+
let i = Rt({ color: r });
|
|
1213
1284
|
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);
|
|
1214
1285
|
}
|
|
1215
|
-
function
|
|
1216
|
-
let r =
|
|
1286
|
+
function Vt(e, { inkColor: t, accentColor: n }) {
|
|
1287
|
+
let r = Rt({
|
|
1217
1288
|
inkColor: t,
|
|
1218
1289
|
accentColor: n
|
|
1219
1290
|
});
|
|
1220
1291
|
e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
|
|
1221
1292
|
}
|
|
1222
|
-
function
|
|
1223
|
-
e && $(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${
|
|
1293
|
+
function Ht(e, t) {
|
|
1294
|
+
e && $(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${zt(e)} as the ${t}; using the default.`);
|
|
1224
1295
|
}
|
|
1225
|
-
function
|
|
1226
|
-
|
|
1296
|
+
function Ut(e, t) {
|
|
1297
|
+
Bt(e, t.color ?? kt), Ht(t.inkColor, "ink color"), Ht(t.accentColor, "accent color"), Vt(e, {
|
|
1227
1298
|
inkColor: t.inkColor,
|
|
1228
1299
|
accentColor: t.accentColor
|
|
1229
1300
|
});
|
|
@@ -1232,7 +1303,16 @@ function Lt(e, t) {
|
|
|
1232
1303
|
}
|
|
1233
1304
|
//#endregion
|
|
1234
1305
|
//#region src/controller.ts
|
|
1235
|
-
var
|
|
1306
|
+
var Wt = 8e3, Gt = 3e3;
|
|
1307
|
+
function Kt(e, t) {
|
|
1308
|
+
return new Promise((n) => {
|
|
1309
|
+
let r = setTimeout(n, t);
|
|
1310
|
+
e.then(() => {
|
|
1311
|
+
clearTimeout(r), n();
|
|
1312
|
+
});
|
|
1313
|
+
});
|
|
1314
|
+
}
|
|
1315
|
+
var qt = class {
|
|
1236
1316
|
config;
|
|
1237
1317
|
state;
|
|
1238
1318
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -1247,18 +1327,19 @@ var Rt = 8e3, zt = class {
|
|
|
1247
1327
|
emptyStateImageAlt;
|
|
1248
1328
|
showFeedback;
|
|
1249
1329
|
constructor(e) {
|
|
1250
|
-
this.config = e, this.launcherIconUrl =
|
|
1330
|
+
this.config = e, this.launcherIconUrl = ft(e.launcherIconUrl, "launcherIconUrl"), this.emptyStateImageUrl = ft(e.emptyStateImageUrl, "emptyStateImageUrl"), this.emptyStateImageAlt = typeof e.emptyStateImageAlt == "string" ? e.emptyStateImageAlt.trim() : "", this.showFeedback = e.showFeedback === !0, this.storageIdentifier = e.publishableKey ?? "session-token-mode", this.prefersReducedMotion = typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches, this.state = {
|
|
1251
1331
|
isOpen: !1,
|
|
1252
1332
|
messages: [],
|
|
1253
1333
|
isStreaming: !1,
|
|
1254
1334
|
initError: null,
|
|
1335
|
+
isInitializing: !1,
|
|
1255
1336
|
runtimeError: null,
|
|
1256
1337
|
messageFeedback: {},
|
|
1257
1338
|
primaryColor: null,
|
|
1258
1339
|
agentName: null,
|
|
1259
1340
|
accentColor: null,
|
|
1260
1341
|
inkColor: null,
|
|
1261
|
-
|
|
1342
|
+
announcement: null,
|
|
1262
1343
|
isSlowResponse: !1,
|
|
1263
1344
|
draft: ""
|
|
1264
1345
|
};
|
|
@@ -1280,11 +1361,21 @@ var Rt = 8e3, zt = class {
|
|
|
1280
1361
|
for (let e of this.listeners) e(this.state);
|
|
1281
1362
|
}
|
|
1282
1363
|
async init() {
|
|
1364
|
+
this.setState({ isInitializing: !0 });
|
|
1365
|
+
try {
|
|
1366
|
+
await this.start();
|
|
1367
|
+
} finally {
|
|
1368
|
+
this.setState({ isInitializing: !1 });
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
async start() {
|
|
1283
1372
|
let e = this.config.apiBaseUrl ?? "https://api.aidenvoice.com";
|
|
1284
1373
|
try {
|
|
1285
|
-
if (this.config.sessionToken)
|
|
1286
|
-
|
|
1287
|
-
|
|
1374
|
+
if (this.config.sessionToken) {
|
|
1375
|
+
if (yt(this.config.sessionToken)) throw Error("The sessionToken has expired.");
|
|
1376
|
+
this.sessionToken = this.config.sessionToken;
|
|
1377
|
+
} else if (this.config.publishableKey) {
|
|
1378
|
+
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await ot(e, this.config.publishableKey);
|
|
1288
1379
|
this.sessionToken = t, this.setState({
|
|
1289
1380
|
primaryColor: n,
|
|
1290
1381
|
agentName: r,
|
|
@@ -1296,31 +1387,34 @@ var Rt = 8e3, zt = class {
|
|
|
1296
1387
|
console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
|
|
1297
1388
|
return;
|
|
1298
1389
|
}
|
|
1299
|
-
this.conversationId =
|
|
1390
|
+
this.conversationId = xt(this.storageIdentifier), this.config.sessionToken && await Kt(this.loadBranding(e, this.config.sessionToken), Gt);
|
|
1300
1391
|
}
|
|
1301
1392
|
async loadBranding(e, t) {
|
|
1302
1393
|
try {
|
|
1303
1394
|
let n = this.config;
|
|
1304
1395
|
if ($(n.color) && $(n.inkColor) && $(n.accentColor) && r(n.name)) return;
|
|
1305
|
-
let { primaryColor: i, name: a, accentColor: o, inkColor: s } = await
|
|
1396
|
+
let { primaryColor: i, name: a, accentColor: o, inkColor: s } = await ct(e, t);
|
|
1306
1397
|
this.setState({
|
|
1307
1398
|
primaryColor: i,
|
|
1308
1399
|
agentName: a,
|
|
1309
1400
|
accentColor: o,
|
|
1310
1401
|
inkColor: s
|
|
1311
1402
|
});
|
|
1312
|
-
} catch {
|
|
1403
|
+
} catch (e) {
|
|
1404
|
+
let t = e?.status;
|
|
1405
|
+
(t === 401 || t === 403) && (console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) }));
|
|
1406
|
+
}
|
|
1313
1407
|
}
|
|
1314
1408
|
open() {
|
|
1315
1409
|
this.setState({ isOpen: !0 });
|
|
1316
1410
|
}
|
|
1317
1411
|
resetConversation() {
|
|
1318
|
-
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null,
|
|
1412
|
+
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, Ct(this.storageIdentifier), this.setState({
|
|
1319
1413
|
messages: [],
|
|
1320
1414
|
messageFeedback: {},
|
|
1321
1415
|
runtimeError: null,
|
|
1322
1416
|
isStreaming: !1,
|
|
1323
|
-
|
|
1417
|
+
announcement: "Conversation cleared"
|
|
1324
1418
|
});
|
|
1325
1419
|
}
|
|
1326
1420
|
setDraft(e) {
|
|
@@ -1347,7 +1441,8 @@ var Rt = 8e3, zt = class {
|
|
|
1347
1441
|
r
|
|
1348
1442
|
],
|
|
1349
1443
|
isStreaming: !0,
|
|
1350
|
-
runtimeError: null
|
|
1444
|
+
runtimeError: null,
|
|
1445
|
+
announcement: null
|
|
1351
1446
|
});
|
|
1352
1447
|
let i = (e) => {
|
|
1353
1448
|
let t = [...this.state.messages];
|
|
@@ -1360,7 +1455,7 @@ var Rt = 8e3, zt = class {
|
|
|
1360
1455
|
let { signal: a } = this.activeRequestController;
|
|
1361
1456
|
this.slowResponseTimer = setTimeout(() => {
|
|
1362
1457
|
this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
|
|
1363
|
-
},
|
|
1458
|
+
}, Wt);
|
|
1364
1459
|
let o = () => {
|
|
1365
1460
|
this.setState({
|
|
1366
1461
|
runtimeError: "Something went wrong, please try again.",
|
|
@@ -1368,17 +1463,17 @@ var Rt = 8e3, zt = class {
|
|
|
1368
1463
|
});
|
|
1369
1464
|
}, s = "";
|
|
1370
1465
|
try {
|
|
1371
|
-
for await (let n of
|
|
1372
|
-
else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await
|
|
1466
|
+
for await (let n of ut(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, St(this.storageIdentifier, n.conversationId);
|
|
1467
|
+
else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await vt(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
|
|
1373
1468
|
else if (n.type === "done") {
|
|
1374
|
-
if (n.conversationId && (this.conversationId = n.conversationId,
|
|
1469
|
+
if (n.conversationId && (this.conversationId = n.conversationId, St(this.storageIdentifier, n.conversationId)), n.messageId) {
|
|
1375
1470
|
let e = [...this.state.messages];
|
|
1376
1471
|
e[e.length - 1] = {
|
|
1377
1472
|
...e[e.length - 1],
|
|
1378
1473
|
id: n.messageId
|
|
1379
1474
|
}, this.setState({ messages: e });
|
|
1380
1475
|
}
|
|
1381
|
-
this.setState({
|
|
1476
|
+
this.setState({ announcement: pt(s) });
|
|
1382
1477
|
} else if (n.type === "error") {
|
|
1383
1478
|
console.error("[whoo-aiden-widget] chat error:", n.error), o(), this.activeRequestController?.abort();
|
|
1384
1479
|
break;
|
|
@@ -1390,9 +1485,24 @@ var Rt = 8e3, zt = class {
|
|
|
1390
1485
|
}
|
|
1391
1486
|
}
|
|
1392
1487
|
expandFeedback(e) {
|
|
1488
|
+
let { correction: t, category: n } = this.state.messageFeedback[e] ?? {};
|
|
1393
1489
|
this.setState({ messageFeedback: {
|
|
1394
1490
|
...this.state.messageFeedback,
|
|
1395
|
-
[e]: {
|
|
1491
|
+
[e]: {
|
|
1492
|
+
status: "expanded",
|
|
1493
|
+
correction: t,
|
|
1494
|
+
category: n
|
|
1495
|
+
}
|
|
1496
|
+
} });
|
|
1497
|
+
}
|
|
1498
|
+
setFeedbackDraft(e, t, n) {
|
|
1499
|
+
this.setState({ messageFeedback: {
|
|
1500
|
+
...this.state.messageFeedback,
|
|
1501
|
+
[e]: {
|
|
1502
|
+
...this.state.messageFeedback[e],
|
|
1503
|
+
correction: t,
|
|
1504
|
+
category: n
|
|
1505
|
+
}
|
|
1396
1506
|
} });
|
|
1397
1507
|
}
|
|
1398
1508
|
cancelFeedback(e) {
|
|
@@ -1412,7 +1522,7 @@ var Rt = 8e3, zt = class {
|
|
|
1412
1522
|
}
|
|
1413
1523
|
} });
|
|
1414
1524
|
try {
|
|
1415
|
-
await
|
|
1525
|
+
await lt(i, this.sessionToken, {
|
|
1416
1526
|
messageId: e,
|
|
1417
1527
|
rating: t,
|
|
1418
1528
|
correction: n,
|
|
@@ -1424,42 +1534,44 @@ var Rt = 8e3, zt = class {
|
|
|
1424
1534
|
rating: t
|
|
1425
1535
|
}
|
|
1426
1536
|
} });
|
|
1427
|
-
} catch (
|
|
1428
|
-
console.error("[whoo-aiden-widget] feedback submission failed:",
|
|
1537
|
+
} catch (i) {
|
|
1538
|
+
console.error("[whoo-aiden-widget] feedback submission failed:", i), this.setState({ messageFeedback: {
|
|
1429
1539
|
...this.state.messageFeedback,
|
|
1430
1540
|
[e]: {
|
|
1431
1541
|
status: "error",
|
|
1432
|
-
rating: t
|
|
1542
|
+
rating: t,
|
|
1543
|
+
correction: n,
|
|
1544
|
+
category: r
|
|
1433
1545
|
}
|
|
1434
1546
|
} });
|
|
1435
1547
|
}
|
|
1436
1548
|
}
|
|
1437
|
-
},
|
|
1549
|
+
}, Jt = ":host,.whoo-widget-root{all:initial;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,sans-serif}.whoo-widget-launcher{bottom:20px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:var(--whoo-widget-color,#4f46e5);width:56px;height:56px;color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:50%;justify-content:center;align-items:center;padding:0;font-size:24px;display:flex;position:fixed;box-shadow:0 2px 8px #0003}.whoo-widget-launcher:focus-visible{box-shadow:0 2px 8px #0003,0 0 0 4px #fff}.whoo-widget-launcher svg{display:block}.whoo-widget-launcher-icon-image{object-fit:cover;border-radius:50%;width:32px;height:32px}.whoo-widget-launcher-icon-image[hidden]{display:none}.whoo-widget-panel{bottom:88px;left:var(--whoo-widget-inset-left,auto);right:var(--whoo-widget-inset-right,20px);background:#fff;border-radius:12px;flex-direction:column;width:360px;max-width:calc(100vw - 40px);height:480px;max-height:calc(100vh - 108px);display:flex;position:fixed;overflow:hidden;box-shadow:0 4px 16px #0003}@media (width<=400px),(height<=420px){.whoo-widget-panel{width:auto;max-width:none;height:auto;max-height:none;inset:8px}}.whoo-widget-header{border-bottom:1px solid #e5e5e5;flex-wrap:wrap;flex-shrink:0;justify-content:space-between;align-items:center;gap:8px;max-height:50%;padding:8px 8px 8px 16px;display:flex;overflow-y:auto}.whoo-widget-header-title{color:var(--whoo-widget-ink,#111);overflow-wrap:anywhere;flex:auto;min-width:0;margin:0;font-size:15px;font-weight:600}.whoo-widget-header-actions{background:#fff;flex-shrink:0;align-items:center;gap:4px;margin-left:auto;display:flex;position:sticky;bottom:0}.whoo-widget-header-close,.whoo-widget-header-reset{color:var(--whoo-widget-color-text,#4f46e5);cursor:pointer;background:0 0;border:none;border-radius:6px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px 8px;font-size:13px;display:inline-flex}.whoo-widget-header-close{width:32px;height:32px;padding:0}.whoo-widget-header-close:hover,.whoo-widget-header-reset:hover{background:#f3f4f6}.whoo-widget-message-list{flex:1;min-height:0;padding:12px;overflow-y:auto}.whoo-widget-message-list:focus-visible{outline-offset:-2px;outline:2px solid #111827;box-shadow:inset 0 0 0 4px #fff}.whoo-widget-empty-state-image{object-fit:contain;max-width:min(160px,100%);height:auto;max-height:160px;margin:8px auto 16px;display:block}@media (width<=400px),(height<=420px){.whoo-widget-empty-state-image{max-height:64px;margin:0 auto 8px}}.whoo-widget-message{overflow-wrap:anywhere;white-space:pre-line;border-radius:8px;max-width:80%;margin-bottom:8px;padding:8px 12px}.whoo-widget-list{margin:4px 0;padding-left:20px}.whoo-widget-message--user{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);margin-left:auto}.whoo-widget-message--user a{color:inherit}.whoo-widget-message--assistant{color:var(--whoo-widget-ink,#111);background:#f0f0f0}.whoo-widget-message--assistant a{color:var(--whoo-widget-link-color,#00e)}.whoo-widget-pending{flex-wrap:wrap;align-items:center;gap:8px;min-height:1.2em;display:flex}.whoo-widget-typing{align-items:center;gap:4px;display:inline-flex}.whoo-widget-typing span{background:#6b7280;border-radius:50%;width:6px;height:6px;animation:1.2s ease-in-out infinite whoo-widget-typing-bounce}.whoo-widget-typing span:nth-child(2){animation-delay:.2s}.whoo-widget-typing span:nth-child(3){animation-delay:.4s}@keyframes whoo-widget-typing-bounce{0%,80%,to{transform:translateY(0)}40%{transform:translateY(-4px)}}@media (prefers-reduced-motion:reduce){.whoo-widget-typing span{animation:none}}.whoo-widget-error-banner{color:#991b1b;background:#fee2e2;padding:8px 12px;font-size:13px}.whoo-widget-composer{border-top:1px solid #e5e5e5;gap:8px;padding:12px;display:flex}.whoo-widget-composer-input{border:1px solid #6b7280;border-radius:6px;flex:1;padding:8px}.whoo-widget-composer-send{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px}.whoo-widget-composer-send[aria-disabled=true],.whoo-widget-composer-input[aria-disabled=true]{opacity:.6;cursor:not-allowed}.whoo-widget-feedback{align-items:center;gap:6px;margin-top:4px;display:flex}.whoo-widget-feedback-buttons{gap:6px;display:flex}.whoo-widget-feedback-buttons button{cursor:pointer;color:#4b5563;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;min-width:24px;min-height:24px;padding:4px;display:inline-flex}.whoo-widget-feedback-buttons button:hover:not(:disabled){color:#111;background:#0000000f}.whoo-widget-feedback-buttons button:disabled{opacity:.3;cursor:not-allowed}.whoo-widget-feedback-form{flex-direction:column;gap:6px;margin-top:6px;display:flex}.whoo-widget-feedback-textarea{box-sizing:border-box;resize:vertical;border:1px solid #6b7280;border-radius:6px;width:100%;padding:6px;font-size:12px}.whoo-widget-feedback-select{border:1px solid #6b7280;border-radius:6px;min-height:24px;padding:4px;font-size:12px}.whoo-widget-feedback-form-buttons{gap:6px;display:flex}.whoo-widget-feedback-submit{background:var(--whoo-widget-color,#4f46e5);color:var(--whoo-widget-text-on-color,#fff);cursor:pointer;border:none;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-cancel{color:#111;cursor:pointer;background:#fff;border:1px solid #6b7280;border-radius:6px;padding:8px 16px;font-size:13px}.whoo-widget-feedback-submitted{color:#4b5563;margin-top:4px;font-size:12px}.whoo-widget-feedback-error{color:#991b1b;font-size:12px}.whoo-widget-sr-only{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}button:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,a:focus-visible{outline-offset:2px;outline:2px solid #111827;box-shadow:0 0 0 4px #fff}@media (forced-colors:active){.whoo-widget-launcher,.whoo-widget-header-close,.whoo-widget-header-reset,.whoo-widget-composer-send,.whoo-widget-feedback-submit,.whoo-widget-feedback-buttons button{border:1px solid buttontext}.whoo-widget-panel{box-sizing:border-box;border:1px solid canvastext}}";
|
|
1438
1550
|
//#endregion
|
|
1439
1551
|
//#region src/mount.tsx
|
|
1440
|
-
function
|
|
1552
|
+
function Yt(e) {
|
|
1441
1553
|
let t = document.createElement("div");
|
|
1442
1554
|
t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(n(e.zIndex));
|
|
1443
1555
|
let r = t.attachShadow({ mode: "open" }), i = document.createElement("style");
|
|
1444
|
-
i.textContent =
|
|
1556
|
+
i.textContent = Jt, r.appendChild(i);
|
|
1445
1557
|
let a = document.createElement("div");
|
|
1446
|
-
r.appendChild(a),
|
|
1447
|
-
let o = new
|
|
1558
|
+
r.appendChild(a), Ut(a, e);
|
|
1559
|
+
let o = new qt(e), s = $(e.color) !== null, c = null, l = "";
|
|
1448
1560
|
return o.subscribe((t) => {
|
|
1449
|
-
!s && t.primaryColor && t.primaryColor !== c && (c = t.primaryColor,
|
|
1561
|
+
!s && t.primaryColor && t.primaryColor !== c && (c = t.primaryColor, Bt(a, t.primaryColor, e.color));
|
|
1450
1562
|
let n = `${t.inkColor}|${t.accentColor}`;
|
|
1451
|
-
(t.inkColor || t.accentColor) && n !== l && (l = n,
|
|
1563
|
+
(t.inkColor || t.accentColor) && n !== l && (l = n, Vt(a, {
|
|
1452
1564
|
inkColor: $(e.inkColor) ? e.inkColor : t.inkColor,
|
|
1453
1565
|
accentColor: $(e.accentColor) ? e.accentColor : t.accentColor
|
|
1454
1566
|
}));
|
|
1455
|
-
}), he(/* @__PURE__ */
|
|
1567
|
+
}), o.init(), he(/* @__PURE__ */ V(at, { controller: o }), a), document.body.appendChild(t), { unmount() {
|
|
1456
1568
|
he(null, a), t.remove();
|
|
1457
1569
|
} };
|
|
1458
1570
|
}
|
|
1459
1571
|
//#endregion
|
|
1460
1572
|
//#region src/index.ts
|
|
1461
|
-
function
|
|
1462
|
-
return i(e),
|
|
1573
|
+
function Xt(e) {
|
|
1574
|
+
return i(e), Yt(e);
|
|
1463
1575
|
}
|
|
1464
1576
|
//#endregion
|
|
1465
|
-
export {
|
|
1577
|
+
export { Xt as init, Rt as resolveTheme };
|