@gram-ai/elements 1.18.6 → 1.18.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Chat/stories/ConnectionConfiguration.stories.d.ts +10 -0
- package/dist/components/Chat/stories/{Customization.stories.d.ts → CustomComponents.stories.d.ts} +1 -3
- package/dist/elements.cjs +32 -32
- package/dist/elements.cjs.map +1 -1
- package/dist/elements.css +1 -1
- package/dist/elements.js +2119 -2098
- package/dist/elements.js.map +1 -1
- package/dist/hooks/useAuth.d.ts +2 -2
- package/dist/lib/auth.d.ts +3 -2
- package/dist/types/index.d.ts +33 -12
- package/package.json +1 -1
- package/src/components/Chat/stories/{Customization.stories.tsx → ConnectionConfiguration.stories.tsx} +38 -19
- package/src/components/Chat/stories/CustomComponents.stories.tsx +46 -0
- package/src/components/assistant-ui/reasoning.tsx +2 -2
- package/src/contexts/ElementsProvider.tsx +33 -2
- package/src/hooks/useAuth.ts +14 -6
- package/src/lib/auth.ts +9 -2
- package/src/types/index.ts +37 -12
package/dist/elements.cjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),T=require("./index-Bj7jPiuy.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("react/jsx-runtime"),T=require("./index-Bj7jPiuy.cjs"),z=require("react"),L=require("@assistant-ui/react"),Zt=require("motion/react"),b0=require("motion/react-m"),_0=require("zustand/shallow"),sm=require("react-dom"),Gs=require("@assistant-ui/react-markdown"),w0=require("remark-gfm"),x0=require("shiki");function Mu(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const o=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,o.get?o:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const _=Mu(z),Lt=Mu(b0),um=Mu(sm);function $0({tools:e}){return m.jsx(m.Fragment,{children:Object.entries(e).map(([,t])=>t({}))})}var lm="vercel.ai.error",S0=Symbol.for(lm),cm,I0=class dm extends Error{constructor({name:t,message:r,cause:o}){super(r),this[cm]=!0,this.name=t,this.cause=o}static isInstance(t){return dm.hasMarker(t,lm)}static hasMarker(t,r){const o=Symbol.for(r);return t!=null&&typeof t=="object"&&o in t&&typeof t[o]=="boolean"&&t[o]===!0}};cm=S0;var Y=I0,pm="AI_APICallError",fm=`vercel.ai.error.${pm}`,k0=Symbol.for(fm),mm,Be=class extends Y{constructor({message:t,url:r,requestBodyValues:o,statusCode:n,responseHeaders:i,responseBody:a,cause:s,isRetryable:l=n!=null&&(n===408||n===409||n===429||n>=500),data:u}){super({name:pm,message:t,cause:s}),this[mm]=!0,this.url=r,this.requestBodyValues=o,this.statusCode=n,this.responseHeaders=i,this.responseBody=a,this.isRetryable=l,this.data=u}static isInstance(t){return Y.hasMarker(t,fm)}};mm=k0;var hm="AI_EmptyResponseBodyError",gm=`vercel.ai.error.${hm}`,E0=Symbol.for(gm),vm,T0=class extends Y{constructor({message:t="Empty response body"}={}){super({name:hm,message:t}),this[vm]=!0}static isInstance(t){return Y.hasMarker(t,gm)}};vm=E0;function sn(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var ym="AI_InvalidArgumentError",bm=`vercel.ai.error.${ym}`,O0=Symbol.for(bm),_m,Ji=class extends Y{constructor({message:t,cause:r,argument:o}){super({name:ym,message:t,cause:r}),this[_m]=!0,this.argument=o}static isInstance(t){return Y.hasMarker(t,bm)}};_m=O0;var wm="AI_InvalidPromptError",xm=`vercel.ai.error.${wm}`,N0=Symbol.for(xm),$m,jr=class extends Y{constructor({prompt:t,message:r,cause:o}){super({name:wm,message:`Invalid prompt: ${r}`,cause:o}),this[$m]=!0,this.prompt=t}static isInstance(t){return Y.hasMarker(t,xm)}};$m=N0;var Sm="AI_JSONParseError",Im=`vercel.ai.error.${Sm}`,P0=Symbol.for(Im),km,Jr=class extends Y{constructor({text:t,cause:r}){super({name:Sm,message:`JSON parsing failed: Text: ${t}.
|
|
2
2
|
Error message: ${sn(r)}`,cause:r}),this[km]=!0,this.text=t}static isInstance(t){return Y.hasMarker(t,Im)}};km=P0;var Em="AI_NoSuchModelError",Tm=`vercel.ai.error.${Em}`,C0=Symbol.for(Tm),Om,j0=class extends Y{constructor({errorName:e=Em,modelId:t,modelType:r,message:o=`No such ${r}: ${t}`}){super({name:e,message:o}),this[Om]=!0,this.modelId=t,this.modelType=r}static isInstance(e){return Y.hasMarker(e,Tm)}};Om=C0;var Nm="AI_TypeValidationError",Pm=`vercel.ai.error.${Nm}`,A0=Symbol.for(Pm),Cm,R0=class Ks extends Y{constructor({value:t,cause:r}){super({name:Nm,message:`Type validation failed: Value: ${JSON.stringify(t)}.
|
|
3
|
-
Error message: ${sn(r)}`,cause:r}),this[Cm]=!0,this.value=t}static isInstance(t){return Y.hasMarker(t,Pm)}static wrap({value:t,cause:r}){return Ks.isInstance(r)&&r.value===t?r:new Ks({value:t,cause:r})}};Cm=A0;var Ft=R0;let Rd=class extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}};function
|
|
3
|
+
Error message: ${sn(r)}`,cause:r}),this[Cm]=!0,this.value=t}static isInstance(t){return Y.hasMarker(t,Pm)}static wrap({value:t,cause:r}){return Ks.isInstance(r)&&r.value===t?r:new Ks({value:t,cause:r})}};Cm=A0;var Ft=R0;let Rd=class extends Error{constructor(t,r){super(t),this.name="ParseError",this.type=r.type,this.field=r.field,this.value=r.value,this.line=r.line}};function vs(e){}function z0(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=vs,onError:r=vs,onRetry:o=vs,onComment:n}=e;let i="",a=!0,s,l="",u="";function c(h){const b=a?h.replace(/^\xEF\xBB\xBF/,""):h,[y,x]=M0(`${i}${b}`);for(const $ of y)d($);i=x,a=!1}function d(h){if(h===""){p();return}if(h.startsWith(":")){n&&n(h.slice(h.startsWith(": ")?2:1));return}const b=h.indexOf(":");if(b!==-1){const y=h.slice(0,b),x=h[b+1]===" "?2:1,$=h.slice(b+x);f(y,$,h);return}f(h,"",h)}function f(h,b,y){switch(h){case"event":u=b;break;case"data":l=`${l}${b}
|
|
4
4
|
`;break;case"id":s=b.includes("\0")?void 0:b;break;case"retry":/^\d+$/.test(b)?o(parseInt(b,10)):r(new Rd(`Invalid \`retry\` value: "${b}"`,{type:"invalid-retry",value:b,line:y}));break;default:r(new Rd(`Unknown field "${h.length>20?`${h.slice(0,20)}…`:h}"`,{type:"unknown-field",field:h,value:b,line:y}));break}}function p(){l.length>0&&t({id:s,event:u||void 0,data:l.endsWith(`
|
|
5
5
|
`)?l.slice(0,-1):l}),s=void 0,l="",u=""}function g(h={}){i&&h.consume&&d(i),a=!0,s=void 0,l="",u="",i=""}return{feed:c,reset:g}}function M0(e){const t=[];let r="",o=0;for(;o<e.length;){const n=e.indexOf("\r",o),i=e.indexOf(`
|
|
6
6
|
`,o);let a=-1;if(n!==-1&&i!==-1?a=Math.min(n,i):n!==-1?n===e.length-1?a=-1:a=n:i!==-1&&(a=i),a===-1){r=e.slice(o);break}else{const s=e.slice(o,a);t.push(s),o=a+1,e[o-1]==="\r"&&e[o]===`
|
|
7
|
-
`&&o++}}return[t,r]}let Pn=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:o}={}){let n;super({start(i){n=z0({onEvent:a=>{i.enqueue(a)},onError(a){t==="terminate"?i.error(a):typeof t=="function"&&t(a)},onRetry:r,onComment:o})},transform(i){n.feed(i)}})}};const Du=Object.freeze({status:"aborted"});function S(e,t,r){function o(s,l){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,l);const u=a.prototype,c=Object.keys(u);for(let d=0;d<c.length;d++){const f=c[d];f in s||(s[f]=u[f].bind(s))}}const n=r?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function a(s){var l;const u=r?.Parent?new i:this;o(u,s),(l=u._zod).deferred??(l.deferred=[]);for(const c of u._zod.deferred)c();return u}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}const jm=Symbol("zod_brand");class vr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Ji extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const li={};function De(e){return e&&Object.assign(li,e),li}function D0(e){return e}function U0(e){return e}function L0(e){}function Z0(e){throw new Error("Unexpected value in exhaustive check")}function F0(e){}function Uu(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function j(e,t="|"){return e.map(r=>H(r)).join(t)}function ci(e,t){return typeof t=="bigint"?t.toString():t}function Xn(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Er(e){return e==null}function Wi(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Am(e,t){const r=(e.toString().split(".")[1]||"").length,o=t.toString();let n=(o.split(".")[1]||"").length;if(n===0&&/\d?e-\d?/.test(o)){const l=o.match(/\d?e-(\d?)/);l?.[1]&&(n=Number.parseInt(l[1]))}const i=r>n?r:n,a=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return a%s/10**i}const zd=Symbol("evaluating");function ne(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==zd)return o===void 0&&(o=zd,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function q0(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function cr(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Wt(...e){const t={};for(const r of e){const o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function V0(e){return Wt(e._zod.def)}function B0(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function J0(e){const t=Object.keys(e),r=t.map(o=>e[o]);return Promise.all(r).then(o=>{const n={};for(let i=0;i<t.length;i++)n[t[i]]=o[i];return n})}function W0(e=10){const t="abcdefghijklmnopqrstuvwxyz";let r="";for(let o=0;o<e;o++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ys(e){return JSON.stringify(e)}function Rm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Lu="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Wr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const zm=Xn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function yr(e){if(Wr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Wr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Hi(e){return yr(e)?{...e}:Array.isArray(e)?[...e]:e}function H0(e){let t=0;for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}const G0=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},di=new Set(["string","number","symbol"]),Mm=new Set(["string","number","bigint","boolean","symbol","undefined"]);function qt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dt(e,t,r){const o=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(o._zod.parent=e),o}function P(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function K0(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,i){return t??(t=e()),Reflect.set(t,o,n,i)},has(r,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(r,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(r,o,n){return t??(t=e()),Reflect.defineProperty(t,o,n)}})}function H(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Dm(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Um={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Lm={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Zm(e,t){const r=e._zod.def,o=Wt(e._zod.def,{get shape(){const n={};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(n[i]=r.shape[i])}return cr(this,"shape",n),n},checks:[]});return dt(e,o)}function Fm(e,t){const r=e._zod.def,o=Wt(e._zod.def,{get shape(){const n={...e._zod.def.shape};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete n[i]}return cr(this,"shape",n),n},checks:[]});return dt(e,o)}function qm(e,t){if(!yr(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const n=Wt(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return cr(this,"shape",i),i},checks:[]});return dt(e,n)}function Vm(e,t){if(!yr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r={...e._zod.def,get shape(){const o={...e._zod.def.shape,...t};return cr(this,"shape",o),o},checks:e._zod.def.checks};return dt(e,r)}function Bm(e,t){const r=Wt(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return cr(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return dt(e,r)}function Jm(e,t,r){const o=Wt(t._zod.def,{get shape(){const n=t._zod.def.shape,i={...n};if(r)for(const a in r){if(!(a in n))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=e?new e({type:"optional",innerType:n[a]}):n[a])}else for(const a in n)i[a]=e?new e({type:"optional",innerType:n[a]}):n[a];return cr(this,"shape",i),i},checks:[]});return dt(t,o)}function Wm(e,t,r){const o=Wt(t._zod.def,{get shape(){const n=t._zod.def.shape,i={...n};if(r)for(const a in r){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=new e({type:"nonoptional",innerType:n[a]}))}else for(const a in n)i[a]=new e({type:"nonoptional",innerType:n[a]});return cr(this,"shape",i),i},checks:[]});return dt(t,o)}function mr(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function _t(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function $n(e){return typeof e=="string"?e:e?.message}function ut(e,t,r){const o={...e,path:e.path??[]};if(!e.message){const n=$n(e.inst?._zod.def?.error?.(e))??$n(t?.error?.(e))??$n(r.customError?.(e))??$n(r.localeError?.(e))??"Invalid input";o.message=n}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function Gi(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Ki(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Hr(...e){const[t,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function Y0(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Hm(e){const t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function Gm(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Q0(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Hm(t+r)}function X0(e){return Gm(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function eI(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const r=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)r[o/2]=Number.parseInt(t.slice(o,o+2),16);return r}function tI(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class rI{constructor(...t){}}const Km=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:Lm,Class:rI,NUMBER_FORMAT_RANGES:Um,aborted:mr,allowsEval:zm,assert:F0,assertEqual:D0,assertIs:L0,assertNever:Z0,assertNotEqual:U0,assignProp:cr,base64ToUint8Array:Hm,base64urlToUint8Array:Q0,cached:Xn,captureStackTrace:Lu,cleanEnum:Y0,cleanRegex:Wi,clone:dt,cloneDef:V0,createTransparentProxy:K0,defineLazy:ne,esc:Ys,escapeRegex:qt,extend:qm,finalizeIssue:ut,floatSafeRemainder:Am,getElementAtPath:B0,getEnumValues:Uu,getLengthableOrigin:Ki,getParsedType:G0,getSizableOrigin:Gi,hexToUint8Array:eI,isObject:Wr,isPlainObject:yr,issue:Hr,joinValues:j,jsonStringifyReplacer:ci,merge:Bm,mergeDefs:Wt,normalizeParams:P,nullish:Er,numKeys:H0,objectClone:q0,omit:Fm,optionalKeys:Dm,partial:Jm,pick:Zm,prefixIssues:_t,primitiveTypes:Mm,promiseAllObject:J0,propertyKeyTypes:di,randomString:W0,required:Wm,safeExtend:Vm,shallowClone:Hi,slugify:Rm,stringifyPrimitive:H,uint8ArrayToBase64:Gm,uint8ArrayToBase64url:X0,uint8ArrayToHex:tI,unwrapMessage:$n},Symbol.toStringTag,{value:"Module"})),Ym=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,ci,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Zu=S("$ZodError",Ym),nt=S("$ZodError",Ym,{Parent:Error});function Fu(e,t=r=>r.message){const r={},o=[];for(const n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):o.push(t(n));return{formErrors:o,fieldErrors:r}}function qu(e,t=r=>r.message){const r={_errors:[]},o=n=>{for(const i of n.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let a=r,s=0;for(;s<i.path.length;){const l=i.path[s];s===i.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(i))):a[l]=a[l]||{_errors:[]},a=a[l],s++}}};return o(e),r}function Qm(e,t=r=>r.message){const r={errors:[]},o=(n,i=[])=>{var a,s;for(const l of n.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>o({issues:u},l.path));else if(l.code==="invalid_key")o({issues:l.issues},l.path);else if(l.code==="invalid_element")o({issues:l.issues},l.path);else{const u=[...i,...l.path];if(u.length===0){r.errors.push(t(l));continue}let c=r,d=0;for(;d<u.length;){const f=u[d],p=d===u.length-1;typeof f=="string"?(c.properties??(c.properties={}),(a=c.properties)[f]??(a[f]={errors:[]}),c=c.properties[f]):(c.items??(c.items=[]),(s=c.items)[f]??(s[f]={errors:[]}),c=c.items[f]),p&&c.errors.push(t(l)),d++}}};return o(e),r}function Xm(e){const t=[],r=e.map(o=>typeof o=="object"?o.key:o);for(const o of r)typeof o=="number"?t.push(`[${o}]`):typeof o=="symbol"?t.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?t.push(`[${JSON.stringify(o)}]`):(t.length&&t.push("."),t.push(o));return t.join("")}function eh(e){const t=[],r=[...e.issues].sort((o,n)=>(o.path??[]).length-(n.path??[]).length);for(const o of r)t.push(`✖ ${o.message}`),o.path?.length&&t.push(` → at ${Xm(o.path)}`);return t.join(`
|
|
8
|
-
`)}const eo=e=>(t,r,o,n)=>{const i=o?Object.assign(o,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new vr;if(a.issues.length){const s=new(n?.Err??e)(a.issues.map(l=>ut(l,i,De())));throw Lu(s,n?.callee),s}return a.value},Qs=eo(nt),to=e=>async(t,r,o,n)=>{const i=o?Object.assign(o,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const s=new(n?.Err??e)(a.issues.map(l=>ut(l,i,De())));throw Lu(s,n?.callee),s}return a.value},Xs=to(nt),ro=e=>(t,r,o)=>{const n=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new vr;return i.issues.length?{success:!1,error:new(e??Zu)(i.issues.map(a=>ut(a,n,De())))}:{success:!0,data:i.value}},th=ro(nt),no=e=>async(t,r,o)=>{const n=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},n);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>ut(a,n,De())))}:{success:!0,data:i.value}},rh=no(nt),Vu=e=>(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return eo(e)(t,r,n)},nI=Vu(nt),Bu=e=>(t,r,o)=>eo(e)(t,r,o),oI=Bu(nt),Ju=e=>async(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return to(e)(t,r,n)},iI=Ju(nt),Wu=e=>async(t,r,o)=>to(e)(t,r,o),aI=Wu(nt),Hu=e=>(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ro(e)(t,r,n)},sI=Hu(nt),Gu=e=>(t,r,o)=>ro(e)(t,r,o),uI=Gu(nt),Ku=e=>async(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return no(e)(t,r,n)},lI=Ku(nt),Yu=e=>async(t,r,o)=>no(e)(t,r,o),cI=Yu(nt),nh=/^[cC][^\s-]{8,}$/,oh=/^[0-9a-z]+$/,ih=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ah=/^[0-9a-vA-V]{20}$/,sh=/^[A-Za-z0-9]{27}$/,uh=/^[a-zA-Z0-9_-]{21}$/,lh=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,dI=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ch=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Gr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,pI=Gr(4),fI=Gr(6),mI=Gr(7),dh=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,hI=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,gI=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,ph=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,vI=ph,yI=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,bI="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function fh(){return new RegExp(bI,"u")}const mh=/^(?:(?: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])$/,hh=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,gh=e=>{const t=qt(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},vh=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,yh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,bh=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Qu=/^[A-Za-z0-9_-]*$/,_h=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,wh=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,xh=/^\+(?:[0-9]){6,14}[0-9]$/,$h="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Sh=new RegExp(`^${$h}$`);function Ih(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function kh(e){return new RegExp(`^${Ih(e)}$`)}function Eh(e){const t=Ih({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${r.join("|")})`;return new RegExp(`^${$h}T(?:${o})$`)}const Th=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Oh=/^-?\d+n?$/,Nh=/^-?\d+$/,Ph=/^-?\d+(?:\.\d+)?/,Ch=/^(?:true|false)$/i,jh=/^null$/i,Ah=/^undefined$/i,Rh=/^[^A-Z]*$/,zh=/^[^a-z]*$/,Mh=/^[0-9a-fA-F]*$/;function oo(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function io(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const _I=/^[0-9a-fA-F]{32}$/,wI=oo(22,"=="),xI=io(22),$I=/^[0-9a-fA-F]{40}$/,SI=oo(27,"="),II=io(27),kI=/^[0-9a-fA-F]{64}$/,EI=oo(43,"="),TI=io(43),OI=/^[0-9a-fA-F]{96}$/,NI=oo(64,""),PI=io(64),CI=/^[0-9a-fA-F]{128}$/,jI=oo(86,"=="),AI=io(86),Xu=Object.freeze(Object.defineProperty({__proto__:null,base64:bh,base64url:Qu,bigint:Oh,boolean:Ch,browserEmail:yI,cidrv4:vh,cidrv6:yh,cuid:nh,cuid2:oh,date:Sh,datetime:Eh,domain:wh,duration:lh,e164:xh,email:dh,emoji:fh,extendedDuration:dI,guid:ch,hex:Mh,hostname:_h,html5Email:hI,idnEmail:vI,integer:Nh,ipv4:mh,ipv6:hh,ksuid:sh,lowercase:Rh,mac:gh,md5_base64:wI,md5_base64url:xI,md5_hex:_I,nanoid:uh,null:jh,number:Ph,rfc5322Email:gI,sha1_base64:SI,sha1_base64url:II,sha1_hex:$I,sha256_base64:EI,sha256_base64url:TI,sha256_hex:kI,sha384_base64:NI,sha384_base64url:PI,sha384_hex:OI,sha512_base64:jI,sha512_base64url:AI,sha512_hex:CI,string:Th,time:kh,ulid:ih,undefined:Ah,unicodeEmail:ph,uppercase:zh,uuid:Gr,uuid4:pI,uuid6:fI,uuid7:mI,xid:ah},Symbol.toStringTag,{value:"Module"})),Se=S("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Dh={number:"number",bigint:"bigint",object:"date"},el=S("$ZodCheckLessThan",(e,t)=>{Se.init(e,t);const r=Dh[typeof t.value];e._zod.onattach.push(o=>{const n=o._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:r,code:"too_big",maximum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tl=S("$ZodCheckGreaterThan",(e,t)=>{Se.init(e,t);const r=Dh[typeof t.value];e._zod.onattach.push(o=>{const n=o._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:r,code:"too_small",minimum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Uh=S("$ZodCheckMultipleOf",(e,t)=>{Se.init(e,t),e._zod.onattach.push(r=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Am(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Lh=S("$ZodCheckNumberFormat",(e,t)=>{Se.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),o=r?"int":"number",[n,i]=Um[t.format];e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,s.minimum=n,s.maximum=i,r&&(s.pattern=Nh)}),e._zod.check=a=>{const s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort});return}}s<n&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inst:e})}}),Zh=S("$ZodCheckBigIntFormat",(e,t)=>{Se.init(e,t);const[r,o]=Lm[t.format];e._zod.onattach.push(n=>{const i=n._zod.bag;i.format=t.format,i.minimum=r,i.maximum=o}),e._zod.check=n=>{const i=n.value;i<r&&n.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>o&&n.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inst:e})}}),Fh=S("$ZodCheckMaxSize",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.size!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const n=o.value;n.size<=t.maximum||o.issues.push({origin:Gi(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),qh=S("$ZodCheckMinSize",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.size!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const n=o.value;n.size>=t.minimum||o.issues.push({origin:Gi(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Vh=S("$ZodCheckSizeEquals",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.size!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=o=>{const n=o.value,i=n.size;if(i===t.size)return;const a=i>t.size;o.issues.push({origin:Gi(n),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Bh=S("$ZodCheckMaxLength",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const n=o.value;if(n.length<=t.maximum)return;const a=Ki(n);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Jh=S("$ZodCheckMinLength",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const n=o.value;if(n.length>=t.minimum)return;const a=Ki(n);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Wh=S("$ZodCheckLengthEquals",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=o=>{const n=o.value,i=n.length;if(i===t.length)return;const a=Ki(n),s=i>t.length;o.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),ao=S("$ZodCheckStringFormat",(e,t)=>{var r,o;Se.init(e,t),e._zod.onattach.push(n=>{const i=n._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Hh=S("$ZodCheckRegex",(e,t)=>{ao.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Gh=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Rh),ao.init(e,t)}),Kh=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zh),ao.init(e,t)}),Yh=S("$ZodCheckIncludes",(e,t)=>{Se.init(e,t);const r=qt(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Qh=S("$ZodCheckStartsWith",(e,t)=>{Se.init(e,t);const r=new RegExp(`^${qt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{const n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Xh=S("$ZodCheckEndsWith",(e,t)=>{Se.init(e,t);const r=new RegExp(`.*${qt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{const n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});function Md(e,t,r){e.issues.length&&t.issues.push(..._t(r,e.issues))}const eg=S("$ZodCheckProperty",(e,t)=>{Se.init(e,t),e._zod.check=r=>{const o=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then(n=>Md(n,r,t.property));Md(o,r,t.property)}}),tg=S("$ZodCheckMimeType",(e,t)=>{Se.init(e,t);const r=new Set(t.mime);e._zod.onattach.push(o=>{o._zod.bag.mime=t.mime}),e._zod.check=o=>{r.has(o.value.type)||o.issues.push({code:"invalid_value",values:t.mime,input:o.value.type,inst:e,continue:!t.abort})}}),rg=S("$ZodCheckOverwrite",(e,t)=>{Se.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class ng{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
|
|
7
|
+
`&&o++}}return[t,r]}let Pn=class extends TransformStream{constructor({onError:t,onRetry:r,onComment:o}={}){let n;super({start(i){n=z0({onEvent:a=>{i.enqueue(a)},onError(a){t==="terminate"?i.error(a):typeof t=="function"&&t(a)},onRetry:r,onComment:o})},transform(i){n.feed(i)}})}};const Du=Object.freeze({status:"aborted"});function S(e,t,r){function o(s,l){if(s._zod||Object.defineProperty(s,"_zod",{value:{def:l,constr:a,traits:new Set},enumerable:!1}),s._zod.traits.has(e))return;s._zod.traits.add(e),t(s,l);const u=a.prototype,c=Object.keys(u);for(let d=0;d<c.length;d++){const f=c[d];f in s||(s[f]=u[f].bind(s))}}const n=r?.Parent??Object;class i extends n{}Object.defineProperty(i,"name",{value:e});function a(s){var l;const u=r?.Parent?new i:this;o(u,s),(l=u._zod).deferred??(l.deferred=[]);for(const c of u._zod.deferred)c();return u}return Object.defineProperty(a,"init",{value:o}),Object.defineProperty(a,Symbol.hasInstance,{value:s=>r?.Parent&&s instanceof r.Parent?!0:s?._zod?.traits?.has(e)}),Object.defineProperty(a,"name",{value:e}),a}const jm=Symbol("zod_brand");class vr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Wi extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}const ci={};function De(e){return e&&Object.assign(ci,e),ci}function D0(e){return e}function U0(e){return e}function L0(e){}function Z0(e){throw new Error("Unexpected value in exhaustive check")}function F0(e){}function Uu(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,n])=>t.indexOf(+o)===-1).map(([o,n])=>n)}function j(e,t="|"){return e.map(r=>H(r)).join(t)}function di(e,t){return typeof t=="bigint"?t.toString():t}function Xn(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Er(e){return e==null}function Hi(e){const t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}function Am(e,t){const r=(e.toString().split(".")[1]||"").length,o=t.toString();let n=(o.split(".")[1]||"").length;if(n===0&&/\d?e-\d?/.test(o)){const l=o.match(/\d?e-(\d?)/);l?.[1]&&(n=Number.parseInt(l[1]))}const i=r>n?r:n,a=Number.parseInt(e.toFixed(i).replace(".","")),s=Number.parseInt(t.toFixed(i).replace(".",""));return a%s/10**i}const zd=Symbol("evaluating");function ne(e,t,r){let o;Object.defineProperty(e,t,{get(){if(o!==zd)return o===void 0&&(o=zd,o=r()),o},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function q0(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function cr(e,t,r){Object.defineProperty(e,t,{value:r,writable:!0,enumerable:!0,configurable:!0})}function Wt(...e){const t={};for(const r of e){const o=Object.getOwnPropertyDescriptors(r);Object.assign(t,o)}return Object.defineProperties({},t)}function V0(e){return Wt(e._zod.def)}function B0(e,t){return t?t.reduce((r,o)=>r?.[o],e):e}function J0(e){const t=Object.keys(e),r=t.map(o=>e[o]);return Promise.all(r).then(o=>{const n={};for(let i=0;i<t.length;i++)n[t[i]]=o[i];return n})}function W0(e=10){const t="abcdefghijklmnopqrstuvwxyz";let r="";for(let o=0;o<e;o++)r+=t[Math.floor(Math.random()*t.length)];return r}function Ys(e){return JSON.stringify(e)}function Rm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Lu="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Wr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const zm=Xn(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function yr(e){if(Wr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const r=t.prototype;return!(Wr(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}function Gi(e){return yr(e)?{...e}:Array.isArray(e)?[...e]:e}function H0(e){let t=0;for(const r in e)Object.prototype.hasOwnProperty.call(e,r)&&t++;return t}const G0=e=>{const t=typeof e;switch(t){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(e)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":return Array.isArray(e)?"array":e===null?"null":e.then&&typeof e.then=="function"&&e.catch&&typeof e.catch=="function"?"promise":typeof Map<"u"&&e instanceof Map?"map":typeof Set<"u"&&e instanceof Set?"set":typeof Date<"u"&&e instanceof Date?"date":typeof File<"u"&&e instanceof File?"file":"object";default:throw new Error(`Unknown data type: ${t}`)}},pi=new Set(["string","number","symbol"]),Mm=new Set(["string","number","bigint","boolean","symbol","undefined"]);function qt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function dt(e,t,r){const o=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(o._zod.parent=e),o}function P(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:()=>t.error}:t}function K0(e){let t;return new Proxy({},{get(r,o,n){return t??(t=e()),Reflect.get(t,o,n)},set(r,o,n,i){return t??(t=e()),Reflect.set(t,o,n,i)},has(r,o){return t??(t=e()),Reflect.has(t,o)},deleteProperty(r,o){return t??(t=e()),Reflect.deleteProperty(t,o)},ownKeys(r){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(r,o){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,o)},defineProperty(r,o,n){return t??(t=e()),Reflect.defineProperty(t,o,n)}})}function H(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Dm(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const Um={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Lm={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Zm(e,t){const r=e._zod.def,o=Wt(e._zod.def,{get shape(){const n={};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&(n[i]=r.shape[i])}return cr(this,"shape",n),n},checks:[]});return dt(e,o)}function Fm(e,t){const r=e._zod.def,o=Wt(e._zod.def,{get shape(){const n={...e._zod.def.shape};for(const i in t){if(!(i in r.shape))throw new Error(`Unrecognized key: "${i}"`);t[i]&&delete n[i]}return cr(this,"shape",n),n},checks:[]});return dt(e,o)}function qm(e,t){if(!yr(t))throw new Error("Invalid input to extend: expected a plain object");const r=e._zod.def.checks;if(r&&r.length>0)throw new Error("Object schemas containing refinements cannot be extended. Use `.safeExtend()` instead.");const n=Wt(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return cr(this,"shape",i),i},checks:[]});return dt(e,n)}function Vm(e,t){if(!yr(t))throw new Error("Invalid input to safeExtend: expected a plain object");const r={...e._zod.def,get shape(){const o={...e._zod.def.shape,...t};return cr(this,"shape",o),o},checks:e._zod.def.checks};return dt(e,r)}function Bm(e,t){const r=Wt(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return cr(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:[]});return dt(e,r)}function Jm(e,t,r){const o=Wt(t._zod.def,{get shape(){const n=t._zod.def.shape,i={...n};if(r)for(const a in r){if(!(a in n))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=e?new e({type:"optional",innerType:n[a]}):n[a])}else for(const a in n)i[a]=e?new e({type:"optional",innerType:n[a]}):n[a];return cr(this,"shape",i),i},checks:[]});return dt(t,o)}function Wm(e,t,r){const o=Wt(t._zod.def,{get shape(){const n=t._zod.def.shape,i={...n};if(r)for(const a in r){if(!(a in i))throw new Error(`Unrecognized key: "${a}"`);r[a]&&(i[a]=new e({type:"nonoptional",innerType:n[a]}))}else for(const a in n)i[a]=new e({type:"nonoptional",innerType:n[a]});return cr(this,"shape",i),i},checks:[]});return dt(t,o)}function mr(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}function _t(e,t){return t.map(r=>{var o;return(o=r).path??(o.path=[]),r.path.unshift(e),r})}function $n(e){return typeof e=="string"?e:e?.message}function ut(e,t,r){const o={...e,path:e.path??[]};if(!e.message){const n=$n(e.inst?._zod.def?.error?.(e))??$n(t?.error?.(e))??$n(r.customError?.(e))??$n(r.localeError?.(e))??"Invalid input";o.message=n}return delete o.inst,delete o.continue,t?.reportInput||delete o.input,o}function Ki(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}function Yi(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Hr(...e){const[t,r,o]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:o}:{...t}}function Y0(e){return Object.entries(e).filter(([t,r])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Hm(e){const t=atob(e),r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o);return r}function Gm(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}function Q0(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r="=".repeat((4-t.length%4)%4);return Hm(t+r)}function X0(e){return Gm(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function eI(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const r=new Uint8Array(t.length/2);for(let o=0;o<t.length;o+=2)r[o/2]=Number.parseInt(t.slice(o,o+2),16);return r}function tI(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class rI{constructor(...t){}}const Km=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:Lm,Class:rI,NUMBER_FORMAT_RANGES:Um,aborted:mr,allowsEval:zm,assert:F0,assertEqual:D0,assertIs:L0,assertNever:Z0,assertNotEqual:U0,assignProp:cr,base64ToUint8Array:Hm,base64urlToUint8Array:Q0,cached:Xn,captureStackTrace:Lu,cleanEnum:Y0,cleanRegex:Hi,clone:dt,cloneDef:V0,createTransparentProxy:K0,defineLazy:ne,esc:Ys,escapeRegex:qt,extend:qm,finalizeIssue:ut,floatSafeRemainder:Am,getElementAtPath:B0,getEnumValues:Uu,getLengthableOrigin:Yi,getParsedType:G0,getSizableOrigin:Ki,hexToUint8Array:eI,isObject:Wr,isPlainObject:yr,issue:Hr,joinValues:j,jsonStringifyReplacer:di,merge:Bm,mergeDefs:Wt,normalizeParams:P,nullish:Er,numKeys:H0,objectClone:q0,omit:Fm,optionalKeys:Dm,partial:Jm,pick:Zm,prefixIssues:_t,primitiveTypes:Mm,promiseAllObject:J0,propertyKeyTypes:pi,randomString:W0,required:Wm,safeExtend:Vm,shallowClone:Gi,slugify:Rm,stringifyPrimitive:H,uint8ArrayToBase64:Gm,uint8ArrayToBase64url:X0,uint8ArrayToHex:tI,unwrapMessage:$n},Symbol.toStringTag,{value:"Module"})),Ym=(e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,di,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Zu=S("$ZodError",Ym),nt=S("$ZodError",Ym,{Parent:Error});function Fu(e,t=r=>r.message){const r={},o=[];for(const n of e.issues)n.path.length>0?(r[n.path[0]]=r[n.path[0]]||[],r[n.path[0]].push(t(n))):o.push(t(n));return{formErrors:o,fieldErrors:r}}function qu(e,t=r=>r.message){const r={_errors:[]},o=n=>{for(const i of n.issues)if(i.code==="invalid_union"&&i.errors.length)i.errors.map(a=>o({issues:a}));else if(i.code==="invalid_key")o({issues:i.issues});else if(i.code==="invalid_element")o({issues:i.issues});else if(i.path.length===0)r._errors.push(t(i));else{let a=r,s=0;for(;s<i.path.length;){const l=i.path[s];s===i.path.length-1?(a[l]=a[l]||{_errors:[]},a[l]._errors.push(t(i))):a[l]=a[l]||{_errors:[]},a=a[l],s++}}};return o(e),r}function Qm(e,t=r=>r.message){const r={errors:[]},o=(n,i=[])=>{var a,s;for(const l of n.issues)if(l.code==="invalid_union"&&l.errors.length)l.errors.map(u=>o({issues:u},l.path));else if(l.code==="invalid_key")o({issues:l.issues},l.path);else if(l.code==="invalid_element")o({issues:l.issues},l.path);else{const u=[...i,...l.path];if(u.length===0){r.errors.push(t(l));continue}let c=r,d=0;for(;d<u.length;){const f=u[d],p=d===u.length-1;typeof f=="string"?(c.properties??(c.properties={}),(a=c.properties)[f]??(a[f]={errors:[]}),c=c.properties[f]):(c.items??(c.items=[]),(s=c.items)[f]??(s[f]={errors:[]}),c=c.items[f]),p&&c.errors.push(t(l)),d++}}};return o(e),r}function Xm(e){const t=[],r=e.map(o=>typeof o=="object"?o.key:o);for(const o of r)typeof o=="number"?t.push(`[${o}]`):typeof o=="symbol"?t.push(`[${JSON.stringify(String(o))}]`):/[^\w$]/.test(o)?t.push(`[${JSON.stringify(o)}]`):(t.length&&t.push("."),t.push(o));return t.join("")}function eh(e){const t=[],r=[...e.issues].sort((o,n)=>(o.path??[]).length-(n.path??[]).length);for(const o of r)t.push(`✖ ${o.message}`),o.path?.length&&t.push(` → at ${Xm(o.path)}`);return t.join(`
|
|
8
|
+
`)}const eo=e=>(t,r,o,n)=>{const i=o?Object.assign(o,{async:!1}):{async:!1},a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise)throw new vr;if(a.issues.length){const s=new(n?.Err??e)(a.issues.map(l=>ut(l,i,De())));throw Lu(s,n?.callee),s}return a.value},Qs=eo(nt),to=e=>async(t,r,o,n)=>{const i=o?Object.assign(o,{async:!0}):{async:!0};let a=t._zod.run({value:r,issues:[]},i);if(a instanceof Promise&&(a=await a),a.issues.length){const s=new(n?.Err??e)(a.issues.map(l=>ut(l,i,De())));throw Lu(s,n?.callee),s}return a.value},Xs=to(nt),ro=e=>(t,r,o)=>{const n=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:r,issues:[]},n);if(i instanceof Promise)throw new vr;return i.issues.length?{success:!1,error:new(e??Zu)(i.issues.map(a=>ut(a,n,De())))}:{success:!0,data:i.value}},th=ro(nt),no=e=>async(t,r,o)=>{const n=o?Object.assign(o,{async:!0}):{async:!0};let i=t._zod.run({value:r,issues:[]},n);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(a=>ut(a,n,De())))}:{success:!0,data:i.value}},rh=no(nt),Vu=e=>(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return eo(e)(t,r,n)},nI=Vu(nt),Bu=e=>(t,r,o)=>eo(e)(t,r,o),oI=Bu(nt),Ju=e=>async(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return to(e)(t,r,n)},iI=Ju(nt),Wu=e=>async(t,r,o)=>to(e)(t,r,o),aI=Wu(nt),Hu=e=>(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return ro(e)(t,r,n)},sI=Hu(nt),Gu=e=>(t,r,o)=>ro(e)(t,r,o),uI=Gu(nt),Ku=e=>async(t,r,o)=>{const n=o?Object.assign(o,{direction:"backward"}):{direction:"backward"};return no(e)(t,r,n)},lI=Ku(nt),Yu=e=>async(t,r,o)=>no(e)(t,r,o),cI=Yu(nt),nh=/^[cC][^\s-]{8,}$/,oh=/^[0-9a-z]+$/,ih=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,ah=/^[0-9a-vA-V]{20}$/,sh=/^[A-Za-z0-9]{27}$/,uh=/^[a-zA-Z0-9_-]{21}$/,lh=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,dI=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,ch=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Gr=e=>e?new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,pI=Gr(4),fI=Gr(6),mI=Gr(7),dh=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,hI=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,gI=/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,ph=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,vI=ph,yI=/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,bI="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function fh(){return new RegExp(bI,"u")}const mh=/^(?:(?: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])$/,hh=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,gh=e=>{const t=qt(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},vh=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,yh=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,bh=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Qu=/^[A-Za-z0-9_-]*$/,_h=/^(?=.{1,253}\.?$)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[-0-9a-zA-Z]{0,61}[0-9a-zA-Z])?)*\.?$/,wh=/^([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/,xh=/^\+(?:[0-9]){6,14}[0-9]$/,$h="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",Sh=new RegExp(`^${$h}$`);function Ih(e){const t="(?:[01]\\d|2[0-3]):[0-5]\\d";return typeof e.precision=="number"?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function kh(e){return new RegExp(`^${Ih(e)}$`)}function Eh(e){const t=Ih({precision:e.precision}),r=["Z"];e.local&&r.push(""),e.offset&&r.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${r.join("|")})`;return new RegExp(`^${$h}T(?:${o})$`)}const Th=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Oh=/^-?\d+n?$/,Nh=/^-?\d+$/,Ph=/^-?\d+(?:\.\d+)?/,Ch=/^(?:true|false)$/i,jh=/^null$/i,Ah=/^undefined$/i,Rh=/^[^A-Z]*$/,zh=/^[^a-z]*$/,Mh=/^[0-9a-fA-F]*$/;function oo(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function io(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const _I=/^[0-9a-fA-F]{32}$/,wI=oo(22,"=="),xI=io(22),$I=/^[0-9a-fA-F]{40}$/,SI=oo(27,"="),II=io(27),kI=/^[0-9a-fA-F]{64}$/,EI=oo(43,"="),TI=io(43),OI=/^[0-9a-fA-F]{96}$/,NI=oo(64,""),PI=io(64),CI=/^[0-9a-fA-F]{128}$/,jI=oo(86,"=="),AI=io(86),Xu=Object.freeze(Object.defineProperty({__proto__:null,base64:bh,base64url:Qu,bigint:Oh,boolean:Ch,browserEmail:yI,cidrv4:vh,cidrv6:yh,cuid:nh,cuid2:oh,date:Sh,datetime:Eh,domain:wh,duration:lh,e164:xh,email:dh,emoji:fh,extendedDuration:dI,guid:ch,hex:Mh,hostname:_h,html5Email:hI,idnEmail:vI,integer:Nh,ipv4:mh,ipv6:hh,ksuid:sh,lowercase:Rh,mac:gh,md5_base64:wI,md5_base64url:xI,md5_hex:_I,nanoid:uh,null:jh,number:Ph,rfc5322Email:gI,sha1_base64:SI,sha1_base64url:II,sha1_hex:$I,sha256_base64:EI,sha256_base64url:TI,sha256_hex:kI,sha384_base64:NI,sha384_base64url:PI,sha384_hex:OI,sha512_base64:jI,sha512_base64url:AI,sha512_hex:CI,string:Th,time:kh,ulid:ih,undefined:Ah,unicodeEmail:ph,uppercase:zh,uuid:Gr,uuid4:pI,uuid6:fI,uuid7:mI,xid:ah},Symbol.toStringTag,{value:"Module"})),Se=S("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),Dh={number:"number",bigint:"bigint",object:"date"},el=S("$ZodCheckLessThan",(e,t)=>{Se.init(e,t);const r=Dh[typeof t.value];e._zod.onattach.push(o=>{const n=o._zod.bag,i=(t.inclusive?n.maximum:n.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:r,code:"too_big",maximum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),tl=S("$ZodCheckGreaterThan",(e,t)=>{Se.init(e,t);const r=Dh[typeof t.value];e._zod.onattach.push(o=>{const n=o._zod.bag,i=(t.inclusive?n.minimum:n.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:r,code:"too_small",minimum:t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Uh=S("$ZodCheckMultipleOf",(e,t)=>{Se.init(e,t),e._zod.onattach.push(r=>{var o;(o=r._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=r=>{if(typeof r.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof r.value=="bigint"?r.value%t.value===BigInt(0):Am(r.value,t.value)===0)||r.issues.push({origin:typeof r.value,code:"not_multiple_of",divisor:t.value,input:r.value,inst:e,continue:!t.abort})}}),Lh=S("$ZodCheckNumberFormat",(e,t)=>{Se.init(e,t),t.format=t.format||"float64";const r=t.format?.includes("int"),o=r?"int":"number",[n,i]=Um[t.format];e._zod.onattach.push(a=>{const s=a._zod.bag;s.format=t.format,s.minimum=n,s.maximum=i,r&&(s.pattern=Nh)}),e._zod.check=a=>{const s=a.value;if(r){if(!Number.isInteger(s)){a.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?a.issues.push({input:s,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort}):a.issues.push({input:s,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,continue:!t.abort});return}}s<n&&a.issues.push({origin:"number",input:s,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),s>i&&a.issues.push({origin:"number",input:s,code:"too_big",maximum:i,inst:e})}}),Zh=S("$ZodCheckBigIntFormat",(e,t)=>{Se.init(e,t);const[r,o]=Lm[t.format];e._zod.onattach.push(n=>{const i=n._zod.bag;i.format=t.format,i.minimum=r,i.maximum=o}),e._zod.check=n=>{const i=n.value;i<r&&n.issues.push({origin:"bigint",input:i,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),i>o&&n.issues.push({origin:"bigint",input:i,code:"too_big",maximum:o,inst:e})}}),Fh=S("$ZodCheckMaxSize",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.size!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const n=o.value;n.size<=t.maximum||o.issues.push({origin:Ki(n),code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),qh=S("$ZodCheckMinSize",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.size!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const n=o.value;n.size>=t.minimum||o.issues.push({origin:Ki(n),code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Vh=S("$ZodCheckSizeEquals",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.size!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag;n.minimum=t.size,n.maximum=t.size,n.size=t.size}),e._zod.check=o=>{const n=o.value,i=n.size;if(i===t.size)return;const a=i>t.size;o.issues.push({origin:Ki(n),...a?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),Bh=S("$ZodCheckMaxLength",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<n&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const n=o.value;if(n.length<=t.maximum)return;const a=Yi(n);o.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Jh=S("$ZodCheckMinLength",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>n&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const n=o.value;if(n.length>=t.minimum)return;const a=Yi(n);o.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:n,inst:e,continue:!t.abort})}}),Wh=S("$ZodCheckLengthEquals",(e,t)=>{var r;Se.init(e,t),(r=e._zod.def).when??(r.when=o=>{const n=o.value;return!Er(n)&&n.length!==void 0}),e._zod.onattach.push(o=>{const n=o._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=o=>{const n=o.value,i=n.length;if(i===t.length)return;const a=Yi(n),s=i>t.length;o.issues.push({origin:a,...s?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),ao=S("$ZodCheckStringFormat",(e,t)=>{var r,o;Se.init(e,t),e._zod.onattach.push(n=>{const i=n._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),Hh=S("$ZodCheckRegex",(e,t)=>{ao.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Gh=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Rh),ao.init(e,t)}),Kh=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=zh),ao.init(e,t)}),Yh=S("$ZodCheckIncludes",(e,t)=>{Se.init(e,t);const r=qt(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${r}`:r);t.pattern=o,e._zod.onattach.push(n=>{const i=n._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Qh=S("$ZodCheckStartsWith",(e,t)=>{Se.init(e,t);const r=new RegExp(`^${qt(t.prefix)}.*`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{const n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),Xh=S("$ZodCheckEndsWith",(e,t)=>{Se.init(e,t);const r=new RegExp(`.*${qt(t.suffix)}$`);t.pattern??(t.pattern=r),e._zod.onattach.push(o=>{const n=o._zod.bag;n.patterns??(n.patterns=new Set),n.patterns.add(r)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}});function Md(e,t,r){e.issues.length&&t.issues.push(..._t(r,e.issues))}const eg=S("$ZodCheckProperty",(e,t)=>{Se.init(e,t),e._zod.check=r=>{const o=t.schema._zod.run({value:r.value[t.property],issues:[]},{});if(o instanceof Promise)return o.then(n=>Md(n,r,t.property));Md(o,r,t.property)}}),tg=S("$ZodCheckMimeType",(e,t)=>{Se.init(e,t);const r=new Set(t.mime);e._zod.onattach.push(o=>{o._zod.bag.mime=t.mime}),e._zod.check=o=>{r.has(o.value.type)||o.issues.push({code:"invalid_value",values:t.mime,input:o.value.type,inst:e,continue:!t.abort})}}),rg=S("$ZodCheckOverwrite",(e,t)=>{Se.init(e,t),e._zod.check=r=>{r.value=t.tx(r.value)}});class ng{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
|
|
9
9
|
`).filter(a=>a),n=Math.min(...o.map(a=>a.length-a.trimStart().length)),i=o.map(a=>a.slice(n)).map(a=>" ".repeat(this.indent*2)+a);for(const a of i)this.content.push(a)}compile(){const t=Function,r=this?.args,n=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...r,n.join(`
|
|
10
|
-
`))}}const og={major:4,minor:2,patch:1},X=S("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=og;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const n of o)for(const i of n._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const n=(a,s,l)=>{let u=mr(a),c;for(const d of s){if(d._zod.def.when){if(!d._zod.def.when(a))continue}else if(u)continue;const f=a.issues.length,p=d._zod.check(a);if(p instanceof Promise&&l?.async===!1)throw new vr;if(c||p instanceof Promise)c=(c??Promise.resolve()).then(async()=>{await p,a.issues.length!==f&&(u||(u=mr(a,f)))});else{if(a.issues.length===f)continue;u||(u=mr(a,f))}}return c?c.then(()=>a):a},i=(a,s,l)=>{if(mr(a))return a.aborted=!0,a;const u=n(s,o,l);if(u instanceof Promise){if(l.async===!1)throw new vr;return u.then(c=>e._zod.parse(c,l))}return e._zod.parse(u,l)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(c=>i(c,a,s)):i(u,a,s)}const l=e._zod.parse(a,s);if(l instanceof Promise){if(s.async===!1)throw new vr;return l.then(u=>n(u,o,s))}return n(l,o,s)}}e["~standard"]={validate:n=>{try{const i=th(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return rh(e,n).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}}),so=S("$ZodString",(e,t)=>{X.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Th(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ge=S("$ZodStringFormat",(e,t)=>{ao.init(e,t),so.init(e,t)}),ig=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ch),ge.init(e,t)}),ag=S("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Gr(o))}else t.pattern??(t.pattern=Gr());ge.init(e,t)}),sg=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=dh),ge.init(e,t)}),ug=S("$ZodURL",(e,t)=>{ge.init(e,t),e._zod.check=r=>{try{const o=r.value.trim(),n=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(n.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=n.href:r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),lg=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=fh()),ge.init(e,t)}),cg=S("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=uh),ge.init(e,t)}),dg=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=nh),ge.init(e,t)}),pg=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=oh),ge.init(e,t)}),fg=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ih),ge.init(e,t)}),mg=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ah),ge.init(e,t)}),hg=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=sh),ge.init(e,t)}),gg=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Eh(t)),ge.init(e,t)}),vg=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Sh),ge.init(e,t)}),yg=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=kh(t)),ge.init(e,t)}),bg=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=lh),ge.init(e,t)}),_g=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=mh),ge.init(e,t),e._zod.bag.format="ipv4"}),wg=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=hh),ge.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),xg=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=gh(t.delimiter)),ge.init(e,t),e._zod.bag.format="mac"}),$g=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=vh),ge.init(e,t)}),Sg=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=yh),ge.init(e,t),e._zod.check=r=>{const o=r.value.split("/");try{if(o.length!==2)throw new Error;const[n,i]=o;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function rl(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Ig=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=bh),ge.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{rl(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function kg(e){if(!Qu.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return rl(r)}const Eg=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Qu),ge.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{kg(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Tg=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=xh),ge.init(e,t)});function Og(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[o]=r;if(!o)return!1;const n=JSON.parse(atob(o));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}const Ng=S("$ZodJWT",(e,t)=>{ge.init(e,t),e._zod.check=r=>{Og(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Pg=S("$ZodCustomStringFormat",(e,t)=>{ge.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),nl=S("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ph,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;const i=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}}),Cg=S("$ZodNumberFormat",(e,t)=>{Lh.init(e,t),nl.init(e,t)}),ol=S("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=Ch,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=!!r.value}catch{}const n=r.value;return typeof n=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),il=S("$ZodBigInt",(e,t)=>{X.init(e,t),e._zod.pattern=Oh,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),jg=S("$ZodBigIntFormat",(e,t)=>{Zh.init(e,t),il.init(e,t)}),Ag=S("$ZodSymbol",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;return typeof n=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),Rg=S("$ZodUndefined",(e,t)=>{X.init(e,t),e._zod.pattern=Ah,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(r,o)=>{const n=r.value;return typeof n>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),zg=S("$ZodNull",(e,t)=>{X.init(e,t),e._zod.pattern=jh,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{const n=r.value;return n===null||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),Mg=S("$ZodAny",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),Dg=S("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),Ug=S("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Lg=S("$ZodVoid",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;return typeof n>"u"||r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),Zg=S("$ZodDate",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}const n=r.value,i=n instanceof Date;return i&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...i?{received:"Invalid Date"}:{},inst:e}),r}});function Dd(e,t,r){e.issues.length&&t.issues.push(..._t(r,e.issues)),t.value[r]=e.value}const Fg=S("$ZodArray",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);const i=[];for(let a=0;a<n.length;a++){const s=n[a],l=t.element._zod.run({value:s,issues:[]},o);l instanceof Promise?i.push(l.then(u=>Dd(u,r,a))):Dd(l,r,a)}return i.length?Promise.all(i).then(()=>r):r}});function pi(e,t,r,o){e.issues.length&&t.issues.push(..._t(r,e.issues)),e.value===void 0?r in o&&(t.value[r]=void 0):t.value[r]=e.value}function qg(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const r=Dm(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Vg(e,t,r,o,n,i){const a=[],s=n.keySet,l=n.catchall._zod,u=l.def.type;for(const c in t){if(s.has(c))continue;if(u==="never"){a.push(c);continue}const d=l.run({value:t[c],issues:[]},o);d instanceof Promise?e.push(d.then(f=>pi(f,r,c,t))):pi(d,r,c,t)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}const Bg=S("$ZodObject",(e,t)=>{if(X.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...s};return Object.defineProperty(t,"shape",{value:l}),l}})}const o=Xn(()=>qg(t));ne(e._zod,"propValues",()=>{const s=t.shape,l={};for(const u in s){const c=s[u]._zod;if(c.values){l[u]??(l[u]=new Set);for(const d of c.values)l[u].add(d)}}return l});const n=Wr,i=t.catchall;let a;e._zod.parse=(s,l)=>{a??(a=o.value);const u=s.value;if(!n(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};const c=[],d=a.shape;for(const f of a.keys){const g=d[f]._zod.run({value:u[f],issues:[]},l);g instanceof Promise?c.push(g.then(h=>pi(h,s,f,u))):pi(g,s,f,u)}return i?Vg(c,u,s,l,o.value,e):c.length?Promise.all(c).then(()=>s):s}}),Jg=S("$ZodObjectJIT",(e,t)=>{Bg.init(e,t);const r=e._zod.parse,o=Xn(()=>qg(t)),n=f=>{const p=new ng(["shape","payload","ctx"]),g=o.value,h=$=>{const v=Ys($);return`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`};p.write("const input = payload.value;");const b=Object.create(null);let y=0;for(const $ of g.keys)b[$]=`key_${y++}`;p.write("const newResult = {};");for(const $ of g.keys){const v=b[$],k=Ys($);p.write(`const ${v} = ${h($)};`),p.write(`
|
|
10
|
+
`))}}const og={major:4,minor:2,patch:1},X=S("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=og;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const n of o)for(const i of n._zod.onattach)i(e);if(o.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const n=(a,s,l)=>{let u=mr(a),c;for(const d of s){if(d._zod.def.when){if(!d._zod.def.when(a))continue}else if(u)continue;const f=a.issues.length,p=d._zod.check(a);if(p instanceof Promise&&l?.async===!1)throw new vr;if(c||p instanceof Promise)c=(c??Promise.resolve()).then(async()=>{await p,a.issues.length!==f&&(u||(u=mr(a,f)))});else{if(a.issues.length===f)continue;u||(u=mr(a,f))}}return c?c.then(()=>a):a},i=(a,s,l)=>{if(mr(a))return a.aborted=!0,a;const u=n(s,o,l);if(u instanceof Promise){if(l.async===!1)throw new vr;return u.then(c=>e._zod.parse(c,l))}return e._zod.parse(u,l)};e._zod.run=(a,s)=>{if(s.skipChecks)return e._zod.parse(a,s);if(s.direction==="backward"){const u=e._zod.parse({value:a.value,issues:[]},{...s,skipChecks:!0});return u instanceof Promise?u.then(c=>i(c,a,s)):i(u,a,s)}const l=e._zod.parse(a,s);if(l instanceof Promise){if(s.async===!1)throw new vr;return l.then(u=>n(u,o,s))}return n(l,o,s)}}e["~standard"]={validate:n=>{try{const i=th(e,n);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return rh(e,n).then(a=>a.success?{value:a.data}:{issues:a.error?.issues})}},vendor:"zod",version:1}}),so=S("$ZodString",(e,t)=>{X.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??Th(e._zod.bag),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),ge=S("$ZodStringFormat",(e,t)=>{ao.init(e,t),so.init(e,t)}),ig=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=ch),ge.init(e,t)}),ag=S("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Gr(o))}else t.pattern??(t.pattern=Gr());ge.init(e,t)}),sg=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=dh),ge.init(e,t)}),ug=S("$ZodURL",(e,t)=>{ge.init(e,t),e._zod.check=r=>{try{const o=r.value.trim(),n=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(n.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(n.protocol.endsWith(":")?n.protocol.slice(0,-1):n.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=n.href:r.value=o;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}}),lg=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=fh()),ge.init(e,t)}),cg=S("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=uh),ge.init(e,t)}),dg=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=nh),ge.init(e,t)}),pg=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=oh),ge.init(e,t)}),fg=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=ih),ge.init(e,t)}),mg=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=ah),ge.init(e,t)}),hg=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=sh),ge.init(e,t)}),gg=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Eh(t)),ge.init(e,t)}),vg=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Sh),ge.init(e,t)}),yg=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=kh(t)),ge.init(e,t)}),bg=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=lh),ge.init(e,t)}),_g=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=mh),ge.init(e,t),e._zod.bag.format="ipv4"}),wg=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=hh),ge.init(e,t),e._zod.bag.format="ipv6",e._zod.check=r=>{try{new URL(`http://[${r.value}]`)}catch{r.issues.push({code:"invalid_format",format:"ipv6",input:r.value,inst:e,continue:!t.abort})}}}),xg=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=gh(t.delimiter)),ge.init(e,t),e._zod.bag.format="mac"}),$g=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=vh),ge.init(e,t)}),Sg=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=yh),ge.init(e,t),e._zod.check=r=>{const o=r.value.split("/");try{if(o.length!==2)throw new Error;const[n,i]=o;if(!i)throw new Error;const a=Number(i);if(`${a}`!==i)throw new Error;if(a<0||a>128)throw new Error;new URL(`http://[${n}]`)}catch{r.issues.push({code:"invalid_format",format:"cidrv6",input:r.value,inst:e,continue:!t.abort})}}});function rl(e){if(e==="")return!0;if(e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Ig=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=bh),ge.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=r=>{rl(r.value)||r.issues.push({code:"invalid_format",format:"base64",input:r.value,inst:e,continue:!t.abort})}});function kg(e){if(!Qu.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),r=t.padEnd(Math.ceil(t.length/4)*4,"=");return rl(r)}const Eg=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Qu),ge.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=r=>{kg(r.value)||r.issues.push({code:"invalid_format",format:"base64url",input:r.value,inst:e,continue:!t.abort})}}),Tg=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=xh),ge.init(e,t)});function Og(e,t=null){try{const r=e.split(".");if(r.length!==3)return!1;const[o]=r;if(!o)return!1;const n=JSON.parse(atob(o));return!("typ"in n&&n?.typ!=="JWT"||!n.alg||t&&(!("alg"in n)||n.alg!==t))}catch{return!1}}const Ng=S("$ZodJWT",(e,t)=>{ge.init(e,t),e._zod.check=r=>{Og(r.value,t.alg)||r.issues.push({code:"invalid_format",format:"jwt",input:r.value,inst:e,continue:!t.abort})}}),Pg=S("$ZodCustomStringFormat",(e,t)=>{ge.init(e,t),e._zod.check=r=>{t.fn(r.value)||r.issues.push({code:"invalid_format",format:t.format,input:r.value,inst:e,continue:!t.abort})}}),nl=S("$ZodNumber",(e,t)=>{X.init(e,t),e._zod.pattern=e._zod.bag.pattern??Ph,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}const n=r.value;if(typeof n=="number"&&!Number.isNaN(n)&&Number.isFinite(n))return r;const i=typeof n=="number"?Number.isNaN(n)?"NaN":Number.isFinite(n)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:n,inst:e,...i?{received:i}:{}}),r}}),Cg=S("$ZodNumberFormat",(e,t)=>{Lh.init(e,t),nl.init(e,t)}),ol=S("$ZodBoolean",(e,t)=>{X.init(e,t),e._zod.pattern=Ch,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=!!r.value}catch{}const n=r.value;return typeof n=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:n,inst:e}),r}}),il=S("$ZodBigInt",(e,t)=>{X.init(e,t),e._zod.pattern=Oh,e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}}),jg=S("$ZodBigIntFormat",(e,t)=>{Zh.init(e,t),il.init(e,t)}),Ag=S("$ZodSymbol",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;return typeof n=="symbol"||r.issues.push({expected:"symbol",code:"invalid_type",input:n,inst:e}),r}}),Rg=S("$ZodUndefined",(e,t)=>{X.init(e,t),e._zod.pattern=Ah,e._zod.values=new Set([void 0]),e._zod.optin="optional",e._zod.optout="optional",e._zod.parse=(r,o)=>{const n=r.value;return typeof n>"u"||r.issues.push({expected:"undefined",code:"invalid_type",input:n,inst:e}),r}}),zg=S("$ZodNull",(e,t)=>{X.init(e,t),e._zod.pattern=jh,e._zod.values=new Set([null]),e._zod.parse=(r,o)=>{const n=r.value;return n===null||r.issues.push({expected:"null",code:"invalid_type",input:n,inst:e}),r}}),Mg=S("$ZodAny",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),Dg=S("$ZodUnknown",(e,t)=>{X.init(e,t),e._zod.parse=r=>r}),Ug=S("$ZodNever",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>(r.issues.push({expected:"never",code:"invalid_type",input:r.value,inst:e}),r)}),Lg=S("$ZodVoid",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;return typeof n>"u"||r.issues.push({expected:"void",code:"invalid_type",input:n,inst:e}),r}}),Zg=S("$ZodDate",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}const n=r.value,i=n instanceof Date;return i&&!Number.isNaN(n.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:n,...i?{received:"Invalid Date"}:{},inst:e}),r}});function Dd(e,t,r){e.issues.length&&t.issues.push(..._t(r,e.issues)),t.value[r]=e.value}const Fg=S("$ZodArray",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!Array.isArray(n))return r.issues.push({expected:"array",code:"invalid_type",input:n,inst:e}),r;r.value=Array(n.length);const i=[];for(let a=0;a<n.length;a++){const s=n[a],l=t.element._zod.run({value:s,issues:[]},o);l instanceof Promise?i.push(l.then(u=>Dd(u,r,a))):Dd(l,r,a)}return i.length?Promise.all(i).then(()=>r):r}});function fi(e,t,r,o){e.issues.length&&t.issues.push(..._t(r,e.issues)),e.value===void 0?r in o&&(t.value[r]=void 0):t.value[r]=e.value}function qg(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const r=Dm(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}function Vg(e,t,r,o,n,i){const a=[],s=n.keySet,l=n.catchall._zod,u=l.def.type;for(const c in t){if(s.has(c))continue;if(u==="never"){a.push(c);continue}const d=l.run({value:t[c],issues:[]},o);d instanceof Promise?e.push(d.then(f=>fi(f,r,c,t))):fi(d,r,c,t)}return a.length&&r.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i}),e.length?Promise.all(e).then(()=>r):r}const Bg=S("$ZodObject",(e,t)=>{if(X.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const s=t.shape;Object.defineProperty(t,"shape",{get:()=>{const l={...s};return Object.defineProperty(t,"shape",{value:l}),l}})}const o=Xn(()=>qg(t));ne(e._zod,"propValues",()=>{const s=t.shape,l={};for(const u in s){const c=s[u]._zod;if(c.values){l[u]??(l[u]=new Set);for(const d of c.values)l[u].add(d)}}return l});const n=Wr,i=t.catchall;let a;e._zod.parse=(s,l)=>{a??(a=o.value);const u=s.value;if(!n(u))return s.issues.push({expected:"object",code:"invalid_type",input:u,inst:e}),s;s.value={};const c=[],d=a.shape;for(const f of a.keys){const g=d[f]._zod.run({value:u[f],issues:[]},l);g instanceof Promise?c.push(g.then(h=>fi(h,s,f,u))):fi(g,s,f,u)}return i?Vg(c,u,s,l,o.value,e):c.length?Promise.all(c).then(()=>s):s}}),Jg=S("$ZodObjectJIT",(e,t)=>{Bg.init(e,t);const r=e._zod.parse,o=Xn(()=>qg(t)),n=f=>{const p=new ng(["shape","payload","ctx"]),g=o.value,h=$=>{const v=Ys($);return`shape[${v}]._zod.run({ value: input[${v}], issues: [] }, ctx)`};p.write("const input = payload.value;");const b=Object.create(null);let y=0;for(const $ of g.keys)b[$]=`key_${y++}`;p.write("const newResult = {};");for(const $ of g.keys){const v=b[$],k=Ys($);p.write(`const ${v} = ${h($)};`),p.write(`
|
|
11
11
|
if (${v}.issues.length) {
|
|
12
12
|
payload.issues = payload.issues.concat(${v}.issues.map(iss => ({
|
|
13
13
|
...iss,
|
|
@@ -24,23 +24,23 @@ Error message: ${sn(r)}`,cause:r}),this[Cm]=!0,this.value=t}static isInstance(t)
|
|
|
24
24
|
newResult[${k}] = ${v}.value;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
`)}p.write("payload.value = newResult;"),p.write("return payload;");const x=p.compile();return($,v)=>x(f,$,v)};let i;const a=Wr,s=!li.jitless,u=s&&zm.value,c=t.catchall;let d;e._zod.parse=(f,p)=>{d??(d=o.value);const g=f.value;return a(g)?s&&u&&p?.async===!1&&p.jitless!==!0?(i||(i=n(t.shape)),f=i(f,p),c?Vg([],g,f,p,d,e):f):r(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f)}});function Ud(e,t,r,o){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const n=e.filter(i=>!mr(i));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>ut(a,o,De())))}),t)}const Yi=S("$ZodUnion",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),ne(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),ne(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),ne(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${n.map(i=>Wi(i.source)).join("|")})$`)}});const r=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(n,i)=>{if(r)return o(n,i);let a=!1;const s=[];for(const l of t.options){const u=l._zod.run({value:n.value,issues:[]},i);if(u instanceof Promise)s.push(u),a=!0;else{if(u.issues.length===0)return u;s.push(u)}}return a?Promise.all(s).then(l=>Ud(l,n,e,i)):Ud(s,n,e,i)}});function Ld(e,t,r,o){const n=e.filter(i=>i.issues.length===0);return n.length===1?(t.value=n[0].value,t):(n.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>ut(a,o,De())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}const Wg=S("$ZodXor",(e,t)=>{Yi.init(e,t),t.inclusive=!1;const r=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(n,i)=>{if(r)return o(n,i);let a=!1;const s=[];for(const l of t.options){const u=l._zod.run({value:n.value,issues:[]},i);u instanceof Promise?(s.push(u),a=!0):s.push(u)}return a?Promise.all(s).then(l=>Ld(l,n,e,i)):Ld(s,n,e,i)}}),Hg=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Yi.init(e,t);const r=e._zod.parse;ne(e._zod,"propValues",()=>{const n={};for(const i of t.options){const a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[s,l]of Object.entries(a)){n[s]||(n[s]=new Set);for(const u of l)n[s].add(u)}}return n});const o=Xn(()=>{const n=t.options,i=new Map;for(const a of n){const s=a._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const l of s){if(i.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);i.set(l,a)}}return i});e._zod.parse=(n,i)=>{const a=n.value;if(!Wr(a))return n.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),n;const s=o.value.get(a?.[t.discriminator]);return s?s._zod.run(n,i):t.unionFallback?r(n,i):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),n)}}),Gg=S("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value,i=t.left._zod.run({value:n,issues:[]},o),a=t.right._zod.run({value:n,issues:[]},o);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([l,u])=>Zd(r,l,u)):Zd(r,i,a)}});function eu(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(yr(e)&&yr(t)){const r=Object.keys(t),o=Object.keys(e).filter(i=>r.indexOf(i)!==-1),n={...e,...t};for(const i of o){const a=eu(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};n[i]=a.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let o=0;o<e.length;o++){const n=e[o],i=t[o],a=eu(n,i);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Zd(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),mr(e))return e;const o=eu(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const al=S("$ZodTuple",(e,t)=>{X.init(e,t);const r=t.items;e._zod.parse=(o,n)=>{const i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];const a=[],s=[...r].reverse().findIndex(c=>c._zod.optin!=="optional"),l=s===-1?0:r.length-s;if(!t.rest){const c=i.length>r.length,d=i.length<l-1;if(c||d)return o.issues.push({...c?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},input:i,inst:e,origin:"array"}),o}let u=-1;for(const c of r){if(u++,u>=i.length&&u>=l)continue;const d=c._zod.run({value:i[u],issues:[]},n);d instanceof Promise?a.push(d.then(f=>Uo(f,o,u))):Uo(d,o,u)}if(t.rest){const c=i.slice(r.length);for(const d of c){u++;const f=t.rest._zod.run({value:d,issues:[]},n);f instanceof Promise?a.push(f.then(p=>Uo(p,o,u))):Uo(f,o,u)}}return a.length?Promise.all(a).then(()=>o):o}});function Uo(e,t,r){e.issues.length&&t.issues.push(..._t(r,e.issues)),t.value[r]=e.value}const Kg=S("$ZodRecord",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!yr(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;const i=[],a=t.keyType._zod.values;if(a){r.value={};const s=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);const c=t.valueType._zod.run({value:n[u],issues:[]},o);c instanceof Promise?i.push(c.then(d=>{d.issues.length&&r.issues.push(..._t(u,d.issues)),r.value[u]=d.value})):(c.issues.length&&r.issues.push(..._t(u,c.issues)),r.value[u]=c.value)}let l;for(const u in n)s.has(u)||(l=l??[],l.push(u));l&&l.length>0&&r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:l})}else{r.value={};for(const s of Reflect.ownKeys(n)){if(s==="__proto__")continue;const l=t.keyType._zod.run({value:s,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){t.mode==="loose"?r.value[s]=n[s]:r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(c=>ut(c,o,De())),input:s,path:[s],inst:e});continue}const u=t.valueType._zod.run({value:n[s],issues:[]},o);u instanceof Promise?i.push(u.then(c=>{c.issues.length&&r.issues.push(..._t(s,c.issues)),r.value[l.value]=c.value})):(u.issues.length&&r.issues.push(..._t(s,u.issues)),r.value[l.value]=u.value)}}return i.length?Promise.all(i).then(()=>r):r}}),Yg=S("$ZodMap",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;const i=[];r.value=new Map;for(const[a,s]of n){const l=t.keyType._zod.run({value:a,issues:[]},o),u=t.valueType._zod.run({value:s,issues:[]},o);l instanceof Promise||u instanceof Promise?i.push(Promise.all([l,u]).then(([c,d])=>{Fd(c,d,r,a,n,e,o)})):Fd(l,u,r,a,n,e,o)}return i.length?Promise.all(i).then(()=>r):r}});function Fd(e,t,r,o,n,i,a){e.issues.length&&(di.has(typeof o)?r.issues.push(..._t(o,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:n,inst:i,issues:e.issues.map(s=>ut(s,a,De()))})),t.issues.length&&(di.has(typeof o)?r.issues.push(..._t(o,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:n,inst:i,key:o,issues:t.issues.map(s=>ut(s,a,De()))})),r.value.set(e.value,t.value)}const Qg=S("$ZodSet",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;const i=[];r.value=new Set;for(const a of n){const s=t.valueType._zod.run({value:a,issues:[]},o);s instanceof Promise?i.push(s.then(l=>qd(l,r))):qd(s,r)}return i.length?Promise.all(i).then(()=>r):r}});function qd(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const Xg=S("$ZodEnum",(e,t)=>{X.init(e,t);const r=Uu(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter(n=>di.has(typeof n)).map(n=>typeof n=="string"?qt(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{const a=n.value;return o.has(a)||n.issues.push({code:"invalid_value",values:r,input:a,inst:e}),n}}),ev=S("$ZodLiteral",(e,t)=>{if(X.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?qt(o):o?qt(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,n)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),tv=S("$ZodFile",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;return n instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),rv=S("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Ji(e.constructor.name);const n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then(a=>(r.value=a,r));if(n instanceof Promise)throw new vr;return r.value=n,r}});function Vd(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const nv=S("$ZodOptional",(e,t)=>{X.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ne(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Wi(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>Vd(i,r.value)):Vd(n,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,o)}}),ov=S("$ZodNullable",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Wi(r.source)}|null)$`):void 0}),ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>r.value===null?r:t.innerType._zod.run(r,o)}),iv=S("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>Bd(i,t)):Bd(n,t)}});function Bd(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const av=S("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>(o.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,o))}),sv=S("$ZodNonOptional",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,o)=>{const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>Jd(i,e)):Jd(n,e)}});function Jd(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const uv=S("$ZodSuccess",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Ji("ZodSuccess");const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>(r.value=i.issues.length===0,r)):(r.value=n.issues.length===0,r)}}),lv=S("$ZodCatch",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>ut(a,o,De()))},input:r.value}),r.issues=[]),r)):(r.value=n.value,n.issues.length&&(r.value=t.catchValue({...r,error:{issues:n.issues.map(i=>ut(i,o,De()))},input:r.value}),r.issues=[]),r)}}),cv=S("$ZodNaN",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),dv=S("$ZodPipe",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>t.in._zod.values),ne(e._zod,"optin",()=>t.in._zod.optin),ne(e._zod,"optout",()=>t.out._zod.optout),ne(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){const i=t.out._zod.run(r,o);return i instanceof Promise?i.then(a=>Lo(a,t.in,o)):Lo(i,t.in,o)}const n=t.in._zod.run(r,o);return n instanceof Promise?n.then(i=>Lo(i,t.out,o)):Lo(n,t.out,o)}});function Lo(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const sl=S("$ZodCodec",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>t.in._zod.values),ne(e._zod,"optin",()=>t.in._zod.optin),ne(e._zod,"optout",()=>t.out._zod.optout),ne(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if((o.direction||"forward")==="forward"){const i=t.in._zod.run(r,o);return i instanceof Promise?i.then(a=>Zo(a,t,o)):Zo(i,t,o)}else{const i=t.out._zod.run(r,o);return i instanceof Promise?i.then(a=>Zo(a,t,o)):Zo(i,t,o)}}});function Zo(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){const n=t.transform(e.value,e);return n instanceof Promise?n.then(i=>Fo(e,i,t.out,r)):Fo(e,n,t.out,r)}else{const n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(i=>Fo(e,i,t.in,r)):Fo(e,n,t.in,r)}}function Fo(e,t,r,o){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},o)}const pv=S("$ZodReadonly",(e,t)=>{X.init(e,t),ne(e._zod,"propValues",()=>t.innerType._zod.propValues),ne(e._zod,"values",()=>t.innerType._zod.values),ne(e._zod,"optin",()=>t.innerType?._zod?.optin),ne(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(Wd):Wd(n)}});function Wd(e){return e.value=Object.freeze(e.value),e}const fv=S("$ZodTemplateLiteral",(e,t)=>{X.init(e,t);const r=[];for(const o of t.parts)if(typeof o=="object"&&o!==null){if(!o._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);const n=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!n)throw new Error(`Invalid template literal part: ${o._zod.traits}`);const i=n.startsWith("^")?1:0,a=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(i,a))}else if(o===null||Mm.has(typeof o))r.push(qt(`${o}`));else throw new Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(o,n)=>typeof o.value!="string"?(o.issues.push({input:o.value,inst:e,expected:"template_literal",code:"invalid_type"}),o):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(o.value)||o.issues.push({input:o.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),o)}),mv=S("$ZodFunction",(e,t)=>(X.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...o){const n=e._def.input?Qs(e._def.input,o):o,i=Reflect.apply(r,this,n);return e._def.output?Qs(e._def.output,i):i}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...o){const n=e._def.input?await Xs(e._def.input,o):o,i=await Reflect.apply(r,this,n);return e._def.output?await Xs(e._def.output,i):i}},e._zod.parse=(r,o)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{const o=e.constructor;return Array.isArray(r[0])?new o({type:"function",input:new al({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new o({type:"function",input:r[0],output:e._def.output})},e.output=r=>{const o=e.constructor;return new o({type:"function",input:e._def.input,output:r})},e)),hv=S("$ZodPromise",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>Promise.resolve(r.value).then(n=>t.innerType._zod.run({value:n,issues:[]},o))}),gv=S("$ZodLazy",(e,t)=>{X.init(e,t),ne(e._zod,"innerType",()=>t.getter()),ne(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),ne(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),ne(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),ne(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,o)=>e._zod.innerType._zod.run(r,o)}),vv=S("$ZodCustom",(e,t)=>{Se.init(e,t),X.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=r=>{const o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then(i=>Hd(i,r,o,e));Hd(n,r,o,e)}});function Hd(e,t,r,o){if(!e){const n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(n.params=o._zod.def.params),t.issues.push(Hr(n))}}const RI=()=>{const e={string:{unit:"حرف",verb:"أن يحوي"},file:{unit:"بايت",verb:"أن يحوي"},array:{unit:"عنصر",verb:"أن يحوي"},set:{unit:"عنصر",verb:"أن يحوي"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"مدخل",email:"بريد إلكتروني",url:"رابط",emoji:"إيموجي",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"تاريخ ووقت بمعيار ISO",date:"تاريخ بمعيار ISO",time:"وقت بمعيار ISO",duration:"مدة بمعيار ISO",ipv4:"عنوان IPv4",ipv6:"عنوان IPv6",cidrv4:"مدى عناوين بصيغة IPv4",cidrv6:"مدى عناوين بصيغة IPv6",base64:"نَص بترميز base64-encoded",base64url:"نَص بترميز base64url-encoded",json_string:"نَص على هيئة JSON",e164:"رقم هاتف بمعيار E.164",jwt:"JWT",template_literal:"مدخل"};return n=>{switch(n.code){case"invalid_type":return`مدخلات غير مقبولة: يفترض إدخال ${n.expected}، ولكن تم إدخال ${r(n.input)}`;case"invalid_value":return n.values.length===1?`مدخلات غير مقبولة: يفترض إدخال ${H(n.values[0])}`:`اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?` أكبر من اللازم: يفترض أن تكون ${n.origin??"القيمة"} ${i} ${n.maximum.toString()} ${a.unit??"عنصر"}`:`أكبر من اللازم: يفترض أن تكون ${n.origin??"القيمة"} ${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`أصغر من اللازم: يفترض لـ ${n.origin} أن يكون ${i} ${n.minimum.toString()} ${a.unit}`:`أصغر من اللازم: يفترض لـ ${n.origin} أن يكون ${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`نَص غير مقبول: يجب أن يبدأ بـ "${n.prefix}"`:i.format==="ends_with"?`نَص غير مقبول: يجب أن ينتهي بـ "${i.suffix}"`:i.format==="includes"?`نَص غير مقبول: يجب أن يتضمَّن "${i.includes}"`:i.format==="regex"?`نَص غير مقبول: يجب أن يطابق النمط ${i.pattern}`:`${o[i.format]??n.format} غير مقبول`}case"not_multiple_of":return`رقم غير مقبول: يجب أن يكون من مضاعفات ${n.divisor}`;case"unrecognized_keys":return`معرف${n.keys.length>1?"ات":""} غريب${n.keys.length>1?"ة":""}: ${j(n.keys,"، ")}`;case"invalid_key":return`معرف غير مقبول في ${n.origin}`;case"invalid_union":return"مدخل غير مقبول";case"invalid_element":return`مدخل غير مقبول في ${n.origin}`;default:return"مدخل غير مقبول"}}};function zI(){return{localeError:RI()}}const MI=()=>{const e={string:{unit:"simvol",verb:"olmalıdır"},file:{unit:"bayt",verb:"olmalıdır"},array:{unit:"element",verb:"olmalıdır"},set:{unit:"element",verb:"olmalıdır"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Yanlış dəyər: gözlənilən ${n.expected}, daxil olan ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Yanlış dəyər: gözlənilən ${H(n.values[0])}`:`Yanlış seçim: aşağıdakılardan biri olmalıdır: ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Çox böyük: gözlənilən ${n.origin??"dəyər"} ${i}${n.maximum.toString()} ${a.unit??"element"}`:`Çox böyük: gözlənilən ${n.origin??"dəyər"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Çox kiçik: gözlənilən ${n.origin} ${i}${n.minimum.toString()} ${a.unit}`:`Çox kiçik: gözlənilən ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Yanlış mətn: "${i.prefix}" ilə başlamalıdır`:i.format==="ends_with"?`Yanlış mətn: "${i.suffix}" ilə bitməlidir`:i.format==="includes"?`Yanlış mətn: "${i.includes}" daxil olmalıdır`:i.format==="regex"?`Yanlış mətn: ${i.pattern} şablonuna uyğun olmalıdır`:`Yanlış ${o[i.format]??n.format}`}case"not_multiple_of":return`Yanlış ədəd: ${n.divisor} ilə bölünə bilən olmalıdır`;case"unrecognized_keys":return`Tanınmayan açar${n.keys.length>1?"lar":""}: ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} daxilində yanlış açar`;case"invalid_union":return"Yanlış dəyər";case"invalid_element":return`${n.origin} daxilində yanlış dəyər`;default:return"Yanlış dəyər"}}};function DI(){return{localeError:MI()}}function Gd(e,t,r,o){const n=Math.abs(e),i=n%10,a=n%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?r:o}const UI=()=>{const e={string:{unit:{one:"сімвал",few:"сімвалы",many:"сімвалаў"},verb:"мець"},array:{unit:{one:"элемент",few:"элементы",many:"элементаў"},verb:"мець"},set:{unit:{one:"элемент",few:"элементы",many:"элементаў"},verb:"мець"},file:{unit:{one:"байт",few:"байты",many:"байтаў"},verb:"мець"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"лік";case"object":{if(Array.isArray(n))return"масіў";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"увод",email:"email адрас",url:"URL",emoji:"эмодзі",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO дата і час",date:"ISO дата",time:"ISO час",duration:"ISO працягласць",ipv4:"IPv4 адрас",ipv6:"IPv6 адрас",cidrv4:"IPv4 дыяпазон",cidrv6:"IPv6 дыяпазон",base64:"радок у фармаце base64",base64url:"радок у фармаце base64url",json_string:"JSON радок",e164:"нумар E.164",jwt:"JWT",template_literal:"увод"};return n=>{switch(n.code){case"invalid_type":return`Няправільны ўвод: чакаўся ${n.expected}, атрымана ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Няправільны ўвод: чакалася ${H(n.values[0])}`:`Няправільны варыянт: чакаўся адзін з ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);if(a){const s=Number(n.maximum),l=Gd(s,a.unit.one,a.unit.few,a.unit.many);return`Занадта вялікі: чакалася, што ${n.origin??"значэнне"} павінна ${a.verb} ${i}${n.maximum.toString()} ${l}`}return`Занадта вялікі: чакалася, што ${n.origin??"значэнне"} павінна быць ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);if(a){const s=Number(n.minimum),l=Gd(s,a.unit.one,a.unit.few,a.unit.many);return`Занадта малы: чакалася, што ${n.origin} павінна ${a.verb} ${i}${n.minimum.toString()} ${l}`}return`Занадта малы: чакалася, што ${n.origin} павінна быць ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Няправільны радок: павінен пачынацца з "${i.prefix}"`:i.format==="ends_with"?`Няправільны радок: павінен заканчвацца на "${i.suffix}"`:i.format==="includes"?`Няправільны радок: павінен змяшчаць "${i.includes}"`:i.format==="regex"?`Няправільны радок: павінен адпавядаць шаблону ${i.pattern}`:`Няправільны ${o[i.format]??n.format}`}case"not_multiple_of":return`Няправільны лік: павінен быць кратным ${n.divisor}`;case"unrecognized_keys":return`Нераспазнаны ${n.keys.length>1?"ключы":"ключ"}: ${j(n.keys,", ")}`;case"invalid_key":return`Няправільны ключ у ${n.origin}`;case"invalid_union":return"Няправільны ўвод";case"invalid_element":return`Няправільнае значэнне ў ${n.origin}`;default:return"Няправільны ўвод"}}};function LI(){return{localeError:UI()}}const ZI=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"число";case"object":{if(Array.isArray(e))return"масив";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},FI=()=>{const e={string:{unit:"символа",verb:"да съдържа"},file:{unit:"байта",verb:"да съдържа"},array:{unit:"елемента",verb:"да съдържа"},set:{unit:"елемента",verb:"да съдържа"}};function t(o){return e[o]??null}const r={regex:"вход",email:"имейл адрес",url:"URL",emoji:"емоджи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO време",date:"ISO дата",time:"ISO време",duration:"ISO продължителност",ipv4:"IPv4 адрес",ipv6:"IPv6 адрес",cidrv4:"IPv4 диапазон",cidrv6:"IPv6 диапазон",base64:"base64-кодиран низ",base64url:"base64url-кодиран низ",json_string:"JSON низ",e164:"E.164 номер",jwt:"JWT",template_literal:"вход"};return o=>{switch(o.code){case"invalid_type":return`Невалиден вход: очакван ${o.expected}, получен ${ZI(o.input)}`;case"invalid_value":return o.values.length===1?`Невалиден вход: очакван ${H(o.values[0])}`:`Невалидна опция: очаквано едно от ${j(o.values,"|")}`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Твърде голямо: очаква се ${o.origin??"стойност"} да съдържа ${n}${o.maximum.toString()} ${i.unit??"елемента"}`:`Твърде голямо: очаква се ${o.origin??"стойност"} да бъде ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Твърде малко: очаква се ${o.origin} да съдържа ${n}${o.minimum.toString()} ${i.unit}`:`Твърде малко: очаква се ${o.origin} да бъде ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;if(n.format==="starts_with")return`Невалиден низ: трябва да започва с "${n.prefix}"`;if(n.format==="ends_with")return`Невалиден низ: трябва да завършва с "${n.suffix}"`;if(n.format==="includes")return`Невалиден низ: трябва да включва "${n.includes}"`;if(n.format==="regex")return`Невалиден низ: трябва да съвпада с ${n.pattern}`;let i="Невалиден";return n.format==="emoji"&&(i="Невалидно"),n.format==="datetime"&&(i="Невалидно"),n.format==="date"&&(i="Невалидна"),n.format==="time"&&(i="Невалидно"),n.format==="duration"&&(i="Невалидна"),`${i} ${r[n.format]??o.format}`}case"not_multiple_of":return`Невалидно число: трябва да бъде кратно на ${o.divisor}`;case"unrecognized_keys":return`Неразпознат${o.keys.length>1?"и":""} ключ${o.keys.length>1?"ове":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Невалиден ключ в ${o.origin}`;case"invalid_union":return"Невалиден вход";case"invalid_element":return`Невалидна стойност в ${o.origin}`;default:return"Невалиден вход"}}};function qI(){return{localeError:FI()}}const VI=()=>{const e={string:{unit:"caràcters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"entrada",email:"adreça electrònica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adreça IPv4",ipv6:"adreça IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return n=>{switch(n.code){case"invalid_type":return`Tipus invàlid: s'esperava ${n.expected}, s'ha rebut ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Valor invàlid: s'esperava ${H(n.values[0])}`:`Opció invàlida: s'esperava una de ${j(n.values," o ")}`;case"too_big":{const i=n.inclusive?"com a màxim":"menys de",a=t(n.origin);return a?`Massa gran: s'esperava que ${n.origin??"el valor"} contingués ${i} ${n.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${n.origin??"el valor"} fos ${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?"com a mínim":"més de",a=t(n.origin);return a?`Massa petit: s'esperava que ${n.origin} contingués ${i} ${n.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${n.origin} fos ${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Format invàlid: ha de començar amb "${i.prefix}"`:i.format==="ends_with"?`Format invàlid: ha d'acabar amb "${i.suffix}"`:i.format==="includes"?`Format invàlid: ha d'incloure "${i.includes}"`:i.format==="regex"?`Format invàlid: ha de coincidir amb el patró ${i.pattern}`:`Format invàlid per a ${o[i.format]??n.format}`}case"not_multiple_of":return`Número invàlid: ha de ser múltiple de ${n.divisor}`;case"unrecognized_keys":return`Clau${n.keys.length>1?"s":""} no reconeguda${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Clau invàlida a ${n.origin}`;case"invalid_union":return"Entrada invàlida";case"invalid_element":return`Element invàlid a ${n.origin}`;default:return"Entrada invàlida"}}};function BI(){return{localeError:VI()}}const JI=()=>{const e={string:{unit:"znaků",verb:"mít"},file:{unit:"bajtů",verb:"mít"},array:{unit:"prvků",verb:"mít"},set:{unit:"prvků",verb:"mít"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"číslo";case"string":return"řetězec";case"boolean":return"boolean";case"bigint":return"bigint";case"function":return"funkce";case"symbol":return"symbol";case"undefined":return"undefined";case"object":{if(Array.isArray(n))return"pole";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"regulární výraz",email:"e-mailová adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a čas ve formátu ISO",date:"datum ve formátu ISO",time:"čas ve formátu ISO",duration:"doba trvání ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"řetězec zakódovaný ve formátu base64",base64url:"řetězec zakódovaný ve formátu base64url",json_string:"řetězec ve formátu JSON",e164:"číslo E.164",jwt:"JWT",template_literal:"vstup"};return n=>{switch(n.code){case"invalid_type":return`Neplatný vstup: očekáváno ${n.expected}, obdrženo ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Neplatný vstup: očekáváno ${H(n.values[0])}`:`Neplatná možnost: očekávána jedna z hodnot ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Hodnota je příliš velká: ${n.origin??"hodnota"} musí mít ${i}${n.maximum.toString()} ${a.unit??"prvků"}`:`Hodnota je příliš velká: ${n.origin??"hodnota"} musí být ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Hodnota je příliš malá: ${n.origin??"hodnota"} musí mít ${i}${n.minimum.toString()} ${a.unit??"prvků"}`:`Hodnota je příliš malá: ${n.origin??"hodnota"} musí být ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Neplatný řetězec: musí začínat na "${i.prefix}"`:i.format==="ends_with"?`Neplatný řetězec: musí končit na "${i.suffix}"`:i.format==="includes"?`Neplatný řetězec: musí obsahovat "${i.includes}"`:i.format==="regex"?`Neplatný řetězec: musí odpovídat vzoru ${i.pattern}`:`Neplatný formát ${o[i.format]??n.format}`}case"not_multiple_of":return`Neplatné číslo: musí být násobkem ${n.divisor}`;case"unrecognized_keys":return`Neznámé klíče: ${j(n.keys,", ")}`;case"invalid_key":return`Neplatný klíč v ${n.origin}`;case"invalid_union":return"Neplatný vstup";case"invalid_element":return`Neplatná hodnota v ${n.origin}`;default:return"Neplatný vstup"}}};function WI(){return{localeError:JI()}}const HI=()=>{const e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}},t={string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"sæt",file:"fil"};function r(a){return e[a]??null}function o(a){return t[a]??a}const n=a=>{const s=typeof a;switch(s){case"number":return Number.isNaN(a)?"NaN":"tal";case"object":return Array.isArray(a)?"liste":a===null?"null":Object.getPrototypeOf(a)!==Object.prototype&&a.constructor?a.constructor.name:"objekt"}return s},i={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslæt",date:"ISO-dato",time:"ISO-klokkeslæt",duration:"ISO-varighed",ipv4:"IPv4-område",ipv6:"IPv6-område",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"};return a=>{switch(a.code){case"invalid_type":return`Ugyldigt input: forventede ${o(a.expected)}, fik ${o(n(a.input))}`;case"invalid_value":return a.values.length===1?`Ugyldig værdi: forventede ${H(a.values[0])}`:`Ugyldigt valg: forventede en af følgende ${j(a.values,"|")}`;case"too_big":{const s=a.inclusive?"<=":"<",l=r(a.origin),u=o(a.origin);return l?`For stor: forventede ${u??"value"} ${l.verb} ${s} ${a.maximum.toString()} ${l.unit??"elementer"}`:`For stor: forventede ${u??"value"} havde ${s} ${a.maximum.toString()}`}case"too_small":{const s=a.inclusive?">=":">",l=r(a.origin),u=o(a.origin);return l?`For lille: forventede ${u} ${l.verb} ${s} ${a.minimum.toString()} ${l.unit}`:`For lille: forventede ${u} havde ${s} ${a.minimum.toString()}`}case"invalid_format":{const s=a;return s.format==="starts_with"?`Ugyldig streng: skal starte med "${s.prefix}"`:s.format==="ends_with"?`Ugyldig streng: skal ende med "${s.suffix}"`:s.format==="includes"?`Ugyldig streng: skal indeholde "${s.includes}"`:s.format==="regex"?`Ugyldig streng: skal matche mønsteret ${s.pattern}`:`Ugyldig ${i[s.format]??a.format}`}case"not_multiple_of":return`Ugyldigt tal: skal være deleligt med ${a.divisor}`;case"unrecognized_keys":return`${a.keys.length>1?"Ukendte nøgler":"Ukendt nøgle"}: ${j(a.keys,", ")}`;case"invalid_key":return`Ugyldig nøgle i ${a.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig værdi i ${a.origin}`;default:return"Ugyldigt input"}}};function GI(){return{localeError:HI()}}const KI=()=>{const e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"Zahl";case"object":{if(Array.isArray(n))return"Array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"};return n=>{switch(n.code){case"invalid_type":return`Ungültige Eingabe: erwartet ${n.expected}, erhalten ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ungültige Eingabe: erwartet ${H(n.values[0])}`:`Ungültige Option: erwartet eine von ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Zu groß: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu groß: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ist`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ist`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Ungültiger String: muss mit "${i.prefix}" beginnen`:i.format==="ends_with"?`Ungültiger String: muss mit "${i.suffix}" enden`:i.format==="includes"?`Ungültiger String: muss "${i.includes}" enthalten`:i.format==="regex"?`Ungültiger String: muss dem Muster ${i.pattern} entsprechen`:`Ungültig: ${o[i.format]??n.format}`}case"not_multiple_of":return`Ungültige Zahl: muss ein Vielfaches von ${n.divisor} sein`;case"unrecognized_keys":return`${n.keys.length>1?"Unbekannte Schlüssel":"Unbekannter Schlüssel"}: ${j(n.keys,", ")}`;case"invalid_key":return`Ungültiger Schlüssel in ${n.origin}`;case"invalid_union":return"Ungültige Eingabe";case"invalid_element":return`Ungültiger Wert in ${n.origin}`;default:return"Ungültige Eingabe"}}};function YI(){return{localeError:KI()}}const QI=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},XI=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(o){return e[o]??null}const r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return o=>{switch(o.code){case"invalid_type":return`Invalid input: expected ${o.expected}, received ${QI(o.input)}`;case"invalid_value":return o.values.length===1?`Invalid input: expected ${H(o.values[0])}`:`Invalid option: expected one of ${j(o.values,"|")}`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${n}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Too small: expected ${o.origin} to have ${n}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Invalid string: must start with "${n.prefix}"`:n.format==="ends_with"?`Invalid string: must end with "${n.suffix}"`:n.format==="includes"?`Invalid string: must include "${n.includes}"`:n.format==="regex"?`Invalid string: must match pattern ${n.pattern}`:`Invalid ${r[n.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function yv(){return{localeError:XI()}}const ek=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"nombro";case"object":{if(Array.isArray(e))return"tabelo";if(e===null)return"senvalora";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},tk=()=>{const e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(o){return e[o]??null}const r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emoĝio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-daŭro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"};return o=>{switch(o.code){case"invalid_type":return`Nevalida enigo: atendiĝis ${o.expected}, riceviĝis ${ek(o.input)}`;case"invalid_value":return o.values.length===1?`Nevalida enigo: atendiĝis ${H(o.values[0])}`:`Nevalida opcio: atendiĝis unu el ${j(o.values,"|")}`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Tro granda: atendiĝis ke ${o.origin??"valoro"} havu ${n}${o.maximum.toString()} ${i.unit??"elementojn"}`:`Tro granda: atendiĝis ke ${o.origin??"valoro"} havu ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Tro malgranda: atendiĝis ke ${o.origin} havu ${n}${o.minimum.toString()} ${i.unit}`:`Tro malgranda: atendiĝis ke ${o.origin} estu ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Nevalida karaktraro: devas komenciĝi per "${n.prefix}"`:n.format==="ends_with"?`Nevalida karaktraro: devas finiĝi per "${n.suffix}"`:n.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${n.includes}"`:n.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${n.pattern}`:`Nevalida ${r[n.format]??o.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${o.divisor}`;case"unrecognized_keys":return`Nekonata${o.keys.length>1?"j":""} ŝlosilo${o.keys.length>1?"j":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Nevalida ŝlosilo en ${o.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${o.origin}`;default:return"Nevalida enigo"}}};function rk(){return{localeError:tk()}}const nk=()=>{const e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}},t={string:"texto",number:"número",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"número grande",symbol:"símbolo",undefined:"indefinido",null:"nulo",function:"función",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeración",union:"unión",literal:"literal",promise:"promesa",void:"vacío",never:"nunca",unknown:"desconocido",any:"cualquiera"};function r(a){return e[a]??null}function o(a){return t[a]??a}const n=a=>{const s=typeof a;switch(s){case"number":return Number.isNaN(a)?"NaN":"number";case"object":return Array.isArray(a)?"array":a===null?"null":Object.getPrototypeOf(a)!==Object.prototype?a.constructor.name:"object"}return s},i={regex:"entrada",email:"dirección de correo electrónico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duración ISO",ipv4:"dirección IPv4",ipv6:"dirección IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return a=>{switch(a.code){case"invalid_type":return`Entrada inválida: se esperaba ${o(a.expected)}, recibido ${o(n(a.input))}`;case"invalid_value":return a.values.length===1?`Entrada inválida: se esperaba ${H(a.values[0])}`:`Opción inválida: se esperaba una de ${j(a.values,"|")}`;case"too_big":{const s=a.inclusive?"<=":"<",l=r(a.origin),u=o(a.origin);return l?`Demasiado grande: se esperaba que ${u??"valor"} tuviera ${s}${a.maximum.toString()} ${l.unit??"elementos"}`:`Demasiado grande: se esperaba que ${u??"valor"} fuera ${s}${a.maximum.toString()}`}case"too_small":{const s=a.inclusive?">=":">",l=r(a.origin),u=o(a.origin);return l?`Demasiado pequeño: se esperaba que ${u} tuviera ${s}${a.minimum.toString()} ${l.unit}`:`Demasiado pequeño: se esperaba que ${u} fuera ${s}${a.minimum.toString()}`}case"invalid_format":{const s=a;return s.format==="starts_with"?`Cadena inválida: debe comenzar con "${s.prefix}"`:s.format==="ends_with"?`Cadena inválida: debe terminar en "${s.suffix}"`:s.format==="includes"?`Cadena inválida: debe incluir "${s.includes}"`:s.format==="regex"?`Cadena inválida: debe coincidir con el patrón ${s.pattern}`:`Inválido ${i[s.format]??a.format}`}case"not_multiple_of":return`Número inválido: debe ser múltiplo de ${a.divisor}`;case"unrecognized_keys":return`Llave${a.keys.length>1?"s":""} desconocida${a.keys.length>1?"s":""}: ${j(a.keys,", ")}`;case"invalid_key":return`Llave inválida en ${o(a.origin)}`;case"invalid_union":return"Entrada inválida";case"invalid_element":return`Valor inválido en ${o(a.origin)}`;default:return"Entrada inválida"}}};function ok(){return{localeError:nk()}}const ik=()=>{const e={string:{unit:"کاراکتر",verb:"داشته باشد"},file:{unit:"بایت",verb:"داشته باشد"},array:{unit:"آیتم",verb:"داشته باشد"},set:{unit:"آیتم",verb:"داشته باشد"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"عدد";case"object":{if(Array.isArray(n))return"آرایه";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ورودی",email:"آدرس ایمیل",url:"URL",emoji:"ایموجی",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"تاریخ و زمان ایزو",date:"تاریخ ایزو",time:"زمان ایزو",duration:"مدت زمان ایزو",ipv4:"IPv4 آدرس",ipv6:"IPv6 آدرس",cidrv4:"IPv4 دامنه",cidrv6:"IPv6 دامنه",base64:"base64-encoded رشته",base64url:"base64url-encoded رشته",json_string:"JSON رشته",e164:"E.164 عدد",jwt:"JWT",template_literal:"ورودی"};return n=>{switch(n.code){case"invalid_type":return`ورودی نامعتبر: میبایست ${n.expected} میبود، ${r(n.input)} دریافت شد`;case"invalid_value":return n.values.length===1?`ورودی نامعتبر: میبایست ${H(n.values[0])} میبود`:`گزینه نامعتبر: میبایست یکی از ${j(n.values,"|")} میبود`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`خیلی بزرگ: ${n.origin??"مقدار"} باید ${i}${n.maximum.toString()} ${a.unit??"عنصر"} باشد`:`خیلی بزرگ: ${n.origin??"مقدار"} باید ${i}${n.maximum.toString()} باشد`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`خیلی کوچک: ${n.origin} باید ${i}${n.minimum.toString()} ${a.unit} باشد`:`خیلی کوچک: ${n.origin} باید ${i}${n.minimum.toString()} باشد`}case"invalid_format":{const i=n;return i.format==="starts_with"?`رشته نامعتبر: باید با "${i.prefix}" شروع شود`:i.format==="ends_with"?`رشته نامعتبر: باید با "${i.suffix}" تمام شود`:i.format==="includes"?`رشته نامعتبر: باید شامل "${i.includes}" باشد`:i.format==="regex"?`رشته نامعتبر: باید با الگوی ${i.pattern} مطابقت داشته باشد`:`${o[i.format]??n.format} نامعتبر`}case"not_multiple_of":return`عدد نامعتبر: باید مضرب ${n.divisor} باشد`;case"unrecognized_keys":return`کلید${n.keys.length>1?"های":""} ناشناس: ${j(n.keys,", ")}`;case"invalid_key":return`کلید ناشناس در ${n.origin}`;case"invalid_union":return"ورودی نامعتبر";case"invalid_element":return`مقدار نامعتبر در ${n.origin}`;default:return"ورودی نامعتبر"}}};function ak(){return{localeError:ik()}}const sk=()=>{const e={string:{unit:"merkkiä",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"päivämäärän"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"säännöllinen lauseke",email:"sähköpostiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-päivämäärä",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"};return n=>{switch(n.code){case"invalid_type":return`Virheellinen tyyppi: odotettiin ${n.expected}, oli ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Virheellinen syöte: täytyy olla ${H(n.values[0])}`:`Virheellinen valinta: täytyy olla yksi seuraavista: ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Liian suuri: ${a.subject} täytyy olla ${i}${n.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon täytyy olla ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Liian pieni: ${a.subject} täytyy olla ${i}${n.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon täytyy olla ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Virheellinen syöte: täytyy alkaa "${i.prefix}"`:i.format==="ends_with"?`Virheellinen syöte: täytyy loppua "${i.suffix}"`:i.format==="includes"?`Virheellinen syöte: täytyy sisältää "${i.includes}"`:i.format==="regex"?`Virheellinen syöte: täytyy vastata säännöllistä lauseketta ${i.pattern}`:`Virheellinen ${o[i.format]??n.format}`}case"not_multiple_of":return`Virheellinen luku: täytyy olla luvun ${n.divisor} monikerta`;case"unrecognized_keys":return`${n.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${j(n.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen syöte"}}};function uk(){return{localeError:sk()}}const lk=()=>{const e={string:{unit:"caractères",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"éléments",verb:"avoir"},set:{unit:"éléments",verb:"avoir"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"nombre";case"object":{if(Array.isArray(n))return"tableau";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"entrée",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"durée ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"chaîne encodée en base64",base64url:"chaîne encodée en base64url",json_string:"chaîne JSON",e164:"numéro E.164",jwt:"JWT",template_literal:"entrée"};return n=>{switch(n.code){case"invalid_type":return`Entrée invalide : ${n.expected} attendu, ${r(n.input)} reçu`;case"invalid_value":return n.values.length===1?`Entrée invalide : ${H(n.values[0])} attendu`:`Option invalide : une valeur parmi ${j(n.values,"|")} attendue`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Trop grand : ${n.origin??"valeur"} doit ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"élément(s)"}`:`Trop grand : ${n.origin??"valeur"} doit être ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Trop petit : ${n.origin} doit ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Trop petit : ${n.origin} doit être ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Chaîne invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Chaîne invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Chaîne invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Chaîne invalide : doit correspondre au modèle ${i.pattern}`:`${o[i.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${n.divisor}`;case"unrecognized_keys":return`Clé${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${j(n.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${n.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entrée invalide"}}};function ck(){return{localeError:lk()}}const dk=()=>{const e={string:{unit:"caractères",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"éléments",verb:"avoir"},set:{unit:"éléments",verb:"avoir"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"entrée",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"durée ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"chaîne encodée en base64",base64url:"chaîne encodée en base64url",json_string:"chaîne JSON",e164:"numéro E.164",jwt:"JWT",template_literal:"entrée"};return n=>{switch(n.code){case"invalid_type":return`Entrée invalide : attendu ${n.expected}, reçu ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Entrée invalide : attendu ${H(n.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"≤":"<",a=t(n.origin);return a?`Trop grand : attendu que ${n.origin??"la valeur"} ait ${i}${n.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${n.origin??"la valeur"} soit ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?"≥":">",a=t(n.origin);return a?`Trop petit : attendu que ${n.origin} ait ${i}${n.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${n.origin} soit ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Chaîne invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Chaîne invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Chaîne invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Chaîne invalide : doit correspondre au motif ${i.pattern}`:`${o[i.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${n.divisor}`;case"unrecognized_keys":return`Clé${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${j(n.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${n.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entrée invalide"}}};function pk(){return{localeError:dk()}}const fk=()=>{const e={string:{label:"מחרוזת",gender:"f"},number:{label:"מספר",gender:"m"},boolean:{label:"ערך בוליאני",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"תאריך",gender:"m"},array:{label:"מערך",gender:"m"},object:{label:"אובייקט",gender:"m"},null:{label:"ערך ריק (null)",gender:"m"},undefined:{label:"ערך לא מוגדר (undefined)",gender:"m"},symbol:{label:"סימבול (Symbol)",gender:"m"},function:{label:"פונקציה",gender:"f"},map:{label:"מפה (Map)",gender:"f"},set:{label:"קבוצה (Set)",gender:"f"},file:{label:"קובץ",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"ערך לא ידוע",gender:"m"},value:{label:"ערך",gender:"m"}},t={string:{unit:"תווים",shortLabel:"קצר",longLabel:"ארוך"},file:{unit:"בייטים",shortLabel:"קטן",longLabel:"גדול"},array:{unit:"פריטים",shortLabel:"קטן",longLabel:"גדול"},set:{unit:"פריטים",shortLabel:"קטן",longLabel:"גדול"},number:{unit:"",shortLabel:"קטן",longLabel:"גדול"}},r=u=>u?e[u]:void 0,o=u=>{const c=r(u);return c?c.label:u??e.unknown.label},n=u=>`ה${o(u)}`,i=u=>(r(u)?.gender??"m")==="f"?"צריכה להיות":"צריך להיות",a=u=>u?t[u]??null:null,s=u=>{const c=typeof u;switch(c){case"number":return Number.isNaN(u)?"NaN":"number";case"object":return Array.isArray(u)?"array":u===null?"null":Object.getPrototypeOf(u)!==Object.prototype&&u.constructor?u.constructor.name:"object";default:return c}},l={regex:{label:"קלט",gender:"m"},email:{label:"כתובת אימייל",gender:"f"},url:{label:"כתובת רשת",gender:"f"},emoji:{label:"אימוג'י",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"תאריך וזמן ISO",gender:"m"},date:{label:"תאריך ISO",gender:"m"},time:{label:"זמן ISO",gender:"m"},duration:{label:"משך זמן ISO",gender:"m"},ipv4:{label:"כתובת IPv4",gender:"f"},ipv6:{label:"כתובת IPv6",gender:"f"},cidrv4:{label:"טווח IPv4",gender:"m"},cidrv6:{label:"טווח IPv6",gender:"m"},base64:{label:"מחרוזת בבסיס 64",gender:"f"},base64url:{label:"מחרוזת בבסיס 64 לכתובות רשת",gender:"f"},json_string:{label:"מחרוזת JSON",gender:"f"},e164:{label:"מספר E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"קלט",gender:"m"},includes:{label:"קלט",gender:"m"},lowercase:{label:"קלט",gender:"m"},starts_with:{label:"קלט",gender:"m"},uppercase:{label:"קלט",gender:"m"}};return u=>{switch(u.code){case"invalid_type":{const c=u.expected,d=o(c),f=s(u.input),p=e[f]?.label??f;return`קלט לא תקין: צריך להיות ${d}, התקבל ${p}`}case"invalid_value":{if(u.values.length===1)return`ערך לא תקין: הערך חייב להיות ${H(u.values[0])}`;const c=u.values.map(p=>H(p));if(u.values.length===2)return`ערך לא תקין: האפשרויות המתאימות הן ${c[0]} או ${c[1]}`;const d=c[c.length-1];return`ערך לא תקין: האפשרויות המתאימות הן ${c.slice(0,-1).join(", ")} או ${d}`}case"too_big":{const c=a(u.origin),d=n(u.origin??"value");if(u.origin==="string")return`${c?.longLabel??"ארוך"} מדי: ${d} צריכה להכיל ${u.maximum.toString()} ${c?.unit??""} ${u.inclusive?"או פחות":"לכל היותר"}`.trim();if(u.origin==="number"){const g=u.inclusive?`קטן או שווה ל-${u.maximum}`:`קטן מ-${u.maximum}`;return`גדול מדי: ${d} צריך להיות ${g}`}if(u.origin==="array"||u.origin==="set"){const g=u.origin==="set"?"צריכה":"צריך",h=u.inclusive?`${u.maximum} ${c?.unit??""} או פחות`:`פחות מ-${u.maximum} ${c?.unit??""}`;return`גדול מדי: ${d} ${g} להכיל ${h}`.trim()}const f=u.inclusive?"<=":"<",p=i(u.origin??"value");return c?.unit?`${c.longLabel} מדי: ${d} ${p} ${f}${u.maximum.toString()} ${c.unit}`:`${c?.longLabel??"גדול"} מדי: ${d} ${p} ${f}${u.maximum.toString()}`}case"too_small":{const c=a(u.origin),d=n(u.origin??"value");if(u.origin==="string")return`${c?.shortLabel??"קצר"} מדי: ${d} צריכה להכיל ${u.minimum.toString()} ${c?.unit??""} ${u.inclusive?"או יותר":"לפחות"}`.trim();if(u.origin==="number"){const g=u.inclusive?`גדול או שווה ל-${u.minimum}`:`גדול מ-${u.minimum}`;return`קטן מדי: ${d} צריך להיות ${g}`}if(u.origin==="array"||u.origin==="set"){const g=u.origin==="set"?"צריכה":"צריך";if(u.minimum===1&&u.inclusive){const b=(u.origin==="set","לפחות פריט אחד");return`קטן מדי: ${d} ${g} להכיל ${b}`}const h=u.inclusive?`${u.minimum} ${c?.unit??""} או יותר`:`יותר מ-${u.minimum} ${c?.unit??""}`;return`קטן מדי: ${d} ${g} להכיל ${h}`.trim()}const f=u.inclusive?">=":">",p=i(u.origin??"value");return c?.unit?`${c.shortLabel} מדי: ${d} ${p} ${f}${u.minimum.toString()} ${c.unit}`:`${c?.shortLabel??"קטן"} מדי: ${d} ${p} ${f}${u.minimum.toString()}`}case"invalid_format":{const c=u;if(c.format==="starts_with")return`המחרוזת חייבת להתחיל ב "${c.prefix}"`;if(c.format==="ends_with")return`המחרוזת חייבת להסתיים ב "${c.suffix}"`;if(c.format==="includes")return`המחרוזת חייבת לכלול "${c.includes}"`;if(c.format==="regex")return`המחרוזת חייבת להתאים לתבנית ${c.pattern}`;const d=l[c.format],f=d?.label??c.format,g=(d?.gender??"m")==="f"?"תקינה":"תקין";return`${f} לא ${g}`}case"not_multiple_of":return`מספר לא תקין: חייב להיות מכפלה של ${u.divisor}`;case"unrecognized_keys":return`מפתח${u.keys.length>1?"ות":""} לא מזוה${u.keys.length>1?"ים":"ה"}: ${j(u.keys,", ")}`;case"invalid_key":return"שדה לא תקין באובייקט";case"invalid_union":return"קלט לא תקין";case"invalid_element":return`ערך לא תקין ב${n(u.origin??"array")}`;default:return"קלט לא תקין"}}};function mk(){return{localeError:fk()}}const hk=()=>{const e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"szám";case"object":{if(Array.isArray(n))return"tömb";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"bemenet",email:"email cím",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO időbélyeg",date:"ISO dátum",time:"ISO idő",duration:"ISO időintervallum",ipv4:"IPv4 cím",ipv6:"IPv6 cím",cidrv4:"IPv4 tartomány",cidrv6:"IPv6 tartomány",base64:"base64-kódolt string",base64url:"base64url-kódolt string",json_string:"JSON string",e164:"E.164 szám",jwt:"JWT",template_literal:"bemenet"};return n=>{switch(n.code){case"invalid_type":return`Érvénytelen bemenet: a várt érték ${n.expected}, a kapott érték ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Érvénytelen bemenet: a várt érték ${H(n.values[0])}`:`Érvénytelen opció: valamelyik érték várt ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Túl nagy: ${n.origin??"érték"} mérete túl nagy ${i}${n.maximum.toString()} ${a.unit??"elem"}`:`Túl nagy: a bemeneti érték ${n.origin??"érték"} túl nagy: ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Túl kicsi: a bemeneti érték ${n.origin} mérete túl kicsi ${i}${n.minimum.toString()} ${a.unit}`:`Túl kicsi: a bemeneti érték ${n.origin} túl kicsi ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Érvénytelen string: "${i.prefix}" értékkel kell kezdődnie`:i.format==="ends_with"?`Érvénytelen string: "${i.suffix}" értékkel kell végződnie`:i.format==="includes"?`Érvénytelen string: "${i.includes}" értéket kell tartalmaznia`:i.format==="regex"?`Érvénytelen string: ${i.pattern} mintának kell megfelelnie`:`Érvénytelen ${o[i.format]??n.format}`}case"not_multiple_of":return`Érvénytelen szám: ${n.divisor} többszörösének kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Érvénytelen kulcs ${n.origin}`;case"invalid_union":return"Érvénytelen bemenet";case"invalid_element":return`Érvénytelen érték: ${n.origin}`;default:return"Érvénytelen bemenet"}}};function gk(){return{localeError:hk()}}const vk=()=>{const e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Input tidak valid: diharapkan ${n.expected}, diterima ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Input tidak valid: diharapkan ${H(n.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Terlalu besar: diharapkan ${n.origin??"value"} memiliki ${i}${n.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${n.origin??"value"} menjadi ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Terlalu kecil: diharapkan ${n.origin} memiliki ${i}${n.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${n.origin} menjadi ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`String tidak valid: harus dimulai dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak valid: harus berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak valid: harus menyertakan "${i.includes}"`:i.format==="regex"?`String tidak valid: harus sesuai pola ${i.pattern}`:`${o[i.format]??n.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${n.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${n.origin}`;default:return"Input tidak valid"}}};function yk(){return{localeError:vk()}}const bk=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"númer";case"object":{if(Array.isArray(e))return"fylki";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},_k=()=>{const e={string:{unit:"stafi",verb:"að hafa"},file:{unit:"bæti",verb:"að hafa"},array:{unit:"hluti",verb:"að hafa"},set:{unit:"hluti",verb:"að hafa"}};function t(o){return e[o]??null}const r={regex:"gildi",email:"netfang",url:"vefslóð",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og tími",date:"ISO dagsetning",time:"ISO tími",duration:"ISO tímalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 tölugildi",jwt:"JWT",template_literal:"gildi"};return o=>{switch(o.code){case"invalid_type":return`Rangt gildi: Þú slóst inn ${bk(o.input)} þar sem á að vera ${o.expected}`;case"invalid_value":return o.values.length===1?`Rangt gildi: gert ráð fyrir ${H(o.values[0])}`:`Ógilt val: má vera eitt af eftirfarandi ${j(o.values,"|")}`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Of stórt: gert er ráð fyrir að ${o.origin??"gildi"} hafi ${n}${o.maximum.toString()} ${i.unit??"hluti"}`:`Of stórt: gert er ráð fyrir að ${o.origin??"gildi"} sé ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Of lítið: gert er ráð fyrir að ${o.origin} hafi ${n}${o.minimum.toString()} ${i.unit}`:`Of lítið: gert er ráð fyrir að ${o.origin} sé ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Ógildur strengur: verður að byrja á "${n.prefix}"`:n.format==="ends_with"?`Ógildur strengur: verður að enda á "${n.suffix}"`:n.format==="includes"?`Ógildur strengur: verður að innihalda "${n.includes}"`:n.format==="regex"?`Ógildur strengur: verður að fylgja mynstri ${n.pattern}`:`Rangt ${r[n.format]??o.format}`}case"not_multiple_of":return`Röng tala: verður að vera margfeldi af ${o.divisor}`;case"unrecognized_keys":return`Óþekkt ${o.keys.length>1?"ir lyklar":"ur lykill"}: ${j(o.keys,", ")}`;case"invalid_key":return`Rangur lykill í ${o.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi í ${o.origin}`;default:return"Rangt gildi"}}};function wk(){return{localeError:_k()}}const xk=()=>{const e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"numero";case"object":{if(Array.isArray(n))return"vettore";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Input non valido: atteso ${n.expected}, ricevuto ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Input non valido: atteso ${H(n.values[0])}`:`Opzione non valida: atteso uno tra ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Troppo grande: ${n.origin??"valore"} deve avere ${i}${n.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${n.origin??"valore"} deve essere ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Troppo piccolo: ${n.origin} deve avere ${i}${n.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${n.origin} deve essere ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Stringa non valida: deve iniziare con "${i.prefix}"`:i.format==="ends_with"?`Stringa non valida: deve terminare con "${i.suffix}"`:i.format==="includes"?`Stringa non valida: deve includere "${i.includes}"`:i.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${i.pattern}`:`Invalid ${o[i.format]??n.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${n.divisor}`;case"unrecognized_keys":return`Chiav${n.keys.length>1?"i":"e"} non riconosciut${n.keys.length>1?"e":"a"}: ${j(n.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${n.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${n.origin}`;default:return"Input non valido"}}};function $k(){return{localeError:xk()}}const Sk=()=>{const e={string:{unit:"文字",verb:"である"},file:{unit:"バイト",verb:"である"},array:{unit:"要素",verb:"である"},set:{unit:"要素",verb:"である"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"数値";case"object":{if(Array.isArray(n))return"配列";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"入力値",email:"メールアドレス",url:"URL",emoji:"絵文字",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日時",date:"ISO日付",time:"ISO時刻",duration:"ISO期間",ipv4:"IPv4アドレス",ipv6:"IPv6アドレス",cidrv4:"IPv4範囲",cidrv6:"IPv6範囲",base64:"base64エンコード文字列",base64url:"base64urlエンコード文字列",json_string:"JSON文字列",e164:"E.164番号",jwt:"JWT",template_literal:"入力値"};return n=>{switch(n.code){case"invalid_type":return`無効な入力: ${n.expected}が期待されましたが、${r(n.input)}が入力されました`;case"invalid_value":return n.values.length===1?`無効な入力: ${H(n.values[0])}が期待されました`:`無効な選択: ${j(n.values,"、")}のいずれかである必要があります`;case"too_big":{const i=n.inclusive?"以下である":"より小さい",a=t(n.origin);return a?`大きすぎる値: ${n.origin??"値"}は${n.maximum.toString()}${a.unit??"要素"}${i}必要があります`:`大きすぎる値: ${n.origin??"値"}は${n.maximum.toString()}${i}必要があります`}case"too_small":{const i=n.inclusive?"以上である":"より大きい",a=t(n.origin);return a?`小さすぎる値: ${n.origin}は${n.minimum.toString()}${a.unit}${i}必要があります`:`小さすぎる値: ${n.origin}は${n.minimum.toString()}${i}必要があります`}case"invalid_format":{const i=n;return i.format==="starts_with"?`無効な文字列: "${i.prefix}"で始まる必要があります`:i.format==="ends_with"?`無効な文字列: "${i.suffix}"で終わる必要があります`:i.format==="includes"?`無効な文字列: "${i.includes}"を含む必要があります`:i.format==="regex"?`無効な文字列: パターン${i.pattern}に一致する必要があります`:`無効な${o[i.format]??n.format}`}case"not_multiple_of":return`無効な数値: ${n.divisor}の倍数である必要があります`;case"unrecognized_keys":return`認識されていないキー${n.keys.length>1?"群":""}: ${j(n.keys,"、")}`;case"invalid_key":return`${n.origin}内の無効なキー`;case"invalid_union":return"無効な入力";case"invalid_element":return`${n.origin}内の無効な値`;default:return"無効な入力"}}};function Ik(){return{localeError:Sk()}}const kk=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"რიცხვი";case"object":{if(Array.isArray(e))return"მასივი";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return{string:"სტრინგი",boolean:"ბულეანი",undefined:"undefined",bigint:"bigint",symbol:"symbol",function:"ფუნქცია"}[t]??t},Ek=()=>{const e={string:{unit:"სიმბოლო",verb:"უნდა შეიცავდეს"},file:{unit:"ბაიტი",verb:"უნდა შეიცავდეს"},array:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"},set:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"}};function t(o){return e[o]??null}const r={regex:"შეყვანა",email:"ელ-ფოსტის მისამართი",url:"URL",emoji:"ემოჯი",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"თარიღი-დრო",date:"თარიღი",time:"დრო",duration:"ხანგრძლივობა",ipv4:"IPv4 მისამართი",ipv6:"IPv6 მისამართი",cidrv4:"IPv4 დიაპაზონი",cidrv6:"IPv6 დიაპაზონი",base64:"base64-კოდირებული სტრინგი",base64url:"base64url-კოდირებული სტრინგი",json_string:"JSON სტრინგი",e164:"E.164 ნომერი",jwt:"JWT",template_literal:"შეყვანა"};return o=>{switch(o.code){case"invalid_type":return`არასწორი შეყვანა: მოსალოდნელი ${o.expected}, მიღებული ${kk(o.input)}`;case"invalid_value":return o.values.length===1?`არასწორი შეყვანა: მოსალოდნელი ${H(o.values[0])}`:`არასწორი ვარიანტი: მოსალოდნელია ერთ-ერთი ${j(o.values,"|")}-დან`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`ზედმეტად დიდი: მოსალოდნელი ${o.origin??"მნიშვნელობა"} ${i.verb} ${n}${o.maximum.toString()} ${i.unit}`:`ზედმეტად დიდი: მოსალოდნელი ${o.origin??"მნიშვნელობა"} იყოს ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`ზედმეტად პატარა: მოსალოდნელი ${o.origin} ${i.verb} ${n}${o.minimum.toString()} ${i.unit}`:`ზედმეტად პატარა: მოსალოდნელი ${o.origin} იყოს ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`არასწორი სტრინგი: უნდა იწყებოდეს "${n.prefix}"-ით`:n.format==="ends_with"?`არასწორი სტრინგი: უნდა მთავრდებოდეს "${n.suffix}"-ით`:n.format==="includes"?`არასწორი სტრინგი: უნდა შეიცავდეს "${n.includes}"-ს`:n.format==="regex"?`არასწორი სტრინგი: უნდა შეესაბამებოდეს შაბლონს ${n.pattern}`:`არასწორი ${r[n.format]??o.format}`}case"not_multiple_of":return`არასწორი რიცხვი: უნდა იყოს ${o.divisor}-ის ჯერადი`;case"unrecognized_keys":return`უცნობი გასაღებ${o.keys.length>1?"ები":"ი"}: ${j(o.keys,", ")}`;case"invalid_key":return`არასწორი გასაღები ${o.origin}-ში`;case"invalid_union":return"არასწორი შეყვანა";case"invalid_element":return`არასწორი მნიშვნელობა ${o.origin}-ში`;default:return"არასწორი შეყვანა"}}};function Tk(){return{localeError:Ek()}}const Ok=()=>{const e={string:{unit:"តួអក្សរ",verb:"គួរមាន"},file:{unit:"បៃ",verb:"គួរមាន"},array:{unit:"ធាតុ",verb:"គួរមាន"},set:{unit:"ធាតុ",verb:"គួរមាន"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"មិនមែនជាលេខ (NaN)":"លេខ";case"object":{if(Array.isArray(n))return"អារេ (Array)";if(n===null)return"គ្មានតម្លៃ (null)";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ទិន្នន័យបញ្ចូល",email:"អាសយដ្ឋានអ៊ីមែល",url:"URL",emoji:"សញ្ញាអារម្មណ៍",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"កាលបរិច្ឆេទ និងម៉ោង ISO",date:"កាលបរិច្ឆេទ ISO",time:"ម៉ោង ISO",duration:"រយៈពេល ISO",ipv4:"អាសយដ្ឋាន IPv4",ipv6:"អាសយដ្ឋាន IPv6",cidrv4:"ដែនអាសយដ្ឋាន IPv4",cidrv6:"ដែនអាសយដ្ឋាន IPv6",base64:"ខ្សែអក្សរអ៊ិកូដ base64",base64url:"ខ្សែអក្សរអ៊ិកូដ base64url",json_string:"ខ្សែអក្សរ JSON",e164:"លេខ E.164",jwt:"JWT",template_literal:"ទិន្នន័យបញ្ចូល"};return n=>{switch(n.code){case"invalid_type":return`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${n.expected} ប៉ុន្តែទទួលបាន ${r(n.input)}`;case"invalid_value":return n.values.length===1?`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${H(n.values[0])}`:`ជម្រើសមិនត្រឹមត្រូវ៖ ត្រូវជាមួយក្នុងចំណោម ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`ធំពេក៖ ត្រូវការ ${n.origin??"តម្លៃ"} ${i} ${n.maximum.toString()} ${a.unit??"ធាតុ"}`:`ធំពេក៖ ត្រូវការ ${n.origin??"តម្លៃ"} ${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`តូចពេក៖ ត្រូវការ ${n.origin} ${i} ${n.minimum.toString()} ${a.unit}`:`តូចពេក៖ ត្រូវការ ${n.origin} ${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវចាប់ផ្តើមដោយ "${i.prefix}"`:i.format==="ends_with"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវបញ្ចប់ដោយ "${i.suffix}"`:i.format==="includes"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវមាន "${i.includes}"`:i.format==="regex"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវតែផ្គូផ្គងនឹងទម្រង់ដែលបានកំណត់ ${i.pattern}`:`មិនត្រឹមត្រូវ៖ ${o[i.format]??n.format}`}case"not_multiple_of":return`លេខមិនត្រឹមត្រូវ៖ ត្រូវតែជាពហុគុណនៃ ${n.divisor}`;case"unrecognized_keys":return`រកឃើញសោមិនស្គាល់៖ ${j(n.keys,", ")}`;case"invalid_key":return`សោមិនត្រឹមត្រូវនៅក្នុង ${n.origin}`;case"invalid_union":return"ទិន្នន័យមិនត្រឹមត្រូវ";case"invalid_element":return`ទិន្នន័យមិនត្រឹមត្រូវនៅក្នុង ${n.origin}`;default:return"ទិន្នន័យមិនត្រឹមត្រូវ"}}};function bv(){return{localeError:Ok()}}function Nk(){return bv()}const Pk=()=>{const e={string:{unit:"문자",verb:"to have"},file:{unit:"바이트",verb:"to have"},array:{unit:"개",verb:"to have"},set:{unit:"개",verb:"to have"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"입력",email:"이메일 주소",url:"URL",emoji:"이모지",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO 날짜시간",date:"ISO 날짜",time:"ISO 시간",duration:"ISO 기간",ipv4:"IPv4 주소",ipv6:"IPv6 주소",cidrv4:"IPv4 범위",cidrv6:"IPv6 범위",base64:"base64 인코딩 문자열",base64url:"base64url 인코딩 문자열",json_string:"JSON 문자열",e164:"E.164 번호",jwt:"JWT",template_literal:"입력"};return n=>{switch(n.code){case"invalid_type":return`잘못된 입력: 예상 타입은 ${n.expected}, 받은 타입은 ${r(n.input)}입니다`;case"invalid_value":return n.values.length===1?`잘못된 입력: 값은 ${H(n.values[0])} 이어야 합니다`:`잘못된 옵션: ${j(n.values,"또는 ")} 중 하나여야 합니다`;case"too_big":{const i=n.inclusive?"이하":"미만",a=i==="미만"?"이어야 합니다":"여야 합니다",s=t(n.origin),l=s?.unit??"요소";return s?`${n.origin??"값"}이 너무 큽니다: ${n.maximum.toString()}${l} ${i}${a}`:`${n.origin??"값"}이 너무 큽니다: ${n.maximum.toString()} ${i}${a}`}case"too_small":{const i=n.inclusive?"이상":"초과",a=i==="이상"?"이어야 합니다":"여야 합니다",s=t(n.origin),l=s?.unit??"요소";return s?`${n.origin??"값"}이 너무 작습니다: ${n.minimum.toString()}${l} ${i}${a}`:`${n.origin??"값"}이 너무 작습니다: ${n.minimum.toString()} ${i}${a}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`잘못된 문자열: "${i.prefix}"(으)로 시작해야 합니다`:i.format==="ends_with"?`잘못된 문자열: "${i.suffix}"(으)로 끝나야 합니다`:i.format==="includes"?`잘못된 문자열: "${i.includes}"을(를) 포함해야 합니다`:i.format==="regex"?`잘못된 문자열: 정규식 ${i.pattern} 패턴과 일치해야 합니다`:`잘못된 ${o[i.format]??n.format}`}case"not_multiple_of":return`잘못된 숫자: ${n.divisor}의 배수여야 합니다`;case"unrecognized_keys":return`인식할 수 없는 키: ${j(n.keys,", ")}`;case"invalid_key":return`잘못된 키: ${n.origin}`;case"invalid_union":return"잘못된 입력";case"invalid_element":return`잘못된 값: ${n.origin}`;default:return"잘못된 입력"}}};function Ck(){return{localeError:Pk()}}const jk=e=>Sn(typeof e,e),Sn=(e,t=void 0)=>{switch(e){case"number":return Number.isNaN(t)?"NaN":"skaičius";case"bigint":return"sveikasis skaičius";case"string":return"eilutė";case"boolean":return"loginė reikšmė";case"undefined":case"void":return"neapibrėžta reikšmė";case"function":return"funkcija";case"symbol":return"simbolis";case"object":return t===void 0?"nežinomas objektas":t===null?"nulinė reikšmė":Array.isArray(t)?"masyvas":Object.getPrototypeOf(t)!==Object.prototype&&t.constructor?t.constructor.name:"objektas";case"null":return"nulinė reikšmė"}return e},bn=e=>e.charAt(0).toUpperCase()+e.slice(1);function Kd(e){const t=Math.abs(e),r=t%10,o=t%100;return o>=11&&o<=19||r===0?"many":r===1?"one":"few"}const Ak=()=>{const e={string:{unit:{one:"simbolis",few:"simboliai",many:"simbolių"},verb:{smaller:{inclusive:"turi būti ne ilgesnė kaip",notInclusive:"turi būti trumpesnė kaip"},bigger:{inclusive:"turi būti ne trumpesnė kaip",notInclusive:"turi būti ilgesnė kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"baitų"},verb:{smaller:{inclusive:"turi būti ne didesnis kaip",notInclusive:"turi būti mažesnis kaip"},bigger:{inclusive:"turi būti ne mažesnis kaip",notInclusive:"turi būti didesnis kaip"}}},array:{unit:{one:"elementą",few:"elementus",many:"elementų"},verb:{smaller:{inclusive:"turi turėti ne daugiau kaip",notInclusive:"turi turėti mažiau kaip"},bigger:{inclusive:"turi turėti ne mažiau kaip",notInclusive:"turi turėti daugiau kaip"}}},set:{unit:{one:"elementą",few:"elementus",many:"elementų"},verb:{smaller:{inclusive:"turi turėti ne daugiau kaip",notInclusive:"turi turėti mažiau kaip"},bigger:{inclusive:"turi turėti ne mažiau kaip",notInclusive:"turi turėti daugiau kaip"}}}};function t(o,n,i,a){const s=e[o]??null;return s===null?s:{unit:s.unit[n],verb:s.verb[a][i?"inclusive":"notInclusive"]}}const r={regex:"įvestis",email:"el. pašto adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukmė",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 užkoduota eilutė",base64url:"base64url užkoduota eilutė",json_string:"JSON eilutė",e164:"E.164 numeris",jwt:"JWT",template_literal:"įvestis"};return o=>{switch(o.code){case"invalid_type":return`Gautas tipas ${jk(o.input)}, o tikėtasi - ${Sn(o.expected)}`;case"invalid_value":return o.values.length===1?`Privalo būti ${H(o.values[0])}`:`Privalo būti vienas iš ${j(o.values,"|")} pasirinkimų`;case"too_big":{const n=Sn(o.origin),i=t(o.origin,Kd(Number(o.maximum)),o.inclusive??!1,"smaller");if(i?.verb)return`${bn(n??o.origin??"reikšmė")} ${i.verb} ${o.maximum.toString()} ${i.unit??"elementų"}`;const a=o.inclusive?"ne didesnis kaip":"mažesnis kaip";return`${bn(n??o.origin??"reikšmė")} turi būti ${a} ${o.maximum.toString()} ${i?.unit}`}case"too_small":{const n=Sn(o.origin),i=t(o.origin,Kd(Number(o.minimum)),o.inclusive??!1,"bigger");if(i?.verb)return`${bn(n??o.origin??"reikšmė")} ${i.verb} ${o.minimum.toString()} ${i.unit??"elementų"}`;const a=o.inclusive?"ne mažesnis kaip":"didesnis kaip";return`${bn(n??o.origin??"reikšmė")} turi būti ${a} ${o.minimum.toString()} ${i?.unit}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Eilutė privalo prasidėti "${n.prefix}"`:n.format==="ends_with"?`Eilutė privalo pasibaigti "${n.suffix}"`:n.format==="includes"?`Eilutė privalo įtraukti "${n.includes}"`:n.format==="regex"?`Eilutė privalo atitikti ${n.pattern}`:`Neteisingas ${r[n.format]??o.format}`}case"not_multiple_of":return`Skaičius privalo būti ${o.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpažint${o.keys.length>1?"i":"as"} rakt${o.keys.length>1?"ai":"as"}: ${j(o.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga įvestis";case"invalid_element":{const n=Sn(o.origin);return`${bn(n??o.origin??"reikšmė")} turi klaidingą įvestį`}default:return"Klaidinga įvestis"}}};function Rk(){return{localeError:Ak()}}const zk=()=>{const e={string:{unit:"знаци",verb:"да имаат"},file:{unit:"бајти",verb:"да имаат"},array:{unit:"ставки",verb:"да имаат"},set:{unit:"ставки",verb:"да имаат"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"број";case"object":{if(Array.isArray(n))return"низа";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"внес",email:"адреса на е-пошта",url:"URL",emoji:"емоџи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO датум и време",date:"ISO датум",time:"ISO време",duration:"ISO времетраење",ipv4:"IPv4 адреса",ipv6:"IPv6 адреса",cidrv4:"IPv4 опсег",cidrv6:"IPv6 опсег",base64:"base64-енкодирана низа",base64url:"base64url-енкодирана низа",json_string:"JSON низа",e164:"E.164 број",jwt:"JWT",template_literal:"внес"};return n=>{switch(n.code){case"invalid_type":return`Грешен внес: се очекува ${n.expected}, примено ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${H(n.values[0])}`:`Грешана опција: се очекува една ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Премногу голем: се очекува ${n.origin??"вредноста"} да има ${i}${n.maximum.toString()} ${a.unit??"елементи"}`:`Премногу голем: се очекува ${n.origin??"вредноста"} да биде ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Премногу мал: се очекува ${n.origin} да има ${i}${n.minimum.toString()} ${a.unit}`:`Премногу мал: се очекува ${n.origin} да биде ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Неважечка низа: мора да започнува со "${i.prefix}"`:i.format==="ends_with"?`Неважечка низа: мора да завршува со "${i.suffix}"`:i.format==="includes"?`Неважечка низа: мора да вклучува "${i.includes}"`:i.format==="regex"?`Неважечка низа: мора да одгоара на патернот ${i.pattern}`:`Invalid ${o[i.format]??n.format}`}case"not_multiple_of":return`Грешен број: мора да биде делив со ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Непрепознаени клучеви":"Непрепознаен клуч"}: ${j(n.keys,", ")}`;case"invalid_key":return`Грешен клуч во ${n.origin}`;case"invalid_union":return"Грешен внес";case"invalid_element":return`Грешна вредност во ${n.origin}`;default:return"Грешен внес"}}};function Mk(){return{localeError:zk()}}const Dk=()=>{const e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"nombor";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Input tidak sah: dijangka ${n.expected}, diterima ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Input tidak sah: dijangka ${H(n.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Terlalu besar: dijangka ${n.origin??"nilai"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${n.origin??"nilai"} adalah ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Terlalu kecil: dijangka ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${n.origin} adalah ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`String tidak sah: mesti bermula dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak sah: mesti mengandungi "${i.includes}"`:i.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${i.pattern}`:`${o[i.format]??n.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${j(n.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${n.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${n.origin}`;default:return"Input tidak sah"}}};function Uk(){return{localeError:Dk()}}const Lk=()=>{const e={string:{unit:"tekens",verb:"te hebben"},file:{unit:"bytes",verb:"te hebben"},array:{unit:"elementen",verb:"te hebben"},set:{unit:"elementen",verb:"te hebben"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"getal";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"};return n=>{switch(n.code){case"invalid_type":return`Ongeldige invoer: verwacht ${n.expected}, ontving ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ongeldige invoer: verwacht ${H(n.values[0])}`:`Ongeldige optie: verwacht één van ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Te groot: verwacht dat ${n.origin??"waarde"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"elementen"}`:`Te groot: verwacht dat ${n.origin??"waarde"} ${i}${n.maximum.toString()} is`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Te klein: verwacht dat ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Te klein: verwacht dat ${n.origin} ${i}${n.minimum.toString()} is`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Ongeldige tekst: moet met "${i.prefix}" beginnen`:i.format==="ends_with"?`Ongeldige tekst: moet op "${i.suffix}" eindigen`:i.format==="includes"?`Ongeldige tekst: moet "${i.includes}" bevatten`:i.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${i.pattern}`:`Ongeldig: ${o[i.format]??n.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${n.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${n.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${n.origin}`;default:return"Ongeldige invoer"}}};function Zk(){return{localeError:Lk()}}const Fk=()=>{const e={string:{unit:"tegn",verb:"å ha"},file:{unit:"bytes",verb:"å ha"},array:{unit:"elementer",verb:"å inneholde"},set:{unit:"elementer",verb:"å inneholde"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"tall";case"object":{if(Array.isArray(n))return"liste";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-område",ipv6:"IPv6-område",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Ugyldig input: forventet ${n.expected}, fikk ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ugyldig verdi: forventet ${H(n.values[0])}`:`Ugyldig valg: forventet en av ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`For stor(t): forventet ${n.origin??"value"} til å ha ${i}${n.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${n.origin??"value"} til å ha ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`For lite(n): forventet ${n.origin} til å ha ${i}${n.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${n.origin} til å ha ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Ugyldig streng: må starte med "${i.prefix}"`:i.format==="ends_with"?`Ugyldig streng: må ende med "${i.suffix}"`:i.format==="includes"?`Ugyldig streng: må inneholde "${i.includes}"`:i.format==="regex"?`Ugyldig streng: må matche mønsteret ${i.pattern}`:`Ugyldig ${o[i.format]??n.format}`}case"not_multiple_of":return`Ugyldig tall: må være et multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjente nøkler":"Ukjent nøkkel"}: ${j(n.keys,", ")}`;case"invalid_key":return`Ugyldig nøkkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};function qk(){return{localeError:Fk()}}const Vk=()=>{const e={string:{unit:"harf",verb:"olmalıdır"},file:{unit:"bayt",verb:"olmalıdır"},array:{unit:"unsur",verb:"olmalıdır"},set:{unit:"unsur",verb:"olmalıdır"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"numara";case"object":{if(Array.isArray(n))return"saf";if(n===null)return"gayb";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"giren",email:"epostagâh",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO hengâmı",date:"ISO tarihi",time:"ISO zamanı",duration:"ISO müddeti",ipv4:"IPv4 nişânı",ipv6:"IPv6 nişânı",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-şifreli metin",base64url:"base64url-şifreli metin",json_string:"JSON metin",e164:"E.164 sayısı",jwt:"JWT",template_literal:"giren"};return n=>{switch(n.code){case"invalid_type":return`Fâsit giren: umulan ${n.expected}, alınan ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Fâsit giren: umulan ${H(n.values[0])}`:`Fâsit tercih: mûteberler ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Fazla büyük: ${n.origin??"value"}, ${i}${n.maximum.toString()} ${a.unit??"elements"} sahip olmalıydı.`:`Fazla büyük: ${n.origin??"value"}, ${i}${n.maximum.toString()} olmalıydı.`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Fazla küçük: ${n.origin}, ${i}${n.minimum.toString()} ${a.unit} sahip olmalıydı.`:`Fazla küçük: ${n.origin}, ${i}${n.minimum.toString()} olmalıydı.`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Fâsit metin: "${i.prefix}" ile başlamalı.`:i.format==="ends_with"?`Fâsit metin: "${i.suffix}" ile bitmeli.`:i.format==="includes"?`Fâsit metin: "${i.includes}" ihtivâ etmeli.`:i.format==="regex"?`Fâsit metin: ${i.pattern} nakşına uymalı.`:`Fâsit ${o[i.format]??n.format}`}case"not_multiple_of":return`Fâsit sayı: ${n.divisor} katı olmalıydı.`;case"unrecognized_keys":return`Tanınmayan anahtar ${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} için tanınmayan anahtar var.`;case"invalid_union":return"Giren tanınamadı.";case"invalid_element":return`${n.origin} için tanınmayan kıymet var.`;default:return"Kıymet tanınamadı."}}};function Bk(){return{localeError:Vk()}}const Jk=()=>{const e={string:{unit:"توکي",verb:"ولري"},file:{unit:"بایټس",verb:"ولري"},array:{unit:"توکي",verb:"ولري"},set:{unit:"توکي",verb:"ولري"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"عدد";case"object":{if(Array.isArray(n))return"ارې";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ورودي",email:"بریښنالیک",url:"یو آر ال",emoji:"ایموجي",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"نیټه او وخت",date:"نېټه",time:"وخت",duration:"موده",ipv4:"د IPv4 پته",ipv6:"د IPv6 پته",cidrv4:"د IPv4 ساحه",cidrv6:"د IPv6 ساحه",base64:"base64-encoded متن",base64url:"base64url-encoded متن",json_string:"JSON متن",e164:"د E.164 شمېره",jwt:"JWT",template_literal:"ورودي"};return n=>{switch(n.code){case"invalid_type":return`ناسم ورودي: باید ${n.expected} وای, مګر ${r(n.input)} ترلاسه شو`;case"invalid_value":return n.values.length===1?`ناسم ورودي: باید ${H(n.values[0])} وای`:`ناسم انتخاب: باید یو له ${j(n.values,"|")} څخه وای`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`ډیر لوی: ${n.origin??"ارزښت"} باید ${i}${n.maximum.toString()} ${a.unit??"عنصرونه"} ولري`:`ډیر لوی: ${n.origin??"ارزښت"} باید ${i}${n.maximum.toString()} وي`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`ډیر کوچنی: ${n.origin} باید ${i}${n.minimum.toString()} ${a.unit} ولري`:`ډیر کوچنی: ${n.origin} باید ${i}${n.minimum.toString()} وي`}case"invalid_format":{const i=n;return i.format==="starts_with"?`ناسم متن: باید د "${i.prefix}" سره پیل شي`:i.format==="ends_with"?`ناسم متن: باید د "${i.suffix}" سره پای ته ورسيږي`:i.format==="includes"?`ناسم متن: باید "${i.includes}" ولري`:i.format==="regex"?`ناسم متن: باید د ${i.pattern} سره مطابقت ولري`:`${o[i.format]??n.format} ناسم دی`}case"not_multiple_of":return`ناسم عدد: باید د ${n.divisor} مضرب وي`;case"unrecognized_keys":return`ناسم ${n.keys.length>1?"کلیډونه":"کلیډ"}: ${j(n.keys,", ")}`;case"invalid_key":return`ناسم کلیډ په ${n.origin} کې`;case"invalid_union":return"ناسمه ورودي";case"invalid_element":return`ناسم عنصر په ${n.origin} کې`;default:return"ناسمه ورودي"}}};function Wk(){return{localeError:Jk()}}const Hk=()=>{const e={string:{unit:"znaków",verb:"mieć"},file:{unit:"bajtów",verb:"mieć"},array:{unit:"elementów",verb:"mieć"},set:{unit:"elementów",verb:"mieć"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"liczba";case"object":{if(Array.isArray(n))return"tablica";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"wyrażenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ciąg znaków zakodowany w formacie base64",base64url:"ciąg znaków zakodowany w formacie base64url",json_string:"ciąg znaków w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wejście"};return n=>{switch(n.code){case"invalid_type":return`Nieprawidłowe dane wejściowe: oczekiwano ${n.expected}, otrzymano ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Nieprawidłowe dane wejściowe: oczekiwano ${H(n.values[0])}`:`Nieprawidłowa opcja: oczekiwano jednej z wartości ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Za duża wartość: oczekiwano, że ${n.origin??"wartość"} będzie mieć ${i}${n.maximum.toString()} ${a.unit??"elementów"}`:`Zbyt duż(y/a/e): oczekiwano, że ${n.origin??"wartość"} będzie wynosić ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Za mała wartość: oczekiwano, że ${n.origin??"wartość"} będzie mieć ${i}${n.minimum.toString()} ${a.unit??"elementów"}`:`Zbyt mał(y/a/e): oczekiwano, że ${n.origin??"wartość"} będzie wynosić ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Nieprawidłowy ciąg znaków: musi zaczynać się od "${i.prefix}"`:i.format==="ends_with"?`Nieprawidłowy ciąg znaków: musi kończyć się na "${i.suffix}"`:i.format==="includes"?`Nieprawidłowy ciąg znaków: musi zawierać "${i.includes}"`:i.format==="regex"?`Nieprawidłowy ciąg znaków: musi odpowiadać wzorcowi ${i.pattern}`:`Nieprawidłow(y/a/e) ${o[i.format]??n.format}`}case"not_multiple_of":return`Nieprawidłowa liczba: musi być wielokrotnością ${n.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Nieprawidłowy klucz w ${n.origin}`;case"invalid_union":return"Nieprawidłowe dane wejściowe";case"invalid_element":return`Nieprawidłowa wartość w ${n.origin}`;default:return"Nieprawidłowe dane wejściowe"}}};function Gk(){return{localeError:Hk()}}const Kk=()=>{const e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"número";case"object":{if(Array.isArray(n))return"array";if(n===null)return"nulo";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"padrão",email:"endereço de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"duração ISO",ipv4:"endereço IPv4",ipv6:"endereço IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return n=>{switch(n.code){case"invalid_type":return`Tipo inválido: esperado ${n.expected}, recebido ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Entrada inválida: esperado ${H(n.values[0])}`:`Opção inválida: esperada uma das ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Muito grande: esperado que ${n.origin??"valor"} tivesse ${i}${n.maximum.toString()} ${a.unit??"elementos"}`:`Muito grande: esperado que ${n.origin??"valor"} fosse ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Muito pequeno: esperado que ${n.origin} tivesse ${i}${n.minimum.toString()} ${a.unit}`:`Muito pequeno: esperado que ${n.origin} fosse ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Texto inválido: deve começar com "${i.prefix}"`:i.format==="ends_with"?`Texto inválido: deve terminar com "${i.suffix}"`:i.format==="includes"?`Texto inválido: deve incluir "${i.includes}"`:i.format==="regex"?`Texto inválido: deve corresponder ao padrão ${i.pattern}`:`${o[i.format]??n.format} inválido`}case"not_multiple_of":return`Número inválido: deve ser múltiplo de ${n.divisor}`;case"unrecognized_keys":return`Chave${n.keys.length>1?"s":""} desconhecida${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Chave inválida em ${n.origin}`;case"invalid_union":return"Entrada inválida";case"invalid_element":return`Valor inválido em ${n.origin}`;default:return"Campo inválido"}}};function Yk(){return{localeError:Kk()}}function Yd(e,t,r,o){const n=Math.abs(e),i=n%10,a=n%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?r:o}const Qk=()=>{const e={string:{unit:{one:"символ",few:"символа",many:"символов"},verb:"иметь"},file:{unit:{one:"байт",few:"байта",many:"байт"},verb:"иметь"},array:{unit:{one:"элемент",few:"элемента",many:"элементов"},verb:"иметь"},set:{unit:{one:"элемент",few:"элемента",many:"элементов"},verb:"иметь"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"число";case"object":{if(Array.isArray(n))return"массив";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ввод",email:"email адрес",url:"URL",emoji:"эмодзи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO дата и время",date:"ISO дата",time:"ISO время",duration:"ISO длительность",ipv4:"IPv4 адрес",ipv6:"IPv6 адрес",cidrv4:"IPv4 диапазон",cidrv6:"IPv6 диапазон",base64:"строка в формате base64",base64url:"строка в формате base64url",json_string:"JSON строка",e164:"номер E.164",jwt:"JWT",template_literal:"ввод"};return n=>{switch(n.code){case"invalid_type":return`Неверный ввод: ожидалось ${n.expected}, получено ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Неверный ввод: ожидалось ${H(n.values[0])}`:`Неверный вариант: ожидалось одно из ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);if(a){const s=Number(n.maximum),l=Yd(s,a.unit.one,a.unit.few,a.unit.many);return`Слишком большое значение: ожидалось, что ${n.origin??"значение"} будет иметь ${i}${n.maximum.toString()} ${l}`}return`Слишком большое значение: ожидалось, что ${n.origin??"значение"} будет ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);if(a){const s=Number(n.minimum),l=Yd(s,a.unit.one,a.unit.few,a.unit.many);return`Слишком маленькое значение: ожидалось, что ${n.origin} будет иметь ${i}${n.minimum.toString()} ${l}`}return`Слишком маленькое значение: ожидалось, что ${n.origin} будет ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Неверная строка: должна начинаться с "${i.prefix}"`:i.format==="ends_with"?`Неверная строка: должна заканчиваться на "${i.suffix}"`:i.format==="includes"?`Неверная строка: должна содержать "${i.includes}"`:i.format==="regex"?`Неверная строка: должна соответствовать шаблону ${i.pattern}`:`Неверный ${o[i.format]??n.format}`}case"not_multiple_of":return`Неверное число: должно быть кратным ${n.divisor}`;case"unrecognized_keys":return`Нераспознанн${n.keys.length>1?"ые":"ый"} ключ${n.keys.length>1?"и":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Неверный ключ в ${n.origin}`;case"invalid_union":return"Неверные входные данные";case"invalid_element":return`Неверное значение в ${n.origin}`;default:return"Неверные входные данные"}}};function Xk(){return{localeError:Qk()}}const eE=()=>{const e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"število";case"object":{if(Array.isArray(n))return"tabela";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"vnos",email:"e-poštni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in čas",date:"ISO datum",time:"ISO čas",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 številka",jwt:"JWT",template_literal:"vnos"};return n=>{switch(n.code){case"invalid_type":return`Neveljaven vnos: pričakovano ${n.expected}, prejeto ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Neveljaven vnos: pričakovano ${H(n.values[0])}`:`Neveljavna možnost: pričakovano eno izmed ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Preveliko: pričakovano, da bo ${n.origin??"vrednost"} imelo ${i}${n.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pričakovano, da bo ${n.origin??"vrednost"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Premajhno: pričakovano, da bo ${n.origin} imelo ${i}${n.minimum.toString()} ${a.unit}`:`Premajhno: pričakovano, da bo ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Neveljaven niz: mora se začeti z "${i.prefix}"`:i.format==="ends_with"?`Neveljaven niz: mora se končati z "${i.suffix}"`:i.format==="includes"?`Neveljaven niz: mora vsebovati "${i.includes}"`:i.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${i.pattern}`:`Neveljaven ${o[i.format]??n.format}`}case"not_multiple_of":return`Neveljavno število: mora biti večkratnik ${n.divisor}`;case"unrecognized_keys":return`Neprepoznan${n.keys.length>1?"i ključi":" ključ"}: ${j(n.keys,", ")}`;case"invalid_key":return`Neveljaven ključ v ${n.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${n.origin}`;default:return"Neveljaven vnos"}}};function tE(){return{localeError:eE()}}const rE=()=>{const e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att innehålla"},set:{unit:"objekt",verb:"att innehålla"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"antal";case"object":{if(Array.isArray(n))return"lista";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"reguljärt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad sträng",base64url:"base64url-kodad sträng",json_string:"JSON-sträng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"};return n=>{switch(n.code){case"invalid_type":return`Ogiltig inmatning: förväntat ${n.expected}, fick ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ogiltig inmatning: förväntat ${H(n.values[0])}`:`Ogiltigt val: förväntade en av ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`För stor(t): förväntade ${n.origin??"värdet"} att ha ${i}${n.maximum.toString()} ${a.unit??"element"}`:`För stor(t): förväntat ${n.origin??"värdet"} att ha ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`För lite(t): förväntade ${n.origin??"värdet"} att ha ${i}${n.minimum.toString()} ${a.unit}`:`För lite(t): förväntade ${n.origin??"värdet"} att ha ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Ogiltig sträng: måste börja med "${i.prefix}"`:i.format==="ends_with"?`Ogiltig sträng: måste sluta med "${i.suffix}"`:i.format==="includes"?`Ogiltig sträng: måste innehålla "${i.includes}"`:i.format==="regex"?`Ogiltig sträng: måste matcha mönstret "${i.pattern}"`:`Ogiltig(t) ${o[i.format]??n.format}`}case"not_multiple_of":return`Ogiltigt tal: måste vara en multipel av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Okända nycklar":"Okänd nyckel"}: ${j(n.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${n.origin??"värdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt värde i ${n.origin??"värdet"}`;default:return"Ogiltig input"}}};function nE(){return{localeError:rE()}}const oE=()=>{const e={string:{unit:"எழுத்துக்கள்",verb:"கொண்டிருக்க வேண்டும்"},file:{unit:"பைட்டுகள்",verb:"கொண்டிருக்க வேண்டும்"},array:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"},set:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"எண் அல்லாதது":"எண்";case"object":{if(Array.isArray(n))return"அணி";if(n===null)return"வெறுமை";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"உள்ளீடு",email:"மின்னஞ்சல் முகவரி",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO தேதி நேரம்",date:"ISO தேதி",time:"ISO நேரம்",duration:"ISO கால அளவு",ipv4:"IPv4 முகவரி",ipv6:"IPv6 முகவரி",cidrv4:"IPv4 வரம்பு",cidrv6:"IPv6 வரம்பு",base64:"base64-encoded சரம்",base64url:"base64url-encoded சரம்",json_string:"JSON சரம்",e164:"E.164 எண்",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${n.expected}, பெறப்பட்டது ${r(n.input)}`;case"invalid_value":return n.values.length===1?`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${H(n.values[0])}`:`தவறான விருப்பம்: எதிர்பார்க்கப்பட்டது ${j(n.values,"|")} இல் ஒன்று`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${n.origin??"மதிப்பு"} ${i}${n.maximum.toString()} ${a.unit??"உறுப்புகள்"} ஆக இருக்க வேண்டும்`:`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${n.origin??"மதிப்பு"} ${i}${n.maximum.toString()} ஆக இருக்க வேண்டும்`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${n.origin} ${i}${n.minimum.toString()} ${a.unit} ஆக இருக்க வேண்டும்`:`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${n.origin} ${i}${n.minimum.toString()} ஆக இருக்க வேண்டும்`}case"invalid_format":{const i=n;return i.format==="starts_with"?`தவறான சரம்: "${i.prefix}" இல் தொடங்க வேண்டும்`:i.format==="ends_with"?`தவறான சரம்: "${i.suffix}" இல் முடிவடைய வேண்டும்`:i.format==="includes"?`தவறான சரம்: "${i.includes}" ஐ உள்ளடக்க வேண்டும்`:i.format==="regex"?`தவறான சரம்: ${i.pattern} முறைபாட்டுடன் பொருந்த வேண்டும்`:`தவறான ${o[i.format]??n.format}`}case"not_multiple_of":return`தவறான எண்: ${n.divisor} இன் பலமாக இருக்க வேண்டும்`;case"unrecognized_keys":return`அடையாளம் தெரியாத விசை${n.keys.length>1?"கள்":""}: ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} இல் தவறான விசை`;case"invalid_union":return"தவறான உள்ளீடு";case"invalid_element":return`${n.origin} இல் தவறான மதிப்பு`;default:return"தவறான உள்ளீடு"}}};function iE(){return{localeError:oE()}}const aE=()=>{const e={string:{unit:"ตัวอักษร",verb:"ควรมี"},file:{unit:"ไบต์",verb:"ควรมี"},array:{unit:"รายการ",verb:"ควรมี"},set:{unit:"รายการ",verb:"ควรมี"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"ไม่ใช่ตัวเลข (NaN)":"ตัวเลข";case"object":{if(Array.isArray(n))return"อาร์เรย์ (Array)";if(n===null)return"ไม่มีค่า (null)";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ข้อมูลที่ป้อน",email:"ที่อยู่อีเมล",url:"URL",emoji:"อิโมจิ",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"วันที่เวลาแบบ ISO",date:"วันที่แบบ ISO",time:"เวลาแบบ ISO",duration:"ช่วงเวลาแบบ ISO",ipv4:"ที่อยู่ IPv4",ipv6:"ที่อยู่ IPv6",cidrv4:"ช่วง IP แบบ IPv4",cidrv6:"ช่วง IP แบบ IPv6",base64:"ข้อความแบบ Base64",base64url:"ข้อความแบบ Base64 สำหรับ URL",json_string:"ข้อความแบบ JSON",e164:"เบอร์โทรศัพท์ระหว่างประเทศ (E.164)",jwt:"โทเคน JWT",template_literal:"ข้อมูลที่ป้อน"};return n=>{switch(n.code){case"invalid_type":return`ประเภทข้อมูลไม่ถูกต้อง: ควรเป็น ${n.expected} แต่ได้รับ ${r(n.input)}`;case"invalid_value":return n.values.length===1?`ค่าไม่ถูกต้อง: ควรเป็น ${H(n.values[0])}`:`ตัวเลือกไม่ถูกต้อง: ควรเป็นหนึ่งใน ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"ไม่เกิน":"น้อยกว่า",a=t(n.origin);return a?`เกินกำหนด: ${n.origin??"ค่า"} ควรมี${i} ${n.maximum.toString()} ${a.unit??"รายการ"}`:`เกินกำหนด: ${n.origin??"ค่า"} ควรมี${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?"อย่างน้อย":"มากกว่า",a=t(n.origin);return a?`น้อยกว่ากำหนด: ${n.origin} ควรมี${i} ${n.minimum.toString()} ${a.unit}`:`น้อยกว่ากำหนด: ${n.origin} ควรมี${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`รูปแบบไม่ถูกต้อง: ข้อความต้องขึ้นต้นด้วย "${i.prefix}"`:i.format==="ends_with"?`รูปแบบไม่ถูกต้อง: ข้อความต้องลงท้ายด้วย "${i.suffix}"`:i.format==="includes"?`รูปแบบไม่ถูกต้อง: ข้อความต้องมี "${i.includes}" อยู่ในข้อความ`:i.format==="regex"?`รูปแบบไม่ถูกต้อง: ต้องตรงกับรูปแบบที่กำหนด ${i.pattern}`:`รูปแบบไม่ถูกต้อง: ${o[i.format]??n.format}`}case"not_multiple_of":return`ตัวเลขไม่ถูกต้อง: ต้องเป็นจำนวนที่หารด้วย ${n.divisor} ได้ลงตัว`;case"unrecognized_keys":return`พบคีย์ที่ไม่รู้จัก: ${j(n.keys,", ")}`;case"invalid_key":return`คีย์ไม่ถูกต้องใน ${n.origin}`;case"invalid_union":return"ข้อมูลไม่ถูกต้อง: ไม่ตรงกับรูปแบบยูเนียนที่กำหนดไว้";case"invalid_element":return`ข้อมูลไม่ถูกต้องใน ${n.origin}`;default:return"ข้อมูลไม่ถูกต้อง"}}};function sE(){return{localeError:aE()}}const uE=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},lE=()=>{const e={string:{unit:"karakter",verb:"olmalı"},file:{unit:"bayt",verb:"olmalı"},array:{unit:"öğe",verb:"olmalı"},set:{unit:"öğe",verb:"olmalı"}};function t(o){return e[o]??null}const r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO süre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aralığı",cidrv6:"IPv6 aralığı",base64:"base64 ile şifrelenmiş metin",base64url:"base64url ile şifrelenmiş metin",json_string:"JSON dizesi",e164:"E.164 sayısı",jwt:"JWT",template_literal:"Şablon dizesi"};return o=>{switch(o.code){case"invalid_type":return`Geçersiz değer: beklenen ${o.expected}, alınan ${uE(o.input)}`;case"invalid_value":return o.values.length===1?`Geçersiz değer: beklenen ${H(o.values[0])}`:`Geçersiz seçenek: aşağıdakilerden biri olmalı: ${j(o.values,"|")}`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Çok büyük: beklenen ${o.origin??"değer"} ${n}${o.maximum.toString()} ${i.unit??"öğe"}`:`Çok büyük: beklenen ${o.origin??"değer"} ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Çok küçük: beklenen ${o.origin} ${n}${o.minimum.toString()} ${i.unit}`:`Çok küçük: beklenen ${o.origin} ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Geçersiz metin: "${n.prefix}" ile başlamalı`:n.format==="ends_with"?`Geçersiz metin: "${n.suffix}" ile bitmeli`:n.format==="includes"?`Geçersiz metin: "${n.includes}" içermeli`:n.format==="regex"?`Geçersiz metin: ${n.pattern} desenine uymalı`:`Geçersiz ${r[n.format]??o.format}`}case"not_multiple_of":return`Geçersiz sayı: ${o.divisor} ile tam bölünebilmeli`;case"unrecognized_keys":return`Tanınmayan anahtar${o.keys.length>1?"lar":""}: ${j(o.keys,", ")}`;case"invalid_key":return`${o.origin} içinde geçersiz anahtar`;case"invalid_union":return"Geçersiz değer";case"invalid_element":return`${o.origin} içinde geçersiz değer`;default:return"Geçersiz değer"}}};function cE(){return{localeError:lE()}}const dE=()=>{const e={string:{unit:"символів",verb:"матиме"},file:{unit:"байтів",verb:"матиме"},array:{unit:"елементів",verb:"матиме"},set:{unit:"елементів",verb:"матиме"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"число";case"object":{if(Array.isArray(n))return"масив";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"вхідні дані",email:"адреса електронної пошти",url:"URL",emoji:"емодзі",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"дата та час ISO",date:"дата ISO",time:"час ISO",duration:"тривалість ISO",ipv4:"адреса IPv4",ipv6:"адреса IPv6",cidrv4:"діапазон IPv4",cidrv6:"діапазон IPv6",base64:"рядок у кодуванні base64",base64url:"рядок у кодуванні base64url",json_string:"рядок JSON",e164:"номер E.164",jwt:"JWT",template_literal:"вхідні дані"};return n=>{switch(n.code){case"invalid_type":return`Неправильні вхідні дані: очікується ${n.expected}, отримано ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Неправильні вхідні дані: очікується ${H(n.values[0])}`:`Неправильна опція: очікується одне з ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Занадто велике: очікується, що ${n.origin??"значення"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"елементів"}`:`Занадто велике: очікується, що ${n.origin??"значення"} буде ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Занадто мале: очікується, що ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Занадто мале: очікується, що ${n.origin} буде ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Неправильний рядок: повинен починатися з "${i.prefix}"`:i.format==="ends_with"?`Неправильний рядок: повинен закінчуватися на "${i.suffix}"`:i.format==="includes"?`Неправильний рядок: повинен містити "${i.includes}"`:i.format==="regex"?`Неправильний рядок: повинен відповідати шаблону ${i.pattern}`:`Неправильний ${o[i.format]??n.format}`}case"not_multiple_of":return`Неправильне число: повинно бути кратним ${n.divisor}`;case"unrecognized_keys":return`Нерозпізнаний ключ${n.keys.length>1?"і":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Неправильний ключ у ${n.origin}`;case"invalid_union":return"Неправильні вхідні дані";case"invalid_element":return`Неправильне значення у ${n.origin}`;default:return"Неправильні вхідні дані"}}};function _v(){return{localeError:dE()}}function pE(){return _v()}const fE=()=>{const e={string:{unit:"حروف",verb:"ہونا"},file:{unit:"بائٹس",verb:"ہونا"},array:{unit:"آئٹمز",verb:"ہونا"},set:{unit:"آئٹمز",verb:"ہونا"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"نمبر";case"object":{if(Array.isArray(n))return"آرے";if(n===null)return"نل";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ان پٹ",email:"ای میل ایڈریس",url:"یو آر ایل",emoji:"ایموجی",uuid:"یو یو آئی ڈی",uuidv4:"یو یو آئی ڈی وی 4",uuidv6:"یو یو آئی ڈی وی 6",nanoid:"نینو آئی ڈی",guid:"جی یو آئی ڈی",cuid:"سی یو آئی ڈی",cuid2:"سی یو آئی ڈی 2",ulid:"یو ایل آئی ڈی",xid:"ایکس آئی ڈی",ksuid:"کے ایس یو آئی ڈی",datetime:"آئی ایس او ڈیٹ ٹائم",date:"آئی ایس او تاریخ",time:"آئی ایس او وقت",duration:"آئی ایس او مدت",ipv4:"آئی پی وی 4 ایڈریس",ipv6:"آئی پی وی 6 ایڈریس",cidrv4:"آئی پی وی 4 رینج",cidrv6:"آئی پی وی 6 رینج",base64:"بیس 64 ان کوڈڈ سٹرنگ",base64url:"بیس 64 یو آر ایل ان کوڈڈ سٹرنگ",json_string:"جے ایس او این سٹرنگ",e164:"ای 164 نمبر",jwt:"جے ڈبلیو ٹی",template_literal:"ان پٹ"};return n=>{switch(n.code){case"invalid_type":return`غلط ان پٹ: ${n.expected} متوقع تھا، ${r(n.input)} موصول ہوا`;case"invalid_value":return n.values.length===1?`غلط ان پٹ: ${H(n.values[0])} متوقع تھا`:`غلط آپشن: ${j(n.values,"|")} میں سے ایک متوقع تھا`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`بہت بڑا: ${n.origin??"ویلیو"} کے ${i}${n.maximum.toString()} ${a.unit??"عناصر"} ہونے متوقع تھے`:`بہت بڑا: ${n.origin??"ویلیو"} کا ${i}${n.maximum.toString()} ہونا متوقع تھا`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`بہت چھوٹا: ${n.origin} کے ${i}${n.minimum.toString()} ${a.unit} ہونے متوقع تھے`:`بہت چھوٹا: ${n.origin} کا ${i}${n.minimum.toString()} ہونا متوقع تھا`}case"invalid_format":{const i=n;return i.format==="starts_with"?`غلط سٹرنگ: "${i.prefix}" سے شروع ہونا چاہیے`:i.format==="ends_with"?`غلط سٹرنگ: "${i.suffix}" پر ختم ہونا چاہیے`:i.format==="includes"?`غلط سٹرنگ: "${i.includes}" شامل ہونا چاہیے`:i.format==="regex"?`غلط سٹرنگ: پیٹرن ${i.pattern} سے میچ ہونا چاہیے`:`غلط ${o[i.format]??n.format}`}case"not_multiple_of":return`غلط نمبر: ${n.divisor} کا مضاعف ہونا چاہیے`;case"unrecognized_keys":return`غیر تسلیم شدہ کی${n.keys.length>1?"ز":""}: ${j(n.keys,"، ")}`;case"invalid_key":return`${n.origin} میں غلط کی`;case"invalid_union":return"غلط ان پٹ";case"invalid_element":return`${n.origin} میں غلط ویلیو`;default:return"غلط ان پٹ"}}};function mE(){return{localeError:fE()}}const hE=()=>{const e={string:{unit:"ký tự",verb:"có"},file:{unit:"byte",verb:"có"},array:{unit:"phần tử",verb:"có"},set:{unit:"phần tử",verb:"có"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"số";case"object":{if(Array.isArray(n))return"mảng";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"đầu vào",email:"địa chỉ email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ngày giờ ISO",date:"ngày ISO",time:"giờ ISO",duration:"khoảng thời gian ISO",ipv4:"địa chỉ IPv4",ipv6:"địa chỉ IPv6",cidrv4:"dải IPv4",cidrv6:"dải IPv6",base64:"chuỗi mã hóa base64",base64url:"chuỗi mã hóa base64url",json_string:"chuỗi JSON",e164:"số E.164",jwt:"JWT",template_literal:"đầu vào"};return n=>{switch(n.code){case"invalid_type":return`Đầu vào không hợp lệ: mong đợi ${n.expected}, nhận được ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Đầu vào không hợp lệ: mong đợi ${H(n.values[0])}`:`Tùy chọn không hợp lệ: mong đợi một trong các giá trị ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Quá lớn: mong đợi ${n.origin??"giá trị"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"phần tử"}`:`Quá lớn: mong đợi ${n.origin??"giá trị"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Quá nhỏ: mong đợi ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Quá nhỏ: mong đợi ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Chuỗi không hợp lệ: phải bắt đầu bằng "${i.prefix}"`:i.format==="ends_with"?`Chuỗi không hợp lệ: phải kết thúc bằng "${i.suffix}"`:i.format==="includes"?`Chuỗi không hợp lệ: phải bao gồm "${i.includes}"`:i.format==="regex"?`Chuỗi không hợp lệ: phải khớp với mẫu ${i.pattern}`:`${o[i.format]??n.format} không hợp lệ`}case"not_multiple_of":return`Số không hợp lệ: phải là bội số của ${n.divisor}`;case"unrecognized_keys":return`Khóa không được nhận dạng: ${j(n.keys,", ")}`;case"invalid_key":return`Khóa không hợp lệ trong ${n.origin}`;case"invalid_union":return"Đầu vào không hợp lệ";case"invalid_element":return`Giá trị không hợp lệ trong ${n.origin}`;default:return"Đầu vào không hợp lệ"}}};function gE(){return{localeError:hE()}}const vE=()=>{const e={string:{unit:"字符",verb:"包含"},file:{unit:"字节",verb:"包含"},array:{unit:"项",verb:"包含"},set:{unit:"项",verb:"包含"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"非数字(NaN)":"数字";case"object":{if(Array.isArray(n))return"数组";if(n===null)return"空值(null)";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"输入",email:"电子邮件",url:"URL",emoji:"表情符号",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日期时间",date:"ISO日期",time:"ISO时间",duration:"ISO时长",ipv4:"IPv4地址",ipv6:"IPv6地址",cidrv4:"IPv4网段",cidrv6:"IPv6网段",base64:"base64编码字符串",base64url:"base64url编码字符串",json_string:"JSON字符串",e164:"E.164号码",jwt:"JWT",template_literal:"输入"};return n=>{switch(n.code){case"invalid_type":return`无效输入:期望 ${n.expected},实际接收 ${r(n.input)}`;case"invalid_value":return n.values.length===1?`无效输入:期望 ${H(n.values[0])}`:`无效选项:期望以下之一 ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`数值过大:期望 ${n.origin??"值"} ${i}${n.maximum.toString()} ${a.unit??"个元素"}`:`数值过大:期望 ${n.origin??"值"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`数值过小:期望 ${n.origin} ${i}${n.minimum.toString()} ${a.unit}`:`数值过小:期望 ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`无效字符串:必须以 "${i.prefix}" 开头`:i.format==="ends_with"?`无效字符串:必须以 "${i.suffix}" 结尾`:i.format==="includes"?`无效字符串:必须包含 "${i.includes}"`:i.format==="regex"?`无效字符串:必须满足正则表达式 ${i.pattern}`:`无效${o[i.format]??n.format}`}case"not_multiple_of":return`无效数字:必须是 ${n.divisor} 的倍数`;case"unrecognized_keys":return`出现未知的键(key): ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} 中的键(key)无效`;case"invalid_union":return"无效输入";case"invalid_element":return`${n.origin} 中包含无效值(value)`;default:return"无效输入"}}};function yE(){return{localeError:vE()}}const bE=()=>{const e={string:{unit:"字元",verb:"擁有"},file:{unit:"位元組",verb:"擁有"},array:{unit:"項目",verb:"擁有"},set:{unit:"項目",verb:"擁有"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"輸入",email:"郵件地址",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO 日期時間",date:"ISO 日期",time:"ISO 時間",duration:"ISO 期間",ipv4:"IPv4 位址",ipv6:"IPv6 位址",cidrv4:"IPv4 範圍",cidrv6:"IPv6 範圍",base64:"base64 編碼字串",base64url:"base64url 編碼字串",json_string:"JSON 字串",e164:"E.164 數值",jwt:"JWT",template_literal:"輸入"};return n=>{switch(n.code){case"invalid_type":return`無效的輸入值:預期為 ${n.expected},但收到 ${r(n.input)}`;case"invalid_value":return n.values.length===1?`無效的輸入值:預期為 ${H(n.values[0])}`:`無效的選項:預期為以下其中之一 ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`數值過大:預期 ${n.origin??"值"} 應為 ${i}${n.maximum.toString()} ${a.unit??"個元素"}`:`數值過大:預期 ${n.origin??"值"} 應為 ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`數值過小:預期 ${n.origin} 應為 ${i}${n.minimum.toString()} ${a.unit}`:`數值過小:預期 ${n.origin} 應為 ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`無效的字串:必須以 "${i.prefix}" 開頭`:i.format==="ends_with"?`無效的字串:必須以 "${i.suffix}" 結尾`:i.format==="includes"?`無效的字串:必須包含 "${i.includes}"`:i.format==="regex"?`無效的字串:必須符合格式 ${i.pattern}`:`無效的 ${o[i.format]??n.format}`}case"not_multiple_of":return`無效的數字:必須為 ${n.divisor} 的倍數`;case"unrecognized_keys":return`無法識別的鍵值${n.keys.length>1?"們":""}:${j(n.keys,"、")}`;case"invalid_key":return`${n.origin} 中有無效的鍵值`;case"invalid_union":return"無效的輸入值";case"invalid_element":return`${n.origin} 中有無效的值`;default:return"無效的輸入值"}}};function _E(){return{localeError:bE()}}const wE=()=>{const e={string:{unit:"àmi",verb:"ní"},file:{unit:"bytes",verb:"ní"},array:{unit:"nkan",verb:"ní"},set:{unit:"nkan",verb:"ní"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"nọ́mbà";case"object":{if(Array.isArray(n))return"akopọ";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ẹ̀rọ ìbáwọlé",email:"àdírẹ́sì ìmẹ́lì",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"àkókò ISO",date:"ọjọ́ ISO",time:"àkókò ISO",duration:"àkókò tó pé ISO",ipv4:"àdírẹ́sì IPv4",ipv6:"àdírẹ́sì IPv6",cidrv4:"àgbègbè IPv4",cidrv6:"àgbègbè IPv6",base64:"ọ̀rọ̀ tí a kọ́ ní base64",base64url:"ọ̀rọ̀ base64url",json_string:"ọ̀rọ̀ JSON",e164:"nọ́mbà E.164",jwt:"JWT",template_literal:"ẹ̀rọ ìbáwọlé"};return n=>{switch(n.code){case"invalid_type":return`Ìbáwọlé aṣìṣe: a ní láti fi ${n.expected}, àmọ̀ a rí ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ìbáwọlé aṣìṣe: a ní láti fi ${H(n.values[0])}`:`Àṣàyàn aṣìṣe: yan ọ̀kan lára ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Tó pọ̀ jù: a ní láti jẹ́ pé ${n.origin??"iye"} ${a.verb} ${i}${n.maximum} ${a.unit}`:`Tó pọ̀ jù: a ní láti jẹ́ ${i}${n.maximum}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Kéré ju: a ní láti jẹ́ pé ${n.origin} ${a.verb} ${i}${n.minimum} ${a.unit}`:`Kéré ju: a ní láti jẹ́ ${i}${n.minimum}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${i.prefix}"`:i.format==="ends_with"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${i.suffix}"`:i.format==="includes"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${i.includes}"`:i.format==="regex"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${i.pattern}`:`Aṣìṣe: ${o[i.format]??n.format}`}case"not_multiple_of":return`Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${n.divisor}`;case"unrecognized_keys":return`Bọtìnì àìmọ̀: ${j(n.keys,", ")}`;case"invalid_key":return`Bọtìnì aṣìṣe nínú ${n.origin}`;case"invalid_union":return"Ìbáwọlé aṣìṣe";case"invalid_element":return`Iye aṣìṣe nínú ${n.origin}`;default:return"Ìbáwọlé aṣìṣe"}}};function xE(){return{localeError:wE()}}const wv=Object.freeze(Object.defineProperty({__proto__:null,ar:zI,az:DI,be:LI,bg:qI,ca:BI,cs:WI,da:GI,de:YI,en:yv,eo:rk,es:ok,fa:ak,fi:uk,fr:ck,frCA:pk,he:mk,hu:gk,id:yk,is:wk,it:$k,ja:Ik,ka:Tk,kh:Nk,km:bv,ko:Ck,lt:Rk,mk:Mk,ms:Uk,nl:Zk,no:qk,ota:Bk,pl:Gk,ps:Wk,pt:Yk,ru:Xk,sl:tE,sv:nE,ta:iE,th:sE,tr:cE,ua:pE,uk:_v,ur:mE,vi:gE,yo:xE,zhCN:yE,zhTW:_E},Symbol.toStringTag,{value:"Module"}));var Qd;const xv=Symbol("ZodOutput"),$v=Symbol("ZodInput");class Sv{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const o=r[0];if(this._map.set(t,o),o&&typeof o=="object"&&"id"in o){if(this._idmap.has(o.id))throw new Error(`ID ${o.id} already exists in the registry`);this._idmap.set(o.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const o={...this.get(r)??{}};delete o.id;const n={...o,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function ul(){return new Sv}(Qd=globalThis).__zod_globalRegistry??(Qd.__zod_globalRegistry=ul());const wt=globalThis.__zod_globalRegistry;function Iv(e,t){return new e({type:"string",...P(t)})}function kv(e,t){return new e({type:"string",coerce:!0,...P(t)})}function ll(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function fi(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function cl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function dl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function pl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function fl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function Qi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function ml(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function hl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function gl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function vl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function yl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function bl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function _l(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function wl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function xl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function Ev(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...P(t)})}function $l(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function Sl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function Il(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function kl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function El(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function Tl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}const Tv={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Ov(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function Nv(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function Pv(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function Cv(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function jv(e,t){return new e({type:"number",checks:[],...P(t)})}function Av(e,t){return new e({type:"number",coerce:!0,checks:[],...P(t)})}function Rv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function zv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...P(t)})}function Mv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...P(t)})}function Dv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...P(t)})}function Uv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...P(t)})}function Lv(e,t){return new e({type:"boolean",...P(t)})}function Zv(e,t){return new e({type:"boolean",coerce:!0,...P(t)})}function Fv(e,t){return new e({type:"bigint",...P(t)})}function qv(e,t){return new e({type:"bigint",coerce:!0,...P(t)})}function Vv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...P(t)})}function Bv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...P(t)})}function Jv(e,t){return new e({type:"symbol",...P(t)})}function Wv(e,t){return new e({type:"undefined",...P(t)})}function Hv(e,t){return new e({type:"null",...P(t)})}function Gv(e){return new e({type:"any"})}function Kv(e){return new e({type:"unknown"})}function Yv(e,t){return new e({type:"never",...P(t)})}function Qv(e,t){return new e({type:"void",...P(t)})}function Xv(e,t){return new e({type:"date",...P(t)})}function ey(e,t){return new e({type:"date",coerce:!0,...P(t)})}function ty(e,t){return new e({type:"nan",...P(t)})}function ir(e,t){return new el({check:"less_than",...P(t),value:e,inclusive:!1})}function st(e,t){return new el({check:"less_than",...P(t),value:e,inclusive:!0})}function ar(e,t){return new tl({check:"greater_than",...P(t),value:e,inclusive:!1})}function We(e,t){return new tl({check:"greater_than",...P(t),value:e,inclusive:!0})}function Ol(e){return ar(0,e)}function Nl(e){return ir(0,e)}function Pl(e){return st(0,e)}function Cl(e){return We(0,e)}function Kr(e,t){return new Uh({check:"multiple_of",...P(t),value:e})}function uo(e,t){return new Fh({check:"max_size",...P(t),maximum:e})}function Yr(e,t){return new qh({check:"min_size",...P(t),minimum:e})}function Xi(e,t){return new Vh({check:"size_equals",...P(t),size:e})}function lo(e,t){return new Bh({check:"max_length",...P(t),maximum:e})}function br(e,t){return new Jh({check:"min_length",...P(t),minimum:e})}function co(e,t){return new Wh({check:"length_equals",...P(t),length:e})}function ea(e,t){return new Hh({check:"string_format",format:"regex",...P(t),pattern:e})}function ta(e){return new Gh({check:"string_format",format:"lowercase",...P(e)})}function ra(e){return new Kh({check:"string_format",format:"uppercase",...P(e)})}function na(e,t){return new Yh({check:"string_format",format:"includes",...P(t),includes:e})}function oa(e,t){return new Qh({check:"string_format",format:"starts_with",...P(t),prefix:e})}function ia(e,t){return new Xh({check:"string_format",format:"ends_with",...P(t),suffix:e})}function jl(e,t,r){return new eg({check:"property",property:e,schema:t,...P(r)})}function aa(e,t){return new tg({check:"mime_type",mime:e,...P(t)})}function Ht(e){return new rg({check:"overwrite",tx:e})}function sa(e){return Ht(t=>t.normalize(e))}function ua(){return Ht(e=>e.trim())}function la(){return Ht(e=>e.toLowerCase())}function ca(){return Ht(e=>e.toUpperCase())}function da(){return Ht(e=>Rm(e))}function ry(e,t,r){return new e({type:"array",element:t,...P(r)})}function $E(e,t,r){return new e({type:"union",options:t,...P(r)})}function SE(e,t,r){return new e({type:"union",options:t,inclusive:!1,...P(r)})}function IE(e,t,r,o){return new e({type:"union",options:r,discriminator:t,...P(o)})}function kE(e,t,r){return new e({type:"intersection",left:t,right:r})}function EE(e,t,r,o){const n=r instanceof X,i=n?o:r,a=n?r:null;return new e({type:"tuple",items:t,rest:a,...P(i)})}function TE(e,t,r,o){return new e({type:"record",keyType:t,valueType:r,...P(o)})}function OE(e,t,r,o){return new e({type:"map",keyType:t,valueType:r,...P(o)})}function NE(e,t,r){return new e({type:"set",valueType:t,...P(r)})}function PE(e,t,r){const o=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:o,...P(r)})}function CE(e,t,r){return new e({type:"enum",entries:t,...P(r)})}function jE(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...P(r)})}function ny(e,t){return new e({type:"file",...P(t)})}function AE(e,t){return new e({type:"transform",transform:t})}function RE(e,t){return new e({type:"optional",innerType:t})}function zE(e,t){return new e({type:"nullable",innerType:t})}function ME(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Hi(r)}})}function DE(e,t,r){return new e({type:"nonoptional",innerType:t,...P(r)})}function UE(e,t){return new e({type:"success",innerType:t})}function LE(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function ZE(e,t,r){return new e({type:"pipe",in:t,out:r})}function FE(e,t){return new e({type:"readonly",innerType:t})}function qE(e,t,r){return new e({type:"template_literal",parts:t,...P(r)})}function VE(e,t){return new e({type:"lazy",getter:t})}function BE(e,t){return new e({type:"promise",innerType:t})}function oy(e,t,r){const o=P(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function iy(e,t,r){return new e({type:"custom",check:"custom",fn:t,...P(r)})}function ay(e){const t=sy(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Hr(o,r.value,t._zod.def));else{const n=o;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),r.issues.push(Hr(n))}},e(r.value,r)));return t}function sy(e,t){const r=new Se({check:"custom",...P(t)});return r._zod.check=e,r}function uy(e){const t=new Se({check:"describe"});return t._zod.onattach=[r=>{const o=wt.get(r)??{};wt.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function ly(e){const t=new Se({check:"meta"});return t._zod.onattach=[r=>{const o=wt.get(r)??{};wt.add(r,{...o,...e})}],t._zod.check=()=>{},t}function cy(e,t){const r=P(t);let o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(o=o.map(p=>typeof p=="string"?p.toLowerCase():p),n=n.map(p=>typeof p=="string"?p.toLowerCase():p));const i=new Set(o),a=new Set(n),s=e.Codec??sl,l=e.Boolean??ol,u=e.String??so,c=new u({type:"string",error:r.error}),d=new l({type:"boolean",error:r.error}),f=new s({type:"pipe",in:c,out:d,transform:((p,g)=>{let h=p;return r.case!=="sensitive"&&(h=h.toLowerCase()),i.has(h)?!0:a.has(h)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...a],input:g.value,inst:f,continue:!1}),{})}),reverseTransform:((p,g)=>p===!0?o[0]||"true":n[0]||"false"),error:r.error});return f}function po(e,t,r,o={}){const n=P(o),i={...P(o),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...n};return r instanceof RegExp&&(i.pattern=r),new e(i)}function Qr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??wt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function he(e,t,r={path:[],schemaPath:[]}){var o;const n=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const c={...r,schemaPath:[...r.schemaPath,e],path:r.path},d=e._zod.parent;if(d)a.ref=d,he(d,t,c),t.seen.get(d).isParent=!0;else if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,c);else{const f=a.schema,p=t.processors[n.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);p(e,t,f,c)}}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&&Ve(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Xr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const c=e.external.registry.get(i[0])?.id,d=e.external.uri??(p=>p);if(c)return{ref:d(c)};const f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${f}`}}if(i[1]===r)return{ref:"#"};const l=`#/${a}/`,u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},n=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:s,defId:l}=o(i);a.def={...a.schema},l&&(a.defId=l);const u=a.schema;for(const c in u)delete u[c];u.$ref=s};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
27
|
+
`)}p.write("payload.value = newResult;"),p.write("return payload;");const x=p.compile();return($,v)=>x(f,$,v)};let i;const a=Wr,s=!ci.jitless,u=s&&zm.value,c=t.catchall;let d;e._zod.parse=(f,p)=>{d??(d=o.value);const g=f.value;return a(g)?s&&u&&p?.async===!1&&p.jitless!==!0?(i||(i=n(t.shape)),f=i(f,p),c?Vg([],g,f,p,d,e):f):r(f,p):(f.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),f)}});function Ud(e,t,r,o){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const n=e.filter(i=>!mr(i));return n.length===1?(t.value=n[0].value,n[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>ut(a,o,De())))}),t)}const Qi=S("$ZodUnion",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.options.some(n=>n._zod.optin==="optional")?"optional":void 0),ne(e._zod,"optout",()=>t.options.some(n=>n._zod.optout==="optional")?"optional":void 0),ne(e._zod,"values",()=>{if(t.options.every(n=>n._zod.values))return new Set(t.options.flatMap(n=>Array.from(n._zod.values)))}),ne(e._zod,"pattern",()=>{if(t.options.every(n=>n._zod.pattern)){const n=t.options.map(i=>i._zod.pattern);return new RegExp(`^(${n.map(i=>Hi(i.source)).join("|")})$`)}});const r=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(n,i)=>{if(r)return o(n,i);let a=!1;const s=[];for(const l of t.options){const u=l._zod.run({value:n.value,issues:[]},i);if(u instanceof Promise)s.push(u),a=!0;else{if(u.issues.length===0)return u;s.push(u)}}return a?Promise.all(s).then(l=>Ud(l,n,e,i)):Ud(s,n,e,i)}});function Ld(e,t,r,o){const n=e.filter(i=>i.issues.length===0);return n.length===1?(t.value=n[0].value,t):(n.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(i=>i.issues.map(a=>ut(a,o,De())))}):t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:[],inclusive:!1}),t)}const Wg=S("$ZodXor",(e,t)=>{Qi.init(e,t),t.inclusive=!1;const r=t.options.length===1,o=t.options[0]._zod.run;e._zod.parse=(n,i)=>{if(r)return o(n,i);let a=!1;const s=[];for(const l of t.options){const u=l._zod.run({value:n.value,issues:[]},i);u instanceof Promise?(s.push(u),a=!0):s.push(u)}return a?Promise.all(s).then(l=>Ld(l,n,e,i)):Ld(s,n,e,i)}}),Hg=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Qi.init(e,t);const r=e._zod.parse;ne(e._zod,"propValues",()=>{const n={};for(const i of t.options){const a=i._zod.propValues;if(!a||Object.keys(a).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[s,l]of Object.entries(a)){n[s]||(n[s]=new Set);for(const u of l)n[s].add(u)}}return n});const o=Xn(()=>{const n=t.options,i=new Map;for(const a of n){const s=a._zod.propValues?.[t.discriminator];if(!s||s.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(a)}"`);for(const l of s){if(i.has(l))throw new Error(`Duplicate discriminator value "${String(l)}"`);i.set(l,a)}}return i});e._zod.parse=(n,i)=>{const a=n.value;if(!Wr(a))return n.issues.push({code:"invalid_type",expected:"object",input:a,inst:e}),n;const s=o.value.get(a?.[t.discriminator]);return s?s._zod.run(n,i):t.unionFallback?r(n,i):(n.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:a,path:[t.discriminator],inst:e}),n)}}),Gg=S("$ZodIntersection",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value,i=t.left._zod.run({value:n,issues:[]},o),a=t.right._zod.run({value:n,issues:[]},o);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([l,u])=>Zd(r,l,u)):Zd(r,i,a)}});function eu(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(yr(e)&&yr(t)){const r=Object.keys(t),o=Object.keys(e).filter(i=>r.indexOf(i)!==-1),n={...e,...t};for(const i of o){const a=eu(e[i],t[i]);if(!a.valid)return{valid:!1,mergeErrorPath:[i,...a.mergeErrorPath]};n[i]=a.data}return{valid:!0,data:n}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const r=[];for(let o=0;o<e.length;o++){const n=e[o],i=t[o],a=eu(n,i);if(!a.valid)return{valid:!1,mergeErrorPath:[o,...a.mergeErrorPath]};r.push(a.data)}return{valid:!0,data:r}}return{valid:!1,mergeErrorPath:[]}}function Zd(e,t,r){if(t.issues.length&&e.issues.push(...t.issues),r.issues.length&&e.issues.push(...r.issues),mr(e))return e;const o=eu(t.value,r.value);if(!o.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}const al=S("$ZodTuple",(e,t)=>{X.init(e,t);const r=t.items;e._zod.parse=(o,n)=>{const i=o.value;if(!Array.isArray(i))return o.issues.push({input:i,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=[];const a=[],s=[...r].reverse().findIndex(c=>c._zod.optin!=="optional"),l=s===-1?0:r.length-s;if(!t.rest){const c=i.length>r.length,d=i.length<l-1;if(c||d)return o.issues.push({...c?{code:"too_big",maximum:r.length}:{code:"too_small",minimum:r.length},input:i,inst:e,origin:"array"}),o}let u=-1;for(const c of r){if(u++,u>=i.length&&u>=l)continue;const d=c._zod.run({value:i[u],issues:[]},n);d instanceof Promise?a.push(d.then(f=>Uo(f,o,u))):Uo(d,o,u)}if(t.rest){const c=i.slice(r.length);for(const d of c){u++;const f=t.rest._zod.run({value:d,issues:[]},n);f instanceof Promise?a.push(f.then(p=>Uo(p,o,u))):Uo(f,o,u)}}return a.length?Promise.all(a).then(()=>o):o}});function Uo(e,t,r){e.issues.length&&t.issues.push(..._t(r,e.issues)),t.value[r]=e.value}const Kg=S("$ZodRecord",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!yr(n))return r.issues.push({expected:"record",code:"invalid_type",input:n,inst:e}),r;const i=[],a=t.keyType._zod.values;if(a){r.value={};const s=new Set;for(const u of a)if(typeof u=="string"||typeof u=="number"||typeof u=="symbol"){s.add(typeof u=="number"?u.toString():u);const c=t.valueType._zod.run({value:n[u],issues:[]},o);c instanceof Promise?i.push(c.then(d=>{d.issues.length&&r.issues.push(..._t(u,d.issues)),r.value[u]=d.value})):(c.issues.length&&r.issues.push(..._t(u,c.issues)),r.value[u]=c.value)}let l;for(const u in n)s.has(u)||(l=l??[],l.push(u));l&&l.length>0&&r.issues.push({code:"unrecognized_keys",input:n,inst:e,keys:l})}else{r.value={};for(const s of Reflect.ownKeys(n)){if(s==="__proto__")continue;const l=t.keyType._zod.run({value:s,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(l.issues.length){t.mode==="loose"?r.value[s]=n[s]:r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(c=>ut(c,o,De())),input:s,path:[s],inst:e});continue}const u=t.valueType._zod.run({value:n[s],issues:[]},o);u instanceof Promise?i.push(u.then(c=>{c.issues.length&&r.issues.push(..._t(s,c.issues)),r.value[l.value]=c.value})):(u.issues.length&&r.issues.push(..._t(s,u.issues)),r.value[l.value]=u.value)}}return i.length?Promise.all(i).then(()=>r):r}}),Yg=S("$ZodMap",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!(n instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:n,inst:e}),r;const i=[];r.value=new Map;for(const[a,s]of n){const l=t.keyType._zod.run({value:a,issues:[]},o),u=t.valueType._zod.run({value:s,issues:[]},o);l instanceof Promise||u instanceof Promise?i.push(Promise.all([l,u]).then(([c,d])=>{Fd(c,d,r,a,n,e,o)})):Fd(l,u,r,a,n,e,o)}return i.length?Promise.all(i).then(()=>r):r}});function Fd(e,t,r,o,n,i,a){e.issues.length&&(pi.has(typeof o)?r.issues.push(..._t(o,e.issues)):r.issues.push({code:"invalid_key",origin:"map",input:n,inst:i,issues:e.issues.map(s=>ut(s,a,De()))})),t.issues.length&&(pi.has(typeof o)?r.issues.push(..._t(o,t.issues)):r.issues.push({origin:"map",code:"invalid_element",input:n,inst:i,key:o,issues:t.issues.map(s=>ut(s,a,De()))})),r.value.set(e.value,t.value)}const Qg=S("$ZodSet",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;if(!(n instanceof Set))return r.issues.push({input:n,inst:e,expected:"set",code:"invalid_type"}),r;const i=[];r.value=new Set;for(const a of n){const s=t.valueType._zod.run({value:a,issues:[]},o);s instanceof Promise?i.push(s.then(l=>qd(l,r))):qd(s,r)}return i.length?Promise.all(i).then(()=>r):r}});function qd(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const Xg=S("$ZodEnum",(e,t)=>{X.init(e,t);const r=Uu(t.entries),o=new Set(r);e._zod.values=o,e._zod.pattern=new RegExp(`^(${r.filter(n=>pi.has(typeof n)).map(n=>typeof n=="string"?qt(n):n.toString()).join("|")})$`),e._zod.parse=(n,i)=>{const a=n.value;return o.has(a)||n.issues.push({code:"invalid_value",values:r,input:a,inst:e}),n}}),ev=S("$ZodLiteral",(e,t)=>{if(X.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?qt(o):o?qt(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,n)=>{const i=o.value;return r.has(i)||o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),tv=S("$ZodFile",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{const n=r.value;return n instanceof File||r.issues.push({expected:"file",code:"invalid_type",input:n,inst:e}),r}}),rv=S("$ZodTransform",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Wi(e.constructor.name);const n=t.transform(r.value,r);if(o.async)return(n instanceof Promise?n:Promise.resolve(n)).then(a=>(r.value=a,r));if(n instanceof Promise)throw new vr;return r.value=n,r}});function Vd(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}const nv=S("$ZodOptional",(e,t)=>{X.init(e,t),e._zod.optin="optional",e._zod.optout="optional",ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),ne(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Hi(r.source)})?$`):void 0}),e._zod.parse=(r,o)=>{if(t.innerType._zod.optin==="optional"){const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>Vd(i,r.value)):Vd(n,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,o)}}),ov=S("$ZodNullable",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"pattern",()=>{const r=t.innerType._zod.pattern;return r?new RegExp(`^(${Hi(r.source)}|null)$`):void 0}),ne(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,o)=>r.value===null?r:t.innerType._zod.run(r,o)}),iv=S("$ZodDefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);if(r.value===void 0)return r.value=t.defaultValue,r;const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>Bd(i,t)):Bd(n,t)}});function Bd(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const av=S("$ZodPrefault",(e,t)=>{X.init(e,t),e._zod.optin="optional",ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>(o.direction==="backward"||r.value===void 0&&(r.value=t.defaultValue),t.innerType._zod.run(r,o))}),sv=S("$ZodNonOptional",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>{const r=t.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(r,o)=>{const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>Jd(i,e)):Jd(n,e)}});function Jd(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const uv=S("$ZodSuccess",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Wi("ZodSuccess");const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>(r.value=i.issues.length===0,r)):(r.value=n.issues.length===0,r)}}),lv=S("$ZodCatch",(e,t)=>{X.init(e,t),ne(e._zod,"optin",()=>t.innerType._zod.optin),ne(e._zod,"optout",()=>t.innerType._zod.optout),ne(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(i=>(r.value=i.value,i.issues.length&&(r.value=t.catchValue({...r,error:{issues:i.issues.map(a=>ut(a,o,De()))},input:r.value}),r.issues=[]),r)):(r.value=n.value,n.issues.length&&(r.value=t.catchValue({...r,error:{issues:n.issues.map(i=>ut(i,o,De()))},input:r.value}),r.issues=[]),r)}}),cv=S("$ZodNaN",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>((typeof r.value!="number"||!Number.isNaN(r.value))&&r.issues.push({input:r.value,inst:e,expected:"nan",code:"invalid_type"}),r)}),dv=S("$ZodPipe",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>t.in._zod.values),ne(e._zod,"optin",()=>t.in._zod.optin),ne(e._zod,"optout",()=>t.out._zod.optout),ne(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if(o.direction==="backward"){const i=t.out._zod.run(r,o);return i instanceof Promise?i.then(a=>Lo(a,t.in,o)):Lo(i,t.in,o)}const n=t.in._zod.run(r,o);return n instanceof Promise?n.then(i=>Lo(i,t.out,o)):Lo(n,t.out,o)}});function Lo(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}const sl=S("$ZodCodec",(e,t)=>{X.init(e,t),ne(e._zod,"values",()=>t.in._zod.values),ne(e._zod,"optin",()=>t.in._zod.optin),ne(e._zod,"optout",()=>t.out._zod.optout),ne(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,o)=>{if((o.direction||"forward")==="forward"){const i=t.in._zod.run(r,o);return i instanceof Promise?i.then(a=>Zo(a,t,o)):Zo(i,t,o)}else{const i=t.out._zod.run(r,o);return i instanceof Promise?i.then(a=>Zo(a,t,o)):Zo(i,t,o)}}});function Zo(e,t,r){if(e.issues.length)return e.aborted=!0,e;if((r.direction||"forward")==="forward"){const n=t.transform(e.value,e);return n instanceof Promise?n.then(i=>Fo(e,i,t.out,r)):Fo(e,n,t.out,r)}else{const n=t.reverseTransform(e.value,e);return n instanceof Promise?n.then(i=>Fo(e,i,t.in,r)):Fo(e,n,t.in,r)}}function Fo(e,t,r,o){return e.issues.length?(e.aborted=!0,e):r._zod.run({value:t,issues:e.issues},o)}const pv=S("$ZodReadonly",(e,t)=>{X.init(e,t),ne(e._zod,"propValues",()=>t.innerType._zod.propValues),ne(e._zod,"values",()=>t.innerType._zod.values),ne(e._zod,"optin",()=>t.innerType?._zod?.optin),ne(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(r,o)=>{if(o.direction==="backward")return t.innerType._zod.run(r,o);const n=t.innerType._zod.run(r,o);return n instanceof Promise?n.then(Wd):Wd(n)}});function Wd(e){return e.value=Object.freeze(e.value),e}const fv=S("$ZodTemplateLiteral",(e,t)=>{X.init(e,t);const r=[];for(const o of t.parts)if(typeof o=="object"&&o!==null){if(!o._zod.pattern)throw new Error(`Invalid template literal part, no pattern found: ${[...o._zod.traits].shift()}`);const n=o._zod.pattern instanceof RegExp?o._zod.pattern.source:o._zod.pattern;if(!n)throw new Error(`Invalid template literal part: ${o._zod.traits}`);const i=n.startsWith("^")?1:0,a=n.endsWith("$")?n.length-1:n.length;r.push(n.slice(i,a))}else if(o===null||Mm.has(typeof o))r.push(qt(`${o}`));else throw new Error(`Invalid template literal part: ${o}`);e._zod.pattern=new RegExp(`^${r.join("")}$`),e._zod.parse=(o,n)=>typeof o.value!="string"?(o.issues.push({input:o.value,inst:e,expected:"template_literal",code:"invalid_type"}),o):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(o.value)||o.issues.push({input:o.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),o)}),mv=S("$ZodFunction",(e,t)=>(X.init(e,t),e._def=t,e._zod.def=t,e.implement=r=>{if(typeof r!="function")throw new Error("implement() must be called with a function");return function(...o){const n=e._def.input?Qs(e._def.input,o):o,i=Reflect.apply(r,this,n);return e._def.output?Qs(e._def.output,i):i}},e.implementAsync=r=>{if(typeof r!="function")throw new Error("implementAsync() must be called with a function");return async function(...o){const n=e._def.input?await Xs(e._def.input,o):o,i=await Reflect.apply(r,this,n);return e._def.output?await Xs(e._def.output,i):i}},e._zod.parse=(r,o)=>typeof r.value!="function"?(r.issues.push({code:"invalid_type",expected:"function",input:r.value,inst:e}),r):(e._def.output&&e._def.output._zod.def.type==="promise"?r.value=e.implementAsync(r.value):r.value=e.implement(r.value),r),e.input=(...r)=>{const o=e.constructor;return Array.isArray(r[0])?new o({type:"function",input:new al({type:"tuple",items:r[0],rest:r[1]}),output:e._def.output}):new o({type:"function",input:r[0],output:e._def.output})},e.output=r=>{const o=e.constructor;return new o({type:"function",input:e._def.input,output:r})},e)),hv=S("$ZodPromise",(e,t)=>{X.init(e,t),e._zod.parse=(r,o)=>Promise.resolve(r.value).then(n=>t.innerType._zod.run({value:n,issues:[]},o))}),gv=S("$ZodLazy",(e,t)=>{X.init(e,t),ne(e._zod,"innerType",()=>t.getter()),ne(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),ne(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),ne(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),ne(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(r,o)=>e._zod.innerType._zod.run(r,o)}),vv=S("$ZodCustom",(e,t)=>{Se.init(e,t),X.init(e,t),e._zod.parse=(r,o)=>r,e._zod.check=r=>{const o=r.value,n=t.fn(o);if(n instanceof Promise)return n.then(i=>Hd(i,r,o,e));Hd(n,r,o,e)}});function Hd(e,t,r,o){if(!e){const n={code:"custom",input:r,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(n.params=o._zod.def.params),t.issues.push(Hr(n))}}const RI=()=>{const e={string:{unit:"حرف",verb:"أن يحوي"},file:{unit:"بايت",verb:"أن يحوي"},array:{unit:"عنصر",verb:"أن يحوي"},set:{unit:"عنصر",verb:"أن يحوي"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"مدخل",email:"بريد إلكتروني",url:"رابط",emoji:"إيموجي",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"تاريخ ووقت بمعيار ISO",date:"تاريخ بمعيار ISO",time:"وقت بمعيار ISO",duration:"مدة بمعيار ISO",ipv4:"عنوان IPv4",ipv6:"عنوان IPv6",cidrv4:"مدى عناوين بصيغة IPv4",cidrv6:"مدى عناوين بصيغة IPv6",base64:"نَص بترميز base64-encoded",base64url:"نَص بترميز base64url-encoded",json_string:"نَص على هيئة JSON",e164:"رقم هاتف بمعيار E.164",jwt:"JWT",template_literal:"مدخل"};return n=>{switch(n.code){case"invalid_type":return`مدخلات غير مقبولة: يفترض إدخال ${n.expected}، ولكن تم إدخال ${r(n.input)}`;case"invalid_value":return n.values.length===1?`مدخلات غير مقبولة: يفترض إدخال ${H(n.values[0])}`:`اختيار غير مقبول: يتوقع انتقاء أحد هذه الخيارات: ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?` أكبر من اللازم: يفترض أن تكون ${n.origin??"القيمة"} ${i} ${n.maximum.toString()} ${a.unit??"عنصر"}`:`أكبر من اللازم: يفترض أن تكون ${n.origin??"القيمة"} ${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`أصغر من اللازم: يفترض لـ ${n.origin} أن يكون ${i} ${n.minimum.toString()} ${a.unit}`:`أصغر من اللازم: يفترض لـ ${n.origin} أن يكون ${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`نَص غير مقبول: يجب أن يبدأ بـ "${n.prefix}"`:i.format==="ends_with"?`نَص غير مقبول: يجب أن ينتهي بـ "${i.suffix}"`:i.format==="includes"?`نَص غير مقبول: يجب أن يتضمَّن "${i.includes}"`:i.format==="regex"?`نَص غير مقبول: يجب أن يطابق النمط ${i.pattern}`:`${o[i.format]??n.format} غير مقبول`}case"not_multiple_of":return`رقم غير مقبول: يجب أن يكون من مضاعفات ${n.divisor}`;case"unrecognized_keys":return`معرف${n.keys.length>1?"ات":""} غريب${n.keys.length>1?"ة":""}: ${j(n.keys,"، ")}`;case"invalid_key":return`معرف غير مقبول في ${n.origin}`;case"invalid_union":return"مدخل غير مقبول";case"invalid_element":return`مدخل غير مقبول في ${n.origin}`;default:return"مدخل غير مقبول"}}};function zI(){return{localeError:RI()}}const MI=()=>{const e={string:{unit:"simvol",verb:"olmalıdır"},file:{unit:"bayt",verb:"olmalıdır"},array:{unit:"element",verb:"olmalıdır"},set:{unit:"element",verb:"olmalıdır"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Yanlış dəyər: gözlənilən ${n.expected}, daxil olan ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Yanlış dəyər: gözlənilən ${H(n.values[0])}`:`Yanlış seçim: aşağıdakılardan biri olmalıdır: ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Çox böyük: gözlənilən ${n.origin??"dəyər"} ${i}${n.maximum.toString()} ${a.unit??"element"}`:`Çox böyük: gözlənilən ${n.origin??"dəyər"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Çox kiçik: gözlənilən ${n.origin} ${i}${n.minimum.toString()} ${a.unit}`:`Çox kiçik: gözlənilən ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Yanlış mətn: "${i.prefix}" ilə başlamalıdır`:i.format==="ends_with"?`Yanlış mətn: "${i.suffix}" ilə bitməlidir`:i.format==="includes"?`Yanlış mətn: "${i.includes}" daxil olmalıdır`:i.format==="regex"?`Yanlış mətn: ${i.pattern} şablonuna uyğun olmalıdır`:`Yanlış ${o[i.format]??n.format}`}case"not_multiple_of":return`Yanlış ədəd: ${n.divisor} ilə bölünə bilən olmalıdır`;case"unrecognized_keys":return`Tanınmayan açar${n.keys.length>1?"lar":""}: ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} daxilində yanlış açar`;case"invalid_union":return"Yanlış dəyər";case"invalid_element":return`${n.origin} daxilində yanlış dəyər`;default:return"Yanlış dəyər"}}};function DI(){return{localeError:MI()}}function Gd(e,t,r,o){const n=Math.abs(e),i=n%10,a=n%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?r:o}const UI=()=>{const e={string:{unit:{one:"сімвал",few:"сімвалы",many:"сімвалаў"},verb:"мець"},array:{unit:{one:"элемент",few:"элементы",many:"элементаў"},verb:"мець"},set:{unit:{one:"элемент",few:"элементы",many:"элементаў"},verb:"мець"},file:{unit:{one:"байт",few:"байты",many:"байтаў"},verb:"мець"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"лік";case"object":{if(Array.isArray(n))return"масіў";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"увод",email:"email адрас",url:"URL",emoji:"эмодзі",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO дата і час",date:"ISO дата",time:"ISO час",duration:"ISO працягласць",ipv4:"IPv4 адрас",ipv6:"IPv6 адрас",cidrv4:"IPv4 дыяпазон",cidrv6:"IPv6 дыяпазон",base64:"радок у фармаце base64",base64url:"радок у фармаце base64url",json_string:"JSON радок",e164:"нумар E.164",jwt:"JWT",template_literal:"увод"};return n=>{switch(n.code){case"invalid_type":return`Няправільны ўвод: чакаўся ${n.expected}, атрымана ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Няправільны ўвод: чакалася ${H(n.values[0])}`:`Няправільны варыянт: чакаўся адзін з ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);if(a){const s=Number(n.maximum),l=Gd(s,a.unit.one,a.unit.few,a.unit.many);return`Занадта вялікі: чакалася, што ${n.origin??"значэнне"} павінна ${a.verb} ${i}${n.maximum.toString()} ${l}`}return`Занадта вялікі: чакалася, што ${n.origin??"значэнне"} павінна быць ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);if(a){const s=Number(n.minimum),l=Gd(s,a.unit.one,a.unit.few,a.unit.many);return`Занадта малы: чакалася, што ${n.origin} павінна ${a.verb} ${i}${n.minimum.toString()} ${l}`}return`Занадта малы: чакалася, што ${n.origin} павінна быць ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Няправільны радок: павінен пачынацца з "${i.prefix}"`:i.format==="ends_with"?`Няправільны радок: павінен заканчвацца на "${i.suffix}"`:i.format==="includes"?`Няправільны радок: павінен змяшчаць "${i.includes}"`:i.format==="regex"?`Няправільны радок: павінен адпавядаць шаблону ${i.pattern}`:`Няправільны ${o[i.format]??n.format}`}case"not_multiple_of":return`Няправільны лік: павінен быць кратным ${n.divisor}`;case"unrecognized_keys":return`Нераспазнаны ${n.keys.length>1?"ключы":"ключ"}: ${j(n.keys,", ")}`;case"invalid_key":return`Няправільны ключ у ${n.origin}`;case"invalid_union":return"Няправільны ўвод";case"invalid_element":return`Няправільнае значэнне ў ${n.origin}`;default:return"Няправільны ўвод"}}};function LI(){return{localeError:UI()}}const ZI=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"число";case"object":{if(Array.isArray(e))return"масив";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},FI=()=>{const e={string:{unit:"символа",verb:"да съдържа"},file:{unit:"байта",verb:"да съдържа"},array:{unit:"елемента",verb:"да съдържа"},set:{unit:"елемента",verb:"да съдържа"}};function t(o){return e[o]??null}const r={regex:"вход",email:"имейл адрес",url:"URL",emoji:"емоджи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO време",date:"ISO дата",time:"ISO време",duration:"ISO продължителност",ipv4:"IPv4 адрес",ipv6:"IPv6 адрес",cidrv4:"IPv4 диапазон",cidrv6:"IPv6 диапазон",base64:"base64-кодиран низ",base64url:"base64url-кодиран низ",json_string:"JSON низ",e164:"E.164 номер",jwt:"JWT",template_literal:"вход"};return o=>{switch(o.code){case"invalid_type":return`Невалиден вход: очакван ${o.expected}, получен ${ZI(o.input)}`;case"invalid_value":return o.values.length===1?`Невалиден вход: очакван ${H(o.values[0])}`:`Невалидна опция: очаквано едно от ${j(o.values,"|")}`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Твърде голямо: очаква се ${o.origin??"стойност"} да съдържа ${n}${o.maximum.toString()} ${i.unit??"елемента"}`:`Твърде голямо: очаква се ${o.origin??"стойност"} да бъде ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Твърде малко: очаква се ${o.origin} да съдържа ${n}${o.minimum.toString()} ${i.unit}`:`Твърде малко: очаква се ${o.origin} да бъде ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;if(n.format==="starts_with")return`Невалиден низ: трябва да започва с "${n.prefix}"`;if(n.format==="ends_with")return`Невалиден низ: трябва да завършва с "${n.suffix}"`;if(n.format==="includes")return`Невалиден низ: трябва да включва "${n.includes}"`;if(n.format==="regex")return`Невалиден низ: трябва да съвпада с ${n.pattern}`;let i="Невалиден";return n.format==="emoji"&&(i="Невалидно"),n.format==="datetime"&&(i="Невалидно"),n.format==="date"&&(i="Невалидна"),n.format==="time"&&(i="Невалидно"),n.format==="duration"&&(i="Невалидна"),`${i} ${r[n.format]??o.format}`}case"not_multiple_of":return`Невалидно число: трябва да бъде кратно на ${o.divisor}`;case"unrecognized_keys":return`Неразпознат${o.keys.length>1?"и":""} ключ${o.keys.length>1?"ове":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Невалиден ключ в ${o.origin}`;case"invalid_union":return"Невалиден вход";case"invalid_element":return`Невалидна стойност в ${o.origin}`;default:return"Невалиден вход"}}};function qI(){return{localeError:FI()}}const VI=()=>{const e={string:{unit:"caràcters",verb:"contenir"},file:{unit:"bytes",verb:"contenir"},array:{unit:"elements",verb:"contenir"},set:{unit:"elements",verb:"contenir"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"entrada",email:"adreça electrònica",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i hora ISO",date:"data ISO",time:"hora ISO",duration:"durada ISO",ipv4:"adreça IPv4",ipv6:"adreça IPv6",cidrv4:"rang IPv4",cidrv6:"rang IPv6",base64:"cadena codificada en base64",base64url:"cadena codificada en base64url",json_string:"cadena JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return n=>{switch(n.code){case"invalid_type":return`Tipus invàlid: s'esperava ${n.expected}, s'ha rebut ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Valor invàlid: s'esperava ${H(n.values[0])}`:`Opció invàlida: s'esperava una de ${j(n.values," o ")}`;case"too_big":{const i=n.inclusive?"com a màxim":"menys de",a=t(n.origin);return a?`Massa gran: s'esperava que ${n.origin??"el valor"} contingués ${i} ${n.maximum.toString()} ${a.unit??"elements"}`:`Massa gran: s'esperava que ${n.origin??"el valor"} fos ${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?"com a mínim":"més de",a=t(n.origin);return a?`Massa petit: s'esperava que ${n.origin} contingués ${i} ${n.minimum.toString()} ${a.unit}`:`Massa petit: s'esperava que ${n.origin} fos ${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Format invàlid: ha de començar amb "${i.prefix}"`:i.format==="ends_with"?`Format invàlid: ha d'acabar amb "${i.suffix}"`:i.format==="includes"?`Format invàlid: ha d'incloure "${i.includes}"`:i.format==="regex"?`Format invàlid: ha de coincidir amb el patró ${i.pattern}`:`Format invàlid per a ${o[i.format]??n.format}`}case"not_multiple_of":return`Número invàlid: ha de ser múltiple de ${n.divisor}`;case"unrecognized_keys":return`Clau${n.keys.length>1?"s":""} no reconeguda${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Clau invàlida a ${n.origin}`;case"invalid_union":return"Entrada invàlida";case"invalid_element":return`Element invàlid a ${n.origin}`;default:return"Entrada invàlida"}}};function BI(){return{localeError:VI()}}const JI=()=>{const e={string:{unit:"znaků",verb:"mít"},file:{unit:"bajtů",verb:"mít"},array:{unit:"prvků",verb:"mít"},set:{unit:"prvků",verb:"mít"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"číslo";case"string":return"řetězec";case"boolean":return"boolean";case"bigint":return"bigint";case"function":return"funkce";case"symbol":return"symbol";case"undefined":return"undefined";case"object":{if(Array.isArray(n))return"pole";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"regulární výraz",email:"e-mailová adresa",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"datum a čas ve formátu ISO",date:"datum ve formátu ISO",time:"čas ve formátu ISO",duration:"doba trvání ISO",ipv4:"IPv4 adresa",ipv6:"IPv6 adresa",cidrv4:"rozsah IPv4",cidrv6:"rozsah IPv6",base64:"řetězec zakódovaný ve formátu base64",base64url:"řetězec zakódovaný ve formátu base64url",json_string:"řetězec ve formátu JSON",e164:"číslo E.164",jwt:"JWT",template_literal:"vstup"};return n=>{switch(n.code){case"invalid_type":return`Neplatný vstup: očekáváno ${n.expected}, obdrženo ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Neplatný vstup: očekáváno ${H(n.values[0])}`:`Neplatná možnost: očekávána jedna z hodnot ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Hodnota je příliš velká: ${n.origin??"hodnota"} musí mít ${i}${n.maximum.toString()} ${a.unit??"prvků"}`:`Hodnota je příliš velká: ${n.origin??"hodnota"} musí být ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Hodnota je příliš malá: ${n.origin??"hodnota"} musí mít ${i}${n.minimum.toString()} ${a.unit??"prvků"}`:`Hodnota je příliš malá: ${n.origin??"hodnota"} musí být ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Neplatný řetězec: musí začínat na "${i.prefix}"`:i.format==="ends_with"?`Neplatný řetězec: musí končit na "${i.suffix}"`:i.format==="includes"?`Neplatný řetězec: musí obsahovat "${i.includes}"`:i.format==="regex"?`Neplatný řetězec: musí odpovídat vzoru ${i.pattern}`:`Neplatný formát ${o[i.format]??n.format}`}case"not_multiple_of":return`Neplatné číslo: musí být násobkem ${n.divisor}`;case"unrecognized_keys":return`Neznámé klíče: ${j(n.keys,", ")}`;case"invalid_key":return`Neplatný klíč v ${n.origin}`;case"invalid_union":return"Neplatný vstup";case"invalid_element":return`Neplatná hodnota v ${n.origin}`;default:return"Neplatný vstup"}}};function WI(){return{localeError:JI()}}const HI=()=>{const e={string:{unit:"tegn",verb:"havde"},file:{unit:"bytes",verb:"havde"},array:{unit:"elementer",verb:"indeholdt"},set:{unit:"elementer",verb:"indeholdt"}},t={string:"streng",number:"tal",boolean:"boolean",array:"liste",object:"objekt",set:"sæt",file:"fil"};function r(a){return e[a]??null}function o(a){return t[a]??a}const n=a=>{const s=typeof a;switch(s){case"number":return Number.isNaN(a)?"NaN":"tal";case"object":return Array.isArray(a)?"liste":a===null?"null":Object.getPrototypeOf(a)!==Object.prototype&&a.constructor?a.constructor.name:"objekt"}return s},i={regex:"input",email:"e-mailadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslæt",date:"ISO-dato",time:"ISO-klokkeslæt",duration:"ISO-varighed",ipv4:"IPv4-område",ipv6:"IPv6-område",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodet streng",base64url:"base64url-kodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"};return a=>{switch(a.code){case"invalid_type":return`Ugyldigt input: forventede ${o(a.expected)}, fik ${o(n(a.input))}`;case"invalid_value":return a.values.length===1?`Ugyldig værdi: forventede ${H(a.values[0])}`:`Ugyldigt valg: forventede en af følgende ${j(a.values,"|")}`;case"too_big":{const s=a.inclusive?"<=":"<",l=r(a.origin),u=o(a.origin);return l?`For stor: forventede ${u??"value"} ${l.verb} ${s} ${a.maximum.toString()} ${l.unit??"elementer"}`:`For stor: forventede ${u??"value"} havde ${s} ${a.maximum.toString()}`}case"too_small":{const s=a.inclusive?">=":">",l=r(a.origin),u=o(a.origin);return l?`For lille: forventede ${u} ${l.verb} ${s} ${a.minimum.toString()} ${l.unit}`:`For lille: forventede ${u} havde ${s} ${a.minimum.toString()}`}case"invalid_format":{const s=a;return s.format==="starts_with"?`Ugyldig streng: skal starte med "${s.prefix}"`:s.format==="ends_with"?`Ugyldig streng: skal ende med "${s.suffix}"`:s.format==="includes"?`Ugyldig streng: skal indeholde "${s.includes}"`:s.format==="regex"?`Ugyldig streng: skal matche mønsteret ${s.pattern}`:`Ugyldig ${i[s.format]??a.format}`}case"not_multiple_of":return`Ugyldigt tal: skal være deleligt med ${a.divisor}`;case"unrecognized_keys":return`${a.keys.length>1?"Ukendte nøgler":"Ukendt nøgle"}: ${j(a.keys,", ")}`;case"invalid_key":return`Ugyldig nøgle i ${a.origin}`;case"invalid_union":return"Ugyldigt input: matcher ingen af de tilladte typer";case"invalid_element":return`Ugyldig værdi i ${a.origin}`;default:return"Ugyldigt input"}}};function GI(){return{localeError:HI()}}const KI=()=>{const e={string:{unit:"Zeichen",verb:"zu haben"},file:{unit:"Bytes",verb:"zu haben"},array:{unit:"Elemente",verb:"zu haben"},set:{unit:"Elemente",verb:"zu haben"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"Zahl";case"object":{if(Array.isArray(n))return"Array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"Eingabe",email:"E-Mail-Adresse",url:"URL",emoji:"Emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-Datum und -Uhrzeit",date:"ISO-Datum",time:"ISO-Uhrzeit",duration:"ISO-Dauer",ipv4:"IPv4-Adresse",ipv6:"IPv6-Adresse",cidrv4:"IPv4-Bereich",cidrv6:"IPv6-Bereich",base64:"Base64-codierter String",base64url:"Base64-URL-codierter String",json_string:"JSON-String",e164:"E.164-Nummer",jwt:"JWT",template_literal:"Eingabe"};return n=>{switch(n.code){case"invalid_type":return`Ungültige Eingabe: erwartet ${n.expected}, erhalten ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ungültige Eingabe: erwartet ${H(n.values[0])}`:`Ungültige Option: erwartet eine von ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Zu groß: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ${a.unit??"Elemente"} hat`:`Zu groß: erwartet, dass ${n.origin??"Wert"} ${i}${n.maximum.toString()} ist`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ${a.unit} hat`:`Zu klein: erwartet, dass ${n.origin} ${i}${n.minimum.toString()} ist`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Ungültiger String: muss mit "${i.prefix}" beginnen`:i.format==="ends_with"?`Ungültiger String: muss mit "${i.suffix}" enden`:i.format==="includes"?`Ungültiger String: muss "${i.includes}" enthalten`:i.format==="regex"?`Ungültiger String: muss dem Muster ${i.pattern} entsprechen`:`Ungültig: ${o[i.format]??n.format}`}case"not_multiple_of":return`Ungültige Zahl: muss ein Vielfaches von ${n.divisor} sein`;case"unrecognized_keys":return`${n.keys.length>1?"Unbekannte Schlüssel":"Unbekannter Schlüssel"}: ${j(n.keys,", ")}`;case"invalid_key":return`Ungültiger Schlüssel in ${n.origin}`;case"invalid_union":return"Ungültige Eingabe";case"invalid_element":return`Ungültiger Wert in ${n.origin}`;default:return"Ungültige Eingabe"}}};function YI(){return{localeError:KI()}}const QI=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},XI=()=>{const e={string:{unit:"characters",verb:"to have"},file:{unit:"bytes",verb:"to have"},array:{unit:"items",verb:"to have"},set:{unit:"items",verb:"to have"}};function t(o){return e[o]??null}const r={regex:"input",email:"email address",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datetime",date:"ISO date",time:"ISO time",duration:"ISO duration",ipv4:"IPv4 address",ipv6:"IPv6 address",mac:"MAC address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded string",base64url:"base64url-encoded string",json_string:"JSON string",e164:"E.164 number",jwt:"JWT",template_literal:"input"};return o=>{switch(o.code){case"invalid_type":return`Invalid input: expected ${o.expected}, received ${QI(o.input)}`;case"invalid_value":return o.values.length===1?`Invalid input: expected ${H(o.values[0])}`:`Invalid option: expected one of ${j(o.values,"|")}`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Too big: expected ${o.origin??"value"} to have ${n}${o.maximum.toString()} ${i.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Too small: expected ${o.origin} to have ${n}${o.minimum.toString()} ${i.unit}`:`Too small: expected ${o.origin} to be ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Invalid string: must start with "${n.prefix}"`:n.format==="ends_with"?`Invalid string: must end with "${n.suffix}"`:n.format==="includes"?`Invalid string: must include "${n.includes}"`:n.format==="regex"?`Invalid string: must match pattern ${n.pattern}`:`Invalid ${r[n.format]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function yv(){return{localeError:XI()}}const ek=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"nombro";case"object":{if(Array.isArray(e))return"tabelo";if(e===null)return"senvalora";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},tk=()=>{const e={string:{unit:"karaktrojn",verb:"havi"},file:{unit:"bajtojn",verb:"havi"},array:{unit:"elementojn",verb:"havi"},set:{unit:"elementojn",verb:"havi"}};function t(o){return e[o]??null}const r={regex:"enigo",email:"retadreso",url:"URL",emoji:"emoĝio",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datotempo",date:"ISO-dato",time:"ISO-tempo",duration:"ISO-daŭro",ipv4:"IPv4-adreso",ipv6:"IPv6-adreso",cidrv4:"IPv4-rango",cidrv6:"IPv6-rango",base64:"64-ume kodita karaktraro",base64url:"URL-64-ume kodita karaktraro",json_string:"JSON-karaktraro",e164:"E.164-nombro",jwt:"JWT",template_literal:"enigo"};return o=>{switch(o.code){case"invalid_type":return`Nevalida enigo: atendiĝis ${o.expected}, riceviĝis ${ek(o.input)}`;case"invalid_value":return o.values.length===1?`Nevalida enigo: atendiĝis ${H(o.values[0])}`:`Nevalida opcio: atendiĝis unu el ${j(o.values,"|")}`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Tro granda: atendiĝis ke ${o.origin??"valoro"} havu ${n}${o.maximum.toString()} ${i.unit??"elementojn"}`:`Tro granda: atendiĝis ke ${o.origin??"valoro"} havu ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Tro malgranda: atendiĝis ke ${o.origin} havu ${n}${o.minimum.toString()} ${i.unit}`:`Tro malgranda: atendiĝis ke ${o.origin} estu ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Nevalida karaktraro: devas komenciĝi per "${n.prefix}"`:n.format==="ends_with"?`Nevalida karaktraro: devas finiĝi per "${n.suffix}"`:n.format==="includes"?`Nevalida karaktraro: devas inkluzivi "${n.includes}"`:n.format==="regex"?`Nevalida karaktraro: devas kongrui kun la modelo ${n.pattern}`:`Nevalida ${r[n.format]??o.format}`}case"not_multiple_of":return`Nevalida nombro: devas esti oblo de ${o.divisor}`;case"unrecognized_keys":return`Nekonata${o.keys.length>1?"j":""} ŝlosilo${o.keys.length>1?"j":""}: ${j(o.keys,", ")}`;case"invalid_key":return`Nevalida ŝlosilo en ${o.origin}`;case"invalid_union":return"Nevalida enigo";case"invalid_element":return`Nevalida valoro en ${o.origin}`;default:return"Nevalida enigo"}}};function rk(){return{localeError:tk()}}const nk=()=>{const e={string:{unit:"caracteres",verb:"tener"},file:{unit:"bytes",verb:"tener"},array:{unit:"elementos",verb:"tener"},set:{unit:"elementos",verb:"tener"}},t={string:"texto",number:"número",boolean:"booleano",array:"arreglo",object:"objeto",set:"conjunto",file:"archivo",date:"fecha",bigint:"número grande",symbol:"símbolo",undefined:"indefinido",null:"nulo",function:"función",map:"mapa",record:"registro",tuple:"tupla",enum:"enumeración",union:"unión",literal:"literal",promise:"promesa",void:"vacío",never:"nunca",unknown:"desconocido",any:"cualquiera"};function r(a){return e[a]??null}function o(a){return t[a]??a}const n=a=>{const s=typeof a;switch(s){case"number":return Number.isNaN(a)?"NaN":"number";case"object":return Array.isArray(a)?"array":a===null?"null":Object.getPrototypeOf(a)!==Object.prototype?a.constructor.name:"object"}return s},i={regex:"entrada",email:"dirección de correo electrónico",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"fecha y hora ISO",date:"fecha ISO",time:"hora ISO",duration:"duración ISO",ipv4:"dirección IPv4",ipv6:"dirección IPv6",cidrv4:"rango IPv4",cidrv6:"rango IPv6",base64:"cadena codificada en base64",base64url:"URL codificada en base64",json_string:"cadena JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return a=>{switch(a.code){case"invalid_type":return`Entrada inválida: se esperaba ${o(a.expected)}, recibido ${o(n(a.input))}`;case"invalid_value":return a.values.length===1?`Entrada inválida: se esperaba ${H(a.values[0])}`:`Opción inválida: se esperaba una de ${j(a.values,"|")}`;case"too_big":{const s=a.inclusive?"<=":"<",l=r(a.origin),u=o(a.origin);return l?`Demasiado grande: se esperaba que ${u??"valor"} tuviera ${s}${a.maximum.toString()} ${l.unit??"elementos"}`:`Demasiado grande: se esperaba que ${u??"valor"} fuera ${s}${a.maximum.toString()}`}case"too_small":{const s=a.inclusive?">=":">",l=r(a.origin),u=o(a.origin);return l?`Demasiado pequeño: se esperaba que ${u} tuviera ${s}${a.minimum.toString()} ${l.unit}`:`Demasiado pequeño: se esperaba que ${u} fuera ${s}${a.minimum.toString()}`}case"invalid_format":{const s=a;return s.format==="starts_with"?`Cadena inválida: debe comenzar con "${s.prefix}"`:s.format==="ends_with"?`Cadena inválida: debe terminar en "${s.suffix}"`:s.format==="includes"?`Cadena inválida: debe incluir "${s.includes}"`:s.format==="regex"?`Cadena inválida: debe coincidir con el patrón ${s.pattern}`:`Inválido ${i[s.format]??a.format}`}case"not_multiple_of":return`Número inválido: debe ser múltiplo de ${a.divisor}`;case"unrecognized_keys":return`Llave${a.keys.length>1?"s":""} desconocida${a.keys.length>1?"s":""}: ${j(a.keys,", ")}`;case"invalid_key":return`Llave inválida en ${o(a.origin)}`;case"invalid_union":return"Entrada inválida";case"invalid_element":return`Valor inválido en ${o(a.origin)}`;default:return"Entrada inválida"}}};function ok(){return{localeError:nk()}}const ik=()=>{const e={string:{unit:"کاراکتر",verb:"داشته باشد"},file:{unit:"بایت",verb:"داشته باشد"},array:{unit:"آیتم",verb:"داشته باشد"},set:{unit:"آیتم",verb:"داشته باشد"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"عدد";case"object":{if(Array.isArray(n))return"آرایه";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ورودی",email:"آدرس ایمیل",url:"URL",emoji:"ایموجی",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"تاریخ و زمان ایزو",date:"تاریخ ایزو",time:"زمان ایزو",duration:"مدت زمان ایزو",ipv4:"IPv4 آدرس",ipv6:"IPv6 آدرس",cidrv4:"IPv4 دامنه",cidrv6:"IPv6 دامنه",base64:"base64-encoded رشته",base64url:"base64url-encoded رشته",json_string:"JSON رشته",e164:"E.164 عدد",jwt:"JWT",template_literal:"ورودی"};return n=>{switch(n.code){case"invalid_type":return`ورودی نامعتبر: میبایست ${n.expected} میبود، ${r(n.input)} دریافت شد`;case"invalid_value":return n.values.length===1?`ورودی نامعتبر: میبایست ${H(n.values[0])} میبود`:`گزینه نامعتبر: میبایست یکی از ${j(n.values,"|")} میبود`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`خیلی بزرگ: ${n.origin??"مقدار"} باید ${i}${n.maximum.toString()} ${a.unit??"عنصر"} باشد`:`خیلی بزرگ: ${n.origin??"مقدار"} باید ${i}${n.maximum.toString()} باشد`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`خیلی کوچک: ${n.origin} باید ${i}${n.minimum.toString()} ${a.unit} باشد`:`خیلی کوچک: ${n.origin} باید ${i}${n.minimum.toString()} باشد`}case"invalid_format":{const i=n;return i.format==="starts_with"?`رشته نامعتبر: باید با "${i.prefix}" شروع شود`:i.format==="ends_with"?`رشته نامعتبر: باید با "${i.suffix}" تمام شود`:i.format==="includes"?`رشته نامعتبر: باید شامل "${i.includes}" باشد`:i.format==="regex"?`رشته نامعتبر: باید با الگوی ${i.pattern} مطابقت داشته باشد`:`${o[i.format]??n.format} نامعتبر`}case"not_multiple_of":return`عدد نامعتبر: باید مضرب ${n.divisor} باشد`;case"unrecognized_keys":return`کلید${n.keys.length>1?"های":""} ناشناس: ${j(n.keys,", ")}`;case"invalid_key":return`کلید ناشناس در ${n.origin}`;case"invalid_union":return"ورودی نامعتبر";case"invalid_element":return`مقدار نامعتبر در ${n.origin}`;default:return"ورودی نامعتبر"}}};function ak(){return{localeError:ik()}}const sk=()=>{const e={string:{unit:"merkkiä",subject:"merkkijonon"},file:{unit:"tavua",subject:"tiedoston"},array:{unit:"alkiota",subject:"listan"},set:{unit:"alkiota",subject:"joukon"},number:{unit:"",subject:"luvun"},bigint:{unit:"",subject:"suuren kokonaisluvun"},int:{unit:"",subject:"kokonaisluvun"},date:{unit:"",subject:"päivämäärän"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"säännöllinen lauseke",email:"sähköpostiosoite",url:"URL-osoite",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-aikaleima",date:"ISO-päivämäärä",time:"ISO-aika",duration:"ISO-kesto",ipv4:"IPv4-osoite",ipv6:"IPv6-osoite",cidrv4:"IPv4-alue",cidrv6:"IPv6-alue",base64:"base64-koodattu merkkijono",base64url:"base64url-koodattu merkkijono",json_string:"JSON-merkkijono",e164:"E.164-luku",jwt:"JWT",template_literal:"templaattimerkkijono"};return n=>{switch(n.code){case"invalid_type":return`Virheellinen tyyppi: odotettiin ${n.expected}, oli ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Virheellinen syöte: täytyy olla ${H(n.values[0])}`:`Virheellinen valinta: täytyy olla yksi seuraavista: ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Liian suuri: ${a.subject} täytyy olla ${i}${n.maximum.toString()} ${a.unit}`.trim():`Liian suuri: arvon täytyy olla ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Liian pieni: ${a.subject} täytyy olla ${i}${n.minimum.toString()} ${a.unit}`.trim():`Liian pieni: arvon täytyy olla ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Virheellinen syöte: täytyy alkaa "${i.prefix}"`:i.format==="ends_with"?`Virheellinen syöte: täytyy loppua "${i.suffix}"`:i.format==="includes"?`Virheellinen syöte: täytyy sisältää "${i.includes}"`:i.format==="regex"?`Virheellinen syöte: täytyy vastata säännöllistä lauseketta ${i.pattern}`:`Virheellinen ${o[i.format]??n.format}`}case"not_multiple_of":return`Virheellinen luku: täytyy olla luvun ${n.divisor} monikerta`;case"unrecognized_keys":return`${n.keys.length>1?"Tuntemattomat avaimet":"Tuntematon avain"}: ${j(n.keys,", ")}`;case"invalid_key":return"Virheellinen avain tietueessa";case"invalid_union":return"Virheellinen unioni";case"invalid_element":return"Virheellinen arvo joukossa";default:return"Virheellinen syöte"}}};function uk(){return{localeError:sk()}}const lk=()=>{const e={string:{unit:"caractères",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"éléments",verb:"avoir"},set:{unit:"éléments",verb:"avoir"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"nombre";case"object":{if(Array.isArray(n))return"tableau";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"entrée",email:"adresse e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date et heure ISO",date:"date ISO",time:"heure ISO",duration:"durée ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"chaîne encodée en base64",base64url:"chaîne encodée en base64url",json_string:"chaîne JSON",e164:"numéro E.164",jwt:"JWT",template_literal:"entrée"};return n=>{switch(n.code){case"invalid_type":return`Entrée invalide : ${n.expected} attendu, ${r(n.input)} reçu`;case"invalid_value":return n.values.length===1?`Entrée invalide : ${H(n.values[0])} attendu`:`Option invalide : une valeur parmi ${j(n.values,"|")} attendue`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Trop grand : ${n.origin??"valeur"} doit ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"élément(s)"}`:`Trop grand : ${n.origin??"valeur"} doit être ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Trop petit : ${n.origin} doit ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Trop petit : ${n.origin} doit être ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Chaîne invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Chaîne invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Chaîne invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Chaîne invalide : doit correspondre au modèle ${i.pattern}`:`${o[i.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${n.divisor}`;case"unrecognized_keys":return`Clé${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${j(n.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${n.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entrée invalide"}}};function ck(){return{localeError:lk()}}const dk=()=>{const e={string:{unit:"caractères",verb:"avoir"},file:{unit:"octets",verb:"avoir"},array:{unit:"éléments",verb:"avoir"},set:{unit:"éléments",verb:"avoir"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"entrée",email:"adresse courriel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"date-heure ISO",date:"date ISO",time:"heure ISO",duration:"durée ISO",ipv4:"adresse IPv4",ipv6:"adresse IPv6",cidrv4:"plage IPv4",cidrv6:"plage IPv6",base64:"chaîne encodée en base64",base64url:"chaîne encodée en base64url",json_string:"chaîne JSON",e164:"numéro E.164",jwt:"JWT",template_literal:"entrée"};return n=>{switch(n.code){case"invalid_type":return`Entrée invalide : attendu ${n.expected}, reçu ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Entrée invalide : attendu ${H(n.values[0])}`:`Option invalide : attendu l'une des valeurs suivantes ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"≤":"<",a=t(n.origin);return a?`Trop grand : attendu que ${n.origin??"la valeur"} ait ${i}${n.maximum.toString()} ${a.unit}`:`Trop grand : attendu que ${n.origin??"la valeur"} soit ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?"≥":">",a=t(n.origin);return a?`Trop petit : attendu que ${n.origin} ait ${i}${n.minimum.toString()} ${a.unit}`:`Trop petit : attendu que ${n.origin} soit ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Chaîne invalide : doit commencer par "${i.prefix}"`:i.format==="ends_with"?`Chaîne invalide : doit se terminer par "${i.suffix}"`:i.format==="includes"?`Chaîne invalide : doit inclure "${i.includes}"`:i.format==="regex"?`Chaîne invalide : doit correspondre au motif ${i.pattern}`:`${o[i.format]??n.format} invalide`}case"not_multiple_of":return`Nombre invalide : doit être un multiple de ${n.divisor}`;case"unrecognized_keys":return`Clé${n.keys.length>1?"s":""} non reconnue${n.keys.length>1?"s":""} : ${j(n.keys,", ")}`;case"invalid_key":return`Clé invalide dans ${n.origin}`;case"invalid_union":return"Entrée invalide";case"invalid_element":return`Valeur invalide dans ${n.origin}`;default:return"Entrée invalide"}}};function pk(){return{localeError:dk()}}const fk=()=>{const e={string:{label:"מחרוזת",gender:"f"},number:{label:"מספר",gender:"m"},boolean:{label:"ערך בוליאני",gender:"m"},bigint:{label:"BigInt",gender:"m"},date:{label:"תאריך",gender:"m"},array:{label:"מערך",gender:"m"},object:{label:"אובייקט",gender:"m"},null:{label:"ערך ריק (null)",gender:"m"},undefined:{label:"ערך לא מוגדר (undefined)",gender:"m"},symbol:{label:"סימבול (Symbol)",gender:"m"},function:{label:"פונקציה",gender:"f"},map:{label:"מפה (Map)",gender:"f"},set:{label:"קבוצה (Set)",gender:"f"},file:{label:"קובץ",gender:"m"},promise:{label:"Promise",gender:"m"},NaN:{label:"NaN",gender:"m"},unknown:{label:"ערך לא ידוע",gender:"m"},value:{label:"ערך",gender:"m"}},t={string:{unit:"תווים",shortLabel:"קצר",longLabel:"ארוך"},file:{unit:"בייטים",shortLabel:"קטן",longLabel:"גדול"},array:{unit:"פריטים",shortLabel:"קטן",longLabel:"גדול"},set:{unit:"פריטים",shortLabel:"קטן",longLabel:"גדול"},number:{unit:"",shortLabel:"קטן",longLabel:"גדול"}},r=u=>u?e[u]:void 0,o=u=>{const c=r(u);return c?c.label:u??e.unknown.label},n=u=>`ה${o(u)}`,i=u=>(r(u)?.gender??"m")==="f"?"צריכה להיות":"צריך להיות",a=u=>u?t[u]??null:null,s=u=>{const c=typeof u;switch(c){case"number":return Number.isNaN(u)?"NaN":"number";case"object":return Array.isArray(u)?"array":u===null?"null":Object.getPrototypeOf(u)!==Object.prototype&&u.constructor?u.constructor.name:"object";default:return c}},l={regex:{label:"קלט",gender:"m"},email:{label:"כתובת אימייל",gender:"f"},url:{label:"כתובת רשת",gender:"f"},emoji:{label:"אימוג'י",gender:"m"},uuid:{label:"UUID",gender:"m"},nanoid:{label:"nanoid",gender:"m"},guid:{label:"GUID",gender:"m"},cuid:{label:"cuid",gender:"m"},cuid2:{label:"cuid2",gender:"m"},ulid:{label:"ULID",gender:"m"},xid:{label:"XID",gender:"m"},ksuid:{label:"KSUID",gender:"m"},datetime:{label:"תאריך וזמן ISO",gender:"m"},date:{label:"תאריך ISO",gender:"m"},time:{label:"זמן ISO",gender:"m"},duration:{label:"משך זמן ISO",gender:"m"},ipv4:{label:"כתובת IPv4",gender:"f"},ipv6:{label:"כתובת IPv6",gender:"f"},cidrv4:{label:"טווח IPv4",gender:"m"},cidrv6:{label:"טווח IPv6",gender:"m"},base64:{label:"מחרוזת בבסיס 64",gender:"f"},base64url:{label:"מחרוזת בבסיס 64 לכתובות רשת",gender:"f"},json_string:{label:"מחרוזת JSON",gender:"f"},e164:{label:"מספר E.164",gender:"m"},jwt:{label:"JWT",gender:"m"},ends_with:{label:"קלט",gender:"m"},includes:{label:"קלט",gender:"m"},lowercase:{label:"קלט",gender:"m"},starts_with:{label:"קלט",gender:"m"},uppercase:{label:"קלט",gender:"m"}};return u=>{switch(u.code){case"invalid_type":{const c=u.expected,d=o(c),f=s(u.input),p=e[f]?.label??f;return`קלט לא תקין: צריך להיות ${d}, התקבל ${p}`}case"invalid_value":{if(u.values.length===1)return`ערך לא תקין: הערך חייב להיות ${H(u.values[0])}`;const c=u.values.map(p=>H(p));if(u.values.length===2)return`ערך לא תקין: האפשרויות המתאימות הן ${c[0]} או ${c[1]}`;const d=c[c.length-1];return`ערך לא תקין: האפשרויות המתאימות הן ${c.slice(0,-1).join(", ")} או ${d}`}case"too_big":{const c=a(u.origin),d=n(u.origin??"value");if(u.origin==="string")return`${c?.longLabel??"ארוך"} מדי: ${d} צריכה להכיל ${u.maximum.toString()} ${c?.unit??""} ${u.inclusive?"או פחות":"לכל היותר"}`.trim();if(u.origin==="number"){const g=u.inclusive?`קטן או שווה ל-${u.maximum}`:`קטן מ-${u.maximum}`;return`גדול מדי: ${d} צריך להיות ${g}`}if(u.origin==="array"||u.origin==="set"){const g=u.origin==="set"?"צריכה":"צריך",h=u.inclusive?`${u.maximum} ${c?.unit??""} או פחות`:`פחות מ-${u.maximum} ${c?.unit??""}`;return`גדול מדי: ${d} ${g} להכיל ${h}`.trim()}const f=u.inclusive?"<=":"<",p=i(u.origin??"value");return c?.unit?`${c.longLabel} מדי: ${d} ${p} ${f}${u.maximum.toString()} ${c.unit}`:`${c?.longLabel??"גדול"} מדי: ${d} ${p} ${f}${u.maximum.toString()}`}case"too_small":{const c=a(u.origin),d=n(u.origin??"value");if(u.origin==="string")return`${c?.shortLabel??"קצר"} מדי: ${d} צריכה להכיל ${u.minimum.toString()} ${c?.unit??""} ${u.inclusive?"או יותר":"לפחות"}`.trim();if(u.origin==="number"){const g=u.inclusive?`גדול או שווה ל-${u.minimum}`:`גדול מ-${u.minimum}`;return`קטן מדי: ${d} צריך להיות ${g}`}if(u.origin==="array"||u.origin==="set"){const g=u.origin==="set"?"צריכה":"צריך";if(u.minimum===1&&u.inclusive){const b=(u.origin==="set","לפחות פריט אחד");return`קטן מדי: ${d} ${g} להכיל ${b}`}const h=u.inclusive?`${u.minimum} ${c?.unit??""} או יותר`:`יותר מ-${u.minimum} ${c?.unit??""}`;return`קטן מדי: ${d} ${g} להכיל ${h}`.trim()}const f=u.inclusive?">=":">",p=i(u.origin??"value");return c?.unit?`${c.shortLabel} מדי: ${d} ${p} ${f}${u.minimum.toString()} ${c.unit}`:`${c?.shortLabel??"קטן"} מדי: ${d} ${p} ${f}${u.minimum.toString()}`}case"invalid_format":{const c=u;if(c.format==="starts_with")return`המחרוזת חייבת להתחיל ב "${c.prefix}"`;if(c.format==="ends_with")return`המחרוזת חייבת להסתיים ב "${c.suffix}"`;if(c.format==="includes")return`המחרוזת חייבת לכלול "${c.includes}"`;if(c.format==="regex")return`המחרוזת חייבת להתאים לתבנית ${c.pattern}`;const d=l[c.format],f=d?.label??c.format,g=(d?.gender??"m")==="f"?"תקינה":"תקין";return`${f} לא ${g}`}case"not_multiple_of":return`מספר לא תקין: חייב להיות מכפלה של ${u.divisor}`;case"unrecognized_keys":return`מפתח${u.keys.length>1?"ות":""} לא מזוה${u.keys.length>1?"ים":"ה"}: ${j(u.keys,", ")}`;case"invalid_key":return"שדה לא תקין באובייקט";case"invalid_union":return"קלט לא תקין";case"invalid_element":return`ערך לא תקין ב${n(u.origin??"array")}`;default:return"קלט לא תקין"}}};function mk(){return{localeError:fk()}}const hk=()=>{const e={string:{unit:"karakter",verb:"legyen"},file:{unit:"byte",verb:"legyen"},array:{unit:"elem",verb:"legyen"},set:{unit:"elem",verb:"legyen"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"szám";case"object":{if(Array.isArray(n))return"tömb";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"bemenet",email:"email cím",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO időbélyeg",date:"ISO dátum",time:"ISO idő",duration:"ISO időintervallum",ipv4:"IPv4 cím",ipv6:"IPv6 cím",cidrv4:"IPv4 tartomány",cidrv6:"IPv6 tartomány",base64:"base64-kódolt string",base64url:"base64url-kódolt string",json_string:"JSON string",e164:"E.164 szám",jwt:"JWT",template_literal:"bemenet"};return n=>{switch(n.code){case"invalid_type":return`Érvénytelen bemenet: a várt érték ${n.expected}, a kapott érték ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Érvénytelen bemenet: a várt érték ${H(n.values[0])}`:`Érvénytelen opció: valamelyik érték várt ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Túl nagy: ${n.origin??"érték"} mérete túl nagy ${i}${n.maximum.toString()} ${a.unit??"elem"}`:`Túl nagy: a bemeneti érték ${n.origin??"érték"} túl nagy: ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Túl kicsi: a bemeneti érték ${n.origin} mérete túl kicsi ${i}${n.minimum.toString()} ${a.unit}`:`Túl kicsi: a bemeneti érték ${n.origin} túl kicsi ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Érvénytelen string: "${i.prefix}" értékkel kell kezdődnie`:i.format==="ends_with"?`Érvénytelen string: "${i.suffix}" értékkel kell végződnie`:i.format==="includes"?`Érvénytelen string: "${i.includes}" értéket kell tartalmaznia`:i.format==="regex"?`Érvénytelen string: ${i.pattern} mintának kell megfelelnie`:`Érvénytelen ${o[i.format]??n.format}`}case"not_multiple_of":return`Érvénytelen szám: ${n.divisor} többszörösének kell lennie`;case"unrecognized_keys":return`Ismeretlen kulcs${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Érvénytelen kulcs ${n.origin}`;case"invalid_union":return"Érvénytelen bemenet";case"invalid_element":return`Érvénytelen érték: ${n.origin}`;default:return"Érvénytelen bemenet"}}};function gk(){return{localeError:hk()}}const vk=()=>{const e={string:{unit:"karakter",verb:"memiliki"},file:{unit:"byte",verb:"memiliki"},array:{unit:"item",verb:"memiliki"},set:{unit:"item",verb:"memiliki"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"input",email:"alamat email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tanggal dan waktu format ISO",date:"tanggal format ISO",time:"jam format ISO",duration:"durasi format ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"rentang alamat IPv4",cidrv6:"rentang alamat IPv6",base64:"string dengan enkode base64",base64url:"string dengan enkode base64url",json_string:"string JSON",e164:"angka E.164",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Input tidak valid: diharapkan ${n.expected}, diterima ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Input tidak valid: diharapkan ${H(n.values[0])}`:`Pilihan tidak valid: diharapkan salah satu dari ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Terlalu besar: diharapkan ${n.origin??"value"} memiliki ${i}${n.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: diharapkan ${n.origin??"value"} menjadi ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Terlalu kecil: diharapkan ${n.origin} memiliki ${i}${n.minimum.toString()} ${a.unit}`:`Terlalu kecil: diharapkan ${n.origin} menjadi ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`String tidak valid: harus dimulai dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak valid: harus berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak valid: harus menyertakan "${i.includes}"`:i.format==="regex"?`String tidak valid: harus sesuai pola ${i.pattern}`:`${o[i.format]??n.format} tidak valid`}case"not_multiple_of":return`Angka tidak valid: harus kelipatan dari ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali ${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Kunci tidak valid di ${n.origin}`;case"invalid_union":return"Input tidak valid";case"invalid_element":return`Nilai tidak valid di ${n.origin}`;default:return"Input tidak valid"}}};function yk(){return{localeError:vk()}}const bk=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"númer";case"object":{if(Array.isArray(e))return"fylki";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},_k=()=>{const e={string:{unit:"stafi",verb:"að hafa"},file:{unit:"bæti",verb:"að hafa"},array:{unit:"hluti",verb:"að hafa"},set:{unit:"hluti",verb:"að hafa"}};function t(o){return e[o]??null}const r={regex:"gildi",email:"netfang",url:"vefslóð",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dagsetning og tími",date:"ISO dagsetning",time:"ISO tími",duration:"ISO tímalengd",ipv4:"IPv4 address",ipv6:"IPv6 address",cidrv4:"IPv4 range",cidrv6:"IPv6 range",base64:"base64-encoded strengur",base64url:"base64url-encoded strengur",json_string:"JSON strengur",e164:"E.164 tölugildi",jwt:"JWT",template_literal:"gildi"};return o=>{switch(o.code){case"invalid_type":return`Rangt gildi: Þú slóst inn ${bk(o.input)} þar sem á að vera ${o.expected}`;case"invalid_value":return o.values.length===1?`Rangt gildi: gert ráð fyrir ${H(o.values[0])}`:`Ógilt val: má vera eitt af eftirfarandi ${j(o.values,"|")}`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Of stórt: gert er ráð fyrir að ${o.origin??"gildi"} hafi ${n}${o.maximum.toString()} ${i.unit??"hluti"}`:`Of stórt: gert er ráð fyrir að ${o.origin??"gildi"} sé ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Of lítið: gert er ráð fyrir að ${o.origin} hafi ${n}${o.minimum.toString()} ${i.unit}`:`Of lítið: gert er ráð fyrir að ${o.origin} sé ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Ógildur strengur: verður að byrja á "${n.prefix}"`:n.format==="ends_with"?`Ógildur strengur: verður að enda á "${n.suffix}"`:n.format==="includes"?`Ógildur strengur: verður að innihalda "${n.includes}"`:n.format==="regex"?`Ógildur strengur: verður að fylgja mynstri ${n.pattern}`:`Rangt ${r[n.format]??o.format}`}case"not_multiple_of":return`Röng tala: verður að vera margfeldi af ${o.divisor}`;case"unrecognized_keys":return`Óþekkt ${o.keys.length>1?"ir lyklar":"ur lykill"}: ${j(o.keys,", ")}`;case"invalid_key":return`Rangur lykill í ${o.origin}`;case"invalid_union":return"Rangt gildi";case"invalid_element":return`Rangt gildi í ${o.origin}`;default:return"Rangt gildi"}}};function wk(){return{localeError:_k()}}const xk=()=>{const e={string:{unit:"caratteri",verb:"avere"},file:{unit:"byte",verb:"avere"},array:{unit:"elementi",verb:"avere"},set:{unit:"elementi",verb:"avere"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"numero";case"object":{if(Array.isArray(n))return"vettore";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"input",email:"indirizzo email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e ora ISO",date:"data ISO",time:"ora ISO",duration:"durata ISO",ipv4:"indirizzo IPv4",ipv6:"indirizzo IPv6",cidrv4:"intervallo IPv4",cidrv6:"intervallo IPv6",base64:"stringa codificata in base64",base64url:"URL codificata in base64",json_string:"stringa JSON",e164:"numero E.164",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Input non valido: atteso ${n.expected}, ricevuto ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Input non valido: atteso ${H(n.values[0])}`:`Opzione non valida: atteso uno tra ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Troppo grande: ${n.origin??"valore"} deve avere ${i}${n.maximum.toString()} ${a.unit??"elementi"}`:`Troppo grande: ${n.origin??"valore"} deve essere ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Troppo piccolo: ${n.origin} deve avere ${i}${n.minimum.toString()} ${a.unit}`:`Troppo piccolo: ${n.origin} deve essere ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Stringa non valida: deve iniziare con "${i.prefix}"`:i.format==="ends_with"?`Stringa non valida: deve terminare con "${i.suffix}"`:i.format==="includes"?`Stringa non valida: deve includere "${i.includes}"`:i.format==="regex"?`Stringa non valida: deve corrispondere al pattern ${i.pattern}`:`Invalid ${o[i.format]??n.format}`}case"not_multiple_of":return`Numero non valido: deve essere un multiplo di ${n.divisor}`;case"unrecognized_keys":return`Chiav${n.keys.length>1?"i":"e"} non riconosciut${n.keys.length>1?"e":"a"}: ${j(n.keys,", ")}`;case"invalid_key":return`Chiave non valida in ${n.origin}`;case"invalid_union":return"Input non valido";case"invalid_element":return`Valore non valido in ${n.origin}`;default:return"Input non valido"}}};function $k(){return{localeError:xk()}}const Sk=()=>{const e={string:{unit:"文字",verb:"である"},file:{unit:"バイト",verb:"である"},array:{unit:"要素",verb:"である"},set:{unit:"要素",verb:"である"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"数値";case"object":{if(Array.isArray(n))return"配列";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"入力値",email:"メールアドレス",url:"URL",emoji:"絵文字",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日時",date:"ISO日付",time:"ISO時刻",duration:"ISO期間",ipv4:"IPv4アドレス",ipv6:"IPv6アドレス",cidrv4:"IPv4範囲",cidrv6:"IPv6範囲",base64:"base64エンコード文字列",base64url:"base64urlエンコード文字列",json_string:"JSON文字列",e164:"E.164番号",jwt:"JWT",template_literal:"入力値"};return n=>{switch(n.code){case"invalid_type":return`無効な入力: ${n.expected}が期待されましたが、${r(n.input)}が入力されました`;case"invalid_value":return n.values.length===1?`無効な入力: ${H(n.values[0])}が期待されました`:`無効な選択: ${j(n.values,"、")}のいずれかである必要があります`;case"too_big":{const i=n.inclusive?"以下である":"より小さい",a=t(n.origin);return a?`大きすぎる値: ${n.origin??"値"}は${n.maximum.toString()}${a.unit??"要素"}${i}必要があります`:`大きすぎる値: ${n.origin??"値"}は${n.maximum.toString()}${i}必要があります`}case"too_small":{const i=n.inclusive?"以上である":"より大きい",a=t(n.origin);return a?`小さすぎる値: ${n.origin}は${n.minimum.toString()}${a.unit}${i}必要があります`:`小さすぎる値: ${n.origin}は${n.minimum.toString()}${i}必要があります`}case"invalid_format":{const i=n;return i.format==="starts_with"?`無効な文字列: "${i.prefix}"で始まる必要があります`:i.format==="ends_with"?`無効な文字列: "${i.suffix}"で終わる必要があります`:i.format==="includes"?`無効な文字列: "${i.includes}"を含む必要があります`:i.format==="regex"?`無効な文字列: パターン${i.pattern}に一致する必要があります`:`無効な${o[i.format]??n.format}`}case"not_multiple_of":return`無効な数値: ${n.divisor}の倍数である必要があります`;case"unrecognized_keys":return`認識されていないキー${n.keys.length>1?"群":""}: ${j(n.keys,"、")}`;case"invalid_key":return`${n.origin}内の無効なキー`;case"invalid_union":return"無効な入力";case"invalid_element":return`${n.origin}内の無効な値`;default:return"無効な入力"}}};function Ik(){return{localeError:Sk()}}const kk=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"რიცხვი";case"object":{if(Array.isArray(e))return"მასივი";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return{string:"სტრინგი",boolean:"ბულეანი",undefined:"undefined",bigint:"bigint",symbol:"symbol",function:"ფუნქცია"}[t]??t},Ek=()=>{const e={string:{unit:"სიმბოლო",verb:"უნდა შეიცავდეს"},file:{unit:"ბაიტი",verb:"უნდა შეიცავდეს"},array:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"},set:{unit:"ელემენტი",verb:"უნდა შეიცავდეს"}};function t(o){return e[o]??null}const r={regex:"შეყვანა",email:"ელ-ფოსტის მისამართი",url:"URL",emoji:"ემოჯი",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"თარიღი-დრო",date:"თარიღი",time:"დრო",duration:"ხანგრძლივობა",ipv4:"IPv4 მისამართი",ipv6:"IPv6 მისამართი",cidrv4:"IPv4 დიაპაზონი",cidrv6:"IPv6 დიაპაზონი",base64:"base64-კოდირებული სტრინგი",base64url:"base64url-კოდირებული სტრინგი",json_string:"JSON სტრინგი",e164:"E.164 ნომერი",jwt:"JWT",template_literal:"შეყვანა"};return o=>{switch(o.code){case"invalid_type":return`არასწორი შეყვანა: მოსალოდნელი ${o.expected}, მიღებული ${kk(o.input)}`;case"invalid_value":return o.values.length===1?`არასწორი შეყვანა: მოსალოდნელი ${H(o.values[0])}`:`არასწორი ვარიანტი: მოსალოდნელია ერთ-ერთი ${j(o.values,"|")}-დან`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`ზედმეტად დიდი: მოსალოდნელი ${o.origin??"მნიშვნელობა"} ${i.verb} ${n}${o.maximum.toString()} ${i.unit}`:`ზედმეტად დიდი: მოსალოდნელი ${o.origin??"მნიშვნელობა"} იყოს ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`ზედმეტად პატარა: მოსალოდნელი ${o.origin} ${i.verb} ${n}${o.minimum.toString()} ${i.unit}`:`ზედმეტად პატარა: მოსალოდნელი ${o.origin} იყოს ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`არასწორი სტრინგი: უნდა იწყებოდეს "${n.prefix}"-ით`:n.format==="ends_with"?`არასწორი სტრინგი: უნდა მთავრდებოდეს "${n.suffix}"-ით`:n.format==="includes"?`არასწორი სტრინგი: უნდა შეიცავდეს "${n.includes}"-ს`:n.format==="regex"?`არასწორი სტრინგი: უნდა შეესაბამებოდეს შაბლონს ${n.pattern}`:`არასწორი ${r[n.format]??o.format}`}case"not_multiple_of":return`არასწორი რიცხვი: უნდა იყოს ${o.divisor}-ის ჯერადი`;case"unrecognized_keys":return`უცნობი გასაღებ${o.keys.length>1?"ები":"ი"}: ${j(o.keys,", ")}`;case"invalid_key":return`არასწორი გასაღები ${o.origin}-ში`;case"invalid_union":return"არასწორი შეყვანა";case"invalid_element":return`არასწორი მნიშვნელობა ${o.origin}-ში`;default:return"არასწორი შეყვანა"}}};function Tk(){return{localeError:Ek()}}const Ok=()=>{const e={string:{unit:"តួអក្សរ",verb:"គួរមាន"},file:{unit:"បៃ",verb:"គួរមាន"},array:{unit:"ធាតុ",verb:"គួរមាន"},set:{unit:"ធាតុ",verb:"គួរមាន"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"មិនមែនជាលេខ (NaN)":"លេខ";case"object":{if(Array.isArray(n))return"អារេ (Array)";if(n===null)return"គ្មានតម្លៃ (null)";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ទិន្នន័យបញ្ចូល",email:"អាសយដ្ឋានអ៊ីមែល",url:"URL",emoji:"សញ្ញាអារម្មណ៍",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"កាលបរិច្ឆេទ និងម៉ោង ISO",date:"កាលបរិច្ឆេទ ISO",time:"ម៉ោង ISO",duration:"រយៈពេល ISO",ipv4:"អាសយដ្ឋាន IPv4",ipv6:"អាសយដ្ឋាន IPv6",cidrv4:"ដែនអាសយដ្ឋាន IPv4",cidrv6:"ដែនអាសយដ្ឋាន IPv6",base64:"ខ្សែអក្សរអ៊ិកូដ base64",base64url:"ខ្សែអក្សរអ៊ិកូដ base64url",json_string:"ខ្សែអក្សរ JSON",e164:"លេខ E.164",jwt:"JWT",template_literal:"ទិន្នន័យបញ្ចូល"};return n=>{switch(n.code){case"invalid_type":return`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${n.expected} ប៉ុន្តែទទួលបាន ${r(n.input)}`;case"invalid_value":return n.values.length===1?`ទិន្នន័យបញ្ចូលមិនត្រឹមត្រូវ៖ ត្រូវការ ${H(n.values[0])}`:`ជម្រើសមិនត្រឹមត្រូវ៖ ត្រូវជាមួយក្នុងចំណោម ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`ធំពេក៖ ត្រូវការ ${n.origin??"តម្លៃ"} ${i} ${n.maximum.toString()} ${a.unit??"ធាតុ"}`:`ធំពេក៖ ត្រូវការ ${n.origin??"តម្លៃ"} ${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`តូចពេក៖ ត្រូវការ ${n.origin} ${i} ${n.minimum.toString()} ${a.unit}`:`តូចពេក៖ ត្រូវការ ${n.origin} ${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវចាប់ផ្តើមដោយ "${i.prefix}"`:i.format==="ends_with"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវបញ្ចប់ដោយ "${i.suffix}"`:i.format==="includes"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវមាន "${i.includes}"`:i.format==="regex"?`ខ្សែអក្សរមិនត្រឹមត្រូវ៖ ត្រូវតែផ្គូផ្គងនឹងទម្រង់ដែលបានកំណត់ ${i.pattern}`:`មិនត្រឹមត្រូវ៖ ${o[i.format]??n.format}`}case"not_multiple_of":return`លេខមិនត្រឹមត្រូវ៖ ត្រូវតែជាពហុគុណនៃ ${n.divisor}`;case"unrecognized_keys":return`រកឃើញសោមិនស្គាល់៖ ${j(n.keys,", ")}`;case"invalid_key":return`សោមិនត្រឹមត្រូវនៅក្នុង ${n.origin}`;case"invalid_union":return"ទិន្នន័យមិនត្រឹមត្រូវ";case"invalid_element":return`ទិន្នន័យមិនត្រឹមត្រូវនៅក្នុង ${n.origin}`;default:return"ទិន្នន័យមិនត្រឹមត្រូវ"}}};function bv(){return{localeError:Ok()}}function Nk(){return bv()}const Pk=()=>{const e={string:{unit:"문자",verb:"to have"},file:{unit:"바이트",verb:"to have"},array:{unit:"개",verb:"to have"},set:{unit:"개",verb:"to have"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"입력",email:"이메일 주소",url:"URL",emoji:"이모지",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO 날짜시간",date:"ISO 날짜",time:"ISO 시간",duration:"ISO 기간",ipv4:"IPv4 주소",ipv6:"IPv6 주소",cidrv4:"IPv4 범위",cidrv6:"IPv6 범위",base64:"base64 인코딩 문자열",base64url:"base64url 인코딩 문자열",json_string:"JSON 문자열",e164:"E.164 번호",jwt:"JWT",template_literal:"입력"};return n=>{switch(n.code){case"invalid_type":return`잘못된 입력: 예상 타입은 ${n.expected}, 받은 타입은 ${r(n.input)}입니다`;case"invalid_value":return n.values.length===1?`잘못된 입력: 값은 ${H(n.values[0])} 이어야 합니다`:`잘못된 옵션: ${j(n.values,"또는 ")} 중 하나여야 합니다`;case"too_big":{const i=n.inclusive?"이하":"미만",a=i==="미만"?"이어야 합니다":"여야 합니다",s=t(n.origin),l=s?.unit??"요소";return s?`${n.origin??"값"}이 너무 큽니다: ${n.maximum.toString()}${l} ${i}${a}`:`${n.origin??"값"}이 너무 큽니다: ${n.maximum.toString()} ${i}${a}`}case"too_small":{const i=n.inclusive?"이상":"초과",a=i==="이상"?"이어야 합니다":"여야 합니다",s=t(n.origin),l=s?.unit??"요소";return s?`${n.origin??"값"}이 너무 작습니다: ${n.minimum.toString()}${l} ${i}${a}`:`${n.origin??"값"}이 너무 작습니다: ${n.minimum.toString()} ${i}${a}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`잘못된 문자열: "${i.prefix}"(으)로 시작해야 합니다`:i.format==="ends_with"?`잘못된 문자열: "${i.suffix}"(으)로 끝나야 합니다`:i.format==="includes"?`잘못된 문자열: "${i.includes}"을(를) 포함해야 합니다`:i.format==="regex"?`잘못된 문자열: 정규식 ${i.pattern} 패턴과 일치해야 합니다`:`잘못된 ${o[i.format]??n.format}`}case"not_multiple_of":return`잘못된 숫자: ${n.divisor}의 배수여야 합니다`;case"unrecognized_keys":return`인식할 수 없는 키: ${j(n.keys,", ")}`;case"invalid_key":return`잘못된 키: ${n.origin}`;case"invalid_union":return"잘못된 입력";case"invalid_element":return`잘못된 값: ${n.origin}`;default:return"잘못된 입력"}}};function Ck(){return{localeError:Pk()}}const jk=e=>Sn(typeof e,e),Sn=(e,t=void 0)=>{switch(e){case"number":return Number.isNaN(t)?"NaN":"skaičius";case"bigint":return"sveikasis skaičius";case"string":return"eilutė";case"boolean":return"loginė reikšmė";case"undefined":case"void":return"neapibrėžta reikšmė";case"function":return"funkcija";case"symbol":return"simbolis";case"object":return t===void 0?"nežinomas objektas":t===null?"nulinė reikšmė":Array.isArray(t)?"masyvas":Object.getPrototypeOf(t)!==Object.prototype&&t.constructor?t.constructor.name:"objektas";case"null":return"nulinė reikšmė"}return e},bn=e=>e.charAt(0).toUpperCase()+e.slice(1);function Kd(e){const t=Math.abs(e),r=t%10,o=t%100;return o>=11&&o<=19||r===0?"many":r===1?"one":"few"}const Ak=()=>{const e={string:{unit:{one:"simbolis",few:"simboliai",many:"simbolių"},verb:{smaller:{inclusive:"turi būti ne ilgesnė kaip",notInclusive:"turi būti trumpesnė kaip"},bigger:{inclusive:"turi būti ne trumpesnė kaip",notInclusive:"turi būti ilgesnė kaip"}}},file:{unit:{one:"baitas",few:"baitai",many:"baitų"},verb:{smaller:{inclusive:"turi būti ne didesnis kaip",notInclusive:"turi būti mažesnis kaip"},bigger:{inclusive:"turi būti ne mažesnis kaip",notInclusive:"turi būti didesnis kaip"}}},array:{unit:{one:"elementą",few:"elementus",many:"elementų"},verb:{smaller:{inclusive:"turi turėti ne daugiau kaip",notInclusive:"turi turėti mažiau kaip"},bigger:{inclusive:"turi turėti ne mažiau kaip",notInclusive:"turi turėti daugiau kaip"}}},set:{unit:{one:"elementą",few:"elementus",many:"elementų"},verb:{smaller:{inclusive:"turi turėti ne daugiau kaip",notInclusive:"turi turėti mažiau kaip"},bigger:{inclusive:"turi turėti ne mažiau kaip",notInclusive:"turi turėti daugiau kaip"}}}};function t(o,n,i,a){const s=e[o]??null;return s===null?s:{unit:s.unit[n],verb:s.verb[a][i?"inclusive":"notInclusive"]}}const r={regex:"įvestis",email:"el. pašto adresas",url:"URL",emoji:"jaustukas",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO data ir laikas",date:"ISO data",time:"ISO laikas",duration:"ISO trukmė",ipv4:"IPv4 adresas",ipv6:"IPv6 adresas",cidrv4:"IPv4 tinklo prefiksas (CIDR)",cidrv6:"IPv6 tinklo prefiksas (CIDR)",base64:"base64 užkoduota eilutė",base64url:"base64url užkoduota eilutė",json_string:"JSON eilutė",e164:"E.164 numeris",jwt:"JWT",template_literal:"įvestis"};return o=>{switch(o.code){case"invalid_type":return`Gautas tipas ${jk(o.input)}, o tikėtasi - ${Sn(o.expected)}`;case"invalid_value":return o.values.length===1?`Privalo būti ${H(o.values[0])}`:`Privalo būti vienas iš ${j(o.values,"|")} pasirinkimų`;case"too_big":{const n=Sn(o.origin),i=t(o.origin,Kd(Number(o.maximum)),o.inclusive??!1,"smaller");if(i?.verb)return`${bn(n??o.origin??"reikšmė")} ${i.verb} ${o.maximum.toString()} ${i.unit??"elementų"}`;const a=o.inclusive?"ne didesnis kaip":"mažesnis kaip";return`${bn(n??o.origin??"reikšmė")} turi būti ${a} ${o.maximum.toString()} ${i?.unit}`}case"too_small":{const n=Sn(o.origin),i=t(o.origin,Kd(Number(o.minimum)),o.inclusive??!1,"bigger");if(i?.verb)return`${bn(n??o.origin??"reikšmė")} ${i.verb} ${o.minimum.toString()} ${i.unit??"elementų"}`;const a=o.inclusive?"ne mažesnis kaip":"didesnis kaip";return`${bn(n??o.origin??"reikšmė")} turi būti ${a} ${o.minimum.toString()} ${i?.unit}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Eilutė privalo prasidėti "${n.prefix}"`:n.format==="ends_with"?`Eilutė privalo pasibaigti "${n.suffix}"`:n.format==="includes"?`Eilutė privalo įtraukti "${n.includes}"`:n.format==="regex"?`Eilutė privalo atitikti ${n.pattern}`:`Neteisingas ${r[n.format]??o.format}`}case"not_multiple_of":return`Skaičius privalo būti ${o.divisor} kartotinis.`;case"unrecognized_keys":return`Neatpažint${o.keys.length>1?"i":"as"} rakt${o.keys.length>1?"ai":"as"}: ${j(o.keys,", ")}`;case"invalid_key":return"Rastas klaidingas raktas";case"invalid_union":return"Klaidinga įvestis";case"invalid_element":{const n=Sn(o.origin);return`${bn(n??o.origin??"reikšmė")} turi klaidingą įvestį`}default:return"Klaidinga įvestis"}}};function Rk(){return{localeError:Ak()}}const zk=()=>{const e={string:{unit:"знаци",verb:"да имаат"},file:{unit:"бајти",verb:"да имаат"},array:{unit:"ставки",verb:"да имаат"},set:{unit:"ставки",verb:"да имаат"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"број";case"object":{if(Array.isArray(n))return"низа";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"внес",email:"адреса на е-пошта",url:"URL",emoji:"емоџи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO датум и време",date:"ISO датум",time:"ISO време",duration:"ISO времетраење",ipv4:"IPv4 адреса",ipv6:"IPv6 адреса",cidrv4:"IPv4 опсег",cidrv6:"IPv6 опсег",base64:"base64-енкодирана низа",base64url:"base64url-енкодирана низа",json_string:"JSON низа",e164:"E.164 број",jwt:"JWT",template_literal:"внес"};return n=>{switch(n.code){case"invalid_type":return`Грешен внес: се очекува ${n.expected}, примено ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Invalid input: expected ${H(n.values[0])}`:`Грешана опција: се очекува една ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Премногу голем: се очекува ${n.origin??"вредноста"} да има ${i}${n.maximum.toString()} ${a.unit??"елементи"}`:`Премногу голем: се очекува ${n.origin??"вредноста"} да биде ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Премногу мал: се очекува ${n.origin} да има ${i}${n.minimum.toString()} ${a.unit}`:`Премногу мал: се очекува ${n.origin} да биде ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Неважечка низа: мора да започнува со "${i.prefix}"`:i.format==="ends_with"?`Неважечка низа: мора да завршува со "${i.suffix}"`:i.format==="includes"?`Неважечка низа: мора да вклучува "${i.includes}"`:i.format==="regex"?`Неважечка низа: мора да одгоара на патернот ${i.pattern}`:`Invalid ${o[i.format]??n.format}`}case"not_multiple_of":return`Грешен број: мора да биде делив со ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Непрепознаени клучеви":"Непрепознаен клуч"}: ${j(n.keys,", ")}`;case"invalid_key":return`Грешен клуч во ${n.origin}`;case"invalid_union":return"Грешен внес";case"invalid_element":return`Грешна вредност во ${n.origin}`;default:return"Грешен внес"}}};function Mk(){return{localeError:zk()}}const Dk=()=>{const e={string:{unit:"aksara",verb:"mempunyai"},file:{unit:"bait",verb:"mempunyai"},array:{unit:"elemen",verb:"mempunyai"},set:{unit:"elemen",verb:"mempunyai"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"nombor";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"input",email:"alamat e-mel",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"tarikh masa ISO",date:"tarikh ISO",time:"masa ISO",duration:"tempoh ISO",ipv4:"alamat IPv4",ipv6:"alamat IPv6",cidrv4:"julat IPv4",cidrv6:"julat IPv6",base64:"string dikodkan base64",base64url:"string dikodkan base64url",json_string:"string JSON",e164:"nombor E.164",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Input tidak sah: dijangka ${n.expected}, diterima ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Input tidak sah: dijangka ${H(n.values[0])}`:`Pilihan tidak sah: dijangka salah satu daripada ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Terlalu besar: dijangka ${n.origin??"nilai"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"elemen"}`:`Terlalu besar: dijangka ${n.origin??"nilai"} adalah ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Terlalu kecil: dijangka ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Terlalu kecil: dijangka ${n.origin} adalah ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`String tidak sah: mesti bermula dengan "${i.prefix}"`:i.format==="ends_with"?`String tidak sah: mesti berakhir dengan "${i.suffix}"`:i.format==="includes"?`String tidak sah: mesti mengandungi "${i.includes}"`:i.format==="regex"?`String tidak sah: mesti sepadan dengan corak ${i.pattern}`:`${o[i.format]??n.format} tidak sah`}case"not_multiple_of":return`Nombor tidak sah: perlu gandaan ${n.divisor}`;case"unrecognized_keys":return`Kunci tidak dikenali: ${j(n.keys,", ")}`;case"invalid_key":return`Kunci tidak sah dalam ${n.origin}`;case"invalid_union":return"Input tidak sah";case"invalid_element":return`Nilai tidak sah dalam ${n.origin}`;default:return"Input tidak sah"}}};function Uk(){return{localeError:Dk()}}const Lk=()=>{const e={string:{unit:"tekens",verb:"te hebben"},file:{unit:"bytes",verb:"te hebben"},array:{unit:"elementen",verb:"te hebben"},set:{unit:"elementen",verb:"te hebben"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"getal";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"invoer",email:"emailadres",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum en tijd",date:"ISO datum",time:"ISO tijd",duration:"ISO duur",ipv4:"IPv4-adres",ipv6:"IPv6-adres",cidrv4:"IPv4-bereik",cidrv6:"IPv6-bereik",base64:"base64-gecodeerde tekst",base64url:"base64 URL-gecodeerde tekst",json_string:"JSON string",e164:"E.164-nummer",jwt:"JWT",template_literal:"invoer"};return n=>{switch(n.code){case"invalid_type":return`Ongeldige invoer: verwacht ${n.expected}, ontving ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ongeldige invoer: verwacht ${H(n.values[0])}`:`Ongeldige optie: verwacht één van ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Te groot: verwacht dat ${n.origin??"waarde"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"elementen"}`:`Te groot: verwacht dat ${n.origin??"waarde"} ${i}${n.maximum.toString()} is`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Te klein: verwacht dat ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Te klein: verwacht dat ${n.origin} ${i}${n.minimum.toString()} is`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Ongeldige tekst: moet met "${i.prefix}" beginnen`:i.format==="ends_with"?`Ongeldige tekst: moet op "${i.suffix}" eindigen`:i.format==="includes"?`Ongeldige tekst: moet "${i.includes}" bevatten`:i.format==="regex"?`Ongeldige tekst: moet overeenkomen met patroon ${i.pattern}`:`Ongeldig: ${o[i.format]??n.format}`}case"not_multiple_of":return`Ongeldig getal: moet een veelvoud van ${n.divisor} zijn`;case"unrecognized_keys":return`Onbekende key${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Ongeldige key in ${n.origin}`;case"invalid_union":return"Ongeldige invoer";case"invalid_element":return`Ongeldige waarde in ${n.origin}`;default:return"Ongeldige invoer"}}};function Zk(){return{localeError:Lk()}}const Fk=()=>{const e={string:{unit:"tegn",verb:"å ha"},file:{unit:"bytes",verb:"å ha"},array:{unit:"elementer",verb:"å inneholde"},set:{unit:"elementer",verb:"å inneholde"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"tall";case"object":{if(Array.isArray(n))return"liste";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"input",email:"e-postadresse",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO dato- og klokkeslett",date:"ISO-dato",time:"ISO-klokkeslett",duration:"ISO-varighet",ipv4:"IPv4-område",ipv6:"IPv6-område",cidrv4:"IPv4-spekter",cidrv6:"IPv6-spekter",base64:"base64-enkodet streng",base64url:"base64url-enkodet streng",json_string:"JSON-streng",e164:"E.164-nummer",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`Ugyldig input: forventet ${n.expected}, fikk ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ugyldig verdi: forventet ${H(n.values[0])}`:`Ugyldig valg: forventet en av ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`For stor(t): forventet ${n.origin??"value"} til å ha ${i}${n.maximum.toString()} ${a.unit??"elementer"}`:`For stor(t): forventet ${n.origin??"value"} til å ha ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`For lite(n): forventet ${n.origin} til å ha ${i}${n.minimum.toString()} ${a.unit}`:`For lite(n): forventet ${n.origin} til å ha ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Ugyldig streng: må starte med "${i.prefix}"`:i.format==="ends_with"?`Ugyldig streng: må ende med "${i.suffix}"`:i.format==="includes"?`Ugyldig streng: må inneholde "${i.includes}"`:i.format==="regex"?`Ugyldig streng: må matche mønsteret ${i.pattern}`:`Ugyldig ${o[i.format]??n.format}`}case"not_multiple_of":return`Ugyldig tall: må være et multiplum av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Ukjente nøkler":"Ukjent nøkkel"}: ${j(n.keys,", ")}`;case"invalid_key":return`Ugyldig nøkkel i ${n.origin}`;case"invalid_union":return"Ugyldig input";case"invalid_element":return`Ugyldig verdi i ${n.origin}`;default:return"Ugyldig input"}}};function qk(){return{localeError:Fk()}}const Vk=()=>{const e={string:{unit:"harf",verb:"olmalıdır"},file:{unit:"bayt",verb:"olmalıdır"},array:{unit:"unsur",verb:"olmalıdır"},set:{unit:"unsur",verb:"olmalıdır"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"numara";case"object":{if(Array.isArray(n))return"saf";if(n===null)return"gayb";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"giren",email:"epostagâh",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO hengâmı",date:"ISO tarihi",time:"ISO zamanı",duration:"ISO müddeti",ipv4:"IPv4 nişânı",ipv6:"IPv6 nişânı",cidrv4:"IPv4 menzili",cidrv6:"IPv6 menzili",base64:"base64-şifreli metin",base64url:"base64url-şifreli metin",json_string:"JSON metin",e164:"E.164 sayısı",jwt:"JWT",template_literal:"giren"};return n=>{switch(n.code){case"invalid_type":return`Fâsit giren: umulan ${n.expected}, alınan ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Fâsit giren: umulan ${H(n.values[0])}`:`Fâsit tercih: mûteberler ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Fazla büyük: ${n.origin??"value"}, ${i}${n.maximum.toString()} ${a.unit??"elements"} sahip olmalıydı.`:`Fazla büyük: ${n.origin??"value"}, ${i}${n.maximum.toString()} olmalıydı.`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Fazla küçük: ${n.origin}, ${i}${n.minimum.toString()} ${a.unit} sahip olmalıydı.`:`Fazla küçük: ${n.origin}, ${i}${n.minimum.toString()} olmalıydı.`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Fâsit metin: "${i.prefix}" ile başlamalı.`:i.format==="ends_with"?`Fâsit metin: "${i.suffix}" ile bitmeli.`:i.format==="includes"?`Fâsit metin: "${i.includes}" ihtivâ etmeli.`:i.format==="regex"?`Fâsit metin: ${i.pattern} nakşına uymalı.`:`Fâsit ${o[i.format]??n.format}`}case"not_multiple_of":return`Fâsit sayı: ${n.divisor} katı olmalıydı.`;case"unrecognized_keys":return`Tanınmayan anahtar ${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} için tanınmayan anahtar var.`;case"invalid_union":return"Giren tanınamadı.";case"invalid_element":return`${n.origin} için tanınmayan kıymet var.`;default:return"Kıymet tanınamadı."}}};function Bk(){return{localeError:Vk()}}const Jk=()=>{const e={string:{unit:"توکي",verb:"ولري"},file:{unit:"بایټس",verb:"ولري"},array:{unit:"توکي",verb:"ولري"},set:{unit:"توکي",verb:"ولري"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"عدد";case"object":{if(Array.isArray(n))return"ارې";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ورودي",email:"بریښنالیک",url:"یو آر ال",emoji:"ایموجي",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"نیټه او وخت",date:"نېټه",time:"وخت",duration:"موده",ipv4:"د IPv4 پته",ipv6:"د IPv6 پته",cidrv4:"د IPv4 ساحه",cidrv6:"د IPv6 ساحه",base64:"base64-encoded متن",base64url:"base64url-encoded متن",json_string:"JSON متن",e164:"د E.164 شمېره",jwt:"JWT",template_literal:"ورودي"};return n=>{switch(n.code){case"invalid_type":return`ناسم ورودي: باید ${n.expected} وای, مګر ${r(n.input)} ترلاسه شو`;case"invalid_value":return n.values.length===1?`ناسم ورودي: باید ${H(n.values[0])} وای`:`ناسم انتخاب: باید یو له ${j(n.values,"|")} څخه وای`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`ډیر لوی: ${n.origin??"ارزښت"} باید ${i}${n.maximum.toString()} ${a.unit??"عنصرونه"} ولري`:`ډیر لوی: ${n.origin??"ارزښت"} باید ${i}${n.maximum.toString()} وي`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`ډیر کوچنی: ${n.origin} باید ${i}${n.minimum.toString()} ${a.unit} ولري`:`ډیر کوچنی: ${n.origin} باید ${i}${n.minimum.toString()} وي`}case"invalid_format":{const i=n;return i.format==="starts_with"?`ناسم متن: باید د "${i.prefix}" سره پیل شي`:i.format==="ends_with"?`ناسم متن: باید د "${i.suffix}" سره پای ته ورسيږي`:i.format==="includes"?`ناسم متن: باید "${i.includes}" ولري`:i.format==="regex"?`ناسم متن: باید د ${i.pattern} سره مطابقت ولري`:`${o[i.format]??n.format} ناسم دی`}case"not_multiple_of":return`ناسم عدد: باید د ${n.divisor} مضرب وي`;case"unrecognized_keys":return`ناسم ${n.keys.length>1?"کلیډونه":"کلیډ"}: ${j(n.keys,", ")}`;case"invalid_key":return`ناسم کلیډ په ${n.origin} کې`;case"invalid_union":return"ناسمه ورودي";case"invalid_element":return`ناسم عنصر په ${n.origin} کې`;default:return"ناسمه ورودي"}}};function Wk(){return{localeError:Jk()}}const Hk=()=>{const e={string:{unit:"znaków",verb:"mieć"},file:{unit:"bajtów",verb:"mieć"},array:{unit:"elementów",verb:"mieć"},set:{unit:"elementów",verb:"mieć"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"liczba";case"object":{if(Array.isArray(n))return"tablica";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"wyrażenie",email:"adres email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data i godzina w formacie ISO",date:"data w formacie ISO",time:"godzina w formacie ISO",duration:"czas trwania ISO",ipv4:"adres IPv4",ipv6:"adres IPv6",cidrv4:"zakres IPv4",cidrv6:"zakres IPv6",base64:"ciąg znaków zakodowany w formacie base64",base64url:"ciąg znaków zakodowany w formacie base64url",json_string:"ciąg znaków w formacie JSON",e164:"liczba E.164",jwt:"JWT",template_literal:"wejście"};return n=>{switch(n.code){case"invalid_type":return`Nieprawidłowe dane wejściowe: oczekiwano ${n.expected}, otrzymano ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Nieprawidłowe dane wejściowe: oczekiwano ${H(n.values[0])}`:`Nieprawidłowa opcja: oczekiwano jednej z wartości ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Za duża wartość: oczekiwano, że ${n.origin??"wartość"} będzie mieć ${i}${n.maximum.toString()} ${a.unit??"elementów"}`:`Zbyt duż(y/a/e): oczekiwano, że ${n.origin??"wartość"} będzie wynosić ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Za mała wartość: oczekiwano, że ${n.origin??"wartość"} będzie mieć ${i}${n.minimum.toString()} ${a.unit??"elementów"}`:`Zbyt mał(y/a/e): oczekiwano, że ${n.origin??"wartość"} będzie wynosić ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Nieprawidłowy ciąg znaków: musi zaczynać się od "${i.prefix}"`:i.format==="ends_with"?`Nieprawidłowy ciąg znaków: musi kończyć się na "${i.suffix}"`:i.format==="includes"?`Nieprawidłowy ciąg znaków: musi zawierać "${i.includes}"`:i.format==="regex"?`Nieprawidłowy ciąg znaków: musi odpowiadać wzorcowi ${i.pattern}`:`Nieprawidłow(y/a/e) ${o[i.format]??n.format}`}case"not_multiple_of":return`Nieprawidłowa liczba: musi być wielokrotnością ${n.divisor}`;case"unrecognized_keys":return`Nierozpoznane klucze${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Nieprawidłowy klucz w ${n.origin}`;case"invalid_union":return"Nieprawidłowe dane wejściowe";case"invalid_element":return`Nieprawidłowa wartość w ${n.origin}`;default:return"Nieprawidłowe dane wejściowe"}}};function Gk(){return{localeError:Hk()}}const Kk=()=>{const e={string:{unit:"caracteres",verb:"ter"},file:{unit:"bytes",verb:"ter"},array:{unit:"itens",verb:"ter"},set:{unit:"itens",verb:"ter"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"número";case"object":{if(Array.isArray(n))return"array";if(n===null)return"nulo";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"padrão",email:"endereço de e-mail",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"data e hora ISO",date:"data ISO",time:"hora ISO",duration:"duração ISO",ipv4:"endereço IPv4",ipv6:"endereço IPv6",cidrv4:"faixa de IPv4",cidrv6:"faixa de IPv6",base64:"texto codificado em base64",base64url:"URL codificada em base64",json_string:"texto JSON",e164:"número E.164",jwt:"JWT",template_literal:"entrada"};return n=>{switch(n.code){case"invalid_type":return`Tipo inválido: esperado ${n.expected}, recebido ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Entrada inválida: esperado ${H(n.values[0])}`:`Opção inválida: esperada uma das ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Muito grande: esperado que ${n.origin??"valor"} tivesse ${i}${n.maximum.toString()} ${a.unit??"elementos"}`:`Muito grande: esperado que ${n.origin??"valor"} fosse ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Muito pequeno: esperado que ${n.origin} tivesse ${i}${n.minimum.toString()} ${a.unit}`:`Muito pequeno: esperado que ${n.origin} fosse ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Texto inválido: deve começar com "${i.prefix}"`:i.format==="ends_with"?`Texto inválido: deve terminar com "${i.suffix}"`:i.format==="includes"?`Texto inválido: deve incluir "${i.includes}"`:i.format==="regex"?`Texto inválido: deve corresponder ao padrão ${i.pattern}`:`${o[i.format]??n.format} inválido`}case"not_multiple_of":return`Número inválido: deve ser múltiplo de ${n.divisor}`;case"unrecognized_keys":return`Chave${n.keys.length>1?"s":""} desconhecida${n.keys.length>1?"s":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Chave inválida em ${n.origin}`;case"invalid_union":return"Entrada inválida";case"invalid_element":return`Valor inválido em ${n.origin}`;default:return"Campo inválido"}}};function Yk(){return{localeError:Kk()}}function Yd(e,t,r,o){const n=Math.abs(e),i=n%10,a=n%100;return a>=11&&a<=19?o:i===1?t:i>=2&&i<=4?r:o}const Qk=()=>{const e={string:{unit:{one:"символ",few:"символа",many:"символов"},verb:"иметь"},file:{unit:{one:"байт",few:"байта",many:"байт"},verb:"иметь"},array:{unit:{one:"элемент",few:"элемента",many:"элементов"},verb:"иметь"},set:{unit:{one:"элемент",few:"элемента",many:"элементов"},verb:"иметь"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"число";case"object":{if(Array.isArray(n))return"массив";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ввод",email:"email адрес",url:"URL",emoji:"эмодзи",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO дата и время",date:"ISO дата",time:"ISO время",duration:"ISO длительность",ipv4:"IPv4 адрес",ipv6:"IPv6 адрес",cidrv4:"IPv4 диапазон",cidrv6:"IPv6 диапазон",base64:"строка в формате base64",base64url:"строка в формате base64url",json_string:"JSON строка",e164:"номер E.164",jwt:"JWT",template_literal:"ввод"};return n=>{switch(n.code){case"invalid_type":return`Неверный ввод: ожидалось ${n.expected}, получено ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Неверный ввод: ожидалось ${H(n.values[0])}`:`Неверный вариант: ожидалось одно из ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);if(a){const s=Number(n.maximum),l=Yd(s,a.unit.one,a.unit.few,a.unit.many);return`Слишком большое значение: ожидалось, что ${n.origin??"значение"} будет иметь ${i}${n.maximum.toString()} ${l}`}return`Слишком большое значение: ожидалось, что ${n.origin??"значение"} будет ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);if(a){const s=Number(n.minimum),l=Yd(s,a.unit.one,a.unit.few,a.unit.many);return`Слишком маленькое значение: ожидалось, что ${n.origin} будет иметь ${i}${n.minimum.toString()} ${l}`}return`Слишком маленькое значение: ожидалось, что ${n.origin} будет ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Неверная строка: должна начинаться с "${i.prefix}"`:i.format==="ends_with"?`Неверная строка: должна заканчиваться на "${i.suffix}"`:i.format==="includes"?`Неверная строка: должна содержать "${i.includes}"`:i.format==="regex"?`Неверная строка: должна соответствовать шаблону ${i.pattern}`:`Неверный ${o[i.format]??n.format}`}case"not_multiple_of":return`Неверное число: должно быть кратным ${n.divisor}`;case"unrecognized_keys":return`Нераспознанн${n.keys.length>1?"ые":"ый"} ключ${n.keys.length>1?"и":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Неверный ключ в ${n.origin}`;case"invalid_union":return"Неверные входные данные";case"invalid_element":return`Неверное значение в ${n.origin}`;default:return"Неверные входные данные"}}};function Xk(){return{localeError:Qk()}}const eE=()=>{const e={string:{unit:"znakov",verb:"imeti"},file:{unit:"bajtov",verb:"imeti"},array:{unit:"elementov",verb:"imeti"},set:{unit:"elementov",verb:"imeti"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"število";case"object":{if(Array.isArray(n))return"tabela";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"vnos",email:"e-poštni naslov",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO datum in čas",date:"ISO datum",time:"ISO čas",duration:"ISO trajanje",ipv4:"IPv4 naslov",ipv6:"IPv6 naslov",cidrv4:"obseg IPv4",cidrv6:"obseg IPv6",base64:"base64 kodiran niz",base64url:"base64url kodiran niz",json_string:"JSON niz",e164:"E.164 številka",jwt:"JWT",template_literal:"vnos"};return n=>{switch(n.code){case"invalid_type":return`Neveljaven vnos: pričakovano ${n.expected}, prejeto ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Neveljaven vnos: pričakovano ${H(n.values[0])}`:`Neveljavna možnost: pričakovano eno izmed ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Preveliko: pričakovano, da bo ${n.origin??"vrednost"} imelo ${i}${n.maximum.toString()} ${a.unit??"elementov"}`:`Preveliko: pričakovano, da bo ${n.origin??"vrednost"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Premajhno: pričakovano, da bo ${n.origin} imelo ${i}${n.minimum.toString()} ${a.unit}`:`Premajhno: pričakovano, da bo ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Neveljaven niz: mora se začeti z "${i.prefix}"`:i.format==="ends_with"?`Neveljaven niz: mora se končati z "${i.suffix}"`:i.format==="includes"?`Neveljaven niz: mora vsebovati "${i.includes}"`:i.format==="regex"?`Neveljaven niz: mora ustrezati vzorcu ${i.pattern}`:`Neveljaven ${o[i.format]??n.format}`}case"not_multiple_of":return`Neveljavno število: mora biti večkratnik ${n.divisor}`;case"unrecognized_keys":return`Neprepoznan${n.keys.length>1?"i ključi":" ključ"}: ${j(n.keys,", ")}`;case"invalid_key":return`Neveljaven ključ v ${n.origin}`;case"invalid_union":return"Neveljaven vnos";case"invalid_element":return`Neveljavna vrednost v ${n.origin}`;default:return"Neveljaven vnos"}}};function tE(){return{localeError:eE()}}const rE=()=>{const e={string:{unit:"tecken",verb:"att ha"},file:{unit:"bytes",verb:"att ha"},array:{unit:"objekt",verb:"att innehålla"},set:{unit:"objekt",verb:"att innehålla"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"antal";case"object":{if(Array.isArray(n))return"lista";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"reguljärt uttryck",email:"e-postadress",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO-datum och tid",date:"ISO-datum",time:"ISO-tid",duration:"ISO-varaktighet",ipv4:"IPv4-intervall",ipv6:"IPv6-intervall",cidrv4:"IPv4-spektrum",cidrv6:"IPv6-spektrum",base64:"base64-kodad sträng",base64url:"base64url-kodad sträng",json_string:"JSON-sträng",e164:"E.164-nummer",jwt:"JWT",template_literal:"mall-literal"};return n=>{switch(n.code){case"invalid_type":return`Ogiltig inmatning: förväntat ${n.expected}, fick ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ogiltig inmatning: förväntat ${H(n.values[0])}`:`Ogiltigt val: förväntade en av ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`För stor(t): förväntade ${n.origin??"värdet"} att ha ${i}${n.maximum.toString()} ${a.unit??"element"}`:`För stor(t): förväntat ${n.origin??"värdet"} att ha ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`För lite(t): förväntade ${n.origin??"värdet"} att ha ${i}${n.minimum.toString()} ${a.unit}`:`För lite(t): förväntade ${n.origin??"värdet"} att ha ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Ogiltig sträng: måste börja med "${i.prefix}"`:i.format==="ends_with"?`Ogiltig sträng: måste sluta med "${i.suffix}"`:i.format==="includes"?`Ogiltig sträng: måste innehålla "${i.includes}"`:i.format==="regex"?`Ogiltig sträng: måste matcha mönstret "${i.pattern}"`:`Ogiltig(t) ${o[i.format]??n.format}`}case"not_multiple_of":return`Ogiltigt tal: måste vara en multipel av ${n.divisor}`;case"unrecognized_keys":return`${n.keys.length>1?"Okända nycklar":"Okänd nyckel"}: ${j(n.keys,", ")}`;case"invalid_key":return`Ogiltig nyckel i ${n.origin??"värdet"}`;case"invalid_union":return"Ogiltig input";case"invalid_element":return`Ogiltigt värde i ${n.origin??"värdet"}`;default:return"Ogiltig input"}}};function nE(){return{localeError:rE()}}const oE=()=>{const e={string:{unit:"எழுத்துக்கள்",verb:"கொண்டிருக்க வேண்டும்"},file:{unit:"பைட்டுகள்",verb:"கொண்டிருக்க வேண்டும்"},array:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"},set:{unit:"உறுப்புகள்",verb:"கொண்டிருக்க வேண்டும்"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"எண் அல்லாதது":"எண்";case"object":{if(Array.isArray(n))return"அணி";if(n===null)return"வெறுமை";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"உள்ளீடு",email:"மின்னஞ்சல் முகவரி",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO தேதி நேரம்",date:"ISO தேதி",time:"ISO நேரம்",duration:"ISO கால அளவு",ipv4:"IPv4 முகவரி",ipv6:"IPv6 முகவரி",cidrv4:"IPv4 வரம்பு",cidrv6:"IPv6 வரம்பு",base64:"base64-encoded சரம்",base64url:"base64url-encoded சரம்",json_string:"JSON சரம்",e164:"E.164 எண்",jwt:"JWT",template_literal:"input"};return n=>{switch(n.code){case"invalid_type":return`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${n.expected}, பெறப்பட்டது ${r(n.input)}`;case"invalid_value":return n.values.length===1?`தவறான உள்ளீடு: எதிர்பார்க்கப்பட்டது ${H(n.values[0])}`:`தவறான விருப்பம்: எதிர்பார்க்கப்பட்டது ${j(n.values,"|")} இல் ஒன்று`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${n.origin??"மதிப்பு"} ${i}${n.maximum.toString()} ${a.unit??"உறுப்புகள்"} ஆக இருக்க வேண்டும்`:`மிக பெரியது: எதிர்பார்க்கப்பட்டது ${n.origin??"மதிப்பு"} ${i}${n.maximum.toString()} ஆக இருக்க வேண்டும்`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${n.origin} ${i}${n.minimum.toString()} ${a.unit} ஆக இருக்க வேண்டும்`:`மிகச் சிறியது: எதிர்பார்க்கப்பட்டது ${n.origin} ${i}${n.minimum.toString()} ஆக இருக்க வேண்டும்`}case"invalid_format":{const i=n;return i.format==="starts_with"?`தவறான சரம்: "${i.prefix}" இல் தொடங்க வேண்டும்`:i.format==="ends_with"?`தவறான சரம்: "${i.suffix}" இல் முடிவடைய வேண்டும்`:i.format==="includes"?`தவறான சரம்: "${i.includes}" ஐ உள்ளடக்க வேண்டும்`:i.format==="regex"?`தவறான சரம்: ${i.pattern} முறைபாட்டுடன் பொருந்த வேண்டும்`:`தவறான ${o[i.format]??n.format}`}case"not_multiple_of":return`தவறான எண்: ${n.divisor} இன் பலமாக இருக்க வேண்டும்`;case"unrecognized_keys":return`அடையாளம் தெரியாத விசை${n.keys.length>1?"கள்":""}: ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} இல் தவறான விசை`;case"invalid_union":return"தவறான உள்ளீடு";case"invalid_element":return`${n.origin} இல் தவறான மதிப்பு`;default:return"தவறான உள்ளீடு"}}};function iE(){return{localeError:oE()}}const aE=()=>{const e={string:{unit:"ตัวอักษร",verb:"ควรมี"},file:{unit:"ไบต์",verb:"ควรมี"},array:{unit:"รายการ",verb:"ควรมี"},set:{unit:"รายการ",verb:"ควรมี"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"ไม่ใช่ตัวเลข (NaN)":"ตัวเลข";case"object":{if(Array.isArray(n))return"อาร์เรย์ (Array)";if(n===null)return"ไม่มีค่า (null)";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ข้อมูลที่ป้อน",email:"ที่อยู่อีเมล",url:"URL",emoji:"อิโมจิ",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"วันที่เวลาแบบ ISO",date:"วันที่แบบ ISO",time:"เวลาแบบ ISO",duration:"ช่วงเวลาแบบ ISO",ipv4:"ที่อยู่ IPv4",ipv6:"ที่อยู่ IPv6",cidrv4:"ช่วง IP แบบ IPv4",cidrv6:"ช่วง IP แบบ IPv6",base64:"ข้อความแบบ Base64",base64url:"ข้อความแบบ Base64 สำหรับ URL",json_string:"ข้อความแบบ JSON",e164:"เบอร์โทรศัพท์ระหว่างประเทศ (E.164)",jwt:"โทเคน JWT",template_literal:"ข้อมูลที่ป้อน"};return n=>{switch(n.code){case"invalid_type":return`ประเภทข้อมูลไม่ถูกต้อง: ควรเป็น ${n.expected} แต่ได้รับ ${r(n.input)}`;case"invalid_value":return n.values.length===1?`ค่าไม่ถูกต้อง: ควรเป็น ${H(n.values[0])}`:`ตัวเลือกไม่ถูกต้อง: ควรเป็นหนึ่งใน ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"ไม่เกิน":"น้อยกว่า",a=t(n.origin);return a?`เกินกำหนด: ${n.origin??"ค่า"} ควรมี${i} ${n.maximum.toString()} ${a.unit??"รายการ"}`:`เกินกำหนด: ${n.origin??"ค่า"} ควรมี${i} ${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?"อย่างน้อย":"มากกว่า",a=t(n.origin);return a?`น้อยกว่ากำหนด: ${n.origin} ควรมี${i} ${n.minimum.toString()} ${a.unit}`:`น้อยกว่ากำหนด: ${n.origin} ควรมี${i} ${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`รูปแบบไม่ถูกต้อง: ข้อความต้องขึ้นต้นด้วย "${i.prefix}"`:i.format==="ends_with"?`รูปแบบไม่ถูกต้อง: ข้อความต้องลงท้ายด้วย "${i.suffix}"`:i.format==="includes"?`รูปแบบไม่ถูกต้อง: ข้อความต้องมี "${i.includes}" อยู่ในข้อความ`:i.format==="regex"?`รูปแบบไม่ถูกต้อง: ต้องตรงกับรูปแบบที่กำหนด ${i.pattern}`:`รูปแบบไม่ถูกต้อง: ${o[i.format]??n.format}`}case"not_multiple_of":return`ตัวเลขไม่ถูกต้อง: ต้องเป็นจำนวนที่หารด้วย ${n.divisor} ได้ลงตัว`;case"unrecognized_keys":return`พบคีย์ที่ไม่รู้จัก: ${j(n.keys,", ")}`;case"invalid_key":return`คีย์ไม่ถูกต้องใน ${n.origin}`;case"invalid_union":return"ข้อมูลไม่ถูกต้อง: ไม่ตรงกับรูปแบบยูเนียนที่กำหนดไว้";case"invalid_element":return`ข้อมูลไม่ถูกต้องใน ${n.origin}`;default:return"ข้อมูลไม่ถูกต้อง"}}};function sE(){return{localeError:aE()}}const uE=e=>{const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"NaN":"number";case"object":{if(Array.isArray(e))return"array";if(e===null)return"null";if(Object.getPrototypeOf(e)!==Object.prototype&&e.constructor)return e.constructor.name}}return t},lE=()=>{const e={string:{unit:"karakter",verb:"olmalı"},file:{unit:"bayt",verb:"olmalı"},array:{unit:"öğe",verb:"olmalı"},set:{unit:"öğe",verb:"olmalı"}};function t(o){return e[o]??null}const r={regex:"girdi",email:"e-posta adresi",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO tarih ve saat",date:"ISO tarih",time:"ISO saat",duration:"ISO süre",ipv4:"IPv4 adresi",ipv6:"IPv6 adresi",cidrv4:"IPv4 aralığı",cidrv6:"IPv6 aralığı",base64:"base64 ile şifrelenmiş metin",base64url:"base64url ile şifrelenmiş metin",json_string:"JSON dizesi",e164:"E.164 sayısı",jwt:"JWT",template_literal:"Şablon dizesi"};return o=>{switch(o.code){case"invalid_type":return`Geçersiz değer: beklenen ${o.expected}, alınan ${uE(o.input)}`;case"invalid_value":return o.values.length===1?`Geçersiz değer: beklenen ${H(o.values[0])}`:`Geçersiz seçenek: aşağıdakilerden biri olmalı: ${j(o.values,"|")}`;case"too_big":{const n=o.inclusive?"<=":"<",i=t(o.origin);return i?`Çok büyük: beklenen ${o.origin??"değer"} ${n}${o.maximum.toString()} ${i.unit??"öğe"}`:`Çok büyük: beklenen ${o.origin??"değer"} ${n}${o.maximum.toString()}`}case"too_small":{const n=o.inclusive?">=":">",i=t(o.origin);return i?`Çok küçük: beklenen ${o.origin} ${n}${o.minimum.toString()} ${i.unit}`:`Çok küçük: beklenen ${o.origin} ${n}${o.minimum.toString()}`}case"invalid_format":{const n=o;return n.format==="starts_with"?`Geçersiz metin: "${n.prefix}" ile başlamalı`:n.format==="ends_with"?`Geçersiz metin: "${n.suffix}" ile bitmeli`:n.format==="includes"?`Geçersiz metin: "${n.includes}" içermeli`:n.format==="regex"?`Geçersiz metin: ${n.pattern} desenine uymalı`:`Geçersiz ${r[n.format]??o.format}`}case"not_multiple_of":return`Geçersiz sayı: ${o.divisor} ile tam bölünebilmeli`;case"unrecognized_keys":return`Tanınmayan anahtar${o.keys.length>1?"lar":""}: ${j(o.keys,", ")}`;case"invalid_key":return`${o.origin} içinde geçersiz anahtar`;case"invalid_union":return"Geçersiz değer";case"invalid_element":return`${o.origin} içinde geçersiz değer`;default:return"Geçersiz değer"}}};function cE(){return{localeError:lE()}}const dE=()=>{const e={string:{unit:"символів",verb:"матиме"},file:{unit:"байтів",verb:"матиме"},array:{unit:"елементів",verb:"матиме"},set:{unit:"елементів",verb:"матиме"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"число";case"object":{if(Array.isArray(n))return"масив";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"вхідні дані",email:"адреса електронної пошти",url:"URL",emoji:"емодзі",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"дата та час ISO",date:"дата ISO",time:"час ISO",duration:"тривалість ISO",ipv4:"адреса IPv4",ipv6:"адреса IPv6",cidrv4:"діапазон IPv4",cidrv6:"діапазон IPv6",base64:"рядок у кодуванні base64",base64url:"рядок у кодуванні base64url",json_string:"рядок JSON",e164:"номер E.164",jwt:"JWT",template_literal:"вхідні дані"};return n=>{switch(n.code){case"invalid_type":return`Неправильні вхідні дані: очікується ${n.expected}, отримано ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Неправильні вхідні дані: очікується ${H(n.values[0])}`:`Неправильна опція: очікується одне з ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Занадто велике: очікується, що ${n.origin??"значення"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"елементів"}`:`Занадто велике: очікується, що ${n.origin??"значення"} буде ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Занадто мале: очікується, що ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Занадто мале: очікується, що ${n.origin} буде ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Неправильний рядок: повинен починатися з "${i.prefix}"`:i.format==="ends_with"?`Неправильний рядок: повинен закінчуватися на "${i.suffix}"`:i.format==="includes"?`Неправильний рядок: повинен містити "${i.includes}"`:i.format==="regex"?`Неправильний рядок: повинен відповідати шаблону ${i.pattern}`:`Неправильний ${o[i.format]??n.format}`}case"not_multiple_of":return`Неправильне число: повинно бути кратним ${n.divisor}`;case"unrecognized_keys":return`Нерозпізнаний ключ${n.keys.length>1?"і":""}: ${j(n.keys,", ")}`;case"invalid_key":return`Неправильний ключ у ${n.origin}`;case"invalid_union":return"Неправильні вхідні дані";case"invalid_element":return`Неправильне значення у ${n.origin}`;default:return"Неправильні вхідні дані"}}};function _v(){return{localeError:dE()}}function pE(){return _v()}const fE=()=>{const e={string:{unit:"حروف",verb:"ہونا"},file:{unit:"بائٹس",verb:"ہونا"},array:{unit:"آئٹمز",verb:"ہونا"},set:{unit:"آئٹمز",verb:"ہونا"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"نمبر";case"object":{if(Array.isArray(n))return"آرے";if(n===null)return"نل";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ان پٹ",email:"ای میل ایڈریس",url:"یو آر ایل",emoji:"ایموجی",uuid:"یو یو آئی ڈی",uuidv4:"یو یو آئی ڈی وی 4",uuidv6:"یو یو آئی ڈی وی 6",nanoid:"نینو آئی ڈی",guid:"جی یو آئی ڈی",cuid:"سی یو آئی ڈی",cuid2:"سی یو آئی ڈی 2",ulid:"یو ایل آئی ڈی",xid:"ایکس آئی ڈی",ksuid:"کے ایس یو آئی ڈی",datetime:"آئی ایس او ڈیٹ ٹائم",date:"آئی ایس او تاریخ",time:"آئی ایس او وقت",duration:"آئی ایس او مدت",ipv4:"آئی پی وی 4 ایڈریس",ipv6:"آئی پی وی 6 ایڈریس",cidrv4:"آئی پی وی 4 رینج",cidrv6:"آئی پی وی 6 رینج",base64:"بیس 64 ان کوڈڈ سٹرنگ",base64url:"بیس 64 یو آر ایل ان کوڈڈ سٹرنگ",json_string:"جے ایس او این سٹرنگ",e164:"ای 164 نمبر",jwt:"جے ڈبلیو ٹی",template_literal:"ان پٹ"};return n=>{switch(n.code){case"invalid_type":return`غلط ان پٹ: ${n.expected} متوقع تھا، ${r(n.input)} موصول ہوا`;case"invalid_value":return n.values.length===1?`غلط ان پٹ: ${H(n.values[0])} متوقع تھا`:`غلط آپشن: ${j(n.values,"|")} میں سے ایک متوقع تھا`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`بہت بڑا: ${n.origin??"ویلیو"} کے ${i}${n.maximum.toString()} ${a.unit??"عناصر"} ہونے متوقع تھے`:`بہت بڑا: ${n.origin??"ویلیو"} کا ${i}${n.maximum.toString()} ہونا متوقع تھا`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`بہت چھوٹا: ${n.origin} کے ${i}${n.minimum.toString()} ${a.unit} ہونے متوقع تھے`:`بہت چھوٹا: ${n.origin} کا ${i}${n.minimum.toString()} ہونا متوقع تھا`}case"invalid_format":{const i=n;return i.format==="starts_with"?`غلط سٹرنگ: "${i.prefix}" سے شروع ہونا چاہیے`:i.format==="ends_with"?`غلط سٹرنگ: "${i.suffix}" پر ختم ہونا چاہیے`:i.format==="includes"?`غلط سٹرنگ: "${i.includes}" شامل ہونا چاہیے`:i.format==="regex"?`غلط سٹرنگ: پیٹرن ${i.pattern} سے میچ ہونا چاہیے`:`غلط ${o[i.format]??n.format}`}case"not_multiple_of":return`غلط نمبر: ${n.divisor} کا مضاعف ہونا چاہیے`;case"unrecognized_keys":return`غیر تسلیم شدہ کی${n.keys.length>1?"ز":""}: ${j(n.keys,"، ")}`;case"invalid_key":return`${n.origin} میں غلط کی`;case"invalid_union":return"غلط ان پٹ";case"invalid_element":return`${n.origin} میں غلط ویلیو`;default:return"غلط ان پٹ"}}};function mE(){return{localeError:fE()}}const hE=()=>{const e={string:{unit:"ký tự",verb:"có"},file:{unit:"byte",verb:"có"},array:{unit:"phần tử",verb:"có"},set:{unit:"phần tử",verb:"có"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"số";case"object":{if(Array.isArray(n))return"mảng";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"đầu vào",email:"địa chỉ email",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ngày giờ ISO",date:"ngày ISO",time:"giờ ISO",duration:"khoảng thời gian ISO",ipv4:"địa chỉ IPv4",ipv6:"địa chỉ IPv6",cidrv4:"dải IPv4",cidrv6:"dải IPv6",base64:"chuỗi mã hóa base64",base64url:"chuỗi mã hóa base64url",json_string:"chuỗi JSON",e164:"số E.164",jwt:"JWT",template_literal:"đầu vào"};return n=>{switch(n.code){case"invalid_type":return`Đầu vào không hợp lệ: mong đợi ${n.expected}, nhận được ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Đầu vào không hợp lệ: mong đợi ${H(n.values[0])}`:`Tùy chọn không hợp lệ: mong đợi một trong các giá trị ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Quá lớn: mong đợi ${n.origin??"giá trị"} ${a.verb} ${i}${n.maximum.toString()} ${a.unit??"phần tử"}`:`Quá lớn: mong đợi ${n.origin??"giá trị"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Quá nhỏ: mong đợi ${n.origin} ${a.verb} ${i}${n.minimum.toString()} ${a.unit}`:`Quá nhỏ: mong đợi ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Chuỗi không hợp lệ: phải bắt đầu bằng "${i.prefix}"`:i.format==="ends_with"?`Chuỗi không hợp lệ: phải kết thúc bằng "${i.suffix}"`:i.format==="includes"?`Chuỗi không hợp lệ: phải bao gồm "${i.includes}"`:i.format==="regex"?`Chuỗi không hợp lệ: phải khớp với mẫu ${i.pattern}`:`${o[i.format]??n.format} không hợp lệ`}case"not_multiple_of":return`Số không hợp lệ: phải là bội số của ${n.divisor}`;case"unrecognized_keys":return`Khóa không được nhận dạng: ${j(n.keys,", ")}`;case"invalid_key":return`Khóa không hợp lệ trong ${n.origin}`;case"invalid_union":return"Đầu vào không hợp lệ";case"invalid_element":return`Giá trị không hợp lệ trong ${n.origin}`;default:return"Đầu vào không hợp lệ"}}};function gE(){return{localeError:hE()}}const vE=()=>{const e={string:{unit:"字符",verb:"包含"},file:{unit:"字节",verb:"包含"},array:{unit:"项",verb:"包含"},set:{unit:"项",verb:"包含"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"非数字(NaN)":"数字";case"object":{if(Array.isArray(n))return"数组";if(n===null)return"空值(null)";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"输入",email:"电子邮件",url:"URL",emoji:"表情符号",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO日期时间",date:"ISO日期",time:"ISO时间",duration:"ISO时长",ipv4:"IPv4地址",ipv6:"IPv6地址",cidrv4:"IPv4网段",cidrv6:"IPv6网段",base64:"base64编码字符串",base64url:"base64url编码字符串",json_string:"JSON字符串",e164:"E.164号码",jwt:"JWT",template_literal:"输入"};return n=>{switch(n.code){case"invalid_type":return`无效输入:期望 ${n.expected},实际接收 ${r(n.input)}`;case"invalid_value":return n.values.length===1?`无效输入:期望 ${H(n.values[0])}`:`无效选项:期望以下之一 ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`数值过大:期望 ${n.origin??"值"} ${i}${n.maximum.toString()} ${a.unit??"个元素"}`:`数值过大:期望 ${n.origin??"值"} ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`数值过小:期望 ${n.origin} ${i}${n.minimum.toString()} ${a.unit}`:`数值过小:期望 ${n.origin} ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`无效字符串:必须以 "${i.prefix}" 开头`:i.format==="ends_with"?`无效字符串:必须以 "${i.suffix}" 结尾`:i.format==="includes"?`无效字符串:必须包含 "${i.includes}"`:i.format==="regex"?`无效字符串:必须满足正则表达式 ${i.pattern}`:`无效${o[i.format]??n.format}`}case"not_multiple_of":return`无效数字:必须是 ${n.divisor} 的倍数`;case"unrecognized_keys":return`出现未知的键(key): ${j(n.keys,", ")}`;case"invalid_key":return`${n.origin} 中的键(key)无效`;case"invalid_union":return"无效输入";case"invalid_element":return`${n.origin} 中包含无效值(value)`;default:return"无效输入"}}};function yE(){return{localeError:vE()}}const bE=()=>{const e={string:{unit:"字元",verb:"擁有"},file:{unit:"位元組",verb:"擁有"},array:{unit:"項目",verb:"擁有"},set:{unit:"項目",verb:"擁有"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"number";case"object":{if(Array.isArray(n))return"array";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"輸入",email:"郵件地址",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"ISO 日期時間",date:"ISO 日期",time:"ISO 時間",duration:"ISO 期間",ipv4:"IPv4 位址",ipv6:"IPv6 位址",cidrv4:"IPv4 範圍",cidrv6:"IPv6 範圍",base64:"base64 編碼字串",base64url:"base64url 編碼字串",json_string:"JSON 字串",e164:"E.164 數值",jwt:"JWT",template_literal:"輸入"};return n=>{switch(n.code){case"invalid_type":return`無效的輸入值:預期為 ${n.expected},但收到 ${r(n.input)}`;case"invalid_value":return n.values.length===1?`無效的輸入值:預期為 ${H(n.values[0])}`:`無效的選項:預期為以下其中之一 ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`數值過大:預期 ${n.origin??"值"} 應為 ${i}${n.maximum.toString()} ${a.unit??"個元素"}`:`數值過大:預期 ${n.origin??"值"} 應為 ${i}${n.maximum.toString()}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`數值過小:預期 ${n.origin} 應為 ${i}${n.minimum.toString()} ${a.unit}`:`數值過小:預期 ${n.origin} 應為 ${i}${n.minimum.toString()}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`無效的字串:必須以 "${i.prefix}" 開頭`:i.format==="ends_with"?`無效的字串:必須以 "${i.suffix}" 結尾`:i.format==="includes"?`無效的字串:必須包含 "${i.includes}"`:i.format==="regex"?`無效的字串:必須符合格式 ${i.pattern}`:`無效的 ${o[i.format]??n.format}`}case"not_multiple_of":return`無效的數字:必須為 ${n.divisor} 的倍數`;case"unrecognized_keys":return`無法識別的鍵值${n.keys.length>1?"們":""}:${j(n.keys,"、")}`;case"invalid_key":return`${n.origin} 中有無效的鍵值`;case"invalid_union":return"無效的輸入值";case"invalid_element":return`${n.origin} 中有無效的值`;default:return"無效的輸入值"}}};function _E(){return{localeError:bE()}}const wE=()=>{const e={string:{unit:"àmi",verb:"ní"},file:{unit:"bytes",verb:"ní"},array:{unit:"nkan",verb:"ní"},set:{unit:"nkan",verb:"ní"}};function t(n){return e[n]??null}const r=n=>{const i=typeof n;switch(i){case"number":return Number.isNaN(n)?"NaN":"nọ́mbà";case"object":{if(Array.isArray(n))return"akopọ";if(n===null)return"null";if(Object.getPrototypeOf(n)!==Object.prototype&&n.constructor)return n.constructor.name}}return i},o={regex:"ẹ̀rọ ìbáwọlé",email:"àdírẹ́sì ìmẹ́lì",url:"URL",emoji:"emoji",uuid:"UUID",uuidv4:"UUIDv4",uuidv6:"UUIDv6",nanoid:"nanoid",guid:"GUID",cuid:"cuid",cuid2:"cuid2",ulid:"ULID",xid:"XID",ksuid:"KSUID",datetime:"àkókò ISO",date:"ọjọ́ ISO",time:"àkókò ISO",duration:"àkókò tó pé ISO",ipv4:"àdírẹ́sì IPv4",ipv6:"àdírẹ́sì IPv6",cidrv4:"àgbègbè IPv4",cidrv6:"àgbègbè IPv6",base64:"ọ̀rọ̀ tí a kọ́ ní base64",base64url:"ọ̀rọ̀ base64url",json_string:"ọ̀rọ̀ JSON",e164:"nọ́mbà E.164",jwt:"JWT",template_literal:"ẹ̀rọ ìbáwọlé"};return n=>{switch(n.code){case"invalid_type":return`Ìbáwọlé aṣìṣe: a ní láti fi ${n.expected}, àmọ̀ a rí ${r(n.input)}`;case"invalid_value":return n.values.length===1?`Ìbáwọlé aṣìṣe: a ní láti fi ${H(n.values[0])}`:`Àṣàyàn aṣìṣe: yan ọ̀kan lára ${j(n.values,"|")}`;case"too_big":{const i=n.inclusive?"<=":"<",a=t(n.origin);return a?`Tó pọ̀ jù: a ní láti jẹ́ pé ${n.origin??"iye"} ${a.verb} ${i}${n.maximum} ${a.unit}`:`Tó pọ̀ jù: a ní láti jẹ́ ${i}${n.maximum}`}case"too_small":{const i=n.inclusive?">=":">",a=t(n.origin);return a?`Kéré ju: a ní láti jẹ́ pé ${n.origin} ${a.verb} ${i}${n.minimum} ${a.unit}`:`Kéré ju: a ní láti jẹ́ ${i}${n.minimum}`}case"invalid_format":{const i=n;return i.format==="starts_with"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bẹ̀rẹ̀ pẹ̀lú "${i.prefix}"`:i.format==="ends_with"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ parí pẹ̀lú "${i.suffix}"`:i.format==="includes"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ ní "${i.includes}"`:i.format==="regex"?`Ọ̀rọ̀ aṣìṣe: gbọ́dọ̀ bá àpẹẹrẹ mu ${i.pattern}`:`Aṣìṣe: ${o[i.format]??n.format}`}case"not_multiple_of":return`Nọ́mbà aṣìṣe: gbọ́dọ̀ jẹ́ èyà pípín ti ${n.divisor}`;case"unrecognized_keys":return`Bọtìnì àìmọ̀: ${j(n.keys,", ")}`;case"invalid_key":return`Bọtìnì aṣìṣe nínú ${n.origin}`;case"invalid_union":return"Ìbáwọlé aṣìṣe";case"invalid_element":return`Iye aṣìṣe nínú ${n.origin}`;default:return"Ìbáwọlé aṣìṣe"}}};function xE(){return{localeError:wE()}}const wv=Object.freeze(Object.defineProperty({__proto__:null,ar:zI,az:DI,be:LI,bg:qI,ca:BI,cs:WI,da:GI,de:YI,en:yv,eo:rk,es:ok,fa:ak,fi:uk,fr:ck,frCA:pk,he:mk,hu:gk,id:yk,is:wk,it:$k,ja:Ik,ka:Tk,kh:Nk,km:bv,ko:Ck,lt:Rk,mk:Mk,ms:Uk,nl:Zk,no:qk,ota:Bk,pl:Gk,ps:Wk,pt:Yk,ru:Xk,sl:tE,sv:nE,ta:iE,th:sE,tr:cE,ua:pE,uk:_v,ur:mE,vi:gE,yo:xE,zhCN:yE,zhTW:_E},Symbol.toStringTag,{value:"Module"}));var Qd;const xv=Symbol("ZodOutput"),$v=Symbol("ZodInput");class Sv{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){const o=r[0];if(this._map.set(t,o),o&&typeof o=="object"&&"id"in o){if(this._idmap.has(o.id))throw new Error(`ID ${o.id} already exists in the registry`);this._idmap.set(o.id,t)}return this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){const r=t._zod.parent;if(r){const o={...this.get(r)??{}};delete o.id;const n={...o,...this._map.get(t)};return Object.keys(n).length?n:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function ul(){return new Sv}(Qd=globalThis).__zod_globalRegistry??(Qd.__zod_globalRegistry=ul());const wt=globalThis.__zod_globalRegistry;function Iv(e,t){return new e({type:"string",...P(t)})}function kv(e,t){return new e({type:"string",coerce:!0,...P(t)})}function ll(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...P(t)})}function mi(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...P(t)})}function cl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...P(t)})}function dl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...P(t)})}function pl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...P(t)})}function fl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...P(t)})}function Xi(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...P(t)})}function ml(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...P(t)})}function hl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...P(t)})}function gl(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...P(t)})}function vl(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...P(t)})}function yl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...P(t)})}function bl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...P(t)})}function _l(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...P(t)})}function wl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...P(t)})}function xl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...P(t)})}function Ev(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...P(t)})}function $l(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...P(t)})}function Sl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...P(t)})}function Il(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...P(t)})}function kl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...P(t)})}function El(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...P(t)})}function Tl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...P(t)})}const Tv={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Ov(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...P(t)})}function Nv(e,t){return new e({type:"string",format:"date",check:"string_format",...P(t)})}function Pv(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...P(t)})}function Cv(e,t){return new e({type:"string",format:"duration",check:"string_format",...P(t)})}function jv(e,t){return new e({type:"number",checks:[],...P(t)})}function Av(e,t){return new e({type:"number",coerce:!0,checks:[],...P(t)})}function Rv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...P(t)})}function zv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...P(t)})}function Mv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...P(t)})}function Dv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...P(t)})}function Uv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...P(t)})}function Lv(e,t){return new e({type:"boolean",...P(t)})}function Zv(e,t){return new e({type:"boolean",coerce:!0,...P(t)})}function Fv(e,t){return new e({type:"bigint",...P(t)})}function qv(e,t){return new e({type:"bigint",coerce:!0,...P(t)})}function Vv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...P(t)})}function Bv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...P(t)})}function Jv(e,t){return new e({type:"symbol",...P(t)})}function Wv(e,t){return new e({type:"undefined",...P(t)})}function Hv(e,t){return new e({type:"null",...P(t)})}function Gv(e){return new e({type:"any"})}function Kv(e){return new e({type:"unknown"})}function Yv(e,t){return new e({type:"never",...P(t)})}function Qv(e,t){return new e({type:"void",...P(t)})}function Xv(e,t){return new e({type:"date",...P(t)})}function ey(e,t){return new e({type:"date",coerce:!0,...P(t)})}function ty(e,t){return new e({type:"nan",...P(t)})}function ir(e,t){return new el({check:"less_than",...P(t),value:e,inclusive:!1})}function st(e,t){return new el({check:"less_than",...P(t),value:e,inclusive:!0})}function ar(e,t){return new tl({check:"greater_than",...P(t),value:e,inclusive:!1})}function We(e,t){return new tl({check:"greater_than",...P(t),value:e,inclusive:!0})}function Ol(e){return ar(0,e)}function Nl(e){return ir(0,e)}function Pl(e){return st(0,e)}function Cl(e){return We(0,e)}function Kr(e,t){return new Uh({check:"multiple_of",...P(t),value:e})}function uo(e,t){return new Fh({check:"max_size",...P(t),maximum:e})}function Yr(e,t){return new qh({check:"min_size",...P(t),minimum:e})}function ea(e,t){return new Vh({check:"size_equals",...P(t),size:e})}function lo(e,t){return new Bh({check:"max_length",...P(t),maximum:e})}function br(e,t){return new Jh({check:"min_length",...P(t),minimum:e})}function co(e,t){return new Wh({check:"length_equals",...P(t),length:e})}function ta(e,t){return new Hh({check:"string_format",format:"regex",...P(t),pattern:e})}function ra(e){return new Gh({check:"string_format",format:"lowercase",...P(e)})}function na(e){return new Kh({check:"string_format",format:"uppercase",...P(e)})}function oa(e,t){return new Yh({check:"string_format",format:"includes",...P(t),includes:e})}function ia(e,t){return new Qh({check:"string_format",format:"starts_with",...P(t),prefix:e})}function aa(e,t){return new Xh({check:"string_format",format:"ends_with",...P(t),suffix:e})}function jl(e,t,r){return new eg({check:"property",property:e,schema:t,...P(r)})}function sa(e,t){return new tg({check:"mime_type",mime:e,...P(t)})}function Ht(e){return new rg({check:"overwrite",tx:e})}function ua(e){return Ht(t=>t.normalize(e))}function la(){return Ht(e=>e.trim())}function ca(){return Ht(e=>e.toLowerCase())}function da(){return Ht(e=>e.toUpperCase())}function pa(){return Ht(e=>Rm(e))}function ry(e,t,r){return new e({type:"array",element:t,...P(r)})}function $E(e,t,r){return new e({type:"union",options:t,...P(r)})}function SE(e,t,r){return new e({type:"union",options:t,inclusive:!1,...P(r)})}function IE(e,t,r,o){return new e({type:"union",options:r,discriminator:t,...P(o)})}function kE(e,t,r){return new e({type:"intersection",left:t,right:r})}function EE(e,t,r,o){const n=r instanceof X,i=n?o:r,a=n?r:null;return new e({type:"tuple",items:t,rest:a,...P(i)})}function TE(e,t,r,o){return new e({type:"record",keyType:t,valueType:r,...P(o)})}function OE(e,t,r,o){return new e({type:"map",keyType:t,valueType:r,...P(o)})}function NE(e,t,r){return new e({type:"set",valueType:t,...P(r)})}function PE(e,t,r){const o=Array.isArray(t)?Object.fromEntries(t.map(n=>[n,n])):t;return new e({type:"enum",entries:o,...P(r)})}function CE(e,t,r){return new e({type:"enum",entries:t,...P(r)})}function jE(e,t,r){return new e({type:"literal",values:Array.isArray(t)?t:[t],...P(r)})}function ny(e,t){return new e({type:"file",...P(t)})}function AE(e,t){return new e({type:"transform",transform:t})}function RE(e,t){return new e({type:"optional",innerType:t})}function zE(e,t){return new e({type:"nullable",innerType:t})}function ME(e,t,r){return new e({type:"default",innerType:t,get defaultValue(){return typeof r=="function"?r():Gi(r)}})}function DE(e,t,r){return new e({type:"nonoptional",innerType:t,...P(r)})}function UE(e,t){return new e({type:"success",innerType:t})}function LE(e,t,r){return new e({type:"catch",innerType:t,catchValue:typeof r=="function"?r:()=>r})}function ZE(e,t,r){return new e({type:"pipe",in:t,out:r})}function FE(e,t){return new e({type:"readonly",innerType:t})}function qE(e,t,r){return new e({type:"template_literal",parts:t,...P(r)})}function VE(e,t){return new e({type:"lazy",getter:t})}function BE(e,t){return new e({type:"promise",innerType:t})}function oy(e,t,r){const o=P(r);return o.abort??(o.abort=!0),new e({type:"custom",check:"custom",fn:t,...o})}function iy(e,t,r){return new e({type:"custom",check:"custom",fn:t,...P(r)})}function ay(e){const t=sy(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Hr(o,r.value,t._zod.def));else{const n=o;n.fatal&&(n.continue=!1),n.code??(n.code="custom"),n.input??(n.input=r.value),n.inst??(n.inst=t),n.continue??(n.continue=!t._zod.def.abort),r.issues.push(Hr(n))}},e(r.value,r)));return t}function sy(e,t){const r=new Se({check:"custom",...P(t)});return r._zod.check=e,r}function uy(e){const t=new Se({check:"describe"});return t._zod.onattach=[r=>{const o=wt.get(r)??{};wt.add(r,{...o,description:e})}],t._zod.check=()=>{},t}function ly(e){const t=new Se({check:"meta"});return t._zod.onattach=[r=>{const o=wt.get(r)??{};wt.add(r,{...o,...e})}],t._zod.check=()=>{},t}function cy(e,t){const r=P(t);let o=r.truthy??["true","1","yes","on","y","enabled"],n=r.falsy??["false","0","no","off","n","disabled"];r.case!=="sensitive"&&(o=o.map(p=>typeof p=="string"?p.toLowerCase():p),n=n.map(p=>typeof p=="string"?p.toLowerCase():p));const i=new Set(o),a=new Set(n),s=e.Codec??sl,l=e.Boolean??ol,u=e.String??so,c=new u({type:"string",error:r.error}),d=new l({type:"boolean",error:r.error}),f=new s({type:"pipe",in:c,out:d,transform:((p,g)=>{let h=p;return r.case!=="sensitive"&&(h=h.toLowerCase()),i.has(h)?!0:a.has(h)?!1:(g.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...a],input:g.value,inst:f,continue:!1}),{})}),reverseTransform:((p,g)=>p===!0?o[0]||"true":n[0]||"false"),error:r.error});return f}function po(e,t,r,o={}){const n=P(o),i={...P(o),check:"string_format",type:"string",format:t,fn:typeof r=="function"?r:s=>r.test(s),...n};return r instanceof RegExp&&(i.pattern=r),new e(i)}function Qr(e){let t=e?.target??"draft-2020-12";return t==="draft-4"&&(t="draft-04"),t==="draft-7"&&(t="draft-07"),{processors:e.processors??{},metadataRegistry:e?.metadata??wt,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,cycles:e?.cycles??"ref",reused:e?.reused??"inline",external:e?.external??void 0}}function he(e,t,r={path:[],schemaPath:[]}){var o;const n=e._zod.def,i=t.seen.get(e);if(i)return i.count++,r.schemaPath.includes(e)&&(i.cycle=r.path),i.schema;const a={schema:{},count:1,cycle:void 0,path:r.path};t.seen.set(e,a);const s=e._zod.toJSONSchema?.();if(s)a.schema=s;else{const c={...r,schemaPath:[...r.schemaPath,e],path:r.path},d=e._zod.parent;if(d)a.ref=d,he(d,t,c),t.seen.get(d).isParent=!0;else if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,a.schema,c);else{const f=a.schema,p=t.processors[n.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${n.type}`);p(e,t,f,c)}}const l=t.metadataRegistry.get(e);return l&&Object.assign(a.schema,l),t.io==="input"&&Ve(e)&&(delete a.schema.examples,delete a.schema.default),t.io==="input"&&a.schema._prefault&&((o=a.schema).default??(o.default=a.schema._prefault)),delete a.schema._prefault,t.seen.get(e).schema}function Xr(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=i=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const c=e.external.registry.get(i[0])?.id,d=e.external.uri??(p=>p);if(c)return{ref:d(c)};const f=i[1].defId??i[1].schema.id??`schema${e.counter++}`;return i[1].defId=f,{defId:f,ref:`${d("__shared")}#/${a}/${f}`}}if(i[1]===r)return{ref:"#"};const l=`#/${a}/`,u=i[1].schema.id??`__schema${e.counter++}`;return{defId:u,ref:l+u}},n=i=>{if(i[1].schema.$ref)return;const a=i[1],{ref:s,defId:l}=o(i);a.def={...a.schema},l&&(a.defId=l);const u=a.schema;for(const c in u)delete u[c];u.$ref=s};if(e.cycles==="throw")for(const i of e.seen.entries()){const a=i[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
28
28
|
|
|
29
|
-
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){n(i);continue}if(e.external){const l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){n(i);continue}}if(e.metadataRegistry.get(i[0])?.id){n(i);continue}if(a.cycle){n(i);continue}if(a.count>1&&e.reused==="ref"){n(i);continue}}}function en(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=a=>{const s=e.seen.get(a),l=s.def??s.schema,u={...l};if(s.ref===null)return;const c=s.ref;if(s.ref=null,c){o(c);const d=e.seen.get(c).schema;d.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(d)):(Object.assign(l,d),Object.assign(l,u))}s.isParent||e.override({zodSchema:a,jsonSchema:l,path:s.path??[]})};for(const a of[...e.seen.entries()].reverse())o(a[0]);const n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const s=a[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?n.$defs=i:n.definitions=i);try{const a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Cn(t,"input"),output:Cn(t,"output")}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ve(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Ve(o.element,r);if(o.type==="set")return Ve(o.valueType,r);if(o.type==="lazy")return Ve(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Ve(o.innerType,r);if(o.type==="intersection")return Ve(o.left,r)||Ve(o.right,r);if(o.type==="record"||o.type==="map")return Ve(o.keyType,r)||Ve(o.valueType,r);if(o.type==="pipe")return Ve(o.in,r)||Ve(o.out,r);if(o.type==="object"){for(const n in o.shape)if(Ve(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(const n of o.options)if(Ve(n,r))return!0;return!1}if(o.type==="tuple"){for(const n of o.items)if(Ve(n,r))return!0;return!!(o.rest&&Ve(o.rest,r))}return!1}const dy=(e,t={})=>r=>{const o=Qr({...r,processors:t});return he(e,o),Xr(o,e),en(o,e)},Cn=(e,t)=>r=>{const{libraryOptions:o,target:n}=r??{},i=Qr({...o??{},target:n,io:t,processors:{}});return he(e,i),Xr(i,e),en(i,e)},JE={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},py=(e,t,r,o)=>{const n=r;n.type="string";const{minimum:i,maximum:a,format:s,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(n.minLength=i),typeof a=="number"&&(n.maxLength=a),s&&(n.format=JE[s]??s,n.format===""&&delete n.format),u&&(n.contentEncoding=u),l&&l.size>0){const c=[...l];c.length===1?n.pattern=c[0].source:c.length>1&&(n.allOf=[...c.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},fy=(e,t,r,o)=>{const n=r,{minimum:i,maximum:a,format:s,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:c}=e._zod.bag;typeof s=="string"&&s.includes("int")?n.type="integer":n.type="number",typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c),typeof i=="number"&&(n.minimum=i,typeof c=="number"&&t.target!=="draft-04"&&(c>=i?delete n.minimum:delete n.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u),typeof a=="number"&&(n.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete n.maximum:delete n.exclusiveMaximum)),typeof l=="number"&&(n.multipleOf=l)},my=(e,t,r,o)=>{r.type="boolean"},hy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},gy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},vy=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},yy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},by=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},_y=(e,t,r,o)=>{r.not={}},wy=(e,t,r,o)=>{},xy=(e,t,r,o)=>{},$y=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Sy=(e,t,r,o)=>{const n=e._zod.def,i=Uu(n.entries);i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},Iy=(e,t,r,o)=>{const n=e._zod.def,i=[];for(const a of n.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},ky=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},Ey=(e,t,r,o)=>{const n=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},Ty=(e,t,r,o)=>{const n=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:l}=e._zod.bag;a!==void 0&&(i.minLength=a),s!==void 0&&(i.maxLength=s),l?l.length===1?(i.contentMediaType=l[0],Object.assign(n,i)):n.anyOf=l.map(u=>({...i,contentMediaType:u})):Object.assign(n,i)},Oy=(e,t,r,o)=>{r.type="boolean"},Ny=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Py=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Cy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},jy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Ay=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Ry=(e,t,r,o)=>{const n=r,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(n.minItems=a),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=he(i.element,t,{...o,path:[...o.path,"items"]})},zy=(e,t,r,o)=>{const n=r,i=e._zod.def;n.type="object",n.properties={};const a=i.shape;for(const u in a)n.properties[u]=he(a[u],t,{...o,path:[...o.path,"properties",u]});const s=new Set(Object.keys(a)),l=new Set([...s].filter(u=>{const c=i.shape[u]._zod;return t.io==="input"?c.optin===void 0:c.optout===void 0}));l.size>0&&(n.required=Array.from(l)),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=he(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},Al=(e,t,r,o)=>{const n=e._zod.def,i=n.inclusive===!1,a=n.options.map((s,l)=>he(s,t,{...o,path:[...o.path,i?"oneOf":"anyOf",l]}));i?r.oneOf=a:r.anyOf=a},My=(e,t,r,o)=>{const n=e._zod.def,i=he(n.left,t,{...o,path:[...o.path,"allOf",0]}),a=he(n.right,t,{...o,path:[...o.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,l=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];r.allOf=l},Dy=(e,t,r,o)=>{const n=r,i=e._zod.def;n.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=i.items.map((f,p)=>he(f,t,{...o,path:[...o.path,a,p]})),u=i.rest?he(i.rest,t,{...o,path:[...o.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;t.target==="draft-2020-12"?(n.prefixItems=l,u&&(n.items=u)):t.target==="openapi-3.0"?(n.items={anyOf:l},u&&n.items.anyOf.push(u),n.minItems=l.length,u||(n.maxItems=l.length)):(n.items=l,u&&(n.additionalItems=u));const{minimum:c,maximum:d}=e._zod.bag;typeof c=="number"&&(n.minItems=c),typeof d=="number"&&(n.maxItems=d)},Uy=(e,t,r,o)=>{const n=r,i=e._zod.def;n.type="object",(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=he(i.keyType,t,{...o,path:[...o.path,"propertyNames"]})),n.additionalProperties=he(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})},Ly=(e,t,r,o)=>{const n=e._zod.def,i=he(n.innerType,t,o),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Zy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType},Fy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},qy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},Vy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},By=(e,t,r,o)=>{const n=e._zod.def,i=t.io==="input"?n.in._zod.def.type==="transform"?n.out:n.in:n.out;he(i,t,o);const a=t.seen.get(e);a.ref=i},Jy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},Wy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType},Hy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType},Gy=(e,t,r,o)=>{const n=e._zod.innerType;he(n,t,o);const i=t.seen.get(e);i.ref=n},tu={string:py,number:fy,boolean:my,bigint:hy,symbol:gy,null:vy,undefined:yy,void:by,never:_y,any:wy,unknown:xy,date:$y,enum:Sy,literal:Iy,nan:ky,template_literal:Ey,file:Ty,success:Oy,custom:Ny,function:Py,transform:Cy,map:jy,set:Ay,array:Ry,object:zy,union:Al,intersection:My,tuple:Dy,record:Uy,nullable:Ly,nonoptional:Zy,default:Fy,prefault:qy,catch:Vy,pipe:By,readonly:Jy,promise:Wy,optional:Hy,lazy:Gy};function pa(e,t){if("_idmap"in e){const o=e,n=Qr({...t,processors:tu}),i={};for(const l of o._idmap.entries()){const[u,c]=l;he(c,n)}const a={},s={registry:o,uri:t?.uri,defs:i};n.external=s;for(const l of o._idmap.entries()){const[u,c]=l;Xr(n,c),a[u]=en(n,c)}if(Object.keys(i).length>0){const l=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:i}}return{schemas:a}}const r=Qr({...t,processors:tu});return he(e,r),Xr(r,e),en(r,e)}class WE{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Qr({processors:tu,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return he(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),Xr(this.ctx,t);const o=en(this.ctx,t),{"~standard":n,...i}=o;return i}}const HE=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),GE=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:Mg,$ZodArray:Fg,$ZodAsyncError:vr,$ZodBase64:Ig,$ZodBase64URL:Eg,$ZodBigInt:il,$ZodBigIntFormat:jg,$ZodBoolean:ol,$ZodCIDRv4:$g,$ZodCIDRv6:Sg,$ZodCUID:dg,$ZodCUID2:pg,$ZodCatch:lv,$ZodCheck:Se,$ZodCheckBigIntFormat:Zh,$ZodCheckEndsWith:Xh,$ZodCheckGreaterThan:tl,$ZodCheckIncludes:Yh,$ZodCheckLengthEquals:Wh,$ZodCheckLessThan:el,$ZodCheckLowerCase:Gh,$ZodCheckMaxLength:Bh,$ZodCheckMaxSize:Fh,$ZodCheckMimeType:tg,$ZodCheckMinLength:Jh,$ZodCheckMinSize:qh,$ZodCheckMultipleOf:Uh,$ZodCheckNumberFormat:Lh,$ZodCheckOverwrite:rg,$ZodCheckProperty:eg,$ZodCheckRegex:Hh,$ZodCheckSizeEquals:Vh,$ZodCheckStartsWith:Qh,$ZodCheckStringFormat:ao,$ZodCheckUpperCase:Kh,$ZodCodec:sl,$ZodCustom:vv,$ZodCustomStringFormat:Pg,$ZodDate:Zg,$ZodDefault:iv,$ZodDiscriminatedUnion:Hg,$ZodE164:Tg,$ZodEmail:sg,$ZodEmoji:lg,$ZodEncodeError:Ji,$ZodEnum:Xg,$ZodError:Zu,$ZodFile:tv,$ZodFunction:mv,$ZodGUID:ig,$ZodIPv4:_g,$ZodIPv6:wg,$ZodISODate:vg,$ZodISODateTime:gg,$ZodISODuration:bg,$ZodISOTime:yg,$ZodIntersection:Gg,$ZodJWT:Ng,$ZodKSUID:hg,$ZodLazy:gv,$ZodLiteral:ev,$ZodMAC:xg,$ZodMap:Yg,$ZodNaN:cv,$ZodNanoID:cg,$ZodNever:Ug,$ZodNonOptional:sv,$ZodNull:zg,$ZodNullable:ov,$ZodNumber:nl,$ZodNumberFormat:Cg,$ZodObject:Bg,$ZodObjectJIT:Jg,$ZodOptional:nv,$ZodPipe:dv,$ZodPrefault:av,$ZodPromise:hv,$ZodReadonly:pv,$ZodRealError:nt,$ZodRecord:Kg,$ZodRegistry:Sv,$ZodSet:Qg,$ZodString:so,$ZodStringFormat:ge,$ZodSuccess:uv,$ZodSymbol:Ag,$ZodTemplateLiteral:fv,$ZodTransform:rv,$ZodTuple:al,$ZodType:X,$ZodULID:fg,$ZodURL:ug,$ZodUUID:ag,$ZodUndefined:Rg,$ZodUnion:Yi,$ZodUnknown:Dg,$ZodVoid:Lg,$ZodXID:mg,$ZodXor:Wg,$brand:jm,$constructor:S,$input:$v,$output:xv,Doc:ng,JSONSchema:HE,JSONSchemaGenerator:WE,NEVER:Du,TimePrecision:Tv,_any:Gv,_array:ry,_base64:Il,_base64url:kl,_bigint:Fv,_boolean:Lv,_catch:LE,_check:sy,_cidrv4:$l,_cidrv6:Sl,_coercedBigint:qv,_coercedBoolean:Zv,_coercedDate:ey,_coercedNumber:Av,_coercedString:kv,_cuid:gl,_cuid2:vl,_custom:oy,_date:Xv,_decode:Bu,_decodeAsync:Wu,_default:ME,_discriminatedUnion:IE,_e164:El,_email:ll,_emoji:ml,_encode:Vu,_encodeAsync:Ju,_endsWith:ia,_enum:PE,_file:ny,_float32:zv,_float64:Mv,_gt:ar,_gte:We,_guid:fi,_includes:na,_int:Rv,_int32:Dv,_int64:Vv,_intersection:kE,_ipv4:wl,_ipv6:xl,_isoDate:Nv,_isoDateTime:Ov,_isoDuration:Cv,_isoTime:Pv,_jwt:Tl,_ksuid:_l,_lazy:VE,_length:co,_literal:jE,_lowercase:ta,_lt:ir,_lte:st,_mac:Ev,_map:OE,_max:st,_maxLength:lo,_maxSize:uo,_mime:aa,_min:We,_minLength:br,_minSize:Yr,_multipleOf:Kr,_nan:ty,_nanoid:hl,_nativeEnum:CE,_negative:Nl,_never:Yv,_nonnegative:Cl,_nonoptional:DE,_nonpositive:Pl,_normalize:sa,_null:Hv,_nullable:zE,_number:jv,_optional:RE,_overwrite:Ht,_parse:eo,_parseAsync:to,_pipe:ZE,_positive:Ol,_promise:BE,_property:jl,_readonly:FE,_record:TE,_refine:iy,_regex:ea,_safeDecode:Gu,_safeDecodeAsync:Yu,_safeEncode:Hu,_safeEncodeAsync:Ku,_safeParse:ro,_safeParseAsync:no,_set:NE,_size:Xi,_slugify:da,_startsWith:oa,_string:Iv,_stringFormat:po,_stringbool:cy,_success:UE,_superRefine:ay,_symbol:Jv,_templateLiteral:qE,_toLowerCase:la,_toUpperCase:ca,_transform:AE,_trim:ua,_tuple:EE,_uint32:Uv,_uint64:Bv,_ulid:yl,_undefined:Wv,_union:$E,_unknown:Kv,_uppercase:ra,_url:Qi,_uuid:cl,_uuidv4:dl,_uuidv6:pl,_uuidv7:fl,_void:Qv,_xid:bl,_xor:SE,clone:dt,config:De,createStandardJSONSchemaMethod:Cn,createToJSONSchemaMethod:dy,decode:oI,decodeAsync:aI,describe:uy,encode:nI,encodeAsync:iI,extractDefs:Xr,finalize:en,flattenError:Fu,formatError:qu,globalConfig:li,globalRegistry:wt,initializeContext:Qr,isValidBase64:rl,isValidBase64URL:kg,isValidJWT:Og,locales:wv,meta:ly,parse:Qs,parseAsync:Xs,prettifyError:eh,process:he,regexes:Xu,registry:ul,safeDecode:uI,safeDecodeAsync:cI,safeEncode:sI,safeEncodeAsync:lI,safeParse:th,safeParseAsync:rh,toDotPath:Xm,toJSONSchema:pa,treeifyError:Qm,util:Km,version:og},Symbol.toStringTag,{value:"Module"})),KE=Object.freeze(Object.defineProperty({__proto__:null,endsWith:ia,gt:ar,gte:We,includes:na,length:co,lowercase:ta,lt:ir,lte:st,maxLength:lo,maxSize:uo,mime:aa,minLength:br,minSize:Yr,multipleOf:Kr,negative:Nl,nonnegative:Cl,nonpositive:Pl,normalize:sa,overwrite:Ht,positive:Ol,property:jl,regex:ea,size:Xi,slugify:da,startsWith:oa,toLowerCase:la,toUpperCase:ca,trim:ua,uppercase:ra},Symbol.toStringTag,{value:"Module"})),Rl=S("ZodISODateTime",(e,t)=>{gg.init(e,t),ve.init(e,t)});function Ky(e){return Ov(Rl,e)}const zl=S("ZodISODate",(e,t)=>{vg.init(e,t),ve.init(e,t)});function Yy(e){return Nv(zl,e)}const Ml=S("ZodISOTime",(e,t)=>{yg.init(e,t),ve.init(e,t)});function Qy(e){return Pv(Ml,e)}const Dl=S("ZodISODuration",(e,t)=>{bg.init(e,t),ve.init(e,t)});function Xy(e){return Cv(Dl,e)}const eb=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:zl,ZodISODateTime:Rl,ZodISODuration:Dl,ZodISOTime:Ml,date:Yy,datetime:Ky,duration:Xy,time:Qy},Symbol.toStringTag,{value:"Module"})),tb=(e,t)=>{Zu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>qu(e,r)},flatten:{value:r=>Fu(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,ci,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,ci,2)}},isEmpty:{get(){return e.issues.length===0}}})},YE=S("ZodError",tb),ot=S("ZodError",tb,{Parent:Error}),rb=eo(ot),nb=to(ot),ob=ro(ot),fa=no(ot),ib=Vu(ot),ab=Bu(ot),sb=Ju(ot),ub=Wu(ot),lb=Hu(ot),cb=Gu(ot),db=Ku(ot),pb=Yu(ot),re=S("ZodType",(e,t)=>(X.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Cn(e,"input"),output:Cn(e,"output")}}),e.toJSONSchema=dy(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(Wt(t,{checks:[...t.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]})),e.clone=(r,o)=>dt(e,r,o),e.brand=()=>e,e.register=((r,o)=>(r.add(e,o),e)),e.parse=(r,o)=>rb(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>ob(e,r,o),e.parseAsync=async(r,o)=>nb(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>fa(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>ib(e,r,o),e.decode=(r,o)=>ab(e,r,o),e.encodeAsync=async(r,o)=>sb(e,r,o),e.decodeAsync=async(r,o)=>ub(e,r,o),e.safeEncode=(r,o)=>lb(e,r,o),e.safeDecode=(r,o)=>cb(e,r,o),e.safeEncodeAsync=async(r,o)=>db(e,r,o),e.safeDecodeAsync=async(r,o)=>pb(e,r,o),e.refine=(r,o)=>e.check(wc(r,o)),e.superRefine=r=>e.check(xc(r)),e.overwrite=r=>e.check(Ht(r)),e.optional=()=>ee(e),e.nullable=()=>An(e),e.nullish=()=>ee(An(e)),e.nonoptional=r=>cc(e,r),e.array=()=>R(e),e.or=r=>G([e,r]),e.and=r=>Yl(e,r),e.transform=r=>Rn(e,za(r)),e.default=r=>sc(e,r),e.prefault=r=>lc(e,r),e.catch=r=>fc(e,r),e.pipe=r=>Rn(e,r),e.readonly=()=>gc(e),e.describe=r=>{const o=e.clone();return wt.add(o,{description:r}),o},Object.defineProperty(e,"description",{get(){return wt.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return wt.get(e);const o=e.clone();return wt.add(o,r[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),ma=S("_ZodString",(e,t)=>{so.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>py(e,o,n);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...o)=>e.check(ea(...o)),e.includes=(...o)=>e.check(na(...o)),e.startsWith=(...o)=>e.check(oa(...o)),e.endsWith=(...o)=>e.check(ia(...o)),e.min=(...o)=>e.check(br(...o)),e.max=(...o)=>e.check(lo(...o)),e.length=(...o)=>e.check(co(...o)),e.nonempty=(...o)=>e.check(br(1,...o)),e.lowercase=o=>e.check(ta(o)),e.uppercase=o=>e.check(ra(o)),e.trim=()=>e.check(ua()),e.normalize=(...o)=>e.check(sa(...o)),e.toLowerCase=()=>e.check(la()),e.toUpperCase=()=>e.check(ca()),e.slugify=()=>e.check(da())}),fo=S("ZodString",(e,t)=>{so.init(e,t),ma.init(e,t),e.email=r=>e.check(ll(ha,r)),e.url=r=>e.check(Qi(mo,r)),e.jwt=r=>e.check(Tl(Pa,r)),e.emoji=r=>e.check(ml(ga,r)),e.guid=r=>e.check(fi(jn,r)),e.uuid=r=>e.check(cl(Ct,r)),e.uuidv4=r=>e.check(dl(Ct,r)),e.uuidv6=r=>e.check(pl(Ct,r)),e.uuidv7=r=>e.check(fl(Ct,r)),e.nanoid=r=>e.check(hl(va,r)),e.guid=r=>e.check(fi(jn,r)),e.cuid=r=>e.check(gl(ya,r)),e.cuid2=r=>e.check(vl(ba,r)),e.ulid=r=>e.check(yl(_a,r)),e.base64=r=>e.check(Il(Ea,r)),e.base64url=r=>e.check(kl(Oa,r)),e.xid=r=>e.check(bl(wa,r)),e.ksuid=r=>e.check(_l(xa,r)),e.ipv4=r=>e.check(wl($a,r)),e.ipv6=r=>e.check(xl(Sa,r)),e.cidrv4=r=>e.check($l(Ia,r)),e.cidrv6=r=>e.check(Sl(ka,r)),e.e164=r=>e.check(El(Na,r)),e.datetime=r=>e.check(Ky(r)),e.date=r=>e.check(Yy(r)),e.time=r=>e.check(Qy(r)),e.duration=r=>e.check(Xy(r))});function w(e){return Iv(fo,e)}const ve=S("ZodStringFormat",(e,t)=>{ge.init(e,t),ma.init(e,t)}),ha=S("ZodEmail",(e,t)=>{sg.init(e,t),ve.init(e,t)});function fb(e){return ll(ha,e)}const jn=S("ZodGUID",(e,t)=>{ig.init(e,t),ve.init(e,t)});function mb(e){return fi(jn,e)}const Ct=S("ZodUUID",(e,t)=>{ag.init(e,t),ve.init(e,t)});function hb(e){return cl(Ct,e)}function gb(e){return dl(Ct,e)}function vb(e){return pl(Ct,e)}function yb(e){return fl(Ct,e)}const mo=S("ZodURL",(e,t)=>{ug.init(e,t),ve.init(e,t)});function bb(e){return Qi(mo,e)}function _b(e){return Qi(mo,{protocol:/^https?$/,hostname:wh,...P(e)})}const ga=S("ZodEmoji",(e,t)=>{lg.init(e,t),ve.init(e,t)});function wb(e){return ml(ga,e)}const va=S("ZodNanoID",(e,t)=>{cg.init(e,t),ve.init(e,t)});function xb(e){return hl(va,e)}const ya=S("ZodCUID",(e,t)=>{dg.init(e,t),ve.init(e,t)});function $b(e){return gl(ya,e)}const ba=S("ZodCUID2",(e,t)=>{pg.init(e,t),ve.init(e,t)});function Sb(e){return vl(ba,e)}const _a=S("ZodULID",(e,t)=>{fg.init(e,t),ve.init(e,t)});function Ib(e){return yl(_a,e)}const wa=S("ZodXID",(e,t)=>{mg.init(e,t),ve.init(e,t)});function kb(e){return bl(wa,e)}const xa=S("ZodKSUID",(e,t)=>{hg.init(e,t),ve.init(e,t)});function Eb(e){return _l(xa,e)}const $a=S("ZodIPv4",(e,t)=>{_g.init(e,t),ve.init(e,t)});function Tb(e){return wl($a,e)}const Ul=S("ZodMAC",(e,t)=>{xg.init(e,t),ve.init(e,t)});function Ob(e){return Ev(Ul,e)}const Sa=S("ZodIPv6",(e,t)=>{wg.init(e,t),ve.init(e,t)});function Nb(e){return xl(Sa,e)}const Ia=S("ZodCIDRv4",(e,t)=>{$g.init(e,t),ve.init(e,t)});function Pb(e){return $l(Ia,e)}const ka=S("ZodCIDRv6",(e,t)=>{Sg.init(e,t),ve.init(e,t)});function Cb(e){return Sl(ka,e)}const Ea=S("ZodBase64",(e,t)=>{Ig.init(e,t),ve.init(e,t)});function Ta(e){return Il(Ea,e)}const Oa=S("ZodBase64URL",(e,t)=>{Eg.init(e,t),ve.init(e,t)});function jb(e){return kl(Oa,e)}const Na=S("ZodE164",(e,t)=>{Tg.init(e,t),ve.init(e,t)});function Ab(e){return El(Na,e)}const Pa=S("ZodJWT",(e,t)=>{Ng.init(e,t),ve.init(e,t)});function Rb(e){return Tl(Pa,e)}const un=S("ZodCustomStringFormat",(e,t)=>{Pg.init(e,t),ve.init(e,t)});function zb(e,t,r={}){return po(un,e,t,r)}function Mb(e){return po(un,"hostname",_h,e)}function Db(e){return po(un,"hex",Mh,e)}function Ub(e,t){const r=t?.enc??"hex",o=`${e}_${r}`,n=Xu[o];if(!n)throw new Error(`Unrecognized hash format: ${o}`);return po(un,o,n,t)}const ho=S("ZodNumber",(e,t)=>{nl.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>fy(e,o,n),e.gt=(o,n)=>e.check(ar(o,n)),e.gte=(o,n)=>e.check(We(o,n)),e.min=(o,n)=>e.check(We(o,n)),e.lt=(o,n)=>e.check(ir(o,n)),e.lte=(o,n)=>e.check(st(o,n)),e.max=(o,n)=>e.check(st(o,n)),e.int=o=>e.check(mi(o)),e.safe=o=>e.check(mi(o)),e.positive=o=>e.check(ar(0,o)),e.nonnegative=o=>e.check(We(0,o)),e.negative=o=>e.check(ir(0,o)),e.nonpositive=o=>e.check(st(0,o)),e.multipleOf=(o,n)=>e.check(Kr(o,n)),e.step=(o,n)=>e.check(Kr(o,n)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function q(e){return jv(ho,e)}const Tr=S("ZodNumberFormat",(e,t)=>{Cg.init(e,t),ho.init(e,t)});function mi(e){return Rv(Tr,e)}function Lb(e){return zv(Tr,e)}function Zb(e){return Mv(Tr,e)}function Fb(e){return Dv(Tr,e)}function qb(e){return Uv(Tr,e)}const go=S("ZodBoolean",(e,t)=>{ol.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>my(e,r,o)});function pe(e){return Lv(go,e)}const vo=S("ZodBigInt",(e,t)=>{il.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>hy(e,o),e.gte=(o,n)=>e.check(We(o,n)),e.min=(o,n)=>e.check(We(o,n)),e.gt=(o,n)=>e.check(ar(o,n)),e.gte=(o,n)=>e.check(We(o,n)),e.min=(o,n)=>e.check(We(o,n)),e.lt=(o,n)=>e.check(ir(o,n)),e.lte=(o,n)=>e.check(st(o,n)),e.max=(o,n)=>e.check(st(o,n)),e.positive=o=>e.check(ar(BigInt(0),o)),e.negative=o=>e.check(ir(BigInt(0),o)),e.nonpositive=o=>e.check(st(BigInt(0),o)),e.nonnegative=o=>e.check(We(BigInt(0),o)),e.multipleOf=(o,n)=>e.check(Kr(o,n));const r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function Vb(e){return Fv(vo,e)}const Ca=S("ZodBigIntFormat",(e,t)=>{jg.init(e,t),vo.init(e,t)});function Bb(e){return Vv(Ca,e)}function Jb(e){return Bv(Ca,e)}const Ll=S("ZodSymbol",(e,t)=>{Ag.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>gy(e,r)});function Wb(e){return Jv(Ll,e)}const Zl=S("ZodUndefined",(e,t)=>{Rg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>yy(e,r)});function Hb(e){return Wv(Zl,e)}const Fl=S("ZodNull",(e,t)=>{zg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>vy(e,r,o)});function yo(e){return Hv(Fl,e)}const ql=S("ZodAny",(e,t)=>{Mg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>wy()});function Pe(){return Gv(ql)}const Vl=S("ZodUnknown",(e,t)=>{Dg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>xy()});function $e(){return Kv(Vl)}const Bl=S("ZodNever",(e,t)=>{Ug.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>_y(e,r,o)});function ja(e){return Yv(Bl,e)}const Jl=S("ZodVoid",(e,t)=>{Lg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>by(e,r)});function Gb(e){return Qv(Jl,e)}const Aa=S("ZodDate",(e,t)=>{Zg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>$y(e,o),e.min=(o,n)=>e.check(We(o,n)),e.max=(o,n)=>e.check(st(o,n));const r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function Kb(e){return Xv(Aa,e)}const Wl=S("ZodArray",(e,t)=>{Fg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ry(e,r,o,n),e.element=t.element,e.min=(r,o)=>e.check(br(r,o)),e.nonempty=r=>e.check(br(1,r)),e.max=(r,o)=>e.check(lo(r,o)),e.length=(r,o)=>e.check(co(r,o)),e.unwrap=()=>e.element});function R(e,t){return ry(Wl,e,t)}function Yb(e){const t=e._zod.def.shape;return dr(Object.keys(t))}const bo=S("ZodObject",(e,t)=>{Jg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>zy(e,r,o,n),ne(e,"shape",()=>t.shape),e.keyof=()=>dr(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:$e()}),e.loose=()=>e.clone({...e._zod.def,catchall:$e()}),e.strict=()=>e.clone({...e._zod.def,catchall:ja()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>qm(e,r),e.safeExtend=r=>Vm(e,r),e.merge=r=>Bm(e,r),e.pick=r=>Zm(e,r),e.omit=r=>Fm(e,r),e.partial=(...r)=>Jm(Ma,e,r[0]),e.required=(...r)=>Wm(Da,e,r[0])});function E(e,t){const r={type:"object",shape:e??{},...P(t)};return new bo(r)}function be(e,t){return new bo({type:"object",shape:e,catchall:ja(),...P(t)})}function er(e,t){return new bo({type:"object",shape:e,catchall:$e(),...P(t)})}const _o=S("ZodUnion",(e,t)=>{Yi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Al(e,r,o,n),e.options=t.options});function G(e,t){return new _o({type:"union",options:e,...P(t)})}const Hl=S("ZodXor",(e,t)=>{_o.init(e,t),Wg.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Al(e,r,o,n),e.options=t.options});function Qb(e,t){return new Hl({type:"union",options:e,inclusive:!1,...P(t)})}const Gl=S("ZodDiscriminatedUnion",(e,t)=>{_o.init(e,t),Hg.init(e,t)});function Ra(e,t,r){return new Gl({type:"union",options:t,discriminator:e,...P(r)})}const Kl=S("ZodIntersection",(e,t)=>{Gg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>My(e,r,o,n)});function Yl(e,t){return new Kl({type:"intersection",left:e,right:t})}const Ql=S("ZodTuple",(e,t)=>{al.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Dy(e,r,o,n),e.rest=r=>e.clone({...e._zod.def,rest:r})});function Xl(e,t,r){const o=t instanceof X,n=o?r:t,i=o?t:null;return new Ql({type:"tuple",items:e,rest:i,...P(n)})}const wo=S("ZodRecord",(e,t)=>{Kg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Uy(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function Xe(e,t,r){return new wo({type:"record",keyType:e,valueType:t,...P(r)})}function Xb(e,t,r){const o=dt(e);return o._zod.values=void 0,new wo({type:"record",keyType:o,valueType:t,...P(r)})}function e_(e,t,r){return new wo({type:"record",keyType:e,valueType:t,mode:"loose",...P(r)})}const ec=S("ZodMap",(e,t)=>{Yg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jy(e,r),e.keyType=t.keyType,e.valueType=t.valueType});function t_(e,t,r){return new ec({type:"map",keyType:e,valueType:t,...P(r)})}const tc=S("ZodSet",(e,t)=>{Qg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ay(e,r),e.min=(...r)=>e.check(Yr(...r)),e.nonempty=r=>e.check(Yr(1,r)),e.max=(...r)=>e.check(uo(...r)),e.size=(...r)=>e.check(Xi(...r))});function r_(e,t){return new tc({type:"set",valueType:e,...P(t)})}const tn=S("ZodEnum",(e,t)=>{Xg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Sy(e,o,n),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{const i={};for(const a of o)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new tn({...t,checks:[],...P(n),entries:i})},e.exclude=(o,n)=>{const i={...t.entries};for(const a of o)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new tn({...t,checks:[],...P(n),entries:i})}});function dr(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new tn({type:"enum",entries:r,...P(t)})}function n_(e,t){return new tn({type:"enum",entries:e,...P(t)})}const rc=S("ZodLiteral",(e,t)=>{ev.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Iy(e,r,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function C(e,t){return new rc({type:"literal",values:Array.isArray(e)?e:[e],...P(t)})}const nc=S("ZodFile",(e,t)=>{tv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ty(e,r,o),e.min=(r,o)=>e.check(Yr(r,o)),e.max=(r,o)=>e.check(uo(r,o)),e.mime=(r,o)=>e.check(aa(Array.isArray(r)?r:[r],o))});function o_(e){return ny(nc,e)}const oc=S("ZodTransform",(e,t)=>{rv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Cy(e,r),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Ji(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(Hr(i,r.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(Hr(a))}};const n=t.transform(r.value,r);return n instanceof Promise?n.then(i=>(r.value=i,r)):(r.value=n,r)}});function za(e){return new oc({type:"transform",transform:e})}const Ma=S("ZodOptional",(e,t)=>{nv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ee(e){return new Ma({type:"optional",innerType:e})}const ic=S("ZodNullable",(e,t)=>{ov.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ly(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function An(e){return new ic({type:"nullable",innerType:e})}function i_(e){return ee(An(e))}const ac=S("ZodDefault",(e,t)=>{iv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sc(e,t){return new ac({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Hi(t)}})}const uc=S("ZodPrefault",(e,t)=>{av.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function lc(e,t){return new uc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Hi(t)}})}const Da=S("ZodNonOptional",(e,t)=>{sv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Zy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function cc(e,t){return new Da({type:"nonoptional",innerType:e,...P(t)})}const dc=S("ZodSuccess",(e,t)=>{uv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Oy(e,r,o),e.unwrap=()=>e._zod.def.innerType});function a_(e){return new dc({type:"success",innerType:e})}const pc=S("ZodCatch",(e,t)=>{lv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fc(e,t){return new pc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const mc=S("ZodNaN",(e,t)=>{cv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ky(e,r)});function s_(e){return ty(mc,e)}const Ua=S("ZodPipe",(e,t)=>{dv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>By(e,r,o,n),e.in=t.in,e.out=t.out});function Rn(e,t){return new Ua({type:"pipe",in:e,out:t})}const La=S("ZodCodec",(e,t)=>{Ua.init(e,t),sl.init(e,t)});function u_(e,t,r){return new La({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}const hc=S("ZodReadonly",(e,t)=>{pv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function gc(e){return new hc({type:"readonly",innerType:e})}const vc=S("ZodTemplateLiteral",(e,t)=>{fv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ey(e,r,o)});function l_(e,t){return new vc({type:"template_literal",parts:e,...P(t)})}const yc=S("ZodLazy",(e,t)=>{gv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gy(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});function xo(e){return new yc({type:"lazy",getter:e})}const bc=S("ZodPromise",(e,t)=>{hv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function c_(e){return new bc({type:"promise",innerType:e})}const _c=S("ZodFunction",(e,t)=>{mv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Py(e,r)});function hi(e){return new _c({type:"function",input:Array.isArray(e?.input)?Xl(e?.input):e?.input??R($e()),output:e?.output??$e()})}const $o=S("ZodCustom",(e,t)=>{vv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ny(e,r)});function d_(e){const t=new Se({check:"custom"});return t._zod.check=e,t}function So(e,t){return oy($o,e??(()=>!0),t)}function wc(e,t={}){return iy($o,e,t)}function xc(e){return ay(e)}const p_=uy,f_=ly;function Rt(e,t={error:`Input not instance of ${e.name}`}){const r=new $o({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...P(t)});return r._zod.bag.Class=e,r}const m_=(...e)=>cy({Codec:La,Boolean:go,String:fo},...e);function h_(e){const t=xo(()=>G([w(e),q(),pe(),yo(),R(t),Xe(w(),t)]));return t}function g_(e,t){return Rn(za(e),t)}const QE=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:ql,ZodArray:Wl,ZodBase64:Ea,ZodBase64URL:Oa,ZodBigInt:vo,ZodBigIntFormat:Ca,ZodBoolean:go,ZodCIDRv4:Ia,ZodCIDRv6:ka,ZodCUID:ya,ZodCUID2:ba,ZodCatch:pc,ZodCodec:La,ZodCustom:$o,ZodCustomStringFormat:un,ZodDate:Aa,ZodDefault:ac,ZodDiscriminatedUnion:Gl,ZodE164:Na,ZodEmail:ha,ZodEmoji:ga,ZodEnum:tn,ZodFile:nc,ZodFunction:_c,ZodGUID:jn,ZodIPv4:$a,ZodIPv6:Sa,ZodIntersection:Kl,ZodJWT:Pa,ZodKSUID:xa,ZodLazy:yc,ZodLiteral:rc,ZodMAC:Ul,ZodMap:ec,ZodNaN:mc,ZodNanoID:va,ZodNever:Bl,ZodNonOptional:Da,ZodNull:Fl,ZodNullable:ic,ZodNumber:ho,ZodNumberFormat:Tr,ZodObject:bo,ZodOptional:Ma,ZodPipe:Ua,ZodPrefault:uc,ZodPromise:bc,ZodReadonly:hc,ZodRecord:wo,ZodSet:tc,ZodString:fo,ZodStringFormat:ve,ZodSuccess:dc,ZodSymbol:Ll,ZodTemplateLiteral:vc,ZodTransform:oc,ZodTuple:Ql,ZodType:re,ZodULID:_a,ZodURL:mo,ZodUUID:Ct,ZodUndefined:Zl,ZodUnion:_o,ZodUnknown:Vl,ZodVoid:Jl,ZodXID:wa,ZodXor:Hl,_ZodString:ma,_default:sc,_function:hi,any:Pe,array:R,base64:Ta,base64url:jb,bigint:Vb,boolean:pe,catch:fc,check:d_,cidrv4:Pb,cidrv6:Cb,codec:u_,cuid:$b,cuid2:Sb,custom:So,date:Kb,describe:p_,discriminatedUnion:Ra,e164:Ab,email:fb,emoji:wb,enum:dr,file:o_,float32:Lb,float64:Zb,function:hi,guid:mb,hash:Ub,hex:Db,hostname:Mb,httpUrl:_b,instanceof:Rt,int:mi,int32:Fb,int64:Bb,intersection:Yl,ipv4:Tb,ipv6:Nb,json:h_,jwt:Rb,keyof:Yb,ksuid:Eb,lazy:xo,literal:C,looseObject:er,looseRecord:e_,mac:Ob,map:t_,meta:f_,nan:s_,nanoid:xb,nativeEnum:n_,never:ja,nonoptional:cc,null:yo,nullable:An,nullish:i_,number:q,object:E,optional:ee,partialRecord:Xb,pipe:Rn,prefault:lc,preprocess:g_,promise:c_,readonly:gc,record:Xe,refine:wc,set:r_,strictObject:be,string:w,stringFormat:zb,stringbool:m_,success:a_,superRefine:xc,symbol:Wb,templateLiteral:l_,transform:za,tuple:Xl,uint32:qb,uint64:Jb,ulid:Ib,undefined:Hb,union:G,unknown:$e,url:bb,uuid:hb,uuidv4:gb,uuidv6:vb,uuidv7:yb,void:Gb,xid:kb,xor:Qb},Symbol.toStringTag,{value:"Module"})),v_={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function XE(e){De({customError:e})}function eT(){return De().customError}var ru;ru||(ru={});const M={...QE,...KE,iso:eb};function tT(e,t){const r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function rT(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");const r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;const o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){const n=r[1];if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function y_(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return M.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){const n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return M.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);const i=rT(n,t),a=Me(i,t);return t.refs.set(n,a),t.processing.delete(n),a}if(e.enum!==void 0){const n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return M.null();if(n.length===0)return M.never();if(n.length===1)return M.literal(n[0]);if(n.every(a=>typeof a=="string"))return M.enum(n);const i=n.map(a=>M.literal(a));return i.length<2?i[0]:M.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return M.literal(e.const);const r=e.type;if(Array.isArray(r)){const n=r.map(i=>{const a={...e,type:i};return y_(a,t)});return n.length===0?M.never():n.length===1?n[0]:M.union(n)}if(!r)return M.any();let o;switch(r){case"string":{let n=M.string();if(e.format){const i=e.format;i==="email"?n=n.check(M.email()):i==="uri"||i==="uri-reference"?n=n.check(M.url()):i==="uuid"||i==="guid"?n=n.check(M.uuid()):i==="date-time"?n=n.check(M.iso.datetime()):i==="date"?n=n.check(M.iso.date()):i==="time"?n=n.check(M.iso.time()):i==="duration"?n=n.check(M.iso.duration()):i==="ipv4"?n=n.check(M.ipv4()):i==="ipv6"?n=n.check(M.ipv6()):i==="mac"?n=n.check(M.mac()):i==="cidr"?n=n.check(M.cidrv4()):i==="cidr-v6"?n=n.check(M.cidrv6()):i==="base64"?n=n.check(M.base64()):i==="base64url"?n=n.check(M.base64url()):i==="e164"?n=n.check(M.e164()):i==="jwt"?n=n.check(M.jwt()):i==="emoji"?n=n.check(M.emoji()):i==="nanoid"?n=n.check(M.nanoid()):i==="cuid"?n=n.check(M.cuid()):i==="cuid2"?n=n.check(M.cuid2()):i==="ulid"?n=n.check(M.ulid()):i==="xid"?n=n.check(M.xid()):i==="ksuid"&&(n=n.check(M.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),o=n;break}case"number":case"integer":{let n=r==="integer"?M.number().int():M.number();typeof e.minimum=="number"&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),o=n;break}case"boolean":{o=M.boolean();break}case"null":{o=M.null();break}case"object":{const n={},i=e.properties||{},a=new Set(e.required||[]);for(const[l,u]of Object.entries(i)){const c=Me(u,t);n[l]=a.has(l)?c:c.optional()}if(e.propertyNames){const l=Me(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?Me(e.additionalProperties,t):M.any();if(Object.keys(n).length===0){o=M.record(l,u);break}const c=M.object(n).passthrough(),d=M.looseRecord(l,u);o=M.intersection(c,d);break}if(e.patternProperties){const l=e.patternProperties,u=Object.keys(l),c=[];for(const f of u){const p=Me(l[f],t),g=M.string().regex(new RegExp(f));c.push(M.looseRecord(g,p))}const d=[];if(Object.keys(n).length>0&&d.push(M.object(n).passthrough()),d.push(...c),d.length===0)o=M.object({}).passthrough();else if(d.length===1)o=d[0];else{let f=M.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=M.intersection(f,d[p]);o=f}break}const s=M.object(n);e.additionalProperties===!1?o=s.strict():typeof e.additionalProperties=="object"?o=s.catchall(Me(e.additionalProperties,t)):o=s.passthrough();break}case"array":{const n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){const a=n.map(l=>Me(l,t)),s=i&&typeof i=="object"&&!Array.isArray(i)?Me(i,t):void 0;s?o=M.tuple(a).rest(s):o=M.tuple(a),typeof e.minItems=="number"&&(o=o.check(M.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(M.maxLength(e.maxItems)))}else if(Array.isArray(i)){const a=i.map(l=>Me(l,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?Me(e.additionalItems,t):void 0;s?o=M.tuple(a).rest(s):o=M.tuple(a),typeof e.minItems=="number"&&(o=o.check(M.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(M.maxLength(e.maxItems)))}else if(i!==void 0){const a=Me(i,t);let s=M.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),o=s}else o=M.array(M.any());break}default:throw new Error(`Unsupported type: ${r}`)}return e.description&&(o=o.describe(e.description)),e.default!==void 0&&(o=o.default(e.default)),o}function Me(e,t){if(typeof e=="boolean")return e?M.any():M.never();let r=y_(e,t);const o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){const n=e.anyOf.map(a=>Me(a,t)),i=M.union(n);r=o?M.intersection(r,i):i}if(e.oneOf&&Array.isArray(e.oneOf)){const n=e.oneOf.map(a=>Me(a,t)),i=M.xor(n);r=o?M.intersection(r,i):i}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:M.any();else{let n=o?r:Me(e.allOf[0],t);const i=o?0:1;for(let a=i;a<e.allOf.length;a++)n=M.intersection(n,Me(e.allOf[a],t));r=n}return e.nullable===!0&&t.version==="openapi-3.0"&&(r=M.nullable(r)),e.readOnly===!0&&(r=M.readonly(r)),r}function nT(e,t){if(typeof e=="boolean")return e?M.any():M.never();const r=tT(e,t?.defaultTarget),o=e.$defs||e.definitions||{};return Me(e,{version:r,defs:o,refs:new Map,processing:new Set,rootSchema:e})}function oT(e){return kv(fo,e)}function iT(e){return Av(ho,e)}function aT(e){return Zv(go,e)}function sT(e){return qv(vo,e)}function uT(e){return ey(Aa,e)}const lT=Object.freeze(Object.defineProperty({__proto__:null,bigint:sT,boolean:aT,date:uT,number:iT,string:oT},Symbol.toStringTag,{value:"Module"}));De(yv());const gi=Object.freeze(Object.defineProperty({__proto__:null,$brand:jm,$input:$v,$output:xv,NEVER:Du,TimePrecision:Tv,ZodAny:ql,ZodArray:Wl,ZodBase64:Ea,ZodBase64URL:Oa,ZodBigInt:vo,ZodBigIntFormat:Ca,ZodBoolean:go,ZodCIDRv4:Ia,ZodCIDRv6:ka,ZodCUID:ya,ZodCUID2:ba,ZodCatch:pc,ZodCodec:La,ZodCustom:$o,ZodCustomStringFormat:un,ZodDate:Aa,ZodDefault:ac,ZodDiscriminatedUnion:Gl,ZodE164:Na,ZodEmail:ha,ZodEmoji:ga,ZodEnum:tn,ZodError:YE,ZodFile:nc,get ZodFirstPartyTypeKind(){return ru},ZodFunction:_c,ZodGUID:jn,ZodIPv4:$a,ZodIPv6:Sa,ZodISODate:zl,ZodISODateTime:Rl,ZodISODuration:Dl,ZodISOTime:Ml,ZodIntersection:Kl,ZodIssueCode:v_,ZodJWT:Pa,ZodKSUID:xa,ZodLazy:yc,ZodLiteral:rc,ZodMAC:Ul,ZodMap:ec,ZodNaN:mc,ZodNanoID:va,ZodNever:Bl,ZodNonOptional:Da,ZodNull:Fl,ZodNullable:ic,ZodNumber:ho,ZodNumberFormat:Tr,ZodObject:bo,ZodOptional:Ma,ZodPipe:Ua,ZodPrefault:uc,ZodPromise:bc,ZodReadonly:hc,ZodRealError:ot,ZodRecord:wo,ZodSet:tc,ZodString:fo,ZodStringFormat:ve,ZodSuccess:dc,ZodSymbol:Ll,ZodTemplateLiteral:vc,ZodTransform:oc,ZodTuple:Ql,ZodType:re,ZodULID:_a,ZodURL:mo,ZodUUID:Ct,ZodUndefined:Zl,ZodUnion:_o,ZodUnknown:Vl,ZodVoid:Jl,ZodXID:wa,ZodXor:Hl,_ZodString:ma,_default:sc,_function:hi,any:Pe,array:R,base64:Ta,base64url:jb,bigint:Vb,boolean:pe,catch:fc,check:d_,cidrv4:Pb,cidrv6:Cb,clone:dt,codec:u_,coerce:lT,config:De,core:GE,cuid:$b,cuid2:Sb,custom:So,date:Kb,decode:ab,decodeAsync:ub,describe:p_,discriminatedUnion:Ra,e164:Ab,email:fb,emoji:wb,encode:ib,encodeAsync:sb,endsWith:ia,enum:dr,file:o_,flattenError:Fu,float32:Lb,float64:Zb,formatError:qu,fromJSONSchema:nT,function:hi,getErrorMap:eT,globalRegistry:wt,gt:ar,gte:We,guid:mb,hash:Ub,hex:Db,hostname:Mb,httpUrl:_b,includes:na,instanceof:Rt,int:mi,int32:Fb,int64:Bb,intersection:Yl,ipv4:Tb,ipv6:Nb,iso:eb,json:h_,jwt:Rb,keyof:Yb,ksuid:Eb,lazy:xo,length:co,literal:C,locales:wv,looseObject:er,looseRecord:e_,lowercase:ta,lt:ir,lte:st,mac:Ob,map:t_,maxLength:lo,maxSize:uo,meta:f_,mime:aa,minLength:br,minSize:Yr,multipleOf:Kr,nan:s_,nanoid:xb,nativeEnum:n_,negative:Nl,never:ja,nonnegative:Cl,nonoptional:cc,nonpositive:Pl,normalize:sa,null:yo,nullable:An,nullish:i_,number:q,object:E,optional:ee,overwrite:Ht,parse:rb,parseAsync:nb,partialRecord:Xb,pipe:Rn,positive:Ol,prefault:lc,preprocess:g_,prettifyError:eh,promise:c_,property:jl,readonly:gc,record:Xe,refine:wc,regex:ea,regexes:Xu,registry:ul,safeDecode:cb,safeDecodeAsync:pb,safeEncode:lb,safeEncodeAsync:db,safeParse:ob,safeParseAsync:fa,set:r_,setErrorMap:XE,size:Xi,slugify:da,startsWith:oa,strictObject:be,string:w,stringFormat:zb,stringbool:m_,success:a_,superRefine:xc,symbol:Wb,templateLiteral:l_,toJSONSchema:pa,toLowerCase:la,toUpperCase:ca,transform:za,treeifyError:Qm,trim:ua,tuple:Xl,uint32:qb,uint64:Jb,ulid:Ib,undefined:Hb,union:G,unknown:$e,uppercase:ra,url:bb,util:Km,uuid:hb,uuidv4:gb,uuidv6:vb,uuidv7:yb,void:Gb,xid:kb,xor:Qb},Symbol.toStringTag,{value:"Module"}));var zn;(function(e){e.assertEqual=n=>{};function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{const i={};for(const a of n)i[a]=a;return i},e.getValidEnumValues=n=>{const i=e.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),a={};for(const s of i)a[s]=n[s];return e.objectValues(a)},e.objectValues=n=>e.objectKeys(n).map(function(i){return n[i]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const i=[];for(const a in n)Object.prototype.hasOwnProperty.call(n,a)&&i.push(a);return i},e.find=(n,i)=>{for(const a of n)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function o(n,i=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=o,e.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(zn||(zn={}));var Xd;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Xd||(Xd={}));zn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);zn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class vi extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(i){return i.message},o={_errors:[]},n=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)o._errors.push(r(a));else{let s=o,l=0;for(;l<a.path.length;){const u=a.path[l];l===a.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(a))):s[u]=s[u]||{_errors:[]},s=s[u],l++}}};return n(this),o}static assert(t){if(!(t instanceof vi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,zn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r=Object.create(null),o=[];for(const n of this.issues)if(n.path.length>0){const i=n.path[0];r[i]=r[i]||[],r[i].push(t(n))}else o.push(t(n));return{formErrors:o,fieldErrors:r}}get formErrors(){return this.flatten()}}vi.create=e=>new vi(e);var ep;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(ep||(ep={}));var A;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(A||(A={}));var cT=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const n=()=>{const i=r.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=r[Math.random()*i|0];return a.join("")};if(e==null)return n;if(r.includes(o))throw new Bi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${r}".`});return()=>`${e}${o}${n()}`};cT();function b_(e=globalThis){var t,r,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(r=e.process)==null?void 0:r.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function dT(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((r,o)=>{t[o.toLowerCase()]=r});else{Array.isArray(e)||(e=Object.entries(e));for(const[r,o]of e)o!=null&&(t[r.toLowerCase()]=o)}return t}function __(e,...t){const r=new Headers(dT(e)),o=r.get("user-agent")||"";return r.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var pT=Symbol.for("vercel.ai.validator");function fT(e){return{...e,type:"dynamic"}}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");var mT=Symbol.for("vercel.ai.schema");function hT(e,{validate:t}={}){return{[mT]:!0,_type:void 0,[pT]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}let $c;$c=globalThis.crypto;async function gT(e){return(await $c).getRandomValues(new Uint8Array(e))}async function vT(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";let r="";const o=await gT(e);for(let n=0;n<e;n++){const i=o[n]%t.length;r+=t[i]}return r}async function yT(e){return await vT(e)}async function bT(e){const t=await(await $c).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function _T(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;const t=await yT(e),r=await bT(t);return{code_verifier:t,code_challenge:r}}var wT="AI_MCPClientError",w_=`vercel.ai.error.${wT}`,xT=Symbol.for(w_),tp,rp,se=class extends(rp=Y,tp=xT,rp){constructor({name:e="MCPClientError",message:t,cause:r,data:o,code:n}){super({name:e,message:t,cause:r}),this[tp]=!0,this.data=o,this.code=n}static isInstance(e){return Y.hasMarker(e,w_)}},ln="2025-06-18",$T=[ln,"2025-03-26","2024-11-05"],ST=er({name:w(),version:w()}),Za=er({_meta:ee(E({}).loose())}),Vt=Za,x_=E({method:w(),params:ee(Za)}),$_=E({applyDefaults:ee(pe())}).loose(),IT=er({experimental:ee(E({}).loose()),logging:ee(E({}).loose()),prompts:ee(er({listChanged:ee(pe())})),resources:ee(er({subscribe:ee(pe()),listChanged:ee(pe())})),tools:ee(er({listChanged:ee(pe())})),elicitation:ee($_)});E({elicitation:ee($_)}).loose();var kT=Vt.extend({protocolVersion:w(),capabilities:IT,serverInfo:ST,instructions:ee(w())}),Sc=Vt.extend({nextCursor:ee(w())}),ET=E({name:w(),description:ee(w()),inputSchema:E({type:C("object"),properties:ee(E({}).loose())}).loose()}).loose(),TT=Sc.extend({tools:R(ET)}),S_=E({type:C("text"),text:w()}).loose(),I_=E({type:C("image"),data:Ta(),mimeType:w()}).loose(),OT=E({uri:w(),name:w(),title:ee(w()),description:ee(w()),mimeType:ee(w()),size:ee(q())}).loose(),NT=Sc.extend({resources:R(OT)}),k_=E({uri:w(),name:ee(w()),title:ee(w()),mimeType:ee(w())}).loose(),E_=k_.extend({text:w()}),T_=k_.extend({blob:Ta()}),O_=E({type:C("resource"),resource:G([E_,T_])}).loose(),PT=Vt.extend({content:R(G([S_,I_,O_])),isError:pe().default(!1).optional()}).or(Vt.extend({toolResult:$e()})),CT=E({uriTemplate:w(),name:w(),title:ee(w()),description:ee(w()),mimeType:ee(w())}).loose(),jT=Vt.extend({resourceTemplates:R(CT)}),AT=Vt.extend({contents:R(G([E_,T_]))}),RT=E({name:w(),description:ee(w()),required:ee(pe())}).loose(),zT=E({name:w(),title:ee(w()),description:ee(w()),arguments:ee(R(RT))}).loose(),MT=Sc.extend({prompts:R(zT)}),DT=E({role:G([C("user"),C("assistant")]),content:G([S_,I_,O_])}).loose(),UT=Vt.extend({description:ee(w()),messages:R(DT)}),LT=Za.extend({message:w(),requestedSchema:$e()}),np=x_.extend({method:C("elicitation/create"),params:LT}),ZT=Vt.extend({action:G([C("accept"),C("decline"),C("cancel")]),content:ee(Xe(w(),$e()))}),Fa="2.0",FT=E({jsonrpc:C(Fa),id:G([w(),q().int()])}).merge(x_).strict(),qT=E({jsonrpc:C(Fa),id:G([w(),q().int()]),result:Vt}).strict(),VT=E({jsonrpc:C(Fa),id:G([w(),q().int()]),error:E({code:q().int(),message:w(),data:ee($e())})}).strict(),BT=E({jsonrpc:C(Fa)}).merge(E({method:w(),params:ee(Za)})).strict(),In=G([FT,BT,qT,VT]),N_=typeof __PACKAGE_VERSION__<"u"?__PACKAGE_VERSION__:"0.0.0-test",P_=E({access_token:w(),id_token:w().optional(),token_type:w(),expires_in:q().optional(),scope:w().optional(),refresh_token:w().optional()}).strip(),He=w().url().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:v_.custom,message:"URL must be parseable",fatal:!0}),Du}).refine(e=>{const t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),JT=E({resource:w().url(),authorization_servers:R(He).optional(),jwks_uri:w().url().optional(),scopes_supported:R(w()).optional(),bearer_methods_supported:R(w()).optional(),resource_signing_alg_values_supported:R(w()).optional(),resource_name:w().optional(),resource_documentation:w().optional(),resource_policy_uri:w().url().optional(),resource_tos_uri:w().url().optional(),tls_client_certificate_bound_access_tokens:pe().optional(),authorization_details_types_supported:R(w()).optional(),dpop_signing_alg_values_supported:R(w()).optional(),dpop_bound_access_tokens_required:pe().optional()}).passthrough(),C_=E({issuer:w(),authorization_endpoint:He,token_endpoint:He,registration_endpoint:He.optional(),scopes_supported:R(w()).optional(),response_types_supported:R(w()),grant_types_supported:R(w()).optional(),code_challenge_methods_supported:R(w()),token_endpoint_auth_methods_supported:R(w()).optional(),token_endpoint_auth_signing_alg_values_supported:R(w()).optional()}).passthrough(),WT=E({issuer:w(),authorization_endpoint:He,token_endpoint:He,userinfo_endpoint:He.optional(),jwks_uri:He,registration_endpoint:He.optional(),scopes_supported:R(w()).optional(),response_types_supported:R(w()),grant_types_supported:R(w()).optional(),subject_types_supported:R(w()),id_token_signing_alg_values_supported:R(w()),claims_supported:R(w()).optional(),token_endpoint_auth_methods_supported:R(w()).optional()}).passthrough(),HT=WT.merge(C_.pick({code_challenge_methods_supported:!0})),GT=E({client_id:w(),client_secret:w().optional(),client_id_issued_at:q().optional(),client_secret_expires_at:q().optional()}).strip(),KT=E({redirect_uris:R(He),token_endpoint_auth_method:w().optional(),grant_types:R(w()).optional(),response_types:R(w()).optional(),client_name:w().optional(),client_uri:He.optional(),logo_uri:He.optional(),scope:w().optional(),contacts:R(w()).optional(),tos_uri:He.optional(),policy_uri:w().optional(),jwks_uri:He.optional(),jwks:Pe().optional(),software_id:w().optional(),software_version:w().optional(),software_statement:w().optional()}).strip(),YT=E({error:w(),error_description:w().optional(),error_uri:w().optional()}),QT=KT.merge(GT),XT="AI_MCPClientOAuthError",j_=`vercel.ai.error.${XT}`,eO=Symbol.for(j_),op,ip,Io=class extends(ip=Y,op=eO,ip){constructor({name:e="MCPClientOAuthError",message:t,cause:r}){super({name:e,message:t,cause:r}),this[op]=!0}static isInstance(e){return Y.hasMarker(e,j_)}},rn=class extends Io{};rn.errorCode="server_error";var yi=class extends Io{};yi.errorCode="invalid_client";var bi=class extends Io{};bi.errorCode="invalid_grant";var _i=class extends Io{};_i.errorCode="unauthorized_client";var tO={[rn.errorCode]:rn,[yi.errorCode]:yi,[bi.errorCode]:bi,[_i.errorCode]:_i};function rO(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function nO({requestedResource:e,configuredResource:t}){const r=typeof e=="string"?new URL(e):new URL(e.href),o=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==o.origin||r.pathname.length<o.pathname.length)return!1;const n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",i=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return n.startsWith(i)}var wi=class extends Error{constructor(e="Unauthorized"){super(e),this.name="UnauthorizedError"}};function xi(e){var t;const r=(t=e.headers.get("www-authenticate"))!=null?t:e.headers.get("WWW-Authenticate");if(!r)return;const[o,n]=r.split(" ");if(o.toLowerCase()!=="bearer"||!n)return;const i=/resource_metadata="([^"]*)"/,a=r.match(i);if(a)try{return new URL(a[1])}catch{return}}function oO(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function Ic(e,t,r=fetch){try{return await r(e,{headers:t})}catch(o){if(o instanceof TypeError)return t?Ic(e,void 0,r):void 0;throw o}}async function ap(e,t,r=fetch){return await Ic(e,{"MCP-Protocol-Version":t},r)}function iO(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function aO(e,t,r,o){var n,i;const a=new URL(e),s=(n=o?.protocolVersion)!=null?n:ln;let l;if(o?.metadataUrl)l=new URL(o.metadataUrl);else{const c=oO(t,a.pathname);l=new URL(c,(i=o?.metadataServerUrl)!=null?i:a),l.search=a.search}let u=await ap(l,s,r);if(!o?.metadataUrl&&iO(u,a.pathname)){const c=new URL(`/.well-known/${t}`,a);u=await ap(c,s,r)}return u}async function sO(e,t,r=fetch){const o=await aO(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!o||o.status===404)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw new Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return JT.parse(await o.json())}function uO(e){const t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",o=[];if(!r)return o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),o.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),o;let n=t.pathname;return n.endsWith("/")&&(n=n.slice(0,-1)),o.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,t.origin),type:"oauth"}),o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),o.push({url:new URL(`/.well-known/openid-configuration${n}`,t.origin),type:"oidc"}),o.push({url:new URL(`${n}/.well-known/openid-configuration`,t.origin),type:"oidc"}),o}async function lO(e,{fetchFn:t=fetch,protocolVersion:r=ln}={}){var o;const n={"MCP-Protocol-Version":r},i=uO(e);for(const{url:a,type:s}of i){const l=await Ic(a,n,t);if(l){if(!l.ok){if(l.status>=400&&l.status<500)continue;throw new Error(`HTTP ${l.status} trying to load ${s==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}if(s==="oauth")return C_.parse(await l.json());{const u=HT.parse(await l.json());if(!((o=u.code_challenge_methods_supported)!=null&&o.includes("S256")))throw new Error(`Incompatible OIDC provider at ${a}: does not support S256 code challenge method required by MCP specification`);return u}}}}async function cO(e,{metadata:t,clientInformation:r,redirectUrl:o,scope:n,state:i,resource:a}){const s="code",l="S256";let u;if(t){if(u=new URL(t.authorization_endpoint),!t.response_types_supported.includes(s))throw new Error(`Incompatible auth server: does not support response type ${s}`);if(!t.code_challenge_methods_supported||!t.code_challenge_methods_supported.includes(l))throw new Error(`Incompatible auth server: does not support code challenge method ${l}`)}else u=new URL("/authorize",e);const c=await _T(),d=c.code_verifier,f=c.code_challenge;return u.searchParams.set("response_type",s),u.searchParams.set("client_id",r.client_id),u.searchParams.set("code_challenge",f),u.searchParams.set("code_challenge_method",l),u.searchParams.set("redirect_uri",String(o)),i&&u.searchParams.set("state",i),n&&u.searchParams.set("scope",n),n?.includes("offline_access")&&u.searchParams.append("prompt","consent"),a&&u.searchParams.set("resource",a.href),{authorizationUrl:u,codeVerifier:d}}function A_(e,t){const r=e.client_secret!==void 0;return t.length===0?r?"client_secret_post":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function R_(e,t,r,o){const{client_id:n,client_secret:i}=t;switch(e){case"client_secret_basic":dO(n,i,r);return;case"client_secret_post":pO(n,i,o);return;case"none":fO(n,o);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function dO(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");const o=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${o}`)}function pO(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function fO(e,t){t.set("client_id",e)}async function kc(e){const t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{const o=YT.parse(JSON.parse(r)),{error:n,error_description:i,error_uri:a}=o,s=tO[n]||rn;return new s({message:i||"",cause:a})}catch(o){const n=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${o}. Raw body: ${r}`;return new rn({message:n})}}async function mO(e,{metadata:t,clientInformation:r,authorizationCode:o,codeVerifier:n,redirectUri:i,resource:a,addClientAuthentication:s,fetchFn:l}){var u;const c="authorization_code",d=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e);if(t?.grant_types_supported&&!t.grant_types_supported.includes(c))throw new Error(`Incompatible auth server: does not support grant type ${c}`);const f=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),p=new URLSearchParams({grant_type:c,code:o,code_verifier:n,redirect_uri:String(i)});if(s)s(f,p,e,t);else{const h=(u=t?.token_endpoint_auth_methods_supported)!=null?u:[],b=A_(r,h);R_(b,r,f,p)}a&&p.set("resource",a.href);const g=await(l??fetch)(d,{method:"POST",headers:f,body:p});if(!g.ok)throw await kc(g);return P_.parse(await g.json())}async function hO(e,{metadata:t,clientInformation:r,refreshToken:o,resource:n,addClientAuthentication:i,fetchFn:a}){var s;const l="refresh_token";let u;if(t){if(u=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(l))throw new Error(`Incompatible auth server: does not support grant type ${l}`)}else u=new URL("/token",e);const c=new Headers({"Content-Type":"application/x-www-form-urlencoded"}),d=new URLSearchParams({grant_type:l,refresh_token:o});if(i)i(c,d,e,t);else{const p=(s=t?.token_endpoint_auth_methods_supported)!=null?s:[],g=A_(r,p);R_(g,r,c,d)}n&&d.set("resource",n.href);const f=await(a??fetch)(u,{method:"POST",headers:c,body:d});if(!f.ok)throw await kc(f);return P_.parse({refresh_token:o,...await f.json()})}async function gO(e,{metadata:t,clientMetadata:r,fetchFn:o}){let n;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");n=new URL(t.registration_endpoint)}else n=new URL("/register",e);const i=await(o??fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok)throw await kc(i);return QT.parse(await i.json())}async function $i(e,t){var r,o;try{return await vs(e,t)}catch(n){if(n instanceof yi||n instanceof _i)return await((r=e.invalidateCredentials)==null?void 0:r.call(e,"all")),await vs(e,t);if(n instanceof bi)return await((o=e.invalidateCredentials)==null?void 0:o.call(e,"tokens")),await vs(e,t);throw n}}async function vO(e,t,r){const o=rO(e);if(t.validateResourceURL)return await t.validateResourceURL(o,r?.resource);if(r){if(!nO({requestedResource:o,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${o} (or origin)`);return new URL(r.resource)}}async function vs(e,{serverUrl:t,authorizationCode:r,scope:o,resourceMetadataUrl:n,fetchFn:i}){let a,s;try{a=await sO(t,{resourceMetadataUrl:n},i),a.authorization_servers&&a.authorization_servers.length>0&&(s=a.authorization_servers[0])}catch{}s||(s=t);const l=await vO(t,e,a),u=await lO(s,{fetchFn:i});let c=await Promise.resolve(e.clientInformation());if(!c){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const h=await gO(s,{metadata:u,clientMetadata:e.clientMetadata,fetchFn:i});await e.saveClientInformation(h),c=h}if(r!==void 0){const h=await e.codeVerifier(),b=await mO(s,{metadata:u,clientInformation:c,authorizationCode:r,codeVerifier:h,redirectUri:e.redirectUrl,resource:l,addClientAuthentication:e.addClientAuthentication,fetchFn:i});return await e.saveTokens(b),"AUTHORIZED"}const d=await e.tokens();if(d?.refresh_token)try{const h=await hO(s,{metadata:u,clientInformation:c,refreshToken:d.refresh_token,resource:l,addClientAuthentication:e.addClientAuthentication,fetchFn:i});return await e.saveTokens(h),"AUTHORIZED"}catch(h){if(!(!(h instanceof Io)||h instanceof rn))throw h}const f=e.state?await e.state():void 0,{authorizationUrl:p,codeVerifier:g}=await cO(s,{metadata:u,clientInformation:c,state:f,redirectUrl:e.redirectUrl,scope:o||e.clientMetadata.scope,resource:l});return await e.saveCodeVerifier(g),await e.redirectToAuthorization(p),"REDIRECT"}var yO=class{constructor({url:e,headers:t,authProvider:r}){this.connected=!1,this.url=new URL(e),this.headers=t,this.authProvider=r}async commonHeaders(e){const t={...this.headers,...e,"mcp-protocol-version":ln};if(this.authProvider){const r=await this.authProvider.tokens();r?.access_token&&(t.Authorization=`Bearer ${r.access_token}`)}return __(t,`ai-sdk/${N_}`,b_())}async start(){return new Promise((e,t)=>{if(this.connected)return e();this.abortController=new AbortController;const r=async(o=!1)=>{var n,i,a,s,l;try{const u=await this.commonHeaders({Accept:"text/event-stream"}),c=await fetch(this.url.href,{headers:u,signal:(n=this.abortController)==null?void 0:n.signal});if(c.status===401&&this.authProvider&&!o){this.resourceMetadataUrl=xi(c);try{if(await $i(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const h=new wi;return(i=this.onerror)==null||i.call(this,h),t(h)}}catch(g){return(a=this.onerror)==null||a.call(this,g),t(g)}return r(!0)}if(!c.ok||!c.body){let g=`MCP SSE Transport Error: ${c.status} ${c.statusText}`;c.status===405&&(g+=". This server does not support SSE transport. Try using `http` transport instead");const h=new se({message:g});return(s=this.onerror)==null||s.call(this,h),t(h)}const f=c.body.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).getReader(),p=async()=>{var g,h,b;try{for(;;){const{done:y,value:x}=await f.read();if(y){if(this.connected)throw this.connected=!1,new se({message:"MCP SSE Transport Error: Connection closed unexpectedly"});return}const{event:$,data:v}=x;if($==="endpoint"){if(this.endpoint=new URL(v,this.url),this.endpoint.origin!==this.url.origin)throw new se({message:`MCP SSE Transport Error: Endpoint origin does not match connection origin: ${this.endpoint.origin}`});this.connected=!0,e()}else if($==="message")try{const k=In.parse(JSON.parse(v));(g=this.onmessage)==null||g.call(this,k)}catch(k){const N=new se({message:"MCP SSE Transport Error: Failed to parse message",cause:k});(h=this.onerror)==null||h.call(this,N)}}}catch(y){if(y instanceof Error&&y.name==="AbortError")return;(b=this.onerror)==null||b.call(this,y),t(y)}};this.sseConnection={close:()=>f.cancel()},p()}catch(u){if(u instanceof Error&&u.name==="AbortError")return;(l=this.onerror)==null||l.call(this,u),t(u)}};r()})}async close(){var e,t,r;this.connected=!1,(e=this.sseConnection)==null||e.close(),(t=this.abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this)}async send(e){if(!this.endpoint||!this.connected)throw new se({message:"MCP SSE Transport Error: Not connected"});const t=this.endpoint,r=async(o=!1)=>{var n,i,a,s,l;try{const c={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json"}),body:JSON.stringify(e),signal:(n=this.abortController)==null?void 0:n.signal},d=await fetch(t,c);if(d.status===401&&this.authProvider&&!o){this.resourceMetadataUrl=xi(d);try{if(await $i(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const p=new wi;(i=this.onerror)==null||i.call(this,p);return}}catch(f){(a=this.onerror)==null||a.call(this,f);return}return r(!0)}if(!d.ok){const f=await d.text().catch(()=>null),p=new se({message:`MCP SSE Transport Error: POSTing to endpoint (HTTP ${d.status}): ${f}`});(s=this.onerror)==null||s.call(this,p);return}}catch(u){(l=this.onerror)==null||l.call(this,u);return}};await r()}},bO=class{constructor({url:e,headers:t,authProvider:r}){this.inboundReconnectAttempts=0,this.reconnectionOptions={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},this.url=new URL(e),this.headers=t,this.authProvider=r}async commonHeaders(e){const t={...this.headers,...e,"mcp-protocol-version":ln};if(this.sessionId&&(t["mcp-session-id"]=this.sessionId),this.authProvider){const r=await this.authProvider.tokens();r?.access_token&&(t.Authorization=`Bearer ${r.access_token}`)}return __(t,`ai-sdk/${N_}`,b_())}async start(){if(this.abortController)throw new se({message:"MCP HTTP Transport Error: Transport already started. Note: client.connect() calls start() automatically."});this.abortController=new AbortController,this.openInboundSse()}async close(){var e,t,r;(e=this.inboundSseConnection)==null||e.close();try{if(this.sessionId&&this.abortController&&!this.abortController.signal.aborted){const o=await this.commonHeaders({});await fetch(this.url,{method:"DELETE",headers:o,signal:this.abortController.signal}).catch(()=>{})}}catch{}(t=this.abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this)}async send(e){const t=async(r=!1)=>{var o,n,i,a,s,l,u;try{const d={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json",Accept:"application/json, text/event-stream"}),body:JSON.stringify(e),signal:(o=this.abortController)==null?void 0:o.signal},f=await fetch(this.url,d),p=f.headers.get("mcp-session-id");if(p&&(this.sessionId=p),f.status===401&&this.authProvider&&!r){this.resourceMetadataUrl=xi(f);try{if(await $i(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED")throw new wi}catch(b){throw(n=this.onerror)==null||n.call(this,b),b}return t(!0)}if(f.status===202){this.inboundSseConnection||this.openInboundSse();return}if(!f.ok){const b=await f.text().catch(()=>null);let y=`MCP HTTP Transport Error: POSTing to endpoint (HTTP ${f.status}): ${b}`;f.status===404&&(y+=". This server does not support HTTP transport. Try using `sse` transport instead");const x=new se({message:y});throw(i=this.onerror)==null||i.call(this,x),x}const g=f.headers.get("content-type")||"";if(g.includes("application/json")){const b=await f.json(),y=Array.isArray(b)?b.map(x=>In.parse(x)):[In.parse(b)];for(const x of y)(a=this.onmessage)==null||a.call(this,x);return}if(g.includes("text/event-stream")){if(!f.body){const $=new se({message:"MCP HTTP Transport Error: text/event-stream response without body"});throw(s=this.onerror)==null||s.call(this,$),$}const y=f.body.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).getReader();(async()=>{var $,v,k;try{for(;;){const{done:N,value:I}=await y.read();if(N)return;const{event:O,data:z}=I;if(O==="message")try{const F=In.parse(JSON.parse(z));($=this.onmessage)==null||$.call(this,F)}catch(F){const te=new se({message:"MCP HTTP Transport Error: Failed to parse message",cause:F});(v=this.onerror)==null||v.call(this,te)}}}catch(N){if(N instanceof Error&&N.name==="AbortError")return;(k=this.onerror)==null||k.call(this,N)}})();return}const h=new se({message:`MCP HTTP Transport Error: Unexpected content type: ${g}`});throw(l=this.onerror)==null||l.call(this,h),h}catch(c){throw(u=this.onerror)==null||u.call(this,c),c}};await t()}getNextReconnectionDelay(e){const{initialReconnectionDelay:t,reconnectionDelayGrowFactor:r,maxReconnectionDelay:o}=this.reconnectionOptions;return Math.min(t*Math.pow(r,e),o)}scheduleInboundSseReconnection(){var e;const{maxRetries:t}=this.reconnectionOptions;if(t>0&&this.inboundReconnectAttempts>=t){(e=this.onerror)==null||e.call(this,new se({message:`MCP HTTP Transport Error: Maximum reconnection attempts (${t}) exceeded.`}));return}const r=this.getNextReconnectionDelay(this.inboundReconnectAttempts);this.inboundReconnectAttempts+=1,setTimeout(async()=>{var o;(o=this.abortController)!=null&&o.signal.aborted||await this.openInboundSse(!1,this.lastInboundEventId)},r)}async openInboundSse(e=!1,t){var r,o,n,i,a,s;try{const l=await this.commonHeaders({Accept:"text/event-stream"});t&&(l["last-event-id"]=t);const u=await fetch(this.url.href,{method:"GET",headers:l,signal:(r=this.abortController)==null?void 0:r.signal}),c=u.headers.get("mcp-session-id");if(c&&(this.sessionId=c),u.status===401&&this.authProvider&&!e){this.resourceMetadataUrl=xi(u);try{if(await $i(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const h=new wi;(o=this.onerror)==null||o.call(this,h);return}}catch(g){(n=this.onerror)==null||n.call(this,g);return}return this.openInboundSse(!0,t)}if(u.status===405)return;if(!u.ok||!u.body){const g=new se({message:`MCP HTTP Transport Error: GET SSE failed: ${u.status} ${u.statusText}`});(i=this.onerror)==null||i.call(this,g);return}const f=u.body.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).getReader(),p=async()=>{var g,h,b,y;try{for(;;){const{done:x,value:$}=await f.read();if(x)return;const{event:v,data:k,id:N}=$;if(N&&(this.lastInboundEventId=N),v==="message")try{const I=In.parse(JSON.parse(k));(g=this.onmessage)==null||g.call(this,I)}catch(I){const O=new se({message:"MCP HTTP Transport Error: Failed to parse message",cause:I});(h=this.onerror)==null||h.call(this,O)}}}catch(x){if(x instanceof Error&&x.name==="AbortError")return;(b=this.onerror)==null||b.call(this,x),(y=this.abortController)!=null&&y.signal.aborted||this.scheduleInboundSseReconnection()}};this.inboundSseConnection={close:()=>f.cancel()},this.inboundReconnectAttempts=0,p()}catch(l){if(l instanceof Error&&l.name==="AbortError")return;(a=this.onerror)==null||a.call(this,l),(s=this.abortController)!=null&&s.signal.aborted||this.scheduleInboundSseReconnection()}}};function _O(e){switch(e.type){case"sse":return new yO(e);case"http":return new bO(e);default:throw new se({message:"Unsupported or invalid transport configuration. If you are using a custom transport, make sure it implements the MCPTransport interface."})}}function wO(e){return"start"in e&&typeof e.start=="function"&&"send"in e&&typeof e.send=="function"&&"close"in e&&typeof e.close=="function"}var xO="1.0.0";async function $O(e){const t=new SO(e);return await t.init(),t}var SO=class{constructor({transport:e,name:t="ai-sdk-mcp-client",version:r=xO,onUncaughtError:o,capabilities:n}){this.requestMessageId=0,this.responseHandlers=new Map,this.serverCapabilities={},this.isClosed=!0,this.onUncaughtError=o,this.clientCapabilities=n??{},wO(e)?this.transport=e:this.transport=_O(e),this.transport.onclose=()=>this.onClose(),this.transport.onerror=i=>this.onError(i),this.transport.onmessage=i=>{if("method"in i){"id"in i?this.onRequestMessage(i):this.onError(new se({message:"Unsupported message type"}));return}this.onResponse(i)},this.clientInfo={name:t,version:r}}async init(){try{await this.transport.start(),this.isClosed=!1;const e=await this.request({request:{method:"initialize",params:{protocolVersion:ln,capabilities:this.clientCapabilities,clientInfo:this.clientInfo}},resultSchema:kT});if(e===void 0)throw new se({message:"Server sent invalid initialize result"});if(!$T.includes(e.protocolVersion))throw new se({message:`Server's protocol version is not supported: ${e.protocolVersion}`});return this.serverCapabilities=e.capabilities,await this.notification({method:"notifications/initialized"}),this}catch(e){throw await this.close(),e}}async close(){var e;this.isClosed||(await((e=this.transport)==null?void 0:e.close()),this.onClose())}assertCapability(e){switch(e){case"initialize":break;case"tools/list":case"tools/call":if(!this.serverCapabilities.tools)throw new se({message:"Server does not support tools"});break;case"resources/list":case"resources/read":case"resources/templates/list":if(!this.serverCapabilities.resources)throw new se({message:"Server does not support resources"});break;case"prompts/list":case"prompts/get":if(!this.serverCapabilities.prompts)throw new se({message:"Server does not support prompts"});break;default:throw new se({message:`Unsupported method: ${e}`})}}async request({request:e,resultSchema:t,options:r}){return new Promise((o,n)=>{if(this.isClosed)return n(new se({message:"Attempted to send a request from a closed client"}));this.assertCapability(e.method);const i=r?.signal;i?.throwIfAborted();const a=this.requestMessageId++,s={...e,jsonrpc:"2.0",id:a},l=()=>{this.responseHandlers.delete(a)};this.responseHandlers.set(a,u=>{if(i?.aborted)return n(new se({message:"Request was aborted",cause:i.reason}));if(u instanceof Error)return n(u);try{const c=t.parse(u.result);o(c)}catch(c){const d=new se({message:"Failed to parse server response",cause:c});n(d)}}),this.transport.send(s).catch(u=>{l(),n(u)})})}async listTools({params:e,options:t}={}){try{return this.request({request:{method:"tools/list",params:e},resultSchema:TT,options:t})}catch(r){throw r}}async callTool({name:e,args:t,options:r}){try{return this.request({request:{method:"tools/call",params:{name:e,arguments:t}},resultSchema:PT,options:{signal:r?.abortSignal}})}catch(o){throw o}}async listResourcesInternal({params:e,options:t}={}){try{return this.request({request:{method:"resources/list",params:e},resultSchema:NT,options:t})}catch(r){throw r}}async readResourceInternal({uri:e,options:t}){try{return this.request({request:{method:"resources/read",params:{uri:e}},resultSchema:AT,options:t})}catch(r){throw r}}async listResourceTemplatesInternal({options:e}={}){try{return this.request({request:{method:"resources/templates/list"},resultSchema:jT,options:e})}catch(t){throw t}}async listPromptsInternal({params:e,options:t}={}){try{return this.request({request:{method:"prompts/list",params:e},resultSchema:MT,options:t})}catch(r){throw r}}async getPromptInternal({name:e,args:t,options:r}){try{return this.request({request:{method:"prompts/get",params:{name:e,arguments:t}},resultSchema:UT,options:r})}catch(o){throw o}}async notification(e){const t={...e,jsonrpc:"2.0"};await this.transport.send(t)}async tools({schemas:e="automatic"}={}){var t;const r={};try{const o=await this.listTools();for(const{name:n,description:i,inputSchema:a}of o.tools){if(e!=="automatic"&&!(n in e))continue;const s=this,l=async(c,d)=>{var f;return(f=d?.abortSignal)==null||f.throwIfAborted(),s.callTool({name:n,args:c,options:d})},u=e==="automatic"?fT({description:i,inputSchema:hT({...a,properties:(t=a.properties)!=null?t:{},additionalProperties:!1}),execute:l}):{description:i,inputSchema:e[n].inputSchema,execute:l};r[n]=u}return r}catch(o){throw o}}listResources({params:e,options:t}={}){return this.listResourcesInternal({params:e,options:t})}readResource({uri:e,options:t}){return this.readResourceInternal({uri:e,options:t})}listResourceTemplates({options:e}={}){return this.listResourceTemplatesInternal({options:e})}listPrompts({params:e,options:t}={}){return this.listPromptsInternal({params:e,options:t})}getPrompt({name:e,arguments:t,options:r}){return this.getPromptInternal({name:e,args:t,options:r})}onElicitationRequest(e,t){if(e!==np)throw new se({message:"Unsupported request schema. Only ElicitationRequestSchema is supported."});this.elicitationRequestHandler=t}async onRequestMessage(e){try{if(e.method!=="elicitation/create"){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Unsupported request method: ${e.method}`}});return}if(!this.elicitationRequestHandler){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"No elicitation handler registered on client"}});return}const t=np.safeParse({method:e.method,params:e.params});if(!t.success){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Invalid elicitation request: ${t.error.message}`,data:t.error.issues}});return}try{const r=await this.elicitationRequestHandler(t.data),o=ZT.parse(r);await this.transport.send({jsonrpc:"2.0",id:e.id,result:o})}catch(r){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32603,message:r instanceof Error?r.message:"Failed to handle elicitation request"}}),this.onError(r)}}catch(t){this.onError(t)}}onClose(){if(this.isClosed)return;this.isClosed=!0;const e=new se({message:"Connection closed"});for(const t of this.responseHandlers.values())t(e);this.responseHandlers.clear()}onError(e){this.onUncaughtError&&this.onUncaughtError(e)}onResponse(e){const t=Number(e.id),r=this.responseHandlers.get(t);if(r===void 0)throw new se({message:`Protocol error: Received a response for an unknown message ID: ${JSON.stringify(e)}`});this.responseHandlers.delete(t),r("result"in e?e:new se({message:e.error.message,code:e.error.code,data:e.error.data,cause:e.error}))}},ko=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},IO={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},kO=class{#e=IO;#t=!1;setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&this.#t&&e!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:e}),this.#e=e,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},hr=new kO;function EO(e){setTimeout(e,0)}var _r=typeof window>"u"||"Deno"in globalThis;function Je(){}function TO(e,t){return typeof e=="function"?e(t):e}function nu(e){return typeof e=="number"&&e>=0&&e!==1/0}function z_(e,t){return Math.max(e+(t||0)-Date.now(),0)}function rr(e,t){return typeof e=="function"?e(t):e}function at(e,t){return typeof e=="function"?e(t):e}function sp(e,t){const{type:r="all",exact:o,fetchStatus:n,predicate:i,queryKey:a,stale:s}=e;if(a){if(o){if(t.queryHash!==Ec(a,t.options))return!1}else if(!Dn(t.queryKey,a))return!1}if(r!=="all"){const l=t.isActive();if(r==="active"&&!l||r==="inactive"&&l)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||n&&n!==t.state.fetchStatus||i&&!i(t))}function up(e,t){const{exact:r,status:o,predicate:n,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if(Mn(t.options.mutationKey)!==Mn(i))return!1}else if(!Dn(t.options.mutationKey,i))return!1}return!(o&&t.state.status!==o||n&&!n(t))}function Ec(e,t){return(t?.queryKeyHashFn||Mn)(e)}function Mn(e){return JSON.stringify(e,(t,r)=>au(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function Dn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Dn(e[r],t[r])):!1}var OO=Object.prototype.hasOwnProperty;function ou(e,t){if(e===t)return e;const r=lp(e)&&lp(t);if(!r&&!(au(e)&&au(t)))return t;const n=(r?e:Object.keys(e)).length,i=r?t:Object.keys(t),a=i.length,s=r?new Array(a):{};let l=0;for(let u=0;u<a;u++){const c=r?u:i[u],d=e[c],f=t[c];if(d===f){s[c]=d,(r?u<n:OO.call(e,c))&&l++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){s[c]=f;continue}const p=ou(d,f);s[c]=p,p===d&&l++}return n===a&&l===n?e:s}function iu(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function lp(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function au(e){if(!cp(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!cp(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function cp(e){return Object.prototype.toString.call(e)==="[object Object]"}function NO(e){return new Promise(t=>{hr.setTimeout(t,e)})}function su(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return ou(e,t)}catch(o){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${o}`),o}return ou(e,t)}return t}function PO(e,t,r=0){const o=[...e,t];return r&&o.length>r?o.slice(1):o}function CO(e,t,r=0){const o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var Si=Symbol();function M_(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Si&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Si?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function jO(e,t){return typeof e=="function"?e(...t):!!e}var AO=class extends ko{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!_r&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Tc=new AO;function uu(){let e,t;const r=new Promise((n,i)=>{e=n,t=i});r.status="pending",r.catch(()=>{});function o(n){Object.assign(r,n),delete r.resolve,delete r.reject}return r.resolve=n=>{o({status:"fulfilled",value:n}),e(n)},r.reject=n=>{o({status:"rejected",reason:n}),t(n)},r}var RO=EO;function zO(){let e=[],t=0,r=s=>{s()},o=s=>{s()},n=RO;const i=s=>{t?e.push(s):n(()=>{r(s)})},a=()=>{const s=e;e=[],s.length&&n(()=>{o(()=>{s.forEach(l=>{r(l)})})})};return{batch:s=>{let l;t++;try{l=s()}finally{t--,t||a()}return l},batchCalls:s=>(...l)=>{i(()=>{s(...l)})},schedule:i,setNotifyFunction:s=>{r=s},setBatchNotifyFunction:s=>{o=s},setScheduler:s=>{n=s}}}var ze=zO(),MO=class extends ko{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!_r&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},Ii=new MO;function DO(e){return Math.min(1e3*2**e,3e4)}function D_(e){return(e??"online")==="online"?Ii.isOnline():!0}var lu=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function U_(e){let t=!1,r=0,o;const n=uu(),i=()=>n.status!=="pending",a=h=>{if(!i()){const b=new lu(h);f(b),e.onCancel?.(b)}},s=()=>{t=!0},l=()=>{t=!1},u=()=>Tc.isFocused()&&(e.networkMode==="always"||Ii.isOnline())&&e.canRun(),c=()=>D_(e.networkMode)&&e.canRun(),d=h=>{i()||(o?.(),n.resolve(h))},f=h=>{i()||(o?.(),n.reject(h))},p=()=>new Promise(h=>{o=b=>{(i()||u())&&h(b)},e.onPause?.()}).then(()=>{o=void 0,i()||e.onContinue?.()}),g=()=>{if(i())return;let h;const b=r===0?e.initialPromise:void 0;try{h=b??e.fn()}catch(y){h=Promise.reject(y)}Promise.resolve(h).then(d).catch(y=>{if(i())return;const x=e.retry??(_r?0:3),$=e.retryDelay??DO,v=typeof $=="function"?$(r,y):$,k=x===!0||typeof x=="number"&&r<x||typeof x=="function"&&x(r,y);if(t||!k){f(y);return}r++,e.onFail?.(r,y),NO(v).then(()=>u()?void 0:p()).then(()=>{t?f(y):g()})})};return{promise:n,status:()=>n.status,cancel:a,continue:()=>(o?.(),n),cancelRetry:s,continueRetry:l,canStart:c,start:()=>(c()?g():p().then(g),n)}}var L_=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),nu(this.gcTime)&&(this.#e=hr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(_r?1/0:300*1e3))}clearGcTimeout(){this.#e&&(hr.clearTimeout(this.#e),this.#e=void 0)}},UO=class extends L_{#e;#t;#r;#o;#n;#s;#a;constructor(e){super(),this.#a=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#o=e.client,this.#r=this.#o.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=pp(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){if(this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=pp(this.options);t.data!==void 0&&(this.setState(dp(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){const r=su(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(Je).catch(Je):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>at(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Si||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>rr(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!z_(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#a?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){const s=this.observers.find(l=>l.options.queryFn);s&&this.setOptions(s.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=s=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#a=!0,r.signal)})},n=()=>{const s=M_(this.options,t),u=(()=>{const c={client:this.#o,queryKey:this.queryKey,meta:this.meta};return o(c),c})();return this.#a=!1,this.options.persister?this.options.persister(s,u,this):s(u)},a=(()=>{const s={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#o,state:this.state,fetchFn:n};return o(s),s})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#i({type:"fetch",meta:a.fetchOptions?.meta}),this.#n=U_({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:s=>{s instanceof lu&&s.revert&&this.setState({...this.#t,fetchStatus:"idle"}),r.abort()},onFail:(s,l)=>{this.#i({type:"failed",failureCount:s,error:l})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const s=await this.#n.start();if(s===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(s),this.#r.config.onSuccess?.(s,this),this.#r.config.onSettled?.(s,this.state.error,this),s}catch(s){if(s instanceof lu){if(s.silent)return this.#n.promise;if(s.revert){if(this.state.data===void 0)throw s;return this.state.data}}throw this.#i({type:"error",error:s}),this.#r.config.onError?.(s,this),this.#r.config.onSettled?.(this.state.data,s,this),s}finally{this.scheduleGc()}}#i(e){const t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Z_(r.data,this.options),fetchMeta:e.meta??null};case"success":const o={...r,...dp(e.data,e.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?o:void 0,o;case"error":const n=e.error;return{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),ze.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function Z_(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:D_(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function dp(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function pp(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,o=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var LO=class extends ko{constructor(e,t){super(),this.options=t,this.#e=e,this.#i=null,this.#a=uu(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#r=void 0;#o=void 0;#n;#s;#a;#i;#h;#p;#f;#l;#c;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),fp(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return cu(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return cu(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#_(),this.#w(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,r=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof at(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#t.setOptions(this.options),t._defaulted&&!iu(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const o=this.hasListeners();o&&mp(this.#t,r,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#t!==r||at(this.options.enabled,this.#t)!==at(t.enabled,this.#t)||rr(this.options.staleTime,this.#t)!==rr(t.staleTime,this.#t))&&this.#g();const n=this.#v();o&&(this.#t!==r||at(this.options.enabled,this.#t)!==at(t.enabled,this.#t)||n!==this.#u)&&this.#y(n)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),r=this.createResult(t,e);return FO(this,r)&&(this.#o=r,this.#s=this.options,this.#n=this.#t.state),r}getCurrentResult(){return this.#o}trackResult(e,t){return new Proxy(e,{get:(r,o)=>(this.trackProp(o),t?.(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,o))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),r=this.#e.getQueryCache().build(this.#e,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#o))}#d(e){this.#x();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Je)),t}#g(){this.#_();const e=rr(this.options.staleTime,this.#t);if(_r||this.#o.isStale||!nu(e))return;const r=z_(this.#o.dataUpdatedAt,e)+1;this.#l=hr.setTimeout(()=>{this.#o.isStale||this.updateResult()},r)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(e){this.#w(),this.#u=e,!(_r||at(this.options.enabled,this.#t)===!1||!nu(this.#u)||this.#u===0)&&(this.#c=hr.setInterval(()=>{(this.options.refetchIntervalInBackground||Tc.isFocused())&&this.#d()},this.#u))}#b(){this.#g(),this.#y(this.#v())}#_(){this.#l&&(hr.clearTimeout(this.#l),this.#l=void 0)}#w(){this.#c&&(hr.clearInterval(this.#c),this.#c=void 0)}createResult(e,t){const r=this.#t,o=this.options,n=this.#o,i=this.#n,a=this.#s,l=e!==r?e.state:this.#r,{state:u}=e;let c={...u},d=!1,f;if(t._optimisticResults){const O=this.hasListeners(),z=!O&&fp(e,t),F=O&&mp(e,r,t,o);(z||F)&&(c={...c,...Z_(u.data,e.options)}),t._optimisticResults==="isRestoring"&&(c.fetchStatus="idle")}let{error:p,errorUpdatedAt:g,status:h}=c;f=c.data;let b=!1;if(t.placeholderData!==void 0&&f===void 0&&h==="pending"){let O;n?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(O=n.data,b=!0):O=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,O!==void 0&&(h="success",f=su(n?.data,O,t),d=!0)}if(t.select&&f!==void 0&&!b)if(n&&f===i?.data&&t.select===this.#h)f=this.#p;else try{this.#h=t.select,f=t.select(f),f=su(n?.data,f,t),this.#p=f,this.#i=null}catch(O){this.#i=O}this.#i&&(p=this.#i,f=this.#p,g=Date.now(),h="error");const y=c.fetchStatus==="fetching",x=h==="pending",$=h==="error",v=x&&y,k=f!==void 0,I={status:h,fetchStatus:c.fetchStatus,isPending:x,isSuccess:h==="success",isError:$,isInitialLoading:v,isLoading:v,data:f,dataUpdatedAt:c.dataUpdatedAt,error:p,errorUpdatedAt:g,failureCount:c.fetchFailureCount,failureReason:c.fetchFailureReason,errorUpdateCount:c.errorUpdateCount,isFetched:c.dataUpdateCount>0||c.errorUpdateCount>0,isFetchedAfterMount:c.dataUpdateCount>l.dataUpdateCount||c.errorUpdateCount>l.errorUpdateCount,isFetching:y,isRefetching:y&&!x,isLoadingError:$&&!k,isPaused:c.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:$&&k,isStale:Oc(e,t),refetch:this.refetch,promise:this.#a,isEnabled:at(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const O=te=>{I.status==="error"?te.reject(I.error):I.data!==void 0&&te.resolve(I.data)},z=()=>{const te=this.#a=I.promise=uu();O(te)},F=this.#a;switch(F.status){case"pending":e.queryHash===r.queryHash&&O(F);break;case"fulfilled":(I.status==="error"||I.data!==F.value)&&z();break;case"rejected":(I.status!=="error"||I.error!==F.reason)&&z();break}}return I}updateResult(){const e=this.#o,t=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#s=this.options,this.#n.data!==void 0&&(this.#f=this.#t),iu(t,e))return;this.#o=t;const r=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,n=typeof o=="function"?o():o;if(n==="all"||!n&&!this.#m.size)return!0;const i=new Set(n??this.#m);return this.options.throwOnError&&i.add("error"),Object.keys(this.#o).some(a=>{const s=a;return this.#o[s]!==e[s]&&i.has(s)})};this.#$({listeners:r()})}#x(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#r=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#$(e){ze.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#o)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function ZO(e,t){return at(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function fp(e,t){return ZO(e,t)||e.state.data!==void 0&&cu(e,t,t.refetchOnMount)}function cu(e,t,r){if(at(t.enabled,e)!==!1&&rr(t.staleTime,e)!=="static"){const o=typeof r=="function"?r(e):r;return o==="always"||o!==!1&&Oc(e,t)}return!1}function mp(e,t,r,o){return(e!==t||at(o.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Oc(e,r)}function Oc(e,t){return at(t.enabled,e)!==!1&&e.isStaleByTime(rr(t.staleTime,e))}function FO(e,t){return!iu(e.getCurrentResult(),t)}function hp(e){return{onFetch:(t,r)=>{const o=t.options,n=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let s={pages:[],pageParams:[]},l=0;const u=async()=>{let c=!1;const d=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},f=M_(t.options,t.fetchOptions),p=async(g,h,b)=>{if(c)return Promise.reject();if(h==null&&g.pages.length)return Promise.resolve(g);const x=(()=>{const N={client:t.client,queryKey:t.queryKey,pageParam:h,direction:b?"backward":"forward",meta:t.options.meta};return d(N),N})(),$=await f(x),{maxPages:v}=t.options,k=b?CO:PO;return{pages:k(g.pages,$,v),pageParams:k(g.pageParams,h,v)}};if(n&&i.length){const g=n==="backward",h=g?qO:gp,b={pages:i,pageParams:a},y=h(o,b);s=await p(b,y,g)}else{const g=e??i.length;do{const h=l===0?a[0]??o.initialPageParam:gp(o,s);if(l>0&&h==null)break;s=await p(s,h),l++}while(l<g)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=u}}}function gp(e,{pages:t,pageParams:r}){const o=t.length-1;return t.length>0?e.getNextPageParam(t[o],t,r[o],r):void 0}function qO(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var VO=class extends L_{#e;#t;#r;#o;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#r=e.mutationCache,this.#t=[],this.state=e.state||BO(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#o?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#n({type:"continue"})},r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#o=U_({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(new Error("No mutationFn found")),onFail:(i,a)=>{this.#n({type:"failed",failureCount:i,error:a})},onPause:()=>{this.#n({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#r.canRun(this)});const o=this.state.status==="pending",n=!this.#o.canStart();try{if(o)t();else{this.#n({type:"pending",variables:e,isPaused:n}),await this.#r.config.onMutate?.(e,this,r);const a=await this.options.onMutate?.(e,r);a!==this.state.context&&this.#n({type:"pending",context:a,variables:e,isPaused:n})}const i=await this.#o.start();return await this.#r.config.onSuccess?.(i,e,this.state.context,this,r),await this.options.onSuccess?.(i,e,this.state.context,r),await this.#r.config.onSettled?.(i,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(i,null,e,this.state.context,r),this.#n({type:"success",data:i}),i}catch(i){try{throw await this.#r.config.onError?.(i,e,this.state.context,this,r),await this.options.onError?.(i,e,this.state.context,r),await this.#r.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(void 0,i,e,this.state.context,r),i}finally{this.#n({type:"error",error:i})}}finally{this.#r.runNext(this)}}#n(e){const t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ze.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(e)}),this.#r.notify({mutation:this,type:"updated",action:e})})}};function BO(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var JO=class extends ko{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){const o=new VO({client:e,mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(o),o}add(e){this.#e.add(e);const t=qo(e);if(typeof t=="string"){const r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=qo(e);if(typeof t=="string"){const r=this.#t.get(t);if(r)if(r.length>1){const o=r.indexOf(e);o!==-1&&r.splice(o,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=qo(e);if(typeof t=="string"){const o=this.#t.get(t)?.find(n=>n.state.status==="pending");return!o||o===e}else return!0}runNext(e){const t=qo(e);return typeof t=="string"?this.#t.get(t)?.find(o=>o!==e&&o.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ze.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(r=>up(t,r))}findAll(e={}){return this.getAll().filter(t=>up(e,t))}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return ze.batch(()=>Promise.all(e.map(t=>t.continue().catch(Je))))}};function qo(e){return e.options.scope?.id}var WO=class extends ko{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){const o=t.queryKey,n=t.queryHash??Ec(o,t);let i=this.get(n);return i||(i=new UO({client:e,queryKey:o,queryHash:n,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(o)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ze.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(r=>sp(t,r))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(r=>sp(e,r)):t}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ze.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ze.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},HO=class{#e;#t;#r;#o;#n;#s;#a;#i;constructor(e={}){this.#e=e.queryCache||new WO,this.#t=e.mutationCache||new JO,this.#r=e.defaultOptions||{},this.#o=new Map,this.#n=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#a=Tc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=Ii.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#a?.(),this.#a=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=this.#e.build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(rr(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{const o=r.data;return[t,o]})}setQueryData(e,t,r){const o=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(o.queryHash)?.state.data,a=TO(t,i);if(a!==void 0)return this.#e.build(this,o).setData(a,{...r,manual:!0})}setQueriesData(e,t,r){return ze.batch(()=>this.#e.findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;ze.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=this.#e;return ze.batch(()=>(r.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},o=ze.batch(()=>this.#e.findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(Je).catch(Je)}invalidateQueries(e,t={}){return ze.batch(()=>(this.#e.findAll(e).forEach(r=>{r.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},o=ze.batch(()=>this.#e.findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let i=n.fetch(void 0,r);return r.throwOnError||(i=i.catch(Je)),n.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(o).then(Je)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=this.#e.build(this,t);return r.isStaleByTime(rr(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Je).catch(Je)}fetchInfiniteQuery(e){return e.behavior=hp(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Je).catch(Je)}ensureInfiniteQueryData(e){return e.behavior=hp(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return Ii.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#o.set(Mn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#o.values()],r={};return t.forEach(o=>{Dn(e,o.queryKey)&&Object.assign(r,o.defaultOptions)}),r}setMutationDefaults(e,t){this.#n.set(Mn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#n.values()],r={};return t.forEach(o=>{Dn(e,o.mutationKey)&&Object.assign(r,o.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ec(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Si&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},F_=_.createContext(void 0),q_=e=>{const t=_.useContext(F_);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},GO=({client:e,children:t})=>(_.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),m.jsx(F_.Provider,{value:e,children:t})),V_=_.createContext(!1),KO=()=>_.useContext(V_);V_.Provider;function YO(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var QO=_.createContext(YO()),XO=()=>_.useContext(QO),eN=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},tN=e=>{_.useEffect(()=>{e.clearReset()},[e])},rN=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||jO(r,[e.error,o])),nN=e=>{if(e.suspense){const r=n=>n==="static"?n:Math.max(n??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...n)=>r(o(...n)):r(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},oN=(e,t)=>e.isLoading&&e.isFetching&&!t,iN=(e,t)=>e?.suspense&&t.isPending,vp=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function aN(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const o=KO(),n=XO(),i=q_(),a=i.defaultQueryOptions(e);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a),process.env.NODE_ENV!=="production"&&(a.queryFn||console.error(`[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),a._optimisticResults=o?"isRestoring":"optimistic",nN(a),eN(a,n),tN(n);const s=!i.getQueryCache().get(a.queryHash),[l]=_.useState(()=>new t(i,a)),u=l.getOptimisticResult(a),c=!o&&e.subscribed!==!1;if(_.useSyncExternalStore(_.useCallback(d=>{const f=c?l.subscribe(ze.batchCalls(d)):Je;return l.updateResult(),f},[l,c]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),_.useEffect(()=>{l.setOptions(a)},[a,l]),iN(a,u))throw vp(a,l,n);if(rN({result:u,errorResetBoundary:n,throwOnError:a.throwOnError,query:i.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw u.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,u),a.experimental_prefetchInRender&&!_r&&oN(u,o)&&(s?vp(a,l,n):i.getQueryCache().get(a.queryHash)?.promise)?.catch(Je).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?u:l.trackResult(u)}function B_(e,t){return aN(e,LO)}function sN({auth:e,mcp:t,environment:r}){const o=Object.entries(e.headers??{}).map((i,a)=>`${i}:${a}`);return B_({queryKey:["mcpTools",t,...o],queryFn:async()=>(T.assert(!e.isLoading,"No auth found"),T.assert(t,"No MCP URL found"),await(await $O({name:"gram-elements-mcp-client",transport:{type:"http",url:t,headers:{...uN(r??{}),...e.headers}}})).tools()),enabled:!e.isLoading&&!!t,staleTime:1/0,gcTime:1/0})}const yp="MCP-";function uN(e){return typeof e!="object"||e===null?{}:Object.entries(e).reduce((t,[r,o])=>{const n=r.replace(/_/g,"-"),i=n.startsWith(yp)?n:`${yp}${n}`;return t[i]=o,t},{})}const J_=()=>{const e=D.useContext(T.ToolApprovalContext);if(!e)throw new Error("useToolApproval must be used within a ToolApprovalProvider");return e},Nc=["anthropic/claude-sonnet-4.5","anthropic/claude-haiku-4.5","anthropic/claude-sonnet-4","anthropic/claude-opus-4.5","openai/gpt-4o","openai/gpt-4o-mini","openai/gpt-5.1-codex","openai/gpt-5","openai/gpt-5.1","openai/gpt-4.1","anthropic/claude-3.7-sonnet","anthropic/claude-opus-4","google/gemini-2.5-pro-preview","google/gemini-3-pro-preview","moonshotai/kimi-k2","mistralai/mistral-medium-3","mistralai/mistral-medium-3.1","mistralai/codestral-2501"],lN=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r.description?{description:r.description}:void 0,parameters:r.parameters instanceof gi.ZodType?gi.toJSONSchema(r.parameters):r.parameters}])),cN=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>!t.disabled&&t.type!=="backend"));let ki=null;function dN(e,t){ki={helpers:e,toolsRequiringApproval:new Set(t)}}function pN(){ki=null}const fN=(e,t)=>L.makeAssistantTool({...e,execute:async(r,o)=>{if(ki?.toolsRequiringApproval.has(t)){const{helpers:n}=ki,i=o.toolCallId??"";if(!n.isToolApproved(t)&&!await n.requestApproval(t,i,r))return{content:[{type:"text",text:`Tool "${t}" execution was denied by the user. Please acknowledge this and continue without using this tool's result.`}],isError:!0}}return e.execute?.(r,o)},toolName:t});function mN(e,t,r){if(!t||t.length===0)return e;const o=new Set(t);return Object.fromEntries(Object.entries(e).map(([n,i])=>{if(!o.has(n))return[n,i];const a=i.execute;return a?[n,{...i,execute:async(s,l)=>{const u=l??{},c=u.toolCallId??"";return r.isToolApproved(n)||await r.requestApproval(n,c,s)?a(s,u):{content:[{type:"text",text:`Tool "${n}" execution was denied by the user. Please acknowledge this and continue without using this tool's result.`}],isError:!0}}}]:[n,i]}))}const hN=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],gN=T.createLucideIcon("arrow-down",hN);const vN=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],yN=T.createLucideIcon("arrow-up",vN);const bN=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],_N=T.createLucideIcon("brain",bN);const wN=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],nr=T.createLucideIcon("check",wN);const xN=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ei=T.createLucideIcon("chevron-down",xN);const $N=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],SN=T.createLucideIcon("chevron-left",$N);const IN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],W_=T.createLucideIcon("chevron-right",IN);const kN=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Pc=T.createLucideIcon("copy",kN);const EN=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],TN=T.createLucideIcon("file-text",EN);const ON=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],Ti=T.createLucideIcon("loader",ON);const NN=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],PN=T.createLucideIcon("maximize",NN);const CN=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],jN=T.createLucideIcon("message-circle",CN);const AN=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],RN=T.createLucideIcon("minimize",AN);const zN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],MN=T.createLucideIcon("panel-right-close",zN);const DN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],UN=T.createLucideIcon("panel-right-open",DN);const LN=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],ZN=T.createLucideIcon("pencil",LN);const FN=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],qN=T.createLucideIcon("plus",FN);const VN=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],BN=T.createLucideIcon("refresh-cw",VN);const JN=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],WN=T.createLucideIcon("settings-2",JN);const HN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],GN=T.createLucideIcon("square",HN);const KN=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Eo=T.createLucideIcon("x",KN);var To=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const n=()=>{const i=r.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=r[Math.random()*i|0];return a.join("")};if(e==null)return n;if(r.includes(o))throw new Bi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${r}".`});return()=>`${e}${o}${n()}`},H_=To();function bp(e=globalThis){var t,r,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(r=e.process)==null?void 0:r.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function fr(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((r,o)=>{t[o.toLowerCase()]=r});else{Array.isArray(e)||(e=Object.entries(e));for(const[r,o]of e)o!=null&&(t[r.toLowerCase()]=o)}return t}function _p(e,...t){const r=new Headers(fr(e)),o=r.get("user-agent")||"";return r.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var YN=/"__proto__"\s*:/,QN=/"constructor"\s*:/;function wp(e){const t=JSON.parse(e);return t===null||typeof t!="object"||YN.test(e)===!1&&QN.test(e)===!1?t:XN(t)}function XN(e){let t=[e];for(;t.length;){const r=t;t=[];for(const o of r){if(Object.prototype.hasOwnProperty.call(o,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const n in o){const i=o[n];i&&typeof i=="object"&&t.push(i)}}}return e}function eP(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return wp(e)}try{return wp(e)}finally{Error.stackTraceLimit=t}}var Oi=Symbol.for("vercel.ai.validator");function tP(e){return{[Oi]:!0,validate:e}}function rP(e){return typeof e=="object"&&e!==null&&Oi in e&&e[Oi]===!0&&"validate"in e}function nP(e){let t;return()=>(t==null&&(t=e()),t)}function oP(e){return rP(e)?e:typeof e=="function"?e():iP(e)}function iP(e){return tP(async t=>{const r=await e["~standard"].validate(t);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new Ft({value:t,cause:r.issues})}})}async function xp({value:e,schema:t}){const r=await Cc({value:e,schema:t});if(!r.success)throw Ft.wrap({value:e,cause:r.error});return r.value}async function Cc({value:e,schema:t}){const r=oP(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const o=await r.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:Ft.wrap({value:e,cause:o.error}),rawValue:e}}catch(o){return{success:!1,error:Ft.wrap({value:e,cause:o}),rawValue:e}}}async function Ni({text:e,schema:t}){try{const r=eP(e);return t==null?{success:!0,value:r,rawValue:r}:await Cc({value:r,schema:t})}catch(r){return{success:!1,error:Jr.isInstance(r)?r:new Jr({text:e,cause:r}),rawValue:void 0}}}function aP({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).pipeThrough(new TransformStream({async transform({data:r},o){r!=="[DONE]"&&o.enqueue(await Ni({text:r,schema:t}))}}))}async function Ar(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}function ti(e){if(e.type==="object"){e.additionalProperties=!1;const t=e.properties;if(t!=null)for(const r in t)t[r]=ti(t[r])}return e.type==="array"&&e.items!=null&&(Array.isArray(e.items)?e.items=e.items.map(t=>ti(t)):e.items=ti(e.items)),e}var sP=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")},uP=Symbol("Let zodToJsonSchema decide on which parser to use"),$p={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"},lP=e=>typeof e=="string"?{...$p,name:e}:{...$p,...e};function et(){return{}}function cP(e,t){var r,o,n;const i={type:"array"};return(r=e.type)!=null&&r._def&&((n=(o=e.type)==null?void 0:o._def)==null?void 0:n.typeName)!==A.ZodAny&&(i.items=le(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i}function dP(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function pP(){return{type:"boolean"}}function G_(e,t){return le(e.type._def,t)}var fP=(e,t)=>le(e.innerType._def,t);function K_(e,t,r){const o=r??t.dateStrategy;if(Array.isArray(o))return{anyOf:o.map((n,i)=>K_(e,t,n))};switch(o){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return mP(e)}}var mP=e=>{const t={type:"integer",format:"unix-time"};for(const r of e.checks)switch(r.kind){case"min":t.minimum=r.value;break;case"max":t.maximum=r.value;break}return t};function hP(e,t){return{...le(e.innerType._def,t),default:e.defaultValue()}}function gP(e,t){return t.effectStrategy==="input"?le(e.schema._def,t):et()}function vP(e){return{type:"string",enum:Array.from(e.values)}}var yP=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function bP(e,t){const r=[le(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),le(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(n=>!!n),o=[];return r.forEach(n=>{if(yP(n))o.push(...n.allOf);else{let i=n;if("additionalProperties"in n&&n.additionalProperties===!1){const{additionalProperties:a,...s}=n;i=s}o.push(i)}}),o.length?{allOf:o}:void 0}function _P(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var ys=void 0,ht={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:()=>(ys===void 0&&(ys=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ys),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 Y_(e,t){const r={type:"string"};if(e.checks)for(const o of e.checks)switch(o.kind){case"min":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value;break;case"max":r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"email":switch(t.emailStrategy){case"format:email":gt(r,"email",o.message,t);break;case"format:idn-email":gt(r,"idn-email",o.message,t);break;case"pattern:zod":Fe(r,ht.email,o.message,t);break}break;case"url":gt(r,"uri",o.message,t);break;case"uuid":gt(r,"uuid",o.message,t);break;case"regex":Fe(r,o.regex,o.message,t);break;case"cuid":Fe(r,ht.cuid,o.message,t);break;case"cuid2":Fe(r,ht.cuid2,o.message,t);break;case"startsWith":Fe(r,RegExp(`^${bs(o.value,t)}`),o.message,t);break;case"endsWith":Fe(r,RegExp(`${bs(o.value,t)}$`),o.message,t);break;case"datetime":gt(r,"date-time",o.message,t);break;case"date":gt(r,"date",o.message,t);break;case"time":gt(r,"time",o.message,t);break;case"duration":gt(r,"duration",o.message,t);break;case"length":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value,r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"includes":{Fe(r,RegExp(bs(o.value,t)),o.message,t);break}case"ip":{o.version!=="v6"&>(r,"ipv4",o.message,t),o.version!=="v4"&>(r,"ipv6",o.message,t);break}case"base64url":Fe(r,ht.base64url,o.message,t);break;case"jwt":Fe(r,ht.jwt,o.message,t);break;case"cidr":{o.version!=="v6"&&Fe(r,ht.ipv4Cidr,o.message,t),o.version!=="v4"&&Fe(r,ht.ipv6Cidr,o.message,t);break}case"emoji":Fe(r,ht.emoji(),o.message,t);break;case"ulid":{Fe(r,ht.ulid,o.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{gt(r,"binary",o.message,t);break}case"contentEncoding:base64":{r.contentEncoding="base64";break}case"pattern:zod":{Fe(r,ht.base64,o.message,t);break}}break}case"nanoid":Fe(r,ht.nanoid,o.message,t)}return r}function bs(e,t){return t.patternStrategy==="escape"?xP(e):e}var wP=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function xP(e){let t="";for(let r=0;r<e.length;r++)wP.has(e[r])||(t+="\\"),t+=e[r];return t}function gt(e,t,r,o){var n;e.format||(n=e.anyOf)!=null&&n.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...r&&o.errorMessages&&{errorMessage:{format:r}}})):e.format=t}function Fe(e,t,r,o){var n;e.pattern||(n=e.allOf)!=null&&n.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Sp(t,o),...r&&o.errorMessages&&{errorMessage:{pattern:r}}})):e.pattern=Sp(t,o)}function Sp(e,t){var r;if(!t.applyRegexFlags||!e.flags)return e.source;const o={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=o.i?e.source.toLowerCase():e.source;let i="",a=!1,s=!1,l=!1;for(let u=0;u<n.length;u++){if(a){i+=n[u],a=!1;continue}if(o.i){if(s){if(n[u].match(/[a-z]/)){l?(i+=n[u],i+=`${n[u-2]}-${n[u]}`.toUpperCase(),l=!1):n[u+1]==="-"&&((r=n[u+2])!=null&&r.match(/[a-z]/))?(i+=n[u],l=!0):i+=`${n[u]}${n[u].toUpperCase()}`;continue}}else if(n[u].match(/[a-z]/)){i+=`[${n[u]}${n[u].toUpperCase()}]`;continue}}if(o.m){if(n[u]==="^"){i+=`(^|(?<=[\r
|
|
29
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const i of e.seen.entries()){const a=i[1];if(t===i[0]){n(i);continue}if(e.external){const l=e.external.registry.get(i[0])?.id;if(t!==i[0]&&l){n(i);continue}}if(e.metadataRegistry.get(i[0])?.id){n(i);continue}if(a.cycle){n(i);continue}if(a.count>1&&e.reused==="ref"){n(i);continue}}}function en(e,t){const r=e.seen.get(t);if(!r)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=a=>{const s=e.seen.get(a),l=s.def??s.schema,u={...l};if(s.ref===null)return;const c=s.ref;if(s.ref=null,c){o(c);const d=e.seen.get(c).schema;d.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(d)):(Object.assign(l,d),Object.assign(l,u))}s.isParent||e.override({zodSchema:a,jsonSchema:l,path:s.path??[]})};for(const a of[...e.seen.entries()].reverse())o(a[0]);const n={};if(e.target==="draft-2020-12"?n.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?n.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?n.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");n.$id=e.external.uri(a)}Object.assign(n,r.def??r.schema);const i=e.external?.defs??{};for(const a of e.seen.entries()){const s=a[1];s.def&&s.defId&&(i[s.defId]=s.def)}e.external||Object.keys(i).length>0&&(e.target==="draft-2020-12"?n.$defs=i:n.definitions=i);try{const a=JSON.parse(JSON.stringify(n));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Cn(t,"input"),output:Cn(t,"output")}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Ve(e,t){const r=t??{seen:new Set};if(r.seen.has(e))return!1;r.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return Ve(o.element,r);if(o.type==="set")return Ve(o.valueType,r);if(o.type==="lazy")return Ve(o.getter(),r);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return Ve(o.innerType,r);if(o.type==="intersection")return Ve(o.left,r)||Ve(o.right,r);if(o.type==="record"||o.type==="map")return Ve(o.keyType,r)||Ve(o.valueType,r);if(o.type==="pipe")return Ve(o.in,r)||Ve(o.out,r);if(o.type==="object"){for(const n in o.shape)if(Ve(o.shape[n],r))return!0;return!1}if(o.type==="union"){for(const n of o.options)if(Ve(n,r))return!0;return!1}if(o.type==="tuple"){for(const n of o.items)if(Ve(n,r))return!0;return!!(o.rest&&Ve(o.rest,r))}return!1}const dy=(e,t={})=>r=>{const o=Qr({...r,processors:t});return he(e,o),Xr(o,e),en(o,e)},Cn=(e,t)=>r=>{const{libraryOptions:o,target:n}=r??{},i=Qr({...o??{},target:n,io:t,processors:{}});return he(e,i),Xr(i,e),en(i,e)},JE={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},py=(e,t,r,o)=>{const n=r;n.type="string";const{minimum:i,maximum:a,format:s,patterns:l,contentEncoding:u}=e._zod.bag;if(typeof i=="number"&&(n.minLength=i),typeof a=="number"&&(n.maxLength=a),s&&(n.format=JE[s]??s,n.format===""&&delete n.format),u&&(n.contentEncoding=u),l&&l.size>0){const c=[...l];c.length===1?n.pattern=c[0].source:c.length>1&&(n.allOf=[...c.map(d=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:d.source}))])}},fy=(e,t,r,o)=>{const n=r,{minimum:i,maximum:a,format:s,multipleOf:l,exclusiveMaximum:u,exclusiveMinimum:c}=e._zod.bag;typeof s=="string"&&s.includes("int")?n.type="integer":n.type="number",typeof c=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(n.minimum=c,n.exclusiveMinimum=!0):n.exclusiveMinimum=c),typeof i=="number"&&(n.minimum=i,typeof c=="number"&&t.target!=="draft-04"&&(c>=i?delete n.minimum:delete n.exclusiveMinimum)),typeof u=="number"&&(t.target==="draft-04"||t.target==="openapi-3.0"?(n.maximum=u,n.exclusiveMaximum=!0):n.exclusiveMaximum=u),typeof a=="number"&&(n.maximum=a,typeof u=="number"&&t.target!=="draft-04"&&(u<=a?delete n.maximum:delete n.exclusiveMaximum)),typeof l=="number"&&(n.multipleOf=l)},my=(e,t,r,o)=>{r.type="boolean"},hy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("BigInt cannot be represented in JSON Schema")},gy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Symbols cannot be represented in JSON Schema")},vy=(e,t,r,o)=>{t.target==="openapi-3.0"?(r.type="string",r.nullable=!0,r.enum=[null]):r.type="null"},yy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Undefined cannot be represented in JSON Schema")},by=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Void cannot be represented in JSON Schema")},_y=(e,t,r,o)=>{r.not={}},wy=(e,t,r,o)=>{},xy=(e,t,r,o)=>{},$y=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Date cannot be represented in JSON Schema")},Sy=(e,t,r,o)=>{const n=e._zod.def,i=Uu(n.entries);i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),r.enum=i},Iy=(e,t,r,o)=>{const n=e._zod.def,i=[];for(const a of n.values)if(a===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof a=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(a))}else i.push(a);if(i.length!==0)if(i.length===1){const a=i[0];r.type=a===null?"null":typeof a,t.target==="draft-04"||t.target==="openapi-3.0"?r.enum=[a]:r.const=a}else i.every(a=>typeof a=="number")&&(r.type="number"),i.every(a=>typeof a=="string")&&(r.type="string"),i.every(a=>typeof a=="boolean")&&(r.type="boolean"),i.every(a=>a===null)&&(r.type="null"),r.enum=i},ky=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("NaN cannot be represented in JSON Schema")},Ey=(e,t,r,o)=>{const n=r,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");n.type="string",n.pattern=i.source},Ty=(e,t,r,o)=>{const n=r,i={type:"string",format:"binary",contentEncoding:"binary"},{minimum:a,maximum:s,mime:l}=e._zod.bag;a!==void 0&&(i.minLength=a),s!==void 0&&(i.maxLength=s),l?l.length===1?(i.contentMediaType=l[0],Object.assign(n,i)):n.anyOf=l.map(u=>({...i,contentMediaType:u})):Object.assign(n,i)},Oy=(e,t,r,o)=>{r.type="boolean"},Ny=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Py=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Function types cannot be represented in JSON Schema")},Cy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},jy=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Map cannot be represented in JSON Schema")},Ay=(e,t,r,o)=>{if(t.unrepresentable==="throw")throw new Error("Set cannot be represented in JSON Schema")},Ry=(e,t,r,o)=>{const n=r,i=e._zod.def,{minimum:a,maximum:s}=e._zod.bag;typeof a=="number"&&(n.minItems=a),typeof s=="number"&&(n.maxItems=s),n.type="array",n.items=he(i.element,t,{...o,path:[...o.path,"items"]})},zy=(e,t,r,o)=>{const n=r,i=e._zod.def;n.type="object",n.properties={};const a=i.shape;for(const u in a)n.properties[u]=he(a[u],t,{...o,path:[...o.path,"properties",u]});const s=new Set(Object.keys(a)),l=new Set([...s].filter(u=>{const c=i.shape[u]._zod;return t.io==="input"?c.optin===void 0:c.optout===void 0}));l.size>0&&(n.required=Array.from(l)),i.catchall?._zod.def.type==="never"?n.additionalProperties=!1:i.catchall?i.catchall&&(n.additionalProperties=he(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(n.additionalProperties=!1)},Al=(e,t,r,o)=>{const n=e._zod.def,i=n.inclusive===!1,a=n.options.map((s,l)=>he(s,t,{...o,path:[...o.path,i?"oneOf":"anyOf",l]}));i?r.oneOf=a:r.anyOf=a},My=(e,t,r,o)=>{const n=e._zod.def,i=he(n.left,t,{...o,path:[...o.path,"allOf",0]}),a=he(n.right,t,{...o,path:[...o.path,"allOf",1]}),s=u=>"allOf"in u&&Object.keys(u).length===1,l=[...s(i)?i.allOf:[i],...s(a)?a.allOf:[a]];r.allOf=l},Dy=(e,t,r,o)=>{const n=r,i=e._zod.def;n.type="array";const a=t.target==="draft-2020-12"?"prefixItems":"items",s=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",l=i.items.map((f,p)=>he(f,t,{...o,path:[...o.path,a,p]})),u=i.rest?he(i.rest,t,{...o,path:[...o.path,s,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;t.target==="draft-2020-12"?(n.prefixItems=l,u&&(n.items=u)):t.target==="openapi-3.0"?(n.items={anyOf:l},u&&n.items.anyOf.push(u),n.minItems=l.length,u||(n.maxItems=l.length)):(n.items=l,u&&(n.additionalItems=u));const{minimum:c,maximum:d}=e._zod.bag;typeof c=="number"&&(n.minItems=c),typeof d=="number"&&(n.maxItems=d)},Uy=(e,t,r,o)=>{const n=r,i=e._zod.def;n.type="object",(t.target==="draft-07"||t.target==="draft-2020-12")&&(n.propertyNames=he(i.keyType,t,{...o,path:[...o.path,"propertyNames"]})),n.additionalProperties=he(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]})},Ly=(e,t,r,o)=>{const n=e._zod.def,i=he(n.innerType,t,o),a=t.seen.get(e);t.target==="openapi-3.0"?(a.ref=n.innerType,r.nullable=!0):r.anyOf=[i,{type:"null"}]},Zy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType},Fy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType,r.default=JSON.parse(JSON.stringify(n.defaultValue))},qy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType,t.io==="input"&&(r._prefault=JSON.parse(JSON.stringify(n.defaultValue)))},Vy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType;let a;try{a=n.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}r.default=a},By=(e,t,r,o)=>{const n=e._zod.def,i=t.io==="input"?n.in._zod.def.type==="transform"?n.out:n.in:n.out;he(i,t,o);const a=t.seen.get(e);a.ref=i},Jy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType,r.readOnly=!0},Wy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType},Hy=(e,t,r,o)=>{const n=e._zod.def;he(n.innerType,t,o);const i=t.seen.get(e);i.ref=n.innerType},Gy=(e,t,r,o)=>{const n=e._zod.innerType;he(n,t,o);const i=t.seen.get(e);i.ref=n},tu={string:py,number:fy,boolean:my,bigint:hy,symbol:gy,null:vy,undefined:yy,void:by,never:_y,any:wy,unknown:xy,date:$y,enum:Sy,literal:Iy,nan:ky,template_literal:Ey,file:Ty,success:Oy,custom:Ny,function:Py,transform:Cy,map:jy,set:Ay,array:Ry,object:zy,union:Al,intersection:My,tuple:Dy,record:Uy,nullable:Ly,nonoptional:Zy,default:Fy,prefault:qy,catch:Vy,pipe:By,readonly:Jy,promise:Wy,optional:Hy,lazy:Gy};function fa(e,t){if("_idmap"in e){const o=e,n=Qr({...t,processors:tu}),i={};for(const l of o._idmap.entries()){const[u,c]=l;he(c,n)}const a={},s={registry:o,uri:t?.uri,defs:i};n.external=s;for(const l of o._idmap.entries()){const[u,c]=l;Xr(n,c),a[u]=en(n,c)}if(Object.keys(i).length>0){const l=n.target==="draft-2020-12"?"$defs":"definitions";a.__shared={[l]:i}}return{schemas:a}}const r=Qr({...t,processors:tu});return he(e,r),Xr(r,e),en(r,e)}class WE{get metadataRegistry(){return this.ctx.metadataRegistry}get target(){return this.ctx.target}get unrepresentable(){return this.ctx.unrepresentable}get override(){return this.ctx.override}get io(){return this.ctx.io}get counter(){return this.ctx.counter}set counter(t){this.ctx.counter=t}get seen(){return this.ctx.seen}constructor(t){let r=t?.target??"draft-2020-12";r==="draft-4"&&(r="draft-04"),r==="draft-7"&&(r="draft-07"),this.ctx=Qr({processors:tu,target:r,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,r={path:[],schemaPath:[]}){return he(t,this.ctx,r)}emit(t,r){r&&(r.cycles&&(this.ctx.cycles=r.cycles),r.reused&&(this.ctx.reused=r.reused),r.external&&(this.ctx.external=r.external)),Xr(this.ctx,t);const o=en(this.ctx,t),{"~standard":n,...i}=o;return i}}const HE=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),GE=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:Mg,$ZodArray:Fg,$ZodAsyncError:vr,$ZodBase64:Ig,$ZodBase64URL:Eg,$ZodBigInt:il,$ZodBigIntFormat:jg,$ZodBoolean:ol,$ZodCIDRv4:$g,$ZodCIDRv6:Sg,$ZodCUID:dg,$ZodCUID2:pg,$ZodCatch:lv,$ZodCheck:Se,$ZodCheckBigIntFormat:Zh,$ZodCheckEndsWith:Xh,$ZodCheckGreaterThan:tl,$ZodCheckIncludes:Yh,$ZodCheckLengthEquals:Wh,$ZodCheckLessThan:el,$ZodCheckLowerCase:Gh,$ZodCheckMaxLength:Bh,$ZodCheckMaxSize:Fh,$ZodCheckMimeType:tg,$ZodCheckMinLength:Jh,$ZodCheckMinSize:qh,$ZodCheckMultipleOf:Uh,$ZodCheckNumberFormat:Lh,$ZodCheckOverwrite:rg,$ZodCheckProperty:eg,$ZodCheckRegex:Hh,$ZodCheckSizeEquals:Vh,$ZodCheckStartsWith:Qh,$ZodCheckStringFormat:ao,$ZodCheckUpperCase:Kh,$ZodCodec:sl,$ZodCustom:vv,$ZodCustomStringFormat:Pg,$ZodDate:Zg,$ZodDefault:iv,$ZodDiscriminatedUnion:Hg,$ZodE164:Tg,$ZodEmail:sg,$ZodEmoji:lg,$ZodEncodeError:Wi,$ZodEnum:Xg,$ZodError:Zu,$ZodFile:tv,$ZodFunction:mv,$ZodGUID:ig,$ZodIPv4:_g,$ZodIPv6:wg,$ZodISODate:vg,$ZodISODateTime:gg,$ZodISODuration:bg,$ZodISOTime:yg,$ZodIntersection:Gg,$ZodJWT:Ng,$ZodKSUID:hg,$ZodLazy:gv,$ZodLiteral:ev,$ZodMAC:xg,$ZodMap:Yg,$ZodNaN:cv,$ZodNanoID:cg,$ZodNever:Ug,$ZodNonOptional:sv,$ZodNull:zg,$ZodNullable:ov,$ZodNumber:nl,$ZodNumberFormat:Cg,$ZodObject:Bg,$ZodObjectJIT:Jg,$ZodOptional:nv,$ZodPipe:dv,$ZodPrefault:av,$ZodPromise:hv,$ZodReadonly:pv,$ZodRealError:nt,$ZodRecord:Kg,$ZodRegistry:Sv,$ZodSet:Qg,$ZodString:so,$ZodStringFormat:ge,$ZodSuccess:uv,$ZodSymbol:Ag,$ZodTemplateLiteral:fv,$ZodTransform:rv,$ZodTuple:al,$ZodType:X,$ZodULID:fg,$ZodURL:ug,$ZodUUID:ag,$ZodUndefined:Rg,$ZodUnion:Qi,$ZodUnknown:Dg,$ZodVoid:Lg,$ZodXID:mg,$ZodXor:Wg,$brand:jm,$constructor:S,$input:$v,$output:xv,Doc:ng,JSONSchema:HE,JSONSchemaGenerator:WE,NEVER:Du,TimePrecision:Tv,_any:Gv,_array:ry,_base64:Il,_base64url:kl,_bigint:Fv,_boolean:Lv,_catch:LE,_check:sy,_cidrv4:$l,_cidrv6:Sl,_coercedBigint:qv,_coercedBoolean:Zv,_coercedDate:ey,_coercedNumber:Av,_coercedString:kv,_cuid:gl,_cuid2:vl,_custom:oy,_date:Xv,_decode:Bu,_decodeAsync:Wu,_default:ME,_discriminatedUnion:IE,_e164:El,_email:ll,_emoji:ml,_encode:Vu,_encodeAsync:Ju,_endsWith:aa,_enum:PE,_file:ny,_float32:zv,_float64:Mv,_gt:ar,_gte:We,_guid:mi,_includes:oa,_int:Rv,_int32:Dv,_int64:Vv,_intersection:kE,_ipv4:wl,_ipv6:xl,_isoDate:Nv,_isoDateTime:Ov,_isoDuration:Cv,_isoTime:Pv,_jwt:Tl,_ksuid:_l,_lazy:VE,_length:co,_literal:jE,_lowercase:ra,_lt:ir,_lte:st,_mac:Ev,_map:OE,_max:st,_maxLength:lo,_maxSize:uo,_mime:sa,_min:We,_minLength:br,_minSize:Yr,_multipleOf:Kr,_nan:ty,_nanoid:hl,_nativeEnum:CE,_negative:Nl,_never:Yv,_nonnegative:Cl,_nonoptional:DE,_nonpositive:Pl,_normalize:ua,_null:Hv,_nullable:zE,_number:jv,_optional:RE,_overwrite:Ht,_parse:eo,_parseAsync:to,_pipe:ZE,_positive:Ol,_promise:BE,_property:jl,_readonly:FE,_record:TE,_refine:iy,_regex:ta,_safeDecode:Gu,_safeDecodeAsync:Yu,_safeEncode:Hu,_safeEncodeAsync:Ku,_safeParse:ro,_safeParseAsync:no,_set:NE,_size:ea,_slugify:pa,_startsWith:ia,_string:Iv,_stringFormat:po,_stringbool:cy,_success:UE,_superRefine:ay,_symbol:Jv,_templateLiteral:qE,_toLowerCase:ca,_toUpperCase:da,_transform:AE,_trim:la,_tuple:EE,_uint32:Uv,_uint64:Bv,_ulid:yl,_undefined:Wv,_union:$E,_unknown:Kv,_uppercase:na,_url:Xi,_uuid:cl,_uuidv4:dl,_uuidv6:pl,_uuidv7:fl,_void:Qv,_xid:bl,_xor:SE,clone:dt,config:De,createStandardJSONSchemaMethod:Cn,createToJSONSchemaMethod:dy,decode:oI,decodeAsync:aI,describe:uy,encode:nI,encodeAsync:iI,extractDefs:Xr,finalize:en,flattenError:Fu,formatError:qu,globalConfig:ci,globalRegistry:wt,initializeContext:Qr,isValidBase64:rl,isValidBase64URL:kg,isValidJWT:Og,locales:wv,meta:ly,parse:Qs,parseAsync:Xs,prettifyError:eh,process:he,regexes:Xu,registry:ul,safeDecode:uI,safeDecodeAsync:cI,safeEncode:sI,safeEncodeAsync:lI,safeParse:th,safeParseAsync:rh,toDotPath:Xm,toJSONSchema:fa,treeifyError:Qm,util:Km,version:og},Symbol.toStringTag,{value:"Module"})),KE=Object.freeze(Object.defineProperty({__proto__:null,endsWith:aa,gt:ar,gte:We,includes:oa,length:co,lowercase:ra,lt:ir,lte:st,maxLength:lo,maxSize:uo,mime:sa,minLength:br,minSize:Yr,multipleOf:Kr,negative:Nl,nonnegative:Cl,nonpositive:Pl,normalize:ua,overwrite:Ht,positive:Ol,property:jl,regex:ta,size:ea,slugify:pa,startsWith:ia,toLowerCase:ca,toUpperCase:da,trim:la,uppercase:na},Symbol.toStringTag,{value:"Module"})),Rl=S("ZodISODateTime",(e,t)=>{gg.init(e,t),ve.init(e,t)});function Ky(e){return Ov(Rl,e)}const zl=S("ZodISODate",(e,t)=>{vg.init(e,t),ve.init(e,t)});function Yy(e){return Nv(zl,e)}const Ml=S("ZodISOTime",(e,t)=>{yg.init(e,t),ve.init(e,t)});function Qy(e){return Pv(Ml,e)}const Dl=S("ZodISODuration",(e,t)=>{bg.init(e,t),ve.init(e,t)});function Xy(e){return Cv(Dl,e)}const eb=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:zl,ZodISODateTime:Rl,ZodISODuration:Dl,ZodISOTime:Ml,date:Yy,datetime:Ky,duration:Xy,time:Qy},Symbol.toStringTag,{value:"Module"})),tb=(e,t)=>{Zu.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:r=>qu(e,r)},flatten:{value:r=>Fu(e,r)},addIssue:{value:r=>{e.issues.push(r),e.message=JSON.stringify(e.issues,di,2)}},addIssues:{value:r=>{e.issues.push(...r),e.message=JSON.stringify(e.issues,di,2)}},isEmpty:{get(){return e.issues.length===0}}})},YE=S("ZodError",tb),ot=S("ZodError",tb,{Parent:Error}),rb=eo(ot),nb=to(ot),ob=ro(ot),ma=no(ot),ib=Vu(ot),ab=Bu(ot),sb=Ju(ot),ub=Wu(ot),lb=Hu(ot),cb=Gu(ot),db=Ku(ot),pb=Yu(ot),re=S("ZodType",(e,t)=>(X.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Cn(e,"input"),output:Cn(e,"output")}}),e.toJSONSchema=dy(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.check=(...r)=>e.clone(Wt(t,{checks:[...t.checks??[],...r.map(o=>typeof o=="function"?{_zod:{check:o,def:{check:"custom"},onattach:[]}}:o)]})),e.clone=(r,o)=>dt(e,r,o),e.brand=()=>e,e.register=((r,o)=>(r.add(e,o),e)),e.parse=(r,o)=>rb(e,r,o,{callee:e.parse}),e.safeParse=(r,o)=>ob(e,r,o),e.parseAsync=async(r,o)=>nb(e,r,o,{callee:e.parseAsync}),e.safeParseAsync=async(r,o)=>ma(e,r,o),e.spa=e.safeParseAsync,e.encode=(r,o)=>ib(e,r,o),e.decode=(r,o)=>ab(e,r,o),e.encodeAsync=async(r,o)=>sb(e,r,o),e.decodeAsync=async(r,o)=>ub(e,r,o),e.safeEncode=(r,o)=>lb(e,r,o),e.safeDecode=(r,o)=>cb(e,r,o),e.safeEncodeAsync=async(r,o)=>db(e,r,o),e.safeDecodeAsync=async(r,o)=>pb(e,r,o),e.refine=(r,o)=>e.check(wc(r,o)),e.superRefine=r=>e.check(xc(r)),e.overwrite=r=>e.check(Ht(r)),e.optional=()=>ee(e),e.nullable=()=>An(e),e.nullish=()=>ee(An(e)),e.nonoptional=r=>cc(e,r),e.array=()=>R(e),e.or=r=>G([e,r]),e.and=r=>Yl(e,r),e.transform=r=>Rn(e,Ma(r)),e.default=r=>sc(e,r),e.prefault=r=>lc(e,r),e.catch=r=>fc(e,r),e.pipe=r=>Rn(e,r),e.readonly=()=>gc(e),e.describe=r=>{const o=e.clone();return wt.add(o,{description:r}),o},Object.defineProperty(e,"description",{get(){return wt.get(e)?.description},configurable:!0}),e.meta=(...r)=>{if(r.length===0)return wt.get(e);const o=e.clone();return wt.add(o,r[0]),o},e.isOptional=()=>e.safeParse(void 0).success,e.isNullable=()=>e.safeParse(null).success,e)),ha=S("_ZodString",(e,t)=>{so.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>py(e,o,n);const r=e._zod.bag;e.format=r.format??null,e.minLength=r.minimum??null,e.maxLength=r.maximum??null,e.regex=(...o)=>e.check(ta(...o)),e.includes=(...o)=>e.check(oa(...o)),e.startsWith=(...o)=>e.check(ia(...o)),e.endsWith=(...o)=>e.check(aa(...o)),e.min=(...o)=>e.check(br(...o)),e.max=(...o)=>e.check(lo(...o)),e.length=(...o)=>e.check(co(...o)),e.nonempty=(...o)=>e.check(br(1,...o)),e.lowercase=o=>e.check(ra(o)),e.uppercase=o=>e.check(na(o)),e.trim=()=>e.check(la()),e.normalize=(...o)=>e.check(ua(...o)),e.toLowerCase=()=>e.check(ca()),e.toUpperCase=()=>e.check(da()),e.slugify=()=>e.check(pa())}),fo=S("ZodString",(e,t)=>{so.init(e,t),ha.init(e,t),e.email=r=>e.check(ll(ga,r)),e.url=r=>e.check(Xi(mo,r)),e.jwt=r=>e.check(Tl(Ca,r)),e.emoji=r=>e.check(ml(va,r)),e.guid=r=>e.check(mi(jn,r)),e.uuid=r=>e.check(cl(Ct,r)),e.uuidv4=r=>e.check(dl(Ct,r)),e.uuidv6=r=>e.check(pl(Ct,r)),e.uuidv7=r=>e.check(fl(Ct,r)),e.nanoid=r=>e.check(hl(ya,r)),e.guid=r=>e.check(mi(jn,r)),e.cuid=r=>e.check(gl(ba,r)),e.cuid2=r=>e.check(vl(_a,r)),e.ulid=r=>e.check(yl(wa,r)),e.base64=r=>e.check(Il(Ta,r)),e.base64url=r=>e.check(kl(Na,r)),e.xid=r=>e.check(bl(xa,r)),e.ksuid=r=>e.check(_l($a,r)),e.ipv4=r=>e.check(wl(Sa,r)),e.ipv6=r=>e.check(xl(Ia,r)),e.cidrv4=r=>e.check($l(ka,r)),e.cidrv6=r=>e.check(Sl(Ea,r)),e.e164=r=>e.check(El(Pa,r)),e.datetime=r=>e.check(Ky(r)),e.date=r=>e.check(Yy(r)),e.time=r=>e.check(Qy(r)),e.duration=r=>e.check(Xy(r))});function w(e){return Iv(fo,e)}const ve=S("ZodStringFormat",(e,t)=>{ge.init(e,t),ha.init(e,t)}),ga=S("ZodEmail",(e,t)=>{sg.init(e,t),ve.init(e,t)});function fb(e){return ll(ga,e)}const jn=S("ZodGUID",(e,t)=>{ig.init(e,t),ve.init(e,t)});function mb(e){return mi(jn,e)}const Ct=S("ZodUUID",(e,t)=>{ag.init(e,t),ve.init(e,t)});function hb(e){return cl(Ct,e)}function gb(e){return dl(Ct,e)}function vb(e){return pl(Ct,e)}function yb(e){return fl(Ct,e)}const mo=S("ZodURL",(e,t)=>{ug.init(e,t),ve.init(e,t)});function bb(e){return Xi(mo,e)}function _b(e){return Xi(mo,{protocol:/^https?$/,hostname:wh,...P(e)})}const va=S("ZodEmoji",(e,t)=>{lg.init(e,t),ve.init(e,t)});function wb(e){return ml(va,e)}const ya=S("ZodNanoID",(e,t)=>{cg.init(e,t),ve.init(e,t)});function xb(e){return hl(ya,e)}const ba=S("ZodCUID",(e,t)=>{dg.init(e,t),ve.init(e,t)});function $b(e){return gl(ba,e)}const _a=S("ZodCUID2",(e,t)=>{pg.init(e,t),ve.init(e,t)});function Sb(e){return vl(_a,e)}const wa=S("ZodULID",(e,t)=>{fg.init(e,t),ve.init(e,t)});function Ib(e){return yl(wa,e)}const xa=S("ZodXID",(e,t)=>{mg.init(e,t),ve.init(e,t)});function kb(e){return bl(xa,e)}const $a=S("ZodKSUID",(e,t)=>{hg.init(e,t),ve.init(e,t)});function Eb(e){return _l($a,e)}const Sa=S("ZodIPv4",(e,t)=>{_g.init(e,t),ve.init(e,t)});function Tb(e){return wl(Sa,e)}const Ul=S("ZodMAC",(e,t)=>{xg.init(e,t),ve.init(e,t)});function Ob(e){return Ev(Ul,e)}const Ia=S("ZodIPv6",(e,t)=>{wg.init(e,t),ve.init(e,t)});function Nb(e){return xl(Ia,e)}const ka=S("ZodCIDRv4",(e,t)=>{$g.init(e,t),ve.init(e,t)});function Pb(e){return $l(ka,e)}const Ea=S("ZodCIDRv6",(e,t)=>{Sg.init(e,t),ve.init(e,t)});function Cb(e){return Sl(Ea,e)}const Ta=S("ZodBase64",(e,t)=>{Ig.init(e,t),ve.init(e,t)});function Oa(e){return Il(Ta,e)}const Na=S("ZodBase64URL",(e,t)=>{Eg.init(e,t),ve.init(e,t)});function jb(e){return kl(Na,e)}const Pa=S("ZodE164",(e,t)=>{Tg.init(e,t),ve.init(e,t)});function Ab(e){return El(Pa,e)}const Ca=S("ZodJWT",(e,t)=>{Ng.init(e,t),ve.init(e,t)});function Rb(e){return Tl(Ca,e)}const un=S("ZodCustomStringFormat",(e,t)=>{Pg.init(e,t),ve.init(e,t)});function zb(e,t,r={}){return po(un,e,t,r)}function Mb(e){return po(un,"hostname",_h,e)}function Db(e){return po(un,"hex",Mh,e)}function Ub(e,t){const r=t?.enc??"hex",o=`${e}_${r}`,n=Xu[o];if(!n)throw new Error(`Unrecognized hash format: ${o}`);return po(un,o,n,t)}const ho=S("ZodNumber",(e,t)=>{nl.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>fy(e,o,n),e.gt=(o,n)=>e.check(ar(o,n)),e.gte=(o,n)=>e.check(We(o,n)),e.min=(o,n)=>e.check(We(o,n)),e.lt=(o,n)=>e.check(ir(o,n)),e.lte=(o,n)=>e.check(st(o,n)),e.max=(o,n)=>e.check(st(o,n)),e.int=o=>e.check(hi(o)),e.safe=o=>e.check(hi(o)),e.positive=o=>e.check(ar(0,o)),e.nonnegative=o=>e.check(We(0,o)),e.negative=o=>e.check(ir(0,o)),e.nonpositive=o=>e.check(st(0,o)),e.multipleOf=(o,n)=>e.check(Kr(o,n)),e.step=(o,n)=>e.check(Kr(o,n)),e.finite=()=>e;const r=e._zod.bag;e.minValue=Math.max(r.minimum??Number.NEGATIVE_INFINITY,r.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(r.maximum??Number.POSITIVE_INFINITY,r.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(r.format??"").includes("int")||Number.isSafeInteger(r.multipleOf??.5),e.isFinite=!0,e.format=r.format??null});function q(e){return jv(ho,e)}const Tr=S("ZodNumberFormat",(e,t)=>{Cg.init(e,t),ho.init(e,t)});function hi(e){return Rv(Tr,e)}function Lb(e){return zv(Tr,e)}function Zb(e){return Mv(Tr,e)}function Fb(e){return Dv(Tr,e)}function qb(e){return Uv(Tr,e)}const go=S("ZodBoolean",(e,t)=>{ol.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>my(e,r,o)});function pe(e){return Lv(go,e)}const vo=S("ZodBigInt",(e,t)=>{il.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>hy(e,o),e.gte=(o,n)=>e.check(We(o,n)),e.min=(o,n)=>e.check(We(o,n)),e.gt=(o,n)=>e.check(ar(o,n)),e.gte=(o,n)=>e.check(We(o,n)),e.min=(o,n)=>e.check(We(o,n)),e.lt=(o,n)=>e.check(ir(o,n)),e.lte=(o,n)=>e.check(st(o,n)),e.max=(o,n)=>e.check(st(o,n)),e.positive=o=>e.check(ar(BigInt(0),o)),e.negative=o=>e.check(ir(BigInt(0),o)),e.nonpositive=o=>e.check(st(BigInt(0),o)),e.nonnegative=o=>e.check(We(BigInt(0),o)),e.multipleOf=(o,n)=>e.check(Kr(o,n));const r=e._zod.bag;e.minValue=r.minimum??null,e.maxValue=r.maximum??null,e.format=r.format??null});function Vb(e){return Fv(vo,e)}const ja=S("ZodBigIntFormat",(e,t)=>{jg.init(e,t),vo.init(e,t)});function Bb(e){return Vv(ja,e)}function Jb(e){return Bv(ja,e)}const Ll=S("ZodSymbol",(e,t)=>{Ag.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>gy(e,r)});function Wb(e){return Jv(Ll,e)}const Zl=S("ZodUndefined",(e,t)=>{Rg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>yy(e,r)});function Hb(e){return Wv(Zl,e)}const Fl=S("ZodNull",(e,t)=>{zg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>vy(e,r,o)});function yo(e){return Hv(Fl,e)}const ql=S("ZodAny",(e,t)=>{Mg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>wy()});function Pe(){return Gv(ql)}const Vl=S("ZodUnknown",(e,t)=>{Dg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>xy()});function $e(){return Kv(Vl)}const Bl=S("ZodNever",(e,t)=>{Ug.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>_y(e,r,o)});function Aa(e){return Yv(Bl,e)}const Jl=S("ZodVoid",(e,t)=>{Lg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>by(e,r)});function Gb(e){return Qv(Jl,e)}const Ra=S("ZodDate",(e,t)=>{Zg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>$y(e,o),e.min=(o,n)=>e.check(We(o,n)),e.max=(o,n)=>e.check(st(o,n));const r=e._zod.bag;e.minDate=r.minimum?new Date(r.minimum):null,e.maxDate=r.maximum?new Date(r.maximum):null});function Kb(e){return Xv(Ra,e)}const Wl=S("ZodArray",(e,t)=>{Fg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ry(e,r,o,n),e.element=t.element,e.min=(r,o)=>e.check(br(r,o)),e.nonempty=r=>e.check(br(1,r)),e.max=(r,o)=>e.check(lo(r,o)),e.length=(r,o)=>e.check(co(r,o)),e.unwrap=()=>e.element});function R(e,t){return ry(Wl,e,t)}function Yb(e){const t=e._zod.def.shape;return dr(Object.keys(t))}const bo=S("ZodObject",(e,t)=>{Jg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>zy(e,r,o,n),ne(e,"shape",()=>t.shape),e.keyof=()=>dr(Object.keys(e._zod.def.shape)),e.catchall=r=>e.clone({...e._zod.def,catchall:r}),e.passthrough=()=>e.clone({...e._zod.def,catchall:$e()}),e.loose=()=>e.clone({...e._zod.def,catchall:$e()}),e.strict=()=>e.clone({...e._zod.def,catchall:Aa()}),e.strip=()=>e.clone({...e._zod.def,catchall:void 0}),e.extend=r=>qm(e,r),e.safeExtend=r=>Vm(e,r),e.merge=r=>Bm(e,r),e.pick=r=>Zm(e,r),e.omit=r=>Fm(e,r),e.partial=(...r)=>Jm(Da,e,r[0]),e.required=(...r)=>Wm(Ua,e,r[0])});function E(e,t){const r={type:"object",shape:e??{},...P(t)};return new bo(r)}function _e(e,t){return new bo({type:"object",shape:e,catchall:Aa(),...P(t)})}function er(e,t){return new bo({type:"object",shape:e,catchall:$e(),...P(t)})}const _o=S("ZodUnion",(e,t)=>{Qi.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Al(e,r,o,n),e.options=t.options});function G(e,t){return new _o({type:"union",options:e,...P(t)})}const Hl=S("ZodXor",(e,t)=>{_o.init(e,t),Wg.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Al(e,r,o,n),e.options=t.options});function Qb(e,t){return new Hl({type:"union",options:e,inclusive:!1,...P(t)})}const Gl=S("ZodDiscriminatedUnion",(e,t)=>{_o.init(e,t),Hg.init(e,t)});function za(e,t,r){return new Gl({type:"union",options:t,discriminator:e,...P(r)})}const Kl=S("ZodIntersection",(e,t)=>{Gg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>My(e,r,o,n)});function Yl(e,t){return new Kl({type:"intersection",left:e,right:t})}const Ql=S("ZodTuple",(e,t)=>{al.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Dy(e,r,o,n),e.rest=r=>e.clone({...e._zod.def,rest:r})});function Xl(e,t,r){const o=t instanceof X,n=o?r:t,i=o?t:null;return new Ql({type:"tuple",items:e,rest:i,...P(n)})}const wo=S("ZodRecord",(e,t)=>{Kg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Uy(e,r,o,n),e.keyType=t.keyType,e.valueType=t.valueType});function Xe(e,t,r){return new wo({type:"record",keyType:e,valueType:t,...P(r)})}function Xb(e,t,r){const o=dt(e);return o._zod.values=void 0,new wo({type:"record",keyType:o,valueType:t,...P(r)})}function e_(e,t,r){return new wo({type:"record",keyType:e,valueType:t,mode:"loose",...P(r)})}const ec=S("ZodMap",(e,t)=>{Yg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>jy(e,r),e.keyType=t.keyType,e.valueType=t.valueType});function t_(e,t,r){return new ec({type:"map",keyType:e,valueType:t,...P(r)})}const tc=S("ZodSet",(e,t)=>{Qg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ay(e,r),e.min=(...r)=>e.check(Yr(...r)),e.nonempty=r=>e.check(Yr(1,r)),e.max=(...r)=>e.check(uo(...r)),e.size=(...r)=>e.check(ea(...r))});function r_(e,t){return new tc({type:"set",valueType:e,...P(t)})}const tn=S("ZodEnum",(e,t)=>{Xg.init(e,t),re.init(e,t),e._zod.processJSONSchema=(o,n,i)=>Sy(e,o,n),e.enum=t.entries,e.options=Object.values(t.entries);const r=new Set(Object.keys(t.entries));e.extract=(o,n)=>{const i={};for(const a of o)if(r.has(a))i[a]=t.entries[a];else throw new Error(`Key ${a} not found in enum`);return new tn({...t,checks:[],...P(n),entries:i})},e.exclude=(o,n)=>{const i={...t.entries};for(const a of o)if(r.has(a))delete i[a];else throw new Error(`Key ${a} not found in enum`);return new tn({...t,checks:[],...P(n),entries:i})}});function dr(e,t){const r=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new tn({type:"enum",entries:r,...P(t)})}function n_(e,t){return new tn({type:"enum",entries:e,...P(t)})}const rc=S("ZodLiteral",(e,t)=>{ev.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Iy(e,r,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function C(e,t){return new rc({type:"literal",values:Array.isArray(e)?e:[e],...P(t)})}const nc=S("ZodFile",(e,t)=>{tv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ty(e,r,o),e.min=(r,o)=>e.check(Yr(r,o)),e.max=(r,o)=>e.check(uo(r,o)),e.mime=(r,o)=>e.check(sa(Array.isArray(r)?r:[r],o))});function o_(e){return ny(nc,e)}const oc=S("ZodTransform",(e,t)=>{rv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Cy(e,r),e._zod.parse=(r,o)=>{if(o.direction==="backward")throw new Wi(e.constructor.name);r.addIssue=i=>{if(typeof i=="string")r.issues.push(Hr(i,r.value,t));else{const a=i;a.fatal&&(a.continue=!1),a.code??(a.code="custom"),a.input??(a.input=r.value),a.inst??(a.inst=e),r.issues.push(Hr(a))}};const n=t.transform(r.value,r);return n instanceof Promise?n.then(i=>(r.value=i,r)):(r.value=n,r)}});function Ma(e){return new oc({type:"transform",transform:e})}const Da=S("ZodOptional",(e,t)=>{nv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Hy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function ee(e){return new Da({type:"optional",innerType:e})}const ic=S("ZodNullable",(e,t)=>{ov.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ly(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function An(e){return new ic({type:"nullable",innerType:e})}function i_(e){return ee(An(e))}const ac=S("ZodDefault",(e,t)=>{iv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Fy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function sc(e,t){return new ac({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Gi(t)}})}const uc=S("ZodPrefault",(e,t)=>{av.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>qy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function lc(e,t){return new uc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Gi(t)}})}const Ua=S("ZodNonOptional",(e,t)=>{sv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Zy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function cc(e,t){return new Ua({type:"nonoptional",innerType:e,...P(t)})}const dc=S("ZodSuccess",(e,t)=>{uv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Oy(e,r,o),e.unwrap=()=>e._zod.def.innerType});function a_(e){return new dc({type:"success",innerType:e})}const pc=S("ZodCatch",(e,t)=>{lv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Vy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function fc(e,t){return new pc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const mc=S("ZodNaN",(e,t)=>{cv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>ky(e,r)});function s_(e){return ty(mc,e)}const La=S("ZodPipe",(e,t)=>{dv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>By(e,r,o,n),e.in=t.in,e.out=t.out});function Rn(e,t){return new La({type:"pipe",in:e,out:t})}const Za=S("ZodCodec",(e,t)=>{La.init(e,t),sl.init(e,t)});function u_(e,t,r){return new Za({type:"pipe",in:e,out:t,transform:r.decode,reverseTransform:r.encode})}const hc=S("ZodReadonly",(e,t)=>{pv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Jy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function gc(e){return new hc({type:"readonly",innerType:e})}const vc=S("ZodTemplateLiteral",(e,t)=>{fv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ey(e,r,o)});function l_(e,t){return new vc({type:"template_literal",parts:e,...P(t)})}const yc=S("ZodLazy",(e,t)=>{gv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Gy(e,r,o,n),e.unwrap=()=>e._zod.def.getter()});function xo(e){return new yc({type:"lazy",getter:e})}const bc=S("ZodPromise",(e,t)=>{hv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Wy(e,r,o,n),e.unwrap=()=>e._zod.def.innerType});function c_(e){return new bc({type:"promise",innerType:e})}const _c=S("ZodFunction",(e,t)=>{mv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Py(e,r)});function gi(e){return new _c({type:"function",input:Array.isArray(e?.input)?Xl(e?.input):e?.input??R($e()),output:e?.output??$e()})}const $o=S("ZodCustom",(e,t)=>{vv.init(e,t),re.init(e,t),e._zod.processJSONSchema=(r,o,n)=>Ny(e,r)});function d_(e){const t=new Se({check:"custom"});return t._zod.check=e,t}function So(e,t){return oy($o,e??(()=>!0),t)}function wc(e,t={}){return iy($o,e,t)}function xc(e){return ay(e)}const p_=uy,f_=ly;function Rt(e,t={error:`Input not instance of ${e.name}`}){const r=new $o({type:"custom",check:"custom",fn:o=>o instanceof e,abort:!0,...P(t)});return r._zod.bag.Class=e,r}const m_=(...e)=>cy({Codec:Za,Boolean:go,String:fo},...e);function h_(e){const t=xo(()=>G([w(e),q(),pe(),yo(),R(t),Xe(w(),t)]));return t}function g_(e,t){return Rn(Ma(e),t)}const QE=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:ql,ZodArray:Wl,ZodBase64:Ta,ZodBase64URL:Na,ZodBigInt:vo,ZodBigIntFormat:ja,ZodBoolean:go,ZodCIDRv4:ka,ZodCIDRv6:Ea,ZodCUID:ba,ZodCUID2:_a,ZodCatch:pc,ZodCodec:Za,ZodCustom:$o,ZodCustomStringFormat:un,ZodDate:Ra,ZodDefault:ac,ZodDiscriminatedUnion:Gl,ZodE164:Pa,ZodEmail:ga,ZodEmoji:va,ZodEnum:tn,ZodFile:nc,ZodFunction:_c,ZodGUID:jn,ZodIPv4:Sa,ZodIPv6:Ia,ZodIntersection:Kl,ZodJWT:Ca,ZodKSUID:$a,ZodLazy:yc,ZodLiteral:rc,ZodMAC:Ul,ZodMap:ec,ZodNaN:mc,ZodNanoID:ya,ZodNever:Bl,ZodNonOptional:Ua,ZodNull:Fl,ZodNullable:ic,ZodNumber:ho,ZodNumberFormat:Tr,ZodObject:bo,ZodOptional:Da,ZodPipe:La,ZodPrefault:uc,ZodPromise:bc,ZodReadonly:hc,ZodRecord:wo,ZodSet:tc,ZodString:fo,ZodStringFormat:ve,ZodSuccess:dc,ZodSymbol:Ll,ZodTemplateLiteral:vc,ZodTransform:oc,ZodTuple:Ql,ZodType:re,ZodULID:wa,ZodURL:mo,ZodUUID:Ct,ZodUndefined:Zl,ZodUnion:_o,ZodUnknown:Vl,ZodVoid:Jl,ZodXID:xa,ZodXor:Hl,_ZodString:ha,_default:sc,_function:gi,any:Pe,array:R,base64:Oa,base64url:jb,bigint:Vb,boolean:pe,catch:fc,check:d_,cidrv4:Pb,cidrv6:Cb,codec:u_,cuid:$b,cuid2:Sb,custom:So,date:Kb,describe:p_,discriminatedUnion:za,e164:Ab,email:fb,emoji:wb,enum:dr,file:o_,float32:Lb,float64:Zb,function:gi,guid:mb,hash:Ub,hex:Db,hostname:Mb,httpUrl:_b,instanceof:Rt,int:hi,int32:Fb,int64:Bb,intersection:Yl,ipv4:Tb,ipv6:Nb,json:h_,jwt:Rb,keyof:Yb,ksuid:Eb,lazy:xo,literal:C,looseObject:er,looseRecord:e_,mac:Ob,map:t_,meta:f_,nan:s_,nanoid:xb,nativeEnum:n_,never:Aa,nonoptional:cc,null:yo,nullable:An,nullish:i_,number:q,object:E,optional:ee,partialRecord:Xb,pipe:Rn,prefault:lc,preprocess:g_,promise:c_,readonly:gc,record:Xe,refine:wc,set:r_,strictObject:_e,string:w,stringFormat:zb,stringbool:m_,success:a_,superRefine:xc,symbol:Wb,templateLiteral:l_,transform:Ma,tuple:Xl,uint32:qb,uint64:Jb,ulid:Ib,undefined:Hb,union:G,unknown:$e,url:bb,uuid:hb,uuidv4:gb,uuidv6:vb,uuidv7:yb,void:Gb,xid:kb,xor:Qb},Symbol.toStringTag,{value:"Module"})),v_={invalid_type:"invalid_type",too_big:"too_big",too_small:"too_small",invalid_format:"invalid_format",not_multiple_of:"not_multiple_of",unrecognized_keys:"unrecognized_keys",invalid_union:"invalid_union",invalid_key:"invalid_key",invalid_element:"invalid_element",invalid_value:"invalid_value",custom:"custom"};function XE(e){De({customError:e})}function eT(){return De().customError}var ru;ru||(ru={});const D={...QE,...KE,iso:eb};function tT(e,t){const r=e.$schema;return r==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":r==="http://json-schema.org/draft-07/schema#"?"draft-7":r==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function rT(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");const r=e.slice(1).split("/").filter(Boolean);if(r.length===0)return t.rootSchema;const o=t.version==="draft-2020-12"?"$defs":"definitions";if(r[0]===o){const n=r[1];if(!n||!t.defs[n])throw new Error(`Reference not found: ${e}`);return t.defs[n]}throw new Error(`Reference not found: ${e}`)}function y_(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return D.never();throw new Error("not is not supported in Zod (except { not: {} } for never)")}if(e.unevaluatedItems!==void 0)throw new Error("unevaluatedItems is not supported");if(e.unevaluatedProperties!==void 0)throw new Error("unevaluatedProperties is not supported");if(e.if!==void 0||e.then!==void 0||e.else!==void 0)throw new Error("Conditional schemas (if/then/else) are not supported");if(e.dependentSchemas!==void 0||e.dependentRequired!==void 0)throw new Error("dependentSchemas and dependentRequired are not supported");if(e.$ref){const n=e.$ref;if(t.refs.has(n))return t.refs.get(n);if(t.processing.has(n))return D.lazy(()=>{if(!t.refs.has(n))throw new Error(`Circular reference not resolved: ${n}`);return t.refs.get(n)});t.processing.add(n);const i=rT(n,t),a=Me(i,t);return t.refs.set(n,a),t.processing.delete(n),a}if(e.enum!==void 0){const n=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&n.length===1&&n[0]===null)return D.null();if(n.length===0)return D.never();if(n.length===1)return D.literal(n[0]);if(n.every(a=>typeof a=="string"))return D.enum(n);const i=n.map(a=>D.literal(a));return i.length<2?i[0]:D.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return D.literal(e.const);const r=e.type;if(Array.isArray(r)){const n=r.map(i=>{const a={...e,type:i};return y_(a,t)});return n.length===0?D.never():n.length===1?n[0]:D.union(n)}if(!r)return D.any();let o;switch(r){case"string":{let n=D.string();if(e.format){const i=e.format;i==="email"?n=n.check(D.email()):i==="uri"||i==="uri-reference"?n=n.check(D.url()):i==="uuid"||i==="guid"?n=n.check(D.uuid()):i==="date-time"?n=n.check(D.iso.datetime()):i==="date"?n=n.check(D.iso.date()):i==="time"?n=n.check(D.iso.time()):i==="duration"?n=n.check(D.iso.duration()):i==="ipv4"?n=n.check(D.ipv4()):i==="ipv6"?n=n.check(D.ipv6()):i==="mac"?n=n.check(D.mac()):i==="cidr"?n=n.check(D.cidrv4()):i==="cidr-v6"?n=n.check(D.cidrv6()):i==="base64"?n=n.check(D.base64()):i==="base64url"?n=n.check(D.base64url()):i==="e164"?n=n.check(D.e164()):i==="jwt"?n=n.check(D.jwt()):i==="emoji"?n=n.check(D.emoji()):i==="nanoid"?n=n.check(D.nanoid()):i==="cuid"?n=n.check(D.cuid()):i==="cuid2"?n=n.check(D.cuid2()):i==="ulid"?n=n.check(D.ulid()):i==="xid"?n=n.check(D.xid()):i==="ksuid"&&(n=n.check(D.ksuid()))}typeof e.minLength=="number"&&(n=n.min(e.minLength)),typeof e.maxLength=="number"&&(n=n.max(e.maxLength)),e.pattern&&(n=n.regex(new RegExp(e.pattern))),o=n;break}case"number":case"integer":{let n=r==="integer"?D.number().int():D.number();typeof e.minimum=="number"&&(n=n.min(e.minimum)),typeof e.maximum=="number"&&(n=n.max(e.maximum)),typeof e.exclusiveMinimum=="number"?n=n.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(n=n.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?n=n.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(n=n.lt(e.maximum)),typeof e.multipleOf=="number"&&(n=n.multipleOf(e.multipleOf)),o=n;break}case"boolean":{o=D.boolean();break}case"null":{o=D.null();break}case"object":{const n={},i=e.properties||{},a=new Set(e.required||[]);for(const[l,u]of Object.entries(i)){const c=Me(u,t);n[l]=a.has(l)?c:c.optional()}if(e.propertyNames){const l=Me(e.propertyNames,t),u=e.additionalProperties&&typeof e.additionalProperties=="object"?Me(e.additionalProperties,t):D.any();if(Object.keys(n).length===0){o=D.record(l,u);break}const c=D.object(n).passthrough(),d=D.looseRecord(l,u);o=D.intersection(c,d);break}if(e.patternProperties){const l=e.patternProperties,u=Object.keys(l),c=[];for(const f of u){const p=Me(l[f],t),g=D.string().regex(new RegExp(f));c.push(D.looseRecord(g,p))}const d=[];if(Object.keys(n).length>0&&d.push(D.object(n).passthrough()),d.push(...c),d.length===0)o=D.object({}).passthrough();else if(d.length===1)o=d[0];else{let f=D.intersection(d[0],d[1]);for(let p=2;p<d.length;p++)f=D.intersection(f,d[p]);o=f}break}const s=D.object(n);e.additionalProperties===!1?o=s.strict():typeof e.additionalProperties=="object"?o=s.catchall(Me(e.additionalProperties,t)):o=s.passthrough();break}case"array":{const n=e.prefixItems,i=e.items;if(n&&Array.isArray(n)){const a=n.map(l=>Me(l,t)),s=i&&typeof i=="object"&&!Array.isArray(i)?Me(i,t):void 0;s?o=D.tuple(a).rest(s):o=D.tuple(a),typeof e.minItems=="number"&&(o=o.check(D.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(D.maxLength(e.maxItems)))}else if(Array.isArray(i)){const a=i.map(l=>Me(l,t)),s=e.additionalItems&&typeof e.additionalItems=="object"?Me(e.additionalItems,t):void 0;s?o=D.tuple(a).rest(s):o=D.tuple(a),typeof e.minItems=="number"&&(o=o.check(D.minLength(e.minItems))),typeof e.maxItems=="number"&&(o=o.check(D.maxLength(e.maxItems)))}else if(i!==void 0){const a=Me(i,t);let s=D.array(a);typeof e.minItems=="number"&&(s=s.min(e.minItems)),typeof e.maxItems=="number"&&(s=s.max(e.maxItems)),o=s}else o=D.array(D.any());break}default:throw new Error(`Unsupported type: ${r}`)}return e.description&&(o=o.describe(e.description)),e.default!==void 0&&(o=o.default(e.default)),o}function Me(e,t){if(typeof e=="boolean")return e?D.any():D.never();let r=y_(e,t);const o=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){const n=e.anyOf.map(a=>Me(a,t)),i=D.union(n);r=o?D.intersection(r,i):i}if(e.oneOf&&Array.isArray(e.oneOf)){const n=e.oneOf.map(a=>Me(a,t)),i=D.xor(n);r=o?D.intersection(r,i):i}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)r=o?r:D.any();else{let n=o?r:Me(e.allOf[0],t);const i=o?0:1;for(let a=i;a<e.allOf.length;a++)n=D.intersection(n,Me(e.allOf[a],t));r=n}return e.nullable===!0&&t.version==="openapi-3.0"&&(r=D.nullable(r)),e.readOnly===!0&&(r=D.readonly(r)),r}function nT(e,t){if(typeof e=="boolean")return e?D.any():D.never();const r=tT(e,t?.defaultTarget),o=e.$defs||e.definitions||{};return Me(e,{version:r,defs:o,refs:new Map,processing:new Set,rootSchema:e})}function oT(e){return kv(fo,e)}function iT(e){return Av(ho,e)}function aT(e){return Zv(go,e)}function sT(e){return qv(vo,e)}function uT(e){return ey(Ra,e)}const lT=Object.freeze(Object.defineProperty({__proto__:null,bigint:sT,boolean:aT,date:uT,number:iT,string:oT},Symbol.toStringTag,{value:"Module"}));De(yv());const vi=Object.freeze(Object.defineProperty({__proto__:null,$brand:jm,$input:$v,$output:xv,NEVER:Du,TimePrecision:Tv,ZodAny:ql,ZodArray:Wl,ZodBase64:Ta,ZodBase64URL:Na,ZodBigInt:vo,ZodBigIntFormat:ja,ZodBoolean:go,ZodCIDRv4:ka,ZodCIDRv6:Ea,ZodCUID:ba,ZodCUID2:_a,ZodCatch:pc,ZodCodec:Za,ZodCustom:$o,ZodCustomStringFormat:un,ZodDate:Ra,ZodDefault:ac,ZodDiscriminatedUnion:Gl,ZodE164:Pa,ZodEmail:ga,ZodEmoji:va,ZodEnum:tn,ZodError:YE,ZodFile:nc,get ZodFirstPartyTypeKind(){return ru},ZodFunction:_c,ZodGUID:jn,ZodIPv4:Sa,ZodIPv6:Ia,ZodISODate:zl,ZodISODateTime:Rl,ZodISODuration:Dl,ZodISOTime:Ml,ZodIntersection:Kl,ZodIssueCode:v_,ZodJWT:Ca,ZodKSUID:$a,ZodLazy:yc,ZodLiteral:rc,ZodMAC:Ul,ZodMap:ec,ZodNaN:mc,ZodNanoID:ya,ZodNever:Bl,ZodNonOptional:Ua,ZodNull:Fl,ZodNullable:ic,ZodNumber:ho,ZodNumberFormat:Tr,ZodObject:bo,ZodOptional:Da,ZodPipe:La,ZodPrefault:uc,ZodPromise:bc,ZodReadonly:hc,ZodRealError:ot,ZodRecord:wo,ZodSet:tc,ZodString:fo,ZodStringFormat:ve,ZodSuccess:dc,ZodSymbol:Ll,ZodTemplateLiteral:vc,ZodTransform:oc,ZodTuple:Ql,ZodType:re,ZodULID:wa,ZodURL:mo,ZodUUID:Ct,ZodUndefined:Zl,ZodUnion:_o,ZodUnknown:Vl,ZodVoid:Jl,ZodXID:xa,ZodXor:Hl,_ZodString:ha,_default:sc,_function:gi,any:Pe,array:R,base64:Oa,base64url:jb,bigint:Vb,boolean:pe,catch:fc,check:d_,cidrv4:Pb,cidrv6:Cb,clone:dt,codec:u_,coerce:lT,config:De,core:GE,cuid:$b,cuid2:Sb,custom:So,date:Kb,decode:ab,decodeAsync:ub,describe:p_,discriminatedUnion:za,e164:Ab,email:fb,emoji:wb,encode:ib,encodeAsync:sb,endsWith:aa,enum:dr,file:o_,flattenError:Fu,float32:Lb,float64:Zb,formatError:qu,fromJSONSchema:nT,function:gi,getErrorMap:eT,globalRegistry:wt,gt:ar,gte:We,guid:mb,hash:Ub,hex:Db,hostname:Mb,httpUrl:_b,includes:oa,instanceof:Rt,int:hi,int32:Fb,int64:Bb,intersection:Yl,ipv4:Tb,ipv6:Nb,iso:eb,json:h_,jwt:Rb,keyof:Yb,ksuid:Eb,lazy:xo,length:co,literal:C,locales:wv,looseObject:er,looseRecord:e_,lowercase:ra,lt:ir,lte:st,mac:Ob,map:t_,maxLength:lo,maxSize:uo,meta:f_,mime:sa,minLength:br,minSize:Yr,multipleOf:Kr,nan:s_,nanoid:xb,nativeEnum:n_,negative:Nl,never:Aa,nonnegative:Cl,nonoptional:cc,nonpositive:Pl,normalize:ua,null:yo,nullable:An,nullish:i_,number:q,object:E,optional:ee,overwrite:Ht,parse:rb,parseAsync:nb,partialRecord:Xb,pipe:Rn,positive:Ol,prefault:lc,preprocess:g_,prettifyError:eh,promise:c_,property:jl,readonly:gc,record:Xe,refine:wc,regex:ta,regexes:Xu,registry:ul,safeDecode:cb,safeDecodeAsync:pb,safeEncode:lb,safeEncodeAsync:db,safeParse:ob,safeParseAsync:ma,set:r_,setErrorMap:XE,size:ea,slugify:pa,startsWith:ia,strictObject:_e,string:w,stringFormat:zb,stringbool:m_,success:a_,superRefine:xc,symbol:Wb,templateLiteral:l_,toJSONSchema:fa,toLowerCase:ca,toUpperCase:da,transform:Ma,treeifyError:Qm,trim:la,tuple:Xl,uint32:qb,uint64:Jb,ulid:Ib,undefined:Hb,union:G,unknown:$e,uppercase:na,url:bb,util:Km,uuid:hb,uuidv4:gb,uuidv6:vb,uuidv7:yb,void:Gb,xid:kb,xor:Qb},Symbol.toStringTag,{value:"Module"}));var zn;(function(e){e.assertEqual=n=>{};function t(n){}e.assertIs=t;function r(n){throw new Error}e.assertNever=r,e.arrayToEnum=n=>{const i={};for(const a of n)i[a]=a;return i},e.getValidEnumValues=n=>{const i=e.objectKeys(n).filter(s=>typeof n[n[s]]!="number"),a={};for(const s of i)a[s]=n[s];return e.objectValues(a)},e.objectValues=n=>e.objectKeys(n).map(function(i){return n[i]}),e.objectKeys=typeof Object.keys=="function"?n=>Object.keys(n):n=>{const i=[];for(const a in n)Object.prototype.hasOwnProperty.call(n,a)&&i.push(a);return i},e.find=(n,i)=>{for(const a of n)if(i(a))return a},e.isInteger=typeof Number.isInteger=="function"?n=>Number.isInteger(n):n=>typeof n=="number"&&Number.isFinite(n)&&Math.floor(n)===n;function o(n,i=" | "){return n.map(a=>typeof a=="string"?`'${a}'`:a).join(i)}e.joinValues=o,e.jsonStringifyReplacer=(n,i)=>typeof i=="bigint"?i.toString():i})(zn||(zn={}));var Xd;(function(e){e.mergeShapes=(t,r)=>({...t,...r})})(Xd||(Xd={}));zn.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]);zn.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class yi extends Error{get errors(){return this.issues}constructor(t){super(),this.issues=[],this.addIssue=o=>{this.issues=[...this.issues,o]},this.addIssues=(o=[])=>{this.issues=[...this.issues,...o]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=t}format(t){const r=t||function(i){return i.message},o={_errors:[]},n=i=>{for(const a of i.issues)if(a.code==="invalid_union")a.unionErrors.map(n);else if(a.code==="invalid_return_type")n(a.returnTypeError);else if(a.code==="invalid_arguments")n(a.argumentsError);else if(a.path.length===0)o._errors.push(r(a));else{let s=o,l=0;for(;l<a.path.length;){const u=a.path[l];l===a.path.length-1?(s[u]=s[u]||{_errors:[]},s[u]._errors.push(r(a))):s[u]=s[u]||{_errors:[]},s=s[u],l++}}};return n(this),o}static assert(t){if(!(t instanceof yi))throw new Error(`Not a ZodError: ${t}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,zn.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(t=r=>r.message){const r=Object.create(null),o=[];for(const n of this.issues)if(n.path.length>0){const i=n.path[0];r[i]=r[i]||[],r[i].push(t(n))}else o.push(t(n));return{formErrors:o,fieldErrors:r}}get formErrors(){return this.flatten()}}yi.create=e=>new yi(e);var ep;(function(e){e.errToObj=t=>typeof t=="string"?{message:t}:t||{},e.toString=t=>typeof t=="string"?t:t?.message})(ep||(ep={}));var A;(function(e){e.ZodString="ZodString",e.ZodNumber="ZodNumber",e.ZodNaN="ZodNaN",e.ZodBigInt="ZodBigInt",e.ZodBoolean="ZodBoolean",e.ZodDate="ZodDate",e.ZodSymbol="ZodSymbol",e.ZodUndefined="ZodUndefined",e.ZodNull="ZodNull",e.ZodAny="ZodAny",e.ZodUnknown="ZodUnknown",e.ZodNever="ZodNever",e.ZodVoid="ZodVoid",e.ZodArray="ZodArray",e.ZodObject="ZodObject",e.ZodUnion="ZodUnion",e.ZodDiscriminatedUnion="ZodDiscriminatedUnion",e.ZodIntersection="ZodIntersection",e.ZodTuple="ZodTuple",e.ZodRecord="ZodRecord",e.ZodMap="ZodMap",e.ZodSet="ZodSet",e.ZodFunction="ZodFunction",e.ZodLazy="ZodLazy",e.ZodLiteral="ZodLiteral",e.ZodEnum="ZodEnum",e.ZodEffects="ZodEffects",e.ZodNativeEnum="ZodNativeEnum",e.ZodOptional="ZodOptional",e.ZodNullable="ZodNullable",e.ZodDefault="ZodDefault",e.ZodCatch="ZodCatch",e.ZodPromise="ZodPromise",e.ZodBranded="ZodBranded",e.ZodPipeline="ZodPipeline",e.ZodReadonly="ZodReadonly"})(A||(A={}));var cT=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const n=()=>{const i=r.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=r[Math.random()*i|0];return a.join("")};if(e==null)return n;if(r.includes(o))throw new Ji({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${r}".`});return()=>`${e}${o}${n()}`};cT();function b_(e=globalThis){var t,r,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(r=e.process)==null?void 0:r.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function dT(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((r,o)=>{t[o.toLowerCase()]=r});else{Array.isArray(e)||(e=Object.entries(e));for(const[r,o]of e)o!=null&&(t[r.toLowerCase()]=o)}return t}function __(e,...t){const r=new Headers(dT(e)),o=r.get("user-agent")||"";return r.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var pT=Symbol.for("vercel.ai.validator");function fT(e){return{...e,type:"dynamic"}}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");var mT=Symbol.for("vercel.ai.schema");function hT(e,{validate:t}={}){return{[mT]:!0,_type:void 0,[pT]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}let $c;$c=globalThis.crypto;async function gT(e){return(await $c).getRandomValues(new Uint8Array(e))}async function vT(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~";let r="";const o=await gT(e);for(let n=0;n<e;n++){const i=o[n]%t.length;r+=t[i]}return r}async function yT(e){return await vT(e)}async function bT(e){const t=await(await $c).subtle.digest("SHA-256",new TextEncoder().encode(e));return btoa(String.fromCharCode(...new Uint8Array(t))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function _T(e){if(e||(e=43),e<43||e>128)throw`Expected a length between 43 and 128. Received ${e}.`;const t=await yT(e),r=await bT(t);return{code_verifier:t,code_challenge:r}}var wT="AI_MCPClientError",w_=`vercel.ai.error.${wT}`,xT=Symbol.for(w_),tp,rp,se=class extends(rp=Y,tp=xT,rp){constructor({name:e="MCPClientError",message:t,cause:r,data:o,code:n}){super({name:e,message:t,cause:r}),this[tp]=!0,this.data=o,this.code=n}static isInstance(e){return Y.hasMarker(e,w_)}},ln="2025-06-18",$T=[ln,"2025-03-26","2024-11-05"],ST=er({name:w(),version:w()}),Fa=er({_meta:ee(E({}).loose())}),Vt=Fa,x_=E({method:w(),params:ee(Fa)}),$_=E({applyDefaults:ee(pe())}).loose(),IT=er({experimental:ee(E({}).loose()),logging:ee(E({}).loose()),prompts:ee(er({listChanged:ee(pe())})),resources:ee(er({subscribe:ee(pe()),listChanged:ee(pe())})),tools:ee(er({listChanged:ee(pe())})),elicitation:ee($_)});E({elicitation:ee($_)}).loose();var kT=Vt.extend({protocolVersion:w(),capabilities:IT,serverInfo:ST,instructions:ee(w())}),Sc=Vt.extend({nextCursor:ee(w())}),ET=E({name:w(),description:ee(w()),inputSchema:E({type:C("object"),properties:ee(E({}).loose())}).loose()}).loose(),TT=Sc.extend({tools:R(ET)}),S_=E({type:C("text"),text:w()}).loose(),I_=E({type:C("image"),data:Oa(),mimeType:w()}).loose(),OT=E({uri:w(),name:w(),title:ee(w()),description:ee(w()),mimeType:ee(w()),size:ee(q())}).loose(),NT=Sc.extend({resources:R(OT)}),k_=E({uri:w(),name:ee(w()),title:ee(w()),mimeType:ee(w())}).loose(),E_=k_.extend({text:w()}),T_=k_.extend({blob:Oa()}),O_=E({type:C("resource"),resource:G([E_,T_])}).loose(),PT=Vt.extend({content:R(G([S_,I_,O_])),isError:pe().default(!1).optional()}).or(Vt.extend({toolResult:$e()})),CT=E({uriTemplate:w(),name:w(),title:ee(w()),description:ee(w()),mimeType:ee(w())}).loose(),jT=Vt.extend({resourceTemplates:R(CT)}),AT=Vt.extend({contents:R(G([E_,T_]))}),RT=E({name:w(),description:ee(w()),required:ee(pe())}).loose(),zT=E({name:w(),title:ee(w()),description:ee(w()),arguments:ee(R(RT))}).loose(),MT=Sc.extend({prompts:R(zT)}),DT=E({role:G([C("user"),C("assistant")]),content:G([S_,I_,O_])}).loose(),UT=Vt.extend({description:ee(w()),messages:R(DT)}),LT=Fa.extend({message:w(),requestedSchema:$e()}),np=x_.extend({method:C("elicitation/create"),params:LT}),ZT=Vt.extend({action:G([C("accept"),C("decline"),C("cancel")]),content:ee(Xe(w(),$e()))}),qa="2.0",FT=E({jsonrpc:C(qa),id:G([w(),q().int()])}).merge(x_).strict(),qT=E({jsonrpc:C(qa),id:G([w(),q().int()]),result:Vt}).strict(),VT=E({jsonrpc:C(qa),id:G([w(),q().int()]),error:E({code:q().int(),message:w(),data:ee($e())})}).strict(),BT=E({jsonrpc:C(qa)}).merge(E({method:w(),params:ee(Fa)})).strict(),In=G([FT,BT,qT,VT]),N_=typeof __PACKAGE_VERSION__<"u"?__PACKAGE_VERSION__:"0.0.0-test",P_=E({access_token:w(),id_token:w().optional(),token_type:w(),expires_in:q().optional(),scope:w().optional(),refresh_token:w().optional()}).strip(),He=w().url().superRefine((e,t)=>{if(!URL.canParse(e))return t.addIssue({code:v_.custom,message:"URL must be parseable",fatal:!0}),Du}).refine(e=>{const t=new URL(e);return t.protocol!=="javascript:"&&t.protocol!=="data:"&&t.protocol!=="vbscript:"},{message:"URL cannot use javascript:, data:, or vbscript: scheme"}),JT=E({resource:w().url(),authorization_servers:R(He).optional(),jwks_uri:w().url().optional(),scopes_supported:R(w()).optional(),bearer_methods_supported:R(w()).optional(),resource_signing_alg_values_supported:R(w()).optional(),resource_name:w().optional(),resource_documentation:w().optional(),resource_policy_uri:w().url().optional(),resource_tos_uri:w().url().optional(),tls_client_certificate_bound_access_tokens:pe().optional(),authorization_details_types_supported:R(w()).optional(),dpop_signing_alg_values_supported:R(w()).optional(),dpop_bound_access_tokens_required:pe().optional()}).passthrough(),C_=E({issuer:w(),authorization_endpoint:He,token_endpoint:He,registration_endpoint:He.optional(),scopes_supported:R(w()).optional(),response_types_supported:R(w()),grant_types_supported:R(w()).optional(),code_challenge_methods_supported:R(w()),token_endpoint_auth_methods_supported:R(w()).optional(),token_endpoint_auth_signing_alg_values_supported:R(w()).optional()}).passthrough(),WT=E({issuer:w(),authorization_endpoint:He,token_endpoint:He,userinfo_endpoint:He.optional(),jwks_uri:He,registration_endpoint:He.optional(),scopes_supported:R(w()).optional(),response_types_supported:R(w()),grant_types_supported:R(w()).optional(),subject_types_supported:R(w()),id_token_signing_alg_values_supported:R(w()),claims_supported:R(w()).optional(),token_endpoint_auth_methods_supported:R(w()).optional()}).passthrough(),HT=WT.merge(C_.pick({code_challenge_methods_supported:!0})),GT=E({client_id:w(),client_secret:w().optional(),client_id_issued_at:q().optional(),client_secret_expires_at:q().optional()}).strip(),KT=E({redirect_uris:R(He),token_endpoint_auth_method:w().optional(),grant_types:R(w()).optional(),response_types:R(w()).optional(),client_name:w().optional(),client_uri:He.optional(),logo_uri:He.optional(),scope:w().optional(),contacts:R(w()).optional(),tos_uri:He.optional(),policy_uri:w().optional(),jwks_uri:He.optional(),jwks:Pe().optional(),software_id:w().optional(),software_version:w().optional(),software_statement:w().optional()}).strip(),YT=E({error:w(),error_description:w().optional(),error_uri:w().optional()}),QT=KT.merge(GT),XT="AI_MCPClientOAuthError",j_=`vercel.ai.error.${XT}`,eO=Symbol.for(j_),op,ip,Io=class extends(ip=Y,op=eO,ip){constructor({name:e="MCPClientOAuthError",message:t,cause:r}){super({name:e,message:t,cause:r}),this[op]=!0}static isInstance(e){return Y.hasMarker(e,j_)}},rn=class extends Io{};rn.errorCode="server_error";var bi=class extends Io{};bi.errorCode="invalid_client";var _i=class extends Io{};_i.errorCode="invalid_grant";var wi=class extends Io{};wi.errorCode="unauthorized_client";var tO={[rn.errorCode]:rn,[bi.errorCode]:bi,[_i.errorCode]:_i,[wi.errorCode]:wi};function rO(e){const t=typeof e=="string"?new URL(e):new URL(e.href);return t.hash="",t}function nO({requestedResource:e,configuredResource:t}){const r=typeof e=="string"?new URL(e):new URL(e.href),o=typeof t=="string"?new URL(t):new URL(t.href);if(r.origin!==o.origin||r.pathname.length<o.pathname.length)return!1;const n=r.pathname.endsWith("/")?r.pathname:r.pathname+"/",i=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";return n.startsWith(i)}var xi=class extends Error{constructor(e="Unauthorized"){super(e),this.name="UnauthorizedError"}};function $i(e){var t;const r=(t=e.headers.get("www-authenticate"))!=null?t:e.headers.get("WWW-Authenticate");if(!r)return;const[o,n]=r.split(" ");if(o.toLowerCase()!=="bearer"||!n)return;const i=/resource_metadata="([^"]*)"/,a=r.match(i);if(a)try{return new URL(a[1])}catch{return}}function oO(e,t="",r={}){return t.endsWith("/")&&(t=t.slice(0,-1)),r.prependPathname?`${t}/.well-known/${e}`:`/.well-known/${e}${t}`}async function Ic(e,t,r=fetch){try{return await r(e,{headers:t})}catch(o){if(o instanceof TypeError)return t?Ic(e,void 0,r):void 0;throw o}}async function ap(e,t,r=fetch){return await Ic(e,{"MCP-Protocol-Version":t},r)}function iO(e,t){return!e||e.status>=400&&e.status<500&&t!=="/"}async function aO(e,t,r,o){var n,i;const a=new URL(e),s=(n=o?.protocolVersion)!=null?n:ln;let l;if(o?.metadataUrl)l=new URL(o.metadataUrl);else{const c=oO(t,a.pathname);l=new URL(c,(i=o?.metadataServerUrl)!=null?i:a),l.search=a.search}let u=await ap(l,s,r);if(!o?.metadataUrl&&iO(u,a.pathname)){const c=new URL(`/.well-known/${t}`,a);u=await ap(c,s,r)}return u}async function sO(e,t,r=fetch){const o=await aO(e,"oauth-protected-resource",r,{protocolVersion:t?.protocolVersion,metadataUrl:t?.resourceMetadataUrl});if(!o||o.status===404)throw new Error("Resource server does not implement OAuth 2.0 Protected Resource Metadata.");if(!o.ok)throw new Error(`HTTP ${o.status} trying to load well-known OAuth protected resource metadata.`);return JT.parse(await o.json())}function uO(e){const t=typeof e=="string"?new URL(e):e,r=t.pathname!=="/",o=[];if(!r)return o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),o.push({url:new URL("/.well-known/openid-configuration",t.origin),type:"oidc"}),o;let n=t.pathname;return n.endsWith("/")&&(n=n.slice(0,-1)),o.push({url:new URL(`/.well-known/oauth-authorization-server${n}`,t.origin),type:"oauth"}),o.push({url:new URL("/.well-known/oauth-authorization-server",t.origin),type:"oauth"}),o.push({url:new URL(`/.well-known/openid-configuration${n}`,t.origin),type:"oidc"}),o.push({url:new URL(`${n}/.well-known/openid-configuration`,t.origin),type:"oidc"}),o}async function lO(e,{fetchFn:t=fetch,protocolVersion:r=ln}={}){var o;const n={"MCP-Protocol-Version":r},i=uO(e);for(const{url:a,type:s}of i){const l=await Ic(a,n,t);if(l){if(!l.ok){if(l.status>=400&&l.status<500)continue;throw new Error(`HTTP ${l.status} trying to load ${s==="oauth"?"OAuth":"OpenID provider"} metadata from ${a}`)}if(s==="oauth")return C_.parse(await l.json());{const u=HT.parse(await l.json());if(!((o=u.code_challenge_methods_supported)!=null&&o.includes("S256")))throw new Error(`Incompatible OIDC provider at ${a}: does not support S256 code challenge method required by MCP specification`);return u}}}}async function cO(e,{metadata:t,clientInformation:r,redirectUrl:o,scope:n,state:i,resource:a}){const s="code",l="S256";let u;if(t){if(u=new URL(t.authorization_endpoint),!t.response_types_supported.includes(s))throw new Error(`Incompatible auth server: does not support response type ${s}`);if(!t.code_challenge_methods_supported||!t.code_challenge_methods_supported.includes(l))throw new Error(`Incompatible auth server: does not support code challenge method ${l}`)}else u=new URL("/authorize",e);const c=await _T(),d=c.code_verifier,f=c.code_challenge;return u.searchParams.set("response_type",s),u.searchParams.set("client_id",r.client_id),u.searchParams.set("code_challenge",f),u.searchParams.set("code_challenge_method",l),u.searchParams.set("redirect_uri",String(o)),i&&u.searchParams.set("state",i),n&&u.searchParams.set("scope",n),n?.includes("offline_access")&&u.searchParams.append("prompt","consent"),a&&u.searchParams.set("resource",a.href),{authorizationUrl:u,codeVerifier:d}}function A_(e,t){const r=e.client_secret!==void 0;return t.length===0?r?"client_secret_post":"none":r&&t.includes("client_secret_basic")?"client_secret_basic":r&&t.includes("client_secret_post")?"client_secret_post":t.includes("none")?"none":r?"client_secret_post":"none"}function R_(e,t,r,o){const{client_id:n,client_secret:i}=t;switch(e){case"client_secret_basic":dO(n,i,r);return;case"client_secret_post":pO(n,i,o);return;case"none":fO(n,o);return;default:throw new Error(`Unsupported client authentication method: ${e}`)}}function dO(e,t,r){if(!t)throw new Error("client_secret_basic authentication requires a client_secret");const o=btoa(`${e}:${t}`);r.set("Authorization",`Basic ${o}`)}function pO(e,t,r){r.set("client_id",e),t&&r.set("client_secret",t)}function fO(e,t){t.set("client_id",e)}async function kc(e){const t=e instanceof Response?e.status:void 0,r=e instanceof Response?await e.text():e;try{const o=YT.parse(JSON.parse(r)),{error:n,error_description:i,error_uri:a}=o,s=tO[n]||rn;return new s({message:i||"",cause:a})}catch(o){const n=`${t?`HTTP ${t}: `:""}Invalid OAuth error response: ${o}. Raw body: ${r}`;return new rn({message:n})}}async function mO(e,{metadata:t,clientInformation:r,authorizationCode:o,codeVerifier:n,redirectUri:i,resource:a,addClientAuthentication:s,fetchFn:l}){var u;const c="authorization_code",d=t?.token_endpoint?new URL(t.token_endpoint):new URL("/token",e);if(t?.grant_types_supported&&!t.grant_types_supported.includes(c))throw new Error(`Incompatible auth server: does not support grant type ${c}`);const f=new Headers({"Content-Type":"application/x-www-form-urlencoded",Accept:"application/json"}),p=new URLSearchParams({grant_type:c,code:o,code_verifier:n,redirect_uri:String(i)});if(s)s(f,p,e,t);else{const h=(u=t?.token_endpoint_auth_methods_supported)!=null?u:[],b=A_(r,h);R_(b,r,f,p)}a&&p.set("resource",a.href);const g=await(l??fetch)(d,{method:"POST",headers:f,body:p});if(!g.ok)throw await kc(g);return P_.parse(await g.json())}async function hO(e,{metadata:t,clientInformation:r,refreshToken:o,resource:n,addClientAuthentication:i,fetchFn:a}){var s;const l="refresh_token";let u;if(t){if(u=new URL(t.token_endpoint),t.grant_types_supported&&!t.grant_types_supported.includes(l))throw new Error(`Incompatible auth server: does not support grant type ${l}`)}else u=new URL("/token",e);const c=new Headers({"Content-Type":"application/x-www-form-urlencoded"}),d=new URLSearchParams({grant_type:l,refresh_token:o});if(i)i(c,d,e,t);else{const p=(s=t?.token_endpoint_auth_methods_supported)!=null?s:[],g=A_(r,p);R_(g,r,c,d)}n&&d.set("resource",n.href);const f=await(a??fetch)(u,{method:"POST",headers:c,body:d});if(!f.ok)throw await kc(f);return P_.parse({refresh_token:o,...await f.json()})}async function gO(e,{metadata:t,clientMetadata:r,fetchFn:o}){let n;if(t){if(!t.registration_endpoint)throw new Error("Incompatible auth server: does not support dynamic client registration");n=new URL(t.registration_endpoint)}else n=new URL("/register",e);const i=await(o??fetch)(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)});if(!i.ok)throw await kc(i);return QT.parse(await i.json())}async function Si(e,t){var r,o;try{return await ys(e,t)}catch(n){if(n instanceof bi||n instanceof wi)return await((r=e.invalidateCredentials)==null?void 0:r.call(e,"all")),await ys(e,t);if(n instanceof _i)return await((o=e.invalidateCredentials)==null?void 0:o.call(e,"tokens")),await ys(e,t);throw n}}async function vO(e,t,r){const o=rO(e);if(t.validateResourceURL)return await t.validateResourceURL(o,r?.resource);if(r){if(!nO({requestedResource:o,configuredResource:r.resource}))throw new Error(`Protected resource ${r.resource} does not match expected ${o} (or origin)`);return new URL(r.resource)}}async function ys(e,{serverUrl:t,authorizationCode:r,scope:o,resourceMetadataUrl:n,fetchFn:i}){let a,s;try{a=await sO(t,{resourceMetadataUrl:n},i),a.authorization_servers&&a.authorization_servers.length>0&&(s=a.authorization_servers[0])}catch{}s||(s=t);const l=await vO(t,e,a),u=await lO(s,{fetchFn:i});let c=await Promise.resolve(e.clientInformation());if(!c){if(r!==void 0)throw new Error("Existing OAuth client information is required when exchanging an authorization code");if(!e.saveClientInformation)throw new Error("OAuth client information must be saveable for dynamic registration");const h=await gO(s,{metadata:u,clientMetadata:e.clientMetadata,fetchFn:i});await e.saveClientInformation(h),c=h}if(r!==void 0){const h=await e.codeVerifier(),b=await mO(s,{metadata:u,clientInformation:c,authorizationCode:r,codeVerifier:h,redirectUri:e.redirectUrl,resource:l,addClientAuthentication:e.addClientAuthentication,fetchFn:i});return await e.saveTokens(b),"AUTHORIZED"}const d=await e.tokens();if(d?.refresh_token)try{const h=await hO(s,{metadata:u,clientInformation:c,refreshToken:d.refresh_token,resource:l,addClientAuthentication:e.addClientAuthentication,fetchFn:i});return await e.saveTokens(h),"AUTHORIZED"}catch(h){if(!(!(h instanceof Io)||h instanceof rn))throw h}const f=e.state?await e.state():void 0,{authorizationUrl:p,codeVerifier:g}=await cO(s,{metadata:u,clientInformation:c,state:f,redirectUrl:e.redirectUrl,scope:o||e.clientMetadata.scope,resource:l});return await e.saveCodeVerifier(g),await e.redirectToAuthorization(p),"REDIRECT"}var yO=class{constructor({url:e,headers:t,authProvider:r}){this.connected=!1,this.url=new URL(e),this.headers=t,this.authProvider=r}async commonHeaders(e){const t={...this.headers,...e,"mcp-protocol-version":ln};if(this.authProvider){const r=await this.authProvider.tokens();r?.access_token&&(t.Authorization=`Bearer ${r.access_token}`)}return __(t,`ai-sdk/${N_}`,b_())}async start(){return new Promise((e,t)=>{if(this.connected)return e();this.abortController=new AbortController;const r=async(o=!1)=>{var n,i,a,s,l;try{const u=await this.commonHeaders({Accept:"text/event-stream"}),c=await fetch(this.url.href,{headers:u,signal:(n=this.abortController)==null?void 0:n.signal});if(c.status===401&&this.authProvider&&!o){this.resourceMetadataUrl=$i(c);try{if(await Si(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const h=new xi;return(i=this.onerror)==null||i.call(this,h),t(h)}}catch(g){return(a=this.onerror)==null||a.call(this,g),t(g)}return r(!0)}if(!c.ok||!c.body){let g=`MCP SSE Transport Error: ${c.status} ${c.statusText}`;c.status===405&&(g+=". This server does not support SSE transport. Try using `http` transport instead");const h=new se({message:g});return(s=this.onerror)==null||s.call(this,h),t(h)}const f=c.body.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).getReader(),p=async()=>{var g,h,b;try{for(;;){const{done:y,value:x}=await f.read();if(y){if(this.connected)throw this.connected=!1,new se({message:"MCP SSE Transport Error: Connection closed unexpectedly"});return}const{event:$,data:v}=x;if($==="endpoint"){if(this.endpoint=new URL(v,this.url),this.endpoint.origin!==this.url.origin)throw new se({message:`MCP SSE Transport Error: Endpoint origin does not match connection origin: ${this.endpoint.origin}`});this.connected=!0,e()}else if($==="message")try{const k=In.parse(JSON.parse(v));(g=this.onmessage)==null||g.call(this,k)}catch(k){const N=new se({message:"MCP SSE Transport Error: Failed to parse message",cause:k});(h=this.onerror)==null||h.call(this,N)}}}catch(y){if(y instanceof Error&&y.name==="AbortError")return;(b=this.onerror)==null||b.call(this,y),t(y)}};this.sseConnection={close:()=>f.cancel()},p()}catch(u){if(u instanceof Error&&u.name==="AbortError")return;(l=this.onerror)==null||l.call(this,u),t(u)}};r()})}async close(){var e,t,r;this.connected=!1,(e=this.sseConnection)==null||e.close(),(t=this.abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this)}async send(e){if(!this.endpoint||!this.connected)throw new se({message:"MCP SSE Transport Error: Not connected"});const t=this.endpoint,r=async(o=!1)=>{var n,i,a,s,l;try{const c={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json"}),body:JSON.stringify(e),signal:(n=this.abortController)==null?void 0:n.signal},d=await fetch(t,c);if(d.status===401&&this.authProvider&&!o){this.resourceMetadataUrl=$i(d);try{if(await Si(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const p=new xi;(i=this.onerror)==null||i.call(this,p);return}}catch(f){(a=this.onerror)==null||a.call(this,f);return}return r(!0)}if(!d.ok){const f=await d.text().catch(()=>null),p=new se({message:`MCP SSE Transport Error: POSTing to endpoint (HTTP ${d.status}): ${f}`});(s=this.onerror)==null||s.call(this,p);return}}catch(u){(l=this.onerror)==null||l.call(this,u);return}};await r()}},bO=class{constructor({url:e,headers:t,authProvider:r}){this.inboundReconnectAttempts=0,this.reconnectionOptions={initialReconnectionDelay:1e3,maxReconnectionDelay:3e4,reconnectionDelayGrowFactor:1.5,maxRetries:2},this.url=new URL(e),this.headers=t,this.authProvider=r}async commonHeaders(e){const t={...this.headers,...e,"mcp-protocol-version":ln};if(this.sessionId&&(t["mcp-session-id"]=this.sessionId),this.authProvider){const r=await this.authProvider.tokens();r?.access_token&&(t.Authorization=`Bearer ${r.access_token}`)}return __(t,`ai-sdk/${N_}`,b_())}async start(){if(this.abortController)throw new se({message:"MCP HTTP Transport Error: Transport already started. Note: client.connect() calls start() automatically."});this.abortController=new AbortController,this.openInboundSse()}async close(){var e,t,r;(e=this.inboundSseConnection)==null||e.close();try{if(this.sessionId&&this.abortController&&!this.abortController.signal.aborted){const o=await this.commonHeaders({});await fetch(this.url,{method:"DELETE",headers:o,signal:this.abortController.signal}).catch(()=>{})}}catch{}(t=this.abortController)==null||t.abort(),(r=this.onclose)==null||r.call(this)}async send(e){const t=async(r=!1)=>{var o,n,i,a,s,l,u;try{const d={method:"POST",headers:await this.commonHeaders({"Content-Type":"application/json",Accept:"application/json, text/event-stream"}),body:JSON.stringify(e),signal:(o=this.abortController)==null?void 0:o.signal},f=await fetch(this.url,d),p=f.headers.get("mcp-session-id");if(p&&(this.sessionId=p),f.status===401&&this.authProvider&&!r){this.resourceMetadataUrl=$i(f);try{if(await Si(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED")throw new xi}catch(b){throw(n=this.onerror)==null||n.call(this,b),b}return t(!0)}if(f.status===202){this.inboundSseConnection||this.openInboundSse();return}if(!f.ok){const b=await f.text().catch(()=>null);let y=`MCP HTTP Transport Error: POSTing to endpoint (HTTP ${f.status}): ${b}`;f.status===404&&(y+=". This server does not support HTTP transport. Try using `sse` transport instead");const x=new se({message:y});throw(i=this.onerror)==null||i.call(this,x),x}const g=f.headers.get("content-type")||"";if(g.includes("application/json")){const b=await f.json(),y=Array.isArray(b)?b.map(x=>In.parse(x)):[In.parse(b)];for(const x of y)(a=this.onmessage)==null||a.call(this,x);return}if(g.includes("text/event-stream")){if(!f.body){const $=new se({message:"MCP HTTP Transport Error: text/event-stream response without body"});throw(s=this.onerror)==null||s.call(this,$),$}const y=f.body.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).getReader();(async()=>{var $,v,k;try{for(;;){const{done:N,value:I}=await y.read();if(N)return;const{event:O,data:M}=I;if(O==="message")try{const F=In.parse(JSON.parse(M));($=this.onmessage)==null||$.call(this,F)}catch(F){const te=new se({message:"MCP HTTP Transport Error: Failed to parse message",cause:F});(v=this.onerror)==null||v.call(this,te)}}}catch(N){if(N instanceof Error&&N.name==="AbortError")return;(k=this.onerror)==null||k.call(this,N)}})();return}const h=new se({message:`MCP HTTP Transport Error: Unexpected content type: ${g}`});throw(l=this.onerror)==null||l.call(this,h),h}catch(c){throw(u=this.onerror)==null||u.call(this,c),c}};await t()}getNextReconnectionDelay(e){const{initialReconnectionDelay:t,reconnectionDelayGrowFactor:r,maxReconnectionDelay:o}=this.reconnectionOptions;return Math.min(t*Math.pow(r,e),o)}scheduleInboundSseReconnection(){var e;const{maxRetries:t}=this.reconnectionOptions;if(t>0&&this.inboundReconnectAttempts>=t){(e=this.onerror)==null||e.call(this,new se({message:`MCP HTTP Transport Error: Maximum reconnection attempts (${t}) exceeded.`}));return}const r=this.getNextReconnectionDelay(this.inboundReconnectAttempts);this.inboundReconnectAttempts+=1,setTimeout(async()=>{var o;(o=this.abortController)!=null&&o.signal.aborted||await this.openInboundSse(!1,this.lastInboundEventId)},r)}async openInboundSse(e=!1,t){var r,o,n,i,a,s;try{const l=await this.commonHeaders({Accept:"text/event-stream"});t&&(l["last-event-id"]=t);const u=await fetch(this.url.href,{method:"GET",headers:l,signal:(r=this.abortController)==null?void 0:r.signal}),c=u.headers.get("mcp-session-id");if(c&&(this.sessionId=c),u.status===401&&this.authProvider&&!e){this.resourceMetadataUrl=$i(u);try{if(await Si(this.authProvider,{serverUrl:this.url,resourceMetadataUrl:this.resourceMetadataUrl})!=="AUTHORIZED"){const h=new xi;(o=this.onerror)==null||o.call(this,h);return}}catch(g){(n=this.onerror)==null||n.call(this,g);return}return this.openInboundSse(!0,t)}if(u.status===405)return;if(!u.ok||!u.body){const g=new se({message:`MCP HTTP Transport Error: GET SSE failed: ${u.status} ${u.statusText}`});(i=this.onerror)==null||i.call(this,g);return}const f=u.body.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).getReader(),p=async()=>{var g,h,b,y;try{for(;;){const{done:x,value:$}=await f.read();if(x)return;const{event:v,data:k,id:N}=$;if(N&&(this.lastInboundEventId=N),v==="message")try{const I=In.parse(JSON.parse(k));(g=this.onmessage)==null||g.call(this,I)}catch(I){const O=new se({message:"MCP HTTP Transport Error: Failed to parse message",cause:I});(h=this.onerror)==null||h.call(this,O)}}}catch(x){if(x instanceof Error&&x.name==="AbortError")return;(b=this.onerror)==null||b.call(this,x),(y=this.abortController)!=null&&y.signal.aborted||this.scheduleInboundSseReconnection()}};this.inboundSseConnection={close:()=>f.cancel()},this.inboundReconnectAttempts=0,p()}catch(l){if(l instanceof Error&&l.name==="AbortError")return;(a=this.onerror)==null||a.call(this,l),(s=this.abortController)!=null&&s.signal.aborted||this.scheduleInboundSseReconnection()}}};function _O(e){switch(e.type){case"sse":return new yO(e);case"http":return new bO(e);default:throw new se({message:"Unsupported or invalid transport configuration. If you are using a custom transport, make sure it implements the MCPTransport interface."})}}function wO(e){return"start"in e&&typeof e.start=="function"&&"send"in e&&typeof e.send=="function"&&"close"in e&&typeof e.close=="function"}var xO="1.0.0";async function $O(e){const t=new SO(e);return await t.init(),t}var SO=class{constructor({transport:e,name:t="ai-sdk-mcp-client",version:r=xO,onUncaughtError:o,capabilities:n}){this.requestMessageId=0,this.responseHandlers=new Map,this.serverCapabilities={},this.isClosed=!0,this.onUncaughtError=o,this.clientCapabilities=n??{},wO(e)?this.transport=e:this.transport=_O(e),this.transport.onclose=()=>this.onClose(),this.transport.onerror=i=>this.onError(i),this.transport.onmessage=i=>{if("method"in i){"id"in i?this.onRequestMessage(i):this.onError(new se({message:"Unsupported message type"}));return}this.onResponse(i)},this.clientInfo={name:t,version:r}}async init(){try{await this.transport.start(),this.isClosed=!1;const e=await this.request({request:{method:"initialize",params:{protocolVersion:ln,capabilities:this.clientCapabilities,clientInfo:this.clientInfo}},resultSchema:kT});if(e===void 0)throw new se({message:"Server sent invalid initialize result"});if(!$T.includes(e.protocolVersion))throw new se({message:`Server's protocol version is not supported: ${e.protocolVersion}`});return this.serverCapabilities=e.capabilities,await this.notification({method:"notifications/initialized"}),this}catch(e){throw await this.close(),e}}async close(){var e;this.isClosed||(await((e=this.transport)==null?void 0:e.close()),this.onClose())}assertCapability(e){switch(e){case"initialize":break;case"tools/list":case"tools/call":if(!this.serverCapabilities.tools)throw new se({message:"Server does not support tools"});break;case"resources/list":case"resources/read":case"resources/templates/list":if(!this.serverCapabilities.resources)throw new se({message:"Server does not support resources"});break;case"prompts/list":case"prompts/get":if(!this.serverCapabilities.prompts)throw new se({message:"Server does not support prompts"});break;default:throw new se({message:`Unsupported method: ${e}`})}}async request({request:e,resultSchema:t,options:r}){return new Promise((o,n)=>{if(this.isClosed)return n(new se({message:"Attempted to send a request from a closed client"}));this.assertCapability(e.method);const i=r?.signal;i?.throwIfAborted();const a=this.requestMessageId++,s={...e,jsonrpc:"2.0",id:a},l=()=>{this.responseHandlers.delete(a)};this.responseHandlers.set(a,u=>{if(i?.aborted)return n(new se({message:"Request was aborted",cause:i.reason}));if(u instanceof Error)return n(u);try{const c=t.parse(u.result);o(c)}catch(c){const d=new se({message:"Failed to parse server response",cause:c});n(d)}}),this.transport.send(s).catch(u=>{l(),n(u)})})}async listTools({params:e,options:t}={}){try{return this.request({request:{method:"tools/list",params:e},resultSchema:TT,options:t})}catch(r){throw r}}async callTool({name:e,args:t,options:r}){try{return this.request({request:{method:"tools/call",params:{name:e,arguments:t}},resultSchema:PT,options:{signal:r?.abortSignal}})}catch(o){throw o}}async listResourcesInternal({params:e,options:t}={}){try{return this.request({request:{method:"resources/list",params:e},resultSchema:NT,options:t})}catch(r){throw r}}async readResourceInternal({uri:e,options:t}){try{return this.request({request:{method:"resources/read",params:{uri:e}},resultSchema:AT,options:t})}catch(r){throw r}}async listResourceTemplatesInternal({options:e}={}){try{return this.request({request:{method:"resources/templates/list"},resultSchema:jT,options:e})}catch(t){throw t}}async listPromptsInternal({params:e,options:t}={}){try{return this.request({request:{method:"prompts/list",params:e},resultSchema:MT,options:t})}catch(r){throw r}}async getPromptInternal({name:e,args:t,options:r}){try{return this.request({request:{method:"prompts/get",params:{name:e,arguments:t}},resultSchema:UT,options:r})}catch(o){throw o}}async notification(e){const t={...e,jsonrpc:"2.0"};await this.transport.send(t)}async tools({schemas:e="automatic"}={}){var t;const r={};try{const o=await this.listTools();for(const{name:n,description:i,inputSchema:a}of o.tools){if(e!=="automatic"&&!(n in e))continue;const s=this,l=async(c,d)=>{var f;return(f=d?.abortSignal)==null||f.throwIfAborted(),s.callTool({name:n,args:c,options:d})},u=e==="automatic"?fT({description:i,inputSchema:hT({...a,properties:(t=a.properties)!=null?t:{},additionalProperties:!1}),execute:l}):{description:i,inputSchema:e[n].inputSchema,execute:l};r[n]=u}return r}catch(o){throw o}}listResources({params:e,options:t}={}){return this.listResourcesInternal({params:e,options:t})}readResource({uri:e,options:t}){return this.readResourceInternal({uri:e,options:t})}listResourceTemplates({options:e}={}){return this.listResourceTemplatesInternal({options:e})}listPrompts({params:e,options:t}={}){return this.listPromptsInternal({params:e,options:t})}getPrompt({name:e,arguments:t,options:r}){return this.getPromptInternal({name:e,args:t,options:r})}onElicitationRequest(e,t){if(e!==np)throw new se({message:"Unsupported request schema. Only ElicitationRequestSchema is supported."});this.elicitationRequestHandler=t}async onRequestMessage(e){try{if(e.method!=="elicitation/create"){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:`Unsupported request method: ${e.method}`}});return}if(!this.elicitationRequestHandler){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32601,message:"No elicitation handler registered on client"}});return}const t=np.safeParse({method:e.method,params:e.params});if(!t.success){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32602,message:`Invalid elicitation request: ${t.error.message}`,data:t.error.issues}});return}try{const r=await this.elicitationRequestHandler(t.data),o=ZT.parse(r);await this.transport.send({jsonrpc:"2.0",id:e.id,result:o})}catch(r){await this.transport.send({jsonrpc:"2.0",id:e.id,error:{code:-32603,message:r instanceof Error?r.message:"Failed to handle elicitation request"}}),this.onError(r)}}catch(t){this.onError(t)}}onClose(){if(this.isClosed)return;this.isClosed=!0;const e=new se({message:"Connection closed"});for(const t of this.responseHandlers.values())t(e);this.responseHandlers.clear()}onError(e){this.onUncaughtError&&this.onUncaughtError(e)}onResponse(e){const t=Number(e.id),r=this.responseHandlers.get(t);if(r===void 0)throw new se({message:`Protocol error: Received a response for an unknown message ID: ${JSON.stringify(e)}`});this.responseHandlers.delete(t),r("result"in e?e:new se({message:e.error.message,code:e.error.code,data:e.error.data,cause:e.error}))}},ko=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},IO={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},kO=class{#e=IO;#t=!1;setTimeoutProvider(e){process.env.NODE_ENV!=="production"&&this.#t&&e!==this.#e&&console.error("[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.",{previous:this.#e,provider:e}),this.#e=e,process.env.NODE_ENV!=="production"&&(this.#t=!1)}setTimeout(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setTimeout(e,t)}clearTimeout(e){this.#e.clearTimeout(e)}setInterval(e,t){return process.env.NODE_ENV!=="production"&&(this.#t=!0),this.#e.setInterval(e,t)}clearInterval(e){this.#e.clearInterval(e)}},hr=new kO;function EO(e){setTimeout(e,0)}var _r=typeof window>"u"||"Deno"in globalThis;function Je(){}function TO(e,t){return typeof e=="function"?e(t):e}function nu(e){return typeof e=="number"&&e>=0&&e!==1/0}function z_(e,t){return Math.max(e+(t||0)-Date.now(),0)}function rr(e,t){return typeof e=="function"?e(t):e}function at(e,t){return typeof e=="function"?e(t):e}function sp(e,t){const{type:r="all",exact:o,fetchStatus:n,predicate:i,queryKey:a,stale:s}=e;if(a){if(o){if(t.queryHash!==Ec(a,t.options))return!1}else if(!Dn(t.queryKey,a))return!1}if(r!=="all"){const l=t.isActive();if(r==="active"&&!l||r==="inactive"&&l)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||n&&n!==t.state.fetchStatus||i&&!i(t))}function up(e,t){const{exact:r,status:o,predicate:n,mutationKey:i}=e;if(i){if(!t.options.mutationKey)return!1;if(r){if(Mn(t.options.mutationKey)!==Mn(i))return!1}else if(!Dn(t.options.mutationKey,i))return!1}return!(o&&t.state.status!==o||n&&!n(t))}function Ec(e,t){return(t?.queryKeyHashFn||Mn)(e)}function Mn(e){return JSON.stringify(e,(t,r)=>au(r)?Object.keys(r).sort().reduce((o,n)=>(o[n]=r[n],o),{}):r)}function Dn(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(r=>Dn(e[r],t[r])):!1}var OO=Object.prototype.hasOwnProperty;function ou(e,t){if(e===t)return e;const r=lp(e)&&lp(t);if(!r&&!(au(e)&&au(t)))return t;const n=(r?e:Object.keys(e)).length,i=r?t:Object.keys(t),a=i.length,s=r?new Array(a):{};let l=0;for(let u=0;u<a;u++){const c=r?u:i[u],d=e[c],f=t[c];if(d===f){s[c]=d,(r?u<n:OO.call(e,c))&&l++;continue}if(d===null||f===null||typeof d!="object"||typeof f!="object"){s[c]=f;continue}const p=ou(d,f);s[c]=p,p===d&&l++}return n===a&&l===n?e:s}function iu(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const r in e)if(e[r]!==t[r])return!1;return!0}function lp(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function au(e){if(!cp(e))return!1;const t=e.constructor;if(t===void 0)return!0;const r=t.prototype;return!(!cp(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function cp(e){return Object.prototype.toString.call(e)==="[object Object]"}function NO(e){return new Promise(t=>{hr.setTimeout(t,e)})}function su(e,t,r){if(typeof r.structuralSharing=="function")return r.structuralSharing(e,t);if(r.structuralSharing!==!1){if(process.env.NODE_ENV!=="production")try{return ou(e,t)}catch(o){throw console.error(`Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${r.queryHash}]: ${o}`),o}return ou(e,t)}return t}function PO(e,t,r=0){const o=[...e,t];return r&&o.length>r?o.slice(1):o}function CO(e,t,r=0){const o=[t,...e];return r&&o.length>r?o.slice(0,-1):o}var Ii=Symbol();function M_(e,t){return process.env.NODE_ENV!=="production"&&e.queryFn===Ii&&console.error(`Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${e.queryHash}'`),!e.queryFn&&t?.initialPromise?()=>t.initialPromise:!e.queryFn||e.queryFn===Ii?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function jO(e,t){return typeof e=="function"?e(...t):!!e}var AO=class extends ko{#e;#t;#r;constructor(){super(),this.#r=e=>{if(!_r&&window.addEventListener){const t=()=>e();return window.addEventListener("visibilitychange",t,!1),()=>{window.removeEventListener("visibilitychange",t)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(t=>{typeof t=="boolean"?this.setFocused(t):this.onFocus()})}setFocused(e){this.#e!==e&&(this.#e=e,this.onFocus())}onFocus(){const e=this.isFocused();this.listeners.forEach(t=>{t(e)})}isFocused(){return typeof this.#e=="boolean"?this.#e:globalThis.document?.visibilityState!=="hidden"}},Tc=new AO;function uu(){let e,t;const r=new Promise((n,i)=>{e=n,t=i});r.status="pending",r.catch(()=>{});function o(n){Object.assign(r,n),delete r.resolve,delete r.reject}return r.resolve=n=>{o({status:"fulfilled",value:n}),e(n)},r.reject=n=>{o({status:"rejected",reason:n}),t(n)},r}var RO=EO;function zO(){let e=[],t=0,r=s=>{s()},o=s=>{s()},n=RO;const i=s=>{t?e.push(s):n(()=>{r(s)})},a=()=>{const s=e;e=[],s.length&&n(()=>{o(()=>{s.forEach(l=>{r(l)})})})};return{batch:s=>{let l;t++;try{l=s()}finally{t--,t||a()}return l},batchCalls:s=>(...l)=>{i(()=>{s(...l)})},schedule:i,setNotifyFunction:s=>{r=s},setBatchNotifyFunction:s=>{o=s},setScheduler:s=>{n=s}}}var ze=zO(),MO=class extends ko{#e=!0;#t;#r;constructor(){super(),this.#r=e=>{if(!_r&&window.addEventListener){const t=()=>e(!0),r=()=>e(!1);return window.addEventListener("online",t,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",t),window.removeEventListener("offline",r)}}}}onSubscribe(){this.#t||this.setEventListener(this.#r)}onUnsubscribe(){this.hasListeners()||(this.#t?.(),this.#t=void 0)}setEventListener(e){this.#r=e,this.#t?.(),this.#t=e(this.setOnline.bind(this))}setOnline(e){this.#e!==e&&(this.#e=e,this.listeners.forEach(r=>{r(e)}))}isOnline(){return this.#e}},ki=new MO;function DO(e){return Math.min(1e3*2**e,3e4)}function D_(e){return(e??"online")==="online"?ki.isOnline():!0}var lu=class extends Error{constructor(e){super("CancelledError"),this.revert=e?.revert,this.silent=e?.silent}};function U_(e){let t=!1,r=0,o;const n=uu(),i=()=>n.status!=="pending",a=h=>{if(!i()){const b=new lu(h);f(b),e.onCancel?.(b)}},s=()=>{t=!0},l=()=>{t=!1},u=()=>Tc.isFocused()&&(e.networkMode==="always"||ki.isOnline())&&e.canRun(),c=()=>D_(e.networkMode)&&e.canRun(),d=h=>{i()||(o?.(),n.resolve(h))},f=h=>{i()||(o?.(),n.reject(h))},p=()=>new Promise(h=>{o=b=>{(i()||u())&&h(b)},e.onPause?.()}).then(()=>{o=void 0,i()||e.onContinue?.()}),g=()=>{if(i())return;let h;const b=r===0?e.initialPromise:void 0;try{h=b??e.fn()}catch(y){h=Promise.reject(y)}Promise.resolve(h).then(d).catch(y=>{if(i())return;const x=e.retry??(_r?0:3),$=e.retryDelay??DO,v=typeof $=="function"?$(r,y):$,k=x===!0||typeof x=="number"&&r<x||typeof x=="function"&&x(r,y);if(t||!k){f(y);return}r++,e.onFail?.(r,y),NO(v).then(()=>u()?void 0:p()).then(()=>{t?f(y):g()})})};return{promise:n,status:()=>n.status,cancel:a,continue:()=>(o?.(),n),cancelRetry:s,continueRetry:l,canStart:c,start:()=>(c()?g():p().then(g),n)}}var L_=class{#e;destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),nu(this.gcTime)&&(this.#e=hr.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(_r?1/0:300*1e3))}clearGcTimeout(){this.#e&&(hr.clearTimeout(this.#e),this.#e=void 0)}},UO=class extends L_{#e;#t;#r;#o;#n;#s;#a;constructor(e){super(),this.#a=!1,this.#s=e.defaultOptions,this.setOptions(e.options),this.observers=[],this.#o=e.client,this.#r=this.#o.getQueryCache(),this.queryKey=e.queryKey,this.queryHash=e.queryHash,this.#e=pp(this.options),this.state=e.state??this.#e,this.scheduleGc()}get meta(){return this.options.meta}get promise(){return this.#n?.promise}setOptions(e){if(this.options={...this.#s,...e},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const t=pp(this.options);t.data!==void 0&&(this.setState(dp(t.data,t.dataUpdatedAt)),this.#e=t)}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&this.#r.remove(this)}setData(e,t){const r=su(this.state.data,e,this.options);return this.#i({data:r,type:"success",dataUpdatedAt:t?.updatedAt,manual:t?.manual}),r}setState(e,t){this.#i({type:"setState",state:e,setStateOptions:t})}cancel(e){const t=this.#n?.promise;return this.#n?.cancel(e),t?t.then(Je).catch(Je):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(this.#e)}isActive(){return this.observers.some(e=>at(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ii||this.state.dataUpdateCount+this.state.errorUpdateCount===0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>rr(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!z_(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(t=>t.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),this.#n?.continue()}onOnline(){this.observers.find(t=>t.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),this.#n?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(t=>t!==e),this.observers.length||(this.#n&&(this.#a?this.#n.cancel({revert:!0}):this.#n.cancelRetry()),this.scheduleGc()),this.#r.notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||this.#i({type:"invalidate"})}async fetch(e,t){if(this.state.fetchStatus!=="idle"&&this.#n?.status()!=="rejected"){if(this.state.data!==void 0&&t?.cancelRefetch)this.cancel({silent:!0});else if(this.#n)return this.#n.continueRetry(),this.#n.promise}if(e&&this.setOptions(e),!this.options.queryFn){const s=this.observers.find(l=>l.options.queryFn);s&&this.setOptions(s.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"));const r=new AbortController,o=s=>{Object.defineProperty(s,"signal",{enumerable:!0,get:()=>(this.#a=!0,r.signal)})},n=()=>{const s=M_(this.options,t),u=(()=>{const c={client:this.#o,queryKey:this.queryKey,meta:this.meta};return o(c),c})();return this.#a=!1,this.options.persister?this.options.persister(s,u,this):s(u)},a=(()=>{const s={fetchOptions:t,options:this.options,queryKey:this.queryKey,client:this.#o,state:this.state,fetchFn:n};return o(s),s})();this.options.behavior?.onFetch(a,this),this.#t=this.state,(this.state.fetchStatus==="idle"||this.state.fetchMeta!==a.fetchOptions?.meta)&&this.#i({type:"fetch",meta:a.fetchOptions?.meta}),this.#n=U_({initialPromise:t?.initialPromise,fn:a.fetchFn,onCancel:s=>{s instanceof lu&&s.revert&&this.setState({...this.#t,fetchStatus:"idle"}),r.abort()},onFail:(s,l)=>{this.#i({type:"failed",failureCount:s,error:l})},onPause:()=>{this.#i({type:"pause"})},onContinue:()=>{this.#i({type:"continue"})},retry:a.options.retry,retryDelay:a.options.retryDelay,networkMode:a.options.networkMode,canRun:()=>!0});try{const s=await this.#n.start();if(s===void 0)throw process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),new Error(`${this.queryHash} data is undefined`);return this.setData(s),this.#r.config.onSuccess?.(s,this),this.#r.config.onSettled?.(s,this.state.error,this),s}catch(s){if(s instanceof lu){if(s.silent)return this.#n.promise;if(s.revert){if(this.state.data===void 0)throw s;return this.state.data}}throw this.#i({type:"error",error:s}),this.#r.config.onError?.(s,this),this.#r.config.onSettled?.(this.state.data,s,this),s}finally{this.scheduleGc()}}#i(e){const t=r=>{switch(e.type){case"failed":return{...r,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Z_(r.data,this.options),fetchMeta:e.meta??null};case"success":const o={...r,...dp(e.data,e.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return this.#t=e.manual?o:void 0,o;case"error":const n=e.error;return{...r,error:n,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:n,fetchStatus:"idle",status:"error"};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...e.state}}};this.state=t(this.state),ze.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),this.#r.notify({query:this,type:"updated",action:e})})}};function Z_(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:D_(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function dp(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function pp(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,r=t!==void 0,o=r?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var LO=class extends ko{constructor(e,t){super(),this.options=t,this.#e=e,this.#i=null,this.#a=uu(),this.bindMethods(),this.setOptions(t)}#e;#t=void 0;#r=void 0;#o=void 0;#n;#s;#a;#i;#h;#p;#f;#l;#c;#u;#m=new Set;bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(this.#t.addObserver(this),fp(this.#t,this.options)?this.#d():this.updateResult(),this.#b())}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return cu(this.#t,this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return cu(this.#t,this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,this.#_(),this.#w(),this.#t.removeObserver(this)}setOptions(e){const t=this.options,r=this.#t;if(this.options=this.#e.defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof at(this.options.enabled,this.#t)!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");this.#x(),this.#t.setOptions(this.options),t._defaulted&&!iu(this.options,t)&&this.#e.getQueryCache().notify({type:"observerOptionsUpdated",query:this.#t,observer:this});const o=this.hasListeners();o&&mp(this.#t,r,this.options,t)&&this.#d(),this.updateResult(),o&&(this.#t!==r||at(this.options.enabled,this.#t)!==at(t.enabled,this.#t)||rr(this.options.staleTime,this.#t)!==rr(t.staleTime,this.#t))&&this.#g();const n=this.#v();o&&(this.#t!==r||at(this.options.enabled,this.#t)!==at(t.enabled,this.#t)||n!==this.#u)&&this.#y(n)}getOptimisticResult(e){const t=this.#e.getQueryCache().build(this.#e,e),r=this.createResult(t,e);return FO(this,r)&&(this.#o=r,this.#s=this.options,this.#n=this.#t.state),r}getCurrentResult(){return this.#o}trackResult(e,t){return new Proxy(e,{get:(r,o)=>(this.trackProp(o),t?.(o),o==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&this.#a.status==="pending"&&this.#a.reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,o))})}trackProp(e){this.#m.add(e)}getCurrentQuery(){return this.#t}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){const t=this.#e.defaultQueryOptions(e),r=this.#e.getQueryCache().build(this.#e,t);return r.fetch().then(()=>this.createResult(r,t))}fetch(e){return this.#d({...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),this.#o))}#d(e){this.#x();let t=this.#t.fetch(this.options,e);return e?.throwOnError||(t=t.catch(Je)),t}#g(){this.#_();const e=rr(this.options.staleTime,this.#t);if(_r||this.#o.isStale||!nu(e))return;const r=z_(this.#o.dataUpdatedAt,e)+1;this.#l=hr.setTimeout(()=>{this.#o.isStale||this.updateResult()},r)}#v(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(this.#t):this.options.refetchInterval)??!1}#y(e){this.#w(),this.#u=e,!(_r||at(this.options.enabled,this.#t)===!1||!nu(this.#u)||this.#u===0)&&(this.#c=hr.setInterval(()=>{(this.options.refetchIntervalInBackground||Tc.isFocused())&&this.#d()},this.#u))}#b(){this.#g(),this.#y(this.#v())}#_(){this.#l&&(hr.clearTimeout(this.#l),this.#l=void 0)}#w(){this.#c&&(hr.clearInterval(this.#c),this.#c=void 0)}createResult(e,t){const r=this.#t,o=this.options,n=this.#o,i=this.#n,a=this.#s,l=e!==r?e.state:this.#r,{state:u}=e;let c={...u},d=!1,f;if(t._optimisticResults){const O=this.hasListeners(),M=!O&&fp(e,t),F=O&&mp(e,r,t,o);(M||F)&&(c={...c,...Z_(u.data,e.options)}),t._optimisticResults==="isRestoring"&&(c.fetchStatus="idle")}let{error:p,errorUpdatedAt:g,status:h}=c;f=c.data;let b=!1;if(t.placeholderData!==void 0&&f===void 0&&h==="pending"){let O;n?.isPlaceholderData&&t.placeholderData===a?.placeholderData?(O=n.data,b=!0):O=typeof t.placeholderData=="function"?t.placeholderData(this.#f?.state.data,this.#f):t.placeholderData,O!==void 0&&(h="success",f=su(n?.data,O,t),d=!0)}if(t.select&&f!==void 0&&!b)if(n&&f===i?.data&&t.select===this.#h)f=this.#p;else try{this.#h=t.select,f=t.select(f),f=su(n?.data,f,t),this.#p=f,this.#i=null}catch(O){this.#i=O}this.#i&&(p=this.#i,f=this.#p,g=Date.now(),h="error");const y=c.fetchStatus==="fetching",x=h==="pending",$=h==="error",v=x&&y,k=f!==void 0,I={status:h,fetchStatus:c.fetchStatus,isPending:x,isSuccess:h==="success",isError:$,isInitialLoading:v,isLoading:v,data:f,dataUpdatedAt:c.dataUpdatedAt,error:p,errorUpdatedAt:g,failureCount:c.fetchFailureCount,failureReason:c.fetchFailureReason,errorUpdateCount:c.errorUpdateCount,isFetched:c.dataUpdateCount>0||c.errorUpdateCount>0,isFetchedAfterMount:c.dataUpdateCount>l.dataUpdateCount||c.errorUpdateCount>l.errorUpdateCount,isFetching:y,isRefetching:y&&!x,isLoadingError:$&&!k,isPaused:c.fetchStatus==="paused",isPlaceholderData:d,isRefetchError:$&&k,isStale:Oc(e,t),refetch:this.refetch,promise:this.#a,isEnabled:at(t.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){const O=te=>{I.status==="error"?te.reject(I.error):I.data!==void 0&&te.resolve(I.data)},M=()=>{const te=this.#a=I.promise=uu();O(te)},F=this.#a;switch(F.status){case"pending":e.queryHash===r.queryHash&&O(F);break;case"fulfilled":(I.status==="error"||I.data!==F.value)&&M();break;case"rejected":(I.status!=="error"||I.error!==F.reason)&&M();break}}return I}updateResult(){const e=this.#o,t=this.createResult(this.#t,this.options);if(this.#n=this.#t.state,this.#s=this.options,this.#n.data!==void 0&&(this.#f=this.#t),iu(t,e))return;this.#o=t;const r=()=>{if(!e)return!0;const{notifyOnChangeProps:o}=this.options,n=typeof o=="function"?o():o;if(n==="all"||!n&&!this.#m.size)return!0;const i=new Set(n??this.#m);return this.options.throwOnError&&i.add("error"),Object.keys(this.#o).some(a=>{const s=a;return this.#o[s]!==e[s]&&i.has(s)})};this.#$({listeners:r()})}#x(){const e=this.#e.getQueryCache().build(this.#e,this.options);if(e===this.#t)return;const t=this.#t;this.#t=e,this.#r=e.state,this.hasListeners()&&(t?.removeObserver(this),e.addObserver(this))}onQueryUpdate(){this.updateResult(),this.hasListeners()&&this.#b()}#$(e){ze.batch(()=>{e.listeners&&this.listeners.forEach(t=>{t(this.#o)}),this.#e.getQueryCache().notify({query:this.#t,type:"observerResultsUpdated"})})}};function ZO(e,t){return at(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function fp(e,t){return ZO(e,t)||e.state.data!==void 0&&cu(e,t,t.refetchOnMount)}function cu(e,t,r){if(at(t.enabled,e)!==!1&&rr(t.staleTime,e)!=="static"){const o=typeof r=="function"?r(e):r;return o==="always"||o!==!1&&Oc(e,t)}return!1}function mp(e,t,r,o){return(e!==t||at(o.enabled,e)===!1)&&(!r.suspense||e.state.status!=="error")&&Oc(e,r)}function Oc(e,t){return at(t.enabled,e)!==!1&&e.isStaleByTime(rr(t.staleTime,e))}function FO(e,t){return!iu(e.getCurrentResult(),t)}function hp(e){return{onFetch:(t,r)=>{const o=t.options,n=t.fetchOptions?.meta?.fetchMore?.direction,i=t.state.data?.pages||[],a=t.state.data?.pageParams||[];let s={pages:[],pageParams:[]},l=0;const u=async()=>{let c=!1;const d=g=>{Object.defineProperty(g,"signal",{enumerable:!0,get:()=>(t.signal.aborted?c=!0:t.signal.addEventListener("abort",()=>{c=!0}),t.signal)})},f=M_(t.options,t.fetchOptions),p=async(g,h,b)=>{if(c)return Promise.reject();if(h==null&&g.pages.length)return Promise.resolve(g);const x=(()=>{const N={client:t.client,queryKey:t.queryKey,pageParam:h,direction:b?"backward":"forward",meta:t.options.meta};return d(N),N})(),$=await f(x),{maxPages:v}=t.options,k=b?CO:PO;return{pages:k(g.pages,$,v),pageParams:k(g.pageParams,h,v)}};if(n&&i.length){const g=n==="backward",h=g?qO:gp,b={pages:i,pageParams:a},y=h(o,b);s=await p(b,y,g)}else{const g=e??i.length;do{const h=l===0?a[0]??o.initialPageParam:gp(o,s);if(l>0&&h==null)break;s=await p(s,h),l++}while(l<g)}return s};t.options.persister?t.fetchFn=()=>t.options.persister?.(u,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},r):t.fetchFn=u}}}function gp(e,{pages:t,pageParams:r}){const o=t.length-1;return t.length>0?e.getNextPageParam(t[o],t,r[o],r):void 0}function qO(e,{pages:t,pageParams:r}){return t.length>0?e.getPreviousPageParam?.(t[0],t,r[0],r):void 0}var VO=class extends L_{#e;#t;#r;#o;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#r=e.mutationCache,this.#t=[],this.state=e.state||BO(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#r.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#r.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status==="pending"?this.scheduleGc():this.#r.remove(this))}continue(){return this.#o?.continue()??this.execute(this.state.variables)}async execute(e){const t=()=>{this.#n({type:"continue"})},r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#o=U_({fn:()=>this.options.mutationFn?this.options.mutationFn(e,r):Promise.reject(new Error("No mutationFn found")),onFail:(i,a)=>{this.#n({type:"failed",failureCount:i,error:a})},onPause:()=>{this.#n({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#r.canRun(this)});const o=this.state.status==="pending",n=!this.#o.canStart();try{if(o)t();else{this.#n({type:"pending",variables:e,isPaused:n}),await this.#r.config.onMutate?.(e,this,r);const a=await this.options.onMutate?.(e,r);a!==this.state.context&&this.#n({type:"pending",context:a,variables:e,isPaused:n})}const i=await this.#o.start();return await this.#r.config.onSuccess?.(i,e,this.state.context,this,r),await this.options.onSuccess?.(i,e,this.state.context,r),await this.#r.config.onSettled?.(i,null,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(i,null,e,this.state.context,r),this.#n({type:"success",data:i}),i}catch(i){try{throw await this.#r.config.onError?.(i,e,this.state.context,this,r),await this.options.onError?.(i,e,this.state.context,r),await this.#r.config.onSettled?.(void 0,i,this.state.variables,this.state.context,this,r),await this.options.onSettled?.(void 0,i,e,this.state.context,r),i}finally{this.#n({type:"error",error:i})}}finally{this.#r.runNext(this)}}#n(e){const t=r=>{switch(e.type){case"failed":return{...r,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...r,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:e.error,failureCount:r.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=t(this.state),ze.batch(()=>{this.#t.forEach(r=>{r.onMutationUpdate(e)}),this.#r.notify({mutation:this,type:"updated",action:e})})}};function BO(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var JO=class extends ko{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#r=0}#e;#t;#r;build(e,t,r){const o=new VO({client:e,mutationCache:this,mutationId:++this.#r,options:e.defaultMutationOptions(t),state:r});return this.add(o),o}add(e){this.#e.add(e);const t=qo(e);if(typeof t=="string"){const r=this.#t.get(t);r?r.push(e):this.#t.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#e.delete(e)){const t=qo(e);if(typeof t=="string"){const r=this.#t.get(t);if(r)if(r.length>1){const o=r.indexOf(e);o!==-1&&r.splice(o,1)}else r[0]===e&&this.#t.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){const t=qo(e);if(typeof t=="string"){const o=this.#t.get(t)?.find(n=>n.state.status==="pending");return!o||o===e}else return!0}runNext(e){const t=qo(e);return typeof t=="string"?this.#t.get(t)?.find(o=>o!==e&&o.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){ze.batch(()=>{this.#e.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){const t={exact:!0,...e};return this.getAll().find(r=>up(t,r))}findAll(e={}){return this.getAll().filter(t=>up(e,t))}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){const e=this.getAll().filter(t=>t.state.isPaused);return ze.batch(()=>Promise.all(e.map(t=>t.continue().catch(Je))))}};function qo(e){return e.options.scope?.id}var WO=class extends ko{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,r){const o=t.queryKey,n=t.queryHash??Ec(o,t);let i=this.get(n);return i||(i=new UO({client:e,queryKey:o,queryHash:n,options:e.defaultQueryOptions(t),state:r,defaultOptions:e.getQueryDefaults(o)}),this.add(i)),i}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){const t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){ze.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){const t={exact:!0,...e};return this.getAll().find(r=>sp(t,r))}findAll(e={}){const t=this.getAll();return Object.keys(e).length>0?t.filter(r=>sp(e,r)):t}notify(e){ze.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){ze.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){ze.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},HO=class{#e;#t;#r;#o;#n;#s;#a;#i;constructor(e={}){this.#e=e.queryCache||new WO,this.#t=e.mutationCache||new JO,this.#r=e.defaultOptions||{},this.#o=new Map,this.#n=new Map,this.#s=0}mount(){this.#s++,this.#s===1&&(this.#a=Tc.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#i=ki.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#s--,this.#s===0&&(this.#a?.(),this.#a=void 0,this.#i?.(),this.#i=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#t.findAll({...e,status:"pending"}).length}getQueryData(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),r=this.#e.build(this,t),o=r.state.data;return o===void 0?this.fetchQuery(e):(e.revalidateIfStale&&r.isStaleByTime(rr(t.staleTime,r))&&this.prefetchQuery(t),Promise.resolve(o))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:t,state:r})=>{const o=r.data;return[t,o]})}setQueryData(e,t,r){const o=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(o.queryHash)?.state.data,a=TO(t,i);if(a!==void 0)return this.#e.build(this,o).setData(a,{...r,manual:!0})}setQueriesData(e,t,r){return ze.batch(()=>this.#e.findAll(e).map(({queryKey:o})=>[o,this.setQueryData(o,t,r)]))}getQueryState(e){const t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){const t=this.#e;ze.batch(()=>{t.findAll(e).forEach(r=>{t.remove(r)})})}resetQueries(e,t){const r=this.#e;return ze.batch(()=>(r.findAll(e).forEach(o=>{o.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const r={revert:!0,...t},o=ze.batch(()=>this.#e.findAll(e).map(n=>n.cancel(r)));return Promise.all(o).then(Je).catch(Je)}invalidateQueries(e,t={}){return ze.batch(()=>(this.#e.findAll(e).forEach(r=>{r.invalidate()}),e?.refetchType==="none"?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t)))}refetchQueries(e,t={}){const r={...t,cancelRefetch:t.cancelRefetch??!0},o=ze.batch(()=>this.#e.findAll(e).filter(n=>!n.isDisabled()&&!n.isStatic()).map(n=>{let i=n.fetch(void 0,r);return r.throwOnError||(i=i.catch(Je)),n.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(o).then(Je)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const r=this.#e.build(this,t);return r.isStaleByTime(rr(t.staleTime,r))?r.fetch(t):Promise.resolve(r.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Je).catch(Je)}fetchInfiniteQuery(e){return e.behavior=hp(e.pages),this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Je).catch(Je)}ensureInfiniteQueryData(e){return e.behavior=hp(e.pages),this.ensureQueryData(e)}resumePausedMutations(){return ki.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#r}setDefaultOptions(e){this.#r=e}setQueryDefaults(e,t){this.#o.set(Mn(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...this.#o.values()],r={};return t.forEach(o=>{Dn(e,o.queryKey)&&Object.assign(r,o.defaultOptions)}),r}setMutationDefaults(e,t){this.#n.set(Mn(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...this.#n.values()],r={};return t.forEach(o=>{Dn(e,o.mutationKey)&&Object.assign(r,o.defaultOptions)}),r}defaultQueryOptions(e){if(e._defaulted)return e;const t={...this.#r.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Ec(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===Ii&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#r.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},F_=_.createContext(void 0),q_=e=>{const t=_.useContext(F_);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},GO=({client:e,children:t})=>(_.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),m.jsx(F_.Provider,{value:e,children:t})),V_=_.createContext(!1),KO=()=>_.useContext(V_);V_.Provider;function YO(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var QO=_.createContext(YO()),XO=()=>_.useContext(QO),eN=(e,t)=>{(e.suspense||e.throwOnError||e.experimental_prefetchInRender)&&(t.isReset()||(e.retryOnMount=!1))},tN=e=>{_.useEffect(()=>{e.clearReset()},[e])},rN=({result:e,errorResetBoundary:t,throwOnError:r,query:o,suspense:n})=>e.isError&&!t.isReset()&&!e.isFetching&&o&&(n&&e.data===void 0||jO(r,[e.error,o])),nN=e=>{if(e.suspense){const r=n=>n==="static"?n:Math.max(n??1e3,1e3),o=e.staleTime;e.staleTime=typeof o=="function"?(...n)=>r(o(...n)):r(o),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},oN=(e,t)=>e.isLoading&&e.isFetching&&!t,iN=(e,t)=>e?.suspense&&t.isPending,vp=(e,t,r)=>t.fetchOptimistic(e).catch(()=>{r.clearReset()});function aN(e,t,r){if(process.env.NODE_ENV!=="production"&&(typeof e!="object"||Array.isArray(e)))throw new Error('Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object');const o=KO(),n=XO(),i=q_(),a=i.defaultQueryOptions(e);i.getDefaultOptions().queries?._experimental_beforeQuery?.(a),process.env.NODE_ENV!=="production"&&(a.queryFn||console.error(`[${a.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`)),a._optimisticResults=o?"isRestoring":"optimistic",nN(a),eN(a,n),tN(n);const s=!i.getQueryCache().get(a.queryHash),[l]=_.useState(()=>new t(i,a)),u=l.getOptimisticResult(a),c=!o&&e.subscribed!==!1;if(_.useSyncExternalStore(_.useCallback(d=>{const f=c?l.subscribe(ze.batchCalls(d)):Je;return l.updateResult(),f},[l,c]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),_.useEffect(()=>{l.setOptions(a)},[a,l]),iN(a,u))throw vp(a,l,n);if(rN({result:u,errorResetBoundary:n,throwOnError:a.throwOnError,query:i.getQueryCache().get(a.queryHash),suspense:a.suspense}))throw u.error;return i.getDefaultOptions().queries?._experimental_afterQuery?.(a,u),a.experimental_prefetchInRender&&!_r&&oN(u,o)&&(s?vp(a,l,n):i.getQueryCache().get(a.queryHash)?.promise)?.catch(Je).finally(()=>{l.updateResult()}),a.notifyOnChangeProps?u:l.trackResult(u)}function B_(e,t){return aN(e,LO)}function sN({auth:e,mcp:t,environment:r}){const o=Object.entries(e.headers??{}).map((i,a)=>`${i}:${a}`);return B_({queryKey:["mcpTools",t,...o],queryFn:async()=>(T.assert(!e.isLoading,"No auth found"),T.assert(t,"No MCP URL found"),await(await $O({name:"gram-elements-mcp-client",transport:{type:"http",url:t,headers:{...uN(r??{}),...e.headers}}})).tools()),enabled:!e.isLoading&&!!t,staleTime:1/0,gcTime:1/0})}const yp="MCP-";function uN(e){return typeof e!="object"||e===null?{}:Object.entries(e).reduce((t,[r,o])=>{const n=r.replace(/_/g,"-"),i=n.startsWith(yp)?n:`${yp}${n}`;return t[i]=o,t},{})}const J_=()=>{const e=z.useContext(T.ToolApprovalContext);if(!e)throw new Error("useToolApproval must be used within a ToolApprovalProvider");return e};function lN(e){return(e.api?.url||""||"https://app.getgram.ai").replace(/\/+$/,"")}const Nc=["anthropic/claude-sonnet-4.5","anthropic/claude-haiku-4.5","anthropic/claude-sonnet-4","anthropic/claude-opus-4.5","openai/gpt-4o","openai/gpt-4o-mini","openai/gpt-5.1-codex","openai/gpt-5","openai/gpt-5.1","openai/gpt-4.1","anthropic/claude-3.7-sonnet","anthropic/claude-opus-4","google/gemini-2.5-pro-preview","google/gemini-3-pro-preview","moonshotai/kimi-k2","mistralai/mistral-medium-3","mistralai/mistral-medium-3.1","mistralai/codestral-2501"],cN=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r.description?{description:r.description}:void 0,parameters:r.parameters instanceof vi.ZodType?vi.toJSONSchema(r.parameters):r.parameters}])),dN=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>!t.disabled&&t.type!=="backend"));let Ei=null;function pN(e,t){Ei={helpers:e,toolsRequiringApproval:new Set(t)}}function fN(){Ei=null}const mN=(e,t)=>L.makeAssistantTool({...e,execute:async(r,o)=>{if(Ei?.toolsRequiringApproval.has(t)){const{helpers:n}=Ei,i=o.toolCallId??"";if(!n.isToolApproved(t)&&!await n.requestApproval(t,i,r))return{content:[{type:"text",text:`Tool "${t}" execution was denied by the user. Please acknowledge this and continue without using this tool's result.`}],isError:!0}}return e.execute?.(r,o)},toolName:t});function hN(e,t,r){if(!t||t.length===0)return e;const o=new Set(t);return Object.fromEntries(Object.entries(e).map(([n,i])=>{if(!o.has(n))return[n,i];const a=i.execute;return a?[n,{...i,execute:async(s,l)=>{const u=l??{},c=u.toolCallId??"";return r.isToolApproved(n)||await r.requestApproval(n,c,s)?a(s,u):{content:[{type:"text",text:`Tool "${n}" execution was denied by the user. Please acknowledge this and continue without using this tool's result.`}],isError:!0}}}]:[n,i]}))}const gN=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],vN=T.createLucideIcon("arrow-down",gN);const yN=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],bN=T.createLucideIcon("arrow-up",yN);const _N=[["path",{d:"M12 18V5",key:"adv99a"}],["path",{d:"M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4",key:"1e3is1"}],["path",{d:"M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5",key:"1gqd8o"}],["path",{d:"M17.997 5.125a4 4 0 0 1 2.526 5.77",key:"iwvgf7"}],["path",{d:"M18 18a4 4 0 0 0 2-7.464",key:"efp6ie"}],["path",{d:"M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517",key:"1gq6am"}],["path",{d:"M6 18a4 4 0 0 1-2-7.464",key:"k1g0md"}],["path",{d:"M6.003 5.125a4 4 0 0 0-2.526 5.77",key:"q97ue3"}]],wN=T.createLucideIcon("brain",_N);const xN=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],nr=T.createLucideIcon("check",xN);const $N=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ti=T.createLucideIcon("chevron-down",$N);const SN=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],IN=T.createLucideIcon("chevron-left",SN);const kN=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],W_=T.createLucideIcon("chevron-right",kN);const EN=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Pc=T.createLucideIcon("copy",EN);const TN=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ON=T.createLucideIcon("file-text",TN);const NN=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],Oi=T.createLucideIcon("loader",NN);const PN=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],CN=T.createLucideIcon("maximize",PN);const jN=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}]],AN=T.createLucideIcon("message-circle",jN);const RN=[["path",{d:"M8 3v3a2 2 0 0 1-2 2H3",key:"hohbtr"}],["path",{d:"M21 8h-3a2 2 0 0 1-2-2V3",key:"5jw1f3"}],["path",{d:"M3 16h3a2 2 0 0 1 2 2v3",key:"198tvr"}],["path",{d:"M16 21v-3a2 2 0 0 1 2-2h3",key:"ph8mxp"}]],zN=T.createLucideIcon("minimize",RN);const MN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],DN=T.createLucideIcon("panel-right-close",MN);const UN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],LN=T.createLucideIcon("panel-right-open",UN);const ZN=[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],FN=T.createLucideIcon("pencil",ZN);const qN=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],VN=T.createLucideIcon("plus",qN);const BN=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],JN=T.createLucideIcon("refresh-cw",BN);const WN=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],HN=T.createLucideIcon("settings-2",WN);const GN=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],KN=T.createLucideIcon("square",GN);const YN=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Eo=T.createLucideIcon("x",YN);var To=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const n=()=>{const i=r.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=r[Math.random()*i|0];return a.join("")};if(e==null)return n;if(r.includes(o))throw new Ji({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${r}".`});return()=>`${e}${o}${n()}`},H_=To();function bp(e=globalThis){var t,r,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(r=e.process)==null?void 0:r.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function fr(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((r,o)=>{t[o.toLowerCase()]=r});else{Array.isArray(e)||(e=Object.entries(e));for(const[r,o]of e)o!=null&&(t[r.toLowerCase()]=o)}return t}function _p(e,...t){const r=new Headers(fr(e)),o=r.get("user-agent")||"";return r.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var QN=/"__proto__"\s*:/,XN=/"constructor"\s*:/;function wp(e){const t=JSON.parse(e);return t===null||typeof t!="object"||QN.test(e)===!1&&XN.test(e)===!1?t:eP(t)}function eP(e){let t=[e];for(;t.length;){const r=t;t=[];for(const o of r){if(Object.prototype.hasOwnProperty.call(o,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const n in o){const i=o[n];i&&typeof i=="object"&&t.push(i)}}}return e}function tP(e){const{stackTraceLimit:t}=Error;try{Error.stackTraceLimit=0}catch{return wp(e)}try{return wp(e)}finally{Error.stackTraceLimit=t}}var Ni=Symbol.for("vercel.ai.validator");function rP(e){return{[Ni]:!0,validate:e}}function nP(e){return typeof e=="object"&&e!==null&&Ni in e&&e[Ni]===!0&&"validate"in e}function oP(e){let t;return()=>(t==null&&(t=e()),t)}function iP(e){return nP(e)?e:typeof e=="function"?e():aP(e)}function aP(e){return rP(async t=>{const r=await e["~standard"].validate(t);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new Ft({value:t,cause:r.issues})}})}async function xp({value:e,schema:t}){const r=await Cc({value:e,schema:t});if(!r.success)throw Ft.wrap({value:e,cause:r.error});return r.value}async function Cc({value:e,schema:t}){const r=iP(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const o=await r.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:Ft.wrap({value:e,cause:o.error}),rawValue:e}}catch(o){return{success:!1,error:Ft.wrap({value:e,cause:o}),rawValue:e}}}async function Pi({text:e,schema:t}){try{const r=tP(e);return t==null?{success:!0,value:r,rawValue:r}:await Cc({value:r,schema:t})}catch(r){return{success:!1,error:Jr.isInstance(r)?r:new Jr({text:e,cause:r}),rawValue:void 0}}}function sP({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).pipeThrough(new TransformStream({async transform({data:r},o){r!=="[DONE]"&&o.enqueue(await Pi({text:r,schema:t}))}}))}async function Ar(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}function ri(e){if(e.type==="object"){e.additionalProperties=!1;const t=e.properties;if(t!=null)for(const r in t)t[r]=ri(t[r])}return e.type==="array"&&e.items!=null&&(Array.isArray(e.items)?e.items=e.items.map(t=>ri(t)):e.items=ri(e.items)),e}var uP=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")},lP=Symbol("Let zodToJsonSchema decide on which parser to use"),$p={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"},cP=e=>typeof e=="string"?{...$p,name:e}:{...$p,...e};function et(){return{}}function dP(e,t){var r,o,n;const i={type:"array"};return(r=e.type)!=null&&r._def&&((n=(o=e.type)==null?void 0:o._def)==null?void 0:n.typeName)!==A.ZodAny&&(i.items=le(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i}function pP(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function fP(){return{type:"boolean"}}function G_(e,t){return le(e.type._def,t)}var mP=(e,t)=>le(e.innerType._def,t);function K_(e,t,r){const o=r??t.dateStrategy;if(Array.isArray(o))return{anyOf:o.map((n,i)=>K_(e,t,n))};switch(o){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return hP(e)}}var hP=e=>{const t={type:"integer",format:"unix-time"};for(const r of e.checks)switch(r.kind){case"min":t.minimum=r.value;break;case"max":t.maximum=r.value;break}return t};function gP(e,t){return{...le(e.innerType._def,t),default:e.defaultValue()}}function vP(e,t){return t.effectStrategy==="input"?le(e.schema._def,t):et()}function yP(e){return{type:"string",enum:Array.from(e.values)}}var bP=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function _P(e,t){const r=[le(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),le(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(n=>!!n),o=[];return r.forEach(n=>{if(bP(n))o.push(...n.allOf);else{let i=n;if("additionalProperties"in n&&n.additionalProperties===!1){const{additionalProperties:a,...s}=n;i=s}o.push(i)}}),o.length?{allOf:o}:void 0}function wP(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var bs=void 0,ht={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:()=>(bs===void 0&&(bs=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),bs),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 Y_(e,t){const r={type:"string"};if(e.checks)for(const o of e.checks)switch(o.kind){case"min":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value;break;case"max":r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"email":switch(t.emailStrategy){case"format:email":gt(r,"email",o.message,t);break;case"format:idn-email":gt(r,"idn-email",o.message,t);break;case"pattern:zod":Fe(r,ht.email,o.message,t);break}break;case"url":gt(r,"uri",o.message,t);break;case"uuid":gt(r,"uuid",o.message,t);break;case"regex":Fe(r,o.regex,o.message,t);break;case"cuid":Fe(r,ht.cuid,o.message,t);break;case"cuid2":Fe(r,ht.cuid2,o.message,t);break;case"startsWith":Fe(r,RegExp(`^${_s(o.value,t)}`),o.message,t);break;case"endsWith":Fe(r,RegExp(`${_s(o.value,t)}$`),o.message,t);break;case"datetime":gt(r,"date-time",o.message,t);break;case"date":gt(r,"date",o.message,t);break;case"time":gt(r,"time",o.message,t);break;case"duration":gt(r,"duration",o.message,t);break;case"length":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value,r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"includes":{Fe(r,RegExp(_s(o.value,t)),o.message,t);break}case"ip":{o.version!=="v6"&>(r,"ipv4",o.message,t),o.version!=="v4"&>(r,"ipv6",o.message,t);break}case"base64url":Fe(r,ht.base64url,o.message,t);break;case"jwt":Fe(r,ht.jwt,o.message,t);break;case"cidr":{o.version!=="v6"&&Fe(r,ht.ipv4Cidr,o.message,t),o.version!=="v4"&&Fe(r,ht.ipv6Cidr,o.message,t);break}case"emoji":Fe(r,ht.emoji(),o.message,t);break;case"ulid":{Fe(r,ht.ulid,o.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{gt(r,"binary",o.message,t);break}case"contentEncoding:base64":{r.contentEncoding="base64";break}case"pattern:zod":{Fe(r,ht.base64,o.message,t);break}}break}case"nanoid":Fe(r,ht.nanoid,o.message,t)}return r}function _s(e,t){return t.patternStrategy==="escape"?$P(e):e}var xP=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function $P(e){let t="";for(let r=0;r<e.length;r++)xP.has(e[r])||(t+="\\"),t+=e[r];return t}function gt(e,t,r,o){var n;e.format||(n=e.anyOf)!=null&&n.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...r&&o.errorMessages&&{errorMessage:{format:r}}})):e.format=t}function Fe(e,t,r,o){var n;e.pattern||(n=e.allOf)!=null&&n.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Sp(t,o),...r&&o.errorMessages&&{errorMessage:{pattern:r}}})):e.pattern=Sp(t,o)}function Sp(e,t){var r;if(!t.applyRegexFlags||!e.flags)return e.source;const o={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=o.i?e.source.toLowerCase():e.source;let i="",a=!1,s=!1,l=!1;for(let u=0;u<n.length;u++){if(a){i+=n[u],a=!1;continue}if(o.i){if(s){if(n[u].match(/[a-z]/)){l?(i+=n[u],i+=`${n[u-2]}-${n[u]}`.toUpperCase(),l=!1):n[u+1]==="-"&&((r=n[u+2])!=null&&r.match(/[a-z]/))?(i+=n[u],l=!0):i+=`${n[u]}${n[u].toUpperCase()}`;continue}}else if(n[u].match(/[a-z]/)){i+=`[${n[u]}${n[u].toUpperCase()}]`;continue}}if(o.m){if(n[u]==="^"){i+=`(^|(?<=[\r
|
|
30
30
|
]))`;continue}else if(n[u]==="$"){i+=`($|(?=[\r
|
|
31
31
|
]))`;continue}}if(o.s&&n[u]==="."){i+=s?`${n[u]}\r
|
|
32
32
|
`:`[${n[u]}\r
|
|
33
|
-
]`;continue}i+=n[u],n[u]==="\\"?a=!0:s&&n[u]==="]"?s=!1:!s&&n[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Q_(e,t){var r,o,n,i,a,s;const l={type:"object",additionalProperties:(r=le(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?r:t.allowedAdditionalProperties};if(((o=e.keyType)==null?void 0:o._def.typeName)===A.ZodString&&((n=e.keyType._def.checks)!=null&&n.length)){const{type:u,...c}=Y_(e.keyType._def,t);return{...l,propertyNames:c}}else{if(((i=e.keyType)==null?void 0:i._def.typeName)===A.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===A.ZodBranded&&e.keyType._def.type._def.typeName===A.ZodString&&((s=e.keyType._def.type._def.checks)!=null&&s.length)){const{type:u,...c}=G_(e.keyType._def,t);return{...l,propertyNames:c}}}return l}function $P(e,t){if(t.mapStrategy==="record")return Q_(e,t);const r=le(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||et(),o=le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||et();return{type:"array",maxItems:125,items:{type:"array",items:[r,o],minItems:2,maxItems:2}}}function SP(e){const t=e.values,o=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(o.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:o}}function IP(){return{not:et()}}function kP(){return{type:"null"}}var du={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function EP(e,t){const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(o=>o._def.typeName in du&&(!o._def.checks||!o._def.checks.length))){const o=r.reduce((n,i)=>{const a=du[i._def.typeName];return a&&!n.includes(a)?[...n,a]:n},[]);return{type:o.length>1?o:o[0]}}else if(r.every(o=>o._def.typeName==="ZodLiteral"&&!o.description)){const o=r.reduce((n,i)=>{const a=typeof i._def.value;switch(a){case"string":case"number":case"boolean":return[...n,a];case"bigint":return[...n,"integer"];case"object":if(i._def.value===null)return[...n,"null"];case"symbol":case"undefined":case"function":default:return n}},[]);if(o.length===r.length){const n=o.filter((i,a,s)=>s.indexOf(i)===a);return{type:n.length>1?n:n[0],enum:r.reduce((i,a)=>i.includes(a._def.value)?i:[...i,a._def.value],[])}}}else if(r.every(o=>o._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((o,n)=>[...o,...n._def.values.filter(i=>!o.includes(i))],[])};return TP(e,t)}var TP=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((o,n)=>le(o._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(o=>!!o&&(!t.strictUnions||typeof o=="object"&&Object.keys(o).length>0));return r.length?{anyOf:r}:void 0};function OP(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[du[e.innerType._def.typeName],"null"]};const r=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function NP(e){const t={type:"number"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"int":t.type="integer";break;case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function PP(e,t){const r={type:"object",properties:{}},o=[],n=e.shape();for(const a in n){let s=n[a];if(s===void 0||s._def===void 0)continue;const l=jP(s),u=le(s._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});u!==void 0&&(r.properties[a]=u,l||o.push(a))}o.length&&(r.required=o);const i=CP(e,t);return i!==void 0&&(r.additionalProperties=i),r}function CP(e,t){if(e.catchall._def.typeName!=="ZodNever")return le(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function jP(e){try{return e.isOptional()}catch{return!0}}var AP=(e,t)=>{var r;if(t.currentPath.toString()===((r=t.propertyPath)==null?void 0:r.toString()))return le(e.innerType._def,t);const o=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return o?{anyOf:[{not:et()},o]}:et()},RP=(e,t)=>{if(t.pipeStrategy==="input")return le(e.in._def,t);if(t.pipeStrategy==="output")return le(e.out._def,t);const r=le(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),o=le(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,o].filter(n=>n!==void 0)}};function zP(e,t){return le(e.type._def,t)}function MP(e,t){const o={type:"array",uniqueItems:!0,items:le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(o.minItems=e.minSize.value),e.maxSize&&(o.maxItems=e.maxSize.value),o}function DP(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,o)=>le(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,o],[]),additionalItems:le(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,o)=>le(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,o],[])}}function UP(){return{not:et()}}function LP(){return et()}var ZP=(e,t)=>le(e.innerType._def,t),FP=(e,t,r)=>{switch(t){case A.ZodString:return Y_(e,r);case A.ZodNumber:return NP(e);case A.ZodObject:return PP(e,r);case A.ZodBigInt:return dP(e);case A.ZodBoolean:return pP();case A.ZodDate:return K_(e,r);case A.ZodUndefined:return UP();case A.ZodNull:return kP();case A.ZodArray:return cP(e,r);case A.ZodUnion:case A.ZodDiscriminatedUnion:return EP(e,r);case A.ZodIntersection:return bP(e,r);case A.ZodTuple:return DP(e,r);case A.ZodRecord:return Q_(e,r);case A.ZodLiteral:return _P(e);case A.ZodEnum:return vP(e);case A.ZodNativeEnum:return SP(e);case A.ZodNullable:return OP(e,r);case A.ZodOptional:return AP(e,r);case A.ZodMap:return $P(e,r);case A.ZodSet:return MP(e,r);case A.ZodLazy:return()=>e.getter()._def;case A.ZodPromise:return zP(e,r);case A.ZodNaN:case A.ZodNever:return IP();case A.ZodEffects:return gP(e,r);case A.ZodAny:return et();case A.ZodUnknown:return LP();case A.ZodDefault:return hP(e,r);case A.ZodBranded:return G_(e,r);case A.ZodReadonly:return ZP(e,r);case A.ZodCatch:return fP(e,r);case A.ZodPipeline:return RP(e,r);case A.ZodFunction:case A.ZodVoid:case A.ZodSymbol:return;default:return(o=>{})()}};function le(e,t,r=!1){var o;const n=t.seen.get(e);if(t.override){const l=(o=t.override)==null?void 0:o.call(t,e,t,n,r);if(l!==uP)return l}if(n&&!r){const l=qP(n,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const a=FP(e,e.typeName,t),s=typeof a=="function"?le(a(),t):a;if(s&&VP(e,t,s),t.postProcess){const l=t.postProcess(s,e,t);return i.jsonSchema=s,l}return i.jsonSchema=s,s}var qP=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:sP(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,o)=>t.currentPath[o]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),et()):t.$refStrategy==="seen"?et():void 0}},VP=(e,t,r)=>(e.description&&(r.description=e.description),r),BP=e=>{const t=lP(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([o,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,o],jsonSchema:void 0}]))}},JP=(e,t)=>{var r;const o=BP(t);let n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,d])=>{var f;return{...u,[c]:(f=le(d._def,{...o,currentPath:[...o.basePath,o.definitionPath,c]},!0))!=null?f:et()}},{}):void 0;const i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=(r=le(e._def,i===void 0?o:{...o,currentPath:[...o.basePath,o.definitionPath,i]},!1))!=null?r:et(),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(a.title=s);const l=i===void 0?n?{...a,[o.definitionPath]:n}:a:{$ref:[...o.$refStrategy==="relative"?[]:o.basePath,o.definitionPath,i].join("/"),[o.definitionPath]:{...n,[i]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},WP=JP;function HP(e,t){var r;const o=(r=void 0)!=null?r:!1;return qa(()=>WP(e,{$refStrategy:o?"root":"none"}),{validate:async n=>{const i=await e.safeParseAsync(n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function GP(e,t){var r;const o=(r=void 0)!=null?r:!1;return qa(()=>ti(pa(e,{target:"draft-7",io:"input",reused:o?"ref":"inline"})),{validate:async n=>{const i=await fa(e,n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function KP(e){return"_zod"in e}function X_(e,t){return KP(e)?GP(e):HP(e)}var pu=Symbol.for("vercel.ai.schema");function qa(e,{validate:t}={}){return{[pu]:!0,_type:void 0,[Oi]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function YP(e){return typeof e=="object"&&e!==null&&pu in e&&e[pu]===!0&&"jsonSchema"in e&&"validate"in e}function QP(e){return e==null?qa({properties:{},additionalProperties:!1}):YP(e)?e:typeof e=="function"?e():X_(e)}function XP(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var eC=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},gr="1.9.0",Ip=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function tC(e){var t=new Set([e]),r=new Set,o=e.match(Ip);if(!o)return function(){return!1};var n={major:+o[1],minor:+o[2],patch:+o[3],prerelease:o[4]};if(n.prerelease!=null)return function(l){return l===e};function i(s){return r.add(s),!1}function a(s){return t.add(s),!0}return function(l){if(t.has(l))return!0;if(r.has(l))return!1;var u=l.match(Ip);if(!u)return i(l);var c={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return c.prerelease!=null||n.major!==c.major?i(l):n.major===0?n.minor===c.minor&&n.patch<=c.patch?a(l):i(l):n.minor<=c.minor?a(l):i(l)}}var rC=tC(gr),nC=gr.split(".")[0],Un=Symbol.for("opentelemetry.js.api."+nC),Ln=eC;function jc(e,t,r,o){var n;o===void 0&&(o=!1);var i=Ln[Un]=(n=Ln[Un])!==null&&n!==void 0?n:{version:gr};if(!o&&i[e]){var a=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return r.error(a.stack||a.message),!1}if(i.version!==gr){var a=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+e+" does not match previously registered API v"+gr);return r.error(a.stack||a.message),!1}return i[e]=t,r.debug("@opentelemetry/api: Registered a global for "+e+" v"+gr+"."),!0}function Zn(e){var t,r,o=(t=Ln[Un])===null||t===void 0?void 0:t.version;if(!(!o||!rC(o)))return(r=Ln[Un])===null||r===void 0?void 0:r[e]}function Ac(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+gr+".");var r=Ln[Un];r&&delete r[e]}var oC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},iC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},aC=(function(){function e(t){this._namespace=t.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("debug",this._namespace,t)},e.prototype.error=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("error",this._namespace,t)},e.prototype.info=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("info",this._namespace,t)},e.prototype.warn=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("warn",this._namespace,t)},e.prototype.verbose=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("verbose",this._namespace,t)},e})();function _n(e,t,r){var o=Zn("diag");if(o)return r.unshift(t),o[e].apply(o,iC([],oC(r),!1))}var Ke;(function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"})(Ke||(Ke={}));function sC(e,t){e<Ke.NONE?e=Ke.NONE:e>Ke.ALL&&(e=Ke.ALL),t=t||{};function r(o,n){var i=t[o];return typeof i=="function"&&e>=n?i.bind(t):function(){}}return{error:r("error",Ke.ERROR),warn:r("warn",Ke.WARN),info:r("info",Ke.INFO),debug:r("debug",Ke.DEBUG),verbose:r("verbose",Ke.VERBOSE)}}var uC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},lC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},cC="diag",Pi=(function(){function e(){function t(n){return function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];var s=Zn("diag");if(s)return s[n].apply(s,lC([],uC(i),!1))}}var r=this,o=function(n,i){var a,s,l;if(i===void 0&&(i={logLevel:Ke.INFO}),n===r){var u=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((a=u.stack)!==null&&a!==void 0?a:u.message),!1}typeof i=="number"&&(i={logLevel:i});var c=Zn("diag"),d=sC((s=i.logLevel)!==null&&s!==void 0?s:Ke.INFO,n);if(c&&!i.suppressOverrideMessage){var f=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";c.warn("Current logger will be overwritten from "+f),d.warn("Current logger will overwrite one already registered from "+f)}return jc("diag",d,r,!0)};r.setLogger=o,r.disable=function(){Ac(cC,r)},r.createComponentLogger=function(n){return new aC(n)},r.verbose=t("verbose"),r.debug=t("debug"),r.info=t("info"),r.warn=t("warn"),r.error=t("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e})();function dC(e){return Symbol.for(e)}var pC=(function(){function e(t){var r=this;r._currentContext=t?new Map(t):new Map,r.getValue=function(o){return r._currentContext.get(o)},r.setValue=function(o,n){var i=new e(r._currentContext);return i._currentContext.set(o,n),i},r.deleteValue=function(o){var n=new e(r._currentContext);return n._currentContext.delete(o),n}}return e})(),fC=new pC,mC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},hC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},gC=(function(){function e(){}return e.prototype.active=function(){return fC},e.prototype.with=function(t,r,o){for(var n=[],i=3;i<arguments.length;i++)n[i-3]=arguments[i];return r.call.apply(r,hC([o],mC(n),!1))},e.prototype.bind=function(t,r){return r},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e})(),vC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},yC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},_s="context",bC=new gC,ew=(function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(t){return jc(_s,t,Pi.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(t,r,o){for(var n,i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return(n=this._getContextManager()).with.apply(n,yC([t,r,o],vC(i),!1))},e.prototype.bind=function(t,r){return this._getContextManager().bind(t,r)},e.prototype._getContextManager=function(){return Zn(_s)||bC},e.prototype.disable=function(){this._getContextManager().disable(),Ac(_s,Pi.instance())},e})(),fu;(function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"})(fu||(fu={}));var tw="0000000000000000",rw="00000000000000000000000000000000",_C={traceId:rw,spanId:tw,traceFlags:fu.NONE},On=(function(){function e(t){t===void 0&&(t=_C),this._spanContext=t}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(t,r){return this},e.prototype.setAttributes=function(t){return this},e.prototype.addEvent=function(t,r){return this},e.prototype.addLink=function(t){return this},e.prototype.addLinks=function(t){return this},e.prototype.setStatus=function(t){return this},e.prototype.updateName=function(t){return this},e.prototype.end=function(t){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(t,r){},e})(),Rc=dC("OpenTelemetry Context Key SPAN");function zc(e){return e.getValue(Rc)||void 0}function wC(){return zc(ew.getInstance().active())}function Mc(e,t){return e.setValue(Rc,t)}function xC(e){return e.deleteValue(Rc)}function $C(e,t){return Mc(e,new On(t))}function nw(e){var t;return(t=zc(e))===null||t===void 0?void 0:t.spanContext()}var SC=/^([0-9a-f]{32})$/i,IC=/^[0-9a-f]{16}$/i;function kC(e){return SC.test(e)&&e!==rw}function EC(e){return IC.test(e)&&e!==tw}function ow(e){return kC(e.traceId)&&EC(e.spanId)}function TC(e){return new On(e)}var ws=ew.getInstance(),iw=(function(){function e(){}return e.prototype.startSpan=function(t,r,o){o===void 0&&(o=ws.active());var n=!!r?.root;if(n)return new On;var i=o&&nw(o);return OC(i)&&ow(i)?new On(i):new On},e.prototype.startActiveSpan=function(t,r,o,n){var i,a,s;if(!(arguments.length<2)){arguments.length===2?s=r:arguments.length===3?(i=r,s=o):(i=r,a=o,s=n);var l=a??ws.active(),u=this.startSpan(t,i,l),c=Mc(l,u);return ws.with(c,s,void 0,u)}},e})();function OC(e){return typeof e=="object"&&typeof e.spanId=="string"&&typeof e.traceId=="string"&&typeof e.traceFlags=="number"}var NC=new iw,PC=(function(){function e(t,r,o,n){this._provider=t,this.name=r,this.version=o,this.options=n}return e.prototype.startSpan=function(t,r,o){return this._getTracer().startSpan(t,r,o)},e.prototype.startActiveSpan=function(t,r,o,n){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):NC},e})(),CC=(function(){function e(){}return e.prototype.getTracer=function(t,r,o){return new iw},e})(),jC=new CC,kp=(function(){function e(){}return e.prototype.getTracer=function(t,r,o){var n;return(n=this.getDelegateTracer(t,r,o))!==null&&n!==void 0?n:new PC(this,t,r,o)},e.prototype.getDelegate=function(){var t;return(t=this._delegate)!==null&&t!==void 0?t:jC},e.prototype.setDelegate=function(t){this._delegate=t},e.prototype.getDelegateTracer=function(t,r,o){var n;return(n=this._delegate)===null||n===void 0?void 0:n.getTracer(t,r,o)},e})(),Ci;(function(e){e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR"})(Ci||(Ci={}));var xs="trace",AC=(function(){function e(){this._proxyTracerProvider=new kp,this.wrapSpanContext=TC,this.isSpanContextValid=ow,this.deleteSpan=xC,this.getSpan=zc,this.getActiveSpan=wC,this.getSpanContext=nw,this.setSpan=Mc,this.setSpanContext=$C}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(t){var r=jc(xs,this._proxyTracerProvider,Pi.instance());return r&&this._proxyTracerProvider.setDelegate(t),r},e.prototype.getTracerProvider=function(){return Zn(xs)||this._proxyTracerProvider},e.prototype.getTracer=function(t,r){return this.getTracerProvider().getTracer(t,r)},e.prototype.disable=function(){Ac(xs,Pi.instance()),this._proxyTracerProvider=new kp},e})(),RC=AC.getInstance(),zC=Object.defineProperty,MC=(e,t)=>{for(var r in t)zC(e,r,{get:t[r],enumerable:!0})},aw="AI_NoObjectGeneratedError",sw=`vercel.ai.error.${aw}`,DC=Symbol.for(sw),uw,Ep=class extends Y{constructor({message:t="No object generated.",cause:r,text:o,response:n,usage:i,finishReason:a}){super({name:aw,message:t,cause:r}),this[uw]=!0,this.text=o,this.response=n,this.usage=i,this.finishReason=a}static isInstance(t){return Y.hasMarker(t,sw)}};uw=DC;var Tp="5.0.116",lw=G([w(),Rt(Uint8Array),Rt(ArrayBuffer),So(e=>{var t,r;return(r=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?r:!1},{message:"Must be a Buffer"})]),Fn=xo(()=>G([yo(),w(),q(),pe(),Xe(w(),Fn),R(Fn)])),ke=Xe(w(),Xe(w(),Fn)),cw=E({type:C("text"),text:w(),providerOptions:ke.optional()}),UC=E({type:C("image"),image:G([lw,Rt(URL)]),mediaType:w().optional(),providerOptions:ke.optional()}),dw=E({type:C("file"),data:G([lw,Rt(URL)]),filename:w().optional(),mediaType:w(),providerOptions:ke.optional()}),LC=E({type:C("reasoning"),text:w(),providerOptions:ke.optional()}),ZC=E({type:C("tool-call"),toolCallId:w(),toolName:w(),input:$e(),providerOptions:ke.optional(),providerExecuted:pe().optional()}),FC=Ra("type",[E({type:C("text"),value:w()}),E({type:C("json"),value:Fn}),E({type:C("error-text"),value:w()}),E({type:C("error-json"),value:Fn}),E({type:C("content"),value:R(G([E({type:C("text"),text:w()}),E({type:C("media"),data:w(),mediaType:w()})]))})]),pw=E({type:C("tool-result"),toolCallId:w(),toolName:w(),output:FC,providerOptions:ke.optional()}),qC=E({role:C("system"),content:w(),providerOptions:ke.optional()}),VC=E({role:C("user"),content:G([w(),R(G([cw,UC,dw]))]),providerOptions:ke.optional()}),BC=E({role:C("assistant"),content:G([w(),R(G([cw,dw,LC,ZC,pw]))]),providerOptions:ke.optional()}),JC=E({role:C("tool"),content:R(pw),providerOptions:ke.optional()});G([qC,VC,BC,JC]);To({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
33
|
+
]`;continue}i+=n[u],n[u]==="\\"?a=!0:s&&n[u]==="]"?s=!1:!s&&n[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function Q_(e,t){var r,o,n,i,a,s;const l={type:"object",additionalProperties:(r=le(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?r:t.allowedAdditionalProperties};if(((o=e.keyType)==null?void 0:o._def.typeName)===A.ZodString&&((n=e.keyType._def.checks)!=null&&n.length)){const{type:u,...c}=Y_(e.keyType._def,t);return{...l,propertyNames:c}}else{if(((i=e.keyType)==null?void 0:i._def.typeName)===A.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===A.ZodBranded&&e.keyType._def.type._def.typeName===A.ZodString&&((s=e.keyType._def.type._def.checks)!=null&&s.length)){const{type:u,...c}=G_(e.keyType._def,t);return{...l,propertyNames:c}}}return l}function SP(e,t){if(t.mapStrategy==="record")return Q_(e,t);const r=le(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||et(),o=le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||et();return{type:"array",maxItems:125,items:{type:"array",items:[r,o],minItems:2,maxItems:2}}}function IP(e){const t=e.values,o=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(o.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:o}}function kP(){return{not:et()}}function EP(){return{type:"null"}}var du={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function TP(e,t){const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(o=>o._def.typeName in du&&(!o._def.checks||!o._def.checks.length))){const o=r.reduce((n,i)=>{const a=du[i._def.typeName];return a&&!n.includes(a)?[...n,a]:n},[]);return{type:o.length>1?o:o[0]}}else if(r.every(o=>o._def.typeName==="ZodLiteral"&&!o.description)){const o=r.reduce((n,i)=>{const a=typeof i._def.value;switch(a){case"string":case"number":case"boolean":return[...n,a];case"bigint":return[...n,"integer"];case"object":if(i._def.value===null)return[...n,"null"];case"symbol":case"undefined":case"function":default:return n}},[]);if(o.length===r.length){const n=o.filter((i,a,s)=>s.indexOf(i)===a);return{type:n.length>1?n:n[0],enum:r.reduce((i,a)=>i.includes(a._def.value)?i:[...i,a._def.value],[])}}}else if(r.every(o=>o._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((o,n)=>[...o,...n._def.values.filter(i=>!o.includes(i))],[])};return OP(e,t)}var OP=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((o,n)=>le(o._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(o=>!!o&&(!t.strictUnions||typeof o=="object"&&Object.keys(o).length>0));return r.length?{anyOf:r}:void 0};function NP(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[du[e.innerType._def.typeName],"null"]};const r=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function PP(e){const t={type:"number"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"int":t.type="integer";break;case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function CP(e,t){const r={type:"object",properties:{}},o=[],n=e.shape();for(const a in n){let s=n[a];if(s===void 0||s._def===void 0)continue;const l=AP(s),u=le(s._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});u!==void 0&&(r.properties[a]=u,l||o.push(a))}o.length&&(r.required=o);const i=jP(e,t);return i!==void 0&&(r.additionalProperties=i),r}function jP(e,t){if(e.catchall._def.typeName!=="ZodNever")return le(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function AP(e){try{return e.isOptional()}catch{return!0}}var RP=(e,t)=>{var r;if(t.currentPath.toString()===((r=t.propertyPath)==null?void 0:r.toString()))return le(e.innerType._def,t);const o=le(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return o?{anyOf:[{not:et()},o]}:et()},zP=(e,t)=>{if(t.pipeStrategy==="input")return le(e.in._def,t);if(t.pipeStrategy==="output")return le(e.out._def,t);const r=le(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),o=le(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,o].filter(n=>n!==void 0)}};function MP(e,t){return le(e.type._def,t)}function DP(e,t){const o={type:"array",uniqueItems:!0,items:le(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(o.minItems=e.minSize.value),e.maxSize&&(o.maxItems=e.maxSize.value),o}function UP(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,o)=>le(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,o],[]),additionalItems:le(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,o)=>le(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,o],[])}}function LP(){return{not:et()}}function ZP(){return et()}var FP=(e,t)=>le(e.innerType._def,t),qP=(e,t,r)=>{switch(t){case A.ZodString:return Y_(e,r);case A.ZodNumber:return PP(e);case A.ZodObject:return CP(e,r);case A.ZodBigInt:return pP(e);case A.ZodBoolean:return fP();case A.ZodDate:return K_(e,r);case A.ZodUndefined:return LP();case A.ZodNull:return EP();case A.ZodArray:return dP(e,r);case A.ZodUnion:case A.ZodDiscriminatedUnion:return TP(e,r);case A.ZodIntersection:return _P(e,r);case A.ZodTuple:return UP(e,r);case A.ZodRecord:return Q_(e,r);case A.ZodLiteral:return wP(e);case A.ZodEnum:return yP(e);case A.ZodNativeEnum:return IP(e);case A.ZodNullable:return NP(e,r);case A.ZodOptional:return RP(e,r);case A.ZodMap:return SP(e,r);case A.ZodSet:return DP(e,r);case A.ZodLazy:return()=>e.getter()._def;case A.ZodPromise:return MP(e,r);case A.ZodNaN:case A.ZodNever:return kP();case A.ZodEffects:return vP(e,r);case A.ZodAny:return et();case A.ZodUnknown:return ZP();case A.ZodDefault:return gP(e,r);case A.ZodBranded:return G_(e,r);case A.ZodReadonly:return FP(e,r);case A.ZodCatch:return mP(e,r);case A.ZodPipeline:return zP(e,r);case A.ZodFunction:case A.ZodVoid:case A.ZodSymbol:return;default:return(o=>{})()}};function le(e,t,r=!1){var o;const n=t.seen.get(e);if(t.override){const l=(o=t.override)==null?void 0:o.call(t,e,t,n,r);if(l!==lP)return l}if(n&&!r){const l=VP(n,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const a=qP(e,e.typeName,t),s=typeof a=="function"?le(a(),t):a;if(s&&BP(e,t,s),t.postProcess){const l=t.postProcess(s,e,t);return i.jsonSchema=s,l}return i.jsonSchema=s,s}var VP=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:uP(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,o)=>t.currentPath[o]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),et()):t.$refStrategy==="seen"?et():void 0}},BP=(e,t,r)=>(e.description&&(r.description=e.description),r),JP=e=>{const t=cP(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([o,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,o],jsonSchema:void 0}]))}},WP=(e,t)=>{var r;const o=JP(t);let n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,d])=>{var f;return{...u,[c]:(f=le(d._def,{...o,currentPath:[...o.basePath,o.definitionPath,c]},!0))!=null?f:et()}},{}):void 0;const i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=(r=le(e._def,i===void 0?o:{...o,currentPath:[...o.basePath,o.definitionPath,i]},!1))!=null?r:et(),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(a.title=s);const l=i===void 0?n?{...a,[o.definitionPath]:n}:a:{$ref:[...o.$refStrategy==="relative"?[]:o.basePath,o.definitionPath,i].join("/"),[o.definitionPath]:{...n,[i]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},HP=WP;function GP(e,t){var r;const o=(r=void 0)!=null?r:!1;return Va(()=>HP(e,{$refStrategy:o?"root":"none"}),{validate:async n=>{const i=await e.safeParseAsync(n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function KP(e,t){var r;const o=(r=void 0)!=null?r:!1;return Va(()=>ri(fa(e,{target:"draft-7",io:"input",reused:o?"ref":"inline"})),{validate:async n=>{const i=await ma(e,n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function YP(e){return"_zod"in e}function X_(e,t){return YP(e)?KP(e):GP(e)}var pu=Symbol.for("vercel.ai.schema");function Va(e,{validate:t}={}){return{[pu]:!0,_type:void 0,[Ni]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function QP(e){return typeof e=="object"&&e!==null&&pu in e&&e[pu]===!0&&"jsonSchema"in e&&"validate"in e}function XP(e){return e==null?Va({properties:{},additionalProperties:!1}):QP(e)?e:typeof e=="function"?e():X_(e)}function eC(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var tC=typeof globalThis=="object"?globalThis:typeof self=="object"?self:typeof window=="object"?window:typeof global=="object"?global:{},gr="1.9.0",Ip=/^(\d+)\.(\d+)\.(\d+)(-(.+))?$/;function rC(e){var t=new Set([e]),r=new Set,o=e.match(Ip);if(!o)return function(){return!1};var n={major:+o[1],minor:+o[2],patch:+o[3],prerelease:o[4]};if(n.prerelease!=null)return function(l){return l===e};function i(s){return r.add(s),!1}function a(s){return t.add(s),!0}return function(l){if(t.has(l))return!0;if(r.has(l))return!1;var u=l.match(Ip);if(!u)return i(l);var c={major:+u[1],minor:+u[2],patch:+u[3],prerelease:u[4]};return c.prerelease!=null||n.major!==c.major?i(l):n.major===0?n.minor===c.minor&&n.patch<=c.patch?a(l):i(l):n.minor<=c.minor?a(l):i(l)}}var nC=rC(gr),oC=gr.split(".")[0],Un=Symbol.for("opentelemetry.js.api."+oC),Ln=tC;function jc(e,t,r,o){var n;o===void 0&&(o=!1);var i=Ln[Un]=(n=Ln[Un])!==null&&n!==void 0?n:{version:gr};if(!o&&i[e]){var a=new Error("@opentelemetry/api: Attempted duplicate registration of API: "+e);return r.error(a.stack||a.message),!1}if(i.version!==gr){var a=new Error("@opentelemetry/api: Registration of version v"+i.version+" for "+e+" does not match previously registered API v"+gr);return r.error(a.stack||a.message),!1}return i[e]=t,r.debug("@opentelemetry/api: Registered a global for "+e+" v"+gr+"."),!0}function Zn(e){var t,r,o=(t=Ln[Un])===null||t===void 0?void 0:t.version;if(!(!o||!nC(o)))return(r=Ln[Un])===null||r===void 0?void 0:r[e]}function Ac(e,t){t.debug("@opentelemetry/api: Unregistering a global for "+e+" v"+gr+".");var r=Ln[Un];r&&delete r[e]}var iC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},aC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},sC=(function(){function e(t){this._namespace=t.namespace||"DiagComponentLogger"}return e.prototype.debug=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("debug",this._namespace,t)},e.prototype.error=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("error",this._namespace,t)},e.prototype.info=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("info",this._namespace,t)},e.prototype.warn=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("warn",this._namespace,t)},e.prototype.verbose=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return _n("verbose",this._namespace,t)},e})();function _n(e,t,r){var o=Zn("diag");if(o)return r.unshift(t),o[e].apply(o,aC([],iC(r),!1))}var Ke;(function(e){e[e.NONE=0]="NONE",e[e.ERROR=30]="ERROR",e[e.WARN=50]="WARN",e[e.INFO=60]="INFO",e[e.DEBUG=70]="DEBUG",e[e.VERBOSE=80]="VERBOSE",e[e.ALL=9999]="ALL"})(Ke||(Ke={}));function uC(e,t){e<Ke.NONE?e=Ke.NONE:e>Ke.ALL&&(e=Ke.ALL),t=t||{};function r(o,n){var i=t[o];return typeof i=="function"&&e>=n?i.bind(t):function(){}}return{error:r("error",Ke.ERROR),warn:r("warn",Ke.WARN),info:r("info",Ke.INFO),debug:r("debug",Ke.DEBUG),verbose:r("verbose",Ke.VERBOSE)}}var lC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},cC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},dC="diag",Ci=(function(){function e(){function t(n){return function(){for(var i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];var s=Zn("diag");if(s)return s[n].apply(s,cC([],lC(i),!1))}}var r=this,o=function(n,i){var a,s,l;if(i===void 0&&(i={logLevel:Ke.INFO}),n===r){var u=new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");return r.error((a=u.stack)!==null&&a!==void 0?a:u.message),!1}typeof i=="number"&&(i={logLevel:i});var c=Zn("diag"),d=uC((s=i.logLevel)!==null&&s!==void 0?s:Ke.INFO,n);if(c&&!i.suppressOverrideMessage){var f=(l=new Error().stack)!==null&&l!==void 0?l:"<failed to generate stacktrace>";c.warn("Current logger will be overwritten from "+f),d.warn("Current logger will overwrite one already registered from "+f)}return jc("diag",d,r,!0)};r.setLogger=o,r.disable=function(){Ac(dC,r)},r.createComponentLogger=function(n){return new sC(n)},r.verbose=t("verbose"),r.debug=t("debug"),r.info=t("info"),r.warn=t("warn"),r.error=t("error")}return e.instance=function(){return this._instance||(this._instance=new e),this._instance},e})();function pC(e){return Symbol.for(e)}var fC=(function(){function e(t){var r=this;r._currentContext=t?new Map(t):new Map,r.getValue=function(o){return r._currentContext.get(o)},r.setValue=function(o,n){var i=new e(r._currentContext);return i._currentContext.set(o,n),i},r.deleteValue=function(o){var n=new e(r._currentContext);return n._currentContext.delete(o),n}}return e})(),mC=new fC,hC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},gC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},vC=(function(){function e(){}return e.prototype.active=function(){return mC},e.prototype.with=function(t,r,o){for(var n=[],i=3;i<arguments.length;i++)n[i-3]=arguments[i];return r.call.apply(r,gC([o],hC(n),!1))},e.prototype.bind=function(t,r){return r},e.prototype.enable=function(){return this},e.prototype.disable=function(){return this},e})(),yC=function(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var o=r.call(e),n,i=[],a;try{for(;(t===void 0||t-- >0)&&!(n=o.next()).done;)i.push(n.value)}catch(s){a={error:s}}finally{try{n&&!n.done&&(r=o.return)&&r.call(o)}finally{if(a)throw a.error}}return i},bC=function(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))},ws="context",_C=new vC,ew=(function(){function e(){}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalContextManager=function(t){return jc(ws,t,Ci.instance())},e.prototype.active=function(){return this._getContextManager().active()},e.prototype.with=function(t,r,o){for(var n,i=[],a=3;a<arguments.length;a++)i[a-3]=arguments[a];return(n=this._getContextManager()).with.apply(n,bC([t,r,o],yC(i),!1))},e.prototype.bind=function(t,r){return this._getContextManager().bind(t,r)},e.prototype._getContextManager=function(){return Zn(ws)||_C},e.prototype.disable=function(){this._getContextManager().disable(),Ac(ws,Ci.instance())},e})(),fu;(function(e){e[e.NONE=0]="NONE",e[e.SAMPLED=1]="SAMPLED"})(fu||(fu={}));var tw="0000000000000000",rw="00000000000000000000000000000000",wC={traceId:rw,spanId:tw,traceFlags:fu.NONE},On=(function(){function e(t){t===void 0&&(t=wC),this._spanContext=t}return e.prototype.spanContext=function(){return this._spanContext},e.prototype.setAttribute=function(t,r){return this},e.prototype.setAttributes=function(t){return this},e.prototype.addEvent=function(t,r){return this},e.prototype.addLink=function(t){return this},e.prototype.addLinks=function(t){return this},e.prototype.setStatus=function(t){return this},e.prototype.updateName=function(t){return this},e.prototype.end=function(t){},e.prototype.isRecording=function(){return!1},e.prototype.recordException=function(t,r){},e})(),Rc=pC("OpenTelemetry Context Key SPAN");function zc(e){return e.getValue(Rc)||void 0}function xC(){return zc(ew.getInstance().active())}function Mc(e,t){return e.setValue(Rc,t)}function $C(e){return e.deleteValue(Rc)}function SC(e,t){return Mc(e,new On(t))}function nw(e){var t;return(t=zc(e))===null||t===void 0?void 0:t.spanContext()}var IC=/^([0-9a-f]{32})$/i,kC=/^[0-9a-f]{16}$/i;function EC(e){return IC.test(e)&&e!==rw}function TC(e){return kC.test(e)&&e!==tw}function ow(e){return EC(e.traceId)&&TC(e.spanId)}function OC(e){return new On(e)}var xs=ew.getInstance(),iw=(function(){function e(){}return e.prototype.startSpan=function(t,r,o){o===void 0&&(o=xs.active());var n=!!r?.root;if(n)return new On;var i=o&&nw(o);return NC(i)&&ow(i)?new On(i):new On},e.prototype.startActiveSpan=function(t,r,o,n){var i,a,s;if(!(arguments.length<2)){arguments.length===2?s=r:arguments.length===3?(i=r,s=o):(i=r,a=o,s=n);var l=a??xs.active(),u=this.startSpan(t,i,l),c=Mc(l,u);return xs.with(c,s,void 0,u)}},e})();function NC(e){return typeof e=="object"&&typeof e.spanId=="string"&&typeof e.traceId=="string"&&typeof e.traceFlags=="number"}var PC=new iw,CC=(function(){function e(t,r,o,n){this._provider=t,this.name=r,this.version=o,this.options=n}return e.prototype.startSpan=function(t,r,o){return this._getTracer().startSpan(t,r,o)},e.prototype.startActiveSpan=function(t,r,o,n){var i=this._getTracer();return Reflect.apply(i.startActiveSpan,i,arguments)},e.prototype._getTracer=function(){if(this._delegate)return this._delegate;var t=this._provider.getDelegateTracer(this.name,this.version,this.options);return t?(this._delegate=t,this._delegate):PC},e})(),jC=(function(){function e(){}return e.prototype.getTracer=function(t,r,o){return new iw},e})(),AC=new jC,kp=(function(){function e(){}return e.prototype.getTracer=function(t,r,o){var n;return(n=this.getDelegateTracer(t,r,o))!==null&&n!==void 0?n:new CC(this,t,r,o)},e.prototype.getDelegate=function(){var t;return(t=this._delegate)!==null&&t!==void 0?t:AC},e.prototype.setDelegate=function(t){this._delegate=t},e.prototype.getDelegateTracer=function(t,r,o){var n;return(n=this._delegate)===null||n===void 0?void 0:n.getTracer(t,r,o)},e})(),ji;(function(e){e[e.UNSET=0]="UNSET",e[e.OK=1]="OK",e[e.ERROR=2]="ERROR"})(ji||(ji={}));var $s="trace",RC=(function(){function e(){this._proxyTracerProvider=new kp,this.wrapSpanContext=OC,this.isSpanContextValid=ow,this.deleteSpan=$C,this.getSpan=zc,this.getActiveSpan=xC,this.getSpanContext=nw,this.setSpan=Mc,this.setSpanContext=SC}return e.getInstance=function(){return this._instance||(this._instance=new e),this._instance},e.prototype.setGlobalTracerProvider=function(t){var r=jc($s,this._proxyTracerProvider,Ci.instance());return r&&this._proxyTracerProvider.setDelegate(t),r},e.prototype.getTracerProvider=function(){return Zn($s)||this._proxyTracerProvider},e.prototype.getTracer=function(t,r){return this.getTracerProvider().getTracer(t,r)},e.prototype.disable=function(){Ac($s,Ci.instance()),this._proxyTracerProvider=new kp},e})(),zC=RC.getInstance(),MC=Object.defineProperty,DC=(e,t)=>{for(var r in t)MC(e,r,{get:t[r],enumerable:!0})},aw="AI_NoObjectGeneratedError",sw=`vercel.ai.error.${aw}`,UC=Symbol.for(sw),uw,Ep=class extends Y{constructor({message:t="No object generated.",cause:r,text:o,response:n,usage:i,finishReason:a}){super({name:aw,message:t,cause:r}),this[uw]=!0,this.text=o,this.response=n,this.usage=i,this.finishReason=a}static isInstance(t){return Y.hasMarker(t,sw)}};uw=UC;var Tp="5.0.116",lw=G([w(),Rt(Uint8Array),Rt(ArrayBuffer),So(e=>{var t,r;return(r=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?r:!1},{message:"Must be a Buffer"})]),Fn=xo(()=>G([yo(),w(),q(),pe(),Xe(w(),Fn),R(Fn)])),ke=Xe(w(),Xe(w(),Fn)),cw=E({type:C("text"),text:w(),providerOptions:ke.optional()}),LC=E({type:C("image"),image:G([lw,Rt(URL)]),mediaType:w().optional(),providerOptions:ke.optional()}),dw=E({type:C("file"),data:G([lw,Rt(URL)]),filename:w().optional(),mediaType:w(),providerOptions:ke.optional()}),ZC=E({type:C("reasoning"),text:w(),providerOptions:ke.optional()}),FC=E({type:C("tool-call"),toolCallId:w(),toolName:w(),input:$e(),providerOptions:ke.optional(),providerExecuted:pe().optional()}),qC=za("type",[E({type:C("text"),value:w()}),E({type:C("json"),value:Fn}),E({type:C("error-text"),value:w()}),E({type:C("error-json"),value:Fn}),E({type:C("content"),value:R(G([E({type:C("text"),text:w()}),E({type:C("media"),data:w(),mediaType:w()})]))})]),pw=E({type:C("tool-result"),toolCallId:w(),toolName:w(),output:qC,providerOptions:ke.optional()}),VC=E({role:C("system"),content:w(),providerOptions:ke.optional()}),BC=E({role:C("user"),content:G([w(),R(G([cw,LC,dw]))]),providerOptions:ke.optional()}),JC=E({role:C("assistant"),content:G([w(),R(G([cw,dw,ZC,FC,pw]))]),providerOptions:ke.optional()}),WC=E({role:C("tool"),content:R(pw),providerOptions:ke.optional()});G([VC,BC,JC,WC]);To({prefix:"aitxt",size:24});(class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
34
34
|
|
|
35
35
|
`)},flush(e){e.enqueue(`data: [DONE]
|
|
36
36
|
|
|
37
|
-
`)}})}});var WC=nP(()=>X_(G([be({type:C("text-start"),id:w(),providerMetadata:ke.optional()}),be({type:C("text-delta"),id:w(),delta:w(),providerMetadata:ke.optional()}),be({type:C("text-end"),id:w(),providerMetadata:ke.optional()}),be({type:C("error"),errorText:w()}),be({type:C("tool-input-start"),toolCallId:w(),toolName:w(),providerExecuted:pe().optional(),dynamic:pe().optional()}),be({type:C("tool-input-delta"),toolCallId:w(),inputTextDelta:w()}),be({type:C("tool-input-available"),toolCallId:w(),toolName:w(),input:$e(),providerExecuted:pe().optional(),providerMetadata:ke.optional(),dynamic:pe().optional()}),be({type:C("tool-input-error"),toolCallId:w(),toolName:w(),input:$e(),providerExecuted:pe().optional(),providerMetadata:ke.optional(),dynamic:pe().optional(),errorText:w()}),be({type:C("tool-output-available"),toolCallId:w(),output:$e(),providerExecuted:pe().optional(),dynamic:pe().optional(),preliminary:pe().optional()}),be({type:C("tool-output-error"),toolCallId:w(),errorText:w(),providerExecuted:pe().optional(),dynamic:pe().optional()}),be({type:C("reasoning-start"),id:w(),providerMetadata:ke.optional()}),be({type:C("reasoning-delta"),id:w(),delta:w(),providerMetadata:ke.optional()}),be({type:C("reasoning-end"),id:w(),providerMetadata:ke.optional()}),be({type:C("source-url"),sourceId:w(),url:w(),title:w().optional(),providerMetadata:ke.optional()}),be({type:C("source-document"),sourceId:w(),mediaType:w(),title:w(),filename:w().optional(),providerMetadata:ke.optional()}),be({type:C("file"),url:w(),mediaType:w(),providerMetadata:ke.optional()}),be({type:So(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:w().optional(),data:$e(),transient:pe().optional()}),be({type:C("start-step")}),be({type:C("finish-step")}),be({type:C("start"),messageId:w().optional(),messageMetadata:$e().optional()}),be({type:C("finish"),finishReason:dr(["stop","length","content-filter","tool-calls","error","other","unknown"]).optional(),messageMetadata:$e().optional()}),be({type:C("abort")}),be({type:C("message-metadata"),messageMetadata:$e()})])));function HC(e){return e.type.startsWith("data-")}function fw(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const r={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const n=t[o];if(n===void 0)continue;const i=o in e?e[o]:void 0,a=n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?r[o]=fw(i,n):r[o]=n}return r}function GC(e){const t=["ROOT"];let r=-1,o=null;function n(l,u,c){switch(l){case'"':{r=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{r=u,o=u,t.pop(),t.push(c),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{r=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{r=u,t.pop(),t.push(c),t.push("INSIDE_ARRAY_START");break}}}function i(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":n(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{r=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{n(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),r=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:r=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{r=l,t.pop();break}default:{r=l,n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=l,t.pop();break}default:{r=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),r=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(o,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(u,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l)):r=l;break}}}let s=e.slice(0,r+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{s+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{s+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{s+="]";break}case"INSIDE_LITERAL":{const c=e.substring(o,e.length);"true".startsWith(c)?s+="true".slice(c.length):"false".startsWith(c)?s+="false".slice(c.length):"null".startsWith(c)&&(s+="null".slice(c.length))}}return s}async function mw(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Ni({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Ni({text:GC(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function Zr(e){return e.type.startsWith("tool-")}function KC(e){return e.type==="dynamic-tool"}function Op(e){return Zr(e)||KC(e)}function Np(e){return e.type.split("-").slice(1).join("-")}function YC({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function QC({stream:e,messageMetadataSchema:t,dataPartSchemas:r,runUpdateMessageJob:o,onError:n,onToolCall:i,onData:a}){return e.pipeThrough(new TransformStream({async transform(s,l){await o(async({state:u,write:c})=>{var d,f,p,g;function h(v){const N=u.message.parts.filter(Zr).find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function b(v){const N=u.message.parts.filter(I=>I.type==="dynamic-tool").find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function y(v){var k;const N=u.message.parts.find(z=>Zr(z)&&z.toolCallId===v.toolCallId),I=v,O=N;N!=null?(N.state=v.state,O.input=I.input,O.output=I.output,O.errorText=I.errorText,O.rawInput=I.rawInput,O.preliminary=I.preliminary,O.providerExecuted=(k=I.providerExecuted)!=null?k:N.providerExecuted,I.providerMetadata!=null&&N.state==="input-available"&&(N.callProviderMetadata=I.providerMetadata)):u.message.parts.push({type:`tool-${v.toolName}`,toolCallId:v.toolCallId,state:v.state,input:I.input,output:I.output,rawInput:I.rawInput,errorText:I.errorText,providerExecuted:I.providerExecuted,preliminary:I.preliminary,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}function x(v){var k,N;const I=u.message.parts.find(F=>F.type==="dynamic-tool"&&F.toolCallId===v.toolCallId),O=v,z=I;I!=null?(I.state=v.state,z.toolName=v.toolName,z.input=O.input,z.output=O.output,z.errorText=O.errorText,z.rawInput=(k=O.rawInput)!=null?k:z.rawInput,z.preliminary=O.preliminary,z.providerExecuted=(N=O.providerExecuted)!=null?N:I.providerExecuted,O.providerMetadata!=null&&I.state==="input-available"&&(I.callProviderMetadata=O.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:v.toolName,toolCallId:v.toolCallId,state:v.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,...O.providerMetadata!=null?{callProviderMetadata:O.providerMetadata}:{}})}async function $(v){if(v!=null){const k=u.message.metadata!=null?fw(u.message.metadata,v):v;t!=null&&await xp({value:k,schema:t}),u.message.metadata=k}}switch(s.type){case"text-start":{const v={type:"text",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeTextParts[s.id]=v,u.message.parts.push(v),c();break}case"text-delta":{const v=u.activeTextParts[s.id];v.text+=s.delta,v.providerMetadata=(d=s.providerMetadata)!=null?d:v.providerMetadata,c();break}case"text-end":{const v=u.activeTextParts[s.id];v.state="done",v.providerMetadata=(f=s.providerMetadata)!=null?f:v.providerMetadata,delete u.activeTextParts[s.id],c();break}case"reasoning-start":{const v={type:"reasoning",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeReasoningParts[s.id]=v,u.message.parts.push(v),c();break}case"reasoning-delta":{const v=u.activeReasoningParts[s.id];v.text+=s.delta,v.providerMetadata=(p=s.providerMetadata)!=null?p:v.providerMetadata,c();break}case"reasoning-end":{const v=u.activeReasoningParts[s.id];v.providerMetadata=(g=s.providerMetadata)!=null?g:v.providerMetadata,v.state="done",delete u.activeReasoningParts[s.id],c();break}case"file":{u.message.parts.push({type:"file",mediaType:s.mediaType,url:s.url}),c();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:s.sourceId,url:s.url,title:s.title,providerMetadata:s.providerMetadata}),c();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:s.sourceId,mediaType:s.mediaType,title:s.title,filename:s.filename,providerMetadata:s.providerMetadata}),c();break}case"tool-input-start":{const v=u.message.parts.filter(Zr);u.partialToolCalls[s.toolCallId]={text:"",toolName:s.toolName,index:v.length,dynamic:s.dynamic},s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}),c();break}case"tool-input-delta":{const v=u.partialToolCalls[s.toolCallId];v.text+=s.inputTextDelta;const{value:k}=await mw(v.text);v.dynamic?x({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}):y({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}),c();break}case"tool-input-available":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c(),i&&!s.providerExecuted&&await i({toolCall:s});break}case"tool-input-error":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:void 0,rawInput:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c();break}case"tool-output-available":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-available",input:v.input,output:s.output,preliminary:s.preliminary})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Np(v),state:"output-available",input:v.input,output:s.output,providerExecuted:s.providerExecuted,preliminary:s.preliminary})}c();break}case"tool-output-error":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-error",input:v.input,errorText:s.errorText,providerExecuted:s.providerExecuted})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Np(v),state:"output-error",input:v.input,rawInput:v.rawInput,errorText:s.errorText,providerExecuted:s.providerExecuted})}c();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{s.messageId!=null&&(u.message.id=s.messageId),await $(s.messageMetadata),(s.messageId!=null||s.messageMetadata!=null)&&c();break}case"finish":{s.finishReason!=null&&(u.finishReason=s.finishReason),await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"message-metadata":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"error":{n?.(new Error(s.errorText));break}default:if(HC(s)){r?.[s.type]!=null&&await xp({value:s.data,schema:r[s.type]});const v=s;if(v.transient){a?.(v);break}const k=v.id!=null?u.message.parts.find(N=>v.type===N.type&&v.id===N.id):void 0;k!=null?k.data=v.data:u.message.parts.push(v),a?.(v),c()}}l.enqueue(s)})}}))}async function XC({stream:e,onError:t}){const r=e.getReader();try{for(;;){const{done:o}=await r.read();if(o)break}}catch(o){t?.(o)}finally{r.releaseLock()}}To({prefix:"aitxt",size:24});To({prefix:"aiobj",size:24});var ej=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,r)=>{this.queue.push(async()=>{try{await e(),t()}catch(o){r(o)}}),this.processQueue()})}};To({prefix:"aiobj",size:24});var tj={};MC(tj,{object:()=>nj,text:()=>rj});var rj=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),nj=({schema:e})=>{const t=QP(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:r}){const o=await mw(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const n=o.state;throw new Error(`Unsupported parse state: ${n}`)}}},async parseOutput({text:r},o){const n=await Ni({text:r});if(!n.success)throw new Ep({message:"No object generated: could not parse the response.",cause:n.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await Cc({value:n.value,schema:t});if(!i.success)throw new Ep({message:"No object generated: response did not match schema.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}};async function oj(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:r,type:o}=t,n=await new Promise((i,a)=>{const s=new FileReader;s.onload=l=>{var u;i((u=l.target)==null?void 0:u.result)},s.onerror=l=>a(l),s.readAsDataURL(t)});return{type:"file",mediaType:o,filename:r,url:n}}))}var ij=class{constructor({api:e="/api/chat",credentials:t,headers:r,body:o,fetch:n,prepareSendMessagesRequest:i,prepareReconnectToStreamRequest:a}){this.api=e,this.credentials=t,this.headers=r,this.body=o,this.fetch=n,this.prepareSendMessagesRequest=i,this.prepareReconnectToStreamRequest=a}async sendMessages({abortSignal:e,...t}){var r,o,n,i,a;const s=await Ar(this.body),l=await Ar(this.headers),u=await Ar(this.credentials),c={...fr(l),...fr(t.headers)},d=await((r=this.prepareSendMessagesRequest)==null?void 0:r.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...s,...t.body},headers:c,credentials:u,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),f=(o=d?.api)!=null?o:this.api,p=d?.headers!==void 0?fr(d.headers):c,g=d?.body!==void 0?d.body:{...s,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},h=(n=d?.credentials)!=null?n:u,y=await((i=this.fetch)!=null?i:globalThis.fetch)(f,{method:"POST",headers:_p({"Content-Type":"application/json",...p},`ai-sdk/${Tp}`,bp()),body:JSON.stringify(g),credentials:h,signal:e});if(!y.ok)throw new Error((a=await y.text())!=null?a:"Failed to fetch the chat response.");if(!y.body)throw new Error("The response body is empty.");return this.processResponseStream(y.body)}async reconnectToStream(e){var t,r,o,n,i;const a=await Ar(this.body),s=await Ar(this.headers),l=await Ar(this.credentials),u={...fr(s),...fr(e.headers)},c=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...a,...e.body},headers:u,credentials:l,requestMetadata:e.metadata})),d=(r=c?.api)!=null?r:`${this.api}/${e.chatId}/stream`,f=c?.headers!==void 0?fr(c.headers):u,p=(o=c?.credentials)!=null?o:l,h=await((n=this.fetch)!=null?n:globalThis.fetch)(d,{method:"GET",headers:_p(f,`ai-sdk/${Tp}`,bp()),credentials:p});if(h.status===204)return null;if(!h.ok)throw new Error((i=await h.text())!=null?i:"Failed to fetch the chat response.");if(!h.body)throw new Error("The response body is empty.");return this.processResponseStream(h.body)}},hw=class extends ij{constructor(e={}){super(e)}processResponseStream(e){return aP({stream:e,schema:WC}).pipeThrough(new TransformStream({async transform(t,r){if(!t.success)throw t.error;r.enqueue(t.value)}}))}},aj=class{constructor({generateId:e=H_,id:t=e(),transport:r=new hw,messageMetadataSchema:o,dataPartSchemas:n,state:i,onError:a,onToolCall:s,onFinish:l,onData:u,sendAutomaticallyWhen:c}){this.activeResponse=void 0,this.jobExecutor=new ej,this.sendMessage=async(d,f)=>{var p,g,h,b;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(p=this.lastMessage)==null?void 0:p.id,...f});return}let y;if("text"in d||"files"in d?y={parts:[...Array.isArray(d.files)?d.files:await oj(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:y=d,d.messageId!=null){const x=this.state.messages.findIndex($=>$.id===d.messageId);if(x===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[x].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,x+1),this.state.replaceMessage(x,{...y,id:d.messageId,role:(g=y.role)!=null?g:"user",metadata:d.metadata})}else this.state.pushMessage({...y,id:(h=y.id)!=null?h:this.generateId(),role:(b=y.role)!=null?b:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...f})},this.regenerate=async({messageId:d,...f}={})=>{const p=d==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===d);if(p===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[p].role==="assistant"?p:p+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...f})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolOutput=async({state:d="output-available",tool:f,toolCallId:p,output:g,errorText:h})=>this.jobExecutor.run(async()=>{var b,y;const x=this.state.messages,$=x[x.length-1];this.state.replaceMessage(x.length-1,{...$,parts:$.parts.map(v=>Op(v)&&v.toolCallId===p?{...v,state:d,output:g,errorText:h}:v)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(v=>Op(v)&&v.toolCallId===p?{...v,state:d,output:g,errorText:h}:v)),this.status!=="streaming"&&this.status!=="submitted"&&((b=this.sendAutomaticallyWhen)!=null&&b.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(y=this.lastMessage)==null?void 0:y.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=r,this.generateId=e,this.messageMetadataSchema=o,this.dataPartSchemas=n,this.state=i,this.onError=a,this.onToolCall=s,this.onFinish=l,this.onData=u,this.sendAutomaticallyWhen=c}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async makeRequest({trigger:e,metadata:t,headers:r,body:o,messageId:n}){var i,a,s,l;this.setStatus({status:"submitted",error:void 0});const u=this.lastMessage;let c=!1,d=!1,f=!1;try{const p={state:YC({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};p.abortController.signal.addEventListener("abort",()=>{c=!0}),this.activeResponse=p;let g;if(e==="resume-stream"){const b=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:r,body:o});if(b==null){this.setStatus({status:"ready"});return}g=b}else g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:p.abortController.signal,metadata:t,headers:r,body:o,trigger:e,messageId:n});const h=b=>this.jobExecutor.run(()=>b({state:p.state,write:()=>{var y;this.setStatus({status:"streaming"}),p.state.message.id===((y=this.lastMessage)==null?void 0:y.id)?this.state.replaceMessage(this.state.messages.length-1,p.state.message):this.state.pushMessage(p.state.message)}}));await XC({stream:QC({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:h,onError:b=>{throw b}}),onError:b=>{throw b}}),this.setStatus({status:"ready"})}catch(p){if(c||p.name==="AbortError")return c=!0,this.setStatus({status:"ready"}),null;f=!0,p instanceof TypeError&&(p.message.toLowerCase().includes("fetch")||p.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:c,isDisconnect:d,isError:f,finishReason:(i=this.activeResponse)==null?void 0:i.state.finishReason})}catch(p){console.error(p)}this.activeResponse=void 0}(s=this.sendAutomaticallyWhen)!=null&&s.call(this,{messages:this.state.messages})&&!f&&await this.makeRequest({trigger:"submit-message",messageId:(l=this.lastMessage)==null?void 0:l.id,metadata:t,headers:r,body:o})}};const Pp=(e,t)=>{if(t==null)return[];let r=e.findIndex(o=>o.id===t);if(r===-1)throw new Error("useVercelAIThreadState: Message not found. This is likely an internal bug in assistant-ui.");for(;e[r+1]?.role==="assistant";)r++;return e.slice(0,r+1)},Cp=e=>{const r=[...e.content.filter(o=>o.type!=="file"),...e.attachments?.flatMap(o=>o.content.map(n=>({...n,filename:o.name})))??[]].map(o=>{switch(o.type){case"text":return{type:"text",text:o.text};case"image":return{type:"file",url:o.image,...o.filename&&{filename:o.filename},mediaType:"image/png"};case"file":return{type:"file",url:o.data,mediaType:o.mimeType,...o.filename&&{filename:o.filename}};default:throw new Error(`Unsupported part type: ${o.type}`)}});return{role:e.role,parts:r}},sj=e=>new Promise((t,r)=>{const o=new FileReader;o.onload=()=>t(o.result),o.onerror=n=>r(n),o.readAsDataURL(e)}),uj={accept:"image/*, text/plain, text/html, text/markdown, text/csv, text/xml, text/json, text/css",async add({file:e}){return{id:H_(),type:e.type.startsWith("image/")?"image":"file",name:e.name,file:e,contentType:e.type,content:[],status:{type:"requires-action",reason:"composer-send"}}},async send(e){return{...e,status:{type:"complete"},content:[{type:"file",mimeType:e.contentType,filename:e.name,data:await sj(e.file)}]}},async remove(){}},jp=e=>L.getExternalStoreMessages(e);function lj(e){return e.replace(/[}\]"]+$/,"")}const $s=(e,t)=>!e.parts||e.parts.length===0?[]:e.parts.filter(r=>r.type!=="step-start"&&r.type!=="file").map(r=>{const o=r.type;if(o==="text")return{type:"text",text:r.text};if(o==="reasoning")return{type:"reasoning",text:r.text};if(Zr(r)){const n=o.replace("tool-",""),i=r.toolCallId;let a={},s,l=!1;r.state==="input-streaming"||r.state==="input-available"?a=r.input||{}:r.state==="output-available"?(a=r.input||{},s=r.output):r.state==="output-error"&&(a=r.input||{},l=!0,s={error:r.errorText});let u=JSON.stringify(a);r.state==="input-streaming"&&(u=lj(u));const c=t.toolStatuses?.[i];return{type:"tool-call",toolName:n,toolCallId:i,argsText:u,args:a,result:s,isError:l,...c?.type==="interrupt"&&{interrupt:c.payload,status:{type:"requires-action",reason:"interrupt"}}}}if(o==="dynamic-tool"){const n=r.toolName,i=r.toolCallId;let a={},s,l=!1;r.state==="input-streaming"||r.state==="input-available"?a=r.input||{}:r.state==="output-available"?(a=r.input||{},s=r.output):r.state==="output-error"&&(a=r.input||{},l=!0,s={error:r.errorText});const u=t.toolStatuses?.[i];return{type:"tool-call",toolName:n,toolCallId:i,argsText:JSON.stringify(a),args:a,result:s,isError:l,...u?.type==="interrupt"&&{interrupt:u.payload,status:{type:"requires-action",reason:"interrupt"}}}}return o==="source-url"?{type:"source",sourceType:"url",id:r.sourceId,url:r.url,title:r.title||""}:o==="source-document"?(console.warn(`Source document part type ${o} is not yet supported in conversion`),null):o.startsWith("data-")?{type:"data",name:o.substring(5),data:r.data}:(console.warn(`Unsupported message part type: ${o}`),null)}).filter(Boolean),Ap=L.unstable_createMessageConverter((e,t)=>{const r=new Date;switch(e.role){case"user":return{role:"user",id:e.id,createdAt:r,content:$s(e,t),attachments:e.parts?.filter(o=>o.type==="file").map((o,n)=>({id:n.toString(),type:o.mediaType.startsWith("image/")?"image":"file",name:o.filename??"file",content:[o.mediaType.startsWith("image/")?{type:"image",image:o.url,filename:o.filename}:{type:"file",filename:o.filename,data:o.url,mimeType:o.mediaType}],contentType:o.mediaType??"unknown/unknown",status:{type:"complete"}}))};case"system":return{role:"system",id:e.id,createdAt:r,content:$s(e,t)};case"assistant":return{role:"assistant",id:e.id,createdAt:r,content:$s(e,t),metadata:{unstable_annotations:e.annotations,unstable_data:Array.isArray(e.data)?e.data:e.data?[e.data]:void 0,custom:{}}};default:return console.warn(`Unsupported message role: ${e.role}`),[]}}),cj={format:"ai-sdk/v5",encode({message:{id:e,parts:t,...r}}){return{...r,parts:t.filter(o=>o.type!=="file")}},decode(e){return{parentId:e.parent_id,message:{id:e.id,...e.content}}},getId(e){return e.id}},{MessageRepository:dj}=L.INTERNAL,pj=(e,t)=>({headId:t.headId,messages:t.messages.map(r=>{const o=e([r.message])[0];return{...r,message:o}})}),fj=(e,t,r,o,n)=>{const i=D.useRef(!1),a=L.useAssistantApi(),s=D.useCallback(()=>a.threadListItem.source?a.threadListItem():null,[a]),[l,u]=D.useState(!1),c=D.useRef(new Set),d=D.useRef(()=>n);return D.useEffect(()=>{d.current=n}),D.useEffect(()=>{if(!t||i.current)return;const f=async()=>{u(!0);try{const p=await t.withFormat?.(o).load();if(p&&p.messages.length>0){const g=pj(r,p);e.current.thread.import(g);const h=new dj;h.import(g);const b=h.getMessages();d.current(b.map(L.getExternalStoreMessages).flat()),c.current=new Set(g.messages.map(y=>y.message.id))}}catch(p){console.error("Failed to load message history:",p)}finally{u(!1)}};if(!i.current){if(i.current=!0,!s()?.getState().remoteId){u(!1);return}f()}},[a,t,o,r,e,s]),D.useEffect(()=>e.current.thread.subscribe(async()=>{const{messages:f,isRunning:p}=e.current.thread.getState();if(!p)for(let g=0;g<f.length;g++){const h=f[g];if(h.status===void 0||h.status.type==="complete"||h.status.type==="incomplete"){if(c.current.has(h.id))continue;c.current.add(h.id);const b=g>0?f[g-1].id:null;await t?.withFormat?.(o).append({parentId:b,message:L.getExternalStoreMessages(h)[0]})}}}),[t,o,e]),l},mj=(e,{adapters:t,toCreateMessage:r,cancelPendingToolCallsOnSend:o=!0}={})=>{const n=L.useRuntimeAdapters(),[i,a]=D.useState({}),s=Object.values(i).some(h=>h?.type==="executing"),l=e.status==="submitted"||e.status==="streaming"||s,u=Ap.useThreadMessages({isRunning:l,messages:e.messages,metadata:D.useMemo(()=>({toolStatuses:i,...e.error&&{error:e.error.message}}),[i,e.error])}),[c]=D.useState(()=>({get current(){return g}})),d=L.INTERNAL.useToolInvocations({state:{messages:u,isRunning:l},getTools:()=>c.current.thread.getModelContext().tools,onResult:h=>{h.type==="add-tool-result"&&e.addToolResult({tool:h.toolName,toolCallId:h.toolCallId,output:h.result})},setToolStatuses:a}),f=fj(c,t?.history??n?.history,Ap.toThreadMessages,cj,h=>{e.setMessages(h)}),p=async()=>{o&&(await d.abort(),e.setMessages(h=>{const b=h.at(-1);if(b?.role!=="assistant")return h;let y=!1;const x=b.parts?.map($=>!Zr($)||$.state==="output-available"||$.state==="output-error"?$:(y=!0,{...$,state:"output-error",errorText:"User cancelled tool call by sending a new message."}));return y?[...h.slice(0,-1),{...b,parts:x}]:h}))},g=L.useExternalStoreRuntime({isRunning:l,messages:u,setMessages:h=>e.setMessages(h.map(jp).filter(Boolean).flat()),onImport:h=>e.setMessages(h.map(jp).filter(Boolean).flat()),onCancel:async()=>{e.stop(),await d.abort()},onNew:async h=>{await p();const b=(r??Cp)(h);await e.sendMessage(b,{metadata:h.runConfig})},onEdit:async h=>{const b=Pp(e.messages,h.parentId);e.setMessages(b);const y=(r??Cp)(h);await e.sendMessage(y,{metadata:h.runConfig})},onReload:async(h,b)=>{const y=Pp(e.messages,h);e.setMessages(y),await e.regenerate({metadata:b.runConfig})},onAddToolResult:({toolCallId:h,result:b,isError:y})=>{y?e.addToolOutput({state:"output-error",tool:h,toolCallId:h,errorText:typeof b=="string"?b:JSON.stringify(b)}):e.addToolOutput({state:"output-available",tool:h,toolCallId:h,output:b})},onResumeToolCall:h=>d.resume(h.toolCallId,h.payload),adapters:{attachments:uj,...n,...t},isLoading:f});return g};var Ss,Rp;function hj(){if(Rp)return Ss;Rp=1;function e(t,r){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let o,n=0;return function(...a){clearTimeout(o);const s=Date.now(),l=s-n,u=r-l;u<=0?(n=s,t.apply(this,a)):o=setTimeout(()=>{n=Date.now(),t.apply(this,a)},u)}}return Ss=e,Ss}var gj=hj();const vj=XP(gj);var Vo={exports:{}},Is={};var zp;function yj(){if(zp)return Is;zp=1;var e=D;function t(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var r=typeof Object.is=="function"?Object.is:t,o=e.useState,n=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function s(d,f){var p=f(),g=o({inst:{value:p,getSnapshot:f}}),h=g[0].inst,b=g[1];return i(function(){h.value=p,h.getSnapshot=f,l(h)&&b({inst:h})},[d,p,f]),n(function(){return l(h)&&b({inst:h}),d(function(){l(h)&&b({inst:h})})},[d]),a(p),p}function l(d){var f=d.getSnapshot;d=d.value;try{var p=f();return!r(d,p)}catch{return!0}}function u(d,f){return f()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:s;return Is.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:c,Is}var ks={};var Mp;function bj(){return Mp||(Mp=1,process.env.NODE_ENV!=="production"&&(function(){function e(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}function t(p,g){c||n.startTransition===void 0||(c=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var h=g();if(!d){var b=g();i(h,b)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}b=a({inst:{value:h,getSnapshot:g}});var y=b[0].inst,x=b[1];return l(function(){y.value=h,y.getSnapshot=g,r(y)&&x({inst:y})},[p,h,g]),s(function(){return r(y)&&x({inst:y}),p(function(){r(y)&&x({inst:y})})},[p]),u(h),h}function r(p){var g=p.getSnapshot;p=p.value;try{var h=g();return!i(p,h)}catch{return!0}}function o(p,g){return g()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=D,i=typeof Object.is=="function"?Object.is:e,a=n.useState,s=n.useEffect,l=n.useLayoutEffect,u=n.useDebugValue,c=!1,d=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:t;ks.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),ks}var Dp;function _j(){return Dp||(Dp=1,process.env.NODE_ENV==="production"?Vo.exports=yj():Vo.exports=bj()),Vo.exports}var wj=_j(),gw=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},_e=(e,t,r)=>(gw(e,t,"read from private field"),r?r.call(e):t.get(e)),Ot=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Yt=(e,t,r,o)=>(gw(e,t,"write to private field"),t.set(e,r),r);function xj(e,t){return t!=null?vj(e,t):e}var it,ri,ni,kn,En,Tn,Dr,mu,hu,$j=class{constructor(e=[]){Ot(this,it,void 0),Ot(this,ri,"ready"),Ot(this,ni,void 0),Ot(this,kn,new Set),Ot(this,En,new Set),Ot(this,Tn,new Set),this.pushMessage=t=>{Yt(this,it,_e(this,it).concat(t)),_e(this,Dr).call(this)},this.popMessage=()=>{Yt(this,it,_e(this,it).slice(0,-1)),_e(this,Dr).call(this)},this.replaceMessage=(t,r)=>{Yt(this,it,[..._e(this,it).slice(0,t),this.snapshot(r),..._e(this,it).slice(t+1)]),_e(this,Dr).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,r)=>{const o=r?xj(t,r):t;return _e(this,kn).add(o),()=>{_e(this,kn).delete(o)}},this["~registerStatusCallback"]=t=>(_e(this,En).add(t),()=>{_e(this,En).delete(t)}),this["~registerErrorCallback"]=t=>(_e(this,Tn).add(t),()=>{_e(this,Tn).delete(t)}),Ot(this,Dr,()=>{_e(this,kn).forEach(t=>t())}),Ot(this,mu,()=>{_e(this,En).forEach(t=>t())}),Ot(this,hu,()=>{_e(this,Tn).forEach(t=>t())}),Yt(this,it,e)}get status(){return _e(this,ri)}set status(e){Yt(this,ri,e),_e(this,mu).call(this)}get error(){return _e(this,ni)}set error(e){Yt(this,ni,e),_e(this,hu).call(this)}get messages(){return _e(this,it)}set messages(e){Yt(this,it,[...e]),_e(this,Dr).call(this)}};it=new WeakMap;ri=new WeakMap;ni=new WeakMap;kn=new WeakMap;En=new WeakMap;Tn=new WeakMap;Dr=new WeakMap;mu=new WeakMap;hu=new WeakMap;var Ur,Up=class extends aj{constructor({messages:t,...r}){const o=new $j(t);super({...r,state:o}),Ot(this,Ur,void 0),this["~registerMessagesCallback"]=(n,i)=>_e(this,Ur)["~registerMessagesCallback"](n,i),this["~registerStatusCallback"]=n=>_e(this,Ur)["~registerStatusCallback"](n),this["~registerErrorCallback"]=n=>_e(this,Ur)["~registerErrorCallback"](n),Yt(this,Ur,o)}};Ur=new WeakMap;function Sj({experimental_throttle:e,resume:t=!1,...r}={}){const o=D.useRef("chat"in r?r.chat:new Up(r));("chat"in r&&r.chat!==o.current||"id"in r&&o.current.id!==r.id)&&(o.current="chat"in r?r.chat:new Up(r));const i=D.useCallback(c=>o.current["~registerMessagesCallback"](c,e),[e,o.current.id]),a=D.useSyncExternalStore(i,()=>o.current.messages,()=>o.current.messages),s=D.useSyncExternalStore(o.current["~registerStatusCallback"],()=>o.current.status,()=>o.current.status),l=D.useSyncExternalStore(o.current["~registerErrorCallback"],()=>o.current.error,()=>o.current.error),u=D.useCallback(c=>{typeof c=="function"&&(c=c(o.current.messages)),o.current.messages=c},[o]);return D.useEffect(()=>{t&&o.current.resumeStream()},[t,o]),{id:o.current.id,messages:a,setMessages:u,sendMessage:o.current.sendMessage,regenerate:o.current.regenerate,clearError:o.current.clearError,stop:o.current.stop,error:l,resumeStream:o.current.resumeStream,status:s,addToolResult:o.current.addToolOutput,addToolOutput:o.current.addToolOutput}}const Ij=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r.description?{description:r.description}:void 0,parameters:r.parameters instanceof gi.ZodType?gi.toJSONSchema(r.parameters):r.parameters}])),kj=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>!t.disabled&&t.type!=="backend"));class Lp extends hw{runtime;constructor(t){super({...t,prepareSendMessagesRequest:async r=>{const o=this.runtime?.thread.getModelContext(),n=(await this.runtime?.threads.mainItem.initialize())?.remoteId??r.id,i={...r,body:{callSettings:o?.callSettings,system:o?.system,tools:Ij(kj(o?.tools??{})),...r?.body}},a=await t?.prepareSendMessagesRequest?.(i);return{...a,body:a?.body??{...i.body,id:n,messages:r.messages,trigger:r.trigger,messageId:r.messageId,metadata:r.requestMetadata}}}})}setRuntime(t){this.runtime=t}}const Ej=e=>{const t=D.useRef(e);return D.useEffect(()=>{t.current=e}),D.useMemo(()=>new Proxy(t.current,{get(o,n){const i=t.current[n];return typeof i=="function"?i.bind(t.current):i}}),[])},Tj=e=>{const{adapters:t,transport:r,toCreateMessage:o,...n}=e??{},i=Ej(r??new Lp),a=L.useAssistantState(({threadListItem:u})=>u.id),s=Sj({...n,id:a,transport:i}),l=mj(s,{adapters:t,...o&&{toCreateMessage:o}});return i instanceof Lp&&i.setRuntime(l),l},Oj=({cloud:e,...t}={})=>{const r=L.unstable_useCloudThreadListAdapter({cloud:e});return L.unstable_useRemoteThreadListRuntime({runtimeHook:function(){return Tj(t)},adapter:r,allowNesting:!0})},Nj=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r.description?{description:r.description}:void 0,inputSchema:qa(r.parameters)}]));var Pj=Object.defineProperty,Cj=Object.defineProperties,jj=Object.getOwnPropertyDescriptors,Zp=Object.getOwnPropertySymbols,Aj=Object.prototype.hasOwnProperty,Rj=Object.prototype.propertyIsEnumerable,Fp=(e,t,r)=>t in e?Pj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ue=(e,t)=>{for(var r in t||(t={}))Aj.call(t,r)&&Fp(e,r,t[r]);if(Zp)for(var r of Zp(t))Rj.call(t,r)&&Fp(e,r,t[r]);return e},ji=(e,t)=>Cj(e,jj(t)),vw="vercel.ai.error",zj=Symbol.for(vw),yw,Mj=class bw extends Error{constructor({name:t,message:r,cause:o}){super(r),this[yw]=!0,this.name=t,this.cause=o}static isInstance(t){return bw.hasMarker(t,vw)}static hasMarker(t,r){const o=Symbol.for(r);return t!=null&&typeof t=="object"&&o in t&&typeof t[o]=="boolean"&&t[o]===!0}};yw=zj;var Ne=Mj,_w="AI_APICallError",ww=`vercel.ai.error.${_w}`,Dj=Symbol.for(ww),xw,xt=class extends Ne{constructor({message:e,url:t,requestBodyValues:r,statusCode:o,responseHeaders:n,responseBody:i,cause:a,isRetryable:s=o!=null&&(o===408||o===409||o===429||o>=500),data:l}){super({name:_w,message:e,cause:a}),this[xw]=!0,this.url=t,this.requestBodyValues=r,this.statusCode=o,this.responseHeaders=n,this.responseBody=i,this.isRetryable=s,this.data=l}static isInstance(e){return Ne.hasMarker(e,ww)}};xw=Dj;var $w="AI_EmptyResponseBodyError",Sw=`vercel.ai.error.${$w}`,Uj=Symbol.for(Sw),Iw,Lj=class extends Ne{constructor({message:e="Empty response body"}={}){super({name:$w,message:e}),this[Iw]=!0}static isInstance(e){return Ne.hasMarker(e,Sw)}};Iw=Uj;function kw(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Ew="AI_InvalidArgumentError",Tw=`vercel.ai.error.${Ew}`,Zj=Symbol.for(Tw),Ow,Nw=class extends Ne{constructor({message:t,cause:r,argument:o}){super({name:Ew,message:t,cause:r}),this[Ow]=!0,this.argument=o}static isInstance(t){return Ne.hasMarker(t,Tw)}};Ow=Zj;var Pw="AI_InvalidPromptError",Cw=`vercel.ai.error.${Pw}`,Fj=Symbol.for(Cw),jw,qj=class extends Ne{constructor({prompt:e,message:t,cause:r}){super({name:Pw,message:`Invalid prompt: ${t}`,cause:r}),this[jw]=!0,this.prompt=e}static isInstance(e){return Ne.hasMarker(e,Cw)}};jw=Fj;var Aw="AI_InvalidResponseDataError",Rw=`vercel.ai.error.${Aw}`,Vj=Symbol.for(Rw),zw,wn=class extends Ne{constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:Aw,message:t}),this[zw]=!0,this.data=e}static isInstance(e){return Ne.hasMarker(e,Rw)}};zw=Vj;var Mw="AI_JSONParseError",Dw=`vercel.ai.error.${Mw}`,Bj=Symbol.for(Dw),Uw,Ai=class extends Ne{constructor({text:e,cause:t}){super({name:Mw,message:`JSON parsing failed: Text: ${e}.
|
|
38
|
-
Error message: ${kw(t)}`,cause:t}),this[Uw]=!0,this.text=e}static isInstance(e){return Ne.hasMarker(e,Dw)}};Uw=
|
|
39
|
-
Error message: ${kw(r)}`,cause:r}),this[Gw]=!0,this.value=t}static isInstance(t){return Ne.hasMarker(t,Hw)}static wrap({value:t,cause:r}){return gu.isInstance(r)&&r.value===t?r:new gu({value:t,cause:r})}};Gw=
|
|
37
|
+
`)}})}});var HC=oP(()=>X_(G([_e({type:C("text-start"),id:w(),providerMetadata:ke.optional()}),_e({type:C("text-delta"),id:w(),delta:w(),providerMetadata:ke.optional()}),_e({type:C("text-end"),id:w(),providerMetadata:ke.optional()}),_e({type:C("error"),errorText:w()}),_e({type:C("tool-input-start"),toolCallId:w(),toolName:w(),providerExecuted:pe().optional(),dynamic:pe().optional()}),_e({type:C("tool-input-delta"),toolCallId:w(),inputTextDelta:w()}),_e({type:C("tool-input-available"),toolCallId:w(),toolName:w(),input:$e(),providerExecuted:pe().optional(),providerMetadata:ke.optional(),dynamic:pe().optional()}),_e({type:C("tool-input-error"),toolCallId:w(),toolName:w(),input:$e(),providerExecuted:pe().optional(),providerMetadata:ke.optional(),dynamic:pe().optional(),errorText:w()}),_e({type:C("tool-output-available"),toolCallId:w(),output:$e(),providerExecuted:pe().optional(),dynamic:pe().optional(),preliminary:pe().optional()}),_e({type:C("tool-output-error"),toolCallId:w(),errorText:w(),providerExecuted:pe().optional(),dynamic:pe().optional()}),_e({type:C("reasoning-start"),id:w(),providerMetadata:ke.optional()}),_e({type:C("reasoning-delta"),id:w(),delta:w(),providerMetadata:ke.optional()}),_e({type:C("reasoning-end"),id:w(),providerMetadata:ke.optional()}),_e({type:C("source-url"),sourceId:w(),url:w(),title:w().optional(),providerMetadata:ke.optional()}),_e({type:C("source-document"),sourceId:w(),mediaType:w(),title:w(),filename:w().optional(),providerMetadata:ke.optional()}),_e({type:C("file"),url:w(),mediaType:w(),providerMetadata:ke.optional()}),_e({type:So(e=>typeof e=="string"&&e.startsWith("data-"),{message:'Type must start with "data-"'}),id:w().optional(),data:$e(),transient:pe().optional()}),_e({type:C("start-step")}),_e({type:C("finish-step")}),_e({type:C("start"),messageId:w().optional(),messageMetadata:$e().optional()}),_e({type:C("finish"),finishReason:dr(["stop","length","content-filter","tool-calls","error","other","unknown"]).optional(),messageMetadata:$e().optional()}),_e({type:C("abort")}),_e({type:C("message-metadata"),messageMetadata:$e()})])));function GC(e){return e.type.startsWith("data-")}function fw(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const r={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const n=t[o];if(n===void 0)continue;const i=o in e?e[o]:void 0,a=n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?r[o]=fw(i,n):r[o]=n}return r}function KC(e){const t=["ROOT"];let r=-1,o=null;function n(l,u,c){switch(l){case'"':{r=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{r=u,o=u,t.pop(),t.push(c),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{r=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{r=u,t.pop(),t.push(c),t.push("INSIDE_ARRAY_START");break}}}function i(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":n(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{r=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{n(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),r=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:r=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{r=l,t.pop();break}default:{r=l,n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=l,t.pop();break}default:{r=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),r=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(o,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(u,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l)):r=l;break}}}let s=e.slice(0,r+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{s+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{s+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{s+="]";break}case"INSIDE_LITERAL":{const c=e.substring(o,e.length);"true".startsWith(c)?s+="true".slice(c.length):"false".startsWith(c)?s+="false".slice(c.length):"null".startsWith(c)&&(s+="null".slice(c.length))}}return s}async function mw(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await Pi({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await Pi({text:KC(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function Zr(e){return e.type.startsWith("tool-")}function YC(e){return e.type==="dynamic-tool"}function Op(e){return Zr(e)||YC(e)}function Np(e){return e.type.split("-").slice(1).join("-")}function QC({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function XC({stream:e,messageMetadataSchema:t,dataPartSchemas:r,runUpdateMessageJob:o,onError:n,onToolCall:i,onData:a}){return e.pipeThrough(new TransformStream({async transform(s,l){await o(async({state:u,write:c})=>{var d,f,p,g;function h(v){const N=u.message.parts.filter(Zr).find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function b(v){const N=u.message.parts.filter(I=>I.type==="dynamic-tool").find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function y(v){var k;const N=u.message.parts.find(M=>Zr(M)&&M.toolCallId===v.toolCallId),I=v,O=N;N!=null?(N.state=v.state,O.input=I.input,O.output=I.output,O.errorText=I.errorText,O.rawInput=I.rawInput,O.preliminary=I.preliminary,O.providerExecuted=(k=I.providerExecuted)!=null?k:N.providerExecuted,I.providerMetadata!=null&&N.state==="input-available"&&(N.callProviderMetadata=I.providerMetadata)):u.message.parts.push({type:`tool-${v.toolName}`,toolCallId:v.toolCallId,state:v.state,input:I.input,output:I.output,rawInput:I.rawInput,errorText:I.errorText,providerExecuted:I.providerExecuted,preliminary:I.preliminary,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}function x(v){var k,N;const I=u.message.parts.find(F=>F.type==="dynamic-tool"&&F.toolCallId===v.toolCallId),O=v,M=I;I!=null?(I.state=v.state,M.toolName=v.toolName,M.input=O.input,M.output=O.output,M.errorText=O.errorText,M.rawInput=(k=O.rawInput)!=null?k:M.rawInput,M.preliminary=O.preliminary,M.providerExecuted=(N=O.providerExecuted)!=null?N:I.providerExecuted,O.providerMetadata!=null&&I.state==="input-available"&&(I.callProviderMetadata=O.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:v.toolName,toolCallId:v.toolCallId,state:v.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,...O.providerMetadata!=null?{callProviderMetadata:O.providerMetadata}:{}})}async function $(v){if(v!=null){const k=u.message.metadata!=null?fw(u.message.metadata,v):v;t!=null&&await xp({value:k,schema:t}),u.message.metadata=k}}switch(s.type){case"text-start":{const v={type:"text",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeTextParts[s.id]=v,u.message.parts.push(v),c();break}case"text-delta":{const v=u.activeTextParts[s.id];v.text+=s.delta,v.providerMetadata=(d=s.providerMetadata)!=null?d:v.providerMetadata,c();break}case"text-end":{const v=u.activeTextParts[s.id];v.state="done",v.providerMetadata=(f=s.providerMetadata)!=null?f:v.providerMetadata,delete u.activeTextParts[s.id],c();break}case"reasoning-start":{const v={type:"reasoning",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeReasoningParts[s.id]=v,u.message.parts.push(v),c();break}case"reasoning-delta":{const v=u.activeReasoningParts[s.id];v.text+=s.delta,v.providerMetadata=(p=s.providerMetadata)!=null?p:v.providerMetadata,c();break}case"reasoning-end":{const v=u.activeReasoningParts[s.id];v.providerMetadata=(g=s.providerMetadata)!=null?g:v.providerMetadata,v.state="done",delete u.activeReasoningParts[s.id],c();break}case"file":{u.message.parts.push({type:"file",mediaType:s.mediaType,url:s.url}),c();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:s.sourceId,url:s.url,title:s.title,providerMetadata:s.providerMetadata}),c();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:s.sourceId,mediaType:s.mediaType,title:s.title,filename:s.filename,providerMetadata:s.providerMetadata}),c();break}case"tool-input-start":{const v=u.message.parts.filter(Zr);u.partialToolCalls[s.toolCallId]={text:"",toolName:s.toolName,index:v.length,dynamic:s.dynamic},s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}),c();break}case"tool-input-delta":{const v=u.partialToolCalls[s.toolCallId];v.text+=s.inputTextDelta;const{value:k}=await mw(v.text);v.dynamic?x({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}):y({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}),c();break}case"tool-input-available":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c(),i&&!s.providerExecuted&&await i({toolCall:s});break}case"tool-input-error":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:void 0,rawInput:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c();break}case"tool-output-available":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-available",input:v.input,output:s.output,preliminary:s.preliminary})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Np(v),state:"output-available",input:v.input,output:s.output,providerExecuted:s.providerExecuted,preliminary:s.preliminary})}c();break}case"tool-output-error":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-error",input:v.input,errorText:s.errorText,providerExecuted:s.providerExecuted})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Np(v),state:"output-error",input:v.input,rawInput:v.rawInput,errorText:s.errorText,providerExecuted:s.providerExecuted})}c();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{s.messageId!=null&&(u.message.id=s.messageId),await $(s.messageMetadata),(s.messageId!=null||s.messageMetadata!=null)&&c();break}case"finish":{s.finishReason!=null&&(u.finishReason=s.finishReason),await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"message-metadata":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"error":{n?.(new Error(s.errorText));break}default:if(GC(s)){r?.[s.type]!=null&&await xp({value:s.data,schema:r[s.type]});const v=s;if(v.transient){a?.(v);break}const k=v.id!=null?u.message.parts.find(N=>v.type===N.type&&v.id===N.id):void 0;k!=null?k.data=v.data:u.message.parts.push(v),a?.(v),c()}}l.enqueue(s)})}}))}async function ej({stream:e,onError:t}){const r=e.getReader();try{for(;;){const{done:o}=await r.read();if(o)break}}catch(o){t?.(o)}finally{r.releaseLock()}}To({prefix:"aitxt",size:24});To({prefix:"aiobj",size:24});var tj=class{constructor(){this.queue=[],this.isProcessing=!1}async processQueue(){if(!this.isProcessing){for(this.isProcessing=!0;this.queue.length>0;)await this.queue[0](),this.queue.shift();this.isProcessing=!1}}async run(e){return new Promise((t,r)=>{this.queue.push(async()=>{try{await e(),t()}catch(o){r(o)}}),this.processQueue()})}};To({prefix:"aiobj",size:24});var rj={};DC(rj,{object:()=>oj,text:()=>nj});var nj=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),oj=({schema:e})=>{const t=XP(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:r}){const o=await mw(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const n=o.state;throw new Error(`Unsupported parse state: ${n}`)}}},async parseOutput({text:r},o){const n=await Pi({text:r});if(!n.success)throw new Ep({message:"No object generated: could not parse the response.",cause:n.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await Cc({value:n.value,schema:t});if(!i.success)throw new Ep({message:"No object generated: response did not match schema.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}};async function ij(e){if(e==null)return[];if(!globalThis.FileList||!(e instanceof globalThis.FileList))throw new Error("FileList is not supported in the current environment");return Promise.all(Array.from(e).map(async t=>{const{name:r,type:o}=t,n=await new Promise((i,a)=>{const s=new FileReader;s.onload=l=>{var u;i((u=l.target)==null?void 0:u.result)},s.onerror=l=>a(l),s.readAsDataURL(t)});return{type:"file",mediaType:o,filename:r,url:n}}))}var aj=class{constructor({api:e="/api/chat",credentials:t,headers:r,body:o,fetch:n,prepareSendMessagesRequest:i,prepareReconnectToStreamRequest:a}){this.api=e,this.credentials=t,this.headers=r,this.body=o,this.fetch=n,this.prepareSendMessagesRequest=i,this.prepareReconnectToStreamRequest=a}async sendMessages({abortSignal:e,...t}){var r,o,n,i,a;const s=await Ar(this.body),l=await Ar(this.headers),u=await Ar(this.credentials),c={...fr(l),...fr(t.headers)},d=await((r=this.prepareSendMessagesRequest)==null?void 0:r.call(this,{api:this.api,id:t.chatId,messages:t.messages,body:{...s,...t.body},headers:c,credentials:u,requestMetadata:t.metadata,trigger:t.trigger,messageId:t.messageId})),f=(o=d?.api)!=null?o:this.api,p=d?.headers!==void 0?fr(d.headers):c,g=d?.body!==void 0?d.body:{...s,...t.body,id:t.chatId,messages:t.messages,trigger:t.trigger,messageId:t.messageId},h=(n=d?.credentials)!=null?n:u,y=await((i=this.fetch)!=null?i:globalThis.fetch)(f,{method:"POST",headers:_p({"Content-Type":"application/json",...p},`ai-sdk/${Tp}`,bp()),body:JSON.stringify(g),credentials:h,signal:e});if(!y.ok)throw new Error((a=await y.text())!=null?a:"Failed to fetch the chat response.");if(!y.body)throw new Error("The response body is empty.");return this.processResponseStream(y.body)}async reconnectToStream(e){var t,r,o,n,i;const a=await Ar(this.body),s=await Ar(this.headers),l=await Ar(this.credentials),u={...fr(s),...fr(e.headers)},c=await((t=this.prepareReconnectToStreamRequest)==null?void 0:t.call(this,{api:this.api,id:e.chatId,body:{...a,...e.body},headers:u,credentials:l,requestMetadata:e.metadata})),d=(r=c?.api)!=null?r:`${this.api}/${e.chatId}/stream`,f=c?.headers!==void 0?fr(c.headers):u,p=(o=c?.credentials)!=null?o:l,h=await((n=this.fetch)!=null?n:globalThis.fetch)(d,{method:"GET",headers:_p(f,`ai-sdk/${Tp}`,bp()),credentials:p});if(h.status===204)return null;if(!h.ok)throw new Error((i=await h.text())!=null?i:"Failed to fetch the chat response.");if(!h.body)throw new Error("The response body is empty.");return this.processResponseStream(h.body)}},hw=class extends aj{constructor(e={}){super(e)}processResponseStream(e){return sP({stream:e,schema:HC}).pipeThrough(new TransformStream({async transform(t,r){if(!t.success)throw t.error;r.enqueue(t.value)}}))}},sj=class{constructor({generateId:e=H_,id:t=e(),transport:r=new hw,messageMetadataSchema:o,dataPartSchemas:n,state:i,onError:a,onToolCall:s,onFinish:l,onData:u,sendAutomaticallyWhen:c}){this.activeResponse=void 0,this.jobExecutor=new tj,this.sendMessage=async(d,f)=>{var p,g,h,b;if(d==null){await this.makeRequest({trigger:"submit-message",messageId:(p=this.lastMessage)==null?void 0:p.id,...f});return}let y;if("text"in d||"files"in d?y={parts:[...Array.isArray(d.files)?d.files:await ij(d.files),..."text"in d&&d.text!=null?[{type:"text",text:d.text}]:[]]}:y=d,d.messageId!=null){const x=this.state.messages.findIndex($=>$.id===d.messageId);if(x===-1)throw new Error(`message with id ${d.messageId} not found`);if(this.state.messages[x].role!=="user")throw new Error(`message with id ${d.messageId} is not a user message`);this.state.messages=this.state.messages.slice(0,x+1),this.state.replaceMessage(x,{...y,id:d.messageId,role:(g=y.role)!=null?g:"user",metadata:d.metadata})}else this.state.pushMessage({...y,id:(h=y.id)!=null?h:this.generateId(),role:(b=y.role)!=null?b:"user",metadata:d.metadata});await this.makeRequest({trigger:"submit-message",messageId:d.messageId,...f})},this.regenerate=async({messageId:d,...f}={})=>{const p=d==null?this.state.messages.length-1:this.state.messages.findIndex(g=>g.id===d);if(p===-1)throw new Error(`message ${d} not found`);this.state.messages=this.state.messages.slice(0,this.messages[p].role==="assistant"?p:p+1),await this.makeRequest({trigger:"regenerate-message",messageId:d,...f})},this.resumeStream=async(d={})=>{await this.makeRequest({trigger:"resume-stream",...d})},this.clearError=()=>{this.status==="error"&&(this.state.error=void 0,this.setStatus({status:"ready"}))},this.addToolOutput=async({state:d="output-available",tool:f,toolCallId:p,output:g,errorText:h})=>this.jobExecutor.run(async()=>{var b,y;const x=this.state.messages,$=x[x.length-1];this.state.replaceMessage(x.length-1,{...$,parts:$.parts.map(v=>Op(v)&&v.toolCallId===p?{...v,state:d,output:g,errorText:h}:v)}),this.activeResponse&&(this.activeResponse.state.message.parts=this.activeResponse.state.message.parts.map(v=>Op(v)&&v.toolCallId===p?{...v,state:d,output:g,errorText:h}:v)),this.status!=="streaming"&&this.status!=="submitted"&&((b=this.sendAutomaticallyWhen)!=null&&b.call(this,{messages:this.state.messages}))&&this.makeRequest({trigger:"submit-message",messageId:(y=this.lastMessage)==null?void 0:y.id})}),this.addToolResult=this.addToolOutput,this.stop=async()=>{var d;this.status!=="streaming"&&this.status!=="submitted"||(d=this.activeResponse)!=null&&d.abortController&&this.activeResponse.abortController.abort()},this.id=t,this.transport=r,this.generateId=e,this.messageMetadataSchema=o,this.dataPartSchemas=n,this.state=i,this.onError=a,this.onToolCall=s,this.onFinish=l,this.onData=u,this.sendAutomaticallyWhen=c}get status(){return this.state.status}setStatus({status:e,error:t}){this.status!==e&&(this.state.status=e,this.state.error=t)}get error(){return this.state.error}get messages(){return this.state.messages}get lastMessage(){return this.state.messages[this.state.messages.length-1]}set messages(e){this.state.messages=e}async makeRequest({trigger:e,metadata:t,headers:r,body:o,messageId:n}){var i,a,s,l;this.setStatus({status:"submitted",error:void 0});const u=this.lastMessage;let c=!1,d=!1,f=!1;try{const p={state:QC({lastMessage:this.state.snapshot(u),messageId:this.generateId()}),abortController:new AbortController};p.abortController.signal.addEventListener("abort",()=>{c=!0}),this.activeResponse=p;let g;if(e==="resume-stream"){const b=await this.transport.reconnectToStream({chatId:this.id,metadata:t,headers:r,body:o});if(b==null){this.setStatus({status:"ready"});return}g=b}else g=await this.transport.sendMessages({chatId:this.id,messages:this.state.messages,abortSignal:p.abortController.signal,metadata:t,headers:r,body:o,trigger:e,messageId:n});const h=b=>this.jobExecutor.run(()=>b({state:p.state,write:()=>{var y;this.setStatus({status:"streaming"}),p.state.message.id===((y=this.lastMessage)==null?void 0:y.id)?this.state.replaceMessage(this.state.messages.length-1,p.state.message):this.state.pushMessage(p.state.message)}}));await ej({stream:XC({stream:g,onToolCall:this.onToolCall,onData:this.onData,messageMetadataSchema:this.messageMetadataSchema,dataPartSchemas:this.dataPartSchemas,runUpdateMessageJob:h,onError:b=>{throw b}}),onError:b=>{throw b}}),this.setStatus({status:"ready"})}catch(p){if(c||p.name==="AbortError")return c=!0,this.setStatus({status:"ready"}),null;f=!0,p instanceof TypeError&&(p.message.toLowerCase().includes("fetch")||p.message.toLowerCase().includes("network"))&&(d=!0),this.onError&&p instanceof Error&&this.onError(p),this.setStatus({status:"error",error:p})}finally{try{(a=this.onFinish)==null||a.call(this,{message:this.activeResponse.state.message,messages:this.state.messages,isAbort:c,isDisconnect:d,isError:f,finishReason:(i=this.activeResponse)==null?void 0:i.state.finishReason})}catch(p){console.error(p)}this.activeResponse=void 0}(s=this.sendAutomaticallyWhen)!=null&&s.call(this,{messages:this.state.messages})&&!f&&await this.makeRequest({trigger:"submit-message",messageId:(l=this.lastMessage)==null?void 0:l.id,metadata:t,headers:r,body:o})}};const Pp=(e,t)=>{if(t==null)return[];let r=e.findIndex(o=>o.id===t);if(r===-1)throw new Error("useVercelAIThreadState: Message not found. This is likely an internal bug in assistant-ui.");for(;e[r+1]?.role==="assistant";)r++;return e.slice(0,r+1)},Cp=e=>{const r=[...e.content.filter(o=>o.type!=="file"),...e.attachments?.flatMap(o=>o.content.map(n=>({...n,filename:o.name})))??[]].map(o=>{switch(o.type){case"text":return{type:"text",text:o.text};case"image":return{type:"file",url:o.image,...o.filename&&{filename:o.filename},mediaType:"image/png"};case"file":return{type:"file",url:o.data,mediaType:o.mimeType,...o.filename&&{filename:o.filename}};default:throw new Error(`Unsupported part type: ${o.type}`)}});return{role:e.role,parts:r}},uj=e=>new Promise((t,r)=>{const o=new FileReader;o.onload=()=>t(o.result),o.onerror=n=>r(n),o.readAsDataURL(e)}),lj={accept:"image/*, text/plain, text/html, text/markdown, text/csv, text/xml, text/json, text/css",async add({file:e}){return{id:H_(),type:e.type.startsWith("image/")?"image":"file",name:e.name,file:e,contentType:e.type,content:[],status:{type:"requires-action",reason:"composer-send"}}},async send(e){return{...e,status:{type:"complete"},content:[{type:"file",mimeType:e.contentType,filename:e.name,data:await uj(e.file)}]}},async remove(){}},jp=e=>L.getExternalStoreMessages(e);function cj(e){return e.replace(/[}\]"]+$/,"")}const Ss=(e,t)=>!e.parts||e.parts.length===0?[]:e.parts.filter(r=>r.type!=="step-start"&&r.type!=="file").map(r=>{const o=r.type;if(o==="text")return{type:"text",text:r.text};if(o==="reasoning")return{type:"reasoning",text:r.text};if(Zr(r)){const n=o.replace("tool-",""),i=r.toolCallId;let a={},s,l=!1;r.state==="input-streaming"||r.state==="input-available"?a=r.input||{}:r.state==="output-available"?(a=r.input||{},s=r.output):r.state==="output-error"&&(a=r.input||{},l=!0,s={error:r.errorText});let u=JSON.stringify(a);r.state==="input-streaming"&&(u=cj(u));const c=t.toolStatuses?.[i];return{type:"tool-call",toolName:n,toolCallId:i,argsText:u,args:a,result:s,isError:l,...c?.type==="interrupt"&&{interrupt:c.payload,status:{type:"requires-action",reason:"interrupt"}}}}if(o==="dynamic-tool"){const n=r.toolName,i=r.toolCallId;let a={},s,l=!1;r.state==="input-streaming"||r.state==="input-available"?a=r.input||{}:r.state==="output-available"?(a=r.input||{},s=r.output):r.state==="output-error"&&(a=r.input||{},l=!0,s={error:r.errorText});const u=t.toolStatuses?.[i];return{type:"tool-call",toolName:n,toolCallId:i,argsText:JSON.stringify(a),args:a,result:s,isError:l,...u?.type==="interrupt"&&{interrupt:u.payload,status:{type:"requires-action",reason:"interrupt"}}}}return o==="source-url"?{type:"source",sourceType:"url",id:r.sourceId,url:r.url,title:r.title||""}:o==="source-document"?(console.warn(`Source document part type ${o} is not yet supported in conversion`),null):o.startsWith("data-")?{type:"data",name:o.substring(5),data:r.data}:(console.warn(`Unsupported message part type: ${o}`),null)}).filter(Boolean),Ap=L.unstable_createMessageConverter((e,t)=>{const r=new Date;switch(e.role){case"user":return{role:"user",id:e.id,createdAt:r,content:Ss(e,t),attachments:e.parts?.filter(o=>o.type==="file").map((o,n)=>({id:n.toString(),type:o.mediaType.startsWith("image/")?"image":"file",name:o.filename??"file",content:[o.mediaType.startsWith("image/")?{type:"image",image:o.url,filename:o.filename}:{type:"file",filename:o.filename,data:o.url,mimeType:o.mediaType}],contentType:o.mediaType??"unknown/unknown",status:{type:"complete"}}))};case"system":return{role:"system",id:e.id,createdAt:r,content:Ss(e,t)};case"assistant":return{role:"assistant",id:e.id,createdAt:r,content:Ss(e,t),metadata:{unstable_annotations:e.annotations,unstable_data:Array.isArray(e.data)?e.data:e.data?[e.data]:void 0,custom:{}}};default:return console.warn(`Unsupported message role: ${e.role}`),[]}}),dj={format:"ai-sdk/v5",encode({message:{id:e,parts:t,...r}}){return{...r,parts:t.filter(o=>o.type!=="file")}},decode(e){return{parentId:e.parent_id,message:{id:e.id,...e.content}}},getId(e){return e.id}},{MessageRepository:pj}=L.INTERNAL,fj=(e,t)=>({headId:t.headId,messages:t.messages.map(r=>{const o=e([r.message])[0];return{...r,message:o}})}),mj=(e,t,r,o,n)=>{const i=z.useRef(!1),a=L.useAssistantApi(),s=z.useCallback(()=>a.threadListItem.source?a.threadListItem():null,[a]),[l,u]=z.useState(!1),c=z.useRef(new Set),d=z.useRef(()=>n);return z.useEffect(()=>{d.current=n}),z.useEffect(()=>{if(!t||i.current)return;const f=async()=>{u(!0);try{const p=await t.withFormat?.(o).load();if(p&&p.messages.length>0){const g=fj(r,p);e.current.thread.import(g);const h=new pj;h.import(g);const b=h.getMessages();d.current(b.map(L.getExternalStoreMessages).flat()),c.current=new Set(g.messages.map(y=>y.message.id))}}catch(p){console.error("Failed to load message history:",p)}finally{u(!1)}};if(!i.current){if(i.current=!0,!s()?.getState().remoteId){u(!1);return}f()}},[a,t,o,r,e,s]),z.useEffect(()=>e.current.thread.subscribe(async()=>{const{messages:f,isRunning:p}=e.current.thread.getState();if(!p)for(let g=0;g<f.length;g++){const h=f[g];if(h.status===void 0||h.status.type==="complete"||h.status.type==="incomplete"){if(c.current.has(h.id))continue;c.current.add(h.id);const b=g>0?f[g-1].id:null;await t?.withFormat?.(o).append({parentId:b,message:L.getExternalStoreMessages(h)[0]})}}}),[t,o,e]),l},hj=(e,{adapters:t,toCreateMessage:r,cancelPendingToolCallsOnSend:o=!0}={})=>{const n=L.useRuntimeAdapters(),[i,a]=z.useState({}),s=Object.values(i).some(h=>h?.type==="executing"),l=e.status==="submitted"||e.status==="streaming"||s,u=Ap.useThreadMessages({isRunning:l,messages:e.messages,metadata:z.useMemo(()=>({toolStatuses:i,...e.error&&{error:e.error.message}}),[i,e.error])}),[c]=z.useState(()=>({get current(){return g}})),d=L.INTERNAL.useToolInvocations({state:{messages:u,isRunning:l},getTools:()=>c.current.thread.getModelContext().tools,onResult:h=>{h.type==="add-tool-result"&&e.addToolResult({tool:h.toolName,toolCallId:h.toolCallId,output:h.result})},setToolStatuses:a}),f=mj(c,t?.history??n?.history,Ap.toThreadMessages,dj,h=>{e.setMessages(h)}),p=async()=>{o&&(await d.abort(),e.setMessages(h=>{const b=h.at(-1);if(b?.role!=="assistant")return h;let y=!1;const x=b.parts?.map($=>!Zr($)||$.state==="output-available"||$.state==="output-error"?$:(y=!0,{...$,state:"output-error",errorText:"User cancelled tool call by sending a new message."}));return y?[...h.slice(0,-1),{...b,parts:x}]:h}))},g=L.useExternalStoreRuntime({isRunning:l,messages:u,setMessages:h=>e.setMessages(h.map(jp).filter(Boolean).flat()),onImport:h=>e.setMessages(h.map(jp).filter(Boolean).flat()),onCancel:async()=>{e.stop(),await d.abort()},onNew:async h=>{await p();const b=(r??Cp)(h);await e.sendMessage(b,{metadata:h.runConfig})},onEdit:async h=>{const b=Pp(e.messages,h.parentId);e.setMessages(b);const y=(r??Cp)(h);await e.sendMessage(y,{metadata:h.runConfig})},onReload:async(h,b)=>{const y=Pp(e.messages,h);e.setMessages(y),await e.regenerate({metadata:b.runConfig})},onAddToolResult:({toolCallId:h,result:b,isError:y})=>{y?e.addToolOutput({state:"output-error",tool:h,toolCallId:h,errorText:typeof b=="string"?b:JSON.stringify(b)}):e.addToolOutput({state:"output-available",tool:h,toolCallId:h,output:b})},onResumeToolCall:h=>d.resume(h.toolCallId,h.payload),adapters:{attachments:lj,...n,...t},isLoading:f});return g};var Is,Rp;function gj(){if(Rp)return Is;Rp=1;function e(t,r){if(typeof t!="function")throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof t}\`.`);let o,n=0;return function(...a){clearTimeout(o);const s=Date.now(),l=s-n,u=r-l;u<=0?(n=s,t.apply(this,a)):o=setTimeout(()=>{n=Date.now(),t.apply(this,a)},u)}}return Is=e,Is}var vj=gj();const yj=eC(vj);var Vo={exports:{}},ks={};var zp;function bj(){if(zp)return ks;zp=1;var e=z;function t(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var r=typeof Object.is=="function"?Object.is:t,o=e.useState,n=e.useEffect,i=e.useLayoutEffect,a=e.useDebugValue;function s(d,f){var p=f(),g=o({inst:{value:p,getSnapshot:f}}),h=g[0].inst,b=g[1];return i(function(){h.value=p,h.getSnapshot=f,l(h)&&b({inst:h})},[d,p,f]),n(function(){return l(h)&&b({inst:h}),d(function(){l(h)&&b({inst:h})})},[d]),a(p),p}function l(d){var f=d.getSnapshot;d=d.value;try{var p=f();return!r(d,p)}catch{return!0}}function u(d,f){return f()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:s;return ks.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:c,ks}var Es={};var Mp;function _j(){return Mp||(Mp=1,process.env.NODE_ENV!=="production"&&(function(){function e(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}function t(p,g){c||n.startTransition===void 0||(c=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var h=g();if(!d){var b=g();i(h,b)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}b=a({inst:{value:h,getSnapshot:g}});var y=b[0].inst,x=b[1];return l(function(){y.value=h,y.getSnapshot=g,r(y)&&x({inst:y})},[p,h,g]),s(function(){return r(y)&&x({inst:y}),p(function(){r(y)&&x({inst:y})})},[p]),u(h),h}function r(p){var g=p.getSnapshot;p=p.value;try{var h=g();return!i(p,h)}catch{return!0}}function o(p,g){return g()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var n=z,i=typeof Object.is=="function"?Object.is:e,a=n.useState,s=n.useEffect,l=n.useLayoutEffect,u=n.useDebugValue,c=!1,d=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o:t;Es.useSyncExternalStore=n.useSyncExternalStore!==void 0?n.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Es}var Dp;function wj(){return Dp||(Dp=1,process.env.NODE_ENV==="production"?Vo.exports=bj():Vo.exports=_j()),Vo.exports}var xj=wj(),gw=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)},we=(e,t,r)=>(gw(e,t,"read from private field"),r?r.call(e):t.get(e)),Ot=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)},Yt=(e,t,r,o)=>(gw(e,t,"write to private field"),t.set(e,r),r);function $j(e,t){return t!=null?yj(e,t):e}var it,ni,oi,kn,En,Tn,Dr,mu,hu,Sj=class{constructor(e=[]){Ot(this,it,void 0),Ot(this,ni,"ready"),Ot(this,oi,void 0),Ot(this,kn,new Set),Ot(this,En,new Set),Ot(this,Tn,new Set),this.pushMessage=t=>{Yt(this,it,we(this,it).concat(t)),we(this,Dr).call(this)},this.popMessage=()=>{Yt(this,it,we(this,it).slice(0,-1)),we(this,Dr).call(this)},this.replaceMessage=(t,r)=>{Yt(this,it,[...we(this,it).slice(0,t),this.snapshot(r),...we(this,it).slice(t+1)]),we(this,Dr).call(this)},this.snapshot=t=>structuredClone(t),this["~registerMessagesCallback"]=(t,r)=>{const o=r?$j(t,r):t;return we(this,kn).add(o),()=>{we(this,kn).delete(o)}},this["~registerStatusCallback"]=t=>(we(this,En).add(t),()=>{we(this,En).delete(t)}),this["~registerErrorCallback"]=t=>(we(this,Tn).add(t),()=>{we(this,Tn).delete(t)}),Ot(this,Dr,()=>{we(this,kn).forEach(t=>t())}),Ot(this,mu,()=>{we(this,En).forEach(t=>t())}),Ot(this,hu,()=>{we(this,Tn).forEach(t=>t())}),Yt(this,it,e)}get status(){return we(this,ni)}set status(e){Yt(this,ni,e),we(this,mu).call(this)}get error(){return we(this,oi)}set error(e){Yt(this,oi,e),we(this,hu).call(this)}get messages(){return we(this,it)}set messages(e){Yt(this,it,[...e]),we(this,Dr).call(this)}};it=new WeakMap;ni=new WeakMap;oi=new WeakMap;kn=new WeakMap;En=new WeakMap;Tn=new WeakMap;Dr=new WeakMap;mu=new WeakMap;hu=new WeakMap;var Ur,Up=class extends sj{constructor({messages:t,...r}){const o=new Sj(t);super({...r,state:o}),Ot(this,Ur,void 0),this["~registerMessagesCallback"]=(n,i)=>we(this,Ur)["~registerMessagesCallback"](n,i),this["~registerStatusCallback"]=n=>we(this,Ur)["~registerStatusCallback"](n),this["~registerErrorCallback"]=n=>we(this,Ur)["~registerErrorCallback"](n),Yt(this,Ur,o)}};Ur=new WeakMap;function Ij({experimental_throttle:e,resume:t=!1,...r}={}){const o=z.useRef("chat"in r?r.chat:new Up(r));("chat"in r&&r.chat!==o.current||"id"in r&&o.current.id!==r.id)&&(o.current="chat"in r?r.chat:new Up(r));const i=z.useCallback(c=>o.current["~registerMessagesCallback"](c,e),[e,o.current.id]),a=z.useSyncExternalStore(i,()=>o.current.messages,()=>o.current.messages),s=z.useSyncExternalStore(o.current["~registerStatusCallback"],()=>o.current.status,()=>o.current.status),l=z.useSyncExternalStore(o.current["~registerErrorCallback"],()=>o.current.error,()=>o.current.error),u=z.useCallback(c=>{typeof c=="function"&&(c=c(o.current.messages)),o.current.messages=c},[o]);return z.useEffect(()=>{t&&o.current.resumeStream()},[t,o]),{id:o.current.id,messages:a,setMessages:u,sendMessage:o.current.sendMessage,regenerate:o.current.regenerate,clearError:o.current.clearError,stop:o.current.stop,error:l,resumeStream:o.current.resumeStream,status:s,addToolResult:o.current.addToolOutput,addToolOutput:o.current.addToolOutput}}const kj=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r.description?{description:r.description}:void 0,parameters:r.parameters instanceof vi.ZodType?vi.toJSONSchema(r.parameters):r.parameters}])),Ej=e=>Object.fromEntries(Object.entries(e).filter(([,t])=>!t.disabled&&t.type!=="backend"));class Lp extends hw{runtime;constructor(t){super({...t,prepareSendMessagesRequest:async r=>{const o=this.runtime?.thread.getModelContext(),n=(await this.runtime?.threads.mainItem.initialize())?.remoteId??r.id,i={...r,body:{callSettings:o?.callSettings,system:o?.system,tools:kj(Ej(o?.tools??{})),...r?.body}},a=await t?.prepareSendMessagesRequest?.(i);return{...a,body:a?.body??{...i.body,id:n,messages:r.messages,trigger:r.trigger,messageId:r.messageId,metadata:r.requestMetadata}}}})}setRuntime(t){this.runtime=t}}const Tj=e=>{const t=z.useRef(e);return z.useEffect(()=>{t.current=e}),z.useMemo(()=>new Proxy(t.current,{get(o,n){const i=t.current[n];return typeof i=="function"?i.bind(t.current):i}}),[])},Oj=e=>{const{adapters:t,transport:r,toCreateMessage:o,...n}=e??{},i=Tj(r??new Lp),a=L.useAssistantState(({threadListItem:u})=>u.id),s=Ij({...n,id:a,transport:i}),l=hj(s,{adapters:t,...o&&{toCreateMessage:o}});return i instanceof Lp&&i.setRuntime(l),l},Nj=({cloud:e,...t}={})=>{const r=L.unstable_useCloudThreadListAdapter({cloud:e});return L.unstable_useRemoteThreadListRuntime({runtimeHook:function(){return Oj(t)},adapter:r,allowNesting:!0})},Pj=e=>Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r.description?{description:r.description}:void 0,inputSchema:Va(r.parameters)}]));var Cj=Object.defineProperty,jj=Object.defineProperties,Aj=Object.getOwnPropertyDescriptors,Zp=Object.getOwnPropertySymbols,Rj=Object.prototype.hasOwnProperty,zj=Object.prototype.propertyIsEnumerable,Fp=(e,t,r)=>t in e?Cj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ue=(e,t)=>{for(var r in t||(t={}))Rj.call(t,r)&&Fp(e,r,t[r]);if(Zp)for(var r of Zp(t))zj.call(t,r)&&Fp(e,r,t[r]);return e},Ai=(e,t)=>jj(e,Aj(t)),vw="vercel.ai.error",Mj=Symbol.for(vw),yw,Dj=class bw extends Error{constructor({name:t,message:r,cause:o}){super(r),this[yw]=!0,this.name=t,this.cause=o}static isInstance(t){return bw.hasMarker(t,vw)}static hasMarker(t,r){const o=Symbol.for(r);return t!=null&&typeof t=="object"&&o in t&&typeof t[o]=="boolean"&&t[o]===!0}};yw=Mj;var Ne=Dj,_w="AI_APICallError",ww=`vercel.ai.error.${_w}`,Uj=Symbol.for(ww),xw,xt=class extends Ne{constructor({message:e,url:t,requestBodyValues:r,statusCode:o,responseHeaders:n,responseBody:i,cause:a,isRetryable:s=o!=null&&(o===408||o===409||o===429||o>=500),data:l}){super({name:_w,message:e,cause:a}),this[xw]=!0,this.url=t,this.requestBodyValues=r,this.statusCode=o,this.responseHeaders=n,this.responseBody=i,this.isRetryable=s,this.data=l}static isInstance(e){return Ne.hasMarker(e,ww)}};xw=Uj;var $w="AI_EmptyResponseBodyError",Sw=`vercel.ai.error.${$w}`,Lj=Symbol.for(Sw),Iw,Zj=class extends Ne{constructor({message:e="Empty response body"}={}){super({name:$w,message:e}),this[Iw]=!0}static isInstance(e){return Ne.hasMarker(e,Sw)}};Iw=Lj;function kw(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}var Ew="AI_InvalidArgumentError",Tw=`vercel.ai.error.${Ew}`,Fj=Symbol.for(Tw),Ow,Nw=class extends Ne{constructor({message:t,cause:r,argument:o}){super({name:Ew,message:t,cause:r}),this[Ow]=!0,this.argument=o}static isInstance(t){return Ne.hasMarker(t,Tw)}};Ow=Fj;var Pw="AI_InvalidPromptError",Cw=`vercel.ai.error.${Pw}`,qj=Symbol.for(Cw),jw,Vj=class extends Ne{constructor({prompt:e,message:t,cause:r}){super({name:Pw,message:`Invalid prompt: ${t}`,cause:r}),this[jw]=!0,this.prompt=e}static isInstance(e){return Ne.hasMarker(e,Cw)}};jw=qj;var Aw="AI_InvalidResponseDataError",Rw=`vercel.ai.error.${Aw}`,Bj=Symbol.for(Rw),zw,wn=class extends Ne{constructor({data:e,message:t=`Invalid response data: ${JSON.stringify(e)}.`}){super({name:Aw,message:t}),this[zw]=!0,this.data=e}static isInstance(e){return Ne.hasMarker(e,Rw)}};zw=Bj;var Mw="AI_JSONParseError",Dw=`vercel.ai.error.${Mw}`,Jj=Symbol.for(Dw),Uw,Ri=class extends Ne{constructor({text:e,cause:t}){super({name:Mw,message:`JSON parsing failed: Text: ${e}.
|
|
38
|
+
Error message: ${kw(t)}`,cause:t}),this[Uw]=!0,this.text=e}static isInstance(e){return Ne.hasMarker(e,Dw)}};Uw=Jj;var Lw="AI_LoadAPIKeyError",Zw=`vercel.ai.error.${Lw}`,Wj=Symbol.for(Zw),Fw,Bo=class extends Ne{constructor({message:e}){super({name:Lw,message:e}),this[Fw]=!0}static isInstance(e){return Ne.hasMarker(e,Zw)}};Fw=Wj;var qw="AI_NoContentGeneratedError",Vw=`vercel.ai.error.${qw}`,Hj=Symbol.for(Vw),Bw,Jw=class extends Ne{constructor({message:e="No content generated."}={}){super({name:qw,message:e}),this[Bw]=!0}static isInstance(e){return Ne.hasMarker(e,Vw)}};Bw=Hj;var Ww="AI_TypeValidationError",Hw=`vercel.ai.error.${Ww}`,Gj=Symbol.for(Hw),Gw,Kj=class gu extends Ne{constructor({value:t,cause:r}){super({name:Ww,message:`Type validation failed: Value: ${JSON.stringify(t)}.
|
|
39
|
+
Error message: ${kw(r)}`,cause:r}),this[Gw]=!0,this.value=t}static isInstance(t){return Ne.hasMarker(t,Hw)}static wrap({value:t,cause:r}){return gu.isInstance(r)&&r.value===t?r:new gu({value:t,cause:r})}};Gw=Gj;var qn=Kj,Kw="AI_UnsupportedFunctionalityError",Yw=`vercel.ai.error.${Kw}`,Yj=Symbol.for(Yw),Qw,Xt=class extends Ne{constructor({functionality:e,message:t=`'${e}' functionality not supported.`}){super({name:Kw,message:t}),this[Qw]=!0,this.functionality=e}static isInstance(e){return Ne.hasMarker(e,Yw)}};Qw=Yj;var qp=class extends Error{constructor(e,t){super(e),this.name="ParseError",this.type=t.type,this.field=t.field,this.value=t.value,this.line=t.line}};function Ts(e){}function Qj(e){if(typeof e=="function")throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");const{onEvent:t=Ts,onError:r=Ts,onRetry:o=Ts,onComment:n}=e;let i="",a=!0,s,l="",u="";function c(h){const b=a?h.replace(/^\xEF\xBB\xBF/,""):h,[y,x]=Xj(`${i}${b}`);for(const $ of y)d($);i=x,a=!1}function d(h){if(h===""){p();return}if(h.startsWith(":")){n&&n(h.slice(h.startsWith(": ")?2:1));return}const b=h.indexOf(":");if(b!==-1){const y=h.slice(0,b),x=h[b+1]===" "?2:1,$=h.slice(b+x);f(y,$,h);return}f(h,"",h)}function f(h,b,y){switch(h){case"event":u=b;break;case"data":l=`${l}${b}
|
|
40
40
|
`;break;case"id":s=b.includes("\0")?void 0:b;break;case"retry":/^\d+$/.test(b)?o(parseInt(b,10)):r(new qp(`Invalid \`retry\` value: "${b}"`,{type:"invalid-retry",value:b,line:y}));break;default:r(new qp(`Unknown field "${h.length>20?`${h.slice(0,20)}…`:h}"`,{type:"unknown-field",field:h,value:b,line:y}));break}}function p(){l.length>0&&t({id:s,event:u||void 0,data:l.endsWith(`
|
|
41
|
-
`)?l.slice(0,-1):l}),s=void 0,l="",u=""}function g(h={}){i&&h.consume&&d(i),a=!0,s=void 0,l="",u="",i=""}return{feed:c,reset:g}}function
|
|
41
|
+
`)?l.slice(0,-1):l}),s=void 0,l="",u=""}function g(h={}){i&&h.consume&&d(i),a=!0,s=void 0,l="",u="",i=""}return{feed:c,reset:g}}function Xj(e){const t=[];let r="",o=0;for(;o<e.length;){const n=e.indexOf("\r",o),i=e.indexOf(`
|
|
42
42
|
`,o);let a=-1;if(n!==-1&&i!==-1?a=Math.min(n,i):n!==-1?a=n:i!==-1&&(a=i),a===-1){r=e.slice(o);break}else{const s=e.slice(o,a);t.push(s),o=a+1,e[o-1]==="\r"&&e[o]===`
|
|
43
|
-
`&&o++}}return[t,r]}var
|
|
43
|
+
`&&o++}}return[t,r]}var e1=class extends TransformStream{constructor({onError:e,onRetry:t,onComment:r}={}){let o;super({start(n){o=Qj({onEvent:i=>{n.enqueue(i)},onError(i){e==="terminate"?n.error(i):typeof e=="function"&&e(i)},onRetry:t,onComment:r})},transform(n){o.feed(n)}})}};new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Vn(...e){return e.reduce((t,r)=>ue(ue({},t),r??{}),{})}function Ba(e){return Object.fromEntries([...e.headers])}var t1=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const n=()=>{const i=r.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=r[Math.random()*i|0];return a.join("")};if(e==null)return n;if(r.includes(o))throw new Nw({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${r}".`});return()=>`${e}${o}${n()}`},bt=t1();function vu(e){return(e instanceof Error||e instanceof DOMException)&&(e.name==="AbortError"||e.name==="ResponseAborted"||e.name==="TimeoutError")}var r1=["fetch failed","failed to fetch"];function n1({error:e,url:t,requestBodyValues:r}){if(vu(e))return e;if(e instanceof TypeError&&r1.includes(e.message.toLowerCase())){const o=e.cause;if(o!=null)return new xt({message:`Cannot connect to API: ${o.message}`,cause:o,url:t,requestBodyValues:r,isRetryable:!0})}return e}function o1(e){return Object.fromEntries(Object.entries(e).filter(([t,r])=>r!=null))}function i1({apiKey:e,environmentVariableName:t,apiKeyParameterName:r="apiKey",description:o}){if(typeof e=="string")return e;if(e!=null)throw new Bo({message:`${o} API key must be a string.`});if(typeof process>"u")throw new Bo({message:`${o} API key is missing. Pass it using the '${r}' parameter. Environment variables is not supported in this environment.`});if(e=process.env[t],e==null)throw new Bo({message:`${o} API key is missing. Pass it using the '${r}' parameter or the ${t} environment variable.`});if(typeof e!="string")throw new Bo({message:`${o} API key must be a string. The value of the ${t} environment variable is not a string.`});return e}var a1=/"__proto__"\s*:/,s1=/"constructor"\s*:/;function u1(e){const t=JSON.parse(e);return t===null||typeof t!="object"||a1.test(e)===!1&&s1.test(e)===!1?t:l1(t)}function l1(e){let t=[e];for(;t.length;){const r=t;t=[];for(const o of r){if(Object.prototype.hasOwnProperty.call(o,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const n in o){const i=o[n];i&&typeof i=="object"&&t.push(i)}}}return e}function Dc(e){const{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return u1(e)}finally{Error.stackTraceLimit=t}}var yu=Symbol.for("vercel.ai.validator");function c1(e){return{[yu]:!0,validate:e}}function d1(e){return typeof e=="object"&&e!==null&&yu in e&&e[yu]===!0&&"validate"in e}function p1(e){return d1(e)?e:f1(e)}function f1(e){return c1(async t=>{const r=await e["~standard"].validate(t);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new qn({value:t,cause:r.issues})}})}async function m1({value:e,schema:t}){const r=await Xw({value:e,schema:t});if(!r.success)throw qn.wrap({value:e,cause:r.error});return r.value}async function Xw({value:e,schema:t}){const r=p1(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const o=await r.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:qn.wrap({value:e,cause:o.error}),rawValue:e}}catch(o){return{success:!1,error:qn.wrap({value:e,cause:o}),rawValue:e}}}async function h1({text:e,schema:t}){try{const r=Dc(e);return t==null?r:m1({value:r,schema:t})}catch(r){throw Ri.isInstance(r)||qn.isInstance(r)?r:new Ri({text:e,cause:r})}}async function ex({text:e,schema:t}){try{const r=Dc(e);return t==null?{success:!0,value:r,rawValue:r}:await Xw({value:r,schema:t})}catch(r){return{success:!1,error:Ri.isInstance(r)?r:new Ri({text:e,cause:r}),rawValue:void 0}}}function Os(e){try{return Dc(e),!0}catch{return!1}}function g1({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new e1).pipeThrough(new TransformStream({async transform({data:r},o){r!=="[DONE]"&&o.enqueue(await ex({text:r,schema:t}))}}))}var v1=()=>globalThis.fetch,Bn=async({url:e,headers:t,body:r,failedResponseHandler:o,successfulResponseHandler:n,abortSignal:i,fetch:a})=>y1({url:e,headers:ue({"Content-Type":"application/json"},t),body:{content:JSON.stringify(r),values:r},failedResponseHandler:o,successfulResponseHandler:n,abortSignal:i,fetch:a}),y1=async({url:e,headers:t={},body:r,successfulResponseHandler:o,failedResponseHandler:n,abortSignal:i,fetch:a=v1()})=>{try{const s=await a(e,{method:"POST",headers:o1(t),body:r.content,signal:i}),l=Ba(s);if(!s.ok){let u;try{u=await n({response:s,url:e,requestBodyValues:r.values})}catch(c){throw vu(c)||xt.isInstance(c)?c:new xt({message:"Failed to process error response",cause:c,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw u.value}try{return await o({response:s,url:e,requestBodyValues:r.values})}catch(u){throw u instanceof Error&&(vu(u)||xt.isInstance(u))?u:new xt({message:"Failed to process successful response",cause:u,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(s){throw n1({error:s,url:e,requestBodyValues:r.values})}},b1=({errorSchema:e,errorToMessage:t,isRetryable:r})=>async({response:o,url:n,requestBodyValues:i})=>{const a=await o.text(),s=Ba(o);if(a.trim()==="")return{responseHeaders:s,value:new xt({message:o.statusText,url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:r?.(o)})};try{const l=await h1({text:a,schema:e});return{responseHeaders:s,value:new xt({message:t(l),url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,data:l,isRetryable:r?.(o,l)})}}catch{return{responseHeaders:s,value:new xt({message:o.statusText,url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:r?.(o)})}}},tx=e=>async({response:t})=>{const r=Ba(t);if(t.body==null)throw new Zj({});return{responseHeaders:r,value:g1({stream:t.body,schema:e})}},Uc=e=>async({response:t,url:r,requestBodyValues:o})=>{const n=await t.text(),i=await ex({text:n,schema:e}),a=Ba(t);if(!i.success)throw new xt({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:a,responseBody:n,url:r,requestBodyValues:o});return{responseHeaders:a,value:i.value,rawValue:i.rawValue}},{btoa:_1}=globalThis;function w1(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCodePoint(e[r]);return _1(t)}function x1(e){return e?.replace(/\/$/,"")}function Ns(e){return e!=null}var rx=(e=>(e.Unknown="unknown",e.OpenAIResponsesV1="openai-responses-v1",e.XAIResponsesV1="xai-responses-v1",e.AnthropicClaudeV1="anthropic-claude-v1",e.GoogleGeminiV1="google-gemini-v1",e))(rx||{}),Lc=E({id:w().nullish(),format:dr(rx).nullish(),index:q().optional()}).loose(),$1=E({type:C("reasoning.summary"),summary:w()}).extend(Lc.shape),S1=E({type:C("reasoning.encrypted"),data:w()}).extend(Lc.shape),I1=E({type:C("reasoning.text"),text:w().nullish(),signature:w().nullish()}).extend(Lc.shape),Zc=G([$1,S1,I1]),ii=G([Zc,$e().transform(()=>null)]),Fc=R(ii).transform(e=>e.filter(t=>!!t));G([E({delta:E({reasoning_details:R(ii)})}).transform(e=>e.delta.reasoning_details.filter(Ns)),E({message:E({reasoning_details:R(ii)})}).transform(e=>e.message.reasoning_details.filter(Ns)),E({text:w(),reasoning_details:R(ii)}).transform(e=>e.reasoning_details.filter(Ns))]);var Ja=E({error:E({code:G([w(),q()]).nullable().optional().default(null),message:w(),type:w().nullable().optional().default(null),param:Pe().nullable().optional().default(null)}).passthrough()}).passthrough(),Jn=b1({errorSchema:Ja,errorToMessage:e=>e.error.message}),nx=E({type:C("file"),file:E({hash:w(),name:w(),content:R(E({type:w(),text:w().optional()}).catchall(Pe())).optional()}).catchall(Pe())}).catchall(Pe()),k1=E({provider:w(),reasoning_details:R(Zc).optional(),annotations:R(nx).optional(),usage:E({promptTokens:q(),promptTokensDetails:E({cachedTokens:q()}).catchall(Pe()).optional(),completionTokens:q(),completionTokensDetails:E({reasoningTokens:q()}).catchall(Pe()).optional(),totalTokens:q(),cost:q().optional(),costDetails:E({upstreamInferenceCost:q()}).catchall(Pe()).optional()}).catchall(Pe())}).catchall(Pe()),Vp=E({openrouter:E({reasoning_details:R(Zc).optional(),annotations:R(nx).optional()}).optional()}).optional();function zi(e){switch(e){case"stop":return"stop";case"length":return"length";case"content_filter":return"content-filter";case"function_call":case"tool_calls":return"tool-calls";default:return"unknown"}}var E1=["wav","mp3","aiff","aac","ogg","flac","m4a","pcm16","pcm24"];function qc({url:e,protocols:t}){try{const r=new URL(e);return t.has(r.protocol)}catch{return!1}}function bu({part:e,defaultMediaType:t}){var r,o;if(e.data instanceof Uint8Array){const i=w1(e.data);return`data:${(r=e.mediaType)!=null?r:t};base64,${i}`}const n=e.data.toString();return qc({url:n,protocols:new Set(["http:","https:"])})||n.startsWith("data:")?n:`data:${(o=e.mediaType)!=null?o:t};base64,${n}`}function Bp(e,t){var r;const o=e.match(/^data:([^;]+)/);return o&&(r=o[1])!=null?r:t}function _u(e){const t=e.match(/^data:[^;]*;base64,(.+)$/);return t?t[1]:e}var T1={mpeg:"mp3",mp3:"mp3","x-wav":"wav",wave:"wav",wav:"wav",ogg:"ogg",vorbis:"ogg",aac:"aac","x-aac":"aac",m4a:"m4a","x-m4a":"m4a",mp4:"m4a",aiff:"aiff","x-aiff":"aiff",flac:"flac","x-flac":"flac",pcm16:"pcm16",pcm24:"pcm24"};function O1(e){const t=bu({part:e,defaultMediaType:"audio/mpeg"});if(qc({url:t,protocols:new Set(["http:","https:"])}))throw new Error(`Audio files cannot be provided as URLs.
|
|
44
44
|
|
|
45
45
|
OpenRouter requires audio to be base64-encoded. Please:
|
|
46
46
|
1. Download the audio file locally
|
|
@@ -49,24 +49,24 @@ OpenRouter requires audio to be base64-encoded. Please:
|
|
|
49
49
|
|
|
50
50
|
The AI SDK will automatically handle base64 encoding.
|
|
51
51
|
|
|
52
|
-
Learn more: https://openrouter.ai/docs/features/multimodal/audio`);const r=_u(t),o=e.mediaType||"audio/mpeg",n=o.replace("audio/",""),i=
|
|
52
|
+
Learn more: https://openrouter.ai/docs/features/multimodal/audio`);const r=_u(t),o=e.mediaType||"audio/mpeg",n=o.replace("audio/",""),i=T1[n];if(i===void 0){const a=E1.join(", ");throw new Error(`Unsupported audio format: "${o}"
|
|
53
53
|
|
|
54
54
|
OpenRouter supports the following audio formats: ${a}
|
|
55
55
|
|
|
56
|
-
Learn more: https://openrouter.ai/docs/features/multimodal/audio`)}return{data:r,format:i}}function Kt(e){var t,r,o;const n=e?.anthropic,i=e?.openrouter;return(o=(r=(t=i?.cacheControl)!=null?t:i?.cache_control)!=null?r:n?.cacheControl)!=null?o:n?.cache_control}function O1(e){var t,r,o,n,i,a,s,l,u,c;const d=[];for(const{role:f,content:p,providerOptions:g}of e)switch(f){case"system":{d.push({role:"system",content:p,cache_control:Kt(g)});break}case"user":{if(p.length===1&&((t=p[0])==null?void 0:t.type)==="text"){const y=(r=Kt(g))!=null?r:Kt(p[0].providerOptions),x=y?[{type:"text",text:p[0].text,cache_control:y}]:p[0].text;d.push({role:"user",content:x});break}const h=Kt(g),b=p.map(y=>{var x,$,v,k,N,I,O;const z=(x=Kt(y.providerOptions))!=null?x:h;switch(y.type){case"text":return{type:"text",text:y.text,cache_control:z};case"file":{if(($=y.mediaType)!=null&&$.startsWith("image/"))return{type:"image_url",image_url:{url:bu({part:y,defaultMediaType:"image/jpeg"})},cache_control:z};if((v=y.mediaType)!=null&&v.startsWith("audio/"))return{type:"input_audio",input_audio:T1(y),cache_control:z};const F=String((O=(I=(N=(k=y.providerOptions)==null?void 0:k.openrouter)==null?void 0:N.filename)!=null?I:y.filename)!=null?O:""),te=bu({part:y,defaultMediaType:"application/pdf"});return qc({url:te,protocols:new Set(["http:","https:"])})?{type:"file",file:{filename:F,file_data:te}}:{type:"file",file:{filename:F,file_data:te},cache_control:z}}default:return{type:"text",text:"",cache_control:z}}});d.push({role:"user",content:b});break}case"assistant":{let h="",b="";const y=[],x=[];for(const I of p)switch(I.type){case"text":{h+=I.text;break}case"tool-call":{const O=(o=I.providerOptions)==null?void 0:o.openrouter;O?.reasoning_details&&Array.isArray(O.reasoning_details)&&x.push(...O.reasoning_details),y.push({id:I.toolCallId,type:"function",function:{name:I.toolName,arguments:JSON.stringify(I.input)}});break}case"reasoning":{b+=I.text;const O=Vp.safeParse(I.providerOptions);O.success&&((i=(n=O.data)==null?void 0:n.openrouter)!=null&&i.reasoning_details)&&x.push(...O.data.openrouter.reasoning_details);break}}const $=Vp.safeParse(g),v=$.success?(s=(a=$.data)==null?void 0:a.openrouter)==null?void 0:s.reasoning_details:void 0,k=$.success?(u=(l=$.data)==null?void 0:l.openrouter)==null?void 0:u.annotations:void 0,N=v&&Array.isArray(v)&&v.length>0?v:x.length>0?x:void 0;d.push({role:"assistant",content:h,tool_calls:y.length>0?y:void 0,reasoning:b||void 0,reasoning_details:N,annotations:k,cache_control:Kt(g)});break}case"tool":{for(const h of p){const b=N1(h);d.push({role:"tool",tool_call_id:h.toolCallId,content:b,cache_control:(c=Kt(g))!=null?c:Kt(h.providerOptions)})}break}}return d}function N1(e){return e.output.type==="text"?e.output.value:JSON.stringify(e.output.value)}G([C("auto"),C("none"),C("required"),E({type:C("function"),function:E({name:w()})})]);function P1(e){switch(e.type){case"auto":case"none":case"required":return e.type;case"tool":return{type:"function",function:{name:e.toolName}};default:throw new Nw({argument:"toolChoice",message:`Invalid tool choice type: ${JSON.stringify(e)}`})}}var C1=E({type:C("image_url"),image_url:E({url:w()}).passthrough()}).passthrough(),j1=G([C1,$e().transform(()=>null)]),ox=R(j1).transform(e=>e.filter(t=>!!t)),ix=E({id:w().optional(),model:w().optional(),provider:w().optional(),usage:E({prompt_tokens:q(),prompt_tokens_details:E({cached_tokens:q()}).passthrough().nullish(),completion_tokens:q(),completion_tokens_details:E({reasoning_tokens:q()}).passthrough().nullish(),total_tokens:q(),cost:q().optional(),cost_details:E({upstream_inference_cost:q().nullish()}).passthrough().nullish()}).passthrough().nullish()}).passthrough(),A1=G([ix.extend({choices:R(E({message:E({role:C("assistant"),content:w().nullable().optional(),reasoning:w().nullable().optional(),reasoning_details:Fc.nullish(),images:ox.nullish(),tool_calls:R(E({id:w().optional().nullable(),type:C("function"),function:E({name:w(),arguments:w()}).passthrough()}).passthrough()).optional(),annotations:R(G([E({type:C("url_citation"),url_citation:E({end_index:q(),start_index:q(),title:w(),url:w(),content:w().optional()}).passthrough()}).passthrough(),E({type:C("file_annotation"),file_annotation:E({file_id:w(),quote:w().optional()}).passthrough()}).passthrough(),E({type:C("file"),file:E({hash:w(),name:w(),content:R(E({type:w(),text:w().optional()}).passthrough()).optional()}).passthrough()}).passthrough()])).nullish()}).passthrough(),index:q().nullish(),logprobs:E({content:R(E({token:w(),logprob:q(),top_logprobs:R(E({token:w(),logprob:q()}).passthrough())}).passthrough()).nullable()}).passthrough().nullable().optional(),finish_reason:w().optional().nullable()}).passthrough())}),Ba.extend({user_id:w().optional()})]),R1=G([ix.extend({choices:R(E({delta:E({role:dr(["assistant"]).optional(),content:w().nullish(),reasoning:w().nullish().optional(),reasoning_details:Fc.nullish(),images:ox.nullish(),tool_calls:R(E({index:q().nullish(),id:w().nullish(),type:C("function").optional(),function:E({name:w().nullish(),arguments:w().nullish()}).passthrough()}).passthrough()).nullish(),annotations:R(G([E({type:C("url_citation"),url_citation:E({end_index:q(),start_index:q(),title:w(),url:w(),content:w().optional()}).passthrough()}).passthrough(),E({type:C("file_annotation"),file_annotation:E({file_id:w(),quote:w().optional()}).passthrough()}).passthrough(),E({type:C("file"),file:E({hash:w(),name:w(),content:R(E({type:w(),text:w().optional()}).passthrough()).optional()}).passthrough()}).passthrough()])).nullish()}).passthrough().nullish(),logprobs:E({content:R(E({token:w(),logprob:q(),top_logprobs:R(E({token:w(),logprob:q()}).passthrough())}).passthrough()).nullable()}).passthrough().nullish(),finish_reason:w().nullable().optional(),index:q().nullish()}).passthrough())}),Ba]),z1=class{constructor(e,t,r){this.specificationVersion="v2",this.provider="openrouter",this.defaultObjectGenerationMode="tool",this.supportsImageUrls=!0,this.supportedUrls={"image/*":[/^data:image\/[a-zA-Z]+;base64,/,/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)$/i],"application/*":[/^data:application\//,/^https?:\/\/.+$/]},this.modelId=e,this.settings=t,this.config=r}getArgs({prompt:e,maxOutputTokens:t,temperature:r,topP:o,frequencyPenalty:n,presencePenalty:i,seed:a,stopSequences:s,responseFormat:l,topK:u,tools:c,toolChoice:d}){var f;const p=ue(ue({model:this.modelId,models:this.settings.models,logit_bias:this.settings.logitBias,logprobs:this.settings.logprobs===!0||typeof this.settings.logprobs=="number"?!0:void 0,top_logprobs:typeof this.settings.logprobs=="number"?this.settings.logprobs:typeof this.settings.logprobs=="boolean"&&this.settings.logprobs?0:void 0,user:this.settings.user,parallel_tool_calls:this.settings.parallelToolCalls,max_tokens:t,temperature:r,top_p:o,frequency_penalty:n,presence_penalty:i,seed:a,stop:s,response_format:l?.type==="json"?l.schema!=null?{type:"json_schema",json_schema:ue({schema:l.schema,strict:!0,name:(f=l.name)!=null?f:"response"},l.description&&{description:l.description})}:{type:"json_object"}:void 0,top_k:u,messages:O1(e),include_reasoning:this.settings.includeReasoning,reasoning:this.settings.reasoning,usage:this.settings.usage,plugins:this.settings.plugins,web_search_options:this.settings.web_search_options,provider:this.settings.provider,debug:this.settings.debug},this.config.extraBody),this.settings.extraBody);if(c&&c.length>0){const g=c.filter(h=>h.type==="function").map(h=>({type:"function",function:{name:h.name,description:h.description,parameters:h.inputSchema}}));return ji(ue({},p),{tools:g,tool_choice:d?P1(d):void 0})}return p}async doGenerate(e){var t,r,o,n,i,a,s,l,u,c,d,f,p,g,h,b,y,x,$,v,k,N,I;const z=(e.providerOptions||{}).openrouter||{},F=ue(ue({},this.getArgs(e)),z),{value:te,responseHeaders:ie}=await Bn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:F,failedResponseHandler:Jn,successfulResponseHandler:Uc(A1),abortSignal:e.abortSignal,fetch:this.config.fetch});if("error"in te){const U=te.error;throw new xt({message:U.message,url:this.config.url({path:"/chat/completions",modelId:this.modelId}),requestBodyValues:F,statusCode:200,responseHeaders:ie,data:U})}const J=te,V=J.choices[0];if(!V)throw new Jw({message:"No choice in response"});const we=J.usage?{inputTokens:(t=J.usage.prompt_tokens)!=null?t:0,outputTokens:(r=J.usage.completion_tokens)!=null?r:0,totalTokens:((o=J.usage.prompt_tokens)!=null?o:0)+((n=J.usage.completion_tokens)!=null?n:0),reasoningTokens:(a=(i=J.usage.completion_tokens_details)==null?void 0:i.reasoning_tokens)!=null?a:0,cachedInputTokens:(l=(s=J.usage.prompt_tokens_details)==null?void 0:s.cached_tokens)!=null?l:0}:{inputTokens:0,outputTokens:0,totalTokens:0,reasoningTokens:0,cachedInputTokens:0},oe=(u=V.message.reasoning_details)!=null?u:[],de=oe.length>0?oe.map(U=>{switch(U.type){case"reasoning.text":{if(U.text)return{type:"reasoning",text:U.text,providerMetadata:{openrouter:{reasoning_details:[U]}}};break}case"reasoning.summary":{if(U.summary)return{type:"reasoning",text:U.summary,providerMetadata:{openrouter:{reasoning_details:[U]}}};break}case"reasoning.encrypted":{if(U.data)return{type:"reasoning",text:"[REDACTED]",providerMetadata:{openrouter:{reasoning_details:[U]}}};break}}return null}).filter(U=>U!==null):V.message.reasoning?[{type:"reasoning",text:V.message.reasoning}]:[],K=[];if(K.push(...de),V.message.content&&K.push({type:"text",text:V.message.content}),V.message.tool_calls)for(const U of V.message.tool_calls)K.push({type:"tool-call",toolCallId:(c=U.id)!=null?c:bt(),toolName:U.function.name,input:U.function.arguments,providerMetadata:{openrouter:{reasoning_details:oe}}});if(V.message.images)for(const U of V.message.images)K.push({type:"file",mediaType:Bp(U.image_url.url,"image/jpeg"),data:_u(U.image_url.url)});if(V.message.annotations)for(const U of V.message.annotations)U.type==="url_citation"&&K.push({type:"source",sourceType:"url",id:U.url_citation.url,url:U.url_citation.url,title:U.url_citation.title,providerMetadata:{openrouter:{content:U.url_citation.content||""}}});const fe=(d=V.message.annotations)==null?void 0:d.filter(U=>U.type==="file"),B=V.message.tool_calls&&V.message.tool_calls.length>0,Ue=oe.some(U=>U.type==="reasoning.encrypted"&&U.data),Le=B&&Ue&&V.finish_reason==="stop"?"tool-calls":Ri(V.finish_reason);return{content:K,finishReason:Le,usage:we,warnings:[],providerMetadata:{openrouter:I1.parse({provider:(f=J.provider)!=null?f:"",reasoning_details:(p=V.message.reasoning_details)!=null?p:[],annotations:fe&&fe.length>0?fe:void 0,usage:ue(ue(ue({promptTokens:(g=we.inputTokens)!=null?g:0,completionTokens:(h=we.outputTokens)!=null?h:0,totalTokens:(b=we.totalTokens)!=null?b:0,cost:(y=J.usage)==null?void 0:y.cost},(($=(x=J.usage)==null?void 0:x.prompt_tokens_details)==null?void 0:$.cached_tokens)!=null?{promptTokensDetails:{cachedTokens:J.usage.prompt_tokens_details.cached_tokens}}:{}),((k=(v=J.usage)==null?void 0:v.completion_tokens_details)==null?void 0:k.reasoning_tokens)!=null?{completionTokensDetails:{reasoningTokens:J.usage.completion_tokens_details.reasoning_tokens}}:{}),((I=(N=J.usage)==null?void 0:N.cost_details)==null?void 0:I.upstream_inference_cost)!=null?{costDetails:{upstreamInferenceCost:J.usage.cost_details.upstream_inference_cost}}:{})})},request:{body:F},response:{id:J.id,modelId:J.model,headers:ie}}}async doStream(e){var t;const o=(e.providerOptions||{}).openrouter||{},n=ue(ue({},this.getArgs(e)),o),{value:i,responseHeaders:a}=await Bn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:ji(ue({},n),{stream:!0,stream_options:this.config.compatibility==="strict"?ue({include_usage:!0},(t=this.settings.usage)!=null&&t.include?{include_usage:!0}:{}):void 0}),failedResponseHandler:Jn,successfulResponseHandler:tx(R1),abortSignal:e.abortSignal,fetch:this.config.fetch}),s=[];let l="other";const u={inputTokens:Number.NaN,outputTokens:Number.NaN,totalTokens:Number.NaN,reasoningTokens:Number.NaN,cachedInputTokens:Number.NaN},c={},d=[],f=[];let p=!1,g=!1,h,b,y,x;return{stream:i.pipeThrough(new TransformStream({transform($,v){var k,N,I,O,z,F,te,ie,J,V,we,oe,de,K,fe;if(!$.success){l="error",v.enqueue({type:"error",error:$.error});return}const B=$.value;if("error"in B){l="error",v.enqueue({type:"error",error:B.error});return}if(B.provider&&(x=B.provider),B.id&&(y=B.id,v.enqueue({type:"response-metadata",id:B.id})),B.model&&v.enqueue({type:"response-metadata",modelId:B.model}),B.usage!=null){if(u.inputTokens=B.usage.prompt_tokens,u.outputTokens=B.usage.completion_tokens,u.totalTokens=B.usage.prompt_tokens+B.usage.completion_tokens,c.promptTokens=B.usage.prompt_tokens,B.usage.prompt_tokens_details){const Q=(k=B.usage.prompt_tokens_details.cached_tokens)!=null?k:0;u.cachedInputTokens=Q,c.promptTokensDetails={cachedTokens:Q}}if(c.completionTokens=B.usage.completion_tokens,B.usage.completion_tokens_details){const Q=(N=B.usage.completion_tokens_details.reasoning_tokens)!=null?N:0;u.reasoningTokens=Q,c.completionTokensDetails={reasoningTokens:Q}}c.cost=B.usage.cost,c.totalTokens=B.usage.total_tokens;const U=(I=B.usage.cost_details)==null?void 0:I.upstream_inference_cost;U!=null&&(c.costDetails={upstreamInferenceCost:U})}const Ue=B.choices[0];if(Ue?.finish_reason!=null&&(l=Ri(Ue.finish_reason)),Ue?.delta==null)return;const ye=Ue.delta,Le=(U,Q)=>{g||(b=y||bt(),v.enqueue({providerMetadata:Q,type:"reasoning-start",id:b}),g=!0),v.enqueue({providerMetadata:Q,type:"reasoning-delta",delta:U,id:b||bt()})};if(ye.reasoning_details&&ye.reasoning_details.length>0){for(const Q of ye.reasoning_details)if(Q.type==="reasoning.text"){const me=d[d.length-1];me?.type==="reasoning.text"?(me.text=(me.text||"")+(Q.text||""),me.signature=me.signature||Q.signature,me.format=me.format||Q.format):d.push(ue({},Q))}else d.push(Q);const U={openrouter:{reasoning_details:ye.reasoning_details}};for(const Q of ye.reasoning_details)switch(Q.type){case"reasoning.text":{Q.text&&Le(Q.text,U);break}case"reasoning.encrypted":{Q.data&&Le("[REDACTED]",U);break}case"reasoning.summary":{Q.summary&&Le(Q.summary,U);break}}}else ye.reasoning&&Le(ye.reasoning);if(ye.content&&(g&&!p&&(v.enqueue({type:"reasoning-end",id:b||bt()}),g=!1),p||(h=y||bt(),v.enqueue({type:"text-start",id:h}),p=!0),v.enqueue({type:"text-delta",delta:ye.content,id:h||bt()})),ye.annotations){for(const U of ye.annotations)if(U.type==="url_citation")v.enqueue({type:"source",sourceType:"url",id:U.url_citation.url,url:U.url_citation.url,title:U.url_citation.title,providerMetadata:{openrouter:{content:U.url_citation.content||""}}});else if(U.type==="file"){const Q=U.file;Q&&typeof Q=="object"&&"hash"in Q&&"name"in Q&&f.push(U)}}if(ye.tool_calls!=null)for(const U of ye.tool_calls){const Q=(O=U.index)!=null?O:s.length-1;if(s[Q]==null){if(U.type!=="function")throw new wn({data:U,message:"Expected 'function' type."});if(U.id==null)throw new wn({data:U,message:"Expected 'id' to be a string."});if(((z=U.function)==null?void 0:z.name)==null)throw new wn({data:U,message:"Expected 'function.name' to be a string."});s[Q]={id:U.id,type:"function",function:{name:U.function.name,arguments:(F=U.function.arguments)!=null?F:""},inputStarted:!1,sent:!1};const xe=s[Q];if(xe==null)throw new wn({data:{index:Q,toolCallsLength:s.length},message:`Tool call at index ${Q} is missing after creation.`});((te=xe.function)==null?void 0:te.name)!=null&&((ie=xe.function)==null?void 0:ie.arguments)!=null&&Ts(xe.function.arguments)&&(xe.inputStarted=!0,v.enqueue({type:"tool-input-start",id:xe.id,toolName:xe.function.name}),v.enqueue({type:"tool-input-delta",id:xe.id,delta:xe.function.arguments}),v.enqueue({type:"tool-input-end",id:xe.id}),v.enqueue({type:"tool-call",toolCallId:xe.id,toolName:xe.function.name,input:xe.function.arguments,providerMetadata:{openrouter:{reasoning_details:d}}}),xe.sent=!0);continue}const me=s[Q];if(me==null)throw new wn({data:{index:Q,toolCallsLength:s.length,toolCallDelta:U},message:`Tool call at index ${Q} is missing during merge.`});me.inputStarted||(me.inputStarted=!0,v.enqueue({type:"tool-input-start",id:me.id,toolName:me.function.name})),((J=U.function)==null?void 0:J.arguments)!=null&&(me.function.arguments+=(we=(V=U.function)==null?void 0:V.arguments)!=null?we:""),v.enqueue({type:"tool-input-delta",id:me.id,delta:(oe=U.function.arguments)!=null?oe:""}),((de=me.function)==null?void 0:de.name)!=null&&((K=me.function)==null?void 0:K.arguments)!=null&&Ts(me.function.arguments)&&(v.enqueue({type:"tool-call",toolCallId:(fe=me.id)!=null?fe:bt(),toolName:me.function.name,input:me.function.arguments,providerMetadata:{openrouter:{reasoning_details:d}}}),me.sent=!0)}if(ye.images!=null)for(const U of ye.images)v.enqueue({type:"file",mediaType:Bp(U.image_url.url,"image/jpeg"),data:_u(U.image_url.url)})},flush($){var v;const k=s.length>0,N=d.some(O=>O.type==="reasoning.encrypted"&&O.data);if(k&&N&&l==="stop"&&(l="tool-calls"),l==="tool-calls")for(const O of s)O&&!O.sent&&($.enqueue({type:"tool-call",toolCallId:(v=O.id)!=null?v:bt(),toolName:O.function.name,input:Ts(O.function.arguments)?O.function.arguments:"{}",providerMetadata:{openrouter:{reasoning_details:d}}}),O.sent=!0);g&&$.enqueue({type:"reasoning-end",id:b||bt()}),p&&$.enqueue({type:"text-end",id:h||bt()});const I={usage:c};x!==void 0&&(I.provider=x),d.length>0&&(I.reasoning_details=d),f.length>0&&(I.annotations=f),$.enqueue({type:"finish",finishReason:l,usage:u,providerMetadata:{openrouter:I}})}})),warnings:[],request:{body:n},response:{headers:a}}}};function M1({prompt:e,inputFormat:t,user:r="user",assistant:o="assistant"}){if(e.length===1&&e[0]&&e[0].role==="user"&&e[0].content.length===1&&e[0].content[0]&&e[0].content[0].type==="text")return{prompt:e[0].content[0].text};let n="";e[0]&&e[0].role==="system"&&(n+=`${e[0].content}
|
|
56
|
+
Learn more: https://openrouter.ai/docs/features/multimodal/audio`)}return{data:r,format:i}}function Kt(e){var t,r,o;const n=e?.anthropic,i=e?.openrouter;return(o=(r=(t=i?.cacheControl)!=null?t:i?.cache_control)!=null?r:n?.cacheControl)!=null?o:n?.cache_control}function N1(e){var t,r,o,n,i,a,s,l,u,c;const d=[];for(const{role:f,content:p,providerOptions:g}of e)switch(f){case"system":{d.push({role:"system",content:p,cache_control:Kt(g)});break}case"user":{if(p.length===1&&((t=p[0])==null?void 0:t.type)==="text"){const y=(r=Kt(g))!=null?r:Kt(p[0].providerOptions),x=y?[{type:"text",text:p[0].text,cache_control:y}]:p[0].text;d.push({role:"user",content:x});break}const h=Kt(g),b=p.map(y=>{var x,$,v,k,N,I,O;const M=(x=Kt(y.providerOptions))!=null?x:h;switch(y.type){case"text":return{type:"text",text:y.text,cache_control:M};case"file":{if(($=y.mediaType)!=null&&$.startsWith("image/"))return{type:"image_url",image_url:{url:bu({part:y,defaultMediaType:"image/jpeg"})},cache_control:M};if((v=y.mediaType)!=null&&v.startsWith("audio/"))return{type:"input_audio",input_audio:O1(y),cache_control:M};const F=String((O=(I=(N=(k=y.providerOptions)==null?void 0:k.openrouter)==null?void 0:N.filename)!=null?I:y.filename)!=null?O:""),te=bu({part:y,defaultMediaType:"application/pdf"});return qc({url:te,protocols:new Set(["http:","https:"])})?{type:"file",file:{filename:F,file_data:te}}:{type:"file",file:{filename:F,file_data:te},cache_control:M}}default:return{type:"text",text:"",cache_control:M}}});d.push({role:"user",content:b});break}case"assistant":{let h="",b="";const y=[],x=[];for(const I of p)switch(I.type){case"text":{h+=I.text;break}case"tool-call":{const O=(o=I.providerOptions)==null?void 0:o.openrouter;O?.reasoning_details&&Array.isArray(O.reasoning_details)&&x.push(...O.reasoning_details),y.push({id:I.toolCallId,type:"function",function:{name:I.toolName,arguments:JSON.stringify(I.input)}});break}case"reasoning":{b+=I.text;const O=Vp.safeParse(I.providerOptions);O.success&&((i=(n=O.data)==null?void 0:n.openrouter)!=null&&i.reasoning_details)&&x.push(...O.data.openrouter.reasoning_details);break}}const $=Vp.safeParse(g),v=$.success?(s=(a=$.data)==null?void 0:a.openrouter)==null?void 0:s.reasoning_details:void 0,k=$.success?(u=(l=$.data)==null?void 0:l.openrouter)==null?void 0:u.annotations:void 0,N=v&&Array.isArray(v)&&v.length>0?v:x.length>0?x:void 0;d.push({role:"assistant",content:h,tool_calls:y.length>0?y:void 0,reasoning:b||void 0,reasoning_details:N,annotations:k,cache_control:Kt(g)});break}case"tool":{for(const h of p){const b=P1(h);d.push({role:"tool",tool_call_id:h.toolCallId,content:b,cache_control:(c=Kt(g))!=null?c:Kt(h.providerOptions)})}break}}return d}function P1(e){return e.output.type==="text"?e.output.value:JSON.stringify(e.output.value)}G([C("auto"),C("none"),C("required"),E({type:C("function"),function:E({name:w()})})]);function C1(e){switch(e.type){case"auto":case"none":case"required":return e.type;case"tool":return{type:"function",function:{name:e.toolName}};default:throw new Nw({argument:"toolChoice",message:`Invalid tool choice type: ${JSON.stringify(e)}`})}}var j1=E({type:C("image_url"),image_url:E({url:w()}).passthrough()}).passthrough(),A1=G([j1,$e().transform(()=>null)]),ox=R(A1).transform(e=>e.filter(t=>!!t)),ix=E({id:w().optional(),model:w().optional(),provider:w().optional(),usage:E({prompt_tokens:q(),prompt_tokens_details:E({cached_tokens:q()}).passthrough().nullish(),completion_tokens:q(),completion_tokens_details:E({reasoning_tokens:q()}).passthrough().nullish(),total_tokens:q(),cost:q().optional(),cost_details:E({upstream_inference_cost:q().nullish()}).passthrough().nullish()}).passthrough().nullish()}).passthrough(),R1=G([ix.extend({choices:R(E({message:E({role:C("assistant"),content:w().nullable().optional(),reasoning:w().nullable().optional(),reasoning_details:Fc.nullish(),images:ox.nullish(),tool_calls:R(E({id:w().optional().nullable(),type:C("function"),function:E({name:w(),arguments:w()}).passthrough()}).passthrough()).optional(),annotations:R(G([E({type:C("url_citation"),url_citation:E({end_index:q(),start_index:q(),title:w(),url:w(),content:w().optional()}).passthrough()}).passthrough(),E({type:C("file_annotation"),file_annotation:E({file_id:w(),quote:w().optional()}).passthrough()}).passthrough(),E({type:C("file"),file:E({hash:w(),name:w(),content:R(E({type:w(),text:w().optional()}).passthrough()).optional()}).passthrough()}).passthrough()])).nullish()}).passthrough(),index:q().nullish(),logprobs:E({content:R(E({token:w(),logprob:q(),top_logprobs:R(E({token:w(),logprob:q()}).passthrough())}).passthrough()).nullable()}).passthrough().nullable().optional(),finish_reason:w().optional().nullable()}).passthrough())}),Ja.extend({user_id:w().optional()})]),z1=G([ix.extend({choices:R(E({delta:E({role:dr(["assistant"]).optional(),content:w().nullish(),reasoning:w().nullish().optional(),reasoning_details:Fc.nullish(),images:ox.nullish(),tool_calls:R(E({index:q().nullish(),id:w().nullish(),type:C("function").optional(),function:E({name:w().nullish(),arguments:w().nullish()}).passthrough()}).passthrough()).nullish(),annotations:R(G([E({type:C("url_citation"),url_citation:E({end_index:q(),start_index:q(),title:w(),url:w(),content:w().optional()}).passthrough()}).passthrough(),E({type:C("file_annotation"),file_annotation:E({file_id:w(),quote:w().optional()}).passthrough()}).passthrough(),E({type:C("file"),file:E({hash:w(),name:w(),content:R(E({type:w(),text:w().optional()}).passthrough()).optional()}).passthrough()}).passthrough()])).nullish()}).passthrough().nullish(),logprobs:E({content:R(E({token:w(),logprob:q(),top_logprobs:R(E({token:w(),logprob:q()}).passthrough())}).passthrough()).nullable()}).passthrough().nullish(),finish_reason:w().nullable().optional(),index:q().nullish()}).passthrough())}),Ja]),M1=class{constructor(e,t,r){this.specificationVersion="v2",this.provider="openrouter",this.defaultObjectGenerationMode="tool",this.supportsImageUrls=!0,this.supportedUrls={"image/*":[/^data:image\/[a-zA-Z]+;base64,/,/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)$/i],"application/*":[/^data:application\//,/^https?:\/\/.+$/]},this.modelId=e,this.settings=t,this.config=r}getArgs({prompt:e,maxOutputTokens:t,temperature:r,topP:o,frequencyPenalty:n,presencePenalty:i,seed:a,stopSequences:s,responseFormat:l,topK:u,tools:c,toolChoice:d}){var f;const p=ue(ue({model:this.modelId,models:this.settings.models,logit_bias:this.settings.logitBias,logprobs:this.settings.logprobs===!0||typeof this.settings.logprobs=="number"?!0:void 0,top_logprobs:typeof this.settings.logprobs=="number"?this.settings.logprobs:typeof this.settings.logprobs=="boolean"&&this.settings.logprobs?0:void 0,user:this.settings.user,parallel_tool_calls:this.settings.parallelToolCalls,max_tokens:t,temperature:r,top_p:o,frequency_penalty:n,presence_penalty:i,seed:a,stop:s,response_format:l?.type==="json"?l.schema!=null?{type:"json_schema",json_schema:ue({schema:l.schema,strict:!0,name:(f=l.name)!=null?f:"response"},l.description&&{description:l.description})}:{type:"json_object"}:void 0,top_k:u,messages:N1(e),include_reasoning:this.settings.includeReasoning,reasoning:this.settings.reasoning,usage:this.settings.usage,plugins:this.settings.plugins,web_search_options:this.settings.web_search_options,provider:this.settings.provider,debug:this.settings.debug},this.config.extraBody),this.settings.extraBody);if(c&&c.length>0){const g=c.filter(h=>h.type==="function").map(h=>({type:"function",function:{name:h.name,description:h.description,parameters:h.inputSchema}}));return Ai(ue({},p),{tools:g,tool_choice:d?C1(d):void 0})}return p}async doGenerate(e){var t,r,o,n,i,a,s,l,u,c,d,f,p,g,h,b,y,x,$,v,k,N,I;const M=(e.providerOptions||{}).openrouter||{},F=ue(ue({},this.getArgs(e)),M),{value:te,responseHeaders:oe}=await Bn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:F,failedResponseHandler:Jn,successfulResponseHandler:Uc(R1),abortSignal:e.abortSignal,fetch:this.config.fetch});if("error"in te){const U=te.error;throw new xt({message:U.message,url:this.config.url({path:"/chat/completions",modelId:this.modelId}),requestBodyValues:F,statusCode:200,responseHeaders:oe,data:U})}const J=te,V=J.choices[0];if(!V)throw new Jw({message:"No choice in response"});const ye=J.usage?{inputTokens:(t=J.usage.prompt_tokens)!=null?t:0,outputTokens:(r=J.usage.completion_tokens)!=null?r:0,totalTokens:((o=J.usage.prompt_tokens)!=null?o:0)+((n=J.usage.completion_tokens)!=null?n:0),reasoningTokens:(a=(i=J.usage.completion_tokens_details)==null?void 0:i.reasoning_tokens)!=null?a:0,cachedInputTokens:(l=(s=J.usage.prompt_tokens_details)==null?void 0:s.cached_tokens)!=null?l:0}:{inputTokens:0,outputTokens:0,totalTokens:0,reasoningTokens:0,cachedInputTokens:0},ie=(u=V.message.reasoning_details)!=null?u:[],de=ie.length>0?ie.map(U=>{switch(U.type){case"reasoning.text":{if(U.text)return{type:"reasoning",text:U.text,providerMetadata:{openrouter:{reasoning_details:[U]}}};break}case"reasoning.summary":{if(U.summary)return{type:"reasoning",text:U.summary,providerMetadata:{openrouter:{reasoning_details:[U]}}};break}case"reasoning.encrypted":{if(U.data)return{type:"reasoning",text:"[REDACTED]",providerMetadata:{openrouter:{reasoning_details:[U]}}};break}}return null}).filter(U=>U!==null):V.message.reasoning?[{type:"reasoning",text:V.message.reasoning}]:[],K=[];if(K.push(...de),V.message.content&&K.push({type:"text",text:V.message.content}),V.message.tool_calls)for(const U of V.message.tool_calls)K.push({type:"tool-call",toolCallId:(c=U.id)!=null?c:bt(),toolName:U.function.name,input:U.function.arguments,providerMetadata:{openrouter:{reasoning_details:ie}}});if(V.message.images)for(const U of V.message.images)K.push({type:"file",mediaType:Bp(U.image_url.url,"image/jpeg"),data:_u(U.image_url.url)});if(V.message.annotations)for(const U of V.message.annotations)U.type==="url_citation"&&K.push({type:"source",sourceType:"url",id:U.url_citation.url,url:U.url_citation.url,title:U.url_citation.title,providerMetadata:{openrouter:{content:U.url_citation.content||""}}});const fe=(d=V.message.annotations)==null?void 0:d.filter(U=>U.type==="file"),B=V.message.tool_calls&&V.message.tool_calls.length>0,Ue=ie.some(U=>U.type==="reasoning.encrypted"&&U.data),Le=B&&Ue&&V.finish_reason==="stop"?"tool-calls":zi(V.finish_reason);return{content:K,finishReason:Le,usage:ye,warnings:[],providerMetadata:{openrouter:k1.parse({provider:(f=J.provider)!=null?f:"",reasoning_details:(p=V.message.reasoning_details)!=null?p:[],annotations:fe&&fe.length>0?fe:void 0,usage:ue(ue(ue({promptTokens:(g=ye.inputTokens)!=null?g:0,completionTokens:(h=ye.outputTokens)!=null?h:0,totalTokens:(b=ye.totalTokens)!=null?b:0,cost:(y=J.usage)==null?void 0:y.cost},(($=(x=J.usage)==null?void 0:x.prompt_tokens_details)==null?void 0:$.cached_tokens)!=null?{promptTokensDetails:{cachedTokens:J.usage.prompt_tokens_details.cached_tokens}}:{}),((k=(v=J.usage)==null?void 0:v.completion_tokens_details)==null?void 0:k.reasoning_tokens)!=null?{completionTokensDetails:{reasoningTokens:J.usage.completion_tokens_details.reasoning_tokens}}:{}),((I=(N=J.usage)==null?void 0:N.cost_details)==null?void 0:I.upstream_inference_cost)!=null?{costDetails:{upstreamInferenceCost:J.usage.cost_details.upstream_inference_cost}}:{})})},request:{body:F},response:{id:J.id,modelId:J.model,headers:oe}}}async doStream(e){var t;const o=(e.providerOptions||{}).openrouter||{},n=ue(ue({},this.getArgs(e)),o),{value:i,responseHeaders:a}=await Bn({url:this.config.url({path:"/chat/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:Ai(ue({},n),{stream:!0,stream_options:this.config.compatibility==="strict"?ue({include_usage:!0},(t=this.settings.usage)!=null&&t.include?{include_usage:!0}:{}):void 0}),failedResponseHandler:Jn,successfulResponseHandler:tx(z1),abortSignal:e.abortSignal,fetch:this.config.fetch}),s=[];let l="other";const u={inputTokens:Number.NaN,outputTokens:Number.NaN,totalTokens:Number.NaN,reasoningTokens:Number.NaN,cachedInputTokens:Number.NaN},c={},d=[],f=[];let p=!1,g=!1,h,b,y,x;return{stream:i.pipeThrough(new TransformStream({transform($,v){var k,N,I,O,M,F,te,oe,J,V,ye,ie,de,K,fe;if(!$.success){l="error",v.enqueue({type:"error",error:$.error});return}const B=$.value;if("error"in B){l="error",v.enqueue({type:"error",error:B.error});return}if(B.provider&&(x=B.provider),B.id&&(y=B.id,v.enqueue({type:"response-metadata",id:B.id})),B.model&&v.enqueue({type:"response-metadata",modelId:B.model}),B.usage!=null){if(u.inputTokens=B.usage.prompt_tokens,u.outputTokens=B.usage.completion_tokens,u.totalTokens=B.usage.prompt_tokens+B.usage.completion_tokens,c.promptTokens=B.usage.prompt_tokens,B.usage.prompt_tokens_details){const Q=(k=B.usage.prompt_tokens_details.cached_tokens)!=null?k:0;u.cachedInputTokens=Q,c.promptTokensDetails={cachedTokens:Q}}if(c.completionTokens=B.usage.completion_tokens,B.usage.completion_tokens_details){const Q=(N=B.usage.completion_tokens_details.reasoning_tokens)!=null?N:0;u.reasoningTokens=Q,c.completionTokensDetails={reasoningTokens:Q}}c.cost=B.usage.cost,c.totalTokens=B.usage.total_tokens;const U=(I=B.usage.cost_details)==null?void 0:I.upstream_inference_cost;U!=null&&(c.costDetails={upstreamInferenceCost:U})}const Ue=B.choices[0];if(Ue?.finish_reason!=null&&(l=zi(Ue.finish_reason)),Ue?.delta==null)return;const be=Ue.delta,Le=(U,Q)=>{g||(b=y||bt(),v.enqueue({providerMetadata:Q,type:"reasoning-start",id:b}),g=!0),v.enqueue({providerMetadata:Q,type:"reasoning-delta",delta:U,id:b||bt()})};if(be.reasoning_details&&be.reasoning_details.length>0){for(const Q of be.reasoning_details)if(Q.type==="reasoning.text"){const me=d[d.length-1];me?.type==="reasoning.text"?(me.text=(me.text||"")+(Q.text||""),me.signature=me.signature||Q.signature,me.format=me.format||Q.format):d.push(ue({},Q))}else d.push(Q);const U={openrouter:{reasoning_details:be.reasoning_details}};for(const Q of be.reasoning_details)switch(Q.type){case"reasoning.text":{Q.text&&Le(Q.text,U);break}case"reasoning.encrypted":{Q.data&&Le("[REDACTED]",U);break}case"reasoning.summary":{Q.summary&&Le(Q.summary,U);break}}}else be.reasoning&&Le(be.reasoning);if(be.content&&(g&&!p&&(v.enqueue({type:"reasoning-end",id:b||bt()}),g=!1),p||(h=y||bt(),v.enqueue({type:"text-start",id:h}),p=!0),v.enqueue({type:"text-delta",delta:be.content,id:h||bt()})),be.annotations){for(const U of be.annotations)if(U.type==="url_citation")v.enqueue({type:"source",sourceType:"url",id:U.url_citation.url,url:U.url_citation.url,title:U.url_citation.title,providerMetadata:{openrouter:{content:U.url_citation.content||""}}});else if(U.type==="file"){const Q=U.file;Q&&typeof Q=="object"&&"hash"in Q&&"name"in Q&&f.push(U)}}if(be.tool_calls!=null)for(const U of be.tool_calls){const Q=(O=U.index)!=null?O:s.length-1;if(s[Q]==null){if(U.type!=="function")throw new wn({data:U,message:"Expected 'function' type."});if(U.id==null)throw new wn({data:U,message:"Expected 'id' to be a string."});if(((M=U.function)==null?void 0:M.name)==null)throw new wn({data:U,message:"Expected 'function.name' to be a string."});s[Q]={id:U.id,type:"function",function:{name:U.function.name,arguments:(F=U.function.arguments)!=null?F:""},inputStarted:!1,sent:!1};const xe=s[Q];if(xe==null)throw new wn({data:{index:Q,toolCallsLength:s.length},message:`Tool call at index ${Q} is missing after creation.`});((te=xe.function)==null?void 0:te.name)!=null&&((oe=xe.function)==null?void 0:oe.arguments)!=null&&Os(xe.function.arguments)&&(xe.inputStarted=!0,v.enqueue({type:"tool-input-start",id:xe.id,toolName:xe.function.name}),v.enqueue({type:"tool-input-delta",id:xe.id,delta:xe.function.arguments}),v.enqueue({type:"tool-input-end",id:xe.id}),v.enqueue({type:"tool-call",toolCallId:xe.id,toolName:xe.function.name,input:xe.function.arguments,providerMetadata:{openrouter:{reasoning_details:d}}}),xe.sent=!0);continue}const me=s[Q];if(me==null)throw new wn({data:{index:Q,toolCallsLength:s.length,toolCallDelta:U},message:`Tool call at index ${Q} is missing during merge.`});me.inputStarted||(me.inputStarted=!0,v.enqueue({type:"tool-input-start",id:me.id,toolName:me.function.name})),((J=U.function)==null?void 0:J.arguments)!=null&&(me.function.arguments+=(ye=(V=U.function)==null?void 0:V.arguments)!=null?ye:""),v.enqueue({type:"tool-input-delta",id:me.id,delta:(ie=U.function.arguments)!=null?ie:""}),((de=me.function)==null?void 0:de.name)!=null&&((K=me.function)==null?void 0:K.arguments)!=null&&Os(me.function.arguments)&&(v.enqueue({type:"tool-call",toolCallId:(fe=me.id)!=null?fe:bt(),toolName:me.function.name,input:me.function.arguments,providerMetadata:{openrouter:{reasoning_details:d}}}),me.sent=!0)}if(be.images!=null)for(const U of be.images)v.enqueue({type:"file",mediaType:Bp(U.image_url.url,"image/jpeg"),data:_u(U.image_url.url)})},flush($){var v;const k=s.length>0,N=d.some(O=>O.type==="reasoning.encrypted"&&O.data);if(k&&N&&l==="stop"&&(l="tool-calls"),l==="tool-calls")for(const O of s)O&&!O.sent&&($.enqueue({type:"tool-call",toolCallId:(v=O.id)!=null?v:bt(),toolName:O.function.name,input:Os(O.function.arguments)?O.function.arguments:"{}",providerMetadata:{openrouter:{reasoning_details:d}}}),O.sent=!0);g&&$.enqueue({type:"reasoning-end",id:b||bt()}),p&&$.enqueue({type:"text-end",id:h||bt()});const I={usage:c};x!==void 0&&(I.provider=x),d.length>0&&(I.reasoning_details=d),f.length>0&&(I.annotations=f),$.enqueue({type:"finish",finishReason:l,usage:u,providerMetadata:{openrouter:I}})}})),warnings:[],request:{body:n},response:{headers:a}}}};function D1({prompt:e,inputFormat:t,user:r="user",assistant:o="assistant"}){if(e.length===1&&e[0]&&e[0].role==="user"&&e[0].content.length===1&&e[0].content[0]&&e[0].content[0].type==="text")return{prompt:e[0].content[0].text};let n="";e[0]&&e[0].role==="system"&&(n+=`${e[0].content}
|
|
57
57
|
|
|
58
|
-
`,e=e.slice(1));for(const{role:i,content:a}of e)switch(i){case"system":throw new
|
|
58
|
+
`,e=e.slice(1));for(const{role:i,content:a}of e)switch(i){case"system":throw new Vj({message:`Unexpected system message in prompt: ${a}`,prompt:e});case"user":{const s=a.map(l=>{switch(l.type){case"text":return l.text;case"file":throw new Xt({functionality:"file attachments"});default:return""}}).join("");n+=`${r}:
|
|
59
59
|
${s}
|
|
60
60
|
|
|
61
61
|
`;break}case"assistant":{const s=a.map(l=>{switch(l.type){case"text":return l.text;case"tool-call":throw new Xt({functionality:"tool-call messages"});case"tool-result":throw new Xt({functionality:"tool-result messages"});case"reasoning":throw new Xt({functionality:"reasoning messages"});case"file":throw new Xt({functionality:"file attachments"});default:return""}}).join("");n+=`${o}:
|
|
62
62
|
${s}
|
|
63
63
|
|
|
64
64
|
`;break}case"tool":throw new Xt({functionality:"tool messages"})}return n+=`${o}:
|
|
65
|
-
`,{prompt:n}}var Jp=G([E({id:w().optional(),model:w().optional(),choices:R(E({text:w(),reasoning:w().nullish().optional(),reasoning_details:Fc.nullish(),finish_reason:w().nullish(),index:q().nullish(),logprobs:E({tokens:R(w()),token_logprobs:R(q()),top_logprobs:R(Xe(w(),q())).nullable()}).passthrough().nullable().optional()}).passthrough()),usage:E({prompt_tokens:q(),prompt_tokens_details:E({cached_tokens:q()}).passthrough().nullish(),completion_tokens:q(),completion_tokens_details:E({reasoning_tokens:q()}).passthrough().nullish(),total_tokens:q(),cost:q().optional(),cost_details:E({upstream_inference_cost:q().nullish()}).passthrough().nullish()}).passthrough().nullish()}).passthrough(),Ba]),D1=class{constructor(e,t,r){this.specificationVersion="v2",this.provider="openrouter",this.supportsImageUrls=!0,this.supportedUrls={"image/*":[/^data:image\/[a-zA-Z]+;base64,/,/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)$/i],"text/*":[/^data:text\//,/^https?:\/\/.+$/],"application/*":[/^data:application\//,/^https?:\/\/.+$/]},this.defaultObjectGenerationMode=void 0,this.modelId=e,this.settings=t,this.config=r}getArgs({prompt:e,maxOutputTokens:t,temperature:r,topP:o,frequencyPenalty:n,presencePenalty:i,seed:a,responseFormat:s,topK:l,stopSequences:u,tools:c,toolChoice:d}){const{prompt:f}=M1({prompt:e,inputFormat:"prompt"});if(c?.length)throw new Xt({functionality:"tools"});if(d)throw new Xt({functionality:"toolChoice"});return ue(ue({model:this.modelId,models:this.settings.models,logit_bias:this.settings.logitBias,logprobs:typeof this.settings.logprobs=="number"?this.settings.logprobs:typeof this.settings.logprobs=="boolean"&&this.settings.logprobs?0:void 0,suffix:this.settings.suffix,user:this.settings.user,max_tokens:t,temperature:r,top_p:o,frequency_penalty:n,presence_penalty:i,seed:a,stop:u,response_format:s,top_k:l,prompt:f,include_reasoning:this.settings.includeReasoning,reasoning:this.settings.reasoning},this.config.extraBody),this.settings.extraBody)}async doGenerate(e){var t,r,o,n,i,a,s,l,u,c,d,f,p,g,h;const y=(e.providerOptions||{}).openrouter||{},x=ue(ue({},this.getArgs(e)),y),{value:$,responseHeaders:v}=await Bn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:x,failedResponseHandler:Jn,successfulResponseHandler:Uc(Jp),abortSignal:e.abortSignal,fetch:this.config.fetch});if("error"in $){const N=$.error;throw new xt({message:N.message,url:this.config.url({path:"/completions",modelId:this.modelId}),requestBodyValues:x,statusCode:200,responseHeaders:v,data:N})}const k=$.choices[0];if(!k)throw new Jw({message:"No choice in OpenRouter completion response"});return{content:[{type:"text",text:(t=k.text)!=null?t:""}],finishReason:Ri(k.finish_reason),usage:{inputTokens:(o=(r=$.usage)==null?void 0:r.prompt_tokens)!=null?o:0,outputTokens:(i=(n=$.usage)==null?void 0:n.completion_tokens)!=null?i:0,totalTokens:((s=(a=$.usage)==null?void 0:a.prompt_tokens)!=null?s:0)+((u=(l=$.usage)==null?void 0:l.completion_tokens)!=null?u:0),reasoningTokens:(f=(d=(c=$.usage)==null?void 0:c.completion_tokens_details)==null?void 0:d.reasoning_tokens)!=null?f:0,cachedInputTokens:(h=(g=(p=$.usage)==null?void 0:p.prompt_tokens_details)==null?void 0:g.cached_tokens)!=null?h:0},warnings:[],response:{headers:v}}}async doStream(e){const r=(e.providerOptions||{}).openrouter||{},o=ue(ue({},this.getArgs(e)),r),{value:n,responseHeaders:i}=await Bn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:ji(ue({},o),{stream:!0,stream_options:this.config.compatibility==="strict"?{include_usage:!0}:void 0}),failedResponseHandler:Jn,successfulResponseHandler:tx(Jp),abortSignal:e.abortSignal,fetch:this.config.fetch});let a="other";const s={inputTokens:Number.NaN,outputTokens:Number.NaN,totalTokens:Number.NaN,reasoningTokens:Number.NaN,cachedInputTokens:Number.NaN},l={};return{stream:n.pipeThrough(new TransformStream({transform(u,c){var d,f,p;if(!u.success){a="error",c.enqueue({type:"error",error:u.error});return}const g=u.value;if("error"in g){a="error",c.enqueue({type:"error",error:g.error});return}if(g.usage!=null){if(s.inputTokens=g.usage.prompt_tokens,s.outputTokens=g.usage.completion_tokens,s.totalTokens=g.usage.prompt_tokens+g.usage.completion_tokens,l.promptTokens=g.usage.prompt_tokens,g.usage.prompt_tokens_details){const y=(d=g.usage.prompt_tokens_details.cached_tokens)!=null?d:0;s.cachedInputTokens=y,l.promptTokensDetails={cachedTokens:y}}if(l.completionTokens=g.usage.completion_tokens,g.usage.completion_tokens_details){const y=(f=g.usage.completion_tokens_details.reasoning_tokens)!=null?f:0;s.reasoningTokens=y,l.completionTokensDetails={reasoningTokens:y}}l.cost=g.usage.cost,l.totalTokens=g.usage.total_tokens;const b=(p=g.usage.cost_details)==null?void 0:p.upstream_inference_cost;b!=null&&(l.costDetails={upstreamInferenceCost:b})}const h=g.choices[0];h?.finish_reason!=null&&(a=Ri(h.finish_reason)),h?.text!=null&&c.enqueue({type:"text-delta",delta:h.text,id:bt()})},flush(u){u.enqueue({type:"finish",finishReason:a,usage:s,providerMetadata:{openrouter:{usage:l}}})}})),response:{headers:i}}}},U1=E({prompt_tokens:q(),total_tokens:q(),cost:q().optional()}),L1=E({object:C("embedding"),embedding:R(q()),index:q().optional()}),Z1=E({id:w().optional(),object:C("list"),data:R(L1),model:w(),usage:U1.optional()}),F1=class{constructor(e,t,r){this.specificationVersion="v2",this.provider="openrouter",this.maxEmbeddingsPerCall=void 0,this.supportsParallelCalls=!0,this.modelId=e,this.settings=t,this.config=r}async doEmbed(e){var t;const{values:r,abortSignal:o,headers:n}=e,i=ue(ue({model:this.modelId,input:r,user:this.settings.user,provider:this.settings.provider},this.config.extraBody),this.settings.extraBody),{value:a,responseHeaders:s}=await Bn({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:Vn(this.config.headers(),n),body:i,failedResponseHandler:Jn,successfulResponseHandler:Uc(Z1),abortSignal:o,fetch:this.config.fetch});return{embeddings:a.data.map(l=>l.embedding),usage:a.usage?{tokens:a.usage.prompt_tokens}:void 0,providerMetadata:(t=a.usage)!=null&&t.cost?{openrouter:{usage:{cost:a.usage.cost}}}:void 0,response:{headers:s,body:a}}}};function q1(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==null))}function V1(e,...t){const r=q1(e??{}),n=[r["user-agent"]||"",...t].filter(Boolean).join(" ");return ji(ue({},r),{"user-agent":n})}var B1="1.5.4";function ax(e={}){var t,r,o;const n=(r=w1((t=e.baseURL)!=null?t:e.baseUrl))!=null?r:"https://openrouter.ai/api/v1",i=(o=e.compatibility)!=null?o:"compatible",a=()=>V1(ue(ue({Authorization:`Bearer ${o1({apiKey:e.apiKey,environmentVariableName:"OPENROUTER_API_KEY",description:"OpenRouter"})}`},e.headers),e.api_keys&&Object.keys(e.api_keys).length>0&&{"X-Provider-API-Keys":JSON.stringify(e.api_keys)}),`ai-sdk/openrouter/${B1}`),s=(f,p={})=>new z1(f,p,{provider:"openrouter.chat",url:({path:g})=>`${n}${g}`,headers:a,compatibility:i,fetch:e.fetch,extraBody:e.extraBody}),l=(f,p={})=>new D1(f,p,{provider:"openrouter.completion",url:({path:g})=>`${n}${g}`,headers:a,compatibility:i,fetch:e.fetch,extraBody:e.extraBody}),u=(f,p={})=>new F1(f,p,{provider:"openrouter.embedding",url:({path:g})=>`${n}${g}`,headers:a,fetch:e.fetch,extraBody:e.extraBody}),c=(f,p)=>{if(new.target)throw new Error("The OpenRouter model function cannot be called with the new keyword.");return f==="openai/gpt-3.5-turbo-instruct"?l(f,p):s(f,p)},d=(f,p)=>c(f,p);return d.languageModel=c,d.chat=s,d.completion=l,d.textEmbeddingModel=u,d.embedding=u,d}ax({compatibility:"strict"});function wu(...e){return e.reduce((t,r)=>({...t,...r??{}}),{})}async function sx(e,t){if(e==null)return Promise.resolve();const r=t?.abortSignal;return new Promise((o,n)=>{if(r?.aborted){n(Wp());return}const i=setTimeout(()=>{a(),o()},e),a=()=>{clearTimeout(i),r?.removeEventListener("abort",s)},s=()=>{a(),n(Wp())};r?.addEventListener("abort",s)})}function Wp(){return new DOMException("Delay was aborted","AbortError")}function Oo(e){return Object.fromEntries([...e.headers])}var No=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const n=()=>{const i=r.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=r[Math.random()*i|0];return a.join("")};if(e==null)return n;if(r.includes(o))throw new Bi({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${r}".`});return()=>`${e}${o}${n()}`},J1=No();function ux(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}function wr(e){return(e instanceof Error||e instanceof DOMException)&&(e.name==="AbortError"||e.name==="ResponseAborted"||e.name==="TimeoutError")}var W1=["fetch failed","failed to fetch"];function lx({error:e,url:t,requestBodyValues:r}){if(wr(e))return e;if(e instanceof TypeError&&W1.includes(e.message.toLowerCase())){const o=e.cause;if(o!=null)return new Be({message:`Cannot connect to API: ${o.message}`,cause:o,url:t,requestBodyValues:r,isRetryable:!0})}return e}function Vc(e=globalThis){var t,r,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(r=e.process)==null?void 0:r.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function H1(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((r,o)=>{t[o.toLowerCase()]=r});else{Array.isArray(e)||(e=Object.entries(e));for(const[r,o]of e)o!=null&&(t[r.toLowerCase()]=o)}return t}function Ja(e,...t){const r=new Headers(H1(e)),o=r.get("user-agent")||"";return r.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var cx="3.0.16",G1=()=>globalThis.fetch,Hp=async({url:e,headers:t={},successfulResponseHandler:r,failedResponseHandler:o,abortSignal:n,fetch:i=G1()})=>{try{const a=await i(e,{method:"GET",headers:Ja(t,`ai-sdk/provider-utils/${cx}`,Vc()),signal:n}),s=Oo(a);if(!a.ok){let l;try{l=await o({response:a,url:e,requestBodyValues:{}})}catch(u){throw wr(u)||Be.isInstance(u)?u:new Be({message:"Failed to process error response",cause:u,statusCode:a.status,url:e,responseHeaders:s,requestBodyValues:{}})}throw l.value}try{return await r({response:a,url:e,requestBodyValues:{}})}catch(l){throw l instanceof Error&&(wr(l)||Be.isInstance(l))?l:new Be({message:"Failed to process successful response",cause:l,statusCode:a.status,url:e,responseHeaders:s,requestBodyValues:{}})}}catch(a){throw lx({error:a,url:e,requestBodyValues:{}})}};function K1({mediaType:e,url:t,supportedUrls:r}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(r).map(([o,n])=>{const i=o.toLowerCase();return i==="*"||i==="*/*"?{mediaTypePrefix:"",regexes:n}:{mediaTypePrefix:i.replace(/\*/,""),regexes:n}}).filter(({mediaTypePrefix:o})=>e.startsWith(o)).flatMap(({regexes:o})=>o).some(o=>o.test(t))}function ii({settingValue:e,environmentVariableName:t}){if(typeof e=="string")return e;if(!(e!=null||typeof process>"u")&&(e=process.env[t],!(e==null||typeof e!="string")))return e}var Y1=/"__proto__"\s*:/,Q1=/"constructor"\s*:/;function X1(e){const t=JSON.parse(e);return t===null||typeof t!="object"||Y1.test(e)===!1&&Q1.test(e)===!1?t:eA(t)}function eA(e){let t=[e];for(;t.length;){const r=t;t=[];for(const o of r){if(Object.prototype.hasOwnProperty.call(o,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const n in o){const i=o[n];i&&typeof i=="object"&&t.push(i)}}}return e}function dx(e){const{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return X1(e)}finally{Error.stackTraceLimit=t}}var zi=Symbol.for("vercel.ai.validator");function tA(e){return{[zi]:!0,validate:e}}function rA(e){return typeof e=="object"&&e!==null&&zi in e&&e[zi]===!0&&"validate"in e}function cn(e){let t;return()=>(t==null&&(t=e()),t)}function nA(e){return rA(e)?e:typeof e=="function"?e():oA(e)}function oA(e){return tA(async t=>{const r=await e["~standard"].validate(t);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new Ft({value:t,cause:r.issues})}})}async function xu({value:e,schema:t}){const r=await sr({value:e,schema:t});if(!r.success)throw Ft.wrap({value:e,cause:r.error});return r.value}async function sr({value:e,schema:t}){const r=nA(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const o=await r.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:Ft.wrap({value:e,cause:o.error}),rawValue:e}}catch(o){return{success:!1,error:Ft.wrap({value:e,cause:o}),rawValue:e}}}async function iA({text:e,schema:t}){try{const r=dx(e);return t==null?r:xu({value:r,schema:t})}catch(r){throw Jr.isInstance(r)||Ft.isInstance(r)?r:new Jr({text:e,cause:r})}}async function xr({text:e,schema:t}){try{const r=dx(e);return t==null?{success:!0,value:r,rawValue:r}:await sr({value:r,schema:t})}catch(r){return{success:!1,error:Jr.isInstance(r)?r:new Jr({text:e,cause:r}),rawValue:void 0}}}function aA({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).pipeThrough(new TransformStream({async transform({data:r},o){r!=="[DONE]"&&o.enqueue(await xr({text:r,schema:t}))}}))}var sA=()=>globalThis.fetch,$u=async({url:e,headers:t,body:r,failedResponseHandler:o,successfulResponseHandler:n,abortSignal:i,fetch:a})=>uA({url:e,headers:{"Content-Type":"application/json",...t},body:{content:JSON.stringify(r),values:r},failedResponseHandler:o,successfulResponseHandler:n,abortSignal:i,fetch:a}),uA=async({url:e,headers:t={},body:r,successfulResponseHandler:o,failedResponseHandler:n,abortSignal:i,fetch:a=sA()})=>{try{const s=await a(e,{method:"POST",headers:Ja(t,`ai-sdk/provider-utils/${cx}`,Vc()),body:r.content,signal:i}),l=Oo(s);if(!s.ok){let u;try{u=await n({response:s,url:e,requestBodyValues:r.values})}catch(c){throw wr(c)||Be.isInstance(c)?c:new Be({message:"Failed to process error response",cause:c,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw u.value}try{return await o({response:s,url:e,requestBodyValues:r.values})}catch(u){throw u instanceof Error&&(wr(u)||Be.isInstance(u))?u:new Be({message:"Failed to process successful response",cause:u,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(s){throw lx({error:s,url:e,requestBodyValues:r.values})}};async function tr(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var Wn=({errorSchema:e,errorToMessage:t,isRetryable:r})=>async({response:o,url:n,requestBodyValues:i})=>{const a=await o.text(),s=Oo(o);if(a.trim()==="")return{responseHeaders:s,value:new Be({message:o.statusText,url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:r?.(o)})};try{const l=await iA({text:a,schema:e});return{responseHeaders:s,value:new Be({message:t(l),url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,data:l,isRetryable:r?.(o,l)})}}catch{return{responseHeaders:s,value:new Be({message:o.statusText,url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:r?.(o)})}}},lA=e=>async({response:t})=>{const r=Oo(t);if(t.body==null)throw new T0({});return{responseHeaders:r,value:aA({stream:t.body,schema:e})}},Mi=e=>async({response:t,url:r,requestBodyValues:o})=>{const n=await t.text(),i=await xr({text:n,schema:e}),a=Oo(t);if(!i.success)throw new Be({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:a,responseBody:n,url:r,requestBodyValues:o});return{responseHeaders:a,value:i.value,rawValue:i.rawValue}},cA=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")},dA=Symbol("Let zodToJsonSchema decide on which parser to use"),Gp={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"},pA=e=>typeof e=="string"?{...Gp,name:e}:{...Gp,...e};function tt(){return{}}function fA(e,t){var r,o,n;const i={type:"array"};return(r=e.type)!=null&&r._def&&((n=(o=e.type)==null?void 0:o._def)==null?void 0:n.typeName)!==A.ZodAny&&(i.items=ce(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i}function mA(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function hA(){return{type:"boolean"}}function px(e,t){return ce(e.type._def,t)}var gA=(e,t)=>ce(e.innerType._def,t);function fx(e,t,r){const o=r??t.dateStrategy;if(Array.isArray(o))return{anyOf:o.map((n,i)=>fx(e,t,n))};switch(o){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return vA(e)}}var vA=e=>{const t={type:"integer",format:"unix-time"};for(const r of e.checks)switch(r.kind){case"min":t.minimum=r.value;break;case"max":t.maximum=r.value;break}return t};function yA(e,t){return{...ce(e.innerType._def,t),default:e.defaultValue()}}function bA(e,t){return t.effectStrategy==="input"?ce(e.schema._def,t):tt()}function _A(e){return{type:"string",enum:Array.from(e.values)}}var wA=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function xA(e,t){const r=[ce(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),ce(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(n=>!!n),o=[];return r.forEach(n=>{if(wA(n))o.push(...n.allOf);else{let i=n;if("additionalProperties"in n&&n.additionalProperties===!1){const{additionalProperties:a,...s}=n;i=s}o.push(i)}}),o.length?{allOf:o}:void 0}function $A(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var Ns=void 0,vt={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:()=>(Ns===void 0&&(Ns=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ns),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 mx(e,t){const r={type:"string"};if(e.checks)for(const o of e.checks)switch(o.kind){case"min":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value;break;case"max":r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"email":switch(t.emailStrategy){case"format:email":yt(r,"email",o.message,t);break;case"format:idn-email":yt(r,"idn-email",o.message,t);break;case"pattern:zod":qe(r,vt.email,o.message,t);break}break;case"url":yt(r,"uri",o.message,t);break;case"uuid":yt(r,"uuid",o.message,t);break;case"regex":qe(r,o.regex,o.message,t);break;case"cuid":qe(r,vt.cuid,o.message,t);break;case"cuid2":qe(r,vt.cuid2,o.message,t);break;case"startsWith":qe(r,RegExp(`^${Ps(o.value,t)}`),o.message,t);break;case"endsWith":qe(r,RegExp(`${Ps(o.value,t)}$`),o.message,t);break;case"datetime":yt(r,"date-time",o.message,t);break;case"date":yt(r,"date",o.message,t);break;case"time":yt(r,"time",o.message,t);break;case"duration":yt(r,"duration",o.message,t);break;case"length":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value,r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"includes":{qe(r,RegExp(Ps(o.value,t)),o.message,t);break}case"ip":{o.version!=="v6"&&yt(r,"ipv4",o.message,t),o.version!=="v4"&&yt(r,"ipv6",o.message,t);break}case"base64url":qe(r,vt.base64url,o.message,t);break;case"jwt":qe(r,vt.jwt,o.message,t);break;case"cidr":{o.version!=="v6"&&qe(r,vt.ipv4Cidr,o.message,t),o.version!=="v4"&&qe(r,vt.ipv6Cidr,o.message,t);break}case"emoji":qe(r,vt.emoji(),o.message,t);break;case"ulid":{qe(r,vt.ulid,o.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{yt(r,"binary",o.message,t);break}case"contentEncoding:base64":{r.contentEncoding="base64";break}case"pattern:zod":{qe(r,vt.base64,o.message,t);break}}break}case"nanoid":qe(r,vt.nanoid,o.message,t)}return r}function Ps(e,t){return t.patternStrategy==="escape"?IA(e):e}var SA=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function IA(e){let t="";for(let r=0;r<e.length;r++)SA.has(e[r])||(t+="\\"),t+=e[r];return t}function yt(e,t,r,o){var n;e.format||(n=e.anyOf)!=null&&n.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...r&&o.errorMessages&&{errorMessage:{format:r}}})):e.format=t}function qe(e,t,r,o){var n;e.pattern||(n=e.allOf)!=null&&n.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Kp(t,o),...r&&o.errorMessages&&{errorMessage:{pattern:r}}})):e.pattern=Kp(t,o)}function Kp(e,t){var r;if(!t.applyRegexFlags||!e.flags)return e.source;const o={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=o.i?e.source.toLowerCase():e.source;let i="",a=!1,s=!1,l=!1;for(let u=0;u<n.length;u++){if(a){i+=n[u],a=!1;continue}if(o.i){if(s){if(n[u].match(/[a-z]/)){l?(i+=n[u],i+=`${n[u-2]}-${n[u]}`.toUpperCase(),l=!1):n[u+1]==="-"&&((r=n[u+2])!=null&&r.match(/[a-z]/))?(i+=n[u],l=!0):i+=`${n[u]}${n[u].toUpperCase()}`;continue}}else if(n[u].match(/[a-z]/)){i+=`[${n[u]}${n[u].toUpperCase()}]`;continue}}if(o.m){if(n[u]==="^"){i+=`(^|(?<=[\r
|
|
65
|
+
`,{prompt:n}}var Jp=G([E({id:w().optional(),model:w().optional(),choices:R(E({text:w(),reasoning:w().nullish().optional(),reasoning_details:Fc.nullish(),finish_reason:w().nullish(),index:q().nullish(),logprobs:E({tokens:R(w()),token_logprobs:R(q()),top_logprobs:R(Xe(w(),q())).nullable()}).passthrough().nullable().optional()}).passthrough()),usage:E({prompt_tokens:q(),prompt_tokens_details:E({cached_tokens:q()}).passthrough().nullish(),completion_tokens:q(),completion_tokens_details:E({reasoning_tokens:q()}).passthrough().nullish(),total_tokens:q(),cost:q().optional(),cost_details:E({upstream_inference_cost:q().nullish()}).passthrough().nullish()}).passthrough().nullish()}).passthrough(),Ja]),U1=class{constructor(e,t,r){this.specificationVersion="v2",this.provider="openrouter",this.supportsImageUrls=!0,this.supportedUrls={"image/*":[/^data:image\/[a-zA-Z]+;base64,/,/^https?:\/\/.+\.(jpg|jpeg|png|gif|webp)$/i],"text/*":[/^data:text\//,/^https?:\/\/.+$/],"application/*":[/^data:application\//,/^https?:\/\/.+$/]},this.defaultObjectGenerationMode=void 0,this.modelId=e,this.settings=t,this.config=r}getArgs({prompt:e,maxOutputTokens:t,temperature:r,topP:o,frequencyPenalty:n,presencePenalty:i,seed:a,responseFormat:s,topK:l,stopSequences:u,tools:c,toolChoice:d}){const{prompt:f}=D1({prompt:e,inputFormat:"prompt"});if(c?.length)throw new Xt({functionality:"tools"});if(d)throw new Xt({functionality:"toolChoice"});return ue(ue({model:this.modelId,models:this.settings.models,logit_bias:this.settings.logitBias,logprobs:typeof this.settings.logprobs=="number"?this.settings.logprobs:typeof this.settings.logprobs=="boolean"&&this.settings.logprobs?0:void 0,suffix:this.settings.suffix,user:this.settings.user,max_tokens:t,temperature:r,top_p:o,frequency_penalty:n,presence_penalty:i,seed:a,stop:u,response_format:s,top_k:l,prompt:f,include_reasoning:this.settings.includeReasoning,reasoning:this.settings.reasoning},this.config.extraBody),this.settings.extraBody)}async doGenerate(e){var t,r,o,n,i,a,s,l,u,c,d,f,p,g,h;const y=(e.providerOptions||{}).openrouter||{},x=ue(ue({},this.getArgs(e)),y),{value:$,responseHeaders:v}=await Bn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:x,failedResponseHandler:Jn,successfulResponseHandler:Uc(Jp),abortSignal:e.abortSignal,fetch:this.config.fetch});if("error"in $){const N=$.error;throw new xt({message:N.message,url:this.config.url({path:"/completions",modelId:this.modelId}),requestBodyValues:x,statusCode:200,responseHeaders:v,data:N})}const k=$.choices[0];if(!k)throw new Jw({message:"No choice in OpenRouter completion response"});return{content:[{type:"text",text:(t=k.text)!=null?t:""}],finishReason:zi(k.finish_reason),usage:{inputTokens:(o=(r=$.usage)==null?void 0:r.prompt_tokens)!=null?o:0,outputTokens:(i=(n=$.usage)==null?void 0:n.completion_tokens)!=null?i:0,totalTokens:((s=(a=$.usage)==null?void 0:a.prompt_tokens)!=null?s:0)+((u=(l=$.usage)==null?void 0:l.completion_tokens)!=null?u:0),reasoningTokens:(f=(d=(c=$.usage)==null?void 0:c.completion_tokens_details)==null?void 0:d.reasoning_tokens)!=null?f:0,cachedInputTokens:(h=(g=(p=$.usage)==null?void 0:p.prompt_tokens_details)==null?void 0:g.cached_tokens)!=null?h:0},warnings:[],response:{headers:v}}}async doStream(e){const r=(e.providerOptions||{}).openrouter||{},o=ue(ue({},this.getArgs(e)),r),{value:n,responseHeaders:i}=await Bn({url:this.config.url({path:"/completions",modelId:this.modelId}),headers:Vn(this.config.headers(),e.headers),body:Ai(ue({},o),{stream:!0,stream_options:this.config.compatibility==="strict"?{include_usage:!0}:void 0}),failedResponseHandler:Jn,successfulResponseHandler:tx(Jp),abortSignal:e.abortSignal,fetch:this.config.fetch});let a="other";const s={inputTokens:Number.NaN,outputTokens:Number.NaN,totalTokens:Number.NaN,reasoningTokens:Number.NaN,cachedInputTokens:Number.NaN},l={};return{stream:n.pipeThrough(new TransformStream({transform(u,c){var d,f,p;if(!u.success){a="error",c.enqueue({type:"error",error:u.error});return}const g=u.value;if("error"in g){a="error",c.enqueue({type:"error",error:g.error});return}if(g.usage!=null){if(s.inputTokens=g.usage.prompt_tokens,s.outputTokens=g.usage.completion_tokens,s.totalTokens=g.usage.prompt_tokens+g.usage.completion_tokens,l.promptTokens=g.usage.prompt_tokens,g.usage.prompt_tokens_details){const y=(d=g.usage.prompt_tokens_details.cached_tokens)!=null?d:0;s.cachedInputTokens=y,l.promptTokensDetails={cachedTokens:y}}if(l.completionTokens=g.usage.completion_tokens,g.usage.completion_tokens_details){const y=(f=g.usage.completion_tokens_details.reasoning_tokens)!=null?f:0;s.reasoningTokens=y,l.completionTokensDetails={reasoningTokens:y}}l.cost=g.usage.cost,l.totalTokens=g.usage.total_tokens;const b=(p=g.usage.cost_details)==null?void 0:p.upstream_inference_cost;b!=null&&(l.costDetails={upstreamInferenceCost:b})}const h=g.choices[0];h?.finish_reason!=null&&(a=zi(h.finish_reason)),h?.text!=null&&c.enqueue({type:"text-delta",delta:h.text,id:bt()})},flush(u){u.enqueue({type:"finish",finishReason:a,usage:s,providerMetadata:{openrouter:{usage:l}}})}})),response:{headers:i}}}},L1=E({prompt_tokens:q(),total_tokens:q(),cost:q().optional()}),Z1=E({object:C("embedding"),embedding:R(q()),index:q().optional()}),F1=E({id:w().optional(),object:C("list"),data:R(Z1),model:w(),usage:L1.optional()}),q1=class{constructor(e,t,r){this.specificationVersion="v2",this.provider="openrouter",this.maxEmbeddingsPerCall=void 0,this.supportsParallelCalls=!0,this.modelId=e,this.settings=t,this.config=r}async doEmbed(e){var t;const{values:r,abortSignal:o,headers:n}=e,i=ue(ue({model:this.modelId,input:r,user:this.settings.user,provider:this.settings.provider},this.config.extraBody),this.settings.extraBody),{value:a,responseHeaders:s}=await Bn({url:this.config.url({path:"/embeddings",modelId:this.modelId}),headers:Vn(this.config.headers(),n),body:i,failedResponseHandler:Jn,successfulResponseHandler:Uc(F1),abortSignal:o,fetch:this.config.fetch});return{embeddings:a.data.map(l=>l.embedding),usage:a.usage?{tokens:a.usage.prompt_tokens}:void 0,providerMetadata:(t=a.usage)!=null&&t.cost?{openrouter:{usage:{cost:a.usage.cost}}}:void 0,response:{headers:s,body:a}}}};function V1(e){return Object.fromEntries(Object.entries(e).filter(([,t])=>t!==null))}function B1(e,...t){const r=V1(e??{}),n=[r["user-agent"]||"",...t].filter(Boolean).join(" ");return Ai(ue({},r),{"user-agent":n})}var J1="1.5.4";function ax(e={}){var t,r,o;const n=(r=x1((t=e.baseURL)!=null?t:e.baseUrl))!=null?r:"https://openrouter.ai/api/v1",i=(o=e.compatibility)!=null?o:"compatible",a=()=>B1(ue(ue({Authorization:`Bearer ${i1({apiKey:e.apiKey,environmentVariableName:"OPENROUTER_API_KEY",description:"OpenRouter"})}`},e.headers),e.api_keys&&Object.keys(e.api_keys).length>0&&{"X-Provider-API-Keys":JSON.stringify(e.api_keys)}),`ai-sdk/openrouter/${J1}`),s=(f,p={})=>new M1(f,p,{provider:"openrouter.chat",url:({path:g})=>`${n}${g}`,headers:a,compatibility:i,fetch:e.fetch,extraBody:e.extraBody}),l=(f,p={})=>new U1(f,p,{provider:"openrouter.completion",url:({path:g})=>`${n}${g}`,headers:a,compatibility:i,fetch:e.fetch,extraBody:e.extraBody}),u=(f,p={})=>new q1(f,p,{provider:"openrouter.embedding",url:({path:g})=>`${n}${g}`,headers:a,fetch:e.fetch,extraBody:e.extraBody}),c=(f,p)=>{if(new.target)throw new Error("The OpenRouter model function cannot be called with the new keyword.");return f==="openai/gpt-3.5-turbo-instruct"?l(f,p):s(f,p)},d=(f,p)=>c(f,p);return d.languageModel=c,d.chat=s,d.completion=l,d.textEmbeddingModel=u,d.embedding=u,d}ax({compatibility:"strict"});function wu(...e){return e.reduce((t,r)=>({...t,...r??{}}),{})}async function sx(e,t){if(e==null)return Promise.resolve();const r=t?.abortSignal;return new Promise((o,n)=>{if(r?.aborted){n(Wp());return}const i=setTimeout(()=>{a(),o()},e),a=()=>{clearTimeout(i),r?.removeEventListener("abort",s)},s=()=>{a(),n(Wp())};r?.addEventListener("abort",s)})}function Wp(){return new DOMException("Delay was aborted","AbortError")}function Oo(e){return Object.fromEntries([...e.headers])}var No=({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:o="-"}={})=>{const n=()=>{const i=r.length,a=new Array(t);for(let s=0;s<t;s++)a[s]=r[Math.random()*i|0];return a.join("")};if(e==null)return n;if(r.includes(o))throw new Ji({argument:"separator",message:`The separator "${o}" must not be part of the alphabet "${r}".`});return()=>`${e}${o}${n()}`},W1=No();function ux(e){return e==null?"unknown error":typeof e=="string"?e:e instanceof Error?e.message:JSON.stringify(e)}function wr(e){return(e instanceof Error||e instanceof DOMException)&&(e.name==="AbortError"||e.name==="ResponseAborted"||e.name==="TimeoutError")}var H1=["fetch failed","failed to fetch"];function lx({error:e,url:t,requestBodyValues:r}){if(wr(e))return e;if(e instanceof TypeError&&H1.includes(e.message.toLowerCase())){const o=e.cause;if(o!=null)return new Be({message:`Cannot connect to API: ${o.message}`,cause:o,url:t,requestBodyValues:r,isRetryable:!0})}return e}function Vc(e=globalThis){var t,r,o;return e.window?"runtime/browser":(t=e.navigator)!=null&&t.userAgent?`runtime/${e.navigator.userAgent.toLowerCase()}`:(o=(r=e.process)==null?void 0:r.versions)!=null&&o.node?`runtime/node.js/${e.process.version.substring(0)}`:e.EdgeRuntime?"runtime/vercel-edge":"runtime/unknown"}function G1(e){if(e==null)return{};const t={};if(e instanceof Headers)e.forEach((r,o)=>{t[o.toLowerCase()]=r});else{Array.isArray(e)||(e=Object.entries(e));for(const[r,o]of e)o!=null&&(t[r.toLowerCase()]=o)}return t}function Wa(e,...t){const r=new Headers(G1(e)),o=r.get("user-agent")||"";return r.set("user-agent",[o,...t].filter(Boolean).join(" ")),Object.fromEntries(r.entries())}var cx="3.0.16",K1=()=>globalThis.fetch,Hp=async({url:e,headers:t={},successfulResponseHandler:r,failedResponseHandler:o,abortSignal:n,fetch:i=K1()})=>{try{const a=await i(e,{method:"GET",headers:Wa(t,`ai-sdk/provider-utils/${cx}`,Vc()),signal:n}),s=Oo(a);if(!a.ok){let l;try{l=await o({response:a,url:e,requestBodyValues:{}})}catch(u){throw wr(u)||Be.isInstance(u)?u:new Be({message:"Failed to process error response",cause:u,statusCode:a.status,url:e,responseHeaders:s,requestBodyValues:{}})}throw l.value}try{return await r({response:a,url:e,requestBodyValues:{}})}catch(l){throw l instanceof Error&&(wr(l)||Be.isInstance(l))?l:new Be({message:"Failed to process successful response",cause:l,statusCode:a.status,url:e,responseHeaders:s,requestBodyValues:{}})}}catch(a){throw lx({error:a,url:e,requestBodyValues:{}})}};function Y1({mediaType:e,url:t,supportedUrls:r}){return t=t.toLowerCase(),e=e.toLowerCase(),Object.entries(r).map(([o,n])=>{const i=o.toLowerCase();return i==="*"||i==="*/*"?{mediaTypePrefix:"",regexes:n}:{mediaTypePrefix:i.replace(/\*/,""),regexes:n}}).filter(({mediaTypePrefix:o})=>e.startsWith(o)).flatMap(({regexes:o})=>o).some(o=>o.test(t))}function ai({settingValue:e,environmentVariableName:t}){if(typeof e=="string")return e;if(!(e!=null||typeof process>"u")&&(e=process.env[t],!(e==null||typeof e!="string")))return e}var Q1=/"__proto__"\s*:/,X1=/"constructor"\s*:/;function eA(e){const t=JSON.parse(e);return t===null||typeof t!="object"||Q1.test(e)===!1&&X1.test(e)===!1?t:tA(t)}function tA(e){let t=[e];for(;t.length;){const r=t;t=[];for(const o of r){if(Object.prototype.hasOwnProperty.call(o,"__proto__"))throw new SyntaxError("Object contains forbidden prototype property");if(Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype"))throw new SyntaxError("Object contains forbidden prototype property");for(const n in o){const i=o[n];i&&typeof i=="object"&&t.push(i)}}}return e}function dx(e){const{stackTraceLimit:t}=Error;Error.stackTraceLimit=0;try{return eA(e)}finally{Error.stackTraceLimit=t}}var Mi=Symbol.for("vercel.ai.validator");function rA(e){return{[Mi]:!0,validate:e}}function nA(e){return typeof e=="object"&&e!==null&&Mi in e&&e[Mi]===!0&&"validate"in e}function cn(e){let t;return()=>(t==null&&(t=e()),t)}function oA(e){return nA(e)?e:typeof e=="function"?e():iA(e)}function iA(e){return rA(async t=>{const r=await e["~standard"].validate(t);return r.issues==null?{success:!0,value:r.value}:{success:!1,error:new Ft({value:t,cause:r.issues})}})}async function xu({value:e,schema:t}){const r=await sr({value:e,schema:t});if(!r.success)throw Ft.wrap({value:e,cause:r.error});return r.value}async function sr({value:e,schema:t}){const r=oA(t);try{if(r.validate==null)return{success:!0,value:e,rawValue:e};const o=await r.validate(e);return o.success?{success:!0,value:o.value,rawValue:e}:{success:!1,error:Ft.wrap({value:e,cause:o.error}),rawValue:e}}catch(o){return{success:!1,error:Ft.wrap({value:e,cause:o}),rawValue:e}}}async function aA({text:e,schema:t}){try{const r=dx(e);return t==null?r:xu({value:r,schema:t})}catch(r){throw Jr.isInstance(r)||Ft.isInstance(r)?r:new Jr({text:e,cause:r})}}async function xr({text:e,schema:t}){try{const r=dx(e);return t==null?{success:!0,value:r,rawValue:r}:await sr({value:r,schema:t})}catch(r){return{success:!1,error:Jr.isInstance(r)?r:new Jr({text:e,cause:r}),rawValue:void 0}}}function sA({stream:e,schema:t}){return e.pipeThrough(new TextDecoderStream).pipeThrough(new Pn).pipeThrough(new TransformStream({async transform({data:r},o){r!=="[DONE]"&&o.enqueue(await xr({text:r,schema:t}))}}))}var uA=()=>globalThis.fetch,$u=async({url:e,headers:t,body:r,failedResponseHandler:o,successfulResponseHandler:n,abortSignal:i,fetch:a})=>lA({url:e,headers:{"Content-Type":"application/json",...t},body:{content:JSON.stringify(r),values:r},failedResponseHandler:o,successfulResponseHandler:n,abortSignal:i,fetch:a}),lA=async({url:e,headers:t={},body:r,successfulResponseHandler:o,failedResponseHandler:n,abortSignal:i,fetch:a=uA()})=>{try{const s=await a(e,{method:"POST",headers:Wa(t,`ai-sdk/provider-utils/${cx}`,Vc()),body:r.content,signal:i}),l=Oo(s);if(!s.ok){let u;try{u=await n({response:s,url:e,requestBodyValues:r.values})}catch(c){throw wr(c)||Be.isInstance(c)?c:new Be({message:"Failed to process error response",cause:c,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}throw u.value}try{return await o({response:s,url:e,requestBodyValues:r.values})}catch(u){throw u instanceof Error&&(wr(u)||Be.isInstance(u))?u:new Be({message:"Failed to process successful response",cause:u,statusCode:s.status,url:e,responseHeaders:l,requestBodyValues:r.values})}}catch(s){throw lx({error:s,url:e,requestBodyValues:r.values})}};async function tr(e){return typeof e=="function"&&(e=e()),Promise.resolve(e)}var Wn=({errorSchema:e,errorToMessage:t,isRetryable:r})=>async({response:o,url:n,requestBodyValues:i})=>{const a=await o.text(),s=Oo(o);if(a.trim()==="")return{responseHeaders:s,value:new Be({message:o.statusText,url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:r?.(o)})};try{const l=await aA({text:a,schema:e});return{responseHeaders:s,value:new Be({message:t(l),url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,data:l,isRetryable:r?.(o,l)})}}catch{return{responseHeaders:s,value:new Be({message:o.statusText,url:n,requestBodyValues:i,statusCode:o.status,responseHeaders:s,responseBody:a,isRetryable:r?.(o)})}}},cA=e=>async({response:t})=>{const r=Oo(t);if(t.body==null)throw new T0({});return{responseHeaders:r,value:sA({stream:t.body,schema:e})}},Di=e=>async({response:t,url:r,requestBodyValues:o})=>{const n=await t.text(),i=await xr({text:n,schema:e}),a=Oo(t);if(!i.success)throw new Be({message:"Invalid JSON response",cause:i.error,statusCode:t.status,responseHeaders:a,responseBody:n,url:r,requestBodyValues:o});return{responseHeaders:a,value:i.value,rawValue:i.rawValue}},dA=(e,t)=>{let r=0;for(;r<e.length&&r<t.length&&e[r]===t[r];r++);return[(e.length-r).toString(),...t.slice(r)].join("/")},pA=Symbol("Let zodToJsonSchema decide on which parser to use"),Gp={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"},fA=e=>typeof e=="string"?{...Gp,name:e}:{...Gp,...e};function tt(){return{}}function mA(e,t){var r,o,n;const i={type:"array"};return(r=e.type)!=null&&r._def&&((n=(o=e.type)==null?void 0:o._def)==null?void 0:n.typeName)!==A.ZodAny&&(i.items=ce(e.type._def,{...t,currentPath:[...t.currentPath,"items"]})),e.minLength&&(i.minItems=e.minLength.value),e.maxLength&&(i.maxItems=e.maxLength.value),e.exactLength&&(i.minItems=e.exactLength.value,i.maxItems=e.exactLength.value),i}function hA(e){const t={type:"integer",format:"int64"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function gA(){return{type:"boolean"}}function px(e,t){return ce(e.type._def,t)}var vA=(e,t)=>ce(e.innerType._def,t);function fx(e,t,r){const o=r??t.dateStrategy;if(Array.isArray(o))return{anyOf:o.map((n,i)=>fx(e,t,n))};switch(o){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return yA(e)}}var yA=e=>{const t={type:"integer",format:"unix-time"};for(const r of e.checks)switch(r.kind){case"min":t.minimum=r.value;break;case"max":t.maximum=r.value;break}return t};function bA(e,t){return{...ce(e.innerType._def,t),default:e.defaultValue()}}function _A(e,t){return t.effectStrategy==="input"?ce(e.schema._def,t):tt()}function wA(e){return{type:"string",enum:Array.from(e.values)}}var xA=e=>"type"in e&&e.type==="string"?!1:"allOf"in e;function $A(e,t){const r=[ce(e.left._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),ce(e.right._def,{...t,currentPath:[...t.currentPath,"allOf","1"]})].filter(n=>!!n),o=[];return r.forEach(n=>{if(xA(n))o.push(...n.allOf);else{let i=n;if("additionalProperties"in n&&n.additionalProperties===!1){const{additionalProperties:a,...s}=n;i=s}o.push(i)}}),o.length?{allOf:o}:void 0}function SA(e){const t=typeof e.value;return t!=="bigint"&&t!=="number"&&t!=="boolean"&&t!=="string"?{type:Array.isArray(e.value)?"array":"object"}:{type:t==="bigint"?"integer":t,const:e.value}}var Ps=void 0,vt={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:()=>(Ps===void 0&&(Ps=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),Ps),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 mx(e,t){const r={type:"string"};if(e.checks)for(const o of e.checks)switch(o.kind){case"min":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value;break;case"max":r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"email":switch(t.emailStrategy){case"format:email":yt(r,"email",o.message,t);break;case"format:idn-email":yt(r,"idn-email",o.message,t);break;case"pattern:zod":qe(r,vt.email,o.message,t);break}break;case"url":yt(r,"uri",o.message,t);break;case"uuid":yt(r,"uuid",o.message,t);break;case"regex":qe(r,o.regex,o.message,t);break;case"cuid":qe(r,vt.cuid,o.message,t);break;case"cuid2":qe(r,vt.cuid2,o.message,t);break;case"startsWith":qe(r,RegExp(`^${Cs(o.value,t)}`),o.message,t);break;case"endsWith":qe(r,RegExp(`${Cs(o.value,t)}$`),o.message,t);break;case"datetime":yt(r,"date-time",o.message,t);break;case"date":yt(r,"date",o.message,t);break;case"time":yt(r,"time",o.message,t);break;case"duration":yt(r,"duration",o.message,t);break;case"length":r.minLength=typeof r.minLength=="number"?Math.max(r.minLength,o.value):o.value,r.maxLength=typeof r.maxLength=="number"?Math.min(r.maxLength,o.value):o.value;break;case"includes":{qe(r,RegExp(Cs(o.value,t)),o.message,t);break}case"ip":{o.version!=="v6"&&yt(r,"ipv4",o.message,t),o.version!=="v4"&&yt(r,"ipv6",o.message,t);break}case"base64url":qe(r,vt.base64url,o.message,t);break;case"jwt":qe(r,vt.jwt,o.message,t);break;case"cidr":{o.version!=="v6"&&qe(r,vt.ipv4Cidr,o.message,t),o.version!=="v4"&&qe(r,vt.ipv6Cidr,o.message,t);break}case"emoji":qe(r,vt.emoji(),o.message,t);break;case"ulid":{qe(r,vt.ulid,o.message,t);break}case"base64":{switch(t.base64Strategy){case"format:binary":{yt(r,"binary",o.message,t);break}case"contentEncoding:base64":{r.contentEncoding="base64";break}case"pattern:zod":{qe(r,vt.base64,o.message,t);break}}break}case"nanoid":qe(r,vt.nanoid,o.message,t)}return r}function Cs(e,t){return t.patternStrategy==="escape"?kA(e):e}var IA=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function kA(e){let t="";for(let r=0;r<e.length;r++)IA.has(e[r])||(t+="\\"),t+=e[r];return t}function yt(e,t,r,o){var n;e.format||(n=e.anyOf)!=null&&n.some(i=>i.format)?(e.anyOf||(e.anyOf=[]),e.format&&(e.anyOf.push({format:e.format}),delete e.format),e.anyOf.push({format:t,...r&&o.errorMessages&&{errorMessage:{format:r}}})):e.format=t}function qe(e,t,r,o){var n;e.pattern||(n=e.allOf)!=null&&n.some(i=>i.pattern)?(e.allOf||(e.allOf=[]),e.pattern&&(e.allOf.push({pattern:e.pattern}),delete e.pattern),e.allOf.push({pattern:Kp(t,o),...r&&o.errorMessages&&{errorMessage:{pattern:r}}})):e.pattern=Kp(t,o)}function Kp(e,t){var r;if(!t.applyRegexFlags||!e.flags)return e.source;const o={i:e.flags.includes("i"),m:e.flags.includes("m"),s:e.flags.includes("s")},n=o.i?e.source.toLowerCase():e.source;let i="",a=!1,s=!1,l=!1;for(let u=0;u<n.length;u++){if(a){i+=n[u],a=!1;continue}if(o.i){if(s){if(n[u].match(/[a-z]/)){l?(i+=n[u],i+=`${n[u-2]}-${n[u]}`.toUpperCase(),l=!1):n[u+1]==="-"&&((r=n[u+2])!=null&&r.match(/[a-z]/))?(i+=n[u],l=!0):i+=`${n[u]}${n[u].toUpperCase()}`;continue}}else if(n[u].match(/[a-z]/)){i+=`[${n[u]}${n[u].toUpperCase()}]`;continue}}if(o.m){if(n[u]==="^"){i+=`(^|(?<=[\r
|
|
66
66
|
]))`;continue}else if(n[u]==="$"){i+=`($|(?=[\r
|
|
67
67
|
]))`;continue}}if(o.s&&n[u]==="."){i+=s?`${n[u]}\r
|
|
68
68
|
`:`[${n[u]}\r
|
|
69
|
-
]`;continue}i+=n[u],n[u]==="\\"?a=!0:s&&n[u]==="]"?s=!1:!s&&n[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function hx(e,t){var r,o,n,i,a,s;const l={type:"object",additionalProperties:(r=ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?r:t.allowedAdditionalProperties};if(((o=e.keyType)==null?void 0:o._def.typeName)===A.ZodString&&((n=e.keyType._def.checks)!=null&&n.length)){const{type:u,...c}=mx(e.keyType._def,t);return{...l,propertyNames:c}}else{if(((i=e.keyType)==null?void 0:i._def.typeName)===A.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===A.ZodBranded&&e.keyType._def.type._def.typeName===A.ZodString&&((s=e.keyType._def.type._def.checks)!=null&&s.length)){const{type:u,...c}=px(e.keyType._def,t);return{...l,propertyNames:c}}}return l}function kA(e,t){if(t.mapStrategy==="record")return hx(e,t);const r=ce(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||tt(),o=ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||tt();return{type:"array",maxItems:125,items:{type:"array",items:[r,o],minItems:2,maxItems:2}}}function EA(e){const t=e.values,o=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(o.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:o}}function TA(){return{not:tt()}}function OA(){return{type:"null"}}var Su={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function NA(e,t){const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(o=>o._def.typeName in Su&&(!o._def.checks||!o._def.checks.length))){const o=r.reduce((n,i)=>{const a=Su[i._def.typeName];return a&&!n.includes(a)?[...n,a]:n},[]);return{type:o.length>1?o:o[0]}}else if(r.every(o=>o._def.typeName==="ZodLiteral"&&!o.description)){const o=r.reduce((n,i)=>{const a=typeof i._def.value;switch(a){case"string":case"number":case"boolean":return[...n,a];case"bigint":return[...n,"integer"];case"object":if(i._def.value===null)return[...n,"null"];case"symbol":case"undefined":case"function":default:return n}},[]);if(o.length===r.length){const n=o.filter((i,a,s)=>s.indexOf(i)===a);return{type:n.length>1?n:n[0],enum:r.reduce((i,a)=>i.includes(a._def.value)?i:[...i,a._def.value],[])}}}else if(r.every(o=>o._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((o,n)=>[...o,...n._def.values.filter(i=>!o.includes(i))],[])};return PA(e,t)}var PA=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((o,n)=>ce(o._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(o=>!!o&&(!t.strictUnions||typeof o=="object"&&Object.keys(o).length>0));return r.length?{anyOf:r}:void 0};function CA(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Su[e.innerType._def.typeName],"null"]};const r=ce(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function jA(e){const t={type:"number"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"int":t.type="integer";break;case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function AA(e,t){const r={type:"object",properties:{}},o=[],n=e.shape();for(const a in n){let s=n[a];if(s===void 0||s._def===void 0)continue;const l=zA(s),u=ce(s._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});u!==void 0&&(r.properties[a]=u,l||o.push(a))}o.length&&(r.required=o);const i=RA(e,t);return i!==void 0&&(r.additionalProperties=i),r}function RA(e,t){if(e.catchall._def.typeName!=="ZodNever")return ce(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function zA(e){try{return e.isOptional()}catch{return!0}}var MA=(e,t)=>{var r;if(t.currentPath.toString()===((r=t.propertyPath)==null?void 0:r.toString()))return ce(e.innerType._def,t);const o=ce(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return o?{anyOf:[{not:tt()},o]}:tt()},DA=(e,t)=>{if(t.pipeStrategy==="input")return ce(e.in._def,t);if(t.pipeStrategy==="output")return ce(e.out._def,t);const r=ce(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),o=ce(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,o].filter(n=>n!==void 0)}};function UA(e,t){return ce(e.type._def,t)}function LA(e,t){const o={type:"array",uniqueItems:!0,items:ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(o.minItems=e.minSize.value),e.maxSize&&(o.maxItems=e.maxSize.value),o}function ZA(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,o)=>ce(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,o],[]),additionalItems:ce(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,o)=>ce(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,o],[])}}function FA(){return{not:tt()}}function qA(){return tt()}var VA=(e,t)=>ce(e.innerType._def,t),BA=(e,t,r)=>{switch(t){case A.ZodString:return mx(e,r);case A.ZodNumber:return jA(e);case A.ZodObject:return AA(e,r);case A.ZodBigInt:return mA(e);case A.ZodBoolean:return hA();case A.ZodDate:return fx(e,r);case A.ZodUndefined:return FA();case A.ZodNull:return OA();case A.ZodArray:return fA(e,r);case A.ZodUnion:case A.ZodDiscriminatedUnion:return NA(e,r);case A.ZodIntersection:return xA(e,r);case A.ZodTuple:return ZA(e,r);case A.ZodRecord:return hx(e,r);case A.ZodLiteral:return $A(e);case A.ZodEnum:return _A(e);case A.ZodNativeEnum:return EA(e);case A.ZodNullable:return CA(e,r);case A.ZodOptional:return MA(e,r);case A.ZodMap:return kA(e,r);case A.ZodSet:return LA(e,r);case A.ZodLazy:return()=>e.getter()._def;case A.ZodPromise:return UA(e,r);case A.ZodNaN:case A.ZodNever:return TA();case A.ZodEffects:return bA(e,r);case A.ZodAny:return tt();case A.ZodUnknown:return qA();case A.ZodDefault:return yA(e,r);case A.ZodBranded:return px(e,r);case A.ZodReadonly:return VA(e,r);case A.ZodCatch:return gA(e,r);case A.ZodPipeline:return DA(e,r);case A.ZodFunction:case A.ZodVoid:case A.ZodSymbol:return;default:return(o=>{})()}};function ce(e,t,r=!1){var o;const n=t.seen.get(e);if(t.override){const l=(o=t.override)==null?void 0:o.call(t,e,t,n,r);if(l!==dA)return l}if(n&&!r){const l=JA(n,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const a=BA(e,e.typeName,t),s=typeof a=="function"?ce(a(),t):a;if(s&&WA(e,t,s),t.postProcess){const l=t.postProcess(s,e,t);return i.jsonSchema=s,l}return i.jsonSchema=s,s}var JA=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:cA(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,o)=>t.currentPath[o]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),tt()):t.$refStrategy==="seen"?tt():void 0}},WA=(e,t,r)=>(e.description&&(r.description=e.description),r),HA=e=>{const t=pA(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([o,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,o],jsonSchema:void 0}]))}},GA=(e,t)=>{var r;const o=HA(t);let n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,d])=>{var f;return{...u,[c]:(f=ce(d._def,{...o,currentPath:[...o.basePath,o.definitionPath,c]},!0))!=null?f:tt()}},{}):void 0;const i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=(r=ce(e._def,i===void 0?o:{...o,currentPath:[...o.basePath,o.definitionPath,i]},!1))!=null?r:tt(),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(a.title=s);const l=i===void 0?n?{...a,[o.definitionPath]:n}:a:{$ref:[...o.$refStrategy==="relative"?[]:o.basePath,o.definitionPath,i].join("/"),[o.definitionPath]:{...n,[i]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},KA=GA;function YA(e,t){var r;const o=(r=void 0)!=null?r:!1;return Bc(()=>KA(e,{$refStrategy:o?"root":"none"}),{validate:async n=>{const i=await e.safeParseAsync(n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function QA(e,t){var r;const o=(r=void 0)!=null?r:!1;return Bc(()=>pa(e,{target:"draft-7",io:"output",reused:o?"ref":"inline"}),{validate:async n=>{const i=await fa(e,n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function XA(e){return"_zod"in e}function Or(e,t){return XA(e)?QA(e):YA(e)}var Iu=Symbol.for("vercel.ai.schema");function Bc(e,{validate:t}={}){return{[Iu]:!0,_type:void 0,[zi]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function eR(e){return typeof e=="object"&&e!==null&&Iu in e&&e[Iu]===!0&&"jsonSchema"in e&&"validate"in e}function Wa(e){return e==null?Bc({properties:{},additionalProperties:!1}):eR(e)?e:typeof e=="function"?e():Or(e)}var{btoa:tR,atob:rR}=globalThis;function Jc(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=rR(t);return Uint8Array.from(r,o=>o.codePointAt(0))}function ku(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCodePoint(e[r]);return tR(t)}function nR(e){return e?.replace(/\/$/,"")}function oR(e){return e!=null&&typeof e[Symbol.asyncIterator]=="function"}async function*iR({execute:e,input:t,options:r}){const o=e(t,r);if(oR(o)){let n;for await(const i of o)n=i,yield{type:"preliminary",output:i};yield{type:"final",output:n}}else yield{type:"final",output:await o}}var Cs,Yp;function aR(){if(Yp)return Cs;Yp=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,n=(c,d)=>{for(var f in d)e(c,f,{get:d[f],enumerable:!0})},i=(c,d,f,p)=>{if(d&&typeof d=="object"||typeof d=="function")for(let g of r(d))!o.call(c,g)&&g!==f&&e(c,g,{get:()=>d[g],enumerable:!(p=t(d,g))||p.enumerable});return c},a=c=>i(e({},"__esModule",{value:!0}),c),s={};n(s,{SYMBOL_FOR_REQ_CONTEXT:()=>l,getContext:()=>u}),Cs=a(s);const l=Symbol.for("@vercel/request-context");function u(){return globalThis[l]?.get?.()??{}}return Cs}var js,Qp;function sR(){if(Qp)return js;Qp=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,n=(d,f)=>{for(var p in f)e(d,p,{get:f[p],enumerable:!0})},i=(d,f,p,g)=>{if(f&&typeof f=="object"||typeof f=="function")for(let h of r(f))!o.call(d,h)&&h!==p&&e(d,h,{get:()=>f[h],enumerable:!(g=t(f,h))||g.enumerable});return d},a=d=>i(e({},"__esModule",{value:!0}),d),s={};n(s,{getContext:()=>l.getContext,getVercelOidcToken:()=>u,getVercelOidcTokenSync:()=>c}),js=a(s);var l=aR();async function u(){return""}function c(){return""}return js}var gx=sR(),uR="vercel.ai.gateway.error",As=Symbol.for(uR),Xp,ef,rt=class vx extends(ef=Error,Xp=As,ef){constructor({message:t,statusCode:r=500,cause:o}){super(t),this[Xp]=!0,this.statusCode=r,this.cause=o}static isInstance(t){return vx.hasMarker(t)}static hasMarker(t){return typeof t=="object"&&t!==null&&As in t&&t[As]===!0}},yx="GatewayAuthenticationError",lR=`vercel.ai.gateway.error.${yx}`,tf=Symbol.for(lR),rf,nf,Wc=class bx extends(nf=rt,rf=tf,nf){constructor({message:t="Authentication failed",statusCode:r=401,cause:o}={}){super({message:t,statusCode:r,cause:o}),this[rf]=!0,this.name=yx,this.type="authentication_error"}static isInstance(t){return rt.hasMarker(t)&&tf in t}static createContextualError({apiKeyProvided:t,oidcTokenProvided:r,message:o="Authentication failed",statusCode:n=401,cause:i}){let a;return t?a=`AI Gateway authentication failed: Invalid API key.
|
|
69
|
+
]`;continue}i+=n[u],n[u]==="\\"?a=!0:s&&n[u]==="]"?s=!1:!s&&n[u]==="["&&(s=!0)}try{new RegExp(i)}catch{return console.warn(`Could not convert regex pattern at ${t.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),e.source}return i}function hx(e,t){var r,o,n,i,a,s;const l={type:"object",additionalProperties:(r=ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]}))!=null?r:t.allowedAdditionalProperties};if(((o=e.keyType)==null?void 0:o._def.typeName)===A.ZodString&&((n=e.keyType._def.checks)!=null&&n.length)){const{type:u,...c}=mx(e.keyType._def,t);return{...l,propertyNames:c}}else{if(((i=e.keyType)==null?void 0:i._def.typeName)===A.ZodEnum)return{...l,propertyNames:{enum:e.keyType._def.values}};if(((a=e.keyType)==null?void 0:a._def.typeName)===A.ZodBranded&&e.keyType._def.type._def.typeName===A.ZodString&&((s=e.keyType._def.type._def.checks)!=null&&s.length)){const{type:u,...c}=px(e.keyType._def,t);return{...l,propertyNames:c}}}return l}function EA(e,t){if(t.mapStrategy==="record")return hx(e,t);const r=ce(e.keyType._def,{...t,currentPath:[...t.currentPath,"items","items","0"]})||tt(),o=ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"items","items","1"]})||tt();return{type:"array",maxItems:125,items:{type:"array",items:[r,o],minItems:2,maxItems:2}}}function TA(e){const t=e.values,o=Object.keys(e.values).filter(i=>typeof t[t[i]]!="number").map(i=>t[i]),n=Array.from(new Set(o.map(i=>typeof i)));return{type:n.length===1?n[0]==="string"?"string":"number":["string","number"],enum:o}}function OA(){return{not:tt()}}function NA(){return{type:"null"}}var Su={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function PA(e,t){const r=e.options instanceof Map?Array.from(e.options.values()):e.options;if(r.every(o=>o._def.typeName in Su&&(!o._def.checks||!o._def.checks.length))){const o=r.reduce((n,i)=>{const a=Su[i._def.typeName];return a&&!n.includes(a)?[...n,a]:n},[]);return{type:o.length>1?o:o[0]}}else if(r.every(o=>o._def.typeName==="ZodLiteral"&&!o.description)){const o=r.reduce((n,i)=>{const a=typeof i._def.value;switch(a){case"string":case"number":case"boolean":return[...n,a];case"bigint":return[...n,"integer"];case"object":if(i._def.value===null)return[...n,"null"];case"symbol":case"undefined":case"function":default:return n}},[]);if(o.length===r.length){const n=o.filter((i,a,s)=>s.indexOf(i)===a);return{type:n.length>1?n:n[0],enum:r.reduce((i,a)=>i.includes(a._def.value)?i:[...i,a._def.value],[])}}}else if(r.every(o=>o._def.typeName==="ZodEnum"))return{type:"string",enum:r.reduce((o,n)=>[...o,...n._def.values.filter(i=>!o.includes(i))],[])};return CA(e,t)}var CA=(e,t)=>{const r=(e.options instanceof Map?Array.from(e.options.values()):e.options).map((o,n)=>ce(o._def,{...t,currentPath:[...t.currentPath,"anyOf",`${n}`]})).filter(o=>!!o&&(!t.strictUnions||typeof o=="object"&&Object.keys(o).length>0));return r.length?{anyOf:r}:void 0};function jA(e,t){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes(e.innerType._def.typeName)&&(!e.innerType._def.checks||!e.innerType._def.checks.length))return{type:[Su[e.innerType._def.typeName],"null"]};const r=ce(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","0"]});return r&&{anyOf:[r,{type:"null"}]}}function AA(e){const t={type:"number"};if(!e.checks)return t;for(const r of e.checks)switch(r.kind){case"int":t.type="integer";break;case"min":r.inclusive?t.minimum=r.value:t.exclusiveMinimum=r.value;break;case"max":r.inclusive?t.maximum=r.value:t.exclusiveMaximum=r.value;break;case"multipleOf":t.multipleOf=r.value;break}return t}function RA(e,t){const r={type:"object",properties:{}},o=[],n=e.shape();for(const a in n){let s=n[a];if(s===void 0||s._def===void 0)continue;const l=MA(s),u=ce(s._def,{...t,currentPath:[...t.currentPath,"properties",a],propertyPath:[...t.currentPath,"properties",a]});u!==void 0&&(r.properties[a]=u,l||o.push(a))}o.length&&(r.required=o);const i=zA(e,t);return i!==void 0&&(r.additionalProperties=i),r}function zA(e,t){if(e.catchall._def.typeName!=="ZodNever")return ce(e.catchall._def,{...t,currentPath:[...t.currentPath,"additionalProperties"]});switch(e.unknownKeys){case"passthrough":return t.allowedAdditionalProperties;case"strict":return t.rejectedAdditionalProperties;case"strip":return t.removeAdditionalStrategy==="strict"?t.allowedAdditionalProperties:t.rejectedAdditionalProperties}}function MA(e){try{return e.isOptional()}catch{return!0}}var DA=(e,t)=>{var r;if(t.currentPath.toString()===((r=t.propertyPath)==null?void 0:r.toString()))return ce(e.innerType._def,t);const o=ce(e.innerType._def,{...t,currentPath:[...t.currentPath,"anyOf","1"]});return o?{anyOf:[{not:tt()},o]}:tt()},UA=(e,t)=>{if(t.pipeStrategy==="input")return ce(e.in._def,t);if(t.pipeStrategy==="output")return ce(e.out._def,t);const r=ce(e.in._def,{...t,currentPath:[...t.currentPath,"allOf","0"]}),o=ce(e.out._def,{...t,currentPath:[...t.currentPath,"allOf",r?"1":"0"]});return{allOf:[r,o].filter(n=>n!==void 0)}};function LA(e,t){return ce(e.type._def,t)}function ZA(e,t){const o={type:"array",uniqueItems:!0,items:ce(e.valueType._def,{...t,currentPath:[...t.currentPath,"items"]})};return e.minSize&&(o.minItems=e.minSize.value),e.maxSize&&(o.maxItems=e.maxSize.value),o}function FA(e,t){return e.rest?{type:"array",minItems:e.items.length,items:e.items.map((r,o)=>ce(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,o],[]),additionalItems:ce(e.rest._def,{...t,currentPath:[...t.currentPath,"additionalItems"]})}:{type:"array",minItems:e.items.length,maxItems:e.items.length,items:e.items.map((r,o)=>ce(r._def,{...t,currentPath:[...t.currentPath,"items",`${o}`]})).reduce((r,o)=>o===void 0?r:[...r,o],[])}}function qA(){return{not:tt()}}function VA(){return tt()}var BA=(e,t)=>ce(e.innerType._def,t),JA=(e,t,r)=>{switch(t){case A.ZodString:return mx(e,r);case A.ZodNumber:return AA(e);case A.ZodObject:return RA(e,r);case A.ZodBigInt:return hA(e);case A.ZodBoolean:return gA();case A.ZodDate:return fx(e,r);case A.ZodUndefined:return qA();case A.ZodNull:return NA();case A.ZodArray:return mA(e,r);case A.ZodUnion:case A.ZodDiscriminatedUnion:return PA(e,r);case A.ZodIntersection:return $A(e,r);case A.ZodTuple:return FA(e,r);case A.ZodRecord:return hx(e,r);case A.ZodLiteral:return SA(e);case A.ZodEnum:return wA(e);case A.ZodNativeEnum:return TA(e);case A.ZodNullable:return jA(e,r);case A.ZodOptional:return DA(e,r);case A.ZodMap:return EA(e,r);case A.ZodSet:return ZA(e,r);case A.ZodLazy:return()=>e.getter()._def;case A.ZodPromise:return LA(e,r);case A.ZodNaN:case A.ZodNever:return OA();case A.ZodEffects:return _A(e,r);case A.ZodAny:return tt();case A.ZodUnknown:return VA();case A.ZodDefault:return bA(e,r);case A.ZodBranded:return px(e,r);case A.ZodReadonly:return BA(e,r);case A.ZodCatch:return vA(e,r);case A.ZodPipeline:return UA(e,r);case A.ZodFunction:case A.ZodVoid:case A.ZodSymbol:return;default:return(o=>{})()}};function ce(e,t,r=!1){var o;const n=t.seen.get(e);if(t.override){const l=(o=t.override)==null?void 0:o.call(t,e,t,n,r);if(l!==pA)return l}if(n&&!r){const l=WA(n,t);if(l!==void 0)return l}const i={def:e,path:t.currentPath,jsonSchema:void 0};t.seen.set(e,i);const a=JA(e,e.typeName,t),s=typeof a=="function"?ce(a(),t):a;if(s&&HA(e,t,s),t.postProcess){const l=t.postProcess(s,e,t);return i.jsonSchema=s,l}return i.jsonSchema=s,s}var WA=(e,t)=>{switch(t.$refStrategy){case"root":return{$ref:e.path.join("/")};case"relative":return{$ref:dA(t.currentPath,e.path)};case"none":case"seen":return e.path.length<t.currentPath.length&&e.path.every((r,o)=>t.currentPath[o]===r)?(console.warn(`Recursive reference detected at ${t.currentPath.join("/")}! Defaulting to any`),tt()):t.$refStrategy==="seen"?tt():void 0}},HA=(e,t,r)=>(e.description&&(r.description=e.description),r),GA=e=>{const t=fA(e),r=t.name!==void 0?[...t.basePath,t.definitionPath,t.name]:t.basePath;return{...t,currentPath:r,propertyPath:void 0,seen:new Map(Object.entries(t.definitions).map(([o,n])=>[n._def,{def:n._def,path:[...t.basePath,t.definitionPath,o],jsonSchema:void 0}]))}},KA=(e,t)=>{var r;const o=GA(t);let n=typeof t=="object"&&t.definitions?Object.entries(t.definitions).reduce((u,[c,d])=>{var f;return{...u,[c]:(f=ce(d._def,{...o,currentPath:[...o.basePath,o.definitionPath,c]},!0))!=null?f:tt()}},{}):void 0;const i=typeof t=="string"?t:t?.nameStrategy==="title"?void 0:t?.name,a=(r=ce(e._def,i===void 0?o:{...o,currentPath:[...o.basePath,o.definitionPath,i]},!1))!=null?r:tt(),s=typeof t=="object"&&t.name!==void 0&&t.nameStrategy==="title"?t.name:void 0;s!==void 0&&(a.title=s);const l=i===void 0?n?{...a,[o.definitionPath]:n}:a:{$ref:[...o.$refStrategy==="relative"?[]:o.basePath,o.definitionPath,i].join("/"),[o.definitionPath]:{...n,[i]:a}};return l.$schema="http://json-schema.org/draft-07/schema#",l},YA=KA;function QA(e,t){var r;const o=(r=void 0)!=null?r:!1;return Bc(()=>YA(e,{$refStrategy:o?"root":"none"}),{validate:async n=>{const i=await e.safeParseAsync(n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function XA(e,t){var r;const o=(r=void 0)!=null?r:!1;return Bc(()=>fa(e,{target:"draft-7",io:"output",reused:o?"ref":"inline"}),{validate:async n=>{const i=await ma(e,n);return i.success?{success:!0,value:i.data}:{success:!1,error:i.error}}})}function eR(e){return"_zod"in e}function Or(e,t){return eR(e)?XA(e):QA(e)}var Iu=Symbol.for("vercel.ai.schema");function Bc(e,{validate:t}={}){return{[Iu]:!0,_type:void 0,[Mi]:!0,get jsonSchema(){return typeof e=="function"&&(e=e()),e},validate:t}}function tR(e){return typeof e=="object"&&e!==null&&Iu in e&&e[Iu]===!0&&"jsonSchema"in e&&"validate"in e}function Ha(e){return e==null?Bc({properties:{},additionalProperties:!1}):tR(e)?e:typeof e=="function"?e():Or(e)}var{btoa:rR,atob:nR}=globalThis;function Jc(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=nR(t);return Uint8Array.from(r,o=>o.codePointAt(0))}function ku(e){let t="";for(let r=0;r<e.length;r++)t+=String.fromCodePoint(e[r]);return rR(t)}function oR(e){return e?.replace(/\/$/,"")}function iR(e){return e!=null&&typeof e[Symbol.asyncIterator]=="function"}async function*aR({execute:e,input:t,options:r}){const o=e(t,r);if(iR(o)){let n;for await(const i of o)n=i,yield{type:"preliminary",output:i};yield{type:"final",output:n}}else yield{type:"final",output:await o}}var js,Yp;function sR(){if(Yp)return js;Yp=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,n=(c,d)=>{for(var f in d)e(c,f,{get:d[f],enumerable:!0})},i=(c,d,f,p)=>{if(d&&typeof d=="object"||typeof d=="function")for(let g of r(d))!o.call(c,g)&&g!==f&&e(c,g,{get:()=>d[g],enumerable:!(p=t(d,g))||p.enumerable});return c},a=c=>i(e({},"__esModule",{value:!0}),c),s={};n(s,{SYMBOL_FOR_REQ_CONTEXT:()=>l,getContext:()=>u}),js=a(s);const l=Symbol.for("@vercel/request-context");function u(){return globalThis[l]?.get?.()??{}}return js}var As,Qp;function uR(){if(Qp)return As;Qp=1;var e=Object.defineProperty,t=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,n=(d,f)=>{for(var p in f)e(d,p,{get:f[p],enumerable:!0})},i=(d,f,p,g)=>{if(f&&typeof f=="object"||typeof f=="function")for(let h of r(f))!o.call(d,h)&&h!==p&&e(d,h,{get:()=>f[h],enumerable:!(g=t(f,h))||g.enumerable});return d},a=d=>i(e({},"__esModule",{value:!0}),d),s={};n(s,{getContext:()=>l.getContext,getVercelOidcToken:()=>u,getVercelOidcTokenSync:()=>c}),As=a(s);var l=sR();async function u(){return""}function c(){return""}return As}var gx=uR(),lR="vercel.ai.gateway.error",Rs=Symbol.for(lR),Xp,ef,rt=class vx extends(ef=Error,Xp=Rs,ef){constructor({message:t,statusCode:r=500,cause:o}){super(t),this[Xp]=!0,this.statusCode=r,this.cause=o}static isInstance(t){return vx.hasMarker(t)}static hasMarker(t){return typeof t=="object"&&t!==null&&Rs in t&&t[Rs]===!0}},yx="GatewayAuthenticationError",cR=`vercel.ai.gateway.error.${yx}`,tf=Symbol.for(cR),rf,nf,Wc=class bx extends(nf=rt,rf=tf,nf){constructor({message:t="Authentication failed",statusCode:r=401,cause:o}={}){super({message:t,statusCode:r,cause:o}),this[rf]=!0,this.name=yx,this.type="authentication_error"}static isInstance(t){return rt.hasMarker(t)&&tf in t}static createContextualError({apiKeyProvided:t,oidcTokenProvided:r,message:o="Authentication failed",statusCode:n=401,cause:i}){let a;return t?a=`AI Gateway authentication failed: Invalid API key.
|
|
70
70
|
|
|
71
71
|
Create a new API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
72
72
|
|
|
@@ -81,20 +81,20 @@ Create an API key: https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%2Fapi-keys
|
|
|
81
81
|
Provide via 'apiKey' option or 'AI_GATEWAY_API_KEY' environment variable.
|
|
82
82
|
|
|
83
83
|
Option 2 - OIDC token:
|
|
84
|
-
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,new bx({message:a,statusCode:n,cause:i})}},_x="GatewayInvalidRequestError",cR=`vercel.ai.gateway.error.${_x}`,of=Symbol.for(cR),af,sf,dR=class extends(sf=rt,af=of,sf){constructor({message:e="Invalid request",statusCode:t=400,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[af]=!0,this.name=_x,this.type="invalid_request_error"}static isInstance(e){return rt.hasMarker(e)&&of in e}},wx="GatewayRateLimitError",pR=`vercel.ai.gateway.error.${wx}`,uf=Symbol.for(pR),lf,cf,fR=class extends(cf=rt,lf=uf,cf){constructor({message:e="Rate limit exceeded",statusCode:t=429,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[lf]=!0,this.name=wx,this.type="rate_limit_exceeded"}static isInstance(e){return rt.hasMarker(e)&&uf in e}},xx="GatewayModelNotFoundError",mR=`vercel.ai.gateway.error.${xx}`,df=Symbol.for(mR),hR=cn(()=>Or(E({modelId:w()}))),pf,ff,$x=class extends(ff=rt,pf=df,ff){constructor({message:e="Model not found",statusCode:t=404,modelId:r,cause:o}={}){super({message:e,statusCode:t,cause:o}),this[pf]=!0,this.name=xx,this.type="model_not_found",this.modelId=r}static isInstance(e){return rt.hasMarker(e)&&df in e}},Sx="GatewayInternalServerError",gR=`vercel.ai.gateway.error.${Sx}`,mf=Symbol.for(gR),hf,gf,vf=class extends(gf=rt,hf=mf,gf){constructor({message:e="Internal server error",statusCode:t=500,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[hf]=!0,this.name=Sx,this.type="internal_server_error"}static isInstance(e){return rt.hasMarker(e)&&mf in e}},Ix="GatewayResponseError",vR=`vercel.ai.gateway.error.${Ix}`,yf=Symbol.for(vR),bf,_f,yR=class extends(_f=rt,bf=yf,_f){constructor({message:e="Invalid response from Gateway",statusCode:t=502,response:r,validationError:o,cause:n}={}){super({message:e,statusCode:t,cause:n}),this[bf]=!0,this.name=Ix,this.type="response_error",this.response=r,this.validationError=o}static isInstance(e){return rt.hasMarker(e)&&yf in e}};async function wf({response:e,statusCode:t,defaultMessage:r="Gateway request failed",cause:o,authMethod:n}){const i=await sr({value:e,schema:bR});if(!i.success)return new yR({message:`Invalid error response format: ${r}`,statusCode:t,response:e,validationError:i.error,cause:o});const a=i.value,s=a.error.type,l=a.error.message;switch(s){case"authentication_error":return Wc.createContextualError({apiKeyProvided:n==="api-key",oidcTokenProvided:n==="oidc",statusCode:t,cause:o});case"invalid_request_error":return new dR({message:l,statusCode:t,cause:o});case"rate_limit_exceeded":return new fR({message:l,statusCode:t,cause:o});case"model_not_found":{const u=await sr({value:a.error.param,schema:hR});return new $x({message:l,statusCode:t,modelId:u.success?u.value.modelId:void 0,cause:o})}case"internal_server_error":return new vf({message:l,statusCode:t,cause:o});default:return new vf({message:l,statusCode:t,cause:o})}}var bR=cn(()=>Or(E({error:E({message:w(),type:w().nullish(),param:$e().nullish(),code:G([w(),q()]).nullish()})})));function $r(e,t){var r;return rt.isInstance(e)?e:Be.isInstance(e)?wf({response:_R(e),statusCode:(r=e.statusCode)!=null?r:500,defaultMessage:"Gateway request failed",cause:e,authMethod:t}):wf({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:"Unknown Gateway error",cause:e,authMethod:t})}function _R(e){if(e.data!==void 0)return e.data;if(e.responseBody!=null)try{return JSON.parse(e.responseBody)}catch{return e.responseBody}return{}}var kx="ai-gateway-auth-method";async function Hn(e){const t=await sr({value:e[kx],schema:wR});return t.success?t.value:void 0}var wR=cn(()=>Or(G([C("api-key"),C("oidc")]))),xf=class{constructor(e){this.config=e}async getAvailableModels(){try{const{value:e}=await Hp({url:`${this.config.baseURL}/config`,headers:await tr(this.config.headers()),successfulResponseHandler:Mi(xR),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:t=>t}),fetch:this.config.fetch});return e}catch(e){throw await $r(e)}}async getCredits(){try{const e=new URL(this.config.baseURL),{value:t}=await Hp({url:`${e.origin}/v1/credits`,headers:await tr(this.config.headers()),successfulResponseHandler:Mi($R),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:r=>r}),fetch:this.config.fetch});return t}catch(e){throw await $r(e)}}},xR=cn(()=>Or(E({models:R(E({id:w(),name:w(),description:w().nullish(),pricing:E({input:w(),output:w(),input_cache_read:w().nullish(),input_cache_write:w().nullish()}).transform(({input:e,output:t,input_cache_read:r,input_cache_write:o})=>({input:e,output:t,...r?{cachedInputTokens:r}:{},...o?{cacheCreationInputTokens:o}:{}})).nullish(),specification:E({specificationVersion:C("v2"),provider:w(),modelId:w()}),modelType:dr(["language","embedding","image"]).nullish()}))}))),$R=cn(()=>Or(E({balance:w(),total_used:w()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),SR=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.supportedUrls={"*/*":[/.*/]}}get provider(){return this.config.provider}async getArgs(e){const{abortSignal:t,...r}=e;return{args:this.maybeEncodeFileParts(r),warnings:[]}}async doGenerate(e){const{args:t,warnings:r}=await this.getArgs(e),{abortSignal:o}=e,n=await tr(this.config.headers());try{const{responseHeaders:i,value:a,rawValue:s}=await $u({url:this.getUrl(),headers:wu(n,e.headers,this.getModelConfigHeaders(this.modelId,!1),await tr(this.config.o11yHeaders)),body:t,successfulResponseHandler:Mi(Pe()),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:l=>l}),...o&&{abortSignal:o},fetch:this.config.fetch});return{...a,request:{body:t},response:{headers:i,body:s},warnings:r}}catch(i){throw await $r(i,await Hn(n))}}async doStream(e){const{args:t,warnings:r}=await this.getArgs(e),{abortSignal:o}=e,n=await tr(this.config.headers());try{const{value:i,responseHeaders:a}=await $u({url:this.getUrl(),headers:wu(n,e.headers,this.getModelConfigHeaders(this.modelId,!0),await tr(this.config.o11yHeaders)),body:t,successfulResponseHandler:lA(Pe()),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:s=>s}),...o&&{abortSignal:o},fetch:this.config.fetch});return{stream:i.pipeThrough(new TransformStream({start(s){r.length>0&&s.enqueue({type:"stream-start",warnings:r})},transform(s,l){if(s.success){const u=s.value;if(u.type==="raw"&&!e.includeRawChunks)return;u.type==="response-metadata"&&u.timestamp&&typeof u.timestamp=="string"&&(u.timestamp=new Date(u.timestamp)),l.enqueue(u)}else l.error(s.error)}})),request:{body:t},response:{headers:a}}}catch(i){throw await $r(i,await Hn(n))}}isFilePart(e){return e&&typeof e=="object"&&"type"in e&&e.type==="file"}maybeEncodeFileParts(e){for(const t of e.prompt)for(const r of t.content)if(this.isFilePart(r)){const o=r;if(o.data instanceof Uint8Array){const n=Uint8Array.from(o.data),i=Buffer.from(n).toString("base64");o.data=new URL(`data:${o.mediaType||"application/octet-stream"};base64,${i}`)}}return e}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(e,t){return{"ai-language-model-specification-version":"2","ai-language-model-id":e,"ai-language-model-streaming":String(t)}}},IR=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}get provider(){return this.config.provider}async doEmbed({values:e,headers:t,abortSignal:r,providerOptions:o}){var n;const i=await tr(this.config.headers());try{const{responseHeaders:a,value:s,rawValue:l}=await $u({url:this.getUrl(),headers:wu(i,t??{},this.getModelConfigHeaders(),await tr(this.config.o11yHeaders)),body:{input:e.length===1?e[0]:e,...o?{providerOptions:o}:{}},successfulResponseHandler:Mi(kR),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:u=>u}),...r&&{abortSignal:r},fetch:this.config.fetch});return{embeddings:s.embeddings,usage:(n=s.usage)!=null?n:void 0,providerMetadata:s.providerMetadata,response:{headers:a,body:l}}}catch(a){throw await $r(a,await Hn(i))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":"2","ai-model-id":this.modelId}}},kR=cn(()=>Or(E({embeddings:R(R(q())),usage:E({tokens:q()}).nullish(),providerMetadata:Xe(w(),Xe(w(),$e())).optional()})));async function ER(){var e;return(e=gx.getContext().headers)==null?void 0:e["x-vercel-id"]}var TR="2.0.7",OR="0.0.1";function NR(e={}){var t,r;let o=null,n=null;const i=(t=e.metadataCacheRefreshMillis)!=null?t:1e3*60*5;let a=0;const s=(r=nR(e.baseURL))!=null?r:"https://ai-gateway.vercel.sh/v1/ai",l=async()=>{const g=await CR(e);if(g)return Ja({Authorization:`Bearer ${g.token}`,"ai-gateway-protocol-version":OR,[kx]:g.authMethod,...e.headers},`ai-sdk/gateway/${TR}`);throw Wc.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401})},u=()=>{const g=ii({settingValue:void 0,environmentVariableName:"VERCEL_DEPLOYMENT_ID"}),h=ii({settingValue:void 0,environmentVariableName:"VERCEL_ENV"}),b=ii({settingValue:void 0,environmentVariableName:"VERCEL_REGION"});return async()=>{const y=await ER();return{...g&&{"ai-o11y-deployment-id":g},...h&&{"ai-o11y-environment":h},...b&&{"ai-o11y-region":b},...y&&{"ai-o11y-request-id":y}}}},c=g=>new SR(g,{provider:"gateway",baseURL:s,headers:l,fetch:e.fetch,o11yHeaders:u()}),d=async()=>{var g,h,b;const y=(b=(h=(g=e._internal)==null?void 0:g.currentDate)==null?void 0:h.call(g).getTime())!=null?b:Date.now();return(!o||y-a>i)&&(a=y,o=new xf({baseURL:s,headers:l,fetch:e.fetch}).getAvailableModels().then(x=>(n=x,x)).catch(async x=>{throw await $r(x,await Hn(await l()))})),n?Promise.resolve(n):o},f=async()=>new xf({baseURL:s,headers:l,fetch:e.fetch}).getCredits().catch(async g=>{throw await $r(g,await Hn(await l()))}),p=function(g){if(new.target)throw new Error("The Gateway Provider model function cannot be called with the new keyword.");return c(g)};return p.getAvailableModels=d,p.getCredits=f,p.imageModel=g=>{throw new j0({modelId:g,modelType:"imageModel"})},p.languageModel=c,p.textEmbeddingModel=g=>new IR(g,{provider:"gateway",baseURL:s,headers:l,fetch:e.fetch,o11yHeaders:u()}),p}var PR=NR();async function CR(e){const t=ii({settingValue:e.apiKey,environmentVariableName:"AI_GATEWAY_API_KEY"});if(t)return{token:t,authMethod:"api-key"};try{return{token:await gx.getVercelOidcToken(),authMethod:"oidc"}}catch{return null}}var jR=Object.defineProperty,AR=(e,t)=>{for(var r in t)jR(e,r,{get:t[r],enumerable:!0})},Ex="AI_NoOutputSpecifiedError",Tx=`vercel.ai.error.${Ex}`,RR=Symbol.for(Tx),Ox,zR=class extends Y{constructor({message:e="No output specified."}={}){super({name:Ex,message:e}),this[Ox]=!0}static isInstance(e){return Y.hasMarker(e,Tx)}};Ox=RR;function MR(e){const t="AI SDK Warning:";switch(e.type){case"unsupported-setting":{let r=`${t} The "${e.setting}" setting is not supported by this model`;return e.details&&(r+=` - ${e.details}`),r}case"unsupported-tool":{const r="name"in e.tool?e.tool.name:"unknown tool";let o=`${t} The tool "${r}" is not supported by this model`;return e.details&&(o+=` - ${e.details}`),o}case"other":return`${t} ${e.message}`;default:return`${t} ${JSON.stringify(e,null,2)}`}}var DR="AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.",$f=!1,UR=e=>{if(e.length===0)return;const t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t=="function"){t(e);return}$f||($f=!0,console.info(DR));for(const r of e)console.warn(MR(r))}},Nx="AI_InvalidArgumentError",Px=`vercel.ai.error.${Nx}`,LR=Symbol.for(Px),Cx,Nt=class extends Y{constructor({parameter:e,value:t,message:r}){super({name:Nx,message:`Invalid argument for parameter ${e}: ${r}`}),this[Cx]=!0,this.parameter=e,this.value=t}static isInstance(e){return Y.hasMarker(e,Px)}};Cx=LR;var jx="AI_InvalidToolInputError",Ax=`vercel.ai.error.${jx}`,ZR=Symbol.for(Ax),Rx,zx=class extends Y{constructor({toolInput:e,toolName:t,cause:r,message:o=`Invalid input for tool ${t}: ${sn(r)}`}){super({name:jx,message:o,cause:r}),this[Rx]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return Y.hasMarker(e,Ax)}};Rx=ZR;var Mx="AI_NoObjectGeneratedError",Dx=`vercel.ai.error.${Mx}`,FR=Symbol.for(Dx),Ux,Sf=class extends Y{constructor({message:e="No object generated.",cause:t,text:r,response:o,usage:n,finishReason:i}){super({name:Mx,message:e,cause:t}),this[Ux]=!0,this.text=r,this.response=o,this.usage=n,this.finishReason=i}static isInstance(e){return Y.hasMarker(e,Dx)}};Ux=FR;var Lx="AI_NoOutputGeneratedError",Zx=`vercel.ai.error.${Lx}`,qR=Symbol.for(Zx),Fx,VR=class extends Y{constructor({message:e="No output generated.",cause:t}={}){super({name:Lx,message:e,cause:t}),this[Fx]=!0}static isInstance(e){return Y.hasMarker(e,Zx)}};Fx=qR;var qx="AI_NoSuchToolError",Vx=`vercel.ai.error.${qx}`,BR=Symbol.for(Vx),Bx,Eu=class extends Y{constructor({toolName:e,availableTools:t=void 0,message:r=`Model tried to call unavailable tool '${e}'. ${t===void 0?"No tools are available.":`Available tools: ${t.join(", ")}.`}`}){super({name:qx,message:r}),this[Bx]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return Y.hasMarker(e,Vx)}};Bx=BR;var Jx="AI_ToolCallRepairError",Wx=`vercel.ai.error.${Jx}`,JR=Symbol.for(Wx),Hx,WR=class extends Y{constructor({cause:e,originalError:t,message:r=`Error repairing tool call: ${sn(e)}`}){super({name:Jx,message:r,cause:e}),this[Hx]=!0,this.originalError=t}static isInstance(e){return Y.hasMarker(e,Wx)}};Hx=JR;var HR=class extends Y{constructor(e){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=e.version,this.provider=e.provider,this.modelId=e.modelId}},Gx="AI_InvalidMessageRoleError",Kx=`vercel.ai.error.${Gx}`,GR=Symbol.for(Kx),Yx,KR=class extends Y{constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:Gx,message:t}),this[Yx]=!0,this.role=e}static isInstance(e){return Y.hasMarker(e,Kx)}};Yx=GR;var Qx="AI_MessageConversionError",Xx=`vercel.ai.error.${Qx}`,YR=Symbol.for(Xx),e$,QR=class extends Y{constructor({originalMessage:e,message:t}){super({name:Qx,message:t}),this[e$]=!0,this.originalMessage=e}static isInstance(e){return Y.hasMarker(e,Xx)}};e$=YR;var t$="AI_DownloadError",r$=`vercel.ai.error.${t$}`,XR=Symbol.for(r$),n$,Rs=class extends Y{constructor({url:e,statusCode:t,statusText:r,cause:o,message:n=o==null?`Failed to download ${e}: ${t} ${r}`:`Failed to download ${e}: ${o}`}){super({name:t$,message:n,cause:o}),this[n$]=!0,this.url=e,this.statusCode=t,this.statusText=r}static isInstance(e){return Y.hasMarker(e,r$)}};n$=XR;var o$="AI_RetryError",i$=`vercel.ai.error.${o$}`,ez=Symbol.for(i$),a$,If=class extends Y{constructor({message:e,reason:t,errors:r}){super({name:o$,message:e}),this[a$]=!0,this.reason=t,this.errors=r,this.lastError=r[r.length-1]}static isInstance(e){return Y.hasMarker(e,i$)}};a$=ez;function s$(e){if(typeof e!="string"){if(e.specificationVersion!=="v2")throw new HR({version:e.specificationVersion,provider:e.provider,modelId:e.modelId});return e}return tz().languageModel(e)}function tz(){var e;return(e=globalThis.AI_SDK_DEFAULT_PROVIDER)!=null?e:PR}var rz=[{mediaType:"image/gif",bytesPrefix:[71,73,70]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],nz=e=>{const t=typeof e=="string"?Jc(e):e,r=(t[6]&127)<<21|(t[7]&127)<<14|(t[8]&127)<<7|t[9]&127;return t.slice(r+10)};function oz(e){return typeof e=="string"&&e.startsWith("SUQz")||typeof e!="string"&&e.length>10&&e[0]===73&&e[1]===68&&e[2]===51?nz(e):e}function iz({data:e,signatures:t}){const r=oz(e),o=typeof r=="string"?Jc(r.substring(0,Math.min(r.length,24))):r;for(const n of t)if(o.length>=n.bytesPrefix.length&&n.bytesPrefix.every((i,a)=>i===null||o[a]===i))return n.mediaType}var az="5.0.90",sz=async({url:e})=>{var t;const r=e.toString();try{const o=await fetch(r,{headers:Ja({},`ai-sdk/${az}`,Vc())});if(!o.ok)throw new Rs({url:r,statusCode:o.status,statusText:o.statusText});return{data:new Uint8Array(await o.arrayBuffer()),mediaType:(t=o.headers.get("content-type"))!=null?t:void 0}}catch(o){throw Rs.isInstance(o)?o:new Rs({url:r,cause:o})}},uz=(e=sz)=>t=>Promise.all(t.map(async r=>r.isUrlSupportedByModel?null:e(r)));function lz(e){try{const[t,r]=e.split(",");return{mediaType:t.split(";")[0].split(":")[1],base64Content:r}}catch{return{mediaType:void 0,base64Content:void 0}}}var u$=G([w(),Rt(Uint8Array),Rt(ArrayBuffer),So(e=>{var t,r;return(r=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?r:!1},{message:"Must be a Buffer"})]);function l$(e){if(e instanceof Uint8Array)return{data:e,mediaType:void 0};if(e instanceof ArrayBuffer)return{data:new Uint8Array(e),mediaType:void 0};if(typeof e=="string")try{e=new URL(e)}catch{}if(e instanceof URL&&e.protocol==="data:"){const{mediaType:t,base64Content:r}=lz(e.toString());if(t==null||r==null)throw new Y({name:"InvalidDataContentError",message:`Invalid data URL format in content ${e.toString()}`});return{data:r,mediaType:t}}return{data:e,mediaType:void 0}}function cz(e){return typeof e=="string"?e:e instanceof ArrayBuffer?ku(new Uint8Array(e)):ku(e)}async function dz({prompt:e,supportedUrls:t,download:r=uz()}){const o=await fz(e.messages,r,t);return[...e.system!=null?[{role:"system",content:e.system}]:[],...e.messages.map(n=>pz({message:n,downloadedAssets:o}))]}function pz({message:e,downloadedAssets:t}){const r=e.role;switch(r){case"system":return{role:"system",content:e.content,providerOptions:e.providerOptions};case"user":return typeof e.content=="string"?{role:"user",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"user",content:e.content.map(o=>mz(o,t)).filter(o=>o.type!=="text"||o.text!==""),providerOptions:e.providerOptions};case"assistant":return typeof e.content=="string"?{role:"assistant",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"assistant",content:e.content.filter(o=>o.type!=="text"||o.text!==""||o.providerOptions!=null).map(o=>{const n=o.providerOptions;switch(o.type){case"file":{const{data:i,mediaType:a}=l$(o.data);return{type:"file",data:i,filename:o.filename,mediaType:a??o.mediaType,providerOptions:n}}case"reasoning":return{type:"reasoning",text:o.text,providerOptions:n};case"text":return{type:"text",text:o.text,providerOptions:n};case"tool-call":return{type:"tool-call",toolCallId:o.toolCallId,toolName:o.toolName,input:o.input,providerExecuted:o.providerExecuted,providerOptions:n};case"tool-result":return{type:"tool-result",toolCallId:o.toolCallId,toolName:o.toolName,output:o.output,providerOptions:n}}}),providerOptions:e.providerOptions};case"tool":return{role:"tool",content:e.content.map(o=>({type:"tool-result",toolCallId:o.toolCallId,toolName:o.toolName,output:o.output,providerOptions:o.providerOptions})),providerOptions:e.providerOptions};default:{const o=r;throw new KR({role:o})}}}async function fz(e,t,r){const o=e.filter(i=>i.role==="user").map(i=>i.content).filter(i=>Array.isArray(i)).flat().filter(i=>i.type==="image"||i.type==="file").map(i=>{var a;const s=(a=i.mediaType)!=null?a:i.type==="image"?"image/*":void 0;let l=i.type==="image"?i.image:i.data;if(typeof l=="string")try{l=new URL(l)}catch{}return{mediaType:s,data:l}}).filter(i=>i.data instanceof URL).map(i=>({url:i.data,isUrlSupportedByModel:i.mediaType!=null&&K1({url:i.data.toString(),mediaType:i.mediaType,supportedUrls:r})})),n=await t(o);return Object.fromEntries(n.map((i,a)=>i==null?null:[o[a].url.toString(),{data:i.data,mediaType:i.mediaType}]).filter(i=>i!=null))}function mz(e,t){var r;if(e.type==="text")return{type:"text",text:e.text,providerOptions:e.providerOptions};let o;const n=e.type;switch(n){case"image":o=e.image;break;case"file":o=e.data;break;default:throw new Error(`Unsupported part type: ${n}`)}const{data:i,mediaType:a}=l$(o);let s=a??e.mediaType,l=i;if(l instanceof URL){const u=t[l.toString()];u&&(l=u.data,s??(s=u.mediaType))}switch(n){case"image":return(l instanceof Uint8Array||typeof l=="string")&&(s=(r=iz({data:l,signatures:rz}))!=null?r:s),{type:"file",mediaType:s??"image/*",filename:void 0,data:l,providerOptions:e.providerOptions};case"file":{if(s==null)throw new Error("Media type is missing for file part");return{type:"file",mediaType:s,filename:e.filename,data:l,providerOptions:e.providerOptions}}}}function hz({maxOutputTokens:e,temperature:t,topP:r,topK:o,presencePenalty:n,frequencyPenalty:i,seed:a,stopSequences:s}){if(e!=null){if(!Number.isInteger(e))throw new Nt({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be an integer"});if(e<1)throw new Nt({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be >= 1"})}if(t!=null&&typeof t!="number")throw new Nt({parameter:"temperature",value:t,message:"temperature must be a number"});if(r!=null&&typeof r!="number")throw new Nt({parameter:"topP",value:r,message:"topP must be a number"});if(o!=null&&typeof o!="number")throw new Nt({parameter:"topK",value:o,message:"topK must be a number"});if(n!=null&&typeof n!="number")throw new Nt({parameter:"presencePenalty",value:n,message:"presencePenalty must be a number"});if(i!=null&&typeof i!="number")throw new Nt({parameter:"frequencyPenalty",value:i,message:"frequencyPenalty must be a number"});if(a!=null&&!Number.isInteger(a))throw new Nt({parameter:"seed",value:a,message:"seed must be an integer"});return{maxOutputTokens:e,temperature:t,topP:r,topK:o,presencePenalty:n,frequencyPenalty:i,stopSequences:s,seed:a}}function gz(e){return e!=null&&Object.keys(e).length>0}function vz({tools:e,toolChoice:t,activeTools:r}){return gz(e)?{tools:(r!=null?Object.entries(e).filter(([n])=>r.includes(n)):Object.entries(e)).map(([n,i])=>{const a=i.type;switch(a){case void 0:case"dynamic":case"function":return{type:"function",name:n,description:i.description,inputSchema:Wa(i.inputSchema).jsonSchema,providerOptions:i.providerOptions};case"provider-defined":return{type:"provider-defined",name:n,id:i.id,args:i.args};default:{const s=a;throw new Error(`Unsupported tool type: ${s}`)}}}),toolChoice:t==null?{type:"auto"}:typeof t=="string"?{type:t}:{type:"tool",toolName:t.toolName}}:{tools:void 0,toolChoice:void 0}}var Gn=xo(()=>G([yo(),w(),q(),pe(),Xe(w(),Gn),R(Gn)])),Mt=Xe(w(),Xe(w(),Gn)),c$=E({type:C("text"),text:w(),providerOptions:Mt.optional()}),yz=E({type:C("image"),image:G([u$,Rt(URL)]),mediaType:w().optional(),providerOptions:Mt.optional()}),d$=E({type:C("file"),data:G([u$,Rt(URL)]),filename:w().optional(),mediaType:w(),providerOptions:Mt.optional()}),bz=E({type:C("reasoning"),text:w(),providerOptions:Mt.optional()}),_z=E({type:C("tool-call"),toolCallId:w(),toolName:w(),input:$e(),providerOptions:Mt.optional(),providerExecuted:pe().optional()}),wz=Ra("type",[E({type:C("text"),value:w()}),E({type:C("json"),value:Gn}),E({type:C("error-text"),value:w()}),E({type:C("error-json"),value:Gn}),E({type:C("content"),value:R(G([E({type:C("text"),text:w()}),E({type:C("media"),data:w(),mediaType:w()})]))})]),p$=E({type:C("tool-result"),toolCallId:w(),toolName:w(),output:wz,providerOptions:Mt.optional()}),xz=E({role:C("system"),content:w(),providerOptions:Mt.optional()}),$z=E({role:C("user"),content:G([w(),R(G([c$,yz,d$]))]),providerOptions:Mt.optional()}),Sz=E({role:C("assistant"),content:G([w(),R(G([c$,d$,bz,_z,p$]))]),providerOptions:Mt.optional()}),Iz=E({role:C("tool"),content:R(p$),providerOptions:Mt.optional()}),kz=G([xz,$z,Sz,Iz]);async function Ez(e){if(e.prompt==null&&e.messages==null)throw new jr({prompt:e,message:"prompt or messages must be defined"});if(e.prompt!=null&&e.messages!=null)throw new jr({prompt:e,message:"prompt and messages cannot be defined at the same time"});if(e.system!=null&&typeof e.system!="string")throw new jr({prompt:e,message:"system must be a string"});let t;if(e.prompt!=null&&typeof e.prompt=="string")t=[{role:"user",content:e.prompt}];else if(e.prompt!=null&&Array.isArray(e.prompt))t=e.prompt;else if(e.messages!=null)t=e.messages;else throw new jr({prompt:e,message:"prompt or messages must be defined"});if(t.length===0)throw new jr({prompt:e,message:"messages must not be empty"});const r=await sr({value:t,schema:R(kz)});if(!r.success)throw new jr({prompt:e,message:"The messages must be a ModelMessage[]. If you have passed a UIMessage[], you can use convertToModelMessages to convert them.",cause:r.error});return{messages:t,system:e.system}}function Tz(e){return Wc.isInstance(e)||$x.isInstance(e)?new Y({name:"GatewayError",message:"Vercel AI Gateway access failed. If you want to use AI SDK providers directly, use the providers, e.g. @ai-sdk/openai, or register a different global default provider.",cause:e}):e}function Tu({operationId:e,telemetry:t}){return{"operation.name":`${e}${t?.functionId!=null?` ${t.functionId}`:""}`,"resource.name":t?.functionId,"ai.operationId":e,"ai.telemetry.functionId":t?.functionId}}function Oz({model:e,settings:t,telemetry:r,headers:o}){var n;return{"ai.model.provider":e.provider,"ai.model.id":e.modelId,...Object.entries(t).reduce((i,[a,s])=>(i[`ai.settings.${a}`]=s,i),{}),...Object.entries((n=r?.metadata)!=null?n:{}).reduce((i,[a,s])=>(i[`ai.telemetry.metadata.${a}`]=s,i),{}),...Object.entries(o??{}).reduce((i,[a,s])=>(s!==void 0&&(i[`ai.request.headers.${a}`]=s),i),{})}}var Nz={startSpan(){return Jo},startActiveSpan(e,t,r,o){if(typeof t=="function")return t(Jo);if(typeof r=="function")return r(Jo);if(typeof o=="function")return o(Jo)}},Jo={spanContext(){return Pz},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this}},Pz={traceId:"",spanId:"",traceFlags:0};function Cz({isEnabled:e=!1,tracer:t}={}){return e?t||RC.getTracer("ai"):Nz}function Ou({name:e,tracer:t,attributes:r,fn:o,endWhenDone:n=!0}){return t.startActiveSpan(e,{attributes:r},async i=>{try{const a=await o(i);return n&&i.end(),a}catch(a){try{f$(i,a)}finally{i.end()}throw a}})}function f$(e,t){t instanceof Error?(e.recordException({name:t.name,message:t.message,stack:t.stack}),e.setStatus({code:Ci.ERROR,message:t.message})):e.setStatus({code:Ci.ERROR})}function Lr({telemetry:e,attributes:t}){return e?.isEnabled!==!0?{}:Object.entries(t).reduce((r,[o,n])=>{if(n==null)return r;if(typeof n=="object"&&"input"in n&&typeof n.input=="function"){if(e?.recordInputs===!1)return r;const i=n.input();return i==null?r:{...r,[o]:i}}if(typeof n=="object"&&"output"in n&&typeof n.output=="function"){if(e?.recordOutputs===!1)return r;const i=n.output();return i==null?r:{...r,[o]:i}}return{...r,[o]:n}},{})}function jz(e){return JSON.stringify(e.map(t=>({...t,content:typeof t.content=="string"?t.content:t.content.map(r=>r.type==="file"?{...r,data:r.data instanceof Uint8Array?cz(r.data):r.data}:r)})))}function Az(e,t){return{inputTokens:xn(e.inputTokens,t.inputTokens),outputTokens:xn(e.outputTokens,t.outputTokens),totalTokens:xn(e.totalTokens,t.totalTokens),reasoningTokens:xn(e.reasoningTokens,t.reasoningTokens),cachedInputTokens:xn(e.cachedInputTokens,t.cachedInputTokens)}}function xn(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}function kf(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function Rz({error:e,exponentialBackoffDelay:t}){const r=e.responseHeaders;if(!r)return t;let o;const n=r["retry-after-ms"];if(n){const a=parseFloat(n);Number.isNaN(a)||(o=a)}const i=r["retry-after"];if(i&&o===void 0){const a=parseFloat(i);Number.isNaN(a)?o=Date.parse(i)-Date.now():o=a*1e3}return o!=null&&!Number.isNaN(o)&&0<=o&&(o<60*1e3||o<t)?o:t}var zz=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:r=2,abortSignal:o}={})=>async n=>m$(n,{maxRetries:e,delayInMs:t,backoffFactor:r,abortSignal:o});async function m$(e,{maxRetries:t,delayInMs:r,backoffFactor:o,abortSignal:n},i=[]){try{return await e()}catch(a){if(wr(a)||t===0)throw a;const s=ux(a),l=[...i,a],u=l.length;if(u>t)throw new If({message:`Failed after ${u} attempts. Last error: ${s}`,reason:"maxRetriesExceeded",errors:l});if(a instanceof Error&&Be.isInstance(a)&&a.isRetryable===!0&&u<=t)return await sx(Rz({error:a,exponentialBackoffDelay:r}),{abortSignal:n}),m$(e,{maxRetries:t,delayInMs:o*r,backoffFactor:o,abortSignal:n},l);throw u===1?a:new If({message:`Failed after ${u} attempts with non-retryable error: '${s}'`,reason:"errorNotRetryable",errors:l})}}function Mz({maxRetries:e,abortSignal:t}){if(e!=null){if(!Number.isInteger(e))throw new Nt({parameter:"maxRetries",value:e,message:"maxRetries must be an integer"});if(e<0)throw new Nt({parameter:"maxRetries",value:e,message:"maxRetries must be >= 0"})}const r=e??2;return{maxRetries:r,retry:zz({maxRetries:r,abortSignal:t})}}var Dz=class{constructor({data:e,mediaType:t}){const r=e instanceof Uint8Array;this.base64Data=r?void 0:e,this.uint8ArrayData=r?e:void 0,this.mediaType=t}get base64(){return this.base64Data==null&&(this.base64Data=ku(this.uint8ArrayData)),this.base64Data}get uint8Array(){return this.uint8ArrayData==null&&(this.uint8ArrayData=Jc(this.base64Data)),this.uint8ArrayData}},Uz=class extends Dz{constructor(e){super(e),this.type="file"}};async function Lz({toolCall:e,tools:t,repairToolCall:r,system:o,messages:n}){try{if(t==null)throw new Eu({toolName:e.toolName});try{return await Ef({toolCall:e,tools:t})}catch(i){if(r==null||!(Eu.isInstance(i)||zx.isInstance(i)))throw i;let a=null;try{a=await r({toolCall:e,tools:t,inputSchema:({toolName:s})=>{const{inputSchema:l}=t[s];return Wa(l).jsonSchema},system:o,messages:n,error:i})}catch(s){throw new WR({cause:s,originalError:i})}if(a==null)throw i;return await Ef({toolCall:a,tools:t})}}catch(i){const a=await xr({text:e.input}),s=a.success?a.value:e.input;return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:s,dynamic:!0,invalid:!0,error:i}}}async function Ef({toolCall:e,tools:t}){const r=e.toolName,o=t[r];if(o==null)throw new Eu({toolName:e.toolName,availableTools:Object.keys(t)});const n=Wa(o.inputSchema),i=e.input.trim()===""?await sr({value:{},schema:n}):await xr({text:e.input,schema:n});if(i.success===!1)throw new zx({toolName:r,toolInput:e.input,cause:i.error});return o.type==="dynamic"?{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,dynamic:!0}:{type:"tool-call",toolCallId:e.toolCallId,toolName:r,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata}}var Zz=class{constructor({content:e,finishReason:t,usage:r,warnings:o,request:n,response:i,providerMetadata:a}){this.content=e,this.finishReason=t,this.usage=r,this.warnings=o,this.request=n,this.response=i,this.providerMetadata=a}get text(){return this.content.filter(e=>e.type==="text").map(e=>e.text).join("")}get reasoning(){return this.content.filter(e=>e.type==="reasoning")}get reasoningText(){return this.reasoning.length===0?void 0:this.reasoning.map(e=>e.text).join("")}get files(){return this.content.filter(e=>e.type==="file").map(e=>e.file)}get sources(){return this.content.filter(e=>e.type==="source")}get toolCalls(){return this.content.filter(e=>e.type==="tool-call")}get staticToolCalls(){return this.toolCalls.filter(e=>e.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(e=>e.dynamic===!0)}get toolResults(){return this.content.filter(e=>e.type==="tool-result")}get staticToolResults(){return this.toolResults.filter(e=>e.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(e=>e.dynamic===!0)}};function h$(e){return({steps:t})=>t.length===e}async function Fz({stopConditions:e,steps:t}){return(await Promise.all(e.map(r=>r({steps:t})))).some(r=>r)}function Nn({output:e,tool:t,errorMode:r}){return r==="text"?{type:"error-text",value:sn(e)}:r==="json"?{type:"error-json",value:Tf(e)}:t?.toModelOutput?t.toModelOutput(e):typeof e=="string"?{type:"text",value:e}:{type:"json",value:Tf(e)}}function Tf(e){return e===void 0?null:e}function Of({content:e,tools:t}){const r=[],o=e.filter(i=>i.type!=="source").filter(i=>(i.type!=="tool-result"||i.providerExecuted)&&(i.type!=="tool-error"||i.providerExecuted)).filter(i=>i.type!=="text"||i.text.length>0).map(i=>{switch(i.type){case"text":return{type:"text",text:i.text,providerOptions:i.providerMetadata};case"reasoning":return{type:"reasoning",text:i.text,providerOptions:i.providerMetadata};case"file":return{type:"file",data:i.file.base64,mediaType:i.file.mediaType,providerOptions:i.providerMetadata};case"tool-call":return{type:"tool-call",toolCallId:i.toolCallId,toolName:i.toolName,input:i.input,providerExecuted:i.providerExecuted,providerOptions:i.providerMetadata};case"tool-result":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Nn({tool:t?.[i.toolName],output:i.output,errorMode:"none"}),providerExecuted:!0,providerOptions:i.providerMetadata};case"tool-error":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Nn({tool:t?.[i.toolName],output:i.error,errorMode:"json"}),providerOptions:i.providerMetadata}}});o.length>0&&r.push({role:"assistant",content:o});const n=e.filter(i=>i.type==="tool-result"||i.type==="tool-error").filter(i=>!i.providerExecuted).map(i=>({type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Nn({tool:t?.[i.toolName],output:i.type==="tool-result"?i.output:i.error,errorMode:i.type==="tool-error"?"text":"none"})}));return n.length>0&&r.push({role:"tool",content:n}),r}No({prefix:"aitxt",size:24});function Ha(e,t){const r=new Headers(e??{});for(const[o,n]of Object.entries(t))r.has(o)||r.set(o,n);return r}function qz({status:e,statusText:t,headers:r,textStream:o}){return new Response(o.pipeThrough(new TextEncoderStream),{status:e??200,statusText:t,headers:Ha(r,{"content-type":"text/plain; charset=utf-8"})})}function g$({response:e,status:t,statusText:r,headers:o,stream:n}){e.writeHead(t??200,r,o);const i=n.getReader();(async()=>{try{for(;;){const{done:s,value:l}=await i.read();if(s)break;e.write(l)||await new Promise(c=>{e.once("drain",c)})}}catch(s){throw s}finally{e.end()}})()}function Vz({response:e,status:t,statusText:r,headers:o,textStream:n}){g$({response:e,status:t,statusText:r,headers:Object.fromEntries(Ha(o,{"content-type":"text/plain; charset=utf-8"}).entries()),stream:n.pipeThrough(new TextEncoderStream)})}var v$=class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
84
|
+
Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the token.`,new bx({message:a,statusCode:n,cause:i})}},_x="GatewayInvalidRequestError",dR=`vercel.ai.gateway.error.${_x}`,of=Symbol.for(dR),af,sf,pR=class extends(sf=rt,af=of,sf){constructor({message:e="Invalid request",statusCode:t=400,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[af]=!0,this.name=_x,this.type="invalid_request_error"}static isInstance(e){return rt.hasMarker(e)&&of in e}},wx="GatewayRateLimitError",fR=`vercel.ai.gateway.error.${wx}`,uf=Symbol.for(fR),lf,cf,mR=class extends(cf=rt,lf=uf,cf){constructor({message:e="Rate limit exceeded",statusCode:t=429,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[lf]=!0,this.name=wx,this.type="rate_limit_exceeded"}static isInstance(e){return rt.hasMarker(e)&&uf in e}},xx="GatewayModelNotFoundError",hR=`vercel.ai.gateway.error.${xx}`,df=Symbol.for(hR),gR=cn(()=>Or(E({modelId:w()}))),pf,ff,$x=class extends(ff=rt,pf=df,ff){constructor({message:e="Model not found",statusCode:t=404,modelId:r,cause:o}={}){super({message:e,statusCode:t,cause:o}),this[pf]=!0,this.name=xx,this.type="model_not_found",this.modelId=r}static isInstance(e){return rt.hasMarker(e)&&df in e}},Sx="GatewayInternalServerError",vR=`vercel.ai.gateway.error.${Sx}`,mf=Symbol.for(vR),hf,gf,vf=class extends(gf=rt,hf=mf,gf){constructor({message:e="Internal server error",statusCode:t=500,cause:r}={}){super({message:e,statusCode:t,cause:r}),this[hf]=!0,this.name=Sx,this.type="internal_server_error"}static isInstance(e){return rt.hasMarker(e)&&mf in e}},Ix="GatewayResponseError",yR=`vercel.ai.gateway.error.${Ix}`,yf=Symbol.for(yR),bf,_f,bR=class extends(_f=rt,bf=yf,_f){constructor({message:e="Invalid response from Gateway",statusCode:t=502,response:r,validationError:o,cause:n}={}){super({message:e,statusCode:t,cause:n}),this[bf]=!0,this.name=Ix,this.type="response_error",this.response=r,this.validationError=o}static isInstance(e){return rt.hasMarker(e)&&yf in e}};async function wf({response:e,statusCode:t,defaultMessage:r="Gateway request failed",cause:o,authMethod:n}){const i=await sr({value:e,schema:_R});if(!i.success)return new bR({message:`Invalid error response format: ${r}`,statusCode:t,response:e,validationError:i.error,cause:o});const a=i.value,s=a.error.type,l=a.error.message;switch(s){case"authentication_error":return Wc.createContextualError({apiKeyProvided:n==="api-key",oidcTokenProvided:n==="oidc",statusCode:t,cause:o});case"invalid_request_error":return new pR({message:l,statusCode:t,cause:o});case"rate_limit_exceeded":return new mR({message:l,statusCode:t,cause:o});case"model_not_found":{const u=await sr({value:a.error.param,schema:gR});return new $x({message:l,statusCode:t,modelId:u.success?u.value.modelId:void 0,cause:o})}case"internal_server_error":return new vf({message:l,statusCode:t,cause:o});default:return new vf({message:l,statusCode:t,cause:o})}}var _R=cn(()=>Or(E({error:E({message:w(),type:w().nullish(),param:$e().nullish(),code:G([w(),q()]).nullish()})})));function $r(e,t){var r;return rt.isInstance(e)?e:Be.isInstance(e)?wf({response:wR(e),statusCode:(r=e.statusCode)!=null?r:500,defaultMessage:"Gateway request failed",cause:e,authMethod:t}):wf({response:{},statusCode:500,defaultMessage:e instanceof Error?`Gateway request failed: ${e.message}`:"Unknown Gateway error",cause:e,authMethod:t})}function wR(e){if(e.data!==void 0)return e.data;if(e.responseBody!=null)try{return JSON.parse(e.responseBody)}catch{return e.responseBody}return{}}var kx="ai-gateway-auth-method";async function Hn(e){const t=await sr({value:e[kx],schema:xR});return t.success?t.value:void 0}var xR=cn(()=>Or(G([C("api-key"),C("oidc")]))),xf=class{constructor(e){this.config=e}async getAvailableModels(){try{const{value:e}=await Hp({url:`${this.config.baseURL}/config`,headers:await tr(this.config.headers()),successfulResponseHandler:Di($R),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:t=>t}),fetch:this.config.fetch});return e}catch(e){throw await $r(e)}}async getCredits(){try{const e=new URL(this.config.baseURL),{value:t}=await Hp({url:`${e.origin}/v1/credits`,headers:await tr(this.config.headers()),successfulResponseHandler:Di(SR),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:r=>r}),fetch:this.config.fetch});return t}catch(e){throw await $r(e)}}},$R=cn(()=>Or(E({models:R(E({id:w(),name:w(),description:w().nullish(),pricing:E({input:w(),output:w(),input_cache_read:w().nullish(),input_cache_write:w().nullish()}).transform(({input:e,output:t,input_cache_read:r,input_cache_write:o})=>({input:e,output:t,...r?{cachedInputTokens:r}:{},...o?{cacheCreationInputTokens:o}:{}})).nullish(),specification:E({specificationVersion:C("v2"),provider:w(),modelId:w()}),modelType:dr(["language","embedding","image"]).nullish()}))}))),SR=cn(()=>Or(E({balance:w(),total_used:w()}).transform(({balance:e,total_used:t})=>({balance:e,totalUsed:t})))),IR=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.supportedUrls={"*/*":[/.*/]}}get provider(){return this.config.provider}async getArgs(e){const{abortSignal:t,...r}=e;return{args:this.maybeEncodeFileParts(r),warnings:[]}}async doGenerate(e){const{args:t,warnings:r}=await this.getArgs(e),{abortSignal:o}=e,n=await tr(this.config.headers());try{const{responseHeaders:i,value:a,rawValue:s}=await $u({url:this.getUrl(),headers:wu(n,e.headers,this.getModelConfigHeaders(this.modelId,!1),await tr(this.config.o11yHeaders)),body:t,successfulResponseHandler:Di(Pe()),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:l=>l}),...o&&{abortSignal:o},fetch:this.config.fetch});return{...a,request:{body:t},response:{headers:i,body:s},warnings:r}}catch(i){throw await $r(i,await Hn(n))}}async doStream(e){const{args:t,warnings:r}=await this.getArgs(e),{abortSignal:o}=e,n=await tr(this.config.headers());try{const{value:i,responseHeaders:a}=await $u({url:this.getUrl(),headers:wu(n,e.headers,this.getModelConfigHeaders(this.modelId,!0),await tr(this.config.o11yHeaders)),body:t,successfulResponseHandler:cA(Pe()),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:s=>s}),...o&&{abortSignal:o},fetch:this.config.fetch});return{stream:i.pipeThrough(new TransformStream({start(s){r.length>0&&s.enqueue({type:"stream-start",warnings:r})},transform(s,l){if(s.success){const u=s.value;if(u.type==="raw"&&!e.includeRawChunks)return;u.type==="response-metadata"&&u.timestamp&&typeof u.timestamp=="string"&&(u.timestamp=new Date(u.timestamp)),l.enqueue(u)}else l.error(s.error)}})),request:{body:t},response:{headers:a}}}catch(i){throw await $r(i,await Hn(n))}}isFilePart(e){return e&&typeof e=="object"&&"type"in e&&e.type==="file"}maybeEncodeFileParts(e){for(const t of e.prompt)for(const r of t.content)if(this.isFilePart(r)){const o=r;if(o.data instanceof Uint8Array){const n=Uint8Array.from(o.data),i=Buffer.from(n).toString("base64");o.data=new URL(`data:${o.mediaType||"application/octet-stream"};base64,${i}`)}}return e}getUrl(){return`${this.config.baseURL}/language-model`}getModelConfigHeaders(e,t){return{"ai-language-model-specification-version":"2","ai-language-model-id":e,"ai-language-model-streaming":String(t)}}},kR=class{constructor(e,t){this.modelId=e,this.config=t,this.specificationVersion="v2",this.maxEmbeddingsPerCall=2048,this.supportsParallelCalls=!0}get provider(){return this.config.provider}async doEmbed({values:e,headers:t,abortSignal:r,providerOptions:o}){var n;const i=await tr(this.config.headers());try{const{responseHeaders:a,value:s,rawValue:l}=await $u({url:this.getUrl(),headers:wu(i,t??{},this.getModelConfigHeaders(),await tr(this.config.o11yHeaders)),body:{input:e.length===1?e[0]:e,...o?{providerOptions:o}:{}},successfulResponseHandler:Di(ER),failedResponseHandler:Wn({errorSchema:Pe(),errorToMessage:u=>u}),...r&&{abortSignal:r},fetch:this.config.fetch});return{embeddings:s.embeddings,usage:(n=s.usage)!=null?n:void 0,providerMetadata:s.providerMetadata,response:{headers:a,body:l}}}catch(a){throw await $r(a,await Hn(i))}}getUrl(){return`${this.config.baseURL}/embedding-model`}getModelConfigHeaders(){return{"ai-embedding-model-specification-version":"2","ai-model-id":this.modelId}}},ER=cn(()=>Or(E({embeddings:R(R(q())),usage:E({tokens:q()}).nullish(),providerMetadata:Xe(w(),Xe(w(),$e())).optional()})));async function TR(){var e;return(e=gx.getContext().headers)==null?void 0:e["x-vercel-id"]}var OR="2.0.7",NR="0.0.1";function PR(e={}){var t,r;let o=null,n=null;const i=(t=e.metadataCacheRefreshMillis)!=null?t:1e3*60*5;let a=0;const s=(r=oR(e.baseURL))!=null?r:"https://ai-gateway.vercel.sh/v1/ai",l=async()=>{const g=await jR(e);if(g)return Wa({Authorization:`Bearer ${g.token}`,"ai-gateway-protocol-version":NR,[kx]:g.authMethod,...e.headers},`ai-sdk/gateway/${OR}`);throw Wc.createContextualError({apiKeyProvided:!1,oidcTokenProvided:!1,statusCode:401})},u=()=>{const g=ai({settingValue:void 0,environmentVariableName:"VERCEL_DEPLOYMENT_ID"}),h=ai({settingValue:void 0,environmentVariableName:"VERCEL_ENV"}),b=ai({settingValue:void 0,environmentVariableName:"VERCEL_REGION"});return async()=>{const y=await TR();return{...g&&{"ai-o11y-deployment-id":g},...h&&{"ai-o11y-environment":h},...b&&{"ai-o11y-region":b},...y&&{"ai-o11y-request-id":y}}}},c=g=>new IR(g,{provider:"gateway",baseURL:s,headers:l,fetch:e.fetch,o11yHeaders:u()}),d=async()=>{var g,h,b;const y=(b=(h=(g=e._internal)==null?void 0:g.currentDate)==null?void 0:h.call(g).getTime())!=null?b:Date.now();return(!o||y-a>i)&&(a=y,o=new xf({baseURL:s,headers:l,fetch:e.fetch}).getAvailableModels().then(x=>(n=x,x)).catch(async x=>{throw await $r(x,await Hn(await l()))})),n?Promise.resolve(n):o},f=async()=>new xf({baseURL:s,headers:l,fetch:e.fetch}).getCredits().catch(async g=>{throw await $r(g,await Hn(await l()))}),p=function(g){if(new.target)throw new Error("The Gateway Provider model function cannot be called with the new keyword.");return c(g)};return p.getAvailableModels=d,p.getCredits=f,p.imageModel=g=>{throw new j0({modelId:g,modelType:"imageModel"})},p.languageModel=c,p.textEmbeddingModel=g=>new kR(g,{provider:"gateway",baseURL:s,headers:l,fetch:e.fetch,o11yHeaders:u()}),p}var CR=PR();async function jR(e){const t=ai({settingValue:e.apiKey,environmentVariableName:"AI_GATEWAY_API_KEY"});if(t)return{token:t,authMethod:"api-key"};try{return{token:await gx.getVercelOidcToken(),authMethod:"oidc"}}catch{return null}}var AR=Object.defineProperty,RR=(e,t)=>{for(var r in t)AR(e,r,{get:t[r],enumerable:!0})},Ex="AI_NoOutputSpecifiedError",Tx=`vercel.ai.error.${Ex}`,zR=Symbol.for(Tx),Ox,MR=class extends Y{constructor({message:e="No output specified."}={}){super({name:Ex,message:e}),this[Ox]=!0}static isInstance(e){return Y.hasMarker(e,Tx)}};Ox=zR;function DR(e){const t="AI SDK Warning:";switch(e.type){case"unsupported-setting":{let r=`${t} The "${e.setting}" setting is not supported by this model`;return e.details&&(r+=` - ${e.details}`),r}case"unsupported-tool":{const r="name"in e.tool?e.tool.name:"unknown tool";let o=`${t} The tool "${r}" is not supported by this model`;return e.details&&(o+=` - ${e.details}`),o}case"other":return`${t} ${e.message}`;default:return`${t} ${JSON.stringify(e,null,2)}`}}var UR="AI SDK Warning System: To turn off warning logging, set the AI_SDK_LOG_WARNINGS global to false.",$f=!1,LR=e=>{if(e.length===0)return;const t=globalThis.AI_SDK_LOG_WARNINGS;if(t!==!1){if(typeof t=="function"){t(e);return}$f||($f=!0,console.info(UR));for(const r of e)console.warn(DR(r))}},Nx="AI_InvalidArgumentError",Px=`vercel.ai.error.${Nx}`,ZR=Symbol.for(Px),Cx,Nt=class extends Y{constructor({parameter:e,value:t,message:r}){super({name:Nx,message:`Invalid argument for parameter ${e}: ${r}`}),this[Cx]=!0,this.parameter=e,this.value=t}static isInstance(e){return Y.hasMarker(e,Px)}};Cx=ZR;var jx="AI_InvalidToolInputError",Ax=`vercel.ai.error.${jx}`,FR=Symbol.for(Ax),Rx,zx=class extends Y{constructor({toolInput:e,toolName:t,cause:r,message:o=`Invalid input for tool ${t}: ${sn(r)}`}){super({name:jx,message:o,cause:r}),this[Rx]=!0,this.toolInput=e,this.toolName=t}static isInstance(e){return Y.hasMarker(e,Ax)}};Rx=FR;var Mx="AI_NoObjectGeneratedError",Dx=`vercel.ai.error.${Mx}`,qR=Symbol.for(Dx),Ux,Sf=class extends Y{constructor({message:e="No object generated.",cause:t,text:r,response:o,usage:n,finishReason:i}){super({name:Mx,message:e,cause:t}),this[Ux]=!0,this.text=r,this.response=o,this.usage=n,this.finishReason=i}static isInstance(e){return Y.hasMarker(e,Dx)}};Ux=qR;var Lx="AI_NoOutputGeneratedError",Zx=`vercel.ai.error.${Lx}`,VR=Symbol.for(Zx),Fx,BR=class extends Y{constructor({message:e="No output generated.",cause:t}={}){super({name:Lx,message:e,cause:t}),this[Fx]=!0}static isInstance(e){return Y.hasMarker(e,Zx)}};Fx=VR;var qx="AI_NoSuchToolError",Vx=`vercel.ai.error.${qx}`,JR=Symbol.for(Vx),Bx,Eu=class extends Y{constructor({toolName:e,availableTools:t=void 0,message:r=`Model tried to call unavailable tool '${e}'. ${t===void 0?"No tools are available.":`Available tools: ${t.join(", ")}.`}`}){super({name:qx,message:r}),this[Bx]=!0,this.toolName=e,this.availableTools=t}static isInstance(e){return Y.hasMarker(e,Vx)}};Bx=JR;var Jx="AI_ToolCallRepairError",Wx=`vercel.ai.error.${Jx}`,WR=Symbol.for(Wx),Hx,HR=class extends Y{constructor({cause:e,originalError:t,message:r=`Error repairing tool call: ${sn(e)}`}){super({name:Jx,message:r,cause:e}),this[Hx]=!0,this.originalError=t}static isInstance(e){return Y.hasMarker(e,Wx)}};Hx=WR;var GR=class extends Y{constructor(e){super({name:"AI_UnsupportedModelVersionError",message:`Unsupported model version ${e.version} for provider "${e.provider}" and model "${e.modelId}". AI SDK 5 only supports models that implement specification version "v2".`}),this.version=e.version,this.provider=e.provider,this.modelId=e.modelId}},Gx="AI_InvalidMessageRoleError",Kx=`vercel.ai.error.${Gx}`,KR=Symbol.for(Kx),Yx,YR=class extends Y{constructor({role:e,message:t=`Invalid message role: '${e}'. Must be one of: "system", "user", "assistant", "tool".`}){super({name:Gx,message:t}),this[Yx]=!0,this.role=e}static isInstance(e){return Y.hasMarker(e,Kx)}};Yx=KR;var Qx="AI_MessageConversionError",Xx=`vercel.ai.error.${Qx}`,QR=Symbol.for(Xx),e$,XR=class extends Y{constructor({originalMessage:e,message:t}){super({name:Qx,message:t}),this[e$]=!0,this.originalMessage=e}static isInstance(e){return Y.hasMarker(e,Xx)}};e$=QR;var t$="AI_DownloadError",r$=`vercel.ai.error.${t$}`,ez=Symbol.for(r$),n$,zs=class extends Y{constructor({url:e,statusCode:t,statusText:r,cause:o,message:n=o==null?`Failed to download ${e}: ${t} ${r}`:`Failed to download ${e}: ${o}`}){super({name:t$,message:n,cause:o}),this[n$]=!0,this.url=e,this.statusCode=t,this.statusText=r}static isInstance(e){return Y.hasMarker(e,r$)}};n$=ez;var o$="AI_RetryError",i$=`vercel.ai.error.${o$}`,tz=Symbol.for(i$),a$,If=class extends Y{constructor({message:e,reason:t,errors:r}){super({name:o$,message:e}),this[a$]=!0,this.reason=t,this.errors=r,this.lastError=r[r.length-1]}static isInstance(e){return Y.hasMarker(e,i$)}};a$=tz;function s$(e){if(typeof e!="string"){if(e.specificationVersion!=="v2")throw new GR({version:e.specificationVersion,provider:e.provider,modelId:e.modelId});return e}return rz().languageModel(e)}function rz(){var e;return(e=globalThis.AI_SDK_DEFAULT_PROVIDER)!=null?e:CR}var nz=[{mediaType:"image/gif",bytesPrefix:[71,73,70]},{mediaType:"image/png",bytesPrefix:[137,80,78,71]},{mediaType:"image/jpeg",bytesPrefix:[255,216]},{mediaType:"image/webp",bytesPrefix:[82,73,70,70,null,null,null,null,87,69,66,80]},{mediaType:"image/bmp",bytesPrefix:[66,77]},{mediaType:"image/tiff",bytesPrefix:[73,73,42,0]},{mediaType:"image/tiff",bytesPrefix:[77,77,0,42]},{mediaType:"image/avif",bytesPrefix:[0,0,0,32,102,116,121,112,97,118,105,102]},{mediaType:"image/heic",bytesPrefix:[0,0,0,32,102,116,121,112,104,101,105,99]}],oz=e=>{const t=typeof e=="string"?Jc(e):e,r=(t[6]&127)<<21|(t[7]&127)<<14|(t[8]&127)<<7|t[9]&127;return t.slice(r+10)};function iz(e){return typeof e=="string"&&e.startsWith("SUQz")||typeof e!="string"&&e.length>10&&e[0]===73&&e[1]===68&&e[2]===51?oz(e):e}function az({data:e,signatures:t}){const r=iz(e),o=typeof r=="string"?Jc(r.substring(0,Math.min(r.length,24))):r;for(const n of t)if(o.length>=n.bytesPrefix.length&&n.bytesPrefix.every((i,a)=>i===null||o[a]===i))return n.mediaType}var sz="5.0.90",uz=async({url:e})=>{var t;const r=e.toString();try{const o=await fetch(r,{headers:Wa({},`ai-sdk/${sz}`,Vc())});if(!o.ok)throw new zs({url:r,statusCode:o.status,statusText:o.statusText});return{data:new Uint8Array(await o.arrayBuffer()),mediaType:(t=o.headers.get("content-type"))!=null?t:void 0}}catch(o){throw zs.isInstance(o)?o:new zs({url:r,cause:o})}},lz=(e=uz)=>t=>Promise.all(t.map(async r=>r.isUrlSupportedByModel?null:e(r)));function cz(e){try{const[t,r]=e.split(",");return{mediaType:t.split(";")[0].split(":")[1],base64Content:r}}catch{return{mediaType:void 0,base64Content:void 0}}}var u$=G([w(),Rt(Uint8Array),Rt(ArrayBuffer),So(e=>{var t,r;return(r=(t=globalThis.Buffer)==null?void 0:t.isBuffer(e))!=null?r:!1},{message:"Must be a Buffer"})]);function l$(e){if(e instanceof Uint8Array)return{data:e,mediaType:void 0};if(e instanceof ArrayBuffer)return{data:new Uint8Array(e),mediaType:void 0};if(typeof e=="string")try{e=new URL(e)}catch{}if(e instanceof URL&&e.protocol==="data:"){const{mediaType:t,base64Content:r}=cz(e.toString());if(t==null||r==null)throw new Y({name:"InvalidDataContentError",message:`Invalid data URL format in content ${e.toString()}`});return{data:r,mediaType:t}}return{data:e,mediaType:void 0}}function dz(e){return typeof e=="string"?e:e instanceof ArrayBuffer?ku(new Uint8Array(e)):ku(e)}async function pz({prompt:e,supportedUrls:t,download:r=lz()}){const o=await mz(e.messages,r,t);return[...e.system!=null?[{role:"system",content:e.system}]:[],...e.messages.map(n=>fz({message:n,downloadedAssets:o}))]}function fz({message:e,downloadedAssets:t}){const r=e.role;switch(r){case"system":return{role:"system",content:e.content,providerOptions:e.providerOptions};case"user":return typeof e.content=="string"?{role:"user",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"user",content:e.content.map(o=>hz(o,t)).filter(o=>o.type!=="text"||o.text!==""),providerOptions:e.providerOptions};case"assistant":return typeof e.content=="string"?{role:"assistant",content:[{type:"text",text:e.content}],providerOptions:e.providerOptions}:{role:"assistant",content:e.content.filter(o=>o.type!=="text"||o.text!==""||o.providerOptions!=null).map(o=>{const n=o.providerOptions;switch(o.type){case"file":{const{data:i,mediaType:a}=l$(o.data);return{type:"file",data:i,filename:o.filename,mediaType:a??o.mediaType,providerOptions:n}}case"reasoning":return{type:"reasoning",text:o.text,providerOptions:n};case"text":return{type:"text",text:o.text,providerOptions:n};case"tool-call":return{type:"tool-call",toolCallId:o.toolCallId,toolName:o.toolName,input:o.input,providerExecuted:o.providerExecuted,providerOptions:n};case"tool-result":return{type:"tool-result",toolCallId:o.toolCallId,toolName:o.toolName,output:o.output,providerOptions:n}}}),providerOptions:e.providerOptions};case"tool":return{role:"tool",content:e.content.map(o=>({type:"tool-result",toolCallId:o.toolCallId,toolName:o.toolName,output:o.output,providerOptions:o.providerOptions})),providerOptions:e.providerOptions};default:{const o=r;throw new YR({role:o})}}}async function mz(e,t,r){const o=e.filter(i=>i.role==="user").map(i=>i.content).filter(i=>Array.isArray(i)).flat().filter(i=>i.type==="image"||i.type==="file").map(i=>{var a;const s=(a=i.mediaType)!=null?a:i.type==="image"?"image/*":void 0;let l=i.type==="image"?i.image:i.data;if(typeof l=="string")try{l=new URL(l)}catch{}return{mediaType:s,data:l}}).filter(i=>i.data instanceof URL).map(i=>({url:i.data,isUrlSupportedByModel:i.mediaType!=null&&Y1({url:i.data.toString(),mediaType:i.mediaType,supportedUrls:r})})),n=await t(o);return Object.fromEntries(n.map((i,a)=>i==null?null:[o[a].url.toString(),{data:i.data,mediaType:i.mediaType}]).filter(i=>i!=null))}function hz(e,t){var r;if(e.type==="text")return{type:"text",text:e.text,providerOptions:e.providerOptions};let o;const n=e.type;switch(n){case"image":o=e.image;break;case"file":o=e.data;break;default:throw new Error(`Unsupported part type: ${n}`)}const{data:i,mediaType:a}=l$(o);let s=a??e.mediaType,l=i;if(l instanceof URL){const u=t[l.toString()];u&&(l=u.data,s??(s=u.mediaType))}switch(n){case"image":return(l instanceof Uint8Array||typeof l=="string")&&(s=(r=az({data:l,signatures:nz}))!=null?r:s),{type:"file",mediaType:s??"image/*",filename:void 0,data:l,providerOptions:e.providerOptions};case"file":{if(s==null)throw new Error("Media type is missing for file part");return{type:"file",mediaType:s,filename:e.filename,data:l,providerOptions:e.providerOptions}}}}function gz({maxOutputTokens:e,temperature:t,topP:r,topK:o,presencePenalty:n,frequencyPenalty:i,seed:a,stopSequences:s}){if(e!=null){if(!Number.isInteger(e))throw new Nt({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be an integer"});if(e<1)throw new Nt({parameter:"maxOutputTokens",value:e,message:"maxOutputTokens must be >= 1"})}if(t!=null&&typeof t!="number")throw new Nt({parameter:"temperature",value:t,message:"temperature must be a number"});if(r!=null&&typeof r!="number")throw new Nt({parameter:"topP",value:r,message:"topP must be a number"});if(o!=null&&typeof o!="number")throw new Nt({parameter:"topK",value:o,message:"topK must be a number"});if(n!=null&&typeof n!="number")throw new Nt({parameter:"presencePenalty",value:n,message:"presencePenalty must be a number"});if(i!=null&&typeof i!="number")throw new Nt({parameter:"frequencyPenalty",value:i,message:"frequencyPenalty must be a number"});if(a!=null&&!Number.isInteger(a))throw new Nt({parameter:"seed",value:a,message:"seed must be an integer"});return{maxOutputTokens:e,temperature:t,topP:r,topK:o,presencePenalty:n,frequencyPenalty:i,stopSequences:s,seed:a}}function vz(e){return e!=null&&Object.keys(e).length>0}function yz({tools:e,toolChoice:t,activeTools:r}){return vz(e)?{tools:(r!=null?Object.entries(e).filter(([n])=>r.includes(n)):Object.entries(e)).map(([n,i])=>{const a=i.type;switch(a){case void 0:case"dynamic":case"function":return{type:"function",name:n,description:i.description,inputSchema:Ha(i.inputSchema).jsonSchema,providerOptions:i.providerOptions};case"provider-defined":return{type:"provider-defined",name:n,id:i.id,args:i.args};default:{const s=a;throw new Error(`Unsupported tool type: ${s}`)}}}),toolChoice:t==null?{type:"auto"}:typeof t=="string"?{type:t}:{type:"tool",toolName:t.toolName}}:{tools:void 0,toolChoice:void 0}}var Gn=xo(()=>G([yo(),w(),q(),pe(),Xe(w(),Gn),R(Gn)])),Mt=Xe(w(),Xe(w(),Gn)),c$=E({type:C("text"),text:w(),providerOptions:Mt.optional()}),bz=E({type:C("image"),image:G([u$,Rt(URL)]),mediaType:w().optional(),providerOptions:Mt.optional()}),d$=E({type:C("file"),data:G([u$,Rt(URL)]),filename:w().optional(),mediaType:w(),providerOptions:Mt.optional()}),_z=E({type:C("reasoning"),text:w(),providerOptions:Mt.optional()}),wz=E({type:C("tool-call"),toolCallId:w(),toolName:w(),input:$e(),providerOptions:Mt.optional(),providerExecuted:pe().optional()}),xz=za("type",[E({type:C("text"),value:w()}),E({type:C("json"),value:Gn}),E({type:C("error-text"),value:w()}),E({type:C("error-json"),value:Gn}),E({type:C("content"),value:R(G([E({type:C("text"),text:w()}),E({type:C("media"),data:w(),mediaType:w()})]))})]),p$=E({type:C("tool-result"),toolCallId:w(),toolName:w(),output:xz,providerOptions:Mt.optional()}),$z=E({role:C("system"),content:w(),providerOptions:Mt.optional()}),Sz=E({role:C("user"),content:G([w(),R(G([c$,bz,d$]))]),providerOptions:Mt.optional()}),Iz=E({role:C("assistant"),content:G([w(),R(G([c$,d$,_z,wz,p$]))]),providerOptions:Mt.optional()}),kz=E({role:C("tool"),content:R(p$),providerOptions:Mt.optional()}),Ez=G([$z,Sz,Iz,kz]);async function Tz(e){if(e.prompt==null&&e.messages==null)throw new jr({prompt:e,message:"prompt or messages must be defined"});if(e.prompt!=null&&e.messages!=null)throw new jr({prompt:e,message:"prompt and messages cannot be defined at the same time"});if(e.system!=null&&typeof e.system!="string")throw new jr({prompt:e,message:"system must be a string"});let t;if(e.prompt!=null&&typeof e.prompt=="string")t=[{role:"user",content:e.prompt}];else if(e.prompt!=null&&Array.isArray(e.prompt))t=e.prompt;else if(e.messages!=null)t=e.messages;else throw new jr({prompt:e,message:"prompt or messages must be defined"});if(t.length===0)throw new jr({prompt:e,message:"messages must not be empty"});const r=await sr({value:t,schema:R(Ez)});if(!r.success)throw new jr({prompt:e,message:"The messages must be a ModelMessage[]. If you have passed a UIMessage[], you can use convertToModelMessages to convert them.",cause:r.error});return{messages:t,system:e.system}}function Oz(e){return Wc.isInstance(e)||$x.isInstance(e)?new Y({name:"GatewayError",message:"Vercel AI Gateway access failed. If you want to use AI SDK providers directly, use the providers, e.g. @ai-sdk/openai, or register a different global default provider.",cause:e}):e}function Tu({operationId:e,telemetry:t}){return{"operation.name":`${e}${t?.functionId!=null?` ${t.functionId}`:""}`,"resource.name":t?.functionId,"ai.operationId":e,"ai.telemetry.functionId":t?.functionId}}function Nz({model:e,settings:t,telemetry:r,headers:o}){var n;return{"ai.model.provider":e.provider,"ai.model.id":e.modelId,...Object.entries(t).reduce((i,[a,s])=>(i[`ai.settings.${a}`]=s,i),{}),...Object.entries((n=r?.metadata)!=null?n:{}).reduce((i,[a,s])=>(i[`ai.telemetry.metadata.${a}`]=s,i),{}),...Object.entries(o??{}).reduce((i,[a,s])=>(s!==void 0&&(i[`ai.request.headers.${a}`]=s),i),{})}}var Pz={startSpan(){return Jo},startActiveSpan(e,t,r,o){if(typeof t=="function")return t(Jo);if(typeof r=="function")return r(Jo);if(typeof o=="function")return o(Jo)}},Jo={spanContext(){return Cz},setAttribute(){return this},setAttributes(){return this},addEvent(){return this},addLink(){return this},addLinks(){return this},setStatus(){return this},updateName(){return this},end(){return this},isRecording(){return!1},recordException(){return this}},Cz={traceId:"",spanId:"",traceFlags:0};function jz({isEnabled:e=!1,tracer:t}={}){return e?t||zC.getTracer("ai"):Pz}function Ou({name:e,tracer:t,attributes:r,fn:o,endWhenDone:n=!0}){return t.startActiveSpan(e,{attributes:r},async i=>{try{const a=await o(i);return n&&i.end(),a}catch(a){try{f$(i,a)}finally{i.end()}throw a}})}function f$(e,t){t instanceof Error?(e.recordException({name:t.name,message:t.message,stack:t.stack}),e.setStatus({code:ji.ERROR,message:t.message})):e.setStatus({code:ji.ERROR})}function Lr({telemetry:e,attributes:t}){return e?.isEnabled!==!0?{}:Object.entries(t).reduce((r,[o,n])=>{if(n==null)return r;if(typeof n=="object"&&"input"in n&&typeof n.input=="function"){if(e?.recordInputs===!1)return r;const i=n.input();return i==null?r:{...r,[o]:i}}if(typeof n=="object"&&"output"in n&&typeof n.output=="function"){if(e?.recordOutputs===!1)return r;const i=n.output();return i==null?r:{...r,[o]:i}}return{...r,[o]:n}},{})}function Az(e){return JSON.stringify(e.map(t=>({...t,content:typeof t.content=="string"?t.content:t.content.map(r=>r.type==="file"?{...r,data:r.data instanceof Uint8Array?dz(r.data):r.data}:r)})))}function Rz(e,t){return{inputTokens:xn(e.inputTokens,t.inputTokens),outputTokens:xn(e.outputTokens,t.outputTokens),totalTokens:xn(e.totalTokens,t.totalTokens),reasoningTokens:xn(e.reasoningTokens,t.reasoningTokens),cachedInputTokens:xn(e.cachedInputTokens,t.cachedInputTokens)}}function xn(e,t){return e==null&&t==null?void 0:(e??0)+(t??0)}function kf(e){return e===void 0?[]:Array.isArray(e)?e:[e]}function zz({error:e,exponentialBackoffDelay:t}){const r=e.responseHeaders;if(!r)return t;let o;const n=r["retry-after-ms"];if(n){const a=parseFloat(n);Number.isNaN(a)||(o=a)}const i=r["retry-after"];if(i&&o===void 0){const a=parseFloat(i);Number.isNaN(a)?o=Date.parse(i)-Date.now():o=a*1e3}return o!=null&&!Number.isNaN(o)&&0<=o&&(o<60*1e3||o<t)?o:t}var Mz=({maxRetries:e=2,initialDelayInMs:t=2e3,backoffFactor:r=2,abortSignal:o}={})=>async n=>m$(n,{maxRetries:e,delayInMs:t,backoffFactor:r,abortSignal:o});async function m$(e,{maxRetries:t,delayInMs:r,backoffFactor:o,abortSignal:n},i=[]){try{return await e()}catch(a){if(wr(a)||t===0)throw a;const s=ux(a),l=[...i,a],u=l.length;if(u>t)throw new If({message:`Failed after ${u} attempts. Last error: ${s}`,reason:"maxRetriesExceeded",errors:l});if(a instanceof Error&&Be.isInstance(a)&&a.isRetryable===!0&&u<=t)return await sx(zz({error:a,exponentialBackoffDelay:r}),{abortSignal:n}),m$(e,{maxRetries:t,delayInMs:o*r,backoffFactor:o,abortSignal:n},l);throw u===1?a:new If({message:`Failed after ${u} attempts with non-retryable error: '${s}'`,reason:"errorNotRetryable",errors:l})}}function Dz({maxRetries:e,abortSignal:t}){if(e!=null){if(!Number.isInteger(e))throw new Nt({parameter:"maxRetries",value:e,message:"maxRetries must be an integer"});if(e<0)throw new Nt({parameter:"maxRetries",value:e,message:"maxRetries must be >= 0"})}const r=e??2;return{maxRetries:r,retry:Mz({maxRetries:r,abortSignal:t})}}var Uz=class{constructor({data:e,mediaType:t}){const r=e instanceof Uint8Array;this.base64Data=r?void 0:e,this.uint8ArrayData=r?e:void 0,this.mediaType=t}get base64(){return this.base64Data==null&&(this.base64Data=ku(this.uint8ArrayData)),this.base64Data}get uint8Array(){return this.uint8ArrayData==null&&(this.uint8ArrayData=Jc(this.base64Data)),this.uint8ArrayData}},Lz=class extends Uz{constructor(e){super(e),this.type="file"}};async function Zz({toolCall:e,tools:t,repairToolCall:r,system:o,messages:n}){try{if(t==null)throw new Eu({toolName:e.toolName});try{return await Ef({toolCall:e,tools:t})}catch(i){if(r==null||!(Eu.isInstance(i)||zx.isInstance(i)))throw i;let a=null;try{a=await r({toolCall:e,tools:t,inputSchema:({toolName:s})=>{const{inputSchema:l}=t[s];return Ha(l).jsonSchema},system:o,messages:n,error:i})}catch(s){throw new HR({cause:s,originalError:i})}if(a==null)throw i;return await Ef({toolCall:a,tools:t})}}catch(i){const a=await xr({text:e.input}),s=a.success?a.value:e.input;return{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:s,dynamic:!0,invalid:!0,error:i}}}async function Ef({toolCall:e,tools:t}){const r=e.toolName,o=t[r];if(o==null)throw new Eu({toolName:e.toolName,availableTools:Object.keys(t)});const n=Ha(o.inputSchema),i=e.input.trim()===""?await sr({value:{},schema:n}):await xr({text:e.input,schema:n});if(i.success===!1)throw new zx({toolName:r,toolInput:e.input,cause:i.error});return o.type==="dynamic"?{type:"tool-call",toolCallId:e.toolCallId,toolName:e.toolName,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata,dynamic:!0}:{type:"tool-call",toolCallId:e.toolCallId,toolName:r,input:i.value,providerExecuted:e.providerExecuted,providerMetadata:e.providerMetadata}}var Fz=class{constructor({content:e,finishReason:t,usage:r,warnings:o,request:n,response:i,providerMetadata:a}){this.content=e,this.finishReason=t,this.usage=r,this.warnings=o,this.request=n,this.response=i,this.providerMetadata=a}get text(){return this.content.filter(e=>e.type==="text").map(e=>e.text).join("")}get reasoning(){return this.content.filter(e=>e.type==="reasoning")}get reasoningText(){return this.reasoning.length===0?void 0:this.reasoning.map(e=>e.text).join("")}get files(){return this.content.filter(e=>e.type==="file").map(e=>e.file)}get sources(){return this.content.filter(e=>e.type==="source")}get toolCalls(){return this.content.filter(e=>e.type==="tool-call")}get staticToolCalls(){return this.toolCalls.filter(e=>e.dynamic!==!0)}get dynamicToolCalls(){return this.toolCalls.filter(e=>e.dynamic===!0)}get toolResults(){return this.content.filter(e=>e.type==="tool-result")}get staticToolResults(){return this.toolResults.filter(e=>e.dynamic!==!0)}get dynamicToolResults(){return this.toolResults.filter(e=>e.dynamic===!0)}};function h$(e){return({steps:t})=>t.length===e}async function qz({stopConditions:e,steps:t}){return(await Promise.all(e.map(r=>r({steps:t})))).some(r=>r)}function Nn({output:e,tool:t,errorMode:r}){return r==="text"?{type:"error-text",value:sn(e)}:r==="json"?{type:"error-json",value:Tf(e)}:t?.toModelOutput?t.toModelOutput(e):typeof e=="string"?{type:"text",value:e}:{type:"json",value:Tf(e)}}function Tf(e){return e===void 0?null:e}function Of({content:e,tools:t}){const r=[],o=e.filter(i=>i.type!=="source").filter(i=>(i.type!=="tool-result"||i.providerExecuted)&&(i.type!=="tool-error"||i.providerExecuted)).filter(i=>i.type!=="text"||i.text.length>0).map(i=>{switch(i.type){case"text":return{type:"text",text:i.text,providerOptions:i.providerMetadata};case"reasoning":return{type:"reasoning",text:i.text,providerOptions:i.providerMetadata};case"file":return{type:"file",data:i.file.base64,mediaType:i.file.mediaType,providerOptions:i.providerMetadata};case"tool-call":return{type:"tool-call",toolCallId:i.toolCallId,toolName:i.toolName,input:i.input,providerExecuted:i.providerExecuted,providerOptions:i.providerMetadata};case"tool-result":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Nn({tool:t?.[i.toolName],output:i.output,errorMode:"none"}),providerExecuted:!0,providerOptions:i.providerMetadata};case"tool-error":return{type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Nn({tool:t?.[i.toolName],output:i.error,errorMode:"json"}),providerOptions:i.providerMetadata}}});o.length>0&&r.push({role:"assistant",content:o});const n=e.filter(i=>i.type==="tool-result"||i.type==="tool-error").filter(i=>!i.providerExecuted).map(i=>({type:"tool-result",toolCallId:i.toolCallId,toolName:i.toolName,output:Nn({tool:t?.[i.toolName],output:i.type==="tool-result"?i.output:i.error,errorMode:i.type==="tool-error"?"text":"none"})}));return n.length>0&&r.push({role:"tool",content:n}),r}No({prefix:"aitxt",size:24});function Ga(e,t){const r=new Headers(e??{});for(const[o,n]of Object.entries(t))r.has(o)||r.set(o,n);return r}function Vz({status:e,statusText:t,headers:r,textStream:o}){return new Response(o.pipeThrough(new TextEncoderStream),{status:e??200,statusText:t,headers:Ga(r,{"content-type":"text/plain; charset=utf-8"})})}function g$({response:e,status:t,statusText:r,headers:o,stream:n}){e.writeHead(t??200,r,o);const i=n.getReader();(async()=>{try{for(;;){const{done:s,value:l}=await i.read();if(s)break;e.write(l)||await new Promise(c=>{e.once("drain",c)})}}catch(s){throw s}finally{e.end()}})()}function Bz({response:e,status:t,statusText:r,headers:o,textStream:n}){g$({response:e,status:t,statusText:r,headers:Object.fromEntries(Ga(o,{"content-type":"text/plain; charset=utf-8"}).entries()),stream:n.pipeThrough(new TextEncoderStream)})}var v$=class extends TransformStream{constructor(){super({transform(e,t){t.enqueue(`data: ${JSON.stringify(e)}
|
|
85
85
|
|
|
86
86
|
`)},flush(e){e.enqueue(`data: [DONE]
|
|
87
87
|
|
|
88
|
-
`)}})}},y$={"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive","x-vercel-ai-ui-message-stream":"v1","x-accel-buffering":"no"};function Bz({status:e,statusText:t,headers:r,stream:o,consumeSseStream:n}){let i=o.pipeThrough(new v$);if(n){const[a,s]=i.tee();i=a,n({stream:s})}return new Response(i.pipeThrough(new TextEncoderStream),{status:e,statusText:t,headers:Ha(r,y$)})}function Jz({originalMessages:e,responseMessageId:t}){if(e==null)return;const r=e[e.length-1];return r?.role==="assistant"?r.id:typeof t=="function"?t():t}function Wz(e){return e.type.startsWith("data-")}function b$(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const r={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const n=t[o];if(n===void 0)continue;const i=o in e?e[o]:void 0,a=n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?r[o]=b$(i,n):r[o]=n}return r}function Hz(e){const t=["ROOT"];let r=-1,o=null;function n(l,u,c){switch(l){case'"':{r=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{r=u,o=u,t.pop(),t.push(c),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{r=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{r=u,t.pop(),t.push(c),t.push("INSIDE_ARRAY_START");break}}}function i(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":n(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{r=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{n(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),r=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:r=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{r=l,t.pop();break}default:{r=l,n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=l,t.pop();break}default:{r=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),r=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(o,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(u,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l)):r=l;break}}}let s=e.slice(0,r+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{s+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{s+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{s+="]";break}case"INSIDE_LITERAL":{const c=e.substring(o,e.length);"true".startsWith(c)?s+="true".slice(c.length):"false".startsWith(c)?s+="false".slice(c.length):"null".startsWith(c)&&(s+="null".slice(c.length))}}return s}async function _$(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await xr({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await xr({text:Hz(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function zs(e){return e.type.startsWith("data-")}function Ms(e){return e.type==="text"}function Ds(e){return e.type==="file"}function Nf(e){return e.type==="reasoning"}function Fr(e){return e.type.startsWith("tool-")}function Hc(e){return e.type==="dynamic-tool"}function Pf(e){return Fr(e)||Hc(e)}function Di(e){return e.type.split("-").slice(1).join("-")}function Gz(e){return Hc(e)?e.toolName:Di(e)}function Kz({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function Yz({stream:e,messageMetadataSchema:t,dataPartSchemas:r,runUpdateMessageJob:o,onError:n,onToolCall:i,onData:a}){return e.pipeThrough(new TransformStream({async transform(s,l){await o(async({state:u,write:c})=>{var d,f,p,g;function h(v){const N=u.message.parts.filter(Fr).find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function b(v){const N=u.message.parts.filter(I=>I.type==="dynamic-tool").find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function y(v){var k;const N=u.message.parts.find(z=>Fr(z)&&z.toolCallId===v.toolCallId),I=v,O=N;N!=null?(N.state=v.state,O.input=I.input,O.output=I.output,O.errorText=I.errorText,O.rawInput=I.rawInput,O.preliminary=I.preliminary,O.providerExecuted=(k=I.providerExecuted)!=null?k:N.providerExecuted,I.providerMetadata!=null&&N.state==="input-available"&&(N.callProviderMetadata=I.providerMetadata)):u.message.parts.push({type:`tool-${v.toolName}`,toolCallId:v.toolCallId,state:v.state,input:I.input,output:I.output,rawInput:I.rawInput,errorText:I.errorText,providerExecuted:I.providerExecuted,preliminary:I.preliminary,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}function x(v){var k,N;const I=u.message.parts.find(F=>F.type==="dynamic-tool"&&F.toolCallId===v.toolCallId),O=v,z=I;I!=null?(I.state=v.state,z.toolName=v.toolName,z.input=O.input,z.output=O.output,z.errorText=O.errorText,z.rawInput=(k=O.rawInput)!=null?k:z.rawInput,z.preliminary=O.preliminary,z.providerExecuted=(N=O.providerExecuted)!=null?N:I.providerExecuted,O.providerMetadata!=null&&I.state==="input-available"&&(I.callProviderMetadata=O.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:v.toolName,toolCallId:v.toolCallId,state:v.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,...O.providerMetadata!=null?{callProviderMetadata:O.providerMetadata}:{}})}async function $(v){if(v!=null){const k=u.message.metadata!=null?b$(u.message.metadata,v):v;t!=null&&await xu({value:k,schema:t}),u.message.metadata=k}}switch(s.type){case"text-start":{const v={type:"text",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeTextParts[s.id]=v,u.message.parts.push(v),c();break}case"text-delta":{const v=u.activeTextParts[s.id];v.text+=s.delta,v.providerMetadata=(d=s.providerMetadata)!=null?d:v.providerMetadata,c();break}case"text-end":{const v=u.activeTextParts[s.id];v.state="done",v.providerMetadata=(f=s.providerMetadata)!=null?f:v.providerMetadata,delete u.activeTextParts[s.id],c();break}case"reasoning-start":{const v={type:"reasoning",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeReasoningParts[s.id]=v,u.message.parts.push(v),c();break}case"reasoning-delta":{const v=u.activeReasoningParts[s.id];v.text+=s.delta,v.providerMetadata=(p=s.providerMetadata)!=null?p:v.providerMetadata,c();break}case"reasoning-end":{const v=u.activeReasoningParts[s.id];v.providerMetadata=(g=s.providerMetadata)!=null?g:v.providerMetadata,v.state="done",delete u.activeReasoningParts[s.id],c();break}case"file":{u.message.parts.push({type:"file",mediaType:s.mediaType,url:s.url}),c();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:s.sourceId,url:s.url,title:s.title,providerMetadata:s.providerMetadata}),c();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:s.sourceId,mediaType:s.mediaType,title:s.title,filename:s.filename,providerMetadata:s.providerMetadata}),c();break}case"tool-input-start":{const v=u.message.parts.filter(Fr);u.partialToolCalls[s.toolCallId]={text:"",toolName:s.toolName,index:v.length,dynamic:s.dynamic},s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}),c();break}case"tool-input-delta":{const v=u.partialToolCalls[s.toolCallId];v.text+=s.inputTextDelta;const{value:k}=await _$(v.text);v.dynamic?x({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}):y({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}),c();break}case"tool-input-available":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c(),i&&!s.providerExecuted&&await i({toolCall:s});break}case"tool-input-error":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:void 0,rawInput:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c();break}case"tool-output-available":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-available",input:v.input,output:s.output,preliminary:s.preliminary})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Di(v),state:"output-available",input:v.input,output:s.output,providerExecuted:s.providerExecuted,preliminary:s.preliminary})}c();break}case"tool-output-error":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-error",input:v.input,errorText:s.errorText,providerExecuted:s.providerExecuted})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Di(v),state:"output-error",input:v.input,rawInput:v.rawInput,errorText:s.errorText,providerExecuted:s.providerExecuted})}c();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{s.messageId!=null&&(u.message.id=s.messageId),await $(s.messageMetadata),(s.messageId!=null||s.messageMetadata!=null)&&c();break}case"finish":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"message-metadata":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"error":{n?.(new Error(s.errorText));break}default:if(Wz(s)){r?.[s.type]!=null&&await xu({value:s.data,schema:r[s.type]});const v=s;if(v.transient){a?.(v);break}const k=v.id!=null?u.message.parts.find(N=>v.type===N.type&&v.id===N.id):void 0;k!=null?k.data=v.data:u.message.parts.push(v),a?.(v),c()}}l.enqueue(s)})}}))}function Qz({messageId:e,originalMessages:t=[],onFinish:r,onError:o,stream:n}){let i=t?.[t.length-1];i?.role!=="assistant"?i=void 0:e=i.id;let a=!1;const s=n.pipeThrough(new TransformStream({transform(f,p){if(f.type==="start"){const g=f;g.messageId==null&&e!=null&&(g.messageId=e)}f.type==="abort"&&(a=!0),p.enqueue(f)}}));if(r==null)return s;const l=Kz({lastMessage:i?structuredClone(i):void 0,messageId:e??""}),u=async f=>{await f({state:l,write:()=>{}})};let c=!1;const d=async()=>{if(c||!r)return;c=!0;const f=l.message.id===i?.id;await r({isAborted:a,isContinuation:f,responseMessage:l.message,messages:[...f?t.slice(0,-1):t,l.message]})};return Yz({stream:s,runUpdateMessageJob:u,onError:o}).pipeThrough(new TransformStream({transform(f,p){p.enqueue(f)},async cancel(){await d()},async flush(){await d()}}))}function Xz({response:e,status:t,statusText:r,headers:o,stream:n,consumeSseStream:i}){let a=n.pipeThrough(new v$);if(i){const[s,l]=a.tee();a=s,i({stream:l})}g$({response:e,status:t,statusText:r,headers:Object.fromEntries(Ha(o,y$).entries()),stream:a.pipeThrough(new TextEncoderStream)})}function Wo(e){const t=e.pipeThrough(new TransformStream);return t[Symbol.asyncIterator]=function(){const r=this.getReader();let o=!1;async function n(i){var a;o=!0;try{i&&await((a=r.cancel)==null?void 0:a.call(r))}finally{try{r.releaseLock()}catch{}}}return{async next(){if(o)return{done:!0,value:void 0};const{done:i,value:a}=await r.read();return i?(await n(!0),{done:!0,value:void 0}):{done:!1,value:a}},async return(){return await n(!0),{done:!0,value:void 0}},async throw(i){throw await n(!0),i}}},t}async function eM({stream:e,onError:t}){const r=e.getReader();try{for(;;){const{done:o}=await r.read();if(o)break}}catch(o){t?.(o)}finally{r.releaseLock()}}function Cf(){let e,t;return{promise:new Promise((o,n)=>{e=o,t=n}),resolve:e,reject:t}}function tM(){let e=[],t=null,r=!1,o=Cf();const n=()=>{r=!0,o.resolve(),e.forEach(a=>a.cancel()),e=[],t?.close()},i=async()=>{if(r&&e.length===0){t?.close();return}if(e.length===0)return o=Cf(),await o.promise,i();try{const{value:a,done:s}=await e[0].read();s?(e.shift(),e.length>0?await i():r&&t?.close()):t?.enqueue(a)}catch(a){t?.error(a),e.shift(),n()}};return{stream:new ReadableStream({start(a){t=a},pull:i,async cancel(){for(const a of e)await a.cancel();e=[],r=!0}}),addStream:a=>{if(r)throw new Error("Cannot add inner stream: outer stream is closed");e.push(a.getReader()),o.resolve()},close:()=>{r=!0,o.resolve(),e.length===0&&t?.close()},terminate:n}}var Ho=class{constructor(){this.status={type:"pending"},this._resolve=void 0,this._reject=void 0}get promise(){return this._promise?this._promise:(this._promise=new Promise((e,t)=>{this.status.type==="resolved"?e(this.status.value):this.status.type==="rejected"&&t(this.status.error),this._resolve=e,this._reject=t}),this._promise)}resolve(e){var t;this.status={type:"resolved",value:e},this._promise&&((t=this._resolve)==null||t.call(this,e))}reject(e){var t;this.status={type:"rejected",error:e},this._promise&&((t=this._reject)==null||t.call(this,e))}};function rM(){var e,t;return(t=(e=globalThis?.performance)==null?void 0:e.now())!=null?t:Date.now()}function nM({tools:e,generatorStream:t,tracer:r,telemetry:o,system:n,messages:i,abortSignal:a,repairToolCall:s,experimental_context:l}){let u=null;const c=new ReadableStream({start(y){u=y}}),d=new Set,f=new Map;let p=!1,g;function h(){p&&d.size===0&&(g!=null&&u.enqueue(g),u.close())}const b=new TransformStream({async transform(y,x){const $=y.type;switch($){case"stream-start":case"text-start":case"text-delta":case"text-end":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"tool-input-start":case"tool-input-delta":case"tool-input-end":case"source":case"response-metadata":case"error":case"raw":{x.enqueue(y);break}case"file":{x.enqueue({type:"file",file:new Uz({data:y.data,mediaType:y.mediaType})});break}case"finish":{g={type:"finish",finishReason:y.finishReason,usage:y.usage,providerMetadata:y.providerMetadata};break}case"tool-call":{try{const v=await Lz({toolCall:y,tools:e,repairToolCall:s,system:n,messages:i});if(x.enqueue(v),v.invalid){u.enqueue({type:"tool-error",toolCallId:v.toolCallId,toolName:v.toolName,input:v.input,error:ux(v.error),dynamic:!0});break}const k=e[v.toolName];if(f.set(v.toolCallId,v.input),k.onInputAvailable!=null&&await k.onInputAvailable({input:v.input,toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}),k.execute!=null&&v.providerExecuted!==!0){const N=J1();d.add(N),Ou({name:"ai.toolCall",attributes:Lr({telemetry:o,attributes:{...Tu({operationId:"ai.toolCall",telemetry:o}),"ai.toolCall.name":v.toolName,"ai.toolCall.id":v.toolCallId,"ai.toolCall.args":{output:()=>JSON.stringify(v.input)}}}),tracer:r,fn:async I=>{let O;try{const z=iR({execute:k.execute.bind(k),input:v.input,options:{toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}});for await(const F of z)u.enqueue({...v,type:"tool-result",output:F.output,...F.type==="preliminary"&&{preliminary:!0}}),F.type==="final"&&(O=F.output)}catch(z){f$(I,z),u.enqueue({...v,type:"tool-error",error:z}),d.delete(N),h();return}d.delete(N),h();try{I.setAttributes(Lr({telemetry:o,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(O)}}}))}catch{}}})}}catch(v){u.enqueue({type:"error",error:v})}break}case"tool-result":{const v=y.toolName;y.isError?u.enqueue({type:"tool-error",toolCallId:y.toolCallId,toolName:v,input:f.get(y.toolCallId),providerExecuted:y.providerExecuted,error:y.result}):x.enqueue({type:"tool-result",toolCallId:y.toolCallId,toolName:v,input:f.get(y.toolCallId),output:y.result,providerExecuted:y.providerExecuted});break}default:{const v=$;throw new Error(`Unhandled chunk type: ${v}`)}}},flush(){p=!0,h()}});return new ReadableStream({async start(y){return Promise.all([t.pipeThrough(b).pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){}})),c.pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){y.close()}}))])}})}var oM=No({prefix:"aitxt",size:24});function iM({model:e,tools:t,toolChoice:r,system:o,prompt:n,messages:i,maxRetries:a,abortSignal:s,headers:l,stopWhen:u=h$(1),experimental_output:c,experimental_telemetry:d,prepareStep:f,providerOptions:p,experimental_activeTools:g,activeTools:h=g,experimental_repairToolCall:b,experimental_transform:y,experimental_download:x,includeRawChunks:$=!1,onChunk:v,onError:k=({error:V})=>{console.error(V)},onFinish:N,onAbort:I,onStepFinish:O,experimental_context:z,_internal:{now:F=rM,generateId:te=oM,currentDate:ie=()=>new Date}={},...J}){return new sM({model:s$(e),telemetry:d,headers:l,settings:J,maxRetries:a,abortSignal:s,system:o,prompt:n,messages:i,tools:t,toolChoice:r,transforms:kf(y),activeTools:h,repairToolCall:b,stopConditions:kf(u),output:c,providerOptions:p,prepareStep:f,includeRawChunks:$,onChunk:v,onError:k,onFinish:N,onAbort:I,onStepFinish:O,now:F,currentDate:ie,generateId:te,experimental_context:z,download:x})}function aM(e){if(!e)return new TransformStream({transform(a,s){s.enqueue({part:a,partialOutput:void 0})}});let t,r="",o="",n="";function i({controller:a,partialOutput:s=void 0}){a.enqueue({part:{type:"text-delta",id:t,text:o},partialOutput:s}),o=""}return new TransformStream({async transform(a,s){if(a.type==="finish-step"&&o.length>0&&i({controller:s}),a.type!=="text-delta"&&a.type!=="text-start"&&a.type!=="text-end"){s.enqueue({part:a,partialOutput:void 0});return}if(t==null)t=a.id;else if(a.id!==t){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-start"){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-end"){o.length>0&&i({controller:s}),s.enqueue({part:a,partialOutput:void 0});return}r+=a.text,o+=a.text;const l=await e.parsePartial({text:r});if(l!=null){const u=JSON.stringify(l.partial);u!==n&&(i({controller:s,partialOutput:l.partial}),n=u)}}})}var sM=class{constructor({model:e,telemetry:t,headers:r,settings:o,maxRetries:n,abortSignal:i,system:a,prompt:s,messages:l,tools:u,toolChoice:c,transforms:d,activeTools:f,repairToolCall:p,stopConditions:g,output:h,providerOptions:b,prepareStep:y,includeRawChunks:x,now:$,currentDate:v,generateId:k,onChunk:N,onError:I,onFinish:O,onAbort:z,onStepFinish:F,experimental_context:te,download:ie}){this._totalUsage=new Ho,this._finishReason=new Ho,this._steps=new Ho,this.output=h,this.includeRawChunks=x,this.tools=u;let J,V=[];const we=[];let oe,de,K={},fe=[];const B=[];let Ue,ye={},Le={};const U=new TransformStream({async transform(Ee,Te){var Ae,ae,ft,mn;Te.enqueue(Ee);const{part:Z}=Ee;if((Z.type==="text-delta"||Z.type==="reasoning-delta"||Z.type==="source"||Z.type==="tool-call"||Z.type==="tool-result"||Z.type==="tool-input-start"||Z.type==="tool-input-delta"||Z.type==="raw")&&await N?.({chunk:Z}),Z.type==="error"&&await I({error:Tz(Z.error)}),Z.type==="text-start"&&(ye[Z.id]={type:"text",text:"",providerMetadata:Z.providerMetadata},V.push(ye[Z.id])),Z.type==="text-delta"){const Ie=ye[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`text part ${Z.id} not found`},partialOutput:void 0});return}Ie.text+=Z.text,Ie.providerMetadata=(Ae=Z.providerMetadata)!=null?Ae:Ie.providerMetadata}if(Z.type==="text-end"){const Ie=ye[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`text part ${Z.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(ae=Z.providerMetadata)!=null?ae:Ie.providerMetadata,delete ye[Z.id]}if(Z.type==="reasoning-start"&&(Le[Z.id]={type:"reasoning",text:"",providerMetadata:Z.providerMetadata},V.push(Le[Z.id])),Z.type==="reasoning-delta"){const Ie=Le[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`reasoning part ${Z.id} not found`},partialOutput:void 0});return}Ie.text+=Z.text,Ie.providerMetadata=(ft=Z.providerMetadata)!=null?ft:Ie.providerMetadata}if(Z.type==="reasoning-end"){const Ie=Le[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`reasoning part ${Z.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(mn=Z.providerMetadata)!=null?mn:Ie.providerMetadata,delete Le[Z.id]}if(Z.type==="file"&&V.push({type:"file",file:Z.file}),Z.type==="source"&&V.push(Z),Z.type==="tool-call"&&V.push(Z),Z.type==="tool-result"&&!Z.preliminary&&V.push(Z),Z.type==="tool-error"&&V.push(Z),Z.type==="start-step"&&(K=Z.request,fe=Z.warnings),Z.type==="finish-step"){const Ie=Of({content:V,tools:u}),hn=new Zz({content:V,finishReason:Z.finishReason,usage:Z.usage,warnings:fe,request:K,response:{...Z.response,messages:[...we,...Ie]},providerMetadata:Z.providerMetadata});await F?.(hn),UR(fe),B.push(hn),V=[],Le={},ye={},we.push(...Ie),J.resolve()}Z.type==="finish"&&(de=Z.totalUsage,oe=Z.finishReason)},async flush(Ee){try{if(B.length===0){const ft=new VR({message:"No output generated. Check the stream for errors."});je._finishReason.reject(ft),je._totalUsage.reject(ft),je._steps.reject(ft);return}const Te=oe??"unknown",Ae=de??{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};je._finishReason.resolve(Te),je._totalUsage.resolve(Ae),je._steps.resolve(B);const ae=B[B.length-1];await O?.({finishReason:Te,totalUsage:Ae,usage:ae.usage,content:ae.content,text:ae.text,reasoningText:ae.reasoningText,reasoning:ae.reasoning,files:ae.files,sources:ae.sources,toolCalls:ae.toolCalls,staticToolCalls:ae.staticToolCalls,dynamicToolCalls:ae.dynamicToolCalls,toolResults:ae.toolResults,staticToolResults:ae.staticToolResults,dynamicToolResults:ae.dynamicToolResults,request:ae.request,response:ae.response,warnings:ae.warnings,providerMetadata:ae.providerMetadata,steps:B}),Ue.setAttributes(Lr({telemetry:t,attributes:{"ai.response.finishReason":Te,"ai.response.text":{output:()=>ae.text},"ai.response.toolCalls":{output:()=>{var ft;return(ft=ae.toolCalls)!=null&&ft.length?JSON.stringify(ae.toolCalls):void 0}},"ai.response.providerMetadata":JSON.stringify(ae.providerMetadata),"ai.usage.inputTokens":Ae.inputTokens,"ai.usage.outputTokens":Ae.outputTokens,"ai.usage.totalTokens":Ae.totalTokens,"ai.usage.reasoningTokens":Ae.reasoningTokens,"ai.usage.cachedInputTokens":Ae.cachedInputTokens}}))}catch(Te){Ee.error(Te)}finally{Ue.end()}}}),Q=tM();this.addStream=Q.addStream,this.closeStream=Q.close;const me=Q.stream.getReader();let xe=new ReadableStream({async start(Ee){Ee.enqueue({type:"start"})},async pull(Ee){function Te(){z?.({steps:B}),Ee.enqueue({type:"abort"}),Ee.close()}try{const{done:Ae,value:ae}=await me.read();if(Ae){Ee.close();return}if(i?.aborted){Te();return}Ee.enqueue(ae)}catch(Ae){wr(Ae)&&i?.aborted?Te():Ee.error(Ae)}},cancel(Ee){return Q.stream.cancel(Ee)}});for(const Ee of d)xe=xe.pipeThrough(Ee({tools:u,stopStream(){Q.terminate()}}));this.baseStream=xe.pipeThrough(aM(h)).pipeThrough(U);const{maxRetries:Ro,retry:us}=Mz({maxRetries:n,abortSignal:i}),fn=Cz(t),pt=hz(o),zo=Oz({model:e,telemetry:t,headers:r,settings:{...pt,maxRetries:Ro}}),je=this;Ou({name:"ai.streamText",attributes:Lr({telemetry:t,attributes:{...Tu({operationId:"ai.streamText",telemetry:t}),...zo,"ai.prompt":{input:()=>JSON.stringify({system:a,prompt:s,messages:l})}}}),tracer:fn,endWhenDone:!1,fn:async Ee=>{Ue=Ee;async function Te({currentStep:Ae,responseMessages:ae,usage:ft}){var mn,Z,Ie,hn,Id;const kd=je.includeRawChunks;J=new Ho;const Ed=await Ez({system:a,prompt:s,messages:l}),gn=[...Ed.messages,...ae],Et=await y?.({model:e,steps:B,stepNumber:B.length,messages:gn}),Nr=s$((mn=Et?.model)!=null?mn:e),Td=await dz({prompt:{system:(Z=Et?.system)!=null?Z:Ed.system,messages:(Ie=Et?.messages)!=null?Ie:gn},supportedUrls:await Nr.supportedUrls,download:ie}),{toolChoice:ls,tools:cs}=vz({tools:u,toolChoice:(hn=Et?.toolChoice)!=null?hn:c,activeTools:(Id=Et?.activeTools)!=null?Id:f}),{result:{stream:g0,response:Od,request:Nd},doStreamSpan:Pr,startTimestampMs:Pd}=await us(()=>Ou({name:"ai.streamText.doStream",attributes:Lr({telemetry:t,attributes:{...Tu({operationId:"ai.streamText.doStream",telemetry:t}),...zo,"ai.model.provider":Nr.provider,"ai.model.id":Nr.modelId,"ai.prompt.messages":{input:()=>jz(Td)},"ai.prompt.tools":{input:()=>cs?.map(W=>JSON.stringify(W))},"ai.prompt.toolChoice":{input:()=>ls!=null?JSON.stringify(ls):void 0},"gen_ai.system":Nr.provider,"gen_ai.request.model":Nr.modelId,"gen_ai.request.frequency_penalty":pt.frequencyPenalty,"gen_ai.request.max_tokens":pt.maxOutputTokens,"gen_ai.request.presence_penalty":pt.presencePenalty,"gen_ai.request.stop_sequences":pt.stopSequences,"gen_ai.request.temperature":pt.temperature,"gen_ai.request.top_k":pt.topK,"gen_ai.request.top_p":pt.topP}}),tracer:fn,endWhenDone:!1,fn:async W=>({startTimestampMs:$(),doStreamSpan:W,result:await Nr.doStream({...pt,tools:cs,toolChoice:ls,responseFormat:h?.responseFormat,prompt:Td,providerOptions:b,abortSignal:i,headers:r,includeRawChunks:kd})})})),v0=nM({tools:u,generatorStream:g0,tracer:fn,telemetry:t,system:a,messages:gn,repairToolCall:p,abortSignal:i,experimental_context:te}),y0=Nd??{},Mo=[],ds=[];let ps;const fs={};let Cr="unknown",mt={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},ms,Cd=!0,Tt={id:k(),timestamp:v(),modelId:e.modelId},jd="";je.addStream(v0.pipeThrough(new TransformStream({async transform(W,Re){var vn,yn,Do,Ut;if(W.type==="stream-start"){ps=W.warnings;return}if(Cd){const Ze=$()-Pd;Cd=!1,Pr.addEvent("ai.stream.firstChunk",{"ai.response.msToFirstChunk":Ze}),Pr.setAttributes({"ai.response.msToFirstChunk":Ze}),Re.enqueue({type:"start-step",request:y0,warnings:ps??[]})}const Ad=W.type;switch(Ad){case"text-start":case"text-end":{Re.enqueue(W);break}case"text-delta":{W.delta.length>0&&(Re.enqueue({type:"text-delta",id:W.id,text:W.delta,providerMetadata:W.providerMetadata}),jd+=W.delta);break}case"reasoning-start":case"reasoning-end":{Re.enqueue(W);break}case"reasoning-delta":{Re.enqueue({type:"reasoning-delta",id:W.id,text:W.delta,providerMetadata:W.providerMetadata});break}case"tool-call":{Re.enqueue(W),Mo.push(W);break}case"tool-result":{Re.enqueue(W),W.preliminary||ds.push(W);break}case"tool-error":{Re.enqueue(W),ds.push(W);break}case"response-metadata":{Tt={id:(vn=W.id)!=null?vn:Tt.id,timestamp:(yn=W.timestamp)!=null?yn:Tt.timestamp,modelId:(Do=W.modelId)!=null?Do:Tt.modelId};break}case"finish":{mt=W.usage,Cr=W.finishReason,ms=W.providerMetadata;const Ze=$()-Pd;Pr.addEvent("ai.stream.finish"),Pr.setAttributes({"ai.response.msToFinish":Ze,"ai.response.avgOutputTokensPerSecond":1e3*((Ut=mt.outputTokens)!=null?Ut:0)/Ze});break}case"file":{Re.enqueue(W);break}case"source":{Re.enqueue(W);break}case"tool-input-start":{fs[W.id]=W.toolName;const Ze=u?.[W.toolName];Ze?.onInputStart!=null&&await Ze.onInputStart({toolCallId:W.id,messages:gn,abortSignal:i,experimental_context:te}),Re.enqueue({...W,dynamic:Ze?.type==="dynamic"});break}case"tool-input-end":{delete fs[W.id],Re.enqueue(W);break}case"tool-input-delta":{const Ze=fs[W.id],hs=u?.[Ze];hs?.onInputDelta!=null&&await hs.onInputDelta({inputTextDelta:W.delta,toolCallId:W.id,messages:gn,abortSignal:i,experimental_context:te}),Re.enqueue(W);break}case"error":{Re.enqueue(W),Cr="error";break}case"raw":{kd&&Re.enqueue(W);break}default:{const Ze=Ad;throw new Error(`Unknown chunk type: ${Ze}`)}}},async flush(W){const Re=Mo.length>0?JSON.stringify(Mo):void 0;try{Pr.setAttributes(Lr({telemetry:t,attributes:{"ai.response.finishReason":Cr,"ai.response.text":{output:()=>jd},"ai.response.toolCalls":{output:()=>Re},"ai.response.id":Tt.id,"ai.response.model":Tt.modelId,"ai.response.timestamp":Tt.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(ms),"ai.usage.inputTokens":mt.inputTokens,"ai.usage.outputTokens":mt.outputTokens,"ai.usage.totalTokens":mt.totalTokens,"ai.usage.reasoningTokens":mt.reasoningTokens,"ai.usage.cachedInputTokens":mt.cachedInputTokens,"gen_ai.response.finish_reasons":[Cr],"gen_ai.response.id":Tt.id,"gen_ai.response.model":Tt.modelId,"gen_ai.usage.input_tokens":mt.inputTokens,"gen_ai.usage.output_tokens":mt.outputTokens}}))}catch{}finally{Pr.end()}W.enqueue({type:"finish-step",finishReason:Cr,usage:mt,providerMetadata:ms,response:{...Tt,headers:Od?.headers}});const vn=Az(ft,mt);await J.promise;const yn=Mo.filter(Ut=>Ut.providerExecuted!==!0),Do=ds.filter(Ut=>Ut.providerExecuted!==!0);if(yn.length>0&&Do.length===yn.length&&!await Fz({stopConditions:g,steps:B})){ae.push(...Of({content:B[B.length-1].content,tools:u}));try{await Te({currentStep:Ae+1,responseMessages:ae,usage:vn})}catch(Ut){W.enqueue({type:"error",error:Ut}),je.closeStream()}}else W.enqueue({type:"finish",finishReason:Cr,totalUsage:vn}),je.closeStream()}})))}await Te({currentStep:0,responseMessages:[],usage:{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0}})}}).catch(Ee=>{je.addStream(new ReadableStream({start(Te){Te.enqueue({type:"error",error:Ee}),Te.close()}})),je.closeStream()})}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then(e=>e[e.length-1])}get content(){return this.finalStep.then(e=>e.content)}get warnings(){return this.finalStep.then(e=>e.warnings)}get providerMetadata(){return this.finalStep.then(e=>e.providerMetadata)}get text(){return this.finalStep.then(e=>e.text)}get reasoningText(){return this.finalStep.then(e=>e.reasoningText)}get reasoning(){return this.finalStep.then(e=>e.reasoning)}get sources(){return this.finalStep.then(e=>e.sources)}get files(){return this.finalStep.then(e=>e.files)}get toolCalls(){return this.finalStep.then(e=>e.toolCalls)}get staticToolCalls(){return this.finalStep.then(e=>e.staticToolCalls)}get dynamicToolCalls(){return this.finalStep.then(e=>e.dynamicToolCalls)}get toolResults(){return this.finalStep.then(e=>e.toolResults)}get staticToolResults(){return this.finalStep.then(e=>e.staticToolResults)}get dynamicToolResults(){return this.finalStep.then(e=>e.dynamicToolResults)}get usage(){return this.finalStep.then(e=>e.usage)}get request(){return this.finalStep.then(e=>e.request)}get response(){return this.finalStep.then(e=>e.response)}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}teeStream(){const[e,t]=this.baseStream.tee();return this.baseStream=t,e}get textStream(){return Wo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){e.type==="text-delta"&&t.enqueue(e.text)}})))}get fullStream(){return Wo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){t.enqueue(e)}})))}async consumeStream(e){var t;try{await eM({stream:this.fullStream,onError:e?.onError})}catch(r){(t=e?.onError)==null||t.call(e,r)}}get experimental_partialOutputStream(){if(this.output==null)throw new zR;return Wo(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:e},t){e!=null&&t.enqueue(e)}})))}toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n=!0,sendSources:i=!1,sendStart:a=!0,sendFinish:s=!0,onError:l=sn}={}){const u=t!=null?Jz({originalMessages:e,responseMessageId:t}):void 0,c={},d=p=>{var g,h;const b=c[p];return((h=(g=this.tools)==null?void 0:g[b])==null?void 0:h.type)==="dynamic"?!0:void 0},f=this.fullStream.pipeThrough(new TransformStream({transform:async(p,g)=>{const h=o?.({part:p}),b=p.type;switch(b){case"text-start":{g.enqueue({type:"text-start",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"text-delta":{g.enqueue({type:"text-delta",id:p.id,delta:p.text,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"text-end":{g.enqueue({type:"text-end",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-start":{g.enqueue({type:"reasoning-start",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-delta":{n&&g.enqueue({type:"reasoning-delta",id:p.id,delta:p.text,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-end":{g.enqueue({type:"reasoning-end",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"file":{g.enqueue({type:"file",mediaType:p.file.mediaType,url:`data:${p.file.mediaType};base64,${p.file.base64}`});break}case"source":{i&&p.sourceType==="url"&&g.enqueue({type:"source-url",sourceId:p.id,url:p.url,title:p.title,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}}),i&&p.sourceType==="document"&&g.enqueue({type:"source-document",sourceId:p.id,mediaType:p.mediaType,title:p.title,filename:p.filename,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"tool-input-start":{c[p.id]=p.toolName;const y=d(p.id);g.enqueue({type:"tool-input-start",toolCallId:p.id,toolName:p.toolName,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"tool-input-delta":{g.enqueue({type:"tool-input-delta",toolCallId:p.id,inputTextDelta:p.delta});break}case"tool-call":{c[p.toolCallId]=p.toolName;const y=d(p.toolCallId);p.invalid?g.enqueue({type:"tool-input-error",toolCallId:p.toolCallId,toolName:p.toolName,input:p.input,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{},...y!=null?{dynamic:y}:{},errorText:l(p.error)}):g.enqueue({type:"tool-input-available",toolCallId:p.toolCallId,toolName:p.toolName,input:p.input,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{},...y!=null?{dynamic:y}:{}});break}case"tool-result":{const y=d(p.toolCallId);g.enqueue({type:"tool-output-available",toolCallId:p.toolCallId,output:p.output,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.preliminary!=null?{preliminary:p.preliminary}:{},...y!=null?{dynamic:y}:{}});break}case"tool-error":{const y=d(p.toolCallId);g.enqueue({type:"tool-output-error",toolCallId:p.toolCallId,errorText:l(p.error),...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"error":{g.enqueue({type:"error",errorText:l(p.error)});break}case"start-step":{g.enqueue({type:"start-step"});break}case"finish-step":{g.enqueue({type:"finish-step"});break}case"start":{a&&g.enqueue({type:"start",...h!=null?{messageMetadata:h}:{},...u!=null?{messageId:u}:{}});break}case"finish":{s&&g.enqueue({type:"finish",...h!=null?{messageMetadata:h}:{}});break}case"abort":{g.enqueue(p);break}case"tool-input-end":break;case"raw":break;default:{const y=b;throw new Error(`Unknown chunk type: ${y}`)}}h!=null&&b!=="start"&&b!=="finish"&&g.enqueue({type:"message-metadata",messageMetadata:h})}}));return Wo(Qz({stream:f,messageId:u??t?.(),originalMessages:e,onFinish:r,onError:l}))}pipeUIMessageStreamToResponse(e,{originalMessages:t,generateMessageId:r,onFinish:o,messageMetadata:n,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u,...c}={}){Xz({response:e,stream:this.toUIMessageStream({originalMessages:t,generateMessageId:r,onFinish:o,messageMetadata:n,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u}),...c})}pipeTextStreamToResponse(e,t){Vz({response:e,textStream:this.textStream,...t})}toUIMessageStreamResponse({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n,sendSources:i,sendFinish:a,sendStart:s,onError:l,...u}={}){return Bz({stream:this.toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n,sendSources:i,sendFinish:a,sendStart:s,onError:l}),...u})}toTextStreamResponse(e){return qz({textStream:this.textStream,...e})}};function uM(e,t){const r=[];t?.ignoreIncompleteToolCalls&&(e=e.map(o=>({...o,parts:o.parts.filter(n=>!Pf(n)||n.state!=="input-streaming"&&n.state!=="input-available")})));for(const o of e)switch(o.role){case"system":{const n=o.parts.filter(a=>a.type==="text"),i=n.reduce((a,s)=>s.providerMetadata!=null?{...a,...s.providerMetadata}:a,{});r.push({role:"system",content:n.map(a=>a.text).join(""),...Object.keys(i).length>0?{providerOptions:i}:{}});break}case"user":{r.push({role:"user",content:o.parts.map(n=>{var i;if(Ms(n))return{type:"text",text:n.text,...n.providerMetadata!=null?{providerOptions:n.providerMetadata}:{}};if(Ds(n))return{type:"file",mediaType:n.mediaType,filename:n.filename,data:n.url,...n.providerMetadata!=null?{providerOptions:n.providerMetadata}:{}};if(zs(n))return(i=t?.convertDataPart)==null?void 0:i.call(t,n)}).filter(n=>n!=null)});break}case"assistant":{if(o.parts!=null){let n=function(){var a,s,l;if(i.length===0)return;const u=[];for(const d of i)if(Ms(d))u.push({type:"text",text:d.text,...d.providerMetadata!=null?{providerOptions:d.providerMetadata}:{}});else if(Ds(d))u.push({type:"file",mediaType:d.mediaType,filename:d.filename,data:d.url});else if(Nf(d))u.push({type:"reasoning",text:d.text,providerOptions:d.providerMetadata});else if(Hc(d)){const f=d.toolName;d.state!=="input-streaming"&&u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:f,input:d.input,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}})}else if(Fr(d)){const f=Di(d);d.state!=="input-streaming"&&(u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:f,input:d.state==="output-error"?(a=d.input)!=null?a:d.rawInput:d.input,providerExecuted:d.providerExecuted,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}}),d.providerExecuted===!0&&(d.state==="output-available"||d.state==="output-error")&&u.push({type:"tool-result",toolCallId:d.toolCallId,toolName:f,output:Nn({output:d.state==="output-error"?d.errorText:d.output,tool:(s=t?.tools)==null?void 0:s[f],errorMode:d.state==="output-error"?"json":"none"})}))}else if(zs(d)){const f=(l=t?.convertDataPart)==null?void 0:l.call(t,d);f!=null&&u.push(f)}else{const f=d;throw new Error(`Unsupported part: ${f}`)}r.push({role:"assistant",content:u});const c=i.filter(d=>Fr(d)&&d.providerExecuted!==!0||d.type==="dynamic-tool");c.length>0&&r.push({role:"tool",content:c.map(d=>{var f;switch(d.state){case"output-error":case"output-available":{const p=Gz(d);return{type:"tool-result",toolCallId:d.toolCallId,toolName:p,output:Nn({output:d.state==="output-error"?d.errorText:d.output,tool:(f=t?.tools)==null?void 0:f[p],errorMode:d.state==="output-error"?"text":"none"})}}default:return null}}).filter(d=>d!=null)}),i=[]},i=[];for(const a of o.parts)Ms(a)||Nf(a)||Ds(a)||Pf(a)||zs(a)?i.push(a):a.type==="step-start"&&n();n();break}break}default:{const n=o.role;throw new QR({originalMessage:o,message:`Unsupported role: ${n}`})}}return r}No({prefix:"aiobj",size:24});No({prefix:"aiobj",size:24});var lM={};AR(lM,{object:()=>dM,text:()=>cM});var cM=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),dM=({schema:e})=>{const t=Wa(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:r}){const o=await _$(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const n=o.state;throw new Error(`Unsupported parse state: ${n}`)}}},async parseOutput({text:r},o){const n=await xr({text:r});if(!n.success)throw new Sf({message:"No object generated: could not parse the response.",cause:n.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await sr({value:n.value,schema:t});if(!i.success)throw new Sf({message:"No object generated: response did not match schema.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}},pM={word:/\S+\s+/m,line:/\n+/m};function fM({delayInMs:e=10,chunking:t="word",_internal:{delay:r=sx}={}}={}){let o;if(typeof t=="function")o=n=>{const i=t(n);if(i==null)return null;if(!i.length)throw new Error("Chunking function must return a non-empty string.");if(!n.startsWith(i))throw new Error(`Chunking function must return a match that is a prefix of the buffer. Received: "${i}" expected to start with "${n}"`);return i};else{const n=typeof t=="string"?pM[t]:t;if(n==null)throw new Bi({argument:"chunking",message:`Chunking must be "word" or "line" or a RegExp. Received: ${t}`});o=i=>{const a=n.exec(i);return a?i.slice(0,a.index)+a?.[0]:null}}return()=>{let n="",i="";return new TransformStream({async transform(a,s){if(a.type!=="text-delta"){n.length>0&&(s.enqueue({type:"text-delta",text:n,id:i}),n=""),s.enqueue(a);return}a.id!==i&&n.length>0&&(s.enqueue({type:"text-delta",text:n,id:i}),n=""),n+=a.text,i=a.id;let l;for(;(l=o(n))!=null;)s.enqueue({type:"text-delta",text:l,id:i}),n=n.slice(l.length),await r(e)}})}}function Us(e){return!!e&&"UNSAFE_apiKey"in e}const mM=({getSession:e,projectSlug:t,enabled:r})=>{const o=q_(),n=["chatSession",t],i=o.getQueryState(n),a=i?.data!==void 0,s=i?.dataUpdatedAt??0,u=a&&Date.now()-s>1/0,c=!a||u,{data:d}=B_({queryKey:n,queryFn:()=>e({projectSlug:t}),enabled:r&&c&&e!==null,staleTime:1/0,gcTime:1/0});return d??null};async function hM(e){return(await(await fetch("/chat/session",{method:"POST",headers:{"Gram-Project":e.projectSlug}})).json()).client_token}const gM=({projectSlug:e,auth:t})=>{const r=mM({enabled:!Us(t),getSession:Us(t)?null:t?.sessionFn??hM,projectSlug:e});return Us(t)?{headers:{"Gram-Project":e,"Gram-Key":t.UNSAFE_apiKey},isLoading:!1}:r?{headers:{"Gram-Project":e,"Gram-Chat-Session":r},isLoading:!1}:{isLoading:!0}};function vM({children:e}){const[t,r]=D.useState(new Map),[o,n]=D.useState(new Set),i=D.useCallback((d,f,p)=>new Promise(g=>{const h={toolCallId:f,toolName:d,args:p,resolve:g};r(b=>{const y=new Map(b);return y.set(f,h),y})}),[]),a=D.useCallback(d=>{n(f=>{const p=new Set(f);return p.add(d),p})},[]),s=D.useCallback(d=>{r(f=>{const p=f.get(d);if(p){p.resolve(!0);const g=new Map(f);return g.delete(d),g}return f})},[]),l=D.useCallback(d=>{r(f=>{const p=f.get(d);if(p){p.resolve(!1);const g=new Map(f);return g.delete(d),g}return f})},[]),u=D.useCallback(d=>o.has(d),[o]),c=D.useCallback(d=>t.get(d),[t]);return m.jsx(T.ToolApprovalContext.Provider,{value:{pendingApprovals:t,approvedTools:o,requestApproval:i,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:l,isToolApproved:u,getPendingApproval:c},children:e})}function yM(e){return(e.api?.url||""||"https://app.getgram.ai").replace(/\/+$/,"")}const bM="You are a helpful assistant that can answer questions and help with tasks.";function _M(e,t){return`
|
|
89
|
-
${
|
|
88
|
+
`)}})}},y$={"content-type":"text/event-stream","cache-control":"no-cache",connection:"keep-alive","x-vercel-ai-ui-message-stream":"v1","x-accel-buffering":"no"};function Jz({status:e,statusText:t,headers:r,stream:o,consumeSseStream:n}){let i=o.pipeThrough(new v$);if(n){const[a,s]=i.tee();i=a,n({stream:s})}return new Response(i.pipeThrough(new TextEncoderStream),{status:e,statusText:t,headers:Ga(r,y$)})}function Wz({originalMessages:e,responseMessageId:t}){if(e==null)return;const r=e[e.length-1];return r?.role==="assistant"?r.id:typeof t=="function"?t():t}function Hz(e){return e.type.startsWith("data-")}function b$(e,t){if(e===void 0&&t===void 0)return;if(e===void 0)return t;if(t===void 0)return e;const r={...e};for(const o in t)if(Object.prototype.hasOwnProperty.call(t,o)){const n=t[o];if(n===void 0)continue;const i=o in e?e[o]:void 0,a=n!==null&&typeof n=="object"&&!Array.isArray(n)&&!(n instanceof Date)&&!(n instanceof RegExp),s=i!=null&&typeof i=="object"&&!Array.isArray(i)&&!(i instanceof Date)&&!(i instanceof RegExp);a&&s?r[o]=b$(i,n):r[o]=n}return r}function Gz(e){const t=["ROOT"];let r=-1,o=null;function n(l,u,c){switch(l){case'"':{r=u,t.pop(),t.push(c),t.push("INSIDE_STRING");break}case"f":case"t":case"n":{r=u,o=u,t.pop(),t.push(c),t.push("INSIDE_LITERAL");break}case"-":{t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=u,t.pop(),t.push(c),t.push("INSIDE_NUMBER");break}case"{":{r=u,t.pop(),t.push(c),t.push("INSIDE_OBJECT_START");break}case"[":{r=u,t.pop(),t.push(c),t.push("INSIDE_ARRAY_START");break}}}function i(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break}case"}":{r=u,t.pop();break}}}function a(l,u){switch(l){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=u,t.pop();break}}}for(let l=0;l<e.length;l++){const u=e[l];switch(t[t.length-1]){case"ROOT":n(u,l,"FINISH");break;case"INSIDE_OBJECT_START":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}case"}":{r=l,t.pop();break}}break}case"INSIDE_OBJECT_AFTER_COMMA":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_KEY");break}}break}case"INSIDE_OBJECT_KEY":{switch(u){case'"':{t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY");break}}break}case"INSIDE_OBJECT_AFTER_KEY":{switch(u){case":":{t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE");break}}break}case"INSIDE_OBJECT_BEFORE_VALUE":{n(u,l,"INSIDE_OBJECT_AFTER_VALUE");break}case"INSIDE_OBJECT_AFTER_VALUE":{i(u,l);break}case"INSIDE_STRING":{switch(u){case'"':{t.pop(),r=l;break}case"\\":{t.push("INSIDE_STRING_ESCAPE");break}default:r=l}break}case"INSIDE_ARRAY_START":{switch(u){case"]":{r=l,t.pop();break}default:{r=l,n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}}break}case"INSIDE_ARRAY_AFTER_VALUE":{switch(u){case",":{t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break}case"]":{r=l,t.pop();break}default:{r=l;break}}break}case"INSIDE_ARRAY_AFTER_COMMA":{n(u,l,"INSIDE_ARRAY_AFTER_VALUE");break}case"INSIDE_STRING_ESCAPE":{t.pop(),r=l;break}case"INSIDE_NUMBER":{switch(u){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":{r=l;break}case"e":case"E":case"-":case".":break;case",":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"}":{t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"&&i(u,l);break}case"]":{t.pop(),t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l);break}default:{t.pop();break}}break}case"INSIDE_LITERAL":{const d=e.substring(o,l+1);!"false".startsWith(d)&&!"true".startsWith(d)&&!"null".startsWith(d)?(t.pop(),t[t.length-1]==="INSIDE_OBJECT_AFTER_VALUE"?i(u,l):t[t.length-1]==="INSIDE_ARRAY_AFTER_VALUE"&&a(u,l)):r=l;break}}}let s=e.slice(0,r+1);for(let l=t.length-1;l>=0;l--)switch(t[l]){case"INSIDE_STRING":{s+='"';break}case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":{s+="}";break}case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":{s+="]";break}case"INSIDE_LITERAL":{const c=e.substring(o,e.length);"true".startsWith(c)?s+="true".slice(c.length):"false".startsWith(c)?s+="false".slice(c.length):"null".startsWith(c)&&(s+="null".slice(c.length))}}return s}async function _$(e){if(e===void 0)return{value:void 0,state:"undefined-input"};let t=await xr({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=await xr({text:Gz(e)}),t.success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"})}function Ms(e){return e.type.startsWith("data-")}function Ds(e){return e.type==="text"}function Us(e){return e.type==="file"}function Nf(e){return e.type==="reasoning"}function Fr(e){return e.type.startsWith("tool-")}function Hc(e){return e.type==="dynamic-tool"}function Pf(e){return Fr(e)||Hc(e)}function Ui(e){return e.type.split("-").slice(1).join("-")}function Kz(e){return Hc(e)?e.toolName:Ui(e)}function Yz({lastMessage:e,messageId:t}){return{message:e?.role==="assistant"?e:{id:t,metadata:void 0,role:"assistant",parts:[]},activeTextParts:{},activeReasoningParts:{},partialToolCalls:{}}}function Qz({stream:e,messageMetadataSchema:t,dataPartSchemas:r,runUpdateMessageJob:o,onError:n,onToolCall:i,onData:a}){return e.pipeThrough(new TransformStream({async transform(s,l){await o(async({state:u,write:c})=>{var d,f,p,g;function h(v){const N=u.message.parts.filter(Fr).find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function b(v){const N=u.message.parts.filter(I=>I.type==="dynamic-tool").find(I=>I.toolCallId===v);if(N==null)throw new Error("tool-output-error must be preceded by a tool-input-available");return N}function y(v){var k;const N=u.message.parts.find(M=>Fr(M)&&M.toolCallId===v.toolCallId),I=v,O=N;N!=null?(N.state=v.state,O.input=I.input,O.output=I.output,O.errorText=I.errorText,O.rawInput=I.rawInput,O.preliminary=I.preliminary,O.providerExecuted=(k=I.providerExecuted)!=null?k:N.providerExecuted,I.providerMetadata!=null&&N.state==="input-available"&&(N.callProviderMetadata=I.providerMetadata)):u.message.parts.push({type:`tool-${v.toolName}`,toolCallId:v.toolCallId,state:v.state,input:I.input,output:I.output,rawInput:I.rawInput,errorText:I.errorText,providerExecuted:I.providerExecuted,preliminary:I.preliminary,...I.providerMetadata!=null?{callProviderMetadata:I.providerMetadata}:{}})}function x(v){var k,N;const I=u.message.parts.find(F=>F.type==="dynamic-tool"&&F.toolCallId===v.toolCallId),O=v,M=I;I!=null?(I.state=v.state,M.toolName=v.toolName,M.input=O.input,M.output=O.output,M.errorText=O.errorText,M.rawInput=(k=O.rawInput)!=null?k:M.rawInput,M.preliminary=O.preliminary,M.providerExecuted=(N=O.providerExecuted)!=null?N:I.providerExecuted,O.providerMetadata!=null&&I.state==="input-available"&&(I.callProviderMetadata=O.providerMetadata)):u.message.parts.push({type:"dynamic-tool",toolName:v.toolName,toolCallId:v.toolCallId,state:v.state,input:O.input,output:O.output,errorText:O.errorText,preliminary:O.preliminary,providerExecuted:O.providerExecuted,...O.providerMetadata!=null?{callProviderMetadata:O.providerMetadata}:{}})}async function $(v){if(v!=null){const k=u.message.metadata!=null?b$(u.message.metadata,v):v;t!=null&&await xu({value:k,schema:t}),u.message.metadata=k}}switch(s.type){case"text-start":{const v={type:"text",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeTextParts[s.id]=v,u.message.parts.push(v),c();break}case"text-delta":{const v=u.activeTextParts[s.id];v.text+=s.delta,v.providerMetadata=(d=s.providerMetadata)!=null?d:v.providerMetadata,c();break}case"text-end":{const v=u.activeTextParts[s.id];v.state="done",v.providerMetadata=(f=s.providerMetadata)!=null?f:v.providerMetadata,delete u.activeTextParts[s.id],c();break}case"reasoning-start":{const v={type:"reasoning",text:"",providerMetadata:s.providerMetadata,state:"streaming"};u.activeReasoningParts[s.id]=v,u.message.parts.push(v),c();break}case"reasoning-delta":{const v=u.activeReasoningParts[s.id];v.text+=s.delta,v.providerMetadata=(p=s.providerMetadata)!=null?p:v.providerMetadata,c();break}case"reasoning-end":{const v=u.activeReasoningParts[s.id];v.providerMetadata=(g=s.providerMetadata)!=null?g:v.providerMetadata,v.state="done",delete u.activeReasoningParts[s.id],c();break}case"file":{u.message.parts.push({type:"file",mediaType:s.mediaType,url:s.url}),c();break}case"source-url":{u.message.parts.push({type:"source-url",sourceId:s.sourceId,url:s.url,title:s.title,providerMetadata:s.providerMetadata}),c();break}case"source-document":{u.message.parts.push({type:"source-document",sourceId:s.sourceId,mediaType:s.mediaType,title:s.title,filename:s.filename,providerMetadata:s.providerMetadata}),c();break}case"tool-input-start":{const v=u.message.parts.filter(Fr);u.partialToolCalls[s.toolCallId]={text:"",toolName:s.toolName,index:v.length,dynamic:s.dynamic},s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-streaming",input:void 0,providerExecuted:s.providerExecuted}),c();break}case"tool-input-delta":{const v=u.partialToolCalls[s.toolCallId];v.text+=s.inputTextDelta;const{value:k}=await _$(v.text);v.dynamic?x({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}):y({toolCallId:s.toolCallId,toolName:v.toolName,state:"input-streaming",input:k}),c();break}case"tool-input-available":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"input-available",input:s.input,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c(),i&&!s.providerExecuted&&await i({toolCall:s});break}case"tool-input-error":{s.dynamic?x({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}):y({toolCallId:s.toolCallId,toolName:s.toolName,state:"output-error",input:void 0,rawInput:s.input,errorText:s.errorText,providerExecuted:s.providerExecuted,providerMetadata:s.providerMetadata}),c();break}case"tool-output-available":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-available",input:v.input,output:s.output,preliminary:s.preliminary})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Ui(v),state:"output-available",input:v.input,output:s.output,providerExecuted:s.providerExecuted,preliminary:s.preliminary})}c();break}case"tool-output-error":{if(s.dynamic){const v=b(s.toolCallId);x({toolCallId:s.toolCallId,toolName:v.toolName,state:"output-error",input:v.input,errorText:s.errorText,providerExecuted:s.providerExecuted})}else{const v=h(s.toolCallId);y({toolCallId:s.toolCallId,toolName:Ui(v),state:"output-error",input:v.input,rawInput:v.rawInput,errorText:s.errorText,providerExecuted:s.providerExecuted})}c();break}case"start-step":{u.message.parts.push({type:"step-start"});break}case"finish-step":{u.activeTextParts={},u.activeReasoningParts={};break}case"start":{s.messageId!=null&&(u.message.id=s.messageId),await $(s.messageMetadata),(s.messageId!=null||s.messageMetadata!=null)&&c();break}case"finish":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"message-metadata":{await $(s.messageMetadata),s.messageMetadata!=null&&c();break}case"error":{n?.(new Error(s.errorText));break}default:if(Hz(s)){r?.[s.type]!=null&&await xu({value:s.data,schema:r[s.type]});const v=s;if(v.transient){a?.(v);break}const k=v.id!=null?u.message.parts.find(N=>v.type===N.type&&v.id===N.id):void 0;k!=null?k.data=v.data:u.message.parts.push(v),a?.(v),c()}}l.enqueue(s)})}}))}function Xz({messageId:e,originalMessages:t=[],onFinish:r,onError:o,stream:n}){let i=t?.[t.length-1];i?.role!=="assistant"?i=void 0:e=i.id;let a=!1;const s=n.pipeThrough(new TransformStream({transform(f,p){if(f.type==="start"){const g=f;g.messageId==null&&e!=null&&(g.messageId=e)}f.type==="abort"&&(a=!0),p.enqueue(f)}}));if(r==null)return s;const l=Yz({lastMessage:i?structuredClone(i):void 0,messageId:e??""}),u=async f=>{await f({state:l,write:()=>{}})};let c=!1;const d=async()=>{if(c||!r)return;c=!0;const f=l.message.id===i?.id;await r({isAborted:a,isContinuation:f,responseMessage:l.message,messages:[...f?t.slice(0,-1):t,l.message]})};return Qz({stream:s,runUpdateMessageJob:u,onError:o}).pipeThrough(new TransformStream({transform(f,p){p.enqueue(f)},async cancel(){await d()},async flush(){await d()}}))}function eM({response:e,status:t,statusText:r,headers:o,stream:n,consumeSseStream:i}){let a=n.pipeThrough(new v$);if(i){const[s,l]=a.tee();a=s,i({stream:l})}g$({response:e,status:t,statusText:r,headers:Object.fromEntries(Ga(o,y$).entries()),stream:a.pipeThrough(new TextEncoderStream)})}function Wo(e){const t=e.pipeThrough(new TransformStream);return t[Symbol.asyncIterator]=function(){const r=this.getReader();let o=!1;async function n(i){var a;o=!0;try{i&&await((a=r.cancel)==null?void 0:a.call(r))}finally{try{r.releaseLock()}catch{}}}return{async next(){if(o)return{done:!0,value:void 0};const{done:i,value:a}=await r.read();return i?(await n(!0),{done:!0,value:void 0}):{done:!1,value:a}},async return(){return await n(!0),{done:!0,value:void 0}},async throw(i){throw await n(!0),i}}},t}async function tM({stream:e,onError:t}){const r=e.getReader();try{for(;;){const{done:o}=await r.read();if(o)break}}catch(o){t?.(o)}finally{r.releaseLock()}}function Cf(){let e,t;return{promise:new Promise((o,n)=>{e=o,t=n}),resolve:e,reject:t}}function rM(){let e=[],t=null,r=!1,o=Cf();const n=()=>{r=!0,o.resolve(),e.forEach(a=>a.cancel()),e=[],t?.close()},i=async()=>{if(r&&e.length===0){t?.close();return}if(e.length===0)return o=Cf(),await o.promise,i();try{const{value:a,done:s}=await e[0].read();s?(e.shift(),e.length>0?await i():r&&t?.close()):t?.enqueue(a)}catch(a){t?.error(a),e.shift(),n()}};return{stream:new ReadableStream({start(a){t=a},pull:i,async cancel(){for(const a of e)await a.cancel();e=[],r=!0}}),addStream:a=>{if(r)throw new Error("Cannot add inner stream: outer stream is closed");e.push(a.getReader()),o.resolve()},close:()=>{r=!0,o.resolve(),e.length===0&&t?.close()},terminate:n}}var Ho=class{constructor(){this.status={type:"pending"},this._resolve=void 0,this._reject=void 0}get promise(){return this._promise?this._promise:(this._promise=new Promise((e,t)=>{this.status.type==="resolved"?e(this.status.value):this.status.type==="rejected"&&t(this.status.error),this._resolve=e,this._reject=t}),this._promise)}resolve(e){var t;this.status={type:"resolved",value:e},this._promise&&((t=this._resolve)==null||t.call(this,e))}reject(e){var t;this.status={type:"rejected",error:e},this._promise&&((t=this._reject)==null||t.call(this,e))}};function nM(){var e,t;return(t=(e=globalThis?.performance)==null?void 0:e.now())!=null?t:Date.now()}function oM({tools:e,generatorStream:t,tracer:r,telemetry:o,system:n,messages:i,abortSignal:a,repairToolCall:s,experimental_context:l}){let u=null;const c=new ReadableStream({start(y){u=y}}),d=new Set,f=new Map;let p=!1,g;function h(){p&&d.size===0&&(g!=null&&u.enqueue(g),u.close())}const b=new TransformStream({async transform(y,x){const $=y.type;switch($){case"stream-start":case"text-start":case"text-delta":case"text-end":case"reasoning-start":case"reasoning-delta":case"reasoning-end":case"tool-input-start":case"tool-input-delta":case"tool-input-end":case"source":case"response-metadata":case"error":case"raw":{x.enqueue(y);break}case"file":{x.enqueue({type:"file",file:new Lz({data:y.data,mediaType:y.mediaType})});break}case"finish":{g={type:"finish",finishReason:y.finishReason,usage:y.usage,providerMetadata:y.providerMetadata};break}case"tool-call":{try{const v=await Zz({toolCall:y,tools:e,repairToolCall:s,system:n,messages:i});if(x.enqueue(v),v.invalid){u.enqueue({type:"tool-error",toolCallId:v.toolCallId,toolName:v.toolName,input:v.input,error:ux(v.error),dynamic:!0});break}const k=e[v.toolName];if(f.set(v.toolCallId,v.input),k.onInputAvailable!=null&&await k.onInputAvailable({input:v.input,toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}),k.execute!=null&&v.providerExecuted!==!0){const N=W1();d.add(N),Ou({name:"ai.toolCall",attributes:Lr({telemetry:o,attributes:{...Tu({operationId:"ai.toolCall",telemetry:o}),"ai.toolCall.name":v.toolName,"ai.toolCall.id":v.toolCallId,"ai.toolCall.args":{output:()=>JSON.stringify(v.input)}}}),tracer:r,fn:async I=>{let O;try{const M=aR({execute:k.execute.bind(k),input:v.input,options:{toolCallId:v.toolCallId,messages:i,abortSignal:a,experimental_context:l}});for await(const F of M)u.enqueue({...v,type:"tool-result",output:F.output,...F.type==="preliminary"&&{preliminary:!0}}),F.type==="final"&&(O=F.output)}catch(M){f$(I,M),u.enqueue({...v,type:"tool-error",error:M}),d.delete(N),h();return}d.delete(N),h();try{I.setAttributes(Lr({telemetry:o,attributes:{"ai.toolCall.result":{output:()=>JSON.stringify(O)}}}))}catch{}}})}}catch(v){u.enqueue({type:"error",error:v})}break}case"tool-result":{const v=y.toolName;y.isError?u.enqueue({type:"tool-error",toolCallId:y.toolCallId,toolName:v,input:f.get(y.toolCallId),providerExecuted:y.providerExecuted,error:y.result}):x.enqueue({type:"tool-result",toolCallId:y.toolCallId,toolName:v,input:f.get(y.toolCallId),output:y.result,providerExecuted:y.providerExecuted});break}default:{const v=$;throw new Error(`Unhandled chunk type: ${v}`)}}},flush(){p=!0,h()}});return new ReadableStream({async start(y){return Promise.all([t.pipeThrough(b).pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){}})),c.pipeTo(new WritableStream({write(x){y.enqueue(x)},close(){y.close()}}))])}})}var iM=No({prefix:"aitxt",size:24});function aM({model:e,tools:t,toolChoice:r,system:o,prompt:n,messages:i,maxRetries:a,abortSignal:s,headers:l,stopWhen:u=h$(1),experimental_output:c,experimental_telemetry:d,prepareStep:f,providerOptions:p,experimental_activeTools:g,activeTools:h=g,experimental_repairToolCall:b,experimental_transform:y,experimental_download:x,includeRawChunks:$=!1,onChunk:v,onError:k=({error:V})=>{console.error(V)},onFinish:N,onAbort:I,onStepFinish:O,experimental_context:M,_internal:{now:F=nM,generateId:te=iM,currentDate:oe=()=>new Date}={},...J}){return new uM({model:s$(e),telemetry:d,headers:l,settings:J,maxRetries:a,abortSignal:s,system:o,prompt:n,messages:i,tools:t,toolChoice:r,transforms:kf(y),activeTools:h,repairToolCall:b,stopConditions:kf(u),output:c,providerOptions:p,prepareStep:f,includeRawChunks:$,onChunk:v,onError:k,onFinish:N,onAbort:I,onStepFinish:O,now:F,currentDate:oe,generateId:te,experimental_context:M,download:x})}function sM(e){if(!e)return new TransformStream({transform(a,s){s.enqueue({part:a,partialOutput:void 0})}});let t,r="",o="",n="";function i({controller:a,partialOutput:s=void 0}){a.enqueue({part:{type:"text-delta",id:t,text:o},partialOutput:s}),o=""}return new TransformStream({async transform(a,s){if(a.type==="finish-step"&&o.length>0&&i({controller:s}),a.type!=="text-delta"&&a.type!=="text-start"&&a.type!=="text-end"){s.enqueue({part:a,partialOutput:void 0});return}if(t==null)t=a.id;else if(a.id!==t){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-start"){s.enqueue({part:a,partialOutput:void 0});return}if(a.type==="text-end"){o.length>0&&i({controller:s}),s.enqueue({part:a,partialOutput:void 0});return}r+=a.text,o+=a.text;const l=await e.parsePartial({text:r});if(l!=null){const u=JSON.stringify(l.partial);u!==n&&(i({controller:s,partialOutput:l.partial}),n=u)}}})}var uM=class{constructor({model:e,telemetry:t,headers:r,settings:o,maxRetries:n,abortSignal:i,system:a,prompt:s,messages:l,tools:u,toolChoice:c,transforms:d,activeTools:f,repairToolCall:p,stopConditions:g,output:h,providerOptions:b,prepareStep:y,includeRawChunks:x,now:$,currentDate:v,generateId:k,onChunk:N,onError:I,onFinish:O,onAbort:M,onStepFinish:F,experimental_context:te,download:oe}){this._totalUsage=new Ho,this._finishReason=new Ho,this._steps=new Ho,this.output=h,this.includeRawChunks=x,this.tools=u;let J,V=[];const ye=[];let ie,de,K={},fe=[];const B=[];let Ue,be={},Le={};const U=new TransformStream({async transform(Ee,Te){var Ae,ae,ft,mn;Te.enqueue(Ee);const{part:Z}=Ee;if((Z.type==="text-delta"||Z.type==="reasoning-delta"||Z.type==="source"||Z.type==="tool-call"||Z.type==="tool-result"||Z.type==="tool-input-start"||Z.type==="tool-input-delta"||Z.type==="raw")&&await N?.({chunk:Z}),Z.type==="error"&&await I({error:Oz(Z.error)}),Z.type==="text-start"&&(be[Z.id]={type:"text",text:"",providerMetadata:Z.providerMetadata},V.push(be[Z.id])),Z.type==="text-delta"){const Ie=be[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`text part ${Z.id} not found`},partialOutput:void 0});return}Ie.text+=Z.text,Ie.providerMetadata=(Ae=Z.providerMetadata)!=null?Ae:Ie.providerMetadata}if(Z.type==="text-end"){const Ie=be[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`text part ${Z.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(ae=Z.providerMetadata)!=null?ae:Ie.providerMetadata,delete be[Z.id]}if(Z.type==="reasoning-start"&&(Le[Z.id]={type:"reasoning",text:"",providerMetadata:Z.providerMetadata},V.push(Le[Z.id])),Z.type==="reasoning-delta"){const Ie=Le[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`reasoning part ${Z.id} not found`},partialOutput:void 0});return}Ie.text+=Z.text,Ie.providerMetadata=(ft=Z.providerMetadata)!=null?ft:Ie.providerMetadata}if(Z.type==="reasoning-end"){const Ie=Le[Z.id];if(Ie==null){Te.enqueue({part:{type:"error",error:`reasoning part ${Z.id} not found`},partialOutput:void 0});return}Ie.providerMetadata=(mn=Z.providerMetadata)!=null?mn:Ie.providerMetadata,delete Le[Z.id]}if(Z.type==="file"&&V.push({type:"file",file:Z.file}),Z.type==="source"&&V.push(Z),Z.type==="tool-call"&&V.push(Z),Z.type==="tool-result"&&!Z.preliminary&&V.push(Z),Z.type==="tool-error"&&V.push(Z),Z.type==="start-step"&&(K=Z.request,fe=Z.warnings),Z.type==="finish-step"){const Ie=Of({content:V,tools:u}),hn=new Fz({content:V,finishReason:Z.finishReason,usage:Z.usage,warnings:fe,request:K,response:{...Z.response,messages:[...ye,...Ie]},providerMetadata:Z.providerMetadata});await F?.(hn),LR(fe),B.push(hn),V=[],Le={},be={},ye.push(...Ie),J.resolve()}Z.type==="finish"&&(de=Z.totalUsage,ie=Z.finishReason)},async flush(Ee){try{if(B.length===0){const ft=new BR({message:"No output generated. Check the stream for errors."});je._finishReason.reject(ft),je._totalUsage.reject(ft),je._steps.reject(ft);return}const Te=ie??"unknown",Ae=de??{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0};je._finishReason.resolve(Te),je._totalUsage.resolve(Ae),je._steps.resolve(B);const ae=B[B.length-1];await O?.({finishReason:Te,totalUsage:Ae,usage:ae.usage,content:ae.content,text:ae.text,reasoningText:ae.reasoningText,reasoning:ae.reasoning,files:ae.files,sources:ae.sources,toolCalls:ae.toolCalls,staticToolCalls:ae.staticToolCalls,dynamicToolCalls:ae.dynamicToolCalls,toolResults:ae.toolResults,staticToolResults:ae.staticToolResults,dynamicToolResults:ae.dynamicToolResults,request:ae.request,response:ae.response,warnings:ae.warnings,providerMetadata:ae.providerMetadata,steps:B}),Ue.setAttributes(Lr({telemetry:t,attributes:{"ai.response.finishReason":Te,"ai.response.text":{output:()=>ae.text},"ai.response.toolCalls":{output:()=>{var ft;return(ft=ae.toolCalls)!=null&&ft.length?JSON.stringify(ae.toolCalls):void 0}},"ai.response.providerMetadata":JSON.stringify(ae.providerMetadata),"ai.usage.inputTokens":Ae.inputTokens,"ai.usage.outputTokens":Ae.outputTokens,"ai.usage.totalTokens":Ae.totalTokens,"ai.usage.reasoningTokens":Ae.reasoningTokens,"ai.usage.cachedInputTokens":Ae.cachedInputTokens}}))}catch(Te){Ee.error(Te)}finally{Ue.end()}}}),Q=rM();this.addStream=Q.addStream,this.closeStream=Q.close;const me=Q.stream.getReader();let xe=new ReadableStream({async start(Ee){Ee.enqueue({type:"start"})},async pull(Ee){function Te(){M?.({steps:B}),Ee.enqueue({type:"abort"}),Ee.close()}try{const{done:Ae,value:ae}=await me.read();if(Ae){Ee.close();return}if(i?.aborted){Te();return}Ee.enqueue(ae)}catch(Ae){wr(Ae)&&i?.aborted?Te():Ee.error(Ae)}},cancel(Ee){return Q.stream.cancel(Ee)}});for(const Ee of d)xe=xe.pipeThrough(Ee({tools:u,stopStream(){Q.terminate()}}));this.baseStream=xe.pipeThrough(sM(h)).pipeThrough(U);const{maxRetries:Ro,retry:ls}=Dz({maxRetries:n,abortSignal:i}),fn=jz(t),pt=gz(o),zo=Nz({model:e,telemetry:t,headers:r,settings:{...pt,maxRetries:Ro}}),je=this;Ou({name:"ai.streamText",attributes:Lr({telemetry:t,attributes:{...Tu({operationId:"ai.streamText",telemetry:t}),...zo,"ai.prompt":{input:()=>JSON.stringify({system:a,prompt:s,messages:l})}}}),tracer:fn,endWhenDone:!1,fn:async Ee=>{Ue=Ee;async function Te({currentStep:Ae,responseMessages:ae,usage:ft}){var mn,Z,Ie,hn,Id;const kd=je.includeRawChunks;J=new Ho;const Ed=await Tz({system:a,prompt:s,messages:l}),gn=[...Ed.messages,...ae],Et=await y?.({model:e,steps:B,stepNumber:B.length,messages:gn}),Nr=s$((mn=Et?.model)!=null?mn:e),Td=await pz({prompt:{system:(Z=Et?.system)!=null?Z:Ed.system,messages:(Ie=Et?.messages)!=null?Ie:gn},supportedUrls:await Nr.supportedUrls,download:oe}),{toolChoice:cs,tools:ds}=yz({tools:u,toolChoice:(hn=Et?.toolChoice)!=null?hn:c,activeTools:(Id=Et?.activeTools)!=null?Id:f}),{result:{stream:g0,response:Od,request:Nd},doStreamSpan:Pr,startTimestampMs:Pd}=await ls(()=>Ou({name:"ai.streamText.doStream",attributes:Lr({telemetry:t,attributes:{...Tu({operationId:"ai.streamText.doStream",telemetry:t}),...zo,"ai.model.provider":Nr.provider,"ai.model.id":Nr.modelId,"ai.prompt.messages":{input:()=>Az(Td)},"ai.prompt.tools":{input:()=>ds?.map(W=>JSON.stringify(W))},"ai.prompt.toolChoice":{input:()=>cs!=null?JSON.stringify(cs):void 0},"gen_ai.system":Nr.provider,"gen_ai.request.model":Nr.modelId,"gen_ai.request.frequency_penalty":pt.frequencyPenalty,"gen_ai.request.max_tokens":pt.maxOutputTokens,"gen_ai.request.presence_penalty":pt.presencePenalty,"gen_ai.request.stop_sequences":pt.stopSequences,"gen_ai.request.temperature":pt.temperature,"gen_ai.request.top_k":pt.topK,"gen_ai.request.top_p":pt.topP}}),tracer:fn,endWhenDone:!1,fn:async W=>({startTimestampMs:$(),doStreamSpan:W,result:await Nr.doStream({...pt,tools:ds,toolChoice:cs,responseFormat:h?.responseFormat,prompt:Td,providerOptions:b,abortSignal:i,headers:r,includeRawChunks:kd})})})),v0=oM({tools:u,generatorStream:g0,tracer:fn,telemetry:t,system:a,messages:gn,repairToolCall:p,abortSignal:i,experimental_context:te}),y0=Nd??{},Mo=[],ps=[];let fs;const ms={};let Cr="unknown",mt={inputTokens:void 0,outputTokens:void 0,totalTokens:void 0},hs,Cd=!0,Tt={id:k(),timestamp:v(),modelId:e.modelId},jd="";je.addStream(v0.pipeThrough(new TransformStream({async transform(W,Re){var vn,yn,Do,Ut;if(W.type==="stream-start"){fs=W.warnings;return}if(Cd){const Ze=$()-Pd;Cd=!1,Pr.addEvent("ai.stream.firstChunk",{"ai.response.msToFirstChunk":Ze}),Pr.setAttributes({"ai.response.msToFirstChunk":Ze}),Re.enqueue({type:"start-step",request:y0,warnings:fs??[]})}const Ad=W.type;switch(Ad){case"text-start":case"text-end":{Re.enqueue(W);break}case"text-delta":{W.delta.length>0&&(Re.enqueue({type:"text-delta",id:W.id,text:W.delta,providerMetadata:W.providerMetadata}),jd+=W.delta);break}case"reasoning-start":case"reasoning-end":{Re.enqueue(W);break}case"reasoning-delta":{Re.enqueue({type:"reasoning-delta",id:W.id,text:W.delta,providerMetadata:W.providerMetadata});break}case"tool-call":{Re.enqueue(W),Mo.push(W);break}case"tool-result":{Re.enqueue(W),W.preliminary||ps.push(W);break}case"tool-error":{Re.enqueue(W),ps.push(W);break}case"response-metadata":{Tt={id:(vn=W.id)!=null?vn:Tt.id,timestamp:(yn=W.timestamp)!=null?yn:Tt.timestamp,modelId:(Do=W.modelId)!=null?Do:Tt.modelId};break}case"finish":{mt=W.usage,Cr=W.finishReason,hs=W.providerMetadata;const Ze=$()-Pd;Pr.addEvent("ai.stream.finish"),Pr.setAttributes({"ai.response.msToFinish":Ze,"ai.response.avgOutputTokensPerSecond":1e3*((Ut=mt.outputTokens)!=null?Ut:0)/Ze});break}case"file":{Re.enqueue(W);break}case"source":{Re.enqueue(W);break}case"tool-input-start":{ms[W.id]=W.toolName;const Ze=u?.[W.toolName];Ze?.onInputStart!=null&&await Ze.onInputStart({toolCallId:W.id,messages:gn,abortSignal:i,experimental_context:te}),Re.enqueue({...W,dynamic:Ze?.type==="dynamic"});break}case"tool-input-end":{delete ms[W.id],Re.enqueue(W);break}case"tool-input-delta":{const Ze=ms[W.id],gs=u?.[Ze];gs?.onInputDelta!=null&&await gs.onInputDelta({inputTextDelta:W.delta,toolCallId:W.id,messages:gn,abortSignal:i,experimental_context:te}),Re.enqueue(W);break}case"error":{Re.enqueue(W),Cr="error";break}case"raw":{kd&&Re.enqueue(W);break}default:{const Ze=Ad;throw new Error(`Unknown chunk type: ${Ze}`)}}},async flush(W){const Re=Mo.length>0?JSON.stringify(Mo):void 0;try{Pr.setAttributes(Lr({telemetry:t,attributes:{"ai.response.finishReason":Cr,"ai.response.text":{output:()=>jd},"ai.response.toolCalls":{output:()=>Re},"ai.response.id":Tt.id,"ai.response.model":Tt.modelId,"ai.response.timestamp":Tt.timestamp.toISOString(),"ai.response.providerMetadata":JSON.stringify(hs),"ai.usage.inputTokens":mt.inputTokens,"ai.usage.outputTokens":mt.outputTokens,"ai.usage.totalTokens":mt.totalTokens,"ai.usage.reasoningTokens":mt.reasoningTokens,"ai.usage.cachedInputTokens":mt.cachedInputTokens,"gen_ai.response.finish_reasons":[Cr],"gen_ai.response.id":Tt.id,"gen_ai.response.model":Tt.modelId,"gen_ai.usage.input_tokens":mt.inputTokens,"gen_ai.usage.output_tokens":mt.outputTokens}}))}catch{}finally{Pr.end()}W.enqueue({type:"finish-step",finishReason:Cr,usage:mt,providerMetadata:hs,response:{...Tt,headers:Od?.headers}});const vn=Rz(ft,mt);await J.promise;const yn=Mo.filter(Ut=>Ut.providerExecuted!==!0),Do=ps.filter(Ut=>Ut.providerExecuted!==!0);if(yn.length>0&&Do.length===yn.length&&!await qz({stopConditions:g,steps:B})){ae.push(...Of({content:B[B.length-1].content,tools:u}));try{await Te({currentStep:Ae+1,responseMessages:ae,usage:vn})}catch(Ut){W.enqueue({type:"error",error:Ut}),je.closeStream()}}else W.enqueue({type:"finish",finishReason:Cr,totalUsage:vn}),je.closeStream()}})))}await Te({currentStep:0,responseMessages:[],usage:{inputTokens:void 0,outputTokens:void 0,totalTokens:void 0}})}}).catch(Ee=>{je.addStream(new ReadableStream({start(Te){Te.enqueue({type:"error",error:Ee}),Te.close()}})),je.closeStream()})}get steps(){return this.consumeStream(),this._steps.promise}get finalStep(){return this.steps.then(e=>e[e.length-1])}get content(){return this.finalStep.then(e=>e.content)}get warnings(){return this.finalStep.then(e=>e.warnings)}get providerMetadata(){return this.finalStep.then(e=>e.providerMetadata)}get text(){return this.finalStep.then(e=>e.text)}get reasoningText(){return this.finalStep.then(e=>e.reasoningText)}get reasoning(){return this.finalStep.then(e=>e.reasoning)}get sources(){return this.finalStep.then(e=>e.sources)}get files(){return this.finalStep.then(e=>e.files)}get toolCalls(){return this.finalStep.then(e=>e.toolCalls)}get staticToolCalls(){return this.finalStep.then(e=>e.staticToolCalls)}get dynamicToolCalls(){return this.finalStep.then(e=>e.dynamicToolCalls)}get toolResults(){return this.finalStep.then(e=>e.toolResults)}get staticToolResults(){return this.finalStep.then(e=>e.staticToolResults)}get dynamicToolResults(){return this.finalStep.then(e=>e.dynamicToolResults)}get usage(){return this.finalStep.then(e=>e.usage)}get request(){return this.finalStep.then(e=>e.request)}get response(){return this.finalStep.then(e=>e.response)}get totalUsage(){return this.consumeStream(),this._totalUsage.promise}get finishReason(){return this.consumeStream(),this._finishReason.promise}teeStream(){const[e,t]=this.baseStream.tee();return this.baseStream=t,e}get textStream(){return Wo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){e.type==="text-delta"&&t.enqueue(e.text)}})))}get fullStream(){return Wo(this.teeStream().pipeThrough(new TransformStream({transform({part:e},t){t.enqueue(e)}})))}async consumeStream(e){var t;try{await tM({stream:this.fullStream,onError:e?.onError})}catch(r){(t=e?.onError)==null||t.call(e,r)}}get experimental_partialOutputStream(){if(this.output==null)throw new MR;return Wo(this.teeStream().pipeThrough(new TransformStream({transform({partialOutput:e},t){e!=null&&t.enqueue(e)}})))}toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n=!0,sendSources:i=!1,sendStart:a=!0,sendFinish:s=!0,onError:l=sn}={}){const u=t!=null?Wz({originalMessages:e,responseMessageId:t}):void 0,c={},d=p=>{var g,h;const b=c[p];return((h=(g=this.tools)==null?void 0:g[b])==null?void 0:h.type)==="dynamic"?!0:void 0},f=this.fullStream.pipeThrough(new TransformStream({transform:async(p,g)=>{const h=o?.({part:p}),b=p.type;switch(b){case"text-start":{g.enqueue({type:"text-start",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"text-delta":{g.enqueue({type:"text-delta",id:p.id,delta:p.text,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"text-end":{g.enqueue({type:"text-end",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-start":{g.enqueue({type:"reasoning-start",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-delta":{n&&g.enqueue({type:"reasoning-delta",id:p.id,delta:p.text,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"reasoning-end":{g.enqueue({type:"reasoning-end",id:p.id,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"file":{g.enqueue({type:"file",mediaType:p.file.mediaType,url:`data:${p.file.mediaType};base64,${p.file.base64}`});break}case"source":{i&&p.sourceType==="url"&&g.enqueue({type:"source-url",sourceId:p.id,url:p.url,title:p.title,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}}),i&&p.sourceType==="document"&&g.enqueue({type:"source-document",sourceId:p.id,mediaType:p.mediaType,title:p.title,filename:p.filename,...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{}});break}case"tool-input-start":{c[p.id]=p.toolName;const y=d(p.id);g.enqueue({type:"tool-input-start",toolCallId:p.id,toolName:p.toolName,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"tool-input-delta":{g.enqueue({type:"tool-input-delta",toolCallId:p.id,inputTextDelta:p.delta});break}case"tool-call":{c[p.toolCallId]=p.toolName;const y=d(p.toolCallId);p.invalid?g.enqueue({type:"tool-input-error",toolCallId:p.toolCallId,toolName:p.toolName,input:p.input,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{},...y!=null?{dynamic:y}:{},errorText:l(p.error)}):g.enqueue({type:"tool-input-available",toolCallId:p.toolCallId,toolName:p.toolName,input:p.input,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.providerMetadata!=null?{providerMetadata:p.providerMetadata}:{},...y!=null?{dynamic:y}:{}});break}case"tool-result":{const y=d(p.toolCallId);g.enqueue({type:"tool-output-available",toolCallId:p.toolCallId,output:p.output,...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...p.preliminary!=null?{preliminary:p.preliminary}:{},...y!=null?{dynamic:y}:{}});break}case"tool-error":{const y=d(p.toolCallId);g.enqueue({type:"tool-output-error",toolCallId:p.toolCallId,errorText:l(p.error),...p.providerExecuted!=null?{providerExecuted:p.providerExecuted}:{},...y!=null?{dynamic:y}:{}});break}case"error":{g.enqueue({type:"error",errorText:l(p.error)});break}case"start-step":{g.enqueue({type:"start-step"});break}case"finish-step":{g.enqueue({type:"finish-step"});break}case"start":{a&&g.enqueue({type:"start",...h!=null?{messageMetadata:h}:{},...u!=null?{messageId:u}:{}});break}case"finish":{s&&g.enqueue({type:"finish",...h!=null?{messageMetadata:h}:{}});break}case"abort":{g.enqueue(p);break}case"tool-input-end":break;case"raw":break;default:{const y=b;throw new Error(`Unknown chunk type: ${y}`)}}h!=null&&b!=="start"&&b!=="finish"&&g.enqueue({type:"message-metadata",messageMetadata:h})}}));return Wo(Xz({stream:f,messageId:u??t?.(),originalMessages:e,onFinish:r,onError:l}))}pipeUIMessageStreamToResponse(e,{originalMessages:t,generateMessageId:r,onFinish:o,messageMetadata:n,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u,...c}={}){eM({response:e,stream:this.toUIMessageStream({originalMessages:t,generateMessageId:r,onFinish:o,messageMetadata:n,sendReasoning:i,sendSources:a,sendFinish:s,sendStart:l,onError:u}),...c})}pipeTextStreamToResponse(e,t){Bz({response:e,textStream:this.textStream,...t})}toUIMessageStreamResponse({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n,sendSources:i,sendFinish:a,sendStart:s,onError:l,...u}={}){return Jz({stream:this.toUIMessageStream({originalMessages:e,generateMessageId:t,onFinish:r,messageMetadata:o,sendReasoning:n,sendSources:i,sendFinish:a,sendStart:s,onError:l}),...u})}toTextStreamResponse(e){return Vz({textStream:this.textStream,...e})}};function lM(e,t){const r=[];t?.ignoreIncompleteToolCalls&&(e=e.map(o=>({...o,parts:o.parts.filter(n=>!Pf(n)||n.state!=="input-streaming"&&n.state!=="input-available")})));for(const o of e)switch(o.role){case"system":{const n=o.parts.filter(a=>a.type==="text"),i=n.reduce((a,s)=>s.providerMetadata!=null?{...a,...s.providerMetadata}:a,{});r.push({role:"system",content:n.map(a=>a.text).join(""),...Object.keys(i).length>0?{providerOptions:i}:{}});break}case"user":{r.push({role:"user",content:o.parts.map(n=>{var i;if(Ds(n))return{type:"text",text:n.text,...n.providerMetadata!=null?{providerOptions:n.providerMetadata}:{}};if(Us(n))return{type:"file",mediaType:n.mediaType,filename:n.filename,data:n.url,...n.providerMetadata!=null?{providerOptions:n.providerMetadata}:{}};if(Ms(n))return(i=t?.convertDataPart)==null?void 0:i.call(t,n)}).filter(n=>n!=null)});break}case"assistant":{if(o.parts!=null){let n=function(){var a,s,l;if(i.length===0)return;const u=[];for(const d of i)if(Ds(d))u.push({type:"text",text:d.text,...d.providerMetadata!=null?{providerOptions:d.providerMetadata}:{}});else if(Us(d))u.push({type:"file",mediaType:d.mediaType,filename:d.filename,data:d.url});else if(Nf(d))u.push({type:"reasoning",text:d.text,providerOptions:d.providerMetadata});else if(Hc(d)){const f=d.toolName;d.state!=="input-streaming"&&u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:f,input:d.input,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}})}else if(Fr(d)){const f=Ui(d);d.state!=="input-streaming"&&(u.push({type:"tool-call",toolCallId:d.toolCallId,toolName:f,input:d.state==="output-error"?(a=d.input)!=null?a:d.rawInput:d.input,providerExecuted:d.providerExecuted,...d.callProviderMetadata!=null?{providerOptions:d.callProviderMetadata}:{}}),d.providerExecuted===!0&&(d.state==="output-available"||d.state==="output-error")&&u.push({type:"tool-result",toolCallId:d.toolCallId,toolName:f,output:Nn({output:d.state==="output-error"?d.errorText:d.output,tool:(s=t?.tools)==null?void 0:s[f],errorMode:d.state==="output-error"?"json":"none"})}))}else if(Ms(d)){const f=(l=t?.convertDataPart)==null?void 0:l.call(t,d);f!=null&&u.push(f)}else{const f=d;throw new Error(`Unsupported part: ${f}`)}r.push({role:"assistant",content:u});const c=i.filter(d=>Fr(d)&&d.providerExecuted!==!0||d.type==="dynamic-tool");c.length>0&&r.push({role:"tool",content:c.map(d=>{var f;switch(d.state){case"output-error":case"output-available":{const p=Kz(d);return{type:"tool-result",toolCallId:d.toolCallId,toolName:p,output:Nn({output:d.state==="output-error"?d.errorText:d.output,tool:(f=t?.tools)==null?void 0:f[p],errorMode:d.state==="output-error"?"text":"none"})}}default:return null}}).filter(d=>d!=null)}),i=[]},i=[];for(const a of o.parts)Ds(a)||Nf(a)||Us(a)||Pf(a)||Ms(a)?i.push(a):a.type==="step-start"&&n();n();break}break}default:{const n=o.role;throw new XR({originalMessage:o,message:`Unsupported role: ${n}`})}}return r}No({prefix:"aiobj",size:24});No({prefix:"aiobj",size:24});var cM={};RR(cM,{object:()=>pM,text:()=>dM});var dM=()=>({type:"text",responseFormat:{type:"text"},async parsePartial({text:e}){return{partial:e}},async parseOutput({text:e}){return e}}),pM=({schema:e})=>{const t=Ha(e);return{type:"object",responseFormat:{type:"json",schema:t.jsonSchema},async parsePartial({text:r}){const o=await _$(r);switch(o.state){case"failed-parse":case"undefined-input":return;case"repaired-parse":case"successful-parse":return{partial:o.value};default:{const n=o.state;throw new Error(`Unsupported parse state: ${n}`)}}},async parseOutput({text:r},o){const n=await xr({text:r});if(!n.success)throw new Sf({message:"No object generated: could not parse the response.",cause:n.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});const i=await sr({value:n.value,schema:t});if(!i.success)throw new Sf({message:"No object generated: response did not match schema.",cause:i.error,text:r,response:o.response,usage:o.usage,finishReason:o.finishReason});return i.value}}},fM={word:/\S+\s+/m,line:/\n+/m};function mM({delayInMs:e=10,chunking:t="word",_internal:{delay:r=sx}={}}={}){let o;if(typeof t=="function")o=n=>{const i=t(n);if(i==null)return null;if(!i.length)throw new Error("Chunking function must return a non-empty string.");if(!n.startsWith(i))throw new Error(`Chunking function must return a match that is a prefix of the buffer. Received: "${i}" expected to start with "${n}"`);return i};else{const n=typeof t=="string"?fM[t]:t;if(n==null)throw new Ji({argument:"chunking",message:`Chunking must be "word" or "line" or a RegExp. Received: ${t}`});o=i=>{const a=n.exec(i);return a?i.slice(0,a.index)+a?.[0]:null}}return()=>{let n="",i="";return new TransformStream({async transform(a,s){if(a.type!=="text-delta"){n.length>0&&(s.enqueue({type:"text-delta",text:n,id:i}),n=""),s.enqueue(a);return}a.id!==i&&n.length>0&&(s.enqueue({type:"text-delta",text:n,id:i}),n=""),n+=a.text,i=a.id;let l;for(;(l=o(n))!=null;)s.enqueue({type:"text-delta",text:l,id:i}),n=n.slice(l.length),await r(e)}})}}function Go(e){return!!e&&"UNSAFE_apiKey"in e}function hM(e){return e?"sessionFn"in e:!1}const gM=({getSession:e,projectSlug:t,enabled:r})=>{const o=q_(),n=["chatSession",t],i=o.getQueryState(n),a=i?.data!==void 0,s=i?.dataUpdatedAt??0,u=a&&Date.now()-s>1/0,c=!a||u,{data:d}=B_({queryKey:n,queryFn:()=>e({projectSlug:t}),enabled:r&&c&&e!==null,staleTime:1/0,gcTime:1/0});return d??null};async function vM(e){return(await(await fetch("/chat/session",{method:"POST",headers:{"Gram-Project":e.projectSlug}})).json()).client_token}const yM=({projectSlug:e,auth:t})=>{const r=z.useMemo(()=>Go(t)?null:!Go(t)&&hM(t)?t.sessionFn:vM,[t]),o=gM({enabled:!Go(t),getSession:r,projectSlug:e});return Go(t)?{headers:{"Gram-Project":e,"Gram-Key":t.UNSAFE_apiKey},isLoading:!1}:o?{headers:{"Gram-Project":e,"Gram-Chat-Session":o},isLoading:!1}:{isLoading:!0}};function bM({children:e}){const[t,r]=z.useState(new Map),[o,n]=z.useState(new Set),i=z.useCallback((d,f,p)=>new Promise(g=>{const h={toolCallId:f,toolName:d,args:p,resolve:g};r(b=>{const y=new Map(b);return y.set(f,h),y})}),[]),a=z.useCallback(d=>{n(f=>{const p=new Set(f);return p.add(d),p})},[]),s=z.useCallback(d=>{r(f=>{const p=f.get(d);if(p){p.resolve(!0);const g=new Map(f);return g.delete(d),g}return f})},[]),l=z.useCallback(d=>{r(f=>{const p=f.get(d);if(p){p.resolve(!1);const g=new Map(f);return g.delete(d),g}return f})},[]),u=z.useCallback(d=>o.has(d),[o]),c=z.useCallback(d=>t.get(d),[t]);return m.jsx(T.ToolApprovalContext.Provider,{value:{pendingApprovals:t,approvedTools:o,requestApproval:i,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:l,isToolApproved:u,getPendingApproval:c},children:e})}const _M="You are a helpful assistant that can answer questions and help with tasks.";function wM(e,t){return`
|
|
89
|
+
${_M}
|
|
90
90
|
|
|
91
91
|
User-provided System Prompt:
|
|
92
92
|
${e??"None provided"}
|
|
93
93
|
|
|
94
94
|
Utilities:
|
|
95
95
|
${t.map(r=>`- ${r.language}: ${r.prompt}`).join(`
|
|
96
|
-
`)}`}const wM=({children:e,config:t})=>{const r=yM(t),o=gM({auth:t.api,projectSlug:t.projectSlug}),n=J_(),[i,a]=D.useState(t.model?.defaultModel??Nc[0]),[s,l]=D.useState(t.modal?.defaultExpanded??!1),[u,c]=D.useState(t.modal?.defaultOpen),d=t.plugins??T.recommended,f=_M(t.systemPrompt,d),{data:p,isLoading:g}=sN({auth:o,mcp:t.mcp,environment:t.environment??{}}),h=D.useRef({requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool});h.current={requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool};const b=D.useCallback(()=>({requestApproval:(...$)=>h.current.requestApproval(...$),isToolApproved:(...$)=>h.current.isToolApproved(...$),whitelistTool:(...$)=>h.current.whitelistTool(...$)}),[]);D.useEffect(()=>(t.tools?.toolsRequiringApproval?.length&&dN(b(),t.tools.toolsRequiringApproval),()=>{pN()}),[t.tools?.toolsRequiringApproval,b]);const y=D.useMemo(()=>({sendMessages:async({messages:$,abortSignal:v})=>{const k=!!t.languageModel;if(o.isLoading)throw new Error("Session is loading");const N=x.thread.getModelContext(),I=lN(cN(N?.tools??{})),O=k?null:ax({baseURL:r,apiKey:"unused, but must be set",headers:o.headers});t.languageModel&&console.log("Using custom language model",t.languageModel);const z={...p,...Nj(I)},F=mN(z,t.tools?.toolsRequiringApproval,b()),te=t.languageModel?t.languageModel:O.chat(i);try{return iM({system:f,model:te,messages:uM($),tools:F,stopWhen:h$(10),experimental_transform:fM({delayInMs:15}),abortSignal:v,onError:({error:J})=>{console.error("Stream error in onError callback:",J)}}).toUIMessageStream()}catch(ie){throw console.error("Error creating stream:",ie),ie}},reconnectToStream:async()=>{throw new Error("Stream reconnection not supported")}}),[t,t.languageModel,i,f,p,g,b,r,o.headers]),x=Oj({transport:y});return m.jsx(L.AssistantRuntimeProvider,{runtime:x,children:m.jsxs(T.ElementsContext.Provider,{value:{config:t,setModel:a,model:i,isExpanded:s,setIsExpanded:l,isOpen:u??!1,setIsOpen:c,plugins:d},children:[e,m.jsx($0,{tools:t.tools?.frontendTools??{}})]})})},xM=e=>{const t=new HO;return m.jsx(GO,{client:t,children:m.jsx(vM,{children:m.jsx(wM,{...e})})})};function Oe(e,t,{checkForDefaultPrevented:r=!0}={}){return function(n){if(e?.(n),r===!1||!n.defaultPrevented)return t?.(n)}}function jf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Gc(...e){return t=>{let r=!1;const o=e.map(n=>{const i=jf(n,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let n=0;n<o.length;n++){const i=o[n];typeof i=="function"?i():jf(e[n],null)}}}}function Ge(...e){return _.useCallback(Gc(...e),e)}function $M(e,t){const r=_.createContext(t),o=i=>{const{children:a,...s}=i,l=_.useMemo(()=>s,Object.values(s));return m.jsx(r.Provider,{value:l,children:a})};o.displayName=e+"Provider";function n(i){const a=_.useContext(r);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[o,n]}function Po(e,t=[]){let r=[];function o(i,a){const s=_.createContext(a),l=r.length;r=[...r,a];const u=d=>{const{scope:f,children:p,...g}=d,h=f?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return m.jsx(h.Provider,{value:b,children:p})};u.displayName=i+"Provider";function c(d,f){const p=f?.[e]?.[l]||s,g=_.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const n=()=>{const i=r.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return n.scopeName=e,[o,SM(n,...t)]}function SM(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return r.scopeName=t.scopeName,r}function Kc(e){const t=IM(e),r=_.forwardRef((o,n)=>{const{children:i,...a}=o,s=_.Children.toArray(i),l=s.find(EM);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return m.jsx(t,{...a,ref:n,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:n,children:i})});return r.displayName=`${e}.Slot`,r}function IM(e){const t=_.forwardRef((r,o)=>{const{children:n,...i}=r;if(_.isValidElement(n)){const a=OM(n),s=TM(i,n.props);return n.type!==_.Fragment&&(s.ref=o?Gc(o,a):a),_.cloneElement(n,s)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var w$=Symbol("radix.slottable");function kM(e){const t=({children:r})=>m.jsx(m.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=w$,t}function EM(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===w$}function TM(e,t){const r={...t};for(const o in t){const n=e[o],i=t[o];/^on[A-Z]/.test(o)?n&&i?r[o]=(...s)=>{const l=i(...s);return n(...s),l}:n&&(r[o]=n):o==="style"?r[o]={...n,...i}:o==="className"&&(r[o]=[n,i].filter(Boolean).join(" "))}return{...e,...r}}function OM(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var NM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=NM.reduce((e,t)=>{const r=Kc(`Primitive.${t}`),o=_.forwardRef((n,i)=>{const{asChild:a,...s}=n,l=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function PM(e,t){e&&um.flushSync(()=>e.dispatchEvent(t))}function Sr(e){const t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...r)=>t.current?.(...r),[])}function CM(e,t=globalThis?.document){const r=Sr(e);_.useEffect(()=>{const o=n=>{n.key==="Escape"&&r(n)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[r,t])}var jM="DismissableLayer",Nu="dismissableLayer.update",AM="dismissableLayer.pointerDownOutside",RM="dismissableLayer.focusOutside",Af,x$=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ga=_.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:n,onFocusOutside:i,onInteractOutside:a,onDismiss:s,...l}=e,u=_.useContext(x$),[c,d]=_.useState(null),f=c?.ownerDocument??globalThis?.document,[,p]=_.useState({}),g=Ge(t,I=>d(I)),h=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=h.indexOf(b),x=c?h.indexOf(c):-1,$=u.layersWithOutsidePointerEventsDisabled.size>0,v=x>=y,k=DM(I=>{const O=I.target,z=[...u.branches].some(F=>F.contains(O));!v||z||(n?.(I),a?.(I),I.defaultPrevented||s?.())},f),N=UM(I=>{const O=I.target;[...u.branches].some(F=>F.contains(O))||(i?.(I),a?.(I),I.defaultPrevented||s?.())},f);return CM(I=>{x===u.layers.size-1&&(o?.(I),!I.defaultPrevented&&s&&(I.preventDefault(),s()))},f),_.useEffect(()=>{if(c)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Af=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),Rf(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Af)}},[c,f,r,u]),_.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),Rf())},[c,u]),_.useEffect(()=>{const I=()=>p({});return document.addEventListener(Nu,I),()=>document.removeEventListener(Nu,I)},[]),m.jsx(Ce.div,{...l,ref:g,style:{pointerEvents:$?v?"auto":"none":void 0,...e.style},onFocusCapture:Oe(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Oe(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Oe(e.onPointerDownCapture,k.onPointerDownCapture)})});Ga.displayName=jM;var zM="DismissableLayerBranch",MM=_.forwardRef((e,t)=>{const r=_.useContext(x$),o=_.useRef(null),n=Ge(t,o);return _.useEffect(()=>{const i=o.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),m.jsx(Ce.div,{...e,ref:n})});MM.displayName=zM;function DM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1),n=_.useRef(()=>{});return _.useEffect(()=>{const i=s=>{if(s.target&&!o.current){let l=function(){$$(AM,r,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",n.current),n.current=l,t.addEventListener("click",n.current,{once:!0})):l()}else t.removeEventListener("click",n.current);o.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",n.current)}},[t,r]),{onPointerDownCapture:()=>o.current=!0}}function UM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1);return _.useEffect(()=>{const n=i=>{i.target&&!o.current&&$$(RM,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",n),()=>t.removeEventListener("focusin",n)},[t,r]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Rf(){const e=new CustomEvent(Nu);document.dispatchEvent(e)}function $$(e,t,r,{discrete:o}){const n=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),o?PM(n,i):n.dispatchEvent(i)}var lt=globalThis?.document?_.useLayoutEffect:()=>{},LM=_[" useId ".trim().toString()]||(()=>{}),ZM=0;function qr(e){const[t,r]=_.useState(LM());return lt(()=>{r(o=>o??String(ZM++))},[e]),t?`radix-${t}`:""}const FM=["top","right","bottom","left"],ur=Math.min,Ye=Math.max,Ui=Math.round,Go=Math.floor,At=e=>({x:e,y:e}),qM={left:"right",right:"left",bottom:"top",top:"bottom"},VM={start:"end",end:"start"};function Pu(e,t,r){return Ye(e,ur(t,r))}function Bt(e,t){return typeof e=="function"?e(t):e}function Jt(e){return e.split("-")[0]}function dn(e){return e.split("-")[1]}function Yc(e){return e==="x"?"y":"x"}function Qc(e){return e==="y"?"height":"width"}const BM=new Set(["top","bottom"]);function jt(e){return BM.has(Jt(e))?"y":"x"}function Xc(e){return Yc(jt(e))}function JM(e,t,r){r===void 0&&(r=!1);const o=dn(e),n=Xc(e),i=Qc(n);let a=n==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Li(a)),[a,Li(a)]}function WM(e){const t=Li(e);return[Cu(e),t,Cu(t)]}function Cu(e){return e.replace(/start|end/g,t=>VM[t])}const zf=["left","right"],Mf=["right","left"],HM=["top","bottom"],GM=["bottom","top"];function KM(e,t,r){switch(e){case"top":case"bottom":return r?t?Mf:zf:t?zf:Mf;case"left":case"right":return t?HM:GM;default:return[]}}function YM(e,t,r,o){const n=dn(e);let i=KM(Jt(e),r==="start",o);return n&&(i=i.map(a=>a+"-"+n),t&&(i=i.concat(i.map(Cu)))),i}function Li(e){return e.replace(/left|right|bottom|top/g,t=>qM[t])}function QM(e){return{top:0,right:0,bottom:0,left:0,...e}}function S$(e){return typeof e!="number"?QM(e):{top:e,right:e,bottom:e,left:e}}function Zi(e){const{x:t,y:r,width:o,height:n}=e;return{width:o,height:n,top:r,left:t,right:t+o,bottom:r+n,x:t,y:r}}function Df(e,t,r){let{reference:o,floating:n}=e;const i=jt(t),a=Xc(t),s=Qc(a),l=Jt(t),u=i==="y",c=o.x+o.width/2-n.width/2,d=o.y+o.height/2-n.height/2,f=o[s]/2-n[s]/2;let p;switch(l){case"top":p={x:c,y:o.y-n.height};break;case"bottom":p={x:c,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-n.width,y:d};break;default:p={x:o.x,y:o.y}}switch(dn(t)){case"start":p[a]-=f*(r&&u?-1:1);break;case"end":p[a]+=f*(r&&u?-1:1);break}return p}const XM=async(e,t,r)=>{const{placement:o="bottom",strategy:n="absolute",middleware:i=[],platform:a}=r,s=i.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:n}),{x:c,y:d}=Df(u,o,l),f=o,p={},g=0;for(let h=0;h<s.length;h++){const{name:b,fn:y}=s[h],{x,y:$,data:v,reset:k}=await y({x:c,y:d,initialPlacement:o,placement:f,strategy:n,middlewareData:p,rects:u,platform:a,elements:{reference:e,floating:t}});c=x??c,d=$??d,p={...p,[b]:{...p[b],...v}},k&&g<=50&&(g++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(u=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:n}):k.rects),{x:c,y:d}=Df(u,f,l)),h=-1)}return{x:c,y:d,placement:f,strategy:n,middlewareData:p}};async function Kn(e,t){var r;t===void 0&&(t={});const{x:o,y:n,platform:i,rects:a,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Bt(t,e),g=S$(p),b=s[f?d==="floating"?"reference":"floating":d],y=Zi(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(b)))==null||r?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),x=d==="floating"?{x:o,y:n,width:a.floating.width,height:a.floating.height}:a.reference,$=await(i.getOffsetParent==null?void 0:i.getOffsetParent(s.floating)),v=await(i.isElement==null?void 0:i.isElement($))?await(i.getScale==null?void 0:i.getScale($))||{x:1,y:1}:{x:1,y:1},k=Zi(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:x,offsetParent:$,strategy:l}):x);return{top:(y.top-k.top+g.top)/v.y,bottom:(k.bottom-y.bottom+g.bottom)/v.y,left:(y.left-k.left+g.left)/v.x,right:(k.right-y.right+g.right)/v.x}}const e4=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:o,placement:n,rects:i,platform:a,elements:s,middlewareData:l}=t,{element:u,padding:c=0}=Bt(e,t)||{};if(u==null)return{};const d=S$(c),f={x:r,y:o},p=Xc(n),g=Qc(p),h=await a.getDimensions(u),b=p==="y",y=b?"top":"left",x=b?"bottom":"right",$=b?"clientHeight":"clientWidth",v=i.reference[g]+i.reference[p]-f[p]-i.floating[g],k=f[p]-i.reference[p],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=N?N[$]:0;(!I||!await(a.isElement==null?void 0:a.isElement(N)))&&(I=s.floating[$]||i.floating[g]);const O=v/2-k/2,z=I/2-h[g]/2-1,F=ur(d[y],z),te=ur(d[x],z),ie=F,J=I-h[g]-te,V=I/2-h[g]/2+O,we=Pu(ie,V,J),oe=!l.arrow&&dn(n)!=null&&V!==we&&i.reference[g]/2-(V<ie?F:te)-h[g]/2<0,de=oe?V<ie?V-ie:V-J:0;return{[p]:f[p]+de,data:{[p]:we,centerOffset:V-we-de,...oe&&{alignmentOffset:de}},reset:oe}}}),t4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,o;const{placement:n,middlewareData:i,rects:a,initialPlacement:s,platform:l,elements:u}=t,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=Bt(e,t);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const y=Jt(n),x=jt(s),$=Jt(s)===s,v=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=f||($||!h?[Li(s)]:WM(s)),N=g!=="none";!f&&N&&k.push(...YM(s,h,g,v));const I=[s,...k],O=await Kn(t,b),z=[];let F=((o=i.flip)==null?void 0:o.overflows)||[];if(c&&z.push(O[y]),d){const V=JM(n,a,v);z.push(O[V[0]],O[V[1]])}if(F=[...F,{placement:n,overflows:z}],!z.every(V=>V<=0)){var te,ie;const V=(((te=i.flip)==null?void 0:te.index)||0)+1,we=I[V];if(we&&(!(d==="alignment"?x!==jt(we):!1)||F.every(K=>jt(K.placement)===x?K.overflows[0]>0:!0)))return{data:{index:V,overflows:F},reset:{placement:we}};let oe=(ie=F.filter(de=>de.overflows[0]<=0).sort((de,K)=>de.overflows[1]-K.overflows[1])[0])==null?void 0:ie.placement;if(!oe)switch(p){case"bestFit":{var J;const de=(J=F.filter(K=>{if(N){const fe=jt(K.placement);return fe===x||fe==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(fe=>fe>0).reduce((fe,B)=>fe+B,0)]).sort((K,fe)=>K[1]-fe[1])[0])==null?void 0:J[0];de&&(oe=de);break}case"initialPlacement":oe=s;break}if(n!==oe)return{reset:{placement:oe}}}return{}}}};function Uf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Lf(e){return FM.some(t=>e[t]>=0)}const r4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:o="referenceHidden",...n}=Bt(e,t);switch(o){case"referenceHidden":{const i=await Kn(t,{...n,elementContext:"reference"}),a=Uf(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Lf(a)}}}case"escaped":{const i=await Kn(t,{...n,altBoundary:!0}),a=Uf(i,r.floating);return{data:{escapedOffsets:a,escaped:Lf(a)}}}default:return{}}}}},I$=new Set(["left","top"]);async function n4(e,t){const{placement:r,platform:o,elements:n}=e,i=await(o.isRTL==null?void 0:o.isRTL(n.floating)),a=Jt(r),s=dn(r),l=jt(r)==="y",u=I$.has(a)?-1:1,c=i&&l?-1:1,d=Bt(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof g=="number"&&(p=s==="end"?g*-1:g),l?{x:p*c,y:f*u}:{x:f*u,y:p*c}}const o4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,o;const{x:n,y:i,placement:a,middlewareData:s}=t,l=await n4(t,e);return a===((r=s.offset)==null?void 0:r.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:n+l.x,y:i+l.y,data:{...l,placement:a}}}}},i4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:o,placement:n}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:s={fn:b=>{let{x:y,y:x}=b;return{x:y,y:x}}},...l}=Bt(e,t),u={x:r,y:o},c=await Kn(t,l),d=jt(Jt(n)),f=Yc(d);let p=u[f],g=u[d];if(i){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",x=p+c[b],$=p-c[y];p=Pu(x,p,$)}if(a){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",x=g+c[b],$=g-c[y];g=Pu(x,g,$)}const h=s.fn({...t,[f]:p,[d]:g});return{...h,data:{x:h.x-r,y:h.y-o,enabled:{[f]:i,[d]:a}}}}}},a4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:o,placement:n,rects:i,middlewareData:a}=t,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=Bt(e,t),c={x:r,y:o},d=jt(n),f=Yc(d);let p=c[f],g=c[d];const h=Bt(s,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(l){const $=f==="y"?"height":"width",v=i.reference[f]-i.floating[$]+b.mainAxis,k=i.reference[f]+i.reference[$]-b.mainAxis;p<v?p=v:p>k&&(p=k)}if(u){var y,x;const $=f==="y"?"width":"height",v=I$.has(Jt(n)),k=i.reference[d]-i.floating[$]+(v&&((y=a.offset)==null?void 0:y[d])||0)+(v?0:b.crossAxis),N=i.reference[d]+i.reference[$]+(v?0:((x=a.offset)==null?void 0:x[d])||0)-(v?b.crossAxis:0);g<k?g=k:g>N&&(g=N)}return{[f]:p,[d]:g}}}},s4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,o;const{placement:n,rects:i,platform:a,elements:s}=t,{apply:l=()=>{},...u}=Bt(e,t),c=await Kn(t,u),d=Jt(n),f=dn(n),p=jt(n)==="y",{width:g,height:h}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=f===(await(a.isRTL==null?void 0:a.isRTL(s.floating))?"start":"end")?"left":"right"):(y=d,b=f==="end"?"top":"bottom");const x=h-c.top-c.bottom,$=g-c.left-c.right,v=ur(h-c[b],x),k=ur(g-c[y],$),N=!t.middlewareData.shift;let I=v,O=k;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(O=$),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(I=x),N&&!f){const F=Ye(c.left,0),te=Ye(c.right,0),ie=Ye(c.top,0),J=Ye(c.bottom,0);p?O=g-2*(F!==0||te!==0?F+te:Ye(c.left,c.right)):I=h-2*(ie!==0||J!==0?ie+J:Ye(c.top,c.bottom))}await l({...t,availableWidth:O,availableHeight:I});const z=await a.getDimensions(s.floating);return g!==z.width||h!==z.height?{reset:{rects:!0}}:{}}}};function Ka(){return typeof window<"u"}function pn(e){return k$(e)?(e.nodeName||"").toLowerCase():"#document"}function Qe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Dt(e){var t;return(t=(k$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function k$(e){return Ka()?e instanceof Node||e instanceof Qe(e).Node:!1}function St(e){return Ka()?e instanceof Element||e instanceof Qe(e).Element:!1}function zt(e){return Ka()?e instanceof HTMLElement||e instanceof Qe(e).HTMLElement:!1}function Zf(e){return!Ka()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qe(e).ShadowRoot}const u4=new Set(["inline","contents"]);function Co(e){const{overflow:t,overflowX:r,overflowY:o,display:n}=It(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+r)&&!u4.has(n)}const l4=new Set(["table","td","th"]);function c4(e){return l4.has(pn(e))}const d4=[":popover-open",":modal"];function Ya(e){return d4.some(t=>{try{return e.matches(t)}catch{return!1}})}const p4=["transform","translate","scale","rotate","perspective"],f4=["transform","translate","scale","rotate","perspective","filter"],m4=["paint","layout","strict","content"];function ed(e){const t=td(),r=St(e)?It(e):e;return p4.some(o=>r[o]?r[o]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||f4.some(o=>(r.willChange||"").includes(o))||m4.some(o=>(r.contain||"").includes(o))}function h4(e){let t=lr(e);for(;zt(t)&&!nn(t);){if(ed(t))return t;if(Ya(t))return null;t=lr(t)}return null}function td(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const g4=new Set(["html","body","#document"]);function nn(e){return g4.has(pn(e))}function It(e){return Qe(e).getComputedStyle(e)}function Qa(e){return St(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lr(e){if(pn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Zf(e)&&e.host||Dt(e);return Zf(t)?t.host:t}function E$(e){const t=lr(e);return nn(t)?e.ownerDocument?e.ownerDocument.body:e.body:zt(t)&&Co(t)?t:E$(t)}function Yn(e,t,r){var o;t===void 0&&(t=[]),r===void 0&&(r=!0);const n=E$(e),i=n===((o=e.ownerDocument)==null?void 0:o.body),a=Qe(n);if(i){const s=ju(a);return t.concat(a,a.visualViewport||[],Co(n)?n:[],s&&r?Yn(s):[])}return t.concat(n,Yn(n,[],r))}function ju(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function T$(e){const t=It(e);let r=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const n=zt(e),i=n?e.offsetWidth:r,a=n?e.offsetHeight:o,s=Ui(r)!==i||Ui(o)!==a;return s&&(r=i,o=a),{width:r,height:o,$:s}}function rd(e){return St(e)?e:e.contextElement}function Vr(e){const t=rd(e);if(!zt(t))return At(1);const r=t.getBoundingClientRect(),{width:o,height:n,$:i}=T$(t);let a=(i?Ui(r.width):r.width)/o,s=(i?Ui(r.height):r.height)/n;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const v4=At(0);function O$(e){const t=Qe(e);return!td()||!t.visualViewport?v4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function y4(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Qe(e)?!1:t}function Ir(e,t,r,o){t===void 0&&(t=!1),r===void 0&&(r=!1);const n=e.getBoundingClientRect(),i=rd(e);let a=At(1);t&&(o?St(o)&&(a=Vr(o)):a=Vr(e));const s=y4(i,r,o)?O$(i):At(0);let l=(n.left+s.x)/a.x,u=(n.top+s.y)/a.y,c=n.width/a.x,d=n.height/a.y;if(i){const f=Qe(i),p=o&&St(o)?Qe(o):o;let g=f,h=ju(g);for(;h&&o&&p!==g;){const b=Vr(h),y=h.getBoundingClientRect(),x=It(h),$=y.left+(h.clientLeft+parseFloat(x.paddingLeft))*b.x,v=y.top+(h.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,u*=b.y,c*=b.x,d*=b.y,l+=$,u+=v,g=Qe(h),h=ju(g)}}return Zi({width:c,height:d,x:l,y:u})}function nd(e,t){const r=Qa(e).scrollLeft;return t?t.left+r:Ir(Dt(e)).left+r}function N$(e,t,r){r===void 0&&(r=!1);const o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-(r?0:nd(e,o)),i=o.top+t.scrollTop;return{x:n,y:i}}function b4(e){let{elements:t,rect:r,offsetParent:o,strategy:n}=e;const i=n==="fixed",a=Dt(o),s=t?Ya(t.floating):!1;if(o===a||s&&i)return r;let l={scrollLeft:0,scrollTop:0},u=At(1);const c=At(0),d=zt(o);if((d||!d&&!i)&&((pn(o)!=="body"||Co(a))&&(l=Qa(o)),zt(o))){const p=Ir(o);u=Vr(o),c.x=p.x+o.clientLeft,c.y=p.y+o.clientTop}const f=a&&!d&&!i?N$(a,l,!0):At(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:r.y*u.y-l.scrollTop*u.y+c.y+f.y}}function _4(e){return Array.from(e.getClientRects())}function w4(e){const t=Dt(e),r=Qa(e),o=e.ownerDocument.body,n=Ye(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),i=Ye(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let a=-r.scrollLeft+nd(e);const s=-r.scrollTop;return It(o).direction==="rtl"&&(a+=Ye(t.clientWidth,o.clientWidth)-n),{width:n,height:i,x:a,y:s}}function x4(e,t){const r=Qe(e),o=Dt(e),n=r.visualViewport;let i=o.clientWidth,a=o.clientHeight,s=0,l=0;if(n){i=n.width,a=n.height;const u=td();(!u||u&&t==="fixed")&&(s=n.offsetLeft,l=n.offsetTop)}return{width:i,height:a,x:s,y:l}}const $4=new Set(["absolute","fixed"]);function S4(e,t){const r=Ir(e,!0,t==="fixed"),o=r.top+e.clientTop,n=r.left+e.clientLeft,i=zt(e)?Vr(e):At(1),a=e.clientWidth*i.x,s=e.clientHeight*i.y,l=n*i.x,u=o*i.y;return{width:a,height:s,x:l,y:u}}function Ff(e,t,r){let o;if(t==="viewport")o=x4(e,r);else if(t==="document")o=w4(Dt(e));else if(St(t))o=S4(t,r);else{const n=O$(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Zi(o)}function P$(e,t){const r=lr(e);return r===t||!St(r)||nn(r)?!1:It(r).position==="fixed"||P$(r,t)}function I4(e,t){const r=t.get(e);if(r)return r;let o=Yn(e,[],!1).filter(s=>St(s)&&pn(s)!=="body"),n=null;const i=It(e).position==="fixed";let a=i?lr(e):e;for(;St(a)&&!nn(a);){const s=It(a),l=ed(a);!l&&s.position==="fixed"&&(n=null),(i?!l&&!n:!l&&s.position==="static"&&!!n&&$4.has(n.position)||Co(a)&&!l&&P$(e,a))?o=o.filter(c=>c!==a):n=s,a=lr(a)}return t.set(e,o),o}function k4(e){let{element:t,boundary:r,rootBoundary:o,strategy:n}=e;const a=[...r==="clippingAncestors"?Ya(t)?[]:I4(t,this._c):[].concat(r),o],s=a[0],l=a.reduce((u,c)=>{const d=Ff(t,c,n);return u.top=Ye(d.top,u.top),u.right=ur(d.right,u.right),u.bottom=ur(d.bottom,u.bottom),u.left=Ye(d.left,u.left),u},Ff(t,s,n));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function E4(e){const{width:t,height:r}=T$(e);return{width:t,height:r}}function T4(e,t,r){const o=zt(t),n=Dt(t),i=r==="fixed",a=Ir(e,!0,i,t);let s={scrollLeft:0,scrollTop:0};const l=At(0);function u(){l.x=nd(n)}if(o||!o&&!i)if((pn(t)!=="body"||Co(n))&&(s=Qa(t)),o){const p=Ir(t,!0,i,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else n&&u();i&&!o&&n&&u();const c=n&&!o&&!i?N$(n,s):At(0),d=a.left+s.scrollLeft-l.x-c.x,f=a.top+s.scrollTop-l.y-c.y;return{x:d,y:f,width:a.width,height:a.height}}function Ls(e){return It(e).position==="static"}function qf(e,t){if(!zt(e)||It(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Dt(e)===r&&(r=r.ownerDocument.body),r}function C$(e,t){const r=Qe(e);if(Ya(e))return r;if(!zt(e)){let n=lr(e);for(;n&&!nn(n);){if(St(n)&&!Ls(n))return n;n=lr(n)}return r}let o=qf(e,t);for(;o&&c4(o)&&Ls(o);)o=qf(o,t);return o&&nn(o)&&Ls(o)&&!ed(o)?r:o||h4(e)||r}const O4=async function(e){const t=this.getOffsetParent||C$,r=this.getDimensions,o=await r(e.floating);return{reference:T4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function N4(e){return It(e).direction==="rtl"}const P4={convertOffsetParentRelativeRectToViewportRelativeRect:b4,getDocumentElement:Dt,getClippingRect:k4,getOffsetParent:C$,getElementRects:O4,getClientRects:_4,getDimensions:E4,getScale:Vr,isElement:St,isRTL:N4};function j$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function C4(e,t){let r=null,o;const n=Dt(e);function i(){var s;clearTimeout(o),(s=r)==null||s.disconnect(),r=null}function a(s,l){s===void 0&&(s=!1),l===void 0&&(l=1),i();const u=e.getBoundingClientRect(),{left:c,top:d,width:f,height:p}=u;if(s||t(),!f||!p)return;const g=Go(d),h=Go(n.clientWidth-(c+f)),b=Go(n.clientHeight-(d+p)),y=Go(c),$={rootMargin:-g+"px "+-h+"px "+-b+"px "+-y+"px",threshold:Ye(0,ur(1,l))||1};let v=!0;function k(N){const I=N[0].intersectionRatio;if(I!==l){if(!v)return a();I?a(!1,I):o=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!j$(u,e.getBoundingClientRect())&&a(),v=!1}try{r=new IntersectionObserver(k,{...$,root:n.ownerDocument})}catch{r=new IntersectionObserver(k,$)}r.observe(e)}return a(!0),i}function j4(e,t,r,o){o===void 0&&(o={});const{ancestorScroll:n=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,u=rd(e),c=n||i?[...u?Yn(u):[],...Yn(t)]:[];c.forEach(y=>{n&&y.addEventListener("scroll",r,{passive:!0}),i&&y.addEventListener("resize",r)});const d=u&&s?C4(u,r):null;let f=-1,p=null;a&&(p=new ResizeObserver(y=>{let[x]=y;x&&x.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var $;($=p)==null||$.observe(t)})),r()}),u&&!l&&p.observe(u),p.observe(t));let g,h=l?Ir(e):null;l&&b();function b(){const y=Ir(e);h&&!j$(h,y)&&r(),h=y,g=requestAnimationFrame(b)}return r(),()=>{var y;c.forEach(x=>{n&&x.removeEventListener("scroll",r),i&&x.removeEventListener("resize",r)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const A4=o4,R4=i4,z4=t4,M4=s4,D4=r4,Vf=e4,U4=a4,L4=(e,t,r)=>{const o=new Map,n={platform:P4,...r},i={...n.platform,_c:o};return XM(e,t,{...n,platform:i})};var Z4=typeof document<"u",F4=function(){},ai=Z4?D.useLayoutEffect:F4;function Fi(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,o,n;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(o=r;o--!==0;)if(!Fi(e[o],t[o]))return!1;return!0}if(n=Object.keys(e),r=n.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(t,n[o]))return!1;for(o=r;o--!==0;){const i=n[o];if(!(i==="_owner"&&e.$$typeof)&&!Fi(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function A$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bf(e,t){const r=A$(e);return Math.round(t*r)/r}function Zs(e){const t=_.useRef(e);return ai(()=>{t.current=e}),t}function q4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:o=[],platform:n,elements:{reference:i,floating:a}={},transform:s=!0,whileElementsMounted:l,open:u}=e,[c,d]=_.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=_.useState(o);Fi(f,o)||p(o);const[g,h]=_.useState(null),[b,y]=_.useState(null),x=_.useCallback(K=>{K!==N.current&&(N.current=K,h(K))},[]),$=_.useCallback(K=>{K!==I.current&&(I.current=K,y(K))},[]),v=i||g,k=a||b,N=_.useRef(null),I=_.useRef(null),O=_.useRef(c),z=l!=null,F=Zs(l),te=Zs(n),ie=Zs(u),J=_.useCallback(()=>{if(!N.current||!I.current)return;const K={placement:t,strategy:r,middleware:f};te.current&&(K.platform=te.current),L4(N.current,I.current,K).then(fe=>{const B={...fe,isPositioned:ie.current!==!1};V.current&&!Fi(O.current,B)&&(O.current=B,um.flushSync(()=>{d(B)}))})},[f,t,r,te,ie]);ai(()=>{u===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(K=>({...K,isPositioned:!1})))},[u]);const V=_.useRef(!1);ai(()=>(V.current=!0,()=>{V.current=!1}),[]),ai(()=>{if(v&&(N.current=v),k&&(I.current=k),v&&k){if(F.current)return F.current(v,k,J);J()}},[v,k,J,F,z]);const we=_.useMemo(()=>({reference:N,floating:I,setReference:x,setFloating:$}),[x,$]),oe=_.useMemo(()=>({reference:v,floating:k}),[v,k]),de=_.useMemo(()=>{const K={position:r,left:0,top:0};if(!oe.floating)return K;const fe=Bf(oe.floating,c.x),B=Bf(oe.floating,c.y);return s?{...K,transform:"translate("+fe+"px, "+B+"px)",...A$(oe.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:fe,top:B}},[r,s,oe.floating,c.x,c.y]);return _.useMemo(()=>({...c,update:J,refs:we,elements:oe,floatingStyles:de}),[c,J,we,oe,de])}const V4=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:o,padding:n}=typeof e=="function"?e(r):e;return o&&t(o)?o.current!=null?Vf({element:o.current,padding:n}).fn(r):{}:o?Vf({element:o,padding:n}).fn(r):{}}}},B4=(e,t)=>({...A4(e),options:[e,t]}),J4=(e,t)=>({...R4(e),options:[e,t]}),W4=(e,t)=>({...U4(e),options:[e,t]}),H4=(e,t)=>({...z4(e),options:[e,t]}),G4=(e,t)=>({...M4(e),options:[e,t]}),K4=(e,t)=>({...D4(e),options:[e,t]}),Y4=(e,t)=>({...V4(e),options:[e,t]});var Q4="Arrow",R$=_.forwardRef((e,t)=>{const{children:r,width:o=10,height:n=5,...i}=e;return m.jsx(Ce.svg,{...i,ref:t,width:o,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});R$.displayName=Q4;var X4=R$;function eD(e){const[t,r]=_.useState(void 0);return lt(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(n=>{if(!Array.isArray(n)||!n.length)return;const i=n[0];let a,s;if("borderBoxSize"in i){const l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;a=u.inlineSize,s=u.blockSize}else a=e.offsetWidth,s=e.offsetHeight;r({width:a,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else r(void 0)},[e]),t}var od="Popper",[z$,Xa]=Po(od),[tD,M$]=z$(od),D$=e=>{const{__scopePopper:t,children:r}=e,[o,n]=_.useState(null);return m.jsx(tD,{scope:t,anchor:o,onAnchorChange:n,children:r})};D$.displayName=od;var U$="PopperAnchor",L$=_.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:o,...n}=e,i=M$(U$,r),a=_.useRef(null),s=Ge(t,a),l=_.useRef(null);return _.useEffect(()=>{const u=l.current;l.current=o?.current||a.current,u!==l.current&&i.onAnchorChange(l.current)}),o?null:m.jsx(Ce.div,{...n,ref:s})});L$.displayName=U$;var id="PopperContent",[rD,nD]=z$(id),Z$=_.forwardRef((e,t)=>{const{__scopePopper:r,side:o="bottom",sideOffset:n=0,align:i="center",alignOffset:a=0,arrowPadding:s=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:g,...h}=e,b=M$(id,r),[y,x]=_.useState(null),$=Ge(t,xe=>x(xe)),[v,k]=_.useState(null),N=eD(v),I=N?.width??0,O=N?.height??0,z=o+(i!=="center"?"-"+i:""),F=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},te=Array.isArray(u)?u:[u],ie=te.length>0,J={padding:F,boundary:te.filter(iD),altBoundary:ie},{refs:V,floatingStyles:we,placement:oe,isPositioned:de,middlewareData:K}=q4({strategy:"fixed",placement:z,whileElementsMounted:(...xe)=>j4(...xe,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[B4({mainAxis:n+O,alignmentAxis:a}),l&&J4({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?W4():void 0,...J}),l&&H4({...J}),G4({...J,apply:({elements:xe,rects:Ro,availableWidth:us,availableHeight:fn})=>{const{width:pt,height:zo}=Ro.reference,je=xe.floating.style;je.setProperty("--radix-popper-available-width",`${us}px`),je.setProperty("--radix-popper-available-height",`${fn}px`),je.setProperty("--radix-popper-anchor-width",`${pt}px`),je.setProperty("--radix-popper-anchor-height",`${zo}px`)}}),v&&Y4({element:v,padding:s}),aD({arrowWidth:I,arrowHeight:O}),f&&K4({strategy:"referenceHidden",...J})]}),[fe,B]=V$(oe),Ue=Sr(g);lt(()=>{de&&Ue?.()},[de,Ue]);const ye=K.arrow?.x,Le=K.arrow?.y,U=K.arrow?.centerOffset!==0,[Q,me]=_.useState();return lt(()=>{y&&me(window.getComputedStyle(y).zIndex)},[y]),m.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...we,transform:de?we.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[K.transformOrigin?.x,K.transformOrigin?.y].join(" "),...K.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(rD,{scope:r,placedSide:fe,onArrowChange:k,arrowX:ye,arrowY:Le,shouldHideArrow:U,children:m.jsx(Ce.div,{"data-side":fe,"data-align":B,...h,ref:$,style:{...h.style,animation:de?void 0:"none"}})})})});Z$.displayName=id;var F$="PopperArrow",oD={top:"bottom",right:"left",bottom:"top",left:"right"},q$=_.forwardRef(function(t,r){const{__scopePopper:o,...n}=t,i=nD(F$,o),a=oD[i.placedSide];return m.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:m.jsx(X4,{...n,ref:r,style:{...n.style,display:"block"}})})});q$.displayName=F$;function iD(e){return e!==null}var aD=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:o,middlewareData:n}=t,a=n.arrow?.centerOffset!==0,s=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[u,c]=V$(r),d={start:"0%",center:"50%",end:"100%"}[c],f=(n.arrow?.x??0)+s/2,p=(n.arrow?.y??0)+l/2;let g="",h="";return u==="bottom"?(g=a?d:`${f}px`,h=`${-l}px`):u==="top"?(g=a?d:`${f}px`,h=`${o.floating.height+l}px`):u==="right"?(g=`${-l}px`,h=a?d:`${p}px`):u==="left"&&(g=`${o.floating.width+l}px`,h=a?d:`${p}px`),{data:{x:g,y:h}}}});function V$(e){const[t,r="center"]=e.split("-");return[t,r]}var B$=D$,ad=L$,J$=Z$,W$=q$,sD="Portal",es=_.forwardRef((e,t)=>{const{container:r,...o}=e,[n,i]=_.useState(!1);lt(()=>i(!0),[]);const a=r||n&&globalThis?.document?.body;return a?sm.createPortal(m.jsx(Ce.div,{...o,ref:t}),a):null});es.displayName=sD;function uD(e,t){return _.useReducer((r,o)=>t[r][o]??r,e)}var Gt=e=>{const{present:t,children:r}=e,o=lD(t),n=typeof r=="function"?r({present:o.isPresent}):_.Children.only(r),i=Ge(o.ref,cD(n));return typeof r=="function"||o.isPresent?_.cloneElement(n,{ref:i}):null};Gt.displayName="Presence";function lD(e){const[t,r]=_.useState(),o=_.useRef(null),n=_.useRef(e),i=_.useRef("none"),a=e?"mounted":"unmounted",[s,l]=uD(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return _.useEffect(()=>{const u=Ko(o.current);i.current=s==="mounted"?u:"none"},[s]),lt(()=>{const u=o.current,c=n.current;if(c!==e){const f=i.current,p=Ko(u);e?l("MOUNT"):p==="none"||u?.display==="none"?l("UNMOUNT"):l(c&&f!==p?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,l]),lt(()=>{if(t){let u;const c=t.ownerDocument.defaultView??window,d=p=>{const h=Ko(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&h&&(l("ANIMATION_END"),!n.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",u=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=p=>{p.target===t&&(i.current=Ko(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(u),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:_.useCallback(u=>{o.current=u?getComputedStyle(u):null,r(u)},[])}}function Ko(e){return e?.animationName||"none"}function cD(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var dD=_[" useInsertionEffect ".trim().toString()]||lt;function ts({prop:e,defaultProp:t,onChange:r=()=>{},caller:o}){const[n,i,a]=pD({defaultProp:t,onChange:r}),s=e!==void 0,l=s?e:n;{const c=_.useRef(e!==void 0);_.useEffect(()=>{const d=c.current;d!==s&&console.warn(`${o} is changing from ${d?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=s},[s,o])}const u=_.useCallback(c=>{if(s){const d=fD(c)?c(e):c;d!==e&&a.current?.(d)}else i(c)},[s,e,i,a]);return[l,u]}function pD({defaultProp:e,onChange:t}){const[r,o]=_.useState(e),n=_.useRef(r),i=_.useRef(t);return dD(()=>{i.current=t},[t]),_.useEffect(()=>{n.current!==r&&(i.current?.(r),n.current=r)},[r,n]),[r,o,i]}function fD(e){return typeof e=="function"}var mD=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),hD="VisuallyHidden",H$=_.forwardRef((e,t)=>m.jsx(Ce.span,{...e,ref:t,style:{...mD,...e.style}}));H$.displayName=hD;var gD=H$,[rs]=Po("Tooltip",[Xa]),ns=Xa(),G$="TooltipProvider",vD=700,Au="tooltip.open",[yD,sd]=rs(G$),K$=e=>{const{__scopeTooltip:t,delayDuration:r=vD,skipDelayDuration:o=300,disableHoverableContent:n=!1,children:i}=e,a=_.useRef(!0),s=_.useRef(!1),l=_.useRef(0);return _.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),m.jsx(yD,{scope:t,isOpenDelayedRef:a,delayDuration:r,onOpen:_.useCallback(()=>{window.clearTimeout(l.current),a.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.current=!0,o)},[o]),isPointerInTransitRef:s,onPointerInTransitChange:_.useCallback(u=>{s.current=u},[]),disableHoverableContent:n,children:i})};K$.displayName=G$;var Qn="Tooltip",[bD,jo]=rs(Qn),Y$=e=>{const{__scopeTooltip:t,children:r,open:o,defaultOpen:n,onOpenChange:i,disableHoverableContent:a,delayDuration:s}=e,l=sd(Qn,e.__scopeTooltip),u=ns(t),[c,d]=_.useState(null),f=qr(),p=_.useRef(0),g=a??l.disableHoverableContent,h=s??l.delayDuration,b=_.useRef(!1),[y,x]=ts({prop:o,defaultProp:n??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(Au))):l.onClose(),i?.(I)},caller:Qn}),$=_.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),v=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,x(!0)},[x]),k=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),N=_.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,x(!0),p.current=0},h)},[h,x]);return _.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),m.jsx(B$,{...u,children:m.jsx(bD,{scope:t,contentId:f,open:y,stateAttribute:$,trigger:c,onTriggerChange:d,onTriggerEnter:_.useCallback(()=>{l.isOpenDelayedRef.current?N():v()},[l.isOpenDelayedRef,N,v]),onTriggerLeave:_.useCallback(()=>{g?k():(window.clearTimeout(p.current),p.current=0)},[k,g]),onOpen:v,onClose:k,disableHoverableContent:g,children:r})})};Y$.displayName=Qn;var Ru="TooltipTrigger",Q$=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=jo(Ru,r),i=sd(Ru,r),a=ns(r),s=_.useRef(null),l=Ge(t,s,n.onTriggerChange),u=_.useRef(!1),c=_.useRef(!1),d=_.useCallback(()=>u.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),m.jsx(ad,{asChild:!0,...a,children:m.jsx(Ce.button,{"aria-describedby":n.open?n.contentId:void 0,"data-state":n.stateAttribute,...o,ref:l,onPointerMove:Oe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!c.current&&!i.isPointerInTransitRef.current&&(n.onTriggerEnter(),c.current=!0)}),onPointerLeave:Oe(e.onPointerLeave,()=>{n.onTriggerLeave(),c.current=!1}),onPointerDown:Oe(e.onPointerDown,()=>{n.open&&n.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Oe(e.onFocus,()=>{u.current||n.onOpen()}),onBlur:Oe(e.onBlur,n.onClose),onClick:Oe(e.onClick,n.onClose)})})});Q$.displayName=Ru;var ud="TooltipPortal",[_D,wD]=rs(ud,{forceMount:void 0}),X$=e=>{const{__scopeTooltip:t,forceMount:r,children:o,container:n}=e,i=jo(ud,t);return m.jsx(_D,{scope:t,forceMount:r,children:m.jsx(Gt,{present:r||i.open,children:m.jsx(es,{asChild:!0,container:n,children:o})})})};X$.displayName=ud;var on="TooltipContent",eS=_.forwardRef((e,t)=>{const r=wD(on,e.__scopeTooltip),{forceMount:o=r.forceMount,side:n="top",...i}=e,a=jo(on,e.__scopeTooltip);return m.jsx(Gt,{present:o||a.open,children:a.disableHoverableContent?m.jsx(tS,{side:n,...i,ref:t}):m.jsx(xD,{side:n,...i,ref:t})})}),xD=_.forwardRef((e,t)=>{const r=jo(on,e.__scopeTooltip),o=sd(on,e.__scopeTooltip),n=_.useRef(null),i=Ge(t,n),[a,s]=_.useState(null),{trigger:l,onClose:u}=r,c=n.current,{onPointerInTransitChange:d}=o,f=_.useCallback(()=>{s(null),d(!1)},[d]),p=_.useCallback((g,h)=>{const b=g.currentTarget,y={x:g.clientX,y:g.clientY},x=kD(y,b.getBoundingClientRect()),$=ED(y,x),v=TD(h.getBoundingClientRect()),k=ND([...$,...v]);s(k),d(!0)},[d]);return _.useEffect(()=>()=>f(),[f]),_.useEffect(()=>{if(l&&c){const g=b=>p(b,c),h=b=>p(b,l);return l.addEventListener("pointerleave",g),c.addEventListener("pointerleave",h),()=>{l.removeEventListener("pointerleave",g),c.removeEventListener("pointerleave",h)}}},[l,c,p,f]),_.useEffect(()=>{if(a){const g=h=>{const b=h.target,y={x:h.clientX,y:h.clientY},x=l?.contains(b)||c?.contains(b),$=!OD(y,a);x?f():$&&(f(),u())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[l,c,a,u,f]),m.jsx(tS,{...e,ref:i})}),[$D,SD]=rs(Qn,{isInside:!1}),ID=kM("TooltipContent"),tS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,children:o,"aria-label":n,onEscapeKeyDown:i,onPointerDownOutside:a,...s}=e,l=jo(on,r),u=ns(r),{onClose:c}=l;return _.useEffect(()=>(document.addEventListener(Au,c),()=>document.removeEventListener(Au,c)),[c]),_.useEffect(()=>{if(l.trigger){const d=f=>{f.target?.contains(l.trigger)&&c()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,c]),m.jsx(Ga,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:d=>d.preventDefault(),onDismiss:c,children:m.jsxs(J$,{"data-state":l.stateAttribute,...u,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(ID,{children:o}),m.jsx($D,{scope:r,isInside:!0,children:m.jsx(gD,{id:l.contentId,role:"tooltip",children:n||o})})]})})});eS.displayName=on;var rS="TooltipArrow",nS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=ns(r);return SD(rS,r).isInside?null:m.jsx(W$,{...n,...o,ref:t})});nS.displayName=rS;function kD(e,t){const r=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),n=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(r,o,n,i)){case i:return"left";case n:return"right";case r:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function ED(e,t,r=5){const o=[];switch(t){case"top":o.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":o.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":o.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":o.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return o}function TD(e){const{top:t,right:r,bottom:o,left:n}=e;return[{x:n,y:t},{x:r,y:t},{x:r,y:o},{x:n,y:o}]}function OD(e,t){const{x:r,y:o}=e;let n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],u=s.x,c=s.y,d=l.x,f=l.y;c>o!=f>o&&r<(d-u)*(o-c)/(f-c)+u&&(n=!n)}return n}function ND(e){const t=e.slice();return t.sort((r,o)=>r.x<o.x?-1:r.x>o.x?1:r.y<o.y?-1:r.y>o.y?1:0),PD(t)}function PD(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const n=e[o];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))t.pop();else break}t.push(n)}t.pop();const r=[];for(let o=e.length-1;o>=0;o--){const n=e[o];for(;r.length>=2;){const i=r[r.length-1],a=r[r.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))r.pop();else break}r.push(n)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var CD=K$,jD=Y$,AD=Q$,RD=X$,zD=eS,MD=nS;function oS({delayDuration:e=0,...t}){return m.jsx(CD,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ld({...e}){return m.jsx(oS,{children:m.jsx(jD,{"data-slot":"tooltip",...e})})}function cd({...e}){return m.jsx(AD,{"data-slot":"tooltip-trigger",...e})}function dd({className:e,sideOffset:t=0,children:r,...o}){return m.jsx(RD,{children:m.jsxs(zD,{"data-slot":"tooltip-content",sideOffset:t,className:T.cn("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...o,children:[r,m.jsx(MD,{className:"bg-foreground fill-foreground z-20 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]"})]})})}var Fs="focusScope.autoFocusOnMount",qs="focusScope.autoFocusOnUnmount",Jf={bubbles:!1,cancelable:!0},DD="FocusScope",pd=_.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:n,onUnmountAutoFocus:i,...a}=e,[s,l]=_.useState(null),u=Sr(n),c=Sr(i),d=_.useRef(null),f=Ge(t,h=>l(h)),p=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(o){let h=function($){if(p.paused||!s)return;const v=$.target;s.contains(v)?d.current=v:Qt(d.current,{select:!0})},b=function($){if(p.paused||!s)return;const v=$.relatedTarget;v!==null&&(s.contains(v)||Qt(d.current,{select:!0}))},y=function($){if(document.activeElement===document.body)for(const k of $)k.removedNodes.length>0&&Qt(s)};document.addEventListener("focusin",h),document.addEventListener("focusout",b);const x=new MutationObserver(y);return s&&x.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",b),x.disconnect()}}},[o,s,p.paused]),_.useEffect(()=>{if(s){Hf.add(p);const h=document.activeElement;if(!s.contains(h)){const y=new CustomEvent(Fs,Jf);s.addEventListener(Fs,u),s.dispatchEvent(y),y.defaultPrevented||(UD(VD(iS(s)),{select:!0}),document.activeElement===h&&Qt(s))}return()=>{s.removeEventListener(Fs,u),setTimeout(()=>{const y=new CustomEvent(qs,Jf);s.addEventListener(qs,c),s.dispatchEvent(y),y.defaultPrevented||Qt(h??document.body,{select:!0}),s.removeEventListener(qs,c),Hf.remove(p)},0)}}},[s,u,c,p]);const g=_.useCallback(h=>{if(!r&&!o||p.paused)return;const b=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,y=document.activeElement;if(b&&y){const x=h.currentTarget,[$,v]=LD(x);$&&v?!h.shiftKey&&y===v?(h.preventDefault(),r&&Qt($,{select:!0})):h.shiftKey&&y===$&&(h.preventDefault(),r&&Qt(v,{select:!0})):y===x&&h.preventDefault()}},[r,o,p.paused]);return m.jsx(Ce.div,{tabIndex:-1,...a,ref:f,onKeyDown:g})});pd.displayName=DD;function UD(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(Qt(o,{select:t}),document.activeElement!==r)return}function LD(e){const t=iS(e),r=Wf(t,e),o=Wf(t.reverse(),e);return[r,o]}function iS(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const n=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||n?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function Wf(e,t){for(const r of e)if(!ZD(r,{upTo:t}))return r}function ZD(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function FD(e){return e instanceof HTMLInputElement&&"select"in e}function Qt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&FD(e)&&t&&e.select()}}var Hf=qD();function qD(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Gf(e,t),e.unshift(t)},remove(t){e=Gf(e,t),e[0]?.resume()}}}function Gf(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}function VD(e){return e.filter(t=>t.tagName!=="A")}var Vs=0;function aS(){_.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Kf()),document.body.insertAdjacentElement("beforeend",e[1]??Kf()),Vs++,()=>{Vs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Vs--}},[])}function Kf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Pt=function(){return Pt=Object.assign||function(t){for(var r,o=1,n=arguments.length;o<n;o++){r=arguments[o];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Pt.apply(this,arguments)};function sS(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}function BD(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}var si="right-scroll-bar-position",ui="width-before-scroll-bar",JD="with-scroll-bars-hidden",WD="--removed-body-scroll-bar-size";function Bs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function HD(e,t){var r=D.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(o){var n=r.value;n!==o&&(r.value=o,r.callback(o,n))}}}})[0];return r.callback=t,r.facade}var GD=typeof window<"u"?_.useLayoutEffect:_.useEffect,Yf=new WeakMap;function KD(e,t){var r=HD(null,function(o){return e.forEach(function(n){return Bs(n,o)})});return GD(function(){var o=Yf.get(r);if(o){var n=new Set(o),i=new Set(e),a=r.current;n.forEach(function(s){i.has(s)||Bs(s,null)}),i.forEach(function(s){n.has(s)||Bs(s,a)})}Yf.set(r,e)},[e]),r}function YD(e){return e}function QD(e,t){t===void 0&&(t=YD);var r=[],o=!1,n={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(i){var a=t(i,o);return r.push(a),function(){r=r.filter(function(s){return s!==a})}},assignSyncMedium:function(i){for(o=!0;r.length;){var a=r;r=[],a.forEach(i)}r={push:function(s){return i(s)},filter:function(){return r}}},assignMedium:function(i){o=!0;var a=[];if(r.length){var s=r;r=[],s.forEach(i),a=r}var l=function(){var c=a;a=[],c.forEach(i)},u=function(){return Promise.resolve().then(l)};u(),r={push:function(c){a.push(c),u()},filter:function(c){return a=a.filter(c),r}}}};return n}function XD(e){e===void 0&&(e={});var t=QD(null);return t.options=Pt({async:!0,ssr:!1},e),t}var uS=function(e){var t=e.sideCar,r=sS(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return _.createElement(o,Pt({},r))};uS.isSideCarExport=!0;function eU(e,t){return e.useMedium(t),uS}var lS=XD(),Js=function(){},os=_.forwardRef(function(e,t){var r=_.useRef(null),o=_.useState({onScrollCapture:Js,onWheelCapture:Js,onTouchMoveCapture:Js}),n=o[0],i=o[1],a=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,c=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,g=e.noIsolation,h=e.inert,b=e.allowPinchZoom,y=e.as,x=y===void 0?"div":y,$=e.gapMode,v=sS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,N=KD([r,t]),I=Pt(Pt({},v),n);return _.createElement(_.Fragment,null,c&&_.createElement(k,{sideCar:lS,removeScrollBar:u,shards:d,noRelative:p,noIsolation:g,inert:h,setCallbacks:i,allowPinchZoom:!!b,lockRef:r,gapMode:$}),a?_.cloneElement(_.Children.only(s),Pt(Pt({},I),{ref:N})):_.createElement(x,Pt({},I,{className:l,ref:N}),s))});os.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};os.classNames={fullWidth:ui,zeroRight:si};var tU=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function rU(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=tU();return t&&e.setAttribute("nonce",t),e}function nU(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function oU(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var iU=function(){var e=0,t=null;return{add:function(r){e==0&&(t=rU())&&(nU(t,r),oU(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},aU=function(){var e=iU();return function(t,r){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},cS=function(){var e=aU(),t=function(r){var o=r.styles,n=r.dynamic;return e(o,n),null};return t},sU={left:0,top:0,right:0,gap:0},Ws=function(e){return parseInt(e||"",10)||0},uU=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],n=t[e==="padding"?"paddingRight":"marginRight"];return[Ws(r),Ws(o),Ws(n)]},lU=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return sU;var t=uU(e),r=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-r+t[2]-t[0])}},cU=cS(),Br="data-scroll-locked",dU=function(e,t,r,o){var n=e.left,i=e.top,a=e.right,s=e.gap;return r===void 0&&(r="margin"),`
|
|
97
|
-
.`.concat(
|
|
96
|
+
`)}`}function xM(e){return e.map(t=>{const r=t.parts;if(!Array.isArray(r))return t;const o=r.map(n=>{const{callProviderMetadata:i,...a}=n;return a});return{...t,parts:o}})}const $M=({children:e,config:t})=>{const r=lN(t),o=yM({auth:t.api,projectSlug:t.projectSlug}),n=J_(),[i,a]=z.useState(t.model?.defaultModel??Nc[0]),[s,l]=z.useState(t.modal?.defaultExpanded??!1),[u,c]=z.useState(t.modal?.defaultOpen),d=t.plugins??T.recommended,f=wM(t.systemPrompt,d),{data:p,isLoading:g}=sN({auth:o,mcp:t.mcp,environment:t.environment??{}}),h=z.useRef({requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool});h.current={requestApproval:n.requestApproval,isToolApproved:n.isToolApproved,whitelistTool:n.whitelistTool};const b=z.useCallback(()=>({requestApproval:(...$)=>h.current.requestApproval(...$),isToolApproved:(...$)=>h.current.isToolApproved(...$),whitelistTool:(...$)=>h.current.whitelistTool(...$)}),[]);z.useEffect(()=>(t.tools?.toolsRequiringApproval?.length&&pN(b(),t.tools.toolsRequiringApproval),()=>{fN()}),[t.tools?.toolsRequiringApproval,b]);const y=z.useMemo(()=>({sendMessages:async({messages:$,abortSignal:v})=>{const k=!!t.languageModel;if(o.isLoading)throw new Error("Session is loading");const N=x.thread.getModelContext(),I=cN(dN(N?.tools??{})),O=k?null:ax({baseURL:r,apiKey:"unused, but must be set",headers:o.headers});t.languageModel&&console.log("Using custom language model",t.languageModel);const M={...p,...Pj(I)},F=hN(M,t.tools?.toolsRequiringApproval,b()),te=t.languageModel?t.languageModel:O.chat(i);try{const oe=xM($),J=lM(oe);return aM({system:f,model:te,messages:J,tools:F,stopWhen:h$(10),experimental_transform:mM({delayInMs:15}),abortSignal:v,onError:({error:ye})=>{console.error("Stream error in onError callback:",ye)}}).toUIMessageStream()}catch(oe){throw console.error("Error creating stream:",oe),oe}},reconnectToStream:async()=>{throw new Error("Stream reconnection not supported")}}),[t,t.languageModel,i,f,p,g,b,r,o.headers]),x=Nj({transport:y});return m.jsx(L.AssistantRuntimeProvider,{runtime:x,children:m.jsxs(T.ElementsContext.Provider,{value:{config:t,setModel:a,model:i,isExpanded:s,setIsExpanded:l,isOpen:u??!1,setIsOpen:c,plugins:d},children:[e,m.jsx($0,{tools:t.tools?.frontendTools??{}})]})})},SM=e=>{const t=new HO;return m.jsx(GO,{client:t,children:m.jsx(bM,{children:m.jsx($M,{...e})})})};function Oe(e,t,{checkForDefaultPrevented:r=!0}={}){return function(n){if(e?.(n),r===!1||!n.defaultPrevented)return t?.(n)}}function jf(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Gc(...e){return t=>{let r=!1;const o=e.map(n=>{const i=jf(n,t);return!r&&typeof i=="function"&&(r=!0),i});if(r)return()=>{for(let n=0;n<o.length;n++){const i=o[n];typeof i=="function"?i():jf(e[n],null)}}}}function Ge(...e){return _.useCallback(Gc(...e),e)}function IM(e,t){const r=_.createContext(t),o=i=>{const{children:a,...s}=i,l=_.useMemo(()=>s,Object.values(s));return m.jsx(r.Provider,{value:l,children:a})};o.displayName=e+"Provider";function n(i){const a=_.useContext(r);if(a)return a;if(t!==void 0)return t;throw new Error(`\`${i}\` must be used within \`${e}\``)}return[o,n]}function Po(e,t=[]){let r=[];function o(i,a){const s=_.createContext(a),l=r.length;r=[...r,a];const u=d=>{const{scope:f,children:p,...g}=d,h=f?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return m.jsx(h.Provider,{value:b,children:p})};u.displayName=i+"Provider";function c(d,f){const p=f?.[e]?.[l]||s,g=_.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const n=()=>{const i=r.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return n.scopeName=e,[o,kM(n,...t)]}function kM(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return r.scopeName=t.scopeName,r}function Kc(e){const t=EM(e),r=_.forwardRef((o,n)=>{const{children:i,...a}=o,s=_.Children.toArray(i),l=s.find(OM);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return m.jsx(t,{...a,ref:n,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:n,children:i})});return r.displayName=`${e}.Slot`,r}function EM(e){const t=_.forwardRef((r,o)=>{const{children:n,...i}=r;if(_.isValidElement(n)){const a=PM(n),s=NM(i,n.props);return n.type!==_.Fragment&&(s.ref=o?Gc(o,a):a),_.cloneElement(n,s)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var w$=Symbol("radix.slottable");function TM(e){const t=({children:r})=>m.jsx(m.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=w$,t}function OM(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===w$}function NM(e,t){const r={...t};for(const o in t){const n=e[o],i=t[o];/^on[A-Z]/.test(o)?n&&i?r[o]=(...s)=>{const l=i(...s);return n(...s),l}:n&&(r[o]=n):o==="style"?r[o]={...n,...i}:o==="className"&&(r[o]=[n,i].filter(Boolean).join(" "))}return{...e,...r}}function PM(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var CM=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Ce=CM.reduce((e,t)=>{const r=Kc(`Primitive.${t}`),o=_.forwardRef((n,i)=>{const{asChild:a,...s}=n,l=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function jM(e,t){e&&um.flushSync(()=>e.dispatchEvent(t))}function Sr(e){const t=_.useRef(e);return _.useEffect(()=>{t.current=e}),_.useMemo(()=>(...r)=>t.current?.(...r),[])}function AM(e,t=globalThis?.document){const r=Sr(e);_.useEffect(()=>{const o=n=>{n.key==="Escape"&&r(n)};return t.addEventListener("keydown",o,{capture:!0}),()=>t.removeEventListener("keydown",o,{capture:!0})},[r,t])}var RM="DismissableLayer",Nu="dismissableLayer.update",zM="dismissableLayer.pointerDownOutside",MM="dismissableLayer.focusOutside",Af,x$=_.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ka=_.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:n,onFocusOutside:i,onInteractOutside:a,onDismiss:s,...l}=e,u=_.useContext(x$),[c,d]=_.useState(null),f=c?.ownerDocument??globalThis?.document,[,p]=_.useState({}),g=Ge(t,I=>d(I)),h=Array.from(u.layers),[b]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=h.indexOf(b),x=c?h.indexOf(c):-1,$=u.layersWithOutsidePointerEventsDisabled.size>0,v=x>=y,k=LM(I=>{const O=I.target,M=[...u.branches].some(F=>F.contains(O));!v||M||(n?.(I),a?.(I),I.defaultPrevented||s?.())},f),N=ZM(I=>{const O=I.target;[...u.branches].some(F=>F.contains(O))||(i?.(I),a?.(I),I.defaultPrevented||s?.())},f);return AM(I=>{x===u.layers.size-1&&(o?.(I),!I.defaultPrevented&&s&&(I.preventDefault(),s()))},f),_.useEffect(()=>{if(c)return r&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(Af=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(c)),u.layers.add(c),Rf(),()=>{r&&u.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=Af)}},[c,f,r,u]),_.useEffect(()=>()=>{c&&(u.layers.delete(c),u.layersWithOutsidePointerEventsDisabled.delete(c),Rf())},[c,u]),_.useEffect(()=>{const I=()=>p({});return document.addEventListener(Nu,I),()=>document.removeEventListener(Nu,I)},[]),m.jsx(Ce.div,{...l,ref:g,style:{pointerEvents:$?v?"auto":"none":void 0,...e.style},onFocusCapture:Oe(e.onFocusCapture,N.onFocusCapture),onBlurCapture:Oe(e.onBlurCapture,N.onBlurCapture),onPointerDownCapture:Oe(e.onPointerDownCapture,k.onPointerDownCapture)})});Ka.displayName=RM;var DM="DismissableLayerBranch",UM=_.forwardRef((e,t)=>{const r=_.useContext(x$),o=_.useRef(null),n=Ge(t,o);return _.useEffect(()=>{const i=o.current;if(i)return r.branches.add(i),()=>{r.branches.delete(i)}},[r.branches]),m.jsx(Ce.div,{...e,ref:n})});UM.displayName=DM;function LM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1),n=_.useRef(()=>{});return _.useEffect(()=>{const i=s=>{if(s.target&&!o.current){let l=function(){$$(zM,r,u,{discrete:!0})};const u={originalEvent:s};s.pointerType==="touch"?(t.removeEventListener("click",n.current),n.current=l,t.addEventListener("click",n.current,{once:!0})):l()}else t.removeEventListener("click",n.current);o.current=!1},a=window.setTimeout(()=>{t.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(a),t.removeEventListener("pointerdown",i),t.removeEventListener("click",n.current)}},[t,r]),{onPointerDownCapture:()=>o.current=!0}}function ZM(e,t=globalThis?.document){const r=Sr(e),o=_.useRef(!1);return _.useEffect(()=>{const n=i=>{i.target&&!o.current&&$$(MM,r,{originalEvent:i},{discrete:!1})};return t.addEventListener("focusin",n),()=>t.removeEventListener("focusin",n)},[t,r]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Rf(){const e=new CustomEvent(Nu);document.dispatchEvent(e)}function $$(e,t,r,{discrete:o}){const n=r.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&n.addEventListener(e,t,{once:!0}),o?jM(n,i):n.dispatchEvent(i)}var lt=globalThis?.document?_.useLayoutEffect:()=>{},FM=_[" useId ".trim().toString()]||(()=>{}),qM=0;function qr(e){const[t,r]=_.useState(FM());return lt(()=>{r(o=>o??String(qM++))},[e]),t?`radix-${t}`:""}const VM=["top","right","bottom","left"],ur=Math.min,Ye=Math.max,Li=Math.round,Ko=Math.floor,At=e=>({x:e,y:e}),BM={left:"right",right:"left",bottom:"top",top:"bottom"},JM={start:"end",end:"start"};function Pu(e,t,r){return Ye(e,ur(t,r))}function Bt(e,t){return typeof e=="function"?e(t):e}function Jt(e){return e.split("-")[0]}function dn(e){return e.split("-")[1]}function Yc(e){return e==="x"?"y":"x"}function Qc(e){return e==="y"?"height":"width"}const WM=new Set(["top","bottom"]);function jt(e){return WM.has(Jt(e))?"y":"x"}function Xc(e){return Yc(jt(e))}function HM(e,t,r){r===void 0&&(r=!1);const o=dn(e),n=Xc(e),i=Qc(n);let a=n==="x"?o===(r?"end":"start")?"right":"left":o==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=Zi(a)),[a,Zi(a)]}function GM(e){const t=Zi(e);return[Cu(e),t,Cu(t)]}function Cu(e){return e.replace(/start|end/g,t=>JM[t])}const zf=["left","right"],Mf=["right","left"],KM=["top","bottom"],YM=["bottom","top"];function QM(e,t,r){switch(e){case"top":case"bottom":return r?t?Mf:zf:t?zf:Mf;case"left":case"right":return t?KM:YM;default:return[]}}function XM(e,t,r,o){const n=dn(e);let i=QM(Jt(e),r==="start",o);return n&&(i=i.map(a=>a+"-"+n),t&&(i=i.concat(i.map(Cu)))),i}function Zi(e){return e.replace(/left|right|bottom|top/g,t=>BM[t])}function e4(e){return{top:0,right:0,bottom:0,left:0,...e}}function S$(e){return typeof e!="number"?e4(e):{top:e,right:e,bottom:e,left:e}}function Fi(e){const{x:t,y:r,width:o,height:n}=e;return{width:o,height:n,top:r,left:t,right:t+o,bottom:r+n,x:t,y:r}}function Df(e,t,r){let{reference:o,floating:n}=e;const i=jt(t),a=Xc(t),s=Qc(a),l=Jt(t),u=i==="y",c=o.x+o.width/2-n.width/2,d=o.y+o.height/2-n.height/2,f=o[s]/2-n[s]/2;let p;switch(l){case"top":p={x:c,y:o.y-n.height};break;case"bottom":p={x:c,y:o.y+o.height};break;case"right":p={x:o.x+o.width,y:d};break;case"left":p={x:o.x-n.width,y:d};break;default:p={x:o.x,y:o.y}}switch(dn(t)){case"start":p[a]-=f*(r&&u?-1:1);break;case"end":p[a]+=f*(r&&u?-1:1);break}return p}const t4=async(e,t,r)=>{const{placement:o="bottom",strategy:n="absolute",middleware:i=[],platform:a}=r,s=i.filter(Boolean),l=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:n}),{x:c,y:d}=Df(u,o,l),f=o,p={},g=0;for(let h=0;h<s.length;h++){const{name:b,fn:y}=s[h],{x,y:$,data:v,reset:k}=await y({x:c,y:d,initialPlacement:o,placement:f,strategy:n,middlewareData:p,rects:u,platform:a,elements:{reference:e,floating:t}});c=x??c,d=$??d,p={...p,[b]:{...p[b],...v}},k&&g<=50&&(g++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(u=k.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:n}):k.rects),{x:c,y:d}=Df(u,f,l)),h=-1)}return{x:c,y:d,placement:f,strategy:n,middlewareData:p}};async function Kn(e,t){var r;t===void 0&&(t={});const{x:o,y:n,platform:i,rects:a,elements:s,strategy:l}=e,{boundary:u="clippingAncestors",rootBoundary:c="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=Bt(t,e),g=S$(p),b=s[f?d==="floating"?"reference":"floating":d],y=Fi(await i.getClippingRect({element:(r=await(i.isElement==null?void 0:i.isElement(b)))==null||r?b:b.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(s.floating)),boundary:u,rootBoundary:c,strategy:l})),x=d==="floating"?{x:o,y:n,width:a.floating.width,height:a.floating.height}:a.reference,$=await(i.getOffsetParent==null?void 0:i.getOffsetParent(s.floating)),v=await(i.isElement==null?void 0:i.isElement($))?await(i.getScale==null?void 0:i.getScale($))||{x:1,y:1}:{x:1,y:1},k=Fi(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:s,rect:x,offsetParent:$,strategy:l}):x);return{top:(y.top-k.top+g.top)/v.y,bottom:(k.bottom-y.bottom+g.bottom)/v.y,left:(y.left-k.left+g.left)/v.x,right:(k.right-y.right+g.right)/v.x}}const r4=e=>({name:"arrow",options:e,async fn(t){const{x:r,y:o,placement:n,rects:i,platform:a,elements:s,middlewareData:l}=t,{element:u,padding:c=0}=Bt(e,t)||{};if(u==null)return{};const d=S$(c),f={x:r,y:o},p=Xc(n),g=Qc(p),h=await a.getDimensions(u),b=p==="y",y=b?"top":"left",x=b?"bottom":"right",$=b?"clientHeight":"clientWidth",v=i.reference[g]+i.reference[p]-f[p]-i.floating[g],k=f[p]-i.reference[p],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=N?N[$]:0;(!I||!await(a.isElement==null?void 0:a.isElement(N)))&&(I=s.floating[$]||i.floating[g]);const O=v/2-k/2,M=I/2-h[g]/2-1,F=ur(d[y],M),te=ur(d[x],M),oe=F,J=I-h[g]-te,V=I/2-h[g]/2+O,ye=Pu(oe,V,J),ie=!l.arrow&&dn(n)!=null&&V!==ye&&i.reference[g]/2-(V<oe?F:te)-h[g]/2<0,de=ie?V<oe?V-oe:V-J:0;return{[p]:f[p]+de,data:{[p]:ye,centerOffset:V-ye-de,...ie&&{alignmentOffset:de}},reset:ie}}}),n4=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var r,o;const{placement:n,middlewareData:i,rects:a,initialPlacement:s,platform:l,elements:u}=t,{mainAxis:c=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:h=!0,...b}=Bt(e,t);if((r=i.arrow)!=null&&r.alignmentOffset)return{};const y=Jt(n),x=jt(s),$=Jt(s)===s,v=await(l.isRTL==null?void 0:l.isRTL(u.floating)),k=f||($||!h?[Zi(s)]:GM(s)),N=g!=="none";!f&&N&&k.push(...XM(s,h,g,v));const I=[s,...k],O=await Kn(t,b),M=[];let F=((o=i.flip)==null?void 0:o.overflows)||[];if(c&&M.push(O[y]),d){const V=HM(n,a,v);M.push(O[V[0]],O[V[1]])}if(F=[...F,{placement:n,overflows:M}],!M.every(V=>V<=0)){var te,oe;const V=(((te=i.flip)==null?void 0:te.index)||0)+1,ye=I[V];if(ye&&(!(d==="alignment"?x!==jt(ye):!1)||F.every(K=>jt(K.placement)===x?K.overflows[0]>0:!0)))return{data:{index:V,overflows:F},reset:{placement:ye}};let ie=(oe=F.filter(de=>de.overflows[0]<=0).sort((de,K)=>de.overflows[1]-K.overflows[1])[0])==null?void 0:oe.placement;if(!ie)switch(p){case"bestFit":{var J;const de=(J=F.filter(K=>{if(N){const fe=jt(K.placement);return fe===x||fe==="y"}return!0}).map(K=>[K.placement,K.overflows.filter(fe=>fe>0).reduce((fe,B)=>fe+B,0)]).sort((K,fe)=>K[1]-fe[1])[0])==null?void 0:J[0];de&&(ie=de);break}case"initialPlacement":ie=s;break}if(n!==ie)return{reset:{placement:ie}}}return{}}}};function Uf(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Lf(e){return VM.some(t=>e[t]>=0)}const o4=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:r}=t,{strategy:o="referenceHidden",...n}=Bt(e,t);switch(o){case"referenceHidden":{const i=await Kn(t,{...n,elementContext:"reference"}),a=Uf(i,r.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:Lf(a)}}}case"escaped":{const i=await Kn(t,{...n,altBoundary:!0}),a=Uf(i,r.floating);return{data:{escapedOffsets:a,escaped:Lf(a)}}}default:return{}}}}},I$=new Set(["left","top"]);async function i4(e,t){const{placement:r,platform:o,elements:n}=e,i=await(o.isRTL==null?void 0:o.isRTL(n.floating)),a=Jt(r),s=dn(r),l=jt(r)==="y",u=I$.has(a)?-1:1,c=i&&l?-1:1,d=Bt(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:g}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof g=="number"&&(p=s==="end"?g*-1:g),l?{x:p*c,y:f*u}:{x:f*u,y:p*c}}const a4=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var r,o;const{x:n,y:i,placement:a,middlewareData:s}=t,l=await i4(t,e);return a===((r=s.offset)==null?void 0:r.placement)&&(o=s.arrow)!=null&&o.alignmentOffset?{}:{x:n+l.x,y:i+l.y,data:{...l,placement:a}}}}},s4=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:r,y:o,placement:n}=t,{mainAxis:i=!0,crossAxis:a=!1,limiter:s={fn:b=>{let{x:y,y:x}=b;return{x:y,y:x}}},...l}=Bt(e,t),u={x:r,y:o},c=await Kn(t,l),d=jt(Jt(n)),f=Yc(d);let p=u[f],g=u[d];if(i){const b=f==="y"?"top":"left",y=f==="y"?"bottom":"right",x=p+c[b],$=p-c[y];p=Pu(x,p,$)}if(a){const b=d==="y"?"top":"left",y=d==="y"?"bottom":"right",x=g+c[b],$=g-c[y];g=Pu(x,g,$)}const h=s.fn({...t,[f]:p,[d]:g});return{...h,data:{x:h.x-r,y:h.y-o,enabled:{[f]:i,[d]:a}}}}}},u4=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:r,y:o,placement:n,rects:i,middlewareData:a}=t,{offset:s=0,mainAxis:l=!0,crossAxis:u=!0}=Bt(e,t),c={x:r,y:o},d=jt(n),f=Yc(d);let p=c[f],g=c[d];const h=Bt(s,t),b=typeof h=="number"?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(l){const $=f==="y"?"height":"width",v=i.reference[f]-i.floating[$]+b.mainAxis,k=i.reference[f]+i.reference[$]-b.mainAxis;p<v?p=v:p>k&&(p=k)}if(u){var y,x;const $=f==="y"?"width":"height",v=I$.has(Jt(n)),k=i.reference[d]-i.floating[$]+(v&&((y=a.offset)==null?void 0:y[d])||0)+(v?0:b.crossAxis),N=i.reference[d]+i.reference[$]+(v?0:((x=a.offset)==null?void 0:x[d])||0)-(v?b.crossAxis:0);g<k?g=k:g>N&&(g=N)}return{[f]:p,[d]:g}}}},l4=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var r,o;const{placement:n,rects:i,platform:a,elements:s}=t,{apply:l=()=>{},...u}=Bt(e,t),c=await Kn(t,u),d=Jt(n),f=dn(n),p=jt(n)==="y",{width:g,height:h}=i.floating;let b,y;d==="top"||d==="bottom"?(b=d,y=f===(await(a.isRTL==null?void 0:a.isRTL(s.floating))?"start":"end")?"left":"right"):(y=d,b=f==="end"?"top":"bottom");const x=h-c.top-c.bottom,$=g-c.left-c.right,v=ur(h-c[b],x),k=ur(g-c[y],$),N=!t.middlewareData.shift;let I=v,O=k;if((r=t.middlewareData.shift)!=null&&r.enabled.x&&(O=$),(o=t.middlewareData.shift)!=null&&o.enabled.y&&(I=x),N&&!f){const F=Ye(c.left,0),te=Ye(c.right,0),oe=Ye(c.top,0),J=Ye(c.bottom,0);p?O=g-2*(F!==0||te!==0?F+te:Ye(c.left,c.right)):I=h-2*(oe!==0||J!==0?oe+J:Ye(c.top,c.bottom))}await l({...t,availableWidth:O,availableHeight:I});const M=await a.getDimensions(s.floating);return g!==M.width||h!==M.height?{reset:{rects:!0}}:{}}}};function Ya(){return typeof window<"u"}function pn(e){return k$(e)?(e.nodeName||"").toLowerCase():"#document"}function Qe(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Dt(e){var t;return(t=(k$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function k$(e){return Ya()?e instanceof Node||e instanceof Qe(e).Node:!1}function St(e){return Ya()?e instanceof Element||e instanceof Qe(e).Element:!1}function zt(e){return Ya()?e instanceof HTMLElement||e instanceof Qe(e).HTMLElement:!1}function Zf(e){return!Ya()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Qe(e).ShadowRoot}const c4=new Set(["inline","contents"]);function Co(e){const{overflow:t,overflowX:r,overflowY:o,display:n}=It(e);return/auto|scroll|overlay|hidden|clip/.test(t+o+r)&&!c4.has(n)}const d4=new Set(["table","td","th"]);function p4(e){return d4.has(pn(e))}const f4=[":popover-open",":modal"];function Qa(e){return f4.some(t=>{try{return e.matches(t)}catch{return!1}})}const m4=["transform","translate","scale","rotate","perspective"],h4=["transform","translate","scale","rotate","perspective","filter"],g4=["paint","layout","strict","content"];function ed(e){const t=td(),r=St(e)?It(e):e;return m4.some(o=>r[o]?r[o]!=="none":!1)||(r.containerType?r.containerType!=="normal":!1)||!t&&(r.backdropFilter?r.backdropFilter!=="none":!1)||!t&&(r.filter?r.filter!=="none":!1)||h4.some(o=>(r.willChange||"").includes(o))||g4.some(o=>(r.contain||"").includes(o))}function v4(e){let t=lr(e);for(;zt(t)&&!nn(t);){if(ed(t))return t;if(Qa(t))return null;t=lr(t)}return null}function td(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const y4=new Set(["html","body","#document"]);function nn(e){return y4.has(pn(e))}function It(e){return Qe(e).getComputedStyle(e)}function Xa(e){return St(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function lr(e){if(pn(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Zf(e)&&e.host||Dt(e);return Zf(t)?t.host:t}function E$(e){const t=lr(e);return nn(t)?e.ownerDocument?e.ownerDocument.body:e.body:zt(t)&&Co(t)?t:E$(t)}function Yn(e,t,r){var o;t===void 0&&(t=[]),r===void 0&&(r=!0);const n=E$(e),i=n===((o=e.ownerDocument)==null?void 0:o.body),a=Qe(n);if(i){const s=ju(a);return t.concat(a,a.visualViewport||[],Co(n)?n:[],s&&r?Yn(s):[])}return t.concat(n,Yn(n,[],r))}function ju(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function T$(e){const t=It(e);let r=parseFloat(t.width)||0,o=parseFloat(t.height)||0;const n=zt(e),i=n?e.offsetWidth:r,a=n?e.offsetHeight:o,s=Li(r)!==i||Li(o)!==a;return s&&(r=i,o=a),{width:r,height:o,$:s}}function rd(e){return St(e)?e:e.contextElement}function Vr(e){const t=rd(e);if(!zt(t))return At(1);const r=t.getBoundingClientRect(),{width:o,height:n,$:i}=T$(t);let a=(i?Li(r.width):r.width)/o,s=(i?Li(r.height):r.height)/n;return(!a||!Number.isFinite(a))&&(a=1),(!s||!Number.isFinite(s))&&(s=1),{x:a,y:s}}const b4=At(0);function O$(e){const t=Qe(e);return!td()||!t.visualViewport?b4:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function _4(e,t,r){return t===void 0&&(t=!1),!r||t&&r!==Qe(e)?!1:t}function Ir(e,t,r,o){t===void 0&&(t=!1),r===void 0&&(r=!1);const n=e.getBoundingClientRect(),i=rd(e);let a=At(1);t&&(o?St(o)&&(a=Vr(o)):a=Vr(e));const s=_4(i,r,o)?O$(i):At(0);let l=(n.left+s.x)/a.x,u=(n.top+s.y)/a.y,c=n.width/a.x,d=n.height/a.y;if(i){const f=Qe(i),p=o&&St(o)?Qe(o):o;let g=f,h=ju(g);for(;h&&o&&p!==g;){const b=Vr(h),y=h.getBoundingClientRect(),x=It(h),$=y.left+(h.clientLeft+parseFloat(x.paddingLeft))*b.x,v=y.top+(h.clientTop+parseFloat(x.paddingTop))*b.y;l*=b.x,u*=b.y,c*=b.x,d*=b.y,l+=$,u+=v,g=Qe(h),h=ju(g)}}return Fi({width:c,height:d,x:l,y:u})}function nd(e,t){const r=Xa(e).scrollLeft;return t?t.left+r:Ir(Dt(e)).left+r}function N$(e,t,r){r===void 0&&(r=!1);const o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-(r?0:nd(e,o)),i=o.top+t.scrollTop;return{x:n,y:i}}function w4(e){let{elements:t,rect:r,offsetParent:o,strategy:n}=e;const i=n==="fixed",a=Dt(o),s=t?Qa(t.floating):!1;if(o===a||s&&i)return r;let l={scrollLeft:0,scrollTop:0},u=At(1);const c=At(0),d=zt(o);if((d||!d&&!i)&&((pn(o)!=="body"||Co(a))&&(l=Xa(o)),zt(o))){const p=Ir(o);u=Vr(o),c.x=p.x+o.clientLeft,c.y=p.y+o.clientTop}const f=a&&!d&&!i?N$(a,l,!0):At(0);return{width:r.width*u.x,height:r.height*u.y,x:r.x*u.x-l.scrollLeft*u.x+c.x+f.x,y:r.y*u.y-l.scrollTop*u.y+c.y+f.y}}function x4(e){return Array.from(e.getClientRects())}function $4(e){const t=Dt(e),r=Xa(e),o=e.ownerDocument.body,n=Ye(t.scrollWidth,t.clientWidth,o.scrollWidth,o.clientWidth),i=Ye(t.scrollHeight,t.clientHeight,o.scrollHeight,o.clientHeight);let a=-r.scrollLeft+nd(e);const s=-r.scrollTop;return It(o).direction==="rtl"&&(a+=Ye(t.clientWidth,o.clientWidth)-n),{width:n,height:i,x:a,y:s}}function S4(e,t){const r=Qe(e),o=Dt(e),n=r.visualViewport;let i=o.clientWidth,a=o.clientHeight,s=0,l=0;if(n){i=n.width,a=n.height;const u=td();(!u||u&&t==="fixed")&&(s=n.offsetLeft,l=n.offsetTop)}return{width:i,height:a,x:s,y:l}}const I4=new Set(["absolute","fixed"]);function k4(e,t){const r=Ir(e,!0,t==="fixed"),o=r.top+e.clientTop,n=r.left+e.clientLeft,i=zt(e)?Vr(e):At(1),a=e.clientWidth*i.x,s=e.clientHeight*i.y,l=n*i.x,u=o*i.y;return{width:a,height:s,x:l,y:u}}function Ff(e,t,r){let o;if(t==="viewport")o=S4(e,r);else if(t==="document")o=$4(Dt(e));else if(St(t))o=k4(t,r);else{const n=O$(e);o={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return Fi(o)}function P$(e,t){const r=lr(e);return r===t||!St(r)||nn(r)?!1:It(r).position==="fixed"||P$(r,t)}function E4(e,t){const r=t.get(e);if(r)return r;let o=Yn(e,[],!1).filter(s=>St(s)&&pn(s)!=="body"),n=null;const i=It(e).position==="fixed";let a=i?lr(e):e;for(;St(a)&&!nn(a);){const s=It(a),l=ed(a);!l&&s.position==="fixed"&&(n=null),(i?!l&&!n:!l&&s.position==="static"&&!!n&&I4.has(n.position)||Co(a)&&!l&&P$(e,a))?o=o.filter(c=>c!==a):n=s,a=lr(a)}return t.set(e,o),o}function T4(e){let{element:t,boundary:r,rootBoundary:o,strategy:n}=e;const a=[...r==="clippingAncestors"?Qa(t)?[]:E4(t,this._c):[].concat(r),o],s=a[0],l=a.reduce((u,c)=>{const d=Ff(t,c,n);return u.top=Ye(d.top,u.top),u.right=ur(d.right,u.right),u.bottom=ur(d.bottom,u.bottom),u.left=Ye(d.left,u.left),u},Ff(t,s,n));return{width:l.right-l.left,height:l.bottom-l.top,x:l.left,y:l.top}}function O4(e){const{width:t,height:r}=T$(e);return{width:t,height:r}}function N4(e,t,r){const o=zt(t),n=Dt(t),i=r==="fixed",a=Ir(e,!0,i,t);let s={scrollLeft:0,scrollTop:0};const l=At(0);function u(){l.x=nd(n)}if(o||!o&&!i)if((pn(t)!=="body"||Co(n))&&(s=Xa(t)),o){const p=Ir(t,!0,i,t);l.x=p.x+t.clientLeft,l.y=p.y+t.clientTop}else n&&u();i&&!o&&n&&u();const c=n&&!o&&!i?N$(n,s):At(0),d=a.left+s.scrollLeft-l.x-c.x,f=a.top+s.scrollTop-l.y-c.y;return{x:d,y:f,width:a.width,height:a.height}}function Ls(e){return It(e).position==="static"}function qf(e,t){if(!zt(e)||It(e).position==="fixed")return null;if(t)return t(e);let r=e.offsetParent;return Dt(e)===r&&(r=r.ownerDocument.body),r}function C$(e,t){const r=Qe(e);if(Qa(e))return r;if(!zt(e)){let n=lr(e);for(;n&&!nn(n);){if(St(n)&&!Ls(n))return n;n=lr(n)}return r}let o=qf(e,t);for(;o&&p4(o)&&Ls(o);)o=qf(o,t);return o&&nn(o)&&Ls(o)&&!ed(o)?r:o||v4(e)||r}const P4=async function(e){const t=this.getOffsetParent||C$,r=this.getDimensions,o=await r(e.floating);return{reference:N4(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:o.width,height:o.height}}};function C4(e){return It(e).direction==="rtl"}const j4={convertOffsetParentRelativeRectToViewportRelativeRect:w4,getDocumentElement:Dt,getClippingRect:T4,getOffsetParent:C$,getElementRects:P4,getClientRects:x4,getDimensions:O4,getScale:Vr,isElement:St,isRTL:C4};function j$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function A4(e,t){let r=null,o;const n=Dt(e);function i(){var s;clearTimeout(o),(s=r)==null||s.disconnect(),r=null}function a(s,l){s===void 0&&(s=!1),l===void 0&&(l=1),i();const u=e.getBoundingClientRect(),{left:c,top:d,width:f,height:p}=u;if(s||t(),!f||!p)return;const g=Ko(d),h=Ko(n.clientWidth-(c+f)),b=Ko(n.clientHeight-(d+p)),y=Ko(c),$={rootMargin:-g+"px "+-h+"px "+-b+"px "+-y+"px",threshold:Ye(0,ur(1,l))||1};let v=!0;function k(N){const I=N[0].intersectionRatio;if(I!==l){if(!v)return a();I?a(!1,I):o=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!j$(u,e.getBoundingClientRect())&&a(),v=!1}try{r=new IntersectionObserver(k,{...$,root:n.ownerDocument})}catch{r=new IntersectionObserver(k,$)}r.observe(e)}return a(!0),i}function R4(e,t,r,o){o===void 0&&(o={});const{ancestorScroll:n=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:s=typeof IntersectionObserver=="function",animationFrame:l=!1}=o,u=rd(e),c=n||i?[...u?Yn(u):[],...Yn(t)]:[];c.forEach(y=>{n&&y.addEventListener("scroll",r,{passive:!0}),i&&y.addEventListener("resize",r)});const d=u&&s?A4(u,r):null;let f=-1,p=null;a&&(p=new ResizeObserver(y=>{let[x]=y;x&&x.target===u&&p&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var $;($=p)==null||$.observe(t)})),r()}),u&&!l&&p.observe(u),p.observe(t));let g,h=l?Ir(e):null;l&&b();function b(){const y=Ir(e);h&&!j$(h,y)&&r(),h=y,g=requestAnimationFrame(b)}return r(),()=>{var y;c.forEach(x=>{n&&x.removeEventListener("scroll",r),i&&x.removeEventListener("resize",r)}),d?.(),(y=p)==null||y.disconnect(),p=null,l&&cancelAnimationFrame(g)}}const z4=a4,M4=s4,D4=n4,U4=l4,L4=o4,Vf=r4,Z4=u4,F4=(e,t,r)=>{const o=new Map,n={platform:j4,...r},i={...n.platform,_c:o};return t4(e,t,{...n,platform:i})};var q4=typeof document<"u",V4=function(){},si=q4?z.useLayoutEffect:V4;function qi(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let r,o,n;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(r=e.length,r!==t.length)return!1;for(o=r;o--!==0;)if(!qi(e[o],t[o]))return!1;return!0}if(n=Object.keys(e),r=n.length,r!==Object.keys(t).length)return!1;for(o=r;o--!==0;)if(!{}.hasOwnProperty.call(t,n[o]))return!1;for(o=r;o--!==0;){const i=n[o];if(!(i==="_owner"&&e.$$typeof)&&!qi(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function A$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Bf(e,t){const r=A$(e);return Math.round(t*r)/r}function Zs(e){const t=_.useRef(e);return si(()=>{t.current=e}),t}function B4(e){e===void 0&&(e={});const{placement:t="bottom",strategy:r="absolute",middleware:o=[],platform:n,elements:{reference:i,floating:a}={},transform:s=!0,whileElementsMounted:l,open:u}=e,[c,d]=_.useState({x:0,y:0,strategy:r,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=_.useState(o);qi(f,o)||p(o);const[g,h]=_.useState(null),[b,y]=_.useState(null),x=_.useCallback(K=>{K!==N.current&&(N.current=K,h(K))},[]),$=_.useCallback(K=>{K!==I.current&&(I.current=K,y(K))},[]),v=i||g,k=a||b,N=_.useRef(null),I=_.useRef(null),O=_.useRef(c),M=l!=null,F=Zs(l),te=Zs(n),oe=Zs(u),J=_.useCallback(()=>{if(!N.current||!I.current)return;const K={placement:t,strategy:r,middleware:f};te.current&&(K.platform=te.current),F4(N.current,I.current,K).then(fe=>{const B={...fe,isPositioned:oe.current!==!1};V.current&&!qi(O.current,B)&&(O.current=B,um.flushSync(()=>{d(B)}))})},[f,t,r,te,oe]);si(()=>{u===!1&&O.current.isPositioned&&(O.current.isPositioned=!1,d(K=>({...K,isPositioned:!1})))},[u]);const V=_.useRef(!1);si(()=>(V.current=!0,()=>{V.current=!1}),[]),si(()=>{if(v&&(N.current=v),k&&(I.current=k),v&&k){if(F.current)return F.current(v,k,J);J()}},[v,k,J,F,M]);const ye=_.useMemo(()=>({reference:N,floating:I,setReference:x,setFloating:$}),[x,$]),ie=_.useMemo(()=>({reference:v,floating:k}),[v,k]),de=_.useMemo(()=>{const K={position:r,left:0,top:0};if(!ie.floating)return K;const fe=Bf(ie.floating,c.x),B=Bf(ie.floating,c.y);return s?{...K,transform:"translate("+fe+"px, "+B+"px)",...A$(ie.floating)>=1.5&&{willChange:"transform"}}:{position:r,left:fe,top:B}},[r,s,ie.floating,c.x,c.y]);return _.useMemo(()=>({...c,update:J,refs:ye,elements:ie,floatingStyles:de}),[c,J,ye,ie,de])}const J4=e=>{function t(r){return{}.hasOwnProperty.call(r,"current")}return{name:"arrow",options:e,fn(r){const{element:o,padding:n}=typeof e=="function"?e(r):e;return o&&t(o)?o.current!=null?Vf({element:o.current,padding:n}).fn(r):{}:o?Vf({element:o,padding:n}).fn(r):{}}}},W4=(e,t)=>({...z4(e),options:[e,t]}),H4=(e,t)=>({...M4(e),options:[e,t]}),G4=(e,t)=>({...Z4(e),options:[e,t]}),K4=(e,t)=>({...D4(e),options:[e,t]}),Y4=(e,t)=>({...U4(e),options:[e,t]}),Q4=(e,t)=>({...L4(e),options:[e,t]}),X4=(e,t)=>({...J4(e),options:[e,t]});var eD="Arrow",R$=_.forwardRef((e,t)=>{const{children:r,width:o=10,height:n=5,...i}=e;return m.jsx(Ce.svg,{...i,ref:t,width:o,height:n,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?r:m.jsx("polygon",{points:"0,0 30,0 15,10"})})});R$.displayName=eD;var tD=R$;function rD(e){const[t,r]=_.useState(void 0);return lt(()=>{if(e){r({width:e.offsetWidth,height:e.offsetHeight});const o=new ResizeObserver(n=>{if(!Array.isArray(n)||!n.length)return;const i=n[0];let a,s;if("borderBoxSize"in i){const l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;a=u.inlineSize,s=u.blockSize}else a=e.offsetWidth,s=e.offsetHeight;r({width:a,height:s})});return o.observe(e,{box:"border-box"}),()=>o.unobserve(e)}else r(void 0)},[e]),t}var od="Popper",[z$,es]=Po(od),[nD,M$]=z$(od),D$=e=>{const{__scopePopper:t,children:r}=e,[o,n]=_.useState(null);return m.jsx(nD,{scope:t,anchor:o,onAnchorChange:n,children:r})};D$.displayName=od;var U$="PopperAnchor",L$=_.forwardRef((e,t)=>{const{__scopePopper:r,virtualRef:o,...n}=e,i=M$(U$,r),a=_.useRef(null),s=Ge(t,a),l=_.useRef(null);return _.useEffect(()=>{const u=l.current;l.current=o?.current||a.current,u!==l.current&&i.onAnchorChange(l.current)}),o?null:m.jsx(Ce.div,{...n,ref:s})});L$.displayName=U$;var id="PopperContent",[oD,iD]=z$(id),Z$=_.forwardRef((e,t)=>{const{__scopePopper:r,side:o="bottom",sideOffset:n=0,align:i="center",alignOffset:a=0,arrowPadding:s=0,avoidCollisions:l=!0,collisionBoundary:u=[],collisionPadding:c=0,sticky:d="partial",hideWhenDetached:f=!1,updatePositionStrategy:p="optimized",onPlaced:g,...h}=e,b=M$(id,r),[y,x]=_.useState(null),$=Ge(t,xe=>x(xe)),[v,k]=_.useState(null),N=rD(v),I=N?.width??0,O=N?.height??0,M=o+(i!=="center"?"-"+i:""),F=typeof c=="number"?c:{top:0,right:0,bottom:0,left:0,...c},te=Array.isArray(u)?u:[u],oe=te.length>0,J={padding:F,boundary:te.filter(sD),altBoundary:oe},{refs:V,floatingStyles:ye,placement:ie,isPositioned:de,middlewareData:K}=B4({strategy:"fixed",placement:M,whileElementsMounted:(...xe)=>R4(...xe,{animationFrame:p==="always"}),elements:{reference:b.anchor},middleware:[W4({mainAxis:n+O,alignmentAxis:a}),l&&H4({mainAxis:!0,crossAxis:!1,limiter:d==="partial"?G4():void 0,...J}),l&&K4({...J}),Y4({...J,apply:({elements:xe,rects:Ro,availableWidth:ls,availableHeight:fn})=>{const{width:pt,height:zo}=Ro.reference,je=xe.floating.style;je.setProperty("--radix-popper-available-width",`${ls}px`),je.setProperty("--radix-popper-available-height",`${fn}px`),je.setProperty("--radix-popper-anchor-width",`${pt}px`),je.setProperty("--radix-popper-anchor-height",`${zo}px`)}}),v&&X4({element:v,padding:s}),uD({arrowWidth:I,arrowHeight:O}),f&&Q4({strategy:"referenceHidden",...J})]}),[fe,B]=V$(ie),Ue=Sr(g);lt(()=>{de&&Ue?.()},[de,Ue]);const be=K.arrow?.x,Le=K.arrow?.y,U=K.arrow?.centerOffset!==0,[Q,me]=_.useState();return lt(()=>{y&&me(window.getComputedStyle(y).zIndex)},[y]),m.jsx("div",{ref:V.setFloating,"data-radix-popper-content-wrapper":"",style:{...ye,transform:de?ye.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:Q,"--radix-popper-transform-origin":[K.transformOrigin?.x,K.transformOrigin?.y].join(" "),...K.hide?.referenceHidden&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:m.jsx(oD,{scope:r,placedSide:fe,onArrowChange:k,arrowX:be,arrowY:Le,shouldHideArrow:U,children:m.jsx(Ce.div,{"data-side":fe,"data-align":B,...h,ref:$,style:{...h.style,animation:de?void 0:"none"}})})})});Z$.displayName=id;var F$="PopperArrow",aD={top:"bottom",right:"left",bottom:"top",left:"right"},q$=_.forwardRef(function(t,r){const{__scopePopper:o,...n}=t,i=iD(F$,o),a=aD[i.placedSide];return m.jsx("span",{ref:i.onArrowChange,style:{position:"absolute",left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[i.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[i.placedSide],visibility:i.shouldHideArrow?"hidden":void 0},children:m.jsx(tD,{...n,ref:r,style:{...n.style,display:"block"}})})});q$.displayName=F$;function sD(e){return e!==null}var uD=e=>({name:"transformOrigin",options:e,fn(t){const{placement:r,rects:o,middlewareData:n}=t,a=n.arrow?.centerOffset!==0,s=a?0:e.arrowWidth,l=a?0:e.arrowHeight,[u,c]=V$(r),d={start:"0%",center:"50%",end:"100%"}[c],f=(n.arrow?.x??0)+s/2,p=(n.arrow?.y??0)+l/2;let g="",h="";return u==="bottom"?(g=a?d:`${f}px`,h=`${-l}px`):u==="top"?(g=a?d:`${f}px`,h=`${o.floating.height+l}px`):u==="right"?(g=`${-l}px`,h=a?d:`${p}px`):u==="left"&&(g=`${o.floating.width+l}px`,h=a?d:`${p}px`),{data:{x:g,y:h}}}});function V$(e){const[t,r="center"]=e.split("-");return[t,r]}var B$=D$,ad=L$,J$=Z$,W$=q$,lD="Portal",ts=_.forwardRef((e,t)=>{const{container:r,...o}=e,[n,i]=_.useState(!1);lt(()=>i(!0),[]);const a=r||n&&globalThis?.document?.body;return a?sm.createPortal(m.jsx(Ce.div,{...o,ref:t}),a):null});ts.displayName=lD;function cD(e,t){return _.useReducer((r,o)=>t[r][o]??r,e)}var Gt=e=>{const{present:t,children:r}=e,o=dD(t),n=typeof r=="function"?r({present:o.isPresent}):_.Children.only(r),i=Ge(o.ref,pD(n));return typeof r=="function"||o.isPresent?_.cloneElement(n,{ref:i}):null};Gt.displayName="Presence";function dD(e){const[t,r]=_.useState(),o=_.useRef(null),n=_.useRef(e),i=_.useRef("none"),a=e?"mounted":"unmounted",[s,l]=cD(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return _.useEffect(()=>{const u=Yo(o.current);i.current=s==="mounted"?u:"none"},[s]),lt(()=>{const u=o.current,c=n.current;if(c!==e){const f=i.current,p=Yo(u);e?l("MOUNT"):p==="none"||u?.display==="none"?l("UNMOUNT"):l(c&&f!==p?"ANIMATION_OUT":"UNMOUNT"),n.current=e}},[e,l]),lt(()=>{if(t){let u;const c=t.ownerDocument.defaultView??window,d=p=>{const h=Yo(o.current).includes(CSS.escape(p.animationName));if(p.target===t&&h&&(l("ANIMATION_END"),!n.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",u=c.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},f=p=>{p.target===t&&(i.current=Yo(o.current))};return t.addEventListener("animationstart",f),t.addEventListener("animationcancel",d),t.addEventListener("animationend",d),()=>{c.clearTimeout(u),t.removeEventListener("animationstart",f),t.removeEventListener("animationcancel",d),t.removeEventListener("animationend",d)}}else l("ANIMATION_END")},[t,l]),{isPresent:["mounted","unmountSuspended"].includes(s),ref:_.useCallback(u=>{o.current=u?getComputedStyle(u):null,r(u)},[])}}function Yo(e){return e?.animationName||"none"}function pD(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var fD=_[" useInsertionEffect ".trim().toString()]||lt;function rs({prop:e,defaultProp:t,onChange:r=()=>{},caller:o}){const[n,i,a]=mD({defaultProp:t,onChange:r}),s=e!==void 0,l=s?e:n;{const c=_.useRef(e!==void 0);_.useEffect(()=>{const d=c.current;d!==s&&console.warn(`${o} is changing from ${d?"controlled":"uncontrolled"} to ${s?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),c.current=s},[s,o])}const u=_.useCallback(c=>{if(s){const d=hD(c)?c(e):c;d!==e&&a.current?.(d)}else i(c)},[s,e,i,a]);return[l,u]}function mD({defaultProp:e,onChange:t}){const[r,o]=_.useState(e),n=_.useRef(r),i=_.useRef(t);return fD(()=>{i.current=t},[t]),_.useEffect(()=>{n.current!==r&&(i.current?.(r),n.current=r)},[r,n]),[r,o,i]}function hD(e){return typeof e=="function"}var gD=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),vD="VisuallyHidden",H$=_.forwardRef((e,t)=>m.jsx(Ce.span,{...e,ref:t,style:{...gD,...e.style}}));H$.displayName=vD;var yD=H$,[ns]=Po("Tooltip",[es]),os=es(),G$="TooltipProvider",bD=700,Au="tooltip.open",[_D,sd]=ns(G$),K$=e=>{const{__scopeTooltip:t,delayDuration:r=bD,skipDelayDuration:o=300,disableHoverableContent:n=!1,children:i}=e,a=_.useRef(!0),s=_.useRef(!1),l=_.useRef(0);return _.useEffect(()=>{const u=l.current;return()=>window.clearTimeout(u)},[]),m.jsx(_D,{scope:t,isOpenDelayedRef:a,delayDuration:r,onOpen:_.useCallback(()=>{window.clearTimeout(l.current),a.current=!1},[]),onClose:_.useCallback(()=>{window.clearTimeout(l.current),l.current=window.setTimeout(()=>a.current=!0,o)},[o]),isPointerInTransitRef:s,onPointerInTransitChange:_.useCallback(u=>{s.current=u},[]),disableHoverableContent:n,children:i})};K$.displayName=G$;var Qn="Tooltip",[wD,jo]=ns(Qn),Y$=e=>{const{__scopeTooltip:t,children:r,open:o,defaultOpen:n,onOpenChange:i,disableHoverableContent:a,delayDuration:s}=e,l=sd(Qn,e.__scopeTooltip),u=os(t),[c,d]=_.useState(null),f=qr(),p=_.useRef(0),g=a??l.disableHoverableContent,h=s??l.delayDuration,b=_.useRef(!1),[y,x]=rs({prop:o,defaultProp:n??!1,onChange:I=>{I?(l.onOpen(),document.dispatchEvent(new CustomEvent(Au))):l.onClose(),i?.(I)},caller:Qn}),$=_.useMemo(()=>y?b.current?"delayed-open":"instant-open":"closed",[y]),v=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,b.current=!1,x(!0)},[x]),k=_.useCallback(()=>{window.clearTimeout(p.current),p.current=0,x(!1)},[x]),N=_.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{b.current=!0,x(!0),p.current=0},h)},[h,x]);return _.useEffect(()=>()=>{p.current&&(window.clearTimeout(p.current),p.current=0)},[]),m.jsx(B$,{...u,children:m.jsx(wD,{scope:t,contentId:f,open:y,stateAttribute:$,trigger:c,onTriggerChange:d,onTriggerEnter:_.useCallback(()=>{l.isOpenDelayedRef.current?N():v()},[l.isOpenDelayedRef,N,v]),onTriggerLeave:_.useCallback(()=>{g?k():(window.clearTimeout(p.current),p.current=0)},[k,g]),onOpen:v,onClose:k,disableHoverableContent:g,children:r})})};Y$.displayName=Qn;var Ru="TooltipTrigger",Q$=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=jo(Ru,r),i=sd(Ru,r),a=os(r),s=_.useRef(null),l=Ge(t,s,n.onTriggerChange),u=_.useRef(!1),c=_.useRef(!1),d=_.useCallback(()=>u.current=!1,[]);return _.useEffect(()=>()=>document.removeEventListener("pointerup",d),[d]),m.jsx(ad,{asChild:!0,...a,children:m.jsx(Ce.button,{"aria-describedby":n.open?n.contentId:void 0,"data-state":n.stateAttribute,...o,ref:l,onPointerMove:Oe(e.onPointerMove,f=>{f.pointerType!=="touch"&&!c.current&&!i.isPointerInTransitRef.current&&(n.onTriggerEnter(),c.current=!0)}),onPointerLeave:Oe(e.onPointerLeave,()=>{n.onTriggerLeave(),c.current=!1}),onPointerDown:Oe(e.onPointerDown,()=>{n.open&&n.onClose(),u.current=!0,document.addEventListener("pointerup",d,{once:!0})}),onFocus:Oe(e.onFocus,()=>{u.current||n.onOpen()}),onBlur:Oe(e.onBlur,n.onClose),onClick:Oe(e.onClick,n.onClose)})})});Q$.displayName=Ru;var ud="TooltipPortal",[xD,$D]=ns(ud,{forceMount:void 0}),X$=e=>{const{__scopeTooltip:t,forceMount:r,children:o,container:n}=e,i=jo(ud,t);return m.jsx(xD,{scope:t,forceMount:r,children:m.jsx(Gt,{present:r||i.open,children:m.jsx(ts,{asChild:!0,container:n,children:o})})})};X$.displayName=ud;var on="TooltipContent",eS=_.forwardRef((e,t)=>{const r=$D(on,e.__scopeTooltip),{forceMount:o=r.forceMount,side:n="top",...i}=e,a=jo(on,e.__scopeTooltip);return m.jsx(Gt,{present:o||a.open,children:a.disableHoverableContent?m.jsx(tS,{side:n,...i,ref:t}):m.jsx(SD,{side:n,...i,ref:t})})}),SD=_.forwardRef((e,t)=>{const r=jo(on,e.__scopeTooltip),o=sd(on,e.__scopeTooltip),n=_.useRef(null),i=Ge(t,n),[a,s]=_.useState(null),{trigger:l,onClose:u}=r,c=n.current,{onPointerInTransitChange:d}=o,f=_.useCallback(()=>{s(null),d(!1)},[d]),p=_.useCallback((g,h)=>{const b=g.currentTarget,y={x:g.clientX,y:g.clientY},x=TD(y,b.getBoundingClientRect()),$=OD(y,x),v=ND(h.getBoundingClientRect()),k=CD([...$,...v]);s(k),d(!0)},[d]);return _.useEffect(()=>()=>f(),[f]),_.useEffect(()=>{if(l&&c){const g=b=>p(b,c),h=b=>p(b,l);return l.addEventListener("pointerleave",g),c.addEventListener("pointerleave",h),()=>{l.removeEventListener("pointerleave",g),c.removeEventListener("pointerleave",h)}}},[l,c,p,f]),_.useEffect(()=>{if(a){const g=h=>{const b=h.target,y={x:h.clientX,y:h.clientY},x=l?.contains(b)||c?.contains(b),$=!PD(y,a);x?f():$&&(f(),u())};return document.addEventListener("pointermove",g),()=>document.removeEventListener("pointermove",g)}},[l,c,a,u,f]),m.jsx(tS,{...e,ref:i})}),[ID,kD]=ns(Qn,{isInside:!1}),ED=TM("TooltipContent"),tS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,children:o,"aria-label":n,onEscapeKeyDown:i,onPointerDownOutside:a,...s}=e,l=jo(on,r),u=os(r),{onClose:c}=l;return _.useEffect(()=>(document.addEventListener(Au,c),()=>document.removeEventListener(Au,c)),[c]),_.useEffect(()=>{if(l.trigger){const d=f=>{f.target?.contains(l.trigger)&&c()};return window.addEventListener("scroll",d,{capture:!0}),()=>window.removeEventListener("scroll",d,{capture:!0})}},[l.trigger,c]),m.jsx(Ka,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:d=>d.preventDefault(),onDismiss:c,children:m.jsxs(J$,{"data-state":l.stateAttribute,...u,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[m.jsx(ED,{children:o}),m.jsx(ID,{scope:r,isInside:!0,children:m.jsx(yD,{id:l.contentId,role:"tooltip",children:n||o})})]})})});eS.displayName=on;var rS="TooltipArrow",nS=_.forwardRef((e,t)=>{const{__scopeTooltip:r,...o}=e,n=os(r);return kD(rS,r).isInside?null:m.jsx(W$,{...n,...o,ref:t})});nS.displayName=rS;function TD(e,t){const r=Math.abs(t.top-e.y),o=Math.abs(t.bottom-e.y),n=Math.abs(t.right-e.x),i=Math.abs(t.left-e.x);switch(Math.min(r,o,n,i)){case i:return"left";case n:return"right";case r:return"top";case o:return"bottom";default:throw new Error("unreachable")}}function OD(e,t,r=5){const o=[];switch(t){case"top":o.push({x:e.x-r,y:e.y+r},{x:e.x+r,y:e.y+r});break;case"bottom":o.push({x:e.x-r,y:e.y-r},{x:e.x+r,y:e.y-r});break;case"left":o.push({x:e.x+r,y:e.y-r},{x:e.x+r,y:e.y+r});break;case"right":o.push({x:e.x-r,y:e.y-r},{x:e.x-r,y:e.y+r});break}return o}function ND(e){const{top:t,right:r,bottom:o,left:n}=e;return[{x:n,y:t},{x:r,y:t},{x:r,y:o},{x:n,y:o}]}function PD(e,t){const{x:r,y:o}=e;let n=!1;for(let i=0,a=t.length-1;i<t.length;a=i++){const s=t[i],l=t[a],u=s.x,c=s.y,d=l.x,f=l.y;c>o!=f>o&&r<(d-u)*(o-c)/(f-c)+u&&(n=!n)}return n}function CD(e){const t=e.slice();return t.sort((r,o)=>r.x<o.x?-1:r.x>o.x?1:r.y<o.y?-1:r.y>o.y?1:0),jD(t)}function jD(e){if(e.length<=1)return e.slice();const t=[];for(let o=0;o<e.length;o++){const n=e[o];for(;t.length>=2;){const i=t[t.length-1],a=t[t.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))t.pop();else break}t.push(n)}t.pop();const r=[];for(let o=e.length-1;o>=0;o--){const n=e[o];for(;r.length>=2;){const i=r[r.length-1],a=r[r.length-2];if((i.x-a.x)*(n.y-a.y)>=(i.y-a.y)*(n.x-a.x))r.pop();else break}r.push(n)}return r.pop(),t.length===1&&r.length===1&&t[0].x===r[0].x&&t[0].y===r[0].y?t:t.concat(r)}var AD=K$,RD=Y$,zD=Q$,MD=X$,DD=eS,UD=nS;function oS({delayDuration:e=0,...t}){return m.jsx(AD,{"data-slot":"tooltip-provider",delayDuration:e,...t})}function ld({...e}){return m.jsx(oS,{children:m.jsx(RD,{"data-slot":"tooltip",...e})})}function cd({...e}){return m.jsx(zD,{"data-slot":"tooltip-trigger",...e})}function dd({className:e,sideOffset:t=0,children:r,...o}){return m.jsx(MD,{children:m.jsxs(DD,{"data-slot":"tooltip-content",sideOffset:t,className:T.cn("bg-foreground text-background animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-md px-3 py-1.5 text-xs text-balance",e),...o,children:[r,m.jsx(UD,{className:"bg-foreground fill-foreground z-20 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]"})]})})}var Fs="focusScope.autoFocusOnMount",qs="focusScope.autoFocusOnUnmount",Jf={bubbles:!1,cancelable:!0},LD="FocusScope",pd=_.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:n,onUnmountAutoFocus:i,...a}=e,[s,l]=_.useState(null),u=Sr(n),c=Sr(i),d=_.useRef(null),f=Ge(t,h=>l(h)),p=_.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;_.useEffect(()=>{if(o){let h=function($){if(p.paused||!s)return;const v=$.target;s.contains(v)?d.current=v:Qt(d.current,{select:!0})},b=function($){if(p.paused||!s)return;const v=$.relatedTarget;v!==null&&(s.contains(v)||Qt(d.current,{select:!0}))},y=function($){if(document.activeElement===document.body)for(const k of $)k.removedNodes.length>0&&Qt(s)};document.addEventListener("focusin",h),document.addEventListener("focusout",b);const x=new MutationObserver(y);return s&&x.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",h),document.removeEventListener("focusout",b),x.disconnect()}}},[o,s,p.paused]),_.useEffect(()=>{if(s){Hf.add(p);const h=document.activeElement;if(!s.contains(h)){const y=new CustomEvent(Fs,Jf);s.addEventListener(Fs,u),s.dispatchEvent(y),y.defaultPrevented||(ZD(JD(iS(s)),{select:!0}),document.activeElement===h&&Qt(s))}return()=>{s.removeEventListener(Fs,u),setTimeout(()=>{const y=new CustomEvent(qs,Jf);s.addEventListener(qs,c),s.dispatchEvent(y),y.defaultPrevented||Qt(h??document.body,{select:!0}),s.removeEventListener(qs,c),Hf.remove(p)},0)}}},[s,u,c,p]);const g=_.useCallback(h=>{if(!r&&!o||p.paused)return;const b=h.key==="Tab"&&!h.altKey&&!h.ctrlKey&&!h.metaKey,y=document.activeElement;if(b&&y){const x=h.currentTarget,[$,v]=FD(x);$&&v?!h.shiftKey&&y===v?(h.preventDefault(),r&&Qt($,{select:!0})):h.shiftKey&&y===$&&(h.preventDefault(),r&&Qt(v,{select:!0})):y===x&&h.preventDefault()}},[r,o,p.paused]);return m.jsx(Ce.div,{tabIndex:-1,...a,ref:f,onKeyDown:g})});pd.displayName=LD;function ZD(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(Qt(o,{select:t}),document.activeElement!==r)return}function FD(e){const t=iS(e),r=Wf(t,e),o=Wf(t.reverse(),e);return[r,o]}function iS(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const n=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||n?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function Wf(e,t){for(const r of e)if(!qD(r,{upTo:t}))return r}function qD(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function VD(e){return e instanceof HTMLInputElement&&"select"in e}function Qt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&VD(e)&&t&&e.select()}}var Hf=BD();function BD(){let e=[];return{add(t){const r=e[0];t!==r&&r?.pause(),e=Gf(e,t),e.unshift(t)},remove(t){e=Gf(e,t),e[0]?.resume()}}}function Gf(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}function JD(e){return e.filter(t=>t.tagName!=="A")}var Vs=0;function aS(){_.useEffect(()=>{const e=document.querySelectorAll("[data-radix-focus-guard]");return document.body.insertAdjacentElement("afterbegin",e[0]??Kf()),document.body.insertAdjacentElement("beforeend",e[1]??Kf()),Vs++,()=>{Vs===1&&document.querySelectorAll("[data-radix-focus-guard]").forEach(t=>t.remove()),Vs--}},[])}function Kf(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Pt=function(){return Pt=Object.assign||function(t){for(var r,o=1,n=arguments.length;o<n;o++){r=arguments[o];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},Pt.apply(this,arguments)};function sS(e,t){var r={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,o=Object.getOwnPropertySymbols(e);n<o.length;n++)t.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(r[o[n]]=e[o[n]]);return r}function WD(e,t,r){if(r||arguments.length===2)for(var o=0,n=t.length,i;o<n;o++)(i||!(o in t))&&(i||(i=Array.prototype.slice.call(t,0,o)),i[o]=t[o]);return e.concat(i||Array.prototype.slice.call(t))}var ui="right-scroll-bar-position",li="width-before-scroll-bar",HD="with-scroll-bars-hidden",GD="--removed-body-scroll-bar-size";function Bs(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function KD(e,t){var r=z.useState(function(){return{value:e,callback:t,facade:{get current(){return r.value},set current(o){var n=r.value;n!==o&&(r.value=o,r.callback(o,n))}}}})[0];return r.callback=t,r.facade}var YD=typeof window<"u"?_.useLayoutEffect:_.useEffect,Yf=new WeakMap;function QD(e,t){var r=KD(null,function(o){return e.forEach(function(n){return Bs(n,o)})});return YD(function(){var o=Yf.get(r);if(o){var n=new Set(o),i=new Set(e),a=r.current;n.forEach(function(s){i.has(s)||Bs(s,null)}),i.forEach(function(s){n.has(s)||Bs(s,a)})}Yf.set(r,e)},[e]),r}function XD(e){return e}function eU(e,t){t===void 0&&(t=XD);var r=[],o=!1,n={read:function(){if(o)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return r.length?r[r.length-1]:e},useMedium:function(i){var a=t(i,o);return r.push(a),function(){r=r.filter(function(s){return s!==a})}},assignSyncMedium:function(i){for(o=!0;r.length;){var a=r;r=[],a.forEach(i)}r={push:function(s){return i(s)},filter:function(){return r}}},assignMedium:function(i){o=!0;var a=[];if(r.length){var s=r;r=[],s.forEach(i),a=r}var l=function(){var c=a;a=[],c.forEach(i)},u=function(){return Promise.resolve().then(l)};u(),r={push:function(c){a.push(c),u()},filter:function(c){return a=a.filter(c),r}}}};return n}function tU(e){e===void 0&&(e={});var t=eU(null);return t.options=Pt({async:!0,ssr:!1},e),t}var uS=function(e){var t=e.sideCar,r=sS(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var o=t.read();if(!o)throw new Error("Sidecar medium not found");return _.createElement(o,Pt({},r))};uS.isSideCarExport=!0;function rU(e,t){return e.useMedium(t),uS}var lS=tU(),Js=function(){},is=_.forwardRef(function(e,t){var r=_.useRef(null),o=_.useState({onScrollCapture:Js,onWheelCapture:Js,onTouchMoveCapture:Js}),n=o[0],i=o[1],a=e.forwardProps,s=e.children,l=e.className,u=e.removeScrollBar,c=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,g=e.noIsolation,h=e.inert,b=e.allowPinchZoom,y=e.as,x=y===void 0?"div":y,$=e.gapMode,v=sS(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),k=f,N=QD([r,t]),I=Pt(Pt({},v),n);return _.createElement(_.Fragment,null,c&&_.createElement(k,{sideCar:lS,removeScrollBar:u,shards:d,noRelative:p,noIsolation:g,inert:h,setCallbacks:i,allowPinchZoom:!!b,lockRef:r,gapMode:$}),a?_.cloneElement(_.Children.only(s),Pt(Pt({},I),{ref:N})):_.createElement(x,Pt({},I,{className:l,ref:N}),s))});is.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};is.classNames={fullWidth:li,zeroRight:ui};var nU=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function oU(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=nU();return t&&e.setAttribute("nonce",t),e}function iU(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function aU(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var sU=function(){var e=0,t=null;return{add:function(r){e==0&&(t=oU())&&(iU(t,r),aU(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},uU=function(){var e=sU();return function(t,r){_.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&r])}},cS=function(){var e=uU(),t=function(r){var o=r.styles,n=r.dynamic;return e(o,n),null};return t},lU={left:0,top:0,right:0,gap:0},Ws=function(e){return parseInt(e||"",10)||0},cU=function(e){var t=window.getComputedStyle(document.body),r=t[e==="padding"?"paddingLeft":"marginLeft"],o=t[e==="padding"?"paddingTop":"marginTop"],n=t[e==="padding"?"paddingRight":"marginRight"];return[Ws(r),Ws(o),Ws(n)]},dU=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return lU;var t=cU(e),r=document.documentElement.clientWidth,o=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,o-r+t[2]-t[0])}},pU=cS(),Br="data-scroll-locked",fU=function(e,t,r,o){var n=e.left,i=e.top,a=e.right,s=e.gap;return r===void 0&&(r="margin"),`
|
|
97
|
+
.`.concat(HD,` {
|
|
98
98
|
overflow: hidden `).concat(o,`;
|
|
99
99
|
padding-right: `).concat(s,"px ").concat(o,`;
|
|
100
100
|
}
|
|
@@ -111,34 +111,34 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
111
111
|
`),r==="padding"&&"padding-right: ".concat(s,"px ").concat(o,";")].filter(Boolean).join(""),`
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
-
.`).concat(
|
|
114
|
+
.`).concat(ui,` {
|
|
115
115
|
right: `).concat(s,"px ").concat(o,`;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
.`).concat(
|
|
118
|
+
.`).concat(li,` {
|
|
119
119
|
margin-right: `).concat(s,"px ").concat(o,`;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
-
.`).concat(
|
|
122
|
+
.`).concat(ui," .").concat(ui,` {
|
|
123
123
|
right: 0 `).concat(o,`;
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
.`).concat(
|
|
126
|
+
.`).concat(li," .").concat(li,` {
|
|
127
127
|
margin-right: 0 `).concat(o,`;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
body[`).concat(Br,`] {
|
|
131
|
-
`).concat(
|
|
131
|
+
`).concat(GD,": ").concat(s,`px;
|
|
132
132
|
}
|
|
133
|
-
`)},Qf=function(){var e=parseInt(document.body.getAttribute(Br)||"0",10);return isFinite(e)?e:0},
|
|
133
|
+
`)},Qf=function(){var e=parseInt(document.body.getAttribute(Br)||"0",10);return isFinite(e)?e:0},mU=function(){_.useEffect(function(){return document.body.setAttribute(Br,(Qf()+1).toString()),function(){var e=Qf()-1;e<=0?document.body.removeAttribute(Br):document.body.setAttribute(Br,e.toString())}},[])},hU=function(e){var t=e.noRelative,r=e.noImportant,o=e.gapMode,n=o===void 0?"margin":o;mU();var i=_.useMemo(function(){return dU(n)},[n]);return _.createElement(pU,{styles:fU(i,!t,n,r?"":"!important")})},zu=!1;if(typeof window<"u")try{var Qo=Object.defineProperty({},"passive",{get:function(){return zu=!0,!0}});window.addEventListener("test",Qo,Qo),window.removeEventListener("test",Qo,Qo)}catch{zu=!1}var Rr=zu?{passive:!1}:!1,gU=function(e){return e.tagName==="TEXTAREA"},dS=function(e,t){if(!(e instanceof Element))return!1;var r=window.getComputedStyle(e);return r[t]!=="hidden"&&!(r.overflowY===r.overflowX&&!gU(e)&&r[t]==="visible")},vU=function(e){return dS(e,"overflowY")},yU=function(e){return dS(e,"overflowX")},Xf=function(e,t){var r=t.ownerDocument,o=t;do{typeof ShadowRoot<"u"&&o instanceof ShadowRoot&&(o=o.host);var n=pS(e,o);if(n){var i=fS(e,o),a=i[1],s=i[2];if(a>s)return!0}o=o.parentNode}while(o&&o!==r.body);return!1},bU=function(e){var t=e.scrollTop,r=e.scrollHeight,o=e.clientHeight;return[t,r,o]},_U=function(e){var t=e.scrollLeft,r=e.scrollWidth,o=e.clientWidth;return[t,r,o]},pS=function(e,t){return e==="v"?vU(t):yU(t)},fS=function(e,t){return e==="v"?bU(t):_U(t)},wU=function(e,t){return e==="h"&&t==="rtl"?-1:1},xU=function(e,t,r,o,n){var i=wU(e,window.getComputedStyle(t).direction),a=i*o,s=r.target,l=t.contains(s),u=!1,c=a>0,d=0,f=0;do{if(!s)break;var p=fS(e,s),g=p[0],h=p[1],b=p[2],y=h-b-i*g;(g||y)&&pS(e,s)&&(d+=y,f+=g);var x=s.parentNode;s=x&&x.nodeType===Node.DOCUMENT_FRAGMENT_NODE?x.host:x}while(!l&&s!==document.body||l&&(t.contains(s)||t===s));return(c&&Math.abs(d)<1||!c&&Math.abs(f)<1)&&(u=!0),u},Xo=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},em=function(e){return[e.deltaX,e.deltaY]},tm=function(e){return e&&"current"in e?e.current:e},$U=function(e,t){return e[0]===t[0]&&e[1]===t[1]},SU=function(e){return`
|
|
134
134
|
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
135
135
|
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
136
|
-
`)}
|
|
136
|
+
`)},IU=0,zr=[];function kU(e){var t=_.useRef([]),r=_.useRef([0,0]),o=_.useRef(),n=_.useState(IU++)[0],i=_.useState(cS)[0],a=_.useRef(e);_.useEffect(function(){a.current=e},[e]),_.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(n));var h=WD([e.lockRef.current],(e.shards||[]).map(tm),!0).filter(Boolean);return h.forEach(function(b){return b.classList.add("allow-interactivity-".concat(n))}),function(){document.body.classList.remove("block-interactivity-".concat(n)),h.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(n))})}}},[e.inert,e.lockRef.current,e.shards]);var s=_.useCallback(function(h,b){if("touches"in h&&h.touches.length===2||h.type==="wheel"&&h.ctrlKey)return!a.current.allowPinchZoom;var y=Xo(h),x=r.current,$="deltaX"in h?h.deltaX:x[0]-y[0],v="deltaY"in h?h.deltaY:x[1]-y[1],k,N=h.target,I=Math.abs($)>Math.abs(v)?"h":"v";if("touches"in h&&I==="h"&&N.type==="range")return!1;var O=Xf(I,N);if(!O)return!0;if(O?k=I:(k=I==="v"?"h":"v",O=Xf(I,N)),!O)return!1;if(!o.current&&"changedTouches"in h&&($||v)&&(o.current=k),!k)return!0;var M=o.current||k;return xU(M,b,h,M==="h"?$:v)},[]),l=_.useCallback(function(h){var b=h;if(!(!zr.length||zr[zr.length-1]!==i)){var y="deltaY"in b?em(b):Xo(b),x=t.current.filter(function(k){return k.name===b.type&&(k.target===b.target||b.target===k.shadowParent)&&$U(k.delta,y)})[0];if(x&&x.should){b.cancelable&&b.preventDefault();return}if(!x){var $=(a.current.shards||[]).map(tm).filter(Boolean).filter(function(k){return k.contains(b.target)}),v=$.length>0?s(b,$[0]):!a.current.noIsolation;v&&b.cancelable&&b.preventDefault()}}},[]),u=_.useCallback(function(h,b,y,x){var $={name:h,delta:b,target:y,should:x,shadowParent:EU(y)};t.current.push($),setTimeout(function(){t.current=t.current.filter(function(v){return v!==$})},1)},[]),c=_.useCallback(function(h){r.current=Xo(h),o.current=void 0},[]),d=_.useCallback(function(h){u(h.type,em(h),h.target,s(h,e.lockRef.current))},[]),f=_.useCallback(function(h){u(h.type,Xo(h),h.target,s(h,e.lockRef.current))},[]);_.useEffect(function(){return zr.push(i),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener("wheel",l,Rr),document.addEventListener("touchmove",l,Rr),document.addEventListener("touchstart",c,Rr),function(){zr=zr.filter(function(h){return h!==i}),document.removeEventListener("wheel",l,Rr),document.removeEventListener("touchmove",l,Rr),document.removeEventListener("touchstart",c,Rr)}},[]);var p=e.removeScrollBar,g=e.inert;return _.createElement(_.Fragment,null,g?_.createElement(i,{styles:SU(n)}):null,p?_.createElement(hU,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function EU(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const TU=rU(lS,kU);var fd=_.forwardRef(function(e,t){return _.createElement(is,Pt({},e,{ref:t,sideCar:TU}))});fd.classNames=is.classNames;var OU=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},Mr=new WeakMap,ei=new WeakMap,ti={},Hs=0,mS=function(e){return e&&(e.host||mS(e.parentNode))},NU=function(e,t){return t.map(function(r){if(e.contains(r))return r;var o=mS(r);return o&&e.contains(o)?o:(console.error("aria-hidden",r,"in not contained inside",e,". Doing nothing"),null)}).filter(function(r){return!!r})},PU=function(e,t,r,o){var n=NU(t,Array.isArray(e)?e:[e]);ti[r]||(ti[r]=new WeakMap);var i=ti[r],a=[],s=new Set,l=new Set(n),u=function(d){!d||s.has(d)||(s.add(d),u(d.parentNode))};n.forEach(u);var c=function(d){!d||l.has(d)||Array.prototype.forEach.call(d.children,function(f){if(s.has(f))c(f);else try{var p=f.getAttribute(o),g=p!==null&&p!=="false",h=(Mr.get(f)||0)+1,b=(i.get(f)||0)+1;Mr.set(f,h),i.set(f,b),a.push(f),h===1&&g&&ei.set(f,!0),b===1&&f.setAttribute(r,"true"),g||f.setAttribute(o,"true")}catch(y){console.error("aria-hidden: cannot operate on ",f,y)}})};return c(t),s.clear(),Hs++,function(){a.forEach(function(d){var f=Mr.get(d)-1,p=i.get(d)-1;Mr.set(d,f),i.set(d,p),f||(ei.has(d)||d.removeAttribute(o),ei.delete(d)),p||d.removeAttribute(r)}),Hs--,Hs||(Mr=new WeakMap,Mr=new WeakMap,ei=new WeakMap,ti={})}},hS=function(e,t,r){r===void 0&&(r="data-aria-hidden");var o=Array.from(Array.isArray(e)?e:[e]),n=OU(e);return n?(o.push.apply(o,Array.from(n.querySelectorAll("[aria-live], script"))),PU(o,n,r,"aria-hidden")):function(){return null}},as="Dialog",[gS]=Po(as),[CU,kt]=gS(as),vS=e=>{const{__scopeDialog:t,children:r,open:o,defaultOpen:n,onOpenChange:i,modal:a=!0}=e,s=_.useRef(null),l=_.useRef(null),[u,c]=rs({prop:o,defaultProp:n??!1,onChange:i,caller:as});return m.jsx(CU,{scope:t,triggerRef:s,contentRef:l,contentId:qr(),titleId:qr(),descriptionId:qr(),open:u,onOpenChange:c,onOpenToggle:_.useCallback(()=>c(d=>!d),[c]),modal:a,children:r})};vS.displayName=as;var yS="DialogTrigger",bS=_.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,n=kt(yS,r),i=Ge(t,n.triggerRef);return m.jsx(Ce.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":gd(n.open),...o,ref:i,onClick:Oe(e.onClick,n.onOpenToggle)})});bS.displayName=yS;var md="DialogPortal",[jU,_S]=gS(md,{forceMount:void 0}),wS=e=>{const{__scopeDialog:t,forceMount:r,children:o,container:n}=e,i=kt(md,t);return m.jsx(jU,{scope:t,forceMount:r,children:_.Children.map(o,a=>m.jsx(Gt,{present:r||i.open,children:m.jsx(ts,{asChild:!0,container:n,children:a})}))})};wS.displayName=md;var Vi="DialogOverlay",xS=_.forwardRef((e,t)=>{const r=_S(Vi,e.__scopeDialog),{forceMount:o=r.forceMount,...n}=e,i=kt(Vi,e.__scopeDialog);return i.modal?m.jsx(Gt,{present:o||i.open,children:m.jsx(RU,{...n,ref:t})}):null});xS.displayName=Vi;var AU=Kc("DialogOverlay.RemoveScroll"),RU=_.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,n=kt(Vi,r);return m.jsx(fd,{as:AU,allowPinchZoom:!0,shards:[n.contentRef],children:m.jsx(Ce.div,{"data-state":gd(n.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),kr="DialogContent",$S=_.forwardRef((e,t)=>{const r=_S(kr,e.__scopeDialog),{forceMount:o=r.forceMount,...n}=e,i=kt(kr,e.__scopeDialog);return m.jsx(Gt,{present:o||i.open,children:i.modal?m.jsx(zU,{...n,ref:t}):m.jsx(MU,{...n,ref:t})})});$S.displayName=kr;var zU=_.forwardRef((e,t)=>{const r=kt(kr,e.__scopeDialog),o=_.useRef(null),n=Ge(t,r.contentRef,o);return _.useEffect(()=>{const i=o.current;if(i)return hS(i)},[]),m.jsx(SS,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,i=>{i.preventDefault(),r.triggerRef.current?.focus()}),onPointerDownOutside:Oe(e.onPointerDownOutside,i=>{const a=i.detail.originalEvent,s=a.button===0&&a.ctrlKey===!0;(a.button===2||s)&&i.preventDefault()}),onFocusOutside:Oe(e.onFocusOutside,i=>i.preventDefault())})}),MU=_.forwardRef((e,t)=>{const r=kt(kr,e.__scopeDialog),o=_.useRef(!1),n=_.useRef(!1);return m.jsx(SS,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||r.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,n.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const a=i.target;r.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&n.current&&i.preventDefault()}})}),SS=_.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:o,onOpenAutoFocus:n,onCloseAutoFocus:i,...a}=e,s=kt(kr,r),l=_.useRef(null),u=Ge(t,l);return aS(),m.jsxs(m.Fragment,{children:[m.jsx(pd,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:n,onUnmountAutoFocus:i,children:m.jsx(Ka,{role:"dialog",id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":gd(s.open),...a,ref:u,onDismiss:()=>s.onOpenChange(!1)})}),m.jsxs(m.Fragment,{children:[m.jsx(UU,{titleId:s.titleId}),m.jsx(ZU,{contentRef:l,descriptionId:s.descriptionId})]})]})}),hd="DialogTitle",IS=_.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,n=kt(hd,r);return m.jsx(Ce.h2,{id:n.titleId,...o,ref:t})});IS.displayName=hd;var kS="DialogDescription",DU=_.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,n=kt(kS,r);return m.jsx(Ce.p,{id:n.descriptionId,...o,ref:t})});DU.displayName=kS;var ES="DialogClose",TS=_.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,n=kt(ES,r);return m.jsx(Ce.button,{type:"button",...o,ref:t,onClick:Oe(e.onClick,()=>n.onOpenChange(!1))})});TS.displayName=ES;function gd(e){return e?"open":"closed"}var OS="DialogTitleWarning",[K2,NS]=IM(OS,{contentName:kr,titleName:hd,docsSlug:"dialog"}),UU=({titleId:e})=>{const t=NS(OS),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
|
|
137
137
|
|
|
138
138
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
139
139
|
|
|
140
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},DU="DialogDescriptionWarning",UU=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${NS(DU).contentName}}.`;return _.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");t&&n&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},LU=vS,ZU=bS,FU=wS,qU=xS,VU=$S,BU=IS,JU=TS;function WU({...e}){return m.jsx(LU,{"data-slot":"dialog",...e})}function HU({...e}){return m.jsx(ZU,{"data-slot":"dialog-trigger",...e})}function GU({...e}){return m.jsx(FU,{"data-slot":"dialog-portal",...e})}function KU({className:e,...t}){return m.jsx(qU,{"data-slot":"dialog-overlay",className:T.cn("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function YU({className:e,children:t,showCloseButton:r=!0,...o}){return m.jsxs(GU,{"data-slot":"dialog-portal",children:[m.jsx(KU,{}),m.jsxs(VU,{"data-slot":"dialog-content",className:T.cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...o,children:[t,r&&m.jsxs(JU,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[m.jsx(Eo,{}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function QU({className:e,...t}){return m.jsx(BU,{"data-slot":"dialog-title",className:T.cn("text-lg leading-none font-semibold",e),...t})}function XU(e,t=[]){let r=[];function o(i,a){const s=_.createContext(a);s.displayName=i+"Context";const l=r.length;r=[...r,a];const u=d=>{const{scope:f,children:p,...g}=d,h=f?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return m.jsx(h.Provider,{value:b,children:p})};u.displayName=i+"Provider";function c(d,f){const p=f?.[e]?.[l]||s,g=_.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const n=()=>{const i=r.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return n.scopeName=e,[o,e6(n,...t)]}function e6(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return r.scopeName=t.scopeName,r}var t6=Symbol.for("react.lazy"),Vi=_[" use ".trim().toString()];function r6(e){return typeof e=="object"&&e!==null&&"then"in e}function PS(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===t6&&"_payload"in e&&r6(e._payload)}function CS(e){const t=o6(e),r=_.forwardRef((o,n)=>{let{children:i,...a}=o;PS(i)&&typeof Vi=="function"&&(i=Vi(i._payload));const s=_.Children.toArray(i),l=s.find(s6);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return m.jsx(t,{...a,ref:n,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:n,children:i})});return r.displayName=`${e}.Slot`,r}var n6=CS("Slot");function o6(e){const t=_.forwardRef((r,o)=>{let{children:n,...i}=r;if(PS(n)&&typeof Vi=="function"&&(n=Vi(n._payload)),_.isValidElement(n)){const a=l6(n),s=u6(i,n.props);return n.type!==_.Fragment&&(s.ref=o?Gc(o,a):a),_.cloneElement(n,s)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var jS=Symbol("radix.slottable");function i6(e){const t=({children:r})=>m.jsx(m.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=jS,t}var a6=i6("Slottable");function s6(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===jS}function u6(e,t){const r={...t};for(const o in t){const n=e[o],i=t[o];/^on[A-Z]/.test(o)?n&&i?r[o]=(...s)=>{const l=i(...s);return n(...s),l}:n&&(r[o]=n):o==="style"?r[o]={...n,...i}:o==="className"&&(r[o]=[n,i].filter(Boolean).join(" "))}return{...e,...r}}function l6(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var c6=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vd=c6.reduce((e,t)=>{const r=CS(`Primitive.${t}`),o=_.forwardRef((n,i)=>{const{asChild:a,...s}=n,l=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function d6(){return wj.useSyncExternalStore(p6,()=>!0,()=>!1)}function p6(){return()=>{}}var yd="Avatar",[f6]=XU(yd),[m6,AS]=f6(yd),RS=_.forwardRef((e,t)=>{const{__scopeAvatar:r,...o}=e,[n,i]=_.useState("idle");return m.jsx(m6,{scope:r,imageLoadingStatus:n,onImageLoadingStatusChange:i,children:m.jsx(vd.span,{...o,ref:t})})});RS.displayName=yd;var zS="AvatarImage",MS=_.forwardRef((e,t)=>{const{__scopeAvatar:r,src:o,onLoadingStatusChange:n=()=>{},...i}=e,a=AS(zS,r),s=h6(o,i),l=Sr(u=>{n(u),a.onImageLoadingStatusChange(u)});return lt(()=>{s!=="idle"&&l(s)},[s,l]),s==="loaded"?m.jsx(vd.img,{...i,ref:t,src:o}):null});MS.displayName=zS;var DS="AvatarFallback",US=_.forwardRef((e,t)=>{const{__scopeAvatar:r,delayMs:o,...n}=e,i=AS(DS,r),[a,s]=_.useState(o===void 0);return _.useEffect(()=>{if(o!==void 0){const l=window.setTimeout(()=>s(!0),o);return()=>window.clearTimeout(l)}},[o]),a&&i.imageLoadingStatus!=="loaded"?m.jsx(vd.span,{...n,ref:t}):null});US.displayName=DS;function rm(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function h6(e,{referrerPolicy:t,crossOrigin:r}){const o=d6(),n=_.useRef(null),i=o?(n.current||(n.current=new window.Image),n.current):null,[a,s]=_.useState(()=>rm(i,e));return lt(()=>{s(rm(i,e))},[i,e]),lt(()=>{const l=d=>()=>{s(d)};if(!i)return;const u=l("loaded"),c=l("error");return i.addEventListener("load",u),i.addEventListener("error",c),t&&(i.referrerPolicy=t),typeof r=="string"&&(i.crossOrigin=r),()=>{i.removeEventListener("load",u),i.removeEventListener("error",c)}},[i,r,t]),a}var g6=RS,v6=MS,y6=US;function b6({className:e,...t}){return m.jsx(g6,{"data-slot":"avatar",className:T.cn("relative flex size-8 shrink-0 overflow-hidden rounded-full",e),...t})}function _6({className:e,...t}){return m.jsx(v6,{"data-slot":"avatar-image",className:T.cn("aspect-square size-full",e),...t})}function w6({className:e,...t}){return m.jsx(y6,{"data-slot":"avatar-fallback",className:T.cn("bg-muted flex size-full items-center justify-center rounded-full",e),...t})}const nm=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,om=T.clsx,LS=(e,t)=>r=>{var o;if(t?.variants==null)return om(e,r?.class,r?.className);const{variants:n,defaultVariants:i}=t,a=Object.keys(n).map(u=>{const c=r?.[u],d=i?.[u];if(c===null)return null;const f=nm(c)||nm(d);return n[u][f]}),s=r&&Object.entries(r).reduce((u,c)=>{let[d,f]=c;return f===void 0||(u[d]=f),u},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((u,c)=>{let{class:d,className:f,...p}=c;return Object.entries(p).every(g=>{let[h,b]=g;return Array.isArray(b)?b.includes({...i,...s}[h]):{...i,...s}[h]===b})?[...u,d,f]:u},[]);return om(e,a,l,r?.class,r?.className)},x6=LS("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),$t=_.forwardRef(({className:e,variant:t,size:r,asChild:o=!1,...n},i)=>{const a=o?n6:"button";return m.jsx(a,{"data-slot":"button",className:T.cn(x6({variant:t,size:r,className:e})),ref:i,...n})});$t.displayName="Button";const ct=D.forwardRef(({children:e,tooltip:t,side:r="bottom",align:o="center",className:n,...i},a)=>m.jsxs(ld,{children:[m.jsx(cd,{asChild:!0,children:m.jsxs($t,{variant:"ghost",size:"icon",...i,className:T.cn("aui-button-icon size-6 p-1",n),ref:a,children:[m.jsx(a6,{children:e}),m.jsx("span",{className:"aui-sr-only sr-only",children:t})]})}),m.jsx(dd,{side:r,align:o,children:t})]}));ct.displayName="TooltipIconButton";const $6=e=>{const[t,r]=D.useState(void 0);return D.useEffect(()=>{if(!e){r(void 0);return}const o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o)}},[e]),t},ZS=()=>{const{file:e,src:t}=L.useAssistantState(_0.useShallow(({attachment:r})=>{if(r.type!=="image")return{};if(r.file)return{file:r.file};const o=r.content?.filter(n=>n.type==="image")[0]?.image;return o?{src:o}:{}}));return $6(e)??t},S6=({src:e})=>{const[t,r]=D.useState(!1);return m.jsx("img",{src:e,alt:"Image Preview",className:t?"aui-attachment-preview-image-loaded block h-auto max-h-[80vh] w-auto max-w-full object-contain":"aui-attachment-preview-image-loading hidden",onLoad:()=>r(!0)})},I6=({children:e})=>{const t=ZS();return t?m.jsxs(WU,{children:[m.jsx(HU,{className:"aui-attachment-preview-trigger hover:bg-accent/50 cursor-pointer transition-colors",asChild:!0,children:e}),m.jsxs(YU,{className:"aui-attachment-preview-dialog-content [&_svg]:text-background [&>button]:bg-foreground/60 [&>button]:hover:[&_svg]:text-destructive p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:!ring-0",children:[m.jsx(QU,{className:"aui-sr-only sr-only",children:"Image Attachment Preview"}),m.jsx("div",{className:"aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden",children:m.jsx(S6,{src:t})})]})]}):e},k6=()=>{const e=L.useAssistantState(({attachment:r})=>r.type==="image"),t=ZS();return m.jsxs(b6,{className:"aui-attachment-tile-avatar h-full w-full rounded-none",children:[m.jsx(_6,{src:t,alt:"Attachment preview",className:"aui-attachment-tile-image object-cover"}),m.jsx(w6,{delayMs:e?200:0,children:m.jsx(TN,{className:"aui-attachment-tile-fallback-icon text-muted-foreground size-8"})})]})},FS=()=>{const t=L.useAssistantApi().attachment.source==="composer",r=L.useAssistantState(({attachment:n})=>n.type==="image"),o=L.useAssistantState(({attachment:n})=>{const i=n.type;switch(i){case"image":return"Image";case"document":return"Document";case"file":return"File";default:{const a=i;throw new Error(`Unknown attachment type: ${a}`)}}});return m.jsxs(ld,{children:[m.jsxs(L.AttachmentPrimitive.Root,{className:T.cn("aui-attachment-root relative",r&&"aui-attachment-root-composer only:[&>#attachment-tile]:size-24"),children:[m.jsx(I6,{children:m.jsx(cd,{asChild:!0,children:m.jsx("div",{className:T.cn("aui-attachment-tile bg-muted size-14 cursor-pointer overflow-hidden rounded-[14px] border transition-opacity hover:opacity-75",t&&"aui-attachment-tile-composer border-foreground/20"),role:"button",id:"attachment-tile","aria-label":`${o} attachment`,children:m.jsx(k6,{})})})}),t&&m.jsx(E6,{})]}),m.jsx(dd,{side:"top",children:m.jsx(L.AttachmentPrimitive.Name,{})})]})},E6=()=>m.jsx(L.AttachmentPrimitive.Remove,{asChild:!0,children:m.jsx(ct,{tooltip:"Remove file",className:"aui-attachment-tile-remove text-muted-foreground hover:[&_svg]:text-destructive absolute top-1.5 right-1.5 size-3.5 rounded-full bg-white opacity-100 shadow-sm hover:!bg-white [&_svg]:text-black",side:"top",children:m.jsx(Eo,{className:"aui-attachment-remove-icon size-3 dark:stroke-[2.5px]"})})}),T6=()=>m.jsx("div",{className:"aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2",children:m.jsx(L.MessagePrimitive.Attachments,{components:{Attachment:FS}})}),O6=()=>m.jsx("div",{className:"aui-composer-attachments mb-2 flex w-full flex-row items-center gap-2 overflow-x-auto px-1.5 pt-0.5 pb-1 empty:hidden",children:m.jsx(L.ComposerPrimitive.Attachments,{components:{Attachment:FS}})}),N6=()=>m.jsx(L.ComposerPrimitive.AddAttachment,{asChild:!0,children:m.jsx(ct,{tooltip:"Add Attachment",side:"top",variant:"ghost",size:"icon",align:"start",className:"aui-composer-add-attachment hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-[34px] rounded-full p-1 text-xs font-semibold","aria-label":"Add Attachment",children:m.jsx(qN,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})});function P6(e){return D.useMemo(()=>e.reduce((t,r)=>(t?.[r.language]&&!r.overrideExisting||(t={...t,[r.language]:{CodeHeader:r.Header??(()=>null),SyntaxHighlighter:r.Component??void 0}}),t),{}),[e])}const C6=()=>{const{plugins:e}=T.useElements(),t=P6(e);return m.jsx(Gs.MarkdownTextPrimitive,{remarkPlugins:[w0],className:"aui-md",components:R6,componentsByLanguage:t})},qS=D.memo(C6),j6=({language:e,code:t})=>{const o=L.useAssistantState(({message:s})=>s).status?.type==="complete",{isCopied:n,copyToClipboard:i}=A6(),a=()=>{!t||n||i(t)};return o?m.jsxs("div",{className:"aui-code-header-root bg-muted-foreground/15 text-foreground dark:bg-muted-foreground/20 mt-4 flex items-center justify-between gap-4 rounded-t-lg px-4 py-2 text-sm font-semibold",children:[m.jsx("span",{className:"aui-code-header-language lowercase [&>span]:text-xs",children:e}),m.jsxs(ct,{tooltip:"Copy",onClick:a,children:[!n&&m.jsx(Pc,{}),n&&m.jsx(nr,{})]})]}):null},A6=({copiedDuration:e=3e3}={})=>{const[t,r]=D.useState(!1);return{isCopied:t,copyToClipboard:n=>{n&&navigator.clipboard.writeText(n).then(()=>{r(!0),setTimeout(()=>r(!1),e)})}}},R6=Gs.unstable_memoizeMarkdownComponents({h1:({className:e,...t})=>m.jsx("h1",{className:T.cn("aui-md-h1 mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0",e),...t}),h2:({className:e,...t})=>m.jsx("h2",{className:T.cn("aui-md-h2 mt-8 mb-4 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h3:({className:e,...t})=>m.jsx("h3",{className:T.cn("aui-md-h3 mt-6 mb-4 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h4:({className:e,...t})=>m.jsx("h4",{className:T.cn("aui-md-h4 mt-6 mb-4 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h5:({className:e,...t})=>m.jsx("h5",{className:T.cn("aui-md-h5 my-4 text-lg font-semibold first:mt-0 last:mb-0",e),...t}),h6:({className:e,...t})=>m.jsx("h6",{className:T.cn("aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0",e),...t}),p:({className:e,...t})=>m.jsx("p",{className:T.cn("aui-md-p mt-5 mb-5 leading-7 first:mt-0 last:mb-0",e),...t}),a:({className:e,...t})=>m.jsx("a",{className:T.cn("aui-md-a text-primary font-medium underline underline-offset-4",e),...t}),blockquote:({className:e,...t})=>m.jsx("blockquote",{className:T.cn("aui-md-blockquote border-l-2 pl-6 italic",e),...t}),ul:({className:e,...t})=>m.jsx("ul",{className:T.cn("aui-md-ul my-5 ml-6 list-disc [&>li]:mt-2",e),...t}),ol:({className:e,...t})=>m.jsx("ol",{className:T.cn("aui-md-ol my-5 ml-6 list-decimal [&>li]:mt-2",e),...t}),hr:({className:e,...t})=>m.jsx("hr",{className:T.cn("aui-md-hr my-5 border-b",e),...t}),table:({className:e,...t})=>m.jsx("table",{className:T.cn("aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto",e),...t}),th:({className:e,...t})=>m.jsx("th",{className:T.cn("aui-md-th bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [[align=center]]:text-center [[align=right]]:text-right",e),...t}),td:({className:e,...t})=>m.jsx("td",{className:T.cn("aui-md-td border-b border-l px-4 py-2 text-left last:border-r [[align=center]]:text-center [[align=right]]:text-right",e),...t}),tr:({className:e,...t})=>m.jsx("tr",{className:T.cn("aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",e),...t}),sup:({className:e,...t})=>m.jsx("sup",{className:T.cn("aui-md-sup [&>a]:text-xs [&>a]:no-underline",e),...t}),pre:({className:e,...t})=>m.jsx("pre",{className:T.cn("aui-md-pre text-foreground bg-muted overflow-x-auto rounded-t-none! rounded-b-lg border border-t-0 p-4",e),...t}),code:function({className:t,...r}){const o=Gs.useIsMarkdownCodeBlock();return m.jsx("code",{className:T.cn(!o&&"aui-md-inline-code bg-muted rounded border font-semibold",t),...r})},CodeHeader:j6});var as="Collapsible",[z6]=Po(as),[M6,bd]=z6(as),VS=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,open:o,defaultOpen:n,disabled:i,onOpenChange:a,...s}=e,[l,u]=ts({prop:o,defaultProp:n??!1,onChange:a,caller:as});return m.jsx(M6,{scope:r,disabled:i,contentId:qr(),open:l,onOpenToggle:_.useCallback(()=>u(c=>!c),[u]),children:m.jsx(Ce.div,{"data-state":wd(l),"data-disabled":i?"":void 0,...s,ref:t})})});VS.displayName=as;var BS="CollapsibleTrigger",JS=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,...o}=e,n=bd(BS,r);return m.jsx(Ce.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":wd(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...o,ref:t,onClick:Oe(e.onClick,n.onOpenToggle)})});JS.displayName=BS;var _d="CollapsibleContent",WS=_.forwardRef((e,t)=>{const{forceMount:r,...o}=e,n=bd(_d,e.__scopeCollapsible);return m.jsx(Gt,{present:r||n.open,children:({present:i})=>m.jsx(D6,{...o,ref:t,present:i})})});WS.displayName=_d;var D6=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,present:o,children:n,...i}=e,a=bd(_d,r),[s,l]=_.useState(o),u=_.useRef(null),c=Ge(t,u),d=_.useRef(0),f=d.current,p=_.useRef(0),g=p.current,h=a.open||s,b=_.useRef(h),y=_.useRef(void 0);return _.useEffect(()=>{const x=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(x)},[]),lt(()=>{const x=u.current;if(x){y.current=y.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const $=x.getBoundingClientRect();d.current=$.height,p.current=$.width,b.current||(x.style.transitionDuration=y.current.transitionDuration,x.style.animationName=y.current.animationName),l(o)}},[a.open,o]),m.jsx(Ce.div,{"data-state":wd(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!h,...i,ref:c,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:h&&n})});function wd(e){return e?"open":"closed"}var U6=VS;function L6({...e}){return m.jsx(U6,{"data-slot":"collapsible",...e})}function Z6({...e}){return m.jsx(JS,{"data-slot":"collapsible-trigger",...e})}function F6({...e}){return m.jsx(WS,{"data-slot":"collapsible-content",...e})}const im=200,HS=({className:e,children:t})=>{const r=D.useRef(null),[o,n]=D.useState(!1),i=L.useScrollLock(r,im),a=D.useCallback(s=>{s||i(),n(s)},[i]);return m.jsx(L6,{ref:r,open:o,onOpenChange:a,className:T.cn("aui-reasoning-root mb-4 w-full",e),style:{"--animation-duration":`${im}ms`},children:t})};HS.displayName="ReasoningRoot";const q6=({className:e})=>m.jsx("div",{className:T.cn("aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-16","bg-[linear-gradient(to_top,var(--color-background),transparent)]","fade-in-0 animate-in","group-data-[state=open]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:delay-[calc(var(--animation-duration)*0.75)]","group-data-[state=open]/collapsible-content:fill-mode-forwards","duration-(--animation-duration)","group-data-[state=open]/collapsible-content:duration-(--animation-duration)",e)}),V6=({active:e,className:t})=>m.jsxs(Z6,{className:T.cn("aui-reasoning-trigger group/trigger text-muted-foreground hover:text-foreground -mb-2 flex max-w-[75%] items-center gap-2 py-2 text-sm transition-colors",t,e&&"shimmer"),children:[m.jsx(_N,{className:"aui-reasoning-trigger-icon size-4 shrink-0"}),m.jsxs("span",{className:"aui-reasoning-trigger-label-wrapper relative inline-block leading-none",children:[m.jsx("span",{children:"Reasoning"}),e?m.jsx("span",{"aria-hidden":!0,className:"aui-reasoning-trigger-shimmer shimmer pointer-events-none absolute inset-0 motion-reduce:animate-none",children:"Reasoning"}):null]}),m.jsx(Ei,{className:T.cn("aui-reasoning-trigger-chevron mt-0.5 size-4 shrink-0","transition-transform duration-(--animation-duration) ease-out","group-data-[state=closed]/trigger:-rotate-90","group-data-[state=open]/trigger:rotate-0")})]}),GS=({className:e,children:t,"aria-busy":r})=>m.jsxs(F6,{className:T.cn("aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none","group/collapsible-content ease-out","data-[state=closed]:animate-collapsible-up","data-[state=open]:animate-collapsible-down","data-[state=closed]:fill-mode-forwards","data-[state=closed]:pointer-events-none","data-[state=open]:duration-(--animation-duration)","data-[state=closed]:duration-(--animation-duration)",e),"aria-busy":r,children:[t,m.jsx(q6,{})]});GS.displayName="ReasoningContent";const KS=({className:e,children:t})=>m.jsx("div",{className:T.cn("aui-reasoning-text relative z-0 space-y-4 pt-4 pl-6 leading-relaxed","transform-gpu transition-[transform,opacity]","group-data-[state=open]/collapsible-content:animate-in","group-data-[state=closed]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-in-0","group-data-[state=closed]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:slide-in-from-top-4","group-data-[state=closed]/collapsible-content:slide-out-to-top-4","group-data-[state=open]/collapsible-content:duration-(--animation-duration)","group-data-[state=closed]/collapsible-content:duration-(--animation-duration)","[&_p]:-mb-2",e),children:t});KS.displayName="ReasoningText";const B6=()=>m.jsx(qS,{}),J6=({children:e,startIndex:t,endIndex:r})=>{const o=L.useAssistantState(({message:n})=>{if(n.status?.type!=="running")return!1;const i=n.parts.length-1;return i<0||n.parts[i]?.type!=="reasoning"?!1:i>=t&&i<=r});return m.jsxs(HS,{children:[m.jsx(V6,{active:o}),m.jsx(GS,{"aria-busy":o,children:m.jsx(KS,{children:e})})]})},YS=D.memo(B6);YS.displayName="Reasoning";const QS=D.memo(J6);QS.displayName="ReasoningGroup";var ss="Popover",[XS]=Po(ss,[Xa]),Ao=Xa(),[W6,pr]=XS(ss),e0=e=>{const{__scopePopover:t,children:r,open:o,defaultOpen:n,onOpenChange:i,modal:a=!1}=e,s=Ao(t),l=_.useRef(null),[u,c]=_.useState(!1),[d,f]=ts({prop:o,defaultProp:n??!1,onChange:i,caller:ss});return m.jsx(B$,{...s,children:m.jsx(W6,{scope:t,contentId:qr(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:_.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:u,onCustomAnchorAdd:_.useCallback(()=>c(!0),[]),onCustomAnchorRemove:_.useCallback(()=>c(!1),[]),modal:a,children:r})})};e0.displayName=ss;var t0="PopoverAnchor",H6=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(t0,r),i=Ao(r),{onCustomAnchorAdd:a,onCustomAnchorRemove:s}=n;return _.useEffect(()=>(a(),()=>s()),[a,s]),m.jsx(ad,{...i,...o,ref:t})});H6.displayName=t0;var r0="PopoverTrigger",n0=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(r0,r),i=Ao(r),a=Ge(t,n.triggerRef),s=m.jsx(Ce.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":u0(n.open),...o,ref:a,onClick:Oe(e.onClick,n.onOpenToggle)});return n.hasCustomAnchor?s:m.jsx(ad,{asChild:!0,...i,children:s})});n0.displayName=r0;var xd="PopoverPortal",[G6,K6]=XS(xd,{forceMount:void 0}),o0=e=>{const{__scopePopover:t,forceMount:r,children:o,container:n}=e,i=pr(xd,t);return m.jsx(G6,{scope:t,forceMount:r,children:m.jsx(Gt,{present:r||i.open,children:m.jsx(es,{asChild:!0,container:n,children:o})})})};o0.displayName=xd;var an="PopoverContent",i0=_.forwardRef((e,t)=>{const r=K6(an,e.__scopePopover),{forceMount:o=r.forceMount,...n}=e,i=pr(an,e.__scopePopover);return m.jsx(Gt,{present:o||i.open,children:i.modal?m.jsx(Q6,{...n,ref:t}):m.jsx(X6,{...n,ref:t})})});i0.displayName=an;var Y6=Kc("PopoverContent.RemoveScroll"),Q6=_.forwardRef((e,t)=>{const r=pr(an,e.__scopePopover),o=_.useRef(null),n=Ge(t,o),i=_.useRef(!1);return _.useEffect(()=>{const a=o.current;if(a)return hS(a)},[]),m.jsx(fd,{as:Y6,allowPinchZoom:!0,children:m.jsx(a0,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,a=>{a.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Oe(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0,u=s.button===2||l;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Oe(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),X6=_.forwardRef((e,t)=>{const r=pr(an,e.__scopePopover),o=_.useRef(!1),n=_.useRef(!1);return m.jsx(a0,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||r.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,n.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const a=i.target;r.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&n.current&&i.preventDefault()}})}),a0=_.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:o,onOpenAutoFocus:n,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:c,...d}=e,f=pr(an,r),p=Ao(r);return aS(),m.jsx(pd,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:n,onUnmountAutoFocus:i,children:m.jsx(Ga,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:c,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>f.onOpenChange(!1),children:m.jsx(J$,{"data-state":u0(f.open),role:"dialog",id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),s0="PopoverClose",e2=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(s0,r);return m.jsx(Ce.button,{type:"button",...o,ref:t,onClick:Oe(e.onClick,()=>n.onOpenChange(!1))})});e2.displayName=s0;var t2="PopoverArrow",r2=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=Ao(r);return m.jsx(W$,{...n,...o,ref:t})});r2.displayName=t2;function u0(e){return e?"open":"closed"}var n2=e0,o2=n0,i2=o0,a2=i0;function l0({...e}){return m.jsx(n2,{"data-slot":"popover",...e})}function c0({...e}){return m.jsx(o2,{"data-slot":"popover-trigger",...e})}function d0({className:e,align:t="center",sideOffset:r=4,...o}){return m.jsx(i2,{children:m.jsx(a2,{"data-slot":"popover-content",align:t,sideOffset:r,className:T.cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...o})})}const s2=LS("flex size-5 items-center justify-center rounded-full",{variants:{status:{pending:"border border-dashed border-muted-foreground/50",running:"text-primary",complete:"text-green-600 dark:text-green-500",error:"text-destructive",approval:"text-amber-500"}},defaultVariants:{status:"pending"}});function u2(e){switch(e){case"text/markdown":return"markdown";case"text/html":return"html";case"text/css":return"css";case"application/json":return"json";case"text/javascript":return"javascript";case"text/typescript":return"typescript";case"text/python":return"python";default:return}}function l2(e,t){if(t==="json")try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}return e}function c2(e){return typeof e=="object"&&e!==null&&"content"in e&&Array.isArray(e.content)}function p0({status:e}){return m.jsxs("div",{className:T.cn(s2({status:e})),children:[e==="pending"&&null,e==="running"&&m.jsx(Ti,{className:"size-4 animate-spin"}),e==="complete"&&m.jsx(nr,{className:"size-4"}),e==="error"&&m.jsx(Eo,{className:"size-4"}),e==="approval"&&m.jsx(Ti,{className:"text-muted-foreground size-4 animate-spin"})]})}function d2({content:e}){const[t,r]=D.useState(!1),o=async n=>{n.stopPropagation(),await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)};return m.jsx("button",{onClick:o,className:"text-muted-foreground hover:bg-accent hover:text-foreground rounded p-1 transition-colors","aria-label":"Copy to clipboard",children:t?m.jsx(nr,{className:"size-4"}):m.jsx(Pc,{className:"size-4"})})}function f0({text:e,language:t,className:r}){const[o,n]=D.useState(null);return D.useEffect(()=>{t&&x0.codeToHtml(e,{lang:t,theme:"github-dark-default",rootStyle:"background-color: transparent;",transformers:[{pre(i){i.properties.class="w-full py-3 px-4 max-h-[300px] overflow-y-auto whitespace-pre-wrap text-left text-sm"}}]}).then(n)},[e,t]),o?m.jsx("div",{className:T.cn("w-full bg-slate-800/90",r),dangerouslySetInnerHTML:{__html:o}}):m.jsx("pre",{className:T.cn("w-full bg-slate-800/90 px-4 py-3 text-sm whitespace-pre-wrap text-slate-100",r),children:e})}function p2({data:e}){const t=`data:image/png;base64,${e}`;return m.jsx("div",{className:"flex items-center justify-center rounded-lg p-5",style:{backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%),
|
|
140
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return _.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},LU="DialogDescriptionWarning",ZU=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${NS(LU).contentName}}.`;return _.useEffect(()=>{const n=e.current?.getAttribute("aria-describedby");t&&n&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},FU=vS,qU=bS,VU=wS,BU=xS,JU=$S,WU=IS,HU=TS;function GU({...e}){return m.jsx(FU,{"data-slot":"dialog",...e})}function KU({...e}){return m.jsx(qU,{"data-slot":"dialog-trigger",...e})}function YU({...e}){return m.jsx(VU,{"data-slot":"dialog-portal",...e})}function QU({className:e,...t}){return m.jsx(BU,{"data-slot":"dialog-overlay",className:T.cn("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function XU({className:e,children:t,showCloseButton:r=!0,...o}){return m.jsxs(YU,{"data-slot":"dialog-portal",children:[m.jsx(QU,{}),m.jsxs(JU,{"data-slot":"dialog-content",className:T.cn("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),...o,children:[t,r&&m.jsxs(HU,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[m.jsx(Eo,{}),m.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function e6({className:e,...t}){return m.jsx(WU,{"data-slot":"dialog-title",className:T.cn("text-lg leading-none font-semibold",e),...t})}function t6(e,t=[]){let r=[];function o(i,a){const s=_.createContext(a);s.displayName=i+"Context";const l=r.length;r=[...r,a];const u=d=>{const{scope:f,children:p,...g}=d,h=f?.[e]?.[l]||s,b=_.useMemo(()=>g,Object.values(g));return m.jsx(h.Provider,{value:b,children:p})};u.displayName=i+"Provider";function c(d,f){const p=f?.[e]?.[l]||s,g=_.useContext(p);if(g)return g;if(a!==void 0)return a;throw new Error(`\`${d}\` must be used within \`${i}\``)}return[u,c]}const n=()=>{const i=r.map(a=>_.createContext(a));return function(s){const l=s?.[e]||i;return _.useMemo(()=>({[`__scope${e}`]:{...s,[e]:l}}),[s,l])}};return n.scopeName=e,[o,r6(n,...t)]}function r6(...e){const t=e[0];if(e.length===1)return t;const r=()=>{const o=e.map(n=>({useScope:n(),scopeName:n.scopeName}));return function(i){const a=o.reduce((s,{useScope:l,scopeName:u})=>{const d=l(i)[`__scope${u}`];return{...s,...d}},{});return _.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return r.scopeName=t.scopeName,r}var n6=Symbol.for("react.lazy"),Bi=_[" use ".trim().toString()];function o6(e){return typeof e=="object"&&e!==null&&"then"in e}function PS(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===n6&&"_payload"in e&&o6(e._payload)}function CS(e){const t=a6(e),r=_.forwardRef((o,n)=>{let{children:i,...a}=o;PS(i)&&typeof Bi=="function"&&(i=Bi(i._payload));const s=_.Children.toArray(i),l=s.find(l6);if(l){const u=l.props.children,c=s.map(d=>d===l?_.Children.count(u)>1?_.Children.only(null):_.isValidElement(u)?u.props.children:null:d);return m.jsx(t,{...a,ref:n,children:_.isValidElement(u)?_.cloneElement(u,void 0,c):null})}return m.jsx(t,{...a,ref:n,children:i})});return r.displayName=`${e}.Slot`,r}var i6=CS("Slot");function a6(e){const t=_.forwardRef((r,o)=>{let{children:n,...i}=r;if(PS(n)&&typeof Bi=="function"&&(n=Bi(n._payload)),_.isValidElement(n)){const a=d6(n),s=c6(i,n.props);return n.type!==_.Fragment&&(s.ref=o?Gc(o,a):a),_.cloneElement(n,s)}return _.Children.count(n)>1?_.Children.only(null):null});return t.displayName=`${e}.SlotClone`,t}var jS=Symbol("radix.slottable");function s6(e){const t=({children:r})=>m.jsx(m.Fragment,{children:r});return t.displayName=`${e}.Slottable`,t.__radixId=jS,t}var u6=s6("Slottable");function l6(e){return _.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===jS}function c6(e,t){const r={...t};for(const o in t){const n=e[o],i=t[o];/^on[A-Z]/.test(o)?n&&i?r[o]=(...s)=>{const l=i(...s);return n(...s),l}:n&&(r[o]=n):o==="style"?r[o]={...n,...i}:o==="className"&&(r[o]=[n,i].filter(Boolean).join(" "))}return{...e,...r}}function d6(e){let t=Object.getOwnPropertyDescriptor(e.props,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning;return r?e.ref:(t=Object.getOwnPropertyDescriptor(e,"ref")?.get,r=t&&"isReactWarning"in t&&t.isReactWarning,r?e.props.ref:e.props.ref||e.ref)}var p6=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],vd=p6.reduce((e,t)=>{const r=CS(`Primitive.${t}`),o=_.forwardRef((n,i)=>{const{asChild:a,...s}=n,l=a?r:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),m.jsx(l,{...s,ref:i})});return o.displayName=`Primitive.${t}`,{...e,[t]:o}},{});function f6(){return xj.useSyncExternalStore(m6,()=>!0,()=>!1)}function m6(){return()=>{}}var yd="Avatar",[h6]=t6(yd),[g6,AS]=h6(yd),RS=_.forwardRef((e,t)=>{const{__scopeAvatar:r,...o}=e,[n,i]=_.useState("idle");return m.jsx(g6,{scope:r,imageLoadingStatus:n,onImageLoadingStatusChange:i,children:m.jsx(vd.span,{...o,ref:t})})});RS.displayName=yd;var zS="AvatarImage",MS=_.forwardRef((e,t)=>{const{__scopeAvatar:r,src:o,onLoadingStatusChange:n=()=>{},...i}=e,a=AS(zS,r),s=v6(o,i),l=Sr(u=>{n(u),a.onImageLoadingStatusChange(u)});return lt(()=>{s!=="idle"&&l(s)},[s,l]),s==="loaded"?m.jsx(vd.img,{...i,ref:t,src:o}):null});MS.displayName=zS;var DS="AvatarFallback",US=_.forwardRef((e,t)=>{const{__scopeAvatar:r,delayMs:o,...n}=e,i=AS(DS,r),[a,s]=_.useState(o===void 0);return _.useEffect(()=>{if(o!==void 0){const l=window.setTimeout(()=>s(!0),o);return()=>window.clearTimeout(l)}},[o]),a&&i.imageLoadingStatus!=="loaded"?m.jsx(vd.span,{...n,ref:t}):null});US.displayName=DS;function rm(e,t){return e?t?(e.src!==t&&(e.src=t),e.complete&&e.naturalWidth>0?"loaded":"loading"):"error":"idle"}function v6(e,{referrerPolicy:t,crossOrigin:r}){const o=f6(),n=_.useRef(null),i=o?(n.current||(n.current=new window.Image),n.current):null,[a,s]=_.useState(()=>rm(i,e));return lt(()=>{s(rm(i,e))},[i,e]),lt(()=>{const l=d=>()=>{s(d)};if(!i)return;const u=l("loaded"),c=l("error");return i.addEventListener("load",u),i.addEventListener("error",c),t&&(i.referrerPolicy=t),typeof r=="string"&&(i.crossOrigin=r),()=>{i.removeEventListener("load",u),i.removeEventListener("error",c)}},[i,r,t]),a}var y6=RS,b6=MS,_6=US;function w6({className:e,...t}){return m.jsx(y6,{"data-slot":"avatar",className:T.cn("relative flex size-8 shrink-0 overflow-hidden rounded-full",e),...t})}function x6({className:e,...t}){return m.jsx(b6,{"data-slot":"avatar-image",className:T.cn("aspect-square size-full",e),...t})}function $6({className:e,...t}){return m.jsx(_6,{"data-slot":"avatar-fallback",className:T.cn("bg-muted flex size-full items-center justify-center rounded-full",e),...t})}const nm=e=>typeof e=="boolean"?`${e}`:e===0?"0":e,om=T.clsx,LS=(e,t)=>r=>{var o;if(t?.variants==null)return om(e,r?.class,r?.className);const{variants:n,defaultVariants:i}=t,a=Object.keys(n).map(u=>{const c=r?.[u],d=i?.[u];if(c===null)return null;const f=nm(c)||nm(d);return n[u][f]}),s=r&&Object.entries(r).reduce((u,c)=>{let[d,f]=c;return f===void 0||(u[d]=f),u},{}),l=t==null||(o=t.compoundVariants)===null||o===void 0?void 0:o.reduce((u,c)=>{let{class:d,className:f,...p}=c;return Object.entries(p).every(g=>{let[h,b]=g;return Array.isArray(b)?b.includes({...i,...s}[h]):{...i,...s}[h]===b})?[...u,d,f]:u},[]);return om(e,a,l,r?.class,r?.className)},S6=LS("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}}),$t=_.forwardRef(({className:e,variant:t,size:r,asChild:o=!1,...n},i)=>{const a=o?i6:"button";return m.jsx(a,{"data-slot":"button",className:T.cn(S6({variant:t,size:r,className:e})),ref:i,...n})});$t.displayName="Button";const ct=z.forwardRef(({children:e,tooltip:t,side:r="bottom",align:o="center",className:n,...i},a)=>m.jsxs(ld,{children:[m.jsx(cd,{asChild:!0,children:m.jsxs($t,{variant:"ghost",size:"icon",...i,className:T.cn("aui-button-icon size-6 p-1",n),ref:a,children:[m.jsx(u6,{children:e}),m.jsx("span",{className:"aui-sr-only sr-only",children:t})]})}),m.jsx(dd,{side:r,align:o,children:t})]}));ct.displayName="TooltipIconButton";const I6=e=>{const[t,r]=z.useState(void 0);return z.useEffect(()=>{if(!e){r(void 0);return}const o=URL.createObjectURL(e);return r(o),()=>{URL.revokeObjectURL(o)}},[e]),t},ZS=()=>{const{file:e,src:t}=L.useAssistantState(_0.useShallow(({attachment:r})=>{if(r.type!=="image")return{};if(r.file)return{file:r.file};const o=r.content?.filter(n=>n.type==="image")[0]?.image;return o?{src:o}:{}}));return I6(e)??t},k6=({src:e})=>{const[t,r]=z.useState(!1);return m.jsx("img",{src:e,alt:"Image Preview",className:t?"aui-attachment-preview-image-loaded block h-auto max-h-[80vh] w-auto max-w-full object-contain":"aui-attachment-preview-image-loading hidden",onLoad:()=>r(!0)})},E6=({children:e})=>{const t=ZS();return t?m.jsxs(GU,{children:[m.jsx(KU,{className:"aui-attachment-preview-trigger hover:bg-accent/50 cursor-pointer transition-colors",asChild:!0,children:e}),m.jsxs(XU,{className:"aui-attachment-preview-dialog-content [&_svg]:text-background [&>button]:bg-foreground/60 [&>button]:hover:[&_svg]:text-destructive p-2 sm:max-w-3xl [&>button]:rounded-full [&>button]:p-1 [&>button]:opacity-100 [&>button]:!ring-0",children:[m.jsx(e6,{className:"aui-sr-only sr-only",children:"Image Attachment Preview"}),m.jsx("div",{className:"aui-attachment-preview bg-background relative mx-auto flex max-h-[80dvh] w-full items-center justify-center overflow-hidden",children:m.jsx(k6,{src:t})})]})]}):e},T6=()=>{const e=L.useAssistantState(({attachment:r})=>r.type==="image"),t=ZS();return m.jsxs(w6,{className:"aui-attachment-tile-avatar h-full w-full rounded-none",children:[m.jsx(x6,{src:t,alt:"Attachment preview",className:"aui-attachment-tile-image object-cover"}),m.jsx($6,{delayMs:e?200:0,children:m.jsx(ON,{className:"aui-attachment-tile-fallback-icon text-muted-foreground size-8"})})]})},FS=()=>{const t=L.useAssistantApi().attachment.source==="composer",r=L.useAssistantState(({attachment:n})=>n.type==="image"),o=L.useAssistantState(({attachment:n})=>{const i=n.type;switch(i){case"image":return"Image";case"document":return"Document";case"file":return"File";default:{const a=i;throw new Error(`Unknown attachment type: ${a}`)}}});return m.jsxs(ld,{children:[m.jsxs(L.AttachmentPrimitive.Root,{className:T.cn("aui-attachment-root relative",r&&"aui-attachment-root-composer only:[&>#attachment-tile]:size-24"),children:[m.jsx(E6,{children:m.jsx(cd,{asChild:!0,children:m.jsx("div",{className:T.cn("aui-attachment-tile bg-muted size-14 cursor-pointer overflow-hidden rounded-[14px] border transition-opacity hover:opacity-75",t&&"aui-attachment-tile-composer border-foreground/20"),role:"button",id:"attachment-tile","aria-label":`${o} attachment`,children:m.jsx(T6,{})})})}),t&&m.jsx(O6,{})]}),m.jsx(dd,{side:"top",children:m.jsx(L.AttachmentPrimitive.Name,{})})]})},O6=()=>m.jsx(L.AttachmentPrimitive.Remove,{asChild:!0,children:m.jsx(ct,{tooltip:"Remove file",className:"aui-attachment-tile-remove text-muted-foreground hover:[&_svg]:text-destructive absolute top-1.5 right-1.5 size-3.5 rounded-full bg-white opacity-100 shadow-sm hover:!bg-white [&_svg]:text-black",side:"top",children:m.jsx(Eo,{className:"aui-attachment-remove-icon size-3 dark:stroke-[2.5px]"})})}),N6=()=>m.jsx("div",{className:"aui-user-message-attachments-end col-span-full col-start-1 row-start-1 flex w-full flex-row justify-end gap-2",children:m.jsx(L.MessagePrimitive.Attachments,{components:{Attachment:FS}})}),P6=()=>m.jsx("div",{className:"aui-composer-attachments mb-2 flex w-full flex-row items-center gap-2 overflow-x-auto px-1.5 pt-0.5 pb-1 empty:hidden",children:m.jsx(L.ComposerPrimitive.Attachments,{components:{Attachment:FS}})}),C6=()=>m.jsx(L.ComposerPrimitive.AddAttachment,{asChild:!0,children:m.jsx(ct,{tooltip:"Add Attachment",side:"top",variant:"ghost",size:"icon",align:"start",className:"aui-composer-add-attachment hover:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 size-[34px] rounded-full p-1 text-xs font-semibold","aria-label":"Add Attachment",children:m.jsx(VN,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})});function j6(e){return z.useMemo(()=>e.reduce((t,r)=>(t?.[r.language]&&!r.overrideExisting||(t={...t,[r.language]:{CodeHeader:r.Header??(()=>null),SyntaxHighlighter:r.Component??void 0}}),t),{}),[e])}const A6=()=>{const{plugins:e}=T.useElements(),t=j6(e);return m.jsx(Gs.MarkdownTextPrimitive,{remarkPlugins:[w0],className:"aui-md",components:M6,componentsByLanguage:t})},qS=z.memo(A6),R6=({language:e,code:t})=>{const o=L.useAssistantState(({message:s})=>s).status?.type==="complete",{isCopied:n,copyToClipboard:i}=z6(),a=()=>{!t||n||i(t)};return o?m.jsxs("div",{className:"aui-code-header-root bg-muted-foreground/15 text-foreground dark:bg-muted-foreground/20 mt-4 flex items-center justify-between gap-4 rounded-t-lg px-4 py-2 text-sm font-semibold",children:[m.jsx("span",{className:"aui-code-header-language lowercase [&>span]:text-xs",children:e}),m.jsxs(ct,{tooltip:"Copy",onClick:a,children:[!n&&m.jsx(Pc,{}),n&&m.jsx(nr,{})]})]}):null},z6=({copiedDuration:e=3e3}={})=>{const[t,r]=z.useState(!1);return{isCopied:t,copyToClipboard:n=>{n&&navigator.clipboard.writeText(n).then(()=>{r(!0),setTimeout(()=>r(!1),e)})}}},M6=Gs.unstable_memoizeMarkdownComponents({h1:({className:e,...t})=>m.jsx("h1",{className:T.cn("aui-md-h1 mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0",e),...t}),h2:({className:e,...t})=>m.jsx("h2",{className:T.cn("aui-md-h2 mt-8 mb-4 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h3:({className:e,...t})=>m.jsx("h3",{className:T.cn("aui-md-h3 mt-6 mb-4 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h4:({className:e,...t})=>m.jsx("h4",{className:T.cn("aui-md-h4 mt-6 mb-4 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0",e),...t}),h5:({className:e,...t})=>m.jsx("h5",{className:T.cn("aui-md-h5 my-4 text-lg font-semibold first:mt-0 last:mb-0",e),...t}),h6:({className:e,...t})=>m.jsx("h6",{className:T.cn("aui-md-h6 my-4 font-semibold first:mt-0 last:mb-0",e),...t}),p:({className:e,...t})=>m.jsx("p",{className:T.cn("aui-md-p mt-5 mb-5 leading-7 first:mt-0 last:mb-0",e),...t}),a:({className:e,...t})=>m.jsx("a",{className:T.cn("aui-md-a text-primary font-medium underline underline-offset-4",e),...t}),blockquote:({className:e,...t})=>m.jsx("blockquote",{className:T.cn("aui-md-blockquote border-l-2 pl-6 italic",e),...t}),ul:({className:e,...t})=>m.jsx("ul",{className:T.cn("aui-md-ul my-5 ml-6 list-disc [&>li]:mt-2",e),...t}),ol:({className:e,...t})=>m.jsx("ol",{className:T.cn("aui-md-ol my-5 ml-6 list-decimal [&>li]:mt-2",e),...t}),hr:({className:e,...t})=>m.jsx("hr",{className:T.cn("aui-md-hr my-5 border-b",e),...t}),table:({className:e,...t})=>m.jsx("table",{className:T.cn("aui-md-table my-5 w-full border-separate border-spacing-0 overflow-y-auto",e),...t}),th:({className:e,...t})=>m.jsx("th",{className:T.cn("aui-md-th bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [[align=center]]:text-center [[align=right]]:text-right",e),...t}),td:({className:e,...t})=>m.jsx("td",{className:T.cn("aui-md-td border-b border-l px-4 py-2 text-left last:border-r [[align=center]]:text-center [[align=right]]:text-right",e),...t}),tr:({className:e,...t})=>m.jsx("tr",{className:T.cn("aui-md-tr m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",e),...t}),sup:({className:e,...t})=>m.jsx("sup",{className:T.cn("aui-md-sup [&>a]:text-xs [&>a]:no-underline",e),...t}),pre:({className:e,...t})=>m.jsx("pre",{className:T.cn("aui-md-pre text-foreground bg-muted overflow-x-auto rounded-t-none! rounded-b-lg border border-t-0 p-4",e),...t}),code:function({className:t,...r}){const o=Gs.useIsMarkdownCodeBlock();return m.jsx("code",{className:T.cn(!o&&"aui-md-inline-code bg-muted rounded border font-semibold",t),...r})},CodeHeader:R6});var ss="Collapsible",[D6]=Po(ss),[U6,bd]=D6(ss),VS=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,open:o,defaultOpen:n,disabled:i,onOpenChange:a,...s}=e,[l,u]=rs({prop:o,defaultProp:n??!1,onChange:a,caller:ss});return m.jsx(U6,{scope:r,disabled:i,contentId:qr(),open:l,onOpenToggle:_.useCallback(()=>u(c=>!c),[u]),children:m.jsx(Ce.div,{"data-state":wd(l),"data-disabled":i?"":void 0,...s,ref:t})})});VS.displayName=ss;var BS="CollapsibleTrigger",JS=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,...o}=e,n=bd(BS,r);return m.jsx(Ce.button,{type:"button","aria-controls":n.contentId,"aria-expanded":n.open||!1,"data-state":wd(n.open),"data-disabled":n.disabled?"":void 0,disabled:n.disabled,...o,ref:t,onClick:Oe(e.onClick,n.onOpenToggle)})});JS.displayName=BS;var _d="CollapsibleContent",WS=_.forwardRef((e,t)=>{const{forceMount:r,...o}=e,n=bd(_d,e.__scopeCollapsible);return m.jsx(Gt,{present:r||n.open,children:({present:i})=>m.jsx(L6,{...o,ref:t,present:i})})});WS.displayName=_d;var L6=_.forwardRef((e,t)=>{const{__scopeCollapsible:r,present:o,children:n,...i}=e,a=bd(_d,r),[s,l]=_.useState(o),u=_.useRef(null),c=Ge(t,u),d=_.useRef(0),f=d.current,p=_.useRef(0),g=p.current,h=a.open||s,b=_.useRef(h),y=_.useRef(void 0);return _.useEffect(()=>{const x=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(x)},[]),lt(()=>{const x=u.current;if(x){y.current=y.current||{transitionDuration:x.style.transitionDuration,animationName:x.style.animationName},x.style.transitionDuration="0s",x.style.animationName="none";const $=x.getBoundingClientRect();d.current=$.height,p.current=$.width,b.current||(x.style.transitionDuration=y.current.transitionDuration,x.style.animationName=y.current.animationName),l(o)}},[a.open,o]),m.jsx(Ce.div,{"data-state":wd(a.open),"data-disabled":a.disabled?"":void 0,id:a.contentId,hidden:!h,...i,ref:c,style:{"--radix-collapsible-content-height":f?`${f}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:h&&n})});function wd(e){return e?"open":"closed"}var Z6=VS;function F6({...e}){return m.jsx(Z6,{"data-slot":"collapsible",...e})}function q6({...e}){return m.jsx(JS,{"data-slot":"collapsible-trigger",...e})}function V6({...e}){return m.jsx(WS,{"data-slot":"collapsible-content",...e})}const im=200,HS=({className:e,children:t})=>{const r=z.useRef(null),[o,n]=z.useState(!1),i=L.useScrollLock(r,im),a=z.useCallback(s=>{s||i(),n(s)},[i]);return m.jsx(F6,{ref:r,open:o,onOpenChange:a,className:T.cn("aui-reasoning-root mb-4 w-full",e),style:{"--animation-duration":`${im}ms`},children:t})};HS.displayName="ReasoningRoot";const B6=({className:e})=>m.jsx("div",{className:T.cn("aui-reasoning-fade pointer-events-none absolute inset-x-0 bottom-0 z-10 h-16","bg-[linear-gradient(to_top,var(--color-background),transparent)]","fade-in-0 animate-in","group-data-[state=open]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:delay-[calc(var(--animation-duration)*0.75)]","group-data-[state=open]/collapsible-content:fill-mode-forwards","duration-(--animation-duration)","group-data-[state=open]/collapsible-content:duration-(--animation-duration)",e)}),J6=({active:e,className:t})=>m.jsxs(q6,{className:T.cn("aui-reasoning-trigger group/trigger text-muted-foreground hover:text-foreground -mb-2 flex max-w-[75%] items-center gap-2 py-2 text-sm transition-colors",t,e&&"shimmer"),children:[m.jsx(wN,{className:"aui-reasoning-trigger-icon size-4 shrink-0"}),m.jsxs("span",{className:"aui-reasoning-trigger-label-wrapper relative inline-block leading-none",children:[m.jsx("span",{children:"Reasoning"}),e?m.jsx("span",{"aria-hidden":!0,className:"aui-reasoning-trigger-shimmer shimmer pointer-events-none absolute inset-0 motion-reduce:animate-none",children:"Reasoning"}):null]}),m.jsx(Ti,{className:T.cn("aui-reasoning-trigger-chevron mt-0.5 size-4 shrink-0","transition-transform duration-(--animation-duration) ease-out","group-data-[state=closed]/trigger:-rotate-90","group-data-[state=open]/trigger:rotate-0")})]}),GS=({className:e,children:t,"aria-busy":r})=>m.jsxs(V6,{className:T.cn("aui-reasoning-content text-muted-foreground relative overflow-hidden text-sm outline-none","group/collapsible-content ease-out","data-[state=closed]:animate-collapsible-up","data-[state=open]:animate-collapsible-down","data-[state=closed]:fill-mode-forwards","data-[state=closed]:pointer-events-none","data-[state=open]:duration-(--animation-duration)","data-[state=closed]:duration-(--animation-duration)",e),"aria-busy":r,children:[t,m.jsx(B6,{})]});GS.displayName="ReasoningContent";const KS=({className:e,children:t})=>m.jsx("div",{className:T.cn("aui-reasoning-text relative z-0 space-y-4 pt-4 pl-6 leading-relaxed","transform-gpu transition-[transform,opacity]","group-data-[state=open]/collapsible-content:animate-in","group-data-[state=closed]/collapsible-content:animate-out","group-data-[state=open]/collapsible-content:fade-in-0","group-data-[state=closed]/collapsible-content:fade-out-0","group-data-[state=open]/collapsible-content:slide-in-from-top-4","group-data-[state=closed]/collapsible-content:slide-out-to-top-4","group-data-[state=open]/collapsible-content:duration-(--animation-duration)","group-data-[state=closed]/collapsible-content:duration-(--animation-duration)","[&_p]:-mb-2",e),children:t});KS.displayName="ReasoningText";const W6=()=>m.jsx(qS,{}),H6=({children:e,startIndex:t,endIndex:r})=>{const o=L.useAssistantState(({message:n})=>{if(n.status?.type!=="running")return!1;const i=n.parts.length-1;return i<0||n.parts[i]?.type!=="reasoning"?!1:i>=t&&i<=r});return m.jsxs(HS,{children:[m.jsx(J6,{active:o}),m.jsx(GS,{"aria-busy":o,children:m.jsx(KS,{children:e})})]})},YS=z.memo(W6);YS.displayName="Reasoning";const QS=z.memo(H6);QS.displayName="ReasoningGroup";var us="Popover",[XS]=Po(us,[es]),Ao=es(),[G6,pr]=XS(us),e0=e=>{const{__scopePopover:t,children:r,open:o,defaultOpen:n,onOpenChange:i,modal:a=!1}=e,s=Ao(t),l=_.useRef(null),[u,c]=_.useState(!1),[d,f]=rs({prop:o,defaultProp:n??!1,onChange:i,caller:us});return m.jsx(B$,{...s,children:m.jsx(G6,{scope:t,contentId:qr(),triggerRef:l,open:d,onOpenChange:f,onOpenToggle:_.useCallback(()=>f(p=>!p),[f]),hasCustomAnchor:u,onCustomAnchorAdd:_.useCallback(()=>c(!0),[]),onCustomAnchorRemove:_.useCallback(()=>c(!1),[]),modal:a,children:r})})};e0.displayName=us;var t0="PopoverAnchor",K6=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(t0,r),i=Ao(r),{onCustomAnchorAdd:a,onCustomAnchorRemove:s}=n;return _.useEffect(()=>(a(),()=>s()),[a,s]),m.jsx(ad,{...i,...o,ref:t})});K6.displayName=t0;var r0="PopoverTrigger",n0=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(r0,r),i=Ao(r),a=Ge(t,n.triggerRef),s=m.jsx(Ce.button,{type:"button","aria-haspopup":"dialog","aria-expanded":n.open,"aria-controls":n.contentId,"data-state":u0(n.open),...o,ref:a,onClick:Oe(e.onClick,n.onOpenToggle)});return n.hasCustomAnchor?s:m.jsx(ad,{asChild:!0,...i,children:s})});n0.displayName=r0;var xd="PopoverPortal",[Y6,Q6]=XS(xd,{forceMount:void 0}),o0=e=>{const{__scopePopover:t,forceMount:r,children:o,container:n}=e,i=pr(xd,t);return m.jsx(Y6,{scope:t,forceMount:r,children:m.jsx(Gt,{present:r||i.open,children:m.jsx(ts,{asChild:!0,container:n,children:o})})})};o0.displayName=xd;var an="PopoverContent",i0=_.forwardRef((e,t)=>{const r=Q6(an,e.__scopePopover),{forceMount:o=r.forceMount,...n}=e,i=pr(an,e.__scopePopover);return m.jsx(Gt,{present:o||i.open,children:i.modal?m.jsx(e2,{...n,ref:t}):m.jsx(t2,{...n,ref:t})})});i0.displayName=an;var X6=Kc("PopoverContent.RemoveScroll"),e2=_.forwardRef((e,t)=>{const r=pr(an,e.__scopePopover),o=_.useRef(null),n=Ge(t,o),i=_.useRef(!1);return _.useEffect(()=>{const a=o.current;if(a)return hS(a)},[]),m.jsx(fd,{as:X6,allowPinchZoom:!0,children:m.jsx(a0,{...e,ref:n,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Oe(e.onCloseAutoFocus,a=>{a.preventDefault(),i.current||r.triggerRef.current?.focus()}),onPointerDownOutside:Oe(e.onPointerDownOutside,a=>{const s=a.detail.originalEvent,l=s.button===0&&s.ctrlKey===!0,u=s.button===2||l;i.current=u},{checkForDefaultPrevented:!1}),onFocusOutside:Oe(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),t2=_.forwardRef((e,t)=>{const r=pr(an,e.__scopePopover),o=_.useRef(!1),n=_.useRef(!1);return m.jsx(a0,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{e.onCloseAutoFocus?.(i),i.defaultPrevented||(o.current||r.triggerRef.current?.focus(),i.preventDefault()),o.current=!1,n.current=!1},onInteractOutside:i=>{e.onInteractOutside?.(i),i.defaultPrevented||(o.current=!0,i.detail.originalEvent.type==="pointerdown"&&(n.current=!0));const a=i.target;r.triggerRef.current?.contains(a)&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&n.current&&i.preventDefault()}})}),a0=_.forwardRef((e,t)=>{const{__scopePopover:r,trapFocus:o,onOpenAutoFocus:n,onCloseAutoFocus:i,disableOutsidePointerEvents:a,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:u,onInteractOutside:c,...d}=e,f=pr(an,r),p=Ao(r);return aS(),m.jsx(pd,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:n,onUnmountAutoFocus:i,children:m.jsx(Ka,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:c,onEscapeKeyDown:s,onPointerDownOutside:l,onFocusOutside:u,onDismiss:()=>f.onOpenChange(!1),children:m.jsx(J$,{"data-state":u0(f.open),role:"dialog",id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),s0="PopoverClose",r2=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=pr(s0,r);return m.jsx(Ce.button,{type:"button",...o,ref:t,onClick:Oe(e.onClick,()=>n.onOpenChange(!1))})});r2.displayName=s0;var n2="PopoverArrow",o2=_.forwardRef((e,t)=>{const{__scopePopover:r,...o}=e,n=Ao(r);return m.jsx(W$,{...n,...o,ref:t})});o2.displayName=n2;function u0(e){return e?"open":"closed"}var i2=e0,a2=n0,s2=o0,u2=i0;function l0({...e}){return m.jsx(i2,{"data-slot":"popover",...e})}function c0({...e}){return m.jsx(a2,{"data-slot":"popover-trigger",...e})}function d0({className:e,align:t="center",sideOffset:r=4,...o}){return m.jsx(s2,{children:m.jsx(u2,{"data-slot":"popover-content",align:t,sideOffset:r,className:T.cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-20 w-72 origin-(--radix-popover-content-transform-origin) rounded-md border p-4 shadow-md outline-hidden",e),...o})})}const l2=LS("flex size-5 items-center justify-center rounded-full",{variants:{status:{pending:"border border-dashed border-muted-foreground/50",running:"text-primary",complete:"text-green-600 dark:text-green-500",error:"text-destructive",approval:"text-amber-500"}},defaultVariants:{status:"pending"}});function c2(e){switch(e){case"text/markdown":return"markdown";case"text/html":return"html";case"text/css":return"css";case"application/json":return"json";case"text/javascript":return"javascript";case"text/typescript":return"typescript";case"text/python":return"python";default:return}}function d2(e,t){if(t==="json")try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}return e}function p2(e){return typeof e=="object"&&e!==null&&"content"in e&&Array.isArray(e.content)}function p0({status:e}){return m.jsxs("div",{className:T.cn(l2({status:e})),children:[e==="pending"&&null,e==="running"&&m.jsx(Oi,{className:"size-4 animate-spin"}),e==="complete"&&m.jsx(nr,{className:"size-4"}),e==="error"&&m.jsx(Eo,{className:"size-4"}),e==="approval"&&m.jsx(Oi,{className:"text-muted-foreground size-4 animate-spin"})]})}function f2({content:e}){const[t,r]=z.useState(!1),o=async n=>{n.stopPropagation(),await navigator.clipboard.writeText(e),r(!0),setTimeout(()=>r(!1),2e3)};return m.jsx("button",{onClick:o,className:"text-muted-foreground hover:bg-accent hover:text-foreground rounded p-1 transition-colors","aria-label":"Copy to clipboard",children:t?m.jsx(nr,{className:"size-4"}):m.jsx(Pc,{className:"size-4"})})}function f0({text:e,language:t,className:r}){const[o,n]=z.useState(null);return z.useEffect(()=>{t&&x0.codeToHtml(e,{lang:t,theme:"github-dark-default",rootStyle:"background-color: transparent;",transformers:[{pre(i){i.properties.class="w-full py-3 px-4 max-h-[300px] overflow-y-auto whitespace-pre-wrap text-left text-sm"}}]}).then(n)},[e,t]),o?m.jsx("div",{className:T.cn("w-full bg-slate-800/90",r),dangerouslySetInnerHTML:{__html:o}}):m.jsx("pre",{className:T.cn("w-full bg-slate-800/90 px-4 py-3 text-sm whitespace-pre-wrap text-slate-100",r),children:e})}function m2({data:e}){const t=`data:image/png;base64,${e}`;return m.jsx("div",{className:"flex items-center justify-center rounded-lg p-5",style:{backgroundImage:`linear-gradient(45deg, #ccc 25%, transparent 25%),
|
|
141
141
|
linear-gradient(135deg, #ccc 25%, transparent 25%),
|
|
142
142
|
linear-gradient(45deg, transparent 75%, #ccc 75%),
|
|
143
|
-
linear-gradient(135deg, transparent 75%, #ccc 75%)`,backgroundSize:"25px 25px",backgroundPosition:"0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px"},children:m.jsx("img",{src:t,className:"max-h-[300px] max-w-full object-contain"})})}function f2({content:e}){return m.jsx("div",{className:"w-full",children:e.content.map((t,r)=>{switch(t.type){case"text":{const o=u2(t._meta?.["getgram.ai/mime-type"]??"text/plain"),n=l2(t.text,o);return m.jsx(f0,{text:n,language:o},r)}case"image":return m.jsx(p2,{data:t.data},r);default:return m.jsx("pre",{className:"px-4 py-3 text-sm whitespace-pre-wrap",children:JSON.stringify(t,null,2)},r)}})})}function am({title:e,content:t,defaultExpanded:r=!1,highlightSyntax:o=!0,language:n="json"}){const[i,a]=D.useState(r),s=c2(t),l=s?JSON.stringify(t,null,2):typeof t=="string"?t:JSON.stringify(t,null,2);return m.jsxs("div",{"data-slot":"tool-ui-section",className:"border-border border-t",children:[m.jsxs("button",{onClick:()=>a(!i),className:"hover:bg-accent/50 flex w-full cursor-pointer items-center justify-between px-4 py-2.5 text-left transition-colors",children:[m.jsx("span",{className:"text-muted-foreground text-sm",children:e}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(d2,{content:l}),m.jsx(W_,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",i&&"rotate-90")})]})]}),i&&m.jsx("div",{className:"border-border border-t",children:s?m.jsx(f2,{content:t}):o?m.jsx(f0,{text:l,language:n}):m.jsx("pre",{className:"text-foreground overflow-x-auto px-4 py-3 text-sm whitespace-pre-wrap",children:l})})]})}function m2({name:e,icon:t,provider:r,status:o="complete",request:n,result:i,defaultExpanded:a=!1,className:s,onApproveOnce:l,onApproveForSession:u,onDeny:c}){const d=o==="approval"&&l!==void 0&&c!==void 0,[f,p]=D.useState(a),g=n!==void 0||i!==void 0,[h,b]=D.useState("one-time"),[y,x]=D.useState(!1);D.useEffect(()=>{!d&&f&&!a&&p(!1)},[d]);const $=()=>{h==="for-session"&&u?u():l&&l()};return m.jsxs("div",{"data-slot":"tool-ui",className:T.cn("border-border bg-card overflow-hidden rounded-lg border",s),children:[r&&m.jsxs("div",{"data-slot":"tool-ui-provider",className:T.cn("border-border flex items-center gap-2 border-b px-4 py-2.5"),children:[t?m.jsx("span",{className:"flex size-5 items-center justify-center",children:t}):m.jsx("span",{className:"bg-muted flex size-5 items-center justify-center rounded text-xs font-medium",children:r.charAt(0).toUpperCase()}),m.jsx("span",{className:"text-sm font-medium",children:r})]}),m.jsxs("button",{onClick:()=>g&&p(!f),disabled:!g,className:T.cn("flex w-full items-center gap-2 px-4 py-3 text-left",g&&"hover:bg-accent/50 cursor-pointer transition-colors"),children:[m.jsx(p0,{status:o}),m.jsx("span",{className:T.cn("flex-1 text-sm",!r&&d&&"shimmer"),children:e}),g&&m.jsx(Ei,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",f&&"rotate-180")})]}),f&&g&&m.jsxs("div",{"data-slot":"tool-ui-content",children:[n!==void 0&&m.jsx(am,{title:"Arguments",content:n,highlightSyntax:!0,language:"json"}),i!==void 0&&m.jsx(am,{title:"Output",content:i,highlightSyntax:!0,language:"json"})]}),d&&m.jsxs("div",{"data-slot":"tool-ui-approval-actions",className:"border-border flex items-center justify-end gap-2 border-t px-4 py-3",children:[m.jsx("div",{children:m.jsx("span",{className:"text-muted-foreground text-sm",children:"This tool requires approval"})}),m.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[m.jsxs($t,{variant:"outline",size:"sm",onClick:c,className:"text-destructive hover:bg-destructive/10",children:[m.jsx(Eo,{className:"mr-1 size-3"}),"Deny"]}),m.jsxs("div",{className:"flex items-center",children:[m.jsxs($t,{variant:"default",size:"sm",onClick:$,className:"flex cursor-pointer justify-between gap-1 rounded-r-none bg-emerald-600 hover:bg-emerald-700",children:[m.jsx(nr,{className:"mr-1 size-3"}),m.jsx("span",{className:"min-w-[110px]",children:h==="one-time"?"Approve this time":"Approve always"})]}),m.jsxs(l0,{open:y,onOpenChange:x,children:[m.jsx(c0,{asChild:!0,children:m.jsx($t,{variant:"default",size:"sm",className:"cursor-pointer rounded-l-none border-l border-emerald-700 bg-emerald-600 px-2 hover:bg-emerald-700",children:m.jsx(Ei,{className:"size-3"})})}),m.jsxs(d0,{align:"end",className:"w-64 p-1",sideOffset:4,children:[m.jsxs("button",{onClick:()=>{b("one-time"),x(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[m.jsx(nr,{className:T.cn("relative top-1 mt-0.5 size-3 shrink-0",h!=="one-time"&&"invisible")}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"text-sm",children:"Approve only once"}),m.jsx("span",{className:"text-muted-foreground text-xs",children:"You'll be asked again next time"})]})]}),u&&m.jsxs("button",{onClick:()=>{b("for-session"),x(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[m.jsx(nr,{className:T.cn("relative top-1 mt-0.5 size-3 shrink-0",h!=="for-session"&&"invisible")}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"text-sm",children:"Approve always"}),m.jsx("span",{className:"text-muted-foreground text-xs",children:"Trust this tool for the session"})]})]})]})]})]})]})]})]})}function h2({title:e,icon:t,status:r="complete",defaultExpanded:o=!1,children:n,className:i}){const[a,s]=D.useState(o);return m.jsxs("div",{"data-slot":"tool-ui-group",className:T.cn("border-border bg-card overflow-hidden rounded-lg border",i),children:[m.jsxs("button",{onClick:()=>s(!a),className:"hover:bg-accent/50 flex w-full items-center gap-2 px-4 py-3 text-left transition-colors",children:[t||m.jsx(p0,{status:r==="running"?"running":"complete"}),m.jsx("span",{className:T.cn("flex-1 text-sm font-medium",r==="running"&&"shimmer"),children:e}),m.jsx(Ei,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",a&&"rotate-180")})]}),a&&m.jsx("div",{"data-slot":"tool-ui-group-content",className:"border-border border-t",children:n})]})}const g2=({toolName:e,toolCallId:t,status:r,result:o,args:n})=>{const{pendingApprovals:i,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:l}=J_(),u=i.get(t),d=L.useAssistantState(({message:x})=>x).parts.filter(x=>x.type==="tool-call"),f=d.findIndex(x=>x.toolName===e),p=()=>{s(t)},g=()=>{a(e),s(t)},h=()=>{l(t)},b=()=>u?"approval":r.type==="incomplete"?"error":r.type==="complete"?o&&typeof o=="object"&&"isError"in o&&o.isError?"error":"complete":"running",y=()=>{if(o!==void 0)return typeof o=="object"&&o!==null&&"content"in o&&Array.isArray(o.content)||typeof o=="string",o};return m.jsx("div",{className:T.cn("aui-tool-fallback-root flex w-full flex-col",f!==-1&&f!==d.length-1&&"border-b"),children:m.jsx(m2,{name:e,status:b(),request:n,result:y(),onApproveOnce:u?p:void 0,onApproveForSession:u?g:void 0,onDeny:u?h:void 0,className:"rounded-none border-0"})})},$d=()=>{const{config:e}=T.useElements(),t=e.theme??{};return D.useMemo(()=>{const{colorScheme:r="light"}=t;return{className:r==="dark"||r==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0}},[t])},or=[.23,1,.32,1];function v2(e){return e.replace(/[-_]/g," ").split(/(?=[A-Z])/).join(" ").split(/\s+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const y2=({children:e})=>{const t=L.useAssistantState(({message:s})=>s).parts,r=t.filter(s=>s.type==="tool-call"),o=r.some(s=>s.status?.type==="running"),{config:n}=T.useElements(),i=n.tools?.expandToolGroupsByDefault??!1,a=D.useMemo(()=>{const s=t.filter(l=>l.type==="tool-call");return s.length===0?"No tools called":s.length===1?`Calling ${v2(s[0].toolName)}...`:o?`Calling ${s.length} tools...`:`Executed ${s.length} tools`},[t,o]);return n.tools?.components?.[r[0]?.toolName]?e:r.length===1?m.jsx("div",{className:T.cn("my-4 w-full max-w-xl"),children:m.jsx("div",{className:"border-border bg-card overflow-hidden rounded-lg border",children:e})}):m.jsx("div",{className:"my-4 w-full max-w-xl",children:m.jsx(h2,{title:a,status:o?"running":"complete",defaultExpanded:i,children:e})})},b2=()=>m.jsxs("div",{className:"m-2 rounded-md border border-amber-500 bg-amber-100 px-4 py-3 text-sm text-amber-800 dark:border-amber-600 dark:bg-amber-900/30 dark:text-amber-200",children:[m.jsx("strong",{children:"Warning:"})," You are using an API key directly in the client. Please"," ",m.jsx("a",{href:"https://github.com/speakeasy-api/gram/tree/main/elements#setting-up-your-backend",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-800 dark:text-amber-300 dark:hover:text-amber-200",children:"set up a session endpoint"})," ","before deploying to production."]}),Sd=()=>{const e=$d(),t=T.useDensity(),{config:r}=T.useElements(),o=r.components??{},n=r.api&&"UNSAFE_apiKey"in r.api;return m.jsx(Zt.LazyMotion,{features:Zt.domAnimation,children:m.jsx(Zt.MotionConfig,{reducedMotion:"user",children:m.jsx(L.ThreadPrimitive.Root,{className:T.cn("aui-root aui-thread-root bg-background @container flex h-full flex-col",e.className),children:m.jsxs(L.ThreadPrimitive.Viewport,{className:T.cn("aui-thread-viewport relative mx-auto flex w-full flex-1 flex-col overflow-x-auto overflow-y-scroll pb-0!",t("p-lg")),children:[m.jsx(L.ThreadPrimitive.If,{empty:!0,children:o.ThreadWelcome?m.jsx(o.ThreadWelcome,{}):m.jsx(w2,{})}),n&&m.jsx(b2,{}),m.jsx(L.ThreadPrimitive.Messages,{components:{UserMessage:o.UserMessage??N2,EditComposer:o.EditComposer??C2,AssistantMessage:o.AssistantMessage??E2}}),m.jsx(L.ThreadPrimitive.If,{empty:!1,children:m.jsx("div",{className:"aui-thread-viewport-spacer min-h-8 grow"})}),m.jsx($2,{})]})})})})},_2=()=>m.jsx(L.ThreadPrimitive.ScrollToBottom,{asChild:!0,children:m.jsx(ct,{tooltip:"Scroll to bottom",variant:"outline",className:"aui-thread-scroll-to-bottom dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible",children:m.jsx(gN,{})})}),w2=()=>{const{config:e}=T.useElements(),t=T.useDensity(),{title:r,subtitle:o}=e.welcome??{},n=e.variant==="standalone";return m.jsxs("div",{className:T.cn("aui-thread-welcome-root my-auto flex w-full grow flex-col",n?"items-center justify-center":"",t("gap-lg")),children:[m.jsx("div",{className:T.cn("aui-thread-welcome-center flex w-full grow flex-col items-center justify-start"),children:m.jsxs("div",{className:T.cn("aui-thread-welcome-message flex flex-col",n?"items-center text-center":"size-full justify-start",t("gap-sm"),!n&&t("py-md")),children:[m.jsx(Lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,ease:or},className:T.cn("aui-thread-welcome-message-motion-1 text-foreground font-semibold",t("text-title")),children:r}),m.jsx(Lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,delay:.05,ease:or},className:T.cn("aui-thread-welcome-message-motion-2 text-muted-foreground/65",t("text-subtitle")),children:o})]})}),m.jsx(x2,{})]})},x2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=T.useDensity(),o=e.welcome?.suggestions??[],n=e.variant==="standalone";return o.length===0?null:m.jsx("div",{className:T.cn("aui-thread-welcome-suggestions w-full",r("gap-md"),r("py-lg"),n?"flex flex-wrap items-center justify-center":o.length===1?"flex":"grid max-w-fit @md:grid-cols-2"),children:o.map((i,a)=>m.jsx(Lt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.25,delay:.03*a,ease:or},className:T.cn("aui-thread-welcome-suggestion-display",!n&&"nth-[n+3]:hidden @md:nth-[n+3]:block"),children:m.jsx(L.ThreadPrimitive.Suggestion,{prompt:i.action,send:!0,asChild:!0,children:m.jsxs($t,{variant:"ghost",className:T.cn("aui-thread-welcome-suggestion dark:hover:bg-accent/60 h-auto w-full border text-left whitespace-break-spaces",r("text-base"),n?`flex-row items-center ${r("gap-sm")} ${r("px-md")} ${r("py-sm")} ${t("full")}`:`w-full flex-1 flex-col flex-wrap items-start justify-start ${r("gap-sm")} ${r("px-lg")} ${r("py-md")} ${t("xl")}`),"aria-label":i.action,children:[m.jsx("span",{className:"aui-thread-welcome-suggestion-text-1 text-foreground text-sm font-medium",children:i.title}),m.jsx("span",{className:"aui-thread-welcome-suggestion-text-2 text-muted-foreground text-sm",children:i.label})]})})},`suggested-action-${i.title}-${a}`))})},$2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=T.useDensity(),o=e.composer??{placeholder:"Send a message...",attachments:!0},n=e.components??{};return n.Composer?m.jsx(n.Composer,{}):m.jsxs("div",{className:T.cn("aui-composer-wrapper bg-background sticky bottom-0 flex w-full flex-col overflow-visible",r("gap-md"),r("py-md"),t("xl")),children:[m.jsx(_2,{}),m.jsxs(L.ComposerPrimitive.Root,{className:T.cn("aui-composer-root group/input-group border-input bg-background has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-ring/5 dark:bg-background relative flex w-full flex-col border px-1 pt-2 shadow-xs transition-[color,box-shadow] outline-none has-[textarea:focus-visible]:ring-1",t("xl")),children:[o.attachments&&m.jsx(O6,{}),m.jsx(L.ComposerPrimitive.Input,{placeholder:o.placeholder,className:T.cn("aui-composer-input placeholder:text-muted-foreground mb-1 max-h-32 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 outline-none focus-visible:ring-0",r("h-input"),r("text-base")),rows:1,autoFocus:!0,"aria-label":"Message input"}),m.jsx(I2,{})]})]})},S2=()=>{const{model:e,setModel:t}=T.useElements(),[r,o]=D.useState(!1),[n,i]=D.useState(!1),a=D.useRef(null),s=D.useRef(0),l=D.useRef(!1);D.useEffect(()=>{r&&!l.current&&requestAnimationFrame(()=>{const c=a.current;c&&c.scrollHeight>0&&(c.scrollTop=s.current)}),l.current=r},[r]),D.useEffect(()=>{r&&i(!1)},[r]);const u=c=>{s.current=c.currentTarget.scrollTop};return m.jsx(oS,{children:m.jsxs(ld,{open:n&&!r,onOpenChange:i,children:[m.jsxs(l0,{open:r,onOpenChange:o,children:[m.jsx(cd,{asChild:!0,children:m.jsx(c0,{asChild:!0,children:m.jsx($t,{variant:"ghost",size:"icon","data-state":r?"open":"closed",className:"aui-composer-model-picker data-[state=open]:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 flex w-fit items-center gap-2 rounded-full px-2.5 py-1 text-xs font-semibold","aria-label":"Model Settings",children:m.jsx(WN,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})})}),m.jsx(d0,{side:"top",align:"start",className:"w-min p-0 shadow-none",children:m.jsx("div",{ref:a,className:"max-h-48 overflow-y-auto",onScroll:u,children:Nc.map(c=>m.jsxs($t,{onClick:()=>{t(c)},variant:"ghost",className:"w-full justify-start gap-2 rounded-none px-2",children:[c===e?m.jsx("div",{children:m.jsx(nr,{className:"size-4 text-emerald-500"})}):m.jsx("div",{className:"size-4",children:" "}),c]},c))})})]}),m.jsx(dd,{side:"bottom",align:"start",children:"Model Settings"})]})})},I2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=e.composer??{attachments:!0};return m.jsxs("div",{className:"aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between",children:[m.jsxs("div",{className:"aui-composer-action-wrapper-inner flex items-center",children:[r.attachments?m.jsx(N6,{}):m.jsx("div",{className:"aui-composer-add-attachment-placeholder"}),e.model?.showModelPicker&&!e.languageModel&&m.jsx(S2,{})]}),m.jsx(L.ThreadPrimitive.If,{running:!1,children:m.jsx(L.ComposerPrimitive.Send,{asChild:!0,children:m.jsx(ct,{tooltip:"Send message",side:"bottom",type:"submit",variant:"default",size:"icon",className:T.cn("aui-composer-send size-[34px] p-1",t("full")),"aria-label":"Send message",children:m.jsx(yN,{className:"aui-composer-send-icon size-5"})})})}),m.jsx(L.ThreadPrimitive.If,{running:!0,children:m.jsx(L.ComposerPrimitive.Cancel,{asChild:!0,children:m.jsx($t,{type:"button",variant:"default",size:"icon",className:T.cn("aui-composer-cancel border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90 size-[34px] border",t("full")),"aria-label":"Stop generating",children:m.jsx(GN,{className:"aui-composer-cancel-icon size-3.5 fill-white dark:fill-black"})})})})]})},k2=()=>m.jsx(L.MessagePrimitive.Error,{children:m.jsx(L.ErrorPrimitive.Root,{className:"aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200",children:m.jsx(L.ErrorPrimitive.Message,{className:"aui-message-error-message line-clamp-2"})})}),E2=()=>{const{config:e}=T.useElements(),t=e.tools??{},r=e.components??{};return m.jsx(L.MessagePrimitive.Root,{asChild:!0,children:m.jsxs("div",{className:"aui-assistant-message-root animate-in fade-in slide-in-from-bottom-1 relative mx-auto w-full py-4 duration-150 ease-out last:mb-24","data-role":"assistant",children:[m.jsxs("div",{className:"aui-assistant-message-content text-foreground mx-2 leading-7 wrap-break-word",children:[m.jsx(L.MessagePrimitive.Parts,{components:{Text:r.Text??qS,Image:r.Image??T2,tools:{by_name:t.components,Fallback:r.ToolFallback??g2},Reasoning:r.Reasoning??YS,ReasoningGroup:r.ReasoningGroup??QS,ToolGroup:r.ToolGroup??y2}}),m.jsx(k2,{})]}),m.jsxs("div",{className:"aui-assistant-message-footer mt-2 ml-2 flex",children:[m.jsx(m0,{}),m.jsx(O2,{})]})]})})},T2=e=>m.jsx("img",{src:e.image}),O2=()=>m.jsxs(L.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",autohideFloat:"single-branch",className:"aui-assistant-action-bar-root text-muted-foreground data-floating:bg-background col-start-3 row-start-2 -ml-1 flex gap-1 data-floating:absolute data-floating:rounded-md data-floating:border data-floating:p-1 data-floating:shadow-sm",children:[m.jsx(L.ActionBarPrimitive.Copy,{asChild:!0,children:m.jsxs(ct,{tooltip:"Copy",children:[m.jsx(L.MessagePrimitive.If,{copied:!0,children:m.jsx(nr,{})}),m.jsx(L.MessagePrimitive.If,{copied:!1,children:m.jsx(Pc,{})})]})}),m.jsx(L.ActionBarPrimitive.Reload,{asChild:!0,children:m.jsx(ct,{tooltip:"Refresh",children:m.jsx(BN,{})})})]}),N2=()=>{const e=T.useRadius();return m.jsx(L.MessagePrimitive.Root,{asChild:!0,children:m.jsxs("div",{className:"aui-user-message-root animate-in fade-in slide-in-from-bottom-1 mx-auto grid w-full auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 px-2 py-4 duration-150 ease-out first:mt-3 last:mb-5 [&:where(>*)]:col-start-2","data-role":"user",children:[m.jsx(T6,{}),m.jsxs("div",{className:"aui-user-message-content-wrapper relative col-start-2 min-w-0",children:[m.jsx("div",{className:T.cn("aui-user-message-content bg-muted text-foreground px-5 py-2.5 wrap-break-word",e("xl")),children:m.jsx(L.MessagePrimitive.Parts,{})}),m.jsx("div",{className:"aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2",children:m.jsx(P2,{})})]}),m.jsx(m0,{className:"aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end"})]})})},P2=()=>m.jsx(L.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",className:"aui-user-action-bar-root flex flex-col items-end",children:m.jsx(L.ActionBarPrimitive.Edit,{asChild:!0,children:m.jsx(ct,{tooltip:"Edit",className:"aui-user-action-edit p-4",children:m.jsx(ZN,{})})})}),C2=()=>m.jsx("div",{className:"aui-edit-composer-wrapper mx-auto flex w-full flex-col gap-4 px-2 first:mt-4",children:m.jsxs(L.ComposerPrimitive.Root,{className:"aui-edit-composer-root bg-muted ml-auto flex w-full max-w-7/8 flex-col rounded-xl",children:[m.jsx(L.ComposerPrimitive.Input,{className:"aui-edit-composer-input text-foreground flex min-h-[60px] w-full resize-none bg-transparent p-4 outline-none",autoFocus:!0}),m.jsxs("div",{className:"aui-edit-composer-footer mx-3 mb-3 flex items-center justify-center gap-2 self-end",children:[m.jsx(L.ComposerPrimitive.Cancel,{asChild:!0,children:m.jsx($t,{variant:"ghost",size:"sm","aria-label":"Cancel edit",children:"Cancel"})}),m.jsx(L.ComposerPrimitive.Send,{asChild:!0,children:m.jsx($t,{size:"sm","aria-label":"Update message",children:"Update"})})]})]})}),m0=({className:e,...t})=>m.jsxs(L.BranchPickerPrimitive.Root,{hideWhenSingleBranch:!0,className:T.cn("aui-branch-picker-root text-muted-foreground mr-2 -ml-2 inline-flex items-center text-xs",e),...t,children:[m.jsx(L.BranchPickerPrimitive.Previous,{asChild:!0,children:m.jsx(ct,{tooltip:"Previous",children:m.jsx(SN,{})})}),m.jsxs("span",{className:"aui-branch-picker-state font-medium",children:[m.jsx(L.BranchPickerPrimitive.Number,{})," / ",m.jsx(L.BranchPickerPrimitive.Count,{})]}),m.jsx(L.BranchPickerPrimitive.Next,{asChild:!0,children:m.jsx(ct,{tooltip:"Next",children:m.jsx(W_,{})})})]}),h0=()=>{const{config:e,isExpanded:t,setIsExpanded:r}=T.useElements(),o=e.modal?.defaultExpanded??!1;return{expandable:e.modal?.expandable??!1,isExpanded:t,setIsExpanded:r,defaultExpanded:o}},j2={layout:{duration:.25,ease:or}},A2=()=>{const{config:e}=T.useElements(),t=$d(),r=T.useRadius(),o=T.useDensity(),[n,i]=D.useState(e.modal?.defaultOpen??!1),{expandable:a,isExpanded:s,setIsExpanded:l}=h0(),u=e.modal?.title,c=e.modal?.icon,d=e.modal?.position??"bottom-right",f=R2(d),p=D.useMemo(()=>e.modal?.dimensions?.default??{width:"500px",height:"600px",maxHeight:"95vh"},[e.modal?.dimensions?.default]),g=D.useMemo(()=>e.modal?.dimensions?.expanded??{width:"70vw",height:"90vh"},[e.modal?.dimensions?.expanded]),b=L.useAssistantState(({thread:v})=>v).messages.some(v=>v.status?.type==="running"),y=s?g.width:p.width,x=s?g.height:p.height,$=p.maxHeight;return m.jsx(Zt.LazyMotion,{features:Zt.domMax,children:m.jsx(Zt.MotionConfig,{reducedMotion:"user",transition:j2,children:m.jsx("div",{className:T.cn("aui-root aui-modal-anchor fixed z-10",f,t.className,r("lg"),n&&"shadow-xl"),children:m.jsx(Zt.AnimatePresence,{mode:"wait",children:n?m.jsxs(Lt.div,{layout:!0,layoutId:"chat-container",className:T.cn("aui-modal-content bg-popover text-popover-foreground flex flex-col overflow-hidden border [&>.aui-thread-root]:bg-inherit",r("lg")),initial:!1,style:{originX:d.includes("left")?0:1,originY:d.includes("top")?0:1,width:y,height:x,maxHeight:$},children:[m.jsxs(Lt.div,{className:T.cn("aui-modal-header flex shrink-0 items-center justify-between border-b",o("h-header"),o("px-lg")),initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1,ease:or},children:[m.jsx("div",{className:T.cn("flex min-w-0 items-center"),children:m.jsxs("span",{className:T.cn("text-md flex items-center gap-2 truncate font-medium",b&&"shimmer"),children:[m.jsx("span",{className:"truncate",children:u}),b&&m.jsx(Ti,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]})}),m.jsxs("div",{className:"flex flex-row items-center justify-end gap-1",children:[a?m.jsx("button",{type:"button",onClick:()=>l(v=>!v),className:T.cn("text-muted-foreground hover:text-foreground hover:bg-accent flex h-8 cursor-pointer items-center rounded-md px-2 text-xs transition-colors"),"aria-pressed":s,"aria-label":s?"Collapse assistant":"Expand assistant",children:s?m.jsx(RN,{strokeWidth:2,className:"size-3.5 rotate-90"}):m.jsx(PN,{strokeWidth:2,className:"size-3.5 rotate-90"})}):null,m.jsx("button",{onClick:()=>{i(!1),l(!1)},className:"text-muted-foreground hover:text-foreground hover:bg-accent -mr-1 flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors","aria-label":`Close ${u}`,children:m.jsx(Eo,{className:"size-4.5"})})]})]}),m.jsx(Lt.div,{className:"aui-modal-thread w-full flex-1 overflow-hidden",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05,ease:or},children:m.jsx(Sd,{})})]},"chat"):m.jsx(Lt.button,{layout:!0,layoutId:"chat-container",onClick:()=>i(!0),className:T.cn("aui-modal-button bg-primary text-primary-foreground flex size-12 cursor-pointer items-center justify-center border shadow-lg transition-shadow hover:shadow-xl",r("full")),initial:!1,"aria-label":`Open ${u}`,style:{originX:1,originY:1},children:m.jsx(Lt.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:or},className:"flex size-full items-center justify-center",children:c?c("closed"):m.jsx(jN,{className:"size-6"})})},"button")})})})})};function R2(e){switch(e){case"bottom-left":return"left-4 bottom-4";case"top-right":return"right-4 top-4";case"top-left":return"left-4 top-4";case"bottom-right":return"right-4 bottom-4";default:T.assertNever(e)}}const z2=()=>{const{config:e}=T.useElements(),t=$d(),r=e.sidecar??{},{title:o,dimensions:n}=r,{isExpanded:i,setIsExpanded:a}=h0(),l=L.useAssistantState(({thread:u})=>u).messages.some(u=>u.status?.type==="running");return m.jsx(Zt.LazyMotion,{features:Zt.domMax,children:m.jsxs(Lt.div,{initial:{width:n?.default?.width??"400px",height:n?.default?.height??"100vh"},animate:{width:i?n?.expanded?.width??"800px":n?.default?.width??"400px",height:i?n?.expanded?.height??"100%":n?.default?.height??"100vh"},transition:{duration:.3,ease:or},className:T.cn("aui-root aui-sidecar bg-popover text-popover-foreground fixed top-0 right-0 border-l",t.className),children:[m.jsxs("div",{className:"aui-sidecar-header flex h-14 items-center justify-between border-b px-4",children:[m.jsxs("span",{className:T.cn("text-md flex items-center gap-2 font-medium",l&&"shimmer"),children:[o,l&&m.jsx(Ti,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]}),m.jsx("div",{className:"aui-sidecar-header-actions flex items-center gap-1",children:m.jsx(ct,{tooltip:i?"Collapse":"Pop out",variant:"ghost",className:"aui-sidecar-popout size-8",onClick:()=>a(u=>!u),children:i?m.jsx(MN,{className:"size-4.5"}):m.jsx(UN,{className:"size-4.5"})})})]}),m.jsx("div",{className:"aui-sidecar-content h-[calc(100%-3.5rem)] overflow-hidden",children:m.jsx(Sd,{})})]})})},M2=()=>{const{config:e}=T.useElements();switch(e.variant){case"standalone":return m.jsx(Sd,{});case"sidecar":return m.jsx(z2,{});default:return m.jsx(A2,{})}};exports.useGramElements=T.useElements;exports.Chat=M2;exports.GramElementsProvider=xM;exports.MODELS=Nc;exports.defineFrontendTool=fN;
|
|
143
|
+
linear-gradient(135deg, transparent 75%, #ccc 75%)`,backgroundSize:"25px 25px",backgroundPosition:"0 0, 12.5px 0, 12.5px -12.5px, 0px 12.5px"},children:m.jsx("img",{src:t,className:"max-h-[300px] max-w-full object-contain"})})}function h2({content:e}){return m.jsx("div",{className:"w-full",children:e.content.map((t,r)=>{switch(t.type){case"text":{const o=c2(t._meta?.["getgram.ai/mime-type"]??"text/plain"),n=d2(t.text,o);return m.jsx(f0,{text:n,language:o},r)}case"image":return m.jsx(m2,{data:t.data},r);default:return m.jsx("pre",{className:"px-4 py-3 text-sm whitespace-pre-wrap",children:JSON.stringify(t,null,2)},r)}})})}function am({title:e,content:t,defaultExpanded:r=!1,highlightSyntax:o=!0,language:n="json"}){const[i,a]=z.useState(r),s=p2(t),l=s?JSON.stringify(t,null,2):typeof t=="string"?t:JSON.stringify(t,null,2);return m.jsxs("div",{"data-slot":"tool-ui-section",className:"border-border border-t",children:[m.jsxs("button",{onClick:()=>a(!i),className:"hover:bg-accent/50 flex w-full cursor-pointer items-center justify-between px-4 py-2.5 text-left transition-colors",children:[m.jsx("span",{className:"text-muted-foreground text-sm",children:e}),m.jsxs("div",{className:"flex items-center gap-1",children:[m.jsx(f2,{content:l}),m.jsx(W_,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",i&&"rotate-90")})]})]}),i&&m.jsx("div",{className:"border-border border-t",children:s?m.jsx(h2,{content:t}):o?m.jsx(f0,{text:l,language:n}):m.jsx("pre",{className:"text-foreground overflow-x-auto px-4 py-3 text-sm whitespace-pre-wrap",children:l})})]})}function g2({name:e,icon:t,provider:r,status:o="complete",request:n,result:i,defaultExpanded:a=!1,className:s,onApproveOnce:l,onApproveForSession:u,onDeny:c}){const d=o==="approval"&&l!==void 0&&c!==void 0,[f,p]=z.useState(a),g=n!==void 0||i!==void 0,[h,b]=z.useState("one-time"),[y,x]=z.useState(!1);z.useEffect(()=>{!d&&f&&!a&&p(!1)},[d]);const $=()=>{h==="for-session"&&u?u():l&&l()};return m.jsxs("div",{"data-slot":"tool-ui",className:T.cn("border-border bg-card overflow-hidden rounded-lg border",s),children:[r&&m.jsxs("div",{"data-slot":"tool-ui-provider",className:T.cn("border-border flex items-center gap-2 border-b px-4 py-2.5"),children:[t?m.jsx("span",{className:"flex size-5 items-center justify-center",children:t}):m.jsx("span",{className:"bg-muted flex size-5 items-center justify-center rounded text-xs font-medium",children:r.charAt(0).toUpperCase()}),m.jsx("span",{className:"text-sm font-medium",children:r})]}),m.jsxs("button",{onClick:()=>g&&p(!f),disabled:!g,className:T.cn("flex w-full items-center gap-2 px-4 py-3 text-left",g&&"hover:bg-accent/50 cursor-pointer transition-colors"),children:[m.jsx(p0,{status:o}),m.jsx("span",{className:T.cn("flex-1 text-sm",!r&&d&&"shimmer"),children:e}),g&&m.jsx(Ti,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",f&&"rotate-180")})]}),f&&g&&m.jsxs("div",{"data-slot":"tool-ui-content",children:[n!==void 0&&m.jsx(am,{title:"Arguments",content:n,highlightSyntax:!0,language:"json"}),i!==void 0&&m.jsx(am,{title:"Output",content:i,highlightSyntax:!0,language:"json"})]}),d&&m.jsxs("div",{"data-slot":"tool-ui-approval-actions",className:"border-border flex items-center justify-end gap-2 border-t px-4 py-3",children:[m.jsx("div",{children:m.jsx("span",{className:"text-muted-foreground text-sm",children:"This tool requires approval"})}),m.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[m.jsxs($t,{variant:"outline",size:"sm",onClick:c,className:"text-destructive hover:bg-destructive/10",children:[m.jsx(Eo,{className:"mr-1 size-3"}),"Deny"]}),m.jsxs("div",{className:"flex items-center",children:[m.jsxs($t,{variant:"default",size:"sm",onClick:$,className:"flex cursor-pointer justify-between gap-1 rounded-r-none bg-emerald-600 hover:bg-emerald-700",children:[m.jsx(nr,{className:"mr-1 size-3"}),m.jsx("span",{className:"min-w-[110px]",children:h==="one-time"?"Approve this time":"Approve always"})]}),m.jsxs(l0,{open:y,onOpenChange:x,children:[m.jsx(c0,{asChild:!0,children:m.jsx($t,{variant:"default",size:"sm",className:"cursor-pointer rounded-l-none border-l border-emerald-700 bg-emerald-600 px-2 hover:bg-emerald-700",children:m.jsx(Ti,{className:"size-3"})})}),m.jsxs(d0,{align:"end",className:"w-64 p-1",sideOffset:4,children:[m.jsxs("button",{onClick:()=>{b("one-time"),x(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[m.jsx(nr,{className:T.cn("relative top-1 mt-0.5 size-3 shrink-0",h!=="one-time"&&"invisible")}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"text-sm",children:"Approve only once"}),m.jsx("span",{className:"text-muted-foreground text-xs",children:"You'll be asked again next time"})]})]}),u&&m.jsxs("button",{onClick:()=>{b("for-session"),x(!1)},className:"hover:bg-accent relative flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left",children:[m.jsx(nr,{className:T.cn("relative top-1 mt-0.5 size-3 shrink-0",h!=="for-session"&&"invisible")}),m.jsxs("div",{className:"flex flex-col gap-0.5",children:[m.jsx("span",{className:"text-sm",children:"Approve always"}),m.jsx("span",{className:"text-muted-foreground text-xs",children:"Trust this tool for the session"})]})]})]})]})]})]})]})]})}function v2({title:e,icon:t,status:r="complete",defaultExpanded:o=!1,children:n,className:i}){const[a,s]=z.useState(o);return m.jsxs("div",{"data-slot":"tool-ui-group",className:T.cn("border-border bg-card overflow-hidden rounded-lg border",i),children:[m.jsxs("button",{onClick:()=>s(!a),className:"hover:bg-accent/50 flex w-full items-center gap-2 px-4 py-3 text-left transition-colors",children:[t||m.jsx(p0,{status:r==="running"?"running":"complete"}),m.jsx("span",{className:T.cn("flex-1 text-sm font-medium",r==="running"&&"shimmer"),children:e}),m.jsx(Ti,{className:T.cn("text-muted-foreground size-4 transition-transform duration-200",a&&"rotate-180")})]}),a&&m.jsx("div",{"data-slot":"tool-ui-group-content",className:"border-border border-t",children:n})]})}const y2=({toolName:e,toolCallId:t,status:r,result:o,args:n})=>{const{pendingApprovals:i,whitelistTool:a,confirmPendingApproval:s,rejectPendingApproval:l}=J_(),u=i.get(t),d=L.useAssistantState(({message:x})=>x).parts.filter(x=>x.type==="tool-call"),f=d.findIndex(x=>x.toolName===e),p=()=>{s(t)},g=()=>{a(e),s(t)},h=()=>{l(t)},b=()=>u?"approval":r.type==="incomplete"?"error":r.type==="complete"?o&&typeof o=="object"&&"isError"in o&&o.isError?"error":"complete":"running",y=()=>{if(o!==void 0)return typeof o=="object"&&o!==null&&"content"in o&&Array.isArray(o.content)||typeof o=="string",o};return m.jsx("div",{className:T.cn("aui-tool-fallback-root flex w-full flex-col",f!==-1&&f!==d.length-1&&"border-b"),children:m.jsx(g2,{name:e,status:b(),request:n,result:y(),onApproveOnce:u?p:void 0,onApproveForSession:u?g:void 0,onDeny:u?h:void 0,className:"rounded-none border-0"})})},$d=()=>{const{config:e}=T.useElements(),t=e.theme??{};return z.useMemo(()=>{const{colorScheme:r="light"}=t;return{className:r==="dark"||r==="system"&&typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":void 0}},[t])},or=[.23,1,.32,1];function b2(e){return e.replace(/[-_]/g," ").split(/(?=[A-Z])/).join(" ").split(/\s+/).map(t=>t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()).join(" ")}const _2=({children:e})=>{const t=L.useAssistantState(({message:s})=>s).parts,r=t.filter(s=>s.type==="tool-call"),o=r.some(s=>s.status?.type==="running"),{config:n}=T.useElements(),i=n.tools?.expandToolGroupsByDefault??!1,a=z.useMemo(()=>{const s=t.filter(l=>l.type==="tool-call");return s.length===0?"No tools called":s.length===1?`Calling ${b2(s[0].toolName)}...`:o?`Calling ${s.length} tools...`:`Executed ${s.length} tools`},[t,o]);return n.tools?.components?.[r[0]?.toolName]?e:r.length===1?m.jsx("div",{className:T.cn("my-4 w-full max-w-xl"),children:m.jsx("div",{className:"border-border bg-card overflow-hidden rounded-lg border",children:e})}):m.jsx("div",{className:"my-4 w-full max-w-xl",children:m.jsx(v2,{title:a,status:o?"running":"complete",defaultExpanded:i,children:e})})},w2=()=>m.jsxs("div",{className:"m-2 rounded-md border border-amber-500 bg-amber-100 px-4 py-3 text-sm text-amber-800 dark:border-amber-600 dark:bg-amber-900/30 dark:text-amber-200",children:[m.jsx("strong",{children:"Warning:"})," You are using an API key directly in the client. Please"," ",m.jsx("a",{href:"https://github.com/speakeasy-api/gram/tree/main/elements#setting-up-your-backend",target:"_blank",rel:"noopener noreferrer",className:"text-amber-700 underline hover:text-amber-800 dark:text-amber-300 dark:hover:text-amber-200",children:"set up a session endpoint"})," ","before deploying to production."]}),Sd=()=>{const e=$d(),t=T.useDensity(),{config:r}=T.useElements(),o=r.components??{},n=r.api&&"UNSAFE_apiKey"in r.api;return m.jsx(Zt.LazyMotion,{features:Zt.domAnimation,children:m.jsx(Zt.MotionConfig,{reducedMotion:"user",children:m.jsx(L.ThreadPrimitive.Root,{className:T.cn("aui-root aui-thread-root bg-background @container flex h-full flex-col",e.className),children:m.jsxs(L.ThreadPrimitive.Viewport,{className:T.cn("aui-thread-viewport relative mx-auto flex w-full flex-1 flex-col overflow-x-auto overflow-y-scroll pb-0!",t("p-lg")),children:[m.jsx(L.ThreadPrimitive.If,{empty:!0,children:o.ThreadWelcome?m.jsx(o.ThreadWelcome,{}):m.jsx($2,{})}),n&&m.jsx(w2,{}),m.jsx(L.ThreadPrimitive.Messages,{components:{UserMessage:o.UserMessage??C2,EditComposer:o.EditComposer??A2,AssistantMessage:o.AssistantMessage??O2}}),m.jsx(L.ThreadPrimitive.If,{empty:!1,children:m.jsx("div",{className:"aui-thread-viewport-spacer min-h-8 grow"})}),m.jsx(I2,{})]})})})})},x2=()=>m.jsx(L.ThreadPrimitive.ScrollToBottom,{asChild:!0,children:m.jsx(ct,{tooltip:"Scroll to bottom",variant:"outline",className:"aui-thread-scroll-to-bottom dark:bg-background dark:hover:bg-accent absolute -top-12 z-10 self-center rounded-full p-4 disabled:invisible",children:m.jsx(vN,{})})}),$2=()=>{const{config:e}=T.useElements(),t=T.useDensity(),{title:r,subtitle:o}=e.welcome??{},n=e.variant==="standalone";return m.jsxs("div",{className:T.cn("aui-thread-welcome-root my-auto flex w-full grow flex-col",n?"items-center justify-center":"",t("gap-lg")),children:[m.jsx("div",{className:T.cn("aui-thread-welcome-center flex w-full grow flex-col items-center justify-start"),children:m.jsxs("div",{className:T.cn("aui-thread-welcome-message flex flex-col",n?"items-center text-center":"size-full justify-start",t("gap-sm"),!n&&t("py-md")),children:[m.jsx(Lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,ease:or},className:T.cn("aui-thread-welcome-message-motion-1 text-foreground font-semibold",t("text-title")),children:r}),m.jsx(Lt.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},exit:{opacity:0,y:10},transition:{duration:.25,delay:.05,ease:or},className:T.cn("aui-thread-welcome-message-motion-2 text-muted-foreground/65",t("text-subtitle")),children:o})]})}),m.jsx(S2,{})]})},S2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=T.useDensity(),o=e.welcome?.suggestions??[],n=e.variant==="standalone";return o.length===0?null:m.jsx("div",{className:T.cn("aui-thread-welcome-suggestions w-full",r("gap-md"),r("py-lg"),n?"flex flex-wrap items-center justify-center":o.length===1?"flex":"grid max-w-fit @md:grid-cols-2"),children:o.map((i,a)=>m.jsx(Lt.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:20},transition:{duration:.25,delay:.03*a,ease:or},className:T.cn("aui-thread-welcome-suggestion-display",!n&&"nth-[n+3]:hidden @md:nth-[n+3]:block"),children:m.jsx(L.ThreadPrimitive.Suggestion,{prompt:i.action,send:!0,asChild:!0,children:m.jsxs($t,{variant:"ghost",className:T.cn("aui-thread-welcome-suggestion dark:hover:bg-accent/60 h-auto w-full border text-left whitespace-break-spaces",r("text-base"),n?`flex-row items-center ${r("gap-sm")} ${r("px-md")} ${r("py-sm")} ${t("full")}`:`w-full flex-1 flex-col flex-wrap items-start justify-start ${r("gap-sm")} ${r("px-lg")} ${r("py-md")} ${t("xl")}`),"aria-label":i.action,children:[m.jsx("span",{className:"aui-thread-welcome-suggestion-text-1 text-foreground text-sm font-medium",children:i.title}),m.jsx("span",{className:"aui-thread-welcome-suggestion-text-2 text-muted-foreground text-sm",children:i.label})]})})},`suggested-action-${i.title}-${a}`))})},I2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=T.useDensity(),o=e.composer??{placeholder:"Send a message...",attachments:!0},n=e.components??{};return n.Composer?m.jsx(n.Composer,{}):m.jsxs("div",{className:T.cn("aui-composer-wrapper bg-background sticky bottom-0 flex w-full flex-col overflow-visible",r("gap-md"),r("py-md"),t("xl")),children:[m.jsx(x2,{}),m.jsxs(L.ComposerPrimitive.Root,{className:T.cn("aui-composer-root group/input-group border-input bg-background has-[textarea:focus-visible]:border-ring has-[textarea:focus-visible]:ring-ring/5 dark:bg-background relative flex w-full flex-col border px-1 pt-2 shadow-xs transition-[color,box-shadow] outline-none has-[textarea:focus-visible]:ring-1",t("xl")),children:[o.attachments&&m.jsx(P6,{}),m.jsx(L.ComposerPrimitive.Input,{placeholder:o.placeholder,className:T.cn("aui-composer-input placeholder:text-muted-foreground mb-1 max-h-32 w-full resize-none bg-transparent px-3.5 pt-1.5 pb-3 outline-none focus-visible:ring-0",r("h-input"),r("text-base")),rows:1,autoFocus:!0,"aria-label":"Message input"}),m.jsx(E2,{})]})]})},k2=()=>{const{model:e,setModel:t}=T.useElements(),[r,o]=z.useState(!1),[n,i]=z.useState(!1),a=z.useRef(null),s=z.useRef(0),l=z.useRef(!1);z.useEffect(()=>{r&&!l.current&&requestAnimationFrame(()=>{const c=a.current;c&&c.scrollHeight>0&&(c.scrollTop=s.current)}),l.current=r},[r]),z.useEffect(()=>{r&&i(!1)},[r]);const u=c=>{s.current=c.currentTarget.scrollTop};return m.jsx(oS,{children:m.jsxs(ld,{open:n&&!r,onOpenChange:i,children:[m.jsxs(l0,{open:r,onOpenChange:o,children:[m.jsx(cd,{asChild:!0,children:m.jsx(c0,{asChild:!0,children:m.jsx($t,{variant:"ghost",size:"icon","data-state":r?"open":"closed",className:"aui-composer-model-picker data-[state=open]:bg-muted-foreground/15 dark:border-muted-foreground/15 dark:hover:bg-muted-foreground/30 flex w-fit items-center gap-2 rounded-full px-2.5 py-1 text-xs font-semibold","aria-label":"Model Settings",children:m.jsx(HN,{className:"aui-attachment-add-icon size-5 stroke-[1.5px]"})})})}),m.jsx(d0,{side:"top",align:"start",className:"w-min p-0 shadow-none",children:m.jsx("div",{ref:a,className:"max-h-48 overflow-y-auto",onScroll:u,children:Nc.map(c=>m.jsxs($t,{onClick:()=>{t(c)},variant:"ghost",className:"w-full justify-start gap-2 rounded-none px-2",children:[c===e?m.jsx("div",{children:m.jsx(nr,{className:"size-4 text-emerald-500"})}):m.jsx("div",{className:"size-4",children:" "}),c]},c))})})]}),m.jsx(dd,{side:"bottom",align:"start",children:"Model Settings"})]})})},E2=()=>{const{config:e}=T.useElements(),t=T.useRadius(),r=e.composer??{attachments:!0};return m.jsxs("div",{className:"aui-composer-action-wrapper relative mx-1 mt-2 mb-2 flex items-center justify-between",children:[m.jsxs("div",{className:"aui-composer-action-wrapper-inner flex items-center",children:[r.attachments?m.jsx(C6,{}):m.jsx("div",{className:"aui-composer-add-attachment-placeholder"}),e.model?.showModelPicker&&!e.languageModel&&m.jsx(k2,{})]}),m.jsx(L.ThreadPrimitive.If,{running:!1,children:m.jsx(L.ComposerPrimitive.Send,{asChild:!0,children:m.jsx(ct,{tooltip:"Send message",side:"bottom",type:"submit",variant:"default",size:"icon",className:T.cn("aui-composer-send size-[34px] p-1",t("full")),"aria-label":"Send message",children:m.jsx(bN,{className:"aui-composer-send-icon size-5"})})})}),m.jsx(L.ThreadPrimitive.If,{running:!0,children:m.jsx(L.ComposerPrimitive.Cancel,{asChild:!0,children:m.jsx($t,{type:"button",variant:"default",size:"icon",className:T.cn("aui-composer-cancel border-muted-foreground/60 hover:bg-primary/75 dark:border-muted-foreground/90 size-[34px] border",t("full")),"aria-label":"Stop generating",children:m.jsx(KN,{className:"aui-composer-cancel-icon size-3.5 fill-white dark:fill-black"})})})})]})},T2=()=>m.jsx(L.MessagePrimitive.Error,{children:m.jsx(L.ErrorPrimitive.Root,{className:"aui-message-error-root border-destructive bg-destructive/10 text-destructive dark:bg-destructive/5 mt-2 rounded-md border p-3 text-sm dark:text-red-200",children:m.jsx(L.ErrorPrimitive.Message,{className:"aui-message-error-message line-clamp-2"})})}),O2=()=>{const{config:e}=T.useElements(),t=e.tools??{},r=e.components??{};return m.jsx(L.MessagePrimitive.Root,{asChild:!0,children:m.jsxs("div",{className:"aui-assistant-message-root animate-in fade-in slide-in-from-bottom-1 relative mx-auto w-full py-4 duration-150 ease-out last:mb-24","data-role":"assistant",children:[m.jsxs("div",{className:"aui-assistant-message-content text-foreground mx-2 leading-7 wrap-break-word",children:[m.jsx(L.MessagePrimitive.Parts,{components:{Text:r.Text??qS,Image:r.Image??N2,tools:{by_name:t.components,Fallback:r.ToolFallback??y2},Reasoning:r.Reasoning??YS,ReasoningGroup:r.ReasoningGroup??QS,ToolGroup:r.ToolGroup??_2}}),m.jsx(T2,{})]}),m.jsxs("div",{className:"aui-assistant-message-footer mt-2 ml-2 flex",children:[m.jsx(m0,{}),m.jsx(P2,{})]})]})})},N2=e=>m.jsx("img",{src:e.image}),P2=()=>m.jsxs(L.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",autohideFloat:"single-branch",className:"aui-assistant-action-bar-root text-muted-foreground data-floating:bg-background col-start-3 row-start-2 -ml-1 flex gap-1 data-floating:absolute data-floating:rounded-md data-floating:border data-floating:p-1 data-floating:shadow-sm",children:[m.jsx(L.ActionBarPrimitive.Copy,{asChild:!0,children:m.jsxs(ct,{tooltip:"Copy",children:[m.jsx(L.MessagePrimitive.If,{copied:!0,children:m.jsx(nr,{})}),m.jsx(L.MessagePrimitive.If,{copied:!1,children:m.jsx(Pc,{})})]})}),m.jsx(L.ActionBarPrimitive.Reload,{asChild:!0,children:m.jsx(ct,{tooltip:"Refresh",children:m.jsx(JN,{})})})]}),C2=()=>{const e=T.useRadius();return m.jsx(L.MessagePrimitive.Root,{asChild:!0,children:m.jsxs("div",{className:"aui-user-message-root animate-in fade-in slide-in-from-bottom-1 mx-auto grid w-full auto-rows-auto grid-cols-[minmax(72px,1fr)_auto] gap-y-2 px-2 py-4 duration-150 ease-out first:mt-3 last:mb-5 [&:where(>*)]:col-start-2","data-role":"user",children:[m.jsx(N6,{}),m.jsxs("div",{className:"aui-user-message-content-wrapper relative col-start-2 min-w-0",children:[m.jsx("div",{className:T.cn("aui-user-message-content bg-muted text-foreground px-5 py-2.5 wrap-break-word",e("xl")),children:m.jsx(L.MessagePrimitive.Parts,{})}),m.jsx("div",{className:"aui-user-action-bar-wrapper absolute top-1/2 left-0 -translate-x-full -translate-y-1/2 pr-2",children:m.jsx(j2,{})})]}),m.jsx(m0,{className:"aui-user-branch-picker col-span-full col-start-1 row-start-3 -mr-1 justify-end"})]})})},j2=()=>m.jsx(L.ActionBarPrimitive.Root,{hideWhenRunning:!0,autohide:"not-last",className:"aui-user-action-bar-root flex flex-col items-end",children:m.jsx(L.ActionBarPrimitive.Edit,{asChild:!0,children:m.jsx(ct,{tooltip:"Edit",className:"aui-user-action-edit p-4",children:m.jsx(FN,{})})})}),A2=()=>m.jsx("div",{className:"aui-edit-composer-wrapper mx-auto flex w-full flex-col gap-4 px-2 first:mt-4",children:m.jsxs(L.ComposerPrimitive.Root,{className:"aui-edit-composer-root bg-muted ml-auto flex w-full max-w-7/8 flex-col rounded-xl",children:[m.jsx(L.ComposerPrimitive.Input,{className:"aui-edit-composer-input text-foreground flex min-h-[60px] w-full resize-none bg-transparent p-4 outline-none",autoFocus:!0}),m.jsxs("div",{className:"aui-edit-composer-footer mx-3 mb-3 flex items-center justify-center gap-2 self-end",children:[m.jsx(L.ComposerPrimitive.Cancel,{asChild:!0,children:m.jsx($t,{variant:"ghost",size:"sm","aria-label":"Cancel edit",children:"Cancel"})}),m.jsx(L.ComposerPrimitive.Send,{asChild:!0,children:m.jsx($t,{size:"sm","aria-label":"Update message",children:"Update"})})]})]})}),m0=({className:e,...t})=>m.jsxs(L.BranchPickerPrimitive.Root,{hideWhenSingleBranch:!0,className:T.cn("aui-branch-picker-root text-muted-foreground mr-2 -ml-2 inline-flex items-center text-xs",e),...t,children:[m.jsx(L.BranchPickerPrimitive.Previous,{asChild:!0,children:m.jsx(ct,{tooltip:"Previous",children:m.jsx(IN,{})})}),m.jsxs("span",{className:"aui-branch-picker-state font-medium",children:[m.jsx(L.BranchPickerPrimitive.Number,{})," / ",m.jsx(L.BranchPickerPrimitive.Count,{})]}),m.jsx(L.BranchPickerPrimitive.Next,{asChild:!0,children:m.jsx(ct,{tooltip:"Next",children:m.jsx(W_,{})})})]}),h0=()=>{const{config:e,isExpanded:t,setIsExpanded:r}=T.useElements(),o=e.modal?.defaultExpanded??!1;return{expandable:e.modal?.expandable??!1,isExpanded:t,setIsExpanded:r,defaultExpanded:o}},R2={layout:{duration:.25,ease:or}},z2=()=>{const{config:e}=T.useElements(),t=$d(),r=T.useRadius(),o=T.useDensity(),[n,i]=z.useState(e.modal?.defaultOpen??!1),{expandable:a,isExpanded:s,setIsExpanded:l}=h0(),u=e.modal?.title,c=e.modal?.icon,d=e.modal?.position??"bottom-right",f=M2(d),p=z.useMemo(()=>e.modal?.dimensions?.default??{width:"500px",height:"600px",maxHeight:"95vh"},[e.modal?.dimensions?.default]),g=z.useMemo(()=>e.modal?.dimensions?.expanded??{width:"70vw",height:"90vh"},[e.modal?.dimensions?.expanded]),b=L.useAssistantState(({thread:v})=>v).messages.some(v=>v.status?.type==="running"),y=s?g.width:p.width,x=s?g.height:p.height,$=p.maxHeight;return m.jsx(Zt.LazyMotion,{features:Zt.domMax,children:m.jsx(Zt.MotionConfig,{reducedMotion:"user",transition:R2,children:m.jsx("div",{className:T.cn("aui-root aui-modal-anchor fixed z-10",f,t.className,r("lg"),n&&"shadow-xl"),children:m.jsx(Zt.AnimatePresence,{mode:"wait",children:n?m.jsxs(Lt.div,{layout:!0,layoutId:"chat-container",className:T.cn("aui-modal-content bg-popover text-popover-foreground flex flex-col overflow-hidden border [&>.aui-thread-root]:bg-inherit",r("lg")),initial:!1,style:{originX:d.includes("left")?0:1,originY:d.includes("top")?0:1,width:y,height:x,maxHeight:$},children:[m.jsxs(Lt.div,{className:T.cn("aui-modal-header flex shrink-0 items-center justify-between border-b",o("h-header"),o("px-lg")),initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.1,ease:or},children:[m.jsx("div",{className:T.cn("flex min-w-0 items-center"),children:m.jsxs("span",{className:T.cn("text-md flex items-center gap-2 truncate font-medium",b&&"shimmer"),children:[m.jsx("span",{className:"truncate",children:u}),b&&m.jsx(Oi,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]})}),m.jsxs("div",{className:"flex flex-row items-center justify-end gap-1",children:[a?m.jsx("button",{type:"button",onClick:()=>l(v=>!v),className:T.cn("text-muted-foreground hover:text-foreground hover:bg-accent flex h-8 cursor-pointer items-center rounded-md px-2 text-xs transition-colors"),"aria-pressed":s,"aria-label":s?"Collapse assistant":"Expand assistant",children:s?m.jsx(zN,{strokeWidth:2,className:"size-3.5 rotate-90"}):m.jsx(CN,{strokeWidth:2,className:"size-3.5 rotate-90"})}):null,m.jsx("button",{onClick:()=>{i(!1),l(!1)},className:"text-muted-foreground hover:text-foreground hover:bg-accent -mr-1 flex size-8 cursor-pointer items-center justify-center rounded-md transition-colors","aria-label":`Close ${u}`,children:m.jsx(Eo,{className:"size-4.5"})})]})]}),m.jsx(Lt.div,{className:"aui-modal-thread w-full flex-1 overflow-hidden",initial:{opacity:0},animate:{opacity:1},transition:{duration:.2,delay:.05,ease:or},children:m.jsx(Sd,{})})]},"chat"):m.jsx(Lt.button,{layout:!0,layoutId:"chat-container",onClick:()=>i(!0),className:T.cn("aui-modal-button bg-primary text-primary-foreground flex size-12 cursor-pointer items-center justify-center border shadow-lg transition-shadow hover:shadow-xl",r("full")),initial:!1,"aria-label":`Open ${u}`,style:{originX:1,originY:1},children:m.jsx(Lt.div,{initial:{opacity:0,scale:.8},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.8},transition:{duration:.2,ease:or},className:"flex size-full items-center justify-center",children:c?c("closed"):m.jsx(AN,{className:"size-6"})})},"button")})})})})};function M2(e){switch(e){case"bottom-left":return"left-4 bottom-4";case"top-right":return"right-4 top-4";case"top-left":return"left-4 top-4";case"bottom-right":return"right-4 bottom-4";default:T.assertNever(e)}}const D2=()=>{const{config:e}=T.useElements(),t=$d(),r=e.sidecar??{},{title:o,dimensions:n}=r,{isExpanded:i,setIsExpanded:a}=h0(),l=L.useAssistantState(({thread:u})=>u).messages.some(u=>u.status?.type==="running");return m.jsx(Zt.LazyMotion,{features:Zt.domMax,children:m.jsxs(Lt.div,{initial:{width:n?.default?.width??"400px",height:n?.default?.height??"100vh"},animate:{width:i?n?.expanded?.width??"800px":n?.default?.width??"400px",height:i?n?.expanded?.height??"100%":n?.default?.height??"100vh"},transition:{duration:.3,ease:or},className:T.cn("aui-root aui-sidecar bg-popover text-popover-foreground fixed top-0 right-0 border-l",t.className),children:[m.jsxs("div",{className:"aui-sidecar-header flex h-14 items-center justify-between border-b px-4",children:[m.jsxs("span",{className:T.cn("text-md flex items-center gap-2 font-medium",l&&"shimmer"),children:[o,l&&m.jsx(Oi,{className:"text-muted-foreground size-4.5 animate-spin",strokeWidth:1.25})]}),m.jsx("div",{className:"aui-sidecar-header-actions flex items-center gap-1",children:m.jsx(ct,{tooltip:i?"Collapse":"Pop out",variant:"ghost",className:"aui-sidecar-popout size-8",onClick:()=>a(u=>!u),children:i?m.jsx(DN,{className:"size-4.5"}):m.jsx(LN,{className:"size-4.5"})})})]}),m.jsx("div",{className:"aui-sidecar-content h-[calc(100%-3.5rem)] overflow-hidden",children:m.jsx(Sd,{})})]})})},U2=()=>{const{config:e}=T.useElements();switch(e.variant){case"standalone":return m.jsx(Sd,{});case"sidecar":return m.jsx(D2,{});default:return m.jsx(z2,{})}};exports.useGramElements=T.useElements;exports.Chat=U2;exports.GramElementsProvider=SM;exports.MODELS=Nc;exports.defineFrontendTool=mN;
|
|
144
144
|
//# sourceMappingURL=elements.cjs.map
|