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