dsh-draw 0.1.0

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