@harnessio/forms 0.14.0 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,21 +1,21 @@
1
- var Ce = Object.defineProperty;
2
- var Ie = (r, e, n) => e in r ? Ce(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
- var D = (r, e, n) => Ie(r, typeof e != "symbol" ? e + "" : e, n);
4
- import { isEmpty as k, set as S, get as v, forOwn as me, isArray as j, isObject as he, merge as M, isUndefined as W, cloneDeep as B, unset as pe, isPlainObject as we, isNull as ye, omitBy as ge, isNil as je, isString as Ve, capitalize as xe } from "lodash-es";
5
- import Fe, { createContext as Pe, useContext as qe, Component as Ae, memo as ke, useMemo as $, useRef as w, useEffect as I, useCallback as Ne, forwardRef as De, Fragment as Me } from "react";
6
- import { useFormContext as $e, get as Ze, useForm as Be, FormProvider as We, appendErrors as Je, useController as Le } from "react-hook-form";
7
- import { Controller as Ur, Form as Hr, FormProvider as Gr, get as Kr, set as Qr, useFieldArray as Xr, useForm as Yr, useFormContext as zr, useFormState as et, useWatch as rt } from "react-hook-form";
8
- import * as d from "zod";
9
- import { toNestErrors as Ue } from "@hookform/resolvers";
10
- class He extends Error {
1
+ var Re = Object.defineProperty;
2
+ var je = (r, e, n) => e in r ? Re(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
3
+ var N = (r, e, n) => je(r, typeof e != "symbol" ? e + "" : e, n);
4
+ import { isEmpty as M, set as O, get as C, forOwn as pe, isArray as x, isObject as he, merge as A, isUndefined as J, cloneDeep as W, unset as ye, isPlainObject as we, isNull as ge, omitBy as be, isNil as Ve, isString as xe, capitalize as Fe } from "lodash-es";
5
+ import Pe, { createContext as qe, useContext as Ae, Component as ke, memo as De, useMemo as B, useRef as V, useEffect as w, useCallback as Me, forwardRef as $e, Fragment as Ne } from "react";
6
+ import { useFormContext as Be, get as Ze, useForm as We, FormProvider as Je, appendErrors as Le, useController as Ue } from "react-hook-form";
7
+ import { Controller as Gr, Form as Kr, FormProvider as Qr, get as Xr, set as Yr, useFieldArray as zr, useForm as et, useFormContext as rt, useFormState as tt, useWatch as nt } from "react-hook-form";
8
+ import * as m from "zod";
9
+ import { toNestErrors as He } from "@hookform/resolvers";
10
+ class Ge extends Error {
11
11
  constructor(e) {
12
12
  super(`Input component '${e}' is already registered.`);
13
13
  }
14
14
  }
15
- class be {
15
+ class ve {
16
16
  constructor(e) {
17
- D(this, "componentBank");
18
- D(this, "allowOverride");
17
+ N(this, "componentBank");
18
+ N(this, "allowOverride");
19
19
  this.allowOverride = (e == null ? void 0 : e.allowOverride) ?? !1, this.componentBank = /* @__PURE__ */ new Map();
20
20
  }
21
21
  /**
@@ -26,11 +26,11 @@ class be {
26
26
  */
27
27
  registerComponent(e) {
28
28
  if (!this.allowOverride && this.getComponent(e.internalType))
29
- throw new He(e.internalType);
29
+ throw new Ge(e.internalType);
30
30
  this.componentBank.set(e.internalType, e);
31
31
  }
32
32
  getComponent(e) {
33
- if (e && !k(e))
33
+ if (e && !M(e))
34
34
  return this.componentBank.get(e);
35
35
  }
36
36
  /**
@@ -47,7 +47,7 @@ class be {
47
47
  * @returns new input factory
48
48
  */
49
49
  clone() {
50
- const e = new be({
50
+ const e = new ve({
51
51
  allowOverride: this.allowOverride
52
52
  });
53
53
  return this.listRegisteredComponents().forEach((n) => {
@@ -55,15 +55,15 @@ class be {
55
55
  }), e;
56
56
  }
57
57
  }
58
- var J = { exports: {} }, V = {};
58
+ var L = { exports: {} }, F = {};
59
59
  /*
60
60
  object-assign
61
61
  (c) Sindre Sorhus
62
62
  @license MIT
63
63
  */
64
- var L, oe;
65
- function Ge() {
66
- if (oe) return L;
64
+ var U, oe;
65
+ function Ke() {
66
+ if (oe) return U;
67
67
  oe = 1;
68
68
  var r = Object.getOwnPropertySymbols, e = Object.prototype.hasOwnProperty, n = Object.prototype.propertyIsEnumerable;
69
69
  function t(s) {
@@ -71,19 +71,19 @@ function Ge() {
71
71
  throw new TypeError("Object.assign cannot be called with null or undefined");
72
72
  return Object(s);
73
73
  }
74
- function o() {
74
+ function i() {
75
75
  try {
76
76
  if (!Object.assign)
77
77
  return !1;
78
78
  var s = new String("abc");
79
79
  if (s[5] = "de", Object.getOwnPropertyNames(s)[0] === "5")
80
80
  return !1;
81
- for (var a = {}, u = 0; u < 10; u++)
82
- a["_" + String.fromCharCode(u)] = u;
83
- var i = Object.getOwnPropertyNames(a).map(function(c) {
81
+ for (var a = {}, o = 0; o < 10; o++)
82
+ a["_" + String.fromCharCode(o)] = o;
83
+ var u = Object.getOwnPropertyNames(a).map(function(c) {
84
84
  return a[c];
85
85
  });
86
- if (i.join("") !== "0123456789")
86
+ if (u.join("") !== "0123456789")
87
87
  return !1;
88
88
  var f = {};
89
89
  return "abcdefghijklmnopqrst".split("").forEach(function(c) {
@@ -93,19 +93,19 @@ function Ge() {
93
93
  return !1;
94
94
  }
95
95
  }
96
- return L = o() ? Object.assign : function(s, a) {
97
- for (var u, i = t(s), f, c = 1; c < arguments.length; c++) {
98
- u = Object(arguments[c]);
99
- for (var m in u)
100
- e.call(u, m) && (i[m] = u[m]);
96
+ return U = i() ? Object.assign : function(s, a) {
97
+ for (var o, u = t(s), f, c = 1; c < arguments.length; c++) {
98
+ o = Object(arguments[c]);
99
+ for (var d in o)
100
+ e.call(o, d) && (u[d] = o[d]);
101
101
  if (r) {
102
- f = r(u);
102
+ f = r(o);
103
103
  for (var l = 0; l < f.length; l++)
104
- n.call(u, f[l]) && (i[f[l]] = u[f[l]]);
104
+ n.call(o, f[l]) && (u[f[l]] = o[f[l]]);
105
105
  }
106
106
  }
107
- return i;
108
- }, L;
107
+ return u;
108
+ }, U;
109
109
  }
110
110
  /** @license React v17.0.2
111
111
  * react-jsx-runtime.production.min.js
@@ -116,38 +116,38 @@ function Ge() {
116
116
  * LICENSE file in the root directory of this source tree.
117
117
  */
118
118
  var ue;
119
- function Ke() {
120
- if (ue) return V;
121
- ue = 1, Ge();
122
- var r = Fe, e = 60103;
123
- if (V.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
119
+ function Qe() {
120
+ if (ue) return F;
121
+ ue = 1, Ke();
122
+ var r = Pe, e = 60103;
123
+ if (F.Fragment = 60107, typeof Symbol == "function" && Symbol.for) {
124
124
  var n = Symbol.for;
125
- e = n("react.element"), V.Fragment = n("react.fragment");
125
+ e = n("react.element"), F.Fragment = n("react.fragment");
126
126
  }
127
- var t = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = Object.prototype.hasOwnProperty, s = { key: !0, ref: !0, __self: !0, __source: !0 };
128
- function a(u, i, f) {
129
- var c, m = {}, l = null, h = null;
130
- f !== void 0 && (l = "" + f), i.key !== void 0 && (l = "" + i.key), i.ref !== void 0 && (h = i.ref);
131
- for (c in i) o.call(i, c) && !s.hasOwnProperty(c) && (m[c] = i[c]);
132
- if (u && u.defaultProps) for (c in i = u.defaultProps, i) m[c] === void 0 && (m[c] = i[c]);
133
- return { $$typeof: e, type: u, key: l, ref: h, props: m, _owner: t.current };
127
+ var t = r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, i = Object.prototype.hasOwnProperty, s = { key: !0, ref: !0, __self: !0, __source: !0 };
128
+ function a(o, u, f) {
129
+ var c, d = {}, l = null, p = null;
130
+ f !== void 0 && (l = "" + f), u.key !== void 0 && (l = "" + u.key), u.ref !== void 0 && (p = u.ref);
131
+ for (c in u) i.call(u, c) && !s.hasOwnProperty(c) && (d[c] = u[c]);
132
+ if (o && o.defaultProps) for (c in u = o.defaultProps, u) d[c] === void 0 && (d[c] = u[c]);
133
+ return { $$typeof: e, type: o, key: l, ref: p, props: d, _owner: t.current };
134
134
  }
135
- return V.jsx = a, V.jsxs = a, V;
135
+ return F.jsx = a, F.jsxs = a, F;
136
136
  }
137
- var ie;
138
- function Qe() {
139
- return ie || (ie = 1, J.exports = Ke()), J.exports;
137
+ var ce;
138
+ function Xe() {
139
+ return ce || (ce = 1, L.exports = Qe()), L.exports;
140
140
  }
141
- var p = Qe();
142
- const ve = Pe({});
143
- function Xe({
141
+ var h = Xe();
142
+ const Ce = qe({});
143
+ function Ye({
144
144
  children: r,
145
145
  metadata: e,
146
146
  inputErrorHandler: n,
147
147
  readonly: t
148
148
  }) {
149
- return /* @__PURE__ */ p.jsx(
150
- ve.Provider,
149
+ return /* @__PURE__ */ h.jsx(
150
+ Ce.Provider,
151
151
  {
152
152
  value: {
153
153
  metadata: e,
@@ -158,14 +158,14 @@ function Xe({
158
158
  }
159
159
  );
160
160
  }
161
- function Ye() {
162
- const r = qe(ve);
161
+ function ze() {
162
+ const r = Ae(Ce);
163
163
  return r || console.warn("useRootFormContext must be used within RootFormProvider"), r;
164
164
  }
165
- class ze extends Ae {
165
+ class er extends ke {
166
166
  constructor() {
167
167
  super(...arguments);
168
- D(this, "state", {
168
+ N(this, "state", {
169
169
  hasError: !1
170
170
  });
171
171
  }
@@ -175,71 +175,71 @@ class ze extends Ae {
175
175
  componentDidCatch(n, t) {
176
176
  var s, a;
177
177
  console.error(n, t);
178
- const o = new Error(
178
+ const i = new Error(
179
179
  `Form input [${this.props.inputType}] has failed at path [${this.props.path}]. Error: ${n}, Error info: ${t}`
180
180
  );
181
- (a = (s = this.props).inputErrorHandler) == null || a.call(s, o);
181
+ (a = (s = this.props).inputErrorHandler) == null || a.call(s, i);
182
182
  }
183
183
  render() {
184
- return this.state.hasError ? /* @__PURE__ */ p.jsx(p.Fragment, {}) : this.props.children;
184
+ return this.state.hasError ? /* @__PURE__ */ h.jsx(h.Fragment, {}) : this.props.children;
185
185
  }
186
186
  }
187
- const ce = ({
187
+ const fe = ({
188
188
  children: r,
189
189
  withoutWrapper: e = !1
190
- }) => e || !r ? r : /* @__PURE__ */ p.jsx("div", { children: r }), er = ke(function({
190
+ }) => e || !r ? r : /* @__PURE__ */ h.jsx("div", { children: r }), rr = De(function({
191
191
  path: e,
192
192
  factory: n,
193
193
  onUpdate: t,
194
- onChange: o,
194
+ onChange: i,
195
195
  initialValues: s,
196
196
  input: a,
197
- withoutWrapper: u = !1
197
+ withoutWrapper: o = !1
198
198
  }) {
199
- var Y, z, ee, re, te;
200
- const i = $e(), { formState: f } = i, { fixedValues: c = {} } = {}, { metadata: m, readonly: l, inputErrorHandler: h } = Ye(), y = n == null ? void 0 : n.getComponent(a.inputType), g = !!(a.isVisible || typeof a.disabled == "function" || typeof ((Y = a.validation) == null ? void 0 : Y.schema) == "function" || typeof ((z = a.warning) == null ? void 0 : z.schema) == "function"), x = !!((ee = a.warning) != null && ee.schema || (re = a.validation) != null && re.schema), E = g ? i.watch() : {}, O = x ? g ? Ze(E, a.path) : i.watch(a.path) : void 0, R = $(() => {
201
- if (!g) return {};
202
- let F = E;
203
- return c && Object.keys(c).forEach((N) => {
204
- const P = c[N];
205
- F = S(F, N, P);
206
- }), F;
207
- }, [g, E, c]), C = !a.isVisible || a.isVisible(R, m), b = l || a.readonly, _ = typeof a.disabled == "function" ? a.disabled(R, m) : a.disabled, T = (te = a.warning) == null ? void 0 : te.schema, Q = $(() => {
208
- var se, ae;
209
- if (!C || typeof T > "u") return;
210
- const F = typeof T == "function" ? T(R, m) : T, { success: N, error: P } = F.safeParse(O), ne = (ae = (se = P == null ? void 0 : P.errors) == null ? void 0 : se[0]) == null ? void 0 : ae.message;
211
- return !N && ne ? ne : void 0;
212
- }, [a.path, O, T, C, m]), X = $(
199
+ var z, ee, re, te, ne;
200
+ const u = Be(), { formState: f } = u, { fixedValues: c = {} } = {}, { metadata: d, readonly: l, inputErrorHandler: p } = ze(), g = n == null ? void 0 : n.getComponent(a.inputType), b = !!(a.isVisible || typeof a.disabled == "function" || typeof ((z = a.validation) == null ? void 0 : z.schema) == "function" || typeof ((ee = a.warning) == null ? void 0 : ee.schema) == "function"), v = !!((re = a.warning) != null && re.schema || (te = a.validation) != null && te.schema), y = b ? u.watch() : {}, S = v ? b ? Ze(y, a.path) : u.watch(a.path) : void 0, _ = B(() => {
201
+ if (!b) return {};
202
+ let P = y;
203
+ return c && Object.keys(c).forEach(($) => {
204
+ const q = c[$];
205
+ P = O(P, $, q);
206
+ }), P;
207
+ }, [b, y, c]), j = !a.isVisible || a.isVisible(_, d), T = l || a.readonly, I = typeof a.disabled == "function" ? a.disabled(_, d) : a.disabled, E = (ne = a.warning) == null ? void 0 : ne.schema, X = B(() => {
208
+ var ae, ie;
209
+ if (!j || typeof E > "u") return;
210
+ const P = typeof E == "function" ? E(_, d) : E, { success: $, error: q } = P.safeParse(S), se = (ie = (ae = q == null ? void 0 : q.errors) == null ? void 0 : ae[0]) == null ? void 0 : ie.message;
211
+ return !$ && se ? se : void 0;
212
+ }, [a.path, S, E, j, d]), Y = B(
213
213
  () => ({
214
214
  path: e,
215
215
  key: e,
216
216
  initialValues: s,
217
217
  onUpdate: t,
218
- onChange: o,
218
+ onChange: i,
219
219
  factory: n,
220
- readonly: b,
220
+ readonly: T,
221
221
  input: a,
222
- disabled: _,
223
- warning: Q
222
+ disabled: I,
223
+ warning: X
224
224
  }),
225
- [n, s, a, o, t, e, b, f.errors, _, Q]
226
- ), Re = $(() => C ? /* @__PURE__ */ p.jsxs(p.Fragment, { children: [
225
+ [n, s, a, i, t, e, T, f.errors, I, X]
226
+ ), Ie = B(() => j ? /* @__PURE__ */ h.jsxs(h.Fragment, { children: [
227
227
  a.before ? a.before : null,
228
- /* @__PURE__ */ p.jsx(ze, { path: e, inputType: a.inputType, inputErrorHandler: h, children: y == null ? void 0 : y.renderComponent(X) }),
228
+ /* @__PURE__ */ h.jsx(er, { path: e, inputType: a.inputType, inputErrorHandler: p, children: g == null ? void 0 : g.renderComponent(Y) }),
229
229
  a.after ? a.after : null
230
- ] }) : null, [C, a.before, a.inputType, a.after, e, y, X, f.errors]);
231
- return y ? /* @__PURE__ */ p.jsx(ce, { withoutWrapper: u, children: Re }) : /* @__PURE__ */ p.jsx(ce, { withoutWrapper: u, children: /* @__PURE__ */ p.jsxs("p", { children: [
230
+ ] }) : null, [j, a.before, a.inputType, a.after, e, g, Y, f.errors]);
231
+ return g ? /* @__PURE__ */ h.jsx(fe, { withoutWrapper: o, children: Ie }) : /* @__PURE__ */ h.jsx(fe, { withoutWrapper: o, children: /* @__PURE__ */ h.jsxs("p", { children: [
232
232
  "Input component not found (internal type: ",
233
233
  a.inputType,
234
234
  ")"
235
235
  ] }) });
236
236
  });
237
- class _r {
237
+ class Sr {
238
238
  getType() {
239
239
  return this.internalType;
240
240
  }
241
241
  }
242
- function fe() {
242
+ function le() {
243
243
  return typeof window < "u" && "requestIdleCallback" in window ? window.requestIdleCallback : function(r, e) {
244
244
  const n = Date.now(), t = (e == null ? void 0 : e.timeout) || 1;
245
245
  return setTimeout(function() {
@@ -252,40 +252,40 @@ function fe() {
252
252
  }, t);
253
253
  };
254
254
  }
255
- function le() {
255
+ function de() {
256
256
  return typeof window < "u" && "cancelIdleCallback" in window ? window.cancelIdleCallback : clearTimeout;
257
257
  }
258
- function Or(r) {
258
+ function _r(r) {
259
259
  const {
260
260
  mode: e = "onSubmit",
261
261
  resolver: n,
262
262
  defaultValues: t,
263
- shouldFocusError: o,
263
+ shouldFocusError: i,
264
264
  // validateAfterFirstSubmit,
265
265
  onValuesChange: s,
266
266
  onValidationChange: a,
267
- onSubmit: u,
268
- onInputRenderError: i,
267
+ onSubmit: o,
268
+ onInputRenderError: u,
269
269
  // validate,
270
270
  // validateDebounceInterval,
271
271
  // validationConfig,
272
272
  metadata: f,
273
273
  children: c,
274
274
  // fixedValues
275
- autoFocusPath: m,
275
+ autoFocusPath: d,
276
276
  readonly: l
277
- } = r, h = Be({
277
+ } = r, p = We({
278
278
  mode: e,
279
279
  reValidateMode: "onChange",
280
280
  defaultValues: t,
281
- shouldFocusError: o,
281
+ shouldFocusError: i,
282
282
  resolver: n
283
- }), y = w(!1), g = w(JSON.stringify(t ?? {}));
284
- I(() => {
285
- g.current = JSON.stringify(t ?? {}), h.reset(t, {});
286
- }, [h.reset, t]), I(() => {
287
- const b = fe(), _ = le(), T = b(() => {
288
- h.reset({}, {
283
+ }), g = V(!1), b = V(JSON.stringify(t ?? {}));
284
+ w(() => {
285
+ b.current = JSON.stringify(t ?? {}), p.reset(t, {});
286
+ }, [p.reset, t]), w(() => {
287
+ const T = le(), I = de(), E = T(() => {
288
+ p.reset({}, {
289
289
  keepErrors: !0,
290
290
  keepDirty: !0,
291
291
  keepDirtyValues: !0,
@@ -298,80 +298,80 @@ function Or(r) {
298
298
  keepSubmitCount: !0
299
299
  });
300
300
  });
301
- return () => _(T);
301
+ return () => I(E);
302
302
  }, []);
303
- const { handleSubmit: x } = h, E = w(s);
304
- I(() => {
305
- E.current = s;
303
+ const { handleSubmit: v } = p, y = V(s);
304
+ w(() => {
305
+ y.current = s;
306
306
  }, [s]);
307
- const O = w(a);
308
- I(() => {
309
- O.current = a;
307
+ const S = V(a);
308
+ w(() => {
309
+ S.current = a;
310
310
  }, [a]);
311
- const R = w(!1);
312
- I(() => {
313
- const b = h.watch((_) => {
314
- var T;
315
- R.current || JSON.stringify(_ ?? {}) !== g.current && ((T = E.current) == null || T.call(E, { ..._ }), y.current === !0 && (R.current = !0, h.trigger().finally(() => {
316
- R.current = !1;
311
+ const _ = V(!1);
312
+ w(() => {
313
+ const T = p.watch((I) => {
314
+ var E;
315
+ _.current || JSON.stringify(I ?? {}) !== b.current && ((E = y.current) == null || E.call(y, { ...I }), g.current === !0 && (_.current = !0, p.trigger().finally(() => {
316
+ _.current = !1;
317
317
  })));
318
318
  });
319
319
  return () => {
320
- b.unsubscribe();
320
+ T.unsubscribe();
321
321
  };
322
- }, [h]);
323
- const C = w(!0);
324
- return I(() => {
325
- var b;
326
- if (C.current) {
327
- C.current = !1;
322
+ }, [p]);
323
+ const j = V(!0);
324
+ return w(() => {
325
+ var T;
326
+ if (j.current) {
327
+ j.current = !1;
328
328
  return;
329
329
  }
330
- (b = O.current) == null || b.call(O, { isValid: h.formState.isValid, isSubmitted: h.formState.isSubmitted });
331
- }, [h.formState.isValid, h.formState.isSubmitted]), I(() => {
332
- if (m) {
333
- const b = fe(), _ = le(), T = b(() => {
334
- h.setFocus(m);
330
+ (T = S.current) == null || T.call(S, { isValid: p.formState.isValid, isSubmitted: p.formState.isSubmitted });
331
+ }, [p.formState.isValid, p.formState.isSubmitted]), w(() => {
332
+ if (d) {
333
+ const T = le(), I = de(), E = T(() => {
334
+ p.setFocus(d);
335
335
  });
336
- return () => _(T);
336
+ return () => I(E);
337
337
  }
338
- }, [h, m]), /* @__PURE__ */ p.jsx(Xe, { metadata: f, readonly: l, inputErrorHandler: i, children: /* @__PURE__ */ p.jsx(We, { ...h, children: typeof c == "function" ? c({
339
- ...h,
338
+ }, [p, d]), /* @__PURE__ */ h.jsx(Ye, { metadata: f, readonly: l, inputErrorHandler: u, children: /* @__PURE__ */ h.jsx(Je, { ...p, children: typeof c == "function" ? c({
339
+ ...p,
340
340
  submitForm: async () => {
341
- u && (y.current = !0, x((b) => {
342
- u(b);
341
+ o && (g.current = !0, v((T) => {
342
+ o(T);
343
343
  })());
344
344
  }
345
345
  }) : c }) });
346
346
  }
347
- const Rr = (r) => {
347
+ const Ir = (r) => {
348
348
  const e = {}, n = (t) => {
349
- t.forEach((o) => {
350
- const { path: s, default: a, inputs: u } = o;
351
- Array.isArray(u) ? n(u) : v(e, s) === void 0 && S(e, s, a);
349
+ t.forEach((i) => {
350
+ const { path: s, default: a, inputs: o } = i;
351
+ Array.isArray(o) ? n(o) : C(e, s) === void 0 && O(e, s, a);
352
352
  });
353
353
  };
354
354
  return Array.isArray(r.inputs) && n(r.inputs), e;
355
355
  };
356
- function Cr(r, e) {
356
+ function Rr(r, e) {
357
357
  const n = r.inputs.map((t) => {
358
- const o = rr(e, t.path);
359
- return o || t;
358
+ const i = tr(e, t.path);
359
+ return i || t;
360
360
  });
361
361
  return { ...r, inputs: n };
362
362
  }
363
- function rr(r, e) {
363
+ function tr(r, e) {
364
364
  return r.inputs.find((n) => n.path === e);
365
365
  }
366
- const Te = "__temp_", Ir = (r) => Te + r.split(".").join("__");
367
- function tr(r) {
366
+ const Te = "__temp_", jr = (r) => Te + r.split(".").join("__");
367
+ function nr(r) {
368
368
  const e = { ...r };
369
- return me(e, (n, t) => {
369
+ return pe(e, (n, t) => {
370
370
  t.startsWith(Te) && delete e[t];
371
371
  }), e;
372
372
  }
373
- const nr = "Required field";
374
- function q(r) {
373
+ const sr = "Required field";
374
+ function k(r) {
375
375
  let e;
376
376
  if (typeof r == "string")
377
377
  try {
@@ -383,74 +383,74 @@ function q(r) {
383
383
  e = r;
384
384
  if (typeof e == "string")
385
385
  return e;
386
- if (j(e))
387
- return q(e[0]);
386
+ if (x(e))
387
+ return k(e[0]);
388
388
  const n = e;
389
389
  return he(n) && (n != null && n.message) ? e == null ? void 0 : e.message : "Unknown error";
390
390
  }
391
- function sr(r, e, n) {
391
+ function ar(r, e, n) {
392
392
  let t = {};
393
393
  if (Z(t, r.inputs, e, n), n != null && n.prefix) {
394
394
  const s = n == null ? void 0 : n.prefix.replace(/.$/, "");
395
- t = S({}, s, t);
395
+ t = O({}, s, t);
396
396
  }
397
- return d.object(A(t, e, n));
397
+ return m.object(D(t, e, n));
398
398
  }
399
- function ar(r, e, n) {
400
- const t = Object.keys(r).filter((a) => /^\d+$/.test(a) && !a.startsWith("_")).map((a) => parseInt(a, 10)).sort((a, u) => a - u);
399
+ function ir(r, e, n) {
400
+ const t = Object.keys(r).filter((a) => /^\d+$/.test(a) && !a.startsWith("_")).map((a) => parseInt(a, 10)).sort((a, o) => a - o);
401
401
  if (t.length === 0) return null;
402
- const o = Math.max(...t), s = [];
403
- for (let a = 0; a <= o; a++)
402
+ const i = Math.max(...t), s = [];
403
+ for (let a = 0; a <= i; a++)
404
404
  if (t.includes(a)) {
405
- const u = r[a], i = A({ item: u }, e, n);
406
- s.push(i.item || d.any().optional());
405
+ const o = r[a], u = D({ item: o }, e, n);
406
+ s.push(u.item || m.any().optional());
407
407
  } else
408
- s.push(d.any().optional());
409
- return d.tuple(s).rest(d.any()).optional();
408
+ s.push(m.any().optional());
409
+ return m.tuple(s).rest(m.any()).optional();
410
410
  }
411
- function A(r, e, n) {
411
+ function D(r, e, n) {
412
412
  const t = {};
413
- return Object.keys(r).forEach((o) => {
413
+ return Object.keys(r).forEach((i) => {
414
414
  const {
415
415
  _requiredOnly: s,
416
416
  _schemaObj: a,
417
- _input: u,
418
- _isList: i,
417
+ _input: o,
418
+ _isList: u,
419
419
  _isArrayItem: f,
420
420
  _isTuple: c,
421
- _schema: m
421
+ _schema: d
422
422
  /*...nestedSchemaObj*/
423
- } = r[o];
424
- if (c && !i && !f) {
425
- const l = ar(r[o], e, n);
423
+ } = r[i];
424
+ if (c && !u && !f) {
425
+ const l = ir(r[i], e, n);
426
426
  if (l) {
427
- t[o] = l;
427
+ t[i] = l;
428
428
  return;
429
429
  }
430
430
  }
431
- if (i && a && u) {
432
- const l = d.object(A(a, e, n)), h = d.union([
433
- d.array(l).optional(),
434
- Ee(u, n)
435
- ]), y = de(m, u, e, n, h);
436
- t[o] = y;
437
- } else if (f && u) {
438
- const l = a != null && a.___array ? A({ ___array: a.___array }, e, n) : { ___array: d.any() }, h = or(l, u, n), y = de(m, u, e, n, h);
439
- t[o] = y;
440
- } else if (m && u) {
441
- const l = ur(m, u, e, n);
442
- t[o] = l;
443
- } else s && u ? t[o] = G(u, n) : t[o] = d.object(A(r[o], e, n)).optional();
431
+ if (u && a && o) {
432
+ const l = m.object(D(a, e, n)), p = m.union([
433
+ m.array(l).optional(),
434
+ Ee(o, n)
435
+ ]), g = me(d, o, e, n, p);
436
+ t[i] = g;
437
+ } else if (f && o) {
438
+ const l = a != null && a.___array ? D({ ___array: a.___array }, e, n) : { ___array: m.any() }, p = or(l, o, n), g = me(d, o, e, n, p);
439
+ t[i] = g;
440
+ } else if (d && o) {
441
+ const l = ur(d, o, e, n);
442
+ t[i] = l;
443
+ } else s && o ? t[i] = K(o, n) : t[i] = m.object(D(r[i], e, n)).optional();
444
444
  }), t;
445
445
  }
446
446
  function Ee(r, e) {
447
- return d.string().superRefine((n, t) => {
448
- var o;
449
- if ((o = e == null ? void 0 : e.validationConfig) != null && o.globalValidation) {
447
+ return m.string().superRefine((n, t) => {
448
+ var i;
449
+ if ((i = e == null ? void 0 : e.validationConfig) != null && i.globalValidation) {
450
450
  const s = e.validationConfig.globalValidation(n, r, e.metadata);
451
451
  if (s.error)
452
452
  return t.addIssue({
453
- code: d.ZodIssueCode.custom,
453
+ code: m.ZodIssueCode.custom,
454
454
  message: s.error
455
455
  }), !1;
456
456
  if (!s.continue)
@@ -460,115 +460,115 @@ function Ee(r, e) {
460
460
  });
461
461
  }
462
462
  function or(r, e, n) {
463
- return d.union([d.array(r.___array).optional(), Ee(e, n)]);
463
+ return m.union([m.array(r.___array).optional(), Ee(e, n)]);
464
464
  }
465
465
  function ur(r, e, n, t) {
466
- return d.any().optional().superRefine(async (o, s) => {
467
- var u, i;
468
- if (e.required && !(await G(e, t).safeParseAsync(o)).success)
466
+ return m.any().optional().superRefine(async (i, s) => {
467
+ var o, u;
468
+ if (e.required && !(await K(e, t).safeParseAsync(i)).success)
469
469
  return s.addIssue({
470
- code: d.ZodIssueCode.custom,
471
- message: U(e, t)
472
- }), d.NEVER;
473
- if ((u = t == null ? void 0 : t.validationConfig) != null && u.globalValidation) {
474
- const f = (i = t == null ? void 0 : t.validationConfig) == null ? void 0 : i.globalValidation(o, e, t.metadata);
470
+ code: m.ZodIssueCode.custom,
471
+ message: H(e, t)
472
+ }), m.NEVER;
473
+ if ((o = t == null ? void 0 : t.validationConfig) != null && o.globalValidation) {
474
+ const f = (u = t == null ? void 0 : t.validationConfig) == null ? void 0 : u.globalValidation(i, e, t.metadata);
475
475
  if (f.error)
476
476
  return s.addIssue({
477
- code: d.ZodIssueCode.custom,
477
+ code: m.ZodIssueCode.custom,
478
478
  message: f.error
479
- }), d.NEVER;
479
+ }), m.NEVER;
480
480
  if (!f.continue)
481
481
  return !0;
482
482
  }
483
- const a = Se(r, n);
483
+ const a = Oe(r, n);
484
484
  if (a) {
485
- const f = await a.safeParseAsync(o);
485
+ const f = await a.safeParseAsync(i);
486
486
  if (!f.success) {
487
- const c = q(f == null ? void 0 : f.error.message), m = c === "Required" ? U(e, t) : c;
487
+ const c = k(f == null ? void 0 : f.error.message), d = c === "Required" ? H(e, t) : c;
488
488
  s.addIssue({
489
- code: d.ZodIssueCode.custom,
490
- message: m
489
+ code: m.ZodIssueCode.custom,
490
+ message: d
491
491
  });
492
492
  }
493
493
  }
494
494
  });
495
495
  }
496
- function de(r, e, n, t, o) {
497
- return d.any().optional().superRefine(async (s, a) => {
498
- var c, m;
499
- const i = await G(e, t).safeParseAsync(s);
500
- if (e.required && !i.success) {
501
- const l = q(i.error.message);
502
- return a.addIssue({ code: d.ZodIssueCode.custom, message: l, fatal: !0 }), d.NEVER;
496
+ function me(r, e, n, t, i) {
497
+ return m.any().optional().superRefine(async (s, a) => {
498
+ var c, d;
499
+ const u = await K(e, t).safeParseAsync(s);
500
+ if (e.required && !u.success) {
501
+ const l = k(u.error.message);
502
+ return a.addIssue({ code: m.ZodIssueCode.custom, message: l, fatal: !0 }), m.NEVER;
503
503
  }
504
- if (!e.required && !i.success)
505
- return d.NEVER;
504
+ if (!e.required && !u.success)
505
+ return m.NEVER;
506
506
  if ((c = t == null ? void 0 : t.validationConfig) != null && c.globalValidation) {
507
- const l = (m = t == null ? void 0 : t.validationConfig) == null ? void 0 : m.globalValidation(s, e, t.metadata);
507
+ const l = (d = t == null ? void 0 : t.validationConfig) == null ? void 0 : d.globalValidation(s, e, t.metadata);
508
508
  if (l.error)
509
509
  return a.addIssue({
510
- code: d.ZodIssueCode.custom,
511
- message: q(l.error)
512
- }), d.NEVER;
510
+ code: m.ZodIssueCode.custom,
511
+ message: k(l.error)
512
+ }), m.NEVER;
513
513
  if (!l.continue)
514
514
  return !0;
515
515
  }
516
- if (!j(s))
516
+ if (!x(s))
517
517
  return a.addIssue({
518
- code: d.ZodIssueCode.custom,
518
+ code: m.ZodIssueCode.custom,
519
519
  message: "'Value is not array'"
520
- }), d.NEVER;
521
- const f = Se(r, n);
520
+ }), m.NEVER;
521
+ const f = Oe(r, n);
522
522
  if (f) {
523
523
  const l = await f.safeParseAsync(s);
524
524
  if (!l.success)
525
525
  return a.addIssue({
526
- code: d.ZodIssueCode.custom,
527
- message: q(l.error.message)
528
- }), d.NEVER;
526
+ code: m.ZodIssueCode.custom,
527
+ message: k(l.error.message)
528
+ }), m.NEVER;
529
529
  }
530
- }).pipe(o ?? d.any());
530
+ }).pipe(i ?? m.any());
531
531
  }
532
- function Z(r, e, n, t, o) {
532
+ function Z(r, e, n, t, i) {
533
533
  e.forEach((s) => {
534
- var u, i, f, c, m, l, h;
534
+ var o, u, f, c, d, l, p;
535
535
  const a = n;
536
- if (!s.isVisible || (u = s.isVisible) != null && u.call(s, a, t == null ? void 0 : t.metadata)) {
537
- const y = v(r, s.path);
538
- if ((i = s.validation) != null && i.schema ? S(
536
+ if (!s.isVisible || (o = s.isVisible) != null && o.call(s, a, t == null ? void 0 : t.metadata)) {
537
+ const g = C(r, s.path);
538
+ if ((u = s.validation) != null && u.schema ? O(
539
539
  r,
540
540
  s.path,
541
- M(y, {
541
+ A(g, {
542
542
  _schema: (f = s.validation) == null ? void 0 : f.schema,
543
543
  _input: s
544
544
  })
545
- ) : s.required && S(r, s.path, M(y, { _requiredOnly: !0, _input: s })), s.inputs && Z(r, s.inputs, n, t), s.inputType === "list") {
546
- const g = {};
545
+ ) : s.required && O(r, s.path, A(g, { _requiredOnly: !0, _input: s })), s.inputs && Z(r, s.inputs, n, t), s.inputType === "list") {
546
+ const b = {};
547
547
  Z(
548
- g,
549
- (m = (c = s.inputConfig) == null ? void 0 : c.inputs) == null ? void 0 : m.map((E) => ({
550
- ...E,
551
- path: E.relativePath
548
+ b,
549
+ (d = (c = s.inputConfig) == null ? void 0 : c.inputs) == null ? void 0 : d.map((y) => ({
550
+ ...y,
551
+ path: y.relativePath
552
552
  })),
553
553
  n,
554
554
  t
555
555
  );
556
- const x = v(r, s.path);
557
- S(r, s.path, M(x, { _schemaObj: g, _isList: !0, _input: s }));
556
+ const v = C(r, s.path);
557
+ O(r, s.path, A(v, { _schemaObj: b, _isList: !0, _input: s }));
558
558
  }
559
559
  if (!((l = s.validation) != null && l.schema) && s.inputType === "array") {
560
- const g = {};
560
+ const b = {};
561
561
  Z(
562
- g,
562
+ b,
563
563
  [{ ...s.inputConfig.input, path: "___array" }],
564
564
  n,
565
565
  t
566
- ), S(
566
+ ), O(
567
567
  r,
568
568
  s.path,
569
- M(y, {
570
- _schemaObj: g,
571
- _schema: (h = s.validation) == null ? void 0 : h.schema,
569
+ A(g, {
570
+ _schemaObj: b,
571
+ _schema: (p = s.validation) == null ? void 0 : p.schema,
572
572
  _isArrayItem: !0,
573
573
  _input: s
574
574
  })
@@ -576,67 +576,67 @@ function Z(r, e, n, t, o) {
576
576
  }
577
577
  }
578
578
  }), e.forEach((s) => {
579
- var u;
579
+ var o;
580
580
  const a = n;
581
- if ((!s.isVisible || (u = s.isVisible) != null && u.call(s, a, t == null ? void 0 : t.metadata)) && s.path) {
582
- const i = s.path.split(".");
583
- i.forEach((f, c) => {
581
+ if ((!s.isVisible || (o = s.isVisible) != null && o.call(s, a, t == null ? void 0 : t.metadata)) && s.path) {
582
+ const u = s.path.split(".");
583
+ u.forEach((f, c) => {
584
584
  if (c > 0 && /^\d+$/.test(f)) {
585
- const m = i.slice(0, c).join("."), l = m ? v(r, m) : r;
585
+ const d = u.slice(0, c).join("."), l = d ? C(r, d) : r;
586
586
  l && typeof l == "object" && (l._isTuple = !0);
587
587
  }
588
588
  });
589
589
  }
590
590
  });
591
591
  }
592
- function U(r, e) {
593
- var n, t, o;
594
- return ((t = (n = e == null ? void 0 : e.validationConfig) == null ? void 0 : n.requiredMessagePerInput) == null ? void 0 : t[r.inputType]) ?? ((o = e == null ? void 0 : e.validationConfig) == null ? void 0 : o.requiredMessage) ?? nr;
592
+ function H(r, e) {
593
+ var n, t, i;
594
+ return ((t = (n = e == null ? void 0 : e.validationConfig) == null ? void 0 : n.requiredMessagePerInput) == null ? void 0 : t[r.inputType]) ?? ((i = e == null ? void 0 : e.validationConfig) == null ? void 0 : i.requiredMessage) ?? sr;
595
595
  }
596
- function G(r, e) {
597
- var t, o, s, a, u, i;
598
- if ((o = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && o[r.inputType])
596
+ function K(r, e) {
597
+ var t, i, s, a, o, u;
598
+ if ((i = (t = e == null ? void 0 : e.validationConfig) == null ? void 0 : t.requiredSchemaPerInput) != null && i[r.inputType])
599
599
  return (a = (s = e == null ? void 0 : e.validationConfig) == null ? void 0 : s.requiredSchemaPerInput) == null ? void 0 : a[r.inputType];
600
- if ((u = e == null ? void 0 : e.validationConfig) != null && u.requiredSchema)
601
- return (i = e == null ? void 0 : e.validationConfig) == null ? void 0 : i.requiredSchema;
602
- const n = U(r, e);
603
- return d.any().optional().superRefine((f, c) => {
604
- typeof f == "object" && k(f) && c.addIssue({
605
- code: d.ZodIssueCode.custom,
600
+ if ((o = e == null ? void 0 : e.validationConfig) != null && o.requiredSchema)
601
+ return (u = e == null ? void 0 : e.validationConfig) == null ? void 0 : u.requiredSchema;
602
+ const n = H(r, e);
603
+ return m.any().optional().superRefine((f, c) => {
604
+ typeof f == "object" && M(f) && c.addIssue({
605
+ code: m.ZodIssueCode.custom,
606
606
  message: n
607
- }), (W(f) || f === "") && c.addIssue({
608
- code: d.ZodIssueCode.custom,
607
+ }), (J(f) || f === "") && c.addIssue({
608
+ code: m.ZodIssueCode.custom,
609
609
  message: n
610
610
  });
611
611
  });
612
612
  }
613
- function Se(r, e) {
614
- if (r instanceof d.ZodType)
613
+ function Oe(r, e) {
614
+ if (r instanceof m.ZodType)
615
615
  return r;
616
616
  if (typeof r == "function")
617
617
  return r(e);
618
618
  }
619
- const ir = (r) => Array.isArray(r == null ? void 0 : r.errors), cr = (r, e) => {
619
+ const cr = (r) => Array.isArray(r == null ? void 0 : r.errors), fr = (r, e) => {
620
620
  const n = {};
621
621
  for (; r.length; ) {
622
- const t = r[0], { code: o, message: s, path: a } = t, u = a.join(".");
623
- if (!n[u])
622
+ const t = r[0], { code: i, message: s, path: a } = t, o = a.join(".");
623
+ if (!n[o])
624
624
  if ("unionErrors" in t) {
625
- const i = t.unionErrors[0].errors[0];
626
- n[u] = {
627
- message: i.message,
628
- type: i.code
625
+ const u = t.unionErrors[0].errors[0];
626
+ n[o] = {
627
+ message: u.message,
628
+ type: u.code
629
629
  };
630
630
  } else
631
- n[u] = { message: s, type: o };
632
- "unionErrors" in t && t.unionErrors.forEach((i) => i.errors.forEach((f) => r.push(f)));
631
+ n[o] = { message: s, type: i };
632
+ "unionErrors" in t && t.unionErrors.forEach((u) => u.errors.forEach((f) => r.push(f)));
633
633
  {
634
- const i = n[u].types, f = i && i[t.code];
635
- n[u] = Je(
636
- u,
634
+ const u = n[o].types, f = u && u[t.code];
635
+ n[o] = Le(
636
+ o,
637
637
  e,
638
638
  n,
639
- o,
639
+ i,
640
640
  f ? [].concat(f, t.message) : t.message
641
641
  );
642
642
  }
@@ -645,18 +645,18 @@ const ir = (r) => Array.isArray(r == null ? void 0 : r.errors), cr = (r, e) => {
645
645
  return n;
646
646
  };
647
647
  function wr(r, e) {
648
- return Ne(
649
- async (n, t, o) => {
648
+ return Me(
649
+ async (n, t, i) => {
650
650
  try {
651
- return await sr(r, n, e).parseAsync(n), {
651
+ return await ar(r, n, e).parseAsync(n), {
652
652
  values: n,
653
653
  errors: {}
654
654
  };
655
655
  } catch (s) {
656
- if (ir(s))
656
+ if (cr(s))
657
657
  return {
658
658
  values: {},
659
- errors: Ue(cr(s.errors, !0), o)
659
+ errors: He(fr(s.errors, !0), i)
660
660
  };
661
661
  throw s;
662
662
  }
@@ -664,90 +664,107 @@ function wr(r, e) {
664
664
  [r, e]
665
665
  );
666
666
  }
667
- function fr(r, e) {
668
- const n = B(r);
667
+ function lr(r, e) {
668
+ const n = W(r);
669
669
  return e.forEach((t) => {
670
- t.inputTransform && (j(t.inputTransform) ? t.inputTransform : [t.inputTransform]).forEach((s) => {
671
- let a;
672
- const u = t.path.split(".");
673
- if (u.length > 1) {
674
- const f = u.slice(0, -1).join("."), c = v(n, f);
675
- typeof c == "string" || typeof c == "number" || typeof c == "boolean" ? a = void 0 : a = v(n, t.path);
670
+ if (t.inputTransform) {
671
+ const i = x(t.inputTransform) ? t.inputTransform : [t.inputTransform];
672
+ let s;
673
+ const a = t.path.split(".");
674
+ if (a.length > 1) {
675
+ const o = a.slice(0, -1).join("."), u = C(n, o);
676
+ typeof u == "string" || typeof u == "number" || typeof u == "boolean" ? s = void 0 : s = C(n, t.path);
676
677
  } else
677
- a = v(n, t.path);
678
- const i = s(a, n);
679
- i && S(n, i.path ?? t.path, i.value);
680
- });
678
+ s = C(n, t.path);
679
+ i.forEach((o) => {
680
+ const u = o(s, n);
681
+ u && (s = u.value, O(n, u.path ?? t.path, u.value));
682
+ });
683
+ }
681
684
  }), n;
682
685
  }
683
- function lr(r, e, n) {
686
+ function dr(r, e, n) {
684
687
  const t = [];
685
- let o = {};
686
- n || (o = B(r));
687
- const s = B(r);
688
+ let i = {};
689
+ n || (i = W(r));
690
+ const s = W(r);
688
691
  return e.forEach((a) => {
689
- a.outputTransform && (j(a.outputTransform) ? a.outputTransform : [a.outputTransform]).forEach((i) => {
690
- const f = v(s, a.path), c = i(f, s);
691
- c && (c.path ? (S(o, c.path, c.value), c.unset && t.push(a.path)) : S(o, a.path, c.value));
692
- });
692
+ if (a.outputTransform) {
693
+ const o = x(a.outputTransform) ? a.outputTransform : [a.outputTransform];
694
+ let u = C(s, a.path);
695
+ o.forEach((f) => {
696
+ const c = f(u, s);
697
+ if (c)
698
+ if (u = c.value, c.path) {
699
+ if (c.merge) {
700
+ const d = C(i, c.path);
701
+ let l;
702
+ d ? l = A({}, d, c.value) : l = c.value, O(i, c.path, l);
703
+ } else
704
+ O(i, c.path, c.value);
705
+ c.unset && t.push(a.path);
706
+ } else
707
+ O(i, a.path, c.value);
708
+ });
709
+ }
693
710
  }), t.forEach((a) => {
694
- pe(o, a);
695
- }), o;
711
+ ye(i, a);
712
+ }), i;
696
713
  }
697
- function K(r) {
698
- return r.reduce((n, t) => Array.isArray(t.inputs) ? [...n, t, ...K(t.inputs)] : [...n, t], []);
714
+ function Q(r) {
715
+ return r.reduce((n, t) => Array.isArray(t.inputs) ? [...n, t, ...Q(t.inputs)] : [...n, t], []);
699
716
  }
700
- const dr = (r) => {
717
+ const mr = (r) => {
701
718
  if (r !== void 0)
702
719
  return { value: r };
703
- }, mr = (r) => {
720
+ }, pr = (r) => {
704
721
  if (r !== void 0)
705
722
  return { value: r };
706
723
  };
707
- function _e(r, e) {
708
- const t = K(r.inputs).reduce((o, s) => {
709
- const a = s.inputType === "text" || s.inputType === "boolean" || s.inputType === "number" || s.inputType === "textarea" || s.inputType === "select", u = !!s.inputTransform, i = !!s.outputTransform, f = Array.isArray(s.inputs) && s.inputs.length > 0, c = s.inputType === "list" || s.inputType === "array";
710
- return u || i ? o.push({
724
+ function Se(r, e) {
725
+ const t = Q(r.inputs).reduce((i, s) => {
726
+ const a = s.inputType === "text" || s.inputType === "boolean" || s.inputType === "number" || s.inputType === "textarea" || s.inputType === "select", o = !!s.inputTransform, u = !!s.outputTransform, f = Array.isArray(s.inputs) && s.inputs.length > 0, c = s.inputType === "list" || s.inputType === "array";
727
+ return o || u ? i.push({
711
728
  path: s.path,
712
729
  inputTransform: s.inputTransform,
713
730
  outputTransform: s.outputTransform,
714
731
  level: s.path.split(".").length,
715
732
  isPrimitive: a
716
- }) : e && !(f || c) && o.push({
733
+ }) : e && !(f || c) && i.push({
717
734
  path: s.path,
718
- inputTransform: dr,
719
- outputTransform: mr,
735
+ inputTransform: mr,
736
+ outputTransform: pr,
720
737
  level: s.path.split(".").length,
721
738
  isPrimitive: a
722
- }), o;
739
+ }), i;
723
740
  }, []);
724
- return t.sort((o, s) => o.level === s.level ? o.isPrimitive ? 1 : -1 : o.level < s.level ? -1 : 1), t;
741
+ return t.sort((i, s) => i.level === s.level ? i.isPrimitive ? 1 : -1 : i.level < s.level ? -1 : 1), t;
725
742
  }
726
743
  function hr(r, e, n, t = {}) {
727
- const { preserve: o } = t, s = K(r.inputs), a = B(e);
728
- return s.forEach((u) => {
729
- o && o.includes(u.path) || u.isVisible && !u.isVisible(e, n) && pe(a, u.path);
744
+ const { preserve: i } = t, s = Q(r.inputs), a = W(e);
745
+ return s.forEach((o) => {
746
+ i && i.includes(o.path) || o.isVisible && !o.isVisible(e, n) && ye(a, o.path);
730
747
  }), a;
731
748
  }
732
- function jr(r, e) {
733
- const n = _e(e);
734
- return fr(r, n);
749
+ function Vr(r, e) {
750
+ const n = Se(e);
751
+ return lr(r, n);
735
752
  }
736
- function Vr(r, e, n, t = {}) {
737
- const o = t.cleanOutput, s = _e(e, o);
753
+ function xr(r, e, n, t = {}) {
754
+ const i = t.cleanOutput, s = Se(e, i);
738
755
  let a = hr(e, r, n, t);
739
- return a = lr(a, s, t.cleanOutput), a = tr(a), a;
756
+ return a = dr(a, s, t.cleanOutput), a = nr(a), a;
740
757
  }
741
- function xr(r) {
758
+ function Fr(r) {
742
759
  const e = {}, n = (t) => {
743
- t.forEach((o) => {
744
- const { default: s, path: a, inputs: u } = o;
745
- Array.isArray(u) ? n(u) : s !== void 0 && S(e, a, s);
760
+ t.forEach((i) => {
761
+ const { default: s, path: a, inputs: o } = i;
762
+ Array.isArray(o) ? n(o) : s !== void 0 && O(e, a, s);
746
763
  });
747
764
  };
748
765
  return Array.isArray(r.inputs) && n(r.inputs), e;
749
766
  }
750
- function Fr() {
767
+ function Pr() {
751
768
  return function(r, e) {
752
769
  if (!(typeof r > "u"))
753
770
  return !r || !we(r) ? { value: r } : {
@@ -755,188 +772,229 @@ function Fr() {
755
772
  };
756
773
  };
757
774
  }
758
- function Pr(r) {
775
+ function qr(r) {
759
776
  return function(e, n) {
760
777
  if (typeof e > "u") return;
761
- if (!e || !j(e)) return { value: e };
778
+ if (!e || !x(e)) return { value: e };
762
779
  const t = {
763
- value: e.reduce((o, s) => ({
764
- ...o,
780
+ value: e.reduce((i, s) => ({
781
+ ...i,
765
782
  [s.key]: r != null && r.assignKeyToValue ? s.key : s.value ?? (r == null ? void 0 : r.fallbackValue)
766
783
  }), {})
767
784
  };
768
785
  return r != null && r.unsetIfEmpty && Object.getOwnPropertyNames(t.value).length === 0 ? { value: void 0 } : t;
769
786
  };
770
787
  }
771
- function qr() {
788
+ function Ar() {
772
789
  return function(r, e) {
773
790
  if (!(typeof r > "u"))
774
- return j(r) && k(r) ? { value: void 0 } : { value: r };
791
+ return x(r) && M(r) ? { value: void 0 } : { value: r };
775
792
  };
776
793
  }
777
- function Ar(r) {
794
+ function kr(r) {
778
795
  return function(e, n) {
779
- const t = r ? v(n, r) : e;
796
+ const t = r ? C(n, r) : e;
780
797
  if (!(typeof t > "u")) {
781
- if (ye(t)) return { value: void 0, path: r };
798
+ if (ge(t)) return { value: void 0, path: r };
782
799
  if (he(t)) {
783
- const o = ge(t, je);
784
- if (k(o))
800
+ const i = be(t, Ve);
801
+ if (M(i))
785
802
  return { value: void 0, path: r };
786
803
  }
787
804
  return { value: t, path: r };
788
805
  }
789
806
  };
790
807
  }
791
- function kr() {
808
+ function Dr() {
792
809
  return function(r, e) {
793
810
  if (!(typeof r > "u"))
794
- return Ve(r) && k(r) ? { value: void 0 } : { value: r };
811
+ return xe(r) && M(r) ? { value: void 0 } : { value: r };
795
812
  };
796
813
  }
797
- function Nr(r) {
814
+ function Mr(r) {
798
815
  return function(e, n) {
799
- const t = v(n, r);
816
+ const t = C(n, r);
800
817
  if (typeof t == "string")
801
818
  return { value: t };
802
819
  if (!(typeof t == "number" || typeof t == "boolean") && e !== void 0)
803
820
  return { value: e };
804
821
  };
805
822
  }
806
- function Dr(r) {
823
+ function $r(r) {
807
824
  return function(e, n) {
808
825
  if (typeof e > "u") return;
809
826
  if (!e) return { value: e };
810
- const t = v(n, r);
827
+ const t = C(n, r);
811
828
  if (typeof t == "object") {
812
- const o = pr(t);
813
- if (Object.getOwnPropertyNames(o).length === 1)
829
+ const i = yr(t);
830
+ if (Object.getOwnPropertyNames(i).length === 1)
814
831
  return { value: e, path: r };
815
832
  }
816
833
  return { value: e };
817
834
  };
818
835
  }
819
- function Mr(r) {
836
+ function Nr(r) {
820
837
  return function(e, n) {
821
- const t = v(n, r);
838
+ const t = C(n, r);
822
839
  if (typeof t == "string")
823
840
  return { value: [t] };
824
841
  if (!(typeof t == "number" || typeof t == "boolean") && e !== void 0)
825
842
  return { value: e };
826
843
  };
827
844
  }
828
- function $r(r, e) {
845
+ function Br(r, e) {
829
846
  return function(n, t) {
830
847
  if (typeof n > "u") return;
831
848
  if (!n) return { value: n };
832
- const o = v(t, r);
833
- if (j(o)) {
834
- if (o.length === 1)
835
- return { value: o[0], path: r };
836
- if (o.length === 0 && e != null && e.unsetIfEmpty)
849
+ const i = C(t, r);
850
+ if (x(i)) {
851
+ if (i.length === 1)
852
+ return { value: i[0], path: r };
853
+ if (i.length === 0 && e != null && e.unsetIfEmpty)
837
854
  return { value: void 0, path: r };
838
855
  }
839
856
  return { value: n };
840
857
  };
841
858
  }
842
- function Oe(r) {
843
- return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !Oe(r[e])) : W(r);
859
+ function _e(r) {
860
+ return typeof r == "object" ? !Object.getOwnPropertyNames(r).some((e) => !_e(r[e])) : J(r);
844
861
  }
845
- function pr(r) {
846
- return ge(r, (e) => typeof e == "object" ? Oe(e) : W(e));
862
+ function yr(r) {
863
+ return be(r, (e) => typeof e == "object" ? _e(e) : J(e));
847
864
  }
848
- function H(r) {
849
- const { items: e, className: n, withoutWrapper: t = !0, ...o } = r, s = e.map((a) => /* @__PURE__ */ p.jsx(er, { input: a, path: a.path, ...o }, `${a.inputType}_${a.path}`));
850
- return t ? /* @__PURE__ */ p.jsx(p.Fragment, { children: s }) : /* @__PURE__ */ p.jsx("div", { className: n, children: s });
865
+ function G(r) {
866
+ const { items: e, className: n, withoutWrapper: t = !0, ...i } = r, s = e.map((a) => /* @__PURE__ */ h.jsx(rr, { input: a, path: a.path, ...i }, `${a.inputType}_${a.path}`));
867
+ return t ? /* @__PURE__ */ h.jsx(h.Fragment, { children: s }) : /* @__PURE__ */ h.jsx("div", { className: n, children: s });
851
868
  }
852
- H.displayName = "RenderInputs";
853
- const yr = De((r, e) => {
854
- const { inputs: n, className: t, factory: o, withoutWrapper: s } = r;
855
- return s ? /* @__PURE__ */ p.jsxs(Me, { children: [
869
+ G.displayName = "RenderInputs";
870
+ const gr = $e((r, e) => {
871
+ const { inputs: n, className: t, factory: i, withoutWrapper: s } = r;
872
+ return s ? /* @__PURE__ */ h.jsxs(Ne, { children: [
856
873
  n.hero,
857
- /* @__PURE__ */ p.jsx(H, { items: n.inputs, factory: o })
858
- ] }) : /* @__PURE__ */ p.jsxs("div", { className: t, ref: e, children: [
874
+ /* @__PURE__ */ h.jsx(G, { items: n.inputs, factory: i })
875
+ ] }) : /* @__PURE__ */ h.jsxs("div", { className: t, ref: e, children: [
859
876
  n.hero,
860
- /* @__PURE__ */ p.jsx(H, { items: n.inputs, factory: o })
877
+ /* @__PURE__ */ h.jsx(G, { items: n.inputs, factory: i })
861
878
  ] });
862
879
  });
863
- yr.displayName = "RenderForm";
880
+ gr.displayName = "RenderForm";
864
881
  function Zr(r) {
865
882
  let e = !0;
866
- return me(r, (n) => {
867
- e = e && (n === "" || ye(n) || W(n));
883
+ return pe(r, (n) => {
884
+ e = e && (n === "" || ge(n) || J(n));
868
885
  }), e;
869
886
  }
870
- const Br = (r = "") => xe(r.split("_").join(" ")), gr = (r, e = 2, n, t = 1e3) => {
871
- let o = !1;
887
+ const Wr = (r = "") => Fe(r.split("_").join(" ")), br = (r, e = 2, n, t = 1e3) => {
888
+ let i = !1;
872
889
  const s = () => {
873
890
  requestAnimationFrame(() => {
874
- o || (e -= 1, e <= 0 ? r() : s());
891
+ i || (e -= 1, e <= 0 ? r() : s());
875
892
  });
876
893
  };
877
894
  return n && Date.now() - n <= t ? (r(), () => {
878
895
  }) : (s(), () => {
879
- o = !0;
896
+ i = !0;
880
897
  });
881
898
  };
882
- function Wr(r) {
899
+ function Jr(r, e) {
900
+ return {
901
+ ...r,
902
+ inputs: r.inputs.map((n) => R(n, e))
903
+ };
904
+ }
905
+ function R(r, e) {
906
+ var u, f, c;
907
+ const { override: n, ...t } = r, i = e && n ? n[e] : void 0, { inputConfig: s, ...a } = i || {}, o = i ? { ...t, ...a } : t;
908
+ if ((t.inputConfig || s) && (o.inputConfig = { ...t.inputConfig, ...s }), o.inputs && (o.inputs = o.inputs.map((d) => R(d, e))), o.inputType === "list" && o.inputConfig) {
909
+ const d = ((u = t.inputConfig) == null ? void 0 : u.inputs) || [], l = (s == null ? void 0 : s.inputs) || [];
910
+ if (d.length > 0 || l.length > 0) {
911
+ const p = Math.max(d.length, l.length);
912
+ o.inputConfig.inputs = Array.from({ length: p }, (g, b) => {
913
+ var S;
914
+ const v = d[b], y = l[b];
915
+ if (!v && y) return R(y, e);
916
+ if (v && !y) return R(v, e);
917
+ if (v && y) {
918
+ const _ = v.override ? { ...v.override } : {};
919
+ return e && y && (_[e] = (S = v.override) != null && S[e] ? { ...v.override[e], ...y } : y), R({ ...v, override: _ }, e);
920
+ }
921
+ }).filter(Boolean);
922
+ } else o.inputConfig.inputs && (o.inputConfig.inputs = o.inputConfig.inputs.map(
923
+ (p) => R(p, e)
924
+ ));
925
+ }
926
+ if (o.inputType === "array" && o.inputConfig) {
927
+ const d = (f = t.inputConfig) == null ? void 0 : f.input, l = s == null ? void 0 : s.input;
928
+ if (d && l) {
929
+ const p = d.override ? { ...d.override } : {};
930
+ e && l && (p[e] = (c = d.override) != null && c[e] ? { ...d.override[e], ...l } : l), o.inputConfig.input = R(
931
+ { ...d, override: p },
932
+ e
933
+ );
934
+ } else o.inputConfig.input && (o.inputConfig.input = R(o.inputConfig.input, e));
935
+ }
936
+ return o;
937
+ }
938
+ function Lr(r) {
883
939
  const {
884
940
  field: { onBlur: e, ...n },
885
941
  ...t
886
- } = Le(r), o = w(Date.now());
942
+ } = Ue(r), i = V(Date.now());
887
943
  return {
888
944
  ...t,
889
945
  field: {
890
946
  ...n,
891
- onBlur: gr(e, 2, o.current)
947
+ onBlur: br(e, 2, i.current)
892
948
  }
893
949
  };
894
950
  }
895
951
  export {
896
- Ur as Controller,
897
- Hr as Form,
898
- Gr as FormProvider,
899
- _r as InputComponent,
900
- er as InputComponentRenderer,
901
- be as InputFactory,
902
- He as InputOverrideError,
903
- yr as RenderForm,
904
- H as RenderInputs,
905
- Or as RootForm,
906
- gr as afterFrames,
907
- Pr as arrayToObjectOutputTransformer,
908
- xr as collectDefaultValues,
909
- jr as convertDataToFormModel,
910
- Vr as convertFormModelToData,
911
- Br as generateReadableLabel,
912
- Kr as get,
913
- Rr as getDefaultValuesFromFormDefinition,
914
- Ir as getTemporaryPath,
915
- _e as getTransformers,
916
- sr as getValidationSchema,
917
- fr as inputTransformValues,
952
+ Gr as Controller,
953
+ Kr as Form,
954
+ Qr as FormProvider,
955
+ Sr as InputComponent,
956
+ rr as InputComponentRenderer,
957
+ ve as InputFactory,
958
+ Ge as InputOverrideError,
959
+ gr as RenderForm,
960
+ G as RenderInputs,
961
+ _r as RootForm,
962
+ br as afterFrames,
963
+ Jr as applyFormOverrides,
964
+ R as applyInputOverride,
965
+ qr as arrayToObjectOutputTransformer,
966
+ Fr as collectDefaultValues,
967
+ Vr as convertDataToFormModel,
968
+ xr as convertFormModelToData,
969
+ Wr as generateReadableLabel,
970
+ Xr as get,
971
+ Ir as getDefaultValuesFromFormDefinition,
972
+ jr as getTemporaryPath,
973
+ Se as getTransformers,
974
+ ar as getValidationSchema,
975
+ lr as inputTransformValues,
918
976
  Zr as isChildrenEmpty,
919
- Fr as objectToArrayInputTransformer,
920
- lr as outputTransformValues,
921
- Cr as overrideFormDefinition,
922
- q as processValidationParseResponse,
923
- tr as removeTemporaryFieldsValue,
924
- Qr as set,
925
- Mr as shorthandArrayInputTransformer,
926
- $r as shorthandArrayOutputTransformer,
927
- Nr as shorthandObjectInputTransformer,
928
- Dr as shorthandObjectOutputTransformer,
929
- qr as unsetEmptyArrayOutputTransformer,
930
- Ar as unsetEmptyObjectOutputTransformer,
931
- kr as unsetEmptyStringOutputTransformer,
977
+ Pr as objectToArrayInputTransformer,
978
+ dr as outputTransformValues,
979
+ Rr as overrideFormDefinition,
980
+ k as processValidationParseResponse,
981
+ nr as removeTemporaryFieldsValue,
982
+ Yr as set,
983
+ Nr as shorthandArrayInputTransformer,
984
+ Br as shorthandArrayOutputTransformer,
985
+ Mr as shorthandObjectInputTransformer,
986
+ $r as shorthandObjectOutputTransformer,
987
+ Ar as unsetEmptyArrayOutputTransformer,
988
+ kr as unsetEmptyObjectOutputTransformer,
989
+ Dr as unsetEmptyStringOutputTransformer,
932
990
  hr as unsetHiddenInputsValues,
933
- Wr as useController,
934
- Xr as useFieldArray,
935
- Yr as useForm,
936
- zr as useFormContext,
937
- et as useFormState,
938
- Ye as useRootFormContext,
939
- rt as useWatch,
991
+ Lr as useController,
992
+ zr as useFieldArray,
993
+ et as useForm,
994
+ rt as useFormContext,
995
+ tt as useFormState,
996
+ ze as useRootFormContext,
997
+ nt as useWatch,
940
998
  wr as useZodValidationResolver
941
999
  };
942
1000
  //# sourceMappingURL=index.js.map