@volverjs/form-vue 1.0.0-beta.9 → 1.1.0-beta.1

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