@rpcbase/api 0.29.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2972 @@
1
+ function $constructor(name, initializer2, params) {
2
+ function init(inst, def) {
3
+ var _a;
4
+ Object.defineProperty(inst, "_zod", {
5
+ value: inst._zod ?? {},
6
+ enumerable: false
7
+ });
8
+ (_a = inst._zod).traits ?? (_a.traits = /* @__PURE__ */ new Set());
9
+ inst._zod.traits.add(name);
10
+ initializer2(inst, def);
11
+ for (const k in _.prototype) {
12
+ if (!(k in inst))
13
+ Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) });
14
+ }
15
+ inst._zod.constr = _;
16
+ inst._zod.def = def;
17
+ }
18
+ const Parent = params?.Parent ?? Object;
19
+ class Definition extends Parent {
20
+ }
21
+ Object.defineProperty(Definition, "name", { value: name });
22
+ function _(def) {
23
+ var _a;
24
+ const inst = params?.Parent ? new Definition() : this;
25
+ init(inst, def);
26
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
27
+ for (const fn of inst._zod.deferred) {
28
+ fn();
29
+ }
30
+ return inst;
31
+ }
32
+ Object.defineProperty(_, "init", { value: init });
33
+ Object.defineProperty(_, Symbol.hasInstance, {
34
+ value: (inst) => {
35
+ if (params?.Parent && inst instanceof params.Parent)
36
+ return true;
37
+ return inst?._zod?.traits?.has(name);
38
+ }
39
+ });
40
+ Object.defineProperty(_, "name", { value: name });
41
+ return _;
42
+ }
43
+ class $ZodAsyncError extends Error {
44
+ constructor() {
45
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
46
+ }
47
+ }
48
+ class $ZodEncodeError extends Error {
49
+ constructor(name) {
50
+ super(`Encountered unidirectional transform during encode: ${name}`);
51
+ this.name = "ZodEncodeError";
52
+ }
53
+ }
54
+ const globalConfig = {};
55
+ function config(newConfig) {
56
+ return globalConfig;
57
+ }
58
+ function getEnumValues(entries) {
59
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
60
+ const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
61
+ return values;
62
+ }
63
+ function jsonStringifyReplacer(_, value) {
64
+ if (typeof value === "bigint")
65
+ return value.toString();
66
+ return value;
67
+ }
68
+ function cached(getter) {
69
+ return {
70
+ get value() {
71
+ {
72
+ const value = getter();
73
+ Object.defineProperty(this, "value", { value });
74
+ return value;
75
+ }
76
+ }
77
+ };
78
+ }
79
+ function nullish(input) {
80
+ return input === null || input === void 0;
81
+ }
82
+ function cleanRegex(source) {
83
+ const start = source.startsWith("^") ? 1 : 0;
84
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
85
+ return source.slice(start, end);
86
+ }
87
+ const EVALUATING = Symbol("evaluating");
88
+ function defineLazy(object2, key, getter) {
89
+ let value = void 0;
90
+ Object.defineProperty(object2, key, {
91
+ get() {
92
+ if (value === EVALUATING) {
93
+ return void 0;
94
+ }
95
+ if (value === void 0) {
96
+ value = EVALUATING;
97
+ value = getter();
98
+ }
99
+ return value;
100
+ },
101
+ set(v) {
102
+ Object.defineProperty(object2, key, {
103
+ value: v
104
+ // configurable: true,
105
+ });
106
+ },
107
+ configurable: true
108
+ });
109
+ }
110
+ function assignProp(target, prop, value) {
111
+ Object.defineProperty(target, prop, {
112
+ value,
113
+ writable: true,
114
+ enumerable: true,
115
+ configurable: true
116
+ });
117
+ }
118
+ function mergeDefs(...defs) {
119
+ const mergedDescriptors = {};
120
+ for (const def of defs) {
121
+ const descriptors = Object.getOwnPropertyDescriptors(def);
122
+ Object.assign(mergedDescriptors, descriptors);
123
+ }
124
+ return Object.defineProperties({}, mergedDescriptors);
125
+ }
126
+ function esc(str) {
127
+ return JSON.stringify(str);
128
+ }
129
+ const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {
130
+ };
131
+ function isObject(data) {
132
+ return typeof data === "object" && data !== null && !Array.isArray(data);
133
+ }
134
+ const allowsEval = cached(() => {
135
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) {
136
+ return false;
137
+ }
138
+ try {
139
+ const F = Function;
140
+ new F("");
141
+ return true;
142
+ } catch (_) {
143
+ return false;
144
+ }
145
+ });
146
+ function isPlainObject(o) {
147
+ if (isObject(o) === false)
148
+ return false;
149
+ const ctor = o.constructor;
150
+ if (ctor === void 0)
151
+ return true;
152
+ const prot = ctor.prototype;
153
+ if (isObject(prot) === false)
154
+ return false;
155
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
156
+ return false;
157
+ }
158
+ return true;
159
+ }
160
+ function shallowClone(o) {
161
+ if (isPlainObject(o))
162
+ return { ...o };
163
+ if (Array.isArray(o))
164
+ return [...o];
165
+ return o;
166
+ }
167
+ const propertyKeyTypes = /* @__PURE__ */ new Set(["string", "number", "symbol"]);
168
+ function escapeRegex(str) {
169
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
170
+ }
171
+ function clone(inst, def, params) {
172
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
173
+ if (!def || params?.parent)
174
+ cl._zod.parent = inst;
175
+ return cl;
176
+ }
177
+ function normalizeParams(_params) {
178
+ const params = _params;
179
+ if (!params)
180
+ return {};
181
+ if (typeof params === "string")
182
+ return { error: () => params };
183
+ if (params?.message !== void 0) {
184
+ if (params?.error !== void 0)
185
+ throw new Error("Cannot specify both `message` and `error` params");
186
+ params.error = params.message;
187
+ }
188
+ delete params.message;
189
+ if (typeof params.error === "string")
190
+ return { ...params, error: () => params.error };
191
+ return params;
192
+ }
193
+ function optionalKeys(shape) {
194
+ return Object.keys(shape).filter((k) => {
195
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
196
+ });
197
+ }
198
+ function pick(schema, mask) {
199
+ const currDef = schema._zod.def;
200
+ const def = mergeDefs(schema._zod.def, {
201
+ get shape() {
202
+ const newShape = {};
203
+ for (const key in mask) {
204
+ if (!(key in currDef.shape)) {
205
+ throw new Error(`Unrecognized key: "${key}"`);
206
+ }
207
+ if (!mask[key])
208
+ continue;
209
+ newShape[key] = currDef.shape[key];
210
+ }
211
+ assignProp(this, "shape", newShape);
212
+ return newShape;
213
+ },
214
+ checks: []
215
+ });
216
+ return clone(schema, def);
217
+ }
218
+ function omit(schema, mask) {
219
+ const currDef = schema._zod.def;
220
+ const def = mergeDefs(schema._zod.def, {
221
+ get shape() {
222
+ const newShape = { ...schema._zod.def.shape };
223
+ for (const key in mask) {
224
+ if (!(key in currDef.shape)) {
225
+ throw new Error(`Unrecognized key: "${key}"`);
226
+ }
227
+ if (!mask[key])
228
+ continue;
229
+ delete newShape[key];
230
+ }
231
+ assignProp(this, "shape", newShape);
232
+ return newShape;
233
+ },
234
+ checks: []
235
+ });
236
+ return clone(schema, def);
237
+ }
238
+ function extend(schema, shape) {
239
+ if (!isPlainObject(shape)) {
240
+ throw new Error("Invalid input to extend: expected a plain object");
241
+ }
242
+ const checks = schema._zod.def.checks;
243
+ const hasChecks = checks && checks.length > 0;
244
+ if (hasChecks) {
245
+ throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");
246
+ }
247
+ const def = mergeDefs(schema._zod.def, {
248
+ get shape() {
249
+ const _shape = { ...schema._zod.def.shape, ...shape };
250
+ assignProp(this, "shape", _shape);
251
+ return _shape;
252
+ },
253
+ checks: []
254
+ });
255
+ return clone(schema, def);
256
+ }
257
+ function safeExtend(schema, shape) {
258
+ if (!isPlainObject(shape)) {
259
+ throw new Error("Invalid input to safeExtend: expected a plain object");
260
+ }
261
+ const def = {
262
+ ...schema._zod.def,
263
+ get shape() {
264
+ const _shape = { ...schema._zod.def.shape, ...shape };
265
+ assignProp(this, "shape", _shape);
266
+ return _shape;
267
+ },
268
+ checks: schema._zod.def.checks
269
+ };
270
+ return clone(schema, def);
271
+ }
272
+ function merge(a, b) {
273
+ const def = mergeDefs(a._zod.def, {
274
+ get shape() {
275
+ const _shape = { ...a._zod.def.shape, ...b._zod.def.shape };
276
+ assignProp(this, "shape", _shape);
277
+ return _shape;
278
+ },
279
+ get catchall() {
280
+ return b._zod.def.catchall;
281
+ },
282
+ checks: []
283
+ // delete existing checks
284
+ });
285
+ return clone(a, def);
286
+ }
287
+ function partial(Class, schema, mask) {
288
+ const def = mergeDefs(schema._zod.def, {
289
+ get shape() {
290
+ const oldShape = schema._zod.def.shape;
291
+ const shape = { ...oldShape };
292
+ if (mask) {
293
+ for (const key in mask) {
294
+ if (!(key in oldShape)) {
295
+ throw new Error(`Unrecognized key: "${key}"`);
296
+ }
297
+ if (!mask[key])
298
+ continue;
299
+ shape[key] = Class ? new Class({
300
+ type: "optional",
301
+ innerType: oldShape[key]
302
+ }) : oldShape[key];
303
+ }
304
+ } else {
305
+ for (const key in oldShape) {
306
+ shape[key] = Class ? new Class({
307
+ type: "optional",
308
+ innerType: oldShape[key]
309
+ }) : oldShape[key];
310
+ }
311
+ }
312
+ assignProp(this, "shape", shape);
313
+ return shape;
314
+ },
315
+ checks: []
316
+ });
317
+ return clone(schema, def);
318
+ }
319
+ function required(Class, schema, mask) {
320
+ const def = mergeDefs(schema._zod.def, {
321
+ get shape() {
322
+ const oldShape = schema._zod.def.shape;
323
+ const shape = { ...oldShape };
324
+ if (mask) {
325
+ for (const key in mask) {
326
+ if (!(key in shape)) {
327
+ throw new Error(`Unrecognized key: "${key}"`);
328
+ }
329
+ if (!mask[key])
330
+ continue;
331
+ shape[key] = new Class({
332
+ type: "nonoptional",
333
+ innerType: oldShape[key]
334
+ });
335
+ }
336
+ } else {
337
+ for (const key in oldShape) {
338
+ shape[key] = new Class({
339
+ type: "nonoptional",
340
+ innerType: oldShape[key]
341
+ });
342
+ }
343
+ }
344
+ assignProp(this, "shape", shape);
345
+ return shape;
346
+ },
347
+ checks: []
348
+ });
349
+ return clone(schema, def);
350
+ }
351
+ function aborted(x, startIndex = 0) {
352
+ if (x.aborted === true)
353
+ return true;
354
+ for (let i = startIndex; i < x.issues.length; i++) {
355
+ if (x.issues[i]?.continue !== true) {
356
+ return true;
357
+ }
358
+ }
359
+ return false;
360
+ }
361
+ function prefixIssues(path, issues) {
362
+ return issues.map((iss) => {
363
+ var _a;
364
+ (_a = iss).path ?? (_a.path = []);
365
+ iss.path.unshift(path);
366
+ return iss;
367
+ });
368
+ }
369
+ function unwrapMessage(message) {
370
+ return typeof message === "string" ? message : message?.message;
371
+ }
372
+ function finalizeIssue(iss, ctx, config2) {
373
+ const full = { ...iss, path: iss.path ?? [] };
374
+ if (!iss.message) {
375
+ const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input";
376
+ full.message = message;
377
+ }
378
+ delete full.inst;
379
+ delete full.continue;
380
+ if (!ctx?.reportInput) {
381
+ delete full.input;
382
+ }
383
+ return full;
384
+ }
385
+ function getLengthableOrigin(input) {
386
+ if (Array.isArray(input))
387
+ return "array";
388
+ if (typeof input === "string")
389
+ return "string";
390
+ return "unknown";
391
+ }
392
+ function issue(...args) {
393
+ const [iss, input, inst] = args;
394
+ if (typeof iss === "string") {
395
+ return {
396
+ message: iss,
397
+ code: "custom",
398
+ input,
399
+ inst
400
+ };
401
+ }
402
+ return { ...iss };
403
+ }
404
+ const initializer$1 = (inst, def) => {
405
+ inst.name = "$ZodError";
406
+ Object.defineProperty(inst, "_zod", {
407
+ value: inst._zod,
408
+ enumerable: false
409
+ });
410
+ Object.defineProperty(inst, "issues", {
411
+ value: def,
412
+ enumerable: false
413
+ });
414
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
415
+ Object.defineProperty(inst, "toString", {
416
+ value: () => inst.message,
417
+ enumerable: false
418
+ });
419
+ };
420
+ const $ZodError = $constructor("$ZodError", initializer$1);
421
+ const $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
422
+ function flattenError(error, mapper = (issue2) => issue2.message) {
423
+ const fieldErrors = {};
424
+ const formErrors = [];
425
+ for (const sub of error.issues) {
426
+ if (sub.path.length > 0) {
427
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
428
+ fieldErrors[sub.path[0]].push(mapper(sub));
429
+ } else {
430
+ formErrors.push(mapper(sub));
431
+ }
432
+ }
433
+ return { formErrors, fieldErrors };
434
+ }
435
+ function formatError(error, mapper = (issue2) => issue2.message) {
436
+ const fieldErrors = { _errors: [] };
437
+ const processError = (error2) => {
438
+ for (const issue2 of error2.issues) {
439
+ if (issue2.code === "invalid_union" && issue2.errors.length) {
440
+ issue2.errors.map((issues) => processError({ issues }));
441
+ } else if (issue2.code === "invalid_key") {
442
+ processError({ issues: issue2.issues });
443
+ } else if (issue2.code === "invalid_element") {
444
+ processError({ issues: issue2.issues });
445
+ } else if (issue2.path.length === 0) {
446
+ fieldErrors._errors.push(mapper(issue2));
447
+ } else {
448
+ let curr = fieldErrors;
449
+ let i = 0;
450
+ while (i < issue2.path.length) {
451
+ const el = issue2.path[i];
452
+ const terminal = i === issue2.path.length - 1;
453
+ if (!terminal) {
454
+ curr[el] = curr[el] || { _errors: [] };
455
+ } else {
456
+ curr[el] = curr[el] || { _errors: [] };
457
+ curr[el]._errors.push(mapper(issue2));
458
+ }
459
+ curr = curr[el];
460
+ i++;
461
+ }
462
+ }
463
+ }
464
+ };
465
+ processError(error);
466
+ return fieldErrors;
467
+ }
468
+ const _parse = (_Err) => (schema, value, _ctx, _params) => {
469
+ const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false };
470
+ const result = schema._zod.run({ value, issues: [] }, ctx);
471
+ if (result instanceof Promise) {
472
+ throw new $ZodAsyncError();
473
+ }
474
+ if (result.issues.length) {
475
+ const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
476
+ captureStackTrace(e, _params?.callee);
477
+ throw e;
478
+ }
479
+ return result.value;
480
+ };
481
+ const _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
482
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
483
+ let result = schema._zod.run({ value, issues: [] }, ctx);
484
+ if (result instanceof Promise)
485
+ result = await result;
486
+ if (result.issues.length) {
487
+ const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
488
+ captureStackTrace(e, params?.callee);
489
+ throw e;
490
+ }
491
+ return result.value;
492
+ };
493
+ const _safeParse = (_Err) => (schema, value, _ctx) => {
494
+ const ctx = _ctx ? { ..._ctx, async: false } : { async: false };
495
+ const result = schema._zod.run({ value, issues: [] }, ctx);
496
+ if (result instanceof Promise) {
497
+ throw new $ZodAsyncError();
498
+ }
499
+ return result.issues.length ? {
500
+ success: false,
501
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
502
+ } : { success: true, data: result.value };
503
+ };
504
+ const safeParse$1 = /* @__PURE__ */ _safeParse($ZodRealError);
505
+ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
506
+ const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true };
507
+ let result = schema._zod.run({ value, issues: [] }, ctx);
508
+ if (result instanceof Promise)
509
+ result = await result;
510
+ return result.issues.length ? {
511
+ success: false,
512
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
513
+ } : { success: true, data: result.value };
514
+ };
515
+ const safeParseAsync$1 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
516
+ const _encode = (_Err) => (schema, value, _ctx) => {
517
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
518
+ return _parse(_Err)(schema, value, ctx);
519
+ };
520
+ const _decode = (_Err) => (schema, value, _ctx) => {
521
+ return _parse(_Err)(schema, value, _ctx);
522
+ };
523
+ const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
524
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
525
+ return _parseAsync(_Err)(schema, value, ctx);
526
+ };
527
+ const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
528
+ return _parseAsync(_Err)(schema, value, _ctx);
529
+ };
530
+ const _safeEncode = (_Err) => (schema, value, _ctx) => {
531
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
532
+ return _safeParse(_Err)(schema, value, ctx);
533
+ };
534
+ const _safeDecode = (_Err) => (schema, value, _ctx) => {
535
+ return _safeParse(_Err)(schema, value, _ctx);
536
+ };
537
+ const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
538
+ const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
539
+ return _safeParseAsync(_Err)(schema, value, ctx);
540
+ };
541
+ const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
542
+ return _safeParseAsync(_Err)(schema, value, _ctx);
543
+ };
544
+ const cuid = /^[cC][^\s-]{8,}$/;
545
+ const cuid2 = /^[0-9a-z]+$/;
546
+ const ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
547
+ const xid = /^[0-9a-vA-V]{20}$/;
548
+ const ksuid = /^[A-Za-z0-9]{27}$/;
549
+ const nanoid = /^[a-zA-Z0-9_-]{21}$/;
550
+ const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
551
+ const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
552
+ const uuid = (version2) => {
553
+ if (!version2)
554
+ return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
555
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version2}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
556
+ };
557
+ const email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
558
+ const _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
559
+ function emoji() {
560
+ return new RegExp(_emoji$1, "u");
561
+ }
562
+ const ipv4 = /^(?:(?: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])$/;
563
+ const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/;
564
+ const cidrv4 = /^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/;
565
+ const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
566
+ const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
567
+ const base64url = /^[A-Za-z0-9_-]*$/;
568
+ const hostname = /^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/;
569
+ const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
570
+ const dateSource = `(?:(?:\\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])))`;
571
+ const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
572
+ function timeSource(args) {
573
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
574
+ const regex = typeof args.precision === "number" ? args.precision === -1 ? `${hhmm}` : args.precision === 0 ? `${hhmm}:[0-5]\\d` : `${hhmm}:[0-5]\\d\\.\\d{${args.precision}}` : `${hhmm}(?::[0-5]\\d(?:\\.\\d+)?)?`;
575
+ return regex;
576
+ }
577
+ function time$1(args) {
578
+ return new RegExp(`^${timeSource(args)}$`);
579
+ }
580
+ function datetime$1(args) {
581
+ const time2 = timeSource({ precision: args.precision });
582
+ const opts = ["Z"];
583
+ if (args.local)
584
+ opts.push("");
585
+ if (args.offset)
586
+ opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
587
+ const timeRegex = `${time2}(?:${opts.join("|")})`;
588
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
589
+ }
590
+ const string$1 = (params) => {
591
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
592
+ return new RegExp(`^${regex}$`);
593
+ };
594
+ const boolean$1 = /^(?:true|false)$/i;
595
+ const lowercase = /^[^A-Z]*$/;
596
+ const uppercase = /^[^a-z]*$/;
597
+ const $ZodCheck = /* @__PURE__ */ $constructor("$ZodCheck", (inst, def) => {
598
+ var _a;
599
+ inst._zod ?? (inst._zod = {});
600
+ inst._zod.def = def;
601
+ (_a = inst._zod).onattach ?? (_a.onattach = []);
602
+ });
603
+ const $ZodCheckMaxLength = /* @__PURE__ */ $constructor("$ZodCheckMaxLength", (inst, def) => {
604
+ var _a;
605
+ $ZodCheck.init(inst, def);
606
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
607
+ const val = payload.value;
608
+ return !nullish(val) && val.length !== void 0;
609
+ });
610
+ inst._zod.onattach.push((inst2) => {
611
+ const curr = inst2._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
612
+ if (def.maximum < curr)
613
+ inst2._zod.bag.maximum = def.maximum;
614
+ });
615
+ inst._zod.check = (payload) => {
616
+ const input = payload.value;
617
+ const length = input.length;
618
+ if (length <= def.maximum)
619
+ return;
620
+ const origin = getLengthableOrigin(input);
621
+ payload.issues.push({
622
+ origin,
623
+ code: "too_big",
624
+ maximum: def.maximum,
625
+ inclusive: true,
626
+ input,
627
+ inst,
628
+ continue: !def.abort
629
+ });
630
+ };
631
+ });
632
+ const $ZodCheckMinLength = /* @__PURE__ */ $constructor("$ZodCheckMinLength", (inst, def) => {
633
+ var _a;
634
+ $ZodCheck.init(inst, def);
635
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
636
+ const val = payload.value;
637
+ return !nullish(val) && val.length !== void 0;
638
+ });
639
+ inst._zod.onattach.push((inst2) => {
640
+ const curr = inst2._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
641
+ if (def.minimum > curr)
642
+ inst2._zod.bag.minimum = def.minimum;
643
+ });
644
+ inst._zod.check = (payload) => {
645
+ const input = payload.value;
646
+ const length = input.length;
647
+ if (length >= def.minimum)
648
+ return;
649
+ const origin = getLengthableOrigin(input);
650
+ payload.issues.push({
651
+ origin,
652
+ code: "too_small",
653
+ minimum: def.minimum,
654
+ inclusive: true,
655
+ input,
656
+ inst,
657
+ continue: !def.abort
658
+ });
659
+ };
660
+ });
661
+ const $ZodCheckLengthEquals = /* @__PURE__ */ $constructor("$ZodCheckLengthEquals", (inst, def) => {
662
+ var _a;
663
+ $ZodCheck.init(inst, def);
664
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
665
+ const val = payload.value;
666
+ return !nullish(val) && val.length !== void 0;
667
+ });
668
+ inst._zod.onattach.push((inst2) => {
669
+ const bag = inst2._zod.bag;
670
+ bag.minimum = def.length;
671
+ bag.maximum = def.length;
672
+ bag.length = def.length;
673
+ });
674
+ inst._zod.check = (payload) => {
675
+ const input = payload.value;
676
+ const length = input.length;
677
+ if (length === def.length)
678
+ return;
679
+ const origin = getLengthableOrigin(input);
680
+ const tooBig = length > def.length;
681
+ payload.issues.push({
682
+ origin,
683
+ ...tooBig ? { code: "too_big", maximum: def.length } : { code: "too_small", minimum: def.length },
684
+ inclusive: true,
685
+ exact: true,
686
+ input: payload.value,
687
+ inst,
688
+ continue: !def.abort
689
+ });
690
+ };
691
+ });
692
+ const $ZodCheckStringFormat = /* @__PURE__ */ $constructor("$ZodCheckStringFormat", (inst, def) => {
693
+ var _a, _b;
694
+ $ZodCheck.init(inst, def);
695
+ inst._zod.onattach.push((inst2) => {
696
+ const bag = inst2._zod.bag;
697
+ bag.format = def.format;
698
+ if (def.pattern) {
699
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
700
+ bag.patterns.add(def.pattern);
701
+ }
702
+ });
703
+ if (def.pattern)
704
+ (_a = inst._zod).check ?? (_a.check = (payload) => {
705
+ def.pattern.lastIndex = 0;
706
+ if (def.pattern.test(payload.value))
707
+ return;
708
+ payload.issues.push({
709
+ origin: "string",
710
+ code: "invalid_format",
711
+ format: def.format,
712
+ input: payload.value,
713
+ ...def.pattern ? { pattern: def.pattern.toString() } : {},
714
+ inst,
715
+ continue: !def.abort
716
+ });
717
+ });
718
+ else
719
+ (_b = inst._zod).check ?? (_b.check = () => {
720
+ });
721
+ });
722
+ const $ZodCheckRegex = /* @__PURE__ */ $constructor("$ZodCheckRegex", (inst, def) => {
723
+ $ZodCheckStringFormat.init(inst, def);
724
+ inst._zod.check = (payload) => {
725
+ def.pattern.lastIndex = 0;
726
+ if (def.pattern.test(payload.value))
727
+ return;
728
+ payload.issues.push({
729
+ origin: "string",
730
+ code: "invalid_format",
731
+ format: "regex",
732
+ input: payload.value,
733
+ pattern: def.pattern.toString(),
734
+ inst,
735
+ continue: !def.abort
736
+ });
737
+ };
738
+ });
739
+ const $ZodCheckLowerCase = /* @__PURE__ */ $constructor("$ZodCheckLowerCase", (inst, def) => {
740
+ def.pattern ?? (def.pattern = lowercase);
741
+ $ZodCheckStringFormat.init(inst, def);
742
+ });
743
+ const $ZodCheckUpperCase = /* @__PURE__ */ $constructor("$ZodCheckUpperCase", (inst, def) => {
744
+ def.pattern ?? (def.pattern = uppercase);
745
+ $ZodCheckStringFormat.init(inst, def);
746
+ });
747
+ const $ZodCheckIncludes = /* @__PURE__ */ $constructor("$ZodCheckIncludes", (inst, def) => {
748
+ $ZodCheck.init(inst, def);
749
+ const escapedRegex = escapeRegex(def.includes);
750
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
751
+ def.pattern = pattern;
752
+ inst._zod.onattach.push((inst2) => {
753
+ const bag = inst2._zod.bag;
754
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
755
+ bag.patterns.add(pattern);
756
+ });
757
+ inst._zod.check = (payload) => {
758
+ if (payload.value.includes(def.includes, def.position))
759
+ return;
760
+ payload.issues.push({
761
+ origin: "string",
762
+ code: "invalid_format",
763
+ format: "includes",
764
+ includes: def.includes,
765
+ input: payload.value,
766
+ inst,
767
+ continue: !def.abort
768
+ });
769
+ };
770
+ });
771
+ const $ZodCheckStartsWith = /* @__PURE__ */ $constructor("$ZodCheckStartsWith", (inst, def) => {
772
+ $ZodCheck.init(inst, def);
773
+ const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
774
+ def.pattern ?? (def.pattern = pattern);
775
+ inst._zod.onattach.push((inst2) => {
776
+ const bag = inst2._zod.bag;
777
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
778
+ bag.patterns.add(pattern);
779
+ });
780
+ inst._zod.check = (payload) => {
781
+ if (payload.value.startsWith(def.prefix))
782
+ return;
783
+ payload.issues.push({
784
+ origin: "string",
785
+ code: "invalid_format",
786
+ format: "starts_with",
787
+ prefix: def.prefix,
788
+ input: payload.value,
789
+ inst,
790
+ continue: !def.abort
791
+ });
792
+ };
793
+ });
794
+ const $ZodCheckEndsWith = /* @__PURE__ */ $constructor("$ZodCheckEndsWith", (inst, def) => {
795
+ $ZodCheck.init(inst, def);
796
+ const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
797
+ def.pattern ?? (def.pattern = pattern);
798
+ inst._zod.onattach.push((inst2) => {
799
+ const bag = inst2._zod.bag;
800
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
801
+ bag.patterns.add(pattern);
802
+ });
803
+ inst._zod.check = (payload) => {
804
+ if (payload.value.endsWith(def.suffix))
805
+ return;
806
+ payload.issues.push({
807
+ origin: "string",
808
+ code: "invalid_format",
809
+ format: "ends_with",
810
+ suffix: def.suffix,
811
+ input: payload.value,
812
+ inst,
813
+ continue: !def.abort
814
+ });
815
+ };
816
+ });
817
+ const $ZodCheckOverwrite = /* @__PURE__ */ $constructor("$ZodCheckOverwrite", (inst, def) => {
818
+ $ZodCheck.init(inst, def);
819
+ inst._zod.check = (payload) => {
820
+ payload.value = def.tx(payload.value);
821
+ };
822
+ });
823
+ class Doc {
824
+ constructor(args = []) {
825
+ this.content = [];
826
+ this.indent = 0;
827
+ if (this)
828
+ this.args = args;
829
+ }
830
+ indented(fn) {
831
+ this.indent += 1;
832
+ fn(this);
833
+ this.indent -= 1;
834
+ }
835
+ write(arg) {
836
+ if (typeof arg === "function") {
837
+ arg(this, { execution: "sync" });
838
+ arg(this, { execution: "async" });
839
+ return;
840
+ }
841
+ const content = arg;
842
+ const lines = content.split("\n").filter((x) => x);
843
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
844
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
845
+ for (const line of dedented) {
846
+ this.content.push(line);
847
+ }
848
+ }
849
+ compile() {
850
+ const F = Function;
851
+ const args = this?.args;
852
+ const content = this?.content ?? [``];
853
+ const lines = [...content.map((x) => ` ${x}`)];
854
+ return new F(...args, lines.join("\n"));
855
+ }
856
+ }
857
+ const version = {
858
+ major: 4,
859
+ minor: 1,
860
+ patch: 12
861
+ };
862
+ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
863
+ var _a;
864
+ inst ?? (inst = {});
865
+ inst._zod.def = def;
866
+ inst._zod.bag = inst._zod.bag || {};
867
+ inst._zod.version = version;
868
+ const checks = [...inst._zod.def.checks ?? []];
869
+ if (inst._zod.traits.has("$ZodCheck")) {
870
+ checks.unshift(inst);
871
+ }
872
+ for (const ch of checks) {
873
+ for (const fn of ch._zod.onattach) {
874
+ fn(inst);
875
+ }
876
+ }
877
+ if (checks.length === 0) {
878
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
879
+ inst._zod.deferred?.push(() => {
880
+ inst._zod.run = inst._zod.parse;
881
+ });
882
+ } else {
883
+ const runChecks = (payload, checks2, ctx) => {
884
+ let isAborted = aborted(payload);
885
+ let asyncResult;
886
+ for (const ch of checks2) {
887
+ if (ch._zod.def.when) {
888
+ const shouldRun = ch._zod.def.when(payload);
889
+ if (!shouldRun)
890
+ continue;
891
+ } else if (isAborted) {
892
+ continue;
893
+ }
894
+ const currLen = payload.issues.length;
895
+ const _ = ch._zod.check(payload);
896
+ if (_ instanceof Promise && ctx?.async === false) {
897
+ throw new $ZodAsyncError();
898
+ }
899
+ if (asyncResult || _ instanceof Promise) {
900
+ asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
901
+ await _;
902
+ const nextLen = payload.issues.length;
903
+ if (nextLen === currLen)
904
+ return;
905
+ if (!isAborted)
906
+ isAborted = aborted(payload, currLen);
907
+ });
908
+ } else {
909
+ const nextLen = payload.issues.length;
910
+ if (nextLen === currLen)
911
+ continue;
912
+ if (!isAborted)
913
+ isAborted = aborted(payload, currLen);
914
+ }
915
+ }
916
+ if (asyncResult) {
917
+ return asyncResult.then(() => {
918
+ return payload;
919
+ });
920
+ }
921
+ return payload;
922
+ };
923
+ const handleCanaryResult = (canary, payload, ctx) => {
924
+ if (aborted(canary)) {
925
+ canary.aborted = true;
926
+ return canary;
927
+ }
928
+ const checkResult = runChecks(payload, checks, ctx);
929
+ if (checkResult instanceof Promise) {
930
+ if (ctx.async === false)
931
+ throw new $ZodAsyncError();
932
+ return checkResult.then((checkResult2) => inst._zod.parse(checkResult2, ctx));
933
+ }
934
+ return inst._zod.parse(checkResult, ctx);
935
+ };
936
+ inst._zod.run = (payload, ctx) => {
937
+ if (ctx.skipChecks) {
938
+ return inst._zod.parse(payload, ctx);
939
+ }
940
+ if (ctx.direction === "backward") {
941
+ const canary = inst._zod.parse({ value: payload.value, issues: [] }, { ...ctx, skipChecks: true });
942
+ if (canary instanceof Promise) {
943
+ return canary.then((canary2) => {
944
+ return handleCanaryResult(canary2, payload, ctx);
945
+ });
946
+ }
947
+ return handleCanaryResult(canary, payload, ctx);
948
+ }
949
+ const result = inst._zod.parse(payload, ctx);
950
+ if (result instanceof Promise) {
951
+ if (ctx.async === false)
952
+ throw new $ZodAsyncError();
953
+ return result.then((result2) => runChecks(result2, checks, ctx));
954
+ }
955
+ return runChecks(result, checks, ctx);
956
+ };
957
+ }
958
+ inst["~standard"] = {
959
+ validate: (value) => {
960
+ try {
961
+ const r = safeParse$1(inst, value);
962
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
963
+ } catch (_) {
964
+ return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
965
+ }
966
+ },
967
+ vendor: "zod",
968
+ version: 1
969
+ };
970
+ });
971
+ const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
972
+ $ZodType.init(inst, def);
973
+ inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
974
+ inst._zod.parse = (payload, _) => {
975
+ if (def.coerce)
976
+ try {
977
+ payload.value = String(payload.value);
978
+ } catch (_2) {
979
+ }
980
+ if (typeof payload.value === "string")
981
+ return payload;
982
+ payload.issues.push({
983
+ expected: "string",
984
+ code: "invalid_type",
985
+ input: payload.value,
986
+ inst
987
+ });
988
+ return payload;
989
+ };
990
+ });
991
+ const $ZodStringFormat = /* @__PURE__ */ $constructor("$ZodStringFormat", (inst, def) => {
992
+ $ZodCheckStringFormat.init(inst, def);
993
+ $ZodString.init(inst, def);
994
+ });
995
+ const $ZodGUID = /* @__PURE__ */ $constructor("$ZodGUID", (inst, def) => {
996
+ def.pattern ?? (def.pattern = guid);
997
+ $ZodStringFormat.init(inst, def);
998
+ });
999
+ const $ZodUUID = /* @__PURE__ */ $constructor("$ZodUUID", (inst, def) => {
1000
+ if (def.version) {
1001
+ const versionMap = {
1002
+ v1: 1,
1003
+ v2: 2,
1004
+ v3: 3,
1005
+ v4: 4,
1006
+ v5: 5,
1007
+ v6: 6,
1008
+ v7: 7,
1009
+ v8: 8
1010
+ };
1011
+ const v = versionMap[def.version];
1012
+ if (v === void 0)
1013
+ throw new Error(`Invalid UUID version: "${def.version}"`);
1014
+ def.pattern ?? (def.pattern = uuid(v));
1015
+ } else
1016
+ def.pattern ?? (def.pattern = uuid());
1017
+ $ZodStringFormat.init(inst, def);
1018
+ });
1019
+ const $ZodEmail = /* @__PURE__ */ $constructor("$ZodEmail", (inst, def) => {
1020
+ def.pattern ?? (def.pattern = email);
1021
+ $ZodStringFormat.init(inst, def);
1022
+ });
1023
+ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
1024
+ $ZodStringFormat.init(inst, def);
1025
+ inst._zod.check = (payload) => {
1026
+ try {
1027
+ const trimmed = payload.value.trim();
1028
+ const url = new URL(trimmed);
1029
+ if (def.hostname) {
1030
+ def.hostname.lastIndex = 0;
1031
+ if (!def.hostname.test(url.hostname)) {
1032
+ payload.issues.push({
1033
+ code: "invalid_format",
1034
+ format: "url",
1035
+ note: "Invalid hostname",
1036
+ pattern: hostname.source,
1037
+ input: payload.value,
1038
+ inst,
1039
+ continue: !def.abort
1040
+ });
1041
+ }
1042
+ }
1043
+ if (def.protocol) {
1044
+ def.protocol.lastIndex = 0;
1045
+ if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) {
1046
+ payload.issues.push({
1047
+ code: "invalid_format",
1048
+ format: "url",
1049
+ note: "Invalid protocol",
1050
+ pattern: def.protocol.source,
1051
+ input: payload.value,
1052
+ inst,
1053
+ continue: !def.abort
1054
+ });
1055
+ }
1056
+ }
1057
+ if (def.normalize) {
1058
+ payload.value = url.href;
1059
+ } else {
1060
+ payload.value = trimmed;
1061
+ }
1062
+ return;
1063
+ } catch (_) {
1064
+ payload.issues.push({
1065
+ code: "invalid_format",
1066
+ format: "url",
1067
+ input: payload.value,
1068
+ inst,
1069
+ continue: !def.abort
1070
+ });
1071
+ }
1072
+ };
1073
+ });
1074
+ const $ZodEmoji = /* @__PURE__ */ $constructor("$ZodEmoji", (inst, def) => {
1075
+ def.pattern ?? (def.pattern = emoji());
1076
+ $ZodStringFormat.init(inst, def);
1077
+ });
1078
+ const $ZodNanoID = /* @__PURE__ */ $constructor("$ZodNanoID", (inst, def) => {
1079
+ def.pattern ?? (def.pattern = nanoid);
1080
+ $ZodStringFormat.init(inst, def);
1081
+ });
1082
+ const $ZodCUID = /* @__PURE__ */ $constructor("$ZodCUID", (inst, def) => {
1083
+ def.pattern ?? (def.pattern = cuid);
1084
+ $ZodStringFormat.init(inst, def);
1085
+ });
1086
+ const $ZodCUID2 = /* @__PURE__ */ $constructor("$ZodCUID2", (inst, def) => {
1087
+ def.pattern ?? (def.pattern = cuid2);
1088
+ $ZodStringFormat.init(inst, def);
1089
+ });
1090
+ const $ZodULID = /* @__PURE__ */ $constructor("$ZodULID", (inst, def) => {
1091
+ def.pattern ?? (def.pattern = ulid);
1092
+ $ZodStringFormat.init(inst, def);
1093
+ });
1094
+ const $ZodXID = /* @__PURE__ */ $constructor("$ZodXID", (inst, def) => {
1095
+ def.pattern ?? (def.pattern = xid);
1096
+ $ZodStringFormat.init(inst, def);
1097
+ });
1098
+ const $ZodKSUID = /* @__PURE__ */ $constructor("$ZodKSUID", (inst, def) => {
1099
+ def.pattern ?? (def.pattern = ksuid);
1100
+ $ZodStringFormat.init(inst, def);
1101
+ });
1102
+ const $ZodISODateTime = /* @__PURE__ */ $constructor("$ZodISODateTime", (inst, def) => {
1103
+ def.pattern ?? (def.pattern = datetime$1(def));
1104
+ $ZodStringFormat.init(inst, def);
1105
+ });
1106
+ const $ZodISODate = /* @__PURE__ */ $constructor("$ZodISODate", (inst, def) => {
1107
+ def.pattern ?? (def.pattern = date$1);
1108
+ $ZodStringFormat.init(inst, def);
1109
+ });
1110
+ const $ZodISOTime = /* @__PURE__ */ $constructor("$ZodISOTime", (inst, def) => {
1111
+ def.pattern ?? (def.pattern = time$1(def));
1112
+ $ZodStringFormat.init(inst, def);
1113
+ });
1114
+ const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, def) => {
1115
+ def.pattern ?? (def.pattern = duration$1);
1116
+ $ZodStringFormat.init(inst, def);
1117
+ });
1118
+ const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
1119
+ def.pattern ?? (def.pattern = ipv4);
1120
+ $ZodStringFormat.init(inst, def);
1121
+ inst._zod.onattach.push((inst2) => {
1122
+ const bag = inst2._zod.bag;
1123
+ bag.format = `ipv4`;
1124
+ });
1125
+ });
1126
+ const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
1127
+ def.pattern ?? (def.pattern = ipv6);
1128
+ $ZodStringFormat.init(inst, def);
1129
+ inst._zod.onattach.push((inst2) => {
1130
+ const bag = inst2._zod.bag;
1131
+ bag.format = `ipv6`;
1132
+ });
1133
+ inst._zod.check = (payload) => {
1134
+ try {
1135
+ new URL(`http://[${payload.value}]`);
1136
+ } catch {
1137
+ payload.issues.push({
1138
+ code: "invalid_format",
1139
+ format: "ipv6",
1140
+ input: payload.value,
1141
+ inst,
1142
+ continue: !def.abort
1143
+ });
1144
+ }
1145
+ };
1146
+ });
1147
+ const $ZodCIDRv4 = /* @__PURE__ */ $constructor("$ZodCIDRv4", (inst, def) => {
1148
+ def.pattern ?? (def.pattern = cidrv4);
1149
+ $ZodStringFormat.init(inst, def);
1150
+ });
1151
+ const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
1152
+ def.pattern ?? (def.pattern = cidrv6);
1153
+ $ZodStringFormat.init(inst, def);
1154
+ inst._zod.check = (payload) => {
1155
+ const parts = payload.value.split("/");
1156
+ try {
1157
+ if (parts.length !== 2)
1158
+ throw new Error();
1159
+ const [address, prefix] = parts;
1160
+ if (!prefix)
1161
+ throw new Error();
1162
+ const prefixNum = Number(prefix);
1163
+ if (`${prefixNum}` !== prefix)
1164
+ throw new Error();
1165
+ if (prefixNum < 0 || prefixNum > 128)
1166
+ throw new Error();
1167
+ new URL(`http://[${address}]`);
1168
+ } catch {
1169
+ payload.issues.push({
1170
+ code: "invalid_format",
1171
+ format: "cidrv6",
1172
+ input: payload.value,
1173
+ inst,
1174
+ continue: !def.abort
1175
+ });
1176
+ }
1177
+ };
1178
+ });
1179
+ function isValidBase64(data) {
1180
+ if (data === "")
1181
+ return true;
1182
+ if (data.length % 4 !== 0)
1183
+ return false;
1184
+ try {
1185
+ atob(data);
1186
+ return true;
1187
+ } catch {
1188
+ return false;
1189
+ }
1190
+ }
1191
+ const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
1192
+ def.pattern ?? (def.pattern = base64);
1193
+ $ZodStringFormat.init(inst, def);
1194
+ inst._zod.onattach.push((inst2) => {
1195
+ inst2._zod.bag.contentEncoding = "base64";
1196
+ });
1197
+ inst._zod.check = (payload) => {
1198
+ if (isValidBase64(payload.value))
1199
+ return;
1200
+ payload.issues.push({
1201
+ code: "invalid_format",
1202
+ format: "base64",
1203
+ input: payload.value,
1204
+ inst,
1205
+ continue: !def.abort
1206
+ });
1207
+ };
1208
+ });
1209
+ function isValidBase64URL(data) {
1210
+ if (!base64url.test(data))
1211
+ return false;
1212
+ const base642 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1213
+ const padded = base642.padEnd(Math.ceil(base642.length / 4) * 4, "=");
1214
+ return isValidBase64(padded);
1215
+ }
1216
+ const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
1217
+ def.pattern ?? (def.pattern = base64url);
1218
+ $ZodStringFormat.init(inst, def);
1219
+ inst._zod.onattach.push((inst2) => {
1220
+ inst2._zod.bag.contentEncoding = "base64url";
1221
+ });
1222
+ inst._zod.check = (payload) => {
1223
+ if (isValidBase64URL(payload.value))
1224
+ return;
1225
+ payload.issues.push({
1226
+ code: "invalid_format",
1227
+ format: "base64url",
1228
+ input: payload.value,
1229
+ inst,
1230
+ continue: !def.abort
1231
+ });
1232
+ };
1233
+ });
1234
+ const $ZodE164 = /* @__PURE__ */ $constructor("$ZodE164", (inst, def) => {
1235
+ def.pattern ?? (def.pattern = e164);
1236
+ $ZodStringFormat.init(inst, def);
1237
+ });
1238
+ function isValidJWT(token, algorithm = null) {
1239
+ try {
1240
+ const tokensParts = token.split(".");
1241
+ if (tokensParts.length !== 3)
1242
+ return false;
1243
+ const [header] = tokensParts;
1244
+ if (!header)
1245
+ return false;
1246
+ const parsedHeader = JSON.parse(atob(header));
1247
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT")
1248
+ return false;
1249
+ if (!parsedHeader.alg)
1250
+ return false;
1251
+ if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm))
1252
+ return false;
1253
+ return true;
1254
+ } catch {
1255
+ return false;
1256
+ }
1257
+ }
1258
+ const $ZodJWT = /* @__PURE__ */ $constructor("$ZodJWT", (inst, def) => {
1259
+ $ZodStringFormat.init(inst, def);
1260
+ inst._zod.check = (payload) => {
1261
+ if (isValidJWT(payload.value, def.alg))
1262
+ return;
1263
+ payload.issues.push({
1264
+ code: "invalid_format",
1265
+ format: "jwt",
1266
+ input: payload.value,
1267
+ inst,
1268
+ continue: !def.abort
1269
+ });
1270
+ };
1271
+ });
1272
+ const $ZodBoolean = /* @__PURE__ */ $constructor("$ZodBoolean", (inst, def) => {
1273
+ $ZodType.init(inst, def);
1274
+ inst._zod.pattern = boolean$1;
1275
+ inst._zod.parse = (payload, _ctx) => {
1276
+ if (def.coerce)
1277
+ try {
1278
+ payload.value = Boolean(payload.value);
1279
+ } catch (_) {
1280
+ }
1281
+ const input = payload.value;
1282
+ if (typeof input === "boolean")
1283
+ return payload;
1284
+ payload.issues.push({
1285
+ expected: "boolean",
1286
+ code: "invalid_type",
1287
+ input,
1288
+ inst
1289
+ });
1290
+ return payload;
1291
+ };
1292
+ });
1293
+ const $ZodUnknown = /* @__PURE__ */ $constructor("$ZodUnknown", (inst, def) => {
1294
+ $ZodType.init(inst, def);
1295
+ inst._zod.parse = (payload) => payload;
1296
+ });
1297
+ const $ZodNever = /* @__PURE__ */ $constructor("$ZodNever", (inst, def) => {
1298
+ $ZodType.init(inst, def);
1299
+ inst._zod.parse = (payload, _ctx) => {
1300
+ payload.issues.push({
1301
+ expected: "never",
1302
+ code: "invalid_type",
1303
+ input: payload.value,
1304
+ inst
1305
+ });
1306
+ return payload;
1307
+ };
1308
+ });
1309
+ function handleArrayResult(result, final, index) {
1310
+ if (result.issues.length) {
1311
+ final.issues.push(...prefixIssues(index, result.issues));
1312
+ }
1313
+ final.value[index] = result.value;
1314
+ }
1315
+ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
1316
+ $ZodType.init(inst, def);
1317
+ inst._zod.parse = (payload, ctx) => {
1318
+ const input = payload.value;
1319
+ if (!Array.isArray(input)) {
1320
+ payload.issues.push({
1321
+ expected: "array",
1322
+ code: "invalid_type",
1323
+ input,
1324
+ inst
1325
+ });
1326
+ return payload;
1327
+ }
1328
+ payload.value = Array(input.length);
1329
+ const proms = [];
1330
+ for (let i = 0; i < input.length; i++) {
1331
+ const item = input[i];
1332
+ const result = def.element._zod.run({
1333
+ value: item,
1334
+ issues: []
1335
+ }, ctx);
1336
+ if (result instanceof Promise) {
1337
+ proms.push(result.then((result2) => handleArrayResult(result2, payload, i)));
1338
+ } else {
1339
+ handleArrayResult(result, payload, i);
1340
+ }
1341
+ }
1342
+ if (proms.length) {
1343
+ return Promise.all(proms).then(() => payload);
1344
+ }
1345
+ return payload;
1346
+ };
1347
+ });
1348
+ function handlePropertyResult(result, final, key, input) {
1349
+ if (result.issues.length) {
1350
+ final.issues.push(...prefixIssues(key, result.issues));
1351
+ }
1352
+ if (result.value === void 0) {
1353
+ if (key in input) {
1354
+ final.value[key] = void 0;
1355
+ }
1356
+ } else {
1357
+ final.value[key] = result.value;
1358
+ }
1359
+ }
1360
+ function normalizeDef(def) {
1361
+ const keys = Object.keys(def.shape);
1362
+ for (const k of keys) {
1363
+ if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) {
1364
+ throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1365
+ }
1366
+ }
1367
+ const okeys = optionalKeys(def.shape);
1368
+ return {
1369
+ ...def,
1370
+ keys,
1371
+ keySet: new Set(keys),
1372
+ numKeys: keys.length,
1373
+ optionalKeys: new Set(okeys)
1374
+ };
1375
+ }
1376
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
1377
+ const unrecognized = [];
1378
+ const keySet = def.keySet;
1379
+ const _catchall = def.catchall._zod;
1380
+ const t = _catchall.def.type;
1381
+ for (const key of Object.keys(input)) {
1382
+ if (keySet.has(key))
1383
+ continue;
1384
+ if (t === "never") {
1385
+ unrecognized.push(key);
1386
+ continue;
1387
+ }
1388
+ const r = _catchall.run({ value: input[key], issues: [] }, ctx);
1389
+ if (r instanceof Promise) {
1390
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
1391
+ } else {
1392
+ handlePropertyResult(r, payload, key, input);
1393
+ }
1394
+ }
1395
+ if (unrecognized.length) {
1396
+ payload.issues.push({
1397
+ code: "unrecognized_keys",
1398
+ keys: unrecognized,
1399
+ input,
1400
+ inst
1401
+ });
1402
+ }
1403
+ if (!proms.length)
1404
+ return payload;
1405
+ return Promise.all(proms).then(() => {
1406
+ return payload;
1407
+ });
1408
+ }
1409
+ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
1410
+ $ZodType.init(inst, def);
1411
+ const desc = Object.getOwnPropertyDescriptor(def, "shape");
1412
+ if (!desc?.get) {
1413
+ const sh = def.shape;
1414
+ Object.defineProperty(def, "shape", {
1415
+ get: () => {
1416
+ const newSh = { ...sh };
1417
+ Object.defineProperty(def, "shape", {
1418
+ value: newSh
1419
+ });
1420
+ return newSh;
1421
+ }
1422
+ });
1423
+ }
1424
+ const _normalized = cached(() => normalizeDef(def));
1425
+ defineLazy(inst._zod, "propValues", () => {
1426
+ const shape = def.shape;
1427
+ const propValues = {};
1428
+ for (const key in shape) {
1429
+ const field = shape[key]._zod;
1430
+ if (field.values) {
1431
+ propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1432
+ for (const v of field.values)
1433
+ propValues[key].add(v);
1434
+ }
1435
+ }
1436
+ return propValues;
1437
+ });
1438
+ const isObject$1 = isObject;
1439
+ const catchall = def.catchall;
1440
+ let value;
1441
+ inst._zod.parse = (payload, ctx) => {
1442
+ value ?? (value = _normalized.value);
1443
+ const input = payload.value;
1444
+ if (!isObject$1(input)) {
1445
+ payload.issues.push({
1446
+ expected: "object",
1447
+ code: "invalid_type",
1448
+ input,
1449
+ inst
1450
+ });
1451
+ return payload;
1452
+ }
1453
+ payload.value = {};
1454
+ const proms = [];
1455
+ const shape = value.shape;
1456
+ for (const key of value.keys) {
1457
+ const el = shape[key];
1458
+ const r = el._zod.run({ value: input[key], issues: [] }, ctx);
1459
+ if (r instanceof Promise) {
1460
+ proms.push(r.then((r2) => handlePropertyResult(r2, payload, key, input)));
1461
+ } else {
1462
+ handlePropertyResult(r, payload, key, input);
1463
+ }
1464
+ }
1465
+ if (!catchall) {
1466
+ return proms.length ? Promise.all(proms).then(() => payload) : payload;
1467
+ }
1468
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1469
+ };
1470
+ });
1471
+ const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
1472
+ $ZodObject.init(inst, def);
1473
+ const superParse = inst._zod.parse;
1474
+ const _normalized = cached(() => normalizeDef(def));
1475
+ const generateFastpass = (shape) => {
1476
+ const doc = new Doc(["shape", "payload", "ctx"]);
1477
+ const normalized = _normalized.value;
1478
+ const parseStr = (key) => {
1479
+ const k = esc(key);
1480
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1481
+ };
1482
+ doc.write(`const input = payload.value;`);
1483
+ const ids = /* @__PURE__ */ Object.create(null);
1484
+ let counter = 0;
1485
+ for (const key of normalized.keys) {
1486
+ ids[key] = `key_${counter++}`;
1487
+ }
1488
+ doc.write(`const newResult = {};`);
1489
+ for (const key of normalized.keys) {
1490
+ const id = ids[key];
1491
+ const k = esc(key);
1492
+ doc.write(`const ${id} = ${parseStr(key)};`);
1493
+ doc.write(`
1494
+ if (${id}.issues.length) {
1495
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1496
+ ...iss,
1497
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1498
+ })));
1499
+ }
1500
+
1501
+
1502
+ if (${id}.value === undefined) {
1503
+ if (${k} in input) {
1504
+ newResult[${k}] = undefined;
1505
+ }
1506
+ } else {
1507
+ newResult[${k}] = ${id}.value;
1508
+ }
1509
+
1510
+ `);
1511
+ }
1512
+ doc.write(`payload.value = newResult;`);
1513
+ doc.write(`return payload;`);
1514
+ const fn = doc.compile();
1515
+ return (payload, ctx) => fn(shape, payload, ctx);
1516
+ };
1517
+ let fastpass;
1518
+ const isObject$1 = isObject;
1519
+ const jit = !globalConfig.jitless;
1520
+ const allowsEval$1 = allowsEval;
1521
+ const fastEnabled = jit && allowsEval$1.value;
1522
+ const catchall = def.catchall;
1523
+ let value;
1524
+ inst._zod.parse = (payload, ctx) => {
1525
+ value ?? (value = _normalized.value);
1526
+ const input = payload.value;
1527
+ if (!isObject$1(input)) {
1528
+ payload.issues.push({
1529
+ expected: "object",
1530
+ code: "invalid_type",
1531
+ input,
1532
+ inst
1533
+ });
1534
+ return payload;
1535
+ }
1536
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1537
+ if (!fastpass)
1538
+ fastpass = generateFastpass(def.shape);
1539
+ payload = fastpass(payload, ctx);
1540
+ if (!catchall)
1541
+ return payload;
1542
+ return handleCatchall([], input, payload, ctx, value, inst);
1543
+ }
1544
+ return superParse(payload, ctx);
1545
+ };
1546
+ });
1547
+ function handleUnionResults(results, final, inst, ctx) {
1548
+ for (const result of results) {
1549
+ if (result.issues.length === 0) {
1550
+ final.value = result.value;
1551
+ return final;
1552
+ }
1553
+ }
1554
+ const nonaborted = results.filter((r) => !aborted(r));
1555
+ if (nonaborted.length === 1) {
1556
+ final.value = nonaborted[0].value;
1557
+ return nonaborted[0];
1558
+ }
1559
+ final.issues.push({
1560
+ code: "invalid_union",
1561
+ input: final.value,
1562
+ inst,
1563
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1564
+ });
1565
+ return final;
1566
+ }
1567
+ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
1568
+ $ZodType.init(inst, def);
1569
+ defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1570
+ defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1571
+ defineLazy(inst._zod, "values", () => {
1572
+ if (def.options.every((o) => o._zod.values)) {
1573
+ return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1574
+ }
1575
+ return void 0;
1576
+ });
1577
+ defineLazy(inst._zod, "pattern", () => {
1578
+ if (def.options.every((o) => o._zod.pattern)) {
1579
+ const patterns = def.options.map((o) => o._zod.pattern);
1580
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1581
+ }
1582
+ return void 0;
1583
+ });
1584
+ const single = def.options.length === 1;
1585
+ const first = def.options[0]._zod.run;
1586
+ inst._zod.parse = (payload, ctx) => {
1587
+ if (single) {
1588
+ return first(payload, ctx);
1589
+ }
1590
+ let async = false;
1591
+ const results = [];
1592
+ for (const option of def.options) {
1593
+ const result = option._zod.run({
1594
+ value: payload.value,
1595
+ issues: []
1596
+ }, ctx);
1597
+ if (result instanceof Promise) {
1598
+ results.push(result);
1599
+ async = true;
1600
+ } else {
1601
+ if (result.issues.length === 0)
1602
+ return result;
1603
+ results.push(result);
1604
+ }
1605
+ }
1606
+ if (!async)
1607
+ return handleUnionResults(results, payload, inst, ctx);
1608
+ return Promise.all(results).then((results2) => {
1609
+ return handleUnionResults(results2, payload, inst, ctx);
1610
+ });
1611
+ };
1612
+ });
1613
+ const $ZodIntersection = /* @__PURE__ */ $constructor("$ZodIntersection", (inst, def) => {
1614
+ $ZodType.init(inst, def);
1615
+ inst._zod.parse = (payload, ctx) => {
1616
+ const input = payload.value;
1617
+ const left = def.left._zod.run({ value: input, issues: [] }, ctx);
1618
+ const right = def.right._zod.run({ value: input, issues: [] }, ctx);
1619
+ const async = left instanceof Promise || right instanceof Promise;
1620
+ if (async) {
1621
+ return Promise.all([left, right]).then(([left2, right2]) => {
1622
+ return handleIntersectionResults(payload, left2, right2);
1623
+ });
1624
+ }
1625
+ return handleIntersectionResults(payload, left, right);
1626
+ };
1627
+ });
1628
+ function mergeValues(a, b) {
1629
+ if (a === b) {
1630
+ return { valid: true, data: a };
1631
+ }
1632
+ if (a instanceof Date && b instanceof Date && +a === +b) {
1633
+ return { valid: true, data: a };
1634
+ }
1635
+ if (isPlainObject(a) && isPlainObject(b)) {
1636
+ const bKeys = Object.keys(b);
1637
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1638
+ const newObj = { ...a, ...b };
1639
+ for (const key of sharedKeys) {
1640
+ const sharedValue = mergeValues(a[key], b[key]);
1641
+ if (!sharedValue.valid) {
1642
+ return {
1643
+ valid: false,
1644
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
1645
+ };
1646
+ }
1647
+ newObj[key] = sharedValue.data;
1648
+ }
1649
+ return { valid: true, data: newObj };
1650
+ }
1651
+ if (Array.isArray(a) && Array.isArray(b)) {
1652
+ if (a.length !== b.length) {
1653
+ return { valid: false, mergeErrorPath: [] };
1654
+ }
1655
+ const newArray = [];
1656
+ for (let index = 0; index < a.length; index++) {
1657
+ const itemA = a[index];
1658
+ const itemB = b[index];
1659
+ const sharedValue = mergeValues(itemA, itemB);
1660
+ if (!sharedValue.valid) {
1661
+ return {
1662
+ valid: false,
1663
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
1664
+ };
1665
+ }
1666
+ newArray.push(sharedValue.data);
1667
+ }
1668
+ return { valid: true, data: newArray };
1669
+ }
1670
+ return { valid: false, mergeErrorPath: [] };
1671
+ }
1672
+ function handleIntersectionResults(result, left, right) {
1673
+ if (left.issues.length) {
1674
+ result.issues.push(...left.issues);
1675
+ }
1676
+ if (right.issues.length) {
1677
+ result.issues.push(...right.issues);
1678
+ }
1679
+ if (aborted(result))
1680
+ return result;
1681
+ const merged = mergeValues(left.value, right.value);
1682
+ if (!merged.valid) {
1683
+ throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
1684
+ }
1685
+ result.value = merged.data;
1686
+ return result;
1687
+ }
1688
+ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
1689
+ $ZodType.init(inst, def);
1690
+ const values = getEnumValues(def.entries);
1691
+ const valuesSet = new Set(values);
1692
+ inst._zod.values = valuesSet;
1693
+ inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
1694
+ inst._zod.parse = (payload, _ctx) => {
1695
+ const input = payload.value;
1696
+ if (valuesSet.has(input)) {
1697
+ return payload;
1698
+ }
1699
+ payload.issues.push({
1700
+ code: "invalid_value",
1701
+ values,
1702
+ input,
1703
+ inst
1704
+ });
1705
+ return payload;
1706
+ };
1707
+ });
1708
+ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
1709
+ $ZodType.init(inst, def);
1710
+ inst._zod.parse = (payload, ctx) => {
1711
+ if (ctx.direction === "backward") {
1712
+ throw new $ZodEncodeError(inst.constructor.name);
1713
+ }
1714
+ const _out = def.transform(payload.value, payload);
1715
+ if (ctx.async) {
1716
+ const output = _out instanceof Promise ? _out : Promise.resolve(_out);
1717
+ return output.then((output2) => {
1718
+ payload.value = output2;
1719
+ return payload;
1720
+ });
1721
+ }
1722
+ if (_out instanceof Promise) {
1723
+ throw new $ZodAsyncError();
1724
+ }
1725
+ payload.value = _out;
1726
+ return payload;
1727
+ };
1728
+ });
1729
+ function handleOptionalResult(result, input) {
1730
+ if (result.issues.length && input === void 0) {
1731
+ return { issues: [], value: void 0 };
1732
+ }
1733
+ return result;
1734
+ }
1735
+ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
1736
+ $ZodType.init(inst, def);
1737
+ inst._zod.optin = "optional";
1738
+ inst._zod.optout = "optional";
1739
+ defineLazy(inst._zod, "values", () => {
1740
+ return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
1741
+ });
1742
+ defineLazy(inst._zod, "pattern", () => {
1743
+ const pattern = def.innerType._zod.pattern;
1744
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
1745
+ });
1746
+ inst._zod.parse = (payload, ctx) => {
1747
+ if (def.innerType._zod.optin === "optional") {
1748
+ const result = def.innerType._zod.run(payload, ctx);
1749
+ if (result instanceof Promise)
1750
+ return result.then((r) => handleOptionalResult(r, payload.value));
1751
+ return handleOptionalResult(result, payload.value);
1752
+ }
1753
+ if (payload.value === void 0) {
1754
+ return payload;
1755
+ }
1756
+ return def.innerType._zod.run(payload, ctx);
1757
+ };
1758
+ });
1759
+ const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
1760
+ $ZodType.init(inst, def);
1761
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1762
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1763
+ defineLazy(inst._zod, "pattern", () => {
1764
+ const pattern = def.innerType._zod.pattern;
1765
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
1766
+ });
1767
+ defineLazy(inst._zod, "values", () => {
1768
+ return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
1769
+ });
1770
+ inst._zod.parse = (payload, ctx) => {
1771
+ if (payload.value === null)
1772
+ return payload;
1773
+ return def.innerType._zod.run(payload, ctx);
1774
+ };
1775
+ });
1776
+ const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
1777
+ $ZodType.init(inst, def);
1778
+ inst._zod.optin = "optional";
1779
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1780
+ inst._zod.parse = (payload, ctx) => {
1781
+ if (ctx.direction === "backward") {
1782
+ return def.innerType._zod.run(payload, ctx);
1783
+ }
1784
+ if (payload.value === void 0) {
1785
+ payload.value = def.defaultValue;
1786
+ return payload;
1787
+ }
1788
+ const result = def.innerType._zod.run(payload, ctx);
1789
+ if (result instanceof Promise) {
1790
+ return result.then((result2) => handleDefaultResult(result2, def));
1791
+ }
1792
+ return handleDefaultResult(result, def);
1793
+ };
1794
+ });
1795
+ function handleDefaultResult(payload, def) {
1796
+ if (payload.value === void 0) {
1797
+ payload.value = def.defaultValue;
1798
+ }
1799
+ return payload;
1800
+ }
1801
+ const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) => {
1802
+ $ZodType.init(inst, def);
1803
+ inst._zod.optin = "optional";
1804
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1805
+ inst._zod.parse = (payload, ctx) => {
1806
+ if (ctx.direction === "backward") {
1807
+ return def.innerType._zod.run(payload, ctx);
1808
+ }
1809
+ if (payload.value === void 0) {
1810
+ payload.value = def.defaultValue;
1811
+ }
1812
+ return def.innerType._zod.run(payload, ctx);
1813
+ };
1814
+ });
1815
+ const $ZodNonOptional = /* @__PURE__ */ $constructor("$ZodNonOptional", (inst, def) => {
1816
+ $ZodType.init(inst, def);
1817
+ defineLazy(inst._zod, "values", () => {
1818
+ const v = def.innerType._zod.values;
1819
+ return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
1820
+ });
1821
+ inst._zod.parse = (payload, ctx) => {
1822
+ const result = def.innerType._zod.run(payload, ctx);
1823
+ if (result instanceof Promise) {
1824
+ return result.then((result2) => handleNonOptionalResult(result2, inst));
1825
+ }
1826
+ return handleNonOptionalResult(result, inst);
1827
+ };
1828
+ });
1829
+ function handleNonOptionalResult(payload, inst) {
1830
+ if (!payload.issues.length && payload.value === void 0) {
1831
+ payload.issues.push({
1832
+ code: "invalid_type",
1833
+ expected: "nonoptional",
1834
+ input: payload.value,
1835
+ inst
1836
+ });
1837
+ }
1838
+ return payload;
1839
+ }
1840
+ const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
1841
+ $ZodType.init(inst, def);
1842
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1843
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1844
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1845
+ inst._zod.parse = (payload, ctx) => {
1846
+ if (ctx.direction === "backward") {
1847
+ return def.innerType._zod.run(payload, ctx);
1848
+ }
1849
+ const result = def.innerType._zod.run(payload, ctx);
1850
+ if (result instanceof Promise) {
1851
+ return result.then((result2) => {
1852
+ payload.value = result2.value;
1853
+ if (result2.issues.length) {
1854
+ payload.value = def.catchValue({
1855
+ ...payload,
1856
+ error: {
1857
+ issues: result2.issues.map((iss) => finalizeIssue(iss, ctx, config()))
1858
+ },
1859
+ input: payload.value
1860
+ });
1861
+ payload.issues = [];
1862
+ }
1863
+ return payload;
1864
+ });
1865
+ }
1866
+ payload.value = result.value;
1867
+ if (result.issues.length) {
1868
+ payload.value = def.catchValue({
1869
+ ...payload,
1870
+ error: {
1871
+ issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config()))
1872
+ },
1873
+ input: payload.value
1874
+ });
1875
+ payload.issues = [];
1876
+ }
1877
+ return payload;
1878
+ };
1879
+ });
1880
+ const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
1881
+ $ZodType.init(inst, def);
1882
+ defineLazy(inst._zod, "values", () => def.in._zod.values);
1883
+ defineLazy(inst._zod, "optin", () => def.in._zod.optin);
1884
+ defineLazy(inst._zod, "optout", () => def.out._zod.optout);
1885
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
1886
+ inst._zod.parse = (payload, ctx) => {
1887
+ if (ctx.direction === "backward") {
1888
+ const right = def.out._zod.run(payload, ctx);
1889
+ if (right instanceof Promise) {
1890
+ return right.then((right2) => handlePipeResult(right2, def.in, ctx));
1891
+ }
1892
+ return handlePipeResult(right, def.in, ctx);
1893
+ }
1894
+ const left = def.in._zod.run(payload, ctx);
1895
+ if (left instanceof Promise) {
1896
+ return left.then((left2) => handlePipeResult(left2, def.out, ctx));
1897
+ }
1898
+ return handlePipeResult(left, def.out, ctx);
1899
+ };
1900
+ });
1901
+ function handlePipeResult(left, next, ctx) {
1902
+ if (left.issues.length) {
1903
+ left.aborted = true;
1904
+ return left;
1905
+ }
1906
+ return next._zod.run({ value: left.value, issues: left.issues }, ctx);
1907
+ }
1908
+ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) => {
1909
+ $ZodType.init(inst, def);
1910
+ defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
1911
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1912
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
1913
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
1914
+ inst._zod.parse = (payload, ctx) => {
1915
+ if (ctx.direction === "backward") {
1916
+ return def.innerType._zod.run(payload, ctx);
1917
+ }
1918
+ const result = def.innerType._zod.run(payload, ctx);
1919
+ if (result instanceof Promise) {
1920
+ return result.then(handleReadonlyResult);
1921
+ }
1922
+ return handleReadonlyResult(result);
1923
+ };
1924
+ });
1925
+ function handleReadonlyResult(payload) {
1926
+ payload.value = Object.freeze(payload.value);
1927
+ return payload;
1928
+ }
1929
+ const $ZodCustom = /* @__PURE__ */ $constructor("$ZodCustom", (inst, def) => {
1930
+ $ZodCheck.init(inst, def);
1931
+ $ZodType.init(inst, def);
1932
+ inst._zod.parse = (payload, _) => {
1933
+ return payload;
1934
+ };
1935
+ inst._zod.check = (payload) => {
1936
+ const input = payload.value;
1937
+ const r = def.fn(input);
1938
+ if (r instanceof Promise) {
1939
+ return r.then((r2) => handleRefineResult(r2, payload, input, inst));
1940
+ }
1941
+ handleRefineResult(r, payload, input, inst);
1942
+ return;
1943
+ };
1944
+ });
1945
+ function handleRefineResult(result, payload, input, inst) {
1946
+ if (!result) {
1947
+ const _iss = {
1948
+ code: "custom",
1949
+ input,
1950
+ inst,
1951
+ // incorporates params.error into issue reporting
1952
+ path: [...inst._zod.def.path ?? []],
1953
+ // incorporates params.error into issue reporting
1954
+ continue: !inst._zod.def.abort
1955
+ // params: inst._zod.def.params,
1956
+ };
1957
+ if (inst._zod.def.params)
1958
+ _iss.params = inst._zod.def.params;
1959
+ payload.issues.push(issue(_iss));
1960
+ }
1961
+ }
1962
+ class $ZodRegistry {
1963
+ constructor() {
1964
+ this._map = /* @__PURE__ */ new WeakMap();
1965
+ this._idmap = /* @__PURE__ */ new Map();
1966
+ }
1967
+ add(schema, ..._meta) {
1968
+ const meta = _meta[0];
1969
+ this._map.set(schema, meta);
1970
+ if (meta && typeof meta === "object" && "id" in meta) {
1971
+ if (this._idmap.has(meta.id)) {
1972
+ throw new Error(`ID ${meta.id} already exists in the registry`);
1973
+ }
1974
+ this._idmap.set(meta.id, schema);
1975
+ }
1976
+ return this;
1977
+ }
1978
+ clear() {
1979
+ this._map = /* @__PURE__ */ new WeakMap();
1980
+ this._idmap = /* @__PURE__ */ new Map();
1981
+ return this;
1982
+ }
1983
+ remove(schema) {
1984
+ const meta = this._map.get(schema);
1985
+ if (meta && typeof meta === "object" && "id" in meta) {
1986
+ this._idmap.delete(meta.id);
1987
+ }
1988
+ this._map.delete(schema);
1989
+ return this;
1990
+ }
1991
+ get(schema) {
1992
+ const p = schema._zod.parent;
1993
+ if (p) {
1994
+ const pm = { ...this.get(p) ?? {} };
1995
+ delete pm.id;
1996
+ const f = { ...pm, ...this._map.get(schema) };
1997
+ return Object.keys(f).length ? f : void 0;
1998
+ }
1999
+ return this._map.get(schema);
2000
+ }
2001
+ has(schema) {
2002
+ return this._map.has(schema);
2003
+ }
2004
+ }
2005
+ function registry() {
2006
+ return new $ZodRegistry();
2007
+ }
2008
+ const globalRegistry = /* @__PURE__ */ registry();
2009
+ function _string(Class, params) {
2010
+ return new Class({
2011
+ type: "string",
2012
+ ...normalizeParams(params)
2013
+ });
2014
+ }
2015
+ function _email(Class, params) {
2016
+ return new Class({
2017
+ type: "string",
2018
+ format: "email",
2019
+ check: "string_format",
2020
+ abort: false,
2021
+ ...normalizeParams(params)
2022
+ });
2023
+ }
2024
+ function _guid(Class, params) {
2025
+ return new Class({
2026
+ type: "string",
2027
+ format: "guid",
2028
+ check: "string_format",
2029
+ abort: false,
2030
+ ...normalizeParams(params)
2031
+ });
2032
+ }
2033
+ function _uuid(Class, params) {
2034
+ return new Class({
2035
+ type: "string",
2036
+ format: "uuid",
2037
+ check: "string_format",
2038
+ abort: false,
2039
+ ...normalizeParams(params)
2040
+ });
2041
+ }
2042
+ function _uuidv4(Class, params) {
2043
+ return new Class({
2044
+ type: "string",
2045
+ format: "uuid",
2046
+ check: "string_format",
2047
+ abort: false,
2048
+ version: "v4",
2049
+ ...normalizeParams(params)
2050
+ });
2051
+ }
2052
+ function _uuidv6(Class, params) {
2053
+ return new Class({
2054
+ type: "string",
2055
+ format: "uuid",
2056
+ check: "string_format",
2057
+ abort: false,
2058
+ version: "v6",
2059
+ ...normalizeParams(params)
2060
+ });
2061
+ }
2062
+ function _uuidv7(Class, params) {
2063
+ return new Class({
2064
+ type: "string",
2065
+ format: "uuid",
2066
+ check: "string_format",
2067
+ abort: false,
2068
+ version: "v7",
2069
+ ...normalizeParams(params)
2070
+ });
2071
+ }
2072
+ function _url(Class, params) {
2073
+ return new Class({
2074
+ type: "string",
2075
+ format: "url",
2076
+ check: "string_format",
2077
+ abort: false,
2078
+ ...normalizeParams(params)
2079
+ });
2080
+ }
2081
+ function _emoji(Class, params) {
2082
+ return new Class({
2083
+ type: "string",
2084
+ format: "emoji",
2085
+ check: "string_format",
2086
+ abort: false,
2087
+ ...normalizeParams(params)
2088
+ });
2089
+ }
2090
+ function _nanoid(Class, params) {
2091
+ return new Class({
2092
+ type: "string",
2093
+ format: "nanoid",
2094
+ check: "string_format",
2095
+ abort: false,
2096
+ ...normalizeParams(params)
2097
+ });
2098
+ }
2099
+ function _cuid(Class, params) {
2100
+ return new Class({
2101
+ type: "string",
2102
+ format: "cuid",
2103
+ check: "string_format",
2104
+ abort: false,
2105
+ ...normalizeParams(params)
2106
+ });
2107
+ }
2108
+ function _cuid2(Class, params) {
2109
+ return new Class({
2110
+ type: "string",
2111
+ format: "cuid2",
2112
+ check: "string_format",
2113
+ abort: false,
2114
+ ...normalizeParams(params)
2115
+ });
2116
+ }
2117
+ function _ulid(Class, params) {
2118
+ return new Class({
2119
+ type: "string",
2120
+ format: "ulid",
2121
+ check: "string_format",
2122
+ abort: false,
2123
+ ...normalizeParams(params)
2124
+ });
2125
+ }
2126
+ function _xid(Class, params) {
2127
+ return new Class({
2128
+ type: "string",
2129
+ format: "xid",
2130
+ check: "string_format",
2131
+ abort: false,
2132
+ ...normalizeParams(params)
2133
+ });
2134
+ }
2135
+ function _ksuid(Class, params) {
2136
+ return new Class({
2137
+ type: "string",
2138
+ format: "ksuid",
2139
+ check: "string_format",
2140
+ abort: false,
2141
+ ...normalizeParams(params)
2142
+ });
2143
+ }
2144
+ function _ipv4(Class, params) {
2145
+ return new Class({
2146
+ type: "string",
2147
+ format: "ipv4",
2148
+ check: "string_format",
2149
+ abort: false,
2150
+ ...normalizeParams(params)
2151
+ });
2152
+ }
2153
+ function _ipv6(Class, params) {
2154
+ return new Class({
2155
+ type: "string",
2156
+ format: "ipv6",
2157
+ check: "string_format",
2158
+ abort: false,
2159
+ ...normalizeParams(params)
2160
+ });
2161
+ }
2162
+ function _cidrv4(Class, params) {
2163
+ return new Class({
2164
+ type: "string",
2165
+ format: "cidrv4",
2166
+ check: "string_format",
2167
+ abort: false,
2168
+ ...normalizeParams(params)
2169
+ });
2170
+ }
2171
+ function _cidrv6(Class, params) {
2172
+ return new Class({
2173
+ type: "string",
2174
+ format: "cidrv6",
2175
+ check: "string_format",
2176
+ abort: false,
2177
+ ...normalizeParams(params)
2178
+ });
2179
+ }
2180
+ function _base64(Class, params) {
2181
+ return new Class({
2182
+ type: "string",
2183
+ format: "base64",
2184
+ check: "string_format",
2185
+ abort: false,
2186
+ ...normalizeParams(params)
2187
+ });
2188
+ }
2189
+ function _base64url(Class, params) {
2190
+ return new Class({
2191
+ type: "string",
2192
+ format: "base64url",
2193
+ check: "string_format",
2194
+ abort: false,
2195
+ ...normalizeParams(params)
2196
+ });
2197
+ }
2198
+ function _e164(Class, params) {
2199
+ return new Class({
2200
+ type: "string",
2201
+ format: "e164",
2202
+ check: "string_format",
2203
+ abort: false,
2204
+ ...normalizeParams(params)
2205
+ });
2206
+ }
2207
+ function _jwt(Class, params) {
2208
+ return new Class({
2209
+ type: "string",
2210
+ format: "jwt",
2211
+ check: "string_format",
2212
+ abort: false,
2213
+ ...normalizeParams(params)
2214
+ });
2215
+ }
2216
+ function _isoDateTime(Class, params) {
2217
+ return new Class({
2218
+ type: "string",
2219
+ format: "datetime",
2220
+ check: "string_format",
2221
+ offset: false,
2222
+ local: false,
2223
+ precision: null,
2224
+ ...normalizeParams(params)
2225
+ });
2226
+ }
2227
+ function _isoDate(Class, params) {
2228
+ return new Class({
2229
+ type: "string",
2230
+ format: "date",
2231
+ check: "string_format",
2232
+ ...normalizeParams(params)
2233
+ });
2234
+ }
2235
+ function _isoTime(Class, params) {
2236
+ return new Class({
2237
+ type: "string",
2238
+ format: "time",
2239
+ check: "string_format",
2240
+ precision: null,
2241
+ ...normalizeParams(params)
2242
+ });
2243
+ }
2244
+ function _isoDuration(Class, params) {
2245
+ return new Class({
2246
+ type: "string",
2247
+ format: "duration",
2248
+ check: "string_format",
2249
+ ...normalizeParams(params)
2250
+ });
2251
+ }
2252
+ function _boolean(Class, params) {
2253
+ return new Class({
2254
+ type: "boolean",
2255
+ ...normalizeParams(params)
2256
+ });
2257
+ }
2258
+ function _unknown(Class) {
2259
+ return new Class({
2260
+ type: "unknown"
2261
+ });
2262
+ }
2263
+ function _never(Class, params) {
2264
+ return new Class({
2265
+ type: "never",
2266
+ ...normalizeParams(params)
2267
+ });
2268
+ }
2269
+ function _maxLength(maximum, params) {
2270
+ const ch = new $ZodCheckMaxLength({
2271
+ check: "max_length",
2272
+ ...normalizeParams(params),
2273
+ maximum
2274
+ });
2275
+ return ch;
2276
+ }
2277
+ function _minLength(minimum, params) {
2278
+ return new $ZodCheckMinLength({
2279
+ check: "min_length",
2280
+ ...normalizeParams(params),
2281
+ minimum
2282
+ });
2283
+ }
2284
+ function _length(length, params) {
2285
+ return new $ZodCheckLengthEquals({
2286
+ check: "length_equals",
2287
+ ...normalizeParams(params),
2288
+ length
2289
+ });
2290
+ }
2291
+ function _regex(pattern, params) {
2292
+ return new $ZodCheckRegex({
2293
+ check: "string_format",
2294
+ format: "regex",
2295
+ ...normalizeParams(params),
2296
+ pattern
2297
+ });
2298
+ }
2299
+ function _lowercase(params) {
2300
+ return new $ZodCheckLowerCase({
2301
+ check: "string_format",
2302
+ format: "lowercase",
2303
+ ...normalizeParams(params)
2304
+ });
2305
+ }
2306
+ function _uppercase(params) {
2307
+ return new $ZodCheckUpperCase({
2308
+ check: "string_format",
2309
+ format: "uppercase",
2310
+ ...normalizeParams(params)
2311
+ });
2312
+ }
2313
+ function _includes(includes, params) {
2314
+ return new $ZodCheckIncludes({
2315
+ check: "string_format",
2316
+ format: "includes",
2317
+ ...normalizeParams(params),
2318
+ includes
2319
+ });
2320
+ }
2321
+ function _startsWith(prefix, params) {
2322
+ return new $ZodCheckStartsWith({
2323
+ check: "string_format",
2324
+ format: "starts_with",
2325
+ ...normalizeParams(params),
2326
+ prefix
2327
+ });
2328
+ }
2329
+ function _endsWith(suffix, params) {
2330
+ return new $ZodCheckEndsWith({
2331
+ check: "string_format",
2332
+ format: "ends_with",
2333
+ ...normalizeParams(params),
2334
+ suffix
2335
+ });
2336
+ }
2337
+ function _overwrite(tx) {
2338
+ return new $ZodCheckOverwrite({
2339
+ check: "overwrite",
2340
+ tx
2341
+ });
2342
+ }
2343
+ function _normalize(form) {
2344
+ return _overwrite((input) => input.normalize(form));
2345
+ }
2346
+ function _trim() {
2347
+ return _overwrite((input) => input.trim());
2348
+ }
2349
+ function _toLowerCase() {
2350
+ return _overwrite((input) => input.toLowerCase());
2351
+ }
2352
+ function _toUpperCase() {
2353
+ return _overwrite((input) => input.toUpperCase());
2354
+ }
2355
+ function _array(Class, element, params) {
2356
+ return new Class({
2357
+ type: "array",
2358
+ element,
2359
+ // get element() {
2360
+ // return element;
2361
+ // },
2362
+ ...normalizeParams(params)
2363
+ });
2364
+ }
2365
+ function _refine(Class, fn, _params) {
2366
+ const schema = new Class({
2367
+ type: "custom",
2368
+ check: "custom",
2369
+ fn,
2370
+ ...normalizeParams(_params)
2371
+ });
2372
+ return schema;
2373
+ }
2374
+ function _superRefine(fn) {
2375
+ const ch = _check((payload) => {
2376
+ payload.addIssue = (issue$1) => {
2377
+ if (typeof issue$1 === "string") {
2378
+ payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
2379
+ } else {
2380
+ const _issue = issue$1;
2381
+ if (_issue.fatal)
2382
+ _issue.continue = false;
2383
+ _issue.code ?? (_issue.code = "custom");
2384
+ _issue.input ?? (_issue.input = payload.value);
2385
+ _issue.inst ?? (_issue.inst = ch);
2386
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2387
+ payload.issues.push(issue(_issue));
2388
+ }
2389
+ };
2390
+ return fn(payload.value, payload);
2391
+ });
2392
+ return ch;
2393
+ }
2394
+ function _check(fn, params) {
2395
+ const ch = new $ZodCheck({
2396
+ check: "custom",
2397
+ ...normalizeParams(params)
2398
+ });
2399
+ ch._zod.check = fn;
2400
+ return ch;
2401
+ }
2402
+ const ZodISODateTime = /* @__PURE__ */ $constructor("ZodISODateTime", (inst, def) => {
2403
+ $ZodISODateTime.init(inst, def);
2404
+ ZodStringFormat.init(inst, def);
2405
+ });
2406
+ function datetime(params) {
2407
+ return _isoDateTime(ZodISODateTime, params);
2408
+ }
2409
+ const ZodISODate = /* @__PURE__ */ $constructor("ZodISODate", (inst, def) => {
2410
+ $ZodISODate.init(inst, def);
2411
+ ZodStringFormat.init(inst, def);
2412
+ });
2413
+ function date(params) {
2414
+ return _isoDate(ZodISODate, params);
2415
+ }
2416
+ const ZodISOTime = /* @__PURE__ */ $constructor("ZodISOTime", (inst, def) => {
2417
+ $ZodISOTime.init(inst, def);
2418
+ ZodStringFormat.init(inst, def);
2419
+ });
2420
+ function time(params) {
2421
+ return _isoTime(ZodISOTime, params);
2422
+ }
2423
+ const ZodISODuration = /* @__PURE__ */ $constructor("ZodISODuration", (inst, def) => {
2424
+ $ZodISODuration.init(inst, def);
2425
+ ZodStringFormat.init(inst, def);
2426
+ });
2427
+ function duration(params) {
2428
+ return _isoDuration(ZodISODuration, params);
2429
+ }
2430
+ const initializer = (inst, issues) => {
2431
+ $ZodError.init(inst, issues);
2432
+ inst.name = "ZodError";
2433
+ Object.defineProperties(inst, {
2434
+ format: {
2435
+ value: (mapper) => formatError(inst, mapper)
2436
+ // enumerable: false,
2437
+ },
2438
+ flatten: {
2439
+ value: (mapper) => flattenError(inst, mapper)
2440
+ // enumerable: false,
2441
+ },
2442
+ addIssue: {
2443
+ value: (issue2) => {
2444
+ inst.issues.push(issue2);
2445
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
2446
+ }
2447
+ // enumerable: false,
2448
+ },
2449
+ addIssues: {
2450
+ value: (issues2) => {
2451
+ inst.issues.push(...issues2);
2452
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
2453
+ }
2454
+ // enumerable: false,
2455
+ },
2456
+ isEmpty: {
2457
+ get() {
2458
+ return inst.issues.length === 0;
2459
+ }
2460
+ // enumerable: false,
2461
+ }
2462
+ });
2463
+ };
2464
+ const ZodRealError = $constructor("ZodError", initializer, {
2465
+ Parent: Error
2466
+ });
2467
+ const parse = /* @__PURE__ */ _parse(ZodRealError);
2468
+ const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
2469
+ const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
2470
+ const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
2471
+ const encode = /* @__PURE__ */ _encode(ZodRealError);
2472
+ const decode = /* @__PURE__ */ _decode(ZodRealError);
2473
+ const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
2474
+ const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
2475
+ const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
2476
+ const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
2477
+ const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
2478
+ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
2479
+ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
2480
+ $ZodType.init(inst, def);
2481
+ inst.def = def;
2482
+ inst.type = def.type;
2483
+ Object.defineProperty(inst, "_def", { value: def });
2484
+ inst.check = (...checks) => {
2485
+ return inst.clone(mergeDefs(def, {
2486
+ checks: [
2487
+ ...def.checks ?? [],
2488
+ ...checks.map((ch) => typeof ch === "function" ? { _zod: { check: ch, def: { check: "custom" }, onattach: [] } } : ch)
2489
+ ]
2490
+ }));
2491
+ };
2492
+ inst.clone = (def2, params) => clone(inst, def2, params);
2493
+ inst.brand = () => inst;
2494
+ inst.register = ((reg, meta) => {
2495
+ reg.add(inst, meta);
2496
+ return inst;
2497
+ });
2498
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
2499
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
2500
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
2501
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
2502
+ inst.spa = inst.safeParseAsync;
2503
+ inst.encode = (data, params) => encode(inst, data, params);
2504
+ inst.decode = (data, params) => decode(inst, data, params);
2505
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
2506
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
2507
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
2508
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
2509
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
2510
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
2511
+ inst.refine = (check, params) => inst.check(refine(check, params));
2512
+ inst.superRefine = (refinement) => inst.check(superRefine(refinement));
2513
+ inst.overwrite = (fn) => inst.check(_overwrite(fn));
2514
+ inst.optional = () => optional(inst);
2515
+ inst.nullable = () => nullable(inst);
2516
+ inst.nullish = () => optional(nullable(inst));
2517
+ inst.nonoptional = (params) => nonoptional(inst, params);
2518
+ inst.array = () => array(inst);
2519
+ inst.or = (arg) => union([inst, arg]);
2520
+ inst.and = (arg) => intersection(inst, arg);
2521
+ inst.transform = (tx) => pipe(inst, transform(tx));
2522
+ inst.default = (def2) => _default(inst, def2);
2523
+ inst.prefault = (def2) => prefault(inst, def2);
2524
+ inst.catch = (params) => _catch(inst, params);
2525
+ inst.pipe = (target) => pipe(inst, target);
2526
+ inst.readonly = () => readonly(inst);
2527
+ inst.describe = (description) => {
2528
+ const cl = inst.clone();
2529
+ globalRegistry.add(cl, { description });
2530
+ return cl;
2531
+ };
2532
+ Object.defineProperty(inst, "description", {
2533
+ get() {
2534
+ return globalRegistry.get(inst)?.description;
2535
+ },
2536
+ configurable: true
2537
+ });
2538
+ inst.meta = (...args) => {
2539
+ if (args.length === 0) {
2540
+ return globalRegistry.get(inst);
2541
+ }
2542
+ const cl = inst.clone();
2543
+ globalRegistry.add(cl, args[0]);
2544
+ return cl;
2545
+ };
2546
+ inst.isOptional = () => inst.safeParse(void 0).success;
2547
+ inst.isNullable = () => inst.safeParse(null).success;
2548
+ return inst;
2549
+ });
2550
+ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
2551
+ $ZodString.init(inst, def);
2552
+ ZodType.init(inst, def);
2553
+ const bag = inst._zod.bag;
2554
+ inst.format = bag.format ?? null;
2555
+ inst.minLength = bag.minimum ?? null;
2556
+ inst.maxLength = bag.maximum ?? null;
2557
+ inst.regex = (...args) => inst.check(_regex(...args));
2558
+ inst.includes = (...args) => inst.check(_includes(...args));
2559
+ inst.startsWith = (...args) => inst.check(_startsWith(...args));
2560
+ inst.endsWith = (...args) => inst.check(_endsWith(...args));
2561
+ inst.min = (...args) => inst.check(_minLength(...args));
2562
+ inst.max = (...args) => inst.check(_maxLength(...args));
2563
+ inst.length = (...args) => inst.check(_length(...args));
2564
+ inst.nonempty = (...args) => inst.check(_minLength(1, ...args));
2565
+ inst.lowercase = (params) => inst.check(_lowercase(params));
2566
+ inst.uppercase = (params) => inst.check(_uppercase(params));
2567
+ inst.trim = () => inst.check(_trim());
2568
+ inst.normalize = (...args) => inst.check(_normalize(...args));
2569
+ inst.toLowerCase = () => inst.check(_toLowerCase());
2570
+ inst.toUpperCase = () => inst.check(_toUpperCase());
2571
+ });
2572
+ const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
2573
+ $ZodString.init(inst, def);
2574
+ _ZodString.init(inst, def);
2575
+ inst.email = (params) => inst.check(_email(ZodEmail, params));
2576
+ inst.url = (params) => inst.check(_url(ZodURL, params));
2577
+ inst.jwt = (params) => inst.check(_jwt(ZodJWT, params));
2578
+ inst.emoji = (params) => inst.check(_emoji(ZodEmoji, params));
2579
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
2580
+ inst.uuid = (params) => inst.check(_uuid(ZodUUID, params));
2581
+ inst.uuidv4 = (params) => inst.check(_uuidv4(ZodUUID, params));
2582
+ inst.uuidv6 = (params) => inst.check(_uuidv6(ZodUUID, params));
2583
+ inst.uuidv7 = (params) => inst.check(_uuidv7(ZodUUID, params));
2584
+ inst.nanoid = (params) => inst.check(_nanoid(ZodNanoID, params));
2585
+ inst.guid = (params) => inst.check(_guid(ZodGUID, params));
2586
+ inst.cuid = (params) => inst.check(_cuid(ZodCUID, params));
2587
+ inst.cuid2 = (params) => inst.check(_cuid2(ZodCUID2, params));
2588
+ inst.ulid = (params) => inst.check(_ulid(ZodULID, params));
2589
+ inst.base64 = (params) => inst.check(_base64(ZodBase64, params));
2590
+ inst.base64url = (params) => inst.check(_base64url(ZodBase64URL, params));
2591
+ inst.xid = (params) => inst.check(_xid(ZodXID, params));
2592
+ inst.ksuid = (params) => inst.check(_ksuid(ZodKSUID, params));
2593
+ inst.ipv4 = (params) => inst.check(_ipv4(ZodIPv4, params));
2594
+ inst.ipv6 = (params) => inst.check(_ipv6(ZodIPv6, params));
2595
+ inst.cidrv4 = (params) => inst.check(_cidrv4(ZodCIDRv4, params));
2596
+ inst.cidrv6 = (params) => inst.check(_cidrv6(ZodCIDRv6, params));
2597
+ inst.e164 = (params) => inst.check(_e164(ZodE164, params));
2598
+ inst.datetime = (params) => inst.check(datetime(params));
2599
+ inst.date = (params) => inst.check(date(params));
2600
+ inst.time = (params) => inst.check(time(params));
2601
+ inst.duration = (params) => inst.check(duration(params));
2602
+ });
2603
+ function string(params) {
2604
+ return _string(ZodString, params);
2605
+ }
2606
+ const ZodStringFormat = /* @__PURE__ */ $constructor("ZodStringFormat", (inst, def) => {
2607
+ $ZodStringFormat.init(inst, def);
2608
+ _ZodString.init(inst, def);
2609
+ });
2610
+ const ZodEmail = /* @__PURE__ */ $constructor("ZodEmail", (inst, def) => {
2611
+ $ZodEmail.init(inst, def);
2612
+ ZodStringFormat.init(inst, def);
2613
+ });
2614
+ const ZodGUID = /* @__PURE__ */ $constructor("ZodGUID", (inst, def) => {
2615
+ $ZodGUID.init(inst, def);
2616
+ ZodStringFormat.init(inst, def);
2617
+ });
2618
+ const ZodUUID = /* @__PURE__ */ $constructor("ZodUUID", (inst, def) => {
2619
+ $ZodUUID.init(inst, def);
2620
+ ZodStringFormat.init(inst, def);
2621
+ });
2622
+ const ZodURL = /* @__PURE__ */ $constructor("ZodURL", (inst, def) => {
2623
+ $ZodURL.init(inst, def);
2624
+ ZodStringFormat.init(inst, def);
2625
+ });
2626
+ const ZodEmoji = /* @__PURE__ */ $constructor("ZodEmoji", (inst, def) => {
2627
+ $ZodEmoji.init(inst, def);
2628
+ ZodStringFormat.init(inst, def);
2629
+ });
2630
+ const ZodNanoID = /* @__PURE__ */ $constructor("ZodNanoID", (inst, def) => {
2631
+ $ZodNanoID.init(inst, def);
2632
+ ZodStringFormat.init(inst, def);
2633
+ });
2634
+ const ZodCUID = /* @__PURE__ */ $constructor("ZodCUID", (inst, def) => {
2635
+ $ZodCUID.init(inst, def);
2636
+ ZodStringFormat.init(inst, def);
2637
+ });
2638
+ const ZodCUID2 = /* @__PURE__ */ $constructor("ZodCUID2", (inst, def) => {
2639
+ $ZodCUID2.init(inst, def);
2640
+ ZodStringFormat.init(inst, def);
2641
+ });
2642
+ const ZodULID = /* @__PURE__ */ $constructor("ZodULID", (inst, def) => {
2643
+ $ZodULID.init(inst, def);
2644
+ ZodStringFormat.init(inst, def);
2645
+ });
2646
+ const ZodXID = /* @__PURE__ */ $constructor("ZodXID", (inst, def) => {
2647
+ $ZodXID.init(inst, def);
2648
+ ZodStringFormat.init(inst, def);
2649
+ });
2650
+ const ZodKSUID = /* @__PURE__ */ $constructor("ZodKSUID", (inst, def) => {
2651
+ $ZodKSUID.init(inst, def);
2652
+ ZodStringFormat.init(inst, def);
2653
+ });
2654
+ const ZodIPv4 = /* @__PURE__ */ $constructor("ZodIPv4", (inst, def) => {
2655
+ $ZodIPv4.init(inst, def);
2656
+ ZodStringFormat.init(inst, def);
2657
+ });
2658
+ const ZodIPv6 = /* @__PURE__ */ $constructor("ZodIPv6", (inst, def) => {
2659
+ $ZodIPv6.init(inst, def);
2660
+ ZodStringFormat.init(inst, def);
2661
+ });
2662
+ const ZodCIDRv4 = /* @__PURE__ */ $constructor("ZodCIDRv4", (inst, def) => {
2663
+ $ZodCIDRv4.init(inst, def);
2664
+ ZodStringFormat.init(inst, def);
2665
+ });
2666
+ const ZodCIDRv6 = /* @__PURE__ */ $constructor("ZodCIDRv6", (inst, def) => {
2667
+ $ZodCIDRv6.init(inst, def);
2668
+ ZodStringFormat.init(inst, def);
2669
+ });
2670
+ const ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
2671
+ $ZodBase64.init(inst, def);
2672
+ ZodStringFormat.init(inst, def);
2673
+ });
2674
+ const ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
2675
+ $ZodBase64URL.init(inst, def);
2676
+ ZodStringFormat.init(inst, def);
2677
+ });
2678
+ const ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
2679
+ $ZodE164.init(inst, def);
2680
+ ZodStringFormat.init(inst, def);
2681
+ });
2682
+ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
2683
+ $ZodJWT.init(inst, def);
2684
+ ZodStringFormat.init(inst, def);
2685
+ });
2686
+ const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
2687
+ $ZodBoolean.init(inst, def);
2688
+ ZodType.init(inst, def);
2689
+ });
2690
+ function boolean(params) {
2691
+ return _boolean(ZodBoolean, params);
2692
+ }
2693
+ const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
2694
+ $ZodUnknown.init(inst, def);
2695
+ ZodType.init(inst, def);
2696
+ });
2697
+ function unknown() {
2698
+ return _unknown(ZodUnknown);
2699
+ }
2700
+ const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
2701
+ $ZodNever.init(inst, def);
2702
+ ZodType.init(inst, def);
2703
+ });
2704
+ function never(params) {
2705
+ return _never(ZodNever, params);
2706
+ }
2707
+ const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
2708
+ $ZodArray.init(inst, def);
2709
+ ZodType.init(inst, def);
2710
+ inst.element = def.element;
2711
+ inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
2712
+ inst.nonempty = (params) => inst.check(_minLength(1, params));
2713
+ inst.max = (maxLength, params) => inst.check(_maxLength(maxLength, params));
2714
+ inst.length = (len, params) => inst.check(_length(len, params));
2715
+ inst.unwrap = () => inst.element;
2716
+ });
2717
+ function array(element, params) {
2718
+ return _array(ZodArray, element, params);
2719
+ }
2720
+ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
2721
+ $ZodObjectJIT.init(inst, def);
2722
+ ZodType.init(inst, def);
2723
+ defineLazy(inst, "shape", () => {
2724
+ return def.shape;
2725
+ });
2726
+ inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
2727
+ inst.catchall = (catchall) => inst.clone({ ...inst._zod.def, catchall });
2728
+ inst.passthrough = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
2729
+ inst.loose = () => inst.clone({ ...inst._zod.def, catchall: unknown() });
2730
+ inst.strict = () => inst.clone({ ...inst._zod.def, catchall: never() });
2731
+ inst.strip = () => inst.clone({ ...inst._zod.def, catchall: void 0 });
2732
+ inst.extend = (incoming) => {
2733
+ return extend(inst, incoming);
2734
+ };
2735
+ inst.safeExtend = (incoming) => {
2736
+ return safeExtend(inst, incoming);
2737
+ };
2738
+ inst.merge = (other) => merge(inst, other);
2739
+ inst.pick = (mask) => pick(inst, mask);
2740
+ inst.omit = (mask) => omit(inst, mask);
2741
+ inst.partial = (...args) => partial(ZodOptional, inst, args[0]);
2742
+ inst.required = (...args) => required(ZodNonOptional, inst, args[0]);
2743
+ });
2744
+ function object(shape, params) {
2745
+ const def = {
2746
+ type: "object",
2747
+ shape: shape ?? {},
2748
+ ...normalizeParams(params)
2749
+ };
2750
+ return new ZodObject(def);
2751
+ }
2752
+ const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
2753
+ $ZodUnion.init(inst, def);
2754
+ ZodType.init(inst, def);
2755
+ inst.options = def.options;
2756
+ });
2757
+ function union(options, params) {
2758
+ return new ZodUnion({
2759
+ type: "union",
2760
+ options,
2761
+ ...normalizeParams(params)
2762
+ });
2763
+ }
2764
+ const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
2765
+ $ZodIntersection.init(inst, def);
2766
+ ZodType.init(inst, def);
2767
+ });
2768
+ function intersection(left, right) {
2769
+ return new ZodIntersection({
2770
+ type: "intersection",
2771
+ left,
2772
+ right
2773
+ });
2774
+ }
2775
+ const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
2776
+ $ZodEnum.init(inst, def);
2777
+ ZodType.init(inst, def);
2778
+ inst.enum = def.entries;
2779
+ inst.options = Object.values(def.entries);
2780
+ const keys = new Set(Object.keys(def.entries));
2781
+ inst.extract = (values, params) => {
2782
+ const newEntries = {};
2783
+ for (const value of values) {
2784
+ if (keys.has(value)) {
2785
+ newEntries[value] = def.entries[value];
2786
+ } else
2787
+ throw new Error(`Key ${value} not found in enum`);
2788
+ }
2789
+ return new ZodEnum({
2790
+ ...def,
2791
+ checks: [],
2792
+ ...normalizeParams(params),
2793
+ entries: newEntries
2794
+ });
2795
+ };
2796
+ inst.exclude = (values, params) => {
2797
+ const newEntries = { ...def.entries };
2798
+ for (const value of values) {
2799
+ if (keys.has(value)) {
2800
+ delete newEntries[value];
2801
+ } else
2802
+ throw new Error(`Key ${value} not found in enum`);
2803
+ }
2804
+ return new ZodEnum({
2805
+ ...def,
2806
+ checks: [],
2807
+ ...normalizeParams(params),
2808
+ entries: newEntries
2809
+ });
2810
+ };
2811
+ });
2812
+ function _enum(values, params) {
2813
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
2814
+ return new ZodEnum({
2815
+ type: "enum",
2816
+ entries,
2817
+ ...normalizeParams(params)
2818
+ });
2819
+ }
2820
+ const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
2821
+ $ZodTransform.init(inst, def);
2822
+ ZodType.init(inst, def);
2823
+ inst._zod.parse = (payload, _ctx) => {
2824
+ if (_ctx.direction === "backward") {
2825
+ throw new $ZodEncodeError(inst.constructor.name);
2826
+ }
2827
+ payload.addIssue = (issue$1) => {
2828
+ if (typeof issue$1 === "string") {
2829
+ payload.issues.push(issue(issue$1, payload.value, def));
2830
+ } else {
2831
+ const _issue = issue$1;
2832
+ if (_issue.fatal)
2833
+ _issue.continue = false;
2834
+ _issue.code ?? (_issue.code = "custom");
2835
+ _issue.input ?? (_issue.input = payload.value);
2836
+ _issue.inst ?? (_issue.inst = inst);
2837
+ payload.issues.push(issue(_issue));
2838
+ }
2839
+ };
2840
+ const output = def.transform(payload.value, payload);
2841
+ if (output instanceof Promise) {
2842
+ return output.then((output2) => {
2843
+ payload.value = output2;
2844
+ return payload;
2845
+ });
2846
+ }
2847
+ payload.value = output;
2848
+ return payload;
2849
+ };
2850
+ });
2851
+ function transform(fn) {
2852
+ return new ZodTransform({
2853
+ type: "transform",
2854
+ transform: fn
2855
+ });
2856
+ }
2857
+ const ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
2858
+ $ZodOptional.init(inst, def);
2859
+ ZodType.init(inst, def);
2860
+ inst.unwrap = () => inst._zod.def.innerType;
2861
+ });
2862
+ function optional(innerType) {
2863
+ return new ZodOptional({
2864
+ type: "optional",
2865
+ innerType
2866
+ });
2867
+ }
2868
+ const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
2869
+ $ZodNullable.init(inst, def);
2870
+ ZodType.init(inst, def);
2871
+ inst.unwrap = () => inst._zod.def.innerType;
2872
+ });
2873
+ function nullable(innerType) {
2874
+ return new ZodNullable({
2875
+ type: "nullable",
2876
+ innerType
2877
+ });
2878
+ }
2879
+ const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
2880
+ $ZodDefault.init(inst, def);
2881
+ ZodType.init(inst, def);
2882
+ inst.unwrap = () => inst._zod.def.innerType;
2883
+ inst.removeDefault = inst.unwrap;
2884
+ });
2885
+ function _default(innerType, defaultValue) {
2886
+ return new ZodDefault({
2887
+ type: "default",
2888
+ innerType,
2889
+ get defaultValue() {
2890
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
2891
+ }
2892
+ });
2893
+ }
2894
+ const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
2895
+ $ZodPrefault.init(inst, def);
2896
+ ZodType.init(inst, def);
2897
+ inst.unwrap = () => inst._zod.def.innerType;
2898
+ });
2899
+ function prefault(innerType, defaultValue) {
2900
+ return new ZodPrefault({
2901
+ type: "prefault",
2902
+ innerType,
2903
+ get defaultValue() {
2904
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
2905
+ }
2906
+ });
2907
+ }
2908
+ const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
2909
+ $ZodNonOptional.init(inst, def);
2910
+ ZodType.init(inst, def);
2911
+ inst.unwrap = () => inst._zod.def.innerType;
2912
+ });
2913
+ function nonoptional(innerType, params) {
2914
+ return new ZodNonOptional({
2915
+ type: "nonoptional",
2916
+ innerType,
2917
+ ...normalizeParams(params)
2918
+ });
2919
+ }
2920
+ const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
2921
+ $ZodCatch.init(inst, def);
2922
+ ZodType.init(inst, def);
2923
+ inst.unwrap = () => inst._zod.def.innerType;
2924
+ inst.removeCatch = inst.unwrap;
2925
+ });
2926
+ function _catch(innerType, catchValue) {
2927
+ return new ZodCatch({
2928
+ type: "catch",
2929
+ innerType,
2930
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
2931
+ });
2932
+ }
2933
+ const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
2934
+ $ZodPipe.init(inst, def);
2935
+ ZodType.init(inst, def);
2936
+ inst.in = def.in;
2937
+ inst.out = def.out;
2938
+ });
2939
+ function pipe(in_, out) {
2940
+ return new ZodPipe({
2941
+ type: "pipe",
2942
+ in: in_,
2943
+ out
2944
+ // ...util.normalizeParams(params),
2945
+ });
2946
+ }
2947
+ const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
2948
+ $ZodReadonly.init(inst, def);
2949
+ ZodType.init(inst, def);
2950
+ inst.unwrap = () => inst._zod.def.innerType;
2951
+ });
2952
+ function readonly(innerType) {
2953
+ return new ZodReadonly({
2954
+ type: "readonly",
2955
+ innerType
2956
+ });
2957
+ }
2958
+ const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
2959
+ $ZodCustom.init(inst, def);
2960
+ ZodType.init(inst, def);
2961
+ });
2962
+ function refine(fn, _params = {}) {
2963
+ return _refine(ZodCustom, fn, _params);
2964
+ }
2965
+ function superRefine(fn) {
2966
+ return _superRefine(fn);
2967
+ }
2968
+ export {
2969
+ boolean as b,
2970
+ object as o,
2971
+ string as s
2972
+ };