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EAA4C;AAChG,EAAA,MAAM,SAAA,GAAY,MAAA;AAGlB,EAAA,IAAI,QAAA,KAAa,aAAA,IAAiB,QAAA,KAAa,aAAA,IAAiB,aAAa,YAAA,EAAc;AACzF,IAAA,OAAO,SAAA,CAAU,IAAA,EAAM,GAAA,EAAK,SAAA,IAAa,UAAU,IAAA,EAAM,SAAA;AAAA,EAC3D;AAGA,EAAA,IAAI,aAAa,YAAA,EAAc;AAC7B,IAAA,OAAO,SAAA,CAAU,IAAA,EAAM,GAAA,EAAK,MAAA,IAAU,UAAU,IAAA,EAAM,MAAA;AAAA,EACxD;AAGA,EAAA,IAAI,aAAa,YAAA,EAAc;AAC7B,IAAA,OAAO,SAAA,CAAU,IAAA,EAAM,GAAA,EAAK,IAAA,IAAQ,UAAU,IAAA,EAAM,IAAA;AAAA,EACtD;AAEA,EAAA,OAAO,MAAA;AACT;AAWO,SAAS,cAAc,MAAA,EAAoC;AAChE,EAAA,IAAI,OAAA,GAAU,MAAA;AACd,EAAA,OAAO,IAAA,EAAM;AACX,IAAA,MAAM,QAAA,GAAW,eAAe,OAAO,CAAA;AACvC,IAAA,IAAI,CAAC,QAAA,EAAU;AACf,IAAA,MAAM,KAAA,GAAQ,eAAA,CAAgB,OAAA,EAAS,QAAQ,CAAA;AAC/C,IAAA,IAAI,CAAC,KAAA,EAAO;AACZ,IAAA,OAAA,GAAU,KAAA;AAAA,EACZ;AACA,EAAA,OAAO,OAAA;AACT","file":"chunk-RLPRSIR2.cjs","sourcesContent":["import type { z } from 'zod/v4';\n\ntype ZodTypeAny = z.ZodType<any, any>;\ntype ZodObjectAny = z.ZodObject<any>;\ntype ZodArrayAny = z.ZodArray<any>;\n\n/**\n * Checks if a value is a Zod type\n * @param value - The value to check\n * @returns True if the value is a Zod type, false otherwise\n */\nexport function isZodType(value: unknown): value is ZodTypeAny {\n  // Check if it's a Zod schema by looking for common Zod properties and methods\n  return (\n    typeof value === 'object' &&\n    value !== null &&\n    '_def' in value &&\n    'parse' in value &&\n    typeof (value as any).parse === 'function' &&\n    'safeParse' in value &&\n    typeof (value as any).safeParse === 'function'\n  );\n}\n\n/**\n * Get the Zod typeName from a schema, compatible with both Zod 3 and Zod 4.\n * Uses string-based typeName instead of instanceof to avoid dual-package hazard\n * where multiple Zod instances can cause instanceof checks to fail.\n *\n * Zod 3 uses `_def.typeName` with values like \"ZodString\", \"ZodOptional\", etc.\n * Zod 4 uses `_def.type` with lowercase values like \"string\", \"optional\", etc.\n *\n * This function normalizes to Zod 3 format (e.g., \"ZodString\") for compatibility.\n *\n * @param schema - The Zod schema to get the type name from\n * @returns The Zod type name string (e.g., \"ZodString\", \"ZodOptional\") or undefined\n */\nexport function getZodTypeName(schema: ZodTypeAny): string | undefined {\n  const schemaAny = schema as any;\n\n  // Zod 3 structure: _def.typeName = \"ZodString\", \"ZodOptional\", etc.\n  if (schemaAny._def?.typeName) {\n    return schemaAny._def.typeName;\n  }\n\n  // Zod 4 structure: _def.type = \"string\", \"optional\", etc. (lowercase, no prefix)\n  const zod4Type = schemaAny._def?.type;\n  if (typeof zod4Type === 'string' && zod4Type) {\n    // Normalize to Zod 3 format: \"string\" -> \"ZodString\", \"optional\" -> \"ZodOptional\"\n    return 'Zod' + zod4Type.charAt(0).toUpperCase() + zod4Type.slice(1);\n  }\n\n  return undefined;\n}\n\n/**\n * Check if a value is a ZodArray type\n * @param value - The value to check (can be any type)\n * @returns True if the value is a ZodArray\n */\nexport function isZodArray(value: unknown): value is ZodArrayAny {\n  if (!isZodType(value)) return false;\n  return getZodTypeName(value as ZodTypeAny) === 'ZodArray';\n}\n\n/**\n * Check if a value is a ZodObject type\n * @param value - The value to check (can be any type)\n * @returns True if the value is a ZodObject\n */\nexport function isZodObject(value: unknown): value is ZodObjectAny {\n  if (!isZodType(value)) return false;\n  return getZodTypeName(value as ZodTypeAny) === 'ZodObject';\n}\n\n/**\n * Get the def object from a Zod schema, compatible with both Zod 3 and Zod 4.\n * @param schema - The Zod schema\n * @returns The def object\n */\nexport function getZodDef(schema: ZodTypeAny): any {\n  const schemaAny = schema as any;\n  return schemaAny._zod?.def ?? schemaAny._def;\n}\n\n/**\n * Get the inner type from a wrapper schema (nullable, optional, default, effects, branded).\n * Compatible with both Zod 3 and Zod 4.\n *\n * @param schema - The wrapper Zod schema\n * @param typeName - The Zod type name of the wrapper (e.g., \"ZodOptional\")\n * @returns The inner schema, or undefined if not found\n */\nexport function getZodInnerType(schema: z.ZodTypeAny, typeName: string): z.ZodTypeAny | undefined {\n  const schemaAny = schema as any;\n\n  // For nullable, optional, default - the inner type is at _def.innerType\n  if (typeName === 'ZodNullable' || typeName === 'ZodOptional' || typeName === 'ZodDefault') {\n    return schemaAny._zod?.def?.innerType ?? schemaAny._def?.innerType;\n  }\n\n  // For effects - the inner type is at _def.schema\n  if (typeName === 'ZodEffects') {\n    return schemaAny._zod?.def?.schema ?? schemaAny._def?.schema;\n  }\n\n  // For branded - the inner type is at _def.type\n  if (typeName === 'ZodBranded') {\n    return schemaAny._zod?.def?.type ?? schemaAny._def?.type;\n  }\n\n  return undefined;\n}\n\n/**\n * Unwraps Zod wrapper types (optional, nullable, default, effects, branded)\n * to find the base schema type. Compatible with both Zod 3 and Zod 4.\n *\n * For example, `z.array(z.string()).nullish().default([])` unwraps to `z.array(z.string())`.\n *\n * @param schema - The Zod schema to unwrap\n * @returns The innermost base schema\n */\nexport function unwrapZodType(schema: z.ZodTypeAny): z.ZodTypeAny {\n  let current = schema;\n  while (true) {\n    const typeName = getZodTypeName(current);\n    if (!typeName) break;\n    const inner = getZodInnerType(current, typeName);\n    if (!inner) break;\n    current = inner;\n  }\n  return current;\n}\n"]}