@golemui/core 1.3.0 → 1.4.0-rc.0

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