@opentabs-dev/opentabs-plugin-fiverr 0.0.109 → 0.0.110

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.
@@ -6,451 +6,6 @@
6
6
  __defProp(target, name, { get: all[name], enumerable: true });
7
7
  };
8
8
 
9
- // node_modules/@opentabs-dev/shared/dist/error.js
10
- var toErrorMessage = (err2) => err2 instanceof Error ? err2.message : String(err2);
11
-
12
- // node_modules/@opentabs-dev/plugin-sdk/dist/errors.js
13
- var ToolError = class _ToolError extends Error {
14
- code;
15
- /** Whether this error is retryable (defaults to false). */
16
- retryable;
17
- /** Suggested delay before retrying, in milliseconds. */
18
- retryAfterMs;
19
- /** Error category for structured error classification. */
20
- category;
21
- constructor(message, code, opts) {
22
- super(message);
23
- this.code = code;
24
- this.name = "ToolError";
25
- this.retryable = opts?.retryable ?? false;
26
- this.retryAfterMs = opts?.retryAfterMs;
27
- this.category = opts?.category;
28
- }
29
- /** Authentication or authorization error (not retryable). Accepts an optional domain-specific code. */
30
- static auth(message, code) {
31
- return new _ToolError(message, code ?? "AUTH_ERROR", { category: "auth", retryable: false });
32
- }
33
- /** Resource not found (not retryable). Accepts an optional domain-specific code. */
34
- static notFound(message, code) {
35
- return new _ToolError(message, code ?? "NOT_FOUND", { category: "not_found", retryable: false });
36
- }
37
- /** Rate limited (retryable). Accepts an optional retry delay in milliseconds and an optional domain-specific code. */
38
- static rateLimited(message, retryAfterMs, code) {
39
- return new _ToolError(message, code ?? "RATE_LIMITED", { category: "rate_limit", retryable: true, retryAfterMs });
40
- }
41
- /** Input validation error (not retryable). Accepts an optional domain-specific code. */
42
- static validation(message, code) {
43
- return new _ToolError(message, code ?? "VALIDATION_ERROR", { category: "validation", retryable: false });
44
- }
45
- /** Operation timed out (retryable). Accepts an optional domain-specific code. */
46
- static timeout(message, code) {
47
- return new _ToolError(message, code ?? "TIMEOUT", { category: "timeout", retryable: true });
48
- }
49
- /** Internal/unexpected error (not retryable). Accepts an optional domain-specific code. */
50
- static internal(message, code) {
51
- return new _ToolError(message, code ?? "INTERNAL_ERROR", { category: "internal", retryable: false });
52
- }
53
- };
54
-
55
- // node_modules/@opentabs-dev/plugin-sdk/dist/fetch.js
56
- var MAX_ERROR_BODY_LENGTH = 512;
57
- var httpStatusToToolError = (response, message) => {
58
- const status = response.status;
59
- if (status === 401 || status === 403) {
60
- return ToolError.auth(message);
61
- }
62
- if (status === 404) {
63
- return ToolError.notFound(message);
64
- }
65
- if (status === 429) {
66
- const retryAfter = response.headers.get("Retry-After");
67
- const retryAfterMs = retryAfter !== null ? parseRetryAfterMs(retryAfter) : void 0;
68
- return ToolError.rateLimited(message, retryAfterMs);
69
- }
70
- if (status === 400 || status === 422) {
71
- return ToolError.validation(message);
72
- }
73
- if (status === 408) {
74
- return ToolError.timeout(message);
75
- }
76
- if (status >= 500) {
77
- const TRANSIENT_5XX = /* @__PURE__ */ new Set([500, 502, 503, 504]);
78
- const retryable = TRANSIENT_5XX.has(status);
79
- const retryAfter = status === 503 ? response.headers.get("Retry-After") : null;
80
- const retryAfterMs = retryAfter !== null ? parseRetryAfterMs(retryAfter) : void 0;
81
- return new ToolError(message, "http_error", { category: "internal", retryable, retryAfterMs });
82
- }
83
- if (status >= 400 && status < 500) {
84
- return new ToolError(message, "http_error", { retryable: false });
85
- }
86
- return new ToolError(message, "http_error", { category: "internal" });
87
- };
88
- var parseRetryAfterMs = (value) => {
89
- const seconds = Number(value);
90
- if (!Number.isNaN(seconds) && seconds >= 0) {
91
- return seconds * 1e3;
92
- }
93
- const date5 = Date.parse(value);
94
- if (!Number.isNaN(date5)) {
95
- const ms = date5 - Date.now();
96
- return ms > 0 ? ms : void 0;
97
- }
98
- return void 0;
99
- };
100
- var buildQueryString = (params) => {
101
- const searchParams = new URLSearchParams();
102
- for (const [key, value] of Object.entries(params)) {
103
- if (value === void 0)
104
- continue;
105
- if (Array.isArray(value)) {
106
- for (const item of value) {
107
- searchParams.append(key, String(item));
108
- }
109
- } else {
110
- searchParams.append(key, String(value));
111
- }
112
- }
113
- return searchParams.toString();
114
- };
115
- var fetchFromPage = async (url2, init) => {
116
- const { timeout = 3e4, signal, ...rest } = init ?? {};
117
- const timeoutSignal = AbortSignal.timeout(timeout);
118
- const combinedSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
119
- let response;
120
- try {
121
- response = await fetch(url2, {
122
- credentials: "include",
123
- ...rest,
124
- signal: combinedSignal
125
- });
126
- } catch (error51) {
127
- if (error51 instanceof DOMException && error51.name === "TimeoutError") {
128
- throw ToolError.timeout(`fetchFromPage: request timed out after ${timeout}ms for ${url2}`);
129
- }
130
- if (combinedSignal.aborted) {
131
- throw new ToolError(`fetchFromPage: request aborted for ${url2}`, "aborted");
132
- }
133
- throw new ToolError(`fetchFromPage: network error for ${url2}: ${toErrorMessage(error51)}`, "network_error", {
134
- category: "internal",
135
- retryable: true
136
- });
137
- }
138
- if (!response.ok) {
139
- const rawText = await response.text().catch(() => response.statusText);
140
- const errorText = rawText.length > MAX_ERROR_BODY_LENGTH ? `${rawText.slice(0, MAX_ERROR_BODY_LENGTH)}\u2026` : rawText;
141
- const msg = `fetchFromPage: HTTP ${response.status} for ${url2}: ${errorText}`;
142
- throw httpStatusToToolError(response, msg);
143
- }
144
- return response;
145
- };
146
-
147
- // node_modules/@opentabs-dev/plugin-sdk/dist/timing.js
148
- var waitUntil = (predicate, opts) => {
149
- const interval = opts?.interval ?? 200;
150
- const timeout = opts?.timeout ?? 1e4;
151
- const signal = opts?.signal;
152
- const abortReason = () => signal?.reason instanceof Error ? signal.reason : new Error("waitUntil: aborted");
153
- if (signal?.aborted)
154
- return Promise.reject(abortReason());
155
- return new Promise((resolve, reject) => {
156
- let settled = false;
157
- let poller;
158
- let lastPredicateError;
159
- const isSettled = () => settled;
160
- const cleanup = () => {
161
- settled = true;
162
- clearTimeout(timer);
163
- clearTimeout(poller);
164
- signal?.removeEventListener("abort", onAbort);
165
- };
166
- const onAbort = () => {
167
- if (isSettled())
168
- return;
169
- cleanup();
170
- reject(abortReason());
171
- };
172
- signal?.addEventListener("abort", onAbort, { once: true });
173
- const timer = setTimeout(() => {
174
- if (isSettled())
175
- return;
176
- cleanup();
177
- const errorContext = lastPredicateError instanceof Error ? `: predicate last threw \u2014 ${lastPredicateError.message}` : "";
178
- reject(new Error(`waitUntil: timed out after ${timeout}ms waiting for predicate to return true${errorContext}`));
179
- }, timeout);
180
- const check2 = async () => {
181
- if (isSettled())
182
- return;
183
- try {
184
- const result = await predicate();
185
- if (result) {
186
- cleanup();
187
- resolve();
188
- return;
189
- }
190
- } catch (err2) {
191
- lastPredicateError = err2;
192
- }
193
- if (!isSettled()) {
194
- poller = setTimeout(() => void check2(), interval);
195
- }
196
- };
197
- void check2();
198
- });
199
- };
200
-
201
- // node_modules/@opentabs-dev/plugin-sdk/dist/log.js
202
- var MAX_DATA_LENGTH = 10;
203
- var MAX_STRING_LENGTH = 4096;
204
- var MAX_SERIALIZED_SIZE = 64 * 1024;
205
- var safeSerializeArg = (value) => {
206
- try {
207
- if (value === null || value === void 0)
208
- return value;
209
- const type = typeof value;
210
- if (type === "boolean" || type === "number")
211
- return value;
212
- if (type === "string") {
213
- return value.length > MAX_STRING_LENGTH ? `${value.slice(0, MAX_STRING_LENGTH)}\u2026` : value;
214
- }
215
- if (type === "function")
216
- return `[Function: ${value.name || "anonymous"}]`;
217
- if (type === "symbol")
218
- return `[Symbol: ${value.description ?? ""}]`;
219
- if (type === "bigint")
220
- return `[BigInt: ${value.toString()}]`;
221
- if (typeof value.nodeType === "number" && typeof value.nodeName === "string") {
222
- try {
223
- const node = value;
224
- let classStr = "";
225
- if (typeof node.className === "string") {
226
- classStr = node.className ? `.${node.className.split(" ")[0] ?? ""}` : "";
227
- } else if (node.className !== null && typeof node.className === "object") {
228
- const baseVal = node.className.baseVal;
229
- if (typeof baseVal === "string") {
230
- classStr = baseVal ? `.${baseVal.split(" ")[0] ?? ""}` : "";
231
- }
232
- }
233
- return `[${node.nodeName}${node.id ? `#${node.id}` : ""}${classStr}]`;
234
- } catch {
235
- }
236
- }
237
- if (value instanceof Error) {
238
- return { name: value.name, message: value.message, stack: value.stack };
239
- }
240
- if (value instanceof WeakRef)
241
- return "[WeakRef]";
242
- if (value instanceof WeakMap)
243
- return "[WeakMap]";
244
- if (value instanceof WeakSet)
245
- return "[WeakSet]";
246
- if (value instanceof ArrayBuffer)
247
- return "[ArrayBuffer]";
248
- if (typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer)
249
- return "[SharedArrayBuffer]";
250
- try {
251
- const seen = /* @__PURE__ */ new WeakSet();
252
- const json2 = JSON.stringify(value, (_key, v) => {
253
- if (typeof v === "object" && v !== null) {
254
- if (seen.has(v))
255
- return "[Circular]";
256
- seen.add(v);
257
- }
258
- if (typeof v === "function")
259
- return `[Function: ${v.name || "anonymous"}]`;
260
- if (typeof v === "bigint")
261
- return `[BigInt: ${v.toString()}]`;
262
- if (typeof v === "symbol")
263
- return `[Symbol: ${v.description ?? ""}]`;
264
- if (v instanceof WeakRef)
265
- return "[WeakRef]";
266
- if (v instanceof WeakMap)
267
- return "[WeakMap]";
268
- if (v instanceof WeakSet)
269
- return "[WeakSet]";
270
- if (v instanceof ArrayBuffer)
271
- return "[ArrayBuffer]";
272
- if (typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer)
273
- return "[SharedArrayBuffer]";
274
- return v;
275
- });
276
- if (json2.length > MAX_SERIALIZED_SIZE) {
277
- return `[Object truncated: ${json2.length} chars]`;
278
- }
279
- return JSON.parse(json2);
280
- } catch {
281
- return `[Unserializable: ${typeof value}]`;
282
- }
283
- } catch {
284
- return `[Unserializable: ${typeof value}]`;
285
- }
286
- };
287
- var safeSerialize = (args) => {
288
- const capped = args.length > MAX_DATA_LENGTH ? args.slice(0, MAX_DATA_LENGTH) : args;
289
- return capped.map(safeSerializeArg);
290
- };
291
- var CONSOLE_METHODS = {
292
- debug: "debug",
293
- info: "info",
294
- warning: "warn",
295
- error: "error"
296
- };
297
- var defaultTransport = (entry) => {
298
- const method = CONSOLE_METHODS[entry.level];
299
- console[method](`[sdk.log] ${entry.message}`, ...entry.data);
300
- };
301
- var activeTransport = defaultTransport;
302
- var _setLogTransport = (transport) => {
303
- const previous = activeTransport;
304
- activeTransport = transport;
305
- return () => {
306
- if (activeTransport === transport)
307
- activeTransport = previous;
308
- };
309
- };
310
- var makeLogMethod = (level) => (message, ...args) => {
311
- const entry = {
312
- level,
313
- message,
314
- data: safeSerialize(args),
315
- ts: (/* @__PURE__ */ new Date()).toISOString()
316
- };
317
- activeTransport(entry);
318
- };
319
- var log = Object.freeze({
320
- debug: makeLogMethod("debug"),
321
- info: makeLogMethod("info"),
322
- warn: makeLogMethod("warning"),
323
- error: makeLogMethod("error")
324
- });
325
- var ot = globalThis.__openTabs ?? {};
326
- globalThis.__openTabs = ot;
327
- ot._setLogTransport = _setLogTransport;
328
- ot.log = log;
329
-
330
- // node_modules/@opentabs-dev/plugin-sdk/dist/page-state.js
331
- var BLOCKED_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
332
- var getPageGlobal = (path) => {
333
- try {
334
- const segments = path.split(".");
335
- let current = globalThis;
336
- for (const segment of segments) {
337
- if (current === null || current === void 0)
338
- return void 0;
339
- if (typeof current !== "object" && typeof current !== "function")
340
- return void 0;
341
- if (BLOCKED_SEGMENTS.has(segment))
342
- return void 0;
343
- current = current[segment];
344
- }
345
- return current;
346
- } catch {
347
- return void 0;
348
- }
349
- };
350
- var getCurrentUrl = () => window.location.href;
351
- var getPageTitle = () => document.title;
352
-
353
- // node_modules/@opentabs-dev/plugin-sdk/dist/index.js
354
- var defineTool = (config2) => config2;
355
- var OpenTabsPlugin = class {
356
- /**
357
- * Chrome match patterns for URLs that should NOT match this plugin.
358
- * Tabs matching both urlPatterns and excludePatterns are excluded.
359
- * Useful when a broad urlPattern overlaps with another plugin's domain.
360
- * @see https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns
361
- */
362
- excludePatterns;
363
- /**
364
- * URL to open when no matching tab exists and the user triggers an
365
- * 'open tab' action from the side panel. Should be a concrete URL
366
- * (e.g., 'https://github.com'), not a match pattern.
367
- */
368
- homepage;
369
- /** Typed configuration schema — declares settings that users provide via config.json or the side panel. */
370
- configSchema;
371
- };
372
-
373
- // src/fiverr-api.ts
374
- var getContext = () => {
375
- const userId = getPageGlobal("initialData.FiverrContext.userId");
376
- if (!userId || userId <= 0) return null;
377
- return {
378
- userId,
379
- userGuid: getPageGlobal("initialData.FiverrContext.userGuid") ?? "",
380
- csrfToken: getPageGlobal("initialData.FiverrContext.csrfToken") ?? "",
381
- currency: getPageGlobal("initialData.FiverrContext.currency") ?? "USD",
382
- countryCode: getPageGlobal("initialData.FiverrContext.countryCode") ?? "",
383
- locale: getPageGlobal("initialData.FiverrContext.locale") ?? "",
384
- isPro: getPageGlobal("initialData.FiverrContext.isPro") ?? false
385
- };
386
- };
387
- var getUsername = () => getPageGlobal("initialData.UserActivationMessage.username") ?? getPageGlobal("initialData.FloatingChat.currentUsername") ?? "";
388
- var isAuthenticated = () => getContext() !== null;
389
- var waitForAuth = () => waitUntil(() => isAuthenticated(), { interval: 500, timeout: 5e3 }).then(
390
- () => true,
391
- () => false
392
- );
393
- var requireContext = () => {
394
- const ctx = getContext();
395
- if (!ctx) throw ToolError.auth("Not authenticated \u2014 please log in to Fiverr.");
396
- return ctx;
397
- };
398
- var normalizeFiverrUsername = (value, fieldName = "username") => {
399
- const username = value.trim().replace(/^[@/]+/, "");
400
- if (!username) throw ToolError.validation(`${fieldName} is required.`);
401
- if (username.includes("/")) {
402
- throw ToolError.validation(`${fieldName} must be a single Fiverr username with no slashes.`);
403
- }
404
- return username;
405
- };
406
- var PERSEUS_ISLAND_RE = /<script[^>]*id="perseus-initial-props"[^>]*>([\s\S]*?)<\/script>/;
407
- var fetchPerseusProps = async (path) => {
408
- requireContext();
409
- const response = await fetchFromPage(path, { headers: { Accept: "text/html" } });
410
- if (!response.ok) throw httpStatusToToolError(response, `Failed to load ${path}`);
411
- const html = await response.text();
412
- const match = html.match(PERSEUS_ISLAND_RE);
413
- if (!match?.[1]) throw ToolError.notFound(`No page data found at ${path} \u2014 it may not exist or require login.`);
414
- try {
415
- return JSON.parse(match[1]);
416
- } catch {
417
- throw ToolError.internal(`Failed to parse page data at ${path}`);
418
- }
419
- };
420
- var fetchInboxJson = async (path) => {
421
- requireContext();
422
- const response = await fetchFromPage(path, {
423
- headers: { Accept: "application/json", "X-Requested-With": "XMLHttpRequest" }
424
- });
425
- if (!response.ok) throw httpStatusToToolError(response, `Failed to load ${path}`);
426
- if (response.status === 204) return null;
427
- return await response.json();
428
- };
429
- var SEND_MESSAGE_PATH = "/inbox/conversations/messages";
430
- var sendInboxMessage = async (recipientUsername, body) => {
431
- const ctx = requireContext();
432
- const response = await fetchFromPage(SEND_MESSAGE_PATH, {
433
- method: "POST",
434
- headers: {
435
- Accept: "application/json",
436
- "Content-Type": "application/json",
437
- "X-Requested-With": "XMLHttpRequest",
438
- "X-CSRF-Token": ctx.csrfToken
439
- },
440
- body: JSON.stringify({
441
- content_blocks: [{ type: "text", plain_text: body, plain_text_format: null }],
442
- content_type: "text",
443
- participants_usernames: [recipientUsername],
444
- channel_id: null,
445
- pending_attachment_ids: []
446
- })
447
- });
448
- if (!response.ok) throw httpStatusToToolError(response, "Failed to send message");
449
- if (response.status === 204) return { messageId: "" };
450
- const data = await response.json();
451
- return { messageId: data.id ?? data.message?.id ?? "" };
452
- };
453
-
454
9
  // node_modules/zod/v4/classic/external.js
455
10
  var external_exports = {};
456
11
  __export(external_exports, {
@@ -13527,1443 +13082,1888 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
13527
13082
  $ZodCIDRv6.init(inst, def);
13528
13083
  ZodStringFormat.init(inst, def);
13529
13084
  });
13530
- function cidrv62(params) {
13531
- return _cidrv6(ZodCIDRv6, params);
13085
+ function cidrv62(params) {
13086
+ return _cidrv6(ZodCIDRv6, params);
13087
+ }
13088
+ var ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
13089
+ $ZodBase64.init(inst, def);
13090
+ ZodStringFormat.init(inst, def);
13091
+ });
13092
+ function base642(params) {
13093
+ return _base64(ZodBase64, params);
13094
+ }
13095
+ var ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
13096
+ $ZodBase64URL.init(inst, def);
13097
+ ZodStringFormat.init(inst, def);
13098
+ });
13099
+ function base64url2(params) {
13100
+ return _base64url(ZodBase64URL, params);
13101
+ }
13102
+ var ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
13103
+ $ZodE164.init(inst, def);
13104
+ ZodStringFormat.init(inst, def);
13105
+ });
13106
+ function e1642(params) {
13107
+ return _e164(ZodE164, params);
13108
+ }
13109
+ var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
13110
+ $ZodJWT.init(inst, def);
13111
+ ZodStringFormat.init(inst, def);
13112
+ });
13113
+ function jwt(params) {
13114
+ return _jwt(ZodJWT, params);
13115
+ }
13116
+ var ZodCustomStringFormat = /* @__PURE__ */ $constructor("ZodCustomStringFormat", (inst, def) => {
13117
+ $ZodCustomStringFormat.init(inst, def);
13118
+ ZodStringFormat.init(inst, def);
13119
+ });
13120
+ function stringFormat(format, fnOrRegex, _params = {}) {
13121
+ return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
13122
+ }
13123
+ function hostname2(_params) {
13124
+ return _stringFormat(ZodCustomStringFormat, "hostname", regexes_exports.hostname, _params);
13125
+ }
13126
+ function hex2(_params) {
13127
+ return _stringFormat(ZodCustomStringFormat, "hex", regexes_exports.hex, _params);
13128
+ }
13129
+ function hash(alg, params) {
13130
+ const enc = params?.enc ?? "hex";
13131
+ const format = `${alg}_${enc}`;
13132
+ const regex = regexes_exports[format];
13133
+ if (!regex)
13134
+ throw new Error(`Unrecognized hash format: ${format}`);
13135
+ return _stringFormat(ZodCustomStringFormat, format, regex, params);
13136
+ }
13137
+ var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
13138
+ $ZodNumber.init(inst, def);
13139
+ ZodType.init(inst, def);
13140
+ inst._zod.processJSONSchema = (ctx, json2, params) => numberProcessor(inst, ctx, json2, params);
13141
+ _installLazyMethods(inst, "ZodNumber", {
13142
+ gt(value, params) {
13143
+ return this.check(_gt(value, params));
13144
+ },
13145
+ gte(value, params) {
13146
+ return this.check(_gte(value, params));
13147
+ },
13148
+ min(value, params) {
13149
+ return this.check(_gte(value, params));
13150
+ },
13151
+ lt(value, params) {
13152
+ return this.check(_lt(value, params));
13153
+ },
13154
+ lte(value, params) {
13155
+ return this.check(_lte(value, params));
13156
+ },
13157
+ max(value, params) {
13158
+ return this.check(_lte(value, params));
13159
+ },
13160
+ int(params) {
13161
+ return this.check(int(params));
13162
+ },
13163
+ safe(params) {
13164
+ return this.check(int(params));
13165
+ },
13166
+ positive(params) {
13167
+ return this.check(_gt(0, params));
13168
+ },
13169
+ nonnegative(params) {
13170
+ return this.check(_gte(0, params));
13171
+ },
13172
+ negative(params) {
13173
+ return this.check(_lt(0, params));
13174
+ },
13175
+ nonpositive(params) {
13176
+ return this.check(_lte(0, params));
13177
+ },
13178
+ multipleOf(value, params) {
13179
+ return this.check(_multipleOf(value, params));
13180
+ },
13181
+ step(value, params) {
13182
+ return this.check(_multipleOf(value, params));
13183
+ },
13184
+ finite() {
13185
+ return this;
13186
+ }
13187
+ });
13188
+ const bag = inst._zod.bag;
13189
+ inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
13190
+ inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
13191
+ inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
13192
+ inst.isFinite = true;
13193
+ inst.format = bag.format ?? null;
13194
+ });
13195
+ function number2(params) {
13196
+ return _number(ZodNumber, params);
13197
+ }
13198
+ var ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
13199
+ $ZodNumberFormat.init(inst, def);
13200
+ ZodNumber.init(inst, def);
13201
+ });
13202
+ function int(params) {
13203
+ return _int(ZodNumberFormat, params);
13204
+ }
13205
+ function float32(params) {
13206
+ return _float32(ZodNumberFormat, params);
13207
+ }
13208
+ function float64(params) {
13209
+ return _float64(ZodNumberFormat, params);
13210
+ }
13211
+ function int32(params) {
13212
+ return _int32(ZodNumberFormat, params);
13213
+ }
13214
+ function uint32(params) {
13215
+ return _uint32(ZodNumberFormat, params);
13216
+ }
13217
+ var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
13218
+ $ZodBoolean.init(inst, def);
13219
+ ZodType.init(inst, def);
13220
+ inst._zod.processJSONSchema = (ctx, json2, params) => booleanProcessor(inst, ctx, json2, params);
13221
+ });
13222
+ function boolean2(params) {
13223
+ return _boolean(ZodBoolean, params);
13224
+ }
13225
+ var ZodBigInt = /* @__PURE__ */ $constructor("ZodBigInt", (inst, def) => {
13226
+ $ZodBigInt.init(inst, def);
13227
+ ZodType.init(inst, def);
13228
+ inst._zod.processJSONSchema = (ctx, json2, params) => bigintProcessor(inst, ctx, json2, params);
13229
+ inst.gte = (value, params) => inst.check(_gte(value, params));
13230
+ inst.min = (value, params) => inst.check(_gte(value, params));
13231
+ inst.gt = (value, params) => inst.check(_gt(value, params));
13232
+ inst.gte = (value, params) => inst.check(_gte(value, params));
13233
+ inst.min = (value, params) => inst.check(_gte(value, params));
13234
+ inst.lt = (value, params) => inst.check(_lt(value, params));
13235
+ inst.lte = (value, params) => inst.check(_lte(value, params));
13236
+ inst.max = (value, params) => inst.check(_lte(value, params));
13237
+ inst.positive = (params) => inst.check(_gt(BigInt(0), params));
13238
+ inst.negative = (params) => inst.check(_lt(BigInt(0), params));
13239
+ inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
13240
+ inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
13241
+ inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
13242
+ const bag = inst._zod.bag;
13243
+ inst.minValue = bag.minimum ?? null;
13244
+ inst.maxValue = bag.maximum ?? null;
13245
+ inst.format = bag.format ?? null;
13246
+ });
13247
+ function bigint2(params) {
13248
+ return _bigint(ZodBigInt, params);
13249
+ }
13250
+ var ZodBigIntFormat = /* @__PURE__ */ $constructor("ZodBigIntFormat", (inst, def) => {
13251
+ $ZodBigIntFormat.init(inst, def);
13252
+ ZodBigInt.init(inst, def);
13253
+ });
13254
+ function int64(params) {
13255
+ return _int64(ZodBigIntFormat, params);
13256
+ }
13257
+ function uint64(params) {
13258
+ return _uint64(ZodBigIntFormat, params);
13259
+ }
13260
+ var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
13261
+ $ZodSymbol.init(inst, def);
13262
+ ZodType.init(inst, def);
13263
+ inst._zod.processJSONSchema = (ctx, json2, params) => symbolProcessor(inst, ctx, json2, params);
13264
+ });
13265
+ function symbol(params) {
13266
+ return _symbol(ZodSymbol, params);
13532
13267
  }
13533
- var ZodBase64 = /* @__PURE__ */ $constructor("ZodBase64", (inst, def) => {
13534
- $ZodBase64.init(inst, def);
13535
- ZodStringFormat.init(inst, def);
13268
+ var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
13269
+ $ZodUndefined.init(inst, def);
13270
+ ZodType.init(inst, def);
13271
+ inst._zod.processJSONSchema = (ctx, json2, params) => undefinedProcessor(inst, ctx, json2, params);
13536
13272
  });
13537
- function base642(params) {
13538
- return _base64(ZodBase64, params);
13273
+ function _undefined3(params) {
13274
+ return _undefined2(ZodUndefined, params);
13539
13275
  }
13540
- var ZodBase64URL = /* @__PURE__ */ $constructor("ZodBase64URL", (inst, def) => {
13541
- $ZodBase64URL.init(inst, def);
13542
- ZodStringFormat.init(inst, def);
13276
+ var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
13277
+ $ZodNull.init(inst, def);
13278
+ ZodType.init(inst, def);
13279
+ inst._zod.processJSONSchema = (ctx, json2, params) => nullProcessor(inst, ctx, json2, params);
13543
13280
  });
13544
- function base64url2(params) {
13545
- return _base64url(ZodBase64URL, params);
13281
+ function _null3(params) {
13282
+ return _null2(ZodNull, params);
13546
13283
  }
13547
- var ZodE164 = /* @__PURE__ */ $constructor("ZodE164", (inst, def) => {
13548
- $ZodE164.init(inst, def);
13549
- ZodStringFormat.init(inst, def);
13284
+ var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
13285
+ $ZodAny.init(inst, def);
13286
+ ZodType.init(inst, def);
13287
+ inst._zod.processJSONSchema = (ctx, json2, params) => anyProcessor(inst, ctx, json2, params);
13550
13288
  });
13551
- function e1642(params) {
13552
- return _e164(ZodE164, params);
13289
+ function any() {
13290
+ return _any(ZodAny);
13553
13291
  }
13554
- var ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
13555
- $ZodJWT.init(inst, def);
13556
- ZodStringFormat.init(inst, def);
13292
+ var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
13293
+ $ZodUnknown.init(inst, def);
13294
+ ZodType.init(inst, def);
13295
+ inst._zod.processJSONSchema = (ctx, json2, params) => unknownProcessor(inst, ctx, json2, params);
13557
13296
  });
13558
- function jwt(params) {
13559
- return _jwt(ZodJWT, params);
13297
+ function unknown() {
13298
+ return _unknown(ZodUnknown);
13560
13299
  }
13561
- var ZodCustomStringFormat = /* @__PURE__ */ $constructor("ZodCustomStringFormat", (inst, def) => {
13562
- $ZodCustomStringFormat.init(inst, def);
13563
- ZodStringFormat.init(inst, def);
13300
+ var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
13301
+ $ZodNever.init(inst, def);
13302
+ ZodType.init(inst, def);
13303
+ inst._zod.processJSONSchema = (ctx, json2, params) => neverProcessor(inst, ctx, json2, params);
13564
13304
  });
13565
- function stringFormat(format, fnOrRegex, _params = {}) {
13566
- return _stringFormat(ZodCustomStringFormat, format, fnOrRegex, _params);
13567
- }
13568
- function hostname2(_params) {
13569
- return _stringFormat(ZodCustomStringFormat, "hostname", regexes_exports.hostname, _params);
13305
+ function never(params) {
13306
+ return _never(ZodNever, params);
13570
13307
  }
13571
- function hex2(_params) {
13572
- return _stringFormat(ZodCustomStringFormat, "hex", regexes_exports.hex, _params);
13308
+ var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
13309
+ $ZodVoid.init(inst, def);
13310
+ ZodType.init(inst, def);
13311
+ inst._zod.processJSONSchema = (ctx, json2, params) => voidProcessor(inst, ctx, json2, params);
13312
+ });
13313
+ function _void2(params) {
13314
+ return _void(ZodVoid, params);
13573
13315
  }
13574
- function hash(alg, params) {
13575
- const enc = params?.enc ?? "hex";
13576
- const format = `${alg}_${enc}`;
13577
- const regex = regexes_exports[format];
13578
- if (!regex)
13579
- throw new Error(`Unrecognized hash format: ${format}`);
13580
- return _stringFormat(ZodCustomStringFormat, format, regex, params);
13316
+ var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
13317
+ $ZodDate.init(inst, def);
13318
+ ZodType.init(inst, def);
13319
+ inst._zod.processJSONSchema = (ctx, json2, params) => dateProcessor(inst, ctx, json2, params);
13320
+ inst.min = (value, params) => inst.check(_gte(value, params));
13321
+ inst.max = (value, params) => inst.check(_lte(value, params));
13322
+ const c = inst._zod.bag;
13323
+ inst.minDate = c.minimum ? new Date(c.minimum) : null;
13324
+ inst.maxDate = c.maximum ? new Date(c.maximum) : null;
13325
+ });
13326
+ function date3(params) {
13327
+ return _date(ZodDate, params);
13581
13328
  }
13582
- var ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
13583
- $ZodNumber.init(inst, def);
13329
+ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
13330
+ $ZodArray.init(inst, def);
13584
13331
  ZodType.init(inst, def);
13585
- inst._zod.processJSONSchema = (ctx, json2, params) => numberProcessor(inst, ctx, json2, params);
13586
- _installLazyMethods(inst, "ZodNumber", {
13587
- gt(value, params) {
13588
- return this.check(_gt(value, params));
13332
+ inst._zod.processJSONSchema = (ctx, json2, params) => arrayProcessor(inst, ctx, json2, params);
13333
+ inst.element = def.element;
13334
+ _installLazyMethods(inst, "ZodArray", {
13335
+ min(n, params) {
13336
+ return this.check(_minLength(n, params));
13589
13337
  },
13590
- gte(value, params) {
13591
- return this.check(_gte(value, params));
13338
+ nonempty(params) {
13339
+ return this.check(_minLength(1, params));
13592
13340
  },
13593
- min(value, params) {
13594
- return this.check(_gte(value, params));
13341
+ max(n, params) {
13342
+ return this.check(_maxLength(n, params));
13595
13343
  },
13596
- lt(value, params) {
13597
- return this.check(_lt(value, params));
13344
+ length(n, params) {
13345
+ return this.check(_length(n, params));
13598
13346
  },
13599
- lte(value, params) {
13600
- return this.check(_lte(value, params));
13347
+ unwrap() {
13348
+ return this.element;
13349
+ }
13350
+ });
13351
+ });
13352
+ function array(element, params) {
13353
+ return _array(ZodArray, element, params);
13354
+ }
13355
+ function keyof(schema) {
13356
+ const shape = schema._zod.def.shape;
13357
+ return _enum2(Object.keys(shape));
13358
+ }
13359
+ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
13360
+ $ZodObjectJIT.init(inst, def);
13361
+ ZodType.init(inst, def);
13362
+ inst._zod.processJSONSchema = (ctx, json2, params) => objectProcessor(inst, ctx, json2, params);
13363
+ util_exports.defineLazy(inst, "shape", () => {
13364
+ return def.shape;
13365
+ });
13366
+ _installLazyMethods(inst, "ZodObject", {
13367
+ keyof() {
13368
+ return _enum2(Object.keys(this._zod.def.shape));
13601
13369
  },
13602
- max(value, params) {
13603
- return this.check(_lte(value, params));
13370
+ catchall(catchall) {
13371
+ return this.clone({ ...this._zod.def, catchall });
13604
13372
  },
13605
- int(params) {
13606
- return this.check(int(params));
13373
+ passthrough() {
13374
+ return this.clone({ ...this._zod.def, catchall: unknown() });
13607
13375
  },
13608
- safe(params) {
13609
- return this.check(int(params));
13376
+ loose() {
13377
+ return this.clone({ ...this._zod.def, catchall: unknown() });
13610
13378
  },
13611
- positive(params) {
13612
- return this.check(_gt(0, params));
13379
+ strict() {
13380
+ return this.clone({ ...this._zod.def, catchall: never() });
13613
13381
  },
13614
- nonnegative(params) {
13615
- return this.check(_gte(0, params));
13382
+ strip() {
13383
+ return this.clone({ ...this._zod.def, catchall: void 0 });
13616
13384
  },
13617
- negative(params) {
13618
- return this.check(_lt(0, params));
13385
+ extend(incoming) {
13386
+ return util_exports.extend(this, incoming);
13619
13387
  },
13620
- nonpositive(params) {
13621
- return this.check(_lte(0, params));
13388
+ safeExtend(incoming) {
13389
+ return util_exports.safeExtend(this, incoming);
13622
13390
  },
13623
- multipleOf(value, params) {
13624
- return this.check(_multipleOf(value, params));
13391
+ merge(other) {
13392
+ return util_exports.merge(this, other);
13625
13393
  },
13626
- step(value, params) {
13627
- return this.check(_multipleOf(value, params));
13394
+ pick(mask) {
13395
+ return util_exports.pick(this, mask);
13628
13396
  },
13629
- finite() {
13630
- return this;
13397
+ omit(mask) {
13398
+ return util_exports.omit(this, mask);
13399
+ },
13400
+ partial(...args) {
13401
+ return util_exports.partial(ZodOptional, this, args[0]);
13402
+ },
13403
+ required(...args) {
13404
+ return util_exports.required(ZodNonOptional, this, args[0]);
13631
13405
  }
13632
13406
  });
13633
- const bag = inst._zod.bag;
13634
- inst.minValue = Math.max(bag.minimum ?? Number.NEGATIVE_INFINITY, bag.exclusiveMinimum ?? Number.NEGATIVE_INFINITY) ?? null;
13635
- inst.maxValue = Math.min(bag.maximum ?? Number.POSITIVE_INFINITY, bag.exclusiveMaximum ?? Number.POSITIVE_INFINITY) ?? null;
13636
- inst.isInt = (bag.format ?? "").includes("int") || Number.isSafeInteger(bag.multipleOf ?? 0.5);
13637
- inst.isFinite = true;
13638
- inst.format = bag.format ?? null;
13639
13407
  });
13640
- function number2(params) {
13641
- return _number(ZodNumber, params);
13408
+ function object(shape, params) {
13409
+ const def = {
13410
+ type: "object",
13411
+ shape: shape ?? {},
13412
+ ...util_exports.normalizeParams(params)
13413
+ };
13414
+ return new ZodObject(def);
13415
+ }
13416
+ function strictObject(shape, params) {
13417
+ return new ZodObject({
13418
+ type: "object",
13419
+ shape,
13420
+ catchall: never(),
13421
+ ...util_exports.normalizeParams(params)
13422
+ });
13423
+ }
13424
+ function looseObject(shape, params) {
13425
+ return new ZodObject({
13426
+ type: "object",
13427
+ shape,
13428
+ catchall: unknown(),
13429
+ ...util_exports.normalizeParams(params)
13430
+ });
13431
+ }
13432
+ var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
13433
+ $ZodUnion.init(inst, def);
13434
+ ZodType.init(inst, def);
13435
+ inst._zod.processJSONSchema = (ctx, json2, params) => unionProcessor(inst, ctx, json2, params);
13436
+ inst.options = def.options;
13437
+ });
13438
+ function union(options, params) {
13439
+ return new ZodUnion({
13440
+ type: "union",
13441
+ options,
13442
+ ...util_exports.normalizeParams(params)
13443
+ });
13444
+ }
13445
+ var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
13446
+ ZodUnion.init(inst, def);
13447
+ $ZodXor.init(inst, def);
13448
+ inst._zod.processJSONSchema = (ctx, json2, params) => unionProcessor(inst, ctx, json2, params);
13449
+ inst.options = def.options;
13450
+ });
13451
+ function xor(options, params) {
13452
+ return new ZodXor({
13453
+ type: "union",
13454
+ options,
13455
+ inclusive: false,
13456
+ ...util_exports.normalizeParams(params)
13457
+ });
13458
+ }
13459
+ var ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
13460
+ ZodUnion.init(inst, def);
13461
+ $ZodDiscriminatedUnion.init(inst, def);
13462
+ });
13463
+ function discriminatedUnion(discriminator, options, params) {
13464
+ return new ZodDiscriminatedUnion({
13465
+ type: "union",
13466
+ options,
13467
+ discriminator,
13468
+ ...util_exports.normalizeParams(params)
13469
+ });
13470
+ }
13471
+ var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
13472
+ $ZodIntersection.init(inst, def);
13473
+ ZodType.init(inst, def);
13474
+ inst._zod.processJSONSchema = (ctx, json2, params) => intersectionProcessor(inst, ctx, json2, params);
13475
+ });
13476
+ function intersection(left, right) {
13477
+ return new ZodIntersection({
13478
+ type: "intersection",
13479
+ left,
13480
+ right
13481
+ });
13482
+ }
13483
+ var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
13484
+ $ZodTuple.init(inst, def);
13485
+ ZodType.init(inst, def);
13486
+ inst._zod.processJSONSchema = (ctx, json2, params) => tupleProcessor(inst, ctx, json2, params);
13487
+ inst.rest = (rest) => inst.clone({
13488
+ ...inst._zod.def,
13489
+ rest
13490
+ });
13491
+ });
13492
+ function tuple(items, _paramsOrRest, _params) {
13493
+ const hasRest = _paramsOrRest instanceof $ZodType;
13494
+ const params = hasRest ? _params : _paramsOrRest;
13495
+ const rest = hasRest ? _paramsOrRest : null;
13496
+ return new ZodTuple({
13497
+ type: "tuple",
13498
+ items,
13499
+ rest,
13500
+ ...util_exports.normalizeParams(params)
13501
+ });
13642
13502
  }
13643
- var ZodNumberFormat = /* @__PURE__ */ $constructor("ZodNumberFormat", (inst, def) => {
13644
- $ZodNumberFormat.init(inst, def);
13645
- ZodNumber.init(inst, def);
13503
+ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
13504
+ $ZodRecord.init(inst, def);
13505
+ ZodType.init(inst, def);
13506
+ inst._zod.processJSONSchema = (ctx, json2, params) => recordProcessor(inst, ctx, json2, params);
13507
+ inst.keyType = def.keyType;
13508
+ inst.valueType = def.valueType;
13646
13509
  });
13647
- function int(params) {
13648
- return _int(ZodNumberFormat, params);
13510
+ function record(keyType, valueType, params) {
13511
+ if (!valueType || !valueType._zod) {
13512
+ return new ZodRecord({
13513
+ type: "record",
13514
+ keyType: string2(),
13515
+ valueType: keyType,
13516
+ ...util_exports.normalizeParams(valueType)
13517
+ });
13518
+ }
13519
+ return new ZodRecord({
13520
+ type: "record",
13521
+ keyType,
13522
+ valueType,
13523
+ ...util_exports.normalizeParams(params)
13524
+ });
13649
13525
  }
13650
- function float32(params) {
13651
- return _float32(ZodNumberFormat, params);
13526
+ function partialRecord(keyType, valueType, params) {
13527
+ const k = clone(keyType);
13528
+ k._zod.values = void 0;
13529
+ return new ZodRecord({
13530
+ type: "record",
13531
+ keyType: k,
13532
+ valueType,
13533
+ ...util_exports.normalizeParams(params)
13534
+ });
13652
13535
  }
13653
- function float64(params) {
13654
- return _float64(ZodNumberFormat, params);
13536
+ function looseRecord(keyType, valueType, params) {
13537
+ return new ZodRecord({
13538
+ type: "record",
13539
+ keyType,
13540
+ valueType,
13541
+ mode: "loose",
13542
+ ...util_exports.normalizeParams(params)
13543
+ });
13655
13544
  }
13656
- function int32(params) {
13657
- return _int32(ZodNumberFormat, params);
13545
+ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
13546
+ $ZodMap.init(inst, def);
13547
+ ZodType.init(inst, def);
13548
+ inst._zod.processJSONSchema = (ctx, json2, params) => mapProcessor(inst, ctx, json2, params);
13549
+ inst.keyType = def.keyType;
13550
+ inst.valueType = def.valueType;
13551
+ inst.min = (...args) => inst.check(_minSize(...args));
13552
+ inst.nonempty = (params) => inst.check(_minSize(1, params));
13553
+ inst.max = (...args) => inst.check(_maxSize(...args));
13554
+ inst.size = (...args) => inst.check(_size(...args));
13555
+ });
13556
+ function map(keyType, valueType, params) {
13557
+ return new ZodMap({
13558
+ type: "map",
13559
+ keyType,
13560
+ valueType,
13561
+ ...util_exports.normalizeParams(params)
13562
+ });
13658
13563
  }
13659
- function uint32(params) {
13660
- return _uint32(ZodNumberFormat, params);
13564
+ var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
13565
+ $ZodSet.init(inst, def);
13566
+ ZodType.init(inst, def);
13567
+ inst._zod.processJSONSchema = (ctx, json2, params) => setProcessor(inst, ctx, json2, params);
13568
+ inst.min = (...args) => inst.check(_minSize(...args));
13569
+ inst.nonempty = (params) => inst.check(_minSize(1, params));
13570
+ inst.max = (...args) => inst.check(_maxSize(...args));
13571
+ inst.size = (...args) => inst.check(_size(...args));
13572
+ });
13573
+ function set(valueType, params) {
13574
+ return new ZodSet({
13575
+ type: "set",
13576
+ valueType,
13577
+ ...util_exports.normalizeParams(params)
13578
+ });
13661
13579
  }
13662
- var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
13663
- $ZodBoolean.init(inst, def);
13580
+ var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
13581
+ $ZodEnum.init(inst, def);
13664
13582
  ZodType.init(inst, def);
13665
- inst._zod.processJSONSchema = (ctx, json2, params) => booleanProcessor(inst, ctx, json2, params);
13583
+ inst._zod.processJSONSchema = (ctx, json2, params) => enumProcessor(inst, ctx, json2, params);
13584
+ inst.enum = def.entries;
13585
+ inst.options = Object.values(def.entries);
13586
+ const keys = new Set(Object.keys(def.entries));
13587
+ inst.extract = (values, params) => {
13588
+ const newEntries = {};
13589
+ for (const value of values) {
13590
+ if (keys.has(value)) {
13591
+ newEntries[value] = def.entries[value];
13592
+ } else
13593
+ throw new Error(`Key ${value} not found in enum`);
13594
+ }
13595
+ return new ZodEnum({
13596
+ ...def,
13597
+ checks: [],
13598
+ ...util_exports.normalizeParams(params),
13599
+ entries: newEntries
13600
+ });
13601
+ };
13602
+ inst.exclude = (values, params) => {
13603
+ const newEntries = { ...def.entries };
13604
+ for (const value of values) {
13605
+ if (keys.has(value)) {
13606
+ delete newEntries[value];
13607
+ } else
13608
+ throw new Error(`Key ${value} not found in enum`);
13609
+ }
13610
+ return new ZodEnum({
13611
+ ...def,
13612
+ checks: [],
13613
+ ...util_exports.normalizeParams(params),
13614
+ entries: newEntries
13615
+ });
13616
+ };
13666
13617
  });
13667
- function boolean2(params) {
13668
- return _boolean(ZodBoolean, params);
13618
+ function _enum2(values, params) {
13619
+ const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
13620
+ return new ZodEnum({
13621
+ type: "enum",
13622
+ entries,
13623
+ ...util_exports.normalizeParams(params)
13624
+ });
13669
13625
  }
13670
- var ZodBigInt = /* @__PURE__ */ $constructor("ZodBigInt", (inst, def) => {
13671
- $ZodBigInt.init(inst, def);
13626
+ function nativeEnum(entries, params) {
13627
+ return new ZodEnum({
13628
+ type: "enum",
13629
+ entries,
13630
+ ...util_exports.normalizeParams(params)
13631
+ });
13632
+ }
13633
+ var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
13634
+ $ZodLiteral.init(inst, def);
13672
13635
  ZodType.init(inst, def);
13673
- inst._zod.processJSONSchema = (ctx, json2, params) => bigintProcessor(inst, ctx, json2, params);
13674
- inst.gte = (value, params) => inst.check(_gte(value, params));
13675
- inst.min = (value, params) => inst.check(_gte(value, params));
13676
- inst.gt = (value, params) => inst.check(_gt(value, params));
13677
- inst.gte = (value, params) => inst.check(_gte(value, params));
13678
- inst.min = (value, params) => inst.check(_gte(value, params));
13679
- inst.lt = (value, params) => inst.check(_lt(value, params));
13680
- inst.lte = (value, params) => inst.check(_lte(value, params));
13681
- inst.max = (value, params) => inst.check(_lte(value, params));
13682
- inst.positive = (params) => inst.check(_gt(BigInt(0), params));
13683
- inst.negative = (params) => inst.check(_lt(BigInt(0), params));
13684
- inst.nonpositive = (params) => inst.check(_lte(BigInt(0), params));
13685
- inst.nonnegative = (params) => inst.check(_gte(BigInt(0), params));
13686
- inst.multipleOf = (value, params) => inst.check(_multipleOf(value, params));
13687
- const bag = inst._zod.bag;
13688
- inst.minValue = bag.minimum ?? null;
13689
- inst.maxValue = bag.maximum ?? null;
13690
- inst.format = bag.format ?? null;
13636
+ inst._zod.processJSONSchema = (ctx, json2, params) => literalProcessor(inst, ctx, json2, params);
13637
+ inst.values = new Set(def.values);
13638
+ Object.defineProperty(inst, "value", {
13639
+ get() {
13640
+ if (def.values.length > 1) {
13641
+ throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
13642
+ }
13643
+ return def.values[0];
13644
+ }
13645
+ });
13691
13646
  });
13692
- function bigint2(params) {
13693
- return _bigint(ZodBigInt, params);
13647
+ function literal(value, params) {
13648
+ return new ZodLiteral({
13649
+ type: "literal",
13650
+ values: Array.isArray(value) ? value : [value],
13651
+ ...util_exports.normalizeParams(params)
13652
+ });
13694
13653
  }
13695
- var ZodBigIntFormat = /* @__PURE__ */ $constructor("ZodBigIntFormat", (inst, def) => {
13696
- $ZodBigIntFormat.init(inst, def);
13697
- ZodBigInt.init(inst, def);
13654
+ var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
13655
+ $ZodFile.init(inst, def);
13656
+ ZodType.init(inst, def);
13657
+ inst._zod.processJSONSchema = (ctx, json2, params) => fileProcessor(inst, ctx, json2, params);
13658
+ inst.min = (size, params) => inst.check(_minSize(size, params));
13659
+ inst.max = (size, params) => inst.check(_maxSize(size, params));
13660
+ inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
13661
+ });
13662
+ function file(params) {
13663
+ return _file(ZodFile, params);
13664
+ }
13665
+ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
13666
+ $ZodTransform.init(inst, def);
13667
+ ZodType.init(inst, def);
13668
+ inst._zod.processJSONSchema = (ctx, json2, params) => transformProcessor(inst, ctx, json2, params);
13669
+ inst._zod.parse = (payload, _ctx) => {
13670
+ if (_ctx.direction === "backward") {
13671
+ throw new $ZodEncodeError(inst.constructor.name);
13672
+ }
13673
+ payload.addIssue = (issue2) => {
13674
+ if (typeof issue2 === "string") {
13675
+ payload.issues.push(util_exports.issue(issue2, payload.value, def));
13676
+ } else {
13677
+ const _issue = issue2;
13678
+ if (_issue.fatal)
13679
+ _issue.continue = false;
13680
+ _issue.code ?? (_issue.code = "custom");
13681
+ _issue.input ?? (_issue.input = payload.value);
13682
+ _issue.inst ?? (_issue.inst = inst);
13683
+ payload.issues.push(util_exports.issue(_issue));
13684
+ }
13685
+ };
13686
+ const output = def.transform(payload.value, payload);
13687
+ if (output instanceof Promise) {
13688
+ return output.then((output2) => {
13689
+ payload.value = output2;
13690
+ payload.fallback = true;
13691
+ return payload;
13692
+ });
13693
+ }
13694
+ payload.value = output;
13695
+ payload.fallback = true;
13696
+ return payload;
13697
+ };
13698
13698
  });
13699
- function int64(params) {
13700
- return _int64(ZodBigIntFormat, params);
13701
- }
13702
- function uint64(params) {
13703
- return _uint64(ZodBigIntFormat, params);
13699
+ function transform(fn) {
13700
+ return new ZodTransform({
13701
+ type: "transform",
13702
+ transform: fn
13703
+ });
13704
13704
  }
13705
- var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
13706
- $ZodSymbol.init(inst, def);
13705
+ var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
13706
+ $ZodOptional.init(inst, def);
13707
13707
  ZodType.init(inst, def);
13708
- inst._zod.processJSONSchema = (ctx, json2, params) => symbolProcessor(inst, ctx, json2, params);
13708
+ inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
13709
+ inst.unwrap = () => inst._zod.def.innerType;
13709
13710
  });
13710
- function symbol(params) {
13711
- return _symbol(ZodSymbol, params);
13711
+ function optional(innerType) {
13712
+ return new ZodOptional({
13713
+ type: "optional",
13714
+ innerType
13715
+ });
13712
13716
  }
13713
- var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
13714
- $ZodUndefined.init(inst, def);
13717
+ var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
13718
+ $ZodExactOptional.init(inst, def);
13715
13719
  ZodType.init(inst, def);
13716
- inst._zod.processJSONSchema = (ctx, json2, params) => undefinedProcessor(inst, ctx, json2, params);
13720
+ inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
13721
+ inst.unwrap = () => inst._zod.def.innerType;
13717
13722
  });
13718
- function _undefined3(params) {
13719
- return _undefined2(ZodUndefined, params);
13723
+ function exactOptional(innerType) {
13724
+ return new ZodExactOptional({
13725
+ type: "optional",
13726
+ innerType
13727
+ });
13720
13728
  }
13721
- var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
13722
- $ZodNull.init(inst, def);
13729
+ var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
13730
+ $ZodNullable.init(inst, def);
13723
13731
  ZodType.init(inst, def);
13724
- inst._zod.processJSONSchema = (ctx, json2, params) => nullProcessor(inst, ctx, json2, params);
13732
+ inst._zod.processJSONSchema = (ctx, json2, params) => nullableProcessor(inst, ctx, json2, params);
13733
+ inst.unwrap = () => inst._zod.def.innerType;
13725
13734
  });
13726
- function _null3(params) {
13727
- return _null2(ZodNull, params);
13735
+ function nullable(innerType) {
13736
+ return new ZodNullable({
13737
+ type: "nullable",
13738
+ innerType
13739
+ });
13728
13740
  }
13729
- var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
13730
- $ZodAny.init(inst, def);
13741
+ function nullish2(innerType) {
13742
+ return optional(nullable(innerType));
13743
+ }
13744
+ var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
13745
+ $ZodDefault.init(inst, def);
13731
13746
  ZodType.init(inst, def);
13732
- inst._zod.processJSONSchema = (ctx, json2, params) => anyProcessor(inst, ctx, json2, params);
13747
+ inst._zod.processJSONSchema = (ctx, json2, params) => defaultProcessor(inst, ctx, json2, params);
13748
+ inst.unwrap = () => inst._zod.def.innerType;
13749
+ inst.removeDefault = inst.unwrap;
13733
13750
  });
13734
- function any() {
13735
- return _any(ZodAny);
13751
+ function _default2(innerType, defaultValue) {
13752
+ return new ZodDefault({
13753
+ type: "default",
13754
+ innerType,
13755
+ get defaultValue() {
13756
+ return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
13757
+ }
13758
+ });
13736
13759
  }
13737
- var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
13738
- $ZodUnknown.init(inst, def);
13760
+ var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
13761
+ $ZodPrefault.init(inst, def);
13739
13762
  ZodType.init(inst, def);
13740
- inst._zod.processJSONSchema = (ctx, json2, params) => unknownProcessor(inst, ctx, json2, params);
13763
+ inst._zod.processJSONSchema = (ctx, json2, params) => prefaultProcessor(inst, ctx, json2, params);
13764
+ inst.unwrap = () => inst._zod.def.innerType;
13741
13765
  });
13742
- function unknown() {
13743
- return _unknown(ZodUnknown);
13766
+ function prefault(innerType, defaultValue) {
13767
+ return new ZodPrefault({
13768
+ type: "prefault",
13769
+ innerType,
13770
+ get defaultValue() {
13771
+ return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
13772
+ }
13773
+ });
13744
13774
  }
13745
- var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
13746
- $ZodNever.init(inst, def);
13775
+ var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
13776
+ $ZodNonOptional.init(inst, def);
13747
13777
  ZodType.init(inst, def);
13748
- inst._zod.processJSONSchema = (ctx, json2, params) => neverProcessor(inst, ctx, json2, params);
13778
+ inst._zod.processJSONSchema = (ctx, json2, params) => nonoptionalProcessor(inst, ctx, json2, params);
13779
+ inst.unwrap = () => inst._zod.def.innerType;
13749
13780
  });
13750
- function never(params) {
13751
- return _never(ZodNever, params);
13781
+ function nonoptional(innerType, params) {
13782
+ return new ZodNonOptional({
13783
+ type: "nonoptional",
13784
+ innerType,
13785
+ ...util_exports.normalizeParams(params)
13786
+ });
13752
13787
  }
13753
- var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
13754
- $ZodVoid.init(inst, def);
13788
+ var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
13789
+ $ZodSuccess.init(inst, def);
13755
13790
  ZodType.init(inst, def);
13756
- inst._zod.processJSONSchema = (ctx, json2, params) => voidProcessor(inst, ctx, json2, params);
13791
+ inst._zod.processJSONSchema = (ctx, json2, params) => successProcessor(inst, ctx, json2, params);
13792
+ inst.unwrap = () => inst._zod.def.innerType;
13757
13793
  });
13758
- function _void2(params) {
13759
- return _void(ZodVoid, params);
13794
+ function success(innerType) {
13795
+ return new ZodSuccess({
13796
+ type: "success",
13797
+ innerType
13798
+ });
13760
13799
  }
13761
- var ZodDate = /* @__PURE__ */ $constructor("ZodDate", (inst, def) => {
13762
- $ZodDate.init(inst, def);
13800
+ var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
13801
+ $ZodCatch.init(inst, def);
13763
13802
  ZodType.init(inst, def);
13764
- inst._zod.processJSONSchema = (ctx, json2, params) => dateProcessor(inst, ctx, json2, params);
13765
- inst.min = (value, params) => inst.check(_gte(value, params));
13766
- inst.max = (value, params) => inst.check(_lte(value, params));
13767
- const c = inst._zod.bag;
13768
- inst.minDate = c.minimum ? new Date(c.minimum) : null;
13769
- inst.maxDate = c.maximum ? new Date(c.maximum) : null;
13803
+ inst._zod.processJSONSchema = (ctx, json2, params) => catchProcessor(inst, ctx, json2, params);
13804
+ inst.unwrap = () => inst._zod.def.innerType;
13805
+ inst.removeCatch = inst.unwrap;
13770
13806
  });
13771
- function date3(params) {
13772
- return _date(ZodDate, params);
13807
+ function _catch2(innerType, catchValue) {
13808
+ return new ZodCatch({
13809
+ type: "catch",
13810
+ innerType,
13811
+ catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
13812
+ });
13773
13813
  }
13774
- var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
13775
- $ZodArray.init(inst, def);
13814
+ var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
13815
+ $ZodNaN.init(inst, def);
13776
13816
  ZodType.init(inst, def);
13777
- inst._zod.processJSONSchema = (ctx, json2, params) => arrayProcessor(inst, ctx, json2, params);
13778
- inst.element = def.element;
13779
- _installLazyMethods(inst, "ZodArray", {
13780
- min(n, params) {
13781
- return this.check(_minLength(n, params));
13782
- },
13783
- nonempty(params) {
13784
- return this.check(_minLength(1, params));
13785
- },
13786
- max(n, params) {
13787
- return this.check(_maxLength(n, params));
13788
- },
13789
- length(n, params) {
13790
- return this.check(_length(n, params));
13791
- },
13792
- unwrap() {
13793
- return this.element;
13794
- }
13795
- });
13817
+ inst._zod.processJSONSchema = (ctx, json2, params) => nanProcessor(inst, ctx, json2, params);
13796
13818
  });
13797
- function array(element, params) {
13798
- return _array(ZodArray, element, params);
13799
- }
13800
- function keyof(schema) {
13801
- const shape = schema._zod.def.shape;
13802
- return _enum2(Object.keys(shape));
13819
+ function nan(params) {
13820
+ return _nan(ZodNaN, params);
13803
13821
  }
13804
- var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
13805
- $ZodObjectJIT.init(inst, def);
13822
+ var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
13823
+ $ZodPipe.init(inst, def);
13806
13824
  ZodType.init(inst, def);
13807
- inst._zod.processJSONSchema = (ctx, json2, params) => objectProcessor(inst, ctx, json2, params);
13808
- util_exports.defineLazy(inst, "shape", () => {
13809
- return def.shape;
13810
- });
13811
- _installLazyMethods(inst, "ZodObject", {
13812
- keyof() {
13813
- return _enum2(Object.keys(this._zod.def.shape));
13814
- },
13815
- catchall(catchall) {
13816
- return this.clone({ ...this._zod.def, catchall });
13817
- },
13818
- passthrough() {
13819
- return this.clone({ ...this._zod.def, catchall: unknown() });
13820
- },
13821
- loose() {
13822
- return this.clone({ ...this._zod.def, catchall: unknown() });
13823
- },
13824
- strict() {
13825
- return this.clone({ ...this._zod.def, catchall: never() });
13826
- },
13827
- strip() {
13828
- return this.clone({ ...this._zod.def, catchall: void 0 });
13829
- },
13830
- extend(incoming) {
13831
- return util_exports.extend(this, incoming);
13832
- },
13833
- safeExtend(incoming) {
13834
- return util_exports.safeExtend(this, incoming);
13835
- },
13836
- merge(other) {
13837
- return util_exports.merge(this, other);
13838
- },
13839
- pick(mask) {
13840
- return util_exports.pick(this, mask);
13841
- },
13842
- omit(mask) {
13843
- return util_exports.omit(this, mask);
13844
- },
13845
- partial(...args) {
13846
- return util_exports.partial(ZodOptional, this, args[0]);
13847
- },
13848
- required(...args) {
13849
- return util_exports.required(ZodNonOptional, this, args[0]);
13850
- }
13851
- });
13825
+ inst._zod.processJSONSchema = (ctx, json2, params) => pipeProcessor(inst, ctx, json2, params);
13826
+ inst.in = def.in;
13827
+ inst.out = def.out;
13852
13828
  });
13853
- function object(shape, params) {
13854
- const def = {
13855
- type: "object",
13856
- shape: shape ?? {},
13857
- ...util_exports.normalizeParams(params)
13858
- };
13859
- return new ZodObject(def);
13829
+ function pipe(in_, out) {
13830
+ return new ZodPipe({
13831
+ type: "pipe",
13832
+ in: in_,
13833
+ out
13834
+ // ...util.normalizeParams(params),
13835
+ });
13860
13836
  }
13861
- function strictObject(shape, params) {
13862
- return new ZodObject({
13863
- type: "object",
13864
- shape,
13865
- catchall: never(),
13866
- ...util_exports.normalizeParams(params)
13837
+ var ZodCodec = /* @__PURE__ */ $constructor("ZodCodec", (inst, def) => {
13838
+ ZodPipe.init(inst, def);
13839
+ $ZodCodec.init(inst, def);
13840
+ });
13841
+ function codec(in_, out, params) {
13842
+ return new ZodCodec({
13843
+ type: "pipe",
13844
+ in: in_,
13845
+ out,
13846
+ transform: params.decode,
13847
+ reverseTransform: params.encode
13867
13848
  });
13868
13849
  }
13869
- function looseObject(shape, params) {
13870
- return new ZodObject({
13871
- type: "object",
13872
- shape,
13873
- catchall: unknown(),
13874
- ...util_exports.normalizeParams(params)
13850
+ function invertCodec(codec2) {
13851
+ const def = codec2._zod.def;
13852
+ return new ZodCodec({
13853
+ type: "pipe",
13854
+ in: def.out,
13855
+ out: def.in,
13856
+ transform: def.reverseTransform,
13857
+ reverseTransform: def.transform
13875
13858
  });
13876
13859
  }
13877
- var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
13878
- $ZodUnion.init(inst, def);
13860
+ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) => {
13861
+ ZodPipe.init(inst, def);
13862
+ $ZodPreprocess.init(inst, def);
13863
+ });
13864
+ var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
13865
+ $ZodReadonly.init(inst, def);
13879
13866
  ZodType.init(inst, def);
13880
- inst._zod.processJSONSchema = (ctx, json2, params) => unionProcessor(inst, ctx, json2, params);
13881
- inst.options = def.options;
13867
+ inst._zod.processJSONSchema = (ctx, json2, params) => readonlyProcessor(inst, ctx, json2, params);
13868
+ inst.unwrap = () => inst._zod.def.innerType;
13882
13869
  });
13883
- function union(options, params) {
13884
- return new ZodUnion({
13885
- type: "union",
13886
- options,
13887
- ...util_exports.normalizeParams(params)
13870
+ function readonly(innerType) {
13871
+ return new ZodReadonly({
13872
+ type: "readonly",
13873
+ innerType
13888
13874
  });
13889
13875
  }
13890
- var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
13891
- ZodUnion.init(inst, def);
13892
- $ZodXor.init(inst, def);
13893
- inst._zod.processJSONSchema = (ctx, json2, params) => unionProcessor(inst, ctx, json2, params);
13894
- inst.options = def.options;
13876
+ var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
13877
+ $ZodTemplateLiteral.init(inst, def);
13878
+ ZodType.init(inst, def);
13879
+ inst._zod.processJSONSchema = (ctx, json2, params) => templateLiteralProcessor(inst, ctx, json2, params);
13895
13880
  });
13896
- function xor(options, params) {
13897
- return new ZodXor({
13898
- type: "union",
13899
- options,
13900
- inclusive: false,
13881
+ function templateLiteral(parts, params) {
13882
+ return new ZodTemplateLiteral({
13883
+ type: "template_literal",
13884
+ parts,
13901
13885
  ...util_exports.normalizeParams(params)
13902
13886
  });
13903
13887
  }
13904
- var ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("ZodDiscriminatedUnion", (inst, def) => {
13905
- ZodUnion.init(inst, def);
13906
- $ZodDiscriminatedUnion.init(inst, def);
13888
+ var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
13889
+ $ZodLazy.init(inst, def);
13890
+ ZodType.init(inst, def);
13891
+ inst._zod.processJSONSchema = (ctx, json2, params) => lazyProcessor(inst, ctx, json2, params);
13892
+ inst.unwrap = () => inst._zod.def.getter();
13907
13893
  });
13908
- function discriminatedUnion(discriminator, options, params) {
13909
- return new ZodDiscriminatedUnion({
13910
- type: "union",
13911
- options,
13912
- discriminator,
13913
- ...util_exports.normalizeParams(params)
13894
+ function lazy(getter) {
13895
+ return new ZodLazy({
13896
+ type: "lazy",
13897
+ getter
13914
13898
  });
13915
13899
  }
13916
- var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
13917
- $ZodIntersection.init(inst, def);
13900
+ var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
13901
+ $ZodPromise.init(inst, def);
13918
13902
  ZodType.init(inst, def);
13919
- inst._zod.processJSONSchema = (ctx, json2, params) => intersectionProcessor(inst, ctx, json2, params);
13903
+ inst._zod.processJSONSchema = (ctx, json2, params) => promiseProcessor(inst, ctx, json2, params);
13904
+ inst.unwrap = () => inst._zod.def.innerType;
13920
13905
  });
13921
- function intersection(left, right) {
13922
- return new ZodIntersection({
13923
- type: "intersection",
13924
- left,
13925
- right
13906
+ function promise(innerType) {
13907
+ return new ZodPromise({
13908
+ type: "promise",
13909
+ innerType
13926
13910
  });
13927
13911
  }
13928
- var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
13929
- $ZodTuple.init(inst, def);
13912
+ var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
13913
+ $ZodFunction.init(inst, def);
13930
13914
  ZodType.init(inst, def);
13931
- inst._zod.processJSONSchema = (ctx, json2, params) => tupleProcessor(inst, ctx, json2, params);
13932
- inst.rest = (rest) => inst.clone({
13933
- ...inst._zod.def,
13934
- rest
13935
- });
13915
+ inst._zod.processJSONSchema = (ctx, json2, params) => functionProcessor(inst, ctx, json2, params);
13936
13916
  });
13937
- function tuple(items, _paramsOrRest, _params) {
13938
- const hasRest = _paramsOrRest instanceof $ZodType;
13939
- const params = hasRest ? _params : _paramsOrRest;
13940
- const rest = hasRest ? _paramsOrRest : null;
13941
- return new ZodTuple({
13942
- type: "tuple",
13943
- items,
13944
- rest,
13945
- ...util_exports.normalizeParams(params)
13917
+ function _function(params) {
13918
+ return new ZodFunction({
13919
+ type: "function",
13920
+ input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
13921
+ output: params?.output ?? unknown()
13946
13922
  });
13947
13923
  }
13948
- var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
13949
- $ZodRecord.init(inst, def);
13924
+ var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
13925
+ $ZodCustom.init(inst, def);
13950
13926
  ZodType.init(inst, def);
13951
- inst._zod.processJSONSchema = (ctx, json2, params) => recordProcessor(inst, ctx, json2, params);
13952
- inst.keyType = def.keyType;
13953
- inst.valueType = def.valueType;
13927
+ inst._zod.processJSONSchema = (ctx, json2, params) => customProcessor(inst, ctx, json2, params);
13954
13928
  });
13955
- function record(keyType, valueType, params) {
13956
- if (!valueType || !valueType._zod) {
13957
- return new ZodRecord({
13958
- type: "record",
13959
- keyType: string2(),
13960
- valueType: keyType,
13961
- ...util_exports.normalizeParams(valueType)
13962
- });
13929
+ function check(fn) {
13930
+ const ch = new $ZodCheck({
13931
+ check: "custom"
13932
+ // ...util.normalizeParams(params),
13933
+ });
13934
+ ch._zod.check = fn;
13935
+ return ch;
13936
+ }
13937
+ function custom(fn, _params) {
13938
+ return _custom(ZodCustom, fn ?? (() => true), _params);
13939
+ }
13940
+ function refine(fn, _params = {}) {
13941
+ return _refine(ZodCustom, fn, _params);
13942
+ }
13943
+ function superRefine(fn, params) {
13944
+ return _superRefine(fn, params);
13945
+ }
13946
+ var describe2 = describe;
13947
+ var meta2 = meta;
13948
+ function _instanceof(cls, params = {}) {
13949
+ const inst = new ZodCustom({
13950
+ type: "custom",
13951
+ check: "custom",
13952
+ fn: (data) => data instanceof cls,
13953
+ abort: true,
13954
+ ...util_exports.normalizeParams(params)
13955
+ });
13956
+ inst._zod.bag.Class = cls;
13957
+ inst._zod.check = (payload) => {
13958
+ if (!(payload.value instanceof cls)) {
13959
+ payload.issues.push({
13960
+ code: "invalid_type",
13961
+ expected: cls.name,
13962
+ input: payload.value,
13963
+ inst,
13964
+ path: [...inst._zod.def.path ?? []]
13965
+ });
13966
+ }
13967
+ };
13968
+ return inst;
13969
+ }
13970
+ var stringbool = (...args) => _stringbool({
13971
+ Codec: ZodCodec,
13972
+ Boolean: ZodBoolean,
13973
+ String: ZodString
13974
+ }, ...args);
13975
+ function json(params) {
13976
+ const jsonSchema = lazy(() => {
13977
+ return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
13978
+ });
13979
+ return jsonSchema;
13980
+ }
13981
+ function preprocess(fn, schema) {
13982
+ return new ZodPreprocess({
13983
+ type: "pipe",
13984
+ in: transform(fn),
13985
+ out: schema
13986
+ });
13987
+ }
13988
+
13989
+ // node_modules/zod/v4/classic/compat.js
13990
+ var ZodIssueCode = {
13991
+ invalid_type: "invalid_type",
13992
+ too_big: "too_big",
13993
+ too_small: "too_small",
13994
+ invalid_format: "invalid_format",
13995
+ not_multiple_of: "not_multiple_of",
13996
+ unrecognized_keys: "unrecognized_keys",
13997
+ invalid_union: "invalid_union",
13998
+ invalid_key: "invalid_key",
13999
+ invalid_element: "invalid_element",
14000
+ invalid_value: "invalid_value",
14001
+ custom: "custom"
14002
+ };
14003
+ function setErrorMap(map2) {
14004
+ config({
14005
+ customError: map2
14006
+ });
14007
+ }
14008
+ function getErrorMap() {
14009
+ return config().customError;
14010
+ }
14011
+ var ZodFirstPartyTypeKind;
14012
+ /* @__PURE__ */ (function(ZodFirstPartyTypeKind2) {
14013
+ })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
14014
+
14015
+ // node_modules/zod/v4/classic/from-json-schema.js
14016
+ var z = {
14017
+ ...schemas_exports2,
14018
+ ...checks_exports2,
14019
+ iso: iso_exports
14020
+ };
14021
+ var RECOGNIZED_KEYS = /* @__PURE__ */ new Set([
14022
+ // Schema identification
14023
+ "$schema",
14024
+ "$ref",
14025
+ "$defs",
14026
+ "definitions",
14027
+ // Core schema keywords
14028
+ "$id",
14029
+ "id",
14030
+ "$comment",
14031
+ "$anchor",
14032
+ "$vocabulary",
14033
+ "$dynamicRef",
14034
+ "$dynamicAnchor",
14035
+ // Type
14036
+ "type",
14037
+ "enum",
14038
+ "const",
14039
+ // Composition
14040
+ "anyOf",
14041
+ "oneOf",
14042
+ "allOf",
14043
+ "not",
14044
+ // Object
14045
+ "properties",
14046
+ "required",
14047
+ "additionalProperties",
14048
+ "patternProperties",
14049
+ "propertyNames",
14050
+ "minProperties",
14051
+ "maxProperties",
14052
+ // Array
14053
+ "items",
14054
+ "prefixItems",
14055
+ "additionalItems",
14056
+ "minItems",
14057
+ "maxItems",
14058
+ "uniqueItems",
14059
+ "contains",
14060
+ "minContains",
14061
+ "maxContains",
14062
+ // String
14063
+ "minLength",
14064
+ "maxLength",
14065
+ "pattern",
14066
+ "format",
14067
+ // Number
14068
+ "minimum",
14069
+ "maximum",
14070
+ "exclusiveMinimum",
14071
+ "exclusiveMaximum",
14072
+ "multipleOf",
14073
+ // Already handled metadata
14074
+ "description",
14075
+ "default",
14076
+ // Content
14077
+ "contentEncoding",
14078
+ "contentMediaType",
14079
+ "contentSchema",
14080
+ // Unsupported (error-throwing)
14081
+ "unevaluatedItems",
14082
+ "unevaluatedProperties",
14083
+ "if",
14084
+ "then",
14085
+ "else",
14086
+ "dependentSchemas",
14087
+ "dependentRequired",
14088
+ // OpenAPI
14089
+ "nullable",
14090
+ "readOnly"
14091
+ ]);
14092
+ function detectVersion(schema, defaultTarget) {
14093
+ const $schema = schema.$schema;
14094
+ if ($schema === "https://json-schema.org/draft/2020-12/schema") {
14095
+ return "draft-2020-12";
13963
14096
  }
13964
- return new ZodRecord({
13965
- type: "record",
13966
- keyType,
13967
- valueType,
13968
- ...util_exports.normalizeParams(params)
13969
- });
13970
- }
13971
- function partialRecord(keyType, valueType, params) {
13972
- const k = clone(keyType);
13973
- k._zod.values = void 0;
13974
- return new ZodRecord({
13975
- type: "record",
13976
- keyType: k,
13977
- valueType,
13978
- ...util_exports.normalizeParams(params)
13979
- });
13980
- }
13981
- function looseRecord(keyType, valueType, params) {
13982
- return new ZodRecord({
13983
- type: "record",
13984
- keyType,
13985
- valueType,
13986
- mode: "loose",
13987
- ...util_exports.normalizeParams(params)
13988
- });
13989
- }
13990
- var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
13991
- $ZodMap.init(inst, def);
13992
- ZodType.init(inst, def);
13993
- inst._zod.processJSONSchema = (ctx, json2, params) => mapProcessor(inst, ctx, json2, params);
13994
- inst.keyType = def.keyType;
13995
- inst.valueType = def.valueType;
13996
- inst.min = (...args) => inst.check(_minSize(...args));
13997
- inst.nonempty = (params) => inst.check(_minSize(1, params));
13998
- inst.max = (...args) => inst.check(_maxSize(...args));
13999
- inst.size = (...args) => inst.check(_size(...args));
14000
- });
14001
- function map(keyType, valueType, params) {
14002
- return new ZodMap({
14003
- type: "map",
14004
- keyType,
14005
- valueType,
14006
- ...util_exports.normalizeParams(params)
14007
- });
14097
+ if ($schema === "http://json-schema.org/draft-07/schema#") {
14098
+ return "draft-7";
14099
+ }
14100
+ if ($schema === "http://json-schema.org/draft-04/schema#") {
14101
+ return "draft-4";
14102
+ }
14103
+ return defaultTarget ?? "draft-2020-12";
14008
14104
  }
14009
- var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
14010
- $ZodSet.init(inst, def);
14011
- ZodType.init(inst, def);
14012
- inst._zod.processJSONSchema = (ctx, json2, params) => setProcessor(inst, ctx, json2, params);
14013
- inst.min = (...args) => inst.check(_minSize(...args));
14014
- inst.nonempty = (params) => inst.check(_minSize(1, params));
14015
- inst.max = (...args) => inst.check(_maxSize(...args));
14016
- inst.size = (...args) => inst.check(_size(...args));
14017
- });
14018
- function set(valueType, params) {
14019
- return new ZodSet({
14020
- type: "set",
14021
- valueType,
14022
- ...util_exports.normalizeParams(params)
14023
- });
14105
+ function resolveRef(ref, ctx) {
14106
+ if (!ref.startsWith("#")) {
14107
+ throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14108
+ }
14109
+ const path = ref.slice(1).split("/").filter(Boolean);
14110
+ if (path.length === 0) {
14111
+ return ctx.rootSchema;
14112
+ }
14113
+ const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14114
+ if (path[0] === defsKey) {
14115
+ const key = path[1];
14116
+ if (!key || !ctx.defs[key]) {
14117
+ throw new Error(`Reference not found: ${ref}`);
14118
+ }
14119
+ return ctx.defs[key];
14120
+ }
14121
+ throw new Error(`Reference not found: ${ref}`);
14024
14122
  }
14025
- var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
14026
- $ZodEnum.init(inst, def);
14027
- ZodType.init(inst, def);
14028
- inst._zod.processJSONSchema = (ctx, json2, params) => enumProcessor(inst, ctx, json2, params);
14029
- inst.enum = def.entries;
14030
- inst.options = Object.values(def.entries);
14031
- const keys = new Set(Object.keys(def.entries));
14032
- inst.extract = (values, params) => {
14033
- const newEntries = {};
14034
- for (const value of values) {
14035
- if (keys.has(value)) {
14036
- newEntries[value] = def.entries[value];
14037
- } else
14038
- throw new Error(`Key ${value} not found in enum`);
14123
+ function convertBaseSchema(schema, ctx) {
14124
+ if (schema.not !== void 0) {
14125
+ if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
14126
+ return z.never();
14039
14127
  }
14040
- return new ZodEnum({
14041
- ...def,
14042
- checks: [],
14043
- ...util_exports.normalizeParams(params),
14044
- entries: newEntries
14128
+ throw new Error("not is not supported in Zod (except { not: {} } for never)");
14129
+ }
14130
+ if (schema.unevaluatedItems !== void 0) {
14131
+ throw new Error("unevaluatedItems is not supported");
14132
+ }
14133
+ if (schema.unevaluatedProperties !== void 0) {
14134
+ throw new Error("unevaluatedProperties is not supported");
14135
+ }
14136
+ if (schema.if !== void 0 || schema.then !== void 0 || schema.else !== void 0) {
14137
+ throw new Error("Conditional schemas (if/then/else) are not supported");
14138
+ }
14139
+ if (schema.dependentSchemas !== void 0 || schema.dependentRequired !== void 0) {
14140
+ throw new Error("dependentSchemas and dependentRequired are not supported");
14141
+ }
14142
+ if (schema.$ref) {
14143
+ const refPath = schema.$ref;
14144
+ if (ctx.refs.has(refPath)) {
14145
+ return ctx.refs.get(refPath);
14146
+ }
14147
+ if (ctx.processing.has(refPath)) {
14148
+ return z.lazy(() => {
14149
+ if (!ctx.refs.has(refPath)) {
14150
+ throw new Error(`Circular reference not resolved: ${refPath}`);
14151
+ }
14152
+ return ctx.refs.get(refPath);
14153
+ });
14154
+ }
14155
+ ctx.processing.add(refPath);
14156
+ const resolved = resolveRef(refPath, ctx);
14157
+ const zodSchema2 = convertSchema(resolved, ctx);
14158
+ ctx.refs.set(refPath, zodSchema2);
14159
+ ctx.processing.delete(refPath);
14160
+ return zodSchema2;
14161
+ }
14162
+ if (schema.enum !== void 0) {
14163
+ const enumValues = schema.enum;
14164
+ if (ctx.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
14165
+ return z.null();
14166
+ }
14167
+ if (enumValues.length === 0) {
14168
+ return z.never();
14169
+ }
14170
+ if (enumValues.length === 1) {
14171
+ return z.literal(enumValues[0]);
14172
+ }
14173
+ if (enumValues.every((v) => typeof v === "string")) {
14174
+ return z.enum(enumValues);
14175
+ }
14176
+ const literalSchemas = enumValues.map((v) => z.literal(v));
14177
+ if (literalSchemas.length < 2) {
14178
+ return literalSchemas[0];
14179
+ }
14180
+ return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
14181
+ }
14182
+ if (schema.const !== void 0) {
14183
+ return z.literal(schema.const);
14184
+ }
14185
+ const type = schema.type;
14186
+ if (Array.isArray(type)) {
14187
+ const typeSchemas = type.map((t) => {
14188
+ const typeSchema = { ...schema, type: t };
14189
+ return convertBaseSchema(typeSchema, ctx);
14045
14190
  });
14046
- };
14047
- inst.exclude = (values, params) => {
14048
- const newEntries = { ...def.entries };
14049
- for (const value of values) {
14050
- if (keys.has(value)) {
14051
- delete newEntries[value];
14052
- } else
14053
- throw new Error(`Key ${value} not found in enum`);
14191
+ if (typeSchemas.length === 0) {
14192
+ return z.never();
14193
+ }
14194
+ if (typeSchemas.length === 1) {
14195
+ return typeSchemas[0];
14196
+ }
14197
+ return z.union(typeSchemas);
14198
+ }
14199
+ if (!type) {
14200
+ return z.any();
14201
+ }
14202
+ let zodSchema;
14203
+ switch (type) {
14204
+ case "string": {
14205
+ let stringSchema = z.string();
14206
+ if (schema.format) {
14207
+ const format = schema.format;
14208
+ if (format === "email") {
14209
+ stringSchema = stringSchema.check(z.email());
14210
+ } else if (format === "uri" || format === "uri-reference") {
14211
+ stringSchema = stringSchema.check(z.url());
14212
+ } else if (format === "uuid" || format === "guid") {
14213
+ stringSchema = stringSchema.check(z.uuid());
14214
+ } else if (format === "date-time") {
14215
+ stringSchema = stringSchema.check(z.iso.datetime());
14216
+ } else if (format === "date") {
14217
+ stringSchema = stringSchema.check(z.iso.date());
14218
+ } else if (format === "time") {
14219
+ stringSchema = stringSchema.check(z.iso.time());
14220
+ } else if (format === "duration") {
14221
+ stringSchema = stringSchema.check(z.iso.duration());
14222
+ } else if (format === "ipv4") {
14223
+ stringSchema = stringSchema.check(z.ipv4());
14224
+ } else if (format === "ipv6") {
14225
+ stringSchema = stringSchema.check(z.ipv6());
14226
+ } else if (format === "mac") {
14227
+ stringSchema = stringSchema.check(z.mac());
14228
+ } else if (format === "cidr") {
14229
+ stringSchema = stringSchema.check(z.cidrv4());
14230
+ } else if (format === "cidr-v6") {
14231
+ stringSchema = stringSchema.check(z.cidrv6());
14232
+ } else if (format === "base64") {
14233
+ stringSchema = stringSchema.check(z.base64());
14234
+ } else if (format === "base64url") {
14235
+ stringSchema = stringSchema.check(z.base64url());
14236
+ } else if (format === "e164") {
14237
+ stringSchema = stringSchema.check(z.e164());
14238
+ } else if (format === "jwt") {
14239
+ stringSchema = stringSchema.check(z.jwt());
14240
+ } else if (format === "emoji") {
14241
+ stringSchema = stringSchema.check(z.emoji());
14242
+ } else if (format === "nanoid") {
14243
+ stringSchema = stringSchema.check(z.nanoid());
14244
+ } else if (format === "cuid") {
14245
+ stringSchema = stringSchema.check(z.cuid());
14246
+ } else if (format === "cuid2") {
14247
+ stringSchema = stringSchema.check(z.cuid2());
14248
+ } else if (format === "ulid") {
14249
+ stringSchema = stringSchema.check(z.ulid());
14250
+ } else if (format === "xid") {
14251
+ stringSchema = stringSchema.check(z.xid());
14252
+ } else if (format === "ksuid") {
14253
+ stringSchema = stringSchema.check(z.ksuid());
14254
+ }
14255
+ }
14256
+ if (typeof schema.minLength === "number") {
14257
+ stringSchema = stringSchema.min(schema.minLength);
14258
+ }
14259
+ if (typeof schema.maxLength === "number") {
14260
+ stringSchema = stringSchema.max(schema.maxLength);
14261
+ }
14262
+ if (schema.pattern) {
14263
+ stringSchema = stringSchema.regex(new RegExp(schema.pattern));
14264
+ }
14265
+ zodSchema = stringSchema;
14266
+ break;
14054
14267
  }
14055
- return new ZodEnum({
14056
- ...def,
14057
- checks: [],
14058
- ...util_exports.normalizeParams(params),
14059
- entries: newEntries
14060
- });
14061
- };
14062
- });
14063
- function _enum2(values, params) {
14064
- const entries = Array.isArray(values) ? Object.fromEntries(values.map((v) => [v, v])) : values;
14065
- return new ZodEnum({
14066
- type: "enum",
14067
- entries,
14068
- ...util_exports.normalizeParams(params)
14069
- });
14070
- }
14071
- function nativeEnum(entries, params) {
14072
- return new ZodEnum({
14073
- type: "enum",
14074
- entries,
14075
- ...util_exports.normalizeParams(params)
14076
- });
14077
- }
14078
- var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
14079
- $ZodLiteral.init(inst, def);
14080
- ZodType.init(inst, def);
14081
- inst._zod.processJSONSchema = (ctx, json2, params) => literalProcessor(inst, ctx, json2, params);
14082
- inst.values = new Set(def.values);
14083
- Object.defineProperty(inst, "value", {
14084
- get() {
14085
- if (def.values.length > 1) {
14086
- throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
14268
+ case "number":
14269
+ case "integer": {
14270
+ let numberSchema = type === "integer" ? z.number().int() : z.number();
14271
+ if (typeof schema.minimum === "number") {
14272
+ numberSchema = numberSchema.min(schema.minimum);
14087
14273
  }
14088
- return def.values[0];
14274
+ if (typeof schema.maximum === "number") {
14275
+ numberSchema = numberSchema.max(schema.maximum);
14276
+ }
14277
+ if (typeof schema.exclusiveMinimum === "number") {
14278
+ numberSchema = numberSchema.gt(schema.exclusiveMinimum);
14279
+ } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
14280
+ numberSchema = numberSchema.gt(schema.minimum);
14281
+ }
14282
+ if (typeof schema.exclusiveMaximum === "number") {
14283
+ numberSchema = numberSchema.lt(schema.exclusiveMaximum);
14284
+ } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
14285
+ numberSchema = numberSchema.lt(schema.maximum);
14286
+ }
14287
+ if (typeof schema.multipleOf === "number") {
14288
+ numberSchema = numberSchema.multipleOf(schema.multipleOf);
14289
+ }
14290
+ zodSchema = numberSchema;
14291
+ break;
14089
14292
  }
14090
- });
14091
- });
14092
- function literal(value, params) {
14093
- return new ZodLiteral({
14094
- type: "literal",
14095
- values: Array.isArray(value) ? value : [value],
14096
- ...util_exports.normalizeParams(params)
14097
- });
14098
- }
14099
- var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
14100
- $ZodFile.init(inst, def);
14101
- ZodType.init(inst, def);
14102
- inst._zod.processJSONSchema = (ctx, json2, params) => fileProcessor(inst, ctx, json2, params);
14103
- inst.min = (size, params) => inst.check(_minSize(size, params));
14104
- inst.max = (size, params) => inst.check(_maxSize(size, params));
14105
- inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
14106
- });
14107
- function file(params) {
14108
- return _file(ZodFile, params);
14109
- }
14110
- var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
14111
- $ZodTransform.init(inst, def);
14112
- ZodType.init(inst, def);
14113
- inst._zod.processJSONSchema = (ctx, json2, params) => transformProcessor(inst, ctx, json2, params);
14114
- inst._zod.parse = (payload, _ctx) => {
14115
- if (_ctx.direction === "backward") {
14116
- throw new $ZodEncodeError(inst.constructor.name);
14293
+ case "boolean": {
14294
+ zodSchema = z.boolean();
14295
+ break;
14117
14296
  }
14118
- payload.addIssue = (issue2) => {
14119
- if (typeof issue2 === "string") {
14120
- payload.issues.push(util_exports.issue(issue2, payload.value, def));
14297
+ case "null": {
14298
+ zodSchema = z.null();
14299
+ break;
14300
+ }
14301
+ case "object": {
14302
+ const shape = {};
14303
+ const properties = schema.properties || {};
14304
+ const requiredSet = new Set(schema.required || []);
14305
+ for (const [key, propSchema] of Object.entries(properties)) {
14306
+ const propZodSchema = convertSchema(propSchema, ctx);
14307
+ shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
14308
+ }
14309
+ if (schema.propertyNames) {
14310
+ const keySchema = convertSchema(schema.propertyNames, ctx);
14311
+ const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z.any();
14312
+ if (Object.keys(shape).length === 0) {
14313
+ zodSchema = z.record(keySchema, valueSchema);
14314
+ break;
14315
+ }
14316
+ const objectSchema2 = z.object(shape).passthrough();
14317
+ const recordSchema = z.looseRecord(keySchema, valueSchema);
14318
+ zodSchema = z.intersection(objectSchema2, recordSchema);
14319
+ break;
14320
+ }
14321
+ if (schema.patternProperties) {
14322
+ const patternProps = schema.patternProperties;
14323
+ const patternKeys = Object.keys(patternProps);
14324
+ const looseRecords = [];
14325
+ for (const pattern of patternKeys) {
14326
+ const patternValue = convertSchema(patternProps[pattern], ctx);
14327
+ const keySchema = z.string().regex(new RegExp(pattern));
14328
+ looseRecords.push(z.looseRecord(keySchema, patternValue));
14329
+ }
14330
+ const schemasToIntersect = [];
14331
+ if (Object.keys(shape).length > 0) {
14332
+ schemasToIntersect.push(z.object(shape).passthrough());
14333
+ }
14334
+ schemasToIntersect.push(...looseRecords);
14335
+ if (schemasToIntersect.length === 0) {
14336
+ zodSchema = z.object({}).passthrough();
14337
+ } else if (schemasToIntersect.length === 1) {
14338
+ zodSchema = schemasToIntersect[0];
14339
+ } else {
14340
+ let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
14341
+ for (let i = 2; i < schemasToIntersect.length; i++) {
14342
+ result = z.intersection(result, schemasToIntersect[i]);
14343
+ }
14344
+ zodSchema = result;
14345
+ }
14346
+ break;
14347
+ }
14348
+ const objectSchema = z.object(shape);
14349
+ if (schema.additionalProperties === false) {
14350
+ zodSchema = objectSchema.strict();
14351
+ } else if (typeof schema.additionalProperties === "object") {
14352
+ zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
14121
14353
  } else {
14122
- const _issue = issue2;
14123
- if (_issue.fatal)
14124
- _issue.continue = false;
14125
- _issue.code ?? (_issue.code = "custom");
14126
- _issue.input ?? (_issue.input = payload.value);
14127
- _issue.inst ?? (_issue.inst = inst);
14128
- payload.issues.push(util_exports.issue(_issue));
14354
+ zodSchema = objectSchema.passthrough();
14355
+ }
14356
+ break;
14357
+ }
14358
+ case "array": {
14359
+ const prefixItems = schema.prefixItems;
14360
+ const items = schema.items;
14361
+ if (prefixItems && Array.isArray(prefixItems)) {
14362
+ const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
14363
+ const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : void 0;
14364
+ if (rest) {
14365
+ zodSchema = z.tuple(tupleItems).rest(rest);
14366
+ } else {
14367
+ zodSchema = z.tuple(tupleItems);
14368
+ }
14369
+ if (typeof schema.minItems === "number") {
14370
+ zodSchema = zodSchema.check(z.minLength(schema.minItems));
14371
+ }
14372
+ if (typeof schema.maxItems === "number") {
14373
+ zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
14374
+ }
14375
+ } else if (Array.isArray(items)) {
14376
+ const tupleItems = items.map((item) => convertSchema(item, ctx));
14377
+ const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : void 0;
14378
+ if (rest) {
14379
+ zodSchema = z.tuple(tupleItems).rest(rest);
14380
+ } else {
14381
+ zodSchema = z.tuple(tupleItems);
14382
+ }
14383
+ if (typeof schema.minItems === "number") {
14384
+ zodSchema = zodSchema.check(z.minLength(schema.minItems));
14385
+ }
14386
+ if (typeof schema.maxItems === "number") {
14387
+ zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
14388
+ }
14389
+ } else if (items !== void 0) {
14390
+ const element = convertSchema(items, ctx);
14391
+ let arraySchema = z.array(element);
14392
+ if (typeof schema.minItems === "number") {
14393
+ arraySchema = arraySchema.min(schema.minItems);
14394
+ }
14395
+ if (typeof schema.maxItems === "number") {
14396
+ arraySchema = arraySchema.max(schema.maxItems);
14397
+ }
14398
+ zodSchema = arraySchema;
14399
+ } else {
14400
+ zodSchema = z.array(z.any());
14401
+ }
14402
+ break;
14403
+ }
14404
+ default:
14405
+ throw new Error(`Unsupported type: ${type}`);
14406
+ }
14407
+ return zodSchema;
14408
+ }
14409
+ function convertSchema(schema, ctx) {
14410
+ if (typeof schema === "boolean") {
14411
+ return schema ? z.any() : z.never();
14412
+ }
14413
+ let baseSchema = convertBaseSchema(schema, ctx);
14414
+ const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
14415
+ if (schema.anyOf && Array.isArray(schema.anyOf)) {
14416
+ const options = schema.anyOf.map((s) => convertSchema(s, ctx));
14417
+ const anyOfUnion = z.union(options);
14418
+ baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
14419
+ }
14420
+ if (schema.oneOf && Array.isArray(schema.oneOf)) {
14421
+ const options = schema.oneOf.map((s) => convertSchema(s, ctx));
14422
+ const oneOfUnion = z.xor(options);
14423
+ baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
14424
+ }
14425
+ if (schema.allOf && Array.isArray(schema.allOf)) {
14426
+ if (schema.allOf.length === 0) {
14427
+ baseSchema = hasExplicitType ? baseSchema : z.any();
14428
+ } else {
14429
+ let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
14430
+ const startIdx = hasExplicitType ? 0 : 1;
14431
+ for (let i = startIdx; i < schema.allOf.length; i++) {
14432
+ result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
14129
14433
  }
14130
- };
14131
- const output = def.transform(payload.value, payload);
14132
- if (output instanceof Promise) {
14133
- return output.then((output2) => {
14134
- payload.value = output2;
14135
- payload.fallback = true;
14136
- return payload;
14137
- });
14434
+ baseSchema = result;
14138
14435
  }
14139
- payload.value = output;
14140
- payload.fallback = true;
14141
- return payload;
14142
- };
14143
- });
14144
- function transform(fn) {
14145
- return new ZodTransform({
14146
- type: "transform",
14147
- transform: fn
14148
- });
14149
- }
14150
- var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
14151
- $ZodOptional.init(inst, def);
14152
- ZodType.init(inst, def);
14153
- inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
14154
- inst.unwrap = () => inst._zod.def.innerType;
14155
- });
14156
- function optional(innerType) {
14157
- return new ZodOptional({
14158
- type: "optional",
14159
- innerType
14160
- });
14161
- }
14162
- var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
14163
- $ZodExactOptional.init(inst, def);
14164
- ZodType.init(inst, def);
14165
- inst._zod.processJSONSchema = (ctx, json2, params) => optionalProcessor(inst, ctx, json2, params);
14166
- inst.unwrap = () => inst._zod.def.innerType;
14167
- });
14168
- function exactOptional(innerType) {
14169
- return new ZodExactOptional({
14170
- type: "optional",
14171
- innerType
14172
- });
14173
- }
14174
- var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
14175
- $ZodNullable.init(inst, def);
14176
- ZodType.init(inst, def);
14177
- inst._zod.processJSONSchema = (ctx, json2, params) => nullableProcessor(inst, ctx, json2, params);
14178
- inst.unwrap = () => inst._zod.def.innerType;
14179
- });
14180
- function nullable(innerType) {
14181
- return new ZodNullable({
14182
- type: "nullable",
14183
- innerType
14184
- });
14185
- }
14186
- function nullish2(innerType) {
14187
- return optional(nullable(innerType));
14188
- }
14189
- var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
14190
- $ZodDefault.init(inst, def);
14191
- ZodType.init(inst, def);
14192
- inst._zod.processJSONSchema = (ctx, json2, params) => defaultProcessor(inst, ctx, json2, params);
14193
- inst.unwrap = () => inst._zod.def.innerType;
14194
- inst.removeDefault = inst.unwrap;
14195
- });
14196
- function _default2(innerType, defaultValue) {
14197
- return new ZodDefault({
14198
- type: "default",
14199
- innerType,
14200
- get defaultValue() {
14201
- return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
14436
+ }
14437
+ if (schema.nullable === true && ctx.version === "openapi-3.0") {
14438
+ baseSchema = z.nullable(baseSchema);
14439
+ }
14440
+ if (schema.readOnly === true) {
14441
+ baseSchema = z.readonly(baseSchema);
14442
+ }
14443
+ if (schema.default !== void 0) {
14444
+ baseSchema = baseSchema.default(schema.default);
14445
+ }
14446
+ const extraMeta = {};
14447
+ const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
14448
+ for (const key of coreMetadataKeys) {
14449
+ if (key in schema) {
14450
+ extraMeta[key] = schema[key];
14202
14451
  }
14203
- });
14204
- }
14205
- var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
14206
- $ZodPrefault.init(inst, def);
14207
- ZodType.init(inst, def);
14208
- inst._zod.processJSONSchema = (ctx, json2, params) => prefaultProcessor(inst, ctx, json2, params);
14209
- inst.unwrap = () => inst._zod.def.innerType;
14210
- });
14211
- function prefault(innerType, defaultValue) {
14212
- return new ZodPrefault({
14213
- type: "prefault",
14214
- innerType,
14215
- get defaultValue() {
14216
- return typeof defaultValue === "function" ? defaultValue() : util_exports.shallowClone(defaultValue);
14452
+ }
14453
+ const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
14454
+ for (const key of contentMetadataKeys) {
14455
+ if (key in schema) {
14456
+ extraMeta[key] = schema[key];
14217
14457
  }
14218
- });
14219
- }
14220
- var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
14221
- $ZodNonOptional.init(inst, def);
14222
- ZodType.init(inst, def);
14223
- inst._zod.processJSONSchema = (ctx, json2, params) => nonoptionalProcessor(inst, ctx, json2, params);
14224
- inst.unwrap = () => inst._zod.def.innerType;
14225
- });
14226
- function nonoptional(innerType, params) {
14227
- return new ZodNonOptional({
14228
- type: "nonoptional",
14229
- innerType,
14230
- ...util_exports.normalizeParams(params)
14231
- });
14232
- }
14233
- var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
14234
- $ZodSuccess.init(inst, def);
14235
- ZodType.init(inst, def);
14236
- inst._zod.processJSONSchema = (ctx, json2, params) => successProcessor(inst, ctx, json2, params);
14237
- inst.unwrap = () => inst._zod.def.innerType;
14238
- });
14239
- function success(innerType) {
14240
- return new ZodSuccess({
14241
- type: "success",
14242
- innerType
14243
- });
14244
- }
14245
- var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
14246
- $ZodCatch.init(inst, def);
14247
- ZodType.init(inst, def);
14248
- inst._zod.processJSONSchema = (ctx, json2, params) => catchProcessor(inst, ctx, json2, params);
14249
- inst.unwrap = () => inst._zod.def.innerType;
14250
- inst.removeCatch = inst.unwrap;
14251
- });
14252
- function _catch2(innerType, catchValue) {
14253
- return new ZodCatch({
14254
- type: "catch",
14255
- innerType,
14256
- catchValue: typeof catchValue === "function" ? catchValue : () => catchValue
14257
- });
14258
- }
14259
- var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
14260
- $ZodNaN.init(inst, def);
14261
- ZodType.init(inst, def);
14262
- inst._zod.processJSONSchema = (ctx, json2, params) => nanProcessor(inst, ctx, json2, params);
14263
- });
14264
- function nan(params) {
14265
- return _nan(ZodNaN, params);
14266
- }
14267
- var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
14268
- $ZodPipe.init(inst, def);
14269
- ZodType.init(inst, def);
14270
- inst._zod.processJSONSchema = (ctx, json2, params) => pipeProcessor(inst, ctx, json2, params);
14271
- inst.in = def.in;
14272
- inst.out = def.out;
14273
- });
14274
- function pipe(in_, out) {
14275
- return new ZodPipe({
14276
- type: "pipe",
14277
- in: in_,
14278
- out
14279
- // ...util.normalizeParams(params),
14280
- });
14281
- }
14282
- var ZodCodec = /* @__PURE__ */ $constructor("ZodCodec", (inst, def) => {
14283
- ZodPipe.init(inst, def);
14284
- $ZodCodec.init(inst, def);
14285
- });
14286
- function codec(in_, out, params) {
14287
- return new ZodCodec({
14288
- type: "pipe",
14289
- in: in_,
14290
- out,
14291
- transform: params.decode,
14292
- reverseTransform: params.encode
14293
- });
14294
- }
14295
- function invertCodec(codec2) {
14296
- const def = codec2._zod.def;
14297
- return new ZodCodec({
14298
- type: "pipe",
14299
- in: def.out,
14300
- out: def.in,
14301
- transform: def.reverseTransform,
14302
- reverseTransform: def.transform
14303
- });
14304
- }
14305
- var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) => {
14306
- ZodPipe.init(inst, def);
14307
- $ZodPreprocess.init(inst, def);
14308
- });
14309
- var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
14310
- $ZodReadonly.init(inst, def);
14311
- ZodType.init(inst, def);
14312
- inst._zod.processJSONSchema = (ctx, json2, params) => readonlyProcessor(inst, ctx, json2, params);
14313
- inst.unwrap = () => inst._zod.def.innerType;
14314
- });
14315
- function readonly(innerType) {
14316
- return new ZodReadonly({
14317
- type: "readonly",
14318
- innerType
14319
- });
14320
- }
14321
- var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
14322
- $ZodTemplateLiteral.init(inst, def);
14323
- ZodType.init(inst, def);
14324
- inst._zod.processJSONSchema = (ctx, json2, params) => templateLiteralProcessor(inst, ctx, json2, params);
14325
- });
14326
- function templateLiteral(parts, params) {
14327
- return new ZodTemplateLiteral({
14328
- type: "template_literal",
14329
- parts,
14330
- ...util_exports.normalizeParams(params)
14331
- });
14332
- }
14333
- var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
14334
- $ZodLazy.init(inst, def);
14335
- ZodType.init(inst, def);
14336
- inst._zod.processJSONSchema = (ctx, json2, params) => lazyProcessor(inst, ctx, json2, params);
14337
- inst.unwrap = () => inst._zod.def.getter();
14338
- });
14339
- function lazy(getter) {
14340
- return new ZodLazy({
14341
- type: "lazy",
14342
- getter
14343
- });
14344
- }
14345
- var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
14346
- $ZodPromise.init(inst, def);
14347
- ZodType.init(inst, def);
14348
- inst._zod.processJSONSchema = (ctx, json2, params) => promiseProcessor(inst, ctx, json2, params);
14349
- inst.unwrap = () => inst._zod.def.innerType;
14350
- });
14351
- function promise(innerType) {
14352
- return new ZodPromise({
14353
- type: "promise",
14354
- innerType
14355
- });
14458
+ }
14459
+ for (const key of Object.keys(schema)) {
14460
+ if (!RECOGNIZED_KEYS.has(key)) {
14461
+ extraMeta[key] = schema[key];
14462
+ }
14463
+ }
14464
+ if (Object.keys(extraMeta).length > 0) {
14465
+ ctx.registry.add(baseSchema, extraMeta);
14466
+ }
14467
+ if (schema.description) {
14468
+ baseSchema = baseSchema.describe(schema.description);
14469
+ }
14470
+ return baseSchema;
14356
14471
  }
14357
- var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
14358
- $ZodFunction.init(inst, def);
14359
- ZodType.init(inst, def);
14360
- inst._zod.processJSONSchema = (ctx, json2, params) => functionProcessor(inst, ctx, json2, params);
14361
- });
14362
- function _function(params) {
14363
- return new ZodFunction({
14364
- type: "function",
14365
- input: Array.isArray(params?.input) ? tuple(params?.input) : params?.input ?? array(unknown()),
14366
- output: params?.output ?? unknown()
14367
- });
14472
+ function fromJSONSchema(schema, params) {
14473
+ if (typeof schema === "boolean") {
14474
+ return schema ? z.any() : z.never();
14475
+ }
14476
+ let normalized;
14477
+ try {
14478
+ normalized = JSON.parse(JSON.stringify(schema));
14479
+ } catch {
14480
+ throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
14481
+ }
14482
+ const version2 = detectVersion(normalized, params?.defaultTarget);
14483
+ const defs = normalized.$defs || normalized.definitions || {};
14484
+ const ctx = {
14485
+ version: version2,
14486
+ defs,
14487
+ refs: /* @__PURE__ */ new Map(),
14488
+ processing: /* @__PURE__ */ new Set(),
14489
+ rootSchema: normalized,
14490
+ registry: params?.registry ?? globalRegistry
14491
+ };
14492
+ return convertSchema(normalized, ctx);
14368
14493
  }
14369
- var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
14370
- $ZodCustom.init(inst, def);
14371
- ZodType.init(inst, def);
14372
- inst._zod.processJSONSchema = (ctx, json2, params) => customProcessor(inst, ctx, json2, params);
14494
+
14495
+ // node_modules/zod/v4/classic/coerce.js
14496
+ var coerce_exports = {};
14497
+ __export(coerce_exports, {
14498
+ bigint: () => bigint3,
14499
+ boolean: () => boolean3,
14500
+ date: () => date4,
14501
+ number: () => number3,
14502
+ string: () => string3
14373
14503
  });
14374
- function check(fn) {
14375
- const ch = new $ZodCheck({
14376
- check: "custom"
14377
- // ...util.normalizeParams(params),
14378
- });
14379
- ch._zod.check = fn;
14380
- return ch;
14381
- }
14382
- function custom(fn, _params) {
14383
- return _custom(ZodCustom, fn ?? (() => true), _params);
14384
- }
14385
- function refine(fn, _params = {}) {
14386
- return _refine(ZodCustom, fn, _params);
14504
+ function string3(params) {
14505
+ return _coercedString(ZodString, params);
14387
14506
  }
14388
- function superRefine(fn, params) {
14389
- return _superRefine(fn, params);
14507
+ function number3(params) {
14508
+ return _coercedNumber(ZodNumber, params);
14390
14509
  }
14391
- var describe2 = describe;
14392
- var meta2 = meta;
14393
- function _instanceof(cls, params = {}) {
14394
- const inst = new ZodCustom({
14395
- type: "custom",
14396
- check: "custom",
14397
- fn: (data) => data instanceof cls,
14398
- abort: true,
14399
- ...util_exports.normalizeParams(params)
14400
- });
14401
- inst._zod.bag.Class = cls;
14402
- inst._zod.check = (payload) => {
14403
- if (!(payload.value instanceof cls)) {
14404
- payload.issues.push({
14405
- code: "invalid_type",
14406
- expected: cls.name,
14407
- input: payload.value,
14408
- inst,
14409
- path: [...inst._zod.def.path ?? []]
14410
- });
14411
- }
14412
- };
14413
- return inst;
14510
+ function boolean3(params) {
14511
+ return _coercedBoolean(ZodBoolean, params);
14414
14512
  }
14415
- var stringbool = (...args) => _stringbool({
14416
- Codec: ZodCodec,
14417
- Boolean: ZodBoolean,
14418
- String: ZodString
14419
- }, ...args);
14420
- function json(params) {
14421
- const jsonSchema = lazy(() => {
14422
- return union([string2(params), number2(), boolean2(), _null3(), array(jsonSchema), record(string2(), jsonSchema)]);
14423
- });
14424
- return jsonSchema;
14513
+ function bigint3(params) {
14514
+ return _coercedBigint(ZodBigInt, params);
14425
14515
  }
14426
- function preprocess(fn, schema) {
14427
- return new ZodPreprocess({
14428
- type: "pipe",
14429
- in: transform(fn),
14430
- out: schema
14431
- });
14516
+ function date4(params) {
14517
+ return _coercedDate(ZodDate, params);
14432
14518
  }
14433
14519
 
14434
- // node_modules/zod/v4/classic/compat.js
14435
- var ZodIssueCode = {
14436
- invalid_type: "invalid_type",
14437
- too_big: "too_big",
14438
- too_small: "too_small",
14439
- invalid_format: "invalid_format",
14440
- not_multiple_of: "not_multiple_of",
14441
- unrecognized_keys: "unrecognized_keys",
14442
- invalid_union: "invalid_union",
14443
- invalid_key: "invalid_key",
14444
- invalid_element: "invalid_element",
14445
- invalid_value: "invalid_value",
14446
- custom: "custom"
14447
- };
14448
- function setErrorMap(map2) {
14449
- config({
14450
- customError: map2
14451
- });
14452
- }
14453
- function getErrorMap() {
14454
- return config().customError;
14455
- }
14456
- var ZodFirstPartyTypeKind;
14457
- /* @__PURE__ */ (function(ZodFirstPartyTypeKind2) {
14458
- })(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
14520
+ // node_modules/zod/v4/classic/external.js
14521
+ config(en_default());
14459
14522
 
14460
- // node_modules/zod/v4/classic/from-json-schema.js
14461
- var z = {
14462
- ...schemas_exports2,
14463
- ...checks_exports2,
14464
- iso: iso_exports
14465
- };
14466
- var RECOGNIZED_KEYS = /* @__PURE__ */ new Set([
14467
- // Schema identification
14468
- "$schema",
14469
- "$ref",
14470
- "$defs",
14471
- "definitions",
14472
- // Core schema keywords
14473
- "$id",
14474
- "id",
14475
- "$comment",
14476
- "$anchor",
14477
- "$vocabulary",
14478
- "$dynamicRef",
14479
- "$dynamicAnchor",
14480
- // Type
14481
- "type",
14482
- "enum",
14483
- "const",
14484
- // Composition
14485
- "anyOf",
14486
- "oneOf",
14487
- "allOf",
14488
- "not",
14489
- // Object
14490
- "properties",
14491
- "required",
14492
- "additionalProperties",
14493
- "patternProperties",
14494
- "propertyNames",
14495
- "minProperties",
14496
- "maxProperties",
14497
- // Array
14498
- "items",
14499
- "prefixItems",
14500
- "additionalItems",
14501
- "minItems",
14502
- "maxItems",
14503
- "uniqueItems",
14504
- "contains",
14505
- "minContains",
14506
- "maxContains",
14507
- // String
14508
- "minLength",
14509
- "maxLength",
14510
- "pattern",
14511
- "format",
14512
- // Number
14513
- "minimum",
14514
- "maximum",
14515
- "exclusiveMinimum",
14516
- "exclusiveMaximum",
14517
- "multipleOf",
14518
- // Already handled metadata
14519
- "description",
14520
- "default",
14521
- // Content
14522
- "contentEncoding",
14523
- "contentMediaType",
14524
- "contentSchema",
14525
- // Unsupported (error-throwing)
14526
- "unevaluatedItems",
14527
- "unevaluatedProperties",
14528
- "if",
14529
- "then",
14530
- "else",
14531
- "dependentSchemas",
14532
- "dependentRequired",
14533
- // OpenAPI
14534
- "nullable",
14535
- "readOnly"
14536
- ]);
14537
- function detectVersion(schema, defaultTarget) {
14538
- const $schema = schema.$schema;
14539
- if ($schema === "https://json-schema.org/draft/2020-12/schema") {
14540
- return "draft-2020-12";
14523
+ // node_modules/@opentabs-dev/shared/dist/error.js
14524
+ var toErrorMessage = (err2) => err2 instanceof Error ? err2.message : String(err2);
14525
+
14526
+ // node_modules/@opentabs-dev/plugin-sdk/dist/errors.js
14527
+ var ToolError = class _ToolError extends Error {
14528
+ code;
14529
+ /** Whether this error is retryable (defaults to false). */
14530
+ retryable;
14531
+ /** Suggested delay before retrying, in milliseconds. */
14532
+ retryAfterMs;
14533
+ /** Error category for structured error classification. */
14534
+ category;
14535
+ constructor(message, code, opts) {
14536
+ super(message);
14537
+ this.code = code;
14538
+ this.name = "ToolError";
14539
+ this.retryable = opts?.retryable ?? false;
14540
+ this.retryAfterMs = opts?.retryAfterMs;
14541
+ this.category = opts?.category;
14542
+ }
14543
+ /** Authentication or authorization error (not retryable). Accepts an optional domain-specific code. */
14544
+ static auth(message, code) {
14545
+ return new _ToolError(message, code ?? "AUTH_ERROR", { category: "auth", retryable: false });
14546
+ }
14547
+ /** Resource not found (not retryable). Accepts an optional domain-specific code. */
14548
+ static notFound(message, code) {
14549
+ return new _ToolError(message, code ?? "NOT_FOUND", { category: "not_found", retryable: false });
14550
+ }
14551
+ /** Rate limited (retryable). Accepts an optional retry delay in milliseconds and an optional domain-specific code. */
14552
+ static rateLimited(message, retryAfterMs, code) {
14553
+ return new _ToolError(message, code ?? "RATE_LIMITED", { category: "rate_limit", retryable: true, retryAfterMs });
14541
14554
  }
14542
- if ($schema === "http://json-schema.org/draft-07/schema#") {
14543
- return "draft-7";
14555
+ /** Input validation error (not retryable). Accepts an optional domain-specific code. */
14556
+ static validation(message, code) {
14557
+ return new _ToolError(message, code ?? "VALIDATION_ERROR", { category: "validation", retryable: false });
14544
14558
  }
14545
- if ($schema === "http://json-schema.org/draft-04/schema#") {
14546
- return "draft-4";
14559
+ /** Operation timed out (retryable). Accepts an optional domain-specific code. */
14560
+ static timeout(message, code) {
14561
+ return new _ToolError(message, code ?? "TIMEOUT", { category: "timeout", retryable: true });
14547
14562
  }
14548
- return defaultTarget ?? "draft-2020-12";
14549
- }
14550
- function resolveRef(ref, ctx) {
14551
- if (!ref.startsWith("#")) {
14552
- throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
14563
+ /** Internal/unexpected error (not retryable). Accepts an optional domain-specific code. */
14564
+ static internal(message, code) {
14565
+ return new _ToolError(message, code ?? "INTERNAL_ERROR", { category: "internal", retryable: false });
14553
14566
  }
14554
- const path = ref.slice(1).split("/").filter(Boolean);
14555
- if (path.length === 0) {
14556
- return ctx.rootSchema;
14567
+ };
14568
+
14569
+ // node_modules/@opentabs-dev/plugin-sdk/dist/fetch.js
14570
+ var MAX_ERROR_BODY_LENGTH = 512;
14571
+ var httpStatusToToolError = (response, message) => {
14572
+ const status = response.status;
14573
+ if (status === 401 || status === 403) {
14574
+ return ToolError.auth(message);
14557
14575
  }
14558
- const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
14559
- if (path[0] === defsKey) {
14560
- const key = path[1];
14561
- if (!key || !ctx.defs[key]) {
14562
- throw new Error(`Reference not found: ${ref}`);
14563
- }
14564
- return ctx.defs[key];
14576
+ if (status === 404) {
14577
+ return ToolError.notFound(message);
14565
14578
  }
14566
- throw new Error(`Reference not found: ${ref}`);
14567
- }
14568
- function convertBaseSchema(schema, ctx) {
14569
- if (schema.not !== void 0) {
14570
- if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
14571
- return z.never();
14572
- }
14573
- throw new Error("not is not supported in Zod (except { not: {} } for never)");
14579
+ if (status === 429) {
14580
+ const retryAfter = response.headers.get("Retry-After");
14581
+ const retryAfterMs = retryAfter !== null ? parseRetryAfterMs(retryAfter) : void 0;
14582
+ return ToolError.rateLimited(message, retryAfterMs);
14574
14583
  }
14575
- if (schema.unevaluatedItems !== void 0) {
14576
- throw new Error("unevaluatedItems is not supported");
14584
+ if (status === 400 || status === 422) {
14585
+ return ToolError.validation(message);
14577
14586
  }
14578
- if (schema.unevaluatedProperties !== void 0) {
14579
- throw new Error("unevaluatedProperties is not supported");
14587
+ if (status === 408) {
14588
+ return ToolError.timeout(message);
14580
14589
  }
14581
- if (schema.if !== void 0 || schema.then !== void 0 || schema.else !== void 0) {
14582
- throw new Error("Conditional schemas (if/then/else) are not supported");
14590
+ if (status >= 500) {
14591
+ const TRANSIENT_5XX = /* @__PURE__ */ new Set([500, 502, 503, 504]);
14592
+ const retryable = TRANSIENT_5XX.has(status);
14593
+ const retryAfter = status === 503 ? response.headers.get("Retry-After") : null;
14594
+ const retryAfterMs = retryAfter !== null ? parseRetryAfterMs(retryAfter) : void 0;
14595
+ return new ToolError(message, "http_error", { category: "internal", retryable, retryAfterMs });
14583
14596
  }
14584
- if (schema.dependentSchemas !== void 0 || schema.dependentRequired !== void 0) {
14585
- throw new Error("dependentSchemas and dependentRequired are not supported");
14597
+ if (status >= 400 && status < 500) {
14598
+ return new ToolError(message, "http_error", { retryable: false });
14586
14599
  }
14587
- if (schema.$ref) {
14588
- const refPath = schema.$ref;
14589
- if (ctx.refs.has(refPath)) {
14590
- return ctx.refs.get(refPath);
14591
- }
14592
- if (ctx.processing.has(refPath)) {
14593
- return z.lazy(() => {
14594
- if (!ctx.refs.has(refPath)) {
14595
- throw new Error(`Circular reference not resolved: ${refPath}`);
14596
- }
14597
- return ctx.refs.get(refPath);
14598
- });
14599
- }
14600
- ctx.processing.add(refPath);
14601
- const resolved = resolveRef(refPath, ctx);
14602
- const zodSchema2 = convertSchema(resolved, ctx);
14603
- ctx.refs.set(refPath, zodSchema2);
14604
- ctx.processing.delete(refPath);
14605
- return zodSchema2;
14600
+ return new ToolError(message, "http_error", { category: "internal" });
14601
+ };
14602
+ var parseRetryAfterMs = (value) => {
14603
+ const seconds = Number(value);
14604
+ if (!Number.isNaN(seconds) && seconds >= 0) {
14605
+ return seconds * 1e3;
14606
14606
  }
14607
- if (schema.enum !== void 0) {
14608
- const enumValues = schema.enum;
14609
- if (ctx.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
14610
- return z.null();
14611
- }
14612
- if (enumValues.length === 0) {
14613
- return z.never();
14614
- }
14615
- if (enumValues.length === 1) {
14616
- return z.literal(enumValues[0]);
14617
- }
14618
- if (enumValues.every((v) => typeof v === "string")) {
14619
- return z.enum(enumValues);
14620
- }
14621
- const literalSchemas = enumValues.map((v) => z.literal(v));
14622
- if (literalSchemas.length < 2) {
14623
- return literalSchemas[0];
14624
- }
14625
- return z.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
14607
+ const date5 = Date.parse(value);
14608
+ if (!Number.isNaN(date5)) {
14609
+ const ms = date5 - Date.now();
14610
+ return ms > 0 ? ms : void 0;
14626
14611
  }
14627
- if (schema.const !== void 0) {
14628
- return z.literal(schema.const);
14612
+ return void 0;
14613
+ };
14614
+ var buildQueryString = (params) => {
14615
+ const searchParams = new URLSearchParams();
14616
+ for (const [key, value] of Object.entries(params)) {
14617
+ if (value === void 0)
14618
+ continue;
14619
+ if (Array.isArray(value)) {
14620
+ for (const item of value) {
14621
+ searchParams.append(key, String(item));
14622
+ }
14623
+ } else {
14624
+ searchParams.append(key, String(value));
14625
+ }
14629
14626
  }
14630
- const type = schema.type;
14631
- if (Array.isArray(type)) {
14632
- const typeSchemas = type.map((t) => {
14633
- const typeSchema = { ...schema, type: t };
14634
- return convertBaseSchema(typeSchema, ctx);
14627
+ return searchParams.toString();
14628
+ };
14629
+ var fetchFromPage = async (url2, init) => {
14630
+ const { timeout = 3e4, signal, ...rest } = init ?? {};
14631
+ const timeoutSignal = AbortSignal.timeout(timeout);
14632
+ const combinedSignal = signal ? AbortSignal.any([signal, timeoutSignal]) : timeoutSignal;
14633
+ let response;
14634
+ try {
14635
+ response = await fetch(url2, {
14636
+ credentials: "include",
14637
+ ...rest,
14638
+ signal: combinedSignal
14635
14639
  });
14636
- if (typeSchemas.length === 0) {
14637
- return z.never();
14640
+ } catch (error51) {
14641
+ if (error51 instanceof DOMException && error51.name === "TimeoutError") {
14642
+ throw ToolError.timeout(`fetchFromPage: request timed out after ${timeout}ms for ${url2}`);
14638
14643
  }
14639
- if (typeSchemas.length === 1) {
14640
- return typeSchemas[0];
14644
+ if (combinedSignal.aborted) {
14645
+ throw new ToolError(`fetchFromPage: request aborted for ${url2}`, "aborted");
14641
14646
  }
14642
- return z.union(typeSchemas);
14647
+ throw new ToolError(`fetchFromPage: network error for ${url2}: ${toErrorMessage(error51)}`, "network_error", {
14648
+ category: "internal",
14649
+ retryable: true
14650
+ });
14643
14651
  }
14644
- if (!type) {
14645
- return z.any();
14652
+ if (!response.ok) {
14653
+ const rawText = await response.text().catch(() => response.statusText);
14654
+ const errorText = rawText.length > MAX_ERROR_BODY_LENGTH ? `${rawText.slice(0, MAX_ERROR_BODY_LENGTH)}\u2026` : rawText;
14655
+ const msg = `fetchFromPage: HTTP ${response.status} for ${url2}: ${errorText}`;
14656
+ throw httpStatusToToolError(response, msg);
14646
14657
  }
14647
- let zodSchema;
14648
- switch (type) {
14649
- case "string": {
14650
- let stringSchema = z.string();
14651
- if (schema.format) {
14652
- const format = schema.format;
14653
- if (format === "email") {
14654
- stringSchema = stringSchema.check(z.email());
14655
- } else if (format === "uri" || format === "uri-reference") {
14656
- stringSchema = stringSchema.check(z.url());
14657
- } else if (format === "uuid" || format === "guid") {
14658
- stringSchema = stringSchema.check(z.uuid());
14659
- } else if (format === "date-time") {
14660
- stringSchema = stringSchema.check(z.iso.datetime());
14661
- } else if (format === "date") {
14662
- stringSchema = stringSchema.check(z.iso.date());
14663
- } else if (format === "time") {
14664
- stringSchema = stringSchema.check(z.iso.time());
14665
- } else if (format === "duration") {
14666
- stringSchema = stringSchema.check(z.iso.duration());
14667
- } else if (format === "ipv4") {
14668
- stringSchema = stringSchema.check(z.ipv4());
14669
- } else if (format === "ipv6") {
14670
- stringSchema = stringSchema.check(z.ipv6());
14671
- } else if (format === "mac") {
14672
- stringSchema = stringSchema.check(z.mac());
14673
- } else if (format === "cidr") {
14674
- stringSchema = stringSchema.check(z.cidrv4());
14675
- } else if (format === "cidr-v6") {
14676
- stringSchema = stringSchema.check(z.cidrv6());
14677
- } else if (format === "base64") {
14678
- stringSchema = stringSchema.check(z.base64());
14679
- } else if (format === "base64url") {
14680
- stringSchema = stringSchema.check(z.base64url());
14681
- } else if (format === "e164") {
14682
- stringSchema = stringSchema.check(z.e164());
14683
- } else if (format === "jwt") {
14684
- stringSchema = stringSchema.check(z.jwt());
14685
- } else if (format === "emoji") {
14686
- stringSchema = stringSchema.check(z.emoji());
14687
- } else if (format === "nanoid") {
14688
- stringSchema = stringSchema.check(z.nanoid());
14689
- } else if (format === "cuid") {
14690
- stringSchema = stringSchema.check(z.cuid());
14691
- } else if (format === "cuid2") {
14692
- stringSchema = stringSchema.check(z.cuid2());
14693
- } else if (format === "ulid") {
14694
- stringSchema = stringSchema.check(z.ulid());
14695
- } else if (format === "xid") {
14696
- stringSchema = stringSchema.check(z.xid());
14697
- } else if (format === "ksuid") {
14698
- stringSchema = stringSchema.check(z.ksuid());
14658
+ return response;
14659
+ };
14660
+
14661
+ // node_modules/@opentabs-dev/plugin-sdk/dist/timing.js
14662
+ var waitUntil = (predicate, opts) => {
14663
+ const interval = opts?.interval ?? 200;
14664
+ const timeout = opts?.timeout ?? 1e4;
14665
+ const signal = opts?.signal;
14666
+ const abortReason = () => signal?.reason instanceof Error ? signal.reason : new Error("waitUntil: aborted");
14667
+ if (signal?.aborted)
14668
+ return Promise.reject(abortReason());
14669
+ return new Promise((resolve, reject) => {
14670
+ let settled = false;
14671
+ let poller;
14672
+ let lastPredicateError;
14673
+ const isSettled = () => settled;
14674
+ const cleanup = () => {
14675
+ settled = true;
14676
+ clearTimeout(timer);
14677
+ clearTimeout(poller);
14678
+ signal?.removeEventListener("abort", onAbort);
14679
+ };
14680
+ const onAbort = () => {
14681
+ if (isSettled())
14682
+ return;
14683
+ cleanup();
14684
+ reject(abortReason());
14685
+ };
14686
+ signal?.addEventListener("abort", onAbort, { once: true });
14687
+ const timer = setTimeout(() => {
14688
+ if (isSettled())
14689
+ return;
14690
+ cleanup();
14691
+ const errorContext = lastPredicateError instanceof Error ? `: predicate last threw \u2014 ${lastPredicateError.message}` : "";
14692
+ reject(new Error(`waitUntil: timed out after ${timeout}ms waiting for predicate to return true${errorContext}`));
14693
+ }, timeout);
14694
+ const check2 = async () => {
14695
+ if (isSettled())
14696
+ return;
14697
+ try {
14698
+ const result = await predicate();
14699
+ if (result) {
14700
+ cleanup();
14701
+ resolve();
14702
+ return;
14699
14703
  }
14704
+ } catch (err2) {
14705
+ lastPredicateError = err2;
14700
14706
  }
14701
- if (typeof schema.minLength === "number") {
14702
- stringSchema = stringSchema.min(schema.minLength);
14703
- }
14704
- if (typeof schema.maxLength === "number") {
14705
- stringSchema = stringSchema.max(schema.maxLength);
14706
- }
14707
- if (schema.pattern) {
14708
- stringSchema = stringSchema.regex(new RegExp(schema.pattern));
14709
- }
14710
- zodSchema = stringSchema;
14711
- break;
14712
- }
14713
- case "number":
14714
- case "integer": {
14715
- let numberSchema = type === "integer" ? z.number().int() : z.number();
14716
- if (typeof schema.minimum === "number") {
14717
- numberSchema = numberSchema.min(schema.minimum);
14718
- }
14719
- if (typeof schema.maximum === "number") {
14720
- numberSchema = numberSchema.max(schema.maximum);
14721
- }
14722
- if (typeof schema.exclusiveMinimum === "number") {
14723
- numberSchema = numberSchema.gt(schema.exclusiveMinimum);
14724
- } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
14725
- numberSchema = numberSchema.gt(schema.minimum);
14726
- }
14727
- if (typeof schema.exclusiveMaximum === "number") {
14728
- numberSchema = numberSchema.lt(schema.exclusiveMaximum);
14729
- } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
14730
- numberSchema = numberSchema.lt(schema.maximum);
14731
- }
14732
- if (typeof schema.multipleOf === "number") {
14733
- numberSchema = numberSchema.multipleOf(schema.multipleOf);
14707
+ if (!isSettled()) {
14708
+ poller = setTimeout(() => void check2(), interval);
14734
14709
  }
14735
- zodSchema = numberSchema;
14736
- break;
14737
- }
14738
- case "boolean": {
14739
- zodSchema = z.boolean();
14740
- break;
14741
- }
14742
- case "null": {
14743
- zodSchema = z.null();
14744
- break;
14710
+ };
14711
+ void check2();
14712
+ });
14713
+ };
14714
+
14715
+ // node_modules/@opentabs-dev/plugin-sdk/dist/log.js
14716
+ var MAX_DATA_LENGTH = 10;
14717
+ var MAX_STRING_LENGTH = 4096;
14718
+ var MAX_SERIALIZED_SIZE = 64 * 1024;
14719
+ var safeSerializeArg = (value) => {
14720
+ try {
14721
+ if (value === null || value === void 0)
14722
+ return value;
14723
+ const type = typeof value;
14724
+ if (type === "boolean" || type === "number")
14725
+ return value;
14726
+ if (type === "string") {
14727
+ return value.length > MAX_STRING_LENGTH ? `${value.slice(0, MAX_STRING_LENGTH)}\u2026` : value;
14745
14728
  }
14746
- case "object": {
14747
- const shape = {};
14748
- const properties = schema.properties || {};
14749
- const requiredSet = new Set(schema.required || []);
14750
- for (const [key, propSchema] of Object.entries(properties)) {
14751
- const propZodSchema = convertSchema(propSchema, ctx);
14752
- shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
14753
- }
14754
- if (schema.propertyNames) {
14755
- const keySchema = convertSchema(schema.propertyNames, ctx);
14756
- const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z.any();
14757
- if (Object.keys(shape).length === 0) {
14758
- zodSchema = z.record(keySchema, valueSchema);
14759
- break;
14760
- }
14761
- const objectSchema2 = z.object(shape).passthrough();
14762
- const recordSchema = z.looseRecord(keySchema, valueSchema);
14763
- zodSchema = z.intersection(objectSchema2, recordSchema);
14764
- break;
14765
- }
14766
- if (schema.patternProperties) {
14767
- const patternProps = schema.patternProperties;
14768
- const patternKeys = Object.keys(patternProps);
14769
- const looseRecords = [];
14770
- for (const pattern of patternKeys) {
14771
- const patternValue = convertSchema(patternProps[pattern], ctx);
14772
- const keySchema = z.string().regex(new RegExp(pattern));
14773
- looseRecords.push(z.looseRecord(keySchema, patternValue));
14774
- }
14775
- const schemasToIntersect = [];
14776
- if (Object.keys(shape).length > 0) {
14777
- schemasToIntersect.push(z.object(shape).passthrough());
14778
- }
14779
- schemasToIntersect.push(...looseRecords);
14780
- if (schemasToIntersect.length === 0) {
14781
- zodSchema = z.object({}).passthrough();
14782
- } else if (schemasToIntersect.length === 1) {
14783
- zodSchema = schemasToIntersect[0];
14784
- } else {
14785
- let result = z.intersection(schemasToIntersect[0], schemasToIntersect[1]);
14786
- for (let i = 2; i < schemasToIntersect.length; i++) {
14787
- result = z.intersection(result, schemasToIntersect[i]);
14729
+ if (type === "function")
14730
+ return `[Function: ${value.name || "anonymous"}]`;
14731
+ if (type === "symbol")
14732
+ return `[Symbol: ${value.description ?? ""}]`;
14733
+ if (type === "bigint")
14734
+ return `[BigInt: ${value.toString()}]`;
14735
+ if (typeof value.nodeType === "number" && typeof value.nodeName === "string") {
14736
+ try {
14737
+ const node = value;
14738
+ let classStr = "";
14739
+ if (typeof node.className === "string") {
14740
+ classStr = node.className ? `.${node.className.split(" ")[0] ?? ""}` : "";
14741
+ } else if (node.className !== null && typeof node.className === "object") {
14742
+ const baseVal = node.className.baseVal;
14743
+ if (typeof baseVal === "string") {
14744
+ classStr = baseVal ? `.${baseVal.split(" ")[0] ?? ""}` : "";
14788
14745
  }
14789
- zodSchema = result;
14790
14746
  }
14791
- break;
14792
- }
14793
- const objectSchema = z.object(shape);
14794
- if (schema.additionalProperties === false) {
14795
- zodSchema = objectSchema.strict();
14796
- } else if (typeof schema.additionalProperties === "object") {
14797
- zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
14798
- } else {
14799
- zodSchema = objectSchema.passthrough();
14747
+ return `[${node.nodeName}${node.id ? `#${node.id}` : ""}${classStr}]`;
14748
+ } catch {
14800
14749
  }
14801
- break;
14802
14750
  }
14803
- case "array": {
14804
- const prefixItems = schema.prefixItems;
14805
- const items = schema.items;
14806
- if (prefixItems && Array.isArray(prefixItems)) {
14807
- const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
14808
- const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : void 0;
14809
- if (rest) {
14810
- zodSchema = z.tuple(tupleItems).rest(rest);
14811
- } else {
14812
- zodSchema = z.tuple(tupleItems);
14813
- }
14814
- if (typeof schema.minItems === "number") {
14815
- zodSchema = zodSchema.check(z.minLength(schema.minItems));
14816
- }
14817
- if (typeof schema.maxItems === "number") {
14818
- zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
14819
- }
14820
- } else if (Array.isArray(items)) {
14821
- const tupleItems = items.map((item) => convertSchema(item, ctx));
14822
- const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : void 0;
14823
- if (rest) {
14824
- zodSchema = z.tuple(tupleItems).rest(rest);
14825
- } else {
14826
- zodSchema = z.tuple(tupleItems);
14827
- }
14828
- if (typeof schema.minItems === "number") {
14829
- zodSchema = zodSchema.check(z.minLength(schema.minItems));
14830
- }
14831
- if (typeof schema.maxItems === "number") {
14832
- zodSchema = zodSchema.check(z.maxLength(schema.maxItems));
14833
- }
14834
- } else if (items !== void 0) {
14835
- const element = convertSchema(items, ctx);
14836
- let arraySchema = z.array(element);
14837
- if (typeof schema.minItems === "number") {
14838
- arraySchema = arraySchema.min(schema.minItems);
14839
- }
14840
- if (typeof schema.maxItems === "number") {
14841
- arraySchema = arraySchema.max(schema.maxItems);
14842
- }
14843
- zodSchema = arraySchema;
14844
- } else {
14845
- zodSchema = z.array(z.any());
14846
- }
14847
- break;
14751
+ if (value instanceof Error) {
14752
+ return { name: value.name, message: value.message, stack: value.stack };
14848
14753
  }
14849
- default:
14850
- throw new Error(`Unsupported type: ${type}`);
14851
- }
14852
- return zodSchema;
14853
- }
14854
- function convertSchema(schema, ctx) {
14855
- if (typeof schema === "boolean") {
14856
- return schema ? z.any() : z.never();
14857
- }
14858
- let baseSchema = convertBaseSchema(schema, ctx);
14859
- const hasExplicitType = schema.type || schema.enum !== void 0 || schema.const !== void 0;
14860
- if (schema.anyOf && Array.isArray(schema.anyOf)) {
14861
- const options = schema.anyOf.map((s) => convertSchema(s, ctx));
14862
- const anyOfUnion = z.union(options);
14863
- baseSchema = hasExplicitType ? z.intersection(baseSchema, anyOfUnion) : anyOfUnion;
14864
- }
14865
- if (schema.oneOf && Array.isArray(schema.oneOf)) {
14866
- const options = schema.oneOf.map((s) => convertSchema(s, ctx));
14867
- const oneOfUnion = z.xor(options);
14868
- baseSchema = hasExplicitType ? z.intersection(baseSchema, oneOfUnion) : oneOfUnion;
14869
- }
14870
- if (schema.allOf && Array.isArray(schema.allOf)) {
14871
- if (schema.allOf.length === 0) {
14872
- baseSchema = hasExplicitType ? baseSchema : z.any();
14873
- } else {
14874
- let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
14875
- const startIdx = hasExplicitType ? 0 : 1;
14876
- for (let i = startIdx; i < schema.allOf.length; i++) {
14877
- result = z.intersection(result, convertSchema(schema.allOf[i], ctx));
14754
+ if (value instanceof WeakRef)
14755
+ return "[WeakRef]";
14756
+ if (value instanceof WeakMap)
14757
+ return "[WeakMap]";
14758
+ if (value instanceof WeakSet)
14759
+ return "[WeakSet]";
14760
+ if (value instanceof ArrayBuffer)
14761
+ return "[ArrayBuffer]";
14762
+ if (typeof SharedArrayBuffer !== "undefined" && value instanceof SharedArrayBuffer)
14763
+ return "[SharedArrayBuffer]";
14764
+ try {
14765
+ const seen = /* @__PURE__ */ new WeakSet();
14766
+ const json2 = JSON.stringify(value, (_key, v) => {
14767
+ if (typeof v === "object" && v !== null) {
14768
+ if (seen.has(v))
14769
+ return "[Circular]";
14770
+ seen.add(v);
14771
+ }
14772
+ if (typeof v === "function")
14773
+ return `[Function: ${v.name || "anonymous"}]`;
14774
+ if (typeof v === "bigint")
14775
+ return `[BigInt: ${v.toString()}]`;
14776
+ if (typeof v === "symbol")
14777
+ return `[Symbol: ${v.description ?? ""}]`;
14778
+ if (v instanceof WeakRef)
14779
+ return "[WeakRef]";
14780
+ if (v instanceof WeakMap)
14781
+ return "[WeakMap]";
14782
+ if (v instanceof WeakSet)
14783
+ return "[WeakSet]";
14784
+ if (v instanceof ArrayBuffer)
14785
+ return "[ArrayBuffer]";
14786
+ if (typeof SharedArrayBuffer !== "undefined" && v instanceof SharedArrayBuffer)
14787
+ return "[SharedArrayBuffer]";
14788
+ return v;
14789
+ });
14790
+ if (json2.length > MAX_SERIALIZED_SIZE) {
14791
+ return `[Object truncated: ${json2.length} chars]`;
14878
14792
  }
14879
- baseSchema = result;
14880
- }
14881
- }
14882
- if (schema.nullable === true && ctx.version === "openapi-3.0") {
14883
- baseSchema = z.nullable(baseSchema);
14884
- }
14885
- if (schema.readOnly === true) {
14886
- baseSchema = z.readonly(baseSchema);
14887
- }
14888
- if (schema.default !== void 0) {
14889
- baseSchema = baseSchema.default(schema.default);
14890
- }
14891
- const extraMeta = {};
14892
- const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
14893
- for (const key of coreMetadataKeys) {
14894
- if (key in schema) {
14895
- extraMeta[key] = schema[key];
14896
- }
14897
- }
14898
- const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
14899
- for (const key of contentMetadataKeys) {
14900
- if (key in schema) {
14901
- extraMeta[key] = schema[key];
14793
+ return JSON.parse(json2);
14794
+ } catch {
14795
+ return `[Unserializable: ${typeof value}]`;
14902
14796
  }
14797
+ } catch {
14798
+ return `[Unserializable: ${typeof value}]`;
14903
14799
  }
14904
- for (const key of Object.keys(schema)) {
14905
- if (!RECOGNIZED_KEYS.has(key)) {
14906
- extraMeta[key] = schema[key];
14800
+ };
14801
+ var safeSerialize = (args) => {
14802
+ const capped = args.length > MAX_DATA_LENGTH ? args.slice(0, MAX_DATA_LENGTH) : args;
14803
+ return capped.map(safeSerializeArg);
14804
+ };
14805
+ var CONSOLE_METHODS = {
14806
+ debug: "debug",
14807
+ info: "info",
14808
+ warning: "warn",
14809
+ error: "error"
14810
+ };
14811
+ var defaultTransport = (entry) => {
14812
+ const method = CONSOLE_METHODS[entry.level];
14813
+ console[method](`[sdk.log] ${entry.message}`, ...entry.data);
14814
+ };
14815
+ var activeTransport = defaultTransport;
14816
+ var _setLogTransport = (transport) => {
14817
+ const previous = activeTransport;
14818
+ activeTransport = transport;
14819
+ return () => {
14820
+ if (activeTransport === transport)
14821
+ activeTransport = previous;
14822
+ };
14823
+ };
14824
+ var makeLogMethod = (level) => (message, ...args) => {
14825
+ const entry = {
14826
+ level,
14827
+ message,
14828
+ data: safeSerialize(args),
14829
+ ts: (/* @__PURE__ */ new Date()).toISOString()
14830
+ };
14831
+ activeTransport(entry);
14832
+ };
14833
+ var log = Object.freeze({
14834
+ debug: makeLogMethod("debug"),
14835
+ info: makeLogMethod("info"),
14836
+ warn: makeLogMethod("warning"),
14837
+ error: makeLogMethod("error")
14838
+ });
14839
+ var ot = globalThis.__openTabs ?? {};
14840
+ globalThis.__openTabs = ot;
14841
+ ot._setLogTransport = _setLogTransport;
14842
+ ot.log = log;
14843
+
14844
+ // node_modules/@opentabs-dev/plugin-sdk/dist/page-state.js
14845
+ var BLOCKED_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
14846
+ var getPageGlobal = (path) => {
14847
+ try {
14848
+ const segments = path.split(".");
14849
+ let current = globalThis;
14850
+ for (const segment of segments) {
14851
+ if (current === null || current === void 0)
14852
+ return void 0;
14853
+ if (typeof current !== "object" && typeof current !== "function")
14854
+ return void 0;
14855
+ if (BLOCKED_SEGMENTS.has(segment))
14856
+ return void 0;
14857
+ current = current[segment];
14907
14858
  }
14859
+ return current;
14860
+ } catch {
14861
+ return void 0;
14908
14862
  }
14909
- if (Object.keys(extraMeta).length > 0) {
14910
- ctx.registry.add(baseSchema, extraMeta);
14911
- }
14912
- if (schema.description) {
14913
- baseSchema = baseSchema.describe(schema.description);
14914
- }
14915
- return baseSchema;
14916
- }
14917
- function fromJSONSchema(schema, params) {
14918
- if (typeof schema === "boolean") {
14919
- return schema ? z.any() : z.never();
14863
+ };
14864
+ var getCurrentUrl = () => window.location.href;
14865
+ var getPageTitle = () => document.title;
14866
+
14867
+ // node_modules/@opentabs-dev/plugin-sdk/dist/index.js
14868
+ var defineTool = (config2) => config2;
14869
+ var OpenTabsPlugin = class {
14870
+ /**
14871
+ * Chrome match patterns for URLs that should NOT match this plugin.
14872
+ * Tabs matching both urlPatterns and excludePatterns are excluded.
14873
+ * Useful when a broad urlPattern overlaps with another plugin's domain.
14874
+ * @see https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns
14875
+ */
14876
+ excludePatterns;
14877
+ /**
14878
+ * URL to open when no matching tab exists and the user triggers an
14879
+ * 'open tab' action from the side panel. Should be a concrete URL
14880
+ * (e.g., 'https://github.com'), not a match pattern.
14881
+ */
14882
+ homepage;
14883
+ /** Typed configuration schema — declares settings that users provide via config.json or the side panel. */
14884
+ configSchema;
14885
+ };
14886
+
14887
+ // src/fiverr-api.ts
14888
+ var getContext = () => {
14889
+ const userId = getPageGlobal("initialData.FiverrContext.userId");
14890
+ if (!userId || userId <= 0) return null;
14891
+ return {
14892
+ userId,
14893
+ userGuid: getPageGlobal("initialData.FiverrContext.userGuid") ?? "",
14894
+ csrfToken: getPageGlobal("initialData.FiverrContext.csrfToken") ?? "",
14895
+ currency: getPageGlobal("initialData.FiverrContext.currency") ?? "USD",
14896
+ countryCode: getPageGlobal("initialData.FiverrContext.countryCode") ?? "",
14897
+ locale: getPageGlobal("initialData.FiverrContext.locale") ?? "",
14898
+ isPro: getPageGlobal("initialData.FiverrContext.isPro") ?? false
14899
+ };
14900
+ };
14901
+ var getUsername = () => getPageGlobal("initialData.UserActivationMessage.username") ?? getPageGlobal("initialData.FloatingChat.currentUsername") ?? "";
14902
+ var isAuthenticated = () => getContext() !== null;
14903
+ var waitForAuth = () => waitUntil(() => isAuthenticated(), { interval: 500, timeout: 5e3 }).then(
14904
+ () => true,
14905
+ () => false
14906
+ );
14907
+ var requireContext = () => {
14908
+ const ctx = getContext();
14909
+ if (!ctx) throw ToolError.auth("Not authenticated \u2014 please log in to Fiverr.");
14910
+ return ctx;
14911
+ };
14912
+ var normalizeFiverrUsername = (value, fieldName = "username") => {
14913
+ const username = value.trim().replace(/^[@/]+/, "");
14914
+ if (!username) throw ToolError.validation(`${fieldName} is required.`);
14915
+ if (username.includes("/")) {
14916
+ throw ToolError.validation(`${fieldName} must be a single Fiverr username with no slashes.`);
14920
14917
  }
14921
- let normalized;
14918
+ return username;
14919
+ };
14920
+ var PERSEUS_ISLAND_RE = /<script[^>]*id="perseus-initial-props"[^>]*>([\s\S]*?)<\/script>/;
14921
+ var fetchPerseusProps = async (path) => {
14922
+ requireContext();
14923
+ const response = await fetchFromPage(path, { headers: { Accept: "text/html" } });
14924
+ if (!response.ok) throw httpStatusToToolError(response, `Failed to load ${path}`);
14925
+ const html = await response.text();
14926
+ const match = html.match(PERSEUS_ISLAND_RE);
14927
+ if (!match?.[1]) throw ToolError.notFound(`No page data found at ${path} \u2014 it may not exist or require login.`);
14922
14928
  try {
14923
- normalized = JSON.parse(JSON.stringify(schema));
14929
+ return JSON.parse(match[1]);
14924
14930
  } catch {
14925
- throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas");
14931
+ throw ToolError.internal(`Failed to parse page data at ${path}`);
14926
14932
  }
14927
- const version2 = detectVersion(normalized, params?.defaultTarget);
14928
- const defs = normalized.$defs || normalized.definitions || {};
14929
- const ctx = {
14930
- version: version2,
14931
- defs,
14932
- refs: /* @__PURE__ */ new Map(),
14933
- processing: /* @__PURE__ */ new Set(),
14934
- rootSchema: normalized,
14935
- registry: params?.registry ?? globalRegistry
14936
- };
14937
- return convertSchema(normalized, ctx);
14938
- }
14939
-
14940
- // node_modules/zod/v4/classic/coerce.js
14941
- var coerce_exports = {};
14942
- __export(coerce_exports, {
14943
- bigint: () => bigint3,
14944
- boolean: () => boolean3,
14945
- date: () => date4,
14946
- number: () => number3,
14947
- string: () => string3
14948
- });
14949
- function string3(params) {
14950
- return _coercedString(ZodString, params);
14951
- }
14952
- function number3(params) {
14953
- return _coercedNumber(ZodNumber, params);
14954
- }
14955
- function boolean3(params) {
14956
- return _coercedBoolean(ZodBoolean, params);
14957
- }
14958
- function bigint3(params) {
14959
- return _coercedBigint(ZodBigInt, params);
14960
- }
14961
- function date4(params) {
14962
- return _coercedDate(ZodDate, params);
14963
- }
14964
-
14965
- // node_modules/zod/v4/classic/external.js
14966
- config(en_default());
14933
+ };
14934
+ var fetchInboxJson = async (path) => {
14935
+ requireContext();
14936
+ const response = await fetchFromPage(path, {
14937
+ headers: { Accept: "application/json", "X-Requested-With": "XMLHttpRequest" }
14938
+ });
14939
+ if (!response.ok) throw httpStatusToToolError(response, `Failed to load ${path}`);
14940
+ if (response.status === 204) return null;
14941
+ return await response.json();
14942
+ };
14943
+ var SEND_MESSAGE_PATH = "/inbox/conversations/messages";
14944
+ var sendInboxMessage = async (recipientUsername, body) => {
14945
+ const ctx = requireContext();
14946
+ const response = await fetchFromPage(SEND_MESSAGE_PATH, {
14947
+ method: "POST",
14948
+ headers: {
14949
+ Accept: "application/json",
14950
+ "Content-Type": "application/json",
14951
+ "X-Requested-With": "XMLHttpRequest",
14952
+ "X-CSRF-Token": ctx.csrfToken
14953
+ },
14954
+ body: JSON.stringify({
14955
+ content_blocks: [{ type: "text", plain_text: body, plain_text_format: null }],
14956
+ content_type: "text",
14957
+ participants_usernames: [recipientUsername],
14958
+ channel_id: null,
14959
+ pending_attachment_ids: []
14960
+ })
14961
+ });
14962
+ if (!response.ok) throw httpStatusToToolError(response, "Failed to send message");
14963
+ if (response.status === 204) return { messageId: "" };
14964
+ const data = await response.json();
14965
+ return { messageId: data.id ?? data.message?.id ?? "" };
14966
+ };
14967
14967
 
14968
14968
  // src/tools/draft-message.ts
14969
14969
  var draftMessage = defineTool({
@@ -15419,7 +15419,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15419
15419
  };
15420
15420
  var src_default = new FiverrPlugin();
15421
15421
 
15422
- // dist/_adapter_entry_270f3a02-d528-4086-bdd5-e4c07ab495e8.ts
15422
+ // dist/_adapter_entry_538f2b4b-b9ea-4d72-a69a-9922dceb8bf3.ts
15423
+ external_exports.config({ jitless: true });
15423
15424
  if (!globalThis.__openTabs) {
15424
15425
  globalThis.__openTabs = {};
15425
15426
  } else {
@@ -15637,5 +15638,5 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15637
15638
  };
15638
15639
  delete src_default.onDeactivate;
15639
15640
  }
15640
- })();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["fiverr"]){var a=o.adapters["fiverr"];a.__adapterHash="3b447c82b07da8780d593d9a804077b4510011604762b635766f9d5af7c69c01";if(a.tools&&Array.isArray(a.tools)){for(var i=0;i<a.tools.length;i++){Object.freeze(a.tools[i]);}Object.freeze(a.tools);}Object.freeze(a);Object.defineProperty(o.adapters,"fiverr",{value:a,writable:false,configurable:false,enumerable:true});Object.defineProperty(o,"adapters",{value:o.adapters,writable:false,configurable:false});}})();
15641
+ })();(function(){var o=(globalThis).__openTabs;if(o&&o.adapters&&o.adapters["fiverr"]){var a=o.adapters["fiverr"];a.__adapterHash="c254b80eeb1a9302fd339b1ef64a6988825db77ad61d59ea8903179202305cc4";if(a.tools&&Array.isArray(a.tools)){for(var i=0;i<a.tools.length;i++){Object.freeze(a.tools[i]);}Object.freeze(a.tools);}Object.freeze(a);Object.defineProperty(o.adapters,"fiverr",{value:a,writable:false,configurable:false,enumerable:true});Object.defineProperty(o,"adapters",{value:o.adapters,writable:false,configurable:false});}})();
15641
15642
  //# sourceMappingURL=adapter.iife.js.map