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