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