@verbb/formie-core 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,3495 @@
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
3
+ if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
+ get: ((e) => i[e]).bind(null, d),
5
+ enumerable: !(s = n(i, d)) || s.enumerable
6
+ });
7
+ return e;
8
+ }, c = (n, r, a) => (a = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule ? t(a, "default", {
9
+ value: n,
10
+ enumerable: !0
11
+ }) : a, n));
12
+ //#endregion
13
+ //#region src/conditions.ts
14
+ function l(e) {
15
+ return Array.isArray(e) ? e.map((e) => String(e ?? "")) : [String(e ?? "")];
16
+ }
17
+ function u(e, t) {
18
+ return e.some((e) => t.includes(e));
19
+ }
20
+ function d(e, t) {
21
+ return e.some((e) => t.some((t) => t === e || t.includes(e)));
22
+ }
23
+ function f(e, t, n) {
24
+ return t.some((t) => e.some((e) => n(e, t)));
25
+ }
26
+ function p(e, t, n) {
27
+ return t.some((t) => {
28
+ let r = Number.parseFloat(t);
29
+ return Number.isFinite(r) ? e.some((e) => {
30
+ let t = Number.parseFloat(e);
31
+ return Number.isFinite(t) ? n(t, r) : !1;
32
+ }) : !1;
33
+ });
34
+ }
35
+ function m(e) {
36
+ return e.length === 0 || e.every((e) => e.trim() === "");
37
+ }
38
+ function h(e, t, n = {}) {
39
+ let r = String(e.condition || ""), i = l(e.value), a = n.visibility ?? null;
40
+ switch (r) {
41
+ case "=": return u(i, t);
42
+ case "!=": return !u(i, t);
43
+ case ">": return p(t, i, (e, t) => e > t);
44
+ case "<": return p(t, i, (e, t) => e < t);
45
+ case "contains": return d(i, t);
46
+ case "notContains": return !d(i, t);
47
+ case "startsWith": return f(t, i, (e, t) => e.startsWith(t));
48
+ case "endsWith": return f(t, i, (e, t) => e.endsWith(t));
49
+ case "empty": return m(t);
50
+ case "notEmpty": return !m(t);
51
+ case "visible": return a === !0;
52
+ case "hidden": return a === !1;
53
+ default: return !1;
54
+ }
55
+ }
56
+ function g(e, t) {
57
+ let n = e.conditionRule === "any" ? t.includes(!0) : t.every((e) => e === !0);
58
+ return {
59
+ finalResult: n,
60
+ shouldHide: n && e.showRule !== "show" || !n && e.showRule === "show"
61
+ };
62
+ }
63
+ //#endregion
64
+ //#region src/events.ts
65
+ var _ = class {
66
+ constructor() {
67
+ this.listeners = /* @__PURE__ */ new Map();
68
+ }
69
+ on(e, t) {
70
+ let n = this.listeners.get(e) ?? /* @__PURE__ */ new Set();
71
+ return n.add(t), this.listeners.set(e, n), () => {
72
+ n.delete(t), n.size === 0 && this.listeners.delete(e);
73
+ };
74
+ }
75
+ emit(e, t) {
76
+ let n = this.listeners.get(e);
77
+ n && n.forEach((e) => {
78
+ e(t);
79
+ });
80
+ }
81
+ }, v = new Set([
82
+ "single-line-text",
83
+ "multi-line-text",
84
+ "number",
85
+ "email",
86
+ "phone",
87
+ "dropdown",
88
+ "radio",
89
+ "checkboxes",
90
+ "agree",
91
+ "date",
92
+ "name",
93
+ "address",
94
+ "repeater",
95
+ "signature",
96
+ "file"
97
+ ]);
98
+ function y(e) {
99
+ return e.pages.flatMap((e) => e.rows.flatMap((e) => e.fields));
100
+ }
101
+ function b(e, t) {
102
+ return y(e).find((e) => e.id === t);
103
+ }
104
+ function x(e, t) {
105
+ return y(e).find((e) => e.handle === t);
106
+ }
107
+ function ee(e, t) {
108
+ return Object.fromEntries(Object.entries(t).map(([t, n]) => [b(e, t)?.handle ?? t, n]));
109
+ }
110
+ function te(e) {
111
+ return v.has(e);
112
+ }
113
+ function S(e) {
114
+ if (!e.runtime) throw Error(`Field "${e.handle}" is missing field value metadata.`);
115
+ return e.runtime;
116
+ }
117
+ function C(e) {
118
+ return S(e).structure;
119
+ }
120
+ function w(e) {
121
+ return C(e) === "fixed-parent" && k(e).length > 0;
122
+ }
123
+ function T(e) {
124
+ return C(e) === "repeatable-parent";
125
+ }
126
+ function E(e) {
127
+ return e.type === "file" || e.input.fieldKind === "file";
128
+ }
129
+ function D(e) {
130
+ let t = e.input;
131
+ return E(e) || e.type === "checkboxes" || e.type === "dropdown" && t.multiple === !0;
132
+ }
133
+ function ne(e) {
134
+ return e.type === "agree" || e.input.fieldKind === "boolean";
135
+ }
136
+ function re(e) {
137
+ return e.type === "number";
138
+ }
139
+ function O(e) {
140
+ return e.type === "email";
141
+ }
142
+ function k(e) {
143
+ let t = e.input;
144
+ return Array.isArray(t.parts) ? t.parts.filter((e) => !!e && typeof e == "object" && "handle" in e && "type" in e) : [];
145
+ }
146
+ function A(e) {
147
+ let t = e.input.rowSchema;
148
+ return !t || typeof t != "object" || !Array.isArray(t.rows) ? [] : t.rows;
149
+ }
150
+ function j(e) {
151
+ return A(e).flatMap((e) => e.fields);
152
+ }
153
+ function M(e) {
154
+ let t = e.input;
155
+ if (e.type === "checkboxes") return (Array.isArray(t.options) ? t.options : []).filter((e) => e.selected === !0).map((e) => e.value ?? "");
156
+ if (e.type === "radio" || e.type === "dropdown") {
157
+ let n = Array.isArray(t.options) ? t.options : [];
158
+ if (e.type === "dropdown" && t.multiple === !0) return n.filter((e) => e.selected === !0).map((e) => e.value ?? "");
159
+ let r = n.find((e) => e.selected === !0);
160
+ if (r) return r.value ?? "";
161
+ }
162
+ if (e.type === "agree") return t.defaultValue ?? !1;
163
+ if (w(e)) return t.defaultValue && typeof t.defaultValue == "object" ? t.defaultValue : {};
164
+ if (T(e)) {
165
+ let n = Number(t.minRows ?? 0) || 0;
166
+ return n <= 0 ? [] : Array.from({ length: n }, () => N(e));
167
+ }
168
+ return E(e) || D(e) ? [] : (e.type, t.defaultValue ?? "");
169
+ }
170
+ function N(e) {
171
+ return Object.fromEntries(j(e).map((e) => [e.handle, M(e)]));
172
+ }
173
+ function P(e, t) {
174
+ if (e.type === "checkboxes" || E(e) || D(e)) return Array.isArray(t) ? t.flatMap((t) => P(e, t)) : [];
175
+ if (T(e)) {
176
+ let n = Array.isArray(t) ? t : [], r = j(e);
177
+ return n.flatMap((e) => {
178
+ if (!e || typeof e != "object") return [];
179
+ let t = e;
180
+ return r.flatMap((e) => P(e, t[e.handle]));
181
+ });
182
+ }
183
+ return w(e) && t && typeof t == "object" ? Object.values(t).flatMap((t) => P(e, t)) : t == null ? [] : typeof t == "boolean" ? t ? ["true"] : ["false"] : Array.isArray(t) ? t.flatMap((t) => P(e, t)) : [String(t)];
184
+ }
185
+ function F(e) {
186
+ return typeof Blob < "u" && e instanceof Blob;
187
+ }
188
+ async function ie(e) {
189
+ return new Promise((t, n) => {
190
+ let r = new FileReader();
191
+ r.onerror = () => {
192
+ n(r.error || /* @__PURE__ */ Error("Unable to read file."));
193
+ }, r.onload = () => {
194
+ t(typeof r.result == "string" ? r.result : "");
195
+ }, r.readAsDataURL(e);
196
+ });
197
+ }
198
+ async function ae(e) {
199
+ let t = Array.isArray(e) ? e : [];
200
+ return (await Promise.all(t.map(async (e) => typeof e == "number" ? { assetId: e } : e && typeof e == "object" && "assetId" in e && typeof e.assetId == "number" ? {
201
+ assetId: e.assetId,
202
+ filename: typeof e.filename == "string" ? e.filename : void 0
203
+ } : e && typeof e == "object" && "fileData" in e && typeof e.fileData == "string" ? {
204
+ fileData: e.fileData,
205
+ filename: typeof e.filename == "string" ? e.filename : void 0
206
+ } : F(e) ? {
207
+ fileData: await ie(e),
208
+ filename: "name" in e && typeof e.name == "string" ? e.name : "upload.bin"
209
+ } : null))).filter((e) => e !== null);
210
+ }
211
+ async function oe(e, t) {
212
+ let n = t && typeof t == "object" ? t : {}, r = { ...n };
213
+ return await Promise.all(e.map(async (e) => {
214
+ r[e.handle] = await ce(e, n[e.handle]);
215
+ })), r;
216
+ }
217
+ async function se(e, t) {
218
+ let n = j(e);
219
+ return n.length === 0 || !Array.isArray(t) ? [] : Promise.all(t.map(async (e) => oe(n, e)));
220
+ }
221
+ async function ce(e, t) {
222
+ return E(e) ? ae(t) : T(e) ? se(e, t) : w(e) ? oe(k(e), t) : t;
223
+ }
224
+ async function I(e, t) {
225
+ let n = await Promise.all(Object.entries(t).map(async ([t, n]) => {
226
+ let r = b(e, t);
227
+ return r ? [r.handle, await ce(r, n)] : [t, n];
228
+ }));
229
+ return Object.fromEntries(n);
230
+ }
231
+ //#endregion
232
+ //#region src/form-instance.ts
233
+ function le(e) {
234
+ return Array.isArray(e) ? e.map((e) => le(e)) : !e || typeof e != "object" || typeof File < "u" && e instanceof File || typeof Blob < "u" && e instanceof Blob ? e : Object.fromEntries(Object.entries(e).map(([e, t]) => [e, le(t)]));
235
+ }
236
+ function L(e) {
237
+ return {
238
+ ...e,
239
+ session: {
240
+ ...e.session,
241
+ tokens: { ...e.session.tokens },
242
+ continuation: e.session.continuation ? { ...e.session.continuation } : null
243
+ },
244
+ values: le(e.values),
245
+ errors: {
246
+ form: [...e.errors.form],
247
+ fields: Object.fromEntries(Object.entries(e.errors.fields).map(([e, t]) => [e, [...t]])),
248
+ pages: Object.fromEntries(Object.entries(e.errors.pages).map(([e, t]) => [e, [...t]]))
249
+ },
250
+ fieldStates: Object.fromEntries(Object.entries(e.fieldStates).map(([e, t]) => [e, { ...t }])),
251
+ pageStates: Object.fromEntries(Object.entries(e.pageStates).map(([e, t]) => [e, { ...t }])),
252
+ lastSubmitResult: e.lastSubmitResult ? {
253
+ ...e.lastSubmitResult,
254
+ errors: {
255
+ form: [...e.lastSubmitResult.errors.form],
256
+ fields: Object.fromEntries(Object.entries(e.lastSubmitResult.errors.fields).map(([e, t]) => [e, [...t]])),
257
+ pages: Object.fromEntries(Object.entries(e.lastSubmitResult.errors.pages).map(([e, t]) => [e, [...t]]))
258
+ },
259
+ messages: { ...e.lastSubmitResult.messages },
260
+ session: e.lastSubmitResult.session ? {
261
+ ...e.lastSubmitResult.session,
262
+ tokens: { ...e.lastSubmitResult.session.tokens },
263
+ continuation: e.lastSubmitResult.session.continuation ? { ...e.lastSubmitResult.session.continuation } : null
264
+ } : null
265
+ } : null
266
+ };
267
+ }
268
+ function ue(e) {
269
+ return Object.fromEntries(y(e.definition).map((e) => [e.id, M(e)]));
270
+ }
271
+ function de(e) {
272
+ return Object.fromEntries(y(e).map((e) => [e.id, {
273
+ hidden: e.meta?.hidden === !0,
274
+ disabled: e.meta?.disabled === !0
275
+ }]));
276
+ }
277
+ function fe(e) {
278
+ return Object.fromEntries(e.pages.map((e) => [e.id, { hidden: !1 }]));
279
+ }
280
+ function pe(e, t) {
281
+ let n = e.definition.pages.find((e) => e.id === t);
282
+ if (!n) return [];
283
+ let r = [];
284
+ return n.rows.forEach((e) => {
285
+ e.fields.forEach((e) => {
286
+ r.push(e.id);
287
+ });
288
+ }), r;
289
+ }
290
+ function me(e, t) {
291
+ return b(e, t.fieldId) || x(e, t.fieldId);
292
+ }
293
+ function he(e) {
294
+ let t = de(e.definition);
295
+ return y(e.definition).forEach((n) => {
296
+ let r = n.condition;
297
+ if (!r || r.rules.length === 0) return;
298
+ let i = r.rules.map((n) => {
299
+ let r = me(e.definition, n), i = r ? t[r.id]?.hidden !== !0 : null;
300
+ return h({
301
+ condition: n.operator,
302
+ value: n.value
303
+ }, r ? P(r, e.values[r.id]) : [], { visibility: i });
304
+ });
305
+ if (r.effect === "show" || r.effect === "hide") {
306
+ let { shouldHide: e } = g({
307
+ conditionRule: r.mode,
308
+ showRule: r.effect === "show" ? "show" : "hide"
309
+ }, i);
310
+ t[n.id] = {
311
+ ...t[n.id],
312
+ hidden: t[n.id].hidden || e
313
+ };
314
+ return;
315
+ }
316
+ let a = r.mode === "any" ? i.includes(!0) : i.every((e) => e === !0);
317
+ t[n.id] = {
318
+ ...t[n.id],
319
+ disabled: t[n.id].disabled || (r.effect === "disable" ? a : !a)
320
+ };
321
+ }), t;
322
+ }
323
+ function ge(e) {
324
+ return M(e);
325
+ }
326
+ function _e(e, t, n) {
327
+ let r = e.values;
328
+ return y(e.definition).forEach((e) => {
329
+ let i = e.condition, a = t[e.id]?.hidden === !0, o = n[e.id]?.hidden === !0, s = i?.clearOnHide !== !1;
330
+ if (!o || a || !s) return;
331
+ let c = ge(e);
332
+ r[e.id] !== c && (r = {
333
+ ...r,
334
+ [e.id]: c
335
+ });
336
+ }), r;
337
+ }
338
+ function R(e, t) {
339
+ return Object.fromEntries(e.definition.pages.map((n) => {
340
+ let r = n.condition;
341
+ if (!r || r.rules.length === 0) return [n.id, { hidden: !1 }];
342
+ let i = r.rules.map((n) => {
343
+ let r = me(e.definition, n), i = r ? t[r.id]?.hidden !== !0 : null;
344
+ return h({
345
+ condition: n.operator,
346
+ value: n.value
347
+ }, r ? P(r, e.values[r.id]) : [], { visibility: i });
348
+ }), { shouldHide: a } = g({
349
+ conditionRule: r.mode,
350
+ showRule: r.effect === "show" ? "show" : "hide"
351
+ }, i);
352
+ return [n.id, { hidden: a }];
353
+ }));
354
+ }
355
+ function z(e, t, n) {
356
+ let r = e.pages[0]?.id || "", i = e.pages.find((e) => t[e.id]?.hidden !== !0)?.id || r;
357
+ return n ? t[n]?.hidden === !0 ? i : n : i;
358
+ }
359
+ function B(e) {
360
+ let t = e;
361
+ for (let e = 0; e < 3; e += 1) {
362
+ let e = he(t), n = _e(t, t.fieldStates, e);
363
+ if (n !== t.values) {
364
+ t = {
365
+ ...t,
366
+ values: n,
367
+ fieldStates: e
368
+ };
369
+ continue;
370
+ }
371
+ let r = R(t, e);
372
+ return {
373
+ ...t,
374
+ fieldStates: e,
375
+ pageStates: r,
376
+ currentPageId: z(t.definition, r, t.currentPageId)
377
+ };
378
+ }
379
+ let n = he(t), r = R(t, n);
380
+ return {
381
+ ...t,
382
+ fieldStates: n,
383
+ pageStates: r,
384
+ currentPageId: z(t.definition, r, t.currentPageId)
385
+ };
386
+ }
387
+ function ve(e, t) {
388
+ return e.type === "checkboxes" ? !Array.isArray(t) || t.length === 0 : ne(e) ? t !== !0 : E(e) || T(e) || D(e) ? !Array.isArray(t) || t.length === 0 : w(e) && t && typeof t == "object" ? Object.values(t).every((e) => e == null || typeof e == "string" && e.trim() === "") : t == null ? !0 : typeof t == "string" ? t.trim() === "" : !1;
389
+ }
390
+ function V(e, t, n, r, i) {
391
+ let a = new Set(e.validation.map((e) => e.type)), o = e.input;
392
+ if ((e.required || a.has("required")) && ve(e, t)) {
393
+ i[r] = ["This field is required."];
394
+ return;
395
+ }
396
+ if ((O(e) || a.has("email")) && typeof t == "string" && t.trim() !== "" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)) {
397
+ i[r] = ["Please enter a valid email address."];
398
+ return;
399
+ }
400
+ if ((re(e) || a.has("number")) && typeof t == "string" && t.trim() !== "") {
401
+ let n = Number.parseFloat(t);
402
+ if (!Number.isFinite(n)) {
403
+ i[r] = ["Please enter a valid number."];
404
+ return;
405
+ }
406
+ let a = e.validation.find((e) => e.type === "number"), s = Number(o.min ?? a?.min ?? NaN), c = Number(o.max ?? a?.max ?? NaN);
407
+ if (Number.isFinite(s) && n < s) {
408
+ i[r] = [`Please enter a value greater than or equal to ${s}.`];
409
+ return;
410
+ }
411
+ if (Number.isFinite(c) && n > c) {
412
+ i[r] = [`Please enter a value less than or equal to ${c}.`];
413
+ return;
414
+ }
415
+ }
416
+ if (a.has("url") && typeof t == "string" && t.trim() !== "") try {
417
+ new URL(t);
418
+ } catch {
419
+ i[r] = ["Please enter a valid URL."];
420
+ return;
421
+ }
422
+ let s = e.validation.find((e) => e.type === "match");
423
+ if (s && typeof t == "string" && t.trim() !== "") {
424
+ let e = (s.fieldId ? b(n.definition, s.fieldId) : void 0) || (s.fieldHandle ? x(n.definition, s.fieldHandle) : void 0), a = e ? n.values[e.id] : void 0;
425
+ if (typeof a == "string" && a !== t) {
426
+ i[r] = ["This value must match the related field."];
427
+ return;
428
+ }
429
+ }
430
+ if (a.has("minmaxOptions") && Array.isArray(t)) {
431
+ let n = e.validation.find((e) => e.type === "minmaxOptions"), a = Number(o.min ?? n?.min ?? NaN), s = Number(o.max ?? n?.max ?? NaN);
432
+ if (Number.isFinite(a) && t.length < a) {
433
+ i[r] = [`Please select at least ${a} option${a === 1 ? "" : "s"}.`];
434
+ return;
435
+ }
436
+ if (Number.isFinite(s) && t.length > s) {
437
+ i[r] = [`Please select no more than ${s} option${s === 1 ? "" : "s"}.`];
438
+ return;
439
+ }
440
+ }
441
+ if (w(e)) {
442
+ let a = k(e), o = t && typeof t == "object" ? t : {};
443
+ a.forEach((e) => {
444
+ e.meta?.hidden !== !0 && V(e, o[e.handle], n, `${r}.${e.handle}`, i);
445
+ });
446
+ return;
447
+ }
448
+ if (T(e)) {
449
+ let a = Array.isArray(t) ? t : [], o = j(e);
450
+ a.forEach((e, t) => {
451
+ let a = e && typeof e == "object" ? e : {};
452
+ o.forEach((e) => {
453
+ V(e, a[e.handle], n, `${r}.${t}.${e.handle}`, i);
454
+ });
455
+ });
456
+ }
457
+ }
458
+ function ye(e) {
459
+ let t = {
460
+ form: [],
461
+ fields: {},
462
+ pages: {}
463
+ };
464
+ return pe(e, e.currentPageId).forEach((n) => {
465
+ let r = b(e.definition, n);
466
+ !r || e.fieldStates[n]?.hidden === !0 || e.fieldStates[n]?.disabled === !0 || V(r, e.values[n], e, n, t.fields);
467
+ }), Object.keys(t.fields).length > 0 && (t.form = [e.definition.settings.validation.formErrorMessage || "Please correct the highlighted fields."]), t;
468
+ }
469
+ function be({ envelope: e, transport: t }) {
470
+ let n = new _(), r = /* @__PURE__ */ new Set(), i = ue(e), a = {
471
+ status: "ready",
472
+ definition: e.definition,
473
+ session: e.session,
474
+ values: i,
475
+ errors: {
476
+ form: [],
477
+ fields: {},
478
+ pages: {}
479
+ },
480
+ fieldStates: de(e.definition),
481
+ pageStates: fe(e.definition),
482
+ currentPageId: e.session.currentPageId || e.definition.settings.initialPageId,
483
+ lastSubmitResult: null
484
+ };
485
+ a = B(a);
486
+ let o = () => {
487
+ let e = L(a);
488
+ r.forEach((t) => {
489
+ t(e);
490
+ });
491
+ }, s = (e) => {
492
+ a = e(a), o();
493
+ }, c = {
494
+ id: e.session.id,
495
+ getState() {
496
+ return L(a);
497
+ },
498
+ subscribe(e) {
499
+ return r.add(e), e(L(a)), () => {
500
+ r.delete(e);
501
+ };
502
+ },
503
+ setValue(e, t) {
504
+ s((n) => {
505
+ let r = Object.fromEntries(Object.entries(n.errors.fields).filter(([t]) => t !== e && !t.startsWith(`${e}.`)));
506
+ return r[e] = [], B({
507
+ ...n,
508
+ values: {
509
+ ...n.values,
510
+ [e]: t
511
+ },
512
+ errors: {
513
+ ...n.errors,
514
+ fields: r
515
+ }
516
+ });
517
+ });
518
+ },
519
+ patchValues(e) {
520
+ s((t) => B({
521
+ ...t,
522
+ values: {
523
+ ...t.values,
524
+ ...e
525
+ }
526
+ }));
527
+ },
528
+ async submit(e) {
529
+ let r = a.definition.pages.find((e) => e.id === a.currentPageId), i = e || r?.actions.primary.type || "submit", o = i === "next" ? "submit" : i;
530
+ if (o !== "back" && o !== "save" && a.definition.settings.validation.onSubmit) {
531
+ let e = ye(a);
532
+ if (e.form.length > 0 || Object.keys(e.fields).length > 0) {
533
+ let t = {
534
+ success: !1,
535
+ isFinalPage: !1,
536
+ errors: e,
537
+ messages: { error: e.form[0] || null },
538
+ session: a.session
539
+ };
540
+ return s((n) => ({
541
+ ...n,
542
+ errors: e,
543
+ lastSubmitResult: t
544
+ })), n.emit("formie:submit:result", t), t;
545
+ }
546
+ }
547
+ s((e) => ({
548
+ ...e,
549
+ status: "submitting",
550
+ errors: {
551
+ form: [],
552
+ fields: {},
553
+ pages: {}
554
+ }
555
+ }));
556
+ try {
557
+ let e = await t.submit({
558
+ definition: a.definition,
559
+ session: a.session,
560
+ values: a.values,
561
+ action: o
562
+ });
563
+ return s((t) => B({
564
+ ...t,
565
+ status: "ready",
566
+ session: e.session ?? t.session,
567
+ currentPageId: e.session?.currentPageId || e.currentPageId || t.currentPageId,
568
+ errors: e.errors,
569
+ lastSubmitResult: e
570
+ })), n.emit("formie:submit:result", e), (e.currentPageId || e.nextPageId) && n.emit("formie:page:navigate", {
571
+ currentPageId: a.currentPageId,
572
+ nextPageId: e.nextPageId || e.currentPageId
573
+ }), e;
574
+ } catch (e) {
575
+ let t = e instanceof Error ? e.message : "Submission failed.", r = {
576
+ success: !1,
577
+ isFinalPage: !1,
578
+ errors: {
579
+ form: [t],
580
+ fields: {},
581
+ pages: {}
582
+ },
583
+ messages: { error: t },
584
+ session: a.session
585
+ };
586
+ return s((e) => ({
587
+ ...e,
588
+ status: "ready",
589
+ errors: r.errors,
590
+ lastSubmitResult: r
591
+ })), n.emit("formie:submit:result", r), r;
592
+ }
593
+ },
594
+ async setPage(e) {
595
+ if (!t.setPage) {
596
+ s((t) => B({
597
+ ...t,
598
+ currentPageId: e,
599
+ session: {
600
+ ...t.session,
601
+ currentPageId: e
602
+ }
603
+ }));
604
+ return;
605
+ }
606
+ s((e) => ({
607
+ ...e,
608
+ status: "refreshing"
609
+ }));
610
+ try {
611
+ let r = await t.setPage({
612
+ definition: a.definition,
613
+ session: a.session,
614
+ values: a.values,
615
+ currentPageId: a.currentPageId,
616
+ targetPageId: e
617
+ });
618
+ s((e) => B({
619
+ ...e,
620
+ status: "ready",
621
+ session: r,
622
+ currentPageId: r.currentPageId
623
+ })), n.emit("formie:page:navigate", {
624
+ currentPageId: a.currentPageId,
625
+ nextPageId: e
626
+ });
627
+ } catch (t) {
628
+ let r = t instanceof Error ? t.message : "Unable to change page.";
629
+ s((e) => ({
630
+ ...e,
631
+ status: "ready"
632
+ })), n.emit("formie:page:navigate:error", {
633
+ currentPageId: a.currentPageId,
634
+ nextPageId: e,
635
+ error: r
636
+ });
637
+ }
638
+ },
639
+ async refreshSession() {
640
+ s((e) => ({
641
+ ...e,
642
+ status: "refreshing"
643
+ }));
644
+ try {
645
+ let e = await t.refreshSession({
646
+ formHandle: a.definition.handle,
647
+ siteId: a.definition.siteId ?? void 0,
648
+ session: a.session
649
+ });
650
+ s((t) => B({
651
+ ...t,
652
+ status: "ready",
653
+ session: e,
654
+ currentPageId: e.currentPageId || t.currentPageId
655
+ })), n.emit("formie:session:refreshed", e);
656
+ } catch (e) {
657
+ let t = e instanceof Error ? e.message : "Unable to refresh session.";
658
+ s((e) => ({
659
+ ...e,
660
+ status: "ready"
661
+ })), n.emit("formie:session:refresh:error", { error: t });
662
+ }
663
+ },
664
+ reset() {
665
+ s((t) => B({
666
+ ...t,
667
+ session: e.session,
668
+ values: { ...i },
669
+ errors: {
670
+ form: [],
671
+ fields: {},
672
+ pages: {}
673
+ },
674
+ currentPageId: e.session.currentPageId || e.definition.settings.initialPageId,
675
+ lastSubmitResult: null
676
+ })), n.emit("formie:state:reset", null);
677
+ },
678
+ async destroy() {
679
+ s((e) => ({
680
+ ...e,
681
+ status: "destroyed"
682
+ })), r.clear();
683
+ },
684
+ on(e, t) {
685
+ return n.on(e, t);
686
+ }
687
+ };
688
+ return queueMicrotask(() => {
689
+ n.emit("formie:client:ready", c.getState());
690
+ }), c;
691
+ }
692
+ //#endregion
693
+ //#region src/event-names.ts
694
+ var xe = [
695
+ "formie:client:ready",
696
+ "formie:submit:result",
697
+ "formie:page:navigate",
698
+ "formie:page:navigate:error",
699
+ "formie:session:refreshed",
700
+ "formie:session:refresh:error",
701
+ "formie:state:reset"
702
+ ], H = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
703
+ (function(n, r) {
704
+ typeof e == "object" && t !== void 0 ? r(e) : typeof define == "function" && define.amd ? define(["exports"], r) : r((n = typeof globalThis < "u" ? globalThis : n || self).ExpressionLanguage = {});
705
+ })(e, function(e) {
706
+ function t(e, t, n) {
707
+ return (t = function(e) {
708
+ var t = function(e, t) {
709
+ if (typeof e != "object" || !e) return e;
710
+ var n = e[Symbol.toPrimitive];
711
+ if (n !== void 0) {
712
+ var r = n.call(e, t);
713
+ if (typeof r != "object") return r;
714
+ throw TypeError("@@toPrimitive must return a primitive value.");
715
+ }
716
+ return (t === "string" ? String : Number)(e);
717
+ }(e, "string");
718
+ return typeof t == "symbol" ? t : t + "";
719
+ }(t)) in e ? Object.defineProperty(e, t, {
720
+ value: n,
721
+ enumerable: !0,
722
+ configurable: !0,
723
+ writable: !0
724
+ }) : e[t] = n, e;
725
+ }
726
+ let n = function(e, t) {
727
+ if (e.length === 0) return t.length;
728
+ if (t.length === 0) return e.length;
729
+ let n, r, i = [];
730
+ for (n = 0; n <= t.length; n++) i[n] = [n];
731
+ for (r = 0; r <= e.length; r++) i[0] === void 0 && (i[0] = []), i[0][r] = r;
732
+ for (n = 1; n <= t.length; n++) for (r = 1; r <= e.length; r++) t.charAt(n - 1) === e.charAt(r - 1) ? i[n][r] = i[n - 1][r - 1] : i[n][r] = Math.min(i[n - 1][r - 1] + 1, Math.min(i[n][r - 1] + 1, i[n - 1][r] + 1));
733
+ return i[t.length] === void 0 && (i[t.length] = []), i[t.length][e.length];
734
+ };
735
+ class r extends Error {
736
+ constructor(e, t, n, r, i) {
737
+ super(e), this.name = "SyntaxError", this.cursor = t, this.expression = n, this.subject = r, this.proposals = i;
738
+ }
739
+ toString() {
740
+ let e = `${this.name}: ${this.message} around position ${this.cursor}`;
741
+ if (this.expression && (e += ` for expression \`${this.expression}\``), e += ".", this.subject && this.proposals) {
742
+ let t = 2 ** 53 - 1, r = null;
743
+ for (let e of this.proposals) {
744
+ let i = n(this.subject, e);
745
+ i < t && (r = e, t = i);
746
+ }
747
+ r !== null && t < 3 && (e += ` Did you mean "${r}"?`);
748
+ }
749
+ return e;
750
+ }
751
+ }
752
+ class i {
753
+ constructor(e, n) {
754
+ t(this, "next", () => {
755
+ if (this.position += 1, this.tokens[this.position] === void 0) throw new r("Unexpected end of expression", this.last.cursor, this.expression);
756
+ }), t(this, "expect", (e, t, n) => {
757
+ let i = this.current;
758
+ if (!i.test(e, t)) {
759
+ let a = "";
760
+ n && (a = n + ". ");
761
+ let o = "";
762
+ throw t && (o = ` with value "${t}"`), a += `Unexpected token "${i.type}" of value "${i.value}" ("${e}" expected${o})`, new r(a, i.cursor, this.expression);
763
+ }
764
+ this.next();
765
+ }), t(this, "isEOF", () => a.EOF_TYPE === this.current.type), t(this, "isEqualTo", (e) => {
766
+ if (e == null || !e instanceof i || e.tokens.length !== this.tokens.length) return !1;
767
+ let t = e.position;
768
+ e.position = 0;
769
+ let n = !0;
770
+ for (let t of this.tokens) {
771
+ if (!e.current.isEqualTo(t)) {
772
+ n = !1;
773
+ break;
774
+ }
775
+ e.position < e.tokens.length - 1 && e.next();
776
+ }
777
+ return e.position = t, n;
778
+ }), t(this, "diff", (e) => {
779
+ let t = [];
780
+ if (!this.isEqualTo(e)) {
781
+ let n = e.position;
782
+ e.position = 0;
783
+ for (let n of this.tokens) {
784
+ let r = n.diff(e.current);
785
+ r.length > 0 && t.push({
786
+ index: 0,
787
+ diff: r
788
+ }), e.position < e.tokens.length - 1 && e.next();
789
+ }
790
+ e.position = n;
791
+ }
792
+ return t;
793
+ }), this.expression = e, this.position = 0, this.tokens = n;
794
+ }
795
+ get current() {
796
+ return this.tokens[this.position];
797
+ }
798
+ get last() {
799
+ return this.tokens[this.position - 1];
800
+ }
801
+ toString() {
802
+ return this.tokens.join("\n");
803
+ }
804
+ }
805
+ class a {
806
+ constructor(e, n, r) {
807
+ t(this, "test", (e, t = null) => this.type === e && (t === null || this.value === t)), t(this, "isEqualTo", (e) => !(e == null || !e instanceof a) && e.value == this.value && e.type === this.type && e.cursor === this.cursor), t(this, "diff", (e) => {
808
+ let t = [];
809
+ return this.isEqualTo(e) || (e.value !== this.value && t.push(`Value: ${e.value} != ${this.value}`), e.cursor !== this.cursor && t.push(`Cursor: ${e.cursor} != ${this.cursor}`), e.type !== this.type && t.push(`Type: ${e.type} != ${this.type}`)), t;
810
+ }), this.value = n, this.type = e, this.cursor = r;
811
+ }
812
+ toString() {
813
+ return `${this.cursor} [${this.type}] ${this.value}`;
814
+ }
815
+ }
816
+ function o(e) {
817
+ let t = 0, n = [], o = [], c = (e = e.replace(/\r|\n|\t|\v|\f/g, " ")).length;
818
+ for (; t < c;) {
819
+ if (e[t] === " ") {
820
+ ++t;
821
+ continue;
822
+ }
823
+ if (e.substr(t, 2) === "/*") {
824
+ let n = e.indexOf("*/", t + 2);
825
+ if (n === -1) {
826
+ t = c;
827
+ break;
828
+ }
829
+ t = n + 2;
830
+ continue;
831
+ }
832
+ let i = s(e.substr(t));
833
+ if (i !== null) {
834
+ let e = i.length, r = i.replace(/_/g, "");
835
+ i = r.indexOf(".") === -1 && r.indexOf("e") === -1 && r.indexOf("E") === -1 ? parseInt(r, 10) : parseFloat(r), n.push(new a(a.NUMBER_TYPE, i, t + 1)), t += e;
836
+ } else if ("([{".indexOf(e[t]) >= 0) o.push([e[t], t]), n.push(new a(a.PUNCTUATION_TYPE, e[t], t + 1)), ++t;
837
+ else if (")]}".indexOf(e[t]) >= 0) {
838
+ if (o.length === 0) throw new r(`Unexpected "${e[t]}"`, t, e);
839
+ let [i, s] = o.pop(), c = i.replace("(", ")").replace("{", "}").replace("[", "]");
840
+ if (e[t] !== c) throw new r(`Unclosed "${i}"`, s, e);
841
+ n.push(new a(a.PUNCTUATION_TYPE, e[t], t + 1)), ++t;
842
+ } else {
843
+ let i = u(e.substr(t));
844
+ if (i !== null) n.push(new a(a.STRING_TYPE, i.captured, t + 1)), t += i.length;
845
+ else if (e.substr(t, 2) === "\\\\") n.push(new a(a.PUNCTUATION_TYPE, "\\", t + 1)), t += 2;
846
+ else {
847
+ let i = n.length > 0 ? n[n.length - 1] : null;
848
+ if (i && i.type === a.PUNCTUATION_TYPE && (i.value === "." || i.value === "?.")) {
849
+ let i = m(e.substr(t));
850
+ if (i) n.push(new a(a.NAME_TYPE, i, t + 1)), t += i.length;
851
+ else {
852
+ let i = p(e.substr(t));
853
+ if (i) n.push(new a(a.OPERATOR_TYPE, i, t + 1)), t += i.length;
854
+ else if (e.substr(t, 2) === "?." || e.substr(t, 2) === "??") n.push(new a(a.PUNCTUATION_TYPE, e.substr(t, 2), t + 1)), t += 2;
855
+ else {
856
+ if (!(".,?:".indexOf(e[t]) >= 0)) throw new r(`Unexpected character "${e[t]}"`, t, e);
857
+ n.push(new a(a.PUNCTUATION_TYPE, e[t], t + 1)), ++t;
858
+ }
859
+ }
860
+ } else {
861
+ let i = p(e.substr(t));
862
+ if (i) n.push(new a(a.OPERATOR_TYPE, i, t + 1)), t += i.length;
863
+ else if (e.substr(t, 2) === "?." || e.substr(t, 2) === "??") n.push(new a(a.PUNCTUATION_TYPE, e.substr(t, 2), t + 1)), t += 2;
864
+ else if (".,?:".indexOf(e[t]) >= 0) n.push(new a(a.PUNCTUATION_TYPE, e[t], t + 1)), ++t;
865
+ else {
866
+ let i = m(e.substr(t));
867
+ if (!i) throw new r(`Unexpected character "${e[t]}"`, t, e);
868
+ n.push(new a(a.NAME_TYPE, i, t + 1)), t += i.length;
869
+ }
870
+ }
871
+ }
872
+ }
873
+ }
874
+ if (n.push(new a(a.EOF_TYPE, null, t + 1)), o.length > 0) {
875
+ let [t, n] = o.pop();
876
+ throw new r(`Unclosed "${t}"`, n, e);
877
+ }
878
+ return new i(e, n);
879
+ }
880
+ function s(e) {
881
+ let t = null, n = e.match(/^(?:((?:\d(?:_?\d)*)\.(?:\d(?:_?\d)*)|\.(?:\d(?:_?\d)*)|(?:\d(?:_?\d)*))(?:[eE][+-]?\d(?:_?\d)*)?)/);
882
+ return n && n.length > 0 && (t = n[0]), t;
883
+ }
884
+ t(a, "EOF_TYPE", "end of expression"), t(a, "NAME_TYPE", "name"), t(a, "NUMBER_TYPE", "number"), t(a, "STRING_TYPE", "string"), t(a, "OPERATOR_TYPE", "operator"), t(a, "PUNCTUATION_TYPE", "punctuation");
885
+ let c = /^"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/s;
886
+ function l(e, t) {
887
+ return t === "\"" ? e = e.replace(/\\\"/g, "\"") : t === "'" && (e = e.replace(/\\'/g, "'")), e = e.replace(/\\\\/g, "\\");
888
+ }
889
+ function u(e) {
890
+ let t = null;
891
+ if (["'", "\""].indexOf(e.substr(0, 1)) === -1) return t;
892
+ let n = c.exec(e);
893
+ return n !== null && n.length > 0 && (t = n[1] === void 0 ? { captured: l(n[2], "'") } : { captured: l(n[1], "\"") }, t.length = n[0].length), t;
894
+ }
895
+ let d = /* @__PURE__ */ "&&,and,||,or,+,-,**,*,/,%,&,|,^,>>,<<,===,!==,!=,==,<=,>=,<,>,contains,matches,starts with,ends with,not in,in,not,!,xor,~,..".split(","), f = [
896
+ "and",
897
+ "or",
898
+ "matches",
899
+ "contains",
900
+ "starts with",
901
+ "ends with",
902
+ "not in",
903
+ "in",
904
+ "not",
905
+ "xor"
906
+ ];
907
+ function p(e) {
908
+ let t = null;
909
+ for (let n of d) if (e.substr(0, n.length) === n) {
910
+ f.indexOf(n) >= 0 ? e.substr(0, n.length + 1) === n + " " && (t = n) : t = n;
911
+ break;
912
+ }
913
+ return t;
914
+ }
915
+ function m(e) {
916
+ let t = null, n = e.match(/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/);
917
+ return n && n.length > 0 && (t = n[0]), t;
918
+ }
919
+ function h(e) {
920
+ return /boolean|number|string/.test(typeof e);
921
+ }
922
+ function g(e, t) {
923
+ var n = "", r = [], i = 0, a = 0, o = "", s = "", c = "", l = "", u = "", d = 0, f = 0, p = 0, m = 0, h = 0, g = [], _ = "", v = /%([\dA-Fa-f]+)/g, y = function(e, t) {
924
+ return (e += "").length < t ? Array(++t - e.length).join("0") + e : e;
925
+ };
926
+ for (i = 0; i < t.length; i++) if (o = t.charAt(i), s = t.charAt(i + 1), o === "\\" && s && /\d/.test(s)) {
927
+ if (m = i + (p = (c = t.slice(i + 1).match(/^\d+/)[0]).length) + 1, t.charAt(m) + t.charAt(m + 1) === "..") {
928
+ if (d = c.charCodeAt(0), /\\\d/.test(t.charAt(m + 2) + t.charAt(m + 3))) l = t.slice(m + 3).match(/^\d+/)[0], i += 1;
929
+ else {
930
+ if (!t.charAt(m + 2)) throw Error("Range with no end point");
931
+ l = t.charAt(m + 2);
932
+ }
933
+ if ((f = l.charCodeAt(0)) > d) for (a = d; a <= f; a++) r.push(String.fromCharCode(a));
934
+ else r.push(".", c, l);
935
+ i += l.length + 2;
936
+ } else u = String.fromCharCode(parseInt(c, 8)), r.push(u);
937
+ i += p;
938
+ } else if (s + t.charAt(i + 2) === "..") {
939
+ if (d = (c = o).charCodeAt(0), /\\\d/.test(t.charAt(i + 3) + t.charAt(i + 4))) l = t.slice(i + 4).match(/^\d+/)[0], i += 1;
940
+ else {
941
+ if (!t.charAt(i + 3)) throw Error("Range with no end point");
942
+ l = t.charAt(i + 3);
943
+ }
944
+ if ((f = l.charCodeAt(0)) > d) for (a = d; a <= f; a++) r.push(String.fromCharCode(a));
945
+ else r.push(".", c, l);
946
+ i += l.length + 2;
947
+ } else r.push(o);
948
+ for (i = 0; i < e.length; i++) if (o = e.charAt(i), r.indexOf(o) !== -1) if (n += "\\", (h = o.charCodeAt(0)) < 32 || h > 126) switch (o) {
949
+ case "\n":
950
+ n += "n";
951
+ break;
952
+ case " ":
953
+ n += "t";
954
+ break;
955
+ case "\r":
956
+ n += "r";
957
+ break;
958
+ case "\x07":
959
+ n += "a";
960
+ break;
961
+ case "\v":
962
+ n += "v";
963
+ break;
964
+ case "\b":
965
+ n += "b";
966
+ break;
967
+ case "\f":
968
+ n += "f";
969
+ break;
970
+ default: for (_ = encodeURIComponent(o), (g = v.exec(_)) !== null && (n += y(parseInt(g[1], 16).toString(8), 3)); (g = v.exec(_)) !== null;) n += "\\" + y(parseInt(g[1], 16).toString(8), 3);
971
+ }
972
+ else n += o;
973
+ else n += o;
974
+ return n;
975
+ }
976
+ class _ {
977
+ constructor(e = {}, n = {}) {
978
+ t(this, "compile", (e) => {
979
+ for (let t of Object.values(this.nodes)) t.compile(e);
980
+ }), t(this, "evaluate", (e, t) => {
981
+ let n = [];
982
+ for (let r of Object.values(this.nodes)) n.push(r.evaluate(e, t));
983
+ return n;
984
+ }), t(this, "toArray", () => {
985
+ throw Error(`Dumping a "${this.name}" instance is not supported yet.`);
986
+ }), t(this, "dump", () => {
987
+ let e = "";
988
+ for (let t of this.toArray()) e += h(t) ? t : t.dump();
989
+ return e;
990
+ }), t(this, "dumpString", (e) => `"${g(e, "\0 \"\\")}"`), t(this, "isHash", (e) => {
991
+ let t = 0;
992
+ for (let n of Object.keys(e)) if (n = parseInt(n), n !== t++) return !0;
993
+ return !1;
994
+ }), this.name = "Node", this.nodes = e, this.attributes = n;
995
+ }
996
+ toString() {
997
+ let e = [];
998
+ for (let t of Object.keys(this.attributes)) {
999
+ let n = "null";
1000
+ this.attributes[t] && (n = this.attributes[t].toString()), e.push(`${t}: '${n}'`);
1001
+ }
1002
+ let t = [this.name + "(" + e.join(", ")];
1003
+ if (this.nodes.length > 0) {
1004
+ for (let e of Object.values(this.nodes)) {
1005
+ let n = e.toString().split("\n");
1006
+ for (let e of n) t.push(" " + e);
1007
+ }
1008
+ t.push(")");
1009
+ } else t[0] += ")";
1010
+ return t.join("\n");
1011
+ }
1012
+ }
1013
+ class v extends _ {
1014
+ constructor(e, n, r) {
1015
+ super({
1016
+ left: n,
1017
+ right: r
1018
+ }, { operator: e }), t(this, "compile", (e) => {
1019
+ let t = this.attributes.operator;
1020
+ t === "matches" ? e.compile(this.nodes.right).raw(".test(").compile(this.nodes.left).raw(")") : t === "contains" ? e.raw("(").compile(this.nodes.left).raw(".toString().toLowerCase().includes(").compile(this.nodes.right).raw(".toString().toLowerCase())") : t === "starts with" ? e.raw("(").compile(this.nodes.left).raw(".toString().toLowerCase().startsWith(").compile(this.nodes.right).raw(".toString().toLowerCase())") : t === "ends with" ? e.raw("(").compile(this.nodes.left).raw(".toString().toLowerCase().endsWith(").compile(this.nodes.right).raw(".toString().toLowerCase())") : v.functions[t] === void 0 ? (v.operators[t] !== void 0 && (t = v.operators[t]), e.raw("(").compile(this.nodes.left).raw(" ").raw(t).raw(" ").compile(this.nodes.right).raw(")")) : e.raw(`${v.functions[t]}(`).compile(this.nodes.left).raw(", ").compile(this.nodes.right).raw(")");
1021
+ }), t(this, "evaluate", (e, t) => {
1022
+ let n = this.attributes.operator, r = this.nodes.left.evaluate(e, t);
1023
+ if (v.functions[n] !== void 0) {
1024
+ let i = this.nodes.right.evaluate(e, t);
1025
+ switch (n) {
1026
+ case "not in": return i.indexOf(r) === -1;
1027
+ case "in": return i.indexOf(r) >= 0;
1028
+ case "..": return function(e, t) {
1029
+ let n = [];
1030
+ for (let r = e; r <= t; r++) n.push(r);
1031
+ return n;
1032
+ }(r, i);
1033
+ case "**": return r ** +i;
1034
+ }
1035
+ }
1036
+ let i = null;
1037
+ switch (n) {
1038
+ case "or":
1039
+ case "||": return r || (i = this.nodes.right.evaluate(e, t)), r || i;
1040
+ case "and":
1041
+ case "&&": return r && (i = this.nodes.right.evaluate(e, t)), r && i;
1042
+ case "xor": return i = this.nodes.right.evaluate(e, t), i && !r || r && !i;
1043
+ case "<<": return i = this.nodes.right.evaluate(e, t), r << i;
1044
+ case ">>": return i = this.nodes.right.evaluate(e, t), r >> i;
1045
+ }
1046
+ switch (i = this.nodes.right.evaluate(e, t), n) {
1047
+ case "|": return r | i;
1048
+ case "^": return r ^ i;
1049
+ case "&": return r & i;
1050
+ case "==": return r == i;
1051
+ case "===": return r === i;
1052
+ case "!=": return r != i;
1053
+ case "!==": return r !== i;
1054
+ case "<": return r < i;
1055
+ case ">": return r > i;
1056
+ case ">=": return r >= i;
1057
+ case "<=": return r <= i;
1058
+ case "not in": return i.indexOf(r) === -1;
1059
+ case "in": return i.indexOf(r) >= 0;
1060
+ case "+": return r + i;
1061
+ case "-": return r - i;
1062
+ case "~": return r.toString() + i.toString();
1063
+ case "*": return r * i;
1064
+ case "/": return r / i;
1065
+ case "%": return r % i;
1066
+ case "matches":
1067
+ if (r == null) return !1;
1068
+ let e = i.match(v.regex_expression);
1069
+ return new RegExp(e[1], e[2]).test(r);
1070
+ case "contains": return r.toString().toLowerCase().includes(i.toString().toLowerCase());
1071
+ case "starts with": return r.toString().toLowerCase().startsWith(i.toString().toLowerCase());
1072
+ case "ends with": return r.toString().toLowerCase().endsWith(i.toString().toLowerCase());
1073
+ }
1074
+ }), t(this, "toArray", () => [
1075
+ "(",
1076
+ this.nodes.left,
1077
+ " " + this.attributes.operator + " ",
1078
+ this.nodes.right,
1079
+ ")"
1080
+ ]), this.name = "BinaryNode";
1081
+ }
1082
+ }
1083
+ t(v, "regex_expression", /\/(.+)\/(.*)/), t(v, "operators", {
1084
+ "~": ".",
1085
+ and: "&&",
1086
+ or: "||",
1087
+ xor: "xor",
1088
+ "<<": "<<",
1089
+ ">>": ">>"
1090
+ }), t(v, "functions", {
1091
+ "**": "Math.pow",
1092
+ "..": "range",
1093
+ in: "includes",
1094
+ "not in": "!includes"
1095
+ });
1096
+ class y extends _ {
1097
+ constructor(e, n) {
1098
+ super({ node: n }, { operator: e }), t(this, "compile", (e) => {
1099
+ e.raw("(").raw(y.operators[this.attributes.operator]).compile(this.nodes.node).raw(")");
1100
+ }), t(this, "evaluate", (e, t) => {
1101
+ let n = this.nodes.node.evaluate(e, t);
1102
+ switch (this.attributes.operator) {
1103
+ case "not":
1104
+ case "!": return !n;
1105
+ case "-": return -n;
1106
+ case "~": return ~n;
1107
+ }
1108
+ return n;
1109
+ }), t(this, "toArray", () => [
1110
+ "(",
1111
+ this.attributes.operator + " ",
1112
+ this.nodes.node,
1113
+ ")"
1114
+ ]), this.name = "UnaryNode";
1115
+ }
1116
+ }
1117
+ t(y, "operators", {
1118
+ "!": "!",
1119
+ not: "!",
1120
+ "+": "+",
1121
+ "-": "-",
1122
+ "~": "~"
1123
+ });
1124
+ class b extends _ {
1125
+ constructor(e, n = !1, r = !1) {
1126
+ super({}, { value: e }), t(this, "compile", (e) => {
1127
+ e.repr(this.attributes.value, this.isIdentifier);
1128
+ }), t(this, "evaluate", (e, t) => this.attributes.value), t(this, "toArray", () => {
1129
+ let e = [], t = this.attributes.value;
1130
+ if (this.isIdentifier) e.push(t);
1131
+ else if (!0 === t) e.push("true");
1132
+ else if (!1 === t) e.push("false");
1133
+ else if (t === null) e.push("null");
1134
+ else if (typeof t == "number") e.push(t);
1135
+ else if (typeof t == "string") e.push(this.dumpString(t));
1136
+ else if (Array.isArray(t)) {
1137
+ for (let n of t) e.push(","), e.push(new b(n));
1138
+ e[0] = "[", e.push("]");
1139
+ } else if (this.isHash(t)) {
1140
+ for (let n of Object.keys(t)) e.push(", "), e.push(new b(n)), e.push(": "), e.push(new b(t[n]));
1141
+ e[0] = "{", e.push("}");
1142
+ }
1143
+ return e;
1144
+ }), this.isIdentifier = n, this.isNullSafe = r, this.name = "ConstantNode";
1145
+ }
1146
+ }
1147
+ class x extends _ {
1148
+ constructor(e, n, r) {
1149
+ super({
1150
+ expr1: e,
1151
+ expr2: n,
1152
+ expr3: r
1153
+ }), t(this, "compile", (e) => {
1154
+ e.raw("((").compile(this.nodes.expr1).raw(") ? (").compile(this.nodes.expr2).raw(") : (").compile(this.nodes.expr3).raw("))");
1155
+ }), t(this, "evaluate", (e, t) => this.nodes.expr1.evaluate(e, t) ? this.nodes.expr2.evaluate(e, t) : this.nodes.expr3.evaluate(e, t)), t(this, "toArray", () => [
1156
+ "(",
1157
+ this.nodes.expr1,
1158
+ " ? ",
1159
+ this.nodes.expr2,
1160
+ " : ",
1161
+ this.nodes.expr3,
1162
+ ")"
1163
+ ]), this.name = "ConditionalNode";
1164
+ }
1165
+ }
1166
+ class ee extends _ {
1167
+ constructor(e, n) {
1168
+ super({ fnArguments: n }, { name: e }), t(this, "compile", (e) => {
1169
+ let t = [];
1170
+ for (let n of Object.values(this.nodes.fnArguments.nodes)) t.push(e.subcompile(n));
1171
+ let n = e.getFunction(this.attributes.name);
1172
+ e.raw(n.compiler.apply(null, t));
1173
+ }), t(this, "evaluate", (e, t) => {
1174
+ let n = [t];
1175
+ for (let r of Object.values(this.nodes.fnArguments.nodes)) n.push(r.evaluate(e, t));
1176
+ return e[this.attributes.name].evaluator.apply(null, n);
1177
+ }), t(this, "toArray", () => {
1178
+ let e = [];
1179
+ e.push(this.attributes.name);
1180
+ for (let t of Object.values(this.nodes.fnArguments.nodes)) e.push(", "), e.push(t);
1181
+ return e[1] = "(", e.push(")"), e;
1182
+ }), this.name = "FunctionNode";
1183
+ }
1184
+ }
1185
+ class te extends _ {
1186
+ constructor(e) {
1187
+ super({}, { name: e }), t(this, "compile", (e) => {
1188
+ e.raw(this.attributes.name);
1189
+ }), t(this, "evaluate", (e, t) => t[this.attributes.name]), t(this, "toArray", () => [this.attributes.name]), this.name = "NameNode";
1190
+ }
1191
+ }
1192
+ class S extends _ {
1193
+ constructor() {
1194
+ super(), t(this, "addElement", (e, t = null) => {
1195
+ t === null ? t = new b(++this.index) : this.type === "Array" && (this.type = "Object"), this.nodes[(++this.keyIndex).toString()] = t, this.nodes[(++this.keyIndex).toString()] = e;
1196
+ }), t(this, "compile", (e) => {
1197
+ this.type === "Object" ? e.raw("{") : e.raw("["), this.compileArguments(e, this.type !== "Array"), this.type === "Object" ? e.raw("}") : e.raw("]");
1198
+ }), t(this, "evaluate", (e, t) => {
1199
+ let n;
1200
+ if (this.type === "Array") {
1201
+ n = [];
1202
+ for (let r of this.getKeyValuePairs()) n.push(r.value.evaluate(e, t));
1203
+ } else {
1204
+ n = {};
1205
+ for (let r of this.getKeyValuePairs()) n[r.key.evaluate(e, t)] = r.value.evaluate(e, t);
1206
+ }
1207
+ return n;
1208
+ }), t(this, "toArray", () => {
1209
+ let e = {};
1210
+ for (let t of this.getKeyValuePairs()) e[t.key.attributes.value] = t.value;
1211
+ let t = [];
1212
+ if (this.isHash(e)) {
1213
+ for (let n of Object.keys(e)) t.push(", "), t.push(new b(n)), t.push(": "), t.push(e[n]);
1214
+ t[0] = "{", t.push("}");
1215
+ } else {
1216
+ for (let n of Object.values(e)) t.push(", "), t.push(n);
1217
+ t[0] = "[", t.push("]");
1218
+ }
1219
+ return t;
1220
+ }), t(this, "getKeyValuePairs", () => {
1221
+ let e, t, n, r = [], i = Object.values(this.nodes);
1222
+ for (e = 0, t = i.length; e < t; e += 2) n = i.slice(e, e + 2), r.push({
1223
+ key: n[0],
1224
+ value: n[1]
1225
+ });
1226
+ return r;
1227
+ }), t(this, "compileArguments", (e, t = !0) => {
1228
+ let n = !0;
1229
+ for (let r of this.getKeyValuePairs()) n || e.raw(", "), n = !1, t && e.compile(r.key).raw(": "), e.compile(r.value);
1230
+ }), this.name = "ArrayNode", this.type = "Array", this.index = -1, this.keyIndex = -1;
1231
+ }
1232
+ }
1233
+ class C extends S {
1234
+ constructor() {
1235
+ super(), t(this, "compile", (e) => {
1236
+ this.compileArguments(e, !1);
1237
+ }), t(this, "toArray", () => {
1238
+ let e = [];
1239
+ for (let t of this.getKeyValuePairs()) e.push(t.value), e.push(", ");
1240
+ return e.pop(), e;
1241
+ }), this.name = "ArgumentsNode";
1242
+ }
1243
+ }
1244
+ class w extends _ {
1245
+ constructor(e, n, r, i) {
1246
+ super({
1247
+ node: e,
1248
+ attribute: n,
1249
+ fnArguments: r
1250
+ }, {
1251
+ type: i,
1252
+ is_null_coalesce: !1,
1253
+ is_short_circuited: !1
1254
+ }), t(this, "compile", (e) => {
1255
+ let t = this.nodes.attribute instanceof b && this.nodes.attribute.isNullSafe;
1256
+ switch (this.attributes.type) {
1257
+ case w.PROPERTY_CALL:
1258
+ e.compile(this.nodes.node).raw(t ? "?." : ".").raw(this.nodes.attribute.attributes.value);
1259
+ break;
1260
+ case w.METHOD_CALL:
1261
+ e.compile(this.nodes.node).raw(t ? "?." : ".").raw(this.nodes.attribute.attributes.value).raw("(").compile(this.nodes.fnArguments).raw(")");
1262
+ break;
1263
+ case w.ARRAY_CALL: e.compile(this.nodes.node).raw("[").compile(this.nodes.attribute).raw("]");
1264
+ }
1265
+ }), t(this, "evaluate", (e, t) => {
1266
+ switch (this.attributes.type) {
1267
+ case w.PROPERTY_CALL:
1268
+ let n = this.nodes.node.evaluate(e, t);
1269
+ if (n === null && (this.nodes.attribute.isNullSafe || this.attributes.is_null_coalesce)) return this.attributes.is_short_circuited = !0, null;
1270
+ if (n === null && this.isShortCircuited()) return null;
1271
+ if (typeof n != "object") throw Error(`Unable to get property "${r}" on a non-object: ` + typeof n);
1272
+ let r = this.nodes.attribute.attributes.value;
1273
+ return this.attributes.is_null_coalesce ? n[r] ?? null : n[r];
1274
+ case w.METHOD_CALL:
1275
+ let i = this.nodes.node.evaluate(e, t);
1276
+ if (i === null && this.nodes.attribute.isNullSafe) return this.attributes.is_short_circuited = !0, null;
1277
+ if (i === null && this.isShortCircuited()) return null;
1278
+ let a = this.nodes.attribute.attributes.value;
1279
+ if (typeof i != "object") throw Error(`Unable to call method "${a}" on a non-object: ` + typeof i);
1280
+ if (i[a] === void 0) throw Error(`Method "${a}" is undefined on object.`);
1281
+ if (typeof i[a] != "function") throw Error(`Method "${a}" is not a function on object.`);
1282
+ let o = this.nodes.fnArguments.evaluate(e, t);
1283
+ return i[a].apply(null, o);
1284
+ case w.ARRAY_CALL:
1285
+ let s = this.nodes.node.evaluate(e, t);
1286
+ if (s === null && this.isShortCircuited()) return null;
1287
+ if (!(Array.isArray(s) || typeof s == "object" || s === null && this.attributes.is_null_coalesce)) throw Error("Unable to get an item on a non-array: " + typeof s);
1288
+ return this.attributes.is_null_coalesce ? s ? s[this.nodes.attribute.evaluate(e, t)] ?? null : null : s[this.nodes.attribute.evaluate(e, t)];
1289
+ }
1290
+ }), t(this, "toArray", () => {
1291
+ let e = this.nodes.attribute instanceof b && this.nodes.attribute.isNullSafe;
1292
+ switch (this.attributes.type) {
1293
+ case w.PROPERTY_CALL: return [
1294
+ this.nodes.node,
1295
+ e ? "?." : ".",
1296
+ this.nodes.attribute
1297
+ ];
1298
+ case w.METHOD_CALL: return [
1299
+ this.nodes.node,
1300
+ e ? "?." : ".",
1301
+ this.nodes.attribute,
1302
+ "(",
1303
+ this.nodes.fnArguments,
1304
+ ")"
1305
+ ];
1306
+ case w.ARRAY_CALL: return [
1307
+ this.nodes.node,
1308
+ "[",
1309
+ this.nodes.attribute,
1310
+ "]"
1311
+ ];
1312
+ }
1313
+ }), this.name = "GetAttrNode";
1314
+ }
1315
+ isShortCircuited() {
1316
+ return this.attributes.is_short_circuited || this.nodes.node instanceof w && this.nodes.node.isShortCircuited();
1317
+ }
1318
+ }
1319
+ t(w, "PROPERTY_CALL", 1), t(w, "METHOD_CALL", 2), t(w, "ARRAY_CALL", 3);
1320
+ class T extends _ {
1321
+ constructor(e, n) {
1322
+ super({
1323
+ expr1: e,
1324
+ expr2: n
1325
+ }), t(this, "compile", (e) => {
1326
+ e.raw("((").compile(this.nodes.expr1).raw(") ?? (").compile(this.nodes.expr2).raw("))");
1327
+ }), t(this, "evaluate", (e, t) => (this.nodes.expr1 instanceof w && this._addNullCoalesceAttributeToGetAttrNodes(this.nodes.expr1), this.nodes.expr1.evaluate(e, t) ?? this.nodes.expr2.evaluate(e, t))), t(this, "toArray", () => [
1328
+ "(",
1329
+ this.nodes.expr1,
1330
+ ") ?? (",
1331
+ this.nodes.expr2,
1332
+ ")"
1333
+ ]), t(this, "_addNullCoalesceAttributeToGetAttrNodes", (e) => {
1334
+ if (!(!e instanceof w)) {
1335
+ e.attributes.is_null_coalesce = !0;
1336
+ for (let t of Object.values(e.nodes)) this._addNullCoalesceAttributeToGetAttrNodes(t);
1337
+ }
1338
+ }), this.name = "NullCoalesceNode";
1339
+ }
1340
+ }
1341
+ class E extends _ {
1342
+ constructor(e) {
1343
+ super({}, { name: e }), t(this, "compile", (e) => {
1344
+ e.raw(this.attributes.name + " ?? null");
1345
+ }), t(this, "evaluate", (e, t) => null), t(this, "toArray", () => [this.attributes.name + " ?? null"]), this.name = "NullCoalescedNameNode";
1346
+ }
1347
+ }
1348
+ class D {
1349
+ constructor(e = {}) {
1350
+ t(this, "functions", {}), t(this, "unaryOperators", {
1351
+ not: { precedence: 50 },
1352
+ "!": { precedence: 50 },
1353
+ "-": { precedence: 500 },
1354
+ "+": { precedence: 500 },
1355
+ "~": { precedence: 500 }
1356
+ }), t(this, "binaryOperators", {
1357
+ or: {
1358
+ precedence: 10,
1359
+ associativity: 1
1360
+ },
1361
+ "||": {
1362
+ precedence: 10,
1363
+ associativity: 1
1364
+ },
1365
+ xor: {
1366
+ precedence: 12,
1367
+ associativity: 1
1368
+ },
1369
+ and: {
1370
+ precedence: 15,
1371
+ associativity: 1
1372
+ },
1373
+ "&&": {
1374
+ precedence: 15,
1375
+ associativity: 1
1376
+ },
1377
+ "|": {
1378
+ precedence: 16,
1379
+ associativity: 1
1380
+ },
1381
+ "^": {
1382
+ precedence: 17,
1383
+ associativity: 1
1384
+ },
1385
+ "&": {
1386
+ precedence: 18,
1387
+ associativity: 1
1388
+ },
1389
+ "==": {
1390
+ precedence: 20,
1391
+ associativity: 1
1392
+ },
1393
+ "===": {
1394
+ precedence: 20,
1395
+ associativity: 1
1396
+ },
1397
+ "!=": {
1398
+ precedence: 20,
1399
+ associativity: 1
1400
+ },
1401
+ "!==": {
1402
+ precedence: 20,
1403
+ associativity: 1
1404
+ },
1405
+ "<": {
1406
+ precedence: 20,
1407
+ associativity: 1
1408
+ },
1409
+ ">": {
1410
+ precedence: 20,
1411
+ associativity: 1
1412
+ },
1413
+ ">=": {
1414
+ precedence: 20,
1415
+ associativity: 1
1416
+ },
1417
+ "<=": {
1418
+ precedence: 20,
1419
+ associativity: 1
1420
+ },
1421
+ "not in": {
1422
+ precedence: 20,
1423
+ associativity: 1
1424
+ },
1425
+ in: {
1426
+ precedence: 20,
1427
+ associativity: 1
1428
+ },
1429
+ matches: {
1430
+ precedence: 20,
1431
+ associativity: 1
1432
+ },
1433
+ contains: {
1434
+ precedence: 20,
1435
+ associativity: 1
1436
+ },
1437
+ "starts with": {
1438
+ precedence: 20,
1439
+ associativity: 1
1440
+ },
1441
+ "ends with": {
1442
+ precedence: 20,
1443
+ associativity: 1
1444
+ },
1445
+ "..": {
1446
+ precedence: 25,
1447
+ associativity: 1
1448
+ },
1449
+ "<<": {
1450
+ precedence: 25,
1451
+ associativity: 1
1452
+ },
1453
+ ">>": {
1454
+ precedence: 25,
1455
+ associativity: 1
1456
+ },
1457
+ "+": {
1458
+ precedence: 30,
1459
+ associativity: 1
1460
+ },
1461
+ "-": {
1462
+ precedence: 30,
1463
+ associativity: 1
1464
+ },
1465
+ "~": {
1466
+ precedence: 40,
1467
+ associativity: 1
1468
+ },
1469
+ "*": {
1470
+ precedence: 60,
1471
+ associativity: 1
1472
+ },
1473
+ "/": {
1474
+ precedence: 60,
1475
+ associativity: 1
1476
+ },
1477
+ "%": {
1478
+ precedence: 60,
1479
+ associativity: 1
1480
+ },
1481
+ "**": {
1482
+ precedence: 200,
1483
+ associativity: 2
1484
+ }
1485
+ }), t(this, "parse", (e, t = [], n = 0) => {
1486
+ this.tokenStream = e, this.names = t, this.objectMatches = {}, this.cachedNames = null, this.nestedExecutions = 0, this.flags = n;
1487
+ let i = this.parseExpression();
1488
+ if (!this.tokenStream.isEOF()) throw new r(`Unexpected token "${this.tokenStream.current.type}" of value "${this.tokenStream.current.value}"`, this.tokenStream.current.cursor, this.tokenStream.expression);
1489
+ return i;
1490
+ }), t(this, "lint", (e, t = [], n = 0) => {
1491
+ t === null && (console.log("Deprecated: passing \"null\" as the second argument of lint is deprecated, pass IGNORE_UNKNOWN_VARIABLES instead as the third argument"), n |= 1, t = []), this.parse(e, t, n);
1492
+ }), t(this, "parseExpression", (e = 0) => {
1493
+ let t = this.getPrimary(), n = this.tokenStream.current;
1494
+ if (this.nestedExecutions++, this.nestedExecutions > 1e3) throw Error("Way to many executions on '" + n.toString() + "' of '" + this.tokenStream.toString() + "'");
1495
+ for (; n.test(a.OPERATOR_TYPE) && this.binaryOperators[n.value] !== void 0 && this.binaryOperators[n.value] !== null && this.binaryOperators[n.value].precedence >= e;) {
1496
+ let e = this.binaryOperators[n.value];
1497
+ this.tokenStream.next();
1498
+ let r = this.parseExpression(e.associativity === 1 ? e.precedence + 1 : e.precedence);
1499
+ t = new v(n.value, t, r), n = this.tokenStream.current;
1500
+ }
1501
+ return e === 0 ? this.parseConditionalExpression(t) : t;
1502
+ }), t(this, "getPrimary", () => {
1503
+ let e = this.tokenStream.current;
1504
+ if (e.test(a.OPERATOR_TYPE) && this.unaryOperators[e.value] !== void 0 && this.unaryOperators[e.value] !== null) {
1505
+ let t = this.unaryOperators[e.value];
1506
+ this.tokenStream.next();
1507
+ let n = this.parseExpression(t.precedence);
1508
+ return this.parsePostfixExpression(new y(e.value, n));
1509
+ }
1510
+ if (e.test(a.PUNCTUATION_TYPE, "(")) {
1511
+ this.tokenStream.next();
1512
+ let e = this.parseExpression();
1513
+ return this.tokenStream.expect(a.PUNCTUATION_TYPE, ")", "An opened parenthesis is not properly closed"), this.parsePostfixExpression(e);
1514
+ }
1515
+ return this.parsePrimaryExpression();
1516
+ }), t(this, "hasVariable", (e) => this.getNames().indexOf(e) >= 0), t(this, "getNames", () => {
1517
+ if (this.cachedNames !== null) return this.cachedNames;
1518
+ if (this.names && this.names.length > 0) {
1519
+ let e = [], t = 0;
1520
+ this.objectMatches = {};
1521
+ for (let n of this.names) typeof n == "object" ? (this.objectMatches[Object.values(n)[0]] = t, e.push(Object.keys(n)[0]), e.push(Object.values(n)[0])) : e.push(n), t++;
1522
+ return this.cachedNames = e, e;
1523
+ }
1524
+ return [];
1525
+ }), t(this, "parseArrayExpression", () => {
1526
+ this.tokenStream.expect(a.PUNCTUATION_TYPE, "[", "An array element was expected");
1527
+ let e = new S(), t = !0;
1528
+ for (; !this.tokenStream.current.test(a.PUNCTUATION_TYPE, "]") && (t || (this.tokenStream.expect(a.PUNCTUATION_TYPE, ",", "An array element must be followed by a comma"), !this.tokenStream.current.test(a.PUNCTUATION_TYPE, "]")));) t = !1, e.addElement(this.parseExpression());
1529
+ return this.tokenStream.expect(a.PUNCTUATION_TYPE, "]", "An opened array is not properly closed"), e;
1530
+ }), t(this, "parseHashExpression", () => {
1531
+ this.tokenStream.expect(a.PUNCTUATION_TYPE, "{", "A hash element was expected");
1532
+ let e = new S(), t = !0;
1533
+ for (; !this.tokenStream.current.test(a.PUNCTUATION_TYPE, "}") && (t || (this.tokenStream.expect(a.PUNCTUATION_TYPE, ",", "A hash value must be followed by a comma"), !this.tokenStream.current.test(a.PUNCTUATION_TYPE, "}")));) {
1534
+ t = !1;
1535
+ let n = null;
1536
+ if (this.tokenStream.current.test(a.STRING_TYPE) || this.tokenStream.current.test(a.NAME_TYPE) || this.tokenStream.current.test(a.NUMBER_TYPE)) n = new b(this.tokenStream.current.value), this.tokenStream.next();
1537
+ else {
1538
+ if (!this.tokenStream.current.test(a.PUNCTUATION_TYPE, "(")) {
1539
+ let e = this.tokenStream.current;
1540
+ throw new r(`A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "${e.type}" of value "${e.value}"`, e.cursor, this.tokenStream.expression);
1541
+ }
1542
+ n = this.parseExpression();
1543
+ }
1544
+ this.tokenStream.expect(a.PUNCTUATION_TYPE, ":", "A hash key must be followed by a colon (:)");
1545
+ let i = this.parseExpression();
1546
+ e.addElement(i, n);
1547
+ }
1548
+ return this.tokenStream.expect(a.PUNCTUATION_TYPE, "}", "An opened hash is not properly closed"), e;
1549
+ }), t(this, "parsePostfixExpression", (e) => {
1550
+ let t = this.tokenStream.current;
1551
+ for (; a.PUNCTUATION_TYPE === t.type;) {
1552
+ if (t.value === "." || t.value === "?.") {
1553
+ let n = t.value === "?.";
1554
+ if (this.tokenStream.next(), t = this.tokenStream.current, this.tokenStream.next(), a.NAME_TYPE !== t.type && (a.OPERATOR_TYPE !== t.type || !/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/.test(t.value))) throw new r("Expected name", t.cursor, this.tokenStream.expression);
1555
+ let i = new b(t.value, !0, n), o = new C(), s = null;
1556
+ if (this.tokenStream.current.test(a.PUNCTUATION_TYPE, "(")) {
1557
+ s = w.METHOD_CALL;
1558
+ for (let e of Object.values(this.parseArguments().nodes)) o.addElement(e);
1559
+ } else s = w.PROPERTY_CALL;
1560
+ e = new w(e, i, o, s);
1561
+ } else {
1562
+ if (t.value !== "[") break;
1563
+ {
1564
+ this.tokenStream.next();
1565
+ let t = this.parseExpression();
1566
+ this.tokenStream.expect(a.PUNCTUATION_TYPE, "]"), e = new w(e, t, new C(), w.ARRAY_CALL);
1567
+ }
1568
+ }
1569
+ t = this.tokenStream.current;
1570
+ }
1571
+ return e;
1572
+ }), t(this, "parseArguments", () => {
1573
+ let e = [];
1574
+ for (this.tokenStream.expect(a.PUNCTUATION_TYPE, "(", "A list of arguments must begin with an opening parenthesis"); !this.tokenStream.current.test(a.PUNCTUATION_TYPE, ")");) e.length !== 0 && this.tokenStream.expect(a.PUNCTUATION_TYPE, ",", "Arguments must be separated by a comma"), e.push(this.parseExpression());
1575
+ return this.tokenStream.expect(a.PUNCTUATION_TYPE, ")", "A list of arguments must be closed by a parenthesis"), new _(e);
1576
+ }), this.functions = e, this.tokenStream = null, this.names = null, this.objectMatches = {}, this.cachedNames = null, this.nestedExecutions = 0, this.flags = 0;
1577
+ }
1578
+ parseConditionalExpression(e) {
1579
+ for (; this.tokenStream.current.test(a.PUNCTUATION_TYPE, "??");) {
1580
+ this.tokenStream.next();
1581
+ let t = this.parseExpression();
1582
+ e = new T(e, t);
1583
+ }
1584
+ for (; this.tokenStream.current.test(a.PUNCTUATION_TYPE, "?");) {
1585
+ let t, n;
1586
+ this.tokenStream.next(), this.tokenStream.current.test(a.PUNCTUATION_TYPE, ":") ? (this.tokenStream.next(), t = e, n = this.parseExpression()) : (t = this.parseExpression(), this.tokenStream.current.test(a.PUNCTUATION_TYPE, ":") ? (this.tokenStream.next(), n = this.parseExpression()) : t instanceof b && typeof t.attributes?.value == "string" ? n = new b("") : t instanceof x ? (n = t.nodes.expr3, t = t.nodes.expr2) : (n = t, t = e)), e = new x(e, t, n);
1587
+ }
1588
+ return e;
1589
+ }
1590
+ parsePrimaryExpression() {
1591
+ let e = this.tokenStream.current, t = null;
1592
+ switch (e.type) {
1593
+ case a.NAME_TYPE:
1594
+ switch (this.tokenStream.next(), e.value) {
1595
+ case "true":
1596
+ case "TRUE": return new b(!0);
1597
+ case "false":
1598
+ case "FALSE": return new b(!1);
1599
+ case "null":
1600
+ case "NULL": return new b(null);
1601
+ default: if (this.tokenStream.current.value === "(") {
1602
+ if (this.functions[e.value] === void 0 && !(2 & this.flags)) throw new r(`The function "${e.value}" does not exist`, e.cursor, this.tokenStream.expression, e.values, Object.keys(this.functions));
1603
+ t = new ee(e.value, this.parseArguments());
1604
+ } else {
1605
+ let n = null;
1606
+ if (1 & this.flags) n = e.value;
1607
+ else {
1608
+ if (!this.hasVariable(e.value)) {
1609
+ if (this.tokenStream.current.test(a.PUNCTUATION_TYPE, "??")) return new E(e.value);
1610
+ throw new r(`Variable "${e.value}" is not valid`, e.cursor, this.tokenStream.expression, e.value, this.getNames());
1611
+ }
1612
+ n = e.value, this.objectMatches[n] !== void 0 && (n = this.getNames()[this.objectMatches[n]]);
1613
+ }
1614
+ t = new te(n);
1615
+ }
1616
+ }
1617
+ break;
1618
+ case a.NUMBER_TYPE:
1619
+ case a.STRING_TYPE: return this.tokenStream.next(), new b(e.value);
1620
+ default: if (e.test(a.PUNCTUATION_TYPE, "[")) t = this.parseArrayExpression();
1621
+ else {
1622
+ if (!e.test(a.PUNCTUATION_TYPE, "{")) throw new r(`Unexpected token "${e.type}" of value "${e.value}"`, e.cursor, this.tokenStream.expression);
1623
+ t = this.parseHashExpression();
1624
+ }
1625
+ }
1626
+ return this.parsePostfixExpression(t);
1627
+ }
1628
+ }
1629
+ class ne {
1630
+ constructor(e) {
1631
+ t(this, "getFunction", (e) => this.functions[e]), t(this, "getSource", () => this.source), t(this, "reset", () => (this.source = "", this)), t(this, "compile", (e) => (e.compile(this), this)), t(this, "subcompile", (e) => {
1632
+ let t = this.source;
1633
+ this.source = "", e.compile(this);
1634
+ let n = this.source;
1635
+ return this.source = t, n;
1636
+ }), t(this, "raw", (e) => (this.source += e, this)), t(this, "string", (e) => (this.source += "\"" + g(e, "\0 \"$\\") + "\"", this)), t(this, "repr", (e, t = !1) => {
1637
+ if (t) this.raw(e);
1638
+ else if (Number.isInteger(e) || +e === e && (!isFinite(e) || e % 1)) this.raw(e);
1639
+ else if (e === null) this.raw("null");
1640
+ else if (typeof e == "boolean") this.raw(e ? "true" : "false");
1641
+ else if (typeof e == "object") {
1642
+ this.raw("{");
1643
+ let t = !0;
1644
+ for (let n of Object.keys(e)) t || this.raw(", "), t = !1, this.repr(n), this.raw(":"), this.repr(e[n]);
1645
+ this.raw("}");
1646
+ } else if (Array.isArray(e)) {
1647
+ this.raw("[");
1648
+ let t = !0;
1649
+ for (let n of e) t || this.raw(", "), t = !1, this.repr(n);
1650
+ this.raw("]");
1651
+ } else this.string(e);
1652
+ return this;
1653
+ }), this.source = "", this.functions = e;
1654
+ }
1655
+ }
1656
+ class re {
1657
+ constructor(e) {
1658
+ this.expression = e;
1659
+ }
1660
+ toString() {
1661
+ return this.expression;
1662
+ }
1663
+ }
1664
+ class O extends re {
1665
+ constructor(e, n) {
1666
+ super(e), t(this, "getNodes", () => this.nodes), this.nodes = n;
1667
+ }
1668
+ static fromJSON(e) {
1669
+ let t = typeof e == "string" ? JSON.parse(e) : e, n = (e) => {
1670
+ if (e == null || e instanceof _ || typeof e != "object" || !e.name) return e;
1671
+ switch (e.name) {
1672
+ case "ConstantNode": return new b(e.attributes?.value, !!e.isIdentifier, !!e.isNullSafe);
1673
+ case "NameNode": return new te(e.attributes?.name);
1674
+ case "NullCoalescedNameNode": return new E(e.attributes?.name);
1675
+ case "UnaryNode": return new y(e.attributes?.operator, n(e.nodes?.node));
1676
+ case "BinaryNode": return new v(e.attributes?.operator, n(e.nodes?.left), n(e.nodes?.right));
1677
+ case "ConditionalNode": return new x(n(e.nodes?.expr1), n(e.nodes?.expr2), n(e.nodes?.expr3));
1678
+ case "NullCoalesceNode": return new T(n(e.nodes?.expr1), n(e.nodes?.expr2));
1679
+ case "ArgumentsNode": {
1680
+ let t = new C();
1681
+ typeof e.type == "string" && (t.type = e.type), typeof e.index == "number" && (t.index = e.index), typeof e.keyIndex == "number" && (t.keyIndex = e.keyIndex), t.nodes = {};
1682
+ for (let r of Object.keys(e.nodes || {})) t.nodes[r] = n(e.nodes[r]);
1683
+ return t;
1684
+ }
1685
+ case "ArrayNode": {
1686
+ let t = new S();
1687
+ typeof e.type == "string" && (t.type = e.type), typeof e.index == "number" && (t.index = e.index), typeof e.keyIndex == "number" && (t.keyIndex = e.keyIndex), t.nodes = {};
1688
+ for (let r of Object.keys(e.nodes || {})) t.nodes[r] = n(e.nodes[r]);
1689
+ return t;
1690
+ }
1691
+ case "FunctionNode": {
1692
+ let t = n(e.nodes?.arguments);
1693
+ return new ee(e.attributes?.name, t);
1694
+ }
1695
+ case "GetAttrNode": {
1696
+ let t = new w(n(e.nodes?.node), n(e.nodes?.attribute), n(e.nodes?.fnArguments), e.attributes?.type);
1697
+ return e.attributes && typeof e.attributes.is_null_coalesce == "boolean" && (t.attributes.is_null_coalesce = e.attributes.is_null_coalesce), e.attributes && typeof e.attributes.is_short_circuited == "boolean" && (t.attributes.is_short_circuited = e.attributes.is_short_circuited), t;
1698
+ }
1699
+ case "Node": {
1700
+ let t = new _();
1701
+ if (Array.isArray(e.nodes)) t.nodes = e.nodes.map(n);
1702
+ else {
1703
+ t.nodes = {};
1704
+ for (let r of Object.keys(e.nodes || {})) t.nodes[r] = n(e.nodes[r]);
1705
+ }
1706
+ return t.attributes = e.attributes || {}, t;
1707
+ }
1708
+ default: {
1709
+ let t = new _();
1710
+ if (t.name = e.name, Array.isArray(e.nodes)) t.nodes = e.nodes.map(n);
1711
+ else {
1712
+ t.nodes = {};
1713
+ for (let r of Object.keys(e.nodes || {})) t.nodes[r] = n(e.nodes[r]);
1714
+ }
1715
+ return t.attributes = e.attributes || {}, t;
1716
+ }
1717
+ }
1718
+ }, r = t.expression;
1719
+ return new O(r, ((e) => {
1720
+ if (e == null) return e;
1721
+ if (e.name) return n(e);
1722
+ if (Array.isArray(e)) return e.map(n);
1723
+ if (typeof e == "object") {
1724
+ let t = {};
1725
+ for (let r of Object.keys(e)) t[r] = n(e[r]);
1726
+ return t;
1727
+ }
1728
+ return e;
1729
+ })(t.nodes));
1730
+ }
1731
+ }
1732
+ var k;
1733
+ class A {
1734
+ constructor(e = 0) {
1735
+ t(this, "createCacheItem", (e, t, n) => {
1736
+ let r = new j();
1737
+ return r.key = e, r.value = t, r.isHit = n, r.defaultLifetime = this.defaultLifetime, r;
1738
+ }), t(this, "get", (e, t, n = null, r = null) => {
1739
+ let i = this.getItem(e);
1740
+ return i.isHit || this.save(i.set(t(i, !0))), i.get();
1741
+ }), t(this, "getItem", (e) => {
1742
+ let t = this.hasItem(e), n = null;
1743
+ return t ? n = this.values[e] : this.values[e] = null, (0, this.createCacheItem)(e, n, t);
1744
+ }), t(this, "getItems", (e) => {
1745
+ for (let t of e) typeof t == "string" || this.expiries[t] || j.validateKey(t);
1746
+ return this.generateItems(e, (/* @__PURE__ */ new Date()).getTime() / 1e3, this.createCacheItem);
1747
+ }), t(this, "deleteItems", (e) => {
1748
+ for (let t of e) this.deleteItem(t);
1749
+ return !0;
1750
+ }), t(this, "save", (e) => !(!e instanceof j) && (e.expiry !== null && e.expiry <= (/* @__PURE__ */ new Date()).getTime() / 1e3 ? (this.deleteItem(e.key), !0) : (e.expiry === null && 0 < e.defaultLifetime && (e.expiry = (/* @__PURE__ */ new Date()).getTime() / 1e3 + e.defaultLifetime), this.values[e.key] = e.value, this.expiries[e.key] = e.expiry || 2 ** 53 - 1, !0))), t(this, "saveDeferred", (e) => this.save(e)), t(this, "commit", () => !0), t(this, "delete", (e) => this.deleteItem(e)), t(this, "getValues", () => this.values), t(this, "hasItem", (e) => !!(typeof e == "string" && this.expiries[e] && this.expiries[e] > (/* @__PURE__ */ new Date()).getTime() / 1e3) || (j.validateKey(e), !!this.expiries[e] && !this.deleteItem(e))), t(this, "clear", () => (this.values = {}, this.expiries = {}, !0)), t(this, "deleteItem", (e) => (typeof e == "string" && this.expiries[e] || j.validateKey(e), delete this.values[e], delete this.expiries[e], !0)), t(this, "reset", () => {
1751
+ this.clear();
1752
+ }), t(this, "generateItems", (e, t, n) => {
1753
+ let r = [];
1754
+ for (let i of e) {
1755
+ let e = null, a = !!this.expiries[i];
1756
+ a || !(this.expiries[i] > t) && this.deleteItem(i) ? e = this.values[i] : this.values[i] = null, r[i] = n(i, e, a);
1757
+ }
1758
+ return r;
1759
+ }), this.defaultLifetime = e, this.values = {}, this.expiries = {};
1760
+ }
1761
+ }
1762
+ class j {
1763
+ constructor() {
1764
+ t(this, "getKey", () => this.key), t(this, "get", () => this.value), t(this, "set", (e) => (this.value = e, this)), t(this, "expiresAt", (e) => {
1765
+ if (e === null) this.expiry = this.defaultLifetime > 0 ? Date.now() / 1e3 + this.defaultLifetime : null;
1766
+ else {
1767
+ if (!(e instanceof Date)) throw Error(`Expiration date must be instance of Date or be null, "${e.name}" given`);
1768
+ this.expiry = e.getTime() / 1e3;
1769
+ }
1770
+ return this;
1771
+ }), t(this, "expiresAfter", (e) => {
1772
+ if (e === null) this.expiry = this.defaultLifetime > 0 ? Date.now() / 1e3 + this.defaultLifetime : null;
1773
+ else {
1774
+ if (!Number.isInteger(e)) throw Error(`Expiration date must be an integer or be null, "${e.name}" given`);
1775
+ this.expiry = (/* @__PURE__ */ new Date()).getTime() / 1e3 + e;
1776
+ }
1777
+ return this;
1778
+ }), t(this, "tag", (e) => {
1779
+ if (!this.isTaggable) throw Error(`Cache item "${this.key}" comes from a non tag-aware pool: you cannot tag it.`);
1780
+ Array.isArray(e) || (e = [e]);
1781
+ for (let t of e) {
1782
+ if (typeof t != "string") throw Error(`Cache tag must by a string, "${typeof t}" given.`);
1783
+ if (this.newMetadata.tags[t] && t === "") throw Error("Cache tag length must be greater than zero");
1784
+ this.newMetadata.tags[t] = t;
1785
+ }
1786
+ return this;
1787
+ }), t(this, "getMetadata", () => this.metadata), this.key = null, this.value = null, this.isHit = !1, this.expiry = null, this.defaultLifetime = null, this.metadata = {}, this.newMetadata = {}, this.innerItem = null, this.poolHash = null, this.isTaggable = !1;
1788
+ }
1789
+ }
1790
+ k = j, t(j, "METADATA_EXPIRY_OFFSET", 1527506807), t(j, "RESERVED_CHARACTERS", [
1791
+ "{",
1792
+ "}",
1793
+ "(",
1794
+ ")",
1795
+ "/",
1796
+ "\\",
1797
+ "@",
1798
+ ":"
1799
+ ]), t(j, "validateKey", (e) => {
1800
+ if (typeof e != "string") throw Error(`Cache key must be string, "${typeof e}" given.`);
1801
+ if (e === "") throw Error("Cache key length must be greater than zero");
1802
+ for (let t of k.RESERVED_CHARACTERS) if (e.indexOf(t) >= 0) throw Error(`Cache key "${e}" contains reserved character "${t}".`);
1803
+ return e;
1804
+ });
1805
+ class M extends Error {
1806
+ constructor(e) {
1807
+ super(e), this.name = "LogicException";
1808
+ }
1809
+ toString() {
1810
+ return `${this.name}: ${this.message}`;
1811
+ }
1812
+ }
1813
+ class N {
1814
+ constructor(e, n, r) {
1815
+ t(this, "getName", () => this.name), t(this, "getCompiler", () => this.compiler), t(this, "getEvaluator", () => this.evaluator), this.name = e, this.compiler = n, this.evaluator = r;
1816
+ }
1817
+ static fromJavascript(e, t = null) {
1818
+ if (typeof e != "string" || e.length === 0) throw TypeError("A JavaScript function name (string) must be provided.");
1819
+ let n = e.replace(/^\/+/, ""), r = n.split("."), i = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {};
1820
+ for (let e of r) {
1821
+ if (i == null) break;
1822
+ i = i[e];
1823
+ }
1824
+ if (typeof i != "function") throw Error(`JavaScript function "${n}" does not exist.`);
1825
+ if (!t && r.length > 1) throw Error(`An expression function name must be defined when JavaScript function "${n}" is namespaced.`);
1826
+ return new this(t || r[r.length - 1], (...e) => `${n}(${e.join(", ")})`, (e, ...t) => i(...t));
1827
+ }
1828
+ }
1829
+ class P {
1830
+ constructor(e = null, n = []) {
1831
+ t(this, "compile", (e, t = []) => this.getCompiler().compile(this.parse(e, t).getNodes()).getSource()), t(this, "evaluate", (e, t = {}) => this.parse(e, Object.keys(t)).getNodes().evaluate(this.functions, t)), t(this, "parse", (e, t, n = 0) => {
1832
+ if (e instanceof O) return e;
1833
+ t.sort((e, t) => {
1834
+ let n = e, r = t;
1835
+ return typeof e == "object" && (n = Object.values(e)[0]), typeof t == "object" && (r = Object.values(t)[0]), n.localeCompare(r);
1836
+ });
1837
+ let r = [];
1838
+ for (let e of t) {
1839
+ let t = e;
1840
+ typeof e == "object" && (t = Object.keys(e)[0] + ":" + Object.values(e)[0]), r.push(t);
1841
+ }
1842
+ let i = this.cache.getItem(this.fixedEncodeURIComponent(e + "//" + r.join("|"))), a = i.get();
1843
+ return a === null && (a = new O(e, this.getParser().parse(this.getLexer().tokenize(e), t, n)), i.set(a), this.cache.save(i)), a;
1844
+ }), t(this, "lint", (e, t = null, n = 0) => {
1845
+ t === null && (console.log("Deprecated: passing \"null\" as the second argument of lint is deprecated, pass IGNORE_UNKNOWN_VARIABLES instead as the third argument"), n |= 1, t = []), e instanceof O || this.getParser().lint(this.getLexer().tokenize(e), t, n);
1846
+ }), t(this, "fixedEncodeURIComponent", (e) => encodeURIComponent(e).replace(/[!'()*]/g, function(e) {
1847
+ return "%" + e.charCodeAt(0).toString(16);
1848
+ })), t(this, "register", (e, t, n) => {
1849
+ if (this.parser !== null) throw new M("Registering functions after calling evaluate(), compile(), or parse() is not supported.");
1850
+ this.functions[e] = {
1851
+ compiler: t,
1852
+ evaluator: n
1853
+ };
1854
+ }), t(this, "addFunction", (e) => {
1855
+ this.register(e.getName(), e.getCompiler(), e.getEvaluator());
1856
+ }), t(this, "registerProvider", (e) => {
1857
+ for (let t of e.getFunctions()) this.addFunction(t);
1858
+ }), t(this, "getLexer", () => (this.lexer === null && (this.lexer = { tokenize: o }), this.lexer)), t(this, "getParser", () => (this.parser === null && (this.parser = new D(this.functions)), this.parser)), t(this, "getCompiler", () => (this.compiler === null && (this.compiler = new ne(this.functions)), this.compiler.reset())), this.functions = [], this.lexer = null, this.parser = null, this.compiler = null, this.cache = e || new A(), this._registerBuiltinFunctions();
1859
+ for (let e of n) this.registerProvider(e);
1860
+ }
1861
+ _registerBuiltinFunctions() {
1862
+ let e = N.fromJavascript("Math.min", "min"), t = N.fromJavascript("Math.max", "max");
1863
+ this.addFunction(e), this.addFunction(t), this.addFunction(new N("constant", function(e) {
1864
+ return `(function(__n){var __g=(typeof globalThis!=='undefined'?globalThis:(typeof window!=='undefined'?window:(typeof global!=='undefined'?global:{})));return __n.split('.').reduce(function(o,k){return o==null?undefined:o[k];}, __g)})(${e})`;
1865
+ }, function(e, t) {
1866
+ if (typeof t != "string" || !t) return;
1867
+ let n = (r = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {}, t.split(".").reduce((e, t) => e?.[t], r));
1868
+ var r;
1869
+ return n === void 0 && e && Object.prototype.hasOwnProperty.call(e, t) && (n = e[t]), n;
1870
+ })), this.addFunction(new N("enum", function(e) {
1871
+ return `(function(__n){var __g=(typeof globalThis!=='undefined'?globalThis:(typeof window!=='undefined'?window:(typeof global!=='undefined'?global:{})));if(typeof __n!=='string'||!__n)return undefined;var s=String(__n);var keys=[],buf='';for(var i=0;i<s.length;i++){var c=s.charCodeAt(i);if(c===46||c===92){if(buf){keys.push(buf);buf='';}continue;}if(c===58){if(i+1<s.length&&s.charCodeAt(i+1)===58){if(buf){keys.push(buf);buf='';}i++;continue;}}buf+=s[i];}if(buf)keys.push(buf);return keys.reduce(function(o,k){return o==null?undefined:o[k];}, __g)})(${e})`;
1872
+ }, function(e, t) {
1873
+ if (typeof t != "string" || !t) return;
1874
+ let n = String(t).replace(/\\/g, ".").replace(/::/g, ".");
1875
+ var r;
1876
+ return n ? (r = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {}, n.split(".").reduce((e, t) => e?.[t], r)) : void 0;
1877
+ }));
1878
+ }
1879
+ }
1880
+ class F {
1881
+ getFunctions() {
1882
+ throw Error("getFunctions must be implemented by " + this.name);
1883
+ }
1884
+ }
1885
+ let ie = new N("isset", function(e) {
1886
+ return `isset(${e})`;
1887
+ }, function(e, t) {
1888
+ if (typeof t != "string") return t != null;
1889
+ if (!(t.split(/[.\[]/)[0] in e)) return !0;
1890
+ let n = "", r = [], i = "", a = "";
1891
+ for (let e = 0; e < t.length; e++) {
1892
+ let o = t[e];
1893
+ if (o !== "]") if (o !== "[") {
1894
+ if (i === "object" && (!/[A-z0-9_]/.test(o) || e === t.length - 1)) {
1895
+ let n = !1;
1896
+ if (e === t.length - 1 && (a += o, n = !0), i = "", r.push({
1897
+ type: "object",
1898
+ attribute: a
1899
+ }), a = "", n) continue;
1900
+ }
1901
+ o === "." ? (i = "object", a = "") : i ? a += o : n += o;
1902
+ } else i = "array", a = "";
1903
+ else i = "", r.push({
1904
+ type: "array",
1905
+ index: a.replace(/"/g, "").replace(/'/g, "")
1906
+ }), a = "";
1907
+ }
1908
+ if (r.length > 0) {
1909
+ if (e[n] !== void 0) {
1910
+ let t = e[n];
1911
+ for (let e of r) {
1912
+ if (e.type === "array") {
1913
+ if (t[e.index] === void 0) return !1;
1914
+ t = t[e.index];
1915
+ }
1916
+ if (e.type === "object") {
1917
+ if (t[e.attribute] === void 0) return !1;
1918
+ t = t[e.attribute];
1919
+ }
1920
+ }
1921
+ return !0;
1922
+ }
1923
+ return !1;
1924
+ }
1925
+ return e[n] !== void 0;
1926
+ }), ae = (e) => Object.entries(e);
1927
+ function oe(e) {
1928
+ return typeof e == "object" && !!e;
1929
+ }
1930
+ function se(e) {
1931
+ return oe(e) && !function(e) {
1932
+ return Array.isArray(e);
1933
+ }(e);
1934
+ }
1935
+ function ce(e) {
1936
+ return function(e) {
1937
+ return oe(e);
1938
+ }(e) ? e : {};
1939
+ }
1940
+ let I = typeof window == "object" && window !== null ? window : typeof global == "object" && global !== null ? global : {};
1941
+ function le() {
1942
+ let e = (() => {
1943
+ let e = I.$locutus;
1944
+ typeof e == "object" && e || (e = {}, I.$locutus = e);
1945
+ let t = e.php;
1946
+ return typeof t == "object" && t || (t = {}, e.php = t), t;
1947
+ })(), t = e.ini, n = e.locales, r = e.localeCategories, i = e.pointers, a = se(t) ? t : {}, o = ((e) => se(e))(n) ? n : {}, s = ((e) => se(e))(r) ? r : {}, c = Array.isArray(i) ? i : [];
1948
+ t !== a && (e.ini = a), n !== o && (e.locales = o), r !== s && (e.localeCategories = s), i !== c && (e.pointers = c);
1949
+ let l = e.locale_default;
1950
+ return {
1951
+ ini: a,
1952
+ locales: o,
1953
+ localeCategories: s,
1954
+ pointers: c,
1955
+ locale_default: typeof l == "string" ? l : void 0
1956
+ };
1957
+ }
1958
+ function L(e) {
1959
+ let t = le().ini[e];
1960
+ return t && t.local_value !== void 0 ? t.local_value === null ? "" : String(t.local_value) : "";
1961
+ }
1962
+ function ue(e, t, n) {
1963
+ let r = function(e) {
1964
+ if (typeof e == "boolean") return e ? "1" : "";
1965
+ if (typeof e == "string") return e;
1966
+ if (typeof e == "number") return isNaN(e) ? "NAN" : isFinite(e) ? e + "" : (e < 0 ? "-" : "") + "INF";
1967
+ if (e === void 0) return "";
1968
+ if (typeof e == "object") return Array.isArray(e) ? "Array" : e === null ? "" : "Object";
1969
+ throw Error("Unsupported value type");
1970
+ }(e), i = L("unicode.semantics") === "on" ? r.match(/[\uD800-\uDBFF][\uDC00-\uDFFF]|[\s\S]/g) || [] : null, a = i ? i.length : r.length, o = a;
1971
+ return t < 0 && (t += o), n !== void 0 && (o = n < 0 ? n + o : n + t), !(t > a || t < 0 || t > o) && (i ? i.slice(t, o).join("") : r.slice(t, o));
1972
+ }
1973
+ function de(e, ...t) {
1974
+ let n = {};
1975
+ if (t.length < 1) return n;
1976
+ let r = ce(e);
1977
+ e: for (let [e, i] of ae(r)) {
1978
+ for (let e of t) {
1979
+ let t = ce(e), n = !1;
1980
+ for (let [, e] of ae(t)) if (e === i) {
1981
+ n = !0;
1982
+ break;
1983
+ }
1984
+ if (!n) continue e;
1985
+ }
1986
+ n[e] = i;
1987
+ }
1988
+ return n;
1989
+ }
1990
+ let fe = (e) => {
1991
+ if (!e || typeof e != "object") return !1;
1992
+ let t = Object.getPrototypeOf(e);
1993
+ return t === Array.prototype || t === Object.prototype;
1994
+ };
1995
+ function pe(e, t = 0) {
1996
+ let n = 0;
1997
+ if (e == null) return 0;
1998
+ if (typeof e != "object") return 1;
1999
+ let r = Object.getPrototypeOf(e);
2000
+ if (r !== Array.prototype && r !== Object.prototype) return 1;
2001
+ let i = t === "COUNT_RECURSIVE" || t === 1;
2002
+ if (Array.isArray(e)) {
2003
+ for (let t of Object.keys(e)) {
2004
+ n++;
2005
+ let r = e[Number(t)];
2006
+ i && fe(r) && (n += pe(r, 1));
2007
+ }
2008
+ return n;
2009
+ }
2010
+ for (let t in e) if (Object.prototype.hasOwnProperty.call(e, t)) {
2011
+ n++;
2012
+ let r = e[t];
2013
+ i && fe(r) && (n += pe(r, 1));
2014
+ }
2015
+ return n;
2016
+ }
2017
+ let me = new N("implode", function(e, t) {
2018
+ return `implode(${e}, ${t})`;
2019
+ }, function(e, t, n) {
2020
+ return function(...e) {
2021
+ let t, n = "", r = "", i = "";
2022
+ if (e.length === 1) {
2023
+ let [n] = e;
2024
+ t = n;
2025
+ } else {
2026
+ let [n, r] = e;
2027
+ i = String(n ?? ""), t = r;
2028
+ }
2029
+ if (typeof t == "object" && t) {
2030
+ if (Array.isArray(t)) return t.join(i);
2031
+ for (let e in t) n += r + t[e], r = i;
2032
+ return n;
2033
+ }
2034
+ return String(t);
2035
+ }(t, n);
2036
+ }), he = new N("count", function(e, t) {
2037
+ let n = "";
2038
+ return t && (n = `, ${t}`), `count(${e}${n})`;
2039
+ }, function(e, t, n) {
2040
+ return pe(t, n);
2041
+ }), ge = new N("array_intersect", function(e, ...t) {
2042
+ let n = "";
2043
+ return t.length > 0 && (n = ", " + t.join(", ")), `array_intersect(${e}${n})`;
2044
+ }, function(e) {
2045
+ let t = [], n = !0;
2046
+ for (let e = 1; e < arguments.length; e++) t.push(arguments[e]), Array.isArray(arguments[e]) || (n = !1);
2047
+ let r = de.apply(null, t);
2048
+ return n ? Object.values(r) : r;
2049
+ });
2050
+ function _e(e, t) {
2051
+ let n, r = /* @__PURE__ */ new Date(), i = [
2052
+ "Sun",
2053
+ "Mon",
2054
+ "Tues",
2055
+ "Wednes",
2056
+ "Thurs",
2057
+ "Fri",
2058
+ "Satur",
2059
+ "January",
2060
+ "February",
2061
+ "March",
2062
+ "April",
2063
+ "May",
2064
+ "June",
2065
+ "July",
2066
+ "August",
2067
+ "September",
2068
+ "October",
2069
+ "November",
2070
+ "December"
2071
+ ], a = /\\?(.?)/gi, o = function(e, t) {
2072
+ return r = e, Object.prototype.hasOwnProperty.call(n, r) ? String(n[e]()) : t;
2073
+ var r;
2074
+ }, s = function(e, t) {
2075
+ let n = String(e);
2076
+ for (; n.length < t;) n = "0" + n;
2077
+ return n;
2078
+ };
2079
+ return n = {
2080
+ d: function() {
2081
+ return s(n.j(), 2);
2082
+ },
2083
+ D: function() {
2084
+ return String(n.l()).slice(0, 3);
2085
+ },
2086
+ j: function() {
2087
+ return r.getDate();
2088
+ },
2089
+ l: function() {
2090
+ return (i[Number(n.w())] ?? "") + "day";
2091
+ },
2092
+ N: function() {
2093
+ return Number(n.w()) || 7;
2094
+ },
2095
+ S: function() {
2096
+ let e = Number(n.j()), t = e % 10;
2097
+ return t <= 3 && Number.parseInt(String(e % 100 / 10), 10) === 1 && (t = 0), [
2098
+ "st",
2099
+ "nd",
2100
+ "rd"
2101
+ ][t - 1] || "th";
2102
+ },
2103
+ w: function() {
2104
+ return r.getDay();
2105
+ },
2106
+ z: function() {
2107
+ let e = new Date(Number(n.Y()), Number(n.n()) - 1, Number(n.j())), t = new Date(Number(n.Y()), 0, 1);
2108
+ return Math.round((e.getTime() - t.getTime()) / 864e5);
2109
+ },
2110
+ W: function() {
2111
+ let e = new Date(Number(n.Y()), Number(n.n()) - 1, Number(n.j()) - Number(n.N()) + 3), t = new Date(e.getFullYear(), 0, 4);
2112
+ return s(1 + Math.round((e.getTime() - t.getTime()) / 864e5 / 7), 2);
2113
+ },
2114
+ F: function() {
2115
+ return i[6 + Number(n.n())] ?? "";
2116
+ },
2117
+ m: function() {
2118
+ return s(n.n(), 2);
2119
+ },
2120
+ M: function() {
2121
+ return String(n.F()).slice(0, 3);
2122
+ },
2123
+ n: function() {
2124
+ return r.getMonth() + 1;
2125
+ },
2126
+ t: function() {
2127
+ return new Date(Number(n.Y()), Number(n.n()), 0).getDate();
2128
+ },
2129
+ L: function() {
2130
+ let e = Number(n.Y());
2131
+ return +(e % 4 == 0 && e % 100 != 0 || e % 400 == 0);
2132
+ },
2133
+ o: function() {
2134
+ let e = Number(n.n()), t = Number(n.W());
2135
+ return Number(n.Y()) + (e === 12 && t < 9 ? 1 : e === 1 && t > 9 ? -1 : 0);
2136
+ },
2137
+ Y: function() {
2138
+ return r.getFullYear();
2139
+ },
2140
+ y: function() {
2141
+ return String(n.Y()).slice(-2);
2142
+ },
2143
+ a: function() {
2144
+ return r.getHours() > 11 ? "pm" : "am";
2145
+ },
2146
+ A: function() {
2147
+ return String(n.a()).toUpperCase();
2148
+ },
2149
+ B: function() {
2150
+ let e = 3600 * r.getUTCHours(), t = 60 * r.getUTCMinutes(), n = r.getUTCSeconds();
2151
+ return s(Math.floor((e + t + n + 3600) / 86.4) % 1e3, 3);
2152
+ },
2153
+ g: function() {
2154
+ return Number(n.G()) % 12 || 12;
2155
+ },
2156
+ G: function() {
2157
+ return r.getHours();
2158
+ },
2159
+ h: function() {
2160
+ return s(n.g(), 2);
2161
+ },
2162
+ H: function() {
2163
+ return s(n.G(), 2);
2164
+ },
2165
+ i: function() {
2166
+ return s(r.getMinutes(), 2);
2167
+ },
2168
+ s: function() {
2169
+ return s(r.getSeconds(), 2);
2170
+ },
2171
+ u: function() {
2172
+ return s(1e3 * r.getMilliseconds(), 6);
2173
+ },
2174
+ e: function() {
2175
+ throw Error("Not supported (see source code of date() for timezone on how to add support)");
2176
+ },
2177
+ I: function() {
2178
+ let e = new Date(Number(n.Y()), 0), t = Date.UTC(Number(n.Y()), 0), r = new Date(Number(n.Y()), 6), i = Date.UTC(Number(n.Y()), 6);
2179
+ return e.getTime() - t === r.getTime() - i ? 0 : 1;
2180
+ },
2181
+ O: function() {
2182
+ let e = r.getTimezoneOffset(), t = Math.abs(e);
2183
+ return (e > 0 ? "-" : "+") + s(100 * Math.floor(t / 60) + t % 60, 4);
2184
+ },
2185
+ P: function() {
2186
+ let e = String(n.O());
2187
+ return e.slice(0, 3) + ":" + e.slice(3, 5);
2188
+ },
2189
+ T: function() {
2190
+ return "UTC";
2191
+ },
2192
+ Z: function() {
2193
+ return 60 * -r.getTimezoneOffset();
2194
+ },
2195
+ c: function() {
2196
+ return "Y-m-d\\TH:i:sP".replace(a, o);
2197
+ },
2198
+ r: function() {
2199
+ return "D, d M Y H:i:s O".replace(a, o);
2200
+ },
2201
+ U: function() {
2202
+ return r.getTime() / 1e3 | 0;
2203
+ }
2204
+ }, c = e, r = (l = t) === void 0 ? /* @__PURE__ */ new Date() : l instanceof Date ? new Date(l) : /* @__PURE__ */ new Date(1e3 * Number(l)), c.replace(a, o);
2205
+ var c, l;
2206
+ }
2207
+ let R = "[ \\t]*", z = "(?:([ap])\\.?m\\.?([\\t ]|$))", B = "(2[0-4]|[01]?[0-9])", ve = "([01][0-9]|2[0-4])", V = "(0?[1-9]|1[0-2])", ye = "([0-5][0-9])", be = "sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun|mon|tue|wed|thu|fri|sat|weekdays?", xe = "next|last|previous|this";
2208
+ "" + be;
2209
+ let H = "([0-9]{4})", Se = "(1[0-2]|0?[0-9])", U = "(0[0-9]|1[0-2])", W = "(?:(3[01]|[0-2]?[0-9])(?:st|nd|rd|th)?)", Ce = "(0[0-9]|[1-2][0-9]|3[01])", we = "january|february|march|april|may|june|july|august|september|october|november|december", Te = "jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec", G = "(" + we + "|jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec|i[vx]|vi{0,3}|xi{0,2}|i{1,3})";
2210
+ "" + B;
2211
+ let K = G + "[ .\\t-]*(?:(3[01]|[0-2]?[0-9])(?:st|nd|rd|th)?)[,.stndrh\\t ]*";
2212
+ function q(e, t) {
2213
+ switch (t?.toLowerCase()) {
2214
+ case "a":
2215
+ e += e === 12 ? -12 : 0;
2216
+ break;
2217
+ case "p": e += e === 12 ? 0 : 12;
2218
+ }
2219
+ return e;
2220
+ }
2221
+ function J(e) {
2222
+ let t = +e;
2223
+ return e.length < 4 && t < 100 && (t += t < 70 ? 2e3 : 1900), t;
2224
+ }
2225
+ function Y(e) {
2226
+ return {
2227
+ jan: 0,
2228
+ january: 0,
2229
+ i: 0,
2230
+ feb: 1,
2231
+ february: 1,
2232
+ ii: 1,
2233
+ mar: 2,
2234
+ march: 2,
2235
+ iii: 2,
2236
+ apr: 3,
2237
+ april: 3,
2238
+ iv: 3,
2239
+ may: 4,
2240
+ v: 4,
2241
+ jun: 5,
2242
+ june: 5,
2243
+ vi: 5,
2244
+ jul: 6,
2245
+ july: 6,
2246
+ vii: 6,
2247
+ aug: 7,
2248
+ august: 7,
2249
+ viii: 7,
2250
+ sep: 8,
2251
+ sept: 8,
2252
+ september: 8,
2253
+ ix: 8,
2254
+ oct: 9,
2255
+ october: 9,
2256
+ x: 9,
2257
+ nov: 10,
2258
+ november: 10,
2259
+ xi: 10,
2260
+ dec: 11,
2261
+ december: 11,
2262
+ xii: 11
2263
+ }[e.toLowerCase()] ?? NaN;
2264
+ }
2265
+ function Ee(e, t = 0) {
2266
+ return {
2267
+ mon: 1,
2268
+ monday: 1,
2269
+ tue: 2,
2270
+ tuesday: 2,
2271
+ wed: 3,
2272
+ wednesday: 3,
2273
+ thu: 4,
2274
+ thursday: 4,
2275
+ fri: 5,
2276
+ friday: 5,
2277
+ sat: 6,
2278
+ saturday: 6,
2279
+ sun: 0,
2280
+ sunday: 0
2281
+ }[e.toLowerCase()] || t;
2282
+ }
2283
+ function X(e, t = NaN) {
2284
+ let n = e?.match(/(?:GMT)?([+-])(\d+)(:?)(\d{0,2})/i);
2285
+ if (!n) return t;
2286
+ let r = n[1] === "-" ? -1 : 1, i = +(n[2] ?? 0), a = +(n[4] ?? 0);
2287
+ return n[4] || n[3] || (a = Math.floor(i % 100), i = Math.floor(i / 100)), r * (60 * i + a) * 60;
2288
+ }
2289
+ let Z = {
2290
+ acdt: 37800,
2291
+ acst: 34200,
2292
+ addt: -7200,
2293
+ adt: -10800,
2294
+ aedt: 39600,
2295
+ aest: 36e3,
2296
+ ahdt: -32400,
2297
+ ahst: -36e3,
2298
+ akdt: -28800,
2299
+ akst: -32400,
2300
+ amt: -13840,
2301
+ apt: -10800,
2302
+ ast: -14400,
2303
+ awdt: 32400,
2304
+ awst: 28800,
2305
+ awt: -10800,
2306
+ bdst: 7200,
2307
+ bdt: -36e3,
2308
+ bmt: -14309,
2309
+ bst: 3600,
2310
+ cast: 34200,
2311
+ cat: 7200,
2312
+ cddt: -14400,
2313
+ cdt: -18e3,
2314
+ cemt: 10800,
2315
+ cest: 7200,
2316
+ cet: 3600,
2317
+ cmt: -15408,
2318
+ cpt: -18e3,
2319
+ cst: -21600,
2320
+ cwt: -18e3,
2321
+ chst: 36e3,
2322
+ dmt: -1521,
2323
+ eat: 10800,
2324
+ eddt: -10800,
2325
+ edt: -14400,
2326
+ eest: 10800,
2327
+ eet: 7200,
2328
+ emt: -26248,
2329
+ ept: -14400,
2330
+ est: -18e3,
2331
+ ewt: -14400,
2332
+ ffmt: -14660,
2333
+ fmt: -4056,
2334
+ gdt: 39600,
2335
+ gmt: 0,
2336
+ gst: 36e3,
2337
+ hdt: -34200,
2338
+ hkst: 32400,
2339
+ hkt: 28800,
2340
+ hmt: -19776,
2341
+ hpt: -34200,
2342
+ hst: -36e3,
2343
+ hwt: -34200,
2344
+ iddt: 14400,
2345
+ idt: 10800,
2346
+ imt: 25025,
2347
+ ist: 7200,
2348
+ jdt: 36e3,
2349
+ jmt: 8440,
2350
+ jst: 32400,
2351
+ kdt: 36e3,
2352
+ kmt: 5736,
2353
+ kst: 30600,
2354
+ lst: 9394,
2355
+ mddt: -18e3,
2356
+ mdst: 16279,
2357
+ mdt: -21600,
2358
+ mest: 7200,
2359
+ met: 3600,
2360
+ mmt: 9017,
2361
+ mpt: -21600,
2362
+ msd: 14400,
2363
+ msk: 10800,
2364
+ mst: -25200,
2365
+ mwt: -21600,
2366
+ nddt: -5400,
2367
+ ndt: -9052,
2368
+ npt: -9e3,
2369
+ nst: -12600,
2370
+ nwt: -9e3,
2371
+ nzdt: 46800,
2372
+ nzmt: 41400,
2373
+ nzst: 43200,
2374
+ pddt: -21600,
2375
+ pdt: -25200,
2376
+ pkst: 21600,
2377
+ pkt: 18e3,
2378
+ plmt: 25590,
2379
+ pmt: -13236,
2380
+ ppmt: -17340,
2381
+ ppt: -25200,
2382
+ pst: -28800,
2383
+ pwt: -25200,
2384
+ qmt: -18840,
2385
+ rmt: 5794,
2386
+ sast: 7200,
2387
+ sdmt: -16800,
2388
+ sjmt: -20173,
2389
+ smt: -13884,
2390
+ sst: -39600,
2391
+ tbmt: 10751,
2392
+ tmt: 12344,
2393
+ uct: 0,
2394
+ utc: 0,
2395
+ wast: 7200,
2396
+ wat: 3600,
2397
+ wemt: 7200,
2398
+ west: 3600,
2399
+ wet: 0,
2400
+ wib: 25200,
2401
+ wita: 28800,
2402
+ wit: 32400,
2403
+ wmt: 5040,
2404
+ yddt: -25200,
2405
+ ydt: -28800,
2406
+ ypt: -28800,
2407
+ yst: -32400,
2408
+ ywt: -28800,
2409
+ a: 3600,
2410
+ b: 7200,
2411
+ c: 10800,
2412
+ d: 14400,
2413
+ e: 18e3,
2414
+ f: 21600,
2415
+ g: 25200,
2416
+ h: 28800,
2417
+ i: 32400,
2418
+ k: 36e3,
2419
+ l: 39600,
2420
+ m: 43200,
2421
+ n: -3600,
2422
+ o: -7200,
2423
+ p: -10800,
2424
+ q: -14400,
2425
+ r: -18e3,
2426
+ s: -21600,
2427
+ t: -25200,
2428
+ u: -28800,
2429
+ v: -32400,
2430
+ w: -36e3,
2431
+ x: -39600,
2432
+ y: -43200,
2433
+ z: 0
2434
+ }, Q = {
2435
+ yesterday: {
2436
+ regex: /^yesterday/i,
2437
+ name: "yesterday",
2438
+ callback() {
2439
+ return --this.rd, this.resetTime();
2440
+ }
2441
+ },
2442
+ now: {
2443
+ regex: /^now/i,
2444
+ name: "now"
2445
+ },
2446
+ noon: {
2447
+ regex: /^noon/i,
2448
+ name: "noon",
2449
+ callback() {
2450
+ return this.resetTime() && this.time(12, 0, 0, 0);
2451
+ }
2452
+ },
2453
+ midnightOrToday: {
2454
+ regex: /^(midnight|today)/i,
2455
+ name: "midnight | today",
2456
+ callback() {
2457
+ return this.resetTime();
2458
+ }
2459
+ },
2460
+ tomorrow: {
2461
+ regex: /^tomorrow/i,
2462
+ name: "tomorrow",
2463
+ callback() {
2464
+ return this.rd += 1, this.resetTime();
2465
+ }
2466
+ },
2467
+ timestamp: {
2468
+ regex: /^@(-?\d+)/i,
2469
+ name: "timestamp",
2470
+ callback(e, t) {
2471
+ return this.rs += +t, this.y = 1970, this.m = 0, this.d = 1, this.dates = 0, this.resetTime() && this.zone(0);
2472
+ }
2473
+ },
2474
+ firstOrLastDay: {
2475
+ regex: /^(first|last) day of/i,
2476
+ name: "firstdayof | lastdayof",
2477
+ callback(e, t) {
2478
+ t.toLowerCase() === "first" ? this.firstOrLastDayOfMonth = 1 : this.firstOrLastDayOfMonth = -1;
2479
+ }
2480
+ },
2481
+ backOrFrontOf: {
2482
+ regex: RegExp("^(back|front) of " + B + R + z + "?", "i"),
2483
+ name: "backof | frontof",
2484
+ callback(e, t, n, r) {
2485
+ let i = +n, a = 15;
2486
+ return t.toLowerCase() === "back" || (--i, a = 45), i = q(i, r), this.resetTime() && this.time(i, a, 0, 0);
2487
+ }
2488
+ },
2489
+ mssqltime: {
2490
+ regex: RegExp("^" + V + ":([0-5][0-9]):(60|[0-5][0-9])[:.]([0-9]+)(?:([ap])\\.?m\\.?([\\t ]|$))", "i"),
2491
+ name: "mssqltime",
2492
+ callback(e, t, n, r, i, a) {
2493
+ return this.time(q(+t, a), +n, +r, +i.substr(0, 3));
2494
+ }
2495
+ },
2496
+ oracledate: {
2497
+ regex: /^(\d{2})-([A-Z]{3})-(\d{2})$/i,
2498
+ name: "d-M-y",
2499
+ callback(e, t, n, r) {
2500
+ let i = {
2501
+ JAN: 0,
2502
+ FEB: 1,
2503
+ MAR: 2,
2504
+ APR: 3,
2505
+ MAY: 4,
2506
+ JUN: 5,
2507
+ JUL: 6,
2508
+ AUG: 7,
2509
+ SEP: 8,
2510
+ OCT: 9,
2511
+ NOV: 10,
2512
+ DEC: 11
2513
+ }[n.toUpperCase()] ?? NaN;
2514
+ return this.ymd(2e3 + parseInt(r, 10), i, parseInt(t, 10));
2515
+ }
2516
+ },
2517
+ timeLong12: {
2518
+ regex: RegExp("^" + V + "[:.]([0-5]?[0-9])[:.](60|[0-5][0-9])[ \\t]*(?:([ap])\\.?m\\.?([\\t ]|$))", "i"),
2519
+ name: "timelong12",
2520
+ callback(e, t, n, r, i) {
2521
+ return this.time(q(+t, i), +n, +r, 0);
2522
+ }
2523
+ },
2524
+ timeShort12: {
2525
+ regex: RegExp("^" + V + "[:.]([0-5][0-9])[ \\t]*(?:([ap])\\.?m\\.?([\\t ]|$))", "i"),
2526
+ name: "timeshort12",
2527
+ callback(e, t, n, r) {
2528
+ return this.time(q(+t, r), +n, 0, 0);
2529
+ }
2530
+ },
2531
+ timeTiny12: {
2532
+ regex: RegExp("^" + V + R + z, "i"),
2533
+ name: "timetiny12",
2534
+ callback(e, t, n) {
2535
+ return this.time(q(+t, n), 0, 0, 0);
2536
+ }
2537
+ },
2538
+ soap: {
2539
+ regex: RegExp("^" + H + "-(0[0-9]|1[0-2])-(0[0-9]|[1-2][0-9]|3[01])T([01][0-9]|2[0-4]):([0-5][0-9]):(60|[0-5][0-9])(?:\\.([0-9]+))((?:GMT)?([+-])(2[0-4]|[01]?[0-9]):?([0-5]?[0-9])?)?", "i"),
2540
+ name: "soap",
2541
+ callback(e, t, n, r, i, a, o, s, c) {
2542
+ return this.ymd(+t, n - 1, +r) && this.time(+i, +a, +o, +s.substr(0, 3)) && this.zone(X(c));
2543
+ }
2544
+ },
2545
+ wddx: {
2546
+ regex: RegExp("^" + H + "-(1[0-2]|0?[0-9])-(?:(3[01]|[0-2]?[0-9])(?:st|nd|rd|th)?)T(2[0-4]|[01]?[0-9]):([0-5]?[0-9]):(60|[0-5]?[0-9])"),
2547
+ name: "wddx",
2548
+ callback(e, t, n, r, i, a, o) {
2549
+ return this.ymd(+t, n - 1, +r) && this.time(+i, +a, +o, 0);
2550
+ }
2551
+ },
2552
+ exif: {
2553
+ regex: RegExp("^" + H + ":(0[0-9]|1[0-2]):(0[0-9]|[1-2][0-9]|3[01]) ([01][0-9]|2[0-4]):([0-5][0-9]):(60|[0-5][0-9])", "i"),
2554
+ name: "exif",
2555
+ callback(e, t, n, r, i, a, o) {
2556
+ return this.ymd(+t, n - 1, +r) && this.time(+i, +a, +o, 0);
2557
+ }
2558
+ },
2559
+ xmlRpc: {
2560
+ regex: RegExp("^" + H + U + Ce + "T(2[0-4]|[01]?[0-9]):([0-5][0-9]):(60|[0-5][0-9])"),
2561
+ name: "xmlrpc",
2562
+ callback(e, t, n, r, i, a, o) {
2563
+ return this.ymd(+t, n - 1, +r) && this.time(+i, +a, +o, 0);
2564
+ }
2565
+ },
2566
+ xmlRpcNoColon: {
2567
+ regex: RegExp("^" + H + U + Ce + "[Tt](2[0-4]|[01]?[0-9])([0-5][0-9])(60|[0-5][0-9])"),
2568
+ name: "xmlrpcnocolon",
2569
+ callback(e, t, n, r, i, a, o) {
2570
+ return this.ymd(+t, n - 1, +r) && this.time(+i, +a, +o, 0);
2571
+ }
2572
+ },
2573
+ clf: {
2574
+ regex: RegExp("^" + W + "/(jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec)/([0-9]{4}):([01][0-9]|2[0-4]):([0-5][0-9]):(60|[0-5][0-9])[ \\t]+((?:GMT)?([+-])(2[0-4]|[01]?[0-9]):?([0-5]?[0-9])?)", "i"),
2575
+ name: "clf",
2576
+ callback(e, t, n, r, i, a, o, s) {
2577
+ return this.ymd(+r, Y(n), +t) && this.time(+i, +a, +o, 0) && this.zone(X(s));
2578
+ }
2579
+ },
2580
+ iso8601long: {
2581
+ regex: RegExp("^t?" + B + "[:.]([0-5]?[0-9])[:.](60|[0-5]?[0-9])(?:\\.([0-9]+))", "i"),
2582
+ name: "iso8601long",
2583
+ callback(e, t, n, r, i) {
2584
+ return this.time(+t, +n, +r, +i.substr(0, 3));
2585
+ }
2586
+ },
2587
+ dateTextual: {
2588
+ regex: RegExp("^" + G + "[ .\\t-]*(?:(3[01]|[0-2]?[0-9])(?:st|nd|rd|th)?)[,.stndrh\\t ]+([0-9]{1,4})", "i"),
2589
+ name: "datetextual",
2590
+ callback(e, t, n, r) {
2591
+ return this.ymd(J(r), Y(t), +n);
2592
+ }
2593
+ },
2594
+ pointedDate4: {
2595
+ regex: RegExp("^" + W + "[.\\t-](1[0-2]|0?[0-9])[.-]([0-9]{4})"),
2596
+ name: "pointeddate4",
2597
+ callback(e, t, n, r) {
2598
+ return this.ymd(+r, n - 1, +t);
2599
+ }
2600
+ },
2601
+ pointedDate2: {
2602
+ regex: RegExp("^" + W + "[.\\t](1[0-2]|0?[0-9])\\.([0-9]{2})"),
2603
+ name: "pointeddate2",
2604
+ callback(e, t, n, r) {
2605
+ return this.ymd(J(r), n - 1, +t);
2606
+ }
2607
+ },
2608
+ timeLong24: {
2609
+ regex: RegExp("^t?" + B + "[:.]([0-5]?[0-9])[:.](60|[0-5]?[0-9])"),
2610
+ name: "timelong24",
2611
+ callback(e, t, n, r) {
2612
+ return this.time(+t, +n, +r, 0);
2613
+ }
2614
+ },
2615
+ dateNoColon: {
2616
+ regex: RegExp("^" + H + U + Ce),
2617
+ name: "datenocolon",
2618
+ callback(e, t, n, r) {
2619
+ return this.ymd(+t, n - 1, +r);
2620
+ }
2621
+ },
2622
+ pgydotd: {
2623
+ regex: RegExp("^" + H + "\\.?(00[1-9]|0[1-9][0-9]|[12][0-9][0-9]|3[0-5][0-9]|36[0-6])"),
2624
+ name: "pgydotd",
2625
+ callback(e, t, n) {
2626
+ return this.ymd(+t, 0, +n);
2627
+ }
2628
+ },
2629
+ timeShort24: {
2630
+ regex: RegExp("^t?" + B + "[:.]([0-5]?[0-9])", "i"),
2631
+ name: "timeshort24",
2632
+ callback(e, t, n) {
2633
+ return this.time(+t, +n, 0, 0);
2634
+ }
2635
+ },
2636
+ iso8601noColon: {
2637
+ regex: RegExp("^t?" + ve + ye + "(60|[0-5][0-9])", "i"),
2638
+ name: "iso8601nocolon",
2639
+ callback(e, t, n, r) {
2640
+ return this.time(+t, +n, +r, 0);
2641
+ }
2642
+ },
2643
+ iso8601dateSlash: {
2644
+ regex: RegExp("^" + H + "/(0[0-9]|1[0-2])/(0[0-9]|[1-2][0-9]|3[01])/"),
2645
+ name: "iso8601dateslash",
2646
+ callback(e, t, n, r) {
2647
+ return this.ymd(+t, n - 1, +r);
2648
+ }
2649
+ },
2650
+ dateSlash: {
2651
+ regex: RegExp("^" + H + "/(1[0-2]|0?[0-9])/(?:(3[01]|[0-2]?[0-9])(?:st|nd|rd|th)?)"),
2652
+ name: "dateslash",
2653
+ callback(e, t, n, r) {
2654
+ return this.ymd(+t, n - 1, +r);
2655
+ }
2656
+ },
2657
+ american: {
2658
+ regex: RegExp("^" + Se + "/(?:(3[01]|[0-2]?[0-9])(?:st|nd|rd|th)?)/([0-9]{1,4})"),
2659
+ name: "american",
2660
+ callback(e, t, n, r) {
2661
+ return this.ymd(J(r), t - 1, +n);
2662
+ }
2663
+ },
2664
+ americanShort: {
2665
+ regex: RegExp("^" + Se + "/(?:(3[01]|[0-2]?[0-9])(?:st|nd|rd|th)?)"),
2666
+ name: "americanshort",
2667
+ callback(e, t, n) {
2668
+ return this.ymd(this.y, t - 1, +n);
2669
+ }
2670
+ },
2671
+ gnuDateShortOrIso8601date2: {
2672
+ regex: RegExp("^([0-9]{1,4})-(1[0-2]|0?[0-9])-(?:(3[01]|[0-2]?[0-9])(?:st|nd|rd|th)?)"),
2673
+ name: "gnudateshort | iso8601date2",
2674
+ callback(e, t, n, r) {
2675
+ return this.ymd(J(t), n - 1, +r);
2676
+ }
2677
+ },
2678
+ iso8601date4: {
2679
+ regex: RegExp("^([+-]?[0-9]{4})-" + U + "-(0[0-9]|[1-2][0-9]|3[01])"),
2680
+ name: "iso8601date4",
2681
+ callback(e, t, n, r) {
2682
+ return this.ymd(+t, n - 1, +r);
2683
+ }
2684
+ },
2685
+ gnuNoColon: {
2686
+ regex: RegExp("^t?" + ve + ye, "i"),
2687
+ name: "gnunocolon",
2688
+ callback(e, t, n) {
2689
+ switch (this.times) {
2690
+ case 0: return this.time(+t, +n, 0, this.f);
2691
+ case 1: return this.y = 100 * t + +n, this.times++, !0;
2692
+ default: return !1;
2693
+ }
2694
+ }
2695
+ },
2696
+ gnuDateShorter: {
2697
+ regex: RegExp("^" + H + "-(1[0-2]|0?[0-9])"),
2698
+ name: "gnudateshorter",
2699
+ callback(e, t, n) {
2700
+ return this.ymd(+t, n - 1, 1);
2701
+ }
2702
+ },
2703
+ pgTextReverse: {
2704
+ regex: RegExp("^(\\d{3,4}|[4-9]\\d|3[2-9])-(" + Te + ")-(0[0-9]|[1-2][0-9]|3[01])", "i"),
2705
+ name: "pgtextreverse",
2706
+ callback(e, t, n, r) {
2707
+ return this.ymd(J(t), Y(n), +r);
2708
+ }
2709
+ },
2710
+ dateFull: {
2711
+ regex: RegExp("^" + W + "[ \\t.-]*(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec|i[vx]|vi{0,3}|xi{0,2}|i{1,3})[ \\t.-]*([0-9]{1,4})", "i"),
2712
+ name: "datefull",
2713
+ callback(e, t, n, r) {
2714
+ return this.ymd(J(r), Y(n), +t);
2715
+ }
2716
+ },
2717
+ dateNoDay: {
2718
+ regex: RegExp("^" + G + "[ .\\t-]*([0-9]{4})", "i"),
2719
+ name: "datenoday",
2720
+ callback(e, t, n) {
2721
+ return this.ymd(+n, Y(t), 1);
2722
+ }
2723
+ },
2724
+ dateNoDayRev: {
2725
+ regex: RegExp("^" + H + "[ .\\t-]*(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec|i[vx]|vi{0,3}|xi{0,2}|i{1,3})", "i"),
2726
+ name: "datenodayrev",
2727
+ callback(e, t, n) {
2728
+ return this.ymd(+t, Y(n), 1);
2729
+ }
2730
+ },
2731
+ pgTextShort: {
2732
+ regex: RegExp("^(" + Te + ")-(0[0-9]|[1-2][0-9]|3[01])-([0-9]{1,4})", "i"),
2733
+ name: "pgtextshort",
2734
+ callback(e, t, n, r) {
2735
+ return this.ymd(J(r), Y(t), +n);
2736
+ }
2737
+ },
2738
+ dateNoYear: {
2739
+ regex: RegExp("^" + K, "i"),
2740
+ name: "datenoyear",
2741
+ callback(e, t, n) {
2742
+ return this.ymd(this.y, Y(t), +n);
2743
+ }
2744
+ },
2745
+ dateNoYearRev: {
2746
+ regex: RegExp("^" + W + "[ .\\t-]*(january|february|march|april|may|june|july|august|september|october|november|december|jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec|i[vx]|vi{0,3}|xi{0,2}|i{1,3})", "i"),
2747
+ name: "datenoyearrev",
2748
+ callback(e, t, n) {
2749
+ return this.ymd(this.y, Y(n), +t);
2750
+ }
2751
+ },
2752
+ isoWeekDay: {
2753
+ regex: RegExp("^" + H + "-?W(0[1-9]|[1-4][0-9]|5[0-3])(?:-?([0-7]))?"),
2754
+ name: "isoweekday | isoweek",
2755
+ callback(e, t, n, r) {
2756
+ let i = r ? +r : 1;
2757
+ if (!this.ymd(+t, 0, 1)) return !1;
2758
+ let a = new Date(this.y, this.m, this.d).getDay();
2759
+ return a = 0 - (a > 4 ? a - 7 : a), this.rd += a + 7 * (n - 1) + i, !0;
2760
+ }
2761
+ },
2762
+ relativeText: {
2763
+ regex: RegExp("^(first|second|third|fourth|fifth|sixth|seventh|eighth?|ninth|tenth|eleventh|twelfth|" + xe + ")[ \\t]+((?:second|sec|minute|min|hour|day|fortnight|forthnight|month|year)s?|weeks|sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun|mon|tue|wed|thu|fri|sat|weekdays?)", "i"),
2764
+ name: "relativetext",
2765
+ callback(e, t, n) {
2766
+ let { amount: r } = function(e) {
2767
+ let t = e.toLowerCase();
2768
+ return {
2769
+ amount: {
2770
+ last: -1,
2771
+ previous: -1,
2772
+ this: 0,
2773
+ first: 1,
2774
+ next: 1,
2775
+ second: 2,
2776
+ third: 3,
2777
+ fourth: 4,
2778
+ fifth: 5,
2779
+ sixth: 6,
2780
+ seventh: 7,
2781
+ eight: 8,
2782
+ eighth: 8,
2783
+ ninth: 9,
2784
+ tenth: 10,
2785
+ eleventh: 11,
2786
+ twelfth: 12
2787
+ }[t] ?? 0,
2788
+ behavior: { this: 1 }[t] || 0
2789
+ };
2790
+ }(t);
2791
+ switch (n.toLowerCase()) {
2792
+ case "sec":
2793
+ case "secs":
2794
+ case "second":
2795
+ case "seconds":
2796
+ this.rs += r;
2797
+ break;
2798
+ case "min":
2799
+ case "mins":
2800
+ case "minute":
2801
+ case "minutes":
2802
+ this.ri += r;
2803
+ break;
2804
+ case "hour":
2805
+ case "hours":
2806
+ this.rh += r;
2807
+ break;
2808
+ case "day":
2809
+ case "days":
2810
+ this.rd += r;
2811
+ break;
2812
+ case "fortnight":
2813
+ case "fortnights":
2814
+ case "forthnight":
2815
+ case "forthnights":
2816
+ this.rd += 14 * r;
2817
+ break;
2818
+ case "week":
2819
+ case "weeks":
2820
+ this.rd += 7 * r;
2821
+ break;
2822
+ case "month":
2823
+ case "months":
2824
+ this.rm += r;
2825
+ break;
2826
+ case "year":
2827
+ case "years":
2828
+ this.ry += r;
2829
+ break;
2830
+ case "mon":
2831
+ case "monday":
2832
+ case "tue":
2833
+ case "tuesday":
2834
+ case "wed":
2835
+ case "wednesday":
2836
+ case "thu":
2837
+ case "thursday":
2838
+ case "fri":
2839
+ case "friday":
2840
+ case "sat":
2841
+ case "saturday":
2842
+ case "sun":
2843
+ case "sunday": this.resetTime(), this.weekday = Ee(n, 7), this.weekdayBehavior = 1, this.rd += 7 * (r > 0 ? r - 1 : r);
2844
+ }
2845
+ }
2846
+ },
2847
+ relative: {
2848
+ regex: RegExp("^([+-]*)[ \\t]*(\\d+)" + R + "((?:second|sec|minute|min|hour|day|fortnight|forthnight|month|year)s?|weeks|sunday|monday|tuesday|wednesday|thursday|friday|saturday|sun|mon|tue|wed|thu|fri|sat|weekdays?|week)", "i"),
2849
+ name: "relative",
2850
+ callback(e, t, n, r) {
2851
+ let i = n * (-1) ** t.replace(/[^-]/g, "").length;
2852
+ switch (r.toLowerCase()) {
2853
+ case "sec":
2854
+ case "secs":
2855
+ case "second":
2856
+ case "seconds":
2857
+ this.rs += i;
2858
+ break;
2859
+ case "min":
2860
+ case "mins":
2861
+ case "minute":
2862
+ case "minutes":
2863
+ this.ri += i;
2864
+ break;
2865
+ case "hour":
2866
+ case "hours":
2867
+ this.rh += i;
2868
+ break;
2869
+ case "day":
2870
+ case "days":
2871
+ this.rd += i;
2872
+ break;
2873
+ case "fortnight":
2874
+ case "fortnights":
2875
+ case "forthnight":
2876
+ case "forthnights":
2877
+ this.rd += 14 * i;
2878
+ break;
2879
+ case "week":
2880
+ case "weeks":
2881
+ this.rd += 7 * i;
2882
+ break;
2883
+ case "month":
2884
+ case "months":
2885
+ this.rm += i;
2886
+ break;
2887
+ case "year":
2888
+ case "years":
2889
+ this.ry += i;
2890
+ break;
2891
+ case "mon":
2892
+ case "monday":
2893
+ case "tue":
2894
+ case "tuesday":
2895
+ case "wed":
2896
+ case "wednesday":
2897
+ case "thu":
2898
+ case "thursday":
2899
+ case "fri":
2900
+ case "friday":
2901
+ case "sat":
2902
+ case "saturday":
2903
+ case "sun":
2904
+ case "sunday": this.resetTime(), this.weekday = Ee(r, 7), this.weekdayBehavior = 1, this.rd += 7 * (i > 0 ? i - 1 : i);
2905
+ }
2906
+ }
2907
+ },
2908
+ dayText: {
2909
+ regex: RegExp("^(" + be + ")", "i"),
2910
+ name: "daytext",
2911
+ callback(e, t) {
2912
+ this.resetTime(), this.weekday = Ee(t, 0), this.weekdayBehavior !== 2 && (this.weekdayBehavior = 1);
2913
+ }
2914
+ },
2915
+ relativeTextWeek: {
2916
+ regex: RegExp("^(" + xe + ")[ \\t]+week", "i"),
2917
+ name: "relativetextweek",
2918
+ callback(e, t) {
2919
+ switch (this.weekdayBehavior = 2, t.toLowerCase()) {
2920
+ case "this":
2921
+ this.rd += 0;
2922
+ break;
2923
+ case "next":
2924
+ this.rd += 7;
2925
+ break;
2926
+ case "last":
2927
+ case "previous": this.rd -= 7;
2928
+ }
2929
+ isNaN(this.weekday) && (this.weekday = 1);
2930
+ }
2931
+ },
2932
+ monthFullOrMonthAbbr: {
2933
+ regex: RegExp("^(" + we + "|jan|feb|mar|apr|may|jun|jul|aug|sept?|oct|nov|dec)", "i"),
2934
+ name: "monthfull | monthabbr",
2935
+ callback(e, t) {
2936
+ return this.ymd(this.y, Y(t), this.d);
2937
+ }
2938
+ },
2939
+ tzCorrection: {
2940
+ regex: RegExp("^((?:GMT)?([+-])(2[0-4]|[01]?[0-9]):?([0-5]?[0-9])?)", "i"),
2941
+ name: "tzcorrection",
2942
+ callback(e) {
2943
+ return this.zone(X(e));
2944
+ }
2945
+ },
2946
+ tzAbbr: {
2947
+ regex: /* @__PURE__ */ RegExp("^\\(?([a-zA-Z]{1,6})\\)?"),
2948
+ name: "tzabbr",
2949
+ callback(e, t) {
2950
+ let n = Z[t.toLowerCase()];
2951
+ return n != null && !Number.isNaN(n) && this.zone(n);
2952
+ }
2953
+ },
2954
+ ago: {
2955
+ regex: /^ago/i,
2956
+ name: "ago",
2957
+ callback() {
2958
+ this.ry = -this.ry, this.rm = -this.rm, this.rd = -this.rd, this.rh = -this.rh, this.ri = -this.ri, this.rs = -this.rs, this.rf = -this.rf;
2959
+ }
2960
+ },
2961
+ year4: {
2962
+ regex: RegExp("^" + H),
2963
+ name: "year4",
2964
+ callback(e, t) {
2965
+ return this.y = +t, !0;
2966
+ }
2967
+ },
2968
+ whitespace: {
2969
+ regex: /^[ .,\t]+/,
2970
+ name: "whitespace"
2971
+ },
2972
+ dateShortWithTimeLong: {
2973
+ regex: RegExp("^" + K + "t?(2[0-4]|[01]?[0-9])[:.]([0-5]?[0-9])[:.](60|[0-5]?[0-9])", "i"),
2974
+ name: "dateshortwithtimelong",
2975
+ callback(e, t, n, r, i, a) {
2976
+ return this.ymd(this.y, Y(t), +n) && this.time(+r, +i, +a, 0);
2977
+ }
2978
+ },
2979
+ dateShortWithTimeLong12: {
2980
+ regex: RegExp("^" + K + V + "[:.]([0-5]?[0-9])[:.](60|[0-5][0-9])[ \\t]*(?:([ap])\\.?m\\.?([\\t ]|$))", "i"),
2981
+ name: "dateshortwithtimelong12",
2982
+ callback(e, t, n, r, i, a, o) {
2983
+ return this.ymd(this.y, Y(t), +n) && this.time(q(+r, o), +i, +a, 0);
2984
+ }
2985
+ },
2986
+ dateShortWithTimeShort: {
2987
+ regex: RegExp("^" + K + "t?(2[0-4]|[01]?[0-9])[:.]([0-5]?[0-9])", "i"),
2988
+ name: "dateshortwithtimeshort",
2989
+ callback(e, t, n, r, i) {
2990
+ return this.ymd(this.y, Y(t), +n) && this.time(+r, +i, 0, 0);
2991
+ }
2992
+ },
2993
+ dateShortWithTimeShort12: {
2994
+ regex: RegExp("^" + K + V + "[:.]([0-5][0-9])[ \\t]*(?:([ap])\\.?m\\.?([\\t ]|$))", "i"),
2995
+ name: "dateshortwithtimeshort12",
2996
+ callback(e, t, n, r, i, a) {
2997
+ return this.ymd(this.y, Y(t), +n) && this.time(q(+r, a), +i, 0, 0);
2998
+ }
2999
+ }
3000
+ }, De = {
3001
+ y: NaN,
3002
+ m: NaN,
3003
+ d: NaN,
3004
+ h: NaN,
3005
+ i: NaN,
3006
+ s: NaN,
3007
+ f: NaN,
3008
+ ry: 0,
3009
+ rm: 0,
3010
+ rd: 0,
3011
+ rh: 0,
3012
+ ri: 0,
3013
+ rs: 0,
3014
+ rf: 0,
3015
+ weekday: NaN,
3016
+ weekdayBehavior: 0,
3017
+ firstOrLastDayOfMonth: 0,
3018
+ z: NaN,
3019
+ dates: 0,
3020
+ times: 0,
3021
+ zones: 0,
3022
+ ymd(e, t, n) {
3023
+ return !(this.dates > 0) && (this.dates++, this.y = e, this.m = t, this.d = n, !0);
3024
+ },
3025
+ time(e, t, n, r) {
3026
+ return !(this.times > 0) && (this.times++, this.h = e, this.i = t, this.s = n, this.f = r, !0);
3027
+ },
3028
+ resetTime() {
3029
+ return this.h = 0, this.i = 0, this.s = 0, this.f = 0, this.times = 0, !0;
3030
+ },
3031
+ zone(e) {
3032
+ return this.zones <= 1 && (this.zones++, this.z = e, !0);
3033
+ },
3034
+ toDate(e) {
3035
+ switch (this.dates && !this.times && (this.h = this.i = this.s = this.f = 0), isNaN(this.y) && (this.y = e.getFullYear()), isNaN(this.m) && (this.m = e.getMonth()), isNaN(this.d) && (this.d = e.getDate()), isNaN(this.h) && (this.h = e.getHours()), isNaN(this.i) && (this.i = e.getMinutes()), isNaN(this.s) && (this.s = e.getSeconds()), isNaN(this.f) && (this.f = e.getMilliseconds()), this.firstOrLastDayOfMonth) {
3036
+ case 1:
3037
+ this.d = 1;
3038
+ break;
3039
+ case -1: this.d = 0, this.m += 1;
3040
+ }
3041
+ if (!isNaN(this.weekday)) {
3042
+ let t = new Date(e.getTime());
3043
+ t.setFullYear(this.y, this.m, this.d), t.setHours(this.h, this.i, this.s, this.f);
3044
+ let n = t.getDay();
3045
+ if (this.weekdayBehavior === 2) n === 0 && this.weekday !== 0 && (this.weekday = -6), this.weekday === 0 && n !== 0 && (this.weekday = 7), this.d -= n, this.d += this.weekday;
3046
+ else {
3047
+ let e = this.weekday - n;
3048
+ (this.rd < 0 && e < 0 || this.rd >= 0 && e <= -this.weekdayBehavior) && (e += 7), this.weekday >= 0 ? this.d += e : this.d -= 7 - (Math.abs(this.weekday) - n), this.weekday = NaN;
3049
+ }
3050
+ }
3051
+ this.y += this.ry, this.m += this.rm, this.d += this.rd, this.h += this.rh, this.i += this.ri, this.s += this.rs, this.f += this.rf, this.ry = this.rm = this.rd = 0, this.rh = this.ri = this.rs = this.rf = 0;
3052
+ let t = new Date(e.getTime());
3053
+ switch (t.setFullYear(this.y, this.m, this.d), t.setHours(this.h, this.i, this.s, this.f), this.firstOrLastDayOfMonth) {
3054
+ case 1:
3055
+ t.setDate(1);
3056
+ break;
3057
+ case -1: t.setMonth(t.getMonth() + 1, 0);
3058
+ }
3059
+ return isNaN(this.z) || t.getTimezoneOffset() === this.z || (t.setUTCFullYear(t.getFullYear(), t.getMonth(), t.getDate()), t.setUTCHours(t.getHours(), t.getMinutes(), t.getSeconds() - this.z, t.getMilliseconds())), t;
3060
+ }
3061
+ };
3062
+ e.AbstractProvider = F, e.ArrayAdapter = A, e.ArrayProvider = class extends F {
3063
+ getFunctions() {
3064
+ return [
3065
+ me,
3066
+ he,
3067
+ ge
3068
+ ];
3069
+ }
3070
+ }, e.BasicProvider = class extends F {
3071
+ getFunctions() {
3072
+ return [ie];
3073
+ }
3074
+ }, e.Compiler = ne, e.DateProvider = class extends F {
3075
+ getFunctions() {
3076
+ return [new N("date", function(e, t) {
3077
+ let n = "";
3078
+ return t && (n = `, ${t}`), `date(${e}${n})`;
3079
+ }, function(e, t, n) {
3080
+ return _e(t, n);
3081
+ }), new N("strtotime", function(e, t) {
3082
+ let n = "";
3083
+ return t && (n = `, ${t}`), `strtotime(${e}${n})`;
3084
+ }, function(e, t, n) {
3085
+ return function(e, t) {
3086
+ let n = t ?? Math.floor(Date.now() / 1e3), r = [
3087
+ Q.yesterday,
3088
+ Q.now,
3089
+ Q.noon,
3090
+ Q.midnightOrToday,
3091
+ Q.tomorrow,
3092
+ Q.timestamp,
3093
+ Q.firstOrLastDay,
3094
+ Q.backOrFrontOf,
3095
+ Q.timeTiny12,
3096
+ Q.timeShort12,
3097
+ Q.timeLong12,
3098
+ Q.mssqltime,
3099
+ Q.oracledate,
3100
+ Q.timeShort24,
3101
+ Q.timeLong24,
3102
+ Q.iso8601long,
3103
+ Q.gnuNoColon,
3104
+ Q.iso8601noColon,
3105
+ Q.americanShort,
3106
+ Q.american,
3107
+ Q.iso8601date4,
3108
+ Q.iso8601dateSlash,
3109
+ Q.dateSlash,
3110
+ Q.gnuDateShortOrIso8601date2,
3111
+ Q.gnuDateShorter,
3112
+ Q.dateFull,
3113
+ Q.pointedDate4,
3114
+ Q.pointedDate2,
3115
+ Q.dateNoDay,
3116
+ Q.dateNoDayRev,
3117
+ Q.dateTextual,
3118
+ Q.dateNoYear,
3119
+ Q.dateNoYearRev,
3120
+ Q.dateNoColon,
3121
+ Q.xmlRpc,
3122
+ Q.xmlRpcNoColon,
3123
+ Q.soap,
3124
+ Q.wddx,
3125
+ Q.exif,
3126
+ Q.pgydotd,
3127
+ Q.isoWeekDay,
3128
+ Q.pgTextShort,
3129
+ Q.pgTextReverse,
3130
+ Q.clf,
3131
+ Q.year4,
3132
+ Q.ago,
3133
+ Q.dayText,
3134
+ Q.relativeTextWeek,
3135
+ Q.relativeText,
3136
+ Q.monthFullOrMonthAbbr,
3137
+ Q.tzCorrection,
3138
+ Q.tzAbbr,
3139
+ Q.dateShortWithTimeShort12,
3140
+ Q.dateShortWithTimeLong12,
3141
+ Q.dateShortWithTimeShort,
3142
+ Q.dateShortWithTimeLong,
3143
+ Q.relative,
3144
+ Q.whitespace
3145
+ ], i = { ...De };
3146
+ for (; e.length;) {
3147
+ let t = null, n = null;
3148
+ for (let i of r) {
3149
+ let r = e.match(i.regex);
3150
+ r && (!t || r[0].length > t[0].length) && (t = r, n = i);
3151
+ }
3152
+ if (!n || !t || n.callback && !1 === n.callback.apply(i, t)) return !1;
3153
+ e = e.substr(t[0].length), n = null, t = null;
3154
+ }
3155
+ return Math.floor(i.toDate(/* @__PURE__ */ new Date(1e3 * n)).getTime() / 1e3);
3156
+ }(t, n);
3157
+ })];
3158
+ }
3159
+ }, e.ExpressionFunction = N, e.ExpressionLanguage = P, e.IGNORE_UNKNOWN_FUNCTIONS = 2, e.IGNORE_UNKNOWN_VARIABLES = 1, e.Parser = D, e.StringProvider = class extends F {
3160
+ getFunctions() {
3161
+ return [
3162
+ new N("strtolower", (e) => "strtolower(" + e + ")", (e, t) => function(e) {
3163
+ return (e + "").toLowerCase();
3164
+ }(t)),
3165
+ new N("strtoupper", (e) => "strtoupper(" + e + ")", (e, t) => function(e) {
3166
+ return (e + "").toUpperCase();
3167
+ }(t)),
3168
+ new N("explode", (e, t, n = "null") => `explode(${e}, ${t}, ${n})`, (e, t, n, r = null) => function(...e) {
3169
+ let [t, n, r] = e, i = t, a = n;
3170
+ if (e.length < 2 || i === void 0 || a === void 0) return null;
3171
+ if (i === "" || !1 === i || i === null) return !1;
3172
+ if (typeof i == "function" || typeof i == "object" || typeof a == "function" || typeof a == "object") return { 0: "" };
3173
+ !0 === i && (i = "1");
3174
+ let o = i + "", s = (a + "").split(o);
3175
+ return r === void 0 ? s : (r === 0 && (r = 1), r > 0 ? r >= s.length ? s : s.slice(0, r - 1).concat([s.slice(r - 1).join(o)]) : -r >= s.length ? [] : (s.splice(s.length + r), s));
3176
+ }(t, n, r)),
3177
+ new N("strlen", function(e) {
3178
+ return `strlen(${e});`;
3179
+ }, function(e, t) {
3180
+ return function(e) {
3181
+ let t = e + "";
3182
+ if ((L("unicode.semantics") || "off") === "off") return t.length;
3183
+ let n = 0, r = 0, i = function(e, t) {
3184
+ let n = e.charCodeAt(t);
3185
+ if (n >= 55296 && n <= 56319) {
3186
+ if (e.length <= t + 1) throw Error("High surrogate without following low surrogate");
3187
+ let n = e.charCodeAt(t + 1);
3188
+ if (n < 56320 || n > 57343) throw Error("High surrogate without following low surrogate");
3189
+ return e.charAt(t) + e.charAt(t + 1);
3190
+ }
3191
+ if (n >= 56320 && n <= 57343) {
3192
+ if (t === 0) throw Error("Low surrogate without preceding high surrogate");
3193
+ let n = e.charCodeAt(t - 1);
3194
+ if (n < 55296 || n > 56319) throw Error("Low surrogate without preceding high surrogate");
3195
+ return !1;
3196
+ }
3197
+ return e.charAt(t);
3198
+ };
3199
+ for (n = 0, r = 0; n < t.length; n++) !1 !== i(t, n) && r++;
3200
+ return r;
3201
+ }(t);
3202
+ }),
3203
+ new N("strstr", function(e, t, n) {
3204
+ let r = "";
3205
+ return n && (r = `, ${n}`), `strstr(${e}, ${t}${r});`;
3206
+ }, function(e, t, n, r) {
3207
+ return function(e, t, n) {
3208
+ let r = 0;
3209
+ return r = (e += "").indexOf(t), r !== -1 && (n ? e.substr(0, r) : e.slice(r));
3210
+ }(t, n, r);
3211
+ }),
3212
+ new N("stristr", function(e, t, n) {
3213
+ let r = "";
3214
+ return n && (r = `, ${n}`), `stristr(${e}, ${t}${r});`;
3215
+ }, function(e, t, n, r) {
3216
+ return function(e, t, n) {
3217
+ let r = 0;
3218
+ return r = (e += "").toLowerCase().indexOf((t + "").toLowerCase()), r !== -1 && (n ? e.substr(0, r) : e.slice(r));
3219
+ }(t, n, r);
3220
+ }),
3221
+ new N("substr", function(e, t, n) {
3222
+ let r = "";
3223
+ return n && (r = `, ${n}`), `substr(${e}, ${t}${r});`;
3224
+ }, function(e, t, n, r) {
3225
+ return ue(t, n, r);
3226
+ })
3227
+ ];
3228
+ }
3229
+ }, e.default = P, e.tokenize = o, Object.defineProperty(e, "__esModule", { value: !0 });
3230
+ }), function(e) {
3231
+ var t = e.ExpressionLanguage;
3232
+ if (t && typeof t.ExpressionLanguage == "function") {
3233
+ var n = t.ExpressionLanguage;
3234
+ Object.keys(t).forEach(function(e) {
3235
+ e in n || (n[e] = t[e]);
3236
+ }), e.ExpressionLanguage = n;
3237
+ }
3238
+ }(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : e);
3239
+ })))(), 1), Se = null;
3240
+ function U() {
3241
+ let e = H, t = e.ExpressionLanguage || e.default || H;
3242
+ if (typeof t != "function") throw TypeError("Unable to resolve expression-language constructor.");
3243
+ return t;
3244
+ }
3245
+ function W() {
3246
+ return Se ??= new (U())(), Se;
3247
+ }
3248
+ function Ce(e) {
3249
+ return (e.formula?.expression || e.formula?.formula || "").trim();
3250
+ }
3251
+ function we(e) {
3252
+ return Object.entries(e.formula?.variables || {}).filter((e) => !!e[1]?.sourceKey);
3253
+ }
3254
+ function Te(e, t) {
3255
+ return Object.entries(e).forEach(([t, n]) => {
3256
+ if (Array.isArray(n)) {
3257
+ e[t] = n.map((e) => typeof e == "string" && e.trim() !== "" && !Number.isNaN(Number(e)) ? Number(e) : e);
3258
+ return;
3259
+ }
3260
+ typeof n == "string" && n.trim() !== "" && !Number.isNaN(Number(n)) && (e[t] = Number(n));
3261
+ }), e;
3262
+ }
3263
+ function G(e, t) {
3264
+ if (t.formatting !== "number") return typeof e == "number" || typeof e == "string" ? e : "";
3265
+ let n = e;
3266
+ Array.isArray(n) && (n = n.reduce((e, t) => e + Number(t || 0), 0));
3267
+ let r = typeof t.decimals == "number" ? t.decimals : 0, i = Number(n || 0).toFixed(r);
3268
+ return `${t.prefix || ""}${i}${t.suffix || ""}`;
3269
+ }
3270
+ function K(e, t) {
3271
+ let n = e.type?.endsWith("\\Number");
3272
+ return e.type?.endsWith("\\Checkboxes") ? Array.isArray(t) ? t.length ? t : "" : t ? [t] : "" : Array.isArray(t) ? t.length ? n ? t.map((e) => Number(e || 0)) : t : "" : n ? Number(t || 0) : t;
3273
+ }
3274
+ function q(e, t, n) {
3275
+ return G(W().evaluate(e, t), n);
3276
+ }
3277
+ //#endregion
3278
+ //#region src/rest.ts
3279
+ function J(e, t) {
3280
+ if (t.startsWith("http://") || t.startsWith("https://")) return t;
3281
+ if (e.startsWith("http://") || e.startsWith("https://")) return new URL(t, e).toString();
3282
+ let n = e.trim();
3283
+ return !n || n === "/" ? t : `${n.replace(/\/+$/, "")}${t}`;
3284
+ }
3285
+ async function Y(e, t) {
3286
+ let n = await fetch(e, t);
3287
+ if (!n.ok) throw Error(`Request failed with status ${n.status}.`);
3288
+ return n.json();
3289
+ }
3290
+ async function Ee(e) {
3291
+ let t = J(e.endpoint, "/actions/formie/client/forms/load"), n = JSON.stringify({
3292
+ handle: e.formHandle,
3293
+ siteId: e.siteId
3294
+ });
3295
+ return Y(t, {
3296
+ method: "POST",
3297
+ credentials: e.credentials ?? "same-origin",
3298
+ headers: { "Content-Type": "application/json" },
3299
+ body: n
3300
+ });
3301
+ }
3302
+ function X(e) {
3303
+ return {
3304
+ async submit({ definition: t, session: n, values: r, action: i }) {
3305
+ let a = J(e.endpoint, "/actions/formie/client/submissions/submit"), o = await I(t, r);
3306
+ return Y(a, {
3307
+ method: "POST",
3308
+ credentials: e.credentials ?? "same-origin",
3309
+ headers: { "Content-Type": "application/json" },
3310
+ body: JSON.stringify({
3311
+ handle: e.formHandle,
3312
+ siteId: e.siteId,
3313
+ action: i,
3314
+ session: n,
3315
+ values: o
3316
+ })
3317
+ });
3318
+ },
3319
+ async refreshSession({ session: t }) {
3320
+ return Y(J(e.endpoint, "/actions/formie/client/sessions/refresh"), {
3321
+ method: "POST",
3322
+ credentials: e.credentials ?? "same-origin",
3323
+ headers: { "Content-Type": "application/json" },
3324
+ body: JSON.stringify({
3325
+ handle: e.formHandle,
3326
+ siteId: e.siteId,
3327
+ session: t
3328
+ })
3329
+ });
3330
+ },
3331
+ async setPage({ definition: t, session: n, values: r, currentPageId: i, targetPageId: a }) {
3332
+ let o = J(e.endpoint, "/actions/formie/client/forms/page"), s = await I(t, r);
3333
+ return Y(o, {
3334
+ method: "POST",
3335
+ credentials: e.credentials ?? "same-origin",
3336
+ headers: { "Content-Type": "application/json" },
3337
+ body: JSON.stringify({
3338
+ handle: e.formHandle,
3339
+ siteId: e.siteId,
3340
+ currentPageId: i,
3341
+ targetPageId: a,
3342
+ session: n,
3343
+ values: s
3344
+ })
3345
+ });
3346
+ }
3347
+ };
3348
+ }
3349
+ //#endregion
3350
+ //#region src/graphql.ts
3351
+ var Z = "\n id\n currentPageId\n tokens\n continuation\n", Q = `
3352
+ success
3353
+ submissionUid
3354
+ currentPageId
3355
+ nextPageId
3356
+ previousPageId
3357
+ isFinalPage
3358
+ errors
3359
+ messages
3360
+ session {
3361
+ ${Z}
3362
+ }
3363
+ `;
3364
+ function De(e) {
3365
+ if (e.startsWith("http://") || e.startsWith("https://")) return e;
3366
+ let t = e.trim();
3367
+ return !t || t === "/" ? "/api" : t;
3368
+ }
3369
+ async function $(e, t, n) {
3370
+ let r = await fetch(De(e.endpoint), {
3371
+ method: "POST",
3372
+ credentials: e.credentials ?? "same-origin",
3373
+ headers: {
3374
+ "Content-Type": "application/json",
3375
+ Accept: "application/json"
3376
+ },
3377
+ body: JSON.stringify({
3378
+ query: t,
3379
+ variables: n
3380
+ })
3381
+ });
3382
+ if (!r.ok) throw Error(`Request failed with status ${r.status}.`);
3383
+ let i = await r.json();
3384
+ if (i.errors?.length) throw Error(i.errors[0]?.message || "GraphQL returned an error.");
3385
+ if (!i.data) throw Error("GraphQL returned no data.");
3386
+ return i.data;
3387
+ }
3388
+ async function Oe(e) {
3389
+ let t = await $(e, `
3390
+ query ClientForm($handle: String!, $siteId: Int) {
3391
+ formieClientForm(handle: $handle, siteId: $siteId) {
3392
+ schemaVersion
3393
+ definition
3394
+ session {
3395
+ ${Z}
3396
+ }
3397
+ }
3398
+ }
3399
+ `, {
3400
+ handle: e.formHandle,
3401
+ siteId: e.siteId
3402
+ });
3403
+ if (!t.formieClientForm) throw Error("No client form definition was returned.");
3404
+ return t.formieClientForm;
3405
+ }
3406
+ function ke(e) {
3407
+ return {
3408
+ async submit({ definition: t, session: n, values: r, action: i }) {
3409
+ let a = await I(t, r), o = await $(e, `
3410
+ mutation SubmitFormieClientForm(
3411
+ $input: FormieClientSubmitInput!
3412
+ ) {
3413
+ submitFormieClientForm(input: $input) {
3414
+ ${Q}
3415
+ }
3416
+ }
3417
+ `, { input: {
3418
+ handle: e.formHandle,
3419
+ siteId: e.siteId,
3420
+ action: i,
3421
+ session: n,
3422
+ values: a
3423
+ } });
3424
+ if (!o.submitFormieClientForm) throw Error("No client submit result was returned.");
3425
+ return o.submitFormieClientForm;
3426
+ },
3427
+ async refreshSession({ session: t }) {
3428
+ let n = await $(e, `
3429
+ mutation RefreshFormieClientSession(
3430
+ $input: FormieClientSessionRefreshInput!
3431
+ ) {
3432
+ refreshFormieClientSession(input: $input) {
3433
+ ${Z}
3434
+ }
3435
+ }
3436
+ `, { input: {
3437
+ handle: e.formHandle,
3438
+ siteId: e.siteId,
3439
+ session: t
3440
+ } });
3441
+ if (!n.refreshFormieClientSession) throw Error("No client session was returned.");
3442
+ return n.refreshFormieClientSession;
3443
+ },
3444
+ async setPage({ definition: t, session: n, values: r, currentPageId: i, targetPageId: a }) {
3445
+ let o = await I(t, r), s = await $(e, `
3446
+ mutation SetFormieClientPage(
3447
+ $input: FormieClientSetPageInput!
3448
+ ) {
3449
+ setFormieClientPage(input: $input) {
3450
+ ${Z}
3451
+ }
3452
+ }
3453
+ `, { input: {
3454
+ handle: e.formHandle,
3455
+ siteId: e.siteId,
3456
+ currentPageId: i,
3457
+ targetPageId: a,
3458
+ session: n,
3459
+ values: o
3460
+ } });
3461
+ if (!s.setFormieClientPage) throw Error("No client page session was returned.");
3462
+ return s.setFormieClientPage;
3463
+ }
3464
+ };
3465
+ }
3466
+ //#endregion
3467
+ //#region src/text.ts
3468
+ var Ae = (() => {
3469
+ let e = Intl.Segmenter;
3470
+ return e ? new e(void 0, { granularity: "grapheme" }) : null;
3471
+ })(), je = /[\p{L}\p{N}\p{M}]+(?:['’._-][\p{L}\p{N}\p{M}]+)*/gu;
3472
+ function Me(e) {
3473
+ return typeof DOMParser < "u" ? new DOMParser().parseFromString(e, "text/html").body.textContent || "" : e.replace(/<[^>]*>/g, " ");
3474
+ }
3475
+ function Ne(e) {
3476
+ return Me(e);
3477
+ }
3478
+ function Pe(e) {
3479
+ return Ne(e).replace(/[\s\t\n\r]+/g, " ").trim();
3480
+ }
3481
+ function Fe(e) {
3482
+ return Ae ? Array.from(Ae.segment(e)).length : Array.from(e).length;
3483
+ }
3484
+ function Ie(e) {
3485
+ return e.match(je)?.length || 0;
3486
+ }
3487
+ function Le(e) {
3488
+ let t = Ne(e), n = Pe(e);
3489
+ return {
3490
+ graphemeCount: Fe(t),
3491
+ wordCount: Ie(n)
3492
+ };
3493
+ }
3494
+ //#endregion
3495
+ export { xe as FRONTEND_CLIENT_EVENT_NAMES, y as allFields, Te as coerceCalculationVariables, k as compositePartDefinitions, Fe as countGraphemes, be as createFrontendFormInstance, ke as createGraphqlFrontendTransport, N as createRepeaterRowValue, X as createRestFrontendTransport, M as defaultValueForField, q as evaluateCalculationExpression, h as evaluateConditionDefinition, P as fieldValueAsStrings, S as fieldValueContract, C as fieldValueStructure, g as finalizeConditionEvaluation, x as findFieldByHandle, b as findFieldById, G as formatCalculationValue, Ce as getCalculationFormula, we as getCalculationVariableEntries, Le as getTextLimitMetrics, Ie as getWordCount, ne as isBooleanField, w as isCompositeField, O as isEmailField, E as isFileField, te as isKnownFrontendFieldType, D as isMultiValueField, re as isNumericField, T as isRepeatableField, Ee as loadFrontendEnvelope, Oe as loadGraphqlFrontendEnvelope, Pe as normalizeText, K as readCalculationVariableValue, j as repeaterFieldDefinitions, A as repeaterRowDefinitions, ee as serializeFieldValues, I as serializeTransportFieldValues };