@aiden-voice/widget 0.3.0 → 0.4.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 +6 -0
- package/dist/components/MessageList.d.ts +2 -1
- package/dist/config.d.ts +2 -0
- package/dist/controller.d.ts +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/version.d.ts +1 -1
- package/dist/widget.iife.js +4 -3
- package/dist/widget.js +321 -305
- package/package.json +1 -1
package/dist/widget.js
CHANGED
|
@@ -1,96 +1,100 @@
|
|
|
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) {
|
|
2
6
|
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
7
|
}
|
|
4
8
|
//#endregion
|
|
5
9
|
//#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/dist/preact.module.js
|
|
6
|
-
var
|
|
7
|
-
function
|
|
10
|
+
var i, a, o, s, c, l, u, d, f, p, m, h, g, _, v = {}, y = [], b = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, x = Array.isArray;
|
|
11
|
+
function S(e, t) {
|
|
8
12
|
for (var n in t) e[n] = t[n];
|
|
9
13
|
return e;
|
|
10
14
|
}
|
|
11
|
-
function
|
|
15
|
+
function ee(e) {
|
|
12
16
|
e && e.parentNode && e.parentNode.removeChild(e);
|
|
13
17
|
}
|
|
14
|
-
function
|
|
15
|
-
var
|
|
16
|
-
for (o in
|
|
17
|
-
if (arguments.length > 2 && (s.children = arguments.length > 3 ?
|
|
18
|
-
return
|
|
18
|
+
function C(e, t, n) {
|
|
19
|
+
var r, a, o, s = {};
|
|
20
|
+
for (o in t) o == "key" ? r = t[o] : o == "ref" ? a = t[o] : s[o] = t[o];
|
|
21
|
+
if (arguments.length > 2 && (s.children = arguments.length > 3 ? i.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (o in e.defaultProps) s[o] === void 0 && (s[o] = e.defaultProps[o]);
|
|
22
|
+
return w(e, s, r, a, null);
|
|
19
23
|
}
|
|
20
|
-
function
|
|
24
|
+
function w(e, t, n, r, i) {
|
|
21
25
|
var s = {
|
|
22
26
|
type: e,
|
|
23
27
|
props: t,
|
|
24
|
-
key:
|
|
25
|
-
ref:
|
|
28
|
+
key: n,
|
|
29
|
+
ref: r,
|
|
26
30
|
__k: null,
|
|
27
31
|
__: null,
|
|
28
32
|
__b: 0,
|
|
29
33
|
__e: null,
|
|
30
34
|
__c: null,
|
|
31
35
|
constructor: void 0,
|
|
32
|
-
__v:
|
|
36
|
+
__v: i ?? ++o,
|
|
33
37
|
__i: -1,
|
|
34
38
|
__u: 0
|
|
35
39
|
};
|
|
36
|
-
return
|
|
40
|
+
return i == null && a.vnode != null && a.vnode(s), s;
|
|
37
41
|
}
|
|
38
|
-
function
|
|
42
|
+
function T(e) {
|
|
39
43
|
return e.children;
|
|
40
44
|
}
|
|
41
|
-
function
|
|
45
|
+
function E(e, t) {
|
|
42
46
|
this.props = e, this.context = t;
|
|
43
47
|
}
|
|
44
|
-
function
|
|
45
|
-
if (t == null) return e.__ ?
|
|
48
|
+
function D(e, t) {
|
|
49
|
+
if (t == null) return e.__ ? D(e.__, e.__i + 1) : null;
|
|
46
50
|
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" ?
|
|
51
|
+
return typeof e.type == "function" ? D(e) : null;
|
|
48
52
|
}
|
|
49
|
-
function
|
|
53
|
+
function O(e) {
|
|
50
54
|
if (e.__P && e.__d) {
|
|
51
|
-
var t = e.__v,
|
|
52
|
-
o.__v = t.__v + 1,
|
|
55
|
+
var t = e.__v, n = t.__e, r = [], i = [], o = S({}, t);
|
|
56
|
+
o.__v = t.__v + 1, a.vnode && a.vnode(o), ae(e.__P, o, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n ?? D(t), !!(32 & t.__u), i), o.__v = t.__v, o.__.__k[o.__i] = o, se(r, o, i), t.__e = t.__ = null, o.__e != n && k(o);
|
|
53
57
|
}
|
|
54
58
|
}
|
|
55
|
-
function
|
|
59
|
+
function k(e) {
|
|
56
60
|
if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) {
|
|
57
61
|
if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e;
|
|
58
|
-
}),
|
|
62
|
+
}), k(e);
|
|
59
63
|
}
|
|
60
|
-
function
|
|
61
|
-
(!e.__d && (e.__d = !0) &&
|
|
64
|
+
function A(e) {
|
|
65
|
+
(!e.__d && (e.__d = !0) && s.push(e) && !j.__r++ || c != a.debounceRendering) && ((c = a.debounceRendering) || l)(j);
|
|
62
66
|
}
|
|
63
|
-
function
|
|
67
|
+
function j() {
|
|
64
68
|
try {
|
|
65
|
-
for (var e, t = 1;
|
|
69
|
+
for (var e, t = 1; s.length;) s.length > t && s.sort(u), e = s.shift(), t = s.length, O(e);
|
|
66
70
|
} finally {
|
|
67
|
-
|
|
71
|
+
s.length = j.__r = 0;
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
|
-
function
|
|
71
|
-
var d, f, p, m,
|
|
72
|
-
for (c =
|
|
73
|
-
return n.__e =
|
|
74
|
+
function te(e, t, n, r, i, a, o, s, c, l, u) {
|
|
75
|
+
var d, f, p, m, h, g, _ = r && r.__k || y, b = t.length;
|
|
76
|
+
for (c = M(n, t, _, c, b), d = 0; d < b; d++) (p = n.__k[d]) != null && (f = p.__i != -1 && _[p.__i] || v, p.__i = d, g = ae(e, p, f, i, a, o, s, c, l, u), m = p.__e, p.ref && f.ref != p.ref && (f.ref && ue(f.ref, null, p), u.push(p.ref, p.__c || m, p)), h == null && m != null && (h = m), 4 & p.__u ? (c = N(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
|
+
return n.__e = h, c;
|
|
74
78
|
}
|
|
75
|
-
function
|
|
79
|
+
function M(e, t, n, r, i) {
|
|
76
80
|
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 =
|
|
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] = w(null, o, null, null, null) : x(o) ? o = e.__k[a] = w(T, { children: o }, null, null, null) : o.constructor === void 0 && o.__b > 0 ? o = e.__k[a] = w(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 = ne(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;
|
|
82
|
+
if (d) for (a = 0; a < u; a++) (s = n[a]) != null && !(2 & s.__u) && (s.__e == r && (r = D(s)), de(s, s));
|
|
79
83
|
return r;
|
|
80
84
|
}
|
|
81
|
-
function
|
|
85
|
+
function N(e, t, n) {
|
|
82
86
|
var r, i;
|
|
83
87
|
if (typeof e.type == "function") {
|
|
84
|
-
for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t =
|
|
88
|
+
for (r = e.__k, i = 0; r && i < r.length; i++) r[i] && (r[i].__ = e, t = N(r[i], t, n));
|
|
85
89
|
return t;
|
|
86
90
|
}
|
|
87
|
-
e.__e != t && (t && e.type && !t.parentNode && (t =
|
|
91
|
+
e.__e != t && (t && e.type && !t.parentNode && (t = D(e)), t = n.insertBefore(e.__e, t || null));
|
|
88
92
|
do
|
|
89
93
|
t &&= t.nextSibling;
|
|
90
94
|
while (t != null && t.nodeType == 8);
|
|
91
95
|
return t;
|
|
92
96
|
}
|
|
93
|
-
function
|
|
97
|
+
function ne(e, t, n, r) {
|
|
94
98
|
var i, a, o, s = e.key, c = e.type, l = t[n], u = l != null && !(2 & l.__u);
|
|
95
99
|
if (l === null && s == null || u && s == l.key && c == l.type) return n;
|
|
96
100
|
if (r > +!!u) {
|
|
@@ -98,18 +102,18 @@ function M(e, t, n, r) {
|
|
|
98
102
|
}
|
|
99
103
|
return -1;
|
|
100
104
|
}
|
|
101
|
-
function
|
|
102
|
-
t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" ||
|
|
105
|
+
function re(e, t, n) {
|
|
106
|
+
t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || b.test(t) ? n : n + "px";
|
|
103
107
|
}
|
|
104
108
|
function P(e, t, n, r, i) {
|
|
105
109
|
var a, o;
|
|
106
110
|
n: if (t == "style") {
|
|
107
111
|
if (typeof n == "string") e.style.cssText = n;
|
|
108
112
|
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] ||
|
|
113
|
+
if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || re(e.style, t, "");
|
|
114
|
+
if (n) for (t in n) r && n[t] == r[t] || re(e.style, t, n[t]);
|
|
111
115
|
}
|
|
112
|
-
} else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(
|
|
116
|
+
} else if (t[0] == "o" && t[1] == "n") a = t != (t = t.replace(m, "$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[p] = r[p] : (n[p] = h, e.addEventListener(t, a ? _ : g, a)) : e.removeEventListener(t, a ? _ : g, a);
|
|
113
117
|
else {
|
|
114
118
|
if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
115
119
|
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,142 +123,142 @@ function P(e, t, n, r, i) {
|
|
|
119
123
|
typeof n == "function" || (n == null || !1 === n && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
|
|
120
124
|
}
|
|
121
125
|
}
|
|
122
|
-
function
|
|
126
|
+
function ie(e) {
|
|
123
127
|
return function(t) {
|
|
124
128
|
if (this.l) {
|
|
125
|
-
var
|
|
126
|
-
if (t[
|
|
127
|
-
else if (t[
|
|
128
|
-
return
|
|
129
|
+
var n = this.l[t.type + e];
|
|
130
|
+
if (t[f] == null) t[f] = h++;
|
|
131
|
+
else if (t[f] < n[p]) return;
|
|
132
|
+
return n(a.event ? a.event(t) : t);
|
|
129
133
|
}
|
|
130
134
|
};
|
|
131
135
|
}
|
|
132
|
-
function
|
|
133
|
-
var d, f, p, m, h, _,
|
|
136
|
+
function ae(e, t, n, r, i, o, s, c, l, u) {
|
|
137
|
+
var d, f, p, m, h, g, _, v, b, C, w, O, k, A, j, M, N = t.type;
|
|
134
138
|
if (t.constructor !== void 0) return null;
|
|
135
|
-
128 &
|
|
136
|
-
n: if (typeof
|
|
139
|
+
128 & n.__u && (l = !!(32 & n.__u), o = [c = t.__e = n.__e]), (d = a.__b) && d(t);
|
|
140
|
+
n: if (typeof N == "function") {
|
|
137
141
|
f = s.length;
|
|
138
142
|
try {
|
|
139
|
-
if (
|
|
143
|
+
if (b = t.props, C = N.prototype && N.prototype.render, w = (d = N.contextType) && r[d.__c], O = d ? w ? w.props.value : d.__ : r, n.__c ? v = (p = t.__c = n.__c).__ = p.__E : (C ? t.__c = p = new N(b, O) : (t.__c = p = new E(b, O), p.constructor = N, p.render = fe), w && w.sub(p), p.state || (p.state = {}), p.__n = r, m = p.__d = !0, p.__h = [], p._sb = []), C && p.__s == null && (p.__s = p.state), C && N.getDerivedStateFromProps != null && (p.__s == p.state && (p.__s = S({}, p.__s)), S(p.__s, N.getDerivedStateFromProps(b, p.__s))), h = p.props, g = p.state, p.__v = t, m) C && N.getDerivedStateFromProps == null && p.componentWillMount != null && p.componentWillMount(), C && p.componentDidMount != null && p.__h.push(p.componentDidMount);
|
|
140
144
|
else {
|
|
141
|
-
if (
|
|
142
|
-
t.__v !=
|
|
145
|
+
if (C && N.getDerivedStateFromProps == null && b !== h && p.componentWillReceiveProps != null && p.componentWillReceiveProps(b, O), t.__v == n.__v || !p.__e && p.shouldComponentUpdate != null && !1 === p.shouldComponentUpdate(b, p.__s, O)) {
|
|
146
|
+
t.__v != n.__v && (p.props = b, p.state = p.__s, p.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(e) {
|
|
143
147
|
e && (e.__ = t);
|
|
144
|
-
}),
|
|
148
|
+
}), y.push.apply(p.__h, p._sb), p._sb = [], p.__h.length && s.push(p), c = D(n);
|
|
145
149
|
break n;
|
|
146
150
|
}
|
|
147
|
-
p.componentWillUpdate != null && p.componentWillUpdate(
|
|
148
|
-
p.componentDidUpdate(h,
|
|
151
|
+
p.componentWillUpdate != null && p.componentWillUpdate(b, p.__s, O), C && p.componentDidUpdate != null && p.__h.push(function() {
|
|
152
|
+
p.componentDidUpdate(h, g, _);
|
|
149
153
|
});
|
|
150
154
|
}
|
|
151
|
-
if (p.context =
|
|
155
|
+
if (p.context = O, p.props = b, p.__P = e, p.__e = !1, k = a.__r, A = 0, C) p.state = p.__s, p.__d = !1, k && k(t), d = p.render(p.props, p.state, p.context), y.push.apply(p.__h, p._sb), p._sb = [];
|
|
152
156
|
else do
|
|
153
|
-
p.__d = !1,
|
|
154
|
-
while (p.__d && ++
|
|
155
|
-
p.state = p.__s, p.getChildContext != null && (
|
|
157
|
+
p.__d = !1, k && k(t), d = p.render(p.props, p.state, p.context), p.state = p.__s;
|
|
158
|
+
while (p.__d && ++A < 25);
|
|
159
|
+
p.state = p.__s, p.getChildContext != null && (r = S(S({}, r), p.getChildContext())), C && !m && p.getSnapshotBeforeUpdate != null && (_ = p.getSnapshotBeforeUpdate(h, g)), j = d != null && d.type === T && d.key == null ? ce(d.props.children) : d, c = te(e, x(j) ? j : [j], t, n, r, i, o, s, c, l, u), p.base = t.__e, t.__u &= -161, p.__h.length && s.push(p), v && (p.__E = p.__ = null);
|
|
156
160
|
} catch (e) {
|
|
157
161
|
if (s.length = f, t.__v = null, l || o != null) {
|
|
158
162
|
if (e.then) {
|
|
159
163
|
for (t.__u |= l ? 160 : 128; c && c.nodeType == 8 && c.nextSibling;) c = c.nextSibling;
|
|
160
164
|
o != null && (o[o.indexOf(c)] = null), t.__e = c;
|
|
161
|
-
} else if (o != null) for (
|
|
162
|
-
} else t.__e =
|
|
163
|
-
t.__k ??=
|
|
165
|
+
} else if (o != null) for (M = o.length; M--;) ee(o[M]);
|
|
166
|
+
} else t.__e = n.__e;
|
|
167
|
+
t.__k ??= n.__k || [], e.then || oe(t), a.__e(e, t, n);
|
|
164
168
|
}
|
|
165
|
-
} else o == null && t.__v ==
|
|
166
|
-
return (d =
|
|
169
|
+
} else o == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : c = t.__e = le(n.__e, t, n, r, i, o, s, l, u);
|
|
170
|
+
return (d = a.diffed) && d(t), 128 & t.__u ? void 0 : c;
|
|
167
171
|
}
|
|
168
|
-
function
|
|
169
|
-
e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(
|
|
172
|
+
function oe(e) {
|
|
173
|
+
e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(oe));
|
|
170
174
|
}
|
|
171
|
-
function
|
|
172
|
-
for (var
|
|
173
|
-
|
|
175
|
+
function se(e, t, n) {
|
|
176
|
+
for (var r = 0; r < n.length; r++) ue(n[r], n[++r], n[++r]);
|
|
177
|
+
a.__c && a.__c(t, e), e.some(function(t) {
|
|
174
178
|
try {
|
|
175
179
|
e = t.__h, t.__h = [], e.some(function(e) {
|
|
176
180
|
e.call(t);
|
|
177
181
|
});
|
|
178
182
|
} catch (e) {
|
|
179
|
-
|
|
183
|
+
a.__e(e, t.__v);
|
|
180
184
|
}
|
|
181
185
|
});
|
|
182
186
|
}
|
|
183
|
-
function
|
|
184
|
-
return typeof e != "object" || !e || e.__b > 0 ? e :
|
|
187
|
+
function ce(e) {
|
|
188
|
+
return typeof e != "object" || !e || e.__b > 0 ? e : x(e) ? e.map(ce) : e.constructor === void 0 ? S({}, e) : null;
|
|
185
189
|
}
|
|
186
|
-
function
|
|
187
|
-
var d, f, p, m, g, _, y
|
|
188
|
-
if (
|
|
189
|
-
for (d = 0; d < s.length; d++) if ((
|
|
190
|
-
e =
|
|
190
|
+
function le(e, t, n, r, o, s, c, l, u) {
|
|
191
|
+
var d, f, p, m, h, g, _, y = n.props || v, b = t.props, S = t.type;
|
|
192
|
+
if (S == "svg" ? o = "http://www.w3.org/2000/svg" : S == "math" ? o = "http://www.w3.org/1998/Math/MathML" : o ||= "http://www.w3.org/1999/xhtml", s != null) {
|
|
193
|
+
for (d = 0; d < s.length; d++) if ((h = s[d]) && "setAttribute" in h == !!S && (S ? h.localName == S : h.nodeType == 3)) {
|
|
194
|
+
e = h, s[d] = null;
|
|
191
195
|
break;
|
|
192
196
|
}
|
|
193
197
|
}
|
|
194
198
|
if (e == null) {
|
|
195
|
-
if (
|
|
196
|
-
e = document.createElementNS(o,
|
|
199
|
+
if (S == null) return document.createTextNode(b);
|
|
200
|
+
e = document.createElementNS(o, S, b.is && b), l &&= (a.__m && a.__m(t, s), !1), s = null;
|
|
197
201
|
}
|
|
198
|
-
if (
|
|
202
|
+
if (S == null) y === b || l && e.data == b || (e.data = b);
|
|
199
203
|
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 &&
|
|
204
|
+
if (s = S == "textarea" && b.defaultValue != null ? null : s && i.call(e.childNodes), !l && s != null) for (y = {}, d = 0; d < e.attributes.length; d++) y[(h = e.attributes[d]).name] = h.value;
|
|
205
|
+
for (d in y) h = y[d], d == "dangerouslySetInnerHTML" ? p = h : d == "children" || d in b || d == "value" && "defaultValue" in b || d == "checked" && "defaultChecked" in b || P(e, d, null, h, o);
|
|
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" || y[d] === h || P(e, d, h, y[d], o);
|
|
207
|
+
if (f) l || p && (f.__html == p.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), t.__k = [];
|
|
208
|
+
else if (p && (e.innerHTML = ""), te(t.type == "template" ? e.content : e, x(m) ? m : [m], t, n, r, S == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o, s, c, s ? s[0] : n.__k && D(n, 0), l, u), s != null) for (d = s.length; d--;) ee(s[d]);
|
|
209
|
+
l && S != "textarea" || (d = "value", S == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[d] || S == "progress" && !g || S == "option" && g != y[d]) && P(e, d, g, y[d], o), d = "checked", _ != null && _ != e[d] && P(e, d, _, y[d], o));
|
|
206
210
|
}
|
|
207
211
|
return e;
|
|
208
212
|
}
|
|
209
|
-
function
|
|
213
|
+
function ue(e, t, n) {
|
|
210
214
|
try {
|
|
211
215
|
if (typeof e == "function") {
|
|
212
|
-
var
|
|
213
|
-
|
|
216
|
+
var r = typeof e.__u == "function";
|
|
217
|
+
r && e.__u(), r && t == null || (e.__u = e(t));
|
|
214
218
|
} else e.current = t;
|
|
215
219
|
} catch (e) {
|
|
216
|
-
|
|
220
|
+
a.__e(e, n);
|
|
217
221
|
}
|
|
218
222
|
}
|
|
219
|
-
function
|
|
220
|
-
var
|
|
221
|
-
if (
|
|
222
|
-
if (
|
|
223
|
-
|
|
223
|
+
function de(e, t, n) {
|
|
224
|
+
var r, i;
|
|
225
|
+
if (a.unmount && a.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || ue(r, null, t)), (r = e.__c) != null) {
|
|
226
|
+
if (r.componentWillUnmount) try {
|
|
227
|
+
r.componentWillUnmount();
|
|
224
228
|
} catch (e) {
|
|
225
|
-
|
|
229
|
+
a.__e(e, t);
|
|
226
230
|
}
|
|
227
|
-
|
|
231
|
+
r.base = r.__P = r.__n = null;
|
|
228
232
|
}
|
|
229
|
-
if (
|
|
230
|
-
|
|
233
|
+
if (r = e.__k) for (i = 0; i < r.length; i++) r[i] && de(r[i], t, n || typeof e.type != "function");
|
|
234
|
+
n || ee(e.__e), e.__c = e.__ = e.__e = void 0;
|
|
231
235
|
}
|
|
232
|
-
function
|
|
236
|
+
function fe(e, t, n) {
|
|
233
237
|
return this.constructor(e, n);
|
|
234
238
|
}
|
|
235
|
-
function
|
|
236
|
-
var
|
|
237
|
-
|
|
239
|
+
function pe(e, t, n) {
|
|
240
|
+
var r, o, s, c;
|
|
241
|
+
t == document && (t = document.documentElement), a.__ && a.__(e, t), o = (r = typeof n == "function") ? null : n && n.__k || t.__k, s = [], c = [], ae(t, e = (!r && n || t).__k = C(T, null, [e]), o || v, v, t.namespaceURI, !r && n ? [n] : o ? null : t.firstChild ? i.call(t.childNodes) : null, s, !r && n ? n : o ? o.__e : t.firstChild, r, c), se(s, e, c), e.props.children = null;
|
|
238
242
|
}
|
|
239
|
-
|
|
243
|
+
i = y.slice, a = { __e: function(e, t, n, r) {
|
|
240
244
|
for (var i, a, o; t = t.__;) if ((i = t.__c) && !i.__) try {
|
|
241
245
|
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
246
|
} catch (t) {
|
|
243
247
|
e = t;
|
|
244
248
|
}
|
|
245
249
|
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
|
-
},
|
|
250
|
+
} }, o = 0, E.prototype.setState = function(e, t) {
|
|
251
|
+
var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = S({}, this.state);
|
|
252
|
+
typeof e == "function" && (e = e(S({}, n), this.props)), e && S(n, e), e != null && this.__v && (t && this._sb.push(t), A(this));
|
|
253
|
+
}, E.prototype.forceUpdate = function(e) {
|
|
254
|
+
this.__v && (this.__e = !0, e && this.__h.push(e), A(this));
|
|
255
|
+
}, E.prototype.render = T, s = [], l = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, u = function(e, t) {
|
|
252
256
|
return e.__v.__b - t.__v.__b;
|
|
253
|
-
},
|
|
257
|
+
}, j.__r = 0, d = Math.random().toString(8), f = "__d" + d, p = "__a" + d, m = /(PointerCapture)$|Capture$/i, h = 0, g = ie(!1), _ = ie(!0);
|
|
254
258
|
//#endregion
|
|
255
259
|
//#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/hooks/dist/hooks.module.js
|
|
256
|
-
var F, I,
|
|
257
|
-
function
|
|
260
|
+
var F, I, me, he, L = 0, ge = [], R = a, _e = R.__b, ve = R.__r, ye = R.diffed, be = R.__c, xe = R.unmount, Se = R.__;
|
|
261
|
+
function Ce(e, t) {
|
|
258
262
|
R.__h && R.__h(I, e, L || t), L = 0;
|
|
259
263
|
var n = I.__H || (I.__H = {
|
|
260
264
|
__: [],
|
|
@@ -263,11 +267,11 @@ function be(e, t) {
|
|
|
263
267
|
return e >= n.__.length && n.__.push({}), n.__[e];
|
|
264
268
|
}
|
|
265
269
|
function z(e) {
|
|
266
|
-
return L = 1,
|
|
270
|
+
return L = 1, we(je, e);
|
|
267
271
|
}
|
|
268
|
-
function
|
|
269
|
-
var r =
|
|
270
|
-
if (r.t = e, !r.__c && (r.__ = [n ? n(t) :
|
|
272
|
+
function we(e, t, n) {
|
|
273
|
+
var r = Ce(F++, 2);
|
|
274
|
+
if (r.t = e, !r.__c && (r.__ = [n ? n(t) : je(void 0, t), function(e) {
|
|
271
275
|
var t = r.__N ? r.__N[0] : r.__[0], n = r.t(t, e);
|
|
272
276
|
t !== n && (r.__N = [n, r.__[1]], r.__c.setState({}));
|
|
273
277
|
}], r.__c = I, !I.__f)) {
|
|
@@ -299,58 +303,58 @@ function xe(e, t, n) {
|
|
|
299
303
|
return r.__N || r.__;
|
|
300
304
|
}
|
|
301
305
|
function B(e, t) {
|
|
302
|
-
var n =
|
|
303
|
-
!R.__s &&
|
|
306
|
+
var n = Ce(F++, 3);
|
|
307
|
+
!R.__s && Ae(n.__H, t) && (n.__ = e, n.u = t, I.__H.__h.push(n));
|
|
304
308
|
}
|
|
305
309
|
function V(e) {
|
|
306
|
-
return L = 5,
|
|
310
|
+
return L = 5, Te(function() {
|
|
307
311
|
return { current: e };
|
|
308
312
|
}, []);
|
|
309
313
|
}
|
|
310
|
-
function
|
|
311
|
-
var n =
|
|
312
|
-
return
|
|
314
|
+
function Te(e, t) {
|
|
315
|
+
var n = Ce(F++, 7);
|
|
316
|
+
return Ae(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
|
|
313
317
|
}
|
|
314
|
-
function
|
|
315
|
-
for (var e; e =
|
|
318
|
+
function Ee() {
|
|
319
|
+
for (var e; e = ge.shift();) {
|
|
316
320
|
var t = e.__H;
|
|
317
321
|
if (e.__P && t) try {
|
|
318
|
-
t.__h.some(H), t.__h.some(
|
|
322
|
+
t.__h.some(H), t.__h.some(ke), t.__h = [];
|
|
319
323
|
} catch (n) {
|
|
320
324
|
t.__h = [], R.__e(n, e.__v);
|
|
321
325
|
}
|
|
322
326
|
}
|
|
323
327
|
}
|
|
324
328
|
R.__b = function(e) {
|
|
325
|
-
I = null,
|
|
329
|
+
I = null, _e && _e(e);
|
|
326
330
|
}, R.__ = function(e, t) {
|
|
327
|
-
e && t.__k && t.__k.__m && (e.__m = t.__k.__m),
|
|
331
|
+
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Se && Se(e, t);
|
|
328
332
|
}, R.__r = function(e) {
|
|
329
|
-
|
|
333
|
+
ve && ve(e), F = 0;
|
|
330
334
|
var t = (I = e.__c).__H;
|
|
331
|
-
t && (
|
|
335
|
+
t && (me === I ? (t.__h = [], I.__h = [], t.__.some(function(e) {
|
|
332
336
|
e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
|
|
333
|
-
})) : (t.__h.some(H), t.__h.some(
|
|
337
|
+
})) : (t.__h.some(H), t.__h.some(ke), t.__h = [], F = 0)), me = I;
|
|
334
338
|
}, R.diffed = function(e) {
|
|
335
|
-
|
|
339
|
+
ye && ye(e);
|
|
336
340
|
var t = e.__c;
|
|
337
|
-
t && t.__H && (t.__H.__h.length && (
|
|
341
|
+
t && t.__H && (t.__H.__h.length && (ge.push(t) !== 1 && he === R.requestAnimationFrame || ((he = R.requestAnimationFrame) || Oe)(Ee)), t.__H.__.some(function(e) {
|
|
338
342
|
e.u &&= (e.__H = e.u, void 0);
|
|
339
|
-
})),
|
|
343
|
+
})), me = I = null;
|
|
340
344
|
}, R.__c = function(e, t) {
|
|
341
345
|
t.some(function(e) {
|
|
342
346
|
try {
|
|
343
347
|
e.__h.some(H), e.__h = e.__h.filter(function(e) {
|
|
344
|
-
return !e.__ ||
|
|
348
|
+
return !e.__ || ke(e);
|
|
345
349
|
});
|
|
346
350
|
} catch (n) {
|
|
347
351
|
t.some(function(e) {
|
|
348
352
|
e.__h &&= [];
|
|
349
353
|
}), t = [], R.__e(n, e.__v);
|
|
350
354
|
}
|
|
351
|
-
}),
|
|
355
|
+
}), be && be(e, t);
|
|
352
356
|
}, R.unmount = function(e) {
|
|
353
|
-
|
|
357
|
+
xe && xe(e);
|
|
354
358
|
var t, n = e.__c;
|
|
355
359
|
n && n.__H && (n.__H.__.some(function(e) {
|
|
356
360
|
try {
|
|
@@ -360,41 +364,41 @@ R.__b = function(e) {
|
|
|
360
364
|
}
|
|
361
365
|
}), n.__H = void 0, t && R.__e(t, n.__v));
|
|
362
366
|
};
|
|
363
|
-
var
|
|
364
|
-
function
|
|
367
|
+
var De = typeof requestAnimationFrame == "function";
|
|
368
|
+
function Oe(e) {
|
|
365
369
|
var t, n = function() {
|
|
366
|
-
clearTimeout(r),
|
|
370
|
+
clearTimeout(r), De && cancelAnimationFrame(t), setTimeout(e);
|
|
367
371
|
}, r = setTimeout(n, 35);
|
|
368
|
-
|
|
372
|
+
De && (t = requestAnimationFrame(n));
|
|
369
373
|
}
|
|
370
374
|
function H(e) {
|
|
371
375
|
var t = I, n = e.__c;
|
|
372
376
|
typeof n == "function" && (e.__c = void 0, n()), I = t;
|
|
373
377
|
}
|
|
374
|
-
function
|
|
378
|
+
function ke(e) {
|
|
375
379
|
var t = I;
|
|
376
380
|
e.__c = e.__(), I = t;
|
|
377
381
|
}
|
|
378
|
-
function
|
|
382
|
+
function Ae(e, t) {
|
|
379
383
|
return !e || e.length !== t.length || t.some(function(t, n) {
|
|
380
384
|
return t !== e[n];
|
|
381
385
|
});
|
|
382
386
|
}
|
|
383
|
-
function
|
|
387
|
+
function je(e, t) {
|
|
384
388
|
return typeof t == "function" ? t(e) : t;
|
|
385
389
|
}
|
|
386
390
|
//#endregion
|
|
387
391
|
//#region node_modules/.pnpm/preact@10.29.8/node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
|
|
388
|
-
var
|
|
392
|
+
var Me = 0;
|
|
389
393
|
Array.isArray;
|
|
390
|
-
function U(e, t, r, i,
|
|
394
|
+
function U(e, t, n, r, i, o) {
|
|
391
395
|
t ||= {};
|
|
392
396
|
var s, c, l = t;
|
|
393
397
|
if ("ref" in l) for (c in l = {}, t) c == "ref" ? s = t[c] : l[c] = t[c];
|
|
394
398
|
var u = {
|
|
395
399
|
type: e,
|
|
396
400
|
props: l,
|
|
397
|
-
key:
|
|
401
|
+
key: n,
|
|
398
402
|
ref: s,
|
|
399
403
|
__k: null,
|
|
400
404
|
__: null,
|
|
@@ -402,14 +406,14 @@ function U(e, t, r, i, a, o) {
|
|
|
402
406
|
__e: null,
|
|
403
407
|
__c: null,
|
|
404
408
|
constructor: void 0,
|
|
405
|
-
__v: --
|
|
409
|
+
__v: --Me,
|
|
406
410
|
__i: -1,
|
|
407
411
|
__u: 0,
|
|
408
|
-
__source:
|
|
412
|
+
__source: i,
|
|
409
413
|
__self: o
|
|
410
414
|
};
|
|
411
415
|
if (typeof e == "function" && (s = e.defaultProps)) for (c in s) l[c] === void 0 && (l[c] = s[c]);
|
|
412
|
-
return
|
|
416
|
+
return a.vnode && a.vnode(u), u;
|
|
413
417
|
}
|
|
414
418
|
//#endregion
|
|
415
419
|
//#region src/components/icons.tsx
|
|
@@ -429,7 +433,7 @@ function W({ name: e, size: t, children: n }) {
|
|
|
429
433
|
children: n
|
|
430
434
|
});
|
|
431
435
|
}
|
|
432
|
-
function
|
|
436
|
+
function Ne({ size: e = 26 }) {
|
|
433
437
|
return /* @__PURE__ */ U(W, {
|
|
434
438
|
name: "chat",
|
|
435
439
|
size: e,
|
|
@@ -439,41 +443,41 @@ function Ae({ size: e = 26 }) {
|
|
|
439
443
|
})]
|
|
440
444
|
});
|
|
441
445
|
}
|
|
442
|
-
function
|
|
446
|
+
function Pe({ size: e = 26 }) {
|
|
443
447
|
return /* @__PURE__ */ U(W, {
|
|
444
448
|
name: "chevron-down",
|
|
445
449
|
size: e,
|
|
446
450
|
children: /* @__PURE__ */ U("path", { d: "M6 9l6 6 6-6" })
|
|
447
451
|
});
|
|
448
452
|
}
|
|
449
|
-
function
|
|
453
|
+
function Fe({ size: e = 18 }) {
|
|
450
454
|
return /* @__PURE__ */ U(W, {
|
|
451
455
|
name: "close",
|
|
452
456
|
size: e,
|
|
453
457
|
children: /* @__PURE__ */ U("path", { d: "M6 6l12 12M18 6L6 18" })
|
|
454
458
|
});
|
|
455
459
|
}
|
|
456
|
-
var
|
|
457
|
-
function
|
|
460
|
+
var Ie = "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";
|
|
461
|
+
function Le({ size: e = 16 }) {
|
|
458
462
|
return /* @__PURE__ */ U(W, {
|
|
459
463
|
name: "thumb-up",
|
|
460
464
|
size: e,
|
|
461
|
-
children: /* @__PURE__ */ U("path", { d:
|
|
465
|
+
children: /* @__PURE__ */ U("path", { d: Ie })
|
|
462
466
|
});
|
|
463
467
|
}
|
|
464
|
-
function
|
|
468
|
+
function Re({ size: e = 16 }) {
|
|
465
469
|
return /* @__PURE__ */ U(W, {
|
|
466
470
|
name: "thumb-down",
|
|
467
471
|
size: e,
|
|
468
472
|
children: /* @__PURE__ */ U("path", {
|
|
469
|
-
d:
|
|
473
|
+
d: Ie,
|
|
470
474
|
transform: "matrix(1 0 0 -1 0 24)"
|
|
471
475
|
})
|
|
472
476
|
});
|
|
473
477
|
}
|
|
474
478
|
//#endregion
|
|
475
479
|
//#region src/components/Launcher.tsx
|
|
476
|
-
function
|
|
480
|
+
function ze({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
|
|
477
481
|
let [i, a] = z("loading"), o = n !== void 0 && i !== "failed", s = o && !e && i === "loaded";
|
|
478
482
|
return /* @__PURE__ */ U("button", {
|
|
479
483
|
type: "button",
|
|
@@ -481,7 +485,7 @@ function Ie({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
|
|
|
481
485
|
onClick: t,
|
|
482
486
|
"aria-label": e ? "Close chat" : "Open chat",
|
|
483
487
|
ref: r,
|
|
484
|
-
children: [e ? /* @__PURE__ */ U(
|
|
488
|
+
children: [e ? /* @__PURE__ */ U(Pe, {}) : s ? null : /* @__PURE__ */ U(Ne, {}), o ? /* @__PURE__ */ U("img", {
|
|
485
489
|
class: "whoo-widget-launcher-icon-image",
|
|
486
490
|
src: n,
|
|
487
491
|
alt: "",
|
|
@@ -494,7 +498,7 @@ function Ie({ isOpen: e, onClick: t, iconUrl: n, buttonRef: r }) {
|
|
|
494
498
|
}
|
|
495
499
|
//#endregion
|
|
496
500
|
//#region src/components/Composer.tsx
|
|
497
|
-
function
|
|
501
|
+
function Be({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
498
502
|
return /* @__PURE__ */ U("div", {
|
|
499
503
|
class: "whoo-widget-composer",
|
|
500
504
|
children: [
|
|
@@ -527,7 +531,7 @@ function Le({ value: e, onChange: t, onSend: n, disabled: r, inputRef: i }) {
|
|
|
527
531
|
}
|
|
528
532
|
//#endregion
|
|
529
533
|
//#region src/components/ErrorBanner.tsx
|
|
530
|
-
function
|
|
534
|
+
function Ve({ message: e }) {
|
|
531
535
|
return /* @__PURE__ */ U("div", {
|
|
532
536
|
class: "whoo-widget-error-banner",
|
|
533
537
|
role: "alert",
|
|
@@ -536,8 +540,8 @@ function Re({ message: e }) {
|
|
|
536
540
|
}
|
|
537
541
|
//#endregion
|
|
538
542
|
//#region src/markdown/tokenizer.ts
|
|
539
|
-
var G = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, K = /\*\*([^*]
|
|
540
|
-
function
|
|
543
|
+
var G = /\[([^\]]+)\]\((https?:\/\/[^\s)]+)\)/y, K = /\*\*([^*\s](?:[^*]*[^*\s])?)\*\*/y, q = /(?<![A-Za-z0-9_])_([^_\s](?:[^_]*[^_\s])?)_(?![A-Za-z0-9_])/y, J = /\*([^*\s](?:[^*]*[^*\s])?)\*/y, Y = /[ \t]*[*+-][ \t]+/y, He = /https?:\/\/\S+/y, Ue = /[.,;:!?)\]}>]+$/;
|
|
544
|
+
function We(e) {
|
|
541
545
|
let t = [], n = 0, r = 0, i = (n) => {
|
|
542
546
|
n > r && t.push({
|
|
543
547
|
type: "text",
|
|
@@ -547,6 +551,15 @@ function Ve(e) {
|
|
|
547
551
|
});
|
|
548
552
|
};
|
|
549
553
|
for (; n < e.length;) {
|
|
554
|
+
if ((n === 0 || e[n - 1] === "\n") && (Y.lastIndex = n, Y.exec(e))) {
|
|
555
|
+
i(n), t.push({
|
|
556
|
+
type: "text",
|
|
557
|
+
value: "• ",
|
|
558
|
+
start: n,
|
|
559
|
+
end: Y.lastIndex
|
|
560
|
+
}), n = Y.lastIndex, r = n;
|
|
561
|
+
continue;
|
|
562
|
+
}
|
|
550
563
|
if (e[n] === "!" && n + 1 < e.length && e[n + 1] === "[") {
|
|
551
564
|
let t = /!\[([^\]]*)\]\(([^)]*)\)/y;
|
|
552
565
|
t.lastIndex = n;
|
|
@@ -603,10 +616,10 @@ function Ve(e) {
|
|
|
603
616
|
}), n = J.lastIndex, r = n;
|
|
604
617
|
continue;
|
|
605
618
|
}
|
|
606
|
-
|
|
607
|
-
let c =
|
|
619
|
+
He.lastIndex = n;
|
|
620
|
+
let c = He.exec(e);
|
|
608
621
|
if (c) {
|
|
609
|
-
let e = c[0].match(
|
|
622
|
+
let e = c[0].match(Ue), a = e ? c[0].slice(0, c[0].length - e[0].length) : c[0];
|
|
610
623
|
if (a.length > 0) {
|
|
611
624
|
i(n), t.push({
|
|
612
625
|
type: "link",
|
|
@@ -624,11 +637,11 @@ function Ve(e) {
|
|
|
624
637
|
}
|
|
625
638
|
//#endregion
|
|
626
639
|
//#region src/markdown/render.tsx
|
|
627
|
-
function
|
|
628
|
-
return
|
|
640
|
+
function Ge(e) {
|
|
641
|
+
return We(e).map((e, t) => {
|
|
629
642
|
switch (e.type) {
|
|
630
|
-
case "bold": return /* @__PURE__ */ U("strong", { children: e.value }, t);
|
|
631
|
-
case "italic": return /* @__PURE__ */ U("em", { children: e.value }, t);
|
|
643
|
+
case "bold": return /* @__PURE__ */ U("strong", { children: Ge(e.value) }, t);
|
|
644
|
+
case "italic": return /* @__PURE__ */ U("em", { children: Ge(e.value) }, t);
|
|
632
645
|
case "link": return /* @__PURE__ */ U("a", {
|
|
633
646
|
href: e.url,
|
|
634
647
|
target: "_blank",
|
|
@@ -644,7 +657,7 @@ function He(e) {
|
|
|
644
657
|
}
|
|
645
658
|
//#endregion
|
|
646
659
|
//#region src/components/MessageFeedback.tsx
|
|
647
|
-
var
|
|
660
|
+
var Ke = [
|
|
648
661
|
{
|
|
649
662
|
value: "",
|
|
650
663
|
label: "Select a reason (optional)"
|
|
@@ -666,7 +679,7 @@ var Ue = [
|
|
|
666
679
|
label: "Other"
|
|
667
680
|
}
|
|
668
681
|
];
|
|
669
|
-
function
|
|
682
|
+
function qe({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmitDetailed: i, onCancel: a }) {
|
|
670
683
|
let [o, s] = z(""), [c, l] = z(""), u = V(e.status);
|
|
671
684
|
if (B(() => {
|
|
672
685
|
let n = u.current;
|
|
@@ -697,7 +710,7 @@ function We({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
|
|
|
697
710
|
"aria-label": "Feedback category",
|
|
698
711
|
value: c,
|
|
699
712
|
onChange: (e) => l(e.target.value),
|
|
700
|
-
children:
|
|
713
|
+
children: Ke.map((e) => /* @__PURE__ */ U("option", {
|
|
701
714
|
value: e.value,
|
|
702
715
|
children: e.label
|
|
703
716
|
}, e.value))
|
|
@@ -728,13 +741,13 @@ function We({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
|
|
|
728
741
|
"aria-label": "Good response",
|
|
729
742
|
disabled: d,
|
|
730
743
|
onClick: n,
|
|
731
|
-
children: /* @__PURE__ */ U(
|
|
744
|
+
children: /* @__PURE__ */ U(Le, {})
|
|
732
745
|
}), /* @__PURE__ */ U("button", {
|
|
733
746
|
type: "button",
|
|
734
747
|
"aria-label": "Bad response",
|
|
735
748
|
disabled: d,
|
|
736
749
|
onClick: r,
|
|
737
|
-
children: /* @__PURE__ */ U(
|
|
750
|
+
children: /* @__PURE__ */ U(Re, {})
|
|
738
751
|
})]
|
|
739
752
|
}), e.status === "error" ? /* @__PURE__ */ U("div", {
|
|
740
753
|
class: "whoo-widget-feedback-error",
|
|
@@ -745,7 +758,7 @@ function We({ state: e, containerRef: t, onThumbsUp: n, onThumbsDown: r, onSubmi
|
|
|
745
758
|
}
|
|
746
759
|
//#endregion
|
|
747
760
|
//#region src/components/MessageList.tsx
|
|
748
|
-
function
|
|
761
|
+
function Je({ isSlowResponse: e }) {
|
|
749
762
|
return /* @__PURE__ */ U("div", {
|
|
750
763
|
class: "whoo-widget-pending",
|
|
751
764
|
role: "status",
|
|
@@ -763,7 +776,7 @@ function Ge({ isSlowResponse: e }) {
|
|
|
763
776
|
}) : null]
|
|
764
777
|
});
|
|
765
778
|
}
|
|
766
|
-
function
|
|
779
|
+
function Ye({ url: e, alt: t }) {
|
|
767
780
|
let [n, r] = z(!1);
|
|
768
781
|
return n ? null : /* @__PURE__ */ U("img", {
|
|
769
782
|
class: "whoo-widget-empty-state-image",
|
|
@@ -773,39 +786,40 @@ function Ke({ url: e, alt: t }) {
|
|
|
773
786
|
onError: () => r(!0)
|
|
774
787
|
});
|
|
775
788
|
}
|
|
776
|
-
function
|
|
777
|
-
let
|
|
789
|
+
function Xe({ message: e, feedbackState: t, showFeedback: n, pending: r, isSlowResponse: i, onThumbsUp: a, onThumbsDown: o, onSubmitDetailed: s, onCancelFeedback: c }) {
|
|
790
|
+
let l = V(null), u = e.id;
|
|
778
791
|
return /* @__PURE__ */ U("div", {
|
|
779
|
-
ref:
|
|
792
|
+
ref: l,
|
|
780
793
|
tabIndex: -1,
|
|
781
794
|
class: `whoo-widget-message whoo-widget-message--${e.role}`,
|
|
782
|
-
children: [
|
|
795
|
+
children: [r ? /* @__PURE__ */ U(Je, { isSlowResponse: i }) : Ge(e.content), n && e.role === "assistant" && u ? /* @__PURE__ */ U(qe, {
|
|
783
796
|
state: t,
|
|
784
|
-
containerRef:
|
|
785
|
-
onThumbsUp: () =>
|
|
786
|
-
onThumbsDown: () =>
|
|
787
|
-
onSubmitDetailed: (e, t) =>
|
|
788
|
-
onCancel: () =>
|
|
797
|
+
containerRef: l,
|
|
798
|
+
onThumbsUp: () => a(u),
|
|
799
|
+
onThumbsDown: () => o(u),
|
|
800
|
+
onSubmitDetailed: (e, t) => s(u, e, t),
|
|
801
|
+
onCancel: () => c(u)
|
|
789
802
|
}) : null]
|
|
790
803
|
});
|
|
791
804
|
}
|
|
792
|
-
function
|
|
793
|
-
let
|
|
805
|
+
function Ze({ 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 }) {
|
|
806
|
+
let d = V(null);
|
|
794
807
|
return B(() => {
|
|
795
|
-
let e =
|
|
808
|
+
let e = d.current;
|
|
796
809
|
e && (e.scrollTop = e.scrollHeight);
|
|
797
|
-
}, [e,
|
|
810
|
+
}, [e, o]), /* @__PURE__ */ U(T, { children: [/* @__PURE__ */ U("div", {
|
|
798
811
|
class: "whoo-widget-message-list",
|
|
799
|
-
ref:
|
|
800
|
-
children: [r ? /* @__PURE__ */ U(
|
|
812
|
+
ref: d,
|
|
813
|
+
children: [r ? /* @__PURE__ */ U(Ye, { ...r }) : null, e.map((n, r) => /* @__PURE__ */ U(Xe, {
|
|
801
814
|
message: n,
|
|
815
|
+
showFeedback: i,
|
|
802
816
|
feedbackState: n.id ? t[n.id] ?? { status: "idle" } : { status: "idle" },
|
|
803
|
-
pending:
|
|
804
|
-
isSlowResponse:
|
|
805
|
-
onThumbsUp:
|
|
806
|
-
onThumbsDown:
|
|
807
|
-
onSubmitDetailed:
|
|
808
|
-
onCancelFeedback:
|
|
817
|
+
pending: a && r === e.length - 1 && n.role === "assistant" && n.content === "",
|
|
818
|
+
isSlowResponse: o,
|
|
819
|
+
onThumbsUp: s,
|
|
820
|
+
onThumbsDown: c,
|
|
821
|
+
onSubmitDetailed: l,
|
|
822
|
+
onCancelFeedback: u
|
|
809
823
|
}, n.id ?? r))]
|
|
810
824
|
}), /* @__PURE__ */ U("div", {
|
|
811
825
|
class: "whoo-widget-sr-only",
|
|
@@ -816,14 +830,14 @@ function Je({ messages: e, messageFeedback: t, lastCompletedMessageText: n, empt
|
|
|
816
830
|
}
|
|
817
831
|
//#endregion
|
|
818
832
|
//#region src/components/Panel.tsx
|
|
819
|
-
var
|
|
820
|
-
function
|
|
821
|
-
return Array.from(e.querySelectorAll(
|
|
833
|
+
var Qe = "button:not(:disabled), [href], input:not(:disabled), select:not(:disabled), textarea:not(:disabled), [tabindex]:not([tabindex=\"-1\"])";
|
|
834
|
+
function $e(e) {
|
|
835
|
+
return Array.from(e.querySelectorAll(Qe)).filter((e) => {
|
|
822
836
|
let t = getComputedStyle(e);
|
|
823
837
|
return t.display !== "none" && t.visibility !== "hidden";
|
|
824
838
|
});
|
|
825
839
|
}
|
|
826
|
-
function
|
|
840
|
+
function et({ state: e, controller: t, greeting: n }) {
|
|
827
841
|
let r = V(null), i = V(null);
|
|
828
842
|
B(() => {
|
|
829
843
|
i.current?.focus();
|
|
@@ -836,7 +850,7 @@ function Ze({ state: e, controller: t, greeting: n }) {
|
|
|
836
850
|
if (e.key !== "Tab") return;
|
|
837
851
|
let n = r.current;
|
|
838
852
|
if (!n) return;
|
|
839
|
-
let i =
|
|
853
|
+
let i = $e(n);
|
|
840
854
|
if (i.length === 0) return;
|
|
841
855
|
let a = i[0], o = i[i.length - 1], s = n.getRootNode().activeElement;
|
|
842
856
|
if (!n.contains(s)) {
|
|
@@ -880,15 +894,16 @@ function Ze({ state: e, controller: t, greeting: n }) {
|
|
|
880
894
|
class: "whoo-widget-header-close",
|
|
881
895
|
"aria-label": "Close chat",
|
|
882
896
|
onClick: () => t.close(),
|
|
883
|
-
children: /* @__PURE__ */ U(
|
|
897
|
+
children: /* @__PURE__ */ U(Fe, {})
|
|
884
898
|
})]
|
|
885
899
|
})]
|
|
886
900
|
}),
|
|
887
|
-
/* @__PURE__ */ U(
|
|
901
|
+
/* @__PURE__ */ U(Ze, {
|
|
888
902
|
messages: c,
|
|
889
903
|
messageFeedback: e.messageFeedback,
|
|
890
904
|
lastCompletedMessageText: e.lastCompletedMessageText,
|
|
891
905
|
emptyStateImage: u,
|
|
906
|
+
showFeedback: t.showFeedback,
|
|
892
907
|
isStreaming: e.isStreaming,
|
|
893
908
|
isSlowResponse: e.isSlowResponse,
|
|
894
909
|
onThumbsUp: (e) => t.submitFeedback(e, "up"),
|
|
@@ -896,8 +911,8 @@ function Ze({ state: e, controller: t, greeting: n }) {
|
|
|
896
911
|
onSubmitDetailed: (e, n, r) => t.submitFeedback(e, "down", n || void 0, r || void 0),
|
|
897
912
|
onCancelFeedback: (e) => t.cancelFeedback(e)
|
|
898
913
|
}),
|
|
899
|
-
e.runtimeError && /* @__PURE__ */ U(
|
|
900
|
-
/* @__PURE__ */ U(
|
|
914
|
+
e.runtimeError && /* @__PURE__ */ U(Ve, { message: e.runtimeError }),
|
|
915
|
+
/* @__PURE__ */ U(Be, {
|
|
901
916
|
value: e.draft,
|
|
902
917
|
onChange: (e) => t.setDraft(e),
|
|
903
918
|
onSend: o,
|
|
@@ -909,16 +924,16 @@ function Ze({ state: e, controller: t, greeting: n }) {
|
|
|
909
924
|
}
|
|
910
925
|
//#endregion
|
|
911
926
|
//#region src/components/App.tsx
|
|
912
|
-
function
|
|
927
|
+
function tt({ controller: e }) {
|
|
913
928
|
let [t, n] = z(e.getState()), r = V(null), i = V(t.isOpen);
|
|
914
929
|
return B(() => (n(e.getState()), e.subscribe(n)), [e]), B(() => {
|
|
915
930
|
i.current && !t.isOpen && r.current?.focus(), i.current = t.isOpen;
|
|
916
|
-
}, [t.isOpen]), t.initError ? null : /* @__PURE__ */ U(
|
|
931
|
+
}, [t.isOpen]), t.initError ? null : /* @__PURE__ */ U(T, { children: [/* @__PURE__ */ U(ze, {
|
|
917
932
|
isOpen: t.isOpen,
|
|
918
933
|
onClick: () => t.isOpen ? e.close() : e.open(),
|
|
919
934
|
iconUrl: e.launcherIconUrl,
|
|
920
935
|
buttonRef: r
|
|
921
|
-
}), t.isOpen && /* @__PURE__ */ U(
|
|
936
|
+
}), t.isOpen && /* @__PURE__ */ U(et, {
|
|
922
937
|
state: t,
|
|
923
938
|
controller: e,
|
|
924
939
|
greeting: e.config.greeting
|
|
@@ -926,34 +941,34 @@ function Qe({ controller: e }) {
|
|
|
926
941
|
}
|
|
927
942
|
//#endregion
|
|
928
943
|
//#region src/api/client.ts
|
|
929
|
-
var
|
|
944
|
+
var nt = class extends Error {
|
|
930
945
|
status;
|
|
931
946
|
constructor(e, t) {
|
|
932
947
|
super(e), this.name = "WidgetApiError", this.status = t;
|
|
933
948
|
}
|
|
934
949
|
};
|
|
935
|
-
function
|
|
950
|
+
function rt(e) {
|
|
936
951
|
if (typeof e != "string") return null;
|
|
937
952
|
let t = e.trim();
|
|
938
953
|
return t === "" ? null : t;
|
|
939
954
|
}
|
|
940
|
-
async function
|
|
955
|
+
async function it(e, t) {
|
|
941
956
|
let n = await fetch(`${e}/api/v1/widget/session`, {
|
|
942
957
|
method: "POST",
|
|
943
958
|
headers: { "Content-Type": "application/json" },
|
|
944
959
|
body: JSON.stringify({ publishable_key: t })
|
|
945
960
|
});
|
|
946
|
-
if (!n.ok) throw new
|
|
961
|
+
if (!n.ok) throw new nt(`Failed to create widget session (${n.status})`, n.status);
|
|
947
962
|
let r = await n.json();
|
|
948
963
|
return {
|
|
949
964
|
token: r.token,
|
|
950
965
|
primaryColor: r.primary_color ?? null,
|
|
951
|
-
name:
|
|
952
|
-
accentColor:
|
|
953
|
-
inkColor:
|
|
966
|
+
name: rt(r.name),
|
|
967
|
+
accentColor: rt(r.accent_color),
|
|
968
|
+
inkColor: rt(r.ink_color)
|
|
954
969
|
};
|
|
955
970
|
}
|
|
956
|
-
async function
|
|
971
|
+
async function at(e, t, n) {
|
|
957
972
|
let r = await fetch(`${e}/api/v1/widget/feedback`, {
|
|
958
973
|
method: "POST",
|
|
959
974
|
headers: {
|
|
@@ -967,11 +982,11 @@ async function nt(e, t, n) {
|
|
|
967
982
|
category: n.category ?? null
|
|
968
983
|
})
|
|
969
984
|
});
|
|
970
|
-
if (!r.ok) throw new
|
|
985
|
+
if (!r.ok) throw new nt(`Feedback submission failed (${r.status})`, r.status);
|
|
971
986
|
}
|
|
972
987
|
//#endregion
|
|
973
988
|
//#region src/api/sse.ts
|
|
974
|
-
async function*
|
|
989
|
+
async function* ot(e, t, n, r, i) {
|
|
975
990
|
let a = await fetch(`${e}/api/v1/widget/chat`, {
|
|
976
991
|
method: "POST",
|
|
977
992
|
headers: {
|
|
@@ -984,7 +999,7 @@ async function* rt(e, t, n, r, i) {
|
|
|
984
999
|
}),
|
|
985
1000
|
signal: i
|
|
986
1001
|
});
|
|
987
|
-
if (!a.ok || !a.body) throw new
|
|
1002
|
+
if (!a.ok || !a.body) throw new nt(`Chat request failed (${a.status})`, a.status);
|
|
988
1003
|
let o = a.body.getReader(), s = new TextDecoder(), c = "";
|
|
989
1004
|
for (;;) {
|
|
990
1005
|
let { done: e, value: t } = await o.read();
|
|
@@ -995,11 +1010,11 @@ async function* rt(e, t, n, r, i) {
|
|
|
995
1010
|
let e = c.slice(0, n);
|
|
996
1011
|
c = c.slice(n + 2);
|
|
997
1012
|
let t = e.split("\n").find((e) => e.startsWith("data: "));
|
|
998
|
-
t && (yield
|
|
1013
|
+
t && (yield st(JSON.parse(t.slice(6)))), n = c.indexOf("\n\n");
|
|
999
1014
|
}
|
|
1000
1015
|
}
|
|
1001
1016
|
}
|
|
1002
|
-
function
|
|
1017
|
+
function st(e) {
|
|
1003
1018
|
return typeof e.error == "string" ? {
|
|
1004
1019
|
type: "error",
|
|
1005
1020
|
error: e.error,
|
|
@@ -1022,7 +1037,7 @@ function it(e) {
|
|
|
1022
1037
|
}
|
|
1023
1038
|
//#endregion
|
|
1024
1039
|
//#region src/imageUrl.ts
|
|
1025
|
-
function
|
|
1040
|
+
function ct(e, t) {
|
|
1026
1041
|
if (e != null && e !== "") {
|
|
1027
1042
|
if (typeof e == "string") try {
|
|
1028
1043
|
let t = new URL(e);
|
|
@@ -1033,16 +1048,16 @@ function at(e, t) {
|
|
|
1033
1048
|
}
|
|
1034
1049
|
//#endregion
|
|
1035
1050
|
//#region src/markdown/reveal.ts
|
|
1036
|
-
var
|
|
1037
|
-
function
|
|
1051
|
+
var lt = 40, ut = 120;
|
|
1052
|
+
function dt(e) {
|
|
1038
1053
|
let t = [];
|
|
1039
|
-
for (let n of
|
|
1054
|
+
for (let n of We(e)) if (n.type === "text") {
|
|
1040
1055
|
let e = n.value.split(/(\s+)/), r = n.start;
|
|
1041
1056
|
for (let n of e) r += n.length, n.trim().length > 0 && t.push(r);
|
|
1042
1057
|
} else t.push(n.end);
|
|
1043
1058
|
return t;
|
|
1044
1059
|
}
|
|
1045
|
-
function
|
|
1060
|
+
function ft(e) {
|
|
1046
1061
|
let t = null;
|
|
1047
1062
|
return e?.addEventListener("abort", () => {
|
|
1048
1063
|
t?.();
|
|
@@ -1057,36 +1072,36 @@ function lt(e) {
|
|
|
1057
1072
|
});
|
|
1058
1073
|
};
|
|
1059
1074
|
}
|
|
1060
|
-
async function
|
|
1061
|
-
let r = n?.wordIntervalMs ??
|
|
1062
|
-
for (let n of
|
|
1075
|
+
async function pt(e, t, n) {
|
|
1076
|
+
let r = n?.wordIntervalMs ?? lt, i = n?.tokenIntervalMs ?? ut, a = n?.signal, o = We(e), s = new Set(o.filter((e) => e.type !== "text").map((e) => e.end)), c = ft(a), l = "";
|
|
1077
|
+
for (let n of dt(e)) if (a?.aborted || (l = e.slice(0, n), t(l), await c(s.has(n) ? i : r), a?.aborted)) return;
|
|
1063
1078
|
l !== e && t(e);
|
|
1064
1079
|
}
|
|
1065
1080
|
//#endregion
|
|
1066
1081
|
//#region src/storage.ts
|
|
1067
|
-
function
|
|
1082
|
+
function mt(e) {
|
|
1068
1083
|
return `whoo-aiden-widget:conversation:${e}`;
|
|
1069
1084
|
}
|
|
1070
|
-
function
|
|
1085
|
+
function ht(e) {
|
|
1071
1086
|
try {
|
|
1072
|
-
return window.sessionStorage.getItem(
|
|
1087
|
+
return window.sessionStorage.getItem(mt(e));
|
|
1073
1088
|
} catch {
|
|
1074
1089
|
return null;
|
|
1075
1090
|
}
|
|
1076
1091
|
}
|
|
1077
|
-
function
|
|
1092
|
+
function gt(e, t) {
|
|
1078
1093
|
try {
|
|
1079
|
-
window.sessionStorage.setItem(
|
|
1094
|
+
window.sessionStorage.setItem(mt(e), t);
|
|
1080
1095
|
} catch {}
|
|
1081
1096
|
}
|
|
1082
|
-
function
|
|
1097
|
+
function _t(e) {
|
|
1083
1098
|
try {
|
|
1084
|
-
window.sessionStorage.removeItem(
|
|
1099
|
+
window.sessionStorage.removeItem(mt(e));
|
|
1085
1100
|
} catch {}
|
|
1086
1101
|
}
|
|
1087
1102
|
//#endregion
|
|
1088
1103
|
//#region src/controller.ts
|
|
1089
|
-
var
|
|
1104
|
+
var vt = 8e3, yt = class {
|
|
1090
1105
|
config;
|
|
1091
1106
|
state;
|
|
1092
1107
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -1099,8 +1114,9 @@ var mt = 8e3, ht = class {
|
|
|
1099
1114
|
launcherIconUrl;
|
|
1100
1115
|
emptyStateImageUrl;
|
|
1101
1116
|
emptyStateImageAlt;
|
|
1117
|
+
showFeedback;
|
|
1102
1118
|
constructor(e) {
|
|
1103
|
-
this.config = e, this.launcherIconUrl =
|
|
1119
|
+
this.config = e, this.launcherIconUrl = ct(e.launcherIconUrl, "launcherIconUrl"), this.emptyStateImageUrl = ct(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 = {
|
|
1104
1120
|
isOpen: !1,
|
|
1105
1121
|
messages: [],
|
|
1106
1122
|
isStreaming: !1,
|
|
@@ -1137,7 +1153,7 @@ var mt = 8e3, ht = class {
|
|
|
1137
1153
|
try {
|
|
1138
1154
|
if (this.config.sessionToken) this.sessionToken = this.config.sessionToken;
|
|
1139
1155
|
else if (this.config.publishableKey) {
|
|
1140
|
-
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await
|
|
1156
|
+
let { token: t, primaryColor: n, name: r, accentColor: i, inkColor: a } = await it(e, this.config.publishableKey);
|
|
1141
1157
|
this.sessionToken = t, this.setState({
|
|
1142
1158
|
primaryColor: n,
|
|
1143
1159
|
agentName: r,
|
|
@@ -1149,13 +1165,13 @@ var mt = 8e3, ht = class {
|
|
|
1149
1165
|
console.error("[whoo-aiden-widget] initialization failed:", e), this.setState({ initError: e instanceof Error ? e.message : String(e) });
|
|
1150
1166
|
return;
|
|
1151
1167
|
}
|
|
1152
|
-
this.conversationId =
|
|
1168
|
+
this.conversationId = ht(this.storageIdentifier);
|
|
1153
1169
|
}
|
|
1154
1170
|
open() {
|
|
1155
1171
|
this.setState({ isOpen: !0 });
|
|
1156
1172
|
}
|
|
1157
1173
|
resetConversation() {
|
|
1158
|
-
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null,
|
|
1174
|
+
this.activeRequestController?.abort(), this.activeRequestController = null, this.clearSlowResponse(), this.conversationId = null, _t(this.storageIdentifier), this.setState({
|
|
1159
1175
|
messages: [],
|
|
1160
1176
|
messageFeedback: {},
|
|
1161
1177
|
runtimeError: null,
|
|
@@ -1200,7 +1216,7 @@ var mt = 8e3, ht = class {
|
|
|
1200
1216
|
let { signal: a } = this.activeRequestController;
|
|
1201
1217
|
this.slowResponseTimer = setTimeout(() => {
|
|
1202
1218
|
this.slowResponseTimer = null, this.setState({ isSlowResponse: !0 });
|
|
1203
|
-
},
|
|
1219
|
+
}, vt);
|
|
1204
1220
|
let o = () => {
|
|
1205
1221
|
this.setState({
|
|
1206
1222
|
runtimeError: "Something went wrong, please try again.",
|
|
@@ -1208,10 +1224,10 @@ var mt = 8e3, ht = class {
|
|
|
1208
1224
|
});
|
|
1209
1225
|
}, s = "";
|
|
1210
1226
|
try {
|
|
1211
|
-
for await (let n of
|
|
1212
|
-
else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await
|
|
1227
|
+
for await (let n of ot(t, this.sessionToken, this.conversationId, e, a)) if (n.type === "conversation_id") this.conversationId = n.conversationId, gt(this.storageIdentifier, n.conversationId);
|
|
1228
|
+
else if (n.type === "delta") this.clearSlowResponse(), n.verbatim && !this.prefersReducedMotion ? (await pt(n.delta, (e) => i(e), { signal: a }), s = n.delta) : n.verbatim ? (s = n.delta, i(s)) : (s += n.delta, i(s));
|
|
1213
1229
|
else if (n.type === "done") {
|
|
1214
|
-
if (n.conversationId && (this.conversationId = n.conversationId,
|
|
1230
|
+
if (n.conversationId && (this.conversationId = n.conversationId, gt(this.storageIdentifier, n.conversationId)), n.messageId) {
|
|
1215
1231
|
let e = [...this.state.messages];
|
|
1216
1232
|
e[e.length - 1] = {
|
|
1217
1233
|
...e[e.length - 1],
|
|
@@ -1252,7 +1268,7 @@ var mt = 8e3, ht = class {
|
|
|
1252
1268
|
}
|
|
1253
1269
|
} });
|
|
1254
1270
|
try {
|
|
1255
|
-
await
|
|
1271
|
+
await at(i, this.sessionToken, {
|
|
1256
1272
|
messageId: e,
|
|
1257
1273
|
rating: t,
|
|
1258
1274
|
correction: n,
|
|
@@ -1274,9 +1290,9 @@ var mt = 8e3, ht = class {
|
|
|
1274
1290
|
} });
|
|
1275
1291
|
}
|
|
1276
1292
|
}
|
|
1277
|
-
},
|
|
1278
|
-
function
|
|
1279
|
-
if (
|
|
1293
|
+
}, 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}", xt = /^(inherit|initial|unset|revert|revert-layer)$|\bcurrentcolor\b|\b(var|env|attr|light-dark)\(/i;
|
|
1294
|
+
function St(e) {
|
|
1295
|
+
if (xt.test(e.trim())) return null;
|
|
1280
1296
|
let t = document.createElement("div");
|
|
1281
1297
|
if (t.style.color = e, t.style.color === "") return null;
|
|
1282
1298
|
let n = document.createElement("div");
|
|
@@ -1295,8 +1311,8 @@ function vt(e) {
|
|
|
1295
1311
|
translucent: a < 1
|
|
1296
1312
|
};
|
|
1297
1313
|
}
|
|
1298
|
-
function
|
|
1299
|
-
return
|
|
1314
|
+
function Ct(e) {
|
|
1315
|
+
return St(e)?.rgb ?? null;
|
|
1300
1316
|
}
|
|
1301
1317
|
function X([e, t, n]) {
|
|
1302
1318
|
let r = (e) => {
|
|
@@ -1305,54 +1321,54 @@ function X([e, t, n]) {
|
|
|
1305
1321
|
};
|
|
1306
1322
|
return .2126 * r(e) + .7152 * r(t) + .0722 * r(n);
|
|
1307
1323
|
}
|
|
1308
|
-
function
|
|
1324
|
+
function Z(e, t) {
|
|
1309
1325
|
let n = Math.max(e, t), r = Math.min(e, t);
|
|
1310
1326
|
return (n + .05) / (r + .05);
|
|
1311
1327
|
}
|
|
1312
|
-
function
|
|
1313
|
-
let t =
|
|
1328
|
+
function wt(e) {
|
|
1329
|
+
let t = Ct(e);
|
|
1314
1330
|
if (!t) return console.warn(`[whoo-aiden-widget] Could not parse color "${e}" for contrast calculation; defaulting to white text.`), "#ffffff";
|
|
1315
1331
|
let n = X(t);
|
|
1316
|
-
return
|
|
1332
|
+
return Z(n, X([
|
|
1317
1333
|
0,
|
|
1318
1334
|
0,
|
|
1319
1335
|
0
|
|
1320
|
-
])) >=
|
|
1336
|
+
])) >= Z(n, X([
|
|
1321
1337
|
255,
|
|
1322
1338
|
255,
|
|
1323
1339
|
255
|
|
1324
1340
|
])) ? "#000000" : "#ffffff";
|
|
1325
1341
|
}
|
|
1326
|
-
var
|
|
1327
|
-
function
|
|
1342
|
+
var Q = "#4f46e5", Tt = "#ffffff", Et = "#f0f0f0", Dt = 4.5;
|
|
1343
|
+
function Ot([e, t, n]) {
|
|
1328
1344
|
return `#${[
|
|
1329
1345
|
e,
|
|
1330
1346
|
t,
|
|
1331
1347
|
n
|
|
1332
1348
|
].map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
1333
1349
|
}
|
|
1334
|
-
function
|
|
1335
|
-
let n =
|
|
1336
|
-
if (!n || !r) return
|
|
1337
|
-
let i = X(r), a = (e) =>
|
|
1338
|
-
if (a(n)) return
|
|
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);
|
|
1339
1355
|
for (let e = .99; e > 0; e -= .01) {
|
|
1340
1356
|
let t = n.map((t) => Math.round(t * e));
|
|
1341
|
-
if (a(t)) return
|
|
1357
|
+
if (a(t)) return Ot(t);
|
|
1342
1358
|
}
|
|
1343
1359
|
return "#000000";
|
|
1344
1360
|
}
|
|
1345
|
-
var
|
|
1346
|
-
function
|
|
1361
|
+
var At = "#111111", jt = "#0000ee";
|
|
1362
|
+
function $(e) {
|
|
1347
1363
|
if (!e) return null;
|
|
1348
|
-
let t =
|
|
1349
|
-
return t ?
|
|
1364
|
+
let t = St(e);
|
|
1365
|
+
return t ? Ot(t.rgb) : null;
|
|
1350
1366
|
}
|
|
1351
|
-
function
|
|
1352
|
-
let r =
|
|
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;
|
|
1353
1369
|
return {
|
|
1354
1370
|
primary: i,
|
|
1355
|
-
textOnPrimary:
|
|
1371
|
+
textOnPrimary: wt(i),
|
|
1356
1372
|
primaryAsText: a,
|
|
1357
1373
|
ink: s,
|
|
1358
1374
|
link: l,
|
|
@@ -1363,24 +1379,24 @@ function $({ color: e, inkColor: t, accentColor: n }) {
|
|
|
1363
1379
|
}
|
|
1364
1380
|
};
|
|
1365
1381
|
}
|
|
1366
|
-
function
|
|
1382
|
+
function Nt(e, t, n = Q) {
|
|
1367
1383
|
let r = t;
|
|
1368
|
-
|
|
1369
|
-
let i =
|
|
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 });
|
|
1370
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);
|
|
1371
1387
|
}
|
|
1372
|
-
function
|
|
1373
|
-
let r =
|
|
1388
|
+
function Pt(e, { inkColor: t, accentColor: n }) {
|
|
1389
|
+
let r = Mt({
|
|
1374
1390
|
inkColor: t,
|
|
1375
1391
|
accentColor: n
|
|
1376
1392
|
});
|
|
1377
1393
|
e.style.setProperty("--whoo-widget-ink", r.ink), e.style.setProperty("--whoo-widget-link-color", r.link);
|
|
1378
1394
|
}
|
|
1379
|
-
function
|
|
1380
|
-
e &&
|
|
1395
|
+
function Ft(e, t) {
|
|
1396
|
+
e && $(e) === null && console.warn(`[whoo-aiden-widget] Could not use "${e}" as the ${t}; using the default.`);
|
|
1381
1397
|
}
|
|
1382
|
-
function
|
|
1383
|
-
|
|
1398
|
+
function It(e, t) {
|
|
1399
|
+
Nt(e, t.color ?? Q), Ft(t.inkColor, "ink color"), Ft(t.accentColor, "accent color"), Pt(e, {
|
|
1384
1400
|
inkColor: t.inkColor,
|
|
1385
1401
|
accentColor: t.accentColor
|
|
1386
1402
|
});
|
|
@@ -1389,29 +1405,29 @@ function Mt(e, t) {
|
|
|
1389
1405
|
}
|
|
1390
1406
|
//#endregion
|
|
1391
1407
|
//#region src/mount.tsx
|
|
1392
|
-
function
|
|
1408
|
+
function Lt(e) {
|
|
1393
1409
|
let t = document.createElement("div");
|
|
1394
|
-
t.id = "whoo-aiden-widget-host";
|
|
1395
|
-
let
|
|
1396
|
-
|
|
1397
|
-
let
|
|
1398
|
-
|
|
1399
|
-
let
|
|
1400
|
-
return
|
|
1401
|
-
t.primaryColor && t.primaryColor !==
|
|
1410
|
+
t.id = "whoo-aiden-widget-host", t.style.position = "relative", t.style.zIndex = String(n(e.zIndex));
|
|
1411
|
+
let r = t.attachShadow({ mode: "open" }), i = document.createElement("style");
|
|
1412
|
+
i.textContent = bt, r.appendChild(i);
|
|
1413
|
+
let a = document.createElement("div");
|
|
1414
|
+
r.appendChild(a), It(a, e);
|
|
1415
|
+
let o = new yt(e), s = null, c = "";
|
|
1416
|
+
return o.subscribe((t) => {
|
|
1417
|
+
t.primaryColor && t.primaryColor !== s && (s = t.primaryColor, Nt(a, t.primaryColor, e.color));
|
|
1402
1418
|
let n = `${t.inkColor}|${t.accentColor}`;
|
|
1403
|
-
(t.inkColor || t.accentColor) && n !==
|
|
1404
|
-
inkColor:
|
|
1405
|
-
accentColor:
|
|
1419
|
+
(t.inkColor || t.accentColor) && n !== c && (c = n, Pt(a, {
|
|
1420
|
+
inkColor: $(t.inkColor) ? t.inkColor : e.inkColor,
|
|
1421
|
+
accentColor: $(t.accentColor) ? t.accentColor : e.accentColor
|
|
1406
1422
|
}));
|
|
1407
|
-
}),
|
|
1408
|
-
|
|
1423
|
+
}), pe(/* @__PURE__ */ U(tt, { controller: o }), a), o.init(), document.body.appendChild(t), { unmount() {
|
|
1424
|
+
pe(null, a), t.remove();
|
|
1409
1425
|
} };
|
|
1410
1426
|
}
|
|
1411
1427
|
//#endregion
|
|
1412
1428
|
//#region src/index.ts
|
|
1413
|
-
function
|
|
1414
|
-
return e
|
|
1429
|
+
function Rt(e) {
|
|
1430
|
+
return r(e), Lt(e);
|
|
1415
1431
|
}
|
|
1416
1432
|
//#endregion
|
|
1417
|
-
export {
|
|
1433
|
+
export { Rt as init, Mt as resolveTheme };
|