@dynamicforms/vue-forms 0.6.0 → 0.11.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.
@@ -1,51 +1,80 @@
1
- var de = Object.defineProperty, ge = Object.defineProperties;
2
- var fe = Object.getOwnPropertyDescriptors;
3
- var P = Object.getOwnPropertySymbols;
4
- var J = Object.prototype.hasOwnProperty, K = Object.prototype.propertyIsEnumerable;
5
- var q = (i, s, e) => s in i ? de(i, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[s] = e, y = (i, s) => {
6
- for (var e in s || (s = {}))
7
- J.call(s, e) && q(i, e, s[e]);
8
- if (P)
9
- for (var e of P(s))
10
- K.call(s, e) && q(i, e, s[e]);
11
- return i;
12
- }, R = (i, s) => ge(i, fe(s));
13
- var I = (i, s) => {
14
- var e = {};
15
- for (var t in i)
16
- J.call(i, t) && s.indexOf(t) < 0 && (e[t] = i[t]);
17
- if (i != null && P)
18
- for (var t of P(i))
19
- s.indexOf(t) < 0 && K.call(i, t) && (e[t] = i[t]);
20
- return e;
1
+ var Gt = Object.defineProperty, Yt = Object.defineProperties;
2
+ var Jt = Object.getOwnPropertyDescriptors;
3
+ var q = Object.getOwnPropertySymbols;
4
+ var mt = Object.prototype.hasOwnProperty, bt = Object.prototype.propertyIsEnumerable;
5
+ var vt = (n) => {
6
+ throw TypeError(n);
7
+ };
8
+ var K = (n, e, t) => e in n ? Gt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, p = (n, e) => {
9
+ for (var t in e || (e = {}))
10
+ mt.call(e, t) && K(n, t, e[t]);
11
+ if (q)
12
+ for (var t of q(e))
13
+ bt.call(e, t) && K(n, t, e[t]);
14
+ return n;
15
+ }, x = (n, e) => Yt(n, Jt(e));
16
+ var k = (n, e) => {
17
+ var t = {};
18
+ for (var s in n)
19
+ mt.call(n, s) && e.indexOf(s) < 0 && (t[s] = n[s]);
20
+ if (n != null && q)
21
+ for (var s of q(n))
22
+ e.indexOf(s) < 0 && bt.call(n, s) && (t[s] = n[s]);
23
+ return t;
21
24
  };
22
- var o = (i, s, e) => q(i, typeof s != "symbol" ? s + "" : s, e);
23
- import { isEqual as k, isBoolean as pe, isString as V, isEmpty as H, truncate as be, isArray as te, isObject as se } from "lodash-es";
24
- import { unref as g, computed as me, reactive as ve, defineComponent as ye, resolveComponent as Z, openBlock as xe, createBlock as Ee, h as S } from "vue";
25
- var F = /* @__PURE__ */ ((i) => (i[i.SUPPRESS = 1] = "SUPPRESS", i[i.HIDDEN = 5] = "HIDDEN", i[i.INVISIBLE = 8] = "INVISIBLE", i[i.FULL = 10] = "FULL", i))(F || {});
26
- const ee = 10;
27
- ((i) => {
28
- function s(n) {
29
- return n.toUpperCase() === "SUPPRESS" ? 1 : n.toUpperCase() === "HIDDEN" ? 5 : n.toUpperCase() === "INVISIBLE" ? 8 : ee;
30
- }
31
- i.fromString = s;
32
- function e(n) {
33
- const r = typeof n == "number" ? n : i.fromString(n);
34
- return Object.values(i).includes(r) ? r : ee;
35
- }
36
- i.fromAny = e;
37
- function t(n) {
38
- const r = typeof n == "number" ? n : i.fromString(n);
39
- return Object.values(i).includes(r);
40
- }
41
- i.isDefined = t;
25
+ var d = (n, e, t) => K(n, typeof e != "symbol" ? e + "" : e, t), Vt = (n, e, t) => e.has(n) || vt("Cannot " + t);
26
+ var l = (n, e, t) => (Vt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), Z = (n, e, t) => e.has(n) ? vt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), tt = (n, e, t, s) => (Vt(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
27
+ var wt = (n, e, t) => new Promise((s, i) => {
28
+ var r = (c) => {
29
+ try {
30
+ o(t.next(c));
31
+ } catch (u) {
32
+ i(u);
33
+ }
34
+ }, a = (c) => {
35
+ try {
36
+ o(t.throw(c));
37
+ } catch (u) {
38
+ i(u);
39
+ }
40
+ }, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(r, a);
41
+ o((t = t.apply(n, e)).next());
42
+ });
43
+ import { isEqual as nt, isEmpty as L, isBoolean as Kt, isString as P, truncate as Zt, isArray as Tt, isObject as Ot } from "lodash-es";
44
+ import { unref as b, computed as jt, isRef as te, reactive as ee, ref as se, defineComponent as ie, resolveComponent as yt, openBlock as ne, createBlock as re, h as R } from "vue";
45
+ var F = /* @__PURE__ */ ((n) => (n[n.SUPPRESS = 1] = "SUPPRESS", n[n.HIDDEN = 5] = "HIDDEN", n[n.INVISIBLE = 8] = "INVISIBLE", n[n.FULL = 10] = "FULL", n))(F || {});
46
+ const Et = 10, xt = new Set(
47
+ Object.values(F).filter((n) => typeof n == "number")
48
+ );
49
+ ((n) => {
50
+ function e(i) {
51
+ return i.toUpperCase() === "SUPPRESS" ? 1 : i.toUpperCase() === "HIDDEN" ? 5 : i.toUpperCase() === "INVISIBLE" ? 8 : Et;
52
+ }
53
+ n.fromString = e;
54
+ function t(i) {
55
+ const r = typeof i == "number" ? i : n.fromString(i);
56
+ return xt.has(r) ? r : Et;
57
+ }
58
+ n.fromAny = t;
59
+ function s(i) {
60
+ const r = typeof i == "number" ? i : n.fromString(i);
61
+ return xt.has(r);
62
+ }
63
+ n.isDefined = s;
42
64
  })(F || (F = {}));
43
65
  Object.freeze(F);
44
- const C = F;
45
- class b {
46
- constructor(s) {
47
- o(this, "executorFn");
48
- this.executorFn = s;
66
+ const N = F;
67
+ class y {
68
+ constructor(e) {
69
+ d(this, "executorFn");
70
+ /**
71
+ * What this action remembers about one of the elements it serves. An action instance is shared - a `List` row
72
+ * carries the instances the item template carries - so anything an action holds about the element it last ran
73
+ * over belongs to that element rather than to the action: a verdict, a sequence number, a listener it installed.
74
+ * The keys are weak, so what an action remembers about a row is released with the row.
75
+ */
76
+ d(this, "states", /* @__PURE__ */ new WeakMap());
77
+ this.executorFn = e;
49
78
  }
50
79
  static get classIdentifier() {
51
80
  throw new Error("classIdentifier must be declared");
@@ -53,48 +82,295 @@ class b {
53
82
  get classIdentifier() {
54
83
  return this.constructor.classIdentifier;
55
84
  }
56
- execute(s, e, ...t) {
57
- return this.executorFn(s, e, ...t);
85
+ /**
86
+ * This action's state for `key`, created by `init` the first time it is asked for. The key is the element the
87
+ * action is running over, or the record that element belongs to where what is remembered is a fact about the
88
+ * whole record.
89
+ */
90
+ state(e, t) {
91
+ return this.states.has(e) || this.states.set(e, t()), this.states.get(e);
92
+ }
93
+ execute(e, t, ...s) {
94
+ return this.executorFn(e, t, ...s);
58
95
  }
59
96
  get eager() {
60
97
  return !1;
61
98
  }
99
+ /**
100
+ * Announces that this action now serves `binding`. It runs once per element the action is registered on, the
101
+ * copies of that element included: a copy takes on the instances it was copied from and each is told about the
102
+ * copy as it does.
103
+ */
62
104
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
63
- boundToField(s) {
105
+ boundToBinding(e) {
64
106
  }
65
- unregister() {
107
+ /**
108
+ * Announces that `binding` no longer holds this action. It names one element rather than the action as a whole,
109
+ * because the instance goes on serving every other element it was registered on.
110
+ */
111
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
112
+ unregisterFrom(e) {
66
113
  }
67
114
  }
68
- class Q extends Error {
115
+ class rt extends Error {
69
116
  }
70
- const ne = /* @__PURE__ */ Symbol("ValueChangedAction");
71
- class m extends b {
72
- constructor(s) {
73
- super(s);
117
+ const B = /* @__PURE__ */ Symbol("ValueChangedAction");
118
+ class O extends y {
119
+ constructor(e) {
120
+ super(e);
74
121
  }
75
122
  static get classIdentifier() {
76
- return ne;
123
+ return B;
77
124
  }
78
- execute(s, e, t, n) {
79
- return super.execute(s, e, t, n);
125
+ execute(e, t, s, i) {
126
+ return super.execute(e, t, s, i);
80
127
  }
81
128
  }
82
- class j extends String {
83
- constructor(e, t, n) {
84
- super(e);
85
- o(this, "plugins");
86
- o(this, "options");
87
- this.plugins = n, this.options = t;
129
+ const z = /* @__PURE__ */ Symbol("Transaction.capture"), Pt = /* @__PURE__ */ Symbol("Transaction.restore"), Ft = /* @__PURE__ */ Symbol("Transaction.announceValue"), Nt = /* @__PURE__ */ Symbol("Transaction.settleValidity");
130
+ function Ct(n) {
131
+ let e = 0, t = n.parent;
132
+ for (; t; )
133
+ e++, t = t.parent;
134
+ return e;
135
+ }
136
+ class ae {
137
+ constructor() {
138
+ d(this, "participants", /* @__PURE__ */ new Map());
139
+ /** work that stands only where the transaction commits; a rollback simply never does it */
140
+ d(this, "deferred", []);
141
+ /** what a rollback has to put back beyond the state slots, newest last */
142
+ d(this, "undo", []);
143
+ /** true once the transaction has been unwound, which is what tells a run started inside it to say nothing */
144
+ d(this, "unwound", !1);
145
+ /** the depth the announcement in progress is working at, -1 while none is */
146
+ d(this, "passDepth", -1);
147
+ /** set while a pass is running and an element it has already passed the depth of gets enrolled */
148
+ d(this, "restartPass", !1);
149
+ }
150
+ /** true for a transaction that was rolled back rather than committed */
151
+ get rolledBack() {
152
+ return this.unwound;
153
+ }
154
+ participant(e) {
155
+ let t = this.participants.get(e);
156
+ return t || (t = { element: e, valueDirty: !1, forceValue: !1, validityDirty: !1 }, this.participants.set(e, t)), t;
157
+ }
158
+ /**
159
+ * Records the state of an element the first time the transaction modifies it. The whole of the mutable state
160
+ * goes into the snapshot rather than the part being written: a rollback that restored some of it would leave
161
+ * the element in a state the form never held.
162
+ */
163
+ touch(e) {
164
+ const t = this.participant(e);
165
+ t.snapshot || (t.snapshot = e[z]());
166
+ }
167
+ /** Enrols an element as one whose value the commit has to announce. `force` skips the comparison. */
168
+ markValueChanged(e, t) {
169
+ const s = this.participant(e);
170
+ s.valueDirty = !0, t && (s.forceValue = !0), this.noteDepth(e);
171
+ }
172
+ /** Enrols an element as one whose verdict the commit has to re-form. */
173
+ markValidityDirty(e) {
174
+ this.participant(e).validityDirty = !0, this.noteDepth(e);
175
+ }
176
+ /**
177
+ * Queues an event that states an operation rather than a state. Added and removed items have no net over a
178
+ * transaction, so they are neither compared nor coalesced: the commit emits them in the order they happened.
179
+ */
180
+ recordStructural(e, t) {
181
+ var i;
182
+ const s = this.participant(e);
183
+ ((i = s.structural) != null ? i : s.structural = []).push(t), this.noteDepth(e);
184
+ }
185
+ /** True where the commit still owes this element a value announcement. */
186
+ willAnnounceValue(e) {
187
+ var t, s;
188
+ return (s = (t = this.participants.get(e)) == null ? void 0 : t.valueDirty) != null ? s : !1;
189
+ }
190
+ /**
191
+ * Registers work the commit does once everything has been announced. It is for what a rollback could not take
192
+ * back: releasing a listener, dropping a registration. Held until the commit, it is simply never done where the
193
+ * transaction unwinds instead.
194
+ */
195
+ whenCommitted(e) {
196
+ this.deferred.push(e);
197
+ }
198
+ /**
199
+ * Registers what a rollback has to put back beyond the element's state slots. The snapshot covers the slots,
200
+ * which is everything an ordinary write touches; an operation that replaces something else the element carries
201
+ * hands its own undo in here rather than making every snapshot carry the thing.
202
+ */
203
+ whenRolledBack(e) {
204
+ this.undo.push(e);
205
+ }
206
+ /**
207
+ * Notes that an element at or below the depth the pass in progress is working at has been enrolled. The pass
208
+ * then gives up the rest of its batch and is started again over what is now owed, so the newcomer is reached
209
+ * before the containers above it: an element a handler writes must still be announced before the container
210
+ * whose composed value carries that write. The depth is only measured while a pass is running - outside one
211
+ * there is nothing the answer would change.
212
+ */
213
+ noteDepth(e) {
214
+ this.passDepth < 0 || Ct(e) >= this.passDepth && (this.restartPass = !0);
215
+ }
216
+ /**
217
+ * Puts every element the transaction modified back as it found it. Nothing is announced: from an observer's
218
+ * point of view the transaction never happened. What a rollback cannot take back are side effects - a handler
219
+ * that called a server during the transaction already did.
220
+ */
221
+ rollback() {
222
+ this.unwound = !0, [...this.participants.values()].reverse().forEach((t) => {
223
+ t.snapshot && t.element[Pt](t.snapshot);
224
+ }), this.participants.clear();
225
+ for (let t = this.undo.length - 1; t >= 0; t--) this.undo[t]();
226
+ this.undo.length = 0, this.deferred.length = 0;
227
+ }
228
+ /**
229
+ * Announces what the transaction did. Values first and verdicts after, because a container's validators run
230
+ * with its value announcement and the verdict they reach is what the validity pass then reports. Both passes
231
+ * run deepest first - field, then row, then list - which is the order the change travelled in.
232
+ *
233
+ * A handler may write while the commit runs; its writes join this transaction, so both passes repeat until
234
+ * nothing is left dirty.
235
+ */
236
+ commit() {
237
+ for (; !(!this.announceValues() && !this.settleValidity()); )
238
+ ;
239
+ this.deferred.splice(0).forEach((t) => t());
240
+ }
241
+ /**
242
+ * The dirty participants a pass has to visit, one bucket per nesting depth; ties keep the order they were
243
+ * enrolled in. A nesting depth is a small integer, so the elements go into buckets rather than through a
244
+ * comparison sort: a whole-list assignment enrols one participant per field, and ordering those by comparison
245
+ * would cost more than the announcement it orders.
246
+ */
247
+ buckets(e) {
248
+ const t = [];
249
+ return this.participants.forEach((s) => {
250
+ var r;
251
+ if (!e(s)) return;
252
+ const i = Ct(s.element);
253
+ ((r = t[i]) != null ? r : t[i] = []).push(s);
254
+ }), t;
255
+ }
256
+ /**
257
+ * Runs one pass over the dirty participants, deepest bucket first; the caller repeats it until it answers
258
+ * false. The buckets are taken once, and the pass gives up as soon as a handler enrols an element at or below
259
+ * the depth being drained: that element is not in the bucket being walked, and going on would reach the
260
+ * containers above it first. The caller's next pass takes fresh buckets and finds it at its own depth.
261
+ */
262
+ pass(e, t) {
263
+ const s = this.buckets(e);
264
+ if (!s.length) return !1;
265
+ for (let i = s.length - 1; i >= 0; i--) {
266
+ const r = s[i];
267
+ if (r) {
268
+ this.passDepth = i, this.restartPass = !1;
269
+ try {
270
+ for (let a = 0; a < r.length; a++) {
271
+ if (this.restartPass) return !0;
272
+ const o = r[a];
273
+ e(o) && t(o);
274
+ }
275
+ } finally {
276
+ this.passDepth = -1;
277
+ }
278
+ if (this.restartPass) return !0;
279
+ }
280
+ }
281
+ return !0;
282
+ }
283
+ announceValues() {
284
+ return this.pass(
285
+ (e) => e.valueDirty || e.structural !== void 0,
286
+ (e) => {
287
+ const { structural: t } = e, s = e.valueDirty, i = e.forceValue;
288
+ e.structural = void 0, e.valueDirty = !1, e.forceValue = !1, e.element[Ft](this, s, i, t);
289
+ }
290
+ );
291
+ }
292
+ settleValidity() {
293
+ return this.pass(
294
+ (e) => e.validityDirty,
295
+ (e) => {
296
+ e.validityDirty = !1, e.element[Nt](this);
297
+ }
298
+ );
299
+ }
300
+ }
301
+ let _, et;
302
+ function kt() {
303
+ return _;
304
+ }
305
+ class Rt {
306
+ }
307
+ class oe {
308
+ constructor() {
309
+ d(this, "open", !0);
310
+ }
311
+ rollback() {
312
+ throw this.open ? new Rt() : new TypeError(
313
+ "this transaction handle is spent: the transaction that handed it out has closed. A handle is only usable inside the call that received it."
314
+ );
315
+ }
316
+ close() {
317
+ this.open = !1;
318
+ }
319
+ }
320
+ function St(n) {
321
+ if (n != null && typeof n.then == "function")
322
+ throw new TypeError(
323
+ "a transaction may not be asynchronous: the callback returned a thenable. Do the awaiting outside and open a transaction for each synchronous part."
324
+ );
325
+ }
326
+ function ot(n) {
327
+ if (_) {
328
+ const s = n(et);
329
+ return St(s), s;
330
+ }
331
+ const e = new ae(), t = new oe();
332
+ _ = e, et = t;
333
+ try {
334
+ const s = n(t);
335
+ return St(s), e.commit(), s;
336
+ } catch (s) {
337
+ if (e.rollback(), s instanceof Rt) return;
338
+ throw s;
339
+ } finally {
340
+ _ = void 0, et = void 0, t.close();
341
+ }
342
+ }
343
+ function g(n) {
344
+ return _ ? n(_) : ot(() => n(_));
345
+ }
346
+ const Dt = { useMarkdownInValidators: !0 };
347
+ function le() {
348
+ return Dt;
349
+ }
350
+ function ce(n) {
351
+ Object.assign(Dt, n);
352
+ }
353
+ const Ye = {
354
+ install(n, e) {
355
+ e && ce(e);
356
+ }
357
+ };
358
+ class U extends String {
359
+ constructor(t, s, i) {
360
+ super(t);
361
+ d(this, "plugins");
362
+ d(this, "options");
363
+ this.plugins = i, this.options = s;
88
364
  }
89
365
  }
90
- function W(i) {
91
- const s = g(i);
92
- return typeof s == "object" && "componentName" in s;
366
+ function lt(n) {
367
+ const e = b(n);
368
+ return typeof e == "object" && "componentName" in e;
93
369
  }
94
- function U(i) {
95
- return typeof g(i) == "function";
370
+ function H(n) {
371
+ return typeof b(n) == "function";
96
372
  }
97
- class X {
373
+ class ct {
98
374
  get componentName() {
99
375
  return "Comment";
100
376
  }
@@ -108,12 +384,12 @@ class X {
108
384
  return "";
109
385
  }
110
386
  }
111
- class _e extends X {
112
- constructor(e, t = "") {
387
+ class ue extends ct {
388
+ constructor(t, s = "") {
113
389
  super();
114
- o(this, "text");
115
- o(this, "classes");
116
- this.text = e, this.classes = t;
390
+ d(this, "text");
391
+ d(this, "classes");
392
+ this.text = t, this.classes = s;
117
393
  }
118
394
  get componentName() {
119
395
  return "template";
@@ -125,24 +401,24 @@ class _e extends X {
125
401
  return this.classes;
126
402
  }
127
403
  }
128
- class p extends X {
129
- constructor(e, t = "") {
404
+ class V extends ct {
405
+ constructor(t, s = "") {
130
406
  super();
131
- o(this, "classes");
132
- o(this, "text");
133
- o(this, "textType");
134
- this.classes = t, this.text = e, this.textType = me(() => this.getTextType);
407
+ d(this, "classes");
408
+ d(this, "text");
409
+ d(this, "textType");
410
+ this.classes = s, this.text = t, this.textType = jt(() => this.getTextType);
135
411
  }
136
412
  get resolvedText() {
137
- const e = g(this.text);
138
- return U(e) ? e() : e;
413
+ const t = b(this.text);
414
+ return H(t) ? t() : t;
139
415
  }
140
416
  get getTextType() {
141
- const e = this.resolvedText;
142
- return e ? e instanceof j ? "md" : W(e) ? "component" : "string" : "string";
417
+ const t = this.resolvedText;
418
+ return t ? t instanceof U ? "md" : lt(t) ? "component" : "string" : "string";
143
419
  }
144
420
  get componentName() {
145
- switch (g(this.textType)) {
421
+ switch (b(this.textType)) {
146
422
  case "string":
147
423
  return "template";
148
424
  case "md":
@@ -154,12 +430,12 @@ class p extends X {
154
430
  }
155
431
  }
156
432
  get componentBindings() {
157
- switch (g(this.textType)) {
433
+ switch (b(this.textType)) {
158
434
  case "string":
159
435
  return {};
160
436
  case "md": {
161
- const e = this.resolvedText;
162
- return { source: e.toString(), options: e.options, plugins: e.plugins };
437
+ const t = this.resolvedText;
438
+ return { source: t.toString(), options: t.options, plugins: t.plugins };
163
439
  }
164
440
  case "component":
165
441
  return this.resolvedText.componentProps || {};
@@ -168,7 +444,7 @@ class p extends X {
168
444
  }
169
445
  }
170
446
  get componentBody() {
171
- switch (g(this.textType)) {
447
+ switch (b(this.textType)) {
172
448
  case "string":
173
449
  return this.resolvedText;
174
450
  case "component":
@@ -181,158 +457,308 @@ class p extends X {
181
457
  return this.classes;
182
458
  }
183
459
  }
184
- class Ve extends p {
460
+ class he extends V {
461
+ }
462
+ function E(n) {
463
+ return le().useMarkdownInValidators ? new U(n) : n.replace(/[*_~`]/g, "").replace(/!\[(.*?)\]\(.*?\)/g, "$1").replace(/\[(.*?)\]\((.*?)\)/g, "$1").replace(/#+\s?/g, "").replace(/>\s?/g, "").replace(/(\*|-|\d+\.)\s+/g, "").replace(/`{3}[\s\S]*?`{3}/g, "").replace(/`([^`]+)`/g, "$1").replace(/\n{2,}/g, `
464
+ `);
185
465
  }
186
- const Ce = /* @__PURE__ */ Symbol("Validator");
187
- class f extends m {
466
+ const de = /* @__PURE__ */ Symbol("Validator"), ge = () => E("Validation could not be completed");
467
+ class v extends O {
188
468
  /**
189
469
  * Creates a new validator
190
470
  * @param validationFn Function that validates the field value and returns errors or null
191
471
  */
192
- constructor(e) {
193
- super((n, r, a, l) => {
194
- const c = e(a, l, n) || [], u = (h) => {
195
- var A;
196
- h == null || h.forEach(
197
- (E) => Object.defineProperty(E, "source", { value: this.source, enumerable: !1, configurable: !1 })
198
- );
199
- for (let E = n.errors.length - 1; E >= 0; E--) {
200
- const L = n.errors[E];
201
- if (L.source === this.source) {
202
- const O = (A = h == null ? void 0 : h.findIndex(($) => k($, L))) != null ? A : -1;
203
- O >= 0 ? h == null || h.splice(O, 1) : n.errors.splice(E, 1);
472
+ constructor(t) {
473
+ super((i, r, a, o) => {
474
+ const c = this.bindingState(i), u = ++c.run, C = i.validationEpoch, G = kt(), dt = () => c.run === u && i.validationEpoch === C && !(G != null && G.rolledBack), Y = t(a, o, i) || [], J = (S) => ot(() => {
475
+ var gt;
476
+ const $ = (gt = S == null ? void 0 : S.map((j) => this.claim(j))) != null ? gt : [];
477
+ for (let j = i.errors.length - 1; j >= 0; j--) {
478
+ const ft = i.errors[j];
479
+ if (ft.source === this.source) {
480
+ const pt = $.findIndex((Xt) => nt(Xt, ft));
481
+ pt >= 0 ? $.splice(pt, 1) : i.errors.splice(j, 1);
204
482
  }
205
483
  }
206
- h && h.length > 0 && n.errors.push(...h), n.validate();
207
- };
208
- return c instanceof Promise ? (n.beginValidating(), c.then((h) => u(h)).finally(() => n.endValidating())) : u(c), r(n, a, l);
484
+ $.length > 0 && i.errors.push(...$), i.validate();
485
+ });
486
+ return Y instanceof Promise ? (i.beginValidating(), Y.then(
487
+ (S) => {
488
+ dt() && J(S);
489
+ },
490
+ (S) => {
491
+ dt() && (J([new V(ge())]), console.error("Validation failed", S));
492
+ }
493
+ ).finally(() => i.endValidating()).catch((S) => console.error("Validation failed", S))) : J(Y), r(i, a, o);
209
494
  });
210
- o(this, "source");
495
+ d(this, "source");
211
496
  this.source = Symbol(this.constructor.name);
212
497
  }
498
+ /**
499
+ * Returns the error instance this validator owns and may later withdraw: the argument itself when it carries no
500
+ * ownership stamp or already carries this validator's, a copy of it when it belongs to another validator. The
501
+ * stamp is not configurable, so an instance one validator owns can never be reassigned to another; the copy is
502
+ * what makes an error instance shareable between validators, and it keeps the prototype and every own property,
503
+ * including the non-enumerable ones, so it renders exactly like the instance it was made from.
504
+ */
505
+ claim(t) {
506
+ const s = t.source;
507
+ if (s === this.source) return t;
508
+ const i = { value: this.source, enumerable: !1, configurable: !1 };
509
+ if (s === void 0)
510
+ return Object.defineProperty(t, "source", i), t;
511
+ const r = Object.getOwnPropertyDescriptors(t);
512
+ return Object.create(Object.getPrototypeOf(t), x(p({}, r), { source: i }));
513
+ }
213
514
  static get classIdentifier() {
214
- return Ce;
515
+ return de;
215
516
  }
216
517
  get eager() {
217
518
  return !0;
218
519
  }
219
- replacePlaceholdersFunction(e, t) {
520
+ /**
521
+ * What this validator remembers about one of the fields it validates. One instance may be registered on several
522
+ * fields - every row of a list carries the instances the item template carries - so each field has a record of
523
+ * its own. A subclass that remembers more widens the record by overriding `newBindingState`.
524
+ */
525
+ bindingState(t) {
526
+ return this.state(t, () => this.newBindingState());
527
+ }
528
+ /**
529
+ * The record a field starts with. `run` is the sequence number of the newest run over that field: every
530
+ * execution takes the next one and a result is applied only while its number is still the newest, so a slow run
531
+ * cannot overwrite the verdict of a faster one that started after it.
532
+ */
533
+ newBindingState() {
534
+ return { run: 0 };
535
+ }
536
+ replacePlaceholdersFunction(t, s) {
220
537
  return () => {
221
- let n = g(e);
222
- for (; U(n); )
223
- n = g(this.replacePlaceholders(n(), t));
224
- return n;
538
+ let i = b(t);
539
+ for (; H(i); )
540
+ i = b(this.replacePlaceholders(i(), s));
541
+ return i;
225
542
  };
226
543
  }
227
- replacePlaceholders(e, t) {
228
- if (U(e)) return this.replacePlaceholdersFunction(e, t);
229
- if (W(e)) return e;
230
- let n = g(e);
231
- return Object.keys(t).forEach((r) => {
232
- n = n.replaceAll(`{${r}}`, t[r]);
233
- }), e instanceof j ? new j(n.toString(), e.options, e.plugins) : n;
544
+ replacePlaceholders(t, s) {
545
+ if (H(t)) return this.replacePlaceholdersFunction(t, s);
546
+ if (lt(t)) return t;
547
+ if (te(t))
548
+ return this.replacePlaceholdersFunction(() => b(t), s);
549
+ let i = b(t);
550
+ return Object.keys(s).forEach((r) => {
551
+ i = i.replaceAll(`{${r}}`, s[r]);
552
+ }), t instanceof U ? new U(i.toString(), t.options, t.plugins) : i;
234
553
  }
235
554
  }
236
- class N extends Map {
555
+ class M extends Map {
237
556
  constructor() {
238
557
  super(...arguments);
239
- o(this, "eagerActions", /* @__PURE__ */ new Set());
240
- o(this, "registeredActions", []);
241
- }
242
- register(e) {
243
- if (!(e instanceof b)) throw new Error("Invalid action type");
244
- this.registeredActions.push(e);
245
- const t = e.classIdentifier, n = this.get(t) || (() => null);
246
- function r(a, ...l) {
247
- return e.execute(a, n, ...l);
558
+ d(this, "eagerActions", /* @__PURE__ */ new Set());
559
+ d(this, "registeredActions", []);
560
+ }
561
+ register(t) {
562
+ if (!(t instanceof y)) throw new Error("Invalid action type");
563
+ this.registeredActions.push(t);
564
+ const s = t.classIdentifier, i = this.get(s) || (() => null);
565
+ function r(a, ...o) {
566
+ return t.execute(a, i, ...o);
248
567
  }
249
- this.set(t, r), e.eager && this.eagerActions.add(e.classIdentifier);
568
+ this.set(s, r), t.eager && this.eagerActions.add(t.classIdentifier);
569
+ }
570
+ /**
571
+ * True when triggering this action would run something: a handler registered under the identifier, or - on the
572
+ * value change identifier, which trigger() answers with an eager pass as well - any eager action at all. A
573
+ * caller that has to build the parameters before it can trigger asks this first and skips building them when
574
+ * there is nothing to receive them.
575
+ */
576
+ willTrigger(t) {
577
+ return this.has(t) ? !0 : t === B && this.eagerActions.size > 0;
578
+ }
579
+ trigger(t, s, ...i) {
580
+ const r = t.classIdentifier;
581
+ return r === B && this.triggerEager(s, ...i), this.triggerChain(r, s, ...i);
250
582
  }
251
- trigger(e, t, ...n) {
252
- const r = e.classIdentifier;
253
- r === ne && this.triggerEager(t, ...n);
254
- const a = this.get(r);
583
+ /**
584
+ * Runs the chain registered under one identifier and nothing else. A caller that has already run the eager
585
+ * pass - a transaction runs it at the write, so that the validators have decided before it commits - reaches
586
+ * the handlers through here, so the eager actions are not run a second time at the announcement.
587
+ */
588
+ triggerChain(t, s, ...i) {
589
+ const r = this.get(t);
255
590
  try {
256
- if (a) return a(t, ...n);
257
- } catch (l) {
258
- if (!(l instanceof Q)) throw l;
591
+ if (r) return r(s, ...i);
592
+ } catch (a) {
593
+ if (!(a instanceof rt)) throw a;
259
594
  }
260
595
  return null;
261
596
  }
262
- triggerEager(e, ...t) {
263
- for (const n of this.eagerActions) {
264
- const r = this.get(n);
597
+ triggerEager(t, ...s) {
598
+ for (const i of this.eagerActions) {
599
+ const r = this.get(i);
265
600
  try {
266
- r && r(e, ...t);
601
+ r && r(t, ...s);
267
602
  } catch (a) {
268
- if (!(a instanceof Q)) throw a;
603
+ if (!(a instanceof rt)) throw a;
269
604
  }
270
605
  }
271
606
  }
607
+ /** the validators registered in this map, in registration order */
608
+ get validators() {
609
+ return this.registeredActions.filter((t) => t instanceof v);
610
+ }
272
611
  clone() {
273
- const e = new N();
274
- return this.registeredActions.forEach((t) => e.register(t)), e;
612
+ const t = new M();
613
+ return this.registeredActions.forEach((s) => t.register(s)), t;
275
614
  }
615
+ /**
616
+ * Tells every action in this map that it serves `owner`. A copied map holds the instances the original holds, so
617
+ * the element that took the copy on is announced to them here, the way registering an action announces the
618
+ * element it was registered on.
619
+ */
620
+ bindTo(t) {
621
+ this.registeredActions.forEach((s) => s.boundToBinding(t));
622
+ }
623
+ /**
624
+ * A copy of this map carrying everything but the validators. It only leaves them out: releasing what a
625
+ * validator installed elsewhere is the caller's to do, and only once the transaction that dropped them has
626
+ * committed, because a rollback puts this map back with its validators in it.
627
+ */
276
628
  cloneWithoutValidators() {
277
- const e = new N();
278
- return this.registeredActions.forEach((t) => {
279
- t instanceof f ? t.unregister() : e.register(t);
280
- }), e;
629
+ const t = new M();
630
+ return this.registeredActions.forEach((s) => {
631
+ s instanceof v || t.register(s);
632
+ }), t;
281
633
  }
282
634
  }
283
- const Ae = /* @__PURE__ */ Symbol("ConditionalStatementAction");
284
- class B extends m {
285
- constructor(e, t) {
286
- const n = (r, a, l, c) => {
287
- const u = e.evaluate();
288
- if (u !== this.lastResult) {
289
- for (const h of this.boundFields)
290
- t(h, u, this.lastResult);
291
- this.lastResult = u;
292
- }
293
- return a(r, l, c);
294
- };
295
- super(n);
296
- o(this, "lastResult");
297
- // boundField tracks the fields this action is bound to. so that it may perform the executorFn on them and not on the
298
- // ValueChangedAction fields that will call the actionExecutor
299
- o(this, "boundFields", /* @__PURE__ */ new Set());
300
- e.collectFields().forEach((r) => r.registerAction(new m(n)));
635
+ function T(n) {
636
+ let e = n;
637
+ for (; e.fieldName !== void 0 && e.parent; ) e = e.parent;
638
+ return e;
639
+ }
640
+ function fe(n) {
641
+ const e = [];
642
+ let t = n;
643
+ for (; t.fieldName !== void 0 && t.parent; )
644
+ e.unshift(t.fieldName), t = t.parent;
645
+ return e;
646
+ }
647
+ function ut(n, e) {
648
+ var s, i;
649
+ let t = e;
650
+ for (const r of fe(n))
651
+ if (t = (i = (s = t.field) == null ? void 0 : s.call(t, r)) != null ? i : void 0, !t) break;
652
+ return (t == null ? void 0 : t.declaration) === n ? t : T(n) === T(e.declaration) ? void 0 : n;
653
+ }
654
+ function Lt(n, e) {
655
+ const t = ut(n, e);
656
+ if (!t) return [];
657
+ if (t !== n) return [t];
658
+ const s = e.bindingsOf(n);
659
+ return s.length > 0 ? s : [n];
660
+ }
661
+ function pe(n, e) {
662
+ var s;
663
+ let t = e.parent;
664
+ for (; t; ) {
665
+ const i = (s = t.field) == null ? void 0 : s.call(t, n);
666
+ if (i) return i;
667
+ t = t.parent;
668
+ }
669
+ }
670
+ const me = /* @__PURE__ */ Symbol("ConditionalStatementAction");
671
+ class Q extends O {
672
+ constructor(t, s) {
673
+ super((r, a, o, c) => (this.applyIn(T(r)) || r.markRecordIncomplete(), a(r, o, c)));
674
+ d(this, "statement");
675
+ d(this, "conditionalExecutor");
676
+ /**
677
+ * What the elements this action was registered on were declared as. It holds declarations rather than the
678
+ * elements themselves, so one entry stands for every row of a list, and the element a result is applied to is
679
+ * the one that declaration names within the record the change happened in.
680
+ */
681
+ d(this, "declarations", /* @__PURE__ */ new Set());
682
+ /**
683
+ * The elements this action was registered on. Registration reaches one element at a time - the rows of a list
684
+ * take the action on one by one, as they are built from the item template that carries it - so this is what
685
+ * says which of the elements a declaration stands for the action actually drives.
686
+ */
687
+ d(this, "registrations", /* @__PURE__ */ new WeakSet());
688
+ this.statement = t, this.conditionalExecutor = s;
689
+ const i = new O((r, a, ...o) => (this.applyFrom(r), a(r, ...o)));
690
+ t.collectFields().forEach((r) => r.registerAction(i));
301
691
  }
302
692
  static get classIdentifier() {
303
- return Ae;
693
+ return me;
304
694
  }
305
695
  get eager() {
306
696
  return !0;
307
697
  }
308
- boundToField(e) {
309
- this.boundFields.add(e);
698
+ boundToBinding(t) {
699
+ this.declarations.add(t.declaration), this.registrations.add(t);
700
+ }
701
+ /**
702
+ * The elements of `scope` this action controls: what each declaration it serves names within that record, and of
703
+ * those the ones that took the action on. A row of a list that never took it on is not one this action drives.
704
+ */
705
+ targetsIn(t) {
706
+ const s = [];
707
+ return this.declarations.forEach(
708
+ (i) => Lt(i, t).forEach((r) => {
709
+ this.registrations.has(r) && s.push(r);
710
+ })
711
+ ), s;
712
+ }
713
+ /**
714
+ * Re-evaluates the statement over one record and applies the result where it changed. The result is recorded
715
+ * before the executor runs, because an executor that writes a value re-enters through that value's eager pass
716
+ * and what it has to find there is the result being applied. It answers whether the record held anything for
717
+ * this action to drive, which is how a caller learns that the record is not assembled yet.
718
+ */
719
+ applyIn(t) {
720
+ const s = this.targetsIn(t);
721
+ if (s.length === 0) return !1;
722
+ const i = this.state(t, () => ({ lastResult: void 0 })), r = this.statement.evaluate(t);
723
+ if (r === i.lastResult) return !0;
724
+ const a = i.lastResult;
725
+ return i.lastResult = r, s.forEach((o) => this.conditionalExecutor(o, r, a)), !0;
726
+ }
727
+ /**
728
+ * Re-evaluates the records a change of `source` speaks for. A field of the record the targets live in speaks for
729
+ * that record alone, which is what keeps one row of a list from answering for another; a field above them - a
730
+ * form field every row reads - speaks for every record below it, and for the record the action was declared in
731
+ * where the change reaches none.
732
+ */
733
+ applyFrom(t) {
734
+ const s = /* @__PURE__ */ new Set();
735
+ this.targetsIn(T(t)).forEach((i) => s.add(T(i))), s.forEach((i) => this.applyIn(i));
310
736
  }
311
737
  }
312
- class Ie extends B {
313
- constructor(s) {
314
- super(s, (e, t) => {
315
- e.visibility = t ? C.FULL : C.SUPPRESS;
738
+ class be extends Q {
739
+ constructor(e) {
740
+ super(e, (t, s) => {
741
+ t.visibility = s ? N.FULL : N.SUPPRESS;
316
742
  });
317
743
  }
318
744
  }
319
- class Se extends B {
320
- constructor(s) {
321
- super(s, (e, t) => {
322
- e.enabled = t;
745
+ class ve extends Q {
746
+ constructor(e) {
747
+ super(e, (t, s) => {
748
+ t.enabled = s;
323
749
  });
324
750
  }
325
751
  }
326
- class we extends B {
327
- constructor(s, e) {
328
- super(s, (t, n) => {
329
- n && (t.value = e);
752
+ class Ve extends Q {
753
+ constructor(e, t) {
754
+ super(e, (s, i) => {
755
+ i && (s.value = t);
330
756
  });
331
757
  }
332
758
  }
333
- var T = /* @__PURE__ */ ((i) => (i[i.NOT = 0] = "NOT", i[i.OR = 1] = "OR", i[i.AND = 2] = "AND", i[i.XOR = 3] = "XOR", i[i.NAND = 4] = "NAND", i[i.NOR = 5] = "NOR", i[i.EQUALS = -1] = "EQUALS", i[i.NOT_EQUALS = -2] = "NOT_EQUALS", i[i.GT = -3] = "GT", i[i.LT = -4] = "LT", i[i.GE = -5] = "GE", i[i.LE = -6] = "LE", i[i.IN = -7] = "IN", i[i.NOT_IN = -8] = "NOT_IN", i[i.INCLUDES = -9] = "INCLUDES", i[i.NOT_INCLUDES = -10] = "NOT_INCLUDES", i))(T || {});
334
- ((i) => {
335
- function s(r) {
759
+ var W = /* @__PURE__ */ ((n) => (n[n.NOT = 0] = "NOT", n[n.OR = 1] = "OR", n[n.AND = 2] = "AND", n[n.XOR = 3] = "XOR", n[n.NAND = 4] = "NAND", n[n.NOR = 5] = "NOR", n[n.EQUALS = -1] = "EQUALS", n[n.NOT_EQUALS = -2] = "NOT_EQUALS", n[n.GT = -3] = "GT", n[n.LT = -4] = "LT", n[n.GE = -5] = "GE", n[n.LE = -6] = "LE", n[n.IN = -7] = "IN", n[n.NOT_IN = -8] = "NOT_IN", n[n.INCLUDES = -9] = "INCLUDES", n[n.NOT_INCLUDES = -10] = "NOT_INCLUDES", n))(W || {});
760
+ ((n) => {
761
+ function e(r) {
336
762
  const a = r.toLowerCase();
337
763
  if (a === "not") return 0;
338
764
  if (a === "or") return 1;
@@ -352,209 +778,664 @@ var T = /* @__PURE__ */ ((i) => (i[i.NOT = 0] = "NOT", i[i.OR = 1] = "OR", i[i.A
352
778
  if (["not_includes", "not-includes", "not includes"].includes(a)) return -10;
353
779
  throw new Error(`Unrecognised operator ${a}`);
354
780
  }
355
- i.fromString = s;
356
- function e(r) {
357
- const a = typeof r == "number" ? r : i.fromString(r);
358
- if (Object.values(i).includes(a)) return a;
781
+ n.fromString = e;
782
+ function t(r) {
783
+ const a = typeof r == "number" ? r : n.fromString(r);
784
+ if (Object.values(n).includes(a)) return a;
359
785
  throw new Error(`Unrecognised operator ${r}`);
360
786
  }
361
- i.fromAny = e;
362
- function t(r) {
363
- const a = typeof r == "number" ? r : i.fromString(r);
364
- return Object.values(i).includes(a);
787
+ n.fromAny = t;
788
+ function s(r) {
789
+ const a = typeof r == "number" ? r : n.fromString(r);
790
+ return Object.values(n).includes(a);
365
791
  }
366
- i.isDefined = t;
367
- function n(r) {
792
+ n.isDefined = s;
793
+ function i(r) {
368
794
  return r >= 0;
369
795
  }
370
- i.isLogicOperator = n;
371
- })(T || (T = {}));
372
- Object.freeze(T);
373
- const d = T, Fe = /* @__PURE__ */ Symbol("EnabledChangingAction");
374
- class ie extends b {
375
- constructor(s) {
376
- super(s);
796
+ n.isLogicOperator = i;
797
+ })(W || (W = {}));
798
+ Object.freeze(W);
799
+ const m = W, we = /* @__PURE__ */ Symbol("EnabledChangingAction");
800
+ class Bt extends y {
801
+ constructor(e) {
802
+ super(e);
377
803
  }
378
804
  static get classIdentifier() {
379
- return Fe;
805
+ return we;
380
806
  }
381
- execute(s, e, t, n) {
382
- return super.execute(s, e, t, n);
807
+ execute(e, t, s, i) {
808
+ return super.execute(e, t, s, i);
383
809
  }
384
810
  }
385
- const je = /* @__PURE__ */ Symbol("EnabledChangedAction");
386
- class re extends b {
387
- constructor(s) {
388
- super(s);
811
+ const ye = /* @__PURE__ */ Symbol("EnabledChangedAction");
812
+ class Ut extends y {
813
+ constructor(e) {
814
+ super(e);
389
815
  }
390
816
  static get classIdentifier() {
391
- return je;
817
+ return ye;
392
818
  }
393
- execute(s, e, t, n) {
394
- return super.execute(s, e, t, n);
819
+ execute(e, t, s, i) {
820
+ return super.execute(e, t, s, i);
395
821
  }
396
822
  }
397
- const Ne = /* @__PURE__ */ Symbol("ValidChangedAction");
398
- class ae extends b {
399
- constructor(s) {
400
- super(s);
823
+ const Ee = /* @__PURE__ */ Symbol("ValidChangedAction");
824
+ class Mt extends y {
825
+ constructor(e) {
826
+ super(e);
401
827
  }
402
828
  static get classIdentifier() {
403
- return Ne;
829
+ return Ee;
404
830
  }
405
- execute(s, e, t, n) {
406
- return super.execute(s, e, t, n);
831
+ execute(e, t, s, i) {
832
+ return super.execute(e, t, s, i);
407
833
  }
408
834
  }
409
- const Te = /* @__PURE__ */ Symbol("VisibilityChangingAction");
410
- class le extends b {
411
- constructor(s) {
412
- super(s);
835
+ const xe = /* @__PURE__ */ Symbol("VisibilityChangingAction");
836
+ class Wt extends y {
837
+ constructor(e) {
838
+ super(e);
413
839
  }
414
840
  static get classIdentifier() {
415
- return Te;
841
+ return xe;
416
842
  }
417
- execute(s, e, t, n) {
418
- return super.execute(s, e, t, n);
843
+ execute(e, t, s, i) {
844
+ return super.execute(e, t, s, i);
419
845
  }
420
846
  }
421
- const Le = /* @__PURE__ */ Symbol("VisibilityChangedAction");
422
- class oe extends b {
423
- constructor(s) {
424
- super(s);
847
+ const Ce = /* @__PURE__ */ Symbol("VisibilityChangedAction");
848
+ class $t extends y {
849
+ constructor(e) {
850
+ super(e);
425
851
  }
426
852
  static get classIdentifier() {
427
- return Le;
853
+ return Ce;
428
854
  }
429
- execute(s, e, t, n) {
430
- return super.execute(s, e, t, n);
855
+ execute(e, t, s, i) {
856
+ return super.execute(e, t, s, i);
431
857
  }
432
858
  }
433
- class x {
859
+ const It = /* @__PURE__ */ new WeakMap(), At = /* @__PURE__ */ new Set(["validators", "actions"]);
860
+ let st = 0;
861
+ var h, f;
862
+ class A {
863
+ constructor(e) {
864
+ /**
865
+ * The element's mutable state, in an object beside the element. `#state` is the tracked view of it: a slot read
866
+ * through it inside an effect subscribes the effect to that slot, and a write to the slot re-runs the effect.
867
+ * `#raw` is the same object without the proxy, for the bookkeeping nothing renders from.
868
+ *
869
+ * They are private class fields, so no reflection over the element reaches the state or the parent link it
870
+ * carries, and a subclass reads its own slot type through the accessors below.
871
+ */
872
+ Z(this, h);
873
+ Z(this, f);
874
+ tt(this, f, e), tt(this, h, ee(e));
875
+ }
434
876
  /**
435
- * A field is a Vue reactive proxy from construction onwards: the base constructor returns the proxy, and a
436
- * derived class's `this` is whatever super() returned, so every subclass constructor, field initializer and
437
- * method sees the proxy. Consequence: plain `field.property = value` is tracked, with no wrapper in between.
877
+ * Vue's getTargetType answers INVALID for an object that carries __v_skip, so reactive() hands an element back
878
+ * unwrapped and no element is ever behind a proxy of its own. isReactive() reads the second flag, and it stays
879
+ * true because what carries an element's reactivity - its state - is a reactive object.
880
+ *
881
+ * Two consequences for a consumer, both silent. watch(field, cb) with a bare element as the source registers
882
+ * no dependency, because the deep traversal Vue starts for a reactive source stops on __v_skip; the supported
883
+ * form is watch(() => field.value, cb). And readonly(field) hands the element straight back, so the value it
884
+ * returns is the element itself and a write through it reaches the field; what a caller hands out instead is
885
+ * the value, which is frozen, or a computed over it.
438
886
  */
439
- constructor() {
440
- // contains original field value as was provided at creation
441
- o(this, "validatingCount", 0);
442
- o(this, "_valid", !0);
443
- // is current value valid as per FE and BE validators?
444
- o(this, "errors", []);
445
- // when member of a Group, fieldName specifies the name of this field
446
- o(this, "actions", new N());
447
- // default property handlers
448
- o(this, "_visibility", C.FULL);
449
- o(this, "_enabled", !0);
450
- return ve(this);
887
+ get __v_skip() {
888
+ return !0;
889
+ }
890
+ get __v_isReactive() {
891
+ return !0;
892
+ }
893
+ /** the tracked view of this element's state; a subclass narrows the return type to its own slots */
894
+ get state() {
895
+ return l(this, h);
896
+ }
897
+ /** the untracked view of this element's state; a subclass narrows the return type to its own slots */
898
+ get raw() {
899
+ return l(this, f);
900
+ }
901
+ /**
902
+ * Exchanges the data this element holds for `data`, in place. The element is the same instance afterwards - its
903
+ * identity, its actions, its extended properties and its place in whatever container holds it all stand - and it
904
+ * ends up in the state `bind(data)` would have produced: the values are written, the change history starts over
905
+ * and the validators run. It is what recycles one element across records, which is what a virtualised renderer
906
+ * does with the rows it keeps.
907
+ *
908
+ * The element makes no statement of its own about the exchange: no `ValueChangedAction` fires for it, the way
909
+ * none fires for an element that was just built. Its members do announce theirs, and a verdict that moves is
910
+ * announced as always - a rebound element that is invalid says so to the container holding it. A change an
911
+ * open transaction is already owed an announcement for stands: the commit reports the pair measured from
912
+ * where the element was when the transaction opened.
913
+ *
914
+ * The data is measured against the element's `declaration`, so a key a record leaves out is taken from the
915
+ * declaration rather than left as the previous record had it.
916
+ */
917
+ rebind(e) {
918
+ return g((t) => {
919
+ t.touch(this);
920
+ const s = t.willAnnounceValue(this), i = l(this, f).announcedValue;
921
+ this.resetTo(this.declaration, e), l(this, f).announcedValue = s ? i : this.value;
922
+ }), this;
923
+ }
924
+ /** contains original field value as was provided at creation */
925
+ get originalValue() {
926
+ return l(this, h).originalValue;
927
+ }
928
+ set originalValue(e) {
929
+ this.touchState(), l(this, h).originalValue = e;
930
+ }
931
+ /**
932
+ * The extended properties this element carries: what a consumer attached to it beyond the members the class
933
+ * declares, such as the label, hint or css class a UI layer binds to the input it renders the element with.
934
+ * The read is tracked, so a template rendering off `field.extra.label` re-renders when the property is written.
935
+ *
936
+ * Every property is optional here, whatever `X` states: a parameter object need not carry one and
937
+ * setExtendedValues writes as few as a caller likes, so a property `X` declares as required is present only
938
+ * once something has written it.
939
+ *
940
+ * The object is frozen and setExtendedValues is the way to change it: it is the object a transaction captured,
941
+ * and one written in place would leave a rollback with nothing to put back.
942
+ */
943
+ get extra() {
944
+ return l(this, h).extra;
945
+ }
946
+ /**
947
+ * Writes extended properties. The values given are merged over the ones the element carries, so a write of one
948
+ * property leaves the others standing, and the merged set replaces the object the element held.
949
+ */
950
+ setExtendedValues(e) {
951
+ this.touchState(), l(this, h).extra = Object.freeze(p(p({}, l(this, f).extra), e));
952
+ }
953
+ /**
954
+ * The extended properties a parameter object carries: every key the element does not answer for itself. A key
955
+ * the element answers for at the time the parameters are applied - `value`, `enabled`, an accessor a subclass
956
+ * adds - is the element's own; a key that only Object.prototype answers for is nobody's declaration and counts
957
+ * as extended, and `validators` and `actions` are neither, since they state what to register on the element.
958
+ *
959
+ * A member a subclass declares as a class field is not among the keys the element answers for: class fields are
960
+ * defined on the instance after the base constructor returns, and the parameters are applied inside it. A
961
+ * subclass that wants a parameter of its own name assigned to it declares that member as an accessor.
962
+ */
963
+ extendedOf(e) {
964
+ const t = /* @__PURE__ */ Object.create(null);
965
+ return Object.entries(e).forEach(([s, i]) => {
966
+ At.has(s) || (!(s in this) || Object.hasOwn(Object.prototype, s)) && (t[s] = i);
967
+ }), t;
968
+ }
969
+ /**
970
+ * Applies a parameter object: the members the element answers for are assigned to the element and the rest
971
+ * become its extended properties. Assigning a getter-only member throws a TypeError, which is what a caller
972
+ * naming `valid` or `parent` past the type system gets.
973
+ */
974
+ assignParams(e) {
975
+ const t = this.extendedOf(e);
976
+ Object.entries(e).forEach(([s, i]) => {
977
+ Object.hasOwn(t, s) || At.has(s) || (this[s] = i);
978
+ }), L(t) || this.setExtendedValues(t);
979
+ }
980
+ /**
981
+ * Takes this element into the record of the open transaction, where one is open. A write of a single slot that
982
+ * announces nothing calls it instead of opening a transaction of its own: on its own such a write is already
983
+ * atomic, and inside a transaction it has to be part of what a rollback puts back.
984
+ */
985
+ touchState() {
986
+ var e;
987
+ (e = kt()) == null || e.touch(this);
988
+ }
989
+ /**
990
+ * Records the whole of this element's mutable state, so that a rolled-back transaction can put it back exactly
991
+ * as it found it. The errors array is copied because a validator writes into the array it is handed rather than
992
+ * replacing it, and a subclass copies whatever else it holds by reference the same way.
993
+ *
994
+ * What is not in the snapshot is the action map, which no write touches: an operation that replaces it hands
995
+ * the transaction its own undo instead, so this stays the one shape every element captures.
996
+ */
997
+ [z]() {
998
+ return x(p({}, l(this, f)), { errors: [...l(this, f).errors] });
999
+ }
1000
+ /**
1001
+ * Puts a captured state back. It writes through the tracked view, so an effect that ran on the state the
1002
+ * transaction produced runs again on the state it is being returned to, and only for the slots that differ.
1003
+ *
1004
+ * validatingCount is the one slot the element keeps: it counts runs that are in flight, and a rollback cannot
1005
+ * un-start one. Put back, the count would no longer match the endValidating calls still to come.
1006
+ */
1007
+ [Pt](e) {
1008
+ const t = l(this, f).validatingCount;
1009
+ Object.assign(l(this, h), e), l(this, h).validatingCount = t;
451
1010
  }
452
1011
  /** true while at least one asynchronous validator is still running for this field */
453
1012
  get validating() {
454
- return this.validatingCount > 0;
1013
+ return l(this, h).validatingCount > 0;
455
1014
  }
456
1015
  /** announces the start of one asynchronous validation run; validators pair it with endValidating */
457
1016
  beginValidating() {
458
- this.validatingCount++;
1017
+ l(this, h).validatingCount++;
459
1018
  }
460
1019
  /** announces the end of one asynchronous validation run */
461
1020
  endValidating() {
462
- this.validatingCount = Math.max(0, this.validatingCount - 1);
1021
+ l(this, h).validatingCount = Math.max(0, l(this, h).validatingCount - 1);
463
1022
  }
464
- get visibility() {
465
- return this._visibility;
1023
+ /**
1024
+ * List of errors. The array handed out is the one the element holds, and a validator writes into it in place,
1025
+ * so a transaction that is open takes the element into its record here: a rollback that put back everything
1026
+ * except the errors would leave a state the form never held.
1027
+ */
1028
+ get errors() {
1029
+ return this.touchState(), l(this, h).errors;
1030
+ }
1031
+ set errors(e) {
1032
+ this.touchState(), l(this, h).errors = e;
466
1033
  }
467
- set visibility(s) {
468
- const e = this._visibility, t = this.actions.trigger(le, this, s, e);
469
- if (!C.isDefined(t != null ? t : s)) throw new Error("visibility must be a DisplayMode constant");
470
- this._visibility = C.fromAny(t != null ? t : s), this.actions.trigger(oe, this, this._visibility, e);
1034
+ /**
1035
+ * The container that holds this element: the Group it is a member of, or the List whose row it is, and
1036
+ * undefined while no container holds it. The container writes it; everyone else reads it. The read is tracked,
1037
+ * so an effect rendering off the link - `v-if="field.parent"` - re-runs when a container takes the element or
1038
+ * releases it.
1039
+ */
1040
+ get parent() {
1041
+ return l(this, h).parent;
1042
+ }
1043
+ /** when member of a Group, fieldName specifies the name of this field. Written by the group, read-only after */
1044
+ get fieldName() {
1045
+ return l(this, h).fieldName;
1046
+ }
1047
+ /**
1048
+ * The element this one was declared as: itself for an element built from parameters, and the element it was
1049
+ * bound from for a binding - transitively, so a binding of a binding names the same one. Every row a `List`
1050
+ * builds from an item template is a binding of it, so a row's member and the template's member it stands for
1051
+ * answer with the same element, and an action registered on the template can tell the two apart.
1052
+ */
1053
+ get declaration() {
1054
+ var e;
1055
+ return (e = l(this, f).declaration) != null ? e : this;
1056
+ }
1057
+ /** The elements this one holds: a Group's members, a List's rows, none for a leaf. */
1058
+ get members() {
1059
+ return [];
1060
+ }
1061
+ /**
1062
+ * Every element in this element's subtree, this element included, that was declared as `declaration`. It answers
1063
+ * the question a shared action asks when the record it changed in is not the record its targets live in - a form
1064
+ * field that every row of a list reacts to - and it costs the subtree, so it is the path taken only when the
1065
+ * cheaper one, resolving within a single record, does not apply.
1066
+ */
1067
+ bindingsOf(e) {
1068
+ const t = e.declaration, s = [], i = (r) => {
1069
+ r.declaration === t && s.push(r), r.members.forEach(i);
1070
+ };
1071
+ return i(this), s;
1072
+ }
1073
+ /**
1074
+ * States that an eager pass over this element reached an element it needs and did not find it, because the
1075
+ * record this element belongs to was not assembled at the time: a `List` row is built member by member and its
1076
+ * members are bound before any of them holds the row, so a validator comparing two of them runs before the
1077
+ * row exists. The container that finishes the record runs the pass again, and a pass that still reaches
1078
+ * nothing says so again, so the next container above answers for it.
1079
+ */
1080
+ markRecordIncomplete() {
1081
+ this._recordPending || (this._recordPending = !0, st++);
1082
+ }
1083
+ /**
1084
+ * Runs the eager passes outstanding in `element`'s subtree, now that the record it belongs to is assembled. A
1085
+ * container calls it where it has just made a record complete: a Group that has written its members, and a
1086
+ * List that has taken a row, which is what gives the row's fields the form above it.
1087
+ */
1088
+ completeRecords(e = this) {
1089
+ st !== 0 && g(() => {
1090
+ const t = (s) => {
1091
+ s._recordPending && (s._recordPending = !1, st--, s.rerunEagerActions()), s.members.forEach(t);
1092
+ };
1093
+ t(e);
1094
+ });
1095
+ }
1096
+ /** Runs this element's eager actions over the value it holds and re-forms the verdict they reach. */
1097
+ rerunEagerActions() {
1098
+ g((e) => {
1099
+ var t;
1100
+ (t = this._actions) == null || t.triggerEager(this, this.value, this.value), e.markValidityDirty(this);
1101
+ });
1102
+ }
1103
+ get actions() {
1104
+ return this._actions || (this._actions = new M()), this._actions;
1105
+ }
1106
+ set actions(e) {
1107
+ this._actions = e;
1108
+ }
1109
+ /**
1110
+ * Counts the writes that have changed the value of this element or of anything below it. A container reads it
1111
+ * before answering from its value cache, and the read is an ordinary tracked one, so an effect that took a
1112
+ * cached value still re-runs when a descendant is written.
1113
+ */
1114
+ get valueVersion() {
1115
+ return l(this, h).valueVersion;
1116
+ }
1117
+ /**
1118
+ * Marks the value of this element and of every ancestor as superseded. It walks the parent chain, so it costs
1119
+ * the nesting depth: an ancestor rebuilds its value the next time one is asked of it, instead of being walked
1120
+ * here for a reader that may never come. The walk also brings each element into the open transaction, so a
1121
+ * rollback puts the versions back and no reader is left holding a cache the tree no longer supports.
1122
+ */
1123
+ bumpValueVersion() {
1124
+ g((e) => {
1125
+ e.touch(this), l(this, h).valueVersion++;
1126
+ let t = this.parent;
1127
+ for (; t; )
1128
+ e.touch(t), l(t, h).valueVersion++, t = t.parent;
1129
+ });
1130
+ }
1131
+ /**
1132
+ * States that this element's value changed and that every container above it therefore holds a different value
1133
+ * too. Nothing is announced here: the transaction works out at commit which of the elements enrolled actually
1134
+ * ends up holding a different value, and announces those once each.
1135
+ *
1136
+ * `force` states that the caller already knows this element's value changed - one item more or fewer is a
1137
+ * different list whatever the items compare as - so the commit announces it without composing a comparison.
1138
+ */
1139
+ propagateValueChanged(e = !1) {
1140
+ g((t) => {
1141
+ var s;
1142
+ t.markValueChanged(this, e), t.markValidityDirty(this), (s = this.parent) == null || s.notifyValueChanged();
1143
+ });
1144
+ }
1145
+ /**
1146
+ * Re-reads the value that the next ValueChangedAction will report as the one it replaces. A leaf records what
1147
+ * it announced at every announcement, so its copy is always current and there is nothing to re-read; a
1148
+ * container that skipped composing a value nobody was listening for overrides this.
1149
+ */
1150
+ refreshPreviousValue() {
1151
+ }
1152
+ /**
1153
+ * The verdict validate() records and announces: this element's own errors plus the tally of children that
1154
+ * reported themselves invalid, so a container forms it without walking its members. `valid` is the read path
1155
+ * and answers over the live errors arrays instead; the two differ only for an error written into a member
1156
+ * without a validate() call, which is the documented cost of pushing errors by hand.
1157
+ */
1158
+ get countedValid() {
1159
+ return l(this, f).errors.length === 0 && l(this, f).invalidChildren === 0;
1160
+ }
1161
+ /**
1162
+ * Makes this element the container of `child`: it installs the back-reference, records the name a Group holds
1163
+ * the child under, and takes the child into the invalid tally. An element belongs to one container at a time,
1164
+ * so a child that already carries the link is refused; releaseChild() takes the link away again, and an element
1165
+ * released that way can be handed on. The child's state is unreachable from outside FieldBase, so a container
1166
+ * writes the two slots through here rather than on the child.
1167
+ */
1168
+ takeChild(e, t) {
1169
+ g((s) => {
1170
+ if (e.parent) throw new TypeError("This element already belongs to a container - pass a bind() of it");
1171
+ s.touch(e), l(e, h).fieldName = t, l(e, h).parent = this, this.adoptChild(e);
1172
+ });
1173
+ }
1174
+ /** Takes a child into this element's invalid tally; a container calls it once the child's parent link exists. */
1175
+ adoptChild(e) {
1176
+ g((t) => {
1177
+ t.touch(this), l(e, f).valid || l(this, f).invalidChildren++, t.markValidityDirty(this);
1178
+ });
1179
+ }
1180
+ /**
1181
+ * Drops a child out of this element's invalid tally and takes its back-reference away. An element keeps no link
1182
+ * to a container that no longer holds it: it would go on moving that container's tally, and the link is what
1183
+ * stands in the way of the element being taken by another container.
1184
+ */
1185
+ releaseChild(e) {
1186
+ g((t) => {
1187
+ t.touch(this), t.touch(e), l(e, f).valid || l(this, f).invalidChildren--, l(e, h).parent = void 0, t.markValidityDirty(this);
1188
+ });
1189
+ }
1190
+ /**
1191
+ * Brings this element to the state a fresh binding of `source` carrying `value` would be in: `value` is written
1192
+ * where the caller supplied one and `source`'s own value where it did not, the change history - originalValue,
1193
+ * touched - starts over and the errors are dropped and re-established by the validators. A container that reuses
1194
+ * an element at a position it already holds calls it, so the element is indistinguishable from one built for
1195
+ * that position.
1196
+ */
1197
+ resetTo(e, t) {
1198
+ g(() => {
1199
+ const s = t === void 0 ? e.value : t, i = this.errors.length > 0;
1200
+ i && (this.errors = []), this.touched = !1;
1201
+ const r = this.enabled && this.value !== s;
1202
+ this.value = s, this.originalValue = this.value, this.validate(!r && i);
1203
+ });
1204
+ }
1205
+ /** Resets a member. It is what lets a container reach the reset of a child whose class it does not know. */
1206
+ resetChild(e, t, s) {
1207
+ e.resetTo(t, s);
1208
+ }
1209
+ /**
1210
+ * Records a child's new verdict in this element's tally. The child reports it as it settles, and the commit
1211
+ * settles the deepest element first, so the tally a container reads when its own turn comes is finished.
1212
+ */
1213
+ childValidityChanged(e) {
1214
+ l(this, f).invalidChildren += e ? -1 : 1;
1215
+ }
1216
+ /**
1217
+ * The composed verdict a container answers `valid` with, memoised by Vue. The walk over the members is what
1218
+ * makes an error pushed into one of them visible without a validate() call, and the computed keeps that walk
1219
+ * from repeating while nothing it read has moved.
1220
+ */
1221
+ get validRead() {
1222
+ let e = It.get(this);
1223
+ return e || (e = jt(() => this.composeValid()), It.set(this, e)), e.value;
1224
+ }
1225
+ /** What validRead computes. A leaf answers over its own errors; a container adds its members. */
1226
+ composeValid() {
1227
+ return l(this, h).errors.length === 0;
1228
+ }
1229
+ // default property handlers
1230
+ get visibility() {
1231
+ return l(this, h).visibility;
1232
+ }
1233
+ set visibility(e) {
1234
+ g((t) => {
1235
+ var r, a;
1236
+ const s = l(this, h).visibility, i = (r = this._actions) == null ? void 0 : r.trigger(Wt, this, e, s);
1237
+ if (!N.isDefined(i != null ? i : e))
1238
+ throw new Error("visibility must be a DisplayMode constant");
1239
+ t.touch(this), l(this, h).visibility = N.fromAny(i != null ? i : e), (a = this._actions) == null || a.trigger($t, this, l(this, h).visibility, s);
1240
+ });
471
1241
  }
472
1242
  get enabled() {
473
- return this._enabled;
1243
+ return l(this, h).enabled;
1244
+ }
1245
+ set enabled(e) {
1246
+ g((t) => {
1247
+ var r, a;
1248
+ const s = l(this, h).enabled, i = (r = this._actions) == null ? void 0 : r.trigger(Bt, this, e, s);
1249
+ if (!Kt(i != null ? i : e)) throw new Error("Enabled value must be boolean");
1250
+ t.touch(this), l(this, h).enabled = i != null ? i : e, l(this, h).enabled !== s && this.bumpValueVersion(), (a = this._actions) == null || a.trigger(Ut, this, l(this, h).enabled, s);
1251
+ });
1252
+ }
1253
+ /**
1254
+ * True for an element whose value is composed of its members'. The commit builds such a value only where
1255
+ * something receives it, compares it by content rather than by identity, and runs the element's own validators
1256
+ * with the announcement: a container's validators read the composed value, which exists only once the members
1257
+ * have been written. A leaf's validators have run at the write instead, so its announcement carries no eager
1258
+ * pass of its own.
1259
+ */
1260
+ get composesValue() {
1261
+ return !1;
474
1262
  }
475
- set enabled(s) {
476
- const e = this._enabled, t = this.actions.trigger(ie, this, s, e);
477
- if (!pe(t != null ? t : s)) throw new Error("Enabled value must be boolean");
478
- this._enabled = t != null ? t : s, this.actions.trigger(re, this, this._enabled, e);
1263
+ /**
1264
+ * Announces what this element's value became over the transaction. The pair carried is (value now, value at the
1265
+ * last announcement), so a value that went A -> B -> A within the transaction says nothing, and the events an
1266
+ * operation states rather than an element's state - an item added, an item removed - are emitted first, in the
1267
+ * order the operations happened.
1268
+ */
1269
+ [Ft](e, t, s, i) {
1270
+ if (i == null || i.forEach((c) => {
1271
+ var u;
1272
+ return (u = this._actions) == null ? void 0 : u.trigger(c.actionClass, this, c.item, c.index);
1273
+ }), !t) return;
1274
+ const r = this._actions;
1275
+ if (this.composesValue && !(r != null && r.willTrigger(B))) return;
1276
+ const a = this.value, o = l(this, f).announcedValue;
1277
+ !s && (this.composesValue ? nt(a, o) : a === o) || (e.touch(this), l(this, f).announcedValue = a, this.composesValue ? r == null || r.trigger(O, this, a, o) : r == null || r.triggerChain(B, this, a, o));
1278
+ }
1279
+ /**
1280
+ * Forms the verdict this element ends the transaction with and announces a transition of it. The container is
1281
+ * told first, so a handler reads a tally that already includes this verdict, and it is enrolled in the same
1282
+ * transaction: its own verdict is composed of its members', so a member that moves without a value change - an
1283
+ * asynchronous validator, an error pushed in by hand - is what makes the container re-form its own. The
1284
+ * transaction settles the deepest element first, so a container is reached only once its members have decided.
1285
+ */
1286
+ [Nt](e) {
1287
+ var r;
1288
+ const t = l(this, f).valid, s = this.countedValid;
1289
+ if (s === t) return;
1290
+ e.touch(this), l(this, f).valid = s;
1291
+ const i = this.parent;
1292
+ i && (e.touch(i), i.childValidityChanged(s), e.markValidityDirty(i)), (r = this._actions) == null || r.trigger(Mt, this, s, t);
479
1293
  }
480
- validate(s = !1) {
481
- s && this.actions.triggerEager(this, this.value, this.value);
482
- const e = this._valid;
483
- this._valid = this.valid, this._valid !== e && this.actions.trigger(ae, this, this.valid, e);
1294
+ validate(e = !1) {
1295
+ g((t) => {
1296
+ var s;
1297
+ e && ((s = this._actions) == null || s.triggerEager(this, this.value, this.value)), t.markValidityDirty(this);
1298
+ });
484
1299
  }
485
1300
  get valid() {
486
- return this.errors.length === 0;
1301
+ return l(this, h).errors.length === 0;
487
1302
  }
488
1303
  get fullValue() {
489
1304
  return this.value;
490
1305
  }
491
1306
  get isChanged() {
492
- return !k(this.value, this.originalValue);
1307
+ return !nt(this.value, this.originalValue);
1308
+ }
1309
+ /**
1310
+ * Brings a fresh element into the state a binding of `source` is in: it records what it was declared as, takes
1311
+ * on the extended properties and the actions `source` carries, and runs the eager ones over the value it was
1312
+ * built with. The extended properties `overrides` states are written over the ones `source` carries, and they
1313
+ * are in place before the eager pass, so an action reading one sees what the binding ends up carrying. The
1314
+ * actions are the very instances `source` holds - what a binding takes on is data, not behaviour - and each is
1315
+ * told about this element as it is taken on, so an action serving several bindings knows all of them.
1316
+ */
1317
+ boundFrom(e, t, s, i) {
1318
+ l(this, f).declaration = e.declaration;
1319
+ const r = p(p({}, e.extra), i && this.extendedOf(i));
1320
+ L(r) || this.setExtendedValues(r);
1321
+ const a = e._actions;
1322
+ a && (this._actions = a.clone(), this._actions.bindTo(this), this._actions.triggerEager(this, t, s));
493
1323
  }
494
- registerAction(s) {
495
- return this.actions.register(s), s.boundToField(this), s.eager && this.actions.trigger(Object.getPrototypeOf(s).constructor, this, this.value, this.originalValue), this;
1324
+ /**
1325
+ * Registers the actions a constructor received in its parameters: registration without the eager trigger,
1326
+ * because a constructor ends with a single this.actions.triggerEager(...) over the finished value, and an
1327
+ * eager action registered here would otherwise also run once per registration, over a half-built field.
1328
+ */
1329
+ registerInitialActions(e) {
1330
+ e.forEach((t) => {
1331
+ this.actions.register(t), t.boundToBinding(this);
1332
+ });
496
1333
  }
497
- triggerAction(s, ...e) {
498
- return this.actions.trigger(s, this, ...e);
1334
+ registerAction(e) {
1335
+ return g((t) => {
1336
+ t.willAnnounceValue(this) || this.refreshPreviousValue(), this.actions.register(e), e.boundToBinding(this), e.eager && this.actions.trigger(Object.getPrototypeOf(e).constructor, this, this.value, this.originalValue);
1337
+ }), this;
1338
+ }
1339
+ triggerAction(e, ...t) {
1340
+ return this._actions ? this._actions.trigger(e, this, ...t) : null;
1341
+ }
1342
+ /**
1343
+ * Generation counter of the validators attached to this field. A Validator reads it when a run starts and drops
1344
+ * a result whose epoch no longer matches, so a validation still in flight when clearValidators() is called
1345
+ * cannot push an error onto a field that no longer has the validator that produced it.
1346
+ */
1347
+ get validationEpoch() {
1348
+ return l(this, h).validationEpoch;
499
1349
  }
500
1350
  clearValidators() {
501
- this.actions = this.actions.cloneWithoutValidators(), this.errors = [], this._valid = !0;
1351
+ g((e) => {
1352
+ if (e.touch(this), l(this, h).validationEpoch++, this._actions) {
1353
+ const t = this._actions, s = t.validators;
1354
+ e.whenRolledBack(() => {
1355
+ this._actions = t;
1356
+ }), this.actions = t.cloneWithoutValidators(), e.whenCommitted(() => s.forEach((i) => i.unregisterFrom(this)));
1357
+ }
1358
+ this.errors = [], this.validate();
1359
+ });
502
1360
  }
503
1361
  }
504
- function Oe(i, s) {
505
- return i ? !s : s;
1362
+ h = new WeakMap(), f = new WeakMap();
1363
+ function Se(n, e) {
1364
+ return n ? !e : e;
506
1365
  }
507
- class w {
508
- constructor(s, e, t) {
509
- o(this, "operand1");
510
- o(this, "operator");
511
- o(this, "operand2");
512
- this.operand1 = s, this.operator = e, this.operand2 = t;
1366
+ class I {
1367
+ constructor(e, t, s) {
1368
+ d(this, "operand1");
1369
+ d(this, "operator");
1370
+ d(this, "operand2");
1371
+ this.operand1 = e, this.operator = t, this.operand2 = s;
1372
+ }
1373
+ /**
1374
+ * The value an operand contributes. A field operand names a field of the record the statement is evaluated in:
1375
+ * the same statement over a `List` reads row 3's field while row 3 is the record, and a field belonging to no
1376
+ * record of the statement's own - a form field above the list - is read where it stands. A record that does not
1377
+ * hold the field yet contributes undefined, which is what a half-built row answers with.
1378
+ */
1379
+ static valueOf(e, t) {
1380
+ if (e instanceof I) return e.evaluate(t);
1381
+ if (e instanceof A) {
1382
+ const s = t ? ut(e, t) : e;
1383
+ return s ? b(s.value) : void 0;
1384
+ }
1385
+ return e;
513
1386
  }
514
1387
  get operand1Value() {
515
- return this.operand1 instanceof w ? this.operand1.evaluate() : this.operand1 instanceof x ? g(this.operand1.value) : this.operand1;
1388
+ return I.valueOf(this.operand1);
516
1389
  }
517
1390
  get operand2Value() {
518
- return this.operand2 instanceof w ? this.operand2.evaluate() : this.operand2 instanceof x ? g(this.operand2.value) : this.operand2;
1391
+ return I.valueOf(this.operand2);
519
1392
  }
520
- evaluate() {
521
- var t, n, r, a;
522
- const s = this.operand1Value, e = this.operand2Value;
1393
+ /**
1394
+ * The result of the statement, over the record `scope` belongs to where one is given and over the fields the
1395
+ * statement was built from where it is not.
1396
+ */
1397
+ evaluate(e) {
1398
+ var i, r;
1399
+ const t = I.valueOf(this.operand1, e), s = I.valueOf(this.operand2, e);
523
1400
  switch (this.operator) {
524
1401
  // logical operators
525
- case d.AND:
526
- return s && e;
527
- case d.OR:
528
- return s || e;
529
- case d.NAND:
530
- return !(s && e);
531
- case d.NOR:
532
- return !(s || e);
533
- case d.XOR:
534
- return Oe(s, e);
535
- case d.NOT:
536
- return !s;
1402
+ // `&&` and `||` evaluate to one of their operands, and the operands are of any type. Without the
1403
+ // coercion evaluate() would hand out the operand itself, so `0` or `''` would reach callers that the
1404
+ // signature promises a boolean, and consumers comparing results with !== would see a change where the
1405
+ // logical value stayed the same.
1406
+ case m.AND:
1407
+ return !!(t && s);
1408
+ case m.OR:
1409
+ return !!(t || s);
1410
+ case m.NAND:
1411
+ return !(t && s);
1412
+ case m.NOR:
1413
+ return !(t || s);
1414
+ case m.XOR:
1415
+ return Se(!!t, !!s);
1416
+ case m.NOT:
1417
+ return !t;
537
1418
  // comparison operators
538
- case d.EQUALS:
539
- return s == e;
540
- case d.NOT_EQUALS:
541
- return s != e;
542
- case d.LT:
543
- return s < e;
544
- case d.LE:
545
- return s <= e;
546
- case d.GE:
547
- return s >= e;
548
- case d.GT:
549
- return s > e;
550
- case d.IN:
551
- return (n = (t = e == null ? void 0 : e.includes) == null ? void 0 : t.call(e, s)) != null ? n : !1;
552
- case d.NOT_IN:
553
- return !((a = (r = e == null ? void 0 : e.includes) == null ? void 0 : r.call(e, s)) == null || a);
554
- case d.INCLUDES:
555
- return V(s) && V(e) && s.indexOf(e) >= 0;
556
- case d.NOT_INCLUDES:
557
- return !(V(s) && V(e) && s.indexOf(e) >= 0);
1419
+ case m.EQUALS:
1420
+ return t == s;
1421
+ case m.NOT_EQUALS:
1422
+ return t != s;
1423
+ case m.LT:
1424
+ return t < s;
1425
+ case m.LE:
1426
+ return t <= s;
1427
+ case m.GE:
1428
+ return t >= s;
1429
+ case m.GT:
1430
+ return t > s;
1431
+ case m.IN:
1432
+ return !!((i = s == null ? void 0 : s.includes) != null && i.call(s, t));
1433
+ case m.NOT_IN:
1434
+ return !((r = s == null ? void 0 : s.includes) != null && r.call(s, t));
1435
+ case m.INCLUDES:
1436
+ return P(t) && P(s) && t.indexOf(s) >= 0;
1437
+ case m.NOT_INCLUDES:
1438
+ return !(P(t) && P(s) && t.indexOf(s) >= 0);
558
1439
  default:
559
1440
  throw new Error(`Operator not implemented ${this.operator}`);
560
1441
  }
@@ -564,55 +1445,97 @@ class w {
564
1445
  * @returns A set of all fields used in this statement
565
1446
  */
566
1447
  collectFields() {
567
- const s = /* @__PURE__ */ new Set();
568
- function e(t) {
569
- t instanceof x ? s.add(t) : t instanceof w && t.collectFields().forEach((r) => s.add(r));
1448
+ const e = /* @__PURE__ */ new Set();
1449
+ function t(s) {
1450
+ s instanceof A ? e.add(s) : s instanceof I && s.collectFields().forEach((r) => e.add(r));
570
1451
  }
571
- return e(this.operand1), e(this.operand2), s;
1452
+ return t(this.operand1), t(this.operand2), e;
572
1453
  }
573
1454
  }
574
- const Pe = /* @__PURE__ */ Symbol("ExecuteAction");
575
- class ce extends b {
576
- constructor(s) {
577
- super(s);
1455
+ const Ie = /* @__PURE__ */ Symbol("ExecuteAction");
1456
+ class qt extends y {
1457
+ constructor(e) {
1458
+ super(e);
578
1459
  }
579
1460
  static get classIdentifier() {
580
- return Pe;
1461
+ return Ie;
581
1462
  }
582
- execute(s, e, t) {
583
- return super.execute(s, e, t);
1463
+ execute(e, t, s) {
1464
+ return super.execute(e, t, s);
584
1465
  }
585
1466
  }
586
- const Re = /* @__PURE__ */ Symbol("ListItemAddedAction");
587
- class z extends b {
588
- constructor(s) {
589
- super(s);
1467
+ const Ae = /* @__PURE__ */ Symbol("ListItemAddedAction");
1468
+ class at extends y {
1469
+ constructor(e) {
1470
+ super(e);
590
1471
  }
591
1472
  static get classIdentifier() {
592
- return Re;
1473
+ return Ae;
593
1474
  }
594
- execute(s, e, t, n) {
595
- return super.execute(s, e, t, n);
1475
+ execute(e, t, s, i) {
1476
+ return super.execute(e, t, s, i);
596
1477
  }
597
1478
  }
598
- const Ue = /* @__PURE__ */ Symbol("ListItemRemovedAction");
599
- class ue extends b {
600
- constructor(s) {
601
- super(s);
1479
+ const _e = /* @__PURE__ */ Symbol("ListItemRemovedAction");
1480
+ class zt extends y {
1481
+ constructor(e) {
1482
+ super(e);
602
1483
  }
603
1484
  static get classIdentifier() {
604
- return Ue;
1485
+ return _e;
605
1486
  }
606
- execute(s, e, t, n) {
607
- return super.execute(s, e, t, n);
1487
+ execute(e, t, s, i) {
1488
+ return super.execute(e, t, s, i);
608
1489
  }
609
1490
  }
610
- class D extends x {
1491
+ const Te = Object.freeze({});
1492
+ function Ht() {
1493
+ return {
1494
+ originalValue: void 0,
1495
+ announcedValue: void 0,
1496
+ errors: [],
1497
+ visibility: N.FULL,
1498
+ enabled: !0,
1499
+ valueVersion: 0,
1500
+ validatingCount: 0,
1501
+ parent: void 0,
1502
+ fieldName: void 0,
1503
+ validationEpoch: 0,
1504
+ declaration: void 0,
1505
+ extra: Te,
1506
+ valid: !0,
1507
+ invalidChildren: 0
1508
+ };
1509
+ }
1510
+ function Oe() {
1511
+ return x(p({}, Ht()), { value: void 0, touched: !1 });
1512
+ }
1513
+ function Qt() {
1514
+ return x(p({}, Ht()), {
1515
+ announcedValue: null,
1516
+ cachedValue: null,
1517
+ cachedValueVersion: -1
1518
+ });
1519
+ }
1520
+ function je() {
1521
+ return x(p({}, Qt()), { rows: null });
1522
+ }
1523
+ class X extends A {
1524
+ get state() {
1525
+ return super.state;
1526
+ }
1527
+ get raw() {
1528
+ return super.raw;
1529
+ }
1530
+ /** the value slot itself, without the notifications the value setter carries around a write */
1531
+ get _value() {
1532
+ return this.state.value;
1533
+ }
1534
+ set _value(e) {
1535
+ this.state.value = e;
1536
+ }
611
1537
  constructor(e) {
612
- super();
613
- o(this, "_value");
614
- o(this, "_touched", !1);
615
- this.init(e);
1538
+ super(Oe()), this.init(e);
616
1539
  }
617
1540
  /**
618
1541
  * Applies the constructor parameters. It is a hook so that a subclass needing different parameter handling
@@ -624,78 +1547,132 @@ class D extends x {
624
1547
  * the moment the initializer runs.
625
1548
  */
626
1549
  init(e) {
627
- if (e) {
628
- const t = e, { value: n, validators: r, actions: a } = t, l = I(t, ["value", "validators", "actions"]);
629
- [...r || [], ...a || []].forEach((c) => this.registerAction(c)), Object.assign(this, l), this._value = n != null ? n : this.originalValue, this.originalValue === void 0 && (this.originalValue = this._value);
630
- }
631
- this.actions.triggerEager(this, this.value, this.originalValue), this.validate();
1550
+ g(() => {
1551
+ var s;
1552
+ if (e) {
1553
+ const t = e, { value: i, validators: r, actions: a } = t, o = k(t, ["value", "validators", "actions"]);
1554
+ this.registerInitialActions([...r || [], ...a || []]), this.assignParams(o), this._value = i !== void 0 ? i : this.originalValue, this.originalValue === void 0 && (this.originalValue = this._value);
1555
+ }
1556
+ this.raw.announcedValue = this._value, (s = this._actions) == null || s.triggerEager(this, this.value, this.originalValue), this.validate();
1557
+ });
632
1558
  }
633
1559
  get value() {
634
1560
  return this._value;
635
1561
  }
636
1562
  set value(e) {
637
1563
  const t = this._value;
638
- !this.enabled || t === e || (this._value = e, this.actions.trigger(m, this, this._value, t), this.parent && this.parent.notifyValueChanged(), this.validate());
1564
+ !this.enabled || t === e || g((s) => {
1565
+ var i;
1566
+ s.touch(this), this._value = e, this.bumpValueVersion(), (i = this._actions) == null || i.triggerEager(this, e, t), this.propagateValueChanged();
1567
+ });
639
1568
  }
640
1569
  get touched() {
641
- return this._touched;
1570
+ return this.state.touched;
642
1571
  }
643
1572
  set touched(e) {
644
- this._touched = e;
645
- }
646
- clone(e) {
647
- var r, a, l;
648
- const t = this.constructor, n = new t(R(y({
649
- value: (r = e == null ? void 0 : e.value) != null ? r : this.value
650
- }, e && "originalValue" in e ? { originalValue: e.originalValue } : {}), {
651
- enabled: (a = e == null ? void 0 : e.enabled) != null ? a : this.enabled,
652
- visibility: (l = e == null ? void 0 : e.visibility) != null ? l : this.visibility
1573
+ this.touchState(), this.state.touched = e;
1574
+ }
1575
+ bind(e, t) {
1576
+ var r, a;
1577
+ const s = this.constructor, i = new s(x(p({
1578
+ // data is what the caller supplied, and undefined is not supplied; an explicit null is, and clears
1579
+ value: e !== void 0 ? e : this.value
1580
+ }, t && "originalValue" in t ? { originalValue: t.originalValue } : {}), {
1581
+ enabled: (r = t == null ? void 0 : t.enabled) != null ? r : this.enabled,
1582
+ visibility: (a = t == null ? void 0 : t.visibility) != null ? a : this.visibility
653
1583
  }));
654
- return n.actions = this.actions.clone(), n.actions.triggerEager(n, n.value, n.originalValue), n;
1584
+ return i.boundFrom(this, i.value, i.originalValue, t), i;
655
1585
  }
656
1586
  }
657
- const ke = new D({ value: "EmptyField" }).registerAction(
658
- new m(() => {
1587
+ const Pe = new X({ value: "EmptyField" }).registerAction(
1588
+ new O(() => {
659
1589
  console.warn("Working with EmptyField! This should not happen");
660
1590
  })
661
- );
662
- function M(i, s) {
663
- return (i == null ? void 0 : i.label) == null && (i == null ? void 0 : i.icon) == null ? s : i;
664
- }
665
- class Be extends D {
666
- init(s) {
667
- if (this._value = { label: void 0, icon: void 0 }, s) {
668
- const e = s, { value: t, originalValue: n, validators: r, actions: a } = e, l = I(e, ["value", "originalValue", "validators", "actions"]);
669
- [...r || [], ...a || []].forEach((h) => this.registerAction(h)), Object.assign(this, l);
670
- const c = M(t, this._value), u = Object.freeze({ label: n == null ? void 0 : n.label, icon: n == null ? void 0 : n.icon });
671
- this._value = M(c, y({}, u)), this.originalValue = M(u, c);
672
- }
673
- this.actions.triggerEager(this, this.value, this.originalValue), this.validate();
1591
+ ), _t = /* @__PURE__ */ new WeakMap();
1592
+ function it(n, e) {
1593
+ return (n == null ? void 0 : n.label) == null && (n == null ? void 0 : n.icon) == null ? e : n;
1594
+ }
1595
+ class Fe extends X {
1596
+ init(e) {
1597
+ g(() => {
1598
+ var s;
1599
+ if (this._value = { label: void 0, icon: void 0 }, e) {
1600
+ const t = e, { value: i, originalValue: r, validators: a, actions: o } = t, c = k(t, ["value", "originalValue", "validators", "actions"]);
1601
+ this.registerInitialActions([...a || [], ...o || []]), this.assignParams(c);
1602
+ const u = it(i, this._value), C = Object.freeze({ label: r == null ? void 0 : r.label, icon: r == null ? void 0 : r.icon });
1603
+ this._value = it(u, p({}, C)), this.originalValue = it(C, u);
1604
+ }
1605
+ this.raw.announcedValue = this._value, (s = this._actions) == null || s.triggerEager(this, this.value, this.originalValue), this.validate();
1606
+ });
1607
+ }
1608
+ /**
1609
+ * A copy of the value this action holds, carrying one member rewritten. A member handed undefined is dropped
1610
+ * from the copy rather than written into it: an own key holding undefined is invisible to a reader and to
1611
+ * JSON, but lodash isEqual compares own-key sets, so writing one would leave the action permanently changed
1612
+ * against a baseline that never carried the key.
1613
+ */
1614
+ valueWith(e, t) {
1615
+ const s = p({}, this.value);
1616
+ return t === void 0 ? delete s[e] : s[e] = t, s;
674
1617
  }
675
1618
  get icon() {
676
1619
  return this.value.icon;
677
1620
  }
678
- set icon(s) {
679
- this.value.icon = s;
1621
+ set icon(e) {
1622
+ this.value.icon !== e && (this.value = this.valueWith("icon", e));
680
1623
  }
681
1624
  get label() {
682
1625
  return this.value.label;
683
1626
  }
684
- set label(s) {
685
- this.value.label = s;
1627
+ /**
1628
+ * The two setters hand the value setter a new object rather than writing into the one the action holds, so each
1629
+ * is an ordinary value change: the handlers fire, isChanged answers over it, and a disabled action refuses it.
1630
+ * The new object is built only for a member that differs from the one held - the value setter compares by
1631
+ * identity and every copy is a new object, so without the comparison here a write of the value already held
1632
+ * would announce a change and invalidate the value cache of every container above.
1633
+ */
1634
+ set label(e) {
1635
+ this.value.label !== e && (this.value = this.valueWith("label", e));
686
1636
  }
687
- execute(s) {
688
- this.actions.trigger(ce, this, s);
1637
+ /** the counter behind `busy`, allocated for this action the first time it is asked for */
1638
+ get busyRuns() {
1639
+ let e = _t.get(this);
1640
+ return e || (e = se(0), _t.set(this, e)), e;
1641
+ }
1642
+ /** true from the moment execute() is called until the handler it ran has settled, however it settles */
1643
+ get busy() {
1644
+ return this.busyRuns.value > 0;
1645
+ }
1646
+ /**
1647
+ * Runs the ExecuteAction chain registered on this action and answers what the chain returned. `busy` stands for
1648
+ * the length of the run: the chain is entered synchronously, and the flag is cleared once the value it produced
1649
+ * has settled - a handler that returns a promise holds it for as long as that promise takes, and one that
1650
+ * rejects clears it as it rejects.
1651
+ *
1652
+ * The answer is a promise whatever the handler returns, so a handler that throws rejects it rather than throwing
1653
+ * out of this call: a caller that does not await the answer and does not attach a catch handler leaves that
1654
+ * rejection unhandled.
1655
+ */
1656
+ execute(e) {
1657
+ return wt(this, null, function* () {
1658
+ const t = this.busyRuns;
1659
+ t.value++;
1660
+ try {
1661
+ return yield this.triggerAction(qt, e);
1662
+ } finally {
1663
+ t.value--;
1664
+ }
1665
+ });
689
1666
  }
690
1667
  }
691
- const De = /* @__PURE__ */ ye({
1668
+ const Ne = /* @__PURE__ */ ie({
692
1669
  __name: "messages-widget",
693
1670
  props: {
694
1671
  message: {},
695
1672
  classes: {}
696
1673
  },
697
- setup(i) {
698
- const s = i, e = Z("vue-markdown"), t = /* @__PURE__ */ new Set([
1674
+ setup(n) {
1675
+ const e = n, t = yt("vue-markdown"), s = /* @__PURE__ */ new Set([
699
1676
  "div",
700
1677
  "span",
701
1678
  "p",
@@ -751,37 +1728,37 @@ const De = /* @__PURE__ */ ye({
751
1728
  "dl",
752
1729
  "dt",
753
1730
  "dd"
754
- ]), n = () => {
755
- if (typeof s.message == "string") return S("span", { class: s.classes }, s.message);
1731
+ ]), i = () => {
1732
+ if (typeof e.message == "string") return R("span", { class: e.classes }, e.message);
756
1733
  const r = [];
757
- return s.message.forEach((a) => {
1734
+ return e.message.forEach((a) => {
758
1735
  switch (a.componentName) {
759
1736
  case "template":
760
- r.push(S("div", { class: [s.classes, a.extraClasses] }, a.componentBody));
1737
+ r.push(R("div", { class: [e.classes, a.extraClasses] }, a.componentBody));
761
1738
  break;
762
1739
  case "vue-markdown":
763
- if (typeof e == "string")
1740
+ if (typeof t == "string")
764
1741
  console.warn(
765
1742
  "You are using markdown for messages-widget, but you haven't registered a vue-markdown component"
766
- ), r.push(S("div", { class: [s.classes, a.extraClasses] }, a.componentBindings.source));
1743
+ ), r.push(R("div", { class: [e.classes, a.extraClasses] }, a.componentBindings.source));
767
1744
  else {
768
- const l = a.componentBindings;
1745
+ const o = a.componentBindings;
769
1746
  r.push(
770
- S(e, {
771
- class: [s.classes, a.extraClasses, "df-messages-widget-markdown"],
772
- source: l.source,
773
- options: l.options,
774
- plugins: l.plugins
1747
+ R(t, {
1748
+ class: [e.classes, a.extraClasses, "df-messages-widget-markdown"],
1749
+ source: o.source,
1750
+ options: o.options,
1751
+ plugins: o.plugins
775
1752
  })
776
1753
  );
777
1754
  }
778
1755
  break;
779
1756
  default:
780
1757
  r.push(
781
- S(
782
- t.has(a.componentName.toLowerCase()) ? a.componentName : Z(a.componentName),
783
- y(y({
784
- class: [s.classes, a.extraClasses]
1758
+ R(
1759
+ s.has(a.componentName.toLowerCase()) ? a.componentName : yt(a.componentName),
1760
+ p(p({
1761
+ class: [e.classes, a.extraClasses]
785
1762
  }, a.componentBindings), a.componentBody ? { innerHTML: a.componentBody } : {})
786
1763
  )
787
1764
  );
@@ -789,419 +1766,619 @@ const De = /* @__PURE__ */ ye({
789
1766
  }
790
1767
  }), r;
791
1768
  };
792
- return (r, a) => (xe(), Ee(n));
1769
+ return (r, a) => (ne(), re(i));
793
1770
  }
794
1771
  });
795
- class _ extends x {
796
- constructor(e, t) {
797
- super();
798
- o(this, "_fields");
799
- o(this, "_value", null);
800
- o(this, "suppressNotifyValueChanged", !1);
801
- if (!_.isValidFields(e)) throw new Error("Invalid fields object provided");
802
- if (this._fields = /* @__PURE__ */ Object.create(null), Object.entries(e).forEach(([r, a]) => this.addField(r, a)), t) {
803
- const n = t, { value: r, validators: a, actions: l } = n, c = I(n, ["value", "validators", "actions"]);
804
- [...a || [], ...l || []].forEach((u) => this.registerAction(u)), Object.assign(this, c), this.value = r != null ? r : this.originalValue;
805
- }
806
- this.originalValue === void 0 && (this.originalValue = this.value), this.actions.triggerEager(this, this.value, this.originalValue), this.validate();
1772
+ class w extends A {
1773
+ constructor(t, s) {
1774
+ super(Qt());
1775
+ d(this, "_fields");
1776
+ if (!w.isValidFields(t)) throw new Error("Invalid fields object provided");
1777
+ this._fields = /* @__PURE__ */ Object.create(null), g(() => {
1778
+ var a;
1779
+ if (Object.entries(t).forEach(([o, c]) => this.addField(o, c)), s) {
1780
+ const r = s, { value: o, validators: c, actions: u } = r, C = k(r, ["value", "validators", "actions"]);
1781
+ this.registerInitialActions([...c || [], ...u || []]), this.assignParams(C), o !== void 0 ? this.assignMembers(o) : this.originalValue !== void 0 && this.assignMembers(this.originalValue);
1782
+ }
1783
+ this.completeRecords();
1784
+ const i = this.value;
1785
+ this.originalValue === void 0 && (this.originalValue = w.baseline(i)), this.raw.announcedValue = i, (a = this._actions) == null || a.triggerEager(this, i, this.originalValue), this.validate();
1786
+ });
1787
+ }
1788
+ get state() {
1789
+ return super.state;
1790
+ }
1791
+ get raw() {
1792
+ return super.raw;
1793
+ }
1794
+ /**
1795
+ * The copy of a built value that serves as a baseline. The value getter hands out one object per version, and
1796
+ * a baseline holding that same object would report every value as its own original.
1797
+ */
1798
+ static baseline(t) {
1799
+ return t == null ? t : p({}, t);
807
1800
  }
808
- addField(e, t) {
809
- if (Object.hasOwn(this._fields, e))
810
- throw new Error(`Field ${e} is already in this form`);
811
- Object.defineProperty(t, "parent", { get: () => this, configurable: !1, enumerable: !1 }), Object.defineProperty(t, "fieldName", { get: () => e, configurable: !1, enumerable: !1 }), Object.defineProperty(this._fields, e, { get: () => t, configurable: !1, enumerable: !0 });
1801
+ addField(t, s) {
1802
+ if (Object.hasOwn(this._fields, t))
1803
+ throw new Error(`Field ${t} is already in this form`);
1804
+ this.takeChild(s, t), Object.defineProperty(this._fields, t, { get: () => s, configurable: !1, enumerable: !0 });
812
1805
  }
813
- static isValidFields(e) {
814
- function t(n) {
815
- return n instanceof x;
1806
+ static isValidFields(t) {
1807
+ function s(i) {
1808
+ return i instanceof A;
816
1809
  }
817
- return typeof e == "object" && e !== null && Object.entries(e).every(([, n]) => t(n));
1810
+ return typeof t == "object" && t !== null && Object.entries(t).every(([, i]) => s(i));
818
1811
  }
819
- static createFromFormData(e) {
820
- if (e instanceof x)
1812
+ static createFromFormData(t) {
1813
+ if (t instanceof A)
821
1814
  throw new Error("data is already a Form structure, should be a simple object");
822
- return new _(
823
- e == null ? {} : Object.fromEntries(Object.entries(e).map(([t, n]) => [t, new D({ value: n })]))
1815
+ return new w(
1816
+ t == null ? {} : Object.fromEntries(Object.entries(t).map(([s, i]) => [s, new X({ value: i })]))
824
1817
  );
825
1818
  }
826
- field(e) {
827
- var t;
828
- return (t = this._fields[e]) != null ? t : null;
1819
+ field(t) {
1820
+ var s;
1821
+ return (s = this._fields[t]) != null ? s : null;
829
1822
  }
830
1823
  get fields() {
831
1824
  return this._fields;
832
1825
  }
1826
+ get members() {
1827
+ return Object.values(this._fields);
1828
+ }
833
1829
  get value() {
834
- const e = /* @__PURE__ */ Object.create(null);
835
- return Object.entries(this._fields).forEach(([t, n]) => {
836
- const r = n.value;
837
- (n.enabled || n instanceof _ && !H(r)) && (e[t] = r);
838
- }), H(e) ? null : y({}, e);
1830
+ const t = this.valueVersion;
1831
+ if (this.raw.cachedValueVersion === t) return this.raw.cachedValue;
1832
+ const s = /* @__PURE__ */ Object.create(null);
1833
+ Object.entries(this._fields).forEach(([r, a]) => {
1834
+ const o = a.value;
1835
+ (a.enabled || a instanceof w && !L(o)) && (s[r] = o);
1836
+ });
1837
+ const i = L(s) ? null : Object.freeze(p({}, s));
1838
+ return this.raw.cachedValue = i, this.raw.cachedValueVersion = t, i;
839
1839
  }
840
- set value(e) {
841
- this.suppressNotifyValueChanged = !0;
842
- try {
843
- Object.entries(this._fields).forEach(([t, n]) => {
844
- (e == null || Object.hasOwn(e, t)) && (n.value = e == null ? null : e[t]);
1840
+ /**
1841
+ * Writes the members that the given value carries. The members are written one by one and the group says
1842
+ * nothing in between: the transaction the assignment runs in measures the group's own value and its own verdict
1843
+ * once, over the finished set, and announces each at most once.
1844
+ */
1845
+ assignMembers(t) {
1846
+ g(() => {
1847
+ Object.entries(this._fields).forEach(([s, i]) => {
1848
+ (t == null || Object.hasOwn(t, s)) && (i.value = t == null ? null : t[s]);
845
1849
  });
846
- } finally {
847
- this.suppressNotifyValueChanged = !1;
848
- }
849
- this.notifyValueChanged(), this.validate();
1850
+ });
1851
+ }
1852
+ set value(t) {
1853
+ g((s) => {
1854
+ this.assignMembers(t), s.markValidityDirty(this);
1855
+ });
1856
+ }
1857
+ /**
1858
+ * Members are reset one by one rather than assigned as a whole value: the value setter writes only the keys the
1859
+ * value carries, while a member the value leaves out has to end up holding what the template gives it. `source`
1860
+ * supplies that per member, so a group reset from the template it was bound from matches a fresh binding of it.
1861
+ */
1862
+ resetTo(t, s) {
1863
+ const i = t;
1864
+ g((r) => {
1865
+ r.touch(this), this.errors.length && (this.errors = []), Object.entries(this._fields).forEach(([o, c]) => {
1866
+ var C;
1867
+ let u;
1868
+ s === null ? u = null : s !== void 0 && Object.hasOwn(s, o) && (u = s[o]), this.resetChild(c, (C = i.field(o)) != null ? C : c, u);
1869
+ });
1870
+ const a = this.value;
1871
+ this.raw.announcedValue = a, this.originalValue = w.baseline(a), super.validate(!0);
1872
+ });
850
1873
  }
851
1874
  get touched() {
852
- return Object.values(this._fields).some((e) => e.touched);
1875
+ return Object.values(this._fields).some((t) => t.touched);
853
1876
  }
854
- set touched(e) {
855
- Object.values(this._fields).forEach((t) => {
856
- t.touched = e;
1877
+ set touched(t) {
1878
+ g(() => {
1879
+ Object.values(this._fields).forEach((s) => {
1880
+ s.touched = t;
1881
+ });
857
1882
  });
858
1883
  }
859
1884
  get fullValue() {
860
- const e = /* @__PURE__ */ Object.create(null);
861
- return Object.entries(this._fields).forEach(([t, n]) => {
862
- e[t] = n.fullValue;
863
- }), y({}, e);
1885
+ const t = /* @__PURE__ */ Object.create(null);
1886
+ return Object.entries(this._fields).forEach(([s, i]) => {
1887
+ t[s] = i.fullValue;
1888
+ }), p({}, t);
864
1889
  }
1890
+ /**
1891
+ * Records that a member changed its value, so that the transaction in progress works out at commit what this
1892
+ * group's own value became and announces it once. A mutation method calls it itself; you rarely need to.
1893
+ */
865
1894
  notifyValueChanged() {
866
- if (this.suppressNotifyValueChanged) return;
867
- const e = this.value;
868
- if (!k(e, this._value)) {
869
- const t = this._value;
870
- this._value = e, this.actions.trigger(m, this, e, t), this.parent && this.parent.notifyValueChanged(), this.validate();
871
- }
1895
+ this.propagateValueChanged();
1896
+ }
1897
+ get composesValue() {
1898
+ return !0;
1899
+ }
1900
+ /**
1901
+ * A group with nothing listening for its value does not compose one at all, so the copy it holds is from before
1902
+ * the changes nobody received. A registration that adds a listener brings it up to date here, and what the
1903
+ * listener is then told about is the change that follows it.
1904
+ */
1905
+ refreshPreviousValue() {
1906
+ this.raw.announcedValue = this.value;
872
1907
  }
873
1908
  get valid() {
874
- return super.valid && Object.values(this._fields).every((e) => e.valid);
1909
+ return this.validRead;
875
1910
  }
876
- validate(e = !1) {
877
- e && Object.values(this._fields).forEach((t) => t.validate(!0)), super.validate(e);
1911
+ composeValid() {
1912
+ return this.state.errors.length === 0 && Object.values(this._fields).every((t) => t.valid);
878
1913
  }
879
- clone(e) {
880
- var r, a, l;
881
- const t = /* @__PURE__ */ Object.create(null);
1914
+ validate(t = !1) {
1915
+ g(() => {
1916
+ t && Object.values(this._fields).forEach((s) => s.validate(!0)), super.validate(t);
1917
+ });
1918
+ }
1919
+ bind(t, s) {
1920
+ var a, o;
1921
+ const i = /* @__PURE__ */ Object.create(null);
882
1922
  Object.entries(this._fields).forEach(([c, u]) => {
883
- t[c] = u.clone();
1923
+ i[c] = u.bind();
884
1924
  });
885
- const n = new _(t, R(y({
886
- value: (r = e == null ? void 0 : e.value) != null ? r : this.value
887
- }, e && "originalValue" in e ? { originalValue: e.originalValue } : {}), {
888
- enabled: (a = e == null ? void 0 : e.enabled) != null ? a : this.enabled,
889
- visibility: (l = e == null ? void 0 : e.visibility) != null ? l : this.visibility
1925
+ const r = new w(i, x(p({
1926
+ // data is what the caller supplied, and undefined is not supplied; an explicit null is, and clears
1927
+ value: t !== void 0 ? t : this.value
1928
+ }, s && "originalValue" in s ? { originalValue: s.originalValue } : {}), {
1929
+ enabled: (a = s == null ? void 0 : s.enabled) != null ? a : this.enabled,
1930
+ visibility: (o = s == null ? void 0 : s.visibility) != null ? o : this.visibility
890
1931
  }));
891
- return n.actions = this.actions.clone(), n.actions.triggerEager(n, n.value, n.originalValue), n;
1932
+ return r.boundFrom(this, r.raw.announcedValue, r.originalValue, s), r;
1933
+ }
1934
+ /**
1935
+ * A record need not name every member: a key it leaves out is taken from the declaration, the same way a member
1936
+ * the constructor is given no value for takes the one it was declared with.
1937
+ */
1938
+ rebind(t) {
1939
+ return super.rebind(t);
892
1940
  }
893
1941
  }
894
- class G extends x {
895
- constructor(e, t) {
896
- super();
897
- o(this, "_value", null);
898
- o(this, "_itemTemplate");
899
- o(this, "_previousValue");
900
- if (this._itemTemplate = e, t) {
901
- const n = t, { value: r, validators: a, actions: l } = n, c = I(n, ["value", "validators", "actions"]);
902
- [...a || [], ...l || []].forEach((u) => this.registerAction(u)), Object.assign(this, c), r && this.setValueInternal(r);
903
- }
904
- this.originalValue === void 0 && (this.originalValue = this.value), this._previousValue = this.value, this.actions.triggerEager(this, this.value, this.originalValue), this.validate();
1942
+ class D extends A {
1943
+ constructor(t, s) {
1944
+ super(je());
1945
+ d(this, "_itemTemplate");
1946
+ this._itemTemplate = t, g(() => {
1947
+ var r;
1948
+ if (s) {
1949
+ const i = s, { value: a, validators: o, actions: c } = i, u = k(i, ["value", "validators", "actions"]);
1950
+ this.registerInitialActions([...o || [], ...c || []]), this.assignParams(u), a != null && this.setValueInternal(a);
1951
+ }
1952
+ this.originalValue === void 0 && (this.originalValue = D.baseline(this.value)), this.raw.announcedValue = this.value, (r = this._actions) == null || r.triggerEager(this, this.value, this.originalValue), this.validate();
1953
+ });
1954
+ }
1955
+ get state() {
1956
+ return super.state;
1957
+ }
1958
+ get raw() {
1959
+ return super.raw;
1960
+ }
1961
+ /** The row array is copied as well: a rollback puts back the set the list held, not the array it went on to hold. */
1962
+ [z]() {
1963
+ const t = super[z]();
1964
+ return t.rows = this.raw.rows ? [...this.raw.rows] : this.raw.rows, t;
1965
+ }
1966
+ /**
1967
+ * The copy of a built value that serves as a baseline. The value getter hands out one array per version, and a
1968
+ * baseline holding that same array would report every value as its own original.
1969
+ */
1970
+ static baseline(t) {
1971
+ return t == null ? t : [...t];
905
1972
  }
906
- processSetValueItem(e) {
907
- let t;
908
- return e instanceof _ ? t = e : this._itemTemplate ? t = this._itemTemplate.clone({ value: e }) : t = _.createFromFormData(e), Object.defineProperty(t, "parent", { get: () => this, configurable: !1, enumerable: !1 }), t;
1973
+ processSetValueItem(t) {
1974
+ let s;
1975
+ return t instanceof w ? s = t : this._itemTemplate ? s = this._itemTemplate.bind(t) : s = w.createFromFormData(t), this.takeChild(s), this.completeRecords(s), s;
909
1976
  }
910
- setValueInternal(e) {
911
- Array.isArray(e) && (this._value = e.map((t) => this.processSetValueItem(t)));
1977
+ /**
1978
+ * Builds the item that fills a gap left by an insert beyond the end of the list: the item template bound to its
1979
+ * own values, or an empty group when the list has no template.
1980
+ */
1981
+ createPaddingItem() {
1982
+ return this.processSetValueItem(this._itemTemplate ? this._itemTemplate.bind() : null);
1983
+ }
1984
+ setValueInternal(t) {
1985
+ g((s) => {
1986
+ var i;
1987
+ if (s.touch(this), t == null)
1988
+ this.releaseRows(), this.state.rows = null;
1989
+ else if (Array.isArray(t)) {
1990
+ const r = (i = this.state.rows) != null ? i : [], a = new Array(t.length);
1991
+ for (let o = 0; o < t.length; o++) {
1992
+ const c = t[o], u = r[o];
1993
+ u && this._itemTemplate && !(c instanceof w) ? (this.resetChild(u, this._itemTemplate, c), a[o] = u) : (u && this.releaseChild(u), a[o] = this.processSetValueItem(c));
1994
+ }
1995
+ for (let o = t.length; o < r.length; o++) this.releaseChild(r[o]);
1996
+ this.state.rows = a;
1997
+ }
1998
+ this.bumpValueVersion();
1999
+ });
912
2000
  }
913
2001
  get value() {
914
- var t;
915
- const e = (t = this._value) == null ? void 0 : t.map((n) => n.value);
916
- return H(e) ? null : e;
2002
+ var r;
2003
+ const t = this.valueVersion;
2004
+ if (this.raw.cachedValueVersion === t) return this.raw.cachedValue;
2005
+ const s = (r = this.state.rows) == null ? void 0 : r.map((a) => a.value), i = L(s) ? null : Object.freeze(s);
2006
+ return this.raw.cachedValue = i, this.raw.cachedValueVersion = t, i;
2007
+ }
2008
+ set value(t) {
2009
+ g(() => {
2010
+ this.setValueInternal(t), this.propagateValueChanged(!0);
2011
+ });
917
2012
  }
918
- set value(e) {
919
- const t = this.value;
920
- this.setValueInternal(e), this.actions.trigger(m, this, this.value, t), this.parent && this.parent.notifyValueChanged(), this.validate();
2013
+ /**
2014
+ * The rows are taken from `source` where the caller supplied no value of its own, so a list nested in a row that
2015
+ * a whole-list assignment reuses ends up holding what the template gives it rather than what it held before.
2016
+ */
2017
+ resetTo(t, s) {
2018
+ g((i) => {
2019
+ i.touch(this), this.errors.length && (this.errors = []), this.setValueInternal(s === void 0 ? t.value : s);
2020
+ const r = this.value;
2021
+ this.raw.announcedValue = r, this.originalValue = D.baseline(r), super.validate(!0);
2022
+ });
921
2023
  }
922
2024
  get touched() {
923
- var e;
924
- return ((e = this._value) == null ? void 0 : e.some((t) => t.touched)) || !1;
925
- }
926
- set touched(e) {
927
2025
  var t;
928
- (t = this._value) == null || t.forEach((n) => {
929
- n.touched = e;
2026
+ return ((t = this.state.rows) == null ? void 0 : t.some((s) => s.touched)) || !1;
2027
+ }
2028
+ set touched(t) {
2029
+ g(() => {
2030
+ var s;
2031
+ (s = this.state.rows) == null || s.forEach((i) => {
2032
+ i.touched = t;
2033
+ });
930
2034
  });
931
2035
  }
932
- clone(e) {
933
- var n, r, a, l, c;
934
- const t = new G((n = this._itemTemplate) == null ? void 0 : n.clone(), R(y({
935
- value: [...(a = (r = e == null ? void 0 : e.value) != null ? r : this.value) != null ? a : []]
936
- }, e && "originalValue" in e ? { originalValue: e.originalValue } : {}), {
937
- enabled: (l = e == null ? void 0 : e.enabled) != null ? l : this.enabled,
938
- visibility: (c = e == null ? void 0 : e.visibility) != null ? c : this.visibility
2036
+ bind(t, s) {
2037
+ var r, a, o, c;
2038
+ const i = new D((r = this._itemTemplate) == null ? void 0 : r.bind(), x(p({
2039
+ // data is what the caller supplied, and undefined is not supplied; an explicit null is, and clears
2040
+ value: [...(a = t !== void 0 ? t : this.value) != null ? a : []]
2041
+ }, s && "originalValue" in s ? { originalValue: s.originalValue } : {}), {
2042
+ enabled: (o = s == null ? void 0 : s.enabled) != null ? o : this.enabled,
2043
+ visibility: (c = s == null ? void 0 : s.visibility) != null ? c : this.visibility
939
2044
  }));
940
- return t.actions = this.actions.clone(), t.actions.triggerEager(t, t.value, t.originalValue), t;
2045
+ return i.boundFrom(this, i.value, i.originalValue, s), i;
941
2046
  }
2047
+ /**
2048
+ * Records that a row changed its value, so that the transaction in progress works out at commit what this
2049
+ * list's own value became and announces it once. The mutation methods call it themselves; you rarely need to.
2050
+ */
942
2051
  notifyValueChanged() {
943
- const e = this.value;
944
- if (!k(e, this._previousValue)) {
945
- const t = this._previousValue;
946
- this._previousValue = e, this.actions.trigger(m, this, e, t), this.parent && this.parent.notifyValueChanged(), this.validate();
947
- }
2052
+ this.propagateValueChanged();
2053
+ }
2054
+ get composesValue() {
2055
+ return !0;
2056
+ }
2057
+ /**
2058
+ * A list with nothing listening for its value does not compose one at all, so the copy it holds is from before
2059
+ * the changes nobody received. A registration that adds a listener brings it up to date here, and what the
2060
+ * listener is then told about is the change that follows it.
2061
+ */
2062
+ refreshPreviousValue() {
2063
+ this.raw.announcedValue = this.value;
948
2064
  }
949
2065
  get valid() {
950
- var e, t;
951
- return super.valid && ((t = (e = this._value) == null ? void 0 : e.every((n) => n.valid)) != null ? t : !0);
2066
+ return this.validRead;
952
2067
  }
953
- validate(e = !1) {
2068
+ composeValid() {
2069
+ var t, s;
2070
+ return this.state.errors.length === 0 && ((s = (t = this.state.rows) == null ? void 0 : t.every((i) => i.valid)) != null ? s : !0);
2071
+ }
2072
+ validate(t = !1) {
2073
+ g(() => {
2074
+ var s;
2075
+ t && ((s = this.state.rows) == null || s.forEach((i) => i.validate(!0))), super.validate(t);
2076
+ });
2077
+ }
2078
+ get members() {
954
2079
  var t;
955
- e && ((t = this._value) == null || t.forEach((n) => n.validate(!0))), super.validate(e);
2080
+ return (t = this.raw.rows) != null ? t : [];
956
2081
  }
957
- get(e) {
958
- return this._value != null ? this._value[e] : void 0;
2082
+ get(t) {
2083
+ return this.state.rows != null ? this.state.rows[t] : void 0;
959
2084
  }
960
- push(e) {
961
- var t, n;
962
- return this.insert(e, (n = (t = this._value) == null ? void 0 : t.length) != null ? n : 0) + 1;
2085
+ push(t) {
2086
+ var s, i;
2087
+ return this.insert(t, (i = (s = this.state.rows) == null ? void 0 : s.length) != null ? i : 0) + 1;
963
2088
  }
964
2089
  pop() {
965
- var e, t;
966
- return this.remove(((t = (e = this._value) == null ? void 0 : e.length) != null ? t : 0) - 1);
967
- }
968
- remove(e) {
969
- var n;
970
- if (this._value == null || e < 0 || this._value.length <= e) return;
971
- let t = (n = this._value.splice(e, 1)) == null ? void 0 : n[0];
972
- return t && (t = t.clone(), this.actions.trigger(ue, this, t, e), this.notifyValueChanged()), t;
973
- }
974
- insert(e, t) {
975
- for (this._value == null && (this._value = []); this._value.length < t; ) {
976
- const r = this.processSetValueItem(null), a = this._value.push(r);
977
- this.actions.trigger(z, this, r, a);
978
- }
979
- const n = this.processSetValueItem(e);
980
- return this._value.splice(t, 0, n), this.actions.trigger(z, this, n, t), this.notifyValueChanged(), t;
2090
+ var t, s;
2091
+ return this.remove(((s = (t = this.state.rows) == null ? void 0 : t.length) != null ? s : 0) - 1);
2092
+ }
2093
+ remove(t) {
2094
+ let s;
2095
+ return g((i) => {
2096
+ var a;
2097
+ if (this.state.rows == null || t < 0 || this.state.rows.length <= t) return;
2098
+ i.touch(this);
2099
+ const r = (a = this.state.rows.splice(t, 1)) == null ? void 0 : a[0];
2100
+ r && (this.releaseChild(r), this.bumpValueVersion(), s = r, i.recordStructural(this, { actionClass: zt, item: s, index: t }), this.propagateValueChanged(!0));
2101
+ }), s;
2102
+ }
2103
+ insert(t, s) {
2104
+ let i = 0;
2105
+ return g((r) => {
2106
+ for (r.touch(this), this.state.rows == null && (this.state.rows = []), i = s < 0 ? Math.max(this.state.rows.length + s, 0) : s; this.state.rows.length < i; ) {
2107
+ const o = this.createPaddingItem(), c = this.state.rows.push(o) - 1;
2108
+ this.bumpValueVersion(), r.recordStructural(this, { actionClass: at, item: o, index: c });
2109
+ }
2110
+ const a = this.processSetValueItem(t);
2111
+ this.state.rows.splice(i, 0, a), r.recordStructural(this, { actionClass: at, item: a, index: i }), this.bumpValueVersion(), this.propagateValueChanged(!0);
2112
+ }), i;
2113
+ }
2114
+ /** Drops every row this list holds out of its tally, so a row that changes its verdict later is not counted. */
2115
+ releaseRows() {
2116
+ var t;
2117
+ (t = this.state.rows) == null || t.forEach((s) => this.releaseChild(s));
981
2118
  }
982
2119
  clear() {
983
- this._value = null, this.notifyValueChanged();
2120
+ g((t) => {
2121
+ var i, r;
2122
+ const s = ((r = (i = this.state.rows) == null ? void 0 : i.length) != null ? r : 0) > 0;
2123
+ t.touch(this), this.releaseRows(), this.state.rows = null, this.bumpValueVersion(), this.propagateValueChanged(s);
2124
+ });
984
2125
  }
985
2126
  }
986
- const he = { useMarkdownInValidators: !0 };
987
- function $e() {
988
- return he;
989
- }
990
- function qe(i) {
991
- Object.assign(he, i);
992
- }
993
- const it = {
994
- install(i, s) {
995
- s && qe(s);
2127
+ class ke extends v {
2128
+ constructor(t, s, i) {
2129
+ super((a, o, c) => {
2130
+ this.comparisonState(c).oldValue = o;
2131
+ const u = this.resolve(c);
2132
+ return u ? (this.listenOn(u), this.isValidComparison(b(a), b(u.value)) ? null : [
2133
+ new V(
2134
+ this.replacePlaceholders(i, { newValue: a, oldValue: o, field: c, otherField: u })
2135
+ )
2136
+ ]) : (c.markRecordIncomplete(), null);
2137
+ });
2138
+ d(this, "isValidComparison");
2139
+ d(this, "otherField");
2140
+ /**
2141
+ * The fields this validator is registered on. Registration reaches one element at a time - the rows of a list
2142
+ * take the validator on one by one, as they are built from the item template that carries it - so this is what
2143
+ * says which of the fields a declaration stands for actually carry the rule, and a field that never took it on
2144
+ * is left alone by a change of the compared field.
2145
+ */
2146
+ d(this, "registrations", /* @__PURE__ */ new WeakSet());
2147
+ /**
2148
+ * The fields this validator has installed its listener on. A binding of such a field carries the listener too -
2149
+ * a binding takes on the actions of the field it was bound from - so the field it was bound from is what is
2150
+ * asked about as well, and a list of a thousand rows installs one listener rather than a thousand.
2151
+ */
2152
+ d(this, "listening", /* @__PURE__ */ new WeakSet());
2153
+ /**
2154
+ * What the fields this validator was registered on were declared as. One entry stands for every binding of such a
2155
+ * field, so a change of a compared field finds the fields of the record that change happened in without a list
2156
+ * of a thousand rows being held here.
2157
+ */
2158
+ d(this, "declarations", /* @__PURE__ */ new Set());
2159
+ this.isValidComparison = s, this.otherField = t;
2160
+ }
2161
+ /** The field `field` is compared against, within the record `field` belongs to. */
2162
+ resolve(t) {
2163
+ var i;
2164
+ const s = this.otherField;
2165
+ return typeof s == "function" ? (i = s(t)) != null ? i : void 0 : typeof s == "string" ? pe(s, t) : ut(s, T(t));
996
2166
  }
997
- };
998
- function v(i) {
999
- return $e().useMarkdownInValidators ? new j(i) : i.replace(/[*_~`]/g, "").replace(/!\[(.*?)\]\(.*?\)/g, "$1").replace(/\[(.*?)\]\((.*?)\)/g, "$1").replace(/#+\s?/g, "").replace(/>\s?/g, "").replace(/(\*|-|\d+\.)\s+/g, "").replace(/`{3}[\s\S]*?`{3}/g, "").replace(/`([^`]+)`/g, "$1").replace(/\n{2,}/g, `
1000
- `);
1001
- }
1002
- class Me extends f {
1003
- constructor(e, t, n) {
1004
- let r = !1, a, l;
1005
- super((u, h, A) => (a = u, l = h, r || (r = !0, this.otherField.registerAction(
1006
- new m((E, L, O, $) => {
1007
- L(E, O, $), this.unregistered || this.execute(A, () => null, a, l);
2167
+ /**
2168
+ * Makes a change of `other` re-run this comparison. The listener re-runs it over the fields of the record the
2169
+ * change happened in rather than over the field that installed it, so the listener a row inherits with the field
2170
+ * it was bound from serves that row; and it re-runs this one validator, not the chain around it.
2171
+ */
2172
+ listenOn(t) {
2173
+ this.listening.has(t) || this.listening.has(t.declaration) || (this.listening.add(t), t.registerAction(
2174
+ new O((s, i, r, a) => {
2175
+ i(s, r, a);
2176
+ const o = T(s);
2177
+ this.declarations.forEach(
2178
+ (c) => Lt(c, o).forEach((u) => {
2179
+ this.registrations.has(u) && this.execute(u, () => null, u.value, this.comparisonState(u).oldValue);
2180
+ })
2181
+ );
1008
2182
  })
1009
- )), this.isValidComparison(g(u), g(this.otherField.value)) ? null : [
1010
- new p(
1011
- this.replacePlaceholders(n, { newValue: u, oldValue: h, field: A, otherField: this.otherField })
1012
- )
1013
- ]));
1014
- o(this, "otherField");
1015
- o(this, "isValidComparison");
1016
- o(this, "unregistered", !1);
1017
- this.otherField = e, this.isValidComparison = t;
2183
+ ));
2184
+ }
2185
+ boundToBinding(t) {
2186
+ this.declarations.add(t.declaration), this.registrations.add(t);
2187
+ }
2188
+ comparisonState(t) {
2189
+ return this.bindingState(t);
1018
2190
  }
1019
- unregister() {
1020
- this.unregistered = !0;
2191
+ newBindingState() {
2192
+ return x(p({}, super.newBindingState()), { oldValue: void 0 });
2193
+ }
2194
+ unregisterFrom(t) {
2195
+ this.registrations.delete(t);
1021
2196
  }
1022
2197
  }
1023
- class He extends f {
1024
- constructor(s, e) {
1025
- const t = e || v("Must be one of [**{allowedAsText}**]");
1026
- let n = s.join(", ");
1027
- n.length > 60 && (n = be(n, {
2198
+ class Re extends v {
2199
+ constructor(e, t) {
2200
+ const s = t || E("Must be one of [**{allowedAsText}**]");
2201
+ let i = e.join(", ");
2202
+ i.length > 60 && (i = Zt(i, {
1028
2203
  length: 40,
1029
2204
  separator: ", ",
1030
- omission: `... (${s.length} items total)`
2205
+ omission: `... (${e.length} items total)`
1031
2206
  }));
1032
- const r = (a, l, c) => s.includes(g(a)) ? null : [
1033
- new p(
1034
- this.replacePlaceholders(t, { newValue: a, oldValue: l, field: c, allowedValues: s, allowedAsText: n })
2207
+ const r = (a, o, c) => e.includes(b(a)) ? null : [
2208
+ new V(
2209
+ this.replacePlaceholders(s, { newValue: a, oldValue: o, field: c, allowedValues: e, allowedAsText: i })
1035
2210
  )
1036
2211
  ];
1037
2212
  super(r);
1038
2213
  }
1039
2214
  }
1040
- function Qe(i) {
1041
- return i == null ? 0 : te(i) || V(i) ? i.length : se(i) && Object.getPrototypeOf(i) === Object.prototype ? Object.keys(i).length : String(i).length;
2215
+ function De(n) {
2216
+ return n == null ? 0 : Tt(n) || P(n) ? n.length : Ot(n) && Object.getPrototypeOf(n) === Object.prototype ? Object.keys(n).length : String(n).length;
1042
2217
  }
1043
- class ze extends f {
1044
- constructor(s) {
1045
- const e = s || v("Please enter a value"), t = (n, r, a) => Qe(g(n)) === 0 ? [new p(this.replacePlaceholders(e, { newValue: n, oldValue: r, field: a }))] : null;
1046
- super(t);
2218
+ class Le extends v {
2219
+ constructor(e) {
2220
+ const t = e || E("Please enter a value"), s = (i, r, a) => De(b(i)) === 0 ? [new V(this.replacePlaceholders(t, { newValue: i, oldValue: r, field: a }))] : null;
2221
+ super(s);
1047
2222
  }
1048
2223
  }
1049
- class We extends f {
1050
- constructor(s, e) {
1051
- const t = e || v("Value must be larger or equal to **{minValue}**"), n = (r, a, l) => r < s || r === void 0 ? [
1052
- new p(this.replacePlaceholders(t, { newValue: r, oldValue: a, field: l, minValue: s }))
2224
+ class Be extends v {
2225
+ constructor(e, t) {
2226
+ const s = t || E("Value must be larger or equal to **{minValue}**"), i = (r, a, o) => r < e || r === void 0 ? [
2227
+ new V(this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, minValue: e }))
1053
2228
  ] : null;
1054
- super(n);
2229
+ super(i);
1055
2230
  }
1056
2231
  }
1057
- class Xe extends f {
1058
- constructor(s, e) {
1059
- const t = e || v("Value must be less than or equal to **{maxValue}**"), n = (r, a, l) => r > s || r === void 0 ? [
1060
- new p(this.replacePlaceholders(t, { newValue: r, oldValue: a, field: l, maxValue: s }))
2232
+ class Ue extends v {
2233
+ constructor(e, t) {
2234
+ const s = t || E("Value must be less than or equal to **{maxValue}**"), i = (r, a, o) => r > e || r === void 0 ? [
2235
+ new V(this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, maxValue: e }))
1061
2236
  ] : null;
1062
- super(n);
2237
+ super(i);
1063
2238
  }
1064
2239
  }
1065
- class Ge extends f {
1066
- constructor(s, e, t) {
1067
- const n = t || v("Value must be between **{minValue}** and **{maxValue}**"), r = (a, l, c) => a < s || a > e || a === void 0 ? [
1068
- new p(
1069
- this.replacePlaceholders(n, { newValue: a, oldValue: l, field: c, minValue: s, maxValue: e })
2240
+ class Me extends v {
2241
+ constructor(e, t, s) {
2242
+ const i = s || E("Value must be between **{minValue}** and **{maxValue}**"), r = (a, o, c) => a < e || a > t || a === void 0 ? [
2243
+ new V(
2244
+ this.replacePlaceholders(i, { newValue: a, oldValue: o, field: c, minValue: e, maxValue: t })
1070
2245
  )
1071
2246
  ] : null;
1072
2247
  super(r);
1073
2248
  }
1074
2249
  }
1075
- function Y(i) {
1076
- return i == null ? 0 : te(i) || V(i) ? i.length : se(i) && Object.getPrototypeOf(i) === Object.prototype ? Object.keys(i).length : String(i).length;
2250
+ function ht(n) {
2251
+ return n == null ? 0 : Tt(n) || P(n) ? n.length : Ot(n) && Object.getPrototypeOf(n) === Object.prototype ? Object.keys(n).length : String(n).length;
1077
2252
  }
1078
- class Ye extends f {
1079
- constructor(s, e) {
1080
- const t = e || v("Length must be larger or equal to **{minLength}**"), n = (r, a, l) => Y(r) < s ? [
1081
- new p(this.replacePlaceholders(t, { newValue: r, oldValue: a, field: l, minLength: s }))
2253
+ class We extends v {
2254
+ constructor(e, t) {
2255
+ const s = t || E("Length must be larger or equal to **{minLength}**"), i = (r, a, o) => ht(r) < e ? [
2256
+ new V(this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, minLength: e }))
1082
2257
  ] : null;
1083
- super(n);
2258
+ super(i);
1084
2259
  }
1085
2260
  }
1086
- class Je extends f {
1087
- constructor(s, e) {
1088
- const t = e || v("Length must be less than or equal to **{maxLength}**"), n = (r, a, l) => Y(r) > s ? [
1089
- new p(this.replacePlaceholders(t, { newValue: r, oldValue: a, field: l, maxLength: s }))
2261
+ class $e extends v {
2262
+ constructor(e, t) {
2263
+ const s = t || E("Length must be less than or equal to **{maxLength}**"), i = (r, a, o) => ht(r) > e ? [
2264
+ new V(this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, maxLength: e }))
1090
2265
  ] : null;
1091
- super(n);
2266
+ super(i);
1092
2267
  }
1093
2268
  }
1094
- class Ke extends f {
1095
- constructor(s, e, t) {
1096
- const n = t || v("Length must be between **{minLength}** and **{maxLength}**"), r = (a, l, c) => {
1097
- const u = Y(a);
1098
- return u < s || u > e ? [
1099
- new p(
1100
- this.replacePlaceholders(n, { newValue: a, oldValue: l, field: c, minLength: s, maxLength: e })
2269
+ class qe extends v {
2270
+ constructor(e, t, s) {
2271
+ const i = s || E("Length must be between **{minLength}** and **{maxLength}**"), r = (a, o, c) => {
2272
+ const u = ht(a);
2273
+ return u < e || u > t ? [
2274
+ new V(
2275
+ this.replacePlaceholders(i, { newValue: a, oldValue: o, field: c, minLength: e, maxLength: t })
1101
2276
  )
1102
2277
  ] : null;
1103
2278
  };
1104
2279
  super(r);
1105
2280
  }
1106
2281
  }
1107
- class Ze extends f {
1108
- constructor(s, e) {
1109
- const t = e || v('Value must match pattern "**{pattern}**"'), n = (r, a, l) => s.test(String(g(r))) ? null : [
1110
- new p(this.replacePlaceholders(t, { newValue: r, oldValue: a, field: l, pattern: s }))
2282
+ class ze extends v {
2283
+ constructor(e, t) {
2284
+ const s = t || E('Value must match pattern "**{pattern}**"'), i = (r, a, o) => e.test(String(b(r))) ? null : [
2285
+ new V(this.replacePlaceholders(s, { newValue: r, oldValue: a, field: o, pattern: e }))
1111
2286
  ];
1112
- super(n);
2287
+ super(i);
1113
2288
  }
1114
2289
  }
1115
- const et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2290
+ const He = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1116
2291
  __proto__: null,
1117
- CompareTo: Me,
1118
- InAllowedValues: He,
1119
- LengthInRange: Ke,
1120
- MaxLength: Je,
1121
- MaxValue: Xe,
1122
- MinLength: Ye,
1123
- MinValue: We,
1124
- Pattern: Ze,
1125
- Required: ze,
1126
- Validator: f,
1127
- ValueInRange: Ge
1128
- }, Symbol.toStringTag, { value: "Module" })), rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2292
+ CompareTo: ke,
2293
+ InAllowedValues: Re,
2294
+ LengthInRange: qe,
2295
+ MaxLength: $e,
2296
+ MaxValue: Ue,
2297
+ MinLength: We,
2298
+ MinValue: Be,
2299
+ Pattern: ze,
2300
+ Required: Le,
2301
+ Validator: v,
2302
+ ValueInRange: Me
2303
+ }, Symbol.toStringTag, { value: "Module" })), Je = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1129
2304
  __proto__: null,
1130
- AbortEventHandlingException: Q,
1131
- Action: Be,
1132
- ActionsMap: N,
1133
- ConditionalEnabledAction: Se,
1134
- ConditionalStatementAction: B,
1135
- ConditionalValueAction: we,
1136
- ConditionalVisibilityAction: Ie,
1137
- DisplayMode: C,
1138
- EmptyField: ke,
1139
- EnabledChangedAction: re,
1140
- EnabledChangingAction: ie,
1141
- ExecuteAction: ce,
1142
- Field: D,
1143
- FieldActionBase: b,
1144
- FieldBase: x,
1145
- Group: _,
1146
- List: G,
1147
- ListItemAddedAction: z,
1148
- ListItemRemovedAction: ue,
1149
- MdString: j,
1150
- MessagesWidget: De,
1151
- Operator: d,
1152
- RenderableValue: Ve,
1153
- Statement: w,
1154
- ValidChangedAction: ae,
1155
- ValidationError: X,
1156
- ValidationErrorRenderContent: p,
1157
- ValidationErrorText: _e,
1158
- Validator: f,
1159
- Validators: et,
1160
- ValueChangedAction: m,
1161
- VisibilityChangedAction: oe,
1162
- VisibilityChangingAction: le,
1163
- buildErrorMessage: v,
1164
- isCallableFunction: U,
1165
- isSimpleComponentDef: W
2305
+ AbortEventHandlingException: rt,
2306
+ Action: Fe,
2307
+ ActionsMap: M,
2308
+ ConditionalEnabledAction: ve,
2309
+ ConditionalStatementAction: Q,
2310
+ ConditionalValueAction: Ve,
2311
+ ConditionalVisibilityAction: be,
2312
+ DisplayMode: N,
2313
+ EmptyField: Pe,
2314
+ EnabledChangedAction: Ut,
2315
+ EnabledChangingAction: Bt,
2316
+ ExecuteAction: qt,
2317
+ Field: X,
2318
+ FieldActionBase: y,
2319
+ FieldBase: A,
2320
+ Group: w,
2321
+ List: D,
2322
+ ListItemAddedAction: at,
2323
+ ListItemRemovedAction: zt,
2324
+ MdString: U,
2325
+ MessagesWidget: Ne,
2326
+ Operator: m,
2327
+ RenderableValue: he,
2328
+ Statement: I,
2329
+ ValidChangedAction: Mt,
2330
+ ValidationError: ct,
2331
+ ValidationErrorRenderContent: V,
2332
+ ValidationErrorText: ue,
2333
+ Validator: v,
2334
+ Validators: He,
2335
+ ValueChangedAction: O,
2336
+ VisibilityChangedAction: $t,
2337
+ VisibilityChangingAction: Wt,
2338
+ buildErrorMessage: E,
2339
+ isCallableFunction: H,
2340
+ isSimpleComponentDef: lt,
2341
+ transaction: ot
1166
2342
  }, Symbol.toStringTag, { value: "Module" }));
1167
2343
  export {
1168
- Q as AbortEventHandlingException,
1169
- Be as Action,
1170
- N as ActionsMap,
1171
- Se as ConditionalEnabledAction,
1172
- B as ConditionalStatementAction,
1173
- we as ConditionalValueAction,
1174
- Ie as ConditionalVisibilityAction,
1175
- C as DisplayMode,
1176
- ke as EmptyField,
1177
- re as EnabledChangedAction,
1178
- ie as EnabledChangingAction,
1179
- ce as ExecuteAction,
1180
- D as Field,
1181
- b as FieldActionBase,
1182
- x as FieldBase,
1183
- _ as Group,
1184
- G as List,
1185
- z as ListItemAddedAction,
1186
- ue as ListItemRemovedAction,
1187
- j as MdString,
1188
- De as MessagesWidget,
1189
- d as Operator,
1190
- Ve as RenderableValue,
1191
- w as Statement,
1192
- ae as ValidChangedAction,
1193
- X as ValidationError,
1194
- p as ValidationErrorRenderContent,
1195
- _e as ValidationErrorText,
1196
- f as Validator,
1197
- et as Validators,
1198
- m as ValueChangedAction,
1199
- oe as VisibilityChangedAction,
1200
- le as VisibilityChangingAction,
1201
- v as buildErrorMessage,
1202
- rt as default,
1203
- it as forms,
1204
- U as isCallableFunction,
1205
- W as isSimpleComponentDef
2344
+ rt as AbortEventHandlingException,
2345
+ Fe as Action,
2346
+ M as ActionsMap,
2347
+ ve as ConditionalEnabledAction,
2348
+ Q as ConditionalStatementAction,
2349
+ Ve as ConditionalValueAction,
2350
+ be as ConditionalVisibilityAction,
2351
+ N as DisplayMode,
2352
+ Pe as EmptyField,
2353
+ Ut as EnabledChangedAction,
2354
+ Bt as EnabledChangingAction,
2355
+ qt as ExecuteAction,
2356
+ X as Field,
2357
+ y as FieldActionBase,
2358
+ A as FieldBase,
2359
+ w as Group,
2360
+ D as List,
2361
+ at as ListItemAddedAction,
2362
+ zt as ListItemRemovedAction,
2363
+ U as MdString,
2364
+ Ne as MessagesWidget,
2365
+ m as Operator,
2366
+ he as RenderableValue,
2367
+ I as Statement,
2368
+ Mt as ValidChangedAction,
2369
+ ct as ValidationError,
2370
+ V as ValidationErrorRenderContent,
2371
+ ue as ValidationErrorText,
2372
+ v as Validator,
2373
+ He as Validators,
2374
+ O as ValueChangedAction,
2375
+ $t as VisibilityChangedAction,
2376
+ Wt as VisibilityChangingAction,
2377
+ E as buildErrorMessage,
2378
+ Je as default,
2379
+ Ye as forms,
2380
+ H as isCallableFunction,
2381
+ lt as isSimpleComponentDef,
2382
+ ot as transaction
1206
2383
  };
1207
2384
  //# sourceMappingURL=dynamicforms-vue-forms.js.map