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