@golemui/core 0.0.2 → 0.12.1

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/index.js CHANGED
@@ -1,15 +1,39 @@
1
- import { BehaviorSubject as Dr, distinctUntilChanged as w, pipe as D, map as I, filter as ae, startWith as kr, Subject as Fr } from "rxjs";
2
- var Tr = class {
1
+ import { BehaviorSubject as zr, distinctUntilChanged as D, Subject as Jr, pipe as T, map as w, filter as Ee, startWith as Qr, combineLatest as qr } from "rxjs";
2
+ const X = class X {
3
+ constructor() {
4
+ this.widgetLoaders = {}, this._ready = !1;
5
+ }
6
+ /**
7
+ * When the registry has been initialized by calling `setWidgetLoaders`
8
+ */
9
+ get ready() {
10
+ return this._ready;
11
+ }
12
+ setWidgetLoaders(r) {
13
+ this.widgetLoaders = r, this._ready = !0;
14
+ }
15
+ async loadWidget(r) {
16
+ const t = this.widgetLoaders[r];
17
+ if (!X.sharedCache.has(t)) {
18
+ const n = t().catch((o) => (X.sharedCache.delete(t), Promise.reject(o)));
19
+ X.sharedCache.set(t, n);
20
+ }
21
+ return X.sharedCache.get(t);
22
+ }
23
+ };
24
+ X.sharedCache = /* @__PURE__ */ new Map();
25
+ let Re = X;
26
+ var Yr = class {
3
27
  constructor(e) {
4
28
  this.value = e;
5
29
  }
6
30
  map(e) {
7
- return k(e(this.value));
31
+ return R(e(this.value));
8
32
  }
9
33
  isOk() {
10
34
  return !0;
11
35
  }
12
- }, _r = class {
36
+ }, Zr = class {
13
37
  constructor(e) {
14
38
  this.error = e;
15
39
  }
@@ -20,13 +44,13 @@ var Tr = class {
20
44
  return !1;
21
45
  }
22
46
  };
23
- function k(e) {
24
- return new Tr(e);
47
+ function R(e) {
48
+ return new Yr(e);
25
49
  }
26
50
  function v(e) {
27
- return new _r(e);
51
+ return new Zr(e);
28
52
  }
29
- var C = class we {
53
+ var W = class ke {
30
54
  constructor(r) {
31
55
  this.decodeFn = r, this["~standard"] = { version: 1, vendor: "ts.data.json", validate: (t) => {
32
56
  let n = this.decode(t);
@@ -48,191 +72,192 @@ var C = class we {
48
72
  });
49
73
  }
50
74
  map(r) {
51
- return new we((t) => {
75
+ return new ke((t) => {
52
76
  let n = this.decodeFn(t);
53
- return n.isOk() ? k(r(n.value)) : v(n.error);
77
+ return n.isOk() ? R(r(n.value)) : v(n.error);
54
78
  });
55
79
  }
56
80
  flatMap(r) {
57
- return new we((t) => {
81
+ return new ke((t) => {
58
82
  let n = this.decodeFn(t);
59
83
  return n.isOk() ? r(n.value).decode(t) : v(n.error);
60
84
  });
61
85
  }
62
- }, Wr = (e, r, t) => `<${e}> decoder failed at index "${r}" with error: ${t}`, G = (e, r) => `${JSON.stringify(e)} is not a valid ${r}`;
63
- function We(e, r) {
64
- return new C((t) => {
86
+ }, xr = (e, r, t) => `<${e}> decoder failed at index "${r}" with error: ${t}`, Y = (e, r) => `${JSON.stringify(e)} is not a valid ${r}`;
87
+ function Ve(e, r) {
88
+ return new W((t) => {
65
89
  if (t instanceof Array) {
66
90
  let n = [];
67
91
  for (let o = 0; o < t.length; o++) {
68
- let s = e.decode(t[o]);
69
- if (s.isOk()) n.push(s.value);
70
- else return v(Wr(r, o, s.error));
92
+ let i = e.decode(t[o]);
93
+ if (i.isOk()) n.push(i.value);
94
+ else return v(xr(r, o, i.error));
71
95
  }
72
- return k(n);
73
- } else return v(G(t, "array"));
96
+ return R(n);
97
+ } else return v(Y(t, "array"));
74
98
  });
75
99
  }
76
- function Pr() {
77
- return new C((e) => typeof e == "boolean" ? k(e) : v(G(e, "boolean")));
100
+ function br() {
101
+ return new W((e) => typeof e == "boolean" ? R(e) : v(Y(e, "boolean")));
78
102
  }
79
- function Nr(e) {
80
- return new C((r) => e().decode(r));
103
+ function et(e) {
104
+ return new W((r) => e().decode(r));
81
105
  }
82
- var jr = (e, r) => `${JSON.stringify(e)} is not exactly ${JSON.stringify(r)}`;
83
- function he(e) {
84
- return new C((r) => r === e ? k(e) : v(jr(r, e)));
106
+ var rt = (e, r) => `${JSON.stringify(e)} is not exactly ${JSON.stringify(r)}`;
107
+ function Se(e) {
108
+ return new W((r) => r === e ? R(e) : v(rt(r, e)));
85
109
  }
86
- function pe() {
87
- return new C((e) => typeof e == "number" ? k(e) : v(G(e, "number")));
110
+ function ve() {
111
+ return new W((e) => typeof e == "number" ? R(e) : v(Y(e, "number")));
88
112
  }
89
- var Lr = (e, r, t) => `<${e}> decoder failed at key "${r}" with error: ${t}`;
90
- function b(e, r) {
91
- return new C((t) => {
113
+ var tt = (e, r, t) => `<${e}> decoder failed at key "${r}" with error: ${t}`;
114
+ function oe(e, r) {
115
+ return new W((t) => {
92
116
  if (t !== null && typeof t == "object") {
93
117
  let n = {};
94
118
  for (let o in e) if (Object.prototype.hasOwnProperty.call(e, o)) {
95
- let s, i = e[o];
96
- if (i instanceof C ? s = i.decode(t[o]) : s = i.decoder.decode(t[i.fromKey]), s.isOk()) n[o] = s.value;
97
- else return v(Lr(r, o, s.error));
119
+ let i, s = e[o];
120
+ if (s instanceof W ? i = s.decode(t[o]) : i = s.decoder.decode(t[s.fromKey]), i.isOk()) n[o] = i.value;
121
+ else return v(tt(r, o, i.error));
98
122
  }
99
- return k(n);
100
- } else return v(G(t, r));
123
+ return R(n);
124
+ } else return v(Y(t, r));
101
125
  });
102
126
  }
103
- var Rr = (e, r) => `<${e}> decoder failed because ${JSON.stringify(r)} can't be decoded with any of the provided oneOf decoders`;
104
- function J(e, r) {
105
- return new C((t) => {
127
+ var nt = (e, r) => `<${e}> decoder failed because ${JSON.stringify(r)} can't be decoded with any of the provided oneOf decoders`;
128
+ function Z(e, r) {
129
+ return new W((t) => {
106
130
  for (let n = 0; n < e.length; n++) {
107
131
  let o = e[n].decode(t);
108
132
  if (o.isOk()) return o;
109
133
  }
110
- return v(Rr(r, t));
134
+ return v(nt(r, t));
111
135
  });
112
136
  }
113
- function m(e) {
114
- return new C((r) => r === void 0 ? k(void 0) : e.decode(r));
137
+ function $(e) {
138
+ return new W((r) => r === void 0 ? R(void 0) : e.decode(r));
115
139
  }
116
- var Ur = (e, r, t) => `<${e}> record decoder failed at key "${r}" with error: ${t}`;
117
- function Vr(e, r) {
118
- return new C((t) => {
140
+ var ot = (e, r, t) => `<${e}> record decoder failed at key "${r}" with error: ${t}`;
141
+ function it(e, r) {
142
+ return new W((t) => {
119
143
  if (t !== null && typeof t == "object") {
120
144
  let n = {};
121
145
  for (let o in t) if (Object.prototype.hasOwnProperty.call(t, o)) {
122
- let s = e.decode(t[o]);
123
- if (s.isOk()) n[o] = s.value;
124
- else return v(Ur(r, o, s.error));
146
+ let i = e.decode(t[o]);
147
+ if (i.isOk()) n[o] = i.value;
148
+ else return v(ot(r, o, i.error));
125
149
  }
126
- return k(n);
127
- } else return v(G(t, r));
150
+ return R(n);
151
+ } else return v(Y(t, r));
128
152
  });
129
153
  }
130
- function O() {
131
- return new C((e) => typeof e == "string" ? k(e) : v(G(e, "string")));
154
+ function I() {
155
+ return new W((e) => typeof e == "string" ? R(e) : v(Y(e, "string")));
132
156
  }
133
- function R() {
134
- return new C((e) => k(e));
157
+ function J() {
158
+ return new W((e) => R(e));
135
159
  }
136
- function ee(e, r) {
137
- return new C((t) => {
160
+ function ie(e, r) {
161
+ return new W((t) => {
138
162
  if (typeof t != "object" || t === null)
139
163
  return v(`<${r}> failed. Expected object literal, got "${typeof t}"`);
140
164
  const n = {};
141
- for (const [o, s] of Object.entries(e)) {
142
- const i = s.decoder.decode(t[o]);
143
- if (!i.isOk())
144
- return v(`<${r}> failed at "${o}" with ${i.error}`);
145
- if (n[o] = i.value, s.suffixed) {
146
- for (const [d, c] of Object.entries(t))
147
- if (d.startsWith(o + ".")) {
148
- const f = s.decoder.decode(c);
149
- if (!f.isOk())
150
- return v(`<${r}> failed at "${d}" with ${f.error}`);
151
- n[d] = f.value;
165
+ for (const [o, i] of Object.entries(e)) {
166
+ const s = i.decoder.decode(t[o]);
167
+ if (!s.isOk())
168
+ return v(`<${r}> failed at "${o}" with ${s.error}`);
169
+ if (n[o] = s.value, i.suffixed) {
170
+ for (const [u, c] of Object.entries(t))
171
+ if (u.startsWith(o + ".")) {
172
+ const h = i.decoder.decode(c);
173
+ if (!h.isOk())
174
+ return v(`<${r}> failed at "${u}" with ${h.error}`);
175
+ n[u] = h.value;
152
176
  }
153
177
  }
154
178
  }
155
- return k(n);
179
+ return R(n);
156
180
  });
157
181
  }
158
- const be = () => crypto.randomUUID().slice(0, 8), wn = (e) => typeof e != "function" && e.kind === "display", De = (e) => typeof e != "function" && e.kind === "action", _ = (e) => typeof e != "function" && e.kind === "input", er = (e) => typeof e != "function" && e.kind === "layout", Pe = (e) => typeof e == "function", Hr = b({ in: We(O(), "In[]") }, "In"), Ne = b({ when: O() }, "When"), ge = J([Hr, Ne], "In | When"), Br = b({ from: We(O(), "From[]") }, "From"), ye = J([Br, Ne], "Exclude"), ke = J([Pr(), Ne], "Bool | When"), Gr = new C(
182
+ const hr = () => crypto.randomUUID().slice(0, 8), st = (e) => typeof e != "function" && e.kind === "display", re = (e) => typeof e != "function" && e.kind === "action", P = (e) => typeof e != "function" && e.kind === "input", _e = (e) => typeof e != "function" && e.kind === "layout", se = (e) => typeof e == "function", dt = oe({ in: Ve(I(), "In[]") }, "In"), Ue = oe({ when: I() }, "When"), Ie = Z([dt, Ue], "In | When"), ut = oe({ from: Ve(I(), "From[]") }, "From"), Oe = Z([ut, Ue], "Exclude"), Ne = Z([br(), Ue], "Bool | When"), ct = new W(
159
183
  (e) => {
160
184
  const r = typeof e;
161
- return r === "function" ? k(e) : v(`Expected a function, got '${r}'`);
185
+ return r === "function" ? R(e) : v(`Expected a function, got '${r}'`);
162
186
  }
163
- ), L = (e) => J([e, Gr], ""), je = ee(
187
+ ), B = (e) => Z([e, ct], ""), Be = ie(
164
188
  {
165
- load: { suffixed: !0, decoder: L(m(O())) },
166
- click: { suffixed: !0, decoder: L(m(O())) },
167
- change: { suffixed: !0, decoder: L(m(O())) },
168
- filter: { suffixed: !0, decoder: L(m(O())) }
189
+ load: { suffixed: !0, decoder: B($(I())) },
190
+ click: { suffixed: !0, decoder: B($(I())) },
191
+ change: { suffixed: !0, decoder: B($(I())) },
192
+ filter: { suffixed: !0, decoder: B($(I())) },
193
+ blur: { suffixed: !0, decoder: B($(I())) }
169
194
  },
170
195
  "On"
171
- ), Jr = b(
196
+ ), lt = oe(
172
197
  {
173
- key: O(),
174
- default: m(O()),
175
- params: R()
198
+ key: I(),
199
+ default: $(I()),
200
+ params: J()
176
201
  },
177
202
  "TranslationConfig"
178
- ), rr = J(
179
- [O(), Jr],
203
+ ), pr = Z(
204
+ [I(), lt],
180
205
  "Localizable"
181
- ), me = m(O()).map((e) => e || be()), Kr = ee(
206
+ ), we = $(I()).map((e) => e || hr()), ft = ie(
182
207
  {
183
- kind: { decoder: he("display") },
184
- uid: { decoder: me },
185
- type: { decoder: O() },
186
- size: { suffixed: !0, decoder: m(pe()) },
187
- include: { decoder: m(ge) },
188
- exclude: { decoder: m(ye) },
189
- props: { decoder: m(R()) }
208
+ kind: { decoder: Se("display") },
209
+ uid: { decoder: we },
210
+ type: { decoder: I() },
211
+ size: { suffixed: !0, decoder: $(ve()) },
212
+ include: { decoder: $(Ie) },
213
+ exclude: { decoder: $(Oe) },
214
+ props: { decoder: $(J()) }
190
215
  },
191
216
  "DisplayWidget"
192
- ), Mr = ee(
217
+ ), at = ie(
193
218
  {
194
- kind: { decoder: he("action") },
195
- uid: { decoder: me },
196
- type: { decoder: O() },
197
- size: { suffixed: !0, decoder: m(pe()) },
198
- include: { decoder: m(ge) },
199
- exclude: { decoder: m(ye) },
200
- label: { suffixed: !0, decoder: L(rr) },
201
- disabled: { suffixed: !0, decoder: m(ke) },
202
- on: { decoder: m(je) },
203
- props: { decoder: m(R()) }
219
+ kind: { decoder: Se("action") },
220
+ uid: { decoder: we },
221
+ type: { decoder: I() },
222
+ size: { suffixed: !0, decoder: $(ve()) },
223
+ include: { decoder: $(Ie) },
224
+ exclude: { decoder: $(Oe) },
225
+ label: { suffixed: !0, decoder: B(pr) },
226
+ disabled: { suffixed: !0, decoder: $(Ne) },
227
+ on: { decoder: $(Be) },
228
+ props: { decoder: $(J()) }
204
229
  },
205
230
  "ActionWidget"
206
- ), Xr = new C(
231
+ ), ht = new W(
207
232
  (e) => {
208
233
  const r = typeof e;
209
234
  if (r === "function") {
210
235
  const t = e, n = t(void 0);
211
- return t.uid = n.uid || be(), t.type = n.type, t.path = n.path, k(t);
236
+ return t.uid = n.uid || hr(), t.type = n.type, t.path = n.path, R(t);
212
237
  } else
213
238
  return v(`Expected a function, got '${r}'`);
214
239
  }
215
- ), Qr = ee(
240
+ ), pt = ie(
216
241
  {
217
- kind: { decoder: he("input") },
218
- uid: { decoder: me },
219
- type: { decoder: O() },
220
- size: { suffixed: !0, decoder: m(pe()) },
221
- include: { decoder: m(ge) },
222
- exclude: { decoder: m(ye) },
223
- disabled: { suffixed: !0, decoder: m(ke) },
224
- readonly: { suffixed: !0, decoder: m(ke) },
225
- on: { decoder: m(je) },
226
- props: { decoder: m(R()) },
242
+ kind: { decoder: Se("input") },
243
+ uid: { decoder: we },
244
+ type: { decoder: I() },
245
+ size: { suffixed: !0, decoder: $(ve()) },
246
+ include: { decoder: $(Ie) },
247
+ exclude: { decoder: $(Oe) },
248
+ disabled: { suffixed: !0, decoder: $(Ne) },
249
+ readonly: { suffixed: !0, decoder: $(Ne) },
250
+ on: { decoder: $(Be) },
251
+ props: { decoder: $(J()) },
227
252
  label: {
228
253
  suffixed: !0,
229
- decoder: L(m(rr))
254
+ decoder: B($(pr))
230
255
  },
231
- path: { decoder: O() },
232
- defaultValue: { decoder: m(R()) },
256
+ path: { decoder: I() },
257
+ defaultValue: { decoder: $(J()) },
233
258
  validator: {
234
259
  suffixed: !0,
235
- decoder: L(m(R()))
260
+ decoder: B($(J()))
236
261
  }
237
262
  },
238
263
  "InputWidget"
@@ -240,35 +265,35 @@ const be = () => crypto.randomUUID().slice(0, 8), wn = (e) => typeof e != "funct
240
265
  const r = { ...e };
241
266
  if (e.uid || (r.uid = `${e.path}-${e.type}`), e.type === "repeater") {
242
267
  const t = e.props;
243
- t.template = Le.parse(t.template);
268
+ t.template = He.parse(t.template);
244
269
  }
245
270
  return r;
246
- }), xr = Nr(
247
- () => J(
271
+ }), gt = et(
272
+ () => Z(
248
273
  [
249
- Xr,
250
- Qr,
251
- Le,
252
- Kr,
253
- Mr
274
+ ht,
275
+ pt,
276
+ He,
277
+ ft,
278
+ at
254
279
  ],
255
280
  "FormWidget"
256
281
  )
257
- ), Le = ee(
282
+ ), He = ie(
258
283
  {
259
- kind: { decoder: he("layout") },
260
- uid: { decoder: me },
261
- type: { decoder: O() },
262
- size: { suffixed: !0, decoder: m(pe()) },
263
- include: { decoder: m(ge) },
264
- exclude: { decoder: m(ye) },
265
- props: { decoder: m(R()) },
266
- on: { decoder: m(je) },
267
- children: { decoder: We(xr, "FormWidget[]") }
284
+ kind: { decoder: Se("layout") },
285
+ uid: { decoder: we },
286
+ type: { decoder: I() },
287
+ size: { suffixed: !0, decoder: $(ve()) },
288
+ include: { decoder: $(Ie) },
289
+ exclude: { decoder: $(Oe) },
290
+ props: { decoder: $(J()) },
291
+ on: { decoder: $(Be) },
292
+ children: { decoder: Ve(gt, "FormWidget[]") }
268
293
  },
269
294
  "LayoutWidget"
270
295
  );
271
- function Dn(e) {
296
+ function So(e) {
272
297
  return {
273
298
  ...e,
274
299
  form: {
@@ -279,15 +304,15 @@ function Dn(e) {
279
304
  }
280
305
  };
281
306
  }
282
- const tr = b(
307
+ const gr = oe(
283
308
  {
284
- states: m(Vr(O(), "states")),
285
- form: Le
309
+ states: $(it(I(), "states")),
310
+ form: He
286
311
  },
287
312
  "FormDef"
288
- ), nr = (e) => ({
313
+ ), mr = (e) => ({
289
314
  formName: "",
290
- formDef: tr.parse({
315
+ formDef: gr.parse({
291
316
  form: {
292
317
  kind: "layout",
293
318
  type: "flex",
@@ -303,101 +328,205 @@ const tr = b(
303
328
  widgetFlags: {},
304
329
  widgetPropOverrides: {},
305
330
  data: {},
331
+ meta: {},
306
332
  formHealth: { status: "ok" },
307
333
  touched: !1,
308
334
  lang: e
309
- }), Zr = (e) => {
335
+ }), mt = (e) => {
310
336
  throw new Error(`Unhandled case: ${JSON.stringify(e)}`);
311
337
  };
312
- function W(e, ...r) {
338
+ function L(e, ...r) {
313
339
  return r.reduce((t, n) => n(t), e);
314
340
  }
315
- function kn(...e) {
341
+ function vo(...e) {
316
342
  return (r) => e.reduceRight((t, n) => n(t), r);
317
343
  }
318
- function Yr(e, r) {
344
+ function yt(e, r) {
319
345
  return {
320
346
  ...e,
321
347
  calculatedWidgets: {
322
348
  ...e.calculatedWidgets,
323
349
  [r.payload.widget.uid]: {
324
350
  source: r.payload.widget,
325
- current: {},
326
- previous: {}
351
+ current: {}
327
352
  }
328
353
  }
329
354
  };
330
355
  }
331
- const Re = 32;
332
- let a, p, A = (e) => (a = 0, p = e, A.newline = !1, e = $(), p[a] ? U() : e || ""), U = (e = "Unexpected token", r = a, t = p.slice(0, r).split(`
333
- `), n = t.pop(), o = p.slice(Math.max(0, r - 40), r), s = "̭", i = (p[r] || " ") + s, d = p.slice(r + 1, r + 20)) => {
356
+ const ae = {
357
+ calculateCurrentStateError: 10,
358
+ initializeParseError: 20,
359
+ initializeUidCollisionError: 21,
360
+ initializeUnknownError: 22,
361
+ widgetCouldNotBeLoaded: 30
362
+ }, N = (e, r) => {
363
+ if (e === void 0)
364
+ throw new Error("obj is undefined");
365
+ return r.split(".").reduce((t, n) => t === void 0 || n === "" ? t : Array.isArray(t) ? t[parseInt(n, 10)] : t[n], e);
366
+ }, Ge = (e, r, t) => {
367
+ if (e === null)
368
+ throw new Error("object is null");
369
+ if (e === void 0)
370
+ throw new Error("object is undefined");
371
+ if (r === "")
372
+ throw new Error("path cannot be empty");
373
+ const n = r.split(".");
374
+ let o = e;
375
+ for (let s = 0; s < n.length - 1; s++) {
376
+ const u = n[s], c = n[s + 1];
377
+ (o[u] == null || typeof o[u] != "object") && (o[u] = $t(c) ? [] : {}), o = o[u];
378
+ }
379
+ const i = n[n.length - 1];
380
+ return o[i] = t, e;
381
+ };
382
+ function $t(e) {
383
+ const r = Number(e);
384
+ return Number.isInteger(r) && r >= 0 && r.toString() === e;
385
+ }
386
+ const ce = (e, r) => (delete e[r], e);
387
+ function sr(e) {
388
+ if (e === null || typeof e != "object")
389
+ return e;
390
+ if (Array.isArray(e))
391
+ return e.map((t) => sr(t));
392
+ const r = {};
393
+ for (const t of Object.keys(e))
394
+ r[t] = sr(e[t]);
395
+ return r;
396
+ }
397
+ const F = {
398
+ FORM: "$form",
399
+ META: "$meta",
400
+ ERRORS: "$errors",
401
+ FORM_IS_INVALID: "$formIsInvalid"
402
+ }, At = (e) => typeof e == "string" && !e.includes(" ") && (e.startsWith(`${F.FORM}.`) || e.startsWith(`${F.META}.`) || e.startsWith(`${F.ERRORS}.`) || e === F.FORM_IS_INVALID), Et = [F.FORM, F.META, F.ERRORS].map((e) => e.replace("$", "\\$")).join("|"), St = new RegExp(
403
+ `\\{\\{(?:(?<scope>${Et})\\.(?<path>[^}]+)|(?<isInvalid>\\${F.FORM_IS_INVALID}))\\}\\}`,
404
+ "g"
405
+ ), vt = (e, r) => typeof e != "string" || !e.includes("{{$") ? e : e.replace(St, (t, ...n) => {
406
+ const o = n[n.length - 1], { scope: i, path: s, isInvalid: u } = o;
407
+ try {
408
+ if (u === F.FORM_IS_INVALID)
409
+ return r.resolveFormIsInvalid();
410
+ if (i && s)
411
+ switch (i) {
412
+ case F.FORM:
413
+ return r.resolveFormPath(s);
414
+ case F.META:
415
+ return r.resolveMetaPath(s);
416
+ case F.ERRORS:
417
+ return r.resolveErrorsPath(s);
418
+ default:
419
+ return t;
420
+ }
421
+ } catch (c) {
422
+ return console.error(`Error resolving Expression: '${e}'`, c), t;
423
+ }
424
+ return t;
425
+ }), It = (e, r) => {
426
+ const t = `${F.FORM}.`;
427
+ if (e.startsWith(t))
428
+ return r.resolveFormPath(e.replace(t, ""));
429
+ const n = `${F.META}.`;
430
+ if (e.startsWith(n))
431
+ return r.resolveMetaPath(e.replace(n, ""));
432
+ const o = `${F.ERRORS}.`;
433
+ if (e.startsWith(o))
434
+ return r.resolveErrorsPath(e.replace(o, ""));
435
+ if (e === F.FORM_IS_INVALID)
436
+ return r.resolveFormIsInvalid();
437
+ };
438
+ function Ke(e) {
439
+ return e.flatMap((r) => [
440
+ r,
441
+ ..._e(r) ? Ke(r.children) : []
442
+ ]);
443
+ }
444
+ function Xe(e) {
445
+ return Object.entries(e.validations).reduce(
446
+ (t, [n, o]) => (o !== null && (t.$formIsInvalid = !0, Ge(t.$errors, n, [...o])), t),
447
+ { $formIsInvalid: !1, $errors: {} }
448
+ );
449
+ }
450
+ const ze = 32;
451
+ let Le, a, p, m = (e) => (a = 0, p = e, m.newline = !1, e = E(), p[a] ? Q() : e || ""), Q = (e = "Unexpected token", r = a, t = p.slice(0, r).split(`
452
+ `), n = t.pop(), o = p.slice(Math.max(0, r - 40), r), i = "̭", s = (p[r] || " ") + i, u = p.slice(r + 1, r + 20)) => {
334
453
  throw SyntaxError(`${e} at ${t.length + 1}:${n.length + 1}
335
454
  ${p[r - 41] !== `
336
- `, "" + o}${i}${d}`);
337
- }, or = (e, r = a) => (Array.isArray(e) && (e.loc = r), e), K = (e, r = a, t) => {
455
+ `, "" + o}${s}${u}`);
456
+ }, yr = (e, r = a) => (Array.isArray(e) && (e.loc = r), e), x = (e, r = a, t) => {
338
457
  for (; t = e(p.charCodeAt(a)); ) a += t;
339
458
  return p.slice(r, a);
340
- }, E = (e = 1) => p[a += e], Fe = (e) => a = e, $ = (e = 0, r) => {
341
- let t, n, o, s, i;
342
- for (r && A.asi && (A.newline = !1); (t = A.space()) && (i = A.newline, 1) && t !== r && (o = ((s = T[t]) && s(n, e)) ?? (n && i && A.asi?.(n, e, $)) ?? (!n && K(A.id))); ) n = o;
343
- return r && (t == r ? a++ : U("Unclosed " + String.fromCharCode(r - (r > 42 ? 2 : 1)))), n;
344
- }, Y = A.space = (e, r = a) => {
345
- for (; (e = p.charCodeAt(a)) <= Re; )
346
- A.asi && e === 10 && (A.newline = !0), a++;
459
+ }, O = (e = 1) => p[a += e], Me = (e) => a = e, E = (e = 0, r) => {
460
+ let t, n, o, i, s;
461
+ for (r && m.asi && (m.newline = !1); (t = m.space()) && (s = m.newline, 1) && t !== r && (o = // ASI before [ on new line (access handler would consume it; lineBreak distinguishes real \n from synthetic } flag)
462
+ (n && t === 91 && Le && m.asi?.(n, e, E) || null) ?? ((i = _[t]) && i(n, e)) ?? (n && s && m.asi?.(n, e, E)) ?? (!n && x(m.id))); ) n = o;
463
+ return r && (t == r ? (a++, r === 125 && m.asi && (m.newline = !0)) : Q("Unclosed " + String.fromCharCode(r - (r > 42 ? 2 : 1)))), n;
464
+ }, G = (e, r = a) => {
465
+ for (Le = !1; (e = p.charCodeAt(a)) <= ze; )
466
+ m.asi && e === 10 && (m.newline = Le = !0), a++;
347
467
  return e;
348
- }, qr = (e = a) => {
349
- for (; p.charCodeAt(e) <= Re; ) e++;
468
+ }, Ot = (e = a) => {
469
+ for (; p.charCodeAt(e) <= ze; ) e++;
350
470
  return p.charCodeAt(e);
351
471
  };
352
- A.id = (e) => e >= 48 && e <= 57 || e >= 65 && e <= 90 || e >= 97 && e <= 122 || e == 36 || e == 95 || e >= 192 && e != 215 && e != 247;
353
- let zr = (e, r = e.length) => p.substr(a, r) === e && !A.id(p.charCodeAt(a + r)), T = [], Qe = {}, F = (e, r = Re, t, n = e.charCodeAt(0), o = e.length, s = T[n], i = e.toUpperCase() !== e, d, c) => (r = Qe[e] = !s && Qe[e] || r, T[n] = (f, y, h, S = a) => (d = h, (h ? e == h : (o < 2 || e.charCodeAt(1) === p.charCodeAt(a + 1) && (o < 3 || p.substr(a, o) == e)) && (!i || !A.id(p.charCodeAt(a + o))) && (d = h = e)) && y < r && (a += o, (c = t(f)) ? or(c, S) : (a = S, d = 0, !i && !s && U()), c) || s?.(f, y, d))), g = (e, r, t = !1) => F(e, r, (n) => n && /* @__PURE__ */ ((o) => o && [e, n, o])($(r - (t ? 0.5 : 0)))), N = (e, r, t) => F(e, r, (n) => !n && (n = $(r - 0.5)) && [e, n]), re = (e, r) => F(e, 200, (t) => !t && [, r]), sr = (e, r, t) => F(
472
+ m.id = (e) => e >= 48 && e <= 57 || e >= 65 && e <= 90 || e >= 97 && e <= 122 || e == 36 || e == 95 || e >= 192 && e != 215 && e != 247;
473
+ let wt = (e, r = e.length) => p.substr(a, r) === e && !m.id(p.charCodeAt(a + r)), _ = [], dr = {}, k = (e, r = ze, t, n = e.charCodeAt(0), o = e.length, i = _[n], s = e.toUpperCase() !== e, u, c) => (r = dr[e] = !i && dr[e] || r, _[n] = (h, A, g, f = a) => (u = g, (g ? e == g : (o < 2 || e.charCodeAt(1) === p.charCodeAt(a + 1) && (o < 3 || p.substr(a, o) == e)) && (!s || !m.id(p.charCodeAt(a + o))) && (u = g = e)) && A < r && (a += o, (c = t(h)) ? yr(c, f) : (a = f, u = 0, !s && !i && !h && Q()), c) || i?.(h, A, u))), y = (e, r, t = !1) => k(e, r, (n) => n && /* @__PURE__ */ ((o) => o && [e, n, o])(E(r - (t ? 0.5 : 0)))), K = (e, r, t) => k(e, r, (n) => !n && (n = E(r - 0.5)) && [e, n]), de = (e, r) => k(e, 200, (t) => !t && [, r]), $r = (e, r, t) => k(
354
474
  e,
355
475
  r,
356
- (n, o) => (o = $(r - (t ? 0.5 : 0)), n?.[0] !== e && (n = [e, n || null]), o?.[0] === e ? n.push(...o.slice(1)) : n.push(o || null), n)
357
- ), Ue = (e, r) => F(e[0], r, (t) => !t && [e, $(0, e.charCodeAt(1)) || null]), ir = (e, r) => F(e[0], r, (t) => t && [e, t, $(0, e.charCodeAt(1)) || null]);
358
- const Te = {}, l = (e, r, t = Te[e]) => Te[e] = (...n) => r(...n) || t?.(...n), u = (e) => Array.isArray(e) ? e[0] == null ? /* @__PURE__ */ ((r) => () => r)(e[1]) : (
476
+ (n, o) => (o = E(r - (t ? 0.5 : 0)), n?.[0] !== e && (n = [e, n || null]), o?.[0] === e ? n.push(...o.slice(1)) : n.push(o || null), n)
477
+ ), Je = (e, r) => k(e[0], r, (t) => !t && [e, E(0, e.charCodeAt(1)) || null]), Ar = (e, r) => k(e[0], r, (t) => t && [e, t, E(0, e.charCodeAt(1)) || null]), ue = (e, r, t, n = e.charCodeAt(0), o = e.length, i = _[n], s) => _[n] = (u, c, h, A = a) => !u && (h ? e == h : (o < 2 || p.substr(a, o) == e) && (h = e)) && c < r && !m.id(p.charCodeAt(a + o)) && (!m.prop || m.prop(a + o)) && (Me(a + o), (s = t()) ? yr(s, A) : Me(A), s) || i?.(u, c, h);
478
+ Object.defineProperty(m, "space", {
479
+ configurable: !0,
480
+ enumerable: !0,
481
+ get: () => G,
482
+ set: (e) => G = e
483
+ });
484
+ const je = {}, l = (e, r, t = je[e]) => je[e] = (...n) => r(...n) || t?.(...n), d = (e) => Array.isArray(e) ? e[0] == null ? /* @__PURE__ */ ((r) => () => r)(e[1]) : (
359
485
  // == catches both undefined and null
360
- Te[e[0]]?.(...e.slice(1)) ?? U(`Unknown operator: ${e[0]}`, e?.loc)
486
+ je[e[0]]?.(...e.slice(1)) ?? Q(`Unknown operator: ${e[0]}`, e?.loc)
361
487
  ) : e === void 0 ? () => {
362
- } : (r) => r?.[e], ue = 46, q = 48, de = 57, br = 69, et = 101, rt = 43, tt = 45, se = 95, nt = 110, ot = 97, st = 102, it = 65, ut = 70, ur = (e) => e.indexOf("_") < 0 ? e : e.replaceAll("_", ""), Ve = (e) => {
363
- let r = ur(K(
488
+ } : (r) => r?.[e], pe = 46, te = 48, ge = 57, Ct = 69, Ft = 101, Dt = 43, Pt = 45, he = 95, Er = 110, Wt = 97, Tt = 102, Rt = 65, kt = 70, Sr = (e) => e.indexOf("_") < 0 ? e : e.replaceAll("_", ""), Qe = (e) => {
489
+ let r = Sr(x(
364
490
  (t) => (
365
491
  // . is decimal only if NOT followed by another . (range operator)
366
- t === ue && p.charCodeAt(a + 1) !== ue || t >= q && t <= de || t === se || ((t === br || t === et) && ((t = p.charCodeAt(a + 1)) >= q && t <= de || t === rt || t === tt) ? 2 : 0)
492
+ t === pe && p.charCodeAt(a + 1) !== pe || t >= te && t <= ge || t === he || ((t === Ct || t === Ft) && ((t = p.charCodeAt(a + 1)) >= te && t <= ge || t === Dt || t === Pt) ? 2 : 0)
367
493
  )
368
494
  ));
369
- return p.charCodeAt(a) === nt ? (E(), [, BigInt(r)]) : (e = +r) != e ? U() : [, e];
370
- }, dt = {
371
- 2: (e) => e === 48 || e === 49 || e === se,
372
- 8: (e) => e >= 48 && e <= 55 || e === se,
373
- 16: (e) => e >= q && e <= de || e >= ot && e <= st || e >= it && e <= ut || e === se
495
+ return p.charCodeAt(a) === Er ? (O(), [, BigInt(r)]) : (e = +r) != e ? Q() : [, e];
496
+ }, _t = {
497
+ 2: (e) => e === 48 || e === 49 || e === he,
498
+ 8: (e) => e >= 48 && e <= 55 || e === he,
499
+ 16: (e) => e >= te && e <= ge || e >= Wt && e <= Tt || e >= Rt && e <= kt || e === he
374
500
  };
375
- A.number = null;
376
- T[ue] = (e) => !e && p.charCodeAt(a + 1) !== ue && Ve();
377
- for (let e = q; e <= de; e++) T[e] = (r) => r ? void 0 : Ve();
378
- T[q] = (e) => {
501
+ m.number = null;
502
+ _[pe] = (e) => !e && p.charCodeAt(a + 1) !== pe && Qe();
503
+ for (let e = te; e <= ge; e++) _[e] = (r) => r ? void 0 : Qe();
504
+ _[te] = (e) => {
379
505
  if (e) return;
380
- const r = A.number;
506
+ const r = m.number;
381
507
  if (r) {
382
508
  for (const [t, n] of Object.entries(r))
383
- if (t[0] === "0" && p[a + 1]?.toLowerCase() === t[1])
384
- return E(2), [, parseInt(ur(K(dt[n])), n)];
509
+ if (t[0] === "0" && p[a + 1]?.toLowerCase() === t[1]) {
510
+ O(2);
511
+ const o = Sr(x(_t[n]));
512
+ return p.charCodeAt(a) === Er ? (O(), [, BigInt("0" + t[1] + o)]) : [, parseInt(o, n)];
513
+ }
385
514
  }
386
- return Ve();
515
+ return Qe();
387
516
  };
388
- const ct = 92, xe = 34, Ze = 39, lt = { n: `
389
- `, r: "\r", t: " ", b: "\b", f: "\f", v: "\v" }, dr = (e) => (r, t, n = "") => {
390
- if (!(r || !A.string?.[String.fromCharCode(e)]))
391
- return E(), K((o) => o - e && (o === ct ? (n += lt[p[a + 1]] || p[a + 1], 2) : (n += p[a], 1))), p[a] === String.fromCharCode(e) ? E() : U("Bad string"), [, n];
517
+ const Nt = 92, ur = 34, cr = 39, Lt = { n: `
518
+ `, r: "\r", t: " ", b: "\b", f: "\f", v: "\v" }, vr = (e) => (r, t, n = "") => {
519
+ if (!(r || !m.string?.[String.fromCharCode(e)]))
520
+ return O(), x((o) => o - e && (o === Nt ? (n += Lt[p[a + 1]] || p[a + 1], 2) : (n += p[a], 1))), p[a] === String.fromCharCode(e) ? O() : Q("Bad string"), [, n];
392
521
  };
393
- T[xe] = dr(xe);
394
- T[Ze] = dr(Ze);
395
- A.string = { '"': !0 };
396
- const ft = 20;
397
- "= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map((e) => g(e, ft, !0));
398
- const cr = (e, r, t, n) => typeof e == "string" ? (o) => r(o, e, o) : e[0] === "." ? (t = u(e[1]), n = e[2], (o) => r(t(o), n, o)) : e[0] === "[]" && e.length === 3 ? (t = u(e[1]), n = u(e[2]), (o) => r(t(o), n(o), o)) : e[0] === "()" && e.length === 2 ? cr(e[1], r) : (() => {
522
+ _[ur] = vr(ur);
523
+ _[cr] = vr(cr);
524
+ m.string = { '"': !0 };
525
+ const Mt = 20;
526
+ "= += -= *= /= %= |= &= ^= >>= <<=".split(" ").map((e) => y(e, Mt, !0));
527
+ const Ir = (e, r, t, n) => typeof e == "string" ? (o) => r(o, e, o) : e[0] === "." ? (t = d(e[1]), n = e[2], (o) => r(t(o), n, o)) : e[0] === "[]" && e.length === 3 ? (t = d(e[1]), n = d(e[2]), (o) => r(t(o), n(o), o)) : e[0] === "()" && e.length === 2 ? Ir(e[1], r) : (() => {
399
528
  throw Error("Invalid assignment target");
400
- })(), Ye = {
529
+ })(), lr = {
401
530
  "=": (e, r, t) => e[r] = t,
402
531
  "+=": (e, r, t) => e[r] += t,
403
532
  "-=": (e, r, t) => e[r] -= t,
@@ -410,715 +539,948 @@ const cr = (e, r, t, n) => typeof e == "string" ? (o) => r(o, e, o) : e[0] === "
410
539
  ">>=": (e, r, t) => e[r] >>= t,
411
540
  "<<=": (e, r, t) => e[r] <<= t
412
541
  };
413
- for (const e in Ye) l(e, (r, t) => (t = u(t), cr(r, (n, o, s) => Ye[e](n, o, t(s)))));
414
- const at = 30, ht = 40, lr = 140;
415
- g("!", lr);
416
- N("!", lr);
417
- g("||", at);
418
- g("&&", ht);
419
- l("!", (e) => (e = u(e), (r) => !e(r)));
420
- l("||", (e, r) => (e = u(e), r = u(r), (t) => e(t) || r(t)));
421
- l("&&", (e, r) => (e = u(e), r = u(r), (t) => e(t) && r(t)));
422
- const pt = 50, gt = 60, yt = 70, fr = 100, mt = 140;
423
- g("|", pt);
424
- g("&", yt);
425
- g("^", gt);
426
- g(">>", fr);
427
- g("<<", fr);
428
- N("~", mt);
429
- l("~", (e) => (e = u(e), (r) => ~e(r)));
430
- l("|", (e, r) => (e = u(e), r = u(r), (t) => e(t) | r(t)));
431
- l("&", (e, r) => (e = u(e), r = u(r), (t) => e(t) & r(t)));
432
- l("^", (e, r) => (e = u(e), r = u(r), (t) => e(t) ^ r(t)));
433
- l(">>", (e, r) => (e = u(e), r = u(r), (t) => e(t) >> r(t)));
434
- l("<<", (e, r) => (e = u(e), r = u(r), (t) => e(t) << r(t)));
435
- const Ae = 90;
436
- g("<", Ae);
437
- g(">", Ae);
438
- g("<=", Ae);
439
- g(">=", Ae);
440
- l(">", (e, r) => (e = u(e), r = u(r), (t) => e(t) > r(t)));
441
- l("<", (e, r) => (e = u(e), r = u(r), (t) => e(t) < r(t)));
442
- l(">=", (e, r) => (e = u(e), r = u(r), (t) => e(t) >= r(t)));
443
- l("<=", (e, r) => (e = u(e), r = u(r), (t) => e(t) <= r(t)));
444
- const ar = 80;
445
- g("==", ar);
446
- g("!=", ar);
447
- l("==", (e, r) => (e = u(e), r = u(r), (t) => e(t) == r(t)));
448
- l("!=", (e, r) => (e = u(e), r = u(r), (t) => e(t) != r(t)));
449
- const hr = 110, He = 120, pr = 140;
450
- g("+", hr);
451
- g("-", hr);
452
- g("*", He);
453
- g("/", He);
454
- g("%", He);
455
- N("+", pr);
456
- N("-", pr);
457
- l("+", (e, r) => r !== void 0 ? (e = u(e), r = u(r), (t) => e(t) + r(t)) : (e = u(e), (t) => +e(t)));
458
- l("-", (e, r) => r !== void 0 ? (e = u(e), r = u(r), (t) => e(t) - r(t)) : (e = u(e), (t) => -e(t)));
459
- l("*", (e, r) => (e = u(e), r = u(r), (t) => e(t) * r(t)));
460
- l("/", (e, r) => (e = u(e), r = u(r), (t) => e(t) / r(t)));
461
- l("%", (e, r) => (e = u(e), r = u(r), (t) => e(t) % r(t)));
462
- const ce = 150;
463
- F("++", ce, (e) => e ? ["++", e, null] : ["++", $(ce - 1)]);
464
- F("--", ce, (e) => e ? ["--", e, null] : ["--", $(ce - 1)]);
465
- const Be = (e, r, t, n) => typeof e == "string" ? (o) => r(o, e) : e[0] === "." ? (t = u(e[1]), n = e[2], (o) => r(t(o), n)) : e[0] === "[]" && e.length === 3 ? (t = u(e[1]), n = u(e[2]), (o) => r(t(o), n(o))) : e[0] === "()" && e.length === 2 ? Be(e[1], r) : (
542
+ for (const e in lr) l(e, (r, t) => (t = d(t), Ir(r, (n, o, i) => lr[e](n, o, t(i)))));
543
+ const jt = 30, Vt = 40, Ut = 140;
544
+ K("!", Ut);
545
+ y("||", jt);
546
+ y("&&", Vt);
547
+ l("!", (e) => (e = d(e), (r) => !e(r)));
548
+ l("||", (e, r) => (e = d(e), r = d(r), (t) => e(t) || r(t)));
549
+ l("&&", (e, r) => (e = d(e), r = d(r), (t) => e(t) && r(t)));
550
+ const Bt = 50, Ht = 60, Gt = 70, Or = 100, Kt = 140;
551
+ y("|", Bt);
552
+ y("&", Gt);
553
+ y("^", Ht);
554
+ y(">>", Or);
555
+ y("<<", Or);
556
+ K("~", Kt);
557
+ l("~", (e) => (e = d(e), (r) => ~e(r)));
558
+ l("|", (e, r) => (e = d(e), r = d(r), (t) => e(t) | r(t)));
559
+ l("&", (e, r) => (e = d(e), r = d(r), (t) => e(t) & r(t)));
560
+ l("^", (e, r) => (e = d(e), r = d(r), (t) => e(t) ^ r(t)));
561
+ l(">>", (e, r) => (e = d(e), r = d(r), (t) => e(t) >> r(t)));
562
+ l("<<", (e, r) => (e = d(e), r = d(r), (t) => e(t) << r(t)));
563
+ const Ce = 90;
564
+ y("<", Ce);
565
+ y(">", Ce);
566
+ y("<=", Ce);
567
+ y(">=", Ce);
568
+ l(">", (e, r) => (e = d(e), r = d(r), (t) => e(t) > r(t)));
569
+ l("<", (e, r) => (e = d(e), r = d(r), (t) => e(t) < r(t)));
570
+ l(">=", (e, r) => (e = d(e), r = d(r), (t) => e(t) >= r(t)));
571
+ l("<=", (e, r) => (e = d(e), r = d(r), (t) => e(t) <= r(t)));
572
+ const wr = 80;
573
+ y("==", wr);
574
+ y("!=", wr);
575
+ l("==", (e, r) => (e = d(e), r = d(r), (t) => e(t) == r(t)));
576
+ l("!=", (e, r) => (e = d(e), r = d(r), (t) => e(t) != r(t)));
577
+ const Cr = 110, qe = 120, Fr = 140;
578
+ y("+", Cr);
579
+ y("-", Cr);
580
+ y("*", qe);
581
+ y("/", qe);
582
+ y("%", qe);
583
+ K("+", Fr);
584
+ K("-", Fr);
585
+ l("+", (e, r) => r !== void 0 ? (e = d(e), r = d(r), (t) => e(t) + r(t)) : (e = d(e), (t) => +e(t)));
586
+ l("-", (e, r) => r !== void 0 ? (e = d(e), r = d(r), (t) => e(t) - r(t)) : (e = d(e), (t) => -e(t)));
587
+ l("*", (e, r) => (e = d(e), r = d(r), (t) => e(t) * r(t)));
588
+ l("/", (e, r) => (e = d(e), r = d(r), (t) => e(t) / r(t)));
589
+ l("%", (e, r) => (e = d(e), r = d(r), (t) => e(t) % r(t)));
590
+ const me = 150;
591
+ k("++", me, (e) => e ? ["++", e, null] : ["++", E(me - 1)]);
592
+ k("--", me, (e) => e ? ["--", e, null] : ["--", E(me - 1)]);
593
+ const Ye = (e, r, t, n) => typeof e == "string" ? (o) => r(o, e) : e[0] === "." ? (t = d(e[1]), n = e[2], (o) => r(t(o), n)) : e[0] === "[]" && e.length === 3 ? (t = d(e[1]), n = d(e[2]), (o) => r(t(o), n(o))) : e[0] === "()" && e.length === 2 ? Ye(e[1], r) : (
466
594
  // unwrap parens: (x)++
467
595
  (() => {
468
596
  throw Error("Invalid increment target");
469
597
  })()
470
598
  );
471
- l("++", (e, r) => Be(e, r === null ? (t, n) => t[n]++ : (t, n) => ++t[n]));
472
- l("--", (e, r) => Be(e, r === null ? (t, n) => t[n]-- : (t, n) => --t[n]));
473
- const At = 5, St = 10;
474
- sr(",", St);
475
- sr(";", At, !0);
476
- const gr = (...e) => (e = e.map(u), (r) => {
599
+ l("++", (e, r) => Ye(e, r === null ? (t, n) => t[n]++ : (t, n) => ++t[n]));
600
+ l("--", (e, r) => Ye(e, r === null ? (t, n) => t[n]-- : (t, n) => --t[n]));
601
+ const Xt = 5, zt = 10;
602
+ $r(",", zt);
603
+ $r(";", Xt, !0);
604
+ const Dr = (...e) => (e = e.map(d), (r) => {
477
605
  let t;
478
606
  for (const n of e) t = n(r);
479
607
  return t;
480
608
  });
481
- l(",", gr);
482
- l(";", gr);
483
- const $t = 170;
484
- Ue("()", $t);
485
- const P = (e) => e?.[0] === "_" && e[1] === "_" || e === "constructor" || e === "prototype", Ge = 170;
486
- ir("[]", Ge);
487
- g(".", Ge);
488
- ir("()", Ge);
489
- const le = (e) => {
609
+ l(",", Dr);
610
+ l(";", Dr);
611
+ const Jt = 170;
612
+ Je("()", Jt);
613
+ const H = (e) => e?.[0] === "_" && e[1] === "_" || e === "constructor" || e === "prototype", Ze = 170;
614
+ Ar("[]", Ze);
615
+ y(".", Ze);
616
+ Ar("()", Ze);
617
+ const ye = (e) => {
490
618
  throw Error(e);
491
619
  };
492
620
  l("[]", (e, r) => r === void 0 ? (e = e ? e[0] === "," ? e.slice(1) : [e] : [], e = e.map((t) => t == null ? (() => {
493
- }) : t[0] === "..." ? (t = u(t[1]), (n) => t(n)) : (t = u(t), (n) => [t(n)])), (t) => e.flatMap((n) => n(t))) : (r == null && le("Missing index"), e = u(e), r = u(r), (t) => {
621
+ }) : t[0] === "..." ? (t = d(t[1]), (n) => t(n)) : (t = d(t), (n) => [t(n)])), (t) => e.flatMap((n) => n(t))) : (r == null && ye("Missing index"), e = d(e), r = d(r), (t) => {
494
622
  const n = r(t);
495
- return P(n) ? void 0 : e(t)[n];
623
+ return H(n) ? void 0 : e(t)[n];
496
624
  }));
497
- l(".", (e, r) => (e = u(e), r = r[0] ? r : r[1], P(r) ? () => {
625
+ l(".", (e, r) => (e = d(e), r = r[0] ? r : r[1], H(r) ? () => {
498
626
  } : (t) => e(t)[r]));
499
627
  l("()", (e, r) => {
500
- if (r === void 0) return e == null ? le("Empty ()") : u(e);
501
- const t = (o) => o?.[0] === "," && o.slice(1).some((s) => s == null || t(s));
502
- t(r) && le("Empty argument");
503
- const n = r ? r[0] === "," ? (r = r.slice(1).map(u), (o) => r.map((s) => s(o))) : (r = u(r), (o) => [r(o)]) : () => [];
504
- return Je(e, (o, s, i) => o[s](...n(i)));
628
+ if (r === void 0) return e == null ? ye("Empty ()") : d(e);
629
+ const t = (o) => o?.[0] === "," && o.slice(1).some((i) => i == null || t(i));
630
+ t(r) && ye("Empty argument");
631
+ const n = r ? r[0] === "," ? (r = r.slice(1).map(d), (o) => r.map((i) => i(o))) : (r = d(r), (o) => [r(o)]) : () => [];
632
+ return xe(e, (o, i, s) => o[i](...n(s)));
505
633
  });
506
- const V = (e) => typeof e == "string" || Array.isArray(e) && (e[0] === "." || e[0] === "?." || e[0] === "[]" && e.length === 3 || e[0] === "?.[]" || e[0] === "()" && e.length === 2 && V(e[1]) || e[0] === "{}"), Je = (e, r, t, n) => e == null ? le("Empty ()") : e[0] === "()" && e.length == 2 ? Je(e[1], r) : typeof e == "string" ? (o) => r(o, e, o) : e[0] === "." ? (t = u(e[1]), n = e[2], (o) => r(t(o), n, o)) : e[0] === "?." ? (t = u(e[1]), n = e[2], (o) => {
507
- const s = t(o);
508
- return s == null ? void 0 : r(s, n, o);
509
- }) : e[0] === "[]" && e.length === 3 ? (t = u(e[1]), n = u(e[2]), (o) => r(t(o), n(o), o)) : e[0] === "?.[]" ? (t = u(e[1]), n = u(e[2]), (o) => {
510
- const s = t(o);
511
- return s == null ? void 0 : r(s, n(o), o);
512
- }) : (e = u(e), (o) => r([e(o)], 0, o)), M = Je, vt = 32, Et = A.space;
513
- A.comment ??= { "//": `
634
+ const q = (e) => typeof e == "string" || Array.isArray(e) && (e[0] === "." || e[0] === "?." || e[0] === "[]" && e.length === 3 || e[0] === "?.[]" || e[0] === "()" && e.length === 2 && q(e[1]) || e[0] === "{}"), xe = (e, r, t, n) => e == null ? ye("Empty ()") : e[0] === "()" && e.length == 2 ? xe(e[1], r) : typeof e == "string" ? (o) => r(o, e, o) : e[0] === "." ? (t = d(e[1]), n = e[2], (o) => r(t(o), n, o)) : e[0] === "?." ? (t = d(e[1]), n = e[2], (o) => {
635
+ const i = t(o);
636
+ return i == null ? void 0 : r(i, n, o);
637
+ }) : e[0] === "[]" && e.length === 3 ? (t = d(e[1]), n = d(e[2]), (o) => r(t(o), n(o), o)) : e[0] === "?.[]" ? (t = d(e[1]), n = d(e[2]), (o) => {
638
+ const i = t(o);
639
+ return i == null ? void 0 : r(i, n(o), o);
640
+ }) : (e = d(e), (o) => r([e(o)], 0, o)), b = xe, Qt = 32, qt = m.space;
641
+ m.comment ??= { "//": `
514
642
  `, "/*": "*/" };
515
- let $e;
516
- A.space = () => {
517
- $e || ($e = Object.entries(A.comment).map(([o, s]) => [o, s, o.charCodeAt(0)]));
518
- for (var e; e = Et(); ) {
519
- for (var r = 0, t; t = $e[r++]; )
643
+ let De;
644
+ m.space = () => {
645
+ De || (De = Object.entries(m.comment).map(([o, i]) => [o, i, o.charCodeAt(0)]));
646
+ for (var e; e = qt(); ) {
647
+ for (var r = 0, t; t = De[r++]; )
520
648
  if (e === t[2] && p.substr(a, t[0].length) === t[0]) {
521
649
  var n = a + t[0].length;
522
650
  if (t[1] === `
523
- `) for (; p.charCodeAt(n) >= vt; ) n++;
651
+ `) for (; p.charCodeAt(n) >= Qt; ) n++;
524
652
  else {
525
653
  for (; p[n] && p.substr(n, t[1].length) !== t[1]; ) n++;
526
654
  p[n] && (n += t[1].length);
527
655
  }
528
- Fe(n), e = 0;
656
+ Me(n), e = 0;
529
657
  break;
530
658
  }
531
659
  if (e) return e;
532
660
  }
533
661
  return e;
534
662
  };
535
- const yr = 80;
536
- g("===", yr);
537
- g("!==", yr);
538
- l("===", (e, r) => (e = u(e), r = u(r), (t) => e(t) === r(t)));
539
- l("!==", (e, r) => (e = u(e), r = u(r), (t) => e(t) !== r(t)));
540
- const Ot = 30;
541
- g("??", Ot);
542
- l("??", (e, r) => (e = u(e), r = u(r), (t) => e(t) ?? r(t)));
543
- const It = 130, Ct = 20;
544
- g("**", It, !0);
545
- g("**=", Ct, !0);
546
- l("**", (e, r) => (e = u(e), r = u(r), (t) => e(t) ** r(t)));
547
- const wt = (e) => {
663
+ const Pr = 80;
664
+ y("===", Pr);
665
+ y("!==", Pr);
666
+ l("===", (e, r) => (e = d(e), r = d(r), (t) => e(t) === r(t)));
667
+ l("!==", (e, r) => (e = d(e), r = d(r), (t) => e(t) !== r(t)));
668
+ const Yt = 30;
669
+ y("??", Yt);
670
+ l("??", (e, r) => (e = d(e), r = d(r), (t) => e(t) ?? r(t)));
671
+ const Zt = 130, xt = 20;
672
+ y("**", Zt, !0);
673
+ y("**=", xt, !0);
674
+ l("**", (e, r) => (e = d(e), r = d(r), (t) => e(t) ** r(t)));
675
+ const bt = (e) => {
548
676
  throw Error(e);
549
677
  };
550
- l("**=", (e, r) => (V(e) || wt("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] **= r(o))));
551
- const mr = 90;
552
- g("in", mr);
553
- g("of", mr);
554
- l("in", (e, r) => (e = u(e), r = u(r), (t) => e(t) in r(t)));
555
- const Dt = 20, kt = 100, Ft = (e) => {
678
+ l("**=", (e, r) => (q(e) || bt("Invalid assignment target"), r = d(r), b(e, (t, n, o) => t[n] **= r(o))));
679
+ const Wr = 90;
680
+ y("in", Wr);
681
+ y("of", Wr);
682
+ l("in", (e, r) => (e = d(e), r = d(r), (t) => e(t) in r(t)));
683
+ const en = 20, rn = 100, tn = (e) => {
556
684
  throw Error(e);
557
685
  };
558
- g(">>>", kt);
559
- g(">>>=", Dt, !0);
560
- l(">>>", (e, r) => (e = u(e), r = u(r), (t) => e(t) >>> r(t)));
561
- l(">>>=", (e, r) => (V(e) || Ft("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] >>>= r(o))));
562
- const Tt = (e) => e[0]?.[0] === "," ? e[0].slice(1) : e, _e = (e, r, t) => {
686
+ y(">>>", rn);
687
+ y(">>>=", en, !0);
688
+ l(">>>", (e, r) => (e = d(e), r = d(r), (t) => e(t) >>> r(t)));
689
+ l(">>>=", (e, r) => (q(e) || tn("Invalid assignment target"), r = d(r), b(e, (t, n, o) => t[n] >>>= r(o))));
690
+ const be = 5, nn = 10, on = 20, sn = (e) => e[0]?.[0] === "," ? e[0].slice(1) : e, $e = (e, r, t) => {
563
691
  if (typeof e == "string") {
564
692
  t[e] = r;
565
693
  return;
566
694
  }
567
- const [n, ...o] = e, s = Tt(o);
695
+ const [n, ...o] = e, i = sn(o);
568
696
  if (n === "{}") {
569
- const i = [];
570
- for (const d of s) {
571
- if (Array.isArray(d) && d[0] === "...") {
572
- const S = {};
573
- for (const j in r) i.includes(j) || (S[j] = r[j]);
574
- t[d[1]] = S;
697
+ const s = [];
698
+ for (const u of i) {
699
+ if (Array.isArray(u) && u[0] === "...") {
700
+ const f = {};
701
+ for (const C in r) s.includes(C) || (f[C] = r[C]);
702
+ t[u[1]] = f;
575
703
  break;
576
704
  }
577
- let c, f, y;
578
- typeof d == "string" ? c = f = d : d[0] === "=" ? (typeof d[1] == "string" ? c = f = d[1] : [, c, f] = d[1], y = d[2]) : [, c, f] = d, i.push(c);
579
- let h = r[c];
580
- h === void 0 && y && (h = u(y)(t)), _e(f, h, t);
705
+ let c, h, A;
706
+ typeof u == "string" ? c = h = u : u[0] === "=" ? (typeof u[1] == "string" ? c = h = u[1] : [, c, h] = u[1], A = u[2]) : [, c, h] = u, s.push(c);
707
+ let g = r[c];
708
+ g === void 0 && A && (g = d(A)(t)), $e(h, g, t);
581
709
  }
582
710
  } else if (n === "[]") {
583
- let i = 0;
584
- for (const d of s) {
585
- if (d === null) {
586
- i++;
711
+ let s = 0;
712
+ for (const u of i) {
713
+ if (u === null) {
714
+ s++;
587
715
  continue;
588
716
  }
589
- if (Array.isArray(d) && d[0] === "...") {
590
- t[d[1]] = r.slice(i);
717
+ if (Array.isArray(u) && u[0] === "...") {
718
+ t[u[1]] = r.slice(s);
591
719
  break;
592
720
  }
593
- let c = d, f;
594
- Array.isArray(d) && d[0] === "=" && ([, c, f] = d);
595
- let y = r[i++];
596
- y === void 0 && f && (y = u(f)(t)), _e(c, y, t);
721
+ let c = u, h;
722
+ Array.isArray(u) && u[0] === "=" && ([, c, h] = u);
723
+ let A = r[s++];
724
+ A === void 0 && h && (A = d(h)(t)), $e(c, A, t);
597
725
  }
598
726
  }
599
- }, Ke = 20, Se = (e) => {
727
+ }, Tr = (e) => {
728
+ let r = E(nn - 1);
729
+ return r?.[0] === "in" || r?.[0] === "of" ? [r[0], [e, r[1]], r[2]] : r?.[0] === "," ? [e, ...r.slice(1)] : [e, r];
730
+ };
731
+ ue("let", be + 1, () => Tr("let"));
732
+ ue("const", be + 1, () => Tr("const"));
733
+ ue("var", be, () => (G(), ["var", E(on)]));
734
+ const Rr = (...e) => (e = e.map((r) => {
735
+ if (typeof r == "string") return (t) => {
736
+ t[r] = void 0;
737
+ };
738
+ if (r[0] === "=") {
739
+ const [, t, n] = r, o = d(n);
740
+ return typeof t == "string" ? (i) => {
741
+ i[t] = o(i);
742
+ } : (i) => $e(t, o(i), i);
743
+ }
744
+ return d(r);
745
+ }), (r) => {
746
+ for (const t of e) t(r);
747
+ });
748
+ l("let", Rr);
749
+ l("const", Rr);
750
+ l("var", (e) => typeof e == "string" ? (r) => {
751
+ r[e] = void 0;
752
+ } : () => {
753
+ });
754
+ const er = 20, Fe = (e) => {
600
755
  throw Error(e);
601
756
  };
602
- g("||=", Ke, !0);
603
- g("&&=", Ke, !0);
604
- g("??=", Ke, !0);
757
+ y("||=", er, !0);
758
+ y("&&=", er, !0);
759
+ y("??=", er, !0);
605
760
  l("=", (e, r) => {
606
761
  if (Array.isArray(e) && (e[0] === "let" || e[0] === "const" || e[0] === "var")) {
607
762
  const t = e[1];
608
- return r = u(r), typeof t == "string" ? (n) => {
763
+ return r = d(r), typeof t == "string" ? (n) => {
609
764
  n[t] = r(n);
610
- } : (n) => _e(t, r(n), n);
765
+ } : (n) => $e(t, r(n), n);
611
766
  }
612
- return V(e) || Se("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] = r(o));
767
+ return q(e) || Fe("Invalid assignment target"), r = d(r), b(e, (t, n, o) => t[n] = r(o));
613
768
  });
614
- l("||=", (e, r) => (V(e) || Se("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] ||= r(o))));
615
- l("&&=", (e, r) => (V(e) || Se("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] &&= r(o))));
616
- l("??=", (e, r) => (V(e) || Se("Invalid assignment target"), r = u(r), M(e, (t, n, o) => t[n] ??= r(o))));
617
- const Ar = (e, r, t, n = e.charCodeAt(0), o = e.length, s = T[n], i) => T[n] = (d, c, f, y = a) => !d && (f ? e == f : (o < 2 || p.substr(a, o) == e) && (f = e)) && c < r && !A.id(p.charCodeAt(a + o)) && qr(a + o) !== 58 && // allow {keyword:value}
618
- (Fe(a + o), (i = t()) ? or(i, y) : Fe(y), i) || s?.(d, c, f);
619
- re("true", !0);
620
- re("false", !1);
621
- re("null", null);
622
- Ar("undefined", 200, () => []);
623
- re("NaN", NaN);
624
- re("Infinity", 1 / 0);
625
- const ve = 20;
626
- F("?", ve, (e, r, t) => e && (r = $(ve - 1)) && K((n) => n === 58) && (t = $(ve - 1), ["?", e, r, t]));
627
- l("?", (e, r, t) => (e = u(e), r = u(r), t = u(t), (n) => e(n) ? r(n) : t(n)));
628
- const _t = [], Wt = 20;
629
- g("=>", Wt, !0);
769
+ l("||=", (e, r) => (q(e) || Fe("Invalid assignment target"), r = d(r), b(e, (t, n, o) => t[n] ||= r(o))));
770
+ l("&&=", (e, r) => (q(e) || Fe("Invalid assignment target"), r = d(r), b(e, (t, n, o) => t[n] &&= r(o))));
771
+ l("??=", (e, r) => (q(e) || Fe("Invalid assignment target"), r = d(r), b(e, (t, n, o) => t[n] ??= r(o))));
772
+ de("true", !0);
773
+ de("false", !1);
774
+ de("null", null);
775
+ ue("undefined", 200, () => []);
776
+ de("NaN", NaN);
777
+ de("Infinity", 1 / 0);
778
+ const Pe = 20;
779
+ k("?", Pe, (e, r, t) => e && (r = E(Pe - 1)) && x((n) => n === 58) && (t = E(Pe - 1), ["?", e, r, t]));
780
+ l("?", (e, r, t) => (e = d(e), r = d(r), t = d(t), (n) => e(n) ? r(n) : t(n)));
781
+ const dn = [], un = 20;
782
+ y("=>", un, !0);
630
783
  l("=>", (e, r) => {
631
784
  e = e?.[0] === "()" ? e[1] : e;
632
785
  const t = e ? e[0] === "," ? e.slice(1) : [e] : [];
633
786
  let n = -1, o = null;
634
- const s = t[t.length - 1];
635
- Array.isArray(s) && s[0] === "..." && (n = t.length - 1, o = s[1], t.length--);
636
- const i = r?.[0] === "{}";
637
- return r = u(i ? ["{", r[1]] : r), (d) => (...c) => {
638
- const f = {};
639
- t.forEach((h, S) => f[h] = c[S]), o && (f[o] = c.slice(n));
640
- const y = new Proxy(f, {
641
- get: (h, S) => S in h ? h[S] : d?.[S],
642
- set: (h, S, j) => ((S in h ? h : d)[S] = j, !0),
643
- has: (h, S) => S in h || (d ? S in d : !1)
787
+ const i = t[t.length - 1];
788
+ Array.isArray(i) && i[0] === "..." && (n = t.length - 1, o = i[1], t.length--);
789
+ const s = r?.[0] === "{}";
790
+ return r = d(s ? ["{", r[1]] : r), (u) => (...c) => {
791
+ const h = {};
792
+ t.forEach((g, f) => h[g] = c[f]), o && (h[o] = c.slice(n));
793
+ const A = new Proxy(h, {
794
+ get: (g, f) => f in g ? g[f] : u?.[f],
795
+ set: (g, f, C) => ((f in g ? g : u)[f] = C, !0),
796
+ has: (g, f) => f in g || (u ? f in u : !1)
644
797
  });
645
798
  try {
646
- const h = r(y);
647
- return i ? void 0 : h;
648
- } catch (h) {
649
- if (h === _t) return h[0];
650
- throw h;
799
+ const g = r(A);
800
+ return s ? void 0 : g;
801
+ } catch (g) {
802
+ if (g === dn) return g[0];
803
+ throw g;
651
804
  }
652
805
  };
653
806
  });
654
- const Pt = 140;
655
- N("...", Pt);
656
- l("...", (e) => (e = u(e), (r) => Object.entries(e(r))));
657
- const qe = 170;
658
- F("?.", qe, (e, r) => {
807
+ const cn = 140;
808
+ K("...", cn);
809
+ l("...", (e) => (e = d(e), (r) => Object.entries(e(r))));
810
+ const fr = 170;
811
+ k("?.", fr, (e, r) => {
659
812
  if (!e) return;
660
- const t = Y();
661
- return t === 40 ? (E(), ["?.()", e, $(0, 41) || null]) : t === 91 ? (E(), ["?.[]", e, $(0, 93)]) : (r = $(qe), r ? ["?.", e, r] : void 0);
813
+ const t = G();
814
+ return t === 40 ? (O(), ["?.()", e, E(0, 41) || null]) : t === 91 ? (O(), ["?.[]", e, E(0, 93)]) : (r = E(fr), r ? ["?.", e, r] : void 0);
662
815
  });
663
- l("?.", (e, r) => (e = u(e), P(r) ? () => {
816
+ l("?.", (e, r) => (e = d(e), H(r) ? () => {
664
817
  } : (t) => e(t)?.[r]));
665
- l("?.[]", (e, r) => (e = u(e), r = u(r), (t) => {
818
+ l("?.[]", (e, r) => (e = d(e), r = d(r), (t) => {
666
819
  const n = r(t);
667
- return P(n) ? void 0 : e(t)?.[n];
820
+ return H(n) ? void 0 : e(t)?.[n];
668
821
  }));
669
822
  l("?.()", (e, r) => {
670
- const t = r ? r[0] === "," ? (r = r.slice(1).map(u), (o) => r.map((s) => s(o))) : (r = u(r), (o) => [r(o)]) : () => [];
823
+ const t = r ? r[0] === "," ? (r = r.slice(1).map(d), (o) => r.map((i) => i(o))) : (r = d(r), (o) => [r(o)]) : () => [];
671
824
  if (e[0] === "?.") {
672
- const o = u(e[1]), s = e[2];
673
- return P(s) ? () => {
674
- } : (i) => o(i)?.[s]?.(...t(i));
825
+ const o = d(e[1]), i = e[2];
826
+ return H(i) ? () => {
827
+ } : (s) => o(s)?.[i]?.(...t(s));
675
828
  }
676
829
  if (e[0] === "?.[]") {
677
- const o = u(e[1]), s = u(e[2]);
678
- return (i) => {
679
- const d = o(i), c = s(i);
680
- return P(c) ? void 0 : d?.[c]?.(...t(i));
830
+ const o = d(e[1]), i = d(e[2]);
831
+ return (s) => {
832
+ const u = o(s), c = i(s);
833
+ return H(c) ? void 0 : u?.[c]?.(...t(s));
681
834
  };
682
835
  }
683
836
  if (e[0] === ".") {
684
- const o = u(e[1]), s = e[2];
685
- return P(s) ? () => {
686
- } : (i) => o(i)?.[s]?.(...t(i));
837
+ const o = d(e[1]), i = e[2];
838
+ return H(i) ? () => {
839
+ } : (s) => o(s)?.[i]?.(...t(s));
687
840
  }
688
841
  if (e[0] === "[]" && e.length === 3) {
689
- const o = u(e[1]), s = u(e[2]);
690
- return (i) => {
691
- const d = o(i), c = s(i);
692
- return P(c) ? void 0 : d?.[c]?.(...t(i));
842
+ const o = d(e[1]), i = d(e[2]);
843
+ return (s) => {
844
+ const u = o(s), c = i(s);
845
+ return H(c) ? void 0 : u?.[c]?.(...t(s));
693
846
  };
694
847
  }
695
- const n = u(e);
848
+ const n = d(e);
696
849
  return (o) => n(o)?.(...t(o));
697
850
  });
698
- const z = 140;
699
- N("typeof", z);
700
- N("void", z);
701
- N("delete", z);
702
- Ar(
851
+ const ne = 140;
852
+ K("typeof", ne);
853
+ K("void", ne);
854
+ K("delete", ne);
855
+ ue(
703
856
  "new",
704
- z,
705
- () => zr(".target") ? (E(7), ["new.target"]) : ["new", $(z)]
857
+ ne,
858
+ () => wt(".target") ? (O(7), ["new.target"]) : ["new", E(ne)]
706
859
  );
707
- l("typeof", (e) => (e = u(e), (r) => typeof e(r)));
708
- l("void", (e) => (e = u(e), (r) => (e(r), void 0)));
860
+ l("typeof", (e) => (e = d(e), (r) => typeof e(r)));
861
+ l("void", (e) => (e = d(e), (r) => (e(r), void 0)));
709
862
  l("delete", (e) => {
710
863
  if (e[0] === ".") {
711
- const r = u(e[1]), t = e[2];
864
+ const r = d(e[1]), t = e[2];
712
865
  return (n) => delete r(n)[t];
713
866
  }
714
867
  if (e[0] === "[]") {
715
- const r = u(e[1]), t = u(e[2]);
868
+ const r = d(e[1]), t = d(e[2]);
716
869
  return (n) => delete r(n)[t(n)];
717
870
  }
718
871
  return () => !0;
719
872
  });
720
873
  l("new", (e) => {
721
- const r = u(e?.[0] === "()" ? e[1] : e), t = e?.[0] === "()" ? e[2] : null, n = t ? t[0] === "," ? /* @__PURE__ */ ((o) => (s) => o.map((i) => i(s)))(t.slice(1).map(u)) : /* @__PURE__ */ ((o) => (s) => [o(s)])(u(t)) : () => [];
874
+ const r = d(e?.[0] === "()" ? e[1] : e), t = e?.[0] === "()" ? e[2] : null, n = t ? t[0] === "," ? /* @__PURE__ */ ((o) => (i) => o.map((s) => s(i)))(t.slice(1).map(d)) : /* @__PURE__ */ ((o) => (i) => [o(i)])(d(t)) : () => [];
722
875
  return (o) => new (r(o))(...n(o));
723
876
  });
724
- const Me = Symbol("accessor"), Xe = 20, Nt = 40, Sr = 41, $r = 123, vr = 125, Er = (e) => (r) => {
877
+ const rr = Symbol("accessor"), tr = 20, ln = 40, kr = 41, _r = 123, Nr = 125, Lr = (e) => (r) => {
725
878
  if (r) return;
726
- Y();
727
- const t = K(A.id);
728
- if (!t || (Y(), p.charCodeAt(a) !== Nt)) return !1;
729
- E();
730
- const n = $(0, Sr);
731
- return Y(), p.charCodeAt(a) !== $r ? !1 : (E(), [e, t, n, $(0, vr)]);
879
+ G();
880
+ const t = x(m.id);
881
+ if (!t || (G(), p.charCodeAt(a) !== ln)) return !1;
882
+ O();
883
+ const n = E(0, kr);
884
+ return G(), p.charCodeAt(a) !== _r ? !1 : (O(), [e, t, n, E(0, Nr)]);
732
885
  };
733
- F("get", Xe - 1, Er("get"));
734
- F("set", Xe - 1, Er("set"));
735
- F("(", Xe - 1, (e) => {
886
+ k("get", tr - 1, Lr("get"));
887
+ k("set", tr - 1, Lr("set"));
888
+ k("(", tr - 1, (e) => {
736
889
  if (!e || typeof e != "string") return;
737
- const r = $(0, Sr) || null;
738
- if (Y(), p.charCodeAt(a) === $r)
739
- return E(), [":", e, ["=>", ["()", r], $(0, vr) || null]];
890
+ const r = E(0, kr) || null;
891
+ if (G(), p.charCodeAt(a) === _r)
892
+ return O(), [":", e, ["=>", ["()", r], E(0, Nr) || null]];
740
893
  });
741
- l("get", (e, r) => (r = r ? u(r) : () => {
742
- }, (t) => [[Me, e, {
894
+ l("get", (e, r) => (r = r ? d(r) : () => {
895
+ }, (t) => [[rr, e, {
743
896
  get: function() {
744
897
  const n = Object.create(t || {});
745
898
  return n.this = this, r(n);
746
899
  }
747
900
  }]]));
748
- l("set", (e, r, t) => (t = t ? u(t) : () => {
749
- }, (n) => [[Me, e, {
901
+ l("set", (e, r, t) => (t = t ? d(t) : () => {
902
+ }, (n) => [[rr, e, {
750
903
  set: function(o) {
751
- const s = Object.create(n || {});
752
- s.this = this, s[r] = o, t(s);
904
+ const i = Object.create(n || {});
905
+ i.this = this, i[r] = o, t(i);
753
906
  }
754
907
  }]]));
755
- const jt = 20, Or = 200, Lt = (e) => e == null || typeof e == "string" || [":", ",", "...", "get", "set"].includes(e[0]);
756
- Ue("[]", Or);
757
- Ue("{}", Or);
758
- g(":", jt - 1, !0);
908
+ const fn = 20, Mr = 200;
909
+ m.prop = (e) => Ot(e) !== 58;
910
+ const an = (e) => e == null || typeof e == "string" || [":", ",", "...", "get", "set"].includes(e[0]);
911
+ Je("[]", Mr);
912
+ Je("{}", Mr);
913
+ y(":", fn - 1, !0);
759
914
  l("{}", (e, r) => {
760
915
  if (r !== void 0) return;
761
- if (!Lt(e)) return u(["{", e]);
916
+ if (!an(e)) return d(["{", e]);
762
917
  e = e ? e[0] !== "," ? [e] : e.slice(1) : [];
763
- const t = e.map((n) => u(typeof n == "string" ? [":", n, n] : n));
918
+ const t = e.map((n) => d(typeof n == "string" ? [":", n, n] : n));
764
919
  return (n) => {
765
- const o = {}, s = {};
766
- for (const i of t.flatMap((d) => d(n)))
767
- if (i[0] === Me) {
768
- const [, d, c] = i;
769
- s[d] = { ...s[d], ...c, configurable: !0, enumerable: !0 };
770
- } else o[i[0]] = i[1];
771
- for (const i in s) Object.defineProperty(o, i, s[i]);
920
+ const o = {}, i = {};
921
+ for (const s of t.flatMap((u) => u(n)))
922
+ if (s[0] === rr) {
923
+ const [, u, c] = s;
924
+ i[u] = { ...i[u], ...c, configurable: !0, enumerable: !0 };
925
+ } else o[s[0]] = s[1];
926
+ for (const s in i) Object.defineProperty(o, s, i[s]);
772
927
  return o;
773
928
  };
774
929
  });
775
- l("{", (e) => (e = e ? u(e) : () => {
930
+ l("{", (e) => (e = e ? d(e) : () => {
776
931
  }, (r) => e(Object.create(r))));
777
- l(":", (e, r) => (r = u(r), Array.isArray(e) ? (e = u(e), (t) => [[e(t), r(t)]]) : (t) => [[e, r(t)]]));
778
- const Rt = 170, fe = 96, Ut = 36, Vt = 123, Ht = 92, Bt = { n: `
779
- `, r: "\r", t: " ", b: "\b", f: "\f", v: "\v" }, ze = () => {
932
+ l(":", (e, r) => (r = d(r), Array.isArray(e) ? (e = d(e), (t) => [[e(t), r(t)]]) : (t) => [[e, r(t)]]));
933
+ const hn = 170, Ae = 96, pn = 36, gn = 123, mn = 92, yn = { n: `
934
+ `, r: "\r", t: " ", b: "\b", f: "\f", v: "\v" }, ar = () => {
780
935
  const e = [];
781
- for (let r = "", t; (t = p.charCodeAt(a)) !== fe; )
782
- t ? t === Ht ? (E(), r += Bt[p[a]] || p[a], E()) : t === Ut && p.charCodeAt(a + 1) === Vt ? (r && e.push([, r]), r = "", E(2), e.push($(0, 125))) : (r += p[a], E(), t = p.charCodeAt(a), t === fe && r && e.push([, r])) : U("Unterminated template");
783
- return E(), e;
784
- }, Gt = T[fe];
785
- T[fe] = (e, r) => e && r < Rt ? A.asi && A.newline ? void 0 : (E(), ["``", e, ...ze()]) : (
936
+ for (let r = "", t; (t = p.charCodeAt(a)) !== Ae; )
937
+ t ? t === mn ? (O(), r += yn[p[a]] || p[a], O()) : t === pn && p.charCodeAt(a + 1) === gn ? (r && e.push([, r]), r = "", O(2), e.push(E(0, 125))) : (r += p[a], O(), t = p.charCodeAt(a), t === Ae && r && e.push([, r])) : Q("Unterminated template");
938
+ return O(), e;
939
+ }, $n = _[Ae];
940
+ _[Ae] = (e, r) => e && r < hn ? m.asi && m.newline ? void 0 : (O(), ["``", e, ...ar()]) : (
786
941
  // tagged
787
942
  e ? (
788
943
  // plain
789
- Gt?.(e, r)
790
- ) : (E(), ((t) => t.length < 2 && t[0]?.[0] === void 0 ? t[0] || [, ""] : ["`", ...t])(ze()))
944
+ $n?.(e, r)
945
+ ) : (O(), ((t) => t.length < 2 && t[0]?.[0] === void 0 ? t[0] || [, ""] : ["`", ...t])(ar()))
791
946
  );
792
- l("`", (...e) => (e = e.map(u), (r) => e.map((t) => t(r)).join("")));
947
+ l("`", (...e) => (e = e.map(d), (r) => e.map((t) => t(r)).join("")));
793
948
  l("``", (e, ...r) => {
794
- e = u(e);
949
+ e = d(e);
795
950
  const t = [], n = [];
796
- for (const s of r)
797
- Array.isArray(s) && s[0] === void 0 ? t.push(s[1]) : n.push(u(s));
951
+ for (const i of r)
952
+ Array.isArray(i) && i[0] === void 0 ? t.push(i[1]) : n.push(d(i));
798
953
  const o = Object.assign([...t], { raw: t });
799
- return (s) => e(s)(o, ...n.map((i) => i(s)));
954
+ return (i) => e(i)(o, ...n.map((s) => s(i)));
800
955
  });
801
- A.string["'"] = !0;
802
- A.number = { "0x": 16, "0b": 2, "0o": 8 };
803
- const X = (e) => {
956
+ m.string["'"] = !0;
957
+ m.number = { "0x": 16, "0b": 2, "0o": 8 };
958
+ const An = {
959
+ log: (e, r) => (r ? console.log(r, e) : console.log(e), e)
960
+ };
961
+ function j(e, r, t, n, o) {
962
+ const i = m(En(e));
963
+ return d(i)({
964
+ $form: r,
965
+ $meta: t,
966
+ $errors: n,
967
+ $formIsInvalid: o,
968
+ $log: An.log
969
+ }) === !0;
970
+ }
971
+ function En(e) {
972
+ return e.replace(/\?\.(\d+)/g, "?.[$1]").replace(/\.(\d+)/g, "[$1]");
973
+ }
974
+ const V = (e) => {
804
975
  let r = e.formDef.states;
805
976
  if (!r || Object.keys(r).length === 0 || e.formHealth.status === "errored")
806
977
  return e;
807
- r = Jt(r);
808
- let t = [], n = { status: "ok" };
978
+ const { $formIsInvalid: t, $errors: n } = Xe(e);
979
+ r = Sn(r);
980
+ let o = [], i = { status: "ok" };
809
981
  try {
810
- t = Object.keys(r).map((o) => {
811
- const s = r[o], i = A(s);
812
- return u(i)({
813
- $form: e.data,
814
- $log: (f, y) => (y ? console.log(y, f) : console.log(f), f)
815
- }) === !0 ? o : void 0;
816
- }).filter((o) => o !== void 0);
817
- } catch (o) {
818
- n = {
982
+ o = Object.keys(r).map((s) => {
983
+ const u = r[s];
984
+ let c;
985
+ try {
986
+ c = j(u, e.data, e.meta, n, t);
987
+ } catch {
988
+ c = !1;
989
+ }
990
+ return c === !0 ? s : void 0;
991
+ }).filter((s) => s !== void 0);
992
+ } catch (s) {
993
+ const u = s, c = ae.calculateCurrentStateError;
994
+ i = {
819
995
  status: "errored",
820
- message: o.message
996
+ message: `[${c}] ${u.message}`,
997
+ code: c
821
998
  };
822
999
  }
823
- return { ...e, currentStates: t, formHealth: n };
1000
+ return { ...e, currentStates: o, formHealth: i };
824
1001
  };
825
- function Jt(e) {
1002
+ function Sn(e) {
826
1003
  const r = {};
827
1004
  function t(n) {
828
- const o = n.split(":"), s = [];
829
- for (let i = 0; i < o.length; i++)
830
- s.push(o.slice(0, i + 1).join(":"));
831
- return s;
1005
+ const o = n.split(":"), i = [];
1006
+ for (let s = 0; s < o.length; s++)
1007
+ i.push(o.slice(0, s + 1).join(":"));
1008
+ return i;
832
1009
  }
833
1010
  for (const [n, o] of Object.entries(e)) {
834
- const s = t(n), i = [];
835
- for (const d of s)
836
- e[d] && i.push(`(${e[d]})`);
837
- r[n] = i.join(" && ");
1011
+ const i = t(n), s = [];
1012
+ for (const u of i)
1013
+ e[u] && s.push(`(${e[u]})`);
1014
+ r[n] = s.join(" && ");
838
1015
  }
839
1016
  return r;
840
1017
  }
841
- const te = (e, r) => (t) => e(t) ? r(t) : t, Kt = (e) => (r) => {
842
- const t = r.touchedControls[e];
843
- return r.touched && t;
844
- }, x = (e) => e !== void 0 && typeof e == "object" && e !== null && "when" in e, Q = (e) => ({
845
- ...e,
846
- widgetFlags: Mt(e)
847
- });
848
- function Mt(e) {
849
- return Object.values(e.flatForm).map((r) => {
850
- if (Pe(r)) {
851
- const t = r({
1018
+ const nr = Symbol("filterMap.skip");
1019
+ function jr(e, r) {
1020
+ const t = [];
1021
+ for (let n = 0; n < e.length; n++) {
1022
+ const o = r(e[n], n, e);
1023
+ o !== nr && t.push(o);
1024
+ }
1025
+ return t;
1026
+ }
1027
+ function Io(e, r, t) {
1028
+ for (let n = 0; n < e.length; n++)
1029
+ r(e[n], n, e) && t(e[n], n, e);
1030
+ }
1031
+ function vn(e, r, t, n) {
1032
+ let o = n;
1033
+ for (let i = 0; i < e.length; i++)
1034
+ r(e[i], i, e) && (o = t(o, e[i], i, e));
1035
+ return o;
1036
+ }
1037
+ function In(e, r, t) {
1038
+ if (e.length !== r.length)
1039
+ return !1;
1040
+ for (let n = 0; n < e.length; n++)
1041
+ if (!t(e[n], r[n], n, e, r))
1042
+ return !1;
1043
+ return !0;
1044
+ }
1045
+ function On(e, r) {
1046
+ const t = Vr(e.uid, r);
1047
+ return P(e) ? {
1048
+ ...e,
1049
+ uid: t,
1050
+ path: wn(e.path, r)
1051
+ } : {
1052
+ ...e,
1053
+ uid: t
1054
+ };
1055
+ }
1056
+ function Vr(e, r) {
1057
+ if (r.length === 0)
1058
+ throw new Error("Repeater indexes cannot be an empty array");
1059
+ const t = r.reduce((n, o) => `${n}[${o}]`, "");
1060
+ return `${e}${t}`;
1061
+ }
1062
+ function wn(e, r) {
1063
+ if (r.length === 0)
1064
+ throw new Error("Repeater indexes cannot be an empty array");
1065
+ const t = "items", n = e.split(`.${t}`), o = n.length - 1;
1066
+ if (o !== r.length)
1067
+ throw new Error(
1068
+ `Path contains ${o} '${t}' occurrences, but ${r.length} indexes were provided.`
1069
+ );
1070
+ return n.reduce((i, s, u) => u === 0 ? s : `${i}.${r[u - 1]}${s}`);
1071
+ }
1072
+ function le(e, r) {
1073
+ let t = 0;
1074
+ return e.replace(/\.items(\??)\./g, (n, o) => {
1075
+ const i = r[t++];
1076
+ return i === void 0 ? n : `.${i}${o}.`;
1077
+ });
1078
+ }
1079
+ const fe = (e, r) => (t) => e(t) ? r(t) : t, z = (e) => e !== void 0 && typeof e == "object" && e !== null && "when" in e, U = (e) => {
1080
+ const { $formIsInvalid: r, $errors: t } = Xe(e);
1081
+ return {
1082
+ ...e,
1083
+ widgetFlags: {
1084
+ ...Cn(e, t, r),
1085
+ ...Fn(e, t, r)
1086
+ }
1087
+ };
1088
+ };
1089
+ function Cn(e, r, t) {
1090
+ return jr(Object.values(e.flatForm), (n) => {
1091
+ if (n.uid?.includes("["))
1092
+ return nr;
1093
+ if (se(n)) {
1094
+ const o = n({
852
1095
  $form: e.data,
853
1096
  errors: void 0,
854
1097
  touched: void 0,
855
1098
  translate: void 0
856
1099
  });
857
- return t.uid = r.uid, t;
1100
+ return o.uid = n.uid, o;
858
1101
  }
859
- return r;
860
- }).filter((r) => !!(r.include && ("in" in r.include || r.include) || r.exclude && ("from" in r.exclude || "when" in r.exclude) || _(r) || De(r) && x(r.disabled) || _(r) && x(r.readonly))).reduce(
861
- (r, t) => (r[t.uid] = r[t.uid] || {}, t.include && "in" in t.include ? r[t.uid].hidden = !t.include.in.some(
862
- (n) => e.currentStates.includes(n)
863
- ) : t.include && "when" in t.include && (r[t.uid].hidden = !ne(t.include.when, e.data)), t.exclude && "from" in t.exclude ? r[t.uid].hidden = t.exclude.from.some(
864
- (n) => e.currentStates.includes(n)
865
- ) : t.exclude && "when" in t.exclude && (r[t.uid].hidden = ne(t.exclude.when, e.data)), (_(t) || De(t)) && x(t.disabled) && (r[t.uid].disabled = ne(
866
- t.disabled.when,
867
- e.data
868
- )), _(t) && x(t.readonly) && (r[t.uid].readonly = ne(
869
- t.readonly.when,
870
- e.data
871
- )), r),
1102
+ return n;
1103
+ }).filter((n) => !!(n.include && ("in" in n.include || "when" in n.include) || n.exclude && ("from" in n.exclude || "when" in n.exclude) || (P(n) || re(n)) && z(n.disabled) || P(n) && z(n.readonly))).reduce(
1104
+ (n, o) => (n[o.uid] = n[o.uid] || {}, o.include && "in" in o.include ? n[o.uid].hidden = !o.include.in.some(
1105
+ (i) => e.currentStates.includes(i)
1106
+ ) : o.include && "when" in o.include && (n[o.uid].hidden = !j(
1107
+ o.include.when,
1108
+ e.data,
1109
+ e.meta,
1110
+ r,
1111
+ t
1112
+ )), o.exclude && "from" in o.exclude ? n[o.uid].hidden = o.exclude.from.some(
1113
+ (i) => e.currentStates.includes(i)
1114
+ ) : o.exclude && "when" in o.exclude && (n[o.uid].hidden = j(
1115
+ o.exclude.when,
1116
+ e.data,
1117
+ e.meta,
1118
+ r,
1119
+ t
1120
+ )), (P(o) || re(o)) && z(o.disabled) && (n[o.uid].disabled = j(
1121
+ o.disabled.when,
1122
+ e.data,
1123
+ e.meta,
1124
+ r,
1125
+ t
1126
+ )), P(o) && z(o.readonly) && (n[o.uid].readonly = j(
1127
+ o.readonly.when,
1128
+ e.data,
1129
+ e.meta,
1130
+ r,
1131
+ t
1132
+ )), n),
872
1133
  {}
873
1134
  );
874
1135
  }
875
- function ne(e, r) {
876
- const t = A(e);
877
- return u(t)({
878
- $form: r,
879
- $log: (s, i) => (i ? console.log(i, s) : console.log(s), s)
880
- }) === !0;
1136
+ function Fn(e, r, t) {
1137
+ return vn(
1138
+ Object.values(e.flatForm),
1139
+ (n) => !se(n) && n.type === "repeater",
1140
+ (n, o) => ({
1141
+ ...n,
1142
+ ...Ur(e, o, [], r, t)
1143
+ }),
1144
+ {}
1145
+ );
881
1146
  }
882
- const Xt = (e) => !(typeof e != "object" || e === null || typeof e.key != "string");
883
- function Fn(e) {
1147
+ function Ur(e, r, t, n, o) {
1148
+ const i = r.props.template, s = N(e.data, r.path);
1149
+ if (!Array.isArray(s))
1150
+ return {};
1151
+ const u = {};
1152
+ return s.forEach((c, h) => {
1153
+ const A = [...t, h];
1154
+ Ke([i]).forEach((g) => {
1155
+ let f;
1156
+ if (se(g) ? (f = g({
1157
+ $form: e.data,
1158
+ errors: void 0,
1159
+ touched: void 0,
1160
+ translate: void 0
1161
+ }), f.uid = g.uid) : f = g, f.type === "repeater") {
1162
+ const ee = On(
1163
+ f,
1164
+ A
1165
+ );
1166
+ Object.assign(
1167
+ u,
1168
+ Ur(
1169
+ e,
1170
+ ee,
1171
+ A,
1172
+ n,
1173
+ o
1174
+ )
1175
+ );
1176
+ return;
1177
+ }
1178
+ const C = Vr(f.uid, A);
1179
+ u[C] = u[C] || {}, f.include && "in" in f.include ? u[C].hidden = !f.include.in.some((ee) => e.currentStates.includes(ee)) : f.include && "when" in f.include && (u[C].hidden = !j(
1180
+ le(f.include.when, A),
1181
+ e.data,
1182
+ e.meta,
1183
+ n,
1184
+ o
1185
+ )), f.exclude && "from" in f.exclude ? u[C].hidden = f.exclude.from.some((ee) => e.currentStates.includes(ee)) : f.exclude && "when" in f.exclude && (u[C].hidden = j(
1186
+ le(f.exclude.when, A),
1187
+ e.data,
1188
+ e.meta,
1189
+ n,
1190
+ o
1191
+ )), (P(f) || re(f)) && z(f.disabled) && (u[C].disabled = j(
1192
+ le(
1193
+ f.disabled.when,
1194
+ A
1195
+ ),
1196
+ e.data,
1197
+ e.meta,
1198
+ n,
1199
+ o
1200
+ )), P(f) && z(f.readonly) && (u[C].readonly = j(
1201
+ le(
1202
+ f.readonly.when,
1203
+ A
1204
+ ),
1205
+ e.data,
1206
+ e.meta,
1207
+ n,
1208
+ o
1209
+ ));
1210
+ });
1211
+ }), u;
1212
+ }
1213
+ const Dn = (e) => !(typeof e != "object" || e === null || typeof e.key != "string");
1214
+ function Oo(e) {
884
1215
  const r = new Intl.Locale(e).maximize().script;
885
1216
  return ["Arab", "Hebr", "Thaa", "Syrc", "Tfng", "Adlm", "Rohg"].includes(r || "") ? "rtl" : "ltr";
886
1217
  }
887
- const Qt = (e = navigator.language || "en-US") => ({
888
- /**
889
- * Returns a generic fallback language code.
890
- */
891
- get lang() {
892
- return e;
893
- },
894
- /**
895
- * Returns the provided translation key without modification.
896
- *
897
- * @param key - Translation key
898
- * @returns The key itself
899
- */
900
- translate(r) {
901
- return r;
902
- },
903
- /**
904
- * No-op teardown function since state never changes.
905
- */
906
- subscribe() {
907
- return () => {
908
- };
1218
+ const Pn = (e = navigator.language || "en-US") => {
1219
+ const r = /* @__PURE__ */ new Set();
1220
+ return {
1221
+ get lang() {
1222
+ return e;
1223
+ },
1224
+ translate(n) {
1225
+ return n;
1226
+ },
1227
+ subscribe(n) {
1228
+ return r.add(n), () => {
1229
+ r.delete(n);
1230
+ };
1231
+ },
1232
+ setLang(n) {
1233
+ e = n, r.forEach((o) => o(e));
1234
+ }
1235
+ };
1236
+ }, M = (e) => (r) => ({
1237
+ ...r,
1238
+ calculatedWidgets: Wn(r, e)
1239
+ });
1240
+ function Wn(e, r) {
1241
+ const { $formIsInvalid: t, $errors: n } = Xe(e), o = Jn(e, r, t, n), i = {};
1242
+ for (const s of Object.keys(e.calculatedWidgets)) {
1243
+ if (e.widgetFlags[s]?.hidden)
1244
+ continue;
1245
+ const u = e.calculatedWidgets[s], c = u.source;
1246
+ if (se(c)) {
1247
+ i[s] = Tn(s, c, e, r);
1248
+ continue;
1249
+ }
1250
+ i[s] = Rn(
1251
+ u,
1252
+ c,
1253
+ e,
1254
+ o
1255
+ );
909
1256
  }
910
- }), xt = (e) => typeof e == "string" && !e.includes(" ") && (e.startsWith("$form.") || e.startsWith("$error.") || e.startsWith("$meta.")), B = (e, r) => {
911
- if (e === void 0)
912
- throw new Error("obj is undefined");
913
- return r.split(".").reduce((t, n) => t === void 0 || n === "" ? t : Array.isArray(t) ? t[parseInt(n, 10)] : t[n], e);
914
- }, ie = (e, r, t) => {
915
- if (e === null)
916
- throw new Error("object is null");
917
- if (e === void 0)
918
- throw new Error("object is undefined");
919
- if (r === "")
920
- throw new Error("path cannot be empty");
921
- const n = r.split(".");
922
- let o = e;
923
- for (let i = 0; i < n.length - 1; i++) {
924
- const d = n[i], c = n[i + 1];
925
- (o[d] == null || typeof o[d] != "object") && (o[d] = Zt(c) ? [] : {}), o = o[d];
1257
+ return i;
1258
+ }
1259
+ function Tn(e, r, t, n) {
1260
+ const o = r({
1261
+ $form: t.data,
1262
+ errors: r.path ? t.validations[r.path] : void 0,
1263
+ touched: r.path ? t.touchedControls[r.path] : void 0,
1264
+ translate: n.translate
1265
+ });
1266
+ return o.uid = e, { source: r, current: o };
1267
+ }
1268
+ function Rn(e, r, t, n) {
1269
+ const o = new zn(r, e.current);
1270
+ return o.write("uid", r.uid), o.write("type", r.type), o.write("kind", r.kind), st(r) ? kn(o, n) : re(r) ? _n(o, n) : P(r) ? Nn(o, n) : _e(r) && Ln(o, n), Mn(r, o, n, t), (re(r) || P(r)) && jn(r, o, n), _e(r) && Vn(r, o, t), o.changed ? { source: e.source, current: o.current } : e;
1271
+ }
1272
+ function kn(e, r) {
1273
+ S(e, r, "size"), S(e, r, "include"), S(e, r, "exclude");
1274
+ }
1275
+ function _n(e, r) {
1276
+ S(e, r, "size"), S(e, r, "include"), S(e, r, "exclude"), S(e, r, "label"), S(e, r, "disabled");
1277
+ }
1278
+ function Nn(e, r) {
1279
+ S(e, r, "size"), S(e, r, "include"), S(e, r, "exclude"), S(e, r, "label"), S(e, r, "disabled"), S(e, r, "readonly"), S(e, r, "validator"), S(e, r, "path"), S(e, r, "defaultValue");
1280
+ }
1281
+ function Ln(e, r) {
1282
+ S(e, r, "size"), S(e, r, "include"), S(e, r, "exclude");
1283
+ }
1284
+ function Mn(e, r, t, n) {
1285
+ const o = n.widgetPropOverrides[e.uid] ?? {}, i = { ...e.props ?? {}, ...o };
1286
+ for (const s of Gr(Object.keys(i)))
1287
+ Un(r, t, s);
1288
+ }
1289
+ function jn(e, r, t) {
1290
+ const n = e.on ?? {};
1291
+ for (const o of Gr(Object.keys(n)))
1292
+ Bn(r, t, o);
1293
+ }
1294
+ function Vn(e, r, t) {
1295
+ const n = Yn(e.uid), o = qn(e.children, n, t.widgetFlags);
1296
+ r.current.children = o;
1297
+ const i = r.previous.children ?? [];
1298
+ i.length === o.length && o.every((u, c) => i[c] && i[c].uid === o[c].uid) || r.markChanged();
1299
+ }
1300
+ function S(e, r, t) {
1301
+ const n = e.source;
1302
+ if (!Qn(n, t))
1303
+ return;
1304
+ const o = ir(n, t, r.sortedStates);
1305
+ let i;
1306
+ switch (t) {
1307
+ case "disabled":
1308
+ case "readonly":
1309
+ i = Gn(o, r, e.source.uid, t);
1310
+ break;
1311
+ default:
1312
+ i = Hr(o, r);
926
1313
  }
927
- const s = n[n.length - 1];
928
- return o[s] = t, e;
929
- };
930
- function Zt(e) {
931
- const r = Number(e);
932
- return Number.isInteger(r) && r >= 0 && r.toString() === e;
1314
+ e.write(t, i);
933
1315
  }
934
- const oe = (e, r) => (delete e[r], e);
935
- function Tn(e) {
936
- return JSON.parse(JSON.stringify(e));
1316
+ function Un(e, r, t) {
1317
+ const n = e.source.props, o = ir(n, t, r.sortedStates);
1318
+ let i = Hr(o, r);
1319
+ const s = r.widgetPropOverrides[e.source.uid]?.[t];
1320
+ s !== void 0 && (i = s), e.write(`props.${t}`, i);
937
1321
  }
938
- const H = (e) => (r) => ({ ...r, calculatedWidgets: qt(r, e) }), Yt = (e, r) => ({
939
- source: e,
940
- previous: r,
941
- current: {},
942
- changed: !1
943
- });
944
- function Ee(e) {
945
- return Array.from(new Set(e.map((r) => r.split(".")[0])));
1322
+ function Bn(e, r, t) {
1323
+ const n = e.source.on, o = ir(n, t, r.sortedStates);
1324
+ e.write(`on.${t}`, Kn(o, r));
946
1325
  }
947
- function qt(e, r) {
948
- return Object.keys(e.calculatedWidgets).reduce(
949
- (t, n) => {
950
- if (e.widgetFlags[n] !== void 0 && e.widgetFlags[n].hidden)
951
- return t;
952
- const o = e.calculatedWidgets[n], s = o.source;
953
- if (Pe(s))
954
- return o.previous = o.current, o.current = s({
955
- $form: e.data,
956
- errors: s.path ? e.validations[s.path] : void 0,
957
- touched: s.path ? e.touchedControls[s.path] : void 0,
958
- translate: r.translate
959
- }), o.current.uid = n, t[n] = { ...o }, t;
960
- const i = Yt(
961
- s,
962
- // previous is the new current
963
- o.current
964
- );
965
- Ee(Object.keys(s)).filter((c) => c !== "props" && c !== "on").forEach((c) => {
966
- Oe({
967
- currentStates: e.currentStates,
968
- widgetPropOverrides: e.widgetPropOverrides,
969
- derivedWidget: i,
970
- property: c,
971
- $form: e.data,
972
- widgetFlags: e.widgetFlags,
973
- localization: r
974
- });
975
- });
976
- const d = {
977
- ...s.props || {},
978
- // We may have overridden properties that aren't set on the original object, so we need to account for them
979
- ...e.widgetPropOverrides[s.uid]
980
- };
981
- if (Ee(Object.keys(d)).forEach((c) => {
982
- Oe({
983
- currentStates: e.currentStates,
984
- widgetPropOverrides: e.widgetPropOverrides,
985
- derivedWidget: i,
986
- property: "props",
987
- subProp: c,
988
- $form: e.data,
989
- widgetFlags: e.widgetFlags,
990
- localization: r
991
- });
992
- }), (_(s) || De(s)) && Ee(Object.keys(s.on || {})).forEach((c) => {
993
- Oe({
994
- currentStates: e.currentStates,
995
- widgetPropOverrides: e.widgetPropOverrides,
996
- derivedWidget: i,
997
- property: "on",
998
- // TODO: type hack: "on" is not a CoreProp
999
- subProp: c,
1000
- $form: e.data,
1001
- widgetFlags: e.widgetFlags,
1002
- localization: r
1003
- });
1004
- }), er(s)) {
1005
- const c = i.previous.children || [], f = s.children.filter((y) => !e.widgetFlags[y.uid] || e.widgetFlags[y.uid].hidden !== !0);
1006
- i.current.children = f, i.changed = c.length !== f.length || !f.every(
1007
- (y, h) => c[h] && c[h].uid === f[h].uid
1008
- );
1009
- }
1010
- return t[n] = i.changed ? i : o, delete t[n].changed, t;
1011
- },
1012
- {}
1013
- );
1326
+ function or(e, r) {
1327
+ return e({ $form: r.$form, translate: r.localization.translate });
1014
1328
  }
1015
- function Oe({
1016
- currentStates: e,
1017
- widgetPropOverrides: r,
1018
- derivedWidget: t,
1019
- property: n,
1020
- subProp: o,
1021
- $form: s,
1022
- widgetFlags: i,
1023
- localization: d
1024
- }) {
1025
- const c = e.sort((h, S) => S.length - h.length).find((h) => (o ? t.source?.[
1026
- n
1027
- /* | 'on' */
1028
- ]?.[`${o}.${h}`] : t.source[`${n}.${h}`]) !== void 0);
1029
- let f;
1030
- c === void 0 ? f = o ? t.source[n]?.[o] : t.source[n] : f = o ? t.source[
1031
- n
1032
- /* | 'on */
1033
- ]?.[`${o}.${c}`] : t.source[`${n}.${c}`];
1034
- const y = o ? `${n}.${o}` : n;
1035
- typeof f == "function" ? ie(t.current, y, f({ $form: s, translate: d.translate })) : (Xt(f) && (f = d.translate(
1036
- f.key,
1037
- zt(f.params, s),
1038
- f.default
1039
- )), (n === "disabled" || n === "readonly") && x(f) && (f = i[t.current.uid][n]), ie(t.current, y, f)), n === "props" && o && r[t.source.uid] && r[t.source.uid][o] !== void 0 && ie(t.current, y, r[t.source.uid][o]), B(t.previous, y) !== B(t.current, y) && (t.changed = !0);
1040
- }
1041
- const zt = (e, r) => e && Object.keys(e).reduce((t, n) => {
1042
- const o = String(e[n]);
1043
- if (xt(o)) {
1044
- const s = o.replace("$form.", "");
1045
- t[n] = B(r, s) || o;
1046
- } else
1047
- t[n] = o;
1048
- return t;
1049
- }, {});
1050
- function Ir(e) {
1051
- return e.flatMap((r) => [
1052
- r,
1053
- ...er(r) ? Ir(r.children) : []
1054
- ]);
1329
+ function Hn(e, r) {
1330
+ return r.localization.translate(e.key, Xn(e.params, r), e.default);
1331
+ }
1332
+ function Br(e, r) {
1333
+ return vt(e, {
1334
+ resolveFormPath: (t) => N(r.$form, t) ?? e,
1335
+ resolveMetaPath: (t) => N(r.$meta, t) ?? e,
1336
+ resolveErrorsPath: (t) => N(r.$errors, t) ?? e,
1337
+ resolveFormIsInvalid: () => String(r.$formIsInvalid)
1338
+ });
1339
+ }
1340
+ function Hr(e, r) {
1341
+ return typeof e == "function" ? or(e, r) : Dn(e) ? Hn(e, r) : typeof e == "string" ? Br(e, r) : e;
1342
+ }
1343
+ function Gn(e, r, t, n) {
1344
+ return typeof e == "function" ? or(e, r) : z(e) ? r.widgetFlags[t]?.[n] : typeof e == "string" ? Br(e, r) : e;
1345
+ }
1346
+ function Kn(e, r) {
1347
+ return typeof e == "function" ? or(e, r) : e;
1348
+ }
1349
+ function ir(e, r, t) {
1350
+ if (e) {
1351
+ for (const n of t) {
1352
+ const o = e[`${r}.${n}`];
1353
+ if (o !== void 0)
1354
+ return o;
1355
+ }
1356
+ return e[r];
1357
+ }
1358
+ }
1359
+ function Xn(e, r) {
1360
+ return e && Object.keys(e).reduce((t, n) => {
1361
+ const o = String(e[n]);
1362
+ return At(o) ? t[n] = It(o, {
1363
+ resolveFormPath: (i) => N(r.$form, i) ?? o,
1364
+ resolveMetaPath: (i) => N(r.$meta, i) ?? o,
1365
+ resolveErrorsPath: (i) => N(r.$errors, i) ?? o,
1366
+ resolveFormIsInvalid: () => r.$formIsInvalid
1367
+ }) : t[n] = o, t;
1368
+ }, {});
1055
1369
  }
1056
- const bt = ({ lang: e }, r) => {
1370
+ class zn {
1371
+ constructor(r, t) {
1372
+ this._changed = !1, this.source = r, this.previous = t, this.current = {};
1373
+ }
1374
+ get changed() {
1375
+ return this._changed;
1376
+ }
1377
+ markChanged() {
1378
+ this._changed = !0;
1379
+ }
1380
+ write(r, t) {
1381
+ Ge(this.current, r, t), N(this.previous, r) !== t && (this._changed = !0);
1382
+ }
1383
+ }
1384
+ function Jn(e, r, t, n) {
1385
+ return {
1386
+ sortedStates: [...e.currentStates].sort((o, i) => i.length - o.length),
1387
+ widgetPropOverrides: e.widgetPropOverrides,
1388
+ widgetFlags: e.widgetFlags,
1389
+ $form: e.data,
1390
+ $meta: e.meta,
1391
+ $formIsInvalid: t,
1392
+ $errors: n,
1393
+ localization: r
1394
+ };
1395
+ }
1396
+ function Qn(e, r) {
1397
+ if (r in e)
1398
+ return !0;
1399
+ const t = `${r}.`;
1400
+ return Object.keys(e).some((n) => n.startsWith(t));
1401
+ }
1402
+ function Gr(e) {
1403
+ return Array.from(new Set(e.map((r) => r.split(".")[0])));
1404
+ }
1405
+ function qn(e, r, t) {
1406
+ const n = r.map((o) => `[${o}]`).join("");
1407
+ return e.filter((o) => {
1408
+ const i = o.uid + n, s = t[i];
1409
+ return !s || s.hidden !== !0;
1410
+ });
1411
+ }
1412
+ const Yn = (e) => [...e.matchAll(/\[(\d+)\]/g)].map((r) => parseInt(r[1], 10)), Zn = ({ lang: e }, r) => {
1057
1413
  const t = {
1058
- ...nr(e),
1414
+ ...mr(e),
1059
1415
  formName: r.payload.formName
1060
1416
  };
1061
1417
  let n = r.payload.formDef, o = { status: "ok" };
1062
1418
  if (typeof n == "string") {
1063
1419
  try {
1064
1420
  n = JSON.parse(n);
1065
- } catch (i) {
1421
+ } catch (u) {
1422
+ const c = u, h = ae.initializeParseError;
1066
1423
  o = {
1067
1424
  status: "errored",
1068
- message: i.message
1425
+ message: `[${h}] ${c.message}`,
1426
+ code: h
1069
1427
  };
1070
1428
  }
1071
1429
  if (o.status === "errored")
1072
1430
  return { ...t, formHealth: o };
1073
1431
  }
1074
1432
  if (Array.isArray(n.form)) {
1075
- const i = n, d = i.form;
1076
- i.form = {
1433
+ const u = n, c = u.form;
1434
+ u.form = {
1077
1435
  uid: "",
1078
1436
  type: "flex",
1079
1437
  kind: "layout",
1080
- children: d
1438
+ children: c
1081
1439
  };
1082
1440
  }
1083
- const s = tr.decode(n);
1084
- if (s.isOk()) {
1441
+ const i = gr.decode(n);
1442
+ if (i.isOk()) {
1085
1443
  o = { status: "ok" };
1086
- let i = {};
1444
+ let u = {};
1087
1445
  try {
1088
- i = Ir([s.value.form]).reduce(
1089
- (d, c) => {
1090
- if (d[c.uid])
1091
- throw { existingWidget: d[c.uid], newWidget: c };
1092
- return d[c.uid] = c, d;
1446
+ u = Ke([i.value.form]).reduce(
1447
+ (c, h) => {
1448
+ if (c[h.uid])
1449
+ throw { existingWidget: c[h.uid], newWidget: h };
1450
+ return c[h.uid] = h, c;
1093
1451
  },
1094
1452
  {}
1095
1453
  );
1096
- } catch (d) {
1454
+ } catch (c) {
1455
+ const h = ae.initializeUidCollisionError;
1097
1456
  o = {
1098
1457
  status: "errored",
1099
- message: en(d.existingWidget, d.newWidget)
1100
- }, i = {};
1458
+ message: `[${h}] ${xn(c.existingWidget, c.newWidget)}`,
1459
+ code: h
1460
+ }, u = {};
1101
1461
  }
1102
1462
  return {
1103
1463
  ...t,
1104
- formDef: s.value,
1105
- flatForm: i,
1464
+ formDef: i.value,
1465
+ flatForm: u,
1106
1466
  formHealth: o
1107
1467
  };
1108
1468
  }
1469
+ const s = ae.initializeUnknownError;
1109
1470
  return {
1110
1471
  ...t,
1111
1472
  formHealth: {
1112
1473
  status: "errored",
1113
- message: s.error
1474
+ message: `[${s}] ${i.error}`,
1475
+ code: s
1114
1476
  }
1115
1477
  };
1116
1478
  };
1117
- function en(e, r) {
1118
- const t = (n) => _(n) ? ` at "${n.path}"` : "";
1479
+ function xn(e, r) {
1480
+ const t = (n) => P(n) ? ` at "${n.path}"` : "";
1119
1481
  return `Duplicate UID "${r.uid}": Assigned to widget "${e.type}"${t(e)} and "${r.type}"${t(r)}.`;
1120
1482
  }
1121
- function rn(e, r) {
1483
+ function bn(e, r) {
1122
1484
  return {
1123
1485
  ...e,
1124
1486
  injectedValidations: {
@@ -1127,194 +1489,208 @@ function rn(e, r) {
1127
1489
  }
1128
1490
  };
1129
1491
  }
1130
- const tn = (e, { payload: r }) => {
1131
- const t = Object.values(e.calculatedWidgets).find(
1132
- ({ source: o }) => _(o) && o.path === r.path
1133
- );
1134
- if (!t)
1135
- return console.warn(`Control "${r.path}" not found`), e;
1492
+ const eo = (e, { payload: r }) => {
1493
+ let t;
1494
+ if ("path" in r) {
1495
+ if (t = Object.values(e.calculatedWidgets).find(
1496
+ ({ source: o }) => P(o) && o.path === r.path
1497
+ ), !t)
1498
+ return console.warn(`Input with path "${r.path}" not found`), e;
1499
+ } else if (t = e.calculatedWidgets[r.uid], !t)
1500
+ return console.warn(`Widget with uid "${r.uid}" not found`), e;
1136
1501
  const n = e.widgetPropOverrides[t.source.uid] || {};
1137
1502
  return {
1138
1503
  ...e,
1139
1504
  widgetPropOverrides: {
1505
+ ...e.widgetPropOverrides,
1140
1506
  [t.source.uid]: { ...n, [r.prop]: r.value }
1141
1507
  }
1142
1508
  };
1143
1509
  };
1144
- function nn(e, r) {
1510
+ function ro(e, r) {
1145
1511
  return {
1146
1512
  ...e,
1147
1513
  widgetFlags: {
1148
- ...oe(e.widgetFlags, r.payload.uid)
1514
+ ...ce(e.widgetFlags, r.payload.uid)
1149
1515
  },
1150
1516
  // TODO: has this already been removed in calculate-widget-props??? Do we need this at all?
1151
1517
  calculatedWidgets: {
1152
- ...oe(e.calculatedWidgets, r.payload.uid)
1518
+ ...ce(e.calculatedWidgets, r.payload.uid)
1153
1519
  },
1154
1520
  widgetPropOverrides: {
1155
- ...oe(e.widgetPropOverrides, r.payload.uid)
1521
+ ...ce(e.widgetPropOverrides, r.payload.uid)
1156
1522
  },
1157
1523
  touchedControls: {
1158
- ...W(e.touchedControls, (t) => {
1524
+ ...L(e.touchedControls, (t) => {
1159
1525
  const n = e.flatForm[r.payload.uid];
1160
- return n && _(n) ? oe(t, n.path) : t;
1526
+ return n && P(n) ? ce(t, n.path) : t;
1161
1527
  })
1162
1528
  }
1163
1529
  // TODO: clear widget from injectedValidations
1164
1530
  };
1165
1531
  }
1166
- const on = (e, r) => ({
1532
+ const to = (e, r) => ({
1167
1533
  ...e,
1168
1534
  data: { ...r.payload.data }
1169
- }), sn = (e, r) => {
1170
- const t = B(e.data, r.payload.path);
1171
- return r.type === "SET_WIDGET_DATA" || r.type === "SET_WIDGET_INITIAL_DATA" && t === void 0 ? {
1172
- ...e,
1173
- data: { ...ie(e.data, r.payload.path, r.payload.data) }
1174
- } : e;
1175
- }, un = (e, r) => ({
1535
+ }), no = (e, r) => ({
1176
1536
  ...e,
1177
1537
  formHealth: r.payload.formHealth
1178
- }), dn = (e, r) => ({
1538
+ }), oo = (e, r) => ({
1179
1539
  ...e,
1180
1540
  lang: r.payload.lang
1181
- });
1182
- function cn(e, r) {
1541
+ }), io = (e, r) => ({
1542
+ ...e,
1543
+ meta: { ...r.payload.meta }
1544
+ }), so = (e, r) => {
1545
+ const t = N(e.data, r.payload.path);
1546
+ return r.type === "SET_WIDGET_DATA" || r.type === "SET_WIDGET_INITIAL_DATA" && t === void 0 ? {
1547
+ ...e,
1548
+ data: { ...Ge(e.data, r.payload.path, r.payload.data) }
1549
+ } : e;
1550
+ };
1551
+ function uo(e, r) {
1183
1552
  const t = e["~standard"].validate(r);
1184
1553
  if (t instanceof Promise)
1185
1554
  throw new TypeError("Schema validation must be synchronous");
1186
1555
  return t;
1187
1556
  }
1188
- function ln(e) {
1557
+ function co(e) {
1189
1558
  return e.issues === void 0;
1190
1559
  }
1191
- const Cr = Symbol("filterMap.skip");
1192
- function fn(e, r) {
1193
- const t = [];
1194
- for (let n = 0; n < e.length; n++) {
1195
- const o = r(e[n], n, e);
1196
- o !== Cr && t.push(o);
1197
- }
1198
- return t;
1199
- }
1200
- function an(e, r, t) {
1201
- if (e.length !== r.length)
1202
- return !1;
1203
- for (let n = 0; n < e.length; n++)
1204
- if (!t(e[n], r[n], n, e, r))
1205
- return !1;
1206
- return !0;
1207
- }
1208
- const Ie = (e) => (r) => {
1209
- const t = fn(
1210
- Object.values(r.calculatedWidgets),
1211
- ({ current: o }) => _(o) ? o : Cr
1212
- ), n = r.validations;
1560
+ const We = (e, r) => (t) => {
1561
+ const n = jr(
1562
+ Object.values(t.calculatedWidgets),
1563
+ ({ current: i }) => P(i) ? i : nr
1564
+ ), o = t.validations;
1213
1565
  return {
1214
- ...r,
1215
- validations: t.reduce(
1216
- (o, s) => {
1217
- if (o[s.path] = null, s.validator) {
1218
- const i = e(s.validator), d = B(r.data, s.path), c = cn(
1219
- i,
1220
- d
1566
+ ...t,
1567
+ validations: n.reduce(
1568
+ (i, s) => {
1569
+ if (i[s.path] = null, s.validator) {
1570
+ const u = e(s.validator, r), c = N(t.data, s.path), h = uo(
1571
+ u,
1572
+ c
1221
1573
  );
1222
- o[s.path] = ln(c) ? null : c.issues.map((f) => f.message);
1574
+ i[s.path] = co(h) ? null : h.issues.map((A) => A.message);
1223
1575
  }
1224
- return Array.isArray(o[s.path]) && Array.isArray(n[s.path]) && an(
1576
+ return Array.isArray(i[s.path]) && Array.isArray(o[s.path]) && In(
1577
+ i[s.path],
1225
1578
  o[s.path],
1226
- n[s.path],
1227
- (i, d) => i === d
1228
- ) && (o[s.path] = n[s.path]), o;
1579
+ (u, c) => u === c
1580
+ ) && (i[s.path] = o[s.path]), i;
1229
1581
  },
1230
1582
  {}
1231
1583
  )
1232
1584
  };
1233
- }, hn = ({
1585
+ }, lo = ({
1234
1586
  validators: e,
1235
1587
  validateOn: r,
1236
1588
  localization: t
1237
1589
  }) => (n, o) => {
1238
1590
  switch (o.type) {
1239
1591
  case "INITIALIZE":
1240
- return bt(n, o);
1592
+ return Zn(n, o);
1241
1593
  case "SET_DATA":
1242
- return W(
1243
- on(n, o),
1244
- X,
1245
- Q,
1246
- H(t)
1594
+ return L(
1595
+ to(n, o),
1596
+ V,
1597
+ U,
1598
+ M(t)
1599
+ );
1600
+ case "SET_META":
1601
+ return L(
1602
+ io(n, o),
1603
+ V,
1604
+ U,
1605
+ M(t)
1247
1606
  );
1248
1607
  case "SET_LANGUAGE":
1249
- return W(
1250
- dn(n, o),
1251
- H(t)
1608
+ return L(
1609
+ oo(n, o),
1610
+ M(t)
1252
1611
  );
1253
1612
  case "ADD_WIDGET":
1254
- return W(
1255
- Yr(n, o),
1256
- te(Ce, X),
1257
- te(Ce, Q),
1258
- te(Ce, H(t))
1613
+ return L(
1614
+ yt(n, o),
1615
+ fe(Te, V),
1616
+ fe(Te, U),
1617
+ fe(Te, M(t))
1259
1618
  );
1260
1619
  case "REMOVE_WIDGET":
1261
- return W(
1262
- nn(n, o),
1263
- X,
1264
- Q,
1265
- H(t)
1620
+ return L(
1621
+ ro(n, o),
1622
+ V,
1623
+ U,
1624
+ M(t)
1266
1625
  );
1267
1626
  case "SET_WIDGET_INITIAL_DATA":
1268
1627
  case "SET_WIDGET_DATA":
1269
- return W(
1270
- sn(n, o),
1271
- X,
1272
- Q,
1273
- H(t)
1628
+ return L(
1629
+ so(n, o),
1630
+ V,
1631
+ U,
1632
+ M(t)
1274
1633
  );
1275
1634
  case "OVERRIDE_WIDGET_PROP":
1276
- return W(
1277
- tn(n, o),
1278
- X,
1279
- Q,
1280
- H(t),
1635
+ return L(
1636
+ eo(n, o),
1637
+ V,
1638
+ U,
1639
+ M(t),
1281
1640
  // Apply validation here because this action can be dispatched from the form's event handlers callback
1282
- te(Kt(o.payload.path), Ie(e))
1641
+ // Apply only when the action is related to an input
1642
+ fe(
1643
+ (i) => {
1644
+ let s = !1, u = "";
1645
+ "path" in o.payload ? (s = !0, u = o.payload.path) : P(i.calculatedWidgets[o.payload.uid].current) && (s = !0, u = i.calculatedWidgets[o.payload.uid].current.path);
1646
+ const c = s && i.touchedControls[u];
1647
+ return i.touched && c;
1648
+ },
1649
+ We(e, t)
1650
+ )
1283
1651
  );
1284
1652
  case "SET_FORM_HEALTH":
1285
- return un(n, o);
1653
+ return no(n, o);
1286
1654
  case "VALIDATE_ALL":
1287
- return W(
1655
+ return L(
1288
1656
  {
1289
1657
  ...n,
1290
1658
  touched: !0,
1291
1659
  touchedControls: Object.keys(n.calculatedWidgets).reduce(
1292
- (s, i) => {
1293
- const d = n.calculatedWidgets[i].source;
1294
- return _(d) && (s[d.path] = !0), s;
1660
+ (i, s) => {
1661
+ const u = n.calculatedWidgets[s].source;
1662
+ return P(u) && (i[u.path] = !0), i;
1295
1663
  },
1296
1664
  {}
1297
1665
  )
1298
1666
  },
1299
- Ie(e)
1667
+ We(e, t),
1668
+ // This handles $errors and $formIsValid expressions variables
1669
+ V,
1670
+ U,
1671
+ M(t)
1300
1672
  );
1301
1673
  case "ATTEMPT_VALIDATION": {
1302
- const s = o.payload.reason, i = o.payload.path;
1303
- return r === "eager" || s === r || r.includes(s) ? W(
1674
+ const i = o.payload.reason, s = o.payload.path;
1675
+ return r === "eager" || i === r || r.includes(i) ? L(
1304
1676
  {
1305
1677
  ...n,
1306
1678
  touched: !0,
1307
- touchedControls: { ...n.touchedControls, [i]: !0 }
1679
+ touchedControls: { ...n.touchedControls, [s]: !0 }
1308
1680
  },
1309
- Ie(e),
1681
+ We(e, t),
1682
+ // This handles $errors and $formIsValid expressions variables
1683
+ V,
1684
+ U,
1685
+ M(t),
1310
1686
  // TODO: extract this into a separate function
1311
1687
  // When the widget is a Widget Function, we propagate the validation result immediately
1312
1688
  (c) => {
1313
- const f = o.payload.uid, y = c.calculatedWidgets[f], h = y.source;
1314
- if (Pe(h)) {
1315
- const S = h({
1689
+ const h = o.payload.uid, A = c.calculatedWidgets[h], g = A.source;
1690
+ if (se(g)) {
1691
+ const f = g({
1316
1692
  $form: c.data,
1317
- errors: c.validations[i],
1693
+ errors: c.validations[s],
1318
1694
  touched: !0,
1319
1695
  translate: t.translate
1320
1696
  });
@@ -1322,10 +1698,9 @@ const Ie = (e) => (r) => {
1322
1698
  ...c,
1323
1699
  calculatedWidgets: {
1324
1700
  ...c.calculatedWidgets,
1325
- [f]: {
1326
- ...y,
1327
- previous: y.current,
1328
- current: S
1701
+ [h]: {
1702
+ source: A.source,
1703
+ current: f
1329
1704
  }
1330
1705
  }
1331
1706
  };
@@ -1335,120 +1710,43 @@ const Ie = (e) => (r) => {
1335
1710
  ) : n;
1336
1711
  }
1337
1712
  case "INJECT_VALIDATION_ISSUES":
1338
- return rn(n, o);
1713
+ return bn(n, o);
1339
1714
  default:
1340
- return Zr(o);
1715
+ return mt(o);
1341
1716
  }
1342
- }, Ce = (e) => e.formHealth.status === "ok";
1343
- function pn(e = [], r, t, n) {
1344
- const o = new Dr(nr(n.lang)), s = o.asObservable().pipe(w()), i = hn({ validators: r, validateOn: t, localization: n });
1345
- function d(h) {
1346
- const S = o.getValue(), j = i(S, h);
1347
- o.next(j);
1717
+ }, Te = (e) => e.formHealth.status === "ok";
1718
+ function fo(e = [], r, t, n) {
1719
+ const o = new zr(mr(n.lang)), i = o.asObservable().pipe(D()), s = lo({ validators: r, validateOn: t, localization: n });
1720
+ function u(g) {
1721
+ const f = o.getValue(), C = s(f, g);
1722
+ o.next(C);
1348
1723
  }
1349
- let c = d;
1350
- const f = {
1724
+ let c = u;
1725
+ const h = {
1351
1726
  getState: () => o.getValue(),
1352
- dispatch: (h) => c(h)
1727
+ dispatch: (g) => c(g)
1353
1728
  // reference is updated later
1354
1729
  };
1355
- return c = e.map((h) => h(f)).reduceRight((h, S) => S(h), d), {
1356
- state$: s,
1730
+ return c = e.map((g) => g(h)).reduceRight((g, f) => f(g), u), {
1731
+ state$: i,
1357
1732
  dispatch: c,
1358
1733
  getState: () => o.getValue()
1359
1734
  };
1360
1735
  }
1361
- const gn = D(
1362
- I((e) => e.data),
1363
- w()
1364
- ), _n = (e) => D(
1365
- gn,
1366
- I((r) => B(r, e)),
1367
- w()
1368
- ), yn = D(
1369
- ae((e) => e.touched === !0),
1370
- I((e) => e.validations),
1371
- w()
1372
- ), Wn = (e) => D(
1373
- yn,
1374
- I((r) => r[e]),
1375
- w()
1376
- ), mn = D(
1377
- ae((e) => e.touched === !0),
1378
- I((e) => e.injectedValidations),
1379
- w()
1380
- ), Pn = (e) => D(
1381
- mn,
1382
- I((r) => r[e]),
1383
- w(),
1384
- // we want to make sure combineLatest([validation$, injectedValidation$]) triggers
1385
- kr(null)
1386
- ), wr = D(
1387
- I((e) => e.calculatedWidgets),
1388
- w()
1389
- ), Nn = (e) => D(
1390
- wr,
1391
- I((r) => r[e]),
1392
- ae((r) => r !== void 0),
1393
- I((r) => r.current),
1394
- w()
1395
- ), jn = (e) => D(
1396
- wr,
1397
- I((r) => r[e]),
1398
- ae((r) => r !== void 0),
1399
- I((r) => r.current.children),
1400
- w()
1401
- ), An = D(
1402
- I((e) => e.widgetFlags),
1403
- w()
1404
- ), Ln = (e) => D(
1405
- An,
1406
- I((r) => r[e]),
1407
- w()
1408
- ), Sn = D(
1409
- I((e) => e.touchedControls),
1410
- w()
1411
- ), Rn = (e) => D(
1412
- Sn,
1413
- I((r) => r[e]),
1414
- w()
1415
- ), $n = D(
1416
- I((e) => e.formHealth),
1417
- w(
1418
- (e, r) => !(e.status !== r.status || e.status === "errored")
1419
- )
1420
- ), Un = (e) => e.pipe($n);
1421
- class vn {
1736
+ class wo {
1422
1737
  constructor() {
1423
- this.registry = {}, this.widgetLoaders = {}, this._ready = !1;
1738
+ this.widgetRegistry = new Re(), this.store = {}, this.events$ = new Jr(), this.uuid = crypto.randomUUID(), this.itemRenderers = {}, this.dependencies = {};
1424
1739
  }
1425
- /**
1426
- * When the registry has been initialized by calling `setWidgetLoaders`
1427
- */
1428
- get ready() {
1429
- return this._ready;
1430
- }
1431
- setWidgetLoaders(r) {
1432
- this.widgetLoaders = r, this._ready = !0;
1433
- }
1434
- async loadWidget(r) {
1435
- return this.registry[r] ?? (this.registry[r] = await this.widgetLoaders[r]());
1436
- }
1437
- }
1438
- class Vn {
1439
- constructor() {
1440
- this.widgetRegistry = new vn(), this.store = {}, this.events$ = new Fr(), this.uuid = crypto.randomUUID(), this.itemRenderers = {};
1441
- }
1442
- initialize(r, t = [], n, o, s, i = Qt()) {
1443
- this.localization = i, this.widgetRegistry.setWidgetLoaders(r), this.itemRenderers = s, this.store = pn(t, n, o, i);
1740
+ initialize(r, t = [], n, o, i, s = Pn(), u) {
1741
+ this.localization = s, this.dependencies = u, this.widgetRegistry.setWidgetLoaders(r), this.itemRenderers = i, this.store = fo(t, n, o, s);
1444
1742
  }
1445
1743
  emitEvent(r, t, n) {
1446
- const s = this.store.getState().currentStates.filter((i) => t.on?.[`${r}.${i}`] !== void 0);
1447
- if (s.length > 0)
1448
- s.forEach((i) => {
1449
- const d = t.on?.[`${r}.${i}`];
1450
- this.attemptValidation(r, d, t), d && this.events$.next({
1451
- name: d,
1744
+ const i = this.store.getState().currentStates.filter((s) => t.on?.[`${r}.${s}`] !== void 0);
1745
+ if (i.length > 0)
1746
+ i.forEach((s) => {
1747
+ const u = t.on?.[`${r}.${s}`];
1748
+ this.attemptValidation(r, u, t), u && this.events$.next({
1749
+ name: u,
1452
1750
  data: this.store.getState().data,
1453
1751
  detail: n ?? void 0,
1454
1752
  callback: (c) => {
@@ -1457,13 +1755,13 @@ class Vn {
1457
1755
  });
1458
1756
  });
1459
1757
  else {
1460
- const i = t.on?.[r];
1461
- this.attemptValidation(r, i, t), i && this.events$.next({
1462
- name: i,
1758
+ const s = t.on?.[r];
1759
+ this.attemptValidation(r, s, t), s && this.events$.next({
1760
+ name: s,
1463
1761
  data: this.store.getState().data,
1464
1762
  detail: n,
1465
- callback: (d) => {
1466
- this.store.dispatch(d);
1763
+ callback: (u) => {
1764
+ this.store.dispatch(u);
1467
1765
  }
1468
1766
  });
1469
1767
  }
@@ -1481,118 +1779,138 @@ class Vn {
1481
1779
  }));
1482
1780
  }
1483
1781
  }
1484
- function En(e) {
1485
- return e.$schema !== void 0 && e.$schema.startsWith("https://json-schema.org/draft");
1486
- }
1487
- const Hn = (e) => (r) => (t) => (n) => {
1488
- if (n.type === "INITIALIZE") {
1489
- let o = n.payload.formDef === "string" ? JSON.parse(n.payload.formDef) : n.payload.formDef;
1490
- En(o) && (o = Z(
1491
- o,
1492
- e,
1493
- // TODO: Implement Json Schema Ref resolver
1494
- () => {
1495
- throw new Error("Ref resolving not implemented");
1496
- }
1497
- ), o = {
1498
- form: o
1499
- }), t({ ...n, payload: { ...n.payload, formDef: o } });
1500
- } else
1501
- t(n);
1502
- };
1503
- function Z(e, r, t, n = []) {
1504
- if (e.$ref) {
1505
- const s = t(e.$ref);
1506
- return Z(s, r, t, n);
1507
- }
1508
- if (e.oneOf)
1509
- return {
1510
- ...r.oneOf(e),
1511
- props: {},
1512
- children: e.oneOf.map((i) => Z(i, r, t, n))
1513
- };
1514
- if (e.anyOf)
1515
- return {
1516
- ...r.anyOf(e),
1517
- props: {},
1518
- children: e.anyOf.map((i) => Z(i, r, t, n))
1782
+ function Co(e = "GolemUI Form Store") {
1783
+ return (r) => {
1784
+ const n = (typeof window < "u" ? window.__REDUX_DEVTOOLS_EXTENSION__ : void 0)?.connect({ name: e });
1785
+ return n?.init(r.getState()), (o) => (i) => {
1786
+ o(i), n && n.send(i, r.getState());
1519
1787
  };
1520
- if (e.type === "object") {
1521
- const s = [];
1522
- if (e.properties)
1523
- for (const [i, d] of Object.entries(e.properties)) {
1524
- const c = [...n, i], f = Z(d, r, t, c);
1525
- s.push(f);
1526
- }
1527
- return r.object(e, s);
1528
- }
1529
- if (e.type === "array")
1530
- throw new Error(`Arrays not supported yet at path: ${n.join(".")}`);
1531
- if (e.enum)
1532
- return r.enum(e, n.join("."));
1533
- const o = r[e.type];
1534
- return o ? o(e, n.join(".")) : r.fallback(e);
1535
- }
1536
- const Bn = {
1537
- log: (e, r) => (r ? console.log(r, e) : console.log(e), e)
1538
- };
1539
- function Gn(e, r) {
1540
- const t = On(e.uid, r);
1541
- return _(e) ? {
1542
- ...e,
1543
- uid: t,
1544
- path: In(e.path, r)
1545
- } : {
1546
- ...e,
1547
- uid: t
1548
1788
  };
1549
1789
  }
1550
- function On(e, r) {
1551
- if (r === -1)
1552
- throw new Error("-1 is an invalid Repeater index");
1553
- return `${e}[${r}]`;
1790
+ const ao = T(
1791
+ w((e) => e.data),
1792
+ D()
1793
+ ), Fo = (e) => T(
1794
+ ao,
1795
+ w((r) => N(r, e)),
1796
+ D()
1797
+ ), ho = T(
1798
+ Ee((e) => e.touched === !0),
1799
+ w((e) => e.validations),
1800
+ D()
1801
+ ), Do = (e) => T(
1802
+ ho,
1803
+ w((r) => r[e]),
1804
+ D()
1805
+ ), po = T(
1806
+ Ee((e) => e.touched === !0),
1807
+ w((e) => e.injectedValidations),
1808
+ D()
1809
+ ), Po = (e) => T(
1810
+ po,
1811
+ w((r) => r[e]),
1812
+ D(),
1813
+ // we want to make sure combineLatest([validation$, injectedValidation$]) triggers
1814
+ Qr(null)
1815
+ ), go = T(
1816
+ w((e) => e.lang),
1817
+ D()
1818
+ ), Kr = T(
1819
+ w((e) => e.calculatedWidgets),
1820
+ D()
1821
+ ), Wo = (e) => (r) => qr([r.pipe(go), r.pipe(Kr)]).pipe(
1822
+ w(([t, n]) => ({ lang: t, widget: n[e] })),
1823
+ Ee((t) => t.widget !== void 0),
1824
+ D((t, n) => t.lang === n.lang && t.widget === n.widget),
1825
+ w((t) => t.widget.current)
1826
+ ), To = (e) => T(
1827
+ Kr,
1828
+ w((r) => r[e]),
1829
+ Ee((r) => r !== void 0),
1830
+ w((r) => r.current.children),
1831
+ D()
1832
+ ), mo = T(
1833
+ w((e) => e.widgetFlags),
1834
+ D()
1835
+ ), Ro = (e) => T(
1836
+ mo,
1837
+ w((r) => r[e]),
1838
+ D()
1839
+ ), yo = T(
1840
+ w((e) => e.touchedControls),
1841
+ D()
1842
+ ), ko = (e) => T(
1843
+ yo,
1844
+ w((r) => r[e]),
1845
+ D()
1846
+ ), $o = T(
1847
+ w((e) => e.formHealth),
1848
+ D(
1849
+ (e, r) => !(e.status !== r.status || e.status === "errored")
1850
+ )
1851
+ ), _o = (e) => e.pipe($o);
1852
+ let Xr = !1;
1853
+ function No() {
1854
+ Xr = !0;
1554
1855
  }
1555
- function In(e, r) {
1556
- if (r === -1)
1557
- throw new Error("-1 is an invalid Repeater index");
1558
- return e.replace(".items.", `.${r}.`);
1856
+ function Ao() {
1857
+ return Xr;
1858
+ }
1859
+ function Lo(e, r, t) {
1860
+ if (!Ao())
1861
+ return;
1862
+ const n = Object.keys(r ?? {}).filter((o) => o in t);
1863
+ if (n.length > 0)
1864
+ throw new Error(
1865
+ `[GolemUI] Widget "${e}": prop keys [${n.join(", ")}] collide with widget fields`
1866
+ );
1559
1867
  }
1560
1868
  export {
1561
- Bn as Debug,
1562
- Vn as FormContext,
1563
- vn as WidgetRegistry,
1564
- jn as calculatedLayoutChildrenByUid$,
1565
- Nn as calculatedWidgetsByUid$,
1566
- Tn as cloneObject,
1567
- kn as compose,
1568
- pn as createFormStore,
1569
- nr as createInitialState,
1570
- _n as dataByPath$,
1571
- Dn as defineForm,
1572
- oe as deleteKey,
1573
- tr as formDefDecoder,
1574
- Un as formHealth,
1575
- B as get,
1576
- Fn as getDirectionFromLanguage,
1577
- Qt as identityTranslator,
1578
- Pn as injectedValidationByPath$,
1579
- De as isActionWidget,
1580
- wn as isDisplayWidget,
1581
- Pe as isFunctionWidget,
1582
- _ as isInputWidget,
1583
- En as isJsonSchema,
1584
- er as isLayoutWidget,
1585
- ln as isStandardValidateSuccess,
1586
- Xt as isTranslationConfig,
1587
- Hn as jsonSchemaMiddleware,
1588
- Le as layoutWidgetDecoder,
1589
- Gn as makeRepeaterItemConfig,
1590
- W as pipe,
1591
- An as selectWidgetFlags,
1592
- ie as set,
1593
- be as shortUUID,
1594
- cn as standardValidate,
1595
- Rn as touchedControlsByPath$,
1596
- Wn as validationByPath$,
1597
- Ln as widgetFlagsByUid$
1869
+ An as Debug,
1870
+ wo as FormContext,
1871
+ nr as SKIP,
1872
+ Re as WidgetRegistry,
1873
+ Lo as assertNoPropCollisions,
1874
+ To as calculatedLayoutChildrenByUid$,
1875
+ Wo as calculatedWidgetsByUid$,
1876
+ sr as cloneObject,
1877
+ vo as compose,
1878
+ fo as createFormStore,
1879
+ mr as createInitialState,
1880
+ Fo as dataByPath$,
1881
+ So as defineForm,
1882
+ ce as deleteKey,
1883
+ Co as devToolsMiddleware,
1884
+ No as enableDevMode,
1885
+ ae as errorCodes,
1886
+ jr as filterMap,
1887
+ vn as filterReduce,
1888
+ Io as filterTap,
1889
+ gr as formDefDecoder,
1890
+ _o as formHealth,
1891
+ N as get,
1892
+ Oo as getDirectionFromLanguage,
1893
+ Pn as identityTranslator,
1894
+ Po as injectedValidationByPath$,
1895
+ re as isActionWidget,
1896
+ Ao as isDevMode,
1897
+ st as isDisplayWidget,
1898
+ se as isFunctionWidget,
1899
+ P as isInputWidget,
1900
+ _e as isLayoutWidget,
1901
+ co as isStandardValidateSuccess,
1902
+ Dn as isTranslationConfig,
1903
+ He as layoutWidgetDecoder,
1904
+ On as makeRepeaterItemConfig,
1905
+ L as pipe,
1906
+ mo as selectWidgetFlags,
1907
+ Ge as set,
1908
+ hr as shortUUID,
1909
+ uo as standardValidate,
1910
+ Vr as toRepeaterItemUid,
1911
+ ko as touchedControlsByPath$,
1912
+ le as transformRepeaterItemWhenExpression,
1913
+ Do as validationByPath$,
1914
+ Ro as widgetFlagsByUid$,
1915
+ In as zipEvery
1598
1916
  };