@jfdevelops/react-multi-step-form 1.0.0-alpha.7 → 1.0.0-alpha.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,137 +1,136 @@
1
- import { jsx as Ae, jsxs as se } from "react/jsx-runtime";
2
- import G from "react";
3
- function U(o, e, t) {
4
- const r = [], s = new Set(o), n = t ? t.format(o.map((u) => `${u}`)) : `[${o.join(", ")}]`;
1
+ import { jsx as je, jsxs as oe } from "react/jsx-runtime";
2
+ import R from "react";
3
+ function M(o, e, t) {
4
+ const r = [], n = new Set(o), s = t ? t.format(o.map((u) => `${u}`)) : `[${o.join(", ")}]`;
5
5
  for (let u = 0; u < e.length; u++) {
6
- const b = e[u];
7
- s.has(b) || r.push(
8
- `Extra element at index ${u}: "${b}" is not in ${n}`
6
+ const S = e[u];
7
+ n.has(S) || r.push(
8
+ `Extra element at index ${u}: "${S}" is not in ${s}`
9
9
  );
10
10
  }
11
- return e.some((u) => s.has(u)) || r.push(
12
- `Array must contain at least one valid element from ${n}`
11
+ return e.some((u) => n.has(u)) || r.push(
12
+ `Array must contain at least one valid element from ${s}`
13
13
  ), r.length > 0 ? { status: "error", errors: r } : { status: "success" };
14
14
  }
15
- function R(o, e) {
16
- const t = (r, s) => `❌ ${s + 1}. ${r}`;
17
- return o.map((r, s) => t(r, s)).join(`
15
+ function U(o, e) {
16
+ const t = (r, n) => `❌ ${n + 1}. ${r}`;
17
+ return o.map((r, n) => t(r, n)).join(`
18
18
  `);
19
19
  }
20
- function oe(o) {
20
+ function ie(o) {
21
21
  return Object.keys(o);
22
22
  }
23
23
  function Te(o, ...e) {
24
24
  return () => String.raw({ raw: o }, ...e);
25
25
  }
26
- function w(o, e, t = Error) {
26
+ function E(o, e, t = Error) {
27
27
  if (!o) {
28
- const r = typeof e == "function" ? e() : Te`${e}`();
29
- throw new t(r);
28
+ const r = new Intl.ListFormat("en", {
29
+ style: "long",
30
+ type: "conjunction"
31
+ }), n = typeof e == "function" ? e(r) : Te`${e}`();
32
+ throw new t(n);
30
33
  }
31
34
  }
32
- function M(o) {
33
- w(o.includes("step"), "Can't extract a valid step number since");
35
+ function q(o) {
36
+ E(o.includes("step"), "Can't extract a valid step number since");
34
37
  const e = o.replace("step", "");
35
- return w(/^\d+$/.test(e), `Invalid step format: "${o}"`), Number.parseInt(e, 10);
38
+ return E(/^\d+$/.test(e), `Invalid step format: "${o}"`), Number.parseInt(e, 10);
36
39
  }
37
- function K(o) {
40
+ function Q(o) {
38
41
  return function(e) {
39
- const { step: t } = e, r = `step${t}`, s = o[r];
40
- return { step: t, data: s };
42
+ const { step: t } = e, r = `step${t}`, n = o[r];
43
+ return { step: t, data: n };
41
44
  };
42
45
  }
43
- function ie(o, e) {
46
+ function P(o, e) {
44
47
  return e.reduce((t, r) => {
45
- const s = M(r), { data: n } = K(o)({
46
- step: s
48
+ const n = q(r), { data: s } = Q(o)({
49
+ step: n
47
50
  });
48
- for (const [a, u] of Object.entries(n))
49
- typeof u == "function" && a !== "update" || (n[a] = u);
50
- return t[r] = n, t;
51
+ for (const [i, u] of Object.entries(s))
52
+ typeof u == "function" && i !== "update" || (s[i] = u);
53
+ return t[r] = s, t;
51
54
  }, {});
52
55
  }
53
- function N(o, e) {
56
+ function L(o, e) {
54
57
  const t = new Intl.ListFormat("en", {
55
58
  style: "long",
56
59
  type: "disjunction"
57
- }), r = Object.keys(o), s = () => `"stepData" must be set to an array of available steps (${t.format(
60
+ }), r = Object.keys(o), n = () => `"stepData" must be set to an array of available steps (${t.format(
58
61
  r
59
62
  )})`;
60
63
  if (e === "all") {
61
- let n = {};
62
- for (const a of r)
63
- n = {
64
- ...n,
65
- [a]: K(o)({
66
- step: M(a)
64
+ let s = {};
65
+ for (const i of r)
66
+ s = {
67
+ ...s,
68
+ [i]: Q(o)({
69
+ step: q(i)
67
70
  })
68
71
  };
69
- return Object.fromEntries(
70
- r.map((a) => [
71
- a,
72
- K(o)({
73
- step: M(a)
74
- })
75
- ])
72
+ return P(
73
+ o,
74
+ r
76
75
  );
77
76
  }
78
77
  if (Array.isArray(e))
79
- return w(
80
- e.every((n) => r.includes(n)),
78
+ return E(
79
+ e.every((s) => r.includes(s)),
81
80
  () => {
82
- const n = U(
81
+ const s = M(
83
82
  e,
84
- r.map((a) => M(a)),
83
+ r.map((i) => q(i)),
85
84
  t
86
85
  );
87
- return n.status === "error" ? `${s()}. See errors:
88
- ${R(
89
- n.errors
90
- )}` : s();
86
+ return s.status === "error" ? `${n()}. See errors:
87
+ ${U(
88
+ s.errors
89
+ )}` : n();
91
90
  }
92
- ), ie(
91
+ ), P(
93
92
  o,
94
93
  e
95
94
  );
96
95
  if (typeof e == "object") {
97
- const n = Object.keys(e);
98
- return w(
99
- n.every((a) => r.includes(a)),
96
+ const s = Object.keys(e);
97
+ return E(
98
+ s.every((i) => r.includes(i)),
100
99
  () => {
101
- const a = U(
102
- n,
100
+ const i = M(
101
+ s,
103
102
  r,
104
103
  t
105
104
  );
106
- return a.status === "error" ? `${s()}. See errors:
107
- ${R(
108
- a.errors
109
- )}` : s();
105
+ return i.status === "error" ? `${n()}. See errors:
106
+ ${U(
107
+ i.errors
108
+ )}` : n();
110
109
  }
111
- ), ie(
110
+ ), P(
112
111
  o,
113
- n
112
+ s
114
113
  );
115
114
  }
116
- throw new Error(`${s()} OR to "all"`);
115
+ throw new Error(`${n()} OR to "all"`);
117
116
  }
118
- function je(o, e) {
117
+ function Ae(o, e) {
119
118
  return typeof o == "function" ? o(e) : o;
120
119
  }
121
- const H = "MultiStepFormSchema";
122
- class Q {
120
+ const G = "MultiStepFormSchema";
121
+ class ee {
123
122
  debug;
124
- prefix = H;
123
+ prefix = G;
125
124
  includeTimestamp = !1;
126
125
  throwOnError = !1;
127
126
  constructor(e) {
128
127
  if (this.debug = e?.debug ?? !1, this.debug && e?.debug) {
129
128
  const {
130
129
  includeTimestamp: t = !1,
131
- prefix: r = H,
132
- throwOnError: s = !1
130
+ prefix: r = G,
131
+ throwOnError: n = !1
133
132
  } = e;
134
- this.includeTimestamp = t, this.prefix = typeof r == "string" ? r : r(H), this.throwOnError = s;
133
+ this.includeTimestamp = t, this.prefix = typeof r == "string" ? r : r(G), this.throwOnError = n;
135
134
  }
136
135
  }
137
136
  wrapValue(e, t) {
@@ -148,34 +147,34 @@ class Q {
148
147
  formatPrefix(e) {
149
148
  if (!e)
150
149
  return this.prefix;
151
- const { action: t, value: r, wrapWith: s } = e;
150
+ const { action: t, value: r, wrapWith: n } = e;
152
151
  if (t === "replace")
153
- return this.wrapValue(s ?? "[]", r);
154
- const { delimiter: n } = e;
152
+ return this.wrapValue(n ?? "[]", r);
153
+ const { delimiter: s } = e;
155
154
  return t === "append" ? `${this.wrapValue(
156
- s?.originalPrefix ?? "[]",
155
+ n?.originalPrefix ?? "[]",
157
156
  this.prefix
158
- )}${n}${this.wrapValue(
159
- s?.addedPrefix ?? "[]",
157
+ )}${s}${this.wrapValue(
158
+ n?.addedPrefix ?? "[]",
160
159
  r
161
160
  )}`.trim() : t === "prepend" ? `${this.wrapValue(
162
- s?.addedPrefix ?? "[]",
161
+ n?.addedPrefix ?? "[]",
163
162
  r
164
- )}${n}${this.wrapValue(
165
- s?.originalPrefix ?? "[]",
163
+ )}${s}${this.wrapValue(
164
+ n?.originalPrefix ?? "[]",
166
165
  this.prefix
167
166
  )}`.trim() : this.prefix;
168
167
  }
169
168
  formatMessage(e, t, r) {
170
169
  const {
171
- includeTimestamp: s = this.includeTimestamp,
172
- prefix: n,
173
- logLevelOptions: a
174
- } = r ?? {}, u = this.formatPrefix(n), b = this.wrapValue(
175
- a?.wrapWith ?? "[]",
176
- (a?.level ?? e).toUpperCase()
177
- ), S = `${u} ${b} ${t}`;
178
- return s ? `[${(/* @__PURE__ */ new Date()).toISOString()}] ${S}` : S;
170
+ includeTimestamp: n = this.includeTimestamp,
171
+ prefix: s,
172
+ logLevelOptions: i
173
+ } = r ?? {}, u = this.formatPrefix(s), S = this.wrapValue(
174
+ i?.wrapWith ?? "[]",
175
+ (i?.level ?? e).toUpperCase()
176
+ ), g = `${u} ${S} ${t}`;
177
+ return n ? `[${(/* @__PURE__ */ new Date()).toISOString()}] ${g}` : g;
179
178
  }
180
179
  info(e, t) {
181
180
  this.debug && console.info(this.formatMessage("info", e, t));
@@ -193,188 +192,169 @@ class Q {
193
192
  }
194
193
  var C;
195
194
  ((o) => {
196
- function e(i, l) {
197
- return l.split(".").reduce((d, c) => d?.[c], i);
195
+ function e(a, l) {
196
+ return l.split(".").reduce((d, c) => d?.[c], a);
198
197
  }
199
- function t(i, l, d) {
198
+ function t(a, l, d) {
200
199
  const c = l.split(".");
201
- let h = i;
200
+ let m = a;
202
201
  for (let _ = 0; _ < c.length; _++) {
203
- const $ = c[_];
204
- _ === c.length - 1 ? h[$] !== void 0 && typeof h[$] == "object" && typeof d == "object" && d !== null ? Object.assign(h[$], d) : h[$] = d : ((typeof h[$] != "object" || h[$] === null) && (h[$] = {}), h = h[$]);
202
+ const O = c[_];
203
+ _ === c.length - 1 ? m[O] !== void 0 && typeof m[O] == "object" && typeof d == "object" && d !== null ? Object.assign(m[O], d) : m[O] = d : ((typeof m[O] != "object" || m[O] === null) && (m[O] = {}), m = m[O]);
205
204
  }
206
- return h;
205
+ return m;
207
206
  }
208
207
  o.setBy = t;
209
- function r(i) {
210
- return i.filter((l) => !i.some((d) => d !== l && l.startsWith(d + ".")));
208
+ function r(a) {
209
+ return a.filter((l) => !a.some((d) => d !== l && l.startsWith(d + ".")));
211
210
  }
212
- function s(i, ...l) {
211
+ function n(a, ...l) {
213
212
  const d = r(l);
214
213
  if (d.length === 1)
215
- return e(i, d[0]);
214
+ return e(a, d[0]);
216
215
  const c = {};
217
- for (const h of d) {
218
- const _ = e(i, h);
219
- t(c, h, _);
216
+ for (const m of d) {
217
+ const _ = e(a, m);
218
+ t(c, m, _);
220
219
  }
221
220
  return c;
222
221
  }
223
- o.pickBy = s;
224
- function n(i) {
222
+ o.pickBy = n;
223
+ function s(a) {
225
224
  const l = [];
226
- function d(c, h = "") {
225
+ function d(c, m = "") {
227
226
  if (c == null || typeof c != "object" || Array.isArray(c))
228
227
  return;
229
228
  const _ = Object.keys(c);
230
- for (const $ of _) {
231
- const T = h ? `${h}.${$}` : $;
232
- l.push(T);
233
- const j = c[$];
234
- j != null && typeof j == "object" && !Array.isArray(j) && d(j, T);
229
+ for (const O of _) {
230
+ const A = m ? `${m}.${O}` : O;
231
+ l.push(A);
232
+ const T = c[O];
233
+ T != null && typeof T == "object" && !Array.isArray(T) && d(T, A);
235
234
  }
236
235
  }
237
- return d(i), l;
236
+ return d(a), l;
238
237
  }
239
- o.createDeep = n;
240
- function a(i) {
241
- if (i === null) return "null";
242
- if (Array.isArray(i)) return "Array";
243
- const l = typeof i;
238
+ o.createDeep = s;
239
+ function i(a) {
240
+ if (a === null) return "null";
241
+ if (Array.isArray(a)) return "Array";
242
+ const l = typeof a;
244
243
  if (l !== "object") return l;
245
- const d = i?.constructor?.name;
244
+ const d = a?.constructor?.name;
246
245
  return d && d !== "Object" ? d : "object";
247
246
  }
248
- function u(i) {
249
- if (!i) return [];
247
+ function u(a) {
248
+ if (!a) return [];
250
249
  const l = [], d = /[^.[\]]+|\[(\d+)\]/g;
251
250
  let c;
252
- for (; c = d.exec(i); )
251
+ for (; c = d.exec(a); )
253
252
  l.push(c[1] ?? c[0]);
254
253
  return l;
255
254
  }
256
- function b(i, l) {
257
- if (!i) return;
258
- if (typeof i == "function")
259
- return i;
255
+ function S(a, l) {
256
+ if (!a) return;
257
+ if (typeof a == "function")
258
+ return a;
260
259
  const d = u(l);
261
- let c = i, h;
260
+ let c = a, m;
262
261
  for (const _ of d) {
263
262
  if (!c) break;
264
263
  if (typeof c == "function") {
265
- h = c;
264
+ m = c;
266
265
  break;
267
266
  }
268
267
  if (c = c[_], typeof c == "function") {
269
- h = c;
268
+ m = c;
270
269
  break;
271
270
  }
272
271
  }
273
- return h;
272
+ return m;
274
273
  }
275
- function S(i, l, d) {
276
- const c = b(d, l);
277
- return c ? c(i, l) : a(i);
274
+ function g(a, l, d) {
275
+ const c = S(d, l);
276
+ return c ? c(a, l) : i(a);
278
277
  }
279
- function p(i) {
280
- return typeof i == "object" && i !== null;
278
+ function p(a) {
279
+ return typeof a == "object" && a !== null;
281
280
  }
282
- function f(i, l, d, c, h) {
283
- if (i === l)
281
+ function f(a, l, d, c, m) {
282
+ if (a === l)
284
283
  return c;
285
- if (i === null || l === null || typeof i != "object" || typeof l != "object") {
286
- const $ = d || "(root)";
287
- return typeof i != typeof l ? (c.push({
288
- path: $,
289
- expected: S(i, $, h.transformExpected),
284
+ if (a === null || l === null || typeof a != "object" || typeof l != "object") {
285
+ const O = d || "(root)";
286
+ return typeof a != typeof l ? (c.push({
287
+ path: O,
288
+ expected: g(a, O, m.transformExpected),
290
289
  actual: l,
291
290
  reason: "type-mismatch"
292
- }), c) : (h.includeValueMismatch && c.push({
293
- path: $,
294
- expected: S(i, $, h.transformExpected),
291
+ }), c) : (m.includeValueMismatch && c.push({
292
+ path: O,
293
+ expected: g(a, O, m.transformExpected),
295
294
  actual: l,
296
295
  reason: "value-mismatch"
297
296
  }), c);
298
297
  }
299
- if (Array.isArray(i) || Array.isArray(l)) {
300
- if (!Array.isArray(i) || !Array.isArray(l)) {
301
- const T = d || "(root)";
298
+ if (Array.isArray(a) || Array.isArray(l)) {
299
+ if (!Array.isArray(a) || !Array.isArray(l)) {
300
+ const A = d || "(root)";
302
301
  return c.push({
303
- path: T,
304
- expected: S(i, T, h.transformExpected),
302
+ path: A,
303
+ expected: g(a, A, m.transformExpected),
305
304
  actual: l,
306
305
  reason: "type-mismatch"
307
306
  }), c;
308
307
  }
309
- const $ = i.length;
310
- for (let T = 0; T < $; T++) {
311
- const j = i[T], k = l[T], F = d === "" ? `[${T}]` : `${d}[${T}]`;
312
- if (T >= l.length) {
313
- c.push({
314
- path: F,
315
- expected: S(j, F, h.transformExpected),
316
- actual: void 0,
317
- reason: "missing-key"
318
- });
319
- continue;
320
- }
321
- f(j, k, F, c, h);
308
+ const O = a.length;
309
+ for (let A = 0; A < O; A++) {
310
+ const T = a[A], V = l[A], N = d === "" ? `[${A}]` : `${d}[${A}]`;
311
+ f(T, V, N, c, m);
322
312
  }
323
- if (l.length > i.length)
324
- for (let T = i.length; T < l.length; T++) {
325
- const j = d === "" ? `[${T}]` : `${d}[${T}]`;
326
- c.push({
327
- path: j,
328
- expected: void 0,
329
- actual: l[T],
330
- reason: "extra-key"
331
- });
332
- }
333
313
  return c;
334
314
  }
335
- if (p(i) && p(l)) {
336
- const $ = Object.keys(i), T = Object.keys(l);
337
- for (const j of $) {
338
- const k = i[j], F = l[j], V = d ? `${d}.${j}` : j;
339
- if (!(j in l)) {
315
+ if (p(a) && p(l)) {
316
+ const O = Object.keys(a), A = Object.keys(l);
317
+ for (const T of O) {
318
+ const V = a[T], N = l[T], k = d ? `${d}.${T}` : T;
319
+ if (!(T in l)) {
340
320
  c.push({
341
- path: V,
342
- expected: S(k, V, h.transformExpected),
321
+ path: k,
322
+ expected: g(V, k, m.transformExpected),
343
323
  actual: void 0,
344
324
  reason: "missing-key"
345
325
  });
346
326
  continue;
347
327
  }
348
- f(k, F, V, c, h);
328
+ f(V, N, k, c, m);
349
329
  }
350
- for (const j of T)
351
- if (!(j in i)) {
352
- const k = d ? `${d}.${j}` : j;
330
+ for (const T of A)
331
+ if (!(T in a)) {
332
+ const V = d ? `${d}.${T}` : T;
353
333
  c.push({
354
- path: k,
334
+ path: V,
355
335
  expected: void 0,
356
- actual: l[j],
336
+ actual: l[T],
357
337
  reason: "extra-key"
358
338
  });
359
339
  }
360
340
  return c;
361
341
  }
362
342
  const _ = d || "(root)";
363
- return typeof i != typeof l ? c.push({
343
+ return typeof a != typeof l ? c.push({
364
344
  path: _,
365
- expected: S(i, _, h.transformExpected),
345
+ expected: g(a, _, m.transformExpected),
366
346
  actual: l,
367
347
  reason: "type-mismatch"
368
- }) : h.includeValueMismatch && c.push({
348
+ }) : m.includeValueMismatch && c.push({
369
349
  path: _,
370
- expected: S(i, _, h.transformExpected),
350
+ expected: g(a, _, m.transformExpected),
371
351
  actual: l,
372
352
  reason: "value-mismatch"
373
353
  }), c;
374
354
  }
375
- function v(i, l, d, c) {
376
- const h = s(i, ...l), _ = [], $ = l.length === 1 ? l[0] : "";
377
- return f(h, d, $, _, {
355
+ function v(a, l, d, c) {
356
+ const m = n(a, ...l), _ = [], O = l.length === 1 ? l[0] : "";
357
+ return f(m, d, O, _, {
378
358
  transformExpected: c?.transformExpected
379
359
  }), {
380
360
  ok: _.length === 0,
@@ -382,17 +362,17 @@ var C;
382
362
  };
383
363
  }
384
364
  o.equalsAtPaths = v;
385
- function y(i) {
386
- if (i === void 0) return "undefined";
387
- if (typeof i == "string") return JSON.stringify(i);
365
+ function y(a) {
366
+ if (a === void 0) return "undefined";
367
+ if (typeof a == "string") return JSON.stringify(a);
388
368
  try {
389
- return JSON.stringify(i, null, 2);
369
+ return JSON.stringify(a, null, 2);
390
370
  } catch {
391
- return String(i);
371
+ return String(a);
392
372
  }
393
373
  }
394
- function m(i) {
395
- switch (i.reason) {
374
+ function h(a) {
375
+ switch (a.reason) {
396
376
  case "missing-key":
397
377
  return "Missing key";
398
378
  case "extra-key":
@@ -402,17 +382,17 @@ var C;
402
382
  case "value-mismatch":
403
383
  return "Value mismatch";
404
384
  default:
405
- return i.reason;
385
+ return a.reason;
406
386
  }
407
387
  }
408
- function g(i) {
409
- if (i.ok || i.mismatches.length === 0)
388
+ function b(a) {
389
+ if (a.ok || a.mismatches.length === 0)
410
390
  return "No mismatches.";
411
391
  const l = [];
412
- for (const d of i.mismatches)
392
+ for (const d of a.mismatches)
413
393
  l.push(
414
394
  `
415
- ● ${m(d)} at "${d.path}":`,
395
+ ● ${h(d)} at "${d.path}":`,
416
396
  ` expected: ${y(d.expected)}`,
417
397
  ` actual: ${y(d.actual)}`,
418
398
  ""
@@ -421,47 +401,47 @@ var C;
421
401
  return l.at(-1) === "" && l.pop(), l.join(`
422
402
  `);
423
403
  }
424
- o.formatMismatches = g;
425
- function E(i) {
426
- const l = g(i);
404
+ o.formatMismatches = b;
405
+ function $(a) {
406
+ const l = b(a);
427
407
  l !== "No mismatches." && console.error(l);
428
408
  }
429
- o.printMismatches = E;
430
- function O(i, l, d) {
409
+ o.printMismatches = $;
410
+ function w(a, l, d) {
431
411
  const c = l.split(".");
432
- function h(_, $) {
433
- const T = c[$], j = Array.isArray(_) ? [..._] : { ..._ };
434
- if ($ === c.length - 1) {
435
- let P = _ && typeof _ == "object" ? j : {};
436
- return P = {
437
- ...P,
438
- [T]: d
439
- }, P;
412
+ function m(_, O) {
413
+ const A = c[O], T = Array.isArray(_) ? [..._] : { ..._ };
414
+ if (O === c.length - 1) {
415
+ let K = _ && typeof _ == "object" ? T : {};
416
+ return K = {
417
+ ...K,
418
+ [A]: d
419
+ }, K;
440
420
  }
441
- const k = _ && typeof _ == "object" ? _[T] : void 0, F = h(k ?? {}, $ + 1);
442
- let V = _ && typeof _ == "object" ? j : {};
443
- return V = {
444
- ...V,
445
- [T]: F
446
- }, V;
421
+ const V = _ && typeof _ == "object" ? _[A] : void 0, N = m(V ?? {}, O + 1);
422
+ let k = _ && typeof _ == "object" ? T : {};
423
+ return k = {
424
+ ...k,
425
+ [A]: N
426
+ }, k;
447
427
  }
448
- return h(i, 0);
428
+ return m(a, 0);
449
429
  }
450
- function A(i, l, d) {
430
+ function j(a, l, d) {
451
431
  const c = r(l);
452
- if (c.length === 0) return i;
453
- let h = i;
432
+ if (c.length === 0) return a;
433
+ let m = a;
454
434
  if (c.length === 1) {
455
435
  const _ = c[0];
456
- return h = O(h, _, d), h;
436
+ return m = w(m, _, d), m;
457
437
  }
458
438
  for (const _ of c) {
459
- const $ = e(d, _);
460
- h = O(h, _, $);
439
+ const O = e(d, _);
440
+ m = w(m, _, O);
461
441
  }
462
- return h;
442
+ return m;
463
443
  }
464
- o.updateAt = A;
444
+ o.updateAt = j;
465
445
  })(C || (C = {}));
466
446
  function ge(o, e) {
467
447
  const t = o["~standard"].validate(e);
@@ -473,10 +453,10 @@ function ge(o, e) {
473
453
  throw new Error(JSON.stringify(t.issues, null, 2));
474
454
  return t.value;
475
455
  }
476
- function Se(o, e) {
456
+ function be(o, e) {
477
457
  return Object.keys(o).includes(e);
478
458
  }
479
- class ee {
459
+ class te {
480
460
  #e;
481
461
  #t;
482
462
  get value() {
@@ -490,24 +470,24 @@ class ee {
490
470
  this.#t(this.enrichValues(e));
491
471
  }
492
472
  createStepUpdaterFnImpl(e) {
493
- const { targetStep: t, updater: r, ctxData: s, fields: n = "all", debug: a } = e, u = new Q({
494
- debug: a,
495
- prefix: (m) => `${m}:update${t}`
473
+ const { targetStep: t, updater: r, ctxData: n, fields: s = "all", debug: i } = e, u = new ee({
474
+ debug: i,
475
+ prefix: (h) => `${h}:update${t}`
496
476
  });
497
- u.info(`${t} will be updated`), w(
498
- Se(this.value, t),
477
+ u.info(`${t} will be updated`), E(
478
+ be(this.value, t),
499
479
  `[update]: The target step ${t} isn't a valid step. Please select a valid step`
500
480
  );
501
- const { [t]: b, ...S } = this.value;
502
- let p = { ...this.value }, f = N(p, [t]);
503
- if (s) {
504
- w(
505
- typeof s == "function",
481
+ const { [t]: S, ...g } = this.value;
482
+ let p = { ...this.value }, f = L(p, [t]);
483
+ if (n) {
484
+ E(
485
+ typeof n == "function",
506
486
  '[update]: "ctxData" must be a function'
507
487
  ), u.info('Custom "ctx" will be used');
508
- const m = s({ ctx: S });
509
- w(
510
- typeof m == "object" && Object.keys(m).length > 0,
488
+ const h = n({ ctx: g });
489
+ E(
490
+ typeof h == "object" && Object.keys(h).length > 0,
511
491
  '[update]: "ctxData" must return an object with keys'
512
492
  ), u.info(
513
493
  `Custom "ctx" consists of the following keys: ${new Intl.ListFormat(
@@ -516,113 +496,113 @@ class ee {
516
496
  style: "long",
517
497
  type: "conjunction"
518
498
  }
519
- ).format(Object.keys(m))}`
499
+ ).format(Object.keys(h))}`
520
500
  ), f = {
521
501
  ...f,
522
- ...m
502
+ ...h
523
503
  };
524
504
  }
525
- const v = je(r, {
505
+ const v = Ae(r, {
526
506
  ctx: f,
527
507
  update: this.createHelperFnInputUpdate([t])
528
508
  });
529
- if (u.info(`The updated data is ${JSON.stringify(v, null, 2)}`), !n) {
530
- w(
509
+ if (u.info(`The updated data is ${JSON.stringify(v, null, 2)}`), !s) {
510
+ E(
531
511
  typeof v == "object",
532
512
  '[update]: "updater" must be an object or a function that returns an object'
533
513
  );
534
- const m = Object.keys(this.value), g = Object.keys(v);
535
- w(g.length === m.length, () => {
536
- const i = m.filter(
537
- (d) => !g.includes(d)
514
+ const h = Object.keys(this.value), b = Object.keys(v);
515
+ E(b.length === h.length, () => {
516
+ const a = h.filter(
517
+ (d) => !b.includes(d)
538
518
  );
539
519
  return `[update]: "updater" is missing keys ${new Intl.ListFormat("en", {
540
520
  style: "long",
541
521
  type: "conjunction"
542
522
  }).format(
543
- i
523
+ a
544
524
  )}`;
545
525
  });
546
- const E = C.createDeep(this.value), { mismatches: O, ok: A } = C.equalsAtPaths(
526
+ const $ = C.createDeep(this.value), { mismatches: w, ok: j } = C.equalsAtPaths(
547
527
  this.value,
548
- E,
528
+ $,
549
529
  v
550
530
  );
551
- w(
552
- A && O.length === 0,
531
+ E(
532
+ j && w.length === 0,
553
533
  `[update]: found value mismatches in ${C.printMismatches({
554
- mismatches: O,
555
- ok: A
534
+ mismatches: w,
535
+ ok: j
556
536
  })}`
557
537
  ), u.info("The entire step will be updated"), p = {
558
538
  ...p,
559
- [t]: C.updateAt(p, E, v)
539
+ [t]: C.updateAt(p, $, v)
560
540
  }, this.handlePostUpdate(p), u.info(`The new value is: ${JSON.stringify(p, null, 2)}`);
561
541
  return;
562
542
  }
563
- const y = C.createDeep(b);
564
- if (Array.isArray(n)) {
565
- const m = U(y, n);
566
- w(
567
- m.status === "success",
543
+ const y = C.createDeep(S);
544
+ if (Array.isArray(s)) {
545
+ const h = M(y, s);
546
+ E(
547
+ h.status === "success",
568
548
  `[update]: Found errors with the provided fields
569
- ${m.status === "error" ? R(m.errors) : ""}`
549
+ ${h.status === "error" ? U(h.errors) : ""}`
570
550
  );
571
- const { mismatches: g, ok: E } = C.equalsAtPaths(
572
- b,
573
- n,
551
+ const { mismatches: b, ok: $ } = C.equalsAtPaths(
552
+ S,
553
+ s,
574
554
  v
575
555
  );
576
- w(
577
- E && g.length === 0,
556
+ E(
557
+ $ && b.length === 0,
578
558
  `[update]: found value mismatches in ${C.printMismatches({
579
- ok: E,
580
- mismatches: g
559
+ ok: $,
560
+ mismatches: b
581
561
  })}`
582
562
  ), u.info(
583
563
  `The following fields will be updated: ${new Intl.ListFormat("en", {
584
564
  type: "conjunction",
585
565
  style: "long"
586
- }).format(n)}`
566
+ }).format(s)}`
587
567
  ), p = {
588
568
  ...p,
589
- [t]: C.updateAt(b, n, v)
569
+ [t]: C.updateAt(S, s, v)
590
570
  }, this.handlePostUpdate(p), u.info(`The new value is: ${JSON.stringify(p, null, 2)}`);
591
571
  return;
592
572
  }
593
- if (typeof n == "object" && Object.keys(n).length > 0) {
594
- const m = C.createDeep(n), g = U(
573
+ if (typeof s == "object" && Object.keys(s).length > 0) {
574
+ const h = C.createDeep(s), b = M(
595
575
  y,
596
- m
576
+ h
597
577
  );
598
- w(
599
- g.status === "success",
578
+ E(
579
+ b.status === "success",
600
580
  `[update]: Found errors with the provided fields
601
- ${g.status === "error" ? R(g.errors) : ""}`
581
+ ${b.status === "error" ? U(b.errors) : ""}`
602
582
  );
603
- const { mismatches: E, ok: O } = C.equalsAtPaths(
604
- b,
605
- m,
583
+ const { mismatches: $, ok: w } = C.equalsAtPaths(
584
+ S,
585
+ h,
606
586
  v
607
587
  );
608
- w(
609
- O && E.length === 0,
588
+ E(
589
+ w && $.length === 0,
610
590
  `[update]: found value mismatches in ${C.printMismatches({
611
- ok: O,
612
- mismatches: E
591
+ ok: w,
592
+ mismatches: $
613
593
  })}`
614
594
  ), p = {
615
595
  ...p,
616
596
  [t]: C.updateAt(
617
- b,
618
- m,
597
+ S,
598
+ h,
619
599
  v
620
600
  )
621
601
  }, u.info(
622
602
  `The following fields will be updated: ${new Intl.ListFormat("en", {
623
603
  type: "conjunction",
624
604
  style: "long"
625
- }).format(Object.keys(n))}`
605
+ }).format(Object.keys(s))}`
626
606
  ), this.handlePostUpdate(p), u.info(`The new value is: ${JSON.stringify(p, null, 2)}`);
627
607
  return;
628
608
  }
@@ -640,56 +620,56 @@ ${g.status === "error" ? R(g.errors) : ""}`
640
620
  return this.createStepUpdaterFnImpl(e);
641
621
  }
642
622
  createHelperFnInputUpdate(e) {
643
- if (x.isAll(e)) {
644
- const r = oe(this.value).reduce((n, a) => (n[a] = this.createStepUpdaterFn(a), n), {});
623
+ if (F.isAll(e)) {
624
+ const r = ie(this.value).reduce((s, i) => (s[i] = this.createStepUpdaterFn(i), s), {});
645
625
  return Object.assign(
646
626
  this.update,
647
627
  r
648
628
  );
649
629
  }
650
630
  const t = Object.keys(this.value);
651
- if (x.isTuple(e, t)) {
652
- const r = e.reduce((n, a) => (n[a] = this.createStepUpdaterFn(a), n), {});
631
+ if (F.isTuple(e, t)) {
632
+ const r = e.reduce((s, i) => (s[i] = this.createStepUpdaterFn(i), s), {});
653
633
  return Object.assign(
654
634
  this.update,
655
635
  r
656
636
  );
657
637
  }
658
- if (x.isObject(e, t)) {
659
- const r = oe(e).reduce((n, a) => (n[a] = this.createStepUpdaterFn(a), n), {});
638
+ if (F.isObject(e, t)) {
639
+ const r = ie(e).reduce((s, i) => (s[i] = this.createStepUpdaterFn(i), s), {});
660
640
  return Object.assign(
661
641
  this.update,
662
642
  r
663
643
  );
664
644
  }
665
- throw new TypeError(`[update]: ${x.CATCH_ALL_MESSAGE}`);
645
+ throw new TypeError(`[update]: ${F.CATCH_ALL_MESSAGE}`);
666
646
  }
667
647
  createStepHelperFn(e) {
668
648
  return (t, r) => {
669
- const s = N(
649
+ const n = L(
670
650
  this.value,
671
651
  e
672
- ), n = this.createHelperFnInputUpdate(
652
+ ), s = this.createHelperFnInputUpdate(
673
653
  e
674
654
  );
675
655
  if (typeof t == "function")
676
656
  return () => t({
677
- ctx: s,
678
- update: n
657
+ ctx: n,
658
+ update: s
679
659
  });
680
660
  if (typeof t == "object")
681
- return (a) => {
661
+ return (i) => {
682
662
  if ("validator" in t) {
683
- w(
684
- typeof a == "object",
663
+ E(
664
+ typeof i == "object",
685
665
  "An input is expected since you provided a validator"
686
666
  ), ge(
687
667
  t.validator,
688
- a.data
668
+ i.data
689
669
  );
690
- let u = s;
670
+ let u = n;
691
671
  if (t.ctxData) {
692
- const b = e[0], { [b]: S, ...p } = this.value;
672
+ const S = e[0], { [S]: g, ...p } = this.value;
693
673
  u = {
694
674
  ...u,
695
675
  ...t.ctxData({ ctx: p })
@@ -697,13 +677,13 @@ ${g.status === "error" ? R(g.errors) : ""}`
697
677
  }
698
678
  return r({
699
679
  ctx: u,
700
- update: n,
701
- ...a
680
+ update: s,
681
+ ...i
702
682
  });
703
683
  }
704
684
  return r({
705
- ctx: s,
706
- update: n
685
+ ctx: n,
686
+ update: s
707
687
  });
708
688
  };
709
689
  throw new Error(
@@ -713,39 +693,39 @@ ${g.status === "error" ? R(g.errors) : ""}`
713
693
  }
714
694
  enrichValues(e, t) {
715
695
  let r = { ...e };
716
- for (const [s, n] of Object.entries(r)) {
717
- const [a] = [s], u = Number.parseInt(
718
- a.replace("step", "")
696
+ for (const [n, s] of Object.entries(r)) {
697
+ const [i] = [n], u = Number.parseInt(
698
+ i.replace("step", "")
719
699
  );
720
- r[a] = {
721
- ...n,
722
- update: this.createStepUpdaterFn(a),
723
- createHelperFn: this.createStepHelperFn([a]),
700
+ r[i] = {
701
+ ...s,
702
+ update: this.createStepUpdaterFn(i),
703
+ createHelperFn: this.createStepHelperFn([i]),
724
704
  ...t?.(u)
725
705
  };
726
706
  }
727
707
  return r;
728
708
  }
729
709
  }
730
- var x;
710
+ var F;
731
711
  ((o) => {
732
712
  o.CATCH_ALL_MESSAGE = 'The chosen steps must either be set to on of the following: "all", an array of steps (["step1", "step2", ...]), or an object containing the steps to chose ({ step1: true, step2: true, ...})';
733
- function e(s) {
734
- return !!(s && typeof s == "string" && s === "all");
713
+ function e(n) {
714
+ return !!(n && typeof n == "string" && n === "all");
735
715
  }
736
716
  o.isAll = e;
737
- function t(s, n) {
738
- return Array.isArray(s) ? n ? s.every((a) => n.includes(a)) : !0 : !1;
717
+ function t(n, s) {
718
+ return Array.isArray(n) ? s ? n.every((i) => s.includes(i)) : !0 : !1;
739
719
  }
740
720
  o.isTuple = t;
741
- function r(s, n) {
742
- if (!s)
721
+ function r(n, s) {
722
+ if (!n)
743
723
  return !1;
744
- const a = Object.keys(s);
745
- return a.length === 0 || n && !a.every((u) => n.includes(u)) ? !1 : Object.entries(s).every(([u, b]) => b === !0);
724
+ const i = Object.keys(n);
725
+ return i.length === 0 || s && !i.every((u) => s.includes(u)) ? !1 : Object.entries(n).every(([u, S]) => S === !0);
746
726
  }
747
727
  o.isObject = r;
748
- })(x || (x = {}));
728
+ })(F || (F = {}));
749
729
  const Ce = [
750
730
  "sentence",
751
731
  "title",
@@ -757,8 +737,8 @@ const Ce = [
757
737
  "screaming-snake",
758
738
  "flat",
759
739
  "kebab"
760
- ], te = "title";
761
- function ke(o, e) {
740
+ ], re = "title";
741
+ function Ve(o, e) {
762
742
  const t = o.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").trim().split(/\s+/).map((r) => r.toLowerCase());
763
743
  switch (e) {
764
744
  case "sentence":
@@ -788,10 +768,10 @@ function ke(o, e) {
788
768
  function Y(o) {
789
769
  return typeof o != "string" ? !1 : Ce.includes(o);
790
770
  }
791
- function be(o, e = te) {
771
+ function Se(o, e = re) {
792
772
  return Y(o) ? o : e;
793
773
  }
794
- const Fe = [
774
+ const ke = [
795
775
  "string",
796
776
  "string.phone",
797
777
  "string.email",
@@ -802,10 +782,10 @@ const Fe = [
802
782
  "dateTime",
803
783
  "boolean.switch"
804
784
  ], ae = "string";
805
- function Ve(o) {
806
- return typeof o == "string" && Fe.includes(o);
785
+ function Fe(o) {
786
+ return typeof o == "string" && ke.includes(o);
807
787
  }
808
- const W = '"window" in undefined. No storage is available', re = "MultiStepForm";
788
+ const W = '"window" in undefined. No storage is available', ne = "MultiStepForm";
809
789
  class ve {
810
790
  key;
811
791
  store;
@@ -814,13 +794,13 @@ class ve {
814
794
  shouldRunActions;
815
795
  throwWhenUndefined;
816
796
  constructor(e) {
817
- const { key: t, data: r, store: s, throwWhenUndefined: n = !1 } = e;
818
- this.log = new Q({
819
- prefix: re
820
- }), this.key = t, this.data = r, this.throwWhenUndefined = n, s ? (this.store = s, this.shouldRunActions = !0, typeof window > "u" && (this.shouldRunActions = !1, this.log.warn(W))) : typeof window < "u" ? (this.store = window.localStorage, this.shouldRunActions = !0) : (this.shouldRunActions = !1, this.log.warn(W));
797
+ const { key: t, data: r, store: n, throwWhenUndefined: s = !1 } = e;
798
+ this.log = new ee({
799
+ prefix: ne
800
+ }), this.key = t, this.data = r, this.throwWhenUndefined = s, n ? (this.store = n, this.shouldRunActions = !0, typeof window > "u" && (this.shouldRunActions = !1, this.log.warn(W))) : typeof window < "u" ? (this.store = window.localStorage, this.shouldRunActions = !0) : (this.shouldRunActions = !1, this.log.warn(W));
821
801
  }
822
802
  throwOnEmptyStore() {
823
- this.throwWhenUndefined && w(this.store, () => this.shouldRunActions ? W : "No storage available");
803
+ this.throwWhenUndefined && E(this.store, () => this.shouldRunActions ? W : "No storage available");
824
804
  }
825
805
  resolveValue(e) {
826
806
  if (typeof e == "object")
@@ -875,140 +855,140 @@ const xe = [
875
855
  "number",
876
856
  "array.string",
877
857
  "array.string.untyped"
878
- ], we = /^step\d+$/i;
858
+ ], _e = /^step\d+$/i;
879
859
  function ue(o, e) {
880
860
  if (typeof o != "object" || o === null) return !1;
881
861
  for (const t of Object.keys(e)) {
882
862
  if (!(t in o)) return !1;
883
- const r = e[t], s = o[t];
884
- if (!r(s)) return !1;
863
+ const r = e[t], n = o[t];
864
+ if (!r(n)) return !1;
885
865
  }
886
866
  return !0;
887
867
  }
888
868
  function ce(o, e, t) {
889
- return o ?? ke(e, t);
869
+ return o ?? Ve(e, t);
890
870
  }
891
871
  function Le(o) {
892
- const e = {}, { fields: t, defaultCasing: r, validateFields: s } = o;
893
- for (const [n, a] of Object.entries(t)) {
894
- w(
895
- typeof n == "string",
896
- `Each key for the "fields" option must be a string. Key ${n} was a ${typeof n}`
897
- ), w(
898
- typeof a == "object",
899
- `The value for key ${n} must be an object. Was ${typeof a}`
872
+ const e = {}, { fields: t, defaultCasing: r, validateFields: n } = o;
873
+ for (const [s, i] of Object.entries(t)) {
874
+ E(
875
+ typeof s == "string",
876
+ `Each key for the "fields" option must be a string. Key ${s} was a ${typeof s}`
877
+ ), E(
878
+ typeof i == "object",
879
+ `The value for key ${s} must be an object. Was ${typeof i}`
900
880
  );
901
881
  const {
902
882
  defaultValue: u,
903
- label: b,
904
- nameTransformCasing: S,
883
+ label: S,
884
+ nameTransformCasing: g,
905
885
  type: p = ae
906
- } = a;
907
- if (s)
908
- e[n] = u;
886
+ } = i;
887
+ if (n)
888
+ e[s] = u;
909
889
  else {
910
- const f = S ?? r;
911
- e[n] = {
912
- ...e[n],
890
+ const f = g ?? r;
891
+ e[s] = {
892
+ ...e[s],
913
893
  nameTransformCasing: f,
914
894
  type: p,
915
895
  defaultValue: u,
916
- label: ce(b, n, f)
896
+ label: ce(S, s, f)
917
897
  // TODO add more fields here
918
898
  };
919
899
  }
920
900
  }
921
- if (s) {
922
- const n = ge(
923
- s,
901
+ if (n) {
902
+ const s = ge(
903
+ n,
924
904
  e
925
905
  );
926
- w(
927
- typeof n == "object",
928
- `The result of the validated fields must be an object, was (${typeof n}). This is probably an internal error, so open up an issue about it`
929
- ), w(
930
- !!n,
906
+ E(
907
+ typeof s == "object",
908
+ `The result of the validated fields must be an object, was (${typeof s}). This is probably an internal error, so open up an issue about it`
909
+ ), E(
910
+ !!s,
931
911
  "The result of the validated fields must be defined. This is probably an internal error, so open up an issue about it"
932
912
  );
933
- for (const [a, u] of Object.entries(n)) {
934
- const b = t[a];
935
- w(
936
- b,
937
- `No field found in the fields config for "${a}"`
913
+ for (const [i, u] of Object.entries(s)) {
914
+ const S = t[i];
915
+ E(
916
+ S,
917
+ `No field found in the fields config for "${i}"`
938
918
  );
939
919
  const {
940
- label: S,
920
+ label: g,
941
921
  type: p = ae,
942
922
  nameTransformCasing: f
943
- } = b, v = f ?? r;
944
- e[a] = {
945
- ...e[a],
923
+ } = S, v = f ?? r;
924
+ e[i] = {
925
+ ...e[i],
946
926
  nameTransformCasing: v,
947
927
  type: p,
948
928
  defaultValue: u,
949
- label: ce(S, a, v)
929
+ label: ce(g, i, v)
950
930
  };
951
931
  }
952
932
  }
953
933
  return e;
954
934
  }
955
- function _e(o) {
935
+ function we(o) {
956
936
  const e = {};
957
- w(!!o, "The steps config must be defined", TypeError), w(
937
+ E(!!o, "The steps config must be defined", TypeError), E(
958
938
  typeof o == "object",
959
939
  `The steps config must be an object, was (${typeof o})`,
960
940
  TypeError
961
941
  );
962
942
  for (const [t, r] of Object.entries(o)) {
963
- w(
943
+ E(
964
944
  typeof t == "string",
965
945
  `Each key for the step config must be a string. Key "${t}" was ${typeof t} `,
966
946
  TypeError
967
- ), w(
968
- we.test(t),
947
+ ), E(
948
+ _e.test(t),
969
949
  `The key "${t}" isn't formatted properly. Each key in the step config must be the following format: "step{number}"`
970
950
  );
971
- const s = t, {
972
- fields: n,
973
- title: a,
974
- nameTransformCasing: u = te,
975
- description: b,
976
- validateFields: S
977
- } = r, p = s.toString().replace("step", "");
978
- w(
979
- n,
980
- `Missing fields for step ${p} (${String(s)})`,
951
+ const n = t, {
952
+ fields: s,
953
+ title: i,
954
+ nameTransformCasing: u = re,
955
+ description: S,
956
+ validateFields: g
957
+ } = r, p = n.toString().replace("step", "");
958
+ E(
959
+ s,
960
+ `Missing fields for step ${p} (${String(n)})`,
981
961
  TypeError
982
- ), w(
983
- typeof n == "object",
962
+ ), E(
963
+ typeof s == "object",
984
964
  "Fields must be an object",
985
965
  TypeError
986
- ), w(
987
- Object.keys(n).length > 0,
966
+ ), E(
967
+ Object.keys(s).length > 0,
988
968
  `The fields config for step ${p} (${String(
989
- s
969
+ n
990
970
  )}) is empty. Please add a field`
991
- ), w(
992
- typeof n == "object",
993
- `The "fields" property must be an object. Was ${typeof n}`
971
+ ), E(
972
+ typeof s == "object",
973
+ `The "fields" property must be an object. Was ${typeof s}`
994
974
  );
995
975
  const f = Le({
996
976
  defaultCasing: u,
997
- fields: n,
998
- validateFields: S
977
+ fields: s,
978
+ validateFields: g
999
979
  });
1000
- e[s] = {
1001
- ...e[s],
1002
- title: a,
980
+ e[n] = {
981
+ ...e[n],
982
+ title: i,
1003
983
  nameTransformCasing: u,
1004
984
  // Only add the description if it's defined
1005
- ...typeof b == "string" ? { description: b } : {},
985
+ ...typeof S == "string" ? { description: S } : {},
1006
986
  fields: f
1007
987
  };
1008
988
  }
1009
989
  return e;
1010
990
  }
1011
- let ne = class extends Ee {
991
+ let se = class extends Ee {
1012
992
  /**
1013
993
  * The original config before any validation or transformations have been applied.
1014
994
  */
@@ -1027,43 +1007,49 @@ let ne = class extends Ee {
1027
1007
  #e;
1028
1008
  constructor(e) {
1029
1009
  super();
1030
- const { steps: t, nameTransformCasing: r, storage: s } = e;
1031
- this.defaultNameTransformationCasing = be(
1010
+ const { steps: t, nameTransformCasing: r, storage: n } = e;
1011
+ this.defaultNameTransformationCasing = Se(
1032
1012
  r
1033
- ), this.original = t, this.value = _e(this.original), this.storage = new ve({
1013
+ ), this.original = t, this.value = we(this.original), this.storage = new ve({
1034
1014
  data: this.value,
1035
- key: s?.key ?? re,
1036
- store: s?.store,
1037
- throwWhenUndefined: s?.throwWhenUndefined ?? !1
1038
- }), this.#e = new ee({
1015
+ key: n?.key ?? ne,
1016
+ store: n?.store,
1017
+ throwWhenUndefined: n?.throwWhenUndefined ?? !1
1018
+ }), this.#e = new te({
1039
1019
  getValue: () => this.value,
1040
- setValue: (n) => this.handlePostUpdate(n)
1020
+ setValue: (s) => this.handlePostUpdate(s)
1041
1021
  }), this.value = this.#e.enrichValues(this.value), this.stepNumbers = Object.keys(this.value).map(
1042
- (n) => Number.parseInt(n.replace("step", ""))
1022
+ (s) => Number.parseInt(s.replace("step", ""))
1043
1023
  ), this.firstStep = this.first(), this.lastStep = this.last(), this.steps = {
1044
1024
  first: this.firstStep.step,
1045
1025
  last: this.lastStep.step,
1046
1026
  value: this.stepNumbers,
1047
- as: (n) => {
1048
- if (w(
1049
- typeof n == "string",
1050
- `The type of the target transformation type must be a string, was ${typeof n}`
1051
- ), n === "string")
1052
- return this.stepNumbers.map((a) => `'${a}'`).join(" | ");
1053
- if (n === "number")
1027
+ as: (s) => {
1028
+ if (E(
1029
+ typeof s == "string",
1030
+ `The type of the target transformation type must be a string, was ${typeof s}`
1031
+ ), s === "string")
1032
+ return this.stepNumbers.map((i) => `'${i}'`).join(" | ");
1033
+ if (s === "number")
1054
1034
  return this.stepNumbers.join(" | ");
1055
- if (n.includes("array.string"))
1056
- return this.stepNumbers.map((a) => `${a}`);
1035
+ if (s.includes("array.string"))
1036
+ return this.stepNumbers.map((i) => `${i}`);
1057
1037
  throw new Error(
1058
- `Transformation type "${n}" is not supported. Available transformations include: ${xe.map(
1059
- (a) => `"${a}"`
1038
+ `Transformation type "${s}" is not supported. Available transformations include: ${xe.map(
1039
+ (i) => `"${i}"`
1060
1040
  ).join(", ")}`
1061
1041
  );
1062
1042
  },
1063
- isValidStepNumber: (n) => this.stepNumbers.includes(n),
1064
- isValidStepKey: (n) => Se(this.value, n)
1043
+ isValidStepNumber: (s) => this.stepNumbers.includes(s),
1044
+ isValidStepKey: (s) => be(this.value, s)
1065
1045
  }, this.sync();
1066
1046
  }
1047
+ /**
1048
+ * @internal
1049
+ */
1050
+ __getStorage() {
1051
+ return this.storage;
1052
+ }
1067
1053
  getSnapshot() {
1068
1054
  return this;
1069
1055
  }
@@ -1071,7 +1057,7 @@ let ne = class extends Ee {
1071
1057
  * Syncs the values from storage to {@linkcode value}.
1072
1058
  */
1073
1059
  sync() {
1074
- const e = this.storage.get();
1060
+ const e = this.__getStorage().get();
1075
1061
  if (e) {
1076
1062
  const t = this.#e.enrichValues(e);
1077
1063
  this.value = { ...t };
@@ -1092,7 +1078,7 @@ let ne = class extends Ee {
1092
1078
  * @returns The step data for the target step.
1093
1079
  */
1094
1080
  get(e) {
1095
- return K(this.value)(e);
1081
+ return Q(this.value)(e);
1096
1082
  }
1097
1083
  /**
1098
1084
  * Gets the data for the first step.
@@ -1111,15 +1097,15 @@ let ne = class extends Ee {
1111
1097
  return this.get({ step: e });
1112
1098
  }
1113
1099
  handlePostUpdate(e) {
1114
- this.value = { ...e }, this.storage.add(this.value), this.sync(), this.notify();
1100
+ this.value = { ...e }, this.__getStorage().add(this.value), this.sync(), this.notify();
1115
1101
  }
1116
1102
  update(e) {
1117
1103
  this.#e.update(e);
1118
1104
  }
1119
1105
  // Implementation
1120
1106
  createHelperFn(e, t) {
1121
- const { stepData: r, ...s } = e;
1122
- return this.#e.createStepHelperFn(r)(s, t);
1107
+ const { stepData: r, ...n } = e;
1108
+ return this.#e.createStepHelperFn(r)(n, t);
1123
1109
  }
1124
1110
  /**
1125
1111
  * Validates that a given object is the proper shape for step data.
@@ -1131,15 +1117,15 @@ let ne = class extends Ee {
1131
1117
  fields: (r) => {
1132
1118
  if (r === null || typeof r != "object")
1133
1119
  return !1;
1134
- for (const s of Object.keys(r)) {
1135
- if (typeof s != "string" || !(s in r))
1120
+ for (const n of Object.keys(r)) {
1121
+ if (typeof n != "string" || !(n in r))
1136
1122
  return !1;
1137
- const n = r[s];
1138
- if (n === null || typeof n != "object" || !ue(n, {
1123
+ const s = r[n];
1124
+ if (s === null || typeof s != "object" || !ue(s, {
1139
1125
  defaultValue: (u) => u !== "undefined" && u !== null,
1140
1126
  label: (u) => typeof u == "string" || typeof u == "boolean" && !u,
1141
1127
  nameTransformCasing: Y,
1142
- type: Ve
1128
+ type: Fe
1143
1129
  }))
1144
1130
  return !1;
1145
1131
  }
@@ -1152,6 +1138,51 @@ let ne = class extends Ee {
1152
1138
  ...t?.optionalKeysToCheck
1153
1139
  });
1154
1140
  }
1141
+ /**
1142
+ * Gets the value of a given field for a given step.
1143
+ * @param step The step to get the value from.
1144
+ * @param field The field to get the value from.
1145
+ * @returns The value of the {@linkcode field}.
1146
+ */
1147
+ getValue(e, t) {
1148
+ const r = this.value[e], n = `Unable to get the value for "${String(
1149
+ e
1150
+ )}.fields.${String(t)}"`;
1151
+ E("fields" in r, n), E(
1152
+ typeof r.fields == "object",
1153
+ `${n} because "fields" is not an object. This shouldn't be the case, so please open an issue`
1154
+ );
1155
+ const s = r.fields;
1156
+ E(
1157
+ t in s,
1158
+ (u) => `${n} because the field "${String(
1159
+ t
1160
+ )}" is one of the available fields for ${String(
1161
+ e
1162
+ )}. Please try again with one of the available fields: ${u.format(
1163
+ Object.keys(s)
1164
+ )}`
1165
+ );
1166
+ const { [String(t)]: i } = s;
1167
+ return E(
1168
+ typeof i == "object",
1169
+ `${n.replace(
1170
+ /"$/,
1171
+ `.${i}"`
1172
+ )} because "${i}" isn't an object`
1173
+ ), E(
1174
+ "defaultValue" in i,
1175
+ `${n.replace(
1176
+ /"$/,
1177
+ `.${i}"`
1178
+ )} because "${i}" doesn't have a "defaultValue":
1179
+ ${JSON.stringify(
1180
+ i,
1181
+ null,
1182
+ 2
1183
+ )}`
1184
+ ), i.defaultValue;
1185
+ }
1155
1186
  }, Ne = class extends Ee {
1156
1187
  defaultNameTransformationCasing;
1157
1188
  stepSchema;
@@ -1159,17 +1190,17 @@ let ne = class extends Ee {
1159
1190
  mountCount = 0;
1160
1191
  constructor(e) {
1161
1192
  super();
1162
- const { steps: t, nameTransformCasing: r, storage: s } = e;
1163
- this.defaultNameTransformationCasing = be(
1193
+ const { steps: t, nameTransformCasing: r, storage: n } = e;
1194
+ this.defaultNameTransformationCasing = Se(
1164
1195
  r
1165
- ), this.stepSchema = new ne({
1196
+ ), this.stepSchema = new se({
1166
1197
  steps: t,
1167
1198
  nameTransformCasing: this.defaultNameTransformationCasing
1168
1199
  }), this.storage = new ve({
1169
- key: s?.key ?? re,
1200
+ key: n?.key ?? ne,
1170
1201
  data: this.stepSchema.value,
1171
- store: s?.store,
1172
- throwWhenUndefined: s?.throwWhenUndefined ?? !1
1202
+ store: n?.store,
1203
+ throwWhenUndefined: n?.throwWhenUndefined ?? !1
1173
1204
  }), this.stepSchema.subscribe(() => {
1174
1205
  this.notify();
1175
1206
  });
@@ -1206,262 +1237,274 @@ let ne = class extends Ee {
1206
1237
  };
1207
1238
  function Ie(o) {
1208
1239
  function e(t) {
1209
- const { children: r, name: s } = t;
1210
- return r(o(s));
1240
+ const { children: r, name: n } = t;
1241
+ return r(o(n));
1211
1242
  }
1212
1243
  return e;
1213
1244
  }
1214
- var L;
1245
+ var x;
1215
1246
  ((o) => {
1216
1247
  o.DEFAULT_FORM_ALIAS = "Form";
1217
- function e(r, s) {
1248
+ function e(r, n) {
1218
1249
  if (Array.isArray(r)) {
1219
- if (s === "all")
1250
+ if (n === "all")
1220
1251
  return !0;
1221
- if (typeof s == "object" && !Array.isArray(s))
1222
- return Object.keys(s).some(
1223
- (n) => r.includes(n)
1252
+ if (typeof n == "object" && !Array.isArray(n))
1253
+ return Object.keys(n).some(
1254
+ (s) => r.includes(s)
1224
1255
  );
1225
- if (Array.isArray(s))
1226
- return s.some((n) => r.includes(n));
1256
+ if (Array.isArray(n))
1257
+ return n.some((s) => r.includes(s));
1227
1258
  }
1228
1259
  return !1;
1229
1260
  }
1230
1261
  o.isFormAvailable = e;
1231
1262
  function t(r) {
1232
- return (s) => /* @__PURE__ */ Ae("form", { id: r, ...s });
1263
+ return (n) => /* @__PURE__ */ je("form", { id: r, ...n });
1233
1264
  }
1234
1265
  o.createDefaultForm = t;
1235
- })(L || (L = {}));
1266
+ })(x || (x = {}));
1236
1267
  var X;
1237
1268
  ((o) => {
1238
1269
  o.DEFAULT_FORM_INSTANCE_ALIAS = "form";
1239
1270
  })(X || (X = {}));
1240
1271
  function De(o, e) {
1241
- w(
1272
+ E(
1242
1273
  e in o,
1243
1274
  `The target step ${e} is not a valid step key`
1244
1275
  );
1245
1276
  const t = o[e];
1246
- w("fields" in t, `No "fields" were found for ${e}`);
1277
+ E("fields" in t, `No "fields" were found for ${e}`);
1247
1278
  let r = {};
1248
- for (const [s, n] of Object.entries(
1279
+ for (const [n, s] of Object.entries(
1249
1280
  t.fields
1250
1281
  ))
1251
1282
  r = {
1252
1283
  ...r,
1253
- [s]: n.defaultValue
1284
+ [n]: s.defaultValue
1254
1285
  };
1255
1286
  return r;
1256
1287
  }
1257
- class Me extends ne {
1288
+ class Me extends se {
1258
1289
  // @ts-ignore type doesn't match `MultiStepFormSchemaBase.value`
1259
1290
  value;
1260
1291
  #e;
1261
1292
  constructor(e) {
1262
1293
  const { form: t, ...r } = e;
1263
- super(r), this.value = _e(this.original), this.#e = new ee({
1294
+ super(r), this.value = we(this.original), this.#e = new te({
1264
1295
  getValue: () => this.value,
1265
- setValue: (s) => this.handlePostUpdate(s)
1266
- }), this.sync(), this.value = this.#e.enrichValues(this.value, (s) => {
1267
- const n = `step${s}`, a = [n], u = t?.id ?? n, b = N(this.value, a);
1296
+ setValue: (n) => this.handlePostUpdate(n)
1297
+ }), this.sync(), this.value = this.#e.enrichValues(this.value, (n) => {
1298
+ const s = `step${n}`, i = [s], u = t?.id ?? s, S = L(this.value, i);
1268
1299
  return {
1269
1300
  createComponent: this.createStepSpecificComponentFactory(
1270
- a,
1301
+ i,
1271
1302
  {
1272
1303
  isStepSpecific: !0,
1273
1304
  defaultId: u,
1274
1305
  form: t
1275
1306
  },
1276
- b
1307
+ S
1277
1308
  )
1278
1309
  };
1279
1310
  });
1280
1311
  }
1281
1312
  createFormComponent(e, t) {
1282
- const { render: r, enabledForSteps: s = "all", id: n = t } = e, a = {
1283
- id: n,
1284
- steps: N(this.value, s)
1313
+ const { render: r, enabledForSteps: n = "all", id: s = t } = e, i = {
1314
+ id: s,
1315
+ steps: L(this.value, n)
1285
1316
  };
1286
- return (u) => r(a, u);
1317
+ return (u) => r(i, u);
1287
1318
  }
1288
- createStepSpecificComponentImpl(e, t, r, s = {}) {
1289
- return (n) => ((a) => {
1319
+ createStepSpecificComponentImpl(e, t, r, n = {}) {
1320
+ return (s) => ((i) => {
1290
1321
  const u = {};
1291
- for (const [E, O] of Object.entries(s))
1292
- if (typeof O == "function")
1322
+ for (const [w, j] of Object.entries(n))
1323
+ if (typeof j == "function")
1293
1324
  try {
1294
- const A = O();
1295
- u[E] = A, typeof console < "u" && console.debug && console.debug(
1296
- `[multi-step-form] Hook "${E}" called successfully`,
1297
- { result: A === void 0 ? "defined" : "undefined" }
1298
- );
1299
- } catch (A) {
1300
- const i = A instanceof Error ? A.message : String(A);
1325
+ const a = j();
1326
+ u[w] = a;
1327
+ } catch (a) {
1328
+ const l = a instanceof Error ? a.message : String(a);
1301
1329
  throw new Error(
1302
- `[multi-step-form] Error calling hook "${E}" in useFormInstance.render: ${i}
1330
+ `[multi-step-form] Error calling hook "${w}" in useFormInstance.render: ${l}
1303
1331
 
1304
1332
  This usually means:
1305
1333
  1. The hook is being called outside of a React component
1306
1334
  2. The hook has invalid dependencies or configuration
1307
1335
  3. There's an error in your hook implementation
1308
1336
 
1309
- Original error: ${i}`,
1310
- { cause: A }
1337
+ Original error: ${l}`,
1338
+ { cause: a }
1311
1339
  );
1312
1340
  }
1313
1341
  else
1314
- u[E] = O;
1315
- const { defaultId: b, form: S } = t, { ctx: p } = r, [f] = e;
1316
- w(
1342
+ u[w] = j;
1343
+ const { defaultId: S, form: g } = t, { ctx: p } = r, [f] = e;
1344
+ E(
1317
1345
  this.steps.isValidStepKey(f),
1318
1346
  `[createComponent]: the target step ${f} is invalid. Note, this error shouldn't appear as the target step should always be valid. If you see this error, please open an issue.`
1319
1347
  );
1320
1348
  const v = Number.parseInt(f.replace("step", ""));
1321
- w(
1349
+ E(
1322
1350
  !Number.isNaN(v),
1323
1351
  `[${f}:"createComponent"]: an error occurred while extracting the number`
1324
1352
  );
1325
1353
  const y = this.value[f];
1326
- w(
1354
+ E(
1327
1355
  "fields" in y,
1328
1356
  `[${f}:createComponent]: unable to find the "fields" for the current step`
1329
- ), w(
1357
+ ), E(
1330
1358
  typeof y.fields == "object",
1331
1359
  `[${f}:createComponent]: the "fields" property must be an object, was ${typeof y.fields}`
1332
1360
  );
1333
- const m = Ie((E) => {
1334
- w(typeof E == "string", () => {
1335
- const h = new Intl.ListFormat("en", {
1361
+ const h = this.#e.createStepUpdaterFn(f), b = Ie((w) => {
1362
+ E(typeof w == "string", () => {
1363
+ const c = new Intl.ListFormat("en", {
1336
1364
  style: "long",
1337
1365
  type: "disjunction"
1338
1366
  });
1339
- return `[${f}:Field]: the "name" prop must be a string and a valid field for ${f}. Available fields include ${h.format(
1367
+ return `[${f}:Field]: the "name" prop must be a string and a valid field for ${f}. Available fields include ${c.format(
1340
1368
  Object.keys(y.fields)
1341
1369
  )}`;
1342
- }), w(
1343
- E in y.fields,
1344
- `[${f}:Field]: the field "${E}" doesn't exist for the current step`
1345
- ), w(
1370
+ }), E(
1371
+ w in y.fields,
1372
+ `[${f}:Field]: the field "${w}" doesn't exist for the current step`
1373
+ ), E(
1346
1374
  "update" in y,
1347
1375
  `[${f}:Field]: No "update" function was found`
1348
1376
  );
1349
- const { fields: O, update: A } = y, { defaultValue: i, label: l, nameTransformCasing: d, type: c } = O[E];
1377
+ const { defaultValue: j, label: a, nameTransformCasing: l, type: d } = y.fields[w];
1350
1378
  return {
1351
- defaultValue: i,
1352
- label: l,
1353
- nameTransformCasing: d,
1354
- type: c,
1355
- name: E,
1356
- onInputChange: (h) => (
1357
- // TODO remove type assertions
1358
- A({
1359
- fields: [`fields.${E}.defaultValue`],
1360
- updater: h
1361
- })
1362
- )
1379
+ defaultValue: j,
1380
+ label: a,
1381
+ nameTransformCasing: l,
1382
+ type: d,
1383
+ name: w,
1384
+ onInputChange: (c) => {
1385
+ const m = typeof c == "function" ? c(
1386
+ this.getValue(f, w)
1387
+ ) : c;
1388
+ this.update({
1389
+ targetStep: f,
1390
+ updater: m,
1391
+ fields: [`fields.${w}.defaultValue`]
1392
+ });
1393
+ }
1394
+ // onInputChange: (value: unknown) =>
1395
+ // // TODO remove type assertions
1396
+ // (
1397
+ // update as UpdateFn.stepSpecific<
1398
+ // resolvedStep,
1399
+ // stepNumbers,
1400
+ // ValidStepKey<stepNumbers>
1401
+ // >
1402
+ // )({
1403
+ // fields: [`fields.${name}.defaultValue`] as never,
1404
+ // updater: value as never,
1405
+ // }),
1363
1406
  };
1364
1407
  });
1365
- let g = {
1408
+ let $ = {
1366
1409
  ctx: p,
1367
- onInputChange: this.#e.createStepUpdaterFn(f),
1368
- Field: m,
1410
+ onInputChange: h,
1411
+ Field: b,
1369
1412
  ...u
1370
1413
  };
1371
- if (S) {
1414
+ if (g) {
1372
1415
  const {
1373
- alias: E = L.DEFAULT_FORM_ALIAS,
1374
- ...O
1375
- } = S, A = O.enabledForSteps ?? "all";
1376
- return L.isFormAvailable(
1416
+ alias: w = x.DEFAULT_FORM_ALIAS,
1417
+ ...j
1418
+ } = g, a = j.enabledForSteps ?? "all";
1419
+ return x.isFormAvailable(
1377
1420
  e,
1378
- A
1379
- ) && (g = {
1380
- ...g,
1381
- [E]: this.createFormComponent(O, b)
1382
- }), n(g, a);
1421
+ a
1422
+ ) && ($ = {
1423
+ ...$,
1424
+ [w]: this.createFormComponent(j, S)
1425
+ }), s($, i);
1383
1426
  }
1384
- return n(
1427
+ return s(
1385
1428
  {
1386
- ...g,
1387
- [L.DEFAULT_FORM_ALIAS]: L.createDefaultForm(b)
1429
+ ...$,
1430
+ [x.DEFAULT_FORM_ALIAS]: x.createDefaultForm(S)
1388
1431
  },
1389
- a
1432
+ i
1390
1433
  );
1391
1434
  });
1392
1435
  }
1393
1436
  createStepSpecificComponentFactory(e, t, r) {
1394
- const s = this.createStepSpecificComponentImpl.bind(this), n = this.createDefaultValues.bind(this);
1437
+ const n = this.createStepSpecificComponentImpl.bind(this), s = this.createDefaultValues.bind(this);
1395
1438
  debugger;
1396
- const a = this.value, u = e[0], b = this.#e.createStepUpdaterFn(u).bind(this.#e);
1397
- function S(p, f) {
1398
- function v(m) {
1399
- return m ? { ctx: { ...r, ...m } } : { ctx: r };
1439
+ const i = this.value, u = e[0], S = this.#e.createStepUpdaterFn(u).bind(this.#e);
1440
+ function g(p, f) {
1441
+ function v(h) {
1442
+ return h ? { ctx: { ...r, ...h } } : { ctx: r };
1400
1443
  }
1401
1444
  function y() {
1402
- return w(
1445
+ return E(
1403
1446
  typeof p == "function",
1404
1447
  "The first argument must be a function"
1405
- ), s(
1448
+ ), n(
1406
1449
  e,
1407
1450
  t,
1408
1451
  v(void 0)
1409
1452
  )(p);
1410
1453
  }
1411
1454
  if (typeof p == "object") {
1412
- const { useFormInstance: m, ctxData: g, debug: E } = p, O = new Q({
1413
- debug: E,
1455
+ const { useFormInstance: h, ctxData: b, debug: $ } = p, w = new ee({
1456
+ debug: $,
1414
1457
  prefix(l) {
1415
1458
  return `${l}-${u}-createComponent`;
1416
1459
  }
1417
1460
  });
1418
- O.info("First argument is an object");
1419
- const { [u]: A, ...i } = a;
1420
- if (w(
1461
+ w.info("First argument is an object");
1462
+ const { [u]: j, ...a } = i;
1463
+ if (E(
1421
1464
  typeof f == "function",
1422
1465
  "The second argument must be a function"
1423
- ), m) {
1466
+ ), h) {
1424
1467
  const {
1425
1468
  render: l,
1426
1469
  alias: d = X.DEFAULT_FORM_INSTANCE_ALIAS
1427
- } = m, [c] = e, h = n(c), _ = g ? {
1470
+ } = h, [c] = e, m = s(c), _ = b ? {
1428
1471
  ...r,
1429
- ...g({ ctx: i })
1430
- } : r, $ = { ctx: _, defaultValues: h };
1431
- return s(
1472
+ ...b({ ctx: a })
1473
+ } : r, O = { ctx: _, defaultValues: m };
1474
+ return n(
1432
1475
  e,
1433
1476
  t,
1434
1477
  _,
1435
1478
  {
1436
- [d]: () => l($)
1479
+ [d]: () => l(O)
1437
1480
  }
1438
1481
  )(f);
1439
1482
  }
1440
- if (g) {
1441
- O.info('Option "ctxData" is defined'), w(
1442
- typeof g == "function",
1483
+ if (b) {
1484
+ w.info('Option "ctxData" is defined'), E(
1485
+ typeof b == "function",
1443
1486
  'Option "ctxData" must be a function'
1444
1487
  );
1445
- const l = g({ ctx: i });
1446
- O.info(
1488
+ const l = b({ ctx: a });
1489
+ w.info(
1447
1490
  `Addition context is: ${JSON.stringify(l, null, 2)}`
1448
1491
  );
1449
1492
  const d = {
1450
1493
  ...r,
1451
1494
  ...l
1452
1495
  };
1453
- return O.info(
1496
+ return w.info(
1454
1497
  `Resolved context is: ${JSON.stringify(d, null, 2)}`
1455
- ), s(e, t, {
1498
+ ), n(e, t, {
1456
1499
  ctx: d,
1457
- update: b
1500
+ update: S
1458
1501
  })(f);
1459
1502
  }
1460
1503
  return y();
1461
1504
  }
1462
1505
  return y();
1463
1506
  }
1464
- return S;
1507
+ return g;
1465
1508
  }
1466
1509
  /**
1467
1510
  * A helper function to create a component for a specific step.
@@ -1471,53 +1514,47 @@ Original error: ${i}`,
1471
1514
  * @returns The created component for the step.
1472
1515
  */
1473
1516
  createComponent(e, t) {
1474
- const { stepData: r } = e, s = N(
1517
+ const { stepData: r } = e, n = L(
1475
1518
  this.value,
1476
1519
  r
1477
1520
  );
1478
- return ((n) => t(s, n));
1521
+ return ((s) => t(n, s));
1479
1522
  }
1480
1523
  createDefaultValues(e) {
1481
1524
  return De(this.value, e);
1482
1525
  }
1483
1526
  }
1484
1527
  class Ue extends Ne {
1528
+ // @ts-ignore
1485
1529
  stepSchema;
1486
1530
  #e;
1487
1531
  constructor(e) {
1488
- const { nameTransformCasing: t = te, storage: r, ...s } = e;
1489
- super({
1490
- nameTransformCasing: t,
1491
- storage: r,
1492
- ...s
1493
- }), this.stepSchema = new Me({
1494
- nameTransformCasing: t,
1495
- ...s
1496
- }), this.#e = new ee({
1532
+ const { nameTransformCasing: t = re, storage: r, ...n } = e, s = { nameTransformCasing: t, storage: r, ...n };
1533
+ super(s), this.stepSchema = new Me(s), this.#e = new te({
1497
1534
  getValue: () => this.stepSchema.value,
1498
- setValue: (n) => {
1499
- this.stepSchema.value = { ...n }, this.storage.add(n), this.notify();
1535
+ setValue: (i) => {
1536
+ this.stepSchema.value = { ...i }, this.storage.add(i), this.notify();
1500
1537
  }
1501
1538
  });
1502
1539
  }
1503
1540
  createComponent(e, t) {
1504
- const { stepData: r } = e, s = N(
1541
+ const { stepData: r } = e, n = L(
1505
1542
  this.stepSchema.value,
1506
1543
  r
1507
1544
  );
1508
- return ((n) => t(
1545
+ return ((s) => t(
1509
1546
  {
1510
- ctx: s,
1547
+ ctx: n,
1511
1548
  update: this.#e.createHelperFnInputUpdate(r)
1512
1549
  },
1513
- n
1550
+ s
1514
1551
  ));
1515
1552
  }
1516
1553
  }
1517
1554
  function Ye(o) {
1518
1555
  return new Ue(o);
1519
1556
  }
1520
- var I = { exports: {} }, B = {}, D = { exports: {} }, J = {};
1557
+ var I = { exports: {} }, H = {}, D = { exports: {} }, B = {};
1521
1558
  /**
1522
1559
  * @license React
1523
1560
  * use-sync-external-store-shim.production.js
@@ -1529,30 +1566,30 @@ var I = { exports: {} }, B = {}, D = { exports: {} }, J = {};
1529
1566
  */
1530
1567
  var le;
1531
1568
  function Re() {
1532
- if (le) return J;
1569
+ if (le) return B;
1533
1570
  le = 1;
1534
- var o = G;
1571
+ var o = R;
1535
1572
  function e(f, v) {
1536
1573
  return f === v && (f !== 0 || 1 / f === 1 / v) || f !== f && v !== v;
1537
1574
  }
1538
- var t = typeof Object.is == "function" ? Object.is : e, r = o.useState, s = o.useEffect, n = o.useLayoutEffect, a = o.useDebugValue;
1575
+ var t = typeof Object.is == "function" ? Object.is : e, r = o.useState, n = o.useEffect, s = o.useLayoutEffect, i = o.useDebugValue;
1539
1576
  function u(f, v) {
1540
- var y = v(), m = r({ inst: { value: y, getSnapshot: v } }), g = m[0].inst, E = m[1];
1541
- return n(
1577
+ var y = v(), h = r({ inst: { value: y, getSnapshot: v } }), b = h[0].inst, $ = h[1];
1578
+ return s(
1542
1579
  function() {
1543
- g.value = y, g.getSnapshot = v, b(g) && E({ inst: g });
1580
+ b.value = y, b.getSnapshot = v, S(b) && $({ inst: b });
1544
1581
  },
1545
1582
  [f, y, v]
1546
- ), s(
1583
+ ), n(
1547
1584
  function() {
1548
- return b(g) && E({ inst: g }), f(function() {
1549
- b(g) && E({ inst: g });
1585
+ return S(b) && $({ inst: b }), f(function() {
1586
+ S(b) && $({ inst: b });
1550
1587
  });
1551
1588
  },
1552
1589
  [f]
1553
- ), a(y), y;
1590
+ ), i(y), y;
1554
1591
  }
1555
- function b(f) {
1592
+ function S(f) {
1556
1593
  var v = f.getSnapshot;
1557
1594
  f = f.value;
1558
1595
  try {
@@ -1562,13 +1599,13 @@ function Re() {
1562
1599
  return !0;
1563
1600
  }
1564
1601
  }
1565
- function S(f, v) {
1602
+ function g(f, v) {
1566
1603
  return v();
1567
1604
  }
1568
- var p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? S : u;
1569
- return J.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : p, J;
1605
+ var p = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? g : u;
1606
+ return B.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : p, B;
1570
1607
  }
1571
- var z = {};
1608
+ var J = {};
1572
1609
  /**
1573
1610
  * @license React
1574
1611
  * use-sync-external-store-shim.development.js
@@ -1581,58 +1618,58 @@ var z = {};
1581
1618
  var fe;
1582
1619
  function Ke() {
1583
1620
  return fe || (fe = 1, process.env.NODE_ENV !== "production" && (function() {
1584
- function o(y, m) {
1585
- return y === m && (y !== 0 || 1 / y === 1 / m) || y !== y && m !== m;
1621
+ function o(y, h) {
1622
+ return y === h && (y !== 0 || 1 / y === 1 / h) || y !== y && h !== h;
1586
1623
  }
1587
- function e(y, m) {
1588
- p || s.startTransition === void 0 || (p = !0, console.error(
1624
+ function e(y, h) {
1625
+ p || n.startTransition === void 0 || (p = !0, console.error(
1589
1626
  "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
1590
1627
  ));
1591
- var g = m();
1628
+ var b = h();
1592
1629
  if (!f) {
1593
- var E = m();
1594
- n(g, E) || (console.error(
1630
+ var $ = h();
1631
+ s(b, $) || (console.error(
1595
1632
  "The result of getSnapshot should be cached to avoid an infinite loop"
1596
1633
  ), f = !0);
1597
1634
  }
1598
- E = a({
1599
- inst: { value: g, getSnapshot: m }
1635
+ $ = i({
1636
+ inst: { value: b, getSnapshot: h }
1600
1637
  });
1601
- var O = E[0].inst, A = E[1];
1602
- return b(
1638
+ var w = $[0].inst, j = $[1];
1639
+ return S(
1603
1640
  function() {
1604
- O.value = g, O.getSnapshot = m, t(O) && A({ inst: O });
1641
+ w.value = b, w.getSnapshot = h, t(w) && j({ inst: w });
1605
1642
  },
1606
- [y, g, m]
1643
+ [y, b, h]
1607
1644
  ), u(
1608
1645
  function() {
1609
- return t(O) && A({ inst: O }), y(function() {
1610
- t(O) && A({ inst: O });
1646
+ return t(w) && j({ inst: w }), y(function() {
1647
+ t(w) && j({ inst: w });
1611
1648
  });
1612
1649
  },
1613
1650
  [y]
1614
- ), S(g), g;
1651
+ ), g(b), b;
1615
1652
  }
1616
1653
  function t(y) {
1617
- var m = y.getSnapshot;
1654
+ var h = y.getSnapshot;
1618
1655
  y = y.value;
1619
1656
  try {
1620
- var g = m();
1621
- return !n(y, g);
1657
+ var b = h();
1658
+ return !s(y, b);
1622
1659
  } catch {
1623
1660
  return !0;
1624
1661
  }
1625
1662
  }
1626
- function r(y, m) {
1627
- return m();
1663
+ function r(y, h) {
1664
+ return h();
1628
1665
  }
1629
1666
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1630
- var s = G, n = typeof Object.is == "function" ? Object.is : o, a = s.useState, u = s.useEffect, b = s.useLayoutEffect, S = s.useDebugValue, p = !1, f = !1, v = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
1631
- z.useSyncExternalStore = s.useSyncExternalStore !== void 0 ? s.useSyncExternalStore : v, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1632
- })()), z;
1667
+ var n = R, s = typeof Object.is == "function" ? Object.is : o, i = n.useState, u = n.useEffect, S = n.useLayoutEffect, g = n.useDebugValue, p = !1, f = !1, v = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? r : e;
1668
+ J.useSyncExternalStore = n.useSyncExternalStore !== void 0 ? n.useSyncExternalStore : v, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1669
+ })()), J;
1633
1670
  }
1634
1671
  var pe;
1635
- function Oe() {
1672
+ function $e() {
1636
1673
  return pe || (pe = 1, process.env.NODE_ENV === "production" ? D.exports = Re() : D.exports = Ke()), D.exports;
1637
1674
  }
1638
1675
  /**
@@ -1645,57 +1682,57 @@ function Oe() {
1645
1682
  * LICENSE file in the root directory of this source tree.
1646
1683
  */
1647
1684
  var de;
1648
- function Ge() {
1649
- if (de) return B;
1685
+ function Pe() {
1686
+ if (de) return H;
1650
1687
  de = 1;
1651
- var o = G, e = Oe();
1652
- function t(S, p) {
1653
- return S === p && (S !== 0 || 1 / S === 1 / p) || S !== S && p !== p;
1654
- }
1655
- var r = typeof Object.is == "function" ? Object.is : t, s = e.useSyncExternalStore, n = o.useRef, a = o.useEffect, u = o.useMemo, b = o.useDebugValue;
1656
- return B.useSyncExternalStoreWithSelector = function(S, p, f, v, y) {
1657
- var m = n(null);
1658
- if (m.current === null) {
1659
- var g = { hasValue: !1, value: null };
1660
- m.current = g;
1661
- } else g = m.current;
1662
- m = u(
1688
+ var o = R, e = $e();
1689
+ function t(g, p) {
1690
+ return g === p && (g !== 0 || 1 / g === 1 / p) || g !== g && p !== p;
1691
+ }
1692
+ var r = typeof Object.is == "function" ? Object.is : t, n = e.useSyncExternalStore, s = o.useRef, i = o.useEffect, u = o.useMemo, S = o.useDebugValue;
1693
+ return H.useSyncExternalStoreWithSelector = function(g, p, f, v, y) {
1694
+ var h = s(null);
1695
+ if (h.current === null) {
1696
+ var b = { hasValue: !1, value: null };
1697
+ h.current = b;
1698
+ } else b = h.current;
1699
+ h = u(
1663
1700
  function() {
1664
- function O(c) {
1665
- if (!A) {
1666
- if (A = !0, i = c, c = v(c), y !== void 0 && g.hasValue) {
1667
- var h = g.value;
1668
- if (y(h, c))
1669
- return l = h;
1701
+ function w(c) {
1702
+ if (!j) {
1703
+ if (j = !0, a = c, c = v(c), y !== void 0 && b.hasValue) {
1704
+ var m = b.value;
1705
+ if (y(m, c))
1706
+ return l = m;
1670
1707
  }
1671
1708
  return l = c;
1672
1709
  }
1673
- if (h = l, r(i, c)) return h;
1710
+ if (m = l, r(a, c)) return m;
1674
1711
  var _ = v(c);
1675
- return y !== void 0 && y(h, _) ? (i = c, h) : (i = c, l = _);
1712
+ return y !== void 0 && y(m, _) ? (a = c, m) : (a = c, l = _);
1676
1713
  }
1677
- var A = !1, i, l, d = f === void 0 ? null : f;
1714
+ var j = !1, a, l, d = f === void 0 ? null : f;
1678
1715
  return [
1679
1716
  function() {
1680
- return O(p());
1717
+ return w(p());
1681
1718
  },
1682
1719
  d === null ? void 0 : function() {
1683
- return O(d());
1720
+ return w(d());
1684
1721
  }
1685
1722
  ];
1686
1723
  },
1687
1724
  [p, f, v, y]
1688
1725
  );
1689
- var E = s(S, m[0], m[1]);
1690
- return a(
1726
+ var $ = n(g, h[0], h[1]);
1727
+ return i(
1691
1728
  function() {
1692
- g.hasValue = !0, g.value = E;
1729
+ b.hasValue = !0, b.value = $;
1693
1730
  },
1694
- [E]
1695
- ), b(E), E;
1696
- }, B;
1731
+ [$]
1732
+ ), S($), $;
1733
+ }, H;
1697
1734
  }
1698
- var q = {};
1735
+ var z = {};
1699
1736
  /**
1700
1737
  * @license React
1701
1738
  * use-sync-external-store-shim/with-selector.development.js
@@ -1706,95 +1743,95 @@ var q = {};
1706
1743
  * LICENSE file in the root directory of this source tree.
1707
1744
  */
1708
1745
  var he;
1709
- function Pe() {
1746
+ function Ge() {
1710
1747
  return he || (he = 1, process.env.NODE_ENV !== "production" && (function() {
1711
- function o(S, p) {
1712
- return S === p && (S !== 0 || 1 / S === 1 / p) || S !== S && p !== p;
1748
+ function o(g, p) {
1749
+ return g === p && (g !== 0 || 1 / g === 1 / p) || g !== g && p !== p;
1713
1750
  }
1714
1751
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
1715
- var e = G, t = Oe(), r = typeof Object.is == "function" ? Object.is : o, s = t.useSyncExternalStore, n = e.useRef, a = e.useEffect, u = e.useMemo, b = e.useDebugValue;
1716
- q.useSyncExternalStoreWithSelector = function(S, p, f, v, y) {
1717
- var m = n(null);
1718
- if (m.current === null) {
1719
- var g = { hasValue: !1, value: null };
1720
- m.current = g;
1721
- } else g = m.current;
1722
- m = u(
1752
+ var e = R, t = $e(), r = typeof Object.is == "function" ? Object.is : o, n = t.useSyncExternalStore, s = e.useRef, i = e.useEffect, u = e.useMemo, S = e.useDebugValue;
1753
+ z.useSyncExternalStoreWithSelector = function(g, p, f, v, y) {
1754
+ var h = s(null);
1755
+ if (h.current === null) {
1756
+ var b = { hasValue: !1, value: null };
1757
+ h.current = b;
1758
+ } else b = h.current;
1759
+ h = u(
1723
1760
  function() {
1724
- function O(c) {
1725
- if (!A) {
1726
- if (A = !0, i = c, c = v(c), y !== void 0 && g.hasValue) {
1727
- var h = g.value;
1728
- if (y(h, c))
1729
- return l = h;
1761
+ function w(c) {
1762
+ if (!j) {
1763
+ if (j = !0, a = c, c = v(c), y !== void 0 && b.hasValue) {
1764
+ var m = b.value;
1765
+ if (y(m, c))
1766
+ return l = m;
1730
1767
  }
1731
1768
  return l = c;
1732
1769
  }
1733
- if (h = l, r(i, c))
1734
- return h;
1770
+ if (m = l, r(a, c))
1771
+ return m;
1735
1772
  var _ = v(c);
1736
- return y !== void 0 && y(h, _) ? (i = c, h) : (i = c, l = _);
1773
+ return y !== void 0 && y(m, _) ? (a = c, m) : (a = c, l = _);
1737
1774
  }
1738
- var A = !1, i, l, d = f === void 0 ? null : f;
1775
+ var j = !1, a, l, d = f === void 0 ? null : f;
1739
1776
  return [
1740
1777
  function() {
1741
- return O(p());
1778
+ return w(p());
1742
1779
  },
1743
1780
  d === null ? void 0 : function() {
1744
- return O(d());
1781
+ return w(d());
1745
1782
  }
1746
1783
  ];
1747
1784
  },
1748
1785
  [p, f, v, y]
1749
1786
  );
1750
- var E = s(S, m[0], m[1]);
1751
- return a(
1787
+ var $ = n(g, h[0], h[1]);
1788
+ return i(
1752
1789
  function() {
1753
- g.hasValue = !0, g.value = E;
1790
+ b.hasValue = !0, b.value = $;
1754
1791
  },
1755
- [E]
1756
- ), b(E), E;
1792
+ [$]
1793
+ ), S($), $;
1757
1794
  }, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1758
- })()), q;
1795
+ })()), z;
1759
1796
  }
1760
1797
  var me;
1761
- function He() {
1762
- return me || (me = 1, process.env.NODE_ENV === "production" ? I.exports = Ge() : I.exports = Pe()), I.exports;
1798
+ function We() {
1799
+ return me || (me = 1, process.env.NODE_ENV === "production" ? I.exports = Pe() : I.exports = Ge()), I.exports;
1763
1800
  }
1764
- var We = He();
1801
+ var He = We();
1765
1802
  function Z(o, e) {
1766
- w(
1803
+ E(
1767
1804
  typeof e == "string",
1768
1805
  `The target step must be a string, was ${typeof e}`
1769
1806
  );
1770
- const { as: t, isValidStepNumber: r } = o.stepSchema.steps, n = new Intl.ListFormat("en", {
1807
+ const { as: t, isValidStepNumber: r } = o.stepSchema.steps, s = new Intl.ListFormat("en", {
1771
1808
  type: "disjunction",
1772
1809
  style: "long"
1773
1810
  }).format(t("array.string.untyped"));
1774
- w(
1775
- we.test(e),
1776
- `The target step must match the following format: "step{number}". Available steps are ${n}`
1811
+ E(
1812
+ _e.test(e),
1813
+ `The target step must match the following format: "step{number}". Available steps are ${s}`
1777
1814
  );
1778
- const a = Number.parseInt(e.replace("step", ""));
1779
- return w(
1780
- r(a),
1781
- `The step number "${a}" is not a valid step number. Valid step numbers include ${n}`,
1815
+ const i = Number.parseInt(e.replace("step", ""));
1816
+ return E(
1817
+ r(i),
1818
+ `The step number "${i}" is not a valid step number. Valid step numbers include ${s}`,
1782
1819
  TypeError
1783
- ), a;
1820
+ ), i;
1784
1821
  }
1785
- function $e(o) {
1822
+ function Oe(o) {
1786
1823
  function e(t) {
1787
- return We.useSyncExternalStoreWithSelector(
1824
+ return He.useSyncExternalStoreWithSelector(
1788
1825
  o.subscribe,
1789
1826
  () => o.getSnapshot(),
1790
1827
  () => o.getSnapshot(),
1791
1828
  (r) => {
1792
1829
  if (typeof t == "object") {
1793
- const s = Z(
1830
+ const n = Z(
1794
1831
  r,
1795
1832
  t.targetStep
1796
1833
  );
1797
- return r.stepSchema.get({ step: s }).data;
1834
+ return r.stepSchema.get({ step: n }).data;
1798
1835
  }
1799
1836
  return typeof t == "function" ? t(r) : r;
1800
1837
  }
@@ -1803,7 +1840,7 @@ function $e(o) {
1803
1840
  return e;
1804
1841
  }
1805
1842
  function Xe(o, e) {
1806
- const t = $e(o);
1843
+ const t = Oe(o);
1807
1844
  return typeof e == "object" || typeof e == "function" ? t(e) : t();
1808
1845
  }
1809
1846
  function ye(o) {
@@ -1812,18 +1849,18 @@ function ye(o) {
1812
1849
  };
1813
1850
  }
1814
1851
  function Ze(o) {
1815
- const e = $e(o);
1852
+ const e = Oe(o);
1816
1853
  function t(u) {
1817
- const { targetStep: b, notFoundMessage: S, isDataGuaranteed: p } = u, f = e({
1818
- targetStep: b
1819
- }), v = S ? a({ targetStep: b }, S) : (y) => /* @__PURE__ */ se("div", { ...y, children: [
1854
+ const { targetStep: S, notFoundMessage: g, isDataGuaranteed: p } = u, f = e({
1855
+ targetStep: S
1856
+ }), v = g ? i({ targetStep: S }, g) : (y) => /* @__PURE__ */ oe("div", { ...y, children: [
1820
1857
  "No data found for step ",
1821
- String(b)
1858
+ String(S)
1822
1859
  ] });
1823
1860
  return p ? {
1824
1861
  data: f,
1825
1862
  NoCurrentData: v
1826
- } : ne.hasData(f) ? {
1863
+ } : se.hasData(f) ? {
1827
1864
  data: f,
1828
1865
  hasData: !0,
1829
1866
  NoCurrentData: v
@@ -1834,47 +1871,47 @@ function Ze(o) {
1834
1871
  };
1835
1872
  }
1836
1873
  function r(u) {
1837
- const b = e(
1838
- (E) => E.stepSchema.steps.value.length
1874
+ const S = e(
1875
+ ($) => $.stepSchema.steps.value.length
1839
1876
  ), {
1840
- targetStep: S,
1877
+ targetStep: g,
1841
1878
  maxProgressValue: p = 100,
1842
- totalSteps: f = b,
1879
+ totalSteps: f = S,
1843
1880
  progressTextTransformer: v
1844
- } = u, y = Z(o, S), m = y / f * p, g = v ? n(
1845
- { targetStep: S, maxProgressValue: p, totalSteps: f },
1881
+ } = u, y = Z(o, g), h = y / f * p, b = v ? s(
1882
+ { targetStep: g, maxProgressValue: p, totalSteps: f },
1846
1883
  v
1847
- ) : (E) => /* @__PURE__ */ se("div", { ...E, children: [
1884
+ ) : ($) => /* @__PURE__ */ oe("div", { ...$, children: [
1848
1885
  "Step ",
1849
1886
  y,
1850
1887
  "/",
1851
1888
  f
1852
1889
  ] });
1853
1890
  return {
1854
- value: m,
1891
+ value: h,
1855
1892
  maxProgressValue: p,
1856
- ProgressText: g
1893
+ ProgressText: b
1857
1894
  };
1858
1895
  }
1859
- function s(u) {
1860
- const S = e((f) => f.storage).get(), p = !!(S && typeof S == "object" && Object.keys(S).length > 0);
1896
+ function n(u) {
1897
+ const g = e((f) => f.storage).get(), p = !!(g && typeof g == "object" && Object.keys(g).length > 0);
1861
1898
  return u ? u(p) : p;
1862
1899
  }
1863
- function n(u, b) {
1864
- const S = o.getSnapshot().stepSchema.steps.value.length, { targetStep: p, maxProgressValue: f = 100, totalSteps: v = S } = u;
1865
- return ye({ targetStep: p, maxProgressValue: f, totalSteps: v })(b);
1900
+ function s(u, S) {
1901
+ const g = o.getSnapshot().stepSchema.steps.value.length, { targetStep: p, maxProgressValue: f = 100, totalSteps: v = g } = u;
1902
+ return ye({ targetStep: p, maxProgressValue: f, totalSteps: v })(S);
1866
1903
  }
1867
- function a(u, b) {
1868
- return Z(o, u.targetStep), ye(u)(b);
1904
+ function i(u, S) {
1905
+ return Z(o, u.targetStep), ye(u)(S);
1869
1906
  }
1870
1907
  return {
1871
1908
  // MultiStepFormContext: Context,
1872
1909
  useMultiStepFormData: e,
1873
1910
  useCurrentStepData: t,
1874
1911
  useProgress: r,
1875
- useCanRestartForm: s,
1876
- withProgressText: n,
1877
- withNoStepDataFound: a
1912
+ useCanRestartForm: n,
1913
+ withProgressText: s,
1914
+ withNoStepDataFound: i
1878
1915
  };
1879
1916
  }
1880
1917
  export {