@majeanson/lac 1.0.2 → 3.0.1

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