@inploi/plugin-chatbot 14.17.2 → 14.17.3

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