@usereq/widget 0.2.25 → 1.0.0-experimental.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/dist/embed.mjs ADDED
@@ -0,0 +1,2839 @@
1
+ async function Vt(e) {
2
+ const t = e.getReader(), n = new TextDecoder();
3
+ let r = "", o = "";
4
+ const i = [], a = /* @__PURE__ */ new Map(), u = (d) => {
5
+ if (!d.startsWith("data:")) return;
6
+ const c = d.slice(5).trim();
7
+ if (!c || c === "[DONE]") return;
8
+ let f;
9
+ try {
10
+ f = JSON.parse(c);
11
+ } catch {
12
+ return;
13
+ }
14
+ switch (f.type) {
15
+ case "start":
16
+ "messageId" in f && f.messageId && (o = f.messageId);
17
+ break;
18
+ case "text-start":
19
+ "id" in f && (i.push(f.id), a.set(f.id, ""));
20
+ break;
21
+ case "text-delta":
22
+ if ("id" in f && "delta" in f) {
23
+ var p;
24
+ a.set(f.id, ((p = a.get(f.id)) !== null && p !== void 0 ? p : "") + f.delta);
25
+ }
26
+ break;
27
+ case "error":
28
+ throw new Error("errorText" in f ? f.errorText : "The reply failed.");
29
+ case "abort":
30
+ throw new Error("The reply was cut short.");
31
+ }
32
+ };
33
+ for (; ; ) {
34
+ const { done: d, value: c } = await t.read();
35
+ if (d) break;
36
+ r += n.decode(c, { stream: !0 });
37
+ let f;
38
+ for (; (f = r.indexOf(`
39
+ `)) !== -1; )
40
+ u(r.slice(0, f).replace(/\r$/, "")), r = r.slice(f + 1);
41
+ }
42
+ return r && u(r), {
43
+ id: o || `reply-${Date.now()}`,
44
+ parts: i.map((d) => {
45
+ var c;
46
+ return (c = a.get(d)) !== null && c !== void 0 ? c : "";
47
+ })
48
+ };
49
+ }
50
+ function Z(e) {
51
+ "@babel/helpers - typeof";
52
+ return Z = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(t) {
53
+ return typeof t;
54
+ } : function(t) {
55
+ return t && typeof Symbol == "function" && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
56
+ }, Z(e);
57
+ }
58
+ function Kt(e, t) {
59
+ if (Z(e) != "object" || !e) return e;
60
+ var n = e[Symbol.toPrimitive];
61
+ if (n !== void 0) {
62
+ var r = n.call(e, t || "default");
63
+ if (Z(r) != "object") return r;
64
+ throw new TypeError("@@toPrimitive must return a primitive value.");
65
+ }
66
+ return (t === "string" ? String : Number)(e);
67
+ }
68
+ function Xt(e) {
69
+ var t = Kt(e, "string");
70
+ return Z(t) == "symbol" ? t : t + "";
71
+ }
72
+ function Ee(e, t, n) {
73
+ return (t = Xt(t)) in e ? Object.defineProperty(e, t, {
74
+ value: n,
75
+ enumerable: !0,
76
+ configurable: !0,
77
+ writable: !0
78
+ }) : e[t] = n, e;
79
+ }
80
+ var ce = class extends Error {
81
+ constructor(e, t, n) {
82
+ super(n), Ee(this, "status", void 0), Ee(this, "code", void 0), this.status = e, this.code = t;
83
+ }
84
+ };
85
+ async function Pe(e) {
86
+ let t = "request_failed", n = `The request failed (${e.status}).`;
87
+ try {
88
+ var r, o;
89
+ const i = await e.json();
90
+ !((r = i.error) === null || r === void 0) && r.code && (t = i.error.code), !((o = i.error) === null || o === void 0) && o.message && (n = i.error.message);
91
+ } catch {
92
+ }
93
+ throw new ce(e.status, t, n);
94
+ }
95
+ var Fe = (e, t = {}) => ({
96
+ method: "POST",
97
+ headers: {
98
+ "Content-Type": "application/json",
99
+ ...t
100
+ },
101
+ body: JSON.stringify(e)
102
+ });
103
+ async function Jt(e, t, n) {
104
+ const r = await fetch(`${e.base}/api/embed/${t}/${n}`);
105
+ return r.ok ? r.json() : Pe(r);
106
+ }
107
+ async function Zt(e, t) {
108
+ const n = await fetch(`${e.base}/api/embed/sessions`, Fe(t));
109
+ return n.ok ? n.json() : Pe(n);
110
+ }
111
+ async function Qt(e, t, n, r, o) {
112
+ const i = await fetch(`${e.base}/api/embed/chat`, {
113
+ ...Fe({
114
+ message: {
115
+ id: n.id,
116
+ role: "user",
117
+ parts: [{
118
+ type: "text",
119
+ text: n.text
120
+ }]
121
+ },
122
+ trigger: r
123
+ }, { Authorization: `Bearer ${t}` }),
124
+ signal: o
125
+ });
126
+ return !i.ok || !i.body ? Pe(i) : Vt(i.body);
127
+ }
128
+ async function en(e, t) {
129
+ try {
130
+ const n = await fetch(`${e.base}/api/embed/events`, {
131
+ ...Fe(t),
132
+ keepalive: !0
133
+ });
134
+ return n.ok ? await n.json() : null;
135
+ } catch {
136
+ return null;
137
+ }
138
+ }
139
+ var O = (e) => typeof e == "object" && e !== null;
140
+ function _t(e) {
141
+ return O(e) && typeof e.id == "string" && O(e.config) && typeof e.config.type == "string" && O(e.config.appearance) && Array.isArray(e.rules);
142
+ }
143
+ function tn(e) {
144
+ return O(e) && typeof e.id == "string" && typeof e.mode == "string" && O(e.config) && Array.isArray(e.members) && e.members.every((t) => O(t) && _t(t.widget)) && Array.isArray(e.rules);
145
+ }
146
+ function nn(e, t) {
147
+ return !O(e) || e.kind !== t ? null : t === "widget" && _t(e.payload) || t === "group" && tn(e.payload) ? e : null;
148
+ }
149
+ var _e, C, gt, rn, L, Ve, mt, bt, $e, ie, J, vt, je, ze, He, on, ue = {}, de = [], an = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, ge = Array.isArray;
150
+ function B(e, t) {
151
+ for (var n in t) e[n] = t[n];
152
+ return e;
153
+ }
154
+ function Be(e) {
155
+ e && e.parentNode && e.parentNode.removeChild(e);
156
+ }
157
+ function sn(e, t, n) {
158
+ var r, o, i, a = {};
159
+ for (i in t) i == "key" ? r = t[i] : i == "ref" ? o = t[i] : a[i] = t[i];
160
+ if (arguments.length > 2 && (a.children = arguments.length > 3 ? _e.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (i in e.defaultProps) a[i] === void 0 && (a[i] = e.defaultProps[i]);
161
+ return oe(e, a, r, o, null);
162
+ }
163
+ function oe(e, t, n, r, o) {
164
+ var i = {
165
+ type: e,
166
+ props: t,
167
+ key: n,
168
+ ref: r,
169
+ __k: null,
170
+ __: null,
171
+ __b: 0,
172
+ __e: null,
173
+ __c: null,
174
+ constructor: void 0,
175
+ __v: o == null ? ++gt : o,
176
+ __i: -1,
177
+ __u: 0
178
+ };
179
+ return o == null && C.vnode != null && C.vnode(i), i;
180
+ }
181
+ function W(e) {
182
+ return e.children;
183
+ }
184
+ function ae(e, t) {
185
+ this.props = e, this.context = t;
186
+ }
187
+ function U(e, t) {
188
+ if (t == null) return e.__ ? U(e.__, e.__i + 1) : null;
189
+ for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
190
+ return typeof e.type == "function" ? U(e) : null;
191
+ }
192
+ function ln(e) {
193
+ if (e.__P && e.__d) {
194
+ var t = e.__v, n = t.__e, r = [], o = [], i = B({}, t);
195
+ i.__v = t.__v + 1, C.vnode && C.vnode(i), De(e.__P, i, t, e.__n, e.__P.namespaceURI, 32 & t.__u ? [n] : null, r, n == null ? U(t) : n, !!(32 & t.__u), o), i.__v = t.__v, i.__.__k[i.__i] = i, St(r, i, o), t.__e = t.__ = null, i.__e != n && yt(i);
196
+ }
197
+ }
198
+ function yt(e) {
199
+ if ((e = e.__) != null && e.__c != null) return e.__e = e.__c.base = null, e.__k.some(function(t) {
200
+ if (t != null && t.__e != null) return e.__e = e.__c.base = t.__e;
201
+ }), yt(e);
202
+ }
203
+ function Ke(e) {
204
+ (!e.__d && (e.__d = !0) && L.push(e) && !fe.__r++ || Ve != C.debounceRendering) && ((Ve = C.debounceRendering) || mt)(fe);
205
+ }
206
+ function fe() {
207
+ try {
208
+ for (var e, t = 1; L.length; ) L.length > t && L.sort(bt), e = L.shift(), t = L.length, ln(e);
209
+ } finally {
210
+ L.length = fe.__r = 0;
211
+ }
212
+ }
213
+ function xt(e, t, n, r, o, i, a, u, d, c, f) {
214
+ var p, l, h, m, y, w, _ = r && r.__k || de, g = t.length;
215
+ for (d = cn(n, t, _, d, g), p = 0; p < g; p++) (h = n.__k[p]) != null && (l = h.__i != -1 && _[h.__i] || ue, h.__i = p, w = De(e, h, l, o, i, a, u, d, c, f), m = h.__e, h.ref && l.ref != h.ref && (l.ref && Le(l.ref, null, h), f.push(h.ref, h.__c || m, h)), y == null && m != null && (y = m), 4 & h.__u ? (d = wt(h, d, e), l.__e && (l.__e = null)) : typeof h.type == "function" && w !== void 0 ? d = w : m && (d = m.nextSibling), h.__u &= -7);
216
+ return n.__e = y, d;
217
+ }
218
+ function cn(e, t, n, r, o) {
219
+ var i, a, u, d, c, f = n.length, p = f, l = 0;
220
+ for (e.__k = new Array(o), i = 0; i < o; i++) (a = t[i]) != null && typeof a != "boolean" && typeof a != "function" ? (typeof a == "string" || typeof a == "number" || typeof a == "bigint" || a.constructor == String ? a = e.__k[i] = oe(null, a, null, null, null) : ge(a) ? a = e.__k[i] = oe(W, { children: a }, null, null, null) : a.constructor === void 0 && a.__b > 0 ? a = e.__k[i] = oe(a.type, a.props, a.key, a.ref ? a.ref : null, a.__v) : e.__k[i] = a, d = i + l, a.__ = e, a.__b = e.__b + 1, u = null, (c = a.__i = un(a, n, d, p)) != -1 && (p--, (u = n[c]) && (u.__u |= 2)), u == null || u.__v == null ? (c == -1 && (o > f ? l-- : o < f && l++), typeof a.type != "function" && (a.__u |= 4)) : c != d && (c == d - 1 ? l-- : c == d + 1 ? l++ : (c > d ? l-- : l++, a.__u |= 4))) : e.__k[i] = null;
221
+ if (p) for (i = 0; i < f; i++) (u = n[i]) != null && (2 & u.__u) == 0 && (u.__e == r && (r = U(u)), Ct(u, u));
222
+ return r;
223
+ }
224
+ function wt(e, t, n) {
225
+ var r, o;
226
+ if (typeof e.type == "function") {
227
+ for (r = e.__k, o = 0; r && o < r.length; o++) r[o] && (r[o].__ = e, t = wt(r[o], t, n));
228
+ return t;
229
+ }
230
+ e.__e != t && (t && e.type && !t.parentNode && (t = U(e)), t = n.insertBefore(e.__e, t || null));
231
+ do
232
+ t = t && t.nextSibling;
233
+ while (t != null && t.nodeType == 8);
234
+ return t;
235
+ }
236
+ function un(e, t, n, r) {
237
+ var o, i, a, u = e.key, d = e.type, c = t[n], f = c != null && (2 & c.__u) == 0;
238
+ if (c === null && u == null || f && u == c.key && d == c.type) return n;
239
+ if (r > (f ? 1 : 0)) {
240
+ for (o = n - 1, i = n + 1; o >= 0 || i < t.length; ) if ((c = t[a = o >= 0 ? o-- : i++]) != null && (2 & c.__u) == 0 && u == c.key && d == c.type) return a;
241
+ }
242
+ return -1;
243
+ }
244
+ function Xe(e, t, n) {
245
+ t[0] == "-" ? e.setProperty(t, n == null ? "" : n) : e[t] = n == null ? "" : typeof n != "number" || an.test(t) ? n : n + "px";
246
+ }
247
+ function te(e, t, n, r, o) {
248
+ var i, a;
249
+ e: if (t == "style") if (typeof n == "string") e.style.cssText = n;
250
+ else {
251
+ if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || Xe(e.style, t, "");
252
+ if (n) for (t in n) r && n[t] == r[t] || Xe(e.style, t, n[t]);
253
+ }
254
+ else if (t[0] == "o" && t[1] == "n") i = t != (t = t.replace(vt, "$1")), a = t.toLowerCase(), t = a in e || t == "onFocusOut" || t == "onFocusIn" ? a.slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + i] = n, n ? r ? n[J] = r[J] : (n[J] = je, e.addEventListener(t, i ? He : ze, i)) : e.removeEventListener(t, i ? He : ze, i);
255
+ else {
256
+ if (o == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
257
+ 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 {
258
+ e[t] = n == null ? "" : n;
259
+ break e;
260
+ } catch {
261
+ }
262
+ typeof n == "function" || (n == null || n === !1 && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
263
+ }
264
+ }
265
+ function Je(e) {
266
+ return function(t) {
267
+ if (this.l) {
268
+ var n = this.l[t.type + e];
269
+ if (t[ie] == null) t[ie] = je++;
270
+ else if (t[ie] < n[J]) return;
271
+ return n(C.event ? C.event(t) : t);
272
+ }
273
+ };
274
+ }
275
+ function De(e, t, n, r, o, i, a, u, d, c) {
276
+ var f, p, l, h, m, y, w, _, g, v, k, x, q, $, z, H, A = t.type;
277
+ if (t.constructor !== void 0) return null;
278
+ 128 & n.__u && (d = !!(32 & n.__u), i = [u = t.__e = n.__e]), (f = C.__b) && f(t);
279
+ e: if (typeof A == "function") {
280
+ p = a.length;
281
+ try {
282
+ if (g = t.props, v = A.prototype && A.prototype.render, k = (f = A.contextType) && r[f.__c], x = f ? k ? k.props.value : f.__ : r, n.__c ? _ = (l = t.__c = n.__c).__ = l.__E : (v ? t.__c = l = new A(g, x) : (t.__c = l = new ae(g, x), l.constructor = A, l.render = fn), k && k.sub(l), l.state || (l.state = {}), l.__n = r, h = l.__d = !0, l.__h = [], l._sb = []), v && l.__s == null && (l.__s = l.state), v && A.getDerivedStateFromProps != null && (l.__s == l.state && (l.__s = B({}, l.__s)), B(l.__s, A.getDerivedStateFromProps(g, l.__s))), m = l.props, y = l.state, l.__v = t, h) v && A.getDerivedStateFromProps == null && l.componentWillMount != null && l.componentWillMount(), v && l.componentDidMount != null && l.__h.push(l.componentDidMount);
283
+ else {
284
+ if (v && A.getDerivedStateFromProps == null && g !== m && l.componentWillReceiveProps != null && l.componentWillReceiveProps(g, x), t.__v == n.__v || !l.__e && l.shouldComponentUpdate != null && l.shouldComponentUpdate(g, l.__s, x) === !1) {
285
+ t.__v != n.__v && (l.props = g, l.state = l.__s, l.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(R) {
286
+ R && (R.__ = t);
287
+ }), de.push.apply(l.__h, l._sb), l._sb = [], l.__h.length && a.push(l), u = U(n);
288
+ break e;
289
+ }
290
+ l.componentWillUpdate != null && l.componentWillUpdate(g, l.__s, x), v && l.componentDidUpdate != null && l.__h.push(function() {
291
+ l.componentDidUpdate(m, y, w);
292
+ });
293
+ }
294
+ if (l.context = x, l.props = g, l.__P = e, l.__e = !1, q = C.__r, $ = 0, v) l.state = l.__s, l.__d = !1, q && q(t), f = l.render(l.props, l.state, l.context), de.push.apply(l.__h, l._sb), l._sb = [];
295
+ else do
296
+ l.__d = !1, q && q(t), f = l.render(l.props, l.state, l.context), l.state = l.__s;
297
+ while (l.__d && ++$ < 25);
298
+ l.state = l.__s, l.getChildContext != null && (r = B(B({}, r), l.getChildContext())), v && !h && l.getSnapshotBeforeUpdate != null && (w = l.getSnapshotBeforeUpdate(m, y)), z = f != null && f.type === W && f.key == null ? $t(f.props.children) : f, u = xt(e, ge(z) ? z : [z], t, n, r, o, i, a, u, d, c), l.base = t.__e, t.__u &= -161, l.__h.length && a.push(l), _ && (l.__E = l.__ = null);
299
+ } catch (R) {
300
+ if (a.length = p, t.__v = null, d || i != null) {
301
+ if (R.then) {
302
+ for (t.__u |= d ? 160 : 128; u && u.nodeType == 8 && u.nextSibling; ) u = u.nextSibling;
303
+ i != null && (i[i.indexOf(u)] = null), t.__e = u;
304
+ } else if (i != null) for (H = i.length; H--; ) Be(i[H]);
305
+ } else t.__e = n.__e;
306
+ t.__k == null && (t.__k = n.__k || []), R.then || kt(t), C.__e(R, t, n);
307
+ }
308
+ } else i == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : u = t.__e = dn(n.__e, t, n, r, o, i, a, d, c);
309
+ return (f = C.diffed) && f(t), 128 & t.__u ? void 0 : u;
310
+ }
311
+ function kt(e) {
312
+ e && (e.__c && (e.__c.__e = !0), e.__k && e.__k.some(kt));
313
+ }
314
+ function St(e, t, n) {
315
+ for (var r = 0; r < n.length; r++) Le(n[r], n[++r], n[++r]);
316
+ C.__c && C.__c(t, e), e.some(function(o) {
317
+ try {
318
+ e = o.__h, o.__h = [], e.some(function(i) {
319
+ i.call(o);
320
+ });
321
+ } catch (i) {
322
+ C.__e(i, o.__v);
323
+ }
324
+ });
325
+ }
326
+ function $t(e) {
327
+ return typeof e != "object" || e == null || e.__b > 0 ? e : ge(e) ? e.map($t) : e.constructor !== void 0 ? null : B({}, e);
328
+ }
329
+ function dn(e, t, n, r, o, i, a, u, d) {
330
+ var c, f, p, l, h, m, y, w = n.props || ue, _ = t.props, g = t.type;
331
+ if (g == "svg" ? o = "http://www.w3.org/2000/svg" : g == "math" ? o = "http://www.w3.org/1998/Math/MathML" : o || (o = "http://www.w3.org/1999/xhtml"), i != null) {
332
+ for (c = 0; c < i.length; c++) if ((h = i[c]) && "setAttribute" in h == !!g && (g ? h.localName == g : h.nodeType == 3)) {
333
+ e = h, i[c] = null;
334
+ break;
335
+ }
336
+ }
337
+ if (e == null) {
338
+ if (g == null) return document.createTextNode(_);
339
+ e = document.createElementNS(o, g, _.is && _), u && (C.__m && C.__m(t, i), u = !1), i = null;
340
+ }
341
+ if (g == null) w === _ || u && e.data == _ || (e.data = _);
342
+ else {
343
+ if (i = g == "textarea" && _.defaultValue != null ? null : i && _e.call(e.childNodes), !u && i != null) for (w = {}, c = 0; c < e.attributes.length; c++) w[(h = e.attributes[c]).name] = h.value;
344
+ for (c in w) h = w[c], c == "dangerouslySetInnerHTML" ? p = h : c == "children" || c in _ || c == "value" && "defaultValue" in _ || c == "checked" && "defaultChecked" in _ || te(e, c, null, h, o);
345
+ for (c in _) h = _[c], c == "children" ? l = h : c == "dangerouslySetInnerHTML" ? f = h : c == "value" ? m = h : c == "checked" ? y = h : u && typeof h != "function" || w[c] === h || te(e, c, h, w[c], o);
346
+ if (f) u || p && (f.__html == p.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), t.__k = [];
347
+ else if (p && (e.innerHTML = ""), xt(t.type == "template" ? e.content : e, ge(l) ? l : [l], t, n, r, g == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o, i, a, i ? i[0] : n.__k && U(n, 0), u, d), i != null) for (c = i.length; c--; ) Be(i[c]);
348
+ u && g != "textarea" || (c = "value", g == "progress" && m == null ? e.removeAttribute("value") : m != null && (m !== e[c] || g == "progress" && !m || g == "option" && m != w[c]) && te(e, c, m, w[c], o), c = "checked", y != null && y != e[c] && te(e, c, y, w[c], o));
349
+ }
350
+ return e;
351
+ }
352
+ function Le(e, t, n) {
353
+ try {
354
+ if (typeof e == "function") {
355
+ var r = typeof e.__u == "function";
356
+ r && e.__u(), r && t == null || (e.__u = e(t));
357
+ } else e.current = t;
358
+ } catch (o) {
359
+ C.__e(o, n);
360
+ }
361
+ }
362
+ function Ct(e, t, n) {
363
+ var r, o;
364
+ if (C.unmount && C.unmount(e), (r = e.ref) && (r.current && r.current != e.__e || Le(r, null, t)), (r = e.__c) != null) {
365
+ if (r.componentWillUnmount) try {
366
+ r.componentWillUnmount();
367
+ } catch (i) {
368
+ C.__e(i, t);
369
+ }
370
+ r.base = r.__P = r.__n = null;
371
+ }
372
+ if (r = e.__k) for (o = 0; o < r.length; o++) r[o] && Ct(r[o], t, n || typeof e.type != "function");
373
+ n || Be(e.__e), e.__c = e.__ = e.__e = void 0;
374
+ }
375
+ function fn(e, t, n) {
376
+ return this.constructor(e, n);
377
+ }
378
+ function Ze(e, t, n) {
379
+ var r, o, i, a;
380
+ t == document && (t = document.documentElement), C.__ && C.__(e, t), o = (r = typeof n == "function") ? null : n && n.__k || t.__k, i = [], a = [], De(t, e = (!r && n || t).__k = sn(W, null, [e]), o || ue, ue, t.namespaceURI, !r && n ? [n] : o ? null : t.firstChild ? _e.call(t.childNodes) : null, i, !r && n ? n : o ? o.__e : t.firstChild, r, a), St(i, e, a), e.props.children = null;
381
+ }
382
+ _e = de.slice, C = { __e: function(e, t, n, r) {
383
+ for (var o, i, a; t = t.__; ) if ((o = t.__c) && !o.__) try {
384
+ if ((i = o.constructor) && i.getDerivedStateFromError != null && (o.setState(i.getDerivedStateFromError(e)), a = o.__d), o.componentDidCatch != null && (o.componentDidCatch(e, r || {}), a = o.__d), a) return o.__E = o;
385
+ } catch (u) {
386
+ e = u;
387
+ }
388
+ throw e;
389
+ } }, gt = 0, rn = function(e) {
390
+ return e != null && e.constructor === void 0;
391
+ }, ae.prototype.setState = function(e, t) {
392
+ var n = this.__s != null && this.__s != this.state ? this.__s : this.__s = B({}, this.state);
393
+ typeof e == "function" && (e = e(B({}, n), this.props)), e && B(n, e), e != null && this.__v && (t && this._sb.push(t), Ke(this));
394
+ }, ae.prototype.forceUpdate = function(e) {
395
+ this.__v && (this.__e = !0, e && this.__h.push(e), Ke(this));
396
+ }, ae.prototype.render = W, L = [], mt = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, bt = function(e, t) {
397
+ return e.__v.__b - t.__v.__b;
398
+ }, fe.__r = 0, $e = Math.random().toString(8), ie = "__d" + $e, J = "__a" + $e, vt = /(PointerCapture)$|Capture$/i, je = 0, ze = Je(!1), He = Je(!0), on = 0;
399
+ var Q, M, Ce, Qe, ee = 0, qt = [], T = C, et = T.__b, tt = T.__r, nt = T.diffed, rt = T.__c, it = T.unmount, ot = T.__;
400
+ function We(e, t) {
401
+ T.__h && T.__h(M, e, ee || t), ee = 0;
402
+ var n = M.__H || (M.__H = {
403
+ __: [],
404
+ __h: []
405
+ });
406
+ return e >= n.__.length && n.__.push({}), n.__[e];
407
+ }
408
+ function E(e) {
409
+ return ee = 1, hn(Mt, e);
410
+ }
411
+ function hn(e, t, n) {
412
+ var r = We(Q++, 2);
413
+ if (r.t = e, !r.__c && (r.__ = [n ? n(t) : Mt(void 0, t), function(u) {
414
+ var d = r.__N ? r.__N[0] : r.__[0], c = r.t(d, u);
415
+ d !== c && (r.__N = [c, r.__[1]], r.__c.setState({}));
416
+ }], r.__c = M, !M.__f)) {
417
+ var o = function(u, d, c) {
418
+ if (!r.__c.__H) return !0;
419
+ var f = !1, p = r.__c.props !== u;
420
+ if (r.__c.__H.__.some(function(h) {
421
+ if (h.__N) {
422
+ f = !0;
423
+ var m = h.__[0];
424
+ h.__ = h.__N, h.__N = void 0, m !== h.__[0] && (p = !0);
425
+ }
426
+ }), i) {
427
+ var l = i.call(this, u, d, c);
428
+ return f ? l || p : l;
429
+ }
430
+ return !f || p;
431
+ };
432
+ M.__f = !0;
433
+ var i = M.shouldComponentUpdate, a = M.componentWillUpdate;
434
+ M.componentWillUpdate = function(u, d, c) {
435
+ if (this.__e) {
436
+ var f = i;
437
+ i = void 0, o(u, d, c), i = f;
438
+ }
439
+ a && a.call(this, u, d, c);
440
+ }, M.shouldComponentUpdate = o;
441
+ }
442
+ return r.__N || r.__;
443
+ }
444
+ function P(e, t) {
445
+ var n = We(Q++, 3);
446
+ !T.__s && It(n.__H, t) && (n.__ = e, n.u = t, M.__H.__h.push(n));
447
+ }
448
+ function F(e) {
449
+ return ee = 5, he(function() {
450
+ return { current: e };
451
+ }, []);
452
+ }
453
+ function he(e, t) {
454
+ var n = We(Q++, 7);
455
+ return It(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
456
+ }
457
+ function X(e, t) {
458
+ return ee = 8, he(function() {
459
+ return e;
460
+ }, t);
461
+ }
462
+ function pn() {
463
+ for (var e; e = qt.shift(); ) {
464
+ var t = e.__H;
465
+ if (e.__P && t) try {
466
+ t.__h.some(se), t.__h.some(Re), t.__h = [];
467
+ } catch (n) {
468
+ t.__h = [], T.__e(n, e.__v);
469
+ }
470
+ }
471
+ }
472
+ T.__b = function(e) {
473
+ M = null, et && et(e);
474
+ }, T.__ = function(e, t) {
475
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), ot && ot(e, t);
476
+ }, T.__r = function(e) {
477
+ tt && tt(e), Q = 0;
478
+ var t = (M = e.__c).__H;
479
+ t && (Ce === M ? (t.__h = [], M.__h = [], t.__.some(function(n) {
480
+ n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
481
+ })) : (t.__h.some(se), t.__h.some(Re), t.__h = [], Q = 0)), Ce = M;
482
+ }, T.diffed = function(e) {
483
+ nt && nt(e);
484
+ var t = e.__c;
485
+ t && t.__H && (t.__H.__h.length && (qt.push(t) !== 1 && Qe === T.requestAnimationFrame || ((Qe = T.requestAnimationFrame) || _n)(pn)), t.__H.__.some(function(n) {
486
+ n.u && (n.__H = n.u, n.u = void 0);
487
+ })), Ce = M = null;
488
+ }, T.__c = function(e, t) {
489
+ t.some(function(n) {
490
+ try {
491
+ n.__h.some(se), n.__h = n.__h.filter(function(r) {
492
+ return !r.__ || Re(r);
493
+ });
494
+ } catch (r) {
495
+ t.some(function(o) {
496
+ o.__h && (o.__h = []);
497
+ }), t = [], T.__e(r, n.__v);
498
+ }
499
+ }), rt && rt(e, t);
500
+ }, T.unmount = function(e) {
501
+ it && it(e);
502
+ var t, n = e.__c;
503
+ n && n.__H && (n.__H.__.some(function(r) {
504
+ try {
505
+ se(r);
506
+ } catch (o) {
507
+ t = o;
508
+ }
509
+ }), n.__H = void 0, t && T.__e(t, n.__v));
510
+ };
511
+ var at = typeof requestAnimationFrame == "function";
512
+ function _n(e) {
513
+ var t, n = function() {
514
+ clearTimeout(r), at && cancelAnimationFrame(t), setTimeout(e);
515
+ }, r = setTimeout(n, 35);
516
+ at && (t = requestAnimationFrame(n));
517
+ }
518
+ function se(e) {
519
+ var t = M, n = e.__c;
520
+ typeof n == "function" && (e.__c = void 0, n()), M = t;
521
+ }
522
+ function Re(e) {
523
+ var t = M;
524
+ e.__c = e.__(), M = t;
525
+ }
526
+ function It(e, t) {
527
+ return !e || e.length !== t.length || t.some(function(n, r) {
528
+ return n !== e[r];
529
+ });
530
+ }
531
+ function Mt(e, t) {
532
+ return typeof t == "function" ? t(e) : t;
533
+ }
534
+ var gn = `
535
+ :host{all:initial;display:contents;font-family:system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;font-size:14px;line-height:1.4;-webkit-font-smoothing:antialiased;color:#15171e}
536
+ :host([hidden]){display:none}
537
+ *,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
538
+ button{font:inherit;color:inherit;background:none;border:0;cursor:pointer;-webkit-tap-highlight-color:transparent}
539
+ input{font:inherit;color:inherit;background:none;border:0;outline:0;min-width:0}
540
+ input::placeholder{color:var(--uq-placeholder,inherit);opacity:1}
541
+ input:disabled{cursor:not-allowed}
542
+ button:disabled{cursor:default}
543
+ a{color:inherit;text-decoration:none}
544
+ img,video{display:block;max-width:100%}
545
+ .uq-fixed{position:fixed;z-index:2147483000}
546
+ .uq-inline{display:block}
547
+ .uq-dots{display:inline-flex;gap:3px;align-items:center;height:10px}
548
+ .uq-dots span{width:5px;height:5px;border-radius:50%;background:currentColor;opacity:.35;animation:uq-dot 1.2s infinite ease-in-out}
549
+ .uq-dots span:nth-child(2){animation-delay:.15s}
550
+ .uq-dots span:nth-child(3){animation-delay:.3s}
551
+ @keyframes uq-dot{0%,80%,100%{opacity:.25;transform:translateY(0)}40%{opacity:.9;transform:translateY(-2px)}}
552
+ .uq-rise{animation:uq-rise .22s ease-out both}
553
+ @keyframes uq-rise{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
554
+ .uq-fade{animation:uq-fade .18s ease-out both}
555
+ @keyframes uq-fade{from{opacity:0}to{opacity:1}}
556
+ .uq-drawer{left:0;right:0;bottom:0;display:flex;flex-direction:column;overflow:hidden;padding-bottom:env(safe-area-inset-bottom);transition:height .28s cubic-bezier(.32,.72,0,1),border-radius .28s ease}
557
+ .uq-drawer-half{height:50%}
558
+ .uq-drawer-full{height:100%}
559
+ .uq-drawer-held{transition:none}
560
+ .uq-grab{flex-shrink:0;height:22px;display:flex;align-items:center;justify-content:center;cursor:grab;touch-action:none;user-select:none;-webkit-user-select:none}
561
+ .uq-grab:active{cursor:grabbing}
562
+ .uq-grab span{width:36px;height:4px;border-radius:2px}
563
+ .uq-slide{animation:uq-slide .3s cubic-bezier(.32,.72,0,1) both}
564
+ @keyframes uq-slide{from{transform:translateY(100%)}to{transform:none}}
565
+ @media (prefers-reduced-motion:reduce){.uq-rise,.uq-fade,.uq-slide,.uq-dots span{animation:none}.uq-drawer{transition:none}}
566
+ `;
567
+ function me(e, t) {
568
+ try {
569
+ return window[e].getItem(t);
570
+ } catch {
571
+ return null;
572
+ }
573
+ }
574
+ function be(e, t, n) {
575
+ try {
576
+ window[e].setItem(t, n);
577
+ } catch {
578
+ }
579
+ }
580
+ var mn = 2e3, bn = 20, vn = 100;
581
+ function Ne(e = Date.now()) {
582
+ const t = /* @__PURE__ */ new Uint8Array(16);
583
+ crypto.getRandomValues(t), t[0] = e / 2 ** 40 & 255, t[1] = e / 2 ** 32 & 255, t[2] = e / 2 ** 24 & 255, t[3] = e / 2 ** 16 & 255, t[4] = e / 256 & 255, t[5] = e & 255, t[6] = t[6] & 15 | 112, t[8] = t[8] & 63 | 128;
584
+ const n = Array.from(t, (r) => r.toString(16).padStart(2, "0")).join("");
585
+ return `${n.slice(0, 8)}-${n.slice(8, 12)}-${n.slice(12, 16)}-${n.slice(16, 20)}-${n.slice(20)}`;
586
+ }
587
+ var st = "usereq:visitor";
588
+ function Tt() {
589
+ const e = me("localStorage", st);
590
+ if (e) return e;
591
+ const t = Ne();
592
+ return be("localStorage", st, t), t;
593
+ }
594
+ function yn(e, t) {
595
+ const n = [];
596
+ let r = null;
597
+ const o = Tt(), i = () => {
598
+ for (r !== null && (window.clearTimeout(r), r = null); n.length > 0; ) {
599
+ const u = n.splice(0, vn);
600
+ en(e, { events: u });
601
+ }
602
+ }, a = (u, d = {}) => {
603
+ n.push({
604
+ id: Ne(),
605
+ type: u,
606
+ embedKind: t.kind,
607
+ embedId: t.id,
608
+ widgetId: d.widgetId,
609
+ sessionId: d.sessionId,
610
+ clientKey: o,
611
+ url: window.location.href.slice(0, 2e3),
612
+ occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
613
+ payload: d.payload
614
+ }), n.length >= bn ? i() : r === null && (r = window.setTimeout(i, mn));
615
+ };
616
+ return window.addEventListener("pagehide", i), document.addEventListener("visibilitychange", () => {
617
+ document.visibilityState === "hidden" && i();
618
+ }), {
619
+ report: a,
620
+ flush: i
621
+ };
622
+ }
623
+ var At = (e) => `usereq:once:${e}`;
624
+ function qe(e, t, n) {
625
+ switch (e) {
626
+ case "is":
627
+ return t === n;
628
+ case "starts_with":
629
+ return t.startsWith(n);
630
+ case "contains":
631
+ return t.includes(n);
632
+ case "matches":
633
+ try {
634
+ return new RegExp(n).test(t);
635
+ } catch {
636
+ return !1;
637
+ }
638
+ }
639
+ }
640
+ function xn(e, t) {
641
+ switch (e.kind) {
642
+ case "path":
643
+ return e.value === "*" || qe(e.op, t.path, e.value);
644
+ case "utm":
645
+ var n;
646
+ return qe(e.op, (n = t.utm[e.param]) !== null && n !== void 0 ? n : "", e.value);
647
+ case "device":
648
+ return t.device === e.value;
649
+ case "referrer":
650
+ return qe(e.op, t.referrer, e.value);
651
+ }
652
+ }
653
+ function wn(e, t) {
654
+ for (const n of e)
655
+ if (!(n.once && me("sessionStorage", At(n.id))) && n.conditions.every((r) => xn(r, t)))
656
+ return n;
657
+ return null;
658
+ }
659
+ function Et(e, t, n) {
660
+ let r = !1, o = () => {
661
+ };
662
+ const i = () => {
663
+ r || (r = !0, o(), n());
664
+ };
665
+ switch (e) {
666
+ case "page_load": {
667
+ const d = window.setTimeout(i, 0);
668
+ o = () => window.clearTimeout(d);
669
+ break;
670
+ }
671
+ case "time_on_page": {
672
+ const d = Number(t.seconds) || 0, c = window.setTimeout(i, d * 1e3);
673
+ o = () => window.clearTimeout(c);
674
+ break;
675
+ }
676
+ case "scroll_depth": {
677
+ const d = Number(t.percent) || 0, c = () => {
678
+ const f = document.documentElement.scrollHeight - window.innerHeight;
679
+ (f <= 0 ? 100 : window.scrollY / f * 100) >= d && i();
680
+ };
681
+ window.addEventListener("scroll", c, { passive: !0 }), o = () => window.removeEventListener("scroll", c), c();
682
+ break;
683
+ }
684
+ case "element_click": {
685
+ var a;
686
+ const d = String((a = t.selector) !== null && a !== void 0 ? a : ""), c = (f) => {
687
+ const p = f.target;
688
+ if (!(!(p instanceof Element) || !d))
689
+ try {
690
+ p.closest(d) && i();
691
+ } catch {
692
+ }
693
+ };
694
+ document.addEventListener("click", c, !0), o = () => document.removeEventListener("click", c, !0);
695
+ break;
696
+ }
697
+ case "element_visible": {
698
+ var u;
699
+ const d = String((u = t.selector) !== null && u !== void 0 ? u : "");
700
+ let c = null;
701
+ const f = () => {
702
+ let p = null;
703
+ try {
704
+ p = d ? document.querySelector(d) : null;
705
+ } catch {
706
+ p = null;
707
+ }
708
+ return p ? (c = new IntersectionObserver((l) => {
709
+ l.some((h) => h.isIntersecting) && i();
710
+ }), c.observe(p), !0) : !1;
711
+ };
712
+ !f() && document.readyState === "loading" && document.addEventListener("DOMContentLoaded", () => void f(), { once: !0 }), o = () => c == null ? void 0 : c.disconnect();
713
+ break;
714
+ }
715
+ case "exit_intent": {
716
+ const d = (c) => {
717
+ c.relatedTarget === null && c.clientY <= 0 && i();
718
+ };
719
+ document.addEventListener("mouseout", d), o = () => document.removeEventListener("mouseout", d);
720
+ break;
721
+ }
722
+ }
723
+ return () => {
724
+ r = !0, o();
725
+ };
726
+ }
727
+ function zt(e, t, n) {
728
+ const r = wn(e, t);
729
+ return r ? Et(r.trigger, r.triggerParams, () => {
730
+ r.once && be("sessionStorage", At(r.id), "1"), n(r);
731
+ }) : () => {
732
+ };
733
+ }
734
+ var lt = (e) => `usereq:split:${e}`, Ht = (e) => `usereq:seq:${e}`;
735
+ function kn(e) {
736
+ let t = 2166136261;
737
+ for (let n = 0; n < e.length; n++)
738
+ t ^= e.charCodeAt(n), t = Math.imul(t, 16777619);
739
+ return t >>> 0;
740
+ }
741
+ function ve(e) {
742
+ return [...e].sort((t, n) => t.position - n.position);
743
+ }
744
+ function Sn(e) {
745
+ const t = ve(e.members);
746
+ if (t.length === 0) return null;
747
+ const n = me("localStorage", lt(e.id)), r = n ? t.find((u) => u.widget.id === n) : void 0;
748
+ if (r) return r;
749
+ const o = t.reduce((u, d) => u + d.weight, 0);
750
+ let i = kn(`${Tt()}:${e.config.salt}`) % o, a = t[t.length - 1];
751
+ for (const u of t) {
752
+ if (i < u.weight) {
753
+ a = u;
754
+ break;
755
+ }
756
+ i -= u.weight;
757
+ }
758
+ return be("localStorage", lt(e.id), a.widget.id), a;
759
+ }
760
+ function Rt(e) {
761
+ var t, n;
762
+ const r = ve(e.members);
763
+ if (r.length === 0) return null;
764
+ const o = Number((t = me("sessionStorage", Ht(e.id))) !== null && t !== void 0 ? t : 0);
765
+ return (n = r[Number.isFinite(o) ? Math.min(o, r.length - 1) : 0]) !== null && n !== void 0 ? n : null;
766
+ }
767
+ function $n(e, t, n) {
768
+ if (!t.advanceOn) return () => {
769
+ };
770
+ const r = ve(e.members), o = r.findIndex((i) => i.widget.id === t.widget.id);
771
+ return Et(t.advanceOn.kind, t.advanceOn.params, () => {
772
+ var i;
773
+ const a = o + 1 < r.length ? o + 1 : null;
774
+ if (a === null) {
775
+ n(null);
776
+ return;
777
+ }
778
+ be("sessionStorage", Ht(e.id), String(a)), n((i = r[a]) !== null && i !== void 0 ? i : null);
779
+ });
780
+ }
781
+ function Cn(e) {
782
+ switch (e.mode) {
783
+ case "split": {
784
+ const t = Sn(e);
785
+ return t ? [t.widget] : [];
786
+ }
787
+ case "sequence": {
788
+ const t = Rt(e);
789
+ return t ? [t.widget] : [];
790
+ }
791
+ case "parallel":
792
+ return ve(e.members).map((t) => t.widget);
793
+ }
794
+ }
795
+ function qn(e) {
796
+ var t, n, r, o;
797
+ if (e) return e === "dark";
798
+ const i = (t = ct(getComputedStyle(document.body).backgroundColor)) !== null && t !== void 0 ? t : ct(getComputedStyle(document.documentElement).backgroundColor);
799
+ return i !== null ? i < 0.5 : (n = (r = (o = window).matchMedia) === null || r === void 0 ? void 0 : r.call(o, "(prefers-color-scheme: dark)").matches) !== null && n !== void 0 ? n : !1;
800
+ }
801
+ function ct(e) {
802
+ const t = /rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)(?:[,\s/]+([\d.]+))?/.exec(e);
803
+ if (!t || (t[4] === void 0 ? 1 : Number(t[4])) < 0.5) return null;
804
+ const [n, r, o] = [
805
+ Number(t[1]),
806
+ Number(t[2]),
807
+ Number(t[3])
808
+ ];
809
+ return (0.299 * n + 0.587 * r + 0.114 * o) / 255;
810
+ }
811
+ function In(e = window.innerWidth) {
812
+ return e < 640 ? "mobile" : e < 1024 ? "tablet" : "desktop";
813
+ }
814
+ function Mn() {
815
+ const e = new URL(window.location.href), t = {};
816
+ for (const n of [
817
+ "source",
818
+ "medium",
819
+ "campaign",
820
+ "term",
821
+ "content"
822
+ ]) {
823
+ const r = e.searchParams.get(`utm_${n}`);
824
+ r && (t[n] = r);
825
+ }
826
+ return {
827
+ href: e.href.slice(0, 2e3),
828
+ path: e.pathname,
829
+ referrer: document.referrer.slice(0, 2e3),
830
+ utm: t,
831
+ device: In()
832
+ };
833
+ }
834
+ function Pt(e) {
835
+ const t = e.replace("#", "");
836
+ return {
837
+ r: parseInt(t.slice(0, 2), 16),
838
+ g: parseInt(t.slice(2, 4), 16),
839
+ b: parseInt(t.slice(4, 6), 16)
840
+ };
841
+ }
842
+ function Tn(e) {
843
+ const { r: t, g: n, b: r } = Pt(e);
844
+ return (0.299 * t + 0.587 * n + 0.114 * r) / 255 > 0.62 ? "#15171e" : "#ffffff";
845
+ }
846
+ var ye = (e) => e ? "245,245,241" : "21,23,30";
847
+ function An(e, t) {
848
+ const n = e.appearance, r = n.accent;
849
+ return {
850
+ accent: r,
851
+ accentFill: (() => {
852
+ if (n.alpha >= 100) return r;
853
+ const { r: o, g: i, b: a } = Pt(r);
854
+ return `rgba(${o},${i},${a},${n.alpha / 100})`;
855
+ })(),
856
+ accentText: Tn(r),
857
+ rad: n.radius,
858
+ isGlass: e.type === "chat" && e.variant === "stream" && n.skin === "glass",
859
+ isMessenger: e.type === "chat" && e.variant === "bubble" && e.preset === "facebook-messenger",
860
+ hostDark: t,
861
+ ink: ye(t),
862
+ surfaceBg: t ? "#181b22" : "#ffffff",
863
+ side: n.position === "bottom-right" ? { right: n.offsetX } : { left: n.offsetX },
864
+ offsetY: n.offsetY
865
+ };
866
+ }
867
+ function S(e, t, n) {
868
+ const r = e.appearance.parts[t], o = [`uq-${t}`];
869
+ return n && o.push(n), r && o.push(r.trim()), o.join(" ");
870
+ }
871
+ var En = 0;
872
+ function s(e, t, n, r, o, i) {
873
+ t || (t = {});
874
+ var a, u, d = t;
875
+ if ("ref" in d) for (u in d = {}, t) u == "ref" ? a = t[u] : d[u] = t[u];
876
+ var c = {
877
+ type: e,
878
+ props: d,
879
+ key: n,
880
+ ref: a,
881
+ __k: null,
882
+ __: null,
883
+ __b: 0,
884
+ __e: null,
885
+ __c: null,
886
+ constructor: void 0,
887
+ __v: --En,
888
+ __i: -1,
889
+ __u: 0,
890
+ __source: o,
891
+ __self: i
892
+ };
893
+ if (typeof e == "function" && (a = e.defaultProps)) for (u in a) d[u] === void 0 && (d[u] = a[u]);
894
+ return C.vnode && C.vnode(c), c;
895
+ }
896
+ function j({ size: e, children: t }) {
897
+ return /* @__PURE__ */ s("svg", {
898
+ xmlns: "http://www.w3.org/2000/svg",
899
+ width: e,
900
+ height: e,
901
+ viewBox: "0 0 24 24",
902
+ fill: "none",
903
+ stroke: "currentColor",
904
+ "stroke-width": "2",
905
+ "stroke-linecap": "round",
906
+ "stroke-linejoin": "round",
907
+ "aria-hidden": "true",
908
+ children: t
909
+ });
910
+ }
911
+ var Ft = ({ size: e }) => /* @__PURE__ */ s(j, {
912
+ size: e,
913
+ children: [
914
+ /* @__PURE__ */ s("path", { d: "M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z" }),
915
+ /* @__PURE__ */ s("path", { d: "M20 2v4" }),
916
+ /* @__PURE__ */ s("path", { d: "M22 4h-4" }),
917
+ /* @__PURE__ */ s("circle", {
918
+ cx: "4",
919
+ cy: "20",
920
+ r: "2"
921
+ })
922
+ ]
923
+ }), jt = ({ size: e }) => /* @__PURE__ */ s(j, {
924
+ size: e,
925
+ children: [/* @__PURE__ */ s("path", { d: "M5 12h14" }), /* @__PURE__ */ s("path", { d: "m12 5 7 7-7 7" })]
926
+ }), xe = ({ size: e }) => /* @__PURE__ */ s(j, {
927
+ size: e,
928
+ children: [/* @__PURE__ */ s("path", { d: "M18 6 6 18" }), /* @__PURE__ */ s("path", { d: "m6 6 12 12" })]
929
+ }), zn = ({ size: e }) => /* @__PURE__ */ s(j, {
930
+ size: e,
931
+ children: /* @__PURE__ */ s("path", { d: "M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384" })
932
+ }), Hn = ({ size: e }) => /* @__PURE__ */ s(j, {
933
+ size: e,
934
+ children: [/* @__PURE__ */ s("path", { d: "m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5" }), /* @__PURE__ */ s("rect", {
935
+ x: "2",
936
+ y: "6",
937
+ width: "14",
938
+ height: "12",
939
+ rx: "2"
940
+ })]
941
+ }), Rn = ({ size: e }) => /* @__PURE__ */ s(j, {
942
+ size: e,
943
+ children: [
944
+ /* @__PURE__ */ s("circle", {
945
+ cx: "12",
946
+ cy: "12",
947
+ r: "10"
948
+ }),
949
+ /* @__PURE__ */ s("path", { d: "M12 16v-4" }),
950
+ /* @__PURE__ */ s("path", { d: "M12 8h.01" })
951
+ ]
952
+ }), Bt = ({ size: e }) => /* @__PURE__ */ s(j, {
953
+ size: e,
954
+ children: /* @__PURE__ */ s("path", { d: "m6 9 6 6 6-6" })
955
+ }), Pn = ({ size: e }) => /* @__PURE__ */ s(j, {
956
+ size: e,
957
+ children: /* @__PURE__ */ s("path", { d: "M5 12h14" })
958
+ }), Fn = ({ size: e }) => /* @__PURE__ */ s(j, {
959
+ size: e,
960
+ children: [/* @__PURE__ */ s("path", { d: "M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z" }), /* @__PURE__ */ s("path", { d: "m21.854 2.147-10.94 10.939" })]
961
+ }), jn = ({ size: e }) => /* @__PURE__ */ s(j, {
962
+ size: e,
963
+ children: [
964
+ /* @__PURE__ */ s("path", { d: "M15 3h6v6" }),
965
+ /* @__PURE__ */ s("path", { d: "M10 14 21 3" }),
966
+ /* @__PURE__ */ s("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" })
967
+ ]
968
+ }), Bn = ({ size: e, d: t }) => /* @__PURE__ */ s("svg", {
969
+ xmlns: "http://www.w3.org/2000/svg",
970
+ width: e,
971
+ height: e,
972
+ viewBox: "0 0 24 24",
973
+ fill: "currentColor",
974
+ "aria-hidden": "true",
975
+ children: /* @__PURE__ */ s("path", { d: t })
976
+ });
977
+ function Dn({ payload: e, look: t, reporter: n, open: r, setOpen: o, pinned: i }) {
978
+ var a;
979
+ const u = e.config, { accentFill: d, accentText: c, rad: f } = t;
980
+ if (!r) return null;
981
+ const p = !((a = u.cta) === null || a === void 0) && a.label.trim() ? u.cta : null, l = (p == null ? void 0 : p.href.trim()) || "", h = u.position === "bottom" ? { bottom: 0 } : { top: 0 };
982
+ return /* @__PURE__ */ s("div", {
983
+ class: S(u, "strip", "uq-fixed uq-fade"),
984
+ role: "region",
985
+ "aria-label": "Announcement",
986
+ style: {
987
+ left: 0,
988
+ right: 0,
989
+ ...h,
990
+ display: "flex",
991
+ alignItems: "center",
992
+ justifyContent: "center",
993
+ gap: 14,
994
+ padding: "11px 14px",
995
+ background: d,
996
+ color: c
997
+ },
998
+ children: [
999
+ /* @__PURE__ */ s("span", {
1000
+ class: S(u, "text"),
1001
+ style: {
1002
+ fontSize: 12.5,
1003
+ fontWeight: 500
1004
+ },
1005
+ children: u.text
1006
+ }),
1007
+ p && /* @__PURE__ */ s("a", {
1008
+ class: S(u, "cta"),
1009
+ href: l || "#",
1010
+ target: l ? "_blank" : void 0,
1011
+ rel: l ? "noopener noreferrer" : void 0,
1012
+ onClick: () => n.report("cta.clicked", {
1013
+ widgetId: e.id,
1014
+ payload: { href: l }
1015
+ }),
1016
+ style: {
1017
+ fontSize: 11.5,
1018
+ padding: "5px 10px",
1019
+ borderRadius: f,
1020
+ border: `1px solid ${c}`,
1021
+ whiteSpace: "nowrap"
1022
+ },
1023
+ children: p.label
1024
+ }),
1025
+ !i && /* @__PURE__ */ s("button", {
1026
+ type: "button",
1027
+ class: S(u, "close"),
1028
+ onClick: () => o(!1),
1029
+ "aria-label": "Close",
1030
+ style: {
1031
+ position: "absolute",
1032
+ right: 10,
1033
+ top: "50%",
1034
+ transform: "translateY(-50%)",
1035
+ width: 24,
1036
+ height: 24,
1037
+ display: "flex",
1038
+ alignItems: "center",
1039
+ justifyContent: "center",
1040
+ opacity: 0.7
1041
+ },
1042
+ children: /* @__PURE__ */ s(xe, { size: 14 })
1043
+ })
1044
+ ]
1045
+ });
1046
+ }
1047
+ var Ie = {
1048
+ holdMs: 1260,
1049
+ gapMs: 1520,
1050
+ jitterMs: 100
1051
+ };
1052
+ function Ln(e, t = Math.random) {
1053
+ const n = [];
1054
+ let r = 0;
1055
+ for (let o = 0; o < e; o++) {
1056
+ if (o === 0) r += Ie.holdMs;
1057
+ else {
1058
+ const i = Math.round((t() * 2 - 1) * Ie.jitterMs);
1059
+ r += Math.max(0, Ie.gapMs + i);
1060
+ }
1061
+ n.push(r);
1062
+ }
1063
+ return n;
1064
+ }
1065
+ function Wn(e, t, n, r) {
1066
+ const [o, i] = E([]), [a, u] = E(!1), [d, c] = E(null), [f, p] = E(null), l = F(null), h = F(null), m = F([]), y = F(null), w = () => {
1067
+ for (const v of m.current) window.clearTimeout(v);
1068
+ m.current = [];
1069
+ };
1070
+ P(() => () => w(), []);
1071
+ const _ = X(async () => {
1072
+ if (l.current) return l.current;
1073
+ const v = await Zt(e, {
1074
+ kind: n.kind,
1075
+ id: n.id,
1076
+ widgetId: n.kind === "group" ? t.id : void 0,
1077
+ landingUrl: r.href,
1078
+ referrer: r.referrer || void 0,
1079
+ utm: Object.keys(r.utm).length ? r.utm : void 0
1080
+ });
1081
+ return l.current = {
1082
+ token: v.token,
1083
+ conversationId: v.conversationId
1084
+ }, p(v.conversationId), l.current;
1085
+ }, [
1086
+ e,
1087
+ n.kind,
1088
+ n.id,
1089
+ t.id,
1090
+ r
1091
+ ]), g = X(async (v, k) => {
1092
+ var x;
1093
+ (x = h.current) === null || x === void 0 || x.abort();
1094
+ const q = new AbortController();
1095
+ h.current = q, w(), u(!0), c(null);
1096
+ try {
1097
+ const { token: $ } = await _(), z = await Qt(e, $, v, k, q.signal);
1098
+ if (q.signal.aborted) return;
1099
+ const H = z.parts.filter((A) => A.trim());
1100
+ if (H.length === 0) throw new Error("The agent did not answer. Try again.");
1101
+ i((A) => [...A, {
1102
+ id: z.id,
1103
+ role: "assistant",
1104
+ parts: H,
1105
+ shown: 0
1106
+ }]), m.current = Ln(H.length).map((A, R) => window.setTimeout(() => {
1107
+ i((D) => D.map((N) => N.id === z.id ? {
1108
+ ...N,
1109
+ shown: R + 1
1110
+ } : N)), R === H.length - 1 && u(!1);
1111
+ }, A));
1112
+ } catch ($) {
1113
+ if (q.signal.aborted) return;
1114
+ $ instanceof ce && ($.status === 401 || $.status === 409) && (l.current = null), u(!1), c($ instanceof ce ? $.message : $ instanceof TypeError ? "Could not reach the agent. Try again." : $ instanceof Error && $.message ? $.message : "Something went wrong. Try again.");
1115
+ }
1116
+ }, [e, _]);
1117
+ return {
1118
+ turns: o,
1119
+ busy: a,
1120
+ error: d,
1121
+ sessionId: f,
1122
+ send: X((v) => {
1123
+ const k = v.trim().slice(0, 4e3);
1124
+ if (!k || a) return;
1125
+ const x = {
1126
+ id: Ne(),
1127
+ text: k
1128
+ };
1129
+ y.current = x, i((q) => [...q, {
1130
+ id: x.id,
1131
+ role: "user",
1132
+ parts: [k],
1133
+ shown: 1
1134
+ }]), g(x, "submit-message");
1135
+ }, [a, g]),
1136
+ retry: X(() => {
1137
+ !y.current || a || g(y.current, "regenerate-message");
1138
+ }, [a, g]),
1139
+ stop: X(() => {
1140
+ var v;
1141
+ (v = h.current) === null || v === void 0 || v.abort(), h.current = null, w(), i((k) => k.map((x) => x.role === "assistant" && x.shown < x.parts.length ? {
1142
+ ...x,
1143
+ shown: x.parts.length
1144
+ } : x)), u(!1);
1145
+ }, [])
1146
+ };
1147
+ }
1148
+ function Nn() {
1149
+ const e = "(max-width: 639px)", [t, n] = E(() => {
1150
+ var r, o, i;
1151
+ return (r = (o = (i = window).matchMedia) === null || o === void 0 ? void 0 : o.call(i, e).matches) !== null && r !== void 0 ? r : !1;
1152
+ });
1153
+ return P(() => {
1154
+ var r, o;
1155
+ const i = (r = (o = window).matchMedia) === null || r === void 0 ? void 0 : r.call(o, e);
1156
+ if (!i) return;
1157
+ const a = () => n(i.matches);
1158
+ return i.addEventListener("change", a), () => i.removeEventListener("change", a);
1159
+ }, []), t;
1160
+ }
1161
+ var On = 0.5, ut = 120, Me = () => document.documentElement.clientHeight;
1162
+ function Dt({ look: e, pinned: t, onClose: n, children: r }) {
1163
+ const [o, i] = E("half"), [a, u] = E(null), d = F(null), c = F(null), f = (_) => {
1164
+ const g = d.current;
1165
+ g && (_.currentTarget.setPointerCapture(_.pointerId), c.current = {
1166
+ startY: _.clientY,
1167
+ startHeight: g.getBoundingClientRect().height,
1168
+ lastY: _.clientY,
1169
+ lastAt: _.timeStamp,
1170
+ velocity: 0
1171
+ }, u(c.current.startHeight));
1172
+ }, p = (_) => {
1173
+ const g = c.current;
1174
+ if (!g) return;
1175
+ const v = _.timeStamp - g.lastAt;
1176
+ v > 0 && (g.velocity = (_.clientY - g.lastY) / v), g.lastY = _.clientY, g.lastAt = _.timeStamp;
1177
+ const k = g.startHeight + (g.startY - _.clientY);
1178
+ u(Math.max(ut, Math.min(Me(), k)));
1179
+ }, l = () => {
1180
+ const _ = c.current;
1181
+ if (!_) return;
1182
+ c.current = null;
1183
+ const g = Math.max(ut, Math.min(Me(), _.startHeight + (_.startY - _.lastY))), v = Me();
1184
+ let k;
1185
+ if (_.velocity < -0.5 ? k = "full" : _.velocity > On ? k = o === "full" ? "half" : "closed" : g > v * 0.75 ? k = "full" : g < v * 0.3 ? k = "closed" : k = "half", u(null), k === "closed") {
1186
+ t ? i("half") : n();
1187
+ return;
1188
+ }
1189
+ i(k);
1190
+ }, { ink: h, surfaceBg: m, rad: y } = e, w = o === "full" && a === null;
1191
+ return /* @__PURE__ */ s("div", {
1192
+ ref: d,
1193
+ class: [
1194
+ "uq-fixed uq-drawer uq-slide",
1195
+ w ? "uq-drawer-full" : "uq-drawer-half",
1196
+ a !== null && "uq-drawer-held"
1197
+ ].filter(Boolean).join(" "),
1198
+ role: "dialog",
1199
+ "aria-modal": "false",
1200
+ style: {
1201
+ height: a !== null ? a : void 0,
1202
+ borderRadius: w ? 0 : `${y}px ${y}px 0 0`,
1203
+ borderTop: `1px solid rgba(${h},.12)`,
1204
+ background: m,
1205
+ boxShadow: "0 -12px 40px rgba(0,0,0,.18)"
1206
+ },
1207
+ children: [/* @__PURE__ */ s("div", {
1208
+ class: "uq-grab",
1209
+ onPointerDown: f,
1210
+ onPointerMove: p,
1211
+ onPointerUp: l,
1212
+ onPointerCancel: l,
1213
+ "aria-label": w ? "Drag down to shrink or close" : "Drag up to expand",
1214
+ style: { background: m },
1215
+ children: /* @__PURE__ */ s("span", { style: { background: `rgba(${h},.25)` } })
1216
+ }), r]
1217
+ });
1218
+ }
1219
+ var b = {
1220
+ accent: "#7B5BFF",
1221
+ gradient: "linear-gradient(135deg,#00B2FF 0%,#006AFF 38%,#8E5BFF 100%)",
1222
+ blue: "#0084FF",
1223
+ surface: {
1224
+ light: "#ffffff",
1225
+ dark: "#242526"
1226
+ },
1227
+ bubble: {
1228
+ light: "#f5f5f5",
1229
+ dark: "#404040"
1230
+ },
1231
+ muted: {
1232
+ light: "#8e8e8e",
1233
+ dark: "#a8a8a8"
1234
+ },
1235
+ border: {
1236
+ light: "rgba(0,0,0,.1)",
1237
+ dark: "rgba(255,255,255,.12)"
1238
+ },
1239
+ panelWidth: 372,
1240
+ panelHeight: 520,
1241
+ panelRadius: 24,
1242
+ panelGap: 14,
1243
+ panelShadow: "0 8px 32px rgba(0,0,0,.16)",
1244
+ launcherSize: 60,
1245
+ launcherShadow: "0 6px 20px rgba(123,91,255,.4)",
1246
+ badgeSize: 20,
1247
+ logo: "M12 2C6.48 2 2 6.18 2 11.32c0 2.93 1.45 5.55 3.7 7.27v3.4l3.39-1.86a10.5 10.5 0 0 0 2.91.41c5.52 0 10-4.18 10-9.22S17.52 2 12 2Zm1.06 12.42-2.55-2.72-4.97 2.72 5.46-5.8 2.61 2.72 4.91-2.72-5.46 5.8Z",
1248
+ headerAvatar: 40,
1249
+ headerButton: 28,
1250
+ headerIcon: 18,
1251
+ nameFont: 15,
1252
+ avatarSize: 28,
1253
+ bubbleRadius: 18,
1254
+ bubbleFont: 14,
1255
+ bubblePadding: "6px 12px",
1256
+ bubbleMaxWidth: "78%",
1257
+ ctaShadow: "0 4px 12px rgba(123,91,255,.32)",
1258
+ composerPlaceholder: "Aa",
1259
+ composerRadius: 24,
1260
+ composerHeight: 36,
1261
+ sendSize: 36,
1262
+ sendIcon: 20
1263
+ }, Yn = 3600, Oe = (e) => e.welcome || "Hi! Ask me anything before you buy.";
1264
+ function Lt(e, t = "Type your message…") {
1265
+ const n = e.spotlights.filter((a) => a.trim()), [r, o] = E(0);
1266
+ P(() => {
1267
+ if (n.length < 2) return;
1268
+ const a = window.setInterval(() => o((u) => u + 1), Yn);
1269
+ return () => window.clearInterval(a);
1270
+ }, [n.length]);
1271
+ const i = e.placeholder || t;
1272
+ return n.length ? n[r % n.length] : i;
1273
+ }
1274
+ function we(e) {
1275
+ const t = F(null);
1276
+ return P(() => {
1277
+ const n = t.current;
1278
+ n && (n.scrollTop = n.scrollHeight);
1279
+ }, e), t;
1280
+ }
1281
+ function Wt(e) {
1282
+ const t = e ? "dark" : "light";
1283
+ return {
1284
+ surface: b.surface[t],
1285
+ bubble: b.bubble[t],
1286
+ muted: b.muted[t],
1287
+ border: b.border[t]
1288
+ };
1289
+ }
1290
+ var Y = (e, t = {}) => ({
1291
+ width: e,
1292
+ height: e,
1293
+ borderRadius: "50%",
1294
+ display: "flex",
1295
+ alignItems: "center",
1296
+ justifyContent: "center",
1297
+ flexShrink: 0,
1298
+ ...t
1299
+ });
1300
+ function Ye({ payload: e, size: t, font: n, palette: r, fallback: o }) {
1301
+ var i, a, u, d;
1302
+ const c = (i = (a = e.agent) === null || a === void 0 ? void 0 : a.name) !== null && i !== void 0 ? i : null, f = (u = (d = e.agent) === null || d === void 0 ? void 0 : d.avatarUrl) !== null && u !== void 0 ? u : null;
1303
+ return f ? /* @__PURE__ */ s("img", {
1304
+ src: f,
1305
+ alt: "",
1306
+ width: t,
1307
+ height: t,
1308
+ style: Y(t, { objectFit: "cover" })
1309
+ }) : /* @__PURE__ */ s("span", {
1310
+ style: Y(t, {
1311
+ background: r.bubble,
1312
+ color: r.muted,
1313
+ fontSize: n,
1314
+ fontWeight: 600,
1315
+ ...o
1316
+ }),
1317
+ children: c ? c.trim().charAt(0).toUpperCase() : "A"
1318
+ });
1319
+ }
1320
+ function dt({ text: e, mine: t, runStart: n, look: r, config: o, payload: i, palette: a, children: u }) {
1321
+ return /* @__PURE__ */ s("div", {
1322
+ class: "uq-rise",
1323
+ style: {
1324
+ display: "flex",
1325
+ alignItems: "flex-end",
1326
+ gap: 6,
1327
+ justifyContent: t ? "flex-end" : "flex-start",
1328
+ marginTop: n ? 6 : 2
1329
+ },
1330
+ children: [!t && (n ? /* @__PURE__ */ s(Ye, {
1331
+ payload: i,
1332
+ size: b.avatarSize,
1333
+ font: 12,
1334
+ palette: a
1335
+ }) : /* @__PURE__ */ s("span", { style: {
1336
+ width: b.avatarSize,
1337
+ flexShrink: 0
1338
+ } })), /* @__PURE__ */ s("div", {
1339
+ class: S(o, t ? "userMessage" : "botMessage"),
1340
+ style: {
1341
+ maxWidth: b.bubbleMaxWidth,
1342
+ padding: u ? "8px 12px" : b.bubblePadding,
1343
+ borderRadius: b.bubbleRadius,
1344
+ background: t ? b.gradient : a.bubble,
1345
+ color: t ? "#fff" : `rgb(${r.ink})`,
1346
+ fontSize: b.bubbleFont,
1347
+ lineHeight: 1.375,
1348
+ whiteSpace: "pre-wrap",
1349
+ overflowWrap: "anywhere"
1350
+ },
1351
+ children: u != null ? u : e
1352
+ })]
1353
+ });
1354
+ }
1355
+ function ft({ payload: e, config: t, look: n, chat: r, focus: o, onCta: i, mobile: a, fill: u = !1, onMinimize: d, onClose: c }) {
1356
+ var f, p, l, h;
1357
+ const m = Wt(n.hostDark), { surface: y, bubble: w, muted: _, border: g } = m, v = Lt(t, b.composerPlaceholder), k = (f = (p = e.agent) === null || p === void 0 ? void 0 : p.name) !== null && f !== void 0 ? f : null, x = !!(!((l = e.agent) === null || l === void 0) && l.live), q = we([
1358
+ r.turns,
1359
+ r.busy,
1360
+ r.error
1361
+ ]), [$, z] = E(""), H = F(null);
1362
+ P(() => {
1363
+ var I;
1364
+ o > 0 && ((I = H.current) === null || I === void 0 || I.focus());
1365
+ }, [o]);
1366
+ const A = (I) => {
1367
+ I.preventDefault(), x && (r.send($), z(""));
1368
+ }, R = !((h = t.cta) === null || h === void 0 || (h = h.href) === null || h === void 0) && h.trim() ? t.cta : null, D = [{
1369
+ key: "welcome",
1370
+ text: Oe(t),
1371
+ mine: !1
1372
+ }];
1373
+ for (const I of r.turns) if (I.role === "user") {
1374
+ var N;
1375
+ D.push({
1376
+ key: I.id,
1377
+ text: (N = I.parts[0]) !== null && N !== void 0 ? N : "",
1378
+ mine: !0
1379
+ });
1380
+ } else I.parts.slice(0, I.shown).forEach((G, ke) => {
1381
+ D.push({
1382
+ key: `${I.id}:${ke}`,
1383
+ text: G,
1384
+ mine: !1
1385
+ });
1386
+ });
1387
+ const Gt = D[D.length - 1], V = (I, G, ke, Se, Ge) => /* @__PURE__ */ s("button", {
1388
+ type: "button",
1389
+ class: Ge ? S(t, Ge) : void 0,
1390
+ onClick: Se,
1391
+ disabled: !Se,
1392
+ "aria-label": G,
1393
+ style: Y(a ? 36 : b.headerButton, {
1394
+ color: ke,
1395
+ opacity: Se ? 1 : 0.6
1396
+ }),
1397
+ children: I
1398
+ }), K = b.headerIcon;
1399
+ return /* @__PURE__ */ s("div", {
1400
+ class: S(t, "panel"),
1401
+ style: {
1402
+ display: "flex",
1403
+ flexDirection: "column",
1404
+ borderRadius: u ? 0 : b.panelRadius,
1405
+ overflow: "hidden",
1406
+ border: u ? void 0 : `1px solid ${g}`,
1407
+ boxShadow: u ? void 0 : b.panelShadow,
1408
+ background: y,
1409
+ color: `rgb(${n.ink})`,
1410
+ ...u ? {
1411
+ flex: 1,
1412
+ minHeight: 0
1413
+ } : {
1414
+ height: b.panelHeight,
1415
+ maxHeight: `calc(100vh - ${n.offsetY + b.launcherSize + b.panelGap + 12}px)`
1416
+ }
1417
+ },
1418
+ children: [
1419
+ /* @__PURE__ */ s("div", {
1420
+ class: S(t, "header"),
1421
+ style: {
1422
+ display: "flex",
1423
+ alignItems: "center",
1424
+ gap: 8,
1425
+ padding: "10px 12px",
1426
+ borderBottom: `1px solid ${g}`
1427
+ },
1428
+ children: [
1429
+ /* @__PURE__ */ s(Ye, {
1430
+ payload: e,
1431
+ size: b.headerAvatar,
1432
+ font: 14,
1433
+ palette: m
1434
+ }),
1435
+ /* @__PURE__ */ s("span", {
1436
+ style: {
1437
+ flex: 1,
1438
+ minWidth: 0,
1439
+ display: "flex",
1440
+ alignItems: "center",
1441
+ gap: 2
1442
+ },
1443
+ children: [/* @__PURE__ */ s("span", {
1444
+ style: {
1445
+ fontSize: b.nameFont,
1446
+ fontWeight: 600,
1447
+ overflow: "hidden",
1448
+ textOverflow: "ellipsis",
1449
+ whiteSpace: "nowrap"
1450
+ },
1451
+ children: k ? k.split("—")[0].trim() : "Chat"
1452
+ }), /* @__PURE__ */ s("span", {
1453
+ style: {
1454
+ color: _,
1455
+ opacity: 0.7,
1456
+ display: "flex"
1457
+ },
1458
+ children: /* @__PURE__ */ s(Bt, { size: 16 })
1459
+ })]
1460
+ }),
1461
+ V(/* @__PURE__ */ s(zn, { size: K }), "Call (unavailable)", b.blue),
1462
+ V(/* @__PURE__ */ s(Hn, { size: K }), "Video call (unavailable)", b.blue),
1463
+ V(/* @__PURE__ */ s(Rn, { size: K }), "Details (unavailable)", _),
1464
+ d && V(/* @__PURE__ */ s(Pn, { size: K }), "Minimize chat", _, d),
1465
+ c && V(/* @__PURE__ */ s(xe, { size: K }), "Close chat", _, c, "close")
1466
+ ]
1467
+ }),
1468
+ /* @__PURE__ */ s("div", {
1469
+ ref: q,
1470
+ style: {
1471
+ flex: 1,
1472
+ minHeight: 0,
1473
+ padding: "6px 12px 12px",
1474
+ display: "flex",
1475
+ flexDirection: "column",
1476
+ overflowY: "auto",
1477
+ overscrollBehavior: "contain"
1478
+ },
1479
+ children: [
1480
+ D.map((I, G) => /* @__PURE__ */ s(dt, {
1481
+ text: I.text,
1482
+ mine: I.mine,
1483
+ runStart: G === 0 || D[G - 1].mine !== I.mine,
1484
+ look: n,
1485
+ config: t,
1486
+ payload: e,
1487
+ palette: m
1488
+ }, I.key)),
1489
+ r.busy && /* @__PURE__ */ s(dt, {
1490
+ mine: !1,
1491
+ runStart: Gt.mine,
1492
+ look: n,
1493
+ config: t,
1494
+ payload: e,
1495
+ palette: m,
1496
+ children: /* @__PURE__ */ s("span", {
1497
+ class: "uq-dots",
1498
+ "aria-label": "Typing",
1499
+ style: { gap: 4 },
1500
+ children: [
1501
+ /* @__PURE__ */ s("span", { style: {
1502
+ width: 6,
1503
+ height: 6
1504
+ } }),
1505
+ /* @__PURE__ */ s("span", { style: {
1506
+ width: 6,
1507
+ height: 6
1508
+ } }),
1509
+ /* @__PURE__ */ s("span", { style: {
1510
+ width: 6,
1511
+ height: 6
1512
+ } })
1513
+ ]
1514
+ })
1515
+ }),
1516
+ r.error && /* @__PURE__ */ s("div", {
1517
+ class: "uq-error uq-fade",
1518
+ style: {
1519
+ display: "flex",
1520
+ gap: 8,
1521
+ marginTop: 6,
1522
+ paddingLeft: b.avatarSize + 6,
1523
+ fontSize: 12,
1524
+ color: _
1525
+ },
1526
+ children: [/* @__PURE__ */ s("span", { children: r.error }), /* @__PURE__ */ s("button", {
1527
+ type: "button",
1528
+ onClick: r.retry,
1529
+ style: {
1530
+ color: b.blue,
1531
+ fontWeight: 500,
1532
+ textDecoration: "underline"
1533
+ },
1534
+ children: "Retry"
1535
+ })]
1536
+ })
1537
+ ]
1538
+ }),
1539
+ R && /* @__PURE__ */ s("div", {
1540
+ style: {
1541
+ display: "flex",
1542
+ justifyContent: "flex-end",
1543
+ padding: "8px 12px"
1544
+ },
1545
+ children: /* @__PURE__ */ s("a", {
1546
+ class: "uq-cta",
1547
+ href: R.href,
1548
+ target: "_blank",
1549
+ rel: "noopener noreferrer",
1550
+ onClick: i,
1551
+ style: {
1552
+ display: "inline-flex",
1553
+ alignItems: "center",
1554
+ gap: 6,
1555
+ padding: "8px 16px",
1556
+ borderRadius: 999,
1557
+ background: b.gradient,
1558
+ color: "#fff",
1559
+ fontSize: 14,
1560
+ fontWeight: 600,
1561
+ boxShadow: b.ctaShadow
1562
+ },
1563
+ children: [R.label || "Learn more", /* @__PURE__ */ s(jn, { size: 16 })]
1564
+ })
1565
+ }),
1566
+ /* @__PURE__ */ s("form", {
1567
+ class: S(t, "composer"),
1568
+ onSubmit: A,
1569
+ style: {
1570
+ display: "flex",
1571
+ alignItems: "center",
1572
+ gap: 4,
1573
+ padding: 8,
1574
+ borderTop: `1px solid ${g}`
1575
+ },
1576
+ children: [/* @__PURE__ */ s("input", {
1577
+ ref: H,
1578
+ type: "text",
1579
+ value: $,
1580
+ onInput: (I) => z(I.target.value),
1581
+ placeholder: v,
1582
+ disabled: !x,
1583
+ maxLength: 4e3,
1584
+ "aria-label": "Message",
1585
+ autoComplete: "off",
1586
+ style: {
1587
+ flex: 1,
1588
+ minHeight: b.composerHeight,
1589
+ padding: "0 12px",
1590
+ borderRadius: b.composerRadius,
1591
+ background: w,
1592
+ color: `rgb(${n.ink})`,
1593
+ fontSize: a ? 16 : 14,
1594
+ "--uq-placeholder": _
1595
+ }
1596
+ }), r.busy ? /* @__PURE__ */ s("button", {
1597
+ type: "button",
1598
+ class: S(t, "sendButton"),
1599
+ onClick: r.stop,
1600
+ "aria-label": "Stop",
1601
+ style: Y(b.sendSize, { color: b.blue }),
1602
+ children: /* @__PURE__ */ s("span", { style: {
1603
+ width: 10,
1604
+ height: 10,
1605
+ background: "currentColor",
1606
+ borderRadius: 2
1607
+ } })
1608
+ }) : /* @__PURE__ */ s("button", {
1609
+ type: "submit",
1610
+ class: S(t, "sendButton"),
1611
+ disabled: !x || !$.trim(),
1612
+ "aria-label": "Send",
1613
+ style: Y(b.sendSize, {
1614
+ color: b.blue,
1615
+ opacity: x && $.trim() ? 1 : 0.5
1616
+ }),
1617
+ children: /* @__PURE__ */ s(Fn, { size: b.sendIcon })
1618
+ })]
1619
+ })
1620
+ ]
1621
+ });
1622
+ }
1623
+ function Un({ payload: e, config: t, look: n, chat: r, mobile: o, focus: i, open: a, setOpen: u, pinned: d, onCta: c }) {
1624
+ const f = Wt(n.hostDark), { side: p, offsetY: l } = n, h = d ? void 0 : () => u(!1);
1625
+ if (a && o) {
1626
+ const m = {
1627
+ ...n,
1628
+ surfaceBg: f.surface,
1629
+ rad: b.panelRadius
1630
+ };
1631
+ return /* @__PURE__ */ s(Dt, {
1632
+ look: m,
1633
+ pinned: d,
1634
+ onClose: () => u(!1),
1635
+ children: /* @__PURE__ */ s(ft, {
1636
+ payload: e,
1637
+ config: t,
1638
+ look: n,
1639
+ chat: r,
1640
+ focus: i,
1641
+ onCta: c,
1642
+ mobile: !0,
1643
+ fill: !0,
1644
+ onClose: h
1645
+ })
1646
+ });
1647
+ }
1648
+ return /* @__PURE__ */ s(W, { children: [a && /* @__PURE__ */ s("div", {
1649
+ class: "uq-fixed uq-rise",
1650
+ style: {
1651
+ bottom: l + b.launcherSize + b.panelGap,
1652
+ width: b.panelWidth,
1653
+ ...p
1654
+ },
1655
+ children: /* @__PURE__ */ s(ft, {
1656
+ payload: e,
1657
+ config: t,
1658
+ look: n,
1659
+ chat: r,
1660
+ focus: i,
1661
+ onCta: c,
1662
+ mobile: !1,
1663
+ onMinimize: h,
1664
+ onClose: h
1665
+ })
1666
+ }), /* @__PURE__ */ s("button", {
1667
+ type: "button",
1668
+ class: S(t, "launcher", "uq-fixed"),
1669
+ "aria-label": a ? "Close chat" : "Open chat",
1670
+ "aria-expanded": a,
1671
+ onClick: () => {
1672
+ a && d || u(!a);
1673
+ },
1674
+ style: {
1675
+ bottom: l,
1676
+ ...Y(b.launcherSize, { boxShadow: b.launcherShadow }),
1677
+ ...p
1678
+ },
1679
+ children: [/* @__PURE__ */ s(Ye, {
1680
+ payload: e,
1681
+ size: b.launcherSize,
1682
+ font: 16,
1683
+ palette: f,
1684
+ fallback: {
1685
+ background: b.gradient,
1686
+ color: "#fff"
1687
+ }
1688
+ }), a ? /* @__PURE__ */ s("span", {
1689
+ style: {
1690
+ position: "absolute",
1691
+ inset: 0,
1692
+ borderRadius: "50%",
1693
+ background: "rgba(0,0,0,.45)",
1694
+ display: "flex",
1695
+ alignItems: "center",
1696
+ justifyContent: "center",
1697
+ color: "#fff"
1698
+ },
1699
+ children: /* @__PURE__ */ s(Bt, { size: 28 })
1700
+ }) : /* @__PURE__ */ s("span", {
1701
+ style: {
1702
+ position: "absolute",
1703
+ right: -4,
1704
+ bottom: -4,
1705
+ ...Y(b.badgeSize, {
1706
+ background: b.accent,
1707
+ color: "#fff",
1708
+ boxShadow: `0 0 0 2px ${f.surface}`
1709
+ })
1710
+ },
1711
+ children: /* @__PURE__ */ s(Bn, {
1712
+ size: 12,
1713
+ d: b.logo
1714
+ })
1715
+ })]
1716
+ })] });
1717
+ }
1718
+ function le({ text: e, mine: t, onDark: n, look: r, config: o, children: i }) {
1719
+ const a = ye(n), { isGlass: u, accentFill: d, accentText: c, rad: f } = r;
1720
+ return /* @__PURE__ */ s("div", {
1721
+ class: S(o, t ? "userMessage" : "botMessage", "uq-rise"),
1722
+ style: {
1723
+ alignSelf: t ? "flex-end" : "flex-start",
1724
+ maxWidth: t ? "78%" : "84%",
1725
+ padding: "8px 10px",
1726
+ borderRadius: f,
1727
+ background: t ? d : u ? "rgba(10,12,18,.42)" : `rgba(${a},${n ? 0.1 : 0.06})`,
1728
+ color: t ? c : u ? "#fff" : `rgb(${a})`,
1729
+ backdropFilter: !t && u ? "blur(6px)" : void 0,
1730
+ fontSize: 12,
1731
+ lineHeight: 1.45,
1732
+ textShadow: !t && u ? "0 1px 2px rgba(0,0,0,.5)" : void 0,
1733
+ whiteSpace: "pre-wrap",
1734
+ overflowWrap: "anywhere"
1735
+ },
1736
+ children: i != null ? i : e
1737
+ });
1738
+ }
1739
+ var Gn = (e) => /* @__PURE__ */ s(le, {
1740
+ mine: !1,
1741
+ ...e,
1742
+ children: /* @__PURE__ */ s("span", {
1743
+ class: "uq-dots",
1744
+ "aria-label": "Typing",
1745
+ children: [
1746
+ /* @__PURE__ */ s("span", {}),
1747
+ /* @__PURE__ */ s("span", {}),
1748
+ /* @__PURE__ */ s("span", {})
1749
+ ]
1750
+ })
1751
+ });
1752
+ function Nt({ config: e, look: t, onClick: n }) {
1753
+ var r;
1754
+ const o = !((r = e.cta) === null || r === void 0 || (r = r.href) === null || r === void 0) && r.trim() ? e.cta : null;
1755
+ return o ? /* @__PURE__ */ s("a", {
1756
+ class: "uq-cta",
1757
+ href: o.href,
1758
+ target: "_blank",
1759
+ rel: "noopener noreferrer",
1760
+ onClick: n,
1761
+ style: {
1762
+ display: "flex",
1763
+ alignItems: "center",
1764
+ justifyContent: "center",
1765
+ padding: "9px 12px",
1766
+ borderRadius: t.rad,
1767
+ background: t.accentFill,
1768
+ color: t.accentText,
1769
+ fontSize: 12,
1770
+ fontWeight: 500
1771
+ },
1772
+ children: o.label || "Learn more"
1773
+ }) : null;
1774
+ }
1775
+ function Ot({ config: e, look: t, onDark: n, hint: r, chat: o, disabled: i, focus: a }) {
1776
+ const u = ye(n), { isGlass: d, accentFill: c, accentText: f, rad: p } = t, [l, h] = E(""), m = F(null);
1777
+ P(() => {
1778
+ var _;
1779
+ a > 0 && ((_ = m.current) === null || _ === void 0 || _.focus());
1780
+ }, [a]);
1781
+ const y = (_) => {
1782
+ _.preventDefault(), !i && (o.send(l), h(""));
1783
+ }, w = d ? "rgba(255,255,255,.75)" : `rgba(${u},${n ? 0.6 : 0.45})`;
1784
+ return /* @__PURE__ */ s("form", {
1785
+ class: S(e, "composer"),
1786
+ onSubmit: y,
1787
+ style: {
1788
+ display: "flex",
1789
+ alignItems: "center",
1790
+ gap: 8,
1791
+ padding: "7px 8px 7px 11px",
1792
+ borderRadius: p,
1793
+ border: d ? "1px solid rgba(255,255,255,.35)" : `1px solid rgba(${u},${n ? 0.28 : 0.12})`,
1794
+ background: d ? "rgba(10,12,18,.3)" : `rgba(${u},${n ? 0.08 : 0.02})`,
1795
+ backdropFilter: d || n ? "blur(6px)" : void 0
1796
+ },
1797
+ children: [/* @__PURE__ */ s("input", {
1798
+ ref: m,
1799
+ type: "text",
1800
+ value: l,
1801
+ onInput: (_) => h(_.target.value),
1802
+ placeholder: r || "Message…",
1803
+ disabled: i,
1804
+ maxLength: 4e3,
1805
+ "aria-label": "Message",
1806
+ autoComplete: "off",
1807
+ style: {
1808
+ flex: 1,
1809
+ fontSize: 11.5,
1810
+ color: d ? "#fff" : `rgb(${u})`,
1811
+ "--uq-placeholder": w
1812
+ }
1813
+ }), o.busy ? /* @__PURE__ */ s("button", {
1814
+ type: "button",
1815
+ class: S(e, "sendButton"),
1816
+ onClick: o.stop,
1817
+ "aria-label": "Stop",
1818
+ style: {
1819
+ width: 24,
1820
+ height: 24,
1821
+ borderRadius: p,
1822
+ background: c,
1823
+ color: f,
1824
+ display: "flex",
1825
+ alignItems: "center",
1826
+ justifyContent: "center",
1827
+ flexShrink: 0
1828
+ },
1829
+ children: /* @__PURE__ */ s("span", { style: {
1830
+ width: 8,
1831
+ height: 8,
1832
+ background: "currentColor",
1833
+ borderRadius: 1
1834
+ } })
1835
+ }) : /* @__PURE__ */ s("button", {
1836
+ type: "submit",
1837
+ class: S(e, "sendButton"),
1838
+ disabled: i,
1839
+ "aria-label": "Send",
1840
+ style: {
1841
+ width: 24,
1842
+ height: 24,
1843
+ borderRadius: p,
1844
+ background: c,
1845
+ color: f,
1846
+ display: "flex",
1847
+ alignItems: "center",
1848
+ justifyContent: "center",
1849
+ flexShrink: 0,
1850
+ opacity: i ? 0.5 : 1
1851
+ },
1852
+ children: /* @__PURE__ */ s(jt, { size: 13 })
1853
+ })]
1854
+ });
1855
+ }
1856
+ function Ue({ welcome: e, chat: t, onDark: n, look: r, config: o }) {
1857
+ const i = ye(n);
1858
+ return /* @__PURE__ */ s(W, { children: [
1859
+ /* @__PURE__ */ s(le, {
1860
+ text: e,
1861
+ mine: !1,
1862
+ onDark: n,
1863
+ look: r,
1864
+ config: o
1865
+ }),
1866
+ t.turns.map((a) => a.role === "user" ? /* @__PURE__ */ s(le, {
1867
+ text: a.parts[0],
1868
+ mine: !0,
1869
+ onDark: n,
1870
+ look: r,
1871
+ config: o
1872
+ }, a.id) : a.parts.slice(0, a.shown).map((u, d) => /* @__PURE__ */ s(le, {
1873
+ text: u,
1874
+ mine: !1,
1875
+ onDark: n,
1876
+ look: r,
1877
+ config: o
1878
+ }, `${a.id}:${d}`))),
1879
+ t.busy && /* @__PURE__ */ s(Gn, {
1880
+ onDark: n,
1881
+ look: r,
1882
+ config: o
1883
+ }),
1884
+ t.error && /* @__PURE__ */ s("div", {
1885
+ class: "uq-error uq-fade",
1886
+ style: {
1887
+ alignSelf: "flex-start",
1888
+ display: "flex",
1889
+ gap: 8,
1890
+ fontSize: 11.5,
1891
+ color: r.isGlass ? "rgba(255,255,255,.8)" : `rgba(${i},.6)`,
1892
+ textShadow: r.isGlass ? "0 1px 2px rgba(0,0,0,.5)" : void 0
1893
+ },
1894
+ children: [/* @__PURE__ */ s("span", { children: t.error }), /* @__PURE__ */ s("button", {
1895
+ type: "button",
1896
+ onClick: t.retry,
1897
+ style: {
1898
+ color: r.isGlass ? "#fff" : r.accent,
1899
+ fontWeight: 500,
1900
+ textDecoration: "underline"
1901
+ },
1902
+ children: "Retry"
1903
+ })]
1904
+ })
1905
+ ] });
1906
+ }
1907
+ function Te({ payload: e, config: t, look: n, chat: r, shadow: o, hint: i, focus: a, onCta: u, fill: d = !1, onClose: c }) {
1908
+ var f, p, l;
1909
+ const { ink: h, surfaceBg: m, hostDark: y, accentFill: w, accentText: _, rad: g } = n, v = (f = (p = e.agent) === null || p === void 0 ? void 0 : p.name) !== null && f !== void 0 ? f : null, k = v ? v.trim().charAt(0).toUpperCase() : "A", x = Oe(t), q = we([
1910
+ r.turns,
1911
+ r.busy,
1912
+ r.error
1913
+ ]), $ = !!(!((l = e.agent) === null || l === void 0) && l.live);
1914
+ return /* @__PURE__ */ s("div", {
1915
+ class: S(t, "panel"),
1916
+ style: {
1917
+ width: "100%",
1918
+ borderRadius: d ? 0 : g,
1919
+ overflow: "hidden",
1920
+ border: d ? void 0 : `1px solid rgba(${h},.12)`,
1921
+ boxShadow: o ? "0 18px 44px rgba(0,0,0,.16)" : void 0,
1922
+ background: m,
1923
+ ...d ? {
1924
+ flex: 1,
1925
+ minHeight: 0,
1926
+ display: "flex",
1927
+ flexDirection: "column"
1928
+ } : {}
1929
+ },
1930
+ children: [
1931
+ /* @__PURE__ */ s("div", {
1932
+ class: S(t, "header"),
1933
+ style: {
1934
+ display: "flex",
1935
+ alignItems: "center",
1936
+ gap: 8,
1937
+ padding: "10px 12px",
1938
+ background: w,
1939
+ color: _
1940
+ },
1941
+ children: [
1942
+ /* @__PURE__ */ s("span", {
1943
+ style: {
1944
+ width: 20,
1945
+ height: 20,
1946
+ borderRadius: "50%",
1947
+ background: "rgba(255,255,255,.25)",
1948
+ display: "flex",
1949
+ alignItems: "center",
1950
+ justifyContent: "center",
1951
+ fontSize: 10,
1952
+ fontWeight: 600,
1953
+ color: _
1954
+ },
1955
+ children: k
1956
+ }),
1957
+ /* @__PURE__ */ s("span", {
1958
+ style: {
1959
+ fontSize: 12,
1960
+ fontWeight: 500
1961
+ },
1962
+ children: v ? v.split("—")[0].trim() : "Chat"
1963
+ }),
1964
+ /* @__PURE__ */ s("span", {
1965
+ style: {
1966
+ marginLeft: "auto",
1967
+ fontSize: 10,
1968
+ opacity: 0.8
1969
+ },
1970
+ children: $ ? "online" : "offline"
1971
+ }),
1972
+ c && /* @__PURE__ */ s("button", {
1973
+ type: "button",
1974
+ class: S(t, "close"),
1975
+ onClick: c,
1976
+ "aria-label": "Close chat",
1977
+ style: {
1978
+ width: 28,
1979
+ height: 28,
1980
+ marginRight: -6,
1981
+ borderRadius: "50%",
1982
+ display: "flex",
1983
+ alignItems: "center",
1984
+ justifyContent: "center",
1985
+ color: _,
1986
+ flexShrink: 0
1987
+ },
1988
+ children: /* @__PURE__ */ s(xe, { size: 16 })
1989
+ })
1990
+ ]
1991
+ }),
1992
+ /* @__PURE__ */ s("div", {
1993
+ ref: q,
1994
+ style: {
1995
+ display: "flex",
1996
+ flexDirection: "column",
1997
+ gap: 7,
1998
+ padding: 12,
1999
+ background: m,
2000
+ maxHeight: d ? void 0 : "min(58vh, 380px)",
2001
+ flex: d ? 1 : void 0,
2002
+ minHeight: d ? 0 : void 0,
2003
+ overflowY: "auto",
2004
+ overscrollBehavior: "contain"
2005
+ },
2006
+ children: /* @__PURE__ */ s(Ue, {
2007
+ welcome: x,
2008
+ chat: r,
2009
+ onDark: y,
2010
+ look: n,
2011
+ config: t
2012
+ })
2013
+ }),
2014
+ /* @__PURE__ */ s("div", {
2015
+ style: {
2016
+ display: "flex",
2017
+ flexDirection: "column",
2018
+ gap: 8,
2019
+ padding: "0 12px 12px",
2020
+ background: m
2021
+ },
2022
+ children: [/* @__PURE__ */ s(Nt, {
2023
+ config: t,
2024
+ look: n,
2025
+ onClick: u
2026
+ }), /* @__PURE__ */ s(Ot, {
2027
+ config: t,
2028
+ look: n,
2029
+ onDark: y,
2030
+ hint: i,
2031
+ chat: r,
2032
+ disabled: !$,
2033
+ focus: a
2034
+ })]
2035
+ })
2036
+ ]
2037
+ });
2038
+ }
2039
+ function Vn({ payload: e, look: t, api: n, embed: r, page: o, reporter: i, open: a, setOpen: u, pinned: d, focus: c }) {
2040
+ var f;
2041
+ const p = e.config, l = Wn(n, e, r, o), h = Lt(p), { accentFill: m, accentText: y, rad: w, side: _, offsetY: g } = t, v = Nn(), k = !!(!((f = e.agent) === null || f === void 0) && f.live), x = Oe(p), q = () => {
2042
+ var z, H;
2043
+ return i.report("cta.clicked", {
2044
+ widgetId: e.id,
2045
+ sessionId: (z = l.sessionId) !== null && z !== void 0 ? z : void 0,
2046
+ payload: { href: (H = p.cta) === null || H === void 0 ? void 0 : H.href }
2047
+ });
2048
+ };
2049
+ if (t.isMessenger) return /* @__PURE__ */ s(Un, {
2050
+ payload: e,
2051
+ config: p,
2052
+ look: t,
2053
+ chat: l,
2054
+ mobile: v,
2055
+ focus: c,
2056
+ open: a,
2057
+ setOpen: u,
2058
+ pinned: d,
2059
+ onCta: q
2060
+ });
2061
+ if (p.variant === "bubble")
2062
+ return a && v ? /* @__PURE__ */ s(Dt, {
2063
+ look: t,
2064
+ pinned: d,
2065
+ onClose: () => u(!1),
2066
+ children: /* @__PURE__ */ s(Te, {
2067
+ payload: e,
2068
+ config: p,
2069
+ look: t,
2070
+ chat: l,
2071
+ shadow: !1,
2072
+ hint: h,
2073
+ focus: c,
2074
+ onCta: q,
2075
+ fill: !0,
2076
+ onClose: d ? void 0 : () => u(!1)
2077
+ })
2078
+ }) : /* @__PURE__ */ s(W, { children: [a && /* @__PURE__ */ s("div", {
2079
+ class: "uq-fixed uq-rise",
2080
+ style: {
2081
+ bottom: g + 54,
2082
+ width: 296,
2083
+ ..._
2084
+ },
2085
+ children: /* @__PURE__ */ s(Te, {
2086
+ payload: e,
2087
+ config: p,
2088
+ look: t,
2089
+ chat: l,
2090
+ shadow: !0,
2091
+ hint: h,
2092
+ focus: c,
2093
+ onCta: q
2094
+ })
2095
+ }), /* @__PURE__ */ s("button", {
2096
+ type: "button",
2097
+ class: S(p, "launcher", "uq-fixed"),
2098
+ "aria-label": a ? "Close chat" : "Open chat",
2099
+ "aria-expanded": a,
2100
+ onClick: () => {
2101
+ a && d || u(!a);
2102
+ },
2103
+ style: {
2104
+ bottom: g,
2105
+ width: 44,
2106
+ height: 44,
2107
+ borderRadius: Math.min(22, w * 2),
2108
+ background: m,
2109
+ color: y,
2110
+ display: "flex",
2111
+ alignItems: "center",
2112
+ justifyContent: "center",
2113
+ boxShadow: "0 10px 26px rgba(0,0,0,.24)",
2114
+ ..._
2115
+ },
2116
+ children: /* @__PURE__ */ s(Ft, { size: 20 })
2117
+ })] });
2118
+ if (p.variant === "box") return /* @__PURE__ */ s("div", {
2119
+ class: "uq-inline",
2120
+ children: /* @__PURE__ */ s(Te, {
2121
+ payload: e,
2122
+ config: p,
2123
+ look: t,
2124
+ chat: l,
2125
+ shadow: !1,
2126
+ hint: h,
2127
+ focus: c,
2128
+ onCta: q
2129
+ })
2130
+ });
2131
+ const $ = {
2132
+ payload: e,
2133
+ config: p,
2134
+ look: t,
2135
+ chat: l,
2136
+ hint: h,
2137
+ mobile: v,
2138
+ focus: c,
2139
+ live: k,
2140
+ welcome: x,
2141
+ onCta: q
2142
+ };
2143
+ return p.variant === "chatbar" ? /* @__PURE__ */ s(Kn, { ...$ }) : /* @__PURE__ */ s(Xn, { ...$ });
2144
+ }
2145
+ function Kn({ config: e, look: t, chat: n, hint: r, mobile: o, focus: i, live: a, welcome: u }) {
2146
+ const { ink: d, hostDark: c, accentFill: f, accentText: p, rad: l } = t, h = we([
2147
+ n.turns,
2148
+ n.busy,
2149
+ n.error
2150
+ ]), m = n.turns.length > 0;
2151
+ return /* @__PURE__ */ s("div", {
2152
+ class: S(e, "panel", "uq-fixed"),
2153
+ style: {
2154
+ left: 0,
2155
+ right: 0,
2156
+ bottom: 0,
2157
+ padding: "10px 12px",
2158
+ background: c ? "rgba(24,27,34,.97)" : "rgba(255,255,255,.97)",
2159
+ borderTop: `1px solid rgba(${d},.12)`,
2160
+ display: "flex",
2161
+ flexDirection: "column",
2162
+ gap: 10,
2163
+ boxShadow: "0 -10px 30px rgba(0,0,0,.12)"
2164
+ },
2165
+ children: [m && /* @__PURE__ */ s("div", {
2166
+ ref: h,
2167
+ style: {
2168
+ display: "flex",
2169
+ flexDirection: "column",
2170
+ gap: 7,
2171
+ maxHeight: "min(50vh, 320px)",
2172
+ overflowY: "auto"
2173
+ },
2174
+ children: /* @__PURE__ */ s(Ue, {
2175
+ welcome: u,
2176
+ chat: n,
2177
+ onDark: c,
2178
+ look: t,
2179
+ config: e
2180
+ })
2181
+ }), /* @__PURE__ */ s("div", {
2182
+ style: {
2183
+ display: "flex",
2184
+ alignItems: "center",
2185
+ gap: 10
2186
+ },
2187
+ children: [
2188
+ /* @__PURE__ */ s("span", {
2189
+ class: S(e, "launcher"),
2190
+ style: {
2191
+ width: 26,
2192
+ height: 26,
2193
+ borderRadius: l,
2194
+ background: f,
2195
+ color: p,
2196
+ display: "flex",
2197
+ alignItems: "center",
2198
+ justifyContent: "center",
2199
+ flexShrink: 0
2200
+ },
2201
+ children: /* @__PURE__ */ s(Ft, { size: 14 })
2202
+ }),
2203
+ /* @__PURE__ */ s("span", {
2204
+ class: S(e, "botMessage"),
2205
+ style: {
2206
+ flex: 1,
2207
+ minWidth: 0,
2208
+ fontSize: 12,
2209
+ color: `rgb(${d})`,
2210
+ overflow: "hidden",
2211
+ whiteSpace: "nowrap",
2212
+ textOverflow: "ellipsis"
2213
+ },
2214
+ children: u
2215
+ }),
2216
+ /* @__PURE__ */ s("form", {
2217
+ class: S(e, "composer"),
2218
+ onSubmit: (y) => {
2219
+ y.preventDefault();
2220
+ const w = y.currentTarget.elements.namedItem("message");
2221
+ !w || !a || (n.send(w.value), w.value = "");
2222
+ },
2223
+ style: {
2224
+ display: "flex",
2225
+ alignItems: "center",
2226
+ gap: 8,
2227
+ flexShrink: 0,
2228
+ padding: "6px 8px 6px 11px",
2229
+ borderRadius: l,
2230
+ border: `1px solid rgba(${d},.14)`,
2231
+ minWidth: o ? 0 : 220
2232
+ },
2233
+ children: [/* @__PURE__ */ s("input", {
2234
+ name: "message",
2235
+ type: "text",
2236
+ placeholder: r,
2237
+ disabled: !a,
2238
+ maxLength: 4e3,
2239
+ "aria-label": "Message",
2240
+ autoComplete: "off",
2241
+ ref: (y) => {
2242
+ y && i > 0 && y.focus();
2243
+ },
2244
+ style: {
2245
+ flex: 1,
2246
+ fontSize: 11.5,
2247
+ color: `rgb(${d})`,
2248
+ "--uq-placeholder": `rgba(${d},.45)`
2249
+ }
2250
+ }), /* @__PURE__ */ s("button", {
2251
+ type: n.busy ? "button" : "submit",
2252
+ class: S(e, "sendButton"),
2253
+ onClick: n.busy ? n.stop : void 0,
2254
+ disabled: !a,
2255
+ "aria-label": n.busy ? "Stop" : "Send",
2256
+ style: {
2257
+ width: 22,
2258
+ height: 22,
2259
+ borderRadius: l,
2260
+ background: f,
2261
+ color: p,
2262
+ display: "flex",
2263
+ alignItems: "center",
2264
+ justifyContent: "center",
2265
+ flexShrink: 0
2266
+ },
2267
+ children: n.busy ? /* @__PURE__ */ s("span", { style: {
2268
+ width: 7,
2269
+ height: 7,
2270
+ background: "currentColor",
2271
+ borderRadius: 1
2272
+ } }) : /* @__PURE__ */ s(jt, { size: 12 })
2273
+ })]
2274
+ })
2275
+ ]
2276
+ })]
2277
+ });
2278
+ }
2279
+ function Xn({ config: e, look: t, chat: n, hint: r, mobile: o, focus: i, live: a, welcome: u, onCta: d }) {
2280
+ const { hostDark: c, side: f, offsetY: p } = t, l = c, h = we([
2281
+ n.turns,
2282
+ n.busy,
2283
+ n.error
2284
+ ]);
2285
+ return /* @__PURE__ */ s("div", {
2286
+ class: S(e, "panel", "uq-fixed"),
2287
+ style: {
2288
+ bottom: p,
2289
+ width: o ? `calc(100% - ${e.appearance.offsetX * 2}px)` : 320,
2290
+ display: "flex",
2291
+ flexDirection: "column",
2292
+ gap: 7,
2293
+ ...f
2294
+ },
2295
+ children: [
2296
+ /* @__PURE__ */ s("div", {
2297
+ ref: h,
2298
+ style: {
2299
+ display: "flex",
2300
+ flexDirection: "column",
2301
+ gap: 7,
2302
+ maxHeight: "min(60vh, 420px)",
2303
+ overflowY: "auto"
2304
+ },
2305
+ children: /* @__PURE__ */ s(Ue, {
2306
+ welcome: u,
2307
+ chat: n,
2308
+ onDark: l,
2309
+ look: t,
2310
+ config: e
2311
+ })
2312
+ }),
2313
+ /* @__PURE__ */ s(Nt, {
2314
+ config: e,
2315
+ look: t,
2316
+ onClick: d
2317
+ }),
2318
+ /* @__PURE__ */ s(Ot, {
2319
+ config: e,
2320
+ look: t,
2321
+ onDark: l,
2322
+ hint: r,
2323
+ chat: n,
2324
+ disabled: !a,
2325
+ focus: i
2326
+ })
2327
+ ]
2328
+ });
2329
+ }
2330
+ var Jn = (e) => /^https?:\/\//i.test(e);
2331
+ function Zn({ config: e, block: t, index: n, look: r, onCta: o }) {
2332
+ const { ink: i, accent: a, accentFill: u, accentText: d, rad: c } = r, f = [
2333
+ "uq-block",
2334
+ `uq-block-${t.kind}`,
2335
+ t.cssClass.trim()
2336
+ ].filter(Boolean).join(" "), p = "align" in t ? t.align : "center", l = {
2337
+ class: f,
2338
+ "data-uq-block": n
2339
+ };
2340
+ switch (t.kind) {
2341
+ case "headline":
2342
+ return /* @__PURE__ */ s("div", {
2343
+ ...l,
2344
+ style: {
2345
+ fontFamily: "var(--font-display, inherit)",
2346
+ fontSize: t.size === "lg" ? 21 : t.size === "sm" ? 15 : 18,
2347
+ fontWeight: 600,
2348
+ letterSpacing: "-0.02em",
2349
+ textAlign: p,
2350
+ color: t.color || `rgb(${i})`
2351
+ },
2352
+ children: t.text
2353
+ });
2354
+ case "text":
2355
+ return /* @__PURE__ */ s("div", {
2356
+ ...l,
2357
+ style: {
2358
+ fontSize: 12.5,
2359
+ lineHeight: 1.5,
2360
+ textAlign: p,
2361
+ color: t.color || `rgba(${i},.65)`,
2362
+ whiteSpace: "pre-wrap"
2363
+ },
2364
+ children: t.text
2365
+ });
2366
+ case "media":
2367
+ return !t.src || !Jn(t.src) ? null : t.mediaType === "video" ? /* @__PURE__ */ s("video", {
2368
+ ...l,
2369
+ src: t.src,
2370
+ muted: !0,
2371
+ loop: !0,
2372
+ autoPlay: !0,
2373
+ playsInline: !0,
2374
+ style: {
2375
+ width: "100%",
2376
+ maxHeight: 200,
2377
+ objectFit: "cover",
2378
+ borderRadius: c,
2379
+ background: "#000"
2380
+ }
2381
+ }) : /* @__PURE__ */ s("img", {
2382
+ ...l,
2383
+ src: t.src,
2384
+ alt: t.alt || "",
2385
+ style: {
2386
+ width: "100%",
2387
+ maxHeight: 200,
2388
+ objectFit: "cover",
2389
+ borderRadius: c
2390
+ }
2391
+ });
2392
+ case "quote":
2393
+ return /* @__PURE__ */ s("div", {
2394
+ ...l,
2395
+ style: { textAlign: "center" },
2396
+ children: [/* @__PURE__ */ s("div", {
2397
+ style: {
2398
+ fontSize: 13,
2399
+ fontStyle: "italic",
2400
+ color: `rgb(${i})`
2401
+ },
2402
+ children: [
2403
+ "“",
2404
+ t.text,
2405
+ "”"
2406
+ ]
2407
+ }), /* @__PURE__ */ s("div", {
2408
+ style: {
2409
+ fontSize: 11,
2410
+ color: `rgba(${i},.55)`,
2411
+ marginTop: 4
2412
+ },
2413
+ children: t.author
2414
+ })]
2415
+ });
2416
+ case "cta":
2417
+ return /* @__PURE__ */ s("a", {
2418
+ ...l,
2419
+ class: `${S(e, "cta")} ${f}`,
2420
+ href: t.href || "#",
2421
+ target: t.newTab ? "_blank" : void 0,
2422
+ rel: t.newTab ? "noopener noreferrer" : void 0,
2423
+ onClick: () => o(t.href),
2424
+ style: {
2425
+ display: "block",
2426
+ marginTop: 4,
2427
+ padding: "10px 14px",
2428
+ borderRadius: c,
2429
+ background: t.style === "outline" ? "transparent" : u,
2430
+ border: t.style === "outline" ? `1px solid ${a}` : void 0,
2431
+ color: t.style === "outline" ? a : d,
2432
+ fontSize: 13,
2433
+ fontWeight: 500,
2434
+ textAlign: "center"
2435
+ },
2436
+ children: t.label
2437
+ });
2438
+ }
2439
+ }
2440
+ function Qn({ payload: e, look: t, reporter: n, open: r, setOpen: o, pinned: i }) {
2441
+ const a = e.config, { ink: u, surfaceBg: d, rad: c } = t;
2442
+ if (!r) return null;
2443
+ const f = () => {
2444
+ i || o(!1);
2445
+ }, p = (l) => n.report("cta.clicked", {
2446
+ widgetId: e.id,
2447
+ payload: { href: l }
2448
+ });
2449
+ return /* @__PURE__ */ s("div", {
2450
+ class: S(a, "scrim", "uq-fixed uq-fade"),
2451
+ onClick: f,
2452
+ style: {
2453
+ inset: 0,
2454
+ background: "rgba(8,10,16,.5)",
2455
+ display: "flex",
2456
+ alignItems: "center",
2457
+ justifyContent: "center",
2458
+ padding: 24
2459
+ },
2460
+ children: /* @__PURE__ */ s("div", {
2461
+ class: S(a, "card", "uq-rise"),
2462
+ role: "dialog",
2463
+ "aria-modal": "true",
2464
+ onClick: (l) => l.stopPropagation(),
2465
+ style: {
2466
+ position: "relative",
2467
+ width: "100%",
2468
+ maxWidth: 340,
2469
+ maxHeight: "calc(100vh - 48px)",
2470
+ overflowY: "auto",
2471
+ background: d,
2472
+ borderRadius: c,
2473
+ padding: "22px 20px",
2474
+ boxShadow: "0 24px 60px rgba(0,0,0,.3)",
2475
+ display: "flex",
2476
+ flexDirection: "column",
2477
+ gap: 10,
2478
+ textAlign: "center",
2479
+ color: `rgb(${u})`
2480
+ },
2481
+ children: [!i && /* @__PURE__ */ s("button", {
2482
+ type: "button",
2483
+ class: S(a, "close"),
2484
+ onClick: f,
2485
+ "aria-label": "Close",
2486
+ style: {
2487
+ position: "absolute",
2488
+ top: 8,
2489
+ right: 8,
2490
+ width: 24,
2491
+ height: 24,
2492
+ borderRadius: "50%",
2493
+ display: "flex",
2494
+ alignItems: "center",
2495
+ justifyContent: "center",
2496
+ color: `rgba(${u},.55)`
2497
+ },
2498
+ children: /* @__PURE__ */ s(xe, { size: 14 })
2499
+ }), a.blocks.map((l, h) => /* @__PURE__ */ s(Zn, {
2500
+ config: a,
2501
+ block: l,
2502
+ index: h,
2503
+ look: t,
2504
+ onCta: p
2505
+ }, h))]
2506
+ })
2507
+ });
2508
+ }
2509
+ var er = 3600;
2510
+ function tr({ payload: e, look: t, open: n }) {
2511
+ const r = e.config, { ink: o, accent: i, surfaceBg: a, rad: u } = t, d = r.quotes, [c, f] = E(0);
2512
+ if (P(() => {
2513
+ if (d.length < 2) return;
2514
+ const h = window.setInterval(() => f((m) => m + 1), er);
2515
+ return () => window.clearInterval(h);
2516
+ }, [d.length]), !n || d.length === 0) return null;
2517
+ const p = c % d.length, l = d[p];
2518
+ return /* @__PURE__ */ s("div", {
2519
+ class: "uq-fixed uq-fade",
2520
+ style: {
2521
+ left: 0,
2522
+ right: 0,
2523
+ bottom: 0,
2524
+ display: "flex",
2525
+ justifyContent: "center",
2526
+ padding: 24,
2527
+ pointerEvents: "none"
2528
+ },
2529
+ children: /* @__PURE__ */ s("figure", {
2530
+ class: S(r, "frame"),
2531
+ style: {
2532
+ width: "100%",
2533
+ maxWidth: 440,
2534
+ background: a,
2535
+ border: `1px solid rgba(${o},.12)`,
2536
+ borderLeft: `3px solid ${i}`,
2537
+ borderRadius: u,
2538
+ padding: "16px 18px",
2539
+ display: "flex",
2540
+ flexDirection: "column",
2541
+ gap: 9,
2542
+ boxShadow: "0 14px 34px rgba(0,0,0,.12)",
2543
+ pointerEvents: "auto"
2544
+ },
2545
+ children: [/* @__PURE__ */ s("blockquote", {
2546
+ class: S(r, "quote", "uq-fade"),
2547
+ style: {
2548
+ fontSize: 13.5,
2549
+ lineHeight: 1.55,
2550
+ color: `rgb(${o})`
2551
+ },
2552
+ children: [
2553
+ "“",
2554
+ l.text || "…",
2555
+ "”"
2556
+ ]
2557
+ }, p), /* @__PURE__ */ s("figcaption", {
2558
+ style: {
2559
+ display: "flex",
2560
+ alignItems: "center",
2561
+ gap: 10
2562
+ },
2563
+ children: [/* @__PURE__ */ s("span", {
2564
+ class: S(r, "author"),
2565
+ style: {
2566
+ fontFamily: "monospace",
2567
+ fontSize: 11,
2568
+ color: `rgba(${o},.55)`
2569
+ },
2570
+ children: l.author || "—"
2571
+ }), /* @__PURE__ */ s("span", {
2572
+ class: S(r, "dots"),
2573
+ style: {
2574
+ marginLeft: "auto",
2575
+ display: "flex",
2576
+ gap: 4
2577
+ },
2578
+ children: d.map((h, m) => /* @__PURE__ */ s("span", { style: {
2579
+ width: 5,
2580
+ height: 5,
2581
+ borderRadius: "50%",
2582
+ background: m === p ? i : `rgba(${o},.18)`
2583
+ } }, m))
2584
+ })]
2585
+ })]
2586
+ })
2587
+ });
2588
+ }
2589
+ function nr(e) {
2590
+ switch (e.config.type) {
2591
+ case "chat":
2592
+ case "exit-popup":
2593
+ return !1;
2594
+ case "banner":
2595
+ case "testimonial":
2596
+ return !0;
2597
+ }
2598
+ }
2599
+ function rr(e) {
2600
+ return e.rules.length > 0 || e.config.type !== "exit-popup" ? e.rules : [{
2601
+ id: `default:${e.id}`,
2602
+ trigger: "exit_intent",
2603
+ triggerParams: {},
2604
+ conditions: [],
2605
+ once: !0,
2606
+ actionConfig: {
2607
+ open: !1,
2608
+ autoStart: !1,
2609
+ pinned: !1
2610
+ }
2611
+ }];
2612
+ }
2613
+ function Yt({ payload: e, api: t, embed: n, page: r, reporter: o, hostDark: i, kick: a = null }) {
2614
+ const u = he(() => An(e.config, i), [e, i]), d = he(() => rr(e), [e]), [c, f] = E(d.length === 0), [p, l] = E(() => d.length === 0 && nr(e)), [h, m] = E(!1), [y, w] = E(0), _ = F(p), g = (x) => {
2615
+ l(x), x !== _.current && (_.current = x, o.report(x ? "surface.opened" : "surface.closed", { widgetId: e.id }));
2616
+ }, v = ({ autoStart: x, pinned: q }) => {
2617
+ f(!0), m(q), g(!0), x && w(($) => $ + 1);
2618
+ };
2619
+ if (P(() => zt(d, r, (x) => {
2620
+ o.report("rule.fired", {
2621
+ widgetId: e.id,
2622
+ payload: {
2623
+ ruleId: x.id,
2624
+ trigger: x.trigger
2625
+ }
2626
+ }), v(x.actionConfig);
2627
+ }), [e.id]), P(() => {
2628
+ a && v(a.action);
2629
+ }, [a]), !c) return null;
2630
+ const k = {
2631
+ payload: e,
2632
+ look: u,
2633
+ api: t,
2634
+ embed: n,
2635
+ page: r,
2636
+ reporter: o,
2637
+ open: p,
2638
+ setOpen: g,
2639
+ pinned: h,
2640
+ focus: y
2641
+ };
2642
+ switch (e.config.type) {
2643
+ case "chat":
2644
+ return /* @__PURE__ */ s(Vn, { ...k });
2645
+ case "exit-popup":
2646
+ return /* @__PURE__ */ s(Qn, { ...k });
2647
+ case "banner":
2648
+ return /* @__PURE__ */ s(Dn, { ...k });
2649
+ case "testimonial":
2650
+ return /* @__PURE__ */ s(tr, { ...k });
2651
+ }
2652
+ }
2653
+ function ir(e) {
2654
+ const t = [], n = e.config.appearance.customCss.trim();
2655
+ return n && t.push(n), e.config.type === "exit-popup" && e.config.blocks.forEach((r, o) => {
2656
+ const i = r.css.trim();
2657
+ i && t.push(`[data-uq-widget="${e.id}"] [data-uq-block="${o}"]{${i}}`);
2658
+ }), t.join(`
2659
+ `);
2660
+ }
2661
+ function or(e) {
2662
+ return e.kind === "widget" ? [e.payload] : e.payload.members.map((t) => t.widget);
2663
+ }
2664
+ var ar = {
2665
+ report: () => {
2666
+ },
2667
+ flush: () => {
2668
+ }
2669
+ };
2670
+ function sr({ group: e, ...t }) {
2671
+ const [n, r] = E(e.rules.length === 0), [o, i] = E(null), [a, u] = E(() => Cn(e));
2672
+ return P(() => zt(e.rules, t.page, (d) => {
2673
+ t.reporter.report("rule.fired", { payload: {
2674
+ ruleId: d.id,
2675
+ trigger: d.trigger
2676
+ } }), r(!0), i((c) => {
2677
+ var f;
2678
+ return {
2679
+ action: d.actionConfig,
2680
+ n: ((f = c == null ? void 0 : c.n) !== null && f !== void 0 ? f : 0) + 1
2681
+ };
2682
+ });
2683
+ }), [e.id]), P(() => {
2684
+ if (e.mode !== "sequence" || !n) return;
2685
+ const d = Rt(e);
2686
+ if (d)
2687
+ return $n(e, d, (c) => u(c ? [c.widget] : []));
2688
+ }, [
2689
+ e.id,
2690
+ e.mode,
2691
+ n,
2692
+ a
2693
+ ]), n ? /* @__PURE__ */ s(W, { children: a.map((d) => /* @__PURE__ */ s("div", {
2694
+ "data-uq-widget": d.id,
2695
+ style: "display:contents",
2696
+ children: /* @__PURE__ */ s(Yt, {
2697
+ payload: d,
2698
+ kick: o,
2699
+ ...t
2700
+ })
2701
+ }, d.id)) }) : null;
2702
+ }
2703
+ function lr({ snapshot: e, ...t }) {
2704
+ const n = {
2705
+ kind: e.kind,
2706
+ id: e.payload.id
2707
+ };
2708
+ return e.kind === "group" ? /* @__PURE__ */ s(sr, {
2709
+ group: e.payload,
2710
+ embed: n,
2711
+ ...t
2712
+ }) : /* @__PURE__ */ s("div", {
2713
+ "data-uq-widget": e.payload.id,
2714
+ style: "display:contents",
2715
+ children: /* @__PURE__ */ s(Yt, {
2716
+ payload: e.payload,
2717
+ embed: n,
2718
+ ...t
2719
+ })
2720
+ });
2721
+ }
2722
+ function cr(e, t, n = {}) {
2723
+ var r, o, i;
2724
+ const a = (r = t.shadowRoot) !== null && r !== void 0 ? r : t.attachShadow({ mode: "open" }), u = { base: ((o = n.apiUrl) !== null && o !== void 0 ? o : "https://api.usereq.com").replace(/\/+$/, "") }, d = {
2725
+ kind: e.kind,
2726
+ id: e.payload.id
2727
+ }, c = n.silent ? ar : yn(u, d), f = qn((i = n.theme) !== null && i !== void 0 ? i : null), p = Mn(), l = document.createElement("style");
2728
+ a.appendChild(l);
2729
+ const h = document.createElement("div");
2730
+ h.setAttribute("data-uq-root", ""), h.style.display = "contents", a.appendChild(h);
2731
+ const m = (y) => {
2732
+ l.textContent = [gn, ...or(y).map(ir)].join(`
2733
+ `), Ze(/* @__PURE__ */ s(lr, {
2734
+ snapshot: y,
2735
+ api: u,
2736
+ page: p,
2737
+ reporter: c,
2738
+ hostDark: f
2739
+ }), h);
2740
+ };
2741
+ return m(e), c.report("embed.loaded", { payload: { version: e.payload.version } }), {
2742
+ update: m,
2743
+ unmount: () => {
2744
+ Ze(null, h), c.flush(), l.remove(), h.remove();
2745
+ }
2746
+ };
2747
+ }
2748
+ function Ut(e, t) {
2749
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
2750
+ }
2751
+ function ur(e, t) {
2752
+ Ut(e, t), t.add(e);
2753
+ }
2754
+ function ht(e, t, n) {
2755
+ Ut(e, t), t.set(e, n);
2756
+ }
2757
+ function pe(e, t, n) {
2758
+ if (typeof e == "function" ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
2759
+ throw new TypeError("Private element is not present on this object");
2760
+ }
2761
+ function ne(e, t) {
2762
+ return e.get(pe(e, t));
2763
+ }
2764
+ function re(e, t, n) {
2765
+ return e.set(pe(e, t), n), n;
2766
+ }
2767
+ var dr = {
2768
+ widget: {
2769
+ element: "usereq-widget",
2770
+ attribute: "widget-id"
2771
+ },
2772
+ group: {
2773
+ element: "usereq-group",
2774
+ attribute: "group-id"
2775
+ }
2776
+ };
2777
+ function Ae(e) {
2778
+ console.warn(`[usereq] ${e}`);
2779
+ }
2780
+ function pt(e) {
2781
+ const { element: t, attribute: n } = dr[e];
2782
+ if (customElements.get(t)) return;
2783
+ var r = /* @__PURE__ */ new WeakMap(), o = /* @__PURE__ */ new WeakMap(), i = /* @__PURE__ */ new WeakSet();
2784
+ class a extends HTMLElement {
2785
+ constructor(...c) {
2786
+ super(...c), ur(this, i), ht(this, r, null), ht(this, o, 0);
2787
+ }
2788
+ connectedCallback() {
2789
+ pe(i, this, u).call(this);
2790
+ }
2791
+ disconnectedCallback() {
2792
+ var c;
2793
+ (c = ne(r, this)) === null || c === void 0 || c.unmount(), re(r, this, null);
2794
+ }
2795
+ attributeChangedCallback(c, f, p) {
2796
+ f !== p && this.isConnected && pe(i, this, u).call(this);
2797
+ }
2798
+ }
2799
+ async function u() {
2800
+ var d, c, f, p;
2801
+ const l = (d = this.getAttribute(n)) === null || d === void 0 ? void 0 : d.trim();
2802
+ if (!l) return;
2803
+ const h = re(o, this, (c = ne(o, this), ++c));
2804
+ (f = ne(r, this)) === null || f === void 0 || f.unmount(), re(r, this, null);
2805
+ const m = ((p = this.getAttribute("api-url")) !== null && p !== void 0 ? p : "https://api.usereq.com").replace(/\/+$/, ""), y = this.getAttribute("theme"), w = y === "light" || y === "dark" ? y : null;
2806
+ let _;
2807
+ try {
2808
+ const g = await Jt({ base: m }, e, l);
2809
+ _ = nn(g, e);
2810
+ } catch (g) {
2811
+ g instanceof ce ? Ae(`${t} ${l}: ${g.message} (${g.code})`) : Ae(`${t} ${l}: could not reach ${m}.`);
2812
+ return;
2813
+ }
2814
+ if (!(h !== ne(o, this) || !this.isConnected)) {
2815
+ if (!_) {
2816
+ Ae(`${t} ${l}: the response was not a ${e} snapshot.`);
2817
+ return;
2818
+ }
2819
+ re(r, this, cr(_, this, {
2820
+ apiUrl: m,
2821
+ theme: w
2822
+ }));
2823
+ }
2824
+ }
2825
+ Ee(a, "observedAttributes", [
2826
+ n,
2827
+ "api-url",
2828
+ "theme"
2829
+ ]), customElements.define(t, a);
2830
+ }
2831
+ function fr() {
2832
+ pt("widget"), pt("group");
2833
+ }
2834
+ fr();
2835
+ export {
2836
+ cr as render
2837
+ };
2838
+
2839
+ //# sourceMappingURL=embed.mjs.map