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