@reverso/forms 0.1.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/README.md +58 -0
- package/dist/components/Form.d.ts +13 -0
- package/dist/components/Form.d.ts.map +1 -0
- package/dist/components/FormField.d.ts +9 -0
- package/dist/components/FormField.d.ts.map +1 -0
- package/dist/components/FormProgress.d.ts +11 -0
- package/dist/components/FormProgress.d.ts.map +1 -0
- package/dist/components/FormStep.d.ts +11 -0
- package/dist/components/FormStep.d.ts.map +1 -0
- package/dist/components/fields/CheckboxField.d.ts +6 -0
- package/dist/components/fields/CheckboxField.d.ts.map +1 -0
- package/dist/components/fields/DateField.d.ts +6 -0
- package/dist/components/fields/DateField.d.ts.map +1 -0
- package/dist/components/fields/EmailField.d.ts +6 -0
- package/dist/components/fields/EmailField.d.ts.map +1 -0
- package/dist/components/fields/FileField.d.ts +6 -0
- package/dist/components/fields/FileField.d.ts.map +1 -0
- package/dist/components/fields/HiddenField.d.ts +6 -0
- package/dist/components/fields/HiddenField.d.ts.map +1 -0
- package/dist/components/fields/NumberField.d.ts +6 -0
- package/dist/components/fields/NumberField.d.ts.map +1 -0
- package/dist/components/fields/RadioField.d.ts +6 -0
- package/dist/components/fields/RadioField.d.ts.map +1 -0
- package/dist/components/fields/SelectField.d.ts +6 -0
- package/dist/components/fields/SelectField.d.ts.map +1 -0
- package/dist/components/fields/TextField.d.ts +6 -0
- package/dist/components/fields/TextField.d.ts.map +1 -0
- package/dist/components/fields/TextareaField.d.ts +6 -0
- package/dist/components/fields/TextareaField.d.ts.map +1 -0
- package/dist/components/fields/index.d.ts +14 -0
- package/dist/components/fields/index.d.ts.map +1 -0
- package/dist/hooks/useConditionalFields.d.ts +12 -0
- package/dist/hooks/useConditionalFields.d.ts.map +1 -0
- package/dist/hooks/useReversoForm.d.ts +32 -0
- package/dist/hooks/useReversoForm.d.ts.map +1 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4959 -0
- package/dist/types.d.ts +115 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/validation/buildSchema.d.ts +17 -0
- package/dist/validation/buildSchema.d.ts.map +1 -0
- package/package.json +73 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,4959 @@
|
|
|
1
|
+
import j, { useMemo as xt, useState as Vn, useCallback as Ie } from "react";
|
|
2
|
+
var et = { exports: {} }, Be = {};
|
|
3
|
+
var Qt;
|
|
4
|
+
function Dn() {
|
|
5
|
+
if (Qt) return Be;
|
|
6
|
+
Qt = 1;
|
|
7
|
+
var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), t = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
+
function r(n, s, o) {
|
|
9
|
+
var i = null;
|
|
10
|
+
if (o !== void 0 && (i = "" + o), s.key !== void 0 && (i = "" + s.key), "key" in s) {
|
|
11
|
+
o = {};
|
|
12
|
+
for (var a in s)
|
|
13
|
+
a !== "key" && (o[a] = s[a]);
|
|
14
|
+
} else o = s;
|
|
15
|
+
return s = o.ref, {
|
|
16
|
+
$$typeof: e,
|
|
17
|
+
type: n,
|
|
18
|
+
key: i,
|
|
19
|
+
ref: s !== void 0 ? s : null,
|
|
20
|
+
props: o
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return Be.Fragment = t, Be.jsx = r, Be.jsxs = r, Be;
|
|
24
|
+
}
|
|
25
|
+
var We = {};
|
|
26
|
+
var er;
|
|
27
|
+
function Un() {
|
|
28
|
+
return er || (er = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
|
+
function e(p) {
|
|
30
|
+
if (p == null) return null;
|
|
31
|
+
if (typeof p == "function")
|
|
32
|
+
return p.$$typeof === Te ? null : p.displayName || p.name || null;
|
|
33
|
+
if (typeof p == "string") return p;
|
|
34
|
+
switch (p) {
|
|
35
|
+
case I:
|
|
36
|
+
return "Fragment";
|
|
37
|
+
case N:
|
|
38
|
+
return "Profiler";
|
|
39
|
+
case F:
|
|
40
|
+
return "StrictMode";
|
|
41
|
+
case L:
|
|
42
|
+
return "Suspense";
|
|
43
|
+
case re:
|
|
44
|
+
return "SuspenseList";
|
|
45
|
+
case le:
|
|
46
|
+
return "Activity";
|
|
47
|
+
}
|
|
48
|
+
if (typeof p == "object")
|
|
49
|
+
switch (typeof p.tag == "number" && console.error(
|
|
50
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
|
+
), p.$$typeof) {
|
|
52
|
+
case O:
|
|
53
|
+
return "Portal";
|
|
54
|
+
case z:
|
|
55
|
+
return p.displayName || "Context";
|
|
56
|
+
case P:
|
|
57
|
+
return (p._context.displayName || "Context") + ".Consumer";
|
|
58
|
+
case S:
|
|
59
|
+
var A = p.render;
|
|
60
|
+
return p = p.displayName, p || (p = A.displayName || A.name || "", p = p !== "" ? "ForwardRef(" + p + ")" : "ForwardRef"), p;
|
|
61
|
+
case ve:
|
|
62
|
+
return A = p.displayName || null, A !== null ? A : e(p.type) || "Memo";
|
|
63
|
+
case ce:
|
|
64
|
+
A = p._payload, p = p._init;
|
|
65
|
+
try {
|
|
66
|
+
return e(p(A));
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function t(p) {
|
|
73
|
+
return "" + p;
|
|
74
|
+
}
|
|
75
|
+
function r(p) {
|
|
76
|
+
try {
|
|
77
|
+
t(p);
|
|
78
|
+
var A = !1;
|
|
79
|
+
} catch {
|
|
80
|
+
A = !0;
|
|
81
|
+
}
|
|
82
|
+
if (A) {
|
|
83
|
+
A = console;
|
|
84
|
+
var M = A.error, G = typeof Symbol == "function" && Symbol.toStringTag && p[Symbol.toStringTag] || p.constructor.name || "Object";
|
|
85
|
+
return M.call(
|
|
86
|
+
A,
|
|
87
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
88
|
+
G
|
|
89
|
+
), t(p);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function n(p) {
|
|
93
|
+
if (p === I) return "<>";
|
|
94
|
+
if (typeof p == "object" && p !== null && p.$$typeof === ce)
|
|
95
|
+
return "<...>";
|
|
96
|
+
try {
|
|
97
|
+
var A = e(p);
|
|
98
|
+
return A ? "<" + A + ">" : "<...>";
|
|
99
|
+
} catch {
|
|
100
|
+
return "<...>";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function s() {
|
|
104
|
+
var p = T.A;
|
|
105
|
+
return p === null ? null : p.getOwner();
|
|
106
|
+
}
|
|
107
|
+
function o() {
|
|
108
|
+
return Error("react-stack-top-frame");
|
|
109
|
+
}
|
|
110
|
+
function i(p) {
|
|
111
|
+
if (R.call(p, "key")) {
|
|
112
|
+
var A = Object.getOwnPropertyDescriptor(p, "key").get;
|
|
113
|
+
if (A && A.isReactWarning) return !1;
|
|
114
|
+
}
|
|
115
|
+
return p.key !== void 0;
|
|
116
|
+
}
|
|
117
|
+
function a(p, A) {
|
|
118
|
+
function M() {
|
|
119
|
+
fe || (fe = !0, console.error(
|
|
120
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
121
|
+
A
|
|
122
|
+
));
|
|
123
|
+
}
|
|
124
|
+
M.isReactWarning = !0, Object.defineProperty(p, "key", {
|
|
125
|
+
get: M,
|
|
126
|
+
configurable: !0
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
function c() {
|
|
130
|
+
var p = e(this.type);
|
|
131
|
+
return se[p] || (se[p] = !0, console.error(
|
|
132
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
133
|
+
)), p = this.props.ref, p !== void 0 ? p : null;
|
|
134
|
+
}
|
|
135
|
+
function f(p, A, M, G, Fe, Pe) {
|
|
136
|
+
var K = M.ref;
|
|
137
|
+
return p = {
|
|
138
|
+
$$typeof: Z,
|
|
139
|
+
type: p,
|
|
140
|
+
key: A,
|
|
141
|
+
props: M,
|
|
142
|
+
_owner: G
|
|
143
|
+
}, (K !== void 0 ? K : null) !== null ? Object.defineProperty(p, "ref", {
|
|
144
|
+
enumerable: !1,
|
|
145
|
+
get: c
|
|
146
|
+
}) : Object.defineProperty(p, "ref", { enumerable: !1, value: null }), p._store = {}, Object.defineProperty(p._store, "validated", {
|
|
147
|
+
configurable: !1,
|
|
148
|
+
enumerable: !1,
|
|
149
|
+
writable: !0,
|
|
150
|
+
value: 0
|
|
151
|
+
}), Object.defineProperty(p, "_debugInfo", {
|
|
152
|
+
configurable: !1,
|
|
153
|
+
enumerable: !1,
|
|
154
|
+
writable: !0,
|
|
155
|
+
value: null
|
|
156
|
+
}), Object.defineProperty(p, "_debugStack", {
|
|
157
|
+
configurable: !1,
|
|
158
|
+
enumerable: !1,
|
|
159
|
+
writable: !0,
|
|
160
|
+
value: Fe
|
|
161
|
+
}), Object.defineProperty(p, "_debugTask", {
|
|
162
|
+
configurable: !1,
|
|
163
|
+
enumerable: !1,
|
|
164
|
+
writable: !0,
|
|
165
|
+
value: Pe
|
|
166
|
+
}), Object.freeze && (Object.freeze(p.props), Object.freeze(p)), p;
|
|
167
|
+
}
|
|
168
|
+
function _(p, A, M, G, Fe, Pe) {
|
|
169
|
+
var K = A.children;
|
|
170
|
+
if (K !== void 0)
|
|
171
|
+
if (G)
|
|
172
|
+
if (H(K)) {
|
|
173
|
+
for (G = 0; G < K.length; G++)
|
|
174
|
+
g(K[G]);
|
|
175
|
+
Object.freeze && Object.freeze(K);
|
|
176
|
+
} else
|
|
177
|
+
console.error(
|
|
178
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
|
+
);
|
|
180
|
+
else g(K);
|
|
181
|
+
if (R.call(A, "key")) {
|
|
182
|
+
K = e(p);
|
|
183
|
+
var be = Object.keys(A).filter(function(Je) {
|
|
184
|
+
return Je !== "key";
|
|
185
|
+
});
|
|
186
|
+
G = 0 < be.length ? "{key: someKey, " + be.join(": ..., ") + ": ...}" : "{key: someKey}", Se[K + G] || (be = 0 < be.length ? "{" + be.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
188
|
+
let props = %s;
|
|
189
|
+
<%s {...props} />
|
|
190
|
+
React keys must be passed directly to JSX without using spread:
|
|
191
|
+
let props = %s;
|
|
192
|
+
<%s key={someKey} {...props} />`,
|
|
193
|
+
G,
|
|
194
|
+
K,
|
|
195
|
+
be,
|
|
196
|
+
K
|
|
197
|
+
), Se[K + G] = !0);
|
|
198
|
+
}
|
|
199
|
+
if (K = null, M !== void 0 && (r(M), K = "" + M), i(A) && (r(A.key), K = "" + A.key), "key" in A) {
|
|
200
|
+
M = {};
|
|
201
|
+
for (var Re in A)
|
|
202
|
+
Re !== "key" && (M[Re] = A[Re]);
|
|
203
|
+
} else M = A;
|
|
204
|
+
return K && a(
|
|
205
|
+
M,
|
|
206
|
+
typeof p == "function" ? p.displayName || p.name || "Unknown" : p
|
|
207
|
+
), f(
|
|
208
|
+
p,
|
|
209
|
+
K,
|
|
210
|
+
M,
|
|
211
|
+
s(),
|
|
212
|
+
Fe,
|
|
213
|
+
Pe
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
function g(p) {
|
|
217
|
+
b(p) ? p._store && (p._store.validated = 1) : typeof p == "object" && p !== null && p.$$typeof === ce && (p._payload.status === "fulfilled" ? b(p._payload.value) && p._payload.value._store && (p._payload.value._store.validated = 1) : p._store && (p._store.validated = 1));
|
|
218
|
+
}
|
|
219
|
+
function b(p) {
|
|
220
|
+
return typeof p == "object" && p !== null && p.$$typeof === Z;
|
|
221
|
+
}
|
|
222
|
+
var v = j, Z = /* @__PURE__ */ Symbol.for("react.transitional.element"), O = /* @__PURE__ */ Symbol.for("react.portal"), I = /* @__PURE__ */ Symbol.for("react.fragment"), F = /* @__PURE__ */ Symbol.for("react.strict_mode"), N = /* @__PURE__ */ Symbol.for("react.profiler"), P = /* @__PURE__ */ Symbol.for("react.consumer"), z = /* @__PURE__ */ Symbol.for("react.context"), S = /* @__PURE__ */ Symbol.for("react.forward_ref"), L = /* @__PURE__ */ Symbol.for("react.suspense"), re = /* @__PURE__ */ Symbol.for("react.suspense_list"), ve = /* @__PURE__ */ Symbol.for("react.memo"), ce = /* @__PURE__ */ Symbol.for("react.lazy"), le = /* @__PURE__ */ Symbol.for("react.activity"), Te = /* @__PURE__ */ Symbol.for("react.client.reference"), T = v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, R = Object.prototype.hasOwnProperty, H = Array.isArray, X = console.createTask ? console.createTask : function() {
|
|
223
|
+
return null;
|
|
224
|
+
};
|
|
225
|
+
v = {
|
|
226
|
+
react_stack_bottom_frame: function(p) {
|
|
227
|
+
return p();
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
var fe, se = {}, ke = v.react_stack_bottom_frame.bind(
|
|
231
|
+
v,
|
|
232
|
+
o
|
|
233
|
+
)(), ze = X(n(o)), Se = {};
|
|
234
|
+
We.Fragment = I, We.jsx = function(p, A, M) {
|
|
235
|
+
var G = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
236
|
+
return _(
|
|
237
|
+
p,
|
|
238
|
+
A,
|
|
239
|
+
M,
|
|
240
|
+
!1,
|
|
241
|
+
G ? Error("react-stack-top-frame") : ke,
|
|
242
|
+
G ? X(n(p)) : ze
|
|
243
|
+
);
|
|
244
|
+
}, We.jsxs = function(p, A, M) {
|
|
245
|
+
var G = 1e4 > T.recentlyCreatedOwnerStacks++;
|
|
246
|
+
return _(
|
|
247
|
+
p,
|
|
248
|
+
A,
|
|
249
|
+
M,
|
|
250
|
+
!0,
|
|
251
|
+
G ? Error("react-stack-top-frame") : ke,
|
|
252
|
+
G ? X(n(p)) : ze
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
})()), We;
|
|
256
|
+
}
|
|
257
|
+
var tr;
|
|
258
|
+
function Ln() {
|
|
259
|
+
return tr || (tr = 1, process.env.NODE_ENV === "production" ? et.exports = Dn() : et.exports = Un()), et.exports;
|
|
260
|
+
}
|
|
261
|
+
var m = Ln(), Qe = (e) => e.type === "checkbox", Oe = (e) => e instanceof Date, de = (e) => e == null;
|
|
262
|
+
const Mr = (e) => typeof e == "object";
|
|
263
|
+
var te = (e) => !de(e) && !Array.isArray(e) && Mr(e) && !Oe(e), Jr = (e) => te(e) && e.target ? Qe(e.target) ? e.target.checked : e.target.value : e, Mn = (e) => e.substring(0, e.search(/\.\d+(\.|$)/)) || e, Br = (e, t) => e.has(Mn(t)), Jn = (e) => {
|
|
264
|
+
const t = e.constructor && e.constructor.prototype;
|
|
265
|
+
return te(t) && t.hasOwnProperty("isPrototypeOf");
|
|
266
|
+
}, Tt = typeof window < "u" && typeof window.HTMLElement < "u" && typeof document < "u";
|
|
267
|
+
function Q(e) {
|
|
268
|
+
if (e instanceof Date)
|
|
269
|
+
return new Date(e);
|
|
270
|
+
const t = typeof FileList < "u" && e instanceof FileList;
|
|
271
|
+
if (Tt && (e instanceof Blob || t))
|
|
272
|
+
return e;
|
|
273
|
+
const r = Array.isArray(e);
|
|
274
|
+
if (!r && !(te(e) && Jn(e)))
|
|
275
|
+
return e;
|
|
276
|
+
const n = r ? [] : Object.create(Object.getPrototypeOf(e));
|
|
277
|
+
for (const s in e)
|
|
278
|
+
Object.prototype.hasOwnProperty.call(e, s) && (n[s] = Q(e[s]));
|
|
279
|
+
return n;
|
|
280
|
+
}
|
|
281
|
+
var dt = (e) => /^\w*$/.test(e), J = (e) => e === void 0, Ft = (e) => Array.isArray(e) ? e.filter(Boolean) : [], Pt = (e) => Ft(e.replace(/["|']|\]/g, "").split(/\.|\[/)), k = (e, t, r) => {
|
|
282
|
+
if (!t || !te(e))
|
|
283
|
+
return r;
|
|
284
|
+
const n = (dt(t) ? [t] : Pt(t)).reduce((s, o) => de(s) ? s : s[o], e);
|
|
285
|
+
return J(n) || n === e ? J(e[t]) ? r : e[t] : n;
|
|
286
|
+
}, me = (e) => typeof e == "boolean", ue = (e) => typeof e == "function", D = (e, t, r) => {
|
|
287
|
+
let n = -1;
|
|
288
|
+
const s = dt(t) ? [t] : Pt(t), o = s.length, i = o - 1;
|
|
289
|
+
for (; ++n < o; ) {
|
|
290
|
+
const a = s[n];
|
|
291
|
+
let c = r;
|
|
292
|
+
if (n !== i) {
|
|
293
|
+
const f = e[a];
|
|
294
|
+
c = te(f) || Array.isArray(f) ? f : isNaN(+s[n + 1]) ? {} : [];
|
|
295
|
+
}
|
|
296
|
+
if (a === "__proto__" || a === "constructor" || a === "prototype")
|
|
297
|
+
return;
|
|
298
|
+
e[a] = c, e = e[a];
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
const ot = {
|
|
302
|
+
BLUR: "blur",
|
|
303
|
+
FOCUS_OUT: "focusout",
|
|
304
|
+
CHANGE: "change"
|
|
305
|
+
}, _e = {
|
|
306
|
+
onBlur: "onBlur",
|
|
307
|
+
onChange: "onChange",
|
|
308
|
+
onSubmit: "onSubmit",
|
|
309
|
+
onTouched: "onTouched",
|
|
310
|
+
all: "all"
|
|
311
|
+
}, we = {
|
|
312
|
+
max: "max",
|
|
313
|
+
min: "min",
|
|
314
|
+
maxLength: "maxLength",
|
|
315
|
+
minLength: "minLength",
|
|
316
|
+
pattern: "pattern",
|
|
317
|
+
required: "required",
|
|
318
|
+
validate: "validate"
|
|
319
|
+
}, Wr = j.createContext(null);
|
|
320
|
+
Wr.displayName = "HookFormControlContext";
|
|
321
|
+
const Rt = () => j.useContext(Wr);
|
|
322
|
+
var qr = (e, t, r, n = !0) => {
|
|
323
|
+
const s = {
|
|
324
|
+
defaultValues: t._defaultValues
|
|
325
|
+
};
|
|
326
|
+
for (const o in e)
|
|
327
|
+
Object.defineProperty(s, o, {
|
|
328
|
+
get: () => {
|
|
329
|
+
const i = o;
|
|
330
|
+
return t._proxyFormState[i] !== _e.all && (t._proxyFormState[i] = !n || _e.all), r && (r[i] = !0), e[i];
|
|
331
|
+
}
|
|
332
|
+
});
|
|
333
|
+
return s;
|
|
334
|
+
};
|
|
335
|
+
const It = typeof window < "u" ? j.useLayoutEffect : j.useEffect;
|
|
336
|
+
function Bn(e) {
|
|
337
|
+
const t = Rt(), { control: r = t, disabled: n, name: s, exact: o } = e || {}, [i, a] = j.useState(r._formState), c = j.useRef({
|
|
338
|
+
isDirty: !1,
|
|
339
|
+
isLoading: !1,
|
|
340
|
+
dirtyFields: !1,
|
|
341
|
+
touchedFields: !1,
|
|
342
|
+
validatingFields: !1,
|
|
343
|
+
isValidating: !1,
|
|
344
|
+
isValid: !1,
|
|
345
|
+
errors: !1
|
|
346
|
+
});
|
|
347
|
+
return It(() => r._subscribe({
|
|
348
|
+
name: s,
|
|
349
|
+
formState: c.current,
|
|
350
|
+
exact: o,
|
|
351
|
+
callback: (f) => {
|
|
352
|
+
!n && a({
|
|
353
|
+
...r._formState,
|
|
354
|
+
...f
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
}), [s, n, o]), j.useEffect(() => {
|
|
358
|
+
c.current.isValid && r._setValid(!0);
|
|
359
|
+
}, [r]), j.useMemo(() => qr(i, r, c.current, !1), [i, r]);
|
|
360
|
+
}
|
|
361
|
+
var pe = (e) => typeof e == "string", Et = (e, t, r, n, s) => pe(e) ? (n && t.watch.add(e), k(r, e, s)) : Array.isArray(e) ? e.map((o) => (n && t.watch.add(o), k(r, o))) : (n && (t.watchAll = !0), r), $t = (e) => de(e) || !Mr(e);
|
|
362
|
+
function ye(e, t, r = /* @__PURE__ */ new WeakSet()) {
|
|
363
|
+
if ($t(e) || $t(t))
|
|
364
|
+
return Object.is(e, t);
|
|
365
|
+
if (Oe(e) && Oe(t))
|
|
366
|
+
return Object.is(e.getTime(), t.getTime());
|
|
367
|
+
const n = Object.keys(e), s = Object.keys(t);
|
|
368
|
+
if (n.length !== s.length)
|
|
369
|
+
return !1;
|
|
370
|
+
if (r.has(e) || r.has(t))
|
|
371
|
+
return !0;
|
|
372
|
+
r.add(e), r.add(t);
|
|
373
|
+
for (const o of n) {
|
|
374
|
+
const i = e[o];
|
|
375
|
+
if (!s.includes(o))
|
|
376
|
+
return !1;
|
|
377
|
+
if (o !== "ref") {
|
|
378
|
+
const a = t[o];
|
|
379
|
+
if (Oe(i) && Oe(a) || te(i) && te(a) || Array.isArray(i) && Array.isArray(a) ? !ye(i, a, r) : !Object.is(i, a))
|
|
380
|
+
return !1;
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return !0;
|
|
384
|
+
}
|
|
385
|
+
function Wn(e) {
|
|
386
|
+
const t = Rt(), { control: r = t, name: n, defaultValue: s, disabled: o, exact: i, compute: a } = e || {}, c = j.useRef(s), f = j.useRef(a), _ = j.useRef(void 0), g = j.useRef(r), b = j.useRef(n);
|
|
387
|
+
f.current = a;
|
|
388
|
+
const [v, Z] = j.useState(() => {
|
|
389
|
+
const z = r._getWatch(n, c.current);
|
|
390
|
+
return f.current ? f.current(z) : z;
|
|
391
|
+
}), O = j.useCallback((z) => {
|
|
392
|
+
const S = Et(n, r._names, z || r._formValues, !1, c.current);
|
|
393
|
+
return f.current ? f.current(S) : S;
|
|
394
|
+
}, [r._formValues, r._names, n]), I = j.useCallback((z) => {
|
|
395
|
+
if (!o) {
|
|
396
|
+
const S = Et(n, r._names, z || r._formValues, !1, c.current);
|
|
397
|
+
if (f.current) {
|
|
398
|
+
const L = f.current(S);
|
|
399
|
+
ye(L, _.current) || (Z(L), _.current = L);
|
|
400
|
+
} else
|
|
401
|
+
Z(S);
|
|
402
|
+
}
|
|
403
|
+
}, [r._formValues, r._names, o, n]);
|
|
404
|
+
It(() => ((g.current !== r || !ye(b.current, n)) && (g.current = r, b.current = n, I()), r._subscribe({
|
|
405
|
+
name: n,
|
|
406
|
+
formState: {
|
|
407
|
+
values: !0
|
|
408
|
+
},
|
|
409
|
+
exact: i,
|
|
410
|
+
callback: (z) => {
|
|
411
|
+
I(z.values);
|
|
412
|
+
}
|
|
413
|
+
})), [r, i, n, I]), j.useEffect(() => r._removeUnmounted());
|
|
414
|
+
const F = g.current !== r, N = b.current, P = j.useMemo(() => {
|
|
415
|
+
if (o)
|
|
416
|
+
return null;
|
|
417
|
+
const z = !F && !ye(N, n);
|
|
418
|
+
return F || z ? O() : null;
|
|
419
|
+
}, [o, F, n, N, O]);
|
|
420
|
+
return P !== null ? P : v;
|
|
421
|
+
}
|
|
422
|
+
function qn(e) {
|
|
423
|
+
const t = Rt(), { name: r, disabled: n, control: s = t, shouldUnregister: o, defaultValue: i, exact: a = !0 } = e, c = Br(s._names.array, r), f = j.useMemo(() => k(s._formValues, r, k(s._defaultValues, r, i)), [s, r, i]), _ = Wn({
|
|
424
|
+
control: s,
|
|
425
|
+
name: r,
|
|
426
|
+
defaultValue: f,
|
|
427
|
+
exact: a
|
|
428
|
+
}), g = Bn({
|
|
429
|
+
control: s,
|
|
430
|
+
name: r,
|
|
431
|
+
exact: a
|
|
432
|
+
}), b = j.useRef(e), v = j.useRef(void 0), Z = j.useRef(s.register(r, {
|
|
433
|
+
...e.rules,
|
|
434
|
+
value: _,
|
|
435
|
+
...me(e.disabled) ? { disabled: e.disabled } : {}
|
|
436
|
+
}));
|
|
437
|
+
b.current = e;
|
|
438
|
+
const O = j.useMemo(() => Object.defineProperties({}, {
|
|
439
|
+
invalid: {
|
|
440
|
+
enumerable: !0,
|
|
441
|
+
get: () => !!k(g.errors, r)
|
|
442
|
+
},
|
|
443
|
+
isDirty: {
|
|
444
|
+
enumerable: !0,
|
|
445
|
+
get: () => !!k(g.dirtyFields, r)
|
|
446
|
+
},
|
|
447
|
+
isTouched: {
|
|
448
|
+
enumerable: !0,
|
|
449
|
+
get: () => !!k(g.touchedFields, r)
|
|
450
|
+
},
|
|
451
|
+
isValidating: {
|
|
452
|
+
enumerable: !0,
|
|
453
|
+
get: () => !!k(g.validatingFields, r)
|
|
454
|
+
},
|
|
455
|
+
error: {
|
|
456
|
+
enumerable: !0,
|
|
457
|
+
get: () => k(g.errors, r)
|
|
458
|
+
}
|
|
459
|
+
}), [g, r]), I = j.useCallback((z) => Z.current.onChange({
|
|
460
|
+
target: {
|
|
461
|
+
value: Jr(z),
|
|
462
|
+
name: r
|
|
463
|
+
},
|
|
464
|
+
type: ot.CHANGE
|
|
465
|
+
}), [r]), F = j.useCallback(() => Z.current.onBlur({
|
|
466
|
+
target: {
|
|
467
|
+
value: k(s._formValues, r),
|
|
468
|
+
name: r
|
|
469
|
+
},
|
|
470
|
+
type: ot.BLUR
|
|
471
|
+
}), [r, s._formValues]), N = j.useCallback((z) => {
|
|
472
|
+
const S = k(s._fields, r);
|
|
473
|
+
S && S._f && z && (S._f.ref = {
|
|
474
|
+
focus: () => ue(z.focus) && z.focus(),
|
|
475
|
+
select: () => ue(z.select) && z.select(),
|
|
476
|
+
setCustomValidity: (L) => ue(z.setCustomValidity) && z.setCustomValidity(L),
|
|
477
|
+
reportValidity: () => ue(z.reportValidity) && z.reportValidity()
|
|
478
|
+
});
|
|
479
|
+
}, [s._fields, r]), P = j.useMemo(() => ({
|
|
480
|
+
name: r,
|
|
481
|
+
value: _,
|
|
482
|
+
...me(n) || g.disabled ? { disabled: g.disabled || n } : {},
|
|
483
|
+
onChange: I,
|
|
484
|
+
onBlur: F,
|
|
485
|
+
ref: N
|
|
486
|
+
}), [r, n, g.disabled, I, F, N, _]);
|
|
487
|
+
return j.useEffect(() => {
|
|
488
|
+
const z = s._options.shouldUnregister || o, S = v.current;
|
|
489
|
+
S && S !== r && !c && s.unregister(S), s.register(r, {
|
|
490
|
+
...b.current.rules,
|
|
491
|
+
...me(b.current.disabled) ? { disabled: b.current.disabled } : {}
|
|
492
|
+
});
|
|
493
|
+
const L = (re, ve) => {
|
|
494
|
+
const ce = k(s._fields, re);
|
|
495
|
+
ce && ce._f && (ce._f.mount = ve);
|
|
496
|
+
};
|
|
497
|
+
if (L(r, !0), z) {
|
|
498
|
+
const re = Q(k(s._options.defaultValues, r, b.current.defaultValue));
|
|
499
|
+
D(s._defaultValues, r, re), J(k(s._formValues, r)) && D(s._formValues, r, re);
|
|
500
|
+
}
|
|
501
|
+
return !c && s.register(r), v.current = r, () => {
|
|
502
|
+
(c ? z && !s._state.action : z) ? s.unregister(r) : L(r, !1);
|
|
503
|
+
};
|
|
504
|
+
}, [r, s, c, o]), j.useEffect(() => {
|
|
505
|
+
s._setDisabledField({
|
|
506
|
+
disabled: n,
|
|
507
|
+
name: r
|
|
508
|
+
});
|
|
509
|
+
}, [n, r, s]), j.useMemo(() => ({
|
|
510
|
+
field: P,
|
|
511
|
+
formState: g,
|
|
512
|
+
fieldState: O
|
|
513
|
+
}), [P, g, O]);
|
|
514
|
+
}
|
|
515
|
+
const rr = (e) => e.render(qn(e)), Yn = j.createContext(null);
|
|
516
|
+
Yn.displayName = "HookFormContext";
|
|
517
|
+
var Ct = (e, t, r, n, s) => t ? {
|
|
518
|
+
...r[e],
|
|
519
|
+
types: {
|
|
520
|
+
...r[e] && r[e].types ? r[e].types : {},
|
|
521
|
+
[n]: s || !0
|
|
522
|
+
}
|
|
523
|
+
} : {}, Ge = (e) => Array.isArray(e) ? e : [e], nr = () => {
|
|
524
|
+
let e = [];
|
|
525
|
+
return {
|
|
526
|
+
get observers() {
|
|
527
|
+
return e;
|
|
528
|
+
},
|
|
529
|
+
next: (s) => {
|
|
530
|
+
for (const o of e)
|
|
531
|
+
o.next && o.next(s);
|
|
532
|
+
},
|
|
533
|
+
subscribe: (s) => (e.push(s), {
|
|
534
|
+
unsubscribe: () => {
|
|
535
|
+
e = e.filter((o) => o !== s);
|
|
536
|
+
}
|
|
537
|
+
}),
|
|
538
|
+
unsubscribe: () => {
|
|
539
|
+
e = [];
|
|
540
|
+
}
|
|
541
|
+
};
|
|
542
|
+
};
|
|
543
|
+
function Yr(e, t) {
|
|
544
|
+
const r = {};
|
|
545
|
+
for (const n in e)
|
|
546
|
+
if (e.hasOwnProperty(n)) {
|
|
547
|
+
const s = e[n], o = t[n];
|
|
548
|
+
if (s && te(s) && o) {
|
|
549
|
+
const i = Yr(s, o);
|
|
550
|
+
te(i) && (r[n] = i);
|
|
551
|
+
} else e[n] && (r[n] = o);
|
|
552
|
+
}
|
|
553
|
+
return r;
|
|
554
|
+
}
|
|
555
|
+
var ae = (e) => te(e) && !Object.keys(e).length, Vt = (e) => e.type === "file", it = (e) => {
|
|
556
|
+
if (!Tt)
|
|
557
|
+
return !1;
|
|
558
|
+
const t = e ? e.ownerDocument : 0;
|
|
559
|
+
return e instanceof (t && t.defaultView ? t.defaultView.HTMLElement : HTMLElement);
|
|
560
|
+
}, Gr = (e) => e.type === "select-multiple", Dt = (e) => e.type === "radio", Gn = (e) => Dt(e) || Qe(e), kt = (e) => it(e) && e.isConnected;
|
|
561
|
+
function Hn(e, t) {
|
|
562
|
+
const r = t.slice(0, -1).length;
|
|
563
|
+
let n = 0;
|
|
564
|
+
for (; n < r; )
|
|
565
|
+
e = J(e) ? n++ : e[t[n++]];
|
|
566
|
+
return e;
|
|
567
|
+
}
|
|
568
|
+
function Kn(e) {
|
|
569
|
+
for (const t in e)
|
|
570
|
+
if (e.hasOwnProperty(t) && !J(e[t]))
|
|
571
|
+
return !1;
|
|
572
|
+
return !0;
|
|
573
|
+
}
|
|
574
|
+
function ee(e, t) {
|
|
575
|
+
const r = Array.isArray(t) ? t : dt(t) ? [t] : Pt(t), n = r.length === 1 ? e : Hn(e, r), s = r.length - 1, o = r[s];
|
|
576
|
+
return n && delete n[o], s !== 0 && (te(n) && ae(n) || Array.isArray(n) && Kn(n)) && ee(e, r.slice(0, -1)), e;
|
|
577
|
+
}
|
|
578
|
+
var Xn = (e) => {
|
|
579
|
+
for (const t in e)
|
|
580
|
+
if (ue(e[t]))
|
|
581
|
+
return !0;
|
|
582
|
+
return !1;
|
|
583
|
+
};
|
|
584
|
+
function Hr(e) {
|
|
585
|
+
return Array.isArray(e) || te(e) && !Xn(e);
|
|
586
|
+
}
|
|
587
|
+
function Nt(e, t = {}) {
|
|
588
|
+
for (const r in e) {
|
|
589
|
+
const n = e[r];
|
|
590
|
+
Hr(n) ? (t[r] = Array.isArray(n) ? [] : {}, Nt(n, t[r])) : J(n) || (t[r] = !0);
|
|
591
|
+
}
|
|
592
|
+
return t;
|
|
593
|
+
}
|
|
594
|
+
function Ve(e, t, r) {
|
|
595
|
+
r || (r = Nt(t));
|
|
596
|
+
for (const n in e) {
|
|
597
|
+
const s = e[n];
|
|
598
|
+
if (Hr(s))
|
|
599
|
+
J(t) || $t(r[n]) ? r[n] = Nt(s, Array.isArray(s) ? [] : {}) : Ve(s, de(t) ? {} : t[n], r[n]);
|
|
600
|
+
else {
|
|
601
|
+
const o = t[n];
|
|
602
|
+
r[n] = !ye(s, o);
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
return r;
|
|
606
|
+
}
|
|
607
|
+
const sr = {
|
|
608
|
+
value: !1,
|
|
609
|
+
isValid: !1
|
|
610
|
+
}, or = { value: !0, isValid: !0 };
|
|
611
|
+
var Kr = (e) => {
|
|
612
|
+
if (Array.isArray(e)) {
|
|
613
|
+
if (e.length > 1) {
|
|
614
|
+
const t = e.filter((r) => r && r.checked && !r.disabled).map((r) => r.value);
|
|
615
|
+
return { value: t, isValid: !!t.length };
|
|
616
|
+
}
|
|
617
|
+
return e[0].checked && !e[0].disabled ? (
|
|
618
|
+
// @ts-expect-error expected to work in the browser
|
|
619
|
+
e[0].attributes && !J(e[0].attributes.value) ? J(e[0].value) || e[0].value === "" ? or : { value: e[0].value, isValid: !0 } : or
|
|
620
|
+
) : sr;
|
|
621
|
+
}
|
|
622
|
+
return sr;
|
|
623
|
+
}, Xr = (e, { valueAsNumber: t, valueAsDate: r, setValueAs: n }) => J(e) ? e : t ? e === "" ? NaN : e && +e : r && pe(e) ? new Date(e) : n ? n(e) : e;
|
|
624
|
+
const ir = {
|
|
625
|
+
isValid: !1,
|
|
626
|
+
value: null
|
|
627
|
+
};
|
|
628
|
+
var Qr = (e) => Array.isArray(e) ? e.reduce((t, r) => r && r.checked && !r.disabled ? {
|
|
629
|
+
isValid: !0,
|
|
630
|
+
value: r.value
|
|
631
|
+
} : t, ir) : ir;
|
|
632
|
+
function ar(e) {
|
|
633
|
+
const t = e.ref;
|
|
634
|
+
return Vt(t) ? t.files : Dt(t) ? Qr(e.refs).value : Gr(t) ? [...t.selectedOptions].map(({ value: r }) => r) : Qe(t) ? Kr(e.refs).value : Xr(J(t.value) ? e.ref.value : t.value, e);
|
|
635
|
+
}
|
|
636
|
+
var Qn = (e, t, r, n) => {
|
|
637
|
+
const s = {};
|
|
638
|
+
for (const o of e) {
|
|
639
|
+
const i = k(t, o);
|
|
640
|
+
i && D(s, o, i._f);
|
|
641
|
+
}
|
|
642
|
+
return {
|
|
643
|
+
criteriaMode: r,
|
|
644
|
+
names: [...e],
|
|
645
|
+
fields: s,
|
|
646
|
+
shouldUseNativeValidation: n
|
|
647
|
+
};
|
|
648
|
+
}, at = (e) => e instanceof RegExp, qe = (e) => J(e) ? e : at(e) ? e.source : te(e) ? at(e.value) ? e.value.source : e.value : e, ur = (e) => ({
|
|
649
|
+
isOnSubmit: !e || e === _e.onSubmit,
|
|
650
|
+
isOnBlur: e === _e.onBlur,
|
|
651
|
+
isOnChange: e === _e.onChange,
|
|
652
|
+
isOnAll: e === _e.all,
|
|
653
|
+
isOnTouch: e === _e.onTouched
|
|
654
|
+
});
|
|
655
|
+
const cr = "AsyncFunction";
|
|
656
|
+
var es = (e) => !!e && !!e.validate && !!(ue(e.validate) && e.validate.constructor.name === cr || te(e.validate) && Object.values(e.validate).find((t) => t.constructor.name === cr)), ts = (e) => e.mount && (e.required || e.min || e.max || e.maxLength || e.minLength || e.pattern || e.validate), lr = (e, t, r) => !r && (t.watchAll || t.watch.has(e) || [...t.watch].some((n) => e.startsWith(n) && /^\.\w+/.test(e.slice(n.length))));
|
|
657
|
+
const He = (e, t, r, n) => {
|
|
658
|
+
for (const s of r || Object.keys(e)) {
|
|
659
|
+
const o = k(e, s);
|
|
660
|
+
if (o) {
|
|
661
|
+
const { _f: i, ...a } = o;
|
|
662
|
+
if (i) {
|
|
663
|
+
if (i.refs && i.refs[0] && t(i.refs[0], s) && !n)
|
|
664
|
+
return !0;
|
|
665
|
+
if (i.ref && t(i.ref, i.name) && !n)
|
|
666
|
+
return !0;
|
|
667
|
+
if (He(a, t))
|
|
668
|
+
break;
|
|
669
|
+
} else if (te(a) && He(a, t))
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
};
|
|
674
|
+
function fr(e, t, r) {
|
|
675
|
+
const n = k(e, r);
|
|
676
|
+
if (n || dt(r))
|
|
677
|
+
return {
|
|
678
|
+
error: n,
|
|
679
|
+
name: r
|
|
680
|
+
};
|
|
681
|
+
const s = r.split(".");
|
|
682
|
+
for (; s.length; ) {
|
|
683
|
+
const o = s.join("."), i = k(t, o), a = k(e, o);
|
|
684
|
+
if (i && !Array.isArray(i) && r !== o)
|
|
685
|
+
return { name: r };
|
|
686
|
+
if (a && a.type)
|
|
687
|
+
return {
|
|
688
|
+
name: o,
|
|
689
|
+
error: a
|
|
690
|
+
};
|
|
691
|
+
if (a && a.root && a.root.type)
|
|
692
|
+
return {
|
|
693
|
+
name: `${o}.root`,
|
|
694
|
+
error: a.root
|
|
695
|
+
};
|
|
696
|
+
s.pop();
|
|
697
|
+
}
|
|
698
|
+
return {
|
|
699
|
+
name: r
|
|
700
|
+
};
|
|
701
|
+
}
|
|
702
|
+
var rs = (e, t, r, n) => {
|
|
703
|
+
r(e);
|
|
704
|
+
const { name: s, ...o } = e;
|
|
705
|
+
return ae(o) || Object.keys(o).length >= Object.keys(t).length || Object.keys(o).find((i) => t[i] === (!n || _e.all));
|
|
706
|
+
}, ns = (e, t, r) => !e || !t || e === t || Ge(e).some((n) => n && (r ? n === t : n.startsWith(t) || t.startsWith(n))), ss = (e, t, r, n, s) => s.isOnAll ? !1 : !r && s.isOnTouch ? !(t || e) : (r ? n.isOnBlur : s.isOnBlur) ? !e : (r ? n.isOnChange : s.isOnChange) ? e : !0, os = (e, t) => !Ft(k(e, t)).length && ee(e, t), is = (e, t, r) => {
|
|
707
|
+
const n = Ge(k(e, r));
|
|
708
|
+
return D(n, "root", t[r]), D(e, r, n), e;
|
|
709
|
+
};
|
|
710
|
+
function dr(e, t, r = "validate") {
|
|
711
|
+
if (pe(e) || Array.isArray(e) && e.every(pe) || me(e) && !e)
|
|
712
|
+
return {
|
|
713
|
+
type: r,
|
|
714
|
+
message: pe(e) ? e : "",
|
|
715
|
+
ref: t
|
|
716
|
+
};
|
|
717
|
+
}
|
|
718
|
+
var Ce = (e) => te(e) && !at(e) ? e : {
|
|
719
|
+
value: e,
|
|
720
|
+
message: ""
|
|
721
|
+
}, hr = async (e, t, r, n, s, o) => {
|
|
722
|
+
const { ref: i, refs: a, required: c, maxLength: f, minLength: _, min: g, max: b, pattern: v, validate: Z, name: O, valueAsNumber: I, mount: F } = e._f, N = k(r, O);
|
|
723
|
+
if (!F || t.has(O))
|
|
724
|
+
return {};
|
|
725
|
+
const P = a ? a[0] : i, z = (T) => {
|
|
726
|
+
s && P.reportValidity && (P.setCustomValidity(me(T) ? "" : T || ""), P.reportValidity());
|
|
727
|
+
}, S = {}, L = Dt(i), re = Qe(i), ve = L || re, ce = (I || Vt(i)) && J(i.value) && J(N) || it(i) && i.value === "" || N === "" || Array.isArray(N) && !N.length, le = Ct.bind(null, O, n, S), Te = (T, R, H, X = we.maxLength, fe = we.minLength) => {
|
|
728
|
+
const se = T ? R : H;
|
|
729
|
+
S[O] = {
|
|
730
|
+
type: T ? X : fe,
|
|
731
|
+
message: se,
|
|
732
|
+
ref: i,
|
|
733
|
+
...le(T ? X : fe, se)
|
|
734
|
+
};
|
|
735
|
+
};
|
|
736
|
+
if (o ? !Array.isArray(N) || !N.length : c && (!ve && (ce || de(N)) || me(N) && !N || re && !Kr(a).isValid || L && !Qr(a).isValid)) {
|
|
737
|
+
const { value: T, message: R } = pe(c) ? { value: !!c, message: c } : Ce(c);
|
|
738
|
+
if (T && (S[O] = {
|
|
739
|
+
type: we.required,
|
|
740
|
+
message: R,
|
|
741
|
+
ref: P,
|
|
742
|
+
...le(we.required, R)
|
|
743
|
+
}, !n))
|
|
744
|
+
return z(R), S;
|
|
745
|
+
}
|
|
746
|
+
if (!ce && (!de(g) || !de(b))) {
|
|
747
|
+
let T, R;
|
|
748
|
+
const H = Ce(b), X = Ce(g);
|
|
749
|
+
if (!de(N) && !isNaN(N)) {
|
|
750
|
+
const fe = i.valueAsNumber || N && +N;
|
|
751
|
+
de(H.value) || (T = fe > H.value), de(X.value) || (R = fe < X.value);
|
|
752
|
+
} else {
|
|
753
|
+
const fe = i.valueAsDate || new Date(N), se = (Se) => /* @__PURE__ */ new Date((/* @__PURE__ */ new Date()).toDateString() + " " + Se), ke = i.type == "time", ze = i.type == "week";
|
|
754
|
+
pe(H.value) && N && (T = ke ? se(N) > se(H.value) : ze ? N > H.value : fe > new Date(H.value)), pe(X.value) && N && (R = ke ? se(N) < se(X.value) : ze ? N < X.value : fe < new Date(X.value));
|
|
755
|
+
}
|
|
756
|
+
if ((T || R) && (Te(!!T, H.message, X.message, we.max, we.min), !n))
|
|
757
|
+
return z(S[O].message), S;
|
|
758
|
+
}
|
|
759
|
+
if ((f || _) && !ce && (pe(N) || o && Array.isArray(N))) {
|
|
760
|
+
const T = Ce(f), R = Ce(_), H = !de(T.value) && N.length > +T.value, X = !de(R.value) && N.length < +R.value;
|
|
761
|
+
if ((H || X) && (Te(H, T.message, R.message), !n))
|
|
762
|
+
return z(S[O].message), S;
|
|
763
|
+
}
|
|
764
|
+
if (v && !ce && pe(N)) {
|
|
765
|
+
const { value: T, message: R } = Ce(v);
|
|
766
|
+
if (at(T) && !N.match(T) && (S[O] = {
|
|
767
|
+
type: we.pattern,
|
|
768
|
+
message: R,
|
|
769
|
+
ref: i,
|
|
770
|
+
...le(we.pattern, R)
|
|
771
|
+
}, !n))
|
|
772
|
+
return z(R), S;
|
|
773
|
+
}
|
|
774
|
+
if (Z) {
|
|
775
|
+
if (ue(Z)) {
|
|
776
|
+
const T = await Z(N, r), R = dr(T, P);
|
|
777
|
+
if (R && (S[O] = {
|
|
778
|
+
...R,
|
|
779
|
+
...le(we.validate, R.message)
|
|
780
|
+
}, !n))
|
|
781
|
+
return z(R.message), S;
|
|
782
|
+
} else if (te(Z)) {
|
|
783
|
+
let T = {};
|
|
784
|
+
for (const R in Z) {
|
|
785
|
+
if (!ae(T) && !n)
|
|
786
|
+
break;
|
|
787
|
+
const H = dr(await Z[R](N, r), P, R);
|
|
788
|
+
H && (T = {
|
|
789
|
+
...H,
|
|
790
|
+
...le(R, H.message)
|
|
791
|
+
}, z(H.message), n && (S[O] = T));
|
|
792
|
+
}
|
|
793
|
+
if (!ae(T) && (S[O] = {
|
|
794
|
+
ref: P,
|
|
795
|
+
...T
|
|
796
|
+
}, !n))
|
|
797
|
+
return S;
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
return z(!0), S;
|
|
801
|
+
};
|
|
802
|
+
const as = {
|
|
803
|
+
mode: _e.onSubmit,
|
|
804
|
+
reValidateMode: _e.onChange,
|
|
805
|
+
shouldFocusError: !0
|
|
806
|
+
};
|
|
807
|
+
function us(e = {}) {
|
|
808
|
+
let t = {
|
|
809
|
+
...as,
|
|
810
|
+
...e
|
|
811
|
+
}, r = {
|
|
812
|
+
submitCount: 0,
|
|
813
|
+
isDirty: !1,
|
|
814
|
+
isReady: !1,
|
|
815
|
+
isLoading: ue(t.defaultValues),
|
|
816
|
+
isValidating: !1,
|
|
817
|
+
isSubmitted: !1,
|
|
818
|
+
isSubmitting: !1,
|
|
819
|
+
isSubmitSuccessful: !1,
|
|
820
|
+
isValid: !1,
|
|
821
|
+
touchedFields: {},
|
|
822
|
+
dirtyFields: {},
|
|
823
|
+
validatingFields: {},
|
|
824
|
+
errors: t.errors || {},
|
|
825
|
+
disabled: t.disabled || !1
|
|
826
|
+
}, n = {}, s = te(t.defaultValues) || te(t.values) ? Q(t.defaultValues || t.values) || {} : {}, o = t.shouldUnregister ? {} : Q(s), i = {
|
|
827
|
+
action: !1,
|
|
828
|
+
mount: !1,
|
|
829
|
+
watch: !1,
|
|
830
|
+
keepIsValid: !1
|
|
831
|
+
}, a = {
|
|
832
|
+
mount: /* @__PURE__ */ new Set(),
|
|
833
|
+
disabled: /* @__PURE__ */ new Set(),
|
|
834
|
+
unMount: /* @__PURE__ */ new Set(),
|
|
835
|
+
array: /* @__PURE__ */ new Set(),
|
|
836
|
+
watch: /* @__PURE__ */ new Set()
|
|
837
|
+
}, c, f = 0;
|
|
838
|
+
const _ = {
|
|
839
|
+
isDirty: !1,
|
|
840
|
+
dirtyFields: !1,
|
|
841
|
+
validatingFields: !1,
|
|
842
|
+
touchedFields: !1,
|
|
843
|
+
isValidating: !1,
|
|
844
|
+
isValid: !1,
|
|
845
|
+
errors: !1
|
|
846
|
+
}, g = {
|
|
847
|
+
..._
|
|
848
|
+
};
|
|
849
|
+
let b = {
|
|
850
|
+
...g
|
|
851
|
+
};
|
|
852
|
+
const v = {
|
|
853
|
+
array: nr(),
|
|
854
|
+
state: nr()
|
|
855
|
+
}, Z = t.criteriaMode === _e.all, O = (u) => (l) => {
|
|
856
|
+
clearTimeout(f), f = setTimeout(u, l);
|
|
857
|
+
}, I = async (u) => {
|
|
858
|
+
if (!i.keepIsValid && !t.disabled && (g.isValid || b.isValid || u)) {
|
|
859
|
+
let l;
|
|
860
|
+
t.resolver ? (l = ae((await ve()).errors), F()) : l = await le(n, !0), l !== r.isValid && v.state.next({
|
|
861
|
+
isValid: l
|
|
862
|
+
});
|
|
863
|
+
}
|
|
864
|
+
}, F = (u, l) => {
|
|
865
|
+
!t.disabled && (g.isValidating || g.validatingFields || b.isValidating || b.validatingFields) && ((u || Array.from(a.mount)).forEach((d) => {
|
|
866
|
+
d && (l ? D(r.validatingFields, d, l) : ee(r.validatingFields, d));
|
|
867
|
+
}), v.state.next({
|
|
868
|
+
validatingFields: r.validatingFields,
|
|
869
|
+
isValidating: !ae(r.validatingFields)
|
|
870
|
+
}));
|
|
871
|
+
}, N = (u, l = [], d, x, w = !0, y = !0) => {
|
|
872
|
+
if (x && d && !t.disabled) {
|
|
873
|
+
if (i.action = !0, y && Array.isArray(k(n, u))) {
|
|
874
|
+
const $ = d(k(n, u), x.argA, x.argB);
|
|
875
|
+
w && D(n, u, $);
|
|
876
|
+
}
|
|
877
|
+
if (y && Array.isArray(k(r.errors, u))) {
|
|
878
|
+
const $ = d(k(r.errors, u), x.argA, x.argB);
|
|
879
|
+
w && D(r.errors, u, $), os(r.errors, u);
|
|
880
|
+
}
|
|
881
|
+
if ((g.touchedFields || b.touchedFields) && y && Array.isArray(k(r.touchedFields, u))) {
|
|
882
|
+
const $ = d(k(r.touchedFields, u), x.argA, x.argB);
|
|
883
|
+
w && D(r.touchedFields, u, $);
|
|
884
|
+
}
|
|
885
|
+
(g.dirtyFields || b.dirtyFields) && (r.dirtyFields = Ve(s, o)), v.state.next({
|
|
886
|
+
name: u,
|
|
887
|
+
isDirty: T(u, l),
|
|
888
|
+
dirtyFields: r.dirtyFields,
|
|
889
|
+
errors: r.errors,
|
|
890
|
+
isValid: r.isValid
|
|
891
|
+
});
|
|
892
|
+
} else
|
|
893
|
+
D(o, u, l);
|
|
894
|
+
}, P = (u, l) => {
|
|
895
|
+
D(r.errors, u, l), v.state.next({
|
|
896
|
+
errors: r.errors
|
|
897
|
+
});
|
|
898
|
+
}, z = (u) => {
|
|
899
|
+
r.errors = u, v.state.next({
|
|
900
|
+
errors: r.errors,
|
|
901
|
+
isValid: !1
|
|
902
|
+
});
|
|
903
|
+
}, S = (u, l, d, x) => {
|
|
904
|
+
const w = k(n, u);
|
|
905
|
+
if (w) {
|
|
906
|
+
const y = k(o, u, J(d) ? k(s, u) : d);
|
|
907
|
+
J(y) || x && x.defaultChecked || l ? D(o, u, l ? y : ar(w._f)) : X(u, y), i.mount && !i.action && I();
|
|
908
|
+
}
|
|
909
|
+
}, L = (u, l, d, x, w) => {
|
|
910
|
+
let y = !1, $ = !1;
|
|
911
|
+
const C = {
|
|
912
|
+
name: u
|
|
913
|
+
};
|
|
914
|
+
if (!t.disabled) {
|
|
915
|
+
if (!d || x) {
|
|
916
|
+
(g.isDirty || b.isDirty) && ($ = r.isDirty, r.isDirty = C.isDirty = T(), y = $ !== C.isDirty);
|
|
917
|
+
const V = ye(k(s, u), l);
|
|
918
|
+
$ = !!k(r.dirtyFields, u), V ? ee(r.dirtyFields, u) : D(r.dirtyFields, u, !0), C.dirtyFields = r.dirtyFields, y = y || (g.dirtyFields || b.dirtyFields) && $ !== !V;
|
|
919
|
+
}
|
|
920
|
+
if (d) {
|
|
921
|
+
const V = k(r.touchedFields, u);
|
|
922
|
+
V || (D(r.touchedFields, u, d), C.touchedFields = r.touchedFields, y = y || (g.touchedFields || b.touchedFields) && V !== d);
|
|
923
|
+
}
|
|
924
|
+
y && w && v.state.next(C);
|
|
925
|
+
}
|
|
926
|
+
return y ? C : {};
|
|
927
|
+
}, re = (u, l, d, x) => {
|
|
928
|
+
const w = k(r.errors, u), y = (g.isValid || b.isValid) && me(l) && r.isValid !== l;
|
|
929
|
+
if (t.delayError && d ? (c = O(() => P(u, d)), c(t.delayError)) : (clearTimeout(f), c = null, d ? D(r.errors, u, d) : ee(r.errors, u)), (d ? !ye(w, d) : w) || !ae(x) || y) {
|
|
930
|
+
const $ = {
|
|
931
|
+
...x,
|
|
932
|
+
...y && me(l) ? { isValid: l } : {},
|
|
933
|
+
errors: r.errors,
|
|
934
|
+
name: u
|
|
935
|
+
};
|
|
936
|
+
r = {
|
|
937
|
+
...r,
|
|
938
|
+
...$
|
|
939
|
+
}, v.state.next($);
|
|
940
|
+
}
|
|
941
|
+
}, ve = async (u) => (F(u, !0), await t.resolver(o, t.context, Qn(u || a.mount, n, t.criteriaMode, t.shouldUseNativeValidation))), ce = async (u) => {
|
|
942
|
+
const { errors: l } = await ve(u);
|
|
943
|
+
if (F(u), u)
|
|
944
|
+
for (const d of u) {
|
|
945
|
+
const x = k(l, d);
|
|
946
|
+
x ? D(r.errors, d, x) : ee(r.errors, d);
|
|
947
|
+
}
|
|
948
|
+
else
|
|
949
|
+
r.errors = l;
|
|
950
|
+
return l;
|
|
951
|
+
}, le = async (u, l, d = {
|
|
952
|
+
valid: !0
|
|
953
|
+
}) => {
|
|
954
|
+
for (const x in u) {
|
|
955
|
+
const w = u[x];
|
|
956
|
+
if (w) {
|
|
957
|
+
const { _f: y, ...$ } = w;
|
|
958
|
+
if (y) {
|
|
959
|
+
const C = a.array.has(y.name), V = w._f && es(w._f);
|
|
960
|
+
V && g.validatingFields && F([y.name], !0);
|
|
961
|
+
const oe = await hr(w, a.disabled, o, Z, t.shouldUseNativeValidation && !l, C);
|
|
962
|
+
if (V && g.validatingFields && F([y.name]), oe[y.name] && (d.valid = !1, l || e.shouldUseNativeValidation))
|
|
963
|
+
break;
|
|
964
|
+
!l && (k(oe, y.name) ? C ? is(r.errors, oe, y.name) : D(r.errors, y.name, oe[y.name]) : ee(r.errors, y.name));
|
|
965
|
+
}
|
|
966
|
+
!ae($) && await le($, l, d);
|
|
967
|
+
}
|
|
968
|
+
}
|
|
969
|
+
return d.valid;
|
|
970
|
+
}, Te = () => {
|
|
971
|
+
for (const u of a.unMount) {
|
|
972
|
+
const l = k(n, u);
|
|
973
|
+
l && (l._f.refs ? l._f.refs.every((d) => !kt(d)) : !kt(l._f.ref)) && be(u);
|
|
974
|
+
}
|
|
975
|
+
a.unMount = /* @__PURE__ */ new Set();
|
|
976
|
+
}, T = (u, l) => !t.disabled && (u && l && D(o, u, l), !ye(p(), s)), R = (u, l, d) => Et(u, a, {
|
|
977
|
+
...i.mount ? o : J(l) ? s : pe(u) ? { [u]: l } : l
|
|
978
|
+
}, d, l), H = (u) => Ft(k(i.mount ? o : s, u, t.shouldUnregister ? k(s, u, []) : [])), X = (u, l, d = {}) => {
|
|
979
|
+
const x = k(n, u);
|
|
980
|
+
let w = l;
|
|
981
|
+
if (x) {
|
|
982
|
+
const y = x._f;
|
|
983
|
+
y && (!y.disabled && D(o, u, Xr(l, y)), w = it(y.ref) && de(l) ? "" : l, Gr(y.ref) ? [...y.ref.options].forEach(($) => $.selected = w.includes($.value)) : y.refs ? Qe(y.ref) ? y.refs.forEach(($) => {
|
|
984
|
+
(!$.defaultChecked || !$.disabled) && (Array.isArray(w) ? $.checked = !!w.find((C) => C === $.value) : $.checked = w === $.value || !!w);
|
|
985
|
+
}) : y.refs.forEach(($) => $.checked = $.value === w) : Vt(y.ref) ? y.ref.value = "" : (y.ref.value = w, y.ref.type || v.state.next({
|
|
986
|
+
name: u,
|
|
987
|
+
values: Q(o)
|
|
988
|
+
})));
|
|
989
|
+
}
|
|
990
|
+
(d.shouldDirty || d.shouldTouch) && L(u, w, d.shouldTouch, d.shouldDirty, !0), d.shouldValidate && Se(u);
|
|
991
|
+
}, fe = (u, l, d) => {
|
|
992
|
+
for (const x in l) {
|
|
993
|
+
if (!l.hasOwnProperty(x))
|
|
994
|
+
return;
|
|
995
|
+
const w = l[x], y = u + "." + x, $ = k(n, y);
|
|
996
|
+
(a.array.has(u) || te(w) || $ && !$._f) && !Oe(w) ? fe(y, w, d) : X(y, w, d);
|
|
997
|
+
}
|
|
998
|
+
}, se = (u, l, d = {}) => {
|
|
999
|
+
const x = k(n, u), w = a.array.has(u), y = Q(l);
|
|
1000
|
+
D(o, u, y), w ? (v.array.next({
|
|
1001
|
+
name: u,
|
|
1002
|
+
values: Q(o)
|
|
1003
|
+
}), (g.isDirty || g.dirtyFields || b.isDirty || b.dirtyFields) && d.shouldDirty && v.state.next({
|
|
1004
|
+
name: u,
|
|
1005
|
+
dirtyFields: Ve(s, o),
|
|
1006
|
+
isDirty: T(u, y)
|
|
1007
|
+
})) : x && !x._f && !de(y) ? fe(u, y, d) : X(u, y, d), lr(u, a) ? v.state.next({
|
|
1008
|
+
...r,
|
|
1009
|
+
name: u,
|
|
1010
|
+
values: Q(o)
|
|
1011
|
+
}) : v.state.next({
|
|
1012
|
+
name: i.mount ? u : void 0,
|
|
1013
|
+
values: Q(o)
|
|
1014
|
+
});
|
|
1015
|
+
}, ke = async (u) => {
|
|
1016
|
+
i.mount = !0;
|
|
1017
|
+
const l = u.target;
|
|
1018
|
+
let d = l.name, x = !0;
|
|
1019
|
+
const w = k(n, d), y = (V) => {
|
|
1020
|
+
x = Number.isNaN(V) || Oe(V) && isNaN(V.getTime()) || ye(V, k(o, d, V));
|
|
1021
|
+
}, $ = ur(t.mode), C = ur(t.reValidateMode);
|
|
1022
|
+
if (w) {
|
|
1023
|
+
let V, oe;
|
|
1024
|
+
const Ne = l.type ? ar(w._f) : Jr(u), xe = u.type === ot.BLUR || u.type === ot.FOCUS_OUT, Rn = !ts(w._f) && !t.resolver && !k(r.errors, d) && !w._f.deps || ss(xe, k(r.touchedFields, d), r.isSubmitted, C, $), bt = lr(d, a, xe);
|
|
1025
|
+
D(o, d, Ne), xe ? (!l || !l.readOnly) && (w._f.onBlur && w._f.onBlur(u), c && c(0)) : w._f.onChange && w._f.onChange(u);
|
|
1026
|
+
const wt = L(d, Ne, xe), In = !ae(wt) || bt;
|
|
1027
|
+
if (!xe && v.state.next({
|
|
1028
|
+
name: d,
|
|
1029
|
+
type: u.type,
|
|
1030
|
+
values: Q(o)
|
|
1031
|
+
}), Rn)
|
|
1032
|
+
return (g.isValid || b.isValid) && (t.mode === "onBlur" ? xe && I() : xe || I()), In && v.state.next({ name: d, ...bt ? {} : wt });
|
|
1033
|
+
if (!xe && bt && v.state.next({ ...r }), t.resolver) {
|
|
1034
|
+
const { errors: Kt } = await ve([d]);
|
|
1035
|
+
if (F([d]), y(Ne), x) {
|
|
1036
|
+
const Cn = fr(r.errors, n, d), Xt = fr(Kt, n, Cn.name || d);
|
|
1037
|
+
V = Xt.error, d = Xt.name, oe = ae(Kt);
|
|
1038
|
+
}
|
|
1039
|
+
} else
|
|
1040
|
+
F([d], !0), V = (await hr(w, a.disabled, o, Z, t.shouldUseNativeValidation))[d], F([d]), y(Ne), x && (V ? oe = !1 : (g.isValid || b.isValid) && (oe = await le(n, !0)));
|
|
1041
|
+
x && (w._f.deps && (!Array.isArray(w._f.deps) || w._f.deps.length > 0) && Se(w._f.deps), re(d, oe, V, wt));
|
|
1042
|
+
}
|
|
1043
|
+
}, ze = (u, l) => {
|
|
1044
|
+
if (k(r.errors, l) && u.focus)
|
|
1045
|
+
return u.focus(), 1;
|
|
1046
|
+
}, Se = async (u, l = {}) => {
|
|
1047
|
+
let d, x;
|
|
1048
|
+
const w = Ge(u);
|
|
1049
|
+
if (t.resolver) {
|
|
1050
|
+
const y = await ce(J(u) ? u : w);
|
|
1051
|
+
d = ae(y), x = u ? !w.some(($) => k(y, $)) : d;
|
|
1052
|
+
} else u ? (x = (await Promise.all(w.map(async (y) => {
|
|
1053
|
+
const $ = k(n, y);
|
|
1054
|
+
return await le($ && $._f ? { [y]: $ } : $);
|
|
1055
|
+
}))).every(Boolean), !(!x && !r.isValid) && I()) : x = d = await le(n);
|
|
1056
|
+
return v.state.next({
|
|
1057
|
+
...!pe(u) || (g.isValid || b.isValid) && d !== r.isValid ? {} : { name: u },
|
|
1058
|
+
...t.resolver || !u ? { isValid: d } : {},
|
|
1059
|
+
errors: r.errors
|
|
1060
|
+
}), l.shouldFocus && !x && He(n, ze, u ? w : a.mount), x;
|
|
1061
|
+
}, p = (u, l) => {
|
|
1062
|
+
let d = {
|
|
1063
|
+
...i.mount ? o : s
|
|
1064
|
+
};
|
|
1065
|
+
return l && (d = Yr(l.dirtyFields ? r.dirtyFields : r.touchedFields, d)), J(u) ? d : pe(u) ? k(d, u) : u.map((x) => k(d, x));
|
|
1066
|
+
}, A = (u, l) => ({
|
|
1067
|
+
invalid: !!k((l || r).errors, u),
|
|
1068
|
+
isDirty: !!k((l || r).dirtyFields, u),
|
|
1069
|
+
error: k((l || r).errors, u),
|
|
1070
|
+
isValidating: !!k(r.validatingFields, u),
|
|
1071
|
+
isTouched: !!k((l || r).touchedFields, u)
|
|
1072
|
+
}), M = (u) => {
|
|
1073
|
+
u && Ge(u).forEach((l) => ee(r.errors, l)), v.state.next({
|
|
1074
|
+
errors: u ? r.errors : {}
|
|
1075
|
+
});
|
|
1076
|
+
}, G = (u, l, d) => {
|
|
1077
|
+
const x = (k(n, u, { _f: {} })._f || {}).ref, w = k(r.errors, u) || {}, { ref: y, message: $, type: C, ...V } = w;
|
|
1078
|
+
D(r.errors, u, {
|
|
1079
|
+
...V,
|
|
1080
|
+
...l,
|
|
1081
|
+
ref: x
|
|
1082
|
+
}), v.state.next({
|
|
1083
|
+
name: u,
|
|
1084
|
+
errors: r.errors,
|
|
1085
|
+
isValid: !1
|
|
1086
|
+
}), d && d.shouldFocus && x && x.focus && x.focus();
|
|
1087
|
+
}, Fe = (u, l) => ue(u) ? v.state.subscribe({
|
|
1088
|
+
next: (d) => "values" in d && u(R(void 0, l), d)
|
|
1089
|
+
}) : R(u, l, !0), Pe = (u) => v.state.subscribe({
|
|
1090
|
+
next: (l) => {
|
|
1091
|
+
ns(u.name, l.name, u.exact) && rs(l, u.formState || g, Pn, u.reRenderRoot) && u.callback({
|
|
1092
|
+
values: { ...o },
|
|
1093
|
+
...r,
|
|
1094
|
+
...l,
|
|
1095
|
+
defaultValues: s
|
|
1096
|
+
});
|
|
1097
|
+
}
|
|
1098
|
+
}).unsubscribe, K = (u) => (i.mount = !0, b = {
|
|
1099
|
+
...b,
|
|
1100
|
+
...u.formState
|
|
1101
|
+
}, Pe({
|
|
1102
|
+
...u,
|
|
1103
|
+
formState: {
|
|
1104
|
+
..._,
|
|
1105
|
+
...u.formState
|
|
1106
|
+
}
|
|
1107
|
+
})), be = (u, l = {}) => {
|
|
1108
|
+
for (const d of u ? Ge(u) : a.mount)
|
|
1109
|
+
a.mount.delete(d), a.array.delete(d), l.keepValue || (ee(n, d), ee(o, d)), !l.keepError && ee(r.errors, d), !l.keepDirty && ee(r.dirtyFields, d), !l.keepTouched && ee(r.touchedFields, d), !l.keepIsValidating && ee(r.validatingFields, d), !t.shouldUnregister && !l.keepDefaultValue && ee(s, d);
|
|
1110
|
+
v.state.next({
|
|
1111
|
+
values: Q(o)
|
|
1112
|
+
}), v.state.next({
|
|
1113
|
+
...r,
|
|
1114
|
+
...l.keepDirty ? { isDirty: T() } : {}
|
|
1115
|
+
}), !l.keepIsValid && I();
|
|
1116
|
+
}, Re = ({ disabled: u, name: l }) => {
|
|
1117
|
+
if (me(u) && i.mount || u || a.disabled.has(l)) {
|
|
1118
|
+
const w = a.disabled.has(l) !== !!u;
|
|
1119
|
+
u ? a.disabled.add(l) : a.disabled.delete(l), w && i.mount && !i.action && I();
|
|
1120
|
+
}
|
|
1121
|
+
}, Je = (u, l = {}) => {
|
|
1122
|
+
let d = k(n, u);
|
|
1123
|
+
const x = me(l.disabled) || me(t.disabled);
|
|
1124
|
+
return D(n, u, {
|
|
1125
|
+
...d || {},
|
|
1126
|
+
_f: {
|
|
1127
|
+
...d && d._f ? d._f : { ref: { name: u } },
|
|
1128
|
+
name: u,
|
|
1129
|
+
mount: !0,
|
|
1130
|
+
...l
|
|
1131
|
+
}
|
|
1132
|
+
}), a.mount.add(u), d ? Re({
|
|
1133
|
+
disabled: me(l.disabled) ? l.disabled : t.disabled,
|
|
1134
|
+
name: u
|
|
1135
|
+
}) : S(u, !0, l.value), {
|
|
1136
|
+
...x ? { disabled: l.disabled || t.disabled } : {},
|
|
1137
|
+
...t.progressive ? {
|
|
1138
|
+
required: !!l.required,
|
|
1139
|
+
min: qe(l.min),
|
|
1140
|
+
max: qe(l.max),
|
|
1141
|
+
minLength: qe(l.minLength),
|
|
1142
|
+
maxLength: qe(l.maxLength),
|
|
1143
|
+
pattern: qe(l.pattern)
|
|
1144
|
+
} : {},
|
|
1145
|
+
name: u,
|
|
1146
|
+
onChange: ke,
|
|
1147
|
+
onBlur: ke,
|
|
1148
|
+
ref: (w) => {
|
|
1149
|
+
if (w) {
|
|
1150
|
+
Je(u, l), d = k(n, u);
|
|
1151
|
+
const y = J(w.value) && w.querySelectorAll && w.querySelectorAll("input,select,textarea")[0] || w, $ = Gn(y), C = d._f.refs || [];
|
|
1152
|
+
if ($ ? C.find((V) => V === y) : y === d._f.ref)
|
|
1153
|
+
return;
|
|
1154
|
+
D(n, u, {
|
|
1155
|
+
_f: {
|
|
1156
|
+
...d._f,
|
|
1157
|
+
...$ ? {
|
|
1158
|
+
refs: [
|
|
1159
|
+
...C.filter(kt),
|
|
1160
|
+
y,
|
|
1161
|
+
...Array.isArray(k(s, u)) ? [{}] : []
|
|
1162
|
+
],
|
|
1163
|
+
ref: { type: y.type, name: u }
|
|
1164
|
+
} : { ref: y }
|
|
1165
|
+
}
|
|
1166
|
+
}), S(u, !1, void 0, y);
|
|
1167
|
+
} else
|
|
1168
|
+
d = k(n, u, {}), d._f && (d._f.mount = !1), (t.shouldUnregister || l.shouldUnregister) && !(Br(a.array, u) && i.action) && a.unMount.add(u);
|
|
1169
|
+
}
|
|
1170
|
+
};
|
|
1171
|
+
}, yt = () => t.shouldFocusError && He(n, ze, a.mount), Zn = (u) => {
|
|
1172
|
+
me(u) && (v.state.next({ disabled: u }), He(n, (l, d) => {
|
|
1173
|
+
const x = k(n, d);
|
|
1174
|
+
x && (l.disabled = x._f.disabled || u, Array.isArray(x._f.refs) && x._f.refs.forEach((w) => {
|
|
1175
|
+
w.disabled = x._f.disabled || u;
|
|
1176
|
+
}));
|
|
1177
|
+
}, 0, !1));
|
|
1178
|
+
}, qt = (u, l) => async (d) => {
|
|
1179
|
+
let x;
|
|
1180
|
+
d && (d.preventDefault && d.preventDefault(), d.persist && d.persist());
|
|
1181
|
+
let w = Q(o);
|
|
1182
|
+
if (v.state.next({
|
|
1183
|
+
isSubmitting: !0
|
|
1184
|
+
}), t.resolver) {
|
|
1185
|
+
const { errors: y, values: $ } = await ve();
|
|
1186
|
+
F(), r.errors = y, w = Q($);
|
|
1187
|
+
} else
|
|
1188
|
+
await le(n);
|
|
1189
|
+
if (a.disabled.size)
|
|
1190
|
+
for (const y of a.disabled)
|
|
1191
|
+
ee(w, y);
|
|
1192
|
+
if (ee(r.errors, "root"), ae(r.errors)) {
|
|
1193
|
+
v.state.next({
|
|
1194
|
+
errors: {}
|
|
1195
|
+
});
|
|
1196
|
+
try {
|
|
1197
|
+
await u(w, d);
|
|
1198
|
+
} catch (y) {
|
|
1199
|
+
x = y;
|
|
1200
|
+
}
|
|
1201
|
+
} else
|
|
1202
|
+
l && await l({ ...r.errors }, d), yt(), setTimeout(yt);
|
|
1203
|
+
if (v.state.next({
|
|
1204
|
+
isSubmitted: !0,
|
|
1205
|
+
isSubmitting: !1,
|
|
1206
|
+
isSubmitSuccessful: ae(r.errors) && !x,
|
|
1207
|
+
submitCount: r.submitCount + 1,
|
|
1208
|
+
errors: r.errors
|
|
1209
|
+
}), x)
|
|
1210
|
+
throw x;
|
|
1211
|
+
}, Tn = (u, l = {}) => {
|
|
1212
|
+
k(n, u) && (J(l.defaultValue) ? se(u, Q(k(s, u))) : (se(u, l.defaultValue), D(s, u, Q(l.defaultValue))), l.keepTouched || ee(r.touchedFields, u), l.keepDirty || (ee(r.dirtyFields, u), r.isDirty = l.defaultValue ? T(u, Q(k(s, u))) : T()), l.keepError || (ee(r.errors, u), g.isValid && I()), v.state.next({ ...r }));
|
|
1213
|
+
}, Yt = (u, l = {}) => {
|
|
1214
|
+
const d = u ? Q(u) : s, x = Q(d), w = ae(u), y = w ? s : x;
|
|
1215
|
+
if (l.keepDefaultValues || (s = d), !l.keepValues) {
|
|
1216
|
+
if (l.keepDirtyValues) {
|
|
1217
|
+
const $ = /* @__PURE__ */ new Set([
|
|
1218
|
+
...a.mount,
|
|
1219
|
+
...Object.keys(Ve(s, o))
|
|
1220
|
+
]);
|
|
1221
|
+
for (const C of Array.from($)) {
|
|
1222
|
+
const V = k(r.dirtyFields, C), oe = k(o, C), Ne = k(y, C);
|
|
1223
|
+
V && !J(oe) ? D(y, C, oe) : !V && !J(Ne) && se(C, Ne);
|
|
1224
|
+
}
|
|
1225
|
+
} else {
|
|
1226
|
+
if (Tt && J(u))
|
|
1227
|
+
for (const $ of a.mount) {
|
|
1228
|
+
const C = k(n, $);
|
|
1229
|
+
if (C && C._f) {
|
|
1230
|
+
const V = Array.isArray(C._f.refs) ? C._f.refs[0] : C._f.ref;
|
|
1231
|
+
if (it(V)) {
|
|
1232
|
+
const oe = V.closest("form");
|
|
1233
|
+
if (oe) {
|
|
1234
|
+
oe.reset();
|
|
1235
|
+
break;
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
if (l.keepFieldsRef)
|
|
1241
|
+
for (const $ of a.mount)
|
|
1242
|
+
se($, k(y, $));
|
|
1243
|
+
else
|
|
1244
|
+
n = {};
|
|
1245
|
+
}
|
|
1246
|
+
o = t.shouldUnregister ? l.keepDefaultValues ? Q(s) : {} : Q(y), v.array.next({
|
|
1247
|
+
values: { ...y }
|
|
1248
|
+
}), v.state.next({
|
|
1249
|
+
values: { ...y }
|
|
1250
|
+
});
|
|
1251
|
+
}
|
|
1252
|
+
a = {
|
|
1253
|
+
mount: l.keepDirtyValues ? a.mount : /* @__PURE__ */ new Set(),
|
|
1254
|
+
unMount: /* @__PURE__ */ new Set(),
|
|
1255
|
+
array: /* @__PURE__ */ new Set(),
|
|
1256
|
+
disabled: /* @__PURE__ */ new Set(),
|
|
1257
|
+
watch: /* @__PURE__ */ new Set(),
|
|
1258
|
+
watchAll: !1,
|
|
1259
|
+
focus: ""
|
|
1260
|
+
}, i.mount = !g.isValid || !!l.keepIsValid || !!l.keepDirtyValues || !t.shouldUnregister && !ae(y), i.watch = !!t.shouldUnregister, i.keepIsValid = !!l.keepIsValid, i.action = !1, l.keepErrors || (r.errors = {}), v.state.next({
|
|
1261
|
+
submitCount: l.keepSubmitCount ? r.submitCount : 0,
|
|
1262
|
+
isDirty: w ? !1 : l.keepDirty ? r.isDirty : !!(l.keepDefaultValues && !ye(u, s)),
|
|
1263
|
+
isSubmitted: l.keepIsSubmitted ? r.isSubmitted : !1,
|
|
1264
|
+
dirtyFields: w ? {} : l.keepDirtyValues ? l.keepDefaultValues && o ? Ve(s, o) : r.dirtyFields : l.keepDefaultValues && u ? Ve(s, u) : l.keepDirty ? r.dirtyFields : {},
|
|
1265
|
+
touchedFields: l.keepTouched ? r.touchedFields : {},
|
|
1266
|
+
errors: l.keepErrors ? r.errors : {},
|
|
1267
|
+
isSubmitSuccessful: l.keepIsSubmitSuccessful ? r.isSubmitSuccessful : !1,
|
|
1268
|
+
isSubmitting: !1,
|
|
1269
|
+
defaultValues: s
|
|
1270
|
+
});
|
|
1271
|
+
}, Gt = (u, l) => Yt(ue(u) ? u(o) : u, { ...t.resetOptions, ...l }), Fn = (u, l = {}) => {
|
|
1272
|
+
const d = k(n, u), x = d && d._f;
|
|
1273
|
+
if (x) {
|
|
1274
|
+
const w = x.refs ? x.refs[0] : x.ref;
|
|
1275
|
+
w.focus && setTimeout(() => {
|
|
1276
|
+
w.focus(), l.shouldSelect && ue(w.select) && w.select();
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
}, Pn = (u) => {
|
|
1280
|
+
r = {
|
|
1281
|
+
...r,
|
|
1282
|
+
...u
|
|
1283
|
+
};
|
|
1284
|
+
}, Ht = {
|
|
1285
|
+
control: {
|
|
1286
|
+
register: Je,
|
|
1287
|
+
unregister: be,
|
|
1288
|
+
getFieldState: A,
|
|
1289
|
+
handleSubmit: qt,
|
|
1290
|
+
setError: G,
|
|
1291
|
+
_subscribe: Pe,
|
|
1292
|
+
_runSchema: ve,
|
|
1293
|
+
_updateIsValidating: F,
|
|
1294
|
+
_focusError: yt,
|
|
1295
|
+
_getWatch: R,
|
|
1296
|
+
_getDirty: T,
|
|
1297
|
+
_setValid: I,
|
|
1298
|
+
_setFieldArray: N,
|
|
1299
|
+
_setDisabledField: Re,
|
|
1300
|
+
_setErrors: z,
|
|
1301
|
+
_getFieldArray: H,
|
|
1302
|
+
_reset: Yt,
|
|
1303
|
+
_resetDefaultValues: () => ue(t.defaultValues) && t.defaultValues().then((u) => {
|
|
1304
|
+
Gt(u, t.resetOptions), v.state.next({
|
|
1305
|
+
isLoading: !1
|
|
1306
|
+
});
|
|
1307
|
+
}),
|
|
1308
|
+
_removeUnmounted: Te,
|
|
1309
|
+
_disableForm: Zn,
|
|
1310
|
+
_subjects: v,
|
|
1311
|
+
_proxyFormState: g,
|
|
1312
|
+
get _fields() {
|
|
1313
|
+
return n;
|
|
1314
|
+
},
|
|
1315
|
+
get _formValues() {
|
|
1316
|
+
return o;
|
|
1317
|
+
},
|
|
1318
|
+
get _state() {
|
|
1319
|
+
return i;
|
|
1320
|
+
},
|
|
1321
|
+
set _state(u) {
|
|
1322
|
+
i = u;
|
|
1323
|
+
},
|
|
1324
|
+
get _defaultValues() {
|
|
1325
|
+
return s;
|
|
1326
|
+
},
|
|
1327
|
+
get _names() {
|
|
1328
|
+
return a;
|
|
1329
|
+
},
|
|
1330
|
+
set _names(u) {
|
|
1331
|
+
a = u;
|
|
1332
|
+
},
|
|
1333
|
+
get _formState() {
|
|
1334
|
+
return r;
|
|
1335
|
+
},
|
|
1336
|
+
get _options() {
|
|
1337
|
+
return t;
|
|
1338
|
+
},
|
|
1339
|
+
set _options(u) {
|
|
1340
|
+
t = {
|
|
1341
|
+
...t,
|
|
1342
|
+
...u
|
|
1343
|
+
};
|
|
1344
|
+
}
|
|
1345
|
+
},
|
|
1346
|
+
subscribe: K,
|
|
1347
|
+
trigger: Se,
|
|
1348
|
+
register: Je,
|
|
1349
|
+
handleSubmit: qt,
|
|
1350
|
+
watch: Fe,
|
|
1351
|
+
setValue: se,
|
|
1352
|
+
getValues: p,
|
|
1353
|
+
reset: Gt,
|
|
1354
|
+
resetField: Tn,
|
|
1355
|
+
clearErrors: M,
|
|
1356
|
+
unregister: be,
|
|
1357
|
+
setError: G,
|
|
1358
|
+
setFocus: Fn,
|
|
1359
|
+
getFieldState: A
|
|
1360
|
+
};
|
|
1361
|
+
return {
|
|
1362
|
+
...Ht,
|
|
1363
|
+
formControl: Ht
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
function cs(e = {}) {
|
|
1367
|
+
const t = j.useRef(void 0), r = j.useRef(void 0), [n, s] = j.useState({
|
|
1368
|
+
isDirty: !1,
|
|
1369
|
+
isValidating: !1,
|
|
1370
|
+
isLoading: ue(e.defaultValues),
|
|
1371
|
+
isSubmitted: !1,
|
|
1372
|
+
isSubmitting: !1,
|
|
1373
|
+
isSubmitSuccessful: !1,
|
|
1374
|
+
isValid: !1,
|
|
1375
|
+
submitCount: 0,
|
|
1376
|
+
dirtyFields: {},
|
|
1377
|
+
touchedFields: {},
|
|
1378
|
+
validatingFields: {},
|
|
1379
|
+
errors: e.errors || {},
|
|
1380
|
+
disabled: e.disabled || !1,
|
|
1381
|
+
isReady: !1,
|
|
1382
|
+
defaultValues: ue(e.defaultValues) ? void 0 : e.defaultValues
|
|
1383
|
+
});
|
|
1384
|
+
if (!t.current)
|
|
1385
|
+
if (e.formControl)
|
|
1386
|
+
t.current = {
|
|
1387
|
+
...e.formControl,
|
|
1388
|
+
formState: n
|
|
1389
|
+
}, e.defaultValues && !ue(e.defaultValues) && e.formControl.reset(e.defaultValues, e.resetOptions);
|
|
1390
|
+
else {
|
|
1391
|
+
const { formControl: i, ...a } = us(e);
|
|
1392
|
+
t.current = {
|
|
1393
|
+
...a,
|
|
1394
|
+
formState: n
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
const o = t.current.control;
|
|
1398
|
+
return o._options = e, It(() => {
|
|
1399
|
+
const i = o._subscribe({
|
|
1400
|
+
formState: o._proxyFormState,
|
|
1401
|
+
callback: () => s({ ...o._formState }),
|
|
1402
|
+
reRenderRoot: !0
|
|
1403
|
+
});
|
|
1404
|
+
return s((a) => ({
|
|
1405
|
+
...a,
|
|
1406
|
+
isReady: !0
|
|
1407
|
+
})), o._formState.isReady = !0, i;
|
|
1408
|
+
}, [o]), j.useEffect(() => o._disableForm(e.disabled), [o, e.disabled]), j.useEffect(() => {
|
|
1409
|
+
e.mode && (o._options.mode = e.mode), e.reValidateMode && (o._options.reValidateMode = e.reValidateMode);
|
|
1410
|
+
}, [o, e.mode, e.reValidateMode]), j.useEffect(() => {
|
|
1411
|
+
e.errors && (o._setErrors(e.errors), o._focusError());
|
|
1412
|
+
}, [o, e.errors]), j.useEffect(() => {
|
|
1413
|
+
e.shouldUnregister && o._subjects.state.next({
|
|
1414
|
+
values: o._getWatch()
|
|
1415
|
+
});
|
|
1416
|
+
}, [o, e.shouldUnregister]), j.useEffect(() => {
|
|
1417
|
+
if (o._proxyFormState.isDirty) {
|
|
1418
|
+
const i = o._getDirty();
|
|
1419
|
+
i !== n.isDirty && o._subjects.state.next({
|
|
1420
|
+
isDirty: i
|
|
1421
|
+
});
|
|
1422
|
+
}
|
|
1423
|
+
}, [o, n.isDirty]), j.useEffect(() => {
|
|
1424
|
+
var i;
|
|
1425
|
+
e.values && !ye(e.values, r.current) ? (o._reset(e.values, {
|
|
1426
|
+
keepFieldsRef: !0,
|
|
1427
|
+
...o._options.resetOptions
|
|
1428
|
+
}), !((i = o._options.resetOptions) === null || i === void 0) && i.keepIsValid || o._setValid(), r.current = e.values, s((a) => ({ ...a }))) : o._resetDefaultValues();
|
|
1429
|
+
}, [o, e.values]), j.useEffect(() => {
|
|
1430
|
+
o._state.mount || (o._setValid(), o._state.mount = !0), o._state.watch && (o._state.watch = !1, o._subjects.state.next({ ...o._formState })), o._removeUnmounted();
|
|
1431
|
+
}), t.current.formState = j.useMemo(() => qr(n, o), [o, n]), t.current;
|
|
1432
|
+
}
|
|
1433
|
+
const mr = (e, t, r) => {
|
|
1434
|
+
if (e && "reportValidity" in e) {
|
|
1435
|
+
const n = k(r, t);
|
|
1436
|
+
e.setCustomValidity(n && n.message || ""), e.reportValidity();
|
|
1437
|
+
}
|
|
1438
|
+
}, Ot = (e, t) => {
|
|
1439
|
+
for (const r in t.fields) {
|
|
1440
|
+
const n = t.fields[r];
|
|
1441
|
+
n && n.ref && "reportValidity" in n.ref ? mr(n.ref, r, e) : n && n.refs && n.refs.forEach((s) => mr(s, r, e));
|
|
1442
|
+
}
|
|
1443
|
+
}, pr = (e, t) => {
|
|
1444
|
+
t.shouldUseNativeValidation && Ot(e, t);
|
|
1445
|
+
const r = {};
|
|
1446
|
+
for (const n in e) {
|
|
1447
|
+
const s = k(t.fields, n), o = Object.assign(e[n] || {}, { ref: s && s.ref });
|
|
1448
|
+
if (ls(t.names || Object.keys(e), n)) {
|
|
1449
|
+
const i = Object.assign({}, k(r, n));
|
|
1450
|
+
D(i, "root", o), D(r, n, i);
|
|
1451
|
+
} else D(r, n, o);
|
|
1452
|
+
}
|
|
1453
|
+
return r;
|
|
1454
|
+
}, ls = (e, t) => {
|
|
1455
|
+
const r = vr(t);
|
|
1456
|
+
return e.some((n) => vr(n).match(`^${r}\\.\\d+`));
|
|
1457
|
+
};
|
|
1458
|
+
function vr(e) {
|
|
1459
|
+
return e.replace(/\]|\[/g, "");
|
|
1460
|
+
}
|
|
1461
|
+
function h(e, t, r) {
|
|
1462
|
+
function n(a, c) {
|
|
1463
|
+
if (a._zod || Object.defineProperty(a, "_zod", {
|
|
1464
|
+
value: {
|
|
1465
|
+
def: c,
|
|
1466
|
+
constr: i,
|
|
1467
|
+
traits: /* @__PURE__ */ new Set()
|
|
1468
|
+
},
|
|
1469
|
+
enumerable: !1
|
|
1470
|
+
}), a._zod.traits.has(e))
|
|
1471
|
+
return;
|
|
1472
|
+
a._zod.traits.add(e), t(a, c);
|
|
1473
|
+
const f = i.prototype, _ = Object.keys(f);
|
|
1474
|
+
for (let g = 0; g < _.length; g++) {
|
|
1475
|
+
const b = _[g];
|
|
1476
|
+
b in a || (a[b] = f[b].bind(a));
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
const s = r?.Parent ?? Object;
|
|
1480
|
+
class o extends s {
|
|
1481
|
+
}
|
|
1482
|
+
Object.defineProperty(o, "name", { value: e });
|
|
1483
|
+
function i(a) {
|
|
1484
|
+
var c;
|
|
1485
|
+
const f = r?.Parent ? new o() : this;
|
|
1486
|
+
n(f, a), (c = f._zod).deferred ?? (c.deferred = []);
|
|
1487
|
+
for (const _ of f._zod.deferred)
|
|
1488
|
+
_();
|
|
1489
|
+
return f;
|
|
1490
|
+
}
|
|
1491
|
+
return Object.defineProperty(i, "init", { value: n }), Object.defineProperty(i, Symbol.hasInstance, {
|
|
1492
|
+
value: (a) => r?.Parent && a instanceof r.Parent ? !0 : a?._zod?.traits?.has(e)
|
|
1493
|
+
}), Object.defineProperty(i, "name", { value: e }), i;
|
|
1494
|
+
}
|
|
1495
|
+
class Ue extends Error {
|
|
1496
|
+
constructor() {
|
|
1497
|
+
super("Encountered Promise during synchronous parse. Use .parseAsync() instead.");
|
|
1498
|
+
}
|
|
1499
|
+
}
|
|
1500
|
+
class en extends Error {
|
|
1501
|
+
constructor(t) {
|
|
1502
|
+
super(`Encountered unidirectional transform during encode: ${t}`), this.name = "ZodEncodeError";
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1505
|
+
const tn = {};
|
|
1506
|
+
function je(e) {
|
|
1507
|
+
return tn;
|
|
1508
|
+
}
|
|
1509
|
+
function rn(e) {
|
|
1510
|
+
const t = Object.values(e).filter((n) => typeof n == "number");
|
|
1511
|
+
return Object.entries(e).filter(([n, s]) => t.indexOf(+n) === -1).map(([n, s]) => s);
|
|
1512
|
+
}
|
|
1513
|
+
function jt(e, t) {
|
|
1514
|
+
return typeof t == "bigint" ? t.toString() : t;
|
|
1515
|
+
}
|
|
1516
|
+
function Ut(e) {
|
|
1517
|
+
return {
|
|
1518
|
+
get value() {
|
|
1519
|
+
{
|
|
1520
|
+
const t = e();
|
|
1521
|
+
return Object.defineProperty(this, "value", { value: t }), t;
|
|
1522
|
+
}
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
}
|
|
1526
|
+
function Lt(e) {
|
|
1527
|
+
return e == null;
|
|
1528
|
+
}
|
|
1529
|
+
function Mt(e) {
|
|
1530
|
+
const t = e.startsWith("^") ? 1 : 0, r = e.endsWith("$") ? e.length - 1 : e.length;
|
|
1531
|
+
return e.slice(t, r);
|
|
1532
|
+
}
|
|
1533
|
+
function fs(e, t) {
|
|
1534
|
+
const r = (e.toString().split(".")[1] || "").length, n = t.toString();
|
|
1535
|
+
let s = (n.split(".")[1] || "").length;
|
|
1536
|
+
if (s === 0 && /\d?e-\d?/.test(n)) {
|
|
1537
|
+
const c = n.match(/\d?e-(\d?)/);
|
|
1538
|
+
c?.[1] && (s = Number.parseInt(c[1]));
|
|
1539
|
+
}
|
|
1540
|
+
const o = r > s ? r : s, i = Number.parseInt(e.toFixed(o).replace(".", "")), a = Number.parseInt(t.toFixed(o).replace(".", ""));
|
|
1541
|
+
return i % a / 10 ** o;
|
|
1542
|
+
}
|
|
1543
|
+
const gr = /* @__PURE__ */ Symbol("evaluating");
|
|
1544
|
+
function U(e, t, r) {
|
|
1545
|
+
let n;
|
|
1546
|
+
Object.defineProperty(e, t, {
|
|
1547
|
+
get() {
|
|
1548
|
+
if (n !== gr)
|
|
1549
|
+
return n === void 0 && (n = gr, n = r()), n;
|
|
1550
|
+
},
|
|
1551
|
+
set(s) {
|
|
1552
|
+
Object.defineProperty(e, t, {
|
|
1553
|
+
value: s
|
|
1554
|
+
// configurable: true,
|
|
1555
|
+
});
|
|
1556
|
+
},
|
|
1557
|
+
configurable: !0
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
function Ze(e, t, r) {
|
|
1561
|
+
Object.defineProperty(e, t, {
|
|
1562
|
+
value: r,
|
|
1563
|
+
writable: !0,
|
|
1564
|
+
enumerable: !0,
|
|
1565
|
+
configurable: !0
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
function Ee(...e) {
|
|
1569
|
+
const t = {};
|
|
1570
|
+
for (const r of e) {
|
|
1571
|
+
const n = Object.getOwnPropertyDescriptors(r);
|
|
1572
|
+
Object.assign(t, n);
|
|
1573
|
+
}
|
|
1574
|
+
return Object.defineProperties({}, t);
|
|
1575
|
+
}
|
|
1576
|
+
function _r(e) {
|
|
1577
|
+
return JSON.stringify(e);
|
|
1578
|
+
}
|
|
1579
|
+
function ds(e) {
|
|
1580
|
+
return e.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
1581
|
+
}
|
|
1582
|
+
const nn = "captureStackTrace" in Error ? Error.captureStackTrace : (...e) => {
|
|
1583
|
+
};
|
|
1584
|
+
function ut(e) {
|
|
1585
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
1586
|
+
}
|
|
1587
|
+
const hs = Ut(() => {
|
|
1588
|
+
if (typeof navigator < "u" && navigator?.userAgent?.includes("Cloudflare"))
|
|
1589
|
+
return !1;
|
|
1590
|
+
try {
|
|
1591
|
+
const e = Function;
|
|
1592
|
+
return new e(""), !0;
|
|
1593
|
+
} catch {
|
|
1594
|
+
return !1;
|
|
1595
|
+
}
|
|
1596
|
+
});
|
|
1597
|
+
function Ke(e) {
|
|
1598
|
+
if (ut(e) === !1)
|
|
1599
|
+
return !1;
|
|
1600
|
+
const t = e.constructor;
|
|
1601
|
+
if (t === void 0 || typeof t != "function")
|
|
1602
|
+
return !0;
|
|
1603
|
+
const r = t.prototype;
|
|
1604
|
+
return !(ut(r) === !1 || Object.prototype.hasOwnProperty.call(r, "isPrototypeOf") === !1);
|
|
1605
|
+
}
|
|
1606
|
+
function sn(e) {
|
|
1607
|
+
return Ke(e) ? { ...e } : Array.isArray(e) ? [...e] : e;
|
|
1608
|
+
}
|
|
1609
|
+
const ms = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
|
|
1610
|
+
function Le(e) {
|
|
1611
|
+
return e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1612
|
+
}
|
|
1613
|
+
function $e(e, t, r) {
|
|
1614
|
+
const n = new e._zod.constr(t ?? e._zod.def);
|
|
1615
|
+
return (!t || r?.parent) && (n._zod.parent = e), n;
|
|
1616
|
+
}
|
|
1617
|
+
function E(e) {
|
|
1618
|
+
const t = e;
|
|
1619
|
+
if (!t)
|
|
1620
|
+
return {};
|
|
1621
|
+
if (typeof t == "string")
|
|
1622
|
+
return { error: () => t };
|
|
1623
|
+
if (t?.message !== void 0) {
|
|
1624
|
+
if (t?.error !== void 0)
|
|
1625
|
+
throw new Error("Cannot specify both `message` and `error` params");
|
|
1626
|
+
t.error = t.message;
|
|
1627
|
+
}
|
|
1628
|
+
return delete t.message, typeof t.error == "string" ? { ...t, error: () => t.error } : t;
|
|
1629
|
+
}
|
|
1630
|
+
function ps(e) {
|
|
1631
|
+
return Object.keys(e).filter((t) => e[t]._zod.optin === "optional" && e[t]._zod.optout === "optional");
|
|
1632
|
+
}
|
|
1633
|
+
const vs = {
|
|
1634
|
+
safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
|
|
1635
|
+
int32: [-2147483648, 2147483647],
|
|
1636
|
+
uint32: [0, 4294967295],
|
|
1637
|
+
float32: [-34028234663852886e22, 34028234663852886e22],
|
|
1638
|
+
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
1639
|
+
};
|
|
1640
|
+
function gs(e, t) {
|
|
1641
|
+
const r = e._zod.def, n = r.checks;
|
|
1642
|
+
if (n && n.length > 0)
|
|
1643
|
+
throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
1644
|
+
const o = Ee(e._zod.def, {
|
|
1645
|
+
get shape() {
|
|
1646
|
+
const i = {};
|
|
1647
|
+
for (const a in t) {
|
|
1648
|
+
if (!(a in r.shape))
|
|
1649
|
+
throw new Error(`Unrecognized key: "${a}"`);
|
|
1650
|
+
t[a] && (i[a] = r.shape[a]);
|
|
1651
|
+
}
|
|
1652
|
+
return Ze(this, "shape", i), i;
|
|
1653
|
+
},
|
|
1654
|
+
checks: []
|
|
1655
|
+
});
|
|
1656
|
+
return $e(e, o);
|
|
1657
|
+
}
|
|
1658
|
+
function _s(e, t) {
|
|
1659
|
+
const r = e._zod.def, n = r.checks;
|
|
1660
|
+
if (n && n.length > 0)
|
|
1661
|
+
throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
1662
|
+
const o = Ee(e._zod.def, {
|
|
1663
|
+
get shape() {
|
|
1664
|
+
const i = { ...e._zod.def.shape };
|
|
1665
|
+
for (const a in t) {
|
|
1666
|
+
if (!(a in r.shape))
|
|
1667
|
+
throw new Error(`Unrecognized key: "${a}"`);
|
|
1668
|
+
t[a] && delete i[a];
|
|
1669
|
+
}
|
|
1670
|
+
return Ze(this, "shape", i), i;
|
|
1671
|
+
},
|
|
1672
|
+
checks: []
|
|
1673
|
+
});
|
|
1674
|
+
return $e(e, o);
|
|
1675
|
+
}
|
|
1676
|
+
function ys(e, t) {
|
|
1677
|
+
if (!Ke(t))
|
|
1678
|
+
throw new Error("Invalid input to extend: expected a plain object");
|
|
1679
|
+
const r = e._zod.def.checks;
|
|
1680
|
+
if (r && r.length > 0) {
|
|
1681
|
+
const o = e._zod.def.shape;
|
|
1682
|
+
for (const i in t)
|
|
1683
|
+
if (Object.getOwnPropertyDescriptor(o, i) !== void 0)
|
|
1684
|
+
throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
1685
|
+
}
|
|
1686
|
+
const s = Ee(e._zod.def, {
|
|
1687
|
+
get shape() {
|
|
1688
|
+
const o = { ...e._zod.def.shape, ...t };
|
|
1689
|
+
return Ze(this, "shape", o), o;
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1692
|
+
return $e(e, s);
|
|
1693
|
+
}
|
|
1694
|
+
function bs(e, t) {
|
|
1695
|
+
if (!Ke(t))
|
|
1696
|
+
throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
1697
|
+
const r = Ee(e._zod.def, {
|
|
1698
|
+
get shape() {
|
|
1699
|
+
const n = { ...e._zod.def.shape, ...t };
|
|
1700
|
+
return Ze(this, "shape", n), n;
|
|
1701
|
+
}
|
|
1702
|
+
});
|
|
1703
|
+
return $e(e, r);
|
|
1704
|
+
}
|
|
1705
|
+
function ws(e, t) {
|
|
1706
|
+
const r = Ee(e._zod.def, {
|
|
1707
|
+
get shape() {
|
|
1708
|
+
const n = { ...e._zod.def.shape, ...t._zod.def.shape };
|
|
1709
|
+
return Ze(this, "shape", n), n;
|
|
1710
|
+
},
|
|
1711
|
+
get catchall() {
|
|
1712
|
+
return t._zod.def.catchall;
|
|
1713
|
+
},
|
|
1714
|
+
checks: []
|
|
1715
|
+
// delete existing checks
|
|
1716
|
+
});
|
|
1717
|
+
return $e(e, r);
|
|
1718
|
+
}
|
|
1719
|
+
function ks(e, t, r) {
|
|
1720
|
+
const s = t._zod.def.checks;
|
|
1721
|
+
if (s && s.length > 0)
|
|
1722
|
+
throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
1723
|
+
const i = Ee(t._zod.def, {
|
|
1724
|
+
get shape() {
|
|
1725
|
+
const a = t._zod.def.shape, c = { ...a };
|
|
1726
|
+
if (r)
|
|
1727
|
+
for (const f in r) {
|
|
1728
|
+
if (!(f in a))
|
|
1729
|
+
throw new Error(`Unrecognized key: "${f}"`);
|
|
1730
|
+
r[f] && (c[f] = e ? new e({
|
|
1731
|
+
type: "optional",
|
|
1732
|
+
innerType: a[f]
|
|
1733
|
+
}) : a[f]);
|
|
1734
|
+
}
|
|
1735
|
+
else
|
|
1736
|
+
for (const f in a)
|
|
1737
|
+
c[f] = e ? new e({
|
|
1738
|
+
type: "optional",
|
|
1739
|
+
innerType: a[f]
|
|
1740
|
+
}) : a[f];
|
|
1741
|
+
return Ze(this, "shape", c), c;
|
|
1742
|
+
},
|
|
1743
|
+
checks: []
|
|
1744
|
+
});
|
|
1745
|
+
return $e(t, i);
|
|
1746
|
+
}
|
|
1747
|
+
function zs(e, t, r) {
|
|
1748
|
+
const n = Ee(t._zod.def, {
|
|
1749
|
+
get shape() {
|
|
1750
|
+
const s = t._zod.def.shape, o = { ...s };
|
|
1751
|
+
if (r)
|
|
1752
|
+
for (const i in r) {
|
|
1753
|
+
if (!(i in o))
|
|
1754
|
+
throw new Error(`Unrecognized key: "${i}"`);
|
|
1755
|
+
r[i] && (o[i] = new e({
|
|
1756
|
+
type: "nonoptional",
|
|
1757
|
+
innerType: s[i]
|
|
1758
|
+
}));
|
|
1759
|
+
}
|
|
1760
|
+
else
|
|
1761
|
+
for (const i in s)
|
|
1762
|
+
o[i] = new e({
|
|
1763
|
+
type: "nonoptional",
|
|
1764
|
+
innerType: s[i]
|
|
1765
|
+
});
|
|
1766
|
+
return Ze(this, "shape", o), o;
|
|
1767
|
+
}
|
|
1768
|
+
});
|
|
1769
|
+
return $e(t, n);
|
|
1770
|
+
}
|
|
1771
|
+
function De(e, t = 0) {
|
|
1772
|
+
if (e.aborted === !0)
|
|
1773
|
+
return !0;
|
|
1774
|
+
for (let r = t; r < e.issues.length; r++)
|
|
1775
|
+
if (e.issues[r]?.continue !== !0)
|
|
1776
|
+
return !0;
|
|
1777
|
+
return !1;
|
|
1778
|
+
}
|
|
1779
|
+
function on(e, t) {
|
|
1780
|
+
return t.map((r) => {
|
|
1781
|
+
var n;
|
|
1782
|
+
return (n = r).path ?? (n.path = []), r.path.unshift(e), r;
|
|
1783
|
+
});
|
|
1784
|
+
}
|
|
1785
|
+
function tt(e) {
|
|
1786
|
+
return typeof e == "string" ? e : e?.message;
|
|
1787
|
+
}
|
|
1788
|
+
function Ae(e, t, r) {
|
|
1789
|
+
const n = { ...e, path: e.path ?? [] };
|
|
1790
|
+
if (!e.message) {
|
|
1791
|
+
const s = tt(e.inst?._zod.def?.error?.(e)) ?? tt(t?.error?.(e)) ?? tt(r.customError?.(e)) ?? tt(r.localeError?.(e)) ?? "Invalid input";
|
|
1792
|
+
n.message = s;
|
|
1793
|
+
}
|
|
1794
|
+
return delete n.inst, delete n.continue, t?.reportInput || delete n.input, n;
|
|
1795
|
+
}
|
|
1796
|
+
function Jt(e) {
|
|
1797
|
+
return Array.isArray(e) ? "array" : typeof e == "string" ? "string" : "unknown";
|
|
1798
|
+
}
|
|
1799
|
+
function Xe(...e) {
|
|
1800
|
+
const [t, r, n] = e;
|
|
1801
|
+
return typeof t == "string" ? {
|
|
1802
|
+
message: t,
|
|
1803
|
+
code: "custom",
|
|
1804
|
+
input: r,
|
|
1805
|
+
inst: n
|
|
1806
|
+
} : { ...t };
|
|
1807
|
+
}
|
|
1808
|
+
const an = (e, t) => {
|
|
1809
|
+
e.name = "$ZodError", Object.defineProperty(e, "_zod", {
|
|
1810
|
+
value: e._zod,
|
|
1811
|
+
enumerable: !1
|
|
1812
|
+
}), Object.defineProperty(e, "issues", {
|
|
1813
|
+
value: t,
|
|
1814
|
+
enumerable: !1
|
|
1815
|
+
}), e.message = JSON.stringify(t, jt, 2), Object.defineProperty(e, "toString", {
|
|
1816
|
+
value: () => e.message,
|
|
1817
|
+
enumerable: !1
|
|
1818
|
+
});
|
|
1819
|
+
}, Bt = h("$ZodError", an), ht = h("$ZodError", an, { Parent: Error });
|
|
1820
|
+
function Ss(e, t = (r) => r.message) {
|
|
1821
|
+
const r = {}, n = [];
|
|
1822
|
+
for (const s of e.issues)
|
|
1823
|
+
s.path.length > 0 ? (r[s.path[0]] = r[s.path[0]] || [], r[s.path[0]].push(t(s))) : n.push(t(s));
|
|
1824
|
+
return { formErrors: n, fieldErrors: r };
|
|
1825
|
+
}
|
|
1826
|
+
function xs(e, t = (r) => r.message) {
|
|
1827
|
+
const r = { _errors: [] }, n = (s) => {
|
|
1828
|
+
for (const o of s.issues)
|
|
1829
|
+
if (o.code === "invalid_union" && o.errors.length)
|
|
1830
|
+
o.errors.map((i) => n({ issues: i }));
|
|
1831
|
+
else if (o.code === "invalid_key")
|
|
1832
|
+
n({ issues: o.issues });
|
|
1833
|
+
else if (o.code === "invalid_element")
|
|
1834
|
+
n({ issues: o.issues });
|
|
1835
|
+
else if (o.path.length === 0)
|
|
1836
|
+
r._errors.push(t(o));
|
|
1837
|
+
else {
|
|
1838
|
+
let i = r, a = 0;
|
|
1839
|
+
for (; a < o.path.length; ) {
|
|
1840
|
+
const c = o.path[a];
|
|
1841
|
+
a === o.path.length - 1 ? (i[c] = i[c] || { _errors: [] }, i[c]._errors.push(t(o))) : i[c] = i[c] || { _errors: [] }, i = i[c], a++;
|
|
1842
|
+
}
|
|
1843
|
+
}
|
|
1844
|
+
};
|
|
1845
|
+
return n(e), r;
|
|
1846
|
+
}
|
|
1847
|
+
const mt = (e) => (t, r, n, s) => {
|
|
1848
|
+
const o = n ? Object.assign(n, { async: !1 }) : { async: !1 }, i = t._zod.run({ value: r, issues: [] }, o);
|
|
1849
|
+
if (i instanceof Promise)
|
|
1850
|
+
throw new Ue();
|
|
1851
|
+
if (i.issues.length) {
|
|
1852
|
+
const a = new (s?.Err ?? e)(i.issues.map((c) => Ae(c, o, je())));
|
|
1853
|
+
throw nn(a, s?.callee), a;
|
|
1854
|
+
}
|
|
1855
|
+
return i.value;
|
|
1856
|
+
}, Es = /* @__PURE__ */ mt(ht), pt = (e) => async (t, r, n, s) => {
|
|
1857
|
+
const o = n ? Object.assign(n, { async: !0 }) : { async: !0 };
|
|
1858
|
+
let i = t._zod.run({ value: r, issues: [] }, o);
|
|
1859
|
+
if (i instanceof Promise && (i = await i), i.issues.length) {
|
|
1860
|
+
const a = new (s?.Err ?? e)(i.issues.map((c) => Ae(c, o, je())));
|
|
1861
|
+
throw nn(a, s?.callee), a;
|
|
1862
|
+
}
|
|
1863
|
+
return i.value;
|
|
1864
|
+
}, $s = /* @__PURE__ */ pt(ht), vt = (e) => (t, r, n) => {
|
|
1865
|
+
const s = n ? { ...n, async: !1 } : { async: !1 }, o = t._zod.run({ value: r, issues: [] }, s);
|
|
1866
|
+
if (o instanceof Promise)
|
|
1867
|
+
throw new Ue();
|
|
1868
|
+
return o.issues.length ? {
|
|
1869
|
+
success: !1,
|
|
1870
|
+
error: new (e ?? Bt)(o.issues.map((i) => Ae(i, s, je())))
|
|
1871
|
+
} : { success: !0, data: o.value };
|
|
1872
|
+
}, Ns = /* @__PURE__ */ vt(ht), gt = (e) => async (t, r, n) => {
|
|
1873
|
+
const s = n ? Object.assign(n, { async: !0 }) : { async: !0 };
|
|
1874
|
+
let o = t._zod.run({ value: r, issues: [] }, s);
|
|
1875
|
+
return o instanceof Promise && (o = await o), o.issues.length ? {
|
|
1876
|
+
success: !1,
|
|
1877
|
+
error: new e(o.issues.map((i) => Ae(i, s, je())))
|
|
1878
|
+
} : { success: !0, data: o.value };
|
|
1879
|
+
}, Os = /* @__PURE__ */ gt(ht), js = (e) => (t, r, n) => {
|
|
1880
|
+
const s = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
1881
|
+
return mt(e)(t, r, s);
|
|
1882
|
+
}, As = (e) => (t, r, n) => mt(e)(t, r, n), Zs = (e) => async (t, r, n) => {
|
|
1883
|
+
const s = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
1884
|
+
return pt(e)(t, r, s);
|
|
1885
|
+
}, Ts = (e) => async (t, r, n) => pt(e)(t, r, n), Fs = (e) => (t, r, n) => {
|
|
1886
|
+
const s = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
1887
|
+
return vt(e)(t, r, s);
|
|
1888
|
+
}, Ps = (e) => (t, r, n) => vt(e)(t, r, n), Rs = (e) => async (t, r, n) => {
|
|
1889
|
+
const s = n ? Object.assign(n, { direction: "backward" }) : { direction: "backward" };
|
|
1890
|
+
return gt(e)(t, r, s);
|
|
1891
|
+
}, Is = (e) => async (t, r, n) => gt(e)(t, r, n), Cs = /^[cC][^\s-]{8,}$/, Vs = /^[0-9a-z]+$/, Ds = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/, Us = /^[0-9a-vA-V]{20}$/, Ls = /^[A-Za-z0-9]{27}$/, Ms = /^[a-zA-Z0-9_-]{21}$/, Js = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/, Bs = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/, yr = (e) => e ? new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`) : /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/, Ws = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/, qs = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
1892
|
+
function Ys() {
|
|
1893
|
+
return new RegExp(qs, "u");
|
|
1894
|
+
}
|
|
1895
|
+
const Gs = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Hs = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/, Ks = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/, Xs = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Qs = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/, un = /^[A-Za-z0-9_-]*$/, eo = /^\+[1-9]\d{6,14}$/, cn = "(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))", to = /* @__PURE__ */ new RegExp(`^${cn}$`);
|
|
1896
|
+
function ln(e) {
|
|
1897
|
+
const t = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
1898
|
+
return typeof e.precision == "number" ? e.precision === -1 ? `${t}` : e.precision === 0 ? `${t}:[0-5]\\d` : `${t}:[0-5]\\d\\.\\d{${e.precision}}` : `${t}(?::[0-5]\\d(?:\\.\\d+)?)?`;
|
|
1899
|
+
}
|
|
1900
|
+
function ro(e) {
|
|
1901
|
+
return new RegExp(`^${ln(e)}$`);
|
|
1902
|
+
}
|
|
1903
|
+
function no(e) {
|
|
1904
|
+
const t = ln({ precision: e.precision }), r = ["Z"];
|
|
1905
|
+
e.local && r.push(""), e.offset && r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");
|
|
1906
|
+
const n = `${t}(?:${r.join("|")})`;
|
|
1907
|
+
return new RegExp(`^${cn}T(?:${n})$`);
|
|
1908
|
+
}
|
|
1909
|
+
const so = (e) => {
|
|
1910
|
+
const t = e ? `[\\s\\S]{${e?.minimum ?? 0},${e?.maximum ?? ""}}` : "[\\s\\S]*";
|
|
1911
|
+
return new RegExp(`^${t}$`);
|
|
1912
|
+
}, oo = /^-?\d+$/, io = /^-?\d+(?:\.\d+)?$/, ao = /^(?:true|false)$/i, uo = /^[^A-Z]*$/, co = /^[^a-z]*$/, he = /* @__PURE__ */ h("$ZodCheck", (e, t) => {
|
|
1913
|
+
var r;
|
|
1914
|
+
e._zod ?? (e._zod = {}), e._zod.def = t, (r = e._zod).onattach ?? (r.onattach = []);
|
|
1915
|
+
}), fn = {
|
|
1916
|
+
number: "number",
|
|
1917
|
+
bigint: "bigint",
|
|
1918
|
+
object: "date"
|
|
1919
|
+
}, dn = /* @__PURE__ */ h("$ZodCheckLessThan", (e, t) => {
|
|
1920
|
+
he.init(e, t);
|
|
1921
|
+
const r = fn[typeof t.value];
|
|
1922
|
+
e._zod.onattach.push((n) => {
|
|
1923
|
+
const s = n._zod.bag, o = (t.inclusive ? s.maximum : s.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
|
|
1924
|
+
t.value < o && (t.inclusive ? s.maximum = t.value : s.exclusiveMaximum = t.value);
|
|
1925
|
+
}), e._zod.check = (n) => {
|
|
1926
|
+
(t.inclusive ? n.value <= t.value : n.value < t.value) || n.issues.push({
|
|
1927
|
+
origin: r,
|
|
1928
|
+
code: "too_big",
|
|
1929
|
+
maximum: typeof t.value == "object" ? t.value.getTime() : t.value,
|
|
1930
|
+
input: n.value,
|
|
1931
|
+
inclusive: t.inclusive,
|
|
1932
|
+
inst: e,
|
|
1933
|
+
continue: !t.abort
|
|
1934
|
+
});
|
|
1935
|
+
};
|
|
1936
|
+
}), hn = /* @__PURE__ */ h("$ZodCheckGreaterThan", (e, t) => {
|
|
1937
|
+
he.init(e, t);
|
|
1938
|
+
const r = fn[typeof t.value];
|
|
1939
|
+
e._zod.onattach.push((n) => {
|
|
1940
|
+
const s = n._zod.bag, o = (t.inclusive ? s.minimum : s.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
|
|
1941
|
+
t.value > o && (t.inclusive ? s.minimum = t.value : s.exclusiveMinimum = t.value);
|
|
1942
|
+
}), e._zod.check = (n) => {
|
|
1943
|
+
(t.inclusive ? n.value >= t.value : n.value > t.value) || n.issues.push({
|
|
1944
|
+
origin: r,
|
|
1945
|
+
code: "too_small",
|
|
1946
|
+
minimum: typeof t.value == "object" ? t.value.getTime() : t.value,
|
|
1947
|
+
input: n.value,
|
|
1948
|
+
inclusive: t.inclusive,
|
|
1949
|
+
inst: e,
|
|
1950
|
+
continue: !t.abort
|
|
1951
|
+
});
|
|
1952
|
+
};
|
|
1953
|
+
}), lo = /* @__PURE__ */ h("$ZodCheckMultipleOf", (e, t) => {
|
|
1954
|
+
he.init(e, t), e._zod.onattach.push((r) => {
|
|
1955
|
+
var n;
|
|
1956
|
+
(n = r._zod.bag).multipleOf ?? (n.multipleOf = t.value);
|
|
1957
|
+
}), e._zod.check = (r) => {
|
|
1958
|
+
if (typeof r.value != typeof t.value)
|
|
1959
|
+
throw new Error("Cannot mix number and bigint in multiple_of check.");
|
|
1960
|
+
(typeof r.value == "bigint" ? r.value % t.value === BigInt(0) : fs(r.value, t.value) === 0) || r.issues.push({
|
|
1961
|
+
origin: typeof r.value,
|
|
1962
|
+
code: "not_multiple_of",
|
|
1963
|
+
divisor: t.value,
|
|
1964
|
+
input: r.value,
|
|
1965
|
+
inst: e,
|
|
1966
|
+
continue: !t.abort
|
|
1967
|
+
});
|
|
1968
|
+
};
|
|
1969
|
+
}), fo = /* @__PURE__ */ h("$ZodCheckNumberFormat", (e, t) => {
|
|
1970
|
+
he.init(e, t), t.format = t.format || "float64";
|
|
1971
|
+
const r = t.format?.includes("int"), n = r ? "int" : "number", [s, o] = vs[t.format];
|
|
1972
|
+
e._zod.onattach.push((i) => {
|
|
1973
|
+
const a = i._zod.bag;
|
|
1974
|
+
a.format = t.format, a.minimum = s, a.maximum = o, r && (a.pattern = oo);
|
|
1975
|
+
}), e._zod.check = (i) => {
|
|
1976
|
+
const a = i.value;
|
|
1977
|
+
if (r) {
|
|
1978
|
+
if (!Number.isInteger(a)) {
|
|
1979
|
+
i.issues.push({
|
|
1980
|
+
expected: n,
|
|
1981
|
+
format: t.format,
|
|
1982
|
+
code: "invalid_type",
|
|
1983
|
+
continue: !1,
|
|
1984
|
+
input: a,
|
|
1985
|
+
inst: e
|
|
1986
|
+
});
|
|
1987
|
+
return;
|
|
1988
|
+
}
|
|
1989
|
+
if (!Number.isSafeInteger(a)) {
|
|
1990
|
+
a > 0 ? i.issues.push({
|
|
1991
|
+
input: a,
|
|
1992
|
+
code: "too_big",
|
|
1993
|
+
maximum: Number.MAX_SAFE_INTEGER,
|
|
1994
|
+
note: "Integers must be within the safe integer range.",
|
|
1995
|
+
inst: e,
|
|
1996
|
+
origin: n,
|
|
1997
|
+
inclusive: !0,
|
|
1998
|
+
continue: !t.abort
|
|
1999
|
+
}) : i.issues.push({
|
|
2000
|
+
input: a,
|
|
2001
|
+
code: "too_small",
|
|
2002
|
+
minimum: Number.MIN_SAFE_INTEGER,
|
|
2003
|
+
note: "Integers must be within the safe integer range.",
|
|
2004
|
+
inst: e,
|
|
2005
|
+
origin: n,
|
|
2006
|
+
inclusive: !0,
|
|
2007
|
+
continue: !t.abort
|
|
2008
|
+
});
|
|
2009
|
+
return;
|
|
2010
|
+
}
|
|
2011
|
+
}
|
|
2012
|
+
a < s && i.issues.push({
|
|
2013
|
+
origin: "number",
|
|
2014
|
+
input: a,
|
|
2015
|
+
code: "too_small",
|
|
2016
|
+
minimum: s,
|
|
2017
|
+
inclusive: !0,
|
|
2018
|
+
inst: e,
|
|
2019
|
+
continue: !t.abort
|
|
2020
|
+
}), a > o && i.issues.push({
|
|
2021
|
+
origin: "number",
|
|
2022
|
+
input: a,
|
|
2023
|
+
code: "too_big",
|
|
2024
|
+
maximum: o,
|
|
2025
|
+
inclusive: !0,
|
|
2026
|
+
inst: e,
|
|
2027
|
+
continue: !t.abort
|
|
2028
|
+
});
|
|
2029
|
+
};
|
|
2030
|
+
}), ho = /* @__PURE__ */ h("$ZodCheckMaxLength", (e, t) => {
|
|
2031
|
+
var r;
|
|
2032
|
+
he.init(e, t), (r = e._zod.def).when ?? (r.when = (n) => {
|
|
2033
|
+
const s = n.value;
|
|
2034
|
+
return !Lt(s) && s.length !== void 0;
|
|
2035
|
+
}), e._zod.onattach.push((n) => {
|
|
2036
|
+
const s = n._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
|
|
2037
|
+
t.maximum < s && (n._zod.bag.maximum = t.maximum);
|
|
2038
|
+
}), e._zod.check = (n) => {
|
|
2039
|
+
const s = n.value;
|
|
2040
|
+
if (s.length <= t.maximum)
|
|
2041
|
+
return;
|
|
2042
|
+
const i = Jt(s);
|
|
2043
|
+
n.issues.push({
|
|
2044
|
+
origin: i,
|
|
2045
|
+
code: "too_big",
|
|
2046
|
+
maximum: t.maximum,
|
|
2047
|
+
inclusive: !0,
|
|
2048
|
+
input: s,
|
|
2049
|
+
inst: e,
|
|
2050
|
+
continue: !t.abort
|
|
2051
|
+
});
|
|
2052
|
+
};
|
|
2053
|
+
}), mo = /* @__PURE__ */ h("$ZodCheckMinLength", (e, t) => {
|
|
2054
|
+
var r;
|
|
2055
|
+
he.init(e, t), (r = e._zod.def).when ?? (r.when = (n) => {
|
|
2056
|
+
const s = n.value;
|
|
2057
|
+
return !Lt(s) && s.length !== void 0;
|
|
2058
|
+
}), e._zod.onattach.push((n) => {
|
|
2059
|
+
const s = n._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
|
|
2060
|
+
t.minimum > s && (n._zod.bag.minimum = t.minimum);
|
|
2061
|
+
}), e._zod.check = (n) => {
|
|
2062
|
+
const s = n.value;
|
|
2063
|
+
if (s.length >= t.minimum)
|
|
2064
|
+
return;
|
|
2065
|
+
const i = Jt(s);
|
|
2066
|
+
n.issues.push({
|
|
2067
|
+
origin: i,
|
|
2068
|
+
code: "too_small",
|
|
2069
|
+
minimum: t.minimum,
|
|
2070
|
+
inclusive: !0,
|
|
2071
|
+
input: s,
|
|
2072
|
+
inst: e,
|
|
2073
|
+
continue: !t.abort
|
|
2074
|
+
});
|
|
2075
|
+
};
|
|
2076
|
+
}), po = /* @__PURE__ */ h("$ZodCheckLengthEquals", (e, t) => {
|
|
2077
|
+
var r;
|
|
2078
|
+
he.init(e, t), (r = e._zod.def).when ?? (r.when = (n) => {
|
|
2079
|
+
const s = n.value;
|
|
2080
|
+
return !Lt(s) && s.length !== void 0;
|
|
2081
|
+
}), e._zod.onattach.push((n) => {
|
|
2082
|
+
const s = n._zod.bag;
|
|
2083
|
+
s.minimum = t.length, s.maximum = t.length, s.length = t.length;
|
|
2084
|
+
}), e._zod.check = (n) => {
|
|
2085
|
+
const s = n.value, o = s.length;
|
|
2086
|
+
if (o === t.length)
|
|
2087
|
+
return;
|
|
2088
|
+
const i = Jt(s), a = o > t.length;
|
|
2089
|
+
n.issues.push({
|
|
2090
|
+
origin: i,
|
|
2091
|
+
...a ? { code: "too_big", maximum: t.length } : { code: "too_small", minimum: t.length },
|
|
2092
|
+
inclusive: !0,
|
|
2093
|
+
exact: !0,
|
|
2094
|
+
input: n.value,
|
|
2095
|
+
inst: e,
|
|
2096
|
+
continue: !t.abort
|
|
2097
|
+
});
|
|
2098
|
+
};
|
|
2099
|
+
}), _t = /* @__PURE__ */ h("$ZodCheckStringFormat", (e, t) => {
|
|
2100
|
+
var r, n;
|
|
2101
|
+
he.init(e, t), e._zod.onattach.push((s) => {
|
|
2102
|
+
const o = s._zod.bag;
|
|
2103
|
+
o.format = t.format, t.pattern && (o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(t.pattern));
|
|
2104
|
+
}), t.pattern ? (r = e._zod).check ?? (r.check = (s) => {
|
|
2105
|
+
t.pattern.lastIndex = 0, !t.pattern.test(s.value) && s.issues.push({
|
|
2106
|
+
origin: "string",
|
|
2107
|
+
code: "invalid_format",
|
|
2108
|
+
format: t.format,
|
|
2109
|
+
input: s.value,
|
|
2110
|
+
...t.pattern ? { pattern: t.pattern.toString() } : {},
|
|
2111
|
+
inst: e,
|
|
2112
|
+
continue: !t.abort
|
|
2113
|
+
});
|
|
2114
|
+
}) : (n = e._zod).check ?? (n.check = () => {
|
|
2115
|
+
});
|
|
2116
|
+
}), vo = /* @__PURE__ */ h("$ZodCheckRegex", (e, t) => {
|
|
2117
|
+
_t.init(e, t), e._zod.check = (r) => {
|
|
2118
|
+
t.pattern.lastIndex = 0, !t.pattern.test(r.value) && r.issues.push({
|
|
2119
|
+
origin: "string",
|
|
2120
|
+
code: "invalid_format",
|
|
2121
|
+
format: "regex",
|
|
2122
|
+
input: r.value,
|
|
2123
|
+
pattern: t.pattern.toString(),
|
|
2124
|
+
inst: e,
|
|
2125
|
+
continue: !t.abort
|
|
2126
|
+
});
|
|
2127
|
+
};
|
|
2128
|
+
}), go = /* @__PURE__ */ h("$ZodCheckLowerCase", (e, t) => {
|
|
2129
|
+
t.pattern ?? (t.pattern = uo), _t.init(e, t);
|
|
2130
|
+
}), _o = /* @__PURE__ */ h("$ZodCheckUpperCase", (e, t) => {
|
|
2131
|
+
t.pattern ?? (t.pattern = co), _t.init(e, t);
|
|
2132
|
+
}), yo = /* @__PURE__ */ h("$ZodCheckIncludes", (e, t) => {
|
|
2133
|
+
he.init(e, t);
|
|
2134
|
+
const r = Le(t.includes), n = new RegExp(typeof t.position == "number" ? `^.{${t.position}}${r}` : r);
|
|
2135
|
+
t.pattern = n, e._zod.onattach.push((s) => {
|
|
2136
|
+
const o = s._zod.bag;
|
|
2137
|
+
o.patterns ?? (o.patterns = /* @__PURE__ */ new Set()), o.patterns.add(n);
|
|
2138
|
+
}), e._zod.check = (s) => {
|
|
2139
|
+
s.value.includes(t.includes, t.position) || s.issues.push({
|
|
2140
|
+
origin: "string",
|
|
2141
|
+
code: "invalid_format",
|
|
2142
|
+
format: "includes",
|
|
2143
|
+
includes: t.includes,
|
|
2144
|
+
input: s.value,
|
|
2145
|
+
inst: e,
|
|
2146
|
+
continue: !t.abort
|
|
2147
|
+
});
|
|
2148
|
+
};
|
|
2149
|
+
}), bo = /* @__PURE__ */ h("$ZodCheckStartsWith", (e, t) => {
|
|
2150
|
+
he.init(e, t);
|
|
2151
|
+
const r = new RegExp(`^${Le(t.prefix)}.*`);
|
|
2152
|
+
t.pattern ?? (t.pattern = r), e._zod.onattach.push((n) => {
|
|
2153
|
+
const s = n._zod.bag;
|
|
2154
|
+
s.patterns ?? (s.patterns = /* @__PURE__ */ new Set()), s.patterns.add(r);
|
|
2155
|
+
}), e._zod.check = (n) => {
|
|
2156
|
+
n.value.startsWith(t.prefix) || n.issues.push({
|
|
2157
|
+
origin: "string",
|
|
2158
|
+
code: "invalid_format",
|
|
2159
|
+
format: "starts_with",
|
|
2160
|
+
prefix: t.prefix,
|
|
2161
|
+
input: n.value,
|
|
2162
|
+
inst: e,
|
|
2163
|
+
continue: !t.abort
|
|
2164
|
+
});
|
|
2165
|
+
};
|
|
2166
|
+
}), wo = /* @__PURE__ */ h("$ZodCheckEndsWith", (e, t) => {
|
|
2167
|
+
he.init(e, t);
|
|
2168
|
+
const r = new RegExp(`.*${Le(t.suffix)}$`);
|
|
2169
|
+
t.pattern ?? (t.pattern = r), e._zod.onattach.push((n) => {
|
|
2170
|
+
const s = n._zod.bag;
|
|
2171
|
+
s.patterns ?? (s.patterns = /* @__PURE__ */ new Set()), s.patterns.add(r);
|
|
2172
|
+
}), e._zod.check = (n) => {
|
|
2173
|
+
n.value.endsWith(t.suffix) || n.issues.push({
|
|
2174
|
+
origin: "string",
|
|
2175
|
+
code: "invalid_format",
|
|
2176
|
+
format: "ends_with",
|
|
2177
|
+
suffix: t.suffix,
|
|
2178
|
+
input: n.value,
|
|
2179
|
+
inst: e,
|
|
2180
|
+
continue: !t.abort
|
|
2181
|
+
});
|
|
2182
|
+
};
|
|
2183
|
+
}), ko = /* @__PURE__ */ h("$ZodCheckOverwrite", (e, t) => {
|
|
2184
|
+
he.init(e, t), e._zod.check = (r) => {
|
|
2185
|
+
r.value = t.tx(r.value);
|
|
2186
|
+
};
|
|
2187
|
+
});
|
|
2188
|
+
class zo {
|
|
2189
|
+
constructor(t = []) {
|
|
2190
|
+
this.content = [], this.indent = 0, this && (this.args = t);
|
|
2191
|
+
}
|
|
2192
|
+
indented(t) {
|
|
2193
|
+
this.indent += 1, t(this), this.indent -= 1;
|
|
2194
|
+
}
|
|
2195
|
+
write(t) {
|
|
2196
|
+
if (typeof t == "function") {
|
|
2197
|
+
t(this, { execution: "sync" }), t(this, { execution: "async" });
|
|
2198
|
+
return;
|
|
2199
|
+
}
|
|
2200
|
+
const n = t.split(`
|
|
2201
|
+
`).filter((i) => i), s = Math.min(...n.map((i) => i.length - i.trimStart().length)), o = n.map((i) => i.slice(s)).map((i) => " ".repeat(this.indent * 2) + i);
|
|
2202
|
+
for (const i of o)
|
|
2203
|
+
this.content.push(i);
|
|
2204
|
+
}
|
|
2205
|
+
compile() {
|
|
2206
|
+
const t = Function, r = this?.args, s = [...(this?.content ?? [""]).map((o) => ` ${o}`)];
|
|
2207
|
+
return new t(...r, s.join(`
|
|
2208
|
+
`));
|
|
2209
|
+
}
|
|
2210
|
+
}
|
|
2211
|
+
const So = {
|
|
2212
|
+
major: 4,
|
|
2213
|
+
minor: 3,
|
|
2214
|
+
patch: 6
|
|
2215
|
+
}, W = /* @__PURE__ */ h("$ZodType", (e, t) => {
|
|
2216
|
+
var r;
|
|
2217
|
+
e ?? (e = {}), e._zod.def = t, e._zod.bag = e._zod.bag || {}, e._zod.version = So;
|
|
2218
|
+
const n = [...e._zod.def.checks ?? []];
|
|
2219
|
+
e._zod.traits.has("$ZodCheck") && n.unshift(e);
|
|
2220
|
+
for (const s of n)
|
|
2221
|
+
for (const o of s._zod.onattach)
|
|
2222
|
+
o(e);
|
|
2223
|
+
if (n.length === 0)
|
|
2224
|
+
(r = e._zod).deferred ?? (r.deferred = []), e._zod.deferred?.push(() => {
|
|
2225
|
+
e._zod.run = e._zod.parse;
|
|
2226
|
+
});
|
|
2227
|
+
else {
|
|
2228
|
+
const s = (i, a, c) => {
|
|
2229
|
+
let f = De(i), _;
|
|
2230
|
+
for (const g of a) {
|
|
2231
|
+
if (g._zod.def.when) {
|
|
2232
|
+
if (!g._zod.def.when(i))
|
|
2233
|
+
continue;
|
|
2234
|
+
} else if (f)
|
|
2235
|
+
continue;
|
|
2236
|
+
const b = i.issues.length, v = g._zod.check(i);
|
|
2237
|
+
if (v instanceof Promise && c?.async === !1)
|
|
2238
|
+
throw new Ue();
|
|
2239
|
+
if (_ || v instanceof Promise)
|
|
2240
|
+
_ = (_ ?? Promise.resolve()).then(async () => {
|
|
2241
|
+
await v, i.issues.length !== b && (f || (f = De(i, b)));
|
|
2242
|
+
});
|
|
2243
|
+
else {
|
|
2244
|
+
if (i.issues.length === b)
|
|
2245
|
+
continue;
|
|
2246
|
+
f || (f = De(i, b));
|
|
2247
|
+
}
|
|
2248
|
+
}
|
|
2249
|
+
return _ ? _.then(() => i) : i;
|
|
2250
|
+
}, o = (i, a, c) => {
|
|
2251
|
+
if (De(i))
|
|
2252
|
+
return i.aborted = !0, i;
|
|
2253
|
+
const f = s(a, n, c);
|
|
2254
|
+
if (f instanceof Promise) {
|
|
2255
|
+
if (c.async === !1)
|
|
2256
|
+
throw new Ue();
|
|
2257
|
+
return f.then((_) => e._zod.parse(_, c));
|
|
2258
|
+
}
|
|
2259
|
+
return e._zod.parse(f, c);
|
|
2260
|
+
};
|
|
2261
|
+
e._zod.run = (i, a) => {
|
|
2262
|
+
if (a.skipChecks)
|
|
2263
|
+
return e._zod.parse(i, a);
|
|
2264
|
+
if (a.direction === "backward") {
|
|
2265
|
+
const f = e._zod.parse({ value: i.value, issues: [] }, { ...a, skipChecks: !0 });
|
|
2266
|
+
return f instanceof Promise ? f.then((_) => o(_, i, a)) : o(f, i, a);
|
|
2267
|
+
}
|
|
2268
|
+
const c = e._zod.parse(i, a);
|
|
2269
|
+
if (c instanceof Promise) {
|
|
2270
|
+
if (a.async === !1)
|
|
2271
|
+
throw new Ue();
|
|
2272
|
+
return c.then((f) => s(f, n, a));
|
|
2273
|
+
}
|
|
2274
|
+
return s(c, n, a);
|
|
2275
|
+
};
|
|
2276
|
+
}
|
|
2277
|
+
U(e, "~standard", () => ({
|
|
2278
|
+
validate: (s) => {
|
|
2279
|
+
try {
|
|
2280
|
+
const o = Ns(e, s);
|
|
2281
|
+
return o.success ? { value: o.data } : { issues: o.error?.issues };
|
|
2282
|
+
} catch {
|
|
2283
|
+
return Os(e, s).then((i) => i.success ? { value: i.data } : { issues: i.error?.issues });
|
|
2284
|
+
}
|
|
2285
|
+
},
|
|
2286
|
+
vendor: "zod",
|
|
2287
|
+
version: 1
|
|
2288
|
+
}));
|
|
2289
|
+
}), Wt = /* @__PURE__ */ h("$ZodString", (e, t) => {
|
|
2290
|
+
W.init(e, t), e._zod.pattern = [...e?._zod.bag?.patterns ?? []].pop() ?? so(e._zod.bag), e._zod.parse = (r, n) => {
|
|
2291
|
+
if (t.coerce)
|
|
2292
|
+
try {
|
|
2293
|
+
r.value = String(r.value);
|
|
2294
|
+
} catch {
|
|
2295
|
+
}
|
|
2296
|
+
return typeof r.value == "string" || r.issues.push({
|
|
2297
|
+
expected: "string",
|
|
2298
|
+
code: "invalid_type",
|
|
2299
|
+
input: r.value,
|
|
2300
|
+
inst: e
|
|
2301
|
+
}), r;
|
|
2302
|
+
};
|
|
2303
|
+
}), B = /* @__PURE__ */ h("$ZodStringFormat", (e, t) => {
|
|
2304
|
+
_t.init(e, t), Wt.init(e, t);
|
|
2305
|
+
}), xo = /* @__PURE__ */ h("$ZodGUID", (e, t) => {
|
|
2306
|
+
t.pattern ?? (t.pattern = Bs), B.init(e, t);
|
|
2307
|
+
}), Eo = /* @__PURE__ */ h("$ZodUUID", (e, t) => {
|
|
2308
|
+
if (t.version) {
|
|
2309
|
+
const n = {
|
|
2310
|
+
v1: 1,
|
|
2311
|
+
v2: 2,
|
|
2312
|
+
v3: 3,
|
|
2313
|
+
v4: 4,
|
|
2314
|
+
v5: 5,
|
|
2315
|
+
v6: 6,
|
|
2316
|
+
v7: 7,
|
|
2317
|
+
v8: 8
|
|
2318
|
+
}[t.version];
|
|
2319
|
+
if (n === void 0)
|
|
2320
|
+
throw new Error(`Invalid UUID version: "${t.version}"`);
|
|
2321
|
+
t.pattern ?? (t.pattern = yr(n));
|
|
2322
|
+
} else
|
|
2323
|
+
t.pattern ?? (t.pattern = yr());
|
|
2324
|
+
B.init(e, t);
|
|
2325
|
+
}), $o = /* @__PURE__ */ h("$ZodEmail", (e, t) => {
|
|
2326
|
+
t.pattern ?? (t.pattern = Ws), B.init(e, t);
|
|
2327
|
+
}), No = /* @__PURE__ */ h("$ZodURL", (e, t) => {
|
|
2328
|
+
B.init(e, t), e._zod.check = (r) => {
|
|
2329
|
+
try {
|
|
2330
|
+
const n = r.value.trim(), s = new URL(n);
|
|
2331
|
+
t.hostname && (t.hostname.lastIndex = 0, t.hostname.test(s.hostname) || r.issues.push({
|
|
2332
|
+
code: "invalid_format",
|
|
2333
|
+
format: "url",
|
|
2334
|
+
note: "Invalid hostname",
|
|
2335
|
+
pattern: t.hostname.source,
|
|
2336
|
+
input: r.value,
|
|
2337
|
+
inst: e,
|
|
2338
|
+
continue: !t.abort
|
|
2339
|
+
})), t.protocol && (t.protocol.lastIndex = 0, t.protocol.test(s.protocol.endsWith(":") ? s.protocol.slice(0, -1) : s.protocol) || r.issues.push({
|
|
2340
|
+
code: "invalid_format",
|
|
2341
|
+
format: "url",
|
|
2342
|
+
note: "Invalid protocol",
|
|
2343
|
+
pattern: t.protocol.source,
|
|
2344
|
+
input: r.value,
|
|
2345
|
+
inst: e,
|
|
2346
|
+
continue: !t.abort
|
|
2347
|
+
})), t.normalize ? r.value = s.href : r.value = n;
|
|
2348
|
+
return;
|
|
2349
|
+
} catch {
|
|
2350
|
+
r.issues.push({
|
|
2351
|
+
code: "invalid_format",
|
|
2352
|
+
format: "url",
|
|
2353
|
+
input: r.value,
|
|
2354
|
+
inst: e,
|
|
2355
|
+
continue: !t.abort
|
|
2356
|
+
});
|
|
2357
|
+
}
|
|
2358
|
+
};
|
|
2359
|
+
}), Oo = /* @__PURE__ */ h("$ZodEmoji", (e, t) => {
|
|
2360
|
+
t.pattern ?? (t.pattern = Ys()), B.init(e, t);
|
|
2361
|
+
}), jo = /* @__PURE__ */ h("$ZodNanoID", (e, t) => {
|
|
2362
|
+
t.pattern ?? (t.pattern = Ms), B.init(e, t);
|
|
2363
|
+
}), Ao = /* @__PURE__ */ h("$ZodCUID", (e, t) => {
|
|
2364
|
+
t.pattern ?? (t.pattern = Cs), B.init(e, t);
|
|
2365
|
+
}), Zo = /* @__PURE__ */ h("$ZodCUID2", (e, t) => {
|
|
2366
|
+
t.pattern ?? (t.pattern = Vs), B.init(e, t);
|
|
2367
|
+
}), To = /* @__PURE__ */ h("$ZodULID", (e, t) => {
|
|
2368
|
+
t.pattern ?? (t.pattern = Ds), B.init(e, t);
|
|
2369
|
+
}), Fo = /* @__PURE__ */ h("$ZodXID", (e, t) => {
|
|
2370
|
+
t.pattern ?? (t.pattern = Us), B.init(e, t);
|
|
2371
|
+
}), Po = /* @__PURE__ */ h("$ZodKSUID", (e, t) => {
|
|
2372
|
+
t.pattern ?? (t.pattern = Ls), B.init(e, t);
|
|
2373
|
+
}), Ro = /* @__PURE__ */ h("$ZodISODateTime", (e, t) => {
|
|
2374
|
+
t.pattern ?? (t.pattern = no(t)), B.init(e, t);
|
|
2375
|
+
}), Io = /* @__PURE__ */ h("$ZodISODate", (e, t) => {
|
|
2376
|
+
t.pattern ?? (t.pattern = to), B.init(e, t);
|
|
2377
|
+
}), Co = /* @__PURE__ */ h("$ZodISOTime", (e, t) => {
|
|
2378
|
+
t.pattern ?? (t.pattern = ro(t)), B.init(e, t);
|
|
2379
|
+
}), Vo = /* @__PURE__ */ h("$ZodISODuration", (e, t) => {
|
|
2380
|
+
t.pattern ?? (t.pattern = Js), B.init(e, t);
|
|
2381
|
+
}), Do = /* @__PURE__ */ h("$ZodIPv4", (e, t) => {
|
|
2382
|
+
t.pattern ?? (t.pattern = Gs), B.init(e, t), e._zod.bag.format = "ipv4";
|
|
2383
|
+
}), Uo = /* @__PURE__ */ h("$ZodIPv6", (e, t) => {
|
|
2384
|
+
t.pattern ?? (t.pattern = Hs), B.init(e, t), e._zod.bag.format = "ipv6", e._zod.check = (r) => {
|
|
2385
|
+
try {
|
|
2386
|
+
new URL(`http://[${r.value}]`);
|
|
2387
|
+
} catch {
|
|
2388
|
+
r.issues.push({
|
|
2389
|
+
code: "invalid_format",
|
|
2390
|
+
format: "ipv6",
|
|
2391
|
+
input: r.value,
|
|
2392
|
+
inst: e,
|
|
2393
|
+
continue: !t.abort
|
|
2394
|
+
});
|
|
2395
|
+
}
|
|
2396
|
+
};
|
|
2397
|
+
}), Lo = /* @__PURE__ */ h("$ZodCIDRv4", (e, t) => {
|
|
2398
|
+
t.pattern ?? (t.pattern = Ks), B.init(e, t);
|
|
2399
|
+
}), Mo = /* @__PURE__ */ h("$ZodCIDRv6", (e, t) => {
|
|
2400
|
+
t.pattern ?? (t.pattern = Xs), B.init(e, t), e._zod.check = (r) => {
|
|
2401
|
+
const n = r.value.split("/");
|
|
2402
|
+
try {
|
|
2403
|
+
if (n.length !== 2)
|
|
2404
|
+
throw new Error();
|
|
2405
|
+
const [s, o] = n;
|
|
2406
|
+
if (!o)
|
|
2407
|
+
throw new Error();
|
|
2408
|
+
const i = Number(o);
|
|
2409
|
+
if (`${i}` !== o)
|
|
2410
|
+
throw new Error();
|
|
2411
|
+
if (i < 0 || i > 128)
|
|
2412
|
+
throw new Error();
|
|
2413
|
+
new URL(`http://[${s}]`);
|
|
2414
|
+
} catch {
|
|
2415
|
+
r.issues.push({
|
|
2416
|
+
code: "invalid_format",
|
|
2417
|
+
format: "cidrv6",
|
|
2418
|
+
input: r.value,
|
|
2419
|
+
inst: e,
|
|
2420
|
+
continue: !t.abort
|
|
2421
|
+
});
|
|
2422
|
+
}
|
|
2423
|
+
};
|
|
2424
|
+
});
|
|
2425
|
+
function mn(e) {
|
|
2426
|
+
if (e === "")
|
|
2427
|
+
return !0;
|
|
2428
|
+
if (e.length % 4 !== 0)
|
|
2429
|
+
return !1;
|
|
2430
|
+
try {
|
|
2431
|
+
return atob(e), !0;
|
|
2432
|
+
} catch {
|
|
2433
|
+
return !1;
|
|
2434
|
+
}
|
|
2435
|
+
}
|
|
2436
|
+
const Jo = /* @__PURE__ */ h("$ZodBase64", (e, t) => {
|
|
2437
|
+
t.pattern ?? (t.pattern = Qs), B.init(e, t), e._zod.bag.contentEncoding = "base64", e._zod.check = (r) => {
|
|
2438
|
+
mn(r.value) || r.issues.push({
|
|
2439
|
+
code: "invalid_format",
|
|
2440
|
+
format: "base64",
|
|
2441
|
+
input: r.value,
|
|
2442
|
+
inst: e,
|
|
2443
|
+
continue: !t.abort
|
|
2444
|
+
});
|
|
2445
|
+
};
|
|
2446
|
+
});
|
|
2447
|
+
function Bo(e) {
|
|
2448
|
+
if (!un.test(e))
|
|
2449
|
+
return !1;
|
|
2450
|
+
const t = e.replace(/[-_]/g, (n) => n === "-" ? "+" : "/"), r = t.padEnd(Math.ceil(t.length / 4) * 4, "=");
|
|
2451
|
+
return mn(r);
|
|
2452
|
+
}
|
|
2453
|
+
const Wo = /* @__PURE__ */ h("$ZodBase64URL", (e, t) => {
|
|
2454
|
+
t.pattern ?? (t.pattern = un), B.init(e, t), e._zod.bag.contentEncoding = "base64url", e._zod.check = (r) => {
|
|
2455
|
+
Bo(r.value) || r.issues.push({
|
|
2456
|
+
code: "invalid_format",
|
|
2457
|
+
format: "base64url",
|
|
2458
|
+
input: r.value,
|
|
2459
|
+
inst: e,
|
|
2460
|
+
continue: !t.abort
|
|
2461
|
+
});
|
|
2462
|
+
};
|
|
2463
|
+
}), qo = /* @__PURE__ */ h("$ZodE164", (e, t) => {
|
|
2464
|
+
t.pattern ?? (t.pattern = eo), B.init(e, t);
|
|
2465
|
+
});
|
|
2466
|
+
function Yo(e, t = null) {
|
|
2467
|
+
try {
|
|
2468
|
+
const r = e.split(".");
|
|
2469
|
+
if (r.length !== 3)
|
|
2470
|
+
return !1;
|
|
2471
|
+
const [n] = r;
|
|
2472
|
+
if (!n)
|
|
2473
|
+
return !1;
|
|
2474
|
+
const s = JSON.parse(atob(n));
|
|
2475
|
+
return !("typ" in s && s?.typ !== "JWT" || !s.alg || t && (!("alg" in s) || s.alg !== t));
|
|
2476
|
+
} catch {
|
|
2477
|
+
return !1;
|
|
2478
|
+
}
|
|
2479
|
+
}
|
|
2480
|
+
const Go = /* @__PURE__ */ h("$ZodJWT", (e, t) => {
|
|
2481
|
+
B.init(e, t), e._zod.check = (r) => {
|
|
2482
|
+
Yo(r.value, t.alg) || r.issues.push({
|
|
2483
|
+
code: "invalid_format",
|
|
2484
|
+
format: "jwt",
|
|
2485
|
+
input: r.value,
|
|
2486
|
+
inst: e,
|
|
2487
|
+
continue: !t.abort
|
|
2488
|
+
});
|
|
2489
|
+
};
|
|
2490
|
+
}), pn = /* @__PURE__ */ h("$ZodNumber", (e, t) => {
|
|
2491
|
+
W.init(e, t), e._zod.pattern = e._zod.bag.pattern ?? io, e._zod.parse = (r, n) => {
|
|
2492
|
+
if (t.coerce)
|
|
2493
|
+
try {
|
|
2494
|
+
r.value = Number(r.value);
|
|
2495
|
+
} catch {
|
|
2496
|
+
}
|
|
2497
|
+
const s = r.value;
|
|
2498
|
+
if (typeof s == "number" && !Number.isNaN(s) && Number.isFinite(s))
|
|
2499
|
+
return r;
|
|
2500
|
+
const o = typeof s == "number" ? Number.isNaN(s) ? "NaN" : Number.isFinite(s) ? void 0 : "Infinity" : void 0;
|
|
2501
|
+
return r.issues.push({
|
|
2502
|
+
expected: "number",
|
|
2503
|
+
code: "invalid_type",
|
|
2504
|
+
input: s,
|
|
2505
|
+
inst: e,
|
|
2506
|
+
...o ? { received: o } : {}
|
|
2507
|
+
}), r;
|
|
2508
|
+
};
|
|
2509
|
+
}), Ho = /* @__PURE__ */ h("$ZodNumberFormat", (e, t) => {
|
|
2510
|
+
fo.init(e, t), pn.init(e, t);
|
|
2511
|
+
}), Ko = /* @__PURE__ */ h("$ZodBoolean", (e, t) => {
|
|
2512
|
+
W.init(e, t), e._zod.pattern = ao, e._zod.parse = (r, n) => {
|
|
2513
|
+
if (t.coerce)
|
|
2514
|
+
try {
|
|
2515
|
+
r.value = !!r.value;
|
|
2516
|
+
} catch {
|
|
2517
|
+
}
|
|
2518
|
+
const s = r.value;
|
|
2519
|
+
return typeof s == "boolean" || r.issues.push({
|
|
2520
|
+
expected: "boolean",
|
|
2521
|
+
code: "invalid_type",
|
|
2522
|
+
input: s,
|
|
2523
|
+
inst: e
|
|
2524
|
+
}), r;
|
|
2525
|
+
};
|
|
2526
|
+
}), Xo = /* @__PURE__ */ h("$ZodAny", (e, t) => {
|
|
2527
|
+
W.init(e, t), e._zod.parse = (r) => r;
|
|
2528
|
+
}), Qo = /* @__PURE__ */ h("$ZodUnknown", (e, t) => {
|
|
2529
|
+
W.init(e, t), e._zod.parse = (r) => r;
|
|
2530
|
+
}), ei = /* @__PURE__ */ h("$ZodNever", (e, t) => {
|
|
2531
|
+
W.init(e, t), e._zod.parse = (r, n) => (r.issues.push({
|
|
2532
|
+
expected: "never",
|
|
2533
|
+
code: "invalid_type",
|
|
2534
|
+
input: r.value,
|
|
2535
|
+
inst: e
|
|
2536
|
+
}), r);
|
|
2537
|
+
});
|
|
2538
|
+
function br(e, t, r) {
|
|
2539
|
+
e.issues.length && t.issues.push(...on(r, e.issues)), t.value[r] = e.value;
|
|
2540
|
+
}
|
|
2541
|
+
const ti = /* @__PURE__ */ h("$ZodArray", (e, t) => {
|
|
2542
|
+
W.init(e, t), e._zod.parse = (r, n) => {
|
|
2543
|
+
const s = r.value;
|
|
2544
|
+
if (!Array.isArray(s))
|
|
2545
|
+
return r.issues.push({
|
|
2546
|
+
expected: "array",
|
|
2547
|
+
code: "invalid_type",
|
|
2548
|
+
input: s,
|
|
2549
|
+
inst: e
|
|
2550
|
+
}), r;
|
|
2551
|
+
r.value = Array(s.length);
|
|
2552
|
+
const o = [];
|
|
2553
|
+
for (let i = 0; i < s.length; i++) {
|
|
2554
|
+
const a = s[i], c = t.element._zod.run({
|
|
2555
|
+
value: a,
|
|
2556
|
+
issues: []
|
|
2557
|
+
}, n);
|
|
2558
|
+
c instanceof Promise ? o.push(c.then((f) => br(f, r, i))) : br(c, r, i);
|
|
2559
|
+
}
|
|
2560
|
+
return o.length ? Promise.all(o).then(() => r) : r;
|
|
2561
|
+
};
|
|
2562
|
+
});
|
|
2563
|
+
function ct(e, t, r, n, s) {
|
|
2564
|
+
if (e.issues.length) {
|
|
2565
|
+
if (s && !(r in n))
|
|
2566
|
+
return;
|
|
2567
|
+
t.issues.push(...on(r, e.issues));
|
|
2568
|
+
}
|
|
2569
|
+
e.value === void 0 ? r in n && (t.value[r] = void 0) : t.value[r] = e.value;
|
|
2570
|
+
}
|
|
2571
|
+
function vn(e) {
|
|
2572
|
+
const t = Object.keys(e.shape);
|
|
2573
|
+
for (const n of t)
|
|
2574
|
+
if (!e.shape?.[n]?._zod?.traits?.has("$ZodType"))
|
|
2575
|
+
throw new Error(`Invalid element at key "${n}": expected a Zod schema`);
|
|
2576
|
+
const r = ps(e.shape);
|
|
2577
|
+
return {
|
|
2578
|
+
...e,
|
|
2579
|
+
keys: t,
|
|
2580
|
+
keySet: new Set(t),
|
|
2581
|
+
numKeys: t.length,
|
|
2582
|
+
optionalKeys: new Set(r)
|
|
2583
|
+
};
|
|
2584
|
+
}
|
|
2585
|
+
function gn(e, t, r, n, s, o) {
|
|
2586
|
+
const i = [], a = s.keySet, c = s.catchall._zod, f = c.def.type, _ = c.optout === "optional";
|
|
2587
|
+
for (const g in t) {
|
|
2588
|
+
if (a.has(g))
|
|
2589
|
+
continue;
|
|
2590
|
+
if (f === "never") {
|
|
2591
|
+
i.push(g);
|
|
2592
|
+
continue;
|
|
2593
|
+
}
|
|
2594
|
+
const b = c.run({ value: t[g], issues: [] }, n);
|
|
2595
|
+
b instanceof Promise ? e.push(b.then((v) => ct(v, r, g, t, _))) : ct(b, r, g, t, _);
|
|
2596
|
+
}
|
|
2597
|
+
return i.length && r.issues.push({
|
|
2598
|
+
code: "unrecognized_keys",
|
|
2599
|
+
keys: i,
|
|
2600
|
+
input: t,
|
|
2601
|
+
inst: o
|
|
2602
|
+
}), e.length ? Promise.all(e).then(() => r) : r;
|
|
2603
|
+
}
|
|
2604
|
+
const ri = /* @__PURE__ */ h("$ZodObject", (e, t) => {
|
|
2605
|
+
if (W.init(e, t), !Object.getOwnPropertyDescriptor(t, "shape")?.get) {
|
|
2606
|
+
const a = t.shape;
|
|
2607
|
+
Object.defineProperty(t, "shape", {
|
|
2608
|
+
get: () => {
|
|
2609
|
+
const c = { ...a };
|
|
2610
|
+
return Object.defineProperty(t, "shape", {
|
|
2611
|
+
value: c
|
|
2612
|
+
}), c;
|
|
2613
|
+
}
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2616
|
+
const n = Ut(() => vn(t));
|
|
2617
|
+
U(e._zod, "propValues", () => {
|
|
2618
|
+
const a = t.shape, c = {};
|
|
2619
|
+
for (const f in a) {
|
|
2620
|
+
const _ = a[f]._zod;
|
|
2621
|
+
if (_.values) {
|
|
2622
|
+
c[f] ?? (c[f] = /* @__PURE__ */ new Set());
|
|
2623
|
+
for (const g of _.values)
|
|
2624
|
+
c[f].add(g);
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
return c;
|
|
2628
|
+
});
|
|
2629
|
+
const s = ut, o = t.catchall;
|
|
2630
|
+
let i;
|
|
2631
|
+
e._zod.parse = (a, c) => {
|
|
2632
|
+
i ?? (i = n.value);
|
|
2633
|
+
const f = a.value;
|
|
2634
|
+
if (!s(f))
|
|
2635
|
+
return a.issues.push({
|
|
2636
|
+
expected: "object",
|
|
2637
|
+
code: "invalid_type",
|
|
2638
|
+
input: f,
|
|
2639
|
+
inst: e
|
|
2640
|
+
}), a;
|
|
2641
|
+
a.value = {};
|
|
2642
|
+
const _ = [], g = i.shape;
|
|
2643
|
+
for (const b of i.keys) {
|
|
2644
|
+
const v = g[b], Z = v._zod.optout === "optional", O = v._zod.run({ value: f[b], issues: [] }, c);
|
|
2645
|
+
O instanceof Promise ? _.push(O.then((I) => ct(I, a, b, f, Z))) : ct(O, a, b, f, Z);
|
|
2646
|
+
}
|
|
2647
|
+
return o ? gn(_, f, a, c, n.value, e) : _.length ? Promise.all(_).then(() => a) : a;
|
|
2648
|
+
};
|
|
2649
|
+
}), ni = /* @__PURE__ */ h("$ZodObjectJIT", (e, t) => {
|
|
2650
|
+
ri.init(e, t);
|
|
2651
|
+
const r = e._zod.parse, n = Ut(() => vn(t)), s = (b) => {
|
|
2652
|
+
const v = new zo(["shape", "payload", "ctx"]), Z = n.value, O = (P) => {
|
|
2653
|
+
const z = _r(P);
|
|
2654
|
+
return `shape[${z}]._zod.run({ value: input[${z}], issues: [] }, ctx)`;
|
|
2655
|
+
};
|
|
2656
|
+
v.write("const input = payload.value;");
|
|
2657
|
+
const I = /* @__PURE__ */ Object.create(null);
|
|
2658
|
+
let F = 0;
|
|
2659
|
+
for (const P of Z.keys)
|
|
2660
|
+
I[P] = `key_${F++}`;
|
|
2661
|
+
v.write("const newResult = {};");
|
|
2662
|
+
for (const P of Z.keys) {
|
|
2663
|
+
const z = I[P], S = _r(P), re = b[P]?._zod?.optout === "optional";
|
|
2664
|
+
v.write(`const ${z} = ${O(P)};`), re ? v.write(`
|
|
2665
|
+
if (${z}.issues.length) {
|
|
2666
|
+
if (${S} in input) {
|
|
2667
|
+
payload.issues = payload.issues.concat(${z}.issues.map(iss => ({
|
|
2668
|
+
...iss,
|
|
2669
|
+
path: iss.path ? [${S}, ...iss.path] : [${S}]
|
|
2670
|
+
})));
|
|
2671
|
+
}
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
if (${z}.value === undefined) {
|
|
2675
|
+
if (${S} in input) {
|
|
2676
|
+
newResult[${S}] = undefined;
|
|
2677
|
+
}
|
|
2678
|
+
} else {
|
|
2679
|
+
newResult[${S}] = ${z}.value;
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
`) : v.write(`
|
|
2683
|
+
if (${z}.issues.length) {
|
|
2684
|
+
payload.issues = payload.issues.concat(${z}.issues.map(iss => ({
|
|
2685
|
+
...iss,
|
|
2686
|
+
path: iss.path ? [${S}, ...iss.path] : [${S}]
|
|
2687
|
+
})));
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
if (${z}.value === undefined) {
|
|
2691
|
+
if (${S} in input) {
|
|
2692
|
+
newResult[${S}] = undefined;
|
|
2693
|
+
}
|
|
2694
|
+
} else {
|
|
2695
|
+
newResult[${S}] = ${z}.value;
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
`);
|
|
2699
|
+
}
|
|
2700
|
+
v.write("payload.value = newResult;"), v.write("return payload;");
|
|
2701
|
+
const N = v.compile();
|
|
2702
|
+
return (P, z) => N(b, P, z);
|
|
2703
|
+
};
|
|
2704
|
+
let o;
|
|
2705
|
+
const i = ut, a = !tn.jitless, f = a && hs.value, _ = t.catchall;
|
|
2706
|
+
let g;
|
|
2707
|
+
e._zod.parse = (b, v) => {
|
|
2708
|
+
g ?? (g = n.value);
|
|
2709
|
+
const Z = b.value;
|
|
2710
|
+
return i(Z) ? a && f && v?.async === !1 && v.jitless !== !0 ? (o || (o = s(t.shape)), b = o(b, v), _ ? gn([], Z, b, v, g, e) : b) : r(b, v) : (b.issues.push({
|
|
2711
|
+
expected: "object",
|
|
2712
|
+
code: "invalid_type",
|
|
2713
|
+
input: Z,
|
|
2714
|
+
inst: e
|
|
2715
|
+
}), b);
|
|
2716
|
+
};
|
|
2717
|
+
});
|
|
2718
|
+
function wr(e, t, r, n) {
|
|
2719
|
+
for (const o of e)
|
|
2720
|
+
if (o.issues.length === 0)
|
|
2721
|
+
return t.value = o.value, t;
|
|
2722
|
+
const s = e.filter((o) => !De(o));
|
|
2723
|
+
return s.length === 1 ? (t.value = s[0].value, s[0]) : (t.issues.push({
|
|
2724
|
+
code: "invalid_union",
|
|
2725
|
+
input: t.value,
|
|
2726
|
+
inst: r,
|
|
2727
|
+
errors: e.map((o) => o.issues.map((i) => Ae(i, n, je())))
|
|
2728
|
+
}), t);
|
|
2729
|
+
}
|
|
2730
|
+
const si = /* @__PURE__ */ h("$ZodUnion", (e, t) => {
|
|
2731
|
+
W.init(e, t), U(e._zod, "optin", () => t.options.some((s) => s._zod.optin === "optional") ? "optional" : void 0), U(e._zod, "optout", () => t.options.some((s) => s._zod.optout === "optional") ? "optional" : void 0), U(e._zod, "values", () => {
|
|
2732
|
+
if (t.options.every((s) => s._zod.values))
|
|
2733
|
+
return new Set(t.options.flatMap((s) => Array.from(s._zod.values)));
|
|
2734
|
+
}), U(e._zod, "pattern", () => {
|
|
2735
|
+
if (t.options.every((s) => s._zod.pattern)) {
|
|
2736
|
+
const s = t.options.map((o) => o._zod.pattern);
|
|
2737
|
+
return new RegExp(`^(${s.map((o) => Mt(o.source)).join("|")})$`);
|
|
2738
|
+
}
|
|
2739
|
+
});
|
|
2740
|
+
const r = t.options.length === 1, n = t.options[0]._zod.run;
|
|
2741
|
+
e._zod.parse = (s, o) => {
|
|
2742
|
+
if (r)
|
|
2743
|
+
return n(s, o);
|
|
2744
|
+
let i = !1;
|
|
2745
|
+
const a = [];
|
|
2746
|
+
for (const c of t.options) {
|
|
2747
|
+
const f = c._zod.run({
|
|
2748
|
+
value: s.value,
|
|
2749
|
+
issues: []
|
|
2750
|
+
}, o);
|
|
2751
|
+
if (f instanceof Promise)
|
|
2752
|
+
a.push(f), i = !0;
|
|
2753
|
+
else {
|
|
2754
|
+
if (f.issues.length === 0)
|
|
2755
|
+
return f;
|
|
2756
|
+
a.push(f);
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2759
|
+
return i ? Promise.all(a).then((c) => wr(c, s, e, o)) : wr(a, s, e, o);
|
|
2760
|
+
};
|
|
2761
|
+
}), oi = /* @__PURE__ */ h("$ZodIntersection", (e, t) => {
|
|
2762
|
+
W.init(e, t), e._zod.parse = (r, n) => {
|
|
2763
|
+
const s = r.value, o = t.left._zod.run({ value: s, issues: [] }, n), i = t.right._zod.run({ value: s, issues: [] }, n);
|
|
2764
|
+
return o instanceof Promise || i instanceof Promise ? Promise.all([o, i]).then(([c, f]) => kr(r, c, f)) : kr(r, o, i);
|
|
2765
|
+
};
|
|
2766
|
+
});
|
|
2767
|
+
function At(e, t) {
|
|
2768
|
+
if (e === t)
|
|
2769
|
+
return { valid: !0, data: e };
|
|
2770
|
+
if (e instanceof Date && t instanceof Date && +e == +t)
|
|
2771
|
+
return { valid: !0, data: e };
|
|
2772
|
+
if (Ke(e) && Ke(t)) {
|
|
2773
|
+
const r = Object.keys(t), n = Object.keys(e).filter((o) => r.indexOf(o) !== -1), s = { ...e, ...t };
|
|
2774
|
+
for (const o of n) {
|
|
2775
|
+
const i = At(e[o], t[o]);
|
|
2776
|
+
if (!i.valid)
|
|
2777
|
+
return {
|
|
2778
|
+
valid: !1,
|
|
2779
|
+
mergeErrorPath: [o, ...i.mergeErrorPath]
|
|
2780
|
+
};
|
|
2781
|
+
s[o] = i.data;
|
|
2782
|
+
}
|
|
2783
|
+
return { valid: !0, data: s };
|
|
2784
|
+
}
|
|
2785
|
+
if (Array.isArray(e) && Array.isArray(t)) {
|
|
2786
|
+
if (e.length !== t.length)
|
|
2787
|
+
return { valid: !1, mergeErrorPath: [] };
|
|
2788
|
+
const r = [];
|
|
2789
|
+
for (let n = 0; n < e.length; n++) {
|
|
2790
|
+
const s = e[n], o = t[n], i = At(s, o);
|
|
2791
|
+
if (!i.valid)
|
|
2792
|
+
return {
|
|
2793
|
+
valid: !1,
|
|
2794
|
+
mergeErrorPath: [n, ...i.mergeErrorPath]
|
|
2795
|
+
};
|
|
2796
|
+
r.push(i.data);
|
|
2797
|
+
}
|
|
2798
|
+
return { valid: !0, data: r };
|
|
2799
|
+
}
|
|
2800
|
+
return { valid: !1, mergeErrorPath: [] };
|
|
2801
|
+
}
|
|
2802
|
+
function kr(e, t, r) {
|
|
2803
|
+
const n = /* @__PURE__ */ new Map();
|
|
2804
|
+
let s;
|
|
2805
|
+
for (const a of t.issues)
|
|
2806
|
+
if (a.code === "unrecognized_keys") {
|
|
2807
|
+
s ?? (s = a);
|
|
2808
|
+
for (const c of a.keys)
|
|
2809
|
+
n.has(c) || n.set(c, {}), n.get(c).l = !0;
|
|
2810
|
+
} else
|
|
2811
|
+
e.issues.push(a);
|
|
2812
|
+
for (const a of r.issues)
|
|
2813
|
+
if (a.code === "unrecognized_keys")
|
|
2814
|
+
for (const c of a.keys)
|
|
2815
|
+
n.has(c) || n.set(c, {}), n.get(c).r = !0;
|
|
2816
|
+
else
|
|
2817
|
+
e.issues.push(a);
|
|
2818
|
+
const o = [...n].filter(([, a]) => a.l && a.r).map(([a]) => a);
|
|
2819
|
+
if (o.length && s && e.issues.push({ ...s, keys: o }), De(e))
|
|
2820
|
+
return e;
|
|
2821
|
+
const i = At(t.value, r.value);
|
|
2822
|
+
if (!i.valid)
|
|
2823
|
+
throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(i.mergeErrorPath)}`);
|
|
2824
|
+
return e.value = i.data, e;
|
|
2825
|
+
}
|
|
2826
|
+
const ii = /* @__PURE__ */ h("$ZodEnum", (e, t) => {
|
|
2827
|
+
W.init(e, t);
|
|
2828
|
+
const r = rn(t.entries), n = new Set(r);
|
|
2829
|
+
e._zod.values = n, e._zod.pattern = new RegExp(`^(${r.filter((s) => ms.has(typeof s)).map((s) => typeof s == "string" ? Le(s) : s.toString()).join("|")})$`), e._zod.parse = (s, o) => {
|
|
2830
|
+
const i = s.value;
|
|
2831
|
+
return n.has(i) || s.issues.push({
|
|
2832
|
+
code: "invalid_value",
|
|
2833
|
+
values: r,
|
|
2834
|
+
input: i,
|
|
2835
|
+
inst: e
|
|
2836
|
+
}), s;
|
|
2837
|
+
};
|
|
2838
|
+
}), ai = /* @__PURE__ */ h("$ZodLiteral", (e, t) => {
|
|
2839
|
+
if (W.init(e, t), t.values.length === 0)
|
|
2840
|
+
throw new Error("Cannot create literal schema with no valid values");
|
|
2841
|
+
const r = new Set(t.values);
|
|
2842
|
+
e._zod.values = r, e._zod.pattern = new RegExp(`^(${t.values.map((n) => typeof n == "string" ? Le(n) : n ? Le(n.toString()) : String(n)).join("|")})$`), e._zod.parse = (n, s) => {
|
|
2843
|
+
const o = n.value;
|
|
2844
|
+
return r.has(o) || n.issues.push({
|
|
2845
|
+
code: "invalid_value",
|
|
2846
|
+
values: t.values,
|
|
2847
|
+
input: o,
|
|
2848
|
+
inst: e
|
|
2849
|
+
}), n;
|
|
2850
|
+
};
|
|
2851
|
+
}), ui = /* @__PURE__ */ h("$ZodTransform", (e, t) => {
|
|
2852
|
+
W.init(e, t), e._zod.parse = (r, n) => {
|
|
2853
|
+
if (n.direction === "backward")
|
|
2854
|
+
throw new en(e.constructor.name);
|
|
2855
|
+
const s = t.transform(r.value, r);
|
|
2856
|
+
if (n.async)
|
|
2857
|
+
return (s instanceof Promise ? s : Promise.resolve(s)).then((i) => (r.value = i, r));
|
|
2858
|
+
if (s instanceof Promise)
|
|
2859
|
+
throw new Ue();
|
|
2860
|
+
return r.value = s, r;
|
|
2861
|
+
};
|
|
2862
|
+
});
|
|
2863
|
+
function zr(e, t) {
|
|
2864
|
+
return e.issues.length && t === void 0 ? { issues: [], value: void 0 } : e;
|
|
2865
|
+
}
|
|
2866
|
+
const _n = /* @__PURE__ */ h("$ZodOptional", (e, t) => {
|
|
2867
|
+
W.init(e, t), e._zod.optin = "optional", e._zod.optout = "optional", U(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, void 0]) : void 0), U(e._zod, "pattern", () => {
|
|
2868
|
+
const r = t.innerType._zod.pattern;
|
|
2869
|
+
return r ? new RegExp(`^(${Mt(r.source)})?$`) : void 0;
|
|
2870
|
+
}), e._zod.parse = (r, n) => {
|
|
2871
|
+
if (t.innerType._zod.optin === "optional") {
|
|
2872
|
+
const s = t.innerType._zod.run(r, n);
|
|
2873
|
+
return s instanceof Promise ? s.then((o) => zr(o, r.value)) : zr(s, r.value);
|
|
2874
|
+
}
|
|
2875
|
+
return r.value === void 0 ? r : t.innerType._zod.run(r, n);
|
|
2876
|
+
};
|
|
2877
|
+
}), ci = /* @__PURE__ */ h("$ZodExactOptional", (e, t) => {
|
|
2878
|
+
_n.init(e, t), U(e._zod, "values", () => t.innerType._zod.values), U(e._zod, "pattern", () => t.innerType._zod.pattern), e._zod.parse = (r, n) => t.innerType._zod.run(r, n);
|
|
2879
|
+
}), li = /* @__PURE__ */ h("$ZodNullable", (e, t) => {
|
|
2880
|
+
W.init(e, t), U(e._zod, "optin", () => t.innerType._zod.optin), U(e._zod, "optout", () => t.innerType._zod.optout), U(e._zod, "pattern", () => {
|
|
2881
|
+
const r = t.innerType._zod.pattern;
|
|
2882
|
+
return r ? new RegExp(`^(${Mt(r.source)}|null)$`) : void 0;
|
|
2883
|
+
}), U(e._zod, "values", () => t.innerType._zod.values ? /* @__PURE__ */ new Set([...t.innerType._zod.values, null]) : void 0), e._zod.parse = (r, n) => r.value === null ? r : t.innerType._zod.run(r, n);
|
|
2884
|
+
}), fi = /* @__PURE__ */ h("$ZodDefault", (e, t) => {
|
|
2885
|
+
W.init(e, t), e._zod.optin = "optional", U(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (r, n) => {
|
|
2886
|
+
if (n.direction === "backward")
|
|
2887
|
+
return t.innerType._zod.run(r, n);
|
|
2888
|
+
if (r.value === void 0)
|
|
2889
|
+
return r.value = t.defaultValue, r;
|
|
2890
|
+
const s = t.innerType._zod.run(r, n);
|
|
2891
|
+
return s instanceof Promise ? s.then((o) => Sr(o, t)) : Sr(s, t);
|
|
2892
|
+
};
|
|
2893
|
+
});
|
|
2894
|
+
function Sr(e, t) {
|
|
2895
|
+
return e.value === void 0 && (e.value = t.defaultValue), e;
|
|
2896
|
+
}
|
|
2897
|
+
const di = /* @__PURE__ */ h("$ZodPrefault", (e, t) => {
|
|
2898
|
+
W.init(e, t), e._zod.optin = "optional", U(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (r, n) => (n.direction === "backward" || r.value === void 0 && (r.value = t.defaultValue), t.innerType._zod.run(r, n));
|
|
2899
|
+
}), hi = /* @__PURE__ */ h("$ZodNonOptional", (e, t) => {
|
|
2900
|
+
W.init(e, t), U(e._zod, "values", () => {
|
|
2901
|
+
const r = t.innerType._zod.values;
|
|
2902
|
+
return r ? new Set([...r].filter((n) => n !== void 0)) : void 0;
|
|
2903
|
+
}), e._zod.parse = (r, n) => {
|
|
2904
|
+
const s = t.innerType._zod.run(r, n);
|
|
2905
|
+
return s instanceof Promise ? s.then((o) => xr(o, e)) : xr(s, e);
|
|
2906
|
+
};
|
|
2907
|
+
});
|
|
2908
|
+
function xr(e, t) {
|
|
2909
|
+
return !e.issues.length && e.value === void 0 && e.issues.push({
|
|
2910
|
+
code: "invalid_type",
|
|
2911
|
+
expected: "nonoptional",
|
|
2912
|
+
input: e.value,
|
|
2913
|
+
inst: t
|
|
2914
|
+
}), e;
|
|
2915
|
+
}
|
|
2916
|
+
const mi = /* @__PURE__ */ h("$ZodCatch", (e, t) => {
|
|
2917
|
+
W.init(e, t), U(e._zod, "optin", () => t.innerType._zod.optin), U(e._zod, "optout", () => t.innerType._zod.optout), U(e._zod, "values", () => t.innerType._zod.values), e._zod.parse = (r, n) => {
|
|
2918
|
+
if (n.direction === "backward")
|
|
2919
|
+
return t.innerType._zod.run(r, n);
|
|
2920
|
+
const s = t.innerType._zod.run(r, n);
|
|
2921
|
+
return s instanceof Promise ? s.then((o) => (r.value = o.value, o.issues.length && (r.value = t.catchValue({
|
|
2922
|
+
...r,
|
|
2923
|
+
error: {
|
|
2924
|
+
issues: o.issues.map((i) => Ae(i, n, je()))
|
|
2925
|
+
},
|
|
2926
|
+
input: r.value
|
|
2927
|
+
}), r.issues = []), r)) : (r.value = s.value, s.issues.length && (r.value = t.catchValue({
|
|
2928
|
+
...r,
|
|
2929
|
+
error: {
|
|
2930
|
+
issues: s.issues.map((o) => Ae(o, n, je()))
|
|
2931
|
+
},
|
|
2932
|
+
input: r.value
|
|
2933
|
+
}), r.issues = []), r);
|
|
2934
|
+
};
|
|
2935
|
+
}), pi = /* @__PURE__ */ h("$ZodPipe", (e, t) => {
|
|
2936
|
+
W.init(e, t), U(e._zod, "values", () => t.in._zod.values), U(e._zod, "optin", () => t.in._zod.optin), U(e._zod, "optout", () => t.out._zod.optout), U(e._zod, "propValues", () => t.in._zod.propValues), e._zod.parse = (r, n) => {
|
|
2937
|
+
if (n.direction === "backward") {
|
|
2938
|
+
const o = t.out._zod.run(r, n);
|
|
2939
|
+
return o instanceof Promise ? o.then((i) => rt(i, t.in, n)) : rt(o, t.in, n);
|
|
2940
|
+
}
|
|
2941
|
+
const s = t.in._zod.run(r, n);
|
|
2942
|
+
return s instanceof Promise ? s.then((o) => rt(o, t.out, n)) : rt(s, t.out, n);
|
|
2943
|
+
};
|
|
2944
|
+
});
|
|
2945
|
+
function rt(e, t, r) {
|
|
2946
|
+
return e.issues.length ? (e.aborted = !0, e) : t._zod.run({ value: e.value, issues: e.issues }, r);
|
|
2947
|
+
}
|
|
2948
|
+
const vi = /* @__PURE__ */ h("$ZodReadonly", (e, t) => {
|
|
2949
|
+
W.init(e, t), U(e._zod, "propValues", () => t.innerType._zod.propValues), U(e._zod, "values", () => t.innerType._zod.values), U(e._zod, "optin", () => t.innerType?._zod?.optin), U(e._zod, "optout", () => t.innerType?._zod?.optout), e._zod.parse = (r, n) => {
|
|
2950
|
+
if (n.direction === "backward")
|
|
2951
|
+
return t.innerType._zod.run(r, n);
|
|
2952
|
+
const s = t.innerType._zod.run(r, n);
|
|
2953
|
+
return s instanceof Promise ? s.then(Er) : Er(s);
|
|
2954
|
+
};
|
|
2955
|
+
});
|
|
2956
|
+
function Er(e) {
|
|
2957
|
+
return e.value = Object.freeze(e.value), e;
|
|
2958
|
+
}
|
|
2959
|
+
const gi = /* @__PURE__ */ h("$ZodCustom", (e, t) => {
|
|
2960
|
+
he.init(e, t), W.init(e, t), e._zod.parse = (r, n) => r, e._zod.check = (r) => {
|
|
2961
|
+
const n = r.value, s = t.fn(n);
|
|
2962
|
+
if (s instanceof Promise)
|
|
2963
|
+
return s.then((o) => $r(o, r, n, e));
|
|
2964
|
+
$r(s, r, n, e);
|
|
2965
|
+
};
|
|
2966
|
+
});
|
|
2967
|
+
function $r(e, t, r, n) {
|
|
2968
|
+
if (!e) {
|
|
2969
|
+
const s = {
|
|
2970
|
+
code: "custom",
|
|
2971
|
+
input: r,
|
|
2972
|
+
inst: n,
|
|
2973
|
+
// incorporates params.error into issue reporting
|
|
2974
|
+
path: [...n._zod.def.path ?? []],
|
|
2975
|
+
// incorporates params.error into issue reporting
|
|
2976
|
+
continue: !n._zod.def.abort
|
|
2977
|
+
// params: inst._zod.def.params,
|
|
2978
|
+
};
|
|
2979
|
+
n._zod.def.params && (s.params = n._zod.def.params), t.issues.push(Xe(s));
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2982
|
+
var Nr;
|
|
2983
|
+
class _i {
|
|
2984
|
+
constructor() {
|
|
2985
|
+
this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map();
|
|
2986
|
+
}
|
|
2987
|
+
add(t, ...r) {
|
|
2988
|
+
const n = r[0];
|
|
2989
|
+
return this._map.set(t, n), n && typeof n == "object" && "id" in n && this._idmap.set(n.id, t), this;
|
|
2990
|
+
}
|
|
2991
|
+
clear() {
|
|
2992
|
+
return this._map = /* @__PURE__ */ new WeakMap(), this._idmap = /* @__PURE__ */ new Map(), this;
|
|
2993
|
+
}
|
|
2994
|
+
remove(t) {
|
|
2995
|
+
const r = this._map.get(t);
|
|
2996
|
+
return r && typeof r == "object" && "id" in r && this._idmap.delete(r.id), this._map.delete(t), this;
|
|
2997
|
+
}
|
|
2998
|
+
get(t) {
|
|
2999
|
+
const r = t._zod.parent;
|
|
3000
|
+
if (r) {
|
|
3001
|
+
const n = { ...this.get(r) ?? {} };
|
|
3002
|
+
delete n.id;
|
|
3003
|
+
const s = { ...n, ...this._map.get(t) };
|
|
3004
|
+
return Object.keys(s).length ? s : void 0;
|
|
3005
|
+
}
|
|
3006
|
+
return this._map.get(t);
|
|
3007
|
+
}
|
|
3008
|
+
has(t) {
|
|
3009
|
+
return this._map.has(t);
|
|
3010
|
+
}
|
|
3011
|
+
}
|
|
3012
|
+
function yi() {
|
|
3013
|
+
return new _i();
|
|
3014
|
+
}
|
|
3015
|
+
(Nr = globalThis).__zod_globalRegistry ?? (Nr.__zod_globalRegistry = yi());
|
|
3016
|
+
const Ye = globalThis.__zod_globalRegistry;
|
|
3017
|
+
// @__NO_SIDE_EFFECTS__
|
|
3018
|
+
function bi(e, t) {
|
|
3019
|
+
return new e({
|
|
3020
|
+
type: "string",
|
|
3021
|
+
...E(t)
|
|
3022
|
+
});
|
|
3023
|
+
}
|
|
3024
|
+
// @__NO_SIDE_EFFECTS__
|
|
3025
|
+
function wi(e, t) {
|
|
3026
|
+
return new e({
|
|
3027
|
+
type: "string",
|
|
3028
|
+
format: "email",
|
|
3029
|
+
check: "string_format",
|
|
3030
|
+
abort: !1,
|
|
3031
|
+
...E(t)
|
|
3032
|
+
});
|
|
3033
|
+
}
|
|
3034
|
+
// @__NO_SIDE_EFFECTS__
|
|
3035
|
+
function Or(e, t) {
|
|
3036
|
+
return new e({
|
|
3037
|
+
type: "string",
|
|
3038
|
+
format: "guid",
|
|
3039
|
+
check: "string_format",
|
|
3040
|
+
abort: !1,
|
|
3041
|
+
...E(t)
|
|
3042
|
+
});
|
|
3043
|
+
}
|
|
3044
|
+
// @__NO_SIDE_EFFECTS__
|
|
3045
|
+
function ki(e, t) {
|
|
3046
|
+
return new e({
|
|
3047
|
+
type: "string",
|
|
3048
|
+
format: "uuid",
|
|
3049
|
+
check: "string_format",
|
|
3050
|
+
abort: !1,
|
|
3051
|
+
...E(t)
|
|
3052
|
+
});
|
|
3053
|
+
}
|
|
3054
|
+
// @__NO_SIDE_EFFECTS__
|
|
3055
|
+
function zi(e, t) {
|
|
3056
|
+
return new e({
|
|
3057
|
+
type: "string",
|
|
3058
|
+
format: "uuid",
|
|
3059
|
+
check: "string_format",
|
|
3060
|
+
abort: !1,
|
|
3061
|
+
version: "v4",
|
|
3062
|
+
...E(t)
|
|
3063
|
+
});
|
|
3064
|
+
}
|
|
3065
|
+
// @__NO_SIDE_EFFECTS__
|
|
3066
|
+
function Si(e, t) {
|
|
3067
|
+
return new e({
|
|
3068
|
+
type: "string",
|
|
3069
|
+
format: "uuid",
|
|
3070
|
+
check: "string_format",
|
|
3071
|
+
abort: !1,
|
|
3072
|
+
version: "v6",
|
|
3073
|
+
...E(t)
|
|
3074
|
+
});
|
|
3075
|
+
}
|
|
3076
|
+
// @__NO_SIDE_EFFECTS__
|
|
3077
|
+
function xi(e, t) {
|
|
3078
|
+
return new e({
|
|
3079
|
+
type: "string",
|
|
3080
|
+
format: "uuid",
|
|
3081
|
+
check: "string_format",
|
|
3082
|
+
abort: !1,
|
|
3083
|
+
version: "v7",
|
|
3084
|
+
...E(t)
|
|
3085
|
+
});
|
|
3086
|
+
}
|
|
3087
|
+
// @__NO_SIDE_EFFECTS__
|
|
3088
|
+
function Ei(e, t) {
|
|
3089
|
+
return new e({
|
|
3090
|
+
type: "string",
|
|
3091
|
+
format: "url",
|
|
3092
|
+
check: "string_format",
|
|
3093
|
+
abort: !1,
|
|
3094
|
+
...E(t)
|
|
3095
|
+
});
|
|
3096
|
+
}
|
|
3097
|
+
// @__NO_SIDE_EFFECTS__
|
|
3098
|
+
function $i(e, t) {
|
|
3099
|
+
return new e({
|
|
3100
|
+
type: "string",
|
|
3101
|
+
format: "emoji",
|
|
3102
|
+
check: "string_format",
|
|
3103
|
+
abort: !1,
|
|
3104
|
+
...E(t)
|
|
3105
|
+
});
|
|
3106
|
+
}
|
|
3107
|
+
// @__NO_SIDE_EFFECTS__
|
|
3108
|
+
function Ni(e, t) {
|
|
3109
|
+
return new e({
|
|
3110
|
+
type: "string",
|
|
3111
|
+
format: "nanoid",
|
|
3112
|
+
check: "string_format",
|
|
3113
|
+
abort: !1,
|
|
3114
|
+
...E(t)
|
|
3115
|
+
});
|
|
3116
|
+
}
|
|
3117
|
+
// @__NO_SIDE_EFFECTS__
|
|
3118
|
+
function Oi(e, t) {
|
|
3119
|
+
return new e({
|
|
3120
|
+
type: "string",
|
|
3121
|
+
format: "cuid",
|
|
3122
|
+
check: "string_format",
|
|
3123
|
+
abort: !1,
|
|
3124
|
+
...E(t)
|
|
3125
|
+
});
|
|
3126
|
+
}
|
|
3127
|
+
// @__NO_SIDE_EFFECTS__
|
|
3128
|
+
function ji(e, t) {
|
|
3129
|
+
return new e({
|
|
3130
|
+
type: "string",
|
|
3131
|
+
format: "cuid2",
|
|
3132
|
+
check: "string_format",
|
|
3133
|
+
abort: !1,
|
|
3134
|
+
...E(t)
|
|
3135
|
+
});
|
|
3136
|
+
}
|
|
3137
|
+
// @__NO_SIDE_EFFECTS__
|
|
3138
|
+
function Ai(e, t) {
|
|
3139
|
+
return new e({
|
|
3140
|
+
type: "string",
|
|
3141
|
+
format: "ulid",
|
|
3142
|
+
check: "string_format",
|
|
3143
|
+
abort: !1,
|
|
3144
|
+
...E(t)
|
|
3145
|
+
});
|
|
3146
|
+
}
|
|
3147
|
+
// @__NO_SIDE_EFFECTS__
|
|
3148
|
+
function Zi(e, t) {
|
|
3149
|
+
return new e({
|
|
3150
|
+
type: "string",
|
|
3151
|
+
format: "xid",
|
|
3152
|
+
check: "string_format",
|
|
3153
|
+
abort: !1,
|
|
3154
|
+
...E(t)
|
|
3155
|
+
});
|
|
3156
|
+
}
|
|
3157
|
+
// @__NO_SIDE_EFFECTS__
|
|
3158
|
+
function Ti(e, t) {
|
|
3159
|
+
return new e({
|
|
3160
|
+
type: "string",
|
|
3161
|
+
format: "ksuid",
|
|
3162
|
+
check: "string_format",
|
|
3163
|
+
abort: !1,
|
|
3164
|
+
...E(t)
|
|
3165
|
+
});
|
|
3166
|
+
}
|
|
3167
|
+
// @__NO_SIDE_EFFECTS__
|
|
3168
|
+
function Fi(e, t) {
|
|
3169
|
+
return new e({
|
|
3170
|
+
type: "string",
|
|
3171
|
+
format: "ipv4",
|
|
3172
|
+
check: "string_format",
|
|
3173
|
+
abort: !1,
|
|
3174
|
+
...E(t)
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
// @__NO_SIDE_EFFECTS__
|
|
3178
|
+
function Pi(e, t) {
|
|
3179
|
+
return new e({
|
|
3180
|
+
type: "string",
|
|
3181
|
+
format: "ipv6",
|
|
3182
|
+
check: "string_format",
|
|
3183
|
+
abort: !1,
|
|
3184
|
+
...E(t)
|
|
3185
|
+
});
|
|
3186
|
+
}
|
|
3187
|
+
// @__NO_SIDE_EFFECTS__
|
|
3188
|
+
function Ri(e, t) {
|
|
3189
|
+
return new e({
|
|
3190
|
+
type: "string",
|
|
3191
|
+
format: "cidrv4",
|
|
3192
|
+
check: "string_format",
|
|
3193
|
+
abort: !1,
|
|
3194
|
+
...E(t)
|
|
3195
|
+
});
|
|
3196
|
+
}
|
|
3197
|
+
// @__NO_SIDE_EFFECTS__
|
|
3198
|
+
function Ii(e, t) {
|
|
3199
|
+
return new e({
|
|
3200
|
+
type: "string",
|
|
3201
|
+
format: "cidrv6",
|
|
3202
|
+
check: "string_format",
|
|
3203
|
+
abort: !1,
|
|
3204
|
+
...E(t)
|
|
3205
|
+
});
|
|
3206
|
+
}
|
|
3207
|
+
// @__NO_SIDE_EFFECTS__
|
|
3208
|
+
function Ci(e, t) {
|
|
3209
|
+
return new e({
|
|
3210
|
+
type: "string",
|
|
3211
|
+
format: "base64",
|
|
3212
|
+
check: "string_format",
|
|
3213
|
+
abort: !1,
|
|
3214
|
+
...E(t)
|
|
3215
|
+
});
|
|
3216
|
+
}
|
|
3217
|
+
// @__NO_SIDE_EFFECTS__
|
|
3218
|
+
function Vi(e, t) {
|
|
3219
|
+
return new e({
|
|
3220
|
+
type: "string",
|
|
3221
|
+
format: "base64url",
|
|
3222
|
+
check: "string_format",
|
|
3223
|
+
abort: !1,
|
|
3224
|
+
...E(t)
|
|
3225
|
+
});
|
|
3226
|
+
}
|
|
3227
|
+
// @__NO_SIDE_EFFECTS__
|
|
3228
|
+
function Di(e, t) {
|
|
3229
|
+
return new e({
|
|
3230
|
+
type: "string",
|
|
3231
|
+
format: "e164",
|
|
3232
|
+
check: "string_format",
|
|
3233
|
+
abort: !1,
|
|
3234
|
+
...E(t)
|
|
3235
|
+
});
|
|
3236
|
+
}
|
|
3237
|
+
// @__NO_SIDE_EFFECTS__
|
|
3238
|
+
function Ui(e, t) {
|
|
3239
|
+
return new e({
|
|
3240
|
+
type: "string",
|
|
3241
|
+
format: "jwt",
|
|
3242
|
+
check: "string_format",
|
|
3243
|
+
abort: !1,
|
|
3244
|
+
...E(t)
|
|
3245
|
+
});
|
|
3246
|
+
}
|
|
3247
|
+
// @__NO_SIDE_EFFECTS__
|
|
3248
|
+
function Li(e, t) {
|
|
3249
|
+
return new e({
|
|
3250
|
+
type: "string",
|
|
3251
|
+
format: "datetime",
|
|
3252
|
+
check: "string_format",
|
|
3253
|
+
offset: !1,
|
|
3254
|
+
local: !1,
|
|
3255
|
+
precision: null,
|
|
3256
|
+
...E(t)
|
|
3257
|
+
});
|
|
3258
|
+
}
|
|
3259
|
+
// @__NO_SIDE_EFFECTS__
|
|
3260
|
+
function Mi(e, t) {
|
|
3261
|
+
return new e({
|
|
3262
|
+
type: "string",
|
|
3263
|
+
format: "date",
|
|
3264
|
+
check: "string_format",
|
|
3265
|
+
...E(t)
|
|
3266
|
+
});
|
|
3267
|
+
}
|
|
3268
|
+
// @__NO_SIDE_EFFECTS__
|
|
3269
|
+
function Ji(e, t) {
|
|
3270
|
+
return new e({
|
|
3271
|
+
type: "string",
|
|
3272
|
+
format: "time",
|
|
3273
|
+
check: "string_format",
|
|
3274
|
+
precision: null,
|
|
3275
|
+
...E(t)
|
|
3276
|
+
});
|
|
3277
|
+
}
|
|
3278
|
+
// @__NO_SIDE_EFFECTS__
|
|
3279
|
+
function Bi(e, t) {
|
|
3280
|
+
return new e({
|
|
3281
|
+
type: "string",
|
|
3282
|
+
format: "duration",
|
|
3283
|
+
check: "string_format",
|
|
3284
|
+
...E(t)
|
|
3285
|
+
});
|
|
3286
|
+
}
|
|
3287
|
+
// @__NO_SIDE_EFFECTS__
|
|
3288
|
+
function Wi(e, t) {
|
|
3289
|
+
return new e({
|
|
3290
|
+
type: "number",
|
|
3291
|
+
coerce: !0,
|
|
3292
|
+
checks: [],
|
|
3293
|
+
...E(t)
|
|
3294
|
+
});
|
|
3295
|
+
}
|
|
3296
|
+
// @__NO_SIDE_EFFECTS__
|
|
3297
|
+
function qi(e, t) {
|
|
3298
|
+
return new e({
|
|
3299
|
+
type: "number",
|
|
3300
|
+
check: "number_format",
|
|
3301
|
+
abort: !1,
|
|
3302
|
+
format: "safeint",
|
|
3303
|
+
...E(t)
|
|
3304
|
+
});
|
|
3305
|
+
}
|
|
3306
|
+
// @__NO_SIDE_EFFECTS__
|
|
3307
|
+
function Yi(e, t) {
|
|
3308
|
+
return new e({
|
|
3309
|
+
type: "boolean",
|
|
3310
|
+
...E(t)
|
|
3311
|
+
});
|
|
3312
|
+
}
|
|
3313
|
+
// @__NO_SIDE_EFFECTS__
|
|
3314
|
+
function Gi(e) {
|
|
3315
|
+
return new e({
|
|
3316
|
+
type: "any"
|
|
3317
|
+
});
|
|
3318
|
+
}
|
|
3319
|
+
// @__NO_SIDE_EFFECTS__
|
|
3320
|
+
function Hi(e) {
|
|
3321
|
+
return new e({
|
|
3322
|
+
type: "unknown"
|
|
3323
|
+
});
|
|
3324
|
+
}
|
|
3325
|
+
// @__NO_SIDE_EFFECTS__
|
|
3326
|
+
function Ki(e, t) {
|
|
3327
|
+
return new e({
|
|
3328
|
+
type: "never",
|
|
3329
|
+
...E(t)
|
|
3330
|
+
});
|
|
3331
|
+
}
|
|
3332
|
+
// @__NO_SIDE_EFFECTS__
|
|
3333
|
+
function jr(e, t) {
|
|
3334
|
+
return new dn({
|
|
3335
|
+
check: "less_than",
|
|
3336
|
+
...E(t),
|
|
3337
|
+
value: e,
|
|
3338
|
+
inclusive: !1
|
|
3339
|
+
});
|
|
3340
|
+
}
|
|
3341
|
+
// @__NO_SIDE_EFFECTS__
|
|
3342
|
+
function zt(e, t) {
|
|
3343
|
+
return new dn({
|
|
3344
|
+
check: "less_than",
|
|
3345
|
+
...E(t),
|
|
3346
|
+
value: e,
|
|
3347
|
+
inclusive: !0
|
|
3348
|
+
});
|
|
3349
|
+
}
|
|
3350
|
+
// @__NO_SIDE_EFFECTS__
|
|
3351
|
+
function Ar(e, t) {
|
|
3352
|
+
return new hn({
|
|
3353
|
+
check: "greater_than",
|
|
3354
|
+
...E(t),
|
|
3355
|
+
value: e,
|
|
3356
|
+
inclusive: !1
|
|
3357
|
+
});
|
|
3358
|
+
}
|
|
3359
|
+
// @__NO_SIDE_EFFECTS__
|
|
3360
|
+
function St(e, t) {
|
|
3361
|
+
return new hn({
|
|
3362
|
+
check: "greater_than",
|
|
3363
|
+
...E(t),
|
|
3364
|
+
value: e,
|
|
3365
|
+
inclusive: !0
|
|
3366
|
+
});
|
|
3367
|
+
}
|
|
3368
|
+
// @__NO_SIDE_EFFECTS__
|
|
3369
|
+
function Zr(e, t) {
|
|
3370
|
+
return new lo({
|
|
3371
|
+
check: "multiple_of",
|
|
3372
|
+
...E(t),
|
|
3373
|
+
value: e
|
|
3374
|
+
});
|
|
3375
|
+
}
|
|
3376
|
+
// @__NO_SIDE_EFFECTS__
|
|
3377
|
+
function yn(e, t) {
|
|
3378
|
+
return new ho({
|
|
3379
|
+
check: "max_length",
|
|
3380
|
+
...E(t),
|
|
3381
|
+
maximum: e
|
|
3382
|
+
});
|
|
3383
|
+
}
|
|
3384
|
+
// @__NO_SIDE_EFFECTS__
|
|
3385
|
+
function lt(e, t) {
|
|
3386
|
+
return new mo({
|
|
3387
|
+
check: "min_length",
|
|
3388
|
+
...E(t),
|
|
3389
|
+
minimum: e
|
|
3390
|
+
});
|
|
3391
|
+
}
|
|
3392
|
+
// @__NO_SIDE_EFFECTS__
|
|
3393
|
+
function bn(e, t) {
|
|
3394
|
+
return new po({
|
|
3395
|
+
check: "length_equals",
|
|
3396
|
+
...E(t),
|
|
3397
|
+
length: e
|
|
3398
|
+
});
|
|
3399
|
+
}
|
|
3400
|
+
// @__NO_SIDE_EFFECTS__
|
|
3401
|
+
function Xi(e, t) {
|
|
3402
|
+
return new vo({
|
|
3403
|
+
check: "string_format",
|
|
3404
|
+
format: "regex",
|
|
3405
|
+
...E(t),
|
|
3406
|
+
pattern: e
|
|
3407
|
+
});
|
|
3408
|
+
}
|
|
3409
|
+
// @__NO_SIDE_EFFECTS__
|
|
3410
|
+
function Qi(e) {
|
|
3411
|
+
return new go({
|
|
3412
|
+
check: "string_format",
|
|
3413
|
+
format: "lowercase",
|
|
3414
|
+
...E(e)
|
|
3415
|
+
});
|
|
3416
|
+
}
|
|
3417
|
+
// @__NO_SIDE_EFFECTS__
|
|
3418
|
+
function ea(e) {
|
|
3419
|
+
return new _o({
|
|
3420
|
+
check: "string_format",
|
|
3421
|
+
format: "uppercase",
|
|
3422
|
+
...E(e)
|
|
3423
|
+
});
|
|
3424
|
+
}
|
|
3425
|
+
// @__NO_SIDE_EFFECTS__
|
|
3426
|
+
function ta(e, t) {
|
|
3427
|
+
return new yo({
|
|
3428
|
+
check: "string_format",
|
|
3429
|
+
format: "includes",
|
|
3430
|
+
...E(t),
|
|
3431
|
+
includes: e
|
|
3432
|
+
});
|
|
3433
|
+
}
|
|
3434
|
+
// @__NO_SIDE_EFFECTS__
|
|
3435
|
+
function ra(e, t) {
|
|
3436
|
+
return new bo({
|
|
3437
|
+
check: "string_format",
|
|
3438
|
+
format: "starts_with",
|
|
3439
|
+
...E(t),
|
|
3440
|
+
prefix: e
|
|
3441
|
+
});
|
|
3442
|
+
}
|
|
3443
|
+
// @__NO_SIDE_EFFECTS__
|
|
3444
|
+
function na(e, t) {
|
|
3445
|
+
return new wo({
|
|
3446
|
+
check: "string_format",
|
|
3447
|
+
format: "ends_with",
|
|
3448
|
+
...E(t),
|
|
3449
|
+
suffix: e
|
|
3450
|
+
});
|
|
3451
|
+
}
|
|
3452
|
+
// @__NO_SIDE_EFFECTS__
|
|
3453
|
+
function Me(e) {
|
|
3454
|
+
return new ko({
|
|
3455
|
+
check: "overwrite",
|
|
3456
|
+
tx: e
|
|
3457
|
+
});
|
|
3458
|
+
}
|
|
3459
|
+
// @__NO_SIDE_EFFECTS__
|
|
3460
|
+
function sa(e) {
|
|
3461
|
+
return /* @__PURE__ */ Me((t) => t.normalize(e));
|
|
3462
|
+
}
|
|
3463
|
+
// @__NO_SIDE_EFFECTS__
|
|
3464
|
+
function oa() {
|
|
3465
|
+
return /* @__PURE__ */ Me((e) => e.trim());
|
|
3466
|
+
}
|
|
3467
|
+
// @__NO_SIDE_EFFECTS__
|
|
3468
|
+
function ia() {
|
|
3469
|
+
return /* @__PURE__ */ Me((e) => e.toLowerCase());
|
|
3470
|
+
}
|
|
3471
|
+
// @__NO_SIDE_EFFECTS__
|
|
3472
|
+
function aa() {
|
|
3473
|
+
return /* @__PURE__ */ Me((e) => e.toUpperCase());
|
|
3474
|
+
}
|
|
3475
|
+
// @__NO_SIDE_EFFECTS__
|
|
3476
|
+
function ua() {
|
|
3477
|
+
return /* @__PURE__ */ Me((e) => ds(e));
|
|
3478
|
+
}
|
|
3479
|
+
// @__NO_SIDE_EFFECTS__
|
|
3480
|
+
function ca(e, t, r) {
|
|
3481
|
+
return new e({
|
|
3482
|
+
type: "array",
|
|
3483
|
+
element: t,
|
|
3484
|
+
// get element() {
|
|
3485
|
+
// return element;
|
|
3486
|
+
// },
|
|
3487
|
+
...E(r)
|
|
3488
|
+
});
|
|
3489
|
+
}
|
|
3490
|
+
// @__NO_SIDE_EFFECTS__
|
|
3491
|
+
function la(e, t, r) {
|
|
3492
|
+
return new e({
|
|
3493
|
+
type: "custom",
|
|
3494
|
+
check: "custom",
|
|
3495
|
+
fn: t,
|
|
3496
|
+
...E(r)
|
|
3497
|
+
});
|
|
3498
|
+
}
|
|
3499
|
+
// @__NO_SIDE_EFFECTS__
|
|
3500
|
+
function fa(e) {
|
|
3501
|
+
const t = /* @__PURE__ */ da((r) => (r.addIssue = (n) => {
|
|
3502
|
+
if (typeof n == "string")
|
|
3503
|
+
r.issues.push(Xe(n, r.value, t._zod.def));
|
|
3504
|
+
else {
|
|
3505
|
+
const s = n;
|
|
3506
|
+
s.fatal && (s.continue = !1), s.code ?? (s.code = "custom"), s.input ?? (s.input = r.value), s.inst ?? (s.inst = t), s.continue ?? (s.continue = !t._zod.def.abort), r.issues.push(Xe(s));
|
|
3507
|
+
}
|
|
3508
|
+
}, e(r.value, r)));
|
|
3509
|
+
return t;
|
|
3510
|
+
}
|
|
3511
|
+
// @__NO_SIDE_EFFECTS__
|
|
3512
|
+
function da(e, t) {
|
|
3513
|
+
const r = new he({
|
|
3514
|
+
check: "custom",
|
|
3515
|
+
...E(t)
|
|
3516
|
+
});
|
|
3517
|
+
return r._zod.check = e, r;
|
|
3518
|
+
}
|
|
3519
|
+
function wn(e) {
|
|
3520
|
+
let t = e?.target ?? "draft-2020-12";
|
|
3521
|
+
return t === "draft-4" && (t = "draft-04"), t === "draft-7" && (t = "draft-07"), {
|
|
3522
|
+
processors: e.processors ?? {},
|
|
3523
|
+
metadataRegistry: e?.metadata ?? Ye,
|
|
3524
|
+
target: t,
|
|
3525
|
+
unrepresentable: e?.unrepresentable ?? "throw",
|
|
3526
|
+
override: e?.override ?? (() => {
|
|
3527
|
+
}),
|
|
3528
|
+
io: e?.io ?? "output",
|
|
3529
|
+
counter: 0,
|
|
3530
|
+
seen: /* @__PURE__ */ new Map(),
|
|
3531
|
+
cycles: e?.cycles ?? "ref",
|
|
3532
|
+
reused: e?.reused ?? "inline",
|
|
3533
|
+
external: e?.external ?? void 0
|
|
3534
|
+
};
|
|
3535
|
+
}
|
|
3536
|
+
function ne(e, t, r = { path: [], schemaPath: [] }) {
|
|
3537
|
+
var n;
|
|
3538
|
+
const s = e._zod.def, o = t.seen.get(e);
|
|
3539
|
+
if (o)
|
|
3540
|
+
return o.count++, r.schemaPath.includes(e) && (o.cycle = r.path), o.schema;
|
|
3541
|
+
const i = { schema: {}, count: 1, cycle: void 0, path: r.path };
|
|
3542
|
+
t.seen.set(e, i);
|
|
3543
|
+
const a = e._zod.toJSONSchema?.();
|
|
3544
|
+
if (a)
|
|
3545
|
+
i.schema = a;
|
|
3546
|
+
else {
|
|
3547
|
+
const _ = {
|
|
3548
|
+
...r,
|
|
3549
|
+
schemaPath: [...r.schemaPath, e],
|
|
3550
|
+
path: r.path
|
|
3551
|
+
};
|
|
3552
|
+
if (e._zod.processJSONSchema)
|
|
3553
|
+
e._zod.processJSONSchema(t, i.schema, _);
|
|
3554
|
+
else {
|
|
3555
|
+
const b = i.schema, v = t.processors[s.type];
|
|
3556
|
+
if (!v)
|
|
3557
|
+
throw new Error(`[toJSONSchema]: Non-representable type encountered: ${s.type}`);
|
|
3558
|
+
v(e, t, b, _);
|
|
3559
|
+
}
|
|
3560
|
+
const g = e._zod.parent;
|
|
3561
|
+
g && (i.ref || (i.ref = g), ne(g, t, _), t.seen.get(g).isParent = !0);
|
|
3562
|
+
}
|
|
3563
|
+
const c = t.metadataRegistry.get(e);
|
|
3564
|
+
return c && Object.assign(i.schema, c), t.io === "input" && ie(e) && (delete i.schema.examples, delete i.schema.default), t.io === "input" && i.schema._prefault && ((n = i.schema).default ?? (n.default = i.schema._prefault)), delete i.schema._prefault, t.seen.get(e).schema;
|
|
3565
|
+
}
|
|
3566
|
+
function kn(e, t) {
|
|
3567
|
+
const r = e.seen.get(t);
|
|
3568
|
+
if (!r)
|
|
3569
|
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3570
|
+
const n = /* @__PURE__ */ new Map();
|
|
3571
|
+
for (const i of e.seen.entries()) {
|
|
3572
|
+
const a = e.metadataRegistry.get(i[0])?.id;
|
|
3573
|
+
if (a) {
|
|
3574
|
+
const c = n.get(a);
|
|
3575
|
+
if (c && c !== i[0])
|
|
3576
|
+
throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
3577
|
+
n.set(a, i[0]);
|
|
3578
|
+
}
|
|
3579
|
+
}
|
|
3580
|
+
const s = (i) => {
|
|
3581
|
+
const a = e.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
3582
|
+
if (e.external) {
|
|
3583
|
+
const g = e.external.registry.get(i[0])?.id, b = e.external.uri ?? ((Z) => Z);
|
|
3584
|
+
if (g)
|
|
3585
|
+
return { ref: b(g) };
|
|
3586
|
+
const v = i[1].defId ?? i[1].schema.id ?? `schema${e.counter++}`;
|
|
3587
|
+
return i[1].defId = v, { defId: v, ref: `${b("__shared")}#/${a}/${v}` };
|
|
3588
|
+
}
|
|
3589
|
+
if (i[1] === r)
|
|
3590
|
+
return { ref: "#" };
|
|
3591
|
+
const f = `#/${a}/`, _ = i[1].schema.id ?? `__schema${e.counter++}`;
|
|
3592
|
+
return { defId: _, ref: f + _ };
|
|
3593
|
+
}, o = (i) => {
|
|
3594
|
+
if (i[1].schema.$ref)
|
|
3595
|
+
return;
|
|
3596
|
+
const a = i[1], { ref: c, defId: f } = s(i);
|
|
3597
|
+
a.def = { ...a.schema }, f && (a.defId = f);
|
|
3598
|
+
const _ = a.schema;
|
|
3599
|
+
for (const g in _)
|
|
3600
|
+
delete _[g];
|
|
3601
|
+
_.$ref = c;
|
|
3602
|
+
};
|
|
3603
|
+
if (e.cycles === "throw")
|
|
3604
|
+
for (const i of e.seen.entries()) {
|
|
3605
|
+
const a = i[1];
|
|
3606
|
+
if (a.cycle)
|
|
3607
|
+
throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
3608
|
+
|
|
3609
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
3610
|
+
}
|
|
3611
|
+
for (const i of e.seen.entries()) {
|
|
3612
|
+
const a = i[1];
|
|
3613
|
+
if (t === i[0]) {
|
|
3614
|
+
o(i);
|
|
3615
|
+
continue;
|
|
3616
|
+
}
|
|
3617
|
+
if (e.external) {
|
|
3618
|
+
const f = e.external.registry.get(i[0])?.id;
|
|
3619
|
+
if (t !== i[0] && f) {
|
|
3620
|
+
o(i);
|
|
3621
|
+
continue;
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
if (e.metadataRegistry.get(i[0])?.id) {
|
|
3625
|
+
o(i);
|
|
3626
|
+
continue;
|
|
3627
|
+
}
|
|
3628
|
+
if (a.cycle) {
|
|
3629
|
+
o(i);
|
|
3630
|
+
continue;
|
|
3631
|
+
}
|
|
3632
|
+
if (a.count > 1 && e.reused === "ref") {
|
|
3633
|
+
o(i);
|
|
3634
|
+
continue;
|
|
3635
|
+
}
|
|
3636
|
+
}
|
|
3637
|
+
}
|
|
3638
|
+
function zn(e, t) {
|
|
3639
|
+
const r = e.seen.get(t);
|
|
3640
|
+
if (!r)
|
|
3641
|
+
throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
3642
|
+
const n = (i) => {
|
|
3643
|
+
const a = e.seen.get(i);
|
|
3644
|
+
if (a.ref === null)
|
|
3645
|
+
return;
|
|
3646
|
+
const c = a.def ?? a.schema, f = { ...c }, _ = a.ref;
|
|
3647
|
+
if (a.ref = null, _) {
|
|
3648
|
+
n(_);
|
|
3649
|
+
const b = e.seen.get(_), v = b.schema;
|
|
3650
|
+
if (v.$ref && (e.target === "draft-07" || e.target === "draft-04" || e.target === "openapi-3.0") ? (c.allOf = c.allOf ?? [], c.allOf.push(v)) : Object.assign(c, v), Object.assign(c, f), i._zod.parent === _)
|
|
3651
|
+
for (const O in c)
|
|
3652
|
+
O === "$ref" || O === "allOf" || O in f || delete c[O];
|
|
3653
|
+
if (v.$ref && b.def)
|
|
3654
|
+
for (const O in c)
|
|
3655
|
+
O === "$ref" || O === "allOf" || O in b.def && JSON.stringify(c[O]) === JSON.stringify(b.def[O]) && delete c[O];
|
|
3656
|
+
}
|
|
3657
|
+
const g = i._zod.parent;
|
|
3658
|
+
if (g && g !== _) {
|
|
3659
|
+
n(g);
|
|
3660
|
+
const b = e.seen.get(g);
|
|
3661
|
+
if (b?.schema.$ref && (c.$ref = b.schema.$ref, b.def))
|
|
3662
|
+
for (const v in c)
|
|
3663
|
+
v === "$ref" || v === "allOf" || v in b.def && JSON.stringify(c[v]) === JSON.stringify(b.def[v]) && delete c[v];
|
|
3664
|
+
}
|
|
3665
|
+
e.override({
|
|
3666
|
+
zodSchema: i,
|
|
3667
|
+
jsonSchema: c,
|
|
3668
|
+
path: a.path ?? []
|
|
3669
|
+
});
|
|
3670
|
+
};
|
|
3671
|
+
for (const i of [...e.seen.entries()].reverse())
|
|
3672
|
+
n(i[0]);
|
|
3673
|
+
const s = {};
|
|
3674
|
+
if (e.target === "draft-2020-12" ? s.$schema = "https://json-schema.org/draft/2020-12/schema" : e.target === "draft-07" ? s.$schema = "http://json-schema.org/draft-07/schema#" : e.target === "draft-04" ? s.$schema = "http://json-schema.org/draft-04/schema#" : e.target, e.external?.uri) {
|
|
3675
|
+
const i = e.external.registry.get(t)?.id;
|
|
3676
|
+
if (!i)
|
|
3677
|
+
throw new Error("Schema is missing an `id` property");
|
|
3678
|
+
s.$id = e.external.uri(i);
|
|
3679
|
+
}
|
|
3680
|
+
Object.assign(s, r.def ?? r.schema);
|
|
3681
|
+
const o = e.external?.defs ?? {};
|
|
3682
|
+
for (const i of e.seen.entries()) {
|
|
3683
|
+
const a = i[1];
|
|
3684
|
+
a.def && a.defId && (o[a.defId] = a.def);
|
|
3685
|
+
}
|
|
3686
|
+
e.external || Object.keys(o).length > 0 && (e.target === "draft-2020-12" ? s.$defs = o : s.definitions = o);
|
|
3687
|
+
try {
|
|
3688
|
+
const i = JSON.parse(JSON.stringify(s));
|
|
3689
|
+
return Object.defineProperty(i, "~standard", {
|
|
3690
|
+
value: {
|
|
3691
|
+
...t["~standard"],
|
|
3692
|
+
jsonSchema: {
|
|
3693
|
+
input: ft(t, "input", e.processors),
|
|
3694
|
+
output: ft(t, "output", e.processors)
|
|
3695
|
+
}
|
|
3696
|
+
},
|
|
3697
|
+
enumerable: !1,
|
|
3698
|
+
writable: !1
|
|
3699
|
+
}), i;
|
|
3700
|
+
} catch {
|
|
3701
|
+
throw new Error("Error converting schema to JSON.");
|
|
3702
|
+
}
|
|
3703
|
+
}
|
|
3704
|
+
function ie(e, t) {
|
|
3705
|
+
const r = t ?? { seen: /* @__PURE__ */ new Set() };
|
|
3706
|
+
if (r.seen.has(e))
|
|
3707
|
+
return !1;
|
|
3708
|
+
r.seen.add(e);
|
|
3709
|
+
const n = e._zod.def;
|
|
3710
|
+
if (n.type === "transform")
|
|
3711
|
+
return !0;
|
|
3712
|
+
if (n.type === "array")
|
|
3713
|
+
return ie(n.element, r);
|
|
3714
|
+
if (n.type === "set")
|
|
3715
|
+
return ie(n.valueType, r);
|
|
3716
|
+
if (n.type === "lazy")
|
|
3717
|
+
return ie(n.getter(), r);
|
|
3718
|
+
if (n.type === "promise" || n.type === "optional" || n.type === "nonoptional" || n.type === "nullable" || n.type === "readonly" || n.type === "default" || n.type === "prefault")
|
|
3719
|
+
return ie(n.innerType, r);
|
|
3720
|
+
if (n.type === "intersection")
|
|
3721
|
+
return ie(n.left, r) || ie(n.right, r);
|
|
3722
|
+
if (n.type === "record" || n.type === "map")
|
|
3723
|
+
return ie(n.keyType, r) || ie(n.valueType, r);
|
|
3724
|
+
if (n.type === "pipe")
|
|
3725
|
+
return ie(n.in, r) || ie(n.out, r);
|
|
3726
|
+
if (n.type === "object") {
|
|
3727
|
+
for (const s in n.shape)
|
|
3728
|
+
if (ie(n.shape[s], r))
|
|
3729
|
+
return !0;
|
|
3730
|
+
return !1;
|
|
3731
|
+
}
|
|
3732
|
+
if (n.type === "union") {
|
|
3733
|
+
for (const s of n.options)
|
|
3734
|
+
if (ie(s, r))
|
|
3735
|
+
return !0;
|
|
3736
|
+
return !1;
|
|
3737
|
+
}
|
|
3738
|
+
if (n.type === "tuple") {
|
|
3739
|
+
for (const s of n.items)
|
|
3740
|
+
if (ie(s, r))
|
|
3741
|
+
return !0;
|
|
3742
|
+
return !!(n.rest && ie(n.rest, r));
|
|
3743
|
+
}
|
|
3744
|
+
return !1;
|
|
3745
|
+
}
|
|
3746
|
+
const ha = (e, t = {}) => (r) => {
|
|
3747
|
+
const n = wn({ ...r, processors: t });
|
|
3748
|
+
return ne(e, n), kn(n, e), zn(n, e);
|
|
3749
|
+
}, ft = (e, t, r = {}) => (n) => {
|
|
3750
|
+
const { libraryOptions: s, target: o } = n ?? {}, i = wn({ ...s ?? {}, target: o, io: t, processors: r });
|
|
3751
|
+
return ne(e, i), kn(i, e), zn(i, e);
|
|
3752
|
+
}, ma = {
|
|
3753
|
+
guid: "uuid",
|
|
3754
|
+
url: "uri",
|
|
3755
|
+
datetime: "date-time",
|
|
3756
|
+
json_string: "json-string",
|
|
3757
|
+
regex: ""
|
|
3758
|
+
// do not set
|
|
3759
|
+
}, pa = (e, t, r, n) => {
|
|
3760
|
+
const s = r;
|
|
3761
|
+
s.type = "string";
|
|
3762
|
+
const { minimum: o, maximum: i, format: a, patterns: c, contentEncoding: f } = e._zod.bag;
|
|
3763
|
+
if (typeof o == "number" && (s.minLength = o), typeof i == "number" && (s.maxLength = i), a && (s.format = ma[a] ?? a, s.format === "" && delete s.format, a === "time" && delete s.format), f && (s.contentEncoding = f), c && c.size > 0) {
|
|
3764
|
+
const _ = [...c];
|
|
3765
|
+
_.length === 1 ? s.pattern = _[0].source : _.length > 1 && (s.allOf = [
|
|
3766
|
+
..._.map((g) => ({
|
|
3767
|
+
...t.target === "draft-07" || t.target === "draft-04" || t.target === "openapi-3.0" ? { type: "string" } : {},
|
|
3768
|
+
pattern: g.source
|
|
3769
|
+
}))
|
|
3770
|
+
]);
|
|
3771
|
+
}
|
|
3772
|
+
}, va = (e, t, r, n) => {
|
|
3773
|
+
const s = r, { minimum: o, maximum: i, format: a, multipleOf: c, exclusiveMaximum: f, exclusiveMinimum: _ } = e._zod.bag;
|
|
3774
|
+
typeof a == "string" && a.includes("int") ? s.type = "integer" : s.type = "number", typeof _ == "number" && (t.target === "draft-04" || t.target === "openapi-3.0" ? (s.minimum = _, s.exclusiveMinimum = !0) : s.exclusiveMinimum = _), typeof o == "number" && (s.minimum = o, typeof _ == "number" && t.target !== "draft-04" && (_ >= o ? delete s.minimum : delete s.exclusiveMinimum)), typeof f == "number" && (t.target === "draft-04" || t.target === "openapi-3.0" ? (s.maximum = f, s.exclusiveMaximum = !0) : s.exclusiveMaximum = f), typeof i == "number" && (s.maximum = i, typeof f == "number" && t.target !== "draft-04" && (f <= i ? delete s.maximum : delete s.exclusiveMaximum)), typeof c == "number" && (s.multipleOf = c);
|
|
3775
|
+
}, ga = (e, t, r, n) => {
|
|
3776
|
+
r.type = "boolean";
|
|
3777
|
+
}, _a = (e, t, r, n) => {
|
|
3778
|
+
r.not = {};
|
|
3779
|
+
}, ya = (e, t, r, n) => {
|
|
3780
|
+
}, ba = (e, t, r, n) => {
|
|
3781
|
+
}, wa = (e, t, r, n) => {
|
|
3782
|
+
const s = e._zod.def, o = rn(s.entries);
|
|
3783
|
+
o.every((i) => typeof i == "number") && (r.type = "number"), o.every((i) => typeof i == "string") && (r.type = "string"), r.enum = o;
|
|
3784
|
+
}, ka = (e, t, r, n) => {
|
|
3785
|
+
const s = e._zod.def, o = [];
|
|
3786
|
+
for (const i of s.values)
|
|
3787
|
+
if (i === void 0) {
|
|
3788
|
+
if (t.unrepresentable === "throw")
|
|
3789
|
+
throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
3790
|
+
} else if (typeof i == "bigint") {
|
|
3791
|
+
if (t.unrepresentable === "throw")
|
|
3792
|
+
throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
3793
|
+
o.push(Number(i));
|
|
3794
|
+
} else
|
|
3795
|
+
o.push(i);
|
|
3796
|
+
if (o.length !== 0) if (o.length === 1) {
|
|
3797
|
+
const i = o[0];
|
|
3798
|
+
r.type = i === null ? "null" : typeof i, t.target === "draft-04" || t.target === "openapi-3.0" ? r.enum = [i] : r.const = i;
|
|
3799
|
+
} else
|
|
3800
|
+
o.every((i) => typeof i == "number") && (r.type = "number"), o.every((i) => typeof i == "string") && (r.type = "string"), o.every((i) => typeof i == "boolean") && (r.type = "boolean"), o.every((i) => i === null) && (r.type = "null"), r.enum = o;
|
|
3801
|
+
}, za = (e, t, r, n) => {
|
|
3802
|
+
if (t.unrepresentable === "throw")
|
|
3803
|
+
throw new Error("Custom types cannot be represented in JSON Schema");
|
|
3804
|
+
}, Sa = (e, t, r, n) => {
|
|
3805
|
+
if (t.unrepresentable === "throw")
|
|
3806
|
+
throw new Error("Transforms cannot be represented in JSON Schema");
|
|
3807
|
+
}, xa = (e, t, r, n) => {
|
|
3808
|
+
const s = r, o = e._zod.def, { minimum: i, maximum: a } = e._zod.bag;
|
|
3809
|
+
typeof i == "number" && (s.minItems = i), typeof a == "number" && (s.maxItems = a), s.type = "array", s.items = ne(o.element, t, { ...n, path: [...n.path, "items"] });
|
|
3810
|
+
}, Ea = (e, t, r, n) => {
|
|
3811
|
+
const s = r, o = e._zod.def;
|
|
3812
|
+
s.type = "object", s.properties = {};
|
|
3813
|
+
const i = o.shape;
|
|
3814
|
+
for (const f in i)
|
|
3815
|
+
s.properties[f] = ne(i[f], t, {
|
|
3816
|
+
...n,
|
|
3817
|
+
path: [...n.path, "properties", f]
|
|
3818
|
+
});
|
|
3819
|
+
const a = new Set(Object.keys(i)), c = new Set([...a].filter((f) => {
|
|
3820
|
+
const _ = o.shape[f]._zod;
|
|
3821
|
+
return t.io === "input" ? _.optin === void 0 : _.optout === void 0;
|
|
3822
|
+
}));
|
|
3823
|
+
c.size > 0 && (s.required = Array.from(c)), o.catchall?._zod.def.type === "never" ? s.additionalProperties = !1 : o.catchall ? o.catchall && (s.additionalProperties = ne(o.catchall, t, {
|
|
3824
|
+
...n,
|
|
3825
|
+
path: [...n.path, "additionalProperties"]
|
|
3826
|
+
})) : t.io === "output" && (s.additionalProperties = !1);
|
|
3827
|
+
}, $a = (e, t, r, n) => {
|
|
3828
|
+
const s = e._zod.def, o = s.inclusive === !1, i = s.options.map((a, c) => ne(a, t, {
|
|
3829
|
+
...n,
|
|
3830
|
+
path: [...n.path, o ? "oneOf" : "anyOf", c]
|
|
3831
|
+
}));
|
|
3832
|
+
o ? r.oneOf = i : r.anyOf = i;
|
|
3833
|
+
}, Na = (e, t, r, n) => {
|
|
3834
|
+
const s = e._zod.def, o = ne(s.left, t, {
|
|
3835
|
+
...n,
|
|
3836
|
+
path: [...n.path, "allOf", 0]
|
|
3837
|
+
}), i = ne(s.right, t, {
|
|
3838
|
+
...n,
|
|
3839
|
+
path: [...n.path, "allOf", 1]
|
|
3840
|
+
}), a = (f) => "allOf" in f && Object.keys(f).length === 1, c = [
|
|
3841
|
+
...a(o) ? o.allOf : [o],
|
|
3842
|
+
...a(i) ? i.allOf : [i]
|
|
3843
|
+
];
|
|
3844
|
+
r.allOf = c;
|
|
3845
|
+
}, Oa = (e, t, r, n) => {
|
|
3846
|
+
const s = e._zod.def, o = ne(s.innerType, t, n), i = t.seen.get(e);
|
|
3847
|
+
t.target === "openapi-3.0" ? (i.ref = s.innerType, r.nullable = !0) : r.anyOf = [o, { type: "null" }];
|
|
3848
|
+
}, ja = (e, t, r, n) => {
|
|
3849
|
+
const s = e._zod.def;
|
|
3850
|
+
ne(s.innerType, t, n);
|
|
3851
|
+
const o = t.seen.get(e);
|
|
3852
|
+
o.ref = s.innerType;
|
|
3853
|
+
}, Aa = (e, t, r, n) => {
|
|
3854
|
+
const s = e._zod.def;
|
|
3855
|
+
ne(s.innerType, t, n);
|
|
3856
|
+
const o = t.seen.get(e);
|
|
3857
|
+
o.ref = s.innerType, r.default = JSON.parse(JSON.stringify(s.defaultValue));
|
|
3858
|
+
}, Za = (e, t, r, n) => {
|
|
3859
|
+
const s = e._zod.def;
|
|
3860
|
+
ne(s.innerType, t, n);
|
|
3861
|
+
const o = t.seen.get(e);
|
|
3862
|
+
o.ref = s.innerType, t.io === "input" && (r._prefault = JSON.parse(JSON.stringify(s.defaultValue)));
|
|
3863
|
+
}, Ta = (e, t, r, n) => {
|
|
3864
|
+
const s = e._zod.def;
|
|
3865
|
+
ne(s.innerType, t, n);
|
|
3866
|
+
const o = t.seen.get(e);
|
|
3867
|
+
o.ref = s.innerType;
|
|
3868
|
+
let i;
|
|
3869
|
+
try {
|
|
3870
|
+
i = s.catchValue(void 0);
|
|
3871
|
+
} catch {
|
|
3872
|
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
3873
|
+
}
|
|
3874
|
+
r.default = i;
|
|
3875
|
+
}, Fa = (e, t, r, n) => {
|
|
3876
|
+
const s = e._zod.def, o = t.io === "input" ? s.in._zod.def.type === "transform" ? s.out : s.in : s.out;
|
|
3877
|
+
ne(o, t, n);
|
|
3878
|
+
const i = t.seen.get(e);
|
|
3879
|
+
i.ref = o;
|
|
3880
|
+
}, Pa = (e, t, r, n) => {
|
|
3881
|
+
const s = e._zod.def;
|
|
3882
|
+
ne(s.innerType, t, n);
|
|
3883
|
+
const o = t.seen.get(e);
|
|
3884
|
+
o.ref = s.innerType, r.readOnly = !0;
|
|
3885
|
+
}, Sn = (e, t, r, n) => {
|
|
3886
|
+
const s = e._zod.def;
|
|
3887
|
+
ne(s.innerType, t, n);
|
|
3888
|
+
const o = t.seen.get(e);
|
|
3889
|
+
o.ref = s.innerType;
|
|
3890
|
+
};
|
|
3891
|
+
function Tr(e, t) {
|
|
3892
|
+
try {
|
|
3893
|
+
var r = e();
|
|
3894
|
+
} catch (n) {
|
|
3895
|
+
return t(n);
|
|
3896
|
+
}
|
|
3897
|
+
return r && r.then ? r.then(void 0, t) : r;
|
|
3898
|
+
}
|
|
3899
|
+
function Ra(e, t) {
|
|
3900
|
+
for (var r = {}; e.length; ) {
|
|
3901
|
+
var n = e[0], s = n.code, o = n.message, i = n.path.join(".");
|
|
3902
|
+
if (!r[i]) if ("unionErrors" in n) {
|
|
3903
|
+
var a = n.unionErrors[0].errors[0];
|
|
3904
|
+
r[i] = { message: a.message, type: a.code };
|
|
3905
|
+
} else r[i] = { message: o, type: s };
|
|
3906
|
+
if ("unionErrors" in n && n.unionErrors.forEach(function(_) {
|
|
3907
|
+
return _.errors.forEach(function(g) {
|
|
3908
|
+
return e.push(g);
|
|
3909
|
+
});
|
|
3910
|
+
}), t) {
|
|
3911
|
+
var c = r[i].types, f = c && c[n.code];
|
|
3912
|
+
r[i] = Ct(i, t, r, s, f ? [].concat(f, n.message) : n.message);
|
|
3913
|
+
}
|
|
3914
|
+
e.shift();
|
|
3915
|
+
}
|
|
3916
|
+
return r;
|
|
3917
|
+
}
|
|
3918
|
+
function Ia(e, t) {
|
|
3919
|
+
for (var r = {}; e.length; ) {
|
|
3920
|
+
var n = e[0], s = n.code, o = n.message, i = n.path.join(".");
|
|
3921
|
+
if (!r[i]) if (n.code === "invalid_union" && n.errors.length > 0) {
|
|
3922
|
+
var a = n.errors[0][0];
|
|
3923
|
+
r[i] = { message: a.message, type: a.code };
|
|
3924
|
+
} else r[i] = { message: o, type: s };
|
|
3925
|
+
if (n.code === "invalid_union" && n.errors.forEach(function(_) {
|
|
3926
|
+
return _.forEach(function(g) {
|
|
3927
|
+
return e.push(g);
|
|
3928
|
+
});
|
|
3929
|
+
}), t) {
|
|
3930
|
+
var c = r[i].types, f = c && c[n.code];
|
|
3931
|
+
r[i] = Ct(i, t, r, s, f ? [].concat(f, n.message) : n.message);
|
|
3932
|
+
}
|
|
3933
|
+
e.shift();
|
|
3934
|
+
}
|
|
3935
|
+
return r;
|
|
3936
|
+
}
|
|
3937
|
+
function Ca(e, t, r) {
|
|
3938
|
+
if (r === void 0 && (r = {}), (function(n) {
|
|
3939
|
+
return "_def" in n && typeof n._def == "object" && "typeName" in n._def;
|
|
3940
|
+
})(e)) return function(n, s, o) {
|
|
3941
|
+
try {
|
|
3942
|
+
return Promise.resolve(Tr(function() {
|
|
3943
|
+
return Promise.resolve(e[r.mode === "sync" ? "parse" : "parseAsync"](n, t)).then(function(i) {
|
|
3944
|
+
return o.shouldUseNativeValidation && Ot({}, o), { errors: {}, values: r.raw ? Object.assign({}, n) : i };
|
|
3945
|
+
});
|
|
3946
|
+
}, function(i) {
|
|
3947
|
+
if ((function(a) {
|
|
3948
|
+
return Array.isArray(a?.issues);
|
|
3949
|
+
})(i)) return { values: {}, errors: pr(Ra(i.errors, !o.shouldUseNativeValidation && o.criteriaMode === "all"), o) };
|
|
3950
|
+
throw i;
|
|
3951
|
+
}));
|
|
3952
|
+
} catch (i) {
|
|
3953
|
+
return Promise.reject(i);
|
|
3954
|
+
}
|
|
3955
|
+
};
|
|
3956
|
+
if ((function(n) {
|
|
3957
|
+
return "_zod" in n && typeof n._zod == "object";
|
|
3958
|
+
})(e)) return function(n, s, o) {
|
|
3959
|
+
try {
|
|
3960
|
+
return Promise.resolve(Tr(function() {
|
|
3961
|
+
return Promise.resolve((r.mode === "sync" ? Es : $s)(e, n, t)).then(function(i) {
|
|
3962
|
+
return o.shouldUseNativeValidation && Ot({}, o), { errors: {}, values: r.raw ? Object.assign({}, n) : i };
|
|
3963
|
+
});
|
|
3964
|
+
}, function(i) {
|
|
3965
|
+
if ((function(a) {
|
|
3966
|
+
return a instanceof Bt;
|
|
3967
|
+
})(i)) return { values: {}, errors: pr(Ia(i.issues, !o.shouldUseNativeValidation && o.criteriaMode === "all"), o) };
|
|
3968
|
+
throw i;
|
|
3969
|
+
}));
|
|
3970
|
+
} catch (i) {
|
|
3971
|
+
return Promise.reject(i);
|
|
3972
|
+
}
|
|
3973
|
+
};
|
|
3974
|
+
throw new Error("Invalid input: not a Zod schema");
|
|
3975
|
+
}
|
|
3976
|
+
const Va = /* @__PURE__ */ h("ZodISODateTime", (e, t) => {
|
|
3977
|
+
Ro.init(e, t), Y.init(e, t);
|
|
3978
|
+
});
|
|
3979
|
+
function Da(e) {
|
|
3980
|
+
return /* @__PURE__ */ Li(Va, e);
|
|
3981
|
+
}
|
|
3982
|
+
const Ua = /* @__PURE__ */ h("ZodISODate", (e, t) => {
|
|
3983
|
+
Io.init(e, t), Y.init(e, t);
|
|
3984
|
+
});
|
|
3985
|
+
function La(e) {
|
|
3986
|
+
return /* @__PURE__ */ Mi(Ua, e);
|
|
3987
|
+
}
|
|
3988
|
+
const Ma = /* @__PURE__ */ h("ZodISOTime", (e, t) => {
|
|
3989
|
+
Co.init(e, t), Y.init(e, t);
|
|
3990
|
+
});
|
|
3991
|
+
function Ja(e) {
|
|
3992
|
+
return /* @__PURE__ */ Ji(Ma, e);
|
|
3993
|
+
}
|
|
3994
|
+
const Ba = /* @__PURE__ */ h("ZodISODuration", (e, t) => {
|
|
3995
|
+
Vo.init(e, t), Y.init(e, t);
|
|
3996
|
+
});
|
|
3997
|
+
function Wa(e) {
|
|
3998
|
+
return /* @__PURE__ */ Bi(Ba, e);
|
|
3999
|
+
}
|
|
4000
|
+
const qa = (e, t) => {
|
|
4001
|
+
Bt.init(e, t), e.name = "ZodError", Object.defineProperties(e, {
|
|
4002
|
+
format: {
|
|
4003
|
+
value: (r) => xs(e, r)
|
|
4004
|
+
// enumerable: false,
|
|
4005
|
+
},
|
|
4006
|
+
flatten: {
|
|
4007
|
+
value: (r) => Ss(e, r)
|
|
4008
|
+
// enumerable: false,
|
|
4009
|
+
},
|
|
4010
|
+
addIssue: {
|
|
4011
|
+
value: (r) => {
|
|
4012
|
+
e.issues.push(r), e.message = JSON.stringify(e.issues, jt, 2);
|
|
4013
|
+
}
|
|
4014
|
+
// enumerable: false,
|
|
4015
|
+
},
|
|
4016
|
+
addIssues: {
|
|
4017
|
+
value: (r) => {
|
|
4018
|
+
e.issues.push(...r), e.message = JSON.stringify(e.issues, jt, 2);
|
|
4019
|
+
}
|
|
4020
|
+
// enumerable: false,
|
|
4021
|
+
},
|
|
4022
|
+
isEmpty: {
|
|
4023
|
+
get() {
|
|
4024
|
+
return e.issues.length === 0;
|
|
4025
|
+
}
|
|
4026
|
+
// enumerable: false,
|
|
4027
|
+
}
|
|
4028
|
+
});
|
|
4029
|
+
}, ge = h("ZodError", qa, {
|
|
4030
|
+
Parent: Error
|
|
4031
|
+
}), Ya = /* @__PURE__ */ mt(ge), Ga = /* @__PURE__ */ pt(ge), Ha = /* @__PURE__ */ vt(ge), Ka = /* @__PURE__ */ gt(ge), Xa = /* @__PURE__ */ js(ge), Qa = /* @__PURE__ */ As(ge), eu = /* @__PURE__ */ Zs(ge), tu = /* @__PURE__ */ Ts(ge), ru = /* @__PURE__ */ Fs(ge), nu = /* @__PURE__ */ Ps(ge), su = /* @__PURE__ */ Rs(ge), ou = /* @__PURE__ */ Is(ge), q = /* @__PURE__ */ h("ZodType", (e, t) => (W.init(e, t), Object.assign(e["~standard"], {
|
|
4032
|
+
jsonSchema: {
|
|
4033
|
+
input: ft(e, "input"),
|
|
4034
|
+
output: ft(e, "output")
|
|
4035
|
+
}
|
|
4036
|
+
}), e.toJSONSchema = ha(e, {}), e.def = t, e.type = t.type, Object.defineProperty(e, "_def", { value: t }), e.check = (...r) => e.clone(Ee(t, {
|
|
4037
|
+
checks: [
|
|
4038
|
+
...t.checks ?? [],
|
|
4039
|
+
...r.map((n) => typeof n == "function" ? { _zod: { check: n, def: { check: "custom" }, onattach: [] } } : n)
|
|
4040
|
+
]
|
|
4041
|
+
}), {
|
|
4042
|
+
parent: !0
|
|
4043
|
+
}), e.with = e.check, e.clone = (r, n) => $e(e, r, n), e.brand = () => e, e.register = ((r, n) => (r.add(e, n), e)), e.parse = (r, n) => Ya(e, r, n, { callee: e.parse }), e.safeParse = (r, n) => Ha(e, r, n), e.parseAsync = async (r, n) => Ga(e, r, n, { callee: e.parseAsync }), e.safeParseAsync = async (r, n) => Ka(e, r, n), e.spa = e.safeParseAsync, e.encode = (r, n) => Xa(e, r, n), e.decode = (r, n) => Qa(e, r, n), e.encodeAsync = async (r, n) => eu(e, r, n), e.decodeAsync = async (r, n) => tu(e, r, n), e.safeEncode = (r, n) => ru(e, r, n), e.safeDecode = (r, n) => nu(e, r, n), e.safeEncodeAsync = async (r, n) => su(e, r, n), e.safeDecodeAsync = async (r, n) => ou(e, r, n), e.refine = (r, n) => e.check(nc(r, n)), e.superRefine = (r) => e.check(sc(r)), e.overwrite = (r) => e.check(/* @__PURE__ */ Me(r)), e.optional = () => Ir(e), e.exactOptional = () => Ju(e), e.nullable = () => Cr(e), e.nullish = () => Ir(Cr(e)), e.nonoptional = (r) => Hu(e, r), e.array = () => Tu(e), e.or = (r) => $n([e, r]), e.and = (r) => Cu(e, r), e.transform = (r) => Vr(e, Lu(r)), e.default = (r) => qu(e, r), e.prefault = (r) => Gu(e, r), e.catch = (r) => Xu(e, r), e.pipe = (r) => Vr(e, r), e.readonly = () => tc(e), e.describe = (r) => {
|
|
4044
|
+
const n = e.clone();
|
|
4045
|
+
return Ye.add(n, { description: r }), n;
|
|
4046
|
+
}, Object.defineProperty(e, "description", {
|
|
4047
|
+
get() {
|
|
4048
|
+
return Ye.get(e)?.description;
|
|
4049
|
+
},
|
|
4050
|
+
configurable: !0
|
|
4051
|
+
}), e.meta = (...r) => {
|
|
4052
|
+
if (r.length === 0)
|
|
4053
|
+
return Ye.get(e);
|
|
4054
|
+
const n = e.clone();
|
|
4055
|
+
return Ye.add(n, r[0]), n;
|
|
4056
|
+
}, e.isOptional = () => e.safeParse(void 0).success, e.isNullable = () => e.safeParse(null).success, e.apply = (r) => r(e), e)), xn = /* @__PURE__ */ h("_ZodString", (e, t) => {
|
|
4057
|
+
Wt.init(e, t), q.init(e, t), e._zod.processJSONSchema = (n, s, o) => pa(e, n, s);
|
|
4058
|
+
const r = e._zod.bag;
|
|
4059
|
+
e.format = r.format ?? null, e.minLength = r.minimum ?? null, e.maxLength = r.maximum ?? null, e.regex = (...n) => e.check(/* @__PURE__ */ Xi(...n)), e.includes = (...n) => e.check(/* @__PURE__ */ ta(...n)), e.startsWith = (...n) => e.check(/* @__PURE__ */ ra(...n)), e.endsWith = (...n) => e.check(/* @__PURE__ */ na(...n)), e.min = (...n) => e.check(/* @__PURE__ */ lt(...n)), e.max = (...n) => e.check(/* @__PURE__ */ yn(...n)), e.length = (...n) => e.check(/* @__PURE__ */ bn(...n)), e.nonempty = (...n) => e.check(/* @__PURE__ */ lt(1, ...n)), e.lowercase = (n) => e.check(/* @__PURE__ */ Qi(n)), e.uppercase = (n) => e.check(/* @__PURE__ */ ea(n)), e.trim = () => e.check(/* @__PURE__ */ oa()), e.normalize = (...n) => e.check(/* @__PURE__ */ sa(...n)), e.toLowerCase = () => e.check(/* @__PURE__ */ ia()), e.toUpperCase = () => e.check(/* @__PURE__ */ aa()), e.slugify = () => e.check(/* @__PURE__ */ ua());
|
|
4060
|
+
}), iu = /* @__PURE__ */ h("ZodString", (e, t) => {
|
|
4061
|
+
Wt.init(e, t), xn.init(e, t), e.email = (r) => e.check(/* @__PURE__ */ wi(au, r)), e.url = (r) => e.check(/* @__PURE__ */ Ei(uu, r)), e.jwt = (r) => e.check(/* @__PURE__ */ Ui(zu, r)), e.emoji = (r) => e.check(/* @__PURE__ */ $i(cu, r)), e.guid = (r) => e.check(/* @__PURE__ */ Or(Fr, r)), e.uuid = (r) => e.check(/* @__PURE__ */ ki(st, r)), e.uuidv4 = (r) => e.check(/* @__PURE__ */ zi(st, r)), e.uuidv6 = (r) => e.check(/* @__PURE__ */ Si(st, r)), e.uuidv7 = (r) => e.check(/* @__PURE__ */ xi(st, r)), e.nanoid = (r) => e.check(/* @__PURE__ */ Ni(lu, r)), e.guid = (r) => e.check(/* @__PURE__ */ Or(Fr, r)), e.cuid = (r) => e.check(/* @__PURE__ */ Oi(fu, r)), e.cuid2 = (r) => e.check(/* @__PURE__ */ ji(du, r)), e.ulid = (r) => e.check(/* @__PURE__ */ Ai(hu, r)), e.base64 = (r) => e.check(/* @__PURE__ */ Ci(bu, r)), e.base64url = (r) => e.check(/* @__PURE__ */ Vi(wu, r)), e.xid = (r) => e.check(/* @__PURE__ */ Zi(mu, r)), e.ksuid = (r) => e.check(/* @__PURE__ */ Ti(pu, r)), e.ipv4 = (r) => e.check(/* @__PURE__ */ Fi(vu, r)), e.ipv6 = (r) => e.check(/* @__PURE__ */ Pi(gu, r)), e.cidrv4 = (r) => e.check(/* @__PURE__ */ Ri(_u, r)), e.cidrv6 = (r) => e.check(/* @__PURE__ */ Ii(yu, r)), e.e164 = (r) => e.check(/* @__PURE__ */ Di(ku, r)), e.datetime = (r) => e.check(Da(r)), e.date = (r) => e.check(La(r)), e.time = (r) => e.check(Ja(r)), e.duration = (r) => e.check(Wa(r));
|
|
4062
|
+
});
|
|
4063
|
+
function nt(e) {
|
|
4064
|
+
return /* @__PURE__ */ bi(iu, e);
|
|
4065
|
+
}
|
|
4066
|
+
const Y = /* @__PURE__ */ h("ZodStringFormat", (e, t) => {
|
|
4067
|
+
B.init(e, t), xn.init(e, t);
|
|
4068
|
+
}), au = /* @__PURE__ */ h("ZodEmail", (e, t) => {
|
|
4069
|
+
$o.init(e, t), Y.init(e, t);
|
|
4070
|
+
}), Fr = /* @__PURE__ */ h("ZodGUID", (e, t) => {
|
|
4071
|
+
xo.init(e, t), Y.init(e, t);
|
|
4072
|
+
}), st = /* @__PURE__ */ h("ZodUUID", (e, t) => {
|
|
4073
|
+
Eo.init(e, t), Y.init(e, t);
|
|
4074
|
+
}), uu = /* @__PURE__ */ h("ZodURL", (e, t) => {
|
|
4075
|
+
No.init(e, t), Y.init(e, t);
|
|
4076
|
+
}), cu = /* @__PURE__ */ h("ZodEmoji", (e, t) => {
|
|
4077
|
+
Oo.init(e, t), Y.init(e, t);
|
|
4078
|
+
}), lu = /* @__PURE__ */ h("ZodNanoID", (e, t) => {
|
|
4079
|
+
jo.init(e, t), Y.init(e, t);
|
|
4080
|
+
}), fu = /* @__PURE__ */ h("ZodCUID", (e, t) => {
|
|
4081
|
+
Ao.init(e, t), Y.init(e, t);
|
|
4082
|
+
}), du = /* @__PURE__ */ h("ZodCUID2", (e, t) => {
|
|
4083
|
+
Zo.init(e, t), Y.init(e, t);
|
|
4084
|
+
}), hu = /* @__PURE__ */ h("ZodULID", (e, t) => {
|
|
4085
|
+
To.init(e, t), Y.init(e, t);
|
|
4086
|
+
}), mu = /* @__PURE__ */ h("ZodXID", (e, t) => {
|
|
4087
|
+
Fo.init(e, t), Y.init(e, t);
|
|
4088
|
+
}), pu = /* @__PURE__ */ h("ZodKSUID", (e, t) => {
|
|
4089
|
+
Po.init(e, t), Y.init(e, t);
|
|
4090
|
+
}), vu = /* @__PURE__ */ h("ZodIPv4", (e, t) => {
|
|
4091
|
+
Do.init(e, t), Y.init(e, t);
|
|
4092
|
+
}), gu = /* @__PURE__ */ h("ZodIPv6", (e, t) => {
|
|
4093
|
+
Uo.init(e, t), Y.init(e, t);
|
|
4094
|
+
}), _u = /* @__PURE__ */ h("ZodCIDRv4", (e, t) => {
|
|
4095
|
+
Lo.init(e, t), Y.init(e, t);
|
|
4096
|
+
}), yu = /* @__PURE__ */ h("ZodCIDRv6", (e, t) => {
|
|
4097
|
+
Mo.init(e, t), Y.init(e, t);
|
|
4098
|
+
}), bu = /* @__PURE__ */ h("ZodBase64", (e, t) => {
|
|
4099
|
+
Jo.init(e, t), Y.init(e, t);
|
|
4100
|
+
}), wu = /* @__PURE__ */ h("ZodBase64URL", (e, t) => {
|
|
4101
|
+
Wo.init(e, t), Y.init(e, t);
|
|
4102
|
+
}), ku = /* @__PURE__ */ h("ZodE164", (e, t) => {
|
|
4103
|
+
qo.init(e, t), Y.init(e, t);
|
|
4104
|
+
}), zu = /* @__PURE__ */ h("ZodJWT", (e, t) => {
|
|
4105
|
+
Go.init(e, t), Y.init(e, t);
|
|
4106
|
+
}), En = /* @__PURE__ */ h("ZodNumber", (e, t) => {
|
|
4107
|
+
pn.init(e, t), q.init(e, t), e._zod.processJSONSchema = (n, s, o) => va(e, n, s), e.gt = (n, s) => e.check(/* @__PURE__ */ Ar(n, s)), e.gte = (n, s) => e.check(/* @__PURE__ */ St(n, s)), e.min = (n, s) => e.check(/* @__PURE__ */ St(n, s)), e.lt = (n, s) => e.check(/* @__PURE__ */ jr(n, s)), e.lte = (n, s) => e.check(/* @__PURE__ */ zt(n, s)), e.max = (n, s) => e.check(/* @__PURE__ */ zt(n, s)), e.int = (n) => e.check(Pr(n)), e.safe = (n) => e.check(Pr(n)), e.positive = (n) => e.check(/* @__PURE__ */ Ar(0, n)), e.nonnegative = (n) => e.check(/* @__PURE__ */ St(0, n)), e.negative = (n) => e.check(/* @__PURE__ */ jr(0, n)), e.nonpositive = (n) => e.check(/* @__PURE__ */ zt(0, n)), e.multipleOf = (n, s) => e.check(/* @__PURE__ */ Zr(n, s)), e.step = (n, s) => e.check(/* @__PURE__ */ Zr(n, s)), e.finite = () => e;
|
|
4108
|
+
const r = e._zod.bag;
|
|
4109
|
+
e.minValue = Math.max(r.minimum ?? Number.NEGATIVE_INFINITY, r.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null, e.maxValue = Math.min(r.maximum ?? Number.POSITIVE_INFINITY, r.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null, e.isInt = (r.format ?? "").includes("int") || Number.isSafeInteger(r.multipleOf ?? 0.5), e.isFinite = !0, e.format = r.format ?? null;
|
|
4110
|
+
}), Su = /* @__PURE__ */ h("ZodNumberFormat", (e, t) => {
|
|
4111
|
+
Ho.init(e, t), En.init(e, t);
|
|
4112
|
+
});
|
|
4113
|
+
function Pr(e) {
|
|
4114
|
+
return /* @__PURE__ */ qi(Su, e);
|
|
4115
|
+
}
|
|
4116
|
+
const xu = /* @__PURE__ */ h("ZodBoolean", (e, t) => {
|
|
4117
|
+
Ko.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => ga(e, r, n);
|
|
4118
|
+
});
|
|
4119
|
+
function Eu(e) {
|
|
4120
|
+
return /* @__PURE__ */ Yi(xu, e);
|
|
4121
|
+
}
|
|
4122
|
+
const $u = /* @__PURE__ */ h("ZodAny", (e, t) => {
|
|
4123
|
+
Xo.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => ya();
|
|
4124
|
+
});
|
|
4125
|
+
function Nu() {
|
|
4126
|
+
return /* @__PURE__ */ Gi($u);
|
|
4127
|
+
}
|
|
4128
|
+
const Ou = /* @__PURE__ */ h("ZodUnknown", (e, t) => {
|
|
4129
|
+
Qo.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => ba();
|
|
4130
|
+
});
|
|
4131
|
+
function Rr() {
|
|
4132
|
+
return /* @__PURE__ */ Hi(Ou);
|
|
4133
|
+
}
|
|
4134
|
+
const ju = /* @__PURE__ */ h("ZodNever", (e, t) => {
|
|
4135
|
+
ei.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => _a(e, r, n);
|
|
4136
|
+
});
|
|
4137
|
+
function Au(e) {
|
|
4138
|
+
return /* @__PURE__ */ Ki(ju, e);
|
|
4139
|
+
}
|
|
4140
|
+
const Zu = /* @__PURE__ */ h("ZodArray", (e, t) => {
|
|
4141
|
+
ti.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => xa(e, r, n, s), e.element = t.element, e.min = (r, n) => e.check(/* @__PURE__ */ lt(r, n)), e.nonempty = (r) => e.check(/* @__PURE__ */ lt(1, r)), e.max = (r, n) => e.check(/* @__PURE__ */ yn(r, n)), e.length = (r, n) => e.check(/* @__PURE__ */ bn(r, n)), e.unwrap = () => e.element;
|
|
4142
|
+
});
|
|
4143
|
+
function Tu(e, t) {
|
|
4144
|
+
return /* @__PURE__ */ ca(Zu, e, t);
|
|
4145
|
+
}
|
|
4146
|
+
const Fu = /* @__PURE__ */ h("ZodObject", (e, t) => {
|
|
4147
|
+
ni.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => Ea(e, r, n, s), U(e, "shape", () => t.shape), e.keyof = () => Nn(Object.keys(e._zod.def.shape)), e.catchall = (r) => e.clone({ ...e._zod.def, catchall: r }), e.passthrough = () => e.clone({ ...e._zod.def, catchall: Rr() }), e.loose = () => e.clone({ ...e._zod.def, catchall: Rr() }), e.strict = () => e.clone({ ...e._zod.def, catchall: Au() }), e.strip = () => e.clone({ ...e._zod.def, catchall: void 0 }), e.extend = (r) => ys(e, r), e.safeExtend = (r) => bs(e, r), e.merge = (r) => ws(e, r), e.pick = (r) => gs(e, r), e.omit = (r) => _s(e, r), e.partial = (...r) => ks(On, e, r[0]), e.required = (...r) => zs(jn, e, r[0]);
|
|
4148
|
+
});
|
|
4149
|
+
function Pu(e, t) {
|
|
4150
|
+
const r = {
|
|
4151
|
+
type: "object",
|
|
4152
|
+
shape: e ?? {},
|
|
4153
|
+
...E(t)
|
|
4154
|
+
};
|
|
4155
|
+
return new Fu(r);
|
|
4156
|
+
}
|
|
4157
|
+
const Ru = /* @__PURE__ */ h("ZodUnion", (e, t) => {
|
|
4158
|
+
si.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => $a(e, r, n, s), e.options = t.options;
|
|
4159
|
+
});
|
|
4160
|
+
function $n(e, t) {
|
|
4161
|
+
return new Ru({
|
|
4162
|
+
type: "union",
|
|
4163
|
+
options: e,
|
|
4164
|
+
...E(t)
|
|
4165
|
+
});
|
|
4166
|
+
}
|
|
4167
|
+
const Iu = /* @__PURE__ */ h("ZodIntersection", (e, t) => {
|
|
4168
|
+
oi.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => Na(e, r, n, s);
|
|
4169
|
+
});
|
|
4170
|
+
function Cu(e, t) {
|
|
4171
|
+
return new Iu({
|
|
4172
|
+
type: "intersection",
|
|
4173
|
+
left: e,
|
|
4174
|
+
right: t
|
|
4175
|
+
});
|
|
4176
|
+
}
|
|
4177
|
+
const Zt = /* @__PURE__ */ h("ZodEnum", (e, t) => {
|
|
4178
|
+
ii.init(e, t), q.init(e, t), e._zod.processJSONSchema = (n, s, o) => wa(e, n, s), e.enum = t.entries, e.options = Object.values(t.entries);
|
|
4179
|
+
const r = new Set(Object.keys(t.entries));
|
|
4180
|
+
e.extract = (n, s) => {
|
|
4181
|
+
const o = {};
|
|
4182
|
+
for (const i of n)
|
|
4183
|
+
if (r.has(i))
|
|
4184
|
+
o[i] = t.entries[i];
|
|
4185
|
+
else
|
|
4186
|
+
throw new Error(`Key ${i} not found in enum`);
|
|
4187
|
+
return new Zt({
|
|
4188
|
+
...t,
|
|
4189
|
+
checks: [],
|
|
4190
|
+
...E(s),
|
|
4191
|
+
entries: o
|
|
4192
|
+
});
|
|
4193
|
+
}, e.exclude = (n, s) => {
|
|
4194
|
+
const o = { ...t.entries };
|
|
4195
|
+
for (const i of n)
|
|
4196
|
+
if (r.has(i))
|
|
4197
|
+
delete o[i];
|
|
4198
|
+
else
|
|
4199
|
+
throw new Error(`Key ${i} not found in enum`);
|
|
4200
|
+
return new Zt({
|
|
4201
|
+
...t,
|
|
4202
|
+
checks: [],
|
|
4203
|
+
...E(s),
|
|
4204
|
+
entries: o
|
|
4205
|
+
});
|
|
4206
|
+
};
|
|
4207
|
+
});
|
|
4208
|
+
function Nn(e, t) {
|
|
4209
|
+
const r = Array.isArray(e) ? Object.fromEntries(e.map((n) => [n, n])) : e;
|
|
4210
|
+
return new Zt({
|
|
4211
|
+
type: "enum",
|
|
4212
|
+
entries: r,
|
|
4213
|
+
...E(t)
|
|
4214
|
+
});
|
|
4215
|
+
}
|
|
4216
|
+
const Vu = /* @__PURE__ */ h("ZodLiteral", (e, t) => {
|
|
4217
|
+
ai.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => ka(e, r, n), e.values = new Set(t.values), Object.defineProperty(e, "value", {
|
|
4218
|
+
get() {
|
|
4219
|
+
if (t.values.length > 1)
|
|
4220
|
+
throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
4221
|
+
return t.values[0];
|
|
4222
|
+
}
|
|
4223
|
+
});
|
|
4224
|
+
});
|
|
4225
|
+
function Du(e, t) {
|
|
4226
|
+
return new Vu({
|
|
4227
|
+
type: "literal",
|
|
4228
|
+
values: Array.isArray(e) ? e : [e],
|
|
4229
|
+
...E(t)
|
|
4230
|
+
});
|
|
4231
|
+
}
|
|
4232
|
+
const Uu = /* @__PURE__ */ h("ZodTransform", (e, t) => {
|
|
4233
|
+
ui.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => Sa(e, r), e._zod.parse = (r, n) => {
|
|
4234
|
+
if (n.direction === "backward")
|
|
4235
|
+
throw new en(e.constructor.name);
|
|
4236
|
+
r.addIssue = (o) => {
|
|
4237
|
+
if (typeof o == "string")
|
|
4238
|
+
r.issues.push(Xe(o, r.value, t));
|
|
4239
|
+
else {
|
|
4240
|
+
const i = o;
|
|
4241
|
+
i.fatal && (i.continue = !1), i.code ?? (i.code = "custom"), i.input ?? (i.input = r.value), i.inst ?? (i.inst = e), r.issues.push(Xe(i));
|
|
4242
|
+
}
|
|
4243
|
+
};
|
|
4244
|
+
const s = t.transform(r.value, r);
|
|
4245
|
+
return s instanceof Promise ? s.then((o) => (r.value = o, r)) : (r.value = s, r);
|
|
4246
|
+
};
|
|
4247
|
+
});
|
|
4248
|
+
function Lu(e) {
|
|
4249
|
+
return new Uu({
|
|
4250
|
+
type: "transform",
|
|
4251
|
+
transform: e
|
|
4252
|
+
});
|
|
4253
|
+
}
|
|
4254
|
+
const On = /* @__PURE__ */ h("ZodOptional", (e, t) => {
|
|
4255
|
+
_n.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => Sn(e, r, n, s), e.unwrap = () => e._zod.def.innerType;
|
|
4256
|
+
});
|
|
4257
|
+
function Ir(e) {
|
|
4258
|
+
return new On({
|
|
4259
|
+
type: "optional",
|
|
4260
|
+
innerType: e
|
|
4261
|
+
});
|
|
4262
|
+
}
|
|
4263
|
+
const Mu = /* @__PURE__ */ h("ZodExactOptional", (e, t) => {
|
|
4264
|
+
ci.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => Sn(e, r, n, s), e.unwrap = () => e._zod.def.innerType;
|
|
4265
|
+
});
|
|
4266
|
+
function Ju(e) {
|
|
4267
|
+
return new Mu({
|
|
4268
|
+
type: "optional",
|
|
4269
|
+
innerType: e
|
|
4270
|
+
});
|
|
4271
|
+
}
|
|
4272
|
+
const Bu = /* @__PURE__ */ h("ZodNullable", (e, t) => {
|
|
4273
|
+
li.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => Oa(e, r, n, s), e.unwrap = () => e._zod.def.innerType;
|
|
4274
|
+
});
|
|
4275
|
+
function Cr(e) {
|
|
4276
|
+
return new Bu({
|
|
4277
|
+
type: "nullable",
|
|
4278
|
+
innerType: e
|
|
4279
|
+
});
|
|
4280
|
+
}
|
|
4281
|
+
const Wu = /* @__PURE__ */ h("ZodDefault", (e, t) => {
|
|
4282
|
+
fi.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => Aa(e, r, n, s), e.unwrap = () => e._zod.def.innerType, e.removeDefault = e.unwrap;
|
|
4283
|
+
});
|
|
4284
|
+
function qu(e, t) {
|
|
4285
|
+
return new Wu({
|
|
4286
|
+
type: "default",
|
|
4287
|
+
innerType: e,
|
|
4288
|
+
get defaultValue() {
|
|
4289
|
+
return typeof t == "function" ? t() : sn(t);
|
|
4290
|
+
}
|
|
4291
|
+
});
|
|
4292
|
+
}
|
|
4293
|
+
const Yu = /* @__PURE__ */ h("ZodPrefault", (e, t) => {
|
|
4294
|
+
di.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => Za(e, r, n, s), e.unwrap = () => e._zod.def.innerType;
|
|
4295
|
+
});
|
|
4296
|
+
function Gu(e, t) {
|
|
4297
|
+
return new Yu({
|
|
4298
|
+
type: "prefault",
|
|
4299
|
+
innerType: e,
|
|
4300
|
+
get defaultValue() {
|
|
4301
|
+
return typeof t == "function" ? t() : sn(t);
|
|
4302
|
+
}
|
|
4303
|
+
});
|
|
4304
|
+
}
|
|
4305
|
+
const jn = /* @__PURE__ */ h("ZodNonOptional", (e, t) => {
|
|
4306
|
+
hi.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => ja(e, r, n, s), e.unwrap = () => e._zod.def.innerType;
|
|
4307
|
+
});
|
|
4308
|
+
function Hu(e, t) {
|
|
4309
|
+
return new jn({
|
|
4310
|
+
type: "nonoptional",
|
|
4311
|
+
innerType: e,
|
|
4312
|
+
...E(t)
|
|
4313
|
+
});
|
|
4314
|
+
}
|
|
4315
|
+
const Ku = /* @__PURE__ */ h("ZodCatch", (e, t) => {
|
|
4316
|
+
mi.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => Ta(e, r, n, s), e.unwrap = () => e._zod.def.innerType, e.removeCatch = e.unwrap;
|
|
4317
|
+
});
|
|
4318
|
+
function Xu(e, t) {
|
|
4319
|
+
return new Ku({
|
|
4320
|
+
type: "catch",
|
|
4321
|
+
innerType: e,
|
|
4322
|
+
catchValue: typeof t == "function" ? t : () => t
|
|
4323
|
+
});
|
|
4324
|
+
}
|
|
4325
|
+
const Qu = /* @__PURE__ */ h("ZodPipe", (e, t) => {
|
|
4326
|
+
pi.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => Fa(e, r, n, s), e.in = t.in, e.out = t.out;
|
|
4327
|
+
});
|
|
4328
|
+
function Vr(e, t) {
|
|
4329
|
+
return new Qu({
|
|
4330
|
+
type: "pipe",
|
|
4331
|
+
in: e,
|
|
4332
|
+
out: t
|
|
4333
|
+
// ...util.normalizeParams(params),
|
|
4334
|
+
});
|
|
4335
|
+
}
|
|
4336
|
+
const ec = /* @__PURE__ */ h("ZodReadonly", (e, t) => {
|
|
4337
|
+
vi.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => Pa(e, r, n, s), e.unwrap = () => e._zod.def.innerType;
|
|
4338
|
+
});
|
|
4339
|
+
function tc(e) {
|
|
4340
|
+
return new ec({
|
|
4341
|
+
type: "readonly",
|
|
4342
|
+
innerType: e
|
|
4343
|
+
});
|
|
4344
|
+
}
|
|
4345
|
+
const rc = /* @__PURE__ */ h("ZodCustom", (e, t) => {
|
|
4346
|
+
gi.init(e, t), q.init(e, t), e._zod.processJSONSchema = (r, n, s) => za(e, r);
|
|
4347
|
+
});
|
|
4348
|
+
function nc(e, t = {}) {
|
|
4349
|
+
return /* @__PURE__ */ la(rc, e, t);
|
|
4350
|
+
}
|
|
4351
|
+
function sc(e) {
|
|
4352
|
+
return /* @__PURE__ */ fa(e);
|
|
4353
|
+
}
|
|
4354
|
+
function oc(e) {
|
|
4355
|
+
return /* @__PURE__ */ Wi(En, e);
|
|
4356
|
+
}
|
|
4357
|
+
function ic(e) {
|
|
4358
|
+
const { type: t, required: r, config: n } = e;
|
|
4359
|
+
let s;
|
|
4360
|
+
switch (t) {
|
|
4361
|
+
case "email":
|
|
4362
|
+
s = nt().email("Please enter a valid email address");
|
|
4363
|
+
break;
|
|
4364
|
+
case "number":
|
|
4365
|
+
s = oc(), n?.min !== void 0 && (s = s.min(n.min, `Must be at least ${n.min}`)), n?.max !== void 0 && (s = s.max(n.max, `Must be at most ${n.max}`));
|
|
4366
|
+
break;
|
|
4367
|
+
case "checkbox":
|
|
4368
|
+
s = Eu();
|
|
4369
|
+
break;
|
|
4370
|
+
case "date":
|
|
4371
|
+
s = nt().refine((o) => !o || !Number.isNaN(Date.parse(o)), "Please enter a valid date");
|
|
4372
|
+
break;
|
|
4373
|
+
case "file":
|
|
4374
|
+
s = Nu();
|
|
4375
|
+
break;
|
|
4376
|
+
case "select":
|
|
4377
|
+
case "radio":
|
|
4378
|
+
if (n?.options && n.options.length > 0) {
|
|
4379
|
+
const o = n.options.map((i) => i.value);
|
|
4380
|
+
s = Nn(o);
|
|
4381
|
+
} else
|
|
4382
|
+
s = nt();
|
|
4383
|
+
break;
|
|
4384
|
+
default:
|
|
4385
|
+
if (s = nt(), n?.minLength !== void 0 && (s = s.min(
|
|
4386
|
+
n.minLength,
|
|
4387
|
+
`Must be at least ${n.minLength} characters`
|
|
4388
|
+
)), n?.maxLength !== void 0 && (s = s.max(
|
|
4389
|
+
n.maxLength,
|
|
4390
|
+
`Must be at most ${n.maxLength} characters`
|
|
4391
|
+
)), n?.pattern)
|
|
4392
|
+
try {
|
|
4393
|
+
const o = new RegExp(n.pattern);
|
|
4394
|
+
s = s.regex(o, "Invalid format");
|
|
4395
|
+
} catch {
|
|
4396
|
+
}
|
|
4397
|
+
break;
|
|
4398
|
+
}
|
|
4399
|
+
return r || (s = s.optional(), (t === "text" || t === "textarea" || t === "email") && (s = $n([s, Du("")]))), s;
|
|
4400
|
+
}
|
|
4401
|
+
function An(e) {
|
|
4402
|
+
const t = {};
|
|
4403
|
+
for (const r of e)
|
|
4404
|
+
t[r.name] = ic(r);
|
|
4405
|
+
return Pu(t);
|
|
4406
|
+
}
|
|
4407
|
+
function kc(e, t) {
|
|
4408
|
+
const n = An(e).safeParse(t);
|
|
4409
|
+
if (n.success)
|
|
4410
|
+
return { success: !0, errors: {} };
|
|
4411
|
+
const s = {};
|
|
4412
|
+
for (const o of n.error.issues) {
|
|
4413
|
+
const i = o.path.join(".");
|
|
4414
|
+
s[i] || (s[i] = o.message);
|
|
4415
|
+
}
|
|
4416
|
+
return { success: !1, errors: s };
|
|
4417
|
+
}
|
|
4418
|
+
function Dr(e, t) {
|
|
4419
|
+
const r = t[e.field];
|
|
4420
|
+
switch (e.operator) {
|
|
4421
|
+
case "equals":
|
|
4422
|
+
return r === e.value;
|
|
4423
|
+
case "notEquals":
|
|
4424
|
+
return r !== e.value;
|
|
4425
|
+
case "contains":
|
|
4426
|
+
return typeof r == "string" && typeof e.value == "string" ? r.toLowerCase().includes(e.value.toLowerCase()) : Array.isArray(r) ? r.includes(e.value) : !1;
|
|
4427
|
+
case "notContains":
|
|
4428
|
+
return typeof r == "string" && typeof e.value == "string" ? !r.toLowerCase().includes(e.value.toLowerCase()) : Array.isArray(r) ? !r.includes(e.value) : !0;
|
|
4429
|
+
case "isEmpty":
|
|
4430
|
+
return r == null || r === "" || Array.isArray(r) && r.length === 0;
|
|
4431
|
+
case "isNotEmpty":
|
|
4432
|
+
return r != null && r !== "" && (!Array.isArray(r) || r.length > 0);
|
|
4433
|
+
default:
|
|
4434
|
+
return !0;
|
|
4435
|
+
}
|
|
4436
|
+
}
|
|
4437
|
+
function ac(e, t) {
|
|
4438
|
+
return {
|
|
4439
|
+
visibleFields: xt(() => e.filter((s) => s.condition ? Dr(s.condition, t) : !0), [e, t]),
|
|
4440
|
+
isFieldVisible: (s) => {
|
|
4441
|
+
const o = e.find((i) => i.name === s);
|
|
4442
|
+
return !o || !o.condition ? !0 : Dr(o.condition, t);
|
|
4443
|
+
}
|
|
4444
|
+
};
|
|
4445
|
+
}
|
|
4446
|
+
function uc({
|
|
4447
|
+
config: e,
|
|
4448
|
+
onSubmit: t,
|
|
4449
|
+
defaultValues: r = {}
|
|
4450
|
+
}) {
|
|
4451
|
+
const [n, s] = Vn({
|
|
4452
|
+
currentStep: 1,
|
|
4453
|
+
isSubmitting: !1,
|
|
4454
|
+
isSubmitted: !1
|
|
4455
|
+
}), o = xt(() => An(e.fields), [e.fields]), i = cs({
|
|
4456
|
+
resolver: Ca(o),
|
|
4457
|
+
defaultValues: r,
|
|
4458
|
+
mode: "onBlur"
|
|
4459
|
+
}), a = i.watch(), { visibleFields: c, isFieldVisible: f } = ac(e.fields, a), _ = e.isMultiStep && e.steps ? e.steps.length : 1, g = xt(() => e.isMultiStep ? c.filter((z) => z.step === n.currentStep) : c, [e.isMultiStep, c, n.currentStep]), b = n.currentStep < _, v = n.currentStep > 1, Z = Ie(async () => {
|
|
4460
|
+
const z = g.map((L) => L.name);
|
|
4461
|
+
return await i.trigger(z);
|
|
4462
|
+
}, [i, g]), O = Ie(async () => {
|
|
4463
|
+
if (!b) return;
|
|
4464
|
+
await Z() && s((S) => ({ ...S, currentStep: S.currentStep + 1 }));
|
|
4465
|
+
}, [b, Z]), I = Ie(() => {
|
|
4466
|
+
v && s((z) => ({ ...z, currentStep: z.currentStep - 1 }));
|
|
4467
|
+
}, [v]), F = Ie(
|
|
4468
|
+
(z) => {
|
|
4469
|
+
z >= 1 && z <= _ && s((S) => ({ ...S, currentStep: z }));
|
|
4470
|
+
},
|
|
4471
|
+
[_]
|
|
4472
|
+
), N = Ie(() => {
|
|
4473
|
+
i.handleSubmit(async (z) => {
|
|
4474
|
+
s((S) => ({ ...S, isSubmitting: !0, submitError: void 0 }));
|
|
4475
|
+
try {
|
|
4476
|
+
if (t) {
|
|
4477
|
+
const S = await t(z);
|
|
4478
|
+
if (S.success)
|
|
4479
|
+
s((L) => ({ ...L, isSubmitting: !1, isSubmitted: !0 })), S.redirectUrl && (((re) => {
|
|
4480
|
+
if (re.startsWith("/") && !re.startsWith("//"))
|
|
4481
|
+
return !0;
|
|
4482
|
+
try {
|
|
4483
|
+
return new URL(re, window.location.origin).origin === window.location.origin;
|
|
4484
|
+
} catch {
|
|
4485
|
+
return !1;
|
|
4486
|
+
}
|
|
4487
|
+
})(S.redirectUrl) ? window.location.href = S.redirectUrl : console.warn("Blocked unsafe redirect URL:", S.redirectUrl));
|
|
4488
|
+
else if (s((L) => ({
|
|
4489
|
+
...L,
|
|
4490
|
+
isSubmitting: !1,
|
|
4491
|
+
submitError: S.message || "Submission failed"
|
|
4492
|
+
})), S.errors)
|
|
4493
|
+
for (const [L, re] of Object.entries(S.errors))
|
|
4494
|
+
i.setError(L, { message: re });
|
|
4495
|
+
}
|
|
4496
|
+
} catch (S) {
|
|
4497
|
+
s((L) => ({
|
|
4498
|
+
...L,
|
|
4499
|
+
isSubmitting: !1,
|
|
4500
|
+
submitError: S instanceof Error ? S.message : "An error occurred"
|
|
4501
|
+
}));
|
|
4502
|
+
}
|
|
4503
|
+
})();
|
|
4504
|
+
}, [i, t]), P = Ie(() => {
|
|
4505
|
+
i.reset(r), s({
|
|
4506
|
+
currentStep: 1,
|
|
4507
|
+
isSubmitting: !1,
|
|
4508
|
+
isSubmitted: !1
|
|
4509
|
+
});
|
|
4510
|
+
}, [i, r]);
|
|
4511
|
+
return {
|
|
4512
|
+
form: i,
|
|
4513
|
+
state: n,
|
|
4514
|
+
currentStep: n.currentStep,
|
|
4515
|
+
totalSteps: _,
|
|
4516
|
+
canGoNext: b,
|
|
4517
|
+
canGoPrev: v,
|
|
4518
|
+
nextStep: O,
|
|
4519
|
+
prevStep: I,
|
|
4520
|
+
goToStep: F,
|
|
4521
|
+
visibleFields: c,
|
|
4522
|
+
currentStepFields: g,
|
|
4523
|
+
isFieldVisible: f,
|
|
4524
|
+
handleSubmit: N,
|
|
4525
|
+
reset: P,
|
|
4526
|
+
config: e
|
|
4527
|
+
};
|
|
4528
|
+
}
|
|
4529
|
+
function Ur({ field: e, value: t, onChange: r, error: n, disabled: s }) {
|
|
4530
|
+
return /* @__PURE__ */ m.jsxs("div", { className: "reverso-field reverso-text-field", children: [
|
|
4531
|
+
e.label && /* @__PURE__ */ m.jsxs("label", { className: "reverso-field-label", htmlFor: e.id, children: [
|
|
4532
|
+
e.label,
|
|
4533
|
+
e.required && /* @__PURE__ */ m.jsx("span", { className: "reverso-field-required", children: "*" })
|
|
4534
|
+
] }),
|
|
4535
|
+
/* @__PURE__ */ m.jsx(
|
|
4536
|
+
"input",
|
|
4537
|
+
{
|
|
4538
|
+
type: "text",
|
|
4539
|
+
id: e.id,
|
|
4540
|
+
name: e.name,
|
|
4541
|
+
value: t || "",
|
|
4542
|
+
onChange: (o) => r(o.target.value),
|
|
4543
|
+
placeholder: e.placeholder,
|
|
4544
|
+
disabled: s,
|
|
4545
|
+
className: `reverso-field-input ${n ? "reverso-field-error" : ""}`,
|
|
4546
|
+
minLength: e.config?.minLength,
|
|
4547
|
+
maxLength: e.config?.maxLength,
|
|
4548
|
+
pattern: e.config?.pattern
|
|
4549
|
+
}
|
|
4550
|
+
),
|
|
4551
|
+
e.help && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-help", children: e.help }),
|
|
4552
|
+
n && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-error-message", children: n })
|
|
4553
|
+
] });
|
|
4554
|
+
}
|
|
4555
|
+
function cc({ field: e, value: t, onChange: r, error: n, disabled: s }) {
|
|
4556
|
+
return /* @__PURE__ */ m.jsxs("div", { className: "reverso-field reverso-email-field", children: [
|
|
4557
|
+
e.label && /* @__PURE__ */ m.jsxs("label", { className: "reverso-field-label", htmlFor: e.id, children: [
|
|
4558
|
+
e.label,
|
|
4559
|
+
e.required && /* @__PURE__ */ m.jsx("span", { className: "reverso-field-required", children: "*" })
|
|
4560
|
+
] }),
|
|
4561
|
+
/* @__PURE__ */ m.jsx(
|
|
4562
|
+
"input",
|
|
4563
|
+
{
|
|
4564
|
+
type: "email",
|
|
4565
|
+
id: e.id,
|
|
4566
|
+
name: e.name,
|
|
4567
|
+
value: t || "",
|
|
4568
|
+
onChange: (o) => r(o.target.value),
|
|
4569
|
+
placeholder: e.placeholder,
|
|
4570
|
+
disabled: s,
|
|
4571
|
+
className: `reverso-field-input ${n ? "reverso-field-error" : ""}`
|
|
4572
|
+
}
|
|
4573
|
+
),
|
|
4574
|
+
e.help && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-help", children: e.help }),
|
|
4575
|
+
n && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-error-message", children: n })
|
|
4576
|
+
] });
|
|
4577
|
+
}
|
|
4578
|
+
function lc({ field: e, value: t, onChange: r, error: n, disabled: s }) {
|
|
4579
|
+
return /* @__PURE__ */ m.jsxs("div", { className: "reverso-field reverso-textarea-field", children: [
|
|
4580
|
+
e.label && /* @__PURE__ */ m.jsxs("label", { className: "reverso-field-label", htmlFor: e.id, children: [
|
|
4581
|
+
e.label,
|
|
4582
|
+
e.required && /* @__PURE__ */ m.jsx("span", { className: "reverso-field-required", children: "*" })
|
|
4583
|
+
] }),
|
|
4584
|
+
/* @__PURE__ */ m.jsx(
|
|
4585
|
+
"textarea",
|
|
4586
|
+
{
|
|
4587
|
+
id: e.id,
|
|
4588
|
+
name: e.name,
|
|
4589
|
+
value: t || "",
|
|
4590
|
+
onChange: (o) => r(o.target.value),
|
|
4591
|
+
placeholder: e.placeholder,
|
|
4592
|
+
disabled: s,
|
|
4593
|
+
className: `reverso-field-input reverso-field-textarea ${n ? "reverso-field-error" : ""}`,
|
|
4594
|
+
rows: e.config?.rows || 4,
|
|
4595
|
+
minLength: e.config?.minLength,
|
|
4596
|
+
maxLength: e.config?.maxLength
|
|
4597
|
+
}
|
|
4598
|
+
),
|
|
4599
|
+
e.help && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-help", children: e.help }),
|
|
4600
|
+
n && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-error-message", children: n })
|
|
4601
|
+
] });
|
|
4602
|
+
}
|
|
4603
|
+
function fc({ field: e, value: t, onChange: r, error: n, disabled: s }) {
|
|
4604
|
+
return /* @__PURE__ */ m.jsxs("div", { className: "reverso-field reverso-number-field", children: [
|
|
4605
|
+
e.label && /* @__PURE__ */ m.jsxs("label", { className: "reverso-field-label", htmlFor: e.id, children: [
|
|
4606
|
+
e.label,
|
|
4607
|
+
e.required && /* @__PURE__ */ m.jsx("span", { className: "reverso-field-required", children: "*" })
|
|
4608
|
+
] }),
|
|
4609
|
+
/* @__PURE__ */ m.jsx(
|
|
4610
|
+
"input",
|
|
4611
|
+
{
|
|
4612
|
+
type: "number",
|
|
4613
|
+
id: e.id,
|
|
4614
|
+
name: e.name,
|
|
4615
|
+
value: t !== void 0 ? String(t) : "",
|
|
4616
|
+
onChange: (o) => r(o.target.value ? Number(o.target.value) : void 0),
|
|
4617
|
+
placeholder: e.placeholder,
|
|
4618
|
+
disabled: s,
|
|
4619
|
+
className: `reverso-field-input ${n ? "reverso-field-error" : ""}`,
|
|
4620
|
+
min: e.config?.min,
|
|
4621
|
+
max: e.config?.max
|
|
4622
|
+
}
|
|
4623
|
+
),
|
|
4624
|
+
e.help && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-help", children: e.help }),
|
|
4625
|
+
n && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-error-message", children: n })
|
|
4626
|
+
] });
|
|
4627
|
+
}
|
|
4628
|
+
function dc({ field: e, value: t, onChange: r, error: n, disabled: s }) {
|
|
4629
|
+
const o = e.config?.options || [];
|
|
4630
|
+
return /* @__PURE__ */ m.jsxs("div", { className: "reverso-field reverso-select-field", children: [
|
|
4631
|
+
e.label && /* @__PURE__ */ m.jsxs("label", { className: "reverso-field-label", htmlFor: e.id, children: [
|
|
4632
|
+
e.label,
|
|
4633
|
+
e.required && /* @__PURE__ */ m.jsx("span", { className: "reverso-field-required", children: "*" })
|
|
4634
|
+
] }),
|
|
4635
|
+
/* @__PURE__ */ m.jsxs(
|
|
4636
|
+
"select",
|
|
4637
|
+
{
|
|
4638
|
+
id: e.id,
|
|
4639
|
+
name: e.name,
|
|
4640
|
+
value: t || "",
|
|
4641
|
+
onChange: (i) => r(i.target.value || void 0),
|
|
4642
|
+
disabled: s,
|
|
4643
|
+
className: `reverso-field-input reverso-field-select ${n ? "reverso-field-error" : ""}`,
|
|
4644
|
+
multiple: e.config?.multiple,
|
|
4645
|
+
children: [
|
|
4646
|
+
!e.required && /* @__PURE__ */ m.jsx("option", { value: "", children: "Select an option..." }),
|
|
4647
|
+
o.map((i) => /* @__PURE__ */ m.jsx("option", { value: i.value, children: i.label }, i.value))
|
|
4648
|
+
]
|
|
4649
|
+
}
|
|
4650
|
+
),
|
|
4651
|
+
e.help && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-help", children: e.help }),
|
|
4652
|
+
n && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-error-message", children: n })
|
|
4653
|
+
] });
|
|
4654
|
+
}
|
|
4655
|
+
function hc({ field: e, value: t, onChange: r, error: n, disabled: s }) {
|
|
4656
|
+
return /* @__PURE__ */ m.jsxs("div", { className: "reverso-field reverso-checkbox-field", children: [
|
|
4657
|
+
/* @__PURE__ */ m.jsxs("div", { className: "reverso-checkbox-wrapper", children: [
|
|
4658
|
+
/* @__PURE__ */ m.jsx(
|
|
4659
|
+
"input",
|
|
4660
|
+
{
|
|
4661
|
+
type: "checkbox",
|
|
4662
|
+
id: e.id,
|
|
4663
|
+
name: e.name,
|
|
4664
|
+
checked: !!t,
|
|
4665
|
+
onChange: (o) => r(o.target.checked),
|
|
4666
|
+
disabled: s,
|
|
4667
|
+
className: `reverso-field-checkbox ${n ? "reverso-field-error" : ""}`
|
|
4668
|
+
}
|
|
4669
|
+
),
|
|
4670
|
+
e.label && /* @__PURE__ */ m.jsxs("label", { className: "reverso-checkbox-label", htmlFor: e.id, children: [
|
|
4671
|
+
e.label,
|
|
4672
|
+
e.required && /* @__PURE__ */ m.jsx("span", { className: "reverso-field-required", children: "*" })
|
|
4673
|
+
] })
|
|
4674
|
+
] }),
|
|
4675
|
+
e.help && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-help", children: e.help }),
|
|
4676
|
+
n && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-error-message", children: n })
|
|
4677
|
+
] });
|
|
4678
|
+
}
|
|
4679
|
+
function mc({ field: e, value: t, onChange: r, error: n, disabled: s }) {
|
|
4680
|
+
const o = e.config?.options || [];
|
|
4681
|
+
return /* @__PURE__ */ m.jsxs("fieldset", { className: "reverso-field reverso-radio-field", children: [
|
|
4682
|
+
e.label && /* @__PURE__ */ m.jsxs("legend", { className: "reverso-field-label", children: [
|
|
4683
|
+
e.label,
|
|
4684
|
+
e.required && /* @__PURE__ */ m.jsx("span", { className: "reverso-field-required", children: "*" })
|
|
4685
|
+
] }),
|
|
4686
|
+
/* @__PURE__ */ m.jsx("div", { className: "reverso-radio-group", children: o.map((i) => /* @__PURE__ */ m.jsxs("div", { className: "reverso-radio-option", children: [
|
|
4687
|
+
/* @__PURE__ */ m.jsx(
|
|
4688
|
+
"input",
|
|
4689
|
+
{
|
|
4690
|
+
type: "radio",
|
|
4691
|
+
id: `${e.id}-${i.value}`,
|
|
4692
|
+
name: e.name,
|
|
4693
|
+
value: i.value,
|
|
4694
|
+
checked: t === i.value,
|
|
4695
|
+
onChange: (a) => r(a.target.value),
|
|
4696
|
+
disabled: s,
|
|
4697
|
+
className: "reverso-field-radio"
|
|
4698
|
+
}
|
|
4699
|
+
),
|
|
4700
|
+
/* @__PURE__ */ m.jsx("label", { className: "reverso-radio-label", htmlFor: `${e.id}-${i.value}`, children: i.label })
|
|
4701
|
+
] }, i.value)) }),
|
|
4702
|
+
e.help && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-help", children: e.help }),
|
|
4703
|
+
n && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-error-message", children: n })
|
|
4704
|
+
] });
|
|
4705
|
+
}
|
|
4706
|
+
function pc({ field: e, value: t, onChange: r, error: n, disabled: s }) {
|
|
4707
|
+
return /* @__PURE__ */ m.jsxs("div", { className: "reverso-field reverso-date-field", children: [
|
|
4708
|
+
e.label && /* @__PURE__ */ m.jsxs("label", { className: "reverso-field-label", htmlFor: e.id, children: [
|
|
4709
|
+
e.label,
|
|
4710
|
+
e.required && /* @__PURE__ */ m.jsx("span", { className: "reverso-field-required", children: "*" })
|
|
4711
|
+
] }),
|
|
4712
|
+
/* @__PURE__ */ m.jsx(
|
|
4713
|
+
"input",
|
|
4714
|
+
{
|
|
4715
|
+
type: "date",
|
|
4716
|
+
id: e.id,
|
|
4717
|
+
name: e.name,
|
|
4718
|
+
value: t || "",
|
|
4719
|
+
onChange: (o) => r(o.target.value || void 0),
|
|
4720
|
+
disabled: s,
|
|
4721
|
+
className: `reverso-field-input ${n ? "reverso-field-error" : ""}`
|
|
4722
|
+
}
|
|
4723
|
+
),
|
|
4724
|
+
e.help && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-help", children: e.help }),
|
|
4725
|
+
n && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-error-message", children: n })
|
|
4726
|
+
] });
|
|
4727
|
+
}
|
|
4728
|
+
function vc({ field: e, value: t, onChange: r, error: n, disabled: s }) {
|
|
4729
|
+
const o = (i) => {
|
|
4730
|
+
const a = i.target.files;
|
|
4731
|
+
a && a.length > 0 ? e.config?.multiple ? r(Array.from(a)) : r(a[0]) : r(void 0);
|
|
4732
|
+
};
|
|
4733
|
+
return /* @__PURE__ */ m.jsxs("div", { className: "reverso-field reverso-file-field", children: [
|
|
4734
|
+
e.label && /* @__PURE__ */ m.jsxs("label", { className: "reverso-field-label", htmlFor: e.id, children: [
|
|
4735
|
+
e.label,
|
|
4736
|
+
e.required && /* @__PURE__ */ m.jsx("span", { className: "reverso-field-required", children: "*" })
|
|
4737
|
+
] }),
|
|
4738
|
+
/* @__PURE__ */ m.jsx(
|
|
4739
|
+
"input",
|
|
4740
|
+
{
|
|
4741
|
+
type: "file",
|
|
4742
|
+
id: e.id,
|
|
4743
|
+
name: e.name,
|
|
4744
|
+
onChange: o,
|
|
4745
|
+
disabled: s,
|
|
4746
|
+
className: `reverso-field-input reverso-field-file ${n ? "reverso-field-error" : ""}`,
|
|
4747
|
+
accept: e.config?.accept,
|
|
4748
|
+
multiple: e.config?.multiple
|
|
4749
|
+
}
|
|
4750
|
+
),
|
|
4751
|
+
e.help && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-help", children: e.help }),
|
|
4752
|
+
n && /* @__PURE__ */ m.jsx("p", { className: "reverso-field-error-message", children: n })
|
|
4753
|
+
] });
|
|
4754
|
+
}
|
|
4755
|
+
function gc({ field: e, value: t }) {
|
|
4756
|
+
return /* @__PURE__ */ m.jsx("input", { type: "hidden", id: e.id, name: e.name, value: t || "" });
|
|
4757
|
+
}
|
|
4758
|
+
function Lr(e) {
|
|
4759
|
+
const { field: t } = e;
|
|
4760
|
+
switch (t.type) {
|
|
4761
|
+
case "text":
|
|
4762
|
+
return /* @__PURE__ */ m.jsx(Ur, { ...e });
|
|
4763
|
+
case "email":
|
|
4764
|
+
return /* @__PURE__ */ m.jsx(cc, { ...e });
|
|
4765
|
+
case "textarea":
|
|
4766
|
+
return /* @__PURE__ */ m.jsx(lc, { ...e });
|
|
4767
|
+
case "number":
|
|
4768
|
+
return /* @__PURE__ */ m.jsx(fc, { ...e });
|
|
4769
|
+
case "select":
|
|
4770
|
+
return /* @__PURE__ */ m.jsx(dc, { ...e });
|
|
4771
|
+
case "checkbox":
|
|
4772
|
+
return /* @__PURE__ */ m.jsx(hc, { ...e });
|
|
4773
|
+
case "radio":
|
|
4774
|
+
return /* @__PURE__ */ m.jsx(mc, { ...e });
|
|
4775
|
+
case "date":
|
|
4776
|
+
return /* @__PURE__ */ m.jsx(pc, { ...e });
|
|
4777
|
+
case "file":
|
|
4778
|
+
return /* @__PURE__ */ m.jsx(vc, { ...e });
|
|
4779
|
+
case "hidden":
|
|
4780
|
+
return /* @__PURE__ */ m.jsx(gc, { ...e });
|
|
4781
|
+
default:
|
|
4782
|
+
return /* @__PURE__ */ m.jsx(Ur, { ...e });
|
|
4783
|
+
}
|
|
4784
|
+
}
|
|
4785
|
+
function _c({ steps: e, currentStep: t, onStepClick: r }) {
|
|
4786
|
+
return /* @__PURE__ */ m.jsxs("div", { className: "reverso-form-progress", children: [
|
|
4787
|
+
/* @__PURE__ */ m.jsx("div", { className: "reverso-progress-steps", children: e.map((n, s) => {
|
|
4788
|
+
const o = s + 1, i = o === t, a = o < t, c = r && o < t;
|
|
4789
|
+
return /* @__PURE__ */ m.jsxs(
|
|
4790
|
+
"div",
|
|
4791
|
+
{
|
|
4792
|
+
className: `reverso-progress-step ${i ? "active" : ""} ${a ? "completed" : ""}`,
|
|
4793
|
+
children: [
|
|
4794
|
+
/* @__PURE__ */ m.jsxs(
|
|
4795
|
+
"button",
|
|
4796
|
+
{
|
|
4797
|
+
type: "button",
|
|
4798
|
+
className: "reverso-progress-step-button",
|
|
4799
|
+
onClick: () => c && r(o),
|
|
4800
|
+
disabled: !c,
|
|
4801
|
+
"aria-current": i ? "step" : void 0,
|
|
4802
|
+
children: [
|
|
4803
|
+
/* @__PURE__ */ m.jsx("span", { className: "reverso-progress-step-number", children: a ? "✓" : o }),
|
|
4804
|
+
/* @__PURE__ */ m.jsx("span", { className: "reverso-progress-step-name", children: n.name })
|
|
4805
|
+
]
|
|
4806
|
+
}
|
|
4807
|
+
),
|
|
4808
|
+
s < e.length - 1 && /* @__PURE__ */ m.jsx("div", { className: "reverso-progress-connector" })
|
|
4809
|
+
]
|
|
4810
|
+
},
|
|
4811
|
+
n.id
|
|
4812
|
+
);
|
|
4813
|
+
}) }),
|
|
4814
|
+
/* @__PURE__ */ m.jsx("div", { className: "reverso-progress-bar", children: /* @__PURE__ */ m.jsx(
|
|
4815
|
+
"div",
|
|
4816
|
+
{
|
|
4817
|
+
className: "reverso-progress-bar-fill",
|
|
4818
|
+
style: { width: `${(t - 1) / (e.length - 1) * 100}%` }
|
|
4819
|
+
}
|
|
4820
|
+
) })
|
|
4821
|
+
] });
|
|
4822
|
+
}
|
|
4823
|
+
function yc({ step: e, isActive: t, children: r }) {
|
|
4824
|
+
return t ? /* @__PURE__ */ m.jsxs("fieldset", { className: "reverso-form-step", children: [
|
|
4825
|
+
/* @__PURE__ */ m.jsx("legend", { className: "reverso-form-step-title", children: e.name }),
|
|
4826
|
+
e.description && /* @__PURE__ */ m.jsx("p", { className: "reverso-form-step-description", children: e.description }),
|
|
4827
|
+
/* @__PURE__ */ m.jsx("div", { className: "reverso-form-step-content", children: r })
|
|
4828
|
+
] }) : null;
|
|
4829
|
+
}
|
|
4830
|
+
function zc({ config: e, onSubmit: t, defaultValues: r, className: n, children: s }) {
|
|
4831
|
+
const {
|
|
4832
|
+
form: o,
|
|
4833
|
+
state: i,
|
|
4834
|
+
currentStep: a,
|
|
4835
|
+
totalSteps: c,
|
|
4836
|
+
canGoNext: f,
|
|
4837
|
+
canGoPrev: _,
|
|
4838
|
+
nextStep: g,
|
|
4839
|
+
prevStep: b,
|
|
4840
|
+
goToStep: v,
|
|
4841
|
+
currentStepFields: Z,
|
|
4842
|
+
handleSubmit: O
|
|
4843
|
+
} = uc({
|
|
4844
|
+
config: e,
|
|
4845
|
+
onSubmit: t,
|
|
4846
|
+
defaultValues: r
|
|
4847
|
+
});
|
|
4848
|
+
if (i.isSubmitted)
|
|
4849
|
+
return /* @__PURE__ */ m.jsx("div", { className: `reverso-form reverso-form-success ${n || ""}`, children: /* @__PURE__ */ m.jsx("div", { className: "reverso-form-success-message", children: /* @__PURE__ */ m.jsx("p", { children: e.settings?.successMessage || "Thank you for your submission!" }) }) });
|
|
4850
|
+
const I = (F) => `${(F || 12) / 12 * 100}%`;
|
|
4851
|
+
return /* @__PURE__ */ m.jsxs(
|
|
4852
|
+
"form",
|
|
4853
|
+
{
|
|
4854
|
+
className: `reverso-form ${n || ""}`,
|
|
4855
|
+
onSubmit: (F) => {
|
|
4856
|
+
F.preventDefault(), e.isMultiStep && f ? g() : O();
|
|
4857
|
+
},
|
|
4858
|
+
noValidate: !0,
|
|
4859
|
+
children: [
|
|
4860
|
+
e.honeypotEnabled && /* @__PURE__ */ m.jsx("div", { style: { position: "absolute", left: "-9999px" }, "aria-hidden": "true", children: /* @__PURE__ */ m.jsx("input", { type: "text", tabIndex: -1, autoComplete: "off", ...o.register("_honeypot") }) }),
|
|
4861
|
+
e.isMultiStep && e.steps && e.steps.length > 1 && /* @__PURE__ */ m.jsx(_c, { steps: e.steps, currentStep: a, onStepClick: v }),
|
|
4862
|
+
/* @__PURE__ */ m.jsx("div", { className: "reverso-form-fields", children: e.isMultiStep && e.steps ? e.steps.map((F, N) => /* @__PURE__ */ m.jsx(yc, { step: F, isActive: N + 1 === a, children: /* @__PURE__ */ m.jsx("div", { className: "reverso-form-fields-grid", children: Z.map((P) => /* @__PURE__ */ m.jsx(
|
|
4863
|
+
"div",
|
|
4864
|
+
{
|
|
4865
|
+
className: "reverso-form-field-wrapper",
|
|
4866
|
+
style: { width: I(P.width) },
|
|
4867
|
+
children: /* @__PURE__ */ m.jsx(
|
|
4868
|
+
rr,
|
|
4869
|
+
{
|
|
4870
|
+
name: P.name,
|
|
4871
|
+
control: o.control,
|
|
4872
|
+
render: ({ field: z, fieldState: S }) => /* @__PURE__ */ m.jsx(
|
|
4873
|
+
Lr,
|
|
4874
|
+
{
|
|
4875
|
+
field: P,
|
|
4876
|
+
value: z.value,
|
|
4877
|
+
onChange: z.onChange,
|
|
4878
|
+
error: S.error?.message,
|
|
4879
|
+
disabled: i.isSubmitting
|
|
4880
|
+
}
|
|
4881
|
+
)
|
|
4882
|
+
}
|
|
4883
|
+
)
|
|
4884
|
+
},
|
|
4885
|
+
P.id
|
|
4886
|
+
)) }) }, F.id)) : /* @__PURE__ */ m.jsx("div", { className: "reverso-form-fields-grid", children: Z.map((F) => /* @__PURE__ */ m.jsx(
|
|
4887
|
+
"div",
|
|
4888
|
+
{
|
|
4889
|
+
className: "reverso-form-field-wrapper",
|
|
4890
|
+
style: { width: I(F.width) },
|
|
4891
|
+
children: /* @__PURE__ */ m.jsx(
|
|
4892
|
+
rr,
|
|
4893
|
+
{
|
|
4894
|
+
name: F.name,
|
|
4895
|
+
control: o.control,
|
|
4896
|
+
render: ({ field: N, fieldState: P }) => /* @__PURE__ */ m.jsx(
|
|
4897
|
+
Lr,
|
|
4898
|
+
{
|
|
4899
|
+
field: F,
|
|
4900
|
+
value: N.value,
|
|
4901
|
+
onChange: N.onChange,
|
|
4902
|
+
error: P.error?.message,
|
|
4903
|
+
disabled: i.isSubmitting
|
|
4904
|
+
}
|
|
4905
|
+
)
|
|
4906
|
+
}
|
|
4907
|
+
)
|
|
4908
|
+
},
|
|
4909
|
+
F.id
|
|
4910
|
+
)) }) }),
|
|
4911
|
+
i.submitError && /* @__PURE__ */ m.jsx("div", { className: "reverso-form-error", role: "alert", children: /* @__PURE__ */ m.jsx("p", { children: i.submitError }) }),
|
|
4912
|
+
s,
|
|
4913
|
+
/* @__PURE__ */ m.jsxs("div", { className: "reverso-form-actions", children: [
|
|
4914
|
+
e.isMultiStep && _ && /* @__PURE__ */ m.jsx(
|
|
4915
|
+
"button",
|
|
4916
|
+
{
|
|
4917
|
+
type: "button",
|
|
4918
|
+
className: "reverso-form-button reverso-form-button-prev",
|
|
4919
|
+
onClick: b,
|
|
4920
|
+
disabled: i.isSubmitting,
|
|
4921
|
+
children: "Previous"
|
|
4922
|
+
}
|
|
4923
|
+
),
|
|
4924
|
+
/* @__PURE__ */ m.jsx(
|
|
4925
|
+
"button",
|
|
4926
|
+
{
|
|
4927
|
+
type: "submit",
|
|
4928
|
+
className: "reverso-form-button reverso-form-button-submit",
|
|
4929
|
+
disabled: i.isSubmitting,
|
|
4930
|
+
children: i.isSubmitting ? "Submitting..." : e.isMultiStep && f ? "Next" : e.settings?.submitButtonText || "Submit"
|
|
4931
|
+
}
|
|
4932
|
+
)
|
|
4933
|
+
] })
|
|
4934
|
+
]
|
|
4935
|
+
}
|
|
4936
|
+
);
|
|
4937
|
+
}
|
|
4938
|
+
const Sc = "0.0.0";
|
|
4939
|
+
export {
|
|
4940
|
+
hc as CheckboxField,
|
|
4941
|
+
pc as DateField,
|
|
4942
|
+
cc as EmailField,
|
|
4943
|
+
vc as FileField,
|
|
4944
|
+
zc as Form,
|
|
4945
|
+
Lr as FormField,
|
|
4946
|
+
_c as FormProgress,
|
|
4947
|
+
yc as FormStep,
|
|
4948
|
+
gc as HiddenField,
|
|
4949
|
+
fc as NumberField,
|
|
4950
|
+
mc as RadioField,
|
|
4951
|
+
dc as SelectField,
|
|
4952
|
+
Ur as TextField,
|
|
4953
|
+
lc as TextareaField,
|
|
4954
|
+
Sc as VERSION,
|
|
4955
|
+
An as buildFormSchema,
|
|
4956
|
+
ac as useConditionalFields,
|
|
4957
|
+
uc as useReversoForm,
|
|
4958
|
+
kc as validateFormData
|
|
4959
|
+
};
|