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