@ownhelp/widget 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/lib/index.js +214 -206
- package/dist/widget.js +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ Visitors see the assistant's reply, never retrieved chunks or scores.
|
|
|
20
20
|
The script can come from your gateway (`/widget.js`) or a CDN. Pin an exact version on a CDN:
|
|
21
21
|
|
|
22
22
|
```html
|
|
23
|
-
<script src="https://cdn.jsdelivr.net/npm/@ownhelp/widget@0.1.
|
|
23
|
+
<script src="https://cdn.jsdelivr.net/npm/@ownhelp/widget@0.1.1/dist/widget.js"
|
|
24
24
|
data-tenant-id="your_tenant"
|
|
25
25
|
data-api-url="https://support.example.com"
|
|
26
26
|
defer></script>
|
|
@@ -38,7 +38,7 @@ uses the origin the script was loaded from.
|
|
|
38
38
|
| `data-position` | no | `right` | `left` or `right`. |
|
|
39
39
|
| `data-accent-color` | no | `#1f6feb` | Any CSS colour. |
|
|
40
40
|
|
|
41
|
-
The widget renders inside a shadow root, so your page's CSS cannot affect it.
|
|
41
|
+
The widget renders inside a shadow root, so your page's CSS cannot affect it. The React component below is isolated the same way. Theme it with `accentColor` or the `--cw-*` custom properties, which inherit through the shadow boundary; page selectors cannot restyle it.
|
|
42
42
|
|
|
43
43
|
## Install: React component
|
|
44
44
|
|
package/dist/lib/index.js
CHANGED
|
@@ -1,55 +1,56 @@
|
|
|
1
|
-
import { jsxs as p, jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { jsxs as p, jsx as a, Fragment as xe } from "react/jsx-runtime";
|
|
2
|
+
import { useState as w, useRef as $, useCallback as J, useLayoutEffect as ve, useEffect as Z } from "react";
|
|
3
|
+
import { createPortal as ke } from "react-dom";
|
|
4
|
+
function ue(t) {
|
|
5
|
+
if (typeof t != "string" || t.length > 50) return;
|
|
6
|
+
const e = t.trim(), r = /^(\+?[0-9 ().-]+?)(?:\s*[xX#]\s*(\d+))?$/.exec(e);
|
|
6
7
|
if (!r || !/\d/.test(r[1])) return;
|
|
7
8
|
const n = r[1].replace(/[^+0-9]/g, "");
|
|
8
|
-
return { display:
|
|
9
|
+
return { display: e, uri: `tel:${n}${r[2] ? `;ext=${r[2]}` : ""}` };
|
|
9
10
|
}
|
|
10
|
-
function ee(
|
|
11
|
-
if (!
|
|
12
|
-
const
|
|
13
|
-
typeof
|
|
14
|
-
const r = ue(
|
|
15
|
-
return r && (
|
|
11
|
+
function ee(t) {
|
|
12
|
+
if (!t || t.available !== !0 || typeof t.token != "string" || !t.token.trim()) return;
|
|
13
|
+
const e = { available: !0, token: t.token };
|
|
14
|
+
typeof t.contact_email == "string" && /^[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/.test(t.contact_email) && (e.contactEmail = t.contact_email);
|
|
15
|
+
const r = ue(t.contact_phone);
|
|
16
|
+
return r && (e.contactPhone = r.display), e;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
const
|
|
18
|
+
function Ce(t) {
|
|
19
|
+
const e = ee({
|
|
19
20
|
available: !0,
|
|
20
|
-
token:
|
|
21
|
-
contact_email:
|
|
22
|
-
contact_phone:
|
|
21
|
+
token: t?.token,
|
|
22
|
+
contact_email: t?.contactEmail,
|
|
23
|
+
contact_phone: t?.contactPhone
|
|
23
24
|
});
|
|
24
25
|
return {
|
|
25
|
-
email:
|
|
26
|
-
phone: ue(
|
|
26
|
+
email: e?.contactEmail ? `mailto:${encodeURIComponent(e.contactEmail)}` : void 0,
|
|
27
|
+
phone: ue(e?.contactPhone)?.uri
|
|
27
28
|
};
|
|
28
29
|
}
|
|
29
|
-
function
|
|
30
|
-
let
|
|
31
|
-
const
|
|
30
|
+
function _e() {
|
|
31
|
+
let t = 0;
|
|
32
|
+
const e = /* @__PURE__ */ new Set();
|
|
32
33
|
return {
|
|
33
34
|
begin() {
|
|
34
|
-
const r =
|
|
35
|
-
return
|
|
35
|
+
const r = t, n = new AbortController();
|
|
36
|
+
return e.add(n), {
|
|
36
37
|
signal: n.signal,
|
|
37
38
|
abort: () => n.abort(),
|
|
38
|
-
isCurrent: () => r ===
|
|
39
|
-
finish: () =>
|
|
39
|
+
isCurrent: () => r === t,
|
|
40
|
+
finish: () => e.delete(n)
|
|
40
41
|
};
|
|
41
42
|
},
|
|
42
43
|
reset() {
|
|
43
|
-
|
|
44
|
-
for (const r of
|
|
45
|
-
|
|
44
|
+
t += 1;
|
|
45
|
+
for (const r of e) r.abort();
|
|
46
|
+
e.clear();
|
|
46
47
|
}
|
|
47
48
|
};
|
|
48
49
|
}
|
|
49
|
-
function
|
|
50
|
-
let
|
|
50
|
+
function Se(t) {
|
|
51
|
+
let e = "", r = "message", n = [];
|
|
51
52
|
function c() {
|
|
52
|
-
n.length > 0 &&
|
|
53
|
+
n.length > 0 && t({ event: r, data: n.join(`
|
|
53
54
|
`) }), r = "message", n = [];
|
|
54
55
|
}
|
|
55
56
|
function k(l) {
|
|
@@ -59,116 +60,116 @@ function _e(e) {
|
|
|
59
60
|
}
|
|
60
61
|
if (l.startsWith(":"))
|
|
61
62
|
return;
|
|
62
|
-
const i = l.indexOf(":"),
|
|
63
|
+
const i = l.indexOf(":"), s = i === -1 ? l : l.slice(0, i);
|
|
63
64
|
let d = i === -1 ? "" : l.slice(i + 1);
|
|
64
|
-
d.startsWith(" ") && (d = d.slice(1)),
|
|
65
|
+
d.startsWith(" ") && (d = d.slice(1)), s === "event" ? r = d : s === "data" && n.push(d);
|
|
65
66
|
}
|
|
66
67
|
return {
|
|
67
68
|
push(l) {
|
|
68
|
-
|
|
69
|
+
e += l;
|
|
69
70
|
let i;
|
|
70
|
-
for (; (i =
|
|
71
|
-
const
|
|
71
|
+
for (; (i = e.search(/\r\n|\n|\r/)) !== -1; ) {
|
|
72
|
+
const s = e.startsWith(`\r
|
|
72
73
|
`, i);
|
|
73
|
-
if (!
|
|
74
|
+
if (!s && e[i] === "\r" && i === e.length - 1)
|
|
74
75
|
return;
|
|
75
|
-
const d =
|
|
76
|
-
|
|
76
|
+
const d = e.slice(0, i);
|
|
77
|
+
e = e.slice(i + (s ? 2 : 1)), k(d);
|
|
77
78
|
}
|
|
78
79
|
},
|
|
79
80
|
/** Call when the stream ends; dispatches nothing that was not terminated by a blank line. */
|
|
80
81
|
flush() {
|
|
81
|
-
|
|
82
|
+
e = "", r = "message", n = [];
|
|
82
83
|
}
|
|
83
84
|
};
|
|
84
85
|
}
|
|
85
|
-
class
|
|
86
|
-
constructor(
|
|
87
|
-
super(r), this.name = "ChatError", this.code =
|
|
86
|
+
class h extends Error {
|
|
87
|
+
constructor(e, r, n, c) {
|
|
88
|
+
super(r), this.name = "ChatError", this.code = e, this.status = n, this.retryAfterSec = c;
|
|
88
89
|
}
|
|
89
90
|
}
|
|
90
|
-
const
|
|
91
|
-
function de(
|
|
92
|
-
return `${String(
|
|
91
|
+
const Ee = 3e4;
|
|
92
|
+
function de(t) {
|
|
93
|
+
return `${String(t).replace(/\/+$/, "")}/api/chat`;
|
|
93
94
|
}
|
|
94
|
-
async function fe(
|
|
95
|
-
let
|
|
95
|
+
async function fe(t) {
|
|
96
|
+
let e = `http_${t.status}`, r = `Request failed (${t.status})`;
|
|
96
97
|
try {
|
|
97
|
-
const c = await
|
|
98
|
-
c && c.error && (
|
|
98
|
+
const c = await t.json();
|
|
99
|
+
c && c.error && (e = c.error.code || e, r = c.error.message || r);
|
|
99
100
|
} catch {
|
|
100
101
|
}
|
|
101
|
-
const n = Number(
|
|
102
|
-
return new
|
|
102
|
+
const n = Number(t.headers && t.headers.get && t.headers.get("retry-after"));
|
|
103
|
+
return new h(e, r, t.status, Number.isFinite(n) && n > 0 ? n : void 0);
|
|
103
104
|
}
|
|
104
|
-
async function
|
|
105
|
-
apiUrl:
|
|
106
|
-
tenantId:
|
|
105
|
+
async function Ne({
|
|
106
|
+
apiUrl: t,
|
|
107
|
+
tenantId: e,
|
|
107
108
|
message: r,
|
|
108
109
|
sessionId: n,
|
|
109
110
|
signal: c,
|
|
110
111
|
onToken: k = () => {
|
|
111
112
|
},
|
|
112
|
-
idleTimeoutMs: l =
|
|
113
|
-
fetchImpl: i = (...
|
|
113
|
+
idleTimeoutMs: l = Ee,
|
|
114
|
+
fetchImpl: i = (...s) => fetch(...s)
|
|
114
115
|
}) {
|
|
115
|
-
const
|
|
116
|
+
const s = new AbortController();
|
|
116
117
|
let d = !1, N = null;
|
|
117
118
|
const P = () => {
|
|
118
119
|
l && (clearTimeout(N), N = setTimeout(() => {
|
|
119
|
-
d = !0,
|
|
120
|
+
d = !0, s.abort();
|
|
120
121
|
}, l));
|
|
121
|
-
}, U = () =>
|
|
122
|
+
}, U = () => s.abort();
|
|
122
123
|
if (c) {
|
|
123
124
|
if (c.aborted)
|
|
124
|
-
throw new
|
|
125
|
+
throw new h("aborted", "Request cancelled");
|
|
125
126
|
c.addEventListener("abort", U, { once: !0 });
|
|
126
127
|
}
|
|
127
|
-
const q = (f) => f instanceof
|
|
128
|
+
const q = (f) => f instanceof h ? f : d ? new h("timeout", "The assistant took too long to respond") : s.signal.aborted ? new h("aborted", "Request cancelled") : new h("network_error", "Could not reach the support service");
|
|
128
129
|
try {
|
|
129
130
|
P();
|
|
130
|
-
const f = await i(de(
|
|
131
|
+
const f = await i(de(t), {
|
|
131
132
|
method: "POST",
|
|
132
133
|
headers: {
|
|
133
134
|
"Content-Type": "application/json",
|
|
134
135
|
Accept: "text/event-stream, application/json"
|
|
135
136
|
},
|
|
136
137
|
body: JSON.stringify({
|
|
137
|
-
tenant_id:
|
|
138
|
+
tenant_id: e,
|
|
138
139
|
message: r,
|
|
139
140
|
session_id: n
|
|
140
141
|
}),
|
|
141
|
-
signal:
|
|
142
|
+
signal: s.signal
|
|
142
143
|
});
|
|
143
144
|
if (!f.ok)
|
|
144
145
|
throw await fe(f);
|
|
145
146
|
if (!(f.headers.get("content-type") || "").includes("text/event-stream") || !f.body) {
|
|
146
|
-
const
|
|
147
|
-
|
|
148
|
-
const
|
|
149
|
-
return { answer:
|
|
147
|
+
const b = await f.json(), g = String(b.answer ?? "");
|
|
148
|
+
g && k(g);
|
|
149
|
+
const y = ee(b.follow_up);
|
|
150
|
+
return { answer: g, sessionId: b.session_id ?? n, ...y ? { followUp: y } : {} };
|
|
150
151
|
}
|
|
151
152
|
let L = "", _ = !1, S, m = null;
|
|
152
|
-
const T =
|
|
153
|
-
let
|
|
153
|
+
const T = Se(({ event: b, data: g }) => {
|
|
154
|
+
let y = {};
|
|
154
155
|
try {
|
|
155
|
-
|
|
156
|
+
y = g ? JSON.parse(g) : {};
|
|
156
157
|
} catch {
|
|
157
158
|
return;
|
|
158
159
|
}
|
|
159
|
-
if (
|
|
160
|
-
const
|
|
161
|
-
L +=
|
|
162
|
-
} else
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
) :
|
|
160
|
+
if (b === "token") {
|
|
161
|
+
const I = String(y.text ?? "");
|
|
162
|
+
L += I, k(I);
|
|
163
|
+
} else b === "error" ? m = new h(
|
|
164
|
+
y.code || "stream_error",
|
|
165
|
+
y.message || "The assistant ran into a problem"
|
|
166
|
+
) : b === "done" && (_ = !0, S = ee(y.follow_up));
|
|
166
167
|
}), j = f.body.getReader(), C = new TextDecoder();
|
|
167
168
|
for (; ; ) {
|
|
168
|
-
const { done:
|
|
169
|
-
if (
|
|
169
|
+
const { done: b, value: g } = await j.read();
|
|
170
|
+
if (b)
|
|
170
171
|
break;
|
|
171
|
-
if (P(), T.push(C.decode(
|
|
172
|
+
if (P(), T.push(C.decode(g, { stream: !0 })), m)
|
|
172
173
|
throw await j.cancel().catch(() => {
|
|
173
174
|
}), m;
|
|
174
175
|
if (_) {
|
|
@@ -180,7 +181,7 @@ async function Ee({
|
|
|
180
181
|
if (T.push(C.decode()), T.flush(), m)
|
|
181
182
|
throw m;
|
|
182
183
|
if (!_)
|
|
183
|
-
throw new
|
|
184
|
+
throw new h("stream_interrupted", "The response ended unexpectedly");
|
|
184
185
|
return { answer: L, sessionId: n, ...S ? { followUp: S } : {} };
|
|
185
186
|
} catch (f) {
|
|
186
187
|
throw q(f);
|
|
@@ -188,23 +189,23 @@ async function Ee({
|
|
|
188
189
|
clearTimeout(N), c && c.removeEventListener("abort", U);
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
|
-
async function
|
|
192
|
-
apiUrl:
|
|
193
|
-
tenantId:
|
|
192
|
+
async function Te({
|
|
193
|
+
apiUrl: t,
|
|
194
|
+
tenantId: e,
|
|
194
195
|
sessionId: r,
|
|
195
196
|
followUpToken: n,
|
|
196
197
|
name: c,
|
|
197
198
|
email: k,
|
|
198
199
|
signal: l,
|
|
199
|
-
fetchImpl: i = (...
|
|
200
|
+
fetchImpl: i = (...s) => fetch(...s)
|
|
200
201
|
}) {
|
|
201
202
|
try {
|
|
202
|
-
if (l?.aborted) throw new
|
|
203
|
-
const
|
|
203
|
+
if (l?.aborted) throw new h("aborted", "Request cancelled");
|
|
204
|
+
const s = await i(`${de(t)}/contact`, {
|
|
204
205
|
method: "POST",
|
|
205
206
|
headers: { "Content-Type": "application/json", Accept: "application/json" },
|
|
206
207
|
body: JSON.stringify({
|
|
207
|
-
tenant_id:
|
|
208
|
+
tenant_id: e,
|
|
208
209
|
session_id: r,
|
|
209
210
|
follow_up_token: n,
|
|
210
211
|
name: c.trim(),
|
|
@@ -212,11 +213,11 @@ async function Ne({
|
|
|
212
213
|
}),
|
|
213
214
|
signal: l
|
|
214
215
|
});
|
|
215
|
-
if (!
|
|
216
|
-
if ((await
|
|
216
|
+
if (!s.ok) throw await fe(s);
|
|
217
|
+
if ((await s.json()).status !== "saved") throw new h("invalid_response", "Could not confirm save");
|
|
217
218
|
return { status: "saved" };
|
|
218
|
-
} catch (
|
|
219
|
-
throw l?.aborted ? new
|
|
219
|
+
} catch (s) {
|
|
220
|
+
throw l?.aborted ? new h("aborted", "Request cancelled") : s instanceof h ? s : new h("network_error", "Could not save contact details");
|
|
220
221
|
}
|
|
221
222
|
}
|
|
222
223
|
const R = /* @__PURE__ */ new Map();
|
|
@@ -230,11 +231,11 @@ function we() {
|
|
|
230
231
|
return null;
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
|
-
function ae(
|
|
234
|
-
const r = `support_widget_session:${
|
|
234
|
+
function ae(t, e = we()) {
|
|
235
|
+
const r = `support_widget_session:${t}`;
|
|
235
236
|
if (R.has(r)) return R.get(r);
|
|
236
237
|
try {
|
|
237
|
-
const c =
|
|
238
|
+
const c = e ? e.getItem(r) : null;
|
|
238
239
|
if (c)
|
|
239
240
|
return R.set(r, c), c;
|
|
240
241
|
} catch {
|
|
@@ -244,21 +245,21 @@ function ae(e, t = we()) {
|
|
|
244
245
|
const n = pe();
|
|
245
246
|
R.set(r, n);
|
|
246
247
|
try {
|
|
247
|
-
|
|
248
|
+
e && e.setItem(r, n);
|
|
248
249
|
} catch {
|
|
249
250
|
}
|
|
250
251
|
return n;
|
|
251
252
|
}
|
|
252
|
-
function
|
|
253
|
-
const r = `support_widget_session:${
|
|
253
|
+
function $e(t, e = we()) {
|
|
254
|
+
const r = `support_widget_session:${t}`, n = pe();
|
|
254
255
|
R.set(r, n);
|
|
255
256
|
try {
|
|
256
|
-
|
|
257
|
+
e?.setItem(r, n);
|
|
257
258
|
} catch {
|
|
258
259
|
}
|
|
259
260
|
return n;
|
|
260
261
|
}
|
|
261
|
-
const
|
|
262
|
+
const he = "The support assistant is temporarily unavailable. Please try again shortly.", se = "Something went wrong. Please try again.", ce = {
|
|
262
263
|
network_error: {
|
|
263
264
|
message: "We couldn't reach the support service. Please check your connection and try again.",
|
|
264
265
|
retryable: !0
|
|
@@ -270,7 +271,7 @@ const me = "The support assistant is temporarily unavailable. Please try again s
|
|
|
270
271
|
},
|
|
271
272
|
generation_failed: { message: "The assistant ran into a problem. Please try again.", retryable: !0 },
|
|
272
273
|
stream_error: { message: "The assistant ran into a problem. Please try again.", retryable: !0 },
|
|
273
|
-
service_unavailable: { message:
|
|
274
|
+
service_unavailable: { message: he, retryable: !0 },
|
|
274
275
|
message_too_long: {
|
|
275
276
|
message: "That message is too long. Please shorten it (2000 characters at most) and send it again.",
|
|
276
277
|
retryable: !1
|
|
@@ -279,24 +280,25 @@ const me = "The support assistant is temporarily unavailable. Please try again s
|
|
|
279
280
|
unknown_tenant: { message: "The support chat isn't available on this site.", retryable: !1 },
|
|
280
281
|
origin_not_allowed: { message: "The support chat isn't available on this site.", retryable: !1 }
|
|
281
282
|
};
|
|
282
|
-
function
|
|
283
|
-
const
|
|
284
|
-
if (
|
|
285
|
-
const n = Number(
|
|
283
|
+
function me(t) {
|
|
284
|
+
const e = t && t.code;
|
|
285
|
+
if (e === "rate_limited") {
|
|
286
|
+
const n = Number(t.retryAfterSec);
|
|
286
287
|
return { message: `You're sending messages too quickly. Please wait ${Number.isFinite(n) && n > 0 ? n > 90 ? `${Math.ceil(n / 60)} minutes` : `${Math.ceil(n)} seconds` : "a moment"} and try again.`, retryable: !0 };
|
|
287
288
|
}
|
|
288
|
-
if (
|
|
289
|
-
return ce[
|
|
290
|
-
const r = Number(
|
|
291
|
-
return r >= 500 ? { message:
|
|
289
|
+
if (e && ce[e])
|
|
290
|
+
return ce[e];
|
|
291
|
+
const r = Number(t && t.status);
|
|
292
|
+
return r >= 500 ? { message: he, retryable: !0 } : r >= 400 ? { message: se, retryable: !1 } : { message: se, retryable: !0 };
|
|
292
293
|
}
|
|
293
|
-
function
|
|
294
|
-
return
|
|
294
|
+
function Re(t) {
|
|
295
|
+
return me(t).message;
|
|
295
296
|
}
|
|
296
|
-
function
|
|
297
|
-
return
|
|
297
|
+
function Pe(t) {
|
|
298
|
+
return me(t).retryable;
|
|
298
299
|
}
|
|
299
|
-
const
|
|
300
|
+
const Ae = `
|
|
301
|
+
:host { all: initial; }
|
|
300
302
|
.cw-root {
|
|
301
303
|
--cw-accent: #1f6feb;
|
|
302
304
|
--cw-accent-text: #ffffff;
|
|
@@ -472,14 +474,14 @@ const Pe = `
|
|
|
472
474
|
@media (prefers-reduced-motion: reduce) {
|
|
473
475
|
.cw-typing::after { animation: none; }
|
|
474
476
|
}
|
|
475
|
-
`, ie = 2e3,
|
|
477
|
+
`, ie = 2e3, Le = 6e3;
|
|
476
478
|
let le = 0;
|
|
477
479
|
function V() {
|
|
478
480
|
return le += 1, `m${le}`;
|
|
479
481
|
}
|
|
480
|
-
function
|
|
481
|
-
apiUrl:
|
|
482
|
-
tenantId:
|
|
482
|
+
function Ie({
|
|
483
|
+
apiUrl: t,
|
|
484
|
+
tenantId: e,
|
|
483
485
|
title: r = "Support",
|
|
484
486
|
greeting: n = "Hi! How can I help you today?",
|
|
485
487
|
position: c = "right",
|
|
@@ -487,110 +489,110 @@ function qe({
|
|
|
487
489
|
defaultOpen: l = !1,
|
|
488
490
|
fetchImpl: i
|
|
489
491
|
}) {
|
|
490
|
-
const [
|
|
492
|
+
const [s, d] = w(l), [N, P] = w(""), [U, q] = w(!1), [f, A] = w(!1), [L, _] = w(() => [
|
|
491
493
|
{ id: V(), role: "assistant", text: n, status: "done" }
|
|
492
494
|
]), S = $(null), m = $(null);
|
|
493
|
-
m.current || (m.current =
|
|
494
|
-
const [T, j] =
|
|
495
|
-
m.current.reset(), S.current = null, H.current = !1,
|
|
496
|
-
}, [
|
|
495
|
+
m.current || (m.current = _e());
|
|
496
|
+
const [T, j] = w(() => ae(e)), [C, b] = w(null), [g, y] = w(""), [I, X] = w(""), [z, D] = w("idle"), [te, W] = w(""), F = $(!1), H = $(!1), re = $(null), Y = $(null), K = $(""), ne = J((o) => {
|
|
497
|
+
m.current.reset(), S.current = null, H.current = !1, F.current = !1, K.current = "", j(o ? $e(e) : ae(e)), _([{ id: V(), role: "assistant", text: n, status: "done" }]), P(""), q(!1), A(!1), b(null), y(""), X(""), D("idle"), W(""), Y.current?.focus();
|
|
498
|
+
}, [e, n]);
|
|
497
499
|
ve(() => {
|
|
498
500
|
ne(!1);
|
|
499
|
-
}, [
|
|
501
|
+
}, [e, t]), Z(() => {
|
|
500
502
|
const o = re.current;
|
|
501
503
|
o && (o.scrollTop = o.scrollHeight);
|
|
502
|
-
}, [L,
|
|
503
|
-
|
|
504
|
-
}, [
|
|
504
|
+
}, [L, s]), Z(() => {
|
|
505
|
+
s && Y.current && Y.current.focus();
|
|
506
|
+
}, [s]), Z(() => () => m.current.reset(), []);
|
|
505
507
|
const M = J((o, u) => {
|
|
506
|
-
_((
|
|
507
|
-
}, []),
|
|
508
|
+
_((v) => v.map((x) => x.id === o ? { ...x, ...u } : x));
|
|
509
|
+
}, []), Q = J(
|
|
508
510
|
async (o) => {
|
|
509
511
|
const u = o.trim().slice(0, ie);
|
|
510
512
|
if (!u || H.current)
|
|
511
513
|
return;
|
|
512
|
-
H.current = !0,
|
|
513
|
-
const
|
|
514
|
+
H.current = !0, K.current = u;
|
|
515
|
+
const v = V();
|
|
514
516
|
_((E) => [
|
|
515
517
|
...E,
|
|
516
518
|
{ id: V(), role: "user", text: u, status: "done" },
|
|
517
|
-
{ id:
|
|
519
|
+
{ id: v, role: "assistant", text: "", status: "streaming" }
|
|
518
520
|
]), P(""), q(!0);
|
|
519
|
-
const
|
|
520
|
-
S.current =
|
|
521
|
+
const x = m.current.begin();
|
|
522
|
+
S.current = x;
|
|
521
523
|
let O = "";
|
|
522
524
|
A(!1);
|
|
523
525
|
const oe = setTimeout(() => {
|
|
524
|
-
|
|
525
|
-
},
|
|
526
|
+
x.isCurrent() && A(!0);
|
|
527
|
+
}, Le);
|
|
526
528
|
try {
|
|
527
|
-
const E = await
|
|
528
|
-
apiUrl:
|
|
529
|
-
tenantId:
|
|
529
|
+
const E = await Ne({
|
|
530
|
+
apiUrl: t,
|
|
531
|
+
tenantId: e,
|
|
530
532
|
message: u,
|
|
531
533
|
sessionId: T,
|
|
532
|
-
signal:
|
|
534
|
+
signal: x.signal,
|
|
533
535
|
fetchImpl: i,
|
|
534
536
|
onToken: (B) => {
|
|
535
|
-
|
|
537
|
+
x.isCurrent() && (clearTimeout(oe), A(!1), O += B, M(v, { text: O }));
|
|
536
538
|
}
|
|
537
539
|
});
|
|
538
|
-
if (!
|
|
539
|
-
M(
|
|
540
|
+
if (!x.isCurrent()) return;
|
|
541
|
+
M(v, { status: "done" }), E.followUp && (b(E.followUp), W(""));
|
|
540
542
|
} catch (E) {
|
|
541
|
-
if (!
|
|
543
|
+
if (!x.isCurrent()) return;
|
|
542
544
|
if (E.code === "aborted")
|
|
543
|
-
M(
|
|
545
|
+
M(v, { status: "done", text: O || "(stopped)" });
|
|
544
546
|
else {
|
|
545
|
-
const B =
|
|
546
|
-
M(
|
|
547
|
+
const B = Re(E);
|
|
548
|
+
M(v, {
|
|
547
549
|
status: "error",
|
|
548
|
-
retryable:
|
|
550
|
+
retryable: Pe(E),
|
|
549
551
|
text: O ? `${O}
|
|
550
552
|
|
|
551
553
|
${B}` : B
|
|
552
554
|
});
|
|
553
555
|
}
|
|
554
556
|
} finally {
|
|
555
|
-
clearTimeout(oe),
|
|
557
|
+
clearTimeout(oe), x.finish(), x.isCurrent() && (S.current = null, H.current = !1, A(!1), q(!1));
|
|
556
558
|
}
|
|
557
559
|
},
|
|
558
|
-
[
|
|
560
|
+
[t, e, T, i, M]
|
|
559
561
|
), be = J(() => {
|
|
560
|
-
const o =
|
|
561
|
-
o && (_((u) => u.slice(0, -2)),
|
|
562
|
-
}, [
|
|
563
|
-
o.preventDefault(),
|
|
562
|
+
const o = K.current;
|
|
563
|
+
o && (_((u) => u.slice(0, -2)), Q(o));
|
|
564
|
+
}, [Q]), ge = (o) => {
|
|
565
|
+
o.preventDefault(), Q(N);
|
|
564
566
|
}, ye = async (o) => {
|
|
565
|
-
if (o.preventDefault(), !C ||
|
|
566
|
-
|
|
567
|
+
if (o.preventDefault(), !C || F.current || z === "saved") return;
|
|
568
|
+
F.current = !0;
|
|
567
569
|
const u = m.current.begin();
|
|
568
|
-
D("pending"),
|
|
569
|
-
const
|
|
570
|
+
D("pending"), W("");
|
|
571
|
+
const v = setTimeout(() => u.abort(), 3e4);
|
|
570
572
|
try {
|
|
571
|
-
await
|
|
572
|
-
apiUrl:
|
|
573
|
-
tenantId:
|
|
573
|
+
await Te({
|
|
574
|
+
apiUrl: t,
|
|
575
|
+
tenantId: e,
|
|
574
576
|
sessionId: T,
|
|
575
577
|
followUpToken: C.token,
|
|
576
|
-
name:
|
|
577
|
-
email:
|
|
578
|
+
name: g,
|
|
579
|
+
email: I,
|
|
578
580
|
signal: u.signal,
|
|
579
581
|
fetchImpl: i
|
|
580
|
-
}), u.isCurrent() && (D("saved"),
|
|
582
|
+
}), u.isCurrent() && (D("saved"), y(""), X(""));
|
|
581
583
|
} catch {
|
|
582
|
-
u.isCurrent() && (D("error"),
|
|
584
|
+
u.isCurrent() && (D("error"), W("Your details could not be saved. Please try again or contact the business directly."));
|
|
583
585
|
} finally {
|
|
584
|
-
clearTimeout(
|
|
586
|
+
clearTimeout(v), u.finish(), u.isCurrent() && (F.current = !1);
|
|
585
587
|
}
|
|
586
|
-
}, G =
|
|
588
|
+
}, G = Ce(C);
|
|
587
589
|
return /* @__PURE__ */ p("div", { className: `cw-root ${c === "left" ? "cw-left" : "cw-right"}`, style: k ? { "--cw-accent": k } : void 0, children: [
|
|
588
|
-
/* @__PURE__ */
|
|
589
|
-
|
|
590
|
+
/* @__PURE__ */ a("style", { children: Ae }),
|
|
591
|
+
s ? /* @__PURE__ */ p("section", { className: "cw-panel", role: "dialog", "aria-label": r, children: [
|
|
590
592
|
/* @__PURE__ */ p("header", { className: "cw-header", children: [
|
|
591
|
-
/* @__PURE__ */
|
|
592
|
-
/* @__PURE__ */
|
|
593
|
-
/* @__PURE__ */
|
|
593
|
+
/* @__PURE__ */ a("span", { children: r }),
|
|
594
|
+
/* @__PURE__ */ a("button", { type: "button", className: "cw-new-chat", onClick: () => ne(!0), children: "New chat" }),
|
|
595
|
+
/* @__PURE__ */ a(
|
|
594
596
|
"button",
|
|
595
597
|
{
|
|
596
598
|
type: "button",
|
|
@@ -603,7 +605,7 @@ ${B}` : B
|
|
|
603
605
|
] }),
|
|
604
606
|
/* @__PURE__ */ p("div", { className: "cw-messages", ref: re, role: "log", "aria-live": "polite", children: [
|
|
605
607
|
L.map((o, u) => {
|
|
606
|
-
const
|
|
608
|
+
const v = u === L.length - 1;
|
|
607
609
|
return /* @__PURE__ */ p(
|
|
608
610
|
"div",
|
|
609
611
|
{
|
|
@@ -611,31 +613,31 @@ ${B}` : B
|
|
|
611
613
|
children: [
|
|
612
614
|
o.text,
|
|
613
615
|
o.status === "streaming" && !o.text ? /* @__PURE__ */ p(xe, { children: [
|
|
614
|
-
/* @__PURE__ */
|
|
615
|
-
f ? /* @__PURE__ */
|
|
616
|
+
/* @__PURE__ */ a("span", { className: "cw-typing", "aria-label": "Assistant is typing" }),
|
|
617
|
+
f ? /* @__PURE__ */ a("span", { className: "cw-slow", children: "Still working on your answer…" }) : null
|
|
616
618
|
] }) : null,
|
|
617
|
-
o.status === "error" && o.retryable !== !1 &&
|
|
619
|
+
o.status === "error" && o.retryable !== !1 && v && !U ? /* @__PURE__ */ a("div", { children: /* @__PURE__ */ a("button", { type: "button", className: "cw-retry", onClick: be, children: "Retry" }) }) : null
|
|
618
620
|
]
|
|
619
621
|
},
|
|
620
622
|
o.id
|
|
621
623
|
);
|
|
622
624
|
}),
|
|
623
625
|
C ? /* @__PURE__ */ p("section", { className: "cw-follow-up", "aria-label": "Email follow-up", children: [
|
|
624
|
-
/* @__PURE__ */
|
|
625
|
-
/* @__PURE__ */
|
|
626
|
+
/* @__PURE__ */ a("strong", { children: "Email follow-up" }),
|
|
627
|
+
/* @__PURE__ */ a("p", { children: "Email follow-up is not immediate. For time-sensitive help, contact the business directly." }),
|
|
626
628
|
G.phone ? /* @__PURE__ */ p("p", { children: [
|
|
627
629
|
"Call ",
|
|
628
|
-
/* @__PURE__ */
|
|
630
|
+
/* @__PURE__ */ a("a", { href: G.phone, target: "_blank", rel: "noopener noreferrer", children: C.contactPhone })
|
|
629
631
|
] }) : null,
|
|
630
632
|
G.email ? /* @__PURE__ */ p("p", { children: [
|
|
631
633
|
"Email ",
|
|
632
|
-
/* @__PURE__ */
|
|
634
|
+
/* @__PURE__ */ a("a", { href: G.email, target: "_blank", rel: "noopener noreferrer", children: C.contactEmail })
|
|
633
635
|
] }) : null,
|
|
634
|
-
|
|
635
|
-
/* @__PURE__ */
|
|
636
|
+
z === "saved" ? /* @__PURE__ */ a("p", { role: "status", children: "Your details were saved for the team to review and follow up by email." }) : /* @__PURE__ */ p("form", { className: "cw-contact-form", onSubmit: ye, children: [
|
|
637
|
+
/* @__PURE__ */ a("p", { children: "Leave your name and email to request follow-up about this conversation." }),
|
|
636
638
|
/* @__PURE__ */ p("label", { children: [
|
|
637
639
|
"Name",
|
|
638
|
-
/* @__PURE__ */
|
|
640
|
+
/* @__PURE__ */ a(
|
|
639
641
|
"input",
|
|
640
642
|
{
|
|
641
643
|
className: "cw-input",
|
|
@@ -643,15 +645,15 @@ ${B}` : B
|
|
|
643
645
|
autoComplete: "name",
|
|
644
646
|
required: !0,
|
|
645
647
|
maxLength: 100,
|
|
646
|
-
value:
|
|
647
|
-
disabled:
|
|
648
|
-
onChange: (o) =>
|
|
648
|
+
value: g,
|
|
649
|
+
disabled: z === "pending",
|
|
650
|
+
onChange: (o) => y(o.target.value)
|
|
649
651
|
}
|
|
650
652
|
)
|
|
651
653
|
] }),
|
|
652
654
|
/* @__PURE__ */ p("label", { children: [
|
|
653
655
|
"Email",
|
|
654
|
-
/* @__PURE__ */
|
|
656
|
+
/* @__PURE__ */ a(
|
|
655
657
|
"input",
|
|
656
658
|
{
|
|
657
659
|
className: "cw-input",
|
|
@@ -660,19 +662,19 @@ ${B}` : B
|
|
|
660
662
|
autoComplete: "email",
|
|
661
663
|
required: !0,
|
|
662
664
|
maxLength: 254,
|
|
663
|
-
value:
|
|
664
|
-
disabled:
|
|
665
|
-
onChange: (o) =>
|
|
665
|
+
value: I,
|
|
666
|
+
disabled: z === "pending",
|
|
667
|
+
onChange: (o) => X(o.target.value)
|
|
666
668
|
}
|
|
667
669
|
)
|
|
668
670
|
] }),
|
|
669
|
-
te ? /* @__PURE__ */
|
|
670
|
-
/* @__PURE__ */
|
|
671
|
+
te ? /* @__PURE__ */ a("p", { role: "alert", children: te }) : null,
|
|
672
|
+
/* @__PURE__ */ a("button", { className: "cw-send", type: "submit", disabled: z === "pending" || !g.trim() || !I.trim(), children: z === "pending" ? "Saving…" : "Request email follow-up" })
|
|
671
673
|
] })
|
|
672
674
|
] }) : null
|
|
673
675
|
] }),
|
|
674
676
|
/* @__PURE__ */ p("form", { className: "cw-form", onSubmit: ge, children: [
|
|
675
|
-
/* @__PURE__ */
|
|
677
|
+
/* @__PURE__ */ a(
|
|
676
678
|
"input",
|
|
677
679
|
{
|
|
678
680
|
ref: Y,
|
|
@@ -684,7 +686,7 @@ ${B}` : B
|
|
|
684
686
|
onChange: (o) => P(o.target.value)
|
|
685
687
|
}
|
|
686
688
|
),
|
|
687
|
-
U ? /* @__PURE__ */
|
|
689
|
+
U ? /* @__PURE__ */ a(
|
|
688
690
|
"button",
|
|
689
691
|
{
|
|
690
692
|
type: "button",
|
|
@@ -692,26 +694,32 @@ ${B}` : B
|
|
|
692
694
|
onClick: () => S.current?.abort(),
|
|
693
695
|
children: "Stop"
|
|
694
696
|
}
|
|
695
|
-
) : /* @__PURE__ */
|
|
697
|
+
) : /* @__PURE__ */ a("button", { type: "submit", className: "cw-send", disabled: !N.trim(), children: "Send" })
|
|
696
698
|
] }),
|
|
697
|
-
/* @__PURE__ */
|
|
698
|
-
] }) : /* @__PURE__ */
|
|
699
|
+
/* @__PURE__ */ a("div", { className: "cw-footer", children: "AI assistant – answers may contain mistakes." })
|
|
700
|
+
] }) : /* @__PURE__ */ a(
|
|
699
701
|
"button",
|
|
700
702
|
{
|
|
701
703
|
type: "button",
|
|
702
704
|
className: "cw-launcher",
|
|
703
705
|
"aria-label": `Open ${r} chat`,
|
|
704
706
|
onClick: () => d(!0),
|
|
705
|
-
children: /* @__PURE__ */
|
|
707
|
+
children: /* @__PURE__ */ a("svg", { width: "26", height: "26", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ a("path", { d: "M4 3h16a2 2 0 0 1 2 2v11a2 2 0 0 1-2 2H9l-5 4v-4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z" }) })
|
|
706
708
|
}
|
|
707
709
|
)
|
|
708
710
|
] });
|
|
709
711
|
}
|
|
712
|
+
function Oe(t) {
|
|
713
|
+
const [e, r] = w(null), [n, c] = w(null);
|
|
714
|
+
return Z(() => {
|
|
715
|
+
e && c(e.shadowRoot || e.attachShadow({ mode: "open" }));
|
|
716
|
+
}, [e]), /* @__PURE__ */ a("div", { ref: r, "data-support-widget": t.tenantId, children: n ? ke(/* @__PURE__ */ a(Ie, { ...t }), n) : null });
|
|
717
|
+
}
|
|
710
718
|
export {
|
|
711
|
-
|
|
712
|
-
|
|
719
|
+
h as ChatError,
|
|
720
|
+
Oe as ChatWidget,
|
|
713
721
|
ae as getSessionId,
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
722
|
+
$e as newSessionId,
|
|
723
|
+
Ne as streamChat,
|
|
724
|
+
Te as submitContact
|
|
717
725
|
};
|
package/dist/widget.js
CHANGED
|
@@ -9,6 +9,7 @@ Error generating stack: `+a.message+`
|
|
|
9
9
|
`).replace(Ky,"")}function Ud(l,t){return t=Md(t),Md(l)===t}function ml(l,t,u,a,e,n){switch(u){case"children":if(typeof a=="string")t==="body"||t==="textarea"&&a===""||pa(l,a);else if(typeof a=="number"||typeof a=="bigint")t!=="body"&&pa(l,""+a);else return;break;case"className":En(l,"class",a);break;case"tabIndex":En(l,"tabindex",a);break;case"dir":case"role":case"viewBox":case"width":case"height":En(l,u,a);break;case"style":Ns(l,a,n);return;case"data":if(t!=="object"){En(l,"data",a);break}case"src":case"href":if(a===""&&(t!=="a"||u!=="href")){l.removeAttribute(u);break}if(a==null||typeof a=="function"||typeof a=="symbol"||typeof a=="boolean"){l.removeAttribute(u);break}a=zn(a),l.setAttribute(u,a);break;case"action":case"formAction":if(typeof a=="function"){l.setAttribute(u,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof n=="function"&&(u==="formAction"?(t!=="input"&&ml(l,t,"name",e.name,e,null),ml(l,t,"formEncType",e.formEncType,e,null),ml(l,t,"formMethod",e.formMethod,e,null),ml(l,t,"formTarget",e.formTarget,e,null)):(ml(l,t,"encType",e.encType,e,null),ml(l,t,"method",e.method,e,null),ml(l,t,"target",e.target,e,null)));if(a==null||typeof a=="symbol"||typeof a=="boolean"){l.removeAttribute(u);break}a=zn(a),l.setAttribute(u,a);break;case"onClick":a!=null&&(l.onclick=Wt);return;case"onScroll":a!=null&&F("scroll",l);return;case"onScrollEnd":a!=null&&F("scrollend",l);return;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(u=a.__html,u!=null){if(e.children!=null)throw Error(r(60));n?.__html!==u&&(l.innerHTML=u)}}break;case"multiple":l.multiple=a&&typeof a!="function"&&typeof a!="symbol";break;case"muted":l.muted=a&&typeof a!="function"&&typeof a!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(a==null||typeof a=="function"||typeof a=="boolean"||typeof a=="symbol"){l.removeAttribute("xlink:href");break}u=zn(a),l.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",u);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":a!=null&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(u,a):l.removeAttribute(u);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"credentialless":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":a&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(u,""):l.removeAttribute(u);break;case"capture":case"download":a===!0?l.setAttribute(u,""):a!==!1&&a!=null&&typeof a!="function"&&typeof a!="symbol"?l.setAttribute(u,a):l.removeAttribute(u);break;case"cols":case"rows":case"size":case"span":a!=null&&typeof a!="function"&&typeof a!="symbol"&&!isNaN(a)&&1<=a?l.setAttribute(u,a):l.removeAttribute(u);break;case"rowSpan":case"start":a==null||typeof a=="function"||typeof a=="symbol"||isNaN(a)?l.removeAttribute(u):l.setAttribute(u,a);break;case"popover":F("beforetoggle",l),F("toggle",l),Tn(l,"popover",a);break;case"xlinkActuate":ou(l,"http://www.w3.org/1999/xlink","xlink:actuate",a);break;case"xlinkArcrole":ou(l,"http://www.w3.org/1999/xlink","xlink:arcrole",a);break;case"xlinkRole":ou(l,"http://www.w3.org/1999/xlink","xlink:role",a);break;case"xlinkShow":ou(l,"http://www.w3.org/1999/xlink","xlink:show",a);break;case"xlinkTitle":ou(l,"http://www.w3.org/1999/xlink","xlink:title",a);break;case"xlinkType":ou(l,"http://www.w3.org/1999/xlink","xlink:type",a);break;case"xmlBase":ou(l,"http://www.w3.org/XML/1998/namespace","xml:base",a);break;case"xmlLang":ou(l,"http://www.w3.org/XML/1998/namespace","xml:lang",a);break;case"xmlSpace":ou(l,"http://www.w3.org/XML/1998/namespace","xml:space",a);break;case"is":Tn(l,"is",a);break;case"innerText":case"textContent":return;default:if(!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")u=rm.get(u)||u,Tn(l,u,a);else return}ol=!0}function co(l,t,u,a,e,n){switch(u){case"style":Ns(l,a,n);return;case"dangerouslySetInnerHTML":if(a!=null){if(typeof a!="object"||!("__html"in a))throw Error(r(61));if(u=a.__html,u!=null){if(e.children!=null)throw Error(r(60));n?.__html!==u&&(l.innerHTML=u)}}break;case"children":if(typeof a=="string")pa(l,a);else if(typeof a=="number"||typeof a=="bigint")pa(l,""+a);else return;break;case"onScroll":a!=null&&F("scroll",l);return;case"onScrollEnd":a!=null&&F("scrollend",l);return;case"onClick":a!=null&&(l.onclick=Wt);return;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"innerHTML":case"ref":return;case"innerText":case"textContent":return;default:if(!hs.hasOwnProperty(u))l:{if(u[0]==="o"&&u[1]==="n"&&(e=u.endsWith("Capture"),n=u.slice(2,e?u.length-7:void 0),t=l[dt]||null,t=t!=null?t[u]:null,typeof t=="function"&&l.removeEventListener(n,t,e),typeof a=="function")){typeof t!="function"&&t!==null&&(u in l?l[u]=null:l.hasAttribute(u)&&l.removeAttribute(u)),l.addEventListener(n,a,e);break l}ol=!0,u in l?l[u]=a:a===!0?l.setAttribute(u,""):Tn(l,u,a)}return}ol=!0}function ut(l,t,u){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"img":F("error",l),F("load",l);var a=!1,e=!1,n;for(n in u)if(u.hasOwnProperty(n)){var c=u[n];if(c!=null)switch(n){case"src":a=!0;break;case"srcSet":e=!0;break;case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:ml(l,t,n,c,u,null)}}e&&ml(l,t,"srcSet",u.srcSet,u,null),a&&ml(l,t,"src",u.src,u,null);return;case"input":F("invalid",l);var f=n=c=e=null,i=null,m=null;for(a in u)if(u.hasOwnProperty(a)){var g=u[a];if(g!=null)switch(a){case"name":e=g;break;case"type":c=g;break;case"checked":i=g;break;case"defaultChecked":m=g;break;case"value":n=g;break;case"defaultValue":f=g;break;case"children":case"dangerouslySetInnerHTML":if(g!=null)throw Error(r(137,t));break;default:ml(l,t,a,g,u,null)}}zs(l,n,f,i,m,c,e,!1);return;case"select":F("invalid",l),a=c=n=null;for(e in u)if(u.hasOwnProperty(e)&&(f=u[e],f!=null))switch(e){case"value":n=f;break;case"defaultValue":c=f;break;case"multiple":a=f;default:ml(l,t,e,f,u,null)}t=n,u=c,l.multiple=!!a,t!=null?Da(l,!!a,t,!1):u!=null&&Da(l,!!a,u,!0);return;case"textarea":F("invalid",l),n=e=a=null;for(c in u)if(u.hasOwnProperty(c)&&(f=u[c],f!=null))switch(c){case"value":a=f;break;case"defaultValue":e=f;break;case"children":n=f;break;case"dangerouslySetInnerHTML":if(f!=null)throw Error(r(91));break;default:ml(l,t,c,f,u,null)}Os(l,a,e,n);return;case"option":for(i in u)u.hasOwnProperty(i)&&(a=u[i],a!=null)&&(i==="selected"?l.selected=a&&typeof a!="function"&&typeof a!="symbol":ml(l,t,i,a,u,null));return;case"dialog":F("beforetoggle",l),F("toggle",l),F("cancel",l),F("close",l);break;case"iframe":case"object":F("load",l);break;case"video":case"audio":for(a=0;a<Ie.length;a++)F(Ie[a],l);break;case"image":F("error",l),F("load",l);break;case"details":F("toggle",l);break;case"embed":case"source":case"link":F("error",l),F("load",l);case"area":case"base":case"br":case"col":case"hr":case"keygen":case"meta":case"param":case"track":case"wbr":case"menuitem":for(m in u)if(u.hasOwnProperty(m)&&(a=u[m],a!=null))switch(m){case"children":case"dangerouslySetInnerHTML":throw Error(r(137,t));default:ml(l,t,m,a,u,null)}return;default:if(ff(t)){for(g in u)u.hasOwnProperty(g)&&(a=u[g],a!==void 0&&co(l,t,g,a,u,void 0));return}}for(f in u)u.hasOwnProperty(f)&&(a=u[f],a!=null&&ml(l,t,f,a,u,null))}var Jy={};function $y(l,t,u,a){switch(t){case"div":case"span":case"svg":case"path":case"a":case"g":case"p":case"li":break;case"input":var e=null,n=null,c=null,f=null,i=null,m=null,g=null;for(h in u){var E=u[h];if(u.hasOwnProperty(h)&&E!=null)switch(h){case"checked":break;case"value":break;case"defaultValue":i=E;default:a.hasOwnProperty(h)||ml(l,t,h,null,a,E)}}for(var d in a){var h=a[d];if(E=u[d],a.hasOwnProperty(d)&&(h!=null||E!=null))switch(d){case"type":h!==E&&(ol=!0),n=h;break;case"name":h!==E&&(ol=!0),e=h;break;case"checked":h!==E&&(ol=!0),m=h;break;case"defaultChecked":h!==E&&(ol=!0),g=h;break;case"value":h!==E&&(ol=!0),c=h;break;case"defaultValue":h!==E&&(ol=!0),f=h;break;case"children":case"dangerouslySetInnerHTML":if(h!=null)throw Error(r(137,t));break;default:h!==E&&ml(l,t,d,h,a,E)}}nf(l,c,f,i,m,g,n,e);return;case"select":h=c=f=d=null;for(n in u)if(i=u[n],u.hasOwnProperty(n)&&i!=null)switch(n){case"value":break;case"multiple":h=i;default:a.hasOwnProperty(n)||ml(l,t,n,null,a,i)}for(e in a)if(n=a[e],i=u[e],a.hasOwnProperty(e)&&(n!=null||i!=null))switch(e){case"value":n!==i&&(ol=!0),d=n;break;case"defaultValue":n!==i&&(ol=!0),f=n;break;case"multiple":n!==i&&(ol=!0),c=n;default:n!==i&&ml(l,t,e,n,a,i)}t=f,u=c,a=h,d!=null?Da(l,!!u,d,!1):!!a!=!!u&&(t!=null?Da(l,!!u,t,!0):Da(l,!!u,u?[]:"",!1));return;case"textarea":h=d=null;for(f in u)if(e=u[f],u.hasOwnProperty(f)&&e!=null&&!a.hasOwnProperty(f))switch(f){case"value":break;case"children":break;default:ml(l,t,f,null,a,e)}for(c in a)if(e=a[c],n=u[c],a.hasOwnProperty(c)&&(e!=null||n!=null))switch(c){case"value":e!==n&&(ol=!0),d=e;break;case"defaultValue":e!==n&&(ol=!0),h=e;break;case"children":break;case"dangerouslySetInnerHTML":if(e!=null)throw Error(r(91));break;default:e!==n&&ml(l,t,c,e,a,n)}_s(l,d,h);return;case"option":for(var _ in u)d=u[_],u.hasOwnProperty(_)&&d!=null&&!a.hasOwnProperty(_)&&(_==="selected"?l.selected=!1:ml(l,t,_,null,a,d));for(i in a)d=a[i],h=u[i],a.hasOwnProperty(i)&&d!==h&&(d!=null||h!=null)&&(i==="selected"?(d!==h&&(ol=!0),l.selected=d&&typeof d!="function"&&typeof d!="symbol"):ml(l,t,i,d,a,h));return;case"img":case"link":case"area":case"base":case"br":case"col":case"embed":case"hr":case"keygen":case"meta":case"param":case"source":case"track":case"wbr":case"menuitem":for(var C in u)d=u[C],u.hasOwnProperty(C)&&d!=null&&!a.hasOwnProperty(C)&&ml(l,t,C,null,a,d);for(m in a)if(d=a[m],h=u[m],a.hasOwnProperty(m)&&d!==h&&(d!=null||h!=null))switch(m){case"children":case"dangerouslySetInnerHTML":if(d!=null)throw Error(r(137,t));break;default:ml(l,t,m,d,a,h)}return;default:if(ff(t)){for(var K in u)d=u[K],u.hasOwnProperty(K)&&d!==void 0&&!a.hasOwnProperty(K)&&co(l,t,K,void 0,a,d);for(g in a)d=a[g],h=u[g],!a.hasOwnProperty(g)||d===h||d===void 0&&h===void 0||co(l,t,g,d,a,h);return}}for(var v in u)d=u[v],u.hasOwnProperty(v)&&d!=null&&!a.hasOwnProperty(v)&&ml(l,t,v,null,a,d);for(E in a)d=a[E],h=u[E],!a.hasOwnProperty(E)||d===h||d==null&&h==null||ml(l,t,E,d,a,h)}function Rd(l){switch(l){case"css":case"script":case"font":case"img":case"image":case"input":case"link":return!0;default:return!1}}function Wy(){if(typeof performance.getEntriesByType=="function"){for(var l=0,t=0,u=performance.getEntriesByType("resource"),a=0;a<u.length;a++){var e=u[a],n=e.transferSize,c=e.initiatorType,f=e.duration;if(n&&f&&Rd(c)){for(c=0,f=e.responseEnd,a+=1;a<u.length;a++){var i=u[a],m=i.startTime;if(m>f)break;var g=i.transferSize,E=i.initiatorType;g&&Rd(E)&&(i=i.responseEnd,c+=g*(i<f?1:(f-m)/(i-m)))}if(--a,t+=8*(n+c)/(e.duration/1e3),l++,10<l)break}}if(0<l)return t/l/1e6}return navigator.connection&&(l=navigator.connection.downlink,typeof l=="number")?l:5}var fo=null,io=null;function ln(l){return l.nodeType===9?l:l.ownerDocument}function Hd(l){switch(l){case"http://www.w3.org/2000/svg":return 1;case"http://www.w3.org/1998/Math/MathML":return 2;default:return 0}}function xd(l,t){if(l===0)switch(t){case"svg":return 1;case"math":return 2;default:return 0}return l===1&&t==="foreignObject"?0:l}function qd(l,t,u,a){return u=ln(u).createElement(l),u[kl]=a,u[dt]=t,ut(u,l,t),Kl(u),u}function oo(l,t){return l==="textarea"||l==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.children=="bigint"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var so=null;function Fy(){var l=window.event;return l&&l.type==="popstate"?l===so?!1:(so=l,!0):(so=null,!1)}var ro=typeof setTimeout=="function"?setTimeout:void 0,ky=typeof clearTimeout=="function"?clearTimeout:void 0,Yd=typeof Promise=="function"?Promise:void 0,Bd=typeof requestAnimationFrame=="function"?requestAnimationFrame:ro,Iy=typeof queueMicrotask=="function"?queueMicrotask:typeof Yd<"u"?function(l){return Yd.resolve(null).then(l).catch(Py)}:ro;function Py(l){setTimeout(function(){throw l})}function Ku(l){return l==="head"}function jd(l,t){var u=t,a=0;do{var e=u.nextSibling;if(l.removeChild(u),e&&e.nodeType===8)if(u=e.data,u==="/$"||u==="/&"){if(a===0){l.removeChild(e),re(t);return}a--}else if(u==="$"||u==="$?"||u==="$~"||u==="$!"||u==="&")a++;else if(u==="html")To(l.ownerDocument.documentElement);else if(u==="head"){u=l.ownerDocument.head,To(u);for(var n=u.firstChild;n;){var c=n.nextSibling,f=n.nodeName;n[Se]||f==="SCRIPT"||f==="STYLE"||f==="LINK"&&n.rel.toLowerCase()==="stylesheet"||u.removeChild(n),n=c}}else u==="body"&&To(l.ownerDocument.body);u=e}while(u);re(t)}function Gd(l,t){var u=l;l=0;do{var a=u.nextSibling;if(u.nodeType===1?t?(u._stashedDisplay=u.style.display,u.style.display="none"):(u.style.display=u._stashedDisplay||"",u.getAttribute("style")===""&&u.removeAttribute("style")):u.nodeType===3&&(t?(u._stashedText=u.nodeValue,u.nodeValue=""):u.nodeValue=u._stashedText||""),a&&a.nodeType===8)if(u=a.data,u==="/$"){if(l===0)break;l--}else u!=="$"&&u!=="$?"&&u!=="$~"&&u!=="$!"||l++;u=a}while(u)}function wd(l,t,u){if(t=CSS.escape(t)!==t?"r-"+btoa(t).replace(/=/g,""):t,l.style.viewTransitionName=t,u!=null&&(l.style.viewTransitionClass=u),u=getComputedStyle(l),u.display==="inline"){if(t=l.getClientRects(),t.length===1)var a=1;else for(var e=a=0;e<t.length;e++){var n=t[e];0<n.width&&0<n.height&&a++}a===1&&(l=l.style,l.display=t.length===1?"inline-block":"block",l.marginTop="-"+u.paddingTop,l.marginBottom="-"+u.paddingBottom)}}function Xd(l,t){l=l.style,t=t.style;var u=t!=null?t.hasOwnProperty("viewTransitionName")?t.viewTransitionName:t.hasOwnProperty("view-transition-name")?t["view-transition-name"]:null:null;l.viewTransitionName=u==null||typeof u=="boolean"?"":(""+u).trim(),u=t!=null?t.hasOwnProperty("viewTransitionClass")?t.viewTransitionClass:t.hasOwnProperty("view-transition-class")?t["view-transition-class"]:null:null,l.viewTransitionClass=u==null||typeof u=="boolean"?"":(""+u).trim(),l.display==="inline-block"&&(t==null?l.display=l.margin="":(u=t.display,l.display=u==null||typeof u=="boolean"?"":u,u=t.margin,u!=null?l.margin=u:(u=t.hasOwnProperty("marginTop")?t.marginTop:t["margin-top"],l.marginTop=u==null||typeof u=="boolean"?"":u,t=t.hasOwnProperty("marginBottom")?t.marginBottom:t["margin-bottom"],l.marginBottom=t==null||typeof t=="boolean"?"":t)))}function lh(l,t,u){return u=u.ownerDocument.defaultView,{rect:l,abs:t.position==="absolute"||t.position==="fixed",clip:t.clipPath!=="none"||t.overflow!=="visible"||t.filter!=="none"||t.mask!=="none"||t.mask!=="none"||t.borderRadius!=="0px",view:0<=l.bottom&&0<=l.right&&l.top<=u.innerHeight&&l.left<=u.innerWidth}}function vo(l){var t=l.getBoundingClientRect(),u=getComputedStyle(l);return lh(t,u,l)}function th(l){return l.documentElement.clientHeight}function uh(l){this.addEventListener("load",l),this.addEventListener("error",l)}function ah(l,t,u,a,e,n,c,f,i){var m=t.nodeType===9?t:t.ownerDocument;try{var g=m.startViewTransition({update:function(){var d=m.defaultView,h=d.navigation&&d.navigation.transition,_=m.fonts.status;a();var C=[];if(_==="loaded"&&(th(m),m.fonts.status==="loading"&&C.push(m.fonts.ready)),_=C.length,l!==null)for(var K=l.suspenseyImages,v=0,o=0;o<K.length;o++){var y=K[o];if(!y.complete){var T=y.getBoundingClientRect();if(0<T.bottom&&0<T.right&&T.top<d.innerHeight&&T.left<d.innerWidth){if(v+=iv(y),v>Uc){C.length=_;break}y=new Promise(uh.bind(y)),C.push(y)}}}if(0<C.length)return d=Promise.race([Promise.all(C),new Promise(function(p){return setTimeout(p,500)})]).then(e,e),(h?Promise.allSettled([h.finished,d]):d).then(n,n);if(e(),h)return h.finished.then(n,n);n()},types:u});m.__reactViewTransition=g;var E=[];return g.ready.then(function(){for(var d=m.documentElement.getAnimations({subtree:!0}),h=0;h<d.length;h++){var _=d[h],C=_.effect,K=C.pseudoElement;if(K!=null&&K.startsWith("::view-transition")){E.push(_),_=C.getKeyframes();for(var v=K=void 0,o=!0,y=0;y<_.length;y++){var T=_[y],p=T.width;if(K===void 0)K=p;else if(K!==p){o=!1;break}if(p=T.height,v===void 0)v=p;else if(v!==p){o=!1;break}delete T.width,delete T.height,T.transform==="none"&&delete T.transform}o&&K!==void 0&&v!==void 0&&(C.setKeyframes(_),o=getComputedStyle(C.target,C.pseudoElement),o.width!==K||o.height!==v)&&(o=_[0],o.width=K,o.height=v,o=_[_.length-1],o.width=K,o.height=v,C.setKeyframes(_))}}c()},function(d){m.__reactViewTransition===g&&(m.__reactViewTransition=null);try{typeof d=="object"&&d!==null&&d.name==="InvalidStateError"&&(d.message==="View transition was skipped because document visibility state is hidden."||d.message==="Skipping view transition because document visibility state has become hidden."||d.message==="Skipping view transition because viewport size changed."||d.message==="Transition was aborted because of invalid state")&&(d=null),d!==null&&i(d)}finally{a(),e(),c()}}),g.finished.finally(function(){for(var d=0;d<E.length;d++)E[d].cancel();m.__reactViewTransition===g&&(m.__reactViewTransition=null),f()}),g}catch{return a(),e(),c(),null}}function Ea(l,t){this._scope=document.documentElement,this._selector="::view-transition-"+l+"("+t+")"}Ea.prototype.animate=function(l,t){return t=typeof t=="number"?{duration:t}:j({},t),t.pseudoElement=this._selector,this._scope.animate(l,t)},Ea.prototype.getAnimations=function(){for(var l=this._scope,t=this._selector,u=l.getAnimations({subtree:!0}),a=[],e=0;e<u.length;e++){var n=u[e].effect;n!==null&&n.target===l&&n.pseudoElement===t&&a.push(u[e])}return a},Ea.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Qd(l){return{name:l,group:new Ea("group",l),imagePair:new Ea("image-pair",l),old:new Ea("old",l),new:new Ea("new",l)}}function Mt(l){this._fragmentFiber=l,this._observers=this._eventListeners=null}Mt.prototype.addEventListener=function(l,t,u){var a=null,e=null;if(!(u!=null&&typeof u!="boolean"&&(a=u.signal||null,a!==null&&a.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var n=this._eventListeners;if(Vd(n,l,t,u)===-1){var c=this,f=t;u!=null&&typeof u!="boolean"&&u.once===!0&&(f=function(i){c.removeEventListener(l,t,u),typeof t=="function"?t.call(this,i):t.handleEvent(i)}),a!==null&&(e=c.removeEventListener.bind(c,l,t,u),a.addEventListener("abort",e,{once:!0}),e=a.removeEventListener.bind(a,"abort",e)),a=ne(u),n.push({type:l,listener:t,optionsOrUseCapture:u,attachedListener:f,cleanup:e}),S(this._fragmentFiber.child,!1,eh,l,f,a)}this._eventListeners=n}};function eh(l,t,u,a){return al(l).addEventListener(t,u,a),!1}Mt.prototype.removeEventListener=function(l,t,u){var a=this._eventListeners;if(a!==null&&(t=Vd(a,l,t,u),t!==-1)){var e=a[t];u=e.attachedListener;var n=e.cleanup;e=ne(e.optionsOrUseCapture),S(this._fragmentFiber.child,!1,nh,l,u,e),a.splice(t,1),n!==null&&n()}};function nh(l,t,u,a){return al(l).removeEventListener(t,u,a),!1}function ne(l){return l!=null&&typeof l!="boolean"&&(l.once===!0||l.signal instanceof AbortSignal)?{capture:l.capture,passive:l.passive}:l}function Zd(l){return l==null?"c=0":typeof l=="boolean"?"c="+(l?"1":"0"):"c="+(l.capture?"1":"0")}function Vd(l,t,u,a){if(l.length===0)return-1;a=Zd(a);for(var e=0;e<l.length;e++){var n=l[e];if(n.type===t&&n.listener===u&&Zd(n.optionsOrUseCapture)===a)return e}return-1}Mt.prototype.dispatchEvent=function(l){var t=Y(this._fragmentFiber);if(t===null)return!0;t=al(t);var u=this._eventListeners;if(u!==null&&0<u.length||!l.bubbles){var a=t.nodeType===9?t.createComment(""):document.createTextNode("");if(u)for(var e=0;e<u.length;e++){var n=u[e];a.addEventListener(n.type,n.attachedListener,ne(n.optionsOrUseCapture))}if(t.appendChild(a),l=a.dispatchEvent(l),u)for(e=0;e<u.length;e++)n=u[e],a.removeEventListener(n.type,n.attachedListener,ne(n.optionsOrUseCapture));return t.removeChild(a),l}return t.dispatchEvent(l)},Mt.prototype.focus=function(l){S(this._fragmentFiber.child,!0,Ld,l,void 0,void 0)};function Ld(l,t){return l.tag===6?!1:(l=al(l),gh(l,t))}Mt.prototype.focusLast=function(l){var t=[];S(this._fragmentFiber.child,!0,mo,t,void 0,void 0);for(var u=t.length-1;0<=u&&!Ld(t[u],l);u--);};function mo(l,t){return t.push(l),!1}Mt.prototype.blur=function(){var l=Y(this._fragmentFiber);l!==null&&(l=al(l),l=ln(l).activeElement,l!==null&&S(this._fragmentFiber.child,!1,ch,l,void 0,void 0))};function ch(l,t){return l.tag===6?!1:(l=al(l),l===t||l.contains(t)?(t.blur(),!0):!1)}Mt.prototype.observeUsing=function(l){this._observers===null&&(this._observers=new Set),this._observers.add(l),S(this._fragmentFiber.child,!1,fh,l,void 0,void 0)};function fh(l,t){return l.tag===6||(l=al(l),t.observe(l)),!1}Mt.prototype.unobserveUsing=function(l){var t=this._observers;if(t!==null&&t.has(l)){t.delete(l),S(this._fragmentFiber.child,!1,ih,l,void 0,void 0);for(var u=t=0;u<Kt.length;u++){var a=Kt[u];a.fragmentInstance===this&&a.observer===l?l.unobserve(a.instance):Kt[t++]=a}Kt.length=t}};function ih(l,t){return l.tag===6||(l=al(l),t.unobserve(l)),!1}var Kt=[],yo=!1;function oh(l,t,u){Kt.push({fragmentInstance:l,observer:t,instance:u}),yo||(yo=!0,Sh(function(){yo=!1;var a=Kt;Kt=[];for(var e=0;e<a.length;e++){var n=a[e];n.observer.unobserve(n.instance)}}))}Mt.prototype.getClientRects=function(){var l=[];return S(this._fragmentFiber.child,!1,sh,l,void 0,void 0),l};function sh(l,t){if(l.tag===6){l=l.stateNode;var u=l.ownerDocument.createRange();u.selectNodeContents(l),t.push.apply(t,u.getClientRects())}else l=al(l),t.push.apply(t,l.getClientRects());return!1}Mt.prototype.getRootNode=function(l){var t=Y(this._fragmentFiber);return t===null?this:al(t).getRootNode(l)},Mt.prototype.compareDocumentPosition=function(l){var t=Y(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var u=[];S(this._fragmentFiber.child,!1,mo,u,void 0,void 0);var a=al(t);if(u.length===0){if(u=a,zl(this._fragmentFiber)){l:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break l}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(u=t)}t=this._fragmentFiber;var e=a=u.compareDocumentPosition(l);return u===l?e=Node.DOCUMENT_POSITION_CONTAINS:a&Node.DOCUMENT_POSITION_CONTAINED_BY&&(u=hl(t)[1],u===null?e=Node.DOCUMENT_POSITION_PRECEDING:(l=al(u).compareDocumentPosition(l),e=l===0||l&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),e|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=al(u[0]),e=al(u[u.length-1]);var n=zl(this._fragmentFiber)?t.parentElement:a;if(n==null)return Node.DOCUMENT_POSITION_DISCONNECTED;a=n.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,n=n.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY;var c=t.compareDocumentPosition(l),f=e.compareDocumentPosition(l),i=c&Node.DOCUMENT_POSITION_CONTAINED_BY||f&Node.DOCUMENT_POSITION_CONTAINED_BY;return f=a&&n&&c&Node.DOCUMENT_POSITION_FOLLOWING&&f&Node.DOCUMENT_POSITION_PRECEDING,t=a&&t===l||n&&e===l||i||f?Node.DOCUMENT_POSITION_CONTAINED_BY:!a&&t===l||!n&&e===l?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:c,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||rh(t,this._fragmentFiber,u[0],u[u.length-1],l)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function rh(l,t,u,a,e){var n=la(e);if(l&Node.DOCUMENT_POSITION_CONTAINED_BY){if(u=!!n)l:{for(;n!==null;){if(n.tag===7&&(n===t||n.alternate===t)){u=!0;break l}n=n.return}u=!1}return u}if(l&Node.DOCUMENT_POSITION_CONTAINS){if(n===null)return n=e.ownerDocument,e===n||e===n.documentElement||e===n.body;l:{for(n=t,t=Y(t);n!==null;){if(!(n.tag!==5&&n.tag!==3&&n.tag!==27||n!==t&&n.alternate!==t)){n=!0;break l}n=n.return}n=!1}return n}return l&Node.DOCUMENT_POSITION_PRECEDING?((t=!!n)&&!(t=n===u)&&(t=Ol(u,n,at),t===null?t=!1:(S(t,!0,Yl,n,u),n=xl,xl=null,t=n!==null)),t):l&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!n)&&!(t=n===a)&&(t=Ol(a,n,at),t===null?t=!1:(S(t,!0,Ll,n,a),n=xl,pl=xl=null,t=n!==null)),t):!1}function Kd(l,t){var u=l.ownerDocument.createRange();u.selectNodeContents(l),l=u.getBoundingClientRect(),window.scrollTo(window.scrollX+l.left,t?window.scrollY+l.top:window.scrollY+l.bottom-window.innerHeight)}Mt.prototype.scrollIntoView=function(l){if(typeof l=="object")throw Error(r(566));var t=[];S(this._fragmentFiber.child,!1,mo,t,void 0,void 0);var u=l!==!1;if(t.length===0){var a=hl(this._fragmentFiber);if(a=u?a[1]||a[0]||Y(this._fragmentFiber):a[0]||a[1],a===null)return;if(a.tag===6){l=al(a),Kd(l,u);return}if(a=al(a),a.nodeType!==9){if(a.nodeType===11){u="host"in a?a.host:null,u!==null&&u.scrollIntoView(l);return}a.scrollIntoView(l)}}for(a=u?t.length-1:0;a!==(u?-1:t.length);){var e=t[a];e.tag===6?(e=al(e),Kd(e,u)):al(e).scrollIntoView(l),a+=u?-1:1}};function dh(l,t){return l=al(l),Jd(l,t),!1}function Jd(l,t){l.reactFragments==null&&(l.reactFragments=new Set),l.reactFragments.add(t)}function $d(l,t){var u=t._eventListeners;if(u!==null)for(var a=0;a<u.length;a++){var e=u[a];l.addEventListener(e.type,e.attachedListener,ne(e.optionsOrUseCapture))}l.nodeType!==3&&(u=t._observers,u!==null&&u.forEach(function(n){for(var c=0,f=0;f<Kt.length;f++){var i=Kt[f];(i.fragmentInstance!==t||i.observer!==n||i.instance!==l)&&(Kt[c++]=i)}Kt.length=c,n.observe(l)}),Jd(l,t))}function vh(l,t){var u=t._eventListeners;if(u!==null)for(var a=0;a<u.length;a++){var e=u[a];l.removeEventListener(e.type,e.attachedListener,ne(e.optionsOrUseCapture))}l.nodeType!==3&&(u=t._observers,u!==null&&u.forEach(function(n){typeof n.rootMargin=="string"?oh(t,n,l):n.unobserve(l)}),l.reactFragments!=null&&l.reactFragments.delete(t))}function ho(l){var t=l.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var u=t;switch(t=t.nextSibling,u.nodeName){case"HTML":case"HEAD":case"BODY":ho(u),bn(u);continue;case"SCRIPT":case"STYLE":continue;case"LINK":if(u.rel.toLowerCase()==="stylesheet")continue}l.removeChild(u)}}function mh(l,t,u,a){for(;l.nodeType===1;){var e=u;if(l.nodeName.toLowerCase()!==t.toLowerCase()){if(!a&&(l.nodeName!=="INPUT"||l.type!=="hidden"))break}else if(a){if(!l[Se])switch(t){case"meta":if(!l.hasAttribute("itemprop"))break;return l;case"link":if(n=l.getAttribute("rel"),n==="stylesheet"&&l.hasAttribute("data-precedence"))break;if(n!==e.rel||l.getAttribute("href")!==(e.href==null||e.href===""?null:e.href)||l.getAttribute("crossorigin")!==(e.crossOrigin==null?null:e.crossOrigin)||l.getAttribute("title")!==(e.title==null?null:e.title))break;return l;case"style":if(l.hasAttribute("data-precedence"))break;return l;case"script":if(n=l.getAttribute("src"),(n!==(e.src==null?null:e.src)||l.getAttribute("type")!==(e.type==null?null:e.type)||l.getAttribute("crossorigin")!==(e.crossOrigin==null?null:e.crossOrigin))&&n&&l.hasAttribute("async")&&!l.hasAttribute("itemprop"))break;return l;default:return l}}else if(t==="input"&&l.type==="hidden"){var n=e.name==null?null:""+e.name;if(e.type==="hidden"&&l.getAttribute("name")===n)return l}else return l;if(l=jt(l.nextSibling),l===null)break}return null}function yh(l,t,u){if(t==="")return null;for(;l.nodeType!==3;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!u||(l=jt(l.nextSibling),l===null))return null;return l}function Wd(l,t){for(;l.nodeType!==8;)if((l.nodeType!==1||l.nodeName!=="INPUT"||l.type!=="hidden")&&!t||(l=jt(l.nextSibling),l===null))return null;return l}function go(l){return l.data==="$?"||l.data==="$~"}function So(l){return l.data==="$!"||l.data==="$?"&&l.ownerDocument.readyState!=="loading"}function hh(l,t){var u=l.ownerDocument;if(l.data==="$~")l._reactRetry=t;else if(l.data!=="$?"||u.readyState!=="loading")t();else{var a=function(){t(),u.removeEventListener("DOMContentLoaded",a)};u.addEventListener("DOMContentLoaded",a),l._reactRetry=a}}function jt(l){for(;l!=null;l=l.nextSibling){var t=l.nodeType;if(t===1||t===3)break;if(t===8){if(t=l.data,t==="$"||t==="$!"||t==="$?"||t==="$~"||t==="&"||t==="F!"||t==="F")break;if(t==="/$"||t==="/&")return null}}return l}var bo=null;function Fd(l){l=l.nextSibling;for(var t=0;l;){if(l.nodeType===8){var u=l.data;if(u==="/$"||u==="/&"){if(t===0)return jt(l.nextSibling);t--}else u!=="$"&&u!=="$!"&&u!=="$?"&&u!=="$~"&&u!=="&"||t++}l=l.nextSibling}return null}function kd(l){l=l.previousSibling;for(var t=0;l;){if(l.nodeType===8){var u=l.data;if(u==="$"||u==="$!"||u==="$?"||u==="$~"||u==="&"){if(t===0)return l;t--}else u!=="/$"&&u!=="/&"||t++}l=l.previousSibling}return null}function gh(l,t){function u(){a=!0}if(l.ownerDocument.activeElement===l)return!0;var a=!1;try{l.ownerDocument.addEventListener("focus",u,!0),(l.focus||HTMLElement.prototype.focus).call(l,t)}finally{l.ownerDocument.removeEventListener("focus",u,!0)}return a}function Sh(l){Bd(function(){Bd(function(t){return l(t)})})}function Id(l,t,u){switch(t=ln(u),l){case"html":if(l=t.documentElement,!l)throw Error(r(452));return l;case"head":if(l=t.head,!l)throw Error(r(453));return l;case"body":if(l=t.body,!l)throw Error(r(454));return l;default:throw Error(r(451))}}function Pd(l,t,u){for(var a in u){var e=u[a];u.hasOwnProperty(a)&&e!=null&&ml(l,t,a,null,Jy,e)}u.dangerouslySetInnerHTML!=null&&(l.textContent=""),l.onclick===Wt&&(l.onclick=null),bn(l)}function To(l){for(var t=l.attributes;t.length;)l.removeAttributeNode(t[0]);bn(l)}var Gt=new Map,lv=new Set;function tn(l){if(typeof l.getRootNode=="function"){var t=l.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return l.nodeType===9?l:l.ownerDocument}var zu=R.d;R.d={f:bh,r:Th,D:Eh,C:zh,L:_h,m:Oh,X:Nh,S:Ah,M:Dh};function bh(){var l=zu.f(),t=zc();return l||t}function Th(l){var t=Oa(l);t!==null&&t.tag===5&&t.type==="form"?u0(t):zu.r(l)}var ce=typeof document>"u"?null:document;function tv(l,t,u){var a=ce;if(a&&typeof t=="string"&&t){var e=Ut(t);e='link[rel="'+l+'"][href="'+e+'"]',typeof u=="string"&&(e+='[crossorigin="'+u+'"]'),lv.has(e)||(lv.add(e),l={rel:l,crossOrigin:u,href:t},a.querySelector(e)===null&&(t=a.createElement("link"),ut(t,"link",l),Kl(t),a.head.appendChild(t)))}}function Eh(l){zu.D(l),tv("dns-prefetch",l,null)}function zh(l,t){zu.C(l,t),tv("preconnect",l,t)}function _h(l,t,u){zu.L(l,t,u);var a=ce;if(a&&l&&t){var e='link[rel="preload"][as="'+Ut(t)+'"]';t==="image"&&u&&u.imageSrcSet?(e+='[imagesrcset="'+Ut(u.imageSrcSet)+'"]',typeof u.imageSizes=="string"&&(e+='[imagesizes="'+Ut(u.imageSizes)+'"]')):e+='[href="'+Ut(l)+'"]';var n=e;switch(t){case"style":n=fe(l);break;case"script":n=ie(l)}if(!(Gt.has(n)||(l=j({rel:"preload",href:t==="image"&&u&&u.imageSrcSet?void 0:l,as:t},u),Gt.set(n,l),a.querySelector(e)!==null||t==="style"&&a.querySelector(un(n))||t==="script"&&a.querySelector(an(n))))){var c=a.createElement("link");ut(c,"link",l),t==="style"&&(c[Sn]=!0,c.onload=c.onerror=function(){ms(c)}),Kl(c),a.head.appendChild(c)}}}function Oh(l,t){zu.m(l,t);var u=ce;if(u&&l){var a=t&&typeof t.as=="string"?t.as:"script",e='link[rel="modulepreload"][as="'+Ut(a)+'"][href="'+Ut(l)+'"]',n=e;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":n=ie(l)}if(!Gt.has(n)&&(l=j({rel:"modulepreload",href:l},t),Gt.set(n,l),u.querySelector(e)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(u.querySelector(an(n)))return}a=u.createElement("link"),ut(a,"link",l),Kl(a),u.head.appendChild(a)}}}function Ah(l,t,u){zu.S(l,t,u);var a=ce;if(a&&l){var e=Aa(a).hoistableStyles,n=fe(l);t=t||"default";var c=e.get(n);if(!c){var f={loading:0,preload:null};if(c=a.querySelector(un(n)))f.loading=5;else{l=j({rel:"stylesheet",href:l,"data-precedence":t},u),(u=Gt.get(n))&&Eo(l,u);var i=c=a.createElement("link");Kl(i),ut(i,"link",l),i._p=new Promise(function(m,g){i.onload=m,i.onerror=g}),i.addEventListener("load",function(){f.loading|=1}),i.addEventListener("error",function(){f.loading|=2}),f.loading|=4,Cc(c,t,a)}c={type:"stylesheet",instance:c,count:1,state:f},e.set(n,c)}}}function Nh(l,t){zu.X(l,t);var u=ce;if(u&&l){var a=Aa(u).hoistableScripts,e=ie(l),n=a.get(e);n||(n=u.querySelector(an(e)),n||(l=j({src:l,async:!0},t),(t=Gt.get(e))&&zo(l,t),n=u.createElement("script"),Kl(n),ut(n,"link",l),u.head.appendChild(n)),n={type:"script",instance:n,count:1,state:null},a.set(e,n))}}function Dh(l,t){zu.M(l,t);var u=ce;if(u&&l){var a=Aa(u).hoistableScripts,e=ie(l),n=a.get(e);n||(n=u.querySelector(an(e)),n||(l=j({src:l,async:!0,type:"module"},t),(t=Gt.get(e))&&zo(l,t),n=u.createElement("script"),Kl(n),ut(n,"link",l),u.head.appendChild(n)),n={type:"script",instance:n,count:1,state:null},a.set(e,n))}}function uv(l,t,u,a){var e=(e=_u.current)?tn(e):null;if(!e)throw Error(r(446));switch(l){case"meta":case"title":return null;case"style":return typeof u.precedence=="string"&&typeof u.href=="string"?(u=fe(u.href),t=Aa(e).hoistableStyles,a=t.get(u),a||(a={type:"style",instance:null,count:0,state:null},t.set(u,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(u.rel==="stylesheet"&&typeof u.href=="string"&&typeof u.precedence=="string"){l=fe(u.href);var n=Aa(e).hoistableStyles,c=n.get(l);if(c||(e=e.ownerDocument||e,c={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},n.set(l,c),(n=e.querySelector(un(l)))?n._p||(c.instance=n,c.state.loading=5):(n=Gt.get(l),n||(n={rel:"preload",as:"style",href:u.href,crossOrigin:u.crossOrigin,integrity:u.integrity,media:u.media,hrefLang:u.hrefLang,referrerPolicy:u.referrerPolicy},Gt.set(l,n)),ph(e,l,n,c.state))),t&&a===null)throw Error(r(528,""));return c}if(t&&a!==null)throw Error(r(529,""));return null;case"script":return t=u.async,u=u.src,typeof u=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(u=ie(u),t=Aa(e).hoistableScripts,a=t.get(u),a||(a={type:"script",instance:null,count:0,state:null},t.set(u,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,l))}}function fe(l){return'href="'+Ut(l)+'"'}function un(l){return'link[rel="stylesheet"]['+l+"]"}function av(l){return j({},l,{"data-precedence":l.precedence,precedence:null})}function ph(l,t,u,a){if(t=l.querySelector('link[rel="preload"][as="style"]['+t+"]")){if(t[Sn]!==!0){a.loading=1;return}}else t=l.createElement("link"),t[Sn]=!0,t.onload=t.onerror=ms.bind(null,t),ut(t,"link",u),Kl(t),l.head.appendChild(t);a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2})}function ie(l){return'[src="'+Ut(l)+'"]'}function an(l){return"script[async]"+l}function ev(l,t,u){if(t.count++,t.instance===null)switch(t.type){case"style":var a=l.querySelector('style[data-href~="'+Ut(u.href)+'"]');if(a)return t.instance=a,Kl(a),a;var e=j({},u,{"data-href":u.href,"data-precedence":u.precedence,href:null,precedence:null});return a=(l.ownerDocument||l).createElement("style"),Kl(a),ut(a,"style",e),Cc(a,u.precedence,l),t.instance=a;case"stylesheet":e=fe(u.href);var n=l.querySelector(un(e));if(n)return t.state.loading|=4,t.instance=n,Kl(n),n;a=av(u),(e=Gt.get(e))&&Eo(a,e),n=(l.ownerDocument||l).createElement("link"),Kl(n);var c=n;return c._p=new Promise(function(f,i){c.onload=f,c.onerror=i}),ut(n,"link",a),t.state.loading|=4,Cc(n,u.precedence,l),t.instance=n;case"script":return n=ie(u.src),(e=l.querySelector(an(n)))?(t.instance=e,Kl(e),e):(a=u,(e=Gt.get(n))&&(a=j({},u),zo(a,e)),l=l.ownerDocument||l,e=l.createElement("script"),Kl(e),ut(e,"link",a),l.head.appendChild(e),t.instance=e);case"void":return null;default:throw Error(r(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,Cc(a,u.precedence,l));return t.instance}function Cc(l,t,u){for(var a=u.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),e=a.length?a[a.length-1]:null,n=e,c=0;c<a.length;c++){var f=a[c];if(f.dataset.precedence===t)n=f;else if(n!==e)break}n?n.parentNode.insertBefore(l,n.nextSibling):(t=u.nodeType===9?u.head:u,t.insertBefore(l,t.firstChild))}function Eo(l,t){l.crossOrigin==null&&(l.crossOrigin=t.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=t.referrerPolicy),l.title==null&&(l.title=t.title)}function zo(l,t){l.crossOrigin==null&&(l.crossOrigin=t.crossOrigin),l.referrerPolicy==null&&(l.referrerPolicy=t.referrerPolicy),l.integrity==null&&(l.integrity=t.integrity)}var Mc=null;function nv(l,t,u){if(Mc===null){var a=new Map,e=Mc=new Map;e.set(u,a)}else e=Mc,a=e.get(u),a||(a=new Map,e.set(u,a));if(a.has(l))return a;for(a.set(l,null),u=u.getElementsByTagName(l),e=0;e<u.length;e++){var n=u[e];if(!(n[Se]||n[kl]||l==="link"&&n.getAttribute("rel")==="stylesheet")&&n.namespaceURI!=="http://www.w3.org/2000/svg"){var c=n.getAttribute(t)||"";c=l+c;var f=a.get(c);f?f.push(n):a.set(c,[n])}}return a}function _o(l,t,u){l=l.ownerDocument||l,l.head.insertBefore(u,t==="title"?l.querySelector("head > title"):null)}function Ch(l,t,u){if(u===1||t.itemProp!=null)return!1;switch(l){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(l=t.disabled,typeof t.precedence=="string"&&l==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function cv(l,t){return l==="img"&&t.src!=null&&t.src!==""&&t.onLoad==null&&t.loading!=="lazy"}function fv(l){return!(l.type==="stylesheet"&&(l.state.loading&3)===0)}function iv(l){return(l.width||100)*(l.height||100)*(typeof devicePixelRatio=="number"?devicePixelRatio:1)*.25}function ov(l,t){typeof t.decode=="function"&&(l.imgCount++,t.complete||(l.imgBytes+=iv(t),l.suspenseyImages.push(t)),l=Rh.bind(l),t.decode().then(l,l))}function Mh(l,t,u,a){if(u.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(u.state.loading&4)===0){if(u.instance===null){var e=fe(a.href),n=t.querySelector(un(e));if(n){t=n._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(l.count++,l=en.bind(l),t.then(l,l)),u.state.loading|=4,u.instance=n,Kl(n);return}n=t.ownerDocument||t,a=av(a),(e=Gt.get(e))&&Eo(a,e),n=n.createElement("link"),Kl(n);var c=n;c._p=new Promise(function(f,i){c.onload=f,c.onerror=i}),ut(n,"link",a),u.instance=n}l.stylesheets===null&&(l.stylesheets=new Map),l.stylesheets.set(u,t),(t=u.state.preload)&&(u.state.loading&3)===0&&(l.count++,u=en.bind(l),t.addEventListener("load",u),t.addEventListener("error",u))}}var Uc=0;function Uh(l,t){return l.stylesheets&&l.count===0&&Hc(l,l.stylesheets),0<l.count||0<l.imgCount?function(u){var a=setTimeout(function(){if(l.stylesheets&&Hc(l,l.stylesheets),l.unsuspend){var n=l.unsuspend;l.unsuspend=null,n()}},6e4+t);0<l.imgBytes&&Uc===0&&(Uc=62500*Wy());var e=setTimeout(function(){if(l.waitingForImages=!1,l.count===0&&(l.stylesheets&&Hc(l,l.stylesheets),l.unsuspend)){var n=l.unsuspend;l.unsuspend=null,n()}},(l.imgBytes>Uc?50:800)+t);return l.unsuspend=u,function(){l.unsuspend=null,clearTimeout(a),clearTimeout(e)}}:null}function sv(l){if(l.count===0&&(l.imgCount===0||!l.waitingForImages)){if(l.stylesheets)Hc(l,l.stylesheets);else if(l.unsuspend){var t=l.unsuspend;l.unsuspend=null,t()}}}function en(){this.count--,sv(this)}function Rh(){this.imgCount--,sv(this)}var Rc=null;function Hc(l,t){l.stylesheets=null,l.unsuspend!==null&&(l.count++,Rc=new Map,t.forEach(Hh,l),Rc=null,en.call(l))}function Hh(l,t){if(!(t.state.loading&4)){var u=Rc.get(l);if(u)var a=u.get(null);else{u=new Map,Rc.set(l,u);for(var e=l.querySelectorAll("link[data-precedence],style[data-precedence]"),n=0;n<e.length;n++){var c=e[n];(c.nodeName==="LINK"||c.getAttribute("media")!=="not all")&&(u.set(c.dataset.precedence,c),a=c)}a&&u.set(null,a)}e=t.instance,c=e.getAttribute("data-precedence"),n=u.get(c)||a,n===a&&u.set(null,e),u.set(c,e),this.count++,a=en.bind(this),e.addEventListener("load",a),e.addEventListener("error",a),n?n.parentNode.insertBefore(e,n.nextSibling):(l=l.nodeType===9?l.head:l,l.insertBefore(e,l.firstChild)),t.state.loading|=4}}var oe={$$typeof:Nl,Provider:null,Consumer:null,_currentValue:Cl,_currentValue2:Cl,_threadCount:0};function xh(l,t,u,a,e,n,c,f,i){this.tag=1,this.containerInfo=l,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=tf(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=tf(0),this.hiddenUpdates=tf(null),this.identifierPrefix=a,this.onUncaughtError=e,this.onCaughtError=n,this.onRecoverableError=c,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=i,this.transitionTypes=null,this.incompleteTransitions=new Map}function rv(l,t,u,a,e,n,c,f,i,m,g,E){return l=new xh(l,t,u,c,i,m,g,E,f),t=1,n===!0&&(t|=24),n=vt(3,null,null,t),l.current=n,n.stateNode=l,t=Bf(),t.refCount++,l.pooledCache=t,t.refCount++,n.memoizedState={element:a,isDehydrated:u,cache:t},Xf(n),l}function dv(l){return l?(l=qa,l):qa}function vv(l,t,u,a,e,n){e=dv(e),a.context===null?a.context=e:a.pendingContext=e,a=xu(t),a.payload={element:u},n=n===void 0?null:n,n!==null&&(a.callback=n),u=qu(l,a,t),u!==null&&(gt(u,l,t),qe(u,l,t))}function mv(l,t){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var u=l.retryLane;l.retryLane=u!==0&&u<t?u:t}}function Oo(l,t){mv(l,t),(l=l.alternate)&&mv(l,t)}function yv(l){if(l.tag===13||l.tag===31){var t=ea(l,67108864);t!==null&>(t,l,67108864),Oo(l,67108864)}}function hv(l){if(l.tag===13||l.tag===31){var t=Ct();t=uf(t);var u=ea(l,t);u!==null&>(u,l,t),Oo(l,t)}}var se=!0;function qh(l,t,u,a){var e=D.T;D.T=null;var n=R.p;try{R.p=2,Ao(l,t,u,a)}finally{R.p=n,D.T=e}}function Yh(l,t,u,a){var e=D.T;D.T=null;var n=R.p;try{R.p=8,Ao(l,t,u,a)}finally{R.p=n,D.T=e}}function Ao(l,t,u,a){if(se){var e=No(a);if(e===null)no(l,t,a,xc,u),Sv(l,a);else if(jh(e,l,t,u,a))a.stopPropagation();else if(Sv(l,a),t&4&&-1<Bh.indexOf(l)){for(;e!==null;){var n=Oa(e);if(n!==null)switch(n.tag){case 3:if(n=n.stateNode,n.current.memoizedState.isDehydrated){var c=Pu(n.pendingLanes);if(c!==0){var f=n;for(f.pendingLanes|=2,f.entangledLanes|=2;c;){var i=1<<31-zt(c);f.entanglements[1]|=i,c&=~i}nu(n),(sl&6)===0&&(bc=Tt()+500,ke(0))}}break;case 31:case 13:f=ea(n,2),f!==null&>(f,n,2),zc(),Oo(n,2)}if(n=No(a),n===null&&no(l,t,a,xc,u),n===e)break;e=n}e!==null&&a.stopPropagation()}else no(l,t,a,null,u)}}function No(l){return l=sf(l),Do(l)}var xc=null;function Do(l){if(xc=null,l=la(l),l!==null){var t=el(l);if(t===null)l=null;else{var u=t.tag;if(u===13){if(l=nl(t),l!==null)return l;l=null}else if(u===31){if(l=cl(t),l!==null)return l;l=null}else if(u===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;l=null}else t!==l&&(l=null)}}return xc=l,null}function gv(l){switch(l){case"beforetoggle":case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"seeked":case"submit":case"toggle":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"fullscreenerror":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 2;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"resize":case"scroll":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 8;case"message":switch(Wv()){case us:return 2;case as:return 8;case vn:case Fv:return 32;case es:return 268435456;default:return 32}default:return 32}}var po=!1,Ju=null,$u=null,Wu=null,nn=new Map,cn=new Map,Fu=[],Bh="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset".split(" ");function Sv(l,t){switch(l){case"focusin":case"focusout":Ju=null;break;case"dragenter":case"dragleave":$u=null;break;case"mouseover":case"mouseout":Wu=null;break;case"pointerover":case"pointerout":nn.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":cn.delete(t.pointerId)}}function fn(l,t,u,a,e,n){return l===null||l.nativeEvent!==n?(l={blockedOn:t,domEventName:u,eventSystemFlags:a,nativeEvent:n,targetContainers:[e]},t!==null&&(t=Oa(t),t!==null&&yv(t)),l):(l.eventSystemFlags|=a,t=l.targetContainers,e!==null&&t.indexOf(e)===-1&&t.push(e),l)}function jh(l,t,u,a,e){switch(t){case"focusin":return Ju=fn(Ju,l,t,u,a,e),!0;case"dragenter":return $u=fn($u,l,t,u,a,e),!0;case"mouseover":return Wu=fn(Wu,l,t,u,a,e),!0;case"pointerover":var n=e.pointerId;return nn.set(n,fn(nn.get(n)||null,l,t,u,a,e)),!0;case"gotpointercapture":return n=e.pointerId,cn.set(n,fn(cn.get(n)||null,l,t,u,a,e)),!0}return!1}function bv(l){var t=la(l.target);if(t!==null){var u=el(t);if(u!==null){if(t=u.tag,t===13){if(t=nl(u),t!==null){l.blockedOn=t,rs(l.priority,function(){hv(u)});return}}else if(t===31){if(t=cl(u),t!==null){l.blockedOn=t,rs(l.priority,function(){hv(u)});return}}else if(t===3&&u.stateNode.current.memoizedState.isDehydrated){l.blockedOn=u.tag===3?u.stateNode.containerInfo:null;return}}}l.blockedOn=null}function qc(l){if(l.blockedOn!==null)return!1;for(var t=l.targetContainers;0<t.length;){var u=No(l.nativeEvent);if(u===null){u=l.nativeEvent;var a=new u.constructor(u.type,u);of=a,u.target.dispatchEvent(a),of=null}else return t=Oa(u),t!==null&&yv(t),l.blockedOn=u,!1;t.shift()}return!0}function Tv(l,t,u){qc(l)&&u.delete(t)}function Gh(){po=!1,Ju!==null&&qc(Ju)&&(Ju=null),$u!==null&&qc($u)&&($u=null),Wu!==null&&qc(Wu)&&(Wu=null),nn.forEach(Tv),cn.forEach(Tv)}function Yc(l,t){l.blockedOn===t&&(l.blockedOn=null,po||(po=!0,b.unstable_scheduleCallback(b.unstable_NormalPriority,Gh)))}var Bc=null;function Ev(l){Bc!==l&&(Bc=l,b.unstable_scheduleCallback(b.unstable_NormalPriority,function(){Bc===l&&(Bc=null);for(var t=0;t<l.length;t+=3){var u=l[t],a=l[t+1],e=l[t+2];if(typeof a!="function"){if(Do(a||u)===null)continue;break}var n=Oa(u);n!==null&&(l.splice(t,3),t-=3,ii(n,{pending:!0,data:e,method:u.method,action:a},a,e))}}))}function re(l){function t(i){return Yc(i,l)}Ju!==null&&Yc(Ju,l),$u!==null&&Yc($u,l),Wu!==null&&Yc(Wu,l),nn.forEach(t),cn.forEach(t);for(var u=0;u<Fu.length;u++){var a=Fu[u];a.blockedOn===l&&(a.blockedOn=null)}for(;0<Fu.length&&(u=Fu[0],u.blockedOn===null);)bv(u),u.blockedOn===null&&Fu.shift();if(u=(l.ownerDocument||l).$$reactFormReplay,u!=null)for(a=0;a<u.length;a+=3){var e=u[a],n=u[a+1],c=e[dt]||null;if(typeof n=="function")c||Ev(u);else if(c){var f=null;if(n&&n.hasAttribute("formAction")){if(e=n,c=n[dt]||null)f=c.formAction;else if(Do(e)!==null)continue}else f=c.action;typeof f=="function"?u[a+1]=f:(u.splice(a,3),a-=3),Ev(u)}}}function zv(){function l(n){n.canIntercept&&n.info==="react-transition"&&n.intercept({handler:function(){return new Promise(function(c){return e=c})},focusReset:"manual",scroll:"manual"})}function t(){e!==null&&(e(),e=null),a||setTimeout(u,20)}function u(){if(!a&&!navigation.transition){var n=navigation.currentEntry;n&&n.url!=null&&navigation.navigate(n.url,{state:n.getState(),info:"react-transition",history:"replace"})}}if(typeof navigation=="object"){var a=!1,e=null;return navigation.addEventListener("navigate",l),navigation.addEventListener("navigatesuccess",t),navigation.addEventListener("navigateerror",t),setTimeout(u,100),function(){a=!0,navigation.removeEventListener("navigate",l),navigation.removeEventListener("navigatesuccess",t),navigation.removeEventListener("navigateerror",t),e!==null&&(e(),e=null)}}}function Co(l){this._internalRoot=l}jc.prototype.render=Co.prototype.render=function(l){var t=this._internalRoot;if(t===null)throw Error(r(409));var u=t.current,a=Ct();vv(u,a,l,t,null,null)},jc.prototype.unmount=Co.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var t=l.containerInfo;vv(l.current,2,null,l,null,null),zc(),t[_a]=null}};function jc(l){this._internalRoot=l}jc.prototype.unstable_scheduleHydration=function(l){if(l){var t=ss();l={blockedOn:null,target:l,priority:t};for(var u=0;u<Fu.length&&t!==0&&t<Fu[u].priority;u++);Fu.splice(u,0,l),u===0&&bv(l)}};var _v=O.version;if(_v!=="19.3.0")throw Error(r(527,_v,"19.3.0"));R.findDOMNode=function(l){var t=l._reactInternals;if(t===void 0)throw typeof l.render=="function"?Error(r(188)):(l=Object.keys(l).join(","),Error(r(268,l)));return l=fl(t),l=l!==null?q(l):null,l=l===null?null:l.stateNode,l};var wh={bundleType:0,version:"19.3.0",rendererPackageName:"react-dom",currentDispatcherRef:D,reconcilerVersion:"19.3.0"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Gc=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Gc.isDisabled&&Gc.supportsFiber)try{ye=Gc.inject(wh),Et=Gc}catch{}}return ve.createRoot=function(l,t){if(!X(l))throw Error(r(299));var u=!1,a="",e=d0,n=v0,c=m0;return t!=null&&(t.unstable_strictMode===!0&&(u=!0),t.identifierPrefix!==void 0&&(a=t.identifierPrefix),t.onUncaughtError!==void 0&&(e=t.onUncaughtError),t.onCaughtError!==void 0&&(n=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=rv(l,1,!1,null,null,u,a,null,e,n,c,zv),l[_a]=t.current,eo(l),new Co(t)},ve.hydrateRoot=function(l,t,u){if(!X(l))throw Error(r(299));var a=!1,e="",n=d0,c=v0,f=m0,i=null;return u!=null&&(u.unstable_strictMode===!0&&(a=!0),u.identifierPrefix!==void 0&&(e=u.identifierPrefix),u.onUncaughtError!==void 0&&(n=u.onUncaughtError),u.onCaughtError!==void 0&&(c=u.onCaughtError),u.onRecoverableError!==void 0&&(f=u.onRecoverableError),u.formState!==void 0&&(i=u.formState)),t=rv(l,1,!0,t,u??null,a,e,i,n,c,f,zv),t.context=dv(null),u=t.current,a=Ct(),a=uf(a),e=xu(a),e.callback=null,qu(u,e,a),u=a,t.current.lanes=u,ge(t,u),nu(t),l[_a]=t.current,eo(l),new jc(t)},ve.version="19.3.0",ve}var Go;function Rv(){if(Go)return Xc.exports;Go=1;function b(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(b)}catch(O){console.error(O)}}return b(),Xc.exports=Uv(),Xc.exports}var Hv=Rv(),Sl=Lc();function wo(b){if(typeof b!="string"||b.length>50)return;const O=b.trim(),A=/^(\+?[0-9 ().-]+?)(?:\s*[xX#]\s*(\d+))?$/.exec(O);if(!A||!/\d/.test(A[1]))return;const r=A[1].replace(/[^+0-9]/g,"");return{display:O,uri:`tel:${r}${A[2]?`;ext=${A[2]}`:""}`}}function Jc(b){if(!b||b.available!==!0||typeof b.token!="string"||!b.token.trim())return;const O={available:!0,token:b.token};typeof b.contact_email=="string"&&/^[A-Za-z0-9.!#$%&'*+/=?^_`{|}~-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/.test(b.contact_email)&&(O.contactEmail=b.contact_email);const A=wo(b.contact_phone);return A&&(O.contactPhone=A.display),O}function xv(b){const O=Jc({available:!0,token:b?.token,contact_email:b?.contactEmail,contact_phone:b?.contactPhone});return{email:O?.contactEmail?`mailto:${encodeURIComponent(O.contactEmail)}`:void 0,phone:wo(O?.contactPhone)?.uri}}function qv(){let b=0;const O=new Set;return{begin(){const A=b,r=new AbortController;return O.add(r),{signal:r.signal,abort:()=>r.abort(),isCurrent:()=>A===b,finish:()=>O.delete(r)}},reset(){b+=1;for(const A of O)A.abort();O.clear()}}}function Yv(b){let O="",A="message",r=[];function X(){r.length>0&&b({event:A,data:r.join(`
|
|
10
10
|
`)}),A="message",r=[]}function el(nl){if(nl===""){X();return}if(nl.startsWith(":"))return;const cl=nl.indexOf(":"),Q=cl===-1?nl:nl.slice(0,cl);let fl=cl===-1?"":nl.slice(cl+1);fl.startsWith(" ")&&(fl=fl.slice(1)),Q==="event"?A=fl:Q==="data"&&r.push(fl)}return{push(nl){O+=nl;let cl;for(;(cl=O.search(/\r\n|\n|\r/))!==-1;){const Q=O.startsWith(`\r
|
|
11
11
|
`,cl);if(!Q&&O[cl]==="\r"&&cl===O.length-1)return;const fl=O.slice(0,cl);O=O.slice(cl+(Q?2:1)),el(fl)}},flush(){O="",A="message",r=[]}}}class St extends Error{constructor(O,A,r,X){super(A),this.name="ChatError",this.code=O,this.status=r,this.retryAfterSec=X}}const Bv=3e4;function Xo(b){return`${String(b).replace(/\/+$/,"")}/api/chat`}async function Qo(b){let O=`http_${b.status}`,A=`Request failed (${b.status})`;try{const X=await b.json();X&&X.error&&(O=X.error.code||O,A=X.error.message||A)}catch{}const r=Number(b.headers&&b.headers.get&&b.headers.get("retry-after"));return new St(O,A,b.status,Number.isFinite(r)&&r>0?r:void 0)}async function jv({apiUrl:b,tenantId:O,message:A,sessionId:r,signal:X,onToken:el=()=>{},idleTimeoutMs:nl=Bv,fetchImpl:cl=(...Q)=>fetch(...Q)}){const Q=new AbortController;let fl=!1,q=null;const S=()=>{nl&&(clearTimeout(q),q=setTimeout(()=>{fl=!0,Q.abort()},nl))},Y=()=>Q.abort();if(X){if(X.aborted)throw new St("aborted","Request cancelled");X.addEventListener("abort",Y,{once:!0})}const zl=hl=>hl instanceof St?hl:fl?new St("timeout","The assistant took too long to respond"):Q.signal.aborted?new St("aborted","Request cancelled"):new St("network_error","Could not reach the support service");try{S();const hl=await cl(Xo(b),{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream, application/json"},body:JSON.stringify({tenant_id:O,message:A,session_id:r}),signal:Q.signal});if(!hl.ok)throw await Qo(hl);if(!(hl.headers.get("content-type")||"").includes("text/event-stream")||!hl.body){const j=await hl.json(),V=String(j.answer??"");V&&el(V);const Al=Jc(j.follow_up);return{answer:V,sessionId:j.session_id??r,...Al?{followUp:Al}:{}}}let al="",xl=!1,pl,Yl=null;const Ll=Yv(({event:j,data:V})=>{let Al={};try{Al=V?JSON.parse(V):{}}catch{return}if(j==="token"){const Ql=String(Al.text??"");al+=Ql,el(Ql)}else j==="error"?Yl=new St(Al.code||"stream_error",Al.message||"The assistant ran into a problem"):j==="done"&&(xl=!0,pl=Jc(Al.follow_up))}),at=hl.body.getReader(),Ol=new TextDecoder;for(;;){const{done:j,value:V}=await at.read();if(j)break;if(S(),Ll.push(Ol.decode(V,{stream:!0})),Yl)throw await at.cancel().catch(()=>{}),Yl;if(xl){await at.cancel().catch(()=>{});break}}if(Ll.push(Ol.decode()),Ll.flush(),Yl)throw Yl;if(!xl)throw new St("stream_interrupted","The response ended unexpectedly");return{answer:al,sessionId:r,...pl?{followUp:pl}:{}}}catch(hl){throw zl(hl)}finally{clearTimeout(q),X&&X.removeEventListener("abort",Y)}}async function Gv({apiUrl:b,tenantId:O,sessionId:A,followUpToken:r,name:X,email:el,signal:nl,fetchImpl:cl=(...Q)=>fetch(...Q)}){try{if(nl?.aborted)throw new St("aborted","Request cancelled");const Q=await cl(`${Xo(b)}/contact`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({tenant_id:O,session_id:A,follow_up_token:r,name:X.trim(),email:el.trim()}),signal:nl});if(!Q.ok)throw await Qo(Q);if((await Q.json()).status!=="saved")throw new St("invalid_response","Could not confirm save");return{status:"saved"}}catch(Q){throw nl?.aborted?new St("aborted","Request cancelled"):Q instanceof St?Q:new St("network_error","Could not save contact details")}}const Iu=new Map;function Zo(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`s_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,12)}`}function Vo(){try{return typeof localStorage<"u"?localStorage:null}catch{return null}}function Lo(b,O=Vo()){const A=`support_widget_session:${b}`;if(Iu.has(A))return Iu.get(A);try{const X=O?O.getItem(A):null;if(X)return Iu.set(A,X),X}catch{}if(Iu.has(A))return Iu.get(A);const r=Zo();Iu.set(A,r);try{O&&O.setItem(A,r)}catch{}return r}function wv(b,O=Vo()){const A=`support_widget_session:${b}`,r=Zo();Iu.set(A,r);try{O?.setItem(A,r)}catch{}return r}const Ko="The support assistant is temporarily unavailable. Please try again shortly.",Jo="Something went wrong. Please try again.",$o={network_error:{message:"We couldn't reach the support service. Please check your connection and try again.",retryable:!0},timeout:{message:"The assistant took too long to respond. Please try again.",retryable:!0},stream_interrupted:{message:"The connection was interrupted before the reply finished. Please try again.",retryable:!0},generation_failed:{message:"The assistant ran into a problem. Please try again.",retryable:!0},stream_error:{message:"The assistant ran into a problem. Please try again.",retryable:!0},service_unavailable:{message:Ko,retryable:!0},message_too_long:{message:"That message is too long. Please shorten it (2000 characters at most) and send it again.",retryable:!1},invalid_request:{message:"That message couldn't be sent. Please edit it and try again.",retryable:!1},unknown_tenant:{message:"The support chat isn't available on this site.",retryable:!1},origin_not_allowed:{message:"The support chat isn't available on this site.",retryable:!1}};function Wo(b){const O=b&&b.code;if(O==="rate_limited"){const r=Number(b.retryAfterSec);return{message:`You're sending messages too quickly. Please wait ${Number.isFinite(r)&&r>0?r>90?`${Math.ceil(r/60)} minutes`:`${Math.ceil(r)} seconds`:"a moment"} and try again.`,retryable:!0}}if(O&&$o[O])return $o[O];const A=Number(b&&b.status);return A>=500?{message:Ko,retryable:!0}:A>=400?{message:Jo,retryable:!1}:{message:Jo,retryable:!0}}function Xv(b){return Wo(b).message}function Qv(b){return Wo(b).retryable}const Zv=`
|
|
12
|
+
:host { all: initial; }
|
|
12
13
|
.cw-root {
|
|
13
14
|
--cw-accent: #1f6feb;
|
|
14
15
|
--cw-accent-text: #ffffff;
|
package/package.json
CHANGED