@oneclick.dev/cms-core-modules 0.0.53 → 0.0.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CalendarDate-CRT2Viyt.mjs +830 -0
- package/dist/CalendarDate-CWtpXgpD.js +1 -0
- package/dist/Components-D9yIIosM.mjs +623 -0
- package/dist/Components-DXbx0RLV.js +1 -0
- package/dist/ContentEditor-DRJFQKCv.mjs +34915 -0
- package/dist/ContentEditor-DzTi8fSZ.js +290 -0
- package/dist/Create-BP8TX6rj.js +1 -0
- package/dist/Create-Bwf1RXdG.mjs +1248 -0
- package/dist/DateFormatter-BbcSwTs4.js +1 -0
- package/dist/DateFormatter-CbO0PVUK.mjs +99 -0
- package/dist/Detail-B-PnkcXD.mjs +3473 -0
- package/dist/Detail-BVlGSjOq.mjs +380 -0
- package/dist/Detail-C4E1T87K.mjs +26 -0
- package/dist/Detail-CNfTDUE5.js +1 -0
- package/dist/Detail-Cd5CBVN0.js +1 -0
- package/dist/Detail-CpfOQChd.mjs +585 -0
- package/dist/Detail-CwagT6gQ.mjs +650 -0
- package/dist/Detail-DUo6qKqO.js +1 -0
- package/dist/Detail-Dd_OkpcN.js +1 -0
- package/dist/Detail-mvSGbnFU.js +1 -0
- package/dist/EditLayout.vue_vue_type_script_setup_true_lang-BWuKVkvV.js +1 -0
- package/dist/EditLayout.vue_vue_type_script_setup_true_lang-D0-EcU0_.mjs +55 -0
- package/dist/Entries-DcpPvlYj.js +1 -0
- package/dist/Entries-QLMtTYLX.mjs +713 -0
- package/dist/Find-BPR0uU-Z.mjs +229 -0
- package/dist/Find-BidEQJxT.js +1 -0
- package/dist/GlobalStyling-CMzPRd18.js +17 -0
- package/dist/GlobalStyling-DoLHUJeV.mjs +988 -0
- package/dist/Overview-BDlBCUI_.js +1 -0
- package/dist/Overview-BH3NwvNX.mjs +26 -0
- package/dist/Overview-BLsZMHNW.mjs +178 -0
- package/dist/Overview-BNMZ9MUK.js +1 -0
- package/dist/Overview-BbvfH1u-.js +1 -0
- package/dist/Overview-CDN88OSM.mjs +190 -0
- package/dist/Overview-CEPodGCn.mjs +311 -0
- package/dist/Overview-CvquDPhB.js +1 -0
- package/dist/Overview-D54pjmI6.mjs +633 -0
- package/dist/Overview-D67UjG6n.mjs +947 -0
- package/dist/Overview-KT2Mgfh5.js +1 -0
- package/dist/Overview-T-lsy3UZ.js +1 -0
- package/dist/RegularSlotEditor.vue_vue_type_script_setup_true_lang-0xZSq0rx.js +1 -0
- package/dist/RegularSlotEditor.vue_vue_type_script_setup_true_lang-Bj_PVLLV.mjs +392 -0
- package/dist/TableView-CpO53xcX.js +111 -0
- package/dist/TableView-D9J5rUls.mjs +72921 -0
- package/dist/TemplateList.vue_vue_type_script_setup_true_lang-B_AtWnHa.js +1 -0
- package/dist/TemplateList.vue_vue_type_script_setup_true_lang-BiLAkhIA.mjs +40 -0
- package/dist/View-DlHBZbFu.js +1 -0
- package/dist/View-Dv5QMrSn.mjs +25 -0
- package/dist/_plugin-vue_export-helper-BHFhmbuH.js +1 -0
- package/dist/_plugin-vue_export-helper-CHgC5LLL.mjs +9 -0
- package/dist/agenda-B49oKGeh.mjs +706 -0
- package/dist/agenda-DipQ5IWP.js +1 -0
- package/dist/availability-C7q9tq6l.js +1 -0
- package/dist/availability-DeCkqiu8.mjs +613 -0
- package/dist/cms-core-modules.css +1 -1
- package/dist/countries-BTPvmrsb.mjs +4 -0
- package/dist/countries-CgZ081No.js +1 -0
- package/dist/exceptions-D3b18TiY.mjs +647 -0
- package/dist/exceptions-DJ9zWX3k.js +1 -0
- package/dist/floating-ui.dom-C82nbomj.js +1 -0
- package/dist/floating-ui.dom-ouSgPqty.mjs +1133 -0
- package/dist/google-CvtuJwgk.mjs +4 -0
- package/dist/google-D4N3gb01.js +1 -0
- package/dist/index--jjEzba7.mjs +24 -0
- package/dist/index-9HVlmvK3.js +1 -0
- package/dist/index-BEGU8Kme.mjs +12 -0
- package/dist/index-Bwi1mtkq.mjs +24 -0
- package/dist/index-BzuHN-r8.mjs +24 -0
- package/dist/index-CImCyE3L.mjs +24 -0
- package/dist/index-CKPshlZ8-BQiiP6r_.mjs +1264 -0
- package/dist/index-CKPshlZ8-CIz1tDwX.js +1 -0
- package/dist/index-CQiY-oTN.mjs +24 -0
- package/dist/index-CSxYBeVA.js +1 -0
- package/dist/index-CkiNvRzs.js +1 -0
- package/dist/index-Co4ON2Di.js +1 -0
- package/dist/index-CwqrAU-H.js +1 -0
- package/dist/index-Cz-baGax.js +1 -0
- package/dist/index-D2a6wEPh.js +1 -0
- package/dist/index-DFQGVHTs.js +1 -0
- package/dist/index-DI6mydpm.mjs +138 -0
- package/dist/index-DMoyoaks.mjs +22 -0
- package/dist/index-DT1wWnUk.mjs +24 -0
- package/dist/index-DUeFrD-B.js +1 -0
- package/dist/index-DsnoK4ia.mjs +579 -0
- package/dist/index-R2oUDsjx.js +1 -0
- package/dist/index-RLz1QPrf.mjs +203 -0
- package/dist/index-UtjLbLw-.js +1 -0
- package/dist/index-_mG-aU3Z.mjs +87 -0
- package/dist/index-_sQDF1pH.js +1 -0
- package/dist/index-ijdf0d9-.js +1 -0
- package/dist/index-klI238nT.mjs +24 -0
- package/dist/index.cjs.js +1 -330
- package/dist/index.mjs +287 -69051
- package/dist/interpolation-BNUjI7LH.js +1 -0
- package/dist/interpolation-BpGXqOz8.mjs +59 -0
- package/dist/payment-kTjsV0Jj.js +1 -0
- package/dist/payment-zpCM0LD-.mjs +981 -0
- package/dist/regular-C4_3YXqx.mjs +602 -0
- package/dist/regular-DFwPEbZO.js +1 -0
- package/dist/regular-slots-4ooEpICB.mjs +67 -0
- package/dist/regular-slots-BAVGbomI.js +1 -0
- package/dist/resources-MpQkSstv.mjs +563 -0
- package/dist/resources-iM28T3dD.js +1 -0
- package/dist/src/appointments/index.d.ts +4 -28
- package/dist/src/appointments/routes.d.ts +3 -9
- package/dist/src/content-manager/index.d.ts +5 -147
- package/dist/src/content-manager/routes.d.ts +4 -128
- package/dist/src/custom/index.d.ts +2 -2
- package/dist/src/custom/routes.d.ts +1 -1
- package/dist/src/mail-templates/index.d.ts +2 -30
- package/dist/src/mail-templates/routes.d.ts +1 -11
- package/dist/src/product-collections/index.d.ts +2 -30
- package/dist/src/product-collections/routes.d.ts +1 -11
- package/dist/src/products/index.d.ts +2 -30
- package/dist/src/products/routes.d.ts +1 -11
- package/dist/src/promo-codes/index.d.ts +2 -30
- package/dist/src/promo-codes/routes.d.ts +1 -11
- package/dist/src/shipping-options/index.d.ts +2 -30
- package/dist/src/shipping-options/routes.d.ts +1 -11
- package/dist/src/table/index.d.ts +2 -70
- package/dist/src/table/routes.d.ts +1 -51
- package/dist/utils-BVKy9S2J.mjs +29 -0
- package/dist/utils-D6CaKJbp.js +2 -0
- package/dist/vee-validate-zod-BPQyEfpF.js +1 -0
- package/dist/vee-validate-zod-IXkfh-6Q.mjs +4402 -0
- package/package.json +3 -3
|
@@ -0,0 +1,4402 @@
|
|
|
1
|
+
import { ref as ce, reactive as ft, computed as Z, toValue as b, unref as $, onMounted as Vr, isRef as ht, watch as be, provide as $t, readonly as fn, inject as Tr, watchEffect as hn, nextTick as de, shallowRef as vn, warn as mn, getCurrentInstance as We, onUnmounted as Er, onBeforeUnmount as pn } from "vue";
|
|
2
|
+
function ee(t) {
|
|
3
|
+
return typeof t == "function";
|
|
4
|
+
}
|
|
5
|
+
function Nr(t) {
|
|
6
|
+
return t == null;
|
|
7
|
+
}
|
|
8
|
+
const Ae = (t) => t !== null && !!t && typeof t == "object" && !Array.isArray(t);
|
|
9
|
+
function Wt(t) {
|
|
10
|
+
return Number(t) >= 0;
|
|
11
|
+
}
|
|
12
|
+
function yn(t) {
|
|
13
|
+
const e = parseFloat(t);
|
|
14
|
+
return isNaN(e) ? t : e;
|
|
15
|
+
}
|
|
16
|
+
function gn(t) {
|
|
17
|
+
return typeof t == "object" && t !== null;
|
|
18
|
+
}
|
|
19
|
+
function _n(t) {
|
|
20
|
+
return t == null ? t === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(t);
|
|
21
|
+
}
|
|
22
|
+
function er(t) {
|
|
23
|
+
if (!gn(t) || _n(t) !== "[object Object]")
|
|
24
|
+
return !1;
|
|
25
|
+
if (Object.getPrototypeOf(t) === null)
|
|
26
|
+
return !0;
|
|
27
|
+
let e = t;
|
|
28
|
+
for (; Object.getPrototypeOf(e) !== null; )
|
|
29
|
+
e = Object.getPrototypeOf(e);
|
|
30
|
+
return Object.getPrototypeOf(t) === e;
|
|
31
|
+
}
|
|
32
|
+
function it(t, e) {
|
|
33
|
+
return Object.keys(e).forEach((r) => {
|
|
34
|
+
if (er(e[r]) && er(t[r])) {
|
|
35
|
+
t[r] || (t[r] = {}), it(t[r], e[r]);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
t[r] = e[r];
|
|
39
|
+
}), t;
|
|
40
|
+
}
|
|
41
|
+
function Qe(t) {
|
|
42
|
+
const e = t.split(".");
|
|
43
|
+
if (!e.length)
|
|
44
|
+
return "";
|
|
45
|
+
let r = String(e[0]);
|
|
46
|
+
for (let n = 1; n < e.length; n++) {
|
|
47
|
+
if (Wt(e[n])) {
|
|
48
|
+
r += `[${e[n]}]`;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
r += `.${e[n]}`;
|
|
52
|
+
}
|
|
53
|
+
return r;
|
|
54
|
+
}
|
|
55
|
+
const bn = {};
|
|
56
|
+
function xn(t) {
|
|
57
|
+
return bn[t];
|
|
58
|
+
}
|
|
59
|
+
function tr(t, e, r) {
|
|
60
|
+
typeof r.value == "object" && (r.value = R(r.value)), !r.enumerable || r.get || r.set || !r.configurable || !r.writable || e === "__proto__" ? Object.defineProperty(t, e, r) : t[e] = r.value;
|
|
61
|
+
}
|
|
62
|
+
function R(t) {
|
|
63
|
+
if (typeof t != "object") return t;
|
|
64
|
+
var e = 0, r, n, a, i = Object.prototype.toString.call(t);
|
|
65
|
+
if (i === "[object Object]" ? a = Object.create(t.__proto__ || null) : i === "[object Array]" ? a = Array(t.length) : i === "[object Set]" ? (a = /* @__PURE__ */ new Set(), t.forEach(function(s) {
|
|
66
|
+
a.add(R(s));
|
|
67
|
+
})) : i === "[object Map]" ? (a = /* @__PURE__ */ new Map(), t.forEach(function(s, o) {
|
|
68
|
+
a.set(R(o), R(s));
|
|
69
|
+
})) : i === "[object Date]" ? a = /* @__PURE__ */ new Date(+t) : i === "[object RegExp]" ? a = new RegExp(t.source, t.flags) : i === "[object DataView]" ? a = new t.constructor(R(t.buffer)) : i === "[object ArrayBuffer]" ? a = t.slice(0) : i.slice(-6) === "Array]" && (a = new t.constructor(t)), a) {
|
|
70
|
+
for (n = Object.getOwnPropertySymbols(t); e < n.length; e++)
|
|
71
|
+
tr(a, n[e], Object.getOwnPropertyDescriptor(t, n[e]));
|
|
72
|
+
for (e = 0, n = Object.getOwnPropertyNames(t); e < n.length; e++)
|
|
73
|
+
Object.hasOwnProperty.call(a, r = n[e]) && a[r] === t[r] || tr(a, r, Object.getOwnPropertyDescriptor(t, r));
|
|
74
|
+
}
|
|
75
|
+
return a || t;
|
|
76
|
+
}
|
|
77
|
+
const qt = /* @__PURE__ */ Symbol("vee-validate-form"), Ir = /* @__PURE__ */ Symbol("vee-validate-form-context"), kn = /* @__PURE__ */ Symbol("vee-validate-field-instance"), rr = /* @__PURE__ */ Symbol("Default empty value"), Rr = typeof window < "u";
|
|
78
|
+
function Ft(t) {
|
|
79
|
+
return ee(t) && !!t.__locatorRef;
|
|
80
|
+
}
|
|
81
|
+
function fe(t) {
|
|
82
|
+
return !!t && ee(t.parse) && t.__type === "VVTypedSchema";
|
|
83
|
+
}
|
|
84
|
+
function vt(t) {
|
|
85
|
+
return !!t && ee(t.validate);
|
|
86
|
+
}
|
|
87
|
+
function Pr(t) {
|
|
88
|
+
return t === "checkbox" || t === "radio";
|
|
89
|
+
}
|
|
90
|
+
function On(t) {
|
|
91
|
+
return Ae(t) || Array.isArray(t);
|
|
92
|
+
}
|
|
93
|
+
function wn(t) {
|
|
94
|
+
return Array.isArray(t) ? t.length === 0 : Ae(t) && Object.keys(t).length === 0;
|
|
95
|
+
}
|
|
96
|
+
function ot(t) {
|
|
97
|
+
return /^\[.+\]$/i.test(t);
|
|
98
|
+
}
|
|
99
|
+
function Sn(t) {
|
|
100
|
+
return Zr(t) && t.multiple;
|
|
101
|
+
}
|
|
102
|
+
function Zr(t) {
|
|
103
|
+
return t.tagName === "SELECT";
|
|
104
|
+
}
|
|
105
|
+
function Cn(t) {
|
|
106
|
+
return $r(t) && t.target && "submit" in t.target;
|
|
107
|
+
}
|
|
108
|
+
function $r(t) {
|
|
109
|
+
return t ? !!(typeof Event < "u" && ee(Event) && t instanceof Event || t && t.srcElement) : !1;
|
|
110
|
+
}
|
|
111
|
+
function Y(t, e) {
|
|
112
|
+
if (t === e)
|
|
113
|
+
return !0;
|
|
114
|
+
if (t && e && typeof t == "object" && typeof e == "object") {
|
|
115
|
+
if (t.constructor !== e.constructor)
|
|
116
|
+
return !1;
|
|
117
|
+
var r, n, a;
|
|
118
|
+
if (Array.isArray(t)) {
|
|
119
|
+
if (r = t.length, r != e.length)
|
|
120
|
+
return !1;
|
|
121
|
+
for (n = r; n-- !== 0; )
|
|
122
|
+
if (!Y(t[n], e[n]))
|
|
123
|
+
return !1;
|
|
124
|
+
return !0;
|
|
125
|
+
}
|
|
126
|
+
if (t instanceof Map && e instanceof Map) {
|
|
127
|
+
if (t.size !== e.size)
|
|
128
|
+
return !1;
|
|
129
|
+
for (n of t.entries())
|
|
130
|
+
if (!e.has(n[0]))
|
|
131
|
+
return !1;
|
|
132
|
+
for (n of t.entries())
|
|
133
|
+
if (!Y(n[1], e.get(n[0])))
|
|
134
|
+
return !1;
|
|
135
|
+
return !0;
|
|
136
|
+
}
|
|
137
|
+
if (ar(t) && ar(e))
|
|
138
|
+
return !(t.size !== e.size || t.name !== e.name || t.lastModified !== e.lastModified || t.type !== e.type);
|
|
139
|
+
if (t instanceof Set && e instanceof Set) {
|
|
140
|
+
if (t.size !== e.size)
|
|
141
|
+
return !1;
|
|
142
|
+
for (n of t.entries())
|
|
143
|
+
if (!e.has(n[0]))
|
|
144
|
+
return !1;
|
|
145
|
+
return !0;
|
|
146
|
+
}
|
|
147
|
+
if (ArrayBuffer.isView(t) && ArrayBuffer.isView(e)) {
|
|
148
|
+
if (r = t.length, r != e.length)
|
|
149
|
+
return !1;
|
|
150
|
+
for (n = r; n-- !== 0; )
|
|
151
|
+
if (t[n] !== e[n])
|
|
152
|
+
return !1;
|
|
153
|
+
return !0;
|
|
154
|
+
}
|
|
155
|
+
if (t.constructor === RegExp)
|
|
156
|
+
return t.source === e.source && t.flags === e.flags;
|
|
157
|
+
if (t.valueOf !== Object.prototype.valueOf)
|
|
158
|
+
return t.valueOf() === e.valueOf();
|
|
159
|
+
if (t.toString !== Object.prototype.toString)
|
|
160
|
+
return t.toString() === e.toString();
|
|
161
|
+
if (t = nr(t), e = nr(e), a = Object.keys(t), r = a.length, r !== Object.keys(e).length)
|
|
162
|
+
return !1;
|
|
163
|
+
for (n = r; n-- !== 0; )
|
|
164
|
+
if (!Object.prototype.hasOwnProperty.call(e, a[n]))
|
|
165
|
+
return !1;
|
|
166
|
+
for (n = r; n-- !== 0; ) {
|
|
167
|
+
var i = a[n];
|
|
168
|
+
if (!Y(t[i], e[i]))
|
|
169
|
+
return !1;
|
|
170
|
+
}
|
|
171
|
+
return !0;
|
|
172
|
+
}
|
|
173
|
+
return t !== t && e !== e;
|
|
174
|
+
}
|
|
175
|
+
function nr(t) {
|
|
176
|
+
return Object.fromEntries(Object.entries(t).filter(([, e]) => e !== void 0));
|
|
177
|
+
}
|
|
178
|
+
function ar(t) {
|
|
179
|
+
return Rr ? t instanceof File : !1;
|
|
180
|
+
}
|
|
181
|
+
function kt(t) {
|
|
182
|
+
return ot(t) ? t.replace(/\[|\]/gi, "") : t;
|
|
183
|
+
}
|
|
184
|
+
function te(t, e, r) {
|
|
185
|
+
return t ? ot(e) ? t[kt(e)] : (e || "").split(/\.|\[(\d+)\]/).filter(Boolean).reduce((a, i) => On(a) && i in a ? a[i] : r, t) : r;
|
|
186
|
+
}
|
|
187
|
+
function ve(t, e, r) {
|
|
188
|
+
if (ot(e)) {
|
|
189
|
+
t[kt(e)] = r;
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
const n = e.split(/\.|\[(\d+)\]/).filter(Boolean);
|
|
193
|
+
let a = t;
|
|
194
|
+
for (let i = 0; i < n.length; i++) {
|
|
195
|
+
if (i === n.length - 1) {
|
|
196
|
+
a[n[i]] = r;
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
(!(n[i] in a) || Nr(a[n[i]])) && (a[n[i]] = Wt(n[i + 1]) ? [] : {}), a = a[n[i]];
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
function Rt(t, e) {
|
|
203
|
+
if (Array.isArray(t) && Wt(e)) {
|
|
204
|
+
t.splice(Number(e), 1);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
Ae(t) && delete t[e];
|
|
208
|
+
}
|
|
209
|
+
function ir(t, e) {
|
|
210
|
+
if (ot(e)) {
|
|
211
|
+
delete t[kt(e)];
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
const r = e.split(/\.|\[(\d+)\]/).filter(Boolean);
|
|
215
|
+
let n = t;
|
|
216
|
+
for (let i = 0; i < r.length; i++) {
|
|
217
|
+
if (i === r.length - 1) {
|
|
218
|
+
Rt(n, r[i]);
|
|
219
|
+
break;
|
|
220
|
+
}
|
|
221
|
+
if (!(r[i] in n) || Nr(n[r[i]]))
|
|
222
|
+
break;
|
|
223
|
+
n = n[r[i]];
|
|
224
|
+
}
|
|
225
|
+
const a = r.map((i, s) => te(t, r.slice(0, s).join(".")));
|
|
226
|
+
for (let i = a.length - 1; i >= 0; i--)
|
|
227
|
+
if (wn(a[i])) {
|
|
228
|
+
if (i === 0) {
|
|
229
|
+
Rt(t, r[0]);
|
|
230
|
+
continue;
|
|
231
|
+
}
|
|
232
|
+
Rt(a[i - 1], r[i - 1]);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
function X(t) {
|
|
236
|
+
return Object.keys(t);
|
|
237
|
+
}
|
|
238
|
+
function Fr(t, e = void 0) {
|
|
239
|
+
const r = We();
|
|
240
|
+
return r?.provides[t] || Tr(t, e);
|
|
241
|
+
}
|
|
242
|
+
function An(t, e, r) {
|
|
243
|
+
if (Array.isArray(t)) {
|
|
244
|
+
const n = [...t], a = n.findIndex((i) => Y(i, e));
|
|
245
|
+
return a >= 0 ? n.splice(a, 1) : n.push(e), n;
|
|
246
|
+
}
|
|
247
|
+
return Y(t, e) ? r : e;
|
|
248
|
+
}
|
|
249
|
+
function jn(t, e) {
|
|
250
|
+
let r, n;
|
|
251
|
+
return function(...a) {
|
|
252
|
+
const i = this;
|
|
253
|
+
return r || (r = !0, setTimeout(() => r = !1, e), n = t.apply(i, a)), n;
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
function sr(t, e = 0) {
|
|
257
|
+
let r = null, n = [];
|
|
258
|
+
return function(...a) {
|
|
259
|
+
return r && clearTimeout(r), r = setTimeout(() => {
|
|
260
|
+
const i = t(...a);
|
|
261
|
+
n.forEach((s) => s(i)), n = [];
|
|
262
|
+
}, e), new Promise((i) => n.push(i));
|
|
263
|
+
};
|
|
264
|
+
}
|
|
265
|
+
function Vn(t, e) {
|
|
266
|
+
return Ae(e) && e.number ? yn(t) : t;
|
|
267
|
+
}
|
|
268
|
+
function Mt(t, e) {
|
|
269
|
+
let r;
|
|
270
|
+
return async function(...a) {
|
|
271
|
+
const i = t(...a);
|
|
272
|
+
r = i;
|
|
273
|
+
const s = await i;
|
|
274
|
+
return i !== r ? s : (r = void 0, e(s, a));
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
function Dt(t) {
|
|
278
|
+
return Array.isArray(t) ? t : t ? [t] : [];
|
|
279
|
+
}
|
|
280
|
+
function dt(t, e) {
|
|
281
|
+
const r = {};
|
|
282
|
+
for (const n in t)
|
|
283
|
+
e.includes(n) || (r[n] = t[n]);
|
|
284
|
+
return r;
|
|
285
|
+
}
|
|
286
|
+
function Tn(t) {
|
|
287
|
+
let e = null, r = [];
|
|
288
|
+
return function(...n) {
|
|
289
|
+
const a = de(() => {
|
|
290
|
+
if (e !== a)
|
|
291
|
+
return;
|
|
292
|
+
const i = t(...n);
|
|
293
|
+
r.forEach((s) => s(i)), r = [], e = null;
|
|
294
|
+
});
|
|
295
|
+
return e = a, new Promise((i) => r.push(i));
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
function Pt(t) {
|
|
299
|
+
if (Mr(t))
|
|
300
|
+
return t._value;
|
|
301
|
+
}
|
|
302
|
+
function Mr(t) {
|
|
303
|
+
return "_value" in t;
|
|
304
|
+
}
|
|
305
|
+
function En(t) {
|
|
306
|
+
return t.type === "number" || t.type === "range" ? Number.isNaN(t.valueAsNumber) ? t.value : t.valueAsNumber : t.value;
|
|
307
|
+
}
|
|
308
|
+
function mt(t) {
|
|
309
|
+
if (!$r(t))
|
|
310
|
+
return t;
|
|
311
|
+
const e = t.target;
|
|
312
|
+
if (Pr(e.type) && Mr(e))
|
|
313
|
+
return Pt(e);
|
|
314
|
+
if (e.type === "file" && e.files) {
|
|
315
|
+
const r = Array.from(e.files);
|
|
316
|
+
return e.multiple ? r : r[0];
|
|
317
|
+
}
|
|
318
|
+
if (Sn(e))
|
|
319
|
+
return Array.from(e.options).filter((r) => r.selected && !r.disabled).map(Pt);
|
|
320
|
+
if (Zr(e)) {
|
|
321
|
+
const r = Array.from(e.options).find((n) => n.selected);
|
|
322
|
+
return r ? Pt(r) : e.value;
|
|
323
|
+
}
|
|
324
|
+
return En(e);
|
|
325
|
+
}
|
|
326
|
+
function Dr(t) {
|
|
327
|
+
const e = {};
|
|
328
|
+
return Object.defineProperty(e, "_$$isNormalized", {
|
|
329
|
+
value: !0,
|
|
330
|
+
writable: !1,
|
|
331
|
+
enumerable: !1,
|
|
332
|
+
configurable: !1
|
|
333
|
+
}), t ? Ae(t) && t._$$isNormalized ? t : Ae(t) ? Object.keys(t).reduce((r, n) => {
|
|
334
|
+
const a = Nn(t[n]);
|
|
335
|
+
return t[n] !== !1 && (r[n] = or(a)), r;
|
|
336
|
+
}, e) : typeof t != "string" ? e : t.split("|").reduce((r, n) => {
|
|
337
|
+
const a = In(n);
|
|
338
|
+
return a.name && (r[a.name] = or(a.params)), r;
|
|
339
|
+
}, e) : e;
|
|
340
|
+
}
|
|
341
|
+
function Nn(t) {
|
|
342
|
+
return t === !0 ? [] : Array.isArray(t) || Ae(t) ? t : [t];
|
|
343
|
+
}
|
|
344
|
+
function or(t) {
|
|
345
|
+
const e = (r) => typeof r == "string" && r[0] === "@" ? Rn(r.slice(1)) : r;
|
|
346
|
+
return Array.isArray(t) ? t.map(e) : t instanceof RegExp ? [t] : Object.keys(t).reduce((r, n) => (r[n] = e(t[n]), r), {});
|
|
347
|
+
}
|
|
348
|
+
const In = (t) => {
|
|
349
|
+
let e = [];
|
|
350
|
+
const r = t.split(":")[0];
|
|
351
|
+
return t.includes(":") && (e = t.split(":").slice(1).join(":").split(",")), { name: r, params: e };
|
|
352
|
+
};
|
|
353
|
+
function Rn(t) {
|
|
354
|
+
const e = (r) => {
|
|
355
|
+
var n;
|
|
356
|
+
return (n = te(r, t)) !== null && n !== void 0 ? n : r[t];
|
|
357
|
+
};
|
|
358
|
+
return e.__locatorRef = t, e;
|
|
359
|
+
}
|
|
360
|
+
function Pn(t) {
|
|
361
|
+
return Array.isArray(t) ? t.filter(Ft) : X(t).filter((e) => Ft(t[e])).map((e) => t[e]);
|
|
362
|
+
}
|
|
363
|
+
const Zn = {
|
|
364
|
+
generateMessage: ({ field: t }) => `${t} is not valid.`,
|
|
365
|
+
bails: !0,
|
|
366
|
+
validateOnBlur: !0,
|
|
367
|
+
validateOnChange: !0,
|
|
368
|
+
validateOnInput: !1,
|
|
369
|
+
validateOnModelUpdate: !0
|
|
370
|
+
};
|
|
371
|
+
let $n = Object.assign({}, Zn);
|
|
372
|
+
const et = () => $n;
|
|
373
|
+
async function Lr(t, e, r = {}) {
|
|
374
|
+
const n = r?.bails, a = {
|
|
375
|
+
name: r?.name || "{field}",
|
|
376
|
+
rules: e,
|
|
377
|
+
label: r?.label,
|
|
378
|
+
bails: n ?? !0,
|
|
379
|
+
formData: r?.values || {}
|
|
380
|
+
}, i = await Fn(a, t);
|
|
381
|
+
return Object.assign(Object.assign({}, i), { valid: !i.errors.length });
|
|
382
|
+
}
|
|
383
|
+
async function Fn(t, e) {
|
|
384
|
+
const r = t.rules;
|
|
385
|
+
if (fe(r) || vt(r))
|
|
386
|
+
return Dn(e, Object.assign(Object.assign({}, t), { rules: r }));
|
|
387
|
+
if (ee(r) || Array.isArray(r)) {
|
|
388
|
+
const o = {
|
|
389
|
+
field: t.label || t.name,
|
|
390
|
+
name: t.name,
|
|
391
|
+
label: t.label,
|
|
392
|
+
form: t.formData,
|
|
393
|
+
value: e
|
|
394
|
+
}, c = Array.isArray(r) ? r : [r], d = c.length, v = [];
|
|
395
|
+
for (let S = 0; S < d; S++) {
|
|
396
|
+
const I = c[S], j = await I(e, o);
|
|
397
|
+
if (!(typeof j != "string" && !Array.isArray(j) && j)) {
|
|
398
|
+
if (Array.isArray(j))
|
|
399
|
+
v.push(...j);
|
|
400
|
+
else {
|
|
401
|
+
const ne = typeof j == "string" ? j : zr(o);
|
|
402
|
+
v.push(ne);
|
|
403
|
+
}
|
|
404
|
+
if (t.bails)
|
|
405
|
+
return {
|
|
406
|
+
errors: v
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return {
|
|
411
|
+
errors: v
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
const n = Object.assign(Object.assign({}, t), { rules: Dr(r) }), a = [], i = Object.keys(n.rules), s = i.length;
|
|
415
|
+
for (let o = 0; o < s; o++) {
|
|
416
|
+
const c = i[o], d = await Ln(n, e, {
|
|
417
|
+
name: c,
|
|
418
|
+
params: n.rules[c]
|
|
419
|
+
});
|
|
420
|
+
if (d.error && (a.push(d.error), t.bails))
|
|
421
|
+
return {
|
|
422
|
+
errors: a
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
return {
|
|
426
|
+
errors: a
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
function Mn(t) {
|
|
430
|
+
return !!t && t.name === "ValidationError";
|
|
431
|
+
}
|
|
432
|
+
function Ur(t) {
|
|
433
|
+
return {
|
|
434
|
+
__type: "VVTypedSchema",
|
|
435
|
+
async parse(r, n) {
|
|
436
|
+
var a;
|
|
437
|
+
try {
|
|
438
|
+
return {
|
|
439
|
+
output: await t.validate(r, { abortEarly: !1, context: n?.formData || {} }),
|
|
440
|
+
errors: []
|
|
441
|
+
};
|
|
442
|
+
} catch (i) {
|
|
443
|
+
if (!Mn(i))
|
|
444
|
+
throw i;
|
|
445
|
+
if (!(!((a = i.inner) === null || a === void 0) && a.length) && i.errors.length)
|
|
446
|
+
return { errors: [{ path: i.path, errors: i.errors }] };
|
|
447
|
+
const s = i.inner.reduce((o, c) => {
|
|
448
|
+
const d = c.path || "";
|
|
449
|
+
return o[d] || (o[d] = { errors: [], path: d }), o[d].errors.push(...c.errors), o;
|
|
450
|
+
}, {});
|
|
451
|
+
return { errors: Object.values(s) };
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
async function Dn(t, e) {
|
|
457
|
+
const n = await (fe(e.rules) ? e.rules : Ur(e.rules)).parse(t, { formData: e.formData }), a = [];
|
|
458
|
+
for (const i of n.errors)
|
|
459
|
+
i.errors.length && a.push(...i.errors);
|
|
460
|
+
return {
|
|
461
|
+
value: n.value,
|
|
462
|
+
errors: a
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
async function Ln(t, e, r) {
|
|
466
|
+
const n = xn(r.name);
|
|
467
|
+
if (!n)
|
|
468
|
+
throw new Error(`No such validator '${r.name}' exists.`);
|
|
469
|
+
const a = Un(r.params, t.formData), i = {
|
|
470
|
+
field: t.label || t.name,
|
|
471
|
+
name: t.name,
|
|
472
|
+
label: t.label,
|
|
473
|
+
value: e,
|
|
474
|
+
form: t.formData,
|
|
475
|
+
rule: Object.assign(Object.assign({}, r), { params: a })
|
|
476
|
+
}, s = await n(e, a, i);
|
|
477
|
+
return typeof s == "string" ? {
|
|
478
|
+
error: s
|
|
479
|
+
} : {
|
|
480
|
+
error: s ? void 0 : zr(i)
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
function zr(t) {
|
|
484
|
+
const e = et().generateMessage;
|
|
485
|
+
return e ? e(t) : "Field is invalid";
|
|
486
|
+
}
|
|
487
|
+
function Un(t, e) {
|
|
488
|
+
const r = (n) => Ft(n) ? n(e) : n;
|
|
489
|
+
return Array.isArray(t) ? t.map(r) : Object.keys(t).reduce((n, a) => (n[a] = r(t[a]), n), {});
|
|
490
|
+
}
|
|
491
|
+
async function zn(t, e) {
|
|
492
|
+
const n = await (fe(t) ? t : Ur(t)).parse(R(e), { formData: R(e) }), a = {}, i = {};
|
|
493
|
+
for (const s of n.errors) {
|
|
494
|
+
const o = s.errors, c = (s.path || "").replace(/\["(\d+)"\]/g, (d, v) => `[${v}]`);
|
|
495
|
+
a[c] = { valid: !o.length, errors: o }, o.length && (i[c] = o[0]);
|
|
496
|
+
}
|
|
497
|
+
return {
|
|
498
|
+
valid: !n.errors.length,
|
|
499
|
+
results: a,
|
|
500
|
+
errors: i,
|
|
501
|
+
values: n.value,
|
|
502
|
+
source: "schema"
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
async function Bn(t, e, r) {
|
|
506
|
+
const a = X(t).map(async (d) => {
|
|
507
|
+
var v, S, I;
|
|
508
|
+
const j = (v = r?.names) === null || v === void 0 ? void 0 : v[d], U = await Lr(te(e, d), t[d], {
|
|
509
|
+
name: j?.name || d,
|
|
510
|
+
label: j?.label,
|
|
511
|
+
values: e,
|
|
512
|
+
bails: (I = (S = r?.bailsMap) === null || S === void 0 ? void 0 : S[d]) !== null && I !== void 0 ? I : !0
|
|
513
|
+
});
|
|
514
|
+
return Object.assign(Object.assign({}, U), { path: d });
|
|
515
|
+
});
|
|
516
|
+
let i = !0;
|
|
517
|
+
const s = await Promise.all(a), o = {}, c = {};
|
|
518
|
+
for (const d of s)
|
|
519
|
+
o[d.path] = {
|
|
520
|
+
valid: d.valid,
|
|
521
|
+
errors: d.errors
|
|
522
|
+
}, d.valid || (i = !1, c[d.path] = d.errors[0]);
|
|
523
|
+
return {
|
|
524
|
+
valid: i,
|
|
525
|
+
results: o,
|
|
526
|
+
errors: c,
|
|
527
|
+
source: "schema"
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
let ur = 0;
|
|
531
|
+
function Wn(t, e) {
|
|
532
|
+
const { value: r, initialValue: n, setInitialValue: a } = qn(t, e.modelValue, e.form);
|
|
533
|
+
if (!e.form) {
|
|
534
|
+
let I = function(j) {
|
|
535
|
+
var U;
|
|
536
|
+
"value" in j && (r.value = j.value), "errors" in j && d(j.errors), "touched" in j && (S.touched = (U = j.touched) !== null && U !== void 0 ? U : S.touched), "initialValue" in j && a(j.initialValue);
|
|
537
|
+
};
|
|
538
|
+
const { errors: c, setErrors: d } = Gn(), v = ur >= Number.MAX_SAFE_INTEGER ? 0 : ++ur, S = Jn(r, n, c, e.schema);
|
|
539
|
+
return {
|
|
540
|
+
id: v,
|
|
541
|
+
path: t,
|
|
542
|
+
value: r,
|
|
543
|
+
initialValue: n,
|
|
544
|
+
meta: S,
|
|
545
|
+
flags: { pendingUnmount: { [v]: !1 }, pendingReset: !1 },
|
|
546
|
+
errors: c,
|
|
547
|
+
setState: I
|
|
548
|
+
};
|
|
549
|
+
}
|
|
550
|
+
const i = e.form.createPathState(t, {
|
|
551
|
+
bails: e.bails,
|
|
552
|
+
label: e.label,
|
|
553
|
+
type: e.type,
|
|
554
|
+
validate: e.validate,
|
|
555
|
+
schema: e.schema
|
|
556
|
+
}), s = Z(() => i.errors);
|
|
557
|
+
function o(c) {
|
|
558
|
+
var d, v, S;
|
|
559
|
+
"value" in c && (r.value = c.value), "errors" in c && ((d = e.form) === null || d === void 0 || d.setFieldError($(t), c.errors)), "touched" in c && ((v = e.form) === null || v === void 0 || v.setFieldTouched($(t), (S = c.touched) !== null && S !== void 0 ? S : !1)), "initialValue" in c && a(c.initialValue);
|
|
560
|
+
}
|
|
561
|
+
return {
|
|
562
|
+
id: Array.isArray(i.id) ? i.id[i.id.length - 1] : i.id,
|
|
563
|
+
path: t,
|
|
564
|
+
value: r,
|
|
565
|
+
errors: s,
|
|
566
|
+
meta: i,
|
|
567
|
+
initialValue: n,
|
|
568
|
+
flags: i.__flags,
|
|
569
|
+
setState: o
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function qn(t, e, r) {
|
|
573
|
+
const n = ce($(e));
|
|
574
|
+
function a() {
|
|
575
|
+
return r ? te(r.initialValues.value, $(t), $(n)) : $(n);
|
|
576
|
+
}
|
|
577
|
+
function i(d) {
|
|
578
|
+
if (!r) {
|
|
579
|
+
n.value = d;
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
r.setFieldInitialValue($(t), d, !0);
|
|
583
|
+
}
|
|
584
|
+
const s = Z(a);
|
|
585
|
+
if (!r)
|
|
586
|
+
return {
|
|
587
|
+
value: ce(a()),
|
|
588
|
+
initialValue: s,
|
|
589
|
+
setInitialValue: i
|
|
590
|
+
};
|
|
591
|
+
const o = Hn(e, r, s, t);
|
|
592
|
+
return r.stageInitialValue($(t), o, !0), {
|
|
593
|
+
value: Z({
|
|
594
|
+
get() {
|
|
595
|
+
return te(r.values, $(t));
|
|
596
|
+
},
|
|
597
|
+
set(d) {
|
|
598
|
+
r.setFieldValue($(t), d, !1);
|
|
599
|
+
}
|
|
600
|
+
}),
|
|
601
|
+
initialValue: s,
|
|
602
|
+
setInitialValue: i
|
|
603
|
+
};
|
|
604
|
+
}
|
|
605
|
+
function Hn(t, e, r, n) {
|
|
606
|
+
return ht(t) ? $(t) : t !== void 0 ? t : te(e.values, $(n), $(r));
|
|
607
|
+
}
|
|
608
|
+
function Jn(t, e, r, n) {
|
|
609
|
+
const a = Z(() => {
|
|
610
|
+
var s, o, c;
|
|
611
|
+
return (c = (o = (s = b(n)) === null || s === void 0 ? void 0 : s.describe) === null || o === void 0 ? void 0 : o.call(s).required) !== null && c !== void 0 ? c : !1;
|
|
612
|
+
}), i = ft({
|
|
613
|
+
touched: !1,
|
|
614
|
+
pending: !1,
|
|
615
|
+
valid: !0,
|
|
616
|
+
required: a,
|
|
617
|
+
validated: !!$(r).length,
|
|
618
|
+
initialValue: Z(() => $(e)),
|
|
619
|
+
dirty: Z(() => !Y($(t), $(e)))
|
|
620
|
+
});
|
|
621
|
+
return be(r, (s) => {
|
|
622
|
+
i.valid = !s.length;
|
|
623
|
+
}, {
|
|
624
|
+
immediate: !0,
|
|
625
|
+
flush: "sync"
|
|
626
|
+
}), i;
|
|
627
|
+
}
|
|
628
|
+
function Gn() {
|
|
629
|
+
const t = ce([]);
|
|
630
|
+
return {
|
|
631
|
+
errors: t,
|
|
632
|
+
setErrors: (e) => {
|
|
633
|
+
t.value = Dt(e);
|
|
634
|
+
}
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
const rt = {}, nt = {}, at = "vee-validate-inspector", Q = {
|
|
638
|
+
error: 12405579,
|
|
639
|
+
success: 448379,
|
|
640
|
+
unknown: 5522283,
|
|
641
|
+
white: 16777215,
|
|
642
|
+
black: 0,
|
|
643
|
+
blue: 218007,
|
|
644
|
+
purple: 12157168,
|
|
645
|
+
orange: 16099682,
|
|
646
|
+
gray: 12304330
|
|
647
|
+
};
|
|
648
|
+
let B = null, ge;
|
|
649
|
+
async function Br(t) {
|
|
650
|
+
if (process.env.NODE_ENV !== "production") {
|
|
651
|
+
if (!Rr)
|
|
652
|
+
return;
|
|
653
|
+
(await import("./index-DyCHxFp3.mjs")).setupDevtoolsPlugin({
|
|
654
|
+
id: "vee-validate-devtools-plugin",
|
|
655
|
+
label: "VeeValidate Plugin",
|
|
656
|
+
packageName: "vee-validate",
|
|
657
|
+
homepage: "https://vee-validate.logaretm.com/v4",
|
|
658
|
+
app: t,
|
|
659
|
+
logo: "https://vee-validate.logaretm.com/v4/logo.png"
|
|
660
|
+
}, (r) => {
|
|
661
|
+
ge = r, r.addInspector({
|
|
662
|
+
id: at,
|
|
663
|
+
icon: "rule",
|
|
664
|
+
label: "vee-validate",
|
|
665
|
+
noSelectionText: "Select a vee-validate node to inspect",
|
|
666
|
+
actions: [
|
|
667
|
+
{
|
|
668
|
+
icon: "done_outline",
|
|
669
|
+
tooltip: "Validate selected item",
|
|
670
|
+
action: async () => {
|
|
671
|
+
if (!B) {
|
|
672
|
+
console.error("There is not a valid selected vee-validate node or component");
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (B.type === "field") {
|
|
676
|
+
await B.field.validate();
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
if (B.type === "form") {
|
|
680
|
+
await B.form.validate();
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
B.type === "pathState" && await B.form.validateField(B.state.path);
|
|
684
|
+
}
|
|
685
|
+
},
|
|
686
|
+
{
|
|
687
|
+
icon: "delete_sweep",
|
|
688
|
+
tooltip: "Clear validation state of the selected item",
|
|
689
|
+
action: () => {
|
|
690
|
+
if (!B) {
|
|
691
|
+
console.error("There is not a valid selected vee-validate node or component");
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
if (B.type === "field") {
|
|
695
|
+
B.field.resetField();
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
B.type === "form" && B.form.resetForm(), B.type === "pathState" && B.form.resetField(B.state.path);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
]
|
|
702
|
+
}), r.on.getInspectorTree((n) => {
|
|
703
|
+
if (n.inspectorId !== at)
|
|
704
|
+
return;
|
|
705
|
+
const a = Object.values(rt), i = Object.values(nt);
|
|
706
|
+
n.rootNodes = [
|
|
707
|
+
...a.map(Xn),
|
|
708
|
+
...i.map((s) => ea(s))
|
|
709
|
+
];
|
|
710
|
+
}), r.on.getInspectorState((n) => {
|
|
711
|
+
if (n.inspectorId !== at)
|
|
712
|
+
return;
|
|
713
|
+
const { form: a, field: i, state: s, type: o } = ta(n.nodeId);
|
|
714
|
+
if (r.unhighlightElement(), a && o === "form") {
|
|
715
|
+
n.state = ra(a), B = { type: "form", form: a }, r.highlightElement(a._vm);
|
|
716
|
+
return;
|
|
717
|
+
}
|
|
718
|
+
if (s && o === "pathState" && a) {
|
|
719
|
+
n.state = lr(s), B = { type: "pathState", state: s, form: a };
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
if (i && o === "field") {
|
|
723
|
+
n.state = lr({
|
|
724
|
+
errors: i.errors.value,
|
|
725
|
+
dirty: i.meta.dirty,
|
|
726
|
+
valid: i.meta.valid,
|
|
727
|
+
touched: i.meta.touched,
|
|
728
|
+
value: i.value.value,
|
|
729
|
+
initialValue: i.meta.initialValue
|
|
730
|
+
}), B = { field: i, type: "field" }, r.highlightElement(i._vm);
|
|
731
|
+
return;
|
|
732
|
+
}
|
|
733
|
+
B = null, r.unhighlightElement();
|
|
734
|
+
});
|
|
735
|
+
});
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
const qe = jn(() => {
|
|
739
|
+
setTimeout(async () => {
|
|
740
|
+
await de(), ge?.sendInspectorState(at), ge?.sendInspectorTree(at);
|
|
741
|
+
}, 100);
|
|
742
|
+
}, 100);
|
|
743
|
+
function Yn(t) {
|
|
744
|
+
const e = We();
|
|
745
|
+
if (!ge) {
|
|
746
|
+
const r = e?.appContext.app;
|
|
747
|
+
if (!r)
|
|
748
|
+
return;
|
|
749
|
+
Br(r);
|
|
750
|
+
}
|
|
751
|
+
rt[t.formId] = Object.assign({}, t), rt[t.formId]._vm = e, Er(() => {
|
|
752
|
+
delete rt[t.formId], qe();
|
|
753
|
+
}), qe();
|
|
754
|
+
}
|
|
755
|
+
function Kn(t) {
|
|
756
|
+
const e = We();
|
|
757
|
+
if (!ge) {
|
|
758
|
+
const r = e?.appContext.app;
|
|
759
|
+
if (!r)
|
|
760
|
+
return;
|
|
761
|
+
Br(r);
|
|
762
|
+
}
|
|
763
|
+
nt[t.id] = Object.assign({}, t), nt[t.id]._vm = e, Er(() => {
|
|
764
|
+
delete nt[t.id], qe();
|
|
765
|
+
}), qe();
|
|
766
|
+
}
|
|
767
|
+
function Xn(t) {
|
|
768
|
+
const { textColor: e, bgColor: r } = qr(t.meta.value.valid), n = {};
|
|
769
|
+
Object.values(t.getAllPathStates()).forEach((s) => {
|
|
770
|
+
ve(n, b(s.path), Qn(s, t));
|
|
771
|
+
});
|
|
772
|
+
function a(s, o = []) {
|
|
773
|
+
const c = [...o].pop();
|
|
774
|
+
return "id" in s ? Object.assign(Object.assign({}, s), { label: c || s.label }) : Ae(s) ? {
|
|
775
|
+
id: `${o.join(".")}`,
|
|
776
|
+
label: c || "",
|
|
777
|
+
children: Object.keys(s).map((d) => a(s[d], [...o, d]))
|
|
778
|
+
} : Array.isArray(s) ? {
|
|
779
|
+
id: `${o.join(".")}`,
|
|
780
|
+
label: `${c}[]`,
|
|
781
|
+
children: s.map((d, v) => a(d, [...o, String(v)]))
|
|
782
|
+
} : { id: "", label: "", children: [] };
|
|
783
|
+
}
|
|
784
|
+
const { children: i } = a(n);
|
|
785
|
+
return {
|
|
786
|
+
id: Ht(t),
|
|
787
|
+
label: t.name,
|
|
788
|
+
children: i,
|
|
789
|
+
tags: [
|
|
790
|
+
{
|
|
791
|
+
label: "Form",
|
|
792
|
+
textColor: e,
|
|
793
|
+
backgroundColor: r
|
|
794
|
+
},
|
|
795
|
+
{
|
|
796
|
+
label: `${t.getAllPathStates().length} fields`,
|
|
797
|
+
textColor: Q.white,
|
|
798
|
+
backgroundColor: Q.unknown
|
|
799
|
+
}
|
|
800
|
+
]
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
function Qn(t, e) {
|
|
804
|
+
return {
|
|
805
|
+
id: Ht(e, t),
|
|
806
|
+
label: b(t.path),
|
|
807
|
+
tags: Wr(t.multiple, t.fieldsCount, t.type, t.valid, e)
|
|
808
|
+
};
|
|
809
|
+
}
|
|
810
|
+
function ea(t, e) {
|
|
811
|
+
return {
|
|
812
|
+
id: Ht(e, t),
|
|
813
|
+
label: $(t.name),
|
|
814
|
+
tags: Wr(!1, 1, t.type, t.meta.valid, e)
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
function Wr(t, e, r, n, a) {
|
|
818
|
+
const { textColor: i, bgColor: s } = qr(n);
|
|
819
|
+
return [
|
|
820
|
+
t ? void 0 : {
|
|
821
|
+
label: "Field",
|
|
822
|
+
textColor: i,
|
|
823
|
+
backgroundColor: s
|
|
824
|
+
},
|
|
825
|
+
a ? void 0 : {
|
|
826
|
+
label: "Standalone",
|
|
827
|
+
textColor: Q.black,
|
|
828
|
+
backgroundColor: Q.gray
|
|
829
|
+
},
|
|
830
|
+
r === "checkbox" ? {
|
|
831
|
+
label: "Checkbox",
|
|
832
|
+
textColor: Q.white,
|
|
833
|
+
backgroundColor: Q.blue
|
|
834
|
+
} : void 0,
|
|
835
|
+
r === "radio" ? {
|
|
836
|
+
label: "Radio",
|
|
837
|
+
textColor: Q.white,
|
|
838
|
+
backgroundColor: Q.purple
|
|
839
|
+
} : void 0,
|
|
840
|
+
t ? {
|
|
841
|
+
label: "Multiple",
|
|
842
|
+
textColor: Q.black,
|
|
843
|
+
backgroundColor: Q.orange
|
|
844
|
+
} : void 0
|
|
845
|
+
].filter(Boolean);
|
|
846
|
+
}
|
|
847
|
+
function Ht(t, e) {
|
|
848
|
+
const r = e ? "path" in e ? "pathState" : "field" : "form", n = e ? "path" in e ? e?.path : b(e?.name) : "", a = { f: t?.formId, ff: e?.id || n, type: r };
|
|
849
|
+
return btoa(encodeURIComponent(JSON.stringify(a)));
|
|
850
|
+
}
|
|
851
|
+
function ta(t) {
|
|
852
|
+
try {
|
|
853
|
+
const e = JSON.parse(decodeURIComponent(atob(t))), r = rt[e.f];
|
|
854
|
+
if (!r && e.ff) {
|
|
855
|
+
const a = nt[e.ff];
|
|
856
|
+
return a ? {
|
|
857
|
+
type: e.type,
|
|
858
|
+
field: a
|
|
859
|
+
} : {};
|
|
860
|
+
}
|
|
861
|
+
if (!r)
|
|
862
|
+
return {};
|
|
863
|
+
const n = r.getPathState(e.ff);
|
|
864
|
+
return {
|
|
865
|
+
type: e.type,
|
|
866
|
+
form: r,
|
|
867
|
+
state: n
|
|
868
|
+
};
|
|
869
|
+
} catch {
|
|
870
|
+
}
|
|
871
|
+
return {};
|
|
872
|
+
}
|
|
873
|
+
function lr(t) {
|
|
874
|
+
return {
|
|
875
|
+
"Field state": [
|
|
876
|
+
{ key: "errors", value: t.errors },
|
|
877
|
+
{
|
|
878
|
+
key: "initialValue",
|
|
879
|
+
value: t.initialValue
|
|
880
|
+
},
|
|
881
|
+
{
|
|
882
|
+
key: "currentValue",
|
|
883
|
+
value: t.value
|
|
884
|
+
},
|
|
885
|
+
{
|
|
886
|
+
key: "touched",
|
|
887
|
+
value: t.touched
|
|
888
|
+
},
|
|
889
|
+
{
|
|
890
|
+
key: "dirty",
|
|
891
|
+
value: t.dirty
|
|
892
|
+
},
|
|
893
|
+
{
|
|
894
|
+
key: "valid",
|
|
895
|
+
value: t.valid
|
|
896
|
+
}
|
|
897
|
+
]
|
|
898
|
+
};
|
|
899
|
+
}
|
|
900
|
+
function ra(t) {
|
|
901
|
+
const { errorBag: e, meta: r, values: n, isSubmitting: a, isValidating: i, submitCount: s } = t;
|
|
902
|
+
return {
|
|
903
|
+
"Form state": [
|
|
904
|
+
{
|
|
905
|
+
key: "submitCount",
|
|
906
|
+
value: s.value
|
|
907
|
+
},
|
|
908
|
+
{
|
|
909
|
+
key: "isSubmitting",
|
|
910
|
+
value: a.value
|
|
911
|
+
},
|
|
912
|
+
{
|
|
913
|
+
key: "isValidating",
|
|
914
|
+
value: i.value
|
|
915
|
+
},
|
|
916
|
+
{
|
|
917
|
+
key: "touched",
|
|
918
|
+
value: r.value.touched
|
|
919
|
+
},
|
|
920
|
+
{
|
|
921
|
+
key: "dirty",
|
|
922
|
+
value: r.value.dirty
|
|
923
|
+
},
|
|
924
|
+
{
|
|
925
|
+
key: "valid",
|
|
926
|
+
value: r.value.valid
|
|
927
|
+
},
|
|
928
|
+
{
|
|
929
|
+
key: "initialValues",
|
|
930
|
+
value: r.value.initialValues
|
|
931
|
+
},
|
|
932
|
+
{
|
|
933
|
+
key: "currentValues",
|
|
934
|
+
value: n
|
|
935
|
+
},
|
|
936
|
+
{
|
|
937
|
+
key: "errors",
|
|
938
|
+
value: X(e.value).reduce((o, c) => {
|
|
939
|
+
var d;
|
|
940
|
+
const v = (d = e.value[c]) === null || d === void 0 ? void 0 : d[0];
|
|
941
|
+
return v && (o[c] = v), o;
|
|
942
|
+
}, {})
|
|
943
|
+
}
|
|
944
|
+
]
|
|
945
|
+
};
|
|
946
|
+
}
|
|
947
|
+
function qr(t) {
|
|
948
|
+
return {
|
|
949
|
+
bgColor: t ? Q.success : Q.error,
|
|
950
|
+
textColor: t ? Q.black : Q.white
|
|
951
|
+
};
|
|
952
|
+
}
|
|
953
|
+
function Ua(t, e, r) {
|
|
954
|
+
return Pr(void 0) ? aa(t, e) : Hr(t, e);
|
|
955
|
+
}
|
|
956
|
+
function Hr(t, e, r) {
|
|
957
|
+
const { initialValue: n, validateOnMount: a, bails: i, type: s, checkedValue: o, label: c, validateOnValueUpdate: d, uncheckedValue: v, controlled: S, keepValueOnUnmount: I, syncVModel: j, form: U } = na(), ne = S ? Fr(qt) : void 0, T = U || ne, ae = Z(() => Qe(b(t))), le = Z(() => {
|
|
958
|
+
if (b(T?.schema))
|
|
959
|
+
return;
|
|
960
|
+
const A = $(e);
|
|
961
|
+
return vt(A) || fe(A) || ee(A) || Array.isArray(A) ? A : Dr(A);
|
|
962
|
+
}), Ot = !ee(le.value) && fe(b(e)), { id: Me, value: Te, initialValue: Ee, meta: W, setState: De, errors: Le, flags: Ne } = Wn(ae, {
|
|
963
|
+
modelValue: n,
|
|
964
|
+
form: T,
|
|
965
|
+
bails: i,
|
|
966
|
+
label: c,
|
|
967
|
+
type: s,
|
|
968
|
+
validate: le.value ? Oe : void 0,
|
|
969
|
+
schema: Ot ? e : void 0
|
|
970
|
+
}), ie = Z(() => Le.value[0]);
|
|
971
|
+
j && ia({
|
|
972
|
+
value: Te,
|
|
973
|
+
prop: j,
|
|
974
|
+
handleChange: q,
|
|
975
|
+
shouldValidate: () => d && !Ne.pendingReset
|
|
976
|
+
});
|
|
977
|
+
const Ue = (_, A = !1) => {
|
|
978
|
+
W.touched = !0, A && ke();
|
|
979
|
+
};
|
|
980
|
+
async function ut(_) {
|
|
981
|
+
var A, F;
|
|
982
|
+
if (T?.validateSchema) {
|
|
983
|
+
const { results: P } = await T.validateSchema(_);
|
|
984
|
+
return (A = P[b(ae)]) !== null && A !== void 0 ? A : { valid: !0, errors: [] };
|
|
985
|
+
}
|
|
986
|
+
return le.value ? Lr(Te.value, le.value, {
|
|
987
|
+
name: b(ae),
|
|
988
|
+
label: b(c),
|
|
989
|
+
values: (F = T?.values) !== null && F !== void 0 ? F : {},
|
|
990
|
+
bails: i
|
|
991
|
+
}) : { valid: !0, errors: [] };
|
|
992
|
+
}
|
|
993
|
+
const ke = Mt(async () => (W.pending = !0, W.validated = !0, ut("validated-only")), (_) => (Ne.pendingUnmount[H.id] || (De({ errors: _.errors }), W.pending = !1, W.valid = _.valid), _)), pe = Mt(async () => ut("silent"), (_) => (W.valid = _.valid, _));
|
|
994
|
+
function Oe(_) {
|
|
995
|
+
return _?.mode === "silent" ? pe() : ke();
|
|
996
|
+
}
|
|
997
|
+
function q(_, A = !0) {
|
|
998
|
+
const F = mt(_);
|
|
999
|
+
Ke(F, A);
|
|
1000
|
+
}
|
|
1001
|
+
Vr(() => {
|
|
1002
|
+
if (a)
|
|
1003
|
+
return ke();
|
|
1004
|
+
(!T || !T.validateSchema) && pe();
|
|
1005
|
+
});
|
|
1006
|
+
function wt(_) {
|
|
1007
|
+
W.touched = _;
|
|
1008
|
+
}
|
|
1009
|
+
function we(_) {
|
|
1010
|
+
var A;
|
|
1011
|
+
const F = _ && "value" in _ ? _.value : Ee.value;
|
|
1012
|
+
De({
|
|
1013
|
+
value: R(F),
|
|
1014
|
+
initialValue: R(F),
|
|
1015
|
+
touched: (A = _?.touched) !== null && A !== void 0 ? A : !1,
|
|
1016
|
+
errors: _?.errors || []
|
|
1017
|
+
}), W.pending = !1, W.validated = !1, pe();
|
|
1018
|
+
}
|
|
1019
|
+
const Ie = We();
|
|
1020
|
+
function Ke(_, A = !0) {
|
|
1021
|
+
Te.value = Ie && j ? Vn(_, Ie.props.modelModifiers) : _, (A ? ke : pe)();
|
|
1022
|
+
}
|
|
1023
|
+
function lt(_) {
|
|
1024
|
+
De({ errors: Array.isArray(_) ? _ : [_] });
|
|
1025
|
+
}
|
|
1026
|
+
const Gt = Z({
|
|
1027
|
+
get() {
|
|
1028
|
+
return Te.value;
|
|
1029
|
+
},
|
|
1030
|
+
set(_) {
|
|
1031
|
+
Ke(_, d);
|
|
1032
|
+
}
|
|
1033
|
+
}), H = {
|
|
1034
|
+
id: Me,
|
|
1035
|
+
name: ae,
|
|
1036
|
+
label: c,
|
|
1037
|
+
value: Gt,
|
|
1038
|
+
meta: W,
|
|
1039
|
+
errors: Le,
|
|
1040
|
+
errorMessage: ie,
|
|
1041
|
+
type: s,
|
|
1042
|
+
checkedValue: o,
|
|
1043
|
+
uncheckedValue: v,
|
|
1044
|
+
bails: i,
|
|
1045
|
+
keepValueOnUnmount: I,
|
|
1046
|
+
resetField: we,
|
|
1047
|
+
handleReset: () => we(),
|
|
1048
|
+
validate: Oe,
|
|
1049
|
+
handleChange: q,
|
|
1050
|
+
handleBlur: Ue,
|
|
1051
|
+
setState: De,
|
|
1052
|
+
setTouched: wt,
|
|
1053
|
+
setErrors: lt,
|
|
1054
|
+
setValue: Ke
|
|
1055
|
+
};
|
|
1056
|
+
if ($t(kn, H), ht(e) && typeof $(e) != "function" && be(e, (_, A) => {
|
|
1057
|
+
Y(_, A) || (W.validated ? ke() : pe());
|
|
1058
|
+
}, {
|
|
1059
|
+
deep: !0
|
|
1060
|
+
}), process.env.NODE_ENV !== "production" && (H._vm = We(), be(() => Object.assign(Object.assign({ errors: Le.value }, W), { value: Te.value }), qe, {
|
|
1061
|
+
deep: !0
|
|
1062
|
+
}), T || Kn(H)), !T)
|
|
1063
|
+
return H;
|
|
1064
|
+
const St = Z(() => {
|
|
1065
|
+
const _ = le.value;
|
|
1066
|
+
return !_ || ee(_) || vt(_) || fe(_) || Array.isArray(_) ? {} : Object.keys(_).reduce((A, F) => {
|
|
1067
|
+
const P = Pn(_[F]).map((ye) => ye.__locatorRef).reduce((ye, he) => {
|
|
1068
|
+
const se = te(T.values, he) || T.values[he];
|
|
1069
|
+
return se !== void 0 && (ye[he] = se), ye;
|
|
1070
|
+
}, {});
|
|
1071
|
+
return Object.assign(A, P), A;
|
|
1072
|
+
}, {});
|
|
1073
|
+
});
|
|
1074
|
+
return be(St, (_, A) => {
|
|
1075
|
+
if (!Object.keys(_).length)
|
|
1076
|
+
return;
|
|
1077
|
+
!Y(_, A) && (W.validated ? ke() : pe());
|
|
1078
|
+
}), pn(() => {
|
|
1079
|
+
var _;
|
|
1080
|
+
const A = (_ = b(H.keepValueOnUnmount)) !== null && _ !== void 0 ? _ : b(T.keepValuesOnUnmount), F = b(ae);
|
|
1081
|
+
if (A || !T || Ne.pendingUnmount[H.id]) {
|
|
1082
|
+
T?.removePathState(F, Me);
|
|
1083
|
+
return;
|
|
1084
|
+
}
|
|
1085
|
+
Ne.pendingUnmount[H.id] = !0;
|
|
1086
|
+
const P = T.getPathState(F);
|
|
1087
|
+
if (Array.isArray(P?.id) && P?.multiple ? P?.id.includes(H.id) : P?.id === H.id) {
|
|
1088
|
+
if (P?.multiple && Array.isArray(P.value)) {
|
|
1089
|
+
const he = P.value.findIndex((se) => Y(se, b(H.checkedValue)));
|
|
1090
|
+
if (he > -1) {
|
|
1091
|
+
const se = [...P.value];
|
|
1092
|
+
se.splice(he, 1), T.setFieldValue(F, se);
|
|
1093
|
+
}
|
|
1094
|
+
Array.isArray(P.id) && P.id.splice(P.id.indexOf(H.id), 1);
|
|
1095
|
+
} else
|
|
1096
|
+
T.unsetPathValue(b(ae));
|
|
1097
|
+
T.removePathState(F, Me);
|
|
1098
|
+
}
|
|
1099
|
+
}), H;
|
|
1100
|
+
}
|
|
1101
|
+
function na(t) {
|
|
1102
|
+
return Object.assign(Object.assign({}, {
|
|
1103
|
+
initialValue: void 0,
|
|
1104
|
+
validateOnMount: !1,
|
|
1105
|
+
bails: !0,
|
|
1106
|
+
label: void 0,
|
|
1107
|
+
validateOnValueUpdate: !0,
|
|
1108
|
+
keepValueOnUnmount: void 0,
|
|
1109
|
+
syncVModel: !1,
|
|
1110
|
+
controlled: !0
|
|
1111
|
+
}), { initialValue: void 0 });
|
|
1112
|
+
}
|
|
1113
|
+
function aa(t, e, r) {
|
|
1114
|
+
const n = Fr(qt), a = void 0, i = void 0;
|
|
1115
|
+
function s(o) {
|
|
1116
|
+
const c = o.handleChange, d = Z(() => {
|
|
1117
|
+
const S = b(o.value), I = b(a);
|
|
1118
|
+
return Array.isArray(S) ? S.findIndex((j) => Y(j, I)) >= 0 : Y(I, S);
|
|
1119
|
+
});
|
|
1120
|
+
function v(S, I = !0) {
|
|
1121
|
+
var j, U;
|
|
1122
|
+
if (d.value === ((j = S?.target) === null || j === void 0 ? void 0 : j.checked)) {
|
|
1123
|
+
I && o.validate();
|
|
1124
|
+
return;
|
|
1125
|
+
}
|
|
1126
|
+
const ne = b(t), T = n?.getPathState(ne), ae = mt(S);
|
|
1127
|
+
let le = (U = b(a)) !== null && U !== void 0 ? U : ae;
|
|
1128
|
+
n && T?.multiple && T.type === "checkbox" && (le = An(te(n.values, ne) || [], le, void 0)), c(le, I);
|
|
1129
|
+
}
|
|
1130
|
+
return Object.assign(Object.assign({}, o), {
|
|
1131
|
+
checked: d,
|
|
1132
|
+
checkedValue: a,
|
|
1133
|
+
uncheckedValue: i,
|
|
1134
|
+
handleChange: v
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
return s(Hr(t, e));
|
|
1138
|
+
}
|
|
1139
|
+
function ia({ prop: t, value: e, handleChange: r, shouldValidate: n }) {
|
|
1140
|
+
const a = We();
|
|
1141
|
+
if (!a || !t) {
|
|
1142
|
+
process.env.NODE_ENV !== "production" && console.warn("Failed to setup model events because `useField` was not called in setup.");
|
|
1143
|
+
return;
|
|
1144
|
+
}
|
|
1145
|
+
const i = typeof t == "string" ? t : "modelValue", s = `update:${i}`;
|
|
1146
|
+
i in a.props && (be(e, (o) => {
|
|
1147
|
+
Y(o, dr(a, i)) || a.emit(s, o);
|
|
1148
|
+
}), be(() => dr(a, i), (o) => {
|
|
1149
|
+
if (o === rr && e.value === void 0)
|
|
1150
|
+
return;
|
|
1151
|
+
const c = o === rr ? void 0 : o;
|
|
1152
|
+
Y(c, e.value) || r(c, n());
|
|
1153
|
+
}));
|
|
1154
|
+
}
|
|
1155
|
+
function dr(t, e) {
|
|
1156
|
+
if (t)
|
|
1157
|
+
return t.props[e];
|
|
1158
|
+
}
|
|
1159
|
+
let sa = 0;
|
|
1160
|
+
const ct = ["bails", "fieldsCount", "id", "multiple", "type", "validate"];
|
|
1161
|
+
function Jr(t) {
|
|
1162
|
+
const e = t?.initialValues || {}, r = Object.assign({}, b(e)), n = $(t?.validationSchema);
|
|
1163
|
+
return n && fe(n) && ee(n.cast) ? R(n.cast(r) || {}) : R(r);
|
|
1164
|
+
}
|
|
1165
|
+
function za(t) {
|
|
1166
|
+
var e;
|
|
1167
|
+
const r = sa++, n = t?.name || "Form";
|
|
1168
|
+
let a = 0;
|
|
1169
|
+
const i = ce(!1), s = ce(!1), o = ce(0), c = [], d = ft(Jr(t)), v = ce([]), S = ce({}), I = ce({}), j = Tn(() => {
|
|
1170
|
+
I.value = v.value.reduce((l, u) => (l[Qe(b(u.path))] = u, l), {});
|
|
1171
|
+
});
|
|
1172
|
+
function U(l, u) {
|
|
1173
|
+
const f = q(l);
|
|
1174
|
+
if (!f) {
|
|
1175
|
+
typeof l == "string" && (S.value[Qe(l)] = Dt(u));
|
|
1176
|
+
return;
|
|
1177
|
+
}
|
|
1178
|
+
if (typeof l == "string") {
|
|
1179
|
+
const p = Qe(l);
|
|
1180
|
+
S.value[p] && delete S.value[p];
|
|
1181
|
+
}
|
|
1182
|
+
f.errors = Dt(u), f.valid = !f.errors.length;
|
|
1183
|
+
}
|
|
1184
|
+
function ne(l) {
|
|
1185
|
+
X(l).forEach((u) => {
|
|
1186
|
+
U(u, l[u]);
|
|
1187
|
+
});
|
|
1188
|
+
}
|
|
1189
|
+
t?.initialErrors && ne(t.initialErrors);
|
|
1190
|
+
const T = Z(() => {
|
|
1191
|
+
const l = v.value.reduce((u, f) => (f.errors.length && (u[b(f.path)] = f.errors), u), {});
|
|
1192
|
+
return Object.assign(Object.assign({}, S.value), l);
|
|
1193
|
+
}), ae = Z(() => X(T.value).reduce((l, u) => {
|
|
1194
|
+
const f = T.value[u];
|
|
1195
|
+
return f?.length && (l[u] = f[0]), l;
|
|
1196
|
+
}, {})), le = Z(() => v.value.reduce((l, u) => (l[b(u.path)] = { name: b(u.path) || "", label: u.label || "" }, l), {})), Ot = Z(() => v.value.reduce((l, u) => {
|
|
1197
|
+
var f;
|
|
1198
|
+
return l[b(u.path)] = (f = u.bails) !== null && f !== void 0 ? f : !0, l;
|
|
1199
|
+
}, {})), Me = Object.assign({}, t?.initialErrors || {}), Te = (e = t?.keepValuesOnUnmount) !== null && e !== void 0 ? e : !1, { initialValues: Ee, originalInitialValues: W, setInitialValues: De } = ua(v, d, t), Le = oa(v, d, W, ae), Ne = Z(() => v.value.reduce((l, u) => {
|
|
1200
|
+
const f = te(d, b(u.path));
|
|
1201
|
+
return ve(l, b(u.path), f), l;
|
|
1202
|
+
}, {})), ie = t?.validationSchema;
|
|
1203
|
+
function Ue(l, u) {
|
|
1204
|
+
var f, p;
|
|
1205
|
+
const k = Z(() => te(Ee.value, b(l))), C = I.value[b(l)], x = u?.type === "checkbox" || u?.type === "radio";
|
|
1206
|
+
if (C && x) {
|
|
1207
|
+
C.multiple = !0;
|
|
1208
|
+
const oe = a++;
|
|
1209
|
+
return Array.isArray(C.id) ? C.id.push(oe) : C.id = [C.id, oe], C.fieldsCount++, C.__flags.pendingUnmount[oe] = !1, C;
|
|
1210
|
+
}
|
|
1211
|
+
const D = Z(() => te(d, b(l))), z = b(l), J = we.findIndex((oe) => oe === z);
|
|
1212
|
+
J !== -1 && we.splice(J, 1);
|
|
1213
|
+
const M = Z(() => {
|
|
1214
|
+
var oe, Xe, Tt, Et;
|
|
1215
|
+
const Nt = b(ie);
|
|
1216
|
+
if (fe(Nt))
|
|
1217
|
+
return (Xe = (oe = Nt.describe) === null || oe === void 0 ? void 0 : oe.call(Nt, b(l)).required) !== null && Xe !== void 0 ? Xe : !1;
|
|
1218
|
+
const It = b(u?.schema);
|
|
1219
|
+
return fe(It) && (Et = (Tt = It.describe) === null || Tt === void 0 ? void 0 : Tt.call(It).required) !== null && Et !== void 0 ? Et : !1;
|
|
1220
|
+
}), G = a++, K = ft({
|
|
1221
|
+
id: G,
|
|
1222
|
+
path: l,
|
|
1223
|
+
touched: !1,
|
|
1224
|
+
pending: !1,
|
|
1225
|
+
valid: !0,
|
|
1226
|
+
validated: !!(!((f = Me[z]) === null || f === void 0) && f.length),
|
|
1227
|
+
required: M,
|
|
1228
|
+
initialValue: k,
|
|
1229
|
+
errors: vn([]),
|
|
1230
|
+
bails: (p = u?.bails) !== null && p !== void 0 ? p : !1,
|
|
1231
|
+
label: u?.label,
|
|
1232
|
+
type: u?.type || "default",
|
|
1233
|
+
value: D,
|
|
1234
|
+
multiple: !1,
|
|
1235
|
+
__flags: {
|
|
1236
|
+
pendingUnmount: { [G]: !1 },
|
|
1237
|
+
pendingReset: !1
|
|
1238
|
+
},
|
|
1239
|
+
fieldsCount: 1,
|
|
1240
|
+
validate: u?.validate,
|
|
1241
|
+
dirty: Z(() => !Y($(D), $(k)))
|
|
1242
|
+
});
|
|
1243
|
+
return v.value.push(K), I.value[z] = K, j(), ae.value[z] && !Me[z] && de(() => {
|
|
1244
|
+
Re(z, { mode: "silent" });
|
|
1245
|
+
}), ht(l) && be(l, (oe) => {
|
|
1246
|
+
j();
|
|
1247
|
+
const Xe = R(D.value);
|
|
1248
|
+
I.value[oe] = K, de(() => {
|
|
1249
|
+
ve(d, oe, Xe);
|
|
1250
|
+
});
|
|
1251
|
+
}), K;
|
|
1252
|
+
}
|
|
1253
|
+
const ut = sr(Xt, 5), ke = sr(Xt, 5), pe = Mt(async (l) => await (l === "silent" ? ut() : ke()), (l, [u]) => {
|
|
1254
|
+
const f = X(A.errorBag.value), k = [
|
|
1255
|
+
.../* @__PURE__ */ new Set([...X(l.results), ...v.value.map((C) => C.path), ...f])
|
|
1256
|
+
].sort().reduce((C, x) => {
|
|
1257
|
+
var D;
|
|
1258
|
+
const z = x, J = q(z) || wt(z), M = ((D = l.results[z]) === null || D === void 0 ? void 0 : D.errors) || [], G = b(J?.path) || z, K = la({ errors: M, valid: !M.length }, C.results[G]);
|
|
1259
|
+
return C.results[G] = K, K.valid || (C.errors[G] = K.errors[0]), J && S.value[G] && delete S.value[G], J ? (J.valid = K.valid, u === "silent" || u === "validated-only" && !J.validated || U(J, K.errors), C) : (U(G, M), C);
|
|
1260
|
+
}, {
|
|
1261
|
+
valid: l.valid,
|
|
1262
|
+
results: {},
|
|
1263
|
+
errors: {},
|
|
1264
|
+
source: l.source
|
|
1265
|
+
});
|
|
1266
|
+
return l.values && (k.values = l.values, k.source = l.source), X(k.results).forEach((C) => {
|
|
1267
|
+
var x;
|
|
1268
|
+
const D = q(C);
|
|
1269
|
+
D && u !== "silent" && (u === "validated-only" && !D.validated || U(D, (x = k.results[C]) === null || x === void 0 ? void 0 : x.errors));
|
|
1270
|
+
}), k;
|
|
1271
|
+
});
|
|
1272
|
+
function Oe(l) {
|
|
1273
|
+
v.value.forEach(l);
|
|
1274
|
+
}
|
|
1275
|
+
function q(l) {
|
|
1276
|
+
const u = typeof l == "string" ? Qe(l) : l;
|
|
1277
|
+
return typeof u == "string" ? I.value[u] : u;
|
|
1278
|
+
}
|
|
1279
|
+
function wt(l) {
|
|
1280
|
+
return v.value.filter((f) => l.startsWith(b(f.path))).reduce((f, p) => f ? p.path.length > f.path.length ? p : f : p, void 0);
|
|
1281
|
+
}
|
|
1282
|
+
let we = [], Ie;
|
|
1283
|
+
function Ke(l) {
|
|
1284
|
+
return we.push(l), Ie || (Ie = de(() => {
|
|
1285
|
+
[...we].sort().reverse().forEach((f) => {
|
|
1286
|
+
ir(d, f);
|
|
1287
|
+
}), we = [], Ie = null;
|
|
1288
|
+
})), Ie;
|
|
1289
|
+
}
|
|
1290
|
+
function lt(l) {
|
|
1291
|
+
return function(f, p) {
|
|
1292
|
+
return function(C) {
|
|
1293
|
+
return C instanceof Event && (C.preventDefault(), C.stopPropagation()), Oe((x) => x.touched = !0), i.value = !0, o.value++, ze().then((x) => {
|
|
1294
|
+
const D = R(d);
|
|
1295
|
+
if (x.valid && typeof f == "function") {
|
|
1296
|
+
const z = R(Ne.value);
|
|
1297
|
+
let J = l ? z : D;
|
|
1298
|
+
return x.values && (J = x.source === "schema" ? x.values : Object.assign({}, J, x.values)), f(J, {
|
|
1299
|
+
evt: C,
|
|
1300
|
+
controlledValues: z,
|
|
1301
|
+
setErrors: ne,
|
|
1302
|
+
setFieldError: U,
|
|
1303
|
+
setTouched: Ct,
|
|
1304
|
+
setFieldTouched: se,
|
|
1305
|
+
setValues: ye,
|
|
1306
|
+
setFieldValue: F,
|
|
1307
|
+
resetForm: At,
|
|
1308
|
+
resetField: Yt
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
!x.valid && typeof p == "function" && p({
|
|
1312
|
+
values: D,
|
|
1313
|
+
evt: C,
|
|
1314
|
+
errors: x.errors,
|
|
1315
|
+
results: x.results
|
|
1316
|
+
});
|
|
1317
|
+
}).then((x) => (i.value = !1, x), (x) => {
|
|
1318
|
+
throw i.value = !1, x;
|
|
1319
|
+
});
|
|
1320
|
+
};
|
|
1321
|
+
};
|
|
1322
|
+
}
|
|
1323
|
+
const H = lt(!1);
|
|
1324
|
+
H.withControlled = lt(!0);
|
|
1325
|
+
function St(l, u) {
|
|
1326
|
+
const f = v.value.findIndex((k) => k.path === l && (Array.isArray(k.id) ? k.id.includes(u) : k.id === u)), p = v.value[f];
|
|
1327
|
+
if (!(f === -1 || !p)) {
|
|
1328
|
+
if (de(() => {
|
|
1329
|
+
Re(l, { mode: "silent", warn: !1 });
|
|
1330
|
+
}), p.multiple && p.fieldsCount && p.fieldsCount--, Array.isArray(p.id)) {
|
|
1331
|
+
const k = p.id.indexOf(u);
|
|
1332
|
+
k >= 0 && p.id.splice(k, 1), delete p.__flags.pendingUnmount[u];
|
|
1333
|
+
}
|
|
1334
|
+
(!p.multiple || p.fieldsCount <= 0) && (v.value.splice(f, 1), Kt(l), j(), delete I.value[l]);
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
function _(l) {
|
|
1338
|
+
X(I.value).forEach((u) => {
|
|
1339
|
+
u.startsWith(l) && delete I.value[u];
|
|
1340
|
+
}), v.value = v.value.filter((u) => !u.path.startsWith(l)), de(() => {
|
|
1341
|
+
j();
|
|
1342
|
+
});
|
|
1343
|
+
}
|
|
1344
|
+
const A = {
|
|
1345
|
+
name: n,
|
|
1346
|
+
formId: r,
|
|
1347
|
+
values: d,
|
|
1348
|
+
controlledValues: Ne,
|
|
1349
|
+
errorBag: T,
|
|
1350
|
+
errors: ae,
|
|
1351
|
+
schema: ie,
|
|
1352
|
+
submitCount: o,
|
|
1353
|
+
meta: Le,
|
|
1354
|
+
isSubmitting: i,
|
|
1355
|
+
isValidating: s,
|
|
1356
|
+
fieldArrays: c,
|
|
1357
|
+
keepValuesOnUnmount: Te,
|
|
1358
|
+
validateSchema: $(ie) ? pe : void 0,
|
|
1359
|
+
validate: ze,
|
|
1360
|
+
setFieldError: U,
|
|
1361
|
+
validateField: Re,
|
|
1362
|
+
setFieldValue: F,
|
|
1363
|
+
setValues: ye,
|
|
1364
|
+
setErrors: ne,
|
|
1365
|
+
setFieldTouched: se,
|
|
1366
|
+
setTouched: Ct,
|
|
1367
|
+
resetForm: At,
|
|
1368
|
+
resetField: Yt,
|
|
1369
|
+
handleSubmit: H,
|
|
1370
|
+
useFieldModel: ln,
|
|
1371
|
+
defineInputBinds: dn,
|
|
1372
|
+
defineComponentBinds: cn,
|
|
1373
|
+
defineField: Vt,
|
|
1374
|
+
stageInitialValue: on,
|
|
1375
|
+
unsetInitialValue: Kt,
|
|
1376
|
+
setFieldInitialValue: jt,
|
|
1377
|
+
createPathState: Ue,
|
|
1378
|
+
getPathState: q,
|
|
1379
|
+
unsetPathValue: Ke,
|
|
1380
|
+
removePathState: St,
|
|
1381
|
+
initialValues: Ee,
|
|
1382
|
+
getAllPathStates: () => v.value,
|
|
1383
|
+
destroyPath: _,
|
|
1384
|
+
isFieldTouched: nn,
|
|
1385
|
+
isFieldDirty: an,
|
|
1386
|
+
isFieldValid: sn
|
|
1387
|
+
};
|
|
1388
|
+
function F(l, u, f = !0) {
|
|
1389
|
+
const p = R(u), k = typeof l == "string" ? l : l.path;
|
|
1390
|
+
q(k) || Ue(k), ve(d, k, p), f && Re(k);
|
|
1391
|
+
}
|
|
1392
|
+
function P(l, u = !0) {
|
|
1393
|
+
X(d).forEach((f) => {
|
|
1394
|
+
delete d[f];
|
|
1395
|
+
}), X(l).forEach((f) => {
|
|
1396
|
+
F(f, l[f], !1);
|
|
1397
|
+
}), u && ze();
|
|
1398
|
+
}
|
|
1399
|
+
function ye(l, u = !0) {
|
|
1400
|
+
it(d, l), c.forEach((f) => f && f.reset()), u && ze();
|
|
1401
|
+
}
|
|
1402
|
+
function he(l, u) {
|
|
1403
|
+
const f = q(b(l)) || Ue(l);
|
|
1404
|
+
return Z({
|
|
1405
|
+
get() {
|
|
1406
|
+
return f.value;
|
|
1407
|
+
},
|
|
1408
|
+
set(p) {
|
|
1409
|
+
var k;
|
|
1410
|
+
const C = b(l);
|
|
1411
|
+
F(C, p, (k = b(u)) !== null && k !== void 0 ? k : !1);
|
|
1412
|
+
}
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
function se(l, u) {
|
|
1416
|
+
const f = q(l);
|
|
1417
|
+
f && (f.touched = u);
|
|
1418
|
+
}
|
|
1419
|
+
function nn(l) {
|
|
1420
|
+
const u = q(l);
|
|
1421
|
+
return u ? u.touched : v.value.filter((f) => f.path.startsWith(l)).some((f) => f.touched);
|
|
1422
|
+
}
|
|
1423
|
+
function an(l) {
|
|
1424
|
+
const u = q(l);
|
|
1425
|
+
return u ? u.dirty : v.value.filter((f) => f.path.startsWith(l)).some((f) => f.dirty);
|
|
1426
|
+
}
|
|
1427
|
+
function sn(l) {
|
|
1428
|
+
const u = q(l);
|
|
1429
|
+
return u ? u.valid : v.value.filter((f) => f.path.startsWith(l)).every((f) => f.valid);
|
|
1430
|
+
}
|
|
1431
|
+
function Ct(l) {
|
|
1432
|
+
if (typeof l == "boolean") {
|
|
1433
|
+
Oe((u) => {
|
|
1434
|
+
u.touched = l;
|
|
1435
|
+
});
|
|
1436
|
+
return;
|
|
1437
|
+
}
|
|
1438
|
+
X(l).forEach((u) => {
|
|
1439
|
+
se(u, !!l[u]);
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
function Yt(l, u) {
|
|
1443
|
+
var f;
|
|
1444
|
+
const p = u && "value" in u ? u.value : te(Ee.value, l), k = q(l);
|
|
1445
|
+
k && (k.__flags.pendingReset = !0), jt(l, R(p), !0), F(l, p, !1), se(l, (f = u?.touched) !== null && f !== void 0 ? f : !1), U(l, u?.errors || []), de(() => {
|
|
1446
|
+
k && (k.__flags.pendingReset = !1);
|
|
1447
|
+
});
|
|
1448
|
+
}
|
|
1449
|
+
function At(l, u) {
|
|
1450
|
+
let f = R(l?.values ? l.values : W.value);
|
|
1451
|
+
f = u?.force ? f : it(W.value, f), f = fe(ie) && ee(ie.cast) ? ie.cast(f) : f, De(f, { force: u?.force }), Oe((p) => {
|
|
1452
|
+
var k;
|
|
1453
|
+
p.__flags.pendingReset = !0, p.validated = !1, p.touched = ((k = l?.touched) === null || k === void 0 ? void 0 : k[b(p.path)]) || !1, F(b(p.path), te(f, b(p.path)), !1), U(b(p.path), void 0);
|
|
1454
|
+
}), u?.force ? P(f, !1) : ye(f, !1), ne(l?.errors || {}), o.value = l?.submitCount || 0, de(() => {
|
|
1455
|
+
ze({ mode: "silent" }), Oe((p) => {
|
|
1456
|
+
p.__flags.pendingReset = !1;
|
|
1457
|
+
});
|
|
1458
|
+
});
|
|
1459
|
+
}
|
|
1460
|
+
async function ze(l) {
|
|
1461
|
+
const u = l?.mode || "force";
|
|
1462
|
+
if (u === "force" && Oe((x) => x.validated = !0), A.validateSchema)
|
|
1463
|
+
return A.validateSchema(u);
|
|
1464
|
+
s.value = !0;
|
|
1465
|
+
const f = await Promise.all(v.value.map((x) => x.validate ? x.validate(l).then((D) => ({
|
|
1466
|
+
key: b(x.path),
|
|
1467
|
+
valid: D.valid,
|
|
1468
|
+
errors: D.errors,
|
|
1469
|
+
value: D.value
|
|
1470
|
+
})) : Promise.resolve({
|
|
1471
|
+
key: b(x.path),
|
|
1472
|
+
valid: !0,
|
|
1473
|
+
errors: [],
|
|
1474
|
+
value: void 0
|
|
1475
|
+
})));
|
|
1476
|
+
s.value = !1;
|
|
1477
|
+
const p = {}, k = {}, C = {};
|
|
1478
|
+
for (const x of f)
|
|
1479
|
+
p[x.key] = {
|
|
1480
|
+
valid: x.valid,
|
|
1481
|
+
errors: x.errors
|
|
1482
|
+
}, x.value && ve(C, x.key, x.value), x.errors.length && (k[x.key] = x.errors[0]);
|
|
1483
|
+
return {
|
|
1484
|
+
valid: f.every((x) => x.valid),
|
|
1485
|
+
results: p,
|
|
1486
|
+
errors: k,
|
|
1487
|
+
values: C,
|
|
1488
|
+
source: "fields"
|
|
1489
|
+
};
|
|
1490
|
+
}
|
|
1491
|
+
async function Re(l, u) {
|
|
1492
|
+
var f;
|
|
1493
|
+
const p = q(l);
|
|
1494
|
+
if (p && u?.mode !== "silent" && (p.validated = !0), ie) {
|
|
1495
|
+
const { results: C } = await pe(u?.mode || "validated-only");
|
|
1496
|
+
return C[l] || { errors: [], valid: !0 };
|
|
1497
|
+
}
|
|
1498
|
+
return p?.validate ? p.validate(u) : (!p && (!((f = u?.warn) !== null && f !== void 0) || f) && process.env.NODE_ENV !== "production" && mn(`field with path ${l} was not found`), Promise.resolve({ errors: [], valid: !0 }));
|
|
1499
|
+
}
|
|
1500
|
+
function Kt(l) {
|
|
1501
|
+
ir(Ee.value, l);
|
|
1502
|
+
}
|
|
1503
|
+
function on(l, u, f = !1) {
|
|
1504
|
+
jt(l, u), ve(d, l, u), f && !t?.initialValues && ve(W.value, l, R(u));
|
|
1505
|
+
}
|
|
1506
|
+
function jt(l, u, f = !1) {
|
|
1507
|
+
ve(Ee.value, l, R(u)), f && ve(W.value, l, R(u));
|
|
1508
|
+
}
|
|
1509
|
+
async function Xt() {
|
|
1510
|
+
const l = $(ie);
|
|
1511
|
+
if (!l)
|
|
1512
|
+
return { valid: !0, results: {}, errors: {}, source: "none" };
|
|
1513
|
+
s.value = !0;
|
|
1514
|
+
const u = vt(l) || fe(l) ? await zn(l, d) : await Bn(l, d, {
|
|
1515
|
+
names: le.value,
|
|
1516
|
+
bailsMap: Ot.value
|
|
1517
|
+
});
|
|
1518
|
+
return s.value = !1, u;
|
|
1519
|
+
}
|
|
1520
|
+
const un = H((l, { evt: u }) => {
|
|
1521
|
+
Cn(u) && u.target.submit();
|
|
1522
|
+
});
|
|
1523
|
+
Vr(() => {
|
|
1524
|
+
if (t?.initialErrors && ne(t.initialErrors), t?.initialTouched && Ct(t.initialTouched), t?.validateOnMount) {
|
|
1525
|
+
ze();
|
|
1526
|
+
return;
|
|
1527
|
+
}
|
|
1528
|
+
A.validateSchema && A.validateSchema("silent");
|
|
1529
|
+
}), ht(ie) && be(ie, () => {
|
|
1530
|
+
var l;
|
|
1531
|
+
(l = A.validateSchema) === null || l === void 0 || l.call(A, "validated-only");
|
|
1532
|
+
}), $t(qt, A), process.env.NODE_ENV !== "production" && (Yn(A), be(() => Object.assign(Object.assign({ errors: T.value }, Le.value), { values: d, isSubmitting: i.value, isValidating: s.value, submitCount: o.value }), qe, {
|
|
1533
|
+
deep: !0
|
|
1534
|
+
}));
|
|
1535
|
+
function Vt(l, u) {
|
|
1536
|
+
const f = ee(u) ? void 0 : u?.label, p = q(b(l)) || Ue(l, { label: f }), k = () => ee(u) ? u(dt(p, ct)) : u || {};
|
|
1537
|
+
function C() {
|
|
1538
|
+
var M;
|
|
1539
|
+
p.touched = !0, ((M = k().validateOnBlur) !== null && M !== void 0 ? M : et().validateOnBlur) && Re(b(p.path));
|
|
1540
|
+
}
|
|
1541
|
+
function x() {
|
|
1542
|
+
var M;
|
|
1543
|
+
((M = k().validateOnInput) !== null && M !== void 0 ? M : et().validateOnInput) && de(() => {
|
|
1544
|
+
Re(b(p.path));
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
function D() {
|
|
1548
|
+
var M;
|
|
1549
|
+
((M = k().validateOnChange) !== null && M !== void 0 ? M : et().validateOnChange) && de(() => {
|
|
1550
|
+
Re(b(p.path));
|
|
1551
|
+
});
|
|
1552
|
+
}
|
|
1553
|
+
const z = Z(() => {
|
|
1554
|
+
const M = {
|
|
1555
|
+
onChange: D,
|
|
1556
|
+
onInput: x,
|
|
1557
|
+
onBlur: C
|
|
1558
|
+
};
|
|
1559
|
+
return ee(u) ? Object.assign(Object.assign({}, M), u(dt(p, ct)).props || {}) : u?.props ? Object.assign(Object.assign({}, M), u.props(dt(p, ct))) : M;
|
|
1560
|
+
});
|
|
1561
|
+
return [he(l, () => {
|
|
1562
|
+
var M, G, K;
|
|
1563
|
+
return (K = (M = k().validateOnModelUpdate) !== null && M !== void 0 ? M : (G = et()) === null || G === void 0 ? void 0 : G.validateOnModelUpdate) !== null && K !== void 0 ? K : !0;
|
|
1564
|
+
}), z];
|
|
1565
|
+
}
|
|
1566
|
+
function ln(l) {
|
|
1567
|
+
return Array.isArray(l) ? l.map((u) => he(u, !0)) : he(l);
|
|
1568
|
+
}
|
|
1569
|
+
function dn(l, u) {
|
|
1570
|
+
const [f, p] = Vt(l, u);
|
|
1571
|
+
function k() {
|
|
1572
|
+
p.value.onBlur();
|
|
1573
|
+
}
|
|
1574
|
+
function C(D) {
|
|
1575
|
+
const z = mt(D);
|
|
1576
|
+
F(b(l), z, !1), p.value.onInput();
|
|
1577
|
+
}
|
|
1578
|
+
function x(D) {
|
|
1579
|
+
const z = mt(D);
|
|
1580
|
+
F(b(l), z, !1), p.value.onChange();
|
|
1581
|
+
}
|
|
1582
|
+
return Z(() => Object.assign(Object.assign({}, p.value), {
|
|
1583
|
+
onBlur: k,
|
|
1584
|
+
onInput: C,
|
|
1585
|
+
onChange: x,
|
|
1586
|
+
value: f.value
|
|
1587
|
+
}));
|
|
1588
|
+
}
|
|
1589
|
+
function cn(l, u) {
|
|
1590
|
+
const [f, p] = Vt(l, u), k = q(b(l));
|
|
1591
|
+
function C(x) {
|
|
1592
|
+
f.value = x;
|
|
1593
|
+
}
|
|
1594
|
+
return Z(() => {
|
|
1595
|
+
const x = ee(u) ? u(dt(k, ct)) : u || {};
|
|
1596
|
+
return Object.assign({ [x.model || "modelValue"]: f.value, [`onUpdate:${x.model || "modelValue"}`]: C }, p.value);
|
|
1597
|
+
});
|
|
1598
|
+
}
|
|
1599
|
+
const Qt = Object.assign(Object.assign({}, A), { values: fn(d), handleReset: () => At(), submitForm: un });
|
|
1600
|
+
return $t(Ir, Qt), Qt;
|
|
1601
|
+
}
|
|
1602
|
+
function oa(t, e, r, n) {
|
|
1603
|
+
const a = {
|
|
1604
|
+
touched: "some",
|
|
1605
|
+
pending: "some",
|
|
1606
|
+
valid: "every"
|
|
1607
|
+
}, i = Z(() => !Y(e, $(r)));
|
|
1608
|
+
function s() {
|
|
1609
|
+
const c = t.value;
|
|
1610
|
+
return X(a).reduce((d, v) => {
|
|
1611
|
+
const S = a[v];
|
|
1612
|
+
return d[v] = c[S]((I) => I[v]), d;
|
|
1613
|
+
}, {});
|
|
1614
|
+
}
|
|
1615
|
+
const o = ft(s());
|
|
1616
|
+
return hn(() => {
|
|
1617
|
+
const c = s();
|
|
1618
|
+
o.touched = c.touched, o.valid = c.valid, o.pending = c.pending;
|
|
1619
|
+
}), Z(() => Object.assign(Object.assign({ initialValues: $(r) }, o), { valid: o.valid && !X(n.value).length, dirty: i.value }));
|
|
1620
|
+
}
|
|
1621
|
+
function ua(t, e, r) {
|
|
1622
|
+
const n = Jr(r), a = ce(n), i = ce(R(n));
|
|
1623
|
+
function s(o, c) {
|
|
1624
|
+
c?.force ? (a.value = R(o), i.value = R(o)) : (a.value = it(R(a.value) || {}, R(o)), i.value = it(R(i.value) || {}, R(o))), c?.updateFields && t.value.forEach((d) => {
|
|
1625
|
+
if (d.touched)
|
|
1626
|
+
return;
|
|
1627
|
+
const S = te(a.value, b(d.path));
|
|
1628
|
+
ve(e, b(d.path), R(S));
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
return {
|
|
1632
|
+
initialValues: a,
|
|
1633
|
+
originalInitialValues: i,
|
|
1634
|
+
setInitialValues: s
|
|
1635
|
+
};
|
|
1636
|
+
}
|
|
1637
|
+
function la(t, e) {
|
|
1638
|
+
return e ? {
|
|
1639
|
+
valid: t.valid && e.valid,
|
|
1640
|
+
errors: [...t.errors, ...e.errors]
|
|
1641
|
+
} : t;
|
|
1642
|
+
}
|
|
1643
|
+
function Ba() {
|
|
1644
|
+
return Tr(Ir);
|
|
1645
|
+
}
|
|
1646
|
+
var N;
|
|
1647
|
+
(function(t) {
|
|
1648
|
+
t.assertEqual = (a) => {
|
|
1649
|
+
};
|
|
1650
|
+
function e(a) {
|
|
1651
|
+
}
|
|
1652
|
+
t.assertIs = e;
|
|
1653
|
+
function r(a) {
|
|
1654
|
+
throw new Error();
|
|
1655
|
+
}
|
|
1656
|
+
t.assertNever = r, t.arrayToEnum = (a) => {
|
|
1657
|
+
const i = {};
|
|
1658
|
+
for (const s of a)
|
|
1659
|
+
i[s] = s;
|
|
1660
|
+
return i;
|
|
1661
|
+
}, t.getValidEnumValues = (a) => {
|
|
1662
|
+
const i = t.objectKeys(a).filter((o) => typeof a[a[o]] != "number"), s = {};
|
|
1663
|
+
for (const o of i)
|
|
1664
|
+
s[o] = a[o];
|
|
1665
|
+
return t.objectValues(s);
|
|
1666
|
+
}, t.objectValues = (a) => t.objectKeys(a).map(function(i) {
|
|
1667
|
+
return a[i];
|
|
1668
|
+
}), t.objectKeys = typeof Object.keys == "function" ? (a) => Object.keys(a) : (a) => {
|
|
1669
|
+
const i = [];
|
|
1670
|
+
for (const s in a)
|
|
1671
|
+
Object.prototype.hasOwnProperty.call(a, s) && i.push(s);
|
|
1672
|
+
return i;
|
|
1673
|
+
}, t.find = (a, i) => {
|
|
1674
|
+
for (const s of a)
|
|
1675
|
+
if (i(s))
|
|
1676
|
+
return s;
|
|
1677
|
+
}, t.isInteger = typeof Number.isInteger == "function" ? (a) => Number.isInteger(a) : (a) => typeof a == "number" && Number.isFinite(a) && Math.floor(a) === a;
|
|
1678
|
+
function n(a, i = " | ") {
|
|
1679
|
+
return a.map((s) => typeof s == "string" ? `'${s}'` : s).join(i);
|
|
1680
|
+
}
|
|
1681
|
+
t.joinValues = n, t.jsonStringifyReplacer = (a, i) => typeof i == "bigint" ? i.toString() : i;
|
|
1682
|
+
})(N || (N = {}));
|
|
1683
|
+
var cr;
|
|
1684
|
+
(function(t) {
|
|
1685
|
+
t.mergeShapes = (e, r) => ({
|
|
1686
|
+
...e,
|
|
1687
|
+
...r
|
|
1688
|
+
// second overwrites first
|
|
1689
|
+
});
|
|
1690
|
+
})(cr || (cr = {}));
|
|
1691
|
+
const y = N.arrayToEnum([
|
|
1692
|
+
"string",
|
|
1693
|
+
"nan",
|
|
1694
|
+
"number",
|
|
1695
|
+
"integer",
|
|
1696
|
+
"float",
|
|
1697
|
+
"boolean",
|
|
1698
|
+
"date",
|
|
1699
|
+
"bigint",
|
|
1700
|
+
"symbol",
|
|
1701
|
+
"function",
|
|
1702
|
+
"undefined",
|
|
1703
|
+
"null",
|
|
1704
|
+
"array",
|
|
1705
|
+
"object",
|
|
1706
|
+
"unknown",
|
|
1707
|
+
"promise",
|
|
1708
|
+
"void",
|
|
1709
|
+
"never",
|
|
1710
|
+
"map",
|
|
1711
|
+
"set"
|
|
1712
|
+
]), Se = (t) => {
|
|
1713
|
+
switch (typeof t) {
|
|
1714
|
+
case "undefined":
|
|
1715
|
+
return y.undefined;
|
|
1716
|
+
case "string":
|
|
1717
|
+
return y.string;
|
|
1718
|
+
case "number":
|
|
1719
|
+
return Number.isNaN(t) ? y.nan : y.number;
|
|
1720
|
+
case "boolean":
|
|
1721
|
+
return y.boolean;
|
|
1722
|
+
case "function":
|
|
1723
|
+
return y.function;
|
|
1724
|
+
case "bigint":
|
|
1725
|
+
return y.bigint;
|
|
1726
|
+
case "symbol":
|
|
1727
|
+
return y.symbol;
|
|
1728
|
+
case "object":
|
|
1729
|
+
return Array.isArray(t) ? y.array : t === null ? y.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? y.promise : typeof Map < "u" && t instanceof Map ? y.map : typeof Set < "u" && t instanceof Set ? y.set : typeof Date < "u" && t instanceof Date ? y.date : y.object;
|
|
1730
|
+
default:
|
|
1731
|
+
return y.unknown;
|
|
1732
|
+
}
|
|
1733
|
+
}, h = N.arrayToEnum([
|
|
1734
|
+
"invalid_type",
|
|
1735
|
+
"invalid_literal",
|
|
1736
|
+
"custom",
|
|
1737
|
+
"invalid_union",
|
|
1738
|
+
"invalid_union_discriminator",
|
|
1739
|
+
"invalid_enum_value",
|
|
1740
|
+
"unrecognized_keys",
|
|
1741
|
+
"invalid_arguments",
|
|
1742
|
+
"invalid_return_type",
|
|
1743
|
+
"invalid_date",
|
|
1744
|
+
"invalid_string",
|
|
1745
|
+
"too_small",
|
|
1746
|
+
"too_big",
|
|
1747
|
+
"invalid_intersection_types",
|
|
1748
|
+
"not_multiple_of",
|
|
1749
|
+
"not_finite"
|
|
1750
|
+
]);
|
|
1751
|
+
class xe extends Error {
|
|
1752
|
+
get errors() {
|
|
1753
|
+
return this.issues;
|
|
1754
|
+
}
|
|
1755
|
+
constructor(e) {
|
|
1756
|
+
super(), this.issues = [], this.addIssue = (n) => {
|
|
1757
|
+
this.issues = [...this.issues, n];
|
|
1758
|
+
}, this.addIssues = (n = []) => {
|
|
1759
|
+
this.issues = [...this.issues, ...n];
|
|
1760
|
+
};
|
|
1761
|
+
const r = new.target.prototype;
|
|
1762
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, r) : this.__proto__ = r, this.name = "ZodError", this.issues = e;
|
|
1763
|
+
}
|
|
1764
|
+
format(e) {
|
|
1765
|
+
const r = e || function(i) {
|
|
1766
|
+
return i.message;
|
|
1767
|
+
}, n = { _errors: [] }, a = (i) => {
|
|
1768
|
+
for (const s of i.issues)
|
|
1769
|
+
if (s.code === "invalid_union")
|
|
1770
|
+
s.unionErrors.map(a);
|
|
1771
|
+
else if (s.code === "invalid_return_type")
|
|
1772
|
+
a(s.returnTypeError);
|
|
1773
|
+
else if (s.code === "invalid_arguments")
|
|
1774
|
+
a(s.argumentsError);
|
|
1775
|
+
else if (s.path.length === 0)
|
|
1776
|
+
n._errors.push(r(s));
|
|
1777
|
+
else {
|
|
1778
|
+
let o = n, c = 0;
|
|
1779
|
+
for (; c < s.path.length; ) {
|
|
1780
|
+
const d = s.path[c];
|
|
1781
|
+
c === s.path.length - 1 ? (o[d] = o[d] || { _errors: [] }, o[d]._errors.push(r(s))) : o[d] = o[d] || { _errors: [] }, o = o[d], c++;
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
};
|
|
1785
|
+
return a(this), n;
|
|
1786
|
+
}
|
|
1787
|
+
static assert(e) {
|
|
1788
|
+
if (!(e instanceof xe))
|
|
1789
|
+
throw new Error(`Not a ZodError: ${e}`);
|
|
1790
|
+
}
|
|
1791
|
+
toString() {
|
|
1792
|
+
return this.message;
|
|
1793
|
+
}
|
|
1794
|
+
get message() {
|
|
1795
|
+
return JSON.stringify(this.issues, N.jsonStringifyReplacer, 2);
|
|
1796
|
+
}
|
|
1797
|
+
get isEmpty() {
|
|
1798
|
+
return this.issues.length === 0;
|
|
1799
|
+
}
|
|
1800
|
+
flatten(e = (r) => r.message) {
|
|
1801
|
+
const r = {}, n = [];
|
|
1802
|
+
for (const a of this.issues)
|
|
1803
|
+
if (a.path.length > 0) {
|
|
1804
|
+
const i = a.path[0];
|
|
1805
|
+
r[i] = r[i] || [], r[i].push(e(a));
|
|
1806
|
+
} else
|
|
1807
|
+
n.push(e(a));
|
|
1808
|
+
return { formErrors: n, fieldErrors: r };
|
|
1809
|
+
}
|
|
1810
|
+
get formErrors() {
|
|
1811
|
+
return this.flatten();
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
xe.create = (t) => new xe(t);
|
|
1815
|
+
const Lt = (t, e) => {
|
|
1816
|
+
let r;
|
|
1817
|
+
switch (t.code) {
|
|
1818
|
+
case h.invalid_type:
|
|
1819
|
+
t.received === y.undefined ? r = "Required" : r = `Expected ${t.expected}, received ${t.received}`;
|
|
1820
|
+
break;
|
|
1821
|
+
case h.invalid_literal:
|
|
1822
|
+
r = `Invalid literal value, expected ${JSON.stringify(t.expected, N.jsonStringifyReplacer)}`;
|
|
1823
|
+
break;
|
|
1824
|
+
case h.unrecognized_keys:
|
|
1825
|
+
r = `Unrecognized key(s) in object: ${N.joinValues(t.keys, ", ")}`;
|
|
1826
|
+
break;
|
|
1827
|
+
case h.invalid_union:
|
|
1828
|
+
r = "Invalid input";
|
|
1829
|
+
break;
|
|
1830
|
+
case h.invalid_union_discriminator:
|
|
1831
|
+
r = `Invalid discriminator value. Expected ${N.joinValues(t.options)}`;
|
|
1832
|
+
break;
|
|
1833
|
+
case h.invalid_enum_value:
|
|
1834
|
+
r = `Invalid enum value. Expected ${N.joinValues(t.options)}, received '${t.received}'`;
|
|
1835
|
+
break;
|
|
1836
|
+
case h.invalid_arguments:
|
|
1837
|
+
r = "Invalid function arguments";
|
|
1838
|
+
break;
|
|
1839
|
+
case h.invalid_return_type:
|
|
1840
|
+
r = "Invalid function return type";
|
|
1841
|
+
break;
|
|
1842
|
+
case h.invalid_date:
|
|
1843
|
+
r = "Invalid date";
|
|
1844
|
+
break;
|
|
1845
|
+
case h.invalid_string:
|
|
1846
|
+
typeof t.validation == "object" ? "includes" in t.validation ? (r = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (r = `${r} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? r = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? r = `Invalid input: must end with "${t.validation.endsWith}"` : N.assertNever(t.validation) : t.validation !== "regex" ? r = `Invalid ${t.validation}` : r = "Invalid";
|
|
1847
|
+
break;
|
|
1848
|
+
case h.too_small:
|
|
1849
|
+
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "bigint" ? r = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : r = "Invalid input";
|
|
1850
|
+
break;
|
|
1851
|
+
case h.too_big:
|
|
1852
|
+
t.type === "array" ? r = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? r = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? r = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? r = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? r = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : r = "Invalid input";
|
|
1853
|
+
break;
|
|
1854
|
+
case h.custom:
|
|
1855
|
+
r = "Invalid input";
|
|
1856
|
+
break;
|
|
1857
|
+
case h.invalid_intersection_types:
|
|
1858
|
+
r = "Intersection results could not be merged";
|
|
1859
|
+
break;
|
|
1860
|
+
case h.not_multiple_of:
|
|
1861
|
+
r = `Number must be a multiple of ${t.multipleOf}`;
|
|
1862
|
+
break;
|
|
1863
|
+
case h.not_finite:
|
|
1864
|
+
r = "Number must be finite";
|
|
1865
|
+
break;
|
|
1866
|
+
default:
|
|
1867
|
+
r = e.defaultError, N.assertNever(t);
|
|
1868
|
+
}
|
|
1869
|
+
return { message: r };
|
|
1870
|
+
};
|
|
1871
|
+
let da = Lt;
|
|
1872
|
+
function ca() {
|
|
1873
|
+
return da;
|
|
1874
|
+
}
|
|
1875
|
+
const fa = (t) => {
|
|
1876
|
+
const { data: e, path: r, errorMaps: n, issueData: a } = t, i = [...r, ...a.path || []], s = {
|
|
1877
|
+
...a,
|
|
1878
|
+
path: i
|
|
1879
|
+
};
|
|
1880
|
+
if (a.message !== void 0)
|
|
1881
|
+
return {
|
|
1882
|
+
...a,
|
|
1883
|
+
path: i,
|
|
1884
|
+
message: a.message
|
|
1885
|
+
};
|
|
1886
|
+
let o = "";
|
|
1887
|
+
const c = n.filter((d) => !!d).slice().reverse();
|
|
1888
|
+
for (const d of c)
|
|
1889
|
+
o = d(s, { data: e, defaultError: o }).message;
|
|
1890
|
+
return {
|
|
1891
|
+
...a,
|
|
1892
|
+
path: i,
|
|
1893
|
+
message: o
|
|
1894
|
+
};
|
|
1895
|
+
};
|
|
1896
|
+
function m(t, e) {
|
|
1897
|
+
const r = ca(), n = fa({
|
|
1898
|
+
issueData: e,
|
|
1899
|
+
data: t.data,
|
|
1900
|
+
path: t.path,
|
|
1901
|
+
errorMaps: [
|
|
1902
|
+
t.common.contextualErrorMap,
|
|
1903
|
+
// contextual error map is first priority
|
|
1904
|
+
t.schemaErrorMap,
|
|
1905
|
+
// then schema-bound map if available
|
|
1906
|
+
r,
|
|
1907
|
+
// then global override map
|
|
1908
|
+
r === Lt ? void 0 : Lt
|
|
1909
|
+
// then global default map
|
|
1910
|
+
].filter((a) => !!a)
|
|
1911
|
+
});
|
|
1912
|
+
t.common.issues.push(n);
|
|
1913
|
+
}
|
|
1914
|
+
class re {
|
|
1915
|
+
constructor() {
|
|
1916
|
+
this.value = "valid";
|
|
1917
|
+
}
|
|
1918
|
+
dirty() {
|
|
1919
|
+
this.value === "valid" && (this.value = "dirty");
|
|
1920
|
+
}
|
|
1921
|
+
abort() {
|
|
1922
|
+
this.value !== "aborted" && (this.value = "aborted");
|
|
1923
|
+
}
|
|
1924
|
+
static mergeArray(e, r) {
|
|
1925
|
+
const n = [];
|
|
1926
|
+
for (const a of r) {
|
|
1927
|
+
if (a.status === "aborted")
|
|
1928
|
+
return w;
|
|
1929
|
+
a.status === "dirty" && e.dirty(), n.push(a.value);
|
|
1930
|
+
}
|
|
1931
|
+
return { status: e.value, value: n };
|
|
1932
|
+
}
|
|
1933
|
+
static async mergeObjectAsync(e, r) {
|
|
1934
|
+
const n = [];
|
|
1935
|
+
for (const a of r) {
|
|
1936
|
+
const i = await a.key, s = await a.value;
|
|
1937
|
+
n.push({
|
|
1938
|
+
key: i,
|
|
1939
|
+
value: s
|
|
1940
|
+
});
|
|
1941
|
+
}
|
|
1942
|
+
return re.mergeObjectSync(e, n);
|
|
1943
|
+
}
|
|
1944
|
+
static mergeObjectSync(e, r) {
|
|
1945
|
+
const n = {};
|
|
1946
|
+
for (const a of r) {
|
|
1947
|
+
const { key: i, value: s } = a;
|
|
1948
|
+
if (i.status === "aborted" || s.status === "aborted")
|
|
1949
|
+
return w;
|
|
1950
|
+
i.status === "dirty" && e.dirty(), s.status === "dirty" && e.dirty(), i.value !== "__proto__" && (typeof s.value < "u" || a.alwaysSet) && (n[i.value] = s.value);
|
|
1951
|
+
}
|
|
1952
|
+
return { status: e.value, value: n };
|
|
1953
|
+
}
|
|
1954
|
+
}
|
|
1955
|
+
const w = Object.freeze({
|
|
1956
|
+
status: "aborted"
|
|
1957
|
+
}), tt = (t) => ({ status: "dirty", value: t }), ue = (t) => ({ status: "valid", value: t }), fr = (t) => t.status === "aborted", hr = (t) => t.status === "dirty", He = (t) => t.status === "valid", pt = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
1958
|
+
var g;
|
|
1959
|
+
(function(t) {
|
|
1960
|
+
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
1961
|
+
})(g || (g = {}));
|
|
1962
|
+
class je {
|
|
1963
|
+
constructor(e, r, n, a) {
|
|
1964
|
+
this._cachedPath = [], this.parent = e, this.data = r, this._path = n, this._key = a;
|
|
1965
|
+
}
|
|
1966
|
+
get path() {
|
|
1967
|
+
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
const vr = (t, e) => {
|
|
1971
|
+
if (He(e))
|
|
1972
|
+
return { success: !0, data: e.value };
|
|
1973
|
+
if (!t.common.issues.length)
|
|
1974
|
+
throw new Error("Validation failed but no issues detected.");
|
|
1975
|
+
return {
|
|
1976
|
+
success: !1,
|
|
1977
|
+
get error() {
|
|
1978
|
+
if (this._error)
|
|
1979
|
+
return this._error;
|
|
1980
|
+
const r = new xe(t.common.issues);
|
|
1981
|
+
return this._error = r, this._error;
|
|
1982
|
+
}
|
|
1983
|
+
};
|
|
1984
|
+
};
|
|
1985
|
+
function V(t) {
|
|
1986
|
+
if (!t)
|
|
1987
|
+
return {};
|
|
1988
|
+
const { errorMap: e, invalid_type_error: r, required_error: n, description: a } = t;
|
|
1989
|
+
if (e && (r || n))
|
|
1990
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
1991
|
+
return e ? { errorMap: e, description: a } : { errorMap: (s, o) => {
|
|
1992
|
+
const { message: c } = t;
|
|
1993
|
+
return s.code === "invalid_enum_value" ? { message: c ?? o.defaultError } : typeof o.data > "u" ? { message: c ?? n ?? o.defaultError } : s.code !== "invalid_type" ? { message: o.defaultError } : { message: c ?? r ?? o.defaultError };
|
|
1994
|
+
}, description: a };
|
|
1995
|
+
}
|
|
1996
|
+
class E {
|
|
1997
|
+
get description() {
|
|
1998
|
+
return this._def.description;
|
|
1999
|
+
}
|
|
2000
|
+
_getType(e) {
|
|
2001
|
+
return Se(e.data);
|
|
2002
|
+
}
|
|
2003
|
+
_getOrReturnCtx(e, r) {
|
|
2004
|
+
return r || {
|
|
2005
|
+
common: e.parent.common,
|
|
2006
|
+
data: e.data,
|
|
2007
|
+
parsedType: Se(e.data),
|
|
2008
|
+
schemaErrorMap: this._def.errorMap,
|
|
2009
|
+
path: e.path,
|
|
2010
|
+
parent: e.parent
|
|
2011
|
+
};
|
|
2012
|
+
}
|
|
2013
|
+
_processInputParams(e) {
|
|
2014
|
+
return {
|
|
2015
|
+
status: new re(),
|
|
2016
|
+
ctx: {
|
|
2017
|
+
common: e.parent.common,
|
|
2018
|
+
data: e.data,
|
|
2019
|
+
parsedType: Se(e.data),
|
|
2020
|
+
schemaErrorMap: this._def.errorMap,
|
|
2021
|
+
path: e.path,
|
|
2022
|
+
parent: e.parent
|
|
2023
|
+
}
|
|
2024
|
+
};
|
|
2025
|
+
}
|
|
2026
|
+
_parseSync(e) {
|
|
2027
|
+
const r = this._parse(e);
|
|
2028
|
+
if (pt(r))
|
|
2029
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
2030
|
+
return r;
|
|
2031
|
+
}
|
|
2032
|
+
_parseAsync(e) {
|
|
2033
|
+
const r = this._parse(e);
|
|
2034
|
+
return Promise.resolve(r);
|
|
2035
|
+
}
|
|
2036
|
+
parse(e, r) {
|
|
2037
|
+
const n = this.safeParse(e, r);
|
|
2038
|
+
if (n.success)
|
|
2039
|
+
return n.data;
|
|
2040
|
+
throw n.error;
|
|
2041
|
+
}
|
|
2042
|
+
safeParse(e, r) {
|
|
2043
|
+
const n = {
|
|
2044
|
+
common: {
|
|
2045
|
+
issues: [],
|
|
2046
|
+
async: r?.async ?? !1,
|
|
2047
|
+
contextualErrorMap: r?.errorMap
|
|
2048
|
+
},
|
|
2049
|
+
path: r?.path || [],
|
|
2050
|
+
schemaErrorMap: this._def.errorMap,
|
|
2051
|
+
parent: null,
|
|
2052
|
+
data: e,
|
|
2053
|
+
parsedType: Se(e)
|
|
2054
|
+
}, a = this._parseSync({ data: e, path: n.path, parent: n });
|
|
2055
|
+
return vr(n, a);
|
|
2056
|
+
}
|
|
2057
|
+
"~validate"(e) {
|
|
2058
|
+
const r = {
|
|
2059
|
+
common: {
|
|
2060
|
+
issues: [],
|
|
2061
|
+
async: !!this["~standard"].async
|
|
2062
|
+
},
|
|
2063
|
+
path: [],
|
|
2064
|
+
schemaErrorMap: this._def.errorMap,
|
|
2065
|
+
parent: null,
|
|
2066
|
+
data: e,
|
|
2067
|
+
parsedType: Se(e)
|
|
2068
|
+
};
|
|
2069
|
+
if (!this["~standard"].async)
|
|
2070
|
+
try {
|
|
2071
|
+
const n = this._parseSync({ data: e, path: [], parent: r });
|
|
2072
|
+
return He(n) ? {
|
|
2073
|
+
value: n.value
|
|
2074
|
+
} : {
|
|
2075
|
+
issues: r.common.issues
|
|
2076
|
+
};
|
|
2077
|
+
} catch (n) {
|
|
2078
|
+
n?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), r.common = {
|
|
2079
|
+
issues: [],
|
|
2080
|
+
async: !0
|
|
2081
|
+
};
|
|
2082
|
+
}
|
|
2083
|
+
return this._parseAsync({ data: e, path: [], parent: r }).then((n) => He(n) ? {
|
|
2084
|
+
value: n.value
|
|
2085
|
+
} : {
|
|
2086
|
+
issues: r.common.issues
|
|
2087
|
+
});
|
|
2088
|
+
}
|
|
2089
|
+
async parseAsync(e, r) {
|
|
2090
|
+
const n = await this.safeParseAsync(e, r);
|
|
2091
|
+
if (n.success)
|
|
2092
|
+
return n.data;
|
|
2093
|
+
throw n.error;
|
|
2094
|
+
}
|
|
2095
|
+
async safeParseAsync(e, r) {
|
|
2096
|
+
const n = {
|
|
2097
|
+
common: {
|
|
2098
|
+
issues: [],
|
|
2099
|
+
contextualErrorMap: r?.errorMap,
|
|
2100
|
+
async: !0
|
|
2101
|
+
},
|
|
2102
|
+
path: r?.path || [],
|
|
2103
|
+
schemaErrorMap: this._def.errorMap,
|
|
2104
|
+
parent: null,
|
|
2105
|
+
data: e,
|
|
2106
|
+
parsedType: Se(e)
|
|
2107
|
+
}, a = this._parse({ data: e, path: n.path, parent: n }), i = await (pt(a) ? a : Promise.resolve(a));
|
|
2108
|
+
return vr(n, i);
|
|
2109
|
+
}
|
|
2110
|
+
refine(e, r) {
|
|
2111
|
+
const n = (a) => typeof r == "string" || typeof r > "u" ? { message: r } : typeof r == "function" ? r(a) : r;
|
|
2112
|
+
return this._refinement((a, i) => {
|
|
2113
|
+
const s = e(a), o = () => i.addIssue({
|
|
2114
|
+
code: h.custom,
|
|
2115
|
+
...n(a)
|
|
2116
|
+
});
|
|
2117
|
+
return typeof Promise < "u" && s instanceof Promise ? s.then((c) => c ? !0 : (o(), !1)) : s ? !0 : (o(), !1);
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
refinement(e, r) {
|
|
2121
|
+
return this._refinement((n, a) => e(n) ? !0 : (a.addIssue(typeof r == "function" ? r(n, a) : r), !1));
|
|
2122
|
+
}
|
|
2123
|
+
_refinement(e) {
|
|
2124
|
+
return new Fe({
|
|
2125
|
+
schema: this,
|
|
2126
|
+
typeName: O.ZodEffects,
|
|
2127
|
+
effect: { type: "refinement", refinement: e }
|
|
2128
|
+
});
|
|
2129
|
+
}
|
|
2130
|
+
superRefine(e) {
|
|
2131
|
+
return this._refinement(e);
|
|
2132
|
+
}
|
|
2133
|
+
constructor(e) {
|
|
2134
|
+
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
2135
|
+
version: 1,
|
|
2136
|
+
vendor: "zod",
|
|
2137
|
+
validate: (r) => this["~validate"](r)
|
|
2138
|
+
};
|
|
2139
|
+
}
|
|
2140
|
+
optional() {
|
|
2141
|
+
return Ce.create(this, this._def);
|
|
2142
|
+
}
|
|
2143
|
+
nullable() {
|
|
2144
|
+
return Ye.create(this, this._def);
|
|
2145
|
+
}
|
|
2146
|
+
nullish() {
|
|
2147
|
+
return this.nullable().optional();
|
|
2148
|
+
}
|
|
2149
|
+
array() {
|
|
2150
|
+
return me.create(this);
|
|
2151
|
+
}
|
|
2152
|
+
promise() {
|
|
2153
|
+
return bt.create(this, this._def);
|
|
2154
|
+
}
|
|
2155
|
+
or(e) {
|
|
2156
|
+
return gt.create([this, e], this._def);
|
|
2157
|
+
}
|
|
2158
|
+
and(e) {
|
|
2159
|
+
return _t.create(this, e, this._def);
|
|
2160
|
+
}
|
|
2161
|
+
transform(e) {
|
|
2162
|
+
return new Fe({
|
|
2163
|
+
...V(this._def),
|
|
2164
|
+
schema: this,
|
|
2165
|
+
typeName: O.ZodEffects,
|
|
2166
|
+
effect: { type: "transform", transform: e }
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2169
|
+
default(e) {
|
|
2170
|
+
const r = typeof e == "function" ? e : () => e;
|
|
2171
|
+
return new xt({
|
|
2172
|
+
...V(this._def),
|
|
2173
|
+
innerType: this,
|
|
2174
|
+
defaultValue: r,
|
|
2175
|
+
typeName: O.ZodDefault
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
brand() {
|
|
2179
|
+
return new Pa({
|
|
2180
|
+
typeName: O.ZodBranded,
|
|
2181
|
+
type: this,
|
|
2182
|
+
...V(this._def)
|
|
2183
|
+
});
|
|
2184
|
+
}
|
|
2185
|
+
catch(e) {
|
|
2186
|
+
const r = typeof e == "function" ? e : () => e;
|
|
2187
|
+
return new zt({
|
|
2188
|
+
...V(this._def),
|
|
2189
|
+
innerType: this,
|
|
2190
|
+
catchValue: r,
|
|
2191
|
+
typeName: O.ZodCatch
|
|
2192
|
+
});
|
|
2193
|
+
}
|
|
2194
|
+
describe(e) {
|
|
2195
|
+
const r = this.constructor;
|
|
2196
|
+
return new r({
|
|
2197
|
+
...this._def,
|
|
2198
|
+
description: e
|
|
2199
|
+
});
|
|
2200
|
+
}
|
|
2201
|
+
pipe(e) {
|
|
2202
|
+
return Jt.create(this, e);
|
|
2203
|
+
}
|
|
2204
|
+
readonly() {
|
|
2205
|
+
return Bt.create(this);
|
|
2206
|
+
}
|
|
2207
|
+
isOptional() {
|
|
2208
|
+
return this.safeParse(void 0).success;
|
|
2209
|
+
}
|
|
2210
|
+
isNullable() {
|
|
2211
|
+
return this.safeParse(null).success;
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
const ha = /^c[^\s-]{8,}$/i, va = /^[0-9a-z]+$/, ma = /^[0-9A-HJKMNP-TV-Z]{26}$/i, pa = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, ya = /^[a-z0-9_-]{21}$/i, ga = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, _a = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, ba = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, xa = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
2215
|
+
let Zt;
|
|
2216
|
+
const ka = /^(?:(?: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])$/, Oa = /^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/, wa = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Sa = /^(([0-9a-fA-F]{1,4}:){7,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}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Ca = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Aa = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Gr = "((\\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])))", ja = new RegExp(`^${Gr}$`);
|
|
2217
|
+
function Yr(t) {
|
|
2218
|
+
let e = "[0-5]\\d";
|
|
2219
|
+
t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
2220
|
+
const r = t.precision ? "+" : "?";
|
|
2221
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`;
|
|
2222
|
+
}
|
|
2223
|
+
function Va(t) {
|
|
2224
|
+
return new RegExp(`^${Yr(t)}$`);
|
|
2225
|
+
}
|
|
2226
|
+
function Ta(t) {
|
|
2227
|
+
let e = `${Gr}T${Yr(t)}`;
|
|
2228
|
+
const r = [];
|
|
2229
|
+
return r.push(t.local ? "Z?" : "Z"), t.offset && r.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${r.join("|")})`, new RegExp(`^${e}$`);
|
|
2230
|
+
}
|
|
2231
|
+
function Ea(t, e) {
|
|
2232
|
+
return !!((e === "v4" || !e) && ka.test(t) || (e === "v6" || !e) && wa.test(t));
|
|
2233
|
+
}
|
|
2234
|
+
function Na(t, e) {
|
|
2235
|
+
if (!ga.test(t))
|
|
2236
|
+
return !1;
|
|
2237
|
+
try {
|
|
2238
|
+
const [r] = t.split(".");
|
|
2239
|
+
if (!r)
|
|
2240
|
+
return !1;
|
|
2241
|
+
const n = r.replace(/-/g, "+").replace(/_/g, "/").padEnd(r.length + (4 - r.length % 4) % 4, "="), a = JSON.parse(atob(n));
|
|
2242
|
+
return !(typeof a != "object" || a === null || "typ" in a && a?.typ !== "JWT" || !a.alg || e && a.alg !== e);
|
|
2243
|
+
} catch {
|
|
2244
|
+
return !1;
|
|
2245
|
+
}
|
|
2246
|
+
}
|
|
2247
|
+
function Ia(t, e) {
|
|
2248
|
+
return !!((e === "v4" || !e) && Oa.test(t) || (e === "v6" || !e) && Sa.test(t));
|
|
2249
|
+
}
|
|
2250
|
+
class _e extends E {
|
|
2251
|
+
_parse(e) {
|
|
2252
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== y.string) {
|
|
2253
|
+
const i = this._getOrReturnCtx(e);
|
|
2254
|
+
return m(i, {
|
|
2255
|
+
code: h.invalid_type,
|
|
2256
|
+
expected: y.string,
|
|
2257
|
+
received: i.parsedType
|
|
2258
|
+
}), w;
|
|
2259
|
+
}
|
|
2260
|
+
const n = new re();
|
|
2261
|
+
let a;
|
|
2262
|
+
for (const i of this._def.checks)
|
|
2263
|
+
if (i.kind === "min")
|
|
2264
|
+
e.data.length < i.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2265
|
+
code: h.too_small,
|
|
2266
|
+
minimum: i.value,
|
|
2267
|
+
type: "string",
|
|
2268
|
+
inclusive: !0,
|
|
2269
|
+
exact: !1,
|
|
2270
|
+
message: i.message
|
|
2271
|
+
}), n.dirty());
|
|
2272
|
+
else if (i.kind === "max")
|
|
2273
|
+
e.data.length > i.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2274
|
+
code: h.too_big,
|
|
2275
|
+
maximum: i.value,
|
|
2276
|
+
type: "string",
|
|
2277
|
+
inclusive: !0,
|
|
2278
|
+
exact: !1,
|
|
2279
|
+
message: i.message
|
|
2280
|
+
}), n.dirty());
|
|
2281
|
+
else if (i.kind === "length") {
|
|
2282
|
+
const s = e.data.length > i.value, o = e.data.length < i.value;
|
|
2283
|
+
(s || o) && (a = this._getOrReturnCtx(e, a), s ? m(a, {
|
|
2284
|
+
code: h.too_big,
|
|
2285
|
+
maximum: i.value,
|
|
2286
|
+
type: "string",
|
|
2287
|
+
inclusive: !0,
|
|
2288
|
+
exact: !0,
|
|
2289
|
+
message: i.message
|
|
2290
|
+
}) : o && m(a, {
|
|
2291
|
+
code: h.too_small,
|
|
2292
|
+
minimum: i.value,
|
|
2293
|
+
type: "string",
|
|
2294
|
+
inclusive: !0,
|
|
2295
|
+
exact: !0,
|
|
2296
|
+
message: i.message
|
|
2297
|
+
}), n.dirty());
|
|
2298
|
+
} else if (i.kind === "email")
|
|
2299
|
+
ba.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2300
|
+
validation: "email",
|
|
2301
|
+
code: h.invalid_string,
|
|
2302
|
+
message: i.message
|
|
2303
|
+
}), n.dirty());
|
|
2304
|
+
else if (i.kind === "emoji")
|
|
2305
|
+
Zt || (Zt = new RegExp(xa, "u")), Zt.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2306
|
+
validation: "emoji",
|
|
2307
|
+
code: h.invalid_string,
|
|
2308
|
+
message: i.message
|
|
2309
|
+
}), n.dirty());
|
|
2310
|
+
else if (i.kind === "uuid")
|
|
2311
|
+
pa.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2312
|
+
validation: "uuid",
|
|
2313
|
+
code: h.invalid_string,
|
|
2314
|
+
message: i.message
|
|
2315
|
+
}), n.dirty());
|
|
2316
|
+
else if (i.kind === "nanoid")
|
|
2317
|
+
ya.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2318
|
+
validation: "nanoid",
|
|
2319
|
+
code: h.invalid_string,
|
|
2320
|
+
message: i.message
|
|
2321
|
+
}), n.dirty());
|
|
2322
|
+
else if (i.kind === "cuid")
|
|
2323
|
+
ha.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2324
|
+
validation: "cuid",
|
|
2325
|
+
code: h.invalid_string,
|
|
2326
|
+
message: i.message
|
|
2327
|
+
}), n.dirty());
|
|
2328
|
+
else if (i.kind === "cuid2")
|
|
2329
|
+
va.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2330
|
+
validation: "cuid2",
|
|
2331
|
+
code: h.invalid_string,
|
|
2332
|
+
message: i.message
|
|
2333
|
+
}), n.dirty());
|
|
2334
|
+
else if (i.kind === "ulid")
|
|
2335
|
+
ma.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2336
|
+
validation: "ulid",
|
|
2337
|
+
code: h.invalid_string,
|
|
2338
|
+
message: i.message
|
|
2339
|
+
}), n.dirty());
|
|
2340
|
+
else if (i.kind === "url")
|
|
2341
|
+
try {
|
|
2342
|
+
new URL(e.data);
|
|
2343
|
+
} catch {
|
|
2344
|
+
a = this._getOrReturnCtx(e, a), m(a, {
|
|
2345
|
+
validation: "url",
|
|
2346
|
+
code: h.invalid_string,
|
|
2347
|
+
message: i.message
|
|
2348
|
+
}), n.dirty();
|
|
2349
|
+
}
|
|
2350
|
+
else i.kind === "regex" ? (i.regex.lastIndex = 0, i.regex.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2351
|
+
validation: "regex",
|
|
2352
|
+
code: h.invalid_string,
|
|
2353
|
+
message: i.message
|
|
2354
|
+
}), n.dirty())) : i.kind === "trim" ? e.data = e.data.trim() : i.kind === "includes" ? e.data.includes(i.value, i.position) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2355
|
+
code: h.invalid_string,
|
|
2356
|
+
validation: { includes: i.value, position: i.position },
|
|
2357
|
+
message: i.message
|
|
2358
|
+
}), n.dirty()) : i.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : i.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : i.kind === "startsWith" ? e.data.startsWith(i.value) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2359
|
+
code: h.invalid_string,
|
|
2360
|
+
validation: { startsWith: i.value },
|
|
2361
|
+
message: i.message
|
|
2362
|
+
}), n.dirty()) : i.kind === "endsWith" ? e.data.endsWith(i.value) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2363
|
+
code: h.invalid_string,
|
|
2364
|
+
validation: { endsWith: i.value },
|
|
2365
|
+
message: i.message
|
|
2366
|
+
}), n.dirty()) : i.kind === "datetime" ? Ta(i).test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2367
|
+
code: h.invalid_string,
|
|
2368
|
+
validation: "datetime",
|
|
2369
|
+
message: i.message
|
|
2370
|
+
}), n.dirty()) : i.kind === "date" ? ja.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2371
|
+
code: h.invalid_string,
|
|
2372
|
+
validation: "date",
|
|
2373
|
+
message: i.message
|
|
2374
|
+
}), n.dirty()) : i.kind === "time" ? Va(i).test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2375
|
+
code: h.invalid_string,
|
|
2376
|
+
validation: "time",
|
|
2377
|
+
message: i.message
|
|
2378
|
+
}), n.dirty()) : i.kind === "duration" ? _a.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2379
|
+
validation: "duration",
|
|
2380
|
+
code: h.invalid_string,
|
|
2381
|
+
message: i.message
|
|
2382
|
+
}), n.dirty()) : i.kind === "ip" ? Ea(e.data, i.version) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2383
|
+
validation: "ip",
|
|
2384
|
+
code: h.invalid_string,
|
|
2385
|
+
message: i.message
|
|
2386
|
+
}), n.dirty()) : i.kind === "jwt" ? Na(e.data, i.alg) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2387
|
+
validation: "jwt",
|
|
2388
|
+
code: h.invalid_string,
|
|
2389
|
+
message: i.message
|
|
2390
|
+
}), n.dirty()) : i.kind === "cidr" ? Ia(e.data, i.version) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2391
|
+
validation: "cidr",
|
|
2392
|
+
code: h.invalid_string,
|
|
2393
|
+
message: i.message
|
|
2394
|
+
}), n.dirty()) : i.kind === "base64" ? Ca.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2395
|
+
validation: "base64",
|
|
2396
|
+
code: h.invalid_string,
|
|
2397
|
+
message: i.message
|
|
2398
|
+
}), n.dirty()) : i.kind === "base64url" ? Aa.test(e.data) || (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2399
|
+
validation: "base64url",
|
|
2400
|
+
code: h.invalid_string,
|
|
2401
|
+
message: i.message
|
|
2402
|
+
}), n.dirty()) : N.assertNever(i);
|
|
2403
|
+
return { status: n.value, value: e.data };
|
|
2404
|
+
}
|
|
2405
|
+
_regex(e, r, n) {
|
|
2406
|
+
return this.refinement((a) => e.test(a), {
|
|
2407
|
+
validation: r,
|
|
2408
|
+
code: h.invalid_string,
|
|
2409
|
+
...g.errToObj(n)
|
|
2410
|
+
});
|
|
2411
|
+
}
|
|
2412
|
+
_addCheck(e) {
|
|
2413
|
+
return new _e({
|
|
2414
|
+
...this._def,
|
|
2415
|
+
checks: [...this._def.checks, e]
|
|
2416
|
+
});
|
|
2417
|
+
}
|
|
2418
|
+
email(e) {
|
|
2419
|
+
return this._addCheck({ kind: "email", ...g.errToObj(e) });
|
|
2420
|
+
}
|
|
2421
|
+
url(e) {
|
|
2422
|
+
return this._addCheck({ kind: "url", ...g.errToObj(e) });
|
|
2423
|
+
}
|
|
2424
|
+
emoji(e) {
|
|
2425
|
+
return this._addCheck({ kind: "emoji", ...g.errToObj(e) });
|
|
2426
|
+
}
|
|
2427
|
+
uuid(e) {
|
|
2428
|
+
return this._addCheck({ kind: "uuid", ...g.errToObj(e) });
|
|
2429
|
+
}
|
|
2430
|
+
nanoid(e) {
|
|
2431
|
+
return this._addCheck({ kind: "nanoid", ...g.errToObj(e) });
|
|
2432
|
+
}
|
|
2433
|
+
cuid(e) {
|
|
2434
|
+
return this._addCheck({ kind: "cuid", ...g.errToObj(e) });
|
|
2435
|
+
}
|
|
2436
|
+
cuid2(e) {
|
|
2437
|
+
return this._addCheck({ kind: "cuid2", ...g.errToObj(e) });
|
|
2438
|
+
}
|
|
2439
|
+
ulid(e) {
|
|
2440
|
+
return this._addCheck({ kind: "ulid", ...g.errToObj(e) });
|
|
2441
|
+
}
|
|
2442
|
+
base64(e) {
|
|
2443
|
+
return this._addCheck({ kind: "base64", ...g.errToObj(e) });
|
|
2444
|
+
}
|
|
2445
|
+
base64url(e) {
|
|
2446
|
+
return this._addCheck({
|
|
2447
|
+
kind: "base64url",
|
|
2448
|
+
...g.errToObj(e)
|
|
2449
|
+
});
|
|
2450
|
+
}
|
|
2451
|
+
jwt(e) {
|
|
2452
|
+
return this._addCheck({ kind: "jwt", ...g.errToObj(e) });
|
|
2453
|
+
}
|
|
2454
|
+
ip(e) {
|
|
2455
|
+
return this._addCheck({ kind: "ip", ...g.errToObj(e) });
|
|
2456
|
+
}
|
|
2457
|
+
cidr(e) {
|
|
2458
|
+
return this._addCheck({ kind: "cidr", ...g.errToObj(e) });
|
|
2459
|
+
}
|
|
2460
|
+
datetime(e) {
|
|
2461
|
+
return typeof e == "string" ? this._addCheck({
|
|
2462
|
+
kind: "datetime",
|
|
2463
|
+
precision: null,
|
|
2464
|
+
offset: !1,
|
|
2465
|
+
local: !1,
|
|
2466
|
+
message: e
|
|
2467
|
+
}) : this._addCheck({
|
|
2468
|
+
kind: "datetime",
|
|
2469
|
+
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
2470
|
+
offset: e?.offset ?? !1,
|
|
2471
|
+
local: e?.local ?? !1,
|
|
2472
|
+
...g.errToObj(e?.message)
|
|
2473
|
+
});
|
|
2474
|
+
}
|
|
2475
|
+
date(e) {
|
|
2476
|
+
return this._addCheck({ kind: "date", message: e });
|
|
2477
|
+
}
|
|
2478
|
+
time(e) {
|
|
2479
|
+
return typeof e == "string" ? this._addCheck({
|
|
2480
|
+
kind: "time",
|
|
2481
|
+
precision: null,
|
|
2482
|
+
message: e
|
|
2483
|
+
}) : this._addCheck({
|
|
2484
|
+
kind: "time",
|
|
2485
|
+
precision: typeof e?.precision > "u" ? null : e?.precision,
|
|
2486
|
+
...g.errToObj(e?.message)
|
|
2487
|
+
});
|
|
2488
|
+
}
|
|
2489
|
+
duration(e) {
|
|
2490
|
+
return this._addCheck({ kind: "duration", ...g.errToObj(e) });
|
|
2491
|
+
}
|
|
2492
|
+
regex(e, r) {
|
|
2493
|
+
return this._addCheck({
|
|
2494
|
+
kind: "regex",
|
|
2495
|
+
regex: e,
|
|
2496
|
+
...g.errToObj(r)
|
|
2497
|
+
});
|
|
2498
|
+
}
|
|
2499
|
+
includes(e, r) {
|
|
2500
|
+
return this._addCheck({
|
|
2501
|
+
kind: "includes",
|
|
2502
|
+
value: e,
|
|
2503
|
+
position: r?.position,
|
|
2504
|
+
...g.errToObj(r?.message)
|
|
2505
|
+
});
|
|
2506
|
+
}
|
|
2507
|
+
startsWith(e, r) {
|
|
2508
|
+
return this._addCheck({
|
|
2509
|
+
kind: "startsWith",
|
|
2510
|
+
value: e,
|
|
2511
|
+
...g.errToObj(r)
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
endsWith(e, r) {
|
|
2515
|
+
return this._addCheck({
|
|
2516
|
+
kind: "endsWith",
|
|
2517
|
+
value: e,
|
|
2518
|
+
...g.errToObj(r)
|
|
2519
|
+
});
|
|
2520
|
+
}
|
|
2521
|
+
min(e, r) {
|
|
2522
|
+
return this._addCheck({
|
|
2523
|
+
kind: "min",
|
|
2524
|
+
value: e,
|
|
2525
|
+
...g.errToObj(r)
|
|
2526
|
+
});
|
|
2527
|
+
}
|
|
2528
|
+
max(e, r) {
|
|
2529
|
+
return this._addCheck({
|
|
2530
|
+
kind: "max",
|
|
2531
|
+
value: e,
|
|
2532
|
+
...g.errToObj(r)
|
|
2533
|
+
});
|
|
2534
|
+
}
|
|
2535
|
+
length(e, r) {
|
|
2536
|
+
return this._addCheck({
|
|
2537
|
+
kind: "length",
|
|
2538
|
+
value: e,
|
|
2539
|
+
...g.errToObj(r)
|
|
2540
|
+
});
|
|
2541
|
+
}
|
|
2542
|
+
/**
|
|
2543
|
+
* Equivalent to `.min(1)`
|
|
2544
|
+
*/
|
|
2545
|
+
nonempty(e) {
|
|
2546
|
+
return this.min(1, g.errToObj(e));
|
|
2547
|
+
}
|
|
2548
|
+
trim() {
|
|
2549
|
+
return new _e({
|
|
2550
|
+
...this._def,
|
|
2551
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
toLowerCase() {
|
|
2555
|
+
return new _e({
|
|
2556
|
+
...this._def,
|
|
2557
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
2558
|
+
});
|
|
2559
|
+
}
|
|
2560
|
+
toUpperCase() {
|
|
2561
|
+
return new _e({
|
|
2562
|
+
...this._def,
|
|
2563
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
get isDatetime() {
|
|
2567
|
+
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
2568
|
+
}
|
|
2569
|
+
get isDate() {
|
|
2570
|
+
return !!this._def.checks.find((e) => e.kind === "date");
|
|
2571
|
+
}
|
|
2572
|
+
get isTime() {
|
|
2573
|
+
return !!this._def.checks.find((e) => e.kind === "time");
|
|
2574
|
+
}
|
|
2575
|
+
get isDuration() {
|
|
2576
|
+
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
2577
|
+
}
|
|
2578
|
+
get isEmail() {
|
|
2579
|
+
return !!this._def.checks.find((e) => e.kind === "email");
|
|
2580
|
+
}
|
|
2581
|
+
get isURL() {
|
|
2582
|
+
return !!this._def.checks.find((e) => e.kind === "url");
|
|
2583
|
+
}
|
|
2584
|
+
get isEmoji() {
|
|
2585
|
+
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
2586
|
+
}
|
|
2587
|
+
get isUUID() {
|
|
2588
|
+
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
2589
|
+
}
|
|
2590
|
+
get isNANOID() {
|
|
2591
|
+
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
2592
|
+
}
|
|
2593
|
+
get isCUID() {
|
|
2594
|
+
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
2595
|
+
}
|
|
2596
|
+
get isCUID2() {
|
|
2597
|
+
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
2598
|
+
}
|
|
2599
|
+
get isULID() {
|
|
2600
|
+
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
2601
|
+
}
|
|
2602
|
+
get isIP() {
|
|
2603
|
+
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
2604
|
+
}
|
|
2605
|
+
get isCIDR() {
|
|
2606
|
+
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
2607
|
+
}
|
|
2608
|
+
get isBase64() {
|
|
2609
|
+
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
2610
|
+
}
|
|
2611
|
+
get isBase64url() {
|
|
2612
|
+
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
2613
|
+
}
|
|
2614
|
+
get minLength() {
|
|
2615
|
+
let e = null;
|
|
2616
|
+
for (const r of this._def.checks)
|
|
2617
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
2618
|
+
return e;
|
|
2619
|
+
}
|
|
2620
|
+
get maxLength() {
|
|
2621
|
+
let e = null;
|
|
2622
|
+
for (const r of this._def.checks)
|
|
2623
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
2624
|
+
return e;
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
_e.create = (t) => new _e({
|
|
2628
|
+
checks: [],
|
|
2629
|
+
typeName: O.ZodString,
|
|
2630
|
+
coerce: t?.coerce ?? !1,
|
|
2631
|
+
...V(t)
|
|
2632
|
+
});
|
|
2633
|
+
function Ra(t, e) {
|
|
2634
|
+
const r = (t.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, a = r > n ? r : n, i = Number.parseInt(t.toFixed(a).replace(".", "")), s = Number.parseInt(e.toFixed(a).replace(".", ""));
|
|
2635
|
+
return i % s / 10 ** a;
|
|
2636
|
+
}
|
|
2637
|
+
class Pe extends E {
|
|
2638
|
+
constructor() {
|
|
2639
|
+
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
2640
|
+
}
|
|
2641
|
+
_parse(e) {
|
|
2642
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== y.number) {
|
|
2643
|
+
const i = this._getOrReturnCtx(e);
|
|
2644
|
+
return m(i, {
|
|
2645
|
+
code: h.invalid_type,
|
|
2646
|
+
expected: y.number,
|
|
2647
|
+
received: i.parsedType
|
|
2648
|
+
}), w;
|
|
2649
|
+
}
|
|
2650
|
+
let n;
|
|
2651
|
+
const a = new re();
|
|
2652
|
+
for (const i of this._def.checks)
|
|
2653
|
+
i.kind === "int" ? N.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), m(n, {
|
|
2654
|
+
code: h.invalid_type,
|
|
2655
|
+
expected: "integer",
|
|
2656
|
+
received: "float",
|
|
2657
|
+
message: i.message
|
|
2658
|
+
}), a.dirty()) : i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (n = this._getOrReturnCtx(e, n), m(n, {
|
|
2659
|
+
code: h.too_small,
|
|
2660
|
+
minimum: i.value,
|
|
2661
|
+
type: "number",
|
|
2662
|
+
inclusive: i.inclusive,
|
|
2663
|
+
exact: !1,
|
|
2664
|
+
message: i.message
|
|
2665
|
+
}), a.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (n = this._getOrReturnCtx(e, n), m(n, {
|
|
2666
|
+
code: h.too_big,
|
|
2667
|
+
maximum: i.value,
|
|
2668
|
+
type: "number",
|
|
2669
|
+
inclusive: i.inclusive,
|
|
2670
|
+
exact: !1,
|
|
2671
|
+
message: i.message
|
|
2672
|
+
}), a.dirty()) : i.kind === "multipleOf" ? Ra(e.data, i.value) !== 0 && (n = this._getOrReturnCtx(e, n), m(n, {
|
|
2673
|
+
code: h.not_multiple_of,
|
|
2674
|
+
multipleOf: i.value,
|
|
2675
|
+
message: i.message
|
|
2676
|
+
}), a.dirty()) : i.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), m(n, {
|
|
2677
|
+
code: h.not_finite,
|
|
2678
|
+
message: i.message
|
|
2679
|
+
}), a.dirty()) : N.assertNever(i);
|
|
2680
|
+
return { status: a.value, value: e.data };
|
|
2681
|
+
}
|
|
2682
|
+
gte(e, r) {
|
|
2683
|
+
return this.setLimit("min", e, !0, g.toString(r));
|
|
2684
|
+
}
|
|
2685
|
+
gt(e, r) {
|
|
2686
|
+
return this.setLimit("min", e, !1, g.toString(r));
|
|
2687
|
+
}
|
|
2688
|
+
lte(e, r) {
|
|
2689
|
+
return this.setLimit("max", e, !0, g.toString(r));
|
|
2690
|
+
}
|
|
2691
|
+
lt(e, r) {
|
|
2692
|
+
return this.setLimit("max", e, !1, g.toString(r));
|
|
2693
|
+
}
|
|
2694
|
+
setLimit(e, r, n, a) {
|
|
2695
|
+
return new Pe({
|
|
2696
|
+
...this._def,
|
|
2697
|
+
checks: [
|
|
2698
|
+
...this._def.checks,
|
|
2699
|
+
{
|
|
2700
|
+
kind: e,
|
|
2701
|
+
value: r,
|
|
2702
|
+
inclusive: n,
|
|
2703
|
+
message: g.toString(a)
|
|
2704
|
+
}
|
|
2705
|
+
]
|
|
2706
|
+
});
|
|
2707
|
+
}
|
|
2708
|
+
_addCheck(e) {
|
|
2709
|
+
return new Pe({
|
|
2710
|
+
...this._def,
|
|
2711
|
+
checks: [...this._def.checks, e]
|
|
2712
|
+
});
|
|
2713
|
+
}
|
|
2714
|
+
int(e) {
|
|
2715
|
+
return this._addCheck({
|
|
2716
|
+
kind: "int",
|
|
2717
|
+
message: g.toString(e)
|
|
2718
|
+
});
|
|
2719
|
+
}
|
|
2720
|
+
positive(e) {
|
|
2721
|
+
return this._addCheck({
|
|
2722
|
+
kind: "min",
|
|
2723
|
+
value: 0,
|
|
2724
|
+
inclusive: !1,
|
|
2725
|
+
message: g.toString(e)
|
|
2726
|
+
});
|
|
2727
|
+
}
|
|
2728
|
+
negative(e) {
|
|
2729
|
+
return this._addCheck({
|
|
2730
|
+
kind: "max",
|
|
2731
|
+
value: 0,
|
|
2732
|
+
inclusive: !1,
|
|
2733
|
+
message: g.toString(e)
|
|
2734
|
+
});
|
|
2735
|
+
}
|
|
2736
|
+
nonpositive(e) {
|
|
2737
|
+
return this._addCheck({
|
|
2738
|
+
kind: "max",
|
|
2739
|
+
value: 0,
|
|
2740
|
+
inclusive: !0,
|
|
2741
|
+
message: g.toString(e)
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2744
|
+
nonnegative(e) {
|
|
2745
|
+
return this._addCheck({
|
|
2746
|
+
kind: "min",
|
|
2747
|
+
value: 0,
|
|
2748
|
+
inclusive: !0,
|
|
2749
|
+
message: g.toString(e)
|
|
2750
|
+
});
|
|
2751
|
+
}
|
|
2752
|
+
multipleOf(e, r) {
|
|
2753
|
+
return this._addCheck({
|
|
2754
|
+
kind: "multipleOf",
|
|
2755
|
+
value: e,
|
|
2756
|
+
message: g.toString(r)
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
finite(e) {
|
|
2760
|
+
return this._addCheck({
|
|
2761
|
+
kind: "finite",
|
|
2762
|
+
message: g.toString(e)
|
|
2763
|
+
});
|
|
2764
|
+
}
|
|
2765
|
+
safe(e) {
|
|
2766
|
+
return this._addCheck({
|
|
2767
|
+
kind: "min",
|
|
2768
|
+
inclusive: !0,
|
|
2769
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
2770
|
+
message: g.toString(e)
|
|
2771
|
+
})._addCheck({
|
|
2772
|
+
kind: "max",
|
|
2773
|
+
inclusive: !0,
|
|
2774
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
2775
|
+
message: g.toString(e)
|
|
2776
|
+
});
|
|
2777
|
+
}
|
|
2778
|
+
get minValue() {
|
|
2779
|
+
let e = null;
|
|
2780
|
+
for (const r of this._def.checks)
|
|
2781
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
2782
|
+
return e;
|
|
2783
|
+
}
|
|
2784
|
+
get maxValue() {
|
|
2785
|
+
let e = null;
|
|
2786
|
+
for (const r of this._def.checks)
|
|
2787
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
2788
|
+
return e;
|
|
2789
|
+
}
|
|
2790
|
+
get isInt() {
|
|
2791
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && N.isInteger(e.value));
|
|
2792
|
+
}
|
|
2793
|
+
get isFinite() {
|
|
2794
|
+
let e = null, r = null;
|
|
2795
|
+
for (const n of this._def.checks) {
|
|
2796
|
+
if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
|
|
2797
|
+
return !0;
|
|
2798
|
+
n.kind === "min" ? (r === null || n.value > r) && (r = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
2799
|
+
}
|
|
2800
|
+
return Number.isFinite(r) && Number.isFinite(e);
|
|
2801
|
+
}
|
|
2802
|
+
}
|
|
2803
|
+
Pe.create = (t) => new Pe({
|
|
2804
|
+
checks: [],
|
|
2805
|
+
typeName: O.ZodNumber,
|
|
2806
|
+
coerce: t?.coerce || !1,
|
|
2807
|
+
...V(t)
|
|
2808
|
+
});
|
|
2809
|
+
class Ze extends E {
|
|
2810
|
+
constructor() {
|
|
2811
|
+
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
2812
|
+
}
|
|
2813
|
+
_parse(e) {
|
|
2814
|
+
if (this._def.coerce)
|
|
2815
|
+
try {
|
|
2816
|
+
e.data = BigInt(e.data);
|
|
2817
|
+
} catch {
|
|
2818
|
+
return this._getInvalidInput(e);
|
|
2819
|
+
}
|
|
2820
|
+
if (this._getType(e) !== y.bigint)
|
|
2821
|
+
return this._getInvalidInput(e);
|
|
2822
|
+
let n;
|
|
2823
|
+
const a = new re();
|
|
2824
|
+
for (const i of this._def.checks)
|
|
2825
|
+
i.kind === "min" ? (i.inclusive ? e.data < i.value : e.data <= i.value) && (n = this._getOrReturnCtx(e, n), m(n, {
|
|
2826
|
+
code: h.too_small,
|
|
2827
|
+
type: "bigint",
|
|
2828
|
+
minimum: i.value,
|
|
2829
|
+
inclusive: i.inclusive,
|
|
2830
|
+
message: i.message
|
|
2831
|
+
}), a.dirty()) : i.kind === "max" ? (i.inclusive ? e.data > i.value : e.data >= i.value) && (n = this._getOrReturnCtx(e, n), m(n, {
|
|
2832
|
+
code: h.too_big,
|
|
2833
|
+
type: "bigint",
|
|
2834
|
+
maximum: i.value,
|
|
2835
|
+
inclusive: i.inclusive,
|
|
2836
|
+
message: i.message
|
|
2837
|
+
}), a.dirty()) : i.kind === "multipleOf" ? e.data % i.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), m(n, {
|
|
2838
|
+
code: h.not_multiple_of,
|
|
2839
|
+
multipleOf: i.value,
|
|
2840
|
+
message: i.message
|
|
2841
|
+
}), a.dirty()) : N.assertNever(i);
|
|
2842
|
+
return { status: a.value, value: e.data };
|
|
2843
|
+
}
|
|
2844
|
+
_getInvalidInput(e) {
|
|
2845
|
+
const r = this._getOrReturnCtx(e);
|
|
2846
|
+
return m(r, {
|
|
2847
|
+
code: h.invalid_type,
|
|
2848
|
+
expected: y.bigint,
|
|
2849
|
+
received: r.parsedType
|
|
2850
|
+
}), w;
|
|
2851
|
+
}
|
|
2852
|
+
gte(e, r) {
|
|
2853
|
+
return this.setLimit("min", e, !0, g.toString(r));
|
|
2854
|
+
}
|
|
2855
|
+
gt(e, r) {
|
|
2856
|
+
return this.setLimit("min", e, !1, g.toString(r));
|
|
2857
|
+
}
|
|
2858
|
+
lte(e, r) {
|
|
2859
|
+
return this.setLimit("max", e, !0, g.toString(r));
|
|
2860
|
+
}
|
|
2861
|
+
lt(e, r) {
|
|
2862
|
+
return this.setLimit("max", e, !1, g.toString(r));
|
|
2863
|
+
}
|
|
2864
|
+
setLimit(e, r, n, a) {
|
|
2865
|
+
return new Ze({
|
|
2866
|
+
...this._def,
|
|
2867
|
+
checks: [
|
|
2868
|
+
...this._def.checks,
|
|
2869
|
+
{
|
|
2870
|
+
kind: e,
|
|
2871
|
+
value: r,
|
|
2872
|
+
inclusive: n,
|
|
2873
|
+
message: g.toString(a)
|
|
2874
|
+
}
|
|
2875
|
+
]
|
|
2876
|
+
});
|
|
2877
|
+
}
|
|
2878
|
+
_addCheck(e) {
|
|
2879
|
+
return new Ze({
|
|
2880
|
+
...this._def,
|
|
2881
|
+
checks: [...this._def.checks, e]
|
|
2882
|
+
});
|
|
2883
|
+
}
|
|
2884
|
+
positive(e) {
|
|
2885
|
+
return this._addCheck({
|
|
2886
|
+
kind: "min",
|
|
2887
|
+
value: BigInt(0),
|
|
2888
|
+
inclusive: !1,
|
|
2889
|
+
message: g.toString(e)
|
|
2890
|
+
});
|
|
2891
|
+
}
|
|
2892
|
+
negative(e) {
|
|
2893
|
+
return this._addCheck({
|
|
2894
|
+
kind: "max",
|
|
2895
|
+
value: BigInt(0),
|
|
2896
|
+
inclusive: !1,
|
|
2897
|
+
message: g.toString(e)
|
|
2898
|
+
});
|
|
2899
|
+
}
|
|
2900
|
+
nonpositive(e) {
|
|
2901
|
+
return this._addCheck({
|
|
2902
|
+
kind: "max",
|
|
2903
|
+
value: BigInt(0),
|
|
2904
|
+
inclusive: !0,
|
|
2905
|
+
message: g.toString(e)
|
|
2906
|
+
});
|
|
2907
|
+
}
|
|
2908
|
+
nonnegative(e) {
|
|
2909
|
+
return this._addCheck({
|
|
2910
|
+
kind: "min",
|
|
2911
|
+
value: BigInt(0),
|
|
2912
|
+
inclusive: !0,
|
|
2913
|
+
message: g.toString(e)
|
|
2914
|
+
});
|
|
2915
|
+
}
|
|
2916
|
+
multipleOf(e, r) {
|
|
2917
|
+
return this._addCheck({
|
|
2918
|
+
kind: "multipleOf",
|
|
2919
|
+
value: e,
|
|
2920
|
+
message: g.toString(r)
|
|
2921
|
+
});
|
|
2922
|
+
}
|
|
2923
|
+
get minValue() {
|
|
2924
|
+
let e = null;
|
|
2925
|
+
for (const r of this._def.checks)
|
|
2926
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
2927
|
+
return e;
|
|
2928
|
+
}
|
|
2929
|
+
get maxValue() {
|
|
2930
|
+
let e = null;
|
|
2931
|
+
for (const r of this._def.checks)
|
|
2932
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
2933
|
+
return e;
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
Ze.create = (t) => new Ze({
|
|
2937
|
+
checks: [],
|
|
2938
|
+
typeName: O.ZodBigInt,
|
|
2939
|
+
coerce: t?.coerce ?? !1,
|
|
2940
|
+
...V(t)
|
|
2941
|
+
});
|
|
2942
|
+
class yt extends E {
|
|
2943
|
+
_parse(e) {
|
|
2944
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== y.boolean) {
|
|
2945
|
+
const n = this._getOrReturnCtx(e);
|
|
2946
|
+
return m(n, {
|
|
2947
|
+
code: h.invalid_type,
|
|
2948
|
+
expected: y.boolean,
|
|
2949
|
+
received: n.parsedType
|
|
2950
|
+
}), w;
|
|
2951
|
+
}
|
|
2952
|
+
return ue(e.data);
|
|
2953
|
+
}
|
|
2954
|
+
}
|
|
2955
|
+
yt.create = (t) => new yt({
|
|
2956
|
+
typeName: O.ZodBoolean,
|
|
2957
|
+
coerce: t?.coerce || !1,
|
|
2958
|
+
...V(t)
|
|
2959
|
+
});
|
|
2960
|
+
class Je extends E {
|
|
2961
|
+
_parse(e) {
|
|
2962
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== y.date) {
|
|
2963
|
+
const i = this._getOrReturnCtx(e);
|
|
2964
|
+
return m(i, {
|
|
2965
|
+
code: h.invalid_type,
|
|
2966
|
+
expected: y.date,
|
|
2967
|
+
received: i.parsedType
|
|
2968
|
+
}), w;
|
|
2969
|
+
}
|
|
2970
|
+
if (Number.isNaN(e.data.getTime())) {
|
|
2971
|
+
const i = this._getOrReturnCtx(e);
|
|
2972
|
+
return m(i, {
|
|
2973
|
+
code: h.invalid_date
|
|
2974
|
+
}), w;
|
|
2975
|
+
}
|
|
2976
|
+
const n = new re();
|
|
2977
|
+
let a;
|
|
2978
|
+
for (const i of this._def.checks)
|
|
2979
|
+
i.kind === "min" ? e.data.getTime() < i.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2980
|
+
code: h.too_small,
|
|
2981
|
+
message: i.message,
|
|
2982
|
+
inclusive: !0,
|
|
2983
|
+
exact: !1,
|
|
2984
|
+
minimum: i.value,
|
|
2985
|
+
type: "date"
|
|
2986
|
+
}), n.dirty()) : i.kind === "max" ? e.data.getTime() > i.value && (a = this._getOrReturnCtx(e, a), m(a, {
|
|
2987
|
+
code: h.too_big,
|
|
2988
|
+
message: i.message,
|
|
2989
|
+
inclusive: !0,
|
|
2990
|
+
exact: !1,
|
|
2991
|
+
maximum: i.value,
|
|
2992
|
+
type: "date"
|
|
2993
|
+
}), n.dirty()) : N.assertNever(i);
|
|
2994
|
+
return {
|
|
2995
|
+
status: n.value,
|
|
2996
|
+
value: new Date(e.data.getTime())
|
|
2997
|
+
};
|
|
2998
|
+
}
|
|
2999
|
+
_addCheck(e) {
|
|
3000
|
+
return new Je({
|
|
3001
|
+
...this._def,
|
|
3002
|
+
checks: [...this._def.checks, e]
|
|
3003
|
+
});
|
|
3004
|
+
}
|
|
3005
|
+
min(e, r) {
|
|
3006
|
+
return this._addCheck({
|
|
3007
|
+
kind: "min",
|
|
3008
|
+
value: e.getTime(),
|
|
3009
|
+
message: g.toString(r)
|
|
3010
|
+
});
|
|
3011
|
+
}
|
|
3012
|
+
max(e, r) {
|
|
3013
|
+
return this._addCheck({
|
|
3014
|
+
kind: "max",
|
|
3015
|
+
value: e.getTime(),
|
|
3016
|
+
message: g.toString(r)
|
|
3017
|
+
});
|
|
3018
|
+
}
|
|
3019
|
+
get minDate() {
|
|
3020
|
+
let e = null;
|
|
3021
|
+
for (const r of this._def.checks)
|
|
3022
|
+
r.kind === "min" && (e === null || r.value > e) && (e = r.value);
|
|
3023
|
+
return e != null ? new Date(e) : null;
|
|
3024
|
+
}
|
|
3025
|
+
get maxDate() {
|
|
3026
|
+
let e = null;
|
|
3027
|
+
for (const r of this._def.checks)
|
|
3028
|
+
r.kind === "max" && (e === null || r.value < e) && (e = r.value);
|
|
3029
|
+
return e != null ? new Date(e) : null;
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
Je.create = (t) => new Je({
|
|
3033
|
+
checks: [],
|
|
3034
|
+
coerce: t?.coerce || !1,
|
|
3035
|
+
typeName: O.ZodDate,
|
|
3036
|
+
...V(t)
|
|
3037
|
+
});
|
|
3038
|
+
class mr extends E {
|
|
3039
|
+
_parse(e) {
|
|
3040
|
+
if (this._getType(e) !== y.symbol) {
|
|
3041
|
+
const n = this._getOrReturnCtx(e);
|
|
3042
|
+
return m(n, {
|
|
3043
|
+
code: h.invalid_type,
|
|
3044
|
+
expected: y.symbol,
|
|
3045
|
+
received: n.parsedType
|
|
3046
|
+
}), w;
|
|
3047
|
+
}
|
|
3048
|
+
return ue(e.data);
|
|
3049
|
+
}
|
|
3050
|
+
}
|
|
3051
|
+
mr.create = (t) => new mr({
|
|
3052
|
+
typeName: O.ZodSymbol,
|
|
3053
|
+
...V(t)
|
|
3054
|
+
});
|
|
3055
|
+
class pr extends E {
|
|
3056
|
+
_parse(e) {
|
|
3057
|
+
if (this._getType(e) !== y.undefined) {
|
|
3058
|
+
const n = this._getOrReturnCtx(e);
|
|
3059
|
+
return m(n, {
|
|
3060
|
+
code: h.invalid_type,
|
|
3061
|
+
expected: y.undefined,
|
|
3062
|
+
received: n.parsedType
|
|
3063
|
+
}), w;
|
|
3064
|
+
}
|
|
3065
|
+
return ue(e.data);
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
pr.create = (t) => new pr({
|
|
3069
|
+
typeName: O.ZodUndefined,
|
|
3070
|
+
...V(t)
|
|
3071
|
+
});
|
|
3072
|
+
class yr extends E {
|
|
3073
|
+
_parse(e) {
|
|
3074
|
+
if (this._getType(e) !== y.null) {
|
|
3075
|
+
const n = this._getOrReturnCtx(e);
|
|
3076
|
+
return m(n, {
|
|
3077
|
+
code: h.invalid_type,
|
|
3078
|
+
expected: y.null,
|
|
3079
|
+
received: n.parsedType
|
|
3080
|
+
}), w;
|
|
3081
|
+
}
|
|
3082
|
+
return ue(e.data);
|
|
3083
|
+
}
|
|
3084
|
+
}
|
|
3085
|
+
yr.create = (t) => new yr({
|
|
3086
|
+
typeName: O.ZodNull,
|
|
3087
|
+
...V(t)
|
|
3088
|
+
});
|
|
3089
|
+
class gr extends E {
|
|
3090
|
+
constructor() {
|
|
3091
|
+
super(...arguments), this._any = !0;
|
|
3092
|
+
}
|
|
3093
|
+
_parse(e) {
|
|
3094
|
+
return ue(e.data);
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
gr.create = (t) => new gr({
|
|
3098
|
+
typeName: O.ZodAny,
|
|
3099
|
+
...V(t)
|
|
3100
|
+
});
|
|
3101
|
+
class _r extends E {
|
|
3102
|
+
constructor() {
|
|
3103
|
+
super(...arguments), this._unknown = !0;
|
|
3104
|
+
}
|
|
3105
|
+
_parse(e) {
|
|
3106
|
+
return ue(e.data);
|
|
3107
|
+
}
|
|
3108
|
+
}
|
|
3109
|
+
_r.create = (t) => new _r({
|
|
3110
|
+
typeName: O.ZodUnknown,
|
|
3111
|
+
...V(t)
|
|
3112
|
+
});
|
|
3113
|
+
class Ve extends E {
|
|
3114
|
+
_parse(e) {
|
|
3115
|
+
const r = this._getOrReturnCtx(e);
|
|
3116
|
+
return m(r, {
|
|
3117
|
+
code: h.invalid_type,
|
|
3118
|
+
expected: y.never,
|
|
3119
|
+
received: r.parsedType
|
|
3120
|
+
}), w;
|
|
3121
|
+
}
|
|
3122
|
+
}
|
|
3123
|
+
Ve.create = (t) => new Ve({
|
|
3124
|
+
typeName: O.ZodNever,
|
|
3125
|
+
...V(t)
|
|
3126
|
+
});
|
|
3127
|
+
class br extends E {
|
|
3128
|
+
_parse(e) {
|
|
3129
|
+
if (this._getType(e) !== y.undefined) {
|
|
3130
|
+
const n = this._getOrReturnCtx(e);
|
|
3131
|
+
return m(n, {
|
|
3132
|
+
code: h.invalid_type,
|
|
3133
|
+
expected: y.void,
|
|
3134
|
+
received: n.parsedType
|
|
3135
|
+
}), w;
|
|
3136
|
+
}
|
|
3137
|
+
return ue(e.data);
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
br.create = (t) => new br({
|
|
3141
|
+
typeName: O.ZodVoid,
|
|
3142
|
+
...V(t)
|
|
3143
|
+
});
|
|
3144
|
+
class me extends E {
|
|
3145
|
+
_parse(e) {
|
|
3146
|
+
const { ctx: r, status: n } = this._processInputParams(e), a = this._def;
|
|
3147
|
+
if (r.parsedType !== y.array)
|
|
3148
|
+
return m(r, {
|
|
3149
|
+
code: h.invalid_type,
|
|
3150
|
+
expected: y.array,
|
|
3151
|
+
received: r.parsedType
|
|
3152
|
+
}), w;
|
|
3153
|
+
if (a.exactLength !== null) {
|
|
3154
|
+
const s = r.data.length > a.exactLength.value, o = r.data.length < a.exactLength.value;
|
|
3155
|
+
(s || o) && (m(r, {
|
|
3156
|
+
code: s ? h.too_big : h.too_small,
|
|
3157
|
+
minimum: o ? a.exactLength.value : void 0,
|
|
3158
|
+
maximum: s ? a.exactLength.value : void 0,
|
|
3159
|
+
type: "array",
|
|
3160
|
+
inclusive: !0,
|
|
3161
|
+
exact: !0,
|
|
3162
|
+
message: a.exactLength.message
|
|
3163
|
+
}), n.dirty());
|
|
3164
|
+
}
|
|
3165
|
+
if (a.minLength !== null && r.data.length < a.minLength.value && (m(r, {
|
|
3166
|
+
code: h.too_small,
|
|
3167
|
+
minimum: a.minLength.value,
|
|
3168
|
+
type: "array",
|
|
3169
|
+
inclusive: !0,
|
|
3170
|
+
exact: !1,
|
|
3171
|
+
message: a.minLength.message
|
|
3172
|
+
}), n.dirty()), a.maxLength !== null && r.data.length > a.maxLength.value && (m(r, {
|
|
3173
|
+
code: h.too_big,
|
|
3174
|
+
maximum: a.maxLength.value,
|
|
3175
|
+
type: "array",
|
|
3176
|
+
inclusive: !0,
|
|
3177
|
+
exact: !1,
|
|
3178
|
+
message: a.maxLength.message
|
|
3179
|
+
}), n.dirty()), r.common.async)
|
|
3180
|
+
return Promise.all([...r.data].map((s, o) => a.type._parseAsync(new je(r, s, r.path, o)))).then((s) => re.mergeArray(n, s));
|
|
3181
|
+
const i = [...r.data].map((s, o) => a.type._parseSync(new je(r, s, r.path, o)));
|
|
3182
|
+
return re.mergeArray(n, i);
|
|
3183
|
+
}
|
|
3184
|
+
get element() {
|
|
3185
|
+
return this._def.type;
|
|
3186
|
+
}
|
|
3187
|
+
min(e, r) {
|
|
3188
|
+
return new me({
|
|
3189
|
+
...this._def,
|
|
3190
|
+
minLength: { value: e, message: g.toString(r) }
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3193
|
+
max(e, r) {
|
|
3194
|
+
return new me({
|
|
3195
|
+
...this._def,
|
|
3196
|
+
maxLength: { value: e, message: g.toString(r) }
|
|
3197
|
+
});
|
|
3198
|
+
}
|
|
3199
|
+
length(e, r) {
|
|
3200
|
+
return new me({
|
|
3201
|
+
...this._def,
|
|
3202
|
+
exactLength: { value: e, message: g.toString(r) }
|
|
3203
|
+
});
|
|
3204
|
+
}
|
|
3205
|
+
nonempty(e) {
|
|
3206
|
+
return this.min(1, e);
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
me.create = (t, e) => new me({
|
|
3210
|
+
type: t,
|
|
3211
|
+
minLength: null,
|
|
3212
|
+
maxLength: null,
|
|
3213
|
+
exactLength: null,
|
|
3214
|
+
typeName: O.ZodArray,
|
|
3215
|
+
...V(e)
|
|
3216
|
+
});
|
|
3217
|
+
function Be(t) {
|
|
3218
|
+
if (t instanceof L) {
|
|
3219
|
+
const e = {};
|
|
3220
|
+
for (const r in t.shape) {
|
|
3221
|
+
const n = t.shape[r];
|
|
3222
|
+
e[r] = Ce.create(Be(n));
|
|
3223
|
+
}
|
|
3224
|
+
return new L({
|
|
3225
|
+
...t._def,
|
|
3226
|
+
shape: () => e
|
|
3227
|
+
});
|
|
3228
|
+
} else return t instanceof me ? new me({
|
|
3229
|
+
...t._def,
|
|
3230
|
+
type: Be(t.element)
|
|
3231
|
+
}) : t instanceof Ce ? Ce.create(Be(t.unwrap())) : t instanceof Ye ? Ye.create(Be(t.unwrap())) : t instanceof $e ? $e.create(t.items.map((e) => Be(e))) : t;
|
|
3232
|
+
}
|
|
3233
|
+
class L extends E {
|
|
3234
|
+
constructor() {
|
|
3235
|
+
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
3236
|
+
}
|
|
3237
|
+
_getCached() {
|
|
3238
|
+
if (this._cached !== null)
|
|
3239
|
+
return this._cached;
|
|
3240
|
+
const e = this._def.shape(), r = N.objectKeys(e);
|
|
3241
|
+
return this._cached = { shape: e, keys: r }, this._cached;
|
|
3242
|
+
}
|
|
3243
|
+
_parse(e) {
|
|
3244
|
+
if (this._getType(e) !== y.object) {
|
|
3245
|
+
const d = this._getOrReturnCtx(e);
|
|
3246
|
+
return m(d, {
|
|
3247
|
+
code: h.invalid_type,
|
|
3248
|
+
expected: y.object,
|
|
3249
|
+
received: d.parsedType
|
|
3250
|
+
}), w;
|
|
3251
|
+
}
|
|
3252
|
+
const { status: n, ctx: a } = this._processInputParams(e), { shape: i, keys: s } = this._getCached(), o = [];
|
|
3253
|
+
if (!(this._def.catchall instanceof Ve && this._def.unknownKeys === "strip"))
|
|
3254
|
+
for (const d in a.data)
|
|
3255
|
+
s.includes(d) || o.push(d);
|
|
3256
|
+
const c = [];
|
|
3257
|
+
for (const d of s) {
|
|
3258
|
+
const v = i[d], S = a.data[d];
|
|
3259
|
+
c.push({
|
|
3260
|
+
key: { status: "valid", value: d },
|
|
3261
|
+
value: v._parse(new je(a, S, a.path, d)),
|
|
3262
|
+
alwaysSet: d in a.data
|
|
3263
|
+
});
|
|
3264
|
+
}
|
|
3265
|
+
if (this._def.catchall instanceof Ve) {
|
|
3266
|
+
const d = this._def.unknownKeys;
|
|
3267
|
+
if (d === "passthrough")
|
|
3268
|
+
for (const v of o)
|
|
3269
|
+
c.push({
|
|
3270
|
+
key: { status: "valid", value: v },
|
|
3271
|
+
value: { status: "valid", value: a.data[v] }
|
|
3272
|
+
});
|
|
3273
|
+
else if (d === "strict")
|
|
3274
|
+
o.length > 0 && (m(a, {
|
|
3275
|
+
code: h.unrecognized_keys,
|
|
3276
|
+
keys: o
|
|
3277
|
+
}), n.dirty());
|
|
3278
|
+
else if (d !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
3279
|
+
} else {
|
|
3280
|
+
const d = this._def.catchall;
|
|
3281
|
+
for (const v of o) {
|
|
3282
|
+
const S = a.data[v];
|
|
3283
|
+
c.push({
|
|
3284
|
+
key: { status: "valid", value: v },
|
|
3285
|
+
value: d._parse(
|
|
3286
|
+
new je(a, S, a.path, v)
|
|
3287
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
3288
|
+
),
|
|
3289
|
+
alwaysSet: v in a.data
|
|
3290
|
+
});
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
return a.common.async ? Promise.resolve().then(async () => {
|
|
3294
|
+
const d = [];
|
|
3295
|
+
for (const v of c) {
|
|
3296
|
+
const S = await v.key, I = await v.value;
|
|
3297
|
+
d.push({
|
|
3298
|
+
key: S,
|
|
3299
|
+
value: I,
|
|
3300
|
+
alwaysSet: v.alwaysSet
|
|
3301
|
+
});
|
|
3302
|
+
}
|
|
3303
|
+
return d;
|
|
3304
|
+
}).then((d) => re.mergeObjectSync(n, d)) : re.mergeObjectSync(n, c);
|
|
3305
|
+
}
|
|
3306
|
+
get shape() {
|
|
3307
|
+
return this._def.shape();
|
|
3308
|
+
}
|
|
3309
|
+
strict(e) {
|
|
3310
|
+
return g.errToObj, new L({
|
|
3311
|
+
...this._def,
|
|
3312
|
+
unknownKeys: "strict",
|
|
3313
|
+
...e !== void 0 ? {
|
|
3314
|
+
errorMap: (r, n) => {
|
|
3315
|
+
const a = this._def.errorMap?.(r, n).message ?? n.defaultError;
|
|
3316
|
+
return r.code === "unrecognized_keys" ? {
|
|
3317
|
+
message: g.errToObj(e).message ?? a
|
|
3318
|
+
} : {
|
|
3319
|
+
message: a
|
|
3320
|
+
};
|
|
3321
|
+
}
|
|
3322
|
+
} : {}
|
|
3323
|
+
});
|
|
3324
|
+
}
|
|
3325
|
+
strip() {
|
|
3326
|
+
return new L({
|
|
3327
|
+
...this._def,
|
|
3328
|
+
unknownKeys: "strip"
|
|
3329
|
+
});
|
|
3330
|
+
}
|
|
3331
|
+
passthrough() {
|
|
3332
|
+
return new L({
|
|
3333
|
+
...this._def,
|
|
3334
|
+
unknownKeys: "passthrough"
|
|
3335
|
+
});
|
|
3336
|
+
}
|
|
3337
|
+
// const AugmentFactory =
|
|
3338
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
3339
|
+
// <Augmentation extends ZodRawShape>(
|
|
3340
|
+
// augmentation: Augmentation
|
|
3341
|
+
// ): ZodObject<
|
|
3342
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
3343
|
+
// Def["unknownKeys"],
|
|
3344
|
+
// Def["catchall"]
|
|
3345
|
+
// > => {
|
|
3346
|
+
// return new ZodObject({
|
|
3347
|
+
// ...def,
|
|
3348
|
+
// shape: () => ({
|
|
3349
|
+
// ...def.shape(),
|
|
3350
|
+
// ...augmentation,
|
|
3351
|
+
// }),
|
|
3352
|
+
// }) as any;
|
|
3353
|
+
// };
|
|
3354
|
+
extend(e) {
|
|
3355
|
+
return new L({
|
|
3356
|
+
...this._def,
|
|
3357
|
+
shape: () => ({
|
|
3358
|
+
...this._def.shape(),
|
|
3359
|
+
...e
|
|
3360
|
+
})
|
|
3361
|
+
});
|
|
3362
|
+
}
|
|
3363
|
+
/**
|
|
3364
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
3365
|
+
* inferred type of merged objects. Please
|
|
3366
|
+
* upgrade if you are experiencing issues.
|
|
3367
|
+
*/
|
|
3368
|
+
merge(e) {
|
|
3369
|
+
return new L({
|
|
3370
|
+
unknownKeys: e._def.unknownKeys,
|
|
3371
|
+
catchall: e._def.catchall,
|
|
3372
|
+
shape: () => ({
|
|
3373
|
+
...this._def.shape(),
|
|
3374
|
+
...e._def.shape()
|
|
3375
|
+
}),
|
|
3376
|
+
typeName: O.ZodObject
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
// merge<
|
|
3380
|
+
// Incoming extends AnyZodObject,
|
|
3381
|
+
// Augmentation extends Incoming["shape"],
|
|
3382
|
+
// NewOutput extends {
|
|
3383
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
3384
|
+
// ? Augmentation[k]["_output"]
|
|
3385
|
+
// : k extends keyof Output
|
|
3386
|
+
// ? Output[k]
|
|
3387
|
+
// : never;
|
|
3388
|
+
// },
|
|
3389
|
+
// NewInput extends {
|
|
3390
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
3391
|
+
// ? Augmentation[k]["_input"]
|
|
3392
|
+
// : k extends keyof Input
|
|
3393
|
+
// ? Input[k]
|
|
3394
|
+
// : never;
|
|
3395
|
+
// }
|
|
3396
|
+
// >(
|
|
3397
|
+
// merging: Incoming
|
|
3398
|
+
// ): ZodObject<
|
|
3399
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
3400
|
+
// Incoming["_def"]["unknownKeys"],
|
|
3401
|
+
// Incoming["_def"]["catchall"],
|
|
3402
|
+
// NewOutput,
|
|
3403
|
+
// NewInput
|
|
3404
|
+
// > {
|
|
3405
|
+
// const merged: any = new ZodObject({
|
|
3406
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
3407
|
+
// catchall: merging._def.catchall,
|
|
3408
|
+
// shape: () =>
|
|
3409
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
3410
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
3411
|
+
// }) as any;
|
|
3412
|
+
// return merged;
|
|
3413
|
+
// }
|
|
3414
|
+
setKey(e, r) {
|
|
3415
|
+
return this.augment({ [e]: r });
|
|
3416
|
+
}
|
|
3417
|
+
// merge<Incoming extends AnyZodObject>(
|
|
3418
|
+
// merging: Incoming
|
|
3419
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
3420
|
+
// ZodObject<
|
|
3421
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
3422
|
+
// Incoming["_def"]["unknownKeys"],
|
|
3423
|
+
// Incoming["_def"]["catchall"]
|
|
3424
|
+
// > {
|
|
3425
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
3426
|
+
// // this._def.shape(),
|
|
3427
|
+
// // merging._def.shape()
|
|
3428
|
+
// // );
|
|
3429
|
+
// const merged: any = new ZodObject({
|
|
3430
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
3431
|
+
// catchall: merging._def.catchall,
|
|
3432
|
+
// shape: () =>
|
|
3433
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
3434
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
3435
|
+
// }) as any;
|
|
3436
|
+
// return merged;
|
|
3437
|
+
// }
|
|
3438
|
+
catchall(e) {
|
|
3439
|
+
return new L({
|
|
3440
|
+
...this._def,
|
|
3441
|
+
catchall: e
|
|
3442
|
+
});
|
|
3443
|
+
}
|
|
3444
|
+
pick(e) {
|
|
3445
|
+
const r = {};
|
|
3446
|
+
for (const n of N.objectKeys(e))
|
|
3447
|
+
e[n] && this.shape[n] && (r[n] = this.shape[n]);
|
|
3448
|
+
return new L({
|
|
3449
|
+
...this._def,
|
|
3450
|
+
shape: () => r
|
|
3451
|
+
});
|
|
3452
|
+
}
|
|
3453
|
+
omit(e) {
|
|
3454
|
+
const r = {};
|
|
3455
|
+
for (const n of N.objectKeys(this.shape))
|
|
3456
|
+
e[n] || (r[n] = this.shape[n]);
|
|
3457
|
+
return new L({
|
|
3458
|
+
...this._def,
|
|
3459
|
+
shape: () => r
|
|
3460
|
+
});
|
|
3461
|
+
}
|
|
3462
|
+
/**
|
|
3463
|
+
* @deprecated
|
|
3464
|
+
*/
|
|
3465
|
+
deepPartial() {
|
|
3466
|
+
return Be(this);
|
|
3467
|
+
}
|
|
3468
|
+
partial(e) {
|
|
3469
|
+
const r = {};
|
|
3470
|
+
for (const n of N.objectKeys(this.shape)) {
|
|
3471
|
+
const a = this.shape[n];
|
|
3472
|
+
e && !e[n] ? r[n] = a : r[n] = a.optional();
|
|
3473
|
+
}
|
|
3474
|
+
return new L({
|
|
3475
|
+
...this._def,
|
|
3476
|
+
shape: () => r
|
|
3477
|
+
});
|
|
3478
|
+
}
|
|
3479
|
+
required(e) {
|
|
3480
|
+
const r = {};
|
|
3481
|
+
for (const n of N.objectKeys(this.shape))
|
|
3482
|
+
if (e && !e[n])
|
|
3483
|
+
r[n] = this.shape[n];
|
|
3484
|
+
else {
|
|
3485
|
+
let i = this.shape[n];
|
|
3486
|
+
for (; i instanceof Ce; )
|
|
3487
|
+
i = i._def.innerType;
|
|
3488
|
+
r[n] = i;
|
|
3489
|
+
}
|
|
3490
|
+
return new L({
|
|
3491
|
+
...this._def,
|
|
3492
|
+
shape: () => r
|
|
3493
|
+
});
|
|
3494
|
+
}
|
|
3495
|
+
keyof() {
|
|
3496
|
+
return Kr(N.objectKeys(this.shape));
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
L.create = (t, e) => new L({
|
|
3500
|
+
shape: () => t,
|
|
3501
|
+
unknownKeys: "strip",
|
|
3502
|
+
catchall: Ve.create(),
|
|
3503
|
+
typeName: O.ZodObject,
|
|
3504
|
+
...V(e)
|
|
3505
|
+
});
|
|
3506
|
+
L.strictCreate = (t, e) => new L({
|
|
3507
|
+
shape: () => t,
|
|
3508
|
+
unknownKeys: "strict",
|
|
3509
|
+
catchall: Ve.create(),
|
|
3510
|
+
typeName: O.ZodObject,
|
|
3511
|
+
...V(e)
|
|
3512
|
+
});
|
|
3513
|
+
L.lazycreate = (t, e) => new L({
|
|
3514
|
+
shape: t,
|
|
3515
|
+
unknownKeys: "strip",
|
|
3516
|
+
catchall: Ve.create(),
|
|
3517
|
+
typeName: O.ZodObject,
|
|
3518
|
+
...V(e)
|
|
3519
|
+
});
|
|
3520
|
+
class gt extends E {
|
|
3521
|
+
_parse(e) {
|
|
3522
|
+
const { ctx: r } = this._processInputParams(e), n = this._def.options;
|
|
3523
|
+
function a(i) {
|
|
3524
|
+
for (const o of i)
|
|
3525
|
+
if (o.result.status === "valid")
|
|
3526
|
+
return o.result;
|
|
3527
|
+
for (const o of i)
|
|
3528
|
+
if (o.result.status === "dirty")
|
|
3529
|
+
return r.common.issues.push(...o.ctx.common.issues), o.result;
|
|
3530
|
+
const s = i.map((o) => new xe(o.ctx.common.issues));
|
|
3531
|
+
return m(r, {
|
|
3532
|
+
code: h.invalid_union,
|
|
3533
|
+
unionErrors: s
|
|
3534
|
+
}), w;
|
|
3535
|
+
}
|
|
3536
|
+
if (r.common.async)
|
|
3537
|
+
return Promise.all(n.map(async (i) => {
|
|
3538
|
+
const s = {
|
|
3539
|
+
...r,
|
|
3540
|
+
common: {
|
|
3541
|
+
...r.common,
|
|
3542
|
+
issues: []
|
|
3543
|
+
},
|
|
3544
|
+
parent: null
|
|
3545
|
+
};
|
|
3546
|
+
return {
|
|
3547
|
+
result: await i._parseAsync({
|
|
3548
|
+
data: r.data,
|
|
3549
|
+
path: r.path,
|
|
3550
|
+
parent: s
|
|
3551
|
+
}),
|
|
3552
|
+
ctx: s
|
|
3553
|
+
};
|
|
3554
|
+
})).then(a);
|
|
3555
|
+
{
|
|
3556
|
+
let i;
|
|
3557
|
+
const s = [];
|
|
3558
|
+
for (const c of n) {
|
|
3559
|
+
const d = {
|
|
3560
|
+
...r,
|
|
3561
|
+
common: {
|
|
3562
|
+
...r.common,
|
|
3563
|
+
issues: []
|
|
3564
|
+
},
|
|
3565
|
+
parent: null
|
|
3566
|
+
}, v = c._parseSync({
|
|
3567
|
+
data: r.data,
|
|
3568
|
+
path: r.path,
|
|
3569
|
+
parent: d
|
|
3570
|
+
});
|
|
3571
|
+
if (v.status === "valid")
|
|
3572
|
+
return v;
|
|
3573
|
+
v.status === "dirty" && !i && (i = { result: v, ctx: d }), d.common.issues.length && s.push(d.common.issues);
|
|
3574
|
+
}
|
|
3575
|
+
if (i)
|
|
3576
|
+
return r.common.issues.push(...i.ctx.common.issues), i.result;
|
|
3577
|
+
const o = s.map((c) => new xe(c));
|
|
3578
|
+
return m(r, {
|
|
3579
|
+
code: h.invalid_union,
|
|
3580
|
+
unionErrors: o
|
|
3581
|
+
}), w;
|
|
3582
|
+
}
|
|
3583
|
+
}
|
|
3584
|
+
get options() {
|
|
3585
|
+
return this._def.options;
|
|
3586
|
+
}
|
|
3587
|
+
}
|
|
3588
|
+
gt.create = (t, e) => new gt({
|
|
3589
|
+
options: t,
|
|
3590
|
+
typeName: O.ZodUnion,
|
|
3591
|
+
...V(e)
|
|
3592
|
+
});
|
|
3593
|
+
function Ut(t, e) {
|
|
3594
|
+
const r = Se(t), n = Se(e);
|
|
3595
|
+
if (t === e)
|
|
3596
|
+
return { valid: !0, data: t };
|
|
3597
|
+
if (r === y.object && n === y.object) {
|
|
3598
|
+
const a = N.objectKeys(e), i = N.objectKeys(t).filter((o) => a.indexOf(o) !== -1), s = { ...t, ...e };
|
|
3599
|
+
for (const o of i) {
|
|
3600
|
+
const c = Ut(t[o], e[o]);
|
|
3601
|
+
if (!c.valid)
|
|
3602
|
+
return { valid: !1 };
|
|
3603
|
+
s[o] = c.data;
|
|
3604
|
+
}
|
|
3605
|
+
return { valid: !0, data: s };
|
|
3606
|
+
} else if (r === y.array && n === y.array) {
|
|
3607
|
+
if (t.length !== e.length)
|
|
3608
|
+
return { valid: !1 };
|
|
3609
|
+
const a = [];
|
|
3610
|
+
for (let i = 0; i < t.length; i++) {
|
|
3611
|
+
const s = t[i], o = e[i], c = Ut(s, o);
|
|
3612
|
+
if (!c.valid)
|
|
3613
|
+
return { valid: !1 };
|
|
3614
|
+
a.push(c.data);
|
|
3615
|
+
}
|
|
3616
|
+
return { valid: !0, data: a };
|
|
3617
|
+
} else return r === y.date && n === y.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
3618
|
+
}
|
|
3619
|
+
class _t extends E {
|
|
3620
|
+
_parse(e) {
|
|
3621
|
+
const { status: r, ctx: n } = this._processInputParams(e), a = (i, s) => {
|
|
3622
|
+
if (fr(i) || fr(s))
|
|
3623
|
+
return w;
|
|
3624
|
+
const o = Ut(i.value, s.value);
|
|
3625
|
+
return o.valid ? ((hr(i) || hr(s)) && r.dirty(), { status: r.value, value: o.data }) : (m(n, {
|
|
3626
|
+
code: h.invalid_intersection_types
|
|
3627
|
+
}), w);
|
|
3628
|
+
};
|
|
3629
|
+
return n.common.async ? Promise.all([
|
|
3630
|
+
this._def.left._parseAsync({
|
|
3631
|
+
data: n.data,
|
|
3632
|
+
path: n.path,
|
|
3633
|
+
parent: n
|
|
3634
|
+
}),
|
|
3635
|
+
this._def.right._parseAsync({
|
|
3636
|
+
data: n.data,
|
|
3637
|
+
path: n.path,
|
|
3638
|
+
parent: n
|
|
3639
|
+
})
|
|
3640
|
+
]).then(([i, s]) => a(i, s)) : a(this._def.left._parseSync({
|
|
3641
|
+
data: n.data,
|
|
3642
|
+
path: n.path,
|
|
3643
|
+
parent: n
|
|
3644
|
+
}), this._def.right._parseSync({
|
|
3645
|
+
data: n.data,
|
|
3646
|
+
path: n.path,
|
|
3647
|
+
parent: n
|
|
3648
|
+
}));
|
|
3649
|
+
}
|
|
3650
|
+
}
|
|
3651
|
+
_t.create = (t, e, r) => new _t({
|
|
3652
|
+
left: t,
|
|
3653
|
+
right: e,
|
|
3654
|
+
typeName: O.ZodIntersection,
|
|
3655
|
+
...V(r)
|
|
3656
|
+
});
|
|
3657
|
+
class $e extends E {
|
|
3658
|
+
_parse(e) {
|
|
3659
|
+
const { status: r, ctx: n } = this._processInputParams(e);
|
|
3660
|
+
if (n.parsedType !== y.array)
|
|
3661
|
+
return m(n, {
|
|
3662
|
+
code: h.invalid_type,
|
|
3663
|
+
expected: y.array,
|
|
3664
|
+
received: n.parsedType
|
|
3665
|
+
}), w;
|
|
3666
|
+
if (n.data.length < this._def.items.length)
|
|
3667
|
+
return m(n, {
|
|
3668
|
+
code: h.too_small,
|
|
3669
|
+
minimum: this._def.items.length,
|
|
3670
|
+
inclusive: !0,
|
|
3671
|
+
exact: !1,
|
|
3672
|
+
type: "array"
|
|
3673
|
+
}), w;
|
|
3674
|
+
!this._def.rest && n.data.length > this._def.items.length && (m(n, {
|
|
3675
|
+
code: h.too_big,
|
|
3676
|
+
maximum: this._def.items.length,
|
|
3677
|
+
inclusive: !0,
|
|
3678
|
+
exact: !1,
|
|
3679
|
+
type: "array"
|
|
3680
|
+
}), r.dirty());
|
|
3681
|
+
const i = [...n.data].map((s, o) => {
|
|
3682
|
+
const c = this._def.items[o] || this._def.rest;
|
|
3683
|
+
return c ? c._parse(new je(n, s, n.path, o)) : null;
|
|
3684
|
+
}).filter((s) => !!s);
|
|
3685
|
+
return n.common.async ? Promise.all(i).then((s) => re.mergeArray(r, s)) : re.mergeArray(r, i);
|
|
3686
|
+
}
|
|
3687
|
+
get items() {
|
|
3688
|
+
return this._def.items;
|
|
3689
|
+
}
|
|
3690
|
+
rest(e) {
|
|
3691
|
+
return new $e({
|
|
3692
|
+
...this._def,
|
|
3693
|
+
rest: e
|
|
3694
|
+
});
|
|
3695
|
+
}
|
|
3696
|
+
}
|
|
3697
|
+
$e.create = (t, e) => {
|
|
3698
|
+
if (!Array.isArray(t))
|
|
3699
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
3700
|
+
return new $e({
|
|
3701
|
+
items: t,
|
|
3702
|
+
typeName: O.ZodTuple,
|
|
3703
|
+
rest: null,
|
|
3704
|
+
...V(e)
|
|
3705
|
+
});
|
|
3706
|
+
};
|
|
3707
|
+
class xr extends E {
|
|
3708
|
+
get keySchema() {
|
|
3709
|
+
return this._def.keyType;
|
|
3710
|
+
}
|
|
3711
|
+
get valueSchema() {
|
|
3712
|
+
return this._def.valueType;
|
|
3713
|
+
}
|
|
3714
|
+
_parse(e) {
|
|
3715
|
+
const { status: r, ctx: n } = this._processInputParams(e);
|
|
3716
|
+
if (n.parsedType !== y.map)
|
|
3717
|
+
return m(n, {
|
|
3718
|
+
code: h.invalid_type,
|
|
3719
|
+
expected: y.map,
|
|
3720
|
+
received: n.parsedType
|
|
3721
|
+
}), w;
|
|
3722
|
+
const a = this._def.keyType, i = this._def.valueType, s = [...n.data.entries()].map(([o, c], d) => ({
|
|
3723
|
+
key: a._parse(new je(n, o, n.path, [d, "key"])),
|
|
3724
|
+
value: i._parse(new je(n, c, n.path, [d, "value"]))
|
|
3725
|
+
}));
|
|
3726
|
+
if (n.common.async) {
|
|
3727
|
+
const o = /* @__PURE__ */ new Map();
|
|
3728
|
+
return Promise.resolve().then(async () => {
|
|
3729
|
+
for (const c of s) {
|
|
3730
|
+
const d = await c.key, v = await c.value;
|
|
3731
|
+
if (d.status === "aborted" || v.status === "aborted")
|
|
3732
|
+
return w;
|
|
3733
|
+
(d.status === "dirty" || v.status === "dirty") && r.dirty(), o.set(d.value, v.value);
|
|
3734
|
+
}
|
|
3735
|
+
return { status: r.value, value: o };
|
|
3736
|
+
});
|
|
3737
|
+
} else {
|
|
3738
|
+
const o = /* @__PURE__ */ new Map();
|
|
3739
|
+
for (const c of s) {
|
|
3740
|
+
const d = c.key, v = c.value;
|
|
3741
|
+
if (d.status === "aborted" || v.status === "aborted")
|
|
3742
|
+
return w;
|
|
3743
|
+
(d.status === "dirty" || v.status === "dirty") && r.dirty(), o.set(d.value, v.value);
|
|
3744
|
+
}
|
|
3745
|
+
return { status: r.value, value: o };
|
|
3746
|
+
}
|
|
3747
|
+
}
|
|
3748
|
+
}
|
|
3749
|
+
xr.create = (t, e, r) => new xr({
|
|
3750
|
+
valueType: e,
|
|
3751
|
+
keyType: t,
|
|
3752
|
+
typeName: O.ZodMap,
|
|
3753
|
+
...V(r)
|
|
3754
|
+
});
|
|
3755
|
+
class st extends E {
|
|
3756
|
+
_parse(e) {
|
|
3757
|
+
const { status: r, ctx: n } = this._processInputParams(e);
|
|
3758
|
+
if (n.parsedType !== y.set)
|
|
3759
|
+
return m(n, {
|
|
3760
|
+
code: h.invalid_type,
|
|
3761
|
+
expected: y.set,
|
|
3762
|
+
received: n.parsedType
|
|
3763
|
+
}), w;
|
|
3764
|
+
const a = this._def;
|
|
3765
|
+
a.minSize !== null && n.data.size < a.minSize.value && (m(n, {
|
|
3766
|
+
code: h.too_small,
|
|
3767
|
+
minimum: a.minSize.value,
|
|
3768
|
+
type: "set",
|
|
3769
|
+
inclusive: !0,
|
|
3770
|
+
exact: !1,
|
|
3771
|
+
message: a.minSize.message
|
|
3772
|
+
}), r.dirty()), a.maxSize !== null && n.data.size > a.maxSize.value && (m(n, {
|
|
3773
|
+
code: h.too_big,
|
|
3774
|
+
maximum: a.maxSize.value,
|
|
3775
|
+
type: "set",
|
|
3776
|
+
inclusive: !0,
|
|
3777
|
+
exact: !1,
|
|
3778
|
+
message: a.maxSize.message
|
|
3779
|
+
}), r.dirty());
|
|
3780
|
+
const i = this._def.valueType;
|
|
3781
|
+
function s(c) {
|
|
3782
|
+
const d = /* @__PURE__ */ new Set();
|
|
3783
|
+
for (const v of c) {
|
|
3784
|
+
if (v.status === "aborted")
|
|
3785
|
+
return w;
|
|
3786
|
+
v.status === "dirty" && r.dirty(), d.add(v.value);
|
|
3787
|
+
}
|
|
3788
|
+
return { status: r.value, value: d };
|
|
3789
|
+
}
|
|
3790
|
+
const o = [...n.data.values()].map((c, d) => i._parse(new je(n, c, n.path, d)));
|
|
3791
|
+
return n.common.async ? Promise.all(o).then((c) => s(c)) : s(o);
|
|
3792
|
+
}
|
|
3793
|
+
min(e, r) {
|
|
3794
|
+
return new st({
|
|
3795
|
+
...this._def,
|
|
3796
|
+
minSize: { value: e, message: g.toString(r) }
|
|
3797
|
+
});
|
|
3798
|
+
}
|
|
3799
|
+
max(e, r) {
|
|
3800
|
+
return new st({
|
|
3801
|
+
...this._def,
|
|
3802
|
+
maxSize: { value: e, message: g.toString(r) }
|
|
3803
|
+
});
|
|
3804
|
+
}
|
|
3805
|
+
size(e, r) {
|
|
3806
|
+
return this.min(e, r).max(e, r);
|
|
3807
|
+
}
|
|
3808
|
+
nonempty(e) {
|
|
3809
|
+
return this.min(1, e);
|
|
3810
|
+
}
|
|
3811
|
+
}
|
|
3812
|
+
st.create = (t, e) => new st({
|
|
3813
|
+
valueType: t,
|
|
3814
|
+
minSize: null,
|
|
3815
|
+
maxSize: null,
|
|
3816
|
+
typeName: O.ZodSet,
|
|
3817
|
+
...V(e)
|
|
3818
|
+
});
|
|
3819
|
+
class kr extends E {
|
|
3820
|
+
get schema() {
|
|
3821
|
+
return this._def.getter();
|
|
3822
|
+
}
|
|
3823
|
+
_parse(e) {
|
|
3824
|
+
const { ctx: r } = this._processInputParams(e);
|
|
3825
|
+
return this._def.getter()._parse({ data: r.data, path: r.path, parent: r });
|
|
3826
|
+
}
|
|
3827
|
+
}
|
|
3828
|
+
kr.create = (t, e) => new kr({
|
|
3829
|
+
getter: t,
|
|
3830
|
+
typeName: O.ZodLazy,
|
|
3831
|
+
...V(e)
|
|
3832
|
+
});
|
|
3833
|
+
class Or extends E {
|
|
3834
|
+
_parse(e) {
|
|
3835
|
+
if (e.data !== this._def.value) {
|
|
3836
|
+
const r = this._getOrReturnCtx(e);
|
|
3837
|
+
return m(r, {
|
|
3838
|
+
received: r.data,
|
|
3839
|
+
code: h.invalid_literal,
|
|
3840
|
+
expected: this._def.value
|
|
3841
|
+
}), w;
|
|
3842
|
+
}
|
|
3843
|
+
return { status: "valid", value: e.data };
|
|
3844
|
+
}
|
|
3845
|
+
get value() {
|
|
3846
|
+
return this._def.value;
|
|
3847
|
+
}
|
|
3848
|
+
}
|
|
3849
|
+
Or.create = (t, e) => new Or({
|
|
3850
|
+
value: t,
|
|
3851
|
+
typeName: O.ZodLiteral,
|
|
3852
|
+
...V(e)
|
|
3853
|
+
});
|
|
3854
|
+
function Kr(t, e) {
|
|
3855
|
+
return new Ge({
|
|
3856
|
+
values: t,
|
|
3857
|
+
typeName: O.ZodEnum,
|
|
3858
|
+
...V(e)
|
|
3859
|
+
});
|
|
3860
|
+
}
|
|
3861
|
+
class Ge extends E {
|
|
3862
|
+
_parse(e) {
|
|
3863
|
+
if (typeof e.data != "string") {
|
|
3864
|
+
const r = this._getOrReturnCtx(e), n = this._def.values;
|
|
3865
|
+
return m(r, {
|
|
3866
|
+
expected: N.joinValues(n),
|
|
3867
|
+
received: r.parsedType,
|
|
3868
|
+
code: h.invalid_type
|
|
3869
|
+
}), w;
|
|
3870
|
+
}
|
|
3871
|
+
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
3872
|
+
const r = this._getOrReturnCtx(e), n = this._def.values;
|
|
3873
|
+
return m(r, {
|
|
3874
|
+
received: r.data,
|
|
3875
|
+
code: h.invalid_enum_value,
|
|
3876
|
+
options: n
|
|
3877
|
+
}), w;
|
|
3878
|
+
}
|
|
3879
|
+
return ue(e.data);
|
|
3880
|
+
}
|
|
3881
|
+
get options() {
|
|
3882
|
+
return this._def.values;
|
|
3883
|
+
}
|
|
3884
|
+
get enum() {
|
|
3885
|
+
const e = {};
|
|
3886
|
+
for (const r of this._def.values)
|
|
3887
|
+
e[r] = r;
|
|
3888
|
+
return e;
|
|
3889
|
+
}
|
|
3890
|
+
get Values() {
|
|
3891
|
+
const e = {};
|
|
3892
|
+
for (const r of this._def.values)
|
|
3893
|
+
e[r] = r;
|
|
3894
|
+
return e;
|
|
3895
|
+
}
|
|
3896
|
+
get Enum() {
|
|
3897
|
+
const e = {};
|
|
3898
|
+
for (const r of this._def.values)
|
|
3899
|
+
e[r] = r;
|
|
3900
|
+
return e;
|
|
3901
|
+
}
|
|
3902
|
+
extract(e, r = this._def) {
|
|
3903
|
+
return Ge.create(e, {
|
|
3904
|
+
...this._def,
|
|
3905
|
+
...r
|
|
3906
|
+
});
|
|
3907
|
+
}
|
|
3908
|
+
exclude(e, r = this._def) {
|
|
3909
|
+
return Ge.create(this.options.filter((n) => !e.includes(n)), {
|
|
3910
|
+
...this._def,
|
|
3911
|
+
...r
|
|
3912
|
+
});
|
|
3913
|
+
}
|
|
3914
|
+
}
|
|
3915
|
+
Ge.create = Kr;
|
|
3916
|
+
class wr extends E {
|
|
3917
|
+
_parse(e) {
|
|
3918
|
+
const r = N.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
|
|
3919
|
+
if (n.parsedType !== y.string && n.parsedType !== y.number) {
|
|
3920
|
+
const a = N.objectValues(r);
|
|
3921
|
+
return m(n, {
|
|
3922
|
+
expected: N.joinValues(a),
|
|
3923
|
+
received: n.parsedType,
|
|
3924
|
+
code: h.invalid_type
|
|
3925
|
+
}), w;
|
|
3926
|
+
}
|
|
3927
|
+
if (this._cache || (this._cache = new Set(N.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
3928
|
+
const a = N.objectValues(r);
|
|
3929
|
+
return m(n, {
|
|
3930
|
+
received: n.data,
|
|
3931
|
+
code: h.invalid_enum_value,
|
|
3932
|
+
options: a
|
|
3933
|
+
}), w;
|
|
3934
|
+
}
|
|
3935
|
+
return ue(e.data);
|
|
3936
|
+
}
|
|
3937
|
+
get enum() {
|
|
3938
|
+
return this._def.values;
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
wr.create = (t, e) => new wr({
|
|
3942
|
+
values: t,
|
|
3943
|
+
typeName: O.ZodNativeEnum,
|
|
3944
|
+
...V(e)
|
|
3945
|
+
});
|
|
3946
|
+
class bt extends E {
|
|
3947
|
+
unwrap() {
|
|
3948
|
+
return this._def.type;
|
|
3949
|
+
}
|
|
3950
|
+
_parse(e) {
|
|
3951
|
+
const { ctx: r } = this._processInputParams(e);
|
|
3952
|
+
if (r.parsedType !== y.promise && r.common.async === !1)
|
|
3953
|
+
return m(r, {
|
|
3954
|
+
code: h.invalid_type,
|
|
3955
|
+
expected: y.promise,
|
|
3956
|
+
received: r.parsedType
|
|
3957
|
+
}), w;
|
|
3958
|
+
const n = r.parsedType === y.promise ? r.data : Promise.resolve(r.data);
|
|
3959
|
+
return ue(n.then((a) => this._def.type.parseAsync(a, {
|
|
3960
|
+
path: r.path,
|
|
3961
|
+
errorMap: r.common.contextualErrorMap
|
|
3962
|
+
})));
|
|
3963
|
+
}
|
|
3964
|
+
}
|
|
3965
|
+
bt.create = (t, e) => new bt({
|
|
3966
|
+
type: t,
|
|
3967
|
+
typeName: O.ZodPromise,
|
|
3968
|
+
...V(e)
|
|
3969
|
+
});
|
|
3970
|
+
class Fe extends E {
|
|
3971
|
+
innerType() {
|
|
3972
|
+
return this._def.schema;
|
|
3973
|
+
}
|
|
3974
|
+
sourceType() {
|
|
3975
|
+
return this._def.schema._def.typeName === O.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3976
|
+
}
|
|
3977
|
+
_parse(e) {
|
|
3978
|
+
const { status: r, ctx: n } = this._processInputParams(e), a = this._def.effect || null, i = {
|
|
3979
|
+
addIssue: (s) => {
|
|
3980
|
+
m(n, s), s.fatal ? r.abort() : r.dirty();
|
|
3981
|
+
},
|
|
3982
|
+
get path() {
|
|
3983
|
+
return n.path;
|
|
3984
|
+
}
|
|
3985
|
+
};
|
|
3986
|
+
if (i.addIssue = i.addIssue.bind(i), a.type === "preprocess") {
|
|
3987
|
+
const s = a.transform(n.data, i);
|
|
3988
|
+
if (n.common.async)
|
|
3989
|
+
return Promise.resolve(s).then(async (o) => {
|
|
3990
|
+
if (r.value === "aborted")
|
|
3991
|
+
return w;
|
|
3992
|
+
const c = await this._def.schema._parseAsync({
|
|
3993
|
+
data: o,
|
|
3994
|
+
path: n.path,
|
|
3995
|
+
parent: n
|
|
3996
|
+
});
|
|
3997
|
+
return c.status === "aborted" ? w : c.status === "dirty" || r.value === "dirty" ? tt(c.value) : c;
|
|
3998
|
+
});
|
|
3999
|
+
{
|
|
4000
|
+
if (r.value === "aborted")
|
|
4001
|
+
return w;
|
|
4002
|
+
const o = this._def.schema._parseSync({
|
|
4003
|
+
data: s,
|
|
4004
|
+
path: n.path,
|
|
4005
|
+
parent: n
|
|
4006
|
+
});
|
|
4007
|
+
return o.status === "aborted" ? w : o.status === "dirty" || r.value === "dirty" ? tt(o.value) : o;
|
|
4008
|
+
}
|
|
4009
|
+
}
|
|
4010
|
+
if (a.type === "refinement") {
|
|
4011
|
+
const s = (o) => {
|
|
4012
|
+
const c = a.refinement(o, i);
|
|
4013
|
+
if (n.common.async)
|
|
4014
|
+
return Promise.resolve(c);
|
|
4015
|
+
if (c instanceof Promise)
|
|
4016
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
4017
|
+
return o;
|
|
4018
|
+
};
|
|
4019
|
+
if (n.common.async === !1) {
|
|
4020
|
+
const o = this._def.schema._parseSync({
|
|
4021
|
+
data: n.data,
|
|
4022
|
+
path: n.path,
|
|
4023
|
+
parent: n
|
|
4024
|
+
});
|
|
4025
|
+
return o.status === "aborted" ? w : (o.status === "dirty" && r.dirty(), s(o.value), { status: r.value, value: o.value });
|
|
4026
|
+
} else
|
|
4027
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => o.status === "aborted" ? w : (o.status === "dirty" && r.dirty(), s(o.value).then(() => ({ status: r.value, value: o.value }))));
|
|
4028
|
+
}
|
|
4029
|
+
if (a.type === "transform")
|
|
4030
|
+
if (n.common.async === !1) {
|
|
4031
|
+
const s = this._def.schema._parseSync({
|
|
4032
|
+
data: n.data,
|
|
4033
|
+
path: n.path,
|
|
4034
|
+
parent: n
|
|
4035
|
+
});
|
|
4036
|
+
if (!He(s))
|
|
4037
|
+
return w;
|
|
4038
|
+
const o = a.transform(s.value, i);
|
|
4039
|
+
if (o instanceof Promise)
|
|
4040
|
+
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
4041
|
+
return { status: r.value, value: o };
|
|
4042
|
+
} else
|
|
4043
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((s) => He(s) ? Promise.resolve(a.transform(s.value, i)).then((o) => ({
|
|
4044
|
+
status: r.value,
|
|
4045
|
+
value: o
|
|
4046
|
+
})) : w);
|
|
4047
|
+
N.assertNever(a);
|
|
4048
|
+
}
|
|
4049
|
+
}
|
|
4050
|
+
Fe.create = (t, e, r) => new Fe({
|
|
4051
|
+
schema: t,
|
|
4052
|
+
typeName: O.ZodEffects,
|
|
4053
|
+
effect: e,
|
|
4054
|
+
...V(r)
|
|
4055
|
+
});
|
|
4056
|
+
Fe.createWithPreprocess = (t, e, r) => new Fe({
|
|
4057
|
+
schema: e,
|
|
4058
|
+
effect: { type: "preprocess", transform: t },
|
|
4059
|
+
typeName: O.ZodEffects,
|
|
4060
|
+
...V(r)
|
|
4061
|
+
});
|
|
4062
|
+
class Ce extends E {
|
|
4063
|
+
_parse(e) {
|
|
4064
|
+
return this._getType(e) === y.undefined ? ue(void 0) : this._def.innerType._parse(e);
|
|
4065
|
+
}
|
|
4066
|
+
unwrap() {
|
|
4067
|
+
return this._def.innerType;
|
|
4068
|
+
}
|
|
4069
|
+
}
|
|
4070
|
+
Ce.create = (t, e) => new Ce({
|
|
4071
|
+
innerType: t,
|
|
4072
|
+
typeName: O.ZodOptional,
|
|
4073
|
+
...V(e)
|
|
4074
|
+
});
|
|
4075
|
+
class Ye extends E {
|
|
4076
|
+
_parse(e) {
|
|
4077
|
+
return this._getType(e) === y.null ? ue(null) : this._def.innerType._parse(e);
|
|
4078
|
+
}
|
|
4079
|
+
unwrap() {
|
|
4080
|
+
return this._def.innerType;
|
|
4081
|
+
}
|
|
4082
|
+
}
|
|
4083
|
+
Ye.create = (t, e) => new Ye({
|
|
4084
|
+
innerType: t,
|
|
4085
|
+
typeName: O.ZodNullable,
|
|
4086
|
+
...V(e)
|
|
4087
|
+
});
|
|
4088
|
+
class xt extends E {
|
|
4089
|
+
_parse(e) {
|
|
4090
|
+
const { ctx: r } = this._processInputParams(e);
|
|
4091
|
+
let n = r.data;
|
|
4092
|
+
return r.parsedType === y.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
|
|
4093
|
+
data: n,
|
|
4094
|
+
path: r.path,
|
|
4095
|
+
parent: r
|
|
4096
|
+
});
|
|
4097
|
+
}
|
|
4098
|
+
removeDefault() {
|
|
4099
|
+
return this._def.innerType;
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
xt.create = (t, e) => new xt({
|
|
4103
|
+
innerType: t,
|
|
4104
|
+
typeName: O.ZodDefault,
|
|
4105
|
+
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
4106
|
+
...V(e)
|
|
4107
|
+
});
|
|
4108
|
+
class zt extends E {
|
|
4109
|
+
_parse(e) {
|
|
4110
|
+
const { ctx: r } = this._processInputParams(e), n = {
|
|
4111
|
+
...r,
|
|
4112
|
+
common: {
|
|
4113
|
+
...r.common,
|
|
4114
|
+
issues: []
|
|
4115
|
+
}
|
|
4116
|
+
}, a = this._def.innerType._parse({
|
|
4117
|
+
data: n.data,
|
|
4118
|
+
path: n.path,
|
|
4119
|
+
parent: {
|
|
4120
|
+
...n
|
|
4121
|
+
}
|
|
4122
|
+
});
|
|
4123
|
+
return pt(a) ? a.then((i) => ({
|
|
4124
|
+
status: "valid",
|
|
4125
|
+
value: i.status === "valid" ? i.value : this._def.catchValue({
|
|
4126
|
+
get error() {
|
|
4127
|
+
return new xe(n.common.issues);
|
|
4128
|
+
},
|
|
4129
|
+
input: n.data
|
|
4130
|
+
})
|
|
4131
|
+
})) : {
|
|
4132
|
+
status: "valid",
|
|
4133
|
+
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
4134
|
+
get error() {
|
|
4135
|
+
return new xe(n.common.issues);
|
|
4136
|
+
},
|
|
4137
|
+
input: n.data
|
|
4138
|
+
})
|
|
4139
|
+
};
|
|
4140
|
+
}
|
|
4141
|
+
removeCatch() {
|
|
4142
|
+
return this._def.innerType;
|
|
4143
|
+
}
|
|
4144
|
+
}
|
|
4145
|
+
zt.create = (t, e) => new zt({
|
|
4146
|
+
innerType: t,
|
|
4147
|
+
typeName: O.ZodCatch,
|
|
4148
|
+
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
4149
|
+
...V(e)
|
|
4150
|
+
});
|
|
4151
|
+
class Sr extends E {
|
|
4152
|
+
_parse(e) {
|
|
4153
|
+
if (this._getType(e) !== y.nan) {
|
|
4154
|
+
const n = this._getOrReturnCtx(e);
|
|
4155
|
+
return m(n, {
|
|
4156
|
+
code: h.invalid_type,
|
|
4157
|
+
expected: y.nan,
|
|
4158
|
+
received: n.parsedType
|
|
4159
|
+
}), w;
|
|
4160
|
+
}
|
|
4161
|
+
return { status: "valid", value: e.data };
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4164
|
+
Sr.create = (t) => new Sr({
|
|
4165
|
+
typeName: O.ZodNaN,
|
|
4166
|
+
...V(t)
|
|
4167
|
+
});
|
|
4168
|
+
class Pa extends E {
|
|
4169
|
+
_parse(e) {
|
|
4170
|
+
const { ctx: r } = this._processInputParams(e), n = r.data;
|
|
4171
|
+
return this._def.type._parse({
|
|
4172
|
+
data: n,
|
|
4173
|
+
path: r.path,
|
|
4174
|
+
parent: r
|
|
4175
|
+
});
|
|
4176
|
+
}
|
|
4177
|
+
unwrap() {
|
|
4178
|
+
return this._def.type;
|
|
4179
|
+
}
|
|
4180
|
+
}
|
|
4181
|
+
class Jt extends E {
|
|
4182
|
+
_parse(e) {
|
|
4183
|
+
const { status: r, ctx: n } = this._processInputParams(e);
|
|
4184
|
+
if (n.common.async)
|
|
4185
|
+
return (async () => {
|
|
4186
|
+
const i = await this._def.in._parseAsync({
|
|
4187
|
+
data: n.data,
|
|
4188
|
+
path: n.path,
|
|
4189
|
+
parent: n
|
|
4190
|
+
});
|
|
4191
|
+
return i.status === "aborted" ? w : i.status === "dirty" ? (r.dirty(), tt(i.value)) : this._def.out._parseAsync({
|
|
4192
|
+
data: i.value,
|
|
4193
|
+
path: n.path,
|
|
4194
|
+
parent: n
|
|
4195
|
+
});
|
|
4196
|
+
})();
|
|
4197
|
+
{
|
|
4198
|
+
const a = this._def.in._parseSync({
|
|
4199
|
+
data: n.data,
|
|
4200
|
+
path: n.path,
|
|
4201
|
+
parent: n
|
|
4202
|
+
});
|
|
4203
|
+
return a.status === "aborted" ? w : a.status === "dirty" ? (r.dirty(), {
|
|
4204
|
+
status: "dirty",
|
|
4205
|
+
value: a.value
|
|
4206
|
+
}) : this._def.out._parseSync({
|
|
4207
|
+
data: a.value,
|
|
4208
|
+
path: n.path,
|
|
4209
|
+
parent: n
|
|
4210
|
+
});
|
|
4211
|
+
}
|
|
4212
|
+
}
|
|
4213
|
+
static create(e, r) {
|
|
4214
|
+
return new Jt({
|
|
4215
|
+
in: e,
|
|
4216
|
+
out: r,
|
|
4217
|
+
typeName: O.ZodPipeline
|
|
4218
|
+
});
|
|
4219
|
+
}
|
|
4220
|
+
}
|
|
4221
|
+
class Bt extends E {
|
|
4222
|
+
_parse(e) {
|
|
4223
|
+
const r = this._def.innerType._parse(e), n = (a) => (He(a) && (a.value = Object.freeze(a.value)), a);
|
|
4224
|
+
return pt(r) ? r.then((a) => n(a)) : n(r);
|
|
4225
|
+
}
|
|
4226
|
+
unwrap() {
|
|
4227
|
+
return this._def.innerType;
|
|
4228
|
+
}
|
|
4229
|
+
}
|
|
4230
|
+
Bt.create = (t, e) => new Bt({
|
|
4231
|
+
innerType: t,
|
|
4232
|
+
typeName: O.ZodReadonly,
|
|
4233
|
+
...V(e)
|
|
4234
|
+
});
|
|
4235
|
+
var O;
|
|
4236
|
+
(function(t) {
|
|
4237
|
+
t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
|
|
4238
|
+
})(O || (O = {}));
|
|
4239
|
+
const Wa = _e.create;
|
|
4240
|
+
Pe.create;
|
|
4241
|
+
Ze.create;
|
|
4242
|
+
const qa = yt.create, Ha = Je.create;
|
|
4243
|
+
Ve.create;
|
|
4244
|
+
const Ja = me.create, Ga = L.create;
|
|
4245
|
+
gt.create;
|
|
4246
|
+
_t.create;
|
|
4247
|
+
$e.create;
|
|
4248
|
+
Ge.create;
|
|
4249
|
+
bt.create;
|
|
4250
|
+
Ce.create;
|
|
4251
|
+
Ye.create;
|
|
4252
|
+
const Ya = Fe.createWithPreprocess, Ka = {
|
|
4253
|
+
string: ((t) => _e.create({ ...t, coerce: !0 })),
|
|
4254
|
+
number: ((t) => Pe.create({ ...t, coerce: !0 })),
|
|
4255
|
+
boolean: ((t) => yt.create({
|
|
4256
|
+
...t,
|
|
4257
|
+
coerce: !0
|
|
4258
|
+
})),
|
|
4259
|
+
bigint: ((t) => Ze.create({ ...t, coerce: !0 })),
|
|
4260
|
+
date: ((t) => Je.create({ ...t, coerce: !0 }))
|
|
4261
|
+
};
|
|
4262
|
+
const Cr = (t) => t !== null && !!t && typeof t == "object" && !Array.isArray(t);
|
|
4263
|
+
function Xr(t) {
|
|
4264
|
+
return Number(t) >= 0;
|
|
4265
|
+
}
|
|
4266
|
+
function Za(t) {
|
|
4267
|
+
return typeof t == "object" && t !== null;
|
|
4268
|
+
}
|
|
4269
|
+
function $a(t) {
|
|
4270
|
+
return t == null ? t === void 0 ? "[object Undefined]" : "[object Null]" : Object.prototype.toString.call(t);
|
|
4271
|
+
}
|
|
4272
|
+
function Ar(t) {
|
|
4273
|
+
if (!Za(t) || $a(t) !== "[object Object]")
|
|
4274
|
+
return !1;
|
|
4275
|
+
if (Object.getPrototypeOf(t) === null)
|
|
4276
|
+
return !0;
|
|
4277
|
+
let e = t;
|
|
4278
|
+
for (; Object.getPrototypeOf(e) !== null; )
|
|
4279
|
+
e = Object.getPrototypeOf(e);
|
|
4280
|
+
return Object.getPrototypeOf(t) === e;
|
|
4281
|
+
}
|
|
4282
|
+
function Qr(t, e) {
|
|
4283
|
+
return Object.keys(e).forEach((r) => {
|
|
4284
|
+
if (Ar(e[r]) && Ar(t[r])) {
|
|
4285
|
+
t[r] || (t[r] = {}), Qr(t[r], e[r]);
|
|
4286
|
+
return;
|
|
4287
|
+
}
|
|
4288
|
+
t[r] = e[r];
|
|
4289
|
+
}), t;
|
|
4290
|
+
}
|
|
4291
|
+
function Fa(t) {
|
|
4292
|
+
const e = t.split(".");
|
|
4293
|
+
if (!e.length)
|
|
4294
|
+
return "";
|
|
4295
|
+
let r = String(e[0]);
|
|
4296
|
+
for (let n = 1; n < e.length; n++) {
|
|
4297
|
+
if (Xr(e[n])) {
|
|
4298
|
+
r += `[${e[n]}]`;
|
|
4299
|
+
continue;
|
|
4300
|
+
}
|
|
4301
|
+
r += `.${e[n]}`;
|
|
4302
|
+
}
|
|
4303
|
+
return r;
|
|
4304
|
+
}
|
|
4305
|
+
function Xa(t, e) {
|
|
4306
|
+
return {
|
|
4307
|
+
__type: "VVTypedSchema",
|
|
4308
|
+
async parse(n) {
|
|
4309
|
+
const a = await t.safeParseAsync(n, e);
|
|
4310
|
+
if (a.success)
|
|
4311
|
+
return {
|
|
4312
|
+
value: a.data,
|
|
4313
|
+
errors: []
|
|
4314
|
+
};
|
|
4315
|
+
const i = {};
|
|
4316
|
+
return en(a.error.issues, i), {
|
|
4317
|
+
errors: Object.values(i)
|
|
4318
|
+
};
|
|
4319
|
+
},
|
|
4320
|
+
cast(n) {
|
|
4321
|
+
try {
|
|
4322
|
+
return t.parse(n);
|
|
4323
|
+
} catch {
|
|
4324
|
+
const i = tn(t);
|
|
4325
|
+
return Cr(i) && Cr(n) ? Qr(i, n) : n;
|
|
4326
|
+
}
|
|
4327
|
+
},
|
|
4328
|
+
describe(n) {
|
|
4329
|
+
try {
|
|
4330
|
+
if (!n)
|
|
4331
|
+
return {
|
|
4332
|
+
required: !t.isOptional(),
|
|
4333
|
+
exists: !0
|
|
4334
|
+
};
|
|
4335
|
+
const a = Ma(n, t);
|
|
4336
|
+
return a ? {
|
|
4337
|
+
required: !a.isOptional(),
|
|
4338
|
+
exists: !0
|
|
4339
|
+
} : {
|
|
4340
|
+
required: !1,
|
|
4341
|
+
exists: !1
|
|
4342
|
+
};
|
|
4343
|
+
} catch {
|
|
4344
|
+
return process.env.NODE_ENV !== "production" && console.warn(`Failed to describe path ${n} on the schema, returning a default description.`), {
|
|
4345
|
+
required: !1,
|
|
4346
|
+
exists: !1
|
|
4347
|
+
};
|
|
4348
|
+
}
|
|
4349
|
+
}
|
|
4350
|
+
};
|
|
4351
|
+
}
|
|
4352
|
+
function en(t, e) {
|
|
4353
|
+
t.forEach((r) => {
|
|
4354
|
+
const n = Fa(r.path.join("."));
|
|
4355
|
+
r.code === "invalid_union" && (en(r.unionErrors.flatMap((a) => a.issues), e), !n) || (e[n] || (e[n] = { errors: [], path: n }), e[n].errors.push(r.message));
|
|
4356
|
+
});
|
|
4357
|
+
}
|
|
4358
|
+
function tn(t) {
|
|
4359
|
+
if (t instanceof L)
|
|
4360
|
+
return Object.fromEntries(Object.entries(t.shape).map(([e, r]) => r instanceof xt ? [e, r._def.defaultValue()] : r instanceof L ? [e, tn(r)] : [e, void 0]));
|
|
4361
|
+
}
|
|
4362
|
+
function Ma(t, e) {
|
|
4363
|
+
if (!jr(e))
|
|
4364
|
+
return null;
|
|
4365
|
+
if (ot(t))
|
|
4366
|
+
return e.shape[kt(t)];
|
|
4367
|
+
const r = (t || "").split(/\.|\[(\d+)\]/).filter(Boolean);
|
|
4368
|
+
let n = e;
|
|
4369
|
+
for (let a = 0; a <= r.length; a++) {
|
|
4370
|
+
const i = r[a];
|
|
4371
|
+
if (!i || !n)
|
|
4372
|
+
return n;
|
|
4373
|
+
if (jr(n)) {
|
|
4374
|
+
n = n.shape[i] || null;
|
|
4375
|
+
continue;
|
|
4376
|
+
}
|
|
4377
|
+
Xr(i) && Da(n) && (n = n._def.type);
|
|
4378
|
+
}
|
|
4379
|
+
return null;
|
|
4380
|
+
}
|
|
4381
|
+
function rn(t) {
|
|
4382
|
+
return t._def.typeName;
|
|
4383
|
+
}
|
|
4384
|
+
function Da(t) {
|
|
4385
|
+
return rn(t) === O.ZodArray;
|
|
4386
|
+
}
|
|
4387
|
+
function jr(t) {
|
|
4388
|
+
return rn(t) === O.ZodObject;
|
|
4389
|
+
}
|
|
4390
|
+
export {
|
|
4391
|
+
Ua as a,
|
|
4392
|
+
Ja as b,
|
|
4393
|
+
qa as c,
|
|
4394
|
+
Ha as d,
|
|
4395
|
+
Ka as e,
|
|
4396
|
+
za as f,
|
|
4397
|
+
Ga as o,
|
|
4398
|
+
Ya as p,
|
|
4399
|
+
Wa as s,
|
|
4400
|
+
Xa as t,
|
|
4401
|
+
Ba as u
|
|
4402
|
+
};
|