@aiden-voice/widget 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -9
- package/dist/api/client.d.ts +5 -2
- package/dist/components/App.d.ts +1 -1
- package/dist/components/Composer.d.ts +1 -1
- package/dist/components/ErrorBanner.d.ts +1 -1
- package/dist/components/Launcher.d.ts +1 -1
- package/dist/components/MessageFeedback.d.ts +3 -2
- package/dist/components/MessageList.d.ts +9 -4
- package/dist/components/Panel.d.ts +1 -1
- package/dist/components/icons.d.ts +5 -5
- package/dist/config.d.ts +2 -0
- package/dist/controller.d.ts +5 -1
- package/dist/markdown/plainText.d.ts +1 -0
- package/dist/markdown/render.d.ts +1 -1
- package/dist/theme.d.ts +2 -2
- package/dist/types.d.ts +7 -5
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +8 -4
- package/dist/widget.js +615 -507
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -3,26 +3,29 @@ function n(n) {
|
|
|
3
3
|
return n === void 0 ? e : Number.isInteger(n) && Math.abs(n) <= t ? n : (console.warn(`whoo-aiden-widget: ignoring zIndex ${String(n)} (expected an integer between -${t} and ${t}); using ${e}.`), e);
|
|
4
4
|
}
|
|
5
5
|
function r(e) {
|
|
6
|
+
return typeof e == "string" ? e.trim() : "";
|
|
7
|
+
}
|
|
8
|
+
function i(e) {
|
|
6
9
|
if ((typeof e.publishableKey == "string" && e.publishableKey.length > 0) == (typeof e.sessionToken == "string" && e.sessionToken.length > 0)) throw Error("whoo-aiden-widget: init() requires exactly one of `publishableKey` or `sessionToken`, not both or neither.");
|
|
7
10
|
}
|
|
8
11
|
//#endregion
|
|
9
12
|
//#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/dist/preact.module.js
|
|
10
|
-
var
|
|
11
|
-
function
|
|
13
|
+
var a, o, s, c, l, u, d, f, p, m, h, g, _, v, y = {}, b = [], x = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, S = Array.isArray;
|
|
14
|
+
function C(e, t) {
|
|
12
15
|
for (var n in t) e[n] = t[n];
|
|
13
16
|
return e;
|
|
14
17
|
}
|
|
15
18
|
function ee(e) {
|
|
16
19
|
e && e.parentNode && e.parentNode.removeChild(e);
|
|
17
20
|
}
|
|
18
|
-
function
|
|
19
|
-
var r,
|
|
20
|
-
for (o in t) o == "key" ? r = t[o] : o == "ref" ?
|
|
21
|
-
if (arguments.length > 2 && (s.children = arguments.length > 3 ?
|
|
22
|
-
return
|
|
21
|
+
function w(e, t, n) {
|
|
22
|
+
var r, i, o, s = {};
|
|
23
|
+
for (o in t) o == "key" ? r = t[o] : o == "ref" ? i = t[o] : s[o] = t[o];
|
|
24
|
+
if (arguments.length > 2 && (s.children = arguments.length > 3 ? a.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (o in e.defaultProps) s[o] === void 0 && (s[o] = e.defaultProps[o]);
|
|
25
|
+
return T(e, s, r, i, null);
|
|
23
26
|
}
|
|
24
|
-
function
|
|
25
|
-
var
|
|
27
|
+
function T(e, t, n, r, i) {
|
|
28
|
+
var a = {
|
|
26
29
|
type: e,
|
|
27
30
|
props: t,
|
|
28
31
|
key: n,
|
|
@@ -33,16 +36,16 @@ function w(e, t, n, r, i) {
|
|
|
33
36
|
__e: null,
|
|
34
37
|
__c: null,
|
|
35
38
|
constructor: void 0,
|
|
36
|
-
__v: i ?? ++
|
|
39
|
+
__v: i ?? ++s,
|
|
37
40
|
__i: -1,
|
|
38
41
|
__u: 0
|
|
39
42
|
};
|
|
40
|
-
return i == null &&
|
|
43
|
+
return i == null && o.vnode != null && o.vnode(a), a;
|
|
41
44
|
}
|
|
42
|
-
function
|
|
45
|
+
function E(e) {
|
|
43
46
|
return e.children;
|
|
44
47
|
}
|
|
45
|
-
function
|
|
48
|
+
function te(e, t) {
|
|
46
49
|
this.props = e, this.context = t;
|
|
47
50
|
}
|
|
48
51
|
function D(e, t) {
|
|
@@ -52,8 +55,8 @@ function D(e, t) {
|
|
|
52
55
|
}
|
|
53
56
|
function O(e) {
|
|
54
57
|
if (e.__P && e.__d) {
|
|
55
|
-
var t = e.__v, n = t.__e, r = [], i = [],
|
|
56
|
-
|
|
58
|
+
var t = e.__v, n = t.__e, r = [], i = [], a = C({}, t);
|
|
59
|
+
a.__v = t.__v + 1, o.vnode && o.vnode(a), se(e.__P, a, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? D(t), !!(32 & t.__u), i), a.__v = t.__v, a.__.__k[a.__i] = a, le(r, a, i), t.__e = t.__ = null, a.__e != n && k(a);
|
|
57
60
|
}
|
|
58
61
|
}
|
|
59
62
|
function k(e) {
|
|
@@ -62,30 +65,30 @@ function k(e) {
|
|
|
62
65
|
}), k(e);
|
|
63
66
|
}
|
|
64
67
|
function A(e) {
|
|
65
|
-
(!e.__d && (e.__d = !0) &&
|
|
68
|
+
(!e.__d && (e.__d = !0) && c.push(e) && !j.__r++ || l != o.debounceRendering) && ((l = o.debounceRendering) || u)(j);
|
|
66
69
|
}
|
|
67
70
|
function j() {
|
|
68
71
|
try {
|
|
69
|
-
for (var e, t = 1;
|
|
72
|
+
for (var e, t = 1; c.length;) c.length > t && c.sort(d), e = c.shift(), t = c.length, O(e);
|
|
70
73
|
} finally {
|
|
71
|
-
|
|
74
|
+
c.length = j.__r = 0;
|
|
72
75
|
}
|
|
73
76
|
}
|
|
74
|
-
function
|
|
75
|
-
var d, f, p, m, h, g, _ = r && r.__k ||
|
|
76
|
-
for (c = M(n, t, _, c,
|
|
77
|
+
function ne(e, t, n, r, i, a, o, s, c, l, u) {
|
|
78
|
+
var d, f, p, m, h, g, _ = r && r.__k || b, v = t.length;
|
|
79
|
+
for (c = M(n, t, _, c, v), d = 0; d < v; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || y, p.__i = d, g = se(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && fe(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = re(p, c, e), f.__e && (f.__e = null)) : typeof p.type == "function" && g !== void 0 ? c = g : m && (c = m.nextSibling), p.__u &= -7);
|
|
77
80
|
return n.__e = h, c;
|
|
78
81
|
}
|
|
79
82
|
function M(e, t, n, r, i) {
|
|
80
83
|
var a, o, s, c, l, u = n.length, d = u, f = 0;
|
|
81
|
-
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] =
|
|
82
|
-
if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = D(s)),
|
|
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));
|
|
83
86
|
return r;
|
|
84
87
|
}
|
|
85
|
-
function
|
|
88
|
+
function re(e, t, n) {
|
|
86
89
|
var r, i;
|
|
87
90
|
if (typeof e.type == "function") {
|
|
88
|
-
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));
|
|
89
92
|
return t;
|
|
90
93
|
}
|
|
91
94
|
e.__e != t && (t && e.type && !t.parentNode && (t = D(e)), t = n.insertBefore(e.__e, t || null));
|
|
@@ -94,7 +97,7 @@ function N(e, t, n) {
|
|
|
94
97
|
while (t != null && t.nodeType == 8);
|
|
95
98
|
return t;
|
|
96
99
|
}
|
|
97
|
-
function
|
|
100
|
+
function ie(e, t, n, r) {
|
|
98
101
|
var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && !(2 & l.__u);
|
|
99
102
|
if (l === null && s == null || u && s == l.key && c == l.type) return n;
|
|
100
103
|
if (r > +!!u) {
|
|
@@ -102,18 +105,18 @@ function ne(e, t, n, r) {
|
|
|
102
105
|
}
|
|
103
106
|
return -1;
|
|
104
107
|
}
|
|
105
|
-
function
|
|
106
|
-
t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" ||
|
|
108
|
+
function ae(e, t, n) {
|
|
109
|
+
t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || x.test(t) ? n : n + "px";
|
|
107
110
|
}
|
|
108
|
-
function
|
|
111
|
+
function N(e, t, n, r, i) {
|
|
109
112
|
var a, o;
|
|
110
113
|
n: if (t == "style") {
|
|
111
114
|
if (typeof n == "string") e.style.cssText = n;
|
|
112
115
|
else {
|
|
113
|
-
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n ||
|
|
114
|
-
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]);
|
|
115
118
|
}
|
|
116
|
-
} else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(
|
|
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);
|
|
117
120
|
else {
|
|
118
121
|
if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
119
122
|
else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
|
|
@@ -123,158 +126,158 @@ function P(e, t, n, r, i) {
|
|
|
123
126
|
typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
|
|
124
127
|
}
|
|
125
128
|
}
|
|
126
|
-
function
|
|
129
|
+
function oe(e) {
|
|
127
130
|
return function(t) {
|
|
128
131
|
if (this.l) {
|
|
129
132
|
var n = this.l[t.type + e];
|
|
130
|
-
if (t[
|
|
131
|
-
else if (t[
|
|
132
|
-
return n(
|
|
133
|
+
if (t[p] == null) t[p] = g++;
|
|
134
|
+
else if (t[p] < n[m]) return;
|
|
135
|
+
return n(o.event ? o.event(t) : t);
|
|
133
136
|
}
|
|
134
137
|
};
|
|
135
138
|
}
|
|
136
|
-
function
|
|
137
|
-
var d, f, p, m, h, g, _, v,
|
|
139
|
+
function se(e, t, n, r, i, a, s, c, l, u) {
|
|
140
|
+
var d, f, p, m, h, g, _, v, y, x, w, T, O, k, A, j, M = t.type;
|
|
138
141
|
if (t.constructor !== void 0) return null;
|
|
139
|
-
128 & n.__u && (l = !!(32 & n.__u),
|
|
140
|
-
n: if (typeof
|
|
142
|
+
128 & n.__u && (l = !!(32 & n.__u), a = [c = t.__e = n.__e]), (d = o.__b) && d(t);
|
|
143
|
+
n: if (typeof M == "function") {
|
|
141
144
|
f = s.length;
|
|
142
145
|
try {
|
|
143
|
-
if (
|
|
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);
|
|
144
147
|
else {
|
|
145
|
-
if (
|
|
146
|
-
t.__v != n.__v && (p.props =
|
|
148
|
+
if (x && M.getDerivedStateFromProps == null && y !== h && p.componentWillReceiveProps != null && p.componentWillReceiveProps(y, T), t.__v == n.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(y, p.__s, T)) {
|
|
149
|
+
t.__v != n.__v && (p.props = y, p.state = p.__s, p.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
|
|
147
150
|
e && (e.__ = t);
|
|
148
|
-
}),
|
|
151
|
+
}), b.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && s.push(p), c = D(n);
|
|
149
152
|
break n;
|
|
150
153
|
}
|
|
151
|
-
p.componentWillUpdate != null && p.componentWillUpdate(
|
|
154
|
+
p.componentWillUpdate != null && p.componentWillUpdate(y, p.__s, T), x && p.componentDidUpdate != null && p.__h.push(function() {
|
|
152
155
|
p.componentDidUpdate(h, g, _);
|
|
153
156
|
});
|
|
154
157
|
}
|
|
155
|
-
if (p.context =
|
|
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 = [];
|
|
156
159
|
else do
|
|
157
|
-
p.__d = !1,
|
|
158
|
-
while (p.__d && ++
|
|
159
|
-
p.state = p.__s, p.getChildContext != null && (r =
|
|
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);
|
|
160
163
|
} catch (e) {
|
|
161
|
-
if (s.length = f, t.__v = null, l ||
|
|
164
|
+
if (s.length = f, t.__v = null, l || a != null) {
|
|
162
165
|
if (e.then) {
|
|
163
166
|
for (t.__u |= l ? 160 : 128; c && c.nodeType == 8 && c.nextSibling;) c = c.nextSibling;
|
|
164
|
-
|
|
165
|
-
} else if (
|
|
167
|
+
a != null && (a[a.indexOf(c)] = null), t.__e = c;
|
|
168
|
+
} else if (a != null) for (j = a.length; j--;) ee(a[j]);
|
|
166
169
|
} else t.__e = n.__e;
|
|
167
|
-
t.__k ??= n.__k || [], e.then ||
|
|
170
|
+
t.__k ??= n.__k || [], e.then || ce(t), o.__e(e, t, n);
|
|
168
171
|
}
|
|
169
|
-
} else
|
|
170
|
-
return (d =
|
|
172
|
+
} else a == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : c = t.__e = de(n.__e, t, n, r, i, a, s, l, u);
|
|
173
|
+
return (d = o.diffed) && d(t), 128 & t.__u ? void 0 : c;
|
|
171
174
|
}
|
|
172
|
-
function
|
|
173
|
-
e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(
|
|
175
|
+
function ce(e) {
|
|
176
|
+
e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(ce));
|
|
174
177
|
}
|
|
175
|
-
function
|
|
176
|
-
for (var r = 0; r < n.length; r++)
|
|
177
|
-
|
|
178
|
+
function le(e, t, n) {
|
|
179
|
+
for (var r = 0; r < n.length; r++) fe(n[r], n[++r], n[++r]);
|
|
180
|
+
o.__c && o.__c(t, e), e.some(function(t) {
|
|
178
181
|
try {
|
|
179
182
|
e = t.__h, t.__h = [], e.some(function(e) {
|
|
180
183
|
e.call(t);
|
|
181
184
|
});
|
|
182
185
|
} catch (e) {
|
|
183
|
-
|
|
186
|
+
o.__e(e, t.__v);
|
|
184
187
|
}
|
|
185
188
|
});
|
|
186
189
|
}
|
|
187
|
-
function
|
|
188
|
-
return typeof e != "object" || !e || e.__b > 0 ? e :
|
|
190
|
+
function ue(e) {
|
|
191
|
+
return typeof e != "object" || !e || e.__b > 0 ? e : S(e) ? e.map(ue) : e.constructor === void 0 ? C({}, e) : null;
|
|
189
192
|
}
|
|
190
|
-
function
|
|
191
|
-
var d, f, p, m, h, g, _,
|
|
192
|
-
if (
|
|
193
|
-
for (d = 0; d < s.length; d++) if ((h = s[d]) && "setAttribute" in h == !!
|
|
193
|
+
function de(e, t, n, r, i, s, c, l, u) {
|
|
194
|
+
var d, f, p, m, h, g, _, v = n.props || y, b = t.props, x = t.type;
|
|
195
|
+
if (x == "svg" ? i = "http://www.w3.org/2000/svg" : x == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i ||= "http://www.w3.org/1999/xhtml", s != null) {
|
|
196
|
+
for (d = 0; d < s.length; d++) if ((h = s[d]) && "setAttribute" in h == !!x && (x ? h.localName == x : h.nodeType == 3)) {
|
|
194
197
|
e = h, s[d] = null;
|
|
195
198
|
break;
|
|
196
199
|
}
|
|
197
200
|
}
|
|
198
201
|
if (e == null) {
|
|
199
|
-
if (
|
|
200
|
-
e = document.createElementNS(
|
|
202
|
+
if (x == null) return document.createTextNode(b);
|
|
203
|
+
e = document.createElementNS(i, x, b.is && b), l &&= (o.__m && o.__m(t, s), !1), s = null;
|
|
201
204
|
}
|
|
202
|
-
if (
|
|
205
|
+
if (x == null) v === b || l && e.data == b || (e.data = b);
|
|
203
206
|
else {
|
|
204
|
-
if (s =
|
|
205
|
-
for (d in
|
|
206
|
-
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" ||
|
|
207
|
+
if (s = x == "textarea" && b.defaultValue != null ? null : s && a.call(e.childNodes), !l && s != null) for (v = {}, d = 0; d < e.attributes.length; d++) v[(h = e.attributes[d]).name] = h.value;
|
|
208
|
+
for (d in v) h = v[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in b || d == "value" && "defaultValue" in b || d == "checked" && "defaultChecked" in b || N(e, d, null, h, i);
|
|
209
|
+
for (d in b) h = b[d], d == "children" ? m = h : d == "dangerouslySetInnerHTML" ? f = h : d == "value" ? g = h : d == "checked" ? _ = h : l && typeof h != "function" || v[d] === h || N(e, d, h, v[d], i);
|
|
207
210
|
if (f) l || p && (f.__html == p.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), t.__k = [];
|
|
208
|
-
else if (p && (e.innerHTML = ""),
|
|
209
|
-
l &&
|
|
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));
|
|
210
213
|
}
|
|
211
214
|
return e;
|
|
212
215
|
}
|
|
213
|
-
function
|
|
216
|
+
function fe(e, t, n) {
|
|
214
217
|
try {
|
|
215
218
|
if (typeof e == "function") {
|
|
216
219
|
var r = typeof e.__u == "function";
|
|
217
220
|
r && e.__u(), r && t == null || (e.__u = e(t));
|
|
218
221
|
} else e.current = t;
|
|
219
222
|
} catch (e) {
|
|
220
|
-
|
|
223
|
+
o.__e(e, n);
|
|
221
224
|
}
|
|
222
225
|
}
|
|
223
|
-
function
|
|
226
|
+
function pe(e, t, n) {
|
|
224
227
|
var r, i;
|
|
225
|
-
if (
|
|
228
|
+
if (o.unmount && o.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || fe(r, null, t)), (r = e.__c) != null) {
|
|
226
229
|
if (r.componentWillUnmount) try {
|
|
227
230
|
r.componentWillUnmount();
|
|
228
231
|
} catch (e) {
|
|
229
|
-
|
|
232
|
+
o.__e(e, t);
|
|
230
233
|
}
|
|
231
234
|
r.base = r.__P = r.__n = null;
|
|
232
235
|
}
|
|
233
|
-
if (r = e.__k) for (i = 0; i < r.length; i++) r[i] &&
|
|
236
|
+
if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && pe(r[i], t, n || typeof e.type != "function");
|
|
234
237
|
n || ee(e.__e), e.__c = e.__ = e.__e = void 0;
|
|
235
238
|
}
|
|
236
|
-
function
|
|
239
|
+
function me(e, t, n) {
|
|
237
240
|
return this.constructor(e, n);
|
|
238
241
|
}
|
|
239
|
-
function
|
|
240
|
-
var r,
|
|
241
|
-
t == document && (t = document.documentElement),
|
|
242
|
+
function he(e, t, n) {
|
|
243
|
+
var r, i, s, c;
|
|
244
|
+
t == document && (t = document.documentElement), o.__ && o.__(e, t), i = (r = typeof n == "function") ? null : n && n.__k || t.__k, s = [], c = [], se(t, e = (!r && n || t).__k = w(E, null, [e]), i || y, y, t.namespaceURI, !r && n ? [n] : i ? null : t.firstChild ? a.call(t.childNodes) : null, s, !r && n ? n : i ? i.__e : t.firstChild, r, c), le(s, e, c), e.props.children = null;
|
|
242
245
|
}
|
|
243
|
-
|
|
246
|
+
a = b.slice, o = { __e: function(e, t, n, r) {
|
|
244
247
|
for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
|
|
245
248
|
if ((a = i.constructor) && a.getDerivedStateFromError != null && (i.setState(a.getDerivedStateFromError(e)), o = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, r || {}), o = i.__d), o) return i.__E = i;
|
|
246
249
|
} catch (t) {
|
|
247
250
|
e = t;
|
|
248
251
|
}
|
|
249
252
|
throw e;
|
|
250
|
-
} },
|
|
251
|
-
var n = this.__s != null && this.__s != this.state ? this.__s : this.__s =
|
|
252
|
-
typeof e == "function" && (e = e(
|
|
253
|
-
},
|
|
253
|
+
} }, s = 0, te.prototype.setState = function(e, t) {
|
|
254
|
+
var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = C({}, this.state);
|
|
255
|
+
typeof e == "function" && (e = e(C({}, n), this.props)), e && C(n, e), e != null && this.__v && (t && this._sb.push(t), A(this));
|
|
256
|
+
}, te.prototype.forceUpdate = function(e) {
|
|
254
257
|
this.__v && (this.__e = !0, e && this.__h.push(e), A(this));
|
|
255
|
-
},
|
|
258
|
+
}, te.prototype.render = E, c = [], u = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, d = function(e, t) {
|
|
256
259
|
return e.__v.__b - t.__v.__b;
|
|
257
|
-
}, j.__r = 0,
|
|
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);
|
|
258
261
|
//#endregion
|
|
259
262
|
//#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/hooks/dist/hooks.module.js
|
|
260
|
-
var
|
|
261
|
-
function
|
|
262
|
-
|
|
263
|
-
var n =
|
|
263
|
+
var P, F, ge, _e, I = 0, ve = [], L = o, ye = L.__b, be = L.__r, xe = L.diffed, Se = L.__c, Ce = L.unmount, we = L.__;
|
|
264
|
+
function Te(e, t) {
|
|
265
|
+
L.__h && L.__h(F, e, I || t), I = 0;
|
|
266
|
+
var n = F.__H || (F.__H = {
|
|
264
267
|
__: [],
|
|
265
268
|
__h: []
|
|
266
269
|
});
|
|
267
270
|
return e >= n.__.length && n.__.push({}), n.__[e];
|
|
268
271
|
}
|
|
269
|
-
function
|
|
270
|
-
return
|
|
272
|
+
function Ee(e) {
|
|
273
|
+
return I = 1, De(Pe, e);
|
|
271
274
|
}
|
|
272
|
-
function
|
|
273
|
-
var r =
|
|
274
|
-
if (r.t = e, !r.__c && (r.__ = [n ? n(t) :
|
|
275
|
+
function De(e, t, n) {
|
|
276
|
+
var r = Te(P++, 2);
|
|
277
|
+
if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Pe(void 0, t), function(e) {
|
|
275
278
|
var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
|
|
276
279
|
t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
|
|
277
|
-
}], r.__c =
|
|
280
|
+
}], r.__c = F, !F.__f)) {
|
|
278
281
|
var i = function(e, t, n) {
|
|
279
282
|
if (!r.__c.__H) return !0;
|
|
280
283
|
var i = !1, o = r.__c.props !== e;
|
|
@@ -290,108 +293,108 @@ function we(e, t, n) {
|
|
|
290
293
|
}
|
|
291
294
|
return !i || o;
|
|
292
295
|
};
|
|
293
|
-
|
|
294
|
-
var a =
|
|
295
|
-
|
|
296
|
+
F.__f = !0;
|
|
297
|
+
var a = F.shouldComponentUpdate, o = F.componentWillUpdate;
|
|
298
|
+
F.componentWillUpdate = function(e, t, n) {
|
|
296
299
|
if (this.__e) {
|
|
297
300
|
var r = a;
|
|
298
301
|
a = void 0, i(e, t, n), a = r;
|
|
299
302
|
}
|
|
300
303
|
o && o.call(this, e, t, n);
|
|
301
|
-
},
|
|
304
|
+
}, F.shouldComponentUpdate = i;
|
|
302
305
|
}
|
|
303
306
|
return r.__N || r.__;
|
|
304
307
|
}
|
|
305
|
-
function
|
|
306
|
-
var n =
|
|
307
|
-
!
|
|
308
|
+
function R(e, t) {
|
|
309
|
+
var n = Te(P++, 3);
|
|
310
|
+
!L.__s && Ne(n.__H, t) && (n.__ = e, n.u = t, F.__H.__h.push(n));
|
|
308
311
|
}
|
|
309
|
-
function
|
|
310
|
-
return
|
|
312
|
+
function z(e) {
|
|
313
|
+
return I = 5, Oe(function() {
|
|
311
314
|
return { current: e };
|
|
312
315
|
}, []);
|
|
313
316
|
}
|
|
314
|
-
function
|
|
315
|
-
var n =
|
|
316
|
-
return
|
|
317
|
+
function Oe(e, t) {
|
|
318
|
+
var n = Te(P++, 7);
|
|
319
|
+
return Ne(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
|
|
317
320
|
}
|
|
318
|
-
function
|
|
319
|
-
for (var e; e =
|
|
321
|
+
function ke() {
|
|
322
|
+
for (var e; e = ve.shift();) {
|
|
320
323
|
var t = e.__H;
|
|
321
324
|
if (e.__P && t) try {
|
|
322
|
-
t.__h.some(
|
|
325
|
+
t.__h.some(B), t.__h.some(Me), t.__h = [];
|
|
323
326
|
} catch (n) {
|
|
324
|
-
t.__h = [],
|
|
327
|
+
t.__h = [], L.__e(n, e.__v);
|
|
325
328
|
}
|
|
326
329
|
}
|
|
327
330
|
}
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
},
|
|
331
|
-
e && t.__k && t.__k.__m && (e.__m = t.__k.__m),
|
|
332
|
-
},
|
|
333
|
-
|
|
334
|
-
var t = (
|
|
335
|
-
t && (
|
|
331
|
+
L.__b = function(e) {
|
|
332
|
+
F = null, ye && ye(e);
|
|
333
|
+
}, L.__ = function(e, t) {
|
|
334
|
+
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), we && we(e, t);
|
|
335
|
+
}, L.__r = function(e) {
|
|
336
|
+
be && be(e), P = 0;
|
|
337
|
+
var t = (F = e.__c).__H;
|
|
338
|
+
t && (ge === F ? (t.__h = [], F.__h = [], t.__.some(function(e) {
|
|
336
339
|
e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
|
|
337
|
-
})) : (t.__h.some(
|
|
338
|
-
},
|
|
339
|
-
|
|
340
|
+
})) : (t.__h.some(B), t.__h.some(Me), t.__h = [], P = 0)), ge = F;
|
|
341
|
+
}, L.diffed = function(e) {
|
|
342
|
+
xe && xe(e);
|
|
340
343
|
var t = e.__c;
|
|
341
|
-
t && t.__H && (t.__H.__h.length && (
|
|
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) {
|
|
342
345
|
e.u &&= (e.__H = e.u, void 0);
|
|
343
|
-
})),
|
|
344
|
-
},
|
|
346
|
+
})), ge = F = null;
|
|
347
|
+
}, L.__c = function(e, t) {
|
|
345
348
|
t.some(function(e) {
|
|
346
349
|
try {
|
|
347
|
-
e.__h.some(
|
|
348
|
-
return !e.__ ||
|
|
350
|
+
e.__h.some(B), e.__h = e.__h.filter(function(e) {
|
|
351
|
+
return !e.__ || Me(e);
|
|
349
352
|
});
|
|
350
353
|
} catch (n) {
|
|
351
354
|
t.some(function(e) {
|
|
352
355
|
e.__h &&= [];
|
|
353
|
-
}), t = [],
|
|
356
|
+
}), t = [], L.__e(n, e.__v);
|
|
354
357
|
}
|
|
355
|
-
}),
|
|
356
|
-
},
|
|
357
|
-
|
|
358
|
+
}), Se && Se(e, t);
|
|
359
|
+
}, L.unmount = function(e) {
|
|
360
|
+
Ce && Ce(e);
|
|
358
361
|
var t, n = e.__c;
|
|
359
362
|
n && n.__H && (n.__H.__.some(function(e) {
|
|
360
363
|
try {
|
|
361
|
-
|
|
364
|
+
B(e);
|
|
362
365
|
} catch (e) {
|
|
363
366
|
t = e;
|
|
364
367
|
}
|
|
365
|
-
}), n.__H = void 0, t &&
|
|
368
|
+
}), n.__H = void 0, t && L.__e(t, n.__v));
|
|
366
369
|
};
|
|
367
|
-
var
|
|
368
|
-
function
|
|
370
|
+
var Ae = typeof requestAnimationFrame == "function";
|
|
371
|
+
function je(e) {
|
|
369
372
|
var t, n = function() {
|
|
370
|
-
clearTimeout(r),
|
|
373
|
+
clearTimeout(r), Ae && cancelAnimationFrame(t), setTimeout(e);
|
|
371
374
|
}, r = setTimeout(n, 35);
|
|
372
|
-
|
|
375
|
+
Ae && (t = requestAnimationFrame(n));
|
|
373
376
|
}
|
|
374
|
-
function
|
|
375
|
-
var t =
|
|
376
|
-
typeof n == "function" && (e.__c = void 0, n()),
|
|
377
|
+
function B(e) {
|
|
378
|
+
var t = F, n = e.__c;
|
|
379
|
+
typeof n == "function" && (e.__c = void 0, n()), F = t;
|
|
377
380
|
}
|
|
378
|
-
function
|
|
379
|
-
var t =
|
|
380
|
-
e.__c = e.__(),
|
|
381
|
+
function Me(e) {
|
|
382
|
+
var t = F;
|
|
383
|
+
e.__c = e.__(), F = t;
|
|
381
384
|
}
|
|
382
|
-
function
|
|
385
|
+
function Ne(e, t) {
|
|
383
386
|
return !e || e.length !== t.length || t.some(function(t, n) {
|
|
384
387
|
return t !== e[n];
|
|
385
388
|
});
|
|
386
389
|
}
|
|
387
|
-
function
|
|
390
|
+
function Pe(e, t) {
|
|
388
391
|
return typeof t == "function" ? t(e) : t;
|
|
389
392
|
}
|
|
390
393
|
//#endregion
|
|
391
394
|
//#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
|
|
392
|
-
var
|
|
395
|
+
var Fe = 0;
|
|
393
396
|
Array.isArray;
|
|
394
|
-
function
|
|
397
|
+
function V(e, t, n, r, i, a) {
|
|
395
398
|
t ||= {};
|
|
396
399
|
var s, c, l = t;
|
|
397
400
|
if ("ref" in l) for (c in l = {}, t) c == "ref" ? s = t[c] : l[c] = t[c];
|
|
@@ -406,19 +409,19 @@ function U(e, t, n, r, i, o) {
|
|
|
406
409
|
__e: null,
|
|
407
410
|
__c: null,
|
|
408
411
|
constructor: void 0,
|
|
409
|
-
__v: --
|
|
412
|
+
__v: --Fe,
|
|
410
413
|
__i: -1,
|
|
411
414
|
__u: 0,
|
|
412
415
|
__source: i,
|
|
413
|
-
__self:
|
|
416
|
+
__self: a
|
|
414
417
|
};
|
|
415
418
|
if (typeof e == "function" && (s = e.defaultProps)) for (c in s) l[c] === void 0 && (l[c] = s[c]);
|
|
416
|
-
return
|
|
419
|
+
return o.vnode && o.vnode(u), u;
|
|
417
420
|
}
|
|
418
421
|
//#endregion
|
|
419
422
|
//#region src/components/icons.tsx
|
|
420
|
-
function
|
|
421
|
-
return /* @__PURE__ */
|
|
423
|
+
function H({ name: e, size: t, children: n }) {
|
|
424
|
+
return /* @__PURE__ */ V("svg", {
|
|
422
425
|
"data-icon": e,
|
|
423
426
|
"aria-hidden": "true",
|
|
424
427
|
focusable: "false",
|
|
@@ -433,59 +436,59 @@ function W({ name: e, size: t, children: n }) {
|
|
|
433
436
|
children: n
|
|
434
437
|
});
|
|
435
438
|
}
|
|
436
|
-
function
|
|
437
|
-
return /* @__PURE__ */
|
|
439
|
+
function Ie({ size: e = 26 }) {
|
|
440
|
+
return /* @__PURE__ */ V(H, {
|
|
438
441
|
name: "chat",
|
|
439
442
|
size: e,
|
|
440
|
-
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", {
|
|
441
444
|
d: "M8.5 9.5h.01M12 9.5h.01M15.5 9.5h.01",
|
|
442
445
|
"stroke-width": "2.5"
|
|
443
446
|
})]
|
|
444
447
|
});
|
|
445
448
|
}
|
|
446
|
-
function
|
|
447
|
-
return /* @__PURE__ */
|
|
449
|
+
function Le({ size: e = 26 }) {
|
|
450
|
+
return /* @__PURE__ */ V(H, {
|
|
448
451
|
name: "chevron-down",
|
|
449
452
|
size: e,
|
|
450
|
-
children: /* @__PURE__ */
|
|
453
|
+
children: /* @__PURE__ */ V("path", { d: "M6 9l6 6 6-6" })
|
|
451
454
|
});
|
|
452
455
|
}
|
|
453
|
-
function
|
|
454
|
-
return /* @__PURE__ */
|
|
456
|
+
function Re({ size: e = 18 }) {
|
|
457
|
+
return /* @__PURE__ */ V(H, {
|
|
455
458
|
name: "close",
|
|
456
459
|
size: e,
|
|
457
|
-
children: /* @__PURE__ */
|
|
460
|
+
children: /* @__PURE__ */ V("path", { d: "M6 6l12 12M18 6L6 18" })
|
|
458
461
|
});
|
|
459
462
|
}
|
|
460
|
-
var
|
|
461
|
-
function
|
|
462
|
-
return /* @__PURE__ */
|
|
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, {
|
|
463
466
|
name: "thumb-up",
|
|
464
467
|
size: e,
|
|
465
|
-
children: /* @__PURE__ */
|
|
468
|
+
children: /* @__PURE__ */ V("path", { d: ze })
|
|
466
469
|
});
|
|
467
470
|
}
|
|
468
|
-
function
|
|
469
|
-
return /* @__PURE__ */
|
|
471
|
+
function Ve({ size: e = 16 }) {
|
|
472
|
+
return /* @__PURE__ */ V(H, {
|
|
470
473
|
name: "thumb-down",
|
|
471
474
|
size: e,
|
|
472
|
-
children: /* @__PURE__ */
|
|
473
|
-
d:
|
|
475
|
+
children: /* @__PURE__ */ V("path", {
|
|
476
|
+
d: ze,
|
|
474
477
|
transform: "matrix(1 0 0 -1 0 24)"
|
|
475
478
|
})
|
|
476
479
|
});
|
|
477
480
|
}
|
|
478
481
|
//#endregion
|
|
479
482
|
//#region src/components/Launcher.tsx
|
|
480
|
-
function
|
|
481
|
-
let [i, a] =
|
|
482
|
-
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", {
|
|
483
486
|
type: "button",
|
|
484
487
|
class: "whoo-widget-launcher",
|
|
485
488
|
onClick: t,
|
|
486
489
|
"aria-label": e ? "Close chat" : "Open chat",
|
|
487
490
|
ref: r,
|
|
488
|
-
children: [e ? /* @__PURE__ */
|
|
491
|
+
children: [e ? /* @__PURE__ */ V(Le, {}) : s ? null : /* @__PURE__ */ V(Ie, {}), o ? /* @__PURE__ */ V("img", {
|
|
489
492
|
class: "whoo-widget-launcher-icon-image",
|
|
490
493
|
src: n,
|
|
491
494
|
alt: "",
|
|
@@ -498,16 +501,16 @@ function ze({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
|
|
|
498
501
|
}
|
|
499
502
|
//#endregion
|
|
500
503
|
//#region src/components/Composer.tsx
|
|
501
|
-
function
|
|
502
|
-
return /* @__PURE__ */
|
|
504
|
+
function Ue({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
505
|
+
return /* @__PURE__ */ V("div", {
|
|
503
506
|
class: "whoo-widget-composer",
|
|
504
507
|
children: [
|
|
505
|
-
/* @__PURE__ */
|
|
508
|
+
/* @__PURE__ */ V("label", {
|
|
506
509
|
class: "whoo-widget-sr-only",
|
|
507
510
|
for: "whoo-widget-composer-input",
|
|
508
511
|
children: "Message"
|
|
509
512
|
}),
|
|
510
|
-
/* @__PURE__ */
|
|
513
|
+
/* @__PURE__ */ V("input", {
|
|
511
514
|
id: "whoo-widget-composer-input",
|
|
512
515
|
class: "whoo-widget-composer-input",
|
|
513
516
|
value: e,
|
|
@@ -519,11 +522,13 @@ function Be({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
|
519
522
|
e.key === "Enter" && n();
|
|
520
523
|
}
|
|
521
524
|
}),
|
|
522
|
-
/* @__PURE__ */
|
|
525
|
+
/* @__PURE__ */ V("button", {
|
|
523
526
|
type: "button",
|
|
524
527
|
class: "whoo-widget-composer-send",
|
|
525
|
-
|
|
526
|
-
|
|
528
|
+
"aria-disabled": r,
|
|
529
|
+
onClick: () => {
|
|
530
|
+
r || n();
|
|
531
|
+
},
|
|
527
532
|
children: "Send"
|
|
528
533
|
})
|
|
529
534
|
]
|
|
@@ -531,8 +536,8 @@ function Be({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
|
531
536
|
}
|
|
532
537
|
//#endregion
|
|
533
538
|
//#region src/components/ErrorBanner.tsx
|
|
534
|
-
function
|
|
535
|
-
return /* @__PURE__ */
|
|
539
|
+
function We({ message: e }) {
|
|
540
|
+
return /* @__PURE__ */ V("div", {
|
|
536
541
|
class: "whoo-widget-error-banner",
|
|
537
542
|
role: "alert",
|
|
538
543
|
children: e
|
|
@@ -540,8 +545,8 @@ function Ve({ message: e }) {
|
|
|
540
545
|
}
|
|
541
546
|
//#endregion
|
|
542
547
|
//#region src/markdown/tokenizer.ts
|
|
543
|
-
var
|
|
544
|
-
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) {
|
|
545
550
|
let t = [], n = 0, r = 0, i = (n) => {
|
|
546
551
|
n > r && t.push({
|
|
547
552
|
type: "text",
|
|
@@ -551,13 +556,13 @@ function We(e) {
|
|
|
551
556
|
});
|
|
552
557
|
};
|
|
553
558
|
for (; n < e.length;) {
|
|
554
|
-
if ((n === 0 || e[n - 1] === "\n") && (
|
|
559
|
+
if ((n === 0 || e[n - 1] === "\n") && (q.lastIndex = n, q.exec(e))) {
|
|
555
560
|
i(n), t.push({
|
|
556
561
|
type: "text",
|
|
557
562
|
value: "• ",
|
|
558
563
|
start: n,
|
|
559
|
-
end:
|
|
560
|
-
}), n =
|
|
564
|
+
end: q.lastIndex
|
|
565
|
+
}), n = q.lastIndex, r = n;
|
|
561
566
|
continue;
|
|
562
567
|
}
|
|
563
568
|
if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
|
|
@@ -570,56 +575,56 @@ function We(e) {
|
|
|
570
575
|
}
|
|
571
576
|
}
|
|
572
577
|
if (e[n - 1] !== "!") {
|
|
573
|
-
|
|
574
|
-
let a =
|
|
578
|
+
U.lastIndex = n;
|
|
579
|
+
let a = U.exec(e);
|
|
575
580
|
if (a) {
|
|
576
581
|
i(n), t.push({
|
|
577
582
|
type: "link",
|
|
578
583
|
text: a[1],
|
|
579
584
|
url: a[2],
|
|
580
585
|
start: n,
|
|
581
|
-
end:
|
|
582
|
-
}), n =
|
|
586
|
+
end: U.lastIndex
|
|
587
|
+
}), n = U.lastIndex, r = n;
|
|
583
588
|
continue;
|
|
584
589
|
}
|
|
585
590
|
}
|
|
586
|
-
|
|
587
|
-
let a =
|
|
591
|
+
W.lastIndex = n;
|
|
592
|
+
let a = W.exec(e);
|
|
588
593
|
if (a) {
|
|
589
594
|
i(n), t.push({
|
|
590
595
|
type: "bold",
|
|
591
596
|
value: a[1],
|
|
592
597
|
start: n,
|
|
593
|
-
end:
|
|
594
|
-
}), n =
|
|
598
|
+
end: W.lastIndex
|
|
599
|
+
}), n = W.lastIndex, r = n;
|
|
595
600
|
continue;
|
|
596
601
|
}
|
|
597
|
-
|
|
598
|
-
let o =
|
|
602
|
+
G.lastIndex = n;
|
|
603
|
+
let o = G.exec(e);
|
|
599
604
|
if (o) {
|
|
600
605
|
i(n), t.push({
|
|
601
606
|
type: "italic",
|
|
602
607
|
value: o[1],
|
|
603
608
|
start: n,
|
|
604
|
-
end:
|
|
605
|
-
}), n =
|
|
609
|
+
end: G.lastIndex
|
|
610
|
+
}), n = G.lastIndex, r = n;
|
|
606
611
|
continue;
|
|
607
612
|
}
|
|
608
|
-
|
|
609
|
-
let s =
|
|
613
|
+
K.lastIndex = n;
|
|
614
|
+
let s = K.exec(e);
|
|
610
615
|
if (s) {
|
|
611
616
|
i(n), t.push({
|
|
612
617
|
type: "italic",
|
|
613
618
|
value: s[1],
|
|
614
619
|
start: n,
|
|
615
|
-
end:
|
|
616
|
-
}), n =
|
|
620
|
+
end: K.lastIndex
|
|
621
|
+
}), n = K.lastIndex, r = n;
|
|
617
622
|
continue;
|
|
618
623
|
}
|
|
619
|
-
|
|
620
|
-
let c =
|
|
624
|
+
Ge.lastIndex = n;
|
|
625
|
+
let c = Ge.exec(e);
|
|
621
626
|
if (c) {
|
|
622
|
-
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];
|
|
623
628
|
if (a.length > 0) {
|
|
624
629
|
i(n), t.push({
|
|
625
630
|
type: "link",
|
|
@@ -637,16 +642,42 @@ function We(e) {
|
|
|
637
642
|
}
|
|
638
643
|
//#endregion
|
|
639
644
|
//#region src/markdown/render.tsx
|
|
640
|
-
|
|
641
|
-
|
|
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) => {
|
|
642
673
|
switch (e.type) {
|
|
643
|
-
case "bold": return /* @__PURE__ */
|
|
644
|
-
case "italic": return /* @__PURE__ */
|
|
645
|
-
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", {
|
|
646
677
|
href: e.url,
|
|
647
678
|
target: "_blank",
|
|
648
679
|
rel: "noopener noreferrer",
|
|
649
|
-
children: [e.text, /* @__PURE__ */
|
|
680
|
+
children: [e.text, /* @__PURE__ */ V("span", {
|
|
650
681
|
class: "whoo-widget-sr-only",
|
|
651
682
|
children: " (opens in new tab)"
|
|
652
683
|
})]
|
|
@@ -655,9 +686,16 @@ function Ge(e) {
|
|
|
655
686
|
}
|
|
656
687
|
});
|
|
657
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
|
+
}
|
|
658
696
|
//#endregion
|
|
659
697
|
//#region src/components/MessageFeedback.tsx
|
|
660
|
-
var
|
|
698
|
+
var Xe = [
|
|
661
699
|
{
|
|
662
700
|
value: "",
|
|
663
701
|
label: "Select a reason (optional)"
|
|
@@ -679,106 +717,101 @@ var Ke = [
|
|
|
679
717
|
label: "Other"
|
|
680
718
|
}
|
|
681
719
|
];
|
|
682
|
-
function
|
|
683
|
-
let
|
|
684
|
-
if (
|
|
685
|
-
let n =
|
|
686
|
-
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;
|
|
687
725
|
let r = t?.current;
|
|
688
726
|
if (!r) return;
|
|
689
727
|
let i = r.getRootNode();
|
|
690
728
|
r.contains(i.activeElement) || r.focus();
|
|
691
|
-
}, [e.status, t]), e.status === "
|
|
692
|
-
class: "whoo-widget-feedback-submitted",
|
|
693
|
-
role: "status",
|
|
694
|
-
children: "Thanks for the feedback"
|
|
695
|
-
});
|
|
696
|
-
if (e.status === "expanded") return /* @__PURE__ */ U("div", {
|
|
729
|
+
}, [e.status, t]), e.status === "expanded") return /* @__PURE__ */ V("div", {
|
|
697
730
|
class: "whoo-widget-feedback-form",
|
|
698
731
|
children: [
|
|
699
|
-
/* @__PURE__ */
|
|
732
|
+
/* @__PURE__ */ V("label", { children: [/* @__PURE__ */ V("span", {
|
|
700
733
|
class: "whoo-widget-sr-only",
|
|
701
734
|
children: "Additional feedback"
|
|
702
|
-
}), /* @__PURE__ */
|
|
735
|
+
}), /* @__PURE__ */ V("textarea", {
|
|
703
736
|
class: "whoo-widget-feedback-textarea",
|
|
704
|
-
value:
|
|
705
|
-
onInput: (e) =>
|
|
737
|
+
value: s,
|
|
738
|
+
onInput: (e) => i(e.target.value, c),
|
|
706
739
|
placeholder: "What was wrong? (optional)"
|
|
707
740
|
})] }),
|
|
708
|
-
/* @__PURE__ */
|
|
741
|
+
/* @__PURE__ */ V("select", {
|
|
709
742
|
class: "whoo-widget-feedback-select",
|
|
710
743
|
"aria-label": "Feedback category",
|
|
711
744
|
value: c,
|
|
712
|
-
onChange: (e) =>
|
|
713
|
-
children:
|
|
745
|
+
onChange: (e) => i(s, e.target.value),
|
|
746
|
+
children: Xe.map((e) => /* @__PURE__ */ V("option", {
|
|
714
747
|
value: e.value,
|
|
715
748
|
children: e.label
|
|
716
749
|
}, e.value))
|
|
717
750
|
}),
|
|
718
|
-
/* @__PURE__ */
|
|
751
|
+
/* @__PURE__ */ V("div", {
|
|
719
752
|
class: "whoo-widget-feedback-form-buttons",
|
|
720
|
-
children: [/* @__PURE__ */
|
|
753
|
+
children: [/* @__PURE__ */ V("button", {
|
|
721
754
|
type: "button",
|
|
722
755
|
class: "whoo-widget-feedback-submit",
|
|
723
|
-
onClick: () =>
|
|
756
|
+
onClick: () => a(s, c),
|
|
724
757
|
children: "Submit"
|
|
725
|
-
}), /* @__PURE__ */
|
|
758
|
+
}), /* @__PURE__ */ V("button", {
|
|
726
759
|
type: "button",
|
|
727
760
|
class: "whoo-widget-feedback-cancel",
|
|
728
|
-
onClick:
|
|
761
|
+
onClick: o,
|
|
729
762
|
children: "Cancel"
|
|
730
763
|
})]
|
|
731
764
|
})
|
|
732
765
|
]
|
|
733
766
|
});
|
|
734
|
-
let
|
|
735
|
-
return /* @__PURE__ */
|
|
767
|
+
let u = e.status === "submitting", d = e.status === "submitted";
|
|
768
|
+
return /* @__PURE__ */ V("div", {
|
|
736
769
|
class: "whoo-widget-feedback",
|
|
737
|
-
children: [/* @__PURE__ */
|
|
770
|
+
children: [d ? null : /* @__PURE__ */ V("div", {
|
|
738
771
|
class: "whoo-widget-feedback-buttons",
|
|
739
|
-
children: [/* @__PURE__ */
|
|
772
|
+
children: [/* @__PURE__ */ V("button", {
|
|
740
773
|
type: "button",
|
|
741
774
|
"aria-label": "Good response",
|
|
742
|
-
disabled:
|
|
775
|
+
disabled: u,
|
|
743
776
|
onClick: n,
|
|
744
|
-
children: /* @__PURE__ */
|
|
745
|
-
}), /* @__PURE__ */
|
|
777
|
+
children: /* @__PURE__ */ V(Be, {})
|
|
778
|
+
}), /* @__PURE__ */ V("button", {
|
|
746
779
|
type: "button",
|
|
747
780
|
"aria-label": "Bad response",
|
|
748
|
-
disabled:
|
|
781
|
+
disabled: u,
|
|
749
782
|
onClick: r,
|
|
750
|
-
children: /* @__PURE__ */
|
|
783
|
+
children: /* @__PURE__ */ V(Ve, {})
|
|
751
784
|
})]
|
|
752
|
-
}),
|
|
753
|
-
class: "whoo-widget-feedback-error",
|
|
785
|
+
}), /* @__PURE__ */ V("div", {
|
|
754
786
|
role: "status",
|
|
755
|
-
|
|
756
|
-
|
|
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
|
+
})]
|
|
757
790
|
});
|
|
758
791
|
}
|
|
759
792
|
//#endregion
|
|
760
793
|
//#region src/components/MessageList.tsx
|
|
761
|
-
function
|
|
762
|
-
return /* @__PURE__ */
|
|
794
|
+
function Qe({ isSlowResponse: e }) {
|
|
795
|
+
return /* @__PURE__ */ V("div", {
|
|
763
796
|
class: "whoo-widget-pending",
|
|
764
797
|
role: "status",
|
|
765
|
-
children: [/* @__PURE__ */
|
|
798
|
+
children: [/* @__PURE__ */ V("span", {
|
|
766
799
|
class: "whoo-widget-typing",
|
|
767
800
|
"aria-hidden": "true",
|
|
768
801
|
children: [
|
|
769
|
-
/* @__PURE__ */
|
|
770
|
-
/* @__PURE__ */
|
|
771
|
-
/* @__PURE__ */
|
|
802
|
+
/* @__PURE__ */ V("span", {}),
|
|
803
|
+
/* @__PURE__ */ V("span", {}),
|
|
804
|
+
/* @__PURE__ */ V("span", {})
|
|
772
805
|
]
|
|
773
|
-
}), e ? /* @__PURE__ */
|
|
806
|
+
}), e ? /* @__PURE__ */ V("span", {
|
|
774
807
|
class: "whoo-widget-pending-text",
|
|
775
808
|
children: "Looking that up for you…"
|
|
776
809
|
}) : null]
|
|
777
810
|
});
|
|
778
811
|
}
|
|
779
|
-
function
|
|
780
|
-
let [n, r] =
|
|
781
|
-
return n ? null : /* @__PURE__ */
|
|
812
|
+
function $e({ url: e, alt: t }) {
|
|
813
|
+
let [n, r] = Ee(!1);
|
|
814
|
+
return n ? null : /* @__PURE__ */ V("img", {
|
|
782
815
|
class: "whoo-widget-empty-state-image",
|
|
783
816
|
src: e,
|
|
784
817
|
alt: t,
|
|
@@ -786,42 +819,54 @@ function Ye({ url: e, alt: t }) {
|
|
|
786
819
|
onError: () => r(!0)
|
|
787
820
|
});
|
|
788
821
|
}
|
|
789
|
-
function
|
|
790
|
-
let
|
|
791
|
-
return /* @__PURE__ */
|
|
792
|
-
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,
|
|
793
826
|
tabIndex: -1,
|
|
794
827
|
class: `whoo-widget-message whoo-widget-message--${e.role}`,
|
|
795
|
-
children: [
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
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
|
+
]
|
|
803
844
|
});
|
|
804
845
|
}
|
|
805
|
-
function
|
|
806
|
-
let
|
|
807
|
-
return
|
|
808
|
-
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;
|
|
809
850
|
e && (e.scrollTop = e.scrollHeight);
|
|
810
|
-
}, [e,
|
|
851
|
+
}, [e, s]), /* @__PURE__ */ V(E, { children: [/* @__PURE__ */ V("section", {
|
|
811
852
|
class: "whoo-widget-message-list",
|
|
812
|
-
ref:
|
|
813
|
-
|
|
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, {
|
|
814
857
|
message: n,
|
|
815
|
-
|
|
858
|
+
speaker: n.role === "user" ? "You" : i,
|
|
859
|
+
showFeedback: a,
|
|
816
860
|
feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
|
|
817
|
-
pending:
|
|
818
|
-
isSlowResponse:
|
|
819
|
-
onThumbsUp:
|
|
820
|
-
onThumbsDown:
|
|
821
|
-
|
|
822
|
-
|
|
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
|
|
823
868
|
}, n.id ?? r))]
|
|
824
|
-
}), /* @__PURE__ */
|
|
869
|
+
}), /* @__PURE__ */ V("div", {
|
|
825
870
|
class: "whoo-widget-sr-only",
|
|
826
871
|
"aria-live": "polite",
|
|
827
872
|
"aria-atomic": "true",
|
|
@@ -830,110 +875,114 @@ function Ze({ messages: e, messageFeedback: t, lastCompletedMessageText: n, empt
|
|
|
830
875
|
}
|
|
831
876
|
//#endregion
|
|
832
877
|
//#region src/components/Panel.tsx
|
|
833
|
-
var
|
|
834
|
-
function
|
|
835
|
-
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) => {
|
|
836
881
|
let t = getComputedStyle(e);
|
|
837
882
|
return t.display !== "none" && t.visibility !== "hidden";
|
|
838
883
|
});
|
|
839
884
|
}
|
|
840
|
-
function
|
|
841
|
-
let
|
|
842
|
-
|
|
843
|
-
|
|
885
|
+
function it({ state: e, controller: t, greeting: n }) {
|
|
886
|
+
let i = z(null), a = z(null);
|
|
887
|
+
R(() => {
|
|
888
|
+
a.current?.focus();
|
|
844
889
|
}, []);
|
|
845
|
-
let
|
|
890
|
+
let o = (e) => {
|
|
846
891
|
if (e.key === "Escape") {
|
|
847
892
|
t.close();
|
|
848
893
|
return;
|
|
849
894
|
}
|
|
850
895
|
if (e.key !== "Tab") return;
|
|
851
|
-
let n =
|
|
896
|
+
let n = i.current;
|
|
852
897
|
if (!n) return;
|
|
853
|
-
let
|
|
854
|
-
if (
|
|
855
|
-
let a =
|
|
898
|
+
let r = rt(n);
|
|
899
|
+
if (r.length === 0) return;
|
|
900
|
+
let a = r[0], o = r[r.length - 1], s = n.getRootNode().activeElement;
|
|
856
901
|
if (!n.contains(s)) {
|
|
857
902
|
e.preventDefault(), a.focus();
|
|
858
903
|
return;
|
|
859
904
|
}
|
|
860
905
|
e.shiftKey && s === a ? (e.preventDefault(), o.focus()) : !e.shiftKey && s === o && (e.preventDefault(), a.focus());
|
|
861
|
-
},
|
|
906
|
+
}, s = () => {
|
|
862
907
|
let n = e.draft.trim();
|
|
863
908
|
n && !e.isStreaming && (t.setDraft(""), t.sendMessage(n));
|
|
864
|
-
},
|
|
909
|
+
}, c = r(t.config.name) || e.agentName || "Aiden", l = `Chat with ${c}`, u = e.messages.length === 0 && n ? [{
|
|
865
910
|
role: "assistant",
|
|
866
911
|
content: n,
|
|
867
912
|
id: null
|
|
868
|
-
}] : e.messages,
|
|
869
|
-
url:
|
|
913
|
+
}] : e.messages, d = t.emptyStateImageUrl, f = e.messages.length === 0 && d ? {
|
|
914
|
+
url: d,
|
|
870
915
|
alt: t.emptyStateImageAlt
|
|
871
916
|
} : void 0;
|
|
872
|
-
return /* @__PURE__ */
|
|
917
|
+
return /* @__PURE__ */ V("div", {
|
|
873
918
|
class: "whoo-widget-panel",
|
|
874
919
|
role: "dialog",
|
|
875
920
|
"aria-modal": "true",
|
|
876
|
-
"aria-label":
|
|
877
|
-
ref:
|
|
878
|
-
onKeyDown:
|
|
921
|
+
"aria-label": l,
|
|
922
|
+
ref: i,
|
|
923
|
+
onKeyDown: o,
|
|
879
924
|
children: [
|
|
880
|
-
/* @__PURE__ */
|
|
925
|
+
/* @__PURE__ */ V("div", {
|
|
881
926
|
class: "whoo-widget-header",
|
|
882
|
-
children: [/* @__PURE__ */
|
|
927
|
+
children: [/* @__PURE__ */ V("h2", {
|
|
883
928
|
class: "whoo-widget-header-title",
|
|
884
|
-
children:
|
|
885
|
-
}), /* @__PURE__ */
|
|
929
|
+
children: l
|
|
930
|
+
}), /* @__PURE__ */ V("div", {
|
|
886
931
|
class: "whoo-widget-header-actions",
|
|
887
|
-
children: [e.messages.length > 0 && /* @__PURE__ */
|
|
932
|
+
children: [e.messages.length > 0 && /* @__PURE__ */ V("button", {
|
|
888
933
|
type: "button",
|
|
889
934
|
class: "whoo-widget-header-reset",
|
|
890
|
-
onClick: () =>
|
|
935
|
+
onClick: () => {
|
|
936
|
+
t.resetConversation(), a.current?.focus();
|
|
937
|
+
},
|
|
891
938
|
children: "New conversation"
|
|
892
|
-
}), /* @__PURE__ */
|
|
939
|
+
}), /* @__PURE__ */ V("button", {
|
|
893
940
|
type: "button",
|
|
894
941
|
class: "whoo-widget-header-close",
|
|
895
942
|
"aria-label": "Close chat",
|
|
896
943
|
onClick: () => t.close(),
|
|
897
|
-
children: /* @__PURE__ */
|
|
944
|
+
children: /* @__PURE__ */ V(Re, {})
|
|
898
945
|
})]
|
|
899
946
|
})]
|
|
900
947
|
}),
|
|
901
|
-
/* @__PURE__ */
|
|
902
|
-
messages:
|
|
948
|
+
/* @__PURE__ */ V(tt, {
|
|
949
|
+
messages: u,
|
|
903
950
|
messageFeedback: e.messageFeedback,
|
|
904
|
-
|
|
905
|
-
emptyStateImage:
|
|
951
|
+
announcement: e.announcement,
|
|
952
|
+
emptyStateImage: f,
|
|
953
|
+
agentName: c,
|
|
906
954
|
showFeedback: t.showFeedback,
|
|
907
955
|
isStreaming: e.isStreaming,
|
|
908
956
|
isSlowResponse: e.isSlowResponse,
|
|
909
957
|
onThumbsUp: (e) => t.submitFeedback(e, "up"),
|
|
910
958
|
onThumbsDown: (e) => t.expandFeedback(e),
|
|
959
|
+
onDraftChange: (e, n, r) => t.setFeedbackDraft(e, n, r),
|
|
911
960
|
onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
|
|
912
961
|
onCancelFeedback: (e) => t.cancelFeedback(e)
|
|
913
962
|
}),
|
|
914
|
-
e.runtimeError && /* @__PURE__ */
|
|
915
|
-
/* @__PURE__ */
|
|
963
|
+
e.runtimeError && /* @__PURE__ */ V(We, { message: e.runtimeError }),
|
|
964
|
+
/* @__PURE__ */ V(Ue, {
|
|
916
965
|
value: e.draft,
|
|
917
966
|
onChange: (e) => t.setDraft(e),
|
|
918
|
-
onSend:
|
|
967
|
+
onSend: s,
|
|
919
968
|
disabled: e.isStreaming,
|
|
920
|
-
inputRef:
|
|
969
|
+
inputRef: a
|
|
921
970
|
})
|
|
922
971
|
]
|
|
923
972
|
});
|
|
924
973
|
}
|
|
925
974
|
//#endregion
|
|
926
975
|
//#region src/components/App.tsx
|
|
927
|
-
function
|
|
928
|
-
let [t, n] =
|
|
929
|
-
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(() => {
|
|
930
979
|
i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
|
|
931
|
-
}, [t.isOpen]), t.initError ? null : /* @__PURE__ */
|
|
980
|
+
}, [t.isOpen]), t.initError ? null : /* @__PURE__ */ V(E, { children: [/* @__PURE__ */ V(He, {
|
|
932
981
|
isOpen: t.isOpen,
|
|
933
982
|
onClick: () => t.isOpen ? e.close() : e.open(),
|
|
934
983
|
iconUrl: e.launcherIconUrl,
|
|
935
984
|
buttonRef: r
|
|
936
|
-
}), t.isOpen && /* @__PURE__ */
|
|
985
|
+
}), t.isOpen && /* @__PURE__ */ V(it, {
|
|
937
986
|
state: t,
|
|
938
987
|
controller: e,
|
|
939
988
|
greeting: e.config.greeting
|
|
@@ -941,34 +990,44 @@ function tt({ controller: e }) {
|
|
|
941
990
|
}
|
|
942
991
|
//#endregion
|
|
943
992
|
//#region src/api/client.ts
|
|
944
|
-
var
|
|
993
|
+
var X = class extends Error {
|
|
945
994
|
status;
|
|
946
995
|
constructor(e, t) {
|
|
947
996
|
super(e), this.name = "WidgetApiError", this.status = t;
|
|
948
997
|
}
|
|
949
998
|
};
|
|
950
|
-
function
|
|
999
|
+
function Z(e) {
|
|
951
1000
|
if (typeof e != "string") return null;
|
|
952
1001
|
let t = e.trim();
|
|
953
1002
|
return t === "" ? null : t;
|
|
954
1003
|
}
|
|
955
|
-
async function
|
|
1004
|
+
async function ot(e, t) {
|
|
956
1005
|
let n = await fetch(`${e}/api/v1/widget/session`, {
|
|
957
1006
|
method: "POST",
|
|
958
1007
|
headers: { "Content-Type": "application/json" },
|
|
959
1008
|
body: JSON.stringify({ publishable_key: t })
|
|
960
1009
|
});
|
|
961
|
-
if (!n.ok) throw new
|
|
1010
|
+
if (!n.ok) throw new X(`Failed to create widget session (${n.status})`, n.status);
|
|
962
1011
|
let r = await n.json();
|
|
963
1012
|
return {
|
|
964
1013
|
token: r.token,
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
1014
|
+
...st(r)
|
|
1015
|
+
};
|
|
1016
|
+
}
|
|
1017
|
+
function st(e) {
|
|
1018
|
+
return {
|
|
1019
|
+
primaryColor: Z(e.primary_color),
|
|
1020
|
+
name: Z(e.name),
|
|
1021
|
+
accentColor: Z(e.accent_color),
|
|
1022
|
+
inkColor: Z(e.ink_color)
|
|
969
1023
|
};
|
|
970
1024
|
}
|
|
971
|
-
async function
|
|
1025
|
+
async function ct(e, t) {
|
|
1026
|
+
let n = await fetch(`${e}/api/v1/widget/branding`, { headers: { Authorization: `Bearer ${t}` } });
|
|
1027
|
+
if (!n.ok) throw new X(`Failed to load widget branding (${n.status})`, n.status);
|
|
1028
|
+
return st(await n.json());
|
|
1029
|
+
}
|
|
1030
|
+
async function lt(e, t, n) {
|
|
972
1031
|
let r = await fetch(`${e}/api/v1/widget/feedback`, {
|
|
973
1032
|
method: "POST",
|
|
974
1033
|
headers: {
|
|
@@ -982,11 +1041,11 @@ async function at(e, t, n) {
|
|
|
982
1041
|
category: n.category ?? null
|
|
983
1042
|
})
|
|
984
1043
|
});
|
|
985
|
-
if (!r.ok) throw new
|
|
1044
|
+
if (!r.ok) throw new X(`Feedback submission failed (${r.status})`, r.status);
|
|
986
1045
|
}
|
|
987
1046
|
//#endregion
|
|
988
1047
|
//#region src/api/sse.ts
|
|
989
|
-
async function*
|
|
1048
|
+
async function* ut(e, t, n, r, i) {
|
|
990
1049
|
let a = await fetch(`${e}/api/v1/widget/chat`, {
|
|
991
1050
|
method: "POST",
|
|
992
1051
|
headers: {
|
|
@@ -999,7 +1058,7 @@ async function* ot(e, t, n, r, i) {
|
|
|
999
1058
|
}),
|
|
1000
1059
|
signal: i
|
|
1001
1060
|
});
|
|
1002
|
-
if (!a.ok || !a.body) throw new
|
|
1061
|
+
if (!a.ok || !a.body) throw new X(`Chat request failed (${a.status})`, a.status);
|
|
1003
1062
|
let o = a.body.getReader(), s = new TextDecoder(), c = "";
|
|
1004
1063
|
for (;;) {
|
|
1005
1064
|
let { done: e, value: t } = await o.read();
|
|
@@ -1010,11 +1069,11 @@ async function* ot(e, t, n, r, i) {
|
|
|
1010
1069
|
let e = c.slice(0, n);
|
|
1011
1070
|
c = c.slice(n + 2);
|
|
1012
1071
|
let t = e.split("\n").find((e) => e.startsWith("data: "));
|
|
1013
|
-
t && (yield
|
|
1072
|
+
t && (yield dt(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
|
|
1014
1073
|
}
|
|
1015
1074
|
}
|
|
1016
1075
|
}
|
|
1017
|
-
function
|
|
1076
|
+
function dt(e) {
|
|
1018
1077
|
return typeof e.error == "string" ? {
|
|
1019
1078
|
type: "error",
|
|
1020
1079
|
error: e.error,
|
|
@@ -1037,7 +1096,7 @@ function st(e) {
|
|
|
1037
1096
|
}
|
|
1038
1097
|
//#endregion
|
|
1039
1098
|
//#region src/imageUrl.ts
|
|
1040
|
-
function
|
|
1099
|
+
function ft(e, t) {
|
|
1041
1100
|
if (e != null && e !== "") {
|
|
1042
1101
|
if (typeof e == "string") try {
|
|
1043
1102
|
let t = new URL(e);
|
|
@@ -1047,17 +1106,29 @@ function ct(e, t) {
|
|
|
1047
1106
|
}
|
|
1048
1107
|
}
|
|
1049
1108
|
//#endregion
|
|
1109
|
+
//#region src/markdown/plainText.ts
|
|
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
|
|
1050
1121
|
//#region src/markdown/reveal.ts
|
|
1051
|
-
var
|
|
1052
|
-
function
|
|
1122
|
+
var mt = 40, ht = 120;
|
|
1123
|
+
function gt(e) {
|
|
1053
1124
|
let t = [];
|
|
1054
|
-
for (let n of
|
|
1125
|
+
for (let n of J(e)) if (n.type === "text") {
|
|
1055
1126
|
let e = n.value.split(/(\s+)/), r = n.start;
|
|
1056
1127
|
for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
|
|
1057
1128
|
} else t.push(n.end);
|
|
1058
1129
|
return t;
|
|
1059
1130
|
}
|
|
1060
|
-
function
|
|
1131
|
+
function _t(e) {
|
|
1061
1132
|
let t = null;
|
|
1062
1133
|
return e?.addEventListener("abort", () => {
|
|
1063
1134
|
t?.();
|
|
@@ -1072,36 +1143,154 @@ function ft(e) {
|
|
|
1072
1143
|
});
|
|
1073
1144
|
};
|
|
1074
1145
|
}
|
|
1075
|
-
async function
|
|
1076
|
-
let r = n?.wordIntervalMs ??
|
|
1077
|
-
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;
|
|
1078
1149
|
l !== e && t(e);
|
|
1079
1150
|
}
|
|
1080
1151
|
//#endregion
|
|
1081
1152
|
//#region src/storage.ts
|
|
1082
|
-
function
|
|
1153
|
+
function yt(e) {
|
|
1083
1154
|
return `whoo-aiden-widget:conversation:${e}`;
|
|
1084
1155
|
}
|
|
1085
|
-
function
|
|
1156
|
+
function bt(e) {
|
|
1086
1157
|
try {
|
|
1087
|
-
return window.sessionStorage.getItem(
|
|
1158
|
+
return window.sessionStorage.getItem(yt(e));
|
|
1088
1159
|
} catch {
|
|
1089
1160
|
return null;
|
|
1090
1161
|
}
|
|
1091
1162
|
}
|
|
1092
|
-
function
|
|
1163
|
+
function xt(e, t) {
|
|
1093
1164
|
try {
|
|
1094
|
-
window.sessionStorage.setItem(
|
|
1165
|
+
window.sessionStorage.setItem(yt(e), t);
|
|
1095
1166
|
} catch {}
|
|
1096
1167
|
}
|
|
1097
|
-
function
|
|
1168
|
+
function St(e) {
|
|
1098
1169
|
try {
|
|
1099
|
-
window.sessionStorage.removeItem(
|
|
1170
|
+
window.sessionStorage.removeItem(yt(e));
|
|
1100
1171
|
} catch {}
|
|
1101
1172
|
}
|
|
1102
1173
|
//#endregion
|
|
1174
|
+
//#region src/theme.ts
|
|
1175
|
+
var Ct = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
|
|
1176
|
+
function wt(e) {
|
|
1177
|
+
if (Ct.test(e.trim())) return null;
|
|
1178
|
+
let t = document.createElement("div");
|
|
1179
|
+
if (t.style.color = e, t.style.color === "") return null;
|
|
1180
|
+
let n = document.createElement("div");
|
|
1181
|
+
n.attachShadow({ mode: "open" }).appendChild(t), document.body.appendChild(n);
|
|
1182
|
+
let r = getComputedStyle(t).color;
|
|
1183
|
+
n.remove();
|
|
1184
|
+
let i = r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);
|
|
1185
|
+
if (!i) return null;
|
|
1186
|
+
let a = i[4] === void 0 ? 1 : Number(i[4]);
|
|
1187
|
+
return {
|
|
1188
|
+
rgb: [
|
|
1189
|
+
Number(i[1]),
|
|
1190
|
+
Number(i[2]),
|
|
1191
|
+
Number(i[3])
|
|
1192
|
+
].map((e) => Math.round(e * a + 255 * (1 - a))),
|
|
1193
|
+
translucent: a < 1
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
function Tt(e) {
|
|
1197
|
+
return wt(e)?.rgb ?? null;
|
|
1198
|
+
}
|
|
1199
|
+
function Q([e, t, n]) {
|
|
1200
|
+
let r = (e) => {
|
|
1201
|
+
let t = e / 255;
|
|
1202
|
+
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
1203
|
+
};
|
|
1204
|
+
return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
|
|
1205
|
+
}
|
|
1206
|
+
function Et(e, t) {
|
|
1207
|
+
let n = Math.max(e, t), r = Math.min(e, t);
|
|
1208
|
+
return (n + .05) / (r + .05);
|
|
1209
|
+
}
|
|
1210
|
+
function Dt(e) {
|
|
1211
|
+
let t = Tt(e);
|
|
1212
|
+
if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
|
|
1213
|
+
let n = Q(t);
|
|
1214
|
+
return Et(n, Q([
|
|
1215
|
+
0,
|
|
1216
|
+
0,
|
|
1217
|
+
0
|
|
1218
|
+
])) >= Et(n, Q([
|
|
1219
|
+
255,
|
|
1220
|
+
255,
|
|
1221
|
+
255
|
|
1222
|
+
])) ? "#000000" : "#ffffff";
|
|
1223
|
+
}
|
|
1224
|
+
var Ot = "#4f46e5", kt = "#ffffff", At = "#f0f0f0", jt = "#f3f4f6", Mt = 4.5;
|
|
1225
|
+
function Nt([e, t, n]) {
|
|
1226
|
+
return `#${[
|
|
1227
|
+
e,
|
|
1228
|
+
t,
|
|
1229
|
+
n
|
|
1230
|
+
].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
1231
|
+
}
|
|
1232
|
+
function Pt(e, t = kt) {
|
|
1233
|
+
let n = Tt(e), r = Tt(t);
|
|
1234
|
+
if (!n || !r) return Ot;
|
|
1235
|
+
let i = Q(r), a = (e) => Et(Q(e), i) >= Mt;
|
|
1236
|
+
if (a(n)) return Nt(n);
|
|
1237
|
+
for (let e = .99; e > 0; e -= .01) {
|
|
1238
|
+
let t = n.map((t) => Math.round(t * e));
|
|
1239
|
+
if (a(t)) return Nt(t);
|
|
1240
|
+
}
|
|
1241
|
+
return "#000000";
|
|
1242
|
+
}
|
|
1243
|
+
var Ft = "#111111", It = "#0000ee";
|
|
1244
|
+
function $(e) {
|
|
1245
|
+
if (typeof e != "string" || !e) return null;
|
|
1246
|
+
let t = wt(e);
|
|
1247
|
+
return t ? Nt(t.rgb) : null;
|
|
1248
|
+
}
|
|
1249
|
+
function Lt({ color: e, inkColor: t, accentColor: n }) {
|
|
1250
|
+
let r = $(e), i = r ?? Ot, a = Pt(i, jt), o = $(t), s = o ? Pt(o, At) : Ft, c = $(n), l = c ? Pt(c, At) : It;
|
|
1251
|
+
return {
|
|
1252
|
+
primary: i,
|
|
1253
|
+
textOnPrimary: Dt(i),
|
|
1254
|
+
primaryAsText: a,
|
|
1255
|
+
ink: s,
|
|
1256
|
+
link: l,
|
|
1257
|
+
adjusted: {
|
|
1258
|
+
primary: r !== null && a !== i,
|
|
1259
|
+
ink: o !== null && s !== o,
|
|
1260
|
+
link: c !== null && l !== c
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
}
|
|
1264
|
+
function Rt(e) {
|
|
1265
|
+
return typeof e == "string" ? `"${e}"` : `a ${typeof e} value`;
|
|
1266
|
+
}
|
|
1267
|
+
function zt(e, t, n = Ot) {
|
|
1268
|
+
let r = t;
|
|
1269
|
+
$(t) === null && (console.warn(`[whoo-aiden-widget] Could not use ${Rt(t)} as the theme color; falling back to ${Rt(n)}.`), r = n);
|
|
1270
|
+
let i = Lt({ color: r });
|
|
1271
|
+
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);
|
|
1272
|
+
}
|
|
1273
|
+
function Bt(e, { inkColor: t, accentColor: n }) {
|
|
1274
|
+
let r = Lt({
|
|
1275
|
+
inkColor: t,
|
|
1276
|
+
accentColor: n
|
|
1277
|
+
});
|
|
1278
|
+
e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
|
|
1279
|
+
}
|
|
1280
|
+
function Vt(e, t) {
|
|
1281
|
+
e && $(e) === null && console.warn(`[whoo-aiden-widget] Could not use ${Rt(e)} as the ${t}; using the default.`);
|
|
1282
|
+
}
|
|
1283
|
+
function Ht(e, t) {
|
|
1284
|
+
zt(e, t.color ?? Ot), Vt(t.inkColor, "ink color"), Vt(t.accentColor, "accent color"), Bt(e, {
|
|
1285
|
+
inkColor: t.inkColor,
|
|
1286
|
+
accentColor: t.accentColor
|
|
1287
|
+
});
|
|
1288
|
+
let n = t.position === "bottom-left";
|
|
1289
|
+
e.style.setProperty("--whoo-widget-inset-left", n ? "20px" : "auto"), e.style.setProperty("--whoo-widget-inset-right", n ? "auto" : "20px");
|
|
1290
|
+
}
|
|
1291
|
+
//#endregion
|
|
1103
1292
|
//#region src/controller.ts
|
|
1104
|
-
var
|
|
1293
|
+
var Ut = 8e3, Wt = class {
|
|
1105
1294
|
config;
|
|
1106
1295
|
state;
|
|
1107
1296
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -1116,7 +1305,7 @@ var vt = 8e3, yt = class {
|
|
|
1116
1305
|
emptyStateImageAlt;
|
|
1117
1306
|
showFeedback;
|
|
1118
1307
|
constructor(e) {
|
|
1119
|
-
this.config = e, this.launcherIconUrl =
|
|
1308
|
+
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 = {
|
|
1120
1309
|
isOpen: !1,
|
|
1121
1310
|
messages: [],
|
|
1122
1311
|
isStreaming: !1,
|
|
@@ -1127,7 +1316,7 @@ var vt = 8e3, yt = class {
|
|
|
1127
1316
|
agentName: null,
|
|
1128
1317
|
accentColor: null,
|
|
1129
1318
|
inkColor: null,
|
|
1130
|
-
|
|
1319
|
+
announcement: null,
|
|
1131
1320
|
isSlowResponse: !1,
|
|
1132
1321
|
draft: ""
|
|
1133
1322
|
};
|
|
@@ -1153,7 +1342,7 @@ var vt = 8e3, yt = class {
|
|
|
1153
1342
|
try {
|
|
1154
1343
|
if (this.config.sessionToken) this.sessionToken = this.config.sessionToken;
|
|
1155
1344
|
else if (this.config.publishableKey) {
|
|
1156
|
-
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await
|
|
1345
|
+
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await ot(e, this.config.publishableKey);
|
|
1157
1346
|
this.sessionToken = t, this.setState({
|
|
1158
1347
|
primaryColor: n,
|
|
1159
1348
|
agentName: r,
|
|
@@ -1165,18 +1354,31 @@ var vt = 8e3, yt = class {
|
|
|
1165
1354
|
console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
|
|
1166
1355
|
return;
|
|
1167
1356
|
}
|
|
1168
|
-
this.conversationId =
|
|
1357
|
+
this.conversationId = bt(this.storageIdentifier), this.config.sessionToken && await this.loadBranding(e, this.config.sessionToken);
|
|
1358
|
+
}
|
|
1359
|
+
async loadBranding(e, t) {
|
|
1360
|
+
try {
|
|
1361
|
+
let n = this.config;
|
|
1362
|
+
if ($(n.color) && $(n.inkColor) && $(n.accentColor) && r(n.name)) return;
|
|
1363
|
+
let { primaryColor: i, name: a, accentColor: o, inkColor: s } = await ct(e, t);
|
|
1364
|
+
this.setState({
|
|
1365
|
+
primaryColor: i,
|
|
1366
|
+
agentName: a,
|
|
1367
|
+
accentColor: o,
|
|
1368
|
+
inkColor: s
|
|
1369
|
+
});
|
|
1370
|
+
} catch {}
|
|
1169
1371
|
}
|
|
1170
1372
|
open() {
|
|
1171
1373
|
this.setState({ isOpen: !0 });
|
|
1172
1374
|
}
|
|
1173
1375
|
resetConversation() {
|
|
1174
|
-
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null,
|
|
1376
|
+
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, St(this.storageIdentifier), this.setState({
|
|
1175
1377
|
messages: [],
|
|
1176
1378
|
messageFeedback: {},
|
|
1177
1379
|
runtimeError: null,
|
|
1178
1380
|
isStreaming: !1,
|
|
1179
|
-
|
|
1381
|
+
announcement: "Conversation cleared"
|
|
1180
1382
|
});
|
|
1181
1383
|
}
|
|
1182
1384
|
setDraft(e) {
|
|
@@ -1203,7 +1405,8 @@ var vt = 8e3, yt = class {
|
|
|
1203
1405
|
r
|
|
1204
1406
|
],
|
|
1205
1407
|
isStreaming: !0,
|
|
1206
|
-
runtimeError: null
|
|
1408
|
+
runtimeError: null,
|
|
1409
|
+
announcement: null
|
|
1207
1410
|
});
|
|
1208
1411
|
let i = (e) => {
|
|
1209
1412
|
let t = [...this.state.messages];
|
|
@@ -1216,7 +1419,7 @@ var vt = 8e3, yt = class {
|
|
|
1216
1419
|
let { signal: a } = this.activeRequestController;
|
|
1217
1420
|
this.slowResponseTimer = setTimeout(() => {
|
|
1218
1421
|
this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
|
|
1219
|
-
},
|
|
1422
|
+
}, Ut);
|
|
1220
1423
|
let o = () => {
|
|
1221
1424
|
this.setState({
|
|
1222
1425
|
runtimeError: "Something went wrong, please try again.",
|
|
@@ -1224,17 +1427,17 @@ var vt = 8e3, yt = class {
|
|
|
1224
1427
|
});
|
|
1225
1428
|
}, s = "";
|
|
1226
1429
|
try {
|
|
1227
|
-
for await (let n of
|
|
1228
|
-
else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await
|
|
1430
|
+
for await (let n of ut(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, xt(this.storageIdentifier, n.conversationId);
|
|
1431
|
+
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));
|
|
1229
1432
|
else if (n.type === "done") {
|
|
1230
|
-
if (n.conversationId && (this.conversationId = n.conversationId,
|
|
1433
|
+
if (n.conversationId && (this.conversationId = n.conversationId, xt(this.storageIdentifier, n.conversationId)), n.messageId) {
|
|
1231
1434
|
let e = [...this.state.messages];
|
|
1232
1435
|
e[e.length - 1] = {
|
|
1233
1436
|
...e[e.length - 1],
|
|
1234
1437
|
id: n.messageId
|
|
1235
1438
|
}, this.setState({ messages: e });
|
|
1236
1439
|
}
|
|
1237
|
-
this.setState({
|
|
1440
|
+
this.setState({ announcement: pt(s) });
|
|
1238
1441
|
} else if (n.type === "error") {
|
|
1239
1442
|
console.error("[whoo-aiden-widget] chat error:", n.error), o(), this.activeRequestController?.abort();
|
|
1240
1443
|
break;
|
|
@@ -1246,9 +1449,24 @@ var vt = 8e3, yt = class {
|
|
|
1246
1449
|
}
|
|
1247
1450
|
}
|
|
1248
1451
|
expandFeedback(e) {
|
|
1452
|
+
let { correction: t, category: n } = this.state.messageFeedback[e] ?? {};
|
|
1249
1453
|
this.setState({ messageFeedback: {
|
|
1250
1454
|
...this.state.messageFeedback,
|
|
1251
|
-
[e]: {
|
|
1455
|
+
[e]: {
|
|
1456
|
+
status: "expanded",
|
|
1457
|
+
correction: t,
|
|
1458
|
+
category: n
|
|
1459
|
+
}
|
|
1460
|
+
} });
|
|
1461
|
+
}
|
|
1462
|
+
setFeedbackDraft(e, t, n) {
|
|
1463
|
+
this.setState({ messageFeedback: {
|
|
1464
|
+
...this.state.messageFeedback,
|
|
1465
|
+
[e]: {
|
|
1466
|
+
...this.state.messageFeedback[e],
|
|
1467
|
+
correction: t,
|
|
1468
|
+
category: n
|
|
1469
|
+
}
|
|
1252
1470
|
} });
|
|
1253
1471
|
}
|
|
1254
1472
|
cancelFeedback(e) {
|
|
@@ -1268,7 +1486,7 @@ var vt = 8e3, yt = class {
|
|
|
1268
1486
|
}
|
|
1269
1487
|
} });
|
|
1270
1488
|
try {
|
|
1271
|
-
await
|
|
1489
|
+
await lt(i, this.sessionToken, {
|
|
1272
1490
|
messageId: e,
|
|
1273
1491
|
rating: t,
|
|
1274
1492
|
correction: n,
|
|
@@ -1280,154 +1498,44 @@ var vt = 8e3, yt = class {
|
|
|
1280
1498
|
rating: t
|
|
1281
1499
|
}
|
|
1282
1500
|
} });
|
|
1283
|
-
} catch (
|
|
1284
|
-
console.error("[whoo-aiden-widget] feedback submission failed:",
|
|
1501
|
+
} catch (i) {
|
|
1502
|
+
console.error("[whoo-aiden-widget] feedback submission failed:", i), this.setState({ messageFeedback: {
|
|
1285
1503
|
...this.state.messageFeedback,
|
|
1286
1504
|
[e]: {
|
|
1287
1505
|
status: "error",
|
|
1288
|
-
rating: t
|
|
1506
|
+
rating: t,
|
|
1507
|
+
correction: n,
|
|
1508
|
+
category: r
|
|
1289
1509
|
}
|
|
1290
1510
|
} });
|
|
1291
1511
|
}
|
|
1292
1512
|
}
|
|
1293
|
-
},
|
|
1294
|
-
function St(e) {
|
|
1295
|
-
if (xt.test(e.trim())) return null;
|
|
1296
|
-
let t = document.createElement("div");
|
|
1297
|
-
if (t.style.color = e, t.style.color === "") return null;
|
|
1298
|
-
let n = document.createElement("div");
|
|
1299
|
-
n.attachShadow({ mode: "open" }).appendChild(t), document.body.appendChild(n);
|
|
1300
|
-
let r = getComputedStyle(t).color;
|
|
1301
|
-
n.remove();
|
|
1302
|
-
let i = r.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*([\d.]+))?/);
|
|
1303
|
-
if (!i) return null;
|
|
1304
|
-
let a = i[4] === void 0 ? 1 : Number(i[4]);
|
|
1305
|
-
return {
|
|
1306
|
-
rgb: [
|
|
1307
|
-
Number(i[1]),
|
|
1308
|
-
Number(i[2]),
|
|
1309
|
-
Number(i[3])
|
|
1310
|
-
].map((e) => Math.round(e * a + 255 * (1 - a))),
|
|
1311
|
-
translucent: a < 1
|
|
1312
|
-
};
|
|
1313
|
-
}
|
|
1314
|
-
function Ct(e) {
|
|
1315
|
-
return St(e)?.rgb ?? null;
|
|
1316
|
-
}
|
|
1317
|
-
function X([e, t, n]) {
|
|
1318
|
-
let r = (e) => {
|
|
1319
|
-
let t = e / 255;
|
|
1320
|
-
return t <= .03928 ? t / 12.92 : ((t + .055) / 1.055) ** 2.4;
|
|
1321
|
-
};
|
|
1322
|
-
return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
|
|
1323
|
-
}
|
|
1324
|
-
function Z(e, t) {
|
|
1325
|
-
let n = Math.max(e, t), r = Math.min(e, t);
|
|
1326
|
-
return (n + .05) / (r + .05);
|
|
1327
|
-
}
|
|
1328
|
-
function wt(e) {
|
|
1329
|
-
let t = Ct(e);
|
|
1330
|
-
if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
|
|
1331
|
-
let n = X(t);
|
|
1332
|
-
return Z(n, X([
|
|
1333
|
-
0,
|
|
1334
|
-
0,
|
|
1335
|
-
0
|
|
1336
|
-
])) >= Z(n, X([
|
|
1337
|
-
255,
|
|
1338
|
-
255,
|
|
1339
|
-
255
|
|
1340
|
-
])) ? "#000000" : "#ffffff";
|
|
1341
|
-
}
|
|
1342
|
-
var Q = "#4f46e5", Tt = "#ffffff", Et = "#f0f0f0", Dt = 4.5;
|
|
1343
|
-
function Ot([e, t, n]) {
|
|
1344
|
-
return `#${[
|
|
1345
|
-
e,
|
|
1346
|
-
t,
|
|
1347
|
-
n
|
|
1348
|
-
].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
1349
|
-
}
|
|
1350
|
-
function kt(e, t = Tt) {
|
|
1351
|
-
let n = Ct(e), r = Ct(t);
|
|
1352
|
-
if (!n || !r) return Q;
|
|
1353
|
-
let i = X(r), a = (e) => Z(X(e), i) >= Dt;
|
|
1354
|
-
if (a(n)) return Ot(n);
|
|
1355
|
-
for (let e = .99; e > 0; e -= .01) {
|
|
1356
|
-
let t = n.map((t) => Math.round(t * e));
|
|
1357
|
-
if (a(t)) return Ot(t);
|
|
1358
|
-
}
|
|
1359
|
-
return "#000000";
|
|
1360
|
-
}
|
|
1361
|
-
var At = "#111111", jt = "#0000ee";
|
|
1362
|
-
function $(e) {
|
|
1363
|
-
if (!e) return null;
|
|
1364
|
-
let t = St(e);
|
|
1365
|
-
return t ? Ot(t.rgb) : null;
|
|
1366
|
-
}
|
|
1367
|
-
function Mt({ color: e, inkColor: t, accentColor: n }) {
|
|
1368
|
-
let r = $(e), i = r ?? Q, a = kt(i), o = $(t), s = o ? kt(o, Et) : At, c = $(n), l = c ? kt(c, Et) : jt;
|
|
1369
|
-
return {
|
|
1370
|
-
primary: i,
|
|
1371
|
-
textOnPrimary: wt(i),
|
|
1372
|
-
primaryAsText: a,
|
|
1373
|
-
ink: s,
|
|
1374
|
-
link: l,
|
|
1375
|
-
adjusted: {
|
|
1376
|
-
primary: r !== null && a !== i,
|
|
1377
|
-
ink: o !== null && s !== o,
|
|
1378
|
-
link: c !== null && l !== c
|
|
1379
|
-
}
|
|
1380
|
-
};
|
|
1381
|
-
}
|
|
1382
|
-
function Nt(e, t, n = Q) {
|
|
1383
|
-
let r = t;
|
|
1384
|
-
$(t) === null && (console.warn(`[whoo-aiden-widget] Could not use "${t}" as the theme color; falling back to "${n}".`), r = n);
|
|
1385
|
-
let i = Mt({ color: r });
|
|
1386
|
-
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);
|
|
1387
|
-
}
|
|
1388
|
-
function Pt(e, { inkColor: t, accentColor: n }) {
|
|
1389
|
-
let r = Mt({
|
|
1390
|
-
inkColor: t,
|
|
1391
|
-
accentColor: n
|
|
1392
|
-
});
|
|
1393
|
-
e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
|
|
1394
|
-
}
|
|
1395
|
-
function Ft(e, t) {
|
|
1396
|
-
e && $(e) === null && console.warn(`[whoo-aiden-widget] Could not use "${e}" as the ${t}; using the default.`);
|
|
1397
|
-
}
|
|
1398
|
-
function It(e, t) {
|
|
1399
|
-
Nt(e, t.color ?? Q), Ft(t.inkColor, "ink color"), Ft(t.accentColor, "accent color"), Pt(e, {
|
|
1400
|
-
inkColor: t.inkColor,
|
|
1401
|
-
accentColor: t.accentColor
|
|
1402
|
-
});
|
|
1403
|
-
let n = t.position === "bottom-left";
|
|
1404
|
-
e.style.setProperty("--whoo-widget-inset-left", n ? "20px" : "auto"), e.style.setProperty("--whoo-widget-inset-right", n ? "auto" : "20px");
|
|
1405
|
-
}
|
|
1513
|
+
}, 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-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}}";
|
|
1406
1514
|
//#endregion
|
|
1407
1515
|
//#region src/mount.tsx
|
|
1408
|
-
function
|
|
1516
|
+
function Kt(e) {
|
|
1409
1517
|
let t = document.createElement("div");
|
|
1410
1518
|
t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(n(e.zIndex));
|
|
1411
1519
|
let r = t.attachShadow({ mode: "open" }), i = document.createElement("style");
|
|
1412
|
-
i.textContent =
|
|
1520
|
+
i.textContent = Gt, r.appendChild(i);
|
|
1413
1521
|
let a = document.createElement("div");
|
|
1414
|
-
r.appendChild(a),
|
|
1415
|
-
let o = new
|
|
1522
|
+
r.appendChild(a), Ht(a, e);
|
|
1523
|
+
let o = new Wt(e), s = $(e.color) !== null, c = null, l = "";
|
|
1416
1524
|
return o.subscribe((t) => {
|
|
1417
|
-
t.primaryColor && t.primaryColor !==
|
|
1525
|
+
!s && t.primaryColor && t.primaryColor !== c && (c = t.primaryColor, zt(a, t.primaryColor, e.color));
|
|
1418
1526
|
let n = `${t.inkColor}|${t.accentColor}`;
|
|
1419
|
-
(t.inkColor || t.accentColor) && n !==
|
|
1420
|
-
inkColor: $(
|
|
1421
|
-
accentColor: $(
|
|
1527
|
+
(t.inkColor || t.accentColor) && n !== l && (l = n, Bt(a, {
|
|
1528
|
+
inkColor: $(e.inkColor) ? e.inkColor : t.inkColor,
|
|
1529
|
+
accentColor: $(e.accentColor) ? e.accentColor : t.accentColor
|
|
1422
1530
|
}));
|
|
1423
|
-
}),
|
|
1424
|
-
|
|
1531
|
+
}), he(/* @__PURE__ */ V(at, { controller: o }), a), o.init(), document.body.appendChild(t), { unmount() {
|
|
1532
|
+
he(null, a), t.remove();
|
|
1425
1533
|
} };
|
|
1426
1534
|
}
|
|
1427
1535
|
//#endregion
|
|
1428
1536
|
//#region src/index.ts
|
|
1429
|
-
function
|
|
1430
|
-
return
|
|
1537
|
+
function qt(e) {
|
|
1538
|
+
return i(e), Kt(e);
|
|
1431
1539
|
}
|
|
1432
1540
|
//#endregion
|
|
1433
|
-
export {
|
|
1541
|
+
export { qt as init, Lt as resolveTheme };
|