@inploi/plugin-chatbot 14.9.0 → 14.10.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.
Files changed (36) hide show
  1. package/cdn/index.js +7 -7
  2. package/cdn/style.css +1 -1
  3. package/dist/chatbot-body-b3e7212a.cjs +5 -0
  4. package/dist/chatbot-body-d3fd468f.js +4094 -0
  5. package/dist/chatbot.d.ts +6 -0
  6. package/dist/chatbot.idb.d.ts +2 -2
  7. package/dist/chatbot.resume.d.ts +15 -0
  8. package/dist/chatbot.resume.test.d.ts +1 -0
  9. package/dist/chatbot.state.d.ts +24 -406
  10. package/dist/chatbot.storage.test.d.ts +1 -0
  11. package/dist/chatbot.utils.d.ts +1 -255
  12. package/dist/components/chat-input/chat-input.address.d.ts +1 -14
  13. package/dist/components/chat-input/chat-input.boolean.d.ts +1 -13
  14. package/dist/components/chat-input/chat-input.d.ts +1 -12
  15. package/dist/components/chat-input/chat-input.file.d.ts +1 -12
  16. package/dist/components/chat-input/chat-input.multiple-choice.d.ts +1 -14
  17. package/dist/components/chat-input/chat-input.number.d.ts +1 -14
  18. package/dist/components/chat-input/chat-input.phone-number.d.ts +1 -17
  19. package/dist/components/chat-input/chat-input.submit.d.ts +1 -10
  20. package/dist/components/chat-input/chat-input.text.d.ts +1 -16
  21. package/dist/components/chatbot-body.lifecycle.test.d.ts +1 -0
  22. package/dist/components/message.link.d.ts +1 -1
  23. package/dist/components/useChatService.d.ts +1 -1
  24. package/dist/components/useChatService.test.d.ts +1 -0
  25. package/dist/i18n.d.ts +42 -0
  26. package/dist/index-4aad840b.cjs +5 -0
  27. package/dist/{index-75330fed.js → index-b8dab3ec.js} +1184 -1122
  28. package/dist/plugin-chatbot.cjs +1 -1
  29. package/dist/plugin-chatbot.js +1 -1
  30. package/dist/style/tokens.d.ts +4 -4
  31. package/dist/style.css +1 -1
  32. package/package.json +4 -4
  33. package/dist/chatbot-body-45ccac19.js +0 -4695
  34. package/dist/chatbot-body-b6a4eef8.cjs +0 -5
  35. package/dist/index-47f31542.cjs +0 -5
  36. package/dist/interpreter.d.ts +0 -67
@@ -0,0 +1,4094 @@
1
+ import { a as Ar, p as ht, D as Ft, c as qe, d as Er, I as Fr, i as hn, S as mn, N as yn, T as Vr, Z as gn, X as Mr, W as bn, C as vn, r as xn, m as wn, k as _n, U as Ht, V as Jt, h as kn, b as Zt, f as Cn, g as Lr, x as Sn, v as In, w as An, y as En, s as K, u as ee, o as u, e as Ke, j as mt, l as ve, _ as he, n as Ne, q as Ae, t as we, L as Rt, F as Fn, z as Nr, A as Rr, B as Vn, E as Ge, G as Xt, H as re, J as ie, M as Mn, K as Ln, O as Nn, P as Rn, Q as Dr, R as Dn } from "./index-b8dab3ec.js";
2
+ import { isApiErrorWithData as Tn, isSdkError as On, ApiError as Bn } from "@inploi/sdk";
3
+ var jn = "9.8.0", Tr = `https://sdk.inploi.com/@inploi/flows@${jn}/cdn/captcha/index.html`, Pn = new URL(Tr).origin, Yt = 3e4, qn = 5 * 6e4, $n = (e) => typeof e == "object" && e !== null && e.source === "inploi-captcha", kt = /* @__PURE__ */ new WeakMap(), Un = (e) => {
4
+ let r = kt.get(e);
5
+ return r || (r = e.fetch("/flow/captcha").then((t) => {
6
+ let n = t == null ? void 0 : t.site_key;
7
+ return typeof n == "string" && n !== "" ? n : void 0;
8
+ }).catch((t) => {
9
+ throw kt.delete(e), t;
10
+ }), kt.set(e, r)), r;
11
+ }, Wn = (e, r = {}) => new Promise((t, n) => {
12
+ let { signal: s, container: i = null, theme: a, onInteractive: o } = r instanceof AbortSignal ? { signal: r } : r, c = !1, f = () => {
13
+ }, g = (I) => {
14
+ c || (c = !0, clearTimeout(m), s == null || s.removeEventListener("abort", h), f(), I());
15
+ }, b = (I) => g(() => n(new Error(I))), h = () => b("Captcha aborted"), m, k = (I) => {
16
+ clearTimeout(m), m = setTimeout(() => b("Captcha timed out"), I);
17
+ };
18
+ if (k(Yt), s == null ? void 0 : s.aborted)
19
+ return h();
20
+ s == null || s.addEventListener("abort", h), (async () => {
21
+ let I = await Un(e);
22
+ if (I === void 0)
23
+ return g(() => t(void 0));
24
+ if (c)
25
+ return;
26
+ let C = document.createElement("iframe");
27
+ C.src = `${Tr}?${new URLSearchParams({ sitekey: I, origin: window.location.origin, ...a && { theme: a } }).toString()}`, C.title = "Cloudflare security check", C.style.cssText = `display:block;border:0;width:${i ? "100%" : "300px"};height:0;color-scheme:normal`, i ? i.appendChild(C) : (C.style.cssText += ";position:fixed;bottom:16px;right:16px;z-index:2147483647", document.body.appendChild(C));
28
+ let x = !1, y = (F) => {
29
+ if (!C.contentWindow || F.source !== C.contentWindow || F.origin !== Pn || !$n(F.data))
30
+ return;
31
+ let N = F.data;
32
+ switch (N.type) {
33
+ case "token":
34
+ return g(() => t(N.token));
35
+ case "resize":
36
+ C.style.height = `${Math.max(0, Math.ceil(N.height))}px`;
37
+ return;
38
+ case "before-interactive":
39
+ return x = !0, k(qn), o == null ? void 0 : o();
40
+ case "after-interactive":
41
+ return x = !1, k(Yt);
42
+ case "error":
43
+ !x && !N.interactive && b("Captcha failed");
44
+ return;
45
+ case "expired":
46
+ return b("Captcha expired");
47
+ case "timeout":
48
+ return b("Captcha timed out");
49
+ }
50
+ };
51
+ window.addEventListener("message", y), f = () => {
52
+ window.removeEventListener("message", y), C.remove();
53
+ };
54
+ })().catch((I) => g(() => n(I)));
55
+ }), Qt = ({ condition: e, context: r, submissions: t, ifBlock: n }) => {
56
+ let [s, ...i] = e.compareKey.split(".");
57
+ if (!s)
58
+ return !1;
59
+ let a = Ar({ context: r, key: s, path: i, submissions: t });
60
+ if (!a)
61
+ return !1;
62
+ switch (a.type) {
63
+ case "address": {
64
+ let o = Ft(a.value, i);
65
+ switch (e.compare) {
66
+ case "equals":
67
+ return o === e.compareValue;
68
+ case "contains":
69
+ return typeof o != "string" ? !1 : o.includes(e.compareValue);
70
+ case "notEquals":
71
+ return o !== e.compareValue;
72
+ case "notContains":
73
+ return typeof o != "string" ? !0 : !o.includes(e.compareValue);
74
+ }
75
+ break;
76
+ }
77
+ case "integration": {
78
+ if (typeof a.value != "object" || Array.isArray(a.value))
79
+ return !1;
80
+ let o = Ft(a.value, i), c = { ...n, data: { compareKey: "_temp", compare: e.compare, compareValue: e.compareValue } };
81
+ switch (typeof o) {
82
+ case "boolean":
83
+ return nt(c, { submissions: { _temp: { value: o, type: "boolean" } }, context: r });
84
+ case "string":
85
+ return nt(c, { submissions: { _temp: { value: o, type: "string" } }, context: r });
86
+ case "number":
87
+ return nt(c, { submissions: { _temp: { value: o, type: "number" } }, context: r });
88
+ case "object":
89
+ return Array.isArray(o) && o.every((f) => typeof f == "string") ? nt(c, { submissions: { _temp: { value: o, type: "enum" } }, context: r }) : !1;
90
+ }
91
+ break;
92
+ }
93
+ case "boolean": {
94
+ let o = e.compareValue === "true";
95
+ switch (e.compare) {
96
+ case "equals":
97
+ return a.value === o;
98
+ case "notEquals":
99
+ return a.value !== o;
100
+ }
101
+ break;
102
+ }
103
+ case "phone":
104
+ case "string": {
105
+ let o = a.type === "phone" ? ht(a.value) : a.value;
106
+ switch (e.compare) {
107
+ case "equals":
108
+ return o === e.compareValue;
109
+ case "contains":
110
+ return o ? o.includes(e.compareValue) : !1;
111
+ case "notEquals":
112
+ return o !== e.compareValue;
113
+ case "notContains":
114
+ return o ? !o.includes(e.compareValue) : !0;
115
+ }
116
+ break;
117
+ }
118
+ case "number": {
119
+ try {
120
+ let o = Number(e.compareValue);
121
+ switch (e.compare) {
122
+ case "equals":
123
+ return a.value === o;
124
+ case "notEquals":
125
+ return a.value !== o;
126
+ case "greaterThan":
127
+ return a.value > o;
128
+ case "greaterThanOrEqualTo":
129
+ return a.value >= o;
130
+ case "lessThan":
131
+ return a.value < o;
132
+ case "lessThanOrEqualTo":
133
+ return a.value <= o;
134
+ }
135
+ } catch {
136
+ return console.error(`Failed to parse number in if-block ${n.id}`, a.value), !1;
137
+ }
138
+ break;
139
+ }
140
+ case "enum":
141
+ switch (e.compare) {
142
+ case "equals":
143
+ return a.value.length === 1 && a.value[0] === e.compareValue;
144
+ case "notEquals":
145
+ return a.value.length === 1 && a.value[0] !== e.compareValue;
146
+ case "contains":
147
+ return a.value.includes(e.compareValue);
148
+ case "notContains":
149
+ return !a.value.includes(e.compareValue);
150
+ }
151
+ break;
152
+ }
153
+ }, nt = (e, { context: r, submissions: t }) => {
154
+ let n = "combinator" in e.data ? e.data.conditions : [e.data];
155
+ if (("combinator" in e.data ? e.data.combinator : "and") === "or") {
156
+ for (let s of n)
157
+ if (Qt({ condition: s, context: r, submissions: t, ifBlock: e }))
158
+ return !0;
159
+ return !1;
160
+ } else {
161
+ for (let s of n)
162
+ if (!Qt({ condition: s, context: r, submissions: t, ifBlock: e }))
163
+ return !1;
164
+ return !0;
165
+ }
166
+ }, zn = /{{\s*([^}]+?)\s*(?:\|\s*([^}]+?)\s*)?}}/g, Kn = (e, { context: r, submissions: t }) => e.replace(zn, (n, s, i = "") => {
167
+ let [a, ...o] = s.trim().split("."), c = Ar({ key: a, path: o, submissions: t, context: r });
168
+ if (!c)
169
+ return i;
170
+ switch (c.type) {
171
+ case "boolean":
172
+ return c.value === !0 ? "true" : "false";
173
+ case "file":
174
+ return c.value.map((f) => `${f.name} (${qe(f.sizeKb)})`).join(", ");
175
+ case "enum":
176
+ return c.value.join(", ");
177
+ case "address":
178
+ return Object.values(c.value).filter((f) => f && f.trim().length > 0).join(", ");
179
+ case "number":
180
+ case "string":
181
+ return c.value ? c.value.toString() : i;
182
+ case "phone":
183
+ return ht(c.value);
184
+ case "integration": {
185
+ if (typeof c.value != "object" || Array.isArray(c.value))
186
+ break;
187
+ let f = Ft(c.value, o);
188
+ switch (typeof f) {
189
+ case "boolean":
190
+ return f === !0 ? "true" : "false";
191
+ case "string":
192
+ return f;
193
+ case "number":
194
+ return f.toString();
195
+ case "object":
196
+ if (Array.isArray(f) && f.every((g) => typeof g == "string"))
197
+ return f.join(", ");
198
+ }
199
+ break;
200
+ }
201
+ }
202
+ return i;
203
+ }), Or = (e) => {
204
+ let r = e.find((t) => t.isHead);
205
+ if (!r)
206
+ throw new Error("No head node found");
207
+ return r;
208
+ }, Dt = (e) => {
209
+ var r, t;
210
+ if (!(e.data.isFinished || (r = e.data.startedWriteNodeIds) != null && r.length))
211
+ return (t = [...e.data.messages].reverse().find((n) => n.groupId && e.nodes.some((s) => s.id === n.groupId && s.type.startsWith("question-")) && (n.type === "system" || "author" in n && n.author === "user"))) == null ? void 0 : t.groupId;
212
+ }, Vt = (e) => Array.isArray(e) ? e.map(Vt) : e !== null && typeof e == "object" ? Object.fromEntries(Object.entries(e).sort(([r], [t]) => r.localeCompare(t)).map(([r, t]) => [r, Vt(t)])) : typeof e == "function" ? void 0 : e;
213
+ async function Gn(e, r, t, n) {
214
+ var s;
215
+ let i = new TextEncoder().encode(JSON.stringify(Vt(t))), a = await crypto.subtle.digest("SHA-256", i);
216
+ if (n != null && n.aborted)
217
+ return;
218
+ let o = Array.from(new Uint8Array(a), (b) => b.toString(16).padStart(2, "0")).join(""), c = (s = e.data).preApplyFingerprints ?? (s.preApplyFingerprints = []);
219
+ if (c.includes(o))
220
+ return;
221
+ c.push(o);
222
+ let f = new AbortController(), g = setTimeout(() => f.abort(), 5e3);
223
+ r.fetch("/flow/pre-apply", { method: "POST", signal: f.signal, body: JSON.stringify(t) }).catch(() => {
224
+ let b = c.indexOf(o);
225
+ b !== -1 && c.splice(b, 1);
226
+ }).finally(() => {
227
+ clearTimeout(g);
228
+ });
229
+ }
230
+ var Br = ({ context: e, submissions: r }) => ({ context: e, submissions: r ?? {} }), fe = (e, r) => Kn(e, Br(r)), Hn = (e, r) => nt(e, Br(r)), jr = ({ node: e, nodes: r, stopWhen: t }) => {
231
+ if ((t == null ? void 0 : t(e)) === !0)
232
+ return e;
233
+ let n = e.nextId ? r.find((s) => s.id === e.nextId) : void 0;
234
+ if (n)
235
+ return jr({ node: n, nodes: r, stopWhen: t });
236
+ }, Jn = ({ childNode: e, nodes: r }) => {
237
+ let t = r.filter((n) => n.type === "if-block").find((n) => {
238
+ if (!n.branchId)
239
+ return !1;
240
+ let s = r.find((a) => a.id === n.branchId);
241
+ if (!s)
242
+ return !1;
243
+ let i = jr({ node: s, nodes: r, stopWhen: (a) => a.id === e.id });
244
+ return !(!i || i.id !== e.id);
245
+ });
246
+ if (t != null && t.nextId)
247
+ return r.find((n) => n.id === t.nextId);
248
+ }, Zn = 3, Xn = ({ flow: e, analytics: r, logger: t, talentBankClient: n, context: s, apiClient: i, getSubmissions: a, getApplicationRecovery: o, setApplicationRecovery: c, chatService: f, persistWriteBarrier: g, onSubmitNetworkError: b, closedRoleBehaviour: h, dateEchoLocale: m, onFlowEnd: k, onInterpret: I, forceSubmitConfirmation: C, t: x }) => {
249
+ var y;
250
+ let F = new AbortController(), N = { submitAccepted: !1 };
251
+ (y = e.data).startedWriteNodeIds ?? (y.startedWriteNodeIds = e.nodes.flatMap((R) => {
252
+ var q, P;
253
+ if (R.type !== "integration-application-submit" || !e.data.nodeHistory.includes(R.id))
254
+ return [];
255
+ let O = R.data.key ? (q = a()) == null ? void 0 : q[R.data.key] : void 0;
256
+ return (O == null ? void 0 : O.type) === "integration" && ((P = Er(O.value)) == null ? void 0 : P.verdict) === "not_submitted" ? [] : [R.id];
257
+ }));
258
+ let V = { ...r.service, log: (R) => r.service.log({ ...R, customProperties: { ...R.customProperties, ...r.customProperties } }) }, T = async (R, O) => {
259
+ let q = F.signal;
260
+ if (q.aborted)
261
+ return;
262
+ let P = a(), H = o(), M = (H == null ? void 0 : H.submitNodeId) === R.id ? e.nodes.find((A) => {
263
+ var B;
264
+ return A.id === H.fileQuestionNodeId && A.type === "question-file" && ((B = P == null ? void 0 : P[A.data.key]) == null ? void 0 : B.type) !== "file";
265
+ }) : void 0;
266
+ if (M)
267
+ return T(M, O);
268
+ I == null || I(R, O);
269
+ try {
270
+ await Yn({ flow: e, analytics: V, logger: t, talentBankClient: n, apiClient: i, context: s, node: R, submissions: P, applicationRecovery: H, setApplicationRecovery: async (A) => {
271
+ if (!q.aborted)
272
+ try {
273
+ await c(A);
274
+ } catch (B) {
275
+ t.error("Failed to persist application recovery", B);
276
+ }
277
+ }, forceSubmitConfirmation: C || (H == null ? void 0 : H.submitNodeId) === R.id, run: N, persistWriteBarrier: g, onSubmitNetworkError: b, closedRoleBehaviour: h, dateEchoLocale: m, signal: q, t: x, chat: { sendMessage: async (A) => f.send({ groupId: R.id, message: A, signal: q }), userInput: async (A) => f.input({ input: A, signal: q }), setSubmission: (A, B) => {
278
+ q.aborted || f.setSubmission(A, B);
279
+ }, captcha: f.captcha }, next: (A) => {
280
+ if (q.aborted)
281
+ return;
282
+ let B = (H == null ? void 0 : H.fileQuestionNodeId) === R.id ? H.submitNodeId : A, $ = B ? e.nodes.find((U) => U.id === B) : Jn({ childNode: R, nodes: e.nodes });
283
+ return $ ? T($, R) : k == null ? void 0 : k(R);
284
+ }, end: () => {
285
+ q.aborted || (k == null || k(R));
286
+ } });
287
+ } catch (A) {
288
+ if (A instanceof Fr)
289
+ return;
290
+ throw A;
291
+ }
292
+ };
293
+ return { interpret: async (R) => {
294
+ let O = e.nodes.find((q) => q.id === R) ?? Or(e.nodes);
295
+ return T(O);
296
+ }, undo: (R) => {
297
+ var B;
298
+ if (delete e.data.reviewReplay, ((B = e.data.startedWriteNodeIds) == null ? void 0 : B.length) || e.data.isFinished)
299
+ return { removed: 0 };
300
+ let O = Dt(e), q = O ? R.lastIndexOf(O) : -1, P = e.nodes.find(($) => $.id === O);
301
+ if (q === -1 || !P)
302
+ return { removed: 0 };
303
+ let H = e.nodes.find(($) => $.id === R[R.length - 1]);
304
+ F.abort();
305
+ let M = R.splice(q);
306
+ e.data.messages = e.data.messages.filter(($) => !$.groupId || !M.includes($.groupId)), e.data.currentInput = null;
307
+ let A = a();
308
+ for (let $ of M.slice(1)) {
309
+ let U = e.nodes.find((j) => j.id === $);
310
+ if (!(!U || !A || U.id === O) && ("key" in U.data && U.data.key && delete A[U.data.key], "keys" in U.data))
311
+ for (let j of Object.values(U.data.keys))
312
+ typeof j == "string" && delete A[j];
313
+ }
314
+ return F = new AbortController(), T(P, H), { removed: M.length };
315
+ }, abort: () => {
316
+ F.abort();
317
+ } };
318
+ };
319
+ async function Yn(e) {
320
+ let r = e.node;
321
+ switch (r.type) {
322
+ case "flow-section":
323
+ return await e.chat.sendMessage({ type: "system", variant: "info", text: r.data.title }), e.next(r.nextId);
324
+ case "pre-apply-result":
325
+ return bs({ ...e, node: r });
326
+ case "text":
327
+ return ls({ ...e, node: r });
328
+ case "image":
329
+ return us({ ...e, node: r });
330
+ case "question-text":
331
+ return cs({ ...e, node: r });
332
+ case "question-enum":
333
+ return ps({ ...e, node: r });
334
+ case "question-number":
335
+ return ds({ ...e, node: r });
336
+ case "question-phone":
337
+ return fs({ ...e, node: r });
338
+ case "question-boolean":
339
+ return hs({ ...e, node: r });
340
+ case "question-file":
341
+ return ys({ ...e, node: r });
342
+ case "question-address":
343
+ return ms({ ...e, node: r });
344
+ case "end-flow":
345
+ return gs({ ...e, node: r });
346
+ case "if-block":
347
+ return os({ ...e, node: r });
348
+ case "jump":
349
+ return ts({ ...e, node: r });
350
+ case "link":
351
+ return is({ ...e, node: r });
352
+ case "integration-application-submit":
353
+ return as({ ...e, node: r });
354
+ case "add-submission":
355
+ return rs({ ...e, node: r });
356
+ case "integration-workflow-get":
357
+ throw Error("Workflow should be unreachable");
358
+ case "check-duplicate":
359
+ return es({ ...e, node: r });
360
+ case "feedback":
361
+ return Qn({ ...e, node: r });
362
+ default:
363
+ throw new Error(`Unknown node: ${JSON.stringify(r)}`);
364
+ }
365
+ }
366
+ async function Qn({ next: e, node: r }) {
367
+ e(r.nextId);
368
+ }
369
+ async function es({ next: e, node: r, talentBankClient: t, submissions: n, flow: s, logger: i, chat: a }) {
370
+ var c;
371
+ let o = { isDuplicate: !1 };
372
+ if (n && t) {
373
+ let f = r.data.scope === "job" ? (c = s.job) == null ? void 0 : c.id : void 0;
374
+ if (r.data.scope === "company" || f != null)
375
+ try {
376
+ o = await t.checkDuplicate({ email: hn({ key: r.data.email, submissions: n }).toString(), jobId: f, scope: r.data.scope });
377
+ } catch (g) {
378
+ i.error("[check-duplicate]", g);
379
+ }
380
+ }
381
+ a.setSubmission(r.data.key, { type: "integration", value: o }), e(r.nextId);
382
+ }
383
+ async function ts({ next: e, node: r }) {
384
+ e(r.data.targetId);
385
+ }
386
+ async function rs({ next: e, node: r, logger: t, submissions: n, context: s }) {
387
+ if (!n) {
388
+ t.error("Submissions not found");
389
+ return;
390
+ }
391
+ n[r.data.key] = { type: "string", value: fe(r.data.value, { submissions: n, context: s }) }, e(r.nextId);
392
+ }
393
+ var ns = 5e3, ss = (e, r, t) => {
394
+ let { waitMs: n, throttles: s, maintenance: i } = En(r == null ? void 0 : r.throttles, t);
395
+ return { key: e, until: Date.now() + n, ...s !== void 0 && { throttles: s }, ...i && { maintenance: i } };
396
+ };
397
+ async function as({ chat: e, next: r, end: t, node: n, logger: s, apiClient: i, submissions: a, analytics: o, flow: c, applicationRecovery: f, setApplicationRecovery: g, forceSubmitConfirmation: b, run: h, persistWriteBarrier: m, signal: k, onSubmitNetworkError: I, closedRoleBehaviour: C, t: x }) {
398
+ var T;
399
+ if ((T = c.data.startedWriteNodeIds) != null && T.includes(n.id) && (f == null ? void 0 : f.submitNodeId) !== n.id)
400
+ return await e.sendMessage({ type: "system", variant: "warning", text: x("submission_unknown") }), t();
401
+ let y = c.job ? `${n.id}@${c.job.id_type}:${c.job.id}` : n.id, F = 0, N = h.submitAccepted && n.data.skipConfirmation === !0 && (f == null ? void 0 : f.submitNodeId) !== n.id, V = async (R) => {
402
+ var Te, Ye, Oe, Be, ut, Qe, ct;
403
+ let O = ((Te = c.data.submitCooldown) == null ? void 0 : Te.key) === y ? c.data.submitCooldown : void 0;
404
+ O && (O.until = Math.min(O.until, Date.now() + (O.maintenance ? gn : O.throttles ? Mr : bn)));
405
+ let q = O == null ? void 0 : O.until;
406
+ (c.data.reviewRequiresSend === !0 && !N || R !== !0 || q !== void 0 && q > Date.now()) && await e.userInput({ type: "submit", key: void 0, config: { label: n.data.submitLabel, ...q !== void 0 && { availableAt: q } } }), N = !1;
407
+ let P;
408
+ if (n.data.captcha) {
409
+ let L = e.captcha, Ve = !0;
410
+ try {
411
+ P = await Wn(i, { signal: k, container: (L == null ? void 0 : L.container()) ?? null, theme: L == null ? void 0 : L.theme, onInteractive: () => {
412
+ e.sendMessage({ type: "text", author: "bot", text: x("captcha_check") }).catch(() => {
413
+ }).then(() => {
414
+ Ve && (L == null || L.reveal(!0));
415
+ });
416
+ } });
417
+ } catch (et) {
418
+ if (s.error("Captcha check failed", et), k.aborted)
419
+ return;
420
+ } finally {
421
+ Ve = !1, L == null || L.reveal(!1);
422
+ }
423
+ }
424
+ await e.sendMessage({ type: "loading", text: x("submitting") });
425
+ let { anonymous_id: H, session_id: M } = o.getSessionInfo();
426
+ if (k.aborted)
427
+ return;
428
+ let A = ((Ye = c.data.startedWriteNodeIds) == null ? void 0 : Ye.includes(n.id)) === !0;
429
+ if ((f == null ? void 0 : f.submitNodeId) === n.id && await g(void 0), A || (c.data.startedWriteNodeIds = [...c.data.startedWriteNodeIds ?? [], n.id]), await m().catch((L) => s.error("Failed to persist application write barrier", L)), k.aborted)
430
+ return;
431
+ let B, $ = setTimeout(() => {
432
+ B = (async () => {
433
+ await e.sendMessage({ type: "text", author: "bot", text: x("submission_still_working") }), await e.sendMessage({ type: "loading", text: x("submitting") });
434
+ })().catch((L) => s.error("Failed to send submission progress message", L));
435
+ }, ns), U, j = await i.fetch("/flow/submit", { method: "POST", body: JSON.stringify({ log_submit: !1, integration_id: n.data.integrationId, anonymous_id: H, session_id: M, job: c.job, flow_build: c.build, ...P !== void 0 && { captcha_token: P }, submissions: vn(c.nodes, xn(a || {}, n.data.submitKeys)), pre_apply: Vr(c.nodes, a || {}, c.data.flowSessionId) }) }).catch((L) => (U = L, Tn(L) ? L.data : L));
436
+ if (clearTimeout($), await B, k.aborted)
437
+ return;
438
+ if (U !== void 0 && !On(U) && I)
439
+ return await I(U, k), V(!0);
440
+ n.data.key && e.setSubmission(n.data.key, { type: "integration", value: j });
441
+ let D = Er(j, U instanceof Bn ? U.status : void 0), le = c.data.failedAttemptAt, ue = le == null ? void 0 : le[y];
442
+ le && ue !== void 0 && ue > Date.now() && (ue = le[y] = Date.now());
443
+ let Je = ue !== void 0 && Date.now() - ue < wn || ((Oe = c.data.unconfirmedAttemptKeys) == null ? void 0 : Oe.includes(y)) === !0, _e = _n(j);
444
+ _e && o.log({ event: "FLOW_SUBMIT", properties: { flow_id: c.id, flow_version: c.version, flow_session_id: c.data.flowSessionId, flow_build: c.build, service: _e.service, response: _e.response, flow_type: "CHATBOT_DRAWER", job: c.job, ...(D == null ? void 0 : D.outcome) === "duplicate" && { outcome: Je ? "duplicate_after_own_attempt" : "duplicate" }, ..._e.outcome && { outcome: _e.outcome } } });
445
+ let lt = Ht(j) || (j == null ? void 0 : j.success) === !0;
446
+ if ((lt || Jt(j)) && (h.submitAccepted = !0), lt && ((Be = c.data.submitCooldown) == null ? void 0 : Be.throttles) !== void 0 && (delete c.data.submitCooldown.throttles, await m().catch((L) => s.error("Failed to persist submit cooldown reset", L))), Ht(j)) {
447
+ let { redirect_url: L, message: Ve, button_text: et } = j.integration_response.data;
448
+ await e.sendMessage({ type: "text", author: "bot", text: Ve ?? x("submission_redirect_message") });
449
+ try {
450
+ let ke = new URL(L);
451
+ H && !ke.searchParams.has("anonymous_id") && ke.searchParams.set("anonymous_id", H), await e.sendMessage({ type: "link", href: ke.toString(), text: et ?? x("complete_submission"), onClick: () => {
452
+ if (!M) {
453
+ s.error("session_id not set, cannot log FLOW_REDIRECT event");
454
+ return;
455
+ }
456
+ o.log({ event: "FLOW_REDIRECT", properties: { flow_build: c.build, flow_id: c.id, flow_session_id: M, flow_version: c.version, href: ke.toString(), job: c.job } });
457
+ } });
458
+ } catch (ke) {
459
+ s.error(`Invalid redirect URL: ${L}`, ke), e.sendMessage({ type: "system", variant: "error", text: x("redirect_url_error") });
460
+ }
461
+ return r(n.nextId);
462
+ }
463
+ let Ze = Jt(j);
464
+ if (Ze)
465
+ return await e.sendMessage({ type: "system", variant: "success", text: Ze.message ?? x("submission_pending") }), r(n.nextId);
466
+ if ((j == null ? void 0 : j.success) === !0)
467
+ return n.data.skipConfirmation !== !0 && await e.sendMessage({ type: "system", variant: "success", text: x("submission_completed") }), r(n.nextId);
468
+ let Xe = kn(D), Fe = Xe !== void 0 && ((ut = a == null ? void 0 : a[Xe]) == null ? void 0 : ut.type) === "file" ? Xe : void 0, De = Fe === void 0 ? void 0 : c.nodes.find((L) => L.type === "question-file" && L.data.key === Fe);
469
+ if (!De && !(C === "terminal" && (D == null ? void 0 : D.outcome) === "closed") && !Zt(D) && (c.data.submitCooldown = ss(y, O, D)), (D == null ? void 0 : D.outcome) !== "duplicate" && (c.data.failedAttemptAt = { ...c.data.failedAttemptAt, [y]: Date.now() }, (Qe = c.data.unconfirmedAttemptKeys) != null && Qe.includes(y) && (c.data.unconfirmedAttemptKeys = c.data.unconfirmedAttemptKeys.filter((L) => L !== y))), (D == null ? void 0 : D.verdict) === "not_submitted" || (D == null ? void 0 : D.outcome) === "duplicate" || (D == null ? void 0 : D.outcome) === "closed" ? (A || (c.data.startedWriteNodeIds = (ct = c.data.startedWriteNodeIds) == null ? void 0 : ct.filter((L) => L !== n.id)), (f == null ? void 0 : f.submitNodeId) === n.id && await g(f), await m().catch((L) => s.error("Failed to persist application write barrier release", L))) : await m().catch((L) => s.error("Failed to persist submit cooldown", L)), D) {
470
+ if (s.error(U ?? D.message), De && Fe !== void 0)
471
+ return e.setSubmission(Fe, null), await g({ fileQuestionNodeId: De.id, submitNodeId: n.id }), await e.sendMessage({ type: "system", variant: "error", text: x("submission_unreadable_document") }), r(De.id);
472
+ if (D.outcome === "duplicate")
473
+ return await e.sendMessage({ type: "system", variant: "info", text: x(Je ? "submission_duplicate_earlier_attempt" : "submission_duplicate") }), V(!1);
474
+ if (D.outcome === "closed")
475
+ return await e.sendMessage({ type: "system", variant: "info", text: x("submission_closed") }), C === "terminal" ? (delete c.data.submitCooldown, t()) : V(!1);
476
+ let L = Cn(D);
477
+ return L ? (await e.sendMessage({ type: "system", variant: "warning", text: L.until === void 0 ? x("submission_provider_maintenance_later") : x("submission_provider_maintenance", { time: Lr(L.until, void 0) }) }), V(!1)) : D.outcome === "unknown" ? (await e.sendMessage({ type: "system", variant: "warning", text: x(Sn(D) ? "submission_unknown_do_not_resubmit" : "submission_unknown") }), V(!1)) : Zt(D) ? In(j) ? (await e.sendMessage({ type: "text", author: "bot", text: D.message }), V(!1)) : (F === 0 && await e.sendMessage({ type: "system", variant: "warning", text: x("captcha_failed") }), F++, V(F <= Zn)) : An(D) ? (await e.sendMessage({ type: "system", variant: "error", text: x("submission_retryable") }), V(!1)) : (await e.sendMessage({ type: "system", variant: "error", text: x("submission_failed") }), t());
478
+ }
479
+ return s.error(U ?? j), await e.sendMessage({ type: "system", variant: "error", text: x("submission_failed") }), t();
480
+ };
481
+ await V(b === !0 && !N ? !1 : n.data.skipConfirmation);
482
+ }
483
+ async function is({ chat: e, next: r, node: t, submissions: n, context: s }) {
484
+ await e.sendMessage({ type: "link", href: fe(t.data.href, { submissions: n, context: s }), text: fe(t.data.cta, { submissions: n, context: s }) }), r(t.nextId);
485
+ }
486
+ async function os({ submissions: e, next: r, node: t, context: n }) {
487
+ r(Hn(t, { submissions: e, context: n }) ? t.branchId : t.nextId);
488
+ }
489
+ async function ls({ chat: e, next: r, node: t, submissions: n, context: s }) {
490
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.text, { submissions: n, context: s }) }), r(t.nextId);
491
+ }
492
+ async function us({ chat: e, next: r, node: t }) {
493
+ await e.sendMessage({ author: "bot", type: "image", url: t.data.url, height: t.data.height, width: t.data.width }), r(t.nextId);
494
+ }
495
+ async function cs({ chat: e, next: r, node: t, submissions: n, context: s, t: i, dateEchoLocale: a }) {
496
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.question, { submissions: n, context: s }) });
497
+ let o = t.data.format === "phone" ? await e.userInput({ key: t.data.key, type: "phone", config: { optional: t.data.optional, placeholder: t.data.placeholder, minChars: t.data.minChars, maxChars: t.data.maxChars, submissionFormat: "text", defaultValue: {} } }) : await e.userInput({ key: t.data.key, type: "text", config: { optional: t.data.optional, placeholder: t.data.placeholder, format: t.data.format, maxChars: t.data.maxChars, minChars: t.data.minChars, multiline: t.data.format === "text" && t.data.multiline === !0 } });
498
+ o === null ? await e.sendMessage({ type: "system", variant: "info", semantic: "question-skipped", text: i("skipped") }) : await e.sendMessage({ author: "user", type: "text", text: o.type === "phone" ? ht(o.value) : t.data.format === "date" && a !== void 0 ? mn(o.value, a) : o.value }), r(t.nextId);
499
+ }
500
+ async function ds({ chat: e, next: r, node: t, submissions: n, context: s, t: i }) {
501
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.question, { submissions: n, context: s }) });
502
+ let a = await e.userInput({ key: t.data.key, type: "number", config: { max: t.data.max, min: t.data.min, optional: t.data.optional, placeholder: t.data.placeholder, decimalCases: t.data.decimalCases } });
503
+ a === null ? await e.sendMessage({ type: "system", variant: "info", semantic: "question-skipped", text: i("skipped") }) : await e.sendMessage({ author: "user", type: "text", text: a.value.toString() }), r(t.nextId);
504
+ }
505
+ async function fs({ chat: e, next: r, node: t, submissions: n, context: s, t: i }) {
506
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.question, { submissions: n, context: s }) });
507
+ let a = await e.userInput({ key: t.data.key, type: "phone", config: { minChars: t.data.minChars, defaultValue: { countryCode: t.data.defaultCountryCode }, placeholder: t.data.placeholder, submissionFormat: "phone", optional: t.data.optional } });
508
+ a === null ? await e.sendMessage({ type: "system", variant: "info", semantic: "question-skipped", text: i("skipped") }) : await e.sendMessage({ author: "user", type: "text", text: a.type === "phone" ? ht(a.value) : a.value }), r(t.nextId);
509
+ }
510
+ async function ps({ chat: e, next: r, node: t, submissions: n, context: s, t: i }) {
511
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.question, { submissions: n, context: s }) });
512
+ let a = await e.userInput({ key: t.data.key, type: "multiple-choice", config: t.data });
513
+ a.value.length === 0 ? await e.sendMessage({ type: "system", variant: "info", semantic: "question-skipped", text: i("skipped") }) : await e.sendMessage({ author: "user", type: "text", text: t.data.options.filter((o) => a.value.includes(o.value)).map((o) => o.label).join(", ") }), r(t.nextId);
514
+ }
515
+ async function hs({ chat: e, next: r, node: t, submissions: n, context: s, t: i }) {
516
+ await e.sendMessage({ author: "bot", type: "text", text: fe(t.data.question, { submissions: n, context: s }) });
517
+ let a = await e.userInput({ key: t.data.key, type: "boolean", config: { optional: t.data.optional, labels: { true: t.data.trueLabel, false: t.data.falseLabel } } });
518
+ a === null ? await e.sendMessage({ type: "system", variant: "info", semantic: "question-skipped", text: i("skipped") }) : await e.sendMessage({ author: "user", type: "text", text: a.value === !0 ? t.data.trueLabel : t.data.falseLabel }), r(t.nextId);
519
+ }
520
+ async function ms({ chat: e, next: r, node: t, t: n }) {
521
+ await e.sendMessage({ author: "bot", type: "text", text: t.data.question });
522
+ let s = await e.userInput({ type: "address", key: t.data.key, config: { optional: t.data.optional, keys: t.data.keys, line2Required: t.data.line2Required, placeholder: t.data.placeholder } });
523
+ if (s === null)
524
+ await e.sendMessage({ type: "system", variant: "info", semantic: "question-skipped", text: n("skipped") });
525
+ else {
526
+ let i = Object.values(s.value).filter((a) => a && a.trim().length > 0).join(", ");
527
+ await e.sendMessage({ author: "user", type: "text", text: i });
528
+ }
529
+ return r(t.nextId);
530
+ }
531
+ async function ys({ node: e, chat: r, next: t, submissions: n, context: s, t: i }) {
532
+ await r.sendMessage({ author: "bot", type: "text", text: fe(e.data.question, { submissions: n, context: s }) });
533
+ let a = await r.userInput({ key: e.data.key, type: "file", config: { optional: e.data.optional, extensions: e.data.extensions, fileSizeLimitKib: e.data.maxSizeKb ?? 10 * 1024, allowMultiple: e.data.multiple === !0 } });
534
+ if (a === null)
535
+ await r.sendMessage({ type: "system", variant: "info", semantic: "question-skipped", text: i("skipped") });
536
+ else
537
+ for (let o of a.value)
538
+ await r.sendMessage({ author: "user", type: "file", fileName: o.name, fileSizeKb: o.sizeKb });
539
+ return t(e.nextId);
540
+ }
541
+ async function gs({ chat: e, end: r, node: t }) {
542
+ await e.sendMessage({ type: "system", variant: "info", text: t.data.systemMessage }), r();
543
+ }
544
+ async function bs({ node: e, flow: r, submissions: t, chat: n, next: s, apiClient: i, analytics: a, signal: o, context: c }) {
545
+ let f = yn(r.nodes, t || {}), { answers: g, ...b } = f;
546
+ if (n.setSubmission(e.data.key, { type: "integration", value: b }), await Gn(r, i, { ...a.getSessionInfo(), job: r.job, flow_build: r.build, pre_apply: Vr(r.nodes, t || {}, r.data.flowSessionId) }, o), f.status !== "skipped") {
547
+ let h = [f.status === "unavailable" ? "We could not prepare your pre-apply summary. You can still continue to your application." : f.hasHardConcerns ? e.data.messages.hard : f.hasAdvisoryConcerns ? e.data.messages.advisory : e.data.messages.matched];
548
+ for (let m of ["hard", "advisory"]) {
549
+ let k = g.filter((I) => !I.matched && I.severity === m);
550
+ k.length && h.push((m === "hard" ? "Role requirements" : "Other things to consider") + `
551
+ ` + k.map((I) => `• ${I.message}`).join(`
552
+ `));
553
+ }
554
+ await n.sendMessage({ type: "text", author: "bot", text: h.join(`
555
+
556
+ `) }), f.hasHardConcerns && e.data.alternativeLink && await n.sendMessage({ type: "link", href: e.data.alternativeLink.href, text: e.data.alternativeLink.label }), await n.userInput({ type: "submit", key: void 0, config: { label: fe(e.data.continueLabel, { submissions: t, context: c }) } });
557
+ }
558
+ return s(e.nextId);
559
+ }
560
+ const er = (e, r, t) => {
561
+ var n;
562
+ return e.log({
563
+ event: t,
564
+ properties: {
565
+ flow_id: r.id,
566
+ flow_version: r.version,
567
+ flow_session_id: r.data.flowSessionId,
568
+ flow_build: r.build,
569
+ flow_type: "CHATBOT_DRAWER",
570
+ job: r.job
571
+ },
572
+ customProperties: (n = r.analytics) == null ? void 0 : n.customProperties
573
+ });
574
+ }, Mt = "resume-prompt", vs = async ({
575
+ chatService: e,
576
+ t: r,
577
+ signal: t
578
+ }) => {
579
+ await e.send({
580
+ message: {
581
+ type: "text",
582
+ author: "bot",
583
+ text: r("resume_prompt")
584
+ },
585
+ groupId: Mt,
586
+ signal: t
587
+ });
588
+ const n = await e.input({
589
+ input: {
590
+ type: "boolean",
591
+ key: void 0,
592
+ config: {
593
+ labels: {
594
+ true: r("resume_continue"),
595
+ false: r("resume_start_again")
596
+ },
597
+ optional: !1
598
+ }
599
+ },
600
+ signal: t
601
+ });
602
+ return K.removeMessagesSentByNodeIds([Mt]), (n == null ? void 0 : n.value) !== !1;
603
+ }, Re = ({
604
+ class: e,
605
+ ...r
606
+ }) => {
607
+ const {
608
+ t
609
+ } = ee();
610
+ return u("button", {
611
+ class: Ke("bg-accent-9 active:bg-accent-10 pointer-coarse:touch-hitbox fr flex-shrink-0 rounded-full p-2 text-white transition-all disabled:cursor-not-allowed disabled:opacity-50", e),
612
+ type: "submit",
613
+ ...r,
614
+ children: u("svg", {
615
+ class: "block",
616
+ width: "16",
617
+ height: "16",
618
+ viewBox: "0 0 16 16",
619
+ fill: "transparent",
620
+ stroke: "currentColor",
621
+ "stroke-linecap": "round",
622
+ "stroke-width": "2",
623
+ children: [u("title", {
624
+ children: t("send")
625
+ }), u("path", {
626
+ d: "M3.5 7.5L8 3L12.5 7.5"
627
+ }), u("path", {
628
+ d: "M8 4V13"
629
+ })]
630
+ })
631
+ });
632
+ };
633
+ var ye;
634
+ // @__NO_SIDE_EFFECTS__
635
+ function yt(e) {
636
+ return {
637
+ lang: (e == null ? void 0 : e.lang) ?? (ye == null ? void 0 : ye.lang),
638
+ message: e == null ? void 0 : e.message,
639
+ abortEarly: (e == null ? void 0 : e.abortEarly) ?? (ye == null ? void 0 : ye.abortEarly),
640
+ abortPipeEarly: (e == null ? void 0 : e.abortPipeEarly) ?? (ye == null ? void 0 : ye.abortPipeEarly)
641
+ };
642
+ }
643
+ var Ct;
644
+ // @__NO_SIDE_EFFECTS__
645
+ function xs(e) {
646
+ return Ct == null ? void 0 : Ct.get(e);
647
+ }
648
+ var St;
649
+ // @__NO_SIDE_EFFECTS__
650
+ function ws(e) {
651
+ return St == null ? void 0 : St.get(e);
652
+ }
653
+ var It;
654
+ // @__NO_SIDE_EFFECTS__
655
+ function _s(e, r) {
656
+ var t;
657
+ return (t = It == null ? void 0 : It.get(e)) == null ? void 0 : t.get(r);
658
+ }
659
+ // @__NO_SIDE_EFFECTS__
660
+ function We(e) {
661
+ var t, n;
662
+ const r = typeof e;
663
+ return r === "string" ? `"${e}"` : r === "number" || r === "bigint" || r === "boolean" ? `${e}` : r === "object" || r === "function" ? (e && ((n = (t = Object.getPrototypeOf(e)) == null ? void 0 : t.constructor) == null ? void 0 : n.name)) ?? "null" : r;
664
+ }
665
+ function Q(e, r, t, n, s) {
666
+ const i = s && "input" in s ? s.input : t.value, a = (s == null ? void 0 : s.expected) ?? e.expects ?? null, o = (s == null ? void 0 : s.received) ?? /* @__PURE__ */ We(i), c = {
667
+ kind: e.kind,
668
+ type: e.type,
669
+ input: i,
670
+ expected: a,
671
+ received: o,
672
+ message: `Invalid ${r}: ${a ? `Expected ${a} but r` : "R"}eceived ${o}`,
673
+ requirement: e.requirement,
674
+ path: s == null ? void 0 : s.path,
675
+ issues: s == null ? void 0 : s.issues,
676
+ lang: n.lang,
677
+ abortEarly: n.abortEarly,
678
+ abortPipeEarly: n.abortPipeEarly
679
+ }, f = e.kind === "schema", g = (s == null ? void 0 : s.message) ?? e.message ?? /* @__PURE__ */ _s(e.reference, c.lang) ?? (f ? /* @__PURE__ */ ws(c.lang) : null) ?? n.message ?? /* @__PURE__ */ xs(c.lang);
680
+ g !== void 0 && (c.message = typeof g == "function" ? (
681
+ // @ts-expect-error
682
+ g(c)
683
+ ) : g), f && (t.typed = !1), t.issues ? t.issues.push(c) : t.issues = [c];
684
+ }
685
+ // @__NO_SIDE_EFFECTS__
686
+ function me(e) {
687
+ return {
688
+ version: 1,
689
+ vendor: "valibot",
690
+ validate(r) {
691
+ return e["~run"]({ value: r }, /* @__PURE__ */ yt());
692
+ }
693
+ };
694
+ }
695
+ // @__NO_SIDE_EFFECTS__
696
+ function ks(e, r) {
697
+ return Object.hasOwn(e, r) && r !== "__proto__" && r !== "prototype" && r !== "constructor";
698
+ }
699
+ // @__NO_SIDE_EFFECTS__
700
+ function Cs(e, r) {
701
+ const t = [...new Set(e)];
702
+ return t.length > 1 ? `(${t.join(` ${r} `)})` : t[0] ?? "never";
703
+ }
704
+ // @__NO_SIDE_EFFECTS__
705
+ function Ss(e) {
706
+ if (e.path) {
707
+ let r = "";
708
+ for (const t of e.path)
709
+ if (typeof t.key == "string" || typeof t.key == "number")
710
+ r ? r += `.${t.key}` : r += t.key;
711
+ else
712
+ return null;
713
+ return r;
714
+ }
715
+ return null;
716
+ }
717
+ var Is = class extends Error {
718
+ /**
719
+ * Creates a Valibot error with useful information.
720
+ *
721
+ * @param issues The error issues.
722
+ */
723
+ constructor(e) {
724
+ super(e[0].message), this.name = "ValiError", this.issues = e;
725
+ }
726
+ }, As = /^[\w+-]+(?:\.[\w+-]+)*@[\da-z]+(?:[.-][\da-z]+)*\.[a-z]{2,}$/iu;
727
+ // @__NO_SIDE_EFFECTS__
728
+ function Pr(e, r) {
729
+ return {
730
+ kind: "validation",
731
+ type: "check",
732
+ reference: Pr,
733
+ async: !1,
734
+ expects: null,
735
+ requirement: e,
736
+ message: r,
737
+ "~run"(t, n) {
738
+ return t.typed && !this.requirement(t.value) && Q(this, "input", t, n), t;
739
+ }
740
+ };
741
+ }
742
+ // @__NO_SIDE_EFFECTS__
743
+ function qr(e) {
744
+ return {
745
+ kind: "validation",
746
+ type: "email",
747
+ reference: qr,
748
+ expects: null,
749
+ async: !1,
750
+ requirement: As,
751
+ message: e,
752
+ "~run"(r, t) {
753
+ return r.typed && !this.requirement.test(r.value) && Q(this, "email", r, t), r;
754
+ }
755
+ };
756
+ }
757
+ // @__NO_SIDE_EFFECTS__
758
+ function st(e, r) {
759
+ return {
760
+ kind: "validation",
761
+ type: "max_length",
762
+ reference: st,
763
+ async: !1,
764
+ expects: `<=${e}`,
765
+ requirement: e,
766
+ message: r,
767
+ "~run"(t, n) {
768
+ return t.typed && t.value.length > this.requirement && Q(this, "length", t, n, {
769
+ received: `${t.value.length}`
770
+ }), t;
771
+ }
772
+ };
773
+ }
774
+ // @__NO_SIDE_EFFECTS__
775
+ function $r(e, r) {
776
+ return {
777
+ kind: "validation",
778
+ type: "max_value",
779
+ reference: $r,
780
+ async: !1,
781
+ expects: `<=${e instanceof Date ? e.toJSON() : /* @__PURE__ */ We(e)}`,
782
+ requirement: e,
783
+ message: r,
784
+ "~run"(t, n) {
785
+ return t.typed && !(t.value <= this.requirement) && Q(this, "value", t, n, {
786
+ received: t.value instanceof Date ? t.value.toJSON() : /* @__PURE__ */ We(t.value)
787
+ }), t;
788
+ }
789
+ };
790
+ }
791
+ // @__NO_SIDE_EFFECTS__
792
+ function Ue(e, r) {
793
+ return {
794
+ kind: "validation",
795
+ type: "min_length",
796
+ reference: Ue,
797
+ async: !1,
798
+ expects: `>=${e}`,
799
+ requirement: e,
800
+ message: r,
801
+ "~run"(t, n) {
802
+ return t.typed && t.value.length < this.requirement && Q(this, "length", t, n, {
803
+ received: `${t.value.length}`
804
+ }), t;
805
+ }
806
+ };
807
+ }
808
+ // @__NO_SIDE_EFFECTS__
809
+ function Ur(e, r) {
810
+ return {
811
+ kind: "validation",
812
+ type: "min_value",
813
+ reference: Ur,
814
+ async: !1,
815
+ expects: `>=${e instanceof Date ? e.toJSON() : /* @__PURE__ */ We(e)}`,
816
+ requirement: e,
817
+ message: r,
818
+ "~run"(t, n) {
819
+ return t.typed && !(t.value >= this.requirement) && Q(this, "value", t, n, {
820
+ received: t.value instanceof Date ? t.value.toJSON() : /* @__PURE__ */ We(t.value)
821
+ }), t;
822
+ }
823
+ };
824
+ }
825
+ // @__NO_SIDE_EFFECTS__
826
+ function Tt(e, r) {
827
+ return {
828
+ kind: "validation",
829
+ type: "regex",
830
+ reference: Tt,
831
+ async: !1,
832
+ expects: `${e}`,
833
+ requirement: e,
834
+ message: r,
835
+ "~run"(t, n) {
836
+ return t.typed && !this.requirement.test(t.value) && Q(this, "format", t, n), t;
837
+ }
838
+ };
839
+ }
840
+ // @__NO_SIDE_EFFECTS__
841
+ function Ot(e) {
842
+ return {
843
+ kind: "transformation",
844
+ type: "transform",
845
+ reference: Ot,
846
+ async: !1,
847
+ operation: e,
848
+ "~run"(r) {
849
+ return r.value = this.operation(r.value), r;
850
+ }
851
+ };
852
+ }
853
+ // @__NO_SIDE_EFFECTS__
854
+ function Wr(e) {
855
+ return {
856
+ kind: "validation",
857
+ type: "url",
858
+ reference: Wr,
859
+ async: !1,
860
+ expects: null,
861
+ requirement(r) {
862
+ try {
863
+ return new URL(r), !0;
864
+ } catch {
865
+ return !1;
866
+ }
867
+ },
868
+ message: e,
869
+ "~run"(r, t) {
870
+ return r.typed && !this.requirement(r.value) && Q(this, "URL", r, t), r;
871
+ }
872
+ };
873
+ }
874
+ // @__NO_SIDE_EFFECTS__
875
+ function Es(e, r, t) {
876
+ return typeof e.fallback == "function" ? (
877
+ // @ts-expect-error
878
+ e.fallback(r, t)
879
+ ) : (
880
+ // @ts-expect-error
881
+ e.fallback
882
+ );
883
+ }
884
+ // @__NO_SIDE_EFFECTS__
885
+ function zr(e, r, t) {
886
+ return typeof e.default == "function" ? (
887
+ // @ts-expect-error
888
+ e.default(r, t)
889
+ ) : (
890
+ // @ts-expect-error
891
+ e.default
892
+ );
893
+ }
894
+ // @__NO_SIDE_EFFECTS__
895
+ function Kr(e, r) {
896
+ return {
897
+ kind: "schema",
898
+ type: "array",
899
+ reference: Kr,
900
+ expects: "Array",
901
+ async: !1,
902
+ item: e,
903
+ message: r,
904
+ get "~standard"() {
905
+ return /* @__PURE__ */ me(this);
906
+ },
907
+ "~run"(t, n) {
908
+ var i;
909
+ const s = t.value;
910
+ if (Array.isArray(s)) {
911
+ t.typed = !0, t.value = [];
912
+ for (let a = 0; a < s.length; a++) {
913
+ const o = s[a], c = this.item["~run"]({ value: o }, n);
914
+ if (c.issues) {
915
+ const f = {
916
+ type: "array",
917
+ origin: "value",
918
+ input: s,
919
+ key: a,
920
+ value: o
921
+ };
922
+ for (const g of c.issues)
923
+ g.path ? g.path.unshift(f) : g.path = [f], (i = t.issues) == null || i.push(g);
924
+ if (t.issues || (t.issues = c.issues), n.abortEarly) {
925
+ t.typed = !1;
926
+ break;
927
+ }
928
+ }
929
+ c.typed || (t.typed = !1), t.value.push(c.value);
930
+ }
931
+ } else
932
+ Q(this, "type", t, n);
933
+ return t;
934
+ }
935
+ };
936
+ }
937
+ // @__NO_SIDE_EFFECTS__
938
+ function Gr(e) {
939
+ return {
940
+ kind: "schema",
941
+ type: "boolean",
942
+ reference: Gr,
943
+ expects: "boolean",
944
+ async: !1,
945
+ message: e,
946
+ get "~standard"() {
947
+ return /* @__PURE__ */ me(this);
948
+ },
949
+ "~run"(r, t) {
950
+ return typeof r.value == "boolean" ? r.typed = !0 : Q(this, "type", r, t), r;
951
+ }
952
+ };
953
+ }
954
+ // @__NO_SIDE_EFFECTS__
955
+ function Hr(e) {
956
+ return {
957
+ kind: "schema",
958
+ type: "number",
959
+ reference: Hr,
960
+ expects: "number",
961
+ async: !1,
962
+ message: e,
963
+ get "~standard"() {
964
+ return /* @__PURE__ */ me(this);
965
+ },
966
+ "~run"(r, t) {
967
+ return typeof r.value == "number" && !isNaN(r.value) ? r.typed = !0 : Q(this, "type", r, t), r;
968
+ }
969
+ };
970
+ }
971
+ // @__NO_SIDE_EFFECTS__
972
+ function xe(e, r) {
973
+ return {
974
+ kind: "schema",
975
+ type: "object",
976
+ reference: xe,
977
+ expects: "Object",
978
+ async: !1,
979
+ entries: e,
980
+ message: r,
981
+ get "~standard"() {
982
+ return /* @__PURE__ */ me(this);
983
+ },
984
+ "~run"(t, n) {
985
+ var i;
986
+ const s = t.value;
987
+ if (s && typeof s == "object") {
988
+ t.typed = !0, t.value = {};
989
+ for (const a in this.entries) {
990
+ const o = this.entries[a];
991
+ if (a in s || (o.type === "exact_optional" || o.type === "optional" || o.type === "nullish") && // @ts-expect-error
992
+ o.default !== void 0) {
993
+ const c = a in s ? (
994
+ // @ts-expect-error
995
+ s[a]
996
+ ) : /* @__PURE__ */ zr(o), f = o["~run"]({ value: c }, n);
997
+ if (f.issues) {
998
+ const g = {
999
+ type: "object",
1000
+ origin: "value",
1001
+ input: s,
1002
+ key: a,
1003
+ value: c
1004
+ };
1005
+ for (const b of f.issues)
1006
+ b.path ? b.path.unshift(g) : b.path = [g], (i = t.issues) == null || i.push(b);
1007
+ if (t.issues || (t.issues = f.issues), n.abortEarly) {
1008
+ t.typed = !1;
1009
+ break;
1010
+ }
1011
+ }
1012
+ f.typed || (t.typed = !1), t.value[a] = f.value;
1013
+ } else if (o.fallback !== void 0)
1014
+ t.value[a] = /* @__PURE__ */ Es(o);
1015
+ else if (o.type !== "exact_optional" && o.type !== "optional" && o.type !== "nullish" && (Q(this, "key", t, n, {
1016
+ input: void 0,
1017
+ expected: `"${a}"`,
1018
+ path: [
1019
+ {
1020
+ type: "object",
1021
+ origin: "key",
1022
+ input: s,
1023
+ key: a,
1024
+ // @ts-expect-error
1025
+ value: s[a]
1026
+ }
1027
+ ]
1028
+ }), n.abortEarly))
1029
+ break;
1030
+ }
1031
+ } else
1032
+ Q(this, "type", t, n);
1033
+ return t;
1034
+ }
1035
+ };
1036
+ }
1037
+ // @__NO_SIDE_EFFECTS__
1038
+ function $e(e, r) {
1039
+ return {
1040
+ kind: "schema",
1041
+ type: "optional",
1042
+ reference: $e,
1043
+ expects: `(${e.expects} | undefined)`,
1044
+ async: !1,
1045
+ wrapped: e,
1046
+ default: r,
1047
+ get "~standard"() {
1048
+ return /* @__PURE__ */ me(this);
1049
+ },
1050
+ "~run"(t, n) {
1051
+ return t.value === void 0 && (this.default !== void 0 && (t.value = /* @__PURE__ */ zr(this, t, n)), t.value === void 0) ? (t.typed = !0, t) : this.wrapped["~run"](t, n);
1052
+ }
1053
+ };
1054
+ }
1055
+ // @__NO_SIDE_EFFECTS__
1056
+ function Jr(e, r) {
1057
+ return {
1058
+ kind: "schema",
1059
+ type: "picklist",
1060
+ reference: Jr,
1061
+ expects: /* @__PURE__ */ Cs(e.map(We), "|"),
1062
+ async: !1,
1063
+ options: e,
1064
+ message: r,
1065
+ get "~standard"() {
1066
+ return /* @__PURE__ */ me(this);
1067
+ },
1068
+ "~run"(t, n) {
1069
+ return this.options.includes(t.value) ? t.typed = !0 : Q(this, "type", t, n), t;
1070
+ }
1071
+ };
1072
+ }
1073
+ // @__NO_SIDE_EFFECTS__
1074
+ function Zr(e, r, t) {
1075
+ return {
1076
+ kind: "schema",
1077
+ type: "record",
1078
+ reference: Zr,
1079
+ expects: "Object",
1080
+ async: !1,
1081
+ key: e,
1082
+ value: r,
1083
+ message: t,
1084
+ get "~standard"() {
1085
+ return /* @__PURE__ */ me(this);
1086
+ },
1087
+ "~run"(n, s) {
1088
+ var a, o;
1089
+ const i = n.value;
1090
+ if (i && typeof i == "object") {
1091
+ n.typed = !0, n.value = {};
1092
+ for (const c in i)
1093
+ if (/* @__PURE__ */ ks(i, c)) {
1094
+ const f = i[c], g = this.key["~run"]({ value: c }, s);
1095
+ if (g.issues) {
1096
+ const h = {
1097
+ type: "object",
1098
+ origin: "key",
1099
+ input: i,
1100
+ key: c,
1101
+ value: f
1102
+ };
1103
+ for (const m of g.issues)
1104
+ m.path = [h], (a = n.issues) == null || a.push(m);
1105
+ if (n.issues || (n.issues = g.issues), s.abortEarly) {
1106
+ n.typed = !1;
1107
+ break;
1108
+ }
1109
+ }
1110
+ const b = this.value["~run"](
1111
+ { value: f },
1112
+ s
1113
+ );
1114
+ if (b.issues) {
1115
+ const h = {
1116
+ type: "object",
1117
+ origin: "value",
1118
+ input: i,
1119
+ key: c,
1120
+ value: f
1121
+ };
1122
+ for (const m of b.issues)
1123
+ m.path ? m.path.unshift(h) : m.path = [h], (o = n.issues) == null || o.push(m);
1124
+ if (n.issues || (n.issues = b.issues), s.abortEarly) {
1125
+ n.typed = !1;
1126
+ break;
1127
+ }
1128
+ }
1129
+ (!g.typed || !b.typed) && (n.typed = !1), g.typed && (n.value[g.value] = b.value);
1130
+ }
1131
+ } else
1132
+ Q(this, "type", n, s);
1133
+ return n;
1134
+ }
1135
+ };
1136
+ }
1137
+ // @__NO_SIDE_EFFECTS__
1138
+ function ae(e) {
1139
+ return {
1140
+ kind: "schema",
1141
+ type: "string",
1142
+ reference: ae,
1143
+ expects: "string",
1144
+ async: !1,
1145
+ message: e,
1146
+ get "~standard"() {
1147
+ return /* @__PURE__ */ me(this);
1148
+ },
1149
+ "~run"(r, t) {
1150
+ return typeof r.value == "string" ? r.typed = !0 : Q(this, "type", r, t), r;
1151
+ }
1152
+ };
1153
+ }
1154
+ function Fs(e, r, t) {
1155
+ const n = e["~run"]({ value: r }, /* @__PURE__ */ yt(t));
1156
+ if (n.issues)
1157
+ throw new Is(n.issues);
1158
+ return n.value;
1159
+ }
1160
+ // @__NO_SIDE_EFFECTS__
1161
+ function Vs(e, r) {
1162
+ const t = {};
1163
+ for (const n in e.entries)
1164
+ t[n] = !r || r.includes(n) ? /* @__PURE__ */ $e(e.entries[n]) : e.entries[n];
1165
+ return {
1166
+ ...e,
1167
+ entries: t,
1168
+ get "~standard"() {
1169
+ return /* @__PURE__ */ me(this);
1170
+ }
1171
+ };
1172
+ }
1173
+ // @__NO_SIDE_EFFECTS__
1174
+ function Ie(...e) {
1175
+ return {
1176
+ ...e[0],
1177
+ pipe: e,
1178
+ get "~standard"() {
1179
+ return /* @__PURE__ */ me(this);
1180
+ },
1181
+ "~run"(r, t) {
1182
+ for (const n of e)
1183
+ if (n.kind !== "metadata") {
1184
+ if (r.issues && (n.kind === "schema" || n.kind === "transformation")) {
1185
+ r.typed = !1;
1186
+ break;
1187
+ }
1188
+ (!r.issues || !t.abortEarly && !t.abortPipeEarly) && (r = n["~run"](r, t));
1189
+ }
1190
+ return r;
1191
+ }
1192
+ };
1193
+ }
1194
+ // @__NO_SIDE_EFFECTS__
1195
+ function Ms(e, r, t) {
1196
+ const n = e["~run"]({ value: r }, /* @__PURE__ */ yt(t));
1197
+ return {
1198
+ typed: n.typed,
1199
+ success: !n.issues,
1200
+ output: n.value,
1201
+ issues: n.issues
1202
+ };
1203
+ }
1204
+ // @__NO_SIDE_EFFECTS__
1205
+ async function Ls(e, r, t) {
1206
+ const n = await e["~run"](
1207
+ { value: r },
1208
+ /* @__PURE__ */ yt(t)
1209
+ );
1210
+ return {
1211
+ typed: n.typed,
1212
+ success: !n.issues,
1213
+ output: n.value,
1214
+ issues: n.issues
1215
+ };
1216
+ }
1217
+ const He = ({
1218
+ error: e
1219
+ }) => !e || !e.message ? null : u("div", {
1220
+ role: "alert",
1221
+ class: "text-error-11 flex max-w-full items-start gap-1 overflow-hidden rounded-2xl px-2 py-2",
1222
+ children: [u("svg", {
1223
+ class: "text-error-9 mt-0.5 h-4 w-4 shrink-0",
1224
+ viewBox: "0 0 16 16",
1225
+ fill: "none",
1226
+ xmlns: "http://www.w3.org/2000/svg",
1227
+ children: [u("circle", {
1228
+ cx: "8",
1229
+ cy: "8",
1230
+ r: "6.3",
1231
+ stroke: "currentColor",
1232
+ "stroke-width": "1.4"
1233
+ }), u("rect", {
1234
+ x: "7",
1235
+ y: "4",
1236
+ width: "2",
1237
+ height: "5",
1238
+ fill: "currentColor"
1239
+ }), u("rect", {
1240
+ x: "7",
1241
+ y: "10",
1242
+ width: "2",
1243
+ height: "2",
1244
+ fill: "currentColor"
1245
+ })]
1246
+ }), u("p", {
1247
+ class: "break-words pr-1 text-sm",
1248
+ children: e.message
1249
+ })]
1250
+ }), Ee = ({
1251
+ class: e,
1252
+ ...r
1253
+ }) => {
1254
+ const {
1255
+ t
1256
+ } = ee();
1257
+ return u("button", {
1258
+ type: "button",
1259
+ class: Ke("fr touch-hitbox text-neutral-11 bg-neutral-1 ring-divider hover:ring-divider active:ring-interactive-bg-hover hover:text-neutral-12 active:text-neutral-12 hover:bg-divider active:bg-interactive-bg-hover flex flex-shrink-0 items-center justify-center gap-1 self-center rounded-full py-1 pl-2 pr-2.5 text-sm ring-1 transition-all", e),
1260
+ ...r,
1261
+ children: [u("svg", {
1262
+ "aria-hidden": !0,
1263
+ class: "block",
1264
+ width: "16",
1265
+ height: "16",
1266
+ viewBox: "0 0 16 16",
1267
+ fill: "transparent",
1268
+ stroke: "currentColor",
1269
+ "stroke-linecap": "round",
1270
+ "stroke-width": "1.5",
1271
+ children: [u("title", {
1272
+ children: t("skip")
1273
+ }), u("path", {
1274
+ d: "M3.25 11.25A5 5 0 0 1 12 7"
1275
+ }), u("path", {
1276
+ d: "M13.25 4.5V8.25H9.5"
1277
+ })]
1278
+ }), t("skip")]
1279
+ });
1280
+ };
1281
+ var Bt = { Afghanistan: "93", Albania: "355", Algeria: "213", "American Samoa": "1 684", Andorra: "376", Angola: "244", Anguilla: "1 264", Antarctica: "672", "Antigua and Barbuda": "1 268", Argentina: "54", Armenia: "374", Aruba: "297", Australia: "61", Austria: "43", Azerbaijan: "994", Bahrain: "973", Bangladesh: "880", Barbados: "1 246", Belarus: "375", Belgium: "32", Belize: "501", Benin: "229", Bermuda: "1 441", Bhutan: "975", Bolivia: "591", "Bosnia and Herzegovina": "387", Botswana: "267", "Bouvet Island": "47", Brazil: "55", "British Indian Ocean Territory": "246", "British Virgin Islands": "1 284", Brunei: "673", Bulgaria: "359", "Burkina Faso": "226", Burundi: "257", "Cabo Verde": "238", Cambodia: "855", Cameroon: "237", Canada: "1", "Caribbean Netherlands": "599", "Cayman Islands": "1 345", "Central African Republic": "236", Chad: "235", Chile: "56", China: "86", "Christmas Island": "61", "Cocos (Keeling) Islands": "61", Colombia: "57", Comoros: "269", "Cook Islands": "682", "Costa Rica": "506", Croatia: "385", Cuba: "53", Curaçao: "599", Cyprus: "357", Czechia: "420", "Côte d'Ivoire": "225", "Democratic Republic of the Congo": "243", Denmark: "45", Djibouti: "253", "Dominican Republic": "1 809", Ecuador: "593", Egypt: "20", "El Salvador": "503", "Equatorial Guinea": "240", Eritrea: "291", Estonia: "372", Eswatini: "268", Ethiopia: "251", "Falkland Islands (Islas Malvinas)": "500", "Faroe Islands": "298", Fiji: "679", Finland: "358", France: "33", "French Guiana": "594", "French Polynesia": "689", "French Southern and Antarctic Lands": "262", Gabon: "241", Georgia: "995", Germany: "49", Ghana: "233", Gibraltar: "350", Greece: "30", Greenland: "299", Grenada: "1 473", Guadeloupe: "590", Guam: "1 671", Guatemala: "502", Guernsey: "44", Guinea: "224", "Guinea-Bissau": "245", Guyana: "592", Haiti: "509", Honduras: "504", "Hong Kong": "852", Hungary: "36", Iceland: "354", India: "91", Indonesia: "62", Iran: "98", Iraq: "964", Ireland: "353", "Isle of Man": "44", Israel: "972", Italy: "39", Jamaica: "1 876", Japan: "81", Jersey: "44", Jordan: "962", Kazakhstan: "7", Kenya: "254", Kiribati: "686", Kosovo: "383", Kuwait: "965", Kyrgyzstan: "996", Laos: "856", Latvia: "371", Lebanon: "961", Lesotho: "266", Liberia: "231", Libya: "218", Liechtenstein: "423", Lithuania: "370", Luxembourg: "352", Macao: "853", Madagascar: "261", Malawi: "265", Malaysia: "60", Maldives: "960", Mali: "223", Malta: "356", "Marshall Islands": "692", Martinique: "596", Mauritania: "222", Mauritius: "230", Mayotte: "262", Mexico: "52", Micronesia: "691", Moldova: "373", Monaco: "377", Mongolia: "976", Montenegro: "382", Montserrat: "1 664", Morocco: "212", Mozambique: "258", "Myanmar (Burma)": "95", Namibia: "264", Nauru: "674", Nepal: "977", Netherlands: "31", "New Caledonia": "687", "New Zealand": "64", Nicaragua: "505", Niger: "227", Nigeria: "234", Niue: "683", "Norfolk Island": "672", "North Korea": "850", "North Macedonia": "389", "Northern Mariana Islands": "1 670", Norway: "47", Oman: "968", Pakistan: "92", Palau: "680", Palestine: "970", Panama: "507", "Papua New Guinea": "675", Paraguay: "595", Peru: "51", Philippines: "63", "Pitcairn Islands": "64", Poland: "48", Portugal: "351", "Puerto Rico": "1 787", Qatar: "974", Romania: "40", Russia: "7", Rwanda: "250", Réunion: "262", "Saint Barthélemy": "590", "Saint Helena, Ascension and Tristan da Cunha": "290", "Saint Kitts and Nevis": "1 869", "Saint Lucia": "1 758", "Saint Martin": "590", "Saint Pierre and Miquelon": "508", "Saint Vincent and the Grenadines": "1 784", Samoa: "685", "San Marino": "378", "Saudi Arabia": "966", Senegal: "221", Serbia: "381", Seychelles: "248", "Sierra Leone": "232", Singapore: "65", "Sint Maarten": "1 721", Slovakia: "421", Slovenia: "386", "Solomon Islands": "677", Somalia: "252", "South Africa": "27", "South Georgia and the South Sandwich Islands": "500", "South Korea": "82", "South Sudan": "211", Spain: "34", "Sri Lanka": "94", Sudan: "249", Suriname: "597", "Svalbard and Jan Mayen": "47", Sweden: "46", Switzerland: "41", Syria: "963", "São Tomé and Príncipe": "239", Taiwan: "886", Tajikistan: "992", Tanzania: "255", Thailand: "66", "The Bahamas": "1 242", "The Gambia": "220", "Timor-Leste": "670", Togo: "228", Tokelau: "690", Tonga: "676", "Trinidad and Tobago": "1 868", Tunisia: "216", Turkmenistan: "993", "Turks and Caicos Islands": "1 649", Tuvalu: "688", Türkiye: "90", "U.S. Virgin Islands": "1 340", Uganda: "256", Ukraine: "380", "United Arab Emirates": "971", "United Kingdom": "44", "United States": "1", "United States Minor Outlying Islands": "1", Uruguay: "598", Uzbekistan: "998", Vanuatu: "678", "Vatican City": "379", Venezuela: "58", Vietnam: "84", "Wallis and Futuna": "681", "Western Sahara": "212", Yemen: "967", Zambia: "260", Zimbabwe: "263", "Åland Islands": "358" };
1282
+ const ze = mt("outline-divider ease-expo-out placeholder:text-neutral-10 text-neutral-12 focus-visible:outline-accent-7 caret-accent-9 bg-lowest py-1 text-base outline outline-2 transition-all", {
1283
+ variants: {
1284
+ optional: {
1285
+ true: "pr-16 pl-3",
1286
+ false: "pl-3 pr-3"
1287
+ }
1288
+ },
1289
+ defaultVariants: {
1290
+ optional: !1
1291
+ }
1292
+ }), Ns = "https://api.mapbox.com/search/searchbox/v1/suggest", Rs = "ZzRDWFU0dTZ3SF9aWk9RNGl6QzZaWS5RZmlFak13a0hPbGxXZXlNSGN5RUhObUJ6TXpSV08yUW5OdE5tSTZJU1lpd2lJb1JYYXRObmJ2Tm5iaGhHZWx4V1lpb2pJMUp5ZS5rcA==", Ds = (e) => atob(e).split("").reverse().join(""), ge = /* @__PURE__ */ xe({
1293
+ name: /* @__PURE__ */ ae()
1294
+ }), Ts = /* @__PURE__ */ xe({
1295
+ suggestions: /* @__PURE__ */ Kr(/* @__PURE__ */ xe({
1296
+ feature_type: /* @__PURE__ */ $e(/* @__PURE__ */ ae()),
1297
+ full_address: /* @__PURE__ */ $e(/* @__PURE__ */ ae()),
1298
+ place_formatted: /* @__PURE__ */ $e(/* @__PURE__ */ ae()),
1299
+ name: /* @__PURE__ */ $e(/* @__PURE__ */ ae()),
1300
+ mapbox_id: /* @__PURE__ */ ae(),
1301
+ context: /* @__PURE__ */ Vs(/* @__PURE__ */ xe({
1302
+ address: ge,
1303
+ street: ge,
1304
+ neighborhood: ge,
1305
+ locality: ge,
1306
+ district: ge,
1307
+ place: ge,
1308
+ region: ge,
1309
+ postcode: ge,
1310
+ country: ge
1311
+ }))
1312
+ }))
1313
+ }), Os = ({
1314
+ logger: e,
1315
+ t: r
1316
+ }) => Fn(() => {
1317
+ var n;
1318
+ const t = (n = K.current$.peek().flow) == null ? void 0 : n.data.flowSessionId;
1319
+ return t ? {
1320
+ enabled: !0,
1321
+ getPredictions: async (s) => {
1322
+ var b;
1323
+ const i = new URL(Ns);
1324
+ i.searchParams.set("q", s), i.searchParams.set("session_token", t);
1325
+ const a = (b = K.current$.peek().flow) == null ? void 0 : b.locationOrigin;
1326
+ a && a.lat !== void 0 && a.lng !== void 0 && a.lat >= -90 && a.lat <= 90 && a.lng >= -180 && a.lng <= 180 && i.searchParams.set("proximity", `${a.lng},${a.lat}`), i.searchParams.set("access_token", Ds(Rs));
1327
+ const c = await fetch(i);
1328
+ if (!c.ok)
1329
+ return e.error("Failed to get address details", c), {
1330
+ ok: !1,
1331
+ error: r("address_error")
1332
+ };
1333
+ const f = /* @__PURE__ */ Ms(Ts, await c.json());
1334
+ if (f.success === !1)
1335
+ return e.error("Failed to parse address details", f.issues), {
1336
+ ok: !1,
1337
+ error: r("address_error")
1338
+ };
1339
+ const {
1340
+ suggestions: g
1341
+ } = f.output;
1342
+ return {
1343
+ ok: !0,
1344
+ data: g.map((h) => {
1345
+ var m, k, I, C, x, y, F, N, V;
1346
+ return {
1347
+ // A postcode result has no full address and is named by the postcode itself (PROD-7311).
1348
+ label: h.full_address ?? ([h.name, h.place_formatted].filter(Boolean).join(", ") || h.mapbox_id),
1349
+ id: h.mapbox_id,
1350
+ address: {
1351
+ line1: ((m = h.context.address) == null ? void 0 : m.name) ?? ((k = h.context.street) == null ? void 0 : k.name),
1352
+ line2: void 0,
1353
+ line3: ((I = h.context.neighborhood) == null ? void 0 : I.name) ?? ((C = h.context.locality) == null ? void 0 : C.name),
1354
+ city: ((x = h.context.place) == null ? void 0 : x.name) ?? ((y = h.context.district) == null ? void 0 : y.name),
1355
+ state: (F = h.context.region) == null ? void 0 : F.name,
1356
+ postcode: ((N = h.context.postcode) == null ? void 0 : N.name) ?? (h.feature_type === "postcode" ? h.name : void 0),
1357
+ country: (V = h.context.country) == null ? void 0 : V.name
1358
+ }
1359
+ };
1360
+ })
1361
+ };
1362
+ }
1363
+ } : {
1364
+ enabled: !1
1365
+ };
1366
+ }, [e, r]), tr = (e) => {
1367
+ const {
1368
+ t: r
1369
+ } = ee();
1370
+ return u("button", {
1371
+ type: "button",
1372
+ class: "touch-hitbox text-neutral-11 hover:bg-neutral-4 hover:text-neutral-12 hover:border-neutral-5 relative flex items-center gap-1 rounded-[18px] border border-solid border-transparent px-3 py-1 pl-1.5 text-sm transition-colors",
1373
+ ...e,
1374
+ children: [u("svg", {
1375
+ width: "16",
1376
+ height: "16",
1377
+ viewBox: "0 0 16 16",
1378
+ stroke: "currentColor",
1379
+ "stroke-width": "1.5",
1380
+ fill: "none",
1381
+ xmlns: "http://www.w3.org/2000/svg",
1382
+ children: u("path", {
1383
+ d: "M10 3L5 8L10 13"
1384
+ })
1385
+ }), u("span", {
1386
+ children: r("back")
1387
+ })]
1388
+ });
1389
+ }, Bs = ({
1390
+ input: e,
1391
+ onSubmitSuccess: r,
1392
+ logger: t
1393
+ }) => {
1394
+ const {
1395
+ t: n
1396
+ } = ee(), [s, i] = ve(), {
1397
+ enabled: a,
1398
+ getPredictions: o
1399
+ } = Os({
1400
+ logger: t,
1401
+ t: n
1402
+ }), [c, f] = ve(a ? "query" : "manual"), [g, b] = ve(""), [h, m] = ve(), k = he(), I = he(), C = (y) => {
1403
+ var N;
1404
+ if (Ne(a, "Query state should not be enabled"), y = y.trim(), y === ((N = k.current) == null ? void 0 : N.query) || y === (h == null ? void 0 : h.query) && h.status === "done")
1405
+ return;
1406
+ if (b(y), y === "") {
1407
+ k.current = void 0, m(void 0);
1408
+ return;
1409
+ }
1410
+ const F = k.current = {
1411
+ query: y
1412
+ };
1413
+ m({
1414
+ query: y,
1415
+ status: "pending"
1416
+ }), o(y).then((V) => {
1417
+ k.current === F && (k.current = void 0, m(V.ok ? {
1418
+ query: y,
1419
+ status: "done",
1420
+ items: V.data
1421
+ } : {
1422
+ query: y,
1423
+ status: "failed",
1424
+ error: V.error
1425
+ }));
1426
+ }, (V) => {
1427
+ k.current === F && (k.current = void 0, t.error("Failed to get address details", V), m({
1428
+ query: y,
1429
+ status: "failed",
1430
+ error: n("address_error")
1431
+ }));
1432
+ });
1433
+ }, x = (y, F) => {
1434
+ i((N) => ({
1435
+ ...N,
1436
+ [y]: F
1437
+ }));
1438
+ };
1439
+ switch (c) {
1440
+ case "query":
1441
+ return Ne(a, "Query state should not be enabled"), u(js, {
1442
+ input: e,
1443
+ onSkip: () => r(null),
1444
+ onAddressSelect: (y) => {
1445
+ if (y === "") {
1446
+ k.current && (k.current = void 0, m(void 0)), f("manual");
1447
+ return;
1448
+ }
1449
+ const F = (h == null ? void 0 : h.status) === "done" ? h.items.find((N) => N.id === y) : void 0;
1450
+ F && (I.current !== y && i(F.address), I.current = y, f("details"));
1451
+ },
1452
+ onAddressSearch: C,
1453
+ lookup: h,
1454
+ query: g
1455
+ });
1456
+ case "details":
1457
+ return Ne(s !== void 0), u(rr, {
1458
+ input: e,
1459
+ logger: t,
1460
+ onSubmitSuccess: r,
1461
+ addressFields: s,
1462
+ onFieldChange: x,
1463
+ actions: u(tr, {
1464
+ onClick: () => {
1465
+ f("query");
1466
+ }
1467
+ })
1468
+ });
1469
+ case "manual":
1470
+ return u(rr, {
1471
+ logger: t,
1472
+ input: e,
1473
+ onSubmitSuccess: r,
1474
+ addressFields: s ?? {},
1475
+ onFieldChange: x,
1476
+ actions: a ? u(tr, {
1477
+ onClick: () => {
1478
+ f("query");
1479
+ }
1480
+ }) : e.config.optional ? (
1481
+ // Without address search this is the only screen, so an optional question needs its own way past.
1482
+ u(Ee, {
1483
+ onClick: () => r(null)
1484
+ })
1485
+ ) : void 0
1486
+ });
1487
+ }
1488
+ }, js = ({
1489
+ input: e,
1490
+ onSkip: r,
1491
+ lookup: t,
1492
+ onAddressSelect: n,
1493
+ query: s,
1494
+ onAddressSearch: i
1495
+ }) => {
1496
+ const {
1497
+ t: a
1498
+ } = ee(), o = he(null);
1499
+ return Ae(() => {
1500
+ o.current && (o.current.focus(), o.current.select());
1501
+ }, []), u(we, {
1502
+ children: [u("form", {
1503
+ noValidate: !0,
1504
+ onSubmit: (c) => {
1505
+ c.preventDefault();
1506
+ const g = new FormData(c.currentTarget).get("address");
1507
+ typeof g == "string" && i(g);
1508
+ },
1509
+ class: "flex gap-2 p-2.5",
1510
+ children: [u("div", {
1511
+ class: "group relative flex-1",
1512
+ children: [u("input", {
1513
+ ref: o,
1514
+ name: "address",
1515
+ id: "chat-address",
1516
+ autocomplete: "address-line1",
1517
+ autoFocus: !0,
1518
+ placeholder: e.config.placeholder || a("address_search"),
1519
+ defaultValue: s,
1520
+ class: ze({
1521
+ optional: !!e.config.optional,
1522
+ className: "w-full rounded-full"
1523
+ })
1524
+ }), u("button", {
1525
+ type: "submit",
1526
+ class: "touch-hitbox text-neutral-12 hover:bg-neutral-3 fr absolute bottom-0 right-0 top-0 flex cursor-pointer items-center gap-1 rounded-full px-3 transition-all",
1527
+ children: [u("svg", {
1528
+ "aria-hidden": "true",
1529
+ width: "16",
1530
+ height: "16",
1531
+ viewBox: "0 0 16 16",
1532
+ fill: "none",
1533
+ xmlns: "http://www.w3.org/2000/svg",
1534
+ children: u("g", {
1535
+ id: "inploi",
1536
+ stroke: "currentColor",
1537
+ "stroke-linecap": "round",
1538
+ "stroke-linejoin": "round",
1539
+ strokeWidth: "1.5",
1540
+ children: [u("circle", {
1541
+ cx: "7",
1542
+ cy: "7",
1543
+ r: "4"
1544
+ }), u("path", {
1545
+ d: "M10 10L13 13"
1546
+ })]
1547
+ })
1548
+ }), u("span", {
1549
+ class: "sr-only",
1550
+ children: a("search")
1551
+ })]
1552
+ })]
1553
+ }), e.config.optional && u(Ee, {
1554
+ class: "relative",
1555
+ onClick: r
1556
+ })]
1557
+ }), (t == null ? void 0 : t.status) === "failed" ? u(He, {
1558
+ error: {
1559
+ message: t.error
1560
+ }
1561
+ }) : null, u("p", {
1562
+ role: "status",
1563
+ class: (t == null ? void 0 : t.status) === "pending" || (t == null ? void 0 : t.status) === "done" && t.items.length === 0 ? "text-neutral-11 flex items-center gap-2 px-4 py-2 text-sm" : "sr-only",
1564
+ children: (t == null ? void 0 : t.status) === "pending" ? u(we, {
1565
+ children: [u(Rt, {
1566
+ "aria-hidden": "true",
1567
+ class: "h-4 w-4 shrink-0"
1568
+ }), a("address_searching")]
1569
+ }) : (t == null ? void 0 : t.status) === "done" && t.items.length === 0 ? a("address_no_results") : null
1570
+ }), u("ul", {
1571
+ children: [((t == null ? void 0 : t.status) === "done" ? t.items : []).map((c) => u("li", {
1572
+ children: u("button", {
1573
+ class: "text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",
1574
+ onClick: () => {
1575
+ n(c.id);
1576
+ },
1577
+ children: [u("span", {
1578
+ class: "flex-grow",
1579
+ children: c.label
1580
+ }), u("svg", {
1581
+ class: "flex-none",
1582
+ width: "16",
1583
+ height: "16",
1584
+ viewBox: "0 0 16 16",
1585
+ stroke: "currentColor",
1586
+ "stroke-width": "1.5",
1587
+ fill: "none",
1588
+ xmlns: "http://www.w3.org/2000/svg",
1589
+ children: u("path", {
1590
+ d: "M6 3L11 8L6 13"
1591
+ })
1592
+ })]
1593
+ })
1594
+ }, c.id)), u("li", {
1595
+ children: u("button", {
1596
+ class: "text-neutral-11 fr hover:bg-neutral-3 focus-visible:bg-neutral-3 hover:text-neutral-12 border-b-neutral-3 flex w-full items-center border border-b border-solid border-transparent px-4 py-3 text-sm transition-colors duration-100",
1597
+ onClick: () => {
1598
+ n("");
1599
+ },
1600
+ children: u("span", {
1601
+ class: "flex-grow",
1602
+ children: a("address_manual")
1603
+ })
1604
+ })
1605
+ }, "")]
1606
+ })]
1607
+ });
1608
+ }, At = ["line1", "line2", "line3", "city", "state", "postcode", "country"], rr = ({
1609
+ addressFields: e,
1610
+ onFieldChange: r,
1611
+ onSubmitSuccess: t,
1612
+ actions: n,
1613
+ input: s
1614
+ }) => {
1615
+ const i = he(null);
1616
+ Ae(() => {
1617
+ if (i.current) {
1618
+ const c = i.current.querySelector("input");
1619
+ c && (c.focus(), c.select());
1620
+ }
1621
+ }, []);
1622
+ const a = Object.keys(Bt), {
1623
+ t: o
1624
+ } = ee();
1625
+ return u("form", {
1626
+ class: "flex flex-col px-2 pt-2",
1627
+ onSubmit: (c) => {
1628
+ const f = c.currentTarget, g = [...f.querySelectorAll("input")].filter((m) => m.value !== "" && !m.value.trim());
1629
+ for (const m of g) {
1630
+ m.value = "";
1631
+ const k = At.find((I) => s.config.keys[I] === m.name);
1632
+ k && r(k, "");
1633
+ }
1634
+ if (g.length > 0 && !f.checkValidity()) {
1635
+ c.preventDefault(), f.reportValidity();
1636
+ return;
1637
+ }
1638
+ const b = new FormData(f), h = Object.fromEntries(b.entries());
1639
+ t({
1640
+ type: "address",
1641
+ value: h
1642
+ });
1643
+ },
1644
+ children: [u("div", {
1645
+ class: "bg-neutral-3 border-neutral-5 grid items-center gap-1.5 rounded-2xl border pb-2 pl-4 pr-3 pt-3 [grid-template-columns:min-content_1fr]",
1646
+ ref: i,
1647
+ children: At.map((c, f) => {
1648
+ const g = `isdk_${c}`, b = s.config.keys[c];
1649
+ return b ? u(we, {
1650
+ children: [u("label", {
1651
+ for: g,
1652
+ class: "text-neutral-11 [&:has(+*>input:focus)]:text-neutral-12 w-24 pb-2 text-xs uppercase leading-3 tracking-widest transition-colors",
1653
+ children: o(c)
1654
+ }), u("div", {
1655
+ class: "flex flex-col items-stretch gap-1.5",
1656
+ children: [c === "country" ? u("div", {
1657
+ class: "relative",
1658
+ children: [u("select", {
1659
+ class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 w-full flex-1 appearance-none rounded-lg border-solid bg-transparent bg-none px-3 py-1.5 text-base transition-colors focus:outline-none",
1660
+ name: b,
1661
+ id: g,
1662
+ defaultValue: e[c],
1663
+ onChange: (h) => r(c, h.currentTarget.value),
1664
+ required: !0,
1665
+ children: [e.country && !a.includes(e.country) ? u("option", {
1666
+ value: e[c],
1667
+ children: e[c]
1668
+ }) : u("option", {
1669
+ value: "",
1670
+ children: o("select_country")
1671
+ }), a.map((h) => u("option", {
1672
+ value: h,
1673
+ children: h
1674
+ }, h))]
1675
+ }), u("svg", {
1676
+ class: "text-neutral-12 absolute bottom-2.5 right-2 flex items-center justify-center",
1677
+ width: "16",
1678
+ height: "16",
1679
+ stroke: "currentColor",
1680
+ "stroke-width": "1.5",
1681
+ "stroke-linecap": "round",
1682
+ "stroke-linejoin": "round",
1683
+ viewBox: "0 0 16 16",
1684
+ fill: "none",
1685
+ xmlns: "http://www.w3.org/2000/svg",
1686
+ children: u("path", {
1687
+ d: "M4 6.5L8 10.5L12 6.5"
1688
+ })
1689
+ })]
1690
+ }) : u("input", {
1691
+ autoFocus: f === 0 ? !0 : void 0,
1692
+ class: "text-neutral-12 hover:bg-neutral-4 placeholder:text-neutral-8 focus:bg-neutral-5 flex-1 rounded-lg border-solid bg-transparent px-3 py-1.5 text-base transition-colors autofill:shadow-[inset_0_0_0_1000px_hsl(210_16.7%_97.6%)] focus:outline-none",
1693
+ name: b,
1694
+ id: g,
1695
+ defaultValue: e[c],
1696
+ onInput: (h) => r(c, h.currentTarget.value),
1697
+ required: c === "line2" ? s.config.line2Required === !0 : c !== "line3"
1698
+ }), f === At.length - 1 ? u("hr", {
1699
+ class: "m-0 w-full border-b border-b-transparent"
1700
+ }) : u("hr", {
1701
+ class: "border-b-neutral-5 m-0 w-full border-b border-solid"
1702
+ })]
1703
+ })]
1704
+ }) : null;
1705
+ })
1706
+ }), u("div", {
1707
+ class: "bg-neutral-1 sticky bottom-0 flex items-center py-2",
1708
+ children: [n, u(Re, {
1709
+ class: "ml-auto"
1710
+ })]
1711
+ })]
1712
+ });
1713
+ }, jt = () => {
1714
+ const e = he(null);
1715
+ return Nr(() => {
1716
+ var r;
1717
+ (r = e.current) == null || r.focus();
1718
+ }, []), e;
1719
+ }, Xr = ["true", "false"], Ps = /* @__PURE__ */ Jr(Xr), qs = "answer", Yr = "flex items-center flex-wrap gap-2 p-2.5", Qr = "min-w-0 max-w-full flex-auto", en = Rr(({
1720
+ label: e,
1721
+ ...r
1722
+ }, t) => u("button", {
1723
+ class: "bg-lowest ease-expo-out ring-divider text-neutral-12 active:ring-accent-7 active:bg-accent-2 active:text-accent-11 fr block w-full overflow-hidden rounded-2xl px-2 py-2.5 ring-2 transition-all selection:bg-transparent",
1724
+ ...r,
1725
+ ref: t,
1726
+ children: u("p", {
1727
+ class: "text-center text-base",
1728
+ children: e
1729
+ })
1730
+ })), $s = ({
1731
+ input: e,
1732
+ onSubmitSuccess: r
1733
+ }) => {
1734
+ const t = jt();
1735
+ return u("form", {
1736
+ noValidate: !0,
1737
+ class: "",
1738
+ onSubmit: (n) => {
1739
+ n.preventDefault();
1740
+ const s = Vn(n).value, i = Fs(Ps, s);
1741
+ r({
1742
+ type: "boolean",
1743
+ value: i === "true"
1744
+ });
1745
+ },
1746
+ children: [u("ul", {
1747
+ class: Yr,
1748
+ children: Xr.map((n, s) => u("li", {
1749
+ class: Qr,
1750
+ children: u(en, {
1751
+ ref: s === 0 ? t : null,
1752
+ type: "submit",
1753
+ name: qs,
1754
+ value: n,
1755
+ label: e.config.labels[n]
1756
+ }, n)
1757
+ }))
1758
+ }), e.config.optional && u("div", {
1759
+ class: "px-2 pb-2",
1760
+ children: u(Ee, {
1761
+ class: "relative w-full",
1762
+ type: "button",
1763
+ onClick: () => r(null)
1764
+ })
1765
+ })]
1766
+ });
1767
+ }, Us = (e) => new Promise((r, t) => {
1768
+ const n = new FileReader();
1769
+ n.onload = () => {
1770
+ if (typeof n.result != "string" || !n.result)
1771
+ return t(new Error("Invalid file"));
1772
+ r(n.result);
1773
+ }, n.onerror = t, n.readAsDataURL(e);
1774
+ }), nr = (e) => e.reduce((r, t) => r + t.sizeKb, 0), Ws = Ge("file"), sr = 3, gt = (e) => {
1775
+ const r = e.lastIndexOf(".");
1776
+ return r === -1 ? [e, ""] : [e.slice(0, r), e.slice(r)];
1777
+ }, zs = ({
1778
+ file: e,
1779
+ class: r,
1780
+ ...t
1781
+ }) => {
1782
+ const {
1783
+ t: n
1784
+ } = ee(), [s, i] = gt(e.name);
1785
+ return u("div", {
1786
+ class: Ke("bg-accent-1 outline-accent-4 flex max-w-full gap-2 overflow-hidden rounded-lg px-3 py-2 text-sm outline", r),
1787
+ ...t,
1788
+ children: [u("p", {
1789
+ class: "text-accent-12 flex flex-grow overflow-hidden",
1790
+ children: [u("span", {
1791
+ class: "sr-only",
1792
+ children: [n("file_name"), ": "]
1793
+ }), u("span", {
1794
+ class: "block truncate",
1795
+ children: s
1796
+ }), u("span", {
1797
+ children: i
1798
+ })]
1799
+ }), u("p", {
1800
+ class: "text-accent-11",
1801
+ children: [u("span", {
1802
+ class: "sr-only",
1803
+ children: [n("file_size"), ": "]
1804
+ }), qe(e.sizeKb)]
1805
+ })]
1806
+ });
1807
+ }, ar = ({
1808
+ class: e,
1809
+ ...r
1810
+ }) => u("li", {
1811
+ class: Ke("outline-neutral-6 text-neutral-11 bg-neutral-1 block rounded-md px-1 py-0.5 text-xs outline outline-1", e),
1812
+ ...r
1813
+ }), Ks = (e, r) => {
1814
+ const [t, n] = gt(e);
1815
+ return `${t.slice(0, r)}${n}`;
1816
+ }, ir = (e) => ({
1817
+ name: Ks(e.name, 42),
1818
+ sizeKb: e.size / 1e3
1819
+ }), Gs = [".heic", ".heif", ".jpg", ".jpeg", ".png", ".gif", ".webp", ".txt", ".rtf", ".odt", ".pages", ".zip"], Hs = (e, r, t) => {
1820
+ const n = gt(r.name)[1].toLowerCase(), s = [...t.map((a) => a.toLowerCase()), ...Gs], i = n === "" ? "none" : s.includes(n) ? n : "other";
1821
+ return `chatbot-file-refused:${e}:${i}`;
1822
+ }, Js = ({
1823
+ input: e,
1824
+ onSubmitSuccess: r,
1825
+ analytics: t
1826
+ }) => {
1827
+ var C;
1828
+ const n = (C = K.current$.value.flow) == null ? void 0 : C.data.submissions[e.key], [s, i] = ve(Ws(n) && n.value.length ? {
1829
+ status: "ready",
1830
+ files: n.value
1831
+ } : {
1832
+ status: "empty"
1833
+ }), a = he(0), o = s.status === "ready" ? s.files : [], c = s.status === "ready" || s.status === "pending" ? s.files : [], f = s.status === "error" ? s.error : void 0, g = c.length - sr, b = nr(c), h = jt(), {
1834
+ t: m
1835
+ } = ee(), k = (x) => {
1836
+ if (!x.length)
1837
+ return {
1838
+ reason: "required",
1839
+ error: {
1840
+ type: "required",
1841
+ message: m("validation_file")
1842
+ }
1843
+ };
1844
+ if (!Xt(x, e.config.extensions))
1845
+ return {
1846
+ reason: "type",
1847
+ file: x.find((y) => !Xt([y], e.config.extensions)),
1848
+ error: {
1849
+ type: "validate",
1850
+ message: m("validation_file_ext", {
1851
+ ext: e.config.extensions.join(", ")
1852
+ })
1853
+ }
1854
+ };
1855
+ if (x.some((y) => y.sizeKb === 0))
1856
+ return {
1857
+ reason: "empty",
1858
+ file: x.find((y) => y.sizeKb === 0),
1859
+ error: {
1860
+ type: "validate",
1861
+ message: m("validation_file_empty")
1862
+ }
1863
+ };
1864
+ if (e.config.fileSizeLimitKib && nr(x) > e.config.fileSizeLimitKib)
1865
+ return {
1866
+ reason: "size",
1867
+ error: {
1868
+ type: "max",
1869
+ message: m("validation_file_size", {
1870
+ size: qe(e.config.fileSizeLimitKib)
1871
+ })
1872
+ }
1873
+ };
1874
+ if (!e.config.allowMultiple && x.length > 1)
1875
+ return {
1876
+ reason: "count",
1877
+ error: {
1878
+ type: "invalid",
1879
+ message: m("validation_file_max", {
1880
+ count: 1
1881
+ })
1882
+ }
1883
+ };
1884
+ }, I = (x, y) => {
1885
+ var F, N;
1886
+ return t.log({
1887
+ event: "INTERACTION",
1888
+ properties: {
1889
+ tag: Hs(x, y, e.config.extensions)
1890
+ },
1891
+ customProperties: (N = (F = K.current$.peek().flow) == null ? void 0 : F.analytics) == null ? void 0 : N.customProperties
1892
+ });
1893
+ };
1894
+ return u("form", {
1895
+ class: "flex flex-col gap-1 p-2.5",
1896
+ onSubmit: (x) => {
1897
+ if (x.preventDefault(), s.status === "pending" || s.status === "error")
1898
+ return;
1899
+ const y = k(o);
1900
+ y ? i({
1901
+ status: "error",
1902
+ error: y.error
1903
+ }) : r({
1904
+ type: "file",
1905
+ value: o
1906
+ });
1907
+ },
1908
+ children: [u("div", {
1909
+ class: "flex items-center gap-2",
1910
+ children: [u("label", {
1911
+ ref: h,
1912
+ for: "dropzone-file",
1913
+ class: "border-neutral-8 bg-neutral-2 flex h-48 w-full cursor-pointer flex-col items-center justify-center overflow-hidden rounded-2xl border border-dashed p-4",
1914
+ children: [c.length > 0 ? u("ul", {
1915
+ class: "flex max-w-full flex-wrap justify-center gap-1 overflow-hidden p-1",
1916
+ children: [c.slice(0, sr).map((x) => {
1917
+ const [y, F] = gt(x.name);
1918
+ return u(ar, {
1919
+ class: "flex overflow-hidden",
1920
+ children: [u("span", {
1921
+ class: "block truncate",
1922
+ children: y
1923
+ }), u("span", {
1924
+ children: F
1925
+ })]
1926
+ });
1927
+ }), g > 0 ? u(ar, {
1928
+ children: m("file_more", {
1929
+ count: g
1930
+ })
1931
+ }) : null]
1932
+ }) : u("div", {
1933
+ class: "flex flex-col justify-center gap-4 pb-6 pt-5",
1934
+ children: [u("header", {
1935
+ class: "flex flex-col items-center gap-0",
1936
+ children: [u("svg", {
1937
+ class: "text-neutral-11 mb-1 h-8 w-8",
1938
+ "aria-hidden": "true",
1939
+ xmlns: "http://www.w3.org/2000/svg",
1940
+ fill: "none",
1941
+ viewBox: "0 0 20 16",
1942
+ children: u("path", {
1943
+ stroke: "currentColor",
1944
+ "stroke-linecap": "round",
1945
+ "stroke-linejoin": "round",
1946
+ "stroke-width": "1.5",
1947
+ d: "M13 13h3a3 3 0 0 0 0-6h-.025A5.56 5.56 0 0 0 16 6.5 5.5 5.5 0 0 0 5.207 5.021C5.137 5.017 5.071 5 5 5a4 4 0 0 0 0 8h2.167M10 15V6m0 0L8 8m2-2 2 2"
1948
+ })
1949
+ }), u("p", {
1950
+ class: "text-neutral-12 tracking-[-0.01em]",
1951
+ children: m("upload_file", {
1952
+ count: e.config.allowMultiple ? 2 : 1
1953
+ })
1954
+ }), e.config.fileSizeLimitKib ? u("p", {
1955
+ class: "text-neutral-11 text-xs",
1956
+ children: ["(", m("file_max_size", {
1957
+ size: qe(e.config.fileSizeLimitKib)
1958
+ }), ")"]
1959
+ }) : null]
1960
+ }), u("aside", {
1961
+ class: "flex flex-col items-center gap-2",
1962
+ children: [u("p", {
1963
+ id: "accepted-filetypes",
1964
+ class: "sr-only",
1965
+ children: m("file_extensions")
1966
+ }), u("ul", {
1967
+ "aria-describedby": "accepted-filetypes",
1968
+ class: "flex flex-wrap justify-center gap-2",
1969
+ children: e.config.extensions.map((x) => u("li", {
1970
+ class: "ring-lowest outline-neutral-6 text-neutral-11 bg-neutral-1 rounded-md px-1 py-0.5 text-[11px] uppercase tracking-wide outline outline-1 ring-2",
1971
+ children: x.replace(".", "")
1972
+ }))
1973
+ })]
1974
+ })]
1975
+ }), u("p", {
1976
+ role: "status",
1977
+ class: Ke("text-neutral-11 flex items-center gap-1.5 text-xs", c.length === 0 && "sr-only"),
1978
+ children: s.status === "pending" ? u(we, {
1979
+ children: [u(Rt, {
1980
+ "aria-hidden": "true",
1981
+ class: "h-4 w-4"
1982
+ }), m("file_preparing", {
1983
+ count: c.length
1984
+ })]
1985
+ }) : s.status === "ready" ? u(we, {
1986
+ children: [o.length > 1 ? m("file_total_size", {
1987
+ size: qe(b)
1988
+ }) : qe(b), u("span", {
1989
+ class: "sr-only",
1990
+ children: [". ", m("file_ready", {
1991
+ count: o.length
1992
+ })]
1993
+ })]
1994
+ }) : null
1995
+ }), u("input", {
1996
+ id: "dropzone-file",
1997
+ "aria-label": m("upload_file", {
1998
+ count: e.config.allowMultiple ? 2 : 1
1999
+ }),
2000
+ onInput: async (x) => {
2001
+ Ne(x.target instanceof HTMLInputElement);
2002
+ const y = x.target.files ? Array.from(x.target.files) : [];
2003
+ x.target.value = "";
2004
+ const [F] = y;
2005
+ if (!F)
2006
+ return;
2007
+ const N = ++a.current, V = s.status === "ready", T = y.map(ir), R = k(T);
2008
+ if (R)
2009
+ return I(R.reason, R.file ?? F), i({
2010
+ status: "error",
2011
+ error: R.error
2012
+ });
2013
+ i({
2014
+ status: "pending",
2015
+ files: T
2016
+ });
2017
+ let O;
2018
+ try {
2019
+ const q = await Promise.all(y.map(async (P) => {
2020
+ try {
2021
+ return {
2022
+ ...ir(P),
2023
+ data: await Us(P)
2024
+ };
2025
+ } catch (H) {
2026
+ throw O ?? (O = P), H;
2027
+ }
2028
+ }));
2029
+ a.current === N && i({
2030
+ status: "ready",
2031
+ files: q
2032
+ });
2033
+ } catch {
2034
+ if (a.current !== N)
2035
+ return;
2036
+ I("unreadable", O ?? F), i({
2037
+ status: "error",
2038
+ error: {
2039
+ type: "invalid",
2040
+ message: m(V ? "file_read_error_replacement" : "file_read_error")
2041
+ }
2042
+ });
2043
+ }
2044
+ },
2045
+ multiple: e.config.allowMultiple,
2046
+ accept: e.config.extensions.join(","),
2047
+ type: "file",
2048
+ class: "sr-only"
2049
+ })]
2050
+ }), u("div", {
2051
+ class: "flex h-full flex-col items-center gap-2",
2052
+ children: [u(Re, {
2053
+ disabled: o.length === 0
2054
+ }), e.config.optional && u(Ee, {
2055
+ class: "relative",
2056
+ onClick: () => r(null)
2057
+ })]
2058
+ })]
2059
+ }), u(He, {
2060
+ error: f
2061
+ })]
2062
+ });
2063
+ };
2064
+ var ot = (e) => e.type === "checkbox", Le = (e) => e instanceof Date, se = (e) => e == null;
2065
+ const tn = (e) => typeof e == "object";
2066
+ var X = (e) => !se(e) && !Array.isArray(e) && tn(e) && !Le(e), Zs = (e) => X(e) && e.target ? ot(e.target) ? e.target.checked : e.target.value : e, Xs = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, Ys = (e, r) => e.has(Xs(r)), Qs = (e) => {
2067
+ const r = e.constructor && e.constructor.prototype;
2068
+ return X(r) && r.hasOwnProperty("isPrototypeOf");
2069
+ }, Pt = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
2070
+ function Y(e) {
2071
+ if (e instanceof Date)
2072
+ return new Date(e);
2073
+ const r = typeof FileList < "u" && e instanceof FileList;
2074
+ if (Pt && (e instanceof Blob || r))
2075
+ return e;
2076
+ const t = Array.isArray(e);
2077
+ if (!t && !(X(e) && Qs(e)))
2078
+ return e;
2079
+ const n = t ? [] : Object.create(Object.getPrototypeOf(e));
2080
+ for (const s in e)
2081
+ Object.prototype.hasOwnProperty.call(e, s) && (n[s] = Y(e[s]));
2082
+ return n;
2083
+ }
2084
+ var bt = (e) => /^\w*$/.test(e), J = (e) => e === void 0, qt = (e) => Array.isArray(e) ? e.filter(Boolean) : [], $t = (e) => qt(e.replace(/["|']|\]/g, "").split(/\.|\[/)), S = (e, r, t) => {
2085
+ if (!r || !X(e))
2086
+ return t;
2087
+ const n = (bt(r) ? [r] : $t(r)).reduce((s, i) => se(s) ? s : s[i], e);
2088
+ return J(n) || n === e ? J(e[r]) ? t : e[r] : n;
2089
+ }, pe = (e) => typeof e == "boolean", ce = (e) => typeof e == "function", G = (e, r, t) => {
2090
+ let n = -1;
2091
+ const s = bt(r) ? [r] : $t(r), i = s.length, a = i - 1;
2092
+ for (; ++n < i; ) {
2093
+ const o = s[n];
2094
+ let c = t;
2095
+ if (n !== a) {
2096
+ const f = e[o];
2097
+ c = X(f) || Array.isArray(f) ? f : isNaN(+s[n + 1]) ? {} : [];
2098
+ }
2099
+ if (o === "__proto__" || o === "constructor" || o === "prototype")
2100
+ return;
2101
+ e[o] = c, e = e[o];
2102
+ }
2103
+ };
2104
+ const or = {
2105
+ BLUR: "blur",
2106
+ FOCUS_OUT: "focusout",
2107
+ CHANGE: "change"
2108
+ }, de = {
2109
+ onBlur: "onBlur",
2110
+ onChange: "onChange",
2111
+ onSubmit: "onSubmit",
2112
+ onTouched: "onTouched",
2113
+ all: "all"
2114
+ }, be = {
2115
+ max: "max",
2116
+ min: "min",
2117
+ maxLength: "maxLength",
2118
+ minLength: "minLength",
2119
+ pattern: "pattern",
2120
+ required: "required",
2121
+ validate: "validate"
2122
+ }, ea = re.createContext(null);
2123
+ ea.displayName = "HookFormControlContext";
2124
+ var ta = (e, r, t, n = !0) => {
2125
+ const s = {
2126
+ defaultValues: r._defaultValues
2127
+ };
2128
+ for (const i in e)
2129
+ Object.defineProperty(s, i, {
2130
+ get: () => {
2131
+ const a = i;
2132
+ return r._proxyFormState[a] !== de.all && (r._proxyFormState[a] = !n || de.all), t && (t[a] = !0), e[a];
2133
+ }
2134
+ });
2135
+ return s;
2136
+ };
2137
+ const ra = typeof window < "u" ? re.useLayoutEffect : re.useEffect;
2138
+ var oe = (e) => typeof e == "string", na = (e, r, t, n, s) => oe(e) ? (n && r.watch.add(e), S(t, e, s)) : Array.isArray(e) ? e.map((i) => (n && r.watch.add(i), S(t, i))) : (n && (r.watchAll = !0), t), Lt = (e) => se(e) || !tn(e);
2139
+ function Se(e, r, t = /* @__PURE__ */ new WeakSet()) {
2140
+ if (Lt(e) || Lt(r))
2141
+ return Object.is(e, r);
2142
+ if (Le(e) && Le(r))
2143
+ return Object.is(e.getTime(), r.getTime());
2144
+ const n = Object.keys(e), s = Object.keys(r);
2145
+ if (n.length !== s.length)
2146
+ return !1;
2147
+ if (t.has(e) || t.has(r))
2148
+ return !0;
2149
+ t.add(e), t.add(r);
2150
+ for (const i of n) {
2151
+ const a = e[i];
2152
+ if (!s.includes(i))
2153
+ return !1;
2154
+ if (i !== "ref") {
2155
+ const o = r[i];
2156
+ if (Le(a) && Le(o) || X(a) && X(o) || Array.isArray(a) && Array.isArray(o) ? !Se(a, o, t) : !Object.is(a, o))
2157
+ return !1;
2158
+ }
2159
+ }
2160
+ return !0;
2161
+ }
2162
+ const sa = re.createContext(null);
2163
+ sa.displayName = "HookFormContext";
2164
+ var rn = (e, r, t, n, s) => r ? {
2165
+ ...t[e],
2166
+ types: {
2167
+ ...t[e] && t[e].types ? t[e].types : {},
2168
+ [n]: s || !0
2169
+ }
2170
+ } : {}, at = (e) => Array.isArray(e) ? e : [e], lr = () => {
2171
+ let e = [];
2172
+ return {
2173
+ get observers() {
2174
+ return e;
2175
+ },
2176
+ next: (s) => {
2177
+ for (const i of e)
2178
+ i.next && i.next(s);
2179
+ },
2180
+ subscribe: (s) => (e.push(s), {
2181
+ unsubscribe: () => {
2182
+ e = e.filter((i) => i !== s);
2183
+ }
2184
+ }),
2185
+ unsubscribe: () => {
2186
+ e = [];
2187
+ }
2188
+ };
2189
+ };
2190
+ function nn(e, r) {
2191
+ const t = {};
2192
+ for (const n in e)
2193
+ if (e.hasOwnProperty(n)) {
2194
+ const s = e[n], i = r[n];
2195
+ if (s && X(s) && i) {
2196
+ const a = nn(s, i);
2197
+ X(a) && (t[n] = a);
2198
+ } else
2199
+ e[n] && (t[n] = i);
2200
+ }
2201
+ return t;
2202
+ }
2203
+ var ne = (e) => X(e) && !Object.keys(e).length, Ut = (e) => e.type === "file", ft = (e) => {
2204
+ if (!Pt)
2205
+ return !1;
2206
+ const r = e ? e.ownerDocument : 0;
2207
+ return e instanceof (r && r.defaultView ? r.defaultView.HTMLElement : HTMLElement);
2208
+ }, sn = (e) => e.type === "select-multiple", Wt = (e) => e.type === "radio", aa = (e) => Wt(e) || ot(e), Et = (e) => ft(e) && e.isConnected;
2209
+ function ia(e, r) {
2210
+ const t = r.slice(0, -1).length;
2211
+ let n = 0;
2212
+ for (; n < t; )
2213
+ e = J(e) ? n++ : e[r[n++]];
2214
+ return e;
2215
+ }
2216
+ function oa(e) {
2217
+ for (const r in e)
2218
+ if (e.hasOwnProperty(r) && !J(e[r]))
2219
+ return !1;
2220
+ return !0;
2221
+ }
2222
+ function Z(e, r) {
2223
+ const t = Array.isArray(r) ? r : bt(r) ? [r] : $t(r), n = t.length === 1 ? e : ia(e, t), s = t.length - 1, i = t[s];
2224
+ return n && delete n[i], s !== 0 && (X(n) && ne(n) || Array.isArray(n) && oa(n)) && Z(e, t.slice(0, -1)), e;
2225
+ }
2226
+ var la = (e) => {
2227
+ for (const r in e)
2228
+ if (ce(e[r]))
2229
+ return !0;
2230
+ return !1;
2231
+ };
2232
+ function an(e) {
2233
+ return Array.isArray(e) || X(e) && !la(e);
2234
+ }
2235
+ function Nt(e, r = {}) {
2236
+ for (const t in e) {
2237
+ const n = e[t];
2238
+ an(n) ? (r[t] = Array.isArray(n) ? [] : {}, Nt(n, r[t])) : J(n) || (r[t] = !0);
2239
+ }
2240
+ return r;
2241
+ }
2242
+ function Pe(e, r, t) {
2243
+ t || (t = Nt(r));
2244
+ for (const n in e) {
2245
+ const s = e[n];
2246
+ if (an(s))
2247
+ J(r) || Lt(t[n]) ? t[n] = Nt(s, Array.isArray(s) ? [] : {}) : Pe(s, se(r) ? {} : r[n], t[n]);
2248
+ else {
2249
+ const i = r[n];
2250
+ t[n] = !Se(s, i);
2251
+ }
2252
+ }
2253
+ return t;
2254
+ }
2255
+ const ur = {
2256
+ value: !1,
2257
+ isValid: !1
2258
+ }, cr = { value: !0, isValid: !0 };
2259
+ var on = (e) => {
2260
+ if (Array.isArray(e)) {
2261
+ if (e.length > 1) {
2262
+ const r = e.filter((t) => t && t.checked && !t.disabled).map((t) => t.value);
2263
+ return { value: r, isValid: !!r.length };
2264
+ }
2265
+ return e[0].checked && !e[0].disabled ? (
2266
+ // @ts-expect-error expected to work in the browser
2267
+ e[0].attributes && !J(e[0].attributes.value) ? J(e[0].value) || e[0].value === "" ? cr : { value: e[0].value, isValid: !0 } : cr
2268
+ ) : ur;
2269
+ }
2270
+ return ur;
2271
+ }, ln = (e, { valueAsNumber: r, valueAsDate: t, setValueAs: n }) => J(e) ? e : r ? e === "" ? NaN : e && +e : t && oe(e) ? new Date(e) : n ? n(e) : e;
2272
+ const dr = {
2273
+ isValid: !1,
2274
+ value: null
2275
+ };
2276
+ var un = (e) => Array.isArray(e) ? e.reduce((r, t) => t && t.checked && !t.disabled ? {
2277
+ isValid: !0,
2278
+ value: t.value
2279
+ } : r, dr) : dr;
2280
+ function fr(e) {
2281
+ const r = e.ref;
2282
+ return Ut(r) ? r.files : Wt(r) ? un(e.refs).value : sn(r) ? [...r.selectedOptions].map(({ value: t }) => t) : ot(r) ? on(e.refs).value : ln(J(r.value) ? e.ref.value : r.value, e);
2283
+ }
2284
+ var ua = (e, r, t, n) => {
2285
+ const s = {};
2286
+ for (const i of e) {
2287
+ const a = S(r, i);
2288
+ a && G(s, i, a._f);
2289
+ }
2290
+ return {
2291
+ criteriaMode: t,
2292
+ names: [...e],
2293
+ fields: s,
2294
+ shouldUseNativeValidation: n
2295
+ };
2296
+ }, pt = (e) => e instanceof RegExp, tt = (e) => J(e) ? e : pt(e) ? e.source : X(e) ? pt(e.value) ? e.value.source : e.value : e, pr = (e) => ({
2297
+ isOnSubmit: !e || e === de.onSubmit,
2298
+ isOnBlur: e === de.onBlur,
2299
+ isOnChange: e === de.onChange,
2300
+ isOnAll: e === de.all,
2301
+ isOnTouch: e === de.onTouched
2302
+ });
2303
+ const hr = "AsyncFunction";
2304
+ var ca = (e) => !!e && !!e.validate && !!(ce(e.validate) && e.validate.constructor.name === hr || X(e.validate) && Object.values(e.validate).find((r) => r.constructor.name === hr)), da = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), mr = (e, r, t) => !t && (r.watchAll || r.watch.has(e) || [...r.watch].some((n) => e.startsWith(n) && /^\.\w+/.test(e.slice(n.length))));
2305
+ const it = (e, r, t, n) => {
2306
+ for (const s of t || Object.keys(e)) {
2307
+ const i = S(e, s);
2308
+ if (i) {
2309
+ const { _f: a, ...o } = i;
2310
+ if (a) {
2311
+ if (a.refs && a.refs[0] && r(a.refs[0], s) && !n)
2312
+ return !0;
2313
+ if (a.ref && r(a.ref, a.name) && !n)
2314
+ return !0;
2315
+ if (it(o, r))
2316
+ break;
2317
+ } else if (X(o) && it(o, r))
2318
+ break;
2319
+ }
2320
+ }
2321
+ };
2322
+ function yr(e, r, t) {
2323
+ const n = S(e, t);
2324
+ if (n || bt(t))
2325
+ return {
2326
+ error: n,
2327
+ name: t
2328
+ };
2329
+ const s = t.split(".");
2330
+ for (; s.length; ) {
2331
+ const i = s.join("."), a = S(r, i), o = S(e, i);
2332
+ if (a && !Array.isArray(a) && t !== i)
2333
+ return { name: t };
2334
+ if (o && o.type)
2335
+ return {
2336
+ name: i,
2337
+ error: o
2338
+ };
2339
+ if (o && o.root && o.root.type)
2340
+ return {
2341
+ name: `${i}.root`,
2342
+ error: o.root
2343
+ };
2344
+ s.pop();
2345
+ }
2346
+ return {
2347
+ name: t
2348
+ };
2349
+ }
2350
+ var fa = (e, r, t, n) => {
2351
+ t(e);
2352
+ const { name: s, ...i } = e;
2353
+ return ne(i) || Object.keys(i).length >= Object.keys(r).length || Object.keys(i).find((a) => r[a] === (!n || de.all));
2354
+ }, pa = (e, r, t) => !e || !r || e === r || at(e).some((n) => n && (t ? n === r : n.startsWith(r) || r.startsWith(n))), ha = (e, r, t, n, s) => s.isOnAll ? !1 : !t && s.isOnTouch ? !(r || e) : (t ? n.isOnBlur : s.isOnBlur) ? !e : (t ? n.isOnChange : s.isOnChange) ? e : !0, ma = (e, r) => !qt(S(e, r)).length && Z(e, r), ya = (e, r, t) => {
2355
+ const n = at(S(e, t));
2356
+ return G(n, "root", r[t]), G(e, t, n), e;
2357
+ };
2358
+ function gr(e, r, t = "validate") {
2359
+ if (oe(e) || Array.isArray(e) && e.every(oe) || pe(e) && !e)
2360
+ return {
2361
+ type: t,
2362
+ message: oe(e) ? e : "",
2363
+ ref: r
2364
+ };
2365
+ }
2366
+ var je = (e) => X(e) && !pt(e) ? e : {
2367
+ value: e,
2368
+ message: ""
2369
+ }, br = async (e, r, t, n, s, i) => {
2370
+ const { ref: a, refs: o, required: c, maxLength: f, minLength: g, min: b, max: h, pattern: m, validate: k, name: I, valueAsNumber: C, mount: x } = e._f, y = S(t, I);
2371
+ if (!x || r.has(I))
2372
+ return {};
2373
+ const F = o ? o[0] : a, N = (M) => {
2374
+ s && F.reportValidity && (F.setCustomValidity(pe(M) ? "" : M || ""), F.reportValidity());
2375
+ }, V = {}, T = Wt(a), R = ot(a), O = T || R, q = (C || Ut(a)) && J(a.value) && J(y) || ft(a) && a.value === "" || y === "" || Array.isArray(y) && !y.length, P = rn.bind(null, I, n, V), H = (M, A, B, $ = be.maxLength, U = be.minLength) => {
2376
+ const j = M ? A : B;
2377
+ V[I] = {
2378
+ type: M ? $ : U,
2379
+ message: j,
2380
+ ref: a,
2381
+ ...P(M ? $ : U, j)
2382
+ };
2383
+ };
2384
+ if (i ? !Array.isArray(y) || !y.length : c && (!O && (q || se(y)) || pe(y) && !y || R && !on(o).isValid || T && !un(o).isValid)) {
2385
+ const { value: M, message: A } = oe(c) ? { value: !!c, message: c } : je(c);
2386
+ if (M && (V[I] = {
2387
+ type: be.required,
2388
+ message: A,
2389
+ ref: F,
2390
+ ...P(be.required, A)
2391
+ }, !n))
2392
+ return N(A), V;
2393
+ }
2394
+ if (!q && (!se(b) || !se(h))) {
2395
+ let M, A;
2396
+ const B = je(h), $ = je(b);
2397
+ if (!se(y) && !isNaN(y)) {
2398
+ const U = a.valueAsNumber || y && +y;
2399
+ se(B.value) || (M = U > B.value), se($.value) || (A = U < $.value);
2400
+ } else {
2401
+ const U = a.valueAsDate || new Date(y), j = (ue) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + ue), D = a.type == "time", le = a.type == "week";
2402
+ oe(B.value) && y && (M = D ? j(y) > j(B.value) : le ? y > B.value : U > new Date(B.value)), oe($.value) && y && (A = D ? j(y) < j($.value) : le ? y < $.value : U < new Date($.value));
2403
+ }
2404
+ if ((M || A) && (H(!!M, B.message, $.message, be.max, be.min), !n))
2405
+ return N(V[I].message), V;
2406
+ }
2407
+ if ((f || g) && !q && (oe(y) || i && Array.isArray(y))) {
2408
+ const M = je(f), A = je(g), B = !se(M.value) && y.length > +M.value, $ = !se(A.value) && y.length < +A.value;
2409
+ if ((B || $) && (H(B, M.message, A.message), !n))
2410
+ return N(V[I].message), V;
2411
+ }
2412
+ if (m && !q && oe(y)) {
2413
+ const { value: M, message: A } = je(m);
2414
+ if (pt(M) && !y.match(M) && (V[I] = {
2415
+ type: be.pattern,
2416
+ message: A,
2417
+ ref: a,
2418
+ ...P(be.pattern, A)
2419
+ }, !n))
2420
+ return N(A), V;
2421
+ }
2422
+ if (k) {
2423
+ if (ce(k)) {
2424
+ const M = await k(y, t), A = gr(M, F);
2425
+ if (A && (V[I] = {
2426
+ ...A,
2427
+ ...P(be.validate, A.message)
2428
+ }, !n))
2429
+ return N(A.message), V;
2430
+ } else if (X(k)) {
2431
+ let M = {};
2432
+ for (const A in k) {
2433
+ if (!ne(M) && !n)
2434
+ break;
2435
+ const B = gr(await k[A](y, t), F, A);
2436
+ B && (M = {
2437
+ ...B,
2438
+ ...P(A, B.message)
2439
+ }, N(B.message), n && (V[I] = M));
2440
+ }
2441
+ if (!ne(M) && (V[I] = {
2442
+ ref: F,
2443
+ ...M
2444
+ }, !n))
2445
+ return V;
2446
+ }
2447
+ }
2448
+ return N(!0), V;
2449
+ };
2450
+ const ga = {
2451
+ mode: de.onSubmit,
2452
+ reValidateMode: de.onChange,
2453
+ shouldFocusError: !0
2454
+ };
2455
+ function ba(e = {}) {
2456
+ let r = {
2457
+ ...ga,
2458
+ ...e
2459
+ }, t = {
2460
+ submitCount: 0,
2461
+ isDirty: !1,
2462
+ isReady: !1,
2463
+ isLoading: ce(r.defaultValues),
2464
+ isValidating: !1,
2465
+ isSubmitted: !1,
2466
+ isSubmitting: !1,
2467
+ isSubmitSuccessful: !1,
2468
+ isValid: !1,
2469
+ touchedFields: {},
2470
+ dirtyFields: {},
2471
+ validatingFields: {},
2472
+ errors: r.errors || {},
2473
+ disabled: r.disabled || !1
2474
+ }, n = {}, s = X(r.defaultValues) || X(r.values) ? Y(r.defaultValues || r.values) || {} : {}, i = r.shouldUnregister ? {} : Y(s), a = {
2475
+ action: !1,
2476
+ mount: !1,
2477
+ watch: !1,
2478
+ keepIsValid: !1
2479
+ }, o = {
2480
+ mount: /* @__PURE__ */ new Set(),
2481
+ disabled: /* @__PURE__ */ new Set(),
2482
+ unMount: /* @__PURE__ */ new Set(),
2483
+ array: /* @__PURE__ */ new Set(),
2484
+ watch: /* @__PURE__ */ new Set()
2485
+ }, c, f = 0;
2486
+ const g = {
2487
+ isDirty: !1,
2488
+ dirtyFields: !1,
2489
+ validatingFields: !1,
2490
+ touchedFields: !1,
2491
+ isValidating: !1,
2492
+ isValid: !1,
2493
+ errors: !1
2494
+ }, b = {
2495
+ ...g
2496
+ };
2497
+ let h = {
2498
+ ...b
2499
+ };
2500
+ const m = {
2501
+ array: lr(),
2502
+ state: lr()
2503
+ }, k = r.criteriaMode === de.all, I = (l) => (d) => {
2504
+ clearTimeout(f), f = setTimeout(l, d);
2505
+ }, C = async (l) => {
2506
+ if (!a.keepIsValid && !r.disabled && (b.isValid || h.isValid || l)) {
2507
+ let d;
2508
+ r.resolver ? (d = ne((await O()).errors), x()) : d = await P(n, !0), d !== t.isValid && m.state.next({
2509
+ isValid: d
2510
+ });
2511
+ }
2512
+ }, x = (l, d) => {
2513
+ !r.disabled && (b.isValidating || b.validatingFields || h.isValidating || h.validatingFields) && ((l || Array.from(o.mount)).forEach((p) => {
2514
+ p && (d ? G(t.validatingFields, p, d) : Z(t.validatingFields, p));
2515
+ }), m.state.next({
2516
+ validatingFields: t.validatingFields,
2517
+ isValidating: !ne(t.validatingFields)
2518
+ }));
2519
+ }, y = (l, d = [], p, _, w = !0, v = !0) => {
2520
+ if (_ && p && !r.disabled) {
2521
+ if (a.action = !0, v && Array.isArray(S(n, l))) {
2522
+ const E = p(S(n, l), _.argA, _.argB);
2523
+ w && G(n, l, E);
2524
+ }
2525
+ if (v && Array.isArray(S(t.errors, l))) {
2526
+ const E = p(S(t.errors, l), _.argA, _.argB);
2527
+ w && G(t.errors, l, E), ma(t.errors, l);
2528
+ }
2529
+ if ((b.touchedFields || h.touchedFields) && v && Array.isArray(S(t.touchedFields, l))) {
2530
+ const E = p(S(t.touchedFields, l), _.argA, _.argB);
2531
+ w && G(t.touchedFields, l, E);
2532
+ }
2533
+ (b.dirtyFields || h.dirtyFields) && (t.dirtyFields = Pe(s, i)), m.state.next({
2534
+ name: l,
2535
+ isDirty: M(l, d),
2536
+ dirtyFields: t.dirtyFields,
2537
+ errors: t.errors,
2538
+ isValid: t.isValid
2539
+ });
2540
+ } else
2541
+ G(i, l, d);
2542
+ }, F = (l, d) => {
2543
+ G(t.errors, l, d), m.state.next({
2544
+ errors: t.errors
2545
+ });
2546
+ }, N = (l) => {
2547
+ t.errors = l, m.state.next({
2548
+ errors: t.errors,
2549
+ isValid: !1
2550
+ });
2551
+ }, V = (l, d, p, _) => {
2552
+ const w = S(n, l);
2553
+ if (w) {
2554
+ const v = S(i, l, J(p) ? S(s, l) : p);
2555
+ J(v) || _ && _.defaultChecked || d ? G(i, l, d ? v : fr(w._f)) : $(l, v), a.mount && !a.action && C();
2556
+ }
2557
+ }, T = (l, d, p, _, w) => {
2558
+ let v = !1, E = !1;
2559
+ const W = {
2560
+ name: l
2561
+ };
2562
+ if (!r.disabled) {
2563
+ if (!p || _) {
2564
+ (b.isDirty || h.isDirty) && (E = t.isDirty, t.isDirty = W.isDirty = M(), v = E !== W.isDirty);
2565
+ const z = Se(S(s, l), d);
2566
+ E = !!S(t.dirtyFields, l), z ? Z(t.dirtyFields, l) : G(t.dirtyFields, l, !0), W.dirtyFields = t.dirtyFields, v = v || (b.dirtyFields || h.dirtyFields) && E !== !z;
2567
+ }
2568
+ if (p) {
2569
+ const z = S(t.touchedFields, l);
2570
+ z || (G(t.touchedFields, l, p), W.touchedFields = t.touchedFields, v = v || (b.touchedFields || h.touchedFields) && z !== p);
2571
+ }
2572
+ v && w && m.state.next(W);
2573
+ }
2574
+ return v ? W : {};
2575
+ }, R = (l, d, p, _) => {
2576
+ const w = S(t.errors, l), v = (b.isValid || h.isValid) && pe(d) && t.isValid !== d;
2577
+ if (r.delayError && p ? (c = I(() => F(l, p)), c(r.delayError)) : (clearTimeout(f), c = null, p ? G(t.errors, l, p) : Z(t.errors, l)), (p ? !Se(w, p) : w) || !ne(_) || v) {
2578
+ const E = {
2579
+ ..._,
2580
+ ...v && pe(d) ? { isValid: d } : {},
2581
+ errors: t.errors,
2582
+ name: l
2583
+ };
2584
+ t = {
2585
+ ...t,
2586
+ ...E
2587
+ }, m.state.next(E);
2588
+ }
2589
+ }, O = async (l) => (x(l, !0), await r.resolver(i, r.context, ua(l || o.mount, n, r.criteriaMode, r.shouldUseNativeValidation))), q = async (l) => {
2590
+ const { errors: d } = await O(l);
2591
+ if (x(l), l)
2592
+ for (const p of l) {
2593
+ const _ = S(d, p);
2594
+ _ ? G(t.errors, p, _) : Z(t.errors, p);
2595
+ }
2596
+ else
2597
+ t.errors = d;
2598
+ return d;
2599
+ }, P = async (l, d, p = {
2600
+ valid: !0
2601
+ }) => {
2602
+ for (const _ in l) {
2603
+ const w = l[_];
2604
+ if (w) {
2605
+ const { _f: v, ...E } = w;
2606
+ if (v) {
2607
+ const W = o.array.has(v.name), z = w._f && ca(w._f);
2608
+ z && b.validatingFields && x([v.name], !0);
2609
+ const te = await br(w, o.disabled, i, k, r.shouldUseNativeValidation && !d, W);
2610
+ if (z && b.validatingFields && x([v.name]), te[v.name] && (p.valid = !1, d || e.shouldUseNativeValidation))
2611
+ break;
2612
+ !d && (S(te, v.name) ? W ? ya(t.errors, te, v.name) : G(t.errors, v.name, te[v.name]) : Z(t.errors, v.name));
2613
+ }
2614
+ !ne(E) && await P(E, d, p);
2615
+ }
2616
+ }
2617
+ return p.valid;
2618
+ }, H = () => {
2619
+ for (const l of o.unMount) {
2620
+ const d = S(n, l);
2621
+ d && (d._f.refs ? d._f.refs.every((p) => !Et(p)) : !Et(d._f.ref)) && Te(l);
2622
+ }
2623
+ o.unMount = /* @__PURE__ */ new Set();
2624
+ }, M = (l, d) => !r.disabled && (l && d && G(i, l, d), !Se(Je(), s)), A = (l, d, p) => na(l, o, {
2625
+ ...a.mount ? i : J(d) ? s : oe(l) ? { [l]: d } : d
2626
+ }, p, d), B = (l) => qt(S(a.mount ? i : s, l, r.shouldUnregister ? S(s, l, []) : [])), $ = (l, d, p = {}) => {
2627
+ const _ = S(n, l);
2628
+ let w = d;
2629
+ if (_) {
2630
+ const v = _._f;
2631
+ v && (!v.disabled && G(i, l, ln(d, v)), w = ft(v.ref) && se(d) ? "" : d, sn(v.ref) ? [...v.ref.options].forEach((E) => E.selected = w.includes(E.value)) : v.refs ? ot(v.ref) ? v.refs.forEach((E) => {
2632
+ (!E.defaultChecked || !E.disabled) && (Array.isArray(w) ? E.checked = !!w.find((W) => W === E.value) : E.checked = w === E.value || !!w);
2633
+ }) : v.refs.forEach((E) => E.checked = E.value === w) : Ut(v.ref) ? v.ref.value = "" : (v.ref.value = w, v.ref.type || m.state.next({
2634
+ name: l,
2635
+ values: Y(i)
2636
+ })));
2637
+ }
2638
+ (p.shouldDirty || p.shouldTouch) && T(l, w, p.shouldTouch, p.shouldDirty, !0), p.shouldValidate && ue(l);
2639
+ }, U = (l, d, p) => {
2640
+ for (const _ in d) {
2641
+ if (!d.hasOwnProperty(_))
2642
+ return;
2643
+ const w = d[_], v = l + "." + _, E = S(n, v);
2644
+ (o.array.has(l) || X(w) || E && !E._f) && !Le(w) ? U(v, w, p) : $(v, w, p);
2645
+ }
2646
+ }, j = (l, d, p = {}) => {
2647
+ const _ = S(n, l), w = o.array.has(l), v = Y(d);
2648
+ G(i, l, v), w ? (m.array.next({
2649
+ name: l,
2650
+ values: Y(i)
2651
+ }), (b.isDirty || b.dirtyFields || h.isDirty || h.dirtyFields) && p.shouldDirty && m.state.next({
2652
+ name: l,
2653
+ dirtyFields: Pe(s, i),
2654
+ isDirty: M(l, v)
2655
+ })) : _ && !_._f && !se(v) ? U(l, v, p) : $(l, v, p), mr(l, o) ? m.state.next({
2656
+ ...t,
2657
+ name: l,
2658
+ values: Y(i)
2659
+ }) : m.state.next({
2660
+ name: a.mount ? l : void 0,
2661
+ values: Y(i)
2662
+ });
2663
+ }, D = async (l) => {
2664
+ a.mount = !0;
2665
+ const d = l.target;
2666
+ let p = d.name, _ = !0;
2667
+ const w = S(n, p), v = (z) => {
2668
+ _ = Number.isNaN(z) || Le(z) && isNaN(z.getTime()) || Se(z, S(i, p, z));
2669
+ }, E = pr(r.mode), W = pr(r.reValidateMode);
2670
+ if (w) {
2671
+ let z, te;
2672
+ const Me = d.type ? fr(w._f) : Zs(l), Ce = l.type === or.BLUR || l.type === or.FOCUS_OUT, dn = !da(w._f) && !r.resolver && !S(t.errors, p) && !w._f.deps || ha(Ce, S(t.touchedFields, p), t.isSubmitted, W, E), wt = mr(p, o, Ce);
2673
+ G(i, p, Me), Ce ? (!d || !d.readOnly) && (w._f.onBlur && w._f.onBlur(l), c && c(0)) : w._f.onChange && w._f.onChange(l);
2674
+ const _t = T(p, Me, Ce), fn = !ne(_t) || wt;
2675
+ if (!Ce && m.state.next({
2676
+ name: p,
2677
+ type: l.type,
2678
+ values: Y(i)
2679
+ }), dn)
2680
+ return (b.isValid || h.isValid) && (r.mode === "onBlur" ? Ce && C() : Ce || C()), fn && m.state.next({ name: p, ...wt ? {} : _t });
2681
+ if (!Ce && wt && m.state.next({ ...t }), r.resolver) {
2682
+ const { errors: Kt } = await O([p]);
2683
+ if (x([p]), v(Me), _) {
2684
+ const pn = yr(t.errors, n, p), Gt = yr(Kt, n, pn.name || p);
2685
+ z = Gt.error, p = Gt.name, te = ne(Kt);
2686
+ }
2687
+ } else
2688
+ x([p], !0), z = (await br(w, o.disabled, i, k, r.shouldUseNativeValidation))[p], x([p]), v(Me), _ && (z ? te = !1 : (b.isValid || h.isValid) && (te = await P(n, !0)));
2689
+ _ && (w._f.deps && (!Array.isArray(w._f.deps) || w._f.deps.length > 0) && ue(w._f.deps), R(p, te, z, _t));
2690
+ }
2691
+ }, le = (l, d) => {
2692
+ if (S(t.errors, d) && l.focus)
2693
+ return l.focus(), 1;
2694
+ }, ue = async (l, d = {}) => {
2695
+ let p, _;
2696
+ const w = at(l);
2697
+ if (r.resolver) {
2698
+ const v = await q(J(l) ? l : w);
2699
+ p = ne(v), _ = l ? !w.some((E) => S(v, E)) : p;
2700
+ } else
2701
+ l ? (_ = (await Promise.all(w.map(async (v) => {
2702
+ const E = S(n, v);
2703
+ return await P(E && E._f ? { [v]: E } : E);
2704
+ }))).every(Boolean), !(!_ && !t.isValid) && C()) : _ = p = await P(n);
2705
+ return m.state.next({
2706
+ ...!oe(l) || (b.isValid || h.isValid) && p !== t.isValid ? {} : { name: l },
2707
+ ...r.resolver || !l ? { isValid: p } : {},
2708
+ errors: t.errors
2709
+ }), d.shouldFocus && !_ && it(n, le, l ? w : o.mount), _;
2710
+ }, Je = (l, d) => {
2711
+ let p = {
2712
+ ...a.mount ? i : s
2713
+ };
2714
+ return d && (p = nn(d.dirtyFields ? t.dirtyFields : t.touchedFields, p)), J(l) ? p : oe(l) ? S(p, l) : l.map((_) => S(p, _));
2715
+ }, _e = (l, d) => ({
2716
+ invalid: !!S((d || t).errors, l),
2717
+ isDirty: !!S((d || t).dirtyFields, l),
2718
+ error: S((d || t).errors, l),
2719
+ isValidating: !!S(t.validatingFields, l),
2720
+ isTouched: !!S((d || t).touchedFields, l)
2721
+ }), lt = (l) => {
2722
+ const d = l ? at(l) : void 0;
2723
+ d == null || d.forEach((p) => Z(t.errors, p)), d ? d.forEach((p) => {
2724
+ m.state.next({
2725
+ name: p,
2726
+ errors: t.errors
2727
+ });
2728
+ }) : m.state.next({
2729
+ errors: {}
2730
+ });
2731
+ }, Ze = (l, d, p) => {
2732
+ const _ = (S(n, l, { _f: {} })._f || {}).ref, w = S(t.errors, l) || {}, { ref: v, message: E, type: W, ...z } = w;
2733
+ G(t.errors, l, {
2734
+ ...z,
2735
+ ...d,
2736
+ ref: _
2737
+ }), m.state.next({
2738
+ name: l,
2739
+ errors: t.errors,
2740
+ isValid: !1
2741
+ }), p && p.shouldFocus && _ && _.focus && _.focus();
2742
+ }, Xe = (l, d) => ce(l) ? m.state.subscribe({
2743
+ next: (p) => "values" in p && l(A(void 0, d), p)
2744
+ }) : A(l, d, !0), Fe = (l) => m.state.subscribe({
2745
+ next: (d) => {
2746
+ pa(l.name, d.name, l.exact) && fa(d, l.formState || b, ke, l.reRenderRoot) && l.callback({
2747
+ values: { ...i },
2748
+ ...t,
2749
+ ...d,
2750
+ defaultValues: s
2751
+ });
2752
+ }
2753
+ }).unsubscribe, De = (l) => (a.mount = !0, h = {
2754
+ ...h,
2755
+ ...l.formState
2756
+ }, Fe({
2757
+ ...l,
2758
+ formState: {
2759
+ ...g,
2760
+ ...l.formState
2761
+ }
2762
+ })), Te = (l, d = {}) => {
2763
+ for (const p of l ? at(l) : o.mount)
2764
+ o.mount.delete(p), o.array.delete(p), d.keepValue || (Z(n, p), Z(i, p)), !d.keepError && Z(t.errors, p), !d.keepDirty && Z(t.dirtyFields, p), !d.keepTouched && Z(t.touchedFields, p), !d.keepIsValidating && Z(t.validatingFields, p), !r.shouldUnregister && !d.keepDefaultValue && Z(s, p);
2765
+ m.state.next({
2766
+ values: Y(i)
2767
+ }), m.state.next({
2768
+ ...t,
2769
+ ...d.keepDirty ? { isDirty: M() } : {}
2770
+ }), !d.keepIsValid && C();
2771
+ }, Ye = ({ disabled: l, name: d }) => {
2772
+ if (pe(l) && a.mount || l || o.disabled.has(d)) {
2773
+ const w = o.disabled.has(d) !== !!l;
2774
+ l ? o.disabled.add(d) : o.disabled.delete(d), w && a.mount && !a.action && C();
2775
+ }
2776
+ }, Oe = (l, d = {}) => {
2777
+ let p = S(n, l);
2778
+ const _ = pe(d.disabled) || pe(r.disabled);
2779
+ return G(n, l, {
2780
+ ...p || {},
2781
+ _f: {
2782
+ ...p && p._f ? p._f : { ref: { name: l } },
2783
+ name: l,
2784
+ mount: !0,
2785
+ ...d
2786
+ }
2787
+ }), o.mount.add(l), p ? Ye({
2788
+ disabled: pe(d.disabled) ? d.disabled : r.disabled,
2789
+ name: l
2790
+ }) : V(l, !0, d.value), {
2791
+ ..._ ? { disabled: d.disabled || r.disabled } : {},
2792
+ ...r.progressive ? {
2793
+ required: !!d.required,
2794
+ min: tt(d.min),
2795
+ max: tt(d.max),
2796
+ minLength: tt(d.minLength),
2797
+ maxLength: tt(d.maxLength),
2798
+ pattern: tt(d.pattern)
2799
+ } : {},
2800
+ name: l,
2801
+ onChange: D,
2802
+ onBlur: D,
2803
+ ref: (w) => {
2804
+ if (w) {
2805
+ Oe(l, d), p = S(n, l);
2806
+ const v = J(w.value) && w.querySelectorAll && w.querySelectorAll("input,select,textarea")[0] || w, E = aa(v), W = p._f.refs || [];
2807
+ if (E ? W.find((z) => z === v) : v === p._f.ref)
2808
+ return;
2809
+ G(n, l, {
2810
+ _f: {
2811
+ ...p._f,
2812
+ ...E ? {
2813
+ refs: [
2814
+ ...W.filter(Et),
2815
+ v,
2816
+ ...Array.isArray(S(s, l)) ? [{}] : []
2817
+ ],
2818
+ ref: { type: v.type, name: l }
2819
+ } : { ref: v }
2820
+ }
2821
+ }), V(l, !1, void 0, v);
2822
+ } else
2823
+ p = S(n, l, {}), p._f && (p._f.mount = !1), (r.shouldUnregister || d.shouldUnregister) && !(Ys(o.array, l) && a.action) && o.unMount.add(l);
2824
+ }
2825
+ };
2826
+ }, Be = () => r.shouldFocusError && it(n, le, o.mount), ut = (l) => {
2827
+ pe(l) && (m.state.next({ disabled: l }), it(n, (d, p) => {
2828
+ const _ = S(n, p);
2829
+ _ && (d.disabled = _._f.disabled || l, Array.isArray(_._f.refs) && _._f.refs.forEach((w) => {
2830
+ w.disabled = _._f.disabled || l;
2831
+ }));
2832
+ }, 0, !1));
2833
+ }, Qe = (l, d) => async (p) => {
2834
+ let _;
2835
+ p && (p.preventDefault && p.preventDefault(), p.persist && p.persist());
2836
+ let w = Y(i);
2837
+ if (m.state.next({
2838
+ isSubmitting: !0
2839
+ }), r.resolver) {
2840
+ const { errors: v, values: E } = await O();
2841
+ x(), t.errors = v, w = Y(E);
2842
+ } else
2843
+ await P(n);
2844
+ if (o.disabled.size)
2845
+ for (const v of o.disabled)
2846
+ Z(w, v);
2847
+ if (Z(t.errors, "root"), ne(t.errors)) {
2848
+ m.state.next({
2849
+ errors: {}
2850
+ });
2851
+ try {
2852
+ await l(w, p);
2853
+ } catch (v) {
2854
+ _ = v;
2855
+ }
2856
+ } else
2857
+ d && await d({ ...t.errors }, p), Be(), setTimeout(Be);
2858
+ if (m.state.next({
2859
+ isSubmitted: !0,
2860
+ isSubmitting: !1,
2861
+ isSubmitSuccessful: ne(t.errors) && !_,
2862
+ submitCount: t.submitCount + 1,
2863
+ errors: t.errors
2864
+ }), _)
2865
+ throw _;
2866
+ }, ct = (l, d = {}) => {
2867
+ S(n, l) && (J(d.defaultValue) ? j(l, Y(S(s, l))) : (j(l, d.defaultValue), G(s, l, Y(d.defaultValue))), d.keepTouched || Z(t.touchedFields, l), d.keepDirty || (Z(t.dirtyFields, l), t.isDirty = d.defaultValue ? M(l, Y(S(s, l))) : M()), d.keepError || (Z(t.errors, l), b.isValid && C()), m.state.next({ ...t }));
2868
+ }, L = (l, d = {}) => {
2869
+ const p = l ? Y(l) : s, _ = Y(p), w = ne(l), v = w ? s : _;
2870
+ if (d.keepDefaultValues || (s = p), !d.keepValues) {
2871
+ if (d.keepDirtyValues) {
2872
+ const E = /* @__PURE__ */ new Set([
2873
+ ...o.mount,
2874
+ ...Object.keys(Pe(s, i))
2875
+ ]);
2876
+ for (const W of Array.from(E)) {
2877
+ const z = S(t.dirtyFields, W), te = S(i, W), Me = S(v, W);
2878
+ z && !J(te) ? G(v, W, te) : !z && !J(Me) && j(W, Me);
2879
+ }
2880
+ } else {
2881
+ if (Pt && J(l))
2882
+ for (const E of o.mount) {
2883
+ const W = S(n, E);
2884
+ if (W && W._f) {
2885
+ const z = Array.isArray(W._f.refs) ? W._f.refs[0] : W._f.ref;
2886
+ if (ft(z)) {
2887
+ const te = z.closest("form");
2888
+ if (te) {
2889
+ te.reset();
2890
+ break;
2891
+ }
2892
+ }
2893
+ }
2894
+ }
2895
+ if (d.keepFieldsRef)
2896
+ for (const E of o.mount)
2897
+ j(E, S(v, E));
2898
+ else
2899
+ n = {};
2900
+ }
2901
+ i = r.shouldUnregister ? d.keepDefaultValues ? Y(s) : {} : Y(v), m.array.next({
2902
+ values: { ...v }
2903
+ }), m.state.next({
2904
+ values: { ...v }
2905
+ });
2906
+ }
2907
+ o = {
2908
+ mount: d.keepDirtyValues ? o.mount : /* @__PURE__ */ new Set(),
2909
+ unMount: /* @__PURE__ */ new Set(),
2910
+ array: /* @__PURE__ */ new Set(),
2911
+ disabled: /* @__PURE__ */ new Set(),
2912
+ watch: /* @__PURE__ */ new Set(),
2913
+ watchAll: !1,
2914
+ focus: ""
2915
+ }, a.mount = !b.isValid || !!d.keepIsValid || !!d.keepDirtyValues || !r.shouldUnregister && !ne(v), a.watch = !!r.shouldUnregister, a.keepIsValid = !!d.keepIsValid, a.action = !1, d.keepErrors || (t.errors = {}), m.state.next({
2916
+ submitCount: d.keepSubmitCount ? t.submitCount : 0,
2917
+ isDirty: w ? !1 : d.keepDirty ? t.isDirty : !!(d.keepDefaultValues && !Se(l, s)),
2918
+ isSubmitted: d.keepIsSubmitted ? t.isSubmitted : !1,
2919
+ dirtyFields: w ? {} : d.keepDirtyValues ? d.keepDefaultValues && i ? Pe(s, i) : t.dirtyFields : d.keepDefaultValues && l ? Pe(s, l) : d.keepDirty ? t.dirtyFields : {},
2920
+ touchedFields: d.keepTouched ? t.touchedFields : {},
2921
+ errors: d.keepErrors ? t.errors : {},
2922
+ isSubmitSuccessful: d.keepIsSubmitSuccessful ? t.isSubmitSuccessful : !1,
2923
+ isSubmitting: !1,
2924
+ defaultValues: s
2925
+ });
2926
+ }, Ve = (l, d) => L(ce(l) ? l(i) : l, { ...r.resetOptions, ...d }), et = (l, d = {}) => {
2927
+ const p = S(n, l), _ = p && p._f;
2928
+ if (_) {
2929
+ const w = _.refs ? _.refs[0] : _.ref;
2930
+ w.focus && setTimeout(() => {
2931
+ w.focus(), d.shouldSelect && ce(w.select) && w.select();
2932
+ });
2933
+ }
2934
+ }, ke = (l) => {
2935
+ t = {
2936
+ ...t,
2937
+ ...l
2938
+ };
2939
+ }, zt = {
2940
+ control: {
2941
+ register: Oe,
2942
+ unregister: Te,
2943
+ getFieldState: _e,
2944
+ handleSubmit: Qe,
2945
+ setError: Ze,
2946
+ _subscribe: Fe,
2947
+ _runSchema: O,
2948
+ _updateIsValidating: x,
2949
+ _focusError: Be,
2950
+ _getWatch: A,
2951
+ _getDirty: M,
2952
+ _setValid: C,
2953
+ _setFieldArray: y,
2954
+ _setDisabledField: Ye,
2955
+ _setErrors: N,
2956
+ _getFieldArray: B,
2957
+ _reset: L,
2958
+ _resetDefaultValues: () => ce(r.defaultValues) && r.defaultValues().then((l) => {
2959
+ Ve(l, r.resetOptions), m.state.next({
2960
+ isLoading: !1
2961
+ });
2962
+ }),
2963
+ _removeUnmounted: H,
2964
+ _disableForm: ut,
2965
+ _subjects: m,
2966
+ _proxyFormState: b,
2967
+ get _fields() {
2968
+ return n;
2969
+ },
2970
+ get _formValues() {
2971
+ return i;
2972
+ },
2973
+ get _state() {
2974
+ return a;
2975
+ },
2976
+ set _state(l) {
2977
+ a = l;
2978
+ },
2979
+ get _defaultValues() {
2980
+ return s;
2981
+ },
2982
+ get _names() {
2983
+ return o;
2984
+ },
2985
+ set _names(l) {
2986
+ o = l;
2987
+ },
2988
+ get _formState() {
2989
+ return t;
2990
+ },
2991
+ get _options() {
2992
+ return r;
2993
+ },
2994
+ set _options(l) {
2995
+ r = {
2996
+ ...r,
2997
+ ...l
2998
+ };
2999
+ }
3000
+ },
3001
+ subscribe: De,
3002
+ trigger: ue,
3003
+ register: Oe,
3004
+ handleSubmit: Qe,
3005
+ watch: Xe,
3006
+ setValue: j,
3007
+ getValues: Je,
3008
+ reset: Ve,
3009
+ resetField: ct,
3010
+ clearErrors: lt,
3011
+ unregister: Te,
3012
+ setError: Ze,
3013
+ setFocus: et,
3014
+ getFieldState: _e
3015
+ };
3016
+ return {
3017
+ ...zt,
3018
+ formControl: zt
3019
+ };
3020
+ }
3021
+ function vt(e = {}) {
3022
+ const r = re.useRef(void 0), t = re.useRef(void 0), [n, s] = re.useState({
3023
+ isDirty: !1,
3024
+ isValidating: !1,
3025
+ isLoading: ce(e.defaultValues),
3026
+ isSubmitted: !1,
3027
+ isSubmitting: !1,
3028
+ isSubmitSuccessful: !1,
3029
+ isValid: !1,
3030
+ submitCount: 0,
3031
+ dirtyFields: {},
3032
+ touchedFields: {},
3033
+ validatingFields: {},
3034
+ errors: e.errors || {},
3035
+ disabled: e.disabled || !1,
3036
+ isReady: !1,
3037
+ defaultValues: ce(e.defaultValues) ? void 0 : e.defaultValues
3038
+ });
3039
+ if (!r.current)
3040
+ if (e.formControl)
3041
+ r.current = {
3042
+ ...e.formControl,
3043
+ formState: n
3044
+ }, e.defaultValues && !ce(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
3045
+ else {
3046
+ const { formControl: a, ...o } = ba(e);
3047
+ r.current = {
3048
+ ...o,
3049
+ formState: n
3050
+ };
3051
+ }
3052
+ const i = r.current.control;
3053
+ return i._options = e, ra(() => {
3054
+ const a = i._subscribe({
3055
+ formState: i._proxyFormState,
3056
+ callback: () => s({ ...i._formState }),
3057
+ reRenderRoot: !0
3058
+ });
3059
+ return s((o) => ({
3060
+ ...o,
3061
+ isReady: !0
3062
+ })), i._formState.isReady = !0, a;
3063
+ }, [i]), re.useEffect(() => i._disableForm(e.disabled), [i, e.disabled]), re.useEffect(() => {
3064
+ e.mode && (i._options.mode = e.mode), e.reValidateMode && (i._options.reValidateMode = e.reValidateMode);
3065
+ }, [i, e.mode, e.reValidateMode]), re.useEffect(() => {
3066
+ e.errors && (i._setErrors(e.errors), i._focusError());
3067
+ }, [i, e.errors]), re.useEffect(() => {
3068
+ e.shouldUnregister && i._subjects.state.next({
3069
+ values: i._getWatch()
3070
+ });
3071
+ }, [i, e.shouldUnregister]), re.useEffect(() => {
3072
+ if (i._proxyFormState.isDirty) {
3073
+ const a = i._getDirty();
3074
+ a !== n.isDirty && i._subjects.state.next({
3075
+ isDirty: a
3076
+ });
3077
+ }
3078
+ }, [i, n.isDirty]), re.useEffect(() => {
3079
+ var a;
3080
+ e.values && !Se(e.values, t.current) ? (i._reset(e.values, {
3081
+ keepFieldsRef: !0,
3082
+ ...i._options.resetOptions
3083
+ }), !((a = i._options.resetOptions) === null || a === void 0) && a.keepIsValid || i._setValid(), t.current = e.values, s((o) => ({ ...o }))) : i._resetDefaultValues();
3084
+ }, [i, e.values]), re.useEffect(() => {
3085
+ i._state.mount || (i._setValid(), i._state.mount = !0), i._state.watch && (i._state.watch = !1, i._subjects.state.next({ ...i._formState })), i._removeUnmounted();
3086
+ }), r.current.formState = re.useMemo(() => ta(n, i), [i, n]), r.current;
3087
+ }
3088
+ const vr = (e, r, t) => {
3089
+ if (e && "reportValidity" in e) {
3090
+ const n = S(t, r);
3091
+ e.setCustomValidity(n && n.message || ""), e.reportValidity();
3092
+ }
3093
+ }, va = (e, r) => {
3094
+ for (const t in r.fields) {
3095
+ const n = r.fields[t];
3096
+ n && n.ref && "reportValidity" in n.ref ? vr(n.ref, t, e) : n.refs && n.refs.forEach((s) => vr(s, t, e));
3097
+ }
3098
+ }, xa = (e, r) => {
3099
+ r.shouldUseNativeValidation && va(e, r);
3100
+ const t = {};
3101
+ for (const n in e) {
3102
+ const s = S(r.fields, n), i = Object.assign(e[n] || {}, { ref: s && s.ref });
3103
+ if (wa(r.names || Object.keys(e), n)) {
3104
+ const a = Object.assign({}, S(t, n));
3105
+ G(a, "root", i), G(t, n, a);
3106
+ } else
3107
+ G(t, n, i);
3108
+ }
3109
+ return t;
3110
+ }, wa = (e, r) => e.some((t) => t.startsWith(r + "."));
3111
+ var xt = function(e, r, t) {
3112
+ return t === void 0 && (t = {}), function(n, s, i) {
3113
+ try {
3114
+ var a = !i.shouldUseNativeValidation && i.criteriaMode === "all";
3115
+ return Promise.resolve(/* @__PURE__ */ Ls(e, n, Object.assign({}, r, { abortPipeEarly: !a }))).then(function(o) {
3116
+ if (o.issues) {
3117
+ for (var c = {}; o.issues.length; ) {
3118
+ var f = o.issues[0], g = /* @__PURE__ */ Ss(f);
3119
+ if (g && (c[g] || (c[g] = { message: f.message, type: f.type }), a)) {
3120
+ var b = c[g].types, h = b && b[f.type];
3121
+ c[g] = rn(g, a, c, f.type, h ? [].concat(h, f.message) : f.message);
3122
+ }
3123
+ o.issues.shift();
3124
+ }
3125
+ return { values: {}, errors: xa(c, i) };
3126
+ }
3127
+ return { values: t.raw ? n : o.output, errors: {} };
3128
+ });
3129
+ } catch (o) {
3130
+ return Promise.reject(o);
3131
+ }
3132
+ };
3133
+ };
3134
+ const xr = 27, wr = 12, _r = 10, _a = Ge("enum"), ka = (e, r) => {
3135
+ const t = {
3136
+ min: e.minSelected ?? 0,
3137
+ max: e.maxSelected ?? e.options.length
3138
+ };
3139
+ return xt(/* @__PURE__ */ xe({
3140
+ checked: /* @__PURE__ */ Ie(/* @__PURE__ */ Zr(/* @__PURE__ */ ae(), /* @__PURE__ */ Gr()), /* @__PURE__ */ Ot((n) => Object.entries(n).filter(([s, i]) => i).map(([s, i]) => s)), /* @__PURE__ */ st(t.max, r("validation_multiple_choice_max", {
3141
+ count: t.max
3142
+ })), /* @__PURE__ */ Ue(t.min, r("validation_multiple_choice_min", {
3143
+ count: t.min
3144
+ })))
3145
+ }));
3146
+ }, Ca = Rr(({
3147
+ option: e,
3148
+ ...r
3149
+ }, t) => u(we, {
3150
+ children: [u("input", {
3151
+ class: "peer sr-only h-full",
3152
+ type: "checkbox",
3153
+ ...r,
3154
+ ref: t
3155
+ }), u("label", {
3156
+ class: "bg-lowest hover:bg-neutral-2 active:outline-neutral-8 ease-expo-out outline-divider text-neutral-11 peer-checked:outline-accent-7 peer-checked:bg-accent-2 peer-checked:text-accent-9 peer-focus-visible:ring-accent-9 peer-focus-visible:ring-offset-accent-7 block cursor-pointer select-none rounded-2xl px-3 py-1.5 outline outline-1 ring-0 ring-transparent transition-all selection:bg-transparent peer-focus-visible:ring-4",
3157
+ htmlFor: r.id,
3158
+ children: e.label
3159
+ })]
3160
+ })), kr = mt("gutter-stable flex w-full flex-1 flex-wrap gap-2 overflow-y-auto rounded-xl p-2.5 pr-4", {
3161
+ variants: {
3162
+ variant: {
3163
+ // In cases where there is only one option, we want to center it
3164
+ singleOption: "justify-center",
3165
+ // Two choices with exactly 1 min 1 max
3166
+ booleanLike: Yr
3167
+ }
3168
+ }
3169
+ }), Sa = ({
3170
+ input: e,
3171
+ onSubmitSuccess: r
3172
+ }) => {
3173
+ var g, b;
3174
+ const t = e.key ? (g = K.current$.value.flow) == null ? void 0 : g.data.submissions[e.key] : void 0, n = (e.config.minSelected === 1 || e.config.minSelected === void 0) && e.config.maxSelected === 1, s = n && e.config.options.length === 2, {
3175
+ t: i
3176
+ } = ee(), {
3177
+ register: a,
3178
+ handleSubmit: o,
3179
+ formState: {
3180
+ errors: c
3181
+ }
3182
+ } = vt({
3183
+ defaultValues: {
3184
+ checked: n ? {} : _a(t) ? Object.fromEntries(t.value.map((h) => [h, !0])) : {}
3185
+ },
3186
+ resolver: ka(e.config, i)
3187
+ }), f = jt();
3188
+ return s ? u("ul", {
3189
+ style: {
3190
+ maxHeight: 6.5 * xr + 5 * wr + 2 * _r
3191
+ },
3192
+ class: kr({
3193
+ variant: "booleanLike"
3194
+ }),
3195
+ children: e.config.options.map((h, m) => u("li", {
3196
+ class: Qr,
3197
+ children: u(en, {
3198
+ type: "submit",
3199
+ ref: (k) => {
3200
+ k && m === 0 && (f.current = k);
3201
+ },
3202
+ label: h.label,
3203
+ value: "true",
3204
+ onClick: () => r({
3205
+ type: "enum",
3206
+ value: [h.value]
3207
+ })
3208
+ })
3209
+ }, h.value))
3210
+ }) : u("form", {
3211
+ noValidate: !0,
3212
+ onSubmit: (h) => o((m) => {
3213
+ const k = m.checked;
3214
+ r({
3215
+ type: "enum",
3216
+ value: k
3217
+ });
3218
+ })(h),
3219
+ children: [u("div", {
3220
+ class: "flex items-center gap-1",
3221
+ children: [u("ul", {
3222
+ style: {
3223
+ maxHeight: 6.5 * xr + 5 * wr + 2 * _r
3224
+ },
3225
+ class: kr({
3226
+ variant: e.config.options.length === 1 ? "singleOption" : void 0
3227
+ }),
3228
+ children: e.config.options.map((h, m) => {
3229
+ const k = `checked.${h.value}`, {
3230
+ ref: I,
3231
+ ...C
3232
+ } = a(k);
3233
+ return u("li", {
3234
+ class: "relative",
3235
+ children: u(Ca, {
3236
+ option: h,
3237
+ autoFocus: m === 0,
3238
+ ref: (x) => {
3239
+ x && m === 0 && (f.current = x), I(x);
3240
+ },
3241
+ id: k,
3242
+ ...C,
3243
+ onClick: n ? () => r({
3244
+ type: "enum",
3245
+ value: [h.value]
3246
+ }) : void 0
3247
+ })
3248
+ }, h.value);
3249
+ })
3250
+ }), u("div", {
3251
+ class: "flex flex-col items-center gap-2 pr-2.5 pt-2.5",
3252
+ children: [n ? null : u(Re, {}), e.config.minSelected === 0 && u(Ee, {
3253
+ class: "relative",
3254
+ type: "button",
3255
+ onClick: () => r({
3256
+ type: "enum",
3257
+ value: []
3258
+ })
3259
+ })]
3260
+ })]
3261
+ }), u("div", {
3262
+ class: "px-1",
3263
+ children: u(He, {
3264
+ error: (b = c.checked) == null ? void 0 : b.root
3265
+ })
3266
+ })]
3267
+ });
3268
+ }, Ia = Ge("number"), Aa = (e, r) => {
3269
+ const t = e.min ?? Number.MIN_SAFE_INTEGER, n = e.max ?? Number.MAX_SAFE_INTEGER, s = e.decimalCases ?? 0;
3270
+ return xt(/* @__PURE__ */ xe({
3271
+ number: /* @__PURE__ */ Ie(/* @__PURE__ */ Hr(r("validation_number")), /* @__PURE__ */ Ur(t, r("validation_number_min", {
3272
+ min: t
3273
+ })), /* @__PURE__ */ $r(n, r("validation_number_max", {
3274
+ max: n
3275
+ })), /* @__PURE__ */ Pr((i) => i === Number(i.toFixed(s)), r("validation_number_decimal_cases", {
3276
+ count: s
3277
+ })))
3278
+ }));
3279
+ }, Ea = ({
3280
+ input: e,
3281
+ onSubmitSuccess: r
3282
+ }) => {
3283
+ var b;
3284
+ const t = e.config.defaultValue, n = e.key ? (b = K.current$.value.flow) == null ? void 0 : b.data.submissions[e.key] : void 0, {
3285
+ t: s
3286
+ } = ee(), {
3287
+ register: i,
3288
+ handleSubmit: a,
3289
+ formState: {
3290
+ errors: o
3291
+ }
3292
+ } = vt({
3293
+ defaultValues: {
3294
+ number: Ia(n) ? n.value : t ? Number(t) : void 0
3295
+ },
3296
+ resolver: Aa(e.config, s)
3297
+ }), {
3298
+ ref: c,
3299
+ ...f
3300
+ } = i("number", {
3301
+ required: !e.config.optional,
3302
+ valueAsNumber: !0
3303
+ }), g = he();
3304
+ return Ae(() => {
3305
+ g.current && (g.current.focus(), g.current.select());
3306
+ }, []), u("form", {
3307
+ class: "flex flex-col gap-1 p-2.5",
3308
+ onSubmit: a((h) => {
3309
+ h.number !== void 0 && r({
3310
+ type: "number",
3311
+ value: h.number
3312
+ });
3313
+ }),
3314
+ children: [u("div", {
3315
+ class: "flex items-center gap-2",
3316
+ children: [u("div", {
3317
+ class: "relative min-w-0 flex-grow",
3318
+ children: [u("input", {
3319
+ ...f,
3320
+ id: "chat-input",
3321
+ autocomplete: "off",
3322
+ autoCapitalize: "off",
3323
+ autoCorrect: "off",
3324
+ autoFocus: !0,
3325
+ ref: (h) => {
3326
+ h && (g.current = h), c(h);
3327
+ },
3328
+ type: "text",
3329
+ min: e.config.min,
3330
+ max: e.config.max,
3331
+ class: ze({
3332
+ optional: e.config.optional,
3333
+ className: "[type=number:-webkit-inner-spin-button] w-full rounded-full [-webkit-outer-spin-button:none]"
3334
+ }),
3335
+ placeholder: e.config.placeholder
3336
+ }), e.config.optional && u(Ee, {
3337
+ class: "absolute bottom-0 right-0.5 top-0",
3338
+ onClick: () => r(null)
3339
+ })]
3340
+ }), u(Re, {})]
3341
+ }), u(He, {
3342
+ error: o.number
3343
+ })]
3344
+ });
3345
+ }, Fa = (e) => {
3346
+ if (e === "")
3347
+ return {
3348
+ countryCode: "",
3349
+ phoneNumber: ""
3350
+ };
3351
+ const r = Object.entries(Bt).find((s) => e.startsWith(s[1])), t = r ? r[1] : "", n = e.replace(t, "");
3352
+ return /^\d+$/.test(n) ? {
3353
+ countryCode: t,
3354
+ phoneNumber: n
3355
+ } : {
3356
+ countryCode: "",
3357
+ phoneNumber: ""
3358
+ };
3359
+ }, Va = "44", Ma = /^[0-9 ]+$/, La = Ge("string"), Na = Ge("phone"), Ra = (e) => {
3360
+ const r = /* @__PURE__ */ Ie(/* @__PURE__ */ ae(e("validation_country_code")), /* @__PURE__ */ Tt(Ma, e("validation_country_code"))), t = /* @__PURE__ */ Ie(/* @__PURE__ */ ae(e("validation_phone")), /* @__PURE__ */ Ue(1, e("validation_phone")), /* @__PURE__ */ Ot((n) => n.replace(/[^0-9]/g, "")));
3361
+ return xt(/* @__PURE__ */ xe({
3362
+ countryCode: r,
3363
+ phoneNumber: t
3364
+ }));
3365
+ }, Da = ({
3366
+ input: e,
3367
+ onSubmitSuccess: r
3368
+ }) => {
3369
+ var I;
3370
+ const t = e.key ? (I = K.current$.value.flow) == null ? void 0 : I.data.submissions[e.key] : void 0, {
3371
+ t: n
3372
+ } = ee(), [s, i] = ve(), a = La(t) ? Fa(t.value) : Na(t) ? t.value : void 0, {
3373
+ register: o,
3374
+ handleSubmit: c,
3375
+ formState: {
3376
+ errors: f
3377
+ },
3378
+ watch: g
3379
+ } = vt({
3380
+ defaultValues: {
3381
+ countryCode: (a == null ? void 0 : a.countryCode) ?? e.config.defaultValue.countryCode ?? Va,
3382
+ phoneNumber: (a == null ? void 0 : a.phoneNumber) ?? e.config.defaultValue.phoneNumber ?? ""
3383
+ },
3384
+ resolver: Ra(n)
3385
+ }), {
3386
+ ref: b,
3387
+ ...h
3388
+ } = o("phoneNumber", {
3389
+ required: !e.config.optional
3390
+ }), m = he(), k = g("countryCode");
3391
+ return Ae(() => {
3392
+ m.current && (m.current.focus(), m.current.select());
3393
+ }, []), u("form", {
3394
+ noValidate: !0,
3395
+ class: "flex flex-col gap-1 p-2.5",
3396
+ onSubmit: c((C) => {
3397
+ const x = C.phoneNumber.replace(/[^0-9]/g, ""), y = C.countryCode.replace(/[^0-9]/g, "");
3398
+ i(void 0);
3399
+ const F = e.config.minChars ?? 7, N = x.length + y.length;
3400
+ if (N < F)
3401
+ return i(n("validation_phone_min_chars", {
3402
+ count: F
3403
+ }));
3404
+ const V = e.config.maxChars;
3405
+ if (V != null && N > V)
3406
+ return i(n("validation_max_chars", {
3407
+ count: V
3408
+ }));
3409
+ e.config.submissionFormat === "phone" ? r({
3410
+ type: "phone",
3411
+ value: {
3412
+ countryCode: y,
3413
+ phoneNumber: x
3414
+ }
3415
+ }) : r({
3416
+ type: "string",
3417
+ value: k + C.phoneNumber
3418
+ });
3419
+ }),
3420
+ children: [u("div", {
3421
+ class: "flex items-center gap-2",
3422
+ children: [u("div", {
3423
+ class: "relative flex min-w-0 flex-1 flex-grow gap-2",
3424
+ children: [u("label", {
3425
+ class: "text-neutral-12 bg-lowest hover:bg-neutral-5 placeholder:text-neutral-8 focus-visible:outline-accent-7 focus-within:bg-neutral-5 focus-within:outline-accent-7 outline-divider relative flex h-full cursor-pointer appearance-none items-center justify-center overflow-hidden text-ellipsis whitespace-nowrap rounded-l-full border-solid px-3 py-1.5 text-center text-base outline outline-2 transition-all focus-within:outline-none",
3426
+ htmlFor: `isdk_phone_${e.key}`,
3427
+ children: [u("span", {
3428
+ children: ["+", k]
3429
+ }), u("select", {
3430
+ ...o("countryCode", {}),
3431
+ id: `isdk_phone_${e.key}`,
3432
+ class: "absolute inset-0 opacity-0",
3433
+ children: Object.entries(Bt).map(([C, x]) => u("option", {
3434
+ value: x,
3435
+ children: [C, " (+", x, ")"]
3436
+ }, C))
3437
+ })]
3438
+ }), u("input", {
3439
+ ...h,
3440
+ id: "chat-input",
3441
+ type: "tel",
3442
+ inputMode: "tel",
3443
+ autocomplete: "off",
3444
+ autoCapitalize: "off",
3445
+ autoCorrect: "off",
3446
+ autoFocus: !0,
3447
+ ref: (C) => {
3448
+ C && (m.current = C), b(C);
3449
+ },
3450
+ class: ze({
3451
+ optional: e.config.optional,
3452
+ className: "min-w-0 flex-1 rounded-r-full"
3453
+ }),
3454
+ placeholder: e.config.placeholder
3455
+ }), e.config.optional && u(Ee, {
3456
+ class: "absolute bottom-0 right-1 top-0",
3457
+ onClick: () => r(null)
3458
+ })]
3459
+ }), u(Re, {})]
3460
+ }), u(He, {
3461
+ error: f.countryCode || f.phoneNumber || {
3462
+ message: s
3463
+ }
3464
+ })]
3465
+ });
3466
+ }, dt = (e) => e === void 0 ? 0 : Math.max(0, Math.ceil((e - Date.now()) / 1e3)), Cr = (e, r, t, n) => t !== void 0 && n * 1e3 > Mr ? e("submission_available_at", {
3467
+ time: Lr(t, r)
3468
+ }) : e("submission_cooldown", {
3469
+ count: n
3470
+ }), Ta = ({
3471
+ input: e,
3472
+ onSubmitSuccess: r
3473
+ }) => {
3474
+ const {
3475
+ t,
3476
+ locale: n
3477
+ } = ee(), {
3478
+ availableAt: s
3479
+ } = e.config, [i, a] = ve(() => dt(s)), [o, c] = ve("");
3480
+ Nr(() => {
3481
+ const g = dt(s);
3482
+ if (a(g), g === 0)
3483
+ return;
3484
+ c(Cr(t, n, s, g));
3485
+ const b = setInterval(() => {
3486
+ const h = dt(s);
3487
+ a(h), !(h > 0) && (clearInterval(b), c(t("submission_cooldown_ready")));
3488
+ }, 250);
3489
+ return () => clearInterval(b);
3490
+ }, [s, n, t]);
3491
+ const f = i > 0;
3492
+ return u("div", {
3493
+ class: "flex flex-col items-center gap-2 py-3",
3494
+ children: [u("button", {
3495
+ class: "bg-accent-9 hover:bg-accent-10 active:bg-submit-bg-active hover:border-accent-10 active:border-submit-bg-active border-accent-9 ring-accent-6 focus-visible:outline-accent-8 ring-offset-neutral-1 aria-disabled:hover:bg-accent-9 aria-disabled:hover:border-accent-9 flex cursor-pointer rounded-full border border-solid px-5 py-3 pr-4 text-white outline-none ring-1 ring-offset-[1.5px] transition-all duration-300 focus-visible:outline-2 active:ring-2 active:ring-offset-2 aria-disabled:cursor-not-allowed aria-disabled:opacity-50 aria-disabled:active:ring-1 aria-disabled:active:ring-offset-[1.5px]",
3496
+ name: e.key,
3497
+ "aria-disabled": f,
3498
+ "aria-describedby": f ? "submit-cooldown" : void 0,
3499
+ onClick: () => {
3500
+ dt(s) > 0 || r(null);
3501
+ },
3502
+ children: u("span", {
3503
+ class: "flex items-center gap-1.5",
3504
+ children: [u("span", {
3505
+ class: "inline-flex items-center text-sm font-medium",
3506
+ children: e.config.label || "Submit"
3507
+ }), u("svg", {
3508
+ stroke: "currentColor",
3509
+ "stroke-width": "1.5",
3510
+ width: "16",
3511
+ height: "16",
3512
+ viewBox: "0 0 16 16",
3513
+ fill: "none",
3514
+ xmlns: "http://www.w3.org/2000/svg",
3515
+ children: [u("path", {
3516
+ d: "M4 8L8 4L12 8"
3517
+ }), u("path", {
3518
+ d: "M8 4V13"
3519
+ })]
3520
+ })]
3521
+ })
3522
+ }), f && u("p", {
3523
+ id: "submit-cooldown",
3524
+ "aria-hidden": "true",
3525
+ class: "text-neutral-11 text-xs",
3526
+ children: Cr(t, n, s, i)
3527
+ }), u("p", {
3528
+ role: "status",
3529
+ class: "sr-only",
3530
+ children: o
3531
+ })]
3532
+ });
3533
+ }, Oa = 160, Sr = (e) => {
3534
+ e.style.height = "auto", e.style.height = `${Math.min(e.scrollHeight, Oa)}px`;
3535
+ }, Ba = {
3536
+ date: {
3537
+ type: "date",
3538
+ inputMode: "text"
3539
+ },
3540
+ email: {
3541
+ type: "email",
3542
+ inputMode: "email",
3543
+ formNoValidate: !0
3544
+ },
3545
+ text: {
3546
+ type: "text",
3547
+ inputMode: "text"
3548
+ },
3549
+ url: {
3550
+ type: "url",
3551
+ inputMode: "url",
3552
+ formNoValidate: !0
3553
+ }
3554
+ }, ja = Ge("string"), Pa = (e, r) => {
3555
+ const t = {
3556
+ maxLength: r("validation_max_chars", {
3557
+ count: e.maxChars ?? 999
3558
+ }),
3559
+ minLength: r("validation_min_chars", {
3560
+ count: e.minChars ?? 1
3561
+ })
3562
+ };
3563
+ return xt(/* @__PURE__ */ xe({
3564
+ text: {
3565
+ date: /* @__PURE__ */ Ie(/* @__PURE__ */ ae(r("validation_date")), /* @__PURE__ */ Tt(/^\d{4}-\d{2}-\d{2}$/, r("validation_date"))),
3566
+ email: /* @__PURE__ */ Ie(/* @__PURE__ */ ae(r("validation_email")), /* @__PURE__ */ qr(r("validation_email")), /* @__PURE__ */ Ue(e.minChars ?? 1, t.minLength), /* @__PURE__ */ st(e.maxChars ?? 1 / 0, t.maxLength)),
3567
+ text: /* @__PURE__ */ Ie(/* @__PURE__ */ ae(), /* @__PURE__ */ Ue(e.minChars ?? 1, t.minLength), /* @__PURE__ */ st(e.maxChars ?? 1 / 0, t.maxLength)),
3568
+ url: /* @__PURE__ */ Ie(/* @__PURE__ */ ae(r("validation_url")), /* @__PURE__ */ Wr(r("validation_url")), /* @__PURE__ */ Ue(e.minChars ?? 1, t.minLength), /* @__PURE__ */ st(e.maxChars ?? 1 / 0, t.maxLength))
3569
+ }[e.format]
3570
+ }));
3571
+ }, qa = ({
3572
+ input: e,
3573
+ onSubmitSuccess: r
3574
+ }) => {
3575
+ var I;
3576
+ const {
3577
+ t
3578
+ } = ee(), n = e.key ? (I = K.current$.value.flow) == null ? void 0 : I.data.submissions[e.key] : void 0, s = e.config.defaultValue, i = e.config.multiline === !0 && e.config.format === "text", {
3579
+ register: a,
3580
+ handleSubmit: o,
3581
+ watch: c,
3582
+ formState: {
3583
+ errors: f
3584
+ }
3585
+ } = vt({
3586
+ defaultValues: {
3587
+ text: ja(n) ? n.value : s ?? ""
3588
+ },
3589
+ resolver: Pa(e.config, t)
3590
+ }), {
3591
+ ref: g,
3592
+ ...b
3593
+ } = a("text", {
3594
+ required: !e.config.optional
3595
+ }), h = he();
3596
+ Ae(() => {
3597
+ h.current && (h.current instanceof HTMLTextAreaElement && Sr(h.current), h.current.focus(), h.current.select());
3598
+ }, []);
3599
+ const m = e.config.maxChars, k = i && m !== void 0 ? c("text").length : void 0;
3600
+ return u("form", {
3601
+ noValidate: !0,
3602
+ class: "flex flex-col gap-1 p-2.5",
3603
+ onSubmit: o((C) => {
3604
+ r({
3605
+ type: "string",
3606
+ value: C.text
3607
+ });
3608
+ }),
3609
+ children: [u("div", {
3610
+ class: i ? "flex items-end gap-2" : "flex items-center gap-2",
3611
+ children: [u("div", {
3612
+ class: "relative min-w-0 flex-1",
3613
+ children: [i ? u("textarea", {
3614
+ id: "chat-input",
3615
+ ...b,
3616
+ rows: 2,
3617
+ maxLength: m,
3618
+ autoFocus: !0,
3619
+ "aria-describedby": k !== void 0 ? "chat-input-count" : void 0,
3620
+ onInput: (C) => Sr(C.currentTarget),
3621
+ onKeyDown: (C) => {
3622
+ var x;
3623
+ C.key === "Enter" && (C.ctrlKey || C.metaKey) && (C.preventDefault(), (x = C.currentTarget.form) == null || x.requestSubmit());
3624
+ },
3625
+ ref: (C) => {
3626
+ C && (h.current = C), g(C);
3627
+ },
3628
+ placeholder: e.config.placeholder,
3629
+ class: ze({
3630
+ optional: !!e.config.optional,
3631
+ className: "block w-full resize-none overflow-y-auto rounded-2xl"
3632
+ })
3633
+ }) : u("input", {
3634
+ id: "chat-input",
3635
+ ...b,
3636
+ ...Ba[e.config.format],
3637
+ autocomplete: "off",
3638
+ autoCapitalize: "off",
3639
+ autoCorrect: "off",
3640
+ autoFocus: !0,
3641
+ ref: (C) => {
3642
+ C && (h.current = C), g(C);
3643
+ },
3644
+ placeholder: e.config.placeholder,
3645
+ class: ze({
3646
+ optional: !!e.config.optional,
3647
+ className: "w-full rounded-full"
3648
+ })
3649
+ }), e.config.optional && u(
3650
+ Ee,
3651
+ {
3652
+ class: i ? "absolute bottom-1 right-0.5" : "absolute bottom-0 right-0.5 top-0",
3653
+ onClick: () => r(null)
3654
+ }
3655
+ )]
3656
+ }), u(Re, {})]
3657
+ }), k !== void 0 && m !== void 0 && u("p", {
3658
+ id: "chat-input-count",
3659
+ class: "text-neutral-10 px-3 text-right text-xs",
3660
+ children: [k, "/", m]
3661
+ }), u(He, {
3662
+ error: f.text
3663
+ })]
3664
+ });
3665
+ }, $a = {
3666
+ text: qa,
3667
+ phone: Da,
3668
+ "multiple-choice": Sa,
3669
+ boolean: $s,
3670
+ file: Js,
3671
+ submit: Ta,
3672
+ address: Bs,
3673
+ number: Ea
3674
+ }, Ua = ({
3675
+ logger: e,
3676
+ analytics: r
3677
+ }) => {
3678
+ var i;
3679
+ const t = (i = K.current$.value.flow) == null ? void 0 : i.data.currentInput, n = he(null), s = () => ie.onInteractionFn$.value();
3680
+ return Ae(() => {
3681
+ var a;
3682
+ (a = n.current) == null || a.scrollTo({
3683
+ top: 0
3684
+ });
3685
+ }, [t]), u("div", {
3686
+ ref: n,
3687
+ class: "border-divider max-h-[calc(100%-var(--header-height)-4rem)] w-full shrink-0 scroll-pb-12 overflow-y-auto overscroll-contain border-t",
3688
+ children: u("div", {
3689
+ class: "flex flex-col",
3690
+ onPointerDownCapture: t ? s : void 0,
3691
+ onKeyDownCapture: t ? s : void 0,
3692
+ children: t ? (() => {
3693
+ const a = $a[t.type];
3694
+ return u(a, {
3695
+ logger: e,
3696
+ analytics: r,
3697
+ onSubmitSuccess: ie.onSubmitSuccessFn$.value,
3698
+ input: t
3699
+ });
3700
+ })() : u("div", {
3701
+ class: "flex items-center gap-2 p-2.5",
3702
+ children: [u("input", {
3703
+ "aria-hidden": "true",
3704
+ id: "chat-input",
3705
+ class: ze({
3706
+ optional: !1,
3707
+ className: "flex-grow rounded-full"
3708
+ }),
3709
+ disabled: !0
3710
+ }), u(Re, {
3711
+ disabled: !0,
3712
+ "aria-hidden": "true",
3713
+ tabIndex: -1
3714
+ })]
3715
+ })
3716
+ })
3717
+ });
3718
+ };
3719
+ function Wa(e) {
3720
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
3721
+ }
3722
+ var za = function(e) {
3723
+ return e instanceof RegExp;
3724
+ }, Ka = function(r) {
3725
+ var t = /[\\^$.*+?()[\]{}|]/g, n = RegExp(t.source);
3726
+ return r && n.test(r) ? r.replace(t, "\\$&") : r;
3727
+ }, cn = function(e) {
3728
+ return typeof e == "string";
3729
+ }, Ga = function(e) {
3730
+ var r = [];
3731
+ return e.forEach(function(t) {
3732
+ Array.isArray(t) ? r = r.concat(t) : r.push(t);
3733
+ }), r;
3734
+ };
3735
+ function Ha(e, r, t) {
3736
+ var n = 0, s = 0;
3737
+ if (e === "")
3738
+ return e;
3739
+ if (!e || !cn(e))
3740
+ throw new TypeError("First argument to react-string-replace#replaceString must be a string");
3741
+ var i = r;
3742
+ za(i) || (i = new RegExp("(" + Ka(i) + ")", "gi"));
3743
+ for (var a = e.split(i), o = 1, c = a.length; o < c; o += 2) {
3744
+ if (a[o] === void 0 || a[o - 1] === void 0) {
3745
+ console.warn("reactStringReplace: Encountered undefined value during string replacement. Your RegExp may not be working the way you expect.");
3746
+ continue;
3747
+ }
3748
+ s = a[o].length, n += a[o - 1].length, a[o] = t(a[o], o, n), n += s;
3749
+ }
3750
+ return a;
3751
+ }
3752
+ var Ja = function(r, t, n) {
3753
+ return Array.isArray(r) || (r = [r]), Ga(r.map(function(s) {
3754
+ return cn(s) ? Ha(s, t, n) : s;
3755
+ }));
3756
+ };
3757
+ const rt = /* @__PURE__ */ Wa(Ja), Za = /(\[[^\]]+\]\([^)]+\))/g, Xa = /\[([^\]]+)\]\(([^)]+)\)/, Ya = /(https?:\/\/[^\s]+)/g, Qa = /_(.*?)_/g, ei = /\*\*(.*?)\*\*/g, ti = /\\n|\n/g, Ir = "text-accent-10 hover:text-accent-11 no-underline underline-offset-2 hover:underline", ri = (e) => {
3758
+ const r = rt(e, Za, (a, o) => {
3759
+ const [, c, f] = a.match(Xa) ?? [];
3760
+ return f ? u("a", {
3761
+ class: Ir,
3762
+ href: f,
3763
+ children: c ?? f
3764
+ }, f + o) : u("span", {
3765
+ children: "INVALID LINK"
3766
+ });
3767
+ }), t = rt(r, Ya, (a, o) => u("a", {
3768
+ class: Ir,
3769
+ href: a,
3770
+ children: a
3771
+ }, a + o)), n = rt(t, Qa, (a, o) => u("em", {
3772
+ children: a
3773
+ }, a + o)), s = rt(n, ei, (a, o) => u("strong", {
3774
+ children: a
3775
+ }, a + o));
3776
+ return rt(s, ti, (a, o) => u("br", {}, `br-${o}`));
3777
+ }, ni = mt("select-text max-w-[min(100%,24rem)] [text-wrap:pretty] leading-snug flex-shrink min-w-[2rem] py-2 px-3 rounded-[18px] min-h-[36px] break-words relative", {
3778
+ variants: {
3779
+ side: {
3780
+ left: "bg-bubble-weak-bg text-neutral-12 shadow-surface-sm outline outline-1 outline-bubble-weak rounded-bl-md",
3781
+ right: "ml-auto bg-accent-9 text-white rounded-br-md shadow-surface-sm shadow-bubble-strong-shadow"
3782
+ },
3783
+ animate: {
3784
+ true: "animate-bubble-in",
3785
+ false: ""
3786
+ }
3787
+ },
3788
+ defaultVariants: {
3789
+ side: "left"
3790
+ }
3791
+ }), si = ({
3792
+ children: e,
3793
+ className: r,
3794
+ animate: t,
3795
+ side: n,
3796
+ ...s
3797
+ }) => u("p", {
3798
+ style: {
3799
+ transformOrigin: n === "left" ? "0% 50%" : "100% 50%"
3800
+ },
3801
+ class: ni({
3802
+ className: r,
3803
+ side: n,
3804
+ animate: t
3805
+ }),
3806
+ ...s,
3807
+ children: e
3808
+ }), ai = ({
3809
+ message: e
3810
+ }) => u("div", {
3811
+ class: "bg-accent-3 flex w-full items-center justify-center overflow-hidden rounded-xl px-2 py-2",
3812
+ children: u("a", {
3813
+ onClick: e.onClick,
3814
+ class: "bg-lowest shadow-surface-sm ring-accent-6 hover:ring-accent-8 active:bg-accent-2 active:text-accent-10 text-accent-9 focus-visible:ring-accent-7/50 text-wrap-balance flex items-center gap-1.5 rounded-full py-2 pl-4 pr-2.5 text-center no-underline ring-1 transition-all focus:outline-none focus-visible:ring-4 focus-visible:ring-offset-2",
3815
+ target: "_blank",
3816
+ href: e.href,
3817
+ children: [e.text, u("svg", {
3818
+ class: "flex-none",
3819
+ width: "15",
3820
+ height: "15",
3821
+ viewBox: "0 0 15 15",
3822
+ fill: "none",
3823
+ xmlns: "http://www.w3.org/2000/svg",
3824
+ children: u("path", {
3825
+ d: "M3.64645 11.3536C3.45118 11.1583 3.45118 10.8417 3.64645 10.6465L10.2929 4L6 4C5.72386 4 5.5 3.77614 5.5 3.5C5.5 3.22386 5.72386 3 6 3L11.5 3C11.6326 3 11.7598 3.05268 11.8536 3.14645C11.9473 3.24022 12 3.36739 12 3.5L12 9.00001C12 9.27615 11.7761 9.50001 11.5 9.50001C11.2239 9.50001 11 9.27615 11 9.00001V4.70711L4.35355 11.3536C4.15829 11.5488 3.84171 11.5488 3.64645 11.3536Z",
3826
+ fill: "currentColor",
3827
+ "fill-rule": "evenodd",
3828
+ "clip-rule": "evenodd"
3829
+ })
3830
+ })]
3831
+ })
3832
+ }), ii = ({
3833
+ className: e,
3834
+ ...r
3835
+ }) => u("div", {
3836
+ "aria-hidden": !0,
3837
+ children: ie.isBotTyping$.value === !0 ? u("div", {
3838
+ "data-testid": "typing-indicator",
3839
+ class: Ke("flex gap-1 p-4", e),
3840
+ ...r,
3841
+ children: Array.from({
3842
+ length: 3
3843
+ }, (t, n) => u("div", {
3844
+ class: "bg-accent-9 h-1.5 w-1.5 animate-bounce rounded-full",
3845
+ style: {
3846
+ animationDelay: `${-n * 200}ms`
3847
+ }
3848
+ }))
3849
+ }) : void 0
3850
+ }), oi = {
3851
+ bot: "left",
3852
+ user: "right"
3853
+ }, li = mt("w-full select-none py-2 text-wrap-balance text-center text-[10px] uppercase tracking-widest drop-shadow-[0_1.5px_var(--i-color-n-1)]", {
3854
+ variants: {
3855
+ variant: {
3856
+ info: "text-neutral-11",
3857
+ warning: "text-system-warning",
3858
+ error: "text-error-11",
3859
+ success: "text-system-success"
3860
+ }
3861
+ }
3862
+ }), ui = ({
3863
+ lastSentMessageFooter: e
3864
+ }) => {
3865
+ const {
3866
+ t: r
3867
+ } = ee(), t = K.current$.value.flow, n = (t == null ? void 0 : t.data.messages) ?? [], s = t ? Dt(t) : void 0;
3868
+ return u("ol", {
3869
+ "aria-label": r("chat_messages"),
3870
+ "aria-live": "polite",
3871
+ class: "mt-auto flex flex-col justify-end gap-2 p-2 pt-[calc(var(--header-height)+1rem)]",
3872
+ children: [n.map((i, a) => u(we, {
3873
+ children: u("li", {
3874
+ class: "flex",
3875
+ tabIndex: a === n.length - 1 ? -1 : void 0,
3876
+ children: [s && i.groupId === s && !n.slice(a + 1).some((o) => o.groupId === s) ? e : null, Mn(i).with({
3877
+ type: "system"
3878
+ }, (o) => u("p", {
3879
+ class: li({
3880
+ variant: o.variant
3881
+ }),
3882
+ children: o.text
3883
+ })).with({
3884
+ type: "text",
3885
+ author: Ln.union("bot", "user")
3886
+ }, (o) => {
3887
+ const c = a === n.length - 1, f = o.author === "bot" ? ri(o.text) : o.text;
3888
+ return u(we, {
3889
+ children: u(si, {
3890
+ animate: c,
3891
+ side: oi[o.author],
3892
+ children: f
3893
+ }, a)
3894
+ });
3895
+ }).with({
3896
+ type: "link"
3897
+ }, (o) => u(ai, {
3898
+ message: o
3899
+ })).with({
3900
+ type: "image"
3901
+ }, (o) => u("img", {
3902
+ class: "shadow-surface-md w-full max-w-[min(100%,24rem)] rounded-2xl",
3903
+ src: o.url,
3904
+ style: {
3905
+ aspectRatio: o.width / o.height
3906
+ }
3907
+ })).with({
3908
+ type: "file"
3909
+ }, (o) => u(zs, {
3910
+ class: o.author === "bot" ? void 0 : "ml-auto",
3911
+ file: {
3912
+ name: o.fileName,
3913
+ sizeKb: o.fileSizeKb
3914
+ }
3915
+ })).with({
3916
+ type: "loading"
3917
+ }, (o) => {
3918
+ const c = n[n.length - 1];
3919
+ return !(o === c) || ie.isBotTyping$.value ? null : u("div", {
3920
+ class: "flex flex-grow flex-col items-center justify-center gap-2",
3921
+ children: [u(Rt, {
3922
+ "aria-hidden": o.text ? "true" : void 0,
3923
+ class: "text-neutral-6 h-8 w-8"
3924
+ }), o.text ? u("p", {
3925
+ role: "status",
3926
+ class: "text-neutral-11 text-sm",
3927
+ children: o.text
3928
+ }) : null]
3929
+ });
3930
+ }).exhaustive()]
3931
+ })
3932
+ }, a)), u("li", {
3933
+ class: ie.captchaVisible$.value ? "flex" : "hidden",
3934
+ children: u("div", {
3935
+ "data-captcha-slot": !0,
3936
+ tabIndex: -1,
3937
+ role: "group",
3938
+ "aria-label": r("captcha_check"),
3939
+ class: "w-full max-w-[min(100%,24rem)] rounded-md"
3940
+ })
3941
+ }, "captcha"), u(ii, {}, "typing")]
3942
+ });
3943
+ }, hi = ({
3944
+ logger: e,
3945
+ apiClient: r,
3946
+ analytics: t,
3947
+ talentBankClient: n
3948
+ }) => {
3949
+ const {
3950
+ flow: s
3951
+ } = K.current$.value;
3952
+ Ne(s, "Flow is required to exist to show chatbot body");
3953
+ const i = K.viewState$.value, {
3954
+ chatRef: a,
3955
+ chatService: o
3956
+ } = Nn(), {
3957
+ t: c
3958
+ } = ee(), [f, g] = ve();
3959
+ return Ae(() => {
3960
+ i === "maximised" && ie.scrollToEnd();
3961
+ }, [i]), Ae(() => {
3962
+ var V;
3963
+ const {
3964
+ state: b,
3965
+ flow: h
3966
+ } = K.current$.peek();
3967
+ if (b !== "loaded")
3968
+ throw new Error(c("invalid_state"));
3969
+ let m = h.data.nodeHistory.at(-1);
3970
+ if (ie.scrollToEnd(), K.setInput(void 0), h.data.isFinished)
3971
+ return;
3972
+ const k = () => {
3973
+ const T = K.current$.peek().flow;
3974
+ !T || T.data.hasInteracted || (K.markAsInteracted(), er(t, T, "FLOW_INTERACT"));
3975
+ };
3976
+ ie.onInteractionFn$.value = k, m === void 0 ? (m = Or(s.nodes).id, K.setCurrentNodeId(m), er(t, h, "FLOW_START")) : K.removeMessagesSentByNodeIds([m, Mt]);
3977
+ const {
3978
+ interpret: I,
3979
+ abort: C,
3980
+ undo: x
3981
+ } = Xn({
3982
+ context: s.context,
3983
+ analytics: {
3984
+ service: t,
3985
+ customProperties: (V = s.analytics) == null ? void 0 : V.customProperties
3986
+ },
3987
+ apiClient: r,
3988
+ logger: e,
3989
+ talentBankClient: n,
3990
+ flow: s,
3991
+ chatService: o,
3992
+ t: c,
3993
+ getApplicationRecovery: () => {
3994
+ var T;
3995
+ return (T = K.current$.peek().flow) == null ? void 0 : T.data.applicationRecovery;
3996
+ },
3997
+ setApplicationRecovery: K.setApplicationRecovery,
3998
+ persistWriteBarrier: () => K.persistWriteBarrier(h),
3999
+ // We need to get fresh submissions, that’s why we call `peek` here.
4000
+ getSubmissions: () => {
4001
+ var T;
4002
+ return (T = K.current$.peek().flow) == null ? void 0 : T.data.submissions;
4003
+ },
4004
+ onInterpret: (T) => K.setCurrentNodeId(T.id),
4005
+ onFlowEnd: async () => {
4006
+ var R;
4007
+ K.markAsFinished();
4008
+ const T = K.current$.peek().flow;
4009
+ Ne(T), t.log({
4010
+ event: "FLOW_END",
4011
+ properties: {
4012
+ flow_id: s.id,
4013
+ flow_version: s.version,
4014
+ flow_session_id: T.data.flowSessionId,
4015
+ flow_build: s.build,
4016
+ job: s.job
4017
+ },
4018
+ customProperties: (R = s.analytics) == null ? void 0 : R.customProperties
4019
+ });
4020
+ }
4021
+ }), y = m, F = () => {
4022
+ g(() => x), I(y);
4023
+ }, N = new AbortController();
4024
+ return h.offerResume ? vs({
4025
+ chatService: o,
4026
+ t: c,
4027
+ signal: N.signal
4028
+ }).then((T) => (K.settleResume(h), T ? F() : (K.restart(), Rn.flushStateData()))).catch((T) => {
4029
+ T instanceof Fr || e.error("Resume prompt failed", T);
4030
+ }) : F(), () => {
4031
+ N.abort(), ie.onInteractionFn$.value === k && (ie.onInteractionFn$.value = () => {
4032
+ }), C();
4033
+ };
4034
+ }, [t, r, o, e, s, n, c]), u(we, {
4035
+ children: [u("div", {
4036
+ class: "relative flex min-h-0 w-full max-w-full flex-grow flex-col",
4037
+ children: [u("div", {
4038
+ ref: a,
4039
+ role: "region",
4040
+ "aria-label": c("conversation_history"),
4041
+ tabIndex: 0,
4042
+ className: "hide-scrollbars fr flex min-h-0 w-full max-w-full flex-grow flex-col overflow-y-auto ring-inset",
4043
+ style: {
4044
+ WebkitOverflowScrolling: "touch"
4045
+ },
4046
+ children: u(ui, {
4047
+ lastSentMessageFooter: !Dt(s) || !f ? null : u(ci, {
4048
+ undoFn: f
4049
+ })
4050
+ })
4051
+ }), ie.isReadingHistory$.value && !s.data.isFinished && !ie.isBotTyping$.value && u("div", {
4052
+ class: "absolute bottom-2 left-1/2 -translate-x-1/2",
4053
+ children: u(Dr, {
4054
+ class: "bg-neutral-1 ring-divider shadow-surface-md ring-1",
4055
+ "aria-label": c("jump_to_current"),
4056
+ onClick: () => {
4057
+ var h, m;
4058
+ ie.scrollToEnd(), (m = ((h = a.current) == null ? void 0 : h.querySelector('li[tabindex="-1"]')) ?? a.current) == null || m.focus({
4059
+ preventScroll: !0
4060
+ });
4061
+ },
4062
+ children: u(Dn, {})
4063
+ })
4064
+ })]
4065
+ }), u(Ua, {
4066
+ logger: e,
4067
+ analytics: t
4068
+ })]
4069
+ });
4070
+ }, ci = ({
4071
+ undoFn: e
4072
+ }) => {
4073
+ const {
4074
+ t: r
4075
+ } = ee();
4076
+ return u("div", {
4077
+ class: "flex flex-1 items-center justify-end px-1",
4078
+ children: u(Dr, {
4079
+ "aria-label": r("undo"),
4080
+ onClick: async () => {
4081
+ const {
4082
+ flow: t
4083
+ } = K.current$.peek();
4084
+ Ne(t), e(t.data.nodeHistory);
4085
+ },
4086
+ children: u("path", {
4087
+ d: "M3 13h2.67l6.66-6.67a1.9 1.9 0 0 0 0-2.66 1.91 1.91 0 0 0-2.66 0L3 10.33V13Zm4.6-7.25 2.67 2.67"
4088
+ })
4089
+ })
4090
+ });
4091
+ };
4092
+ export {
4093
+ hi as ChatbotBody
4094
+ };