// @bun
var R=Object.defineProperty;var U=(B)=>B;function V(B,x){this[B]=U.bind(null,x)}var A=(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 J=import.meta.require;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(X(x));case"number":case"integer":return F(Y(x));case"boolean":return F(D.boolean());case"null":return D.null();case"array":return F(_(x));case"object":return F($(x));default:return D.unknown()}}function X(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 Y(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 $(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 y(B){if(!B||Object.keys(B).length===0)return D.object({});return H(B)}var L=()=>{};L();import{Output as I}from"ai";function f(B){let x=H(B);return I.object({schema:x})}function g(B){let x=H(B);return I.array({element:x})}function q(B){return I.choice({options:B})}function w(B){return I.object({schema:B})}function v(){return I.text()}var T={fromJsonSchema:f,arrayFromJsonSchema:g,fromEnum:q,fromZod:w,text:v};L();export{w as zodToOutput,v as textOutput,y as jsonSchemaToZodSafe,H as jsonSchemaToZod,f as jsonSchemaToOutput,g as jsonSchemaToArrayOutput,q as enumToChoiceOutput,T as SchemaOutput};
