@mulmoclaude/google-plugin 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,4189 @@
1
+ import { DEFAULT_LIST_MAX_RESULTS, MAX_LIST_RESULTS, clientSecretPresence, createCalendarEvent, getGoogleAccessToken, isIsoDateTimeWithOffset, listCalendarEvents, loadGoogleTokens } from "@mulmoclaude/core/google";
2
+ //#region ../../../node_modules/gui-chat-protocol/dist/index.js
3
+ function definePlugin(setup) {
4
+ return setup;
5
+ }
6
+ //#endregion
7
+ //#region ../../../node_modules/zod/v4/core/core.js
8
+ var _a$1;
9
+ function $constructor(name, initializer, params) {
10
+ function init(inst, def) {
11
+ if (!inst._zod) Object.defineProperty(inst, "_zod", {
12
+ value: {
13
+ def,
14
+ constr: _,
15
+ traits: /* @__PURE__ */ new Set()
16
+ },
17
+ enumerable: false
18
+ });
19
+ if (inst._zod.traits.has(name)) return;
20
+ inst._zod.traits.add(name);
21
+ initializer(inst, def);
22
+ const proto = _.prototype;
23
+ const keys = Object.keys(proto);
24
+ for (let i = 0; i < keys.length; i++) {
25
+ const k = keys[i];
26
+ if (!(k in inst)) inst[k] = proto[k].bind(inst);
27
+ }
28
+ }
29
+ const Parent = params?.Parent ?? Object;
30
+ class Definition extends Parent {}
31
+ Object.defineProperty(Definition, "name", { value: name });
32
+ function _(def) {
33
+ var _a;
34
+ const inst = params?.Parent ? new Definition() : this;
35
+ init(inst, def);
36
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
37
+ for (const fn of inst._zod.deferred) fn();
38
+ return inst;
39
+ }
40
+ Object.defineProperty(_, "init", { value: init });
41
+ Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => {
42
+ if (params?.Parent && inst instanceof params.Parent) return true;
43
+ return inst?._zod?.traits?.has(name);
44
+ } });
45
+ Object.defineProperty(_, "name", { value: name });
46
+ return _;
47
+ }
48
+ var $ZodAsyncError = class extends Error {
49
+ constructor() {
50
+ super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
51
+ }
52
+ };
53
+ var $ZodEncodeError = class extends Error {
54
+ constructor(name) {
55
+ super(`Encountered unidirectional transform during encode: ${name}`);
56
+ this.name = "ZodEncodeError";
57
+ }
58
+ };
59
+ (_a$1 = globalThis).__zod_globalConfig ?? (_a$1.__zod_globalConfig = {});
60
+ var globalConfig = globalThis.__zod_globalConfig;
61
+ function config(newConfig) {
62
+ if (newConfig) Object.assign(globalConfig, newConfig);
63
+ return globalConfig;
64
+ }
65
+ //#endregion
66
+ //#region ../../../node_modules/zod/v4/core/util.js
67
+ function getEnumValues(entries) {
68
+ const numericValues = Object.values(entries).filter((v) => typeof v === "number");
69
+ return Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v);
70
+ }
71
+ function jsonStringifyReplacer(_, value) {
72
+ if (typeof value === "bigint") return value.toString();
73
+ return value;
74
+ }
75
+ function cached(getter) {
76
+ return { get value() {
77
+ {
78
+ const value = getter();
79
+ Object.defineProperty(this, "value", { value });
80
+ return value;
81
+ }
82
+ throw new Error("cached value already set");
83
+ } };
84
+ }
85
+ function nullish(input) {
86
+ return input === null || input === void 0;
87
+ }
88
+ function cleanRegex(source) {
89
+ const start = source.startsWith("^") ? 1 : 0;
90
+ const end = source.endsWith("$") ? source.length - 1 : source.length;
91
+ return source.slice(start, end);
92
+ }
93
+ function floatSafeRemainder(val, step) {
94
+ const ratio = val / step;
95
+ const roundedRatio = Math.round(ratio);
96
+ const tolerance = Number.EPSILON * Math.max(Math.abs(ratio), 1);
97
+ if (Math.abs(ratio - roundedRatio) < tolerance) return 0;
98
+ return ratio - roundedRatio;
99
+ }
100
+ var EVALUATING = /* @__PURE__*/ Symbol("evaluating");
101
+ function defineLazy(object, key, getter) {
102
+ let value = void 0;
103
+ Object.defineProperty(object, key, {
104
+ get() {
105
+ if (value === EVALUATING) return;
106
+ if (value === void 0) {
107
+ value = EVALUATING;
108
+ value = getter();
109
+ }
110
+ return value;
111
+ },
112
+ set(v) {
113
+ Object.defineProperty(object, key, { value: v });
114
+ },
115
+ configurable: true
116
+ });
117
+ }
118
+ function assignProp(target, prop, value) {
119
+ Object.defineProperty(target, prop, {
120
+ value,
121
+ writable: true,
122
+ enumerable: true,
123
+ configurable: true
124
+ });
125
+ }
126
+ function mergeDefs(...defs) {
127
+ const mergedDescriptors = {};
128
+ for (const def of defs) {
129
+ const descriptors = Object.getOwnPropertyDescriptors(def);
130
+ Object.assign(mergedDescriptors, descriptors);
131
+ }
132
+ return Object.defineProperties({}, mergedDescriptors);
133
+ }
134
+ function esc(str) {
135
+ return JSON.stringify(str);
136
+ }
137
+ function slugify(input) {
138
+ return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
139
+ }
140
+ var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
141
+ function isObject(data) {
142
+ return typeof data === "object" && data !== null && !Array.isArray(data);
143
+ }
144
+ var allowsEval = /* @__PURE__*/ cached(() => {
145
+ if (globalConfig.jitless) return false;
146
+ if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) return false;
147
+ try {
148
+ new Function("");
149
+ return true;
150
+ } catch (_) {
151
+ return false;
152
+ }
153
+ });
154
+ function isPlainObject(o) {
155
+ if (isObject(o) === false) return false;
156
+ const ctor = o.constructor;
157
+ if (ctor === void 0) return true;
158
+ if (typeof ctor !== "function") return true;
159
+ const prot = ctor.prototype;
160
+ if (isObject(prot) === false) return false;
161
+ if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
162
+ return true;
163
+ }
164
+ function shallowClone(o) {
165
+ if (isPlainObject(o)) return { ...o };
166
+ if (Array.isArray(o)) return [...o];
167
+ if (o instanceof Map) return new Map(o);
168
+ if (o instanceof Set) return new Set(o);
169
+ return o;
170
+ }
171
+ var propertyKeyTypes = /* @__PURE__*/ new Set([
172
+ "string",
173
+ "number",
174
+ "symbol"
175
+ ]);
176
+ function escapeRegex(str) {
177
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
178
+ }
179
+ function clone(inst, def, params) {
180
+ const cl = new inst._zod.constr(def ?? inst._zod.def);
181
+ if (!def || params?.parent) cl._zod.parent = inst;
182
+ return cl;
183
+ }
184
+ function normalizeParams(_params) {
185
+ const params = _params;
186
+ if (!params) return {};
187
+ if (typeof params === "string") return { error: () => params };
188
+ if (params?.message !== void 0) {
189
+ if (params?.error !== void 0) throw new Error("Cannot specify both `message` and `error` params");
190
+ params.error = params.message;
191
+ }
192
+ delete params.message;
193
+ if (typeof params.error === "string") return {
194
+ ...params,
195
+ error: () => params.error
196
+ };
197
+ return params;
198
+ }
199
+ function optionalKeys(shape) {
200
+ return Object.keys(shape).filter((k) => {
201
+ return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional";
202
+ });
203
+ }
204
+ var NUMBER_FORMAT_RANGES = {
205
+ safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER],
206
+ int32: [-2147483648, 2147483647],
207
+ uint32: [0, 4294967295],
208
+ float32: [-34028234663852886e22, 34028234663852886e22],
209
+ float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
210
+ };
211
+ function pick(schema, mask) {
212
+ const currDef = schema._zod.def;
213
+ const checks = currDef.checks;
214
+ if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
215
+ return clone(schema, mergeDefs(schema._zod.def, {
216
+ get shape() {
217
+ const newShape = {};
218
+ for (const key in mask) {
219
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
220
+ if (!mask[key]) continue;
221
+ newShape[key] = currDef.shape[key];
222
+ }
223
+ assignProp(this, "shape", newShape);
224
+ return newShape;
225
+ },
226
+ checks: []
227
+ }));
228
+ }
229
+ function omit(schema, mask) {
230
+ const currDef = schema._zod.def;
231
+ const checks = currDef.checks;
232
+ if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
233
+ return clone(schema, mergeDefs(schema._zod.def, {
234
+ get shape() {
235
+ const newShape = { ...schema._zod.def.shape };
236
+ for (const key in mask) {
237
+ if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
238
+ if (!mask[key]) continue;
239
+ delete newShape[key];
240
+ }
241
+ assignProp(this, "shape", newShape);
242
+ return newShape;
243
+ },
244
+ checks: []
245
+ }));
246
+ }
247
+ function extend(schema, shape) {
248
+ if (!isPlainObject(shape)) throw new Error("Invalid input to extend: expected a plain object");
249
+ const checks = schema._zod.def.checks;
250
+ if (checks && checks.length > 0) {
251
+ const existingShape = schema._zod.def.shape;
252
+ for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
253
+ }
254
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
255
+ const _shape = {
256
+ ...schema._zod.def.shape,
257
+ ...shape
258
+ };
259
+ assignProp(this, "shape", _shape);
260
+ return _shape;
261
+ } }));
262
+ }
263
+ function safeExtend(schema, shape) {
264
+ if (!isPlainObject(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
265
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
266
+ const _shape = {
267
+ ...schema._zod.def.shape,
268
+ ...shape
269
+ };
270
+ assignProp(this, "shape", _shape);
271
+ return _shape;
272
+ } }));
273
+ }
274
+ function merge(a, b) {
275
+ if (a._zod.def.checks?.length) throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");
276
+ return clone(a, mergeDefs(a._zod.def, {
277
+ get shape() {
278
+ const _shape = {
279
+ ...a._zod.def.shape,
280
+ ...b._zod.def.shape
281
+ };
282
+ assignProp(this, "shape", _shape);
283
+ return _shape;
284
+ },
285
+ get catchall() {
286
+ return b._zod.def.catchall;
287
+ },
288
+ checks: b._zod.def.checks ?? []
289
+ }));
290
+ }
291
+ function partial(Class, schema, mask) {
292
+ const checks = schema._zod.def.checks;
293
+ if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
294
+ return clone(schema, mergeDefs(schema._zod.def, {
295
+ get shape() {
296
+ const oldShape = schema._zod.def.shape;
297
+ const shape = { ...oldShape };
298
+ if (mask) for (const key in mask) {
299
+ if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
300
+ if (!mask[key]) continue;
301
+ shape[key] = Class ? new Class({
302
+ type: "optional",
303
+ innerType: oldShape[key]
304
+ }) : oldShape[key];
305
+ }
306
+ else for (const key in oldShape) shape[key] = Class ? new Class({
307
+ type: "optional",
308
+ innerType: oldShape[key]
309
+ }) : oldShape[key];
310
+ assignProp(this, "shape", shape);
311
+ return shape;
312
+ },
313
+ checks: []
314
+ }));
315
+ }
316
+ function required(Class, schema, mask) {
317
+ return clone(schema, mergeDefs(schema._zod.def, { get shape() {
318
+ const oldShape = schema._zod.def.shape;
319
+ const shape = { ...oldShape };
320
+ if (mask) for (const key in mask) {
321
+ if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
322
+ if (!mask[key]) continue;
323
+ shape[key] = new Class({
324
+ type: "nonoptional",
325
+ innerType: oldShape[key]
326
+ });
327
+ }
328
+ else for (const key in oldShape) shape[key] = new Class({
329
+ type: "nonoptional",
330
+ innerType: oldShape[key]
331
+ });
332
+ assignProp(this, "shape", shape);
333
+ return shape;
334
+ } }));
335
+ }
336
+ function aborted(x, startIndex = 0) {
337
+ if (x.aborted === true) return true;
338
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
339
+ return false;
340
+ }
341
+ function explicitlyAborted(x, startIndex = 0) {
342
+ if (x.aborted === true) return true;
343
+ for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue === false) return true;
344
+ return false;
345
+ }
346
+ function prefixIssues(path, issues) {
347
+ return issues.map((iss) => {
348
+ var _a;
349
+ (_a = iss).path ?? (_a.path = []);
350
+ iss.path.unshift(path);
351
+ return iss;
352
+ });
353
+ }
354
+ function unwrapMessage(message) {
355
+ return typeof message === "string" ? message : message?.message;
356
+ }
357
+ function finalizeIssue(iss, ctx, config) {
358
+ const message = iss.message ? iss.message : unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config.customError?.(iss)) ?? unwrapMessage(config.localeError?.(iss)) ?? "Invalid input";
359
+ const { inst: _inst, continue: _continue, input: _input, ...rest } = iss;
360
+ rest.path ?? (rest.path = []);
361
+ rest.message = message;
362
+ if (ctx?.reportInput) rest.input = _input;
363
+ return rest;
364
+ }
365
+ function getLengthableOrigin(input) {
366
+ if (Array.isArray(input)) return "array";
367
+ if (typeof input === "string") return "string";
368
+ return "unknown";
369
+ }
370
+ function issue(...args) {
371
+ const [iss, input, inst] = args;
372
+ if (typeof iss === "string") return {
373
+ message: iss,
374
+ code: "custom",
375
+ input,
376
+ inst
377
+ };
378
+ return { ...iss };
379
+ }
380
+ //#endregion
381
+ //#region ../../../node_modules/zod/v4/core/errors.js
382
+ var initializer$1 = (inst, def) => {
383
+ inst.name = "$ZodError";
384
+ Object.defineProperty(inst, "_zod", {
385
+ value: inst._zod,
386
+ enumerable: false
387
+ });
388
+ Object.defineProperty(inst, "issues", {
389
+ value: def,
390
+ enumerable: false
391
+ });
392
+ inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
393
+ Object.defineProperty(inst, "toString", {
394
+ value: () => inst.message,
395
+ enumerable: false
396
+ });
397
+ };
398
+ var $ZodError = $constructor("$ZodError", initializer$1);
399
+ var $ZodRealError = $constructor("$ZodError", initializer$1, { Parent: Error });
400
+ function flattenError(error, mapper = (issue) => issue.message) {
401
+ const fieldErrors = {};
402
+ const formErrors = [];
403
+ for (const sub of error.issues) if (sub.path.length > 0) {
404
+ fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
405
+ fieldErrors[sub.path[0]].push(mapper(sub));
406
+ } else formErrors.push(mapper(sub));
407
+ return {
408
+ formErrors,
409
+ fieldErrors
410
+ };
411
+ }
412
+ function formatError(error, mapper = (issue) => issue.message) {
413
+ const fieldErrors = { _errors: [] };
414
+ const processError = (error, path = []) => {
415
+ for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }, [...path, ...issue.path]));
416
+ else if (issue.code === "invalid_key") processError({ issues: issue.issues }, [...path, ...issue.path]);
417
+ else if (issue.code === "invalid_element") processError({ issues: issue.issues }, [...path, ...issue.path]);
418
+ else {
419
+ const fullpath = [...path, ...issue.path];
420
+ if (fullpath.length === 0) fieldErrors._errors.push(mapper(issue));
421
+ else {
422
+ let curr = fieldErrors;
423
+ let i = 0;
424
+ while (i < fullpath.length) {
425
+ const el = fullpath[i];
426
+ if (!(i === fullpath.length - 1)) curr[el] = curr[el] || { _errors: [] };
427
+ else {
428
+ curr[el] = curr[el] || { _errors: [] };
429
+ curr[el]._errors.push(mapper(issue));
430
+ }
431
+ curr = curr[el];
432
+ i++;
433
+ }
434
+ }
435
+ }
436
+ };
437
+ processError(error);
438
+ return fieldErrors;
439
+ }
440
+ //#endregion
441
+ //#region ../../../node_modules/zod/v4/core/parse.js
442
+ var _parse = (_Err) => (schema, value, _ctx, _params) => {
443
+ const ctx = _ctx ? {
444
+ ..._ctx,
445
+ async: false
446
+ } : { async: false };
447
+ const result = schema._zod.run({
448
+ value,
449
+ issues: []
450
+ }, ctx);
451
+ if (result instanceof Promise) throw new $ZodAsyncError();
452
+ if (result.issues.length) {
453
+ const e = new ((_params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
454
+ captureStackTrace(e, _params?.callee);
455
+ throw e;
456
+ }
457
+ return result.value;
458
+ };
459
+ var _parseAsync = (_Err) => async (schema, value, _ctx, params) => {
460
+ const ctx = _ctx ? {
461
+ ..._ctx,
462
+ async: true
463
+ } : { async: true };
464
+ let result = schema._zod.run({
465
+ value,
466
+ issues: []
467
+ }, ctx);
468
+ if (result instanceof Promise) result = await result;
469
+ if (result.issues.length) {
470
+ const e = new ((params?.Err) ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())));
471
+ captureStackTrace(e, params?.callee);
472
+ throw e;
473
+ }
474
+ return result.value;
475
+ };
476
+ var _safeParse = (_Err) => (schema, value, _ctx) => {
477
+ const ctx = _ctx ? {
478
+ ..._ctx,
479
+ async: false
480
+ } : { async: false };
481
+ const result = schema._zod.run({
482
+ value,
483
+ issues: []
484
+ }, ctx);
485
+ if (result instanceof Promise) throw new $ZodAsyncError();
486
+ return result.issues.length ? {
487
+ success: false,
488
+ error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
489
+ } : {
490
+ success: true,
491
+ data: result.value
492
+ };
493
+ };
494
+ var safeParse$1 = /* @__PURE__*/ _safeParse($ZodRealError);
495
+ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
496
+ const ctx = _ctx ? {
497
+ ..._ctx,
498
+ async: true
499
+ } : { async: true };
500
+ let result = schema._zod.run({
501
+ value,
502
+ issues: []
503
+ }, ctx);
504
+ if (result instanceof Promise) result = await result;
505
+ return result.issues.length ? {
506
+ success: false,
507
+ error: new _Err(result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
508
+ } : {
509
+ success: true,
510
+ data: result.value
511
+ };
512
+ };
513
+ var safeParseAsync$1 = /* @__PURE__*/ _safeParseAsync($ZodRealError);
514
+ var _encode = (_Err) => (schema, value, _ctx) => {
515
+ const ctx = _ctx ? {
516
+ ..._ctx,
517
+ direction: "backward"
518
+ } : { direction: "backward" };
519
+ return _parse(_Err)(schema, value, ctx);
520
+ };
521
+ var _decode = (_Err) => (schema, value, _ctx) => {
522
+ return _parse(_Err)(schema, value, _ctx);
523
+ };
524
+ var _encodeAsync = (_Err) => async (schema, value, _ctx) => {
525
+ const ctx = _ctx ? {
526
+ ..._ctx,
527
+ direction: "backward"
528
+ } : { direction: "backward" };
529
+ return _parseAsync(_Err)(schema, value, ctx);
530
+ };
531
+ var _decodeAsync = (_Err) => async (schema, value, _ctx) => {
532
+ return _parseAsync(_Err)(schema, value, _ctx);
533
+ };
534
+ var _safeEncode = (_Err) => (schema, value, _ctx) => {
535
+ const ctx = _ctx ? {
536
+ ..._ctx,
537
+ direction: "backward"
538
+ } : { direction: "backward" };
539
+ return _safeParse(_Err)(schema, value, ctx);
540
+ };
541
+ var _safeDecode = (_Err) => (schema, value, _ctx) => {
542
+ return _safeParse(_Err)(schema, value, _ctx);
543
+ };
544
+ var _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
545
+ const ctx = _ctx ? {
546
+ ..._ctx,
547
+ direction: "backward"
548
+ } : { direction: "backward" };
549
+ return _safeParseAsync(_Err)(schema, value, ctx);
550
+ };
551
+ var _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
552
+ return _safeParseAsync(_Err)(schema, value, _ctx);
553
+ };
554
+ //#endregion
555
+ //#region ../../../node_modules/zod/v4/core/regexes.js
556
+ /**
557
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
558
+ * (timestamps embedded in the id). Use {@link cuid2} instead.
559
+ * See https://github.com/paralleldrive/cuid.
560
+ */
561
+ var cuid = /^[cC][0-9a-z]{6,}$/;
562
+ var cuid2 = /^[0-9a-z]+$/;
563
+ var ulid = /^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/;
564
+ var xid = /^[0-9a-vA-V]{20}$/;
565
+ var ksuid = /^[A-Za-z0-9]{27}$/;
566
+ var nanoid = /^[a-zA-Z0-9_-]{21}$/;
567
+ /** ISO 8601-1 duration regex. Does not support the 8601-2 extensions like negative durations or fractional/negative components. */
568
+ var duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
569
+ /** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
570
+ var 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})$/;
571
+ /** Returns a regex for validating an RFC 9562/4122 UUID.
572
+ *
573
+ * @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
574
+ var uuid = (version) => {
575
+ if (!version) 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)$/;
576
+ return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
577
+ };
578
+ /** Practical email validation */
579
+ var email = /^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;
580
+ var _emoji$1 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
581
+ function emoji() {
582
+ return new RegExp(_emoji$1, "u");
583
+ }
584
+ var 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])$/;
585
+ var 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}|:))$/;
586
+ var 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])$/;
587
+ var 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])$/;
588
+ var base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
589
+ var base64url = /^[A-Za-z0-9_-]*$/;
590
+ var httpProtocol = /^https?$/;
591
+ var e164 = /^\+[1-9]\d{6,14}$/;
592
+ var 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])))`;
593
+ var date$1 = /*@__PURE__*/ new RegExp(`^${dateSource}$`);
594
+ function timeSource(args) {
595
+ const hhmm = `(?:[01]\\d|2[0-3]):[0-5]\\d`;
596
+ return 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+)?)?`;
597
+ }
598
+ function time$1(args) {
599
+ return new RegExp(`^${timeSource(args)}$`);
600
+ }
601
+ function datetime$1(args) {
602
+ const time = timeSource({ precision: args.precision });
603
+ const opts = ["Z"];
604
+ if (args.local) opts.push("");
605
+ if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
606
+ const timeRegex = `${time}(?:${opts.join("|")})`;
607
+ return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
608
+ }
609
+ var string$1 = (params) => {
610
+ const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
611
+ return new RegExp(`^${regex}$`);
612
+ };
613
+ var integer = /^-?\d+$/;
614
+ var number$1 = /^-?\d+(?:\.\d+)?$/;
615
+ var lowercase = /^[^A-Z]*$/;
616
+ var uppercase = /^[^a-z]*$/;
617
+ //#endregion
618
+ //#region ../../../node_modules/zod/v4/core/checks.js
619
+ var $ZodCheck = /*@__PURE__*/ $constructor("$ZodCheck", (inst, def) => {
620
+ var _a;
621
+ inst._zod ?? (inst._zod = {});
622
+ inst._zod.def = def;
623
+ (_a = inst._zod).onattach ?? (_a.onattach = []);
624
+ });
625
+ var numericOriginMap = {
626
+ number: "number",
627
+ bigint: "bigint",
628
+ object: "date"
629
+ };
630
+ var $ZodCheckLessThan = /*@__PURE__*/ $constructor("$ZodCheckLessThan", (inst, def) => {
631
+ $ZodCheck.init(inst, def);
632
+ const origin = numericOriginMap[typeof def.value];
633
+ inst._zod.onattach.push((inst) => {
634
+ const bag = inst._zod.bag;
635
+ const curr = (def.inclusive ? bag.maximum : bag.exclusiveMaximum) ?? Number.POSITIVE_INFINITY;
636
+ if (def.value < curr) if (def.inclusive) bag.maximum = def.value;
637
+ else bag.exclusiveMaximum = def.value;
638
+ });
639
+ inst._zod.check = (payload) => {
640
+ if (def.inclusive ? payload.value <= def.value : payload.value < def.value) return;
641
+ payload.issues.push({
642
+ origin,
643
+ code: "too_big",
644
+ maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
645
+ input: payload.value,
646
+ inclusive: def.inclusive,
647
+ inst,
648
+ continue: !def.abort
649
+ });
650
+ };
651
+ });
652
+ var $ZodCheckGreaterThan = /*@__PURE__*/ $constructor("$ZodCheckGreaterThan", (inst, def) => {
653
+ $ZodCheck.init(inst, def);
654
+ const origin = numericOriginMap[typeof def.value];
655
+ inst._zod.onattach.push((inst) => {
656
+ const bag = inst._zod.bag;
657
+ const curr = (def.inclusive ? bag.minimum : bag.exclusiveMinimum) ?? Number.NEGATIVE_INFINITY;
658
+ if (def.value > curr) if (def.inclusive) bag.minimum = def.value;
659
+ else bag.exclusiveMinimum = def.value;
660
+ });
661
+ inst._zod.check = (payload) => {
662
+ if (def.inclusive ? payload.value >= def.value : payload.value > def.value) return;
663
+ payload.issues.push({
664
+ origin,
665
+ code: "too_small",
666
+ minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
667
+ input: payload.value,
668
+ inclusive: def.inclusive,
669
+ inst,
670
+ continue: !def.abort
671
+ });
672
+ };
673
+ });
674
+ var $ZodCheckMultipleOf = /*@__PURE__*/ $constructor("$ZodCheckMultipleOf", (inst, def) => {
675
+ $ZodCheck.init(inst, def);
676
+ inst._zod.onattach.push((inst) => {
677
+ var _a;
678
+ (_a = inst._zod.bag).multipleOf ?? (_a.multipleOf = def.value);
679
+ });
680
+ inst._zod.check = (payload) => {
681
+ if (typeof payload.value !== typeof def.value) throw new Error("Cannot mix number and bigint in multiple_of check.");
682
+ if (typeof payload.value === "bigint" ? payload.value % def.value === BigInt(0) : floatSafeRemainder(payload.value, def.value) === 0) return;
683
+ payload.issues.push({
684
+ origin: typeof payload.value,
685
+ code: "not_multiple_of",
686
+ divisor: def.value,
687
+ input: payload.value,
688
+ inst,
689
+ continue: !def.abort
690
+ });
691
+ };
692
+ });
693
+ var $ZodCheckNumberFormat = /*@__PURE__*/ $constructor("$ZodCheckNumberFormat", (inst, def) => {
694
+ $ZodCheck.init(inst, def);
695
+ def.format = def.format || "float64";
696
+ const isInt = def.format?.includes("int");
697
+ const origin = isInt ? "int" : "number";
698
+ const [minimum, maximum] = NUMBER_FORMAT_RANGES[def.format];
699
+ inst._zod.onattach.push((inst) => {
700
+ const bag = inst._zod.bag;
701
+ bag.format = def.format;
702
+ bag.minimum = minimum;
703
+ bag.maximum = maximum;
704
+ if (isInt) bag.pattern = integer;
705
+ });
706
+ inst._zod.check = (payload) => {
707
+ const input = payload.value;
708
+ if (isInt) {
709
+ if (!Number.isInteger(input)) {
710
+ payload.issues.push({
711
+ expected: origin,
712
+ format: def.format,
713
+ code: "invalid_type",
714
+ continue: false,
715
+ input,
716
+ inst
717
+ });
718
+ return;
719
+ }
720
+ if (!Number.isSafeInteger(input)) {
721
+ if (input > 0) payload.issues.push({
722
+ input,
723
+ code: "too_big",
724
+ maximum: Number.MAX_SAFE_INTEGER,
725
+ note: "Integers must be within the safe integer range.",
726
+ inst,
727
+ origin,
728
+ inclusive: true,
729
+ continue: !def.abort
730
+ });
731
+ else payload.issues.push({
732
+ input,
733
+ code: "too_small",
734
+ minimum: Number.MIN_SAFE_INTEGER,
735
+ note: "Integers must be within the safe integer range.",
736
+ inst,
737
+ origin,
738
+ inclusive: true,
739
+ continue: !def.abort
740
+ });
741
+ return;
742
+ }
743
+ }
744
+ if (input < minimum) payload.issues.push({
745
+ origin: "number",
746
+ input,
747
+ code: "too_small",
748
+ minimum,
749
+ inclusive: true,
750
+ inst,
751
+ continue: !def.abort
752
+ });
753
+ if (input > maximum) payload.issues.push({
754
+ origin: "number",
755
+ input,
756
+ code: "too_big",
757
+ maximum,
758
+ inclusive: true,
759
+ inst,
760
+ continue: !def.abort
761
+ });
762
+ };
763
+ });
764
+ var $ZodCheckMaxLength = /*@__PURE__*/ $constructor("$ZodCheckMaxLength", (inst, def) => {
765
+ var _a;
766
+ $ZodCheck.init(inst, def);
767
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
768
+ const val = payload.value;
769
+ return !nullish(val) && val.length !== void 0;
770
+ });
771
+ inst._zod.onattach.push((inst) => {
772
+ const curr = inst._zod.bag.maximum ?? Number.POSITIVE_INFINITY;
773
+ if (def.maximum < curr) inst._zod.bag.maximum = def.maximum;
774
+ });
775
+ inst._zod.check = (payload) => {
776
+ const input = payload.value;
777
+ if (input.length <= def.maximum) return;
778
+ const origin = getLengthableOrigin(input);
779
+ payload.issues.push({
780
+ origin,
781
+ code: "too_big",
782
+ maximum: def.maximum,
783
+ inclusive: true,
784
+ input,
785
+ inst,
786
+ continue: !def.abort
787
+ });
788
+ };
789
+ });
790
+ var $ZodCheckMinLength = /*@__PURE__*/ $constructor("$ZodCheckMinLength", (inst, def) => {
791
+ var _a;
792
+ $ZodCheck.init(inst, def);
793
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
794
+ const val = payload.value;
795
+ return !nullish(val) && val.length !== void 0;
796
+ });
797
+ inst._zod.onattach.push((inst) => {
798
+ const curr = inst._zod.bag.minimum ?? Number.NEGATIVE_INFINITY;
799
+ if (def.minimum > curr) inst._zod.bag.minimum = def.minimum;
800
+ });
801
+ inst._zod.check = (payload) => {
802
+ const input = payload.value;
803
+ if (input.length >= def.minimum) return;
804
+ const origin = getLengthableOrigin(input);
805
+ payload.issues.push({
806
+ origin,
807
+ code: "too_small",
808
+ minimum: def.minimum,
809
+ inclusive: true,
810
+ input,
811
+ inst,
812
+ continue: !def.abort
813
+ });
814
+ };
815
+ });
816
+ var $ZodCheckLengthEquals = /*@__PURE__*/ $constructor("$ZodCheckLengthEquals", (inst, def) => {
817
+ var _a;
818
+ $ZodCheck.init(inst, def);
819
+ (_a = inst._zod.def).when ?? (_a.when = (payload) => {
820
+ const val = payload.value;
821
+ return !nullish(val) && val.length !== void 0;
822
+ });
823
+ inst._zod.onattach.push((inst) => {
824
+ const bag = inst._zod.bag;
825
+ bag.minimum = def.length;
826
+ bag.maximum = def.length;
827
+ bag.length = def.length;
828
+ });
829
+ inst._zod.check = (payload) => {
830
+ const input = payload.value;
831
+ const length = input.length;
832
+ if (length === def.length) return;
833
+ const origin = getLengthableOrigin(input);
834
+ const tooBig = length > def.length;
835
+ payload.issues.push({
836
+ origin,
837
+ ...tooBig ? {
838
+ code: "too_big",
839
+ maximum: def.length
840
+ } : {
841
+ code: "too_small",
842
+ minimum: def.length
843
+ },
844
+ inclusive: true,
845
+ exact: true,
846
+ input: payload.value,
847
+ inst,
848
+ continue: !def.abort
849
+ });
850
+ };
851
+ });
852
+ var $ZodCheckStringFormat = /*@__PURE__*/ $constructor("$ZodCheckStringFormat", (inst, def) => {
853
+ var _a, _b;
854
+ $ZodCheck.init(inst, def);
855
+ inst._zod.onattach.push((inst) => {
856
+ const bag = inst._zod.bag;
857
+ bag.format = def.format;
858
+ if (def.pattern) {
859
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
860
+ bag.patterns.add(def.pattern);
861
+ }
862
+ });
863
+ if (def.pattern) (_a = inst._zod).check ?? (_a.check = (payload) => {
864
+ def.pattern.lastIndex = 0;
865
+ if (def.pattern.test(payload.value)) return;
866
+ payload.issues.push({
867
+ origin: "string",
868
+ code: "invalid_format",
869
+ format: def.format,
870
+ input: payload.value,
871
+ ...def.pattern ? { pattern: def.pattern.toString() } : {},
872
+ inst,
873
+ continue: !def.abort
874
+ });
875
+ });
876
+ else (_b = inst._zod).check ?? (_b.check = () => {});
877
+ });
878
+ var $ZodCheckRegex = /*@__PURE__*/ $constructor("$ZodCheckRegex", (inst, def) => {
879
+ $ZodCheckStringFormat.init(inst, def);
880
+ inst._zod.check = (payload) => {
881
+ def.pattern.lastIndex = 0;
882
+ if (def.pattern.test(payload.value)) return;
883
+ payload.issues.push({
884
+ origin: "string",
885
+ code: "invalid_format",
886
+ format: "regex",
887
+ input: payload.value,
888
+ pattern: def.pattern.toString(),
889
+ inst,
890
+ continue: !def.abort
891
+ });
892
+ };
893
+ });
894
+ var $ZodCheckLowerCase = /*@__PURE__*/ $constructor("$ZodCheckLowerCase", (inst, def) => {
895
+ def.pattern ?? (def.pattern = lowercase);
896
+ $ZodCheckStringFormat.init(inst, def);
897
+ });
898
+ var $ZodCheckUpperCase = /*@__PURE__*/ $constructor("$ZodCheckUpperCase", (inst, def) => {
899
+ def.pattern ?? (def.pattern = uppercase);
900
+ $ZodCheckStringFormat.init(inst, def);
901
+ });
902
+ var $ZodCheckIncludes = /*@__PURE__*/ $constructor("$ZodCheckIncludes", (inst, def) => {
903
+ $ZodCheck.init(inst, def);
904
+ const escapedRegex = escapeRegex(def.includes);
905
+ const pattern = new RegExp(typeof def.position === "number" ? `^.{${def.position}}${escapedRegex}` : escapedRegex);
906
+ def.pattern = pattern;
907
+ inst._zod.onattach.push((inst) => {
908
+ const bag = inst._zod.bag;
909
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
910
+ bag.patterns.add(pattern);
911
+ });
912
+ inst._zod.check = (payload) => {
913
+ if (payload.value.includes(def.includes, def.position)) return;
914
+ payload.issues.push({
915
+ origin: "string",
916
+ code: "invalid_format",
917
+ format: "includes",
918
+ includes: def.includes,
919
+ input: payload.value,
920
+ inst,
921
+ continue: !def.abort
922
+ });
923
+ };
924
+ });
925
+ var $ZodCheckStartsWith = /*@__PURE__*/ $constructor("$ZodCheckStartsWith", (inst, def) => {
926
+ $ZodCheck.init(inst, def);
927
+ const pattern = new RegExp(`^${escapeRegex(def.prefix)}.*`);
928
+ def.pattern ?? (def.pattern = pattern);
929
+ inst._zod.onattach.push((inst) => {
930
+ const bag = inst._zod.bag;
931
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
932
+ bag.patterns.add(pattern);
933
+ });
934
+ inst._zod.check = (payload) => {
935
+ if (payload.value.startsWith(def.prefix)) return;
936
+ payload.issues.push({
937
+ origin: "string",
938
+ code: "invalid_format",
939
+ format: "starts_with",
940
+ prefix: def.prefix,
941
+ input: payload.value,
942
+ inst,
943
+ continue: !def.abort
944
+ });
945
+ };
946
+ });
947
+ var $ZodCheckEndsWith = /*@__PURE__*/ $constructor("$ZodCheckEndsWith", (inst, def) => {
948
+ $ZodCheck.init(inst, def);
949
+ const pattern = new RegExp(`.*${escapeRegex(def.suffix)}$`);
950
+ def.pattern ?? (def.pattern = pattern);
951
+ inst._zod.onattach.push((inst) => {
952
+ const bag = inst._zod.bag;
953
+ bag.patterns ?? (bag.patterns = /* @__PURE__ */ new Set());
954
+ bag.patterns.add(pattern);
955
+ });
956
+ inst._zod.check = (payload) => {
957
+ if (payload.value.endsWith(def.suffix)) return;
958
+ payload.issues.push({
959
+ origin: "string",
960
+ code: "invalid_format",
961
+ format: "ends_with",
962
+ suffix: def.suffix,
963
+ input: payload.value,
964
+ inst,
965
+ continue: !def.abort
966
+ });
967
+ };
968
+ });
969
+ var $ZodCheckOverwrite = /*@__PURE__*/ $constructor("$ZodCheckOverwrite", (inst, def) => {
970
+ $ZodCheck.init(inst, def);
971
+ inst._zod.check = (payload) => {
972
+ payload.value = def.tx(payload.value);
973
+ };
974
+ });
975
+ //#endregion
976
+ //#region ../../../node_modules/zod/v4/core/doc.js
977
+ var Doc = class {
978
+ constructor(args = []) {
979
+ this.content = [];
980
+ this.indent = 0;
981
+ if (this) this.args = args;
982
+ }
983
+ indented(fn) {
984
+ this.indent += 1;
985
+ fn(this);
986
+ this.indent -= 1;
987
+ }
988
+ write(arg) {
989
+ if (typeof arg === "function") {
990
+ arg(this, { execution: "sync" });
991
+ arg(this, { execution: "async" });
992
+ return;
993
+ }
994
+ const lines = arg.split("\n").filter((x) => x);
995
+ const minIndent = Math.min(...lines.map((x) => x.length - x.trimStart().length));
996
+ const dedented = lines.map((x) => x.slice(minIndent)).map((x) => " ".repeat(this.indent * 2) + x);
997
+ for (const line of dedented) this.content.push(line);
998
+ }
999
+ compile() {
1000
+ const F = Function;
1001
+ const args = this?.args;
1002
+ const lines = [...(this?.content ?? [``]).map((x) => ` ${x}`)];
1003
+ return new F(...args, lines.join("\n"));
1004
+ }
1005
+ };
1006
+ //#endregion
1007
+ //#region ../../../node_modules/zod/v4/core/versions.js
1008
+ var version = {
1009
+ major: 4,
1010
+ minor: 4,
1011
+ patch: 3
1012
+ };
1013
+ //#endregion
1014
+ //#region ../../../node_modules/zod/v4/core/schemas.js
1015
+ var $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1016
+ var _a;
1017
+ inst ?? (inst = {});
1018
+ inst._zod.def = def;
1019
+ inst._zod.bag = inst._zod.bag || {};
1020
+ inst._zod.version = version;
1021
+ const checks = [...inst._zod.def.checks ?? []];
1022
+ if (inst._zod.traits.has("$ZodCheck")) checks.unshift(inst);
1023
+ for (const ch of checks) for (const fn of ch._zod.onattach) fn(inst);
1024
+ if (checks.length === 0) {
1025
+ (_a = inst._zod).deferred ?? (_a.deferred = []);
1026
+ inst._zod.deferred?.push(() => {
1027
+ inst._zod.run = inst._zod.parse;
1028
+ });
1029
+ } else {
1030
+ const runChecks = (payload, checks, ctx) => {
1031
+ let isAborted = aborted(payload);
1032
+ let asyncResult;
1033
+ for (const ch of checks) {
1034
+ if (ch._zod.def.when) {
1035
+ if (explicitlyAborted(payload)) continue;
1036
+ if (!ch._zod.def.when(payload)) continue;
1037
+ } else if (isAborted) continue;
1038
+ const currLen = payload.issues.length;
1039
+ const _ = ch._zod.check(payload);
1040
+ if (_ instanceof Promise && ctx?.async === false) throw new $ZodAsyncError();
1041
+ if (asyncResult || _ instanceof Promise) asyncResult = (asyncResult ?? Promise.resolve()).then(async () => {
1042
+ await _;
1043
+ if (payload.issues.length === currLen) return;
1044
+ if (!isAborted) isAborted = aborted(payload, currLen);
1045
+ });
1046
+ else {
1047
+ if (payload.issues.length === currLen) continue;
1048
+ if (!isAborted) isAborted = aborted(payload, currLen);
1049
+ }
1050
+ }
1051
+ if (asyncResult) return asyncResult.then(() => {
1052
+ return payload;
1053
+ });
1054
+ return payload;
1055
+ };
1056
+ const handleCanaryResult = (canary, payload, ctx) => {
1057
+ if (aborted(canary)) {
1058
+ canary.aborted = true;
1059
+ return canary;
1060
+ }
1061
+ const checkResult = runChecks(payload, checks, ctx);
1062
+ if (checkResult instanceof Promise) {
1063
+ if (ctx.async === false) throw new $ZodAsyncError();
1064
+ return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
1065
+ }
1066
+ return inst._zod.parse(checkResult, ctx);
1067
+ };
1068
+ inst._zod.run = (payload, ctx) => {
1069
+ if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
1070
+ if (ctx.direction === "backward") {
1071
+ const canary = inst._zod.parse({
1072
+ value: payload.value,
1073
+ issues: []
1074
+ }, {
1075
+ ...ctx,
1076
+ skipChecks: true
1077
+ });
1078
+ if (canary instanceof Promise) return canary.then((canary) => {
1079
+ return handleCanaryResult(canary, payload, ctx);
1080
+ });
1081
+ return handleCanaryResult(canary, payload, ctx);
1082
+ }
1083
+ const result = inst._zod.parse(payload, ctx);
1084
+ if (result instanceof Promise) {
1085
+ if (ctx.async === false) throw new $ZodAsyncError();
1086
+ return result.then((result) => runChecks(result, checks, ctx));
1087
+ }
1088
+ return runChecks(result, checks, ctx);
1089
+ };
1090
+ }
1091
+ defineLazy(inst, "~standard", () => ({
1092
+ validate: (value) => {
1093
+ try {
1094
+ const r = safeParse$1(inst, value);
1095
+ return r.success ? { value: r.data } : { issues: r.error?.issues };
1096
+ } catch (_) {
1097
+ return safeParseAsync$1(inst, value).then((r) => r.success ? { value: r.data } : { issues: r.error?.issues });
1098
+ }
1099
+ },
1100
+ vendor: "zod",
1101
+ version: 1
1102
+ }));
1103
+ });
1104
+ var $ZodString = /*@__PURE__*/ $constructor("$ZodString", (inst, def) => {
1105
+ $ZodType.init(inst, def);
1106
+ inst._zod.pattern = [...inst?._zod.bag?.patterns ?? []].pop() ?? string$1(inst._zod.bag);
1107
+ inst._zod.parse = (payload, _) => {
1108
+ if (def.coerce) try {
1109
+ payload.value = String(payload.value);
1110
+ } catch (_) {}
1111
+ if (typeof payload.value === "string") return payload;
1112
+ payload.issues.push({
1113
+ expected: "string",
1114
+ code: "invalid_type",
1115
+ input: payload.value,
1116
+ inst
1117
+ });
1118
+ return payload;
1119
+ };
1120
+ });
1121
+ var $ZodStringFormat = /*@__PURE__*/ $constructor("$ZodStringFormat", (inst, def) => {
1122
+ $ZodCheckStringFormat.init(inst, def);
1123
+ $ZodString.init(inst, def);
1124
+ });
1125
+ var $ZodGUID = /*@__PURE__*/ $constructor("$ZodGUID", (inst, def) => {
1126
+ def.pattern ?? (def.pattern = guid);
1127
+ $ZodStringFormat.init(inst, def);
1128
+ });
1129
+ var $ZodUUID = /*@__PURE__*/ $constructor("$ZodUUID", (inst, def) => {
1130
+ if (def.version) {
1131
+ const v = {
1132
+ v1: 1,
1133
+ v2: 2,
1134
+ v3: 3,
1135
+ v4: 4,
1136
+ v5: 5,
1137
+ v6: 6,
1138
+ v7: 7,
1139
+ v8: 8
1140
+ }[def.version];
1141
+ if (v === void 0) throw new Error(`Invalid UUID version: "${def.version}"`);
1142
+ def.pattern ?? (def.pattern = uuid(v));
1143
+ } else def.pattern ?? (def.pattern = uuid());
1144
+ $ZodStringFormat.init(inst, def);
1145
+ });
1146
+ var $ZodEmail = /*@__PURE__*/ $constructor("$ZodEmail", (inst, def) => {
1147
+ def.pattern ?? (def.pattern = email);
1148
+ $ZodStringFormat.init(inst, def);
1149
+ });
1150
+ var $ZodURL = /*@__PURE__*/ $constructor("$ZodURL", (inst, def) => {
1151
+ $ZodStringFormat.init(inst, def);
1152
+ inst._zod.check = (payload) => {
1153
+ try {
1154
+ const trimmed = payload.value.trim();
1155
+ if (!def.normalize && def.protocol?.source === httpProtocol.source) {
1156
+ if (!/^https?:\/\//i.test(trimmed)) {
1157
+ payload.issues.push({
1158
+ code: "invalid_format",
1159
+ format: "url",
1160
+ note: "Invalid URL format",
1161
+ input: payload.value,
1162
+ inst,
1163
+ continue: !def.abort
1164
+ });
1165
+ return;
1166
+ }
1167
+ }
1168
+ const url = new URL(trimmed);
1169
+ if (def.hostname) {
1170
+ def.hostname.lastIndex = 0;
1171
+ if (!def.hostname.test(url.hostname)) payload.issues.push({
1172
+ code: "invalid_format",
1173
+ format: "url",
1174
+ note: "Invalid hostname",
1175
+ pattern: def.hostname.source,
1176
+ input: payload.value,
1177
+ inst,
1178
+ continue: !def.abort
1179
+ });
1180
+ }
1181
+ if (def.protocol) {
1182
+ def.protocol.lastIndex = 0;
1183
+ if (!def.protocol.test(url.protocol.endsWith(":") ? url.protocol.slice(0, -1) : url.protocol)) payload.issues.push({
1184
+ code: "invalid_format",
1185
+ format: "url",
1186
+ note: "Invalid protocol",
1187
+ pattern: def.protocol.source,
1188
+ input: payload.value,
1189
+ inst,
1190
+ continue: !def.abort
1191
+ });
1192
+ }
1193
+ if (def.normalize) payload.value = url.href;
1194
+ else payload.value = trimmed;
1195
+ return;
1196
+ } catch (_) {
1197
+ payload.issues.push({
1198
+ code: "invalid_format",
1199
+ format: "url",
1200
+ input: payload.value,
1201
+ inst,
1202
+ continue: !def.abort
1203
+ });
1204
+ }
1205
+ };
1206
+ });
1207
+ var $ZodEmoji = /*@__PURE__*/ $constructor("$ZodEmoji", (inst, def) => {
1208
+ def.pattern ?? (def.pattern = emoji());
1209
+ $ZodStringFormat.init(inst, def);
1210
+ });
1211
+ var $ZodNanoID = /*@__PURE__*/ $constructor("$ZodNanoID", (inst, def) => {
1212
+ def.pattern ?? (def.pattern = nanoid);
1213
+ $ZodStringFormat.init(inst, def);
1214
+ });
1215
+ /**
1216
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
1217
+ * (timestamps embedded in the id). Use {@link $ZodCUID2} instead.
1218
+ * See https://github.com/paralleldrive/cuid.
1219
+ */
1220
+ var $ZodCUID = /*@__PURE__*/ $constructor("$ZodCUID", (inst, def) => {
1221
+ def.pattern ?? (def.pattern = cuid);
1222
+ $ZodStringFormat.init(inst, def);
1223
+ });
1224
+ var $ZodCUID2 = /*@__PURE__*/ $constructor("$ZodCUID2", (inst, def) => {
1225
+ def.pattern ?? (def.pattern = cuid2);
1226
+ $ZodStringFormat.init(inst, def);
1227
+ });
1228
+ var $ZodULID = /*@__PURE__*/ $constructor("$ZodULID", (inst, def) => {
1229
+ def.pattern ?? (def.pattern = ulid);
1230
+ $ZodStringFormat.init(inst, def);
1231
+ });
1232
+ var $ZodXID = /*@__PURE__*/ $constructor("$ZodXID", (inst, def) => {
1233
+ def.pattern ?? (def.pattern = xid);
1234
+ $ZodStringFormat.init(inst, def);
1235
+ });
1236
+ var $ZodKSUID = /*@__PURE__*/ $constructor("$ZodKSUID", (inst, def) => {
1237
+ def.pattern ?? (def.pattern = ksuid);
1238
+ $ZodStringFormat.init(inst, def);
1239
+ });
1240
+ var $ZodISODateTime = /*@__PURE__*/ $constructor("$ZodISODateTime", (inst, def) => {
1241
+ def.pattern ?? (def.pattern = datetime$1(def));
1242
+ $ZodStringFormat.init(inst, def);
1243
+ });
1244
+ var $ZodISODate = /*@__PURE__*/ $constructor("$ZodISODate", (inst, def) => {
1245
+ def.pattern ?? (def.pattern = date$1);
1246
+ $ZodStringFormat.init(inst, def);
1247
+ });
1248
+ var $ZodISOTime = /*@__PURE__*/ $constructor("$ZodISOTime", (inst, def) => {
1249
+ def.pattern ?? (def.pattern = time$1(def));
1250
+ $ZodStringFormat.init(inst, def);
1251
+ });
1252
+ var $ZodISODuration = /*@__PURE__*/ $constructor("$ZodISODuration", (inst, def) => {
1253
+ def.pattern ?? (def.pattern = duration$1);
1254
+ $ZodStringFormat.init(inst, def);
1255
+ });
1256
+ var $ZodIPv4 = /*@__PURE__*/ $constructor("$ZodIPv4", (inst, def) => {
1257
+ def.pattern ?? (def.pattern = ipv4);
1258
+ $ZodStringFormat.init(inst, def);
1259
+ inst._zod.bag.format = `ipv4`;
1260
+ });
1261
+ var $ZodIPv6 = /*@__PURE__*/ $constructor("$ZodIPv6", (inst, def) => {
1262
+ def.pattern ?? (def.pattern = ipv6);
1263
+ $ZodStringFormat.init(inst, def);
1264
+ inst._zod.bag.format = `ipv6`;
1265
+ inst._zod.check = (payload) => {
1266
+ try {
1267
+ new URL(`http://[${payload.value}]`);
1268
+ } catch {
1269
+ payload.issues.push({
1270
+ code: "invalid_format",
1271
+ format: "ipv6",
1272
+ input: payload.value,
1273
+ inst,
1274
+ continue: !def.abort
1275
+ });
1276
+ }
1277
+ };
1278
+ });
1279
+ var $ZodCIDRv4 = /*@__PURE__*/ $constructor("$ZodCIDRv4", (inst, def) => {
1280
+ def.pattern ?? (def.pattern = cidrv4);
1281
+ $ZodStringFormat.init(inst, def);
1282
+ });
1283
+ var $ZodCIDRv6 = /*@__PURE__*/ $constructor("$ZodCIDRv6", (inst, def) => {
1284
+ def.pattern ?? (def.pattern = cidrv6);
1285
+ $ZodStringFormat.init(inst, def);
1286
+ inst._zod.check = (payload) => {
1287
+ const parts = payload.value.split("/");
1288
+ try {
1289
+ if (parts.length !== 2) throw new Error();
1290
+ const [address, prefix] = parts;
1291
+ if (!prefix) throw new Error();
1292
+ const prefixNum = Number(prefix);
1293
+ if (`${prefixNum}` !== prefix) throw new Error();
1294
+ if (prefixNum < 0 || prefixNum > 128) throw new Error();
1295
+ new URL(`http://[${address}]`);
1296
+ } catch {
1297
+ payload.issues.push({
1298
+ code: "invalid_format",
1299
+ format: "cidrv6",
1300
+ input: payload.value,
1301
+ inst,
1302
+ continue: !def.abort
1303
+ });
1304
+ }
1305
+ };
1306
+ });
1307
+ function isValidBase64(data) {
1308
+ if (data === "") return true;
1309
+ if (/\s/.test(data)) return false;
1310
+ if (data.length % 4 !== 0) return false;
1311
+ try {
1312
+ atob(data);
1313
+ return true;
1314
+ } catch {
1315
+ return false;
1316
+ }
1317
+ }
1318
+ var $ZodBase64 = /*@__PURE__*/ $constructor("$ZodBase64", (inst, def) => {
1319
+ def.pattern ?? (def.pattern = base64);
1320
+ $ZodStringFormat.init(inst, def);
1321
+ inst._zod.bag.contentEncoding = "base64";
1322
+ inst._zod.check = (payload) => {
1323
+ if (isValidBase64(payload.value)) return;
1324
+ payload.issues.push({
1325
+ code: "invalid_format",
1326
+ format: "base64",
1327
+ input: payload.value,
1328
+ inst,
1329
+ continue: !def.abort
1330
+ });
1331
+ };
1332
+ });
1333
+ function isValidBase64URL(data) {
1334
+ if (!base64url.test(data)) return false;
1335
+ const base64 = data.replace(/[-_]/g, (c) => c === "-" ? "+" : "/");
1336
+ return isValidBase64(base64.padEnd(Math.ceil(base64.length / 4) * 4, "="));
1337
+ }
1338
+ var $ZodBase64URL = /*@__PURE__*/ $constructor("$ZodBase64URL", (inst, def) => {
1339
+ def.pattern ?? (def.pattern = base64url);
1340
+ $ZodStringFormat.init(inst, def);
1341
+ inst._zod.bag.contentEncoding = "base64url";
1342
+ inst._zod.check = (payload) => {
1343
+ if (isValidBase64URL(payload.value)) return;
1344
+ payload.issues.push({
1345
+ code: "invalid_format",
1346
+ format: "base64url",
1347
+ input: payload.value,
1348
+ inst,
1349
+ continue: !def.abort
1350
+ });
1351
+ };
1352
+ });
1353
+ var $ZodE164 = /*@__PURE__*/ $constructor("$ZodE164", (inst, def) => {
1354
+ def.pattern ?? (def.pattern = e164);
1355
+ $ZodStringFormat.init(inst, def);
1356
+ });
1357
+ function isValidJWT(token, algorithm = null) {
1358
+ try {
1359
+ const tokensParts = token.split(".");
1360
+ if (tokensParts.length !== 3) return false;
1361
+ const [header] = tokensParts;
1362
+ if (!header) return false;
1363
+ const parsedHeader = JSON.parse(atob(header));
1364
+ if ("typ" in parsedHeader && parsedHeader?.typ !== "JWT") return false;
1365
+ if (!parsedHeader.alg) return false;
1366
+ if (algorithm && (!("alg" in parsedHeader) || parsedHeader.alg !== algorithm)) return false;
1367
+ return true;
1368
+ } catch {
1369
+ return false;
1370
+ }
1371
+ }
1372
+ var $ZodJWT = /*@__PURE__*/ $constructor("$ZodJWT", (inst, def) => {
1373
+ $ZodStringFormat.init(inst, def);
1374
+ inst._zod.check = (payload) => {
1375
+ if (isValidJWT(payload.value, def.alg)) return;
1376
+ payload.issues.push({
1377
+ code: "invalid_format",
1378
+ format: "jwt",
1379
+ input: payload.value,
1380
+ inst,
1381
+ continue: !def.abort
1382
+ });
1383
+ };
1384
+ });
1385
+ var $ZodNumber = /*@__PURE__*/ $constructor("$ZodNumber", (inst, def) => {
1386
+ $ZodType.init(inst, def);
1387
+ inst._zod.pattern = inst._zod.bag.pattern ?? number$1;
1388
+ inst._zod.parse = (payload, _ctx) => {
1389
+ if (def.coerce) try {
1390
+ payload.value = Number(payload.value);
1391
+ } catch (_) {}
1392
+ const input = payload.value;
1393
+ if (typeof input === "number" && !Number.isNaN(input) && Number.isFinite(input)) return payload;
1394
+ const received = typeof input === "number" ? Number.isNaN(input) ? "NaN" : !Number.isFinite(input) ? "Infinity" : void 0 : void 0;
1395
+ payload.issues.push({
1396
+ expected: "number",
1397
+ code: "invalid_type",
1398
+ input,
1399
+ inst,
1400
+ ...received ? { received } : {}
1401
+ });
1402
+ return payload;
1403
+ };
1404
+ });
1405
+ var $ZodNumberFormat = /*@__PURE__*/ $constructor("$ZodNumberFormat", (inst, def) => {
1406
+ $ZodCheckNumberFormat.init(inst, def);
1407
+ $ZodNumber.init(inst, def);
1408
+ });
1409
+ var $ZodUnknown = /*@__PURE__*/ $constructor("$ZodUnknown", (inst, def) => {
1410
+ $ZodType.init(inst, def);
1411
+ inst._zod.parse = (payload) => payload;
1412
+ });
1413
+ var $ZodNever = /*@__PURE__*/ $constructor("$ZodNever", (inst, def) => {
1414
+ $ZodType.init(inst, def);
1415
+ inst._zod.parse = (payload, _ctx) => {
1416
+ payload.issues.push({
1417
+ expected: "never",
1418
+ code: "invalid_type",
1419
+ input: payload.value,
1420
+ inst
1421
+ });
1422
+ return payload;
1423
+ };
1424
+ });
1425
+ function handleArrayResult(result, final, index) {
1426
+ if (result.issues.length) final.issues.push(...prefixIssues(index, result.issues));
1427
+ final.value[index] = result.value;
1428
+ }
1429
+ var $ZodArray = /*@__PURE__*/ $constructor("$ZodArray", (inst, def) => {
1430
+ $ZodType.init(inst, def);
1431
+ inst._zod.parse = (payload, ctx) => {
1432
+ const input = payload.value;
1433
+ if (!Array.isArray(input)) {
1434
+ payload.issues.push({
1435
+ expected: "array",
1436
+ code: "invalid_type",
1437
+ input,
1438
+ inst
1439
+ });
1440
+ return payload;
1441
+ }
1442
+ payload.value = Array(input.length);
1443
+ const proms = [];
1444
+ for (let i = 0; i < input.length; i++) {
1445
+ const item = input[i];
1446
+ const result = def.element._zod.run({
1447
+ value: item,
1448
+ issues: []
1449
+ }, ctx);
1450
+ if (result instanceof Promise) proms.push(result.then((result) => handleArrayResult(result, payload, i)));
1451
+ else handleArrayResult(result, payload, i);
1452
+ }
1453
+ if (proms.length) return Promise.all(proms).then(() => payload);
1454
+ return payload;
1455
+ };
1456
+ });
1457
+ function handlePropertyResult(result, final, key, input, isOptionalIn, isOptionalOut) {
1458
+ const isPresent = key in input;
1459
+ if (result.issues.length) {
1460
+ if (isOptionalIn && isOptionalOut && !isPresent) return;
1461
+ final.issues.push(...prefixIssues(key, result.issues));
1462
+ }
1463
+ if (!isPresent && !isOptionalIn) {
1464
+ if (!result.issues.length) final.issues.push({
1465
+ code: "invalid_type",
1466
+ expected: "nonoptional",
1467
+ input: void 0,
1468
+ path: [key]
1469
+ });
1470
+ return;
1471
+ }
1472
+ if (result.value === void 0) {
1473
+ if (isPresent) final.value[key] = void 0;
1474
+ } else final.value[key] = result.value;
1475
+ }
1476
+ function normalizeDef(def) {
1477
+ const keys = Object.keys(def.shape);
1478
+ for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
1479
+ const okeys = optionalKeys(def.shape);
1480
+ return {
1481
+ ...def,
1482
+ keys,
1483
+ keySet: new Set(keys),
1484
+ numKeys: keys.length,
1485
+ optionalKeys: new Set(okeys)
1486
+ };
1487
+ }
1488
+ function handleCatchall(proms, input, payload, ctx, def, inst) {
1489
+ const unrecognized = [];
1490
+ const keySet = def.keySet;
1491
+ const _catchall = def.catchall._zod;
1492
+ const t = _catchall.def.type;
1493
+ const isOptionalIn = _catchall.optin === "optional";
1494
+ const isOptionalOut = _catchall.optout === "optional";
1495
+ for (const key in input) {
1496
+ if (key === "__proto__") continue;
1497
+ if (keySet.has(key)) continue;
1498
+ if (t === "never") {
1499
+ unrecognized.push(key);
1500
+ continue;
1501
+ }
1502
+ const r = _catchall.run({
1503
+ value: input[key],
1504
+ issues: []
1505
+ }, ctx);
1506
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1507
+ else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1508
+ }
1509
+ if (unrecognized.length) payload.issues.push({
1510
+ code: "unrecognized_keys",
1511
+ keys: unrecognized,
1512
+ input,
1513
+ inst
1514
+ });
1515
+ if (!proms.length) return payload;
1516
+ return Promise.all(proms).then(() => {
1517
+ return payload;
1518
+ });
1519
+ }
1520
+ var $ZodObject = /*@__PURE__*/ $constructor("$ZodObject", (inst, def) => {
1521
+ $ZodType.init(inst, def);
1522
+ if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
1523
+ const sh = def.shape;
1524
+ Object.defineProperty(def, "shape", { get: () => {
1525
+ const newSh = { ...sh };
1526
+ Object.defineProperty(def, "shape", { value: newSh });
1527
+ return newSh;
1528
+ } });
1529
+ }
1530
+ const _normalized = cached(() => normalizeDef(def));
1531
+ defineLazy(inst._zod, "propValues", () => {
1532
+ const shape = def.shape;
1533
+ const propValues = {};
1534
+ for (const key in shape) {
1535
+ const field = shape[key]._zod;
1536
+ if (field.values) {
1537
+ propValues[key] ?? (propValues[key] = /* @__PURE__ */ new Set());
1538
+ for (const v of field.values) propValues[key].add(v);
1539
+ }
1540
+ }
1541
+ return propValues;
1542
+ });
1543
+ const isObject$2 = isObject;
1544
+ const catchall = def.catchall;
1545
+ let value;
1546
+ inst._zod.parse = (payload, ctx) => {
1547
+ value ?? (value = _normalized.value);
1548
+ const input = payload.value;
1549
+ if (!isObject$2(input)) {
1550
+ payload.issues.push({
1551
+ expected: "object",
1552
+ code: "invalid_type",
1553
+ input,
1554
+ inst
1555
+ });
1556
+ return payload;
1557
+ }
1558
+ payload.value = {};
1559
+ const proms = [];
1560
+ const shape = value.shape;
1561
+ for (const key of value.keys) {
1562
+ const el = shape[key];
1563
+ const isOptionalIn = el._zod.optin === "optional";
1564
+ const isOptionalOut = el._zod.optout === "optional";
1565
+ const r = el._zod.run({
1566
+ value: input[key],
1567
+ issues: []
1568
+ }, ctx);
1569
+ if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut)));
1570
+ else handlePropertyResult(r, payload, key, input, isOptionalIn, isOptionalOut);
1571
+ }
1572
+ if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
1573
+ return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
1574
+ };
1575
+ });
1576
+ var $ZodObjectJIT = /*@__PURE__*/ $constructor("$ZodObjectJIT", (inst, def) => {
1577
+ $ZodObject.init(inst, def);
1578
+ const superParse = inst._zod.parse;
1579
+ const _normalized = cached(() => normalizeDef(def));
1580
+ const generateFastpass = (shape) => {
1581
+ const doc = new Doc([
1582
+ "shape",
1583
+ "payload",
1584
+ "ctx"
1585
+ ]);
1586
+ const normalized = _normalized.value;
1587
+ const parseStr = (key) => {
1588
+ const k = esc(key);
1589
+ return `shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`;
1590
+ };
1591
+ doc.write(`const input = payload.value;`);
1592
+ const ids = Object.create(null);
1593
+ let counter = 0;
1594
+ for (const key of normalized.keys) ids[key] = `key_${counter++}`;
1595
+ doc.write(`const newResult = {};`);
1596
+ for (const key of normalized.keys) {
1597
+ const id = ids[key];
1598
+ const k = esc(key);
1599
+ const schema = shape[key];
1600
+ const isOptionalIn = schema?._zod?.optin === "optional";
1601
+ const isOptionalOut = schema?._zod?.optout === "optional";
1602
+ doc.write(`const ${id} = ${parseStr(key)};`);
1603
+ if (isOptionalIn && isOptionalOut) doc.write(`
1604
+ if (${id}.issues.length) {
1605
+ if (${k} in input) {
1606
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1607
+ ...iss,
1608
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1609
+ })));
1610
+ }
1611
+ }
1612
+
1613
+ if (${id}.value === undefined) {
1614
+ if (${k} in input) {
1615
+ newResult[${k}] = undefined;
1616
+ }
1617
+ } else {
1618
+ newResult[${k}] = ${id}.value;
1619
+ }
1620
+
1621
+ `);
1622
+ else if (!isOptionalIn) doc.write(`
1623
+ const ${id}_present = ${k} in input;
1624
+ if (${id}.issues.length) {
1625
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1626
+ ...iss,
1627
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1628
+ })));
1629
+ }
1630
+ if (!${id}_present && !${id}.issues.length) {
1631
+ payload.issues.push({
1632
+ code: "invalid_type",
1633
+ expected: "nonoptional",
1634
+ input: undefined,
1635
+ path: [${k}]
1636
+ });
1637
+ }
1638
+
1639
+ if (${id}_present) {
1640
+ if (${id}.value === undefined) {
1641
+ newResult[${k}] = undefined;
1642
+ } else {
1643
+ newResult[${k}] = ${id}.value;
1644
+ }
1645
+ }
1646
+
1647
+ `);
1648
+ else doc.write(`
1649
+ if (${id}.issues.length) {
1650
+ payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
1651
+ ...iss,
1652
+ path: iss.path ? [${k}, ...iss.path] : [${k}]
1653
+ })));
1654
+ }
1655
+
1656
+ if (${id}.value === undefined) {
1657
+ if (${k} in input) {
1658
+ newResult[${k}] = undefined;
1659
+ }
1660
+ } else {
1661
+ newResult[${k}] = ${id}.value;
1662
+ }
1663
+
1664
+ `);
1665
+ }
1666
+ doc.write(`payload.value = newResult;`);
1667
+ doc.write(`return payload;`);
1668
+ const fn = doc.compile();
1669
+ return (payload, ctx) => fn(shape, payload, ctx);
1670
+ };
1671
+ let fastpass;
1672
+ const isObject$1 = isObject;
1673
+ const jit = !globalConfig.jitless;
1674
+ const fastEnabled = jit && allowsEval.value;
1675
+ const catchall = def.catchall;
1676
+ let value;
1677
+ inst._zod.parse = (payload, ctx) => {
1678
+ value ?? (value = _normalized.value);
1679
+ const input = payload.value;
1680
+ if (!isObject$1(input)) {
1681
+ payload.issues.push({
1682
+ expected: "object",
1683
+ code: "invalid_type",
1684
+ input,
1685
+ inst
1686
+ });
1687
+ return payload;
1688
+ }
1689
+ if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
1690
+ if (!fastpass) fastpass = generateFastpass(def.shape);
1691
+ payload = fastpass(payload, ctx);
1692
+ if (!catchall) return payload;
1693
+ return handleCatchall([], input, payload, ctx, value, inst);
1694
+ }
1695
+ return superParse(payload, ctx);
1696
+ };
1697
+ });
1698
+ function handleUnionResults(results, final, inst, ctx) {
1699
+ for (const result of results) if (result.issues.length === 0) {
1700
+ final.value = result.value;
1701
+ return final;
1702
+ }
1703
+ const nonaborted = results.filter((r) => !aborted(r));
1704
+ if (nonaborted.length === 1) {
1705
+ final.value = nonaborted[0].value;
1706
+ return nonaborted[0];
1707
+ }
1708
+ final.issues.push({
1709
+ code: "invalid_union",
1710
+ input: final.value,
1711
+ inst,
1712
+ errors: results.map((result) => result.issues.map((iss) => finalizeIssue(iss, ctx, config())))
1713
+ });
1714
+ return final;
1715
+ }
1716
+ var $ZodUnion = /*@__PURE__*/ $constructor("$ZodUnion", (inst, def) => {
1717
+ $ZodType.init(inst, def);
1718
+ defineLazy(inst._zod, "optin", () => def.options.some((o) => o._zod.optin === "optional") ? "optional" : void 0);
1719
+ defineLazy(inst._zod, "optout", () => def.options.some((o) => o._zod.optout === "optional") ? "optional" : void 0);
1720
+ defineLazy(inst._zod, "values", () => {
1721
+ if (def.options.every((o) => o._zod.values)) return new Set(def.options.flatMap((option) => Array.from(option._zod.values)));
1722
+ });
1723
+ defineLazy(inst._zod, "pattern", () => {
1724
+ if (def.options.every((o) => o._zod.pattern)) {
1725
+ const patterns = def.options.map((o) => o._zod.pattern);
1726
+ return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
1727
+ }
1728
+ });
1729
+ const first = def.options.length === 1 ? def.options[0]._zod.run : null;
1730
+ inst._zod.parse = (payload, ctx) => {
1731
+ if (first) return first(payload, ctx);
1732
+ let async = false;
1733
+ const results = [];
1734
+ for (const option of def.options) {
1735
+ const result = option._zod.run({
1736
+ value: payload.value,
1737
+ issues: []
1738
+ }, ctx);
1739
+ if (result instanceof Promise) {
1740
+ results.push(result);
1741
+ async = true;
1742
+ } else {
1743
+ if (result.issues.length === 0) return result;
1744
+ results.push(result);
1745
+ }
1746
+ }
1747
+ if (!async) return handleUnionResults(results, payload, inst, ctx);
1748
+ return Promise.all(results).then((results) => {
1749
+ return handleUnionResults(results, payload, inst, ctx);
1750
+ });
1751
+ };
1752
+ });
1753
+ var $ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
1754
+ def.inclusive = false;
1755
+ $ZodUnion.init(inst, def);
1756
+ const _super = inst._zod.parse;
1757
+ defineLazy(inst._zod, "propValues", () => {
1758
+ const propValues = {};
1759
+ for (const option of def.options) {
1760
+ const pv = option._zod.propValues;
1761
+ if (!pv || Object.keys(pv).length === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(option)}"`);
1762
+ for (const [k, v] of Object.entries(pv)) {
1763
+ if (!propValues[k]) propValues[k] = /* @__PURE__ */ new Set();
1764
+ for (const val of v) propValues[k].add(val);
1765
+ }
1766
+ }
1767
+ return propValues;
1768
+ });
1769
+ const disc = cached(() => {
1770
+ const opts = def.options;
1771
+ const map = /* @__PURE__ */ new Map();
1772
+ for (const o of opts) {
1773
+ const values = o._zod.propValues?.[def.discriminator];
1774
+ if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
1775
+ for (const v of values) {
1776
+ if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
1777
+ map.set(v, o);
1778
+ }
1779
+ }
1780
+ return map;
1781
+ });
1782
+ inst._zod.parse = (payload, ctx) => {
1783
+ const input = payload.value;
1784
+ if (!isObject(input)) {
1785
+ payload.issues.push({
1786
+ code: "invalid_type",
1787
+ expected: "object",
1788
+ input,
1789
+ inst
1790
+ });
1791
+ return payload;
1792
+ }
1793
+ const opt = disc.value.get(input?.[def.discriminator]);
1794
+ if (opt) return opt._zod.run(payload, ctx);
1795
+ if (def.unionFallback || ctx.direction === "backward") return _super(payload, ctx);
1796
+ payload.issues.push({
1797
+ code: "invalid_union",
1798
+ errors: [],
1799
+ note: "No matching discriminator",
1800
+ discriminator: def.discriminator,
1801
+ options: Array.from(disc.value.keys()),
1802
+ input,
1803
+ path: [def.discriminator],
1804
+ inst
1805
+ });
1806
+ return payload;
1807
+ };
1808
+ });
1809
+ var $ZodIntersection = /*@__PURE__*/ $constructor("$ZodIntersection", (inst, def) => {
1810
+ $ZodType.init(inst, def);
1811
+ inst._zod.parse = (payload, ctx) => {
1812
+ const input = payload.value;
1813
+ const left = def.left._zod.run({
1814
+ value: input,
1815
+ issues: []
1816
+ }, ctx);
1817
+ const right = def.right._zod.run({
1818
+ value: input,
1819
+ issues: []
1820
+ }, ctx);
1821
+ if (left instanceof Promise || right instanceof Promise) return Promise.all([left, right]).then(([left, right]) => {
1822
+ return handleIntersectionResults(payload, left, right);
1823
+ });
1824
+ return handleIntersectionResults(payload, left, right);
1825
+ };
1826
+ });
1827
+ function mergeValues(a, b) {
1828
+ if (a === b) return {
1829
+ valid: true,
1830
+ data: a
1831
+ };
1832
+ if (a instanceof Date && b instanceof Date && +a === +b) return {
1833
+ valid: true,
1834
+ data: a
1835
+ };
1836
+ if (isPlainObject(a) && isPlainObject(b)) {
1837
+ const bKeys = Object.keys(b);
1838
+ const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
1839
+ const newObj = {
1840
+ ...a,
1841
+ ...b
1842
+ };
1843
+ for (const key of sharedKeys) {
1844
+ const sharedValue = mergeValues(a[key], b[key]);
1845
+ if (!sharedValue.valid) return {
1846
+ valid: false,
1847
+ mergeErrorPath: [key, ...sharedValue.mergeErrorPath]
1848
+ };
1849
+ newObj[key] = sharedValue.data;
1850
+ }
1851
+ return {
1852
+ valid: true,
1853
+ data: newObj
1854
+ };
1855
+ }
1856
+ if (Array.isArray(a) && Array.isArray(b)) {
1857
+ if (a.length !== b.length) return {
1858
+ valid: false,
1859
+ mergeErrorPath: []
1860
+ };
1861
+ const newArray = [];
1862
+ for (let index = 0; index < a.length; index++) {
1863
+ const itemA = a[index];
1864
+ const itemB = b[index];
1865
+ const sharedValue = mergeValues(itemA, itemB);
1866
+ if (!sharedValue.valid) return {
1867
+ valid: false,
1868
+ mergeErrorPath: [index, ...sharedValue.mergeErrorPath]
1869
+ };
1870
+ newArray.push(sharedValue.data);
1871
+ }
1872
+ return {
1873
+ valid: true,
1874
+ data: newArray
1875
+ };
1876
+ }
1877
+ return {
1878
+ valid: false,
1879
+ mergeErrorPath: []
1880
+ };
1881
+ }
1882
+ function handleIntersectionResults(result, left, right) {
1883
+ const unrecKeys = /* @__PURE__ */ new Map();
1884
+ let unrecIssue;
1885
+ for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
1886
+ unrecIssue ?? (unrecIssue = iss);
1887
+ for (const k of iss.keys) {
1888
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1889
+ unrecKeys.get(k).l = true;
1890
+ }
1891
+ } else result.issues.push(iss);
1892
+ for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
1893
+ if (!unrecKeys.has(k)) unrecKeys.set(k, {});
1894
+ unrecKeys.get(k).r = true;
1895
+ }
1896
+ else result.issues.push(iss);
1897
+ const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
1898
+ if (bothKeys.length && unrecIssue) result.issues.push({
1899
+ ...unrecIssue,
1900
+ keys: bothKeys
1901
+ });
1902
+ if (aborted(result)) return result;
1903
+ const merged = mergeValues(left.value, right.value);
1904
+ if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
1905
+ result.value = merged.data;
1906
+ return result;
1907
+ }
1908
+ var $ZodEnum = /*@__PURE__*/ $constructor("$ZodEnum", (inst, def) => {
1909
+ $ZodType.init(inst, def);
1910
+ const values = getEnumValues(def.entries);
1911
+ const valuesSet = new Set(values);
1912
+ inst._zod.values = valuesSet;
1913
+ inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
1914
+ inst._zod.parse = (payload, _ctx) => {
1915
+ const input = payload.value;
1916
+ if (valuesSet.has(input)) return payload;
1917
+ payload.issues.push({
1918
+ code: "invalid_value",
1919
+ values,
1920
+ input,
1921
+ inst
1922
+ });
1923
+ return payload;
1924
+ };
1925
+ });
1926
+ var $ZodLiteral = /*@__PURE__*/ $constructor("$ZodLiteral", (inst, def) => {
1927
+ $ZodType.init(inst, def);
1928
+ if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
1929
+ const values = new Set(def.values);
1930
+ inst._zod.values = values;
1931
+ inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
1932
+ inst._zod.parse = (payload, _ctx) => {
1933
+ const input = payload.value;
1934
+ if (values.has(input)) return payload;
1935
+ payload.issues.push({
1936
+ code: "invalid_value",
1937
+ values: def.values,
1938
+ input,
1939
+ inst
1940
+ });
1941
+ return payload;
1942
+ };
1943
+ });
1944
+ var $ZodTransform = /*@__PURE__*/ $constructor("$ZodTransform", (inst, def) => {
1945
+ $ZodType.init(inst, def);
1946
+ inst._zod.optin = "optional";
1947
+ inst._zod.parse = (payload, ctx) => {
1948
+ if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
1949
+ const _out = def.transform(payload.value, payload);
1950
+ if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
1951
+ payload.value = output;
1952
+ payload.fallback = true;
1953
+ return payload;
1954
+ });
1955
+ if (_out instanceof Promise) throw new $ZodAsyncError();
1956
+ payload.value = _out;
1957
+ payload.fallback = true;
1958
+ return payload;
1959
+ };
1960
+ });
1961
+ function handleOptionalResult(result, input) {
1962
+ if (input === void 0 && (result.issues.length || result.fallback)) return {
1963
+ issues: [],
1964
+ value: void 0
1965
+ };
1966
+ return result;
1967
+ }
1968
+ var $ZodOptional = /*@__PURE__*/ $constructor("$ZodOptional", (inst, def) => {
1969
+ $ZodType.init(inst, def);
1970
+ inst._zod.optin = "optional";
1971
+ inst._zod.optout = "optional";
1972
+ defineLazy(inst._zod, "values", () => {
1973
+ return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, void 0]) : void 0;
1974
+ });
1975
+ defineLazy(inst._zod, "pattern", () => {
1976
+ const pattern = def.innerType._zod.pattern;
1977
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
1978
+ });
1979
+ inst._zod.parse = (payload, ctx) => {
1980
+ if (def.innerType._zod.optin === "optional") {
1981
+ const input = payload.value;
1982
+ const result = def.innerType._zod.run(payload, ctx);
1983
+ if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, input));
1984
+ return handleOptionalResult(result, input);
1985
+ }
1986
+ if (payload.value === void 0) return payload;
1987
+ return def.innerType._zod.run(payload, ctx);
1988
+ };
1989
+ });
1990
+ var $ZodExactOptional = /*@__PURE__*/ $constructor("$ZodExactOptional", (inst, def) => {
1991
+ $ZodOptional.init(inst, def);
1992
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
1993
+ defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
1994
+ inst._zod.parse = (payload, ctx) => {
1995
+ return def.innerType._zod.run(payload, ctx);
1996
+ };
1997
+ });
1998
+ var $ZodNullable = /*@__PURE__*/ $constructor("$ZodNullable", (inst, def) => {
1999
+ $ZodType.init(inst, def);
2000
+ defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
2001
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2002
+ defineLazy(inst._zod, "pattern", () => {
2003
+ const pattern = def.innerType._zod.pattern;
2004
+ return pattern ? new RegExp(`^(${cleanRegex(pattern.source)}|null)$`) : void 0;
2005
+ });
2006
+ defineLazy(inst._zod, "values", () => {
2007
+ return def.innerType._zod.values ? /* @__PURE__ */ new Set([...def.innerType._zod.values, null]) : void 0;
2008
+ });
2009
+ inst._zod.parse = (payload, ctx) => {
2010
+ if (payload.value === null) return payload;
2011
+ return def.innerType._zod.run(payload, ctx);
2012
+ };
2013
+ });
2014
+ var $ZodDefault = /*@__PURE__*/ $constructor("$ZodDefault", (inst, def) => {
2015
+ $ZodType.init(inst, def);
2016
+ inst._zod.optin = "optional";
2017
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2018
+ inst._zod.parse = (payload, ctx) => {
2019
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2020
+ if (payload.value === void 0) {
2021
+ payload.value = def.defaultValue;
2022
+ /**
2023
+ * $ZodDefault returns the default value immediately in forward direction.
2024
+ * It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
2025
+ return payload;
2026
+ }
2027
+ const result = def.innerType._zod.run(payload, ctx);
2028
+ if (result instanceof Promise) return result.then((result) => handleDefaultResult(result, def));
2029
+ return handleDefaultResult(result, def);
2030
+ };
2031
+ });
2032
+ function handleDefaultResult(payload, def) {
2033
+ if (payload.value === void 0) payload.value = def.defaultValue;
2034
+ return payload;
2035
+ }
2036
+ var $ZodPrefault = /*@__PURE__*/ $constructor("$ZodPrefault", (inst, def) => {
2037
+ $ZodType.init(inst, def);
2038
+ inst._zod.optin = "optional";
2039
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2040
+ inst._zod.parse = (payload, ctx) => {
2041
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2042
+ if (payload.value === void 0) payload.value = def.defaultValue;
2043
+ return def.innerType._zod.run(payload, ctx);
2044
+ };
2045
+ });
2046
+ var $ZodNonOptional = /*@__PURE__*/ $constructor("$ZodNonOptional", (inst, def) => {
2047
+ $ZodType.init(inst, def);
2048
+ defineLazy(inst._zod, "values", () => {
2049
+ const v = def.innerType._zod.values;
2050
+ return v ? new Set([...v].filter((x) => x !== void 0)) : void 0;
2051
+ });
2052
+ inst._zod.parse = (payload, ctx) => {
2053
+ const result = def.innerType._zod.run(payload, ctx);
2054
+ if (result instanceof Promise) return result.then((result) => handleNonOptionalResult(result, inst));
2055
+ return handleNonOptionalResult(result, inst);
2056
+ };
2057
+ });
2058
+ function handleNonOptionalResult(payload, inst) {
2059
+ if (!payload.issues.length && payload.value === void 0) payload.issues.push({
2060
+ code: "invalid_type",
2061
+ expected: "nonoptional",
2062
+ input: payload.value,
2063
+ inst
2064
+ });
2065
+ return payload;
2066
+ }
2067
+ var $ZodCatch = /*@__PURE__*/ $constructor("$ZodCatch", (inst, def) => {
2068
+ $ZodType.init(inst, def);
2069
+ inst._zod.optin = "optional";
2070
+ defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
2071
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2072
+ inst._zod.parse = (payload, ctx) => {
2073
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2074
+ const result = def.innerType._zod.run(payload, ctx);
2075
+ if (result instanceof Promise) return result.then((result) => {
2076
+ payload.value = result.value;
2077
+ if (result.issues.length) {
2078
+ payload.value = def.catchValue({
2079
+ ...payload,
2080
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2081
+ input: payload.value
2082
+ });
2083
+ payload.issues = [];
2084
+ payload.fallback = true;
2085
+ }
2086
+ return payload;
2087
+ });
2088
+ payload.value = result.value;
2089
+ if (result.issues.length) {
2090
+ payload.value = def.catchValue({
2091
+ ...payload,
2092
+ error: { issues: result.issues.map((iss) => finalizeIssue(iss, ctx, config())) },
2093
+ input: payload.value
2094
+ });
2095
+ payload.issues = [];
2096
+ payload.fallback = true;
2097
+ }
2098
+ return payload;
2099
+ };
2100
+ });
2101
+ var $ZodPipe = /*@__PURE__*/ $constructor("$ZodPipe", (inst, def) => {
2102
+ $ZodType.init(inst, def);
2103
+ defineLazy(inst._zod, "values", () => def.in._zod.values);
2104
+ defineLazy(inst._zod, "optin", () => def.in._zod.optin);
2105
+ defineLazy(inst._zod, "optout", () => def.out._zod.optout);
2106
+ defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
2107
+ inst._zod.parse = (payload, ctx) => {
2108
+ if (ctx.direction === "backward") {
2109
+ const right = def.out._zod.run(payload, ctx);
2110
+ if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
2111
+ return handlePipeResult(right, def.in, ctx);
2112
+ }
2113
+ const left = def.in._zod.run(payload, ctx);
2114
+ if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
2115
+ return handlePipeResult(left, def.out, ctx);
2116
+ };
2117
+ });
2118
+ function handlePipeResult(left, next, ctx) {
2119
+ if (left.issues.length) {
2120
+ left.aborted = true;
2121
+ return left;
2122
+ }
2123
+ return next._zod.run({
2124
+ value: left.value,
2125
+ issues: left.issues,
2126
+ fallback: left.fallback
2127
+ }, ctx);
2128
+ }
2129
+ var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2130
+ $ZodType.init(inst, def);
2131
+ defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
2132
+ defineLazy(inst._zod, "values", () => def.innerType._zod.values);
2133
+ defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
2134
+ defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
2135
+ inst._zod.parse = (payload, ctx) => {
2136
+ if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
2137
+ const result = def.innerType._zod.run(payload, ctx);
2138
+ if (result instanceof Promise) return result.then(handleReadonlyResult);
2139
+ return handleReadonlyResult(result);
2140
+ };
2141
+ });
2142
+ function handleReadonlyResult(payload) {
2143
+ payload.value = Object.freeze(payload.value);
2144
+ return payload;
2145
+ }
2146
+ var $ZodCustom = /*@__PURE__*/ $constructor("$ZodCustom", (inst, def) => {
2147
+ $ZodCheck.init(inst, def);
2148
+ $ZodType.init(inst, def);
2149
+ inst._zod.parse = (payload, _) => {
2150
+ return payload;
2151
+ };
2152
+ inst._zod.check = (payload) => {
2153
+ const input = payload.value;
2154
+ const r = def.fn(input);
2155
+ if (r instanceof Promise) return r.then((r) => handleRefineResult(r, payload, input, inst));
2156
+ handleRefineResult(r, payload, input, inst);
2157
+ };
2158
+ });
2159
+ function handleRefineResult(result, payload, input, inst) {
2160
+ if (!result) {
2161
+ const _iss = {
2162
+ code: "custom",
2163
+ input,
2164
+ inst,
2165
+ path: [...inst._zod.def.path ?? []],
2166
+ continue: !inst._zod.def.abort
2167
+ };
2168
+ if (inst._zod.def.params) _iss.params = inst._zod.def.params;
2169
+ payload.issues.push(issue(_iss));
2170
+ }
2171
+ }
2172
+ //#endregion
2173
+ //#region ../../../node_modules/zod/v4/core/registries.js
2174
+ var _a;
2175
+ var $ZodRegistry = class {
2176
+ constructor() {
2177
+ this._map = /* @__PURE__ */ new WeakMap();
2178
+ this._idmap = /* @__PURE__ */ new Map();
2179
+ }
2180
+ add(schema, ..._meta) {
2181
+ const meta = _meta[0];
2182
+ this._map.set(schema, meta);
2183
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
2184
+ return this;
2185
+ }
2186
+ clear() {
2187
+ this._map = /* @__PURE__ */ new WeakMap();
2188
+ this._idmap = /* @__PURE__ */ new Map();
2189
+ return this;
2190
+ }
2191
+ remove(schema) {
2192
+ const meta = this._map.get(schema);
2193
+ if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
2194
+ this._map.delete(schema);
2195
+ return this;
2196
+ }
2197
+ get(schema) {
2198
+ const p = schema._zod.parent;
2199
+ if (p) {
2200
+ const pm = { ...this.get(p) ?? {} };
2201
+ delete pm.id;
2202
+ const f = {
2203
+ ...pm,
2204
+ ...this._map.get(schema)
2205
+ };
2206
+ return Object.keys(f).length ? f : void 0;
2207
+ }
2208
+ return this._map.get(schema);
2209
+ }
2210
+ has(schema) {
2211
+ return this._map.has(schema);
2212
+ }
2213
+ };
2214
+ function registry() {
2215
+ return new $ZodRegistry();
2216
+ }
2217
+ (_a = globalThis).__zod_globalRegistry ?? (_a.__zod_globalRegistry = registry());
2218
+ var globalRegistry = globalThis.__zod_globalRegistry;
2219
+ //#endregion
2220
+ //#region ../../../node_modules/zod/v4/core/api.js
2221
+ // @__NO_SIDE_EFFECTS__
2222
+ function _string(Class, params) {
2223
+ return new Class({
2224
+ type: "string",
2225
+ ...normalizeParams(params)
2226
+ });
2227
+ }
2228
+ // @__NO_SIDE_EFFECTS__
2229
+ function _email(Class, params) {
2230
+ return new Class({
2231
+ type: "string",
2232
+ format: "email",
2233
+ check: "string_format",
2234
+ abort: false,
2235
+ ...normalizeParams(params)
2236
+ });
2237
+ }
2238
+ // @__NO_SIDE_EFFECTS__
2239
+ function _guid(Class, params) {
2240
+ return new Class({
2241
+ type: "string",
2242
+ format: "guid",
2243
+ check: "string_format",
2244
+ abort: false,
2245
+ ...normalizeParams(params)
2246
+ });
2247
+ }
2248
+ // @__NO_SIDE_EFFECTS__
2249
+ function _uuid(Class, params) {
2250
+ return new Class({
2251
+ type: "string",
2252
+ format: "uuid",
2253
+ check: "string_format",
2254
+ abort: false,
2255
+ ...normalizeParams(params)
2256
+ });
2257
+ }
2258
+ // @__NO_SIDE_EFFECTS__
2259
+ function _uuidv4(Class, params) {
2260
+ return new Class({
2261
+ type: "string",
2262
+ format: "uuid",
2263
+ check: "string_format",
2264
+ abort: false,
2265
+ version: "v4",
2266
+ ...normalizeParams(params)
2267
+ });
2268
+ }
2269
+ // @__NO_SIDE_EFFECTS__
2270
+ function _uuidv6(Class, params) {
2271
+ return new Class({
2272
+ type: "string",
2273
+ format: "uuid",
2274
+ check: "string_format",
2275
+ abort: false,
2276
+ version: "v6",
2277
+ ...normalizeParams(params)
2278
+ });
2279
+ }
2280
+ // @__NO_SIDE_EFFECTS__
2281
+ function _uuidv7(Class, params) {
2282
+ return new Class({
2283
+ type: "string",
2284
+ format: "uuid",
2285
+ check: "string_format",
2286
+ abort: false,
2287
+ version: "v7",
2288
+ ...normalizeParams(params)
2289
+ });
2290
+ }
2291
+ // @__NO_SIDE_EFFECTS__
2292
+ function _url(Class, params) {
2293
+ return new Class({
2294
+ type: "string",
2295
+ format: "url",
2296
+ check: "string_format",
2297
+ abort: false,
2298
+ ...normalizeParams(params)
2299
+ });
2300
+ }
2301
+ // @__NO_SIDE_EFFECTS__
2302
+ function _emoji(Class, params) {
2303
+ return new Class({
2304
+ type: "string",
2305
+ format: "emoji",
2306
+ check: "string_format",
2307
+ abort: false,
2308
+ ...normalizeParams(params)
2309
+ });
2310
+ }
2311
+ // @__NO_SIDE_EFFECTS__
2312
+ function _nanoid(Class, params) {
2313
+ return new Class({
2314
+ type: "string",
2315
+ format: "nanoid",
2316
+ check: "string_format",
2317
+ abort: false,
2318
+ ...normalizeParams(params)
2319
+ });
2320
+ }
2321
+ /**
2322
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
2323
+ * (timestamps embedded in the id). Use {@link _cuid2} instead.
2324
+ * See https://github.com/paralleldrive/cuid.
2325
+ */
2326
+ // @__NO_SIDE_EFFECTS__
2327
+ function _cuid(Class, params) {
2328
+ return new Class({
2329
+ type: "string",
2330
+ format: "cuid",
2331
+ check: "string_format",
2332
+ abort: false,
2333
+ ...normalizeParams(params)
2334
+ });
2335
+ }
2336
+ // @__NO_SIDE_EFFECTS__
2337
+ function _cuid2(Class, params) {
2338
+ return new Class({
2339
+ type: "string",
2340
+ format: "cuid2",
2341
+ check: "string_format",
2342
+ abort: false,
2343
+ ...normalizeParams(params)
2344
+ });
2345
+ }
2346
+ // @__NO_SIDE_EFFECTS__
2347
+ function _ulid(Class, params) {
2348
+ return new Class({
2349
+ type: "string",
2350
+ format: "ulid",
2351
+ check: "string_format",
2352
+ abort: false,
2353
+ ...normalizeParams(params)
2354
+ });
2355
+ }
2356
+ // @__NO_SIDE_EFFECTS__
2357
+ function _xid(Class, params) {
2358
+ return new Class({
2359
+ type: "string",
2360
+ format: "xid",
2361
+ check: "string_format",
2362
+ abort: false,
2363
+ ...normalizeParams(params)
2364
+ });
2365
+ }
2366
+ // @__NO_SIDE_EFFECTS__
2367
+ function _ksuid(Class, params) {
2368
+ return new Class({
2369
+ type: "string",
2370
+ format: "ksuid",
2371
+ check: "string_format",
2372
+ abort: false,
2373
+ ...normalizeParams(params)
2374
+ });
2375
+ }
2376
+ // @__NO_SIDE_EFFECTS__
2377
+ function _ipv4(Class, params) {
2378
+ return new Class({
2379
+ type: "string",
2380
+ format: "ipv4",
2381
+ check: "string_format",
2382
+ abort: false,
2383
+ ...normalizeParams(params)
2384
+ });
2385
+ }
2386
+ // @__NO_SIDE_EFFECTS__
2387
+ function _ipv6(Class, params) {
2388
+ return new Class({
2389
+ type: "string",
2390
+ format: "ipv6",
2391
+ check: "string_format",
2392
+ abort: false,
2393
+ ...normalizeParams(params)
2394
+ });
2395
+ }
2396
+ // @__NO_SIDE_EFFECTS__
2397
+ function _cidrv4(Class, params) {
2398
+ return new Class({
2399
+ type: "string",
2400
+ format: "cidrv4",
2401
+ check: "string_format",
2402
+ abort: false,
2403
+ ...normalizeParams(params)
2404
+ });
2405
+ }
2406
+ // @__NO_SIDE_EFFECTS__
2407
+ function _cidrv6(Class, params) {
2408
+ return new Class({
2409
+ type: "string",
2410
+ format: "cidrv6",
2411
+ check: "string_format",
2412
+ abort: false,
2413
+ ...normalizeParams(params)
2414
+ });
2415
+ }
2416
+ // @__NO_SIDE_EFFECTS__
2417
+ function _base64(Class, params) {
2418
+ return new Class({
2419
+ type: "string",
2420
+ format: "base64",
2421
+ check: "string_format",
2422
+ abort: false,
2423
+ ...normalizeParams(params)
2424
+ });
2425
+ }
2426
+ // @__NO_SIDE_EFFECTS__
2427
+ function _base64url(Class, params) {
2428
+ return new Class({
2429
+ type: "string",
2430
+ format: "base64url",
2431
+ check: "string_format",
2432
+ abort: false,
2433
+ ...normalizeParams(params)
2434
+ });
2435
+ }
2436
+ // @__NO_SIDE_EFFECTS__
2437
+ function _e164(Class, params) {
2438
+ return new Class({
2439
+ type: "string",
2440
+ format: "e164",
2441
+ check: "string_format",
2442
+ abort: false,
2443
+ ...normalizeParams(params)
2444
+ });
2445
+ }
2446
+ // @__NO_SIDE_EFFECTS__
2447
+ function _jwt(Class, params) {
2448
+ return new Class({
2449
+ type: "string",
2450
+ format: "jwt",
2451
+ check: "string_format",
2452
+ abort: false,
2453
+ ...normalizeParams(params)
2454
+ });
2455
+ }
2456
+ // @__NO_SIDE_EFFECTS__
2457
+ function _isoDateTime(Class, params) {
2458
+ return new Class({
2459
+ type: "string",
2460
+ format: "datetime",
2461
+ check: "string_format",
2462
+ offset: false,
2463
+ local: false,
2464
+ precision: null,
2465
+ ...normalizeParams(params)
2466
+ });
2467
+ }
2468
+ // @__NO_SIDE_EFFECTS__
2469
+ function _isoDate(Class, params) {
2470
+ return new Class({
2471
+ type: "string",
2472
+ format: "date",
2473
+ check: "string_format",
2474
+ ...normalizeParams(params)
2475
+ });
2476
+ }
2477
+ // @__NO_SIDE_EFFECTS__
2478
+ function _isoTime(Class, params) {
2479
+ return new Class({
2480
+ type: "string",
2481
+ format: "time",
2482
+ check: "string_format",
2483
+ precision: null,
2484
+ ...normalizeParams(params)
2485
+ });
2486
+ }
2487
+ // @__NO_SIDE_EFFECTS__
2488
+ function _isoDuration(Class, params) {
2489
+ return new Class({
2490
+ type: "string",
2491
+ format: "duration",
2492
+ check: "string_format",
2493
+ ...normalizeParams(params)
2494
+ });
2495
+ }
2496
+ // @__NO_SIDE_EFFECTS__
2497
+ function _number(Class, params) {
2498
+ return new Class({
2499
+ type: "number",
2500
+ checks: [],
2501
+ ...normalizeParams(params)
2502
+ });
2503
+ }
2504
+ // @__NO_SIDE_EFFECTS__
2505
+ function _int(Class, params) {
2506
+ return new Class({
2507
+ type: "number",
2508
+ check: "number_format",
2509
+ abort: false,
2510
+ format: "safeint",
2511
+ ...normalizeParams(params)
2512
+ });
2513
+ }
2514
+ // @__NO_SIDE_EFFECTS__
2515
+ function _unknown(Class) {
2516
+ return new Class({ type: "unknown" });
2517
+ }
2518
+ // @__NO_SIDE_EFFECTS__
2519
+ function _never(Class, params) {
2520
+ return new Class({
2521
+ type: "never",
2522
+ ...normalizeParams(params)
2523
+ });
2524
+ }
2525
+ // @__NO_SIDE_EFFECTS__
2526
+ function _lt(value, params) {
2527
+ return new $ZodCheckLessThan({
2528
+ check: "less_than",
2529
+ ...normalizeParams(params),
2530
+ value,
2531
+ inclusive: false
2532
+ });
2533
+ }
2534
+ // @__NO_SIDE_EFFECTS__
2535
+ function _lte(value, params) {
2536
+ return new $ZodCheckLessThan({
2537
+ check: "less_than",
2538
+ ...normalizeParams(params),
2539
+ value,
2540
+ inclusive: true
2541
+ });
2542
+ }
2543
+ // @__NO_SIDE_EFFECTS__
2544
+ function _gt(value, params) {
2545
+ return new $ZodCheckGreaterThan({
2546
+ check: "greater_than",
2547
+ ...normalizeParams(params),
2548
+ value,
2549
+ inclusive: false
2550
+ });
2551
+ }
2552
+ // @__NO_SIDE_EFFECTS__
2553
+ function _gte(value, params) {
2554
+ return new $ZodCheckGreaterThan({
2555
+ check: "greater_than",
2556
+ ...normalizeParams(params),
2557
+ value,
2558
+ inclusive: true
2559
+ });
2560
+ }
2561
+ // @__NO_SIDE_EFFECTS__
2562
+ function _multipleOf(value, params) {
2563
+ return new $ZodCheckMultipleOf({
2564
+ check: "multiple_of",
2565
+ ...normalizeParams(params),
2566
+ value
2567
+ });
2568
+ }
2569
+ // @__NO_SIDE_EFFECTS__
2570
+ function _maxLength(maximum, params) {
2571
+ return new $ZodCheckMaxLength({
2572
+ check: "max_length",
2573
+ ...normalizeParams(params),
2574
+ maximum
2575
+ });
2576
+ }
2577
+ // @__NO_SIDE_EFFECTS__
2578
+ function _minLength(minimum, params) {
2579
+ return new $ZodCheckMinLength({
2580
+ check: "min_length",
2581
+ ...normalizeParams(params),
2582
+ minimum
2583
+ });
2584
+ }
2585
+ // @__NO_SIDE_EFFECTS__
2586
+ function _length(length, params) {
2587
+ return new $ZodCheckLengthEquals({
2588
+ check: "length_equals",
2589
+ ...normalizeParams(params),
2590
+ length
2591
+ });
2592
+ }
2593
+ // @__NO_SIDE_EFFECTS__
2594
+ function _regex(pattern, params) {
2595
+ return new $ZodCheckRegex({
2596
+ check: "string_format",
2597
+ format: "regex",
2598
+ ...normalizeParams(params),
2599
+ pattern
2600
+ });
2601
+ }
2602
+ // @__NO_SIDE_EFFECTS__
2603
+ function _lowercase(params) {
2604
+ return new $ZodCheckLowerCase({
2605
+ check: "string_format",
2606
+ format: "lowercase",
2607
+ ...normalizeParams(params)
2608
+ });
2609
+ }
2610
+ // @__NO_SIDE_EFFECTS__
2611
+ function _uppercase(params) {
2612
+ return new $ZodCheckUpperCase({
2613
+ check: "string_format",
2614
+ format: "uppercase",
2615
+ ...normalizeParams(params)
2616
+ });
2617
+ }
2618
+ // @__NO_SIDE_EFFECTS__
2619
+ function _includes(includes, params) {
2620
+ return new $ZodCheckIncludes({
2621
+ check: "string_format",
2622
+ format: "includes",
2623
+ ...normalizeParams(params),
2624
+ includes
2625
+ });
2626
+ }
2627
+ // @__NO_SIDE_EFFECTS__
2628
+ function _startsWith(prefix, params) {
2629
+ return new $ZodCheckStartsWith({
2630
+ check: "string_format",
2631
+ format: "starts_with",
2632
+ ...normalizeParams(params),
2633
+ prefix
2634
+ });
2635
+ }
2636
+ // @__NO_SIDE_EFFECTS__
2637
+ function _endsWith(suffix, params) {
2638
+ return new $ZodCheckEndsWith({
2639
+ check: "string_format",
2640
+ format: "ends_with",
2641
+ ...normalizeParams(params),
2642
+ suffix
2643
+ });
2644
+ }
2645
+ // @__NO_SIDE_EFFECTS__
2646
+ function _overwrite(tx) {
2647
+ return new $ZodCheckOverwrite({
2648
+ check: "overwrite",
2649
+ tx
2650
+ });
2651
+ }
2652
+ // @__NO_SIDE_EFFECTS__
2653
+ function _normalize(form) {
2654
+ return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
2655
+ }
2656
+ // @__NO_SIDE_EFFECTS__
2657
+ function _trim() {
2658
+ return /* @__PURE__ */ _overwrite((input) => input.trim());
2659
+ }
2660
+ // @__NO_SIDE_EFFECTS__
2661
+ function _toLowerCase() {
2662
+ return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
2663
+ }
2664
+ // @__NO_SIDE_EFFECTS__
2665
+ function _toUpperCase() {
2666
+ return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
2667
+ }
2668
+ // @__NO_SIDE_EFFECTS__
2669
+ function _slugify() {
2670
+ return /* @__PURE__ */ _overwrite((input) => slugify(input));
2671
+ }
2672
+ // @__NO_SIDE_EFFECTS__
2673
+ function _array(Class, element, params) {
2674
+ return new Class({
2675
+ type: "array",
2676
+ element,
2677
+ ...normalizeParams(params)
2678
+ });
2679
+ }
2680
+ // @__NO_SIDE_EFFECTS__
2681
+ function _refine(Class, fn, _params) {
2682
+ return new Class({
2683
+ type: "custom",
2684
+ check: "custom",
2685
+ fn,
2686
+ ...normalizeParams(_params)
2687
+ });
2688
+ }
2689
+ // @__NO_SIDE_EFFECTS__
2690
+ function _superRefine(fn, params) {
2691
+ const ch = /* @__PURE__ */ _check((payload) => {
2692
+ payload.addIssue = (issue$2) => {
2693
+ if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
2694
+ else {
2695
+ const _issue = issue$2;
2696
+ if (_issue.fatal) _issue.continue = false;
2697
+ _issue.code ?? (_issue.code = "custom");
2698
+ _issue.input ?? (_issue.input = payload.value);
2699
+ _issue.inst ?? (_issue.inst = ch);
2700
+ _issue.continue ?? (_issue.continue = !ch._zod.def.abort);
2701
+ payload.issues.push(issue(_issue));
2702
+ }
2703
+ };
2704
+ return fn(payload.value, payload);
2705
+ }, params);
2706
+ return ch;
2707
+ }
2708
+ // @__NO_SIDE_EFFECTS__
2709
+ function _check(fn, params) {
2710
+ const ch = new $ZodCheck({
2711
+ check: "custom",
2712
+ ...normalizeParams(params)
2713
+ });
2714
+ ch._zod.check = fn;
2715
+ return ch;
2716
+ }
2717
+ //#endregion
2718
+ //#region ../../../node_modules/zod/v4/core/to-json-schema.js
2719
+ function initializeContext(params) {
2720
+ let target = params?.target ?? "draft-2020-12";
2721
+ if (target === "draft-4") target = "draft-04";
2722
+ if (target === "draft-7") target = "draft-07";
2723
+ return {
2724
+ processors: params.processors ?? {},
2725
+ metadataRegistry: params?.metadata ?? globalRegistry,
2726
+ target,
2727
+ unrepresentable: params?.unrepresentable ?? "throw",
2728
+ override: params?.override ?? (() => {}),
2729
+ io: params?.io ?? "output",
2730
+ counter: 0,
2731
+ seen: /* @__PURE__ */ new Map(),
2732
+ cycles: params?.cycles ?? "ref",
2733
+ reused: params?.reused ?? "inline",
2734
+ external: params?.external ?? void 0
2735
+ };
2736
+ }
2737
+ function process(schema, ctx, _params = {
2738
+ path: [],
2739
+ schemaPath: []
2740
+ }) {
2741
+ var _a;
2742
+ const def = schema._zod.def;
2743
+ const seen = ctx.seen.get(schema);
2744
+ if (seen) {
2745
+ seen.count++;
2746
+ if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
2747
+ return seen.schema;
2748
+ }
2749
+ const result = {
2750
+ schema: {},
2751
+ count: 1,
2752
+ cycle: void 0,
2753
+ path: _params.path
2754
+ };
2755
+ ctx.seen.set(schema, result);
2756
+ const overrideSchema = schema._zod.toJSONSchema?.();
2757
+ if (overrideSchema) result.schema = overrideSchema;
2758
+ else {
2759
+ const params = {
2760
+ ..._params,
2761
+ schemaPath: [..._params.schemaPath, schema],
2762
+ path: _params.path
2763
+ };
2764
+ if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
2765
+ else {
2766
+ const _json = result.schema;
2767
+ const processor = ctx.processors[def.type];
2768
+ if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
2769
+ processor(schema, ctx, _json, params);
2770
+ }
2771
+ const parent = schema._zod.parent;
2772
+ if (parent) {
2773
+ if (!result.ref) result.ref = parent;
2774
+ process(parent, ctx, params);
2775
+ ctx.seen.get(parent).isParent = true;
2776
+ }
2777
+ }
2778
+ const meta = ctx.metadataRegistry.get(schema);
2779
+ if (meta) Object.assign(result.schema, meta);
2780
+ if (ctx.io === "input" && isTransforming(schema)) {
2781
+ delete result.schema.examples;
2782
+ delete result.schema.default;
2783
+ }
2784
+ if (ctx.io === "input" && "_prefault" in result.schema) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
2785
+ delete result.schema._prefault;
2786
+ return ctx.seen.get(schema).schema;
2787
+ }
2788
+ function extractDefs(ctx, schema) {
2789
+ const root = ctx.seen.get(schema);
2790
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2791
+ const idToSchema = /* @__PURE__ */ new Map();
2792
+ for (const entry of ctx.seen.entries()) {
2793
+ const id = ctx.metadataRegistry.get(entry[0])?.id;
2794
+ if (id) {
2795
+ const existing = idToSchema.get(id);
2796
+ if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
2797
+ idToSchema.set(id, entry[0]);
2798
+ }
2799
+ }
2800
+ const makeURI = (entry) => {
2801
+ const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
2802
+ if (ctx.external) {
2803
+ const externalId = ctx.external.registry.get(entry[0])?.id;
2804
+ const uriGenerator = ctx.external.uri ?? ((id) => id);
2805
+ if (externalId) return { ref: uriGenerator(externalId) };
2806
+ const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
2807
+ entry[1].defId = id;
2808
+ return {
2809
+ defId: id,
2810
+ ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
2811
+ };
2812
+ }
2813
+ if (entry[1] === root) return { ref: "#" };
2814
+ const defUriPrefix = `#/${defsSegment}/`;
2815
+ const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
2816
+ return {
2817
+ defId,
2818
+ ref: defUriPrefix + defId
2819
+ };
2820
+ };
2821
+ const extractToDef = (entry) => {
2822
+ if (entry[1].schema.$ref) return;
2823
+ const seen = entry[1];
2824
+ const { ref, defId } = makeURI(entry);
2825
+ seen.def = { ...seen.schema };
2826
+ if (defId) seen.defId = defId;
2827
+ const schema = seen.schema;
2828
+ for (const key in schema) delete schema[key];
2829
+ schema.$ref = ref;
2830
+ };
2831
+ if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
2832
+ const seen = entry[1];
2833
+ if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
2834
+
2835
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
2836
+ }
2837
+ for (const entry of ctx.seen.entries()) {
2838
+ const seen = entry[1];
2839
+ if (schema === entry[0]) {
2840
+ extractToDef(entry);
2841
+ continue;
2842
+ }
2843
+ if (ctx.external) {
2844
+ const ext = ctx.external.registry.get(entry[0])?.id;
2845
+ if (schema !== entry[0] && ext) {
2846
+ extractToDef(entry);
2847
+ continue;
2848
+ }
2849
+ }
2850
+ if (ctx.metadataRegistry.get(entry[0])?.id) {
2851
+ extractToDef(entry);
2852
+ continue;
2853
+ }
2854
+ if (seen.cycle) {
2855
+ extractToDef(entry);
2856
+ continue;
2857
+ }
2858
+ if (seen.count > 1) {
2859
+ if (ctx.reused === "ref") {
2860
+ extractToDef(entry);
2861
+ continue;
2862
+ }
2863
+ }
2864
+ }
2865
+ }
2866
+ function finalize(ctx, schema) {
2867
+ const root = ctx.seen.get(schema);
2868
+ if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
2869
+ const flattenRef = (zodSchema) => {
2870
+ const seen = ctx.seen.get(zodSchema);
2871
+ if (seen.ref === null) return;
2872
+ const schema = seen.def ?? seen.schema;
2873
+ const _cached = { ...schema };
2874
+ const ref = seen.ref;
2875
+ seen.ref = null;
2876
+ if (ref) {
2877
+ flattenRef(ref);
2878
+ const refSeen = ctx.seen.get(ref);
2879
+ const refSchema = refSeen.schema;
2880
+ if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
2881
+ schema.allOf = schema.allOf ?? [];
2882
+ schema.allOf.push(refSchema);
2883
+ } else Object.assign(schema, refSchema);
2884
+ Object.assign(schema, _cached);
2885
+ if (zodSchema._zod.parent === ref) for (const key in schema) {
2886
+ if (key === "$ref" || key === "allOf") continue;
2887
+ if (!(key in _cached)) delete schema[key];
2888
+ }
2889
+ if (refSchema.$ref && refSeen.def) for (const key in schema) {
2890
+ if (key === "$ref" || key === "allOf") continue;
2891
+ if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
2892
+ }
2893
+ }
2894
+ const parent = zodSchema._zod.parent;
2895
+ if (parent && parent !== ref) {
2896
+ flattenRef(parent);
2897
+ const parentSeen = ctx.seen.get(parent);
2898
+ if (parentSeen?.schema.$ref) {
2899
+ schema.$ref = parentSeen.schema.$ref;
2900
+ if (parentSeen.def) for (const key in schema) {
2901
+ if (key === "$ref" || key === "allOf") continue;
2902
+ if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
2903
+ }
2904
+ }
2905
+ }
2906
+ ctx.override({
2907
+ zodSchema,
2908
+ jsonSchema: schema,
2909
+ path: seen.path ?? []
2910
+ });
2911
+ };
2912
+ for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
2913
+ const result = {};
2914
+ if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
2915
+ else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
2916
+ else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
2917
+ else if (ctx.target === "openapi-3.0") {}
2918
+ if (ctx.external?.uri) {
2919
+ const id = ctx.external.registry.get(schema)?.id;
2920
+ if (!id) throw new Error("Schema is missing an `id` property");
2921
+ result.$id = ctx.external.uri(id);
2922
+ }
2923
+ Object.assign(result, root.def ?? root.schema);
2924
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
2925
+ if (rootMetaId !== void 0 && result.id === rootMetaId) delete result.id;
2926
+ const defs = ctx.external?.defs ?? {};
2927
+ for (const entry of ctx.seen.entries()) {
2928
+ const seen = entry[1];
2929
+ if (seen.def && seen.defId) {
2930
+ if (seen.def.id === seen.defId) delete seen.def.id;
2931
+ defs[seen.defId] = seen.def;
2932
+ }
2933
+ }
2934
+ if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
2935
+ else result.definitions = defs;
2936
+ try {
2937
+ const finalized = JSON.parse(JSON.stringify(result));
2938
+ Object.defineProperty(finalized, "~standard", {
2939
+ value: {
2940
+ ...schema["~standard"],
2941
+ jsonSchema: {
2942
+ input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
2943
+ output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
2944
+ }
2945
+ },
2946
+ enumerable: false,
2947
+ writable: false
2948
+ });
2949
+ return finalized;
2950
+ } catch (_err) {
2951
+ throw new Error("Error converting schema to JSON.");
2952
+ }
2953
+ }
2954
+ function isTransforming(_schema, _ctx) {
2955
+ const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
2956
+ if (ctx.seen.has(_schema)) return false;
2957
+ ctx.seen.add(_schema);
2958
+ const def = _schema._zod.def;
2959
+ if (def.type === "transform") return true;
2960
+ if (def.type === "array") return isTransforming(def.element, ctx);
2961
+ if (def.type === "set") return isTransforming(def.valueType, ctx);
2962
+ if (def.type === "lazy") return isTransforming(def.getter(), ctx);
2963
+ if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
2964
+ if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
2965
+ if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
2966
+ if (def.type === "pipe") {
2967
+ if (_schema._zod.traits.has("$ZodCodec")) return true;
2968
+ return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
2969
+ }
2970
+ if (def.type === "object") {
2971
+ for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
2972
+ return false;
2973
+ }
2974
+ if (def.type === "union") {
2975
+ for (const option of def.options) if (isTransforming(option, ctx)) return true;
2976
+ return false;
2977
+ }
2978
+ if (def.type === "tuple") {
2979
+ for (const item of def.items) if (isTransforming(item, ctx)) return true;
2980
+ if (def.rest && isTransforming(def.rest, ctx)) return true;
2981
+ return false;
2982
+ }
2983
+ return false;
2984
+ }
2985
+ /**
2986
+ * Creates a toJSONSchema method for a schema instance.
2987
+ * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
2988
+ */
2989
+ var createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
2990
+ const ctx = initializeContext({
2991
+ ...params,
2992
+ processors
2993
+ });
2994
+ process(schema, ctx);
2995
+ extractDefs(ctx, schema);
2996
+ return finalize(ctx, schema);
2997
+ };
2998
+ var createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
2999
+ const { libraryOptions, target } = params ?? {};
3000
+ const ctx = initializeContext({
3001
+ ...libraryOptions ?? {},
3002
+ target,
3003
+ io,
3004
+ processors
3005
+ });
3006
+ process(schema, ctx);
3007
+ extractDefs(ctx, schema);
3008
+ return finalize(ctx, schema);
3009
+ };
3010
+ //#endregion
3011
+ //#region ../../../node_modules/zod/v4/core/json-schema-processors.js
3012
+ var formatMap = {
3013
+ guid: "uuid",
3014
+ url: "uri",
3015
+ datetime: "date-time",
3016
+ json_string: "json-string",
3017
+ regex: ""
3018
+ };
3019
+ var stringProcessor = (schema, ctx, _json, _params) => {
3020
+ const json = _json;
3021
+ json.type = "string";
3022
+ const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
3023
+ if (typeof minimum === "number") json.minLength = minimum;
3024
+ if (typeof maximum === "number") json.maxLength = maximum;
3025
+ if (format) {
3026
+ json.format = formatMap[format] ?? format;
3027
+ if (json.format === "") delete json.format;
3028
+ if (format === "time") delete json.format;
3029
+ }
3030
+ if (contentEncoding) json.contentEncoding = contentEncoding;
3031
+ if (patterns && patterns.size > 0) {
3032
+ const regexes = [...patterns];
3033
+ if (regexes.length === 1) json.pattern = regexes[0].source;
3034
+ else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
3035
+ ...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
3036
+ pattern: regex.source
3037
+ }))];
3038
+ }
3039
+ };
3040
+ var numberProcessor = (schema, ctx, _json, _params) => {
3041
+ const json = _json;
3042
+ const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
3043
+ if (typeof format === "string" && format.includes("int")) json.type = "integer";
3044
+ else json.type = "number";
3045
+ const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
3046
+ const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
3047
+ const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
3048
+ if (exMin) if (legacy) {
3049
+ json.minimum = exclusiveMinimum;
3050
+ json.exclusiveMinimum = true;
3051
+ } else json.exclusiveMinimum = exclusiveMinimum;
3052
+ else if (typeof minimum === "number") json.minimum = minimum;
3053
+ if (exMax) if (legacy) {
3054
+ json.maximum = exclusiveMaximum;
3055
+ json.exclusiveMaximum = true;
3056
+ } else json.exclusiveMaximum = exclusiveMaximum;
3057
+ else if (typeof maximum === "number") json.maximum = maximum;
3058
+ if (typeof multipleOf === "number") json.multipleOf = multipleOf;
3059
+ };
3060
+ var neverProcessor = (_schema, _ctx, json, _params) => {
3061
+ json.not = {};
3062
+ };
3063
+ var enumProcessor = (schema, _ctx, json, _params) => {
3064
+ const def = schema._zod.def;
3065
+ const values = getEnumValues(def.entries);
3066
+ if (values.every((v) => typeof v === "number")) json.type = "number";
3067
+ if (values.every((v) => typeof v === "string")) json.type = "string";
3068
+ json.enum = values;
3069
+ };
3070
+ var literalProcessor = (schema, ctx, json, _params) => {
3071
+ const def = schema._zod.def;
3072
+ const vals = [];
3073
+ for (const val of def.values) if (val === void 0) {
3074
+ if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
3075
+ } else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
3076
+ else vals.push(Number(val));
3077
+ else vals.push(val);
3078
+ if (vals.length === 0) {} else if (vals.length === 1) {
3079
+ const val = vals[0];
3080
+ json.type = val === null ? "null" : typeof val;
3081
+ if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
3082
+ else json.const = val;
3083
+ } else {
3084
+ if (vals.every((v) => typeof v === "number")) json.type = "number";
3085
+ if (vals.every((v) => typeof v === "string")) json.type = "string";
3086
+ if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
3087
+ if (vals.every((v) => v === null)) json.type = "null";
3088
+ json.enum = vals;
3089
+ }
3090
+ };
3091
+ var customProcessor = (_schema, ctx, _json, _params) => {
3092
+ if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
3093
+ };
3094
+ var transformProcessor = (_schema, ctx, _json, _params) => {
3095
+ if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
3096
+ };
3097
+ var arrayProcessor = (schema, ctx, _json, params) => {
3098
+ const json = _json;
3099
+ const def = schema._zod.def;
3100
+ const { minimum, maximum } = schema._zod.bag;
3101
+ if (typeof minimum === "number") json.minItems = minimum;
3102
+ if (typeof maximum === "number") json.maxItems = maximum;
3103
+ json.type = "array";
3104
+ json.items = process(def.element, ctx, {
3105
+ ...params,
3106
+ path: [...params.path, "items"]
3107
+ });
3108
+ };
3109
+ var objectProcessor = (schema, ctx, _json, params) => {
3110
+ const json = _json;
3111
+ const def = schema._zod.def;
3112
+ json.type = "object";
3113
+ json.properties = {};
3114
+ const shape = def.shape;
3115
+ for (const key in shape) json.properties[key] = process(shape[key], ctx, {
3116
+ ...params,
3117
+ path: [
3118
+ ...params.path,
3119
+ "properties",
3120
+ key
3121
+ ]
3122
+ });
3123
+ const allKeys = new Set(Object.keys(shape));
3124
+ const requiredKeys = new Set([...allKeys].filter((key) => {
3125
+ const v = def.shape[key]._zod;
3126
+ if (ctx.io === "input") return v.optin === void 0;
3127
+ else return v.optout === void 0;
3128
+ }));
3129
+ if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
3130
+ if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
3131
+ else if (!def.catchall) {
3132
+ if (ctx.io === "output") json.additionalProperties = false;
3133
+ } else if (def.catchall) json.additionalProperties = process(def.catchall, ctx, {
3134
+ ...params,
3135
+ path: [...params.path, "additionalProperties"]
3136
+ });
3137
+ };
3138
+ var unionProcessor = (schema, ctx, json, params) => {
3139
+ const def = schema._zod.def;
3140
+ const isExclusive = def.inclusive === false;
3141
+ const options = def.options.map((x, i) => process(x, ctx, {
3142
+ ...params,
3143
+ path: [
3144
+ ...params.path,
3145
+ isExclusive ? "oneOf" : "anyOf",
3146
+ i
3147
+ ]
3148
+ }));
3149
+ if (isExclusive) json.oneOf = options;
3150
+ else json.anyOf = options;
3151
+ };
3152
+ var intersectionProcessor = (schema, ctx, json, params) => {
3153
+ const def = schema._zod.def;
3154
+ const a = process(def.left, ctx, {
3155
+ ...params,
3156
+ path: [
3157
+ ...params.path,
3158
+ "allOf",
3159
+ 0
3160
+ ]
3161
+ });
3162
+ const b = process(def.right, ctx, {
3163
+ ...params,
3164
+ path: [
3165
+ ...params.path,
3166
+ "allOf",
3167
+ 1
3168
+ ]
3169
+ });
3170
+ const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
3171
+ json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
3172
+ };
3173
+ var nullableProcessor = (schema, ctx, json, params) => {
3174
+ const def = schema._zod.def;
3175
+ const inner = process(def.innerType, ctx, params);
3176
+ const seen = ctx.seen.get(schema);
3177
+ if (ctx.target === "openapi-3.0") {
3178
+ seen.ref = def.innerType;
3179
+ json.nullable = true;
3180
+ } else json.anyOf = [inner, { type: "null" }];
3181
+ };
3182
+ var nonoptionalProcessor = (schema, ctx, _json, params) => {
3183
+ const def = schema._zod.def;
3184
+ process(def.innerType, ctx, params);
3185
+ const seen = ctx.seen.get(schema);
3186
+ seen.ref = def.innerType;
3187
+ };
3188
+ var defaultProcessor = (schema, ctx, json, params) => {
3189
+ const def = schema._zod.def;
3190
+ process(def.innerType, ctx, params);
3191
+ const seen = ctx.seen.get(schema);
3192
+ seen.ref = def.innerType;
3193
+ json.default = JSON.parse(JSON.stringify(def.defaultValue));
3194
+ };
3195
+ var prefaultProcessor = (schema, ctx, json, params) => {
3196
+ const def = schema._zod.def;
3197
+ process(def.innerType, ctx, params);
3198
+ const seen = ctx.seen.get(schema);
3199
+ seen.ref = def.innerType;
3200
+ if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
3201
+ };
3202
+ var catchProcessor = (schema, ctx, json, params) => {
3203
+ const def = schema._zod.def;
3204
+ process(def.innerType, ctx, params);
3205
+ const seen = ctx.seen.get(schema);
3206
+ seen.ref = def.innerType;
3207
+ let catchValue;
3208
+ try {
3209
+ catchValue = def.catchValue(void 0);
3210
+ } catch {
3211
+ throw new Error("Dynamic catch values are not supported in JSON Schema");
3212
+ }
3213
+ json.default = catchValue;
3214
+ };
3215
+ var pipeProcessor = (schema, ctx, _json, params) => {
3216
+ const def = schema._zod.def;
3217
+ const inIsTransform = def.in._zod.traits.has("$ZodTransform");
3218
+ const innerType = ctx.io === "input" ? inIsTransform ? def.out : def.in : def.out;
3219
+ process(innerType, ctx, params);
3220
+ const seen = ctx.seen.get(schema);
3221
+ seen.ref = innerType;
3222
+ };
3223
+ var readonlyProcessor = (schema, ctx, json, params) => {
3224
+ const def = schema._zod.def;
3225
+ process(def.innerType, ctx, params);
3226
+ const seen = ctx.seen.get(schema);
3227
+ seen.ref = def.innerType;
3228
+ json.readOnly = true;
3229
+ };
3230
+ var optionalProcessor = (schema, ctx, _json, params) => {
3231
+ const def = schema._zod.def;
3232
+ process(def.innerType, ctx, params);
3233
+ const seen = ctx.seen.get(schema);
3234
+ seen.ref = def.innerType;
3235
+ };
3236
+ //#endregion
3237
+ //#region ../../../node_modules/zod/v4/classic/iso.js
3238
+ var ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
3239
+ $ZodISODateTime.init(inst, def);
3240
+ ZodStringFormat.init(inst, def);
3241
+ });
3242
+ function datetime(params) {
3243
+ return /* @__PURE__ */ _isoDateTime(ZodISODateTime, params);
3244
+ }
3245
+ var ZodISODate = /*@__PURE__*/ $constructor("ZodISODate", (inst, def) => {
3246
+ $ZodISODate.init(inst, def);
3247
+ ZodStringFormat.init(inst, def);
3248
+ });
3249
+ function date(params) {
3250
+ return /* @__PURE__ */ _isoDate(ZodISODate, params);
3251
+ }
3252
+ var ZodISOTime = /*@__PURE__*/ $constructor("ZodISOTime", (inst, def) => {
3253
+ $ZodISOTime.init(inst, def);
3254
+ ZodStringFormat.init(inst, def);
3255
+ });
3256
+ function time(params) {
3257
+ return /* @__PURE__ */ _isoTime(ZodISOTime, params);
3258
+ }
3259
+ var ZodISODuration = /*@__PURE__*/ $constructor("ZodISODuration", (inst, def) => {
3260
+ $ZodISODuration.init(inst, def);
3261
+ ZodStringFormat.init(inst, def);
3262
+ });
3263
+ function duration(params) {
3264
+ return /* @__PURE__ */ _isoDuration(ZodISODuration, params);
3265
+ }
3266
+ //#endregion
3267
+ //#region ../../../node_modules/zod/v4/classic/errors.js
3268
+ var initializer = (inst, issues) => {
3269
+ $ZodError.init(inst, issues);
3270
+ inst.name = "ZodError";
3271
+ Object.defineProperties(inst, {
3272
+ format: { value: (mapper) => formatError(inst, mapper) },
3273
+ flatten: { value: (mapper) => flattenError(inst, mapper) },
3274
+ addIssue: { value: (issue) => {
3275
+ inst.issues.push(issue);
3276
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3277
+ } },
3278
+ addIssues: { value: (issues) => {
3279
+ inst.issues.push(...issues);
3280
+ inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
3281
+ } },
3282
+ isEmpty: { get() {
3283
+ return inst.issues.length === 0;
3284
+ } }
3285
+ });
3286
+ };
3287
+ var ZodRealError = /*@__PURE__*/ $constructor("ZodError", initializer, { Parent: Error });
3288
+ //#endregion
3289
+ //#region ../../../node_modules/zod/v4/classic/parse.js
3290
+ var parse = /* @__PURE__ */ _parse(ZodRealError);
3291
+ var parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
3292
+ var safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
3293
+ var safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
3294
+ var encode = /* @__PURE__ */ _encode(ZodRealError);
3295
+ var decode = /* @__PURE__ */ _decode(ZodRealError);
3296
+ var encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
3297
+ var decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
3298
+ var safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
3299
+ var safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
3300
+ var safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
3301
+ var safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
3302
+ //#endregion
3303
+ //#region ../../../node_modules/zod/v4/classic/schemas.js
3304
+ var _installedGroups = /* @__PURE__ */ new WeakMap();
3305
+ function _installLazyMethods(inst, group, methods) {
3306
+ const proto = Object.getPrototypeOf(inst);
3307
+ let installed = _installedGroups.get(proto);
3308
+ if (!installed) {
3309
+ installed = /* @__PURE__ */ new Set();
3310
+ _installedGroups.set(proto, installed);
3311
+ }
3312
+ if (installed.has(group)) return;
3313
+ installed.add(group);
3314
+ for (const key in methods) {
3315
+ const fn = methods[key];
3316
+ Object.defineProperty(proto, key, {
3317
+ configurable: true,
3318
+ enumerable: false,
3319
+ get() {
3320
+ const bound = fn.bind(this);
3321
+ Object.defineProperty(this, key, {
3322
+ configurable: true,
3323
+ writable: true,
3324
+ enumerable: true,
3325
+ value: bound
3326
+ });
3327
+ return bound;
3328
+ },
3329
+ set(v) {
3330
+ Object.defineProperty(this, key, {
3331
+ configurable: true,
3332
+ writable: true,
3333
+ enumerable: true,
3334
+ value: v
3335
+ });
3336
+ }
3337
+ });
3338
+ }
3339
+ }
3340
+ var ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
3341
+ $ZodType.init(inst, def);
3342
+ Object.assign(inst["~standard"], { jsonSchema: {
3343
+ input: createStandardJSONSchemaMethod(inst, "input"),
3344
+ output: createStandardJSONSchemaMethod(inst, "output")
3345
+ } });
3346
+ inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
3347
+ inst.def = def;
3348
+ inst.type = def.type;
3349
+ Object.defineProperty(inst, "_def", { value: def });
3350
+ inst.parse = (data, params) => parse(inst, data, params, { callee: inst.parse });
3351
+ inst.safeParse = (data, params) => safeParse(inst, data, params);
3352
+ inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
3353
+ inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
3354
+ inst.spa = inst.safeParseAsync;
3355
+ inst.encode = (data, params) => encode(inst, data, params);
3356
+ inst.decode = (data, params) => decode(inst, data, params);
3357
+ inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
3358
+ inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
3359
+ inst.safeEncode = (data, params) => safeEncode(inst, data, params);
3360
+ inst.safeDecode = (data, params) => safeDecode(inst, data, params);
3361
+ inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
3362
+ inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
3363
+ _installLazyMethods(inst, "ZodType", {
3364
+ check(...chks) {
3365
+ const def = this.def;
3366
+ return this.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...chks.map((ch) => typeof ch === "function" ? { _zod: {
3367
+ check: ch,
3368
+ def: { check: "custom" },
3369
+ onattach: []
3370
+ } } : ch)] }), { parent: true });
3371
+ },
3372
+ with(...chks) {
3373
+ return this.check(...chks);
3374
+ },
3375
+ clone(def, params) {
3376
+ return clone(this, def, params);
3377
+ },
3378
+ brand() {
3379
+ return this;
3380
+ },
3381
+ register(reg, meta) {
3382
+ reg.add(this, meta);
3383
+ return this;
3384
+ },
3385
+ refine(check, params) {
3386
+ return this.check(refine(check, params));
3387
+ },
3388
+ superRefine(refinement, params) {
3389
+ return this.check(superRefine(refinement, params));
3390
+ },
3391
+ overwrite(fn) {
3392
+ return this.check(/* @__PURE__ */ _overwrite(fn));
3393
+ },
3394
+ optional() {
3395
+ return optional(this);
3396
+ },
3397
+ exactOptional() {
3398
+ return exactOptional(this);
3399
+ },
3400
+ nullable() {
3401
+ return nullable(this);
3402
+ },
3403
+ nullish() {
3404
+ return optional(nullable(this));
3405
+ },
3406
+ nonoptional(params) {
3407
+ return nonoptional(this, params);
3408
+ },
3409
+ array() {
3410
+ return array(this);
3411
+ },
3412
+ or(arg) {
3413
+ return union([this, arg]);
3414
+ },
3415
+ and(arg) {
3416
+ return intersection(this, arg);
3417
+ },
3418
+ transform(tx) {
3419
+ return pipe(this, transform(tx));
3420
+ },
3421
+ default(d) {
3422
+ return _default(this, d);
3423
+ },
3424
+ prefault(d) {
3425
+ return prefault(this, d);
3426
+ },
3427
+ catch(params) {
3428
+ return _catch(this, params);
3429
+ },
3430
+ pipe(target) {
3431
+ return pipe(this, target);
3432
+ },
3433
+ readonly() {
3434
+ return readonly(this);
3435
+ },
3436
+ describe(description) {
3437
+ const cl = this.clone();
3438
+ globalRegistry.add(cl, { description });
3439
+ return cl;
3440
+ },
3441
+ meta(...args) {
3442
+ if (args.length === 0) return globalRegistry.get(this);
3443
+ const cl = this.clone();
3444
+ globalRegistry.add(cl, args[0]);
3445
+ return cl;
3446
+ },
3447
+ isOptional() {
3448
+ return this.safeParse(void 0).success;
3449
+ },
3450
+ isNullable() {
3451
+ return this.safeParse(null).success;
3452
+ },
3453
+ apply(fn) {
3454
+ return fn(this);
3455
+ }
3456
+ });
3457
+ Object.defineProperty(inst, "description", {
3458
+ get() {
3459
+ return globalRegistry.get(inst)?.description;
3460
+ },
3461
+ configurable: true
3462
+ });
3463
+ return inst;
3464
+ });
3465
+ /** @internal */
3466
+ var _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
3467
+ $ZodString.init(inst, def);
3468
+ ZodType.init(inst, def);
3469
+ inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
3470
+ const bag = inst._zod.bag;
3471
+ inst.format = bag.format ?? null;
3472
+ inst.minLength = bag.minimum ?? null;
3473
+ inst.maxLength = bag.maximum ?? null;
3474
+ _installLazyMethods(inst, "_ZodString", {
3475
+ regex(...args) {
3476
+ return this.check(/* @__PURE__ */ _regex(...args));
3477
+ },
3478
+ includes(...args) {
3479
+ return this.check(/* @__PURE__ */ _includes(...args));
3480
+ },
3481
+ startsWith(...args) {
3482
+ return this.check(/* @__PURE__ */ _startsWith(...args));
3483
+ },
3484
+ endsWith(...args) {
3485
+ return this.check(/* @__PURE__ */ _endsWith(...args));
3486
+ },
3487
+ min(...args) {
3488
+ return this.check(/* @__PURE__ */ _minLength(...args));
3489
+ },
3490
+ max(...args) {
3491
+ return this.check(/* @__PURE__ */ _maxLength(...args));
3492
+ },
3493
+ length(...args) {
3494
+ return this.check(/* @__PURE__ */ _length(...args));
3495
+ },
3496
+ nonempty(...args) {
3497
+ return this.check(/* @__PURE__ */ _minLength(1, ...args));
3498
+ },
3499
+ lowercase(params) {
3500
+ return this.check(/* @__PURE__ */ _lowercase(params));
3501
+ },
3502
+ uppercase(params) {
3503
+ return this.check(/* @__PURE__ */ _uppercase(params));
3504
+ },
3505
+ trim() {
3506
+ return this.check(/* @__PURE__ */ _trim());
3507
+ },
3508
+ normalize(...args) {
3509
+ return this.check(/* @__PURE__ */ _normalize(...args));
3510
+ },
3511
+ toLowerCase() {
3512
+ return this.check(/* @__PURE__ */ _toLowerCase());
3513
+ },
3514
+ toUpperCase() {
3515
+ return this.check(/* @__PURE__ */ _toUpperCase());
3516
+ },
3517
+ slugify() {
3518
+ return this.check(/* @__PURE__ */ _slugify());
3519
+ }
3520
+ });
3521
+ });
3522
+ var ZodString = /*@__PURE__*/ $constructor("ZodString", (inst, def) => {
3523
+ $ZodString.init(inst, def);
3524
+ _ZodString.init(inst, def);
3525
+ inst.email = (params) => inst.check(/* @__PURE__ */ _email(ZodEmail, params));
3526
+ inst.url = (params) => inst.check(/* @__PURE__ */ _url(ZodURL, params));
3527
+ inst.jwt = (params) => inst.check(/* @__PURE__ */ _jwt(ZodJWT, params));
3528
+ inst.emoji = (params) => inst.check(/* @__PURE__ */ _emoji(ZodEmoji, params));
3529
+ inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3530
+ inst.uuid = (params) => inst.check(/* @__PURE__ */ _uuid(ZodUUID, params));
3531
+ inst.uuidv4 = (params) => inst.check(/* @__PURE__ */ _uuidv4(ZodUUID, params));
3532
+ inst.uuidv6 = (params) => inst.check(/* @__PURE__ */ _uuidv6(ZodUUID, params));
3533
+ inst.uuidv7 = (params) => inst.check(/* @__PURE__ */ _uuidv7(ZodUUID, params));
3534
+ inst.nanoid = (params) => inst.check(/* @__PURE__ */ _nanoid(ZodNanoID, params));
3535
+ inst.guid = (params) => inst.check(/* @__PURE__ */ _guid(ZodGUID, params));
3536
+ inst.cuid = (params) => inst.check(/* @__PURE__ */ _cuid(ZodCUID, params));
3537
+ inst.cuid2 = (params) => inst.check(/* @__PURE__ */ _cuid2(ZodCUID2, params));
3538
+ inst.ulid = (params) => inst.check(/* @__PURE__ */ _ulid(ZodULID, params));
3539
+ inst.base64 = (params) => inst.check(/* @__PURE__ */ _base64(ZodBase64, params));
3540
+ inst.base64url = (params) => inst.check(/* @__PURE__ */ _base64url(ZodBase64URL, params));
3541
+ inst.xid = (params) => inst.check(/* @__PURE__ */ _xid(ZodXID, params));
3542
+ inst.ksuid = (params) => inst.check(/* @__PURE__ */ _ksuid(ZodKSUID, params));
3543
+ inst.ipv4 = (params) => inst.check(/* @__PURE__ */ _ipv4(ZodIPv4, params));
3544
+ inst.ipv6 = (params) => inst.check(/* @__PURE__ */ _ipv6(ZodIPv6, params));
3545
+ inst.cidrv4 = (params) => inst.check(/* @__PURE__ */ _cidrv4(ZodCIDRv4, params));
3546
+ inst.cidrv6 = (params) => inst.check(/* @__PURE__ */ _cidrv6(ZodCIDRv6, params));
3547
+ inst.e164 = (params) => inst.check(/* @__PURE__ */ _e164(ZodE164, params));
3548
+ inst.datetime = (params) => inst.check(datetime(params));
3549
+ inst.date = (params) => inst.check(date(params));
3550
+ inst.time = (params) => inst.check(time(params));
3551
+ inst.duration = (params) => inst.check(duration(params));
3552
+ });
3553
+ function string(params) {
3554
+ return /* @__PURE__ */ _string(ZodString, params);
3555
+ }
3556
+ var ZodStringFormat = /*@__PURE__*/ $constructor("ZodStringFormat", (inst, def) => {
3557
+ $ZodStringFormat.init(inst, def);
3558
+ _ZodString.init(inst, def);
3559
+ });
3560
+ var ZodEmail = /*@__PURE__*/ $constructor("ZodEmail", (inst, def) => {
3561
+ $ZodEmail.init(inst, def);
3562
+ ZodStringFormat.init(inst, def);
3563
+ });
3564
+ var ZodGUID = /*@__PURE__*/ $constructor("ZodGUID", (inst, def) => {
3565
+ $ZodGUID.init(inst, def);
3566
+ ZodStringFormat.init(inst, def);
3567
+ });
3568
+ var ZodUUID = /*@__PURE__*/ $constructor("ZodUUID", (inst, def) => {
3569
+ $ZodUUID.init(inst, def);
3570
+ ZodStringFormat.init(inst, def);
3571
+ });
3572
+ var ZodURL = /*@__PURE__*/ $constructor("ZodURL", (inst, def) => {
3573
+ $ZodURL.init(inst, def);
3574
+ ZodStringFormat.init(inst, def);
3575
+ });
3576
+ var ZodEmoji = /*@__PURE__*/ $constructor("ZodEmoji", (inst, def) => {
3577
+ $ZodEmoji.init(inst, def);
3578
+ ZodStringFormat.init(inst, def);
3579
+ });
3580
+ var ZodNanoID = /*@__PURE__*/ $constructor("ZodNanoID", (inst, def) => {
3581
+ $ZodNanoID.init(inst, def);
3582
+ ZodStringFormat.init(inst, def);
3583
+ });
3584
+ /**
3585
+ * @deprecated CUID v1 is deprecated by its authors due to information leakage
3586
+ * (timestamps embedded in the id). Use {@link ZodCUID2} instead.
3587
+ * See https://github.com/paralleldrive/cuid.
3588
+ */
3589
+ var ZodCUID = /*@__PURE__*/ $constructor("ZodCUID", (inst, def) => {
3590
+ $ZodCUID.init(inst, def);
3591
+ ZodStringFormat.init(inst, def);
3592
+ });
3593
+ var ZodCUID2 = /*@__PURE__*/ $constructor("ZodCUID2", (inst, def) => {
3594
+ $ZodCUID2.init(inst, def);
3595
+ ZodStringFormat.init(inst, def);
3596
+ });
3597
+ var ZodULID = /*@__PURE__*/ $constructor("ZodULID", (inst, def) => {
3598
+ $ZodULID.init(inst, def);
3599
+ ZodStringFormat.init(inst, def);
3600
+ });
3601
+ var ZodXID = /*@__PURE__*/ $constructor("ZodXID", (inst, def) => {
3602
+ $ZodXID.init(inst, def);
3603
+ ZodStringFormat.init(inst, def);
3604
+ });
3605
+ var ZodKSUID = /*@__PURE__*/ $constructor("ZodKSUID", (inst, def) => {
3606
+ $ZodKSUID.init(inst, def);
3607
+ ZodStringFormat.init(inst, def);
3608
+ });
3609
+ var ZodIPv4 = /*@__PURE__*/ $constructor("ZodIPv4", (inst, def) => {
3610
+ $ZodIPv4.init(inst, def);
3611
+ ZodStringFormat.init(inst, def);
3612
+ });
3613
+ var ZodIPv6 = /*@__PURE__*/ $constructor("ZodIPv6", (inst, def) => {
3614
+ $ZodIPv6.init(inst, def);
3615
+ ZodStringFormat.init(inst, def);
3616
+ });
3617
+ var ZodCIDRv4 = /*@__PURE__*/ $constructor("ZodCIDRv4", (inst, def) => {
3618
+ $ZodCIDRv4.init(inst, def);
3619
+ ZodStringFormat.init(inst, def);
3620
+ });
3621
+ var ZodCIDRv6 = /*@__PURE__*/ $constructor("ZodCIDRv6", (inst, def) => {
3622
+ $ZodCIDRv6.init(inst, def);
3623
+ ZodStringFormat.init(inst, def);
3624
+ });
3625
+ var ZodBase64 = /*@__PURE__*/ $constructor("ZodBase64", (inst, def) => {
3626
+ $ZodBase64.init(inst, def);
3627
+ ZodStringFormat.init(inst, def);
3628
+ });
3629
+ var ZodBase64URL = /*@__PURE__*/ $constructor("ZodBase64URL", (inst, def) => {
3630
+ $ZodBase64URL.init(inst, def);
3631
+ ZodStringFormat.init(inst, def);
3632
+ });
3633
+ var ZodE164 = /*@__PURE__*/ $constructor("ZodE164", (inst, def) => {
3634
+ $ZodE164.init(inst, def);
3635
+ ZodStringFormat.init(inst, def);
3636
+ });
3637
+ var ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
3638
+ $ZodJWT.init(inst, def);
3639
+ ZodStringFormat.init(inst, def);
3640
+ });
3641
+ var ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
3642
+ $ZodNumber.init(inst, def);
3643
+ ZodType.init(inst, def);
3644
+ inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
3645
+ _installLazyMethods(inst, "ZodNumber", {
3646
+ gt(value, params) {
3647
+ return this.check(/* @__PURE__ */ _gt(value, params));
3648
+ },
3649
+ gte(value, params) {
3650
+ return this.check(/* @__PURE__ */ _gte(value, params));
3651
+ },
3652
+ min(value, params) {
3653
+ return this.check(/* @__PURE__ */ _gte(value, params));
3654
+ },
3655
+ lt(value, params) {
3656
+ return this.check(/* @__PURE__ */ _lt(value, params));
3657
+ },
3658
+ lte(value, params) {
3659
+ return this.check(/* @__PURE__ */ _lte(value, params));
3660
+ },
3661
+ max(value, params) {
3662
+ return this.check(/* @__PURE__ */ _lte(value, params));
3663
+ },
3664
+ int(params) {
3665
+ return this.check(int(params));
3666
+ },
3667
+ safe(params) {
3668
+ return this.check(int(params));
3669
+ },
3670
+ positive(params) {
3671
+ return this.check(/* @__PURE__ */ _gt(0, params));
3672
+ },
3673
+ nonnegative(params) {
3674
+ return this.check(/* @__PURE__ */ _gte(0, params));
3675
+ },
3676
+ negative(params) {
3677
+ return this.check(/* @__PURE__ */ _lt(0, params));
3678
+ },
3679
+ nonpositive(params) {
3680
+ return this.check(/* @__PURE__ */ _lte(0, params));
3681
+ },
3682
+ multipleOf(value, params) {
3683
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
3684
+ },
3685
+ step(value, params) {
3686
+ return this.check(/* @__PURE__ */ _multipleOf(value, params));
3687
+ },
3688
+ finite() {
3689
+ return this;
3690
+ }
3691
+ });
3692
+ const bag = inst._zod.bag;
3693
+ inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
3694
+ inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
3695
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? .5);
3696
+ inst.isFinite = true;
3697
+ inst.format = bag.format ?? null;
3698
+ });
3699
+ function number(params) {
3700
+ return /* @__PURE__ */ _number(ZodNumber, params);
3701
+ }
3702
+ var ZodNumberFormat = /*@__PURE__*/ $constructor("ZodNumberFormat", (inst, def) => {
3703
+ $ZodNumberFormat.init(inst, def);
3704
+ ZodNumber.init(inst, def);
3705
+ });
3706
+ function int(params) {
3707
+ return /* @__PURE__ */ _int(ZodNumberFormat, params);
3708
+ }
3709
+ var ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
3710
+ $ZodUnknown.init(inst, def);
3711
+ ZodType.init(inst, def);
3712
+ inst._zod.processJSONSchema = (ctx, json, params) => void 0;
3713
+ });
3714
+ function unknown() {
3715
+ return /* @__PURE__ */ _unknown(ZodUnknown);
3716
+ }
3717
+ var ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
3718
+ $ZodNever.init(inst, def);
3719
+ ZodType.init(inst, def);
3720
+ inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
3721
+ });
3722
+ function never(params) {
3723
+ return /* @__PURE__ */ _never(ZodNever, params);
3724
+ }
3725
+ var ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
3726
+ $ZodArray.init(inst, def);
3727
+ ZodType.init(inst, def);
3728
+ inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
3729
+ inst.element = def.element;
3730
+ _installLazyMethods(inst, "ZodArray", {
3731
+ min(n, params) {
3732
+ return this.check(/* @__PURE__ */ _minLength(n, params));
3733
+ },
3734
+ nonempty(params) {
3735
+ return this.check(/* @__PURE__ */ _minLength(1, params));
3736
+ },
3737
+ max(n, params) {
3738
+ return this.check(/* @__PURE__ */ _maxLength(n, params));
3739
+ },
3740
+ length(n, params) {
3741
+ return this.check(/* @__PURE__ */ _length(n, params));
3742
+ },
3743
+ unwrap() {
3744
+ return this.element;
3745
+ }
3746
+ });
3747
+ });
3748
+ function array(element, params) {
3749
+ return /* @__PURE__ */ _array(ZodArray, element, params);
3750
+ }
3751
+ var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
3752
+ $ZodObjectJIT.init(inst, def);
3753
+ ZodType.init(inst, def);
3754
+ inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
3755
+ defineLazy(inst, "shape", () => {
3756
+ return def.shape;
3757
+ });
3758
+ _installLazyMethods(inst, "ZodObject", {
3759
+ keyof() {
3760
+ return _enum(Object.keys(this._zod.def.shape));
3761
+ },
3762
+ catchall(catchall) {
3763
+ return this.clone({
3764
+ ...this._zod.def,
3765
+ catchall
3766
+ });
3767
+ },
3768
+ passthrough() {
3769
+ return this.clone({
3770
+ ...this._zod.def,
3771
+ catchall: unknown()
3772
+ });
3773
+ },
3774
+ loose() {
3775
+ return this.clone({
3776
+ ...this._zod.def,
3777
+ catchall: unknown()
3778
+ });
3779
+ },
3780
+ strict() {
3781
+ return this.clone({
3782
+ ...this._zod.def,
3783
+ catchall: never()
3784
+ });
3785
+ },
3786
+ strip() {
3787
+ return this.clone({
3788
+ ...this._zod.def,
3789
+ catchall: void 0
3790
+ });
3791
+ },
3792
+ extend(incoming) {
3793
+ return extend(this, incoming);
3794
+ },
3795
+ safeExtend(incoming) {
3796
+ return safeExtend(this, incoming);
3797
+ },
3798
+ merge(other) {
3799
+ return merge(this, other);
3800
+ },
3801
+ pick(mask) {
3802
+ return pick(this, mask);
3803
+ },
3804
+ omit(mask) {
3805
+ return omit(this, mask);
3806
+ },
3807
+ partial(...args) {
3808
+ return partial(ZodOptional, this, args[0]);
3809
+ },
3810
+ required(...args) {
3811
+ return required(ZodNonOptional, this, args[0]);
3812
+ }
3813
+ });
3814
+ });
3815
+ function object(shape, params) {
3816
+ return new ZodObject({
3817
+ type: "object",
3818
+ shape: shape ?? {},
3819
+ ...normalizeParams(params)
3820
+ });
3821
+ }
3822
+ var ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
3823
+ $ZodUnion.init(inst, def);
3824
+ ZodType.init(inst, def);
3825
+ inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
3826
+ inst.options = def.options;
3827
+ });
3828
+ function union(options, params) {
3829
+ return new ZodUnion({
3830
+ type: "union",
3831
+ options,
3832
+ ...normalizeParams(params)
3833
+ });
3834
+ }
3835
+ var ZodDiscriminatedUnion = /*@__PURE__*/ $constructor("ZodDiscriminatedUnion", (inst, def) => {
3836
+ ZodUnion.init(inst, def);
3837
+ $ZodDiscriminatedUnion.init(inst, def);
3838
+ });
3839
+ function discriminatedUnion(discriminator, options, params) {
3840
+ return new ZodDiscriminatedUnion({
3841
+ type: "union",
3842
+ options,
3843
+ discriminator,
3844
+ ...normalizeParams(params)
3845
+ });
3846
+ }
3847
+ var ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
3848
+ $ZodIntersection.init(inst, def);
3849
+ ZodType.init(inst, def);
3850
+ inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
3851
+ });
3852
+ function intersection(left, right) {
3853
+ return new ZodIntersection({
3854
+ type: "intersection",
3855
+ left,
3856
+ right
3857
+ });
3858
+ }
3859
+ var ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
3860
+ $ZodEnum.init(inst, def);
3861
+ ZodType.init(inst, def);
3862
+ inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
3863
+ inst.enum = def.entries;
3864
+ inst.options = Object.values(def.entries);
3865
+ const keys = new Set(Object.keys(def.entries));
3866
+ inst.extract = (values, params) => {
3867
+ const newEntries = {};
3868
+ for (const value of values) if (keys.has(value)) newEntries[value] = def.entries[value];
3869
+ else throw new Error(`Key ${value} not found in enum`);
3870
+ return new ZodEnum({
3871
+ ...def,
3872
+ checks: [],
3873
+ ...normalizeParams(params),
3874
+ entries: newEntries
3875
+ });
3876
+ };
3877
+ inst.exclude = (values, params) => {
3878
+ const newEntries = { ...def.entries };
3879
+ for (const value of values) if (keys.has(value)) delete newEntries[value];
3880
+ else throw new Error(`Key ${value} not found in enum`);
3881
+ return new ZodEnum({
3882
+ ...def,
3883
+ checks: [],
3884
+ ...normalizeParams(params),
3885
+ entries: newEntries
3886
+ });
3887
+ };
3888
+ });
3889
+ function _enum(values, params) {
3890
+ return new ZodEnum({
3891
+ type: "enum",
3892
+ entries: Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values,
3893
+ ...normalizeParams(params)
3894
+ });
3895
+ }
3896
+ var ZodLiteral = /*@__PURE__*/ $constructor("ZodLiteral", (inst, def) => {
3897
+ $ZodLiteral.init(inst, def);
3898
+ ZodType.init(inst, def);
3899
+ inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
3900
+ inst.values = new Set(def.values);
3901
+ Object.defineProperty(inst, "value", { get() {
3902
+ if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
3903
+ return def.values[0];
3904
+ } });
3905
+ });
3906
+ function literal(value, params) {
3907
+ return new ZodLiteral({
3908
+ type: "literal",
3909
+ values: Array.isArray(value) ? value : [value],
3910
+ ...normalizeParams(params)
3911
+ });
3912
+ }
3913
+ var ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
3914
+ $ZodTransform.init(inst, def);
3915
+ ZodType.init(inst, def);
3916
+ inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
3917
+ inst._zod.parse = (payload, _ctx) => {
3918
+ if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
3919
+ payload.addIssue = (issue$1) => {
3920
+ if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
3921
+ else {
3922
+ const _issue = issue$1;
3923
+ if (_issue.fatal) _issue.continue = false;
3924
+ _issue.code ?? (_issue.code = "custom");
3925
+ _issue.input ?? (_issue.input = payload.value);
3926
+ _issue.inst ?? (_issue.inst = inst);
3927
+ payload.issues.push(issue(_issue));
3928
+ }
3929
+ };
3930
+ const output = def.transform(payload.value, payload);
3931
+ if (output instanceof Promise) return output.then((output) => {
3932
+ payload.value = output;
3933
+ payload.fallback = true;
3934
+ return payload;
3935
+ });
3936
+ payload.value = output;
3937
+ payload.fallback = true;
3938
+ return payload;
3939
+ };
3940
+ });
3941
+ function transform(fn) {
3942
+ return new ZodTransform({
3943
+ type: "transform",
3944
+ transform: fn
3945
+ });
3946
+ }
3947
+ var ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
3948
+ $ZodOptional.init(inst, def);
3949
+ ZodType.init(inst, def);
3950
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3951
+ inst.unwrap = () => inst._zod.def.innerType;
3952
+ });
3953
+ function optional(innerType) {
3954
+ return new ZodOptional({
3955
+ type: "optional",
3956
+ innerType
3957
+ });
3958
+ }
3959
+ var ZodExactOptional = /*@__PURE__*/ $constructor("ZodExactOptional", (inst, def) => {
3960
+ $ZodExactOptional.init(inst, def);
3961
+ ZodType.init(inst, def);
3962
+ inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
3963
+ inst.unwrap = () => inst._zod.def.innerType;
3964
+ });
3965
+ function exactOptional(innerType) {
3966
+ return new ZodExactOptional({
3967
+ type: "optional",
3968
+ innerType
3969
+ });
3970
+ }
3971
+ var ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
3972
+ $ZodNullable.init(inst, def);
3973
+ ZodType.init(inst, def);
3974
+ inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
3975
+ inst.unwrap = () => inst._zod.def.innerType;
3976
+ });
3977
+ function nullable(innerType) {
3978
+ return new ZodNullable({
3979
+ type: "nullable",
3980
+ innerType
3981
+ });
3982
+ }
3983
+ var ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
3984
+ $ZodDefault.init(inst, def);
3985
+ ZodType.init(inst, def);
3986
+ inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
3987
+ inst.unwrap = () => inst._zod.def.innerType;
3988
+ inst.removeDefault = inst.unwrap;
3989
+ });
3990
+ function _default(innerType, defaultValue) {
3991
+ return new ZodDefault({
3992
+ type: "default",
3993
+ innerType,
3994
+ get defaultValue() {
3995
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
3996
+ }
3997
+ });
3998
+ }
3999
+ var ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
4000
+ $ZodPrefault.init(inst, def);
4001
+ ZodType.init(inst, def);
4002
+ inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
4003
+ inst.unwrap = () => inst._zod.def.innerType;
4004
+ });
4005
+ function prefault(innerType, defaultValue) {
4006
+ return new ZodPrefault({
4007
+ type: "prefault",
4008
+ innerType,
4009
+ get defaultValue() {
4010
+ return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
4011
+ }
4012
+ });
4013
+ }
4014
+ var ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
4015
+ $ZodNonOptional.init(inst, def);
4016
+ ZodType.init(inst, def);
4017
+ inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
4018
+ inst.unwrap = () => inst._zod.def.innerType;
4019
+ });
4020
+ function nonoptional(innerType, params) {
4021
+ return new ZodNonOptional({
4022
+ type: "nonoptional",
4023
+ innerType,
4024
+ ...normalizeParams(params)
4025
+ });
4026
+ }
4027
+ var ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
4028
+ $ZodCatch.init(inst, def);
4029
+ ZodType.init(inst, def);
4030
+ inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
4031
+ inst.unwrap = () => inst._zod.def.innerType;
4032
+ inst.removeCatch = inst.unwrap;
4033
+ });
4034
+ function _catch(innerType, catchValue) {
4035
+ return new ZodCatch({
4036
+ type: "catch",
4037
+ innerType,
4038
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
4039
+ });
4040
+ }
4041
+ var ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
4042
+ $ZodPipe.init(inst, def);
4043
+ ZodType.init(inst, def);
4044
+ inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
4045
+ inst.in = def.in;
4046
+ inst.out = def.out;
4047
+ });
4048
+ function pipe(in_, out) {
4049
+ return new ZodPipe({
4050
+ type: "pipe",
4051
+ in: in_,
4052
+ out
4053
+ });
4054
+ }
4055
+ var ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
4056
+ $ZodReadonly.init(inst, def);
4057
+ ZodType.init(inst, def);
4058
+ inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
4059
+ inst.unwrap = () => inst._zod.def.innerType;
4060
+ });
4061
+ function readonly(innerType) {
4062
+ return new ZodReadonly({
4063
+ type: "readonly",
4064
+ innerType
4065
+ });
4066
+ }
4067
+ var ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
4068
+ $ZodCustom.init(inst, def);
4069
+ ZodType.init(inst, def);
4070
+ inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
4071
+ });
4072
+ function refine(fn, _params = {}) {
4073
+ return /* @__PURE__ */ _refine(ZodCustom, fn, _params);
4074
+ }
4075
+ function superRefine(fn, params) {
4076
+ return /* @__PURE__ */ _superRefine(fn, params);
4077
+ }
4078
+ //#endregion
4079
+ //#region src/args.ts
4080
+ var IsoDateTimeWithOffset = string().refine(isIsoDateTimeWithOffset, { error: "must be an ISO 8601 date-time with a timezone offset (e.g. 2026-07-17T09:00:00+09:00)" });
4081
+ var GoogleArgs = discriminatedUnion("kind", [
4082
+ object({ kind: literal("status") }),
4083
+ object({
4084
+ kind: literal("calendarListEvents"),
4085
+ timeMin: IsoDateTimeWithOffset.optional(),
4086
+ maxResults: number().int().min(1).max(MAX_LIST_RESULTS).optional()
4087
+ }),
4088
+ object({
4089
+ kind: literal("calendarCreateEvent"),
4090
+ summary: string().min(1),
4091
+ start: IsoDateTimeWithOffset,
4092
+ end: IsoDateTimeWithOffset,
4093
+ description: string().optional()
4094
+ })
4095
+ ]);
4096
+ //#endregion
4097
+ //#region src/definition.ts
4098
+ var TOOL_DEFINITION = {
4099
+ type: "function",
4100
+ name: "google",
4101
+ prompt: "The user's Google account is linked LOCALLY on this machine — the refresh token lives in ~/.config/mulmoclaude/ and never reaches any cloud. This is independent of claude.ai Google connectors; the tool works without them. If a call fails with 'Google account not linked', ask the user to link it in Settings → Plugins → Google (or run `yarn google:auth`), then retry the original call.",
4102
+ description: "Operate the user's Google services through the locally linked Google account. Currently Google Calendar (the primary calendar). Supported kinds:\n - `status`: report whether the Google account is linked on this machine — call this first when unsure.\n - `calendarListEvents`: list upcoming events. Optional `timeMin` (ISO 8601 date-time with timezone offset; default now) and `maxResults` (1-50, default 10).\n - `calendarCreateEvent`: create an event. Requires `summary`, `start`, `end` — ISO 8601 date-times WITH a timezone offset (e.g. 2026-07-17T09:00:00+09:00); optional `description`.",
4103
+ parameters: {
4104
+ type: "object",
4105
+ properties: {
4106
+ kind: {
4107
+ type: "string",
4108
+ enum: [
4109
+ "status",
4110
+ "calendarListEvents",
4111
+ "calendarCreateEvent"
4112
+ ]
4113
+ },
4114
+ timeMin: {
4115
+ type: "string",
4116
+ description: "calendarListEvents: lower bound, ISO 8601 with timezone offset (default: now)"
4117
+ },
4118
+ maxResults: {
4119
+ type: "number",
4120
+ description: "calendarListEvents: max events to return, 1-50 (default 10)"
4121
+ },
4122
+ summary: {
4123
+ type: "string",
4124
+ description: "calendarCreateEvent: event title"
4125
+ },
4126
+ start: {
4127
+ type: "string",
4128
+ description: "calendarCreateEvent: start, ISO 8601 with timezone offset"
4129
+ },
4130
+ end: {
4131
+ type: "string",
4132
+ description: "calendarCreateEvent: end, ISO 8601 with timezone offset"
4133
+ },
4134
+ description: {
4135
+ type: "string",
4136
+ description: "calendarCreateEvent: optional event body"
4137
+ }
4138
+ },
4139
+ required: ["kind"]
4140
+ }
4141
+ };
4142
+ //#endregion
4143
+ //#region src/index.ts
4144
+ var LINK_GUIDANCE = "Ask the user to link their Google account in Settings → Plugins → Google (or run `yarn google:auth`), then retry.";
4145
+ var src_default = definePlugin(({ log }) => {
4146
+ return {
4147
+ TOOL_DEFINITION,
4148
+ async google(rawArgs) {
4149
+ const args = GoogleArgs.parse(rawArgs);
4150
+ switch (args.kind) {
4151
+ case "status": {
4152
+ const [tokens, clientSecret] = await Promise.all([loadGoogleTokens(), clientSecretPresence()]);
4153
+ const linked = Boolean(tokens?.refresh_token);
4154
+ return {
4155
+ ok: true,
4156
+ linked,
4157
+ clientSecret,
4158
+ ...linked ? {} : { guidance: LINK_GUIDANCE }
4159
+ };
4160
+ }
4161
+ case "calendarListEvents": return {
4162
+ ok: true,
4163
+ events: await listCalendarEvents(await getGoogleAccessToken(), {
4164
+ timeMin: args.timeMin,
4165
+ maxResults: args.maxResults ?? DEFAULT_LIST_MAX_RESULTS
4166
+ })
4167
+ };
4168
+ case "calendarCreateEvent": {
4169
+ const event = await createCalendarEvent(await getGoogleAccessToken(), {
4170
+ summary: args.summary,
4171
+ startDateTime: args.start,
4172
+ endDateTime: args.end,
4173
+ description: args.description
4174
+ });
4175
+ log.info("calendar event created", { id: event.id });
4176
+ return {
4177
+ ok: true,
4178
+ event
4179
+ };
4180
+ }
4181
+ default: throw new Error(`unknown kind: ${JSON.stringify(args)}`);
4182
+ }
4183
+ }
4184
+ };
4185
+ });
4186
+ //#endregion
4187
+ export { TOOL_DEFINITION, src_default as default };
4188
+
4189
+ //# sourceMappingURL=index.js.map