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