chain-insights 0.42.2 → 0.43.0

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.
@@ -1,4 +1,4 @@
1
- <!-- Chain Insights UI 0d11c76747003217abb4e54365252c4665354601 (npm run build:claude-view); refresh with scripts/refresh-claude-view.mjs, never edit by hand -->
1
+ <!-- Chain Insights UI 905d40dd70f472b31780818f97f0fdec9b473e3c (npm run build:claude-view); refresh with scripts/refresh-claude-view.mjs, never edit by hand -->
2
2
  <!doctype html>
3
3
  <html lang="en">
4
4
  <head>
@@ -6,50 +6,50 @@
6
6
  <meta name="viewport" content="width=device-width,initial-scale=1">
7
7
  <meta name="color-scheme" content="light dark">
8
8
  <title>Chain Insights view</title>
9
- <script type="module">const Jg=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),Wg=function(e,t){return new URL(e,t).href},$l={},Gg=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let u=function(l){return Promise.all(l.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const s=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),c=a?.nonce||a?.getAttribute("nonce");o=u(n.map(l=>{if(l=Wg(l,r),l in $l)return;$l[l]=!0;const d=l.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(r)for(let h=s.length-1;h>=0;h--){const m=s[h];if(m.href===l&&(!d||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${f}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":Jg,d||(p.as="script"),p.crossOrigin="",p.href=l,c&&p.setAttribute("nonce",c),document.head.appendChild(p),d)return new Promise((h,m)=>{p.addEventListener("load",h),p.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return o.then(s=>{for(const a of s||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})};function Yg(e){return e}function Qg(e){return e}function xo(){return e=>e}function Xg(e){}function ey(e){throw new Error("Unexpected value in exhaustive check")}function ty(e){}function go(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ls(e,t="|"){return e.map(n=>As(n)).join(t)}function yo(e,t){return typeof t=="bigint"?t.toString():t}class ny{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}}function qn(e){return new ny(e)}function Ns(e){return e==null}function gt(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Os(e,t){const n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}const Sl=Symbol("evaluating");function Cd(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Sl)return r===void 0&&(r=Sl,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function ry(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Re(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function To(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function nt(e){return To(e._zod.def)??e._zod.def.shape}function Ed(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return Re(this,t,r),r},enumerable:!0,configurable:!0})}function Nd(e,t,n){t in e?Re(e,t,n):e[t]=n}function Ot(e,t,n,r){const o=nt(t);for(const i of n){const s=Object.getOwnPropertyDescriptor(o,i);s.enumerable&&(s.get?Ed(e,i,()=>{const a=t._zod.def.shape[i];return r?r(a,i):a}):Nd(e,i,r?r(s.value,i):s.value))}}function oy(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Ed(e,n,()=>t[n]):Nd(e,n,r.value))}}function ke(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function iy(e){return ke(e._zod.def)}function sy(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function ay(e){const t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{const o={};for(let i=0;i<t.length;i++)o[t[i]]=r[i];return o})}function cy(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function Pe(e){return JSON.stringify(e)}function Od(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Ps="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Jt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Pd=qn(()=>{if(ze.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function rt(e){if(Jt(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Jt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Hn(e){return rt(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function uy(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const ly=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}`)}},_o=new Set(["string","number","symbol"]),Ad=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ot(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function oe(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function $(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 dy(e){let t;return new Proxy({},{get(n,r,o){return t??(t=e()),Reflect.get(t,r,o)},set(n,r,o,i){return t??(t=e()),Reflect.set(t,r,o,i)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,o){return t??(t=e()),Reflect.defineProperty(t,r,o)}})}function As(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function Md(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const Ms={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]},Rs={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Rd(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i={};return Ot(i,e,Co(e,t)),oe(e,ke(n,{shape:i,checks:[]}))}function Co(e,t){const n=nt(e),r=[];for(const o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&r.push(o)}return r}function Ld(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=new Set(Co(e,t)),s={};return Ot(s,e,Reflect.ownKeys(nt(e)).filter(a=>!i.has(a))),oe(e,ke(n,{shape:s,checks:[]}))}function Zd(e,t){if(!rt(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=nt(e);for(const i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return oe(e,ke(e._zod.def,{shape:Dd(e,t)}))}function Dd(e,t){const n={};return Ot(n,e,Reflect.ownKeys(nt(e))),oy(n,t),n}function jd(e,t){if(!rt(t))throw new Error("Invalid input to safeExtend: expected a plain object");return oe(e,ke(e._zod.def,{shape:Dd(e,t)}))}function Fd(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};Ot(n,e,Reflect.ownKeys(nt(e))),Ot(n,t,Reflect.ownKeys(nt(t)));const r=ke(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return oe(e,r)}function ds(e,t,n,r="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set(Co(t,n)):void 0,c={};return Ot(c,t,Reflect.ownKeys(nt(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),oe(t,ke(t._zod.def,{shape:c,checks:[]}))}function Ud(e,t,n){const r=n?new Set(Co(t,n)):void 0,o={};return Ot(o,t,Reflect.ownKeys(nt(t)),(i,s)=>r&&!r.has(s)?i:new e({type:"nonoptional",innerType:i})),oe(t,ke(t._zod.def,{shape:o}))}function Ce(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Vd(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function De(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Ht(e){return typeof e=="string"?e:e?.message}function fs(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Fe(e,t,n){var r;const o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:Ht(e.inst?._zod.def?.error?.(e))??Ht(i?.(e))??Ht(t?.error?.(e))??Ht(n.customError?.(e))??Ht(n.localeError?.(e))??"Invalid input",a={};for(const c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}function Eo(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}const fy=/[\uD800-\uDBFF]/;function Bn(e){const t=e.length;if(!fy.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function No(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function qd(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Wt(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function py(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Hd(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function Bd(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function hy(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return Hd(t+n)}function my(e){return Bd(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function gy(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function yy(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class _y{constructor(...t){}}function Kd(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):by(e,n,r.value)}}function it(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Oo(e,t,n){return it(e,t,n,!1)}function Kn(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return it(this,n,r(this))},set(o){it(this,n,o)}})}return t}function by(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:it(this,t,n.bind(this))},set(r){it(this,t,r)}})}function wy(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let Xi,ft=!1;const vy={configurable:!0,get(){ft=!0}};function F(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&Xi!==e._zod){Xi=void 0;return}Xi=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,vy);const o=ft;ft=!1;try{const i=n(this);return ft?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),ft=ft||o,i}catch(i){throw delete this[t],ft=ft||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function Jd(e,t,n,r){const o=wy(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}const Ls="~constantCatch";function Zs(e){const t=()=>e;return t[Ls]=!0,t}const Ds=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:Rs,CONSTANT_CATCH:Ls,Class:_y,NUMBER_FORMAT_RANGES:Ms,aborted:Ce,allowsEval:Pd,assert:ty,assertEqual:Yg,assertIs:Xg,assertNever:ey,assertNotEqual:Qg,assignProp:Re,attachSchema:fs,base64ToUint8Array:Hd,base64urlToUint8Array:hy,cached:qn,captureStackTrace:Ps,cleanEnum:py,cleanRegex:gt,clone:oe,cloneDef:iy,codePointLength:Bn,constantCatch:Zs,createTransparentProxy:dy,defineLazy:Cd,defineLazyInternal:F,derived:Kn,esc:Pe,escapeRegex:ot,explicitlyAborted:Vd,extend:Zd,finalizeIssue:Fe,floatSafeRemainder:Os,getElementAtPath:sy,getEnumValues:go,getLengthableOrigin:No,getParsedType:ly,getSizableOrigin:Eo,hexToUint8Array:gy,hide:Oo,installLazyProp:Jd,isObject:Jt,isPlainObject:rt,issue:Wt,joinValues:ls,jsonStringifyReplacer:yo,members:Kd,merge:Fd,mergeDefs:ke,normalizeParams:$,nullish:Ns,numKeys:uy,objectClone:ry,omit:Ld,optionalKeys:Md,own:it,parsedType:qd,partial:ds,pick:Rd,prefixIssues:De,primitiveTypes:Ad,promiseAllObject:ay,propertyKeyTypes:_o,randomString:cy,rawShape:To,required:Ud,safeExtend:jd,shallowClone:Hn,slugify:Od,stringifyPrimitive:As,toZod:xo,uint8ArrayToBase64:Bd,uint8ArrayToBase64url:my,uint8ArrayToHex:yy,unwrapMessage:Ht},Symbol.toStringTag,{value:"Module"}));var Il;const js=Object.freeze({status:"aborted"}),es={value:void 0,enumerable:!1};let zl="captureStackTrace"in Error?Error:null;function ky(e){const t=zl;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return zl=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function g(e,t,n,r){const o={};function i(f){this.def=f,this.constr=d,this.traits=new Set}i.prototype=o;const s=n,a=s&&new WeakSet;function c(f,p){if(f._zod){if(f._zod.traits.has(e))return}else{es.value=new i(p);try{Object.defineProperty(f,"_zod",es)}finally{es.value=void 0}}if(f._zod.traits.add(e),t(f,p),a){const m=Object.getPrototypeOf(f),k=f._zod.constr.prototype;let I=m;for(;I&&I!==k;)I=Object.getPrototypeOf(I);const v=I??m;a.has(v)||(a.add(v),Kd(v,s))}const h=d.prototype;for(const m in h)Object.prototype.hasOwnProperty.call(h,m)&&(m in f||(f[m]=h[m].bind(f)))}const u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){const p=r?.Parent?ky(l):this;c(p,f);const h=p._zod.deferred;if(h){for(const k of h)k();p._zod.deferred=void 0}const m=globalThis.__zod_globalConfig?.postProcessor;return m&&m(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>r?.Parent&&f instanceof r.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}const Fs=Symbol("zod_brand");class tt extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Po extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Il=globalThis).__zod_globalConfig??(Il.__zod_globalConfig={});const ze=globalThis.__zod_globalConfig;function me(e){return e&&Object.assign(ze,e),ze}function $y(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,yo,2)),e.message}function Sy(e){this._zod.message=e}const Iy={get:$y,set:Sy,enumerable:!0,configurable:!0},ts={value:void 0,enumerable:!1},xl=new WeakSet([Object.prototype,Error.prototype]),Wd=(e,t)=>{e.name="$ZodError",ts.value=t,Object.defineProperty(e,"issues",ts),ts.value=void 0,Object.defineProperty(e,"message",Iy);const n=Object.getPrototypeOf(e);xl.has(n)||(xl.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},Gd=g("$ZodError",Wd),Le=g("$ZodError",Wd,void 0,{Parent:Error});function zy(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Ao(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?zy(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Mo(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{const a=[...i,...s.path];if(a.length===0)n._errors.push(t(s));else{let c=n,u=0;for(;u<a.length;){const l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(s)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const f=c[l];d&&f._errors.push(t(s)),c=f,u++}}}};return r(e),n}function Us(e,t=n=>n.message){const n={errors:[]},r=(o,i=[])=>{var s;for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(c=>r({issues:c},[...i,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...i,...a.path]);else{const c=[...i,...a.path];if(c.length===0){n.errors.push(t(a));continue}let u=n,l=0;for(;l<c.length;){const d=c[l],f=l===c.length-1;typeof d=="string"?(u.properties??(u.properties={}),Object.prototype.hasOwnProperty.call(u.properties,d)||Object.defineProperty(u.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),u=u.properties[d]):(u.items??(u.items=[]),(s=u.items)[d]??(s[d]={errors:[]}),u=u.items[d]),f&&u.errors.push(t(a)),l++}}};return r(e),n}function Yd(e){const t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(const r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function Vs(e){const t=[],n=[...e.issues].sort((r,o)=>(r.path??[]).length-(o.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${Yd(r.path)}`);return t.join(`
10
- `)}function Ro(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Jn=e=>{const t=(n,r,o,i)=>{const s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new tt;if(a.issues.length){const c=new(i?.Err??e)(a.issues.map(u=>Fe(u,s,me())));throw Ps(c,i?.callee??t),c}return a.value};return t},ps=Jn(Le),Wn=e=>{const t=async(n,r,o,i)=>{const s=o?{...o,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const c=new(i?.Err??e)(a.issues.map(u=>Fe(u,s,me())));throw Ps(c,i?.callee??t),c}return a.value};return t},hs=Wn(Le),Gn=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new tt;return i.issues.length?Xd(e,i.issues,o):{success:!0,data:i.value}},Qd=Gn(Le);function Xd(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(o=>Fe(o,n,me()))),t=void 0,n=void 0),r},set error(o){r=o,t=void 0,n=void 0}}}const Yn=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?Xd(e,i.issues,o):{success:!0,data:i.value}},xy=Yn(Le),Ty=Symbol.for("zod.compile.invalid"),Cy=Symbol.for("zod.compile.fallback"),Lo=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Ty)return!0;if(r.definite===!0&&n===void 0)return!1}return Ey(e,t,n)});function Ey(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun;let i;if(o?(r[Cy]=!0,i=o({value:t,issues:[]},r)):i=e._zod.run({value:t,issues:[]},r),i instanceof Promise)throw new tt;return i.issues.length===0}const Zo=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let o=e._zod.run({value:t,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length===0},qs=e=>{const t=Jn(e),n=(r,o,i,s)=>{const a=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,a,Ro(n,s))};return n},Ny=qs(Le),Hs=e=>{const t=Jn(e),n=(r,o,i,s)=>t(r,o,i,Ro(n,s));return n},Oy=Hs(Le),Bs=e=>{const t=Wn(e),n=async(r,o,i,s)=>{const a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,a,Ro(n,s))};return n},Py=Bs(Le),Ks=e=>{const t=Wn(e),n=async(r,o,i,s)=>await t(r,o,i,Ro(n,s));return n},Ay=Ks(Le),Js=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Gn(e)(t,n,o)},My=Js(Le),Ws=e=>(t,n,r)=>Gn(e)(t,n,r),Ry=Ws(Le),Gs=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return Yn(e)(t,n,o)},Ly=Gs(Le),Ys=e=>async(t,n,r)=>Yn(e)(t,n,r),Zy=Ys(Le),ef=/^[cC][0-9a-z]{6,}$/,tf=/^[0-9a-z]+$/,nf=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,rf=/^[0-9a-vA-V]{20}$/,of=/^[A-Za-z0-9]{27}$/,sf=/^[a-zA-Z0-9_-]{21}$/;function af(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const cf=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Dy=/^[-+]?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)?)??$/,uf=/^([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})$/,Gt=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)$/,jy=Gt(4),Fy=Gt(6),Uy=Gt(7),lf=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Vy=/^[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])?)*$/,qy=/^(([^<>()\[\]\\.,;:\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,}))$/,df=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Hy=df,By=/^[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])?)*$/,Ky="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function ff(){return new RegExp(Ky,"u")}const pf=/^(?:(?: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])$/,hf=/^(([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}|:))$/,mf=e=>{const t=ot(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},gf=/^((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])$/,yf=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,_f=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,bf=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,wf=/^(?=.{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])?)*\.?$/,vf=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,Qs=/^https?$/,kf=/^\+[1-9]\d{6,14}$/,Xs=/^\d(?:[ -]?\d){11,18}$/,$f=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,ea=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,Sf="(?:(?:\\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])))";function Jy(e){return new RegExp(`^${e}$`)}const If=Jy(Sf);function ms(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}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function zf(e){return new RegExp(`^${ms(e)}$`)}function xf(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${ms({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${ms({precision:e.precision})}`:n;return new RegExp(`^${Sf}T(?:${r})$`)}const Tf=/^[\s\S]{0,}$/,Cf=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Ef=/^-?\d+n?$/,ta=/^-?\d+$/,an=/^-?\d+(?:\.\d+)?$/,Nf=/^(?:true|false)$/i,Of=/^null$/i,Pf=/^undefined$/i,Af=/^[^A-Z]*$/,Mf=/^[^a-z]*$/,Rf=/^[0-9a-fA-F]*$/;function Qn(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Xn(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const Wy=/^[0-9a-fA-F]{32}$/,Gy=Qn(22,"=="),Yy=Xn(22),Qy=/^[0-9a-fA-F]{40}$/,Xy=Qn(27,"="),e_=Xn(27),t_=/^[0-9a-fA-F]{64}$/,n_=Qn(43,"="),r_=Xn(43),o_=/^[0-9a-fA-F]{96}$/,i_=Qn(64,""),s_=Xn(64),a_=/^[0-9a-fA-F]{128}$/,c_=Qn(86,"=="),u_=Xn(86),Do=Object.freeze(Object.defineProperty({__proto__:null,anyString:Tf,base64:_f,base64url:bf,bigint:Ef,boolean:Nf,browserEmail:By,cidrv4:gf,cidrv6:yf,creditCard:Xs,cuid:ef,cuid2:tf,currencyCode:$f,date:If,datetime:xf,domain:vf,duration:cf,e164:kf,email:lf,emoji:ff,extendedDuration:Dy,guid:uf,hex:Rf,hostname:wf,html5Email:Vy,httpProtocol:Qs,iban:ea,idnEmail:Hy,integer:ta,ipv4:pf,ipv6:hf,ksuid:of,lowercase:Af,mac:mf,md5_base64:Gy,md5_base64url:Yy,md5_hex:Wy,nanoid:sf,nanoidOfLength:af,null:Of,number:an,rfc5322Email:qy,sha1_base64:Xy,sha1_base64url:e_,sha1_hex:Qy,sha256_base64:n_,sha256_base64url:r_,sha256_hex:t_,sha384_base64:i_,sha384_base64url:s_,sha384_hex:o_,sha512_base64:c_,sha512_base64url:u_,sha512_hex:a_,string:Cf,time:zf,ulid:nf,undefined:Pf,unicodeEmail:df,uppercase:Mf,uuid:Gt,uuid4:jy,uuid6:Fy,uuid7:Uy,xid:rf},Symbol.toStringTag,{value:"Module"})),ie=g("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),na=e=>{const t=e.value;return!Ns(t)&&t.size!==void 0},ra=e=>{const t=e.value;return!Ns(t)&&t.length!==void 0},bo={number:"number",bigint:"bigint",object:"date"},oa=g("$ZodCheckLessThan",(e,t)=>{ie.init(e,t);const n=bo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:bo[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ia=g("$ZodCheckGreaterThan",(e,t)=>{ie.init(e,t);const n=bo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:bo[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Lf=g("$ZodCheckMultipleOf",(e,t)=>{ie.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Os(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Zf=g("$ZodCheckNumberFormat",(e,t)=>{ie.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=Ms[t.format];e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),Df=g("$ZodCheckBigIntFormat",(e,t)=>{ie.init(e,t);const[n,r]=Rs[t.format];e._zod.check=o=>{const i=o.value;i<n&&o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>r&&o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),jf=g("$ZodCheckMaxSize",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=na),e._zod.check=r=>{const o=r.value;o.size<=t.maximum||r.issues.push({origin:Eo(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Ff=g("$ZodCheckMinSize",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=na),e._zod.check=r=>{const o=r.value;o.size>=t.minimum||r.issues.push({origin:Eo(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Uf=g("$ZodCheckSizeEquals",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=na),e._zod.check=r=>{const o=r.value,i=o.size;if(i===t.size)return;const s=i>t.size;r.issues.push({origin:Eo(o),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Vf=g("$ZodCheckMaxLength",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=ra),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>t.maximum?Bn(o):i)<=t.maximum)return;const a=No(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),qf=g("$ZodCheckMinLength",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=ra),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?Bn(o):i)>=t.minimum)return;const a=No(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),Hf=g("$ZodCheckLengthEquals",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=ra),e._zod.check=r=>{const o=r.value,i=o.length,s=typeof o=="string"&&i>=t.length&&i<=t.length*2?Bn(o):i;if(s===t.length)return;const a=No(o),c=s>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),er=g("$ZodCheckStringFormat",(e,t)=>{var n,r;ie.init(e,t),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Bf=g("$ZodCheckRegex",(e,t)=>{er.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Kf=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=Af),er.init(e,t)}),Jf=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=Mf),er.init(e,t)}),Wf=g("$ZodCheckIncludes",(e,t)=>{ie.init(e,t);const n=ot(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),Gf=g("$ZodCheckStartsWith",(e,t)=>{ie.init(e,t);const n=new RegExp(`^${ot(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),Yf=g("$ZodCheckEndsWith",(e,t)=>{ie.init(e,t);const n=new RegExp(`.*${ot(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});function wo(e,t,n){e.issues.length&&t.issues.push(...De(n,e.issues))}const Qf=g("$ZodCheckProperty",(e,t)=>{ie.init(e,t),e._zod.check=n=>{const r=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then(o=>wo(o,n,t.property));wo(r,n,t.property)}}),Xf=g("$ZodCheckProperties",(e,t)=>{ie.init(e,t),Oo(e,Symbol.iterator,function*(){yield e});let n;e._zod.check=r=>{if(r.value==null){r.issues.push({expected:"object",code:"invalid_type",input:r.value,inst:e});return}n??(n=Reflect.ownKeys(t.shape).map(s=>[s,t.shape[s]]));const o=r.value;let i;for(const[s,a]of n){const c=a._zod.run({value:o[s],issues:[]},{});c instanceof Promise?(i??(i=[]),i.push(c.then(u=>wo(u,r,s)))):wo(c,r,s)}if(i)return Promise.all(i).then(()=>{})}}),ep=g("$ZodCheckMimeType",(e,t)=>{ie.init(e,t);const n=new Set(t.mime);e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),tp=g("$ZodCheckOverwrite",(e,t)=>{ie.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class sa{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
9
+ <script type="module">const Ey=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),Cy=function(e,t){return new URL(e,t).href},Pl={},Ay=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){let u=function(l){return Promise.all(l.map(d=>Promise.resolve(d).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};const s=document.getElementsByTagName("link"),a=document.querySelector("meta[property=csp-nonce]"),c=a?.nonce||a?.getAttribute("nonce");o=u(n.map(l=>{if(l=Cy(l,r),l in Pl)return;Pl[l]=!0;const d=l.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(r)for(let h=s.length-1;h>=0;h--){const m=s[h];if(m.href===l&&(!d||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${f}`))return;const p=document.createElement("link");if(p.rel=d?"stylesheet":Ey,d||(p.as="script"),p.crossOrigin="",p.href=l,c&&p.setAttribute("nonce",c),document.head.appendChild(p),d)return new Promise((h,m)=>{p.addEventListener("load",h),p.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function i(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return o.then(s=>{for(const a of s||[])a.status==="rejected"&&i(a.reason);return t().catch(i)})};function Ny(e){return e}function Oy(e){return e}function Mo(){return e=>e}function Py(e){}function My(e){throw new Error("Unexpected value in exhaustive check")}function Ry(e){}function So(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,o])=>t.indexOf(+r)===-1).map(([r,o])=>o)}function ws(e,t="|"){return e.map(n=>Ks(n)).join(t)}function Io(e,t){return typeof t=="bigint"?t.toString():t}class Ly{constructor(t){this._getter=t,this._value=void 0}get value(){const t=this._getter;return t!==void 0&&(this._value=t(),this._getter=void 0),this._value}}function Gn(e){return new Ly(e)}function qs(e){return e==null}function vt(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function Hs(e,t){const n=e/t,r=Math.round(n),o=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<o?0:n-r}const Ml=Symbol("evaluating");function Gd(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==Ml)return r===void 0&&(r=Ml,r=n()),r},set(o){Object.defineProperty(e,t,{value:o})},configurable:!0})}function Dy(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Fe(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Ro(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function at(e){return Ro(e._zod.def)??e._zod.def.shape}function Yd(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return Fe(this,t,r),r},enumerable:!0,configurable:!0})}function Qd(e,t,n){t in e?Fe(e,t,n):e[t]=n}function Lt(e,t,n,r){const o=at(t);for(const i of n){const s=Object.getOwnPropertyDescriptor(o,i);s.enumerable&&(s.get?Yd(e,i,()=>{const a=t._zod.def.shape[i];return r?r(a,i):a}):Qd(e,i,r?r(s.value,i):s.value))}}function Zy(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Yd(e,n,()=>t[n]):Qd(e,n,r.value))}}function Se(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function jy(e){return Se(e._zod.def)}function Fy(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function Uy(e){const t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{const o={};for(let i=0;i<t.length;i++)o[t[i]]=r[i];return o})}function Vy(e=10){const t="abcdefghijklmnopqrstuvwxyz";let n="";for(let r=0;r<e;r++)n+=t[Math.floor(Math.random()*t.length)];return n}function De(e){return JSON.stringify(e)}function Xd(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Bs="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Yt(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const ef=Gn(()=>{if(Ee.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ct(e){if(Yt(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(Yt(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Yn(e){return ct(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function qy(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const Hy=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}`)}},xo=new Set(["string","number","symbol"]),tf=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ut(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function oe(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function I(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 By(e){let t;return new Proxy({},{get(n,r,o){return t??(t=e()),Reflect.get(t,r,o)},set(n,r,o,i){return t??(t=e()),Reflect.set(t,r,o,i)},has(n,r){return t??(t=e()),Reflect.has(t,r)},deleteProperty(n,r){return t??(t=e()),Reflect.deleteProperty(t,r)},ownKeys(n){return t??(t=e()),Reflect.ownKeys(t)},getOwnPropertyDescriptor(n,r){return t??(t=e()),Reflect.getOwnPropertyDescriptor(t,r)},defineProperty(n,r,o){return t??(t=e()),Reflect.defineProperty(t,r,o)}})}function Ks(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function nf(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const Js={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]},Ws={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function rf(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i={};return Lt(i,e,Lo(e,t)),oe(e,Se(n,{shape:i,checks:[]}))}function Lo(e,t){const n=at(e),r=[];for(const o of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,o)?.enumerable)throw new Error(`Unrecognized key: "${String(o)}"`);t[o]&&r.push(o)}return r}function of(e,t){const n=e._zod.def,r=n.checks;if(r&&r.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=new Set(Lo(e,t)),s={};return Lt(s,e,Reflect.ownKeys(at(e)).filter(a=>!i.has(a))),oe(e,Se(n,{shape:s,checks:[]}))}function sf(e,t){if(!ct(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const o=at(e);for(const i of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(o,i)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return oe(e,Se(e._zod.def,{shape:af(e,t)}))}function af(e,t){const n={};return Lt(n,e,Reflect.ownKeys(at(e))),Zy(n,t),n}function cf(e,t){if(!ct(t))throw new Error("Invalid input to safeExtend: expected a plain object");return oe(e,Se(e._zod.def,{shape:af(e,t)}))}function uf(e,t){if(!t?._zod?.def)throw new Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n={};Lt(n,e,Reflect.ownKeys(at(e))),Lt(n,t,Reflect.ownKeys(at(t)));const r=Se(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return oe(e,r)}function vs(e,t,n,r="partial"){const i=t._zod.def.checks;if(i&&i.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set(Lo(t,n)):void 0,c={};return Lt(c,t,Reflect.ownKeys(at(t)),e&&((u,l)=>a&&!a.has(l)?u:new e({type:"optional",innerType:u}))),oe(t,Se(t._zod.def,{shape:c,checks:[]}))}function lf(e,t,n){const r=n?new Set(Lo(t,n)):void 0,o={};return Lt(o,t,Reflect.ownKeys(at(t)),(i,s)=>r&&!r.has(s)?i:new e({type:"nonoptional",innerType:i})),oe(t,Se(t._zod.def,{shape:o}))}function Ae(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function df(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function qe(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function Jt(e){return typeof e=="string"?e:e?.message}function ks(e,t,n){var r;for(let o=t;o<e.length;o++)(r=e[o]).schema??(r.schema=n)}function Be(e,t,n){var r;const o=e.inst?._zod?.traits;o?.has("$ZodType")&&(o.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const i=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:Jt(e.inst?._zod.def?.error?.(e))??Jt(i?.(e))??Jt(t?.error?.(e))??Jt(n.customError?.(e))??Jt(n.localeError?.(e))??"Invalid input",a={};for(const c of Object.keys(e))c==="inst"||c==="schema"||c==="continue"||c==="input"||c==="__proto__"||(a[c]=e[c]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}function Do(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}const Ky=/[\uD800-\uDBFF]/;function Qn(e){const t=e.length;if(!Ky.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)===55296&&(e.charCodeAt(r+1)&64512)===56320&&(n--,r++);return n}function Zo(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function ff(e){const t=typeof e;switch(t){case"number":return Number.isNaN(e)?"nan":"number";case"object":{if(e===null)return"null";if(Array.isArray(e))return"array";const n=e;if(n&&Object.getPrototypeOf(n)!==Object.prototype&&"constructor"in n&&n.constructor)return n.constructor.name}}return t}function Qt(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function Jy(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function pf(e){const t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}function hf(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Wy(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return pf(t+n)}function Gy(e){return hf(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Yy(e){const t=e.replace(/^0x/,"");if(t.length%2!==0)throw new Error("Invalid hex string length");const n=new Uint8Array(t.length/2);for(let r=0;r<t.length;r+=2)n[r/2]=Number.parseInt(t.slice(r,r+2),16);return n}function Qy(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class Xy{constructor(...t){}}function mf(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):e_(e,n,r.value)}}function lt(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function jo(e,t,n){return lt(e,t,n,!1)}function Xn(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return lt(this,n,r(this))},set(o){lt(this,n,o)}})}return t}function e_(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:lt(this,t,n.bind(this))},set(r){lt(this,t,r)}})}function t_(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let as,_t=!1;const n_={configurable:!0,get(){_t=!0}};function U(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&as!==e._zod){as=void 0;return}as=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,n_);const o=_t;_t=!1;try{const i=n(this);return _t?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i}),_t=_t||o,i}catch(i){throw delete this[t],_t=_t||o,i}},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o})}})}function gf(e,t,n,r){const o=t_(e,t);o&&Object.defineProperty(o,t,{configurable:!0,get(){const i={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,i),i.value=n(this),Object.defineProperty(this,t,i),i.value},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:i})}})}const Gs="~constantCatch";function Ys(e){const t=()=>e;return t[Gs]=!0,t}const Qs=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:Ws,CONSTANT_CATCH:Gs,Class:Xy,NUMBER_FORMAT_RANGES:Js,aborted:Ae,allowsEval:ef,assert:Ry,assertEqual:Ny,assertIs:Py,assertNever:My,assertNotEqual:Oy,assignProp:Fe,attachSchema:ks,base64ToUint8Array:pf,base64urlToUint8Array:Wy,cached:Gn,captureStackTrace:Bs,cleanEnum:Jy,cleanRegex:vt,clone:oe,cloneDef:jy,codePointLength:Qn,constantCatch:Ys,createTransparentProxy:By,defineLazy:Gd,defineLazyInternal:U,derived:Xn,esc:De,escapeRegex:ut,explicitlyAborted:df,extend:sf,finalizeIssue:Be,floatSafeRemainder:Hs,getElementAtPath:Fy,getEnumValues:So,getLengthableOrigin:Zo,getParsedType:Hy,getSizableOrigin:Do,hexToUint8Array:Yy,hide:jo,installLazyProp:gf,isObject:Yt,isPlainObject:ct,issue:Qt,joinValues:ws,jsonStringifyReplacer:Io,members:mf,merge:uf,mergeDefs:Se,normalizeParams:I,nullish:qs,numKeys:qy,objectClone:Dy,omit:of,optionalKeys:nf,own:lt,parsedType:ff,partial:vs,pick:rf,prefixIssues:qe,primitiveTypes:tf,promiseAllObject:Uy,propertyKeyTypes:xo,randomString:Vy,rawShape:Ro,required:lf,safeExtend:cf,shallowClone:Yn,slugify:Xd,stringifyPrimitive:Ks,toZod:Mo,uint8ArrayToBase64:hf,uint8ArrayToBase64url:Gy,uint8ArrayToHex:Qy,unwrapMessage:Jt},Symbol.toStringTag,{value:"Module"}));var Rl;const Xs=Object.freeze({status:"aborted"}),cs={value:void 0,enumerable:!1};let Ll="captureStackTrace"in Error?Error:null;function r_(e){const t=Ll;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return Ll=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function g(e,t,n,r){const o={};function i(f){this.def=f,this.constr=d,this.traits=new Set}i.prototype=o;const s=n,a=s&&new WeakSet;function c(f,p){if(f._zod){if(f._zod.traits.has(e))return}else{cs.value=new i(p);try{Object.defineProperty(f,"_zod",cs)}finally{cs.value=void 0}}if(f._zod.traits.add(e),t(f,p),a){const m=Object.getPrototypeOf(f),y=f._zod.constr.prototype;let $=m;for(;$&&$!==y;)$=Object.getPrototypeOf($);const w=$??m;a.has(w)||(a.add(w),mf(w,s))}const h=d.prototype;for(const m in h)Object.prototype.hasOwnProperty.call(h,m)&&(m in f||(f[m]=h[m].bind(f)))}const u=r?.Parent??Object;class l extends u{}Object.defineProperty(l,"name",{value:e});function d(f){const p=r?.Parent?r_(l):this;c(p,f);const h=p._zod.deferred;if(h){for(const y of h)y();p._zod.deferred=void 0}const m=globalThis.__zod_globalConfig?.postProcessor;return m&&m(p),p}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:f=>r?.Parent&&f instanceof r.Parent?!0:f?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}const ea=Symbol("zod_brand");class st extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Fo extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Rl=globalThis).__zod_globalConfig??(Rl.__zod_globalConfig={});const Ee=globalThis.__zod_globalConfig;function me(e){return e&&Object.assign(Ee,e),Ee}function o_(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,Io,2)),e.message}function i_(e){this._zod.message=e}const s_={get:o_,set:i_,enumerable:!0,configurable:!0},us={value:void 0,enumerable:!1},Dl=new WeakSet([Object.prototype,Error.prototype]),yf=(e,t)=>{e.name="$ZodError",us.value=t,Object.defineProperty(e,"issues",us),us.value=void 0,Object.defineProperty(e,"message",s_);const n=Object.getPrototypeOf(e);Dl.has(n)||(Dl.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){const r=()=>this.message;return Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,"toString",{value:r,configurable:!0,writable:!0})}}))},_f=g("$ZodError",yf),Ue=g("$ZodError",yf,void 0,{Parent:Error});function a_(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t==="__proto__"?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function Uo(e,t=n=>n.message){const n={},r=[];for(const o of e.issues)o.path.length>0?a_(n,o.path[0],()=>[]).push(t(o)):r.push(t(o));return{formErrors:r,fieldErrors:n}}function Vo(e,t=n=>n.message){const n={_errors:[]},r=(o,i=[])=>{for(const s of o.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...i,...s.path]);else{const a=[...i,...s.path];if(a.length===0)n._errors.push(t(s));else{let c=n,u=0;for(;u<a.length;){const l=a[u],d=u===a.length-1;if(l==="_errors"){d&&c._errors.push(t(s)),u++;continue}Object.prototype.hasOwnProperty.call(c,l)||Object.defineProperty(c,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const f=c[l];d&&f._errors.push(t(s)),c=f,u++}}}};return r(e),n}function ta(e,t=n=>n.message){const n={errors:[]},r=(o,i=[])=>{var s;for(const a of o.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(c=>r({issues:c},[...i,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...i,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...i,...a.path]);else{const c=[...i,...a.path];if(c.length===0){n.errors.push(t(a));continue}let u=n,l=0;for(;l<c.length;){const d=c[l],f=l===c.length-1;typeof d=="string"?(u.properties??(u.properties={}),Object.prototype.hasOwnProperty.call(u.properties,d)||Object.defineProperty(u.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),u=u.properties[d]):(u.items??(u.items=[]),(s=u.items)[d]??(s[d]={errors:[]}),u=u.items[d]),f&&u.errors.push(t(a)),l++}}};return r(e),n}function bf(e){const t=[],n=e.map(r=>typeof r=="object"?r.key:r);for(const r of n)typeof r=="number"?t.push(`[${r}]`):typeof r=="symbol"?t.push(`[${JSON.stringify(String(r))}]`):/[^\w$]/.test(r)?t.push(`[${JSON.stringify(r)}]`):(t.length&&t.push("."),t.push(r));return t.join("")}function na(e){const t=[],n=[...e.issues].sort((r,o)=>(r.path??[]).length-(o.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${bf(r.path)}`);return t.join(`
10
+ `)}function qo(e,t){return{callee:t?.callee??e,Err:t?.Err}}const er=e=>{const t=(n,r,o,i)=>{const s=o?{...o,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new st;if(a.issues.length){const c=new(i?.Err??e)(a.issues.map(u=>Be(u,s,me())));throw Bs(c,i?.callee??t),c}return a.value};return t},$s=er(Ue),tr=e=>{const t=async(n,r,o,i)=>{const s=o?{...o,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const c=new(i?.Err??e)(a.issues.map(u=>Be(u,s,me())));throw Bs(c,i?.callee??t),c}return a.value};return t},Ss=tr(Ue),nr=e=>(t,n,r)=>{const o=r?{...r,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},o);if(i instanceof Promise)throw new st;return i.issues.length?vf(e,i.issues,o):{success:!0,data:i.value}},wf=nr(Ue);function vf(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(o=>Be(o,n,me()))),t=void 0,n=void 0),r},set error(o){r=o,t=void 0,n=void 0}}}const rr=e=>async(t,n,r)=>{const o=r?{...r,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},o);return i instanceof Promise&&(i=await i),i.issues.length?vf(e,i.issues,o):{success:!0,data:i.value}},c_=rr(Ue),u_=Symbol.for("zod.compile.invalid"),l_=Symbol.for("zod.compile.fallback"),Ho=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==u_)return!0;if(r.definite===!0&&n===void 0)return!1}return d_(e,t,n)});function d_(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},o=e._zod.bag.fallbackRun;let i;if(o?(r[l_]=!0,i=o({value:t,issues:[]},r)):i=e._zod.run({value:t,issues:[]},r),i instanceof Promise)throw new st;return i.issues.length===0}const Bo=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let o=e._zod.run({value:t,issues:[]},r);return o instanceof Promise&&(o=await o),o.issues.length===0},ra=e=>{const t=er(e),n=(r,o,i,s)=>{const a=i?{...i,direction:"backward"}:{direction:"backward"};return t(r,o,a,qo(n,s))};return n},f_=ra(Ue),oa=e=>{const t=er(e),n=(r,o,i,s)=>t(r,o,i,qo(n,s));return n},p_=oa(Ue),ia=e=>{const t=tr(e),n=async(r,o,i,s)=>{const a=i?{...i,direction:"backward"}:{direction:"backward"};return await t(r,o,a,qo(n,s))};return n},h_=ia(Ue),sa=e=>{const t=tr(e),n=async(r,o,i,s)=>await t(r,o,i,qo(n,s));return n},m_=sa(Ue),aa=e=>(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return nr(e)(t,n,o)},g_=aa(Ue),ca=e=>(t,n,r)=>nr(e)(t,n,r),y_=ca(Ue),ua=e=>async(t,n,r)=>{const o=r?{...r,direction:"backward"}:{direction:"backward"};return rr(e)(t,n,o)},__=ua(Ue),la=e=>async(t,n,r)=>rr(e)(t,n,r),b_=la(Ue),kf=/^[cC][0-9a-z]{6,}$/,$f=/^[0-9a-z]+$/,Sf=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,If=/^[0-9a-vA-V]{20}$/,xf=/^[A-Za-z0-9]{27}$/,zf=/^[a-zA-Z0-9_-]{21}$/;function Tf(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Ef=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,w_=/^[-+]?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)?)??$/,Cf=/^([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})$/,Xt=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)$/,v_=Xt(4),k_=Xt(6),$_=Xt(7),Af=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,S_=/^[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])?)*$/,I_=/^(([^<>()\[\]\\.,;:\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,}))$/,Nf=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,x_=Nf,z_=/^[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])?)*$/,T_="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Of(){return new RegExp(T_,"u")}const Pf=/^(?:(?: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])$/,Mf=/^(([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}|:))$/,Rf=e=>{const t=ut(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},Lf=/^((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])$/,Df=/^(([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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Zf=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,jf=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Ff=/^(?=.{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])?)*\.?$/,Uf=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,da=/^https?$/,Vf=/^\+[1-9]\d{6,14}$/,fa=/^\d(?:[ -]?\d){11,18}$/,qf=/^(?:AED|AFN|ALL|AMD|AOA|ARS|AUD|AWG|AZN|BAM|BBD|BDT|BHD|BIF|BMD|BND|BOB|BOV|BRL|BSD|BTN|BWP|BYN|BZD|CAD|CDF|CHE|CHF|CHW|CLF|CLP|CNY|COP|COU|CRC|CUP|CVE|CZK|DJF|DKK|DOP|DZD|EGP|ERN|ETB|EUR|FJD|FKP|GBP|GEL|GHS|GIP|GMD|GNF|GTQ|GYD|HKD|HNL|HTG|HUF|IDR|ILS|INR|IQD|IRR|ISK|JMD|JOD|JPY|KES|KGS|KHR|KMF|KPW|KRW|KWD|KYD|KZT|LAK|LBP|LKR|LRD|LSL|LYD|MAD|MDL|MGA|MKD|MMK|MNT|MOP|MRU|MUR|MVR|MWK|MXN|MXV|MYR|MZN|NAD|NGN|NIO|NOK|NPR|NZD|OMR|PAB|PEN|PGK|PHP|PKR|PLN|PYG|QAR|RON|RSD|RUB|RWF|SAR|SBD|SCR|SDG|SEK|SGD|SHP|SLE|SOS|SRD|SSP|STN|SVC|SYP|SZL|THB|TJS|TMT|TND|TOP|TRY|TTD|TWD|TZS|UAH|UGX|USD|USN|UYI|UYU|UYW|UZS|VED|VES|VND|VUV|WST|XAD|XAF|XAG|XAU|XBA|XBB|XBC|XBD|XCD|XCG|XDR|XOF|XPD|XPF|XPT|XSU|XTS|XUA|XXX|YER|ZAR|ZMW|ZWG)$/,pa=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,Hf="(?:(?:\\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])))";function E_(e){return new RegExp(`^${e}$`)}const Bf=E_(Hf);function Is(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}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function Kf(e){return new RegExp(`^${Is(e)}$`)}function Jf(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Is({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Is({precision:e.precision})}`:n;return new RegExp(`^${Hf}T(?:${r})$`)}const Wf=/^[\s\S]{0,}$/,Gf=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},Yf=/^-?\d+n?$/,ha=/^-?\d+$/,ln=/^-?\d+(?:\.\d+)?$/,Qf=/^(?:true|false)$/i,Xf=/^null$/i,ep=/^undefined$/i,tp=/^[^A-Z]*$/,np=/^[^a-z]*$/,rp=/^[0-9a-fA-F]*$/;function or(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function ir(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const C_=/^[0-9a-fA-F]{32}$/,A_=or(22,"=="),N_=ir(22),O_=/^[0-9a-fA-F]{40}$/,P_=or(27,"="),M_=ir(27),R_=/^[0-9a-fA-F]{64}$/,L_=or(43,"="),D_=ir(43),Z_=/^[0-9a-fA-F]{96}$/,j_=or(64,""),F_=ir(64),U_=/^[0-9a-fA-F]{128}$/,V_=or(86,"=="),q_=ir(86),Ko=Object.freeze(Object.defineProperty({__proto__:null,anyString:Wf,base64:Zf,base64url:jf,bigint:Yf,boolean:Qf,browserEmail:z_,cidrv4:Lf,cidrv6:Df,creditCard:fa,cuid:kf,cuid2:$f,currencyCode:qf,date:Bf,datetime:Jf,domain:Uf,duration:Ef,e164:Vf,email:Af,emoji:Of,extendedDuration:w_,guid:Cf,hex:rp,hostname:Ff,html5Email:S_,httpProtocol:da,iban:pa,idnEmail:x_,integer:ha,ipv4:Pf,ipv6:Mf,ksuid:xf,lowercase:tp,mac:Rf,md5_base64:A_,md5_base64url:N_,md5_hex:C_,nanoid:zf,nanoidOfLength:Tf,null:Xf,number:ln,rfc5322Email:I_,sha1_base64:P_,sha1_base64url:M_,sha1_hex:O_,sha256_base64:L_,sha256_base64url:D_,sha256_hex:R_,sha384_base64:j_,sha384_base64url:F_,sha384_hex:Z_,sha512_base64:V_,sha512_base64url:q_,sha512_hex:U_,string:Gf,time:Kf,ulid:Sf,undefined:ep,unicodeEmail:Nf,uppercase:np,uuid:Xt,uuid4:v_,uuid6:k_,uuid7:$_,xid:If},Symbol.toStringTag,{value:"Module"})),ie=g("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),ma=e=>{const t=e.value;return!qs(t)&&t.size!==void 0},ga=e=>{const t=e.value;return!qs(t)&&t.length!==void 0},zo={number:"number",bigint:"bigint",object:"date"},ya=g("$ZodCheckLessThan",(e,t)=>{ie.init(e,t);const n=zo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:zo[typeof r.value]??n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),_a=g("$ZodCheckGreaterThan",(e,t)=>{ie.init(e,t);const n=zo[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:zo[typeof r.value]??n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),op=g("$ZodCheckMultipleOf",(e,t)=>{ie.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Hs(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:"not_multiple_of",divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),ip=g("$ZodCheckNumberFormat",(e,t)=>{ie.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[o,i]=Js[t.format];e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:r,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}a<o&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:o,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),sp=g("$ZodCheckBigIntFormat",(e,t)=>{ie.init(e,t);const[n,r]=Ws[t.format];e._zod.check=o=>{const i=o.value;i<n&&o.issues.push({origin:"bigint",input:i,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),i>r&&o.issues.push({origin:"bigint",input:i,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),ap=g("$ZodCheckMaxSize",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=ma),e._zod.check=r=>{const o=r.value;o.size<=t.maximum||r.issues.push({origin:Do(o),code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),cp=g("$ZodCheckMinSize",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=ma),e._zod.check=r=>{const o=r.value;o.size>=t.minimum||r.issues.push({origin:Do(o),code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),up=g("$ZodCheckSizeEquals",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=ma),e._zod.check=r=>{const o=r.value,i=o.size;if(i===t.size)return;const s=i>t.size;r.issues.push({origin:Do(o),...s?{code:"too_big",maximum:t.size}:{code:"too_small",minimum:t.size},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),lp=g("$ZodCheckMaxLength",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=ga),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>t.maximum?Qn(o):i)<=t.maximum)return;const a=Zo(o);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),dp=g("$ZodCheckMinLength",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=ga),e._zod.check=r=>{const o=r.value,i=o.length;if((typeof o=="string"&&i>=t.minimum&&i<t.minimum*2?Qn(o):i)>=t.minimum)return;const a=Zo(o);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:o,inst:e,continue:!t.abort})}}),fp=g("$ZodCheckLengthEquals",(e,t)=>{var n;ie.init(e,t),(n=e._zod.def).when??(n.when=ga),e._zod.check=r=>{const o=r.value,i=o.length,s=typeof o=="string"&&i>=t.length&&i<=t.length*2?Qn(o):i;if(s===t.length)return;const a=Zo(o),c=s>t.length;r.issues.push({origin:a,...c?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),sr=g("$ZodCheckStringFormat",(e,t)=>{var n,r;ie.init(e,t),t.pattern?(n=e._zod).check??(n.check=o=>{t.pattern.lastIndex=0,!t.pattern.test(o.value)&&o.issues.push({origin:"string",code:"invalid_format",format:t.format,input:o.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),pp=g("$ZodCheckRegex",(e,t)=>{sr.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:"string",code:"invalid_format",format:"regex",input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),hp=g("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=tp),sr.init(e,t)}),mp=g("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=np),sr.init(e,t)}),gp=g("$ZodCheckIncludes",(e,t)=>{ie.init(e,t);const n=ut(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=o=>{o.value.includes(t.includes,t.position)||o.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:o.value,inst:e,continue:!t.abort})}}),yp=g("$ZodCheckStartsWith",(e,t)=>{ie.init(e,t);const n=new RegExp(`^${ut(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.startsWith(t.prefix)||r.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:r.value,inst:e,continue:!t.abort})}}),_p=g("$ZodCheckEndsWith",(e,t)=>{ie.init(e,t);const n=new RegExp(`.*${ut(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.check=r=>{r.value.endsWith(t.suffix)||r.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:r.value,inst:e,continue:!t.abort})}});function To(e,t,n){e.issues.length&&t.issues.push(...qe(n,e.issues))}const bp=g("$ZodCheckProperty",(e,t)=>{ie.init(e,t),e._zod.check=n=>{const r=t.schema._zod.run({value:n.value[t.property],issues:[]},{});if(r instanceof Promise)return r.then(o=>To(o,n,t.property));To(r,n,t.property)}}),wp=g("$ZodCheckProperties",(e,t)=>{ie.init(e,t),jo(e,Symbol.iterator,function*(){yield e});let n;e._zod.check=r=>{if(r.value==null){r.issues.push({expected:"object",code:"invalid_type",input:r.value,inst:e});return}n??(n=Reflect.ownKeys(t.shape).map(s=>[s,t.shape[s]]));const o=r.value;let i;for(const[s,a]of n){const c=a._zod.run({value:o[s],issues:[]},{});c instanceof Promise?(i??(i=[]),i.push(c.then(u=>To(u,r,s)))):To(c,r,s)}if(i)return Promise.all(i).then(()=>{})}}),vp=g("$ZodCheckMimeType",(e,t)=>{ie.init(e,t);const n=new Set(t.mime);e._zod.check=r=>{n.has(r.value.type)||r.issues.push({code:"invalid_value",values:t.mime,input:r.value.type,inst:e,continue:!t.abort})}}),kp=g("$ZodCheckOverwrite",(e,t)=>{ie.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class ba{constructor(t=[],n={}){this.content=[],this.indent=0,this.args=t,this.closed=n}indented(t){this.indent+=1;try{t(this)}finally{this.indent-=1}}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const r=t.split(`
11
11
  `).filter(s=>s),o=Math.min(...r.map(s=>s.length-s.trimStart().length)),i=r.map(s=>s.slice(o)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.content??[""];return new t(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
12
12
  ${n.join(`
13
13
  `)}
14
- };`)(...Object.values(this.closed))}}const np={major:4,minor:6,patch:5},L=g("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=np;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const i of o)for(const s of i._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const i=(a,c,u)=>{if(a.memo)return a;let l=Ce(a),d;for(const f of c){if(f._zod.def.when){if(Vd(a)||!f._zod.def.when(a))continue}else if(l)continue;const p=a.issues.length,h=f._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new tt;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,a.issues.length!==p&&(fs(a.issues,p,e),l||(l=Ce(a,p)))});else{if(a.issues.length===p)continue;fs(a.issues,p,e),l||(l=Ce(a,p))}}return d?d.then(()=>a):a},s=(a,c,u)=>{if(Ce(a))return a.aborted=!0,a;const l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new tt;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>s(d,a,c)):s(l,a,c)}const u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new tt;return u.then(l=>i(l,o,c))}return i(u,o,c)}}},{get"~standard"(){return Oo(this,"~standard",aa(this))},set"~standard"(e){it(this,"~standard",e)}}),rp=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Fe(n,t,me()))}:{value:e.value};async function l_(e,t){const n={async:!0};return rp(await e._zod.run({value:t,issues:[]},n),n)}function aa(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return rp(r,n)}catch{}return l_(e,t)},vendor:"zod",version:1}}const tr=g("$ZodString",(e,t)=>{L.init(e,t),e._zod.pattern=t.pattern??Tf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),te=g("$ZodStringFormat",(e,t)=>{er.init(e,t),tr.init(e,t)}),op=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=uf),te.init(e,t)}),ip=g("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Gt(r))}else t.pattern??(t.pattern=Gt());te.init(e,t)}),sp=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=lf),te.init(e,t)}),ca=1,Rn=2;function ua(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function la(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?ua(e)||Rn:ap(e,t)}function ap(e,t){if(!t.normalize&&t.protocol?.source===Qs.source&&!/^https?:\/\//i.test(e))return ca;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??Rn}return new URL(e)}catch{return Rn}}const d_=/[\t\n\r]/g;function vo(e){return e.replace(d_,"")}function da(e,t){return t.lastIndex=0,t.test(e.hostname)}function fa(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const cp=g("$ZodURL",(e,t)=>{te.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=la(r,t);if(o===ca){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===Rn){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(o===!0){n.value=vo(r);return}t.hostname&&!da(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!fa(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:vo(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),up=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=ff()),te.init(e,t)}),lp=g("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?sf:af(t.length)),te.init(e,t)}),dp=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=ef),te.init(e,t)}),fp=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=tf),te.init(e,t)}),pp=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=nf),te.init(e,t)}),hp=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=rf),te.init(e,t)}),mp=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=of),te.init(e,t)}),gp=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=xf(t)),te.init(e,t)}),yp=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=If),te.init(e,t)}),_p=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=zf(t)),te.init(e,t)}),bp=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=cf),te.init(e,t)}),wp=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=pf),te.init(e,t)}),f_=/^[0-9a-fA-F:.]+$/;function jo(e){return f_.test(e)?ua(`http://[${e}]`):!1}const vp=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=hf),te.init(e,t),e._zod.check=n=>{jo(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),kp=g("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=mf(t.delimiter)),te.init(e,t)}),$p=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=gf),te.init(e,t)});function pa(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const o=Number(r);return`${o}`!==r||o<0||o>128?!1:jo(n)}const Sp=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=yf),te.init(e,t),e._zod.check=n=>{pa(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Fo(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const ha=/^[0-9a-zA-Z+/]*={0,2}$/,Ip=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ha),te.init(e,t),e._zod.check=n=>{Fo(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Uo=/^[A-Za-z0-9_-]*$/;function ma(e){if(!Uo.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Fo(n)}const zp=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Uo),te.init(e,t),e._zod.check=n=>{ma(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),xp=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=kf),te.init(e,t)}),p_=/[- ]/g;function h_(e){let t=e.length,n=1,r=0;for(;t;){const o=e.charCodeAt(--t)-48;n^=1,r+=n?[0,2,4,6,8,1,3,5,7,9][o]:o}return r%10===0}function ga(e){return Xs.test(e)?h_(e.replace(p_,"")):!1}const Tp=g("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=Xs),te.init(e,t),e._zod.check=n=>{ga(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function m_(e){let t=0;const n=e.length;for(let r=4;r<n;r++){const o=e.charCodeAt(r);t=(o>=65?t*100+(o-55):t*10+(o-48))%97}for(let r=0;r<4;r++){const o=e.charCodeAt(r);t=(o>=65?t*100+(o-55):t*10+(o-48))%97}return t===1}function ya(e){return ea.test(e)?m_(e):!1}const Cp=g("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=ea),te.init(e,t),e._zod.check=n=>{ya(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function _a(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Ep=g("$ZodJWT",(e,t)=>{te.init(e,t),e._zod.check=n=>{_a(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Np=g("$ZodCustomStringFormat",(e,t)=>{te.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),ba=g("$ZodNumber",(e,t)=>{L.init(e,t),e._zod.pattern=an,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Op=g("$ZodNumberFormat",(e,t)=>{Zf.init(e,t),ba.init(e,t)}),wa=g("$ZodBoolean",(e,t)=>{L.init(e,t),e._zod.pattern=Nf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),va=g("$ZodBigInt",(e,t)=>{L.init(e,t),e._zod.pattern=Ef,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),Pp=g("$ZodBigIntFormat",(e,t)=>{Df.init(e,t),va.init(e,t)}),Ap=g("$ZodSymbol",(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;return typeof o=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),n}}),Mp=g("$ZodUndefined",(e,t)=>{L.init(e,t),e._zod.pattern=Pf,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{const o=n.value;return typeof o>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}}),Rp=g("$ZodNull",(e,t)=>{L.init(e,t),e._zod.pattern=Of,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),Lp=g("$ZodAny",(e,t)=>{L.init(e,t),e._zod.parse=n=>n}),Zp=g("$ZodUnknown",(e,t)=>{L.init(e,t),e._zod.parse=n=>n}),Dp=g("$ZodNever",(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),jp=g("$ZodVoid",(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;return typeof o>"u"||n.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),n}}),Fp=g("$ZodDate",(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const o=n.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});function Tl(e,t,n){e.issues.length&&t.issues.push(...De(n,e.issues)),t.value[n]=e.value}const Up=g("$ZodArray",(e,t)=>{L.init(e,t);const n=ze.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);const s=[],a=o?.abortEarly;for(let c=0;c<i.length;c++){const u=i[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then(d=>Tl(d,r,c)));else if(Tl(l,r,c),a&&l.issues.length!==0&&Ce(l))break}return s.length?Promise.all(s).then(()=>r):r}});function ko(e,t,n,r,o,i){const s=n in r,a=i==="optional";if(!(!s&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...De(n,e.issues))}if(!s&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(s||o==="defaulted"&&!a)&&(t.value[n]=void 0):t.value[n]=e.value}}const g_=[];function Vp(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:g_,o=r.length?[...t,...r]:t;for(const s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);const i=Md(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function qp(e,t,n,r,o,i,s){const a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,f=u.optout;let p=0;for(const h in t){if(s&&n.issues.length!==p){if(Ce(n,p))break;p=n.issues.length}if(c.has(h))continue;if(h==="__proto__"){l==="never"&&a.push(h);continue}if(l==="never"){a.push(h);continue}const m=u.run({value:t[h],issues:[]},r);m instanceof Promise?e.push(m.then(k=>ko(k,n,h,t,d,f))):ko(m,n,h,t,d,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Hp=g("$ZodObject",(e,t)=>{L.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const u=()=>{const l={...r};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=r,Object.defineProperty(t,"shape",{get:u})}const o=qn(()=>Vp(t));F(e,"propValues",u=>{const l=u.def.shape,d={};for(const f in l){const p=l[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||Re(d,f,new Set);for(const h of p.values)d[f].add(h);p.optin!==void 0&&d[f].add(void 0)}}return d});const i=Jt,s=t.catchall;let a;const c=ze.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);const d=u.value;if(!i(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};const f=[],p=a.shape,h=l?.abortEarly;let m=u.issues.length;for(const k of a.allKeys){if(h&&u.issues.length!==m){if(Ce(u,m))break;m=u.issues.length}if(k==="__proto__")continue;const I=p[k],v=I._zod.optin,z=I._zod.optout,C=I._zod.run({value:d[k],issues:[]},l);C instanceof Promise?f.push(C.then(R=>ko(R,u,k,d,v,z))):ko(C,u,k,d,v,z)}return s?qp(f,d,u,l,o.value,e,h===!0):f.length?Promise.all(f).then(()=>u):u}}),Bp=g("$ZodObjectJIT",(e,t)=>{Hp.init(e,t);const n=e._zod.parse,r=qn(()=>Vp(t)),o=ze.memoizer,i=p=>{const h=r.value,m=h.symbolKeys,k=new sa(["payload","ctx"],{shape:p,inst:e,memo:o,syms:m}),I=R=>`shape[${R}]._zod.run({ value: input[${R}], issues: [] }, ctx)`,v=(R,N)=>`
15
- let ${R}_ab = false;
16
- for (let i = 0; i < ${R}.issues.length; i++) {
17
- const iss = ${R}.issues[i];
18
- iss.path = iss.path ? [${N}, ...iss.path] : [${N}];
14
+ };`)(...Object.values(this.closed))}}const $p={major:4,minor:6,patch:5},D=g("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=$p;const r=e._zod.def.checks,o=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const i of o)for(const s of i._zod.onattach)s(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const i=(a,c,u)=>{if(a.memo)return a;let l=Ae(a),d;for(const f of c){if(f._zod.def.when){if(df(a)||!f._zod.def.when(a))continue}else if(l)continue;const p=a.issues.length,h=f._zod.check(a);if(h instanceof Promise&&u?.async===!1)throw new st;if(d||h instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await h,a.issues.length!==p&&(ks(a.issues,p,e),l||(l=Ae(a,p)))});else{if(a.issues.length===p)continue;ks(a.issues,p,e),l||(l=Ae(a,p))}}return d?d.then(()=>a):a},s=(a,c,u)=>{if(Ae(a))return a.aborted=!0,a;const l=i(c,o,u);if(l instanceof Promise){if(u.async===!1)throw new st;return l.then(d=>e._zod.parse(d,u))}return e._zod.parse(l,u)};e._zod.run=(a,c)=>{if(c.skipChecks)return e._zod.parse(a,c);if(c.direction==="backward"){const l=e._zod.parse({value:a.value,issues:[]},{...c,skipChecks:!0});return l instanceof Promise?l.then(d=>s(d,a,c)):s(l,a,c)}const u=e._zod.parse(a,c);if(u instanceof Promise){if(c.async===!1)throw new st;return u.then(l=>i(l,o,c))}return i(u,o,c)}}},{get"~standard"(){return jo(this,"~standard",wa(this))},set"~standard"(e){lt(this,"~standard",e)}}),Sp=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Be(n,t,me()))}:{value:e.value};async function H_(e,t){const n={async:!0};return Sp(await e._zod.run({value:t,issues:[]},n),n)}function wa(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Sp(r,n)}catch{}return H_(e,t)},vendor:"zod",version:1}}const ar=g("$ZodString",(e,t)=>{D.init(e,t),e._zod.pattern=t.pattern??Wf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value=="string"||n.issues.push({expected:"string",code:"invalid_type",input:n.value,inst:e}),n}}),ne=g("$ZodStringFormat",(e,t)=>{sr.init(e,t),ar.init(e,t)}),Ip=g("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Cf),ne.init(e,t)}),xp=g("$ZodUUID",(e,t)=>{if(t.version){const r={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(r===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Xt(r))}else t.pattern??(t.pattern=Xt());ne.init(e,t)}),zp=g("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Af),ne.init(e,t)}),va=1,Un=2;function ka(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function $a(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?ka(e)||Un:Tp(e,t)}function Tp(e,t){if(!t.normalize&&t.protocol?.source===da.source&&!/^https?:\/\//i.test(e))return va;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??Un}return new URL(e)}catch{return Un}}const B_=/[\t\n\r]/g;function Eo(e){return e.replace(B_,"")}function Sa(e,t){return t.lastIndex=0,t.test(e.hostname)}function Ia(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const Ep=g("$ZodURL",(e,t)=>{ne.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),o=$a(r,t);if(o===va){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(o===Un){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(o===!0){n.value=Eo(r);return}t.hostname&&!Sa(o,t.hostname)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Ia(o,t.protocol)&&n.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?o.href:Eo(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Cp=g("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Of()),ne.init(e,t)}),Ap=g("$ZodNanoID",(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw new Error(`Invalid nanoid length: ${t.length}`);t.pattern??(t.pattern=t.length===void 0?zf:Tf(t.length)),ne.init(e,t)}),Np=g("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=kf),ne.init(e,t)}),Op=g("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=$f),ne.init(e,t)}),Pp=g("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Sf),ne.init(e,t)}),Mp=g("$ZodXID",(e,t)=>{t.pattern??(t.pattern=If),ne.init(e,t)}),Rp=g("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=xf),ne.init(e,t)}),Lp=g("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=Jf(t)),ne.init(e,t)}),Dp=g("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=Bf),ne.init(e,t)}),Zp=g("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=Kf(t)),ne.init(e,t)}),jp=g("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Ef),ne.init(e,t)}),Fp=g("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Pf),ne.init(e,t)}),K_=/^[0-9a-fA-F:.]+$/;function Jo(e){return K_.test(e)?ka(`http://[${e}]`):!1}const Up=g("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Mf),ne.init(e,t),e._zod.check=n=>{Jo(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),Vp=g("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Rf(t.delimiter)),ne.init(e,t)}),qp=g("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Lf),ne.init(e,t)});function xa(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const o=Number(r);return`${o}`!==r||o<0||o>128?!1:Jo(n)}const Hp=g("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=Df),ne.init(e,t),e._zod.check=n=>{xa(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Wo(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const za=/^[0-9a-zA-Z+/]*={0,2}$/,Bp=g("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=za),ne.init(e,t),e._zod.check=n=>{Wo(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Go=/^[A-Za-z0-9_-]*$/;function Ta(e){if(!Go.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Wo(n)}const Kp=g("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Go),ne.init(e,t),e._zod.check=n=>{Ta(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Jp=g("$ZodE164",(e,t)=>{t.pattern??(t.pattern=Vf),ne.init(e,t)}),J_=/[- ]/g;function W_(e){let t=e.length,n=1,r=0;for(;t;){const o=e.charCodeAt(--t)-48;n^=1,r+=n?[0,2,4,6,8,1,3,5,7,9][o]:o}return r%10===0}function Ea(e){return fa.test(e)?W_(e.replace(J_,"")):!1}const Wp=g("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=fa),ne.init(e,t),e._zod.check=n=>{Ea(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function G_(e){let t=0;const n=e.length;for(let r=4;r<n;r++){const o=e.charCodeAt(r);t=(o>=65?t*100+(o-55):t*10+(o-48))%97}for(let r=0;r<4;r++){const o=e.charCodeAt(r);t=(o>=65?t*100+(o-55):t*10+(o-48))%97}return t===1}function Ca(e){return pa.test(e)?G_(e):!1}const Gp=g("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=pa),ne.init(e,t),e._zod.check=n=>{Ca(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function Aa(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const o=JSON.parse(atob(r));return!("typ"in o&&o?.typ!=="JWT"||!o.alg||t&&(!("alg"in o)||o.alg!==t))}catch{return!1}}const Yp=g("$ZodJWT",(e,t)=>{ne.init(e,t),e._zod.check=n=>{Aa(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Qp=g("$ZodCustomStringFormat",(e,t)=>{ne.init(e,t),e._zod.check=n=>{t.fn(n.value)||n.issues.push({code:"invalid_format",format:t.format,input:n.value,inst:e,continue:!t.abort})}}),Na=g("$ZodNumber",(e,t)=>{D.init(e,t),e._zod.pattern=ln,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const o=n.value;if(typeof o=="number"&&!Number.isNaN(o)&&Number.isFinite(o))return n;const i=typeof o=="number"?Number.isNaN(o)?"NaN":Number.isFinite(o)?void 0:String(o):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:o,inst:e,...i?{received:i}:{}}),n}}),Xp=g("$ZodNumberFormat",(e,t)=>{ip.init(e,t),Na.init(e,t)}),Oa=g("$ZodBoolean",(e,t)=>{D.init(e,t),e._zod.pattern=Qf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const o=n.value;return typeof o=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:o,inst:e}),n}}),Pa=g("$ZodBigInt",(e,t)=>{D.init(e,t),e._zod.pattern=Yf,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=BigInt(n.value)}catch{}return typeof n.value=="bigint"||n.issues.push({expected:"bigint",code:"invalid_type",input:n.value,inst:e}),n}}),eh=g("$ZodBigIntFormat",(e,t)=>{sp.init(e,t),Pa.init(e,t)}),th=g("$ZodSymbol",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;return typeof o=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:o,inst:e}),n}}),nh=g("$ZodUndefined",(e,t)=>{D.init(e,t),e._zod.pattern=ep,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{const o=n.value;return typeof o>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:o,inst:e}),n}}),rh=g("$ZodNull",(e,t)=>{D.init(e,t),e._zod.pattern=Xf,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const o=n.value;return o===null||n.issues.push({expected:"null",code:"invalid_type",input:o,inst:e}),n}}),oh=g("$ZodAny",(e,t)=>{D.init(e,t),e._zod.parse=n=>n}),ih=g("$ZodUnknown",(e,t)=>{D.init(e,t),e._zod.parse=n=>n}),sh=g("$ZodNever",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),ah=g("$ZodVoid",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;return typeof o>"u"||n.issues.push({expected:"void",code:"invalid_type",input:o,inst:e}),n}}),ch=g("$ZodDate",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const o=n.value,i=o instanceof Date;return i&&!Number.isNaN(o.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:o,...i?{received:"Invalid Date"}:{},inst:e}),n}});function Zl(e,t,n){e.issues.length&&t.issues.push(...qe(n,e.issues)),t.value[n]=e.value}const uh=g("$ZodArray",(e,t)=>{D.init(e,t);const n=Ee.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=n?n.alloc(e,r,Array(i.length),o):Array(i.length);const s=[],a=o?.abortEarly;for(let c=0;c<i.length;c++){const u=i[c],l=t.element._zod.run({value:u,issues:[]},o);if(l instanceof Promise)s.push(l.then(d=>Zl(d,r,c)));else if(Zl(l,r,c),a&&l.issues.length!==0&&Ae(l))break}return s.length?Promise.all(s).then(()=>r):r}});function Co(e,t,n,r,o,i){const s=n in r,a=i==="optional";if(!(!s&&a&&o==="optional")){if(e.issues.length){if(o!==void 0&&a&&!s)return;t.issues.push(...qe(n,e.issues))}if(!s&&o===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(s||o==="defaulted"&&!a)&&(t.value[n]=void 0):t.value[n]=e.value}}const Y_=[];function lh(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Y_,o=r.length?[...t,...r]:t;for(const s of o)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);const i=nf(e.shape);return{...e,allKeys:o,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(i)}}function dh(e,t,n,r,o,i,s){const a=[],c=o.keySet,u=o.catchall._zod,l=u.def.type,d=u.optin,f=u.optout;let p=0;for(const h in t){if(s&&n.issues.length!==p){if(Ae(n,p))break;p=n.issues.length}if(c.has(h))continue;if(h==="__proto__"){l==="never"&&a.push(h);continue}if(l==="never"){a.push(h);continue}const m=u.run({value:t[h],issues:[]},r);m instanceof Promise?e.push(m.then(y=>Co(y,n,h,t,d,f))):Co(m,n,h,t,d,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:i,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const fh=g("$ZodObject",(e,t)=>{D.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const u=()=>{const l={...r};return Object.defineProperty(t,"shape",{value:l}),u.raw=l,l};u.raw=r,Object.defineProperty(t,"shape",{get:u})}const o=Gn(()=>lh(t));U(e,"propValues",u=>{const l=u.def.shape,d={};for(const f in l){const p=l[f]._zod;if(p.values){Object.prototype.hasOwnProperty.call(d,f)||Fe(d,f,new Set);for(const h of p.values)d[f].add(h);p.optin!==void 0&&d[f].add(void 0)}}return d});const i=Yt,s=t.catchall;let a;const c=Ee.memoizer;c?.attach(e),e._zod.parse=(u,l)=>{a??(a=o.value);const d=u.value;if(!i(d))return u.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),u;u.value=c?c.alloc(e,u,{},l):{};const f=[],p=a.shape,h=l?.abortEarly;let m=u.issues.length;for(const y of a.allKeys){if(h&&u.issues.length!==m){if(Ae(u,m))break;m=u.issues.length}if(y==="__proto__")continue;const $=p[y],w=$._zod.optin,S=$._zod.optout,T=$._zod.run({value:d[y],issues:[]},l);T instanceof Promise?f.push(T.then(O=>Co(O,u,y,d,w,S))):Co(T,u,y,d,w,S)}return s?dh(f,d,u,l,o.value,e,h===!0):f.length?Promise.all(f).then(()=>u):u}}),ph=g("$ZodObjectJIT",(e,t)=>{fh.init(e,t);const n=e._zod.parse,r=Gn(()=>lh(t)),o=Ee.memoizer,i=p=>{const h=r.value,m=h.symbolKeys,y=new ba(["payload","ctx"],{shape:p,inst:e,memo:o,syms:m}),$=O=>`shape[${O}]._zod.run({ value: input[${O}], issues: [] }, ctx)`,w=(O,C)=>`
15
+ let ${O}_ab = false;
16
+ for (let i = 0; i < ${O}.issues.length; i++) {
17
+ const iss = ${O}.issues[i];
18
+ iss.path = iss.path ? [${C}, ...iss.path] : [${C}];
19
19
  payload.issues.push(iss);
20
- if (iss.continue !== true) ${R}_ab = true;
20
+ if (iss.continue !== true) ${O}_ab = true;
21
21
  }
22
- if (${R}_ab && ctx && ctx.abortEarly) {
22
+ if (${O}_ab && ctx && ctx.abortEarly) {
23
23
  payload.value = newResult;
24
24
  return payload;
25
- }`;k.write("const input = payload.value;");const z=Object.create(null);let C=0;for(const R of h.allKeys)z[R]=`key_${C++}`;k.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const R of h.allKeys){if(R==="__proto__")continue;const N=z[R],U=typeof R=="symbol"?`syms[${m.indexOf(R)}]`:Pe(R),de=`${U} in input`,re=p[R],fe=re?._zod?.optin,Te=fe!==void 0,Qe=re?._zod?.optout==="optional";if(k.write(`const ${N} = ${I(U)};`),Te&&Qe){const kt=fe==="optional"?`${N}_present`:`${N}.value !== undefined || ${N}_present`;k.write(`
26
- const ${N}_present = ${de};
27
- if (!${N}.issues.length || ${N}_present) {
28
- if (${N}.issues.length) {${v(N,U)}
25
+ }`;y.write("const input = payload.value;");const S=Object.create(null);let T=0;for(const O of h.allKeys)S[O]=`key_${T++}`;y.write(o?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const O of h.allKeys){if(O==="__proto__")continue;const C=S[O],L=typeof O=="symbol"?`syms[${m.indexOf(O)}]`:De(O),ue=`${L} in input`,Q=p[O],le=Q?._zod?.optin,xe=le!==void 0,$e=Q?._zod?.optout==="optional";if(y.write(`const ${C} = ${$(L)};`),xe&&$e){const We=le==="optional"?`${C}_present`:`${C}.value !== undefined || ${C}_present`;y.write(`
26
+ const ${C}_present = ${ue};
27
+ if (!${C}.issues.length || ${C}_present) {
28
+ if (${C}.issues.length) {${w(C,L)}
29
29
  }
30
30
 
31
- if (${kt}) {
32
- newResult[${U}] = ${N}.value;
31
+ if (${We}) {
32
+ newResult[${L}] = ${C}.value;
33
33
  }
34
34
  }
35
35
 
36
- `)}else Te?(k.write(`
37
- if (${N}.issues.length) {${v(N,U)}
36
+ `)}else xe?(y.write(`
37
+ if (${C}.issues.length) {${w(C,L)}
38
38
  }
39
- `),fe==="defaulted"?k.write(`newResult[${U}] = ${N}.value;`):k.write(`
40
- if (${N}.value !== undefined || ${de}) {
41
- newResult[${U}] = ${N}.value;
39
+ `),le==="defaulted"?y.write(`newResult[${L}] = ${C}.value;`):y.write(`
40
+ if (${C}.value !== undefined || ${ue}) {
41
+ newResult[${L}] = ${C}.value;
42
42
  }
43
- `)):k.write(`
44
- const ${N}_present = ${de};
45
- if (${N}.issues.length) {${v(N,U)}
43
+ `)):y.write(`
44
+ const ${C}_present = ${ue};
45
+ if (${C}.issues.length) {${w(C,L)}
46
46
  }
47
- if (!${N}_present && !${N}.issues.length) {
47
+ if (!${C}_present && !${C}.issues.length) {
48
48
  payload.issues.push({
49
49
  code: "invalid_type",
50
50
  expected: "nonoptional",
51
51
  input: undefined,
52
- path: [${U}]
52
+ path: [${L}]
53
53
  });
54
54
  if (ctx && ctx.abortEarly) {
55
55
  payload.value = newResult;
@@ -57,23 +57,23 @@ ${n.join(`
57
57
  }
58
58
  }
59
59
 
60
- if (${N}_present) {
61
- newResult[${U}] = ${N}.value;
60
+ if (${C}_present) {
61
+ newResult[${L}] = ${C}.value;
62
62
  }
63
63
 
64
- `)}return k.write("payload.value = newResult;"),k.write("return payload;"),k.compile()};let s;const a=Jt,c=!ze.jitless,l=c&&Pd.value,d=t.catchall;let f;e._zod.parse=(p,h)=>{f??(f=r.value);const m=p.value;return a(m)?c&&l&&h?.async===!1&&h.jitless!==!0?(s||(s=i(t.shape)),p=s(p,h),d?qp([],m,p,h,f,e,h?.abortEarly===!0):p):n(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p)}});function Cl(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!Ce(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>Fe(s,r,me())))}),t)}const Vo=g("$ZodUnion",(e,t)=>{L.init(e,t),F(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),F(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),F(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),F(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){const o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>gt(i.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>Cl(a,r,e,o)):Cl(s,r,e,o)}});function El(e,t,n,r){const o=[];for(let i=0;i<e.length;i++)e[i].issues.length===0&&o.push(i);return o.length===1?(t.value=e[o[0]].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>Fe(s,r,me())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:o}),t)}const Kp=g("$ZodXor",(e,t)=>{Vo.init(e,t),t.inclusive=!1;const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},o);c instanceof Promise?(s.push(c),i=!0):s.push(c)}return i?Promise.all(s).then(a=>El(a,r,e,o)):El(s,r,e,o)}});function ka(e,t){const n=e._zod;let r=n.bag.optionsMap;r||(r=Jp(n.def),n.bag.optionsMap=r);const o=r.get(t);if(o===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return o}function Jp(e){const t=new Map;for(const n of e.options){const r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(const o of r)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,n)}return t}const Wp=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Vo.init(e,t);const n=e._zod.parse;F(e,"propValues",o=>{const i={};let s=0;for(const a of o.def.options){const c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&s++;for(const[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(i,u)||Re(i,u,new Set);for(const d of l)i[u].add(d)}}return!o.def.unionFallback&&s>1&&i[o.def.discriminator]?.delete(void 0),i}),t.options.forEach((o,i)=>{const s=To(o._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});const r=qn(()=>Jp(t));e._zod.parse=(o,i)=>{const s=o.value;if(!Jt(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=s?.[t.discriminator],c=r.value.get(a);return c&&(a!==void 0||i.direction!=="backward")?c._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(u=>r.value.get(u)!==null),input:s,path:[t.discriminator],inst:e}),o)}}),Gp=g("$ZodIntersection",(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,u])=>Nl(n,c,u)):Nl(n,i,s)}});function Ln(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(rt(e)&&rt(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const i of r){if(i==="__proto__")continue;const s=Ln(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=Ln(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Nl(e,t,n){const r=new Map;let o;const i=new Map,s=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){const f=String(u.path[0]);i.has(f)||i.set(f,u),d=[f]}else return!1;for(const f of d)r.has(f)||r.set(f,{}),r.get(f)[l]=!0;return!0};for(const u of t.issues)s(u,"l")||e.issues.push(u);for(const u of n.issues)s(u,"r")||e.issues.push(u);const a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){const u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(const l of a)!u.includes(l)&&i.has(l)&&e.issues.push(i.get(l))}const c=Ln(t.value,n.value);if(!c.valid){if(Ce(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const $a=g("$ZodTuple",(e,t)=>{L.init(e,t);const n=t.items,r=ze.memoizer;r?.attach(e),e._zod.parse=(o,i)=>{const s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];const a=[],c=Ol(n,"optin"),u=Ol(n,"optout");if(!t.rest){if(s.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),o;s.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}const l=new Array(n.length),d=t.rest?i?.abortEarly:void 0;let f=!1;for(let p=0;p<n.length;p++){const h=n[p]._zod.run({value:s[p],issues:[]},i);h instanceof Promise?a.push(h.then(m=>{l[p]=m})):(l[p]=h,d&&!f&&h.issues.length&&(f=Ce(h)))}if(t.rest&&!f){let p=n.length-1;const h=s.slice(n.length);let m=o.issues.length;for(const k of h){if(d&&o.issues.length!==m){if(Ce(o,m))break;m=o.issues.length}p++;const I=t.rest._zod.run({value:k,issues:[]},i);I instanceof Promise?a.push(I.then(v=>Pl(v,o,p))):Pl(I,o,p)}}return a.length?Promise.all(a).then(()=>Al(l,o,n,s,u)):Al(l,o,n,s,u)}});function Ol(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Pl(e,t,n){e.issues.length&&t.issues.push(...De(n,e.issues)),t.value[n]=e.value}function Al(e,t,n,r,o){for(let i=0;i<n.length;i++){const s=e[i],a=i<r.length;if(!a&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...De(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=r.length&&(n[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}const Yp=g("$ZodRecord",(e,t)=>{L.init(e,t);const n=ze.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!rt(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;const s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};const c=new Set;for(const l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;const d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>Fe(h,o,me())),input:l,path:[l],inst:e});continue}const f=d.value;if(f==="__proto__")continue;const p=t.valueType._zod.run({value:i[l],issues:[]},o);p instanceof Promise?s.push(p.then(h=>{h.issues.length&&r.issues.push(...De(l,h.issues)),r.value[f]=h.value})):(p.issues.length&&r.issues.push(...De(l,p.issues)),r.value[f]=p.value)}let u;for(const l in i)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},o):{};let c;for(const u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&an.test(u)&&l.issues.length){const h=t.keyType._zod.run({value:Number(u),issues:[]},o);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(l=h)}if(l.issues.length){t.mode==="loose"?r.value[u]=i[u]:a?(c=c??[],c.push(u)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(h=>Fe(h,o,me())),input:u,path:[u],inst:e});continue}const f=l.value;if(f==="__proto__")continue;const p=t.valueType._zod.run({value:i[u],issues:[]},o);p instanceof Promise?s.push(p.then(h=>{h.issues.length&&r.issues.push(...De(u,h.issues)),r.value[f]=h.value})):(p.issues.length&&r.issues.push(...De(u,p.issues)),r.value[f]=p.value)}c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}}),Qp=g("$ZodMap",(e,t)=>{L.init(e,t);const n=ze.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!(i instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),r;const s=[];r.value=n?n.alloc(e,r,new Map,o):new Map;const a=o?.abortEarly;let c=r.issues.length;for(const[u,l]of i){if(a&&r.issues.length!==c){if(Ce(r,c))break;c=r.issues.length}const d=t.keyType._zod.run({value:u,issues:[]},o),f=t.valueType._zod.run({value:l,issues:[]},o);d instanceof Promise||f instanceof Promise?s.push(Promise.all([d,f]).then(([p,h])=>{Ml(p,h,r,u,i,e,o)})):Ml(d,f,r,u,i,e,o)}return s.length?Promise.all(s).then(()=>r):r}});function Ml(e,t,n,r,o,i,s){e.issues.length&&(_o.has(typeof r)?n.issues.push(...De(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map(a=>Fe(a,s,me()))})),t.issues.length&&(_o.has(typeof r)?n.issues.push(...De(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:r,issues:t.issues.map(a=>Fe(a,s,me()))})),n.value.set(e.value,t.value)}const Xp=g("$ZodSet",(e,t)=>{L.init(e,t);const n=ze.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!(i instanceof Set))return r.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),r;const s=[];r.value=n?n.alloc(e,r,new Set,o):new Set;const a=o?.abortEarly;let c=r.issues.length;for(const u of i){if(a&&r.issues.length!==c){if(Ce(r,c))break;c=r.issues.length}const l=t.valueType._zod.run({value:u,issues:[]},o);l instanceof Promise?s.push(l.then(d=>Rl(d,r))):Rl(l,r)}return s.length?Promise.all(s).then(()=>r):r}});function Rl(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const eh=g("$ZodEnum",(e,t)=>{L.init(e,t);const n=go(t.entries),r=new Set(n);e._zod.values=r,F(e,"pattern",o=>{const i=go(o.def.entries).filter(s=>_o.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>ot(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),th=g("$ZodLiteral",(e,t)=>{L.init(e,t);const n=new Set(t.values);e._zod.values=n,F(e,"pattern",r=>{const o=r.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?ot(i):i?ot(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),nh=g("$ZodFile",(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;return o instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:o,inst:e}),n}}),rh=g("$ZodTransform",(e,t)=>{L.init(e,t),e._zod.optin="optional",ze.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Po(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(n.value=s,n));if(o instanceof Promise)throw new tt;return n.value=o,n}});function Ll(e,t){return e.value=t.issues.length?void 0:t.value,e}const Sa=g("$ZodOptional",(e,t)=>{L.init(e,t),F(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",F(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),F(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${gt(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>Ll(n,i)):Ll(n,o)}return t.innerType._zod.run(n,r)}}),oh=g("$ZodExactOptional",(e,t)=>{Sa.init(e,t),F(e,"values",n=>n.def.innerType._zod.values),F(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),ih=g("$ZodNullable",(e,t)=>{L.init(e,t),F(e,"optin",n=>n.def.innerType._zod.optin),F(e,"optout",n=>n.def.innerType._zod.optout),F(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${gt(r.source)}|null)$`):void 0}),F(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),sh=g("$ZodDefault",(e,t)=>{L.init(e,t),e._zod.optin="defaulted",F(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Zl(i,t)):Zl(o,t)}});function Zl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ah=g("$ZodPrefault",(e,t)=>{L.init(e,t),e._zod.optin="defaulted",F(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),ch=g("$ZodNonOptional",(e,t)=>{L.init(e,t),F(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Dl(i,e)):Dl(o,e)}});function Dl(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 uh=g("$ZodSuccess",(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Po("ZodSuccess");const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.issues.length===0,n)):(n.value=o.issues.length===0,n)}});function jl(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Fe(o,r,me()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const lh=g("$ZodCatch",(e,t)=>{L.init(e,t),F(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),F(e,"optout",n=>n.def.innerType._zod.optout),F(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>jl(n,i,t,r)):jl(n,o,t,r)}}),dh=g("$ZodNaN",(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),Ia=g("$ZodPipe",(e,t)=>{L.init(e,t),F(e,"values",n=>n.def.in._zod.values),F(e,"optin",n=>n.def.in._zod.optin),F(e,"optout",n=>n.def.out._zod.optout),F(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>Xr(s,t.in,r)):Xr(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>Xr(i,t.out,r)):Xr(o,t.out,r)}});function Xr(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const za=g("$ZodCodec",(e,t)=>{L.init(e,t),F(e,"values",n=>n.def.in._zod.values),F(e,"optin",n=>n.def.in._zod.optin),F(e,"optout",n=>n.def.out._zod.optout),F(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if((r.direction||"forward")==="forward"){const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>eo(s,t,r)):eo(i,t,r)}else{const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>eo(s,t,r)):eo(i,t,r)}}});function eo(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){const o=t.transform(e.value,e);return o instanceof Promise?o.then(i=>to(e,i,t.out,n)):to(e,o,t.out,n)}else{const o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>to(e,i,t.in,n)):to(e,o,t.in,n)}}function to(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const fh=g("$ZodPreprocess",(e,t)=>{Ia.init(e,t)}),ph=g("$ZodReadonly",(e,t)=>{L.init(e,t),F(e,"propValues",n=>n.def.innerType._zod.propValues),F(e,"values",n=>n.def.innerType._zod.values),F(e,"optin",n=>n.def.innerType?._zod?.optin),F(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Fl):Fl(o)}});function Fl(e){return e.memo||(e.value=Object.freeze(e.value)),e}function y_(e){const t=e._zod.def;let n=t.pattern,r=!!t.format?.includes("int"),o,i;for(const a of t.checks??[]){const c=a._zod.def;c.pattern&&(n=c.pattern),r||(r=!!c.format?.includes("int"));const u=c.minimum??c.length,l=c.maximum??c.length;u!==void 0&&(o===void 0||u>o)&&(o=u),l!==void 0&&(i===void 0||l<i)&&(i=l)}if(n)return n.source;if(o!==void 0&&i!==void 0&&o>i)return"(?!)";if(o!==void 0||i!==void 0)return Cf({minimum:o,maximum:i}).source;const s=e._zod.pattern;return(r&&s===an?ta:s)?.source}function gs(e){const t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){const o=r._zod.pattern?.source,i=gs(r);return n&&o&&i&&i!==o?n.replace(gt(o),()=>gt(i)):n}if(t.options){const o=t.options.map(gs);if(o.every(Boolean))return`^(${o.map(i=>gt(i)).join("|")})$`}return y_(e)}const hh=g("$ZodTemplateLiteral",(e,t)=>{L.init(e,t);const n=[];for(const r of t.parts)if(typeof r=="object"&&r!==null){const o=gs(r);if(!o)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(gt(o))}else if(r===null||Ad.has(typeof r))n.push(ot(`${r}`));else throw new Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(r,o)=>typeof r.value!="string"?(r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}),r):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(r.value)||r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),r)}),mh=g("$ZodFunction",(e,t)=>(L.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return Object.defineProperty(function(...r){const o=e._def.input?ps(e._def.input,r):r,i=Reflect.apply(n,this,o);return e._def.output?ps(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...r){const o=e._def.input?await hs(e._def.input,r):r,i=await Reflect.apply(n,this,o);return e._def.output?await hs(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,r)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{const r=e.constructor;return Array.isArray(n[0])?new r({type:"function",input:new $a({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new r({type:"function",input:n[0],output:e._def.output})},e.output=n=>{const r=e.constructor;return new r({type:"function",input:e._def.input,output:n})},e)),gh=g("$ZodPromise",(e,t)=>{L.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then(o=>t.innerType._zod.run({value:o,issues:[]},r))}),xa=g("$ZodLazy",(e,t)=>{L.init(e,t),Cd(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),F(e,"pattern",n=>n.innerType?._zod?.pattern),F(e,"propValues",n=>n.innerType?._zod?.propValues),F(e,"optin",n=>n.innerType?._zod?.optin??void 0),F(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),yh=g("$ZodCustom",(e,t)=>{ie.init(e,t),L.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Ul(i,n,r,e));Ul(o,n,r,e)}});function Ul(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Wt(o))}}class _h extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const ys="~memo",Vl=[];function bh(e){return e!==null&&typeof e=="object"}function ns(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const wh=new WeakMap,Kt=0,ho=1,On=2;function Pn(e,t,n){const r=wh.get(e);if(r!==void 0)return r?On:Kt;if(t.has(e))return On;t.add(e);let o=Kt;const i=l=>{if(o!==On&&l?._zod){const d=Pn(l,t,n);d>o&&(o=d)}},s=(l,d)=>{let f=Kt;for(const p of Reflect.ownKeys(l)){const h=Object.getOwnPropertyDescriptor(l,p);if(!h.enumerable)continue;const m=h.get?ho:h.value?._zod?Pn(h.value,t,n):Kt;m>f&&(f=m)}return f},a=l=>{l>o&&(o=l)},c=e._zod.def;switch(c.type){case"object":{const l=To(c);a(l?s(l):ho),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(const l of c.items)i(l);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(const l of c.options)i(l);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{const l=c._cachedInner??(n?e._zod.innerType:void 0);a(l?Pn(l,t,!1):ho);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const l in c){const d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;const f=d.value;if(!(!f||typeof f!="object")){if(f._zod)i(f);else if(Array.isArray(f))for(const p of f)i(p)}}}return t.delete(e),__(e,o)}function __(e,t){return t!==ho&&wh.set(e,t===On),t}function Ta(e){return Pn(e,new Set,!0)!==Kt}function b_(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let no;const ro=[],w_={alloc(e,t,n){const r=no;if(!r)return n;no=void 0;const o={value:n,issues:null};return r.set(t.value,o),ro.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&Ca(i,o.value))throw new _h;return n(o,i)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(c,u)=>{if(n===void 0){const I=Pn(e,new Set,!1);if(I===Kt)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(c,u);I===On||r?n=!0:r=!0}const l=c.value;if(!bh(l))return s(c,u);let d=u[ys];d||(d={buckets:new WeakMap,backEdges:void 0},u[ys]=d);let f;o===u?f=i:(f=b_(d,e),o=u,i=f);const p=f.get(l);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...ns(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;no=f;const h=ro.length,m=s(c,u);no=void 0;const k=ro.length>h?ro.pop():void 0;return m instanceof Promise?m.then(I=>(k&&(k.issues=I.issues.length?ns(I.issues):Vl),I)):(k&&(k.issues=m.issues.length?ns(m.issues):Vl),m)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function qo(){return w_}function Ca(e,t){const n=e[ys]?.backEdges;return n!==void 0&&bh(t)&&n.has(t)}const Ea=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var ql;const Na=Symbol("ZodOutput"),Oa=Symbol("ZodInput");class vh{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Ho(){return new vh}(ql=globalThis).__zod_globalRegistry??(ql.__zod_globalRegistry=Ho());const Oe=globalThis.__zod_globalRegistry,xe=Symbol.for("zod.compile.invalid"),Hl=Symbol.for("zod.compile.fallback");class st extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}}class H extends Error{constructor(t,n=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=n}}function v_(e,t){try{return Ko(e,{assertOnly:!0})}catch{return t}}function Pa(e,t){try{const n=Ko(e),r=Bo(e,n);return r._zod.bag.validator=v_(e,n),r}catch(n){if(t?.strict)throw n;return e}}function Bo(e,t){if(Ta(e))throw new H("a schema whose subtree contains a reference cycle");const n=oe(e),r=e._zod.run,o=r.__originalRun??r,i=(s,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[Hl]||a&&Ca(a,s.value))return o(s,a);const c=t(s.value);return c!==xe?(s.value=c,s):(a&&(a[Hl]=!0),o(s,a))};return i.__originalRun=o,n._zod.bag.fallbackRun=o,n._zod.bag.validator=t,n._zod.run=i,r.__originalRun||k_(n,e,t),n}function k_(e,t,n){const r=e,o=t;if(typeof o.safeParse=="function"){const i=o.safeParse;r.safeParse=(s,a)=>{const c=n(s);return c!==xe?{success:!0,data:c}:i(s,a)}}if(typeof o.parse=="function"){const i=o.parse;r.parse=(s,a)=>{const c=n(s);return c!==xe?c:i(s,a)}}}function Ko(e,t){let n=!0;try{n=Ta(e)}catch{}if(n)throw new H("a schema whose subtree contains a reference cycle");const r={constants:new Map,constantCounter:0,varCounter:0,definite:!0},o=new sa(["input"]),i=se(o,r,e,"input",!t?.assertOnly);o.write(i===null?"return true;":`return ${i};`);const s=["INVALID",...r.constants.keys()],a=[xe,...r.constants.values()],c=o.content.join(`
64
+ `)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()};let s;const a=Yt,c=!Ee.jitless,l=c&&ef.value,d=t.catchall;let f;e._zod.parse=(p,h)=>{f??(f=r.value);const m=p.value;return a(m)?c&&l&&h?.async===!1&&h.jitless!==!0?(s||(s=i(t.shape)),p=s(p,h),d?dh([],m,p,h,f,e,h?.abortEarly===!0):p):n(p,h):(p.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),p)}});function jl(e,t,n,r){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const o=e.filter(i=>!Ae(i));return o.length===1?(t.value=o[0].value,o[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>Be(s,r,me())))}),t)}const Yo=g("$ZodUnion",(e,t)=>{D.init(e,t),U(e,"optin",r=>r.def.options.some(o=>o._zod.optin==="defaulted")?"defaulted":r.def.options.some(o=>o._zod.optin!==void 0)?"optional":void 0),U(e,"optout",r=>r.def.options.some(o=>o._zod.optout==="optional")?"optional":void 0),U(e,"values",r=>{if(r.def.options.every(o=>o._zod.values))return new Set(r.def.options.flatMap(o=>Array.from(o._zod.values)))}),U(e,"pattern",r=>{if(r.def.options.every(o=>o._zod.pattern)){const o=r.def.options.map(i=>i._zod.pattern);return new RegExp(`^(${o.map(i=>vt(i.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},o);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>jl(a,r,e,o)):jl(s,r,e,o)}});function Fl(e,t,n,r){const o=[];for(let i=0;i<e.length;i++)e[i].issues.length===0&&o.push(i);return o.length===1?(t.value=e[o[0]].value,t):(o.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>Be(s,r,me())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:o}),t)}const hh=g("$ZodXor",(e,t)=>{Yo.init(e,t),t.inclusive=!1;const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,o)=>{if(n)return n(r,o);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:r.value,issues:[]},o);c instanceof Promise?(s.push(c),i=!0):s.push(c)}return i?Promise.all(s).then(a=>Fl(a,r,e,o)):Fl(s,r,e,o)}});function Ma(e,t){const n=e._zod;let r=n.bag.optionsMap;r||(r=mh(n.def),n.bag.optionsMap=r);const o=r.get(t);if(o===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return o}function mh(e){const t=new Map;for(const n of e.options){const r=n._zod.propValues?.[e.discriminator];if(!r||r.size===0)throw new Error(`Invalid discriminated union option at index "${e.options.indexOf(n)}"`);for(const o of r)if(t.has(o)){if(o!==void 0)throw new Error(`Duplicate discriminator value "${String(o)}"`);t.set(o,null)}else t.set(o,n)}return t}const gh=g("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Yo.init(e,t);const n=e._zod.parse;U(e,"propValues",o=>{const i={};let s=0;for(const a of o.def.options){const c=a._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${o.def.options.indexOf(a)}"`);c[o.def.discriminator]?.has(void 0)&&s++;for(const[u,l]of Object.entries(c)){Object.prototype.hasOwnProperty.call(i,u)||Fe(i,u,new Set);for(const d of l)i[u].add(d)}}return!o.def.unionFallback&&s>1&&i[o.def.discriminator]?.delete(void 0),i}),t.options.forEach((o,i)=>{const s=Ro(o._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${i}"`)});const r=Gn(()=>mh(t));e._zod.parse=(o,i)=>{const s=o.value;if(!Yt(s))return o.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),o;const a=s?.[t.discriminator],c=r.value.get(a);return c&&(a!==void 0||i.direction!=="backward")?c._zod.run(o,i):t.unionFallback||i.direction==="backward"?n(o,i):(o.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(u=>r.value.get(u)!==null),input:s,path:[t.discriminator],inst:e}),o)}}),yh=g("$ZodIntersection",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{const o=n.value,i=t.left._zod.run({value:o,issues:[]},r),s=t.right._zod.run({value:o,issues:[]},r);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,u])=>Ul(n,c,u)):Ul(n,i,s)}});function Vn(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(ct(e)&&ct(t)){const n=Object.keys(t),r=Object.keys(e).filter(i=>n.indexOf(i)!==-1),o={...e,...t};Object.prototype.hasOwnProperty.call(o,"__proto__")&&delete o.__proto__;for(const i of r){if(i==="__proto__")continue;const s=Vn(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};o[i]=s.data}return{valid:!0,data:o}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let r=0;r<e.length;r++){const o=e[r],i=t[r],s=Vn(o,i);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ul(e,t,n){const r=new Map;let o;const i=new Map,s=(u,l)=>{let d;if(u.code==="unrecognized_keys"&&!u.path?.length)o??(o=u),d=u.keys;else if(u.code==="invalid_key"&&u.origin==="record"&&u.path?.length===1){const f=String(u.path[0]);i.has(f)||i.set(f,u),d=[f]}else return!1;for(const f of d)r.has(f)||r.set(f,{}),r.get(f)[l]=!0;return!0};for(const u of t.issues)s(u,"l")||e.issues.push(u);for(const u of n.issues)s(u,"r")||e.issues.push(u);const a=[...r].filter(([,u])=>u.l&&u.r).map(([u])=>u);if(a.length){const u=o?a.filter(l=>o.keys.includes(l)):[];u.length&&e.issues.push({...o,keys:u});for(const l of a)!u.includes(l)&&i.has(l)&&e.issues.push(i.get(l))}const c=Vn(t.value,n.value);if(!c.valid){if(Ae(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}const Ra=g("$ZodTuple",(e,t)=>{D.init(e,t);const n=t.items,r=Ee.memoizer;r?.attach(e),e._zod.parse=(o,i)=>{const s=o.value;if(!Array.isArray(s))return o.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),o;o.value=r?r.alloc(e,o,[],i):[];const a=[],c=Vl(n,"optin"),u=Vl(n,"optout");if(!t.rest){if(s.length<c)return o.issues.push({code:"too_small",minimum:c,inclusive:!0,input:s,inst:e,origin:"array"}),o;s.length>n.length&&o.issues.push({code:"too_big",maximum:n.length,inclusive:!0,input:s,inst:e,origin:"array"})}const l=new Array(n.length),d=t.rest?i?.abortEarly:void 0;let f=!1;for(let p=0;p<n.length;p++){const h=n[p]._zod.run({value:s[p],issues:[]},i);h instanceof Promise?a.push(h.then(m=>{l[p]=m})):(l[p]=h,d&&!f&&h.issues.length&&(f=Ae(h)))}if(t.rest&&!f){let p=n.length-1;const h=s.slice(n.length);let m=o.issues.length;for(const y of h){if(d&&o.issues.length!==m){if(Ae(o,m))break;m=o.issues.length}p++;const $=t.rest._zod.run({value:y,issues:[]},i);$ instanceof Promise?a.push($.then(w=>ql(w,o,p))):ql($,o,p)}}return a.length?Promise.all(a).then(()=>Hl(l,o,n,s,u)):Hl(l,o,n,s,u)}});function Vl(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function ql(e,t,n){e.issues.length&&t.issues.push(...qe(n,e.issues)),t.value[n]=e.value}function Hl(e,t,n,r,o){for(let i=0;i<n.length;i++){const s=e[i],a=i<r.length;if(!a&&i>=o&&n[i]._zod.optin==="optional"){t.value.length=i;break}if(s.issues.length){if(!a&&i>=o){t.value.length=i;break}t.issues.push(...qe(i,s.issues))}t.value[i]=s.value}for(let i=t.value.length-1;i>=r.length&&(n[i]._zod.optout==="optional"&&t.value[i]===void 0);i--)t.value.length=i;return t}const _h=g("$ZodRecord",(e,t)=>{D.init(e,t);const n=Ee.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!ct(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;const s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},o):{};const c=new Set;for(const l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(c.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;const d=t.keyType._zod.run({value:l,issues:[]},o);if(d instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(d.issues.length){r.issues.push({code:"invalid_key",origin:"record",issues:d.issues.map(h=>Be(h,o,me())),input:l,path:[l],inst:e});continue}const f=d.value;if(f==="__proto__")continue;const p=t.valueType._zod.run({value:i[l],issues:[]},o);p instanceof Promise?s.push(p.then(h=>{h.issues.length&&r.issues.push(...qe(l,h.issues)),r.value[f]=h.value})):(p.issues.length&&r.issues.push(...qe(l,p.issues)),r.value[f]=p.value)}let u;for(const l in i)if(!c.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=i[l]}else u=u??[],u.push(l);u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:u,continue:!0})}else{r.value=n?n.alloc(e,r,{},o):{};let c;for(const u of Reflect.ownKeys(i)){if(u==="__proto__"||!Object.prototype.propertyIsEnumerable.call(i,u))continue;let l=t.keyType._zod.run({value:u,issues:[]},o);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof u=="string"&&ln.test(u)&&l.issues.length){const h=t.keyType._zod.run({value:Number(u),issues:[]},o);if(h instanceof Promise)throw new Error("Async schemas not supported in object keys currently");h.issues.length===0&&(l=h)}if(l.issues.length){t.mode==="loose"?r.value[u]=i[u]:a?(c=c??[],c.push(u)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(h=>Be(h,o,me())),input:u,path:[u],inst:e});continue}const f=l.value;if(f==="__proto__")continue;const p=t.valueType._zod.run({value:i[u],issues:[]},o);p instanceof Promise?s.push(p.then(h=>{h.issues.length&&r.issues.push(...qe(u,h.issues)),r.value[f]=h.value})):(p.issues.length&&r.issues.push(...qe(u,p.issues)),r.value[f]=p.value)}c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:c,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}}),bh=g("$ZodMap",(e,t)=>{D.init(e,t);const n=Ee.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!(i instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:i,inst:e}),r;const s=[];r.value=n?n.alloc(e,r,new Map,o):new Map;const a=o?.abortEarly;let c=r.issues.length;for(const[u,l]of i){if(a&&r.issues.length!==c){if(Ae(r,c))break;c=r.issues.length}const d=t.keyType._zod.run({value:u,issues:[]},o),f=t.valueType._zod.run({value:l,issues:[]},o);d instanceof Promise||f instanceof Promise?s.push(Promise.all([d,f]).then(([p,h])=>{Bl(p,h,r,u,i,e,o)})):Bl(d,f,r,u,i,e,o)}return s.length?Promise.all(s).then(()=>r):r}});function Bl(e,t,n,r,o,i,s){e.issues.length&&(xo.has(typeof r)?n.issues.push(...qe(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:o,inst:i,issues:e.issues.map(a=>Be(a,s,me()))})),t.issues.length&&(xo.has(typeof r)?n.issues.push(...qe(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:o,inst:i,key:r,issues:t.issues.map(a=>Be(a,s,me()))})),n.value.set(e.value,t.value)}const wh=g("$ZodSet",(e,t)=>{D.init(e,t);const n=Ee.memoizer;n?.attach(e),e._zod.parse=(r,o)=>{const i=r.value;if(!(i instanceof Set))return r.issues.push({input:i,inst:e,expected:"set",code:"invalid_type"}),r;const s=[];r.value=n?n.alloc(e,r,new Set,o):new Set;const a=o?.abortEarly;let c=r.issues.length;for(const u of i){if(a&&r.issues.length!==c){if(Ae(r,c))break;c=r.issues.length}const l=t.valueType._zod.run({value:u,issues:[]},o);l instanceof Promise?s.push(l.then(d=>Kl(d,r))):Kl(l,r)}return s.length?Promise.all(s).then(()=>r):r}});function Kl(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const vh=g("$ZodEnum",(e,t)=>{D.init(e,t);const n=So(t.entries),r=new Set(n);e._zod.values=r,U(e,"pattern",o=>{const i=So(o.def.entries).filter(s=>xo.has(typeof s));return new RegExp(i.length?`^(${i.map(s=>ut(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(o,i)=>{const s=o.value;return r.has(s)||o.issues.push({code:"invalid_value",values:n,input:s,inst:e}),o}}),kh=g("$ZodLiteral",(e,t)=>{D.init(e,t);const n=new Set(t.values);e._zod.values=n,U(e,"pattern",r=>{const o=r.def.values;return new RegExp(o.length?`^(${o.map(i=>typeof i=="string"?ut(i):i?ut(i.toString()):String(i)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,o)=>{const i=r.value;return n.has(i)||r.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),r}}),$h=g("$ZodFile",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{const o=n.value;return o instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:o,inst:e}),n}}),Sh=g("$ZodTransform",(e,t)=>{D.init(e,t),e._zod.optin="optional",Ee.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Fo(e.constructor.name);const o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(s=>(n.value=s,n));if(o instanceof Promise)throw new st;return n.value=o,n}});function Jl(e,t){return e.value=t.issues.length?void 0:t.value,e}const La=g("$ZodOptional",(e,t)=>{D.init(e,t),U(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",U(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),U(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${vt(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>Jl(n,i)):Jl(n,o)}return t.innerType._zod.run(n,r)}}),Ih=g("$ZodExactOptional",(e,t)=>{La.init(e,t),U(e,"values",n=>n.def.innerType._zod.values),U(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),xh=g("$ZodNullable",(e,t)=>{D.init(e,t),U(e,"optin",n=>n.def.innerType._zod.optin),U(e,"optout",n=>n.def.innerType._zod.optout),U(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${vt(r.source)}|null)$`):void 0}),U(e,"values",n=>n.def.innerType._zod.values?new Set([...n.def.innerType._zod.values,null]):void 0),e._zod.parse=(n,r)=>n.value===null?n:t.innerType._zod.run(n,r)}),zh=g("$ZodDefault",(e,t)=>{D.init(e,t),e._zod.optin="defaulted",U(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);if(n.value===void 0)return n.value=t.defaultValue,n;const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Wl(i,t)):Wl(o,t)}});function Wl(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Th=g("$ZodPrefault",(e,t)=>{D.init(e,t),e._zod.optin="defaulted",U(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>(r.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,r))}),Eh=g("$ZodNonOptional",(e,t)=>{D.init(e,t),U(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,r)=>{const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>Gl(i,e)):Gl(o,e)}});function Gl(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 Ch=g("$ZodSuccess",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Fo("ZodSuccess");const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(i=>(n.value=i.issues.length===0,n)):(n.value=o.issues.length===0,n)}});function Yl(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(o=>Be(o,r,me()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Ah=g("$ZodCatch",(e,t)=>{D.init(e,t),U(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),U(e,"optout",n=>n.def.innerType._zod.optout),U(e,"values",n=>n.def.innerType._zod.values),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run({value:n.value,issues:[]},r);return o instanceof Promise?o.then(i=>Yl(n,i,t,r)):Yl(n,o,t,r)}}),Nh=g("$ZodNaN",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>((typeof n.value!="number"||!Number.isNaN(n.value))&&n.issues.push({input:n.value,inst:e,expected:"nan",code:"invalid_type"}),n)}),Da=g("$ZodPipe",(e,t)=>{D.init(e,t),U(e,"values",n=>n.def.in._zod.values),U(e,"optin",n=>n.def.in._zod.optin),U(e,"optout",n=>n.def.out._zod.optout),U(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>so(s,t.in,r)):so(i,t.in,r)}const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(i=>so(i,t.out,r)):so(o,t.out,r)}});function so(e,t,n){return e.issues.some(r=>r.code!=="unrecognized_keys")?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}const Za=g("$ZodCodec",(e,t)=>{D.init(e,t),U(e,"values",n=>n.def.in._zod.values),U(e,"optin",n=>n.def.in._zod.optin),U(e,"optout",n=>n.def.out._zod.optout),U(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if((r.direction||"forward")==="forward"){const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(s=>ao(s,t,r)):ao(i,t,r)}else{const i=t.out._zod.run(n,r);return i instanceof Promise?i.then(s=>ao(s,t,r)):ao(i,t,r)}}});function ao(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){const o=t.transform(e.value,e);return o instanceof Promise?o.then(i=>co(e,i,t.out,n)):co(e,o,t.out,n)}else{const o=t.reverseTransform(e.value,e);return o instanceof Promise?o.then(i=>co(e,i,t.in,n)):co(e,o,t.in,n)}}function co(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Oh=g("$ZodPreprocess",(e,t)=>{Da.init(e,t)}),Ph=g("$ZodReadonly",(e,t)=>{D.init(e,t),U(e,"propValues",n=>n.def.innerType._zod.propValues),U(e,"values",n=>n.def.innerType._zod.values),U(e,"optin",n=>n.def.innerType?._zod?.optin),U(e,"optout",n=>n.def.innerType?._zod?.optout),e._zod.parse=(n,r)=>{if(r.direction==="backward")return t.innerType._zod.run(n,r);const o=t.innerType._zod.run(n,r);return o instanceof Promise?o.then(Ql):Ql(o)}});function Ql(e){return e.memo||(e.value=Object.freeze(e.value)),e}function Q_(e){const t=e._zod.def;let n=t.pattern,r=!!t.format?.includes("int"),o,i;for(const a of t.checks??[]){const c=a._zod.def;c.pattern&&(n=c.pattern),r||(r=!!c.format?.includes("int"));const u=c.minimum??c.length,l=c.maximum??c.length;u!==void 0&&(o===void 0||u>o)&&(o=u),l!==void 0&&(i===void 0||l<i)&&(i=l)}if(n)return n.source;if(o!==void 0&&i!==void 0&&o>i)return"(?!)";if(o!==void 0||i!==void 0)return Gf({minimum:o,maximum:i}).source;const s=e._zod.pattern;return(r&&s===ln?ha:s)?.source}function xs(e){const t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){const o=r._zod.pattern?.source,i=xs(r);return n&&o&&i&&i!==o?n.replace(vt(o),()=>vt(i)):n}if(t.options){const o=t.options.map(xs);if(o.every(Boolean))return`^(${o.map(i=>vt(i)).join("|")})$`}return Q_(e)}const Mh=g("$ZodTemplateLiteral",(e,t)=>{D.init(e,t);const n=[];for(const r of t.parts)if(typeof r=="object"&&r!==null){const o=xs(r);if(!o)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(vt(o))}else if(r===null||tf.has(typeof r))n.push(ut(`${r}`));else throw new Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(r,o)=>typeof r.value!="string"?(r.issues.push({input:r.value,inst:e,expected:"string",code:"invalid_type"}),r):(e._zod.pattern.lastIndex=0,e._zod.pattern.test(r.value)||r.issues.push({input:r.value,inst:e,code:"invalid_format",format:t.format??"template_literal",pattern:e._zod.pattern.source}),r)}),Rh=g("$ZodFunction",(e,t)=>(D.init(e,t),Object.defineProperty(e,"_def",{value:t}),e._zod.def=t,e.implement=n=>{if(typeof n!="function")throw new Error("implement() must be called with a function");return Object.defineProperty(function(...r){const o=e._def.input?$s(e._def.input,r):r,i=Reflect.apply(n,this,o);return e._def.output?$s(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e.implementAsync=n=>{if(typeof n!="function")throw new Error("implementAsync() must be called with a function");return Object.defineProperty(async function(...r){const o=e._def.input?await Ss(e._def.input,r):r,i=await Reflect.apply(n,this,o);return e._def.output?await Ss(e._def.output,i):i},"_zod",{value:e._zod,enumerable:!1})},e._zod.parse=(n,r)=>typeof n.value!="function"?(n.issues.push({code:"invalid_type",expected:"function",input:n.value,inst:e}),n):(e._def.output&&e._def.output._zod.def.type==="promise"?n.value=e.implementAsync(n.value):n.value=e.implement(n.value),n),e.input=(...n)=>{const r=e.constructor;return Array.isArray(n[0])?new r({type:"function",input:new Ra({type:"tuple",items:n[0],rest:n[1]}),output:e._def.output}):new r({type:"function",input:n[0],output:e._def.output})},e.output=n=>{const r=e.constructor;return new r({type:"function",input:e._def.input,output:n})},e)),Lh=g("$ZodPromise",(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then(o=>t.innerType._zod.run({value:o,issues:[]},r))}),ja=g("$ZodLazy",(e,t)=>{D.init(e,t),Gd(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),U(e,"pattern",n=>n.innerType?._zod?.pattern),U(e,"propValues",n=>n.innerType?._zod?.propValues),U(e,"optin",n=>n.innerType?._zod?.optin??void 0),U(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),Dh=g("$ZodCustom",(e,t)=>{ie.init(e,t),D.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,o=t.fn(r);if(o instanceof Promise)return o.then(i=>Xl(i,n,r,e));Xl(o,n,r,e)}});function Xl(e,t,n,r){if(!e){const o={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(o.params=r._zod.def.params),t.issues.push(Qt(o))}}class Zh extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const zs="~memo",ed=[];function jh(e){return e!==null&&typeof e=="object"}function ls(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const Fh=new WeakMap,Gt=0,ko=1,Dn=2;function Zn(e,t,n){const r=Fh.get(e);if(r!==void 0)return r?Dn:Gt;if(t.has(e))return Dn;t.add(e);let o=Gt;const i=l=>{if(o!==Dn&&l?._zod){const d=Zn(l,t,n);d>o&&(o=d)}},s=(l,d)=>{let f=Gt;for(const p of Reflect.ownKeys(l)){const h=Object.getOwnPropertyDescriptor(l,p);if(!h.enumerable)continue;const m=h.get?ko:h.value?._zod?Zn(h.value,t,n):Gt;m>f&&(f=m)}return f},a=l=>{l>o&&(o=l)},c=e._zod.def;switch(c.type){case"object":{const l=Ro(c);a(l?s(l):ko),i(c.catchall);break}case"array":i(c.element);break;case"tuple":for(const l of c.items)i(l);i(c.rest);break;case"record":case"map":i(c.keyType),i(c.valueType);break;case"set":i(c.valueType);break;case"union":for(const l of c.options)i(l);break;case"intersection":i(c.left),i(c.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":i(c.innerType);break;case"pipe":i(c.in),i(c.out);break;case"function":i(c.input),i(c.output);break;case"lazy":{const l=c._cachedInner??(n?e._zod.innerType:void 0);a(l?Zn(l,t,!1):ko);break}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":break;default:for(const l in c){const d=Object.getOwnPropertyDescriptor(c,l);if(!d||d.get)continue;const f=d.value;if(!(!f||typeof f!="object")){if(f._zod)i(f);else if(Array.isArray(f))for(const p of f)i(p)}}}return t.delete(e),X_(e,o)}function X_(e,t){return t!==ko&&Fh.set(e,t===Dn),t}function Fa(e){return Zn(e,new Set,!0)!==Gt}function eb(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let uo;const lo=[],tb={alloc(e,t,n){const r=uo;if(!r)return n;uo=void 0;const o={value:n,issues:null};return r.set(t.value,o),lo.push(o),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(o,i)=>{if(i.direction!=="backward"&&Ua(i,o.value))throw new Zh;return n(o,i)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r=!1,o,i;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(c,u)=>{if(n===void 0){const $=Zn(e,new Set,!1);if($===Gt)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(c,u);$===Dn||r?n=!0:r=!0}const l=c.value;if(!jh(l))return s(c,u);let d=u[zs];d||(d={buckets:new WeakMap,backEdges:void 0},u[zs]=d);let f;o===u?f=i:(f=eb(d,e),o=u,i=f);const p=f.get(l);if(p)return c.value=p.value,p.issues?p.issues.length&&c.issues.push(...ls(p.issues)):(c.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(p.value)),c;uo=f;const h=lo.length,m=s(c,u);uo=void 0;const y=lo.length>h?lo.pop():void 0;return m instanceof Promise?m.then($=>(y&&(y.issues=$.issues.length?ls($.issues):ed),$)):(y&&(y.issues=m.issues.length?ls(m.issues):ed),m)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function Qo(){return tb}function Ua(e,t){const n=e[zs]?.backEdges;return n!==void 0&&jh(t)&&n.has(t)}const Va=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var td;const qa=Symbol("ZodOutput"),Ha=Symbol("ZodInput");class Uh{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const r=n[0];return this._map.set(t,r),r&&typeof r=="object"&&"id"in r&&this._idmap.set(r.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const r={...this.get(n)??{}};delete r.id;const o={...r,...this._map.get(t)};return Object.keys(o).length?o:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Xo(){return new Uh}(td=globalThis).__zod_globalRegistry??(td.__zod_globalRegistry=Xo());const Le=globalThis.__zod_globalRegistry,Ce=Symbol.for("zod.compile.invalid"),nd=Symbol.for("zod.compile.fallback");class dt extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}}class B extends Error{constructor(t,n=!0){super(`z.compile does not support ${t}; this schema must use the runtime parser`),this.name="ZodCompileUnsupportedError",this.islandable=n}}function nb(e,t){try{return ti(e,{assertOnly:!0})}catch{return t}}function Ba(e,t){try{const n=ti(e),r=ei(e,n);return r._zod.bag.validator=nb(e,n),r}catch(n){if(t?.strict)throw n;return e}}function ei(e,t){if(Fa(e))throw new B("a schema whose subtree contains a reference cycle");const n=oe(e),r=e._zod.run,o=r.__originalRun??r,i=(s,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[nd]||a&&Ua(a,s.value))return o(s,a);const c=t(s.value);return c!==Ce?(s.value=c,s):(a&&(a[nd]=!0),o(s,a))};return i.__originalRun=o,n._zod.bag.fallbackRun=o,n._zod.bag.validator=t,n._zod.run=i,r.__originalRun||rb(n,e,t),n}function rb(e,t,n){const r=e,o=t;if(typeof o.safeParse=="function"){const i=o.safeParse;r.safeParse=(s,a)=>{const c=n(s);return c!==Ce?{success:!0,data:c}:i(s,a)}}if(typeof o.parse=="function"){const i=o.parse;r.parse=(s,a)=>{const c=n(s);return c!==Ce?c:i(s,a)}}}function ti(e,t){let n=!0;try{n=Fa(e)}catch{}if(n)throw new B("a schema whose subtree contains a reference cycle");const r={constants:new Map,constantCounter:0,varCounter:0,definite:!0},o=new ba(["input"]),i=se(o,r,e,"input",!t?.assertOnly);o.write(i===null?"return true;":`return ${i};`);const s=["INVALID",...r.constants.keys()],a=[Ce,...r.constants.values()],c=o.content.join(`
65
65
  `),u=t?.debug?s.length>0?`// Constants: ${s.join(", ")}
66
66
  ${c}`:c:"",l=Function,d=`return (input) => {
67
67
  ${c}
68
- }`;let f;try{f=new l(...s,d)(...a)}catch(p){throw new H(`this schema (generated code failed to evaluate: ${p.message})`)}return t?.debug&&(f.code=u),f.definite=r.definite,f}function M(e,t){for(const[r,o]of e.constants)if(o===t)return r;const n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}function Pt(e,t){return e.definite=!1,M(e,t)}function P(e){return`v${e.varCounter++}`}function $_(e,t){const n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return xe;const r=n;return r.issues.length===0?r.value:xe}function $e(e,t,n,r,o=!0){const i=e.content.length,s=t.constants.size,a=t.constantCounter,c=t.varCounter;try{return se(e,t,n,r,o)}catch(u){if(!(u instanceof H)||!u.islandable)throw u;if(e.content.length=i,t.constants.size>s){const l=Array.from(t.constants.keys()).slice(s);for(const d of l)t.constants.delete(d)}return t.constantCounter=a,t.varCounter=c,S_(e,t,n,r)}}function S_(e,t,n,r){t.definite=!1;const o=M(t,n),i=M(t,$_),s=P(t);return e.write(`const ${s} = ${i}(${o}, ${r});`),e.write(`if (${s} === INVALID) return INVALID;`),s}const I_=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function z_(e,t,n,r){const o=n._zod.def.checks;if(!o||o.length===0)return r;let i=r;for(const s of o){const a=s._zod.def;if(a.when&&!I_.has(a.check))throw new H('check with a custom "when" condition');switch(a.check){case"greater_than":x_(e,t,a,i);break;case"less_than":T_(e,t,a,i);break;case"multiple_of":C_(e,t,a,i);break;case"number_format":$h(e,a,i);break;case"min_length":{const c=Ct(a.minimum,"min_length"),u=rs(e,t,i,`${i}.length >= ${c} && ${i}.length < ${a.minimum*2}`);e.write(`if (${u} < ${c}) return INVALID;`);break}case"max_length":{const c=Ct(a.maximum,"max_length"),u=rs(e,t,i,`${i}.length > ${c}`);e.write(`if (${u} > ${c}) return INVALID;`);break}case"length_equals":{const c=Ct(a.length,"length_equals"),u=rs(e,t,i,`${i}.length >= ${c} && ${i}.length <= ${a.length*2}`);e.write(`if (${u} !== ${c}) return INVALID;`);break}case"min_size":e.write(`if (${i}.size < ${Ct(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${i}.size > ${Ct(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${i}.size !== ${Ct(a.size,"size_equals")}) return INVALID;`);break;case"string_format":i=Sh(e,t,a,i);break;case"custom":i=M_(e,t,s,i);break;case"bigint_format":E_(e,a,i);break;case"mime_type":N_(e,t,a,i);break;case"property":P_(e,t,a,i);break;case"properties":O_(e,t,a,i);break;case"overwrite":{const c=P(t);A_(e,t,s,i,c),i=c;break}default:throw new H(`check type ${a.check}`)}}return i}function rs(e,t,n,r){const o=M(t,Bn),i=P(t);return e.write(`const ${i} = typeof ${n} === "string" && ${r} ? ${o}(${n}) : ${n}.length;`),i}function Ct(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new H(`${t} bound of type ${typeof e}`);return`${e}`}function kh(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new H("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new H("comparison check with Invalid Date bound");return M(e,t)}throw new H(`comparison check bound of type ${typeof t}`)}function x_(e,t,n,r){const o=n.inclusive?"<":"<=";e.write(`if (${r} ${o} ${kh(t,n.value)}) return INVALID;`)}function T_(e,t,n,r){const o=n.inclusive?">":">=";e.write(`if (${r} ${o} ${kh(t,n.value)}) return INVALID;`)}function C_(e,t,n,r){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new H("multiple_of check with a zero divisor");e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{const o=M(t,Os);e.write(`if (${o}(${r}, ${Ct(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function $h(e,t,n){const r=t.format;switch(r){case"safeint":e.write(`if (!Number.isSafeInteger(${n})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${n}) || ${n} < -2147483648 || ${n} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${n}) || ${n} < 0 || ${n} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${n}) || ${n} < -3.4028234663852886e38 || ${n} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${n})) return INVALID;`);break;default:throw new H(`number format ${r}`)}}function E_(e,t,n){const r=t.format;if(r)switch(r){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break;default:throw new H(`bigint format ${r}`)}}function N_(e,t,n,r){const o=n.mime;if(o&&o.length>0){const i=M(t,new Set(o));e.write(`if (!${i}.has(${r}.type)) return INVALID;`)}}function O_(e,t,n,r){if(n.when)throw new H('check with a custom "when" condition');e.write(`if (${r} == null) return INVALID;`);const o=n.shape;for(const i of Reflect.ownKeys(o)){const s=typeof i=="symbol"?M(t,i):Pe(i),a=P(t);e.write(`const ${a} = ${r}[${s}];`),$e(e,t,o[i],a,!1)}}function P_(e,t,n,r){const o=`${r}[${JSON.stringify(n.property)}]`;se(e,t,n.schema,o)}function A_(e,t,n,r,o){const i=n._zod.def.tx;if(!i)throw new H("overwrite check without a transform function");if(At(i))throw new st("z.compile: async overwrite transforms are not supported");const s=M(t,i);e.write(`const ${o} = ${s}(${r});`)}function _s(){throw new tt}function Aa(e){this.issues.push(e)}function M_(e,t,n,r){const o=n._zod.def;if(o.fn){if(At(o.fn))throw new st("z.compile: async .refine() predicates are not supported");const i=Pt(t,o.fn),s=M(t,_s),a=P(t);return e.write(`const ${a} = ${i}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`),r}if(n._zod.check){if(At(n._zod.check))throw new st("z.compile: async .superRefine() / check functions are not supported");const i=n._zod.check,a=Pt(t,u=>{const l={value:u,issues:[],addIssue:Aa};return i(l)instanceof Promise&&_s(),l.issues.length===0?l.value:xe}),c=P(t);return e.write(`const ${c} = ${a}(${r});`),e.write(`if (${c} === INVALID) return INVALID;`),c}throw new H("custom check without a predicate or check function")}const R_=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function Sh(e,t,n,r,o=!0){const i=n.format;if(i==="base64"){const u=M(t,Fo);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="base64url"){const u=M(t,ma);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="jwt"){const u=M(t,_a),l=M(t,n.alg??null);return e.write(`if (!${u}(${r}, ${l})) return INVALID;`),r}if(i==="ipv6"){const u=M(t,jo);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="cidrv6"){const u=M(t,pa);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="credit_card"){const u=M(t,ga);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="iban"){const u=M(t,ya);return e.write(`if (!${u}(${r})) return INVALID;`),r}const s=n;if(i==="url"||i==="httpurl"||s.normalize||s.hostname!==void 0||s.protocol!==void 0){const u=M(t,la),l=M(t,n),d=P(t),f=P(t);if(e.write(`const ${d} = ${r}.trim();`),e.write(`const ${f} = ${u}(${d}, ${l});`),e.write(`if (typeof ${f} === "number") return INVALID;`),s.hostname!==void 0){const m=M(t,da);e.write(`if (!${m}(${f}, ${l}.hostname)) return INVALID;`)}if(s.protocol!==void 0){const m=M(t,fa);e.write(`if (!${m}(${f}, ${l}.protocol)) return INVALID;`)}if(!o)return null;const p=P(t),h=s.normalize?`${f}.href`:`${M(t,vo)}(${d})`;return e.write(`const ${p} = ${h};`),p}const a=n.fn;if(a){if(At(a))throw new H(`async string format ${i}`);const u=M(t,a);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(R_.has(i)&&n.pattern){const u=M(t,n.pattern);return e.write(`${u}.lastIndex = 0;`),e.write(`if (!${u}.test(${r})) return INVALID;`),r}const c=n.format;switch(c){case"regex":throw new H("regex format without a pattern");case"lowercase":e.write(`if (${r} !== ${r}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${r} !== ${r}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${r}.includes(${Pe(n.includes)})) return INVALID;`);break;case"starts_with":{const u=n.prefix;e.write(`if (${r}.slice(0, ${u.length}) !== ${Pe(u)}) return INVALID;`);break}case"ends_with":{const u=n.suffix;e.write(`if (${r}.slice(-${u.length}) !== ${Pe(u)}) return INVALID;`);break}default:throw new H(`string format ${c}`)}return r}function se(e,t,n,r,o=!0){const i=n._zod.def,s=i.type;if(i.coerce)throw new H(`coercion (z.coerce.${s}())`);const a=o||!!i.checks?.length;let c;switch(s){case"string":c=L_(e,t,n,r,a);break;case"number":c=Z_(e,n,r);break;case"boolean":c=D_(e,r);break;case"bigint":c=j_(e,n,r);break;case"symbol":c=F_(e,r);break;case"undefined":c=U_(e,r);break;case"null":c=V_(e,r);break;case"any":case"unknown":c=r;break;case"never":e.write("return INVALID;"),c=r;break;case"void":c=q_(e,r);break;case"nan":c=H_(e,r);break;case"date":c=B_(e,r);break;case"object":c=K_(e,t,n,r,a);break;case"optional":c=J_(e,t,n,r,a);break;case"nullable":c=Y_(e,t,n,r,a);break;case"array":c=Q_(e,t,n,r,a);break;case"literal":c=X_(e,t,n,r);break;case"enum":c=eb(e,t,n,r);break;case"readonly":{const u=Kl(e,t,n,r),l=P(t);e.write(`const ${l} = Object.freeze(${u});`),c=l;break}case"success":Kl(e,t,n,r),c="true";break;case"default":case"prefault":c=tb(e,t,n,r);break;case"nonoptional":c=nb(e,t,n,r);break;case"tuple":c=rb(e,t,n,r);break;case"union":c=ob(e,t,n,r);break;case"intersection":c=ab(e,t,n,r);break;case"record":c=cb(e,t,n,r);break;case"map":c=lb(e,t,n,r);break;case"set":c=db(e,t,n,r);break;case"file":c=fb(e,r);break;case"template_literal":c=pb(e,t,n,r);break;case"lazy":c=hb(e,t,n,r);break;case"pipe":c=mb(e,t,n,r);break;case"custom":c=gb(e,t,n,r);break;case"transform":c=bb(e,t,n,r);break;case"catch":c=_b(e,t,n,r);break;default:throw new H(`schema type ${s}`)}return c===null?null:z_(e,t,n,c)}function L_(e,t,n,r,o=!0){e.write(`if (typeof ${r} !== "string") return INVALID;`);const i=n._zod.def;return i.format===void 0?r:Sh(e,t,i,r,o)}function Z_(e,t,n){e.write(`if (typeof ${n} !== "number" || !Number.isFinite(${n})) return INVALID;`);const r=t._zod.def;return r.check==="number_format"&&r.format&&$h(e,{format:r.format},n),n}function D_(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function j_(e,t,n){e.write(`if (typeof ${n} !== "bigint") return INVALID;`);const r=t._zod.def;if(r.format)switch(r.format){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break}return n}function F_(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function U_(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function V_(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function q_(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function H_(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function B_(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function K_(e,t,n,r,o=!0){const i=n._zod.def;e.write(`if (typeof ${r} !== "object" || ${r} === null || Array.isArray(${r})) return INVALID;`);const s=i.shape,a=Object.keys(s),c=Object.getOwnPropertySymbols(s),u=c.length?[...a,...c]:a,l=v=>typeof v=="symbol"?M(t,v):Pe(v),d=v=>typeof v=="symbol"?`[${l(v)}]`:Pe(v),f=s;if(a.includes("__proto__"))throw new H('object shape key "__proto__"');const p=new Map;for(const v of u){const z=f[v],C=l(v),R=P(t);if(e.write(`const ${R} = ${r}[${C}];`),z._zod.optin!==void 0){const N=P(t);e.write(`let ${N} = (() => {`),e.indented(U=>{const de=$e(U,t,z,R);U.write(`return ${de};`)}),e.write("})();"),z._zod.optout==="optional"?(e.write(`if (${N} === INVALID) {`),e.indented(U=>{U.write(`if (${C} in ${r}) return INVALID;`),U.write(`${N} = undefined;`)}),e.write("}")):e.write(`if (${N} === INVALID) return INVALID;`),p.set(v,N)}else{G_(z)&&e.write(`if (!(${C} in ${r})) return INVALID;`);const N=$e(e,t,z,R,o);N!==null&&p.set(v,N)}}const h=i.catchall;let m="none";if(h){const v=h._zod.def.type;if(v==="never"){const z=a.map(C=>`k !== ${Pe(C)}`).join(" && ")||"true";e.write(`for (const k in ${r}) {`),e.indented(C=>{C.write(`if (${z}) return INVALID;`)}),e.write("}")}else(v==="unknown"||v==="any")&&!h._zod.def.checks?.length?m="passthrough":m="schema"}const k=P(t),I=u.some(v=>Bl(f[v])||bs(f[v]));if(!o){if(m==="schema"){const v=a.length>0?M(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(z=>{z.write('if (k === "__proto__") continue;'),v&&z.write(`if (${v}.has(k)) continue;`);const C=P(t);z.write(`const ${C} = ${r}[k];`),$e(z,t,h,C,!1)}),e.write("}")}return null}if(I){e.write(`const ${k} = {};`);for(const v of u){const z=l(v),C=p.get(v);bs(f[v])?e.write(`if (${z} in ${r}) ${k}[${z}] = ${C};`):Bl(f[v])?e.write(`if (${C} !== undefined || ${z} in ${r}) ${k}[${z}] = ${C};`):e.write(`${k}[${z}] = ${C};`)}}else{const v=u.map(z=>`${d(z)}: ${p.get(z)}`).join(", ");e.write(`const ${k} = { ${v} };`)}if(m!=="none"){const v=a.length>0?M(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(z=>{if(z.write('if (k === "__proto__") continue;'),v&&z.write(`if (${v}.has(k)) continue;`),m==="passthrough")z.write(`${k}[k] = ${r}[k];`);else{const C=P(t);z.write(`const ${C} = ${r}[k];`);const R=$e(z,t,h,C);z.write(`${k}[k] = ${R};`)}}),e.write("}")}return k}function J_(e,t,n,r,o=!0){const i=n._zod.def;if(W_(n))return se(e,t,i.innerType,r,o);if(i.innerType._zod.optin==="defaulted"){const a=P(t),c=P(t);return e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(u=>{u.write(`const ${c} = (() => {`),u.indented(l=>{const d=se(l,t,i.innerType,r);l.write(`return ${d};`)}),u.write("})();"),u.write(`if (${c} !== INVALID) ${a} = ${c};`)}),e.write("} else {"),e.indented(u=>{const l=se(u,t,i.innerType,r);u.write(`${a} = ${l};`)}),e.write("}"),a}const s=o?P(t):null;return s&&e.write(`let ${s};`),e.write(`if (${r} !== undefined) {`),e.indented(a=>{const c=se(a,t,i.innerType,r,o);s&&c!==null&&a.write(`${s} = ${c};`)}),e.write("}"),s}function W_(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function G_(e){return e._zod.optin===void 0&&Et(e)}function Et(e){if(e._zod.def.coerce)return!0;const t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?Et(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?Et(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Et):!0;case"intersection":return!t.left||!t.right?!0:Et(t.left)&&Et(t.right);case"pipe":return t.in?Et(t.in):!0;default:return!0}}function bs(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function Bl(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&Bt(e)}function Bt(e){const t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?Bt(t.innerType):!0;case"union":return t.options?t.options.some(Bt):!0;case"intersection":return!t.left||!t.right||Bt(t.left)||Bt(t.right);case"pipe":return t.out?Bt(t.out):!0;default:return!0}}function Y_(e,t,n,r,o=!0){const i=n._zod.def,s=o?P(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${r} !== null) {`),e.indented(a=>{const c=se(a,t,i.innerType,r,o);s&&c!==null&&a.write(`${s} = ${c};`)}),e.write("}"),s}function Q_(e,t,n,r,o=!0){const i=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`);const s=o?P(t):null,a=P(t),c=P(t);return s&&e.write(`const ${s} = new Array(${r}.length);`),e.write(`for (let ${a} = 0; ${a} < ${r}.length; ${a}++) {`),e.indented(u=>{u.write(`const ${c} = ${r}[${a}];`);const l=$e(u,t,i.element,c,o);s&&l!==null&&u.write(`${s}[${a}] = ${l};`)}),e.write("}"),s}function X_(e,t,n,r){const i=n._zod.def.values;if(i.length!==1){const a=M(t,new Set(i));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}const s=i[0];if(typeof s=="number"&&Number.isNaN(s)){const a=M(t,new Set(i));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}if(typeof s=="string")e.write(`if (${r} !== ${Pe(s)}) return INVALID;`);else if(typeof s=="number"||typeof s=="boolean")e.write(`if (${r} !== ${s}) return INVALID;`);else if(s===null)e.write(`if (${r} !== null) return INVALID;`);else if(s===void 0)e.write(`if (${r} !== undefined) return INVALID;`);else if(typeof s=="bigint")e.write(`if (${r} !== ${s}n) return INVALID;`);else throw new H(`literal type ${typeof s}`);return r}function eb(e,t,n,r){const o=n._zod.values;if(!o)throw new H("enum schema without enumerated values");const i=M(t,o);return e.write(`if (!${i}.has(${r})) return INVALID;`),r}function Kl(e,t,n,r){const o=n._zod.def;return se(e,t,o.innerType,r)}function tb(e,t,n,r){const o=n._zod.def,s=Object.getOwnPropertyDescriptor(n._zod.def,"defaultValue")?()=>n._zod.def.defaultValue:void 0;if(n._zod.def.type==="prefault"){if(!s)return se(e,t,o.innerType,r);const c=M(t,s),u=P(t);return e.write(`let ${u} = ${r};`),e.write(`if (${r} === undefined) ${u} = ${c}();`),se(e,t,o.innerType,u)}const a=P(t);if(s){const c=M(t,s),u=M(t,Hn);e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(l=>{l.write(`${a} = ${u}(${c}());`)}),e.write("} else {"),e.indented(l=>{const d=se(l,t,o.innerType,r);l.write(`${a} = ${d} === undefined ? ${u}(${c}()) : ${d};`)}),e.write("}")}else e.write(`let ${a};`),e.write(`if (${r} !== undefined) {`),e.indented(c=>{const u=se(c,t,o.innerType,r);c.write(`${a} = ${u};`)}),e.write("}");return a}function nb(e,t,n,r){const o=n._zod.def,i=se(e,t,o.innerType,r),s=P(t);return e.write(`const ${s} = ${i};`),e.write(`if (${s} === undefined) return INVALID;`),s}function rb(e,t,n,r){const o=n._zod.def,i=o.items,s=o.rest;e.write(`if (!Array.isArray(${r})) return INVALID;`);const a=Jl(i,"optin"),c=Jl(i,"optout");s?e.write(`if (${r}.length < ${a}) return INVALID;`):e.write(`if (${r}.length < ${a} || ${r}.length > ${i.length}) return INVALID;`);const u=P(t);e.write(`const ${u} = [];`);for(let l=0;l<i.length;l++){const d=i[l];if(l>=c)e.write(`if (${u}.length === ${l}) {`),e.indented(f=>{f.write(`if (${l} < ${r}.length) {`),f.indented(p=>{const h=P(t);p.write(`const ${h} = ${r}[${l}];`);const m=$e(p,t,d,h);p.write(`${u}[${l}] = ${m};`)}),f.write("} else {"),f.indented(p=>{if(bs(d)){p.write(`${u}.length = ${l};`);return}const h=P(t),m=P(t);p.write(`const ${h} = undefined;`),p.write(`const ${m} = (() => {`),p.indented(k=>{const I=$e(k,t,d,h);k.write(`return ${I};`)}),p.write("})();"),p.write(`if (${m} === INVALID || ${m} === undefined) ${u}.length = ${l};`),p.write(`else ${u}[${l}] = ${m};`)}),f.write("}")}),e.write("}");else{const f=P(t);e.write(`const ${f} = ${r}[${l}];`);const p=$e(e,t,d,f);e.write(`${u}[${l}] = ${p};`)}}if(s){const l=P(t),d=P(t);e.write(`for (let ${l} = ${i.length}; ${l} < ${r}.length; ${l}++) {`),e.indented(f=>{f.write(`const ${d} = ${r}[${l}];`);const p=$e(f,t,s,d);f.write(`${u}[${l}] = ${p};`)}),e.write("}")}return u}function Jl(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function ob(e,t,n,r){const o=n._zod.def,i=o.options;if(o.discriminator)return ib(e,t,o,r);if(o.inclusive===!1)throw new H("exclusive unions (z.xor)");if(i.length===0)return e.write("return INVALID;"),r;if(i.length===1)return se(e,t,i[0],r);if(i.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){const c=new Set(i.flatMap(l=>l._zod.def.values)),u=M(t,c);return e.write(`if (!${u}.has(${r})) return INVALID;`),r}const a=P(t);e.write(`let ${a};`);for(let c=0;c<i.length;c++){const u=i[c];c===0?e.write(`${a} = (() => {`):e.write(`if (${a} === INVALID) ${a} = (() => {`),e.indented(l=>{const d=se(l,t,u,r);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function ib(e,t,n,r){if(n.unionFallback)throw new H("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),r;const o=P(t),i=P(t);e.write(`const ${o} = ${r}?.[${Pe(n.discriminator)}];`),e.write(`let ${i};`);let s=!0;const a=new Set;for(const c of n.options){const u=c._zod.propValues?.[n.discriminator];if(!u||u.size===0)throw new H("discriminated union option without static discriminator values");for(const f of u){if(a.has(f))throw new H(`duplicate discriminator value ${String(f)}`);a.add(f)}const l=Array.from(u,f=>sb(t,o,f)),d=s?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{const p=se(f,t,c,r);f.write(`${i} = ${p};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),i}function sb(e,t,n){if(typeof n=="string")return`${t} === ${Pe(n)}`;if(typeof n=="number")return Number.isNaN(n)?`Number.isNaN(${t})`:`${t} === ${n}`;if(typeof n=="boolean")return`${t} === ${n}`;if(n===null)return`${t} === null`;if(n===void 0)return`${t} === undefined`;if(typeof n=="bigint")return`${t} === ${n}n`;if(typeof n=="symbol"){const r=M(e,n);return`${t} === ${r}`}throw new H(`literal discriminator value ${String(n)}`)}function ab(e,t,n,r){const o=n._zod.def;t.definite=!1;const i=$e(e,t,o.left,r),s=$e(e,t,o.right,r),a=M(t,Ln),c=P(t);return e.write(`const ${c} = ${a}(${i}, ${s});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function cb(e,t,n,r){const o=n._zod.def,i=M(t,rt);e.write(`if (!${i}(${r})) return INVALID;`);const s=P(t),a=P(t),c=P(t);e.write(`const ${s} = {};`);const u=o,l=u.partial?void 0:o.keyType._zod.values;if(l){const p=[];for(const m of l){if(!(typeof m=="string"||typeof m=="number"||typeof m=="symbol"))throw new H(`record key value ${String(m)}`);const k=typeof m=="number"?m.toString():m;if(k==="__proto__")throw new H('record key "__proto__"');p.push(k);const I=M(t,m),v=se(e,t,o.keyType,I),z=P(t);e.write(`const ${z} = ${r}[${ub(t,k)}];`);const C=$e(e,t,o.valueType,z);e.write(`${s}[${v}] = ${C};`)}const h=M(t,new Set(p));return e.write(`for (const ${a} in ${r}) {`),e.indented(m=>{m.write(`if (${h}.has(${a})) continue;`),u.mode==="loose"?m.write(`if (${a} !== "__proto__") ${s}[${a}] = ${r}[${a}];`):m.write("return INVALID;")}),e.write("}"),s}const d=o.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){const p=o.mode==="loose",h=Ko(o.keyType);h.definite===!1&&(t.definite=!1);const m=M(t,h),k=M(t,an),I=P(t);return Wl(e,t,r,a,v=>{v.write(`let ${I} = ${m}(${a});`),v.write(`if (${I} === INVALID && typeof ${a} === "string" && ${k}.test(${a})) ${I} = ${m}(Number(${a}));`),p?v.write(`if (${I} === INVALID) { ${s}[${a}] = ${r}[${a}]; continue; }`):v.write(`if (${I} === INVALID) return INVALID;`),v.write(`if (${I} === "__proto__") continue;`);const z=P(t);v.write(`const ${z} = ${r}[${a}];`);const C=$e(v,t,o.valueType,z);v.write(`${s}[${I}] = ${C};`)}),s}return Wl(e,t,r,a,p=>{p.write(`const ${c} = ${r}[${a}];`);const h=$e(p,t,o.valueType,c);p.write(`${s}[${a}] = ${h};`)},"return INVALID;"),s}function Wl(e,t,n,r,o,i){const s=M(t,Object.prototype.propertyIsEnumerable),a=P(t),c=P(t),u=P(t);e.write(`const ${a} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${c} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${u} = 0; ${u} < ${c}.length; ${u}++) {`),e.indented(l=>{l.write(`const ${r} = ${c}[${u}];`),l.write(`if (${r} === "__proto__" || !${s}.call(${n}, ${r})) continue;`),o(l)}),e.write("}"),e.write(`for (let ${u} = 0; ${u} < ${a}.length; ${u}++) {`),e.indented(l=>{l.write(`const ${r} = ${a}[${u}];`),l.write(`if (!${s}.call(${n}, ${r})) continue;`),i?l.write(i):o(l)}),e.write("}")}function ub(e,t){return typeof t=="string"?Pe(t):M(e,t)}function lb(e,t,n,r){const o=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`);const i=P(t),s=P(t),a=P(t);return e.write(`const ${i} = new Map();`),e.write(`for (const [${s}, ${a}] of ${r}) {`),e.indented(c=>{const u=se(c,t,o.keyType,s),l=se(c,t,o.valueType,a);c.write(`${i}.set(${u}, ${l});`)}),e.write("}"),i}function db(e,t,n,r){const o=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`);const i=P(t),s=P(t);return e.write(`const ${i} = new Set();`),e.write(`for (const ${s} of ${r}) {`),e.indented(a=>{const c=se(a,t,o.valueType,s);a.write(`${i}.add(${c});`)}),e.write("}"),i}function fb(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function pb(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);const o=n._zod.pattern;if(o){const i=M(t,o);e.write(`${i}.lastIndex = 0;`),e.write(`if (!${i}.test(${r})) return INVALID;`)}return r}function hb(e,t,n,r){const o=n._zod.def,i=Pt(t,o.getter),s=M(t,{parser:null});e.write(`if (!${s}.parser) {`),e.indented(c=>{c.write(`const inner = ${i}();`),c.write(`${s}.parser = function(input) {`),c.indented(u=>{u.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),u.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),e.write("}");const a=P(t);return e.write(`const ${a} = ${s}.parser(${r});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function mb(e,t,n,r){const o=n._zod.def,i=se(e,t,o.in,r);if(o.transform){if(At(o.transform))throw new st("z.compile: async transforms in pipes are not supported");const s=o.transform,c=Pt(t,l=>{const d={value:l,issues:[],addIssue:Aa},f=s(l,d);return f instanceof Promise?xe:d.issues.length===0?f:xe}),u=P(t);return e.write(`const ${u} = ${c}(${i});`),e.write(`if (${u} === INVALID) return INVALID;`),se(e,t,o.out,u)}else return se(e,t,o.out,i)}function At(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function gb(e,t,n,r){const o=n._zod.def;if(o.fn){if(At(o.fn))throw new st("z.compile: async custom predicates are not supported");const i=Pt(t,o.fn),s=M(t,_s),a=P(t);e.write(`const ${a} = ${i}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`)}else throw new H("custom schema without a predicate function");return r}function yb(e,t,n){const r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then=="function")return xe;const o=r;return o.issues.length===0?o.value:t()}function _b(e,t,n,r){const o=n._zod.def;if(!o.catchValue[Ls])throw new H("catch with a callback (only a constant catch value compiles)",!1);const i=P(t);e.write(`let ${i} = (() => {`),e.indented(u=>{const l=$e(u,t,o.innerType,r);u.write(`return ${l};`)}),e.write("})();");const s=M(t,o.innerType),a=Pt(t,o.catchValue),c=M(t,yb);return e.write(`if (${i} === INVALID) {`),e.indented(u=>{u.write(`${i} = ${c}(${s}, ${a}, ${r});`),u.write(`if (${i} === INVALID) return INVALID;`)}),e.write("}"),i}function bb(e,t,n,r){const o=n._zod.def;if(o.transform){if(At(o.transform))throw new st("z.compile: async transforms are not supported");const i=o.transform,a=Pt(t,u=>{const l={value:u,issues:[],addIssue:Aa},d=i(u,l);return d instanceof Promise?xe:l.issues.length===0?d:xe}),c=P(t);return e.write(`const ${c} = ${a}(${r});`),e.write(`if (${c} === INVALID) return INVALID;`),c}return r}function Jo(e){return e.checks&&(e.checks=[...e.checks]),e}function Ih(e,t){return new e(Jo({type:"string",...$(t)}))}function zh(e,t){return new e(Jo({type:"string",coerce:!0,...$(t)}))}function Ma(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...$(t)})}function Ra(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...$(t)})}function La(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...$(t)})}function Za(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...$(t)})}function Da(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...$(t)})}function ja(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...$(t)})}function Wo(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...$(t)})}function Fa(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...$(t)})}function Ua(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...$(t)})}function Va(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...$(t)})}function qa(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...$(t)})}function Ha(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...$(t)})}function Ba(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...$(t)})}function Ka(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...$(t)})}function Ja(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...$(t)})}function Wa(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...$(t)})}function xh(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...$(t)})}function Ga(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...$(t)})}function Ya(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...$(t)})}function Qa(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...$(t)})}function Xa(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...$(t)})}function ec(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...$(t)})}function Th(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...$(t)})}function Ch(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...$(t)})}function tc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...$(t)})}const nc={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function rc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...$(t)})}function oc(e,t){return new e({type:"string",format:"date",check:"string_format",...$(t)})}function ic(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...$(t)})}function sc(e,t){return new e({type:"string",format:"duration",check:"string_format",...$(t)})}function Eh(e,t){return new e(Jo({type:"number",checks:[],...$(t)}))}function Nh(e,t){return new e(Jo({type:"number",coerce:!0,checks:[],...$(t)}))}function Oh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...$(t)})}function Ph(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...$(t)})}function Ah(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...$(t)})}function Mh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...$(t)})}function Rh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...$(t)})}function Lh(e,t){return new e({type:"boolean",...$(t)})}function Zh(e,t){return new e({type:"boolean",coerce:!0,...$(t)})}function Dh(e,t){return new e({type:"bigint",...$(t)})}function jh(e,t){return new e({type:"bigint",coerce:!0,...$(t)})}function Fh(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...$(t)})}function Uh(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...$(t)})}function Vh(e,t){return new e({type:"symbol",...$(t)})}function qh(e,t){return new e({type:"undefined",...$(t)})}function Hh(e,t){return new e({type:"null",...$(t)})}function Bh(e){return new e({type:"any"})}function Kh(e){return new e({type:"unknown"})}function Jh(e,t){return new e({type:"never",...$(t)})}function Wh(e,t){return new e({type:"void",...$(t)})}function Gh(e,t){return new e({type:"date",...$(t)})}function Yh(e,t){return new e({type:"date",coerce:!0,...$(t)})}function Qh(e,t){return new e({type:"nan",...$(t)})}function at(e,t){return new oa({check:"less_than",...$(t),value:e,inclusive:!1})}function Ae(e,t){return new oa({check:"less_than",...$(t),value:e,inclusive:!0})}function ct(e,t){return new ia({check:"greater_than",...$(t),value:e,inclusive:!1})}function Me(e,t){return new ia({check:"greater_than",...$(t),value:e,inclusive:!0})}function Go(e){return ct(0,e)}function Yo(e){return at(0,e)}function Qo(e){return Ae(0,e)}function Xo(e){return Me(0,e)}function Mt(e,t){return new Lf({check:"multiple_of",...$(t),value:e})}function Dt(e,t){return new jf({check:"max_size",...$(t),maximum:e})}function ut(e,t){return new Ff({check:"min_size",...$(t),minimum:e})}function cn(e,t){return new Uf({check:"size_equals",...$(t),size:e})}function un(e,t){return new Vf({check:"max_length",...$(t),maximum:e})}function bt(e,t){return new qf({check:"min_length",...$(t),minimum:e})}function ln(e,t){return new Hf({check:"length_equals",...$(t),length:e})}function nr(e,t){return new Bf({check:"string_format",format:"regex",...$(t),pattern:e})}function rr(e){return new Kf({check:"string_format",format:"lowercase",...$(e)})}function or(e){return new Jf({check:"string_format",format:"uppercase",...$(e)})}function ir(e,t){return new Wf({check:"string_format",format:"includes",...$(t),includes:e})}function sr(e,t){return new Gf({check:"string_format",format:"starts_with",...$(t),prefix:e})}function ar(e,t){return new Yf({check:"string_format",format:"ends_with",...$(t),suffix:e})}function ei(e,t,n){return new Qf({check:"property",property:e,schema:t,...$(n)})}function cr(e,t){return new Xf({check:"properties",shape:e,...$(t)})}function ur(e,t){return new ep({check:"mime_type",mime:e,...$(t)})}function Ye(e){return new tp({check:"overwrite",tx:e})}function lr(e){return Ye(t=>t.normalize(e))}function dr(){return Ye(e=>e.trim())}function fr(){return Ye(e=>e.toLowerCase())}function pr(){return Ye(e=>e.toUpperCase())}function hr(){return Ye(e=>Od(e))}function Xh(e,t,n){return new e({type:"array",element:t,...$(n)})}function wb(e,t,n){return new e({type:"union",options:t,...$(n)})}function vb(e,t,n){return new e({type:"union",options:t,inclusive:!1,...$(n)})}function kb(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...$(r)})}function $b(e,t,n){return new e({type:"intersection",left:t,right:n})}function Sb(e,t,n,r){const o=n instanceof L,i=o?r:n,s=o?n:null;return new e({type:"tuple",items:t,rest:s,...$(i)})}function Ib(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...$(r)})}function zb(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...$(r)})}function xb(e,t,n){return new e({type:"set",valueType:t,...$(n)})}function Tb(e,t,n){const r=Array.isArray(t)?Object.fromEntries(t.map(o=>[o,o])):t;return new e({type:"enum",entries:r,...$(n)})}function Cb(e,t,n){return new e({type:"enum",entries:t,...$(n)})}function Eb(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...$(n)})}function em(e,t){return new e({type:"file",...$(t)})}function Nb(e,t){return new e({type:"transform",transform:t})}function Ob(e,t){return new e({type:"optional",innerType:t})}function Pb(e,t){return new e({type:"nullable",innerType:t})}function Ab(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():Hn(n)}})}function Mb(e,t,n){return new e({type:"nonoptional",innerType:t,...$(n)})}function Rb(e,t){return new e({type:"success",innerType:t})}function Lb(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:Zs(n)})}function Zb(e,t,n){return new e({type:"pipe",in:t,out:n})}function Db(e,t){return new e({type:"readonly",innerType:t})}function jb(e,t,n){return new e({type:"template_literal",parts:t,...$(n)})}function Fb(e,t){return new e({type:"lazy",getter:t})}function Ub(e,t){return new e({type:"promise",innerType:t})}function tm(e,t,n){const r=$(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function nm(e,t,n){return new e({type:"custom",check:"custom",fn:t,...$(n)})}function rm(e,t){const n=om(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Wt(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(Wt(i))}},e(r.value,r)),t);return n}function om(e,t){const n=new ie({check:"custom",...$(t)});return n._zod.check=e,n}function im(e){const t=new ie({check:"describe"});return t._zod.onattach=[n=>{const r=Oe.get(n)??{};Oe.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function sm(e){const t=new ie({check:"meta"});return t._zod.onattach=[n=>{const r=Oe.get(n)??{};Oe.add(n,{...r,...e})}],t._zod.check=()=>{},t}function am(e,t){const n=$(t);let r=n.truthy??["true","1","yes","on","y","enabled"],o=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(r=r.map(p=>typeof p=="string"?p.toLowerCase():p),o=o.map(p=>typeof p=="string"?p.toLowerCase():p));const i=new Set(r),s=new Set(o),a=e.Codec??za,c=e.Boolean??wa,u=e.String??tr,l=new u({type:"string",error:n.error}),d=new c({type:"boolean",error:n.error}),f=new a({type:"pipe",in:l,out:d,transform:((p,h)=>{let m=p;return n.case!=="sensitive"&&(m=m.toLowerCase()),i.has(m)?!0:s.has(m)?!1:(h.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:h.value,inst:f,continue:!1}),{})}),reverseTransform:((p,h)=>p===!0?r[0]||"true":o[0]||"false"),error:n.error});return f._zod.bag.truthy=r,f._zod.bag.falsy=o,f._zod.bag.case=n.case??"insensitive",f}function dn(e,t,n,r={}){const o=$(r),i={check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:a=>n.test(a),...o};return n instanceof RegExp&&(i.pattern=n),new e(i)}function An(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&Re(e,r,n[r]);return e}function Yt(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??Oe,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ye(e,t,n,r,o){const i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(o);return Object.assign(n,i),!0}function ee(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const l={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{const f=s.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,l)}const d=e._zod.parent;d&&(s.ref||(s.ref=d),ee(d,t,l),t.seen.get(d).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&An(s.schema,c),t.io==="input"&&Se(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function Gl(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function Qt(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=r.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(s[0])?.id,f=e.external.uri??(h=>h);if(d)return{ref:f(d)};const p=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${Gl(p)}`}}const c="#",u=`${c}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:c};const l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+Gl(l)}},i=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:u}=o(s);a.def={...a.schema},u&&(a.defId=u);const l=a.schema;for(const d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
68
+ }`;let f;try{f=new l(...s,d)(...a)}catch(p){throw new B(`this schema (generated code failed to evaluate: ${p.message})`)}return t?.debug&&(f.code=u),f.definite=r.definite,f}function R(e,t){for(const[r,o]of e.constants)if(o===t)return r;const n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}function Dt(e,t){return e.definite=!1,R(e,t)}function P(e){return`v${e.varCounter++}`}function ob(e,t){const n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return Ce;const r=n;return r.issues.length===0?r.value:Ce}function Ie(e,t,n,r,o=!0){const i=e.content.length,s=t.constants.size,a=t.constantCounter,c=t.varCounter;try{return se(e,t,n,r,o)}catch(u){if(!(u instanceof B)||!u.islandable)throw u;if(e.content.length=i,t.constants.size>s){const l=Array.from(t.constants.keys()).slice(s);for(const d of l)t.constants.delete(d)}return t.constantCounter=a,t.varCounter=c,ib(e,t,n,r)}}function ib(e,t,n,r){t.definite=!1;const o=R(t,n),i=R(t,ob),s=P(t);return e.write(`const ${s} = ${i}(${o}, ${r});`),e.write(`if (${s} === INVALID) return INVALID;`),s}const sb=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function ab(e,t,n,r){const o=n._zod.def.checks;if(!o||o.length===0)return r;let i=r;for(const s of o){const a=s._zod.def;if(a.when&&!sb.has(a.check))throw new B('check with a custom "when" condition');switch(a.check){case"greater_than":cb(e,t,a,i);break;case"less_than":ub(e,t,a,i);break;case"multiple_of":lb(e,t,a,i);break;case"number_format":qh(e,a,i);break;case"min_length":{const c=Pt(a.minimum,"min_length"),u=ds(e,t,i,`${i}.length >= ${c} && ${i}.length < ${a.minimum*2}`);e.write(`if (${u} < ${c}) return INVALID;`);break}case"max_length":{const c=Pt(a.maximum,"max_length"),u=ds(e,t,i,`${i}.length > ${c}`);e.write(`if (${u} > ${c}) return INVALID;`);break}case"length_equals":{const c=Pt(a.length,"length_equals"),u=ds(e,t,i,`${i}.length >= ${c} && ${i}.length <= ${a.length*2}`);e.write(`if (${u} !== ${c}) return INVALID;`);break}case"min_size":e.write(`if (${i}.size < ${Pt(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${i}.size > ${Pt(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${i}.size !== ${Pt(a.size,"size_equals")}) return INVALID;`);break;case"string_format":i=Hh(e,t,a,i);break;case"custom":i=gb(e,t,s,i);break;case"bigint_format":db(e,a,i);break;case"mime_type":fb(e,t,a,i);break;case"property":hb(e,t,a,i);break;case"properties":pb(e,t,a,i);break;case"overwrite":{const c=P(t);mb(e,t,s,i,c),i=c;break}default:throw new B(`check type ${a.check}`)}}return i}function ds(e,t,n,r){const o=R(t,Qn),i=P(t);return e.write(`const ${i} = typeof ${n} === "string" && ${r} ? ${o}(${n}) : ${n}.length;`),i}function Pt(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new B(`${t} bound of type ${typeof e}`);return`${e}`}function Vh(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new B("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new B("comparison check with Invalid Date bound");return R(e,t)}throw new B(`comparison check bound of type ${typeof t}`)}function cb(e,t,n,r){const o=n.inclusive?"<":"<=";e.write(`if (${r} ${o} ${Vh(t,n.value)}) return INVALID;`)}function ub(e,t,n,r){const o=n.inclusive?">":">=";e.write(`if (${r} ${o} ${Vh(t,n.value)}) return INVALID;`)}function lb(e,t,n,r){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new B("multiple_of check with a zero divisor");e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{const o=R(t,Hs);e.write(`if (${o}(${r}, ${Pt(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function qh(e,t,n){const r=t.format;switch(r){case"safeint":e.write(`if (!Number.isSafeInteger(${n})) return INVALID;`);break;case"int32":e.write(`if (!Number.isInteger(${n}) || ${n} < -2147483648 || ${n} > 2147483647) return INVALID;`);break;case"uint32":e.write(`if (!Number.isInteger(${n}) || ${n} < 0 || ${n} > 4294967295) return INVALID;`);break;case"float32":e.write(`if (!Number.isFinite(${n}) || ${n} < -3.4028234663852886e38 || ${n} > 3.4028234663852886e38) return INVALID;`);break;case"float64":e.write(`if (!Number.isFinite(${n})) return INVALID;`);break;default:throw new B(`number format ${r}`)}}function db(e,t,n){const r=t.format;if(r)switch(r){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break;default:throw new B(`bigint format ${r}`)}}function fb(e,t,n,r){const o=n.mime;if(o&&o.length>0){const i=R(t,new Set(o));e.write(`if (!${i}.has(${r}.type)) return INVALID;`)}}function pb(e,t,n,r){if(n.when)throw new B('check with a custom "when" condition');e.write(`if (${r} == null) return INVALID;`);const o=n.shape;for(const i of Reflect.ownKeys(o)){const s=typeof i=="symbol"?R(t,i):De(i),a=P(t);e.write(`const ${a} = ${r}[${s}];`),Ie(e,t,o[i],a,!1)}}function hb(e,t,n,r){const o=`${r}[${JSON.stringify(n.property)}]`;se(e,t,n.schema,o)}function mb(e,t,n,r,o){const i=n._zod.def.tx;if(!i)throw new B("overwrite check without a transform function");if(Zt(i))throw new dt("z.compile: async overwrite transforms are not supported");const s=R(t,i);e.write(`const ${o} = ${s}(${r});`)}function Ts(){throw new st}function Ka(e){this.issues.push(e)}function gb(e,t,n,r){const o=n._zod.def;if(o.fn){if(Zt(o.fn))throw new dt("z.compile: async .refine() predicates are not supported");const i=Dt(t,o.fn),s=R(t,Ts),a=P(t);return e.write(`const ${a} = ${i}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`),r}if(n._zod.check){if(Zt(n._zod.check))throw new dt("z.compile: async .superRefine() / check functions are not supported");const i=n._zod.check,a=Dt(t,u=>{const l={value:u,issues:[],addIssue:Ka};return i(l)instanceof Promise&&Ts(),l.issues.length===0?l.value:Ce}),c=P(t);return e.write(`const ${c} = ${a}(${r});`),e.write(`if (${c} === INVALID) return INVALID;`),c}throw new B("custom check without a predicate or check function")}const yb=new Set(["cidrv4","cuid","cuid2","date","datetime","duration","e164","email","emoji","ends_with","guid","includes","ipv4","ksuid","lowercase","mac","nanoid","regex","starts_with","time","ulid","uppercase","uuid","xid"]);function Hh(e,t,n,r,o=!0){const i=n.format;if(i==="base64"){const u=R(t,Wo);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="base64url"){const u=R(t,Ta);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="jwt"){const u=R(t,Aa),l=R(t,n.alg??null);return e.write(`if (!${u}(${r}, ${l})) return INVALID;`),r}if(i==="ipv6"){const u=R(t,Jo);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="cidrv6"){const u=R(t,xa);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="credit_card"){const u=R(t,Ea);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(i==="iban"){const u=R(t,Ca);return e.write(`if (!${u}(${r})) return INVALID;`),r}const s=n;if(i==="url"||i==="httpurl"||s.normalize||s.hostname!==void 0||s.protocol!==void 0){const u=R(t,$a),l=R(t,n),d=P(t),f=P(t);if(e.write(`const ${d} = ${r}.trim();`),e.write(`const ${f} = ${u}(${d}, ${l});`),e.write(`if (typeof ${f} === "number") return INVALID;`),s.hostname!==void 0){const m=R(t,Sa);e.write(`if (!${m}(${f}, ${l}.hostname)) return INVALID;`)}if(s.protocol!==void 0){const m=R(t,Ia);e.write(`if (!${m}(${f}, ${l}.protocol)) return INVALID;`)}if(!o)return null;const p=P(t),h=s.normalize?`${f}.href`:`${R(t,Eo)}(${d})`;return e.write(`const ${p} = ${h};`),p}const a=n.fn;if(a){if(Zt(a))throw new B(`async string format ${i}`);const u=R(t,a);return e.write(`if (!${u}(${r})) return INVALID;`),r}if(yb.has(i)&&n.pattern){const u=R(t,n.pattern);return e.write(`${u}.lastIndex = 0;`),e.write(`if (!${u}.test(${r})) return INVALID;`),r}const c=n.format;switch(c){case"regex":throw new B("regex format without a pattern");case"lowercase":e.write(`if (${r} !== ${r}.toLowerCase()) return INVALID;`);break;case"uppercase":e.write(`if (${r} !== ${r}.toUpperCase()) return INVALID;`);break;case"includes":e.write(`if (!${r}.includes(${De(n.includes)})) return INVALID;`);break;case"starts_with":{const u=n.prefix;e.write(`if (${r}.slice(0, ${u.length}) !== ${De(u)}) return INVALID;`);break}case"ends_with":{const u=n.suffix;e.write(`if (${r}.slice(-${u.length}) !== ${De(u)}) return INVALID;`);break}default:throw new B(`string format ${c}`)}return r}function se(e,t,n,r,o=!0){const i=n._zod.def,s=i.type;if(i.coerce)throw new B(`coercion (z.coerce.${s}())`);const a=o||!!i.checks?.length;let c;switch(s){case"string":c=_b(e,t,n,r,a);break;case"number":c=bb(e,n,r);break;case"boolean":c=wb(e,r);break;case"bigint":c=vb(e,n,r);break;case"symbol":c=kb(e,r);break;case"undefined":c=$b(e,r);break;case"null":c=Sb(e,r);break;case"any":case"unknown":c=r;break;case"never":e.write("return INVALID;"),c=r;break;case"void":c=Ib(e,r);break;case"nan":c=xb(e,r);break;case"date":c=zb(e,r);break;case"object":c=Tb(e,t,n,r,a);break;case"optional":c=Eb(e,t,n,r,a);break;case"nullable":c=Nb(e,t,n,r,a);break;case"array":c=Ob(e,t,n,r,a);break;case"literal":c=Pb(e,t,n,r);break;case"enum":c=Mb(e,t,n,r);break;case"readonly":{const u=od(e,t,n,r),l=P(t);e.write(`const ${l} = Object.freeze(${u});`),c=l;break}case"success":od(e,t,n,r),c="true";break;case"default":case"prefault":c=Rb(e,t,n,r);break;case"nonoptional":c=Lb(e,t,n,r);break;case"tuple":c=Db(e,t,n,r);break;case"union":c=Zb(e,t,n,r);break;case"intersection":c=Ub(e,t,n,r);break;case"record":c=Vb(e,t,n,r);break;case"map":c=Hb(e,t,n,r);break;case"set":c=Bb(e,t,n,r);break;case"file":c=Kb(e,r);break;case"template_literal":c=Jb(e,t,n,r);break;case"lazy":c=Wb(e,t,n,r);break;case"pipe":c=Gb(e,t,n,r);break;case"custom":c=Yb(e,t,n,r);break;case"transform":c=ew(e,t,n,r);break;case"catch":c=Xb(e,t,n,r);break;default:throw new B(`schema type ${s}`)}return c===null?null:ab(e,t,n,c)}function _b(e,t,n,r,o=!0){e.write(`if (typeof ${r} !== "string") return INVALID;`);const i=n._zod.def;return i.format===void 0?r:Hh(e,t,i,r,o)}function bb(e,t,n){e.write(`if (typeof ${n} !== "number" || !Number.isFinite(${n})) return INVALID;`);const r=t._zod.def;return r.check==="number_format"&&r.format&&qh(e,{format:r.format},n),n}function wb(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function vb(e,t,n){e.write(`if (typeof ${n} !== "bigint") return INVALID;`);const r=t._zod.def;if(r.format)switch(r.format){case"int64":e.write(`if (${n} < -9223372036854775808n || ${n} > 9223372036854775807n) return INVALID;`);break;case"uint64":e.write(`if (${n} < 0n || ${n} > 18446744073709551615n) return INVALID;`);break}return n}function kb(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function $b(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function Sb(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function Ib(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function xb(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function zb(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function Tb(e,t,n,r,o=!0){const i=n._zod.def;e.write(`if (typeof ${r} !== "object" || ${r} === null || Array.isArray(${r})) return INVALID;`);const s=i.shape,a=Object.keys(s),c=Object.getOwnPropertySymbols(s),u=c.length?[...a,...c]:a,l=w=>typeof w=="symbol"?R(t,w):De(w),d=w=>typeof w=="symbol"?`[${l(w)}]`:De(w),f=s;if(a.includes("__proto__"))throw new B('object shape key "__proto__"');const p=new Map;for(const w of u){const S=f[w],T=l(w),O=P(t);if(e.write(`const ${O} = ${r}[${T}];`),S._zod.optin!==void 0){const C=P(t);e.write(`let ${C} = (() => {`),e.indented(L=>{const ue=Ie(L,t,S,O);L.write(`return ${ue};`)}),e.write("})();"),S._zod.optout==="optional"?(e.write(`if (${C} === INVALID) {`),e.indented(L=>{L.write(`if (${T} in ${r}) return INVALID;`),L.write(`${C} = undefined;`)}),e.write("}")):e.write(`if (${C} === INVALID) return INVALID;`),p.set(w,C)}else{Ab(S)&&e.write(`if (!(${T} in ${r})) return INVALID;`);const C=Ie(e,t,S,O,o);C!==null&&p.set(w,C)}}const h=i.catchall;let m="none";if(h){const w=h._zod.def.type;if(w==="never"){const S=a.map(T=>`k !== ${De(T)}`).join(" && ")||"true";e.write(`for (const k in ${r}) {`),e.indented(T=>{T.write(`if (${S}) return INVALID;`)}),e.write("}")}else(w==="unknown"||w==="any")&&!h._zod.def.checks?.length?m="passthrough":m="schema"}const y=P(t),$=u.some(w=>rd(f[w])||Es(f[w]));if(!o){if(m==="schema"){const w=a.length>0?R(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(S=>{S.write('if (k === "__proto__") continue;'),w&&S.write(`if (${w}.has(k)) continue;`);const T=P(t);S.write(`const ${T} = ${r}[k];`),Ie(S,t,h,T,!1)}),e.write("}")}return null}if($){e.write(`const ${y} = {};`);for(const w of u){const S=l(w),T=p.get(w);Es(f[w])?e.write(`if (${S} in ${r}) ${y}[${S}] = ${T};`):rd(f[w])?e.write(`if (${T} !== undefined || ${S} in ${r}) ${y}[${S}] = ${T};`):e.write(`${y}[${S}] = ${T};`)}}else{const w=u.map(S=>`${d(S)}: ${p.get(S)}`).join(", ");e.write(`const ${y} = { ${w} };`)}if(m!=="none"){const w=a.length>0?R(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(S=>{if(S.write('if (k === "__proto__") continue;'),w&&S.write(`if (${w}.has(k)) continue;`),m==="passthrough")S.write(`${y}[k] = ${r}[k];`);else{const T=P(t);S.write(`const ${T} = ${r}[k];`);const O=Ie(S,t,h,T);S.write(`${y}[k] = ${O};`)}}),e.write("}")}return y}function Eb(e,t,n,r,o=!0){const i=n._zod.def;if(Cb(n))return se(e,t,i.innerType,r,o);if(i.innerType._zod.optin==="defaulted"){const a=P(t),c=P(t);return e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(u=>{u.write(`const ${c} = (() => {`),u.indented(l=>{const d=se(l,t,i.innerType,r);l.write(`return ${d};`)}),u.write("})();"),u.write(`if (${c} !== INVALID) ${a} = ${c};`)}),e.write("} else {"),e.indented(u=>{const l=se(u,t,i.innerType,r);u.write(`${a} = ${l};`)}),e.write("}"),a}const s=o?P(t):null;return s&&e.write(`let ${s};`),e.write(`if (${r} !== undefined) {`),e.indented(a=>{const c=se(a,t,i.innerType,r,o);s&&c!==null&&a.write(`${s} = ${c};`)}),e.write("}"),s}function Cb(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function Ab(e){return e._zod.optin===void 0&&Mt(e)}function Mt(e){if(e._zod.def.coerce)return!0;const t=e._zod.def;switch(t.type){case"any":case"unknown":case"undefined":case"void":case"default":case"prefault":case"transform":case"custom":case"lazy":return!0;case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"never":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":return!1;case"nonoptional":return t.innerType?Mt(t.innerType):!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":case"nullable":case"readonly":case"success":return t.innerType?Mt(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Mt):!0;case"intersection":return!t.left||!t.right?!0:Mt(t.left)&&Mt(t.right);case"pipe":return t.in?Mt(t.in):!0;default:return!0}}function Es(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function rd(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&Wt(e)}function Wt(e){const t=e._zod.def;switch(t.type){case"string":case"number":case"boolean":case"bigint":case"symbol":case"null":case"nan":case"date":case"object":case"array":case"tuple":case"record":case"map":case"set":case"file":case"template_literal":case"never":case"success":return!1;case"literal":return!!t.values?.includes(void 0);case"enum":return!!e._zod.values?.has(void 0);case"optional":return!0;case"nullable":case"readonly":case"nonoptional":return t.innerType?Wt(t.innerType):!0;case"union":return t.options?t.options.some(Wt):!0;case"intersection":return!t.left||!t.right||Wt(t.left)||Wt(t.right);case"pipe":return t.out?Wt(t.out):!0;default:return!0}}function Nb(e,t,n,r,o=!0){const i=n._zod.def,s=o?P(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${r} !== null) {`),e.indented(a=>{const c=se(a,t,i.innerType,r,o);s&&c!==null&&a.write(`${s} = ${c};`)}),e.write("}"),s}function Ob(e,t,n,r,o=!0){const i=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`);const s=o?P(t):null,a=P(t),c=P(t);return s&&e.write(`const ${s} = new Array(${r}.length);`),e.write(`for (let ${a} = 0; ${a} < ${r}.length; ${a}++) {`),e.indented(u=>{u.write(`const ${c} = ${r}[${a}];`);const l=Ie(u,t,i.element,c,o);s&&l!==null&&u.write(`${s}[${a}] = ${l};`)}),e.write("}"),s}function Pb(e,t,n,r){const i=n._zod.def.values;if(i.length!==1){const a=R(t,new Set(i));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}const s=i[0];if(typeof s=="number"&&Number.isNaN(s)){const a=R(t,new Set(i));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}if(typeof s=="string")e.write(`if (${r} !== ${De(s)}) return INVALID;`);else if(typeof s=="number"||typeof s=="boolean")e.write(`if (${r} !== ${s}) return INVALID;`);else if(s===null)e.write(`if (${r} !== null) return INVALID;`);else if(s===void 0)e.write(`if (${r} !== undefined) return INVALID;`);else if(typeof s=="bigint")e.write(`if (${r} !== ${s}n) return INVALID;`);else throw new B(`literal type ${typeof s}`);return r}function Mb(e,t,n,r){const o=n._zod.values;if(!o)throw new B("enum schema without enumerated values");const i=R(t,o);return e.write(`if (!${i}.has(${r})) return INVALID;`),r}function od(e,t,n,r){const o=n._zod.def;return se(e,t,o.innerType,r)}function Rb(e,t,n,r){const o=n._zod.def,s=Object.getOwnPropertyDescriptor(n._zod.def,"defaultValue")?()=>n._zod.def.defaultValue:void 0;if(n._zod.def.type==="prefault"){if(!s)return se(e,t,o.innerType,r);const c=R(t,s),u=P(t);return e.write(`let ${u} = ${r};`),e.write(`if (${r} === undefined) ${u} = ${c}();`),se(e,t,o.innerType,u)}const a=P(t);if(s){const c=R(t,s),u=R(t,Yn);e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(l=>{l.write(`${a} = ${u}(${c}());`)}),e.write("} else {"),e.indented(l=>{const d=se(l,t,o.innerType,r);l.write(`${a} = ${d} === undefined ? ${u}(${c}()) : ${d};`)}),e.write("}")}else e.write(`let ${a};`),e.write(`if (${r} !== undefined) {`),e.indented(c=>{const u=se(c,t,o.innerType,r);c.write(`${a} = ${u};`)}),e.write("}");return a}function Lb(e,t,n,r){const o=n._zod.def,i=se(e,t,o.innerType,r),s=P(t);return e.write(`const ${s} = ${i};`),e.write(`if (${s} === undefined) return INVALID;`),s}function Db(e,t,n,r){const o=n._zod.def,i=o.items,s=o.rest;e.write(`if (!Array.isArray(${r})) return INVALID;`);const a=id(i,"optin"),c=id(i,"optout");s?e.write(`if (${r}.length < ${a}) return INVALID;`):e.write(`if (${r}.length < ${a} || ${r}.length > ${i.length}) return INVALID;`);const u=P(t);e.write(`const ${u} = [];`);for(let l=0;l<i.length;l++){const d=i[l];if(l>=c)e.write(`if (${u}.length === ${l}) {`),e.indented(f=>{f.write(`if (${l} < ${r}.length) {`),f.indented(p=>{const h=P(t);p.write(`const ${h} = ${r}[${l}];`);const m=Ie(p,t,d,h);p.write(`${u}[${l}] = ${m};`)}),f.write("} else {"),f.indented(p=>{if(Es(d)){p.write(`${u}.length = ${l};`);return}const h=P(t),m=P(t);p.write(`const ${h} = undefined;`),p.write(`const ${m} = (() => {`),p.indented(y=>{const $=Ie(y,t,d,h);y.write(`return ${$};`)}),p.write("})();"),p.write(`if (${m} === INVALID || ${m} === undefined) ${u}.length = ${l};`),p.write(`else ${u}[${l}] = ${m};`)}),f.write("}")}),e.write("}");else{const f=P(t);e.write(`const ${f} = ${r}[${l}];`);const p=Ie(e,t,d,f);e.write(`${u}[${l}] = ${p};`)}}if(s){const l=P(t),d=P(t);e.write(`for (let ${l} = ${i.length}; ${l} < ${r}.length; ${l}++) {`),e.indented(f=>{f.write(`const ${d} = ${r}[${l}];`);const p=Ie(f,t,s,d);f.write(`${u}[${l}] = ${p};`)}),e.write("}")}return u}function id(e,t){for(let n=e.length-1;n>=0;n--)if(!(t==="optin"?e[n]._zod.optin!==void 0:e[n]._zod.optout==="optional"))return n+1;return 0}function Zb(e,t,n,r){const o=n._zod.def,i=o.options;if(o.discriminator)return jb(e,t,o,r);if(o.inclusive===!1)throw new B("exclusive unions (z.xor)");if(i.length===0)return e.write("return INVALID;"),r;if(i.length===1)return se(e,t,i[0],r);if(i.every(c=>c._zod.def.type==="literal"&&!c._zod.def.checks?.length)){const c=new Set(i.flatMap(l=>l._zod.def.values)),u=R(t,c);return e.write(`if (!${u}.has(${r})) return INVALID;`),r}const a=P(t);e.write(`let ${a};`);for(let c=0;c<i.length;c++){const u=i[c];c===0?e.write(`${a} = (() => {`):e.write(`if (${a} === INVALID) ${a} = (() => {`),e.indented(l=>{const d=se(l,t,u,r);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function jb(e,t,n,r){if(n.unionFallback)throw new B("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),r;const o=P(t),i=P(t);e.write(`const ${o} = ${r}?.[${De(n.discriminator)}];`),e.write(`let ${i};`);let s=!0;const a=new Set;for(const c of n.options){const u=c._zod.propValues?.[n.discriminator];if(!u||u.size===0)throw new B("discriminated union option without static discriminator values");for(const f of u){if(a.has(f))throw new B(`duplicate discriminator value ${String(f)}`);a.add(f)}const l=Array.from(u,f=>Fb(t,o,f)),d=s?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{const p=se(f,t,c,r);f.write(`${i} = ${p};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),i}function Fb(e,t,n){if(typeof n=="string")return`${t} === ${De(n)}`;if(typeof n=="number")return Number.isNaN(n)?`Number.isNaN(${t})`:`${t} === ${n}`;if(typeof n=="boolean")return`${t} === ${n}`;if(n===null)return`${t} === null`;if(n===void 0)return`${t} === undefined`;if(typeof n=="bigint")return`${t} === ${n}n`;if(typeof n=="symbol"){const r=R(e,n);return`${t} === ${r}`}throw new B(`literal discriminator value ${String(n)}`)}function Ub(e,t,n,r){const o=n._zod.def;t.definite=!1;const i=Ie(e,t,o.left,r),s=Ie(e,t,o.right,r),a=R(t,Vn),c=P(t);return e.write(`const ${c} = ${a}(${i}, ${s});`),e.write(`if (!${c}.valid) return INVALID;`),`${c}.data`}function Vb(e,t,n,r){const o=n._zod.def,i=R(t,ct);e.write(`if (!${i}(${r})) return INVALID;`);const s=P(t),a=P(t),c=P(t);e.write(`const ${s} = {};`);const u=o,l=u.partial?void 0:o.keyType._zod.values;if(l){const p=[];for(const m of l){if(!(typeof m=="string"||typeof m=="number"||typeof m=="symbol"))throw new B(`record key value ${String(m)}`);const y=typeof m=="number"?m.toString():m;if(y==="__proto__")throw new B('record key "__proto__"');p.push(y);const $=R(t,m),w=se(e,t,o.keyType,$),S=P(t);e.write(`const ${S} = ${r}[${qb(t,y)}];`);const T=Ie(e,t,o.valueType,S);e.write(`${s}[${w}] = ${T};`)}const h=R(t,new Set(p));return e.write(`for (const ${a} in ${r}) {`),e.indented(m=>{m.write(`if (${h}.has(${a})) continue;`),u.mode==="loose"?m.write(`if (${a} !== "__proto__") ${s}[${a}] = ${r}[${a}];`):m.write("return INVALID;")}),e.write("}"),s}const d=o.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){const p=o.mode==="loose",h=ti(o.keyType);h.definite===!1&&(t.definite=!1);const m=R(t,h),y=R(t,ln),$=P(t);return sd(e,t,r,a,w=>{w.write(`let ${$} = ${m}(${a});`),w.write(`if (${$} === INVALID && typeof ${a} === "string" && ${y}.test(${a})) ${$} = ${m}(Number(${a}));`),p?w.write(`if (${$} === INVALID) { ${s}[${a}] = ${r}[${a}]; continue; }`):w.write(`if (${$} === INVALID) return INVALID;`),w.write(`if (${$} === "__proto__") continue;`);const S=P(t);w.write(`const ${S} = ${r}[${a}];`);const T=Ie(w,t,o.valueType,S);w.write(`${s}[${$}] = ${T};`)}),s}return sd(e,t,r,a,p=>{p.write(`const ${c} = ${r}[${a}];`);const h=Ie(p,t,o.valueType,c);p.write(`${s}[${a}] = ${h};`)},"return INVALID;"),s}function sd(e,t,n,r,o,i){const s=R(t,Object.prototype.propertyIsEnumerable),a=P(t),c=P(t),u=P(t);e.write(`const ${a} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${c} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${u} = 0; ${u} < ${c}.length; ${u}++) {`),e.indented(l=>{l.write(`const ${r} = ${c}[${u}];`),l.write(`if (${r} === "__proto__" || !${s}.call(${n}, ${r})) continue;`),o(l)}),e.write("}"),e.write(`for (let ${u} = 0; ${u} < ${a}.length; ${u}++) {`),e.indented(l=>{l.write(`const ${r} = ${a}[${u}];`),l.write(`if (!${s}.call(${n}, ${r})) continue;`),i?l.write(i):o(l)}),e.write("}")}function qb(e,t){return typeof t=="string"?De(t):R(e,t)}function Hb(e,t,n,r){const o=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`);const i=P(t),s=P(t),a=P(t);return e.write(`const ${i} = new Map();`),e.write(`for (const [${s}, ${a}] of ${r}) {`),e.indented(c=>{const u=se(c,t,o.keyType,s),l=se(c,t,o.valueType,a);c.write(`${i}.set(${u}, ${l});`)}),e.write("}"),i}function Bb(e,t,n,r){const o=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`);const i=P(t),s=P(t);return e.write(`const ${i} = new Set();`),e.write(`for (const ${s} of ${r}) {`),e.indented(a=>{const c=se(a,t,o.valueType,s);a.write(`${i}.add(${c});`)}),e.write("}"),i}function Kb(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function Jb(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);const o=n._zod.pattern;if(o){const i=R(t,o);e.write(`${i}.lastIndex = 0;`),e.write(`if (!${i}.test(${r})) return INVALID;`)}return r}function Wb(e,t,n,r){const o=n._zod.def,i=Dt(t,o.getter),s=R(t,{parser:null});e.write(`if (!${s}.parser) {`),e.indented(c=>{c.write(`const inner = ${i}();`),c.write(`${s}.parser = function(input) {`),c.indented(u=>{u.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),u.write("return result.issues.length === 0 ? result.value : INVALID;")}),c.write("};")}),e.write("}");const a=P(t);return e.write(`const ${a} = ${s}.parser(${r});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function Gb(e,t,n,r){const o=n._zod.def,i=se(e,t,o.in,r);if(o.transform){if(Zt(o.transform))throw new dt("z.compile: async transforms in pipes are not supported");const s=o.transform,c=Dt(t,l=>{const d={value:l,issues:[],addIssue:Ka},f=s(l,d);return f instanceof Promise?Ce:d.issues.length===0?f:Ce}),u=P(t);return e.write(`const ${u} = ${c}(${i});`),e.write(`if (${u} === INVALID) return INVALID;`),se(e,t,o.out,u)}else return se(e,t,o.out,i)}function Zt(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function Yb(e,t,n,r){const o=n._zod.def;if(o.fn){if(Zt(o.fn))throw new dt("z.compile: async custom predicates are not supported");const i=Dt(t,o.fn),s=R(t,Ts),a=P(t);e.write(`const ${a} = ${i}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`)}else throw new B("custom schema without a predicate function");return r}function Qb(e,t,n){const r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then=="function")return Ce;const o=r;return o.issues.length===0?o.value:t()}function Xb(e,t,n,r){const o=n._zod.def;if(!o.catchValue[Gs])throw new B("catch with a callback (only a constant catch value compiles)",!1);const i=P(t);e.write(`let ${i} = (() => {`),e.indented(u=>{const l=Ie(u,t,o.innerType,r);u.write(`return ${l};`)}),e.write("})();");const s=R(t,o.innerType),a=Dt(t,o.catchValue),c=R(t,Qb);return e.write(`if (${i} === INVALID) {`),e.indented(u=>{u.write(`${i} = ${c}(${s}, ${a}, ${r});`),u.write(`if (${i} === INVALID) return INVALID;`)}),e.write("}"),i}function ew(e,t,n,r){const o=n._zod.def;if(o.transform){if(Zt(o.transform))throw new dt("z.compile: async transforms are not supported");const i=o.transform,a=Dt(t,u=>{const l={value:u,issues:[],addIssue:Ka},d=i(u,l);return d instanceof Promise?Ce:l.issues.length===0?d:Ce}),c=P(t);return e.write(`const ${c} = ${a}(${r});`),e.write(`if (${c} === INVALID) return INVALID;`),c}return r}function ni(e){return e.checks&&(e.checks=[...e.checks]),e}function Bh(e,t){return new e(ni({type:"string",...I(t)}))}function Kh(e,t){return new e(ni({type:"string",coerce:!0,...I(t)}))}function Ja(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...I(t)})}function Wa(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...I(t)})}function Ga(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...I(t)})}function Ya(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...I(t)})}function Qa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...I(t)})}function Xa(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...I(t)})}function ri(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...I(t)})}function ec(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...I(t)})}function tc(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...I(t)})}function nc(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...I(t)})}function rc(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...I(t)})}function oc(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...I(t)})}function ic(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...I(t)})}function sc(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...I(t)})}function ac(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...I(t)})}function cc(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...I(t)})}function Jh(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...I(t)})}function uc(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...I(t)})}function lc(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...I(t)})}function dc(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...I(t)})}function fc(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...I(t)})}function pc(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...I(t)})}function Wh(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...I(t)})}function Gh(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...I(t)})}function hc(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...I(t)})}const mc={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function gc(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...I(t)})}function yc(e,t){return new e({type:"string",format:"date",check:"string_format",...I(t)})}function _c(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...I(t)})}function bc(e,t){return new e({type:"string",format:"duration",check:"string_format",...I(t)})}function Yh(e,t){return new e(ni({type:"number",checks:[],...I(t)}))}function Qh(e,t){return new e(ni({type:"number",coerce:!0,checks:[],...I(t)}))}function Xh(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...I(t)})}function em(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...I(t)})}function tm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...I(t)})}function nm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...I(t)})}function rm(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...I(t)})}function om(e,t){return new e({type:"boolean",...I(t)})}function im(e,t){return new e({type:"boolean",coerce:!0,...I(t)})}function sm(e,t){return new e({type:"bigint",...I(t)})}function am(e,t){return new e({type:"bigint",coerce:!0,...I(t)})}function cm(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...I(t)})}function um(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...I(t)})}function lm(e,t){return new e({type:"symbol",...I(t)})}function dm(e,t){return new e({type:"undefined",...I(t)})}function fm(e,t){return new e({type:"null",...I(t)})}function pm(e){return new e({type:"any"})}function hm(e){return new e({type:"unknown"})}function mm(e,t){return new e({type:"never",...I(t)})}function gm(e,t){return new e({type:"void",...I(t)})}function ym(e,t){return new e({type:"date",...I(t)})}function _m(e,t){return new e({type:"date",coerce:!0,...I(t)})}function bm(e,t){return new e({type:"nan",...I(t)})}function ft(e,t){return new ya({check:"less_than",...I(t),value:e,inclusive:!1})}function Ze(e,t){return new ya({check:"less_than",...I(t),value:e,inclusive:!0})}function pt(e,t){return new _a({check:"greater_than",...I(t),value:e,inclusive:!1})}function je(e,t){return new _a({check:"greater_than",...I(t),value:e,inclusive:!0})}function oi(e){return pt(0,e)}function ii(e){return ft(0,e)}function si(e){return Ze(0,e)}function ai(e){return je(0,e)}function jt(e,t){return new op({check:"multiple_of",...I(t),value:e})}function qt(e,t){return new ap({check:"max_size",...I(t),maximum:e})}function ht(e,t){return new cp({check:"min_size",...I(t),minimum:e})}function dn(e,t){return new up({check:"size_equals",...I(t),size:e})}function fn(e,t){return new lp({check:"max_length",...I(t),maximum:e})}function St(e,t){return new dp({check:"min_length",...I(t),minimum:e})}function pn(e,t){return new fp({check:"length_equals",...I(t),length:e})}function cr(e,t){return new pp({check:"string_format",format:"regex",...I(t),pattern:e})}function ur(e){return new hp({check:"string_format",format:"lowercase",...I(e)})}function lr(e){return new mp({check:"string_format",format:"uppercase",...I(e)})}function dr(e,t){return new gp({check:"string_format",format:"includes",...I(t),includes:e})}function fr(e,t){return new yp({check:"string_format",format:"starts_with",...I(t),prefix:e})}function pr(e,t){return new _p({check:"string_format",format:"ends_with",...I(t),suffix:e})}function ci(e,t,n){return new bp({check:"property",property:e,schema:t,...I(n)})}function hr(e,t){return new wp({check:"properties",shape:e,...I(t)})}function mr(e,t){return new vp({check:"mime_type",mime:e,...I(t)})}function tt(e){return new kp({check:"overwrite",tx:e})}function gr(e){return tt(t=>t.normalize(e))}function yr(){return tt(e=>e.trim())}function _r(){return tt(e=>e.toLowerCase())}function br(){return tt(e=>e.toUpperCase())}function wr(){return tt(e=>Xd(e))}function wm(e,t,n){return new e({type:"array",element:t,...I(n)})}function tw(e,t,n){return new e({type:"union",options:t,...I(n)})}function nw(e,t,n){return new e({type:"union",options:t,inclusive:!1,...I(n)})}function rw(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...I(r)})}function ow(e,t,n){return new e({type:"intersection",left:t,right:n})}function iw(e,t,n,r){const o=n instanceof D,i=o?r:n,s=o?n:null;return new e({type:"tuple",items:t,rest:s,...I(i)})}function sw(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...I(r)})}function aw(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...I(r)})}function cw(e,t,n){return new e({type:"set",valueType:t,...I(n)})}function uw(e,t,n){const r=Array.isArray(t)?Object.fromEntries(t.map(o=>[o,o])):t;return new e({type:"enum",entries:r,...I(n)})}function lw(e,t,n){return new e({type:"enum",entries:t,...I(n)})}function dw(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...I(n)})}function vm(e,t){return new e({type:"file",...I(t)})}function fw(e,t){return new e({type:"transform",transform:t})}function pw(e,t){return new e({type:"optional",innerType:t})}function hw(e,t){return new e({type:"nullable",innerType:t})}function mw(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():Yn(n)}})}function gw(e,t,n){return new e({type:"nonoptional",innerType:t,...I(n)})}function yw(e,t){return new e({type:"success",innerType:t})}function _w(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:Ys(n)})}function bw(e,t,n){return new e({type:"pipe",in:t,out:n})}function ww(e,t){return new e({type:"readonly",innerType:t})}function vw(e,t,n){return new e({type:"template_literal",parts:t,...I(n)})}function kw(e,t){return new e({type:"lazy",getter:t})}function $w(e,t){return new e({type:"promise",innerType:t})}function km(e,t,n){const r=I(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function $m(e,t,n){return new e({type:"custom",check:"custom",fn:t,...I(n)})}function Sm(e,t){const n=Im(r=>(r.addIssue=o=>{if(typeof o=="string")r.issues.push(Qt(o,r.value,n._zod.def));else{const i=o;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),"input"in i||(i.input=r.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),r.issues.push(Qt(i))}},e(r.value,r)),t);return n}function Im(e,t){const n=new ie({check:"custom",...I(t)});return n._zod.check=e,n}function xm(e){const t=new ie({check:"describe"});return t._zod.onattach=[n=>{const r=Le.get(n)??{};Le.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function zm(e){const t=new ie({check:"meta"});return t._zod.onattach=[n=>{const r=Le.get(n)??{};Le.add(n,{...r,...e})}],t._zod.check=()=>{},t}function Tm(e,t){const n=I(t);let r=n.truthy??["true","1","yes","on","y","enabled"],o=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(r=r.map(p=>typeof p=="string"?p.toLowerCase():p),o=o.map(p=>typeof p=="string"?p.toLowerCase():p));const i=new Set(r),s=new Set(o),a=e.Codec??Za,c=e.Boolean??Oa,u=e.String??ar,l=new u({type:"string",error:n.error}),d=new c({type:"boolean",error:n.error}),f=new a({type:"pipe",in:l,out:d,transform:((p,h)=>{let m=p;return n.case!=="sensitive"&&(m=m.toLowerCase()),i.has(m)?!0:s.has(m)?!1:(h.issues.push({code:"invalid_value",expected:"stringbool",values:[...i,...s],input:h.value,inst:f,continue:!1}),{})}),reverseTransform:((p,h)=>p===!0?r[0]||"true":o[0]||"false"),error:n.error});return f._zod.bag.truthy=r,f._zod.bag.falsy=o,f._zod.bag.case=n.case??"insensitive",f}function hn(e,t,n,r={}){const o=I(r),i={check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:a=>n.test(a),...o};return n instanceof RegExp&&(i.pattern=n),new e(i)}function jn(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&Fe(e,r,n[r]);return e}function en(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??Le,target:t,unrepresentable:e?.unrepresentable??"throw",override:e?.override??(()=>{}),io:e?.io??"output",counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??"ref",reused:e?.reused??"inline",intersections:[],deferred:[],external:e?.external??void 0}}function ye(e,t,n,r,o){const i=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:o}):t.unrepresentable;if(i==="any")return!1;if(i===void 0||i==="throw")throw new Error(o);return Object.assign(n,i),!0}function te(e,t,n={path:[],schemaPath:[]}){var r;const o=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const l={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,l);else{const f=s.schema,p=t.processors[o.type];if(!p)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${o.type}`);p(e,t,f,l)}const d=e._zod.parent;d&&(s.ref||(s.ref=d),te(d,t,l),t.seen.get(d).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&jn(s.schema,c),t.io==="input"&&ze(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((r=s.schema).default??(r.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function ad(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function tn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");if(e.external&&e.sharedDefsExtractedFor===e.external)return;const r=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=r.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(a,s[0])}}const o=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const d=e.external.registry.get(s[0])?.id,f=e.external.uri??(h=>h);if(d)return{ref:f(d)};const p=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=p,{defId:p,ref:`${f("__shared")}#/${a}/${ad(p)}`}}const c="#",u=`${c}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:c};const l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:u+ad(l)}},i=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:u}=o(s);a.def={...a.schema},u&&(a.defId=u);const l=a.schema;for(const d in l)delete l[d];l.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
69
69
 
70
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){i(s);continue}if(e.external){const u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}a.count>1&&e.reused==="ref"&&i(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function cm(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;cm(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const i=r.type;for(const s of Array.isArray(i)?i:[i]){if(typeof s!="string")return;n.includes(s)||n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const um=new Set(["type","properties","required","additionalProperties"]),Yl=["oneOf","anyOf"];function Ql(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function ws(e){const t=[];for(const i of e){if(typeof i!="object"||i.type!=="object")return null;for(const s in i)if(!um.has(s))return null;t.push(i)}const n={},r=new Set;for(const i of t){for(const s in i.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;const a=[];for(const u of t){const l=u.properties?.[s]??Ql(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}const c=a.length===1?a[0]:ws(a)??{allOf:a};Re(n,s,c)}for(const s of i.required??[])r.add(s)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(i=>i.additionalProperties===!1))o.additionalProperties=!1;else{const i=[];for(const s of t){const a=Ql(s);a&&!i.some(c=>JSON.stringify(c)===JSON.stringify(a))&&i.push(a)}i.length===1?o.additionalProperties=i[0]:i.length>1&&(o.additionalProperties={allOf:i})}return o}function Vb(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of um)if(o in e)return;const n=t.filter(o=>Yl.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=ws(t);else{const o=n[0],i=Yl.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;const s=t.filter(c=>c!==o),a=o[i].map(c=>ws([...s,c]));if(a.some(c=>!c))return;r={[i]:a}}r&&(delete e.allOf,An(e,r))}function Xt(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){r(d);const p=e.seen.get(d),h=p.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):An(u,h),An(u,l),a._zod.parent===d)for(const k in u)k==="$ref"||k==="allOf"||k in l||delete u[k];if(h.$ref&&p.def)for(const k in u)k==="$ref"||k==="allOf"||k in p.def&&JSON.stringify(u[k])===JSON.stringify(p.def[k])&&delete u[k]}const f=a._zod.parent;if(f&&f!==d){r(f);const p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(const h in u)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(u[h])===JSON.stringify(p.def[h])&&delete u[h]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(const a of e.seen.entries())cm(a[1].def??a[1].schema);for(const a of e.deferred)a();if(e.intersections.length){const a=new Map;for(const c of e.seen.values())for(const u of[c.schema,c.def]){const l=u?.allOf;if(!Array.isArray(l))continue;const d=a.get(l);d?d.push(u):a.set(l,[u])}for(const c of e.intersections)for(const u of a.get(c)??[])Vb(u)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$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");o.$id=e.external.uri(a)}An(o,n.defId?n.schema:n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Re(s,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Zn(t,"input",e.processors),output:Zn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function Se(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return Se(r.element,n);if(r.type==="set")return Se(r.valueType,n);if(r.type==="lazy")return Se(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return Se(r.innerType,n);if(r.type==="intersection")return Se(r.left,n)||Se(r.right,n);if(r.type==="record"||r.type==="map")return Se(r.keyType,n)||Se(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:Se(r.in,n)||Se(r.out,n);if(r.type==="object"){for(const o in r.shape)if(Se(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(Se(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(Se(o,n))return!0;return!!(r.rest&&Se(r.rest,n))}return!1}const lm=(e,t={})=>n=>{const r=Yt({...n,processors:t});return ee(e,r),Qt(r,e),Xt(r,e)},Zn=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=Yt({...o??{},target:i,io:t,processors:n});return ee(e,s),Qt(s,e),Xt(s,e)},en=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},tn=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Xl=(e,t)=>{en(e,"minimum",t),tn(e,"maximum",t)},dm=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},fm=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},pm=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},hm=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},ed=(e,t)=>en(e,"minimum",t.minimum),td=(e,t)=>tn(e,"maximum",t.maximum),nd=e=>(t,n)=>{hm(t,n.format);const[r,o]=e[n.format];en(t,"minimum",r),tn(t,"maximum",o)},qb={greater_than:(e,t)=>en(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>tn(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>dm(e,t.value),number_format:nd(Ms),bigint_format:nd(Rs),min_length:ed,max_length:td,length_equals:(e,t)=>Xl(e,t.length),min_size:ed,max_size:td,size_equals:(e,t)=>Xl(e,t.size),string_format:(e,t)=>{hm(e,t.format),t.pattern&&fm(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>pm(e,t.mime)};function ge(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const i of r)qb[i._zod.def.check]?.(t,i._zod.def);const o=e._zod.bag;o.minimum!==void 0&&en(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&en(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&tn(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&tn(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&dm(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&pm(t,o.mime);for(const i of o.patterns??[])fm(t,i);return t}const Hb={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Bb=new Map([[ha,_f],[Uo,bf]]),mm=e=>Bb.get(e)??e,gm=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=ge(e);if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=Hb[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c].map(mm);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},ym=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=ge(e);o.type=l?"integer":"number";const d=typeof u=="number"&&u>=(i??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(s??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof i=="number"&&(o.minimum=i),f?p?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof s=="number"&&(o.maximum=s),a){const h=new Set;for(const I of a)Number.isFinite(I)&&I!==0?h.add(Math.abs(I)):ye(e,t,o,r,`A multipleOf divisor of ${I} cannot be represented in JSON Schema`);const[m,...k]=h;m!==void 0&&(o.multipleOf=m),k.length&&(o.allOf=[...o.allOf??[],...k.map(I=>({multipleOf:I}))])}},_m=(e,t,n,r)=>{n.type="boolean"},bm=(e,t,n,r)=>{ye(e,t,n,r,"BigInt cannot be represented in JSON Schema")},wm=(e,t,n,r)=>{ye(e,t,n,r,"Symbols cannot be represented in JSON Schema")},vm=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},km=(e,t,n,r)=>{ye(e,t,n,r,"Undefined cannot be represented in JSON Schema")},$m=(e,t,n,r)=>{ye(e,t,n,r,"Void cannot be represented in JSON Schema")},Sm=(e,t,n,r)=>{n.not={}},Im=(e,t,n,r)=>{},zm=(e,t,n,r)=>{},xm=(e,t,n,r)=>{ye(e,t,n,r,"Date cannot be represented in JSON Schema")},Tm=(e,t,n,r)=>{const o=e._zod.def,i=go(o.entries);if(i.length===0){n.not={};return}i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},Cm=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return}const i=[];for(const s of o.values)if(s===void 0){if(ye(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(ye(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){const s=i[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),i.every(s=>typeof s=="boolean")&&(n.type="boolean"),i.every(s=>s===null)&&(n.type="null"),n.enum=i},Em=(e,t,n,r)=>{ye(e,t,n,r,"NaN cannot be represented in JSON Schema")},Nm=(e,t,n,r)=>{const o=n,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},Om=(e,t,n,r)=>{const o=n;o.type="string",o.format="binary",o.contentEncoding="binary";const{minimum:i,maximum:s,mime:a}=ge(e);i!==void 0&&(o.minLength=i),s!==void 0&&(o.maxLength=s),a&&(a.length===0?o.not={}:a.length===1?o.contentMediaType=a[0]:o.anyOf=a.map(c=>({contentMediaType:c})))},Pm=(e,t,n,r)=>{n.type="boolean"},Am=(e,t,n,r)=>{ye(e,t,n,r,"Custom types cannot be represented in JSON Schema")},Mm=(e,t,n,r)=>{ye(e,t,n,r,"Function types cannot be represented in JSON Schema")},Rm=(e,t,n,r)=>{ye(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Lm=(e,t,n,r)=>{ye(e,t,n,r,"Map cannot be represented in JSON Schema")},Zm=(e,t,n,r)=>{ye(e,t,n,r,"Set cannot be represented in JSON Schema")},Dm=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=ge(e);typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=ee(i.element,t,{...r,path:[...r.path,"items"]})};function Dn(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Dn(t.out):t.type==="catch"?Dn(t.innerType):e._zod.optin}const jm=(e,t,n,r)=>{const o=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&ye(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const u in s)Re(o.properties,u,ee(s[u],t,{...r,path:[...r.path,"properties",u]}));const c=[];for(const u of Object.keys(s)){const l=i.shape[u];(t.io==="input"?Dn(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=ee(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},ac=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>ee(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s},Fm=(e,t,n,r)=>{const o=e._zod.def,i=ee(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=ee(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)},Um=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((m,k)=>ee(m,t,{...r,path:[...r.path,s,k]})),u=i.rest?ee(i.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;let l=i.items.length;for(;l>0;){const m=i.items[l-1];if(!(t.io==="input"?Dn(m)!==void 0:m._zod.optout==="optional"))break;l--}const d=i.items.length,f=!i.rest;t.target==="draft-2020-12"?(o.prefixItems=c,f?o.items=!1:u&&(o.items=u),l>0&&(o.minItems=l),f&&(o.maxItems=d)):t.target==="openapi-3.0"?(o.items={anyOf:c},u&&o.items.anyOf.push(u),l>0&&(o.minItems=l),f&&(o.maxItems=d)):(o.items=c,f?o.additionalItems=!1:u&&(o.additionalItems=u),l>0&&(o.minItems=l),f&&(o.maxItems=d));const{minimum:p,maximum:h}=ge(e);typeof p=="number"&&(o.minItems=p),typeof h=="number"&&(o.maxItems=h)};function vs(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);const h=e.get(t)?.def;if(!h)return t;const m=vs(e,h,n);return m===h?t:m}for(const h of["anyOf","oneOf"]){const m=t[h];if(!Array.isArray(m))continue;const k=m.map(I=>vs(e,I,n));k.some((I,v)=>I!==m[v])&&(t={...t,[h]:k})}const r=Array.isArray(t.type)?t.type:[t.type],o=!r.includes("string")&&r.some(h=>h==="number"||h==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some(h=>typeof h=="number"))return t;const{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(h=>typeof h=="number"?String(h):h):typeof p.const=="number"&&(p.const=String(p.const)),o&&(p.type="string",i||(p.pattern=(r.includes("number")?an:ta).source)),p}const ks=new WeakMap;function Kb(e){const t=new Map;for(const r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);const n=new Map;for(const r of ks.get(e)??[]){const o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||n.has(i))continue;const s=vs(t,i,new Set);s!==i&&n.set(i,s)}if(n.size)for(const r of e.seen.values())for(const o of[r.schema,r.def]){const i=o&&n.get(o.propertyNames);i&&(o.propertyNames=i)}}const Vm=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,a=ge(s).patterns;if(i.mode==="loose"&&a&&a.size>0){const l=ee(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const d of a)Re(o.patternProperties,mm(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=ee(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});let l=ks.get(t);l||(l=[],ks.set(t,l),t.deferred.push(()=>Kb(t))),l.push(e)}o.additionalProperties=ee(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const c=s._zod.values,u=t.io==="input"&&Dn(i.valueType)!==void 0;if(c&&!i.partial&&!u){const l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},qm=(e,t,n,r)=>{const o=e._zod.def,i=ee(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Hm=(e,t,n,r)=>{const o=e._zod.def;ee(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},cc=Symbol();function Bm(e,t,n,r,o){let i=!1;const s=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(i=!0,null));return i?(ye(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),cc):JSON.parse(s)}const Km=(e,t,n,r)=>{const o=e._zod.def;ee(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const s=Bm(o.defaultValue,e,t,n,r);s!==cc&&(n.default=s)},Jm=(e,t,n,r)=>{const o=e._zod.def;ee(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const s=Bm(o.defaultValue,e,t,n,r);s!==cc&&(n._prefault=s)},Wm=(e,t,n,r)=>{const o=e._zod.def;ee(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{ye(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},Gm=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;ee(s,t,r);const a=t.seen.get(e);a.ref=s},Ym=(e,t,n,r)=>{const o=e._zod.def;ee(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},Qm=(e,t,n,r)=>{const o=e._zod.def;ee(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},uc=(e,t,n,r)=>{const o=e._zod.def;ee(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},Xm=(e,t,n,r)=>{const o=e._zod.innerType;ee(o,t,r);const i=t.seen.get(e);i.ref=o},$s={string:gm,number:ym,boolean:_m,bigint:bm,symbol:wm,null:vm,undefined:km,void:$m,never:Sm,any:Im,unknown:zm,date:xm,enum:Tm,literal:Cm,nan:Em,template_literal:Nm,file:Om,success:Pm,custom:Am,function:Mm,transform:Rm,map:Lm,set:Zm,array:Dm,object:jm,union:ac,intersection:Fm,tuple:Um,record:Vm,nullable:qm,nonoptional:Hm,default:Km,prefault:Jm,catch:Wm,pipe:Gm,readonly:Ym,promise:Qm,optional:uc,lazy:Xm};function lc(e,t){if("_idmap"in e){const r=e,o=Yt({...t,processors:$s}),i={};for(const c of r._idmap.entries()){const[u,l]=c;ee(l,o)}const s={},a={registry:r,uri:t?.uri,defs:i};o.external=a;for(const c of r._idmap.entries()){const[u,l]=c;Qt(o,l),Re(s,u,Xt(o,l))}if(Object.keys(i).length>0){const c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}const n=Yt({...t,processors:$s});return ee(e,n),Qt(n,e),Xt(n,e)}class Jb{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 n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=Yt({processors:$s,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return ee(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,Qt(this.ctx,t);const r=Xt(this.ctx,t),{"~standard":o,...i}=r;return i}}const Wb=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),eg=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:Lp,$ZodArray:Up,$ZodAsyncError:tt,$ZodBase64:Ip,$ZodBase64URL:zp,$ZodBigInt:va,$ZodBigIntFormat:Pp,$ZodBoolean:wa,$ZodCIDRv4:$p,$ZodCIDRv6:Sp,$ZodCUID:dp,$ZodCUID2:fp,$ZodCatch:lh,$ZodCheck:ie,$ZodCheckBigIntFormat:Df,$ZodCheckEndsWith:Yf,$ZodCheckGreaterThan:ia,$ZodCheckIncludes:Wf,$ZodCheckLengthEquals:Hf,$ZodCheckLessThan:oa,$ZodCheckLowerCase:Kf,$ZodCheckMaxLength:Vf,$ZodCheckMaxSize:jf,$ZodCheckMimeType:ep,$ZodCheckMinLength:qf,$ZodCheckMinSize:Ff,$ZodCheckMultipleOf:Lf,$ZodCheckNumberFormat:Zf,$ZodCheckOverwrite:tp,$ZodCheckProperties:Xf,$ZodCheckProperty:Qf,$ZodCheckRegex:Bf,$ZodCheckSizeEquals:Uf,$ZodCheckStartsWith:Gf,$ZodCheckStringFormat:er,$ZodCheckUpperCase:Jf,$ZodCodec:za,$ZodCreditCard:Tp,$ZodCustom:yh,$ZodCustomStringFormat:Np,$ZodCyclicError:_h,$ZodDate:Fp,$ZodDefault:sh,$ZodDiscriminatedUnion:Wp,$ZodE164:xp,$ZodEmail:sp,$ZodEmoji:up,$ZodEncodeError:Po,$ZodEnum:eh,$ZodError:Gd,$ZodExactOptional:oh,$ZodFile:nh,$ZodFunction:mh,$ZodGUID:op,$ZodIBAN:Cp,$ZodIPv4:wp,$ZodIPv6:vp,$ZodISODate:yp,$ZodISODateTime:gp,$ZodISODuration:bp,$ZodISOTime:_p,$ZodIntersection:Gp,$ZodJWT:Ep,$ZodKSUID:mp,$ZodLazy:xa,$ZodLiteral:th,$ZodMAC:kp,$ZodMap:Qp,$ZodNaN:dh,$ZodNanoID:lp,$ZodNever:Dp,$ZodNonOptional:ch,$ZodNull:Rp,$ZodNullable:ih,$ZodNumber:ba,$ZodNumberFormat:Op,$ZodObject:Hp,$ZodObjectJIT:Bp,$ZodOptional:Sa,$ZodPipe:Ia,$ZodPrefault:ah,$ZodPreprocess:fh,$ZodPromise:gh,$ZodReadonly:ph,$ZodRealError:Le,$ZodRecord:Yp,$ZodRegistry:vh,$ZodSet:Xp,$ZodString:tr,$ZodStringFormat:te,$ZodSuccess:uh,$ZodSymbol:Ap,$ZodTemplateLiteral:hh,$ZodTransform:rh,$ZodTuple:$a,$ZodType:L,$ZodULID:pp,$ZodURL:cp,$ZodUUID:ip,$ZodUndefined:Mp,$ZodUnion:Vo,$ZodUnknown:Zp,$ZodVoid:jp,$ZodXID:hp,$ZodXor:Kp,$brand:Fs,$constructor:g,$input:Oa,$output:Na,Doc:sa,INVALID:xe,JSONSchema:Wb,JSONSchemaGenerator:Jb,NEVER:js,TimePrecision:nc,URL_BAD_FORMAT:ca,URL_UNPARSEABLE:Rn,ZodCompileAsyncError:st,ZodCompileUnsupportedError:H,_any:Bh,_array:Xh,_base64:Qa,_base64url:Xa,_bigint:Dh,_boolean:Lh,_catch:Lb,_check:om,_cidrv4:Ga,_cidrv6:Ya,_coercedBigint:jh,_coercedBoolean:Zh,_coercedDate:Yh,_coercedNumber:Nh,_coercedString:zh,_creditCard:Th,_cuid:Va,_cuid2:qa,_custom:tm,_date:Gh,_decode:Hs,_decodeAsync:Ks,_default:Ab,_discriminatedUnion:kb,_e164:ec,_email:Ma,_emoji:Fa,_encode:qs,_encodeAsync:Bs,_endsWith:ar,_enum:Tb,_file:em,_float32:Ph,_float64:Ah,_gt:ct,_gte:Me,_guid:Ra,_iban:Ch,_includes:ir,_int:Oh,_int32:Mh,_int64:Fh,_intersection:$b,_ipv4:Ja,_ipv6:Wa,_isoDate:oc,_isoDateTime:rc,_isoDuration:sc,_isoTime:ic,_jwt:tc,_ksuid:Ka,_lazy:Fb,_length:ln,_literal:Eb,_lowercase:rr,_lt:at,_lte:Ae,_mac:xh,_map:zb,_max:Ae,_maxLength:un,_maxSize:Dt,_mime:ur,_min:Me,_minLength:bt,_minSize:ut,_multipleOf:Mt,_nan:Qh,_nanoid:Ua,_nativeEnum:Cb,_negative:Yo,_never:Jh,_nonnegative:Xo,_nonoptional:Mb,_nonpositive:Qo,_normalize:lr,_null:Hh,_nullable:Pb,_number:Eh,_optional:Ob,_overwrite:Ye,_parse:Jn,_parseAsync:Wn,_pipe:Zb,_positive:Go,_promise:Ub,_properties:cr,_property:ei,_readonly:Db,_record:Ib,_refine:nm,_regex:nr,_safeDecode:Ws,_safeDecodeAsync:Ys,_safeEncode:Js,_safeEncodeAsync:Gs,_safeParse:Gn,_safeParseAsync:Yn,_set:xb,_size:cn,_slugify:hr,_startsWith:sr,_string:Ih,_stringFormat:dn,_stringbool:am,_success:Rb,_superRefine:rm,_symbol:Vh,_templateLiteral:jb,_toLowerCase:fr,_toUpperCase:pr,_transform:Nb,_trim:dr,_tuple:Sb,_uint32:Rh,_uint64:Uh,_ulid:Ha,_undefined:qh,_union:wb,_unknown:Kh,_uppercase:or,_url:Wo,_uuid:La,_uuidv4:Za,_uuidv6:Da,_uuidv7:ja,_void:Wh,_xid:Ba,_xor:vb,base64Charset:ha,base64urlCharset:Uo,canParseURL:ua,clone:oe,compile:Pa,compileFn:Ko,config:me,createStandardJSONSchemaMethod:Zn,createToJSONSchemaMethod:lm,decode:Oy,decodeAsync:Ay,describe:im,encode:Ny,encodeAsync:Py,extractDefs:Qt,finalize:Xt,flattenError:Ao,formatError:Mo,getDiscriminatedOption:ka,globalConfig:ze,globalRegistry:Oe,handleUnrepresentable:ye,initializeContext:Yt,isBackEdge:Ca,isRecursiveSchema:Ta,isValidBase64:Fo,isValidBase64URL:ma,isValidCIDRv6:pa,isValidCreditCard:ga,isValidIBAN:ya,isValidIPv6:jo,isValidJWT:_a,locales:Ea,memoizer:qo,mergeValues:Ln,meta:sm,parse:ps,parseAsync:hs,parseURLObject:ap,prettifyError:Vs,process:ee,processSchema:ee,regexes:Do,registry:Ho,safeDecode:Ry,safeDecodeAsync:Zy,safeEncode:My,safeEncodeAsync:Ly,safeParse:Qd,safeParseAsync:xy,standardProps:aa,stripTabAndNewline:vo,toDotPath:Yd,toJSONSchema:lc,toZod:xo,treeifyError:Us,urlHostnameOk:da,urlProtocolOk:fa,util:Ds,validate:Lo,validateAsync:Zo,validateURL:la,version:np,withParser:Bo},Symbol.toStringTag,{value:"Module"})),rd=Symbol("z.visit/resolving");function dc(e,t){const n=typeof t=="function"?t:(s,a)=>{const c=t[s._zod.def.type];return c?c(s,a):s},r=new Map;function o(s){const a=r.get(s);if(a===rd)return new xa({type:"lazy",getter:()=>r.get(s)});if(a!==void 0)return a;r.set(s,rd);const c=i(s),u=n(c,c!==s);return r.set(s,u),u}function i(s){const a=s._zod.def;switch(a.type){case"object":{const u=a.shape,l=Object.keys(u);let d=!1;const f={};for(const h of l){const m=o(u[h]);m!==u[h]&&(d=!0),f[h]=m}let p=a.catchall;return a.catchall&&(p=o(a.catchall),p!==a.catchall&&(d=!0)),d?oe(s,{...a,shape:f,catchall:p}):s}case"array":{const u=o(a.element);return u===a.element?s:oe(s,{...a,element:u})}case"tuple":{const u=a.items;let l=!1;const d=[];for(const p of u){const h=o(p);h!==p&&(l=!0),d.push(h)}let f=a.rest;return a.rest&&(f=o(a.rest),f!==a.rest&&(l=!0)),l?oe(s,{...a,items:d,rest:f}):s}case"record":case"map":{const u=o(a.keyType),l=o(a.valueType);return u===a.keyType&&l===a.valueType?s:oe(s,{...a,keyType:u,valueType:l})}case"set":{const u=o(a.valueType);return u===a.valueType?s:oe(s,{...a,valueType:u})}case"union":{const u=a.options;let l=!1;const d=[];for(const f of u){const p=o(f);p!==f&&(l=!0),d.push(p)}return l?oe(s,{...a,options:d}):s}case"intersection":{const u=o(a.left),l=o(a.right);return u===a.left&&l===a.right?s:oe(s,{...a,left:u,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{const u=o(a.innerType);return u===a.innerType?s:oe(s,{...a,innerType:u})}case"pipe":{const u=o(a.in),l=o(a.out);return u===a.in&&l===a.out?s:oe(s,{...a,in:u,out:l})}case"function":{const u=o(a.input),l=o(a.output);return u===a.input&&l===a.output?s:oe(s,{...a,input:u,output:l})}case"lazy":{const u=a.getter,{_cachedInner:l,...d}=a;return oe(s,{...d,getter:()=>o(u())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return s;default:return s}}return o(e)}function fc(e){return!!e._zod}function tg(e,t){return fc(e)?Qd(e,t):e.safeParse(t)}function Gb(e){if(!e)return;let t;if(fc(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Yb(e){if(fc(e)){const i=e._zod?.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}const n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const r=e.value;if(r!==void 0)return r}const Qb=()=>{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"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}const n={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",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){return i==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[i]??i}return i=>{switch(i.code){case"invalid_type":{const s=o(i.expected),a=qd(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${As(i.values[0])}`:`Invalid option: expected one of ${ls(i.values,"|")}`;case"too_big":{const s=i.exact?"exactly ":i.inclusive?"<=":"<",a=t(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{const s=i.exact?"exactly ":i.inclusive?">=":">",a=t(i.origin);return a?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{const s=i;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${n[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${ls(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(a=>`'${a}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Xb(){return{localeError:Qb()}}const ew=Object.freeze(Object.defineProperty({__proto__:null,endsWith:ar,gt:ct,gte:Me,includes:ir,length:ln,lowercase:rr,lt:at,lte:Ae,maxLength:un,maxSize:Dt,mime:ur,minLength:bt,minSize:ut,multipleOf:Mt,negative:Yo,nonnegative:Xo,nonpositive:Qo,normalize:lr,overwrite:Ye,positive:Go,properties:cr,property:ei,regex:nr,size:cn,slugify:hr,startsWith:sr,toLowerCase:fr,toUpperCase:pr,trim:dr,uppercase:or},Symbol.toStringTag,{value:"Module"})),od=new WeakSet([Object.prototype,Error.prototype]);function oo(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const ng=(e,t)=>{Gd.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);od.has(n)||(od.add(n),oo(n,"format",r=>o=>Mo(r,o)),oo(n,"flatten",r=>o=>Ao(r,o)),oo(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,yo,2)}),oo(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,yo,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},rg=g("ZodError",ng),Ee=g("ZodError",ng,void 0,{Parent:Error}),pc=Jn(Ee),hc=Wn(Ee),mc=Gn(Ee),gc=Yn(Ee),yc=qs(Ee),_c=Hs(Ee),bc=Bs(Ee),wc=Ks(Ee),vc=Js(Ee),kc=Ws(Ee),$c=Gs(Ee),Sc=Ys(Ee);function tw(){ze.localeError||me(Xb())}function jt(){ze.memoizer||me({memoizer:qo()})}const D=g("ZodType",(e,t)=>(tw(),L.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(ke(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return oe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ui(e,t))},superRefine(e,t){return this.check(Vi(e,t))},overwrite(e){return this.check(Ye(e))},optional(){return ne(this)},exactOptional(){return ki(this)},nullable(){return rn(this)},nullish(){return ne(rn(this))},nonoptional(e){return Ti(this,e)},array(){return A(this)},or(e){return j([this,e])},and(e){return $n(this,e)},transform(e){return Fn(this,Zr(e))},default(e){return Ii(this,e)},prefault(e){return xi(this,e)},catch(e){return Ni(this,e)},pipe(e){return Fn(this,e)},readonly(){return Mi(this)},describe(e){const t=this.clone();return Oe.add(t,{description:e}),t},meta(...e){if(e.length===0)return Oe.get(this);const t=this.clone();return Oe.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return Oo(this,"~standard",{...aa(this),jsonSchema:{input:Zn(this,"input"),output:Zn(this,"output")}})},set"~standard"(e){it(this,"~standard",e)},parse:function e(t,n){return pc(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await hc(this,t,n,{callee:e})},safeParse(e,t){return mc(this,e,t)},async safeParseAsync(e,t){return gc(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){it(this,"spa",e)},validate(e,t){return Lo(this,e,t)},validateAsync(e,t){return Zo(this,e,t)},encode:function e(t,n){return yc(this,t,n,{callee:e})},decode:function e(t,n){return _c(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await bc(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await wc(this,t,n,{callee:e})},safeEncode(e,t){return vc(this,e,t)},safeDecode(e,t){return kc(this,e,t)},async safeEncodeAsync(e,t){return $c(this,e,t)},async safeDecodeAsync(e,t){return Sc(this,e,t)},toJSONSchema(e){return lm(this,{})(e)},get description(){return Oe.get(this)?.description},get _def(){return this._zod.def}}),mr=g("_ZodString",(e,t)=>{tr.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gm(e,n,r)},Kn({format:e=>ge(e).format??null,minLength:e=>ge(e).minimum??null,maxLength:e=>ge(e).maximum??null},{regex(...e){return this.check(nr(...e))},includes(...e){return this.check(ir(...e))},startsWith(...e){return this.check(sr(...e))},endsWith(...e){return this.check(ar(...e))},min(...e){return this.check(bt(...e))},max(...e){return this.check(un(...e))},length(...e){return this.check(ln(...e))},nonempty(...e){return this.check(bt(1,...e))},lowercase(e){return this.check(rr(e))},uppercase(e){return this.check(or(e))},trim(){return this.check(dr())},normalize(...e){return this.check(lr(...e))},toLowerCase(){return this.check(fr())},toUpperCase(){return this.check(pr())},slugify(){return this.check(hr())}})),fn=g("ZodString",(e,t)=>{tr.init(e,t),mr.init(e,t)},{email(e){return this.check(Ma(gr,e))},url(e){return this.check(Wo(yn,e))},jwt(e){return this.check(tc(Or,e))},emoji(e){return this.check(Fa(_r,e))},guid(e){return this.check(Ra(yr,e))},uuid(e){return this.check(La(He,e))},uuidv4(e){return this.check(Za(He,e))},uuidv6(e){return this.check(Da(He,e))},uuidv7(e){return this.check(ja(He,e))},nanoid(e){return this.check(Ua(br,e))},cuid(e){return this.check(Va(wr,e))},cuid2(e){return this.check(qa(vr,e))},ulid(e){return this.check(Ha(kr,e))},base64(e){return this.check(Qa(Cr,e))},base64url(e){return this.check(Xa(Er,e))},xid(e){return this.check(Ba($r,e))},ksuid(e){return this.check(Ka(Sr,e))},ipv4(e){return this.check(Ja(Ir,e))},ipv6(e){return this.check(Wa(zr,e))},cidrv4(e){return this.check(Ga(xr,e))},cidrv6(e){return this.check(Ya(Tr,e))},e164(e){return this.check(ec(Nr,e))},datetime(e){return this.check(rc(pn,e))},date(e){return this.check(oc(hn,e))},time(e){return this.check(ic(mn,e))},duration(e){return this.check(sc(gn,e))}});function y(e){return Ih(fn,e)}const X=g("ZodStringFormat",(e,t)=>{te.init(e,t),mr.init(e,t)}),pn=g("ZodISODateTime",(e,t)=>{gp.init(e,t),X.init(e,t)}),hn=g("ZodISODate",(e,t)=>{yp.init(e,t),X.init(e,t)}),mn=g("ZodISOTime",(e,t)=>{_p.init(e,t),X.init(e,t)}),gn=g("ZodISODuration",(e,t)=>{bp.init(e,t),X.init(e,t)}),gr=g("ZodEmail",(e,t)=>{sp.init(e,t),X.init(e,t)});function Ic(e){return Ma(gr,e)}const yr=g("ZodGUID",(e,t)=>{op.init(e,t),X.init(e,t)});function zc(e){return Ra(yr,e)}const He=g("ZodUUID",(e,t)=>{ip.init(e,t),X.init(e,t)});function xc(e){return La(He,e)}function Tc(e){return Za(He,e)}function Cc(e){return Da(He,e)}function Ec(e){return ja(He,e)}const yn=g("ZodURL",(e,t)=>{cp.init(e,t),X.init(e,t)});function Nc(e){return Wo(yn,e)}function Oc(e){return Wo(yn,{protocol:Qs,hostname:vf,...$(e)})}const _r=g("ZodEmoji",(e,t)=>{up.init(e,t),X.init(e,t)});function Pc(e){return Fa(_r,e)}const br=g("ZodNanoID",(e,t)=>{lp.init(e,t),X.init(e,t)});function Ac(e){return Ua(br,e)}const wr=g("ZodCUID",(e,t)=>{dp.init(e,t),X.init(e,t)});function Mc(e){return Va(wr,e)}const vr=g("ZodCUID2",(e,t)=>{fp.init(e,t),X.init(e,t)});function Rc(e){return qa(vr,e)}const kr=g("ZodULID",(e,t)=>{pp.init(e,t),X.init(e,t)});function Lc(e){return Ha(kr,e)}const $r=g("ZodXID",(e,t)=>{hp.init(e,t),X.init(e,t)});function Zc(e){return Ba($r,e)}const Sr=g("ZodKSUID",(e,t)=>{mp.init(e,t),X.init(e,t)});function Dc(e){return Ka(Sr,e)}const Ir=g("ZodIPv4",(e,t)=>{wp.init(e,t),X.init(e,t)});function jc(e){return Ja(Ir,e)}const ti=g("ZodMAC",(e,t)=>{kp.init(e,t),X.init(e,t)});function Fc(e){return xh(ti,e)}const zr=g("ZodIPv6",(e,t)=>{vp.init(e,t),X.init(e,t)});function Uc(e){return Wa(zr,e)}const xr=g("ZodCIDRv4",(e,t)=>{$p.init(e,t),X.init(e,t)});function Vc(e){return Ga(xr,e)}const Tr=g("ZodCIDRv6",(e,t)=>{Sp.init(e,t),X.init(e,t)});function qc(e){return Ya(Tr,e)}const Cr=g("ZodBase64",(e,t)=>{Ip.init(e,t),X.init(e,t)});function Hc(e){return Qa(Cr,e)}const Er=g("ZodBase64URL",(e,t)=>{zp.init(e,t),X.init(e,t)});function Bc(e){return Xa(Er,e)}const Nr=g("ZodE164",(e,t)=>{xp.init(e,t),X.init(e,t)});function Kc(e){return ec(Nr,e)}const ni=g("ZodCreditCard",(e,t)=>{Tp.init(e,t),X.init(e,t)});function Jc(e){return Th(ni,e)}const ri=g("ZodIBAN",(e,t)=>{Cp.init(e,t),X.init(e,t)});function Wc(e){return Ch(ri,e)}const Or=g("ZodJWT",(e,t)=>{Ep.init(e,t),X.init(e,t)});function Gc(e){return tc(Or,e)}const wt=g("ZodCustomStringFormat",(e,t)=>{Np.init(e,t),X.init(e,t)});function Yc(e,t,n={}){return dn(wt,e,t,n)}function Qc(e){return dn(wt,"hostname",wf,e)}function Xc(e){return dn(wt,"hex",Rf,e)}function eu(e){return dn(wt,"currency_code",$f,e)}function tu(e,t){const n=t?.enc??"hex",r=`${e}_${n}`,o=Do[r];if(!o)throw new Error(`Unrecognized hash format: ${r}`);return dn(wt,r,o,t)}const _n=g("ZodNumber",(e,t)=>{ba.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ym(e,n,r,o),e.isFinite=!0},Kn({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=ge(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=ge(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=ge(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>ge(e).format??null},{gt(e,t){return this.check(ct(e,t))},gte(e,t){return this.check(Me(e,t))},min(e,t){return this.check(Me(e,t))},lt(e,t){return this.check(at(e,t))},lte(e,t){return this.check(Ae(e,t))},max(e,t){return this.check(Ae(e,t))},int(e){return this.check(jn(e))},safe(e){return this.check(jn(e))},positive(e){return this.check(ct(0,e))},nonnegative(e){return this.check(Me(0,e))},negative(e){return this.check(at(0,e))},nonpositive(e){return this.check(Ae(0,e))},multipleOf(e,t){return this.check(Mt(e,t))},step(e,t){return this.check(Mt(e,t))},finite(){return this}}));function Z(e){return Eh(_n,e)}const vt=g("ZodNumberFormat",(e,t)=>{Op.init(e,t),_n.init(e,t)});function jn(e){return Oh(vt,e)}function nu(e){return Ph(vt,e)}function ru(e){return Ah(vt,e)}function ou(e){return Mh(vt,e)}function iu(e){return Rh(vt,e)}const bn=g("ZodBoolean",(e,t)=>{wa.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_m(e,n,r)});function Q(e){return Lh(bn,e)}const wn=g("ZodBigInt",(e,t)=>{va.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bm(e,n,r,o)},Kn({minValue:e=>ge(e).minimum??null,maxValue:e=>ge(e).maximum??null,format:e=>ge(e).format??null},{gte(e,t){return this.check(Me(e,t))},min(e,t){return this.check(Me(e,t))},gt(e,t){return this.check(ct(e,t))},lt(e,t){return this.check(at(e,t))},lte(e,t){return this.check(Ae(e,t))},max(e,t){return this.check(Ae(e,t))},positive(e){return this.check(ct(BigInt(0),e))},negative(e){return this.check(at(BigInt(0),e))},nonpositive(e){return this.check(Ae(BigInt(0),e))},nonnegative(e){return this.check(Me(BigInt(0),e))},multipleOf(e,t){return this.check(Mt(e,t))}}));function su(e){return Dh(wn,e)}const Pr=g("ZodBigIntFormat",(e,t)=>{Pp.init(e,t),wn.init(e,t)});function au(e){return Fh(Pr,e)}function cu(e){return Uh(Pr,e)}const oi=g("ZodSymbol",(e,t)=>{Ap.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wm(e,n,r,o)});function uu(e){return Vh(oi,e)}const ii=g("ZodUndefined",(e,t)=>{Mp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>km(e,n,r,o)});function nn(e){return qh(ii,e)}const si=g("ZodNull",(e,t)=>{Rp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>vm(e,n,r)});function Ar(e){return Hh(si,e)}const ai=g("ZodAny",(e,t)=>{Lp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Im()});function Mr(){return Bh(ai)}const ci=g("ZodUnknown",(e,t)=>{Zp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>zm()});function Y(){return Kh(ci)}const ui=g("ZodNever",(e,t)=>{Dp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Sm(e,n,r)});function Rt(e){return Jh(ui,e)}const li=g("ZodVoid",(e,t)=>{jp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>$m(e,n,r,o)});function lu(e){return Wh(li,e)}const Rr=g("ZodDate",(e,t)=>{Fp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>xm(e,n,r,o),e.min=(n,r)=>e.check(Me(n,r)),e.max=(n,r)=>e.check(Ae(n,r))},Kn({minDate:e=>{const{minimum:t}=ge(e);return t?new Date(t):null},maxDate:e=>{const{maximum:t}=ge(e);return t?new Date(t):null}},{}));function du(e){return Gh(Rr,e)}const di=g("ZodArray",(e,t)=>{jt(),Up.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Dm(e,n,r,o),e.element=t.element},{min(e,t){return this.check(bt(e,t))},nonempty(e){return this.check(bt(1,e))},max(e,t){return this.check(un(e,t))},length(e,t){return this.check(ln(e,t))},unwrap(){return this.element}});function A(e,t){return Xh(di,e,t)}function fu(e){const t=e._zod.def.shape;return be(Object.keys(t))}const vn=g("ZodObject",(e,t)=>{jt(),Bp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jm(e,n,r,o),Jd(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return be(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(ke(this._zod.def,{catchall:e}))},passthrough(){return this.clone(ke(this._zod.def,{catchall:Y()}))},loose(){return this.clone(ke(this._zod.def,{catchall:Y()}))},strict(){return this.clone(ke(this._zod.def,{catchall:Rt()}))},strip(){return this.clone(ke(this._zod.def,{catchall:void 0}))},extend(e){return Zd(this,e)},safeExtend(e){return jd(this,e)},merge(e){return Fd(this,e)},pick(e){return Rd(this,e)},omit(e){return Ld(this,e)},partial(...e){return ds(Sn,this,e[0])},exactPartial(...e){return ds(Dr,this,e[0],"exactPartial")},required(...e){return Ud(jr,this,e[0])}});function b(e,t){const n={type:"object",shape:e??{},...$(t)};return new vn(n)}function pu(e,t){return new vn({type:"object",shape:e,catchall:Rt(),...$(t)})}function _e(e,t){return new vn({type:"object",shape:e,catchall:Y(),...$(t)})}const kn=g("ZodUnion",(e,t)=>{Vo.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ac(e,n,r,o),e.options=t.options});function j(e,t){return new kn({type:"union",options:e,...$(t)})}const fi=g("ZodXor",(e,t)=>{kn.init(e,t),Kp.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ac(e,n,r,o),e.options=t.options});function hu(e,t){return new fi({type:"union",options:e,inclusive:!1,...$(t)})}const pi=g("ZodDiscriminatedUnion",(e,t)=>{kn.init(e,t),Wp.init(e,t)});function Lr(e,t,n){return new pi({type:"union",options:t,discriminator:e,...$(n)})}const hi=g("ZodIntersection",(e,t)=>{Gp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fm(e,n,r,o)});function $n(e,t){return new hi({type:"intersection",left:e,right:t})}const mi=g("ZodTuple",(e,t)=>{jt(),$a.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Um(e,n,r,o)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){const e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new Sn({type:"optional",innerType:t}))})}});function gi(e,t,n){const r=t instanceof L,o=r?n:t,i=r?t:null;return new mi({type:"tuple",items:e,rest:i,...$(o)})}const Lt=g("ZodRecord",(e,t)=>{jt(),Yp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vm(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function V(e,t,n){return!t||!t._zod?new Lt({type:"record",keyType:y(),valueType:e,...$(t)}):new Lt({type:"record",keyType:e,valueType:t,...$(n)})}function mu(e,t,n){return new Lt({type:"record",keyType:e,valueType:t,...$(n),partial:!0})}function gu(e,t,n){return new Lt({type:"record",keyType:e,valueType:t,mode:"loose",...$(n)})}const yi=g("ZodMap",(e,t)=>{jt(),Qp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Lm(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(ut(...n)),e.nonempty=n=>e.check(ut(1,n)),e.max=(...n)=>e.check(Dt(...n)),e.size=(...n)=>e.check(cn(...n))});function yu(e,t,n){return new yi({type:"map",keyType:e,valueType:t,...$(n)})}const _i=g("ZodSet",(e,t)=>{jt(),Xp.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zm(e,n,r,o),e.min=(...n)=>e.check(ut(...n)),e.nonempty=n=>e.check(ut(1,n)),e.max=(...n)=>e.check(Dt(...n)),e.size=(...n)=>e.check(cn(...n))});function _u(e,t){return new _i({type:"set",valueType:e,...$(t)})}const Zt=g("ZodEnum",(e,t)=>{eh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Tm(e,r,o),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Zt({...t,checks:[],...$(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Zt({...t,checks:[],...$(o),entries:i})}});function be(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Zt({type:"enum",entries:n,...$(t)})}function bu(e,t){return new Zt({type:"enum",entries:e,...$(t)})}const bi=g("ZodLiteral",(e,t)=>{th.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Cm(e,n,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 _(e,t){return new bi({type:"literal",values:Array.isArray(e)?e:[e],...$(t)})}const wi=g("ZodFile",(e,t)=>{nh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Om(e,n,r),e.min=(n,r)=>e.check(ut(n,r)),e.max=(n,r)=>e.check(Dt(n,r)),e.mime=(n,r)=>e.check(ur(Array.isArray(n)?n:[n],r))});function wu(e){return em(wi,e)}const vi=g("ZodTransform",(e,t)=>{jt(),rh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Rm(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Po(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Wt(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=e),n.issues.push(Wt(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function Zr(e){return new vi({type:"transform",transform:e})}const Sn=g("ZodOptional",(e,t)=>{Sa.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>uc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ne(e){return new Sn({type:"optional",innerType:e})}const Dr=g("ZodExactOptional",(e,t)=>{oh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>uc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ki(e){return new Dr({type:"optional",innerType:e})}const $i=g("ZodNullable",(e,t)=>{ih.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function rn(e){return new $i({type:"nullable",innerType:e})}function vu(e){return ne(rn(e))}const Si=g("ZodDefault",(e,t)=>{sh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Km(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ii(e,t){return new Si({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Hn(t)}})}const zi=g("ZodPrefault",(e,t)=>{ah.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xi(e,t){return new zi({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Hn(t)}})}const jr=g("ZodNonOptional",(e,t)=>{ch.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ti(e,t){return new jr({type:"nonoptional",innerType:e,...$(t)})}const Ci=g("ZodSuccess",(e,t)=>{uh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Pm(e,n,r),e.unwrap=()=>e._zod.def.innerType});function ku(e){return new Ci({type:"success",innerType:e})}const Ei=g("ZodCatch",(e,t)=>{lh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Wm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ni(e,t){return new Ei({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Zs(t)})}const Oi=g("ZodNaN",(e,t)=>{dh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Em(e,n,r,o)});function $u(e){return Qh(Oi,e)}const In=g("ZodPipe",(e,t)=>{Ia.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gm(e,n,r,o),e.in=t.in,e.out=t.out});function Fn(e,t){return new In({type:"pipe",in:e,out:t})}const zn=g("ZodCodec",(e,t)=>{In.init(e,t),za.init(e,t)});function Su(e,t,n){return new zn({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function Iu(e){const t=e._zod.def;return new zn({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}const Pi=g("ZodPreprocess",(e,t)=>{In.init(e,t),fh.init(e,t)}),Ai=g("ZodReadonly",(e,t)=>{ph.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ym(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Mi(e){return new Ai({type:"readonly",innerType:e})}const Ri=g("ZodTemplateLiteral",(e,t)=>{hh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Nm(e,n,r)});function zu(e,t){return new Ri({type:"template_literal",parts:e,...$(t)})}const Li=g("ZodLazy",(e,t)=>{xa.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xm(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function Zi(e){return new Li({type:"lazy",getter:e})}const Di=g("ZodPromise",(e,t)=>{gh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qm(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function xu(e){return new Di({type:"promise",innerType:e})}const ji=g("ZodFunction",(e,t)=>{mh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Mm(e,n,r,o)});function on(e){return new ji({type:"function",input:Array.isArray(e?.input)?gi(e?.input):e?.input??A(Y()),output:e?.output??Y()})}const xn=g("ZodCustom",(e,t)=>{yh.init(e,t),D.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Am(e,n,r,o)});function Tu(e){const t=new ie({check:"custom"});return t._zod.check=e,t}function Fi(e,t){return tm(xn,e??(()=>!0),t)}function Ui(e,t={}){return nm(xn,e,t)}function Vi(e,t){return rm(e,t)}const Cu=im,Eu=sm,qi=g("ZodInstanceOf",(e,t)=>{xn.init(e,t)},{properties(e,t){return this.check(cr(e,t))}});function Nu(e,t={}){const n=new qi({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...$(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}const Ou=(...e)=>am({Codec:zn,Boolean:bn,String:fn},...e);function Pu(e){const t=Zi(()=>j([y(e),Z(),Q(),Ar(),A(t),V(y(),t)]));return t}function Fr(e,t){return new Pi({type:"pipe",in:Zr(e),out:t})}const nw=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:ai,ZodArray:di,ZodBase64:Cr,ZodBase64URL:Er,ZodBigInt:wn,ZodBigIntFormat:Pr,ZodBoolean:bn,ZodCIDRv4:xr,ZodCIDRv6:Tr,ZodCUID:wr,ZodCUID2:vr,ZodCatch:Ei,ZodCodec:zn,ZodCreditCard:ni,ZodCustom:xn,ZodCustomStringFormat:wt,ZodDate:Rr,ZodDefault:Si,ZodDiscriminatedUnion:pi,ZodE164:Nr,ZodEmail:gr,ZodEmoji:_r,ZodEnum:Zt,ZodExactOptional:Dr,ZodFile:wi,ZodFunction:ji,ZodGUID:yr,ZodIBAN:ri,ZodIPv4:Ir,ZodIPv6:zr,ZodISODate:hn,ZodISODateTime:pn,ZodISODuration:gn,ZodISOTime:mn,ZodInstanceOf:qi,ZodIntersection:hi,ZodJWT:Or,ZodKSUID:Sr,ZodLazy:Li,ZodLiteral:bi,ZodMAC:ti,ZodMap:yi,ZodNaN:Oi,ZodNanoID:br,ZodNever:ui,ZodNonOptional:jr,ZodNull:si,ZodNullable:$i,ZodNumber:_n,ZodNumberFormat:vt,ZodObject:vn,ZodOptional:Sn,ZodPipe:In,ZodPrefault:zi,ZodPreprocess:Pi,ZodPromise:Di,ZodReadonly:Ai,ZodRecord:Lt,ZodSet:_i,ZodString:fn,ZodStringFormat:X,ZodSuccess:Ci,ZodSymbol:oi,ZodTemplateLiteral:Ri,ZodTransform:vi,ZodTuple:mi,ZodType:D,ZodULID:kr,ZodURL:yn,ZodUUID:He,ZodUndefined:ii,ZodUnion:kn,ZodUnknown:ci,ZodVoid:li,ZodXID:$r,ZodXor:fi,_ZodString:mr,_default:Ii,_function:on,any:Mr,array:A,base64:Hc,base64url:Bc,bigint:su,boolean:Q,catch:Ni,check:Tu,cidrv4:Vc,cidrv6:qc,codec:Su,creditCard:Jc,cuid:Mc,cuid2:Rc,currencyCode:eu,custom:Fi,date:du,describe:Cu,discriminatedUnion:Lr,e164:Kc,email:Ic,emoji:Pc,enum:be,exactOptional:ki,file:wu,float32:nu,float64:ru,function:on,guid:zc,hash:tu,hex:Xc,hostname:Qc,httpUrl:Oc,iban:Wc,instanceof:Nu,int:jn,int32:ou,int64:au,intersection:$n,invertCodec:Iu,ipv4:jc,ipv6:Uc,json:Pu,jwt:Gc,keyof:fu,ksuid:Dc,lazy:Zi,literal:_,looseObject:_e,looseRecord:gu,mac:Fc,map:yu,meta:Eu,nan:$u,nanoid:Ac,nativeEnum:bu,never:Rt,nonoptional:Ti,null:Ar,nullable:rn,nullish:vu,number:Z,object:b,optional:ne,partialRecord:mu,pipe:Fn,prefault:xi,preprocess:Fr,promise:xu,readonly:Mi,record:V,refine:Ui,set:_u,strictObject:pu,string:y,stringFormat:Yc,stringbool:Ou,success:ku,superRefine:Vi,symbol:uu,templateLiteral:zu,transform:Zr,tuple:gi,uint32:iu,uint64:cu,ulid:Lc,undefined:nn,union:j,unknown:Y,url:Nc,uuid:xc,uuidv4:Tc,uuidv6:Cc,uuidv7:Ec,void:lu,xid:Zc,xor:hu},Symbol.toStringTag,{value:"Module"})),og={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 ig(e){me({customError:e})}function sg(){return me().customError}var $o;$o||($o={});function ag(e){return rc(pn,e)}function rw(e){return oc(hn,e)}function ow(e){return ic(mn,e)}function iw(e){return sc(gn,e)}const Au=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:hn,ZodISODateTime:pn,ZodISODuration:gn,ZodISOTime:mn,date:rw,datetime:ag,duration:iw,time:ow},Symbol.toStringTag,{value:"Module"})),x={...nw,...ew,iso:Au},sw=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function aw(e,t){const n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function id(e,t){return e.map((n,r)=>r<t?n:n.optional())}function cw(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function uw(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");const n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;const r=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===r){const o=n[1]===void 0?void 0:cw(n[1]);if(!o||!t.defs[o])throw new Error(`Reference not found: ${e}`);return t.defs[o]}throw new Error(`Reference not found: ${e}`)}function lw(e,t){return x.transform(r=>r).check(r=>{const o=r.value;if(typeof o!="object"||o===null||Array.isArray(o))return;const i=Object.getOwnPropertyNames(o);if(t.minProperties!==void 0&&i.length<t.minProperties&&r.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:o,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&r.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:o,inst:e,continue:!0}),t.keySchema)for(const s of i){const a=t.keySchema.safeParse(s);a.success||r.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:s,path:[s],continue:!0})}}).pipe(e)}function Ss(e,t){if(e===null)return"z";const n=typeof e;if(n!=="object"){if(n==="number"&&Number.isNaN(e))return null;const r=String(e);return`${n[0]}${r.length}:${r}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){const i=[];for(const s of e){const a=Ss(s,t);if(a===null)return null;i.push(a)}return`a${i.length}:[${i.join(",")}]`}const r=Object.keys(e).sort(),o=[];for(const i of r){const s=Ss(e[i],t);if(s===null)return null;o.push(`${i.length}:${i}=${s}`)}return`o${o.length}:{${o.join(",")}}`}finally{t.delete(e)}}const dw=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),fw=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Mn(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Mn):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>dw.has(t)?Mn(n):!fw.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(Mn))}function sd(e){return e===1?"element":"elements"}function pw(e,t){return x.transform(r=>r).check(r=>{const o=r.value;if(Array.isArray(o)){if(t.uniqueItems===!0){const i=new Map;for(let s=0;s<o.length;s++){const a=Ss(o[s],new Set);if(a===null)continue;const c=i.get(a);if(c===void 0){i.set(a,s);continue}r.issues.push({code:"custom",message:`Array items must be unique: element at index ${s} duplicates the one at index ${c}`,input:o,path:[s],continue:!0})}}if(t.containsSchema){const i=t.minContains??1,s=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY;let a=0;for(const c of o)if(t.containsSchema.safeParse(c).success&&++a>=s)break;a<i&&r.issues.push({code:"custom",message:`Array must contain at least ${i} matching ${sd(i)}; found ${a}`,input:o,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&r.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${sd(t.maxContains)}`,input:o,continue:!0})}}}).pipe(e)}function ad(e,t){if(e!==!1)return e===void 0||e===!0?x.any():Ie(e,t)}const hw=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function cg(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return x.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 o=e.$ref;if(t.refs.has(o))return t.refs.get(o);if(t.processing.has(o))return x.lazy(()=>{if(!t.refs.has(o))throw new Error(`Circular reference not resolved: ${o}`);return t.refs.get(o)});t.processing.add(o);const i=uw(o,t),s=Ie(i,t);return t.refs.set(o,s),t.processing.delete(o),s}if(e.enum!==void 0){const o=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&o.length===1&&o[0]===null)return x.null();if(o.length===0)return x.never();if(o.length===1)return x.literal(o[0]);if(o.every(s=>typeof s=="string"))return x.enum(o);const i=o.map(s=>x.literal(s));return i.length<2?i[0]:x.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return x.literal(e.const);const n=e.type;if(Array.isArray(n)){const o=n.map(i=>{const s={...e,type:i};return cg(s,t)});return o.length===0?x.never():o.length===1?o[0]:x.union(o)}if(!n)return x.any();let r;switch(n){case"string":{let o=x.string();if(e.format){const i=e.format;i==="email"?o=o.check(x.email()):i==="uri"||i==="uri-reference"?o=o.check(x.url()):i==="uuid"||i==="guid"?o=o.check(x.uuid()):i==="date-time"?o=o.check(x.iso.datetime({offset:!0})):i==="date"?o=o.check(x.iso.date()):i==="time"?o=o.check(x.regex(hw)):i==="duration"?o=o.check(x.iso.duration()):i==="hostname"?o=o.check(x.hostname()):i==="ipv4"?o=o.check(x.ipv4()):i==="ipv6"?o=o.check(x.ipv6()):i==="mac"?o=o.check(x.mac()):i==="cidr"?o=o.check(x.cidrv4()):i==="cidr-v6"?o=o.check(x.cidrv6()):i==="base64"?o=o.check(x.base64()):i==="base64url"?o=o.check(x.base64url()):i==="e164"?o=o.check(x.e164()):i==="credit_card"?o=o.check(x.creditCard()):i==="iban"?o=o.check(x.iban()):i==="jwt"?o=o.check(x.jwt()):i==="emoji"?o=o.check(x.emoji()):i==="nanoid"?o=o.check(x.nanoid()):i==="cuid"?o=o.check(x.cuid()):i==="cuid2"?o=o.check(x.cuid2()):i==="ulid"?o=o.check(x.ulid()):i==="xid"?o=o.check(x.xid()):i==="ksuid"&&(o=o.check(x.ksuid()))}typeof e.minLength=="number"&&(o=o.min(e.minLength)),typeof e.maxLength=="number"&&(o=o.max(e.maxLength)),e.pattern&&(o=o.regex(new RegExp(e.pattern))),r=o;break}case"number":case"integer":{let o=n==="integer"?x.number().int():x.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(o=o.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(o=o.max(e.maximum)),typeof e.exclusiveMinimum=="number"?o=o.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(o=o.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?o=o.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(o=o.lt(e.maximum)),typeof e.multipleOf=="number"&&(o=o.multipleOf(e.multipleOf)),r=o;break}case"boolean":{r=x.boolean();break}case"null":{r=x.null();break}case"object":{const o={},i=e.properties||{},s=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?Ie(e.additionalProperties,t):void 0;for(const[d,f]of Object.entries(i)){const p=Ie(f,t);Re(o,d,s.has(d)?p:p.optional())}if(e.patternProperties){const d=e.patternProperties,f=Object.keys(d),p=[];for(const m of f){const k=Ie(d[m],t),I=x.string().regex(new RegExp(m));p.push(x.looseRecord(I,k))}const h=[];if(Object.keys(o).length>0&&h.push(x.object(o).passthrough()),h.push(...p),h.length===0)r=x.object({}).passthrough();else if(h.length===1)r=h[0];else{let m=x.intersection(h[0],h[1]);for(let k=2;k<h.length;k++)m=x.intersection(m,h[k]);r=m}if(e.additionalProperties===!1){const m=Object.keys(o),k=f.map(v=>new RegExp(v)),I=r;r=r.check(v=>{if(!rt(v.value))return;const z=[];for(const C of Object.keys(v.value))m.includes(C)||k.some(R=>R.test(C))||z.push(C);z.length&&v.issues.push({code:"unrecognized_keys",keys:z,input:v.value,inst:I})})}}else{const d=x.object(o);e.additionalProperties===!1?r=d.strict():a?r=d.catchall(a):r=d.passthrough()}const c=e.propertyNames!==void 0&&e.propertyNames!==!0,u=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(c||u!==void 0||l!==void 0){let d;if(c){const f=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=Ie(f,t)}r=lw(r,{keySchema:d,minProperties:u,maxProperties:l})}break}case"array":{const o=e.prefixItems,i=e.items;if(o&&Array.isArray(o)){const s=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>Ie(d,t)),c=id(a,s),u=Array.isArray(i)?void 0:ad(i,t),l=x.tuple(c);r=u?l.rest(u):l,typeof e.minItems=="number"&&(r=r.check(x.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(x.maxLength(e.maxItems)))}else if(Array.isArray(i)){const s=typeof e.minItems=="number"?e.minItems:0,a=i.map(d=>Ie(d,t)),c=id(a,s),u=ad(e.additionalItems,t),l=x.tuple(c);r=u?l.rest(u):l,typeof e.minItems=="number"&&(r=r.check(x.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(x.maxLength(e.maxItems)))}else if(i!==void 0){const s=Ie(i,t);let a=x.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=x.array(x.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=pw(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?Ie(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${n}`)}return r}function Ie(e,t){if(typeof e=="boolean")return e?x.any():x.never();let n=cg(e,t);const r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){const a=e.anyOf.map(u=>Ie(u,t)),c=x.union(a);n=r?x.intersection(n,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){const a=e.oneOf.map(u=>Ie(u,t)),c=x.xor(a);n=r?x.intersection(n,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:x.any();else{let a=r?n:Ie(e.allOf[0],t);const c=r?0:1;for(let u=c;u<e.allOf.length;u++)a=x.intersection(a,Ie(e.allOf[u],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=x.nullable(n)),e.readOnly===!0&&(n=x.readonly(n)),e.default!==void 0&&(n=n.default(e.default));const o={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(const a of i)a in e&&(o[a]=e[a]);const s=["contentEncoding","contentMediaType","contentSchema"];for(const a of s)a in e&&(o[a]=e[a]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!Mn(e.propertyNames)&&(o.propertyNames=e.propertyNames);for(const a of["minProperties","maxProperties"])e[a]!==void 0&&(o[a]=e[a])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!Mn(e.contains)&&(o.contains=e.contains);for(const a of["uniqueItems","minContains","maxContains"])e[a]!==void 0&&(o[a]=e[a])}for(const a of Object.keys(e))sw.has(a)||Re(o,a,e[a]);return Object.keys(o).length>0&&t.registry.add(n,o),e.description&&(n=n.describe(e.description)),n}function ug(e,t){if(typeof e=="boolean")return e?x.any():x.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}const r=aw(n,t?.defaultTarget),o=n.$defs||n.definitions||{},i={version:r,defs:o,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??Oe};return Ie(n,i)}function lg(e){return dc(e,{object:t=>t.partial(),union:t=>{const n=t._zod.def;return n.discriminator===void 0?t:j(n.options)}})}function mw(e,t){if(!t?.length)return e;const n=e._zod.def;return oe(e,ke(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function dg(e){return mw(e.out,e.checks)}function gw(e){return e.in._zod.traits.has("$ZodTransform")?dg(e):e.in}function fg(e){return dc(e,{pipe:t=>gw(t._zod.def),default:(t,n)=>n?ne(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function pg(e){return dc(e,{pipe:t=>dg(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}function yw(e){return zh(fn,e)}function _w(e){return Nh(_n,e)}function bw(e){return Zh(bn,e)}function ww(e){return jh(wn,e)}function vw(e){return Yh(Rr,e)}const hg=Object.freeze(Object.defineProperty({__proto__:null,bigint:ww,boolean:bw,date:vw,number:_w,string:yw},Symbol.toStringTag,{value:"Module"})),cd=Object.freeze(Object.defineProperty({__proto__:null,$brand:Fs,$input:Oa,$output:Na,INVALID:xe,NEVER:js,TimePrecision:nc,ZodAny:ai,ZodArray:di,ZodBase64:Cr,ZodBase64URL:Er,ZodBigInt:wn,ZodBigIntFormat:Pr,ZodBoolean:bn,ZodCIDRv4:xr,ZodCIDRv6:Tr,ZodCUID:wr,ZodCUID2:vr,ZodCatch:Ei,ZodCodec:zn,ZodCompileAsyncError:st,ZodCompileUnsupportedError:H,ZodCreditCard:ni,ZodCustom:xn,ZodCustomStringFormat:wt,ZodDate:Rr,ZodDefault:Si,ZodDiscriminatedUnion:pi,ZodE164:Nr,ZodEmail:gr,ZodEmoji:_r,ZodEnum:Zt,ZodError:rg,ZodExactOptional:Dr,ZodFile:wi,get ZodFirstPartyTypeKind(){return $o},ZodFunction:ji,ZodGUID:yr,ZodIBAN:ri,ZodIPv4:Ir,ZodIPv6:zr,ZodISODate:hn,ZodISODateTime:pn,ZodISODuration:gn,ZodISOTime:mn,ZodInstanceOf:qi,ZodIntersection:hi,ZodIssueCode:og,ZodJWT:Or,ZodKSUID:Sr,ZodLazy:Li,ZodLiteral:bi,ZodMAC:ti,ZodMap:yi,ZodNaN:Oi,ZodNanoID:br,ZodNever:ui,ZodNonOptional:jr,ZodNull:si,ZodNullable:$i,ZodNumber:_n,ZodNumberFormat:vt,ZodObject:vn,ZodOptional:Sn,ZodPipe:In,ZodPrefault:zi,ZodPreprocess:Pi,ZodPromise:Di,ZodReadonly:Ai,ZodRealError:Ee,ZodRecord:Lt,ZodSet:_i,ZodString:fn,ZodStringFormat:X,ZodSuccess:Ci,ZodSymbol:oi,ZodTemplateLiteral:Ri,ZodTransform:vi,ZodTuple:mi,ZodType:D,ZodULID:kr,ZodURL:yn,ZodUUID:He,ZodUndefined:ii,ZodUnion:kn,ZodUnknown:ci,ZodVoid:li,ZodXID:$r,ZodXor:fi,_ZodString:mr,_default:Ii,_function:on,any:Mr,array:A,base64:Hc,base64url:Bc,bigint:su,boolean:Q,catch:Ni,check:Tu,cidrv4:Vc,cidrv6:qc,clone:oe,codec:Su,coerce:hg,compile:Pa,config:me,core:eg,creditCard:Jc,cuid:Mc,cuid2:Rc,currencyCode:eu,custom:Fi,date:du,decode:_c,decodeAsync:wc,deepPartial:lg,describe:Cu,discriminatedUnion:Lr,e164:Kc,email:Ic,emoji:Pc,encode:yc,encodeAsync:bc,endsWith:ar,enum:be,exactOptional:ki,file:wu,flattenError:Ao,float32:nu,float64:ru,formatError:Mo,fromJSONSchema:ug,function:on,getDiscriminatedOption:ka,getErrorMap:sg,globalRegistry:Oe,gt:ct,gte:Me,guid:zc,hash:tu,hex:Xc,hostname:Qc,httpUrl:Oc,iban:Wc,includes:ir,input:fg,instanceof:Nu,int:jn,int32:ou,int64:au,intersection:$n,invertCodec:Iu,ipv4:jc,ipv6:Uc,iso:Au,json:Pu,jwt:Gc,keyof:fu,ksuid:Dc,lazy:Zi,length:ln,literal:_,locales:Ea,looseObject:_e,looseRecord:gu,lowercase:rr,lt:at,lte:Ae,mac:Fc,map:yu,maxLength:un,maxSize:Dt,memoizer:qo,meta:Eu,mime:ur,minLength:bt,minSize:ut,multipleOf:Mt,nan:$u,nanoid:Ac,nativeEnum:bu,negative:Yo,never:Rt,nonnegative:Xo,nonoptional:Ti,nonpositive:Qo,normalize:lr,null:Ar,nullable:rn,nullish:vu,number:Z,object:b,optional:ne,output:pg,overwrite:Ye,parse:pc,parseAsync:hc,partialRecord:mu,pipe:Fn,positive:Go,prefault:xi,preprocess:Fr,prettifyError:Vs,promise:xu,properties:cr,property:ei,readonly:Mi,record:V,refine:Ui,regex:nr,regexes:Do,registry:Ho,safeDecode:kc,safeDecodeAsync:Sc,safeEncode:vc,safeEncodeAsync:$c,safeParse:mc,safeParseAsync:gc,set:_u,setErrorMap:ig,size:cn,slugify:hr,startsWith:sr,strictObject:pu,string:y,stringFormat:Yc,stringbool:Ou,success:ku,superRefine:Vi,symbol:uu,templateLiteral:zu,toJSONSchema:lc,toLowerCase:fr,toUpperCase:pr,toZod:xo,transform:Zr,treeifyError:Us,trim:dr,tuple:gi,uint32:iu,uint64:cu,ulid:Lc,undefined:nn,union:j,unknown:Y,uppercase:or,url:Nc,util:Ds,uuid:xc,uuidv4:Tc,uuidv6:Cc,uuidv7:Ec,validate:Lo,validateAsync:Zo,void:lu,withParser:Bo,xid:Zc,xor:hu},Symbol.toStringTag,{value:"Module"})),kw=Object.freeze(Object.defineProperty({__proto__:null,$brand:Fs,$input:Oa,$output:Na,INVALID:xe,NEVER:js,TimePrecision:nc,ZodAny:ai,ZodArray:di,ZodBase64:Cr,ZodBase64URL:Er,ZodBigInt:wn,ZodBigIntFormat:Pr,ZodBoolean:bn,ZodCIDRv4:xr,ZodCIDRv6:Tr,ZodCUID:wr,ZodCUID2:vr,ZodCatch:Ei,ZodCodec:zn,ZodCompileAsyncError:st,ZodCompileUnsupportedError:H,ZodCreditCard:ni,ZodCustom:xn,ZodCustomStringFormat:wt,ZodDate:Rr,ZodDefault:Si,ZodDiscriminatedUnion:pi,ZodE164:Nr,ZodEmail:gr,ZodEmoji:_r,ZodEnum:Zt,ZodError:rg,ZodExactOptional:Dr,ZodFile:wi,get ZodFirstPartyTypeKind(){return $o},ZodFunction:ji,ZodGUID:yr,ZodIBAN:ri,ZodIPv4:Ir,ZodIPv6:zr,ZodISODate:hn,ZodISODateTime:pn,ZodISODuration:gn,ZodISOTime:mn,ZodInstanceOf:qi,ZodIntersection:hi,ZodIssueCode:og,ZodJWT:Or,ZodKSUID:Sr,ZodLazy:Li,ZodLiteral:bi,ZodMAC:ti,ZodMap:yi,ZodNaN:Oi,ZodNanoID:br,ZodNever:ui,ZodNonOptional:jr,ZodNull:si,ZodNullable:$i,ZodNumber:_n,ZodNumberFormat:vt,ZodObject:vn,ZodOptional:Sn,ZodPipe:In,ZodPrefault:zi,ZodPreprocess:Pi,ZodPromise:Di,ZodReadonly:Ai,ZodRealError:Ee,ZodRecord:Lt,ZodSet:_i,ZodString:fn,ZodStringFormat:X,ZodSuccess:Ci,ZodSymbol:oi,ZodTemplateLiteral:Ri,ZodTransform:vi,ZodTuple:mi,ZodType:D,ZodULID:kr,ZodURL:yn,ZodUUID:He,ZodUndefined:ii,ZodUnion:kn,ZodUnknown:ci,ZodVoid:li,ZodXID:$r,ZodXor:fi,_ZodString:mr,_default:Ii,_function:on,any:Mr,array:A,base64:Hc,base64url:Bc,bigint:su,boolean:Q,catch:Ni,check:Tu,cidrv4:Vc,cidrv6:qc,clone:oe,codec:Su,coerce:hg,compile:Pa,config:me,core:eg,creditCard:Jc,cuid:Mc,cuid2:Rc,currencyCode:eu,custom:Fi,date:du,decode:_c,decodeAsync:wc,deepPartial:lg,default:cd,describe:Cu,discriminatedUnion:Lr,e164:Kc,email:Ic,emoji:Pc,encode:yc,encodeAsync:bc,endsWith:ar,enum:be,exactOptional:ki,file:wu,flattenError:Ao,float32:nu,float64:ru,formatError:Mo,fromJSONSchema:ug,function:on,getDiscriminatedOption:ka,getErrorMap:sg,globalRegistry:Oe,gt:ct,gte:Me,guid:zc,hash:tu,hex:Xc,hostname:Qc,httpUrl:Oc,iban:Wc,includes:ir,input:fg,instanceof:Nu,int:jn,int32:ou,int64:au,intersection:$n,invertCodec:Iu,ipv4:jc,ipv6:Uc,iso:Au,json:Pu,jwt:Gc,keyof:fu,ksuid:Dc,lazy:Zi,length:ln,literal:_,locales:Ea,looseObject:_e,looseRecord:gu,lowercase:rr,lt:at,lte:Ae,mac:Fc,map:yu,maxLength:un,maxSize:Dt,memoizer:qo,meta:Eu,mime:ur,minLength:bt,minSize:ut,multipleOf:Mt,nan:$u,nanoid:Ac,nativeEnum:bu,negative:Yo,never:Rt,nonnegative:Xo,nonoptional:Ti,nonpositive:Qo,normalize:lr,null:Ar,nullable:rn,nullish:vu,number:Z,object:b,optional:ne,output:pg,overwrite:Ye,parse:pc,parseAsync:hc,partialRecord:mu,pipe:Fn,positive:Go,prefault:xi,preprocess:Fr,prettifyError:Vs,promise:xu,properties:cr,property:ei,readonly:Mi,record:V,refine:Ui,regex:nr,regexes:Do,registry:Ho,safeDecode:kc,safeDecodeAsync:Sc,safeEncode:vc,safeEncodeAsync:$c,safeParse:mc,safeParseAsync:gc,set:_u,setErrorMap:ig,size:cn,slugify:hr,startsWith:sr,strictObject:pu,string:y,stringFormat:Yc,stringbool:Ou,success:ku,superRefine:Vi,symbol:uu,templateLiteral:zu,toJSONSchema:lc,toLowerCase:fr,toUpperCase:pr,toZod:xo,transform:Zr,treeifyError:Us,trim:dr,tuple:gi,uint32:iu,uint64:cu,ulid:Lc,undefined:nn,union:j,unknown:Y,uppercase:or,url:Nc,util:Ds,uuid:xc,uuidv4:Tc,uuidv6:Cc,uuidv7:Ec,validate:Lo,validateAsync:Zo,void:lu,withParser:Bo,xid:Zc,xor:hu,z:cd},Symbol.toStringTag,{value:"Module"})),Nt="io.modelcontextprotocol/related-task",Hi="2.0",he=Fi(e=>e!==null&&(typeof e=="object"||typeof e=="function")),mg=j([y(),Z().int()]),gg=y();_e({ttl:Z().optional(),pollInterval:Z().optional()});const $w=b({ttl:Z().optional()}),Sw=b({taskId:y()}),Mu=_e({progressToken:mg.optional(),[Nt]:Sw.optional()}),Ze=b({_meta:Mu.optional()}),Ur=Ze.extend({task:$w.optional()}),Iw=e=>Ur.safeParse(e).success,we=b({method:y(),params:Ze.loose().optional()}),Ue=b({_meta:Mu.optional()}),Ve=b({method:y(),params:Ue.loose().optional()}),ve=_e({_meta:Mu.optional()}),Vr=j([y(),Z().int()]),yg=b({jsonrpc:_(Hi),id:Vr,...we.shape}).strict(),ud=e=>yg.safeParse(e).success,_g=b({jsonrpc:_(Hi),...Ve.shape}).strict(),zw=e=>_g.safeParse(e).success,Ru=b({jsonrpc:_(Hi),id:Vr,result:ve}).strict(),io=e=>Ru.safeParse(e).success;var G;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(G||(G={}));const Lu=b({jsonrpc:_(Hi),id:Vr.optional(),error:b({code:Z().int(),message:y(),data:Y().optional()})}).strict(),xw=e=>Lu.safeParse(e).success,Tw=j([yg,_g,Ru,Lu]);j([Ru,Lu]);const Zu=ve.strict(),Cw=Ue.extend({requestId:Vr.optional(),reason:y().optional()}),Du=Ve.extend({method:_("notifications/cancelled"),params:Cw}),Ew=b({src:y(),mimeType:y().optional(),sizes:A(y()).optional(),theme:be(["light","dark"]).optional()}),qr=b({icons:A(Ew).optional()}),sn=b({name:y(),title:y().optional()}),Bi=sn.extend({...sn.shape,...qr.shape,version:y(),websiteUrl:y().optional(),description:y().optional()}),Nw=$n(b({applyDefaults:Q().optional()}),V(y(),Y())),Ow=Fr(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,$n(b({form:Nw.optional(),url:he.optional()}),V(y(),Y()).optional())),Pw=_e({list:he.optional(),cancel:he.optional(),requests:_e({sampling:_e({createMessage:he.optional()}).optional(),elicitation:_e({create:he.optional()}).optional()}).optional()}),Aw=_e({list:he.optional(),cancel:he.optional(),requests:_e({tools:_e({call:he.optional()}).optional()}).optional()}),Mw=b({experimental:V(y(),he).optional(),sampling:b({context:he.optional(),tools:he.optional()}).optional(),elicitation:Ow.optional(),roots:b({listChanged:Q().optional()}).optional(),tasks:Pw.optional(),extensions:V(y(),he).optional()}),Rw=Ze.extend({protocolVersion:y(),capabilities:Mw,clientInfo:Bi}),Lw=we.extend({method:_("initialize"),params:Rw}),Zw=b({experimental:V(y(),he).optional(),logging:he.optional(),completions:he.optional(),prompts:b({listChanged:Q().optional()}).optional(),resources:b({subscribe:Q().optional(),listChanged:Q().optional()}).optional(),tools:b({listChanged:Q().optional()}).optional(),tasks:Aw.optional(),extensions:V(y(),he).optional()}),Dw=ve.extend({protocolVersion:y(),capabilities:Zw,serverInfo:Bi,instructions:y().optional()}),jw=Ve.extend({method:_("notifications/initialized"),params:Ue.optional()}),Ki=we.extend({method:_("ping"),params:Ze.optional()}),Fw=b({progress:Z(),total:ne(Z()),message:ne(y())}),Uw=b({...Ue.shape,...Fw.shape,progressToken:mg}),ju=Ve.extend({method:_("notifications/progress"),params:Uw}),Vw=Ze.extend({cursor:gg.optional()}),Hr=we.extend({params:Vw.optional()}),Br=ve.extend({nextCursor:gg.optional()}),qw=be(["working","input_required","completed","failed","cancelled"]),Kr=b({taskId:y(),status:qw,ttl:j([Z(),Ar()]),createdAt:y(),lastUpdatedAt:y(),pollInterval:ne(Z()),statusMessage:ne(y())}),Fu=ve.extend({task:Kr}),Hw=Ue.merge(Kr),So=Ve.extend({method:_("notifications/tasks/status"),params:Hw}),Uu=we.extend({method:_("tasks/get"),params:Ze.extend({taskId:y()})}),Vu=ve.merge(Kr),qu=we.extend({method:_("tasks/result"),params:Ze.extend({taskId:y()})});ve.loose();const Hu=Hr.extend({method:_("tasks/list")}),Bu=Br.extend({tasks:A(Kr)}),Ku=we.extend({method:_("tasks/cancel"),params:Ze.extend({taskId:y()})}),Bw=ve.merge(Kr),bg=b({uri:y(),mimeType:ne(y()),_meta:V(y(),Y()).optional()}),wg=bg.extend({text:y()}),Ju=y().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),vg=bg.extend({blob:Ju}),Jr=be(["user","assistant"]),Tn=b({audience:A(Jr).optional(),priority:Z().min(0).max(1).optional(),lastModified:ag({offset:!0}).optional()}),kg=b({...sn.shape,...qr.shape,uri:y(),description:ne(y()),mimeType:ne(y()),size:ne(Z()),annotations:Tn.optional(),_meta:ne(_e({}))}),Kw=b({...sn.shape,...qr.shape,uriTemplate:y(),description:ne(y()),mimeType:ne(y()),annotations:Tn.optional(),_meta:ne(_e({}))}),Jw=Hr.extend({method:_("resources/list")}),$g=Br.extend({resources:A(kg)}),Ww=Hr.extend({method:_("resources/templates/list")}),Gw=Br.extend({resourceTemplates:A(Kw)}),Wu=Ze.extend({uri:y()}),Yw=Wu,Qw=we.extend({method:_("resources/read"),params:Yw}),Sg=ve.extend({contents:A(j([wg,vg]))}),Xw=Ve.extend({method:_("notifications/resources/list_changed"),params:Ue.optional()}),ev=Wu,tv=we.extend({method:_("resources/subscribe"),params:ev}),nv=Wu,rv=we.extend({method:_("resources/unsubscribe"),params:nv}),ov=Ue.extend({uri:y()}),iv=Ve.extend({method:_("notifications/resources/updated"),params:ov}),sv=b({name:y(),description:ne(y()),required:ne(Q())}),av=b({...sn.shape,...qr.shape,description:ne(y()),arguments:ne(A(sv)),_meta:ne(_e({}))}),cv=Hr.extend({method:_("prompts/list")}),uv=Br.extend({prompts:A(av)}),lv=Ze.extend({name:y(),arguments:V(y(),y()).optional()}),dv=we.extend({method:_("prompts/get"),params:lv}),Gu=b({type:_("text"),text:y(),annotations:Tn.optional(),_meta:V(y(),Y()).optional()}),Yu=b({type:_("image"),data:Ju,mimeType:y(),annotations:Tn.optional(),_meta:V(y(),Y()).optional()}),Qu=b({type:_("audio"),data:Ju,mimeType:y(),annotations:Tn.optional(),_meta:V(y(),Y()).optional()}),fv=b({type:_("tool_use"),name:y(),id:y(),input:V(y(),Y()),_meta:V(y(),Y()).optional()}),Ig=b({type:_("resource"),resource:j([wg,vg]),annotations:Tn.optional(),_meta:V(y(),Y()).optional()}),zg=kg.extend({type:_("resource_link")}),Wr=j([Gu,Yu,Qu,zg,Ig]),pv=b({role:Jr,content:Wr}),hv=ve.extend({description:y().optional(),messages:A(pv)}),mv=Ve.extend({method:_("notifications/prompts/list_changed"),params:Ue.optional()}),gv=b({title:y().optional(),readOnlyHint:Q().optional(),destructiveHint:Q().optional(),idempotentHint:Q().optional(),openWorldHint:Q().optional()}),yv=b({taskSupport:be(["required","optional","forbidden"]).optional()}),Xu=b({...sn.shape,...qr.shape,description:y().optional(),inputSchema:b({type:_("object"),properties:V(y(),he).optional(),required:A(y()).optional()}).catchall(Y()),outputSchema:b({type:_("object"),properties:V(y(),he).optional(),required:A(y()).optional()}).catchall(Y()).optional(),annotations:gv.optional(),execution:yv.optional(),_meta:V(y(),Y()).optional()}),xg=Hr.extend({method:_("tools/list")}),_v=Br.extend({tools:A(Xu)}),Ji=ve.extend({content:A(Wr).default([]),structuredContent:V(y(),Y()).optional(),isError:Q().optional()});Ji.or(ve.extend({toolResult:Y()}));const bv=Ur.extend({name:y(),arguments:V(y(),Y()).optional()}),Tg=we.extend({method:_("tools/call"),params:bv}),wv=Ve.extend({method:_("notifications/tools/list_changed"),params:Ue.optional()});b({autoRefresh:Q().default(!0),debounceMs:Z().int().nonnegative().default(300)});const Cg=be(["debug","info","notice","warning","error","critical","alert","emergency"]),vv=Ze.extend({level:Cg}),kv=we.extend({method:_("logging/setLevel"),params:vv}),$v=Ue.extend({level:Cg,logger:y().optional(),data:Y()}),Sv=Ve.extend({method:_("notifications/message"),params:$v}),Iv=b({name:y().optional()}),zv=b({hints:A(Iv).optional(),costPriority:Z().min(0).max(1).optional(),speedPriority:Z().min(0).max(1).optional(),intelligencePriority:Z().min(0).max(1).optional()}),xv=b({mode:be(["auto","required","none"]).optional()}),Tv=b({type:_("tool_result"),toolUseId:y().describe("The unique identifier for the corresponding tool call."),content:A(Wr).default([]),structuredContent:b({}).loose().optional(),isError:Q().optional(),_meta:V(y(),Y()).optional()}),Cv=Lr("type",[Gu,Yu,Qu]),Io=Lr("type",[Gu,Yu,Qu,fv,Tv]),Ev=b({role:Jr,content:j([Io,A(Io)]),_meta:V(y(),Y()).optional()}),Nv=Ur.extend({messages:A(Ev),modelPreferences:zv.optional(),systemPrompt:y().optional(),includeContext:be(["none","thisServer","allServers"]).optional(),temperature:Z().optional(),maxTokens:Z().int(),stopSequences:A(y()).optional(),metadata:he.optional(),tools:A(Xu).optional(),toolChoice:xv.optional()}),Ov=we.extend({method:_("sampling/createMessage"),params:Nv}),Eg=ve.extend({model:y(),stopReason:ne(be(["endTurn","stopSequence","maxTokens"]).or(y())),role:Jr,content:Cv}),Ng=ve.extend({model:y(),stopReason:ne(be(["endTurn","stopSequence","maxTokens","toolUse"]).or(y())),role:Jr,content:j([Io,A(Io)])}),Pv=b({type:_("boolean"),title:y().optional(),description:y().optional(),default:Q().optional()}),Av=b({type:_("string"),title:y().optional(),description:y().optional(),minLength:Z().optional(),maxLength:Z().optional(),format:be(["email","uri","date","date-time"]).optional(),default:y().optional()}),Mv=b({type:be(["number","integer"]),title:y().optional(),description:y().optional(),minimum:Z().optional(),maximum:Z().optional(),default:Z().optional()}),Rv=b({type:_("string"),title:y().optional(),description:y().optional(),enum:A(y()),default:y().optional()}),Lv=b({type:_("string"),title:y().optional(),description:y().optional(),oneOf:A(b({const:y(),title:y()})),default:y().optional()}),Zv=b({type:_("string"),title:y().optional(),description:y().optional(),enum:A(y()),enumNames:A(y()).optional(),default:y().optional()}),Dv=j([Rv,Lv]),jv=b({type:_("array"),title:y().optional(),description:y().optional(),minItems:Z().optional(),maxItems:Z().optional(),items:b({type:_("string"),enum:A(y())}),default:A(y()).optional()}),Fv=b({type:_("array"),title:y().optional(),description:y().optional(),minItems:Z().optional(),maxItems:Z().optional(),items:b({anyOf:A(b({const:y(),title:y()}))}),default:A(y()).optional()}),Uv=j([jv,Fv]),Vv=j([Zv,Dv,Uv]),qv=j([Vv,Pv,Av,Mv]),Hv=Ur.extend({mode:_("form").optional(),message:y(),requestedSchema:b({type:_("object"),properties:V(y(),qv),required:A(y()).optional()})}),Bv=Ur.extend({mode:_("url"),message:y(),elicitationId:y(),url:y().url()}),Kv=j([Hv,Bv]),Jv=we.extend({method:_("elicitation/create"),params:Kv}),Wv=Ue.extend({elicitationId:y()}),Gv=Ve.extend({method:_("notifications/elicitation/complete"),params:Wv}),Yv=ve.extend({action:be(["accept","decline","cancel"]),content:Fr(e=>e===null?void 0:e,V(y(),j([y(),Z(),Q(),A(y())])).optional())}),Qv=b({type:_("ref/resource"),uri:y()}),Xv=b({type:_("ref/prompt"),name:y()}),ek=Ze.extend({ref:j([Xv,Qv]),argument:b({name:y(),value:y()}),context:b({arguments:V(y(),y()).optional()}).optional()}),tk=we.extend({method:_("completion/complete"),params:ek}),nk=ve.extend({completion:_e({values:A(y()).max(100),total:ne(Z().int()),hasMore:ne(Q())})}),rk=b({uri:y().startsWith("file://"),name:y().optional(),_meta:V(y(),Y()).optional()}),ok=we.extend({method:_("roots/list"),params:Ze.optional()}),ik=ve.extend({roots:A(rk)}),sk=Ve.extend({method:_("notifications/roots/list_changed"),params:Ue.optional()});j([Ki,Lw,tk,kv,dv,cv,Jw,Ww,Qw,tv,rv,Tg,xg,Uu,qu,Hu,Ku]);j([Du,ju,jw,sk,So]);j([Zu,Eg,Ng,Yv,ik,Vu,Bu,Fu]);j([Ki,Ov,Jv,ok,Uu,qu,Hu,Ku]);j([Du,ju,Sv,iv,Xw,wv,mv,So,Gv]);j([Zu,Dw,nk,hv,uv,$g,Gw,Sg,Ji,_v,Vu,Bu,Fu]);class q extends Error{constructor(t,n,r){super(`MCP error ${t}: ${n}`),this.code=t,this.data=r,this.name="McpError"}static fromError(t,n,r){if(t===G.UrlElicitationRequired&&r){const o=r;if(o.elicitations)return new ak(o.elicitations,n)}return new q(t,n,r)}}class ak extends q{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(G.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function Tt(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function ld(e){const n=Gb(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=Yb(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function dd(e,t){const n=tg(e,t);if(!n.success)throw n.error;return n.data}const ck=6e4;class uk{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Du,n=>{this._oncancel(n)}),this.setNotificationHandler(ju,n=>{this._onprogress(n)}),this.setRequestHandler(Ki,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Uu,async(n,r)=>{const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new q(G.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(qu,async(n,r)=>{const o=async()=>{const i=n.params.taskId;if(!await this._taskStore.getTask(i,r.sessionId))throw new q(G.InvalidParams,`Task not found: ${i}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(i,r.sessionId);){if(a.type==="response"||a.type==="error"){const c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{const d=c,f=new q(d.error.code,d.error.message,d.error.data);l(f)}else{const d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:r.requestId})}}const s=await this._taskStore.getTask(i,r.sessionId);if(!s)throw new q(G.InvalidParams,`Task not found: ${i}`);if(!Tt(s.status))return await this._waitForTaskUpdate(i,r.signal,r.sessionId),await o();if(Tt(s.status)){const a=await this._taskStore.getTaskResult(i,r.sessionId);return this._clearTaskQueue(i,r.sessionId),{...a,_meta:{...a._meta,[Nt]:{taskId:i}}}}return await o()};return await o()}),this.setRequestHandler(Hu,async(n,r)=>{try{const{tasks:o,nextCursor:i}=await this._taskStore.listTasks(n.params?.cursor,r.sessionId);return{tasks:o,nextCursor:i,_meta:{}}}catch(o){throw new q(G.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(Ku,async(n,r)=>{try{const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new q(G.InvalidParams,`Task not found: ${n.params.taskId}`);if(Tt(o.status))throw new q(G.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",r.sessionId),this._clearTaskQueue(n.params.taskId,r.sessionId);const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new q(G.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...i}}catch(o){throw o instanceof q?o:new q(G.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,n,r,o,i=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,n),startTime:Date.now(),timeout:n,maxTotalTimeout:r,resetTimeoutOnProgress:i,onTimeout:o})}_resetTimeout(t){const n=this._timeoutInfo.get(t);if(!n)return!1;const r=Date.now()-n.startTime;if(n.maxTotalTimeout&&r>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),q.fromError(G.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:r});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){const n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const n=this.transport?.onclose;this._transport.onclose=()=>{n?.(),this._onclose()};const r=this.transport?.onerror;this._transport.onerror=i=>{r?.(i),this._onerror(i)};const o=this._transport?.onmessage;this._transport.onmessage=(i,s)=>{o?.(i,s),io(i)||xw(i)?this._onresponse(i):ud(i)?this._onrequest(i,s):zw(i)?this._onnotification(i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`))},await this._transport.start()}_onclose(){const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();for(const r of this._requestHandlerAbortControllers.values())r.abort();this._requestHandlerAbortControllers.clear();const n=q.fromError(G.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const r of t.values())r(n)}_onerror(t){this.onerror?.(t)}_onnotification(t){const n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(r=>this._onerror(new Error(`Uncaught error in notification handler: ${r}`)))}_onrequest(t,n){const r=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,i=t.params?._meta?.[Nt]?.taskId,s=o?.sessionId,a=this._taskStore;let c=!0,u;if(i&&a&&this._taskMessageQueue&&s!==void 0&&(c=!1,u=(async()=>{if(!await a.getTask(i,s))throw new q(G.InvalidParams,`Task not found: ${i}`);c=!0})()),r===void 0){const h={jsonrpc:"2.0",id:t.id,error:{code:G.MethodNotFound,message:"Method not found"}};if(i&&u){const m={type:"error",message:h,timestamp:Date.now()};u.then(()=>this._enqueueTaskMessage(i,m,s),()=>o?.send(h)).catch(k=>this._onerror(new Error(`Failed to send an error response: ${k}`)))}else i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:h,timestamp:Date.now()},o?.sessionId).catch(m=>this._onerror(new Error(`Failed to enqueue error response: ${m}`))):o?.send(h).catch(m=>this._onerror(new Error(`Failed to send an error response: ${m}`)));return}const l=new AbortController;this._requestHandlerAbortControllers.set(t.id,l);const d=Iw(t.params)?t.params.task:void 0,f=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,p={signal:l.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async h=>{if(l.signal.aborted)return;const m={relatedRequestId:t.id};i&&(m.relatedTask={taskId:i}),await this.notification(h,m)},sendRequest:async(h,m,k)=>{if(l.signal.aborted)throw new q(G.ConnectionClosed,"Request was cancelled");const I={...k,relatedRequestId:t.id};i&&!I.relatedTask&&(I.relatedTask={taskId:i});const v=I.relatedTask?.taskId??i;return v&&f&&await f.updateTaskStatus(v,"input_required"),await this.request(h,m,I)},authInfo:n?.authInfo,requestId:t.id,requestInfo:n?.requestInfo,taskId:i,taskStore:f,taskRequestedTtl:d?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};(u??Promise.resolve()).then(()=>{if(u&&l.signal.aborted)throw new q(G.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>r(t,p)).then(async h=>{if(l.signal.aborted)return;const m={result:h,jsonrpc:"2.0",id:t.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:m,timestamp:Date.now()},o?.sessionId):await o?.send(m)},async h=>{if(l.signal.aborted)return;const m={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(h.code)?h.code:G.InternalError,message:h.message??"Internal error",...h.data!==void 0&&{data:h.data}}};i&&this._taskMessageQueue&&c?await this._enqueueTaskMessage(i,{type:"error",message:m,timestamp:Date.now()},o?.sessionId):await o?.send(m)}).catch(h=>this._onerror(new Error(`Failed to send response: ${h}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===l&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...r}=t.params,o=Number(n),i=this._progressHandlers.get(o);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const s=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),s(c);return}i(r)}_onresponse(t){const n=Number(t.id),r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),io(t))r(t);else{const s=new q(t.error.code,t.error.message,t.error.data);r(s)}return}const o=this._responseHandlers.get(n);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let i=!1;if(io(t)&&t.result&&typeof t.result=="object"){const s=t.result;if(s.task&&typeof s.task=="object"){const a=s.task;typeof a.taskId=="string"&&(i=!0,this._taskProgressTokens.set(a.taskId,n))}}if(i||this._progressHandlers.delete(n),io(t))o(t);else{const s=q.fromError(t.error.code,t.error.message,t.error.data);o(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,n,r){const{task:o}=r??{};if(!o){try{yield{type:"result",result:await this.request(t,n,r)}}catch(s){yield{type:"error",error:s instanceof q?s:new q(G.InternalError,String(s))}}return}let i;try{const s=await this.request(t,Fu,r);if(s.task)i=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new q(G.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:i},r);if(yield{type:"taskStatus",task:a},Tt(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},n,r)}:a.status==="failed"?yield{type:"error",error:new q(G.InternalError,`Task ${i} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new q(G.InternalError,`Task ${i} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},n,r)};return}const c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),r?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof q?s:new q(G.InternalError,String(s))}}}request(t,n,r){const{relatedRequestId:o,resumptionToken:i,onresumptiontoken:s,task:a,relatedTask:c}=r??{};return new Promise((u,l)=>{const d=v=>{l(v)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(v){d(v);return}r?.signal?.throwIfAborted();const f=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:f};r?.onprogress&&(this._progressHandlers.set(f,r.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Nt]:c}});const h=v=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(v)}},{relatedRequestId:o,resumptionToken:i,onresumptiontoken:s}).catch(C=>this._onerror(new Error(`Failed to send cancellation: ${C}`)));const z=v instanceof q?v:new q(G.RequestTimeout,String(v));l(z)};this._responseHandlers.set(f,v=>{if(!r?.signal?.aborted){if(v instanceof Error)return l(v);try{const z=tg(n,v.result);z.success?u(z.data):l(z.error)}catch(z){l(z)}}}),r?.signal?.addEventListener("abort",()=>{h(r?.signal?.reason)});const m=r?.timeout??ck,k=()=>h(q.fromError(G.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(f,m,r?.maxTotalTimeout,k,r?.resetTimeoutOnProgress??!1);const I=c?.taskId;if(I){const v=z=>{const C=this._responseHandlers.get(f);C?C(z):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,v),this._enqueueTaskMessage(I,{type:"request",message:p,timestamp:Date.now()}).catch(z=>{this._cleanupTimeout(f),l(z)})}else this._transport.send(p,{relatedRequestId:o,resumptionToken:i,onresumptiontoken:s}).catch(v=>{this._cleanupTimeout(f),l(v)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},Vu,n)}async getTaskResult(t,n,r){return this.request({method:"tasks/result",params:t},n,r)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},Bu,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},Bw,n)}async notification(t,n){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const r=n?.relatedTask?.taskId;if(r){const a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Nt]:n.relatedTask}}};await this._enqueueTaskMessage(r,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId&&!n?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};n?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Nt]:n.relatedTask}}}),this._transport?.send(a,n).catch(c=>this._onerror(c))});return}let s={...t,jsonrpc:"2.0"};n?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Nt]:n.relatedTask}}}),await this._transport.send(s,n)}setRequestHandler(t,n){const r=ld(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(o,i)=>{const s=dd(t,o);return Promise.resolve(n(s,i))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){const r=ld(t);this._notificationHandlers.set(r,o=>{const i=dd(t,o);return Promise.resolve(n(i))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,r??this._transport?.sessionId,o)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(t,n);for(const o of r)if(o.type==="request"&&ud(o.message)){const i=o.message.id,s=this._requestResolvers.get(i);s?(s(new q(G.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n,r){let o=this._options?.defaultTaskPollInterval??1e3;try{const i=await this._taskStore?.getTask(t,r);i?.pollInterval&&(o=i.pollInterval)}catch{}return new Promise((i,s)=>{if(n.aborted){s(new q(G.InvalidRequest,"Request cancelled"));return}const a=setTimeout(i,o);n.addEventListener("abort",()=>{clearTimeout(a),s(new q(G.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await r.createTask(o,t.id,{method:t.method,params:t.params},n)},getTask:async o=>{const i=await r.getTask(o,n);if(!i)throw new q(G.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(o,i,s)=>{await r.storeTaskResult(o,i,s,n);const a=await r.getTask(o,n);if(a){const c=So.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Tt(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>r.getTaskResult(o,n),updateTaskStatus:async(o,i,s)=>{const a=await r.getTask(o,n);if(!a)throw new q(G.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Tt(a.status))throw new q(G.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(o,i,s,n);const c=await r.getTask(o,n);if(c){const u=So.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Tt(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>r.listTasks(o,n)}}}function fd(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function lk(e,t){const n={...e};for(const r in t){const o=r,i=t[o];if(i===void 0)continue;const s=n[o];fd(s)&&fd(i)?n[o]={...s,...i}:n[o]=i}return n}(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});class dk extends uk{_registeredMethods=new Set;_eventSlots=new Map;onEventDispatch(t,n){}_ensureEventSlot(t){let n=this._eventSlots.get(t);if(!n){let r=this.eventSchemas[t];if(!r)throw Error(`Unknown event: ${String(t)}`);n={listeners:[]},this._eventSlots.set(t,n);let o=r.shape.method.value;this._registeredMethods.add(o);let i=n;super.setNotificationHandler(r,s=>{let a=s.params;this.onEventDispatch(t,a),i.onHandler?.(a);for(let c of[...i.listeners])c(a)})}return n}setEventHandler(t,n){let r=this._ensureEventSlot(t);r.onHandler&&n&&console.warn(`[MCP Apps] on${String(t)} handler replaced. Use addEventListener("${String(t)}", …) to add multiple listeners without replacing.`),r.onHandler=n}getEventHandler(t){return this._eventSlots.get(t)?.onHandler}addEventListener(t,n){this._ensureEventSlot(t).listeners.push(n)}removeEventListener(t,n){let r=this._eventSlots.get(t);if(!r)return;let o=r.listeners.indexOf(n);o!==-1&&r.listeners.splice(o,1)}setRequestHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setRequestHandler"),super.setRequestHandler(t,n)};setNotificationHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setNotificationHandler"),super.setNotificationHandler(t,n)};warnIfRequestHandlerReplaced(t,n,r){n&&r&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}replaceRequestHandler=(t,n)=>{let r=t.shape.method.value;this._registeredMethods.add(r),super.setRequestHandler(t,n)};_assertMethodNotRegistered(t,n){let r=t.shape.method.value;if(this._registeredMethods.has(r))throw Error(`Handler for "${r}" already registered (via ${n}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(r)}}var fk="2026-01-26",pk="ui/notifications/tool-input-partial";class Og{eventTarget;eventSource;messageListener;constructor(t=window.parent,n){this.eventTarget=t,this.eventSource=n,this.messageListener=r=>{if(n&&r.source!==this.eventSource){console.debug("Ignoring message from unknown source",r);return}let o=Tw.safeParse(r.data);o.success?(console.debug("Parsed message",o.data),this.onmessage?.(o.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",o.error.message,r):(console.error("Failed to parse message",o.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+o.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==pk&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var hk=j([_("light"),_("dark")]).describe("Color theme preference for the host environment."),Un=j([_("inline"),_("fullscreen"),_("pip")]).describe("Display mode for UI presentation."),mk=j([_("--color-background-primary"),_("--color-background-secondary"),_("--color-background-tertiary"),_("--color-background-inverse"),_("--color-background-ghost"),_("--color-background-info"),_("--color-background-danger"),_("--color-background-success"),_("--color-background-warning"),_("--color-background-disabled"),_("--color-text-primary"),_("--color-text-secondary"),_("--color-text-tertiary"),_("--color-text-inverse"),_("--color-text-ghost"),_("--color-text-info"),_("--color-text-danger"),_("--color-text-success"),_("--color-text-warning"),_("--color-text-disabled"),_("--color-border-primary"),_("--color-border-secondary"),_("--color-border-tertiary"),_("--color-border-inverse"),_("--color-border-ghost"),_("--color-border-info"),_("--color-border-danger"),_("--color-border-success"),_("--color-border-warning"),_("--color-border-disabled"),_("--color-ring-primary"),_("--color-ring-secondary"),_("--color-ring-inverse"),_("--color-ring-info"),_("--color-ring-danger"),_("--color-ring-success"),_("--color-ring-warning"),_("--font-sans"),_("--font-mono"),_("--font-weight-normal"),_("--font-weight-medium"),_("--font-weight-semibold"),_("--font-weight-bold"),_("--font-text-xs-size"),_("--font-text-sm-size"),_("--font-text-md-size"),_("--font-text-lg-size"),_("--font-heading-xs-size"),_("--font-heading-sm-size"),_("--font-heading-md-size"),_("--font-heading-lg-size"),_("--font-heading-xl-size"),_("--font-heading-2xl-size"),_("--font-heading-3xl-size"),_("--font-text-xs-line-height"),_("--font-text-sm-line-height"),_("--font-text-md-line-height"),_("--font-text-lg-line-height"),_("--font-heading-xs-line-height"),_("--font-heading-sm-line-height"),_("--font-heading-md-line-height"),_("--font-heading-lg-line-height"),_("--font-heading-xl-line-height"),_("--font-heading-2xl-line-height"),_("--font-heading-3xl-line-height"),_("--border-radius-xs"),_("--border-radius-sm"),_("--border-radius-md"),_("--border-radius-lg"),_("--border-radius-xl"),_("--border-radius-full"),_("--border-width-regular"),_("--shadow-hairline"),_("--shadow-sm"),_("--shadow-md"),_("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),gk=V(mk.describe(`Style variables for theming MCP apps.
70
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){i(s);continue}if(e.external){const u=e.external.registry.get(s[0])?.id;if(t!==s[0]&&u){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}a.count>1&&e.reused==="ref"&&i(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Em(e){const t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;const n=[];for(const r of t){if(!r||typeof r!="object")return;Em(r);const o=Object.keys(r);if(o.length!==1||o[0]!=="type")return;const i=r.type;for(const s of Array.isArray(i)?i:[i]){if(typeof s!="string")return;n.includes(s)||n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Cm=new Set(["type","properties","required","additionalProperties"]),cd=["oneOf","anyOf"];function ud(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Cs(e){const t=[];for(const i of e){if(typeof i!="object"||i.type!=="object")return null;for(const s in i)if(!Cm.has(s))return null;t.push(i)}const n={},r=new Set;for(const i of t){for(const s in i.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;const a=[];for(const u of t){const l=u.properties?.[s]??ud(u);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}const c=a.length===1?a[0]:Cs(a)??{allOf:a};Fe(n,s,c)}for(const s of i.required??[])r.add(s)}const o={type:"object",properties:n};if(r.size&&(o.required=[...r]),t.every(i=>i.additionalProperties===!1))o.additionalProperties=!1;else{const i=[];for(const s of t){const a=ud(s);a&&!i.some(c=>JSON.stringify(c)===JSON.stringify(a))&&i.push(a)}i.length===1?o.additionalProperties=i[0]:i.length>1&&(o.additionalProperties={allOf:i})}return o}function Sw(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const o of Cm)if(o in e)return;const n=t.filter(o=>cd.some(i=>Array.isArray(o[i])));let r=null;if(!n.length)r=Cs(t);else{const o=n[0],i=cd.find(c=>Array.isArray(o[c]));if(Object.keys(o).length!==1)return;const s=t.filter(c=>c!==o),a=o[i].map(c=>Cs([...s,c]));if(a.some(c=>!c))return;r={[i]:a}}r&&(delete e.allOf,jn(e,r))}function nn(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const r=a=>{const c=e.seen.get(a);if(c.ref===null)return;const u=c.def??c.schema,l={...u},d=c.ref;if(c.ref=null,d){r(d);const p=e.seen.get(d),h=p.schema;if(h.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(u.allOf=u.allOf??[],u.allOf.push(h)):jn(u,h),jn(u,l),a._zod.parent===d)for(const y in u)y==="$ref"||y==="allOf"||y in l||delete u[y];if(h.$ref&&p.def)for(const y in u)y==="$ref"||y==="allOf"||y in p.def&&JSON.stringify(u[y])===JSON.stringify(p.def[y])&&delete u[y]}const f=a._zod.parent;if(f&&f!==d){r(f);const p=e.seen.get(f);if(p?.schema.$ref&&(u.$ref=p.schema.$ref,p.def))for(const h in u)h==="$ref"||h==="allOf"||h in p.def&&JSON.stringify(u[h])===JSON.stringify(p.def[h])&&delete u[h]}e.override({zodSchema:a,jsonSchema:u,path:c.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(const a of[...e.seen.entries()].reverse())r(a[0]);if(e.target!=="openapi-3.0")for(const a of e.seen.entries())Em(a[1].def??a[1].schema);for(const a of e.deferred)a();if(e.intersections.length){const a=new Map;for(const c of e.seen.values())for(const u of[c.schema,c.def]){const l=u?.allOf;if(!Array.isArray(l))continue;const d=a.get(l);d?d.push(u):a.set(l,[u])}for(const c of e.intersections)for(const u of a.get(c)??[])Sw(u)}}const o={};if(e.target==="draft-2020-12"?o.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?o.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?o.$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");o.$id=e.external.uri(a)}jn(o,n.defId?n.schema:n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&o.id===i&&delete o.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,Fe(s,c.defId,c.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?o.$defs=s:o.definitions=s);try{const a=JSON.parse(JSON.stringify(o));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:qn(t,"input",e.processors),output:qn(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function ze(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const r=e._zod.def;if(r.type==="transform")return!0;if(r.type==="array")return ze(r.element,n);if(r.type==="set")return ze(r.valueType,n);if(r.type==="lazy")return ze(r.getter(),n);if(r.type==="promise"||r.type==="optional"||r.type==="nonoptional"||r.type==="nullable"||r.type==="readonly"||r.type==="default"||r.type==="prefault"||r.type==="catch")return ze(r.innerType,n);if(r.type==="intersection")return ze(r.left,n)||ze(r.right,n);if(r.type==="record"||r.type==="map")return ze(r.keyType,n)||ze(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:ze(r.in,n)||ze(r.out,n);if(r.type==="object"){for(const o in r.shape)if(ze(r.shape[o],n))return!0;return!1}if(r.type==="union"){for(const o of r.options)if(ze(o,n))return!0;return!1}if(r.type==="tuple"){for(const o of r.items)if(ze(o,n))return!0;return!!(r.rest&&ze(r.rest,n))}return!1}const Am=(e,t={})=>n=>{const r=en({...n,processors:t});return te(e,r),tn(r,e),nn(r,e)},qn=(e,t,n={})=>r=>{const{libraryOptions:o,target:i}=r??{},s=en({...o??{},target:i,io:t,processors:n});return te(e,s),tn(s,e),nn(s,e)},rn=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},on=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},ld=(e,t)=>{rn(e,"minimum",t),on(e,"maximum",t)},Nm=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Om=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Pm=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},Mm=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},dd=(e,t)=>rn(e,"minimum",t.minimum),fd=(e,t)=>on(e,"maximum",t.maximum),pd=e=>(t,n)=>{Mm(t,n.format);const[r,o]=e[n.format];rn(t,"minimum",r),on(t,"maximum",o)},Iw={greater_than:(e,t)=>rn(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>on(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Nm(e,t.value),number_format:pd(Js),bigint_format:pd(Ws),min_length:dd,max_length:fd,length_equals:(e,t)=>ld(e,t.length),min_size:dd,max_size:fd,size_equals:(e,t)=>ld(e,t.size),string_format:(e,t)=>{Mm(e,t.format),t.pattern&&Om(e,t.pattern),(t.format==="base64"||t.format==="base64url")&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Pm(e,t.mime)};function ge(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const i of r)Iw[i._zod.def.check]?.(t,i._zod.def);const o=e._zod.bag;o.minimum!==void 0&&rn(t,"minimum",o.minimum),o.exclusiveMinimum!==void 0&&rn(t,"exclusiveMinimum",o.exclusiveMinimum),o.maximum!==void 0&&on(t,"maximum",o.maximum),o.exclusiveMaximum!==void 0&&on(t,"exclusiveMaximum",o.exclusiveMaximum),o.multipleOf!==void 0&&Nm(t,o.multipleOf),o.format!==void 0&&(t.format??(t.format=o.format),o.format.includes("int")&&(t.isInt=!0)),o.mime&&Pm(t,o.mime);for(const i of o.patterns??[])Om(t,i);return t}const xw={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},zw=new Map([[za,Zf],[Go,jf]]),Rm=e=>zw.get(e)??e,Lm=(e,t,n,r)=>{const o=n;o.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:u,laxFormat:l}=ge(e);if(typeof i=="number"&&(o.minLength=i),typeof s=="number"&&(o.maxLength=s),a&&(o.format=xw[a]??a,o.format===""&&delete o.format,(a==="time"||l)&&delete o.format),u&&(o.contentEncoding=u),c&&c.size>0){const d=[...c].map(Rm);d.length===1?o.pattern=d[0].source:d.length>1&&(o.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},Dm=(e,t,n,r)=>{const o=n,{minimum:i,maximum:s,multipleOf:a,exclusiveMaximum:c,exclusiveMinimum:u,isInt:l}=ge(e);o.type=l?"integer":"number";const d=typeof u=="number"&&u>=(i??Number.NEGATIVE_INFINITY),f=typeof c=="number"&&c<=(s??Number.POSITIVE_INFINITY),p=t.target==="draft-04"||t.target==="openapi-3.0";if(d?p?(o.minimum=u,o.exclusiveMinimum=!0):o.exclusiveMinimum=u:typeof i=="number"&&(o.minimum=i),f?p?(o.maximum=c,o.exclusiveMaximum=!0):o.exclusiveMaximum=c:typeof s=="number"&&(o.maximum=s),a){const h=new Set;for(const $ of a)Number.isFinite($)&&$!==0?h.add(Math.abs($)):ye(e,t,o,r,`A multipleOf divisor of ${$} cannot be represented in JSON Schema`);const[m,...y]=h;m!==void 0&&(o.multipleOf=m),y.length&&(o.allOf=[...o.allOf??[],...y.map($=>({multipleOf:$}))])}},Zm=(e,t,n,r)=>{n.type="boolean"},jm=(e,t,n,r)=>{ye(e,t,n,r,"BigInt cannot be represented in JSON Schema")},Fm=(e,t,n,r)=>{ye(e,t,n,r,"Symbols cannot be represented in JSON Schema")},Um=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},Vm=(e,t,n,r)=>{ye(e,t,n,r,"Undefined cannot be represented in JSON Schema")},qm=(e,t,n,r)=>{ye(e,t,n,r,"Void cannot be represented in JSON Schema")},Hm=(e,t,n,r)=>{n.not={}},Bm=(e,t,n,r)=>{},Km=(e,t,n,r)=>{},Jm=(e,t,n,r)=>{ye(e,t,n,r,"Date cannot be represented in JSON Schema")},Wm=(e,t,n,r)=>{const o=e._zod.def,i=So(o.entries);if(i.length===0){n.not={};return}i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},Gm=(e,t,n,r)=>{const o=e._zod.def;if(o.values.length===0){n.not={};return}const i=[];for(const s of o.values)if(s===void 0){if(ye(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(ye(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){const s=i[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),i.every(s=>typeof s=="boolean")&&(n.type="boolean"),i.every(s=>s===null)&&(n.type="null"),n.enum=i},Ym=(e,t,n,r)=>{ye(e,t,n,r,"NaN cannot be represented in JSON Schema")},Qm=(e,t,n,r)=>{const o=n,i=e._zod.pattern;if(!i)throw new Error("Pattern not found in template literal");o.type="string",o.pattern=i.source},Xm=(e,t,n,r)=>{const o=n;o.type="string",o.format="binary",o.contentEncoding="binary";const{minimum:i,maximum:s,mime:a}=ge(e);i!==void 0&&(o.minLength=i),s!==void 0&&(o.maxLength=s),a&&(a.length===0?o.not={}:a.length===1?o.contentMediaType=a[0]:o.anyOf=a.map(c=>({contentMediaType:c})))},eg=(e,t,n,r)=>{n.type="boolean"},tg=(e,t,n,r)=>{ye(e,t,n,r,"Custom types cannot be represented in JSON Schema")},ng=(e,t,n,r)=>{ye(e,t,n,r,"Function types cannot be represented in JSON Schema")},rg=(e,t,n,r)=>{ye(e,t,n,r,"Transforms cannot be represented in JSON Schema")},og=(e,t,n,r)=>{ye(e,t,n,r,"Map cannot be represented in JSON Schema")},ig=(e,t,n,r)=>{ye(e,t,n,r,"Set cannot be represented in JSON Schema")},sg=(e,t,n,r)=>{const o=n,i=e._zod.def,{minimum:s,maximum:a}=ge(e);typeof s=="number"&&(o.minItems=s),typeof a=="number"&&(o.maxItems=a),o.type="array",o.items=te(i.element,t,{...r,path:[...r.path,"items"]})};function Hn(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?Hn(t.out):t.type==="catch"?Hn(t.innerType):e._zod.optin}const ag=(e,t,n,r)=>{const o=n,i=e._zod.def,s=i.shape;if(Object.getOwnPropertySymbols(s).length&&ye(e,t,o,r,"Symbol keys cannot be represented in JSON Schema"))return;o.type="object",o.properties={};for(const u in s)Fe(o.properties,u,te(s[u],t,{...r,path:[...r.path,"properties",u]}));const c=[];for(const u of Object.keys(s)){const l=i.shape[u];(t.io==="input"?Hn(l)===void 0:l._zod.optout===void 0)&&c.push(u)}c.length>0&&(o.required=c),i.catchall?._zod.def.type==="never"?o.additionalProperties=!1:i.catchall?i.catchall&&(o.additionalProperties=te(i.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(o.additionalProperties=!1)},wc=(e,t,n,r)=>{const o=e._zod.def,i=o.inclusive===!1,s=o.options.map((a,c)=>te(a,t,{...r,path:[...r.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s},cg=(e,t,n,r)=>{const o=e._zod.def,i=te(o.left,t,{...r,path:[...r.path,"allOf",0]}),s=te(o.right,t,{...r,path:[...r.path,"allOf",1]}),a=u=>"allOf"in u&&Object.keys(u).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c,t.intersections.push(c)},ug=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="array";const s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",c=i.items.map((m,y)=>te(m,t,{...r,path:[...r.path,s,y]})),u=i.rest?te(i.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[i.items.length]:[]]}):null;let l=i.items.length;for(;l>0;){const m=i.items[l-1];if(!(t.io==="input"?Hn(m)!==void 0:m._zod.optout==="optional"))break;l--}const d=i.items.length,f=!i.rest;t.target==="draft-2020-12"?(o.prefixItems=c,f?o.items=!1:u&&(o.items=u),l>0&&(o.minItems=l),f&&(o.maxItems=d)):t.target==="openapi-3.0"?(o.items={anyOf:c},u&&o.items.anyOf.push(u),l>0&&(o.minItems=l),f&&(o.maxItems=d)):(o.items=c,f?o.additionalItems=!1:u&&(o.additionalItems=u),l>0&&(o.minItems=l),f&&(o.maxItems=d));const{minimum:p,maximum:h}=ge(e);typeof p=="number"&&(o.minItems=p),typeof h=="number"&&(o.maxItems=h)};function As(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);const h=e.get(t)?.def;if(!h)return t;const m=As(e,h,n);return m===h?t:m}for(const h of["anyOf","oneOf"]){const m=t[h];if(!Array.isArray(m))continue;const y=m.map($=>As(e,$,n));y.some(($,w)=>$!==m[w])&&(t={...t,[h]:y})}const r=Array.isArray(t.type)?t.type:[t.type],o=!r.includes("string")&&r.some(h=>h==="number"||h==="integer"),i=t.enum??(t.const!==void 0?[t.const]:void 0);if(!o&&!i?.some(h=>typeof h=="number"))return t;const{minimum:s,maximum:a,exclusiveMinimum:c,exclusiveMaximum:u,multipleOf:l,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(h=>typeof h=="number"?String(h):h):typeof p.const=="number"&&(p.const=String(p.const)),o&&(p.type="string",i||(p.pattern=(r.includes("number")?ln:ha).source)),p}const Ns=new WeakMap;function Tw(e){const t=new Map;for(const r of e.seen.values())r.def&&!t.has(r.schema)&&t.set(r.schema,r);const n=new Map;for(const r of Ns.get(e)??[]){const o=e.seen.get(r),i=(o?.def??o?.schema)?.propertyNames;if(!i||i===!0||n.has(i))continue;const s=As(t,i,new Set);s!==i&&n.set(i,s)}if(n.size)for(const r of e.seen.values())for(const o of[r.schema,r.def]){const i=o&&n.get(o.propertyNames);i&&(o.propertyNames=i)}}const lg=(e,t,n,r)=>{const o=n,i=e._zod.def;o.type="object";const s=i.keyType,a=ge(s).patterns;if(i.mode==="loose"&&a&&a.size>0){const l=te(i.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});o.patternProperties={};for(const d of a)Fe(o.patternProperties,Rm(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){o.propertyNames=te(i.keyType,t,{...r,path:[...r.path,"propertyNames"]});let l=Ns.get(t);l||(l=[],Ns.set(t,l),t.deferred.push(()=>Tw(t))),l.push(e)}o.additionalProperties=te(i.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const c=s._zod.values,u=t.io==="input"&&Hn(i.valueType)!==void 0;if(c&&!i.partial&&!u){const l=[...c].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(o.required=l.map(String))}},dg=(e,t,n,r)=>{const o=e._zod.def,i=te(o.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=o.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},fg=(e,t,n,r)=>{const o=e._zod.def;te(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},vc=Symbol();function pg(e,t,n,r,o){let i=!1;const s=JSON.stringify(e,(a,c)=>typeof c!="bigint"?c:(i=!0,null));return i?(ye(t,n,r,o,"BigInt defaults cannot be represented in JSON Schema"),vc):JSON.parse(s)}const hg=(e,t,n,r)=>{const o=e._zod.def;te(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;const s=pg(o.defaultValue,e,t,n,r);s!==vc&&(n.default=s)},mg=(e,t,n,r)=>{const o=e._zod.def;te(o.innerType,t,r);const i=t.seen.get(e);if(i.ref=o.innerType,t.io!=="input")return;const s=pg(o.defaultValue,e,t,n,r);s!==vc&&(n._prefault=s)},gg=(e,t,n,r)=>{const o=e._zod.def;te(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType;let s;try{s=o.catchValue(void 0)}catch{ye(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},yg=(e,t,n,r)=>{const o=e._zod.def,i=o.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?o.out:o.in:o.out;te(s,t,r);const a=t.seen.get(e);a.ref=s},_g=(e,t,n,r)=>{const o=e._zod.def;te(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType,n.readOnly=!0},bg=(e,t,n,r)=>{const o=e._zod.def;te(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},kc=(e,t,n,r)=>{const o=e._zod.def;te(o.innerType,t,r);const i=t.seen.get(e);i.ref=o.innerType},wg=(e,t,n,r)=>{const o=e._zod.innerType;te(o,t,r);const i=t.seen.get(e);i.ref=o},Os={string:Lm,number:Dm,boolean:Zm,bigint:jm,symbol:Fm,null:Um,undefined:Vm,void:qm,never:Hm,any:Bm,unknown:Km,date:Jm,enum:Wm,literal:Gm,nan:Ym,template_literal:Qm,file:Xm,success:eg,custom:tg,function:ng,transform:rg,map:og,set:ig,array:sg,object:ag,union:wc,intersection:cg,tuple:ug,record:lg,nullable:dg,nonoptional:fg,default:hg,prefault:mg,catch:gg,pipe:yg,readonly:_g,promise:bg,optional:kc,lazy:wg};function $c(e,t){if("_idmap"in e){const r=e,o=en({...t,processors:Os}),i={};for(const c of r._idmap.entries()){const[u,l]=c;te(l,o)}const s={},a={registry:r,uri:t?.uri,defs:i};o.external=a;for(const c of r._idmap.entries()){const[u,l]=c;tn(o,l),Fe(s,u,nn(o,l))}if(Object.keys(i).length>0){const c=o.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[c]:i}}return{schemas:s}}const n=en({...t,processors:Os});return te(e,n),tn(n,e),nn(n,e)}class Ew{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 n=t?.target??"draft-2020-12";n==="draft-4"&&(n="draft-04"),n==="draft-7"&&(n="draft-07"),this.ctx=en({processors:Os,target:n,...t?.metadata&&{metadata:t.metadata},...t?.unrepresentable&&{unrepresentable:t.unrepresentable},...t?.override&&{override:t.override},...t?.io&&{io:t.io}})}process(t,n={path:[],schemaPath:[]}){return te(t,this.ctx,n)}emit(t,n){n&&(n.cycles&&(this.ctx.cycles=n.cycles),n.reused&&(this.ctx.reused=n.reused),n.external&&(this.ctx.external=n.external)),this.ctx.sharedDefsExtractedFor=void 0,this.ctx.sharedEmitDoneFor=void 0,tn(this.ctx,t);const r=nn(this.ctx,t),{"~standard":o,...i}=r;return i}}const Cw=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),vg=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:oh,$ZodArray:uh,$ZodAsyncError:st,$ZodBase64:Bp,$ZodBase64URL:Kp,$ZodBigInt:Pa,$ZodBigIntFormat:eh,$ZodBoolean:Oa,$ZodCIDRv4:qp,$ZodCIDRv6:Hp,$ZodCUID:Np,$ZodCUID2:Op,$ZodCatch:Ah,$ZodCheck:ie,$ZodCheckBigIntFormat:sp,$ZodCheckEndsWith:_p,$ZodCheckGreaterThan:_a,$ZodCheckIncludes:gp,$ZodCheckLengthEquals:fp,$ZodCheckLessThan:ya,$ZodCheckLowerCase:hp,$ZodCheckMaxLength:lp,$ZodCheckMaxSize:ap,$ZodCheckMimeType:vp,$ZodCheckMinLength:dp,$ZodCheckMinSize:cp,$ZodCheckMultipleOf:op,$ZodCheckNumberFormat:ip,$ZodCheckOverwrite:kp,$ZodCheckProperties:wp,$ZodCheckProperty:bp,$ZodCheckRegex:pp,$ZodCheckSizeEquals:up,$ZodCheckStartsWith:yp,$ZodCheckStringFormat:sr,$ZodCheckUpperCase:mp,$ZodCodec:Za,$ZodCreditCard:Wp,$ZodCustom:Dh,$ZodCustomStringFormat:Qp,$ZodCyclicError:Zh,$ZodDate:ch,$ZodDefault:zh,$ZodDiscriminatedUnion:gh,$ZodE164:Jp,$ZodEmail:zp,$ZodEmoji:Cp,$ZodEncodeError:Fo,$ZodEnum:vh,$ZodError:_f,$ZodExactOptional:Ih,$ZodFile:$h,$ZodFunction:Rh,$ZodGUID:Ip,$ZodIBAN:Gp,$ZodIPv4:Fp,$ZodIPv6:Up,$ZodISODate:Dp,$ZodISODateTime:Lp,$ZodISODuration:jp,$ZodISOTime:Zp,$ZodIntersection:yh,$ZodJWT:Yp,$ZodKSUID:Rp,$ZodLazy:ja,$ZodLiteral:kh,$ZodMAC:Vp,$ZodMap:bh,$ZodNaN:Nh,$ZodNanoID:Ap,$ZodNever:sh,$ZodNonOptional:Eh,$ZodNull:rh,$ZodNullable:xh,$ZodNumber:Na,$ZodNumberFormat:Xp,$ZodObject:fh,$ZodObjectJIT:ph,$ZodOptional:La,$ZodPipe:Da,$ZodPrefault:Th,$ZodPreprocess:Oh,$ZodPromise:Lh,$ZodReadonly:Ph,$ZodRealError:Ue,$ZodRecord:_h,$ZodRegistry:Uh,$ZodSet:wh,$ZodString:ar,$ZodStringFormat:ne,$ZodSuccess:Ch,$ZodSymbol:th,$ZodTemplateLiteral:Mh,$ZodTransform:Sh,$ZodTuple:Ra,$ZodType:D,$ZodULID:Pp,$ZodURL:Ep,$ZodUUID:xp,$ZodUndefined:nh,$ZodUnion:Yo,$ZodUnknown:ih,$ZodVoid:ah,$ZodXID:Mp,$ZodXor:hh,$brand:ea,$constructor:g,$input:Ha,$output:qa,Doc:ba,INVALID:Ce,JSONSchema:Cw,JSONSchemaGenerator:Ew,NEVER:Xs,TimePrecision:mc,URL_BAD_FORMAT:va,URL_UNPARSEABLE:Un,ZodCompileAsyncError:dt,ZodCompileUnsupportedError:B,_any:pm,_array:wm,_base64:dc,_base64url:fc,_bigint:sm,_boolean:om,_catch:_w,_check:Im,_cidrv4:uc,_cidrv6:lc,_coercedBigint:am,_coercedBoolean:im,_coercedDate:_m,_coercedNumber:Qh,_coercedString:Kh,_creditCard:Wh,_cuid:nc,_cuid2:rc,_custom:km,_date:ym,_decode:oa,_decodeAsync:sa,_default:mw,_discriminatedUnion:rw,_e164:pc,_email:Ja,_emoji:ec,_encode:ra,_encodeAsync:ia,_endsWith:pr,_enum:uw,_file:vm,_float32:em,_float64:tm,_gt:pt,_gte:je,_guid:Wa,_iban:Gh,_includes:dr,_int:Xh,_int32:nm,_int64:cm,_intersection:ow,_ipv4:ac,_ipv6:cc,_isoDate:yc,_isoDateTime:gc,_isoDuration:bc,_isoTime:_c,_jwt:hc,_ksuid:sc,_lazy:kw,_length:pn,_literal:dw,_lowercase:ur,_lt:ft,_lte:Ze,_mac:Jh,_map:aw,_max:Ze,_maxLength:fn,_maxSize:qt,_mime:mr,_min:je,_minLength:St,_minSize:ht,_multipleOf:jt,_nan:bm,_nanoid:tc,_nativeEnum:lw,_negative:ii,_never:mm,_nonnegative:ai,_nonoptional:gw,_nonpositive:si,_normalize:gr,_null:fm,_nullable:hw,_number:Yh,_optional:pw,_overwrite:tt,_parse:er,_parseAsync:tr,_pipe:bw,_positive:oi,_promise:$w,_properties:hr,_property:ci,_readonly:ww,_record:sw,_refine:$m,_regex:cr,_safeDecode:ca,_safeDecodeAsync:la,_safeEncode:aa,_safeEncodeAsync:ua,_safeParse:nr,_safeParseAsync:rr,_set:cw,_size:dn,_slugify:wr,_startsWith:fr,_string:Bh,_stringFormat:hn,_stringbool:Tm,_success:yw,_superRefine:Sm,_symbol:lm,_templateLiteral:vw,_toLowerCase:_r,_toUpperCase:br,_transform:fw,_trim:yr,_tuple:iw,_uint32:rm,_uint64:um,_ulid:oc,_undefined:dm,_union:tw,_unknown:hm,_uppercase:lr,_url:ri,_uuid:Ga,_uuidv4:Ya,_uuidv6:Qa,_uuidv7:Xa,_void:gm,_xid:ic,_xor:nw,base64Charset:za,base64urlCharset:Go,canParseURL:ka,clone:oe,compile:Ba,compileFn:ti,config:me,createStandardJSONSchemaMethod:qn,createToJSONSchemaMethod:Am,decode:p_,decodeAsync:m_,describe:xm,encode:f_,encodeAsync:h_,extractDefs:tn,finalize:nn,flattenError:Uo,formatError:Vo,getDiscriminatedOption:Ma,globalConfig:Ee,globalRegistry:Le,handleUnrepresentable:ye,initializeContext:en,isBackEdge:Ua,isRecursiveSchema:Fa,isValidBase64:Wo,isValidBase64URL:Ta,isValidCIDRv6:xa,isValidCreditCard:Ea,isValidIBAN:Ca,isValidIPv6:Jo,isValidJWT:Aa,locales:Va,memoizer:Qo,mergeValues:Vn,meta:zm,parse:$s,parseAsync:Ss,parseURLObject:Tp,prettifyError:na,process:te,processSchema:te,regexes:Ko,registry:Xo,safeDecode:y_,safeDecodeAsync:b_,safeEncode:g_,safeEncodeAsync:__,safeParse:wf,safeParseAsync:c_,standardProps:wa,stripTabAndNewline:Eo,toDotPath:bf,toJSONSchema:$c,toZod:Mo,treeifyError:ta,urlHostnameOk:Sa,urlProtocolOk:Ia,util:Qs,validate:Ho,validateAsync:Bo,validateURL:$a,version:$p,withParser:ei},Symbol.toStringTag,{value:"Module"})),hd=Symbol("z.visit/resolving");function Sc(e,t){const n=typeof t=="function"?t:(s,a)=>{const c=t[s._zod.def.type];return c?c(s,a):s},r=new Map;function o(s){const a=r.get(s);if(a===hd)return new ja({type:"lazy",getter:()=>r.get(s)});if(a!==void 0)return a;r.set(s,hd);const c=i(s),u=n(c,c!==s);return r.set(s,u),u}function i(s){const a=s._zod.def;switch(a.type){case"object":{const u=a.shape,l=Object.keys(u);let d=!1;const f={};for(const h of l){const m=o(u[h]);m!==u[h]&&(d=!0),f[h]=m}let p=a.catchall;return a.catchall&&(p=o(a.catchall),p!==a.catchall&&(d=!0)),d?oe(s,{...a,shape:f,catchall:p}):s}case"array":{const u=o(a.element);return u===a.element?s:oe(s,{...a,element:u})}case"tuple":{const u=a.items;let l=!1;const d=[];for(const p of u){const h=o(p);h!==p&&(l=!0),d.push(h)}let f=a.rest;return a.rest&&(f=o(a.rest),f!==a.rest&&(l=!0)),l?oe(s,{...a,items:d,rest:f}):s}case"record":case"map":{const u=o(a.keyType),l=o(a.valueType);return u===a.keyType&&l===a.valueType?s:oe(s,{...a,keyType:u,valueType:l})}case"set":{const u=o(a.valueType);return u===a.valueType?s:oe(s,{...a,valueType:u})}case"union":{const u=a.options;let l=!1;const d=[];for(const f of u){const p=o(f);p!==f&&(l=!0),d.push(p)}return l?oe(s,{...a,options:d}):s}case"intersection":{const u=o(a.left),l=o(a.right);return u===a.left&&l===a.right?s:oe(s,{...a,left:u,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{const u=o(a.innerType);return u===a.innerType?s:oe(s,{...a,innerType:u})}case"pipe":{const u=o(a.in),l=o(a.out);return u===a.in&&l===a.out?s:oe(s,{...a,in:u,out:l})}case"function":{const u=o(a.input),l=o(a.output);return u===a.input&&l===a.output?s:oe(s,{...a,input:u,output:l})}case"lazy":{const u=a.getter,{_cachedInner:l,...d}=a;return oe(s,{...d,getter:()=>o(u())})}case"template_literal":case"string":case"number":case"int":case"boolean":case"bigint":case"symbol":case"undefined":case"null":case"void":case"never":case"any":case"unknown":case"date":case"nan":case"enum":case"literal":case"file":case"transform":case"custom":return s;default:return s}}return o(e)}function Ic(e){return!!e._zod}function kg(e,t){return Ic(e)?wf(e,t):e.safeParse(t)}function Aw(e){if(!e)return;let t;if(Ic(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function Nw(e){if(Ic(e)){const i=e._zod?.def;if(i){if(i.value!==void 0)return i.value;if(Array.isArray(i.values)&&i.values.length>0)return i.values[0]}}const n=e._def;if(n){if(n.value!==void 0)return n.value;if(Array.isArray(n.values)&&n.values.length>0)return n.values[0]}const r=e.value;if(r!==void 0)return r}const Ow=()=>{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"},map:{unit:"entries",verb:"to have"}};function t(i){return e[i]??null}const n={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",currency_code:"currency code",credit_card:"credit card number",iban:"IBAN",jwt:"JWT",template_literal:"input"},r={nan:"NaN"};function o(i,s){return i==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[i]??i}return i=>{switch(i.code){case"invalid_type":{const s=o(i.expected),a=ff(i.input),c=o(a,i.input);return`Invalid input: expected ${s}, received ${c}`}case"invalid_value":return i.values.length===1?`Invalid input: expected ${Ks(i.values[0])}`:`Invalid option: expected one of ${ws(i.values,"|")}`;case"too_big":{const s=i.exact?"exactly ":i.inclusive?"<=":"<",a=t(i.origin);return a?`Too big: expected ${i.origin??"value"} to have ${s}${i.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${i.origin??"value"} to be ${s}${i.maximum.toString()}`}case"too_small":{const s=i.exact?"exactly ":i.inclusive?">=":">",a=t(i.origin);return a?`Too small: expected ${i.origin} to have ${s}${i.minimum.toString()} ${a.unit}`:`Too small: expected ${i.origin} to be ${s}${i.minimum.toString()}`}case"invalid_format":{const s=i;return s.format==="starts_with"?`Invalid string: must start with "${s.prefix}"`:s.format==="ends_with"?`Invalid string: must end with "${s.suffix}"`:s.format==="includes"?`Invalid string: must include "${s.includes}"`:s.format==="regex"?`Invalid string: must match pattern ${s.pattern}`:`Invalid ${n[s.format]??i.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${i.divisor}`;case"unrecognized_keys":return`Unrecognized key${i.keys.length>1?"s":""}: ${ws(i.keys,", ")}`;case"invalid_key":return`Invalid key in ${i.origin}`;case"invalid_union":return i.options&&Array.isArray(i.options)&&i.options.length>0?`Invalid discriminator value. Expected ${i.options.map(a=>`'${a}'`).join(" | ")}`:i.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${i.origin}`;default:return"Invalid input"}}};function Pw(){return{localeError:Ow()}}const Mw=Object.freeze(Object.defineProperty({__proto__:null,endsWith:pr,gt:pt,gte:je,includes:dr,length:pn,lowercase:ur,lt:ft,lte:Ze,maxLength:fn,maxSize:qt,mime:mr,minLength:St,minSize:ht,multipleOf:jt,negative:ii,nonnegative:ai,nonpositive:si,normalize:gr,overwrite:tt,positive:oi,properties:hr,property:ci,regex:cr,size:dn,slugify:wr,startsWith:fr,toLowerCase:_r,toUpperCase:br,trim:yr,uppercase:lr},Symbol.toStringTag,{value:"Module"})),md=new WeakSet([Object.prototype,Error.prototype]);function fo(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){const r=n(this);return Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0}),r},set(r){Object.defineProperty(this,t,{value:r,configurable:!0,writable:!0})}})}const $g=(e,t)=>{_f.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);md.has(n)||(md.add(n),fo(n,"format",r=>o=>Vo(r,o)),fo(n,"flatten",r=>o=>Uo(r,o)),fo(n,"addIssue",r=>o=>{r.issues.push(o),r.message=JSON.stringify(r.issues,Io,2)}),fo(n,"addIssues",r=>o=>{r.issues.push(...o),r.message=JSON.stringify(r.issues,Io,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Sg=g("ZodError",$g),Ne=g("ZodError",$g,void 0,{Parent:Error}),xc=er(Ne),zc=tr(Ne),Tc=nr(Ne),Ec=rr(Ne),Cc=ra(Ne),Ac=oa(Ne),Nc=ia(Ne),Oc=sa(Ne),Pc=aa(Ne),Mc=ca(Ne),Rc=ua(Ne),Lc=la(Ne);function Rw(){Ee.localeError||me(Pw())}function Ht(){Ee.memoizer||me({memoizer:Qo()})}const j=g("ZodType",(e,t)=>(Rw(),D.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(Se(t,{checks:[...t.checks??[],...e.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return oe(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Gi(e,t))},superRefine(e,t){return this.check(Yi(e,t))},overwrite(e){return this.check(tt(e))},optional(){return re(this)},exactOptional(){return Ci(this)},nullable(){return an(this)},nullish(){return re(an(this))},nonoptional(e){return Ri(this,e)},array(){return M(this)},or(e){return F([this,e])},and(e){return xn(this,e)},transform(e){return Kn(this,qr(e))},default(e){return Oi(this,e)},prefault(e){return Mi(this,e)},catch(e){return Zi(this,e)},pipe(e){return Kn(this,e)},readonly(){return Vi(this)},describe(e){const t=this.clone();return Le.add(t,{description:e}),t},meta(...e){if(e.length===0)return Le.get(this);const t=this.clone();return Le.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return jo(this,"~standard",{...wa(this),jsonSchema:{input:qn(this,"input"),output:qn(this,"output")}})},set"~standard"(e){lt(this,"~standard",e)},parse:function e(t,n){return xc(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await zc(this,t,n,{callee:e})},safeParse(e,t){return Tc(this,e,t)},async safeParseAsync(e,t){return Ec(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){lt(this,"spa",e)},validate(e,t){return Ho(this,e,t)},validateAsync(e,t){return Bo(this,e,t)},encode:function e(t,n){return Cc(this,t,n,{callee:e})},decode:function e(t,n){return Ac(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Nc(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Oc(this,t,n,{callee:e})},safeEncode(e,t){return Pc(this,e,t)},safeDecode(e,t){return Mc(this,e,t)},async safeEncodeAsync(e,t){return Rc(this,e,t)},async safeDecodeAsync(e,t){return Lc(this,e,t)},toJSONSchema(e){return Am(this,{})(e)},get description(){return Le.get(this)?.description},get _def(){return this._zod.def}}),vr=g("_ZodString",(e,t)=>{ar.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Lm(e,n,r)},Xn({format:e=>ge(e).format??null,minLength:e=>ge(e).minimum??null,maxLength:e=>ge(e).maximum??null},{regex(...e){return this.check(cr(...e))},includes(...e){return this.check(dr(...e))},startsWith(...e){return this.check(fr(...e))},endsWith(...e){return this.check(pr(...e))},min(...e){return this.check(St(...e))},max(...e){return this.check(fn(...e))},length(...e){return this.check(pn(...e))},nonempty(...e){return this.check(St(1,...e))},lowercase(e){return this.check(ur(e))},uppercase(e){return this.check(lr(e))},trim(){return this.check(yr())},normalize(...e){return this.check(gr(...e))},toLowerCase(){return this.check(_r())},toUpperCase(){return this.check(br())},slugify(){return this.check(wr())}})),mn=g("ZodString",(e,t)=>{ar.init(e,t),vr.init(e,t)},{email(e){return this.check(Ja(kr,e))},url(e){return this.check(ri(wn,e))},jwt(e){return this.check(hc(Dr,e))},emoji(e){return this.check(ec(Sr,e))},guid(e){return this.check(Wa($r,e))},uuid(e){return this.check(Ga(Ge,e))},uuidv4(e){return this.check(Ya(Ge,e))},uuidv6(e){return this.check(Qa(Ge,e))},uuidv7(e){return this.check(Xa(Ge,e))},nanoid(e){return this.check(tc(Ir,e))},cuid(e){return this.check(nc(xr,e))},cuid2(e){return this.check(rc(zr,e))},ulid(e){return this.check(oc(Tr,e))},base64(e){return this.check(dc(Mr,e))},base64url(e){return this.check(fc(Rr,e))},xid(e){return this.check(ic(Er,e))},ksuid(e){return this.check(sc(Cr,e))},ipv4(e){return this.check(ac(Ar,e))},ipv6(e){return this.check(cc(Nr,e))},cidrv4(e){return this.check(uc(Or,e))},cidrv6(e){return this.check(lc(Pr,e))},e164(e){return this.check(pc(Lr,e))},datetime(e){return this.check(gc(gn,e))},date(e){return this.check(yc(yn,e))},time(e){return this.check(_c(_n,e))},duration(e){return this.check(bc(bn,e))}});function _(e){return Bh(mn,e)}const ee=g("ZodStringFormat",(e,t)=>{ne.init(e,t),vr.init(e,t)}),gn=g("ZodISODateTime",(e,t)=>{Lp.init(e,t),ee.init(e,t)}),yn=g("ZodISODate",(e,t)=>{Dp.init(e,t),ee.init(e,t)}),_n=g("ZodISOTime",(e,t)=>{Zp.init(e,t),ee.init(e,t)}),bn=g("ZodISODuration",(e,t)=>{jp.init(e,t),ee.init(e,t)}),kr=g("ZodEmail",(e,t)=>{zp.init(e,t),ee.init(e,t)});function Dc(e){return Ja(kr,e)}const $r=g("ZodGUID",(e,t)=>{Ip.init(e,t),ee.init(e,t)});function Zc(e){return Wa($r,e)}const Ge=g("ZodUUID",(e,t)=>{xp.init(e,t),ee.init(e,t)});function jc(e){return Ga(Ge,e)}function Fc(e){return Ya(Ge,e)}function Uc(e){return Qa(Ge,e)}function Vc(e){return Xa(Ge,e)}const wn=g("ZodURL",(e,t)=>{Ep.init(e,t),ee.init(e,t)});function qc(e){return ri(wn,e)}function Hc(e){return ri(wn,{protocol:da,hostname:Uf,...I(e)})}const Sr=g("ZodEmoji",(e,t)=>{Cp.init(e,t),ee.init(e,t)});function Bc(e){return ec(Sr,e)}const Ir=g("ZodNanoID",(e,t)=>{Ap.init(e,t),ee.init(e,t)});function Kc(e){return tc(Ir,e)}const xr=g("ZodCUID",(e,t)=>{Np.init(e,t),ee.init(e,t)});function Jc(e){return nc(xr,e)}const zr=g("ZodCUID2",(e,t)=>{Op.init(e,t),ee.init(e,t)});function Wc(e){return rc(zr,e)}const Tr=g("ZodULID",(e,t)=>{Pp.init(e,t),ee.init(e,t)});function Gc(e){return oc(Tr,e)}const Er=g("ZodXID",(e,t)=>{Mp.init(e,t),ee.init(e,t)});function Yc(e){return ic(Er,e)}const Cr=g("ZodKSUID",(e,t)=>{Rp.init(e,t),ee.init(e,t)});function Qc(e){return sc(Cr,e)}const Ar=g("ZodIPv4",(e,t)=>{Fp.init(e,t),ee.init(e,t)});function Xc(e){return ac(Ar,e)}const ui=g("ZodMAC",(e,t)=>{Vp.init(e,t),ee.init(e,t)});function eu(e){return Jh(ui,e)}const Nr=g("ZodIPv6",(e,t)=>{Up.init(e,t),ee.init(e,t)});function tu(e){return cc(Nr,e)}const Or=g("ZodCIDRv4",(e,t)=>{qp.init(e,t),ee.init(e,t)});function nu(e){return uc(Or,e)}const Pr=g("ZodCIDRv6",(e,t)=>{Hp.init(e,t),ee.init(e,t)});function ru(e){return lc(Pr,e)}const Mr=g("ZodBase64",(e,t)=>{Bp.init(e,t),ee.init(e,t)});function ou(e){return dc(Mr,e)}const Rr=g("ZodBase64URL",(e,t)=>{Kp.init(e,t),ee.init(e,t)});function iu(e){return fc(Rr,e)}const Lr=g("ZodE164",(e,t)=>{Jp.init(e,t),ee.init(e,t)});function su(e){return pc(Lr,e)}const li=g("ZodCreditCard",(e,t)=>{Wp.init(e,t),ee.init(e,t)});function au(e){return Wh(li,e)}const di=g("ZodIBAN",(e,t)=>{Gp.init(e,t),ee.init(e,t)});function cu(e){return Gh(di,e)}const Dr=g("ZodJWT",(e,t)=>{Yp.init(e,t),ee.init(e,t)});function uu(e){return hc(Dr,e)}const It=g("ZodCustomStringFormat",(e,t)=>{Qp.init(e,t),ee.init(e,t)});function lu(e,t,n={}){return hn(It,e,t,n)}function du(e){return hn(It,"hostname",Ff,e)}function fu(e){return hn(It,"hex",rp,e)}function pu(e){return hn(It,"currency_code",qf,e)}function hu(e,t){const n=t?.enc??"hex",r=`${e}_${n}`,o=Ko[r];if(!o)throw new Error(`Unrecognized hash format: ${r}`);return hn(It,r,o,t)}const vn=g("ZodNumber",(e,t)=>{Na.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Dm(e,n,r,o),e.isFinite=!0},Xn({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=ge(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=ge(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=ge(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>ge(e).format??null},{gt(e,t){return this.check(pt(e,t))},gte(e,t){return this.check(je(e,t))},min(e,t){return this.check(je(e,t))},lt(e,t){return this.check(ft(e,t))},lte(e,t){return this.check(Ze(e,t))},max(e,t){return this.check(Ze(e,t))},int(e){return this.check(Bn(e))},safe(e){return this.check(Bn(e))},positive(e){return this.check(pt(0,e))},nonnegative(e){return this.check(je(0,e))},negative(e){return this.check(ft(0,e))},nonpositive(e){return this.check(Ze(0,e))},multipleOf(e,t){return this.check(jt(e,t))},step(e,t){return this.check(jt(e,t))},finite(){return this}}));function Z(e){return Yh(vn,e)}const xt=g("ZodNumberFormat",(e,t)=>{Xp.init(e,t),vn.init(e,t)});function Bn(e){return Xh(xt,e)}function mu(e){return em(xt,e)}function gu(e){return tm(xt,e)}function yu(e){return nm(xt,e)}function _u(e){return rm(xt,e)}const kn=g("ZodBoolean",(e,t)=>{Oa.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Zm(e,n,r)});function X(e){return om(kn,e)}const $n=g("ZodBigInt",(e,t)=>{Pa.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>jm(e,n,r,o)},Xn({minValue:e=>ge(e).minimum??null,maxValue:e=>ge(e).maximum??null,format:e=>ge(e).format??null},{gte(e,t){return this.check(je(e,t))},min(e,t){return this.check(je(e,t))},gt(e,t){return this.check(pt(e,t))},lt(e,t){return this.check(ft(e,t))},lte(e,t){return this.check(Ze(e,t))},max(e,t){return this.check(Ze(e,t))},positive(e){return this.check(pt(BigInt(0),e))},negative(e){return this.check(ft(BigInt(0),e))},nonpositive(e){return this.check(Ze(BigInt(0),e))},nonnegative(e){return this.check(je(BigInt(0),e))},multipleOf(e,t){return this.check(jt(e,t))}}));function bu(e){return sm($n,e)}const Zr=g("ZodBigIntFormat",(e,t)=>{eh.init(e,t),$n.init(e,t)});function wu(e){return cm(Zr,e)}function vu(e){return um(Zr,e)}const fi=g("ZodSymbol",(e,t)=>{th.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Fm(e,n,r,o)});function ku(e){return lm(fi,e)}const pi=g("ZodUndefined",(e,t)=>{nh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Vm(e,n,r,o)});function sn(e){return dm(pi,e)}const hi=g("ZodNull",(e,t)=>{rh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Um(e,n,r)});function jr(e){return fm(hi,e)}const mi=g("ZodAny",(e,t)=>{oh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Bm()});function Fr(){return pm(mi)}const gi=g("ZodUnknown",(e,t)=>{ih.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Km()});function Y(){return hm(gi)}const yi=g("ZodNever",(e,t)=>{sh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Hm(e,n,r)});function Ft(e){return mm(yi,e)}const _i=g("ZodVoid",(e,t)=>{ah.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>qm(e,n,r,o)});function $u(e){return gm(_i,e)}const Ur=g("ZodDate",(e,t)=>{ch.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Jm(e,n,r,o),e.min=(n,r)=>e.check(je(n,r)),e.max=(n,r)=>e.check(Ze(n,r))},Xn({minDate:e=>{const{minimum:t}=ge(e);return t?new Date(t):null},maxDate:e=>{const{maximum:t}=ge(e);return t?new Date(t):null}},{}));function Su(e){return ym(Ur,e)}const bi=g("ZodArray",(e,t)=>{Ht(),uh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>sg(e,n,r,o),e.element=t.element},{min(e,t){return this.check(St(e,t))},nonempty(e){return this.check(St(1,e))},max(e,t){return this.check(fn(e,t))},length(e,t){return this.check(pn(e,t))},unwrap(){return this.element}});function M(e,t){return wm(bi,e,t)}function Iu(e){const t=e._zod.def.shape;return we(Object.keys(t))}const Sn=g("ZodObject",(e,t)=>{Ht(),ph.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ag(e,n,r,o),gf(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return we(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Se(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Se(this._zod.def,{catchall:Y()}))},loose(){return this.clone(Se(this._zod.def,{catchall:Y()}))},strict(){return this.clone(Se(this._zod.def,{catchall:Ft()}))},strip(){return this.clone(Se(this._zod.def,{catchall:void 0}))},extend(e){return sf(this,e)},safeExtend(e){return cf(this,e)},merge(e){return uf(this,e)},pick(e){return rf(this,e)},omit(e){return of(this,e)},partial(...e){return vs(zn,this,e[0])},exactPartial(...e){return vs(Hr,this,e[0],"exactPartial")},required(...e){return lf(Br,this,e[0])}});function v(e,t){const n={type:"object",shape:e??{},...I(t)};return new Sn(n)}function xu(e,t){return new Sn({type:"object",shape:e,catchall:Ft(),...I(t)})}function be(e,t){return new Sn({type:"object",shape:e,catchall:Y(),...I(t)})}const In=g("ZodUnion",(e,t)=>{Yo.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wc(e,n,r,o),e.options=t.options});function F(e,t){return new In({type:"union",options:e,...I(t)})}const wi=g("ZodXor",(e,t)=>{In.init(e,t),hh.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wc(e,n,r,o),e.options=t.options});function zu(e,t){return new wi({type:"union",options:e,inclusive:!1,...I(t)})}const vi=g("ZodDiscriminatedUnion",(e,t)=>{In.init(e,t),gh.init(e,t)});function Vr(e,t,n){return new vi({type:"union",options:t,discriminator:e,...I(n)})}const ki=g("ZodIntersection",(e,t)=>{yh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>cg(e,n,r,o)});function xn(e,t){return new ki({type:"intersection",left:e,right:t})}const $i=g("ZodTuple",(e,t)=>{Ht(),Ra.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ug(e,n,r,o)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){const e=this._zod.def;if(e.checks?.length)throw new Error(".partial() cannot be used on tuple schemas containing refinements");return this.clone({...e,items:e.items.map(t=>new zn({type:"optional",innerType:t}))})}});function Si(e,t,n){const r=t instanceof D,o=r?n:t,i=r?t:null;return new $i({type:"tuple",items:e,rest:i,...I(o)})}const Ut=g("ZodRecord",(e,t)=>{Ht(),_h.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>lg(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType});function q(e,t,n){return!t||!t._zod?new Ut({type:"record",keyType:_(),valueType:e,...I(t)}):new Ut({type:"record",keyType:e,valueType:t,...I(n)})}function Tu(e,t,n){return new Ut({type:"record",keyType:e,valueType:t,...I(n),partial:!0})}function Eu(e,t,n){return new Ut({type:"record",keyType:e,valueType:t,mode:"loose",...I(n)})}const Ii=g("ZodMap",(e,t)=>{Ht(),bh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>og(e,n,r,o),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(ht(...n)),e.nonempty=n=>e.check(ht(1,n)),e.max=(...n)=>e.check(qt(...n)),e.size=(...n)=>e.check(dn(...n))});function Cu(e,t,n){return new Ii({type:"map",keyType:e,valueType:t,...I(n)})}const xi=g("ZodSet",(e,t)=>{Ht(),wh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ig(e,n,r,o),e.min=(...n)=>e.check(ht(...n)),e.nonempty=n=>e.check(ht(1,n)),e.max=(...n)=>e.check(qt(...n)),e.size=(...n)=>e.check(dn(...n))});function Au(e,t){return new xi({type:"set",valueType:e,...I(t)})}const Vt=g("ZodEnum",(e,t)=>{vh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(r,o,i)=>Wm(e,r,o),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(r,o)=>{const i={};for(const s of r)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Vt({...t,checks:[],...I(o),entries:i})},e.exclude=(r,o)=>{const i={...t.entries};for(const s of r)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new Vt({...t,checks:[],...I(o),entries:i})}});function we(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Vt({type:"enum",entries:n,...I(t)})}function Nu(e,t){return new Vt({type:"enum",entries:e,...I(t)})}const zi=g("ZodLiteral",(e,t)=>{kh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Gm(e,n,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 b(e,t){return new zi({type:"literal",values:Array.isArray(e)?e:[e],...I(t)})}const Ti=g("ZodFile",(e,t)=>{$h.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Xm(e,n,r),e.min=(n,r)=>e.check(ht(n,r)),e.max=(n,r)=>e.check(qt(n,r)),e.mime=(n,r)=>e.check(mr(Array.isArray(n)?n:[n],r))});function Ou(e){return vm(Ti,e)}const Ei=g("ZodTransform",(e,t)=>{Ht(),Sh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>rg(e,n,r,o),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new Fo(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Qt(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),"input"in s||(s.input=n.value),s.inst??(s.inst=e),n.issues.push(Qt(s))}};const o=t.transform(n.value,n);return o instanceof Promise?o.then(i=>(n.value=i,n)):(n.value=o,n)}});function qr(e){return new Ei({type:"transform",transform:e})}const zn=g("ZodOptional",(e,t)=>{La.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>kc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function re(e){return new zn({type:"optional",innerType:e})}const Hr=g("ZodExactOptional",(e,t)=>{Ih.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>kc(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ci(e){return new Hr({type:"optional",innerType:e})}const Ai=g("ZodNullable",(e,t)=>{xh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>dg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function an(e){return new Ai({type:"nullable",innerType:e})}function Pu(e){return re(an(e))}const Ni=g("ZodDefault",(e,t)=>{zh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>hg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Oi(e,t){return new Ni({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Yn(t)}})}const Pi=g("ZodPrefault",(e,t)=>{Th.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>mg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Mi(e,t){return new Pi({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Yn(t)}})}const Br=g("ZodNonOptional",(e,t)=>{Eh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>fg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Ri(e,t){return new Br({type:"nonoptional",innerType:e,...I(t)})}const Li=g("ZodSuccess",(e,t)=>{Ch.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>eg(e,n,r),e.unwrap=()=>e._zod.def.innerType});function Mu(e){return new Li({type:"success",innerType:e})}const Di=g("ZodCatch",(e,t)=>{Ah.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>gg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Zi(e,t){return new Di({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Ys(t)})}const ji=g("ZodNaN",(e,t)=>{Nh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Ym(e,n,r,o)});function Ru(e){return bm(ji,e)}const Tn=g("ZodPipe",(e,t)=>{Da.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>yg(e,n,r,o),e.in=t.in,e.out=t.out});function Kn(e,t){return new Tn({type:"pipe",in:e,out:t})}const En=g("ZodCodec",(e,t)=>{Tn.init(e,t),Za.init(e,t)});function Lu(e,t,n){return new En({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function Du(e){const t=e._zod.def;return new En({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}const Fi=g("ZodPreprocess",(e,t)=>{Tn.init(e,t),Oh.init(e,t)}),Ui=g("ZodReadonly",(e,t)=>{Ph.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>_g(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function Vi(e){return new Ui({type:"readonly",innerType:e})}const qi=g("ZodTemplateLiteral",(e,t)=>{Mh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>Qm(e,n,r)});function Zu(e,t){return new qi({type:"template_literal",parts:e,...I(t)})}const Hi=g("ZodLazy",(e,t)=>{ja.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>wg(e,n,r,o),e.unwrap=()=>e._zod.def.getter()});function Bi(e){return new Hi({type:"lazy",getter:e})}const Ki=g("ZodPromise",(e,t)=>{Lh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>bg(e,n,r,o),e.unwrap=()=>e._zod.def.innerType});function ju(e){return new Ki({type:"promise",innerType:e})}const Ji=g("ZodFunction",(e,t)=>{Rh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>ng(e,n,r,o)});function cn(e){return new Ji({type:"function",input:Array.isArray(e?.input)?Si(e?.input):e?.input??M(Y()),output:e?.output??Y()})}const Cn=g("ZodCustom",(e,t)=>{Dh.init(e,t),j.init(e,t),e._zod.processJSONSchema=(n,r,o)=>tg(e,n,r,o)});function Fu(e){const t=new ie({check:"custom"});return t._zod.check=e,t}function Wi(e,t){return km(Cn,e??(()=>!0),t)}function Gi(e,t={}){return $m(Cn,e,t)}function Yi(e,t){return Sm(e,t)}const Uu=xm,Vu=zm,Qi=g("ZodInstanceOf",(e,t)=>{Cn.init(e,t)},{properties(e,t){return this.check(hr(e,t))}});function qu(e,t={}){const n=new Qi({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...I(t)});return n._zod.bag.Class=e,n._zod.check=r=>{r.value instanceof e||r.issues.push({code:"invalid_type",expected:e.name,input:r.value,inst:n,path:[...n._zod.def.path??[]]})},n}const Hu=(...e)=>Tm({Codec:En,Boolean:kn,String:mn},...e);function Bu(e){const t=Bi(()=>F([_(e),Z(),X(),jr(),M(t),q(_(),t)]));return t}function Kr(e,t){return new Fi({type:"pipe",in:qr(e),out:t})}const Lw=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:mi,ZodArray:bi,ZodBase64:Mr,ZodBase64URL:Rr,ZodBigInt:$n,ZodBigIntFormat:Zr,ZodBoolean:kn,ZodCIDRv4:Or,ZodCIDRv6:Pr,ZodCUID:xr,ZodCUID2:zr,ZodCatch:Di,ZodCodec:En,ZodCreditCard:li,ZodCustom:Cn,ZodCustomStringFormat:It,ZodDate:Ur,ZodDefault:Ni,ZodDiscriminatedUnion:vi,ZodE164:Lr,ZodEmail:kr,ZodEmoji:Sr,ZodEnum:Vt,ZodExactOptional:Hr,ZodFile:Ti,ZodFunction:Ji,ZodGUID:$r,ZodIBAN:di,ZodIPv4:Ar,ZodIPv6:Nr,ZodISODate:yn,ZodISODateTime:gn,ZodISODuration:bn,ZodISOTime:_n,ZodInstanceOf:Qi,ZodIntersection:ki,ZodJWT:Dr,ZodKSUID:Cr,ZodLazy:Hi,ZodLiteral:zi,ZodMAC:ui,ZodMap:Ii,ZodNaN:ji,ZodNanoID:Ir,ZodNever:yi,ZodNonOptional:Br,ZodNull:hi,ZodNullable:Ai,ZodNumber:vn,ZodNumberFormat:xt,ZodObject:Sn,ZodOptional:zn,ZodPipe:Tn,ZodPrefault:Pi,ZodPreprocess:Fi,ZodPromise:Ki,ZodReadonly:Ui,ZodRecord:Ut,ZodSet:xi,ZodString:mn,ZodStringFormat:ee,ZodSuccess:Li,ZodSymbol:fi,ZodTemplateLiteral:qi,ZodTransform:Ei,ZodTuple:$i,ZodType:j,ZodULID:Tr,ZodURL:wn,ZodUUID:Ge,ZodUndefined:pi,ZodUnion:In,ZodUnknown:gi,ZodVoid:_i,ZodXID:Er,ZodXor:wi,_ZodString:vr,_default:Oi,_function:cn,any:Fr,array:M,base64:ou,base64url:iu,bigint:bu,boolean:X,catch:Zi,check:Fu,cidrv4:nu,cidrv6:ru,codec:Lu,creditCard:au,cuid:Jc,cuid2:Wc,currencyCode:pu,custom:Wi,date:Su,describe:Uu,discriminatedUnion:Vr,e164:su,email:Dc,emoji:Bc,enum:we,exactOptional:Ci,file:Ou,float32:mu,float64:gu,function:cn,guid:Zc,hash:hu,hex:fu,hostname:du,httpUrl:Hc,iban:cu,instanceof:qu,int:Bn,int32:yu,int64:wu,intersection:xn,invertCodec:Du,ipv4:Xc,ipv6:tu,json:Bu,jwt:uu,keyof:Iu,ksuid:Qc,lazy:Bi,literal:b,looseObject:be,looseRecord:Eu,mac:eu,map:Cu,meta:Vu,nan:Ru,nanoid:Kc,nativeEnum:Nu,never:Ft,nonoptional:Ri,null:jr,nullable:an,nullish:Pu,number:Z,object:v,optional:re,partialRecord:Tu,pipe:Kn,prefault:Mi,preprocess:Kr,promise:ju,readonly:Vi,record:q,refine:Gi,set:Au,strictObject:xu,string:_,stringFormat:lu,stringbool:Hu,success:Mu,superRefine:Yi,symbol:ku,templateLiteral:Zu,transform:qr,tuple:Si,uint32:_u,uint64:vu,ulid:Gc,undefined:sn,union:F,unknown:Y,url:qc,uuid:jc,uuidv4:Fc,uuidv6:Uc,uuidv7:Vc,void:$u,xid:Yc,xor:zu},Symbol.toStringTag,{value:"Module"})),Ig={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 xg(e){me({customError:e})}function zg(){return me().customError}var Ao;Ao||(Ao={});function Tg(e){return gc(gn,e)}function Dw(e){return yc(yn,e)}function Zw(e){return _c(_n,e)}function jw(e){return bc(bn,e)}const Ku=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:yn,ZodISODateTime:gn,ZodISODuration:bn,ZodISOTime:_n,date:Dw,datetime:Tg,duration:jw,time:Zw},Symbol.toStringTag,{value:"Module"})),E={...Lw,...Mw,iso:Ku},Fw=new Set(["$schema","$ref","$defs","definitions","$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor","type","enum","const","anyOf","oneOf","allOf","not","properties","required","additionalProperties","patternProperties","propertyNames","minProperties","maxProperties","items","prefixItems","additionalItems","minItems","maxItems","uniqueItems","contains","minContains","maxContains","minLength","maxLength","pattern","format","minimum","maximum","exclusiveMinimum","exclusiveMaximum","multipleOf","description","default","contentEncoding","contentMediaType","contentSchema","unevaluatedItems","unevaluatedProperties","if","then","else","dependentSchemas","dependentRequired","nullable","readOnly"]);function Uw(e,t){const n=e.$schema;return n==="https://json-schema.org/draft/2020-12/schema"?"draft-2020-12":n==="http://json-schema.org/draft-07/schema#"?"draft-7":n==="http://json-schema.org/draft-04/schema#"?"draft-4":t??"draft-2020-12"}function gd(e,t){return e.map((n,r)=>r<t?n:n.optional())}function Vw(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function qw(e,t){if(!e.startsWith("#"))throw new Error("External $ref is not supported, only local refs (#/...) are allowed");const n=e.slice(1).split("/").filter(Boolean);if(n.length===0)return t.rootSchema;const r=t.version==="draft-2020-12"?"$defs":"definitions";if(n[0]===r){const o=n[1]===void 0?void 0:Vw(n[1]);if(!o||!t.defs[o])throw new Error(`Reference not found: ${e}`);return t.defs[o]}throw new Error(`Reference not found: ${e}`)}function Hw(e,t){return E.transform(r=>r).check(r=>{const o=r.value;if(typeof o!="object"||o===null||Array.isArray(o))return;const i=Object.getOwnPropertyNames(o);if(t.minProperties!==void 0&&i.length<t.minProperties&&r.issues.push({origin:"object",code:"too_small",minimum:t.minProperties,inclusive:!0,message:`Too small: expected object to have >=${t.minProperties} properties`,input:o,inst:e,continue:!0}),t.maxProperties!==void 0&&i.length>t.maxProperties&&r.issues.push({origin:"object",code:"too_big",maximum:t.maxProperties,inclusive:!0,message:`Too big: expected object to have <=${t.maxProperties} properties`,input:o,inst:e,continue:!0}),t.keySchema)for(const s of i){const a=t.keySchema.safeParse(s);a.success||r.issues.push({code:"invalid_key",origin:"record",issues:a.error.issues,input:s,path:[s],continue:!0})}}).pipe(e)}function Ps(e,t){if(e===null)return"z";const n=typeof e;if(n!=="object"){if(n==="number"&&Number.isNaN(e))return null;const r=String(e);return`${n[0]}${r.length}:${r}`}if(t.has(e))return null;t.add(e);try{if(Array.isArray(e)){const i=[];for(const s of e){const a=Ps(s,t);if(a===null)return null;i.push(a)}return`a${i.length}:[${i.join(",")}]`}const r=Object.keys(e).sort(),o=[];for(const i of r){const s=Ps(e[i],t);if(s===null)return null;o.push(`${i.length}:${i}=${s}`)}return`o${o.length}:{${o.join(",")}}`}finally{t.delete(e)}}const Bw=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),Kw=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function Fn(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(Fn):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>Bw.has(t)?Fn(n):!Kw.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(Fn))}function yd(e){return e===1?"element":"elements"}function Jw(e,t){return E.transform(r=>r).check(r=>{const o=r.value;if(Array.isArray(o)){if(t.uniqueItems===!0){const i=new Map;for(let s=0;s<o.length;s++){const a=Ps(o[s],new Set);if(a===null)continue;const c=i.get(a);if(c===void 0){i.set(a,s);continue}r.issues.push({code:"custom",message:`Array items must be unique: element at index ${s} duplicates the one at index ${c}`,input:o,path:[s],continue:!0})}}if(t.containsSchema){const i=t.minContains??1,s=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY;let a=0;for(const c of o)if(t.containsSchema.safeParse(c).success&&++a>=s)break;a<i&&r.issues.push({code:"custom",message:`Array must contain at least ${i} matching ${yd(i)}; found ${a}`,input:o,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&r.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${yd(t.maxContains)}`,input:o,continue:!0})}}}).pipe(e)}function _d(e,t){if(e!==!1)return e===void 0||e===!0?E.any():Te(e,t)}const Ww=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Eg(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return E.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 o=e.$ref;if(t.refs.has(o))return t.refs.get(o);if(t.processing.has(o))return E.lazy(()=>{if(!t.refs.has(o))throw new Error(`Circular reference not resolved: ${o}`);return t.refs.get(o)});t.processing.add(o);const i=qw(o,t),s=Te(i,t);return t.refs.set(o,s),t.processing.delete(o),s}if(e.enum!==void 0){const o=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&o.length===1&&o[0]===null)return E.null();if(o.length===0)return E.never();if(o.length===1)return E.literal(o[0]);if(o.every(s=>typeof s=="string"))return E.enum(o);const i=o.map(s=>E.literal(s));return i.length<2?i[0]:E.union([i[0],i[1],...i.slice(2)])}if(e.const!==void 0)return E.literal(e.const);const n=e.type;if(Array.isArray(n)){const o=n.map(i=>{const s={...e,type:i};return Eg(s,t)});return o.length===0?E.never():o.length===1?o[0]:E.union(o)}if(!n)return E.any();let r;switch(n){case"string":{let o=E.string();if(e.format){const i=e.format;i==="email"?o=o.check(E.email()):i==="uri"||i==="uri-reference"?o=o.check(E.url()):i==="uuid"||i==="guid"?o=o.check(E.uuid()):i==="date-time"?o=o.check(E.iso.datetime({offset:!0})):i==="date"?o=o.check(E.iso.date()):i==="time"?o=o.check(E.regex(Ww)):i==="duration"?o=o.check(E.iso.duration()):i==="hostname"?o=o.check(E.hostname()):i==="ipv4"?o=o.check(E.ipv4()):i==="ipv6"?o=o.check(E.ipv6()):i==="mac"?o=o.check(E.mac()):i==="cidr"?o=o.check(E.cidrv4()):i==="cidr-v6"?o=o.check(E.cidrv6()):i==="base64"?o=o.check(E.base64()):i==="base64url"?o=o.check(E.base64url()):i==="e164"?o=o.check(E.e164()):i==="credit_card"?o=o.check(E.creditCard()):i==="iban"?o=o.check(E.iban()):i==="jwt"?o=o.check(E.jwt()):i==="emoji"?o=o.check(E.emoji()):i==="nanoid"?o=o.check(E.nanoid()):i==="cuid"?o=o.check(E.cuid()):i==="cuid2"?o=o.check(E.cuid2()):i==="ulid"?o=o.check(E.ulid()):i==="xid"?o=o.check(E.xid()):i==="ksuid"&&(o=o.check(E.ksuid()))}typeof e.minLength=="number"&&(o=o.min(e.minLength)),typeof e.maxLength=="number"&&(o=o.max(e.maxLength)),e.pattern&&(o=o.regex(new RegExp(e.pattern))),r=o;break}case"number":case"integer":{let o=n==="integer"?E.number().int():E.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(o=o.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(o=o.max(e.maximum)),typeof e.exclusiveMinimum=="number"?o=o.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(o=o.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?o=o.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(o=o.lt(e.maximum)),typeof e.multipleOf=="number"&&(o=o.multipleOf(e.multipleOf)),r=o;break}case"boolean":{r=E.boolean();break}case"null":{r=E.null();break}case"object":{const o={},i=e.properties||{},s=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?Te(e.additionalProperties,t):void 0;for(const[d,f]of Object.entries(i)){const p=Te(f,t);Fe(o,d,s.has(d)?p:p.optional())}if(e.patternProperties){const d=e.patternProperties,f=Object.keys(d),p=[];for(const m of f){const y=Te(d[m],t),$=E.string().regex(new RegExp(m));p.push(E.looseRecord($,y))}const h=[];if(Object.keys(o).length>0&&h.push(E.object(o).passthrough()),h.push(...p),h.length===0)r=E.object({}).passthrough();else if(h.length===1)r=h[0];else{let m=E.intersection(h[0],h[1]);for(let y=2;y<h.length;y++)m=E.intersection(m,h[y]);r=m}if(e.additionalProperties===!1){const m=Object.keys(o),y=f.map(w=>new RegExp(w)),$=r;r=r.check(w=>{if(!ct(w.value))return;const S=[];for(const T of Object.keys(w.value))m.includes(T)||y.some(O=>O.test(T))||S.push(T);S.length&&w.issues.push({code:"unrecognized_keys",keys:S,input:w.value,inst:$})})}}else{const d=E.object(o);e.additionalProperties===!1?r=d.strict():a?r=d.catchall(a):r=d.passthrough()}const c=e.propertyNames!==void 0&&e.propertyNames!==!0,u=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(c||u!==void 0||l!==void 0){let d;if(c){const f=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=Te(f,t)}r=Hw(r,{keySchema:d,minProperties:u,maxProperties:l})}break}case"array":{const o=e.prefixItems,i=e.items;if(o&&Array.isArray(o)){const s=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>Te(d,t)),c=gd(a,s),u=Array.isArray(i)?void 0:_d(i,t),l=E.tuple(c);r=u?l.rest(u):l,typeof e.minItems=="number"&&(r=r.check(E.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(E.maxLength(e.maxItems)))}else if(Array.isArray(i)){const s=typeof e.minItems=="number"?e.minItems:0,a=i.map(d=>Te(d,t)),c=gd(a,s),u=_d(e.additionalItems,t),l=E.tuple(c);r=u?l.rest(u):l,typeof e.minItems=="number"&&(r=r.check(E.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(E.maxLength(e.maxItems)))}else if(i!==void 0){const s=Te(i,t);let a=E.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=E.array(E.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=Jw(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?Te(e.contains,t):void 0,minContains:typeof e.minContains=="number"?e.minContains:void 0,maxContains:typeof e.maxContains=="number"?e.maxContains:void 0}));break}default:throw new Error(`Unsupported type: ${n}`)}return r}function Te(e,t){if(typeof e=="boolean")return e?E.any():E.never();let n=Eg(e,t);const r=e.type||e.enum!==void 0||e.const!==void 0;if(e.anyOf&&Array.isArray(e.anyOf)){const a=e.anyOf.map(u=>Te(u,t)),c=E.union(a);n=r?E.intersection(n,c):c}if(e.oneOf&&Array.isArray(e.oneOf)){const a=e.oneOf.map(u=>Te(u,t)),c=E.xor(a);n=r?E.intersection(n,c):c}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:E.any();else{let a=r?n:Te(e.allOf[0],t);const c=r?0:1;for(let u=c;u<e.allOf.length;u++)a=E.intersection(a,Te(e.allOf[u],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=E.nullable(n)),e.readOnly===!0&&(n=E.readonly(n)),e.default!==void 0&&(n=n.default(e.default));const o={},i=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(const a of i)a in e&&(o[a]=e[a]);const s=["contentEncoding","contentMediaType","contentSchema"];for(const a of s)a in e&&(o[a]=e[a]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!Fn(e.propertyNames)&&(o.propertyNames=e.propertyNames);for(const a of["minProperties","maxProperties"])e[a]!==void 0&&(o[a]=e[a])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!Fn(e.contains)&&(o.contains=e.contains);for(const a of["uniqueItems","minContains","maxContains"])e[a]!==void 0&&(o[a]=e[a])}for(const a of Object.keys(e))Fw.has(a)||Fe(o,a,e[a]);return Object.keys(o).length>0&&t.registry.add(n,o),e.description&&(n=n.describe(e.description)),n}function Cg(e,t){if(typeof e=="boolean")return e?E.any():E.never();let n;try{n=JSON.parse(JSON.stringify(e))}catch{throw new Error("fromJSONSchema input is not valid JSON (possibly cyclic); use $defs/$ref for recursive schemas")}const r=Uw(n,t?.defaultTarget),o=n.$defs||n.definitions||{},i={version:r,defs:o,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??Le};return Te(n,i)}function Ag(e){return Sc(e,{object:t=>t.partial(),union:t=>{const n=t._zod.def;return n.discriminator===void 0?t:F(n.options)}})}function Gw(e,t){if(!t?.length)return e;const n=e._zod.def;return oe(e,Se(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function Ng(e){return Gw(e.out,e.checks)}function Yw(e){return e.in._zod.traits.has("$ZodTransform")?Ng(e):e.in}function Og(e){return Sc(e,{pipe:t=>Yw(t._zod.def),default:(t,n)=>n?re(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function Pg(e){return Sc(e,{pipe:t=>Ng(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}function Qw(e){return Kh(mn,e)}function Xw(e){return Qh(vn,e)}function ev(e){return im(kn,e)}function tv(e){return am($n,e)}function nv(e){return _m(Ur,e)}const Mg=Object.freeze(Object.defineProperty({__proto__:null,bigint:tv,boolean:ev,date:nv,number:Xw,string:Qw},Symbol.toStringTag,{value:"Module"})),bd=Object.freeze(Object.defineProperty({__proto__:null,$brand:ea,$input:Ha,$output:qa,INVALID:Ce,NEVER:Xs,TimePrecision:mc,ZodAny:mi,ZodArray:bi,ZodBase64:Mr,ZodBase64URL:Rr,ZodBigInt:$n,ZodBigIntFormat:Zr,ZodBoolean:kn,ZodCIDRv4:Or,ZodCIDRv6:Pr,ZodCUID:xr,ZodCUID2:zr,ZodCatch:Di,ZodCodec:En,ZodCompileAsyncError:dt,ZodCompileUnsupportedError:B,ZodCreditCard:li,ZodCustom:Cn,ZodCustomStringFormat:It,ZodDate:Ur,ZodDefault:Ni,ZodDiscriminatedUnion:vi,ZodE164:Lr,ZodEmail:kr,ZodEmoji:Sr,ZodEnum:Vt,ZodError:Sg,ZodExactOptional:Hr,ZodFile:Ti,get ZodFirstPartyTypeKind(){return Ao},ZodFunction:Ji,ZodGUID:$r,ZodIBAN:di,ZodIPv4:Ar,ZodIPv6:Nr,ZodISODate:yn,ZodISODateTime:gn,ZodISODuration:bn,ZodISOTime:_n,ZodInstanceOf:Qi,ZodIntersection:ki,ZodIssueCode:Ig,ZodJWT:Dr,ZodKSUID:Cr,ZodLazy:Hi,ZodLiteral:zi,ZodMAC:ui,ZodMap:Ii,ZodNaN:ji,ZodNanoID:Ir,ZodNever:yi,ZodNonOptional:Br,ZodNull:hi,ZodNullable:Ai,ZodNumber:vn,ZodNumberFormat:xt,ZodObject:Sn,ZodOptional:zn,ZodPipe:Tn,ZodPrefault:Pi,ZodPreprocess:Fi,ZodPromise:Ki,ZodReadonly:Ui,ZodRealError:Ne,ZodRecord:Ut,ZodSet:xi,ZodString:mn,ZodStringFormat:ee,ZodSuccess:Li,ZodSymbol:fi,ZodTemplateLiteral:qi,ZodTransform:Ei,ZodTuple:$i,ZodType:j,ZodULID:Tr,ZodURL:wn,ZodUUID:Ge,ZodUndefined:pi,ZodUnion:In,ZodUnknown:gi,ZodVoid:_i,ZodXID:Er,ZodXor:wi,_ZodString:vr,_default:Oi,_function:cn,any:Fr,array:M,base64:ou,base64url:iu,bigint:bu,boolean:X,catch:Zi,check:Fu,cidrv4:nu,cidrv6:ru,clone:oe,codec:Lu,coerce:Mg,compile:Ba,config:me,core:vg,creditCard:au,cuid:Jc,cuid2:Wc,currencyCode:pu,custom:Wi,date:Su,decode:Ac,decodeAsync:Oc,deepPartial:Ag,describe:Uu,discriminatedUnion:Vr,e164:su,email:Dc,emoji:Bc,encode:Cc,encodeAsync:Nc,endsWith:pr,enum:we,exactOptional:Ci,file:Ou,flattenError:Uo,float32:mu,float64:gu,formatError:Vo,fromJSONSchema:Cg,function:cn,getDiscriminatedOption:Ma,getErrorMap:zg,globalRegistry:Le,gt:pt,gte:je,guid:Zc,hash:hu,hex:fu,hostname:du,httpUrl:Hc,iban:cu,includes:dr,input:Og,instanceof:qu,int:Bn,int32:yu,int64:wu,intersection:xn,invertCodec:Du,ipv4:Xc,ipv6:tu,iso:Ku,json:Bu,jwt:uu,keyof:Iu,ksuid:Qc,lazy:Bi,length:pn,literal:b,locales:Va,looseObject:be,looseRecord:Eu,lowercase:ur,lt:ft,lte:Ze,mac:eu,map:Cu,maxLength:fn,maxSize:qt,memoizer:Qo,meta:Vu,mime:mr,minLength:St,minSize:ht,multipleOf:jt,nan:Ru,nanoid:Kc,nativeEnum:Nu,negative:ii,never:Ft,nonnegative:ai,nonoptional:Ri,nonpositive:si,normalize:gr,null:jr,nullable:an,nullish:Pu,number:Z,object:v,optional:re,output:Pg,overwrite:tt,parse:xc,parseAsync:zc,partialRecord:Tu,pipe:Kn,positive:oi,prefault:Mi,preprocess:Kr,prettifyError:na,promise:ju,properties:hr,property:ci,readonly:Vi,record:q,refine:Gi,regex:cr,regexes:Ko,registry:Xo,safeDecode:Mc,safeDecodeAsync:Lc,safeEncode:Pc,safeEncodeAsync:Rc,safeParse:Tc,safeParseAsync:Ec,set:Au,setErrorMap:xg,size:dn,slugify:wr,startsWith:fr,strictObject:xu,string:_,stringFormat:lu,stringbool:Hu,success:Mu,superRefine:Yi,symbol:ku,templateLiteral:Zu,toJSONSchema:$c,toLowerCase:_r,toUpperCase:br,toZod:Mo,transform:qr,treeifyError:ta,trim:yr,tuple:Si,uint32:_u,uint64:vu,ulid:Gc,undefined:sn,union:F,unknown:Y,uppercase:lr,url:qc,util:Qs,uuid:jc,uuidv4:Fc,uuidv6:Uc,uuidv7:Vc,validate:Ho,validateAsync:Bo,void:$u,withParser:ei,xid:Yc,xor:zu},Symbol.toStringTag,{value:"Module"})),rv=Object.freeze(Object.defineProperty({__proto__:null,$brand:ea,$input:Ha,$output:qa,INVALID:Ce,NEVER:Xs,TimePrecision:mc,ZodAny:mi,ZodArray:bi,ZodBase64:Mr,ZodBase64URL:Rr,ZodBigInt:$n,ZodBigIntFormat:Zr,ZodBoolean:kn,ZodCIDRv4:Or,ZodCIDRv6:Pr,ZodCUID:xr,ZodCUID2:zr,ZodCatch:Di,ZodCodec:En,ZodCompileAsyncError:dt,ZodCompileUnsupportedError:B,ZodCreditCard:li,ZodCustom:Cn,ZodCustomStringFormat:It,ZodDate:Ur,ZodDefault:Ni,ZodDiscriminatedUnion:vi,ZodE164:Lr,ZodEmail:kr,ZodEmoji:Sr,ZodEnum:Vt,ZodError:Sg,ZodExactOptional:Hr,ZodFile:Ti,get ZodFirstPartyTypeKind(){return Ao},ZodFunction:Ji,ZodGUID:$r,ZodIBAN:di,ZodIPv4:Ar,ZodIPv6:Nr,ZodISODate:yn,ZodISODateTime:gn,ZodISODuration:bn,ZodISOTime:_n,ZodInstanceOf:Qi,ZodIntersection:ki,ZodIssueCode:Ig,ZodJWT:Dr,ZodKSUID:Cr,ZodLazy:Hi,ZodLiteral:zi,ZodMAC:ui,ZodMap:Ii,ZodNaN:ji,ZodNanoID:Ir,ZodNever:yi,ZodNonOptional:Br,ZodNull:hi,ZodNullable:Ai,ZodNumber:vn,ZodNumberFormat:xt,ZodObject:Sn,ZodOptional:zn,ZodPipe:Tn,ZodPrefault:Pi,ZodPreprocess:Fi,ZodPromise:Ki,ZodReadonly:Ui,ZodRealError:Ne,ZodRecord:Ut,ZodSet:xi,ZodString:mn,ZodStringFormat:ee,ZodSuccess:Li,ZodSymbol:fi,ZodTemplateLiteral:qi,ZodTransform:Ei,ZodTuple:$i,ZodType:j,ZodULID:Tr,ZodURL:wn,ZodUUID:Ge,ZodUndefined:pi,ZodUnion:In,ZodUnknown:gi,ZodVoid:_i,ZodXID:Er,ZodXor:wi,_ZodString:vr,_default:Oi,_function:cn,any:Fr,array:M,base64:ou,base64url:iu,bigint:bu,boolean:X,catch:Zi,check:Fu,cidrv4:nu,cidrv6:ru,clone:oe,codec:Lu,coerce:Mg,compile:Ba,config:me,core:vg,creditCard:au,cuid:Jc,cuid2:Wc,currencyCode:pu,custom:Wi,date:Su,decode:Ac,decodeAsync:Oc,deepPartial:Ag,default:bd,describe:Uu,discriminatedUnion:Vr,e164:su,email:Dc,emoji:Bc,encode:Cc,encodeAsync:Nc,endsWith:pr,enum:we,exactOptional:Ci,file:Ou,flattenError:Uo,float32:mu,float64:gu,formatError:Vo,fromJSONSchema:Cg,function:cn,getDiscriminatedOption:Ma,getErrorMap:zg,globalRegistry:Le,gt:pt,gte:je,guid:Zc,hash:hu,hex:fu,hostname:du,httpUrl:Hc,iban:cu,includes:dr,input:Og,instanceof:qu,int:Bn,int32:yu,int64:wu,intersection:xn,invertCodec:Du,ipv4:Xc,ipv6:tu,iso:Ku,json:Bu,jwt:uu,keyof:Iu,ksuid:Qc,lazy:Bi,length:pn,literal:b,locales:Va,looseObject:be,looseRecord:Eu,lowercase:ur,lt:ft,lte:Ze,mac:eu,map:Cu,maxLength:fn,maxSize:qt,memoizer:Qo,meta:Vu,mime:mr,minLength:St,minSize:ht,multipleOf:jt,nan:Ru,nanoid:Kc,nativeEnum:Nu,negative:ii,never:Ft,nonnegative:ai,nonoptional:Ri,nonpositive:si,normalize:gr,null:jr,nullable:an,nullish:Pu,number:Z,object:v,optional:re,output:Pg,overwrite:tt,parse:xc,parseAsync:zc,partialRecord:Tu,pipe:Kn,positive:oi,prefault:Mi,preprocess:Kr,prettifyError:na,promise:ju,properties:hr,property:ci,readonly:Vi,record:q,refine:Gi,regex:cr,regexes:Ko,registry:Xo,safeDecode:Mc,safeDecodeAsync:Lc,safeEncode:Pc,safeEncodeAsync:Rc,safeParse:Tc,safeParseAsync:Ec,set:Au,setErrorMap:xg,size:dn,slugify:wr,startsWith:fr,strictObject:xu,string:_,stringFormat:lu,stringbool:Hu,success:Mu,superRefine:Yi,symbol:ku,templateLiteral:Zu,toJSONSchema:$c,toLowerCase:_r,toUpperCase:br,toZod:Mo,transform:qr,treeifyError:ta,trim:yr,tuple:Si,uint32:_u,uint64:vu,ulid:Gc,undefined:sn,union:F,unknown:Y,uppercase:lr,url:qc,util:Qs,uuid:jc,uuidv4:Fc,uuidv6:Uc,uuidv7:Vc,validate:Ho,validateAsync:Bo,void:$u,withParser:ei,xid:Yc,xor:zu,z:bd},Symbol.toStringTag,{value:"Module"})),Rt="io.modelcontextprotocol/related-task",Xi="2.0",he=Wi(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Rg=F([_(),Z().int()]),Lg=_();be({ttl:Z().optional(),pollInterval:Z().optional()});const ov=v({ttl:Z().optional()}),iv=v({taskId:_()}),Ju=be({progressToken:Rg.optional(),[Rt]:iv.optional()}),Ve=v({_meta:Ju.optional()}),Jr=Ve.extend({task:ov.optional()}),sv=e=>Jr.safeParse(e).success,ve=v({method:_(),params:Ve.loose().optional()}),Ke=v({_meta:Ju.optional()}),Je=v({method:_(),params:Ke.loose().optional()}),ke=be({_meta:Ju.optional()}),Wr=F([_(),Z().int()]),Dg=v({jsonrpc:b(Xi),id:Wr,...ve.shape}).strict(),wd=e=>Dg.safeParse(e).success,Zg=v({jsonrpc:b(Xi),...Je.shape}).strict(),av=e=>Zg.safeParse(e).success,Wu=v({jsonrpc:b(Xi),id:Wr,result:ke}).strict(),po=e=>Wu.safeParse(e).success;var G;(function(e){e[e.ConnectionClosed=-32e3]="ConnectionClosed",e[e.RequestTimeout=-32001]="RequestTimeout",e[e.ParseError=-32700]="ParseError",e[e.InvalidRequest=-32600]="InvalidRequest",e[e.MethodNotFound=-32601]="MethodNotFound",e[e.InvalidParams=-32602]="InvalidParams",e[e.InternalError=-32603]="InternalError",e[e.UrlElicitationRequired=-32042]="UrlElicitationRequired"})(G||(G={}));const Gu=v({jsonrpc:b(Xi),id:Wr.optional(),error:v({code:Z().int(),message:_(),data:Y().optional()})}).strict(),cv=e=>Gu.safeParse(e).success,uv=F([Dg,Zg,Wu,Gu]);F([Wu,Gu]);const Yu=ke.strict(),lv=Ke.extend({requestId:Wr.optional(),reason:_().optional()}),Qu=Je.extend({method:b("notifications/cancelled"),params:lv}),dv=v({src:_(),mimeType:_().optional(),sizes:M(_()).optional(),theme:we(["light","dark"]).optional()}),Gr=v({icons:M(dv).optional()}),un=v({name:_(),title:_().optional()}),es=un.extend({...un.shape,...Gr.shape,version:_(),websiteUrl:_().optional(),description:_().optional()}),fv=xn(v({applyDefaults:X().optional()}),q(_(),Y())),pv=Kr(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,xn(v({form:fv.optional(),url:he.optional()}),q(_(),Y()).optional())),hv=be({list:he.optional(),cancel:he.optional(),requests:be({sampling:be({createMessage:he.optional()}).optional(),elicitation:be({create:he.optional()}).optional()}).optional()}),mv=be({list:he.optional(),cancel:he.optional(),requests:be({tools:be({call:he.optional()}).optional()}).optional()}),gv=v({experimental:q(_(),he).optional(),sampling:v({context:he.optional(),tools:he.optional()}).optional(),elicitation:pv.optional(),roots:v({listChanged:X().optional()}).optional(),tasks:hv.optional(),extensions:q(_(),he).optional()}),yv=Ve.extend({protocolVersion:_(),capabilities:gv,clientInfo:es}),_v=ve.extend({method:b("initialize"),params:yv}),bv=v({experimental:q(_(),he).optional(),logging:he.optional(),completions:he.optional(),prompts:v({listChanged:X().optional()}).optional(),resources:v({subscribe:X().optional(),listChanged:X().optional()}).optional(),tools:v({listChanged:X().optional()}).optional(),tasks:mv.optional(),extensions:q(_(),he).optional()}),wv=ke.extend({protocolVersion:_(),capabilities:bv,serverInfo:es,instructions:_().optional()}),vv=Je.extend({method:b("notifications/initialized"),params:Ke.optional()}),ts=ve.extend({method:b("ping"),params:Ve.optional()}),kv=v({progress:Z(),total:re(Z()),message:re(_())}),$v=v({...Ke.shape,...kv.shape,progressToken:Rg}),Xu=Je.extend({method:b("notifications/progress"),params:$v}),Sv=Ve.extend({cursor:Lg.optional()}),Yr=ve.extend({params:Sv.optional()}),Qr=ke.extend({nextCursor:Lg.optional()}),Iv=we(["working","input_required","completed","failed","cancelled"]),Xr=v({taskId:_(),status:Iv,ttl:F([Z(),jr()]),createdAt:_(),lastUpdatedAt:_(),pollInterval:re(Z()),statusMessage:re(_())}),el=ke.extend({task:Xr}),xv=Ke.merge(Xr),No=Je.extend({method:b("notifications/tasks/status"),params:xv}),tl=ve.extend({method:b("tasks/get"),params:Ve.extend({taskId:_()})}),nl=ke.merge(Xr),rl=ve.extend({method:b("tasks/result"),params:Ve.extend({taskId:_()})});ke.loose();const ol=Yr.extend({method:b("tasks/list")}),il=Qr.extend({tasks:M(Xr)}),sl=ve.extend({method:b("tasks/cancel"),params:Ve.extend({taskId:_()})}),zv=ke.merge(Xr),jg=v({uri:_(),mimeType:re(_()),_meta:q(_(),Y()).optional()}),Fg=jg.extend({text:_()}),al=_().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),Ug=jg.extend({blob:al}),eo=we(["user","assistant"]),An=v({audience:M(eo).optional(),priority:Z().min(0).max(1).optional(),lastModified:Tg({offset:!0}).optional()}),Vg=v({...un.shape,...Gr.shape,uri:_(),description:re(_()),mimeType:re(_()),size:re(Z()),annotations:An.optional(),_meta:re(be({}))}),Tv=v({...un.shape,...Gr.shape,uriTemplate:_(),description:re(_()),mimeType:re(_()),annotations:An.optional(),_meta:re(be({}))}),Ev=Yr.extend({method:b("resources/list")}),qg=Qr.extend({resources:M(Vg)}),Cv=Yr.extend({method:b("resources/templates/list")}),Av=Qr.extend({resourceTemplates:M(Tv)}),cl=Ve.extend({uri:_()}),Nv=cl,Ov=ve.extend({method:b("resources/read"),params:Nv}),Hg=ke.extend({contents:M(F([Fg,Ug]))}),Pv=Je.extend({method:b("notifications/resources/list_changed"),params:Ke.optional()}),Mv=cl,Rv=ve.extend({method:b("resources/subscribe"),params:Mv}),Lv=cl,Dv=ve.extend({method:b("resources/unsubscribe"),params:Lv}),Zv=Ke.extend({uri:_()}),jv=Je.extend({method:b("notifications/resources/updated"),params:Zv}),Fv=v({name:_(),description:re(_()),required:re(X())}),Uv=v({...un.shape,...Gr.shape,description:re(_()),arguments:re(M(Fv)),_meta:re(be({}))}),Vv=Yr.extend({method:b("prompts/list")}),qv=Qr.extend({prompts:M(Uv)}),Hv=Ve.extend({name:_(),arguments:q(_(),_()).optional()}),Bv=ve.extend({method:b("prompts/get"),params:Hv}),ul=v({type:b("text"),text:_(),annotations:An.optional(),_meta:q(_(),Y()).optional()}),ll=v({type:b("image"),data:al,mimeType:_(),annotations:An.optional(),_meta:q(_(),Y()).optional()}),dl=v({type:b("audio"),data:al,mimeType:_(),annotations:An.optional(),_meta:q(_(),Y()).optional()}),Kv=v({type:b("tool_use"),name:_(),id:_(),input:q(_(),Y()),_meta:q(_(),Y()).optional()}),Bg=v({type:b("resource"),resource:F([Fg,Ug]),annotations:An.optional(),_meta:q(_(),Y()).optional()}),Kg=Vg.extend({type:b("resource_link")}),to=F([ul,ll,dl,Kg,Bg]),Jv=v({role:eo,content:to}),Wv=ke.extend({description:_().optional(),messages:M(Jv)}),Gv=Je.extend({method:b("notifications/prompts/list_changed"),params:Ke.optional()}),Yv=v({title:_().optional(),readOnlyHint:X().optional(),destructiveHint:X().optional(),idempotentHint:X().optional(),openWorldHint:X().optional()}),Qv=v({taskSupport:we(["required","optional","forbidden"]).optional()}),fl=v({...un.shape,...Gr.shape,description:_().optional(),inputSchema:v({type:b("object"),properties:q(_(),he).optional(),required:M(_()).optional()}).catchall(Y()),outputSchema:v({type:b("object"),properties:q(_(),he).optional(),required:M(_()).optional()}).catchall(Y()).optional(),annotations:Yv.optional(),execution:Qv.optional(),_meta:q(_(),Y()).optional()}),Jg=Yr.extend({method:b("tools/list")}),Xv=Qr.extend({tools:M(fl)}),ns=ke.extend({content:M(to).default([]),structuredContent:q(_(),Y()).optional(),isError:X().optional()});ns.or(ke.extend({toolResult:Y()}));const ek=Jr.extend({name:_(),arguments:q(_(),Y()).optional()}),Wg=ve.extend({method:b("tools/call"),params:ek}),tk=Je.extend({method:b("notifications/tools/list_changed"),params:Ke.optional()});v({autoRefresh:X().default(!0),debounceMs:Z().int().nonnegative().default(300)});const Gg=we(["debug","info","notice","warning","error","critical","alert","emergency"]),nk=Ve.extend({level:Gg}),rk=ve.extend({method:b("logging/setLevel"),params:nk}),ok=Ke.extend({level:Gg,logger:_().optional(),data:Y()}),ik=Je.extend({method:b("notifications/message"),params:ok}),sk=v({name:_().optional()}),ak=v({hints:M(sk).optional(),costPriority:Z().min(0).max(1).optional(),speedPriority:Z().min(0).max(1).optional(),intelligencePriority:Z().min(0).max(1).optional()}),ck=v({mode:we(["auto","required","none"]).optional()}),uk=v({type:b("tool_result"),toolUseId:_().describe("The unique identifier for the corresponding tool call."),content:M(to).default([]),structuredContent:v({}).loose().optional(),isError:X().optional(),_meta:q(_(),Y()).optional()}),lk=Vr("type",[ul,ll,dl]),Oo=Vr("type",[ul,ll,dl,Kv,uk]),dk=v({role:eo,content:F([Oo,M(Oo)]),_meta:q(_(),Y()).optional()}),fk=Jr.extend({messages:M(dk),modelPreferences:ak.optional(),systemPrompt:_().optional(),includeContext:we(["none","thisServer","allServers"]).optional(),temperature:Z().optional(),maxTokens:Z().int(),stopSequences:M(_()).optional(),metadata:he.optional(),tools:M(fl).optional(),toolChoice:ck.optional()}),pk=ve.extend({method:b("sampling/createMessage"),params:fk}),Yg=ke.extend({model:_(),stopReason:re(we(["endTurn","stopSequence","maxTokens"]).or(_())),role:eo,content:lk}),Qg=ke.extend({model:_(),stopReason:re(we(["endTurn","stopSequence","maxTokens","toolUse"]).or(_())),role:eo,content:F([Oo,M(Oo)])}),hk=v({type:b("boolean"),title:_().optional(),description:_().optional(),default:X().optional()}),mk=v({type:b("string"),title:_().optional(),description:_().optional(),minLength:Z().optional(),maxLength:Z().optional(),format:we(["email","uri","date","date-time"]).optional(),default:_().optional()}),gk=v({type:we(["number","integer"]),title:_().optional(),description:_().optional(),minimum:Z().optional(),maximum:Z().optional(),default:Z().optional()}),yk=v({type:b("string"),title:_().optional(),description:_().optional(),enum:M(_()),default:_().optional()}),_k=v({type:b("string"),title:_().optional(),description:_().optional(),oneOf:M(v({const:_(),title:_()})),default:_().optional()}),bk=v({type:b("string"),title:_().optional(),description:_().optional(),enum:M(_()),enumNames:M(_()).optional(),default:_().optional()}),wk=F([yk,_k]),vk=v({type:b("array"),title:_().optional(),description:_().optional(),minItems:Z().optional(),maxItems:Z().optional(),items:v({type:b("string"),enum:M(_())}),default:M(_()).optional()}),kk=v({type:b("array"),title:_().optional(),description:_().optional(),minItems:Z().optional(),maxItems:Z().optional(),items:v({anyOf:M(v({const:_(),title:_()}))}),default:M(_()).optional()}),$k=F([vk,kk]),Sk=F([bk,wk,$k]),Ik=F([Sk,hk,mk,gk]),xk=Jr.extend({mode:b("form").optional(),message:_(),requestedSchema:v({type:b("object"),properties:q(_(),Ik),required:M(_()).optional()})}),zk=Jr.extend({mode:b("url"),message:_(),elicitationId:_(),url:_().url()}),Tk=F([xk,zk]),Ek=ve.extend({method:b("elicitation/create"),params:Tk}),Ck=Ke.extend({elicitationId:_()}),Ak=Je.extend({method:b("notifications/elicitation/complete"),params:Ck}),Nk=ke.extend({action:we(["accept","decline","cancel"]),content:Kr(e=>e===null?void 0:e,q(_(),F([_(),Z(),X(),M(_())])).optional())}),Ok=v({type:b("ref/resource"),uri:_()}),Pk=v({type:b("ref/prompt"),name:_()}),Mk=Ve.extend({ref:F([Pk,Ok]),argument:v({name:_(),value:_()}),context:v({arguments:q(_(),_()).optional()}).optional()}),Rk=ve.extend({method:b("completion/complete"),params:Mk}),Lk=ke.extend({completion:be({values:M(_()).max(100),total:re(Z().int()),hasMore:re(X())})}),Dk=v({uri:_().startsWith("file://"),name:_().optional(),_meta:q(_(),Y()).optional()}),Zk=ve.extend({method:b("roots/list"),params:Ve.optional()}),jk=ke.extend({roots:M(Dk)}),Fk=Je.extend({method:b("notifications/roots/list_changed"),params:Ke.optional()});F([ts,_v,Rk,rk,Bv,Vv,Ev,Cv,Ov,Rv,Dv,Wg,Jg,tl,rl,ol,sl]);F([Qu,Xu,vv,Fk,No]);F([Yu,Yg,Qg,Nk,jk,nl,il,el]);F([ts,pk,Ek,Zk,tl,rl,ol,sl]);F([Qu,Xu,ik,jv,Pv,tk,Gv,No,Ak]);F([Yu,wv,Lk,Wv,qv,qg,Av,Hg,ns,Xv,nl,il,el]);class H extends Error{constructor(t,n,r){super(`MCP error ${t}: ${n}`),this.code=t,this.data=r,this.name="McpError"}static fromError(t,n,r){if(t===G.UrlElicitationRequired&&r){const o=r;if(o.elicitations)return new Uk(o.elicitations,n)}return new H(t,n,r)}}class Uk extends H{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(G.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function Ot(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function vd(e){const n=Aw(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=Nw(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function kd(e,t){const n=kg(e,t);if(!n.success)throw n.error;return n.data}const Vk=6e4;class qk{constructor(t){this._options=t,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this._pendingDebouncedNotifications=new Set,this._taskProgressTokens=new Map,this._requestResolvers=new Map,this.setNotificationHandler(Qu,n=>{this._oncancel(n)}),this.setNotificationHandler(Xu,n=>{this._onprogress(n)}),this.setRequestHandler(ts,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(tl,async(n,r)=>{const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new H(G.InvalidParams,"Failed to retrieve task: Task not found");return{...o}}),this.setRequestHandler(rl,async(n,r)=>{const o=async()=>{const i=n.params.taskId;if(!await this._taskStore.getTask(i,r.sessionId))throw new H(G.InvalidParams,`Task not found: ${i}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(i,r.sessionId);){if(a.type==="response"||a.type==="error"){const c=a.message,u=c.id,l=this._requestResolvers.get(u);if(l)if(this._requestResolvers.delete(u),a.type==="response")l(c);else{const d=c,f=new H(d.error.code,d.error.message,d.error.data);l(f)}else{const d=a.type==="response"?"Response":"Error";this._onerror(new Error(`${d} handler missing for request ${u}`))}continue}await this._transport?.send(a.message,{relatedRequestId:r.requestId})}}const s=await this._taskStore.getTask(i,r.sessionId);if(!s)throw new H(G.InvalidParams,`Task not found: ${i}`);if(!Ot(s.status))return await this._waitForTaskUpdate(i,r.signal,r.sessionId),await o();if(Ot(s.status)){const a=await this._taskStore.getTaskResult(i,r.sessionId);return this._clearTaskQueue(i,r.sessionId),{...a,_meta:{...a._meta,[Rt]:{taskId:i}}}}return await o()};return await o()}),this.setRequestHandler(ol,async(n,r)=>{try{const{tasks:o,nextCursor:i}=await this._taskStore.listTasks(n.params?.cursor,r.sessionId);return{tasks:o,nextCursor:i,_meta:{}}}catch(o){throw new H(G.InvalidParams,`Failed to list tasks: ${o instanceof Error?o.message:String(o)}`)}}),this.setRequestHandler(sl,async(n,r)=>{try{const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new H(G.InvalidParams,`Task not found: ${n.params.taskId}`);if(Ot(o.status))throw new H(G.InvalidParams,`Cannot cancel task in terminal status: ${o.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",r.sessionId),this._clearTaskQueue(n.params.taskId,r.sessionId);const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new H(G.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...i}}catch(o){throw o instanceof H?o:new H(G.InvalidRequest,`Failed to cancel task: ${o instanceof Error?o.message:String(o)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,n,r,o,i=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(o,n),startTime:Date.now(),timeout:n,maxTotalTimeout:r,resetTimeoutOnProgress:i,onTimeout:o})}_resetTimeout(t){const n=this._timeoutInfo.get(t);if(!n)return!1;const r=Date.now()-n.startTime;if(n.maxTotalTimeout&&r>=n.maxTotalTimeout)throw this._timeoutInfo.delete(t),H.fromError(G.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:n.maxTotalTimeout,totalElapsed:r});return clearTimeout(n.timeoutId),n.timeoutId=setTimeout(n.onTimeout,n.timeout),!0}_cleanupTimeout(t){const n=this._timeoutInfo.get(t);n&&(clearTimeout(n.timeoutId),this._timeoutInfo.delete(t))}async connect(t){if(this._transport)throw new Error("Already connected to a transport. Call close() before connecting to a new transport, or use a separate Protocol instance per connection.");this._transport=t;const n=this.transport?.onclose;this._transport.onclose=()=>{n?.(),this._onclose()};const r=this.transport?.onerror;this._transport.onerror=i=>{r?.(i),this._onerror(i)};const o=this._transport?.onmessage;this._transport.onmessage=(i,s)=>{o?.(i,s),po(i)||cv(i)?this._onresponse(i):wd(i)?this._onrequest(i,s):av(i)?this._onnotification(i):this._onerror(new Error(`Unknown message type: ${JSON.stringify(i)}`))},await this._transport.start()}_onclose(){const t=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._taskProgressTokens.clear(),this._pendingDebouncedNotifications.clear();for(const r of this._timeoutInfo.values())clearTimeout(r.timeoutId);this._timeoutInfo.clear();for(const r of this._requestHandlerAbortControllers.values())r.abort();this._requestHandlerAbortControllers.clear();const n=H.fromError(G.ConnectionClosed,"Connection closed");this._transport=void 0,this.onclose?.();for(const r of t.values())r(n)}_onerror(t){this.onerror?.(t)}_onnotification(t){const n=this._notificationHandlers.get(t.method)??this.fallbackNotificationHandler;n!==void 0&&Promise.resolve().then(()=>n(t)).catch(r=>this._onerror(new Error(`Uncaught error in notification handler: ${r}`)))}_onrequest(t,n){const r=this._requestHandlers.get(t.method)??this.fallbackRequestHandler,o=this._transport,i=t.params?._meta?.[Rt]?.taskId,s=o?.sessionId,a=this._taskStore;let c=!0,u;if(i&&a&&this._taskMessageQueue&&s!==void 0&&(c=!1,u=(async()=>{if(!await a.getTask(i,s))throw new H(G.InvalidParams,`Task not found: ${i}`);c=!0})()),r===void 0){const h={jsonrpc:"2.0",id:t.id,error:{code:G.MethodNotFound,message:"Method not found"}};if(i&&u){const m={type:"error",message:h,timestamp:Date.now()};u.then(()=>this._enqueueTaskMessage(i,m,s),()=>o?.send(h)).catch(y=>this._onerror(new Error(`Failed to send an error response: ${y}`)))}else i&&this._taskMessageQueue?this._enqueueTaskMessage(i,{type:"error",message:h,timestamp:Date.now()},o?.sessionId).catch(m=>this._onerror(new Error(`Failed to enqueue error response: ${m}`))):o?.send(h).catch(m=>this._onerror(new Error(`Failed to send an error response: ${m}`)));return}const l=new AbortController;this._requestHandlerAbortControllers.set(t.id,l);const d=sv(t.params)?t.params.task:void 0,f=this._taskStore?this.requestTaskStore(t,o?.sessionId):void 0,p={signal:l.signal,sessionId:o?.sessionId,_meta:t.params?._meta,sendNotification:async h=>{if(l.signal.aborted)return;const m={relatedRequestId:t.id};i&&(m.relatedTask={taskId:i}),await this.notification(h,m)},sendRequest:async(h,m,y)=>{if(l.signal.aborted)throw new H(G.ConnectionClosed,"Request was cancelled");const $={...y,relatedRequestId:t.id};i&&!$.relatedTask&&($.relatedTask={taskId:i});const w=$.relatedTask?.taskId??i;return w&&f&&await f.updateTaskStatus(w,"input_required"),await this.request(h,m,$)},authInfo:n?.authInfo,requestId:t.id,requestInfo:n?.requestInfo,taskId:i,taskStore:f,taskRequestedTtl:d?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};(u??Promise.resolve()).then(()=>{if(u&&l.signal.aborted)throw new H(G.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>r(t,p)).then(async h=>{if(l.signal.aborted)return;const m={result:h,jsonrpc:"2.0",id:t.id};i&&this._taskMessageQueue?await this._enqueueTaskMessage(i,{type:"response",message:m,timestamp:Date.now()},o?.sessionId):await o?.send(m)},async h=>{if(l.signal.aborted)return;const m={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(h.code)?h.code:G.InternalError,message:h.message??"Internal error",...h.data!==void 0&&{data:h.data}}};i&&this._taskMessageQueue&&c?await this._enqueueTaskMessage(i,{type:"error",message:m,timestamp:Date.now()},o?.sessionId):await o?.send(m)}).catch(h=>this._onerror(new Error(`Failed to send response: ${h}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===l&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...r}=t.params,o=Number(n),i=this._progressHandlers.get(o);if(!i){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const s=this._responseHandlers.get(o),a=this._timeoutInfo.get(o);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(o)}catch(c){this._responseHandlers.delete(o),this._progressHandlers.delete(o),this._cleanupTimeout(o),s(c);return}i(r)}_onresponse(t){const n=Number(t.id),r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),po(t))r(t);else{const s=new H(t.error.code,t.error.message,t.error.data);r(s)}return}const o=this._responseHandlers.get(n);if(o===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify(t)}`));return}this._responseHandlers.delete(n),this._cleanupTimeout(n);let i=!1;if(po(t)&&t.result&&typeof t.result=="object"){const s=t.result;if(s.task&&typeof s.task=="object"){const a=s.task;typeof a.taskId=="string"&&(i=!0,this._taskProgressTokens.set(a.taskId,n))}}if(i||this._progressHandlers.delete(n),po(t))o(t);else{const s=H.fromError(t.error.code,t.error.message,t.error.data);o(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,n,r){const{task:o}=r??{};if(!o){try{yield{type:"result",result:await this.request(t,n,r)}}catch(s){yield{type:"error",error:s instanceof H?s:new H(G.InternalError,String(s))}}return}let i;try{const s=await this.request(t,el,r);if(s.task)i=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new H(G.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:i},r);if(yield{type:"taskStatus",task:a},Ot(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:i},n,r)}:a.status==="failed"?yield{type:"error",error:new H(G.InternalError,`Task ${i} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new H(G.InternalError,`Task ${i} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:i},n,r)};return}const c=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(u=>setTimeout(u,c)),r?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof H?s:new H(G.InternalError,String(s))}}}request(t,n,r){const{relatedRequestId:o,resumptionToken:i,onresumptiontoken:s,task:a,relatedTask:c}=r??{};return new Promise((u,l)=>{const d=w=>{l(w)};if(!this._transport){d(new Error("Not connected"));return}if(this._options?.enforceStrictCapabilities===!0)try{this.assertCapabilityForMethod(t.method),a&&this.assertTaskCapability(t.method)}catch(w){d(w);return}r?.signal?.throwIfAborted();const f=this._requestMessageId++,p={...t,jsonrpc:"2.0",id:f};r?.onprogress&&(this._progressHandlers.set(f,r.onprogress),p.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(p.params={...p.params,task:a}),c&&(p.params={...p.params,_meta:{...p.params?._meta||{},[Rt]:c}});const h=w=>{this._responseHandlers.delete(f),this._progressHandlers.delete(f),this._cleanupTimeout(f),this._transport?.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:f,reason:String(w)}},{relatedRequestId:o,resumptionToken:i,onresumptiontoken:s}).catch(T=>this._onerror(new Error(`Failed to send cancellation: ${T}`)));const S=w instanceof H?w:new H(G.RequestTimeout,String(w));l(S)};this._responseHandlers.set(f,w=>{if(!r?.signal?.aborted){if(w instanceof Error)return l(w);try{const S=kg(n,w.result);S.success?u(S.data):l(S.error)}catch(S){l(S)}}}),r?.signal?.addEventListener("abort",()=>{h(r?.signal?.reason)});const m=r?.timeout??Vk,y=()=>h(H.fromError(G.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(f,m,r?.maxTotalTimeout,y,r?.resetTimeoutOnProgress??!1);const $=c?.taskId;if($){const w=S=>{const T=this._responseHandlers.get(f);T?T(S):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,w),this._enqueueTaskMessage($,{type:"request",message:p,timestamp:Date.now()}).catch(S=>{this._cleanupTimeout(f),l(S)})}else this._transport.send(p,{relatedRequestId:o,resumptionToken:i,onresumptiontoken:s}).catch(w=>{this._cleanupTimeout(f),l(w)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},nl,n)}async getTaskResult(t,n,r){return this.request({method:"tasks/result",params:t},n,r)}async listTasks(t,n){return this.request({method:"tasks/list",params:t},il,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},zv,n)}async notification(t,n){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability(t.method);const r=n?.relatedTask?.taskId;if(r){const a={...t,jsonrpc:"2.0",params:{...t.params,_meta:{...t.params?._meta||{},[Rt]:n.relatedTask}}};await this._enqueueTaskMessage(r,{type:"notification",message:a,timestamp:Date.now()});return}if((this._options?.debouncedNotificationMethods??[]).includes(t.method)&&!t.params&&!n?.relatedRequestId&&!n?.relatedTask){if(this._pendingDebouncedNotifications.has(t.method))return;this._pendingDebouncedNotifications.add(t.method),Promise.resolve().then(()=>{if(this._pendingDebouncedNotifications.delete(t.method),!this._transport)return;let a={...t,jsonrpc:"2.0"};n?.relatedTask&&(a={...a,params:{...a.params,_meta:{...a.params?._meta||{},[Rt]:n.relatedTask}}}),this._transport?.send(a,n).catch(c=>this._onerror(c))});return}let s={...t,jsonrpc:"2.0"};n?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Rt]:n.relatedTask}}}),await this._transport.send(s,n)}setRequestHandler(t,n){const r=vd(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(o,i)=>{const s=kd(t,o);return Promise.resolve(n(s,i))})}removeRequestHandler(t){this._requestHandlers.delete(t)}assertCanSetRequestHandler(t){if(this._requestHandlers.has(t))throw new Error(`A request handler for ${t} already exists, which would be overridden`)}setNotificationHandler(t,n){const r=vd(t);this._notificationHandlers.set(r,o=>{const i=kd(t,o);return Promise.resolve(n(i))})}removeNotificationHandler(t){this._notificationHandlers.delete(t)}_cleanupTaskProgressHandler(t){const n=this._taskProgressTokens.get(t);n!==void 0&&(this._progressHandlers.delete(n),this._taskProgressTokens.delete(t))}async _enqueueTaskMessage(t,n,r){if(!this._taskStore||!this._taskMessageQueue)throw new Error("Cannot enqueue task message: taskStore and taskMessageQueue are not configured");const o=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,r??this._transport?.sessionId,o)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(t,n);for(const o of r)if(o.type==="request"&&wd(o.message)){const i=o.message.id,s=this._requestResolvers.get(i);s?(s(new H(G.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(i)):this._onerror(new Error(`Resolver missing for request ${i} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n,r){let o=this._options?.defaultTaskPollInterval??1e3;try{const i=await this._taskStore?.getTask(t,r);i?.pollInterval&&(o=i.pollInterval)}catch{}return new Promise((i,s)=>{if(n.aborted){s(new H(G.InvalidRequest,"Request cancelled"));return}const a=setTimeout(i,o);n.addEventListener("abort",()=>{clearTimeout(a),s(new H(G.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async o=>{if(!t)throw new Error("No request provided");return await r.createTask(o,t.id,{method:t.method,params:t.params},n)},getTask:async o=>{const i=await r.getTask(o,n);if(!i)throw new H(G.InvalidParams,"Failed to retrieve task: Task not found");return i},storeTaskResult:async(o,i,s)=>{await r.storeTaskResult(o,i,s,n);const a=await r.getTask(o,n);if(a){const c=No.parse({method:"notifications/tasks/status",params:a});await this.notification(c),Ot(a.status)&&this._cleanupTaskProgressHandler(o)}},getTaskResult:o=>r.getTaskResult(o,n),updateTaskStatus:async(o,i,s)=>{const a=await r.getTask(o,n);if(!a)throw new H(G.InvalidParams,`Task "${o}" not found - it may have been cleaned up`);if(Ot(a.status))throw new H(G.InvalidParams,`Cannot update task "${o}" from terminal status "${a.status}" to "${i}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(o,i,s,n);const c=await r.getTask(o,n);if(c){const u=No.parse({method:"notifications/tasks/status",params:c});await this.notification(u),Ot(c.status)&&this._cleanupTaskProgressHandler(o)}},listTasks:o=>r.listTasks(o,n)}}}function $d(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Hk(e,t){const n={...e};for(const r in t){const o=r,i=t[o];if(i===void 0)continue;const s=n[o];$d(s)&&$d(i)?n[o]={...s,...i}:n[o]=i}return n}(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,n)=>(typeof require<"u"?require:t)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});class Bk extends qk{_registeredMethods=new Set;_eventSlots=new Map;onEventDispatch(t,n){}_ensureEventSlot(t){let n=this._eventSlots.get(t);if(!n){let r=this.eventSchemas[t];if(!r)throw Error(`Unknown event: ${String(t)}`);n={listeners:[]},this._eventSlots.set(t,n);let o=r.shape.method.value;this._registeredMethods.add(o);let i=n;super.setNotificationHandler(r,s=>{let a=s.params;this.onEventDispatch(t,a),i.onHandler?.(a);for(let c of[...i.listeners])c(a)})}return n}setEventHandler(t,n){let r=this._ensureEventSlot(t);r.onHandler&&n&&console.warn(`[MCP Apps] on${String(t)} handler replaced. Use addEventListener("${String(t)}", …) to add multiple listeners without replacing.`),r.onHandler=n}getEventHandler(t){return this._eventSlots.get(t)?.onHandler}addEventListener(t,n){this._ensureEventSlot(t).listeners.push(n)}removeEventListener(t,n){let r=this._eventSlots.get(t);if(!r)return;let o=r.listeners.indexOf(n);o!==-1&&r.listeners.splice(o,1)}setRequestHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setRequestHandler"),super.setRequestHandler(t,n)};setNotificationHandler=(t,n)=>{this._assertMethodNotRegistered(t,"setNotificationHandler"),super.setNotificationHandler(t,n)};warnIfRequestHandlerReplaced(t,n,r){n&&r&&console.warn(`[MCP Apps] ${t} handler replaced. Previous handler will no longer be called.`)}replaceRequestHandler=(t,n)=>{let r=t.shape.method.value;this._registeredMethods.add(r),super.setRequestHandler(t,n)};_assertMethodNotRegistered(t,n){let r=t.shape.method.value;if(this._registeredMethods.has(r))throw Error(`Handler for "${r}" already registered (via ${n}). Use addEventListener() to attach multiple listeners, or the on* setter for replace semantics.`);this._registeredMethods.add(r)}}var Kk="2026-01-26",Jk="ui/notifications/tool-input-partial";class Xg{eventTarget;eventSource;messageListener;constructor(t=window.parent,n){this.eventTarget=t,this.eventSource=n,this.messageListener=r=>{if(n&&r.source!==this.eventSource){console.debug("Ignoring message from unknown source",r);return}let o=uv.safeParse(r.data);o.success?(console.debug("Parsed message",o.data),this.onmessage?.(o.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",o.error.message,r):(console.error("Failed to parse message",o.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+o.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==Jk&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var Wk=F([b("light"),b("dark")]).describe("Color theme preference for the host environment."),Jn=F([b("inline"),b("fullscreen"),b("pip")]).describe("Display mode for UI presentation."),Gk=F([b("--color-background-primary"),b("--color-background-secondary"),b("--color-background-tertiary"),b("--color-background-inverse"),b("--color-background-ghost"),b("--color-background-info"),b("--color-background-danger"),b("--color-background-success"),b("--color-background-warning"),b("--color-background-disabled"),b("--color-text-primary"),b("--color-text-secondary"),b("--color-text-tertiary"),b("--color-text-inverse"),b("--color-text-ghost"),b("--color-text-info"),b("--color-text-danger"),b("--color-text-success"),b("--color-text-warning"),b("--color-text-disabled"),b("--color-border-primary"),b("--color-border-secondary"),b("--color-border-tertiary"),b("--color-border-inverse"),b("--color-border-ghost"),b("--color-border-info"),b("--color-border-danger"),b("--color-border-success"),b("--color-border-warning"),b("--color-border-disabled"),b("--color-ring-primary"),b("--color-ring-secondary"),b("--color-ring-inverse"),b("--color-ring-info"),b("--color-ring-danger"),b("--color-ring-success"),b("--color-ring-warning"),b("--font-sans"),b("--font-mono"),b("--font-weight-normal"),b("--font-weight-medium"),b("--font-weight-semibold"),b("--font-weight-bold"),b("--font-text-xs-size"),b("--font-text-sm-size"),b("--font-text-md-size"),b("--font-text-lg-size"),b("--font-heading-xs-size"),b("--font-heading-sm-size"),b("--font-heading-md-size"),b("--font-heading-lg-size"),b("--font-heading-xl-size"),b("--font-heading-2xl-size"),b("--font-heading-3xl-size"),b("--font-text-xs-line-height"),b("--font-text-sm-line-height"),b("--font-text-md-line-height"),b("--font-text-lg-line-height"),b("--font-heading-xs-line-height"),b("--font-heading-sm-line-height"),b("--font-heading-md-line-height"),b("--font-heading-lg-line-height"),b("--font-heading-xl-line-height"),b("--font-heading-2xl-line-height"),b("--font-heading-3xl-line-height"),b("--border-radius-xs"),b("--border-radius-sm"),b("--border-radius-md"),b("--border-radius-lg"),b("--border-radius-xl"),b("--border-radius-full"),b("--border-width-regular"),b("--shadow-hairline"),b("--shadow-sm"),b("--shadow-md"),b("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),Yk=q(Gk.describe(`Style variables for theming MCP apps.
71
71
 
72
72
  Individual style keys are optional - hosts may provide any subset of these values.
73
73
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
74
74
 
75
75
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
76
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),j([y(),nn()]).describe(`Style variables for theming MCP apps.
76
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),F([_(),sn()]).describe(`Style variables for theming MCP apps.
77
77
 
78
78
  Individual style keys are optional - hosts may provide any subset of these values.
79
79
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
@@ -85,10 +85,10 @@ Individual style keys are optional - hosts may provide any subset of these value
85
85
  Values are strings containing CSS values (colors, sizes, font stacks, etc.).
86
86
 
87
87
  Note: This type uses \`Record<K, string | undefined>\` rather than \`Partial<Record<K, string>>\`
88
- for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);b({method:_("ui/open-link"),params:b({url:y().describe("URL to open in the host's browser")})});var yk=b({isError:Q().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),_k=b({isError:Q().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),bk=b({isError:Q().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();b({method:_("ui/notifications/sandbox-proxy-ready"),params:b({})});var el=b({connectDomains:A(y()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
88
+ for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);v({method:b("ui/open-link"),params:v({url:_().describe("URL to open in the host's browser")})});var Qk=v({isError:X().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),Xk=v({isError:X().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),e$=v({isError:X().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();v({method:b("ui/notifications/sandbox-proxy-ready"),params:v({})});var pl=v({connectDomains:M(_()).optional().describe(`Origins for network requests (fetch/XHR/WebSocket).
89
89
 
90
90
  - Maps to CSP \`connect-src\` directive
91
- - Empty or omitted → no network connections (secure default)`),resourceDomains:A(y()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:A(y()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:A(y()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),tl=b({camera:b({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:b({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:b({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:b({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});b({method:_("ui/notifications/size-changed"),params:b({width:Z().optional().describe("New width in pixels."),height:Z().optional().describe("New height in pixels.")})});var wk=b({method:_("ui/notifications/tool-input"),params:b({arguments:V(y(),Y().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),vk=b({method:_("ui/notifications/tool-input-partial"),params:b({arguments:V(y(),Y().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),kk=b({method:_("ui/notifications/tool-cancelled"),params:b({reason:y().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),$k=b({fonts:y().optional()}),Sk=b({variables:gk.optional().describe("CSS variables for theming the app."),css:$k.optional().describe("CSS blocks that apps can inject.")}),Ik=b({method:_("ui/resource-teardown"),params:b({})});V(y(),Y());var pd=b({text:b({}).optional().describe("Host supports text content blocks."),image:b({}).optional().describe("Host supports image content blocks."),audio:b({}).optional().describe("Host supports audio content blocks."),resource:b({}).optional().describe("Host supports resource content blocks."),resourceLink:b({}).optional().describe("Host supports resource link content blocks."),structuredContent:b({}).optional().describe("Host supports structured content.")});b({method:_("ui/notifications/request-teardown"),params:b({}).optional()});var zk=b({experimental:V(y(),V(y(),Mr()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:b({}).optional().describe("Host supports opening external URLs."),downloadFile:b({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:b({listChanged:Q().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:b({listChanged:Q().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:b({}).optional().describe("Host accepts log messages."),sandbox:b({permissions:tl.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:el.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:pd.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:pd.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:b({tools:b({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),xk=b({experimental:V(y(),V(y(),Mr()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:b({listChanged:Q().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:A(Un).optional().describe("Display modes the app supports.")});b({method:_("ui/notifications/initialized"),params:b({}).optional()});b({csp:el.optional().describe("Content Security Policy configuration for UI resources."),permissions:tl.optional().describe("Sandbox permissions requested by the UI resource."),domain:y().optional().describe(`Dedicated origin for view sandbox.
91
+ - Empty or omitted → no network connections (secure default)`),resourceDomains:M(_()).optional().describe("Origins for static resources (images, scripts, stylesheets, fonts, media).\n\n- Maps to CSP `img-src`, `script-src`, `style-src`, `font-src`, `media-src` directives\n- Wildcard subdomains supported: `https://*.example.com`\n- Empty or omitted → no network resources (secure default)"),frameDomains:M(_()).optional().describe("Origins for nested iframes.\n\n- Maps to CSP `frame-src` directive\n- Empty or omitted → no nested iframes allowed (`frame-src 'none'`)"),baseUriDomains:M(_()).optional().describe("Allowed base URIs for the document.\n\n- Maps to CSP `base-uri` directive\n- Empty or omitted → only same origin allowed (`base-uri 'self'`)")}),hl=v({camera:v({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:v({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:v({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:v({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});v({method:b("ui/notifications/size-changed"),params:v({width:Z().optional().describe("New width in pixels."),height:Z().optional().describe("New height in pixels.")})});var t$=v({method:b("ui/notifications/tool-input"),params:v({arguments:q(_(),Y().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),n$=v({method:b("ui/notifications/tool-input-partial"),params:v({arguments:q(_(),Y().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),r$=v({method:b("ui/notifications/tool-cancelled"),params:v({reason:_().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),o$=v({fonts:_().optional()}),i$=v({variables:Yk.optional().describe("CSS variables for theming the app."),css:o$.optional().describe("CSS blocks that apps can inject.")}),s$=v({method:b("ui/resource-teardown"),params:v({})});q(_(),Y());var Sd=v({text:v({}).optional().describe("Host supports text content blocks."),image:v({}).optional().describe("Host supports image content blocks."),audio:v({}).optional().describe("Host supports audio content blocks."),resource:v({}).optional().describe("Host supports resource content blocks."),resourceLink:v({}).optional().describe("Host supports resource link content blocks."),structuredContent:v({}).optional().describe("Host supports structured content.")});v({method:b("ui/notifications/request-teardown"),params:v({}).optional()});var a$=v({experimental:q(_(),q(_(),Fr()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:v({}).optional().describe("Host supports opening external URLs."),downloadFile:v({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:v({listChanged:X().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:v({listChanged:X().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:v({}).optional().describe("Host accepts log messages."),sandbox:v({permissions:hl.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:pl.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:Sd.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:Sd.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:v({tools:v({}).optional().describe("Host supports tool use via `tools` and `toolChoice` parameters.")}).optional().describe("Host supports LLM sampling (sampling/createMessage) from the view.\nMirrors the MCP `ClientCapabilities.sampling` shape so hosts can pass it through.")}),c$=v({experimental:q(_(),q(_(),Fr()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:v({listChanged:X().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:M(Jn).optional().describe("Display modes the app supports.")});v({method:b("ui/notifications/initialized"),params:v({}).optional()});v({csp:pl.optional().describe("Content Security Policy configuration for UI resources."),permissions:hl.optional().describe("Sandbox permissions requested by the UI resource."),domain:_().optional().describe(`Dedicated origin for view sandbox.
92
92
 
93
93
  Useful when views need stable, dedicated origins for OAuth callbacks, CORS policies, or API key allowlists.
94
94
 
@@ -96,19 +96,19 @@ Useful when views need stable, dedicated origins for OAuth callbacks, CORS polic
96
96
  - Hash-based subdomains (e.g., \`{hash}.claudemcpcontent.com\`)
97
97
  - URL-derived subdomains (e.g., \`www-example-com.oaiusercontent.com\`)
98
98
 
99
- If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:Q().optional().describe(`Visual boundary preference - true if view prefers a visible border.
99
+ If omitted, host uses default sandbox origin (typically per-conversation).`),prefersBorder:X().optional().describe(`Visual boundary preference - true if view prefers a visible border.
100
100
 
101
101
  Boolean requesting whether a visible border and background is provided by the host. Specifying an explicit value for this is recommended because hosts' defaults may vary.
102
102
 
103
103
  - \`true\`: request visible border + background
104
104
  - \`false\`: request no visible border + background
105
- - omitted: host decides border`)});b({method:_("ui/request-display-mode"),params:b({mode:Un.describe("The display mode being requested.")})});var Tk=b({mode:Un.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),Ck=j([_("model"),_("app")]).describe("Tool visibility scope - who can access the tool.");b({resourceUri:y().optional(),visibility:A(Ck).optional().describe(`Who can access this tool. Default: ["model", "app"]
105
+ - omitted: host decides border`)});v({method:b("ui/request-display-mode"),params:v({mode:Jn.describe("The display mode being requested.")})});var u$=v({mode:Jn.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),l$=F([b("model"),b("app")]).describe("Tool visibility scope - who can access the tool.");v({resourceUri:_().optional(),visibility:M(l$).optional().describe(`Who can access this tool. Default: ["model", "app"]
106
106
  - "model": Tool visible to and callable by the agent
107
- - "app": Tool callable by the app from this server only`),csp:Rt().optional(),permissions:Rt().optional()});b({mimeTypes:A(y()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});b({method:_("ui/download-file"),params:b({contents:A(j([Ig,zg])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});b({method:_("ui/message"),params:b({role:_("user").describe('Message role, currently only "user" is supported.'),content:A(Wr).describe("Message content blocks (text, image, etc.).")})});b({method:_("ui/notifications/sandbox-resource-ready"),params:b({html:y().describe("HTML content to load into the inner iframe."),sandbox:y().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:el.optional().describe("CSP configuration from resource metadata."),permissions:tl.optional().describe("Sandbox permissions from resource metadata.")})});var Ek=b({method:_("ui/notifications/tool-result"),params:Ji.describe("Standard MCP tool execution result.")}),Pg=b({toolInfo:b({id:Vr.optional().describe("JSON-RPC id of the tools/call request."),tool:Xu.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:hk.optional().describe("Current color theme preference."),styles:Sk.optional().describe("Style configuration for theming the app."),displayMode:Un.optional().describe("How the UI is currently displayed."),availableDisplayModes:A(Un).optional().describe("Display modes the host supports."),containerDimensions:j([b({height:Z().describe("Fixed container height in pixels.")}),b({maxHeight:j([Z(),nn()]).optional().describe("Maximum container height in pixels.")})]).and(j([b({width:Z().describe("Fixed container width in pixels.")}),b({maxWidth:j([Z(),nn()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
108
- container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:y().optional().describe("User's language and region preference in BCP 47 format."),timeZone:y().optional().describe("User's timezone in IANA format."),userAgent:y().optional().describe("Host application identifier."),platform:j([_("web"),_("desktop"),_("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:b({touch:Q().optional().describe("Whether the device supports touch input."),hover:Q().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:b({top:Z().describe("Top safe area inset in pixels."),right:Z().describe("Right safe area inset in pixels."),bottom:Z().describe("Bottom safe area inset in pixels."),left:Z().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),Nk=b({method:_("ui/notifications/host-context-changed"),params:Pg.describe("Partial context update containing only changed fields.")});b({method:_("ui/update-model-context"),params:b({content:A(Wr).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:V(y(),Y().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});b({method:_("ui/initialize"),params:b({appInfo:Bi.describe("App identification (name and version)."),appCapabilities:xk.describe("Features and capabilities this app provides."),protocolVersion:y().describe("Protocol version this app supports.")})});var Ok=b({protocolVersion:y().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:Bi.describe("Host application identification and version."),hostCapabilities:zk.describe("Features and capabilities provided by the host."),hostContext:Pg.describe("Rich context about the host environment.")}).passthrough(),Pk={target:"draft-2020-12"};async function hd(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](Pk);if(n.vendor==="zod"){let{z:r}=await Gg(()=>Promise.resolve().then(()=>kw),void 0,import.meta.url);return r.toJSONSchema(e,{io:t})}throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function md(e,t,n=""){let r=await e["~standard"].validate(t);if(r.issues){let o=r.issues.map(i=>{let s=i.path?.map(a=>typeof a=="object"?a.key:a).join(".");return s?`${s}: ${i.message}`:i.message}).join("; ");throw Error(n+o)}return r.value}function Ak(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Mk(e){if(document.getElementById("__mcp-host-fonts"))return;let t=document.createElement("style");t.id="__mcp-host-fonts",t.textContent=e,document.head.appendChild(t)}class nl extends dk{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(t){if(this._initializedSent)return;let n=`[ext-apps] App.${t}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:wk,toolinputpartial:vk,toolresult:Ek,toolcancelled:kk,hostcontextchanged:Nk};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!nl.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(t,n){n&&this._assertHandlerTiming(t),super.setEventHandler(t,n)}addEventListener(t,n){this._assertHandlerTiming(t),super.addEventListener(t,n)}onEventDispatch(t,n){t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...n})}constructor(t,n={},r={autoResize:!0}){super(r),this._appInfo=t,this._capabilities=n,this.options=r,r.allowUnsafeEval||me({jitless:!0}),this.setRequestHandler(Ki,o=>(console.log("Received ping:",o.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=lk(this._capabilities,t)}registerTool(t,n,r){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let o=this,i=()=>{o._initializedSent&&o._capabilities.tools?.listChanged&&o.sendToolListChanged()},s=n.inputSchema!==void 0,a={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(c){Object.assign(this,c),i()},remove(){o._registeredTools[t]===a&&(delete o._registeredTools[t],i())},handler:async(c,u)=>{if(!a.enabled)throw Error(`Tool ${t} is disabled`);let l;if(s){let d=a.inputSchema,f=d?await md(d,c??{},`Invalid input for tool ${t}: `):c??{};l=await r(f,u)}else l=await r(u);return a.outputSchema&&!l.isError&&(l.structuredContent=await md(a.outputSchema,l.structuredContent,`Invalid output for tool ${t}: `)),l}};return this._registeredTools[t]=a,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,n)=>{let r=this._registeredTools[t.name];if(!r)throw Error(`Tool ${t.name} not found`);return r.handler(t.arguments,n)},this.onlisttools=async(t,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([r,o])=>o.enabled).map(async([r,o])=>{let i={name:r,title:o.title,description:o.description,inputSchema:o.inputSchema?await hd(o.inputSchema,"input"):{type:"object",properties:{}}};return o.outputSchema&&(i.outputSchema=await hd(o.outputSchema,"output")),o.annotations&&(i.annotations=o.annotations),o._meta&&(i._meta=o._meta),i}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler(Ik,(n,r)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n.params,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler(Tg,(n,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,r)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler(xg,(n,r)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,r)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${t} registered`)}}assertNotificationCapability(t){}assertTaskCapability(t){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(t){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(t,n){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},Ji,{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},Sg,n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},$g,n)}async createSamplingMessage(t,n){this._assertInitialized("createSamplingMessage");let r=t.tools?Ng:Eg;return await this.request({method:"sampling/createMessage",params:t},r,n)}sendMessage(t,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},bk,n)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},Zu,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},yk,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},_k,n)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},Tk,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,r=0,o=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let s=document.documentElement,a=s.style.height;s.style.height="max-content";let c=Math.ceil(s.getBoundingClientRect().height);s.style.height=a;let u=Math.ceil(window.innerWidth);(u!==n||c!==r)&&(n=u,r=c,this.sendSizeChanged({width:u,height:c}))}))};o();let i=new ResizeObserver(o);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(t=new Og(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(t);try{let r=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:fk}},Ok,n);if(r===void 0)throw Error(`Server sent invalid initialize result: ${r}`);this._hostCapabilities=r.hostCapabilities,this._hostInfo=r.hostInfo,this._hostContext=r.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(r){throw this.close(),r}}}const Rk="http://www.w3.org/2000/svg",Lk=.45,Zk=2.5,Dk=5,jk="chain-insights.flows.v1",rl="cia-graph-model",Fk=90,pt={rest:.6,related:.95,faded:.07},gd={checked:24,other:19},Vn=16,Uk=[["Sanctioned","Sanctioned"],["Scam","Scam"],["Poisoned","Poisoned"],["OnMoneyTrail","On money trail"],["Mixer","Mixer"],["Bridge","Bridge"],["Exchange","Exchange"],["Victim","Victim"],["Targeted","Targeted"]],Gr=["exchange","scam","sanctioned","victim","pool","other"],Vk={exchange:"infrastructure",scam:"danger",sanctioned:"danger",victim:"target",pool:"trail",other:"neutral"},Ag={exchange:"Exchange",scam:"Scam",sanctioned:"Sanctioned",victim:"Victim",pool:"Pool",other:""};function ol(e){return!!e&&e.schema===jk}function qk(e){return!!e&&e.kind===rl}function le(e){return String(e??"").trim().toLowerCase()}function Hk(e){const t=le(e);return Gr.includes(t)?t:"other"}function dt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Is(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function Bk(e){const t=String(e??"").toUpperCase();return t==="IN"||t==="OUT"||t==="MIXED"||t==="CHECKED"?t:"OUT"}function je(e){return qk(e)?e:ol(e)?Kk(e):Jk(e)}function Kk(e){const t=le(e.center),n=new Map;for(const a of e.nodes??[]){const c=le(a?.address);c&&!n.has(c)&&n.set(c,a)}const r=new Map,o=[],i=new Set;for(const a of e.edges??[]){const c=le(a?.from),u=le(a?.to);if(!n.has(c)||!n.has(u)||c===u)continue;const l=`${c}->${u}`;i.has(l)||(i.add(l),o.push({id:l,from:c,to:u,source:"flows",amount_usd_sum:dt(a.usd),tx_count:dt(a.tx_count),first_seen_timestamp:dt(a.first_seen_ms),last_seen_timestamp:dt(a.last_seen_ms)}),u===t&&yd(r,c,"IN"),c===t&&yd(r,u,"OUT"))}const s=[...n.entries()].map(([a,c])=>{const u=r.get(a),l=a===t?"CHECKED":u?.size===2?"MIXED":u?.has("IN")?"IN":"OUT";return{id:a,address:a,direction:l,hop:a===t?0:u?1:2,labels:Is(c.labels),taxonomy:[],role:Hk(c.role),total_in_usd:dt(c.total_in_usd),total_out_usd:dt(c.total_out_usd),degree_in:dt(c.degree_in),degree_out:dt(c.degree_out)}});return{kind:rl,checked_address:t,network:e.network??null,nodes:s,edges:o,truncated:!!e.truncated,cursor:e.cursor??null}}function yd(e,t,n){e.has(t)||e.set(t,new Set),e.get(t).add(n)}function Jk(e){const t=(e?.nodes??[]).map(r=>({...r,id:String(r.id??r.address),address:r.address,hop:Number(r.hop)||0,direction:r.address===e.checked_address?"CHECKED":Bk(r.direction),labels:Is(r.labels),taxonomy:Is(r.taxonomy),role:null})),n=(e?.edges??[]).map(r=>({...r,id:String(r.id??`${r.from}->${r.to}`),amount_usd_sum:r.amount_usd_sum??null,tx_count:r.tx_count??null,first_seen_timestamp:r.first_seen_timestamp??null,last_seen_timestamp:r.last_seen_timestamp??null,source:"risk"}));return{kind:rl,checked_address:e?.checked_address??"",network:null,nodes:t,edges:n,truncated:!1,cursor:null}}function Wk(e,t,n){const r=je(t),o=mo(e,n??r.checked_address),i=e.nodes.find(d=>d.id===o),s=new Map(e.nodes.map(d=>[le(d.address),d])),a=[];for(const d of r.nodes){if(s.has(le(d.address)))continue;const f=!i||i.direction==="CHECKED"?d.direction==="CHECKED"?"OUT":d.direction:i.direction,p={...d,id:d.id,direction:f,hop:Math.min(2,(i?.hop??0)+1)};a.push(p),s.set(le(d.address),p)}const c=new Set(e.edges.map(d=>d.id)),u=new Set(e.edges.map(d=>`${le(d.from)}->${le(d.to)}`)),l=[...e.edges];for(const d of r.edges){const f=`${le(d.from)}->${le(d.to)}`;if(c.has(d.id)||u.has(f)||!s.has(le(d.from))||!s.has(le(d.to)))continue;const p=s.get(le(d.from)).address,h=s.get(le(d.to)).address;l.push({...d,from:p,to:h}),c.add(d.id),u.add(f)}return{model:{...e,nodes:[...e.nodes,...a],edges:l,truncated:e.truncated||r.truncated},added:a.map(d=>d.id)}}function mo(e,t){if(t==null)return null;const n=le(t);return e.nodes.find(o=>o.id===t||le(o.address)===n)?.id??null}function et(e){return typeof e!="string"||e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function il(e){return String(e??"").trim().replace(/\s+/g," ")}function zo(e){return il(e).replaceAll(" ","").toLowerCase()}function yt(e){const t=[...e.taxonomy??[],...e.labels??[]],n=new Set,r=[];for(const o of t){const i=il(o),s=i.toLowerCase();!i||s==="address"||n.has(s)||(n.add(s),r.push(i))}return r}function so(e,t){const n=new Set(yt(e).map(zo));return t.some(r=>n.has(zo(r)))}function Gk(e){if(e.role&&Gr.includes(e.role))return Vk[e.role];if(so(e,["Sanctioned","Scam","Poisoned"]))return"danger";if(so(e,["Victim","Targeted"]))return"target";if(so(e,["OnMoneyTrail","Mixer"]))return"trail";if(so(e,["Exchange","Bridge","token contract"]))return"infrastructure";if(e.risk_score!=null){const t=String(e.risk_level).toLowerCase();if(t==="critical"||t==="high"||t==="medium"||t==="low")return t}return"neutral"}function ue(e){return`var(--cia-graph-${e})`}const Yk={semantic:{danger:{stroke:ue("danger"),fill:ue("node")},target:{stroke:ue("target"),fill:ue("node")},trail:{stroke:ue("trail"),fill:ue("node")},infrastructure:{stroke:ue("infrastructure"),fill:ue("node")},neutral:{stroke:ue("neutral"),fill:ue("node")}},risk:{CRITICAL:{stroke:ue("critical"),fill:ue("node")},HIGH:{stroke:ue("high"),fill:ue("node")},MEDIUM:{stroke:ue("medium"),fill:ue("node")},LOW:{stroke:ue("low"),fill:ue("node")}}};function Qk(e,t=Yk){const n=Gk(e);return n==="critical"||n==="high"||n==="medium"||n==="low"?t.risk[n.toUpperCase()]??t.semantic.neutral:t.semantic[n]}function Xk(e){return e.role&&Gr.includes(e.role)?ue(`role-${e.role}`):Qk(e).stroke}function Wi(e){if(e.role&&e.role!=="other"&&Gr.includes(e.role))return Ag[e.role];const t=yt(e);for(const[r,o]of Uk)if(t.some(i=>zo(i)===zo(r)))return o;return(Array.isArray(e.labels)?e.labels.map(il).filter(Boolean).sort((r,o)=>r.localeCompare(o)):[])[0]??""}function zs(e){return Math.min(Zk,Math.max(Lk,e))}function Yr(e){return[...e.nodes??[]].sort((t,n)=>String(t.id).localeCompare(String(n.id)))}function sl(e,t=Yr(e)){return t.find(n=>n.address===e.checked_address)??t[0]}function ao(e,t){return e.address===t?43:e.hop>=2?25:30}function xs(e,t){return e.address===t?gd.checked:gd.other}function Gi(e,t,n){const r=e.address===t,o=xs(e,t),i=Wi(e),s=[];return i&&s.push({kind:"role",text:B$(i),y:o+17}),s.push({kind:"address",text:et(e.address),y:o+(i?33:17)}),n&&s.push({kind:"note",text:n,y:o+(i?48:32)}),{radius:o,ring:r,dot:r?8:5,texts:s}}const e$={role:{size:13,advance:.68},address:{size:11,advance:.62},note:{size:11,advance:.6}},os=2;function al(e){const t=e.radius+(e.ring?7:2),n=[{kind:"circle",box:{x1:-t,y1:-t,x2:t,y2:t}}];for(const r of e.texts){const o=e$[r.kind],i=[...r.text].length*o.size*o.advance/2+os;n.push({kind:r.kind,box:{x1:-i,y1:r.y-o.size*.8-os,x2:i,y2:r.y+o.size*.25+os}})}return n}function Mg(e){return e.length?{x1:Math.min(...e.map(t=>t.x1)),y1:Math.min(...e.map(t=>t.y1)),x2:Math.max(...e.map(t=>t.x2)),y2:Math.max(...e.map(t=>t.y2))}:null}function t$(e){return Mg(al(e).map(t=>t.box))}const cl=(e,t)=>(e instanceof Map?e.get(t):e?.[t])??null;function n$(e,t,n){const r=je(e),o=[];for(const i of r.nodes){const s=t[i.id];if(s)for(const{kind:a,box:c}of al(Gi(i,r.checked_address,cl(n,i.id))))o.push({id:i.id,kind:a,x1:s.x+c.x1,y1:s.y+c.y1,x2:s.x+c.x2,y2:s.y+c.y2})}return o}function r$(e,t,n){return Mg(n$(e,t,n))}function o$(e,t){return e.x1<t.x2&&t.x1<e.x2&&e.y1<t.y2&&t.y1<e.y2}function i$(e){let t=0;for(const n of String(e))t=(t<<5)-t+n.charCodeAt(0)|0;return Math.abs(t)}function s$(e,t,n){const r=je(e),o={x:t/2,y:n/2},i={},s=Yr(r),a=sl(r,s);if(!a)return i;i[a.id]=o;const c=new Map;for(const u of s){if(u.id===a.id)continue;let l=u.direction==="IN"?-1:1;u.direction==="MIXED"&&(l=i$(u.id)%2?-1:1);const d=Math.min(2,Math.max(1,Number(u.hop)||1)),f=`${l}:${d}`;c.has(f)||c.set(f,[]),c.get(f).push(u)}for(const[u,l]of c){const[d,f]=u.split(":"),p=Number(d),h=Number(f),m=o.x+p*(h===1?t*.23:t*.43);Object.assign(i,a$(l,m,o.y,r.checked_address))}return i}function a$(e,t,n,r,o=24){const i=e.map((s,a)=>({node:s,x:t,y:n+(a-(e.length-1)/2)*64}));for(let s=0;s<o;s++){for(let u=1;u<i.length;u++){const l=i[u-1],d=i[u];if(!l||!d)continue;const f=ao(l.node,r)+ao(d.node,r)+20;d.y=Math.max(d.y,l.y+f)}for(let u=i.length-2;u>=0;u--){const l=i[u],d=i[u+1];if(!l||!d)continue;const f=ao(l.node,r)+ao(d.node,r)+20;l.y=Math.min(l.y,d.y-f)}const a=i[0],c=i[i.length-1];if(a&&c){const u=(a.y+c.y)/2,l=n-u;for(const d of i)d.y+=l}}return Object.fromEntries(i.map(s=>[s.node.id,{x:s.x,y:s.y}]))}function c$(e,t,n){const r=je(e),o={x:t/2,y:n/2},i={},s=Yr(r),a=sl(r,s);if(!a)return i;i[a.id]=o;const c=s.filter(u=>u.id!==a.id);return c.forEach((u,l)=>{const d=-Math.PI/2+l*Math.PI*2/Math.max(1,c.length),f=u.hop>=2?Math.min(t,n)*.39:Math.min(t,n)*.27;i[u.id]={x:o.x+Math.cos(d)*f,y:o.y+Math.sin(d)*f}}),i}function u$(e,t,n,r){const o=je(e),i=Yr(o).filter(c=>t[c.id]),s=i.find(c=>c.address===o.checked_address);for(let c=0;c<i.length;c++)for(let u=c+1;u<i.length;u++){const l=i[c],d=i[u],f=l&&t[l.id],p=d&&t[d.id];if(!f||!p)continue;const h=p.x-f.x||.1,m=p.y-f.y||.1,k=Math.max(1,Math.hypot(h,m)),I=Math.max(0,88-k)*.012;f.x-=h/k*I,f.y-=m/k*I,p.x+=h/k*I,p.y+=m/k*I}const a=new Map(i.map(c=>[c.address,c]));for(const c of o.edges){const u=a.get(c.from),l=a.get(c.to);if(!u||!l)continue;const d=t[u.id],f=t[l.id];if(!d||!f)continue;const p=f.x-d.x,h=f.y-d.y,m=Math.max(1,Math.hypot(p,h)),k=(m-155)*.003;u!==s&&(d.x+=p/m*k,d.y+=h/m*k),l!==s&&(f.x-=p/m*k,f.y-=h/m*k)}return s&&(t[s.id]={x:n/2,y:r/2}),t}function l$(e,t,n,r=Fk){const o=je(e),i=c$(o,t,n);for(let s=0;s<r;s++)u$(o,i,t,n);return i}function co(e,t,n,r){return t==="tree"?s$(e,n,r):l$(e,n,r)}function d$(e,t,n,r,o={}){const i=je(e),s=t[n],a={...t};if(!s)return a;const c=o.spacing??80,u=o.gap??48,l=Math.max(1,o.perColumn??6),d=i.nodes.find(v=>v.id===n),f=new Map(i.nodes.map(v=>[v.id,v])),p=v=>t$(Gi(v,i.checked_address,cl(o.notes,v.id))),h=i.nodes.flatMap(v=>{const z=t[v.id];if(!z)return[];const C=p(v);return[{x1:z.x+C.x1,x2:z.x+C.x2}]});let m=h.length?Math.min(...h.map(v=>v.x1)):s.x,k=h.length?Math.max(...h.map(v=>v.x2)):s.x;const I={left:[],right:[]};for(const v of[...r].sort()){const z=f.get(v);if(!z||a[v])continue;const C=i.edges.some(N=>N.from===z.address&&N.to===d?.address),R=i.edges.some(N=>N.to===z.address&&N.from===d?.address);I[C&&!R?"left":"right"].push(z)}for(const v of["left","right"]){const z=I[v];for(let C=0;C<z.length;C+=l){const R=z.slice(C,C+l),N=R.map(p),U=Math.max(...N.map(fe=>Math.max(-fe.x1,fe.x2))),de=Math.max(c,Math.max(...N.map(fe=>fe.y2))-Math.min(...N.map(fe=>fe.y1))+6),re=v==="left"?m-u-U:k+u+U;R.forEach((fe,Te)=>{a[fe.id]={x:re,y:s.y+(Te-(R.length-1)/2)*de}}),v==="left"?m=re-U:k=re+U}}return a}function f$(e,t,n,r=Vn){const o=Math.max(1,e.x2-e.x1),i=Math.max(1,e.y2-e.y1),s=zs(Math.min((t-r*2)/o,(n-r*2)/i));return{x:t/2-(e.x1+e.x2)/2*s,y:n/2-(e.y1+e.y2)/2*s,scale:s}}function _d(e,t,n,r=Vn){return Math.min((t-r*2)/Math.max(1,e.x2-e.x1),(n-r*2)/Math.max(1,e.y2-e.y1))}function p$(e,t,n,r,o=4){const i=t.x-e.x,s=t.y-e.y,a=Math.hypot(i,s),c=n+o,u=r+o;if(!Number.isFinite(a)||a<=0||c+u>=a)return null;const l=i/a,d=s/a;return{x1:e.x+l*c,y1:e.y+d*c,x2:t.x-l*u,y2:t.y-d*u}}function Je(e){return Math.round(e*100)/100}function is(e,t,n,r,o){const i=s=>`${Je(s.x)},${Je(s.y)}`;return{kind:e,start:t,end:o,controls:[n,r],d:`M${i(t)} C${i(n)} ${i(r)} ${i(o)}`}}function h$(e,t,n,r,o=4){const i=t.x-e.x,s=t.y-e.y,a=Math.hypot(i,s),c=n+r+o*2;if(!Number.isFinite(a)||a<=c)return null;if(i>=c){const f={x:e.x+n+o,y:e.y},p={x:t.x-r-o,y:t.y},h=p.x-f.x,m=Math.max(h*.45,Math.min(65,h));return is("forward",f,{x:f.x+m,y:f.y},{x:p.x-m,y:p.y},p)}if(i<=-c){const f={x:e.x,y:e.y-n-o},p={x:t.x,y:t.y-r-o},h=Math.max(100,Math.abs(i)*.2);return is("backward",f,{x:f.x+85,y:f.y-h},{x:p.x+85,y:p.y-h},p)}if(Math.abs(s)>c){const f=s>0?1:-1,p={x:e.x,y:e.y+f*(n+o)},h={x:t.x,y:t.y-f*(r+o)},m=Math.abs(h.y-p.y),k=Math.max(m*.45,Math.min(40,m));return is("vertical",p,{x:p.x,y:p.y+f*k},{x:h.x,y:h.y-f*k},h)}const u=p$(e,t,n,r,o),l={x:u.x1,y:u.y1},d={x:u.x2,y:u.y2};return{kind:"straight",start:l,end:d,controls:null,d:`M${Je(l.x)},${Je(l.y)} L${Je(d.x)},${Je(d.y)}`}}const m$=6,ss=m$+3,Ke=14,bd=10,g$=3,wd=6;function y$(e,t,n){const r=je(e),o=[];for(const i of r.nodes){const s=t[i.id];if(s)for(const{kind:a,box:c}of al(Gi(i,r.checked_address,cl(n,i.id))))a==="circle"?o.push({id:i.id,kind:"circle",x:s.x,y:s.y,r:c.x2}):o.push({id:i.id,kind:"box",x1:s.x+c.x1,y1:s.y+c.y1,x2:s.x+c.x2,y2:s.y+c.y2})}return o}function _$(e,t){if(t.kind==="circle")return Math.hypot(e.x-t.x,e.y-t.y)-t.r;const n=Math.max(t.x1-e.x,0,e.x-t.x2),r=Math.max(t.y1-e.y,0,e.y-t.y2);return n||r?Math.hypot(n,r):-Math.min(e.x-t.x1,t.x2-e.x,e.y-t.y1,t.y2-e.y)}function b$(e,t){return e.kind==="circle"?{x1:e.x-e.r-t,y1:e.y-e.r-t,x2:e.x+e.r+t,y2:e.y+e.r+t}:{x1:e.x1-t,y1:e.y1-t,x2:e.x2+t,y2:e.y2+t}}function w$(e,t){const n=1-t;return{x:n*n*n*e[0].x+3*n*n*t*e[1].x+3*n*t*t*e[2].x+t*t*t*e[3].x,y:n*n*n*e[0].y+3*n*n*t*e[1].y+3*n*t*t*e[2].y+t*t*t*e[3].y}}function v$(e){return e.controls?[{kind:"C",points:[e.start,e.controls[0],e.controls[1],e.end]}]:[{kind:"L",points:[e.start,e.end]}]}function Rg(e){let t=0,n;for(const r of e)n&&(t+=Math.hypot(r.x-n.x,r.y-n.y)),n=r;return t}function k$(e,t){const n=[];for(const r of e){const o=Math.max(1,Math.ceil(Rg(r.points)/t));for(let i=0;i<=o;i++){const s=i/o;if(r.kind==="L"){const[a,c]=r.points;n.push({x:a.x+(c.x-a.x)*s,y:a.y+(c.y-a.y)*s})}else n.push(w$(r.points,s))}}return n}function vd(e,t,n,r){const o=e.flatMap(a=>a.points),i={x1:Math.min(...o.map(a=>a.x)),y1:Math.min(...o.map(a=>a.y)),x2:Math.max(...o.map(a=>a.x)),y2:Math.max(...o.map(a=>a.y))},s=[];if(n.forEach((a,c)=>{a.x1<=i.x2&&i.x1<=a.x2&&a.y1<=i.y2&&i.y1<=a.y2&&s.push(c)}),!s.length)return!0;for(const a of k$(e,g$))for(const c of s){const u=n[c],l=t[c];if(!(!u||!l)&&!(a.x<u.x1||a.x>u.x2||a.y<u.y1||a.y>u.y2)&&_$(a,l)<r)return!1}return!0}function $$(e){const t=e[0],n=e[e.length-1];if(!t||!n)return[];const r=[];for(let s=1;s<e.length;s++)r.push(Rg(e.slice(s-1,s+1)));const o=[];let i=t;for(let s=1;s<e.length-1;s++){const a=e[s-1],c=e[s],u=e[s+1],l=r[s-1],d=r[s];if(!a||!c||!u||l===void 0||d===void 0)continue;const f=l/(s-1===0?1:2),p=d/(s===r.length-1?1:2),h=Math.min(Ke,f,p),m={x:(c.x-a.x)/l,y:(c.y-a.y)/l},k={x:(u.x-c.x)/d,y:(u.y-c.y)/d},I={x:c.x-m.x*h,y:c.y-m.y*h},v={x:c.x+k.x*h,y:c.y+k.y*h};o.push({kind:"L",points:[i,I]}),o.push({kind:"C",points:[I,{x:I.x+m.x*h*.55,y:I.y+m.y*h*.55},{x:v.x-k.x*h*.55,y:v.y-k.y*h*.55},v]}),i=v}return o.push({kind:"L",points:[i,n]}),o.filter(s=>s.kind==="C"||Math.hypot(s.points[1].x-s.points[0].x,s.points[1].y-s.points[0].y)>.01)}function S$(e){const t=o=>`${Je(o.x)},${Je(o.y)}`,n=e[0];if(!n)return"";let r=`M${t(n.points[0])}`;for(const o of e)r+=o.kind==="L"?` L${t(o.points[1])}`:` C${t(o.points[1])} ${t(o.points[2])} ${t(o.points[3])}`;return r}function kd(e,t,n,r,o){const i=Math.min(e.y,n)-Ke,s=Math.max(e.y,n)+Ke,a=d=>(d-e.x)*t;let c=1/0;for(const d of o)if(d.y1<e.y&&e.y<d.y2){const f=t===1?d.x1:d.x2,p=t===1?d.x2:d.x1;a(p)>0&&(c=Math.min(c,Math.max(0,a(f))))}const u=o.filter(d=>d.y1<s&&i<d.y2).map(d=>[a(t===1?d.x1:d.x2),a(t===1?d.x2:d.x1)]).filter(([,d])=>d>r).sort((d,f)=>d[0]-f[0]);let l=r;for(const[d,f]of[...u,[1/0,1/0]]){if(d>l+1){const p=Math.min(d,c);if(p<=l+1)return null;const h=Number.isFinite(p)&&p-l<80?(l+p)/2:l+40;return e.x+t*h}if(l=Math.max(l,f),l>=c)return null}return null}function I$(e){const t=[];for(const n of e){const r=t[t.length-1];r&&Math.abs(r.x-n.x)<.01&&Math.abs(r.y-n.y)<.01||t.push(n)}return t.filter((n,r)=>{if(r===0||r===t.length-1)return!0;const o=t[r-1],i=t[r+1];return!o||!i?!0:!(Math.abs(o.x-n.x)<.01&&Math.abs(i.x-n.x)<.01||Math.abs(o.y-n.y)<.01&&Math.abs(i.y-n.y)<.01)})}function z$(e,t,n,r,o,i=4){const s=h$(e,t,n,r,i);if(!s||!o.length)return s;const a=o.map(f=>b$(f,ss));if(vd(v$(s),o,a,ss))return s;const c=new Set([e.y,t.y]),u=f=>Math.abs(f-e.y)<wd?e.y:Math.abs(f-t.y)<wd?t.y:f;for(const f of a)c.add(u(Math.round(f.y1)-Ke-1)),c.add(u(Math.round(f.y2)+Ke+1));const l=t.x>=e.x?1:-1,d=[[l,l],[l,-l],[-l,l],[-l,-l]];for(const[f,p]of d){const h={x:e.x+f*(n+i),y:e.y},m={x:t.x-p*(r+i),y:t.y},k=[];for(const I of c){const v=Math.abs(I-h.y)<.01?h.x:kd(h,f,I,Ke,a);if(v===null)continue;const z=Math.abs(I-m.y)<.01?m.x:kd(m,-p,I,Ke+bd,a);if(z===null||Math.abs(I-m.y)<.01&&(m.x-v)*p<Ke+bd||Math.abs(I-h.y)<.01&&(z-h.x)*f<Ke)continue;const C=I$([h,{x:v,y:h.y},{x:v,y:I},{x:z,y:I},{x:z,y:m.y},m]);if(!x$(C,a))continue;let R=(C.length-2)*Ke,N;for(const U of C)N&&(R+=Math.abs(U.x-N.x)+Math.abs(U.y-N.y)),N=U;k.push({points:C,length:R})}k.sort((I,v)=>{const z=I.points[2]?.y,C=v.points[2]?.y;return I.length-v.length||(z===void 0||C===void 0?0:z-C)});for(const I of k){const v=$$(I.points);if(!vd(v,o,a,ss))continue;const z=I.points,C=z[0],R=z[z.length-1];if(!C||!R)continue;const N={x1:Math.min(...z.map(U=>U.x)),y1:Math.min(...z.map(U=>U.y)),x2:Math.max(...z.map(U=>U.x)),y2:Math.max(...z.map(U=>U.y))};return{kind:"routed",start:C,end:R,controls:null,d:S$(v),bounds:N}}}return s}function x$(e,t){let n;for(const r of e){if(n){const o={x1:Math.min(n.x,r.x),y1:Math.min(n.y,r.y),x2:Math.max(n.x,r.x),y2:Math.max(n.y,r.y)};for(const i of t)if(o$(o,i))return!1}n=r}return!0}function T$(e,t){if(!t)return pt.rest;const n=le(t);return le(e.from)===n||le(e.to)===n?pt.related:pt.faded}function C$(){return{hit:{stroke:"transparent",width:16},line:{stroke:ue("edge"),width:1.6},arrow:{fill:ue("edge")}}}function E$(e,t,n){return e!=="gravity"&&e!=="tree"?null:{layout:e,id:t,pointerId:n}}function N$(e,t,n,r){return e!=="node"&&e!=="edge"&&e!=="canvas"||!Number.isFinite(r?.x)||!Number.isFinite(r?.y)?null:{kind:e,id:t??null,pointerId:n,start:{...r},moved:!1}}function O$(e,t,n,r=Dk){if(!e||e.pointerId!==t)return e;const o=Math.hypot(n.x-e.start.x,n.y-e.start.y);return{...e,moved:e.moved||o>r}}function P$(e,t,n=!1){return!e||e.pointerId!==t||n||e.moved?null:e.kind==="node"?{type:"select-node",id:e.id}:e.kind==="edge"?{type:"select-edge",id:e.id}:e.kind==="canvas"?{type:"select-checked"}:null}function $d(e){return e==="Enter"||e===" "}function A$(e,t){return{x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale}}function M$(e,t,n,r,o){return!t||t.pointerId!==n||!Object.hasOwn(e,t.id)?!1:(e[t.id]=A$(r,o),!0)}function R$(e,t){return e?.pointerId===t?null:e}function L$(e,t,n,r){const o=Math.min(t.width/n,t.height/r),i=t.left+(t.width-n*o)/2,s=t.top+(t.height-r*o)/2;return{x:(e.x-i)/o,y:(e.y-s)/o}}function Z$(e,t){const n=new Map;let r=null,o=null,i=null;function s(f){if(f===e)return{kind:"canvas",id:null};const p=f;if(p?.closest?.("[data-canvas]"))return{kind:"canvas",id:null};const h=p?.closest?.("[data-node-id]");if(h)return{kind:"node",id:h.dataset.nodeId??null};const m=p?.closest?.("[data-edge-id]");return m?{kind:"edge",id:m.dataset.edgeId??null}:null}function a(f){if(f.pointerType==="mouse"&&f.button!==0)return;const p=s(f.target);if(!p)return;const h=t.point(f);if(n.set(f.pointerId,h),e.setPointerCapture(f.pointerId),p.kind!=="canvas"&&(f.preventDefault(),f.stopPropagation()),n.size===1){r=N$(p.kind,p.id,f.pointerId,{x:f.clientX,y:f.clientY}),o=p.kind==="canvas"?{point:h,transform:{...t.transform()}}:null;return}if(r&&(r={...r,moved:!0}),o=null,n.size===2){const[m,k]=[...n.values()];m&&k&&(i={distance:Math.hypot(k.x-m.x,k.y-m.y),scale:t.transform().scale},t.startPinch())}}function c(f){if(!n.has(f.pointerId))return;const p=t.point(f);if(n.set(f.pointerId,p),i){const[h,m]=[...n.values()];h&&m&&t.pinch(i,[h,m],f);return}if(r?.pointerId===f.pointerId){if(r=O$(r,f.pointerId,{x:f.clientX,y:f.clientY}),!r?.moved)return;if(r.kind==="node"){t.drag(r.id??"",f.pointerId,p,f);return}if(r.kind==="edge")return}o&&t.pan(o,p,f)}function u(f,p=!1){const h=P$(r,f.pointerId,p);h&&t.select(h),r?.pointerId===f.pointerId&&(r=null),t.endDrag(f.pointerId),n.delete(f.pointerId),n.size||(r=null,o=null,i=null),e.hasPointerCapture(f.pointerId)&&e.releasePointerCapture(f.pointerId)}const l=f=>u(f),d=f=>u(f,!0);return e.addEventListener("pointerdown",a,!0),e.addEventListener("pointermove",c),e.addEventListener("pointerup",l),e.addEventListener("pointercancel",d),()=>{e.removeEventListener("pointerdown",a,!0),e.removeEventListener("pointermove",c),e.removeEventListener("pointerup",l),e.removeEventListener("pointercancel",d)}}function D$(e,t,n){let r=!1;function o(i,s=!1){r=i,e.classList.toggle("graph-panel--expanded",i),n.classList.toggle("graph-expanded",i),t.classList.toggle("expand-control--expanded",i),t.setAttribute("aria-expanded",String(i)),t.setAttribute("aria-label",i?"Close expanded graph":"Expand graph"),t.setAttribute("title",i?"Close expanded graph":"Expand graph"),i?(e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true")):(e.removeAttribute("role"),e.removeAttribute("aria-modal"),s&&t.focus())}return{open(){o(!0)},close(i={}){o(!1,i.restoreFocus!==!1)},toggle(){o(!r,r)},isOpen(){return r}}}function Lg(e){const t=String(e??"").toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown"}function Ts(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e)}function Cs(e){return e==null?"Unavailable":new Intl.NumberFormat("en-US").format(e)}function ht(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"Unavailable";const t=new Date(e<1e11?e*1e3:e);return!Number.isFinite(t.getTime())||t.getUTCFullYear()<2009||t.getUTCFullYear()>2100?"Unavailable":new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeStyle:"short",timeZone:"UTC"}).format(t)}function Zg(e,t=Date.now()){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"Unavailable";const n=Math.max(0,(t-(e<1e11?e*1e3:e))/1e3),r=[[31536e3,"year"],[2592e3,"month"],[86400,"day"],[3600,"hour"],[60,"minute"]];for(const[o,i]of r){const s=Math.floor(n/o);if(s>=1)return`${s} ${i}${s===1?"":"s"} ago`}return"just now"}function Es(e){if(e.amount_usd_sum==null||e.price_coverage_ratio===0)return"Unavailable";const t=e.price_coverage_ratio;return Ts(e.amount_usd_sum)+(t!=null&&t>0&&t<1?" (priced portion)":"")}function j$(e){const t=[["Incoming amount (USD)",e.total_in_usd==null?"Unavailable":Ts(e.total_in_usd)],["Outgoing amount (USD)",e.total_out_usd==null?"Unavailable":Ts(e.total_out_usd)]];return e.role&&Gr.includes(e.role)?[["Role",Ag[e.role]||"Other"],...t,["Senders",Cs(e.degree_in)],["Receivers",Cs(e.degree_out)],["Labels",yt(e).join(", ")||"No labels"]]:[["Address risk",e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} · ${Lg(e.risk_level)}`],["Confidence","Unavailable"],...t,["First activity (UTC)",ht(e.first_activity_timestamp)],["Last activity (UTC)",ht(e.last_activity_timestamp)],["Labels",yt(e).join(", ")||"No labels"]]}function F$(e,t){if(e.source==="flows")return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",Es(e)],["Transfers",Cs(e.tx_count)],["First seen (UTC)",ht(e.first_seen_timestamp)],["Last seen (UTC)",ht(e.last_seen_timestamp)],["Since last seen",Zg(e.last_seen_timestamp,t)]];const n=e.price_coverage_ratio;return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",Es(e)],["Price coverage",n==null?"Unavailable":new Intl.NumberFormat("en-GB",{style:"percent",maximumFractionDigits:1}).format(n)],["Transfers",e.tx_count==null?"Unavailable":String(e.tx_count)],["First seen (UTC)",ht(e.first_seen_timestamp)],["Last seen (UTC)",ht(e.last_seen_timestamp)],["First transaction",e.first_tx_id||"Unavailable"],["Last transaction",e.last_tx_id||"Unavailable"]]}function U$(e){return typeof e!="string"||!/^0x[a-fA-F0-9]{64}$/.test(e)?null:`https://robinhoodchain.blockscout.com/tx/${e.toLowerCase()}`}function Sd(e){const t=Wi(e);if(e.role)return`${e.address}. ${t||"Other"}.${yt(e).length?` Labels: ${yt(e).join(", ")}.`:""}`;const n=e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} ${Lg(e.risk_level)} risk`,r=yt(e).join(", ");return`${e.address}. ${n}.${r?` Labels: ${r}.`:""}`}function Id(e,t){const n=`${e.from} to ${e.to}. Aggregate value ${Es(e)}. ${e.tx_count??0} ${e.tx_count===1?"transfer":"transfers"}.`;return e.source==="flows"&&e.last_seen_timestamp?`${n} Last seen ${Zg(e.last_seen_timestamp,t)}.`:n}function V$(e,t){return je(e).nodes.map(n=>{const r={id:n.address,label:yt(n).join(", ")||Wi(n)};n.role&&(r.role=n.role);const o=t?.(n.address);return o&&(r.href=o),r})}let q$=0;function pe(e,t={}){const n=document.createElementNS(Rk,e);for(const[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function H$(e,t,n){const r=pe("text",{x:0,y:t,"text-anchor":"middle",class:n,"pointer-events":"none"});return r.textContent=e,r}function B$(e,t=22){return e.length>t?`${e.slice(0,t-1)}…`:e}function K$(e,t,n={}){const r=`cia-graph-${++q$}`,o=e.ownerDocument;let i=je(t),s=n.layout??(ol(t)?"tree":"gravity");const a={width:e.clientWidth||n.width||820,height:e.clientHeight||n.height||430};let c=co(i,s,a.width,a.height);const u=new Map,l=()=>{const w=new Map,S=new Map(i.nodes.map(E=>[E.address,E])),T=y$(i,c,u);for(const E of i.edges){const B=S.get(E.from),K=S.get(E.to),ae=B&&c[B.id],Ne=K&&c[K.id];if(!B||!K||!ae||!Ne){w.set(E.id,null);continue}const Xe=T.filter(zt=>zt.id!==B.id&&zt.id!==K.id);w.set(E.id,z$(ae,Ne,xs(B,i.checked_address),xs(K,i.checked_address),Xe))}return w},d=()=>{const w=r$(i,c,u);if(!w)return null;for(const S of l().values())S?.bounds&&(w.x1=Math.min(w.x1,S.bounds.x1),w.y1=Math.min(w.y1,S.bounds.y1),w.x2=Math.max(w.x2,S.bounds.x2),w.y2=Math.max(w.y2,S.bounds.y2));return w},f=()=>{const w=d();return w?f$(w,a.width,a.height,Vn):{x:0,y:0,scale:1}};let p=f(),h=null,m=null;const k=n.now??(()=>Date.now());e.classList.add("cia-graph-engine"),e.closest(".cia-graph-surface")||e.classList.add("cia-graph-surface");const I=pe("svg",{class:"cia-graph-svg",viewBox:`0 0 ${a.width} ${a.height}`,role:"group",tabindex:0,"aria-label":n.label??"Money-flow graph. Drag the background or use arrow keys to pan, plus and minus to zoom. Select an address or a link for details."}),v=pe("defs"),z=pe("pattern",{id:`${r}-dots`,width:24,height:24,patternUnits:"userSpaceOnUse"});z.append(pe("circle",{class:"cia-graph-dot",cx:1,cy:1,r:1})),v.append(z);const C=pe("rect",{class:"cia-graph-backdrop",width:"100%",height:"100%","data-canvas":""}),R=pe("rect",{class:"cia-graph-dots",width:"100%",height:"100%",fill:`url(#${r}-dots)`,"data-canvas":""}),N=pe("g",{"data-viewport":""}),U=pe("g",{"data-edges":"",class:"cia-graph-edges"}),de=pe("g",{"data-nodes":"",class:"cia-graph-nodes"});N.append(U,de),I.append(v,C,R,N);const re=o.createElement("div");re.className="graph-tooltip cia-graph-tooltip",re.hidden=!0,re.setAttribute("role","tooltip"),e.append(I,re);const fe=new Map,Te=new Map,Qe=new Map;function kt(w){let S=fe.get(w);if(S)return S;S=`${r}-arrow-${fe.size}`;const T=pe("marker",{id:S,viewBox:"0 0 10 10",refX:9,refY:5,markerWidth:6,markerHeight:6,orient:"auto-start-reverse",markerUnits:"strokeWidth"}),E=pe("path",{d:"M0 0L10 5L0 10Z",class:"cia-graph-arrowhead"});return E.style.fill=w,T.append(E),v.append(T),fe.set(w,S),S}const Qr=()=>new Map(i.nodes.map(w=>[w.address,w])),J=w=>n.nodeStyle?.(w).stroke??Xk(w);function W(){U.replaceChildren(),de.replaceChildren(),Te.clear(),Qe.clear();const w=Qr();for(const S of i.edges){const T=w.get(S.from);if(!T||!w.get(S.to))continue;const E=J(T),B=pe("g",{class:"cia-graph-edge graph-edge",tabindex:0,role:"button","aria-label":Id(S,k())});B.dataset.edgeId=S.id,B.style.setProperty("--edge-tone",E);const K=C$(),ae=pe("path",{class:"cia-graph-edge-hit","stroke-width":K.hit.width,"pointer-events":"stroke"}),Ne=pe("path",{class:"cia-graph-edge-line","stroke-width":K.line.width,"marker-end":`url(#${kt(E)})`,"pointer-events":"none"});B.append(ae,Ne),B.addEventListener("keydown",Xe=>{$d(Xe.key)&&(Xe.preventDefault(),Yi(S.id))}),B.addEventListener("pointerenter",Xe=>hl(Xe,Id(S,k()))),B.addEventListener("pointerleave",ml),U.append(B),Qe.set(S.id,{group:B,hit:ae,line:Ne})}for(const S of Yr(i))de.append(qe(S));ce(),Be()}function qe(w){const S=w.address===i.checked_address,T=u.get(w.id),E=Gi(w,i.checked_address,T),B=E.radius,K=pe("g",{class:"cia-graph-node graph-node",tabindex:0,role:"button","aria-label":Sd(w),"aria-pressed":"false"});K.dataset.nodeId=w.id,S&&(K.dataset.checked=""),K.style.setProperty("--node-tone",J(w)),S&&K.append(pe("circle",{class:"cia-graph-node-ring",r:B+6})),K.append(pe("circle",{class:"cia-graph-node-body",r:B})),K.append(pe("circle",{class:"cia-graph-node-dot",r:E.dot}));for(const ae of E.texts)K.append(H$(ae.text,ae.y,`cia-graph-node-${ae.kind}`));return T&&(K.dataset.state="refused"),K.addEventListener("keydown",ae=>{$d(ae.key)&&(ae.preventDefault(),qt(w.id))}),K.addEventListener("pointerenter",ae=>hl(ae,Sd(w))),K.addEventListener("pointerleave",ml),Te.set(w.id,K),K}function ce(){N.setAttribute("transform",`translate(${p.x} ${p.y}) scale(${p.scale})`);for(const[S,T]of Te){const E=c[S]??{x:a.width/2,y:a.height/2};T.setAttribute("transform",`translate(${Je(E.x)} ${Je(E.y)})`)}const w=l();for(const S of i.edges){const T=Qe.get(S.id);if(!T)continue;const E=w.get(S.id)??null;T.group.style.display=E?"":"none",E&&(T.hit.setAttribute("d",E.d),T.line.setAttribute("d",E.d))}}function Ft(){return h?.kind!=="node"?null:i.nodes.find(w=>w.id===h.id)?.address??null}function Be(){const w=Ft();for(const S of i.edges){const T=Qe.get(S.id);if(!T)continue;const E=h?.kind==="edge"&&h.id===S.id,B=h?.kind==="edge"?E?pt.related:pt.faded:T$(S,w),K=B===pt.faded;T.group.setAttribute("opacity",K?String(B):"1"),T.line.setAttribute("stroke-opacity",K?"1":String(B)),T.group.dataset.opacity=String(B),T.group.dataset.state=B===pt.rest?"rest":B===pt.related?"related":"faded",T.group.setAttribute("aria-pressed",String(E))}for(const[S,T]of Te){const E=h?.kind==="node"&&h.id===S;T.classList.toggle("is-selected",E),T.setAttribute("aria-pressed",String(E))}}function Ut(){const w=V$(i,n.href),S=h?.kind==="node"?i.nodes.find(E=>E.id===h.id)??null:null,T=h?.kind==="edge"?i.edges.find(E=>E.id===h.id)??null:null;if(S){const E=i.edges.filter(B=>B.from===S.address||B.to===S.address);return{kind:"node",id:S.id,selectedId:S.address,nodes:w,title:"Selected address",identity:S.address,values:j$(S),related:E,node:S,edge:null}}return T?{kind:"edge",id:T.id,selectedId:null,nodes:w,title:"Selected aggregate flow",identity:`${T.from} → ${T.to}`,values:F$(T,k()),related:[T],node:null,edge:T}:{kind:null,id:null,selectedId:null,nodes:w,title:"Nothing selected",identity:"",values:[],related:[],node:null,edge:null}}function Vt(){const w=Ut();qg(w),n.onSelect?.(w)}function qg(w){const S=n.selectionRoot,T=S?.querySelector("[data-selection-title]"),E=S?.querySelector("[data-selection-identity]"),B=S?.querySelector("[data-selection-meta]");!T||!E||!B||(T.textContent=w.title,E.textContent=w.identity,B.replaceChildren(...w.values.map(([K,ae])=>{const Ne=o.createElement("div");Ne.className="meta-item",ae!=="Unavailable"&&(["From","To","First transaction","Last transaction"].includes(K)&&Ne.classList.add("meta-item--identity"),K==="Incoming amount (USD)"&&Ne.classList.add("meta-item--incoming"),K==="Outgoing amount (USD)"&&Ne.classList.add("meta-item--outgoing")),["From","To","First transaction","Last transaction","Labels"].includes(K)&&Ne.classList.add("meta-item--wide");const Xe=o.createElement("span");Xe.textContent=K;const zt=o.createElement("strong"),En=["First transaction","Last transaction"].includes(K)?U$(ae):null;if(En&&n.openLink){const lt=n.openLink,xt=o.createElement("button");xt.type="button",xt.className="cia-graph-explorer-link",xt.dataset.explorer=En,xt.textContent=ae,xt.setAttribute("aria-label",`${K}: ${ae} (opens the explorer)`),xt.addEventListener("click",()=>lt(En)),zt.append(xt)}else if(En){const lt=o.createElement("a");lt.href=En,lt.target="_blank",lt.rel="noopener noreferrer",lt.textContent=ae,lt.setAttribute("aria-label",`${K}: ${ae} (opens in new tab)`),zt.append(lt)}else zt.textContent=ae;return Ne.append(Xe,zt),Ne})))}function qt(w){h=w?{kind:"node",id:w}:null,Be(),Vt()}function Yi(w){h=w?{kind:"edge",id:w}:null,Be(),Vt()}function fl(w){if(w==null)return qt(null);const S=mo(i,w);if(S)return qt(S);if(i.edges.some(T=>T.id===w))return Yi(w)}function $t(){p=f(),ce()}function St(w,S={x:a.width/2,y:a.height/2}){const T=zs(p.scale*(1+w)),E=T/p.scale;p={x:S.x-(S.x-p.x)*E,y:S.y-(S.y-p.y)*E,scale:T},ce()}function pl(w){s=w,n.controls?.querySelectorAll("[data-layout]").forEach(S=>{S.classList.toggle("active",S.dataset.layout===w),S.setAttribute("aria-pressed",String(S.dataset.layout===w))}),n.onLayoutChange?.(w),c=co(i,s,a.width,a.height),$t()}function hl(w,S){re.textContent=S,re.hidden=!1;const T=e.getBoundingClientRect();re.style.left=`${Math.min(T.width-330,Math.max(8,w.clientX-T.left+12))}px`,re.style.top=`${Math.max(8,w.clientY-T.top+12)}px`}function ml(){re.hidden=!0}function gl(w){return L$({x:w.clientX,y:w.clientY},I.getBoundingClientRect(),a.width,a.height)}const Hg=Z$(I,{point:gl,transform:()=>p,select(w){w.type==="select-node"?qt(w.id):w.type==="select-edge"?Yi(w.id):qt(sl(i)?.id??null)},drag(w,S,T){!m&&(m=E$(s,w,S),!m)||M$(c,m,S,T,p)&&ce()},endDrag(w){m=R$(m,w)},pan(w,S){p={x:w.transform.x+S.x-w.point.x,y:w.transform.y+S.y-w.point.y,scale:p.scale},ce()},startPinch(){m=null},pinch(w,[S,T]){const E=Math.hypot(T.x-S.x,T.y-S.y),B=zs(w.scale*E/Math.max(1,w.distance));St(B/p.scale-1,{x:(S.x+T.x)/2,y:(S.y+T.y)/2})}}),yl=w=>{w.preventDefault(),St(w.deltaY>0?-.12:.12,gl(w))},Bg={ArrowLeft:[60,0],ArrowRight:[-60,0],ArrowUp:[0,60],ArrowDown:[0,-60]},_l=w=>{if(w.target!==I)return;const S=Bg[w.key];S?(w.preventDefault(),p={...p,x:p.x+S[0],y:p.y+S[1]},ce()):w.key==="+"||w.key==="="?St(.18):w.key==="-"?St(-.18):w.key==="0"&&$t()};I.addEventListener("wheel",yl,{passive:!1}),I.addEventListener("keydown",_l);const Qi=n.controls?.querySelector("[data-expand]")??null,It=n.panel&&Qi?D$(n.panel,Qi,o.body):null,Kg=()=>{It?.toggle(),n.onExpansionChange?.(It?.isOpen()??!1),requestAnimationFrame($t)},bl=n.panel??e,wl=w=>{if(w.key==="Tab"&&It?.isOpen()&&n.panel){const S=Array.from(n.panel.querySelectorAll('button,a[href],[tabindex="0"],summary')).filter(B=>B.checkVisibility()),T=S[0],E=S.at(-1);w.shiftKey&&o.activeElement===T?(w.preventDefault(),E?.focus()):!w.shiftKey&&o.activeElement===E&&(w.preventDefault(),T?.focus())}if(w.key==="Escape"){if(It?.isOpen()){It.close(),n.onExpansionChange?.(!1),requestAnimationFrame($t);return}qt(null)}};bl.addEventListener("keydown",wl);const vl=[],Cn=(w,S)=>{w&&(w.addEventListener("click",S),vl.push([w,S]))};n.controls?.querySelectorAll("[data-layout]").forEach(w=>Cn(w,()=>pl(w.dataset.layout==="tree"?"tree":"gravity"))),Cn(n.controls?.querySelector("[data-zoom='in']"),()=>St(.18)),Cn(n.controls?.querySelector("[data-zoom='out']"),()=>St(-.18)),Cn(n.controls?.querySelector("[data-zoom='fit']"),$t),It&&Cn(Qi,Kg);const kl=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const w=e.clientWidth,S=e.clientHeight;!w||!S||w===a.width&&S===a.height||(a.width=w,a.height=S,I.setAttribute("viewBox",`0 0 ${w} ${S}`),$t())});return kl?.observe(e),W(),n.selected&&fl(n.selected),{update(w){const S=c;i=je(w);const T=co(i,s,a.width,a.height);c=Object.fromEntries(i.nodes.map(E=>[E.id,S[E.id]??T[E.id]]).filter(([,E])=>E)),h&&!(h.kind==="node"?i.nodes.some(E=>E.id===h.id):i.edges.some(E=>E.id===h.id))&&(h=null),p=f(),W()},merge(w,S){const T=Wk(i,w,S);i=T.model;const E=mo(i,S??je(w).checked_address);return c=E?d$(i,c,E,T.added,{notes:u}):{...c,...co(i,s,a.width,a.height),...c},T.added.length&&(p=f()),W(),T.added},setTheme(w){w&&o.documentElement.setAttribute("data-theme",w);for(const S of i.nodes)Te.get(S.id)?.style.setProperty("--node-tone",J(S))},select:fl,destroy(){kl?.disconnect(),Hg(),I.removeEventListener("wheel",yl),I.removeEventListener("keydown",_l),bl.removeEventListener("keydown",wl);for(const[w,S]of vl)w.removeEventListener("click",S);It?.close({restoreFocus:!1}),I.remove(),re.remove(),e.classList.remove("cia-graph-engine")},fit:$t,zoom:w=>St(w),setLayout:pl,markNode(w,S){const T=mo(i,w);T&&(S?u.set(T,S):u.delete(T),W())},positions:()=>structuredClone(c),model:()=>i,contentBounds:()=>d(),transform:()=>({...p})}}const J$="chain-insights.flows.v1",W$="chain-insights.result.v1",zd=200;function ul(e){return(e?.content??[]).filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
109
- `).trim()}const G$=new Set(["usage_status","subscription_status","meta_usage_status","meta_subscription_status"]);function Y$(e){if(!e||e.isError)return"text";const t=e.structuredContent;if(t?.schema===J$)return"flows";if(t?.schema===W$){if(t.tool==="graph_query")return"table";if(typeof t.tool=="string"&&G$.has(t.tool))return"balance"}return"text"}function O(e,t,n={},...r){const o=e.createElement(t);for(const[i,s]of Object.entries(n))s==null||s===!1||(i==="class"?o.className=String(s):i==="text"?o.textContent=String(s):o.setAttribute(i,s===!0?"":String(s)));for(const i of r)i==null||i===!1||o.append(typeof i=="string"?e.createTextNode(i):i);return o}const Q$=/^0x[0-9a-fA-F]{40}$/,X$=/^0x[0-9a-fA-F]{64}$/;function eS(e){return typeof e=="string"&&(Q$.test(e)||X$.test(e))}function tS(e,t){const n=O(e,"code",{class:"cv-addr",title:t,"data-full":t,text:et(t)}),r=O(e,"button",{type:"button",class:"cv-copy","data-copy":t,"aria-label":`Copy ${t}`,title:"Copy the full value",text:"Copy"});return r.addEventListener("click",()=>{nS(e,t,n,r)}),O(e,"span",{class:"cv-addr-cell"},n,r)}async function nS(e,t,n,r){const o=e.defaultView?.navigator?.clipboard;try{if(o?.writeText)return await o.writeText(t),r&&(r.textContent="Copied"),"copied"}catch{}return n.textContent=t,n.classList.add("is-full"),e.getSelection?.()?.selectAllChildren(n),r&&(r.textContent="Selected"),"selected"}function rS(e,t){return/(timestamp|seen|_at|_ms|time)$/i.test(t)&&e>1e9?ht(e):/usd/i.test(t)?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e):new Intl.NumberFormat("en-US",{maximumFractionDigits:4}).format(e)}function oS(e){const t=e?.facts?.query,n=Array.isArray(t?.results)?t.results.filter(i=>!!i&&typeof i=="object"&&!Array.isArray(i)):[],r=n.slice(0,zd),o=[];for(const i of r)for(const s of Object.keys(i))o.includes(s)||o.push(s);return{columns:o,rows:r,total:n.length,truncated:n.length>zd||t?.truncated===!0,elapsedMs:typeof t?.elapsed_ms=="number"?t.elapsed_ms:null}}function iS(e,t,n){return t==null?O(e,"span",{class:"cv-null","aria-label":"empty",text:"—"}):eS(t)?tS(e,t):typeof t=="number"?e.createTextNode(rS(t,n)):typeof t=="boolean"?e.createTextNode(t?"yes":"no"):Array.isArray(t)?e.createTextNode(t.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(", ")):typeof t=="object"?e.createTextNode(JSON.stringify(t)):e.createTextNode(String(t))}function sS(e,t){const n=e.ownerDocument,r=oS(t.structuredContent),o=r.rows.length,i=r.total===0?"The query returned no rows.":`${new Intl.NumberFormat("en-US").format(o)} ${o===1?"row":"rows"}${r.elapsedMs==null?"":` in ${r.elapsedMs} ms`}`,s=O(n,"table",{class:"cv-table"},O(n,"thead",{},O(n,"tr",{},...r.columns.map(a=>O(n,"th",{scope:"col",text:a})))),O(n,"tbody",{},...r.rows.map(a=>O(n,"tr",{},...r.columns.map(c=>O(n,"td",{},iS(n,a[c],c)))))));return e.replaceChildren(O(n,"section",{class:"cv-card cv-table-view","data-view":"table","aria-label":"Graph query result"},O(n,"header",{class:"cv-card-head"},O(n,"strong",{text:"Graph query result"}),O(n,"span",{class:"cv-muted",text:i})),r.truncated?O(n,"p",{class:"cv-note",role:"note","data-truncated":"",text:`Truncated: showing the first ${new Intl.NumberFormat("en-US").format(o)} of ${new Intl.NumberFormat("en-US").format(r.total)} rows. Narrow the query to see the rest.`}):null,r.columns.length?O(n,"div",{class:"cv-table-wrap"},s):null)),r}const Nn=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e:t,uo=e=>typeof e=="string"&&e?e:null;function aS(e){const t=e?.facts??{};if(typeof t.wallet=="string"&&t.wallet)return{kind:"wallet",wallet:t.wallet,tier:String(t.tier??"anonymous"),allowanceUsd:Nn(t.allowance_usd),consumedUsd:Nn(t.consumed_usd),windowEnd:uo(t.window_end)};const n=t.usage;if(n&&typeof n=="object"){const r="daily_units_limit"in n||"daily_units_used"in n,o=uo(n.access_mode);return{kind:"free",unit:r?"units":"seconds",used:Nn(r?n.daily_units_used:n.daily_seconds_used),limit:Nn(r?n.daily_units_limit:n.daily_seconds_limit),remaining:Nn(r?n.remaining_units:n.remaining_seconds),resetAt:uo(n.reset_at),identifierKind:uo(n.identifier_kind),accessMode:o,noLimit:!r&&o==="public_free"&&n.daily_seconds_limit===0}}return{kind:"unknown"}}const xd=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e),lo=(e,t)=>`${new Intl.NumberFormat("en-US").format(e)} ${t==="units"?e===1?"unit":"units":e===1?"second":"seconds"}`;function as(e){if(!e)return"No active window";const t=Date.parse(e);return Number.isFinite(t)?`${ht(t)} UTC`:e}function Td(e,t,n,r){const o=n>0?Math.min(1,t/n):0,i=O(e,"div",{class:"cv-meter",role:"meter","aria-label":r,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":Math.min(t,n)},O(e,"span"));return i.firstElementChild.style.width=`${Math.round(o*100)}%`,i}function cs(e,t){return O(e,"dl",{class:"cv-facts"},...t.flatMap(([n,r])=>[O(e,"dt",{text:n}),O(e,"dd",{text:r})]))}function cS(e,t){const n=e.ownerDocument,r=aS(t.structuredContent);let o,i,s;return r.kind==="wallet"?(i="Wallet allowance",s=`${et(r.wallet)} · ${r.tier==="subscriber"?"Subscriber":"No active subscription"}`,o=[Td(n,r.consumedUsd,r.allowanceUsd,"Share of today's allowance used"),cs(n,[["Daily allowance",xd(r.allowanceUsd)],["Used today",xd(r.consumedUsd)],["Window ends",as(r.windowEnd)]])]):r.kind==="free"?(i="Free tier",s=`No wallet · counted per ${r.identifierKind==="ip"||!r.identifierKind?"network address":r.identifierKind}`,o=r.noLimit?[O(n,"p",{class:"cv-balance-note","data-no-limit":"",text:"Free access, no daily limit"}),cs(n,[["Daily allowance","No daily limit"],["Used today",lo(r.used,r.unit)],["Window ends",as(r.resetAt)]])]:[Td(n,r.used,r.limit,"Share of today's free allowance used"),cs(n,[["Daily allowance",lo(r.limit,r.unit)],["Used today",lo(r.used,r.unit)],["Left today",lo(r.remaining,r.unit)],["Window ends",as(r.resetAt)]])]):(i="Usage",s="The server sent no allowance figures.",o=[O(n,"p",{class:"cv-muted",text:ul(t)||"Nothing to show."})]),e.replaceChildren(O(n,"section",{class:"cv-card cv-balance-view","data-view":"balance","data-balance":r.kind,"aria-label":i},O(n,"header",{class:"cv-card-head"},O(n,"strong",{text:i}),O(n,"span",{class:"cv-muted",text:s})),...o)),r}function ll(e,t,n="No drawing for this answer."){const r=e.ownerDocument,o=ul(t);e.replaceChildren(O(r,"section",{class:"cv-card cv-text-view","data-view":"text",role:t?.isError?"alert":null},O(r,"p",{text:t?.isError?"No drawing: the tool answered with an error.":n}),o?O(r,"p",{class:"cv-muted cv-text-body",text:o.length>600?`${o.slice(0,599)}…`:o}):null))}function Dg(e,t="Loading the Chain Insights view"){const n=e.ownerDocument;e.replaceChildren(O(n,"section",{class:"cv-card cv-skeleton","data-view":"loading","aria-busy":"true","aria-label":t},O(n,"span",{class:"cv-sr",text:t}),O(n,"div",{class:"cv-skel-line cv-skel-title"}),O(n,"div",{class:"cv-skel-line cv-skel-sub"}),O(n,"div",{class:"cv-skel-block"})))}const uS="graph_expand",fo="too busy to expand",jg=480,lS=300,us=.45,dS="Full screen shows the whole graph",fS=[["scam","Scam"],["sanctioned","Sanctioned"],["exchange","Exchange"],["victim","Victim"],["pool","Pool"],["other","Other"]];function pS(e,t,n){return{network:e,address:t,in_offset:n?.in_offset??0,out_offset:n?.out_offset??0}}function hS(e){const t=ul(e);return e?e.isError?t||"the server refused the expansion":/query_timeout|topology_busy/.test(t)?t:ol(e.structuredContent)?null:t||"the answer held no money flows":"no answer"}function mS(e,t,n,r=jg,o=lS){if(!e||t<=0)return{height:r,fits:!0};const i=Math.max(1,e.x2-e.x1),s=Math.max(1,e.y2-e.y1),a=Math.max(us,Math.min(1,(t-Vn*2)/i)),c=Math.ceil(n+s*a+Vn*2),u=Math.min(r,Math.max(o,c));return _d(e,t,u-n)>=us?{height:u,fits:!0}:{height:r,fits:_d(e,t,r-n)>=us}}function gS(e,t){return`investigator expanded ${e}: ${t} new addresses`}function yS(e,t){const n=e.nodes.find(r=>r.address.toLowerCase()===t.toLowerCase());return n&&Wi({role:n.role??null,labels:n.labels??[]})||"Other"}function _S(e,t,n){const r=e.ownerDocument,o=t.network??"robinhood",i=t.center.toLowerCase(),s=new Map([[i,{cursor:t.cursor??null,truncated:!!t.truncated}]]),a=new Set,c=new Set;let u=!1;const l=O(r,"p",{class:"cv-status",role:"status","aria-live":"polite",text:"Select an address to load its senders and receivers."}),d=O(r,"ul",{class:"cv-roles","aria-label":"Address roles"}),f=O(r,"div",{class:"cv-canvas","data-graph":""}),p=O(r,"aside",{class:"cv-detail","aria-label":"Selection",hidden:!0},O(r,"strong",{"data-selection-title":""}),O(r,"code",{"data-selection-identity":""}),O(r,"div",{class:"cv-detail-meta","data-selection-meta":""})),h=O(r,"button",{type:"button",class:"cv-button","data-fullscreen":"",hidden:!0,"aria-label":"Open full screen",text:"Full screen"}),m=O(r,"span",{class:"cv-hint","data-fullscreen-hint":"",hidden:!0,text:dS}),k=O(r,"div",{class:"cv-actions"},O(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"out","aria-label":"Zoom out",text:"−"}),O(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"in","aria-label":"Zoom in",text:"+"}),O(r,"button",{type:"button",class:"cv-button","data-zoom":"fit","aria-label":"Fit the graph",text:"Fit"}),m,h),I=O(r,"span",{class:"cv-muted"}),v=O(r,"section",{class:"cv-flows cia-graph-surface","data-view":"flows","aria-label":`Money flows of ${i}`},O(r,"header",{class:"cv-flows-head"},O(r,"div",{class:"cv-title"},O(r,"strong",{text:"Money flows"}),I),k),d,f,p,l);e.replaceChildren(v);function z(){const J=de.model(),W=J.truncated?" · more flows than shown":"";I.textContent=`${et(i)} · ${yS(t,i)} · ${o} · ${J.nodes.length} addresses${W}`;const qe=new Set(J.nodes.map(ce=>ce.role??"other"));d.replaceChildren(...fS.filter(([ce])=>qe.has(ce)).map(([ce,Ft])=>{const Be=O(r,"i",{"aria-hidden":"true"});return Be.style.background=`var(--cia-graph-role-${ce})`,O(r,"li",{"data-role":ce},Be,Ft)}))}const C=J=>{u=!!J.target?.closest?.("[data-node-id]")},R=J=>{u=(J.key==="Enter"||J.key===" ")&&!!J.target?.closest?.("[data-node-id]")};f.addEventListener("pointerdown",C,!0),f.addEventListener("keydown",R,!0);function N(J){const W=p.hidden;p.hidden=J.kind==null,W!==p.hidden&&Te();const qe=u&&J.kind==="node"&&J.node;u=!1,qe&&Qe(J.node.address)}const U=n.height??jg,de=K$(f,t,{layout:"tree",width:n.width??720,height:U,now:n.now,controls:k,selectionRoot:p,onSelect:N,openLink:J=>{n.host.openLink?.({url:J}).catch(()=>{l.textContent="The host did not open the link."})},label:`Money flows of ${i}: senders on the left, receivers on the right. Select an address to load its next page.`});z();let re=n.displayMode??"inline",fe=n.availableDisplayModes??[];function Te(){if(re==="fullscreen"){v.style.removeProperty("height"),m.hidden=!0;return}const J=f.clientWidth||n.width||720,W=Math.max(0,v.offsetHeight-f.offsetHeight)||140,{height:qe,fits:ce}=mS(de.contentBounds(),J,W);v.style.height=`${qe}px`,m.hidden=ce||!fe.includes("fullscreen"),v.dataset.fits=String(ce),de.fit()}async function Qe(J){const W=J.toLowerCase();if(a.has(W))return l.textContent=`${et(W)} is ${fo}.`,{added:[],refused:fo};if(c.has(W))return{added:[],refused:null};const qe=s.get(W);if(qe&&!qe.truncated)return l.textContent=`Every recent flow of ${et(W)} is drawn.`,{added:[],refused:null};c.add(W),l.textContent=`Loading the flows of ${et(W)}…`;let ce=null;try{ce=await n.host.callServerTool({name:uS,arguments:pS(o,W,qe?.cursor)})}catch(Vt){ce={isError:!0,content:[{type:"text",text:Vt instanceof Error?Vt.message:String(Vt)}]}}finally{c.delete(W)}const Ft=hS(ce);if(Ft)return a.add(W),de.markNode(W,fo),l.textContent=`${et(W)} is ${fo}. The drawing is kept.`,{added:[],refused:Ft};const Be=ce.structuredContent,Ut=de.merge(Be,W);s.set(W,{cursor:Be.cursor??null,truncated:!!Be.truncated}),z(),Te(),l.textContent=`${Ut.length} new ${Ut.length===1?"address":"addresses"} linked to ${et(W)}.`;try{await n.host.updateModelContext?.({content:[{type:"text",text:gS(W,Ut.length)}]})}catch{}return{added:Ut,refused:null}}function kt(J,W){J&&(re=J),W&&(fe=W),v.dataset.displayMode=re,h.hidden=!fe.includes("fullscreen"),h.textContent=re==="fullscreen"?"Exit full screen":"Full screen",h.setAttribute("aria-label",re==="fullscreen"?"Back to the inline view":"Open full screen"),Te()}kt(re);const Qr=async()=>{const J=re==="fullscreen"?"inline":"fullscreen";try{const W=await n.host.requestDisplayMode?.({mode:J});kt(W?.mode??J)}catch{l.textContent="The host did not change the display mode."}};return h.addEventListener("click",Qr),{root:v,graph:de,expand:Qe,setTheme(J){de.setTheme(J)},setDisplayMode:kt,destroy(){f.removeEventListener("pointerdown",C,!0),f.removeEventListener("keydown",R,!0),h.removeEventListener("click",Qr),de.destroy()}}}function bS(e){return e==="light"||e==="dark"}function wS(e,t=()=>!1){return bS(e?.theme)?e.theme:t()?"dark":"light"}function dl(e,t){const n={...e??{},...t??{}};return(e?.styles||t?.styles)&&(n.styles={...e?.styles??{},...t?.styles??{},variables:{...e?.styles?.variables??{},...t?.styles?.variables??{}}}),n}function Fg(e,t,n={}){const r=e.documentElement,o=wS(t,n.prefersDark);r.setAttribute("data-theme",o),r.style.colorScheme=o;const i=t?.styles?.variables;i&&n.applyVariables&&n.applyVariables(i,r);const s=t?.styles?.css?.fonts;return s&&n.applyFonts&&n.applyFonts(s),o}const mt=document.getElementById("view"),Ug=()=>typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches;let _t={},po=Fg(document,_t,{prefersDark:Ug}),We=null;Dg(mt);const Ge=new nl({name:"chain-insights-view",version:"1.0.0"},{});function Vg(e){const t=po;po=Fg(document,e,{prefersDark:Ug,applyVariables:(n,r)=>Ak(n,r),applyFonts:Mk}),We&&po!==t&&We.setTheme(po),We?.setDisplayMode(e.displayMode,e.availableDisplayModes)}function vS(e){We?.destroy(),We=null;const t=Y$(e);if(document.documentElement.dataset.view=t,t==="flows"){const n=dl(Ge.getHostContext(),_t);We=_S(mt,e.structuredContent,{host:Ge,availableDisplayModes:n.availableDisplayModes,displayMode:n.displayMode})}else t==="table"?sS(mt,e):t==="balance"?cS(mt,e):ll(mt,e)}Ge.ontoolinput=e=>{const t=typeof e.arguments?.address=="string"?e.arguments.address:null;We||Dg(mt,t?`Loading the money flows of ${t}`:"Loading the Chain Insights view")};Ge.ontoolresult=e=>{vS(e)};Ge.ontoolcancelled=()=>{We||ll(mt,null,"The tool call was cancelled. Nothing to draw.")};Ge.onhostcontextchanged=e=>{_t=dl(_t,e),Vg(_t)};Ge.onteardown=async()=>(We?.destroy(),We=null,{});Ge.onerror=e=>{console.warn("chain-insights-view:",e)};Ge.connect(new Og(window.parent,window.parent)).then(()=>{_t=dl(_t,Ge.getHostContext()),Vg(_t)},e=>{console.warn("chain-insights-view: no host answered",e),ll(mt,null,"This view opens inside Claude, next to a Chain Insights tool answer.")});
107
+ - "app": Tool callable by the app from this server only`),csp:Ft().optional(),permissions:Ft().optional()});v({mimeTypes:M(_()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});v({method:b("ui/download-file"),params:v({contents:M(F([Bg,Kg])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});v({method:b("ui/message"),params:v({role:b("user").describe('Message role, currently only "user" is supported.'),content:M(to).describe("Message content blocks (text, image, etc.).")})});v({method:b("ui/notifications/sandbox-resource-ready"),params:v({html:_().describe("HTML content to load into the inner iframe."),sandbox:_().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:pl.optional().describe("CSP configuration from resource metadata."),permissions:hl.optional().describe("Sandbox permissions from resource metadata.")})});var d$=v({method:b("ui/notifications/tool-result"),params:ns.describe("Standard MCP tool execution result.")}),ey=v({toolInfo:v({id:Wr.optional().describe("JSON-RPC id of the tools/call request."),tool:fl.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:Wk.optional().describe("Current color theme preference."),styles:i$.optional().describe("Style configuration for theming the app."),displayMode:Jn.optional().describe("How the UI is currently displayed."),availableDisplayModes:M(Jn).optional().describe("Display modes the host supports."),containerDimensions:F([v({height:Z().describe("Fixed container height in pixels.")}),v({maxHeight:F([Z(),sn()]).optional().describe("Maximum container height in pixels.")})]).and(F([v({width:Z().describe("Fixed container width in pixels.")}),v({maxWidth:F([Z(),sn()]).optional().describe("Maximum container width in pixels.")})])).optional().describe(`Container dimensions. Represents the dimensions of the iframe or other
108
+ container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:_().optional().describe("User's language and region preference in BCP 47 format."),timeZone:_().optional().describe("User's timezone in IANA format."),userAgent:_().optional().describe("Host application identifier."),platform:F([b("web"),b("desktop"),b("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:v({touch:X().optional().describe("Whether the device supports touch input."),hover:X().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:v({top:Z().describe("Top safe area inset in pixels."),right:Z().describe("Right safe area inset in pixels."),bottom:Z().describe("Bottom safe area inset in pixels."),left:Z().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),f$=v({method:b("ui/notifications/host-context-changed"),params:ey.describe("Partial context update containing only changed fields.")});v({method:b("ui/update-model-context"),params:v({content:M(to).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:q(_(),Y().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});v({method:b("ui/initialize"),params:v({appInfo:es.describe("App identification (name and version)."),appCapabilities:c$.describe("Features and capabilities this app provides."),protocolVersion:_().describe("Protocol version this app supports.")})});var p$=v({protocolVersion:_().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:es.describe("Host application identification and version."),hostCapabilities:a$.describe("Features and capabilities provided by the host."),hostContext:ey.describe("Rich context about the host environment.")}).passthrough(),h$={target:"draft-2020-12"};async function Id(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](h$);if(n.vendor==="zod"){let{z:r}=await Ay(()=>Promise.resolve().then(()=>rv),void 0,import.meta.url);return r.toJSONSchema(e,{io:t})}throw Error(`Schema (vendor: ${n.vendor}) does not implement Standard JSON Schema (~standard.jsonSchema). Use a library that does (zod v4, ArkType, Valibot) or wrap your schema accordingly.`)}async function xd(e,t,n=""){let r=await e["~standard"].validate(t);if(r.issues){let o=r.issues.map(i=>{let s=i.path?.map(a=>typeof a=="object"?a.key:a).join(".");return s?`${s}: ${i.message}`:i.message}).join("; ");throw Error(n+o)}return r.value}function m$(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function g$(e){if(document.getElementById("__mcp-host-fonts"))return;let t=document.createElement("style");t.id="__mcp-host-fonts",t.textContent=e,document.head.appendChild(t)}class ml extends Bk{_appInfo;_capabilities;options;_hostCapabilities;_hostInfo;_hostContext;_registeredTools={};_initializedSent=!1;_assertInitialized(t){if(this._initializedSent)return;let n=`[ext-apps] App.${t}() called before connect() completed the ui/initialize handshake. Await app.connect() before calling this method, or move data loading to an ontoolresult handler.`;if(this.options?.strict)throw Error(n);console.warn(`${n}. This will throw in a future release.`)}eventSchemas={toolinput:t$,toolinputpartial:n$,toolresult:d$,toolcancelled:r$,hostcontextchanged:f$};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!ml.ONE_SHOT_EVENTS.has(t)||this._everHadListener.has(t)||(this._everHadListener.add(t),!this._initializedSent))return;let n=`[ext-apps] "${String(t)}" handler registered after connect() completed the ui/initialize handshake. The host may have already sent this notification. Register handlers before calling app.connect().`;if(this.options?.strict)throw Error(n);console.warn(n)}setEventHandler(t,n){n&&this._assertHandlerTiming(t),super.setEventHandler(t,n)}addEventListener(t,n){this._assertHandlerTiming(t),super.addEventListener(t,n)}onEventDispatch(t,n){t==="hostcontextchanged"&&(this._hostContext={...this._hostContext,...n})}constructor(t,n={},r={autoResize:!0}){super(r),this._appInfo=t,this._capabilities=n,this.options=r,r.allowUnsafeEval||me({jitless:!0}),this.setRequestHandler(ts,o=>(console.log("Received ping:",o.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=Hk(this._capabilities,t)}registerTool(t,n,r){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let o=this,i=()=>{o._initializedSent&&o._capabilities.tools?.listChanged&&o.sendToolListChanged()},s=n.inputSchema!==void 0,a={title:n.title,description:n.description,inputSchema:n.inputSchema,outputSchema:n.outputSchema,annotations:n.annotations,_meta:n._meta,enabled:!0,enable(){this.enabled=!0,i()},disable(){this.enabled=!1,i()},update(c){Object.assign(this,c),i()},remove(){o._registeredTools[t]===a&&(delete o._registeredTools[t],i())},handler:async(c,u)=>{if(!a.enabled)throw Error(`Tool ${t} is disabled`);let l;if(s){let d=a.inputSchema,f=d?await xd(d,c??{},`Invalid input for tool ${t}: `):c??{};l=await r(f,u)}else l=await r(u);return a.outputSchema&&!l.isError&&(l.structuredContent=await xd(a.outputSchema,l.structuredContent,`Invalid output for tool ${t}: `)),l}};return this._registeredTools[t]=a,!this._capabilities.tools&&!this.transport&&this.registerCapabilities({tools:{listChanged:!0}}),this.ensureToolHandlersInitialized(),i(),a}_toolHandlersInitialized=!1;ensureToolHandlersInitialized(){this._toolHandlersInitialized||(this._toolHandlersInitialized=!0,this.oncalltool=async(t,n)=>{let r=this._registeredTools[t.name];if(!r)throw Error(`Tool ${t.name} not found`);return r.handler(t.arguments,n)},this.onlisttools=async(t,n)=>({tools:await Promise.all(Object.entries(this._registeredTools).filter(([r,o])=>o.enabled).map(async([r,o])=>{let i={name:r,title:o.title,description:o.description,inputSchema:o.inputSchema?await Id(o.inputSchema,"input"):{type:"object",properties:{}}};return o.outputSchema&&(i.outputSchema=await Id(o.outputSchema,"output")),o.annotations&&(i.annotations=o.annotations),o._meta&&(i._meta=o._meta),i}))}))}async sendToolListChanged(t={}){this._assertInitialized("sendToolListChanged"),await this.notification({method:"notifications/tools/list_changed",params:t})}getHostCapabilities(){return this._hostCapabilities}getHostVersion(){return this._hostInfo}getHostContext(){return this._hostContext}get ontoolinput(){return this.getEventHandler("toolinput")}set ontoolinput(t){this.setEventHandler("toolinput",t)}get ontoolinputpartial(){return this.getEventHandler("toolinputpartial")}set ontoolinputpartial(t){this.setEventHandler("toolinputpartial",t)}get ontoolresult(){return this.getEventHandler("toolresult")}set ontoolresult(t){this.setEventHandler("toolresult",t)}get ontoolcancelled(){return this.getEventHandler("toolcancelled")}set ontoolcancelled(t){this.setEventHandler("toolcancelled",t)}get onhostcontextchanged(){return this.getEventHandler("hostcontextchanged")}set onhostcontextchanged(t){this.setEventHandler("hostcontextchanged",t)}_onteardown;get onteardown(){return this._onteardown}set onteardown(t){this.warnIfRequestHandlerReplaced("onteardown",this._onteardown,t),this._onteardown=t,this.replaceRequestHandler(s$,(n,r)=>{if(!this._onteardown)throw Error("No onteardown handler set");return this._onteardown(n.params,r)})}_oncalltool;get oncalltool(){return this._oncalltool}set oncalltool(t){this.warnIfRequestHandlerReplaced("oncalltool",this._oncalltool,t),this._oncalltool=t,this.replaceRequestHandler(Wg,(n,r)=>{if(!this._oncalltool)throw Error("No oncalltool handler set");return this._oncalltool(n.params,r)})}_onlisttools;get onlisttools(){return this._onlisttools}set onlisttools(t){this.warnIfRequestHandlerReplaced("onlisttools",this._onlisttools,t),this._onlisttools=t,this.replaceRequestHandler(Jg,(n,r)=>{if(!this._onlisttools)throw Error("No onlisttools handler set");return this._onlisttools(n.params,r)})}assertCapabilityForMethod(t){switch(t){case"sampling/createMessage":if(!this._hostCapabilities?.sampling)throw Error(`Host does not support sampling (required for ${t})`);break}}assertRequestHandlerCapability(t){switch(t){case"tools/call":case"tools/list":if(!this._capabilities.tools)throw Error(`Client does not support tool capability (required for ${t})`);return;case"ping":case"ui/resource-teardown":return;default:throw Error(`No handler for method ${t} registered`)}}assertNotificationCapability(t){}assertTaskCapability(t){throw Error("Tasks are not supported in MCP Apps")}assertTaskHandlerCapability(t){throw Error("Task handlers are not supported in MCP Apps")}async callServerTool(t,n){if(this._assertInitialized("callServerTool"),typeof t=="string")throw Error(`callServerTool() expects an object as its first argument, but received a string ("${t}"). Did you mean: callServerTool({ name: "${t}", arguments: { ... } })?`);return await this.request({method:"tools/call",params:t},ns,{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},Hg,n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},qg,n)}async createSamplingMessage(t,n){this._assertInitialized("createSamplingMessage");let r=t.tools?Qg:Yg;return await this.request({method:"sampling/createMessage",params:t},r,n)}sendMessage(t,n){return this._assertInitialized("sendMessage"),this.request({method:"ui/message",params:t},e$,n)}sendLog(t){return this.notification({method:"notifications/message",params:t})}updateModelContext(t,n){return this._assertInitialized("updateModelContext"),this.request({method:"ui/update-model-context",params:t},Yu,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},Qk,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},Xk,n)}requestTeardown(t={}){return this.notification({method:"ui/notifications/request-teardown",params:t})}requestDisplayMode(t,n){return this._assertInitialized("requestDisplayMode"),this.request({method:"ui/request-display-mode",params:t},u$,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,r=0,o=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let s=document.documentElement,a=s.style.height;s.style.height="max-content";let c=Math.ceil(s.getBoundingClientRect().height);s.style.height=a;let u=Math.ceil(window.innerWidth);(u!==n||c!==r)&&(n=u,r=c,this.sendSizeChanged({width:u,height:c}))}))};o();let i=new ResizeObserver(o);return i.observe(document.documentElement),i.observe(document.body),()=>i.disconnect()}async connect(t=new Xg(window.parent,window.parent),n){if(this.transport)throw Error("App is already connected. Call close() before connecting again.");this._initializedSent=!1,await super.connect(t);try{let r=await this.request({method:"ui/initialize",params:{appCapabilities:this._capabilities,appInfo:this._appInfo,protocolVersion:Kk}},p$,n);if(r===void 0)throw Error(`Server sent invalid initialize result: ${r}`);this._hostCapabilities=r.hostCapabilities,this._hostInfo=r.hostInfo,this._hostContext=r.hostContext,await this.notification({method:"ui/notifications/initialized"}),this._initializedSent=!0,this.options?.autoResize&&this.setupSizeChangedNotifications()}catch(r){throw this.close(),r}}}const y$="http://www.w3.org/2000/svg",_$=.45,b$=2.5,w$=5,v$="chain-insights.flows.v1",gl="cia-graph-model",k$=90,bt={rest:.6,related:.95,faded:.07},zd={checked:24,other:19},Wn=16,$$=[["Sanctioned","Sanctioned"],["Scam","Scam"],["Poisoned","Poisoned"],["OnMoneyTrail","On money trail"],["Mixer","Mixer"],["Bridge","Bridge"],["Exchange","Exchange"],["Victim","Victim"],["Targeted","Targeted"]],no=["exchange","scam","sanctioned","victim","pool","other"],S$={exchange:"infrastructure",scam:"danger",sanctioned:"danger",victim:"target",pool:"trail",other:"neutral"},ty={exchange:"Exchange",scam:"Scam",sanctioned:"Sanctioned",victim:"Victim",pool:"Pool",other:""};function yl(e){return!!e&&e.schema===v$}function I$(e){return!!e&&e.kind===gl}function fe(e){return String(e??"").trim().toLowerCase()}function x$(e){const t=fe(e);return no.includes(t)?t:"other"}function yt(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Ms(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function z$(e){const t=String(e??"").toUpperCase();return t==="IN"||t==="OUT"||t==="MIXED"||t==="CHECKED"?t:"OUT"}function He(e){return I$(e)?e:yl(e)?T$(e):C$(e)}function T$(e){const t=fe(e.center),n=new Map;for(const a of e.nodes??[]){const c=fe(a?.address);c&&!n.has(c)&&n.set(c,a)}const r=[],o=new Set;for(const a of e.edges??[]){const c=fe(a?.from),u=fe(a?.to);if(!n.has(c)||!n.has(u)||c===u)continue;const l=`${c}->${u}`;o.has(l)||(o.add(l),r.push({id:l,from:c,to:u,source:"flows",amount_usd_sum:yt(a.usd),tx_count:yt(a.tx_count),first_seen_timestamp:yt(a.first_seen_ms),last_seen_timestamp:yt(a.last_seen_ms),...typeof a.link_kind=="string"&&a.link_kind?{link_kind:a.link_kind}:{}}))}const i=E$(t,[...n.keys()],r),s=[...n.entries()].map(([a,c])=>{const u=i.get(a)??{direction:"OUT",hop:2};return{id:a,address:a,direction:a===t?"CHECKED":u.direction,hop:a===t?0:u.hop,labels:Ms(c.labels),taxonomy:[],role:x$(c.role),total_in_usd:yt(c.total_in_usd),total_out_usd:yt(c.total_out_usd),degree_in:yt(c.degree_in),degree_out:yt(c.degree_out)}});return{kind:gl,checked_address:t,network:e.network??null,nodes:s,edges:r,truncated:!!e.truncated,cursor:e.cursor??null}}function E$(e,t,n){const r=new Map,o=new Map,i=new Map,s=(d,f,p)=>d.set(f,[...d.get(f)??[],p]);for(const d of n)s(r,d.from,d.to),s(o,d.to,d.from),s(i,d.from,d.to),s(i,d.to,d.from);const a=d=>{const f=new Map([[e,0]]);for(let p=[e];p.length;){const h=[];for(const m of p)for(const y of d.get(m)??[])f.has(y)||(f.set(y,(f.get(m)??0)+1),h.push(y));p=h}return f},c=a(r),u=a(o),l=new Map;for(const d of t){if(d===e)continue;const f=c.get(d),p=u.get(d);if(f==null&&p==null)continue;const h=f!=null&&p!=null?f<p?"OUT":p<f?"IN":"MIXED":f!=null?"OUT":"IN";l.set(d,{direction:h,hop:Math.min(2,Math.min(f??1/0,p??1/0))})}for(let d=!0;d;){d=!1;for(const f of t){if(f===e||l.has(f))continue;const p=(i.get(f)??[]).find(m=>m!==e&&l.has(m));if(p==null)continue;const h=l.get(p);l.set(f,{direction:h.direction==="MIXED"?"OUT":h.direction,hop:2}),d=!0}}return l}function C$(e){const t=(e?.nodes??[]).map(r=>({...r,id:String(r.id??r.address),address:r.address,hop:Number(r.hop)||0,direction:r.address===e.checked_address?"CHECKED":z$(r.direction),labels:Ms(r.labels),taxonomy:Ms(r.taxonomy),role:null})),n=(e?.edges??[]).map(r=>({...r,id:String(r.id??`${r.from}->${r.to}`),amount_usd_sum:r.amount_usd_sum??null,tx_count:r.tx_count??null,first_seen_timestamp:r.first_seen_timestamp??null,last_seen_timestamp:r.last_seen_timestamp??null,source:"risk"}));return{kind:gl,checked_address:e?.checked_address??"",network:null,nodes:t,edges:n,truncated:!1,cursor:null}}function A$(e,t,n){const r=He(t),o=$o(e,n??r.checked_address),i=e.nodes.find(d=>d.id===o),s=new Map(e.nodes.map(d=>[fe(d.address),d])),a=[];for(const d of r.nodes){if(s.has(fe(d.address)))continue;const f=!i||i.direction==="CHECKED"?d.direction==="CHECKED"?"OUT":d.direction:i.direction,p={...d,id:d.id,direction:f,hop:Math.min(2,(i?.hop??0)+1)};a.push(p),s.set(fe(d.address),p)}const c=new Set(e.edges.map(d=>d.id)),u=new Set(e.edges.map(d=>`${fe(d.from)}->${fe(d.to)}`)),l=[...e.edges];for(const d of r.edges){const f=`${fe(d.from)}->${fe(d.to)}`;if(c.has(d.id)||u.has(f)||!s.has(fe(d.from))||!s.has(fe(d.to)))continue;const p=s.get(fe(d.from)).address,h=s.get(fe(d.to)).address;l.push({...d,from:p,to:h}),c.add(d.id),u.add(f)}return{model:{...e,nodes:[...e.nodes,...a],edges:l,truncated:e.truncated||r.truncated},added:a.map(d=>d.id)}}function $o(e,t){if(t==null)return null;const n=fe(t);return e.nodes.find(o=>o.id===t||fe(o.address)===n)?.id??null}function Re(e){return typeof e!="string"||e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function _l(e){return String(e??"").trim().replace(/\s+/g," ")}function Po(e){return _l(e).replaceAll(" ","").toLowerCase()}function kt(e){const t=[...e.taxonomy??[],...e.labels??[]],n=new Set,r=[];for(const o of t){const i=_l(o),s=i.toLowerCase();!i||s==="address"||n.has(s)||(n.add(s),r.push(i))}return r}function ho(e,t){const n=new Set(kt(e).map(Po));return t.some(r=>n.has(Po(r)))}function N$(e){if(e.role&&no.includes(e.role))return S$[e.role];if(ho(e,["Sanctioned","Scam","Poisoned"]))return"danger";if(ho(e,["Victim","Targeted"]))return"target";if(ho(e,["OnMoneyTrail","Mixer"]))return"trail";if(ho(e,["Exchange","Bridge","token contract"]))return"infrastructure";if(e.risk_score!=null){const t=String(e.risk_level).toLowerCase();if(t==="critical"||t==="high"||t==="medium"||t==="low")return t}return"neutral"}function de(e){return`var(--cia-graph-${e})`}const O$={semantic:{danger:{stroke:de("danger"),fill:de("node")},target:{stroke:de("target"),fill:de("node")},trail:{stroke:de("trail"),fill:de("node")},infrastructure:{stroke:de("infrastructure"),fill:de("node")},neutral:{stroke:de("neutral"),fill:de("node")}},risk:{CRITICAL:{stroke:de("critical"),fill:de("node")},HIGH:{stroke:de("high"),fill:de("node")},MEDIUM:{stroke:de("medium"),fill:de("node")},LOW:{stroke:de("low"),fill:de("node")}}};function P$(e,t=O$){const n=N$(e);return n==="critical"||n==="high"||n==="medium"||n==="low"?t.risk[n.toUpperCase()]??t.semantic.neutral:t.semantic[n]}function M$(e){return e.role&&no.includes(e.role)?de(`role-${e.role}`):P$(e).stroke}function rs(e){if(e.role&&e.role!=="other"&&no.includes(e.role))return ty[e.role];const t=kt(e);for(const[r,o]of $$)if(t.some(i=>Po(i)===Po(r)))return o;return(Array.isArray(e.labels)?e.labels.map(_l).filter(Boolean).sort((r,o)=>r.localeCompare(o)):[])[0]??""}function Rs(e){return Math.min(b$,Math.max(_$,e))}function ro(e){return[...e.nodes??[]].sort((t,n)=>String(t.id).localeCompare(String(n.id)))}function bl(e,t=ro(e)){return t.find(n=>n.address===e.checked_address)??t[0]}function Td(e,t){return e.address===t?43:e.hop>=2?25:30}function Ls(e,t){return e.address===t?zd.checked:zd.other}function oo(e,t,n){const r=e.address===t,o=Ls(e,t),i=rs(e),s=[];return i&&s.push({kind:"role",text:xS(i),y:o+17}),s.push({kind:"address",text:Re(e.address),y:o+(i?33:17)}),n&&s.push({kind:"note",text:n,y:o+(i?48:32)}),{radius:o,ring:r,dot:r?8:5,texts:s}}const R$={role:{size:13,advance:.68},address:{size:11,advance:.62},note:{size:11,advance:.6}},fs=2;function wl(e){const t=e.radius+(e.ring?7:2),n=[{kind:"circle",box:{x1:-t,y1:-t,x2:t,y2:t}}];for(const r of e.texts){const o=R$[r.kind],i=[...r.text].length*o.size*o.advance/2+fs;n.push({kind:r.kind,box:{x1:-i,y1:r.y-o.size*.8-fs,x2:i,y2:r.y+o.size*.25+fs}})}return n}function ny(e){return e.length?{x1:Math.min(...e.map(t=>t.x1)),y1:Math.min(...e.map(t=>t.y1)),x2:Math.max(...e.map(t=>t.x2)),y2:Math.max(...e.map(t=>t.y2))}:null}function ry(e){return ny(wl(e).map(t=>t.box))}const vl=(e,t)=>(e instanceof Map?e.get(t):e?.[t])??null;function L$(e,t,n){const r=He(e),o=[];for(const i of r.nodes){const s=t[i.id];if(s)for(const{kind:a,box:c}of wl(oo(i,r.checked_address,vl(n,i.id))))o.push({id:i.id,kind:a,x1:s.x+c.x1,y1:s.y+c.y1,x2:s.x+c.x2,y2:s.y+c.y2})}return o}function D$(e,t,n){return ny(L$(e,t,n))}function Z$(e,t){return e.x1<t.x2&&t.x1<e.x2&&e.y1<t.y2&&t.y1<e.y2}function j$(e){let t=0;for(const n of String(e))t=(t<<5)-t+n.charCodeAt(0)|0;return Math.abs(t)}function F$(e,t,n){const r=He(e),o={x:t/2,y:n/2},i={},s=ro(r),a=bl(r,s);if(!a)return i;i[a.id]=o;const c=new Map;for(const u of s){if(u.id===a.id)continue;let l=u.direction==="IN"?-1:1;u.direction==="MIXED"&&(l=j$(u.id)%2?-1:1);const d=Math.min(2,Math.max(1,Number(u.hop)||1)),f=`${l}:${d}`;c.has(f)||c.set(f,[]),c.get(f).push(u)}for(const[u,l]of c){const[d,f]=u.split(":"),p=Number(d),h=Number(f),m=o.x+p*(h===1?t*.23:t*.43);Object.assign(i,U$(l,m,o.y,r.checked_address))}return i}function U$(e,t,n,r,o=24){const i=e.map((c,u)=>({node:c,x:t,y:n+(u-(e.length-1)/2)*64})),s=c=>ry(oo(c,r)),a=(c,u)=>Math.max(Td(c,r)+Td(u,r)+20,s(c).y2-s(u).y1+2);for(let c=0;c<o;c++){for(let d=1;d<i.length;d++){const f=i[d-1],p=i[d];!f||!p||(p.y=Math.max(p.y,f.y+a(f.node,p.node)))}for(let d=i.length-2;d>=0;d--){const f=i[d],p=i[d+1];!f||!p||(f.y=Math.min(f.y,p.y-a(f.node,p.node)))}const u=i[0],l=i[i.length-1];if(u&&l){const d=(u.y+l.y)/2,f=n-d;for(const p of i)p.y+=f}}return Object.fromEntries(i.map(c=>[c.node.id,{x:c.x,y:c.y}]))}function V$(e,t,n){const r=He(e),o={x:t/2,y:n/2},i={},s=ro(r),a=bl(r,s);if(!a)return i;i[a.id]=o;const c=s.filter(u=>u.id!==a.id);return c.forEach((u,l)=>{const d=-Math.PI/2+l*Math.PI*2/Math.max(1,c.length),f=u.hop>=2?Math.min(t,n)*.39:Math.min(t,n)*.27;i[u.id]={x:o.x+Math.cos(d)*f,y:o.y+Math.sin(d)*f}}),i}function q$(e,t,n,r){const o=He(e),i=ro(o).filter(c=>t[c.id]),s=i.find(c=>c.address===o.checked_address);for(let c=0;c<i.length;c++)for(let u=c+1;u<i.length;u++){const l=i[c],d=i[u],f=l&&t[l.id],p=d&&t[d.id];if(!f||!p)continue;const h=p.x-f.x||.1,m=p.y-f.y||.1,y=Math.max(1,Math.hypot(h,m)),$=Math.max(0,88-y)*.012;f.x-=h/y*$,f.y-=m/y*$,p.x+=h/y*$,p.y+=m/y*$}const a=new Map(i.map(c=>[c.address,c]));for(const c of o.edges){const u=a.get(c.from),l=a.get(c.to);if(!u||!l)continue;const d=t[u.id],f=t[l.id];if(!d||!f)continue;const p=f.x-d.x,h=f.y-d.y,m=Math.max(1,Math.hypot(p,h)),y=(m-155)*.003;u!==s&&(d.x+=p/m*y,d.y+=h/m*y),l!==s&&(f.x-=p/m*y,f.y-=h/m*y)}return s&&(t[s.id]={x:n/2,y:r/2}),t}function H$(e,t,n,r=k$){const o=He(e),i=V$(o,t,n);for(let s=0;s<r;s++)q$(o,i,t,n);return i}function mo(e,t,n,r){return t==="tree"?F$(e,n,r):H$(e,n,r)}function B$(e,t,n,r,o={}){const i=He(e),s=t[n],a={...t};if(!s)return a;const c=o.spacing??80,u=o.gap??48,l=Math.max(1,o.perColumn??6),d=i.nodes.find(w=>w.id===n),f=new Map(i.nodes.map(w=>[w.id,w])),p=w=>ry(oo(w,i.checked_address,vl(o.notes,w.id))),h=i.nodes.flatMap(w=>{const S=t[w.id];if(!S)return[];const T=p(w);return[{x1:S.x+T.x1,x2:S.x+T.x2}]});let m=h.length?Math.min(...h.map(w=>w.x1)):s.x,y=h.length?Math.max(...h.map(w=>w.x2)):s.x;const $={left:[],right:[]};for(const w of[...r].sort()){const S=f.get(w);if(!S||a[w])continue;const T=i.edges.some(C=>C.from===S.address&&C.to===d?.address),O=i.edges.some(C=>C.to===S.address&&C.from===d?.address);$[T&&!O?"left":"right"].push(S)}for(const w of["left","right"]){const S=$[w];for(let T=0;T<S.length;T+=l){const O=S.slice(T,T+l),C=O.map(p),L=Math.max(...C.map(le=>Math.max(-le.x1,le.x2))),ue=Math.max(c,Math.max(...C.map(le=>le.y2))-Math.min(...C.map(le=>le.y1))+6),Q=w==="left"?m-u-L:y+u+L;O.forEach((le,xe)=>{a[le.id]={x:Q,y:s.y+(xe-(O.length-1)/2)*ue}}),w==="left"?m=Q-L:y=Q+L}}return a}function K$(e,t,n,r=Wn){const o=Math.max(1,e.x2-e.x1),i=Math.max(1,e.y2-e.y1),s=Rs(Math.min((t-r*2)/o,(n-r*2)/i));return{x:t/2-(e.x1+e.x2)/2*s,y:n/2-(e.y1+e.y2)/2*s,scale:s}}function Ed(e,t,n,r=Wn){return Math.min((t-r*2)/Math.max(1,e.x2-e.x1),(n-r*2)/Math.max(1,e.y2-e.y1))}function J$(e,t,n,r,o=4){const i=t.x-e.x,s=t.y-e.y,a=Math.hypot(i,s),c=n+o,u=r+o;if(!Number.isFinite(a)||a<=0||c+u>=a)return null;const l=i/a,d=s/a;return{x1:e.x+l*c,y1:e.y+d*c,x2:t.x-l*u,y2:t.y-d*u}}function Xe(e){return Math.round(e*100)/100}function ps(e,t,n,r,o){const i=s=>`${Xe(s.x)},${Xe(s.y)}`;return{kind:e,start:t,end:o,controls:[n,r],d:`M${i(t)} C${i(n)} ${i(r)} ${i(o)}`}}function W$(e,t,n,r,o=4){const i=t.x-e.x,s=t.y-e.y,a=Math.hypot(i,s),c=n+r+o*2;if(!Number.isFinite(a)||a<=c)return null;if(i>=c){const f={x:e.x+n+o,y:e.y},p={x:t.x-r-o,y:t.y},h=p.x-f.x,m=Math.max(h*.45,Math.min(65,h));return ps("forward",f,{x:f.x+m,y:f.y},{x:p.x-m,y:p.y},p)}if(i<=-c){const f={x:e.x,y:e.y-n-o},p={x:t.x,y:t.y-r-o},h=Math.max(100,Math.abs(i)*.2);return ps("backward",f,{x:f.x+85,y:f.y-h},{x:p.x+85,y:p.y-h},p)}if(Math.abs(s)>c){const f=s>0?1:-1,p={x:e.x,y:e.y+f*(n+o)},h={x:t.x,y:t.y-f*(r+o)},m=Math.abs(h.y-p.y),y=Math.max(m*.45,Math.min(40,m));return ps("vertical",p,{x:p.x,y:p.y+f*y},{x:h.x,y:h.y-f*y},h)}const u=J$(e,t,n,r,o),l={x:u.x1,y:u.y1},d={x:u.x2,y:u.y2};return{kind:"straight",start:l,end:d,controls:null,d:`M${Xe(l.x)},${Xe(l.y)} L${Xe(d.x)},${Xe(d.y)}`}}const G$=6,hs=G$+3,Qe=14,Cd=10,Y$=3,Ad=6;function Q$(e,t,n){const r=He(e),o=[];for(const i of r.nodes){const s=t[i.id];if(s)for(const{kind:a,box:c}of wl(oo(i,r.checked_address,vl(n,i.id))))a==="circle"?o.push({id:i.id,kind:"circle",x:s.x,y:s.y,r:c.x2}):o.push({id:i.id,kind:"box",x1:s.x+c.x1,y1:s.y+c.y1,x2:s.x+c.x2,y2:s.y+c.y2})}return o}function X$(e,t){if(t.kind==="circle")return Math.hypot(e.x-t.x,e.y-t.y)-t.r;const n=Math.max(t.x1-e.x,0,e.x-t.x2),r=Math.max(t.y1-e.y,0,e.y-t.y2);return n||r?Math.hypot(n,r):-Math.min(e.x-t.x1,t.x2-e.x,e.y-t.y1,t.y2-e.y)}function eS(e,t){return e.kind==="circle"?{x1:e.x-e.r-t,y1:e.y-e.r-t,x2:e.x+e.r+t,y2:e.y+e.r+t}:{x1:e.x1-t,y1:e.y1-t,x2:e.x2+t,y2:e.y2+t}}function tS(e,t){const n=1-t;return{x:n*n*n*e[0].x+3*n*n*t*e[1].x+3*n*t*t*e[2].x+t*t*t*e[3].x,y:n*n*n*e[0].y+3*n*n*t*e[1].y+3*n*t*t*e[2].y+t*t*t*e[3].y}}function nS(e){return e.controls?[{kind:"C",points:[e.start,e.controls[0],e.controls[1],e.end]}]:[{kind:"L",points:[e.start,e.end]}]}function oy(e){let t=0,n;for(const r of e)n&&(t+=Math.hypot(r.x-n.x,r.y-n.y)),n=r;return t}function rS(e,t){const n=[];for(const r of e){const o=Math.max(1,Math.ceil(oy(r.points)/t));for(let i=0;i<=o;i++){const s=i/o;if(r.kind==="L"){const[a,c]=r.points;n.push({x:a.x+(c.x-a.x)*s,y:a.y+(c.y-a.y)*s})}else n.push(tS(r.points,s))}}return n}function Nd(e,t,n,r){const o=e.flatMap(a=>a.points),i={x1:Math.min(...o.map(a=>a.x)),y1:Math.min(...o.map(a=>a.y)),x2:Math.max(...o.map(a=>a.x)),y2:Math.max(...o.map(a=>a.y))},s=[];if(n.forEach((a,c)=>{a.x1<=i.x2&&i.x1<=a.x2&&a.y1<=i.y2&&i.y1<=a.y2&&s.push(c)}),!s.length)return!0;for(const a of rS(e,Y$))for(const c of s){const u=n[c],l=t[c];if(!(!u||!l)&&!(a.x<u.x1||a.x>u.x2||a.y<u.y1||a.y>u.y2)&&X$(a,l)<r)return!1}return!0}function oS(e){const t=e[0],n=e[e.length-1];if(!t||!n)return[];const r=[];for(let s=1;s<e.length;s++)r.push(oy(e.slice(s-1,s+1)));const o=[];let i=t;for(let s=1;s<e.length-1;s++){const a=e[s-1],c=e[s],u=e[s+1],l=r[s-1],d=r[s];if(!a||!c||!u||l===void 0||d===void 0)continue;const f=l/(s-1===0?1:2),p=d/(s===r.length-1?1:2),h=Math.min(Qe,f,p),m={x:(c.x-a.x)/l,y:(c.y-a.y)/l},y={x:(u.x-c.x)/d,y:(u.y-c.y)/d},$={x:c.x-m.x*h,y:c.y-m.y*h},w={x:c.x+y.x*h,y:c.y+y.y*h};o.push({kind:"L",points:[i,$]}),o.push({kind:"C",points:[$,{x:$.x+m.x*h*.55,y:$.y+m.y*h*.55},{x:w.x-y.x*h*.55,y:w.y-y.y*h*.55},w]}),i=w}return o.push({kind:"L",points:[i,n]}),o.filter(s=>s.kind==="C"||Math.hypot(s.points[1].x-s.points[0].x,s.points[1].y-s.points[0].y)>.01)}function iS(e){const t=o=>`${Xe(o.x)},${Xe(o.y)}`,n=e[0];if(!n)return"";let r=`M${t(n.points[0])}`;for(const o of e)r+=o.kind==="L"?` L${t(o.points[1])}`:` C${t(o.points[1])} ${t(o.points[2])} ${t(o.points[3])}`;return r}function Od(e,t,n,r,o){const i=Math.min(e.y,n)-Qe,s=Math.max(e.y,n)+Qe,a=d=>(d-e.x)*t;let c=1/0;for(const d of o)if(d.y1<e.y&&e.y<d.y2){const f=t===1?d.x1:d.x2,p=t===1?d.x2:d.x1;a(p)>0&&(c=Math.min(c,Math.max(0,a(f))))}const u=o.filter(d=>d.y1<s&&i<d.y2).map(d=>[a(t===1?d.x1:d.x2),a(t===1?d.x2:d.x1)]).filter(([,d])=>d>r).sort((d,f)=>d[0]-f[0]);let l=r;for(const[d,f]of[...u,[1/0,1/0]]){if(d>l+1){const p=Math.min(d,c);if(p<=l+1)return null;const h=Number.isFinite(p)&&p-l<80?(l+p)/2:l+40;return e.x+t*h}if(l=Math.max(l,f),l>=c)return null}return null}function sS(e){const t=[];for(const n of e){const r=t[t.length-1];r&&Math.abs(r.x-n.x)<.01&&Math.abs(r.y-n.y)<.01||t.push(n)}return t.filter((n,r)=>{if(r===0||r===t.length-1)return!0;const o=t[r-1],i=t[r+1];return!o||!i?!0:!(Math.abs(o.x-n.x)<.01&&Math.abs(i.x-n.x)<.01||Math.abs(o.y-n.y)<.01&&Math.abs(i.y-n.y)<.01)})}function aS(e,t,n,r,o,i=4){const s=W$(e,t,n,r,i);if(!s||!o.length)return s;const a=o.map(f=>eS(f,hs));if(Nd(nS(s),o,a,hs))return s;const c=new Set([e.y,t.y]),u=f=>Math.abs(f-e.y)<Ad?e.y:Math.abs(f-t.y)<Ad?t.y:f;for(const f of a)c.add(u(Math.round(f.y1)-Qe-1)),c.add(u(Math.round(f.y2)+Qe+1));const l=t.x>=e.x?1:-1,d=[[l,l],[l,-l],[-l,l],[-l,-l]];for(const[f,p]of d){const h={x:e.x+f*(n+i),y:e.y},m={x:t.x-p*(r+i),y:t.y},y=[];for(const $ of c){const w=Math.abs($-h.y)<.01?h.x:Od(h,f,$,Qe,a);if(w===null)continue;const S=Math.abs($-m.y)<.01?m.x:Od(m,-p,$,Qe+Cd,a);if(S===null||Math.abs($-m.y)<.01&&(m.x-w)*p<Qe+Cd||Math.abs($-h.y)<.01&&(S-h.x)*f<Qe)continue;const T=sS([h,{x:w,y:h.y},{x:w,y:$},{x:S,y:$},{x:S,y:m.y},m]);if(!cS(T,a))continue;let O=(T.length-2)*Qe,C;for(const L of T)C&&(O+=Math.abs(L.x-C.x)+Math.abs(L.y-C.y)),C=L;y.push({points:T,length:O})}y.sort(($,w)=>{const S=$.points[2]?.y,T=w.points[2]?.y;return $.length-w.length||(S===void 0||T===void 0?0:S-T)});for(const $ of y){const w=oS($.points);if(!Nd(w,o,a,hs))continue;const S=$.points,T=S[0],O=S[S.length-1];if(!T||!O)continue;const C={x1:Math.min(...S.map(L=>L.x)),y1:Math.min(...S.map(L=>L.y)),x2:Math.max(...S.map(L=>L.x)),y2:Math.max(...S.map(L=>L.y))};return{kind:"routed",start:T,end:O,controls:null,d:iS(w),bounds:C}}}return s}function cS(e,t){let n;for(const r of e){if(n){const o={x1:Math.min(n.x,r.x),y1:Math.min(n.y,r.y),x2:Math.max(n.x,r.x),y2:Math.max(n.y,r.y)};for(const i of t)if(Z$(o,i))return!1}n=r}return!0}function uS(e,t){if(!t)return bt.rest;const n=fe(t);return fe(e.from)===n||fe(e.to)===n?bt.related:bt.faded}function lS(){return{hit:{stroke:"transparent",width:16},line:{stroke:de("edge"),width:1.6},arrow:{fill:de("edge")}}}function dS(e,t,n){return e!=="gravity"&&e!=="tree"?null:{layout:e,id:t,pointerId:n}}function fS(e,t,n,r){return e!=="node"&&e!=="edge"&&e!=="canvas"||!Number.isFinite(r?.x)||!Number.isFinite(r?.y)?null:{kind:e,id:t??null,pointerId:n,start:{...r},moved:!1}}function pS(e,t,n,r=w$){if(!e||e.pointerId!==t)return e;const o=Math.hypot(n.x-e.start.x,n.y-e.start.y);return{...e,moved:e.moved||o>r}}function hS(e,t,n=!1){return!e||e.pointerId!==t||n||e.moved?null:e.kind==="node"?{type:"select-node",id:e.id}:e.kind==="edge"?{type:"select-edge",id:e.id}:e.kind==="canvas"?{type:"select-checked"}:null}function Pd(e){return e==="Enter"||e===" "}function mS(e,t){return{x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale}}function gS(e,t,n,r,o){return!t||t.pointerId!==n||!Object.hasOwn(e,t.id)?!1:(e[t.id]=mS(r,o),!0)}function yS(e,t){return e?.pointerId===t?null:e}function _S(e,t,n,r){const o=Math.min(t.width/n,t.height/r),i=t.left+(t.width-n*o)/2,s=t.top+(t.height-r*o)/2;return{x:(e.x-i)/o,y:(e.y-s)/o}}function bS(e,t){const n=new Map;let r=null,o=null,i=null;function s(f){if(f===e)return{kind:"canvas",id:null};const p=f;if(p?.closest?.("[data-canvas]"))return{kind:"canvas",id:null};const h=p?.closest?.("[data-node-id]");if(h)return{kind:"node",id:h.dataset.nodeId??null};const m=p?.closest?.("[data-edge-id]");return m?{kind:"edge",id:m.dataset.edgeId??null}:null}function a(f){if(f.pointerType==="mouse"&&f.button!==0)return;const p=s(f.target);if(!p)return;const h=t.point(f);if(n.set(f.pointerId,h),e.setPointerCapture(f.pointerId),p.kind!=="canvas"&&(f.preventDefault(),f.stopPropagation()),n.size===1){r=fS(p.kind,p.id,f.pointerId,{x:f.clientX,y:f.clientY}),o=p.kind==="canvas"?{point:h,transform:{...t.transform()}}:null;return}if(r&&(r={...r,moved:!0}),o=null,n.size===2){const[m,y]=[...n.values()];m&&y&&(i={distance:Math.hypot(y.x-m.x,y.y-m.y),scale:t.transform().scale},t.startPinch())}}function c(f){if(!n.has(f.pointerId))return;const p=t.point(f);if(n.set(f.pointerId,p),i){const[h,m]=[...n.values()];h&&m&&t.pinch(i,[h,m],f);return}if(r?.pointerId===f.pointerId){if(r=pS(r,f.pointerId,{x:f.clientX,y:f.clientY}),!r?.moved)return;if(r.kind==="node"){t.drag(r.id??"",f.pointerId,p,f);return}if(r.kind==="edge")return}o&&t.pan(o,p,f)}function u(f,p=!1){const h=hS(r,f.pointerId,p);h&&t.select(h),r?.pointerId===f.pointerId&&(r=null),t.endDrag(f.pointerId),n.delete(f.pointerId),n.size||(r=null,o=null,i=null),e.hasPointerCapture(f.pointerId)&&e.releasePointerCapture(f.pointerId)}const l=f=>u(f),d=f=>u(f,!0);return e.addEventListener("pointerdown",a,!0),e.addEventListener("pointermove",c),e.addEventListener("pointerup",l),e.addEventListener("pointercancel",d),()=>{e.removeEventListener("pointerdown",a,!0),e.removeEventListener("pointermove",c),e.removeEventListener("pointerup",l),e.removeEventListener("pointercancel",d)}}function wS(e,t,n){let r=!1;function o(i,s=!1){r=i,e.classList.toggle("graph-panel--expanded",i),n.classList.toggle("graph-expanded",i),t.classList.toggle("expand-control--expanded",i),t.setAttribute("aria-expanded",String(i)),t.setAttribute("aria-label",i?"Close expanded graph":"Expand graph"),t.setAttribute("title",i?"Close expanded graph":"Expand graph"),i?(e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true")):(e.removeAttribute("role"),e.removeAttribute("aria-modal"),s&&t.focus())}return{open(){o(!0)},close(i={}){o(!1,i.restoreFocus!==!1)},toggle(){o(!r,r)},isOpen(){return r}}}function iy(e){const t=String(e??"").toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown"}function Ds(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e)}function Zs(e){return e==null?"Unavailable":new Intl.NumberFormat("en-US").format(e)}function wt(e){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"Unavailable";const t=new Date(e<1e11?e*1e3:e);return!Number.isFinite(t.getTime())||t.getUTCFullYear()<2009||t.getUTCFullYear()>2100?"Unavailable":new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeStyle:"short",timeZone:"UTC"}).format(t)}function sy(e,t=Date.now()){if(typeof e!="number"||!Number.isFinite(e)||e<=0)return"Unavailable";const n=Math.max(0,(t-(e<1e11?e*1e3:e))/1e3),r=[[31536e3,"year"],[2592e3,"month"],[86400,"day"],[3600,"hour"],[60,"minute"]];for(const[o,i]of r){const s=Math.floor(n/o);if(s>=1)return`${s} ${i}${s===1?"":"s"} ago`}return"just now"}function js(e){if(e.amount_usd_sum==null||e.price_coverage_ratio===0)return"Unavailable";const t=e.price_coverage_ratio;return Ds(e.amount_usd_sum)+(t!=null&&t>0&&t<1?" (priced portion)":"")}function vS(e){const t=[["Incoming amount (USD)",e.total_in_usd==null?"Unavailable":Ds(e.total_in_usd)],["Outgoing amount (USD)",e.total_out_usd==null?"Unavailable":Ds(e.total_out_usd)]];return e.role&&no.includes(e.role)?[["Role",ty[e.role]||"Other"],...t,["Senders",Zs(e.degree_in)],["Receivers",Zs(e.degree_out)],["Labels",kt(e).join(", ")||"No labels"]]:[["Address risk",e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} · ${iy(e.risk_level)}`],["Confidence","Unavailable"],...t,["First activity (UTC)",wt(e.first_activity_timestamp)],["Last activity (UTC)",wt(e.last_activity_timestamp)],["Labels",kt(e).join(", ")||"No labels"]]}function kS(e,t){if(e.source==="flows")return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",js(e)],["Transfers",Zs(e.tx_count)],["First seen (UTC)",wt(e.first_seen_timestamp)],["Last seen (UTC)",wt(e.last_seen_timestamp)],["Since last seen",sy(e.last_seen_timestamp,t)],...e.link_kind?[["Link kind",e.link_kind]]:[]];const n=e.price_coverage_ratio;return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",js(e)],["Price coverage",n==null?"Unavailable":new Intl.NumberFormat("en-GB",{style:"percent",maximumFractionDigits:1}).format(n)],["Transfers",e.tx_count==null?"Unavailable":String(e.tx_count)],["First seen (UTC)",wt(e.first_seen_timestamp)],["Last seen (UTC)",wt(e.last_seen_timestamp)],["First transaction",e.first_tx_id||"Unavailable"],["Last transaction",e.last_tx_id||"Unavailable"]]}function ay(e){return typeof e!="string"||!/^0x[a-fA-F0-9]{64}$/.test(e)?null:`https://robinhoodchain.blockscout.com/tx/${e.toLowerCase()}`}function Md(e){const t=rs(e);if(e.role)return`${e.address}. ${t||"Other"}.${kt(e).length?` Labels: ${kt(e).join(", ")}.`:""}`;const n=e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} ${iy(e.risk_level)} risk`,r=kt(e).join(", ");return`${e.address}. ${n}.${r?` Labels: ${r}.`:""}`}function Rd(e,t){const n=`${e.from} to ${e.to}. Aggregate value ${js(e)}. ${e.tx_count??0} ${e.tx_count===1?"transfer":"transfers"}.`;return e.source==="flows"&&e.last_seen_timestamp?`${n} Last seen ${sy(e.last_seen_timestamp,t)}.`:n}function $S(e,t){return He(e).nodes.map(n=>{const r={id:n.address,label:kt(n).join(", ")||rs(n)};n.role&&(r.role=n.role);const o=t?.(n.address);return o&&(r.href=o),r})}let SS=0;function pe(e,t={}){const n=document.createElementNS(y$,e);for(const[r,o]of Object.entries(t))n.setAttribute(r,String(o));return n}function IS(e,t,n){const r=pe("text",{x:0,y:t,"text-anchor":"middle",class:n,"pointer-events":"none"});return r.textContent=e,r}function xS(e,t=22){return e.length>t?`${e.slice(0,t-1)}…`:e}function zS(e,t,n={}){const r=`cia-graph-${++SS}`,o=e.ownerDocument;let i=He(t),s=n.layout??(yl(t)?"tree":"gravity");const a={width:e.clientWidth||n.width||820,height:e.clientHeight||n.height||430};let c=mo(i,s,a.width,a.height);const u=new Map,l=()=>{const k=new Map,x=new Map(i.nodes.map(N=>[N.address,N])),A=Q$(i,c,u);for(const N of i.edges){const J=x.get(N.from),W=x.get(N.to),ce=J&&c[J.id],Pe=W&&c[W.id];if(!J||!W||!ce||!Pe){k.set(N.id,null);continue}const ot=A.filter(At=>At.id!==J.id&&At.id!==W.id);k.set(N.id,aS(ce,Pe,Ls(J,i.checked_address),Ls(W,i.checked_address),ot))}return k},d=()=>{const k=D$(i,c,u);if(!k)return null;for(const x of l().values())x?.bounds&&(k.x1=Math.min(k.x1,x.bounds.x1),k.y1=Math.min(k.y1,x.bounds.y1),k.x2=Math.max(k.x2,x.bounds.x2),k.y2=Math.max(k.y2,x.bounds.y2));return k},f=()=>{const k=d();return k?K$(k,a.width,a.height,Wn):{x:0,y:0,scale:1}};let p=f(),h=null,m=null;const y=n.now??(()=>Date.now());e.classList.add("cia-graph-engine"),e.closest(".cia-graph-surface")||e.classList.add("cia-graph-surface");const $=pe("svg",{class:"cia-graph-svg",viewBox:`0 0 ${a.width} ${a.height}`,role:"group",tabindex:0,"aria-label":n.label??"Money-flow graph. Drag the background or use arrow keys to pan, plus and minus to zoom. Select an address or a link for details."}),w=pe("defs"),S=pe("pattern",{id:`${r}-dots`,width:24,height:24,patternUnits:"userSpaceOnUse"});S.append(pe("circle",{class:"cia-graph-dot",cx:1,cy:1,r:1})),w.append(S);const T=pe("rect",{class:"cia-graph-backdrop",width:"100%",height:"100%","data-canvas":""}),O=pe("rect",{class:"cia-graph-dots",width:"100%",height:"100%",fill:`url(#${r}-dots)`,"data-canvas":""}),C=pe("g",{"data-viewport":""}),L=pe("g",{"data-edges":"",class:"cia-graph-edges"}),ue=pe("g",{"data-nodes":"",class:"cia-graph-nodes"});C.append(L,ue),$.append(w,T,O,C);const Q=o.createElement("div");Q.className="graph-tooltip cia-graph-tooltip",Q.hidden=!0,Q.setAttribute("role","tooltip"),e.append($,Q);const le=new Map,xe=new Map,$e=new Map;function We(k){let x=le.get(k);if(x)return x;x=`${r}-arrow-${le.size}`;const A=pe("marker",{id:x,viewBox:"0 0 10 10",refX:9,refY:5,markerWidth:6,markerHeight:6,orient:"auto-start-reverse",markerUnits:"strokeWidth"}),N=pe("path",{d:"M0 0L10 5L0 10Z",class:"cia-graph-arrowhead"});return N.style.fill=k,A.append(N),w.append(A),le.set(k,x),x}const Nn=()=>new Map(i.nodes.map(k=>[k.address,k])),nt=k=>n.nodeStyle?.(k).stroke??M$(k);function zt(){L.replaceChildren(),ue.replaceChildren(),xe.clear(),$e.clear();const k=Nn();for(const x of i.edges){const A=k.get(x.from);if(!A||!k.get(x.to))continue;const N=nt(A),J=pe("g",{class:"cia-graph-edge graph-edge",tabindex:0,role:"button","aria-label":Rd(x,y())});J.dataset.edgeId=x.id,J.style.setProperty("--edge-tone",N);const W=lS(),ce=pe("path",{class:"cia-graph-edge-hit","stroke-width":W.hit.width,"pointer-events":"stroke"}),Pe=pe("path",{class:"cia-graph-edge-line","stroke-width":W.line.width,"marker-end":`url(#${We(N)})`,"pointer-events":"none"});J.append(ce,Pe),J.addEventListener("keydown",ot=>{Pd(ot.key)&&(ot.preventDefault(),mt(x.id))}),J.addEventListener("pointerenter",ot=>Il(ot,Rd(x,y()))),J.addEventListener("pointerleave",xl),L.append(J),$e.set(x.id,{group:J,hit:ce,line:Pe})}for(const x of ro(i))ue.append(On(x));rt(),V()}function On(k){const x=k.address===i.checked_address,A=u.get(k.id),N=oo(k,i.checked_address,A),J=N.radius,W=pe("g",{class:"cia-graph-node graph-node",tabindex:0,role:"button","aria-label":Md(k),"aria-pressed":"false"});W.dataset.nodeId=k.id,x&&(W.dataset.checked=""),W.style.setProperty("--node-tone",nt(k)),x&&W.append(pe("circle",{class:"cia-graph-node-ring",r:J+6})),W.append(pe("circle",{class:"cia-graph-node-body",r:J})),W.append(pe("circle",{class:"cia-graph-node-dot",r:N.dot}));for(const ce of N.texts)W.append(IS(ce.text,ce.y,`cia-graph-node-${ce.kind}`));return A&&(W.dataset.state="refused"),W.addEventListener("keydown",ce=>{Pd(ce.key)&&(ce.preventDefault(),Oe(k.id))}),W.addEventListener("pointerenter",ce=>Il(ce,Md(k))),W.addEventListener("pointerleave",xl),xe.set(k.id,W),W}function rt(){C.setAttribute("transform",`translate(${p.x} ${p.y}) scale(${p.scale})`);for(const[x,A]of xe){const N=c[x]??{x:a.width/2,y:a.height/2};A.setAttribute("transform",`translate(${Xe(N.x)} ${Xe(N.y)})`)}const k=l();for(const x of i.edges){const A=$e.get(x.id);if(!A)continue;const N=k.get(x.id)??null;A.group.style.display=N?"":"none",N&&(A.hit.setAttribute("d",N.d),A.line.setAttribute("d",N.d))}}function K(){return h?.kind!=="node"?null:i.nodes.find(k=>k.id===h.id)?.address??null}function V(){const k=K();for(const x of i.edges){const A=$e.get(x.id);if(!A)continue;const N=h?.kind==="edge"&&h.id===x.id,J=h?.kind==="edge"?N?bt.related:bt.faded:uS(x,k),W=J===bt.faded;A.group.setAttribute("opacity",W?String(J):"1"),A.line.setAttribute("stroke-opacity",W?"1":String(J)),A.group.dataset.opacity=String(J),A.group.dataset.state=J===bt.rest?"rest":J===bt.related?"related":"faded",A.group.setAttribute("aria-pressed",String(N))}for(const[x,A]of xe){const N=h?.kind==="node"&&h.id===x;A.classList.toggle("is-selected",N),A.setAttribute("aria-pressed",String(N))}}function _e(){const k=$S(i,n.href),x=h?.kind==="node"?i.nodes.find(N=>N.id===h.id)??null:null,A=h?.kind==="edge"?i.edges.find(N=>N.id===h.id)??null:null;if(x){const N=i.edges.filter(J=>J.from===x.address||J.to===x.address);return{kind:"node",id:x.id,selectedId:x.address,nodes:k,title:"Selected address",identity:x.address,values:vS(x),related:N,node:x,edge:null}}return A?{kind:"edge",id:A.id,selectedId:null,nodes:k,title:"Selected aggregate flow",identity:`${A.from} → ${A.to}`,values:kS(A,y()),related:[A],node:null,edge:A}:{kind:null,id:null,selectedId:null,nodes:k,title:"Nothing selected",identity:"",values:[],related:[],node:null,edge:null}}function ae(){const k=_e();Bt(k),n.onSelect?.(k)}function Bt(k){const x=n.selectionRoot,A=x?.querySelector("[data-selection-title]"),N=x?.querySelector("[data-selection-identity]"),J=x?.querySelector("[data-selection-meta]");!A||!N||!J||(A.textContent=k.title,N.textContent=k.identity,J.replaceChildren(...k.values.map(([W,ce])=>{const Pe=o.createElement("div");Pe.className="meta-item",ce!=="Unavailable"&&(["From","To","First transaction","Last transaction"].includes(W)&&Pe.classList.add("meta-item--identity"),W==="Incoming amount (USD)"&&Pe.classList.add("meta-item--incoming"),W==="Outgoing amount (USD)"&&Pe.classList.add("meta-item--outgoing")),["From","To","First transaction","Last transaction","Labels"].includes(W)&&Pe.classList.add("meta-item--wide");const ot=o.createElement("span");ot.textContent=W;const At=o.createElement("strong"),Mn=["First transaction","Last transaction"].includes(W)?ay(ce):null;if(Mn&&n.openLink){const gt=n.openLink,Nt=o.createElement("button");Nt.type="button",Nt.className="cia-graph-explorer-link",Nt.dataset.explorer=Mn,Nt.textContent=ce,Nt.setAttribute("aria-label",`${W}: ${ce} (opens the explorer)`),Nt.addEventListener("click",()=>gt(Mn)),At.append(Nt)}else if(Mn){const gt=o.createElement("a");gt.href=Mn,gt.target="_blank",gt.rel="noopener noreferrer",gt.textContent=ce,gt.setAttribute("aria-label",`${W}: ${ce} (opens in new tab)`),At.append(gt)}else At.textContent=ce;return Pe.append(ot,At),Pe})))}function Oe(k){h=k?{kind:"node",id:k}:null,V(),ae()}function mt(k){h=k?{kind:"edge",id:k}:null,V(),ae()}function Kt(k){if(k==null)return Oe(null);const x=$o(i,k);if(x)return Oe(x);if(i.edges.some(A=>A.id===k))return mt(k)}function Tt(){p=f(),rt()}function Et(k,x={x:a.width/2,y:a.height/2}){const A=Rs(p.scale*(1+k)),N=A/p.scale;p={x:x.x-(x.x-p.x)*N,y:x.y-(x.y-p.y)*N,scale:A},rt()}function Sl(k){s=k,n.controls?.querySelectorAll("[data-layout]").forEach(x=>{x.classList.toggle("active",x.dataset.layout===k),x.setAttribute("aria-pressed",String(x.dataset.layout===k))}),n.onLayoutChange?.(k),c=mo(i,s,a.width,a.height),Tt()}function Il(k,x){Q.textContent=x,Q.hidden=!1;const A=e.getBoundingClientRect();Q.style.left=`${Math.min(A.width-330,Math.max(8,k.clientX-A.left+12))}px`,Q.style.top=`${Math.max(8,k.clientY-A.top+12)}px`}function xl(){Q.hidden=!0}function zl(k){return _S({x:k.clientX,y:k.clientY},$.getBoundingClientRect(),a.width,a.height)}const xy=bS($,{point:zl,transform:()=>p,select(k){k.type==="select-node"?Oe(k.id):k.type==="select-edge"?mt(k.id):Oe(bl(i)?.id??null)},drag(k,x,A){!m&&(m=dS(s,k,x),!m)||gS(c,m,x,A,p)&&rt()},endDrag(k){m=yS(m,k)},pan(k,x){p={x:k.transform.x+x.x-k.point.x,y:k.transform.y+x.y-k.point.y,scale:p.scale},rt()},startPinch(){m=null},pinch(k,[x,A]){const N=Math.hypot(A.x-x.x,A.y-x.y),J=Rs(k.scale*N/Math.max(1,k.distance));Et(J/p.scale-1,{x:(x.x+A.x)/2,y:(x.y+A.y)/2})}}),Tl=k=>{k.preventDefault(),Et(k.deltaY>0?-.12:.12,zl(k))},zy={ArrowLeft:[60,0],ArrowRight:[-60,0],ArrowUp:[0,60],ArrowDown:[0,-60]},El=k=>{if(k.target!==$)return;const x=zy[k.key];x?(k.preventDefault(),p={...p,x:p.x+x[0],y:p.y+x[1]},rt()):k.key==="+"||k.key==="="?Et(.18):k.key==="-"?Et(-.18):k.key==="0"&&Tt()};$.addEventListener("wheel",Tl,{passive:!1}),$.addEventListener("keydown",El);const ss=n.controls?.querySelector("[data-expand]")??null,Ct=n.panel&&ss?wS(n.panel,ss,o.body):null,Ty=()=>{Ct?.toggle(),n.onExpansionChange?.(Ct?.isOpen()??!1),requestAnimationFrame(Tt)},Cl=n.panel??e,Al=k=>{if(k.key==="Tab"&&Ct?.isOpen()&&n.panel){const x=Array.from(n.panel.querySelectorAll('button,a[href],[tabindex="0"],summary')).filter(J=>J.checkVisibility()),A=x[0],N=x.at(-1);k.shiftKey&&o.activeElement===A?(k.preventDefault(),N?.focus()):!k.shiftKey&&o.activeElement===N&&(k.preventDefault(),A?.focus())}if(k.key==="Escape"){if(Ct?.isOpen()){Ct.close(),n.onExpansionChange?.(!1),requestAnimationFrame(Tt);return}Oe(null)}};Cl.addEventListener("keydown",Al);const Nl=[],Pn=(k,x)=>{k&&(k.addEventListener("click",x),Nl.push([k,x]))};n.controls?.querySelectorAll("[data-layout]").forEach(k=>Pn(k,()=>Sl(k.dataset.layout==="tree"?"tree":"gravity"))),Pn(n.controls?.querySelector("[data-zoom='in']"),()=>Et(.18)),Pn(n.controls?.querySelector("[data-zoom='out']"),()=>Et(-.18)),Pn(n.controls?.querySelector("[data-zoom='fit']"),Tt),Ct&&Pn(ss,Ty);const Ol=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const k=e.clientWidth,x=e.clientHeight;!k||!x||k===a.width&&x===a.height||(a.width=k,a.height=x,$.setAttribute("viewBox",`0 0 ${k} ${x}`),Tt())});return Ol?.observe(e),zt(),n.selected&&Kt(n.selected),{update(k){const x=c;i=He(k);const A=mo(i,s,a.width,a.height);c=Object.fromEntries(i.nodes.map(N=>[N.id,x[N.id]??A[N.id]]).filter(([,N])=>N)),h&&!(h.kind==="node"?i.nodes.some(N=>N.id===h.id):i.edges.some(N=>N.id===h.id))&&(h=null),p=f(),zt()},merge(k,x){const A=A$(i,k,x);i=A.model;const N=$o(i,x??He(k).checked_address);return c=N?B$(i,c,N,A.added,{notes:u}):{...c,...mo(i,s,a.width,a.height),...c},A.added.length&&(p=f()),zt(),A.added},setTheme(k){k&&o.documentElement.setAttribute("data-theme",k);for(const x of i.nodes)xe.get(x.id)?.style.setProperty("--node-tone",nt(x))},select:Kt,destroy(){Ol?.disconnect(),xy(),$.removeEventListener("wheel",Tl),$.removeEventListener("keydown",El),Cl.removeEventListener("keydown",Al);for(const[k,x]of Nl)k.removeEventListener("click",x);Ct?.close({restoreFocus:!1}),$.remove(),Q.remove(),e.classList.remove("cia-graph-engine")},fit:Tt,zoom:k=>Et(k),setLayout:Sl,markNode(k,x){const A=$o(i,k);A&&(x?u.set(A,x):u.delete(A),zt())},positions:()=>structuredClone(c),model:()=>i,contentBounds:()=>d(),transform:()=>({...p})}}const cy="chain-insights.flows.v1",uy="chain-insights.result.v1",TS=60,Ld=6,ly=/^0x[0-9a-fA-F]{40}$/,ES=/^0x[0-9a-fA-F]{64}$/;function CS(e){return typeof e=="string"&&(ly.test(e)||ES.test(e))}function Dd(e){return typeof e=="string"&&ly.test(e)}function Fs(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function dy(e){const t=e?.facts?.query?.results;return Array.isArray(t)?t.filter(Fs):[]}function AS(e){const t=e?.facts;return typeof t?.subject?.network=="string"&&t.subject.network?t.subject.network:"robinhood"}function it(e){if(typeof e=="number")return Number.isFinite(e)?e:null;if(typeof e=="string"&&/^-?\d+(\.\d+)?([eE][-+]?\d+)?$/.test(e.trim())){const t=Number(e);return Number.isFinite(t)?t:null}return null}function kl(e){return e<1e11?e*1e3:e}const Us=/^\d{4}-\d{2}-\d{2}$/,NS=Date.UTC(2009,0,1),OS=Date.UTC(2100,0,1);function ms(e){return new Date(kl(e)).toISOString().slice(0,10)}function Zd(e){const t=Date.parse(`${e}T00:00:00Z`);return new Date(t-864e5).toISOString().slice(0,10)}function PS(e){return typeof e=="string"&&Us.test(e)&&Number.isFinite(Date.parse(`${e}T00:00:00Z`))}const MS=new Set(["day","date"]);function jd(e){return MS.has(e)||e.endsWith("_timestamp")}function RS(e){const t=[];for(const n of e)for(const r of Object.keys(n))t.includes(r)||t.push(r);return t}function fy(e){return e.length>0&&e.every(t=>Dd(t.from_address)&&Dd(t.to_address))}function Fd(e){if(typeof e=="string"){const r=e.trim();if(Us.test(r)||/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/.test(r)){const o=Date.parse(Us.test(r)?`${r}T00:00:00Z`:/(?:Z|[+-]\d{2}:?\d{2})$/.test(r)?r.replace(" ","T"):`${r.replace(" ","T")}Z`);return Number.isFinite(o)?o:null}}const t=it(e);if(t==null)return null;const n=kl(t);return n>=NS&&n<OS?n:null}function py(e){if(e.length===0||fy(e))return null;const t=RS(e),r=t.filter(jd).find(a=>e.some(c=>Fd(c[a])!=null));if(!r)return null;const o=t.filter(a=>{if(jd(a))return!1;const c=e.map(u=>u[a]).filter(u=>u!=null);return c.length>0&&c.every(u=>it(u)!=null)});if(o.length===0)return null;const i=e.map((a,c)=>({time:Fd(a[r]),row:a,index:c})).filter(a=>a.time!=null).sort((a,c)=>a.time-c.time||a.index-c.index),s=o.slice(0,Ld);return{xColumn:r,times:i.map(a=>a.time),daily:i.every(a=>a.time%864e5===0),series:s.map(a=>({column:a,values:i.map(c=>it(c.row[a]))})),omittedColumns:o.slice(Ld),skippedRows:e.length-i.length}}function LS(e){return fy(e)?"graph":py(e)?"chart":"table"}const DS=[["sanctioned","sanctioned"],["scam","scam"],["victim","victim"],["pool","pool"],["exchange","exchange"]];function Ud(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim()):[]}function ZS(e,t){if(t)return"exchange";const n=new Set(e.map(r=>r.replace(/\s+/g,"").toLowerCase()));for(const[r,o]of DS)if(n.has(r))return o;return"other"}const Vd=(e,t)=>e==null?t:t==null?e:e+t;function jS(e,t="robinhood"){const n=new Map;for(const d of e)for(const f of new Set([String(d.from_address).toLowerCase(),String(d.to_address).toLowerCase()]))n.set(f,(n.get(f)??0)+1);let r="",o=0;for(const[d,f]of n)f>o&&(r=d,o=f);const i=new Map,s=new Map,a=(d,f,p)=>{const h=i.get(d)??{address:d,labels:[],exchange:!1};for(const m of f)h.labels.some(y=>y.toLowerCase()===m.toLowerCase())||h.labels.push(m);h.exchange=h.exchange||p,i.set(d,h)};r&&i.set(r,{address:r,labels:[],exchange:!1});let c=0;for(const d of e){const f=String(d.from_address).toLowerCase(),p=String(d.to_address).toLowerCase(),h=[f,p].filter((S,T,O)=>!i.has(S)&&O.indexOf(S)===T).length;if(i.size+h>TS||(c++,a(f,Ud(d.from_labels),d.from_is_exchange===!0),a(p,Ud(d.to_labels),d.to_is_exchange===!0),f===p))continue;const m=`${f}->${p}`,y=s.get(m)??{from:f,to:p,usd:null,tx:null,first:null,last:null,kinds:[]};y.usd=Vd(y.usd,it(d.amount_usd_sum)),y.tx=Vd(y.tx,it(d.tx_count));const $=it(d.first_seen_timestamp),w=it(d.last_seen_timestamp);$!=null&&(y.first=y.first==null?$:Math.min(y.first,$)),w!=null&&(y.last=y.last==null?w:Math.max(y.last,w)),typeof d.link_kind=="string"&&d.link_kind&&!y.kinds.includes(d.link_kind)&&y.kinds.push(d.link_kind),s.set(m,y)}const u=[...i.values()].map(d=>({address:d.address,role:ZS(d.labels,d.exchange),labels:d.labels})),l=[...s.values()].map(d=>({from:d.from,to:d.to,usd:d.usd,tx_count:d.tx,first_seen_ms:d.first,last_seen_ms:d.last,...d.kinds.length?{link_kind:d.kinds.join(", ")}:{}}));return{view:{schema:cy,network:t,center:r,nodes:u,edges:l,truncated:!1},rowsTotal:e.length,rowsDrawn:c,rowsLeftOut:e.length-c,addresses:i.size}}function FS(e){const t=e?.facts?.queries;return Array.isArray(t)?t.filter(Fs).map((n,r)=>({id:typeof n.id=="string"&&n.id?n.id:`Query ${r+1}`,ok:n.ok!==!1&&n.error==null,error:typeof n.error=="string"&&n.error?n.error:null,rows:Array.isArray(n.results)?n.results.filter(Fs):[],count:typeof n.count=="number"?n.count:null,truncated:n.truncated===!0,elapsedMs:typeof n.elapsed_ms=="number"?n.elapsed_ms:null})):[]}const qd=200;function os(e){return(e?.content??[]).filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
109
+ `).trim()}const US=new Set(["usage_status","subscription_status","meta_usage_status","meta_subscription_status"]);function hy(e){if(!e||e.isError)return"text";const t=e.structuredContent;if(t?.schema===cy)return"flows";if(t?.schema===uy){if(t.tool==="graph_query")return LS(dy(t));if(t.tool==="graph_query_batch")return Array.isArray(t.facts?.queries)&&t.facts.queries.length>0?"batch":"text";if(typeof t.tool=="string"&&US.has(t.tool))return"balance"}return"text"}function z(e,t,n={},...r){const o=e.createElement(t);for(const[i,s]of Object.entries(n))s==null||s===!1||(i==="class"?o.className=String(s):i==="text"?o.textContent=String(s):o.setAttribute(i,s===!0?"":String(s)));for(const i of r)i==null||i===!1||o.append(typeof i=="string"?e.createTextNode(i):i);return o}function VS(e,t){const n=z(e,"code",{class:"cv-addr",title:t,"data-full":t,text:Re(t)}),r=z(e,"button",{type:"button",class:"cv-copy","data-copy":t,"aria-label":`Copy ${t}`,title:"Copy the full value",text:"Copy"});return r.addEventListener("click",()=>{qS(e,t,n,r)}),z(e,"span",{class:"cv-addr-cell"},n,r)}async function qS(e,t,n,r){const o=e.defaultView?.navigator?.clipboard;try{if(o?.writeText)return await o.writeText(t),r&&(r.textContent="Copied"),"copied"}catch{}return n.textContent=t,n.classList.add("is-full"),e.getSelection?.()?.selectAllChildren(n),r&&(r.textContent="Selected"),"selected"}function HS(e,t){return/(timestamp|seen|_at|_ms|time)$/i.test(t)&&e>1e9?wt(e):/usd/i.test(t)?new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e):new Intl.NumberFormat("en-US",{maximumFractionDigits:4}).format(e)}function BS(e){const t=e?.facts?.query,n=Array.isArray(t?.results)?t.results.filter(i=>!!i&&typeof i=="object"&&!Array.isArray(i)):[],r=n.slice(0,qd),o=[];for(const i of r)for(const s of Object.keys(i))o.includes(s)||o.push(s);return{columns:o,rows:r,total:n.length,truncated:n.length>qd||t?.truncated===!0,elapsedMs:typeof t?.elapsed_ms=="number"?t.elapsed_ms:null}}function KS(e,t,n){return t==null?z(e,"span",{class:"cv-null","aria-label":"empty",text:"—"}):CS(t)?VS(e,t):typeof t=="number"?e.createTextNode(HS(t,n)):typeof t=="boolean"?e.createTextNode(t?"yes":"no"):Array.isArray(t)?e.createTextNode(t.map(r=>typeof r=="string"?r:JSON.stringify(r)).join(", ")):typeof t=="object"?e.createTextNode(JSON.stringify(t)):e.createTextNode(String(t))}function Hd(e,t,n={}){const r=e.ownerDocument,o=BS(t.structuredContent),i=o.rows.length,s=o.total===0?"The query returned no rows.":`${new Intl.NumberFormat("en-US").format(i)} ${i===1?"row":"rows"}${o.elapsedMs==null?"":` in ${o.elapsedMs} ms`}`,a=z(r,"table",{class:"cv-table"},z(r,"thead",{},z(r,"tr",{},...o.columns.map(c=>z(r,"th",{scope:"col",text:c})))),z(r,"tbody",{},...o.rows.map(c=>z(r,"tr",{},...o.columns.map(u=>z(r,"td",{},KS(r,c[u],u)))))));return e.replaceChildren(z(r,"section",{class:"cv-card cv-table-view","data-view":"table","aria-label":"Graph query result"},z(r,"header",{class:"cv-card-head"},z(r,"strong",{text:"Graph query result"}),z(r,"span",{class:"cv-muted",text:s}),n.toggle??null),o.truncated?z(r,"p",{class:"cv-note",role:"note","data-truncated":"",text:`Truncated: showing the first ${new Intl.NumberFormat("en-US").format(i)} of ${new Intl.NumberFormat("en-US").format(o.total)} rows. Narrow the query to see the rest.`}):null,o.columns.length?z(r,"div",{class:"cv-table-wrap"},a):null)),o}const Rn=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e:t,go=e=>typeof e=="string"&&e?e:null;function JS(e){const t=e?.facts??{};if(typeof t.wallet=="string"&&t.wallet)return{kind:"wallet",wallet:t.wallet,tier:String(t.tier??"anonymous"),allowanceUsd:Rn(t.allowance_usd),consumedUsd:Rn(t.consumed_usd),windowEnd:go(t.window_end)};const n=t.usage;if(n&&typeof n=="object"){const r="daily_units_limit"in n||"daily_units_used"in n,o=go(n.access_mode);return{kind:"free",unit:r?"units":"seconds",used:Rn(r?n.daily_units_used:n.daily_seconds_used),limit:Rn(r?n.daily_units_limit:n.daily_seconds_limit),remaining:Rn(r?n.remaining_units:n.remaining_seconds),resetAt:go(n.reset_at),identifierKind:go(n.identifier_kind),accessMode:o,noLimit:!r&&o==="public_free"&&n.daily_seconds_limit===0}}return{kind:"unknown"}}const Bd=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e),yo=(e,t)=>`${new Intl.NumberFormat("en-US").format(e)} ${t==="units"?e===1?"unit":"units":e===1?"second":"seconds"}`;function gs(e){if(!e)return"No active window";const t=Date.parse(e);return Number.isFinite(t)?`${wt(t)} UTC`:e}function Kd(e,t,n,r){const o=n>0?Math.min(1,t/n):0,i=z(e,"div",{class:"cv-meter",role:"meter","aria-label":r,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":Math.min(t,n)},z(e,"span"));return i.firstElementChild.style.width=`${Math.round(o*100)}%`,i}function ys(e,t){return z(e,"dl",{class:"cv-facts"},...t.flatMap(([n,r])=>[z(e,"dt",{text:n}),z(e,"dd",{text:r})]))}function WS(e,t){const n=e.ownerDocument,r=JS(t.structuredContent);let o,i,s;return r.kind==="wallet"?(i="Wallet allowance",s=`${Re(r.wallet)} · ${r.tier==="subscriber"?"Subscriber":"No active subscription"}`,o=[Kd(n,r.consumedUsd,r.allowanceUsd,"Share of today's allowance used"),ys(n,[["Daily allowance",Bd(r.allowanceUsd)],["Used today",Bd(r.consumedUsd)],["Window ends",gs(r.windowEnd)]])]):r.kind==="free"?(i="Free tier",s=`No wallet · counted per ${r.identifierKind==="ip"||!r.identifierKind?"network address":r.identifierKind}`,o=r.noLimit?[z(n,"p",{class:"cv-balance-note","data-no-limit":"",text:"Free access, no daily limit"}),ys(n,[["Daily allowance","No daily limit"],["Used today",yo(r.used,r.unit)],["Window ends",gs(r.resetAt)]])]:[Kd(n,r.used,r.limit,"Share of today's free allowance used"),ys(n,[["Daily allowance",yo(r.limit,r.unit)],["Used today",yo(r.used,r.unit)],["Left today",yo(r.remaining,r.unit)],["Window ends",gs(r.resetAt)]])]):(i="Usage",s="The server sent no allowance figures.",o=[z(n,"p",{class:"cv-muted",text:os(t)||"Nothing to show."})]),e.replaceChildren(z(n,"section",{class:"cv-card cv-balance-view","data-view":"balance","data-balance":r.kind,"aria-label":i},z(n,"header",{class:"cv-card-head"},z(n,"strong",{text:i}),z(n,"span",{class:"cv-muted",text:s})),...o)),r}function is(e,t,n="No drawing for this answer."){const r=e.ownerDocument,o=os(t);e.replaceChildren(z(r,"section",{class:"cv-card cv-text-view","data-view":"text",role:t?.isError?"alert":null},z(r,"p",{text:t?.isError?"No drawing: the tool answered with an error.":n}),o?z(r,"p",{class:"cv-muted cv-text-body",text:o.length>600?`${o.slice(0,599)}…`:o}):null))}function my(e,t="Loading the Chain Insights view"){const n=e.ownerDocument;e.replaceChildren(z(n,"section",{class:"cv-card cv-skeleton","data-view":"loading","aria-busy":"true","aria-label":t},z(n,"span",{class:"cv-sr",text:t}),z(n,"div",{class:"cv-skel-line cv-skel-title"}),z(n,"div",{class:"cv-skel-line cv-skel-sub"}),z(n,"div",{class:"cv-skel-block"})))}const GS="http://www.w3.org/2000/svg",YS=720,QS=6,_o={left:66,right:18,top:6},Jd=18,XS=16,e0=26,t0=170,n0=82,r0=80;function gy(e,t){const n=new Date(e).toISOString();return t?n.slice(0,10):`${n.slice(0,10)} ${n.slice(11,16)}`}const o0=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:2}),yy=new Intl.NumberFormat("en-US",{maximumFractionDigits:6});function Wd(e){return Math.abs(e)<1e3?yy.format(Math.round(e*100)/100):o0.format(e)}function i0(e,t=YS){const n=_o.left,r=t-_o.right,o=r-n,i=e.times[0]??0,s=e.times[e.times.length-1]??i,a=s-i,c=p=>a>0?n+(p-i)/a*o:n+o/2,u=e.series.length===1?t0:n0,l=e.series.map((p,h)=>{const m=_o.top+h*(Jd+u+XS),y=m+Jd,$=y+u,w=p.values.filter(Q=>Q!=null),S=Math.min(0,...w),T=Math.max(...w,S+1e-9),O=Q=>$-(Q-S)/(T-S||1)*u,C=[],L=[];let ue=[];return p.values.forEach((Q,le)=>{if(Q==null){ue.length&&L.push(ue),ue=[];return}const xe={x:c(e.times[le]??i),y:O(Q),time:e.times[le]??i,value:Q};C.push(xe),ue.push(xe)}),ue.length&&L.push(ue),{column:p.column,color:`var(--cia-graph-series-${h%QS+1})`,top:m,plotTop:y,plotBottom:$,min:S,max:T,runs:L,points:C}}),d=(l[l.length-1]?.plotBottom??_o.top)+6,f=[];if(e.times.length){const p=a>0?[[i,"start"],[i+a/2,"middle"],[s,"end"]]:[[i,"middle"]];for(const[h,m]of p)f.push({x:c(h),label:gy(h,e.daily),anchor:m})}return{width:t,height:d+e0,plotLeft:n,plotRight:r,lanes:l,ticks:f,axisY:d}}function Me(e,t,n={}){const r=e.createElementNS(GS,t);for(const[o,i]of Object.entries(n))r.setAttribute(o,String(i));return r}const Ln=e=>Math.round(e*10)/10;function s0(e,t,n={}){const r=e.ownerDocument,o=i0(t),i=Me(r,"svg",{class:"cv-chart-svg",viewBox:`0 0 ${o.width} ${o.height}`,role:"img",preserveAspectRatio:"xMidYMid meet","aria-label":`Line chart of ${t.series.map(u=>u.column).join(", ")} by ${t.xColumn}, ${t.times.length} ${t.times.length===1?"point":"points"}`});for(const u of o.lanes){const l=Me(r,"g",{class:"cv-chart-lane","data-series":u.column}),d=Me(r,"rect",{class:"cv-chart-swatch",x:o.plotLeft,y:u.top+4,width:14,height:4,rx:2});d.style.fill=u.color;const f=Me(r,"text",{class:"cv-chart-name",x:o.plotLeft+20,y:u.top+11});f.textContent=u.column,l.append(d,f,Me(r,"line",{class:"cv-chart-grid",x1:o.plotLeft,x2:o.plotRight,y1:u.plotTop,y2:u.plotTop}),Me(r,"line",{class:"cv-chart-base",x1:o.plotLeft,x2:o.plotRight,y1:u.plotBottom,y2:u.plotBottom}));const p=Me(r,"text",{class:"cv-chart-tick",x:o.plotLeft-8,y:u.plotTop+4,"text-anchor":"end"});p.textContent=Wd(u.max);const h=Me(r,"text",{class:"cv-chart-tick",x:o.plotLeft-8,y:u.plotBottom+4,"text-anchor":"end"});h.textContent=Wd(u.min),l.append(p,h);for(const m of u.runs){if(m.length<2)continue;const y=Me(r,"polyline",{class:"cv-chart-line",points:m.map($=>`${Ln($.x)},${Ln($.y)}`).join(" "),fill:"none"});y.style.stroke=u.color,l.append(y)}if(u.points.length<=r0)for(const m of u.points){const y=Me(r,"circle",{class:"cv-chart-dot",cx:Ln(m.x),cy:Ln(m.y),r:3});y.style.fill=u.color;const $=Me(r,"title");$.textContent=`${gy(m.time,t.daily)} · ${u.column} ${yy.format(m.value)}`,y.append($),l.append(y)}i.append(l)}const s=Me(r,"g",{class:"cv-chart-axis"});for(const u of o.ticks){const l=Me(r,"text",{class:"cv-chart-tick",x:Ln(u.x),y:o.axisY+14,"text-anchor":u.anchor});l.textContent=u.label,s.append(l)}i.append(s);const a=[t.omittedColumns.length?`${t.omittedColumns.length} more number ${t.omittedColumns.length===1?"column is":"columns are"} only in the table: ${t.omittedColumns.join(", ")}.`:"",t.skippedRows?`${t.skippedRows} ${t.skippedRows===1?"row has":"rows have"} no usable ${t.xColumn} and ${t.skippedRows===1?"is":"are"} only in the table.`:""].filter(Boolean),c=z(r,"section",{class:"cv-chart cia-graph-surface","data-view":"chart","aria-label":`Chart by ${t.xColumn}`},z(r,"header",{class:"cv-flows-head"},z(r,"div",{class:"cv-title"},z(r,"strong",{text:"Chart"}),z(r,"span",{class:"cv-muted",text:`${t.times.length} ${t.times.length===1?"point":"points"} by ${t.xColumn} (UTC) · ${t.series.length} ${t.series.length===1?"line":"lines"}`})),n.toggle??null),a.length?z(r,"p",{class:"cv-note",role:"note","data-chart-note":"",text:a.join(" ")}):null,z(r,"div",{class:"cv-chart-body"},i));return e.replaceChildren(c),{root:c,layout:o}}const a0="chain-insights.transfers.v1",c0="graph_expand",u0="2015-01-01";function l0(e,t,n,r){return{network:e,from:t,to:n,day:r}}function d0(e,t){const n=typeof e.first_seen_timestamp=="number"&&e.first_seen_timestamp>0?ms(e.first_seen_timestamp):null,r=typeof e.last_seen_timestamp=="number"&&e.last_seen_timestamp>0?ms(e.last_seen_timestamp):ms(t);return{first:n,last:n&&r<n?n:r}}function bo(e,t){return e<=(t??u0)}function f0(e){if(!e)return"no answer";const t=os(e);return e.isError?t||"the server refused the read":/query_timeout|topology_busy/.test(t)?t:_y(e.structuredContent)?null:t||"the answer held no transfers"}function _y(e){const t=e;if(!t||t.schema!==a0||!Array.isArray(t.transfers)||typeof t.from!="string"||typeof t.to!="string"||!PS(t.day))return null;const n=[];for(const r of t.transfers){if(!r||typeof r!="object")continue;const o=r;if(typeof o.tx_id!="string")continue;const i=it(o.block_timestamp);n.push({tx_id:o.tx_id,block_timestamp:i,amount:typeof o.amount=="string"?o.amount:typeof o.amount=="number"?String(o.amount):null,asset_symbol:typeof o.asset_symbol=="string"&&o.asset_symbol?o.asset_symbol:null,amount_usd:it(o.amount_usd)})}return{network:typeof t.network=="string"?t.network:null,from:t.from,to:t.to,day:t.day,transfers:n,truncated:t.truncated===!0}}function p0(e){return[...e].sort((t,n)=>(n.block_timestamp??0)-(t.block_timestamp??0)||t.tx_id.localeCompare(n.tx_id))}function h0(e){if(e==null)return"—";const t=e.trim().match(/^(-?)(\d+)(?:\.(\d+))?$/);if(!t)return e;const[,n="",r="0",o=""]=t,i=o.replace(/0+$/,"");return`${n}${r.replace(/\B(?=(\d{3})+(?!\d))/g,",")}${i?`.${i}`:""}`}function m0(e){return e==null?"—":new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:e!==0&&Math.abs(e)<.01?6:2}).format(e)}function g0(e){return e==null?"—":`${new Date(kl(e)).toISOString().slice(11,19)} UTC`}function _s(e){return new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeZone:"UTC"}).format(new Date(`${e}T00:00:00Z`))}function y0(e,t){const n=t.now??Date.now,r=z(e,"strong",{"data-link-title":"",text:"Transfers"}),o=z(e,"button",{type:"button",class:"cv-button cv-icon","data-link-close":"","aria-label":"Close the transfers",text:"×"}),i=z(e,"p",{class:"cv-link-pair","data-link-pair":""}),s=z(e,"p",{class:"cv-link-day","data-link-day":""}),a=z(e,"div",{class:"cv-link-body","data-link-body":"",role:"status","aria-live":"polite"}),c=z(e,"button",{type:"button",class:"cv-button","data-link-earlier":"",text:"Earlier day"}),u=z(e,"aside",{class:"cv-linkpanel","data-link-panel":"","aria-label":"Transfers of the selected link",hidden:!0},z(e,"header",{class:"cv-link-head"},r,o),i,s,a,c);let l=null,d=0;function f(){if(!l){u.hidden=!0;return}u.hidden=!1,i.replaceChildren(z(e,"code",{title:l.from,text:Re(l.from)})," → ",z(e,"code",{title:l.to,text:Re(l.to)})),s.textContent=`${_s(l.day)} (UTC)`,c.disabled=l.status==="loading"||bo(l.day,l.firstDay);const $=bo(l.day,l.firstDay)?null:Zd(l.day);c.setAttribute("aria-label",$?`Earlier day: show the transfers of ${_s($)}`:"Earlier day: this is the first day the link was seen"),l.status==="loading"?a.replaceChildren(z(e,"p",{class:"cv-muted",text:`Loading the transfers of ${_s(l.day)}…`})):l.status==="error"?a.replaceChildren(z(e,"p",{class:"cv-link-error","data-link-error":"",role:"alert",text:l.error??"The transfers could not be read."})):l.transfers.length===0?a.replaceChildren(z(e,"p",{class:"cv-muted","data-link-empty":"",text:"No transfers between these two addresses on this day."})):(a.replaceChildren(z(e,"ol",{class:"cv-transfers"},...l.transfers.map(w=>_0(e,w,t.host)))),l.truncated&&a.append(z(e,"p",{class:"cv-muted","data-link-truncated":"",text:`${l.transfers.length} transfers shown. This day holds more.`}))),l.status!=="loading"&&bo(l.day,l.firstDay)&&l.firstDay&&a.append(z(e,"p",{class:"cv-muted","data-link-first":"",text:"This is the first day the link was seen."}))}async function p($){const w=++d,S=l;S.day=$,S.status="loading",S.error=null,f(),t.onLayout?.();let T=null;try{T=await t.host.callServerTool({name:c0,arguments:l0(t.network,S.from,S.to,$)})}catch(C){T={isError:!0,content:[{type:"text",text:C instanceof Error?C.message:String(C)}]}}if(w!==d||l!==S)return S;const O=f0(T);if(O)S.status="error",S.transfers=[],S.error=O.length>300?`${O.slice(0,299)}…`:O;else{const C=_y(T.structuredContent);S.status="ready",S.transfers=p0(C.transfers),S.truncated=C.truncated}return f(),t.onLayout?.(),S}const h=()=>y.close(),m=()=>{y.earlier()};o.addEventListener("click",h),c.addEventListener("click",m);const y={element:u,open($){const w=d0($,n());return l={from:$.from,to:$.to,day:w.last,firstDay:w.first,status:"loading",transfers:[],truncated:!1,error:null},p(w.last)},async earlier(){return!l||l.status==="loading"||bo(l.day,l.firstDay)?null:p(Zd(l.day))},close(){d++,l=null,f(),t.onLayout?.()},state:()=>l?{...l,transfers:[...l.transfers]}:null,destroy(){d++,o.removeEventListener("click",h),c.removeEventListener("click",m)}};return y}function _0(e,t,n){const r=ay(t.tx_id),o=n.openLink,i=r&&o?z(e,"button",{type:"button",class:"cia-graph-explorer-link","data-explorer":r,"aria-label":`Transaction ${t.tx_id} (opens the explorer)`,title:t.tx_id,text:Re(t.tx_id)}):z(e,"code",{title:t.tx_id,text:Re(t.tx_id)});return r&&o&&i.addEventListener("click",()=>{o.call(n,{url:r}).catch(()=>{})}),z(e,"li",{class:"cv-transfer","data-tx":t.tx_id},z(e,"span",{class:"cv-transfer-time",text:g0(t.block_timestamp)}),z(e,"span",{class:"cv-transfer-amount",text:`${h0(t.amount)}${t.asset_symbol?` ${t.asset_symbol}`:""}`}),z(e,"span",{class:"cv-transfer-usd",text:t.amount_usd==null?"— USD":m0(t.amount_usd)}),i)}const b0="graph_expand",wo="too busy to expand",by=480,w0=300,bs=.45,v0="Full screen shows the whole graph",k0=[["scam","Scam"],["sanctioned","Sanctioned"],["exchange","Exchange"],["victim","Victim"],["pool","Pool"],["other","Other"]];function $0(e,t,n){return{network:e,address:t,in_offset:n?.in_offset??0,out_offset:n?.out_offset??0}}function S0(e){const t=os(e);return e?e.isError?t||"the server refused the expansion":/query_timeout|topology_busy/.test(t)?t:yl(e.structuredContent)?null:t||"the answer held no money flows":"no answer"}function I0(e,t,n,r=by,o=w0){if(!e||t<=0)return{height:r,fits:!0};const i=Math.max(1,e.x2-e.x1),s=Math.max(1,e.y2-e.y1),a=Math.max(bs,Math.min(1,(t-Wn*2)/i)),c=Math.ceil(n+s*a+Wn*2),u=Math.min(r,Math.max(o,c));return Ed(e,t,u-n)>=bs?{height:u,fits:!0}:{height:r,fits:Ed(e,t,r-n)>=bs}}function x0(e,t){return`investigator expanded ${e}: ${t} new addresses`}function z0(e,t){const n=e.nodes.find(r=>r.address.toLowerCase()===t.toLowerCase());return n&&rs({role:n.role??null,labels:n.labels??[]})||"Other"}function wy(e,t,n){const r=e.ownerDocument,o=t.network??"robinhood",i=t.center.toLowerCase(),s=new Map(t.cursor?[[i,{cursor:t.cursor,truncated:!!t.truncated}]]:[]),a=new Set,c=new Set;let u=!1,l=!1;const d=n.title??"Money flows",f=z(r,"p",{class:"cv-status",role:"status","aria-live":"polite",text:"Select an address to load its senders and receivers, or a link to list its transfers."}),p=z(r,"ul",{class:"cv-roles","aria-label":"Address roles"}),h=z(r,"div",{class:"cv-canvas","data-graph":""}),m=z(r,"aside",{class:"cv-detail","aria-label":"Selection",hidden:!0},z(r,"strong",{"data-selection-title":""}),z(r,"code",{"data-selection-identity":""}),z(r,"div",{class:"cv-detail-meta","data-selection-meta":""})),y=z(r,"button",{type:"button",class:"cv-button","data-fullscreen":"",hidden:!0,"aria-label":"Open full screen",text:"Full screen"}),$=z(r,"span",{class:"cv-hint","data-fullscreen-hint":"",hidden:!0,text:v0}),w=z(r,"div",{class:"cv-actions"},z(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"out","aria-label":"Zoom out",text:"−"}),z(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"in","aria-label":"Zoom in",text:"+"}),z(r,"button",{type:"button",class:"cv-button","data-zoom":"fit","aria-label":"Fit the graph",text:"Fit"}),$,y),S=z(r,"span",{class:"cv-muted"}),T=y0(r,{host:n.host,network:o,now:n.now,onLayout:()=>nt()}),O=z(r,"section",{class:"cv-flows cia-graph-surface","data-view":"flows","aria-label":`${d} of ${i}`},z(r,"header",{class:"cv-flows-head"},z(r,"div",{class:"cv-title"},z(r,"strong",{text:d}),S),n.toggle??null,w),p,n.note?z(r,"p",{class:"cv-note",role:"note","data-left-out":"",text:n.note}):null,z(r,"div",{class:"cv-body"},h,T.element),m,f);e.replaceChildren(O);function C(){const K=$e.model(),V=K.truncated?" · more flows than shown":"";S.textContent=`${Re(i)} · ${z0(t,i)} · ${o} · ${K.nodes.length} addresses${V}`;const _e=new Set(K.nodes.map(ae=>ae.role??"other"));p.replaceChildren(...k0.filter(([ae])=>_e.has(ae)).map(([ae,Bt])=>{const Oe=z(r,"i",{"aria-hidden":"true"});return Oe.style.background=`var(--cia-graph-role-${ae})`,z(r,"li",{"data-role":ae},Oe,Bt)}))}const L=K=>{const V=K.target;u=!!V?.closest?.("[data-node-id]"),l=!u&&!!V?.closest?.("[data-edge-id]")},ue=K=>{const V=K.target,_e=K.key==="Enter"||K.key===" ";u=_e&&!!V?.closest?.("[data-node-id]"),l=_e&&!u&&!!V?.closest?.("[data-edge-id]")},Q=()=>{u=!1,l=!1};h.addEventListener("pointerdown",L,!0),h.addEventListener("keydown",ue,!0),h.addEventListener("pointerup",Q),h.addEventListener("pointercancel",Q);function le(K){const V=m.hidden;m.hidden=K.kind==null,V!==m.hidden&&nt();const _e=u&&K.kind==="node"&&K.node,ae=l&&K.kind==="edge"&&K.edge;u=!1,l=!1,_e&&zt(K.node.address),ae&&T.open(K.edge)}const xe=n.height??by,$e=zS(h,t,{layout:"tree",width:n.width??720,height:xe,now:n.now,controls:w,selectionRoot:m,onSelect:le,openLink:K=>{n.host.openLink?.({url:K}).catch(()=>{f.textContent="The host did not open the link."})},label:`${d} of ${i}: senders on the left, receivers on the right. Select an address to load its next page, or a link to list its transfers.`});C();let We=n.displayMode??"inline",Nn=n.availableDisplayModes??[];function nt(){if(We==="fullscreen"){O.style.removeProperty("height"),$.hidden=!0;return}const K=h.clientWidth||n.width||720,V=Math.max(0,O.offsetHeight-h.offsetHeight)||140,{height:_e,fits:ae}=I0($e.contentBounds(),K,V);O.style.height=`${_e}px`,$.hidden=ae||!Nn.includes("fullscreen"),O.dataset.fits=String(ae),$e.fit()}async function zt(K){const V=K.toLowerCase();if(a.has(V))return f.textContent=`${Re(V)} is ${wo}.`,{added:[],refused:wo};if(c.has(V))return{added:[],refused:null};const _e=s.get(V);if(_e&&!_e.truncated)return f.textContent=`Every recent flow of ${Re(V)} is drawn.`,{added:[],refused:null};c.add(V),f.textContent=`Loading the flows of ${Re(V)}…`;let ae=null;try{ae=await n.host.callServerTool({name:b0,arguments:$0(o,V,_e?.cursor)})}catch(Kt){ae={isError:!0,content:[{type:"text",text:Kt instanceof Error?Kt.message:String(Kt)}]}}finally{c.delete(V)}const Bt=S0(ae);if(Bt)return a.add(V),$e.markNode(V,wo),f.textContent=`${Re(V)} is ${wo}. The drawing is kept.`,{added:[],refused:Bt};const Oe=ae.structuredContent,mt=$e.merge(Oe,V);s.set(V,{cursor:Oe.cursor??null,truncated:!!Oe.truncated}),C(),nt(),f.textContent=`${mt.length} new ${mt.length===1?"address":"addresses"} linked to ${Re(V)}.`;try{await n.host.updateModelContext?.({content:[{type:"text",text:x0(V,mt.length)}]})}catch{}return{added:mt,refused:null}}function On(K,V){K&&(We=K),V&&(Nn=V),O.dataset.displayMode=We,y.hidden=!Nn.includes("fullscreen"),y.textContent=We==="fullscreen"?"Exit full screen":"Full screen",y.setAttribute("aria-label",We==="fullscreen"?"Back to the inline view":"Open full screen"),nt()}On(We);const rt=async()=>{const K=We==="fullscreen"?"inline":"fullscreen";try{const V=await n.host.requestDisplayMode?.({mode:K});On(V?.mode??K)}catch{f.textContent="The host did not change the display mode."}};return y.addEventListener("click",rt),{root:O,graph:$e,expand:zt,linkPanel:T,openLink(K,V){const _e=$e.model().edges.find(ae=>ae.from===K.toLowerCase()&&ae.to===V.toLowerCase());return _e?T.open(_e):Promise.resolve(null)},setTheme(K){$e.setTheme(K)},setDisplayMode:On,refit:nt,destroy(){h.removeEventListener("pointerdown",L,!0),h.removeEventListener("keydown",ue,!0),h.removeEventListener("pointerup",Q),h.removeEventListener("pointercancel",Q),y.removeEventListener("click",rt),T.destroy(),$e.destroy()}}}function Vs(e){return{kind:e,flows:()=>[],setTheme(){},setDisplayMode(){},refit(){},destroy(){}}}function T0(e,t){return{kind:e,flows:()=>{const n=t();return n?[n]:[]},setTheme(n){t()?.setTheme(n)},setDisplayMode(n,r){t()?.setDisplayMode(n,r)},refit(){t()?.refit()},destroy(){t()?.destroy()}}}const vy=e=>({host:e.host,availableDisplayModes:e.availableDisplayModes,displayMode:e.displayMode,now:e.now,width:e.width,height:e.height});function E0(e,t){if(e<=0)return null;const n=new Intl.NumberFormat("en-US");return`${n.format(e)} of ${n.format(t)} rows ${e===1?"is":"are"} not drawn: a graph holds at most 60 addresses. The table has the rows.`}function C0(e,t,n){const r=[];let o="picture";const i=s=>{for(const a of s.querySelectorAll("[data-show]"))a.setAttribute("aria-pressed",String(a.dataset.show===o))};return{make(){const s=z(e,"button",{type:"button",class:"cv-toggle-button","data-show":"picture",text:t}),a=z(e,"button",{type:"button",class:"cv-toggle-button","data-show":"table",text:"Table"});s.addEventListener("click",()=>n("picture")),a.addEventListener("click",()=>n("table"));const c=z(e,"div",{class:"cv-toggle",role:"group","aria-label":"Show the rows as"},s,a);return r.push(c),i(c),c},set(s){o=s,r.forEach(i)}}}function ky(e,t,n){const r=e.ownerDocument,o=hy(t);if(o!=="graph"&&o!=="chart")return o==="table"?Hd(e,t):is(e,t),Vs(o==="table"?"table":"text");const i=t.structuredContent,s=dy(i),a=z(r,"div",{class:"cv-face","data-face":"picture"}),c=z(r,"div",{class:"cv-face","data-face":"table",hidden:!0});e.replaceChildren(a,c);const u=C0(r,o==="graph"?"Graph":"Chart",p=>f(p));let l=null,d=!1;if(o==="graph"){const p=jS(s,AS(i));l=wy(a,p.view,{...vy(n),title:"Graph",toggle:u.make(),note:E0(p.rowsLeftOut,p.rowsTotal)})}else s0(a,py(s),{toggle:u.make()});function f(p){a.hidden=p!=="picture",c.hidden=p!=="table",p==="table"&&!d&&(d=!0,Hd(c,t,{toggle:u.make()})),u.set(p),p==="picture"&&l?.refit()}return{kind:o,flows:()=>l?[l]:[],setTheme(p){l?.setTheme(p)},setDisplayMode(p,h){l?.setDisplayMode(p,h)},refit(){a.hidden||l?.refit()},destroy(){l?.destroy()}}}function A0(e,t){if(!e.ok)return{isError:!0,content:[{type:"text",text:e.error??"The query failed."}]};const n=t?.facts?.subject;return{content:[],structuredContent:{schema:uy,tool:"graph_query",facts:{...n?{subject:n}:{},query:{results:e.rows,count:e.count??e.rows.length,truncated:e.truncated,elapsed_ms:e.elapsedMs}}}}}function N0(e,t,n){const r=e.ownerDocument,o=FS(t.structuredContent),i=o.map((h,m)=>z(r,"button",{type:"button",role:"tab",class:"cv-tab",id:`cv-tab-${m}`,"data-tab":h.id,"aria-controls":`cv-panel-${m}`,"aria-selected":"false",tabindex:-1,text:h.ok?h.id:`${h.id} (failed)`})),s=o.map((h,m)=>z(r,"div",{class:"cv-tabpanel",role:"tabpanel",id:`cv-panel-${m}`,"aria-labelledby":`cv-tab-${m}`,hidden:!0})),a=z(r,"div",{class:"cv-tabs",role:"tablist","aria-label":"Queries of the batch"},...i);e.replaceChildren(a,...s);const c=o.map(()=>null);let u=n.displayMode,l=n.availableDisplayModes,d=-1;const f=()=>e.style.setProperty("--cv-tabs-h",`${a.offsetHeight}px`);function p(h){const m=o[h],y=s[h];if(!m||!y)return;d=h,i.forEach((w,S)=>{w.setAttribute("aria-selected",String(S===h)),w.tabIndex=S===h?0:-1}),s.forEach((w,S)=>{w.hidden=S!==h});const $=c[h];if($)$.refit();else{const w=ky(y,A0(m,t.structuredContent),{...n,displayMode:u,availableDisplayModes:l});c[h]=w,y.dataset.view=w.kind}f()}return i.forEach((h,m)=>{h.addEventListener("click",()=>p(m)),h.addEventListener("keydown",y=>{const $=i.length-1,w=y.key==="ArrowRight"?m===$?0:m+1:y.key==="ArrowLeft"?m===0?$:m-1:y.key==="Home"?0:y.key==="End"?$:null;w!=null&&(y.preventDefault(),p(w),i[w]?.focus())})}),p(0),{kind:"batch",flows:()=>c.flatMap(h=>h?.flows()??[]),setTheme(h){for(const m of c)m?.setTheme(h)},setDisplayMode(h,m){h&&(u=h),m&&(l=m);for(const y of c)y?.setDisplayMode(h,m);f()},refit(){d>=0&&c[d]?.refit()},destroy(){for(const h of c)h?.destroy()}}}function O0(e,t,n){const r=hy(t);if(r==="flows"){const o=wy(e,t.structuredContent,vy(n));return T0("flows",()=>o)}return r==="graph"||r==="chart"||r==="table"?ky(e,t,n):r==="batch"?N0(e,t,n):r==="balance"?(WS(e,t),Vs("balance")):(is(e,t),Vs("text"))}function P0(e){return e==="light"||e==="dark"}function M0(e,t=()=>!1){return P0(e?.theme)?e.theme:t()?"dark":"light"}function $l(e,t){const n={...e??{},...t??{}};return(e?.styles||t?.styles)&&(n.styles={...e?.styles??{},...t?.styles??{},variables:{...e?.styles?.variables??{},...t?.styles?.variables??{}}}),n}function $y(e,t,n={}){const r=e.documentElement,o=M0(t,n.prefersDark);r.setAttribute("data-theme",o),r.style.colorScheme=o;const i=t?.styles?.variables;i&&n.applyVariables&&n.applyVariables(i,r);const s=t?.styles?.css?.fonts;return s&&n.applyFonts&&n.applyFonts(s),o}const io=document.getElementById("view"),Sy=()=>typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches;let $t={},vo=$y(document,$t,{prefersDark:Sy}),Ye=null;my(io);const et=new ml({name:"chain-insights-view",version:"1.0.0"},{});function Iy(e){const t=vo;vo=$y(document,e,{prefersDark:Sy,applyVariables:(n,r)=>m$(n,r),applyFonts:g$}),Ye&&vo!==t&&Ye.setTheme(vo),Ye?.setDisplayMode(e.displayMode,e.availableDisplayModes)}function R0(e){Ye?.destroy(),Ye=null;const t=$l(et.getHostContext(),$t);Ye=O0(io,e,{host:et,availableDisplayModes:t.availableDisplayModes,displayMode:t.displayMode}),document.documentElement.dataset.view=Ye.kind}et.ontoolinput=e=>{const t=typeof e.arguments?.address=="string"?e.arguments.address:null;Ye||my(io,t?`Loading the graph of ${t}`:"Loading the Chain Insights view")};et.ontoolresult=e=>{R0(e)};et.ontoolcancelled=()=>{Ye||is(io,null,"The tool call was cancelled. Nothing to draw.")};et.onhostcontextchanged=e=>{$t=$l($t,e),Iy($t)};et.onteardown=async()=>(Ye?.destroy(),Ye=null,{});et.onerror=e=>{console.warn("chain-insights-view:",e)};et.connect(new Xg(window.parent,window.parent)).then(()=>{$t=$l($t,et.getHostContext()),Iy($t)},e=>{console.warn("chain-insights-view: no host answered",e),is(io,null,"This view opens inside Claude, next to a Chain Insights tool answer.")});
110
110
  </script>
111
- <style>.cia-graph-surface{--cia-graph-surface:linear-gradient(140deg,#171a20,#0d0f13);--cia-graph-canvas:#101318;--cia-graph-dot:#f2dda621;--cia-graph-text:#e2e8f0;--cia-graph-muted:#adb1ba;--cia-graph-border:#f2dda640;--cia-graph-divider:#ffffff10;--cia-graph-control:#14161a;--cia-graph-hover:#f2dda626;--cia-graph-active:#f2dda6;--cia-graph-active-text:#0b0e13;--cia-graph-node:#14161a;--cia-graph-edge:#f2dda6;--cia-graph-halo:#07090d;--cia-graph-selected:#ffffff;--cia-graph-danger:#d89087;--cia-graph-target:#8bb6b0;--cia-graph-trail:#b49bc4;--cia-graph-infrastructure:#94b58b;--cia-graph-neutral:#f2dda6;--cia-graph-critical:#d89087;--cia-graph-high:#d6a07d;--cia-graph-medium:#b49bc4;--cia-graph-low:#94b58b;--cia-graph-role-exchange:var(--cia-graph-infrastructure);--cia-graph-role-scam:var(--cia-graph-danger);--cia-graph-role-sanctioned:var(--cia-graph-danger);--cia-graph-role-victim:var(--cia-graph-target);--cia-graph-role-pool:var(--cia-graph-trail);--cia-graph-role-other:var(--cia-graph-neutral);color:var(--cia-graph-text);background:var(--cia-graph-surface);border:1px solid var(--cia-graph-border);border-radius:14px;overflow:hidden}html[data-theme=light] .cia-graph-surface{--cia-graph-surface:#f9f9f9;--cia-graph-canvas:#fff;--cia-graph-dot:#dedede;--cia-graph-text:#242424;--cia-graph-muted:#686868;--cia-graph-border:#dedede;--cia-graph-divider:#e6e6e6;--cia-graph-control:#fff;--cia-graph-hover:#ececec;--cia-graph-active:#4e708a;--cia-graph-active-text:#fff;--cia-graph-node:#fff;--cia-graph-edge:#4e708a;--cia-graph-halo:#fff;--cia-graph-selected:#242424;--cia-graph-danger:#a64d4b;--cia-graph-target:#356e68;--cia-graph-trail:#78538f;--cia-graph-infrastructure:#416c4a;--cia-graph-neutral:#4e708a;--cia-graph-critical:#a64d4b;--cia-graph-high:#a15432;--cia-graph-medium:#78538f;--cia-graph-low:#416c4a}.cia-graph-canvas{background:radial-gradient(circle,var(--cia-graph-dot) 1px,transparent 1px) 0 0/24px 24px,var(--cia-graph-canvas)}.graph-detail{border-top:1px solid var(--cia-graph-divider,#ffffff10);padding:1rem 1.5rem;font-size:.85rem;color:var(--cia-graph-muted,#adb1ba);line-height:1.6}.graph-detail strong{color:var(--cia-graph-text,#f2dda6)}.graph-detail p{margin:0}.graph-detail ul{padding-left:1.25rem;margin-bottom:0}.graph-detail strong,.graph-detail li{overflow-wrap:anywhere}.graph-legend{border-top:1px solid var(--cia-graph-divider,#ffffff10);padding:1rem 1.5rem;font-size:.85rem}.graph-legend summary{cursor:pointer}.graph-legend ul{list-style:none;padding:0}.graph-legend li{display:flex;flex-wrap:wrap;gap:.4rem 1rem;padding:.6rem 0;border-bottom:1px solid var(--cia-graph-divider,#ffffff0a)}.graph-legend button{color:var(--cia-graph-edge,#f2dda6);background:none;border:0;padding:0;text-align:left;cursor:pointer;font:inherit;font-family:ui-monospace,monospace;overflow-wrap:anywhere;max-width:100%}.graph-legend span{color:var(--cia-graph-muted,#adb1ba)}.graph-detail a,.graph-legend a{color:var(--cia-graph-edge,#f2dda6);text-decoration:none;border-bottom:1px solid var(--cia-graph-border,#f2dda659)}.graph-detail a:hover,.graph-legend a:hover{border-bottom-color:var(--cia-graph-edge,#f2dda6)}.graph-legend .graph-legend-link{overflow-wrap:normal;flex:none}.cia-graph-node-body{fill:var(--cia-graph-node,#14161a)}.cia-graph-node-ring{stroke:var(--cia-graph-edge,#f2dda6)}.cia-graph-node-address{fill:var(--cia-graph-muted,#adb1ba)}.cia-graph-edge-underlay{stroke:var(--cia-graph-halo,#07090d)}.cia-graph-edge-direction{stroke:var(--cia-graph-edge,#f2dda6)}.cia-graph-edge-arrow{fill:var(--cia-graph-edge,#f2dda6);stroke:var(--cia-graph-halo,#07090d)}.cia-graph-surface .graph-tooltip{background:var(--cia-graph-control);color:var(--cia-graph-text);border-color:var(--cia-graph-border)}.cia-graph-engine{position:relative;min-height:240px}.cia-graph-svg{display:block;width:100%;height:100%;touch-action:none;font-family:Inter,system-ui,sans-serif;outline:none}.cia-graph-svg:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:-2px}.cia-graph-backdrop{fill:var(--cia-graph-canvas)}.cia-graph-dot{fill:var(--cia-graph-dot)}.cia-graph-edge{cursor:pointer;outline:none;transition:opacity .15s}.cia-graph-edge-hit{fill:none;stroke:transparent}.cia-graph-edge-line{fill:none;stroke:var(--edge-tone,var(--cia-graph-edge));stroke-linecap:round}.cia-graph-edge:focus-visible .cia-graph-edge-line,.cia-graph-edge[aria-pressed=true] .cia-graph-edge-line{stroke-width:3}.cia-graph-node{cursor:pointer;outline:none}.cia-graph-engine .cia-graph-node-body{fill:var(--cia-graph-node);stroke:var(--node-tone,var(--cia-graph-neutral));stroke-width:2}.cia-graph-engine .cia-graph-node-ring{fill:none;stroke:var(--cia-graph-edge);stroke-width:2}.cia-graph-node-dot{fill:var(--node-tone,var(--cia-graph-neutral))}.cia-graph-node.is-selected .cia-graph-node-body,.cia-graph-node:focus-visible .cia-graph-node-body{stroke:var(--cia-graph-selected);stroke-width:4}.cia-graph-node text{paint-order:stroke;stroke:var(--cia-graph-halo);stroke-width:4px;stroke-linejoin:round}.cia-graph-node-role{fill:var(--node-tone,var(--cia-graph-neutral));font-size:13px;font-weight:600}.cia-graph-engine .cia-graph-node-address{fill:var(--cia-graph-muted);font:400 11px ui-monospace,monospace}.cia-graph-node-note{fill:var(--cia-graph-text);font-size:11px;font-style:italic}.cia-graph-node[data-state=refused] .cia-graph-node-body{stroke-dasharray:4 3}.cia-graph-engine>.graph-tooltip{position:absolute;z-index:2;max-width:320px;padding:.5rem .65rem;border:1px solid;border-radius:6px;font:12px/1.45 Inter,system-ui,sans-serif;overflow-wrap:anywhere;pointer-events:none}:root{color-scheme:light dark}html,body{margin:0;padding:0;background:transparent}html[data-theme=dark]{color-scheme:dark;--cv-text:var(--color-text-primary,#ececec);--cv-muted:var(--color-text-secondary,#b4b4b4);--cv-surface:var(--color-background-secondary,#262624);--cv-raised:var(--color-background-tertiary,#30302e);--cv-border:var(--color-border-primary,#4a4a46);--cv-ring:var(--color-ring-primary,#8fb5ff);--cv-skeleton:#3a3a37}html[data-theme=light]{color-scheme:light;--cv-text:var(--color-text-primary,#1f1f1e);--cv-muted:var(--color-text-secondary,#5c5c58);--cv-surface:var(--color-background-secondary,#f5f4ef);--cv-raised:var(--color-background-tertiary,#ecebe5);--cv-border:var(--color-border-primary,#d6d4cc);--cv-ring:var(--color-ring-primary,#2f5fb8);--cv-skeleton:#e4e2db}body{color:var(--cv-text);font-family:var(--font-sans,system-ui,-apple-system,"Segoe UI",sans-serif);font-size:var(--font-text-sm-size,14px);line-height:var(--font-text-sm-line-height,1.45)}.cv-root{display:block}.cv-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.cv-muted{color:var(--cv-muted)}button:focus-visible{outline:2px solid var(--cv-ring);outline-offset:2px}.cv-card{box-sizing:border-box;border:var(--border-width-regular,1px) solid var(--cv-border);border-radius:var(--border-radius-lg,12px);background:var(--cv-surface);padding:14px 16px;overflow:hidden}.cv-card-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin-bottom:10px}.cv-card-head strong{font-size:var(--font-text-md-size,15px);font-weight:var(--font-weight-semibold,600)}.cv-note{margin:0 0 10px;padding:6px 10px;border-radius:var(--border-radius-sm,6px);background:var(--color-background-warning,var(--cv-raised));color:var(--color-text-warning,var(--cv-text))}.cv-text-view p{margin:0 0 6px}.cv-text-body{white-space:pre-wrap;overflow-wrap:anywhere}.cv-skeleton{min-height:220px}.cv-skel-line,.cv-skel-block{background:var(--cv-skeleton);border-radius:6px;margin-bottom:10px}.cv-skel-title{width:32%;height:16px}.cv-skel-sub{width:54%;height:12px}.cv-skel-block{height:160px;border-radius:10px}@media(prefers-reduced-motion:no-preference){.cv-skel-line,.cv-skel-block{animation:cv-pulse 1.6s ease-in-out infinite}}@keyframes cv-pulse{50%{opacity:.55}}.cv-table-wrap{overflow-x:auto}.cv-table{width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums}.cv-table th{position:sticky;top:0;text-align:left;font-weight:var(--font-weight-semibold,600);color:var(--cv-muted);background:var(--cv-surface);border-bottom:1px solid var(--cv-border);padding:6px 10px;white-space:nowrap}.cv-table td{padding:5px 10px;border-bottom:1px solid var(--color-border-secondary,var(--cv-border));white-space:nowrap}.cv-table tr:last-child td{border-bottom:0}.cv-null{color:var(--cv-muted)}.cv-addr-cell{display:inline-flex;align-items:center;gap:6px}.cv-addr{font-family:var(--font-mono,ui-monospace,monospace);font-size:.92em}.cv-addr.is-full{-webkit-user-select:all;user-select:all}.cv-copy{font:inherit;font-size:.8em;padding:1px 7px;border:1px solid var(--cv-border);border-radius:var(--border-radius-sm,5px);background:transparent;color:var(--cv-muted);cursor:pointer}.cv-copy:hover{color:var(--cv-text);background:var(--cv-raised)}.cv-meter{height:8px;border-radius:999px;background:var(--cv-raised);overflow:hidden;margin:2px 0 12px}.cv-meter span{display:block;height:100%;background:var(--cv-ring)}.cv-balance-note{margin:2px 0 12px;font-weight:var(--font-weight-semibold,600)}.cv-facts{display:grid;grid-template-columns:max-content 1fr;gap:6px 18px;margin:0}.cv-facts dt{color:var(--cv-muted)}.cv-facts dd{margin:0;font-weight:var(--font-weight-medium,500)}.cv-flows{box-sizing:border-box;display:flex;flex-direction:column;height:480px;max-height:480px;font-family:var(--font-sans,system-ui,sans-serif)}.cv-flows[data-display-mode=fullscreen]{height:100vh;max-height:none;border-radius:0}.cv-flows-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 12px;padding:10px 14px 6px}.cv-title{display:flex;flex-direction:column;min-width:0}.cv-title strong{font-size:15px;font-weight:600}.cv-title .cv-muted,.cv-flows .cv-muted{color:var(--cia-graph-muted);font-size:12px;overflow-wrap:anywhere}.cv-actions{display:flex;gap:6px;align-items:center;flex-wrap:wrap;justify-content:flex-end}.cv-hint{font-size:12px;color:var(--cia-graph-muted);margin-right:2px}.cv-hint[hidden]{display:none}.cv-button{min-height:30px;min-width:30px;padding:0 10px;border:1px solid var(--cia-graph-border);border-radius:6px;background:var(--cia-graph-control);color:var(--cia-graph-text);font:500 12px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-button:hover{background:var(--cia-graph-hover)}.cv-button:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:1px}.cv-icon{padding:0;font-size:16px;line-height:1}.cv-roles{display:flex;flex-wrap:wrap;gap:4px 14px;margin:0;padding:0 14px 6px;list-style:none;font-size:12px;color:var(--cia-graph-muted)}.cv-roles li{display:inline-flex;align-items:center;gap:5px}.cv-roles i{width:9px;height:9px;border-radius:50%}.cv-canvas{position:relative;flex:1;min-height:0;border-top:1px solid var(--cia-graph-divider);border-bottom:1px solid var(--cia-graph-divider)}.cv-canvas.cia-graph-engine{min-height:0}.cv-canvas .cia-graph-svg{font-family:var(--font-sans,Inter,system-ui,sans-serif)}.cv-status{margin:0;padding:6px 14px 8px;font-size:12px;color:var(--cia-graph-muted)}.cv-detail{flex:none;max-height:58px;overflow:auto;padding:6px 14px;border-bottom:1px solid var(--cia-graph-divider);color:var(--cia-graph-text);font-size:12px;display:flex;flex-wrap:wrap;align-items:baseline;gap:2px 12px}.cv-detail[hidden]{display:none}.cv-detail>strong{color:var(--cia-graph-muted);font-weight:500}.cv-detail>code{font:11px var(--font-mono,ui-monospace,monospace);overflow-wrap:anywhere}.cv-detail-meta{display:contents}.cv-detail-meta .meta-item{display:inline-flex;gap:5px;align-items:baseline}.cv-detail-meta .meta-item span{color:var(--cia-graph-muted)}.cv-detail-meta .meta-item strong{color:var(--cia-graph-text);font-weight:600;overflow-wrap:anywhere}.cv-detail-meta .cia-graph-explorer-link{font:inherit;font-weight:600;padding:0;border:0;border-bottom:1px solid var(--cia-graph-border);background:none;color:var(--cia-graph-edge);cursor:pointer;overflow-wrap:anywhere;text-align:left}.cv-detail-meta .cia-graph-explorer-link:hover{border-bottom-color:var(--cia-graph-edge)}
111
+ <style>.cia-graph-surface{--cia-graph-surface:linear-gradient(140deg,#171a20,#0d0f13);--cia-graph-canvas:#101318;--cia-graph-dot:#f2dda621;--cia-graph-text:#e2e8f0;--cia-graph-muted:#adb1ba;--cia-graph-border:#f2dda640;--cia-graph-divider:#ffffff10;--cia-graph-control:#14161a;--cia-graph-hover:#f2dda626;--cia-graph-active:#f2dda6;--cia-graph-active-text:#0b0e13;--cia-graph-node:#14161a;--cia-graph-edge:#f2dda6;--cia-graph-halo:#07090d;--cia-graph-selected:#ffffff;--cia-graph-danger:#d89087;--cia-graph-target:#8bb6b0;--cia-graph-trail:#b49bc4;--cia-graph-infrastructure:#94b58b;--cia-graph-neutral:#f2dda6;--cia-graph-critical:#d89087;--cia-graph-high:#d6a07d;--cia-graph-medium:#b49bc4;--cia-graph-low:#94b58b;--cia-graph-role-exchange:var(--cia-graph-infrastructure);--cia-graph-role-scam:var(--cia-graph-danger);--cia-graph-role-sanctioned:var(--cia-graph-danger);--cia-graph-role-victim:var(--cia-graph-target);--cia-graph-role-pool:var(--cia-graph-trail);--cia-graph-role-other:var(--cia-graph-neutral);--cia-graph-series-1:var(--cia-graph-edge);--cia-graph-series-2:var(--cia-graph-target);--cia-graph-series-3:var(--cia-graph-trail);--cia-graph-series-4:var(--cia-graph-infrastructure);--cia-graph-series-5:var(--cia-graph-danger);--cia-graph-series-6:var(--cia-graph-high);color:var(--cia-graph-text);background:var(--cia-graph-surface);border:1px solid var(--cia-graph-border);border-radius:14px;overflow:hidden}html[data-theme=light] .cia-graph-surface{--cia-graph-surface:#f9f9f9;--cia-graph-canvas:#fff;--cia-graph-dot:#dedede;--cia-graph-text:#242424;--cia-graph-muted:#686868;--cia-graph-border:#dedede;--cia-graph-divider:#e6e6e6;--cia-graph-control:#fff;--cia-graph-hover:#ececec;--cia-graph-active:#4e708a;--cia-graph-active-text:#fff;--cia-graph-node:#fff;--cia-graph-edge:#4e708a;--cia-graph-halo:#fff;--cia-graph-selected:#242424;--cia-graph-danger:#a64d4b;--cia-graph-target:#356e68;--cia-graph-trail:#78538f;--cia-graph-infrastructure:#416c4a;--cia-graph-neutral:#4e708a;--cia-graph-critical:#a64d4b;--cia-graph-high:#a15432;--cia-graph-medium:#78538f;--cia-graph-low:#416c4a}.cia-graph-canvas{background:radial-gradient(circle,var(--cia-graph-dot) 1px,transparent 1px) 0 0/24px 24px,var(--cia-graph-canvas)}.graph-detail{border-top:1px solid var(--cia-graph-divider,#ffffff10);padding:1rem 1.5rem;font-size:.85rem;color:var(--cia-graph-muted,#adb1ba);line-height:1.6}.graph-detail strong{color:var(--cia-graph-text,#f2dda6)}.graph-detail p{margin:0}.graph-detail ul{padding-left:1.25rem;margin-bottom:0}.graph-detail strong,.graph-detail li{overflow-wrap:anywhere}.graph-legend{border-top:1px solid var(--cia-graph-divider,#ffffff10);padding:1rem 1.5rem;font-size:.85rem}.graph-legend summary{cursor:pointer}.graph-legend ul{list-style:none;padding:0}.graph-legend li{display:flex;flex-wrap:wrap;gap:.4rem 1rem;padding:.6rem 0;border-bottom:1px solid var(--cia-graph-divider,#ffffff0a)}.graph-legend button{color:var(--cia-graph-edge,#f2dda6);background:none;border:0;padding:0;text-align:left;cursor:pointer;font:inherit;font-family:ui-monospace,monospace;overflow-wrap:anywhere;max-width:100%}.graph-legend span{color:var(--cia-graph-muted,#adb1ba)}.graph-detail a,.graph-legend a{color:var(--cia-graph-edge,#f2dda6);text-decoration:none;border-bottom:1px solid var(--cia-graph-border,#f2dda659)}.graph-detail a:hover,.graph-legend a:hover{border-bottom-color:var(--cia-graph-edge,#f2dda6)}.graph-legend .graph-legend-link{overflow-wrap:normal;flex:none}.cia-graph-node-body{fill:var(--cia-graph-node,#14161a)}.cia-graph-node-ring{stroke:var(--cia-graph-edge,#f2dda6)}.cia-graph-node-address{fill:var(--cia-graph-muted,#adb1ba)}.cia-graph-edge-underlay{stroke:var(--cia-graph-halo,#07090d)}.cia-graph-edge-direction{stroke:var(--cia-graph-edge,#f2dda6)}.cia-graph-edge-arrow{fill:var(--cia-graph-edge,#f2dda6);stroke:var(--cia-graph-halo,#07090d)}.cia-graph-surface .graph-tooltip{background:var(--cia-graph-control);color:var(--cia-graph-text);border-color:var(--cia-graph-border)}.cia-graph-engine{position:relative;min-height:240px}.cia-graph-svg{display:block;width:100%;height:100%;touch-action:none;font-family:Inter,system-ui,sans-serif;outline:none}.cia-graph-svg:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:-2px}.cia-graph-backdrop{fill:var(--cia-graph-canvas)}.cia-graph-dot{fill:var(--cia-graph-dot)}.cia-graph-edge{cursor:pointer;outline:none;transition:opacity .15s}.cia-graph-edge-hit{fill:none;stroke:transparent}.cia-graph-edge-line{fill:none;stroke:var(--edge-tone,var(--cia-graph-edge));stroke-linecap:round}.cia-graph-edge:focus-visible .cia-graph-edge-line,.cia-graph-edge[aria-pressed=true] .cia-graph-edge-line{stroke-width:3}.cia-graph-node{cursor:pointer;outline:none}.cia-graph-engine .cia-graph-node-body{fill:var(--cia-graph-node);stroke:var(--node-tone,var(--cia-graph-neutral));stroke-width:2}.cia-graph-engine .cia-graph-node-ring{fill:none;stroke:var(--cia-graph-edge);stroke-width:2}.cia-graph-node-dot{fill:var(--node-tone,var(--cia-graph-neutral))}.cia-graph-node.is-selected .cia-graph-node-body,.cia-graph-node:focus-visible .cia-graph-node-body{stroke:var(--cia-graph-selected);stroke-width:4}.cia-graph-node text{paint-order:stroke;stroke:var(--cia-graph-halo);stroke-width:4px;stroke-linejoin:round}.cia-graph-node-role{fill:var(--node-tone,var(--cia-graph-neutral));font-size:13px;font-weight:600}.cia-graph-engine .cia-graph-node-address{fill:var(--cia-graph-muted);font:400 11px ui-monospace,monospace}.cia-graph-node-note{fill:var(--cia-graph-text);font-size:11px;font-style:italic}.cia-graph-node[data-state=refused] .cia-graph-node-body{stroke-dasharray:4 3}.cia-graph-engine>.graph-tooltip{position:absolute;z-index:2;max-width:320px;padding:.5rem .65rem;border:1px solid;border-radius:6px;font:12px/1.45 Inter,system-ui,sans-serif;overflow-wrap:anywhere;pointer-events:none}:root{color-scheme:light dark}html,body{margin:0;padding:0;background:transparent}html[data-theme=dark]{color-scheme:dark;--cv-text:var(--color-text-primary,#ececec);--cv-muted:var(--color-text-secondary,#b4b4b4);--cv-surface:var(--color-background-secondary,#262624);--cv-raised:var(--color-background-tertiary,#30302e);--cv-border:var(--color-border-primary,#4a4a46);--cv-ring:var(--color-ring-primary,#8fb5ff);--cv-skeleton:#3a3a37}html[data-theme=light]{color-scheme:light;--cv-text:var(--color-text-primary,#1f1f1e);--cv-muted:var(--color-text-secondary,#5c5c58);--cv-surface:var(--color-background-secondary,#f5f4ef);--cv-raised:var(--color-background-tertiary,#ecebe5);--cv-border:var(--color-border-primary,#d6d4cc);--cv-ring:var(--color-ring-primary,#2f5fb8);--cv-skeleton:#e4e2db}body{color:var(--cv-text);font-family:var(--font-sans,system-ui,-apple-system,"Segoe UI",sans-serif);font-size:var(--font-text-sm-size,14px);line-height:var(--font-text-sm-line-height,1.45)}.cv-root{display:block}.cv-sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}.cv-muted{color:var(--cv-muted)}button:focus-visible{outline:2px solid var(--cv-ring);outline-offset:2px}.cv-card{box-sizing:border-box;border:var(--border-width-regular,1px) solid var(--cv-border);border-radius:var(--border-radius-lg,12px);background:var(--cv-surface);padding:14px 16px;overflow:hidden}.cv-card-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:4px 12px;margin-bottom:10px}.cv-card-head strong{font-size:var(--font-text-md-size,15px);font-weight:var(--font-weight-semibold,600)}.cv-note{margin:0 0 10px;padding:6px 10px;border-radius:var(--border-radius-sm,6px);background:var(--color-background-warning,var(--cv-raised));color:var(--color-text-warning,var(--cv-text))}.cv-text-view p{margin:0 0 6px}.cv-text-body{white-space:pre-wrap;overflow-wrap:anywhere}.cv-skeleton{min-height:220px}.cv-skel-line,.cv-skel-block{background:var(--cv-skeleton);border-radius:6px;margin-bottom:10px}.cv-skel-title{width:32%;height:16px}.cv-skel-sub{width:54%;height:12px}.cv-skel-block{height:160px;border-radius:10px}@media(prefers-reduced-motion:no-preference){.cv-skel-line,.cv-skel-block{animation:cv-pulse 1.6s ease-in-out infinite}}@keyframes cv-pulse{50%{opacity:.55}}.cv-table-wrap{overflow-x:auto}.cv-table{width:100%;border-collapse:collapse;font-variant-numeric:tabular-nums}.cv-table th{position:sticky;top:0;text-align:left;font-weight:var(--font-weight-semibold,600);color:var(--cv-muted);background:var(--cv-surface);border-bottom:1px solid var(--cv-border);padding:6px 10px;white-space:nowrap}.cv-table td{padding:5px 10px;border-bottom:1px solid var(--color-border-secondary,var(--cv-border));white-space:nowrap}.cv-table tr:last-child td{border-bottom:0}.cv-null{color:var(--cv-muted)}.cv-addr-cell{display:inline-flex;align-items:center;gap:6px}.cv-addr{font-family:var(--font-mono,ui-monospace,monospace);font-size:.92em}.cv-addr.is-full{-webkit-user-select:all;user-select:all}.cv-copy{font:inherit;font-size:.8em;padding:1px 7px;border:1px solid var(--cv-border);border-radius:var(--border-radius-sm,5px);background:transparent;color:var(--cv-muted);cursor:pointer}.cv-copy:hover{color:var(--cv-text);background:var(--cv-raised)}.cv-meter{height:8px;border-radius:999px;background:var(--cv-raised);overflow:hidden;margin:2px 0 12px}.cv-meter span{display:block;height:100%;background:var(--cv-ring)}.cv-balance-note{margin:2px 0 12px;font-weight:var(--font-weight-semibold,600)}.cv-facts{display:grid;grid-template-columns:max-content 1fr;gap:6px 18px;margin:0}.cv-facts dt{color:var(--cv-muted)}.cv-facts dd{margin:0;font-weight:var(--font-weight-medium,500)}.cv-flows{box-sizing:border-box;display:flex;flex-direction:column;height:480px;max-height:480px;font-family:var(--font-sans,system-ui,sans-serif)}.cv-flows[data-display-mode=fullscreen]{height:calc(100vh - var(--cv-tabs-h,0px));max-height:none;border-radius:0}.cv-flows-head{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:6px 12px;padding:10px 14px 6px}.cv-title{display:flex;flex-direction:column;min-width:0}.cv-title strong{font-size:15px;font-weight:600}.cv-title .cv-muted,.cv-flows .cv-muted{color:var(--cia-graph-muted);font-size:12px;overflow-wrap:anywhere}.cv-actions{display:flex;gap:6px;align-items:center;flex-wrap:wrap;justify-content:flex-end}.cv-hint{font-size:12px;color:var(--cia-graph-muted);margin-right:2px}.cv-hint[hidden]{display:none}.cv-button{min-height:30px;min-width:30px;padding:0 10px;border:1px solid var(--cia-graph-border);border-radius:6px;background:var(--cia-graph-control);color:var(--cia-graph-text);font:500 12px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-button:hover{background:var(--cia-graph-hover)}.cv-button:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:1px}.cv-icon{padding:0;font-size:16px;line-height:1}.cv-roles{display:flex;flex-wrap:wrap;gap:4px 14px;margin:0;padding:0 14px 6px;list-style:none;font-size:12px;color:var(--cia-graph-muted)}.cv-roles li{display:inline-flex;align-items:center;gap:5px}.cv-roles i{width:9px;height:9px;border-radius:50%}.cv-canvas{position:relative;flex:1;min-height:0;border-top:1px solid var(--cia-graph-divider);border-bottom:1px solid var(--cia-graph-divider)}.cv-canvas.cia-graph-engine{min-height:0}.cv-canvas .cia-graph-svg{font-family:var(--font-sans,Inter,system-ui,sans-serif)}.cv-status{margin:0;padding:6px 14px 8px;font-size:12px;color:var(--cia-graph-muted)}.cv-detail{flex:none;max-height:58px;overflow:auto;padding:6px 14px;border-bottom:1px solid var(--cia-graph-divider);color:var(--cia-graph-text);font-size:12px;display:flex;flex-wrap:wrap;align-items:baseline;gap:2px 12px}.cv-detail[hidden]{display:none}.cv-detail>strong{color:var(--cia-graph-muted);font-weight:500}.cv-detail>code{font:11px var(--font-mono,ui-monospace,monospace);overflow-wrap:anywhere}.cv-detail-meta{display:contents}.cv-detail-meta .meta-item{display:inline-flex;gap:5px;align-items:baseline}.cv-detail-meta .meta-item span{color:var(--cia-graph-muted)}.cv-detail-meta .meta-item strong{color:var(--cia-graph-text);font-weight:600;overflow-wrap:anywhere}.cv-detail-meta .cia-graph-explorer-link{font:inherit;font-weight:600;padding:0;border:0;border-bottom:1px solid var(--cia-graph-border);background:none;color:var(--cia-graph-edge);cursor:pointer;overflow-wrap:anywhere;text-align:left}.cv-detail-meta .cia-graph-explorer-link:hover{border-bottom-color:var(--cia-graph-edge)}.cv-face[hidden],.cv-tabpanel[hidden]{display:none}.cv-toggle{display:inline-flex;flex:none;border:1px solid var(--cia-graph-border,var(--cv-border));border-radius:6px;overflow:hidden}.cv-card-head .cv-toggle{margin-left:auto}.cv-toggle-button{min-height:28px;padding:0 12px;border:0;background:var(--cia-graph-control,var(--cv-raised));color:var(--cia-graph-text,var(--cv-text));font:500 12px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-toggle-button+.cv-toggle-button{border-left:1px solid var(--cia-graph-border,var(--cv-border))}.cv-toggle-button:hover{background:var(--cia-graph-hover,var(--cv-border))}.cv-toggle-button[aria-pressed=true]{background:var(--cia-graph-active,var(--cv-text));color:var(--cia-graph-active-text,var(--cv-surface))}.cv-toggle-button:focus-visible{outline:2px solid var(--cia-graph-active,var(--cv-ring));outline-offset:-2px}.cia-graph-surface .cv-note{margin:0 14px 6px;background:var(--cia-graph-control);color:var(--cia-graph-text);border:1px solid var(--cia-graph-border)}.cv-tabs{display:flex;flex-wrap:wrap;gap:4px;margin:0 0 8px}.cv-tab{padding:6px 12px;border:1px solid var(--cv-border);border-radius:var(--border-radius-md,8px);background:transparent;color:var(--cv-muted);font:500 13px var(--font-sans,system-ui,sans-serif);cursor:pointer}.cv-tab:hover{color:var(--cv-text)}.cv-tab[aria-selected=true]{background:var(--cv-raised);color:var(--cv-text);border-color:var(--cv-ring)}.cv-tab:focus-visible{outline:2px solid var(--cv-ring);outline-offset:2px}.cv-chart{box-sizing:border-box;font-family:var(--font-sans,system-ui,sans-serif)}.cv-chart .cv-muted{color:var(--cia-graph-muted);font-size:12px}.cv-chart-body{padding:4px 14px 12px}.cv-chart-svg{display:block;width:100%;height:auto}.cv-chart-name{fill:var(--cia-graph-text);font:600 12px var(--font-sans,Inter,system-ui,sans-serif)}.cv-chart-tick{fill:var(--cia-graph-muted);font:400 11px var(--font-sans,Inter,system-ui,sans-serif)}.cv-chart-grid{stroke:var(--cia-graph-divider);stroke-width:1}.cv-chart-base{stroke:var(--cia-graph-border);stroke-width:1}.cv-chart-line{stroke-width:2;stroke-linejoin:round;stroke-linecap:round}.cv-body{position:relative;display:flex;flex:1;min-height:0;min-width:0}.cv-body>.cv-canvas{flex:1;min-width:0}.cv-linkpanel{display:flex;flex-direction:column;flex:none;box-sizing:border-box;width:min(46%,320px);overflow:hidden;padding:10px 12px;border-top:1px solid var(--cia-graph-divider);border-bottom:1px solid var(--cia-graph-divider);border-left:1px solid var(--cia-graph-divider);font-size:12px;color:var(--cia-graph-text)}.cv-linkpanel[hidden]{display:none}.cv-link-body{flex:1;min-height:0;overflow:auto}.cv-linkpanel>[data-link-earlier]{flex:none;align-self:flex-start;margin-top:8px}.cv-link-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:4px}.cv-link-head strong{font-size:13px}.cv-link-pair{margin:0;color:var(--cia-graph-muted)}.cv-link-pair code{font:11px var(--font-mono,ui-monospace,monospace)}.cv-link-day{margin:4px 0 8px;font-weight:600}.cv-link-body p{margin:0 0 8px}.cv-link-error{color:var(--cia-graph-danger);overflow-wrap:anywhere}.cv-transfers{list-style:none;margin:0 0 8px;padding:0}.cv-transfer{display:grid;grid-template-columns:auto 1fr auto;gap:2px 8px;padding:6px 0;border-bottom:1px solid var(--cia-graph-divider)}.cv-transfer-time{color:var(--cia-graph-muted);font-variant-numeric:tabular-nums}.cv-transfer-amount{font-weight:600;overflow-wrap:anywhere}.cv-transfer-usd{text-align:right;font-variant-numeric:tabular-nums}.cv-transfer>code,.cv-transfer>.cia-graph-explorer-link{grid-column:1/-1;font:11px var(--font-mono,ui-monospace,monospace);color:var(--cia-graph-muted)}.cv-transfer>.cia-graph-explorer-link{padding:0;border:0;border-bottom:1px solid var(--cia-graph-border);background:none;text-align:left;cursor:pointer;justify-self:start;color:var(--cia-graph-edge)}.cv-transfer>.cia-graph-explorer-link:hover{border-bottom-color:var(--cia-graph-edge)}.cv-linkpanel .cv-button:disabled{opacity:.5;cursor:default}@media(max-width:560px){.cv-linkpanel{position:absolute;inset:0;width:auto;border-left:0;background:var(--cia-graph-surface)}}
112
112
  </style>
113
113
  </head>
114
114
  <body>