@eum-agent/session-todo 1.0.1 → 1.2.0

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