import{createRequire as X}from"node:module";var R=Object.defineProperty;var U=(B)=>B;function V(B,x){this[B]=U.bind(null,x)}var J=(B,x)=>{for(var F in x)R(B,F,{get:x[F],enumerable:!0,configurable:!0,set:V.bind(x,F)})};var W=(B,x)=>()=>(B&&(x=B(B=0)),x);var C=X(import.meta.url);import{z as D}from"zod";function H(B){let x=B,F=(E)=>{return x.nullable?D.union([E,D.null()]):E};if(x.const!==void 0)return D.literal(x.const);if(x.enum){let E=x.enum;return F(D.enum(E.map(String)))}if(x.anyOf&&x.anyOf.length>0){let E=x.anyOf.map((G)=>H(G));if(E.length===1)return E[0]??D.unknown();return D.union([E[0]??D.unknown(),E[1]??D.unknown(),...E.slice(2)])}if(x.oneOf&&x.oneOf.length>0){let E=x.oneOf.map((G)=>H(G));if(E.length===1)return E[0]??D.unknown();return D.union([E[0]??D.unknown(),E[1]??D.unknown(),...E.slice(2)])}if(x.allOf&&x.allOf.length>0)return x.allOf.map((G)=>H(G)).reduce((G,K)=>D.intersection(G,K));switch(x.type){case"string":return F(Y(x));case"number":case"integer":return F(_(x));case"boolean":return F(D.boolean());case"null":return D.null();case"array":return F($(x));case"object":return F(f(x));default:return D.unknown()}}function Y(B){let x=D.string();if(B.description)x=x.describe(B.description);switch(B.format){case"email":x=x.email();break;case"uri":case"url":x=x.url();break;case"uuid":x=x.uuid();break;case"date-time":x=x.datetime();break;case"date":x=x.date();break}if(B.minLength!==void 0)x=x.min(B.minLength);if(B.maxLength!==void 0)x=x.max(B.maxLength);if(B.pattern)x=x.regex(new RegExp(B.pattern));return x}function _(B){let x=B.type==="integer"?D.number().int():D.number();if(B.description)x=x.describe(B.description);if(B.minimum!==void 0)x=x.min(B.minimum);if(B.maximum!==void 0)x=x.max(B.maximum);return x}function $(B){let x=B.items?H(B.items):D.unknown(),F=D.array(x);if(B.description)F=F.describe(B.description);return F}function f(B){let x=B.properties??{},F=new Set(B.required??[]),E={};for(let[K,Q]of Object.entries(x)){let M=H(Q);E[K]=F.has(K)?M:M.optional()}let G=D.object(E);if(B.description)G=G.describe(B.description);return G}function N(B){if(!B||Object.keys(B).length===0)return D.object({});return H(B)}var L=()=>{};L();import{Output as I}from"ai";function g(B){let x=H(B);return I.object({schema:x})}function q(B){let x=H(B);return I.array({element:x})}function w(B){return I.choice({options:B})}function v(B){return I.object({schema:B})}function A(){return I.text()}var j={fromJsonSchema:g,arrayFromJsonSchema:q,fromEnum:w,fromZod:v,text:A};L();export{v as zodToOutput,A as textOutput,N as jsonSchemaToZodSafe,H as jsonSchemaToZod,g as jsonSchemaToOutput,q as jsonSchemaToArrayOutput,w as enumToChoiceOutput,j as SchemaOutput};
