@volverjs/form-vue 1.0.1 → 1.1.0-beta.2

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,102 +1,3456 @@
1
- import { ref as L, computed as O, readonly as G, defineComponent as C, h as F, withModifiers as te, toRaw as B, watch as A, isProxy as ve, onMounted as q, provide as T, toRefs as Q, useId as oe, inject as U, onBeforeUnmount as P, unref as _, resolveComponent as W, defineAsyncComponent as ce, getCurrentInstance as me } from "vue";
2
- import { watchIgnorable as pe, throttleFilter as ye } from "@vueuse/core";
3
- import { ZodObject as K, ZodDefault as he, ZodNullable as be, ZodSchema as ge, ZodArray as Ve, ZodRecord as we, ZodEffects as re, ZodOptional as ae, ZodError as De } from "zod";
4
- var w = /* @__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))(w || {}), x = /* @__PURE__ */ ((e) => (e.invalid = "invalid", e.valid = "valid", e.submitting = "submitting", e.reset = "reset", e.updated = "updated", e.unknown = "unknown", e))(x || {});
5
- function Z(e, i = {}) {
6
- const a = (u) => {
7
- let o = u;
8
- for (; o instanceof re; )
9
- o = o.innerType();
10
- return o instanceof ae && (o = o._def.innerType), o;
11
- }, v = (u) => {
12
- let o = u;
13
- for (; o instanceof re; )
14
- o = o.innerType();
15
- return o instanceof ae;
16
- }, n = a(e);
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.");
17
332
  return {
18
- ...(n instanceof K ? n._def.unknownKeys === "passthrough" : !1) ? i : {},
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;
1939
+ }
1940
+ }
1941
+ get options() {
1942
+ return this._def.options;
1943
+ }
1944
+ }
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;
1961
+ }
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);
1972
+ }
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
+ }));
2006
+ }
2007
+ }
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
+ }
2053
+ }
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();
2379
+ },
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
2519
+ }
2520
+ });
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
+ }), r.message = JSON.stringify(e, lr, 2), Object.defineProperty(r, "toString", {
2709
+ value: () => r.message,
2710
+ enumerable: !1
2711
+ });
2712
+ }, bt = vt("$ZodError", _t), xt = vt("$ZodError", _t, { Parent: Error });
2713
+ function kt(r, e) {
2714
+ const t = function(a) {
2715
+ return a.message;
2716
+ }, s = { _errors: [] }, n = (a) => {
2717
+ for (const i of a.issues)
2718
+ if (i.code === "invalid_union" && i.errors.length)
2719
+ i.errors.map((o) => n({ issues: o }));
2720
+ else if (i.code === "invalid_key")
2721
+ n({ issues: i.issues });
2722
+ else if (i.code === "invalid_element")
2723
+ n({ issues: i.issues });
2724
+ else if (i.path.length === 0)
2725
+ s._errors.push(t(i));
2726
+ else {
2727
+ let o = s, u = 0;
2728
+ for (; u < i.path.length; ) {
2729
+ const l = i.path[u];
2730
+ 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++;
2731
+ }
2732
+ }
2733
+ };
2734
+ return n(r), s;
2735
+ }
2736
+ const dr = (r) => (e, t, s) => {
2737
+ const n = s ? { ...s, async: !1 } : { async: !1 }, a = e._zod.run({ value: t, issues: [] }, n);
2738
+ if (a instanceof Promise)
2739
+ throw new or();
2740
+ return a.issues.length ? {
2741
+ success: !1,
2742
+ error: new (r ?? bt)(a.issues.map((i) => gt(i, n, yt())))
2743
+ } : { success: !0, data: a.value };
2744
+ }, fr = /* @__PURE__ */ dr(xt), hr = (r) => async (e, t, s) => {
2745
+ const n = s ? Object.assign(s, { async: !0 }) : { async: !0 };
2746
+ let a = e._zod.run({ value: t, issues: [] }, n);
2747
+ return a instanceof Promise && (a = await a), a.issues.length ? {
2748
+ success: !1,
2749
+ error: new r(a.issues.map((i) => gt(i, n, yt())))
2750
+ } : { success: !0, data: a.value };
2751
+ }, pr = /* @__PURE__ */ hr(xt);
2752
+ class wt {
2753
+ constructor() {
2754
+ this._map = /* @__PURE__ */ new Map(), this._idmap = /* @__PURE__ */ new Map();
2755
+ }
2756
+ add(e, ...t) {
2757
+ const s = t[0];
2758
+ if (this._map.set(e, s), s && typeof s == "object" && "id" in s) {
2759
+ if (this._idmap.has(s.id))
2760
+ throw new Error(`ID ${s.id} already exists in the registry`);
2761
+ this._idmap.set(s.id, e);
2762
+ }
2763
+ return this;
2764
+ }
2765
+ clear() {
2766
+ return this._map = /* @__PURE__ */ new Map(), this._idmap = /* @__PURE__ */ new Map(), this;
2767
+ }
2768
+ remove(e) {
2769
+ const t = this._map.get(e);
2770
+ return t && typeof t == "object" && "id" in t && this._idmap.delete(t.id), this._map.delete(e), this;
2771
+ }
2772
+ get(e) {
2773
+ const t = e._zod.parent;
2774
+ if (t) {
2775
+ const s = { ...this.get(t) ?? {} };
2776
+ delete s.id;
2777
+ const n = { ...s, ...this._map.get(e) };
2778
+ return Object.keys(n).length ? n : void 0;
2779
+ }
2780
+ return this._map.get(e);
2781
+ }
2782
+ has(e) {
2783
+ return this._map.has(e);
2784
+ }
2785
+ }
2786
+ function mr() {
2787
+ return new wt();
2788
+ }
2789
+ const vr = /* @__PURE__ */ mr();
2790
+ class lt {
2791
+ constructor(e) {
2792
+ this.counter = 0, this.metadataRegistry = e?.metadata ?? vr, this.target = e?.target ?? "draft-2020-12", this.unrepresentable = e?.unrepresentable ?? "throw", this.override = e?.override ?? (() => {
2793
+ }), this.io = e?.io ?? "output", this.seen = /* @__PURE__ */ new Map();
2794
+ }
2795
+ process(e, t = { path: [], schemaPath: [] }) {
2796
+ var s;
2797
+ const n = e._zod.def, a = {
2798
+ guid: "uuid",
2799
+ url: "uri",
2800
+ datetime: "date-time",
2801
+ json_string: "json-string",
2802
+ regex: ""
2803
+ // do not set
2804
+ }, i = this.seen.get(e);
2805
+ if (i)
2806
+ return i.count++, t.schemaPath.includes(e) && (i.cycle = t.path), i.schema;
2807
+ const o = { schema: {}, count: 1, cycle: void 0, path: t.path };
2808
+ this.seen.set(e, o);
2809
+ const u = e._zod.toJSONSchema?.();
2810
+ if (u)
2811
+ o.schema = u;
2812
+ else {
2813
+ const f = {
2814
+ ...t,
2815
+ schemaPath: [...t.schemaPath, e],
2816
+ path: t.path
2817
+ }, k = e._zod.parent;
2818
+ if (k)
2819
+ o.ref = k, this.process(k, f), this.seen.get(k).isParent = !0;
2820
+ else {
2821
+ const b = o.schema;
2822
+ switch (n.type) {
2823
+ case "string": {
2824
+ const c = b;
2825
+ c.type = "string";
2826
+ const { minimum: h, maximum: m, format: x, patterns: j, contentEncoding: N } = e._zod.bag;
2827
+ 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) {
2828
+ const P = [...j];
2829
+ P.length === 1 ? c.pattern = P[0].source : P.length > 1 && (o.schema.allOf = [
2830
+ ...P.map((E) => ({
2831
+ ...this.target === "draft-7" ? { type: "string" } : {},
2832
+ pattern: E.source
2833
+ }))
2834
+ ]);
2835
+ }
2836
+ break;
2837
+ }
2838
+ case "number": {
2839
+ const c = b, { minimum: h, maximum: m, format: x, multipleOf: j, exclusiveMaximum: N, exclusiveMinimum: P } = e._zod.bag;
2840
+ 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);
2841
+ break;
2842
+ }
2843
+ case "boolean": {
2844
+ const c = b;
2845
+ c.type = "boolean";
2846
+ break;
2847
+ }
2848
+ case "bigint": {
2849
+ if (this.unrepresentable === "throw")
2850
+ throw new Error("BigInt cannot be represented in JSON Schema");
2851
+ break;
2852
+ }
2853
+ case "symbol": {
2854
+ if (this.unrepresentable === "throw")
2855
+ throw new Error("Symbols cannot be represented in JSON Schema");
2856
+ break;
2857
+ }
2858
+ case "null": {
2859
+ b.type = "null";
2860
+ break;
2861
+ }
2862
+ case "any":
2863
+ break;
2864
+ case "unknown":
2865
+ break;
2866
+ case "undefined": {
2867
+ if (this.unrepresentable === "throw")
2868
+ throw new Error("Undefined cannot be represented in JSON Schema");
2869
+ break;
2870
+ }
2871
+ case "void": {
2872
+ if (this.unrepresentable === "throw")
2873
+ throw new Error("Void cannot be represented in JSON Schema");
2874
+ break;
2875
+ }
2876
+ case "never": {
2877
+ b.not = {};
2878
+ break;
2879
+ }
2880
+ case "date": {
2881
+ if (this.unrepresentable === "throw")
2882
+ throw new Error("Date cannot be represented in JSON Schema");
2883
+ break;
2884
+ }
2885
+ case "array": {
2886
+ const c = b, { minimum: h, maximum: m } = e._zod.bag;
2887
+ 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"] });
2888
+ break;
2889
+ }
2890
+ case "object": {
2891
+ const c = b;
2892
+ c.type = "object", c.properties = {};
2893
+ const h = n.shape;
2894
+ for (const j in h)
2895
+ c.properties[j] = this.process(h[j], {
2896
+ ...f,
2897
+ path: [...f.path, "properties", j]
2898
+ });
2899
+ const m = new Set(Object.keys(h)), x = new Set([...m].filter((j) => {
2900
+ const N = n.shape[j]._zod;
2901
+ return this.io === "input" ? N.optin === void 0 : N.optout === void 0;
2902
+ }));
2903
+ 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, {
2904
+ ...f,
2905
+ path: [...f.path, "additionalProperties"]
2906
+ })) : this.io === "output" && (c.additionalProperties = !1);
2907
+ break;
2908
+ }
2909
+ case "union": {
2910
+ const c = b;
2911
+ c.anyOf = n.options.map((h, m) => this.process(h, {
2912
+ ...f,
2913
+ path: [...f.path, "anyOf", m]
2914
+ }));
2915
+ break;
2916
+ }
2917
+ case "intersection": {
2918
+ const c = b, h = this.process(n.left, {
2919
+ ...f,
2920
+ path: [...f.path, "allOf", 0]
2921
+ }), m = this.process(n.right, {
2922
+ ...f,
2923
+ path: [...f.path, "allOf", 1]
2924
+ }), x = (N) => "allOf" in N && Object.keys(N).length === 1, j = [
2925
+ ...x(h) ? h.allOf : [h],
2926
+ ...x(m) ? m.allOf : [m]
2927
+ ];
2928
+ c.allOf = j;
2929
+ break;
2930
+ }
2931
+ case "tuple": {
2932
+ const c = b;
2933
+ c.type = "array";
2934
+ const h = n.items.map((j, N) => this.process(j, { ...f, path: [...f.path, "prefixItems", N] }));
2935
+ if (this.target === "draft-2020-12" ? c.prefixItems = h : c.items = h, n.rest) {
2936
+ const j = this.process(n.rest, {
2937
+ ...f,
2938
+ path: [...f.path, "items"]
2939
+ });
2940
+ this.target === "draft-2020-12" ? c.items = j : c.additionalItems = j;
2941
+ }
2942
+ n.rest && (c.items = this.process(n.rest, {
2943
+ ...f,
2944
+ path: [...f.path, "items"]
2945
+ }));
2946
+ const { minimum: m, maximum: x } = e._zod.bag;
2947
+ typeof m == "number" && (c.minItems = m), typeof x == "number" && (c.maxItems = x);
2948
+ break;
2949
+ }
2950
+ case "record": {
2951
+ const c = b;
2952
+ c.type = "object", c.propertyNames = this.process(n.keyType, { ...f, path: [...f.path, "propertyNames"] }), c.additionalProperties = this.process(n.valueType, {
2953
+ ...f,
2954
+ path: [...f.path, "additionalProperties"]
2955
+ });
2956
+ break;
2957
+ }
2958
+ case "map": {
2959
+ if (this.unrepresentable === "throw")
2960
+ throw new Error("Map cannot be represented in JSON Schema");
2961
+ break;
2962
+ }
2963
+ case "set": {
2964
+ if (this.unrepresentable === "throw")
2965
+ throw new Error("Set cannot be represented in JSON Schema");
2966
+ break;
2967
+ }
2968
+ case "enum": {
2969
+ const c = b, h = cr(n.entries);
2970
+ h.every((m) => typeof m == "number") && (c.type = "number"), h.every((m) => typeof m == "string") && (c.type = "string"), c.enum = h;
2971
+ break;
2972
+ }
2973
+ case "literal": {
2974
+ const c = b, h = [];
2975
+ for (const m of n.values)
2976
+ if (m === void 0) {
2977
+ if (this.unrepresentable === "throw")
2978
+ throw new Error("Literal `undefined` cannot be represented in JSON Schema");
2979
+ } else if (typeof m == "bigint") {
2980
+ if (this.unrepresentable === "throw")
2981
+ throw new Error("BigInt literals cannot be represented in JSON Schema");
2982
+ h.push(Number(m));
2983
+ } else
2984
+ h.push(m);
2985
+ if (h.length !== 0) if (h.length === 1) {
2986
+ const m = h[0];
2987
+ c.type = m === null ? "null" : typeof m, c.const = m;
2988
+ } else
2989
+ 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;
2990
+ break;
2991
+ }
2992
+ case "file": {
2993
+ const c = b, h = {
2994
+ type: "string",
2995
+ format: "binary",
2996
+ contentEncoding: "binary"
2997
+ }, { minimum: m, maximum: x, mime: j } = e._zod.bag;
2998
+ 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);
2999
+ break;
3000
+ }
3001
+ case "transform": {
3002
+ if (this.unrepresentable === "throw")
3003
+ throw new Error("Transforms cannot be represented in JSON Schema");
3004
+ break;
3005
+ }
3006
+ case "nullable": {
3007
+ const c = this.process(n.innerType, f);
3008
+ b.anyOf = [c, { type: "null" }];
3009
+ break;
3010
+ }
3011
+ case "nonoptional": {
3012
+ this.process(n.innerType, f), o.ref = n.innerType;
3013
+ break;
3014
+ }
3015
+ case "success": {
3016
+ const c = b;
3017
+ c.type = "boolean";
3018
+ break;
3019
+ }
3020
+ case "default": {
3021
+ this.process(n.innerType, f), o.ref = n.innerType, b.default = JSON.parse(JSON.stringify(n.defaultValue));
3022
+ break;
3023
+ }
3024
+ case "prefault": {
3025
+ this.process(n.innerType, f), o.ref = n.innerType, this.io === "input" && (b._prefault = JSON.parse(JSON.stringify(n.defaultValue)));
3026
+ break;
3027
+ }
3028
+ case "catch": {
3029
+ this.process(n.innerType, f), o.ref = n.innerType;
3030
+ let c;
3031
+ try {
3032
+ c = n.catchValue(void 0);
3033
+ } catch {
3034
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
3035
+ }
3036
+ b.default = c;
3037
+ break;
3038
+ }
3039
+ case "nan": {
3040
+ if (this.unrepresentable === "throw")
3041
+ throw new Error("NaN cannot be represented in JSON Schema");
3042
+ break;
3043
+ }
3044
+ case "template_literal": {
3045
+ const c = b, h = e._zod.pattern;
3046
+ if (!h)
3047
+ throw new Error("Pattern not found in template literal");
3048
+ c.type = "string", c.pattern = h.source;
3049
+ break;
3050
+ }
3051
+ case "pipe": {
3052
+ const c = this.io === "input" ? n.in._zod.def.type === "transform" ? n.out : n.in : n.out;
3053
+ this.process(c, f), o.ref = c;
3054
+ break;
3055
+ }
3056
+ case "readonly": {
3057
+ this.process(n.innerType, f), o.ref = n.innerType, b.readOnly = !0;
3058
+ break;
3059
+ }
3060
+ // passthrough types
3061
+ case "promise": {
3062
+ this.process(n.innerType, f), o.ref = n.innerType;
3063
+ break;
3064
+ }
3065
+ case "optional": {
3066
+ this.process(n.innerType, f), o.ref = n.innerType;
3067
+ break;
3068
+ }
3069
+ case "lazy": {
3070
+ const c = e._zod.innerType;
3071
+ this.process(c, f), o.ref = c;
3072
+ break;
3073
+ }
3074
+ case "custom": {
3075
+ if (this.unrepresentable === "throw")
3076
+ throw new Error("Custom types cannot be represented in JSON Schema");
3077
+ break;
3078
+ }
3079
+ }
3080
+ }
3081
+ }
3082
+ const l = this.metadataRegistry.get(e);
3083
+ 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;
3084
+ }
3085
+ emit(e, t) {
3086
+ const s = {
3087
+ cycles: t?.cycles ?? "ref",
3088
+ reused: t?.reused ?? "inline",
3089
+ // unrepresentable: _params?.unrepresentable ?? "throw",
3090
+ // uri: _params?.uri ?? ((id) => `${id}`),
3091
+ external: t?.external ?? void 0
3092
+ }, n = this.seen.get(e);
3093
+ if (!n)
3094
+ throw new Error("Unprocessed schema. This is a bug in Zod.");
3095
+ const a = (d) => {
3096
+ const f = this.target === "draft-2020-12" ? "$defs" : "definitions";
3097
+ if (s.external) {
3098
+ const h = s.external.registry.get(d[0])?.id, m = s.external.uri ?? ((j) => j);
3099
+ if (h)
3100
+ return { ref: m(h) };
3101
+ const x = d[1].defId ?? d[1].schema.id ?? `schema${this.counter++}`;
3102
+ return d[1].defId = x, { defId: x, ref: `${m("__shared")}#/${f}/${x}` };
3103
+ }
3104
+ if (d[1] === n)
3105
+ return { ref: "#" };
3106
+ const b = `#/${f}/`, c = d[1].schema.id ?? `__schema${this.counter++}`;
3107
+ return { defId: c, ref: b + c };
3108
+ }, i = (d) => {
3109
+ if (d[1].schema.$ref)
3110
+ return;
3111
+ const f = d[1], { ref: k, defId: b } = a(d);
3112
+ f.def = { ...f.schema }, b && (f.defId = b);
3113
+ const c = f.schema;
3114
+ for (const h in c)
3115
+ delete c[h];
3116
+ c.$ref = k;
3117
+ };
3118
+ if (s.cycles === "throw")
3119
+ for (const d of this.seen.entries()) {
3120
+ const f = d[1];
3121
+ if (f.cycle)
3122
+ throw new Error(`Cycle detected: #/${f.cycle?.join("/")}/<root>
3123
+
3124
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
3125
+ }
3126
+ for (const d of this.seen.entries()) {
3127
+ const f = d[1];
3128
+ if (e === d[0]) {
3129
+ i(d);
3130
+ continue;
3131
+ }
3132
+ if (s.external) {
3133
+ const b = s.external.registry.get(d[0])?.id;
3134
+ if (e !== d[0] && b) {
3135
+ i(d);
3136
+ continue;
3137
+ }
3138
+ }
3139
+ if (this.metadataRegistry.get(d[0])?.id) {
3140
+ i(d);
3141
+ continue;
3142
+ }
3143
+ if (f.cycle) {
3144
+ i(d);
3145
+ continue;
3146
+ }
3147
+ if (f.count > 1 && s.reused === "ref") {
3148
+ i(d);
3149
+ continue;
3150
+ }
3151
+ }
3152
+ const o = (d, f) => {
3153
+ const k = this.seen.get(d), b = k.def ?? k.schema, c = { ...b };
3154
+ if (k.ref === null)
3155
+ return;
3156
+ const h = k.ref;
3157
+ if (k.ref = null, h) {
3158
+ o(h, f);
3159
+ const m = this.seen.get(h).schema;
3160
+ m.$ref && f.target === "draft-7" ? (b.allOf = b.allOf ?? [], b.allOf.push(m)) : (Object.assign(b, m), Object.assign(b, c));
3161
+ }
3162
+ k.isParent || this.override({
3163
+ zodSchema: d,
3164
+ jsonSchema: b,
3165
+ path: k.path ?? []
3166
+ });
3167
+ };
3168
+ for (const d of [...this.seen.entries()].reverse())
3169
+ o(d[0], { target: this.target });
3170
+ const u = {};
3171
+ 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) {
3172
+ const d = s.external.registry.get(e)?.id;
3173
+ if (!d)
3174
+ throw new Error("Schema is missing an `id` property");
3175
+ u.$id = s.external.uri(d);
3176
+ }
3177
+ Object.assign(u, n.def);
3178
+ const l = s.external?.defs ?? {};
3179
+ for (const d of this.seen.entries()) {
3180
+ const f = d[1];
3181
+ f.def && f.defId && (l[f.defId] = f.def);
3182
+ }
3183
+ s.external || Object.keys(l).length > 0 && (this.target === "draft-2020-12" ? u.$defs = l : u.definitions = l);
3184
+ try {
3185
+ return JSON.parse(JSON.stringify(u));
3186
+ } catch {
3187
+ throw new Error("Error converting schema to JSON.");
3188
+ }
3189
+ }
3190
+ }
3191
+ function yr(r, e) {
3192
+ if (r instanceof wt) {
3193
+ const s = new lt(e), n = {};
3194
+ for (const o of r._idmap.entries()) {
3195
+ const [u, l] = o;
3196
+ s.process(l);
3197
+ }
3198
+ const a = {}, i = {
3199
+ registry: r,
3200
+ uri: e?.uri,
3201
+ defs: n
3202
+ };
3203
+ for (const o of r._idmap.entries()) {
3204
+ const [u, l] = o;
3205
+ a[u] = s.emit(l, {
3206
+ ...e,
3207
+ external: i
3208
+ });
3209
+ }
3210
+ if (Object.keys(n).length > 0) {
3211
+ const o = s.target === "draft-2020-12" ? "$defs" : "definitions";
3212
+ a.__shared = {
3213
+ [o]: n
3214
+ };
3215
+ }
3216
+ return { schemas: a };
3217
+ }
3218
+ const t = new lt(e);
3219
+ return t.process(r), t.emit(r, e);
3220
+ }
3221
+ function z(r, e) {
3222
+ const t = e ?? { seen: /* @__PURE__ */ new Set() };
3223
+ if (t.seen.has(r))
3224
+ return !1;
3225
+ t.seen.add(r);
3226
+ const n = r._zod.def;
3227
+ switch (n.type) {
3228
+ case "string":
3229
+ case "number":
3230
+ case "bigint":
3231
+ case "boolean":
3232
+ case "date":
3233
+ case "symbol":
3234
+ case "undefined":
3235
+ case "null":
3236
+ case "any":
3237
+ case "unknown":
3238
+ case "never":
3239
+ case "void":
3240
+ case "literal":
3241
+ case "enum":
3242
+ case "nan":
3243
+ case "file":
3244
+ case "template_literal":
3245
+ return !1;
3246
+ case "array":
3247
+ return z(n.element, t);
3248
+ case "object": {
3249
+ for (const a in n.shape)
3250
+ if (z(n.shape[a], t))
3251
+ return !0;
3252
+ return !1;
3253
+ }
3254
+ case "union": {
3255
+ for (const a of n.options)
3256
+ if (z(a, t))
3257
+ return !0;
3258
+ return !1;
3259
+ }
3260
+ case "intersection":
3261
+ return z(n.left, t) || z(n.right, t);
3262
+ case "tuple": {
3263
+ for (const a of n.items)
3264
+ if (z(a, t))
3265
+ return !0;
3266
+ return !!(n.rest && z(n.rest, t));
3267
+ }
3268
+ case "record":
3269
+ return z(n.keyType, t) || z(n.valueType, t);
3270
+ case "map":
3271
+ return z(n.keyType, t) || z(n.valueType, t);
3272
+ case "set":
3273
+ return z(n.valueType, t);
3274
+ // inner types
3275
+ case "promise":
3276
+ case "optional":
3277
+ case "nonoptional":
3278
+ case "nullable":
3279
+ case "readonly":
3280
+ return z(n.innerType, t);
3281
+ case "lazy":
3282
+ return z(n.getter(), t);
3283
+ case "default":
3284
+ return z(n.innerType, t);
3285
+ case "prefault":
3286
+ return z(n.innerType, t);
3287
+ case "custom":
3288
+ return !1;
3289
+ case "transform":
3290
+ return !0;
3291
+ case "pipe":
3292
+ return z(n.in, t) || z(n.out, t);
3293
+ case "success":
3294
+ return !1;
3295
+ case "catch":
3296
+ return !1;
3297
+ }
3298
+ throw new Error(`Unknown schema type: ${n.type}`);
3299
+ }
3300
+ const xe = (r) => {
3301
+ let e = r;
3302
+ for (; e instanceof se; )
3303
+ e = e.innerType();
3304
+ return e instanceof G && (e = e._def.innerType), e;
3305
+ }, gr = (r) => {
3306
+ let e = r;
3307
+ for (; e instanceof se; )
3308
+ e = e.innerType();
3309
+ return e instanceof G || e instanceof ae;
3310
+ };
3311
+ function _r(r) {
3312
+ return Array.isArray(r) ? "array" : r === null ? "null" : typeof r;
3313
+ }
3314
+ function br(r, e) {
3315
+ const t = _r(r);
3316
+ return e.type ? e.type === t || e.type === "integer" && t === "number" && Number.isInteger(r) : !0;
3317
+ }
3318
+ function ue(r, e) {
3319
+ if (r.anyOf && Array.isArray(r.anyOf)) {
3320
+ if (e !== void 0) {
3321
+ for (const i of r.anyOf)
3322
+ if (br(e, i))
3323
+ return ue(i, e);
3324
+ for (const i of r.anyOf) {
3325
+ const o = i;
3326
+ if (!o.type || o.type === "object")
3327
+ return ue(o, e);
3328
+ }
3329
+ }
3330
+ return ue(r.anyOf[0], e);
3331
+ }
3332
+ if (r.type !== "object" || !r.properties)
3333
+ switch (r.type) {
3334
+ case "string":
3335
+ return typeof e == "string" ? e : r.default;
3336
+ case "number":
3337
+ case "integer":
3338
+ return typeof e == "number" ? e : r.default;
3339
+ case "boolean":
3340
+ return typeof e == "boolean" ? e : r.default;
3341
+ case "null":
3342
+ return e === null ? e : r.default;
3343
+ case "array":
3344
+ return Array.isArray(e) && r.items ? e.map((i) => ue(r.items, i)) : r.default;
3345
+ default:
3346
+ return r.default;
3347
+ }
3348
+ const t = r.properties, n = e && typeof e == "object" && !Array.isArray(e) ? e : void 0, a = {};
3349
+ for (const i in t) {
3350
+ const o = n?.[i];
3351
+ a[i] = ue(t[i], o);
3352
+ }
3353
+ if (n && r.additionalProperties !== !1) {
3354
+ const i = new Set(Object.keys(t));
3355
+ for (const [o, u] of Object.entries(n))
3356
+ i.has(o) || (a[o] = u);
3357
+ }
3358
+ return a;
3359
+ }
3360
+ const Ze = (r) => "_zod" in r;
3361
+ function we(r, e = {}) {
3362
+ if (Ze(r)) {
3363
+ const n = yr(r);
3364
+ if (n.type !== "object" || !n.properties)
3365
+ return e;
3366
+ const a = fr(r, e);
3367
+ return ue(n, a.success ? a.data : e);
3368
+ }
3369
+ const t = xe(r);
3370
+ return t instanceof $ ? {
3371
+ ...(t instanceof $ ? t._def.unknownKeys === "passthrough" : !1) ? e : {},
19
3372
  ...Object.fromEntries(
20
- Object.entries(n.shape).map(
21
- ([u, o]) => {
22
- const r = i[u], p = v(o);
23
- let d = a(o), c;
24
- if (d instanceof he && (c = d._def.defaultValue(), d = d._def.innerType), r === null && d instanceof be)
25
- return [u, r];
26
- if (r == null && p)
27
- return [u, c];
28
- if (d instanceof ge) {
29
- const m = o.safeParse(r);
30
- if (m.success)
31
- return [u, m.data ?? c];
3373
+ ("shape" in t ? Object.entries(t.shape) : []).map(
3374
+ ([n, a]) => {
3375
+ const i = e[n], o = gr(a);
3376
+ let u = xe(a), l;
3377
+ if (u instanceof Ee && (l = u._def.defaultValue(), u = u._def.innerType), i === null && u instanceof ae)
3378
+ return [n, i];
3379
+ if (i == null && o)
3380
+ return [n, l];
3381
+ if (u instanceof I) {
3382
+ const d = a.safeParse(i);
3383
+ if (d.success)
3384
+ return [n, d.data ?? l];
32
3385
  }
33
- if (d instanceof Ve && Array.isArray(r) && r.length) {
34
- const m = a(d._def.type);
35
- if (m instanceof K)
3386
+ if (u instanceof W && Array.isArray(i) && i.length) {
3387
+ const d = xe(u._def.type);
3388
+ if (d instanceof $)
36
3389
  return [
37
- u,
38
- r.map(
39
- (j) => Z(
40
- m,
41
- j && typeof j == "object" ? j : void 0
3390
+ n,
3391
+ i.map(
3392
+ (f) => we(
3393
+ d,
3394
+ f && typeof f == "object" ? f : void 0
42
3395
  )
43
3396
  )
44
3397
  ];
45
3398
  }
46
- if (d instanceof we && r) {
47
- const m = a(d._def.valueType);
48
- if (m instanceof K)
49
- return [u, Object.keys(r).reduce((j, y) => (j[y] = Z(m, r[y]), j), {})];
3399
+ if (u instanceof Ie && i) {
3400
+ const d = xe(u._def.valueType);
3401
+ if (d instanceof $)
3402
+ return [n, Object.keys(i).reduce((f, k) => (f[k] = we(d, i[k]), f), {})];
50
3403
  }
51
- return d instanceof K ? [
52
- u,
53
- Z(
54
- d,
55
- r && typeof r == "object" ? r : c
3404
+ return u instanceof $ ? [
3405
+ n,
3406
+ we(
3407
+ u,
3408
+ i && typeof i == "object" ? i : l
56
3409
  )
57
- ] : [u, c];
3410
+ ] : [n, l];
58
3411
  }
59
3412
  )
60
3413
  )
61
- };
3414
+ } : e;
62
3415
  }
63
- function je(e, i, a, v, n) {
64
- const l = L(), u = L(), o = O(() => u.value === x.invalid), r = L(), p = L(!1);
3416
+ 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();
3417
+ function Or(r, e, t, s, n) {
3418
+ const a = ce(), i = ce(), o = Z(() => i.value === L.invalid), u = ce(), l = ce(!1);
65
3419
  let d;
66
- const c = (D) => {
67
- const S = Z(e, D);
68
- if (a?.class) {
69
- const t = a.class;
70
- return new t(S);
3420
+ const f = (E) => {
3421
+ const D = we(r, E);
3422
+ if (t?.class) {
3423
+ const g = t.class;
3424
+ return new g(D);
71
3425
  }
72
- return S;
73
- }, m = async (D = r.value, S) => {
74
- if (d = S?.fields, p.value)
3426
+ return D;
3427
+ }, k = async (E = u.value, D) => {
3428
+ if (d = D?.fields, l.value)
75
3429
  return !0;
76
- const t = S?.superRefine ? await e.superRefine(S.superRefine).safeParseAsync(D) : await e.safeParseAsync(D);
77
- if (!t.success) {
78
- if (u.value = x.invalid, !d?.size)
79
- return l.value = t.error.format(), !1;
80
- const V = t.error.issues.filter(
81
- ($) => d?.has($.path.join("."))
3430
+ const g = await xr(r, E);
3431
+ if (!g.success) {
3432
+ if (i.value = L.invalid, !d?.size)
3433
+ return a.value = kr(r, g.error), !1;
3434
+ const A = g.error.issues.filter(
3435
+ (Q) => d?.has(Q.path.join("."))
82
3436
  );
83
- return V.length ? (l.value = new De(V).format(), !1) : (l.value = void 0, !0);
3437
+ return A.length ? (a.value = wr(r, A), !1) : (a.value = void 0, !0);
84
3438
  }
85
- return l.value = void 0, u.value = x.valid, r.value = c(t.data), !0;
86
- }, j = () => {
87
- l.value = void 0, u.value = void 0, d = void 0;
88
- }, y = () => {
89
- r.value = c(), j(), u.value = x.reset;
90
- }, f = async (D) => p.value || !await m(void 0, D) ? !1 : (u.value = x.submitting, !0), { ignoreUpdates: h, stop: g } = pe(
91
- r,
3439
+ return a.value = void 0, i.value = L.valid, u.value = f(g.data), !0;
3440
+ }, b = () => {
3441
+ a.value = void 0, i.value = void 0, d = void 0;
3442
+ }, c = () => {
3443
+ u.value = f(), b(), i.value = L.reset;
3444
+ }, h = async (E) => l.value || !await k(void 0, E) ? !1 : (i.value = L.submitting, !0), { ignoreUpdates: m, stop: x } = Rt(
3445
+ u,
92
3446
  () => {
93
- u.value = x.updated;
3447
+ i.value = L.updated;
94
3448
  },
95
3449
  {
96
3450
  deep: !0,
97
- eventFilter: ye(a?.updateThrottle ?? 500)
3451
+ eventFilter: Vt(t?.updateThrottle ?? 500)
98
3452
  }
99
- ), I = G(l), R = G(u), k = C({
3453
+ ), j = H(a), N = H(i), P = _e({
100
3454
  name: "VvForm",
101
3455
  props: {
102
3456
  continuousValidation: {
@@ -109,7 +3463,7 @@ function je(e, i, a, v, n) {
109
3463
  },
110
3464
  readonly: {
111
3465
  type: Boolean,
112
- default: a?.readonly ?? !1
3466
+ default: t?.readonly
113
3467
  },
114
3468
  tag: {
115
3469
  type: String,
@@ -150,215 +3504,215 @@ function je(e, i, a, v, n) {
150
3504
  "reset"
151
3505
  ],
152
3506
  slots: Object,
153
- setup(D, { emit: S }) {
154
- return r.value = c(B(D.modelValue)), A(
155
- () => D.modelValue,
156
- (t) => {
157
- if (t) {
158
- const V = ve(t) ? B(t) : t;
159
- if (JSON.stringify(V) === JSON.stringify(B(r.value)))
3507
+ setup(E, { emit: D }) {
3508
+ return u.value = f(X(E.modelValue)), J(
3509
+ () => E.modelValue,
3510
+ (g) => {
3511
+ if (g) {
3512
+ const A = Ct(g) ? X(g) : g;
3513
+ if (JSON.stringify(A) === JSON.stringify(X(u.value)))
160
3514
  return;
161
- r.value = typeof V?.clone == "function" ? V.clone() : JSON.parse(JSON.stringify(V));
3515
+ u.value = typeof A?.clone == "function" ? A.clone() : JSON.parse(JSON.stringify(A));
162
3516
  }
163
3517
  },
164
3518
  { deep: !0 }
165
- ), A(u, async (t) => {
166
- if (t === x.invalid) {
167
- const V = B(l.value);
168
- S("invalid", V), a?.onInvalid?.(
169
- V
3519
+ ), J(i, async (g) => {
3520
+ if (g === L.invalid) {
3521
+ const A = X(a.value);
3522
+ D("invalid", A), t?.onInvalid?.(
3523
+ A
170
3524
  );
171
3525
  return;
172
3526
  }
173
- if (t === x.valid) {
174
- const V = B(r.value);
175
- S("valid", V), a?.onValid?.(V), S("update:modelValue", V), a?.onUpdate?.(V);
3527
+ if (g === L.valid) {
3528
+ const A = X(u.value);
3529
+ D("valid", A), t?.onValid?.(A), D("update:modelValue", A), t?.onUpdate?.(A);
176
3530
  return;
177
3531
  }
178
- if (t === x.submitting) {
179
- const V = B(r.value);
180
- S("submit", V), a?.onSubmit?.(V);
3532
+ if (g === L.submitting) {
3533
+ const A = X(u.value);
3534
+ D("submit", A), t?.onSubmit?.(A);
181
3535
  return;
182
3536
  }
183
- if (t === x.reset) {
184
- const V = B(r.value);
185
- S("reset", V), a?.onReset?.(V);
3537
+ if (g === L.reset) {
3538
+ const A = X(u.value);
3539
+ D("reset", A), t?.onReset?.(A);
186
3540
  return;
187
3541
  }
188
- if (t === x.updated) {
189
- if ((l.value || a?.continuousValidation || D.continuousValidation) && await m(void 0, {
190
- superRefine: D.superRefine,
191
- fields: d ?? new Set(D.validateFields)
192
- }), !r.value || !D.modelValue || JSON.stringify(r.value) !== JSON.stringify(D.modelValue)) {
193
- const V = B(r.value);
194
- S("update:modelValue", V), a?.onUpdate?.(V);
3542
+ if (g === L.updated) {
3543
+ if ((a.value || t?.continuousValidation || E.continuousValidation) && await k(void 0, {
3544
+ superRefine: E.superRefine,
3545
+ fields: d ?? new Set(E.validateFields)
3546
+ }), !u.value || !E.modelValue || JSON.stringify(u.value) !== JSON.stringify(E.modelValue)) {
3547
+ const A = X(u.value);
3548
+ D("update:modelValue", A), t?.onUpdate?.(A);
195
3549
  }
196
- u.value === x.updated && (u.value = x.unknown);
3550
+ i.value === L.updated && (i.value = L.unknown);
197
3551
  }
198
- }), q(() => {
199
- p.value = D.readonly;
200
- }), A(
201
- () => D.readonly,
202
- (t) => {
203
- p.value = t;
3552
+ }), Re(() => {
3553
+ E.readonly !== void 0 && (l.value = E.readonly);
3554
+ }), J(
3555
+ () => E.readonly,
3556
+ (g) => {
3557
+ l.value = g;
204
3558
  }
205
- ), A(p, (t) => {
206
- t !== D.readonly && S("update:readonly", p.value);
207
- }), T(i, {
208
- clear: j,
209
- errors: I,
210
- formData: r,
211
- ignoreUpdates: h,
3559
+ ), J(l, (g) => {
3560
+ g !== E.readonly && D("update:readonly", l.value);
3561
+ }), Ve(e, {
3562
+ clear: b,
3563
+ errors: j,
3564
+ formData: u,
3565
+ ignoreUpdates: m,
212
3566
  invalid: o,
213
- readonly: p,
214
- reset: y,
215
- status: R,
216
- stopUpdatesWatch: g,
217
- submit: f,
218
- validate: m,
3567
+ readonly: l,
3568
+ reset: c,
3569
+ status: N,
3570
+ stopUpdatesWatch: x,
3571
+ submit: h,
3572
+ validate: k,
219
3573
  wrappers: n
220
3574
  }), {
221
- clear: j,
222
- errors: I,
223
- formData: r,
224
- ignoreUpdates: h,
3575
+ clear: b,
3576
+ errors: j,
3577
+ formData: u,
3578
+ ignoreUpdates: m,
225
3579
  invalid: o,
226
- isReadonly: p,
227
- reset: y,
228
- status: R,
229
- stopUpdatesWatch: g,
230
- submit: () => f({
231
- superRefine: D.superRefine,
232
- fields: new Set(D.validateFields)
3580
+ isReadonly: l,
3581
+ reset: c,
3582
+ status: N,
3583
+ stopUpdatesWatch: x,
3584
+ submit: () => h({
3585
+ superRefine: E.superRefine,
3586
+ fields: new Set(E.validateFields)
233
3587
  }),
234
- validate: m,
3588
+ validate: k,
235
3589
  wrappers: n
236
3590
  };
237
3591
  },
238
3592
  render() {
239
- const D = () => this.$slots?.default?.({
240
- errors: I.value,
241
- formData: r.value,
3593
+ const E = () => this.$slots?.default?.({
3594
+ errors: j.value,
3595
+ formData: u.value,
242
3596
  invalid: o.value,
243
- readonly: p.value,
244
- status: R.value,
3597
+ readonly: l.value,
3598
+ status: N.value,
245
3599
  wrappers: n,
246
- clear: j,
247
- ignoreUpdates: h,
248
- reset: y,
249
- stopUpdatesWatch: g,
250
- submit: f,
251
- validate: m
3600
+ clear: b,
3601
+ ignoreUpdates: m,
3602
+ reset: c,
3603
+ stopUpdatesWatch: x,
3604
+ submit: h,
3605
+ validate: k
252
3606
  }) ?? this.$slots.default;
253
3607
  return F(
254
3608
  this.tag,
255
3609
  {
256
- onSubmit: te(this.submit, ["prevent"]),
257
- onReset: te(this.reset, ["prevent"])
3610
+ onSubmit: Ge(this.submit, ["prevent"]),
3611
+ onReset: Ge(this.reset, ["prevent"])
258
3612
  },
259
- (this.template ?? a?.template) && v ? [
3613
+ (this.template ?? t?.template) && s ? [
260
3614
  F(
261
- v,
3615
+ s,
262
3616
  {
263
- schema: this.template ?? a?.template
3617
+ schema: this.template ?? t?.template
264
3618
  },
265
3619
  {
266
- default: D
3620
+ default: E
267
3621
  }
268
3622
  )
269
3623
  ] : {
270
- default: D
3624
+ default: E
271
3625
  }
272
3626
  );
273
3627
  }
274
3628
  });
275
3629
  return {
276
- clear: j,
277
- errors: l,
278
- formData: r,
279
- ignoreUpdates: h,
3630
+ clear: b,
3631
+ errors: a,
3632
+ formData: u,
3633
+ ignoreUpdates: m,
280
3634
  invalid: o,
281
- readonly: p,
282
- reset: y,
283
- status: u,
3635
+ readonly: l,
3636
+ reset: c,
3637
+ status: i,
284
3638
  wrappers: n,
285
- stopUpdatesWatch: g,
286
- submit: f,
287
- validate: m,
288
- VvForm: k
3639
+ stopUpdatesWatch: x,
3640
+ submit: h,
3641
+ validate: k,
3642
+ VvForm: P
289
3643
  };
290
3644
  }
291
- function H(e) {
292
- return Array.isArray(e);
3645
+ function Le(r) {
3646
+ return Array.isArray(r);
293
3647
  }
294
- function Oe(e) {
3648
+ function Sr(r) {
295
3649
  return !1;
296
3650
  }
297
- function ne(e) {
298
- return e === null;
3651
+ function dt(r) {
3652
+ return r === null;
299
3653
  }
300
- function le(e) {
301
- return typeof e == "object";
3654
+ function Ot(r) {
3655
+ return typeof r == "object";
302
3656
  }
303
- function ue(e) {
304
- return typeof e == "string";
3657
+ function St(r) {
3658
+ return typeof r == "string";
305
3659
  }
306
- function z(e) {
307
- return typeof e > "u";
3660
+ function Oe(r) {
3661
+ return typeof r > "u";
308
3662
  }
309
- const Se = /^[0-9]+$/, Re = ["__proto__", "prototype", "constructor"];
310
- function N(e, i, a) {
311
- const v = Oe() ? a : void 0;
312
- if (!le(e) || !ue(i))
313
- return v;
314
- const n = ie(i);
3663
+ const jr = /^[0-9]+$/, Tr = ["__proto__", "prototype", "constructor"];
3664
+ function he(r, e, t) {
3665
+ const s = Sr() ? t : void 0;
3666
+ if (!Ot(r) || !St(e))
3667
+ return s;
3668
+ const n = jt(e);
315
3669
  if (n.length !== 0) {
316
- for (const l of n) {
317
- if (l === "*")
3670
+ for (const a of n) {
3671
+ if (a === "*")
318
3672
  continue;
319
- const u = function(o) {
320
- return o.map((r) => z(r) || ne(r) ? r : H(r) ? u(r) : r[l]);
3673
+ const i = function(o) {
3674
+ return o.map((u) => Oe(u) || dt(u) ? u : Le(u) ? i(u) : u[a]);
321
3675
  };
322
- if (H(e) && !Se.test(l) ? e = u(e) : e = e[l], z(e) || ne(e))
3676
+ if (Le(r) && !jr.test(a) ? r = i(r) : r = r[a], Oe(r) || dt(r))
323
3677
  break;
324
3678
  }
325
- return z(e) ? v : e;
3679
+ return Oe(r) ? s : r;
326
3680
  }
327
3681
  }
328
- function X(e, i, a) {
329
- if (!le(e) || !ue(i))
3682
+ function Be(r, e, t) {
3683
+ if (!Ot(r) || !St(e))
330
3684
  return;
331
- const v = ie(i);
332
- if (v.length === 0)
3685
+ const s = jt(e);
3686
+ if (s.length === 0)
333
3687
  return;
334
- const n = v.length;
335
- for (let l = 0; l < n; l++) {
336
- const u = v[l];
337
- if (l === n - 1) {
338
- e[u] = a;
3688
+ const n = s.length;
3689
+ for (let a = 0; a < n; a++) {
3690
+ const i = s[a];
3691
+ if (a === n - 1) {
3692
+ r[i] = t;
339
3693
  return;
340
3694
  }
341
- if (u === "*" && H(e)) {
342
- const o = v.slice(l + 1).join(".");
343
- for (const r of e)
344
- X(r, o, a);
3695
+ if (i === "*" && Le(r)) {
3696
+ const o = s.slice(a + 1).join(".");
3697
+ for (const u of r)
3698
+ Be(u, o, t);
345
3699
  return;
346
3700
  }
347
- z(e[u]) && (e[u] = {}), e = e[u];
3701
+ Oe(r[i]) && (r[i] = {}), r = r[i];
348
3702
  }
349
3703
  }
350
- function ie(e) {
351
- const i = e.split(/[.]|(?:\[(\d|\*)\])/).filter((a) => !!a);
352
- return i.some((a) => Re.indexOf(a) !== -1) ? [] : i;
3704
+ function jt(r) {
3705
+ const e = r.split(/[.]|(?:\[(\d|\*)\])/).filter((t) => !!t);
3706
+ return e.some((t) => Tr.indexOf(t) !== -1) ? [] : e;
353
3707
  }
354
- function xe(e, i, a, v) {
355
- return C({
3708
+ function Nr(r, e, t, s) {
3709
+ return _e({
356
3710
  name: "VvFormField",
357
3711
  props: {
358
3712
  type: {
359
3713
  type: String,
360
- validator: (n) => Object.values(w).includes(n),
361
- default: w.custom
3714
+ validator: (n) => Object.values(R).includes(n),
3715
+ default: R.custom
362
3716
  },
363
3717
  is: {
364
3718
  type: [Object, String],
@@ -405,175 +3759,175 @@ function xe(e, i, a, v) {
405
3759
  "type"
406
3760
  ],
407
3761
  slots: Object,
408
- setup(n, { slots: l, emit: u }) {
409
- const { props: o, name: r } = Q(n), p = oe(), d = U(i, void 0);
410
- d && d.fields.value.set(p, n.name);
411
- const c = U(e), m = O({
3762
+ setup(n, { slots: a, emit: i }) {
3763
+ const { props: o, name: u } = Fe(n), l = ft(), d = re(e, void 0);
3764
+ d && d.fields.value.set(l, n.name);
3765
+ const f = re(r), k = Z({
412
3766
  get() {
413
- if (c?.formData)
414
- return N(
415
- new Object(c.formData.value),
3767
+ if (f?.formData)
3768
+ return he(
3769
+ new Object(f.formData.value),
416
3770
  String(n.name)
417
3771
  );
418
3772
  },
419
- set(t) {
420
- c?.formData && (X(
421
- new Object(c.formData.value),
3773
+ set(g) {
3774
+ f?.formData && (Be(
3775
+ new Object(f.formData.value),
422
3776
  String(n.name),
423
- t
424
- ), u("update:modelValue", {
425
- newValue: m.value,
426
- formData: c?.formData
3777
+ g
3778
+ ), i("update:modelValue", {
3779
+ newValue: k.value,
3780
+ formData: f?.formData
427
3781
  }));
428
3782
  }
429
3783
  });
430
- q(() => {
431
- m.value === void 0 && n.defaultValue !== void 0 && (m.value = n.defaultValue);
432
- }), P(() => {
433
- d && d.fields.value.delete(p);
3784
+ Re(() => {
3785
+ k.value === void 0 && n.defaultValue !== void 0 && (k.value = n.defaultValue);
3786
+ }), me(() => {
3787
+ d && d.fields.value.delete(l);
434
3788
  });
435
- const j = O(() => {
436
- if (c?.errors.value)
437
- return N(c.errors.value, String(n.name));
438
- }), y = O(() => j.value?._errors), f = O(() => j.value !== void 0), h = A(f, (t) => {
439
- if (t) {
440
- u("invalid", j.value), d && d.errors.value.set(
3789
+ const b = Z(() => {
3790
+ if (f?.errors.value)
3791
+ return he(f.errors.value, String(n.name));
3792
+ }), c = Z(() => b.value?._errors), h = Z(() => b.value !== void 0), m = J(h, (g) => {
3793
+ if (g) {
3794
+ i("invalid", b.value), d && d.errors.value.set(
441
3795
  String(n.name),
442
- j.value
3796
+ b.value
443
3797
  );
444
3798
  return;
445
3799
  }
446
- u("valid", m.value), d && d.errors.value.delete(
3800
+ i("valid", k.value), d && d.errors.value.delete(
447
3801
  n.name
448
3802
  );
449
- }), g = A(
450
- () => c?.formData,
3803
+ }), x = J(
3804
+ () => f?.formData,
451
3805
  () => {
452
- u("update:formData", c?.formData);
3806
+ i("update:formData", f?.formData);
453
3807
  },
454
3808
  { deep: !0 }
455
3809
  );
456
- P(() => {
457
- h(), g();
3810
+ me(() => {
3811
+ m(), x();
458
3812
  });
459
- const I = (t) => {
460
- t instanceof InputEvent && (t = t.target.value), m.value = t;
461
- }, R = O(() => {
462
- let t = o.value;
463
- return typeof t == "function" && (t = t(c?.formData)), Object.keys(t).reduce(
464
- (V, $) => (V[$] = _(t[$]), V),
3813
+ const j = (g) => {
3814
+ g instanceof InputEvent && (g = g.target.value), k.value = g;
3815
+ }, N = Z(() => {
3816
+ let g = o.value;
3817
+ return typeof g == "function" && (g = g(f?.formData)), Object.keys(g).reduce(
3818
+ (A, Q) => (A[Q] = le(g[Q]), A),
465
3819
  {}
466
3820
  );
467
- }), k = O(() => c?.readonly.value || d?.readonly.value ? !0 : R.value.readonly ?? n.readonly), D = O(() => ({
468
- ...R.value,
469
- name: R.value.name ?? n.name,
470
- invalid: f.value,
471
- valid: n.showValid ? !!(!f.value && m.value) : void 0,
472
- type: ((t) => {
3821
+ }), P = Z(() => f?.readonly.value || d?.readonly.value ? !0 : N.value.readonly ?? n.readonly), E = Z(() => ({
3822
+ ...N.value,
3823
+ name: N.value.name ?? n.name,
3824
+ invalid: h.value,
3825
+ valid: n.showValid ? !!(!h.value && k.value) : void 0,
3826
+ type: ((g) => {
473
3827
  if ([
474
- w.color,
475
- w.date,
476
- w.datetimeLocal,
477
- w.email,
478
- w.month,
479
- w.number,
480
- w.password,
481
- w.search,
482
- w.tel,
483
- w.text,
484
- w.time,
485
- w.url,
486
- w.week
487
- ].includes(t))
488
- return t;
3828
+ R.color,
3829
+ R.date,
3830
+ R.datetimeLocal,
3831
+ R.email,
3832
+ R.month,
3833
+ R.number,
3834
+ R.password,
3835
+ R.search,
3836
+ R.tel,
3837
+ R.text,
3838
+ R.time,
3839
+ R.url,
3840
+ R.week
3841
+ ].includes(g))
3842
+ return g;
489
3843
  })(n.type),
490
- invalidLabel: y.value,
491
- modelValue: m.value,
492
- readonly: k.value,
493
- "onUpdate:modelValue": I
3844
+ invalidLabel: c.value,
3845
+ modelValue: k.value,
3846
+ readonly: P.value,
3847
+ "onUpdate:modelValue": j
494
3848
  }));
495
- return T(a, {
496
- name: G(r),
497
- errors: G(j)
498
- }), { component: O(() => {
499
- if (n.type === w.custom)
3849
+ return Ve(t, {
3850
+ name: H(u),
3851
+ errors: H(b)
3852
+ }), { component: Z(() => {
3853
+ if (n.type === R.custom)
500
3854
  return {
501
3855
  render() {
502
- return l.default?.({
503
- errors: j.value,
504
- formData: c?.formData.value,
505
- formErrors: c?.errors.value,
506
- invalid: f.value,
507
- invalidLabel: y.value,
508
- modelValue: m.value,
509
- readonly: k.value,
510
- onUpdate: I,
511
- submit: c?.submit,
512
- validate: c?.validate
513
- }) ?? l.default;
3856
+ return a.default?.({
3857
+ errors: b.value,
3858
+ formData: f?.formData.value,
3859
+ formErrors: f?.errors.value,
3860
+ invalid: h.value,
3861
+ invalidLabel: c.value,
3862
+ modelValue: k.value,
3863
+ readonly: P.value,
3864
+ onUpdate: j,
3865
+ submit: f?.submit,
3866
+ validate: f?.validate
3867
+ }) ?? a.default;
514
3868
  }
515
3869
  };
516
- if (!(v?.lazyLoad ?? n.lazyLoad)) {
517
- let t;
3870
+ if (!(s?.lazyLoad ?? n.lazyLoad)) {
3871
+ let g;
518
3872
  switch (n.type) {
519
- case w.select:
520
- t = W("VvSelect");
3873
+ case R.select:
3874
+ g = ee("VvSelect");
521
3875
  break;
522
- case w.checkbox:
523
- t = W("VvCheckbox");
3876
+ case R.checkbox:
3877
+ g = ee("VvCheckbox");
524
3878
  break;
525
- case w.radio:
526
- t = W("VvRadio");
3879
+ case R.radio:
3880
+ g = ee("VvRadio");
527
3881
  break;
528
- case w.textarea:
529
- t = W("VvTextarea");
3882
+ case R.textarea:
3883
+ g = ee("VvTextarea");
530
3884
  break;
531
- case w.radioGroup:
532
- t = W("VvRadioGroup");
3885
+ case R.radioGroup:
3886
+ g = ee("VvRadioGroup");
533
3887
  break;
534
- case w.checkboxGroup:
535
- t = W("VvCheckboxGroup");
3888
+ case R.checkboxGroup:
3889
+ g = ee("VvCheckboxGroup");
536
3890
  break;
537
- case w.combobox:
538
- t = W("VvCombobox");
3891
+ case R.combobox:
3892
+ g = ee("VvCombobox");
539
3893
  break;
540
3894
  default:
541
- t = W("VvInputText");
3895
+ g = ee("VvInputText");
542
3896
  }
543
- if (typeof t != "string")
544
- return t;
3897
+ if (typeof g != "string")
3898
+ return g;
545
3899
  console.warn(
546
- `[@volverjs/form-vue]: ${t} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
3900
+ `[@volverjs/form-vue]: ${g} not found, the component will be loaded asynchronously. To avoid this warning, please set "lazyLoad" option.`
547
3901
  );
548
3902
  }
549
- return ce(async () => {
550
- switch (v?.sideEffects && await Promise.resolve(v.sideEffects(n.type)), n.type) {
551
- case w.textarea:
3903
+ return Et(async () => {
3904
+ switch (s?.sideEffects && await Promise.resolve(s.sideEffects(n.type)), n.type) {
3905
+ case R.textarea:
552
3906
  return import("@volverjs/ui-vue/vv-textarea");
553
- case w.radio:
3907
+ case R.radio:
554
3908
  return import("@volverjs/ui-vue/vv-radio");
555
- case w.radioGroup:
3909
+ case R.radioGroup:
556
3910
  return import("@volverjs/ui-vue/vv-radio-group");
557
- case w.checkbox:
3911
+ case R.checkbox:
558
3912
  return import("@volverjs/ui-vue/vv-checkbox");
559
- case w.checkboxGroup:
3913
+ case R.checkboxGroup:
560
3914
  return import("@volverjs/ui-vue/vv-checkbox-group");
561
- case w.select:
3915
+ case R.select:
562
3916
  return import("@volverjs/ui-vue/vv-select");
563
- case w.combobox:
3917
+ case R.combobox:
564
3918
  return import("@volverjs/ui-vue/vv-combobox");
565
3919
  }
566
3920
  return import("@volverjs/ui-vue/vv-input-text");
567
3921
  });
568
- }), hasProps: D, invalid: f };
3922
+ }), hasProps: E, invalid: h };
569
3923
  },
570
3924
  render() {
571
- return this.is ? F(this.is, this.hasProps, this.$slots) : this.type === w.custom ? F(this.component, null, this.$slots) : F(this.component, this.hasProps, this.$slots);
3925
+ 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);
572
3926
  }
573
3927
  });
574
3928
  }
575
- function Ie(e, i, a) {
576
- return C({
3929
+ function Ir(r, e, t) {
3930
+ return _e({
577
3931
  name: "VvFormFieldsGroup",
578
3932
  props: {
579
3933
  is: {
@@ -616,151 +3970,151 @@ function Ie(e, i, a) {
616
3970
  "is"
617
3971
  ],
618
3972
  slots: Object,
619
- setup(v, { slots: n, emit: l }) {
620
- const { props: u, names: o, defaultValues: r } = Q(v), p = oe(), d = O(() => Array.isArray(o.value) ? o.value : Object.values(o.value)), c = O(() => Array.isArray(o.value) ? o.value : Object.keys(o.value)), m = O(() => Array.isArray(o.value) ? o.value.reduce((s, b) => (s[String(b)] = b, s), {}) : o.value), j = O(() => Object.keys(m.value).reduce((s, b) => (s[String(m.value[b])] = b, s), {})), y = U(i, void 0);
621
- y && d.value.forEach((s) => {
622
- y.fields.value.set(`${p}-${s}`, s);
3973
+ setup(s, { slots: n, emit: a }) {
3974
+ 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);
3975
+ c && d.value.forEach((w) => {
3976
+ c.fields.value.set(`${l}-${w}`, w);
623
3977
  });
624
- const f = U(e), h = O({
3978
+ const h = re(r), m = Z({
625
3979
  get() {
626
- return f?.formData ? c.value.reduce((s, b) => (s[b] = N(
627
- new Object(f.formData.value),
628
- m.value[b]
629
- ), s), {}) : {};
3980
+ return h?.formData ? f.value.reduce((w, C) => (w[C] = he(
3981
+ new Object(h.formData.value),
3982
+ k.value[C]
3983
+ ), w), {}) : {};
630
3984
  },
631
- set(s) {
632
- f?.formData && (c.value.forEach((b) => {
633
- X(
634
- new Object(f.formData.value),
635
- m.value[b],
636
- s?.[b]
3985
+ set(w) {
3986
+ h?.formData && (f.value.forEach((C) => {
3987
+ Be(
3988
+ new Object(h.formData.value),
3989
+ k.value[C],
3990
+ w?.[C]
637
3991
  );
638
- }), l("update:modelValue", {
639
- newValue: h.value,
640
- formData: f?.formData
3992
+ }), a("update:modelValue", {
3993
+ newValue: m.value,
3994
+ formData: h?.formData
641
3995
  }));
642
3996
  }
643
3997
  });
644
- q(() => {
645
- r.value && d.value.forEach((s) => {
646
- r.value?.[s] !== void 0 && h.value[s] === void 0 && (h.value = {
647
- ...h.value,
648
- [s]: r.value?.[s]
3998
+ Re(() => {
3999
+ u.value && d.value.forEach((w) => {
4000
+ u.value?.[w] !== void 0 && m.value[w] === void 0 && (m.value = {
4001
+ ...m.value,
4002
+ [w]: u.value?.[w]
649
4003
  });
650
4004
  });
651
- }), P(() => {
652
- y && d.value.forEach((s) => {
653
- y.fields.value.delete(
654
- `${p}-${s}`
4005
+ }), me(() => {
4006
+ c && d.value.forEach((w) => {
4007
+ c.fields.value.delete(
4008
+ `${l}-${w}`
655
4009
  );
656
4010
  });
657
4011
  });
658
- const g = O(() => {
659
- if (!f?.errors.value)
4012
+ const x = Z(() => {
4013
+ if (!h?.errors.value)
660
4014
  return;
661
- const s = d.value.reduce((b, E) => {
662
- if (!f.errors.value)
663
- return b;
664
- const ee = N(f.errors.value, String(E));
665
- return ee === void 0 || (b[String(E)] = ee), b;
4015
+ const w = d.value.reduce((C, B) => {
4016
+ if (!h.errors.value)
4017
+ return C;
4018
+ const We = he(h.errors.value, String(B));
4019
+ return We === void 0 || (C[String(B)] = We), C;
666
4020
  }, {});
667
- if (Object.keys(s).length !== 0)
668
- return s;
669
- }), I = O(() => {
670
- if (!g.value)
4021
+ if (Object.keys(w).length !== 0)
4022
+ return w;
4023
+ }), j = Z(() => {
4024
+ if (!x.value)
671
4025
  return;
672
- const s = Object.keys(g.value).reduce((b, E) => (g.value?.[E] && (b[j.value[E]] = g.value[E]._errors), b), {});
673
- if (Object.keys(s).length !== 0)
674
- return s;
675
- }), R = O(() => g.value !== void 0), k = O(() => c.value.reduce((s, b) => (s[b] = !!g.value?.[j.value[b]], s), {})), D = A(R, () => {
676
- if (R.value) {
677
- l("invalid", g.value), y && d.value.forEach((s) => {
678
- if (!g.value?.[s]) {
679
- y.errors.value.delete(
680
- s
4026
+ const w = Object.keys(x.value).reduce((C, B) => (x.value?.[B] && (C[b.value[B]] = x.value[B]._errors), C), {});
4027
+ if (Object.keys(w).length !== 0)
4028
+ return w;
4029
+ }), N = Z(() => x.value !== void 0), P = Z(() => f.value.reduce((w, C) => (w[C] = !!x.value?.[b.value[C]], w), {})), E = J(N, () => {
4030
+ if (N.value) {
4031
+ a("invalid", x.value), c && d.value.forEach((w) => {
4032
+ if (!x.value?.[w]) {
4033
+ c.errors.value.delete(
4034
+ w
681
4035
  );
682
4036
  return;
683
4037
  }
684
- y.errors.value.set(
685
- s,
686
- g.value?.[s]
4038
+ c.errors.value.set(
4039
+ w,
4040
+ x.value?.[w]
687
4041
  );
688
4042
  });
689
4043
  return;
690
4044
  }
691
- l("valid", h.value), y && d.value.forEach((s) => {
692
- y.errors.value.delete(
693
- s
4045
+ a("valid", m.value), c && d.value.forEach((w) => {
4046
+ c.errors.value.delete(
4047
+ w
694
4048
  );
695
4049
  });
696
- }), S = A(
697
- () => f?.formData,
4050
+ }), D = J(
4051
+ () => h?.formData,
698
4052
  () => {
699
- l("update:formData", f?.formData);
4053
+ a("update:formData", h?.formData);
700
4054
  },
701
4055
  { deep: !0 }
702
4056
  );
703
- P(() => {
704
- D(), S();
4057
+ me(() => {
4058
+ E(), D();
705
4059
  });
706
- const t = (s) => {
707
- h.value = s;
708
- }, V = (s, b) => {
709
- b instanceof InputEvent && (b = b.target.value), c.value.includes(s) && (h.value = {
710
- ...h.value,
711
- [s]: b
4060
+ const g = (w) => {
4061
+ m.value = w;
4062
+ }, A = (w, C) => {
4063
+ C instanceof InputEvent && (C = C.target.value), f.value.includes(w) && (m.value = {
4064
+ ...m.value,
4065
+ [w]: C
712
4066
  });
713
- }, $ = O(() => {
714
- let s = u.value;
715
- return typeof s == "function" && (s = s(f?.formData)), Object.keys(s).reduce(
716
- (b, E) => (b[E] = _(s[E]), b),
4067
+ }, Q = Z(() => {
4068
+ let w = i.value;
4069
+ return typeof w == "function" && (w = w(h?.formData)), Object.keys(w).reduce(
4070
+ (C, B) => (C[B] = le(w[B]), C),
717
4071
  {}
718
4072
  );
719
- }), Y = O(() => f?.readonly.value ? !0 : $.value.readonly ?? v.readonly), de = O(() => c.value.reduce((s, b) => (s[`onUpdate:${b}`] = (E) => {
720
- V(b, E);
721
- }, s), {
722
- "onUpdate:modelValue": t
723
- })), fe = O(() => ({
724
- ...de.value,
725
- ...$.value,
726
- ...h.value,
727
- modelValue: h.value,
728
- names: $.value.name ?? d.value,
729
- invalid: R.value,
730
- invalids: k.value,
731
- valid: v.showValid ? !!(!R.value && h.value) : void 0,
732
- invalidLabels: I.value,
733
- readonly: Y.value
4073
+ }), Je = Z(() => h?.readonly.value ? !0 : Q.value.readonly ?? s.readonly), Nt = Z(() => f.value.reduce((w, C) => (w[`onUpdate:${C}`] = (B) => {
4074
+ A(C, B);
4075
+ }, w), {
4076
+ "onUpdate:modelValue": g
4077
+ })), It = Z(() => ({
4078
+ ...Nt.value,
4079
+ ...Q.value,
4080
+ ...m.value,
4081
+ modelValue: m.value,
4082
+ names: Q.value.name ?? d.value,
4083
+ invalid: N.value,
4084
+ invalids: P.value,
4085
+ valid: s.showValid ? !!(!N.value && m.value) : void 0,
4086
+ invalidLabels: j.value,
4087
+ readonly: Je.value
734
4088
  }));
735
- return T(a, {
736
- names: G(o),
737
- errors: G(g)
738
- }), { component: O(() => ({
4089
+ return Ve(t, {
4090
+ names: H(o),
4091
+ errors: H(x)
4092
+ }), { component: Z(() => ({
739
4093
  render() {
740
4094
  return n.default?.({
741
- errors: g.value,
742
- formData: f?.formData.value,
743
- formErrors: f?.errors.value,
744
- invalid: R.value,
745
- invalids: k.value,
746
- invalidLabels: I.value,
747
- modelValue: h.value,
748
- onUpdate: t,
749
- onUpdateField: V,
750
- readonly: Y.value,
751
- submit: f?.submit,
752
- validate: f?.validate
4095
+ errors: x.value,
4096
+ formData: h?.formData.value,
4097
+ formErrors: h?.errors.value,
4098
+ invalid: N.value,
4099
+ invalids: P.value,
4100
+ invalidLabels: j.value,
4101
+ modelValue: m.value,
4102
+ onUpdate: g,
4103
+ onUpdateField: A,
4104
+ readonly: Je.value,
4105
+ submit: h?.submit,
4106
+ validate: h?.validate
753
4107
  }) ?? n.default;
754
4108
  }
755
- })), hasProps: fe, invalid: R };
4109
+ })), hasProps: It, invalid: N };
756
4110
  },
757
4111
  render() {
758
4112
  return this.is ? F(this.is, this.hasProps, this.$slots) : F(this.component, null, this.$slots);
759
4113
  }
760
4114
  });
761
4115
  }
762
- function Fe(e, i) {
763
- return C({
4116
+ function Cr(r, e) {
4117
+ return _e({
764
4118
  name: "VvFormWrapper",
765
4119
  props: {
766
4120
  name: {
@@ -792,75 +4146,75 @@ function Fe(e, i) {
792
4146
  "validateWrapper"
793
4147
  ],
794
4148
  slots: Object,
795
- setup(a, { emit: v }) {
796
- const n = U(e), l = U(i, void 0), u = L(/* @__PURE__ */ new Map()), o = L(/* @__PURE__ */ new Map()), { name: r } = Q(a), p = O(() => n?.invalid.value ? o.value.size > 0 : !1);
797
- A(p, (y) => {
798
- if (y) {
799
- v("invalid");
4149
+ setup(t, { emit: s }) {
4150
+ 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);
4151
+ J(l, (c) => {
4152
+ if (c) {
4153
+ s("invalid");
800
4154
  return;
801
4155
  }
802
- v("valid");
4156
+ s("valid");
803
4157
  });
804
- const d = O(() => n?.readonly.value || a.readonly), c = {
805
- name: G(r),
4158
+ const d = Z(() => n?.readonly.value || t.readonly), f = {
4159
+ name: H(u),
806
4160
  errors: o,
807
- invalid: G(p),
808
- readonly: G(d),
809
- fields: u
4161
+ invalid: H(l),
4162
+ readonly: H(d),
4163
+ fields: i
810
4164
  };
811
- T(i, c);
812
- const m = O(() => new Map(u.value));
813
- A(
814
- m,
815
- (y, f) => {
816
- l?.fields && (f.forEach((h, g) => {
817
- y.has(g) || l?.fields.value.delete(g);
818
- }), y.forEach((h, g) => {
819
- l?.fields.value.has(g) || l?.fields.value.set(g, h);
4165
+ Ve(e, f);
4166
+ const k = Z(() => new Map(i.value));
4167
+ J(
4168
+ k,
4169
+ (c, h) => {
4170
+ a?.fields && (h.forEach((m, x) => {
4171
+ c.has(x) || a?.fields.value.delete(x);
4172
+ }), c.forEach((m, x) => {
4173
+ a?.fields.value.has(x) || a?.fields.value.set(x, m);
820
4174
  }));
821
4175
  },
822
4176
  { deep: !0 }
823
- ), A(
4177
+ ), J(
824
4178
  o,
825
- (y) => {
826
- l?.errors && u.value.forEach((f) => {
827
- if (y.has(f) || l.errors.value.delete(f), y.has(f)) {
828
- const h = y.get(f);
829
- h && l.errors.value.set(f, h);
4179
+ (c) => {
4180
+ a?.errors && i.value.forEach((h) => {
4181
+ if (c.has(h) || a.errors.value.delete(h), c.has(h)) {
4182
+ const m = c.get(h);
4183
+ m && a.errors.value.set(h, m);
830
4184
  }
831
4185
  });
832
4186
  },
833
4187
  { deep: !0 }
834
- ), q(() => {
835
- if (!n?.wrappers || !r.value) {
4188
+ ), Re(() => {
4189
+ if (!n?.wrappers || !u.value) {
836
4190
  console.warn("[@volverjs/form-vue]: Invalid wrapper registration state");
837
4191
  return;
838
4192
  }
839
- if (n.wrappers.has(r.value)) {
840
- console.warn(`[@volverjs/form-vue]: wrapper name "${r.value}" is already used`);
4193
+ if (n.wrappers.has(u.value)) {
4194
+ console.warn(`[@volverjs/form-vue]: wrapper name "${u.value}" is already used`);
841
4195
  return;
842
4196
  }
843
- n.wrappers.set(r.value, c);
844
- }), P(() => {
845
- n?.wrappers && r.value && n.wrappers.delete(r.value);
4197
+ n.wrappers.set(u.value, f);
4198
+ }), me(() => {
4199
+ n?.wrappers && u.value && n.wrappers.delete(u.value);
846
4200
  });
847
- const j = () => n?.validate(void 0, { fields: new Set(u.value.values()) }) ?? Promise.resolve(!0);
4201
+ const b = () => n?.validate(void 0, { fields: new Set(i.value.values()) }) ?? Promise.resolve(!0);
848
4202
  return {
849
4203
  errors: n?.errors,
850
- fields: u,
4204
+ fields: i,
851
4205
  fieldsErrors: o,
852
4206
  formData: n?.formData,
853
- invalid: p,
4207
+ invalid: l,
854
4208
  readonly: d,
855
4209
  clear: n?.clear,
856
4210
  reset: n?.reset,
857
4211
  submit: n?.submit,
858
4212
  validate: n?.validate,
859
- validateWrapper: j
4213
+ validateWrapper: b
860
4214
  };
861
4215
  },
862
4216
  render() {
863
- const a = () => this.$slots.default?.({
4217
+ const t = () => this.$slots.default?.({
864
4218
  errors: this.errors,
865
4219
  fieldsErrors: this.fieldsErrors,
866
4220
  formData: this.formData,
@@ -873,13 +4227,13 @@ function Fe(e, i) {
873
4227
  validateWrapper: this.validateWrapper
874
4228
  });
875
4229
  return this.tag ? F(this.tag, null, {
876
- default: a
877
- }) : a();
4230
+ default: t
4231
+ }) : t();
878
4232
  }
879
4233
  });
880
4234
  }
881
- function ke(e, i) {
882
- const a = C({
4235
+ function Er(r, e) {
4236
+ const t = _e({
883
4237
  name: "VvFormTemplate",
884
4238
  props: {
885
4239
  schema: {
@@ -892,174 +4246,174 @@ function ke(e, i) {
892
4246
  }
893
4247
  },
894
4248
  slots: Object,
895
- setup(v, { slots: n }) {
896
- const l = U(e);
897
- if (l?.formData)
4249
+ setup(s, { slots: n }) {
4250
+ const a = re(r);
4251
+ if (a?.formData)
898
4252
  return () => {
899
- const u = typeof v.schema == "function" ? v.schema(
900
- l,
901
- v.scope
902
- ) : v.schema;
4253
+ const i = typeof s.schema == "function" ? s.schema(
4254
+ a,
4255
+ s.scope
4256
+ ) : s.schema;
903
4257
  let o;
904
- const r = u.reduce((p, d) => {
905
- const c = typeof d == "function" ? d(l, v.scope) : d, {
906
- vvIs: m,
907
- vvName: j,
908
- vvSlots: y,
909
- vvChildren: f,
910
- vvIf: h,
911
- vvElseIf: g,
912
- vvType: I,
913
- vvDefaultValue: R,
914
- vvShowValid: k,
915
- vvContent: D,
916
- ...S
917
- } = c;
918
- if (h !== void 0) {
919
- if (typeof h == "string" ? o = !!N(
920
- new Object(l.formData.value),
921
- h
922
- ) : typeof h == "function" ? o = _(h(l)) : o = _(h), !o)
923
- return p;
924
- } else if (g !== void 0 && o !== void 0) {
925
- if (o || (typeof g == "string" ? o = !!N(
926
- new Object(l.formData.value),
927
- g
928
- ) : typeof g == "function" ? o = _(g(l)) : o = _(g), !o))
929
- return p;
4258
+ const u = i.reduce((l, d) => {
4259
+ const f = typeof d == "function" ? d(a, s.scope) : d, {
4260
+ vvIs: k,
4261
+ vvName: b,
4262
+ vvSlots: c,
4263
+ vvChildren: h,
4264
+ vvIf: m,
4265
+ vvElseIf: x,
4266
+ vvType: j,
4267
+ vvDefaultValue: N,
4268
+ vvShowValid: P,
4269
+ vvContent: E,
4270
+ ...D
4271
+ } = f;
4272
+ if (m !== void 0) {
4273
+ if (typeof m == "string" ? o = !!he(
4274
+ new Object(a.formData.value),
4275
+ m
4276
+ ) : typeof m == "function" ? o = le(m(a)) : o = le(m), !o)
4277
+ return l;
4278
+ } else if (x !== void 0 && o !== void 0) {
4279
+ if (o || (typeof x == "string" ? o = !!he(
4280
+ new Object(a.formData.value),
4281
+ x
4282
+ ) : typeof x == "function" ? o = le(x(a)) : o = le(x), !o))
4283
+ return l;
930
4284
  } else
931
4285
  o = void 0;
932
- let t;
933
- return f && (typeof m == "string" ? t = F(a, {
934
- schema: f
935
- }) : t = {
936
- default: (V) => F(a, {
937
- schema: f,
938
- scope: V
4286
+ let g;
4287
+ return h && (typeof k == "string" ? g = F(t, {
4288
+ schema: h
4289
+ }) : g = {
4290
+ default: (A) => F(t, {
4291
+ schema: h,
4292
+ scope: A
939
4293
  })
940
- }), j ? (p.push(
4294
+ }), b ? (l.push(
941
4295
  F(
942
- i,
4296
+ e,
943
4297
  {
944
- name: j,
945
- is: m,
946
- type: I,
947
- defaultValue: R,
948
- showValid: k,
949
- props: S
4298
+ name: b,
4299
+ is: k,
4300
+ type: j,
4301
+ defaultValue: N,
4302
+ showValid: P,
4303
+ props: D
950
4304
  },
951
- y ?? t ?? D
4305
+ c ?? g ?? E
952
4306
  )
953
- ), p) : m ? (p.push(
4307
+ ), l) : k ? (l.push(
954
4308
  F(
955
- m,
956
- S,
957
- y ?? t ?? D
4309
+ k,
4310
+ D,
4311
+ c ?? g ?? E
958
4312
  )
959
- ), p) : (t && ("default" in t ? p.push(t.default(v.scope)) : p.push(t)), p);
4313
+ ), l) : (g && ("default" in g ? l.push(g.default(s.scope)) : l.push(g)), l);
960
4314
  }, []);
961
- return r.push(
4315
+ return u.push(
962
4316
  n?.default?.({
963
- errors: l?.errors.value,
964
- formData: l?.formData.value,
965
- invalid: l?.invalid.value,
966
- status: l?.status.value,
967
- submit: l?.submit,
968
- validate: l?.validate,
969
- clear: l?.clear,
970
- reset: l?.reset
4317
+ errors: a?.errors.value,
4318
+ formData: a?.formData.value,
4319
+ invalid: a?.invalid.value,
4320
+ status: a?.status.value,
4321
+ submit: a?.submit,
4322
+ validate: a?.validate,
4323
+ clear: a?.clear,
4324
+ reset: a?.reset
971
4325
  })
972
- ), r;
4326
+ ), u;
973
4327
  };
974
4328
  }
975
4329
  });
976
- return a;
4330
+ return t;
977
4331
  }
978
- function J(e, i = {}) {
979
- const a = Symbol("formInjectionKey"), v = Symbol("formWrapperInjectionKey"), n = Symbol("formFieldInjectionKey"), l = Symbol("formFieldsGroupInjectionKey"), u = Fe(
980
- a,
981
- v
982
- ), o = xe(
983
- a,
984
- v,
4332
+ function Ae(r, e = {}) {
4333
+ const t = Symbol("formInjectionKey"), s = Symbol("formWrapperInjectionKey"), n = Symbol("formFieldInjectionKey"), a = Symbol("formFieldsGroupInjectionKey"), i = Cr(
4334
+ t,
4335
+ s
4336
+ ), o = Nr(
4337
+ t,
4338
+ s,
985
4339
  n,
986
- i
987
- ), r = Ie(
988
- a,
989
- v,
990
- l
991
- ), p = ke(a, o), d = /* @__PURE__ */ new Map(), {
992
- clear: c,
993
- errors: m,
994
- formData: j,
995
- ignoreUpdates: y,
996
- invalid: f,
997
- readonly: h,
998
- reset: g,
999
- status: I,
1000
- stopUpdatesWatch: R,
1001
- submit: k,
1002
- validate: D,
1003
- VvForm: S
1004
- } = je(e, a, i, p, d);
4340
+ e
4341
+ ), u = Ir(
4342
+ t,
4343
+ s,
4344
+ a
4345
+ ), l = Er(t, o), d = /* @__PURE__ */ new Map(), {
4346
+ clear: f,
4347
+ errors: k,
4348
+ formData: b,
4349
+ ignoreUpdates: c,
4350
+ invalid: h,
4351
+ readonly: m,
4352
+ reset: x,
4353
+ status: j,
4354
+ stopUpdatesWatch: N,
4355
+ submit: P,
4356
+ validate: E,
4357
+ VvForm: D
4358
+ } = Or(r, t, e, l, d);
1005
4359
  return {
1006
- clear: c,
1007
- errors: m,
1008
- formData: j,
4360
+ clear: f,
4361
+ errors: k,
4362
+ formData: b,
1009
4363
  formFieldInjectionKey: n,
1010
- formInjectionKey: a,
1011
- formWrapperInjectionKey: v,
1012
- ignoreUpdates: y,
1013
- invalid: f,
1014
- readonly: h,
1015
- reset: g,
1016
- status: I,
1017
- stopUpdatesWatch: R,
1018
- submit: k,
1019
- validate: D,
4364
+ formInjectionKey: t,
4365
+ formWrapperInjectionKey: s,
4366
+ ignoreUpdates: c,
4367
+ invalid: h,
4368
+ readonly: m,
4369
+ reset: x,
4370
+ status: j,
4371
+ stopUpdatesWatch: N,
4372
+ submit: P,
4373
+ validate: E,
1020
4374
  wrappers: d,
1021
- VvForm: S,
4375
+ VvForm: D,
1022
4376
  VvFormField: o,
1023
- VvFormFieldsGroup: r,
1024
- VvFormTemplate: p,
1025
- VvFormWrapper: u
4377
+ VvFormFieldsGroup: u,
4378
+ VvFormTemplate: l,
4379
+ VvFormWrapper: i
1026
4380
  };
1027
4381
  }
1028
- const se = Symbol("pluginInjectionKey");
1029
- function Be(e) {
1030
- let i = {};
1031
- return e.schema && (i = J(e.schema, e)), {
1032
- ...i,
1033
- install(a, { global: v = !1 } = {}) {
1034
- a.provide(se, e), v && (a.config.globalProperties.$vvForm = e, i?.VvForm && a.component("VvForm", i.VvForm), i?.VvFormWrapper && a.component("VvFormWrapper", i.VvFormWrapper), i?.VvFormField && a.component("VvFormField", i.VvFormField), i?.VvFormFieldsGroup && a.component("VvFormFieldsGroup", i.VvFormFieldsGroup), i?.VvFormTemplate && a.component("VvFormTemplate", i.VvFormTemplate));
4382
+ const Tt = Symbol("pluginInjectionKey");
4383
+ function Zr(r) {
4384
+ let e = {};
4385
+ return r.schema && (e = Ae(r.schema, r)), {
4386
+ ...e,
4387
+ install(t, { global: s = !1 } = {}) {
4388
+ 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));
1035
4389
  }
1036
4390
  };
1037
4391
  }
1038
- const M = /* @__PURE__ */ new Map();
1039
- function We(e, i = {}) {
1040
- if (i.scope && M.has(i.scope))
1041
- return M.get(i.scope);
1042
- if (!me()) {
1043
- const v = J(e, i);
1044
- return i.scope && M.set(i.scope, v), v;
4392
+ const ke = /* @__PURE__ */ new Map();
4393
+ function $r(r, e = {}) {
4394
+ if (e.scope && ke.has(e.scope))
4395
+ return ke.get(e.scope);
4396
+ if (!At()) {
4397
+ const s = Ae(r, e);
4398
+ return e.scope && ke.set(e.scope, s), s;
1045
4399
  }
1046
- const a = J(
1047
- e,
4400
+ const t = Ae(
4401
+ r,
1048
4402
  {
1049
- ...U(se, {}),
1050
- ...i
4403
+ ...re(Tt, {}),
4404
+ ...e
1051
4405
  }
1052
4406
  );
1053
- return i.scope && M.set(i.scope, a), a;
4407
+ return e.scope && ke.set(e.scope, t), t;
1054
4408
  }
1055
- function Ue(e, i = {}) {
1056
- return J(e, i);
4409
+ function Pr(r, e = {}) {
4410
+ return Ae(r, e);
1057
4411
  }
1058
4412
  export {
1059
- w as FormFieldType,
1060
- Be as createForm,
1061
- Z as defaultObjectBySchema,
1062
- Ue as formType,
1063
- se as pluginInjectionKey,
1064
- We as useForm
4413
+ R as FormFieldType,
4414
+ Zr as createForm,
4415
+ we as defaultObjectBySchema,
4416
+ Pr as formType,
4417
+ Tt as pluginInjectionKey,
4418
+ $r as useForm
1065
4419
  };