UNPKG

json-to-sql-parser

Version:

A TypeScript library that converts JSON-based query specifications into safe SQL queries

1,632 lines (1,613 loc) 496 kB
var __defProp = Object.defineProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true, configurable: true, set: (newValue) => all[name] = () => newValue }); }; // src/constants/errors.ts var JSON_ACCESS_TYPE_ERROR = (path, field, type) => `JSON path access '${path}' is only allowed on JSON fields, but field '${field}' is of type '${type}'`; var invalidJsonAccessReasons = { format: "Expected format: ->jsonPathSegment->...->'jsonLastSegment' or ->'jsonPathSegment'->...->>jsonLastSegment", quote: "Unterminated quote in JSON access path" }; var INVALID_JSON_ACCESS_ERROR = (jsonAccess, reason) => `Invalid JSON access path '${jsonAccess}'. ${invalidJsonAccessReasons[reason]}`; var INVALID_OPERATOR_VALUE_TYPE_ERROR = (operator, type) => `${operator.toUpperCase().slice(1)} operator requires a ${type} value`; var FUNCTION_TYPE_MISMATCH_ERROR = (functionName, fieldType, type) => `Type mismatch for '${functionName}': expected ${fieldType}, got ${type}`; var COMPARISON_TYPE_MISMATCH_ERROR = (operator, field, fieldType, type) => `Field type mismatch for '${operator}' comparison on '${field}': expected ${fieldType}, got ${type}`; var INVALID_ARGUMENT_COUNT_ERROR = (functionName, argCount, count, variadic) => `Function '${functionName}' requires ${variadic ? "at least" : "exactly"} ${argCount} argument${argCount !== 1 ? "s" : ""}, got ${count}`; var MISSING_AGGREGATION_FIELD_ERROR = "Aggregation query must have at least one group by field or aggregated field"; var FORBIDDEN_EXISTING_ROW_EVALUATION_ON_INSERT_ERROR = "Evaluations on existing rows are not allowed during INSERT. Use 'NEW_ROW' as a prefix for evaluating new row values, or $exists to apply a condition on existing rows."; var NON_EMPTY_CONDITION_ARRAY_ERROR = (operator) => `${operator} condition should be a non-empty array.`; var MATHEMATICAL_OPERATORS_NOT_SUPPORTED_IN_DIALECT_ERROR = (operator, dialect) => `Advanced mathematical operators (such as '${operator}') are not supported in dialect '${dialect}'`; // src/constants/dialects.ts var Dialect; ((Dialect2) => { Dialect2["POSTGRESQL"] = "postgresql"; Dialect2["SQLITE_MINIMAL"] = "sqlite-3.44-minimal"; Dialect2["SQLITE_EXTENSIONS"] = "sqlite-3.44-extensions"; })(Dialect ||= {}); // src/utils/function-call.ts function removeAllWrappingParens(expression) { expression = expression.trim(); while (expression.startsWith("(") && expression.endsWith(")")) { let depth = 0; let wraps = true; for (let i = 0;i < expression.length; i++) { if (expression[i] === "(") depth++; if (expression[i] === ")") depth--; if (depth === 0 && i < expression.length - 1) { wraps = false; break; } } if (wraps) expression = expression.slice(1, -1).trim(); else break; } return expression; } function applyFunction(functionName, args) { return `${functionName}(${args.map((arg) => removeAllWrappingParens(arg)).join(", ")})`; } // src/functions/aggregate.ts var aggregationFunctions = [ { name: "COUNT", expressionType: "any" }, { name: "SUM", expressionType: "number" }, { name: "AVG", expressionType: "number" }, { name: "MIN", expressionType: "number" }, { name: "MAX", expressionType: "number" }, { name: "STDDEV", expressionType: "number", toSQL: (expression, _, dialect) => { if (dialect === "postgresql" /* POSTGRESQL */) return `STDDEV(${expression})`; return `SQRT(AVG(POW(${expression}, 2))-POW(AVG(${expression}),2))`; } }, { name: "VARIANCE", expressionType: "number", toSQL: (expression, _, dialect) => { if (dialect === "postgresql" /* POSTGRESQL */) return `VARIANCE(${expression})`; return `AVG(POW(${expression}, 2))-POW(AVG(${expression}),2)`; } }, { name: "COUNT_DISTINCT", expressionType: "any", toSQL: (expression) => `COUNT(DISTINCT ${expression})` }, { name: "STRING_AGG", expressionType: "string", additionalArgumentTypes: ["string"], toSQL: (expression, args, dialect) => { if (dialect === "postgresql" /* POSTGRESQL */) return applyFunction("STRING_AGG", [expression, ...args]); return applyFunction("GROUP_CONCAT", [expression, ...args]); } } ]; var aggregationFunctionNames = aggregationFunctions.map(({ name }) => name); var allowedAggregationFunctions = aggregationFunctions; // node_modules/uuid/dist/esm/stringify.js var byteToHex = []; for (let i = 0;i < 256; ++i) { byteToHex.push((i + 256).toString(16).slice(1)); } function unsafeStringify(arr, offset = 0) { return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); } // node_modules/uuid/dist/esm/rng.js import { randomFillSync } from "crypto"; var rnds8Pool = new Uint8Array(256); var poolPtr = rnds8Pool.length; function rng() { if (poolPtr > rnds8Pool.length - 16) { randomFillSync(rnds8Pool); poolPtr = 0; } return rnds8Pool.slice(poolPtr, poolPtr += 16); } // node_modules/uuid/dist/esm/native.js import { randomUUID } from "crypto"; var native_default = { randomUUID }; // node_modules/uuid/dist/esm/v4.js function v4(options, buf, offset) { if (native_default.randomUUID && !buf && !options) { return native_default.randomUUID(); } options = options || {}; const rnds = options.random ?? options.rng?.() ?? rng(); if (rnds.length < 16) { throw new Error("Random bytes length must be >= 16"); } rnds[6] = rnds[6] & 15 | 64; rnds[8] = rnds[8] & 63 | 128; if (buf) { offset = offset || 0; if (offset < 0 || offset + 16 > buf.length) { throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`); } for (let i = 0;i < 16; ++i) { buf[offset + i] = rnds[i]; } return buf; } return unsafeStringify(rnds); } var v4_default = v4; // src/utils/index.ts function isNotNull(value) { return value !== null; } function isNonEmptyArray(value) { return Array.isArray(value) && value.length > 0; } function objectSize(obj) { return Object.keys(obj).length; } function objectKeys(obj) { return Object.keys(obj); } function objectEntries(obj) { return Object.entries(obj); } var quote = (str) => `'${str.replaceAll(/'/g, "''")}'`; var doubleQuote = (str) => `"${str.replaceAll(/"/g, '""')}"`; // src/utils/parse-values.ts function parseTimestamp(value) { const date = new Date(value.replace(" ", "T")); if (Number.isNaN(date.getTime())) throw new Error("Invalid timestamp format"); return date; } function parseDate(value) { const date = new Date(value); if (Number.isNaN(date.getTime())) throw new Error("Invalid date format"); return date; } // src/parsers/parse-json-access.ts var segmentCharacter = "[0-9a-z_]"; var segmentRegex = `(?:(?:'[^']+'|${segmentCharacter}+))`; var fieldPathRegex = `->(?:>${segmentRegex}|${segmentRegex}(?:->${segmentRegex})*(?:->>${segmentRegex})?)`; var jsonAccessRegex = new RegExp(`^${fieldPathRegex}$`); var segmentCharacterRegex = new RegExp(segmentCharacter); function parseJsonAccess(jsonAccessPath) { if (!jsonAccessRegex.test(jsonAccessPath)) throw new Error(INVALID_JSON_ACCESS_ERROR(jsonAccessPath, "format")); const segments = []; let i = 2; let currentSegment = ""; let jsonExtractText = false; while (i < jsonAccessPath.length) { const char = jsonAccessPath[i]; if (char === "-" && i + 1 < jsonAccessPath.length && jsonAccessPath[i + 1] === ">") { if (currentSegment) { segments.push(currentSegment); currentSegment = ""; } i += 2; if (i < jsonAccessPath.length && jsonAccessPath[i] === ">") { jsonExtractText = true; i++; } continue; } if (i === 2 && char === ">") { jsonExtractText = true; i++; continue; } if (char === "'") { i++; let quotedContent = ""; while (i < jsonAccessPath.length && jsonAccessPath[i] !== "'") { quotedContent += jsonAccessPath[i]; i++; } if (i >= jsonAccessPath.length) throw new Error(INVALID_JSON_ACCESS_ERROR(jsonAccessPath, "quote")); i++; currentSegment = quotedContent; } else { let character = jsonAccessPath[i]; while (i < jsonAccessPath.length && character && segmentCharacterRegex.test(character)) { currentSegment += character; i++; character = jsonAccessPath[i]; } } } if (currentSegment) segments.push(currentSegment); return { jsonAccess: segments, jsonExtractText: jsonExtractText || undefined }; } // node_modules/zod/v4/classic/external.js var exports_external = {}; __export(exports_external, { xid: () => xid2, void: () => _void2, uuidv7: () => uuidv7, uuidv6: () => uuidv6, uuidv4: () => uuidv4, uuid: () => uuid2, util: () => exports_util, url: () => url, uppercase: () => _uppercase, unknown: () => unknown, union: () => union, undefined: () => _undefined3, ulid: () => ulid2, uint64: () => uint64, uint32: () => uint32, tuple: () => tuple, trim: () => _trim, treeifyError: () => treeifyError, transform: () => transform, toUpperCase: () => _toUpperCase, toLowerCase: () => _toLowerCase, toJSONSchema: () => toJSONSchema, templateLiteral: () => templateLiteral, symbol: () => symbol, superRefine: () => superRefine, success: () => success, stringbool: () => stringbool, stringFormat: () => stringFormat, string: () => string2, strictObject: () => strictObject, startsWith: () => _startsWith, size: () => _size, setErrorMap: () => setErrorMap, set: () => set, safeParseAsync: () => safeParseAsync2, safeParse: () => safeParse2, safeEncodeAsync: () => safeEncodeAsync2, safeEncode: () => safeEncode2, safeDecodeAsync: () => safeDecodeAsync2, safeDecode: () => safeDecode2, registry: () => registry, regexes: () => exports_regexes, regex: () => _regex, refine: () => refine, record: () => record, readonly: () => readonly, property: () => _property, promise: () => promise, prettifyError: () => prettifyError, preprocess: () => preprocess, prefault: () => prefault, positive: () => _positive, pipe: () => pipe, partialRecord: () => partialRecord, parseAsync: () => parseAsync2, parse: () => parse3, overwrite: () => _overwrite, optional: () => optional, object: () => object, number: () => number2, nullish: () => nullish2, nullable: () => nullable, null: () => _null3, normalize: () => _normalize, nonpositive: () => _nonpositive, nonoptional: () => nonoptional, nonnegative: () => _nonnegative, never: () => never, negative: () => _negative, nativeEnum: () => nativeEnum, nanoid: () => nanoid2, nan: () => nan, multipleOf: () => _multipleOf, minSize: () => _minSize, minLength: () => _minLength, mime: () => _mime, maxSize: () => _maxSize, maxLength: () => _maxLength, map: () => map, lte: () => _lte, lt: () => _lt, lowercase: () => _lowercase, looseObject: () => looseObject, locales: () => exports_locales, literal: () => literal, length: () => _length, lazy: () => lazy, ksuid: () => ksuid2, keyof: () => keyof, jwt: () => jwt, json: () => json, iso: () => exports_iso, ipv6: () => ipv62, ipv4: () => ipv42, intersection: () => intersection, int64: () => int64, int32: () => int32, int: () => int, instanceof: () => _instanceof, includes: () => _includes, httpUrl: () => httpUrl, hostname: () => hostname2, hex: () => hex2, hash: () => hash, guid: () => guid2, gte: () => _gte, gt: () => _gt, globalRegistry: () => globalRegistry, getErrorMap: () => getErrorMap, function: () => _function, formatError: () => formatError, float64: () => float64, float32: () => float32, flattenError: () => flattenError, file: () => file, enum: () => _enum2, endsWith: () => _endsWith, encodeAsync: () => encodeAsync2, encode: () => encode2, emoji: () => emoji2, email: () => email2, e164: () => e1642, discriminatedUnion: () => discriminatedUnion, decodeAsync: () => decodeAsync2, decode: () => decode2, date: () => date3, custom: () => custom, cuid2: () => cuid22, cuid: () => cuid3, core: () => exports_core2, config: () => config, coerce: () => exports_coerce, codec: () => codec, clone: () => clone, cidrv6: () => cidrv62, cidrv4: () => cidrv42, check: () => check, catch: () => _catch2, boolean: () => boolean2, bigint: () => bigint2, base64url: () => base64url2, base64: () => base642, array: () => array, any: () => any, _function: () => _function, _default: () => _default2, _ZodString: () => _ZodString, ZodXID: () => ZodXID, ZodVoid: () => ZodVoid, ZodUnknown: () => ZodUnknown, ZodUnion: () => ZodUnion, ZodUndefined: () => ZodUndefined, ZodUUID: () => ZodUUID, ZodURL: () => ZodURL, ZodULID: () => ZodULID, ZodType: () => ZodType, ZodTuple: () => ZodTuple, ZodTransform: () => ZodTransform, ZodTemplateLiteral: () => ZodTemplateLiteral, ZodSymbol: () => ZodSymbol, ZodSuccess: () => ZodSuccess, ZodStringFormat: () => ZodStringFormat, ZodString: () => ZodString, ZodSet: () => ZodSet, ZodRecord: () => ZodRecord, ZodRealError: () => ZodRealError, ZodReadonly: () => ZodReadonly, ZodPromise: () => ZodPromise, ZodPrefault: () => ZodPrefault, ZodPipe: () => ZodPipe, ZodOptional: () => ZodOptional, ZodObject: () => ZodObject, ZodNumberFormat: () => ZodNumberFormat, ZodNumber: () => ZodNumber, ZodNullable: () => ZodNullable, ZodNull: () => ZodNull, ZodNonOptional: () => ZodNonOptional, ZodNever: () => ZodNever, ZodNanoID: () => ZodNanoID, ZodNaN: () => ZodNaN, ZodMap: () => ZodMap, ZodLiteral: () => ZodLiteral, ZodLazy: () => ZodLazy, ZodKSUID: () => ZodKSUID, ZodJWT: () => ZodJWT, ZodIssueCode: () => ZodIssueCode, ZodIntersection: () => ZodIntersection, ZodISOTime: () => ZodISOTime, ZodISODuration: () => ZodISODuration, ZodISODateTime: () => ZodISODateTime, ZodISODate: () => ZodISODate, ZodIPv6: () => ZodIPv6, ZodIPv4: () => ZodIPv4, ZodGUID: () => ZodGUID, ZodFunction: () => ZodFunction, ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind, ZodFile: () => ZodFile, ZodError: () => ZodError, ZodEnum: () => ZodEnum, ZodEmoji: () => ZodEmoji, ZodEmail: () => ZodEmail, ZodE164: () => ZodE164, ZodDiscriminatedUnion: () => ZodDiscriminatedUnion, ZodDefault: () => ZodDefault, ZodDate: () => ZodDate, ZodCustomStringFormat: () => ZodCustomStringFormat, ZodCustom: () => ZodCustom, ZodCodec: () => ZodCodec, ZodCatch: () => ZodCatch, ZodCUID2: () => ZodCUID2, ZodCUID: () => ZodCUID, ZodCIDRv6: () => ZodCIDRv6, ZodCIDRv4: () => ZodCIDRv4, ZodBoolean: () => ZodBoolean, ZodBigIntFormat: () => ZodBigIntFormat, ZodBigInt: () => ZodBigInt, ZodBase64URL: () => ZodBase64URL, ZodBase64: () => ZodBase64, ZodArray: () => ZodArray, ZodAny: () => ZodAny, TimePrecision: () => TimePrecision, NEVER: () => NEVER, $output: () => $output, $input: () => $input, $brand: () => $brand }); // node_modules/zod/v4/core/index.js var exports_core2 = {}; __export(exports_core2, { version: () => version, util: () => exports_util, treeifyError: () => treeifyError, toJSONSchema: () => toJSONSchema, toDotPath: () => toDotPath, safeParseAsync: () => safeParseAsync, safeParse: () => safeParse, safeEncodeAsync: () => safeEncodeAsync, safeEncode: () => safeEncode, safeDecodeAsync: () => safeDecodeAsync, safeDecode: () => safeDecode, registry: () => registry, regexes: () => exports_regexes, prettifyError: () => prettifyError, parseAsync: () => parseAsync, parse: () => parse, locales: () => exports_locales, isValidJWT: () => isValidJWT, isValidBase64URL: () => isValidBase64URL, isValidBase64: () => isValidBase64, globalRegistry: () => globalRegistry, globalConfig: () => globalConfig, formatError: () => formatError, flattenError: () => flattenError, encodeAsync: () => encodeAsync, encode: () => encode, decodeAsync: () => decodeAsync, decode: () => decode, config: () => config, clone: () => clone, _xid: () => _xid, _void: () => _void, _uuidv7: () => _uuidv7, _uuidv6: () => _uuidv6, _uuidv4: () => _uuidv4, _uuid: () => _uuid, _url: () => _url, _uppercase: () => _uppercase, _unknown: () => _unknown, _union: () => _union, _undefined: () => _undefined2, _ulid: () => _ulid, _uint64: () => _uint64, _uint32: () => _uint32, _tuple: () => _tuple, _trim: () => _trim, _transform: () => _transform, _toUpperCase: () => _toUpperCase, _toLowerCase: () => _toLowerCase, _templateLiteral: () => _templateLiteral, _symbol: () => _symbol, _superRefine: () => _superRefine, _success: () => _success, _stringbool: () => _stringbool, _stringFormat: () => _stringFormat, _string: () => _string, _startsWith: () => _startsWith, _size: () => _size, _set: () => _set, _safeParseAsync: () => _safeParseAsync, _safeParse: () => _safeParse, _safeEncodeAsync: () => _safeEncodeAsync, _safeEncode: () => _safeEncode, _safeDecodeAsync: () => _safeDecodeAsync, _safeDecode: () => _safeDecode, _regex: () => _regex, _refine: () => _refine, _record: () => _record, _readonly: () => _readonly, _property: () => _property, _promise: () => _promise, _positive: () => _positive, _pipe: () => _pipe, _parseAsync: () => _parseAsync, _parse: () => _parse, _overwrite: () => _overwrite, _optional: () => _optional, _number: () => _number, _nullable: () => _nullable, _null: () => _null2, _normalize: () => _normalize, _nonpositive: () => _nonpositive, _nonoptional: () => _nonoptional, _nonnegative: () => _nonnegative, _never: () => _never, _negative: () => _negative, _nativeEnum: () => _nativeEnum, _nanoid: () => _nanoid, _nan: () => _nan, _multipleOf: () => _multipleOf, _minSize: () => _minSize, _minLength: () => _minLength, _min: () => _gte, _mime: () => _mime, _maxSize: () => _maxSize, _maxLength: () => _maxLength, _max: () => _lte, _map: () => _map, _lte: () => _lte, _lt: () => _lt, _lowercase: () => _lowercase, _literal: () => _literal, _length: () => _length, _lazy: () => _lazy, _ksuid: () => _ksuid, _jwt: () => _jwt, _isoTime: () => _isoTime, _isoDuration: () => _isoDuration, _isoDateTime: () => _isoDateTime, _isoDate: () => _isoDate, _ipv6: () => _ipv6, _ipv4: () => _ipv4, _intersection: () => _intersection, _int64: () => _int64, _int32: () => _int32, _int: () => _int, _includes: () => _includes, _guid: () => _guid, _gte: () => _gte, _gt: () => _gt, _float64: () => _float64, _float32: () => _float32, _file: () => _file, _enum: () => _enum, _endsWith: () => _endsWith, _encodeAsync: () => _encodeAsync, _encode: () => _encode, _emoji: () => _emoji2, _email: () => _email, _e164: () => _e164, _discriminatedUnion: () => _discriminatedUnion, _default: () => _default, _decodeAsync: () => _decodeAsync, _decode: () => _decode, _date: () => _date, _custom: () => _custom, _cuid2: () => _cuid2, _cuid: () => _cuid, _coercedString: () => _coercedString, _coercedNumber: () => _coercedNumber, _coercedDate: () => _coercedDate, _coercedBoolean: () => _coercedBoolean, _coercedBigint: () => _coercedBigint, _cidrv6: () => _cidrv6, _cidrv4: () => _cidrv4, _check: () => _check, _catch: () => _catch, _boolean: () => _boolean, _bigint: () => _bigint, _base64url: () => _base64url, _base64: () => _base64, _array: () => _array, _any: () => _any, TimePrecision: () => TimePrecision, NEVER: () => NEVER, JSONSchemaGenerator: () => JSONSchemaGenerator, JSONSchema: () => exports_json_schema, Doc: () => Doc, $output: () => $output, $input: () => $input, $constructor: () => $constructor, $brand: () => $brand, $ZodXID: () => $ZodXID, $ZodVoid: () => $ZodVoid, $ZodUnknown: () => $ZodUnknown, $ZodUnion: () => $ZodUnion, $ZodUndefined: () => $ZodUndefined, $ZodUUID: () => $ZodUUID, $ZodURL: () => $ZodURL, $ZodULID: () => $ZodULID, $ZodType: () => $ZodType, $ZodTuple: () => $ZodTuple, $ZodTransform: () => $ZodTransform, $ZodTemplateLiteral: () => $ZodTemplateLiteral, $ZodSymbol: () => $ZodSymbol, $ZodSuccess: () => $ZodSuccess, $ZodStringFormat: () => $ZodStringFormat, $ZodString: () => $ZodString, $ZodSet: () => $ZodSet, $ZodRegistry: () => $ZodRegistry, $ZodRecord: () => $ZodRecord, $ZodRealError: () => $ZodRealError, $ZodReadonly: () => $ZodReadonly, $ZodPromise: () => $ZodPromise, $ZodPrefault: () => $ZodPrefault, $ZodPipe: () => $ZodPipe, $ZodOptional: () => $ZodOptional, $ZodObjectJIT: () => $ZodObjectJIT, $ZodObject: () => $ZodObject, $ZodNumberFormat: () => $ZodNumberFormat, $ZodNumber: () => $ZodNumber, $ZodNullable: () => $ZodNullable, $ZodNull: () => $ZodNull, $ZodNonOptional: () => $ZodNonOptional, $ZodNever: () => $ZodNever, $ZodNanoID: () => $ZodNanoID, $ZodNaN: () => $ZodNaN, $ZodMap: () => $ZodMap, $ZodLiteral: () => $ZodLiteral, $ZodLazy: () => $ZodLazy, $ZodKSUID: () => $ZodKSUID, $ZodJWT: () => $ZodJWT, $ZodIntersection: () => $ZodIntersection, $ZodISOTime: () => $ZodISOTime, $ZodISODuration: () => $ZodISODuration, $ZodISODateTime: () => $ZodISODateTime, $ZodISODate: () => $ZodISODate, $ZodIPv6: () => $ZodIPv6, $ZodIPv4: () => $ZodIPv4, $ZodGUID: () => $ZodGUID, $ZodFunction: () => $ZodFunction, $ZodFile: () => $ZodFile, $ZodError: () => $ZodError, $ZodEnum: () => $ZodEnum, $ZodEncodeError: () => $ZodEncodeError, $ZodEmoji: () => $ZodEmoji, $ZodEmail: () => $ZodEmail, $ZodE164: () => $ZodE164, $ZodDiscriminatedUnion: () => $ZodDiscriminatedUnion, $ZodDefault: () => $ZodDefault, $ZodDate: () => $ZodDate, $ZodCustomStringFormat: () => $ZodCustomStringFormat, $ZodCustom: () => $ZodCustom, $ZodCodec: () => $ZodCodec, $ZodCheckUpperCase: () => $ZodCheckUpperCase, $ZodCheckStringFormat: () => $ZodCheckStringFormat, $ZodCheckStartsWith: () => $ZodCheckStartsWith, $ZodCheckSizeEquals: () => $ZodCheckSizeEquals, $ZodCheckRegex: () => $ZodCheckRegex, $ZodCheckProperty: () => $ZodCheckProperty, $ZodCheckOverwrite: () => $ZodCheckOverwrite, $ZodCheckNumberFormat: () => $ZodCheckNumberFormat, $ZodCheckMultipleOf: () => $ZodCheckMultipleOf, $ZodCheckMinSize: () => $ZodCheckMinSize, $ZodCheckMinLength: () => $ZodCheckMinLength, $ZodCheckMimeType: () => $ZodCheckMimeType, $ZodCheckMaxSize: () => $ZodCheckMaxSize, $ZodCheckMaxLength: () => $ZodCheckMaxLength, $ZodCheckLowerCase: () => $ZodCheckLowerCase, $ZodCheckLessThan: () => $ZodCheckLessThan, $ZodCheckLengthEquals: () => $ZodCheckLengthEquals, $ZodCheckIncludes: () => $ZodCheckIncludes, $ZodCheckGreaterThan: () => $ZodCheckGreaterThan, $ZodCheckEndsWith: () => $ZodCheckEndsWith, $ZodCheckBigIntFormat: () => $ZodCheckBigIntFormat, $ZodCheck: () => $ZodCheck, $ZodCatch: () => $ZodCatch, $ZodCUID2: () => $ZodCUID2, $ZodCUID: () => $ZodCUID, $ZodCIDRv6: () => $ZodCIDRv6, $ZodCIDRv4: () => $ZodCIDRv4, $ZodBoolean: () => $ZodBoolean, $ZodBigIntFormat: () => $ZodBigIntFormat, $ZodBigInt: () => $ZodBigInt, $ZodBase64URL: () => $ZodBase64URL, $ZodBase64: () => $ZodBase64, $ZodAsyncError: () => $ZodAsyncError, $ZodArray: () => $ZodArray, $ZodAny: () => $ZodAny }); // node_modules/zod/v4/core/core.js var NEVER = Object.freeze({ status: "aborted" }); function $constructor(name, initializer, params) { function init(inst, def) { var _a; Object.defineProperty(inst, "_zod", { value: inst._zod ?? {}, enumerable: false }); (_a = inst._zod).traits ?? (_a.traits = new Set); inst._zod.traits.add(name); initializer(inst, def); for (const k in _.prototype) { if (!(k in inst)) Object.defineProperty(inst, k, { value: _.prototype[k].bind(inst) }); } inst._zod.constr = _; inst._zod.def = def; } const Parent = params?.Parent ?? Object; class Definition extends Parent { } Object.defineProperty(Definition, "name", { value: name }); function _(def) { var _a; const inst = params?.Parent ? new Definition : this; init(inst, def); (_a = inst._zod).deferred ?? (_a.deferred = []); for (const fn of inst._zod.deferred) { fn(); } return inst; } Object.defineProperty(_, "init", { value: init }); Object.defineProperty(_, Symbol.hasInstance, { value: (inst) => { if (params?.Parent && inst instanceof params.Parent) return true; return inst?._zod?.traits?.has(name); } }); Object.defineProperty(_, "name", { value: name }); return _; } var $brand = Symbol("zod_brand"); class $ZodAsyncError extends Error { constructor() { super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`); } } class $ZodEncodeError extends Error { constructor(name) { super(`Encountered unidirectional transform during encode: ${name}`); this.name = "ZodEncodeError"; } } var globalConfig = {}; function config(newConfig) { if (newConfig) Object.assign(globalConfig, newConfig); return globalConfig; } // node_modules/zod/v4/core/util.js var exports_util = {}; __export(exports_util, { unwrapMessage: () => unwrapMessage, uint8ArrayToHex: () => uint8ArrayToHex, uint8ArrayToBase64url: () => uint8ArrayToBase64url, uint8ArrayToBase64: () => uint8ArrayToBase64, stringifyPrimitive: () => stringifyPrimitive, shallowClone: () => shallowClone, safeExtend: () => safeExtend, required: () => required, randomString: () => randomString, propertyKeyTypes: () => propertyKeyTypes, promiseAllObject: () => promiseAllObject, primitiveTypes: () => primitiveTypes, prefixIssues: () => prefixIssues, pick: () => pick, partial: () => partial, optionalKeys: () => optionalKeys, omit: () => omit, objectClone: () => objectClone, numKeys: () => numKeys, nullish: () => nullish, normalizeParams: () => normalizeParams, mergeDefs: () => mergeDefs, merge: () => merge, jsonStringifyReplacer: () => jsonStringifyReplacer, joinValues: () => joinValues, issue: () => issue, isPlainObject: () => isPlainObject, isObject: () => isObject, hexToUint8Array: () => hexToUint8Array, getSizableOrigin: () => getSizableOrigin, getParsedType: () => getParsedType, getLengthableOrigin: () => getLengthableOrigin, getEnumValues: () => getEnumValues, getElementAtPath: () => getElementAtPath, floatSafeRemainder: () => floatSafeRemainder, finalizeIssue: () => finalizeIssue, extend: () => extend, escapeRegex: () => escapeRegex, esc: () => esc, defineLazy: () => defineLazy, createTransparentProxy: () => createTransparentProxy, cloneDef: () => cloneDef, clone: () => clone, cleanRegex: () => cleanRegex, cleanEnum: () => cleanEnum, captureStackTrace: () => captureStackTrace, cached: () => cached, base64urlToUint8Array: () => base64urlToUint8Array, base64ToUint8Array: () => base64ToUint8Array, assignProp: () => assignProp, assertNotEqual: () => assertNotEqual, assertNever: () => assertNever, assertIs: () => assertIs, assertEqual: () => assertEqual, assert: () => assert, allowsEval: () => allowsEval, aborted: () => aborted, NUMBER_FORMAT_RANGES: () => NUMBER_FORMAT_RANGES, Class: () => Class, BIGINT_FORMAT_RANGES: () => BIGINT_FORMAT_RANGES }); function assertEqual(val) { return val; } function assertNotEqual(val) { return val; } function assertIs(_arg) {} function assertNever(_x) { throw new Error; } function assert(_) {} function getEnumValues(entries) { const numericValues = Object.values(entries).filter((v) => typeof v === "number"); const values = Object.entries(entries).filter(([k, _]) => numericValues.indexOf(+k) === -1).map(([_, v]) => v); return values; } function joinValues(array, separator = "|") { return array.map((val) => stringifyPrimitive(val)).join(separator); } function jsonStringifyReplacer(_, value) { if (typeof value === "bigint") return value.toString(); return value; } function cached(getter) { const set = false; return { get value() { if (!set) { const value = getter(); Object.defineProperty(this, "value", { value }); return value; } throw new Error("cached value already set"); } }; } function nullish(input) { return input === null || input === undefined; } function cleanRegex(source) { const start = source.startsWith("^") ? 1 : 0; const end = source.endsWith("$") ? source.length - 1 : source.length; return source.slice(start, end); } function floatSafeRemainder(val, step) { const valDecCount = (val.toString().split(".")[1] || "").length; const stepString = step.toString(); let stepDecCount = (stepString.split(".")[1] || "").length; if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) { const match = stepString.match(/\d?e-(\d?)/); if (match?.[1]) { stepDecCount = Number.parseInt(match[1]); } } const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount; const valInt = Number.parseInt(val.toFixed(decCount).replace(".", "")); const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", "")); return valInt % stepInt / 10 ** decCount; } var EVALUATING = Symbol("evaluating"); function defineLazy(object, key, getter) { let value = undefined; Object.defineProperty(object, key, { get() { if (value === EVALUATING) { return; } if (value === undefined) { value = EVALUATING; value = getter(); } return value; }, set(v) { Object.defineProperty(object, key, { value: v }); }, configurable: true }); } function objectClone(obj) { return Object.create(Object.getPrototypeOf(obj), Object.getOwnPropertyDescriptors(obj)); } function assignProp(target, prop, value) { Object.defineProperty(target, prop, { value, writable: true, enumerable: true, configurable: true }); } function mergeDefs(...defs) { const mergedDescriptors = {}; for (const def of defs) { const descriptors = Object.getOwnPropertyDescriptors(def); Object.assign(mergedDescriptors, descriptors); } return Object.defineProperties({}, mergedDescriptors); } function cloneDef(schema) { return mergeDefs(schema._zod.def); } function getElementAtPath(obj, path) { if (!path) return obj; return path.reduce((acc, key) => acc?.[key], obj); } function promiseAllObject(promisesObj) { const keys = Object.keys(promisesObj); const promises = keys.map((key) => promisesObj[key]); return Promise.all(promises).then((results) => { const resolvedObj = {}; for (let i = 0;i < keys.length; i++) { resolvedObj[keys[i]] = results[i]; } return resolvedObj; }); } function randomString(length = 10) { const chars = "abcdefghijklmnopqrstuvwxyz"; let str = ""; for (let i = 0;i < length; i++) { str += chars[Math.floor(Math.random() * chars.length)]; } return str; } function esc(str) { return JSON.stringify(str); } var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {}; function isObject(data) { return typeof data === "object" && data !== null && !Array.isArray(data); } var allowsEval = cached(() => { if (typeof navigator !== "undefined" && navigator?.userAgent?.includes("Cloudflare")) { return false; } try { const F = Function; new F(""); return true; } catch (_) { return false; } }); function isPlainObject(o) { if (isObject(o) === false) return false; const ctor = o.constructor; if (ctor === undefined) return true; const prot = ctor.prototype; if (isObject(prot) === false) return false; if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) { return false; } return true; } function shallowClone(o) { if (isPlainObject(o)) return { ...o }; return o; } function numKeys(data) { let keyCount = 0; for (const key in data) { if (Object.prototype.hasOwnProperty.call(data, key)) { keyCount++; } } return keyCount; } var getParsedType = (data) => { const t = typeof data; switch (t) { case "undefined": return "undefined"; case "string": return "string"; case "number": return Number.isNaN(data) ? "nan" : "number"; case "boolean": return "boolean"; case "function": return "function"; case "bigint": return "bigint"; case "symbol": return "symbol"; case "object": if (Array.isArray(data)) { return "array"; } if (data === null) { return "null"; } if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") { return "promise"; } if (typeof Map !== "undefined" && data instanceof Map) { return "map"; } if (typeof Set !== "undefined" && data instanceof Set) { return "set"; } if (typeof Date !== "undefined" && data instanceof Date) { return "date"; } if (typeof File !== "undefined" && data instanceof File) { return "file"; } return "object"; default: throw new Error(`Unknown data type: ${t}`); } }; var propertyKeyTypes = new Set(["string", "number", "symbol"]); var primitiveTypes = new Set(["string", "number", "bigint", "boolean", "symbol", "undefined"]); function escapeRegex(str) { return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); } function clone(inst, def, params) { const cl = new inst._zod.constr(def ?? inst._zod.def); if (!def || params?.parent) cl._zod.parent = inst; return cl; } function normalizeParams(_params) { const params = _params; if (!params) return {}; if (typeof params === "string") return { error: () => params }; if (params?.message !== undefined) { if (params?.error !== undefined) throw new Error("Cannot specify both `message` and `error` params"); params.error = params.message; } delete params.message; if (typeof params.error === "string") return { ...params, error: () => params.error }; return params; } function createTransparentProxy(getter) { let target; return new Proxy({}, { get(_, prop, receiver) { target ?? (target = getter()); return Reflect.get(target, prop, receiver); }, set(_, prop, value, receiver) { target ?? (target = getter()); return Reflect.set(target, prop, value, receiver); }, has(_, prop) { target ?? (target = getter()); return Reflect.has(target, prop); }, deleteProperty(_, prop) { target ?? (target = getter()); return Reflect.deleteProperty(target, prop); }, ownKeys(_) { target ?? (target = getter()); return Reflect.ownKeys(target); }, getOwnPropertyDescriptor(_, prop) { target ?? (target = getter()); return Reflect.getOwnPropertyDescriptor(target, prop); }, defineProperty(_, prop, descriptor) { target ?? (target = getter()); return Reflect.defineProperty(target, prop, descriptor); } }); } function stringifyPrimitive(value) { if (typeof value === "bigint") return value.toString() + "n"; if (typeof value === "string") return `"${value}"`; return `${value}`; } function optionalKeys(shape) { return Object.keys(shape).filter((k) => { return shape[k]._zod.optin === "optional" && shape[k]._zod.optout === "optional"; }); } var NUMBER_FORMAT_RANGES = { safeint: [Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER], int32: [-2147483648, 2147483647], uint32: [0, 4294967295], float32: [-340282346638528860000000000000000000000, 340282346638528860000000000000000000000], float64: [-Number.MAX_VALUE, Number.MAX_VALUE] }; var BIGINT_FORMAT_RANGES = { int64: [/* @__PURE__ */ BigInt("-9223372036854775808"), /* @__PURE__ */ BigInt("9223372036854775807")], uint64: [/* @__PURE__ */ BigInt(0), /* @__PURE__ */ BigInt("18446744073709551615")] }; function pick(schema, mask) { const currDef = schema._zod.def; const def = mergeDefs(schema._zod.def, { get shape() { const newShape = {}; for (const key in mask) { if (!(key in currDef.shape)) { throw new Error(`Unrecognized key: "${key}"`); } if (!mask[key]) continue; newShape[key] = currDef.shape[key]; } assignProp(this, "shape", newShape); return newShape; }, checks: [] }); return clone(schema, def); } function omit(schema, mask) { const currDef = schema._zod.def; const def = mergeDefs(schema._zod.def, { get shape() { const newShape = { ...schema._zod.def.shape }; for (const key in mask) { if (!(key in currDef.shape)) { throw new Error(`Unrecognized key: "${key}"`); } if (!mask[key]) continue; delete newShape[key]; } assignProp(this, "shape", newShape); return newShape; }, checks: [] }); return clone(schema, def); } function extend(schema, shape) { if (!isPlainObject(shape)) { throw new Error("Invalid input to extend: expected a plain object"); } const checks = schema._zod.def.checks; const hasChecks = checks && checks.length > 0; if (hasChecks) { throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead."); } const def = mergeDefs(schema._zod.def, { get shape() { const _shape = { ...schema._zod.def.shape, ...shape }; assignProp(this, "shape", _shape); return _shape; }, checks: [] }); return clone(schema, def); } function safeExtend(schema, shape) { if (!isPlainObject(shape)) { throw new Error("Invalid input to safeExtend: expected a plain object"); } const def = { ...schema._zod.def, get shape() { const _shape = { ...schema._zod.def.shape, ...shape }; assignProp(this, "shape", _shape); return _shape; }, checks: schema._zod.def.checks }; return clone(schema, def); } function merge(a, b) { const def = mergeDefs(a._zod.def, { get shape() { const _shape = { ...a._zod.def.shape, ...b._zod.def.shape }; assignProp(this, "shape", _shape); return _shape; }, get catchall() { return b._zod.def.catchall; }, checks: [] }); return clone(a, def); } function partial(Class, schema, mask) { const def = mergeDefs(schema._zod.def, { get shape() { const oldShape = schema._zod.def.shape; const shape = { ...oldShape }; if (mask) { for (const key in mask) { if (!(key in oldShape)) { throw new Error(`Unrecognized key: "${key}"`); } if (!mask[key]) continue; shape[key] = Class ? new Class({ type: "optional", innerType: oldShape[key] }) : oldShape[key]; } } else { for (const key in oldShape) { shape[key] = Class ? new Class({ type: "optional", innerType: oldShape[key] }) : oldShape[key]; } } assignProp(this, "shape", shape); return shape; }, checks: [] }); return clone(schema, def); } function required(Class, schema, mask) { const def = mergeDefs(schema._zod.def, { get shape() { const oldShape = schema._zod.def.shape; const shape = { ...oldShape }; if (mask) { for (const key in mask) { if (!(key in shape)) { throw new Error(`Unrecognized key: "${key}"`); } if (!mask[key]) continue; shape[key] = new Class({ type: "nonoptional", innerType: oldShape[key] }); } } else { for (const key in oldShape) { shape[key] = new Class({ type: "nonoptional", innerType: oldShape[key] }); } } assignProp(this, "shape", shape); return shape; }, checks: [] }); return clone(schema, def); } function aborted(x, startIndex = 0) { if (x.aborted === true) return true; for (let i = startIndex;i < x.issues.length; i++) { if (x.issues[i]?.continue !== true) { return true; } } return false; } function prefixIssues(path, issues) { return issues.map((iss) => { var _a; (_a = iss).path ?? (_a.path = []); iss.path.unshift(path); return iss; }); } function unwrapMessage(message) { return typeof message === "string" ? message : message?.message; } function finalizeIssue(iss, ctx, config2) { const full = { ...iss, path: iss.path ?? [] }; if (!iss.message) { const message = unwrapMessage(iss.inst?._zod.def?.error?.(iss)) ?? unwrapMessage(ctx?.error?.(iss)) ?? unwrapMessage(config2.customError?.(iss)) ?? unwrapMessage(config2.localeError?.(iss)) ?? "Invalid input"; full.message = message; } delete full.inst; delete full.continue; if (!ctx?.reportInput) { delete full.input; } return full; } function getSizableOrigin(input) { if (input instanceof Set) return "set"; if (input instanceof Map) return "map"; if (input instanceof File) return "file"; return "unknown"; } function getLengthableOrigin(input) { if (Array.isArray(input)) return "array"; if (typeof input === "string") return "string"; return "unknown"; } function issue(...args) { const [iss, input, inst] = args; if (typeof iss === "string") { return { message: iss, code: "custom", input, inst }; } return { ...iss }; } function cleanEnum(obj) { return Object.entries(obj).filter(([k, _]) => { return Number.isNaN(Number.parseInt(k, 10)); }).map((el) => el[1]); } function base64ToUint8Array(base64) { const binaryString = atob(base64); const bytes = new Uint8Array(binaryString.length); for (let i = 0;i < binaryString.length; i++) { bytes[i] = binaryString.charCodeAt(i); } return bytes; } function uint8ArrayToBase64(bytes) { let binaryString = ""; for (let i = 0;i < bytes.length; i++) { binaryString += String.fromCharCode(bytes[i]); } return btoa(binaryString); } function base64urlToUint8Array(base64url) { const base64 = base64url.replace(/-/g, "+").replace(/_/g, "/"); const padding = "=".repeat((4 - base64.length % 4) % 4); return base64ToUint8Array(base64 + padding); } function uint8ArrayToBase64url(bytes) { return uint8ArrayToBase64(bytes).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, ""); } function hexToUint8Array(hex) { const cleanHex = hex.replace(/^0x/, ""); if (cleanHex.length % 2 !== 0) { throw new Error("Invalid hex string length"); } const bytes = new Uint8Array(cleanHex.length / 2); for (let i = 0;i < cleanHex.length; i += 2) { bytes[i / 2] = Number.parseInt(cleanHex.slice(i, i + 2), 16); } return bytes; } function uint8ArrayToHex(bytes) { return Array.from(bytes).map((b) => b.toString(16).padStart(2, "0")).join(""); } class Class { constructor(..._args) {} } // node_modules/zod/v4/core/errors.js var initializer = (inst, def) => { inst.name = "$ZodError"; Object.defineProperty(inst, "_zod", { value: inst._zod, enumerable: false }); Object.defineProperty(inst, "issues", { value: def, enumerable: false }); inst.message = JSON.stringify(def, jsonStringifyReplacer, 2); Object.defineProperty(inst, "toString", { value: () => inst.message, enumerable: false }); }; var $ZodError = $constructor("$ZodError", initializer); var $ZodRealError = $constructor("$ZodError", initializer, { Parent: Error }); function flattenError(error, mapper = (issue2) => issue2.message) { const fieldErrors = {}; const formErrors = []; for (const sub of error.issues) { if (sub.path.length > 0) { fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || []; fieldErrors[sub.path[0]].push(mapper(sub)); } else { formErrors.push(mapper(sub)); } } return { formErrors, fieldErrors }; } function formatError(error, _mapper) { const mapper = _mapper || function(issue2) { return issue2.message; }; const fieldErrors = { _errors: [] }; const processError = (error2) => { for (const issue2 of error2.issues) { if (issue2.code === "invalid_union" && issue2.errors.length) { issue2.errors.map((issues) => processError({ issues })); } else if (issue2.code === "invalid_key") { processError({ issues: issue2.issues }); } else if (issue2.code === "invalid_element") { processError({ issues: issue2.issues }); } else if (issue2.path.length === 0) { fieldErrors._errors.push(mapper(issue2)); } else { let curr = fieldErrors; let i = 0; while (i < issue2.path.length) { const el = issue2.path[i]; const terminal = i === issue2.path.length - 1; if (!terminal) { curr[el] = curr[el] || { _errors: [] }; } else { curr[el] = curr[el] || { _errors: [] }; curr[el]._errors.push(mapper(issue2)); } curr = curr[el]; i++; } } } }; processError(error); return fieldErrors; } function treeifyError(error, _mapper) { const mapper = _mapper || function(issue2) { return issue2.message; }; const result = { errors: [] }; const processError = (error2, path = []) => { var _a, _b; for (const issue2 of error2.issues) { if (issue2.code === "invalid_union" && issue2.errors.length) { issue2.errors.map((issues) => processError({ issues }, issue2.path)); } else if (issue2.code === "invalid_key") { processError({ issues: issue2.issues }, issue2.path); } else if (issue2.code === "invalid_element") { processError({ issues: issue2.issues }, issue2.path); } else { const fullpath = [...path, ...issue2.path]; if (fullpath.length === 0) { result.errors.push(mapper(issue2)); continue; } let curr = result; let i = 0; while (i < fullpath.length) { const el = fullpath[i]; const terminal = i === fullpath.length - 1; if (typeof el === "string") { curr.properties ?? (curr.properties = {}); (_a = curr.properties)[el] ?? (_a[el] = { errors: [] }); curr = curr.properties[el]; } else { curr.items ?? (curr.items = []); (_b = curr.items)[el] ?? (_b[el] = { errors: [] }); curr = curr.items[el]; } if (terminal) { curr.errors.push(mapper(issue2)); } i++; } } } }; processError(error); return result; } function toDotPath(_path) { const segs = []; const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg); for (const seg of path) { if (typeof seg === "number") segs.push(`[${seg}]`); else if (typeof seg === "symbol") segs.push(`[${JSON.stringify(String(seg))}]`); else if (/[^\w$]/.test(seg)) segs.push(`[${JSON.stringify(seg)}]`); else { if (segs.length) segs.push("."); segs.push(seg); } } return segs.join(""); } function prettifyError(error) { const lines = []; const issues = [...error.issues].sort((a, b) => (a.path ?? []).length - (b.path ?? []).length); for (const issue2 of issues) { lines.push(`✖ ${issue2.message}`); if (issue2.path?.length) lines.push(` → at ${toDotPath(issue2.path)}`); } return lines.join(` `); } // node_modules/zod/v4/core/parse.js var _parse = (_Err) => (schema, value, _ctx, _params) => { const ctx = _ctx ? Object.assign(_ctx, { async: false }) : { async: false }; const result = schema._zod.run({ value, issues: [] }, ctx); if (result instanceof Promise) { throw new $ZodAsyncError; } if (result.issues.length) { const e = new (_params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))); captureStackTrace(e, _params?.callee); throw e; } return result.value; }; var parse = /* @__PURE__ */ _parse($ZodRealError); var _parseAsync = (_Err) => async (schema, value, _ctx, params) => { const ctx = _ctx ? Object.assign(_ctx, { async: true }) : { async: true }; let result = schema._zod.run({ value, issues: [] }, ctx); if (result instanceof Promise) result = await result; if (result.issues.length) { const e = new (params?.Err ?? _Err)(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))); captureStackTrace(e, params?.callee); throw e; } return result.value; }; var parseAsync = /* @__PURE__ */ _parseAsync($ZodRealError); var _safeParse = (_Err) => (schema, value, _ctx) => { const ctx = _ctx ? { ..._ctx, async: false } : { async: false }; const result = schema._zod.run({ value, issues: [] }, ctx); if (result instanceof Promise) { throw new $ZodAsyncError; } return result.issues.length ? { success: false, error: new (_Err ?? $ZodError)(result.issues.map((iss) => finalizeIssue(iss, ctx, config()))) } : { success: true, data: result.value }; }; var saf