// @bun
import{Jv as K,kv as qW,mv as LW}from"./chunk-0dcnzv90.js";var TQ="vercel.ai.error",yW=Symbol.for(TQ),e,QQ,D=class Q extends(QQ=Error,e=yW,QQ){constructor({name:W,message:X,cause:Y}){super(X);this[e]=!0,this.name=W,this.cause=Y}static isInstance(W){return Q.hasMarker(W,TQ)}static hasMarker(W,X){let Y=Symbol.for(X);return W!=null&&typeof W==="object"&&Y in W&&typeof W[Y]==="boolean"&&W[Y]===!0}},IQ="AI_APICallError",jQ=`vercel.ai.error.${IQ}`,vW=Symbol.for(jQ),WQ,XQ,z=class extends(XQ=D,WQ=vW,XQ){constructor({message:Q,url:W,requestBodyValues:X,statusCode:Y,responseHeaders:Z,responseBody:$,cause:J,isRetryable:w=Y!=null&&(Y===408||Y===409||Y===429||Y>=500),data:M}){super({name:IQ,message:Q,cause:J});this[WQ]=!0,this.url=W,this.requestBodyValues=X,this.statusCode=Y,this.responseHeaders=Z,this.responseBody=$,this.isRetryable=w,this.data=M}static isInstance(Q){return D.hasMarker(Q,jQ)}},_Q="AI_EmptyResponseBodyError",bQ=`vercel.ai.error.${_Q}`,xW=Symbol.for(bQ),YQ,ZQ,SQ=class extends(ZQ=D,YQ=xW,ZQ){constructor({message:Q="Empty response body"}={}){super({name:_Q,message:Q});this[YQ]=!0}static isInstance(Q){return D.hasMarker(Q,bQ)}};function gQ(Q){if(Q==null)return"unknown error";if(typeof Q==="string")return Q;if(Q instanceof Error)return Q.message;return JSON.stringify(Q)}var kQ="AI_InvalidArgumentError",yQ=`vercel.ai.error.${kQ}`,mW=Symbol.for(yQ),$Q,JQ,x=class extends(JQ=D,$Q=mW,JQ){constructor({message:Q,cause:W,argument:X}){super({name:kQ,message:Q,cause:W});this[$Q]=!0,this.argument=X}static isInstance(Q){return D.hasMarker(Q,yQ)}},vQ="AI_InvalidPromptError",xQ=`vercel.ai.error.${vQ}`,hW=Symbol.for(xQ),wQ,UQ,UY=class extends(UQ=D,wQ=hW,UQ){constructor({prompt:Q,message:W,cause:X}){super({name:vQ,message:`Invalid prompt: ${W}`,cause:X});this[wQ]=!0,this.prompt=Q}static isInstance(Q){return D.hasMarker(Q,xQ)}},mQ="AI_InvalidResponseDataError",hQ=`vercel.ai.error.${mQ}`,pW=Symbol.for(hQ),GQ,MQ,GY=class extends(MQ=D,GQ=pW,MQ){constructor({data:Q,message:W=`Invalid response data: ${JSON.stringify(Q)}.`}){super({name:mQ,message:W});this[GQ]=!0,this.data=Q}static isInstance(Q){return D.hasMarker(Q,hQ)}},pQ="AI_JSONParseError",iQ=`vercel.ai.error.${pQ}`,iW=Symbol.for(iQ),FQ,KQ,S=class extends(KQ=D,FQ=iW,KQ){constructor({text:Q,cause:W}){super({name:pQ,message:`JSON parsing failed: Text: ${Q}.
Error message: ${gQ(W)}`,cause:W});this[FQ]=!0,this.text=Q}static isInstance(Q){return D.hasMarker(Q,iQ)}},lQ="AI_LoadAPIKeyError",fQ=`vercel.ai.error.${lQ}`,lW=Symbol.for(fQ),qQ,LQ,g=class extends(LQ=D,qQ=lW,LQ){constructor({message:Q}){super({name:lQ,message:Q});this[qQ]=!0}static isInstance(Q){return D.hasMarker(Q,fQ)}},uQ="AI_LoadSettingError",dQ=`vercel.ai.error.${uQ}`,fW=Symbol.for(dQ),DQ,OQ,k=class extends(OQ=D,DQ=fW,OQ){constructor({message:Q}){super({name:uQ,message:Q});this[DQ]=!0}static isInstance(Q){return D.hasMarker(Q,dQ)}},cQ="AI_NoContentGeneratedError",nQ=`vercel.ai.error.${cQ}`,uW=Symbol.for(nQ),zQ,HQ,MY=class extends(HQ=D,zQ=uW,HQ){constructor({message:Q="No content generated."}={}){super({name:cQ,message:Q});this[zQ]=!0}static isInstance(Q){return D.hasMarker(Q,nQ)}},tQ="AI_NoSuchModelError",oQ=`vercel.ai.error.${tQ}`,dW=Symbol.for(oQ),AQ,BQ,FY=class extends(BQ=D,AQ=dW,BQ){constructor({errorName:Q=tQ,modelId:W,modelType:X,message:Y=`No such ${X}: ${W}`}){super({name:Q,message:Y});this[AQ]=!0,this.modelId=W,this.modelType=X}static isInstance(Q){return D.hasMarker(Q,oQ)}},aQ="AI_TooManyEmbeddingValuesForCallError",sQ=`vercel.ai.error.${aQ}`,cW=Symbol.for(sQ),EQ,RQ,KY=class extends(RQ=D,EQ=cW,RQ){constructor(Q){super({name:aQ,message:`Too many values for a single embedding call. The ${Q.provider} model "${Q.modelId}" can only embed up to ${Q.maxEmbeddingsPerCall} values per call, but ${Q.values.length} values were provided.`});this[EQ]=!0,this.provider=Q.provider,this.modelId=Q.modelId,this.maxEmbeddingsPerCall=Q.maxEmbeddingsPerCall,this.values=Q.values}static isInstance(Q){return D.hasMarker(Q,sQ)}},rQ="AI_TypeValidationError",eQ=`vercel.ai.error.${rQ}`,nW=Symbol.for(eQ),PQ,NQ,V=class Q extends(NQ=D,PQ=nW,NQ){constructor({value:W,cause:X,context:Y}){let Z="Type validation failed";if(Y==null?void 0:Y.field)Z+=` for ${Y.field}`;if((Y==null?void 0:Y.entityName)||(Y==null?void 0:Y.entityId)){Z+=" (";let $=[];if(Y.entityName)$.push(Y.entityName);if(Y.entityId)$.push(`id: "${Y.entityId}"`);Z+=$.join(", "),Z+=")"}super({name:rQ,message:`${Z}: Value: ${JSON.stringify(W)}.
Error message: ${gQ(X)}`,cause:X});this[PQ]=!0,this.value=W,this.context=Y}static isInstance(W){return D.hasMarker(W,eQ)}static wrap({value:W,cause:X,context:Y}){var Z,$,J;if(Q.isInstance(X)&&X.value===W&&((Z=X.context)==null?void 0:Z.field)===(Y==null?void 0:Y.field)&&(($=X.context)==null?void 0:$.entityName)===(Y==null?void 0:Y.entityName)&&((J=X.context)==null?void 0:J.entityId)===(Y==null?void 0:Y.entityId))return X;return new Q({value:W,cause:X,context:Y})}},QW="AI_UnsupportedFunctionalityError",WW=`vercel.ai.error.${QW}`,tW=Symbol.for(WW),CQ,VQ,qY=class extends(VQ=D,CQ=tW,VQ){constructor({functionality:Q,message:W=`'${Q}' functionality not supported.`}){super({name:QW,message:W});this[CQ]=!0,this.functionality=Q}static isInstance(Q){return D.hasMarker(Q,WW)}};class i extends Error{constructor(Q,W){super(Q),this.name="ParseError",this.type=W.type,this.field=W.field,this.value=W.value,this.line=W.line}}var XW=10,oW=13,T=32;function p(Q){}function $W(Q){if(typeof Q=="function")throw TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");let{onEvent:W=p,onError:X=p,onRetry:Y=p,onComment:Z}=Q,$=[],J=!0,w,M="",U=0,q;function j(F){if(J&&(J=!1,F.charCodeAt(0)===239&&F.charCodeAt(1)===187&&F.charCodeAt(2)===191&&(F=F.slice(3))),$.length===0){let A=b(F);A!==""&&$.push(A);return}if(F.indexOf(`
`)===-1&&F.indexOf("\r")===-1){$.push(F);return}$.push(F);let G=$.join("");$.length=0;let L=b(G);L!==""&&$.push(L)}function b(F){let G=0;if(F.indexOf("\r")===-1){let L=F.indexOf(`
`,G);for(;L!==-1;){if(G===L){U>0&&W({id:w,event:q,data:M}),w=void 0,M="",U=0,q=void 0,G=L+1,L=F.indexOf(`
`,G);continue}let A=F.charCodeAt(G);if(YW(F,G,A)){let H=F.charCodeAt(G+5)===T?G+6:G+5,C=F.slice(H,L);if(U===0&&F.charCodeAt(L+1)===XW){W({id:w,event:q,data:C}),w=void 0,M="",q=void 0,G=L+2,L=F.indexOf(`
`,G);continue}M=U===0?C:`${M}
${C}`,U++}else ZW(F,G,A)?q=F.slice(F.charCodeAt(G+6)===T?G+7:G+6,L)||void 0:h(F,G,L);G=L+1,L=F.indexOf(`
`,G)}return F.slice(G)}for(;G<F.length;){let L=F.indexOf("\r",G),A=F.indexOf(`
`,G),H=-1;if(L!==-1&&A!==-1?H=L<A?L:A:L!==-1?L===F.length-1?H=-1:H=L:A!==-1&&(H=A),H===-1)break;h(F,G,H),G=H+1,F.charCodeAt(G-1)===oW&&F.charCodeAt(G)===XW&&G++}return F.slice(G)}function h(F,G,L){if(G===L){_W();return}let A=F.charCodeAt(G);if(YW(F,G,A)){let _=F.charCodeAt(G+5)===T?G+6:G+5,r=F.slice(_,L);M=U===0?r:`${M}
${r}`,U++;return}if(ZW(F,G,A)){q=F.slice(F.charCodeAt(G+6)===T?G+7:G+6,L)||void 0;return}if(A===105&&F.charCodeAt(G+1)===100&&F.charCodeAt(G+2)===58){let _=F.slice(F.charCodeAt(G+3)===T?G+4:G+3,L);w=_.includes("\x00")?void 0:_;return}if(A===58){if(Z){let _=F.slice(G,L);Z(_.slice(F.charCodeAt(G+1)===T?2:1))}return}let H=F.slice(G,L),C=H.indexOf(":");if(C===-1){s(H,"",H);return}let SW=H.slice(0,C),gW=H.charCodeAt(C+1)===T?2:1,kW=H.slice(C+gW);s(SW,kW,H)}function s(F,G,L){switch(F){case"event":q=G||void 0;break;case"data":M=U===0?G:`${M}
${G}`,U++;break;case"id":w=G.includes("\x00")?void 0:G;break;case"retry":/^\d+$/.test(G)?Y(parseInt(G,10)):X(new i(`Invalid \`retry\` value: "${G}"`,{type:"invalid-retry",value:G,line:L}));break;default:X(new i(`Unknown field "${F.length>20?`${F.slice(0,20)}\u2026`:F}"`,{type:"unknown-field",field:F,value:G,line:L}));break}}function _W(){U>0&&W({id:w,event:q,data:M}),w=void 0,M="",U=0,q=void 0}function bW(F={}){if(F.consume&&$.length>0){let G=$.join("");h(G,0,G.length)}J=!0,w=void 0,M="",U=0,q=void 0,$.length=0}return{feed:j,reset:bW}}function YW(Q,W,X){return X===100&&Q.charCodeAt(W+1)===97&&Q.charCodeAt(W+2)===116&&Q.charCodeAt(W+3)===97&&Q.charCodeAt(W+4)===58}function ZW(Q,W,X){return X===101&&Q.charCodeAt(W+1)===118&&Q.charCodeAt(W+2)===101&&Q.charCodeAt(W+3)===110&&Q.charCodeAt(W+4)===116&&Q.charCodeAt(W+5)===58}class l extends TransformStream{constructor({onError:Q,onRetry:W,onComment:X}={}){let Y;super({start(Z){Y=$W({onEvent:($)=>{Z.enqueue($)},onError($){Q==="terminate"?Z.error($):typeof Q=="function"&&Q($)},onRetry:W,onComment:X})},transform(Z){Y.feed(Z)}})}}function bY(...Q){return Q.reduce((W,X)=>({...W,...X!=null?X:{}}),{})}function SY({tools:Q=[],providerToolNames:W,resolveProviderToolName:X}){var Y;let Z={},$={};for(let J of Q)if(J.type==="provider"){let w=(Y=X==null?void 0:X(J))!=null?Y:(J.id in W)?W[J.id]:void 0;if(w==null)continue;Z[J.name]=w,$[w]=J.name}return{toProviderToolName:(J)=>{var w;return(w=Z[J])!=null?w:J},toCustomToolName:(J)=>{var w;return(w=$[J])!=null?w:J}}}async function gY(Q,W){if(Q==null)return Promise.resolve();let X=W==null?void 0:W.abortSignal;return new Promise((Y,Z)=>{if(X==null?void 0:X.aborted){Z(JW());return}let $=setTimeout(()=>{J(),Y()},Q),J=()=>{clearTimeout($),X==null||X.removeEventListener("abort",w)},w=()=>{J(),Z(JW())};X==null||X.addEventListener("abort",w)})}function JW(){return new DOMException("Delay was aborted","AbortError")}function v(Q){return Object.fromEntries([...Q.headers])}var{btoa:aW,atob:sW}=globalThis;function kY(Q){let W=Q.replace(/-/g,"+").replace(/_/g,"/"),X=sW(W);return Uint8Array.from(X,(Y)=>Y.codePointAt(0))}function rW(Q){let W="";for(let X=0;X<Q.length;X++)W+=String.fromCodePoint(Q[X]);return aW(W)}function yY(Q){return Q instanceof Uint8Array?rW(Q):Q}function vY(Q,W={}){let{useArrayBrackets:X=!0}=W,Y=new FormData;for(let[Z,$]of Object.entries(Q)){if($==null)continue;if(Array.isArray($)){if($.length===1){Y.append(Z,$[0]);continue}let J=X?`${Z}[]`:Z;for(let w of $)Y.append(J,w);continue}Y.append(Z,$)}return Y}var DW="AI_DownloadError",OW=`vercel.ai.error.${DW}`,eW=Symbol.for(OW),wW,UW,N=class extends(UW=D,wW=eW,UW){constructor({url:Q,statusCode:W,statusText:X,cause:Y,message:Z=Y==null?`Failed to download ${Q}: ${W} ${X}`:`Failed to download ${Q}: ${Y}`}){super({name:DW,message:Z,cause:Y});this[wW]=!0,this.url=Q,this.statusCode=W,this.statusText=X}static isInstance(Q){return D.hasMarker(Q,OW)}},zW=2147483648;async function QX({response:Q,url:W,maxBytes:X=zW}){let Y=Q.headers.get("content-length");if(Y!=null){let q=parseInt(Y,10);if(!isNaN(q)&&q>X)throw new N({url:W,message:`Download of ${W} exceeded maximum size of ${X} bytes (Content-Length: ${q}).`})}let Z=Q.body;if(Z==null)return new Uint8Array(0);let $=Z.getReader(),J=[],w=0;try{while(!0){let{done:q,value:j}=await $.read();if(q)break;if(w+=j.length,w>X)throw new N({url:W,message:`Download of ${W} exceeded maximum size of ${X} bytes.`});J.push(j)}}finally{try{await $.cancel()}finally{$.releaseLock()}}let M=new Uint8Array(w),U=0;for(let q of J)M.set(q,U),U+=q.length;return M}function GW(Q){let W;try{W=new URL(Q)}catch(Y){throw new N({url:Q,message:`Invalid URL: ${Q}`})}if(W.protocol==="data:")return;if(W.protocol!=="http:"&&W.protocol!=="https:")throw new N({url:Q,message:`URL scheme must be http, https, or data, got ${W.protocol}`});let X=W.hostname;if(!X)throw new N({url:Q,message:"URL must have a hostname"});if(X==="localhost"||X.endsWith(".local")||X.endsWith(".localhost"))throw new N({url:Q,message:`URL with hostname ${X} is not allowed`});if(X.startsWith("[")&&X.endsWith("]")){let Y=X.slice(1,-1);if(WX(Y))throw new N({url:Q,message:`URL with IPv6 address ${X} is not allowed`});return}if(HW(X)){if(d(X))throw new N({url:Q,message:`URL with IP address ${X} is not allowed`});return}}function HW(Q){let W=Q.split(".");if(W.length!==4)return!1;return W.every((X)=>{let Y=Number(X);return Number.isInteger(Y)&&Y>=0&&Y<=255&&String(Y)===X})}function d(Q){let W=Q.split(".").map(Number),[X,Y]=W;if(X===0)return!0;if(X===10)return!0;if(X===127)return!0;if(X===169&&Y===254)return!0;if(X===172&&Y>=16&&Y<=31)return!0;if(X===192&&Y===168)return!0;return!1}function WX(Q){let W=Q.toLowerCase();if(W==="::1")return!0;if(W==="::")return!0;if(W.startsWith("::ffff:")){let X=W.slice(7);if(HW(X))return d(X);let Y=X.split(":");if(Y.length===2){let Z=parseInt(Y[0],16),$=parseInt(Y[1],16);if(!isNaN(Z)&&!isNaN($)){let J=Z>>8&255,w=Z&255,M=$>>8&255,U=$&255;return d(`${J}.${w}.${M}.${U}`)}}}if(W.startsWith("fc")||W.startsWith("fd"))return!0;if(W.startsWith("fe80"))return!0;return!1}async function mY(Q,W){var X,Y;GW(Q);try{let Z=await fetch(Q,{signal:W==null?void 0:W.abortSignal});if(Z.redirected)GW(Z.url);if(!Z.ok)throw new N({url:Q,statusCode:Z.status,statusText:Z.statusText});let $=await QX({response:Z,url:Q,maxBytes:(X=W==null?void 0:W.maxBytes)!=null?X:zW}),J=(Y=Z.headers.get("content-type"))!=null?Y:void 0;return new Blob([$],J?{type:J}:void 0)}catch(Z){if(N.isInstance(Z))throw Z;throw new N({url:Q,cause:Z})}}var XX=({prefix:Q,size:W=16,alphabet:X="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:Y="-"}={})=>{let Z=()=>{let $=X.length,J=Array(W);for(let w=0;w<W;w++)J[w]=X[Math.random()*$|0];return J.join("")};if(Q==null)return Z;if(X.includes(Y))throw new x({argument:"separator",message:`The separator "${Y}" must not be part of the alphabet "${X}".`});return()=>`${Q}${Y}${Z()}`},pY=XX();function y(Q){return(Q instanceof Error||Q instanceof DOMException)&&(Q.name==="AbortError"||Q.name==="ResponseAborted"||Q.name==="TimeoutError")}var YX=["fetch failed","failed to fetch"],ZX=["ConnectionRefused","ConnectionClosed","FailedToOpenSocket","ECONNRESET","ECONNREFUSED","ETIMEDOUT","EPIPE"];function $X(Q){if(!(Q instanceof Error))return!1;let W=Q.code;if(typeof W==="string"&&ZX.includes(W))return!0;return!1}function AW({error:Q,url:W,requestBodyValues:X}){if(y(Q))return Q;if(Q instanceof TypeError&&YX.includes(Q.message.toLowerCase())){let Y=Q.cause;if(Y!=null)return new z({message:`Cannot connect to API: ${Y.message}`,cause:Y,url:W,requestBodyValues:X,isRetryable:!0})}if($X(Q))return new z({message:`Cannot connect to API: ${Q.message}`,cause:Q,url:W,requestBodyValues:X,isRetryable:!0});return Q}function BW(Q=globalThis){var W,X,Y;if(Q.window)return"runtime/browser";if((W=Q.navigator)==null?void 0:W.userAgent)return`runtime/${Q.navigator.userAgent.toLowerCase()}`;if((Y=(X=Q.process)==null?void 0:X.versions)==null?void 0:Y.node)return`runtime/node.js/${Q.process.version.substring(0)}`;if(Q.EdgeRuntime)return"runtime/vercel-edge";return"runtime/unknown"}function JX(Q){if(Q==null)return{};let W={};if(Q instanceof Headers)Q.forEach((X,Y)=>{W[Y.toLowerCase()]=X});else{if(!Array.isArray(Q))Q=Object.entries(Q);for(let[X,Y]of Q)if(Y!=null)W[X.toLowerCase()]=Y}return W}function EW(Q,...W){let X=new Headers(JX(Q)),Y=X.get("user-agent")||"";return X.set("user-agent",[Y,...W].filter(Boolean).join(" ")),Object.fromEntries(X.entries())}var RW="4.0.27",wX=()=>globalThis.fetch,fY=async({url:Q,headers:W={},successfulResponseHandler:X,failedResponseHandler:Y,abortSignal:Z,fetch:$=wX()})=>{try{let J=await $(Q,{method:"GET",headers:EW(W,`ai-sdk/provider-utils/${RW}`,BW()),signal:Z}),w=v(J);if(!J.ok){let M;try{M=await Y({response:J,url:Q,requestBodyValues:{}})}catch(U){if(y(U)||z.isInstance(U))throw U;throw new z({message:"Failed to process error response",cause:U,statusCode:J.status,url:Q,responseHeaders:w,requestBodyValues:{}})}throw M.value}try{return await X({response:J,url:Q,requestBodyValues:{}})}catch(M){if(M instanceof Error){if(y(M)||z.isInstance(M))throw M}throw new z({message:"Failed to process successful response",cause:M,statusCode:J.status,url:Q,responseHeaders:w,requestBodyValues:{}})}}catch(J){throw AW({error:J,url:Q,requestBodyValues:{}})}};function uY(Q){return Q!=null}function cY({apiKey:Q,environmentVariableName:W,apiKeyParameterName:X="apiKey",description:Y}){if(typeof Q==="string")return Q;if(Q!=null)throw new g({message:`${Y} API key must be a string.`});if(typeof process>"u")throw new g({message:`${Y} API key is missing. Pass it using the '${X}' parameter. Environment variables are not supported in this environment.`});if(Q=process.env[W],Q==null)throw new g({message:`${Y} API key is missing. Pass it using the '${X}' parameter or the ${W} environment variable.`});if(typeof Q!=="string")throw new g({message:`${Y} API key must be a string. The value of the ${W} environment variable is not a string.`});return Q}function nY({settingValue:Q,environmentVariableName:W}){if(typeof Q==="string")return Q;if(Q!=null||typeof process>"u")return;if(Q=process.env[W],Q==null||typeof Q!=="string")return;return Q}function oY({settingValue:Q,environmentVariableName:W,settingName:X,description:Y}){if(typeof Q==="string")return Q;if(Q!=null)throw new k({message:`${Y} setting must be a string.`});if(typeof process>"u")throw new k({message:`${Y} setting is missing. Pass it using the '${X}' parameter. Environment variables are not supported in this environment.`});if(Q=process.env[W],Q==null)throw new k({message:`${Y} setting is missing. Pass it using the '${X}' parameter or the ${W} environment variable.`});if(typeof Q!=="string")throw new k({message:`${Y} setting must be a string. The value of the ${W} environment variable is not a string.`});return Q}var UX=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,GX=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function MW(Q){let W=JSON.parse(Q);if(W===null||typeof W!=="object")return W;if(UX.test(Q)===!1&&GX.test(Q)===!1)return W;return MX(W)}function MX(Q){let W=[Q];while(W.length){let X=W;W=[];for(let Y of X){if(Object.prototype.hasOwnProperty.call(Y,"__proto__"))throw SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(Y,"constructor")&&Y.constructor!==null&&typeof Y.constructor==="object"&&Object.prototype.hasOwnProperty.call(Y.constructor,"prototype"))throw SyntaxError("Object contains forbidden prototype property");for(let Z in Y){let $=Y[Z];if($&&typeof $==="object")W.push($)}}}return Q}function t(Q){let{stackTraceLimit:W}=Error;try{Error.stackTraceLimit=0}catch(X){return MW(Q)}try{return MW(Q)}finally{Error.stackTraceLimit=W}}function o(Q){if(Q.type==="object"||Array.isArray(Q.type)&&Q.type.includes("object")){Q.additionalProperties=!1;let{properties:X}=Q;if(X!=null)for(let Y of Object.keys(X))X[Y]=I(X[Y])}if(Q.items!=null)Q.items=Array.isArray(Q.items)?Q.items.map(I):I(Q.items);if(Q.anyOf!=null)Q.anyOf=Q.anyOf.map(I);if(Q.allOf!=null)Q.allOf=Q.allOf.map(I);if(Q.oneOf!=null)Q.oneOf=Q.oneOf.map(I);let{definitions:W}=Q;if(W!=null)for(let X of Object.keys(W))W[X]=I(W[X]);return Q}function I(Q){if(typeof Q==="boolean")return Q;return o(Q)}var FX=Symbol("Let zodToJsonSchema decide on which parser to use"),FW={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",strictUnions:!1,definitions:{},errorMessages:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},KX=(Q)=>typeof Q==="string"?{...FW,name:Q}:{...FW,...Q};function E(){return{}}function qX(Q,W){var X,Y,Z;let $={type:"array"};if(((X=Q.type)==null?void 0:X._def)&&((Z=(Y=Q.type)==null?void 0:Y._def)==null?void 0:Z.typeName)!==K.ZodAny)$.items=O(Q.type._def,{...W,currentPath:[...W.currentPath,"items"]});if(Q.minLength)$.minItems=Q.minLength.value;if(Q.maxLength)$.maxItems=Q.maxLength.value;if(Q.exactLength)$.minItems=Q.exactLength.value,$.maxItems=Q.exactLength.value;return $}function LX(Q){let W={type:"integer",format:"int64"};if(!Q.checks)return W;for(let X of Q.checks)switch(X.kind){case"min":if(X.inclusive)W.minimum=X.value;else W.exclusiveMinimum=X.value;break;case"max":if(X.inclusive)W.maximum=X.value;else W.exclusiveMaximum=X.value;break;case"multipleOf":W.multipleOf=X.value;break}return W}function DX(){return{type:"boolean"}}function PW(Q,W){return O(Q.type._def,W)}var OX=(Q,W)=>{return O(Q.innerType._def,W)};function NW(Q,W,X){let Y=X!=null?X:W.dateStrategy;if(Array.isArray(Y))return{anyOf:Y.map((Z,$)=>NW(Q,W,Z))};switch(Y){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return zX(Q)}}var zX=(Q)=>{let W={type:"integer",format:"unix-time"};for(let X of Q.checks)switch(X.kind){case"min":W.minimum=X.value;break;case"max":W.maximum=X.value;break}return W};function HX(Q,W){return{...O(Q.innerType._def,W),default:Q.defaultValue()}}function AX(Q,W){return W.effectStrategy==="input"?O(Q.schema._def,W):E()}function BX(Q){return{type:"string",enum:Array.from(Q.values)}}var EX=(Q)=>{if("type"in Q&&Q.type==="string")return!1;return"allOf"in Q};function RX(Q,W){let X=[O(Q.left._def,{...W,currentPath:[...W.currentPath,"allOf","0"]}),O(Q.right._def,{...W,currentPath:[...W.currentPath,"allOf","1"]})].filter((Z)=>!!Z),Y=[];return X.forEach((Z)=>{if(EX(Z))Y.push(...Z.allOf);else{let $=Z;if("additionalProperties"in Z&&Z.additionalProperties===!1){let{additionalProperties:J,...w}=Z;$=w}Y.push($)}}),Y.length?{allOf:Y}:void 0}function PX(Q){let W=typeof Q.value;if(W!=="bigint"&&W!=="number"&&W!=="boolean"&&W!=="string")return{type:Array.isArray(Q.value)?"array":"object"};return{type:W==="bigint"?"integer":W,const:Q.value}}var f=void 0,R={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(f===void 0)f=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return f},uuid:/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,ipv4:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ipv4Cidr:/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function CW(Q,W){let X={type:"string"};if(Q.checks)for(let Y of Q.checks)switch(Y.kind){case"min":X.minLength=typeof X.minLength==="number"?Math.max(X.minLength,Y.value):Y.value;break;case"max":X.maxLength=typeof X.maxLength==="number"?Math.min(X.maxLength,Y.value):Y.value;break;case"email":switch(W.emailStrategy){case"format:email":P(X,"email",Y.message,W);break;case"format:idn-email":P(X,"idn-email",Y.message,W);break;case"pattern:zod":B(X,R.email,Y.message,W);break}break;case"url":P(X,"uri",Y.message,W);break;case"uuid":P(X,"uuid",Y.message,W);break;case"regex":B(X,Y.regex,Y.message,W);break;case"cuid":B(X,R.cuid,Y.message,W);break;case"cuid2":B(X,R.cuid2,Y.message,W);break;case"startsWith":B(X,RegExp(`^${u(Y.value,W)}`),Y.message,W);break;case"endsWith":B(X,RegExp(`${u(Y.value,W)}$`),Y.message,W);break;case"datetime":P(X,"date-time",Y.message,W);break;case"date":P(X,"date",Y.message,W);break;case"time":P(X,"time",Y.message,W);break;case"duration":P(X,"duration",Y.message,W);break;case"length":X.minLength=typeof X.minLength==="number"?Math.max(X.minLength,Y.value):Y.value,X.maxLength=typeof X.maxLength==="number"?Math.min(X.maxLength,Y.value):Y.value;break;case"includes":{B(X,RegExp(u(Y.value,W)),Y.message,W);break}case"ip":{if(Y.version!=="v6")P(X,"ipv4",Y.message,W);if(Y.version!=="v4")P(X,"ipv6",Y.message,W);break}case"base64url":B(X,R.base64url,Y.message,W);break;case"jwt":B(X,R.jwt,Y.message,W);break;case"cidr":{if(Y.version!=="v6")B(X,R.ipv4Cidr,Y.message,W);if(Y.version!=="v4")B(X,R.ipv6Cidr,Y.message,W);break}case"emoji":B(X,R.emoji(),Y.message,W);break;case"ulid":{B(X,R.ulid,Y.message,W);break}case"base64":{switch(W.base64Strategy){case"format:binary":{P(X,"binary",Y.message,W);break}case"contentEncoding:base64":{X.contentEncoding="base64";break}case"pattern:zod":{B(X,R.base64,Y.message,W);break}}break}case"nanoid":B(X,R.nanoid,Y.message,W);case"toLowerCase":case"toUpperCase":case"trim":break;default:}return X}function u(Q,W){return W.patternStrategy==="escape"?CX(Q):Q}var NX=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function CX(Q){let W="";for(let X=0;X<Q.length;X++){if(!NX.has(Q[X]))W+="\\";W+=Q[X]}return W}function P(Q,W,X,Y){var Z;if(Q.format||((Z=Q.anyOf)==null?void 0:Z.some(($)=>$.format))){if(!Q.anyOf)Q.anyOf=[];if(Q.format)Q.anyOf.push({format:Q.format}),delete Q.format;Q.anyOf.push({format:W,...X&&Y.errorMessages&&{errorMessage:{format:X}}})}else Q.format=W}function B(Q,W,X,Y){var Z;if(Q.pattern||((Z=Q.allOf)==null?void 0:Z.some(($)=>$.pattern))){if(!Q.allOf)Q.allOf=[];if(Q.pattern)Q.allOf.push({pattern:Q.pattern}),delete Q.pattern;Q.allOf.push({pattern:KW(W,Y),...X&&Y.errorMessages&&{errorMessage:{pattern:X}}})}else Q.pattern=KW(W,Y)}function KW(Q,W){var X;if(!W.applyRegexFlags||!Q.flags)return Q.source;let Y={i:Q.flags.includes("i"),m:Q.flags.includes("m"),s:Q.flags.includes("s")},Z=Y.i?Q.source.toLowerCase():Q.source,$="",J=!1,w=!1,M=!1;for(let U=0;U<Z.length;U++){if(J){$+=Z[U],J=!1;continue}if(Y.i){if(w){if(Z[U].match(/[a-z]/)){if(M)$+=Z[U],$+=`${Z[U-2]}-${Z[U]}`.toUpperCase(),M=!1;else if(Z[U+1]==="-"&&((X=Z[U+2])==null?void 0:X.match(/[a-z]/)))$+=Z[U],M=!0;else $+=`${Z[U]}${Z[U].toUpperCase()}`;continue}}else if(Z[U].match(/[a-z]/)){$+=`[${Z[U]}${Z[U].toUpperCase()}]`;continue}}if(Y.m){if(Z[U]==="^"){$+=`(^|(?<=[\r
]))`;continue}else if(Z[U]==="$"){$+=`($|(?=[\r
]))`;continue}}if(Y.s&&Z[U]==="."){$+=w?`${Z[U]}\r
`:`[${Z[U]}\r
]`;continue}if($+=Z[U],Z[U]==="\\")J=!0;else if(w&&Z[U]==="]")w=!1;else if(!w&&Z[U]==="[")w=!0}try{new RegExp($)}catch(U){return console.warn(`Could not convert regex pattern at ${W.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),Q.source}return $}function VW(Q,W){var X,Y,Z,$,J,w;let M={type:"object",additionalProperties:(X=O(Q.valueType._def,{...W,currentPath:[...W.currentPath,"additionalProperties"]}))!=null?X:W.allowedAdditionalProperties};if(((Y=Q.keyType)==null?void 0:Y._def.typeName)===K.ZodString&&((Z=Q.keyType._def.checks)==null?void 0:Z.length)){let{type:U,...q}=CW(Q.keyType._def,W);return{...M,propertyNames:q}}else if((($=Q.keyType)==null?void 0:$._def.typeName)===K.ZodEnum)return{...M,propertyNames:{enum:Q.keyType._def.values}};else if(((J=Q.keyType)==null?void 0:J._def.typeName)===K.ZodBranded&&Q.keyType._def.type._def.typeName===K.ZodString&&((w=Q.keyType._def.type._def.checks)==null?void 0:w.length)){let{type:U,...q}=PW(Q.keyType._def,W);return{...M,propertyNames:q}}return M}function VX(Q,W){if(W.mapStrategy==="record")return VW(Q,W);let X=O(Q.keyType._def,{...W,currentPath:[...W.currentPath,"items","items","0"]})||E(),Y=O(Q.valueType._def,{...W,currentPath:[...W.currentPath,"items","items","1"]})||E();return{type:"array",maxItems:125,items:{type:"array",items:[X,Y],minItems:2,maxItems:2}}}function TX(Q){let W=Q.values,Y=Object.keys(Q.values).filter(($)=>{return typeof W[W[$]]!=="number"}).map(($)=>W[$]),Z=Array.from(new Set(Y.map(($)=>typeof $)));return{type:Z.length===1?Z[0]==="string"?"string":"number":["string","number"],enum:Y}}function IX(){return{not:E()}}function jX(){return{type:"null"}}var c={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function _X(Q,W){let X=Q.options instanceof Map?Array.from(Q.options.values()):Q.options;if(X.every((Y)=>(Y._def.typeName in c)&&(!Y._def.checks||!Y._def.checks.length))){let Y=X.reduce((Z,$)=>{let J=c[$._def.typeName];return J&&!Z.includes(J)?[...Z,J]:Z},[]);return{type:Y.length>1?Y:Y[0]}}else if(X.every((Y)=>Y._def.typeName==="ZodLiteral"&&!Y.description)){let Y=X.reduce((Z,$)=>{let J=typeof $._def.value;switch(J){case"string":case"number":case"boolean":return[...Z,J];case"bigint":return[...Z,"integer"];case"object":if($._def.value===null)return[...Z,"null"];case"symbol":case"undefined":case"function":default:return Z}},[]);if(Y.length===X.length){let Z=Y.filter(($,J,w)=>w.indexOf($)===J);return{type:Z.length>1?Z:Z[0],enum:X.reduce(($,J)=>{return $.includes(J._def.value)?$:[...$,J._def.value]},[])}}}else if(X.every((Y)=>Y._def.typeName==="ZodEnum"))return{type:"string",enum:X.reduce((Y,Z)=>[...Y,...Z._def.values.filter(($)=>!Y.includes($))],[])};return bX(Q,W)}var bX=(Q,W)=>{let X=(Q.options instanceof Map?Array.from(Q.options.values()):Q.options).map((Y,Z)=>O(Y._def,{...W,currentPath:[...W.currentPath,"anyOf",`${Z}`]})).filter((Y)=>!!Y&&(!W.strictUnions||typeof Y==="object"&&Object.keys(Y).length>0));return X.length?{anyOf:X}:void 0};function SX(Q,W){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(Q.innerType._def.typeName)&&(!Q.innerType._def.checks||!Q.innerType._def.checks.length))return{type:[c[Q.innerType._def.typeName],"null"]};let X=O(Q.innerType._def,{...W,currentPath:[...W.currentPath,"anyOf","0"]});return X&&{anyOf:[X,{type:"null"}]}}function gX(Q){let W={type:"number"};if(!Q.checks)return W;for(let X of Q.checks)switch(X.kind){case"int":W.type="integer";break;case"min":if(X.inclusive)W.minimum=X.value;else W.exclusiveMinimum=X.value;break;case"max":if(X.inclusive)W.maximum=X.value;else W.exclusiveMaximum=X.value;break;case"multipleOf":W.multipleOf=X.value;break}return W}function kX(Q,W){let X={type:"object",properties:{}},Y=[],Z=Q.shape();for(let J in Z){let w=Z[J];if(w===void 0||w._def===void 0)continue;let M=vX(w),U=O(w._def,{...W,currentPath:[...W.currentPath,"properties",J],propertyPath:[...W.currentPath,"properties",J]});if(U===void 0)continue;if(X.properties[J]=U,!M)Y.push(J)}if(Y.length)X.required=Y;let $=yX(Q,W);if($!==void 0)X.additionalProperties=$;return X}function yX(Q,W){if(Q.catchall._def.typeName!=="ZodNever")return O(Q.catchall._def,{...W,currentPath:[...W.currentPath,"additionalProperties"]});switch(Q.unknownKeys){case"passthrough":return W.allowedAdditionalProperties;case"strict":return W.rejectedAdditionalProperties;case"strip":return W.removeAdditionalStrategy==="strict"?W.allowedAdditionalProperties:W.rejectedAdditionalProperties}}function vX(Q){try{return Q.isOptional()}catch(W){return!0}}var xX=(Q,W)=>{var X;if(W.currentPath.toString()===((X=W.propertyPath)==null?void 0:X.toString()))return O(Q.innerType._def,W);let Y=O(Q.innerType._def,{...W,currentPath:[...W.currentPath,"anyOf","1"]});return Y?{anyOf:[{not:E()},Y]}:E()},mX=(Q,W)=>{if(W.pipeStrategy==="input")return O(Q.in._def,W);else if(W.pipeStrategy==="output")return O(Q.out._def,W);let X=O(Q.in._def,{...W,currentPath:[...W.currentPath,"allOf","0"]}),Y=O(Q.out._def,{...W,currentPath:[...W.currentPath,"allOf",X?"1":"0"]});return{allOf:[X,Y].filter((Z)=>Z!==void 0)}};function hX(Q,W){return O(Q.type._def,W)}function pX(Q,W){let Y={type:"array",uniqueItems:!0,items:O(Q.valueType._def,{...W,currentPath:[...W.currentPath,"items"]})};if(Q.minSize)Y.minItems=Q.minSize.value;if(Q.maxSize)Y.maxItems=Q.maxSize.value;return Y}function iX(Q,W){if(Q.rest)return{type:"array",minItems:Q.items.length,items:Q.items.map((X,Y)=>O(X._def,{...W,currentPath:[...W.currentPath,"items",`${Y}`]})).reduce((X,Y)=>Y===void 0?X:[...X,Y],[]),additionalItems:O(Q.rest._def,{...W,currentPath:[...W.currentPath,"additionalItems"]})};else return{type:"array",minItems:Q.items.length,maxItems:Q.items.length,items:Q.items.map((X,Y)=>O(X._def,{...W,currentPath:[...W.currentPath,"items",`${Y}`]})).reduce((X,Y)=>Y===void 0?X:[...X,Y],[])}}function lX(){return{not:E()}}function fX(){return E()}var uX=(Q,W)=>{return O(Q.innerType._def,W)},dX=(Q,W,X)=>{switch(W){case K.ZodString:return CW(Q,X);case K.ZodNumber:return gX(Q);case K.ZodObject:return kX(Q,X);case K.ZodBigInt:return LX(Q);case K.ZodBoolean:return DX();case K.ZodDate:return NW(Q,X);case K.ZodUndefined:return lX();case K.ZodNull:return jX();case K.ZodArray:return qX(Q,X);case K.ZodUnion:case K.ZodDiscriminatedUnion:return _X(Q,X);case K.ZodIntersection:return RX(Q,X);case K.ZodTuple:return iX(Q,X);case K.ZodRecord:return VW(Q,X);case K.ZodLiteral:return PX(Q);case K.ZodEnum:return BX(Q);case K.ZodNativeEnum:return TX(Q);case K.ZodNullable:return SX(Q,X);case K.ZodOptional:return xX(Q,X);case K.ZodMap:return VX(Q,X);case K.ZodSet:return pX(Q,X);case K.ZodLazy:return()=>Q.getter()._def;case K.ZodPromise:return hX(Q,X);case K.ZodNaN:case K.ZodNever:return IX();case K.ZodEffects:return AX(Q,X);case K.ZodAny:return E();case K.ZodUnknown:return fX();case K.ZodDefault:return HX(Q,X);case K.ZodBranded:return PW(Q,X);case K.ZodReadonly:return uX(Q,X);case K.ZodCatch:return OX(Q,X);case K.ZodPipeline:return mX(Q,X);case K.ZodFunction:case K.ZodVoid:case K.ZodSymbol:return;default:return((Y)=>{return})(W)}},cX=(Q,W)=>{let X=0;for(;X<Q.length&&X<W.length;X++)if(Q[X]!==W[X])break;return[(Q.length-X).toString(),...W.slice(X)].join("/")};function O(Q,W,X=!1){var Y;let Z=W.seen.get(Q);if(W.override){let M=(Y=W.override)==null?void 0:Y.call(W,Q,W,Z,X);if(M!==FX)return M}if(Z&&!X){let M=nX(Z,W);if(M!==void 0)return M}let $={def:Q,path:W.currentPath,jsonSchema:void 0};W.seen.set(Q,$);let J=dX(Q,Q.typeName,W),w=typeof J==="function"?O(J(),W):J;if(w)tX(Q,W,w);if(W.postProcess){let M=W.postProcess(w,Q,W);return $.jsonSchema=w,M}return $.jsonSchema=w,w}var nX=(Q,W)=>{switch(W.$refStrategy){case"root":return{$ref:Q.path.join("/")};case"relative":return{$ref:cX(W.currentPath,Q.path)};case"none":case"seen":{if(Q.path.length<W.currentPath.length&&Q.path.every((X,Y)=>W.currentPath[Y]===X))return console.warn(`Recursive reference detected at ${W.currentPath.join("/")}! Defaulting to any`),E();return W.$refStrategy==="seen"?E():void 0}}},tX=(Q,W,X)=>{if(Q.description)X.description=Q.description;return X},oX=(Q)=>{let W=KX(Q),X=W.name!==void 0?[...W.basePath,W.definitionPath,W.name]:W.basePath;return{...W,currentPath:X,propertyPath:void 0,seen:new Map(Object.entries(W.definitions).map(([Y,Z])=>[Z._def,{def:Z._def,path:[...W.basePath,W.definitionPath,Y],jsonSchema:void 0}]))}},aX=(Q,W)=>{var X;let Y=oX(W),Z=typeof W==="object"&&W.definitions?Object.entries(W.definitions).reduce((U,[q,j])=>{var b;return{...U,[q]:(b=O(j._def,{...Y,currentPath:[...Y.basePath,Y.definitionPath,q]},!0))!=null?b:E()}},{}):void 0,$=typeof W==="string"?W:(W==null?void 0:W.nameStrategy)==="title"?void 0:W==null?void 0:W.name,J=(X=O(Q._def,$===void 0?Y:{...Y,currentPath:[...Y.basePath,Y.definitionPath,$]},!1))!=null?X:E(),w=typeof W==="object"&&W.name!==void 0&&W.nameStrategy==="title"?W.name:void 0;if(w!==void 0)J.title=w;let M=$===void 0?Z?{...J,[Y.definitionPath]:Z}:J:{$ref:[...Y.$refStrategy==="relative"?[]:Y.basePath,Y.definitionPath,$].join("/"),[Y.definitionPath]:{...Z,[$]:J}};return M.$schema="http://json-schema.org/draft-07/schema#",M},n=Symbol.for("vercel.ai.schema");function XZ(Q){let W;return()=>{if(W==null)W=Q();return W}}function m(Q,{validate:W}={}){return{[n]:!0,_type:void 0,get jsonSchema(){if(typeof Q==="function")Q=Q();return Q},validate:W}}function sX(Q){return typeof Q==="object"&&Q!==null&&n in Q&&Q[n]===!0&&"jsonSchema"in Q&&"validate"in Q}function rX(Q){return Q==null?m({properties:{},additionalProperties:!1}):sX(Q)?Q:("~standard"in Q)?Q["~standard"].vendor==="zod"?YY(Q):eX(Q):Q()}function eX(Q){return m(()=>o(Q["~standard"].jsonSchema.input({target:"draft-07"})),{validate:async(W)=>{let X=await Q["~standard"].validate(W);return"value"in X?{success:!0,value:X.value}:{success:!1,error:new V({value:W,cause:X.issues})}}})}function QY(Q,W){var X;let Y=(X=W==null?void 0:W.useReferences)!=null?X:!1;return m(()=>aX(Q,{$refStrategy:Y?"root":"none"}),{validate:async(Z)=>{let $=await Q.safeParseAsync(Z);return $.success?{success:!0,value:$.data}:{success:!1,error:$.error}}})}function WY(Q,W){var X;let Y=(X=W==null?void 0:W.useReferences)!=null?X:!1;return m(()=>o(qW(Q,{target:"draft-7",io:"input",reused:Y?"ref":"inline"})),{validate:async(Z)=>{let $=await LW(Q,Z);return $.success?{success:!0,value:$.data}:{success:!1,error:$.error}}})}function XY(Q){return"_zod"in Q}function YY(Q,W){if(XY(Q))return WY(Q,W);else return QY(Q,W)}async function ZY({value:Q,schema:W,context:X}){let Y=await a({value:Q,schema:W,context:X});if(!Y.success)throw V.wrap({value:Q,cause:Y.error,context:X});return Y.value}async function a({value:Q,schema:W,context:X}){let Y=rX(W);try{if(Y.validate==null)return{success:!0,value:Q,rawValue:Q};let Z=await Y.validate(Q);if(Z.success)return{success:!0,value:Z.value,rawValue:Q};return{success:!1,error:V.wrap({value:Q,cause:Z.error,context:X}),rawValue:Q}}catch(Z){return{success:!1,error:V.wrap({value:Q,cause:Z,context:X}),rawValue:Q}}}async function $Y({text:Q,schema:W}){try{let X=t(Q);if(W==null)return X;return ZY({value:X,schema:W})}catch(X){if(S.isInstance(X)||V.isInstance(X))throw X;throw new S({text:Q,cause:X})}}async function TW({text:Q,schema:W}){try{let X=t(Q);if(W==null)return{success:!0,value:X,rawValue:X};return await a({value:X,schema:W})}catch(X){return{success:!1,error:S.isInstance(X)?X:new S({text:Q,cause:X}),rawValue:void 0}}}function YZ(Q){try{return t(Q),!0}catch(W){return!1}}function JY({stream:Q,schema:W}){return Q.pipeThrough(new TextDecoderStream).pipeThrough(new l).pipeThrough(new TransformStream({async transform({data:X},Y){if(X==="[DONE]")return;Y.enqueue(await TW({text:X,schema:W}))}}))}async function JZ({provider:Q,providerOptions:W,schema:X}){if((W==null?void 0:W[Q])==null)return;let Y=await a({value:W[Q],schema:X});if(!Y.success)throw new x({argument:"providerOptions",message:`invalid ${Q} provider options`,cause:Y.error});return Y.value}var wY=()=>globalThis.fetch,UZ=async({url:Q,headers:W,body:X,failedResponseHandler:Y,successfulResponseHandler:Z,abortSignal:$,fetch:J})=>IW({url:Q,headers:{"Content-Type":"application/json",...W},body:{content:JSON.stringify(X),values:X},failedResponseHandler:Y,successfulResponseHandler:Z,abortSignal:$,fetch:J}),GZ=async({url:Q,headers:W,formData:X,failedResponseHandler:Y,successfulResponseHandler:Z,abortSignal:$,fetch:J})=>IW({url:Q,headers:W,body:{content:X,values:Object.fromEntries(X.entries())},failedResponseHandler:Y,successfulResponseHandler:Z,abortSignal:$,fetch:J}),IW=async({url:Q,headers:W={},body:X,successfulResponseHandler:Y,failedResponseHandler:Z,abortSignal:$,fetch:J=wY()})=>{try{let w=await J(Q,{method:"POST",headers:EW(W,`ai-sdk/provider-utils/${RW}`,BW()),body:X.content,signal:$}),M=v(w);if(!w.ok){let U;try{U=await Z({response:w,url:Q,requestBodyValues:X.values})}catch(q){if(y(q)||z.isInstance(q))throw q;throw new z({message:"Failed to process error response",cause:q,statusCode:w.status,url:Q,responseHeaders:M,requestBodyValues:X.values})}throw U.value}try{return await Y({response:w,url:Q,requestBodyValues:X.values})}catch(U){if(U instanceof Error){if(y(U)||z.isInstance(U))throw U}throw new z({message:"Failed to process successful response",cause:U,statusCode:w.status,url:Q,responseHeaders:M,requestBodyValues:X.values})}}catch(w){throw AW({error:w,url:Q,requestBodyValues:X.values})}};function jW(Q){return Q}function MZ({id:Q,inputSchema:W}){return({execute:X,outputSchema:Y,needsApproval:Z,toModelOutput:$,onInputStart:J,onInputDelta:w,onInputAvailable:M,...U})=>jW({type:"provider",id:Q,args:U,inputSchema:W,outputSchema:Y,execute:X,needsApproval:Z,toModelOutput:$,onInputStart:J,onInputDelta:w,onInputAvailable:M})}function FZ({id:Q,inputSchema:W,outputSchema:X,supportsDeferredResults:Y}){return({execute:Z,needsApproval:$,toModelOutput:J,onInputStart:w,onInputDelta:M,onInputAvailable:U,...q})=>jW({type:"provider",id:Q,args:q,inputSchema:W,outputSchema:X,execute:Z,needsApproval:$,toModelOutput:J,onInputStart:w,onInputDelta:M,onInputAvailable:U,supportsDeferredResults:Y})}async function KZ(Q){if(typeof Q==="function")Q=Q();return Promise.resolve(Q)}var LZ=({errorSchema:Q,errorToMessage:W,isRetryable:X})=>async({response:Y,url:Z,requestBodyValues:$})=>{let J=await Y.text(),w=v(Y);if(J.trim()==="")return{responseHeaders:w,value:new z({message:Y.statusText,url:Z,requestBodyValues:$,statusCode:Y.status,responseHeaders:w,responseBody:J,isRetryable:X==null?void 0:X(Y)})};try{let M=await $Y({text:J,schema:Q});return{responseHeaders:w,value:new z({message:W(M),url:Z,requestBodyValues:$,statusCode:Y.status,responseHeaders:w,responseBody:J,data:M,isRetryable:X==null?void 0:X(Y,M)})}}catch(M){return{responseHeaders:w,value:new z({message:Y.statusText,url:Z,requestBodyValues:$,statusCode:Y.status,responseHeaders:w,responseBody:J,isRetryable:X==null?void 0:X(Y)})}}},DZ=(Q)=>async({response:W})=>{let X=v(W);if(W.body==null)throw new SQ({});return{responseHeaders:X,value:JY({stream:W.body,schema:Q})}},OZ=(Q)=>async({response:W,url:X,requestBodyValues:Y})=>{let Z=await W.text(),$=await TW({text:Z,schema:Q}),J=v(W);if(!$.success)throw new z({message:"Invalid JSON response",cause:$.error,statusCode:W.status,responseHeaders:J,responseBody:Z,url:X,requestBodyValues:Y});return{responseHeaders:J,value:$.value,rawValue:$.rawValue}};function zZ(Q){let W=Q.indexOf(".");return W===-1?Q:Q.slice(0,W)}function HZ(Q){return Q==null?void 0:Q.replace(/\/$/,"")}
export{D as mi,z as ni,SQ as oi,UY as pi,GY as qi,FY as ri,KY as si,qY as ti,bY as ui,SY as vi,gY as wi,v as xi,kY as yi,rW as zi,yY as Ai,vY as Bi,mY as Ci,pY as Di,y as Ei,BW as Fi,JX as Gi,EW as Hi,fY as Ii,uY as Ji,cY as Ki,nY as Li,oY as Mi,XZ as Ni,rX as Oi,YY as Pi,ZY as Qi,a as Ri,TW as Si,YZ as Ti,JZ as Ui,UZ as Vi,GZ as Wi,MZ as Xi,FZ as Yi,KZ as Zi,LZ as _i,DZ as $i,OZ as aj,zZ as bj,HZ as cj};
