@inploi/plugin-chatbot 14.18.2 → 14.19.0

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