chain-insights 0.54.0 → 0.54.2
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
|
|
1
|
+
<!-- Chain Insights UI b40ca381e1f6dc6d940b294203aafd4e45bd6718 (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,12 +6,12 @@
|
|
|
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 Q_=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),ek=function(e,t){return new URL(e,t).href},ch={},tk=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let c=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]"),u=a?.nonce||a?.getAttribute("nonce");i=c(n.map(l=>{if(l=ek(l,r),l in ch)return;ch[l]=!0;const d=l.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(r)for(let p=s.length-1;p>=0;p--){const m=s[p];if(m.href===l&&(!d||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${f}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":Q_,d||(h.as="script"),h.crossOrigin="",h.href=l,u&&h.setAttribute("nonce",u),document.head.appendChild(h),d)return new Promise((p,m)=>{h.addEventListener("load",p),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return i.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};function nk(e){return e}function rk(e){return e}function Ss(){return e=>e}function ik(e){}function ok(e){throw new Error("Unexpected value in exhaustive check")}function sk(e){}function is(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function Lu(e,t="|"){return e.map(n=>wc(n)).join(t)}function os(e,t){return typeof t=="bigint"?t.toString():t}class ak{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 bi(e){return new ak(e)}function yc(e){return e==null}function Cn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function vc(e,t){const n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}const lh=Symbol("evaluating");function pm(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==lh)return r===void 0&&(r=lh,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function uk(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Tt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function xs(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function un(e){return xs(e._zod.def)??e._zod.def.shape}function mm(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return Tt(this,t,r),r},enumerable:!0,configurable:!0})}function gm(e,t,n){t in e?Tt(e,t,n):e[t]=n}function Bn(e,t,n,r){const i=un(t);for(const o of n){const s=Object.getOwnPropertyDescriptor(i,o);s.enumerable&&(s.get?mm(e,o,()=>{const a=t._zod.def.shape[o];return r?r(a,o):a}):gm(e,o,r?r(s.value,o):s.value))}}function ck(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?mm(e,n,()=>t[n]):gm(e,n,r.value))}}function lt(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function lk(e){return lt(e._zod.def)}function dk(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function fk(e){const t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{const i={};for(let o=0;o<t.length;o++)i[t[o]]=r[o];return i})}function hk(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 xt(e){return JSON.stringify(e)}function ym(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const bc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function sr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const vm=bi(()=>{if(vt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function cn(e){if(sr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(sr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function wi(e){return cn(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function pk(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const mk=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}`)}},ss=new Set(["string","number","symbol"]),bm=new Set(["string","number","bigint","boolean","symbol","undefined"]);function ln(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function je(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function N(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 gk(e){let t;return new Proxy({},{get(n,r,i){return t??(t=e()),Reflect.get(t,r,i)},set(n,r,i,o){return t??(t=e()),Reflect.set(t,r,i,o)},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,i){return t??(t=e()),Reflect.defineProperty(t,r,i)}})}function wc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function wm(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const _c={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]},kc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function _m(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 o={};return Bn(o,e,Es(e,t)),je(e,lt(n,{shape:o,checks:[]}))}function Es(e,t){const n=un(e),r=[];for(const i of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,i)?.enumerable)throw new Error(`Unrecognized key: "${String(i)}"`);t[i]&&r.push(i)}return r}function km(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 o=new Set(Es(e,t)),s={};return Bn(s,e,Reflect.ownKeys(un(e)).filter(a=>!o.has(a))),je(e,lt(n,{shape:s,checks:[]}))}function Sm(e,t){if(!cn(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=un(e);for(const o of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return je(e,lt(e._zod.def,{shape:xm(e,t)}))}function xm(e,t){const n={};return Bn(n,e,Reflect.ownKeys(un(e))),ck(n,t),n}function Em(e,t){if(!cn(t))throw new Error("Invalid input to safeExtend: expected a plain object");return je(e,lt(e._zod.def,{shape:xm(e,t)}))}function $m(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={};Bn(n,e,Reflect.ownKeys(un(e))),Bn(n,t,Reflect.ownKeys(un(t)));const r=lt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return je(e,r)}function zu(e,t,n,r="partial"){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set(Es(t,n)):void 0,u={};return Bn(u,t,Reflect.ownKeys(un(t)),e&&((c,l)=>a&&!a.has(l)?c:new e({type:"optional",innerType:c}))),je(t,lt(t._zod.def,{shape:u,checks:[]}))}function Tm(e,t,n){const r=n?new Set(Es(t,n)):void 0,i={};return Bn(i,t,Reflect.ownKeys(un(t)),(o,s)=>r&&!r.has(s)?o:new e({type:"nonoptional",innerType:o})),je(t,lt(t._zod.def,{shape:i}))}function wt(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 Cm(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 zt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function er(e){return typeof e=="string"?e:e?.message}function Pu(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Ot(e,t,n){var r;const i=e.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:er(e.inst?._zod.def?.error?.(e))??er(o?.(e))??er(t?.error?.(e))??er(n.customError?.(e))??er(n.localeError?.(e))??"Invalid input",a={};for(const u of Object.keys(e))u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__"||(a[u]=e[u]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}function $s(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}const yk=/[\uD800-\uDBFF]/;function _i(e){const t=e.length;if(!yk.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 Ts(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Am(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 ar(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function vk(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Im(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 Nm(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function bk(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return Im(t+n)}function wk(e){return Nm(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function _k(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 kk(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class Sk{constructor(...t){}}function Rm(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):xk(e,n,r.value)}}function dn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Cs(e,t,n){return dn(e,t,n,!1)}function ki(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return dn(this,n,r(this))},set(i){dn(this,n,i)}})}return t}function xk(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:dn(this,t,n.bind(this))},set(r){dn(this,t,r)}})}function Ek(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let eu,kn=!1;const $k={configurable:!0,get(){kn=!0}};function Se(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&eu!==e._zod){eu=void 0;return}eu=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,$k);const i=kn;kn=!1;try{const o=n(this);return kn?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),kn=kn||i,o}catch(o){throw delete this[t],kn=kn||i,o}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function Lm(e,t,n,r){const i=Ek(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){const o={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,o),o.value=n(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:o})}})}const Sc="~constantCatch";function xc(e){const t=()=>e;return t[Sc]=!0,t}const Ec=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:kc,CONSTANT_CATCH:Sc,Class:Sk,NUMBER_FORMAT_RANGES:_c,aborted:wt,allowsEval:vm,assert:sk,assertEqual:nk,assertIs:ik,assertNever:ok,assertNotEqual:rk,assignProp:Tt,attachSchema:Pu,base64ToUint8Array:Im,base64urlToUint8Array:bk,cached:bi,captureStackTrace:bc,cleanEnum:vk,cleanRegex:Cn,clone:je,cloneDef:lk,codePointLength:_i,constantCatch:xc,createTransparentProxy:gk,defineLazy:pm,defineLazyInternal:Se,derived:ki,esc:xt,escapeRegex:ln,explicitlyAborted:Cm,extend:Sm,finalizeIssue:Ot,floatSafeRemainder:vc,getElementAtPath:dk,getEnumValues:is,getLengthableOrigin:Ts,getParsedType:mk,getSizableOrigin:$s,hexToUint8Array:_k,hide:Cs,installLazyProp:Lm,isObject:sr,isPlainObject:cn,issue:ar,joinValues:Lu,jsonStringifyReplacer:os,members:Rm,merge:$m,mergeDefs:lt,normalizeParams:N,nullish:yc,numKeys:pk,objectClone:uk,omit:km,optionalKeys:wm,own:dn,parsedType:Am,partial:zu,pick:_m,prefixIssues:zt,primitiveTypes:bm,promiseAllObject:fk,propertyKeyTypes:ss,randomString:hk,rawShape:xs,required:Tm,safeExtend:Em,shallowClone:wi,slugify:ym,stringifyPrimitive:wc,toZod:Ss,uint8ArrayToBase64:Nm,uint8ArrayToBase64url:wk,uint8ArrayToHex:kk,unwrapMessage:er},Symbol.toStringTag,{value:"Module"}));var dh;const $c=Object.freeze({status:"aborted"}),tu={value:void 0,enumerable:!1};let fh="captureStackTrace"in Error?Error:null;function Tk(e){const t=fh;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return fh=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function S(e,t,n,r){const i={};function o(f){this.def=f,this.constr=d,this.traits=new Set}o.prototype=i;const s=n,a=s&&new WeakSet;function u(f,h){if(f._zod){if(f._zod.traits.has(e))return}else{tu.value=new o(h);try{Object.defineProperty(f,"_zod",tu)}finally{tu.value=void 0}}if(f._zod.traits.add(e),t(f,h),a){const m=Object.getPrototypeOf(f),y=f._zod.constr.prototype;let w=m;for(;w&&w!==y;)w=Object.getPrototypeOf(w);const g=w??m;a.has(g)||(a.add(g),Rm(g,s))}const p=d.prototype;for(const m in p)Object.prototype.hasOwnProperty.call(p,m)&&(m in f||(f[m]=p[m].bind(f)))}const c=r?.Parent??Object;class l extends c{}Object.defineProperty(l,"name",{value:e});function d(f){const h=r?.Parent?Tk(l):this;u(h,f);const p=h._zod.deferred;if(p){for(const y of p)y();h._zod.deferred=void 0}const m=globalThis.__zod_globalConfig?.postProcessor;return m&&m(h),h}return Object.defineProperty(d,"init",{value:u}),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 Tc=Symbol("zod_brand");class sn extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class As extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(dh=globalThis).__zod_globalConfig??(dh.__zod_globalConfig={});const vt=globalThis.__zod_globalConfig;function et(e){return e&&Object.assign(vt,e),vt}function Ck(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,os,2)),e.message}function Ak(e){this._zod.message=e}const Ik={get:Ck,set:Ak,enumerable:!0,configurable:!0},nu={value:void 0,enumerable:!1},hh=new WeakSet([Object.prototype,Error.prototype]),zm=(e,t)=>{e.name="$ZodError",nu.value=t,Object.defineProperty(e,"issues",nu),nu.value=void 0,Object.defineProperty(e,"message",Ik);const n=Object.getPrototypeOf(e);hh.has(n)||(hh.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})}}))},Pm=S("$ZodError",zm),Ct=S("$ZodError",zm,void 0,{Parent:Error});function Nk(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 Is(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?Nk(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ns(e,t=n=>n.message){const n={_errors:[]},r=(i,o=[])=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...o,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...o,...s.path]);else{const a=[...o,...s.path];if(a.length===0)n._errors.push(t(s));else{let u=n,c=0;for(;c<a.length;){const l=a[c],d=c===a.length-1;if(l==="_errors"){d&&u._errors.push(t(s)),c++;continue}Object.prototype.hasOwnProperty.call(u,l)||Object.defineProperty(u,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const f=u[l];d&&f._errors.push(t(s)),u=f,c++}}}};return r(e),n}function Cc(e,t=n=>n.message){const n={errors:[]},r=(i,o=[])=>{var s;for(const a of i.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(u=>r({issues:u},[...o,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...o,...a.path]);else{const u=[...o,...a.path];if(u.length===0){n.errors.push(t(a));continue}let c=n,l=0;for(;l<u.length;){const d=u[l],f=l===u.length-1;typeof d=="string"?(c.properties??(c.properties={}),Object.prototype.hasOwnProperty.call(c.properties,d)||Object.defineProperty(c.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),c=c.properties[d]):(c.items??(c.items=[]),(s=c.items)[d]??(s[d]={errors:[]}),c=c.items[d]),f&&c.errors.push(t(a)),l++}}};return r(e),n}function Dm(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 Ac(e){const t=[],n=[...e.issues].sort((r,i)=>(r.path??[]).length-(i.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${Dm(r.path)}`);return t.join(`
|
|
10
|
-
`)}function Rs(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Si=e=>{const t=(n,r,i,o)=>{const s=i?{...i,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new sn;if(a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Ot(c,s,et())));throw bc(u,o?.callee??t),u}return a.value};return t},Du=Si(Ct),xi=e=>{const t=async(n,r,i,o)=>{const s=i?{...i,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Ot(c,s,et())));throw bc(u,o?.callee??t),u}return a.value};return t},Ou=xi(Ct),Ei=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new sn;return o.issues.length?Mm(e,o.issues,i):{success:!0,data:o.value}},Om=Ei(Ct);function Mm(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(i=>Ot(i,n,et()))),t=void 0,n=void 0),r},set error(i){r=i,t=void 0,n=void 0}}}const $i=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?Mm(e,o.issues,i):{success:!0,data:o.value}},Rk=$i(Ct),Lk=Symbol.for("zod.compile.invalid"),zk=Symbol.for("zod.compile.fallback"),Ls=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Lk)return!0;if(r.definite===!0&&n===void 0)return!1}return Pk(e,t,n)});function Pk(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun;let o;if(i?(r[zk]=!0,o=i({value:t,issues:[]},r)):o=e._zod.run({value:t,issues:[]},r),o instanceof Promise)throw new sn;return o.issues.length===0}const zs=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Ic=e=>{const t=Si(e),n=(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return t(r,i,a,Rs(n,s))};return n},Dk=Ic(Ct),Nc=e=>{const t=Si(e),n=(r,i,o,s)=>t(r,i,o,Rs(n,s));return n},Ok=Nc(Ct),Rc=e=>{const t=xi(e),n=async(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return await t(r,i,a,Rs(n,s))};return n},Mk=Rc(Ct),Lc=e=>{const t=xi(e),n=async(r,i,o,s)=>await t(r,i,o,Rs(n,s));return n},Fk=Lc(Ct),zc=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return Ei(e)(t,n,i)},Uk=zc(Ct),Pc=e=>(t,n,r)=>Ei(e)(t,n,r),Gk=Pc(Ct),Dc=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return $i(e)(t,n,i)},jk=Dc(Ct),Oc=e=>async(t,n,r)=>$i(e)(t,n,r),Zk=Oc(Ct),Fm=/^[cC][0-9a-z]{6,}$/,Um=/^[0-9a-z]+$/,Gm=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,jm=/^[0-9a-vA-V]{20}$/,Zm=/^[A-Za-z0-9]{27}$/,Bm=/^[a-zA-Z0-9_-]{21}$/;function Hm(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Vm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Bk=/^[-+]?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)?)??$/,qm=/^([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})$/,ur=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)$/,Hk=ur(4),Vk=ur(6),qk=ur(7),Wm=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Wk=/^[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])?)*$/,Kk=/^(([^<>()\[\]\\.,;:\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,}))$/,Km=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Jk=Km,Yk=/^[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])?)*$/,Xk="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Jm(){return new RegExp(Xk,"u")}const Ym=/^(?:(?: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])$/,Xm=/^(([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}|:))$/,Qm=e=>{const t=ln(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},eg=/^((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])$/,tg=/^(([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])$/,ng=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rg=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,ig=/^(?=.{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])?)*\.?$/,og=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,Mc=/^https?$/,sg=/^\+[1-9]\d{6,14}$/,Fc=/^\d(?:[ -]?\d){11,18}$/,ag=/^(?: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)$/,Uc=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,ug="(?:(?:\\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 Qk(e){return new RegExp(`^${e}$`)}const cg=Qk(ug);function Mu(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 lg(e){return new RegExp(`^${Mu(e)}$`)}function dg(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Mu({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Mu({precision:e.precision})}`:n;return new RegExp(`^${ug}T(?:${r})$`)}const fg=/^[\s\S]{0,}$/,hg=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},pg=/^-?\d+n?$/,Gc=/^-?\d+$/,wr=/^-?\d+(?:\.\d+)?$/,mg=/^(?:true|false)$/i,gg=/^null$/i,yg=/^undefined$/i,vg=/^[^A-Z]*$/,bg=/^[^a-z]*$/,wg=/^[0-9a-fA-F]*$/;function Ti(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Ci(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const eS=/^[0-9a-fA-F]{32}$/,tS=Ti(22,"=="),nS=Ci(22),rS=/^[0-9a-fA-F]{40}$/,iS=Ti(27,"="),oS=Ci(27),sS=/^[0-9a-fA-F]{64}$/,aS=Ti(43,"="),uS=Ci(43),cS=/^[0-9a-fA-F]{96}$/,lS=Ti(64,""),dS=Ci(64),fS=/^[0-9a-fA-F]{128}$/,hS=Ti(86,"=="),pS=Ci(86),Ps=Object.freeze(Object.defineProperty({__proto__:null,anyString:fg,base64:ng,base64url:rg,bigint:pg,boolean:mg,browserEmail:Yk,cidrv4:eg,cidrv6:tg,creditCard:Fc,cuid:Fm,cuid2:Um,currencyCode:ag,date:cg,datetime:dg,domain:og,duration:Vm,e164:sg,email:Wm,emoji:Jm,extendedDuration:Bk,guid:qm,hex:wg,hostname:ig,html5Email:Wk,httpProtocol:Mc,iban:Uc,idnEmail:Jk,integer:Gc,ipv4:Ym,ipv6:Xm,ksuid:Zm,lowercase:vg,mac:Qm,md5_base64:tS,md5_base64url:nS,md5_hex:eS,nanoid:Bm,nanoidOfLength:Hm,null:gg,number:wr,rfc5322Email:Kk,sha1_base64:iS,sha1_base64url:oS,sha1_hex:rS,sha256_base64:aS,sha256_base64url:uS,sha256_hex:sS,sha384_base64:lS,sha384_base64url:dS,sha384_hex:cS,sha512_base64:hS,sha512_base64url:pS,sha512_hex:fS,string:hg,time:lg,ulid:Gm,undefined:yg,unicodeEmail:Km,uppercase:bg,uuid:ur,uuid4:Hk,uuid6:Vk,uuid7:qk,xid:jm},Symbol.toStringTag,{value:"Module"})),Ze=S("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),jc=e=>{const t=e.value;return!yc(t)&&t.size!==void 0},Zc=e=>{const t=e.value;return!yc(t)&&t.length!==void 0},as={number:"number",bigint:"bigint",object:"date"},Bc=S("$ZodCheckLessThan",(e,t)=>{Ze.init(e,t);const n=as[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:as[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})}}),Hc=S("$ZodCheckGreaterThan",(e,t)=>{Ze.init(e,t);const n=as[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:as[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})}}),_g=S("$ZodCheckMultipleOf",(e,t)=>{Ze.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):vc(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})}}),kg=S("$ZodCheckNumberFormat",(e,t)=>{Ze.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=_c[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<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),Sg=S("$ZodCheckBigIntFormat",(e,t)=>{Ze.init(e,t);const[n,r]=kc[t.format];e._zod.check=i=>{const o=i.value;o<n&&i.issues.push({origin:"bigint",input:o,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),o>r&&i.issues.push({origin:"bigint",input:o,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),xg=S("$ZodCheckMaxSize",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=jc),e._zod.check=r=>{const i=r.value;i.size<=t.maximum||r.issues.push({origin:$s(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Eg=S("$ZodCheckMinSize",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=jc),e._zod.check=r=>{const i=r.value;i.size>=t.minimum||r.issues.push({origin:$s(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),$g=S("$ZodCheckSizeEquals",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=jc),e._zod.check=r=>{const i=r.value,o=i.size;if(o===t.size)return;const s=o>t.size;r.issues.push({origin:$s(i),...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})}}),Tg=S("$ZodCheckMaxLength",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=Zc),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>t.maximum?_i(i):o)<=t.maximum)return;const a=Ts(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Cg=S("$ZodCheckMinLength",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=Zc),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>=t.minimum&&o<t.minimum*2?_i(i):o)>=t.minimum)return;const a=Ts(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Ag=S("$ZodCheckLengthEquals",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=Zc),e._zod.check=r=>{const i=r.value,o=i.length,s=typeof i=="string"&&o>=t.length&&o<=t.length*2?_i(i):o;if(s===t.length)return;const a=Ts(i),u=s>t.length;r.issues.push({origin:a,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Ai=S("$ZodCheckStringFormat",(e,t)=>{var n,r;Ze.init(e,t),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Ig=S("$ZodCheckRegex",(e,t)=>{Ai.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})}}),Ng=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=vg),Ai.init(e,t)}),Rg=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=bg),Ai.init(e,t)}),Lg=S("$ZodCheckIncludes",(e,t)=>{Ze.init(e,t);const n=ln(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),zg=S("$ZodCheckStartsWith",(e,t)=>{Ze.init(e,t);const n=new RegExp(`^${ln(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})}}),Pg=S("$ZodCheckEndsWith",(e,t)=>{Ze.init(e,t);const n=new RegExp(`.*${ln(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 us(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues))}const Dg=S("$ZodCheckProperty",(e,t)=>{Ze.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(i=>us(i,n,t.property));us(r,n,t.property)}}),Og=S("$ZodCheckProperties",(e,t)=>{Ze.init(e,t),Cs(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 i=r.value;let o;for(const[s,a]of n){const u=a._zod.run({value:i[s],issues:[]},{});u instanceof Promise?(o??(o=[]),o.push(u.then(c=>us(c,r,s)))):us(u,r,s)}if(o)return Promise.all(o).then(()=>{})}}),Mg=S("$ZodCheckMimeType",(e,t)=>{Ze.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})}}),Fg=S("$ZodCheckOverwrite",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Vc{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 nk=(function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"})(),rk=function(e,t){return new URL(e,t).href},lh={},ik=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){let c=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]"),u=a?.nonce||a?.getAttribute("nonce");i=c(n.map(l=>{if(l=rk(l,r),l in lh)return;lh[l]=!0;const d=l.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(r)for(let p=s.length-1;p>=0;p--){const m=s[p];if(m.href===l&&(!d||m.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${l}"]${f}`))return;const h=document.createElement("link");if(h.rel=d?"stylesheet":nk,d||(h.as="script"),h.crossOrigin="",h.href=l,u&&h.setAttribute("nonce",u),document.head.appendChild(h),d)return new Promise((p,m)=>{h.addEventListener("load",p),h.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${l}`)))})}))}function o(s){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=s,window.dispatchEvent(a),!a.defaultPrevented)throw s}return i.then(s=>{for(const a of s||[])a.status==="rejected"&&o(a.reason);return t().catch(o)})};function ok(e){return e}function sk(e){return e}function Ss(){return e=>e}function ak(e){}function uk(e){throw new Error("Unexpected value in exhaustive check")}function ck(e){}function is(e){const t=Object.values(e).filter(r=>typeof r=="number");return Object.entries(e).filter(([r,i])=>t.indexOf(+r)===-1).map(([r,i])=>i)}function Lu(e,t="|"){return e.map(n=>wc(n)).join(t)}function os(e,t){return typeof t=="bigint"?t.toString():t}class lk{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 bi(e){return new lk(e)}function yc(e){return e==null}function Tn(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function vc(e,t){const n=e/t,r=Math.round(n),i=4*Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}const dh=Symbol("evaluating");function gm(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==dh)return r===void 0&&(r=dh,r=n()),r},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}function dk(e){return Object.create(Object.getPrototypeOf(e),Object.getOwnPropertyDescriptors(e))}function Tt(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Es(e){const t=Object.getOwnPropertyDescriptor(e,"shape");return t?.get?t.get.raw:t?.value}function cn(e){return Es(e._zod.def)??e._zod.def.shape}function ym(e,t,n){Object.defineProperty(e,t,{get(){const r=n();return Tt(this,t,r),r},enumerable:!0,configurable:!0})}function vm(e,t,n){t in e?Tt(e,t,n):e[t]=n}function Bn(e,t,n,r){const i=cn(t);for(const o of n){const s=Object.getOwnPropertyDescriptor(i,o);s.enumerable&&(s.get?ym(e,o,()=>{const a=t._zod.def.shape[o];return r?r(a,o):a}):vm(e,o,r?r(s.value,o):s.value))}}function fk(e,t){for(const n of Reflect.ownKeys(t)){const r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?ym(e,n,()=>t[n]):vm(e,n,r.value))}}function lt(...e){const t={};for(const n of e){const r=Object.getOwnPropertyDescriptors(n);Object.assign(t,r)}return Object.defineProperties({},t)}function hk(e){return lt(e._zod.def)}function pk(e,t){return t?t.reduce((n,r)=>n?.[r],e):e}function mk(e){const t=Object.keys(e),n=t.map(r=>e[r]);return Promise.all(n).then(r=>{const i={};for(let o=0;o<t.length;o++)i[t[o]]=r[o];return i})}function gk(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 Et(e){return JSON.stringify(e)}function bm(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const bc="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function sr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const wm=bi(()=>{if(vt.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function ln(e){if(sr(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(sr(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function wi(e){return ln(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}function yk(e){let t=0;for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&t++;return t}const vk=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}`)}},ss=new Set(["string","number","symbol"]),_m=new Set(["string","number","bigint","boolean","symbol","undefined"]);function dn(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function je(e,t,n){const r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function N(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 bk(e){let t;return new Proxy({},{get(n,r,i){return t??(t=e()),Reflect.get(t,r,i)},set(n,r,i,o){return t??(t=e()),Reflect.set(t,r,i,o)},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,i){return t??(t=e()),Reflect.defineProperty(t,r,i)}})}function wc(e){return typeof e=="bigint"?e.toString()+"n":typeof e=="string"?`"${e}"`:`${e}`}function km(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout==="optional")}const _c={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]},kc={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};function Sm(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 o={};return Bn(o,e,xs(e,t)),je(e,lt(n,{shape:o,checks:[]}))}function xs(e,t){const n=cn(e),r=[];for(const i of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,i)?.enumerable)throw new Error(`Unrecognized key: "${String(i)}"`);t[i]&&r.push(i)}return r}function Em(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 o=new Set(xs(e,t)),s={};return Bn(s,e,Reflect.ownKeys(cn(e)).filter(a=>!o.has(a))),je(e,lt(n,{shape:s,checks:[]}))}function xm(e,t){if(!ln(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=cn(e);for(const o of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(i,o)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return je(e,lt(e._zod.def,{shape:$m(e,t)}))}function $m(e,t){const n={};return Bn(n,e,Reflect.ownKeys(cn(e))),fk(n,t),n}function Tm(e,t){if(!ln(t))throw new Error("Invalid input to safeExtend: expected a plain object");return je(e,lt(e._zod.def,{shape:$m(e,t)}))}function Cm(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={};Bn(n,e,Reflect.ownKeys(cn(e))),Bn(n,t,Reflect.ownKeys(cn(t)));const r=lt(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return je(e,r)}function zu(e,t,n,r="partial"){const o=t._zod.def.checks;if(o&&o.length>0)throw new Error(`.${r}() cannot be used on object schemas containing refinements`);const a=n?new Set(xs(t,n)):void 0,u={};return Bn(u,t,Reflect.ownKeys(cn(t)),e&&((c,l)=>a&&!a.has(l)?c:new e({type:"optional",innerType:c}))),je(t,lt(t._zod.def,{shape:u,checks:[]}))}function Am(e,t,n){const r=n?new Set(xs(t,n)):void 0,i={};return Bn(i,t,Reflect.ownKeys(cn(t)),(o,s)=>r&&!r.has(s)?o:new e({type:"nonoptional",innerType:o})),je(t,lt(t._zod.def,{shape:i}))}function wt(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 Im(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 zt(e,t){return t.map(n=>{var r;return(r=n).path??(r.path=[]),n.path.unshift(e),n})}function er(e){return typeof e=="string"?e:e?.message}function Pu(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Dt(e,t,n){var r;const i=e.inst?._zod?.traits;i?.has("$ZodType")&&(i.has("$ZodCheck")?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);const o=e.schema!==e.inst?e.schema?._zod.def?.error:void 0,s=e.message?e.message:er(e.inst?._zod.def?.error?.(e))??er(o?.(e))??er(t?.error?.(e))??er(n.customError?.(e))??er(n.localeError?.(e))??"Invalid input",a={};for(const u of Object.keys(e))u==="inst"||u==="schema"||u==="continue"||u==="input"||u==="__proto__"||(a[u]=e[u]);return a.path??(a.path=[]),a.message=s,t?.reportInput&&(a.input=e.input),a}function $s(e){return e instanceof Set?"set":e instanceof Map?"map":e instanceof File?"file":"unknown"}const wk=/[\uD800-\uDBFF]/;function _i(e){const t=e.length;if(!wk.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 Ts(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Nm(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 ar(...e){const[t,n,r]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:r}:{...t}}function _k(e){return Object.entries(e).filter(([t,n])=>Number.isNaN(Number.parseInt(t,10))).map(t=>t[1])}function Rm(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 Lm(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function kk(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n="=".repeat((4-t.length%4)%4);return Rm(t+n)}function Sk(e){return Lm(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Ek(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 xk(e){return Array.from(e).map(t=>t.toString(16).padStart(2,"0")).join("")}class $k{constructor(...t){}}function zm(e,t){for(const n in t){const r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):Tk(e,n,r.value)}}function fn(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function Cs(e,t,n){return fn(e,t,n,!1)}function ki(e,t){for(const n in e){const r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return fn(this,n,r(this))},set(i){fn(this,n,i)}})}return t}function Tk(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:fn(this,t,n.bind(this))},set(r){fn(this,t,r)}})}function Ck(e,t){const n=Object.getPrototypeOf(e);return t in n?void 0:n}let eu,_n=!1;const Ak={configurable:!0,get(){_n=!0}};function Se(e,t,n){const r=Object.getPrototypeOf(e._zod);if(t in r&&eu!==e._zod){eu=void 0;return}eu=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Ak);const i=_n;_n=!1;try{const o=n(this);return _n?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:o}),_n=_n||i,o}catch(o){throw delete this[t],_n=_n||i,o}},set(i){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:i})}})}function Pm(e,t,n,r){const i=Ck(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){const o={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,o),o.value=n(this),Object.defineProperty(this,t,o),o.value},set(o){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:o})}})}const Sc="~constantCatch";function Ec(e){const t=()=>e;return t[Sc]=!0,t}const xc=Object.freeze(Object.defineProperty({__proto__:null,BIGINT_FORMAT_RANGES:kc,CONSTANT_CATCH:Sc,Class:$k,NUMBER_FORMAT_RANGES:_c,aborted:wt,allowsEval:wm,assert:ck,assertEqual:ok,assertIs:ak,assertNever:uk,assertNotEqual:sk,assignProp:Tt,attachSchema:Pu,base64ToUint8Array:Rm,base64urlToUint8Array:kk,cached:bi,captureStackTrace:bc,cleanEnum:_k,cleanRegex:Tn,clone:je,cloneDef:hk,codePointLength:_i,constantCatch:Ec,createTransparentProxy:bk,defineLazy:gm,defineLazyInternal:Se,derived:ki,esc:Et,escapeRegex:dn,explicitlyAborted:Im,extend:xm,finalizeIssue:Dt,floatSafeRemainder:vc,getElementAtPath:pk,getEnumValues:is,getLengthableOrigin:Ts,getParsedType:vk,getSizableOrigin:$s,hexToUint8Array:Ek,hide:Cs,installLazyProp:Pm,isObject:sr,isPlainObject:ln,issue:ar,joinValues:Lu,jsonStringifyReplacer:os,members:zm,merge:Cm,mergeDefs:lt,normalizeParams:N,nullish:yc,numKeys:yk,objectClone:dk,omit:Em,optionalKeys:km,own:fn,parsedType:Nm,partial:zu,pick:Sm,prefixIssues:zt,primitiveTypes:_m,promiseAllObject:mk,propertyKeyTypes:ss,randomString:gk,rawShape:Es,required:Am,safeExtend:Tm,shallowClone:wi,slugify:bm,stringifyPrimitive:wc,toZod:Ss,uint8ArrayToBase64:Lm,uint8ArrayToBase64url:Sk,uint8ArrayToHex:xk,unwrapMessage:er},Symbol.toStringTag,{value:"Module"}));var fh;const $c=Object.freeze({status:"aborted"}),tu={value:void 0,enumerable:!1};let hh="captureStackTrace"in Error?Error:null;function Ik(e){const t=hh;if(t){const n=t.stackTraceLimit;if(typeof n=="number"){try{t.stackTraceLimit=0}catch{return hh=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function S(e,t,n,r){const i={};function o(f){this.def=f,this.constr=d,this.traits=new Set}o.prototype=i;const s=n,a=s&&new WeakSet;function u(f,h){if(f._zod){if(f._zod.traits.has(e))return}else{tu.value=new o(h);try{Object.defineProperty(f,"_zod",tu)}finally{tu.value=void 0}}if(f._zod.traits.add(e),t(f,h),a){const m=Object.getPrototypeOf(f),y=f._zod.constr.prototype;let w=m;for(;w&&w!==y;)w=Object.getPrototypeOf(w);const g=w??m;a.has(g)||(a.add(g),zm(g,s))}const p=d.prototype;for(const m in p)Object.prototype.hasOwnProperty.call(p,m)&&(m in f||(f[m]=p[m].bind(f)))}const c=r?.Parent??Object;class l extends c{}Object.defineProperty(l,"name",{value:e});function d(f){const h=r?.Parent?Ik(l):this;u(h,f);const p=h._zod.deferred;if(p){for(const y of p)y();h._zod.deferred=void 0}const m=globalThis.__zod_globalConfig?.postProcessor;return m&&m(h),h}return Object.defineProperty(d,"init",{value:u}),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 Tc=Symbol("zod_brand");class an extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class As extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(fh=globalThis).__zod_globalConfig??(fh.__zod_globalConfig={});const vt=globalThis.__zod_globalConfig;function et(e){return e&&Object.assign(vt,e),vt}function Nk(){const e=this._zod;return e.message??(e.message=JSON.stringify(e.def,os,2)),e.message}function Rk(e){this._zod.message=e}const Lk={get:Nk,set:Rk,enumerable:!0,configurable:!0},nu={value:void 0,enumerable:!1},ph=new WeakSet([Object.prototype,Error.prototype]),Om=(e,t)=>{e.name="$ZodError",nu.value=t,Object.defineProperty(e,"issues",nu),nu.value=void 0,Object.defineProperty(e,"message",Lk);const n=Object.getPrototypeOf(e);ph.has(n)||(ph.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})}}))},Dm=S("$ZodError",Om),Ct=S("$ZodError",Om,void 0,{Parent:Error});function zk(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 Is(e,t=n=>n.message){const n={},r=[];for(const i of e.issues)i.path.length>0?zk(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ns(e,t=n=>n.message){const n={_errors:[]},r=(i,o=[])=>{for(const s of i.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>r({issues:a},[...o,...s.path]));else if(s.code==="invalid_key")r({issues:s.issues},[...o,...s.path]);else if(s.code==="invalid_element")r({issues:s.issues},[...o,...s.path]);else{const a=[...o,...s.path];if(a.length===0)n._errors.push(t(s));else{let u=n,c=0;for(;c<a.length;){const l=a[c],d=c===a.length-1;if(l==="_errors"){d&&u._errors.push(t(s)),c++;continue}Object.prototype.hasOwnProperty.call(u,l)||Object.defineProperty(u,l,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});const f=u[l];d&&f._errors.push(t(s)),u=f,c++}}}};return r(e),n}function Cc(e,t=n=>n.message){const n={errors:[]},r=(i,o=[])=>{var s;for(const a of i.issues)if(a.code==="invalid_union"&&a.errors.length)a.errors.map(u=>r({issues:u},[...o,...a.path]));else if(a.code==="invalid_key")r({issues:a.issues},[...o,...a.path]);else if(a.code==="invalid_element")r({issues:a.issues},[...o,...a.path]);else{const u=[...o,...a.path];if(u.length===0){n.errors.push(t(a));continue}let c=n,l=0;for(;l<u.length;){const d=u[l],f=l===u.length-1;typeof d=="string"?(c.properties??(c.properties={}),Object.prototype.hasOwnProperty.call(c.properties,d)||Object.defineProperty(c.properties,d,{value:{errors:[]},enumerable:!0,writable:!0,configurable:!0}),c=c.properties[d]):(c.items??(c.items=[]),(s=c.items)[d]??(s[d]={errors:[]}),c=c.items[d]),f&&c.errors.push(t(a)),l++}}};return r(e),n}function Mm(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 Ac(e){const t=[],n=[...e.issues].sort((r,i)=>(r.path??[]).length-(i.path??[]).length);for(const r of n)t.push(`✖ ${r.message}`),r.path?.length&&t.push(` → at ${Mm(r.path)}`);return t.join(`
|
|
10
|
+
`)}function Rs(e,t){return{callee:t?.callee??e,Err:t?.Err}}const Si=e=>{const t=(n,r,i,o)=>{const s=i?{...i,async:!1}:{async:!1},a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise)throw new an;if(a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Dt(c,s,et())));throw bc(u,o?.callee??t),u}return a.value};return t},Ou=Si(Ct),Ei=e=>{const t=async(n,r,i,o)=>{const s=i?{...i,async:!0}:{async:!0};let a=n._zod.run({value:r,issues:[]},s);if(a instanceof Promise&&(a=await a),a.issues.length){const u=new(o?.Err??e)(a.issues.map(c=>Dt(c,s,et())));throw bc(u,o?.callee??t),u}return a.value};return t},Du=Ei(Ct),xi=e=>(t,n,r)=>{const i=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},i);if(o instanceof Promise)throw new an;return o.issues.length?Um(e,o.issues,i):{success:!0,data:o.value}},Fm=xi(Ct);function Um(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(i=>Dt(i,n,et()))),t=void 0,n=void 0),r},set error(i){r=i,t=void 0,n=void 0}}}const $i=e=>async(t,n,r)=>{const i=r?{...r,async:!0}:{async:!0};let o=t._zod.run({value:n,issues:[]},i);return o instanceof Promise&&(o=await o),o.issues.length?Um(e,o.issues,i):{success:!0,data:o.value}},Pk=$i(Ct),Ok=Symbol.for("zod.compile.invalid"),Dk=Symbol.for("zod.compile.fallback"),Ls=((e,t,n)=>{const r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Ok)return!0;if(r.definite===!0&&n===void 0)return!1}return Mk(e,t,n)});function Mk(e,t,n){const r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun;let o;if(i?(r[Dk]=!0,o=i({value:t,issues:[]},r)):o=e._zod.run({value:t,issues:[]},r),o instanceof Promise)throw new an;return o.issues.length===0}const zs=async(e,t,n)=>{const r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0};let i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Ic=e=>{const t=Si(e),n=(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return t(r,i,a,Rs(n,s))};return n},Fk=Ic(Ct),Nc=e=>{const t=Si(e),n=(r,i,o,s)=>t(r,i,o,Rs(n,s));return n},Uk=Nc(Ct),Rc=e=>{const t=Ei(e),n=async(r,i,o,s)=>{const a=o?{...o,direction:"backward"}:{direction:"backward"};return await t(r,i,a,Rs(n,s))};return n},Gk=Rc(Ct),Lc=e=>{const t=Ei(e),n=async(r,i,o,s)=>await t(r,i,o,Rs(n,s));return n},jk=Lc(Ct),zc=e=>(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return xi(e)(t,n,i)},Zk=zc(Ct),Pc=e=>(t,n,r)=>xi(e)(t,n,r),Bk=Pc(Ct),Oc=e=>async(t,n,r)=>{const i=r?{...r,direction:"backward"}:{direction:"backward"};return $i(e)(t,n,i)},Hk=Oc(Ct),Dc=e=>async(t,n,r)=>$i(e)(t,n,r),Vk=Dc(Ct),Gm=/^[cC][0-9a-z]{6,}$/,jm=/^[0-9a-z]+$/,Zm=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Bm=/^[0-9a-vA-V]{20}$/,Hm=/^[A-Za-z0-9]{27}$/,Vm=/^[a-zA-Z0-9_-]{21}$/;function qm(e){return new RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}const Wm=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qk=/^[-+]?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)?)??$/,Km=/^([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})$/,ur=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)$/,Wk=ur(4),Kk=ur(6),Jk=ur(7),Jm=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Yk=/^[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])?)*$/,Xk=/^(([^<>()\[\]\\.,;:\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,}))$/,Ym=/^[^\s@"]{1,64}@[^\s@]{1,255}$/u,Qk=Ym,eS=/^[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])?)*$/,tS="^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$";function Xm(){return new RegExp(tS,"u")}const Qm=/^(?:(?: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])$/,eg=/^(([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}|:))$/,tg=e=>{const t=dn(e??":");return new RegExp(`^(?:[0-9A-F]{2}${t}){5}[0-9A-F]{2}$|^(?:[0-9a-f]{2}${t}){5}[0-9a-f]{2}$`)},ng=/^((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])$/,rg=/^(([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])$/,ig=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,og=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,sg=/^(?=.{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])?)*\.?$/,ag=/^(?=.{1,253}$)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,63}$/,Mc=/^https?$/,ug=/^\+[1-9]\d{6,14}$/,Fc=/^\d(?:[ -]?\d){11,18}$/,cg=/^(?: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)$/,Uc=/^[A-Z]{2}(?!00|01|99)\d{2}[A-Z0-9]{11,30}$/,lg="(?:(?:\\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 nS(e){return new RegExp(`^${e}$`)}const dg=nS(lg);function Mu(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 fg(e){return new RegExp(`^${Mu(e)}$`)}function hg(e){const t=["Z"];e.offset&&t.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const n=`${Mu({precision:e.precision,seconds:!0})}(?:${t.join("|")})`,r=e.local?`${n}|${Mu({precision:e.precision})}`:n;return new RegExp(`^${lg}T(?:${r})$`)}const pg=/^[\s\S]{0,}$/,mg=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},gg=/^-?\d+n?$/,Gc=/^-?\d+$/,wr=/^-?\d+(?:\.\d+)?$/,yg=/^(?:true|false)$/i,vg=/^null$/i,bg=/^undefined$/i,wg=/^[^A-Z]*$/,_g=/^[^a-z]*$/,kg=/^[0-9a-fA-F]*$/;function Ti(e,t){return new RegExp(`^[A-Za-z0-9+/]{${e}}${t}$`)}function Ci(e){return new RegExp(`^[A-Za-z0-9_-]{${e}}$`)}const rS=/^[0-9a-fA-F]{32}$/,iS=Ti(22,"=="),oS=Ci(22),sS=/^[0-9a-fA-F]{40}$/,aS=Ti(27,"="),uS=Ci(27),cS=/^[0-9a-fA-F]{64}$/,lS=Ti(43,"="),dS=Ci(43),fS=/^[0-9a-fA-F]{96}$/,hS=Ti(64,""),pS=Ci(64),mS=/^[0-9a-fA-F]{128}$/,gS=Ti(86,"=="),yS=Ci(86),Ps=Object.freeze(Object.defineProperty({__proto__:null,anyString:pg,base64:ig,base64url:og,bigint:gg,boolean:yg,browserEmail:eS,cidrv4:ng,cidrv6:rg,creditCard:Fc,cuid:Gm,cuid2:jm,currencyCode:cg,date:dg,datetime:hg,domain:ag,duration:Wm,e164:ug,email:Jm,emoji:Xm,extendedDuration:qk,guid:Km,hex:kg,hostname:sg,html5Email:Yk,httpProtocol:Mc,iban:Uc,idnEmail:Qk,integer:Gc,ipv4:Qm,ipv6:eg,ksuid:Hm,lowercase:wg,mac:tg,md5_base64:iS,md5_base64url:oS,md5_hex:rS,nanoid:Vm,nanoidOfLength:qm,null:vg,number:wr,rfc5322Email:Xk,sha1_base64:aS,sha1_base64url:uS,sha1_hex:sS,sha256_base64:lS,sha256_base64url:dS,sha256_hex:cS,sha384_base64:hS,sha384_base64url:pS,sha384_hex:fS,sha512_base64:gS,sha512_base64url:yS,sha512_hex:mS,string:mg,time:fg,ulid:Zm,undefined:bg,unicodeEmail:Ym,uppercase:_g,uuid:ur,uuid4:Wk,uuid6:Kk,uuid7:Jk,xid:Bm},Symbol.toStringTag,{value:"Module"})),Ze=S("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),jc=e=>{const t=e.value;return!yc(t)&&t.size!==void 0},Zc=e=>{const t=e.value;return!yc(t)&&t.length!==void 0},as={number:"number",bigint:"bigint",object:"date"},Bc=S("$ZodCheckLessThan",(e,t)=>{Ze.init(e,t);const n=as[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:as[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})}}),Hc=S("$ZodCheckGreaterThan",(e,t)=>{Ze.init(e,t);const n=as[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:as[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})}}),Sg=S("$ZodCheckMultipleOf",(e,t)=>{Ze.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):vc(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})}}),Eg=S("$ZodCheckNumberFormat",(e,t)=>{Ze.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),r=n?"int":"number",[i,o]=_c[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<i&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),a>o&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:o,inclusive:!0,inst:e,continue:!t.abort})}}),xg=S("$ZodCheckBigIntFormat",(e,t)=>{Ze.init(e,t);const[n,r]=kc[t.format];e._zod.check=i=>{const o=i.value;o<n&&i.issues.push({origin:"bigint",input:o,code:"too_small",minimum:n,inclusive:!0,inst:e,continue:!t.abort}),o>r&&i.issues.push({origin:"bigint",input:o,code:"too_big",maximum:r,inclusive:!0,inst:e,continue:!t.abort})}}),$g=S("$ZodCheckMaxSize",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=jc),e._zod.check=r=>{const i=r.value;i.size<=t.maximum||r.issues.push({origin:$s(i),code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Tg=S("$ZodCheckMinSize",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=jc),e._zod.check=r=>{const i=r.value;i.size>=t.minimum||r.issues.push({origin:$s(i),code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Cg=S("$ZodCheckSizeEquals",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=jc),e._zod.check=r=>{const i=r.value,o=i.size;if(o===t.size)return;const s=o>t.size;r.issues.push({origin:$s(i),...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})}}),Ag=S("$ZodCheckMaxLength",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=Zc),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>t.maximum?_i(i):o)<=t.maximum)return;const a=Ts(i);r.issues.push({origin:a,code:"too_big",maximum:t.maximum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Ig=S("$ZodCheckMinLength",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=Zc),e._zod.check=r=>{const i=r.value,o=i.length;if((typeof i=="string"&&o>=t.minimum&&o<t.minimum*2?_i(i):o)>=t.minimum)return;const a=Ts(i);r.issues.push({origin:a,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}}),Ng=S("$ZodCheckLengthEquals",(e,t)=>{var n;Ze.init(e,t),(n=e._zod.def).when??(n.when=Zc),e._zod.check=r=>{const i=r.value,o=i.length,s=typeof i=="string"&&o>=t.length&&o<=t.length*2?_i(i):o;if(s===t.length)return;const a=Ts(i),u=s>t.length;r.issues.push({origin:a,...u?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:r.value,inst:e,continue:!t.abort})}}),Ai=S("$ZodCheckStringFormat",(e,t)=>{var n,r;Ze.init(e,t),t.pattern?(n=e._zod).check??(n.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Rg=S("$ZodCheckRegex",(e,t)=>{Ai.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})}}),Lg=S("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=wg),Ai.init(e,t)}),zg=S("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=_g),Ai.init(e,t)}),Pg=S("$ZodCheckIncludes",(e,t)=>{Ze.init(e,t);const n=dn(t.includes),r=new RegExp(typeof t.position=="number"?`^.{${t.position},}${n}`:n);t.pattern=r,e._zod.check=i=>{i.value.includes(t.includes,t.position)||i.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:i.value,inst:e,continue:!t.abort})}}),Og=S("$ZodCheckStartsWith",(e,t)=>{Ze.init(e,t);const n=new RegExp(`^${dn(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})}}),Dg=S("$ZodCheckEndsWith",(e,t)=>{Ze.init(e,t);const n=new RegExp(`.*${dn(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 us(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues))}const Mg=S("$ZodCheckProperty",(e,t)=>{Ze.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(i=>us(i,n,t.property));us(r,n,t.property)}}),Fg=S("$ZodCheckProperties",(e,t)=>{Ze.init(e,t),Cs(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 i=r.value;let o;for(const[s,a]of n){const u=a._zod.run({value:i[s],issues:[]},{});u instanceof Promise?(o??(o=[]),o.push(u.then(c=>us(c,r,s)))):us(u,r,s)}if(o)return Promise.all(o).then(()=>{})}}),Ug=S("$ZodCheckMimeType",(e,t)=>{Ze.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})}}),Gg=S("$ZodCheckOverwrite",(e,t)=>{Ze.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Vc{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),i=Math.min(...r.map(s=>s.length-s.trimStart().length)),o=r.map(s=>s.slice(i)).map(s=>" ".repeat(this.indent*2)+s);for(const s of o)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 Ug={major:4,minor:6,patch:5},pe=S("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ug;const r=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const o of i)for(const s of o._zod.onattach)s(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,u,c)=>{if(a.memo)return a;let l=wt(a),d;for(const f of u){if(f._zod.def.when){if(Cm(a)||!f._zod.def.when(a))continue}else if(l)continue;const h=a.issues.length,p=f._zod.check(a);if(p instanceof Promise&&c?.async===!1)throw new sn;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,a.issues.length!==h&&(Pu(a.issues,h,e),l||(l=wt(a,h)))});else{if(a.issues.length===h)continue;Pu(a.issues,h,e),l||(l=wt(a,h))}}return d?d.then(()=>a):a},s=(a,u,c)=>{if(wt(a))return a.aborted=!0,a;const l=o(u,i,c);if(l instanceof Promise){if(c.async===!1)throw new sn;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(a,u)=>{if(u.skipChecks)return e._zod.parse(a,u);if(u.direction==="backward"){const l=e._zod.parse({value:a.value,issues:[]},{...u,skipChecks:!0});return l instanceof Promise?l.then(d=>s(d,a,u)):s(l,a,u)}const c=e._zod.parse(a,u);if(c instanceof Promise){if(u.async===!1)throw new sn;return c.then(l=>o(l,i,u))}return o(c,i,u)}}},{get"~standard"(){return Cs(this,"~standard",qc(this))},set"~standard"(e){dn(this,"~standard",e)}}),Gg=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Ot(n,t,et()))}:{value:e.value};async function mS(e,t){const n={async:!0};return Gg(await e._zod.run({value:t,issues:[]},n),n)}function qc(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Gg(r,n)}catch{}return mS(e,t)},vendor:"zod",version:1}}const Ii=S("$ZodString",(e,t)=>{pe.init(e,t),e._zod.pattern=t.pattern??fg,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}}),Fe=S("$ZodStringFormat",(e,t)=>{Ai.init(e,t),Ii.init(e,t)}),jg=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=qm),Fe.init(e,t)}),Zg=S("$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=ur(r))}else t.pattern??(t.pattern=ur());Fe.init(e,t)}),Bg=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Wm),Fe.init(e,t)}),Wc=1,ai=2;function Kc(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Jc(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Kc(e)||ai:Hg(e,t)}function Hg(e,t){if(!t.normalize&&t.protocol?.source===Mc.source&&!/^https?:\/\//i.test(e))return Wc;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??ai}return new URL(e)}catch{return ai}}const gS=/[\t\n\r]/g;function cs(e){return e.replace(gS,"")}function Yc(e,t){return t.lastIndex=0,t.test(e.hostname)}function Xc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const Vg=S("$ZodURL",(e,t)=>{Fe.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=Jc(r,t);if(i===Wc){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===ai){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=cs(r);return}t.hostname&&!Yc(i,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&&!Xc(i,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?i.href:cs(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),qg=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Jm()),Fe.init(e,t)}),Wg=S("$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?Bm:Hm(t.length)),Fe.init(e,t)}),Kg=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Fm),Fe.init(e,t)}),Jg=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Um),Fe.init(e,t)}),Yg=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Gm),Fe.init(e,t)}),Xg=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=jm),Fe.init(e,t)}),Qg=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Zm),Fe.init(e,t)}),ey=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=dg(t)),Fe.init(e,t)}),ty=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=cg),Fe.init(e,t)}),ny=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=lg(t)),Fe.init(e,t)}),ry=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Vm),Fe.init(e,t)}),iy=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Ym),Fe.init(e,t)}),yS=/^[0-9a-fA-F:.]+$/;function Ds(e){return yS.test(e)?Kc(`http://[${e}]`):!1}const oy=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xm),Fe.init(e,t),e._zod.check=n=>{Ds(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),sy=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=Qm(t.delimiter)),Fe.init(e,t)}),ay=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=eg),Fe.init(e,t)});function Qc(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const i=Number(r);return`${i}`!==r||i<0||i>128?!1:Ds(n)}const uy=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=tg),Fe.init(e,t),e._zod.check=n=>{Qc(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Os(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const el=/^[0-9a-zA-Z+/]*={0,2}$/,cy=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=el),Fe.init(e,t),e._zod.check=n=>{Os(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Ms=/^[A-Za-z0-9_-]*$/;function tl(e){if(!Ms.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Os(n)}const ly=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ms),Fe.init(e,t),e._zod.check=n=>{tl(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),dy=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=sg),Fe.init(e,t)}),vS=/[- ]/g;function bS(e){let t=e.length,n=1,r=0;for(;t;){const i=e.charCodeAt(--t)-48;n^=1,r+=n?[0,2,4,6,8,1,3,5,7,9][i]:i}return r%10===0}function nl(e){return Fc.test(e)?bS(e.replace(vS,"")):!1}const fy=S("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=Fc),Fe.init(e,t),e._zod.check=n=>{nl(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function wS(e){let t=0;const n=e.length;for(let r=4;r<n;r++){const i=e.charCodeAt(r);t=(i>=65?t*100+(i-55):t*10+(i-48))%97}for(let r=0;r<4;r++){const i=e.charCodeAt(r);t=(i>=65?t*100+(i-55):t*10+(i-48))%97}return t===1}function rl(e){return Uc.test(e)?wS(e):!1}const hy=S("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=Uc),Fe.init(e,t),e._zod.check=n=>{rl(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function il(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const py=S("$ZodJWT",(e,t)=>{Fe.init(e,t),e._zod.check=n=>{il(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),my=S("$ZodCustomStringFormat",(e,t)=>{Fe.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})}}),ol=S("$ZodNumber",(e,t)=>{pe.init(e,t),e._zod.pattern=wr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),gy=S("$ZodNumberFormat",(e,t)=>{kg.init(e,t),ol.init(e,t)}),sl=S("$ZodBoolean",(e,t)=>{pe.init(e,t),e._zod.pattern=mg,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),al=S("$ZodBigInt",(e,t)=>{pe.init(e,t),e._zod.pattern=pg,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}}),yy=S("$ZodBigIntFormat",(e,t)=>{Sg.init(e,t),al.init(e,t)}),vy=S("$ZodSymbol",(e,t)=>{pe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return typeof i=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:i,inst:e}),n}}),by=S("$ZodUndefined",(e,t)=>{pe.init(e,t),e._zod.pattern=yg,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{const i=n.value;return typeof i>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),n}}),wy=S("$ZodNull",(e,t)=>{pe.init(e,t),e._zod.pattern=gg,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),_y=S("$ZodAny",(e,t)=>{pe.init(e,t),e._zod.parse=n=>n}),ky=S("$ZodUnknown",(e,t)=>{pe.init(e,t),e._zod.parse=n=>n}),Sy=S("$ZodNever",(e,t)=>{pe.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),xy=S("$ZodVoid",(e,t)=>{pe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return typeof i>"u"||n.issues.push({expected:"void",code:"invalid_type",input:i,inst:e}),n}}),Ey=S("$ZodDate",(e,t)=>{pe.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const i=n.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),n}});function ph(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues)),t.value[n]=e.value}const $y=S("$ZodArray",(e,t)=>{pe.init(e,t);const n=vt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=n?n.alloc(e,r,Array(o.length),i):Array(o.length);const s=[],a=i?.abortEarly;for(let u=0;u<o.length;u++){const c=o[u],l=t.element._zod.run({value:c,issues:[]},i);if(l instanceof Promise)s.push(l.then(d=>ph(d,r,u)));else if(ph(l,r,u),a&&l.issues.length!==0&&wt(l))break}return s.length?Promise.all(s).then(()=>r):r}});function ls(e,t,n,r,i,o){const s=n in r,a=o==="optional";if(!(!s&&a&&i==="optional")){if(e.issues.length){if(i!==void 0&&a&&!s)return;t.issues.push(...zt(n,e.issues))}if(!s&&i===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(s||i==="defaulted"&&!a)&&(t.value[n]=void 0):t.value[n]=e.value}}const _S=[];function Ty(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:_S,i=r.length?[...t,...r]:t;for(const s of i)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);const o=wm(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function Cy(e,t,n,r,i,o,s){const a=[],u=i.keySet,c=i.catchall._zod,l=c.def.type,d=c.optin,f=c.optout;let h=0;for(const p in t){if(s&&n.issues.length!==h){if(wt(n,h))break;h=n.issues.length}if(u.has(p))continue;if(p==="__proto__"){l==="never"&&a.push(p);continue}if(l==="never"){a.push(p);continue}const m=c.run({value:t[p],issues:[]},r);m instanceof Promise?e.push(m.then(y=>ls(y,n,p,t,d,f))):ls(m,n,p,t,d,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Ay=S("$ZodObject",(e,t)=>{pe.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const c=()=>{const l={...r};return Object.defineProperty(t,"shape",{value:l}),c.raw=l,l};c.raw=r,Object.defineProperty(t,"shape",{get:c})}const i=bi(()=>Ty(t));Se(e,"propValues",c=>{const l=c.def.shape,d={};for(const f in l){const h=l[f]._zod;if(h.values){Object.prototype.hasOwnProperty.call(d,f)||Tt(d,f,new Set);for(const p of h.values)d[f].add(p);h.optin!==void 0&&d[f].add(void 0)}}return d});const o=sr,s=t.catchall;let a;const u=vt.memoizer;u?.attach(e),e._zod.parse=(c,l)=>{a??(a=i.value);const d=c.value;if(!o(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value=u?u.alloc(e,c,{},l):{};const f=[],h=a.shape,p=l?.abortEarly;let m=c.issues.length;for(const y of a.allKeys){if(p&&c.issues.length!==m){if(wt(c,m))break;m=c.issues.length}if(y==="__proto__")continue;const w=h[y],g=w._zod.optin,b=w._zod.optout,v=w._zod.run({value:d[y],issues:[]},l);v instanceof Promise?f.push(v.then(k=>ls(k,c,y,d,g,b))):ls(v,c,y,d,g,b)}return s?Cy(f,d,c,l,i.value,e,p===!0):f.length?Promise.all(f).then(()=>c):c}}),Iy=S("$ZodObjectJIT",(e,t)=>{Ay.init(e,t);const n=e._zod.parse,r=bi(()=>Ty(t)),i=vt.memoizer,o=h=>{const p=r.value,m=p.symbolKeys,y=new Vc(["payload","ctx"],{shape:h,inst:e,memo:i,syms:m}),w=k=>`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`,g=(k,_)=>`
|
|
14
|
+
};`)(...Object.values(this.closed))}}const jg={major:4,minor:6,patch:5},me=S("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=jg;const r=e._zod.def.checks,i=e._zod.traits.has("$ZodCheck")?[e,...r??[]]:r?.length?[...r]:[];for(const o of i)for(const s of o._zod.onattach)s(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const o=(a,u,c)=>{if(a.memo)return a;let l=wt(a),d;for(const f of u){if(f._zod.def.when){if(Im(a)||!f._zod.def.when(a))continue}else if(l)continue;const h=a.issues.length,p=f._zod.check(a);if(p instanceof Promise&&c?.async===!1)throw new an;if(d||p instanceof Promise)d=(d??Promise.resolve()).then(async()=>{await p,a.issues.length!==h&&(Pu(a.issues,h,e),l||(l=wt(a,h)))});else{if(a.issues.length===h)continue;Pu(a.issues,h,e),l||(l=wt(a,h))}}return d?d.then(()=>a):a},s=(a,u,c)=>{if(wt(a))return a.aborted=!0,a;const l=o(u,i,c);if(l instanceof Promise){if(c.async===!1)throw new an;return l.then(d=>e._zod.parse(d,c))}return e._zod.parse(l,c)};e._zod.run=(a,u)=>{if(u.skipChecks)return e._zod.parse(a,u);if(u.direction==="backward"){const l=e._zod.parse({value:a.value,issues:[]},{...u,skipChecks:!0});return l instanceof Promise?l.then(d=>s(d,a,u)):s(l,a,u)}const c=e._zod.parse(a,u);if(c instanceof Promise){if(u.async===!1)throw new an;return c.then(l=>o(l,i,u))}return o(c,i,u)}}},{get"~standard"(){return Cs(this,"~standard",qc(this))},set"~standard"(e){fn(this,"~standard",e)}}),Zg=(e,t)=>e.issues.length?{issues:e.issues.map(n=>Dt(n,t,et()))}:{value:e.value};async function vS(e,t){const n={async:!0};return Zg(await e._zod.run({value:t,issues:[]},n),n)}function qc(e){return{validate:t=>{const n={async:!1};try{const r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Zg(r,n)}catch{}return vS(e,t)},vendor:"zod",version:1}}const Ii=S("$ZodString",(e,t)=>{me.init(e,t),e._zod.pattern=t.pattern??pg,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}}),Fe=S("$ZodStringFormat",(e,t)=>{Ai.init(e,t),Ii.init(e,t)}),Bg=S("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Km),Fe.init(e,t)}),Hg=S("$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=ur(r))}else t.pattern??(t.pattern=ur());Fe.init(e,t)}),Vg=S("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Jm),Fe.init(e,t)}),Wc=1,ai=2;function Kc(e){try{return typeof URL<"u"&&typeof URL.canParse=="function"?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Jc(e,t){return!("normalize"in t)&&!("hostname"in t)&&!("protocol"in t)?Kc(e)||ai:qg(e,t)}function qg(e,t){if(!t.normalize&&t.protocol?.source===Mc.source&&!/^https?:\/\//i.test(e))return Wc;try{if(typeof URL<"u"){const n=URL;if(typeof n.parse=="function")return n.parse(e)??ai}return new URL(e)}catch{return ai}}const bS=/[\t\n\r]/g;function cs(e){return e.replace(bS,"")}function Yc(e,t){return t.lastIndex=0,t.test(e.hostname)}function Xc(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(":")?e.protocol.slice(0,-1):e.protocol)}const Wg=S("$ZodURL",(e,t)=>{Fe.init(e,t),e._zod.check=n=>{try{const r=n.value.trim(),i=Jc(r,t);if(i===Wc){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}if(i===ai){n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=cs(r);return}t.hostname&&!Yc(i,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&&!Xc(i,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?i.href:cs(r);return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Kg=S("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Xm()),Fe.init(e,t)}),Jg=S("$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?Vm:qm(t.length)),Fe.init(e,t)}),Yg=S("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Gm),Fe.init(e,t)}),Xg=S("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=jm),Fe.init(e,t)}),Qg=S("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Zm),Fe.init(e,t)}),ey=S("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Bm),Fe.init(e,t)}),ty=S("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=Hm),Fe.init(e,t)}),ny=S("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=hg(t)),Fe.init(e,t)}),ry=S("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=dg),Fe.init(e,t)}),iy=S("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=fg(t)),Fe.init(e,t)}),oy=S("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Wm),Fe.init(e,t)}),sy=S("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Qm),Fe.init(e,t)}),wS=/^[0-9a-fA-F:.]+$/;function Os(e){return wS.test(e)?Kc(`http://[${e}]`):!1}const ay=S("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=eg),Fe.init(e,t),e._zod.check=n=>{Os(n.value)||n.issues.push({code:"invalid_format",format:"ipv6",input:n.value,inst:e,continue:!t.abort})}}),uy=S("$ZodMAC",(e,t)=>{t.pattern??(t.pattern=tg(t.delimiter)),Fe.init(e,t)}),cy=S("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=ng),Fe.init(e,t)});function Qc(e){const t=e.split("/");if(t.length!==2)return!1;const[n,r]=t;if(!r)return!1;const i=Number(r);return`${i}`!==r||i<0||i>128?!1:Os(n)}const ly=S("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=rg),Fe.init(e,t),e._zod.check=n=>{Qc(n.value)||n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}});function Ds(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const el=/^[0-9a-zA-Z+/]*={0,2}$/,dy=S("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=el),Fe.init(e,t),e._zod.check=n=>{Ds(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}}),Ms=/^[A-Za-z0-9_-]*$/;function tl(e){if(!Ms.test(e))return!1;const t=e.replace(/[-_]/g,r=>r==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Ds(n)}const fy=S("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Ms),Fe.init(e,t),e._zod.check=n=>{tl(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),hy=S("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ug),Fe.init(e,t)}),_S=/[- ]/g;function kS(e){let t=e.length,n=1,r=0;for(;t;){const i=e.charCodeAt(--t)-48;n^=1,r+=n?[0,2,4,6,8,1,3,5,7,9][i]:i}return r%10===0}function nl(e){return Fc.test(e)?kS(e.replace(_S,"")):!1}const py=S("$ZodCreditCard",(e,t)=>{t.pattern??(t.pattern=Fc),Fe.init(e,t),e._zod.check=n=>{nl(n.value)||n.issues.push({code:"invalid_format",format:"credit_card",input:n.value,inst:e,continue:!t.abort})}});function SS(e){let t=0;const n=e.length;for(let r=4;r<n;r++){const i=e.charCodeAt(r);t=(i>=65?t*100+(i-55):t*10+(i-48))%97}for(let r=0;r<4;r++){const i=e.charCodeAt(r);t=(i>=65?t*100+(i-55):t*10+(i-48))%97}return t===1}function rl(e){return Uc.test(e)?SS(e):!1}const my=S("$ZodIBAN",(e,t)=>{t.pattern??(t.pattern=Uc),Fe.init(e,t),e._zod.check=n=>{rl(n.value)||n.issues.push({code:"invalid_format",format:"iban",input:n.value,inst:e,continue:!t.abort})}});function il(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[r]=n;if(!r)return!1;const i=JSON.parse(atob(r));return!("typ"in i&&i?.typ!=="JWT"||!i.alg||t&&(!("alg"in i)||i.alg!==t))}catch{return!1}}const gy=S("$ZodJWT",(e,t)=>{Fe.init(e,t),e._zod.check=n=>{il(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),yy=S("$ZodCustomStringFormat",(e,t)=>{Fe.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})}}),ol=S("$ZodNumber",(e,t)=>{me.init(e,t),e._zod.pattern=wr,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const i=n.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return n;const o=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...o?{received:o}:{}}),n}}),vy=S("$ZodNumberFormat",(e,t)=>{Eg.init(e,t),ol.init(e,t)}),sl=S("$ZodBoolean",(e,t)=>{me.init(e,t),e._zod.pattern=yg,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}const i=n.value;return typeof i=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),n}}),al=S("$ZodBigInt",(e,t)=>{me.init(e,t),e._zod.pattern=gg,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}}),by=S("$ZodBigIntFormat",(e,t)=>{xg.init(e,t),al.init(e,t)}),wy=S("$ZodSymbol",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return typeof i=="symbol"||n.issues.push({expected:"symbol",code:"invalid_type",input:i,inst:e}),n}}),_y=S("$ZodUndefined",(e,t)=>{me.init(e,t),e._zod.pattern=bg,e._zod.values=new Set([void 0]),e._zod.parse=(n,r)=>{const i=n.value;return typeof i>"u"||n.issues.push({expected:"undefined",code:"invalid_type",input:i,inst:e}),n}}),ky=S("$ZodNull",(e,t)=>{me.init(e,t),e._zod.pattern=vg,e._zod.values=new Set([null]),e._zod.parse=(n,r)=>{const i=n.value;return i===null||n.issues.push({expected:"null",code:"invalid_type",input:i,inst:e}),n}}),Sy=S("$ZodAny",(e,t)=>{me.init(e,t),e._zod.parse=n=>n}),Ey=S("$ZodUnknown",(e,t)=>{me.init(e,t),e._zod.parse=n=>n}),xy=S("$ZodNever",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)}),$y=S("$ZodVoid",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return typeof i>"u"||n.issues.push({expected:"void",code:"invalid_type",input:i,inst:e}),n}}),Ty=S("$ZodDate",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=new Date(n.value)}catch{}const i=n.value,o=i instanceof Date;return o&&!Number.isNaN(i.getTime())||n.issues.push({expected:"date",code:"invalid_type",input:i,...o?{received:"Invalid Date"}:{},inst:e}),n}});function mh(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues)),t.value[n]=e.value}const Cy=S("$ZodArray",(e,t)=>{me.init(e,t);const n=vt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!Array.isArray(o))return r.issues.push({expected:"array",code:"invalid_type",input:o,inst:e}),r;r.value=n?n.alloc(e,r,Array(o.length),i):Array(o.length);const s=[],a=i?.abortEarly;for(let u=0;u<o.length;u++){const c=o[u],l=t.element._zod.run({value:c,issues:[]},i);if(l instanceof Promise)s.push(l.then(d=>mh(d,r,u)));else if(mh(l,r,u),a&&l.issues.length!==0&&wt(l))break}return s.length?Promise.all(s).then(()=>r):r}});function ls(e,t,n,r,i,o){const s=n in r,a=o==="optional";if(!(!s&&a&&i==="optional")){if(e.issues.length){if(i!==void 0&&a&&!s)return;t.issues.push(...zt(n,e.issues))}if(!s&&i===void 0){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?(s||i==="defaulted"&&!a)&&(t.value[n]=void 0):t.value[n]=e.value}}const ES=[];function Ay(e){const t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:ES,i=r.length?[...t,...r]:t;for(const s of i)if(!e.shape?.[s]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${String(s)}": expected a Zod schema`);const o=km(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(o)}}function Iy(e,t,n,r,i,o,s){const a=[],u=i.keySet,c=i.catchall._zod,l=c.def.type,d=c.optin,f=c.optout;let h=0;for(const p in t){if(s&&n.issues.length!==h){if(wt(n,h))break;h=n.issues.length}if(u.has(p))continue;if(p==="__proto__"){l==="never"&&a.push(p);continue}if(l==="never"){a.push(p);continue}const m=c.run({value:t[p],issues:[]},r);m instanceof Promise?e.push(m.then(y=>ls(y,n,p,t,d,f))):ls(m,n,p,t,d,f)}return a.length&&n.issues.push({code:"unrecognized_keys",keys:a,input:t,inst:o,continue:!0}),e.length?Promise.all(e).then(()=>n):n}const Ny=S("$ZodObject",(e,t)=>{me.init(e,t);const n=Object.getOwnPropertyDescriptor(t,"shape"),r=n?.get?n.get.raw:t.shape??{};if(r){const c=()=>{const l={...r};return Object.defineProperty(t,"shape",{value:l}),c.raw=l,l};c.raw=r,Object.defineProperty(t,"shape",{get:c})}const i=bi(()=>Ay(t));Se(e,"propValues",c=>{const l=c.def.shape,d={};for(const f in l){const h=l[f]._zod;if(h.values){Object.prototype.hasOwnProperty.call(d,f)||Tt(d,f,new Set);for(const p of h.values)d[f].add(p);h.optin!==void 0&&d[f].add(void 0)}}return d});const o=sr,s=t.catchall;let a;const u=vt.memoizer;u?.attach(e),e._zod.parse=(c,l)=>{a??(a=i.value);const d=c.value;if(!o(d))return c.issues.push({expected:"object",code:"invalid_type",input:d,inst:e}),c;c.value=u?u.alloc(e,c,{},l):{};const f=[],h=a.shape,p=l?.abortEarly;let m=c.issues.length;for(const y of a.allKeys){if(p&&c.issues.length!==m){if(wt(c,m))break;m=c.issues.length}if(y==="__proto__")continue;const w=h[y],g=w._zod.optin,b=w._zod.optout,v=w._zod.run({value:d[y],issues:[]},l);v instanceof Promise?f.push(v.then(k=>ls(k,c,y,d,g,b))):ls(v,c,y,d,g,b)}return s?Iy(f,d,c,l,i.value,e,p===!0):f.length?Promise.all(f).then(()=>c):c}}),Ry=S("$ZodObjectJIT",(e,t)=>{Ny.init(e,t);const n=e._zod.parse,r=bi(()=>Ay(t)),i=vt.memoizer,o=h=>{const p=r.value,m=p.symbolKeys,y=new Vc(["payload","ctx"],{shape:h,inst:e,memo:i,syms:m}),w=k=>`shape[${k}]._zod.run({ value: input[${k}], issues: [] }, ctx)`,g=(k,_)=>`
|
|
15
15
|
let ${k}_ab = false;
|
|
16
16
|
for (let i = 0; i < ${k}.issues.length; i++) {
|
|
17
17
|
const iss = ${k}.issues[i];
|
|
@@ -22,8 +22,8 @@ ${n.join(`
|
|
|
22
22
|
if (${k}_ab && ctx && ctx.abortEarly) {
|
|
23
23
|
payload.value = newResult;
|
|
24
24
|
return payload;
|
|
25
|
-
}`;y.write("const input = payload.value;");const b=Object.create(null);let v=0;for(const k of p.allKeys)b[k]=`key_${v++}`;y.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const k of p.allKeys){if(k==="__proto__")continue;const _=b[k],$=typeof k=="symbol"?`syms[${m.indexOf(k)}]`:
|
|
26
|
-
const ${_}_present = ${
|
|
25
|
+
}`;y.write("const input = payload.value;");const b=Object.create(null);let v=0;for(const k of p.allKeys)b[k]=`key_${v++}`;y.write(i?"const newResult = memo.alloc(inst, payload, {}, ctx);":"const newResult = {};");for(const k of p.allKeys){if(k==="__proto__")continue;const _=b[k],$=typeof k=="symbol"?`syms[${m.indexOf(k)}]`:Et(k),D=`${$} in input`,M=h[k],O=M?._zod?.optin,J=O!==void 0,se=M?._zod?.optout==="optional";if(y.write(`const ${_} = ${w($)};`),J&&se){const we=O==="optional"?`${_}_present`:`${_}.value !== undefined || ${_}_present`;y.write(`
|
|
26
|
+
const ${_}_present = ${D};
|
|
27
27
|
if (!${_}.issues.length || ${_}_present) {
|
|
28
28
|
if (${_}.issues.length) {${g(_,$)}
|
|
29
29
|
}
|
|
@@ -36,12 +36,12 @@ ${n.join(`
|
|
|
36
36
|
`)}else J?(y.write(`
|
|
37
37
|
if (${_}.issues.length) {${g(_,$)}
|
|
38
38
|
}
|
|
39
|
-
`),
|
|
40
|
-
if (${_}.value !== undefined || ${
|
|
39
|
+
`),O==="defaulted"?y.write(`newResult[${$}] = ${_}.value;`):y.write(`
|
|
40
|
+
if (${_}.value !== undefined || ${D}) {
|
|
41
41
|
newResult[${$}] = ${_}.value;
|
|
42
42
|
}
|
|
43
43
|
`)):y.write(`
|
|
44
|
-
const ${_}_present = ${
|
|
44
|
+
const ${_}_present = ${D};
|
|
45
45
|
if (${_}.issues.length) {${g(_,$)}
|
|
46
46
|
}
|
|
47
47
|
if (!${_}_present && !${_}.issues.length) {
|
|
@@ -61,19 +61,19 @@ ${n.join(`
|
|
|
61
61
|
newResult[${$}] = ${_}.value;
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
`)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()};let s;const a=sr,u=!vt.jitless,l=u&&vm.value,d=t.catchall;let f;e._zod.parse=(h,p)=>{f??(f=r.value);const m=h.value;return a(m)?u&&l&&p?.async===!1&&p.jitless!==!0?(s||(s=o(t.shape)),h=s(h,p),d?Cy([],m,h,p,f,e,p?.abortEarly===!0):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h)}});function mh(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!wt(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>Ot(s,r,et())))}),t)}const Fs=S("$ZodUnion",(e,t)=>{pe.init(e,t),Se(e,"optin",r=>r.def.options.some(i=>i._zod.optin==="defaulted")?"defaulted":r.def.options.some(i=>i._zod.optin!==void 0)?"optional":void 0),Se(e,"optout",r=>r.def.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Se(e,"values",r=>{if(r.def.options.every(i=>i._zod.values))return new Set(r.def.options.flatMap(i=>Array.from(i._zod.values)))}),Se(e,"pattern",r=>{if(r.def.options.every(i=>i._zod.pattern)){const i=r.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>Cn(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const a of t.options){const u=a._zod.run({value:r.value,issues:[]},i);if(u instanceof Promise)s.push(u),o=!0;else{if(u.issues.length===0)return u;s.push(u)}}return o?Promise.all(s).then(a=>mh(a,r,e,i)):mh(s,r,e,i)}});function gh(e,t,n,r){const i=[];for(let o=0;o<e.length;o++)e[o].issues.length===0&&i.push(o);return i.length===1?(t.value=e[i[0]].value,t):(i.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>Ot(s,r,et())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:i}),t)}const Ny=S("$ZodXor",(e,t)=>{Fs.init(e,t),t.inclusive=!1;const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const a of t.options){const u=a._zod.run({value:r.value,issues:[]},i);u instanceof Promise?(s.push(u),o=!0):s.push(u)}return o?Promise.all(s).then(a=>gh(a,r,e,i)):gh(s,r,e,i)}});function ul(e,t){const n=e._zod;let r=n.bag.optionsMap;r||(r=Ry(n.def),n.bag.optionsMap=r);const i=r.get(t);if(i===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return i}function Ry(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 i of r)if(t.has(i)){if(i!==void 0)throw new Error(`Duplicate discriminator value "${String(i)}"`);t.set(i,null)}else t.set(i,n)}return t}const Ly=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Fs.init(e,t);const n=e._zod.parse;Se(e,"propValues",i=>{const o={};let s=0;for(const a of i.def.options){const u=a._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${i.def.options.indexOf(a)}"`);u[i.def.discriminator]?.has(void 0)&&s++;for(const[c,l]of Object.entries(u)){Object.prototype.hasOwnProperty.call(o,c)||Tt(o,c,new Set);for(const d of l)o[c].add(d)}}return!i.def.unionFallback&&s>1&&o[i.def.discriminator]?.delete(void 0),o}),t.options.forEach((i,o)=>{const s=xs(i._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});const r=bi(()=>Ry(t));e._zod.parse=(i,o)=>{const s=i.value;if(!sr(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;const a=s?.[t.discriminator],u=r.value.get(a);return u&&(a!==void 0||o.direction!=="backward")?u._zod.run(i,o):t.unionFallback||o.direction==="backward"?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(c=>r.value.get(c)!==null),input:s,path:[t.discriminator],inst:e}),i)}}),zy=S("$ZodIntersection",(e,t)=>{pe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},r),s=t.right._zod.run({value:i,issues:[]},r);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([u,c])=>yh(n,u,c)):yh(n,o,s)}});function ui(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(cn(e)&&cn(t)){const n=Object.keys(t),r=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(const o of r){if(o==="__proto__")continue;const s=ui(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}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 i=e[r],o=t[r],s=ui(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function yh(e,t,n){const r=new Map;let i;const o=new Map,s=(c,l)=>{let d;if(c.code==="unrecognized_keys"&&!c.path?.length)i??(i=c),d=c.keys;else if(c.code==="invalid_key"&&c.origin==="record"&&c.path?.length===1){const f=String(c.path[0]);o.has(f)||o.set(f,c),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 c of t.issues)s(c,"l")||e.issues.push(c);for(const c of n.issues)s(c,"r")||e.issues.push(c);const a=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(a.length){const c=i?a.filter(l=>i.keys.includes(l)):[];c.length&&e.issues.push({...i,keys:c});for(const l of a)!c.includes(l)&&o.has(l)&&e.issues.push(o.get(l))}const u=ui(t.value,n.value);if(!u.valid){if(wt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const cl=S("$ZodTuple",(e,t)=>{pe.init(e,t);const n=t.items,r=vt.memoizer;r?.attach(e),e._zod.parse=(i,o)=>{const s=i.value;if(!Array.isArray(s))return i.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=r?r.alloc(e,i,[],o):[];const a=[],u=vh(n,"optin"),c=vh(n,"optout");if(!t.rest){if(s.length<u)return i.issues.push({code:"too_small",minimum:u,inclusive:!0,input:s,inst:e,origin:"array"}),i;s.length>n.length&&i.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?o?.abortEarly:void 0;let f=!1;for(let h=0;h<n.length;h++){const p=n[h]._zod.run({value:s[h],issues:[]},o);p instanceof Promise?a.push(p.then(m=>{l[h]=m})):(l[h]=p,d&&!f&&p.issues.length&&(f=wt(p)))}if(t.rest&&!f){let h=n.length-1;const p=s.slice(n.length);let m=i.issues.length;for(const y of p){if(d&&i.issues.length!==m){if(wt(i,m))break;m=i.issues.length}h++;const w=t.rest._zod.run({value:y,issues:[]},o);w instanceof Promise?a.push(w.then(g=>bh(g,i,h))):bh(w,i,h)}}return a.length?Promise.all(a).then(()=>wh(l,i,n,s,c)):wh(l,i,n,s,c)}});function vh(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 bh(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues)),t.value[n]=e.value}function wh(e,t,n,r,i){for(let o=0;o<n.length;o++){const s=e[o],a=o<r.length;if(!a&&o>=i&&n[o]._zod.optin==="optional"){t.value.length=o;break}if(s.issues.length){if(!a&&o>=i){t.value.length=o;break}t.issues.push(...zt(o,s.issues))}t.value[o]=s.value}for(let o=t.value.length-1;o>=r.length&&(n[o]._zod.optout==="optional"&&t.value[o]===void 0);o--)t.value.length=o;return t}const Py=S("$ZodRecord",(e,t)=>{pe.init(e,t);const n=vt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!cn(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;const s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};const u=new Set;for(const l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(u.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;const d=t.keyType._zod.run({value:l,issues:[]},i);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(p=>Ot(p,i,et())),input:l,path:[l],inst:e});continue}const f=d.value;if(f==="__proto__")continue;const h=t.valueType._zod.run({value:o[l],issues:[]},i);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&r.issues.push(...zt(l,p.issues)),r.value[f]=p.value})):(h.issues.length&&r.issues.push(...zt(l,h.issues)),r.value[f]=h.value)}let c;for(const l in o)if(!u.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=o[l]}else c=c??[],c.push(l);c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let u;for(const c of Reflect.ownKeys(o)){if(c==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,c))continue;let l=t.keyType._zod.run({value:c,issues:[]},i);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&wr.test(c)&&l.issues.length){const p=t.keyType._zod.run({value:Number(c),issues:[]},i);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(l=p)}if(l.issues.length){t.mode==="loose"?r.value[c]=o[c]:a?(u=u??[],u.push(c)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>Ot(p,i,et())),input:c,path:[c],inst:e});continue}const f=l.value;if(f==="__proto__")continue;const h=t.valueType._zod.run({value:o[c],issues:[]},i);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&r.issues.push(...zt(c,p.issues)),r.value[f]=p.value})):(h.issues.length&&r.issues.push(...zt(c,h.issues)),r.value[f]=h.value)}u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}}),Dy=S("$ZodMap",(e,t)=>{pe.init(e,t);const n=vt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!(o instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),r;const s=[];r.value=n?n.alloc(e,r,new Map,i):new Map;const a=i?.abortEarly;let u=r.issues.length;for(const[c,l]of o){if(a&&r.issues.length!==u){if(wt(r,u))break;u=r.issues.length}const d=t.keyType._zod.run({value:c,issues:[]},i),f=t.valueType._zod.run({value:l,issues:[]},i);d instanceof Promise||f instanceof Promise?s.push(Promise.all([d,f]).then(([h,p])=>{_h(h,p,r,c,o,e,i)})):_h(d,f,r,c,o,e,i)}return s.length?Promise.all(s).then(()=>r):r}});function _h(e,t,n,r,i,o,s){e.issues.length&&(ss.has(typeof r)?n.issues.push(...zt(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(a=>Ot(a,s,et()))})),t.issues.length&&(ss.has(typeof r)?n.issues.push(...zt(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:r,issues:t.issues.map(a=>Ot(a,s,et()))})),n.value.set(e.value,t.value)}const Oy=S("$ZodSet",(e,t)=>{pe.init(e,t);const n=vt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!(o instanceof Set))return r.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),r;const s=[];r.value=n?n.alloc(e,r,new Set,i):new Set;const a=i?.abortEarly;let u=r.issues.length;for(const c of o){if(a&&r.issues.length!==u){if(wt(r,u))break;u=r.issues.length}const l=t.valueType._zod.run({value:c,issues:[]},i);l instanceof Promise?s.push(l.then(d=>kh(d,r))):kh(l,r)}return s.length?Promise.all(s).then(()=>r):r}});function kh(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const My=S("$ZodEnum",(e,t)=>{pe.init(e,t);const n=is(t.entries),r=new Set(n);e._zod.values=r,Se(e,"pattern",i=>{const o=is(i.def.entries).filter(s=>ss.has(typeof s));return new RegExp(o.length?`^(${o.map(s=>ln(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,o)=>{const s=i.value;return r.has(s)||i.issues.push({code:"invalid_value",values:n,input:s,inst:e}),i}}),Fy=S("$ZodLiteral",(e,t)=>{pe.init(e,t);const n=new Set(t.values);e._zod.values=n,Se(e,"pattern",r=>{const i=r.def.values;return new RegExp(i.length?`^(${i.map(o=>typeof o=="string"?ln(o):o?ln(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,i)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),Uy=S("$ZodFile",(e,t)=>{pe.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return i instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:i,inst:e}),n}}),Gy=S("$ZodTransform",(e,t)=>{pe.init(e,t),e._zod.optin="optional",vt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new As(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(n.value=s,n));if(i instanceof Promise)throw new sn;return n.value=i,n}});function Sh(e,t){return e.value=t.issues.length?void 0:t.value,e}const ll=S("$ZodOptional",(e,t)=>{pe.init(e,t),Se(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Se(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),Se(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Cn(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const i=t.innerType._zod.run({value:n.value,issues:[]},r);return i instanceof Promise?i.then(o=>Sh(n,o)):Sh(n,i)}return t.innerType._zod.run(n,r)}}),jy=S("$ZodExactOptional",(e,t)=>{ll.init(e,t),Se(e,"values",n=>n.def.innerType._zod.values),Se(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Zy=S("$ZodNullable",(e,t)=>{pe.init(e,t),Se(e,"optin",n=>n.def.innerType._zod.optin),Se(e,"optout",n=>n.def.innerType._zod.optout),Se(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Cn(r.source)}|null)$`):void 0}),Se(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)}),By=S("$ZodDefault",(e,t)=>{pe.init(e,t),e._zod.optin="defaulted",Se(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 i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>xh(o,t)):xh(i,t)}});function xh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const Hy=S("$ZodPrefault",(e,t)=>{pe.init(e,t),e._zod.optin="defaulted",Se(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))}),Vy=S("$ZodNonOptional",(e,t)=>{pe.init(e,t),Se(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(i=>i!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>Eh(o,e)):Eh(i,e)}});function Eh(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 qy=S("$ZodSuccess",(e,t)=>{pe.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new As("ZodSuccess");const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>(n.value=o.issues.length===0,n)):(n.value=i.issues.length===0,n)}});function $h(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(i=>Ot(i,r,et()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Wy=S("$ZodCatch",(e,t)=>{pe.init(e,t),Se(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Se(e,"optout",n=>n.def.innerType._zod.optout),Se(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 i=t.innerType._zod.run({value:n.value,issues:[]},r);return i instanceof Promise?i.then(o=>$h(n,o,t,r)):$h(n,i,t,r)}}),Ky=S("$ZodNaN",(e,t)=>{pe.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)}),dl=S("$ZodPipe",(e,t)=>{pe.init(e,t),Se(e,"values",n=>n.def.in._zod.values),Se(e,"optin",n=>n.def.in._zod.optin),Se(e,"optout",n=>n.def.out._zod.optout),Se(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>No(s,t.in,r)):No(o,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(o=>No(o,t.out,r)):No(i,t.out,r)}});function No(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 fl=S("$ZodCodec",(e,t)=>{pe.init(e,t),Se(e,"values",n=>n.def.in._zod.values),Se(e,"optin",n=>n.def.in._zod.optin),Se(e,"optout",n=>n.def.out._zod.optout),Se(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if((r.direction||"forward")==="forward"){const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>Ro(s,t,r)):Ro(o,t,r)}else{const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>Ro(s,t,r)):Ro(o,t,r)}}});function Ro(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){const i=t.transform(e.value,e);return i instanceof Promise?i.then(o=>Lo(e,o,t.out,n)):Lo(e,i,t.out,n)}else{const i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>Lo(e,o,t.in,n)):Lo(e,i,t.in,n)}}function Lo(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Jy=S("$ZodPreprocess",(e,t)=>{dl.init(e,t)}),Yy=S("$ZodReadonly",(e,t)=>{pe.init(e,t),Se(e,"propValues",n=>n.def.innerType._zod.propValues),Se(e,"values",n=>n.def.innerType._zod.values),Se(e,"optin",n=>n.def.innerType?._zod?.optin),Se(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 i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(Th):Th(i)}});function Th(e){return e.memo||(e.value=Object.freeze(e.value)),e}function kS(e){const t=e._zod.def;let n=t.pattern,r=!!t.format?.includes("int"),i,o;for(const a of t.checks??[]){const u=a._zod.def;u.pattern&&(n=u.pattern),r||(r=!!u.format?.includes("int"));const c=u.minimum??u.length,l=u.maximum??u.length;c!==void 0&&(i===void 0||c>i)&&(i=c),l!==void 0&&(o===void 0||l<o)&&(o=l)}if(n)return n.source;if(i!==void 0&&o!==void 0&&i>o)return"(?!)";if(i!==void 0||o!==void 0)return hg({minimum:i,maximum:o}).source;const s=e._zod.pattern;return(r&&s===wr?Gc:s)?.source}function Fu(e){const t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){const i=r._zod.pattern?.source,o=Fu(r);return n&&i&&o&&o!==i?n.replace(Cn(i),()=>Cn(o)):n}if(t.options){const i=t.options.map(Fu);if(i.every(Boolean))return`^(${i.map(o=>Cn(o)).join("|")})$`}return kS(e)}const Xy=S("$ZodTemplateLiteral",(e,t)=>{pe.init(e,t);const n=[];for(const r of t.parts)if(typeof r=="object"&&r!==null){const i=Fu(r);if(!i)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(Cn(i))}else if(r===null||bm.has(typeof r))n.push(ln(`${r}`));else throw new Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(r,i)=>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)}),Qy=S("$ZodFunction",(e,t)=>(pe.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 i=e._def.input?Du(e._def.input,r):r,o=Reflect.apply(n,this,i);return e._def.output?Du(e._def.output,o):o},"_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 i=e._def.input?await Ou(e._def.input,r):r,o=await Reflect.apply(n,this,i);return e._def.output?await Ou(e._def.output,o):o},"_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 cl({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)),ev=S("$ZodPromise",(e,t)=>{pe.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then(i=>t.innerType._zod.run({value:i,issues:[]},r))}),hl=S("$ZodLazy",(e,t)=>{pe.init(e,t),pm(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),Se(e,"pattern",n=>n.innerType?._zod?.pattern),Se(e,"propValues",n=>n.innerType?._zod?.propValues),Se(e,"optin",n=>n.innerType?._zod?.optin??void 0),Se(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),tv=S("$ZodCustom",(e,t)=>{Ze.init(e,t),pe.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(o=>Ch(o,n,r,e));Ch(i,n,r,e)}});function Ch(e,t,n,r){if(!e){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(ar(i))}}class nv extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Uu="~memo",Ah=[];function rv(e){return e!==null&&typeof e=="object"}function ru(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const iv=new WeakMap,ir=0,es=1,ni=2;function ri(e,t,n){const r=iv.get(e);if(r!==void 0)return r?ni:ir;if(t.has(e))return ni;t.add(e);let i=ir;const o=l=>{if(i!==ni&&l?._zod){const d=ri(l,t,n);d>i&&(i=d)}},s=(l,d)=>{let f=ir;for(const h of Reflect.ownKeys(l)){const p=Object.getOwnPropertyDescriptor(l,h);if(!p.enumerable)continue;const m=p.get?es:p.value?._zod?ri(p.value,t,n):ir;m>f&&(f=m)}return f},a=l=>{l>i&&(i=l)},u=e._zod.def;switch(u.type){case"object":{const l=xs(u);a(l?s(l):es),o(u.catchall);break}case"array":o(u.element);break;case"tuple":for(const l of u.items)o(l);o(u.rest);break;case"record":case"map":o(u.keyType),o(u.valueType);break;case"set":o(u.valueType);break;case"union":for(const l of u.options)o(l);break;case"intersection":o(u.left),o(u.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(u.innerType);break;case"pipe":o(u.in),o(u.out);break;case"function":o(u.input),o(u.output);break;case"lazy":{const l=u._cachedInner??(n?e._zod.innerType:void 0);a(l?ri(l,t,!1):es);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 u){const d=Object.getOwnPropertyDescriptor(u,l);if(!d||d.get)continue;const f=d.value;if(!(!f||typeof f!="object")){if(f._zod)o(f);else if(Array.isArray(f))for(const h of f)o(h)}}}return t.delete(e),SS(e,i)}function SS(e,t){return t!==es&&iv.set(e,t===ni),t}function pl(e){return ri(e,new Set,!0)!==ir}function xS(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let zo;const Po=[],ES={alloc(e,t,n){const r=zo;if(!r)return n;zo=void 0;const i={value:n,issues:null};return r.set(t.value,i),Po.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(i,o)=>{if(o.direction!=="backward"&&ml(o,i.value))throw new nv;return n(i,o)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r=!1,i,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(u,c)=>{if(n===void 0){const w=ri(e,new Set,!1);if(w===ir)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(u,c);w===ni||r?n=!0:r=!0}const l=u.value;if(!rv(l))return s(u,c);let d=c[Uu];d||(d={buckets:new WeakMap,backEdges:void 0},c[Uu]=d);let f;i===c?f=o:(f=xS(d,e),i=c,o=f);const h=f.get(l);if(h)return u.value=h.value,h.issues?h.issues.length&&u.issues.push(...ru(h.issues)):(u.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value)),u;zo=f;const p=Po.length,m=s(u,c);zo=void 0;const y=Po.length>p?Po.pop():void 0;return m instanceof Promise?m.then(w=>(y&&(y.issues=w.issues.length?ru(w.issues):Ah),w)):(y&&(y.issues=m.issues.length?ru(m.issues):Ah),m)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function Us(){return ES}function ml(e,t){const n=e[Uu]?.backEdges;return n!==void 0&&rv(t)&&n.has(t)}const gl=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var Ih;const yl=Symbol("ZodOutput"),vl=Symbol("ZodInput");class ov{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 i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Gs(){return new ov}(Ih=globalThis).__zod_globalRegistry??(Ih.__zod_globalRegistry=Gs());const St=globalThis.__zod_globalRegistry,bt=Symbol.for("zod.compile.invalid"),Nh=Symbol.for("zod.compile.fallback");class fn extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}}class Ce 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 $S(e,t){try{return Zs(e,{assertOnly:!0})}catch{return t}}function bl(e,t){try{const n=Zs(e),r=js(e,n);return r._zod.bag.validator=$S(e,n),r}catch(n){if(t?.strict)throw n;return e}}function js(e,t){if(pl(e))throw new Ce("a schema whose subtree contains a reference cycle");const n=je(e),r=e._zod.run,i=r.__originalRun??r,o=(s,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[Nh]||a&&ml(a,s.value))return i(s,a);const u=t(s.value);return u!==bt?(s.value=u,s):(a&&(a[Nh]=!0),i(s,a))};return o.__originalRun=i,n._zod.bag.fallbackRun=i,n._zod.bag.validator=t,n._zod.run=o,r.__originalRun||TS(n,e,t),n}function TS(e,t,n){const r=e,i=t;if(typeof i.safeParse=="function"){const o=i.safeParse;r.safeParse=(s,a)=>{const u=n(s);return u!==bt?{success:!0,data:u}:o(s,a)}}if(typeof i.parse=="function"){const o=i.parse;r.parse=(s,a)=>{const u=n(s);return u!==bt?u:o(s,a)}}}function Zs(e,t){let n=!0;try{n=pl(e)}catch{}if(n)throw new Ce("a schema whose subtree contains a reference cycle");const r={constants:new Map,constantCounter:0,varCounter:0,definite:!0},i=new Vc(["input"]),o=Be(i,r,e,"input",!t?.assertOnly);i.write(o===null?"return true;":`return ${o};`);const s=["INVALID",...r.constants.keys()],a=[bt,...r.constants.values()],u=i.content.join(`
|
|
64
|
+
`)}return y.write("payload.value = newResult;"),y.write("return payload;"),y.compile()};let s;const a=sr,u=!vt.jitless,l=u&&wm.value,d=t.catchall;let f;e._zod.parse=(h,p)=>{f??(f=r.value);const m=h.value;return a(m)?u&&l&&p?.async===!1&&p.jitless!==!0?(s||(s=o(t.shape)),h=s(h,p),d?Iy([],m,h,p,f,e,p?.abortEarly===!0):h):n(h,p):(h.issues.push({expected:"object",code:"invalid_type",input:m,inst:e}),h)}});function gh(e,t,n,r){for(const o of e)if(o.issues.length===0)return t.value=o.value,t;const i=e.filter(o=>!wt(o));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>Dt(s,r,et())))}),t)}const Fs=S("$ZodUnion",(e,t)=>{me.init(e,t),Se(e,"optin",r=>r.def.options.some(i=>i._zod.optin==="defaulted")?"defaulted":r.def.options.some(i=>i._zod.optin!==void 0)?"optional":void 0),Se(e,"optout",r=>r.def.options.some(i=>i._zod.optout==="optional")?"optional":void 0),Se(e,"values",r=>{if(r.def.options.every(i=>i._zod.values))return new Set(r.def.options.flatMap(i=>Array.from(i._zod.values)))}),Se(e,"pattern",r=>{if(r.def.options.every(i=>i._zod.pattern)){const i=r.def.options.map(o=>o._zod.pattern);return new RegExp(`^(${i.map(o=>Tn(o.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const a of t.options){const u=a._zod.run({value:r.value,issues:[]},i);if(u instanceof Promise)s.push(u),o=!0;else{if(u.issues.length===0)return u;s.push(u)}}return o?Promise.all(s).then(a=>gh(a,r,e,i)):gh(s,r,e,i)}});function yh(e,t,n,r){const i=[];for(let o=0;o<e.length;o++)e[o].issues.length===0&&i.push(o);return i.length===1?(t.value=e[i[0]].value,t):(i.length===0?t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(o=>o.issues.map(s=>Dt(s,r,et())))}):t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:[],inclusive:!1,matches:i}),t)}const Ly=S("$ZodXor",(e,t)=>{Fs.init(e,t),t.inclusive=!1;const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let o=!1;const s=[];for(const a of t.options){const u=a._zod.run({value:r.value,issues:[]},i);u instanceof Promise?(s.push(u),o=!0):s.push(u)}return o?Promise.all(s).then(a=>yh(a,r,e,i)):yh(s,r,e,i)}});function ul(e,t){const n=e._zod;let r=n.bag.optionsMap;r||(r=zy(n.def),n.bag.optionsMap=r);const i=r.get(t);if(i===null)throw new Error(`Ambiguous discriminator value "${String(t)}"`);return i}function zy(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 i of r)if(t.has(i)){if(i!==void 0)throw new Error(`Duplicate discriminator value "${String(i)}"`);t.set(i,null)}else t.set(i,n)}return t}const Py=S("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Fs.init(e,t);const n=e._zod.parse;Se(e,"propValues",i=>{const o={};let s=0;for(const a of i.def.options){const u=a._zod.propValues;if(!u||Object.keys(u).length===0)throw new Error(`Invalid discriminated union option at index "${i.def.options.indexOf(a)}"`);u[i.def.discriminator]?.has(void 0)&&s++;for(const[c,l]of Object.entries(u)){Object.prototype.hasOwnProperty.call(o,c)||Tt(o,c,new Set);for(const d of l)o[c].add(d)}}return!i.def.unionFallback&&s>1&&o[i.def.discriminator]?.delete(void 0),o}),t.options.forEach((i,o)=>{const s=Es(i._zod.def);if(s&&!Object.prototype.hasOwnProperty.call(s,t.discriminator))throw new Error(`Invalid discriminated union option at index "${o}"`)});const r=bi(()=>zy(t));e._zod.parse=(i,o)=>{const s=i.value;if(!sr(s))return i.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),i;const a=s?.[t.discriminator],u=r.value.get(a);return u&&(a!==void 0||o.direction!=="backward")?u._zod.run(i,o):t.unionFallback||o.direction==="backward"?n(i,o):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(r.value.keys()).filter(c=>r.value.get(c)!==null),input:s,path:[t.discriminator],inst:e}),i)}}),Oy=S("$ZodIntersection",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{const i=n.value,o=t.left._zod.run({value:i,issues:[]},r),s=t.right._zod.run({value:i,issues:[]},r);return o instanceof Promise||s instanceof Promise?Promise.all([o,s]).then(([u,c])=>vh(n,u,c)):vh(n,o,s)}});function ui(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(ln(e)&&ln(t)){const n=Object.keys(t),r=Object.keys(e).filter(o=>n.indexOf(o)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,"__proto__")&&delete i.__proto__;for(const o of r){if(o==="__proto__")continue;const s=ui(e[o],t[o]);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};i[o]=s.data}return{valid:!0,data:i}}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 i=e[r],o=t[r],s=ui(i,o);if(!s.valid)return{valid:!1,mergeErrorPath:[r,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function vh(e,t,n){const r=new Map;let i;const o=new Map,s=(c,l)=>{let d;if(c.code==="unrecognized_keys"&&!c.path?.length)i??(i=c),d=c.keys;else if(c.code==="invalid_key"&&c.origin==="record"&&c.path?.length===1){const f=String(c.path[0]);o.has(f)||o.set(f,c),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 c of t.issues)s(c,"l")||e.issues.push(c);for(const c of n.issues)s(c,"r")||e.issues.push(c);const a=[...r].filter(([,c])=>c.l&&c.r).map(([c])=>c);if(a.length){const c=i?a.filter(l=>i.keys.includes(l)):[];c.length&&e.issues.push({...i,keys:c});for(const l of a)!c.includes(l)&&o.has(l)&&e.issues.push(o.get(l))}const u=ui(t.value,n.value);if(!u.valid){if(wt(e))return e;throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(u.mergeErrorPath)}`)}return e.value=u.data,e}const cl=S("$ZodTuple",(e,t)=>{me.init(e,t);const n=t.items,r=vt.memoizer;r?.attach(e),e._zod.parse=(i,o)=>{const s=i.value;if(!Array.isArray(s))return i.issues.push({input:s,inst:e,expected:"tuple",code:"invalid_type"}),i;i.value=r?r.alloc(e,i,[],o):[];const a=[],u=bh(n,"optin"),c=bh(n,"optout");if(!t.rest){if(s.length<u)return i.issues.push({code:"too_small",minimum:u,inclusive:!0,input:s,inst:e,origin:"array"}),i;s.length>n.length&&i.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?o?.abortEarly:void 0;let f=!1;for(let h=0;h<n.length;h++){const p=n[h]._zod.run({value:s[h],issues:[]},o);p instanceof Promise?a.push(p.then(m=>{l[h]=m})):(l[h]=p,d&&!f&&p.issues.length&&(f=wt(p)))}if(t.rest&&!f){let h=n.length-1;const p=s.slice(n.length);let m=i.issues.length;for(const y of p){if(d&&i.issues.length!==m){if(wt(i,m))break;m=i.issues.length}h++;const w=t.rest._zod.run({value:y,issues:[]},o);w instanceof Promise?a.push(w.then(g=>wh(g,i,h))):wh(w,i,h)}}return a.length?Promise.all(a).then(()=>_h(l,i,n,s,c)):_h(l,i,n,s,c)}});function bh(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 wh(e,t,n){e.issues.length&&t.issues.push(...zt(n,e.issues)),t.value[n]=e.value}function _h(e,t,n,r,i){for(let o=0;o<n.length;o++){const s=e[o],a=o<r.length;if(!a&&o>=i&&n[o]._zod.optin==="optional"){t.value.length=o;break}if(s.issues.length){if(!a&&o>=i){t.value.length=o;break}t.issues.push(...zt(o,s.issues))}t.value[o]=s.value}for(let o=t.value.length-1;o>=r.length&&(n[o]._zod.optout==="optional"&&t.value[o]===void 0);o--)t.value.length=o;return t}const Dy=S("$ZodRecord",(e,t)=>{me.init(e,t);const n=vt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!ln(o))return r.issues.push({expected:"record",code:"invalid_type",input:o,inst:e}),r;const s=[],a=t.keyType._zod.values;if(a&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};const u=new Set;for(const l of a)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){if(u.add(typeof l=="number"?l.toString():l),l==="__proto__")continue;const d=t.keyType._zod.run({value:l,issues:[]},i);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(p=>Dt(p,i,et())),input:l,path:[l],inst:e});continue}const f=d.value;if(f==="__proto__")continue;const h=t.valueType._zod.run({value:o[l],issues:[]},i);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&r.issues.push(...zt(l,p.issues)),r.value[f]=p.value})):(h.issues.length&&r.issues.push(...zt(l,h.issues)),r.value[f]=h.value)}let c;for(const l in o)if(!u.has(l))if(t.mode==="loose"){if(l==="__proto__")continue;r.value[l]=o[l]}else c=c??[],c.push(l);c&&c.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:c,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let u;for(const c of Reflect.ownKeys(o)){if(c==="__proto__"||!Object.prototype.propertyIsEnumerable.call(o,c))continue;let l=t.keyType._zod.run({value:c,issues:[]},i);if(l instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof c=="string"&&wr.test(c)&&l.issues.length){const p=t.keyType._zod.run({value:Number(c),issues:[]},i);if(p instanceof Promise)throw new Error("Async schemas not supported in object keys currently");p.issues.length===0&&(l=p)}if(l.issues.length){t.mode==="loose"?r.value[c]=o[c]:a?(u=u??[],u.push(c)):r.issues.push({code:"invalid_key",origin:"record",issues:l.issues.map(p=>Dt(p,i,et())),input:c,path:[c],inst:e});continue}const f=l.value;if(f==="__proto__")continue;const h=t.valueType._zod.run({value:o[c],issues:[]},i);h instanceof Promise?s.push(h.then(p=>{p.issues.length&&r.issues.push(...zt(c,p.issues)),r.value[f]=p.value})):(h.issues.length&&r.issues.push(...zt(c,h.issues)),r.value[f]=h.value)}u&&u.length>0&&r.issues.push({code:"unrecognized_keys",input:o,inst:e,keys:u,continue:!0})}return s.length?Promise.all(s).then(()=>r):r}}),My=S("$ZodMap",(e,t)=>{me.init(e,t);const n=vt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!(o instanceof Map))return r.issues.push({expected:"map",code:"invalid_type",input:o,inst:e}),r;const s=[];r.value=n?n.alloc(e,r,new Map,i):new Map;const a=i?.abortEarly;let u=r.issues.length;for(const[c,l]of o){if(a&&r.issues.length!==u){if(wt(r,u))break;u=r.issues.length}const d=t.keyType._zod.run({value:c,issues:[]},i),f=t.valueType._zod.run({value:l,issues:[]},i);d instanceof Promise||f instanceof Promise?s.push(Promise.all([d,f]).then(([h,p])=>{kh(h,p,r,c,o,e,i)})):kh(d,f,r,c,o,e,i)}return s.length?Promise.all(s).then(()=>r):r}});function kh(e,t,n,r,i,o,s){e.issues.length&&(ss.has(typeof r)?n.issues.push(...zt(r,e.issues)):n.issues.push({code:"invalid_key",origin:"map",input:i,inst:o,issues:e.issues.map(a=>Dt(a,s,et()))})),t.issues.length&&(ss.has(typeof r)?n.issues.push(...zt(r,t.issues)):n.issues.push({origin:"map",code:"invalid_element",input:i,inst:o,key:r,issues:t.issues.map(a=>Dt(a,s,et()))})),n.value.set(e.value,t.value)}const Fy=S("$ZodSet",(e,t)=>{me.init(e,t);const n=vt.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{const o=r.value;if(!(o instanceof Set))return r.issues.push({input:o,inst:e,expected:"set",code:"invalid_type"}),r;const s=[];r.value=n?n.alloc(e,r,new Set,i):new Set;const a=i?.abortEarly;let u=r.issues.length;for(const c of o){if(a&&r.issues.length!==u){if(wt(r,u))break;u=r.issues.length}const l=t.valueType._zod.run({value:c,issues:[]},i);l instanceof Promise?s.push(l.then(d=>Sh(d,r))):Sh(l,r)}return s.length?Promise.all(s).then(()=>r):r}});function Sh(e,t){e.issues.length&&t.issues.push(...e.issues),t.value.add(e.value)}const Uy=S("$ZodEnum",(e,t)=>{me.init(e,t);const n=is(t.entries),r=new Set(n);e._zod.values=r,Se(e,"pattern",i=>{const o=is(i.def.entries).filter(s=>ss.has(typeof s));return new RegExp(o.length?`^(${o.map(s=>dn(s.toString())).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(i,o)=>{const s=i.value;return r.has(s)||i.issues.push({code:"invalid_value",values:n,input:s,inst:e}),i}}),Gy=S("$ZodLiteral",(e,t)=>{me.init(e,t);const n=new Set(t.values);e._zod.values=n,Se(e,"pattern",r=>{const i=r.def.values;return new RegExp(i.length?`^(${i.map(o=>typeof o=="string"?dn(o):o?dn(o.toString()):String(o)).join("|")})$`:"^[^\\s\\S]$")}),e._zod.parse=(r,i)=>{const o=r.value;return n.has(o)||r.issues.push({code:"invalid_value",values:t.values,input:o,inst:e}),r}}),jy=S("$ZodFile",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{const i=n.value;return i instanceof File||n.issues.push({expected:"file",code:"invalid_type",input:i,inst:e}),n}}),Zy=S("$ZodTransform",(e,t)=>{me.init(e,t),e._zod.optin="optional",vt.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new As(e.constructor.name);const i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(s=>(n.value=s,n));if(i instanceof Promise)throw new an;return n.value=i,n}});function Eh(e,t){return e.value=t.issues.length?void 0:t.value,e}const ll=S("$ZodOptional",(e,t)=>{me.init(e,t),Se(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),e._zod.optout="optional",Se(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r,void 0]):void 0}),Se(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Tn(r.source)})?$`):void 0}),e._zod.parse=(n,r)=>{if(n.value===void 0){if(t.innerType._zod.optin!=="defaulted")return n;const i=t.innerType._zod.run({value:n.value,issues:[]},r);return i instanceof Promise?i.then(o=>Eh(n,o)):Eh(n,i)}return t.innerType._zod.run(n,r)}}),By=S("$ZodExactOptional",(e,t)=>{ll.init(e,t),Se(e,"values",n=>n.def.innerType._zod.values),Se(e,"pattern",n=>n.def.innerType._zod.pattern),e._zod.parse=(n,r)=>t.innerType._zod.run(n,r)}),Hy=S("$ZodNullable",(e,t)=>{me.init(e,t),Se(e,"optin",n=>n.def.innerType._zod.optin),Se(e,"optout",n=>n.def.innerType._zod.optout),Se(e,"pattern",n=>{const r=n.def.innerType._zod.pattern;return r?new RegExp(`^(${Tn(r.source)}|null)$`):void 0}),Se(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)}),Vy=S("$ZodDefault",(e,t)=>{me.init(e,t),e._zod.optin="defaulted",Se(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 i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>xh(o,t)):xh(i,t)}});function xh(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const qy=S("$ZodPrefault",(e,t)=>{me.init(e,t),e._zod.optin="defaulted",Se(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))}),Wy=S("$ZodNonOptional",(e,t)=>{me.init(e,t),Se(e,"values",n=>{const r=n.def.innerType._zod.values;return r?new Set([...r].filter(i=>i!==void 0)):void 0}),e._zod.parse=(n,r)=>{const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>$h(o,e)):$h(i,e)}});function $h(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 Ky=S("$ZodSuccess",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new As("ZodSuccess");const i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(o=>(n.value=o.issues.length===0,n)):(n.value=i.issues.length===0,n)}});function Th(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(i=>Dt(i,r,et()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}const Jy=S("$ZodCatch",(e,t)=>{me.init(e,t),Se(e,"optin",n=>n.def.innerType._zod.optin==="defaulted"?"defaulted":"optional"),Se(e,"optout",n=>n.def.innerType._zod.optout),Se(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 i=t.innerType._zod.run({value:n.value,issues:[]},r);return i instanceof Promise?i.then(o=>Th(n,o,t,r)):Th(n,i,t,r)}}),Yy=S("$ZodNaN",(e,t)=>{me.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)}),dl=S("$ZodPipe",(e,t)=>{me.init(e,t),Se(e,"values",n=>n.def.in._zod.values),Se(e,"optin",n=>n.def.in._zod.optin),Se(e,"optout",n=>n.def.out._zod.optout),Se(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if(r.direction==="backward"){const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>No(s,t.in,r)):No(o,t.in,r)}const i=t.in._zod.run(n,r);return i instanceof Promise?i.then(o=>No(o,t.out,r)):No(i,t.out,r)}});function No(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 fl=S("$ZodCodec",(e,t)=>{me.init(e,t),Se(e,"values",n=>n.def.in._zod.values),Se(e,"optin",n=>n.def.in._zod.optin),Se(e,"optout",n=>n.def.out._zod.optout),Se(e,"propValues",n=>n.def.in._zod.propValues),e._zod.parse=(n,r)=>{if((r.direction||"forward")==="forward"){const o=t.in._zod.run(n,r);return o instanceof Promise?o.then(s=>Ro(s,t,r)):Ro(o,t,r)}else{const o=t.out._zod.run(n,r);return o instanceof Promise?o.then(s=>Ro(s,t,r)):Ro(o,t,r)}}});function Ro(e,t,n){if(e.issues.length)return e.aborted=!0,e;if((n.direction||"forward")==="forward"){const i=t.transform(e.value,e);return i instanceof Promise?i.then(o=>Lo(e,o,t.out,n)):Lo(e,i,t.out,n)}else{const i=t.reverseTransform(e.value,e);return i instanceof Promise?i.then(o=>Lo(e,o,t.in,n)):Lo(e,i,t.in,n)}}function Lo(e,t,n,r){return e.issues.length?(e.aborted=!0,e):n._zod.run({value:t,issues:e.issues},r)}const Xy=S("$ZodPreprocess",(e,t)=>{dl.init(e,t)}),Qy=S("$ZodReadonly",(e,t)=>{me.init(e,t),Se(e,"propValues",n=>n.def.innerType._zod.propValues),Se(e,"values",n=>n.def.innerType._zod.values),Se(e,"optin",n=>n.def.innerType?._zod?.optin),Se(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 i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(Ch):Ch(i)}});function Ch(e){return e.memo||(e.value=Object.freeze(e.value)),e}function xS(e){const t=e._zod.def;let n=t.pattern,r=!!t.format?.includes("int"),i,o;for(const a of t.checks??[]){const u=a._zod.def;u.pattern&&(n=u.pattern),r||(r=!!u.format?.includes("int"));const c=u.minimum??u.length,l=u.maximum??u.length;c!==void 0&&(i===void 0||c>i)&&(i=c),l!==void 0&&(o===void 0||l<o)&&(o=l)}if(n)return n.source;if(i!==void 0&&o!==void 0&&i>o)return"(?!)";if(i!==void 0||o!==void 0)return mg({minimum:i,maximum:o}).source;const s=e._zod.pattern;return(r&&s===wr?Gc:s)?.source}function Fu(e){const t=e._zod.def,n=e._zod.pattern?.source,r=t.innerType??e._zod.innerType;if(r){const i=r._zod.pattern?.source,o=Fu(r);return n&&i&&o&&o!==i?n.replace(Tn(i),()=>Tn(o)):n}if(t.options){const i=t.options.map(Fu);if(i.every(Boolean))return`^(${i.map(o=>Tn(o)).join("|")})$`}return xS(e)}const ev=S("$ZodTemplateLiteral",(e,t)=>{me.init(e,t);const n=[];for(const r of t.parts)if(typeof r=="object"&&r!==null){const i=Fu(r);if(!i)throw new Error(`Invalid template literal part, no pattern found: ${[...r._zod.traits].shift()}`);n.push(Tn(i))}else if(r===null||_m.has(typeof r))n.push(dn(`${r}`));else throw new Error(`Invalid template literal part: ${r}`);e._zod.pattern=new RegExp(`^${n.join("")}$`),e._zod.parse=(r,i)=>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)}),tv=S("$ZodFunction",(e,t)=>(me.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 i=e._def.input?Ou(e._def.input,r):r,o=Reflect.apply(n,this,i);return e._def.output?Ou(e._def.output,o):o},"_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 i=e._def.input?await Du(e._def.input,r):r,o=await Reflect.apply(n,this,i);return e._def.output?await Du(e._def.output,o):o},"_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 cl({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)),nv=S("$ZodPromise",(e,t)=>{me.init(e,t),e._zod.parse=(n,r)=>Promise.resolve(n.value).then(i=>t.innerType._zod.run({value:i,issues:[]},r))}),hl=S("$ZodLazy",(e,t)=>{me.init(e,t),gm(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),Se(e,"pattern",n=>n.innerType?._zod?.pattern),Se(e,"propValues",n=>n.innerType?._zod?.propValues),Se(e,"optin",n=>n.innerType?._zod?.optin??void 0),Se(e,"optout",n=>n.innerType?._zod?.optout??void 0),e._zod.parse=(n,r)=>e._zod.innerType._zod.run(n,r)}),rv=S("$ZodCustom",(e,t)=>{Ze.init(e,t),me.init(e,t),e._zod.parse=(n,r)=>n,e._zod.check=n=>{const r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(o=>Ah(o,n,r,e));Ah(i,n,r,e)}});function Ah(e,t,n,r){if(!e){const i={code:"custom",input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(i.params=r._zod.def.params),t.issues.push(ar(i))}}class iv extends Error{constructor(){super("Cannot parse a reference cycle that closes through a transform"),this.name="ZodCyclicError"}}const Uu="~memo",Ih=[];function ov(e){return e!==null&&typeof e=="object"}function ru(e){return e.map(t=>t.path?{...t,path:t.path.slice()}:{...t})}const sv=new WeakMap,ir=0,es=1,ni=2;function ri(e,t,n){const r=sv.get(e);if(r!==void 0)return r?ni:ir;if(t.has(e))return ni;t.add(e);let i=ir;const o=l=>{if(i!==ni&&l?._zod){const d=ri(l,t,n);d>i&&(i=d)}},s=(l,d)=>{let f=ir;for(const h of Reflect.ownKeys(l)){const p=Object.getOwnPropertyDescriptor(l,h);if(!p.enumerable)continue;const m=p.get?es:p.value?._zod?ri(p.value,t,n):ir;m>f&&(f=m)}return f},a=l=>{l>i&&(i=l)},u=e._zod.def;switch(u.type){case"object":{const l=Es(u);a(l?s(l):es),o(u.catchall);break}case"array":o(u.element);break;case"tuple":for(const l of u.items)o(l);o(u.rest);break;case"record":case"map":o(u.keyType),o(u.valueType);break;case"set":o(u.valueType);break;case"union":for(const l of u.options)o(l);break;case"intersection":o(u.left),o(u.right);break;case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":o(u.innerType);break;case"pipe":o(u.in),o(u.out);break;case"function":o(u.input),o(u.output);break;case"lazy":{const l=u._cachedInner??(n?e._zod.innerType:void 0);a(l?ri(l,t,!1):es);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 u){const d=Object.getOwnPropertyDescriptor(u,l);if(!d||d.get)continue;const f=d.value;if(!(!f||typeof f!="object")){if(f._zod)o(f);else if(Array.isArray(f))for(const h of f)o(h)}}}return t.delete(e),$S(e,i)}function $S(e,t){return t!==es&&sv.set(e,t===ni),t}function pl(e){return ri(e,new Set,!0)!==ir}function TS(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}let zo;const Po=[],CS={alloc(e,t,n){const r=zo;if(!r)return n;zo=void 0;const i={value:n,issues:null};return r.set(t.value,i),Po.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const n=e._zod.parse,r=(i,o)=>{if(o.direction!=="backward"&&ml(o,i.value))throw new iv;return n(i,o)};e._zod.parse=r,e._zod.run===n&&(e._zod.run=r)})},attach(e){var t;let n,r=!1,i,o;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{const s=e._zod.parse,a=(u,c)=>{if(n===void 0){const w=ri(e,new Set,!1);if(w===ir)return e._zod.parse=s,e._zod.run===a&&(e._zod.run=s),s(u,c);w===ni||r?n=!0:r=!0}const l=u.value;if(!ov(l))return s(u,c);let d=c[Uu];d||(d={buckets:new WeakMap,backEdges:void 0},c[Uu]=d);let f;i===c?f=o:(f=TS(d,e),i=c,o=f);const h=f.get(l);if(h)return u.value=h.value,h.issues?h.issues.length&&u.issues.push(...ru(h.issues)):(u.memo=!0,d.backEdges??(d.backEdges=new WeakSet),d.backEdges.add(h.value)),u;zo=f;const p=Po.length,m=s(u,c);zo=void 0;const y=Po.length>p?Po.pop():void 0;return m instanceof Promise?m.then(w=>(y&&(y.issues=w.issues.length?ru(w.issues):Ih),w)):(y&&(y.issues=m.issues.length?ru(m.issues):Ih),m)};e._zod.parse=a,e._zod.run===s&&(e._zod.run=a)})}};function Us(){return CS}function ml(e,t){const n=e[Uu]?.backEdges;return n!==void 0&&ov(t)&&n.has(t)}const gl=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var Nh;const yl=Symbol("ZodOutput"),vl=Symbol("ZodInput");class av{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 i={...r,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function Gs(){return new av}(Nh=globalThis).__zod_globalRegistry??(Nh.__zod_globalRegistry=Gs());const St=globalThis.__zod_globalRegistry,bt=Symbol.for("zod.compile.invalid"),Rh=Symbol.for("zod.compile.fallback");class hn extends Error{constructor(t="z.compile does not support async refinements, transforms, or checks"){super(t),this.name="ZodCompileAsyncError"}}class Ce 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 AS(e,t){try{return Zs(e,{assertOnly:!0})}catch{return t}}function bl(e,t){try{const n=Zs(e),r=js(e,n);return r._zod.bag.validator=AS(e,n),r}catch(n){if(t?.strict)throw n;return e}}function js(e,t){if(pl(e))throw new Ce("a schema whose subtree contains a reference cycle");const n=je(e),r=e._zod.run,i=r.__originalRun??r,o=(s,a)=>{if(a?.async||a?.direction==="backward"||a?.skipChecks||a?.[Rh]||a&&ml(a,s.value))return i(s,a);const u=t(s.value);return u!==bt?(s.value=u,s):(a&&(a[Rh]=!0),i(s,a))};return o.__originalRun=i,n._zod.bag.fallbackRun=i,n._zod.bag.validator=t,n._zod.run=o,r.__originalRun||IS(n,e,t),n}function IS(e,t,n){const r=e,i=t;if(typeof i.safeParse=="function"){const o=i.safeParse;r.safeParse=(s,a)=>{const u=n(s);return u!==bt?{success:!0,data:u}:o(s,a)}}if(typeof i.parse=="function"){const o=i.parse;r.parse=(s,a)=>{const u=n(s);return u!==bt?u:o(s,a)}}}function Zs(e,t){let n=!0;try{n=pl(e)}catch{}if(n)throw new Ce("a schema whose subtree contains a reference cycle");const r={constants:new Map,constantCounter:0,varCounter:0,definite:!0},i=new Vc(["input"]),o=Be(i,r,e,"input",!t?.assertOnly);i.write(o===null?"return true;":`return ${o};`);const s=["INVALID",...r.constants.keys()],a=[bt,...r.constants.values()],u=i.content.join(`
|
|
65
65
|
`),c=t?.debug?s.length>0?`// Constants: ${s.join(", ")}
|
|
66
66
|
${u}`:u:"",l=Function,d=`return (input) => {
|
|
67
67
|
${u}
|
|
68
|
-
}`;let f;try{f=new l(...s,d)(...a)}catch(h){throw new Ce(`this schema (generated code failed to evaluate: ${h.message})`)}return t?.debug&&(f.code=c),f.definite=r.definite,f}function ue(e,t){for(const[r,i]of e.constants)if(i===t)return r;const n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}function Hn(e,t){return e.definite=!1,ue(e,t)}function te(e){return`v${e.varCounter++}`}function CS(e,t){const n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return bt;const r=n;return r.issues.length===0?r.value:bt}function dt(e,t,n,r,i=!0){const o=e.content.length,s=t.constants.size,a=t.constantCounter,u=t.varCounter;try{return Be(e,t,n,r,i)}catch(c){if(!(c instanceof Ce)||!c.islandable)throw c;if(e.content.length=o,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=u,AS(e,t,n,r)}}function AS(e,t,n,r){t.definite=!1;const i=ue(t,n),o=ue(t,CS),s=te(t);return e.write(`const ${s} = ${o}(${i}, ${r});`),e.write(`if (${s} === INVALID) return INVALID;`),s}const IS=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function NS(e,t,n,r){const i=n._zod.def.checks;if(!i||i.length===0)return r;let o=r;for(const s of i){const a=s._zod.def;if(a.when&&!IS.has(a.check))throw new Ce('check with a custom "when" condition');switch(a.check){case"greater_than":RS(e,t,a,o);break;case"less_than":LS(e,t,a,o);break;case"multiple_of":zS(e,t,a,o);break;case"number_format":av(e,a,o);break;case"min_length":{const u=Mn(a.minimum,"min_length"),c=iu(e,t,o,`${o}.length >= ${u} && ${o}.length < ${a.minimum*2}`);e.write(`if (${c} < ${u}) return INVALID;`);break}case"max_length":{const u=Mn(a.maximum,"max_length"),c=iu(e,t,o,`${o}.length > ${u}`);e.write(`if (${c} > ${u}) return INVALID;`);break}case"length_equals":{const u=Mn(a.length,"length_equals"),c=iu(e,t,o,`${o}.length >= ${u} && ${o}.length <= ${a.length*2}`);e.write(`if (${c} !== ${u}) return INVALID;`);break}case"min_size":e.write(`if (${o}.size < ${Mn(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${Mn(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${Mn(a.size,"size_equals")}) return INVALID;`);break;case"string_format":o=uv(e,t,a,o);break;case"custom":o=US(e,t,s,o);break;case"bigint_format":PS(e,a,o);break;case"mime_type":DS(e,t,a,o);break;case"property":MS(e,t,a,o);break;case"properties":OS(e,t,a,o);break;case"overwrite":{const u=te(t);FS(e,t,s,o,u),o=u;break}default:throw new Ce(`check type ${a.check}`)}}return o}function iu(e,t,n,r){const i=ue(t,_i),o=te(t);return e.write(`const ${o} = typeof ${n} === "string" && ${r} ? ${i}(${n}) : ${n}.length;`),o}function Mn(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new Ce(`${t} bound of type ${typeof e}`);return`${e}`}function sv(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new Ce("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new Ce("comparison check with Invalid Date bound");return ue(e,t)}throw new Ce(`comparison check bound of type ${typeof t}`)}function RS(e,t,n,r){const i=n.inclusive?"<":"<=";e.write(`if (${r} ${i} ${sv(t,n.value)}) return INVALID;`)}function LS(e,t,n,r){const i=n.inclusive?">":">=";e.write(`if (${r} ${i} ${sv(t,n.value)}) return INVALID;`)}function zS(e,t,n,r){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new Ce("multiple_of check with a zero divisor");e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{const i=ue(t,vc);e.write(`if (${i}(${r}, ${Mn(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function av(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 Ce(`number format ${r}`)}}function PS(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 Ce(`bigint format ${r}`)}}function DS(e,t,n,r){const i=n.mime;if(i&&i.length>0){const o=ue(t,new Set(i));e.write(`if (!${o}.has(${r}.type)) return INVALID;`)}}function OS(e,t,n,r){if(n.when)throw new Ce('check with a custom "when" condition');e.write(`if (${r} == null) return INVALID;`);const i=n.shape;for(const o of Reflect.ownKeys(i)){const s=typeof o=="symbol"?ue(t,o):xt(o),a=te(t);e.write(`const ${a} = ${r}[${s}];`),dt(e,t,i[o],a,!1)}}function MS(e,t,n,r){const i=`${r}[${JSON.stringify(n.property)}]`;Be(e,t,n.schema,i)}function FS(e,t,n,r,i){const o=n._zod.def.tx;if(!o)throw new Ce("overwrite check without a transform function");if(Vn(o))throw new fn("z.compile: async overwrite transforms are not supported");const s=ue(t,o);e.write(`const ${i} = ${s}(${r});`)}function Gu(){throw new sn}function wl(e){this.issues.push(e)}function US(e,t,n,r){const i=n._zod.def;if(i.fn){if(Vn(i.fn))throw new fn("z.compile: async .refine() predicates are not supported");const o=Hn(t,i.fn),s=ue(t,Gu),a=te(t);return e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`),r}if(n._zod.check){if(Vn(n._zod.check))throw new fn("z.compile: async .superRefine() / check functions are not supported");const o=n._zod.check,a=Hn(t,c=>{const l={value:c,issues:[],addIssue:wl};return o(l)instanceof Promise&&Gu(),l.issues.length===0?l.value:bt}),u=te(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}throw new Ce("custom check without a predicate or check function")}const GS=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 uv(e,t,n,r,i=!0){const o=n.format;if(o==="base64"){const c=ue(t,Os);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="base64url"){const c=ue(t,tl);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="jwt"){const c=ue(t,il),l=ue(t,n.alg??null);return e.write(`if (!${c}(${r}, ${l})) return INVALID;`),r}if(o==="ipv6"){const c=ue(t,Ds);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="cidrv6"){const c=ue(t,Qc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="credit_card"){const c=ue(t,nl);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="iban"){const c=ue(t,rl);return e.write(`if (!${c}(${r})) return INVALID;`),r}const s=n;if(o==="url"||o==="httpurl"||s.normalize||s.hostname!==void 0||s.protocol!==void 0){const c=ue(t,Jc),l=ue(t,n),d=te(t),f=te(t);if(e.write(`const ${d} = ${r}.trim();`),e.write(`const ${f} = ${c}(${d}, ${l});`),e.write(`if (typeof ${f} === "number") return INVALID;`),s.hostname!==void 0){const m=ue(t,Yc);e.write(`if (!${m}(${f}, ${l}.hostname)) return INVALID;`)}if(s.protocol!==void 0){const m=ue(t,Xc);e.write(`if (!${m}(${f}, ${l}.protocol)) return INVALID;`)}if(!i)return null;const h=te(t),p=s.normalize?`${f}.href`:`${ue(t,cs)}(${d})`;return e.write(`const ${h} = ${p};`),h}const a=n.fn;if(a){if(Vn(a))throw new Ce(`async string format ${o}`);const c=ue(t,a);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(GS.has(o)&&n.pattern){const c=ue(t,n.pattern);return e.write(`${c}.lastIndex = 0;`),e.write(`if (!${c}.test(${r})) return INVALID;`),r}const u=n.format;switch(u){case"regex":throw new Ce("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(${xt(n.includes)})) return INVALID;`);break;case"starts_with":{const c=n.prefix;e.write(`if (${r}.slice(0, ${c.length}) !== ${xt(c)}) return INVALID;`);break}case"ends_with":{const c=n.suffix;e.write(`if (${r}.slice(-${c.length}) !== ${xt(c)}) return INVALID;`);break}default:throw new Ce(`string format ${u}`)}return r}function Be(e,t,n,r,i=!0){const o=n._zod.def,s=o.type;if(o.coerce)throw new Ce(`coercion (z.coerce.${s}())`);const a=i||!!o.checks?.length;let u;switch(s){case"string":u=jS(e,t,n,r,a);break;case"number":u=ZS(e,n,r);break;case"boolean":u=BS(e,r);break;case"bigint":u=HS(e,n,r);break;case"symbol":u=VS(e,r);break;case"undefined":u=qS(e,r);break;case"null":u=WS(e,r);break;case"any":case"unknown":u=r;break;case"never":e.write("return INVALID;"),u=r;break;case"void":u=KS(e,r);break;case"nan":u=JS(e,r);break;case"date":u=YS(e,r);break;case"object":u=XS(e,t,n,r,a);break;case"optional":u=QS(e,t,n,r,a);break;case"nullable":u=n0(e,t,n,r,a);break;case"array":u=r0(e,t,n,r,a);break;case"literal":u=i0(e,t,n,r);break;case"enum":u=o0(e,t,n,r);break;case"readonly":{const c=Lh(e,t,n,r),l=te(t);e.write(`const ${l} = Object.freeze(${c});`),u=l;break}case"success":Lh(e,t,n,r),u="true";break;case"default":case"prefault":u=s0(e,t,n,r);break;case"nonoptional":u=a0(e,t,n,r);break;case"tuple":u=u0(e,t,n,r);break;case"union":u=c0(e,t,n,r);break;case"intersection":u=f0(e,t,n,r);break;case"record":u=h0(e,t,n,r);break;case"map":u=m0(e,t,n,r);break;case"set":u=g0(e,t,n,r);break;case"file":u=y0(e,r);break;case"template_literal":u=v0(e,t,n,r);break;case"lazy":u=b0(e,t,n,r);break;case"pipe":u=w0(e,t,n,r);break;case"custom":u=_0(e,t,n,r);break;case"transform":u=x0(e,t,n,r);break;case"catch":u=S0(e,t,n,r);break;default:throw new Ce(`schema type ${s}`)}return u===null?null:NS(e,t,n,u)}function jS(e,t,n,r,i=!0){e.write(`if (typeof ${r} !== "string") return INVALID;`);const o=n._zod.def;return o.format===void 0?r:uv(e,t,o,r,i)}function ZS(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&&av(e,{format:r.format},n),n}function BS(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function HS(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 VS(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function qS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function WS(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function KS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function JS(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function YS(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function XS(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (typeof ${r} !== "object" || ${r} === null || Array.isArray(${r})) return INVALID;`);const s=o.shape,a=Object.keys(s),u=Object.getOwnPropertySymbols(s),c=u.length?[...a,...u]:a,l=g=>typeof g=="symbol"?ue(t,g):xt(g),d=g=>typeof g=="symbol"?`[${l(g)}]`:xt(g),f=s;if(a.includes("__proto__"))throw new Ce('object shape key "__proto__"');const h=new Map;for(const g of c){const b=f[g],v=l(g),k=te(t);if(e.write(`const ${k} = ${r}[${v}];`),b._zod.optin!==void 0){const _=te(t);e.write(`let ${_} = (() => {`),e.indented($=>{const O=dt($,t,b,k);$.write(`return ${O};`)}),e.write("})();"),b._zod.optout==="optional"?(e.write(`if (${_} === INVALID) {`),e.indented($=>{$.write(`if (${v} in ${r}) return INVALID;`),$.write(`${_} = undefined;`)}),e.write("}")):e.write(`if (${_} === INVALID) return INVALID;`),h.set(g,_)}else{t0(b)&&e.write(`if (!(${v} in ${r})) return INVALID;`);const _=dt(e,t,b,k,i);_!==null&&h.set(g,_)}}const p=o.catchall;let m="none";if(p){const g=p._zod.def.type;if(g==="never"){const b=a.map(v=>`k !== ${xt(v)}`).join(" && ")||"true";e.write(`for (const k in ${r}) {`),e.indented(v=>{v.write(`if (${b}) return INVALID;`)}),e.write("}")}else(g==="unknown"||g==="any")&&!p._zod.def.checks?.length?m="passthrough":m="schema"}const y=te(t),w=c.some(g=>Rh(f[g])||ju(f[g]));if(!i){if(m==="schema"){const g=a.length>0?ue(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{b.write('if (k === "__proto__") continue;'),g&&b.write(`if (${g}.has(k)) continue;`);const v=te(t);b.write(`const ${v} = ${r}[k];`),dt(b,t,p,v,!1)}),e.write("}")}return null}if(w){e.write(`const ${y} = {};`);for(const g of c){const b=l(g),v=h.get(g);ju(f[g])?e.write(`if (${b} in ${r}) ${y}[${b}] = ${v};`):Rh(f[g])?e.write(`if (${v} !== undefined || ${b} in ${r}) ${y}[${b}] = ${v};`):e.write(`${y}[${b}] = ${v};`)}}else{const g=c.map(b=>`${d(b)}: ${h.get(b)}`).join(", ");e.write(`const ${y} = { ${g} };`)}if(m!=="none"){const g=a.length>0?ue(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{if(b.write('if (k === "__proto__") continue;'),g&&b.write(`if (${g}.has(k)) continue;`),m==="passthrough")b.write(`${y}[k] = ${r}[k];`);else{const v=te(t);b.write(`const ${v} = ${r}[k];`);const k=dt(b,t,p,v);b.write(`${y}[k] = ${k};`)}}),e.write("}")}return y}function QS(e,t,n,r,i=!0){const o=n._zod.def;if(e0(n))return Be(e,t,o.innerType,r,i);if(o.innerType._zod.optin==="defaulted"){const a=te(t),u=te(t);return e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(c=>{c.write(`const ${u} = (() => {`),c.indented(l=>{const d=Be(l,t,o.innerType,r);l.write(`return ${d};`)}),c.write("})();"),c.write(`if (${u} !== INVALID) ${a} = ${u};`)}),e.write("} else {"),e.indented(c=>{const l=Be(c,t,o.innerType,r);c.write(`${a} = ${l};`)}),e.write("}"),a}const s=i?te(t):null;return s&&e.write(`let ${s};`),e.write(`if (${r} !== undefined) {`),e.indented(a=>{const u=Be(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function e0(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function t0(e){return e._zod.optin===void 0&&Fn(e)}function Fn(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?Fn(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?Fn(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Fn):!0;case"intersection":return!t.left||!t.right?!0:Fn(t.left)&&Fn(t.right);case"pipe":return t.in?Fn(t.in):!0;default:return!0}}function ju(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function Rh(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&tr(e)}function tr(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?tr(t.innerType):!0;case"union":return t.options?t.options.some(tr):!0;case"intersection":return!t.left||!t.right||tr(t.left)||tr(t.right);case"pipe":return t.out?tr(t.out):!0;default:return!0}}function n0(e,t,n,r,i=!0){const o=n._zod.def,s=i?te(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${r} !== null) {`),e.indented(a=>{const u=Be(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function r0(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`);const s=i?te(t):null,a=te(t),u=te(t);return s&&e.write(`const ${s} = new Array(${r}.length);`),e.write(`for (let ${a} = 0; ${a} < ${r}.length; ${a}++) {`),e.indented(c=>{c.write(`const ${u} = ${r}[${a}];`);const l=dt(c,t,o.element,u,i);s&&l!==null&&c.write(`${s}[${a}] = ${l};`)}),e.write("}"),s}function i0(e,t,n,r){const o=n._zod.def.values;if(o.length!==1){const a=ue(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}const s=o[0];if(typeof s=="number"&&Number.isNaN(s)){const a=ue(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}if(typeof s=="string")e.write(`if (${r} !== ${xt(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 Ce(`literal type ${typeof s}`);return r}function o0(e,t,n,r){const i=n._zod.values;if(!i)throw new Ce("enum schema without enumerated values");const o=ue(t,i);return e.write(`if (!${o}.has(${r})) return INVALID;`),r}function Lh(e,t,n,r){const i=n._zod.def;return Be(e,t,i.innerType,r)}function s0(e,t,n,r){const i=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 Be(e,t,i.innerType,r);const u=ue(t,s),c=te(t);return e.write(`let ${c} = ${r};`),e.write(`if (${r} === undefined) ${c} = ${u}();`),Be(e,t,i.innerType,c)}const a=te(t);if(s){const u=ue(t,s),c=ue(t,wi);e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(l=>{l.write(`${a} = ${c}(${u}());`)}),e.write("} else {"),e.indented(l=>{const d=Be(l,t,i.innerType,r);l.write(`${a} = ${d} === undefined ? ${c}(${u}()) : ${d};`)}),e.write("}")}else e.write(`let ${a};`),e.write(`if (${r} !== undefined) {`),e.indented(u=>{const c=Be(u,t,i.innerType,r);u.write(`${a} = ${c};`)}),e.write("}");return a}function a0(e,t,n,r){const i=n._zod.def,o=Be(e,t,i.innerType,r),s=te(t);return e.write(`const ${s} = ${o};`),e.write(`if (${s} === undefined) return INVALID;`),s}function u0(e,t,n,r){const i=n._zod.def,o=i.items,s=i.rest;e.write(`if (!Array.isArray(${r})) return INVALID;`);const a=zh(o,"optin"),u=zh(o,"optout");s?e.write(`if (${r}.length < ${a}) return INVALID;`):e.write(`if (${r}.length < ${a} || ${r}.length > ${o.length}) return INVALID;`);const c=te(t);e.write(`const ${c} = [];`);for(let l=0;l<o.length;l++){const d=o[l];if(l>=u)e.write(`if (${c}.length === ${l}) {`),e.indented(f=>{f.write(`if (${l} < ${r}.length) {`),f.indented(h=>{const p=te(t);h.write(`const ${p} = ${r}[${l}];`);const m=dt(h,t,d,p);h.write(`${c}[${l}] = ${m};`)}),f.write("} else {"),f.indented(h=>{if(ju(d)){h.write(`${c}.length = ${l};`);return}const p=te(t),m=te(t);h.write(`const ${p} = undefined;`),h.write(`const ${m} = (() => {`),h.indented(y=>{const w=dt(y,t,d,p);y.write(`return ${w};`)}),h.write("})();"),h.write(`if (${m} === INVALID || ${m} === undefined) ${c}.length = ${l};`),h.write(`else ${c}[${l}] = ${m};`)}),f.write("}")}),e.write("}");else{const f=te(t);e.write(`const ${f} = ${r}[${l}];`);const h=dt(e,t,d,f);e.write(`${c}[${l}] = ${h};`)}}if(s){const l=te(t),d=te(t);e.write(`for (let ${l} = ${o.length}; ${l} < ${r}.length; ${l}++) {`),e.indented(f=>{f.write(`const ${d} = ${r}[${l}];`);const h=dt(f,t,s,d);f.write(`${c}[${l}] = ${h};`)}),e.write("}")}return c}function zh(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 c0(e,t,n,r){const i=n._zod.def,o=i.options;if(i.discriminator)return l0(e,t,i,r);if(i.inclusive===!1)throw new Ce("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),r;if(o.length===1)return Be(e,t,o[0],r);if(o.every(u=>u._zod.def.type==="literal"&&!u._zod.def.checks?.length)){const u=new Set(o.flatMap(l=>l._zod.def.values)),c=ue(t,u);return e.write(`if (!${c}.has(${r})) return INVALID;`),r}const a=te(t);e.write(`let ${a};`);for(let u=0;u<o.length;u++){const c=o[u];u===0?e.write(`${a} = (() => {`):e.write(`if (${a} === INVALID) ${a} = (() => {`),e.indented(l=>{const d=Be(l,t,c,r);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function l0(e,t,n,r){if(n.unionFallback)throw new Ce("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),r;const i=te(t),o=te(t);e.write(`const ${i} = ${r}?.[${xt(n.discriminator)}];`),e.write(`let ${o};`);let s=!0;const a=new Set;for(const u of n.options){const c=u._zod.propValues?.[n.discriminator];if(!c||c.size===0)throw new Ce("discriminated union option without static discriminator values");for(const f of c){if(a.has(f))throw new Ce(`duplicate discriminator value ${String(f)}`);a.add(f)}const l=Array.from(c,f=>d0(t,i,f)),d=s?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{const h=Be(f,t,u,r);f.write(`${o} = ${h};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),o}function d0(e,t,n){if(typeof n=="string")return`${t} === ${xt(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=ue(e,n);return`${t} === ${r}`}throw new Ce(`literal discriminator value ${String(n)}`)}function f0(e,t,n,r){const i=n._zod.def;t.definite=!1;const o=dt(e,t,i.left,r),s=dt(e,t,i.right,r),a=ue(t,ui),u=te(t);return e.write(`const ${u} = ${a}(${o}, ${s});`),e.write(`if (!${u}.valid) return INVALID;`),`${u}.data`}function h0(e,t,n,r){const i=n._zod.def,o=ue(t,cn);e.write(`if (!${o}(${r})) return INVALID;`);const s=te(t),a=te(t),u=te(t);e.write(`const ${s} = {};`);const c=i,l=c.partial?void 0:i.keyType._zod.values;if(l){const h=[];for(const m of l){if(!(typeof m=="string"||typeof m=="number"||typeof m=="symbol"))throw new Ce(`record key value ${String(m)}`);const y=typeof m=="number"?m.toString():m;if(y==="__proto__")throw new Ce('record key "__proto__"');h.push(y);const w=ue(t,m),g=Be(e,t,i.keyType,w),b=te(t);e.write(`const ${b} = ${r}[${p0(t,y)}];`);const v=dt(e,t,i.valueType,b);e.write(`${s}[${g}] = ${v};`)}const p=ue(t,new Set(h));return e.write(`for (const ${a} in ${r}) {`),e.indented(m=>{m.write(`if (${p}.has(${a})) continue;`),c.mode==="loose"?m.write(`if (${a} !== "__proto__") ${s}[${a}] = ${r}[${a}];`):m.write("return INVALID;")}),e.write("}"),s}const d=i.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){const h=i.mode==="loose",p=Zs(i.keyType);p.definite===!1&&(t.definite=!1);const m=ue(t,p),y=ue(t,wr),w=te(t);return Ph(e,t,r,a,g=>{g.write(`let ${w} = ${m}(${a});`),g.write(`if (${w} === INVALID && typeof ${a} === "string" && ${y}.test(${a})) ${w} = ${m}(Number(${a}));`),h?g.write(`if (${w} === INVALID) { ${s}[${a}] = ${r}[${a}]; continue; }`):g.write(`if (${w} === INVALID) return INVALID;`),g.write(`if (${w} === "__proto__") continue;`);const b=te(t);g.write(`const ${b} = ${r}[${a}];`);const v=dt(g,t,i.valueType,b);g.write(`${s}[${w}] = ${v};`)}),s}return Ph(e,t,r,a,h=>{h.write(`const ${u} = ${r}[${a}];`);const p=dt(h,t,i.valueType,u);h.write(`${s}[${a}] = ${p};`)},"return INVALID;"),s}function Ph(e,t,n,r,i,o){const s=ue(t,Object.prototype.propertyIsEnumerable),a=te(t),u=te(t),c=te(t);e.write(`const ${a} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${u} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${c} = 0; ${c} < ${u}.length; ${c}++) {`),e.indented(l=>{l.write(`const ${r} = ${u}[${c}];`),l.write(`if (${r} === "__proto__" || !${s}.call(${n}, ${r})) continue;`),i(l)}),e.write("}"),e.write(`for (let ${c} = 0; ${c} < ${a}.length; ${c}++) {`),e.indented(l=>{l.write(`const ${r} = ${a}[${c}];`),l.write(`if (!${s}.call(${n}, ${r})) continue;`),o?l.write(o):i(l)}),e.write("}")}function p0(e,t){return typeof t=="string"?xt(t):ue(e,t)}function m0(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`);const o=te(t),s=te(t),a=te(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${s}, ${a}] of ${r}) {`),e.indented(u=>{const c=Be(u,t,i.keyType,s),l=Be(u,t,i.valueType,a);u.write(`${o}.set(${c}, ${l});`)}),e.write("}"),o}function g0(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`);const o=te(t),s=te(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${s} of ${r}) {`),e.indented(a=>{const u=Be(a,t,i.valueType,s);a.write(`${o}.add(${u});`)}),e.write("}"),o}function y0(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function v0(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);const i=n._zod.pattern;if(i){const o=ue(t,i);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${r})) return INVALID;`)}return r}function b0(e,t,n,r){const i=n._zod.def,o=Hn(t,i.getter),s=ue(t,{parser:null});e.write(`if (!${s}.parser) {`),e.indented(u=>{u.write(`const inner = ${o}();`),u.write(`${s}.parser = function(input) {`),u.indented(c=>{c.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),c.write("return result.issues.length === 0 ? result.value : INVALID;")}),u.write("};")}),e.write("}");const a=te(t);return e.write(`const ${a} = ${s}.parser(${r});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function w0(e,t,n,r){const i=n._zod.def,o=Be(e,t,i.in,r);if(i.transform){if(Vn(i.transform))throw new fn("z.compile: async transforms in pipes are not supported");const s=i.transform,u=Hn(t,l=>{const d={value:l,issues:[],addIssue:wl},f=s(l,d);return f instanceof Promise?bt:d.issues.length===0?f:bt}),c=te(t);return e.write(`const ${c} = ${u}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),Be(e,t,i.out,c)}else return Be(e,t,i.out,o)}function Vn(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function _0(e,t,n,r){const i=n._zod.def;if(i.fn){if(Vn(i.fn))throw new fn("z.compile: async custom predicates are not supported");const o=Hn(t,i.fn),s=ue(t,Gu),a=te(t);e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`)}else throw new Ce("custom schema without a predicate function");return r}function k0(e,t,n){const r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then=="function")return bt;const i=r;return i.issues.length===0?i.value:t()}function S0(e,t,n,r){const i=n._zod.def;if(!i.catchValue[Sc])throw new Ce("catch with a callback (only a constant catch value compiles)",!1);const o=te(t);e.write(`let ${o} = (() => {`),e.indented(c=>{const l=dt(c,t,i.innerType,r);c.write(`return ${l};`)}),e.write("})();");const s=ue(t,i.innerType),a=Hn(t,i.catchValue),u=ue(t,k0);return e.write(`if (${o} === INVALID) {`),e.indented(c=>{c.write(`${o} = ${u}(${s}, ${a}, ${r});`),c.write(`if (${o} === INVALID) return INVALID;`)}),e.write("}"),o}function x0(e,t,n,r){const i=n._zod.def;if(i.transform){if(Vn(i.transform))throw new fn("z.compile: async transforms are not supported");const o=i.transform,a=Hn(t,c=>{const l={value:c,issues:[],addIssue:wl},d=o(c,l);return d instanceof Promise?bt:l.issues.length===0?d:bt}),u=te(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}return r}function Bs(e){return e.checks&&(e.checks=[...e.checks]),e}function cv(e,t){return new e(Bs({type:"string",...N(t)}))}function lv(e,t){return new e(Bs({type:"string",coerce:!0,...N(t)}))}function _l(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...N(t)})}function kl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...N(t)})}function Sl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...N(t)})}function xl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...N(t)})}function El(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...N(t)})}function $l(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...N(t)})}function Hs(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...N(t)})}function Tl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...N(t)})}function Cl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...N(t)})}function Al(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...N(t)})}function Il(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...N(t)})}function Nl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...N(t)})}function Rl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...N(t)})}function Ll(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...N(t)})}function zl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...N(t)})}function Pl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...N(t)})}function dv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...N(t)})}function Dl(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...N(t)})}function Ol(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...N(t)})}function Ml(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...N(t)})}function Fl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...N(t)})}function Ul(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...N(t)})}function fv(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...N(t)})}function hv(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...N(t)})}function Gl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...N(t)})}const jl={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Zl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...N(t)})}function Bl(e,t){return new e({type:"string",format:"date",check:"string_format",...N(t)})}function Hl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...N(t)})}function Vl(e,t){return new e({type:"string",format:"duration",check:"string_format",...N(t)})}function pv(e,t){return new e(Bs({type:"number",checks:[],...N(t)}))}function mv(e,t){return new e(Bs({type:"number",coerce:!0,checks:[],...N(t)}))}function gv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...N(t)})}function yv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...N(t)})}function vv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...N(t)})}function bv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...N(t)})}function wv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...N(t)})}function _v(e,t){return new e({type:"boolean",...N(t)})}function kv(e,t){return new e({type:"boolean",coerce:!0,...N(t)})}function Sv(e,t){return new e({type:"bigint",...N(t)})}function xv(e,t){return new e({type:"bigint",coerce:!0,...N(t)})}function Ev(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...N(t)})}function $v(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...N(t)})}function Tv(e,t){return new e({type:"symbol",...N(t)})}function Cv(e,t){return new e({type:"undefined",...N(t)})}function Av(e,t){return new e({type:"null",...N(t)})}function Iv(e){return new e({type:"any"})}function Nv(e){return new e({type:"unknown"})}function Rv(e,t){return new e({type:"never",...N(t)})}function Lv(e,t){return new e({type:"void",...N(t)})}function zv(e,t){return new e({type:"date",...N(t)})}function Pv(e,t){return new e({type:"date",coerce:!0,...N(t)})}function Dv(e,t){return new e({type:"nan",...N(t)})}function hn(e,t){return new Bc({check:"less_than",...N(t),value:e,inclusive:!1})}function Et(e,t){return new Bc({check:"less_than",...N(t),value:e,inclusive:!0})}function pn(e,t){return new Hc({check:"greater_than",...N(t),value:e,inclusive:!1})}function $t(e,t){return new Hc({check:"greater_than",...N(t),value:e,inclusive:!0})}function Vs(e){return pn(0,e)}function qs(e){return hn(0,e)}function Ws(e){return Et(0,e)}function Ks(e){return $t(0,e)}function qn(e,t){return new _g({check:"multiple_of",...N(t),value:e})}function Yn(e,t){return new xg({check:"max_size",...N(t),maximum:e})}function mn(e,t){return new Eg({check:"min_size",...N(t),minimum:e})}function _r(e,t){return new $g({check:"size_equals",...N(t),size:e})}function kr(e,t){return new Tg({check:"max_length",...N(t),maximum:e})}function In(e,t){return new Cg({check:"min_length",...N(t),minimum:e})}function Sr(e,t){return new Ag({check:"length_equals",...N(t),length:e})}function Ni(e,t){return new Ig({check:"string_format",format:"regex",...N(t),pattern:e})}function Ri(e){return new Ng({check:"string_format",format:"lowercase",...N(e)})}function Li(e){return new Rg({check:"string_format",format:"uppercase",...N(e)})}function zi(e,t){return new Lg({check:"string_format",format:"includes",...N(t),includes:e})}function Pi(e,t){return new zg({check:"string_format",format:"starts_with",...N(t),prefix:e})}function Di(e,t){return new Pg({check:"string_format",format:"ends_with",...N(t),suffix:e})}function Js(e,t,n){return new Dg({check:"property",property:e,schema:t,...N(n)})}function Oi(e,t){return new Og({check:"properties",shape:e,...N(t)})}function Mi(e,t){return new Mg({check:"mime_type",mime:e,...N(t)})}function tn(e){return new Fg({check:"overwrite",tx:e})}function Fi(e){return tn(t=>t.normalize(e))}function Ui(){return tn(e=>e.trim())}function Gi(){return tn(e=>e.toLowerCase())}function ji(){return tn(e=>e.toUpperCase())}function Zi(){return tn(e=>ym(e))}function Ov(e,t,n){return new e({type:"array",element:t,...N(n)})}function E0(e,t,n){return new e({type:"union",options:t,...N(n)})}function $0(e,t,n){return new e({type:"union",options:t,inclusive:!1,...N(n)})}function T0(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...N(r)})}function C0(e,t,n){return new e({type:"intersection",left:t,right:n})}function A0(e,t,n,r){const i=n instanceof pe,o=i?r:n,s=i?n:null;return new e({type:"tuple",items:t,rest:s,...N(o)})}function I0(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...N(r)})}function N0(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...N(r)})}function R0(e,t,n){return new e({type:"set",valueType:t,...N(n)})}function L0(e,t,n){const r=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:r,...N(n)})}function z0(e,t,n){return new e({type:"enum",entries:t,...N(n)})}function P0(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...N(n)})}function Mv(e,t){return new e({type:"file",...N(t)})}function D0(e,t){return new e({type:"transform",transform:t})}function O0(e,t){return new e({type:"optional",innerType:t})}function M0(e,t){return new e({type:"nullable",innerType:t})}function F0(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():wi(n)}})}function U0(e,t,n){return new e({type:"nonoptional",innerType:t,...N(n)})}function G0(e,t){return new e({type:"success",innerType:t})}function j0(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:xc(n)})}function Z0(e,t,n){return new e({type:"pipe",in:t,out:n})}function B0(e,t){return new e({type:"readonly",innerType:t})}function H0(e,t,n){return new e({type:"template_literal",parts:t,...N(n)})}function V0(e,t){return new e({type:"lazy",getter:t})}function q0(e,t){return new e({type:"promise",innerType:t})}function Fv(e,t,n){const r=N(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function Uv(e,t,n){return new e({type:"custom",check:"custom",fn:t,...N(n)})}function Gv(e,t){const n=jv(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(ar(i,r.value,n._zod.def));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=r.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),r.issues.push(ar(o))}},e(r.value,r)),t);return n}function jv(e,t){const n=new Ze({check:"custom",...N(t)});return n._zod.check=e,n}function Zv(e){const t=new Ze({check:"describe"});return t._zod.onattach=[n=>{const r=St.get(n)??{};St.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function Bv(e){const t=new Ze({check:"meta"});return t._zod.onattach=[n=>{const r=St.get(n)??{};St.add(n,{...r,...e})}],t._zod.check=()=>{},t}function Hv(e,t){const n=N(t);let r=n.truthy??["true","1","yes","on","y","enabled"],i=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(r=r.map(h=>typeof h=="string"?h.toLowerCase():h),i=i.map(h=>typeof h=="string"?h.toLowerCase():h));const o=new Set(r),s=new Set(i),a=e.Codec??fl,u=e.Boolean??sl,c=e.String??Ii,l=new c({type:"string",error:n.error}),d=new u({type:"boolean",error:n.error}),f=new a({type:"pipe",in:l,out:d,transform:((h,p)=>{let m=h;return n.case!=="sensitive"&&(m=m.toLowerCase()),o.has(m)?!0:s.has(m)?!1:(p.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...s],input:p.value,inst:f,continue:!1}),{})}),reverseTransform:((h,p)=>h===!0?r[0]||"true":i[0]||"false"),error:n.error});return f._zod.bag.truthy=r,f._zod.bag.falsy=i,f._zod.bag.case=n.case??"insensitive",f}function xr(e,t,n,r={}){const i=N(r),o={check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:a=>n.test(a),...i};return n instanceof RegExp&&(o.pattern=n),new e(o)}function ii(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&Tt(e,r,n[r]);return e}function cr(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??St,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 nt(e,t,n,r,i){const o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(i);return Object.assign(n,o),!0}function Oe(e,t,n={path:[],schemaPath:[]}){var r;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.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,h=t.processors[i.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,f,l)}const d=e._zod.parent;d&&(s.ref||(s.ref=d),Oe(d,t,l),t.seen.get(d).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&ii(s.schema,u),t.io==="input"&&mt(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 Dh(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function lr(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 u=r.get(a);if(u&&u!==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 i=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??(p=>p);if(d)return{ref:f(d)};const h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${f("__shared")}#/${a}/${Dh(h)}`}}const u="#",c=`${u}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:u};const l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:c+Dh(l)}},o=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:u,defId:c}=i(s);a.def={...a.schema},c&&(a.defId=c);const l=a.schema;for(const d in l)delete l[d];l.$ref=u};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(h){throw new Ce(`this schema (generated code failed to evaluate: ${h.message})`)}return t?.debug&&(f.code=c),f.definite=r.definite,f}function ue(e,t){for(const[r,i]of e.constants)if(i===t)return r;const n=`c${e.constantCounter++}`;return e.constants.set(n,t),n}function Hn(e,t){return e.definite=!1,ue(e,t)}function te(e){return`v${e.varCounter++}`}function NS(e,t){const n=e._zod.run({value:t,issues:[]},{});if(n&&typeof n.then=="function")return bt;const r=n;return r.issues.length===0?r.value:bt}function dt(e,t,n,r,i=!0){const o=e.content.length,s=t.constants.size,a=t.constantCounter,u=t.varCounter;try{return Be(e,t,n,r,i)}catch(c){if(!(c instanceof Ce)||!c.islandable)throw c;if(e.content.length=o,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=u,RS(e,t,n,r)}}function RS(e,t,n,r){t.definite=!1;const i=ue(t,n),o=ue(t,NS),s=te(t);return e.write(`const ${s} = ${o}(${i}, ${r});`),e.write(`if (${s} === INVALID) return INVALID;`),s}const LS=new Set(["max_size","min_size","size_equals","max_length","min_length","length_equals"]);function zS(e,t,n,r){const i=n._zod.def.checks;if(!i||i.length===0)return r;let o=r;for(const s of i){const a=s._zod.def;if(a.when&&!LS.has(a.check))throw new Ce('check with a custom "when" condition');switch(a.check){case"greater_than":PS(e,t,a,o);break;case"less_than":OS(e,t,a,o);break;case"multiple_of":DS(e,t,a,o);break;case"number_format":cv(e,a,o);break;case"min_length":{const u=Mn(a.minimum,"min_length"),c=iu(e,t,o,`${o}.length >= ${u} && ${o}.length < ${a.minimum*2}`);e.write(`if (${c} < ${u}) return INVALID;`);break}case"max_length":{const u=Mn(a.maximum,"max_length"),c=iu(e,t,o,`${o}.length > ${u}`);e.write(`if (${c} > ${u}) return INVALID;`);break}case"length_equals":{const u=Mn(a.length,"length_equals"),c=iu(e,t,o,`${o}.length >= ${u} && ${o}.length <= ${a.length*2}`);e.write(`if (${c} !== ${u}) return INVALID;`);break}case"min_size":e.write(`if (${o}.size < ${Mn(a.minimum,"min_size")}) return INVALID;`);break;case"max_size":e.write(`if (${o}.size > ${Mn(a.maximum,"max_size")}) return INVALID;`);break;case"size_equals":e.write(`if (${o}.size !== ${Mn(a.size,"size_equals")}) return INVALID;`);break;case"string_format":o=lv(e,t,a,o);break;case"custom":o=ZS(e,t,s,o);break;case"bigint_format":MS(e,a,o);break;case"mime_type":FS(e,t,a,o);break;case"property":GS(e,t,a,o);break;case"properties":US(e,t,a,o);break;case"overwrite":{const u=te(t);jS(e,t,s,o,u),o=u;break}default:throw new Ce(`check type ${a.check}`)}}return o}function iu(e,t,n,r){const i=ue(t,_i),o=te(t);return e.write(`const ${o} = typeof ${n} === "string" && ${r} ? ${i}(${n}) : ${n}.length;`),o}function Mn(e,t){if(typeof e!="number"||!Number.isFinite(e))throw new Ce(`${t} bound of type ${typeof e}`);return`${e}`}function uv(e,t){if(typeof t=="bigint")return`${t}n`;if(typeof t=="number"){if(Number.isNaN(t))throw new Ce("comparison check with NaN bound");return`${t}`}if(t instanceof Date){if(Number.isNaN(t.getTime()))throw new Ce("comparison check with Invalid Date bound");return ue(e,t)}throw new Ce(`comparison check bound of type ${typeof t}`)}function PS(e,t,n,r){const i=n.inclusive?"<":"<=";e.write(`if (${r} ${i} ${uv(t,n.value)}) return INVALID;`)}function OS(e,t,n,r){const i=n.inclusive?">":">=";e.write(`if (${r} ${i} ${uv(t,n.value)}) return INVALID;`)}function DS(e,t,n,r){if(typeof n.value=="bigint"){if(n.value===BigInt(0))throw new Ce("multiple_of check with a zero divisor");e.write(`if (${r} % ${n.value}n !== 0n) return INVALID;`)}else{const i=ue(t,vc);e.write(`if (${i}(${r}, ${Mn(n.value,"multiple_of")}) !== 0) return INVALID;`)}}function cv(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 Ce(`number format ${r}`)}}function MS(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 Ce(`bigint format ${r}`)}}function FS(e,t,n,r){const i=n.mime;if(i&&i.length>0){const o=ue(t,new Set(i));e.write(`if (!${o}.has(${r}.type)) return INVALID;`)}}function US(e,t,n,r){if(n.when)throw new Ce('check with a custom "when" condition');e.write(`if (${r} == null) return INVALID;`);const i=n.shape;for(const o of Reflect.ownKeys(i)){const s=typeof o=="symbol"?ue(t,o):Et(o),a=te(t);e.write(`const ${a} = ${r}[${s}];`),dt(e,t,i[o],a,!1)}}function GS(e,t,n,r){const i=`${r}[${JSON.stringify(n.property)}]`;Be(e,t,n.schema,i)}function jS(e,t,n,r,i){const o=n._zod.def.tx;if(!o)throw new Ce("overwrite check without a transform function");if(Vn(o))throw new hn("z.compile: async overwrite transforms are not supported");const s=ue(t,o);e.write(`const ${i} = ${s}(${r});`)}function Gu(){throw new an}function wl(e){this.issues.push(e)}function ZS(e,t,n,r){const i=n._zod.def;if(i.fn){if(Vn(i.fn))throw new hn("z.compile: async .refine() predicates are not supported");const o=Hn(t,i.fn),s=ue(t,Gu),a=te(t);return e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`),r}if(n._zod.check){if(Vn(n._zod.check))throw new hn("z.compile: async .superRefine() / check functions are not supported");const o=n._zod.check,a=Hn(t,c=>{const l={value:c,issues:[],addIssue:wl};return o(l)instanceof Promise&&Gu(),l.issues.length===0?l.value:bt}),u=te(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}throw new Ce("custom check without a predicate or check function")}const BS=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 lv(e,t,n,r,i=!0){const o=n.format;if(o==="base64"){const c=ue(t,Ds);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="base64url"){const c=ue(t,tl);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="jwt"){const c=ue(t,il),l=ue(t,n.alg??null);return e.write(`if (!${c}(${r}, ${l})) return INVALID;`),r}if(o==="ipv6"){const c=ue(t,Os);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="cidrv6"){const c=ue(t,Qc);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="credit_card"){const c=ue(t,nl);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(o==="iban"){const c=ue(t,rl);return e.write(`if (!${c}(${r})) return INVALID;`),r}const s=n;if(o==="url"||o==="httpurl"||s.normalize||s.hostname!==void 0||s.protocol!==void 0){const c=ue(t,Jc),l=ue(t,n),d=te(t),f=te(t);if(e.write(`const ${d} = ${r}.trim();`),e.write(`const ${f} = ${c}(${d}, ${l});`),e.write(`if (typeof ${f} === "number") return INVALID;`),s.hostname!==void 0){const m=ue(t,Yc);e.write(`if (!${m}(${f}, ${l}.hostname)) return INVALID;`)}if(s.protocol!==void 0){const m=ue(t,Xc);e.write(`if (!${m}(${f}, ${l}.protocol)) return INVALID;`)}if(!i)return null;const h=te(t),p=s.normalize?`${f}.href`:`${ue(t,cs)}(${d})`;return e.write(`const ${h} = ${p};`),h}const a=n.fn;if(a){if(Vn(a))throw new Ce(`async string format ${o}`);const c=ue(t,a);return e.write(`if (!${c}(${r})) return INVALID;`),r}if(BS.has(o)&&n.pattern){const c=ue(t,n.pattern);return e.write(`${c}.lastIndex = 0;`),e.write(`if (!${c}.test(${r})) return INVALID;`),r}const u=n.format;switch(u){case"regex":throw new Ce("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(${Et(n.includes)})) return INVALID;`);break;case"starts_with":{const c=n.prefix;e.write(`if (${r}.slice(0, ${c.length}) !== ${Et(c)}) return INVALID;`);break}case"ends_with":{const c=n.suffix;e.write(`if (${r}.slice(-${c.length}) !== ${Et(c)}) return INVALID;`);break}default:throw new Ce(`string format ${u}`)}return r}function Be(e,t,n,r,i=!0){const o=n._zod.def,s=o.type;if(o.coerce)throw new Ce(`coercion (z.coerce.${s}())`);const a=i||!!o.checks?.length;let u;switch(s){case"string":u=HS(e,t,n,r,a);break;case"number":u=VS(e,n,r);break;case"boolean":u=qS(e,r);break;case"bigint":u=WS(e,n,r);break;case"symbol":u=KS(e,r);break;case"undefined":u=JS(e,r);break;case"null":u=YS(e,r);break;case"any":case"unknown":u=r;break;case"never":e.write("return INVALID;"),u=r;break;case"void":u=XS(e,r);break;case"nan":u=QS(e,r);break;case"date":u=e0(e,r);break;case"object":u=t0(e,t,n,r,a);break;case"optional":u=n0(e,t,n,r,a);break;case"nullable":u=o0(e,t,n,r,a);break;case"array":u=s0(e,t,n,r,a);break;case"literal":u=a0(e,t,n,r);break;case"enum":u=u0(e,t,n,r);break;case"readonly":{const c=zh(e,t,n,r),l=te(t);e.write(`const ${l} = Object.freeze(${c});`),u=l;break}case"success":zh(e,t,n,r),u="true";break;case"default":case"prefault":u=c0(e,t,n,r);break;case"nonoptional":u=l0(e,t,n,r);break;case"tuple":u=d0(e,t,n,r);break;case"union":u=f0(e,t,n,r);break;case"intersection":u=m0(e,t,n,r);break;case"record":u=g0(e,t,n,r);break;case"map":u=v0(e,t,n,r);break;case"set":u=b0(e,t,n,r);break;case"file":u=w0(e,r);break;case"template_literal":u=_0(e,t,n,r);break;case"lazy":u=k0(e,t,n,r);break;case"pipe":u=S0(e,t,n,r);break;case"custom":u=E0(e,t,n,r);break;case"transform":u=T0(e,t,n,r);break;case"catch":u=$0(e,t,n,r);break;default:throw new Ce(`schema type ${s}`)}return u===null?null:zS(e,t,n,u)}function HS(e,t,n,r,i=!0){e.write(`if (typeof ${r} !== "string") return INVALID;`);const o=n._zod.def;return o.format===void 0?r:lv(e,t,o,r,i)}function VS(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&&cv(e,{format:r.format},n),n}function qS(e,t){return e.write(`if (typeof ${t} !== "boolean") return INVALID;`),t}function WS(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 KS(e,t){return e.write(`if (typeof ${t} !== "symbol") return INVALID;`),t}function JS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function YS(e,t){return e.write(`if (${t} !== null) return INVALID;`),t}function XS(e,t){return e.write(`if (${t} !== undefined) return INVALID;`),t}function QS(e,t){return e.write(`if (typeof ${t} !== "number" || !Number.isNaN(${t})) return INVALID;`),t}function e0(e,t){return e.write(`if (!(${t} instanceof Date) || Number.isNaN(${t}.getTime())) return INVALID;`),t}function t0(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (typeof ${r} !== "object" || ${r} === null || Array.isArray(${r})) return INVALID;`);const s=o.shape,a=Object.keys(s),u=Object.getOwnPropertySymbols(s),c=u.length?[...a,...u]:a,l=g=>typeof g=="symbol"?ue(t,g):Et(g),d=g=>typeof g=="symbol"?`[${l(g)}]`:Et(g),f=s;if(a.includes("__proto__"))throw new Ce('object shape key "__proto__"');const h=new Map;for(const g of c){const b=f[g],v=l(g),k=te(t);if(e.write(`const ${k} = ${r}[${v}];`),b._zod.optin!==void 0){const _=te(t);e.write(`let ${_} = (() => {`),e.indented($=>{const D=dt($,t,b,k);$.write(`return ${D};`)}),e.write("})();"),b._zod.optout==="optional"?(e.write(`if (${_} === INVALID) {`),e.indented($=>{$.write(`if (${v} in ${r}) return INVALID;`),$.write(`${_} = undefined;`)}),e.write("}")):e.write(`if (${_} === INVALID) return INVALID;`),h.set(g,_)}else{i0(b)&&e.write(`if (!(${v} in ${r})) return INVALID;`);const _=dt(e,t,b,k,i);_!==null&&h.set(g,_)}}const p=o.catchall;let m="none";if(p){const g=p._zod.def.type;if(g==="never"){const b=a.map(v=>`k !== ${Et(v)}`).join(" && ")||"true";e.write(`for (const k in ${r}) {`),e.indented(v=>{v.write(`if (${b}) return INVALID;`)}),e.write("}")}else(g==="unknown"||g==="any")&&!p._zod.def.checks?.length?m="passthrough":m="schema"}const y=te(t),w=c.some(g=>Lh(f[g])||ju(f[g]));if(!i){if(m==="schema"){const g=a.length>0?ue(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{b.write('if (k === "__proto__") continue;'),g&&b.write(`if (${g}.has(k)) continue;`);const v=te(t);b.write(`const ${v} = ${r}[k];`),dt(b,t,p,v,!1)}),e.write("}")}return null}if(w){e.write(`const ${y} = {};`);for(const g of c){const b=l(g),v=h.get(g);ju(f[g])?e.write(`if (${b} in ${r}) ${y}[${b}] = ${v};`):Lh(f[g])?e.write(`if (${v} !== undefined || ${b} in ${r}) ${y}[${b}] = ${v};`):e.write(`${y}[${b}] = ${v};`)}}else{const g=c.map(b=>`${d(b)}: ${h.get(b)}`).join(", ");e.write(`const ${y} = { ${g} };`)}if(m!=="none"){const g=a.length>0?ue(t,new Set(a)):null;e.write(`for (const k in ${r}) {`),e.indented(b=>{if(b.write('if (k === "__proto__") continue;'),g&&b.write(`if (${g}.has(k)) continue;`),m==="passthrough")b.write(`${y}[k] = ${r}[k];`);else{const v=te(t);b.write(`const ${v} = ${r}[k];`);const k=dt(b,t,p,v);b.write(`${y}[k] = ${k};`)}}),e.write("}")}return y}function n0(e,t,n,r,i=!0){const o=n._zod.def;if(r0(n))return Be(e,t,o.innerType,r,i);if(o.innerType._zod.optin==="defaulted"){const a=te(t),u=te(t);return e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(c=>{c.write(`const ${u} = (() => {`),c.indented(l=>{const d=Be(l,t,o.innerType,r);l.write(`return ${d};`)}),c.write("})();"),c.write(`if (${u} !== INVALID) ${a} = ${u};`)}),e.write("} else {"),e.indented(c=>{const l=Be(c,t,o.innerType,r);c.write(`${a} = ${l};`)}),e.write("}"),a}const s=i?te(t):null;return s&&e.write(`let ${s};`),e.write(`if (${r} !== undefined) {`),e.indented(a=>{const u=Be(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function r0(e){return e._zod.traits?.has("$ZodExactOptional")===!0}function i0(e){return e._zod.optin===void 0&&Fn(e)}function Fn(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?Fn(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?Fn(t.innerType):!0;case"catch":return!0;case"union":return t.options?t.options.some(Fn):!0;case"intersection":return!t.left||!t.right?!0:Fn(t.left)&&Fn(t.right);case"pipe":return t.in?Fn(t.in):!0;default:return!0}}function ju(e){return e._zod.optin==="optional"&&e._zod.optout==="optional"}function Lh(e){return(e._zod.optin!=="defaulted"||e._zod.optout==="optional")&&tr(e)}function tr(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?tr(t.innerType):!0;case"union":return t.options?t.options.some(tr):!0;case"intersection":return!t.left||!t.right||tr(t.left)||tr(t.right);case"pipe":return t.out?tr(t.out):!0;default:return!0}}function o0(e,t,n,r,i=!0){const o=n._zod.def,s=i?te(t):null;return s&&e.write(`let ${s} = null;`),e.write(`if (${r} !== null) {`),e.indented(a=>{const u=Be(a,t,o.innerType,r,i);s&&u!==null&&a.write(`${s} = ${u};`)}),e.write("}"),s}function s0(e,t,n,r,i=!0){const o=n._zod.def;e.write(`if (!Array.isArray(${r})) return INVALID;`);const s=i?te(t):null,a=te(t),u=te(t);return s&&e.write(`const ${s} = new Array(${r}.length);`),e.write(`for (let ${a} = 0; ${a} < ${r}.length; ${a}++) {`),e.indented(c=>{c.write(`const ${u} = ${r}[${a}];`);const l=dt(c,t,o.element,u,i);s&&l!==null&&c.write(`${s}[${a}] = ${l};`)}),e.write("}"),s}function a0(e,t,n,r){const o=n._zod.def.values;if(o.length!==1){const a=ue(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}const s=o[0];if(typeof s=="number"&&Number.isNaN(s)){const a=ue(t,new Set(o));return e.write(`if (!${a}.has(${r})) return INVALID;`),r}if(typeof s=="string")e.write(`if (${r} !== ${Et(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 Ce(`literal type ${typeof s}`);return r}function u0(e,t,n,r){const i=n._zod.values;if(!i)throw new Ce("enum schema without enumerated values");const o=ue(t,i);return e.write(`if (!${o}.has(${r})) return INVALID;`),r}function zh(e,t,n,r){const i=n._zod.def;return Be(e,t,i.innerType,r)}function c0(e,t,n,r){const i=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 Be(e,t,i.innerType,r);const u=ue(t,s),c=te(t);return e.write(`let ${c} = ${r};`),e.write(`if (${r} === undefined) ${c} = ${u}();`),Be(e,t,i.innerType,c)}const a=te(t);if(s){const u=ue(t,s),c=ue(t,wi);e.write(`let ${a};`),e.write(`if (${r} === undefined) {`),e.indented(l=>{l.write(`${a} = ${c}(${u}());`)}),e.write("} else {"),e.indented(l=>{const d=Be(l,t,i.innerType,r);l.write(`${a} = ${d} === undefined ? ${c}(${u}()) : ${d};`)}),e.write("}")}else e.write(`let ${a};`),e.write(`if (${r} !== undefined) {`),e.indented(u=>{const c=Be(u,t,i.innerType,r);u.write(`${a} = ${c};`)}),e.write("}");return a}function l0(e,t,n,r){const i=n._zod.def,o=Be(e,t,i.innerType,r),s=te(t);return e.write(`const ${s} = ${o};`),e.write(`if (${s} === undefined) return INVALID;`),s}function d0(e,t,n,r){const i=n._zod.def,o=i.items,s=i.rest;e.write(`if (!Array.isArray(${r})) return INVALID;`);const a=Ph(o,"optin"),u=Ph(o,"optout");s?e.write(`if (${r}.length < ${a}) return INVALID;`):e.write(`if (${r}.length < ${a} || ${r}.length > ${o.length}) return INVALID;`);const c=te(t);e.write(`const ${c} = [];`);for(let l=0;l<o.length;l++){const d=o[l];if(l>=u)e.write(`if (${c}.length === ${l}) {`),e.indented(f=>{f.write(`if (${l} < ${r}.length) {`),f.indented(h=>{const p=te(t);h.write(`const ${p} = ${r}[${l}];`);const m=dt(h,t,d,p);h.write(`${c}[${l}] = ${m};`)}),f.write("} else {"),f.indented(h=>{if(ju(d)){h.write(`${c}.length = ${l};`);return}const p=te(t),m=te(t);h.write(`const ${p} = undefined;`),h.write(`const ${m} = (() => {`),h.indented(y=>{const w=dt(y,t,d,p);y.write(`return ${w};`)}),h.write("})();"),h.write(`if (${m} === INVALID || ${m} === undefined) ${c}.length = ${l};`),h.write(`else ${c}[${l}] = ${m};`)}),f.write("}")}),e.write("}");else{const f=te(t);e.write(`const ${f} = ${r}[${l}];`);const h=dt(e,t,d,f);e.write(`${c}[${l}] = ${h};`)}}if(s){const l=te(t),d=te(t);e.write(`for (let ${l} = ${o.length}; ${l} < ${r}.length; ${l}++) {`),e.indented(f=>{f.write(`const ${d} = ${r}[${l}];`);const h=dt(f,t,s,d);f.write(`${c}[${l}] = ${h};`)}),e.write("}")}return c}function Ph(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 f0(e,t,n,r){const i=n._zod.def,o=i.options;if(i.discriminator)return h0(e,t,i,r);if(i.inclusive===!1)throw new Ce("exclusive unions (z.xor)");if(o.length===0)return e.write("return INVALID;"),r;if(o.length===1)return Be(e,t,o[0],r);if(o.every(u=>u._zod.def.type==="literal"&&!u._zod.def.checks?.length)){const u=new Set(o.flatMap(l=>l._zod.def.values)),c=ue(t,u);return e.write(`if (!${c}.has(${r})) return INVALID;`),r}const a=te(t);e.write(`let ${a};`);for(let u=0;u<o.length;u++){const c=o[u];u===0?e.write(`${a} = (() => {`):e.write(`if (${a} === INVALID) ${a} = (() => {`),e.indented(l=>{const d=Be(l,t,c,r);l.write(`return ${d};`)}),e.write("})();")}return e.write(`if (${a} === INVALID) return INVALID;`),a}function h0(e,t,n,r){if(n.unionFallback)throw new Ce("discriminated union with unionFallback");if(n.options.length===0)return e.write("return INVALID;"),r;const i=te(t),o=te(t);e.write(`const ${i} = ${r}?.[${Et(n.discriminator)}];`),e.write(`let ${o};`);let s=!0;const a=new Set;for(const u of n.options){const c=u._zod.propValues?.[n.discriminator];if(!c||c.size===0)throw new Ce("discriminated union option without static discriminator values");for(const f of c){if(a.has(f))throw new Ce(`duplicate discriminator value ${String(f)}`);a.add(f)}const l=Array.from(c,f=>p0(t,i,f)),d=s?"if":"else if";e.write(`${d} (${l.join(" || ")}) {`),e.indented(f=>{const h=Be(f,t,u,r);f.write(`${o} = ${h};`)}),e.write("}"),s=!1}return e.write("else { return INVALID; }"),o}function p0(e,t,n){if(typeof n=="string")return`${t} === ${Et(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=ue(e,n);return`${t} === ${r}`}throw new Ce(`literal discriminator value ${String(n)}`)}function m0(e,t,n,r){const i=n._zod.def;t.definite=!1;const o=dt(e,t,i.left,r),s=dt(e,t,i.right,r),a=ue(t,ui),u=te(t);return e.write(`const ${u} = ${a}(${o}, ${s});`),e.write(`if (!${u}.valid) return INVALID;`),`${u}.data`}function g0(e,t,n,r){const i=n._zod.def,o=ue(t,ln);e.write(`if (!${o}(${r})) return INVALID;`);const s=te(t),a=te(t),u=te(t);e.write(`const ${s} = {};`);const c=i,l=c.partial?void 0:i.keyType._zod.values;if(l){const h=[];for(const m of l){if(!(typeof m=="string"||typeof m=="number"||typeof m=="symbol"))throw new Ce(`record key value ${String(m)}`);const y=typeof m=="number"?m.toString():m;if(y==="__proto__")throw new Ce('record key "__proto__"');h.push(y);const w=ue(t,m),g=Be(e,t,i.keyType,w),b=te(t);e.write(`const ${b} = ${r}[${y0(t,y)}];`);const v=dt(e,t,i.valueType,b);e.write(`${s}[${g}] = ${v};`)}const p=ue(t,new Set(h));return e.write(`for (const ${a} in ${r}) {`),e.indented(m=>{m.write(`if (${p}.has(${a})) continue;`),c.mode==="loose"?m.write(`if (${a} !== "__proto__") ${s}[${a}] = ${r}[${a}];`):m.write("return INVALID;")}),e.write("}"),s}const d=i.keyType._zod.def;if(!(d.type==="string"&&d.format===void 0&&!d.coerce&&(d.checks?.length??0)===0)){const h=i.mode==="loose",p=Zs(i.keyType);p.definite===!1&&(t.definite=!1);const m=ue(t,p),y=ue(t,wr),w=te(t);return Oh(e,t,r,a,g=>{g.write(`let ${w} = ${m}(${a});`),g.write(`if (${w} === INVALID && typeof ${a} === "string" && ${y}.test(${a})) ${w} = ${m}(Number(${a}));`),h?g.write(`if (${w} === INVALID) { ${s}[${a}] = ${r}[${a}]; continue; }`):g.write(`if (${w} === INVALID) return INVALID;`),g.write(`if (${w} === "__proto__") continue;`);const b=te(t);g.write(`const ${b} = ${r}[${a}];`);const v=dt(g,t,i.valueType,b);g.write(`${s}[${w}] = ${v};`)}),s}return Oh(e,t,r,a,h=>{h.write(`const ${u} = ${r}[${a}];`);const p=dt(h,t,i.valueType,u);h.write(`${s}[${a}] = ${p};`)},"return INVALID;"),s}function Oh(e,t,n,r,i,o){const s=ue(t,Object.prototype.propertyIsEnumerable),a=te(t),u=te(t),c=te(t);e.write(`const ${a} = Object.getOwnPropertySymbols(${n});`),e.write(`const ${u} = Object.getOwnPropertyNames(${n});`),e.write(`for (let ${c} = 0; ${c} < ${u}.length; ${c}++) {`),e.indented(l=>{l.write(`const ${r} = ${u}[${c}];`),l.write(`if (${r} === "__proto__" || !${s}.call(${n}, ${r})) continue;`),i(l)}),e.write("}"),e.write(`for (let ${c} = 0; ${c} < ${a}.length; ${c}++) {`),e.indented(l=>{l.write(`const ${r} = ${a}[${c}];`),l.write(`if (!${s}.call(${n}, ${r})) continue;`),o?l.write(o):i(l)}),e.write("}")}function y0(e,t){return typeof t=="string"?Et(t):ue(e,t)}function v0(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Map)) return INVALID;`);const o=te(t),s=te(t),a=te(t);return e.write(`const ${o} = new Map();`),e.write(`for (const [${s}, ${a}] of ${r}) {`),e.indented(u=>{const c=Be(u,t,i.keyType,s),l=Be(u,t,i.valueType,a);u.write(`${o}.set(${c}, ${l});`)}),e.write("}"),o}function b0(e,t,n,r){const i=n._zod.def;e.write(`if (!(${r} instanceof Set)) return INVALID;`);const o=te(t),s=te(t);return e.write(`const ${o} = new Set();`),e.write(`for (const ${s} of ${r}) {`),e.indented(a=>{const u=Be(a,t,i.valueType,s);a.write(`${o}.add(${u});`)}),e.write("}"),o}function w0(e,t){return e.write(`if (!(${t} instanceof File)) return INVALID;`),t}function _0(e,t,n,r){e.write(`if (typeof ${r} !== "string") return INVALID;`);const i=n._zod.pattern;if(i){const o=ue(t,i);e.write(`${o}.lastIndex = 0;`),e.write(`if (!${o}.test(${r})) return INVALID;`)}return r}function k0(e,t,n,r){const i=n._zod.def,o=Hn(t,i.getter),s=ue(t,{parser:null});e.write(`if (!${s}.parser) {`),e.indented(u=>{u.write(`const inner = ${o}();`),u.write(`${s}.parser = function(input) {`),u.indented(c=>{c.write("const result = inner._zod.run({ value: input, issues: [] }, {});"),c.write("return result.issues.length === 0 ? result.value : INVALID;")}),u.write("};")}),e.write("}");const a=te(t);return e.write(`const ${a} = ${s}.parser(${r});`),e.write(`if (${a} === INVALID) return INVALID;`),a}function S0(e,t,n,r){const i=n._zod.def,o=Be(e,t,i.in,r);if(i.transform){if(Vn(i.transform))throw new hn("z.compile: async transforms in pipes are not supported");const s=i.transform,u=Hn(t,l=>{const d={value:l,issues:[],addIssue:wl},f=s(l,d);return f instanceof Promise?bt:d.issues.length===0?f:bt}),c=te(t);return e.write(`const ${c} = ${u}(${o});`),e.write(`if (${c} === INVALID) return INVALID;`),Be(e,t,i.out,c)}else return Be(e,t,i.out,o)}function Vn(e){return typeof e=="function"&&(e.constructor.name==="AsyncFunction"||e[Symbol.toStringTag]==="AsyncFunction")}function E0(e,t,n,r){const i=n._zod.def;if(i.fn){if(Vn(i.fn))throw new hn("z.compile: async custom predicates are not supported");const o=Hn(t,i.fn),s=ue(t,Gu),a=te(t);e.write(`const ${a} = ${o}(${r});`),e.write(`if (${a} instanceof Promise) ${s}();`),e.write(`if (!${a}) return INVALID;`)}else throw new Ce("custom schema without a predicate function");return r}function x0(e,t,n){const r=e._zod.run({value:n,issues:[]},{});if(r&&typeof r.then=="function")return bt;const i=r;return i.issues.length===0?i.value:t()}function $0(e,t,n,r){const i=n._zod.def;if(!i.catchValue[Sc])throw new Ce("catch with a callback (only a constant catch value compiles)",!1);const o=te(t);e.write(`let ${o} = (() => {`),e.indented(c=>{const l=dt(c,t,i.innerType,r);c.write(`return ${l};`)}),e.write("})();");const s=ue(t,i.innerType),a=Hn(t,i.catchValue),u=ue(t,x0);return e.write(`if (${o} === INVALID) {`),e.indented(c=>{c.write(`${o} = ${u}(${s}, ${a}, ${r});`),c.write(`if (${o} === INVALID) return INVALID;`)}),e.write("}"),o}function T0(e,t,n,r){const i=n._zod.def;if(i.transform){if(Vn(i.transform))throw new hn("z.compile: async transforms are not supported");const o=i.transform,a=Hn(t,c=>{const l={value:c,issues:[],addIssue:wl},d=o(c,l);return d instanceof Promise?bt:l.issues.length===0?d:bt}),u=te(t);return e.write(`const ${u} = ${a}(${r});`),e.write(`if (${u} === INVALID) return INVALID;`),u}return r}function Bs(e){return e.checks&&(e.checks=[...e.checks]),e}function dv(e,t){return new e(Bs({type:"string",...N(t)}))}function fv(e,t){return new e(Bs({type:"string",coerce:!0,...N(t)}))}function _l(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...N(t)})}function kl(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...N(t)})}function Sl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...N(t)})}function El(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...N(t)})}function xl(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...N(t)})}function $l(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...N(t)})}function Hs(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...N(t)})}function Tl(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...N(t)})}function Cl(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...N(t)})}function Al(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...N(t)})}function Il(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...N(t)})}function Nl(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...N(t)})}function Rl(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...N(t)})}function Ll(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...N(t)})}function zl(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...N(t)})}function Pl(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...N(t)})}function hv(e,t){return new e({type:"string",format:"mac",check:"string_format",abort:!1,...N(t)})}function Ol(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...N(t)})}function Dl(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...N(t)})}function Ml(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...N(t)})}function Fl(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...N(t)})}function Ul(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...N(t)})}function pv(e,t){return new e({type:"string",format:"credit_card",check:"string_format",abort:!1,...N(t)})}function mv(e,t){return new e({type:"string",format:"iban",check:"string_format",abort:!1,...N(t)})}function Gl(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...N(t)})}const jl={Any:null,Minute:-1,Second:0,Millisecond:3,Microsecond:6};function Zl(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...N(t)})}function Bl(e,t){return new e({type:"string",format:"date",check:"string_format",...N(t)})}function Hl(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...N(t)})}function Vl(e,t){return new e({type:"string",format:"duration",check:"string_format",...N(t)})}function gv(e,t){return new e(Bs({type:"number",checks:[],...N(t)}))}function yv(e,t){return new e(Bs({type:"number",coerce:!0,checks:[],...N(t)}))}function vv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...N(t)})}function bv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float32",...N(t)})}function wv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"float64",...N(t)})}function _v(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"int32",...N(t)})}function kv(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"uint32",...N(t)})}function Sv(e,t){return new e({type:"boolean",...N(t)})}function Ev(e,t){return new e({type:"boolean",coerce:!0,...N(t)})}function xv(e,t){return new e({type:"bigint",...N(t)})}function $v(e,t){return new e({type:"bigint",coerce:!0,...N(t)})}function Tv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"int64",...N(t)})}function Cv(e,t){return new e({type:"bigint",check:"bigint_format",abort:!1,format:"uint64",...N(t)})}function Av(e,t){return new e({type:"symbol",...N(t)})}function Iv(e,t){return new e({type:"undefined",...N(t)})}function Nv(e,t){return new e({type:"null",...N(t)})}function Rv(e){return new e({type:"any"})}function Lv(e){return new e({type:"unknown"})}function zv(e,t){return new e({type:"never",...N(t)})}function Pv(e,t){return new e({type:"void",...N(t)})}function Ov(e,t){return new e({type:"date",...N(t)})}function Dv(e,t){return new e({type:"date",coerce:!0,...N(t)})}function Mv(e,t){return new e({type:"nan",...N(t)})}function pn(e,t){return new Bc({check:"less_than",...N(t),value:e,inclusive:!1})}function xt(e,t){return new Bc({check:"less_than",...N(t),value:e,inclusive:!0})}function mn(e,t){return new Hc({check:"greater_than",...N(t),value:e,inclusive:!1})}function $t(e,t){return new Hc({check:"greater_than",...N(t),value:e,inclusive:!0})}function Vs(e){return mn(0,e)}function qs(e){return pn(0,e)}function Ws(e){return xt(0,e)}function Ks(e){return $t(0,e)}function qn(e,t){return new Sg({check:"multiple_of",...N(t),value:e})}function Yn(e,t){return new $g({check:"max_size",...N(t),maximum:e})}function gn(e,t){return new Tg({check:"min_size",...N(t),minimum:e})}function _r(e,t){return new Cg({check:"size_equals",...N(t),size:e})}function kr(e,t){return new Ag({check:"max_length",...N(t),maximum:e})}function An(e,t){return new Ig({check:"min_length",...N(t),minimum:e})}function Sr(e,t){return new Ng({check:"length_equals",...N(t),length:e})}function Ni(e,t){return new Rg({check:"string_format",format:"regex",...N(t),pattern:e})}function Ri(e){return new Lg({check:"string_format",format:"lowercase",...N(e)})}function Li(e){return new zg({check:"string_format",format:"uppercase",...N(e)})}function zi(e,t){return new Pg({check:"string_format",format:"includes",...N(t),includes:e})}function Pi(e,t){return new Og({check:"string_format",format:"starts_with",...N(t),prefix:e})}function Oi(e,t){return new Dg({check:"string_format",format:"ends_with",...N(t),suffix:e})}function Js(e,t,n){return new Mg({check:"property",property:e,schema:t,...N(n)})}function Di(e,t){return new Fg({check:"properties",shape:e,...N(t)})}function Mi(e,t){return new Ug({check:"mime_type",mime:e,...N(t)})}function tn(e){return new Gg({check:"overwrite",tx:e})}function Fi(e){return tn(t=>t.normalize(e))}function Ui(){return tn(e=>e.trim())}function Gi(){return tn(e=>e.toLowerCase())}function ji(){return tn(e=>e.toUpperCase())}function Zi(){return tn(e=>bm(e))}function Fv(e,t,n){return new e({type:"array",element:t,...N(n)})}function C0(e,t,n){return new e({type:"union",options:t,...N(n)})}function A0(e,t,n){return new e({type:"union",options:t,inclusive:!1,...N(n)})}function I0(e,t,n,r){return new e({type:"union",options:n,discriminator:t,...N(r)})}function N0(e,t,n){return new e({type:"intersection",left:t,right:n})}function R0(e,t,n,r){const i=n instanceof me,o=i?r:n,s=i?n:null;return new e({type:"tuple",items:t,rest:s,...N(o)})}function L0(e,t,n,r){return new e({type:"record",keyType:t,valueType:n,...N(r)})}function z0(e,t,n,r){return new e({type:"map",keyType:t,valueType:n,...N(r)})}function P0(e,t,n){return new e({type:"set",valueType:t,...N(n)})}function O0(e,t,n){const r=Array.isArray(t)?Object.fromEntries(t.map(i=>[i,i])):t;return new e({type:"enum",entries:r,...N(n)})}function D0(e,t,n){return new e({type:"enum",entries:t,...N(n)})}function M0(e,t,n){return new e({type:"literal",values:Array.isArray(t)?t:[t],...N(n)})}function Uv(e,t){return new e({type:"file",...N(t)})}function F0(e,t){return new e({type:"transform",transform:t})}function U0(e,t){return new e({type:"optional",innerType:t})}function G0(e,t){return new e({type:"nullable",innerType:t})}function j0(e,t,n){return new e({type:"default",innerType:t,get defaultValue(){return typeof n=="function"?n():wi(n)}})}function Z0(e,t,n){return new e({type:"nonoptional",innerType:t,...N(n)})}function B0(e,t){return new e({type:"success",innerType:t})}function H0(e,t,n){return new e({type:"catch",innerType:t,catchValue:typeof n=="function"?n:Ec(n)})}function V0(e,t,n){return new e({type:"pipe",in:t,out:n})}function q0(e,t){return new e({type:"readonly",innerType:t})}function W0(e,t,n){return new e({type:"template_literal",parts:t,...N(n)})}function K0(e,t){return new e({type:"lazy",getter:t})}function J0(e,t){return new e({type:"promise",innerType:t})}function Gv(e,t,n){const r=N(n);return r.abort??(r.abort=!0),new e({type:"custom",check:"custom",fn:t,...r})}function jv(e,t,n){return new e({type:"custom",check:"custom",fn:t,...N(n)})}function Zv(e,t){const n=Bv(r=>(r.addIssue=i=>{if(typeof i=="string")r.issues.push(ar(i,r.value,n._zod.def));else{const o=i;o.fatal&&(o.continue=!1),o.code??(o.code="custom"),"input"in o||(o.input=r.value),o.inst??(o.inst=n),o.continue??(o.continue=!n._zod.def.abort),r.issues.push(ar(o))}},e(r.value,r)),t);return n}function Bv(e,t){const n=new Ze({check:"custom",...N(t)});return n._zod.check=e,n}function Hv(e){const t=new Ze({check:"describe"});return t._zod.onattach=[n=>{const r=St.get(n)??{};St.add(n,{...r,description:e})}],t._zod.check=()=>{},t}function Vv(e){const t=new Ze({check:"meta"});return t._zod.onattach=[n=>{const r=St.get(n)??{};St.add(n,{...r,...e})}],t._zod.check=()=>{},t}function qv(e,t){const n=N(t);let r=n.truthy??["true","1","yes","on","y","enabled"],i=n.falsy??["false","0","no","off","n","disabled"];n.case!=="sensitive"&&(r=r.map(h=>typeof h=="string"?h.toLowerCase():h),i=i.map(h=>typeof h=="string"?h.toLowerCase():h));const o=new Set(r),s=new Set(i),a=e.Codec??fl,u=e.Boolean??sl,c=e.String??Ii,l=new c({type:"string",error:n.error}),d=new u({type:"boolean",error:n.error}),f=new a({type:"pipe",in:l,out:d,transform:((h,p)=>{let m=h;return n.case!=="sensitive"&&(m=m.toLowerCase()),o.has(m)?!0:s.has(m)?!1:(p.issues.push({code:"invalid_value",expected:"stringbool",values:[...o,...s],input:p.value,inst:f,continue:!1}),{})}),reverseTransform:((h,p)=>h===!0?r[0]||"true":i[0]||"false"),error:n.error});return f._zod.bag.truthy=r,f._zod.bag.falsy=i,f._zod.bag.case=n.case??"insensitive",f}function Er(e,t,n,r={}){const i=N(r),o={check:"string_format",type:"string",format:t,fn:typeof n=="function"?n:a=>n.test(a),...i};return n instanceof RegExp&&(o.pattern=n),new e(o)}function ii(e,...t){for(const n of t)for(const r of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,r)&&Tt(e,r,n[r]);return e}function cr(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??St,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 nt(e,t,n,r,i){const o=typeof t.unrepresentable=="function"?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(o==="any")return!1;if(o===void 0||o==="throw")throw new Error(i);return Object.assign(n,o),!0}function De(e,t,n={path:[],schemaPath:[]}){var r;const i=e._zod.def,o=t.seen.get(e);if(o)return o.count++,n.schemaPath.includes(e)&&(o.cycle=n.path),o.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,h=t.processors[i.type];if(!h)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);h(e,t,f,l)}const d=e._zod.parent;d&&(s.ref||(s.ref=d),De(d,t,l),t.seen.get(d).isParent=!0)}const u=t.metadataRegistry.get(e);return u&&ii(s.schema,u),t.io==="input"&&mt(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 Dh(e){return e.replace(/~/g,"~0").replace(/\//g,"~1")}function lr(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 u=r.get(a);if(u&&u!==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 i=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??(p=>p);if(d)return{ref:f(d)};const h=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=h,{defId:h,ref:`${f("__shared")}#/${a}/${Dh(h)}`}}const u="#",c=`${u}/${a}/`;if(s[1]===n&&!s[1].schema.id)return{ref:u};const l=s[1].schema.id??`__schema${e.counter++}`;return{defId:l,ref:c+Dh(l)}},o=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:u,defId:c}=i(s);a.def={...a.schema},c&&(a.defId=c);const l=a.schema;for(const d in l)delete l[d];l.$ref=u};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]){o(s);continue}if(e.external){const c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){o(s);continue}}if(e.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}a.count>1&&e.reused==="ref"&&o(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Vv(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;Vv(r);const i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;const o=r.type;for(const s of Array.isArray(o)?o:[o]){if(typeof s!="string")return;n.includes(s)||n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const qv=new Set(["type","properties","required","additionalProperties"]),Oh=["oneOf","anyOf"];function Mh(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Zu(e){const t=[];for(const o of e){if(typeof o!="object"||o.type!=="object")return null;for(const s in o)if(!qv.has(s))return null;t.push(o)}const n={},r=new Set;for(const o of t){for(const s in o.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;const a=[];for(const c of t){const l=c.properties?.[s]??Mh(c);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}const u=a.length===1?a[0]:Zu(a)??{allOf:a};Tt(n,s,u)}for(const s of o.required??[])r.add(s)}const i={type:"object",properties:n};if(r.size&&(i.required=[...r]),t.every(o=>o.additionalProperties===!1))i.additionalProperties=!1;else{const o=[];for(const s of t){const a=Mh(s);a&&!o.some(u=>JSON.stringify(u)===JSON.stringify(a))&&o.push(a)}o.length===1?i.additionalProperties=o[0]:o.length>1&&(i.additionalProperties={allOf:o})}return i}function W0(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const i of qv)if(i in e)return;const n=t.filter(i=>Oh.some(o=>Array.isArray(i[o])));let r=null;if(!n.length)r=Zu(t);else{const i=n[0],o=Oh.find(u=>Array.isArray(i[u]));if(Object.keys(i).length!==1)return;const s=t.filter(u=>u!==i),a=i[o].map(u=>Zu([...s,u]));if(a.some(u=>!u))return;r={[o]:a}}r&&(delete e.allOf,ii(e,r))}function dr(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 u=e.seen.get(a);if(u.ref===null)return;const c=u.def??u.schema,l={...c},d=u.ref;if(u.ref=null,d){r(d);const h=e.seen.get(d),p=h.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(p)):ii(c,p),ii(c,l),a._zod.parent===d)for(const y in c)y==="$ref"||y==="allOf"||y in l||delete c[y];if(p.$ref&&h.def)for(const y in c)y==="$ref"||y==="allOf"||y in h.def&&JSON.stringify(c[y])===JSON.stringify(h.def[y])&&delete c[y]}const f=a._zod.parent;if(f&&f!==d){r(f);const h=e.seen.get(f);if(h?.schema.$ref&&(c.$ref=h.schema.$ref,h.def))for(const p in c)p==="$ref"||p==="allOf"||p in h.def&&JSON.stringify(c[p])===JSON.stringify(h.def[p])&&delete c[p]}e.override({zodSchema:a,jsonSchema:c,path:u.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())Vv(a[1].def??a[1].schema);for(const a of e.deferred)a();if(e.intersections.length){const a=new Map;for(const u of e.seen.values())for(const c of[u.schema,u.def]){const l=c?.allOf;if(!Array.isArray(l))continue;const d=a.get(l);d?d.push(c):a.set(l,[c])}for(const u of e.intersections)for(const c of a.get(u)??[])W0(c)}}const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$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");i.$id=e.external.uri(a)}ii(i,n.defId?n.schema:n.def??n.schema);const o=e.metadataRegistry.get(t)?.id;o!==void 0&&i.id===o&&delete i.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const a of e.seen.entries()){const u=a[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,Tt(s,u.defId,u.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:ci(t,"input",e.processors),output:ci(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function mt(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 mt(r.element,n);if(r.type==="set")return mt(r.valueType,n);if(r.type==="lazy")return mt(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 mt(r.innerType,n);if(r.type==="intersection")return mt(r.left,n)||mt(r.right,n);if(r.type==="record"||r.type==="map")return mt(r.keyType,n)||mt(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:mt(r.in,n)||mt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(mt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(mt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(mt(i,n))return!0;return!!(r.rest&&mt(r.rest,n))}return!1}const Wv=(e,t={})=>n=>{const r=cr({...n,processors:t});return Oe(e,r),lr(r,e),dr(r,e)},ci=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=cr({...i??{},target:o,io:t,processors:n});return Oe(e,s),lr(s,e),dr(s,e)},fr=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},hr=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Fh=(e,t)=>{fr(e,"minimum",t),hr(e,"maximum",t)},Kv=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Jv=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Yv=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},Xv=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Uh=(e,t)=>fr(e,"minimum",t.minimum),Gh=(e,t)=>hr(e,"maximum",t.maximum),jh=e=>(t,n)=>{Xv(t,n.format);const[r,i]=e[n.format];fr(t,"minimum",r),hr(t,"maximum",i)},K0={greater_than:(e,t)=>fr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>hr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Kv(e,t.value),number_format:jh(_c),bigint_format:jh(kc),min_length:Uh,max_length:Gh,length_equals:(e,t)=>Fh(e,t.length),min_size:Uh,max_size:Gh,size_equals:(e,t)=>Fh(e,t.size),string_format:(e,t)=>{Xv(e,t.format),t.pattern&&Jv(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)=>Yv(e,t.mime)};function tt(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const o of r)K0[o._zod.def.check]?.(t,o._zod.def);const i=e._zod.bag;i.minimum!==void 0&&fr(t,"minimum",i.minimum),i.exclusiveMinimum!==void 0&&fr(t,"exclusiveMinimum",i.exclusiveMinimum),i.maximum!==void 0&&hr(t,"maximum",i.maximum),i.exclusiveMaximum!==void 0&&hr(t,"exclusiveMaximum",i.exclusiveMaximum),i.multipleOf!==void 0&&Kv(t,i.multipleOf),i.format!==void 0&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&Yv(t,i.mime);for(const o of i.patterns??[])Jv(t,o);return t}const J0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},Y0=new Map([[el,ng],[Ms,rg]]),Qv=e=>Y0.get(e)??e,eb=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:o,maximum:s,format:a,patterns:u,contentEncoding:c,laxFormat:l}=tt(e);if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=J0[a]??a,i.format===""&&delete i.format,(a==="time"||l)&&delete i.format),c&&(i.contentEncoding=c),u&&u.size>0){const d=[...u].map(Qv);d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},tb=(e,t,n,r)=>{const i=n,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=tt(e);i.type=l?"integer":"number";const d=typeof c=="number"&&c>=(o??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(d?h?(i.minimum=c,i.exclusiveMinimum=!0):i.exclusiveMinimum=c:typeof o=="number"&&(i.minimum=o),f?h?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u:typeof s=="number"&&(i.maximum=s),a){const p=new Set;for(const w of a)Number.isFinite(w)&&w!==0?p.add(Math.abs(w)):nt(e,t,i,r,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);const[m,...y]=p;m!==void 0&&(i.multipleOf=m),y.length&&(i.allOf=[...i.allOf??[],...y.map(w=>({multipleOf:w}))])}},nb=(e,t,n,r)=>{n.type="boolean"},rb=(e,t,n,r)=>{nt(e,t,n,r,"BigInt cannot be represented in JSON Schema")},ib=(e,t,n,r)=>{nt(e,t,n,r,"Symbols cannot be represented in JSON Schema")},ob=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},sb=(e,t,n,r)=>{nt(e,t,n,r,"Undefined cannot be represented in JSON Schema")},ab=(e,t,n,r)=>{nt(e,t,n,r,"Void cannot be represented in JSON Schema")},ub=(e,t,n,r)=>{n.not={}},cb=(e,t,n,r)=>{},lb=(e,t,n,r)=>{},db=(e,t,n,r)=>{nt(e,t,n,r,"Date cannot be represented in JSON Schema")},fb=(e,t,n,r)=>{const i=e._zod.def,o=is(i.entries);if(o.length===0){n.not={};return}o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),n.enum=o},hb=(e,t,n,r)=>{const i=e._zod.def;if(i.values.length===0){n.not={};return}const o=[];for(const s of i.values)if(s===void 0){if(nt(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(nt(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(s))}else o.push(s);if(o.length!==0)if(o.length===1){const s=o[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),o.every(s=>typeof s=="boolean")&&(n.type="boolean"),o.every(s=>s===null)&&(n.type="null"),n.enum=o},pb=(e,t,n,r)=>{nt(e,t,n,r,"NaN cannot be represented in JSON Schema")},mb=(e,t,n,r)=>{const i=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=o.source},gb=(e,t,n,r)=>{const i=n;i.type="string",i.format="binary",i.contentEncoding="binary";const{minimum:o,maximum:s,mime:a}=tt(e);o!==void 0&&(i.minLength=o),s!==void 0&&(i.maxLength=s),a&&(a.length===0?i.not={}:a.length===1?i.contentMediaType=a[0]:i.anyOf=a.map(u=>({contentMediaType:u})))},yb=(e,t,n,r)=>{n.type="boolean"},vb=(e,t,n,r)=>{nt(e,t,n,r,"Custom types cannot be represented in JSON Schema")},bb=(e,t,n,r)=>{nt(e,t,n,r,"Function types cannot be represented in JSON Schema")},wb=(e,t,n,r)=>{nt(e,t,n,r,"Transforms cannot be represented in JSON Schema")},_b=(e,t,n,r)=>{nt(e,t,n,r,"Map cannot be represented in JSON Schema")},kb=(e,t,n,r)=>{nt(e,t,n,r,"Set cannot be represented in JSON Schema")},Sb=(e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=tt(e);typeof s=="number"&&(i.minItems=s),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=Oe(o.element,t,{...r,path:[...r.path,"items"]})};function li(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?li(t.out):t.type==="catch"?li(t.innerType):e._zod.optin}const xb=(e,t,n,r)=>{const i=n,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&nt(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const c in s)Tt(i.properties,c,Oe(s[c],t,{...r,path:[...r.path,"properties",c]}));const u=[];for(const c of Object.keys(s)){const l=o.shape[c];(t.io==="input"?li(l)===void 0:l._zod.optout===void 0)&&u.push(c)}u.length>0&&(i.required=u),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=Oe(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},ql=(e,t,n,r)=>{const i=e._zod.def,o=i.inclusive===!1,s=i.options.map((a,u)=>Oe(a,t,{...r,path:[...r.path,o?"oneOf":"anyOf",u]}));o?n.oneOf=s:n.anyOf=s},Eb=(e,t,n,r)=>{const i=e._zod.def,o=Oe(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=Oe(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,u=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];n.allOf=u,t.intersections.push(u)},$b=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="array";const s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=o.items.map((m,y)=>Oe(m,t,{...r,path:[...r.path,s,y]})),c=o.rest?Oe(o.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;let l=o.items.length;for(;l>0;){const m=o.items[l-1];if(!(t.io==="input"?li(m)!==void 0:m._zod.optout==="optional"))break;l--}const d=o.items.length,f=!o.rest;t.target==="draft-2020-12"?(i.prefixItems=u,f?i.items=!1:c&&(i.items=c),l>0&&(i.minItems=l),f&&(i.maxItems=d)):t.target==="openapi-3.0"?(i.items={anyOf:u},c&&i.items.anyOf.push(c),l>0&&(i.minItems=l),f&&(i.maxItems=d)):(i.items=u,f?i.additionalItems=!1:c&&(i.additionalItems=c),l>0&&(i.minItems=l),f&&(i.maxItems=d));const{minimum:h,maximum:p}=tt(e);typeof h=="number"&&(i.minItems=h),typeof p=="number"&&(i.maxItems=p)};function Bu(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);const p=e.get(t)?.def;if(!p)return t;const m=Bu(e,p,n);return m===p?t:m}for(const p of["anyOf","oneOf"]){const m=t[p];if(!Array.isArray(m))continue;const y=m.map(w=>Bu(e,w,n));y.some((w,g)=>w!==m[g])&&(t={...t,[p]:y})}const r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes("string")&&r.some(p=>p==="number"||p==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!i&&!o?.some(p=>typeof p=="number"))return t;const{minimum:s,maximum:a,exclusiveMinimum:u,exclusiveMaximum:c,multipleOf:l,format:d,id:f,...h}=t;return h.enum?h.enum=h.enum.map(p=>typeof p=="number"?String(p):p):typeof h.const=="number"&&(h.const=String(h.const)),i&&(h.type="string",o||(h.pattern=(r.includes("number")?wr:Gc).source)),h}const Hu=new WeakMap;function X0(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 Hu.get(e)??[]){const i=e.seen.get(r),o=(i?.def??i?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;const s=Bu(t,o,new Set);s!==o&&n.set(o,s)}if(n.size)for(const r of e.seen.values())for(const i of[r.schema,r.def]){const o=i&&n.get(i.propertyNames);o&&(i.propertyNames=o)}}const Tb=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const s=o.keyType,a=tt(s).patterns;if(o.mode==="loose"&&a&&a.size>0){const l=Oe(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const d of a)Tt(i.patternProperties,Qv(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){i.propertyNames=Oe(o.keyType,t,{...r,path:[...r.path,"propertyNames"]});let l=Hu.get(t);l||(l=[],Hu.set(t,l),t.deferred.push(()=>X0(t))),l.push(e)}i.additionalProperties=Oe(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const u=s._zod.values,c=t.io==="input"&&li(o.valueType)!==void 0;if(u&&!o.partial&&!c){const l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(i.required=l.map(String))}},Cb=(e,t,n,r)=>{const i=e._zod.def,o=Oe(i.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},Ab=(e,t,n,r)=>{const i=e._zod.def;Oe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Wl=Symbol();function Ib(e,t,n,r,i){let o=!1;const s=JSON.stringify(e,(a,u)=>typeof u!="bigint"?u:(o=!0,null));return o?(nt(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),Wl):JSON.parse(s)}const Nb=(e,t,n,r)=>{const i=e._zod.def;Oe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;const s=Ib(i.defaultValue,e,t,n,r);s!==Wl&&(n.default=s)},Rb=(e,t,n,r)=>{const i=e._zod.def;Oe(i.innerType,t,r);const o=t.seen.get(e);if(o.ref=i.innerType,t.io!=="input")return;const s=Ib(i.defaultValue,e,t,n,r);s!==Wl&&(n._prefault=s)},Lb=(e,t,n,r)=>{const i=e._zod.def;Oe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{nt(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},zb=(e,t,n,r)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?o?i.out:i.in:i.out;Oe(s,t,r);const a=t.seen.get(e);a.ref=s},Pb=(e,t,n,r)=>{const i=e._zod.def;Oe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},Db=(e,t,n,r)=>{const i=e._zod.def;Oe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Kl=(e,t,n,r)=>{const i=e._zod.def;Oe(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Ob=(e,t,n,r)=>{const i=e._zod.innerType;Oe(i,t,r);const o=t.seen.get(e);o.ref=i},Vu={string:eb,number:tb,boolean:nb,bigint:rb,symbol:ib,null:ob,undefined:sb,void:ab,never:ub,any:cb,unknown:lb,date:db,enum:fb,literal:hb,nan:pb,template_literal:mb,file:gb,success:yb,custom:vb,function:bb,transform:wb,map:_b,set:kb,array:Sb,object:xb,union:ql,intersection:Eb,tuple:$b,record:Tb,nullable:Cb,nonoptional:Ab,default:Nb,prefault:Rb,catch:Lb,pipe:zb,readonly:Pb,promise:Db,optional:Kl,lazy:Ob};function Jl(e,t){if("_idmap"in e){const r=e,i=cr({...t,processors:Vu}),o={};for(const u of r._idmap.entries()){const[c,l]=u;Oe(l,i)}const s={},a={registry:r,uri:t?.uri,defs:o};i.external=a;for(const u of r._idmap.entries()){const[c,l]=u;lr(i,l),Tt(s,c,dr(i,l))}if(Object.keys(o).length>0){const u=i.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[u]:o}}return{schemas:s}}const n=cr({...t,processors:Vu});return Oe(e,n),lr(n,e),dr(n,e)}class Q0{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=cr({processors:Vu,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 Oe(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,lr(this.ctx,t);const r=dr(this.ctx,t),{"~standard":i,...o}=r;return o}}const ex=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Mb=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:_y,$ZodArray:$y,$ZodAsyncError:sn,$ZodBase64:cy,$ZodBase64URL:ly,$ZodBigInt:al,$ZodBigIntFormat:yy,$ZodBoolean:sl,$ZodCIDRv4:ay,$ZodCIDRv6:uy,$ZodCUID:Kg,$ZodCUID2:Jg,$ZodCatch:Wy,$ZodCheck:Ze,$ZodCheckBigIntFormat:Sg,$ZodCheckEndsWith:Pg,$ZodCheckGreaterThan:Hc,$ZodCheckIncludes:Lg,$ZodCheckLengthEquals:Ag,$ZodCheckLessThan:Bc,$ZodCheckLowerCase:Ng,$ZodCheckMaxLength:Tg,$ZodCheckMaxSize:xg,$ZodCheckMimeType:Mg,$ZodCheckMinLength:Cg,$ZodCheckMinSize:Eg,$ZodCheckMultipleOf:_g,$ZodCheckNumberFormat:kg,$ZodCheckOverwrite:Fg,$ZodCheckProperties:Og,$ZodCheckProperty:Dg,$ZodCheckRegex:Ig,$ZodCheckSizeEquals:$g,$ZodCheckStartsWith:zg,$ZodCheckStringFormat:Ai,$ZodCheckUpperCase:Rg,$ZodCodec:fl,$ZodCreditCard:fy,$ZodCustom:tv,$ZodCustomStringFormat:my,$ZodCyclicError:nv,$ZodDate:Ey,$ZodDefault:By,$ZodDiscriminatedUnion:Ly,$ZodE164:dy,$ZodEmail:Bg,$ZodEmoji:qg,$ZodEncodeError:As,$ZodEnum:My,$ZodError:Pm,$ZodExactOptional:jy,$ZodFile:Uy,$ZodFunction:Qy,$ZodGUID:jg,$ZodIBAN:hy,$ZodIPv4:iy,$ZodIPv6:oy,$ZodISODate:ty,$ZodISODateTime:ey,$ZodISODuration:ry,$ZodISOTime:ny,$ZodIntersection:zy,$ZodJWT:py,$ZodKSUID:Qg,$ZodLazy:hl,$ZodLiteral:Fy,$ZodMAC:sy,$ZodMap:Dy,$ZodNaN:Ky,$ZodNanoID:Wg,$ZodNever:Sy,$ZodNonOptional:Vy,$ZodNull:wy,$ZodNullable:Zy,$ZodNumber:ol,$ZodNumberFormat:gy,$ZodObject:Ay,$ZodObjectJIT:Iy,$ZodOptional:ll,$ZodPipe:dl,$ZodPrefault:Hy,$ZodPreprocess:Jy,$ZodPromise:ev,$ZodReadonly:Yy,$ZodRealError:Ct,$ZodRecord:Py,$ZodRegistry:ov,$ZodSet:Oy,$ZodString:Ii,$ZodStringFormat:Fe,$ZodSuccess:qy,$ZodSymbol:vy,$ZodTemplateLiteral:Xy,$ZodTransform:Gy,$ZodTuple:cl,$ZodType:pe,$ZodULID:Yg,$ZodURL:Vg,$ZodUUID:Zg,$ZodUndefined:by,$ZodUnion:Fs,$ZodUnknown:ky,$ZodVoid:xy,$ZodXID:Xg,$ZodXor:Ny,$brand:Tc,$constructor:S,$input:vl,$output:yl,Doc:Vc,INVALID:bt,JSONSchema:ex,JSONSchemaGenerator:Q0,NEVER:$c,TimePrecision:jl,URL_BAD_FORMAT:Wc,URL_UNPARSEABLE:ai,ZodCompileAsyncError:fn,ZodCompileUnsupportedError:Ce,_any:Iv,_array:Ov,_base64:Ml,_base64url:Fl,_bigint:Sv,_boolean:_v,_catch:j0,_check:jv,_cidrv4:Dl,_cidrv6:Ol,_coercedBigint:xv,_coercedBoolean:kv,_coercedDate:Pv,_coercedNumber:mv,_coercedString:lv,_creditCard:fv,_cuid:Al,_cuid2:Il,_custom:Fv,_date:zv,_decode:Nc,_decodeAsync:Lc,_default:F0,_discriminatedUnion:T0,_e164:Ul,_email:_l,_emoji:Tl,_encode:Ic,_encodeAsync:Rc,_endsWith:Di,_enum:L0,_file:Mv,_float32:yv,_float64:vv,_gt:pn,_gte:$t,_guid:kl,_iban:hv,_includes:zi,_int:gv,_int32:bv,_int64:Ev,_intersection:C0,_ipv4:zl,_ipv6:Pl,_isoDate:Bl,_isoDateTime:Zl,_isoDuration:Vl,_isoTime:Hl,_jwt:Gl,_ksuid:Ll,_lazy:V0,_length:Sr,_literal:P0,_lowercase:Ri,_lt:hn,_lte:Et,_mac:dv,_map:N0,_max:Et,_maxLength:kr,_maxSize:Yn,_mime:Mi,_min:$t,_minLength:In,_minSize:mn,_multipleOf:qn,_nan:Dv,_nanoid:Cl,_nativeEnum:z0,_negative:qs,_never:Rv,_nonnegative:Ks,_nonoptional:U0,_nonpositive:Ws,_normalize:Fi,_null:Av,_nullable:M0,_number:pv,_optional:O0,_overwrite:tn,_parse:Si,_parseAsync:xi,_pipe:Z0,_positive:Vs,_promise:q0,_properties:Oi,_property:Js,_readonly:B0,_record:I0,_refine:Uv,_regex:Ni,_safeDecode:Pc,_safeDecodeAsync:Oc,_safeEncode:zc,_safeEncodeAsync:Dc,_safeParse:Ei,_safeParseAsync:$i,_set:R0,_size:_r,_slugify:Zi,_startsWith:Pi,_string:cv,_stringFormat:xr,_stringbool:Hv,_success:G0,_superRefine:Gv,_symbol:Tv,_templateLiteral:H0,_toLowerCase:Gi,_toUpperCase:ji,_transform:D0,_trim:Ui,_tuple:A0,_uint32:wv,_uint64:$v,_ulid:Nl,_undefined:Cv,_union:E0,_unknown:Nv,_uppercase:Li,_url:Hs,_uuid:Sl,_uuidv4:xl,_uuidv6:El,_uuidv7:$l,_void:Lv,_xid:Rl,_xor:$0,base64Charset:el,base64urlCharset:Ms,canParseURL:Kc,clone:je,compile:bl,compileFn:Zs,config:et,createStandardJSONSchemaMethod:ci,createToJSONSchemaMethod:Wv,decode:Ok,decodeAsync:Fk,describe:Zv,encode:Dk,encodeAsync:Mk,extractDefs:lr,finalize:dr,flattenError:Is,formatError:Ns,getDiscriminatedOption:ul,globalConfig:vt,globalRegistry:St,handleUnrepresentable:nt,initializeContext:cr,isBackEdge:ml,isRecursiveSchema:pl,isValidBase64:Os,isValidBase64URL:tl,isValidCIDRv6:Qc,isValidCreditCard:nl,isValidIBAN:rl,isValidIPv6:Ds,isValidJWT:il,locales:gl,memoizer:Us,mergeValues:ui,meta:Bv,parse:Du,parseAsync:Ou,parseURLObject:Hg,prettifyError:Ac,process:Oe,processSchema:Oe,regexes:Ps,registry:Gs,safeDecode:Gk,safeDecodeAsync:Zk,safeEncode:Uk,safeEncodeAsync:jk,safeParse:Om,safeParseAsync:Rk,standardProps:qc,stripTabAndNewline:cs,toDotPath:Dm,toJSONSchema:Jl,toZod:Ss,treeifyError:Cc,urlHostnameOk:Yc,urlProtocolOk:Xc,util:Ec,validate:Ls,validateAsync:zs,validateURL:Jc,version:Ug,withParser:js},Symbol.toStringTag,{value:"Module"})),Zh=Symbol("z.visit/resolving");function Yl(e,t){const n=typeof t=="function"?t:(s,a)=>{const u=t[s._zod.def.type];return u?u(s,a):s},r=new Map;function i(s){const a=r.get(s);if(a===Zh)return new hl({type:"lazy",getter:()=>r.get(s)});if(a!==void 0)return a;r.set(s,Zh);const u=o(s),c=n(u,u!==s);return r.set(s,c),c}function o(s){const a=s._zod.def;switch(a.type){case"object":{const c=a.shape,l=Object.keys(c);let d=!1;const f={};for(const p of l){const m=i(c[p]);m!==c[p]&&(d=!0),f[p]=m}let h=a.catchall;return a.catchall&&(h=i(a.catchall),h!==a.catchall&&(d=!0)),d?je(s,{...a,shape:f,catchall:h}):s}case"array":{const c=i(a.element);return c===a.element?s:je(s,{...a,element:c})}case"tuple":{const c=a.items;let l=!1;const d=[];for(const h of c){const p=i(h);p!==h&&(l=!0),d.push(p)}let f=a.rest;return a.rest&&(f=i(a.rest),f!==a.rest&&(l=!0)),l?je(s,{...a,items:d,rest:f}):s}case"record":case"map":{const c=i(a.keyType),l=i(a.valueType);return c===a.keyType&&l===a.valueType?s:je(s,{...a,keyType:c,valueType:l})}case"set":{const c=i(a.valueType);return c===a.valueType?s:je(s,{...a,valueType:c})}case"union":{const c=a.options;let l=!1;const d=[];for(const f of c){const h=i(f);h!==f&&(l=!0),d.push(h)}return l?je(s,{...a,options:d}):s}case"intersection":{const c=i(a.left),l=i(a.right);return c===a.left&&l===a.right?s:je(s,{...a,left:c,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{const c=i(a.innerType);return c===a.innerType?s:je(s,{...a,innerType:c})}case"pipe":{const c=i(a.in),l=i(a.out);return c===a.in&&l===a.out?s:je(s,{...a,in:c,out:l})}case"function":{const c=i(a.input),l=i(a.output);return c===a.input&&l===a.output?s:je(s,{...a,input:c,output:l})}case"lazy":{const c=a.getter,{_cachedInner:l,...d}=a;return je(s,{...d,getter:()=>i(c())})}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 i(e)}function Xl(e){return!!e._zod}function Fb(e,t){return Xl(e)?Om(e,t):e.safeParse(t)}function tx(e){if(!e)return;let t;if(Xl(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function nx(e){if(Xl(e)){const o=e._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.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 rx=()=>{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(o){return e[o]??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 i(o,s){return o==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[o]??o}return o=>{switch(o.code){case"invalid_type":{const s=i(o.expected),a=Am(o.input),u=i(a,o.input);return`Invalid input: expected ${s}, received ${u}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${wc(o.values[0])}`:`Invalid option: expected one of ${Lu(o.values,"|")}`;case"too_big":{const s=o.exact?"exactly ":o.inclusive?"<=":"<",a=t(o.origin);return a?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{const s=o.exact?"exactly ":o.inclusive?">=":">",a=t(o.origin);return a?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${a.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{const s=o;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]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${Lu(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(a=>`'${a}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function ix(){return{localeError:rx()}}const ox=Object.freeze(Object.defineProperty({__proto__:null,endsWith:Di,gt:pn,gte:$t,includes:zi,length:Sr,lowercase:Ri,lt:hn,lte:Et,maxLength:kr,maxSize:Yn,mime:Mi,minLength:In,minSize:mn,multipleOf:qn,negative:qs,nonnegative:Ks,nonpositive:Ws,normalize:Fi,overwrite:tn,positive:Vs,properties:Oi,property:Js,regex:Ni,size:_r,slugify:Zi,startsWith:Pi,toLowerCase:Gi,toUpperCase:ji,trim:Ui,uppercase:Li},Symbol.toStringTag,{value:"Module"})),Bh=new WeakSet([Object.prototype,Error.prototype]);function Do(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 Ub=(e,t)=>{Pm.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Bh.has(n)||(Bh.add(n),Do(n,"format",r=>i=>Ns(r,i)),Do(n,"flatten",r=>i=>Is(r,i)),Do(n,"addIssue",r=>i=>{r.issues.push(i),r.message=JSON.stringify(r.issues,os,2)}),Do(n,"addIssues",r=>i=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,os,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Gb=S("ZodError",Ub),_t=S("ZodError",Ub,void 0,{Parent:Error}),Ql=Si(_t),ed=xi(_t),td=Ei(_t),nd=$i(_t),rd=Ic(_t),id=Nc(_t),od=Rc(_t),sd=Lc(_t),ad=zc(_t),ud=Pc(_t),cd=Dc(_t),ld=Oc(_t);function sx(){vt.localeError||et(ix())}function Xn(){vt.memoizer||et({memoizer:Us()})}const ye=S("ZodType",(e,t)=>(sx(),pe.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(lt(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 je(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ma(e,t))},superRefine(e,t){return this.check(Fa(e,t))},overwrite(e){return this.check(tn(e))},optional(){return Ue(this)},exactOptional(){return va(this)},nullable(){return mr(this)},nullish(){return Ue(mr(this))},nonoptional(e){return xa(this,e)},array(){return ae(this)},or(e){return ke([this,e])},and(e){return Dr(this,e)},transform(e){return fi(this,po(e))},default(e){return _a(this,e)},prefault(e){return Sa(this,e)},catch(e){return Ta(this,e)},pipe(e){return fi(this,e)},readonly(){return Na(this)},describe(e){const t=this.clone();return St.add(t,{description:e}),t},meta(...e){if(e.length===0)return St.get(this);const t=this.clone();return St.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 Cs(this,"~standard",{...qc(this),jsonSchema:{input:ci(this,"input"),output:ci(this,"output")}})},set"~standard"(e){dn(this,"~standard",e)},parse:function e(t,n){return Ql(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ed(this,t,n,{callee:e})},safeParse(e,t){return td(this,e,t)},async safeParseAsync(e,t){return nd(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){dn(this,"spa",e)},validate(e,t){return Ls(this,e,t)},validateAsync(e,t){return zs(this,e,t)},encode:function e(t,n){return rd(this,t,n,{callee:e})},decode:function e(t,n){return id(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await od(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await sd(this,t,n,{callee:e})},safeEncode(e,t){return ad(this,e,t)},safeDecode(e,t){return ud(this,e,t)},async safeEncodeAsync(e,t){return cd(this,e,t)},async safeDecodeAsync(e,t){return ld(this,e,t)},toJSONSchema(e){return Wv(this,{})(e)},get description(){return St.get(this)?.description},get _def(){return this._zod.def}}),Bi=S("_ZodString",(e,t)=>{Ii.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>eb(e,n,r)},ki({format:e=>tt(e).format??null,minLength:e=>tt(e).minimum??null,maxLength:e=>tt(e).maximum??null},{regex(...e){return this.check(Ni(...e))},includes(...e){return this.check(zi(...e))},startsWith(...e){return this.check(Pi(...e))},endsWith(...e){return this.check(Di(...e))},min(...e){return this.check(In(...e))},max(...e){return this.check(kr(...e))},length(...e){return this.check(Sr(...e))},nonempty(...e){return this.check(In(1,...e))},lowercase(e){return this.check(Ri(e))},uppercase(e){return this.check(Li(e))},trim(){return this.check(Ui())},normalize(...e){return this.check(Fi(...e))},toLowerCase(){return this.check(Gi())},toUpperCase(){return this.check(ji())},slugify(){return this.check(Zi())}})),Er=S("ZodString",(e,t)=>{Ii.init(e,t),Bi.init(e,t)},{email(e){return this.check(_l(Hi,e))},url(e){return this.check(Hs(Ir,e))},jwt(e){return this.check(Gl(ao,e))},emoji(e){return this.check(Tl(qi,e))},guid(e){return this.check(kl(Vi,e))},uuid(e){return this.check(Sl(qt,e))},uuidv4(e){return this.check(xl(qt,e))},uuidv6(e){return this.check(El(qt,e))},uuidv7(e){return this.check($l(qt,e))},nanoid(e){return this.check(Cl(Wi,e))},cuid(e){return this.check(Al(Ki,e))},cuid2(e){return this.check(Il(Ji,e))},ulid(e){return this.check(Nl(Yi,e))},base64(e){return this.check(Ml(io,e))},base64url(e){return this.check(Fl(oo,e))},xid(e){return this.check(Rl(Xi,e))},ksuid(e){return this.check(Ll(Qi,e))},ipv4(e){return this.check(zl(eo,e))},ipv6(e){return this.check(Pl(to,e))},cidrv4(e){return this.check(Dl(no,e))},cidrv6(e){return this.check(Ol(ro,e))},e164(e){return this.check(Ul(so,e))},datetime(e){return this.check(Zl($r,e))},date(e){return this.check(Bl(Tr,e))},time(e){return this.check(Hl(Cr,e))},duration(e){return this.check(Vl(Ar,e))}});function x(e){return cv(Er,e)}const De=S("ZodStringFormat",(e,t)=>{Fe.init(e,t),Bi.init(e,t)}),$r=S("ZodISODateTime",(e,t)=>{ey.init(e,t),De.init(e,t)}),Tr=S("ZodISODate",(e,t)=>{ty.init(e,t),De.init(e,t)}),Cr=S("ZodISOTime",(e,t)=>{ny.init(e,t),De.init(e,t)}),Ar=S("ZodISODuration",(e,t)=>{ry.init(e,t),De.init(e,t)}),Hi=S("ZodEmail",(e,t)=>{Bg.init(e,t),De.init(e,t)});function dd(e){return _l(Hi,e)}const Vi=S("ZodGUID",(e,t)=>{jg.init(e,t),De.init(e,t)});function fd(e){return kl(Vi,e)}const qt=S("ZodUUID",(e,t)=>{Zg.init(e,t),De.init(e,t)});function hd(e){return Sl(qt,e)}function pd(e){return xl(qt,e)}function md(e){return El(qt,e)}function gd(e){return $l(qt,e)}const Ir=S("ZodURL",(e,t)=>{Vg.init(e,t),De.init(e,t)});function yd(e){return Hs(Ir,e)}function vd(e){return Hs(Ir,{protocol:Mc,hostname:og,...N(e)})}const qi=S("ZodEmoji",(e,t)=>{qg.init(e,t),De.init(e,t)});function bd(e){return Tl(qi,e)}const Wi=S("ZodNanoID",(e,t)=>{Wg.init(e,t),De.init(e,t)});function wd(e){return Cl(Wi,e)}const Ki=S("ZodCUID",(e,t)=>{Kg.init(e,t),De.init(e,t)});function _d(e){return Al(Ki,e)}const Ji=S("ZodCUID2",(e,t)=>{Jg.init(e,t),De.init(e,t)});function kd(e){return Il(Ji,e)}const Yi=S("ZodULID",(e,t)=>{Yg.init(e,t),De.init(e,t)});function Sd(e){return Nl(Yi,e)}const Xi=S("ZodXID",(e,t)=>{Xg.init(e,t),De.init(e,t)});function xd(e){return Rl(Xi,e)}const Qi=S("ZodKSUID",(e,t)=>{Qg.init(e,t),De.init(e,t)});function Ed(e){return Ll(Qi,e)}const eo=S("ZodIPv4",(e,t)=>{iy.init(e,t),De.init(e,t)});function $d(e){return zl(eo,e)}const Ys=S("ZodMAC",(e,t)=>{sy.init(e,t),De.init(e,t)});function Td(e){return dv(Ys,e)}const to=S("ZodIPv6",(e,t)=>{oy.init(e,t),De.init(e,t)});function Cd(e){return Pl(to,e)}const no=S("ZodCIDRv4",(e,t)=>{ay.init(e,t),De.init(e,t)});function Ad(e){return Dl(no,e)}const ro=S("ZodCIDRv6",(e,t)=>{uy.init(e,t),De.init(e,t)});function Id(e){return Ol(ro,e)}const io=S("ZodBase64",(e,t)=>{cy.init(e,t),De.init(e,t)});function Nd(e){return Ml(io,e)}const oo=S("ZodBase64URL",(e,t)=>{ly.init(e,t),De.init(e,t)});function Rd(e){return Fl(oo,e)}const so=S("ZodE164",(e,t)=>{dy.init(e,t),De.init(e,t)});function Ld(e){return Ul(so,e)}const Xs=S("ZodCreditCard",(e,t)=>{fy.init(e,t),De.init(e,t)});function zd(e){return fv(Xs,e)}const Qs=S("ZodIBAN",(e,t)=>{hy.init(e,t),De.init(e,t)});function Pd(e){return hv(Qs,e)}const ao=S("ZodJWT",(e,t)=>{py.init(e,t),De.init(e,t)});function Dd(e){return Gl(ao,e)}const Nn=S("ZodCustomStringFormat",(e,t)=>{my.init(e,t),De.init(e,t)});function Od(e,t,n={}){return xr(Nn,e,t,n)}function Md(e){return xr(Nn,"hostname",ig,e)}function Fd(e){return xr(Nn,"hex",wg,e)}function Ud(e){return xr(Nn,"currency_code",ag,e)}function Gd(e,t){const n=t?.enc??"hex",r=`${e}_${n}`,i=Ps[r];if(!i)throw new Error(`Unrecognized hash format: ${r}`);return xr(Nn,r,i,t)}const Nr=S("ZodNumber",(e,t)=>{ol.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>tb(e,n,r,i),e.isFinite=!0},ki({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=tt(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=tt(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=tt(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>tt(e).format??null},{gt(e,t){return this.check(pn(e,t))},gte(e,t){return this.check($t(e,t))},min(e,t){return this.check($t(e,t))},lt(e,t){return this.check(hn(e,t))},lte(e,t){return this.check(Et(e,t))},max(e,t){return this.check(Et(e,t))},int(e){return this.check(di(e))},safe(e){return this.check(di(e))},positive(e){return this.check(pn(0,e))},nonnegative(e){return this.check($t(0,e))},negative(e){return this.check(hn(0,e))},nonpositive(e){return this.check(Et(0,e))},multipleOf(e,t){return this.check(qn(e,t))},step(e,t){return this.check(qn(e,t))},finite(){return this}}));function ge(e){return pv(Nr,e)}const Rn=S("ZodNumberFormat",(e,t)=>{gy.init(e,t),Nr.init(e,t)});function di(e){return gv(Rn,e)}function jd(e){return yv(Rn,e)}function Zd(e){return vv(Rn,e)}function Bd(e){return bv(Rn,e)}function Hd(e){return wv(Rn,e)}const Rr=S("ZodBoolean",(e,t)=>{sl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nb(e,n,r)});function Pe(e){return _v(Rr,e)}const Lr=S("ZodBigInt",(e,t)=>{al.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rb(e,n,r,i)},ki({minValue:e=>tt(e).minimum??null,maxValue:e=>tt(e).maximum??null,format:e=>tt(e).format??null},{gte(e,t){return this.check($t(e,t))},min(e,t){return this.check($t(e,t))},gt(e,t){return this.check(pn(e,t))},lt(e,t){return this.check(hn(e,t))},lte(e,t){return this.check(Et(e,t))},max(e,t){return this.check(Et(e,t))},positive(e){return this.check(pn(BigInt(0),e))},negative(e){return this.check(hn(BigInt(0),e))},nonpositive(e){return this.check(Et(BigInt(0),e))},nonnegative(e){return this.check($t(BigInt(0),e))},multipleOf(e,t){return this.check(qn(e,t))}}));function Vd(e){return Sv(Lr,e)}const uo=S("ZodBigIntFormat",(e,t)=>{yy.init(e,t),Lr.init(e,t)});function qd(e){return Ev(uo,e)}function Wd(e){return $v(uo,e)}const ea=S("ZodSymbol",(e,t)=>{vy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ib(e,n,r,i)});function Kd(e){return Tv(ea,e)}const ta=S("ZodUndefined",(e,t)=>{by.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sb(e,n,r,i)});function pr(e){return Cv(ta,e)}const na=S("ZodNull",(e,t)=>{wy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ob(e,n,r)});function co(e){return Av(na,e)}const ra=S("ZodAny",(e,t)=>{_y.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cb()});function lo(){return Iv(ra)}const ia=S("ZodUnknown",(e,t)=>{ky.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lb()});function Le(){return Nv(ia)}const oa=S("ZodNever",(e,t)=>{Sy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ub(e,n,r)});function Wn(e){return Rv(oa,e)}const sa=S("ZodVoid",(e,t)=>{xy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ab(e,n,r,i)});function Jd(e){return Lv(sa,e)}const fo=S("ZodDate",(e,t)=>{Ey.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>db(e,n,r,i),e.min=(n,r)=>e.check($t(n,r)),e.max=(n,r)=>e.check(Et(n,r))},ki({minDate:e=>{const{minimum:t}=tt(e);return t?new Date(t):null},maxDate:e=>{const{maximum:t}=tt(e);return t?new Date(t):null}},{}));function Yd(e){return zv(fo,e)}const aa=S("ZodArray",(e,t)=>{Xn(),$y.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Sb(e,n,r,i),e.element=t.element},{min(e,t){return this.check(In(e,t))},nonempty(e){return this.check(In(1,e))},max(e,t){return this.check(kr(e,t))},length(e,t){return this.check(Sr(e,t))},unwrap(){return this.element}});function ae(e,t){return Ov(aa,e,t)}function Xd(e){const t=e._zod.def.shape;return at(Object.keys(t))}const zr=S("ZodObject",(e,t)=>{Xn(),Iy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xb(e,n,r,i),Lm(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return at(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(lt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(lt(this._zod.def,{catchall:Le()}))},loose(){return this.clone(lt(this._zod.def,{catchall:Le()}))},strict(){return this.clone(lt(this._zod.def,{catchall:Wn()}))},strip(){return this.clone(lt(this._zod.def,{catchall:void 0}))},extend(e){return Sm(this,e)},safeExtend(e){return Em(this,e)},merge(e){return $m(this,e)},pick(e){return _m(this,e)},omit(e){return km(this,e)},partial(...e){return zu(Or,this,e[0])},exactPartial(...e){return zu(mo,this,e[0],"exactPartial")},required(...e){return Tm(go,this,e[0])}});function T(e,t){const n={type:"object",shape:e??{},...N(t)};return new zr(n)}function Qd(e,t){return new zr({type:"object",shape:e,catchall:Wn(),...N(t)})}function st(e,t){return new zr({type:"object",shape:e,catchall:Le(),...N(t)})}const Pr=S("ZodUnion",(e,t)=>{Fs.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ql(e,n,r,i),e.options=t.options});function ke(e,t){return new Pr({type:"union",options:e,...N(t)})}const ua=S("ZodXor",(e,t)=>{Pr.init(e,t),Ny.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ql(e,n,r,i),e.options=t.options});function ef(e,t){return new ua({type:"union",options:e,inclusive:!1,...N(t)})}const ca=S("ZodDiscriminatedUnion",(e,t)=>{Pr.init(e,t),Ly.init(e,t)});function ho(e,t,n){return new ca({type:"union",options:t,discriminator:e,...N(n)})}const la=S("ZodIntersection",(e,t)=>{zy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Eb(e,n,r,i)});function Dr(e,t){return new la({type:"intersection",left:e,right:t})}const da=S("ZodTuple",(e,t)=>{Xn(),cl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>$b(e,n,r,i)},{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 Or({type:"optional",innerType:t}))})}});function fa(e,t,n){const r=t instanceof pe,i=r?n:t,o=r?t:null;return new da({type:"tuple",items:e,rest:o,...N(i)})}const Kn=S("ZodRecord",(e,t)=>{Xn(),Py.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Tb(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function xe(e,t,n){return!t||!t._zod?new Kn({type:"record",keyType:x(),valueType:e,...N(t)}):new Kn({type:"record",keyType:e,valueType:t,...N(n)})}function tf(e,t,n){return new Kn({type:"record",keyType:e,valueType:t,...N(n),partial:!0})}function nf(e,t,n){return new Kn({type:"record",keyType:e,valueType:t,mode:"loose",...N(n)})}const ha=S("ZodMap",(e,t)=>{Xn(),Dy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>_b(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(mn(...n)),e.nonempty=n=>e.check(mn(1,n)),e.max=(...n)=>e.check(Yn(...n)),e.size=(...n)=>e.check(_r(...n))});function rf(e,t,n){return new ha({type:"map",keyType:e,valueType:t,...N(n)})}const pa=S("ZodSet",(e,t)=>{Xn(),Oy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kb(e,n,r,i),e.min=(...n)=>e.check(mn(...n)),e.nonempty=n=>e.check(mn(1,n)),e.max=(...n)=>e.check(Yn(...n)),e.size=(...n)=>e.check(_r(...n))});function of(e,t){return new pa({type:"set",valueType:e,...N(t)})}const Jn=S("ZodEnum",(e,t)=>{My.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(r,i,o)=>fb(e,r,i),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const o={};for(const s of r)if(n.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Jn({...t,checks:[],...N(i),entries:o})},e.exclude=(r,i)=>{const o={...t.entries};for(const s of r)if(n.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new Jn({...t,checks:[],...N(i),entries:o})}});function at(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Jn({type:"enum",entries:n,...N(t)})}function sf(e,t){return new Jn({type:"enum",entries:e,...N(t)})}const ma=S("ZodLiteral",(e,t)=>{Fy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hb(e,n,r,i),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(e,t){return new ma({type:"literal",values:Array.isArray(e)?e:[e],...N(t)})}const ga=S("ZodFile",(e,t)=>{Uy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gb(e,n,r),e.min=(n,r)=>e.check(mn(n,r)),e.max=(n,r)=>e.check(Yn(n,r)),e.mime=(n,r)=>e.check(Mi(Array.isArray(n)?n:[n],r))});function af(e){return Mv(ga,e)}const ya=S("ZodTransform",(e,t)=>{Xn(),Gy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>wb(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new As(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(ar(o,n.value,t));else{const s=o;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(ar(s))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function po(e){return new ya({type:"transform",transform:e})}const Or=S("ZodOptional",(e,t)=>{ll.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ue(e){return new Or({type:"optional",innerType:e})}const mo=S("ZodExactOptional",(e,t)=>{jy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function va(e){return new mo({type:"optional",innerType:e})}const ba=S("ZodNullable",(e,t)=>{Zy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Cb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function mr(e){return new ba({type:"nullable",innerType:e})}function uf(e){return Ue(mr(e))}const wa=S("ZodDefault",(e,t)=>{By.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Nb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _a(e,t){return new wa({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():wi(t)}})}const ka=S("ZodPrefault",(e,t)=>{Hy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Rb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Sa(e,t){return new ka({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():wi(t)}})}const go=S("ZodNonOptional",(e,t)=>{Vy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ab(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function xa(e,t){return new go({type:"nonoptional",innerType:e,...N(t)})}const Ea=S("ZodSuccess",(e,t)=>{qy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yb(e,n,r),e.unwrap=()=>e._zod.def.innerType});function cf(e){return new Ea({type:"success",innerType:e})}const $a=S("ZodCatch",(e,t)=>{Wy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Lb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ta(e,t){return new $a({type:"catch",innerType:e,catchValue:typeof t=="function"?t:xc(t)})}const Ca=S("ZodNaN",(e,t)=>{Ky.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>pb(e,n,r,i)});function lf(e){return Dv(Ca,e)}const Mr=S("ZodPipe",(e,t)=>{dl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>zb(e,n,r,i),e.in=t.in,e.out=t.out});function fi(e,t){return new Mr({type:"pipe",in:e,out:t})}const Fr=S("ZodCodec",(e,t)=>{Mr.init(e,t),fl.init(e,t)});function df(e,t,n){return new Fr({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function ff(e){const t=e._zod.def;return new Fr({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}const Aa=S("ZodPreprocess",(e,t)=>{Mr.init(e,t),Jy.init(e,t)}),Ia=S("ZodReadonly",(e,t)=>{Yy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Pb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Na(e){return new Ia({type:"readonly",innerType:e})}const Ra=S("ZodTemplateLiteral",(e,t)=>{Xy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mb(e,n,r)});function hf(e,t){return new Ra({type:"template_literal",parts:e,...N(t)})}const La=S("ZodLazy",(e,t)=>{hl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ob(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function za(e){return new La({type:"lazy",getter:e})}const Pa=S("ZodPromise",(e,t)=>{ev.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Db(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function pf(e){return new Pa({type:"promise",innerType:e})}const Da=S("ZodFunction",(e,t)=>{Qy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bb(e,n,r,i)});function gr(e){return new Da({type:"function",input:Array.isArray(e?.input)?fa(e?.input):e?.input??ae(Le()),output:e?.output??Le()})}const Ur=S("ZodCustom",(e,t)=>{tv.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vb(e,n,r,i)});function mf(e){const t=new Ze({check:"custom"});return t._zod.check=e,t}function Oa(e,t){return Fv(Ur,e??(()=>!0),t)}function Ma(e,t={}){return Uv(Ur,e,t)}function Fa(e,t){return Gv(e,t)}const gf=Zv,yf=Bv,Ua=S("ZodInstanceOf",(e,t)=>{Ur.init(e,t)},{properties(e,t){return this.check(Oi(e,t))}});function vf(e,t={}){const n=new Ua({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...N(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 bf=(...e)=>Hv({Codec:Fr,Boolean:Rr,String:Er},...e);function wf(e){const t=za(()=>ke([x(e),ge(),Pe(),co(),ae(t),xe(x(),t)]));return t}function yo(e,t){return new Aa({type:"pipe",in:po(e),out:t})}const ax=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:ra,ZodArray:aa,ZodBase64:io,ZodBase64URL:oo,ZodBigInt:Lr,ZodBigIntFormat:uo,ZodBoolean:Rr,ZodCIDRv4:no,ZodCIDRv6:ro,ZodCUID:Ki,ZodCUID2:Ji,ZodCatch:$a,ZodCodec:Fr,ZodCreditCard:Xs,ZodCustom:Ur,ZodCustomStringFormat:Nn,ZodDate:fo,ZodDefault:wa,ZodDiscriminatedUnion:ca,ZodE164:so,ZodEmail:Hi,ZodEmoji:qi,ZodEnum:Jn,ZodExactOptional:mo,ZodFile:ga,ZodFunction:Da,ZodGUID:Vi,ZodIBAN:Qs,ZodIPv4:eo,ZodIPv6:to,ZodISODate:Tr,ZodISODateTime:$r,ZodISODuration:Ar,ZodISOTime:Cr,ZodInstanceOf:Ua,ZodIntersection:la,ZodJWT:ao,ZodKSUID:Qi,ZodLazy:La,ZodLiteral:ma,ZodMAC:Ys,ZodMap:ha,ZodNaN:Ca,ZodNanoID:Wi,ZodNever:oa,ZodNonOptional:go,ZodNull:na,ZodNullable:ba,ZodNumber:Nr,ZodNumberFormat:Rn,ZodObject:zr,ZodOptional:Or,ZodPipe:Mr,ZodPrefault:ka,ZodPreprocess:Aa,ZodPromise:Pa,ZodReadonly:Ia,ZodRecord:Kn,ZodSet:pa,ZodString:Er,ZodStringFormat:De,ZodSuccess:Ea,ZodSymbol:ea,ZodTemplateLiteral:Ra,ZodTransform:ya,ZodTuple:da,ZodType:ye,ZodULID:Yi,ZodURL:Ir,ZodUUID:qt,ZodUndefined:ta,ZodUnion:Pr,ZodUnknown:ia,ZodVoid:sa,ZodXID:Xi,ZodXor:ua,_ZodString:Bi,_default:_a,_function:gr,any:lo,array:ae,base64:Nd,base64url:Rd,bigint:Vd,boolean:Pe,catch:Ta,check:mf,cidrv4:Ad,cidrv6:Id,codec:df,creditCard:zd,cuid:_d,cuid2:kd,currencyCode:Ud,custom:Oa,date:Yd,describe:gf,discriminatedUnion:ho,e164:Ld,email:dd,emoji:bd,enum:at,exactOptional:va,file:af,float32:jd,float64:Zd,function:gr,guid:fd,hash:Gd,hex:Fd,hostname:Md,httpUrl:vd,iban:Pd,instanceof:vf,int:di,int32:Bd,int64:qd,intersection:Dr,invertCodec:ff,ipv4:$d,ipv6:Cd,json:wf,jwt:Dd,keyof:Xd,ksuid:Ed,lazy:za,literal:E,looseObject:st,looseRecord:nf,mac:Td,map:rf,meta:yf,nan:lf,nanoid:wd,nativeEnum:sf,never:Wn,nonoptional:xa,null:co,nullable:mr,nullish:uf,number:ge,object:T,optional:Ue,partialRecord:tf,pipe:fi,prefault:Sa,preprocess:yo,promise:pf,readonly:Na,record:xe,refine:Ma,set:of,strictObject:Qd,string:x,stringFormat:Od,stringbool:bf,success:cf,superRefine:Fa,symbol:Kd,templateLiteral:hf,transform:po,tuple:fa,uint32:Hd,uint64:Wd,ulid:Sd,undefined:pr,union:ke,unknown:Le,url:yd,uuid:hd,uuidv4:pd,uuidv6:md,uuidv7:gd,void:Jd,xid:xd,xor:ef},Symbol.toStringTag,{value:"Module"})),jb={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 Zb(e){et({customError:e})}function Bb(){return et().customError}var ds;ds||(ds={});function Hb(e){return Zl($r,e)}function ux(e){return Bl(Tr,e)}function cx(e){return Hl(Cr,e)}function lx(e){return Vl(Ar,e)}const _f=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:Tr,ZodISODateTime:$r,ZodISODuration:Ar,ZodISOTime:Cr,date:ux,datetime:Hb,duration:lx,time:cx},Symbol.toStringTag,{value:"Module"})),V={...ax,...ox,iso:_f},dx=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 fx(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 Hh(e,t){return e.map((n,r)=>r<t?n:n.optional())}function hx(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function px(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 i=n[1]===void 0?void 0:hx(n[1]);if(!i||!t.defs[i])throw new Error(`Reference not found: ${e}`);return t.defs[i]}throw new Error(`Reference not found: ${e}`)}function mx(e,t){return V.transform(r=>r).check(r=>{const i=r.value;if(typeof i!="object"||i===null||Array.isArray(i))return;const o=Object.getOwnPropertyNames(i);if(t.minProperties!==void 0&&o.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:i,inst:e,continue:!0}),t.maxProperties!==void 0&&o.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:i,inst:e,continue:!0}),t.keySchema)for(const s of o){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 qu(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 o=[];for(const s of e){const a=qu(s,t);if(a===null)return null;o.push(a)}return`a${o.length}:[${o.join(",")}]`}const r=Object.keys(e).sort(),i=[];for(const o of r){const s=qu(e[o],t);if(s===null)return null;i.push(`${o.length}:${o}=${s}`)}return`o${i.length}:{${i.join(",")}}`}finally{t.delete(e)}}const gx=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),yx=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function oi(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(oi):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>gx.has(t)?oi(n):!yx.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(oi))}function Vh(e){return e===1?"element":"elements"}function vx(e,t){return V.transform(r=>r).check(r=>{const i=r.value;if(Array.isArray(i)){if(t.uniqueItems===!0){const o=new Map;for(let s=0;s<i.length;s++){const a=qu(i[s],new Set);if(a===null)continue;const u=o.get(a);if(u===void 0){o.set(a,s);continue}r.issues.push({code:"custom",message:`Array items must be unique: element at index ${s} duplicates the one at index ${u}`,input:i,path:[s],continue:!0})}}if(t.containsSchema){const o=t.minContains??1,s=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY;let a=0;for(const u of i)if(t.containsSchema.safeParse(u).success&&++a>=s)break;a<o&&r.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${Vh(o)}; found ${a}`,input:i,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&r.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${Vh(t.maxContains)}`,input:i,continue:!0})}}}).pipe(e)}function qh(e,t){if(e!==!1)return e===void 0||e===!0?V.any():yt(e,t)}const bx=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Vb(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return V.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 i=e.$ref;if(t.refs.has(i))return t.refs.get(i);if(t.processing.has(i))return V.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);const o=px(i,t),s=yt(o,t);return t.refs.set(i,s),t.processing.delete(i),s}if(e.enum!==void 0){const i=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&i.length===1&&i[0]===null)return V.null();if(i.length===0)return V.never();if(i.length===1)return V.literal(i[0]);if(i.every(s=>typeof s=="string"))return V.enum(i);const o=i.map(s=>V.literal(s));return o.length<2?o[0]:V.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return V.literal(e.const);const n=e.type;if(Array.isArray(n)){const i=n.map(o=>{const s={...e,type:o};return Vb(s,t)});return i.length===0?V.never():i.length===1?i[0]:V.union(i)}if(!n)return V.any();let r;switch(n){case"string":{let i=V.string();if(e.format){const o=e.format;o==="email"?i=i.check(V.email()):o==="uri"||o==="uri-reference"?i=i.check(V.url()):o==="uuid"||o==="guid"?i=i.check(V.uuid()):o==="date-time"?i=i.check(V.iso.datetime({offset:!0})):o==="date"?i=i.check(V.iso.date()):o==="time"?i=i.check(V.regex(bx)):o==="duration"?i=i.check(V.iso.duration()):o==="hostname"?i=i.check(V.hostname()):o==="ipv4"?i=i.check(V.ipv4()):o==="ipv6"?i=i.check(V.ipv6()):o==="mac"?i=i.check(V.mac()):o==="cidr"?i=i.check(V.cidrv4()):o==="cidr-v6"?i=i.check(V.cidrv6()):o==="base64"?i=i.check(V.base64()):o==="base64url"?i=i.check(V.base64url()):o==="e164"?i=i.check(V.e164()):o==="credit_card"?i=i.check(V.creditCard()):o==="iban"?i=i.check(V.iban()):o==="jwt"?i=i.check(V.jwt()):o==="emoji"?i=i.check(V.emoji()):o==="nanoid"?i=i.check(V.nanoid()):o==="cuid"?i=i.check(V.cuid()):o==="cuid2"?i=i.check(V.cuid2()):o==="ulid"?i=i.check(V.ulid()):o==="xid"?i=i.check(V.xid()):o==="ksuid"&&(i=i.check(V.ksuid()))}typeof e.minLength=="number"&&(i=i.min(e.minLength)),typeof e.maxLength=="number"&&(i=i.max(e.maxLength)),e.pattern&&(i=i.regex(new RegExp(e.pattern))),r=i;break}case"number":case"integer":{let i=n==="integer"?V.number().int():V.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(i=i.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(i=i.max(e.maximum)),typeof e.exclusiveMinimum=="number"?i=i.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(i=i.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?i=i.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(i=i.lt(e.maximum)),typeof e.multipleOf=="number"&&(i=i.multipleOf(e.multipleOf)),r=i;break}case"boolean":{r=V.boolean();break}case"null":{r=V.null();break}case"object":{const i={},o=e.properties||{},s=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?yt(e.additionalProperties,t):void 0;for(const[d,f]of Object.entries(o)){const h=yt(f,t);Tt(i,d,s.has(d)?h:h.optional())}if(e.patternProperties){const d=e.patternProperties,f=Object.keys(d),h=[];for(const m of f){const y=yt(d[m],t),w=V.string().regex(new RegExp(m));h.push(V.looseRecord(w,y))}const p=[];if(Object.keys(i).length>0&&p.push(V.object(i).passthrough()),p.push(...h),p.length===0)r=V.object({}).passthrough();else if(p.length===1)r=p[0];else{let m=V.intersection(p[0],p[1]);for(let y=2;y<p.length;y++)m=V.intersection(m,p[y]);r=m}if(e.additionalProperties===!1){const m=Object.keys(i),y=f.map(g=>new RegExp(g)),w=r;r=r.check(g=>{if(!cn(g.value))return;const b=[];for(const v of Object.keys(g.value))m.includes(v)||y.some(k=>k.test(v))||b.push(v);b.length&&g.issues.push({code:"unrecognized_keys",keys:b,input:g.value,inst:w})})}}else{const d=V.object(i);e.additionalProperties===!1?r=d.strict():a?r=d.catchall(a):r=d.passthrough()}const u=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(u||c!==void 0||l!==void 0){let d;if(u){const f=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=yt(f,t)}r=mx(r,{keySchema:d,minProperties:c,maxProperties:l})}break}case"array":{const i=e.prefixItems,o=e.items;if(i&&Array.isArray(i)){const s=typeof e.minItems=="number"?e.minItems:0,a=i.map(d=>yt(d,t)),u=Hh(a,s),c=Array.isArray(o)?void 0:qh(o,t),l=V.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(V.maxLength(e.maxItems)))}else if(Array.isArray(o)){const s=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>yt(d,t)),u=Hh(a,s),c=qh(e.additionalItems,t),l=V.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(V.maxLength(e.maxItems)))}else if(o!==void 0){const s=yt(o,t);let a=V.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=V.array(V.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=vx(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?yt(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 yt(e,t){if(typeof e=="boolean")return e?V.any():V.never();let n=Vb(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(c=>yt(c,t)),u=V.union(a);n=r?V.intersection(n,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){const a=e.oneOf.map(c=>yt(c,t)),u=V.xor(a);n=r?V.intersection(n,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:V.any();else{let a=r?n:yt(e.allOf[0],t);const u=r?0:1;for(let c=u;c<e.allOf.length;c++)a=V.intersection(a,yt(e.allOf[c],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=V.nullable(n)),e.readOnly===!0&&(n=V.readonly(n)),e.default!==void 0&&(n=n.default(e.default));const i={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(const a of o)a in e&&(i[a]=e[a]);const s=["contentEncoding","contentMediaType","contentSchema"];for(const a of s)a in e&&(i[a]=e[a]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!oi(e.propertyNames)&&(i.propertyNames=e.propertyNames);for(const a of["minProperties","maxProperties"])e[a]!==void 0&&(i[a]=e[a])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!oi(e.contains)&&(i.contains=e.contains);for(const a of["uniqueItems","minContains","maxContains"])e[a]!==void 0&&(i[a]=e[a])}for(const a of Object.keys(e))dx.has(a)||Tt(i,a,e[a]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function qb(e,t){if(typeof e=="boolean")return e?V.any():V.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=fx(n,t?.defaultTarget),i=n.$defs||n.definitions||{},o={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??St};return yt(n,o)}function Wb(e){return Yl(e,{object:t=>t.partial(),union:t=>{const n=t._zod.def;return n.discriminator===void 0?t:ke(n.options)}})}function wx(e,t){if(!t?.length)return e;const n=e._zod.def;return je(e,lt(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function Kb(e){return wx(e.out,e.checks)}function _x(e){return e.in._zod.traits.has("$ZodTransform")?Kb(e):e.in}function Jb(e){return Yl(e,{pipe:t=>_x(t._zod.def),default:(t,n)=>n?Ue(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function Yb(e){return Yl(e,{pipe:t=>Kb(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}function kx(e){return lv(Er,e)}function Sx(e){return mv(Nr,e)}function xx(e){return kv(Rr,e)}function Ex(e){return xv(Lr,e)}function $x(e){return Pv(fo,e)}const Xb=Object.freeze(Object.defineProperty({__proto__:null,bigint:Ex,boolean:xx,date:$x,number:Sx,string:kx},Symbol.toStringTag,{value:"Module"})),Wh=Object.freeze(Object.defineProperty({__proto__:null,$brand:Tc,$input:vl,$output:yl,INVALID:bt,NEVER:$c,TimePrecision:jl,ZodAny:ra,ZodArray:aa,ZodBase64:io,ZodBase64URL:oo,ZodBigInt:Lr,ZodBigIntFormat:uo,ZodBoolean:Rr,ZodCIDRv4:no,ZodCIDRv6:ro,ZodCUID:Ki,ZodCUID2:Ji,ZodCatch:$a,ZodCodec:Fr,ZodCompileAsyncError:fn,ZodCompileUnsupportedError:Ce,ZodCreditCard:Xs,ZodCustom:Ur,ZodCustomStringFormat:Nn,ZodDate:fo,ZodDefault:wa,ZodDiscriminatedUnion:ca,ZodE164:so,ZodEmail:Hi,ZodEmoji:qi,ZodEnum:Jn,ZodError:Gb,ZodExactOptional:mo,ZodFile:ga,get ZodFirstPartyTypeKind(){return ds},ZodFunction:Da,ZodGUID:Vi,ZodIBAN:Qs,ZodIPv4:eo,ZodIPv6:to,ZodISODate:Tr,ZodISODateTime:$r,ZodISODuration:Ar,ZodISOTime:Cr,ZodInstanceOf:Ua,ZodIntersection:la,ZodIssueCode:jb,ZodJWT:ao,ZodKSUID:Qi,ZodLazy:La,ZodLiteral:ma,ZodMAC:Ys,ZodMap:ha,ZodNaN:Ca,ZodNanoID:Wi,ZodNever:oa,ZodNonOptional:go,ZodNull:na,ZodNullable:ba,ZodNumber:Nr,ZodNumberFormat:Rn,ZodObject:zr,ZodOptional:Or,ZodPipe:Mr,ZodPrefault:ka,ZodPreprocess:Aa,ZodPromise:Pa,ZodReadonly:Ia,ZodRealError:_t,ZodRecord:Kn,ZodSet:pa,ZodString:Er,ZodStringFormat:De,ZodSuccess:Ea,ZodSymbol:ea,ZodTemplateLiteral:Ra,ZodTransform:ya,ZodTuple:da,ZodType:ye,ZodULID:Yi,ZodURL:Ir,ZodUUID:qt,ZodUndefined:ta,ZodUnion:Pr,ZodUnknown:ia,ZodVoid:sa,ZodXID:Xi,ZodXor:ua,_ZodString:Bi,_default:_a,_function:gr,any:lo,array:ae,base64:Nd,base64url:Rd,bigint:Vd,boolean:Pe,catch:Ta,check:mf,cidrv4:Ad,cidrv6:Id,clone:je,codec:df,coerce:Xb,compile:bl,config:et,core:Mb,creditCard:zd,cuid:_d,cuid2:kd,currencyCode:Ud,custom:Oa,date:Yd,decode:id,decodeAsync:sd,deepPartial:Wb,describe:gf,discriminatedUnion:ho,e164:Ld,email:dd,emoji:bd,encode:rd,encodeAsync:od,endsWith:Di,enum:at,exactOptional:va,file:af,flattenError:Is,float32:jd,float64:Zd,formatError:Ns,fromJSONSchema:qb,function:gr,getDiscriminatedOption:ul,getErrorMap:Bb,globalRegistry:St,gt:pn,gte:$t,guid:fd,hash:Gd,hex:Fd,hostname:Md,httpUrl:vd,iban:Pd,includes:zi,input:Jb,instanceof:vf,int:di,int32:Bd,int64:qd,intersection:Dr,invertCodec:ff,ipv4:$d,ipv6:Cd,iso:_f,json:wf,jwt:Dd,keyof:Xd,ksuid:Ed,lazy:za,length:Sr,literal:E,locales:gl,looseObject:st,looseRecord:nf,lowercase:Ri,lt:hn,lte:Et,mac:Td,map:rf,maxLength:kr,maxSize:Yn,memoizer:Us,meta:yf,mime:Mi,minLength:In,minSize:mn,multipleOf:qn,nan:lf,nanoid:wd,nativeEnum:sf,negative:qs,never:Wn,nonnegative:Ks,nonoptional:xa,nonpositive:Ws,normalize:Fi,null:co,nullable:mr,nullish:uf,number:ge,object:T,optional:Ue,output:Yb,overwrite:tn,parse:Ql,parseAsync:ed,partialRecord:tf,pipe:fi,positive:Vs,prefault:Sa,preprocess:yo,prettifyError:Ac,promise:pf,properties:Oi,property:Js,readonly:Na,record:xe,refine:Ma,regex:Ni,regexes:Ps,registry:Gs,safeDecode:ud,safeDecodeAsync:ld,safeEncode:ad,safeEncodeAsync:cd,safeParse:td,safeParseAsync:nd,set:of,setErrorMap:Zb,size:_r,slugify:Zi,startsWith:Pi,strictObject:Qd,string:x,stringFormat:Od,stringbool:bf,success:cf,superRefine:Fa,symbol:Kd,templateLiteral:hf,toJSONSchema:Jl,toLowerCase:Gi,toUpperCase:ji,toZod:Ss,transform:po,treeifyError:Cc,trim:Ui,tuple:fa,uint32:Hd,uint64:Wd,ulid:Sd,undefined:pr,union:ke,unknown:Le,uppercase:Li,url:yd,util:Ec,uuid:hd,uuidv4:pd,uuidv6:md,uuidv7:gd,validate:Ls,validateAsync:zs,void:Jd,withParser:js,xid:xd,xor:ef},Symbol.toStringTag,{value:"Module"})),Tx=Object.freeze(Object.defineProperty({__proto__:null,$brand:Tc,$input:vl,$output:yl,INVALID:bt,NEVER:$c,TimePrecision:jl,ZodAny:ra,ZodArray:aa,ZodBase64:io,ZodBase64URL:oo,ZodBigInt:Lr,ZodBigIntFormat:uo,ZodBoolean:Rr,ZodCIDRv4:no,ZodCIDRv6:ro,ZodCUID:Ki,ZodCUID2:Ji,ZodCatch:$a,ZodCodec:Fr,ZodCompileAsyncError:fn,ZodCompileUnsupportedError:Ce,ZodCreditCard:Xs,ZodCustom:Ur,ZodCustomStringFormat:Nn,ZodDate:fo,ZodDefault:wa,ZodDiscriminatedUnion:ca,ZodE164:so,ZodEmail:Hi,ZodEmoji:qi,ZodEnum:Jn,ZodError:Gb,ZodExactOptional:mo,ZodFile:ga,get ZodFirstPartyTypeKind(){return ds},ZodFunction:Da,ZodGUID:Vi,ZodIBAN:Qs,ZodIPv4:eo,ZodIPv6:to,ZodISODate:Tr,ZodISODateTime:$r,ZodISODuration:Ar,ZodISOTime:Cr,ZodInstanceOf:Ua,ZodIntersection:la,ZodIssueCode:jb,ZodJWT:ao,ZodKSUID:Qi,ZodLazy:La,ZodLiteral:ma,ZodMAC:Ys,ZodMap:ha,ZodNaN:Ca,ZodNanoID:Wi,ZodNever:oa,ZodNonOptional:go,ZodNull:na,ZodNullable:ba,ZodNumber:Nr,ZodNumberFormat:Rn,ZodObject:zr,ZodOptional:Or,ZodPipe:Mr,ZodPrefault:ka,ZodPreprocess:Aa,ZodPromise:Pa,ZodReadonly:Ia,ZodRealError:_t,ZodRecord:Kn,ZodSet:pa,ZodString:Er,ZodStringFormat:De,ZodSuccess:Ea,ZodSymbol:ea,ZodTemplateLiteral:Ra,ZodTransform:ya,ZodTuple:da,ZodType:ye,ZodULID:Yi,ZodURL:Ir,ZodUUID:qt,ZodUndefined:ta,ZodUnion:Pr,ZodUnknown:ia,ZodVoid:sa,ZodXID:Xi,ZodXor:ua,_ZodString:Bi,_default:_a,_function:gr,any:lo,array:ae,base64:Nd,base64url:Rd,bigint:Vd,boolean:Pe,catch:Ta,check:mf,cidrv4:Ad,cidrv6:Id,clone:je,codec:df,coerce:Xb,compile:bl,config:et,core:Mb,creditCard:zd,cuid:_d,cuid2:kd,currencyCode:Ud,custom:Oa,date:Yd,decode:id,decodeAsync:sd,deepPartial:Wb,default:Wh,describe:gf,discriminatedUnion:ho,e164:Ld,email:dd,emoji:bd,encode:rd,encodeAsync:od,endsWith:Di,enum:at,exactOptional:va,file:af,flattenError:Is,float32:jd,float64:Zd,formatError:Ns,fromJSONSchema:qb,function:gr,getDiscriminatedOption:ul,getErrorMap:Bb,globalRegistry:St,gt:pn,gte:$t,guid:fd,hash:Gd,hex:Fd,hostname:Md,httpUrl:vd,iban:Pd,includes:zi,input:Jb,instanceof:vf,int:di,int32:Bd,int64:qd,intersection:Dr,invertCodec:ff,ipv4:$d,ipv6:Cd,iso:_f,json:wf,jwt:Dd,keyof:Xd,ksuid:Ed,lazy:za,length:Sr,literal:E,locales:gl,looseObject:st,looseRecord:nf,lowercase:Ri,lt:hn,lte:Et,mac:Td,map:rf,maxLength:kr,maxSize:Yn,memoizer:Us,meta:yf,mime:Mi,minLength:In,minSize:mn,multipleOf:qn,nan:lf,nanoid:wd,nativeEnum:sf,negative:qs,never:Wn,nonnegative:Ks,nonoptional:xa,nonpositive:Ws,normalize:Fi,null:co,nullable:mr,nullish:uf,number:ge,object:T,optional:Ue,output:Yb,overwrite:tn,parse:Ql,parseAsync:ed,partialRecord:tf,pipe:fi,positive:Vs,prefault:Sa,preprocess:yo,prettifyError:Ac,promise:pf,properties:Oi,property:Js,readonly:Na,record:xe,refine:Ma,regex:Ni,regexes:Ps,registry:Gs,safeDecode:ud,safeDecodeAsync:ld,safeEncode:ad,safeEncodeAsync:cd,safeParse:td,safeParseAsync:nd,set:of,setErrorMap:Zb,size:_r,slugify:Zi,startsWith:Pi,strictObject:Qd,string:x,stringFormat:Od,stringbool:bf,success:cf,superRefine:Fa,symbol:Kd,templateLiteral:hf,toJSONSchema:Jl,toLowerCase:Gi,toUpperCase:ji,toZod:Ss,transform:po,treeifyError:Cc,trim:Ui,tuple:fa,uint32:Hd,uint64:Wd,ulid:Sd,undefined:pr,union:ke,unknown:Le,uppercase:Li,url:yd,util:Ec,uuid:hd,uuidv4:pd,uuidv6:md,uuidv7:gd,validate:Ls,validateAsync:zs,void:Jd,withParser:js,xid:xd,xor:ef,z:Wh},Symbol.toStringTag,{value:"Module"})),Un="io.modelcontextprotocol/related-task",Ga="2.0",Qe=Oa(e=>e!==null&&(typeof e=="object"||typeof e=="function")),Qb=ke([x(),ge().int()]),ew=x();st({ttl:ge().optional(),pollInterval:ge().optional()});const Cx=T({ttl:ge().optional()}),Ax=T({taskId:x()}),kf=st({progressToken:Qb.optional(),[Un]:Ax.optional()}),At=T({_meta:kf.optional()}),vo=At.extend({task:Cx.optional()}),Ix=e=>vo.safeParse(e).success,ut=T({method:x(),params:At.loose().optional()}),Mt=T({_meta:kf.optional()}),Ft=T({method:x(),params:Mt.loose().optional()}),ct=st({_meta:kf.optional()}),bo=ke([x(),ge().int()]),tw=T({jsonrpc:E(Ga),id:bo,...ut.shape}).strict(),Kh=e=>tw.safeParse(e).success,nw=T({jsonrpc:E(Ga),...Ft.shape}).strict(),Nx=e=>nw.safeParse(e).success,Sf=T({jsonrpc:E(Ga),id:bo,result:ct}).strict(),Oo=e=>Sf.safeParse(e).success;var Re;(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"})(Re||(Re={}));const xf=T({jsonrpc:E(Ga),id:bo.optional(),error:T({code:ge().int(),message:x(),data:Le().optional()})}).strict(),Rx=e=>xf.safeParse(e).success,Lx=ke([tw,nw,Sf,xf]);ke([Sf,xf]);const Ef=ct.strict(),zx=Mt.extend({requestId:bo.optional(),reason:x().optional()}),$f=Ft.extend({method:E("notifications/cancelled"),params:zx}),Px=T({src:x(),mimeType:x().optional(),sizes:ae(x()).optional(),theme:at(["light","dark"]).optional()}),wo=T({icons:ae(Px).optional()}),yr=T({name:x(),title:x().optional()}),ja=yr.extend({...yr.shape,...wo.shape,version:x(),websiteUrl:x().optional(),description:x().optional()}),Dx=Dr(T({applyDefaults:Pe().optional()}),xe(x(),Le())),Ox=yo(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Dr(T({form:Dx.optional(),url:Qe.optional()}),xe(x(),Le()).optional())),Mx=st({list:Qe.optional(),cancel:Qe.optional(),requests:st({sampling:st({createMessage:Qe.optional()}).optional(),elicitation:st({create:Qe.optional()}).optional()}).optional()}),Fx=st({list:Qe.optional(),cancel:Qe.optional(),requests:st({tools:st({call:Qe.optional()}).optional()}).optional()}),Ux=T({experimental:xe(x(),Qe).optional(),sampling:T({context:Qe.optional(),tools:Qe.optional()}).optional(),elicitation:Ox.optional(),roots:T({listChanged:Pe().optional()}).optional(),tasks:Mx.optional(),extensions:xe(x(),Qe).optional()}),Gx=At.extend({protocolVersion:x(),capabilities:Ux,clientInfo:ja}),jx=ut.extend({method:E("initialize"),params:Gx}),Zx=T({experimental:xe(x(),Qe).optional(),logging:Qe.optional(),completions:Qe.optional(),prompts:T({listChanged:Pe().optional()}).optional(),resources:T({subscribe:Pe().optional(),listChanged:Pe().optional()}).optional(),tools:T({listChanged:Pe().optional()}).optional(),tasks:Fx.optional(),extensions:xe(x(),Qe).optional()}),Bx=ct.extend({protocolVersion:x(),capabilities:Zx,serverInfo:ja,instructions:x().optional()}),Hx=Ft.extend({method:E("notifications/initialized"),params:Mt.optional()}),Za=ut.extend({method:E("ping"),params:At.optional()}),Vx=T({progress:ge(),total:Ue(ge()),message:Ue(x())}),qx=T({...Mt.shape,...Vx.shape,progressToken:Qb}),Tf=Ft.extend({method:E("notifications/progress"),params:qx}),Wx=At.extend({cursor:ew.optional()}),_o=ut.extend({params:Wx.optional()}),ko=ct.extend({nextCursor:ew.optional()}),Kx=at(["working","input_required","completed","failed","cancelled"]),So=T({taskId:x(),status:Kx,ttl:ke([ge(),co()]),createdAt:x(),lastUpdatedAt:x(),pollInterval:Ue(ge()),statusMessage:Ue(x())}),Cf=ct.extend({task:So}),Jx=Mt.merge(So),fs=Ft.extend({method:E("notifications/tasks/status"),params:Jx}),Af=ut.extend({method:E("tasks/get"),params:At.extend({taskId:x()})}),If=ct.merge(So),Nf=ut.extend({method:E("tasks/result"),params:At.extend({taskId:x()})});ct.loose();const Rf=_o.extend({method:E("tasks/list")}),Lf=ko.extend({tasks:ae(So)}),zf=ut.extend({method:E("tasks/cancel"),params:At.extend({taskId:x()})}),Yx=ct.merge(So),rw=T({uri:x(),mimeType:Ue(x()),_meta:xe(x(),Le()).optional()}),iw=rw.extend({text:x()}),Pf=x().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),ow=rw.extend({blob:Pf}),xo=at(["user","assistant"]),Gr=T({audience:ae(xo).optional(),priority:ge().min(0).max(1).optional(),lastModified:Hb({offset:!0}).optional()}),sw=T({...yr.shape,...wo.shape,uri:x(),description:Ue(x()),mimeType:Ue(x()),size:Ue(ge()),annotations:Gr.optional(),_meta:Ue(st({}))}),Xx=T({...yr.shape,...wo.shape,uriTemplate:x(),description:Ue(x()),mimeType:Ue(x()),annotations:Gr.optional(),_meta:Ue(st({}))}),Qx=_o.extend({method:E("resources/list")}),aw=ko.extend({resources:ae(sw)}),eE=_o.extend({method:E("resources/templates/list")}),tE=ko.extend({resourceTemplates:ae(Xx)}),Df=At.extend({uri:x()}),nE=Df,rE=ut.extend({method:E("resources/read"),params:nE}),uw=ct.extend({contents:ae(ke([iw,ow]))}),iE=Ft.extend({method:E("notifications/resources/list_changed"),params:Mt.optional()}),oE=Df,sE=ut.extend({method:E("resources/subscribe"),params:oE}),aE=Df,uE=ut.extend({method:E("resources/unsubscribe"),params:aE}),cE=Mt.extend({uri:x()}),lE=Ft.extend({method:E("notifications/resources/updated"),params:cE}),dE=T({name:x(),description:Ue(x()),required:Ue(Pe())}),fE=T({...yr.shape,...wo.shape,description:Ue(x()),arguments:Ue(ae(dE)),_meta:Ue(st({}))}),hE=_o.extend({method:E("prompts/list")}),pE=ko.extend({prompts:ae(fE)}),mE=At.extend({name:x(),arguments:xe(x(),x()).optional()}),gE=ut.extend({method:E("prompts/get"),params:mE}),Of=T({type:E("text"),text:x(),annotations:Gr.optional(),_meta:xe(x(),Le()).optional()}),Mf=T({type:E("image"),data:Pf,mimeType:x(),annotations:Gr.optional(),_meta:xe(x(),Le()).optional()}),Ff=T({type:E("audio"),data:Pf,mimeType:x(),annotations:Gr.optional(),_meta:xe(x(),Le()).optional()}),yE=T({type:E("tool_use"),name:x(),id:x(),input:xe(x(),Le()),_meta:xe(x(),Le()).optional()}),cw=T({type:E("resource"),resource:ke([iw,ow]),annotations:Gr.optional(),_meta:xe(x(),Le()).optional()}),lw=sw.extend({type:E("resource_link")}),Eo=ke([Of,Mf,Ff,lw,cw]),vE=T({role:xo,content:Eo}),bE=ct.extend({description:x().optional(),messages:ae(vE)}),wE=Ft.extend({method:E("notifications/prompts/list_changed"),params:Mt.optional()}),_E=T({title:x().optional(),readOnlyHint:Pe().optional(),destructiveHint:Pe().optional(),idempotentHint:Pe().optional(),openWorldHint:Pe().optional()}),kE=T({taskSupport:at(["required","optional","forbidden"]).optional()}),Uf=T({...yr.shape,...wo.shape,description:x().optional(),inputSchema:T({type:E("object"),properties:xe(x(),Qe).optional(),required:ae(x()).optional()}).catchall(Le()),outputSchema:T({type:E("object"),properties:xe(x(),Qe).optional(),required:ae(x()).optional()}).catchall(Le()).optional(),annotations:_E.optional(),execution:kE.optional(),_meta:xe(x(),Le()).optional()}),dw=_o.extend({method:E("tools/list")}),SE=ko.extend({tools:ae(Uf)}),Ba=ct.extend({content:ae(Eo).default([]),structuredContent:xe(x(),Le()).optional(),isError:Pe().optional()});Ba.or(ct.extend({toolResult:Le()}));const xE=vo.extend({name:x(),arguments:xe(x(),Le()).optional()}),fw=ut.extend({method:E("tools/call"),params:xE}),EE=Ft.extend({method:E("notifications/tools/list_changed"),params:Mt.optional()});T({autoRefresh:Pe().default(!0),debounceMs:ge().int().nonnegative().default(300)});const hw=at(["debug","info","notice","warning","error","critical","alert","emergency"]),$E=At.extend({level:hw}),TE=ut.extend({method:E("logging/setLevel"),params:$E}),CE=Mt.extend({level:hw,logger:x().optional(),data:Le()}),AE=Ft.extend({method:E("notifications/message"),params:CE}),IE=T({name:x().optional()}),NE=T({hints:ae(IE).optional(),costPriority:ge().min(0).max(1).optional(),speedPriority:ge().min(0).max(1).optional(),intelligencePriority:ge().min(0).max(1).optional()}),RE=T({mode:at(["auto","required","none"]).optional()}),LE=T({type:E("tool_result"),toolUseId:x().describe("The unique identifier for the corresponding tool call."),content:ae(Eo).default([]),structuredContent:T({}).loose().optional(),isError:Pe().optional(),_meta:xe(x(),Le()).optional()}),zE=ho("type",[Of,Mf,Ff]),hs=ho("type",[Of,Mf,Ff,yE,LE]),PE=T({role:xo,content:ke([hs,ae(hs)]),_meta:xe(x(),Le()).optional()}),DE=vo.extend({messages:ae(PE),modelPreferences:NE.optional(),systemPrompt:x().optional(),includeContext:at(["none","thisServer","allServers"]).optional(),temperature:ge().optional(),maxTokens:ge().int(),stopSequences:ae(x()).optional(),metadata:Qe.optional(),tools:ae(Uf).optional(),toolChoice:RE.optional()}),OE=ut.extend({method:E("sampling/createMessage"),params:DE}),pw=ct.extend({model:x(),stopReason:Ue(at(["endTurn","stopSequence","maxTokens"]).or(x())),role:xo,content:zE}),mw=ct.extend({model:x(),stopReason:Ue(at(["endTurn","stopSequence","maxTokens","toolUse"]).or(x())),role:xo,content:ke([hs,ae(hs)])}),ME=T({type:E("boolean"),title:x().optional(),description:x().optional(),default:Pe().optional()}),FE=T({type:E("string"),title:x().optional(),description:x().optional(),minLength:ge().optional(),maxLength:ge().optional(),format:at(["email","uri","date","date-time"]).optional(),default:x().optional()}),UE=T({type:at(["number","integer"]),title:x().optional(),description:x().optional(),minimum:ge().optional(),maximum:ge().optional(),default:ge().optional()}),GE=T({type:E("string"),title:x().optional(),description:x().optional(),enum:ae(x()),default:x().optional()}),jE=T({type:E("string"),title:x().optional(),description:x().optional(),oneOf:ae(T({const:x(),title:x()})),default:x().optional()}),ZE=T({type:E("string"),title:x().optional(),description:x().optional(),enum:ae(x()),enumNames:ae(x()).optional(),default:x().optional()}),BE=ke([GE,jE]),HE=T({type:E("array"),title:x().optional(),description:x().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:T({type:E("string"),enum:ae(x())}),default:ae(x()).optional()}),VE=T({type:E("array"),title:x().optional(),description:x().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:T({anyOf:ae(T({const:x(),title:x()}))}),default:ae(x()).optional()}),qE=ke([HE,VE]),WE=ke([ZE,BE,qE]),KE=ke([WE,ME,FE,UE]),JE=vo.extend({mode:E("form").optional(),message:x(),requestedSchema:T({type:E("object"),properties:xe(x(),KE),required:ae(x()).optional()})}),YE=vo.extend({mode:E("url"),message:x(),elicitationId:x(),url:x().url()}),XE=ke([JE,YE]),QE=ut.extend({method:E("elicitation/create"),params:XE}),e$=Mt.extend({elicitationId:x()}),t$=Ft.extend({method:E("notifications/elicitation/complete"),params:e$}),n$=ct.extend({action:at(["accept","decline","cancel"]),content:yo(e=>e===null?void 0:e,xe(x(),ke([x(),ge(),Pe(),ae(x())])).optional())}),r$=T({type:E("ref/resource"),uri:x()}),i$=T({type:E("ref/prompt"),name:x()}),o$=At.extend({ref:ke([i$,r$]),argument:T({name:x(),value:x()}),context:T({arguments:xe(x(),x()).optional()}).optional()}),s$=ut.extend({method:E("completion/complete"),params:o$}),a$=ct.extend({completion:st({values:ae(x()).max(100),total:Ue(ge().int()),hasMore:Ue(Pe())})}),u$=T({uri:x().startsWith("file://"),name:x().optional(),_meta:xe(x(),Le()).optional()}),c$=ut.extend({method:E("roots/list"),params:At.optional()}),l$=ct.extend({roots:ae(u$)}),d$=Ft.extend({method:E("notifications/roots/list_changed"),params:Mt.optional()});ke([Za,jx,s$,TE,gE,hE,Qx,eE,rE,sE,uE,fw,dw,Af,Nf,Rf,zf]);ke([$f,Tf,Hx,d$,fs]);ke([Ef,pw,mw,n$,l$,If,Lf,Cf]);ke([Za,OE,QE,c$,Af,Nf,Rf,zf]);ke([$f,Tf,AE,lE,iE,EE,wE,fs,t$]);ke([Ef,Bx,a$,bE,pE,aw,tE,uw,Ba,SE,If,Lf,Cf]);class Te 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===Re.UrlElicitationRequired&&r){const i=r;if(i.elicitations)return new f$(i.elicitations,n)}return new Te(t,n,r)}}class f$ extends Te{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(Re.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function Dn(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Jh(e){const n=tx(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=nx(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function Yh(e,t){const n=Fb(e,t);if(!n.success)throw n.error;return n.data}const h$=6e4;class p${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($f,n=>{this._oncancel(n)}),this.setNotificationHandler(Tf,n=>{this._onprogress(n)}),this.setRequestHandler(Za,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Af,async(n,r)=>{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new Te(Re.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(Nf,async(n,r)=>{const i=async()=>{const o=n.params.taskId;if(!await this._taskStore.getTask(o,r.sessionId))throw new Te(Re.InvalidParams,`Task not found: ${o}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,r.sessionId);){if(a.type==="response"||a.type==="error"){const u=a.message,c=u.id,l=this._requestResolvers.get(c);if(l)if(this._requestResolvers.delete(c),a.type==="response")l(u);else{const d=u,f=new Te(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 ${c}`))}continue}await this._transport?.send(a.message,{relatedRequestId:r.requestId})}}const s=await this._taskStore.getTask(o,r.sessionId);if(!s)throw new Te(Re.InvalidParams,`Task not found: ${o}`);if(!Dn(s.status))return await this._waitForTaskUpdate(o,r.signal,r.sessionId),await i();if(Dn(s.status)){const a=await this._taskStore.getTaskResult(o,r.sessionId);return this._clearTaskQueue(o,r.sessionId),{...a,_meta:{...a._meta,[Un]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(Rf,async(n,r)=>{try{const{tasks:i,nextCursor:o}=await this._taskStore.listTasks(n.params?.cursor,r.sessionId);return{tasks:i,nextCursor:o,_meta:{}}}catch(i){throw new Te(Re.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(zf,async(n,r)=>{try{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new Te(Re.InvalidParams,`Task not found: ${n.params.taskId}`);if(Dn(i.status))throw new Te(Re.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",r.sessionId),this._clearTaskQueue(n.params.taskId,r.sessionId);const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new Te(Re.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof Te?i:new Te(Re.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,n,r,i,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,n),startTime:Date.now(),timeout:n,maxTotalTimeout:r,resetTimeoutOnProgress:o,onTimeout:i})}_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),Te.fromError(Re.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=o=>{r?.(o),this._onerror(o)};const i=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{i?.(o,s),Oo(o)||Rx(o)?this._onresponse(o):Kh(o)?this._onrequest(o,s):Nx(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},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=Te.fromError(Re.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,i=this._transport,o=t.params?._meta?.[Un]?.taskId,s=i?.sessionId,a=this._taskStore;let u=!0,c;if(o&&a&&this._taskMessageQueue&&s!==void 0&&(u=!1,c=(async()=>{if(!await a.getTask(o,s))throw new Te(Re.InvalidParams,`Task not found: ${o}`);u=!0})()),r===void 0){const p={jsonrpc:"2.0",id:t.id,error:{code:Re.MethodNotFound,message:"Method not found"}};if(o&&c){const m={type:"error",message:p,timestamp:Date.now()};c.then(()=>this._enqueueTaskMessage(o,m,s),()=>i?.send(p)).catch(y=>this._onerror(new Error(`Failed to send an error response: ${y}`)))}else o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:p,timestamp:Date.now()},i?.sessionId).catch(m=>this._onerror(new Error(`Failed to enqueue error response: ${m}`))):i?.send(p).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=Ix(t.params)?t.params.task:void 0,f=this._taskStore?this.requestTaskStore(t,i?.sessionId):void 0,h={signal:l.signal,sessionId:i?.sessionId,_meta:t.params?._meta,sendNotification:async p=>{if(l.signal.aborted)return;const m={relatedRequestId:t.id};o&&(m.relatedTask={taskId:o}),await this.notification(p,m)},sendRequest:async(p,m,y)=>{if(l.signal.aborted)throw new Te(Re.ConnectionClosed,"Request was cancelled");const w={...y,relatedRequestId:t.id};o&&!w.relatedTask&&(w.relatedTask={taskId:o});const g=w.relatedTask?.taskId??o;return g&&f&&await f.updateTaskStatus(g,"input_required"),await this.request(p,m,w)},authInfo:n?.authInfo,requestId:t.id,requestInfo:n?.requestInfo,taskId:o,taskStore:f,taskRequestedTtl:d?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};(c??Promise.resolve()).then(()=>{if(c&&l.signal.aborted)throw new Te(Re.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>r(t,h)).then(async p=>{if(l.signal.aborted)return;const m={result:p,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:m,timestamp:Date.now()},i?.sessionId):await i?.send(m)},async p=>{if(l.signal.aborted)return;const m={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(p.code)?p.code:Re.InternalError,message:p.message??"Internal error",...p.data!==void 0&&{data:p.data}}};o&&this._taskMessageQueue&&u?await this._enqueueTaskMessage(o,{type:"error",message:m,timestamp:Date.now()},i?.sessionId):await i?.send(m)}).catch(p=>this._onerror(new Error(`Failed to send response: ${p}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===l&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...r}=t.params,i=Number(n),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const s=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(u){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),s(u);return}o(r)}_onresponse(t){const n=Number(t.id),r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),Oo(t))r(t);else{const s=new Te(t.error.code,t.error.message,t.error.data);r(s)}return}const i=this._responseHandlers.get(n);if(i===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 o=!1;if(Oo(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"&&(o=!0,this._taskProgressTokens.set(a.taskId,n))}}if(o||this._progressHandlers.delete(n),Oo(t))i(t);else{const s=Te.fromError(t.error.code,t.error.message,t.error.data);i(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,n,r){const{task:i}=r??{};if(!i){try{yield{type:"result",result:await this.request(t,n,r)}}catch(s){yield{type:"error",error:s instanceof Te?s:new Te(Re.InternalError,String(s))}}return}let o;try{const s=await this.request(t,Cf,r);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new Te(Re.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:o},r);if(yield{type:"taskStatus",task:a},Dn(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)}:a.status==="failed"?yield{type:"error",error:new Te(Re.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new Te(Re.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)};return}const u=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(c=>setTimeout(c,u)),r?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof Te?s:new Te(Re.InternalError,String(s))}}}request(t,n,r){const{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:u}=r??{};return new Promise((c,l)=>{const d=g=>{l(g)};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(g){d(g);return}r?.signal?.throwIfAborted();const f=this._requestMessageId++,h={...t,jsonrpc:"2.0",id:f};r?.onprogress&&(this._progressHandlers.set(f,r.onprogress),h.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(h.params={...h.params,task:a}),u&&(h.params={...h.params,_meta:{...h.params?._meta||{},[Un]:u}});const p=g=>{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(g)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>this._onerror(new Error(`Failed to send cancellation: ${v}`)));const b=g instanceof Te?g:new Te(Re.RequestTimeout,String(g));l(b)};this._responseHandlers.set(f,g=>{if(!r?.signal?.aborted){if(g instanceof Error)return l(g);try{const b=Fb(n,g.result);b.success?c(b.data):l(b.error)}catch(b){l(b)}}}),r?.signal?.addEventListener("abort",()=>{p(r?.signal?.reason)});const m=r?.timeout??h$,y=()=>p(Te.fromError(Re.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(f,m,r?.maxTotalTimeout,y,r?.resetTimeoutOnProgress??!1);const w=u?.taskId;if(w){const g=b=>{const v=this._responseHandlers.get(f);v?v(b):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,g),this._enqueueTaskMessage(w,{type:"request",message:h,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(f),l(b)})}else this._transport.send(h,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(g=>{this._cleanupTimeout(f),l(g)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},If,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},Lf,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},Yx,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||{},[Un]: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||{},[Un]:n.relatedTask}}}),this._transport?.send(a,n).catch(u=>this._onerror(u))});return}let s={...t,jsonrpc:"2.0"};n?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Un]:n.relatedTask}}}),await this._transport.send(s,n)}setRequestHandler(t,n){const r=Jh(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(i,o)=>{const s=Yh(t,i);return Promise.resolve(n(s,o))})}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=Jh(t);this._notificationHandlers.set(r,i=>{const o=Yh(t,i);return Promise.resolve(n(o))})}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 i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,r??this._transport?.sessionId,i)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(t,n);for(const i of r)if(i.type==="request"&&Kh(i.message)){const o=i.message.id,s=this._requestResolvers.get(o);s?(s(new Te(Re.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n,r){let i=this._options?.defaultTaskPollInterval??1e3;try{const o=await this._taskStore?.getTask(t,r);o?.pollInterval&&(i=o.pollInterval)}catch{}return new Promise((o,s)=>{if(n.aborted){s(new Te(Re.InvalidRequest,"Request cancelled"));return}const a=setTimeout(o,i);n.addEventListener("abort",()=>{clearTimeout(a),s(new Te(Re.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await r.createTask(i,t.id,{method:t.method,params:t.params},n)},getTask:async i=>{const o=await r.getTask(i,n);if(!o)throw new Te(Re.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(i,o,s)=>{await r.storeTaskResult(i,o,s,n);const a=await r.getTask(i,n);if(a){const u=fs.parse({method:"notifications/tasks/status",params:a});await this.notification(u),Dn(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>r.getTaskResult(i,n),updateTaskStatus:async(i,o,s)=>{const a=await r.getTask(i,n);if(!a)throw new Te(Re.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(Dn(a.status))throw new Te(Re.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(i,o,s,n);const u=await r.getTask(i,n);if(u){const c=fs.parse({method:"notifications/tasks/status",params:u});await this.notification(c),Dn(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>r.listTasks(i,n)}}}function Xh(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function m$(e,t){const n={...e};for(const r in t){const i=r,o=t[i];if(o===void 0)continue;const s=n[i];Xh(s)&&Xh(o)?n[i]={...s,...o}:n[i]=o}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 g$ extends p${_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 i=r.shape.method.value;this._registeredMethods.add(i);let o=n;super.setNotificationHandler(r,s=>{let a=s.params;this.onEventDispatch(t,a),o.onHandler?.(a);for(let u of[...o.listeners])u(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 i=r.listeners.indexOf(n);i!==-1&&r.listeners.splice(i,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 y$="2026-01-26",v$="ui/notifications/tool-input-partial";class gw{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 i=Lx.safeParse(r.data);i.success?(console.debug("Parsed message",i.data),this.onmessage?.(i.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",i.error.message,r):(console.error("Failed to parse message",i.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+i.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==v$&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var b$=ke([E("light"),E("dark")]).describe("Color theme preference for the host environment."),hi=ke([E("inline"),E("fullscreen"),E("pip")]).describe("Display mode for UI presentation."),w$=ke([E("--color-background-primary"),E("--color-background-secondary"),E("--color-background-tertiary"),E("--color-background-inverse"),E("--color-background-ghost"),E("--color-background-info"),E("--color-background-danger"),E("--color-background-success"),E("--color-background-warning"),E("--color-background-disabled"),E("--color-text-primary"),E("--color-text-secondary"),E("--color-text-tertiary"),E("--color-text-inverse"),E("--color-text-ghost"),E("--color-text-info"),E("--color-text-danger"),E("--color-text-success"),E("--color-text-warning"),E("--color-text-disabled"),E("--color-border-primary"),E("--color-border-secondary"),E("--color-border-tertiary"),E("--color-border-inverse"),E("--color-border-ghost"),E("--color-border-info"),E("--color-border-danger"),E("--color-border-success"),E("--color-border-warning"),E("--color-border-disabled"),E("--color-ring-primary"),E("--color-ring-secondary"),E("--color-ring-inverse"),E("--color-ring-info"),E("--color-ring-danger"),E("--color-ring-success"),E("--color-ring-warning"),E("--font-sans"),E("--font-mono"),E("--font-weight-normal"),E("--font-weight-medium"),E("--font-weight-semibold"),E("--font-weight-bold"),E("--font-text-xs-size"),E("--font-text-sm-size"),E("--font-text-md-size"),E("--font-text-lg-size"),E("--font-heading-xs-size"),E("--font-heading-sm-size"),E("--font-heading-md-size"),E("--font-heading-lg-size"),E("--font-heading-xl-size"),E("--font-heading-2xl-size"),E("--font-heading-3xl-size"),E("--font-text-xs-line-height"),E("--font-text-sm-line-height"),E("--font-text-md-line-height"),E("--font-text-lg-line-height"),E("--font-heading-xs-line-height"),E("--font-heading-sm-line-height"),E("--font-heading-md-line-height"),E("--font-heading-lg-line-height"),E("--font-heading-xl-line-height"),E("--font-heading-2xl-line-height"),E("--font-heading-3xl-line-height"),E("--border-radius-xs"),E("--border-radius-sm"),E("--border-radius-md"),E("--border-radius-lg"),E("--border-radius-xl"),E("--border-radius-full"),E("--border-width-regular"),E("--shadow-hairline"),E("--shadow-sm"),E("--shadow-md"),E("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),_$=xe(w$.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]){o(s);continue}if(e.external){const c=e.external.registry.get(s[0])?.id;if(t!==s[0]&&c){o(s);continue}}if(e.metadataRegistry.get(s[0])?.id){o(s);continue}if(a.cycle){o(s);continue}a.count>1&&e.reused==="ref"&&o(s)}e.external&&(e.sharedDefsExtractedFor=e.external)}function Wv(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;Wv(r);const i=Object.keys(r);if(i.length!==1||i[0]!=="type")return;const o=r.type;for(const s of Array.isArray(o)?o:[o]){if(typeof s!="string")return;n.includes(s)||n.push(s)}}delete e.anyOf,e.type=n.length===1?n[0]:n}const Kv=new Set(["type","properties","required","additionalProperties"]),Mh=["oneOf","anyOf"];function Fh(e){const t=e.additionalProperties;return t===void 0||t===!1||typeof t!="object"||t===null?null:Object.keys(t).length?t:null}function Zu(e){const t=[];for(const o of e){if(typeof o!="object"||o.type!=="object")return null;for(const s in o)if(!Kv.has(s))return null;t.push(o)}const n={},r=new Set;for(const o of t){for(const s in o.properties){if(Object.prototype.hasOwnProperty.call(n,s))continue;const a=[];for(const c of t){const l=c.properties?.[s]??Fh(c);l!=null&&(a.some(d=>JSON.stringify(d)===JSON.stringify(l))||a.push(l))}const u=a.length===1?a[0]:Zu(a)??{allOf:a};Tt(n,s,u)}for(const s of o.required??[])r.add(s)}const i={type:"object",properties:n};if(r.size&&(i.required=[...r]),t.every(o=>o.additionalProperties===!1))i.additionalProperties=!1;else{const o=[];for(const s of t){const a=Fh(s);a&&!o.some(u=>JSON.stringify(u)===JSON.stringify(a))&&o.push(a)}o.length===1?i.additionalProperties=o[0]:o.length>1&&(i.additionalProperties={allOf:o})}return i}function Y0(e){const t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(const i of Kv)if(i in e)return;const n=t.filter(i=>Mh.some(o=>Array.isArray(i[o])));let r=null;if(!n.length)r=Zu(t);else{const i=n[0],o=Mh.find(u=>Array.isArray(i[u]));if(Object.keys(i).length!==1)return;const s=t.filter(u=>u!==i),a=i[o].map(u=>Zu([...s,u]));if(a.some(u=>!u))return;r={[o]:a}}r&&(delete e.allOf,ii(e,r))}function dr(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 u=e.seen.get(a);if(u.ref===null)return;const c=u.def??u.schema,l={...c},d=u.ref;if(u.ref=null,d){r(d);const h=e.seen.get(d),p=h.schema;if(p.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(c.allOf=c.allOf??[],c.allOf.push(p)):ii(c,p),ii(c,l),a._zod.parent===d)for(const y in c)y==="$ref"||y==="allOf"||y in l||delete c[y];if(p.$ref&&h.def)for(const y in c)y==="$ref"||y==="allOf"||y in h.def&&JSON.stringify(c[y])===JSON.stringify(h.def[y])&&delete c[y]}const f=a._zod.parent;if(f&&f!==d){r(f);const h=e.seen.get(f);if(h?.schema.$ref&&(c.$ref=h.schema.$ref,h.def))for(const p in c)p==="$ref"||p==="allOf"||p in h.def&&JSON.stringify(c[p])===JSON.stringify(h.def[p])&&delete c[p]}e.override({zodSchema:a,jsonSchema:c,path:u.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())Wv(a[1].def??a[1].schema);for(const a of e.deferred)a();if(e.intersections.length){const a=new Map;for(const u of e.seen.values())for(const c of[u.schema,u.def]){const l=c?.allOf;if(!Array.isArray(l))continue;const d=a.get(l);d?d.push(c):a.set(l,[c])}for(const u of e.intersections)for(const c of a.get(u)??[])Y0(c)}}const i={};if(e.target==="draft-2020-12"?i.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?i.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?i.$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");i.$id=e.external.uri(a)}ii(i,n.defId?n.schema:n.def??n.schema);const o=e.metadataRegistry.get(t)?.id;o!==void 0&&i.id===o&&delete i.id;const s=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(const a of e.seen.entries()){const u=a[1];u.def&&u.defId&&(u.def.id===u.defId&&delete u.def.id,Tt(s,u.defId,u.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?i.$defs=s:i.definitions=s);try{const a=JSON.parse(JSON.stringify(i));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:ci(t,"input",e.processors),output:ci(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function mt(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 mt(r.element,n);if(r.type==="set")return mt(r.valueType,n);if(r.type==="lazy")return mt(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 mt(r.innerType,n);if(r.type==="intersection")return mt(r.left,n)||mt(r.right,n);if(r.type==="record"||r.type==="map")return mt(r.keyType,n)||mt(r.valueType,n);if(r.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:mt(r.in,n)||mt(r.out,n);if(r.type==="object"){for(const i in r.shape)if(mt(r.shape[i],n))return!0;return!1}if(r.type==="union"){for(const i of r.options)if(mt(i,n))return!0;return!1}if(r.type==="tuple"){for(const i of r.items)if(mt(i,n))return!0;return!!(r.rest&&mt(r.rest,n))}return!1}const Jv=(e,t={})=>n=>{const r=cr({...n,processors:t});return De(e,r),lr(r,e),dr(r,e)},ci=(e,t,n={})=>r=>{const{libraryOptions:i,target:o}=r??{},s=cr({...i??{},target:o,io:t,processors:n});return De(e,s),lr(s,e),dr(s,e)},fr=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},hr=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Uh=(e,t)=>{fr(e,"minimum",t),hr(e,"maximum",t)},Yv=(e,t)=>{e.multipleOf??(e.multipleOf=[]),e.multipleOf.includes(t)||e.multipleOf.push(t)},Xv=(e,t)=>{e.patterns??(e.patterns=new Set),e.patterns.add(t)},Qv=(e,t)=>{e.mime=e.mime?e.mime.filter(n=>t.includes(n)):[...t]},eb=(e,t)=>{e.format=t,t.includes("int")&&(e.isInt=!0)},Gh=(e,t)=>fr(e,"minimum",t.minimum),jh=(e,t)=>hr(e,"maximum",t.maximum),Zh=e=>(t,n)=>{eb(t,n.format);const[r,i]=e[n.format];fr(t,"minimum",r),hr(t,"maximum",i)},X0={greater_than:(e,t)=>fr(e,t.inclusive?"minimum":"exclusiveMinimum",t.value),less_than:(e,t)=>hr(e,t.inclusive?"maximum":"exclusiveMaximum",t.value),multiple_of:(e,t)=>Yv(e,t.value),number_format:Zh(_c),bigint_format:Zh(kc),min_length:Gh,max_length:jh,length_equals:(e,t)=>Uh(e,t.length),min_size:Gh,max_size:jh,size_equals:(e,t)=>Uh(e,t.size),string_format:(e,t)=>{eb(e,t.format),t.pattern&&Xv(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)=>Qv(e,t.mime)};function tt(e){const t={},n=e._zod.def,r=e._zod.traits.has("$ZodCheck")?[e,...n.checks??[]]:n.checks??[];for(const o of r)X0[o._zod.def.check]?.(t,o._zod.def);const i=e._zod.bag;i.minimum!==void 0&&fr(t,"minimum",i.minimum),i.exclusiveMinimum!==void 0&&fr(t,"exclusiveMinimum",i.exclusiveMinimum),i.maximum!==void 0&&hr(t,"maximum",i.maximum),i.exclusiveMaximum!==void 0&&hr(t,"exclusiveMaximum",i.exclusiveMaximum),i.multipleOf!==void 0&&Yv(t,i.multipleOf),i.format!==void 0&&(t.format??(t.format=i.format),i.format.includes("int")&&(t.isInt=!0)),i.mime&&Qv(t,i.mime);for(const o of i.patterns??[])Xv(t,o);return t}const Q0={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},eE=new Map([[el,ig],[Ms,og]]),tb=e=>eE.get(e)??e,nb=(e,t,n,r)=>{const i=n;i.type="string";const{minimum:o,maximum:s,format:a,patterns:u,contentEncoding:c,laxFormat:l}=tt(e);if(typeof o=="number"&&(i.minLength=o),typeof s=="number"&&(i.maxLength=s),a&&(i.format=Q0[a]??a,i.format===""&&delete i.format,(a==="time"||l)&&delete i.format),c&&(i.contentEncoding=c),u&&u.size>0){const d=[...u].map(tb);d.length===1?i.pattern=d[0].source:d.length>1&&(i.allOf=[...d.map(f=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:f.source}))])}},rb=(e,t,n,r)=>{const i=n,{minimum:o,maximum:s,multipleOf:a,exclusiveMaximum:u,exclusiveMinimum:c,isInt:l}=tt(e);i.type=l?"integer":"number";const d=typeof c=="number"&&c>=(o??Number.NEGATIVE_INFINITY),f=typeof u=="number"&&u<=(s??Number.POSITIVE_INFINITY),h=t.target==="draft-04"||t.target==="openapi-3.0";if(d?h?(i.minimum=c,i.exclusiveMinimum=!0):i.exclusiveMinimum=c:typeof o=="number"&&(i.minimum=o),f?h?(i.maximum=u,i.exclusiveMaximum=!0):i.exclusiveMaximum=u:typeof s=="number"&&(i.maximum=s),a){const p=new Set;for(const w of a)Number.isFinite(w)&&w!==0?p.add(Math.abs(w)):nt(e,t,i,r,`A multipleOf divisor of ${w} cannot be represented in JSON Schema`);const[m,...y]=p;m!==void 0&&(i.multipleOf=m),y.length&&(i.allOf=[...i.allOf??[],...y.map(w=>({multipleOf:w}))])}},ib=(e,t,n,r)=>{n.type="boolean"},ob=(e,t,n,r)=>{nt(e,t,n,r,"BigInt cannot be represented in JSON Schema")},sb=(e,t,n,r)=>{nt(e,t,n,r,"Symbols cannot be represented in JSON Schema")},ab=(e,t,n,r)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},ub=(e,t,n,r)=>{nt(e,t,n,r,"Undefined cannot be represented in JSON Schema")},cb=(e,t,n,r)=>{nt(e,t,n,r,"Void cannot be represented in JSON Schema")},lb=(e,t,n,r)=>{n.not={}},db=(e,t,n,r)=>{},fb=(e,t,n,r)=>{},hb=(e,t,n,r)=>{nt(e,t,n,r,"Date cannot be represented in JSON Schema")},pb=(e,t,n,r)=>{const i=e._zod.def,o=is(i.entries);if(o.length===0){n.not={};return}o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),n.enum=o},mb=(e,t,n,r)=>{const i=e._zod.def;if(i.values.length===0){n.not={};return}const o=[];for(const s of i.values)if(s===void 0){if(nt(e,t,n,r,"Literal `undefined` cannot be represented in JSON Schema"))return}else if(typeof s=="bigint"){if(nt(e,t,n,r,"BigInt literals cannot be represented in JSON Schema"))return;o.push(Number(s))}else o.push(s);if(o.length!==0)if(o.length===1){const s=o[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else o.every(s=>typeof s=="number")&&(n.type="number"),o.every(s=>typeof s=="string")&&(n.type="string"),o.every(s=>typeof s=="boolean")&&(n.type="boolean"),o.every(s=>s===null)&&(n.type="null"),n.enum=o},gb=(e,t,n,r)=>{nt(e,t,n,r,"NaN cannot be represented in JSON Schema")},yb=(e,t,n,r)=>{const i=n,o=e._zod.pattern;if(!o)throw new Error("Pattern not found in template literal");i.type="string",i.pattern=o.source},vb=(e,t,n,r)=>{const i=n;i.type="string",i.format="binary",i.contentEncoding="binary";const{minimum:o,maximum:s,mime:a}=tt(e);o!==void 0&&(i.minLength=o),s!==void 0&&(i.maxLength=s),a&&(a.length===0?i.not={}:a.length===1?i.contentMediaType=a[0]:i.anyOf=a.map(u=>({contentMediaType:u})))},bb=(e,t,n,r)=>{n.type="boolean"},wb=(e,t,n,r)=>{nt(e,t,n,r,"Custom types cannot be represented in JSON Schema")},_b=(e,t,n,r)=>{nt(e,t,n,r,"Function types cannot be represented in JSON Schema")},kb=(e,t,n,r)=>{nt(e,t,n,r,"Transforms cannot be represented in JSON Schema")},Sb=(e,t,n,r)=>{nt(e,t,n,r,"Map cannot be represented in JSON Schema")},Eb=(e,t,n,r)=>{nt(e,t,n,r,"Set cannot be represented in JSON Schema")},xb=(e,t,n,r)=>{const i=n,o=e._zod.def,{minimum:s,maximum:a}=tt(e);typeof s=="number"&&(i.minItems=s),typeof a=="number"&&(i.maxItems=a),i.type="array",i.items=De(o.element,t,{...r,path:[...r.path,"items"]})};function li(e){const t=e._zod.def;return t.type==="pipe"&&t.in._zod.traits.has("$ZodTransform")?li(t.out):t.type==="catch"?li(t.innerType):e._zod.optin}const $b=(e,t,n,r)=>{const i=n,o=e._zod.def,s=o.shape;if(Object.getOwnPropertySymbols(s).length&&nt(e,t,i,r,"Symbol keys cannot be represented in JSON Schema"))return;i.type="object",i.properties={};for(const c in s)Tt(i.properties,c,De(s[c],t,{...r,path:[...r.path,"properties",c]}));const u=[];for(const c of Object.keys(s)){const l=o.shape[c];(t.io==="input"?li(l)===void 0:l._zod.optout===void 0)&&u.push(c)}u.length>0&&(i.required=u),o.catchall?._zod.def.type==="never"?i.additionalProperties=!1:o.catchall?o.catchall&&(i.additionalProperties=De(o.catchall,t,{...r,path:[...r.path,"additionalProperties"]})):t.io==="output"&&(i.additionalProperties=!1)},ql=(e,t,n,r)=>{const i=e._zod.def,o=i.inclusive===!1,s=i.options.map((a,u)=>De(a,t,{...r,path:[...r.path,o?"oneOf":"anyOf",u]}));o?n.oneOf=s:n.anyOf=s},Tb=(e,t,n,r)=>{const i=e._zod.def,o=De(i.left,t,{...r,path:[...r.path,"allOf",0]}),s=De(i.right,t,{...r,path:[...r.path,"allOf",1]}),a=c=>"allOf"in c&&Object.keys(c).length===1,u=[...a(o)?o.allOf:[o],...a(s)?s.allOf:[s]];n.allOf=u,t.intersections.push(u)},Cb=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="array";const s=t.target==="draft-2020-12"?"prefixItems":"items",a=t.target==="draft-2020-12"||t.target==="openapi-3.0"?"items":"additionalItems",u=o.items.map((m,y)=>De(m,t,{...r,path:[...r.path,s,y]})),c=o.rest?De(o.rest,t,{...r,path:[...r.path,a,...t.target==="openapi-3.0"?[o.items.length]:[]]}):null;let l=o.items.length;for(;l>0;){const m=o.items[l-1];if(!(t.io==="input"?li(m)!==void 0:m._zod.optout==="optional"))break;l--}const d=o.items.length,f=!o.rest;t.target==="draft-2020-12"?(i.prefixItems=u,f?i.items=!1:c&&(i.items=c),l>0&&(i.minItems=l),f&&(i.maxItems=d)):t.target==="openapi-3.0"?(i.items={anyOf:u},c&&i.items.anyOf.push(c),l>0&&(i.minItems=l),f&&(i.maxItems=d)):(i.items=u,f?i.additionalItems=!1:c&&(i.additionalItems=c),l>0&&(i.minItems=l),f&&(i.maxItems=d));const{minimum:h,maximum:p}=tt(e);typeof h=="number"&&(i.minItems=h),typeof p=="number"&&(i.maxItems=p)};function Bu(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);const p=e.get(t)?.def;if(!p)return t;const m=Bu(e,p,n);return m===p?t:m}for(const p of["anyOf","oneOf"]){const m=t[p];if(!Array.isArray(m))continue;const y=m.map(w=>Bu(e,w,n));y.some((w,g)=>w!==m[g])&&(t={...t,[p]:y})}const r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes("string")&&r.some(p=>p==="number"||p==="integer"),o=t.enum??(t.const!==void 0?[t.const]:void 0);if(!i&&!o?.some(p=>typeof p=="number"))return t;const{minimum:s,maximum:a,exclusiveMinimum:u,exclusiveMaximum:c,multipleOf:l,format:d,id:f,...h}=t;return h.enum?h.enum=h.enum.map(p=>typeof p=="number"?String(p):p):typeof h.const=="number"&&(h.const=String(h.const)),i&&(h.type="string",o||(h.pattern=(r.includes("number")?wr:Gc).source)),h}const Hu=new WeakMap;function tE(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 Hu.get(e)??[]){const i=e.seen.get(r),o=(i?.def??i?.schema)?.propertyNames;if(!o||o===!0||n.has(o))continue;const s=Bu(t,o,new Set);s!==o&&n.set(o,s)}if(n.size)for(const r of e.seen.values())for(const i of[r.schema,r.def]){const o=i&&n.get(i.propertyNames);o&&(i.propertyNames=o)}}const Ab=(e,t,n,r)=>{const i=n,o=e._zod.def;i.type="object";const s=o.keyType,a=tt(s).patterns;if(o.mode==="loose"&&a&&a.size>0){const l=De(o.valueType,t,{...r,path:[...r.path,"patternProperties","*"]});i.patternProperties={};for(const d of a)Tt(i.patternProperties,tb(d).source,l)}else{if(t.target==="draft-07"||t.target==="draft-2020-12"){i.propertyNames=De(o.keyType,t,{...r,path:[...r.path,"propertyNames"]});let l=Hu.get(t);l||(l=[],Hu.set(t,l),t.deferred.push(()=>tE(t))),l.push(e)}i.additionalProperties=De(o.valueType,t,{...r,path:[...r.path,"additionalProperties"]})}const u=s._zod.values,c=t.io==="input"&&li(o.valueType)!==void 0;if(u&&!o.partial&&!c){const l=[...u].filter(d=>typeof d=="string"||typeof d=="number");l.length>0&&(i.required=l.map(String))}},Ib=(e,t,n,r)=>{const i=e._zod.def,o=De(i.innerType,t,r),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=i.innerType,n.nullable=!0):n.anyOf=[o,{type:"null"}]},Nb=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Wl=Symbol();function Rb(e,t,n,r,i){let o=!1;const s=JSON.stringify(e,(a,u)=>typeof u!="bigint"?u:(o=!0,null));return o?(nt(t,n,r,i,"BigInt defaults cannot be represented in JSON Schema"),Wl):JSON.parse(s)}const Lb=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;const s=Rb(i.defaultValue,e,t,n,r);s!==Wl&&(n.default=s)},zb=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);if(o.ref=i.innerType,t.io!=="input")return;const s=Rb(i.defaultValue,e,t,n,r);s!==Wl&&(n._prefault=s)},Pb=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType;let s;try{s=i.catchValue(void 0)}catch{nt(e,t,n,r,"Dynamic catch values are not supported in JSON Schema");return}n.default=s},Ob=(e,t,n,r)=>{const i=e._zod.def,o=i.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?o?i.out:i.in:i.out;De(s,t,r);const a=t.seen.get(e);a.ref=s},Db=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType,n.readOnly=!0},Mb=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Kl=(e,t,n,r)=>{const i=e._zod.def;De(i.innerType,t,r);const o=t.seen.get(e);o.ref=i.innerType},Fb=(e,t,n,r)=>{const i=e._zod.innerType;De(i,t,r);const o=t.seen.get(e);o.ref=i},Vu={string:nb,number:rb,boolean:ib,bigint:ob,symbol:sb,null:ab,undefined:ub,void:cb,never:lb,any:db,unknown:fb,date:hb,enum:pb,literal:mb,nan:gb,template_literal:yb,file:vb,success:bb,custom:wb,function:_b,transform:kb,map:Sb,set:Eb,array:xb,object:$b,union:ql,intersection:Tb,tuple:Cb,record:Ab,nullable:Ib,nonoptional:Nb,default:Lb,prefault:zb,catch:Pb,pipe:Ob,readonly:Db,promise:Mb,optional:Kl,lazy:Fb};function Jl(e,t){if("_idmap"in e){const r=e,i=cr({...t,processors:Vu}),o={};for(const u of r._idmap.entries()){const[c,l]=u;De(l,i)}const s={},a={registry:r,uri:t?.uri,defs:o};i.external=a;for(const u of r._idmap.entries()){const[c,l]=u;lr(i,l),Tt(s,c,dr(i,l))}if(Object.keys(o).length>0){const u=i.target==="draft-2020-12"?"$defs":"definitions";s.__shared={[u]:o}}return{schemas:s}}const n=cr({...t,processors:Vu});return De(e,n),lr(n,e),dr(n,e)}class nE{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=cr({processors:Vu,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 De(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,lr(this.ctx,t);const r=dr(this.ctx,t),{"~standard":i,...o}=r;return o}}const rE=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"})),Ub=Object.freeze(Object.defineProperty({__proto__:null,$ZodAny:Sy,$ZodArray:Cy,$ZodAsyncError:an,$ZodBase64:dy,$ZodBase64URL:fy,$ZodBigInt:al,$ZodBigIntFormat:by,$ZodBoolean:sl,$ZodCIDRv4:cy,$ZodCIDRv6:ly,$ZodCUID:Yg,$ZodCUID2:Xg,$ZodCatch:Jy,$ZodCheck:Ze,$ZodCheckBigIntFormat:xg,$ZodCheckEndsWith:Dg,$ZodCheckGreaterThan:Hc,$ZodCheckIncludes:Pg,$ZodCheckLengthEquals:Ng,$ZodCheckLessThan:Bc,$ZodCheckLowerCase:Lg,$ZodCheckMaxLength:Ag,$ZodCheckMaxSize:$g,$ZodCheckMimeType:Ug,$ZodCheckMinLength:Ig,$ZodCheckMinSize:Tg,$ZodCheckMultipleOf:Sg,$ZodCheckNumberFormat:Eg,$ZodCheckOverwrite:Gg,$ZodCheckProperties:Fg,$ZodCheckProperty:Mg,$ZodCheckRegex:Rg,$ZodCheckSizeEquals:Cg,$ZodCheckStartsWith:Og,$ZodCheckStringFormat:Ai,$ZodCheckUpperCase:zg,$ZodCodec:fl,$ZodCreditCard:py,$ZodCustom:rv,$ZodCustomStringFormat:yy,$ZodCyclicError:iv,$ZodDate:Ty,$ZodDefault:Vy,$ZodDiscriminatedUnion:Py,$ZodE164:hy,$ZodEmail:Vg,$ZodEmoji:Kg,$ZodEncodeError:As,$ZodEnum:Uy,$ZodError:Dm,$ZodExactOptional:By,$ZodFile:jy,$ZodFunction:tv,$ZodGUID:Bg,$ZodIBAN:my,$ZodIPv4:sy,$ZodIPv6:ay,$ZodISODate:ry,$ZodISODateTime:ny,$ZodISODuration:oy,$ZodISOTime:iy,$ZodIntersection:Oy,$ZodJWT:gy,$ZodKSUID:ty,$ZodLazy:hl,$ZodLiteral:Gy,$ZodMAC:uy,$ZodMap:My,$ZodNaN:Yy,$ZodNanoID:Jg,$ZodNever:xy,$ZodNonOptional:Wy,$ZodNull:ky,$ZodNullable:Hy,$ZodNumber:ol,$ZodNumberFormat:vy,$ZodObject:Ny,$ZodObjectJIT:Ry,$ZodOptional:ll,$ZodPipe:dl,$ZodPrefault:qy,$ZodPreprocess:Xy,$ZodPromise:nv,$ZodReadonly:Qy,$ZodRealError:Ct,$ZodRecord:Dy,$ZodRegistry:av,$ZodSet:Fy,$ZodString:Ii,$ZodStringFormat:Fe,$ZodSuccess:Ky,$ZodSymbol:wy,$ZodTemplateLiteral:ev,$ZodTransform:Zy,$ZodTuple:cl,$ZodType:me,$ZodULID:Qg,$ZodURL:Wg,$ZodUUID:Hg,$ZodUndefined:_y,$ZodUnion:Fs,$ZodUnknown:Ey,$ZodVoid:$y,$ZodXID:ey,$ZodXor:Ly,$brand:Tc,$constructor:S,$input:vl,$output:yl,Doc:Vc,INVALID:bt,JSONSchema:rE,JSONSchemaGenerator:nE,NEVER:$c,TimePrecision:jl,URL_BAD_FORMAT:Wc,URL_UNPARSEABLE:ai,ZodCompileAsyncError:hn,ZodCompileUnsupportedError:Ce,_any:Rv,_array:Fv,_base64:Ml,_base64url:Fl,_bigint:xv,_boolean:Sv,_catch:H0,_check:Bv,_cidrv4:Ol,_cidrv6:Dl,_coercedBigint:$v,_coercedBoolean:Ev,_coercedDate:Dv,_coercedNumber:yv,_coercedString:fv,_creditCard:pv,_cuid:Al,_cuid2:Il,_custom:Gv,_date:Ov,_decode:Nc,_decodeAsync:Lc,_default:j0,_discriminatedUnion:I0,_e164:Ul,_email:_l,_emoji:Tl,_encode:Ic,_encodeAsync:Rc,_endsWith:Oi,_enum:O0,_file:Uv,_float32:bv,_float64:wv,_gt:mn,_gte:$t,_guid:kl,_iban:mv,_includes:zi,_int:vv,_int32:_v,_int64:Tv,_intersection:N0,_ipv4:zl,_ipv6:Pl,_isoDate:Bl,_isoDateTime:Zl,_isoDuration:Vl,_isoTime:Hl,_jwt:Gl,_ksuid:Ll,_lazy:K0,_length:Sr,_literal:M0,_lowercase:Ri,_lt:pn,_lte:xt,_mac:hv,_map:z0,_max:xt,_maxLength:kr,_maxSize:Yn,_mime:Mi,_min:$t,_minLength:An,_minSize:gn,_multipleOf:qn,_nan:Mv,_nanoid:Cl,_nativeEnum:D0,_negative:qs,_never:zv,_nonnegative:Ks,_nonoptional:Z0,_nonpositive:Ws,_normalize:Fi,_null:Nv,_nullable:G0,_number:gv,_optional:U0,_overwrite:tn,_parse:Si,_parseAsync:Ei,_pipe:V0,_positive:Vs,_promise:J0,_properties:Di,_property:Js,_readonly:q0,_record:L0,_refine:jv,_regex:Ni,_safeDecode:Pc,_safeDecodeAsync:Dc,_safeEncode:zc,_safeEncodeAsync:Oc,_safeParse:xi,_safeParseAsync:$i,_set:P0,_size:_r,_slugify:Zi,_startsWith:Pi,_string:dv,_stringFormat:Er,_stringbool:qv,_success:B0,_superRefine:Zv,_symbol:Av,_templateLiteral:W0,_toLowerCase:Gi,_toUpperCase:ji,_transform:F0,_trim:Ui,_tuple:R0,_uint32:kv,_uint64:Cv,_ulid:Nl,_undefined:Iv,_union:C0,_unknown:Lv,_uppercase:Li,_url:Hs,_uuid:Sl,_uuidv4:El,_uuidv6:xl,_uuidv7:$l,_void:Pv,_xid:Rl,_xor:A0,base64Charset:el,base64urlCharset:Ms,canParseURL:Kc,clone:je,compile:bl,compileFn:Zs,config:et,createStandardJSONSchemaMethod:ci,createToJSONSchemaMethod:Jv,decode:Uk,decodeAsync:jk,describe:Hv,encode:Fk,encodeAsync:Gk,extractDefs:lr,finalize:dr,flattenError:Is,formatError:Ns,getDiscriminatedOption:ul,globalConfig:vt,globalRegistry:St,handleUnrepresentable:nt,initializeContext:cr,isBackEdge:ml,isRecursiveSchema:pl,isValidBase64:Ds,isValidBase64URL:tl,isValidCIDRv6:Qc,isValidCreditCard:nl,isValidIBAN:rl,isValidIPv6:Os,isValidJWT:il,locales:gl,memoizer:Us,mergeValues:ui,meta:Vv,parse:Ou,parseAsync:Du,parseURLObject:qg,prettifyError:Ac,process:De,processSchema:De,regexes:Ps,registry:Gs,safeDecode:Bk,safeDecodeAsync:Vk,safeEncode:Zk,safeEncodeAsync:Hk,safeParse:Fm,safeParseAsync:Pk,standardProps:qc,stripTabAndNewline:cs,toDotPath:Mm,toJSONSchema:Jl,toZod:Ss,treeifyError:Cc,urlHostnameOk:Yc,urlProtocolOk:Xc,util:xc,validate:Ls,validateAsync:zs,validateURL:Jc,version:jg,withParser:js},Symbol.toStringTag,{value:"Module"})),Bh=Symbol("z.visit/resolving");function Yl(e,t){const n=typeof t=="function"?t:(s,a)=>{const u=t[s._zod.def.type];return u?u(s,a):s},r=new Map;function i(s){const a=r.get(s);if(a===Bh)return new hl({type:"lazy",getter:()=>r.get(s)});if(a!==void 0)return a;r.set(s,Bh);const u=o(s),c=n(u,u!==s);return r.set(s,c),c}function o(s){const a=s._zod.def;switch(a.type){case"object":{const c=a.shape,l=Object.keys(c);let d=!1;const f={};for(const p of l){const m=i(c[p]);m!==c[p]&&(d=!0),f[p]=m}let h=a.catchall;return a.catchall&&(h=i(a.catchall),h!==a.catchall&&(d=!0)),d?je(s,{...a,shape:f,catchall:h}):s}case"array":{const c=i(a.element);return c===a.element?s:je(s,{...a,element:c})}case"tuple":{const c=a.items;let l=!1;const d=[];for(const h of c){const p=i(h);p!==h&&(l=!0),d.push(p)}let f=a.rest;return a.rest&&(f=i(a.rest),f!==a.rest&&(l=!0)),l?je(s,{...a,items:d,rest:f}):s}case"record":case"map":{const c=i(a.keyType),l=i(a.valueType);return c===a.keyType&&l===a.valueType?s:je(s,{...a,keyType:c,valueType:l})}case"set":{const c=i(a.valueType);return c===a.valueType?s:je(s,{...a,valueType:c})}case"union":{const c=a.options;let l=!1;const d=[];for(const f of c){const h=i(f);h!==f&&(l=!0),d.push(h)}return l?je(s,{...a,options:d}):s}case"intersection":{const c=i(a.left),l=i(a.right);return c===a.left&&l===a.right?s:je(s,{...a,left:c,right:l})}case"optional":case"nullable":case"default":case"prefault":case"catch":case"readonly":case"nonoptional":case"promise":case"success":{const c=i(a.innerType);return c===a.innerType?s:je(s,{...a,innerType:c})}case"pipe":{const c=i(a.in),l=i(a.out);return c===a.in&&l===a.out?s:je(s,{...a,in:c,out:l})}case"function":{const c=i(a.input),l=i(a.output);return c===a.input&&l===a.output?s:je(s,{...a,input:c,output:l})}case"lazy":{const c=a.getter,{_cachedInner:l,...d}=a;return je(s,{...d,getter:()=>i(c())})}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 i(e)}function Xl(e){return!!e._zod}function Gb(e,t){return Xl(e)?Fm(e,t):e.safeParse(t)}function iE(e){if(!e)return;let t;if(Xl(e)?t=e._zod?.def?.shape:t=e.shape,!!t){if(typeof t=="function")try{return t()}catch{return}return t}}function oE(e){if(Xl(e)){const o=e._zod?.def;if(o){if(o.value!==void 0)return o.value;if(Array.isArray(o.values)&&o.values.length>0)return o.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 sE=()=>{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(o){return e[o]??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 i(o,s){return o==="number"&&typeof s=="number"&&!Number.isFinite(s)?String(s):r[o]??o}return o=>{switch(o.code){case"invalid_type":{const s=i(o.expected),a=Nm(o.input),u=i(a,o.input);return`Invalid input: expected ${s}, received ${u}`}case"invalid_value":return o.values.length===1?`Invalid input: expected ${wc(o.values[0])}`:`Invalid option: expected one of ${Lu(o.values,"|")}`;case"too_big":{const s=o.exact?"exactly ":o.inclusive?"<=":"<",a=t(o.origin);return a?`Too big: expected ${o.origin??"value"} to have ${s}${o.maximum.toString()} ${a.unit??"elements"}`:`Too big: expected ${o.origin??"value"} to be ${s}${o.maximum.toString()}`}case"too_small":{const s=o.exact?"exactly ":o.inclusive?">=":">",a=t(o.origin);return a?`Too small: expected ${o.origin} to have ${s}${o.minimum.toString()} ${a.unit}`:`Too small: expected ${o.origin} to be ${s}${o.minimum.toString()}`}case"invalid_format":{const s=o;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]??o.format}`}case"not_multiple_of":return`Invalid number: must be a multiple of ${o.divisor}`;case"unrecognized_keys":return`Unrecognized key${o.keys.length>1?"s":""}: ${Lu(o.keys,", ")}`;case"invalid_key":return`Invalid key in ${o.origin}`;case"invalid_union":return o.options&&Array.isArray(o.options)&&o.options.length>0?`Invalid discriminator value. Expected ${o.options.map(a=>`'${a}'`).join(" | ")}`:o.inclusive===!1?"Invalid input: more than one option matched":"Invalid input";case"invalid_element":return`Invalid value in ${o.origin}`;default:return"Invalid input"}}};function aE(){return{localeError:sE()}}const uE=Object.freeze(Object.defineProperty({__proto__:null,endsWith:Oi,gt:mn,gte:$t,includes:zi,length:Sr,lowercase:Ri,lt:pn,lte:xt,maxLength:kr,maxSize:Yn,mime:Mi,minLength:An,minSize:gn,multipleOf:qn,negative:qs,nonnegative:Ks,nonpositive:Ws,normalize:Fi,overwrite:tn,positive:Vs,properties:Di,property:Js,regex:Ni,size:_r,slugify:Zi,startsWith:Pi,toLowerCase:Gi,toUpperCase:ji,trim:Ui,uppercase:Li},Symbol.toStringTag,{value:"Module"})),Hh=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 jb=(e,t)=>{Dm.init(e,t),e.name="ZodError";const n=Object.getPrototypeOf(e);Hh.has(n)||(Hh.add(n),Oo(n,"format",r=>i=>Ns(r,i)),Oo(n,"flatten",r=>i=>Is(r,i)),Oo(n,"addIssue",r=>i=>{r.issues.push(i),r.message=JSON.stringify(r.issues,os,2)}),Oo(n,"addIssues",r=>i=>{r.issues.push(...i),r.message=JSON.stringify(r.issues,os,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},Zb=S("ZodError",jb),_t=S("ZodError",jb,void 0,{Parent:Error}),Ql=Si(_t),ed=Ei(_t),td=xi(_t),nd=$i(_t),rd=Ic(_t),id=Nc(_t),od=Rc(_t),sd=Lc(_t),ad=zc(_t),ud=Pc(_t),cd=Oc(_t),ld=Dc(_t);function cE(){vt.localeError||et(aE())}function Xn(){vt.memoizer||et({memoizer:Us()})}const ye=S("ZodType",(e,t)=>(cE(),me.init(e,t),e.def=t,e.type=t.type,e),{check(...e){const t=this.def;return this.clone(lt(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 je(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Ma(e,t))},superRefine(e,t){return this.check(Fa(e,t))},overwrite(e){return this.check(tn(e))},optional(){return Ue(this)},exactOptional(){return va(this)},nullable(){return mr(this)},nullish(){return Ue(mr(this))},nonoptional(e){return Ea(this,e)},array(){return ae(this)},or(e){return ke([this,e])},and(e){return Or(this,e)},transform(e){return fi(this,po(e))},default(e){return _a(this,e)},prefault(e){return Sa(this,e)},catch(e){return Ta(this,e)},pipe(e){return fi(this,e)},readonly(){return Na(this)},describe(e){const t=this.clone();return St.add(t,{description:e}),t},meta(...e){if(e.length===0)return St.get(this);const t=this.clone();return St.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 Cs(this,"~standard",{...qc(this),jsonSchema:{input:ci(this,"input"),output:ci(this,"output")}})},set"~standard"(e){fn(this,"~standard",e)},parse:function e(t,n){return Ql(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await ed(this,t,n,{callee:e})},safeParse(e,t){return td(this,e,t)},async safeParseAsync(e,t){return nd(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){fn(this,"spa",e)},validate(e,t){return Ls(this,e,t)},validateAsync(e,t){return zs(this,e,t)},encode:function e(t,n){return rd(this,t,n,{callee:e})},decode:function e(t,n){return id(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await od(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await sd(this,t,n,{callee:e})},safeEncode(e,t){return ad(this,e,t)},safeDecode(e,t){return ud(this,e,t)},async safeEncodeAsync(e,t){return cd(this,e,t)},async safeDecodeAsync(e,t){return ld(this,e,t)},toJSONSchema(e){return Jv(this,{})(e)},get description(){return St.get(this)?.description},get _def(){return this._zod.def}}),Bi=S("_ZodString",(e,t)=>{Ii.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>nb(e,n,r)},ki({format:e=>tt(e).format??null,minLength:e=>tt(e).minimum??null,maxLength:e=>tt(e).maximum??null},{regex(...e){return this.check(Ni(...e))},includes(...e){return this.check(zi(...e))},startsWith(...e){return this.check(Pi(...e))},endsWith(...e){return this.check(Oi(...e))},min(...e){return this.check(An(...e))},max(...e){return this.check(kr(...e))},length(...e){return this.check(Sr(...e))},nonempty(...e){return this.check(An(1,...e))},lowercase(e){return this.check(Ri(e))},uppercase(e){return this.check(Li(e))},trim(){return this.check(Ui())},normalize(...e){return this.check(Fi(...e))},toLowerCase(){return this.check(Gi())},toUpperCase(){return this.check(ji())},slugify(){return this.check(Zi())}})),xr=S("ZodString",(e,t)=>{Ii.init(e,t),Bi.init(e,t)},{email(e){return this.check(_l(Hi,e))},url(e){return this.check(Hs(Ir,e))},jwt(e){return this.check(Gl(ao,e))},emoji(e){return this.check(Tl(qi,e))},guid(e){return this.check(kl(Vi,e))},uuid(e){return this.check(Sl(Wt,e))},uuidv4(e){return this.check(El(Wt,e))},uuidv6(e){return this.check(xl(Wt,e))},uuidv7(e){return this.check($l(Wt,e))},nanoid(e){return this.check(Cl(Wi,e))},cuid(e){return this.check(Al(Ki,e))},cuid2(e){return this.check(Il(Ji,e))},ulid(e){return this.check(Nl(Yi,e))},base64(e){return this.check(Ml(io,e))},base64url(e){return this.check(Fl(oo,e))},xid(e){return this.check(Rl(Xi,e))},ksuid(e){return this.check(Ll(Qi,e))},ipv4(e){return this.check(zl(eo,e))},ipv6(e){return this.check(Pl(to,e))},cidrv4(e){return this.check(Ol(no,e))},cidrv6(e){return this.check(Dl(ro,e))},e164(e){return this.check(Ul(so,e))},datetime(e){return this.check(Zl($r,e))},date(e){return this.check(Bl(Tr,e))},time(e){return this.check(Hl(Cr,e))},duration(e){return this.check(Vl(Ar,e))}});function E(e){return dv(xr,e)}const Oe=S("ZodStringFormat",(e,t)=>{Fe.init(e,t),Bi.init(e,t)}),$r=S("ZodISODateTime",(e,t)=>{ny.init(e,t),Oe.init(e,t)}),Tr=S("ZodISODate",(e,t)=>{ry.init(e,t),Oe.init(e,t)}),Cr=S("ZodISOTime",(e,t)=>{iy.init(e,t),Oe.init(e,t)}),Ar=S("ZodISODuration",(e,t)=>{oy.init(e,t),Oe.init(e,t)}),Hi=S("ZodEmail",(e,t)=>{Vg.init(e,t),Oe.init(e,t)});function dd(e){return _l(Hi,e)}const Vi=S("ZodGUID",(e,t)=>{Bg.init(e,t),Oe.init(e,t)});function fd(e){return kl(Vi,e)}const Wt=S("ZodUUID",(e,t)=>{Hg.init(e,t),Oe.init(e,t)});function hd(e){return Sl(Wt,e)}function pd(e){return El(Wt,e)}function md(e){return xl(Wt,e)}function gd(e){return $l(Wt,e)}const Ir=S("ZodURL",(e,t)=>{Wg.init(e,t),Oe.init(e,t)});function yd(e){return Hs(Ir,e)}function vd(e){return Hs(Ir,{protocol:Mc,hostname:ag,...N(e)})}const qi=S("ZodEmoji",(e,t)=>{Kg.init(e,t),Oe.init(e,t)});function bd(e){return Tl(qi,e)}const Wi=S("ZodNanoID",(e,t)=>{Jg.init(e,t),Oe.init(e,t)});function wd(e){return Cl(Wi,e)}const Ki=S("ZodCUID",(e,t)=>{Yg.init(e,t),Oe.init(e,t)});function _d(e){return Al(Ki,e)}const Ji=S("ZodCUID2",(e,t)=>{Xg.init(e,t),Oe.init(e,t)});function kd(e){return Il(Ji,e)}const Yi=S("ZodULID",(e,t)=>{Qg.init(e,t),Oe.init(e,t)});function Sd(e){return Nl(Yi,e)}const Xi=S("ZodXID",(e,t)=>{ey.init(e,t),Oe.init(e,t)});function Ed(e){return Rl(Xi,e)}const Qi=S("ZodKSUID",(e,t)=>{ty.init(e,t),Oe.init(e,t)});function xd(e){return Ll(Qi,e)}const eo=S("ZodIPv4",(e,t)=>{sy.init(e,t),Oe.init(e,t)});function $d(e){return zl(eo,e)}const Ys=S("ZodMAC",(e,t)=>{uy.init(e,t),Oe.init(e,t)});function Td(e){return hv(Ys,e)}const to=S("ZodIPv6",(e,t)=>{ay.init(e,t),Oe.init(e,t)});function Cd(e){return Pl(to,e)}const no=S("ZodCIDRv4",(e,t)=>{cy.init(e,t),Oe.init(e,t)});function Ad(e){return Ol(no,e)}const ro=S("ZodCIDRv6",(e,t)=>{ly.init(e,t),Oe.init(e,t)});function Id(e){return Dl(ro,e)}const io=S("ZodBase64",(e,t)=>{dy.init(e,t),Oe.init(e,t)});function Nd(e){return Ml(io,e)}const oo=S("ZodBase64URL",(e,t)=>{fy.init(e,t),Oe.init(e,t)});function Rd(e){return Fl(oo,e)}const so=S("ZodE164",(e,t)=>{hy.init(e,t),Oe.init(e,t)});function Ld(e){return Ul(so,e)}const Xs=S("ZodCreditCard",(e,t)=>{py.init(e,t),Oe.init(e,t)});function zd(e){return pv(Xs,e)}const Qs=S("ZodIBAN",(e,t)=>{my.init(e,t),Oe.init(e,t)});function Pd(e){return mv(Qs,e)}const ao=S("ZodJWT",(e,t)=>{gy.init(e,t),Oe.init(e,t)});function Od(e){return Gl(ao,e)}const In=S("ZodCustomStringFormat",(e,t)=>{yy.init(e,t),Oe.init(e,t)});function Dd(e,t,n={}){return Er(In,e,t,n)}function Md(e){return Er(In,"hostname",sg,e)}function Fd(e){return Er(In,"hex",kg,e)}function Ud(e){return Er(In,"currency_code",cg,e)}function Gd(e,t){const n=t?.enc??"hex",r=`${e}_${n}`,i=Ps[r];if(!i)throw new Error(`Unrecognized hash format: ${r}`);return Er(In,r,i,t)}const Nr=S("ZodNumber",(e,t)=>{ol.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>rb(e,n,r,i),e.isFinite=!0},ki({minValue:e=>{const{minimum:t,exclusiveMinimum:n}=tt(e);return Math.max(t??Number.NEGATIVE_INFINITY,n??Number.NEGATIVE_INFINITY)},maxValue:e=>{const{maximum:t,exclusiveMaximum:n}=tt(e);return Math.min(t??Number.POSITIVE_INFINITY,n??Number.POSITIVE_INFINITY)},isInt:e=>{const{isInt:t,multipleOf:n}=tt(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>tt(e).format??null},{gt(e,t){return this.check(mn(e,t))},gte(e,t){return this.check($t(e,t))},min(e,t){return this.check($t(e,t))},lt(e,t){return this.check(pn(e,t))},lte(e,t){return this.check(xt(e,t))},max(e,t){return this.check(xt(e,t))},int(e){return this.check(di(e))},safe(e){return this.check(di(e))},positive(e){return this.check(mn(0,e))},nonnegative(e){return this.check($t(0,e))},negative(e){return this.check(pn(0,e))},nonpositive(e){return this.check(xt(0,e))},multipleOf(e,t){return this.check(qn(e,t))},step(e,t){return this.check(qn(e,t))},finite(){return this}}));function ge(e){return gv(Nr,e)}const Nn=S("ZodNumberFormat",(e,t)=>{vy.init(e,t),Nr.init(e,t)});function di(e){return vv(Nn,e)}function jd(e){return bv(Nn,e)}function Zd(e){return wv(Nn,e)}function Bd(e){return _v(Nn,e)}function Hd(e){return kv(Nn,e)}const Rr=S("ZodBoolean",(e,t)=>{sl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ib(e,n,r)});function Pe(e){return Sv(Rr,e)}const Lr=S("ZodBigInt",(e,t)=>{al.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ob(e,n,r,i)},ki({minValue:e=>tt(e).minimum??null,maxValue:e=>tt(e).maximum??null,format:e=>tt(e).format??null},{gte(e,t){return this.check($t(e,t))},min(e,t){return this.check($t(e,t))},gt(e,t){return this.check(mn(e,t))},lt(e,t){return this.check(pn(e,t))},lte(e,t){return this.check(xt(e,t))},max(e,t){return this.check(xt(e,t))},positive(e){return this.check(mn(BigInt(0),e))},negative(e){return this.check(pn(BigInt(0),e))},nonpositive(e){return this.check(xt(BigInt(0),e))},nonnegative(e){return this.check($t(BigInt(0),e))},multipleOf(e,t){return this.check(qn(e,t))}}));function Vd(e){return xv(Lr,e)}const uo=S("ZodBigIntFormat",(e,t)=>{by.init(e,t),Lr.init(e,t)});function qd(e){return Tv(uo,e)}function Wd(e){return Cv(uo,e)}const ea=S("ZodSymbol",(e,t)=>{wy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>sb(e,n,r,i)});function Kd(e){return Av(ea,e)}const ta=S("ZodUndefined",(e,t)=>{_y.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ub(e,n,r,i)});function pr(e){return Iv(ta,e)}const na=S("ZodNull",(e,t)=>{ky.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ab(e,n,r)});function co(e){return Nv(na,e)}const ra=S("ZodAny",(e,t)=>{Sy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>db()});function lo(){return Rv(ra)}const ia=S("ZodUnknown",(e,t)=>{Ey.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>fb()});function Le(){return Lv(ia)}const oa=S("ZodNever",(e,t)=>{xy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>lb(e,n,r)});function Wn(e){return zv(oa,e)}const sa=S("ZodVoid",(e,t)=>{$y.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>cb(e,n,r,i)});function Jd(e){return Pv(sa,e)}const fo=S("ZodDate",(e,t)=>{Ty.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>hb(e,n,r,i),e.min=(n,r)=>e.check($t(n,r)),e.max=(n,r)=>e.check(xt(n,r))},ki({minDate:e=>{const{minimum:t}=tt(e);return t?new Date(t):null},maxDate:e=>{const{maximum:t}=tt(e);return t?new Date(t):null}},{}));function Yd(e){return Ov(fo,e)}const aa=S("ZodArray",(e,t)=>{Xn(),Cy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>xb(e,n,r,i),e.element=t.element},{min(e,t){return this.check(An(e,t))},nonempty(e){return this.check(An(1,e))},max(e,t){return this.check(kr(e,t))},length(e,t){return this.check(Sr(e,t))},unwrap(){return this.element}});function ae(e,t){return Fv(aa,e,t)}function Xd(e){const t=e._zod.def.shape;return at(Object.keys(t))}const zr=S("ZodObject",(e,t)=>{Xn(),Ry.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>$b(e,n,r,i),Pm(e,"shape",n=>n._zod.def.shape,!1)},{keyof(){return at(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(lt(this._zod.def,{catchall:e}))},passthrough(){return this.clone(lt(this._zod.def,{catchall:Le()}))},loose(){return this.clone(lt(this._zod.def,{catchall:Le()}))},strict(){return this.clone(lt(this._zod.def,{catchall:Wn()}))},strip(){return this.clone(lt(this._zod.def,{catchall:void 0}))},extend(e){return xm(this,e)},safeExtend(e){return Tm(this,e)},merge(e){return Cm(this,e)},pick(e){return Sm(this,e)},omit(e){return Em(this,e)},partial(...e){return zu(Dr,this,e[0])},exactPartial(...e){return zu(mo,this,e[0],"exactPartial")},required(...e){return Am(go,this,e[0])}});function T(e,t){const n={type:"object",shape:e??{},...N(t)};return new zr(n)}function Qd(e,t){return new zr({type:"object",shape:e,catchall:Wn(),...N(t)})}function st(e,t){return new zr({type:"object",shape:e,catchall:Le(),...N(t)})}const Pr=S("ZodUnion",(e,t)=>{Fs.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ql(e,n,r,i),e.options=t.options});function ke(e,t){return new Pr({type:"union",options:e,...N(t)})}const ua=S("ZodXor",(e,t)=>{Pr.init(e,t),Ly.init(e,t),e._zod.processJSONSchema=(n,r,i)=>ql(e,n,r,i),e.options=t.options});function ef(e,t){return new ua({type:"union",options:e,inclusive:!1,...N(t)})}const ca=S("ZodDiscriminatedUnion",(e,t)=>{Pr.init(e,t),Py.init(e,t)});function ho(e,t,n){return new ca({type:"union",options:t,discriminator:e,...N(n)})}const la=S("ZodIntersection",(e,t)=>{Oy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Tb(e,n,r,i)});function Or(e,t){return new la({type:"intersection",left:e,right:t})}const da=S("ZodTuple",(e,t)=>{Xn(),cl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Cb(e,n,r,i)},{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 Dr({type:"optional",innerType:t}))})}});function fa(e,t,n){const r=t instanceof me,i=r?n:t,o=r?t:null;return new da({type:"tuple",items:e,rest:o,...N(i)})}const Kn=S("ZodRecord",(e,t)=>{Xn(),Dy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ab(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType});function Ee(e,t,n){return!t||!t._zod?new Kn({type:"record",keyType:E(),valueType:e,...N(t)}):new Kn({type:"record",keyType:e,valueType:t,...N(n)})}function tf(e,t,n){return new Kn({type:"record",keyType:e,valueType:t,...N(n),partial:!0})}function nf(e,t,n){return new Kn({type:"record",keyType:e,valueType:t,mode:"loose",...N(n)})}const ha=S("ZodMap",(e,t)=>{Xn(),My.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Sb(e,n,r,i),e.keyType=t.keyType,e.valueType=t.valueType,e.min=(...n)=>e.check(gn(...n)),e.nonempty=n=>e.check(gn(1,n)),e.max=(...n)=>e.check(Yn(...n)),e.size=(...n)=>e.check(_r(...n))});function rf(e,t,n){return new ha({type:"map",keyType:e,valueType:t,...N(n)})}const pa=S("ZodSet",(e,t)=>{Xn(),Fy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Eb(e,n,r,i),e.min=(...n)=>e.check(gn(...n)),e.nonempty=n=>e.check(gn(1,n)),e.max=(...n)=>e.check(Yn(...n)),e.size=(...n)=>e.check(_r(...n))});function of(e,t){return new pa({type:"set",valueType:e,...N(t)})}const Jn=S("ZodEnum",(e,t)=>{Uy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(r,i,o)=>pb(e,r,i),e.enum=t.entries,e.options=[...e._zod.values];const n=new Set(Object.keys(t.entries));e.extract=(r,i)=>{const o={};for(const s of r)if(n.has(s))o[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new Jn({...t,checks:[],...N(i),entries:o})},e.exclude=(r,i)=>{const o={...t.entries};for(const s of r)if(n.has(s))delete o[s];else throw new Error(`Key ${s} not found in enum`);return new Jn({...t,checks:[],...N(i),entries:o})}});function at(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(r=>[r,r])):e;return new Jn({type:"enum",entries:n,...N(t)})}function sf(e,t){return new Jn({type:"enum",entries:e,...N(t)})}const ma=S("ZodLiteral",(e,t)=>{Gy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>mb(e,n,r,i),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 x(e,t){return new ma({type:"literal",values:Array.isArray(e)?e:[e],...N(t)})}const ga=S("ZodFile",(e,t)=>{jy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>vb(e,n,r),e.min=(n,r)=>e.check(gn(n,r)),e.max=(n,r)=>e.check(Yn(n,r)),e.mime=(n,r)=>e.check(Mi(Array.isArray(n)?n:[n],r))});function af(e){return Uv(ga,e)}const ya=S("ZodTransform",(e,t)=>{Xn(),Zy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>kb(e,n,r,i),e._zod.parse=(n,r)=>{if(r.direction==="backward")throw new As(e.constructor.name);n.addIssue=o=>{if(typeof o=="string")n.issues.push(ar(o,n.value,t));else{const s=o;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(ar(s))}};const i=t.transform(n.value,n);return i instanceof Promise?i.then(o=>(n.value=o,n)):(n.value=i,n)}});function po(e){return new ya({type:"transform",transform:e})}const Dr=S("ZodOptional",(e,t)=>{ll.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ue(e){return new Dr({type:"optional",innerType:e})}const mo=S("ZodExactOptional",(e,t)=>{By.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Kl(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function va(e){return new mo({type:"optional",innerType:e})}const ba=S("ZodNullable",(e,t)=>{Hy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ib(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function mr(e){return new ba({type:"nullable",innerType:e})}function uf(e){return Ue(mr(e))}const wa=S("ZodDefault",(e,t)=>{Vy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Lb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function _a(e,t){return new wa({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():wi(t)}})}const ka=S("ZodPrefault",(e,t)=>{qy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>zb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Sa(e,t){return new ka({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():wi(t)}})}const go=S("ZodNonOptional",(e,t)=>{Wy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Nb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Ea(e,t){return new go({type:"nonoptional",innerType:e,...N(t)})}const xa=S("ZodSuccess",(e,t)=>{Ky.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>bb(e,n,r),e.unwrap=()=>e._zod.def.innerType});function cf(e){return new xa({type:"success",innerType:e})}const $a=S("ZodCatch",(e,t)=>{Jy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Pb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Ta(e,t){return new $a({type:"catch",innerType:e,catchValue:typeof t=="function"?t:Ec(t)})}const Ca=S("ZodNaN",(e,t)=>{Yy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>gb(e,n,r,i)});function lf(e){return Mv(Ca,e)}const Mr=S("ZodPipe",(e,t)=>{dl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Ob(e,n,r,i),e.in=t.in,e.out=t.out});function fi(e,t){return new Mr({type:"pipe",in:e,out:t})}const Fr=S("ZodCodec",(e,t)=>{Mr.init(e,t),fl.init(e,t)});function df(e,t,n){return new Fr({type:"pipe",in:e,out:t,transform:n.decode,reverseTransform:n.encode})}function ff(e){const t=e._zod.def;return new Fr({type:"pipe",in:t.out,out:t.in,transform:t.reverseTransform,reverseTransform:t.transform})}const Aa=S("ZodPreprocess",(e,t)=>{Mr.init(e,t),Xy.init(e,t)}),Ia=S("ZodReadonly",(e,t)=>{Qy.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Db(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function Na(e){return new Ia({type:"readonly",innerType:e})}const Ra=S("ZodTemplateLiteral",(e,t)=>{ev.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>yb(e,n,r)});function hf(e,t){return new Ra({type:"template_literal",parts:e,...N(t)})}const La=S("ZodLazy",(e,t)=>{hl.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Fb(e,n,r,i),e.unwrap=()=>e._zod.def.getter()});function za(e){return new La({type:"lazy",getter:e})}const Pa=S("ZodPromise",(e,t)=>{nv.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>Mb(e,n,r,i),e.unwrap=()=>e._zod.def.innerType});function pf(e){return new Pa({type:"promise",innerType:e})}const Oa=S("ZodFunction",(e,t)=>{tv.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>_b(e,n,r,i)});function gr(e){return new Oa({type:"function",input:Array.isArray(e?.input)?fa(e?.input):e?.input??ae(Le()),output:e?.output??Le()})}const Ur=S("ZodCustom",(e,t)=>{rv.init(e,t),ye.init(e,t),e._zod.processJSONSchema=(n,r,i)=>wb(e,n,r,i)});function mf(e){const t=new Ze({check:"custom"});return t._zod.check=e,t}function Da(e,t){return Gv(Ur,e??(()=>!0),t)}function Ma(e,t={}){return jv(Ur,e,t)}function Fa(e,t){return Zv(e,t)}const gf=Hv,yf=Vv,Ua=S("ZodInstanceOf",(e,t)=>{Ur.init(e,t)},{properties(e,t){return this.check(Di(e,t))}});function vf(e,t={}){const n=new Ua({type:"custom",check:"custom",fn:r=>r instanceof e,abort:!0,...N(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 bf=(...e)=>qv({Codec:Fr,Boolean:Rr,String:xr},...e);function wf(e){const t=za(()=>ke([E(e),ge(),Pe(),co(),ae(t),Ee(E(),t)]));return t}function yo(e,t){return new Aa({type:"pipe",in:po(e),out:t})}const lE=Object.freeze(Object.defineProperty({__proto__:null,ZodAny:ra,ZodArray:aa,ZodBase64:io,ZodBase64URL:oo,ZodBigInt:Lr,ZodBigIntFormat:uo,ZodBoolean:Rr,ZodCIDRv4:no,ZodCIDRv6:ro,ZodCUID:Ki,ZodCUID2:Ji,ZodCatch:$a,ZodCodec:Fr,ZodCreditCard:Xs,ZodCustom:Ur,ZodCustomStringFormat:In,ZodDate:fo,ZodDefault:wa,ZodDiscriminatedUnion:ca,ZodE164:so,ZodEmail:Hi,ZodEmoji:qi,ZodEnum:Jn,ZodExactOptional:mo,ZodFile:ga,ZodFunction:Oa,ZodGUID:Vi,ZodIBAN:Qs,ZodIPv4:eo,ZodIPv6:to,ZodISODate:Tr,ZodISODateTime:$r,ZodISODuration:Ar,ZodISOTime:Cr,ZodInstanceOf:Ua,ZodIntersection:la,ZodJWT:ao,ZodKSUID:Qi,ZodLazy:La,ZodLiteral:ma,ZodMAC:Ys,ZodMap:ha,ZodNaN:Ca,ZodNanoID:Wi,ZodNever:oa,ZodNonOptional:go,ZodNull:na,ZodNullable:ba,ZodNumber:Nr,ZodNumberFormat:Nn,ZodObject:zr,ZodOptional:Dr,ZodPipe:Mr,ZodPrefault:ka,ZodPreprocess:Aa,ZodPromise:Pa,ZodReadonly:Ia,ZodRecord:Kn,ZodSet:pa,ZodString:xr,ZodStringFormat:Oe,ZodSuccess:xa,ZodSymbol:ea,ZodTemplateLiteral:Ra,ZodTransform:ya,ZodTuple:da,ZodType:ye,ZodULID:Yi,ZodURL:Ir,ZodUUID:Wt,ZodUndefined:ta,ZodUnion:Pr,ZodUnknown:ia,ZodVoid:sa,ZodXID:Xi,ZodXor:ua,_ZodString:Bi,_default:_a,_function:gr,any:lo,array:ae,base64:Nd,base64url:Rd,bigint:Vd,boolean:Pe,catch:Ta,check:mf,cidrv4:Ad,cidrv6:Id,codec:df,creditCard:zd,cuid:_d,cuid2:kd,currencyCode:Ud,custom:Da,date:Yd,describe:gf,discriminatedUnion:ho,e164:Ld,email:dd,emoji:bd,enum:at,exactOptional:va,file:af,float32:jd,float64:Zd,function:gr,guid:fd,hash:Gd,hex:Fd,hostname:Md,httpUrl:vd,iban:Pd,instanceof:vf,int:di,int32:Bd,int64:qd,intersection:Or,invertCodec:ff,ipv4:$d,ipv6:Cd,json:wf,jwt:Od,keyof:Xd,ksuid:xd,lazy:za,literal:x,looseObject:st,looseRecord:nf,mac:Td,map:rf,meta:yf,nan:lf,nanoid:wd,nativeEnum:sf,never:Wn,nonoptional:Ea,null:co,nullable:mr,nullish:uf,number:ge,object:T,optional:Ue,partialRecord:tf,pipe:fi,prefault:Sa,preprocess:yo,promise:pf,readonly:Na,record:Ee,refine:Ma,set:of,strictObject:Qd,string:E,stringFormat:Dd,stringbool:bf,success:cf,superRefine:Fa,symbol:Kd,templateLiteral:hf,transform:po,tuple:fa,uint32:Hd,uint64:Wd,ulid:Sd,undefined:pr,union:ke,unknown:Le,url:yd,uuid:hd,uuidv4:pd,uuidv6:md,uuidv7:gd,void:Jd,xid:Ed,xor:ef},Symbol.toStringTag,{value:"Module"})),Bb={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 Hb(e){et({customError:e})}function Vb(){return et().customError}var ds;ds||(ds={});function qb(e){return Zl($r,e)}function dE(e){return Bl(Tr,e)}function fE(e){return Hl(Cr,e)}function hE(e){return Vl(Ar,e)}const _f=Object.freeze(Object.defineProperty({__proto__:null,ZodISODate:Tr,ZodISODateTime:$r,ZodISODuration:Ar,ZodISOTime:Cr,date:dE,datetime:qb,duration:hE,time:fE},Symbol.toStringTag,{value:"Module"})),V={...lE,...uE,iso:_f},pE=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 mE(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 Vh(e,t){return e.map((n,r)=>r<t?n:n.optional())}function gE(e){return e.replace(/~1/g,"/").replace(/~0/g,"~")}function yE(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 i=n[1]===void 0?void 0:gE(n[1]);if(!i||!t.defs[i])throw new Error(`Reference not found: ${e}`);return t.defs[i]}throw new Error(`Reference not found: ${e}`)}function vE(e,t){return V.transform(r=>r).check(r=>{const i=r.value;if(typeof i!="object"||i===null||Array.isArray(i))return;const o=Object.getOwnPropertyNames(i);if(t.minProperties!==void 0&&o.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:i,inst:e,continue:!0}),t.maxProperties!==void 0&&o.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:i,inst:e,continue:!0}),t.keySchema)for(const s of o){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 qu(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 o=[];for(const s of e){const a=qu(s,t);if(a===null)return null;o.push(a)}return`a${o.length}:[${o.join(",")}]`}const r=Object.keys(e).sort(),i=[];for(const o of r){const s=qu(e[o],t);if(s===null)return null;i.push(`${o.length}:${o}=${s}`)}return`o${i.length}:{${i.join(",")}}`}finally{t.delete(e)}}const bE=new Set(["items","prefixItems","additionalItems","additionalProperties","contains","propertyNames","not","if","then","else","allOf","anyOf","oneOf","unevaluatedItems","unevaluatedProperties","contentSchema"]),wE=new Set(["properties","patternProperties","dependentSchemas","dependencies","$defs","definitions"]);function oi(e){return typeof e!="object"||e===null?!1:Array.isArray(e)?e.some(oi):typeof e.$ref=="string"?!0:Object.entries(e).some(([t,n])=>bE.has(t)?oi(n):!wE.has(t)||typeof n!="object"||n===null?!1:Object.values(n).some(oi))}function qh(e){return e===1?"element":"elements"}function _E(e,t){return V.transform(r=>r).check(r=>{const i=r.value;if(Array.isArray(i)){if(t.uniqueItems===!0){const o=new Map;for(let s=0;s<i.length;s++){const a=qu(i[s],new Set);if(a===null)continue;const u=o.get(a);if(u===void 0){o.set(a,s);continue}r.issues.push({code:"custom",message:`Array items must be unique: element at index ${s} duplicates the one at index ${u}`,input:i,path:[s],continue:!0})}}if(t.containsSchema){const o=t.minContains??1,s=t.maxContains!==void 0?t.maxContains+1:Number.POSITIVE_INFINITY;let a=0;for(const u of i)if(t.containsSchema.safeParse(u).success&&++a>=s)break;a<o&&r.issues.push({code:"custom",message:`Array must contain at least ${o} matching ${qh(o)}; found ${a}`,input:i,continue:!0}),t.maxContains!==void 0&&a>t.maxContains&&r.issues.push({code:"custom",message:`Array must contain at most ${t.maxContains} matching ${qh(t.maxContains)}`,input:i,continue:!0})}}}).pipe(e)}function Wh(e,t){if(e!==!1)return e===void 0||e===!0?V.any():yt(e,t)}const kE=/^(?:[01]\d|2[0-3]):[0-5]\d:[0-5]\d(?:\.\d+)?(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/;function Wb(e,t){if(e.not!==void 0){if(typeof e.not=="object"&&Object.keys(e.not).length===0)return V.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 i=e.$ref;if(t.refs.has(i))return t.refs.get(i);if(t.processing.has(i))return V.lazy(()=>{if(!t.refs.has(i))throw new Error(`Circular reference not resolved: ${i}`);return t.refs.get(i)});t.processing.add(i);const o=yE(i,t),s=yt(o,t);return t.refs.set(i,s),t.processing.delete(i),s}if(e.enum!==void 0){const i=e.enum;if(t.version==="openapi-3.0"&&e.nullable===!0&&i.length===1&&i[0]===null)return V.null();if(i.length===0)return V.never();if(i.length===1)return V.literal(i[0]);if(i.every(s=>typeof s=="string"))return V.enum(i);const o=i.map(s=>V.literal(s));return o.length<2?o[0]:V.union([o[0],o[1],...o.slice(2)])}if(e.const!==void 0)return V.literal(e.const);const n=e.type;if(Array.isArray(n)){const i=n.map(o=>{const s={...e,type:o};return Wb(s,t)});return i.length===0?V.never():i.length===1?i[0]:V.union(i)}if(!n)return V.any();let r;switch(n){case"string":{let i=V.string();if(e.format){const o=e.format;o==="email"?i=i.check(V.email()):o==="uri"||o==="uri-reference"?i=i.check(V.url()):o==="uuid"||o==="guid"?i=i.check(V.uuid()):o==="date-time"?i=i.check(V.iso.datetime({offset:!0})):o==="date"?i=i.check(V.iso.date()):o==="time"?i=i.check(V.regex(kE)):o==="duration"?i=i.check(V.iso.duration()):o==="hostname"?i=i.check(V.hostname()):o==="ipv4"?i=i.check(V.ipv4()):o==="ipv6"?i=i.check(V.ipv6()):o==="mac"?i=i.check(V.mac()):o==="cidr"?i=i.check(V.cidrv4()):o==="cidr-v6"?i=i.check(V.cidrv6()):o==="base64"?i=i.check(V.base64()):o==="base64url"?i=i.check(V.base64url()):o==="e164"?i=i.check(V.e164()):o==="credit_card"?i=i.check(V.creditCard()):o==="iban"?i=i.check(V.iban()):o==="jwt"?i=i.check(V.jwt()):o==="emoji"?i=i.check(V.emoji()):o==="nanoid"?i=i.check(V.nanoid()):o==="cuid"?i=i.check(V.cuid()):o==="cuid2"?i=i.check(V.cuid2()):o==="ulid"?i=i.check(V.ulid()):o==="xid"?i=i.check(V.xid()):o==="ksuid"&&(i=i.check(V.ksuid()))}typeof e.minLength=="number"&&(i=i.min(e.minLength)),typeof e.maxLength=="number"&&(i=i.max(e.maxLength)),e.pattern&&(i=i.regex(new RegExp(e.pattern))),r=i;break}case"number":case"integer":{let i=n==="integer"?V.number().int():V.number();typeof e.minimum=="number"&&e.exclusiveMinimum!==!0&&(i=i.min(e.minimum)),typeof e.maximum=="number"&&e.exclusiveMaximum!==!0&&(i=i.max(e.maximum)),typeof e.exclusiveMinimum=="number"?i=i.gt(e.exclusiveMinimum):e.exclusiveMinimum===!0&&typeof e.minimum=="number"&&(i=i.gt(e.minimum)),typeof e.exclusiveMaximum=="number"?i=i.lt(e.exclusiveMaximum):e.exclusiveMaximum===!0&&typeof e.maximum=="number"&&(i=i.lt(e.maximum)),typeof e.multipleOf=="number"&&(i=i.multipleOf(e.multipleOf)),r=i;break}case"boolean":{r=V.boolean();break}case"null":{r=V.null();break}case"object":{const i={},o=e.properties||{},s=new Set(e.required||[]),a=typeof e.additionalProperties=="object"?yt(e.additionalProperties,t):void 0;for(const[d,f]of Object.entries(o)){const h=yt(f,t);Tt(i,d,s.has(d)?h:h.optional())}if(e.patternProperties){const d=e.patternProperties,f=Object.keys(d),h=[];for(const m of f){const y=yt(d[m],t),w=V.string().regex(new RegExp(m));h.push(V.looseRecord(w,y))}const p=[];if(Object.keys(i).length>0&&p.push(V.object(i).passthrough()),p.push(...h),p.length===0)r=V.object({}).passthrough();else if(p.length===1)r=p[0];else{let m=V.intersection(p[0],p[1]);for(let y=2;y<p.length;y++)m=V.intersection(m,p[y]);r=m}if(e.additionalProperties===!1){const m=Object.keys(i),y=f.map(g=>new RegExp(g)),w=r;r=r.check(g=>{if(!ln(g.value))return;const b=[];for(const v of Object.keys(g.value))m.includes(v)||y.some(k=>k.test(v))||b.push(v);b.length&&g.issues.push({code:"unrecognized_keys",keys:b,input:g.value,inst:w})})}}else{const d=V.object(i);e.additionalProperties===!1?r=d.strict():a?r=d.catchall(a):r=d.passthrough()}const u=e.propertyNames!==void 0&&e.propertyNames!==!0,c=typeof e.minProperties=="number"?e.minProperties:void 0,l=typeof e.maxProperties=="number"?e.maxProperties:void 0;if(u||c!==void 0||l!==void 0){let d;if(u){const f=typeof e.propertyNames=="object"&&e.propertyNames.type===void 0?{type:"string",...e.propertyNames}:e.propertyNames;d=yt(f,t)}r=vE(r,{keySchema:d,minProperties:c,maxProperties:l})}break}case"array":{const i=e.prefixItems,o=e.items;if(i&&Array.isArray(i)){const s=typeof e.minItems=="number"?e.minItems:0,a=i.map(d=>yt(d,t)),u=Vh(a,s),c=Array.isArray(o)?void 0:Wh(o,t),l=V.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(V.maxLength(e.maxItems)))}else if(Array.isArray(o)){const s=typeof e.minItems=="number"?e.minItems:0,a=o.map(d=>yt(d,t)),u=Vh(a,s),c=Wh(e.additionalItems,t),l=V.tuple(u);r=c?l.rest(c):l,typeof e.minItems=="number"&&(r=r.check(V.minLength(e.minItems))),typeof e.maxItems=="number"&&(r=r.check(V.maxLength(e.maxItems)))}else if(o!==void 0){const s=yt(o,t);let a=V.array(s);typeof e.minItems=="number"&&(a=a.min(e.minItems)),typeof e.maxItems=="number"&&(a=a.max(e.maxItems)),r=a}else r=V.array(V.any());(e.uniqueItems===!0||e.contains!==void 0)&&(r=_E(r,{uniqueItems:e.uniqueItems===!0,containsSchema:e.contains!==void 0?yt(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 yt(e,t){if(typeof e=="boolean")return e?V.any():V.never();let n=Wb(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(c=>yt(c,t)),u=V.union(a);n=r?V.intersection(n,u):u}if(e.oneOf&&Array.isArray(e.oneOf)){const a=e.oneOf.map(c=>yt(c,t)),u=V.xor(a);n=r?V.intersection(n,u):u}if(e.allOf&&Array.isArray(e.allOf))if(e.allOf.length===0)n=r?n:V.any();else{let a=r?n:yt(e.allOf[0],t);const u=r?0:1;for(let c=u;c<e.allOf.length;c++)a=V.intersection(a,yt(e.allOf[c],t));n=a}e.nullable===!0&&t.version==="openapi-3.0"&&(n=V.nullable(n)),e.readOnly===!0&&(n=V.readonly(n)),e.default!==void 0&&(n=n.default(e.default));const i={},o=["$id","id","$comment","$anchor","$vocabulary","$dynamicRef","$dynamicAnchor"];for(const a of o)a in e&&(i[a]=e[a]);const s=["contentEncoding","contentMediaType","contentSchema"];for(const a of s)a in e&&(i[a]=e[a]);if(e.type==="object"&&e.$ref===void 0){e.propertyNames!==void 0&&!oi(e.propertyNames)&&(i.propertyNames=e.propertyNames);for(const a of["minProperties","maxProperties"])e[a]!==void 0&&(i[a]=e[a])}if(e.type==="array"&&e.$ref===void 0){e.contains!==void 0&&!oi(e.contains)&&(i.contains=e.contains);for(const a of["uniqueItems","minContains","maxContains"])e[a]!==void 0&&(i[a]=e[a])}for(const a of Object.keys(e))pE.has(a)||Tt(i,a,e[a]);return Object.keys(i).length>0&&t.registry.add(n,i),e.description&&(n=n.describe(e.description)),n}function Kb(e,t){if(typeof e=="boolean")return e?V.any():V.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=mE(n,t?.defaultTarget),i=n.$defs||n.definitions||{},o={version:r,defs:i,refs:new Map,processing:new Set,rootSchema:n,registry:t?.registry??St};return yt(n,o)}function Jb(e){return Yl(e,{object:t=>t.partial(),union:t=>{const n=t._zod.def;return n.discriminator===void 0?t:ke(n.options)}})}function SE(e,t){if(!t?.length)return e;const n=e._zod.def;return je(e,lt(n,{checks:[...n.checks??[],...t]}),{parent:!0})}function Yb(e){return SE(e.out,e.checks)}function EE(e){return e.in._zod.traits.has("$ZodTransform")?Yb(e):e.in}function Xb(e){return Yl(e,{pipe:t=>EE(t._zod.def),default:(t,n)=>n?Ue(t._zod.def.innerType):t,catch:(t,n)=>n?t._zod.def.innerType:t})}function Qb(e){return Yl(e,{pipe:t=>Yb(t._zod.def),prefault:(t,n)=>n?t._zod.def.innerType:t})}function xE(e){return fv(xr,e)}function $E(e){return yv(Nr,e)}function TE(e){return Ev(Rr,e)}function CE(e){return $v(Lr,e)}function AE(e){return Dv(fo,e)}const ew=Object.freeze(Object.defineProperty({__proto__:null,bigint:CE,boolean:TE,date:AE,number:$E,string:xE},Symbol.toStringTag,{value:"Module"})),Kh=Object.freeze(Object.defineProperty({__proto__:null,$brand:Tc,$input:vl,$output:yl,INVALID:bt,NEVER:$c,TimePrecision:jl,ZodAny:ra,ZodArray:aa,ZodBase64:io,ZodBase64URL:oo,ZodBigInt:Lr,ZodBigIntFormat:uo,ZodBoolean:Rr,ZodCIDRv4:no,ZodCIDRv6:ro,ZodCUID:Ki,ZodCUID2:Ji,ZodCatch:$a,ZodCodec:Fr,ZodCompileAsyncError:hn,ZodCompileUnsupportedError:Ce,ZodCreditCard:Xs,ZodCustom:Ur,ZodCustomStringFormat:In,ZodDate:fo,ZodDefault:wa,ZodDiscriminatedUnion:ca,ZodE164:so,ZodEmail:Hi,ZodEmoji:qi,ZodEnum:Jn,ZodError:Zb,ZodExactOptional:mo,ZodFile:ga,get ZodFirstPartyTypeKind(){return ds},ZodFunction:Oa,ZodGUID:Vi,ZodIBAN:Qs,ZodIPv4:eo,ZodIPv6:to,ZodISODate:Tr,ZodISODateTime:$r,ZodISODuration:Ar,ZodISOTime:Cr,ZodInstanceOf:Ua,ZodIntersection:la,ZodIssueCode:Bb,ZodJWT:ao,ZodKSUID:Qi,ZodLazy:La,ZodLiteral:ma,ZodMAC:Ys,ZodMap:ha,ZodNaN:Ca,ZodNanoID:Wi,ZodNever:oa,ZodNonOptional:go,ZodNull:na,ZodNullable:ba,ZodNumber:Nr,ZodNumberFormat:Nn,ZodObject:zr,ZodOptional:Dr,ZodPipe:Mr,ZodPrefault:ka,ZodPreprocess:Aa,ZodPromise:Pa,ZodReadonly:Ia,ZodRealError:_t,ZodRecord:Kn,ZodSet:pa,ZodString:xr,ZodStringFormat:Oe,ZodSuccess:xa,ZodSymbol:ea,ZodTemplateLiteral:Ra,ZodTransform:ya,ZodTuple:da,ZodType:ye,ZodULID:Yi,ZodURL:Ir,ZodUUID:Wt,ZodUndefined:ta,ZodUnion:Pr,ZodUnknown:ia,ZodVoid:sa,ZodXID:Xi,ZodXor:ua,_ZodString:Bi,_default:_a,_function:gr,any:lo,array:ae,base64:Nd,base64url:Rd,bigint:Vd,boolean:Pe,catch:Ta,check:mf,cidrv4:Ad,cidrv6:Id,clone:je,codec:df,coerce:ew,compile:bl,config:et,core:Ub,creditCard:zd,cuid:_d,cuid2:kd,currencyCode:Ud,custom:Da,date:Yd,decode:id,decodeAsync:sd,deepPartial:Jb,describe:gf,discriminatedUnion:ho,e164:Ld,email:dd,emoji:bd,encode:rd,encodeAsync:od,endsWith:Oi,enum:at,exactOptional:va,file:af,flattenError:Is,float32:jd,float64:Zd,formatError:Ns,fromJSONSchema:Kb,function:gr,getDiscriminatedOption:ul,getErrorMap:Vb,globalRegistry:St,gt:mn,gte:$t,guid:fd,hash:Gd,hex:Fd,hostname:Md,httpUrl:vd,iban:Pd,includes:zi,input:Xb,instanceof:vf,int:di,int32:Bd,int64:qd,intersection:Or,invertCodec:ff,ipv4:$d,ipv6:Cd,iso:_f,json:wf,jwt:Od,keyof:Xd,ksuid:xd,lazy:za,length:Sr,literal:x,locales:gl,looseObject:st,looseRecord:nf,lowercase:Ri,lt:pn,lte:xt,mac:Td,map:rf,maxLength:kr,maxSize:Yn,memoizer:Us,meta:yf,mime:Mi,minLength:An,minSize:gn,multipleOf:qn,nan:lf,nanoid:wd,nativeEnum:sf,negative:qs,never:Wn,nonnegative:Ks,nonoptional:Ea,nonpositive:Ws,normalize:Fi,null:co,nullable:mr,nullish:uf,number:ge,object:T,optional:Ue,output:Qb,overwrite:tn,parse:Ql,parseAsync:ed,partialRecord:tf,pipe:fi,positive:Vs,prefault:Sa,preprocess:yo,prettifyError:Ac,promise:pf,properties:Di,property:Js,readonly:Na,record:Ee,refine:Ma,regex:Ni,regexes:Ps,registry:Gs,safeDecode:ud,safeDecodeAsync:ld,safeEncode:ad,safeEncodeAsync:cd,safeParse:td,safeParseAsync:nd,set:of,setErrorMap:Hb,size:_r,slugify:Zi,startsWith:Pi,strictObject:Qd,string:E,stringFormat:Dd,stringbool:bf,success:cf,superRefine:Fa,symbol:Kd,templateLiteral:hf,toJSONSchema:Jl,toLowerCase:Gi,toUpperCase:ji,toZod:Ss,transform:po,treeifyError:Cc,trim:Ui,tuple:fa,uint32:Hd,uint64:Wd,ulid:Sd,undefined:pr,union:ke,unknown:Le,uppercase:Li,url:yd,util:xc,uuid:hd,uuidv4:pd,uuidv6:md,uuidv7:gd,validate:Ls,validateAsync:zs,void:Jd,withParser:js,xid:Ed,xor:ef},Symbol.toStringTag,{value:"Module"})),IE=Object.freeze(Object.defineProperty({__proto__:null,$brand:Tc,$input:vl,$output:yl,INVALID:bt,NEVER:$c,TimePrecision:jl,ZodAny:ra,ZodArray:aa,ZodBase64:io,ZodBase64URL:oo,ZodBigInt:Lr,ZodBigIntFormat:uo,ZodBoolean:Rr,ZodCIDRv4:no,ZodCIDRv6:ro,ZodCUID:Ki,ZodCUID2:Ji,ZodCatch:$a,ZodCodec:Fr,ZodCompileAsyncError:hn,ZodCompileUnsupportedError:Ce,ZodCreditCard:Xs,ZodCustom:Ur,ZodCustomStringFormat:In,ZodDate:fo,ZodDefault:wa,ZodDiscriminatedUnion:ca,ZodE164:so,ZodEmail:Hi,ZodEmoji:qi,ZodEnum:Jn,ZodError:Zb,ZodExactOptional:mo,ZodFile:ga,get ZodFirstPartyTypeKind(){return ds},ZodFunction:Oa,ZodGUID:Vi,ZodIBAN:Qs,ZodIPv4:eo,ZodIPv6:to,ZodISODate:Tr,ZodISODateTime:$r,ZodISODuration:Ar,ZodISOTime:Cr,ZodInstanceOf:Ua,ZodIntersection:la,ZodIssueCode:Bb,ZodJWT:ao,ZodKSUID:Qi,ZodLazy:La,ZodLiteral:ma,ZodMAC:Ys,ZodMap:ha,ZodNaN:Ca,ZodNanoID:Wi,ZodNever:oa,ZodNonOptional:go,ZodNull:na,ZodNullable:ba,ZodNumber:Nr,ZodNumberFormat:Nn,ZodObject:zr,ZodOptional:Dr,ZodPipe:Mr,ZodPrefault:ka,ZodPreprocess:Aa,ZodPromise:Pa,ZodReadonly:Ia,ZodRealError:_t,ZodRecord:Kn,ZodSet:pa,ZodString:xr,ZodStringFormat:Oe,ZodSuccess:xa,ZodSymbol:ea,ZodTemplateLiteral:Ra,ZodTransform:ya,ZodTuple:da,ZodType:ye,ZodULID:Yi,ZodURL:Ir,ZodUUID:Wt,ZodUndefined:ta,ZodUnion:Pr,ZodUnknown:ia,ZodVoid:sa,ZodXID:Xi,ZodXor:ua,_ZodString:Bi,_default:_a,_function:gr,any:lo,array:ae,base64:Nd,base64url:Rd,bigint:Vd,boolean:Pe,catch:Ta,check:mf,cidrv4:Ad,cidrv6:Id,clone:je,codec:df,coerce:ew,compile:bl,config:et,core:Ub,creditCard:zd,cuid:_d,cuid2:kd,currencyCode:Ud,custom:Da,date:Yd,decode:id,decodeAsync:sd,deepPartial:Jb,default:Kh,describe:gf,discriminatedUnion:ho,e164:Ld,email:dd,emoji:bd,encode:rd,encodeAsync:od,endsWith:Oi,enum:at,exactOptional:va,file:af,flattenError:Is,float32:jd,float64:Zd,formatError:Ns,fromJSONSchema:Kb,function:gr,getDiscriminatedOption:ul,getErrorMap:Vb,globalRegistry:St,gt:mn,gte:$t,guid:fd,hash:Gd,hex:Fd,hostname:Md,httpUrl:vd,iban:Pd,includes:zi,input:Xb,instanceof:vf,int:di,int32:Bd,int64:qd,intersection:Or,invertCodec:ff,ipv4:$d,ipv6:Cd,iso:_f,json:wf,jwt:Od,keyof:Xd,ksuid:xd,lazy:za,length:Sr,literal:x,locales:gl,looseObject:st,looseRecord:nf,lowercase:Ri,lt:pn,lte:xt,mac:Td,map:rf,maxLength:kr,maxSize:Yn,memoizer:Us,meta:yf,mime:Mi,minLength:An,minSize:gn,multipleOf:qn,nan:lf,nanoid:wd,nativeEnum:sf,negative:qs,never:Wn,nonnegative:Ks,nonoptional:Ea,nonpositive:Ws,normalize:Fi,null:co,nullable:mr,nullish:uf,number:ge,object:T,optional:Ue,output:Qb,overwrite:tn,parse:Ql,parseAsync:ed,partialRecord:tf,pipe:fi,positive:Vs,prefault:Sa,preprocess:yo,prettifyError:Ac,promise:pf,properties:Di,property:Js,readonly:Na,record:Ee,refine:Ma,regex:Ni,regexes:Ps,registry:Gs,safeDecode:ud,safeDecodeAsync:ld,safeEncode:ad,safeEncodeAsync:cd,safeParse:td,safeParseAsync:nd,set:of,setErrorMap:Hb,size:_r,slugify:Zi,startsWith:Pi,strictObject:Qd,string:E,stringFormat:Dd,stringbool:bf,success:cf,superRefine:Fa,symbol:Kd,templateLiteral:hf,toJSONSchema:Jl,toLowerCase:Gi,toUpperCase:ji,toZod:Ss,transform:po,treeifyError:Cc,trim:Ui,tuple:fa,uint32:Hd,uint64:Wd,ulid:Sd,undefined:pr,union:ke,unknown:Le,uppercase:Li,url:yd,util:xc,uuid:hd,uuidv4:pd,uuidv6:md,uuidv7:gd,validate:Ls,validateAsync:zs,void:Jd,withParser:js,xid:Ed,xor:ef,z:Kh},Symbol.toStringTag,{value:"Module"})),Un="io.modelcontextprotocol/related-task",Ga="2.0",Qe=Da(e=>e!==null&&(typeof e=="object"||typeof e=="function")),tw=ke([E(),ge().int()]),nw=E();st({ttl:ge().optional(),pollInterval:ge().optional()});const NE=T({ttl:ge().optional()}),RE=T({taskId:E()}),kf=st({progressToken:tw.optional(),[Un]:RE.optional()}),At=T({_meta:kf.optional()}),vo=At.extend({task:NE.optional()}),LE=e=>vo.safeParse(e).success,ut=T({method:E(),params:At.loose().optional()}),Mt=T({_meta:kf.optional()}),Ft=T({method:E(),params:Mt.loose().optional()}),ct=st({_meta:kf.optional()}),bo=ke([E(),ge().int()]),rw=T({jsonrpc:x(Ga),id:bo,...ut.shape}).strict(),Jh=e=>rw.safeParse(e).success,iw=T({jsonrpc:x(Ga),...Ft.shape}).strict(),zE=e=>iw.safeParse(e).success,Sf=T({jsonrpc:x(Ga),id:bo,result:ct}).strict(),Do=e=>Sf.safeParse(e).success;var Re;(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"})(Re||(Re={}));const Ef=T({jsonrpc:x(Ga),id:bo.optional(),error:T({code:ge().int(),message:E(),data:Le().optional()})}).strict(),PE=e=>Ef.safeParse(e).success,OE=ke([rw,iw,Sf,Ef]);ke([Sf,Ef]);const xf=ct.strict(),DE=Mt.extend({requestId:bo.optional(),reason:E().optional()}),$f=Ft.extend({method:x("notifications/cancelled"),params:DE}),ME=T({src:E(),mimeType:E().optional(),sizes:ae(E()).optional(),theme:at(["light","dark"]).optional()}),wo=T({icons:ae(ME).optional()}),yr=T({name:E(),title:E().optional()}),ja=yr.extend({...yr.shape,...wo.shape,version:E(),websiteUrl:E().optional(),description:E().optional()}),FE=Or(T({applyDefaults:Pe().optional()}),Ee(E(),Le())),UE=yo(e=>e&&typeof e=="object"&&!Array.isArray(e)&&Object.keys(e).length===0?{form:{}}:e,Or(T({form:FE.optional(),url:Qe.optional()}),Ee(E(),Le()).optional())),GE=st({list:Qe.optional(),cancel:Qe.optional(),requests:st({sampling:st({createMessage:Qe.optional()}).optional(),elicitation:st({create:Qe.optional()}).optional()}).optional()}),jE=st({list:Qe.optional(),cancel:Qe.optional(),requests:st({tools:st({call:Qe.optional()}).optional()}).optional()}),ZE=T({experimental:Ee(E(),Qe).optional(),sampling:T({context:Qe.optional(),tools:Qe.optional()}).optional(),elicitation:UE.optional(),roots:T({listChanged:Pe().optional()}).optional(),tasks:GE.optional(),extensions:Ee(E(),Qe).optional()}),BE=At.extend({protocolVersion:E(),capabilities:ZE,clientInfo:ja}),HE=ut.extend({method:x("initialize"),params:BE}),VE=T({experimental:Ee(E(),Qe).optional(),logging:Qe.optional(),completions:Qe.optional(),prompts:T({listChanged:Pe().optional()}).optional(),resources:T({subscribe:Pe().optional(),listChanged:Pe().optional()}).optional(),tools:T({listChanged:Pe().optional()}).optional(),tasks:jE.optional(),extensions:Ee(E(),Qe).optional()}),qE=ct.extend({protocolVersion:E(),capabilities:VE,serverInfo:ja,instructions:E().optional()}),WE=Ft.extend({method:x("notifications/initialized"),params:Mt.optional()}),Za=ut.extend({method:x("ping"),params:At.optional()}),KE=T({progress:ge(),total:Ue(ge()),message:Ue(E())}),JE=T({...Mt.shape,...KE.shape,progressToken:tw}),Tf=Ft.extend({method:x("notifications/progress"),params:JE}),YE=At.extend({cursor:nw.optional()}),_o=ut.extend({params:YE.optional()}),ko=ct.extend({nextCursor:nw.optional()}),XE=at(["working","input_required","completed","failed","cancelled"]),So=T({taskId:E(),status:XE,ttl:ke([ge(),co()]),createdAt:E(),lastUpdatedAt:E(),pollInterval:Ue(ge()),statusMessage:Ue(E())}),Cf=ct.extend({task:So}),QE=Mt.merge(So),fs=Ft.extend({method:x("notifications/tasks/status"),params:QE}),Af=ut.extend({method:x("tasks/get"),params:At.extend({taskId:E()})}),If=ct.merge(So),Nf=ut.extend({method:x("tasks/result"),params:At.extend({taskId:E()})});ct.loose();const Rf=_o.extend({method:x("tasks/list")}),Lf=ko.extend({tasks:ae(So)}),zf=ut.extend({method:x("tasks/cancel"),params:At.extend({taskId:E()})}),ex=ct.merge(So),ow=T({uri:E(),mimeType:Ue(E()),_meta:Ee(E(),Le()).optional()}),sw=ow.extend({text:E()}),Pf=E().refine(e=>{try{return atob(e),!0}catch{return!1}},{message:"Invalid Base64 string"}),aw=ow.extend({blob:Pf}),Eo=at(["user","assistant"]),Gr=T({audience:ae(Eo).optional(),priority:ge().min(0).max(1).optional(),lastModified:qb({offset:!0}).optional()}),uw=T({...yr.shape,...wo.shape,uri:E(),description:Ue(E()),mimeType:Ue(E()),size:Ue(ge()),annotations:Gr.optional(),_meta:Ue(st({}))}),tx=T({...yr.shape,...wo.shape,uriTemplate:E(),description:Ue(E()),mimeType:Ue(E()),annotations:Gr.optional(),_meta:Ue(st({}))}),nx=_o.extend({method:x("resources/list")}),cw=ko.extend({resources:ae(uw)}),rx=_o.extend({method:x("resources/templates/list")}),ix=ko.extend({resourceTemplates:ae(tx)}),Of=At.extend({uri:E()}),ox=Of,sx=ut.extend({method:x("resources/read"),params:ox}),lw=ct.extend({contents:ae(ke([sw,aw]))}),ax=Ft.extend({method:x("notifications/resources/list_changed"),params:Mt.optional()}),ux=Of,cx=ut.extend({method:x("resources/subscribe"),params:ux}),lx=Of,dx=ut.extend({method:x("resources/unsubscribe"),params:lx}),fx=Mt.extend({uri:E()}),hx=Ft.extend({method:x("notifications/resources/updated"),params:fx}),px=T({name:E(),description:Ue(E()),required:Ue(Pe())}),mx=T({...yr.shape,...wo.shape,description:Ue(E()),arguments:Ue(ae(px)),_meta:Ue(st({}))}),gx=_o.extend({method:x("prompts/list")}),yx=ko.extend({prompts:ae(mx)}),vx=At.extend({name:E(),arguments:Ee(E(),E()).optional()}),bx=ut.extend({method:x("prompts/get"),params:vx}),Df=T({type:x("text"),text:E(),annotations:Gr.optional(),_meta:Ee(E(),Le()).optional()}),Mf=T({type:x("image"),data:Pf,mimeType:E(),annotations:Gr.optional(),_meta:Ee(E(),Le()).optional()}),Ff=T({type:x("audio"),data:Pf,mimeType:E(),annotations:Gr.optional(),_meta:Ee(E(),Le()).optional()}),wx=T({type:x("tool_use"),name:E(),id:E(),input:Ee(E(),Le()),_meta:Ee(E(),Le()).optional()}),dw=T({type:x("resource"),resource:ke([sw,aw]),annotations:Gr.optional(),_meta:Ee(E(),Le()).optional()}),fw=uw.extend({type:x("resource_link")}),xo=ke([Df,Mf,Ff,fw,dw]),_x=T({role:Eo,content:xo}),kx=ct.extend({description:E().optional(),messages:ae(_x)}),Sx=Ft.extend({method:x("notifications/prompts/list_changed"),params:Mt.optional()}),Ex=T({title:E().optional(),readOnlyHint:Pe().optional(),destructiveHint:Pe().optional(),idempotentHint:Pe().optional(),openWorldHint:Pe().optional()}),xx=T({taskSupport:at(["required","optional","forbidden"]).optional()}),Uf=T({...yr.shape,...wo.shape,description:E().optional(),inputSchema:T({type:x("object"),properties:Ee(E(),Qe).optional(),required:ae(E()).optional()}).catchall(Le()),outputSchema:T({type:x("object"),properties:Ee(E(),Qe).optional(),required:ae(E()).optional()}).catchall(Le()).optional(),annotations:Ex.optional(),execution:xx.optional(),_meta:Ee(E(),Le()).optional()}),hw=_o.extend({method:x("tools/list")}),$x=ko.extend({tools:ae(Uf)}),Ba=ct.extend({content:ae(xo).default([]),structuredContent:Ee(E(),Le()).optional(),isError:Pe().optional()});Ba.or(ct.extend({toolResult:Le()}));const Tx=vo.extend({name:E(),arguments:Ee(E(),Le()).optional()}),pw=ut.extend({method:x("tools/call"),params:Tx}),Cx=Ft.extend({method:x("notifications/tools/list_changed"),params:Mt.optional()});T({autoRefresh:Pe().default(!0),debounceMs:ge().int().nonnegative().default(300)});const mw=at(["debug","info","notice","warning","error","critical","alert","emergency"]),Ax=At.extend({level:mw}),Ix=ut.extend({method:x("logging/setLevel"),params:Ax}),Nx=Mt.extend({level:mw,logger:E().optional(),data:Le()}),Rx=Ft.extend({method:x("notifications/message"),params:Nx}),Lx=T({name:E().optional()}),zx=T({hints:ae(Lx).optional(),costPriority:ge().min(0).max(1).optional(),speedPriority:ge().min(0).max(1).optional(),intelligencePriority:ge().min(0).max(1).optional()}),Px=T({mode:at(["auto","required","none"]).optional()}),Ox=T({type:x("tool_result"),toolUseId:E().describe("The unique identifier for the corresponding tool call."),content:ae(xo).default([]),structuredContent:T({}).loose().optional(),isError:Pe().optional(),_meta:Ee(E(),Le()).optional()}),Dx=ho("type",[Df,Mf,Ff]),hs=ho("type",[Df,Mf,Ff,wx,Ox]),Mx=T({role:Eo,content:ke([hs,ae(hs)]),_meta:Ee(E(),Le()).optional()}),Fx=vo.extend({messages:ae(Mx),modelPreferences:zx.optional(),systemPrompt:E().optional(),includeContext:at(["none","thisServer","allServers"]).optional(),temperature:ge().optional(),maxTokens:ge().int(),stopSequences:ae(E()).optional(),metadata:Qe.optional(),tools:ae(Uf).optional(),toolChoice:Px.optional()}),Ux=ut.extend({method:x("sampling/createMessage"),params:Fx}),gw=ct.extend({model:E(),stopReason:Ue(at(["endTurn","stopSequence","maxTokens"]).or(E())),role:Eo,content:Dx}),yw=ct.extend({model:E(),stopReason:Ue(at(["endTurn","stopSequence","maxTokens","toolUse"]).or(E())),role:Eo,content:ke([hs,ae(hs)])}),Gx=T({type:x("boolean"),title:E().optional(),description:E().optional(),default:Pe().optional()}),jx=T({type:x("string"),title:E().optional(),description:E().optional(),minLength:ge().optional(),maxLength:ge().optional(),format:at(["email","uri","date","date-time"]).optional(),default:E().optional()}),Zx=T({type:at(["number","integer"]),title:E().optional(),description:E().optional(),minimum:ge().optional(),maximum:ge().optional(),default:ge().optional()}),Bx=T({type:x("string"),title:E().optional(),description:E().optional(),enum:ae(E()),default:E().optional()}),Hx=T({type:x("string"),title:E().optional(),description:E().optional(),oneOf:ae(T({const:E(),title:E()})),default:E().optional()}),Vx=T({type:x("string"),title:E().optional(),description:E().optional(),enum:ae(E()),enumNames:ae(E()).optional(),default:E().optional()}),qx=ke([Bx,Hx]),Wx=T({type:x("array"),title:E().optional(),description:E().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:T({type:x("string"),enum:ae(E())}),default:ae(E()).optional()}),Kx=T({type:x("array"),title:E().optional(),description:E().optional(),minItems:ge().optional(),maxItems:ge().optional(),items:T({anyOf:ae(T({const:E(),title:E()}))}),default:ae(E()).optional()}),Jx=ke([Wx,Kx]),Yx=ke([Vx,qx,Jx]),Xx=ke([Yx,Gx,jx,Zx]),Qx=vo.extend({mode:x("form").optional(),message:E(),requestedSchema:T({type:x("object"),properties:Ee(E(),Xx),required:ae(E()).optional()})}),e$=vo.extend({mode:x("url"),message:E(),elicitationId:E(),url:E().url()}),t$=ke([Qx,e$]),n$=ut.extend({method:x("elicitation/create"),params:t$}),r$=Mt.extend({elicitationId:E()}),i$=Ft.extend({method:x("notifications/elicitation/complete"),params:r$}),o$=ct.extend({action:at(["accept","decline","cancel"]),content:yo(e=>e===null?void 0:e,Ee(E(),ke([E(),ge(),Pe(),ae(E())])).optional())}),s$=T({type:x("ref/resource"),uri:E()}),a$=T({type:x("ref/prompt"),name:E()}),u$=At.extend({ref:ke([a$,s$]),argument:T({name:E(),value:E()}),context:T({arguments:Ee(E(),E()).optional()}).optional()}),c$=ut.extend({method:x("completion/complete"),params:u$}),l$=ct.extend({completion:st({values:ae(E()).max(100),total:Ue(ge().int()),hasMore:Ue(Pe())})}),d$=T({uri:E().startsWith("file://"),name:E().optional(),_meta:Ee(E(),Le()).optional()}),f$=ut.extend({method:x("roots/list"),params:At.optional()}),h$=ct.extend({roots:ae(d$)}),p$=Ft.extend({method:x("notifications/roots/list_changed"),params:Mt.optional()});ke([Za,HE,c$,Ix,bx,gx,nx,rx,sx,cx,dx,pw,hw,Af,Nf,Rf,zf]);ke([$f,Tf,WE,p$,fs]);ke([xf,gw,yw,o$,h$,If,Lf,Cf]);ke([Za,Ux,n$,f$,Af,Nf,Rf,zf]);ke([$f,Tf,Rx,hx,ax,Cx,Sx,fs,i$]);ke([xf,qE,l$,kx,yx,cw,ix,lw,Ba,$x,If,Lf,Cf]);class Te 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===Re.UrlElicitationRequired&&r){const i=r;if(i.elicitations)return new m$(i.elicitations,n)}return new Te(t,n,r)}}class m$ extends Te{constructor(t,n=`URL elicitation${t.length>1?"s":""} required`){super(Re.UrlElicitationRequired,n,{elicitations:t})}get elicitations(){return this.data?.elicitations??[]}}function On(e){return e==="completed"||e==="failed"||e==="cancelled"}new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function Yh(e){const n=iE(e)?.method;if(!n)throw new Error("Schema is missing a method literal");const r=oE(n);if(typeof r!="string")throw new Error("Schema method literal must be a string");return r}function Xh(e,t){const n=Gb(e,t);if(!n.success)throw n.error;return n.data}const g$=6e4;class y${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($f,n=>{this._oncancel(n)}),this.setNotificationHandler(Tf,n=>{this._onprogress(n)}),this.setRequestHandler(Za,n=>({})),this._taskStore=t?.taskStore,this._taskMessageQueue=t?.taskMessageQueue,this._taskStore&&(this.setRequestHandler(Af,async(n,r)=>{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new Te(Re.InvalidParams,"Failed to retrieve task: Task not found");return{...i}}),this.setRequestHandler(Nf,async(n,r)=>{const i=async()=>{const o=n.params.taskId;if(!await this._taskStore.getTask(o,r.sessionId))throw new Te(Re.InvalidParams,`Task not found: ${o}`);if(this._taskMessageQueue){let a;for(;a=await this._taskMessageQueue.dequeue(o,r.sessionId);){if(a.type==="response"||a.type==="error"){const u=a.message,c=u.id,l=this._requestResolvers.get(c);if(l)if(this._requestResolvers.delete(c),a.type==="response")l(u);else{const d=u,f=new Te(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 ${c}`))}continue}await this._transport?.send(a.message,{relatedRequestId:r.requestId})}}const s=await this._taskStore.getTask(o,r.sessionId);if(!s)throw new Te(Re.InvalidParams,`Task not found: ${o}`);if(!On(s.status))return await this._waitForTaskUpdate(o,r.signal,r.sessionId),await i();if(On(s.status)){const a=await this._taskStore.getTaskResult(o,r.sessionId);return this._clearTaskQueue(o,r.sessionId),{...a,_meta:{...a._meta,[Un]:{taskId:o}}}}return await i()};return await i()}),this.setRequestHandler(Rf,async(n,r)=>{try{const{tasks:i,nextCursor:o}=await this._taskStore.listTasks(n.params?.cursor,r.sessionId);return{tasks:i,nextCursor:o,_meta:{}}}catch(i){throw new Te(Re.InvalidParams,`Failed to list tasks: ${i instanceof Error?i.message:String(i)}`)}}),this.setRequestHandler(zf,async(n,r)=>{try{const i=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!i)throw new Te(Re.InvalidParams,`Task not found: ${n.params.taskId}`);if(On(i.status))throw new Te(Re.InvalidParams,`Cannot cancel task in terminal status: ${i.status}`);await this._taskStore.updateTaskStatus(n.params.taskId,"cancelled","Client cancelled task execution.",r.sessionId),this._clearTaskQueue(n.params.taskId,r.sessionId);const o=await this._taskStore.getTask(n.params.taskId,r.sessionId);if(!o)throw new Te(Re.InvalidParams,`Task not found after cancellation: ${n.params.taskId}`);return{_meta:{},...o}}catch(i){throw i instanceof Te?i:new Te(Re.InvalidRequest,`Failed to cancel task: ${i instanceof Error?i.message:String(i)}`)}}))}async _oncancel(t){if(!t.params.requestId)return;this._requestHandlerAbortControllers.get(t.params.requestId)?.abort(t.params.reason)}_setupTimeout(t,n,r,i,o=!1){this._timeoutInfo.set(t,{timeoutId:setTimeout(i,n),startTime:Date.now(),timeout:n,maxTotalTimeout:r,resetTimeoutOnProgress:o,onTimeout:i})}_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),Te.fromError(Re.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=o=>{r?.(o),this._onerror(o)};const i=this._transport?.onmessage;this._transport.onmessage=(o,s)=>{i?.(o,s),Do(o)||PE(o)?this._onresponse(o):Jh(o)?this._onrequest(o,s):zE(o)?this._onnotification(o):this._onerror(new Error(`Unknown message type: ${JSON.stringify(o)}`))},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=Te.fromError(Re.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,i=this._transport,o=t.params?._meta?.[Un]?.taskId,s=i?.sessionId,a=this._taskStore;let u=!0,c;if(o&&a&&this._taskMessageQueue&&s!==void 0&&(u=!1,c=(async()=>{if(!await a.getTask(o,s))throw new Te(Re.InvalidParams,`Task not found: ${o}`);u=!0})()),r===void 0){const p={jsonrpc:"2.0",id:t.id,error:{code:Re.MethodNotFound,message:"Method not found"}};if(o&&c){const m={type:"error",message:p,timestamp:Date.now()};c.then(()=>this._enqueueTaskMessage(o,m,s),()=>i?.send(p)).catch(y=>this._onerror(new Error(`Failed to send an error response: ${y}`)))}else o&&this._taskMessageQueue?this._enqueueTaskMessage(o,{type:"error",message:p,timestamp:Date.now()},i?.sessionId).catch(m=>this._onerror(new Error(`Failed to enqueue error response: ${m}`))):i?.send(p).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=LE(t.params)?t.params.task:void 0,f=this._taskStore?this.requestTaskStore(t,i?.sessionId):void 0,h={signal:l.signal,sessionId:i?.sessionId,_meta:t.params?._meta,sendNotification:async p=>{if(l.signal.aborted)return;const m={relatedRequestId:t.id};o&&(m.relatedTask={taskId:o}),await this.notification(p,m)},sendRequest:async(p,m,y)=>{if(l.signal.aborted)throw new Te(Re.ConnectionClosed,"Request was cancelled");const w={...y,relatedRequestId:t.id};o&&!w.relatedTask&&(w.relatedTask={taskId:o});const g=w.relatedTask?.taskId??o;return g&&f&&await f.updateTaskStatus(g,"input_required"),await this.request(p,m,w)},authInfo:n?.authInfo,requestId:t.id,requestInfo:n?.requestInfo,taskId:o,taskStore:f,taskRequestedTtl:d?.ttl,closeSSEStream:n?.closeSSEStream,closeStandaloneSSEStream:n?.closeStandaloneSSEStream};(c??Promise.resolve()).then(()=>{if(c&&l.signal.aborted)throw new Te(Re.ConnectionClosed,"Request was cancelled");d&&this.assertTaskHandlerCapability(t.method)}).then(()=>r(t,h)).then(async p=>{if(l.signal.aborted)return;const m={result:p,jsonrpc:"2.0",id:t.id};o&&this._taskMessageQueue?await this._enqueueTaskMessage(o,{type:"response",message:m,timestamp:Date.now()},i?.sessionId):await i?.send(m)},async p=>{if(l.signal.aborted)return;const m={jsonrpc:"2.0",id:t.id,error:{code:Number.isSafeInteger(p.code)?p.code:Re.InternalError,message:p.message??"Internal error",...p.data!==void 0&&{data:p.data}}};o&&this._taskMessageQueue&&u?await this._enqueueTaskMessage(o,{type:"error",message:m,timestamp:Date.now()},i?.sessionId):await i?.send(m)}).catch(p=>this._onerror(new Error(`Failed to send response: ${p}`))).finally(()=>{this._requestHandlerAbortControllers.get(t.id)===l&&this._requestHandlerAbortControllers.delete(t.id)})}_onprogress(t){const{progressToken:n,...r}=t.params,i=Number(n),o=this._progressHandlers.get(i);if(!o){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify(t)}`));return}const s=this._responseHandlers.get(i),a=this._timeoutInfo.get(i);if(a&&s&&a.resetTimeoutOnProgress)try{this._resetTimeout(i)}catch(u){this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),s(u);return}o(r)}_onresponse(t){const n=Number(t.id),r=this._requestResolvers.get(n);if(r){if(this._requestResolvers.delete(n),Do(t))r(t);else{const s=new Te(t.error.code,t.error.message,t.error.data);r(s)}return}const i=this._responseHandlers.get(n);if(i===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 o=!1;if(Do(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"&&(o=!0,this._taskProgressTokens.set(a.taskId,n))}}if(o||this._progressHandlers.delete(n),Do(t))i(t);else{const s=Te.fromError(t.error.code,t.error.message,t.error.data);i(s)}}get transport(){return this._transport}async close(){await this._transport?.close()}async*requestStream(t,n,r){const{task:i}=r??{};if(!i){try{yield{type:"result",result:await this.request(t,n,r)}}catch(s){yield{type:"error",error:s instanceof Te?s:new Te(Re.InternalError,String(s))}}return}let o;try{const s=await this.request(t,Cf,r);if(s.task)o=s.task.taskId,yield{type:"taskCreated",task:s.task};else throw new Te(Re.InternalError,"Task creation did not return a task");for(;;){const a=await this.getTask({taskId:o},r);if(yield{type:"taskStatus",task:a},On(a.status)){a.status==="completed"?yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)}:a.status==="failed"?yield{type:"error",error:new Te(Re.InternalError,`Task ${o} failed`)}:a.status==="cancelled"&&(yield{type:"error",error:new Te(Re.InternalError,`Task ${o} was cancelled`)});return}if(a.status==="input_required"){yield{type:"result",result:await this.getTaskResult({taskId:o},n,r)};return}const u=a.pollInterval??this._options?.defaultTaskPollInterval??1e3;await new Promise(c=>setTimeout(c,u)),r?.signal?.throwIfAborted()}}catch(s){yield{type:"error",error:s instanceof Te?s:new Te(Re.InternalError,String(s))}}}request(t,n,r){const{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s,task:a,relatedTask:u}=r??{};return new Promise((c,l)=>{const d=g=>{l(g)};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(g){d(g);return}r?.signal?.throwIfAborted();const f=this._requestMessageId++,h={...t,jsonrpc:"2.0",id:f};r?.onprogress&&(this._progressHandlers.set(f,r.onprogress),h.params={...t.params,_meta:{...t.params?._meta||{},progressToken:f}}),a&&(h.params={...h.params,task:a}),u&&(h.params={...h.params,_meta:{...h.params?._meta||{},[Un]:u}});const p=g=>{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(g)}},{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(v=>this._onerror(new Error(`Failed to send cancellation: ${v}`)));const b=g instanceof Te?g:new Te(Re.RequestTimeout,String(g));l(b)};this._responseHandlers.set(f,g=>{if(!r?.signal?.aborted){if(g instanceof Error)return l(g);try{const b=Gb(n,g.result);b.success?c(b.data):l(b.error)}catch(b){l(b)}}}),r?.signal?.addEventListener("abort",()=>{p(r?.signal?.reason)});const m=r?.timeout??g$,y=()=>p(Te.fromError(Re.RequestTimeout,"Request timed out",{timeout:m}));this._setupTimeout(f,m,r?.maxTotalTimeout,y,r?.resetTimeoutOnProgress??!1);const w=u?.taskId;if(w){const g=b=>{const v=this._responseHandlers.get(f);v?v(b):this._onerror(new Error(`Response handler missing for side-channeled request ${f}`))};this._requestResolvers.set(f,g),this._enqueueTaskMessage(w,{type:"request",message:h,timestamp:Date.now()}).catch(b=>{this._cleanupTimeout(f),l(b)})}else this._transport.send(h,{relatedRequestId:i,resumptionToken:o,onresumptiontoken:s}).catch(g=>{this._cleanupTimeout(f),l(g)})})}async getTask(t,n){return this.request({method:"tasks/get",params:t},If,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},Lf,n)}async cancelTask(t,n){return this.request({method:"tasks/cancel",params:t},ex,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||{},[Un]: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||{},[Un]:n.relatedTask}}}),this._transport?.send(a,n).catch(u=>this._onerror(u))});return}let s={...t,jsonrpc:"2.0"};n?.relatedTask&&(s={...s,params:{...s.params,_meta:{...s.params?._meta||{},[Un]:n.relatedTask}}}),await this._transport.send(s,n)}setRequestHandler(t,n){const r=Yh(t);this.assertRequestHandlerCapability(r),this._requestHandlers.set(r,(i,o)=>{const s=Xh(t,i);return Promise.resolve(n(s,o))})}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=Yh(t);this._notificationHandlers.set(r,i=>{const o=Xh(t,i);return Promise.resolve(n(o))})}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 i=this._options?.maxTaskQueueSize;await this._taskMessageQueue.enqueue(t,n,r??this._transport?.sessionId,i)}async _clearTaskQueue(t,n){if(this._taskMessageQueue){const r=await this._taskMessageQueue.dequeueAll(t,n);for(const i of r)if(i.type==="request"&&Jh(i.message)){const o=i.message.id,s=this._requestResolvers.get(o);s?(s(new Te(Re.InternalError,"Task cancelled or completed")),this._requestResolvers.delete(o)):this._onerror(new Error(`Resolver missing for request ${o} during task ${t} cleanup`))}}}async _waitForTaskUpdate(t,n,r){let i=this._options?.defaultTaskPollInterval??1e3;try{const o=await this._taskStore?.getTask(t,r);o?.pollInterval&&(i=o.pollInterval)}catch{}return new Promise((o,s)=>{if(n.aborted){s(new Te(Re.InvalidRequest,"Request cancelled"));return}const a=setTimeout(o,i);n.addEventListener("abort",()=>{clearTimeout(a),s(new Te(Re.InvalidRequest,"Request cancelled"))},{once:!0})})}requestTaskStore(t,n){const r=this._taskStore;if(!r)throw new Error("No task store configured");return{createTask:async i=>{if(!t)throw new Error("No request provided");return await r.createTask(i,t.id,{method:t.method,params:t.params},n)},getTask:async i=>{const o=await r.getTask(i,n);if(!o)throw new Te(Re.InvalidParams,"Failed to retrieve task: Task not found");return o},storeTaskResult:async(i,o,s)=>{await r.storeTaskResult(i,o,s,n);const a=await r.getTask(i,n);if(a){const u=fs.parse({method:"notifications/tasks/status",params:a});await this.notification(u),On(a.status)&&this._cleanupTaskProgressHandler(i)}},getTaskResult:i=>r.getTaskResult(i,n),updateTaskStatus:async(i,o,s)=>{const a=await r.getTask(i,n);if(!a)throw new Te(Re.InvalidParams,`Task "${i}" not found - it may have been cleaned up`);if(On(a.status))throw new Te(Re.InvalidParams,`Cannot update task "${i}" from terminal status "${a.status}" to "${o}". Terminal states (completed, failed, cancelled) cannot transition to other states.`);await r.updateTaskStatus(i,o,s,n);const u=await r.getTask(i,n);if(u){const c=fs.parse({method:"notifications/tasks/status",params:u});await this.notification(c),On(u.status)&&this._cleanupTaskProgressHandler(i)}},listTasks:i=>r.listTasks(i,n)}}}function Qh(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function v$(e,t){const n={...e};for(const r in t){const i=r,o=t[i];if(o===void 0)continue;const s=n[i];Qh(s)&&Qh(o)?n[i]={...s,...o}:n[i]=o}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 b$ extends y${_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 i=r.shape.method.value;this._registeredMethods.add(i);let o=n;super.setNotificationHandler(r,s=>{let a=s.params;this.onEventDispatch(t,a),o.onHandler?.(a);for(let u of[...o.listeners])u(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 i=r.listeners.indexOf(n);i!==-1&&r.listeners.splice(i,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 w$="2026-01-26",_$="ui/notifications/tool-input-partial";class vw{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 i=OE.safeParse(r.data);i.success?(console.debug("Parsed message",i.data),this.onmessage?.(i.data)):r.data?.jsonrpc!=="2.0"?console.debug("Ignoring non-JSON-RPC message",i.error.message,r):(console.error("Failed to parse message",i.error.message,r),this.onerror?.(Error("Invalid JSON-RPC message received: "+i.error.message)))}}async start(){window.addEventListener("message",this.messageListener)}async send(t,n){t.method!==_$&&console.debug("Sending message",t),this.eventTarget.postMessage(t,"*")}async close(){window.removeEventListener("message",this.messageListener),this.onclose?.()}onclose;onerror;onmessage;sessionId;setProtocolVersion}var k$=ke([x("light"),x("dark")]).describe("Color theme preference for the host environment."),hi=ke([x("inline"),x("fullscreen"),x("pip")]).describe("Display mode for UI presentation."),S$=ke([x("--color-background-primary"),x("--color-background-secondary"),x("--color-background-tertiary"),x("--color-background-inverse"),x("--color-background-ghost"),x("--color-background-info"),x("--color-background-danger"),x("--color-background-success"),x("--color-background-warning"),x("--color-background-disabled"),x("--color-text-primary"),x("--color-text-secondary"),x("--color-text-tertiary"),x("--color-text-inverse"),x("--color-text-ghost"),x("--color-text-info"),x("--color-text-danger"),x("--color-text-success"),x("--color-text-warning"),x("--color-text-disabled"),x("--color-border-primary"),x("--color-border-secondary"),x("--color-border-tertiary"),x("--color-border-inverse"),x("--color-border-ghost"),x("--color-border-info"),x("--color-border-danger"),x("--color-border-success"),x("--color-border-warning"),x("--color-border-disabled"),x("--color-ring-primary"),x("--color-ring-secondary"),x("--color-ring-inverse"),x("--color-ring-info"),x("--color-ring-danger"),x("--color-ring-success"),x("--color-ring-warning"),x("--font-sans"),x("--font-mono"),x("--font-weight-normal"),x("--font-weight-medium"),x("--font-weight-semibold"),x("--font-weight-bold"),x("--font-text-xs-size"),x("--font-text-sm-size"),x("--font-text-md-size"),x("--font-text-lg-size"),x("--font-heading-xs-size"),x("--font-heading-sm-size"),x("--font-heading-md-size"),x("--font-heading-lg-size"),x("--font-heading-xl-size"),x("--font-heading-2xl-size"),x("--font-heading-3xl-size"),x("--font-text-xs-line-height"),x("--font-text-sm-line-height"),x("--font-text-md-line-height"),x("--font-text-lg-line-height"),x("--font-heading-xs-line-height"),x("--font-heading-sm-line-height"),x("--font-heading-md-line-height"),x("--font-heading-lg-line-height"),x("--font-heading-xl-line-height"),x("--font-heading-2xl-line-height"),x("--font-heading-3xl-line-height"),x("--border-radius-xs"),x("--border-radius-sm"),x("--border-radius-md"),x("--border-radius-lg"),x("--border-radius-xl"),x("--border-radius-full"),x("--border-width-regular"),x("--shadow-hairline"),x("--shadow-sm"),x("--shadow-md"),x("--shadow-lg")]).describe("CSS variable keys available to MCP apps for theming."),E$=Ee(S$.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.`),ke([
|
|
76
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`),ke([E(),pr()]).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.`);T({method:
|
|
88
|
+
for compatibility with Zod schema generation. Both are functionally equivalent for validation.`);T({method:x("ui/open-link"),params:T({url:E().describe("URL to open in the host's browser")})});var x$=T({isError:Pe().optional().describe("True if the host failed to open the URL (e.g., due to security policy).")}).passthrough(),$$=T({isError:Pe().optional().describe("True if the download failed (e.g., user cancelled or host denied).")}).passthrough(),T$=T({isError:Pe().optional().describe("True if the host rejected or failed to deliver the message.")}).passthrough();T({method:x("ui/notifications/sandbox-proxy-ready"),params:T({})});var Gf=T({connectDomains:ae(E()).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:ae(
|
|
91
|
+
- Empty or omitted → no network connections (secure default)`),resourceDomains:ae(E()).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:ae(E()).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:ae(E()).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'`)")}),jf=T({camera:T({}).optional().describe("Request camera access.\n\nMaps to Permission Policy `camera` feature."),microphone:T({}).optional().describe("Request microphone access.\n\nMaps to Permission Policy `microphone` feature."),geolocation:T({}).optional().describe("Request geolocation access.\n\nMaps to Permission Policy `geolocation` feature."),clipboardWrite:T({}).optional().describe("Request clipboard write access.\n\nMaps to Permission Policy `clipboard-write` feature.")});T({method:x("ui/notifications/size-changed"),params:T({width:ge().optional().describe("New width in pixels."),height:ge().optional().describe("New height in pixels.")})});var C$=T({method:x("ui/notifications/tool-input"),params:T({arguments:Ee(E(),Le().describe("Complete tool call arguments as key-value pairs.")).optional().describe("Complete tool call arguments as key-value pairs.")})}),A$=T({method:x("ui/notifications/tool-input-partial"),params:T({arguments:Ee(E(),Le().describe("Partial tool call arguments (incomplete, may change).")).optional().describe("Partial tool call arguments (incomplete, may change).")})}),I$=T({method:x("ui/notifications/tool-cancelled"),params:T({reason:E().optional().describe('Optional reason for the cancellation (e.g., "user action", "timeout").')})}),N$=T({fonts:E().optional()}),R$=T({variables:E$.optional().describe("CSS variables for theming the app."),css:N$.optional().describe("CSS blocks that apps can inject.")}),L$=T({method:x("ui/resource-teardown"),params:T({})});Ee(E(),Le());var ep=T({text:T({}).optional().describe("Host supports text content blocks."),image:T({}).optional().describe("Host supports image content blocks."),audio:T({}).optional().describe("Host supports audio content blocks."),resource:T({}).optional().describe("Host supports resource content blocks."),resourceLink:T({}).optional().describe("Host supports resource link content blocks."),structuredContent:T({}).optional().describe("Host supports structured content.")});T({method:x("ui/notifications/request-teardown"),params:T({}).optional()});var z$=T({experimental:Ee(E(),Ee(E(),lo()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),openLinks:T({}).optional().describe("Host supports opening external URLs."),downloadFile:T({}).optional().describe("Host supports file downloads via ui/download-file."),serverTools:T({listChanged:Pe().optional().describe("Host supports tools/list_changed notifications.")}).optional().describe("Host can proxy tool calls to the MCP server."),serverResources:T({listChanged:Pe().optional().describe("Host supports resources/list_changed notifications.")}).optional().describe("Host can proxy resource reads to the MCP server."),logging:T({}).optional().describe("Host accepts log messages."),sandbox:T({permissions:jf.optional().describe("Permissions granted by the host (camera, microphone, geolocation)."),csp:Gf.optional().describe("CSP domains approved by the host.")}).optional().describe("Sandbox configuration applied by the host."),updateModelContext:ep.optional().describe("Host accepts context updates (ui/update-model-context) to be included in the model's context for future turns."),message:ep.optional().describe("Host supports receiving content messages (ui/message) from the view."),sampling:T({tools:T({}).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.")}),P$=T({experimental:Ee(E(),Ee(E(),lo()).describe("Experimental features keyed by identifier.")).optional().describe("Experimental features keyed by identifier."),tools:T({listChanged:Pe().optional().describe("App supports tools/list_changed notifications.")}).optional().describe("App exposes MCP-style tools that the host can call."),availableDisplayModes:ae(hi).optional().describe("Display modes the app supports.")});T({method:x("ui/notifications/initialized"),params:T({}).optional()});T({csp:Gf.optional().describe("Content Security Policy configuration for UI resources."),permissions:jf.optional().describe("Sandbox permissions requested by the UI resource."),domain:E().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
|
|
|
@@ -102,16 +102,16 @@ Boolean requesting whether a visible border and background is provided by the ho
|
|
|
102
102
|
|
|
103
103
|
- \`true\`: request visible border + background
|
|
104
104
|
- \`false\`: request no visible border + background
|
|
105
|
-
- omitted: host decides border`)});T({method:
|
|
105
|
+
- omitted: host decides border`)});T({method:x("ui/request-display-mode"),params:T({mode:hi.describe("The display mode being requested.")})});var O$=T({mode:hi.describe("The display mode that was actually set. May differ from requested if not supported.")}).passthrough(),D$=ke([x("model"),x("app")]).describe("Tool visibility scope - who can access the tool.");T({resourceUri:E().optional(),visibility:ae(D$).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:Wn().optional(),permissions:Wn().optional()});T({mimeTypes:ae(
|
|
108
|
-
container holding the app. Specify either width or maxWidth, and either height or maxHeight.`),locale:x().optional().describe("User's language and region preference in BCP 47 format."),timeZone:x().optional().describe("User's timezone in IANA format."),userAgent:x().optional().describe("Host application identifier."),platform:ke([E("web"),E("desktop"),E("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:T({touch:Pe().optional().describe("Whether the device supports touch input."),hover:Pe().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:T({top:ge().describe("Top safe area inset in pixels."),right:ge().describe("Right safe area inset in pixels."),bottom:ge().describe("Bottom safe area inset in pixels."),left:ge().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),D$=T({method:E("ui/notifications/host-context-changed"),params:yw.describe("Partial context update containing only changed fields.")});T({method:E("ui/update-model-context"),params:T({content:ae(Eo).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:xe(x(),Le().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});T({method:E("ui/initialize"),params:T({appInfo:ja.describe("App identification (name and version)."),appCapabilities:R$.describe("Features and capabilities this app provides."),protocolVersion:x().describe("Protocol version this app supports.")})});var O$=T({protocolVersion:x().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:ja.describe("Host application identification and version."),hostCapabilities:N$.describe("Features and capabilities provided by the host."),hostContext:yw.describe("Rich context about the host environment.")}).passthrough(),M$={target:"draft-2020-12"};async function ep(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](M$);if(n.vendor==="zod"){let{z:r}=await tk(()=>Promise.resolve().then(()=>Tx),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 tp(e,t,n=""){let r=await e["~standard"].validate(t);if(r.issues){let i=r.issues.map(o=>{let s=o.path?.map(a=>typeof a=="object"?a.key:a).join(".");return s?`${s}: ${o.message}`:o.message}).join("; ");throw Error(n+i)}return r.value}function F$(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function U$(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 Zf extends g${_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:E$,toolinputpartial:$$,toolresult:P$,toolcancelled:T$,hostcontextchanged:D$};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!Zf.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||et({jitless:!0}),this.setRequestHandler(Za,i=>(console.log("Received ping:",i.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=m$(this._capabilities,t)}registerTool(t,n,r){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let i=this,o=()=>{i._initializedSent&&i._capabilities.tools?.listChanged&&i.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,o()},disable(){this.enabled=!1,o()},update(u){Object.assign(this,u),o()},remove(){i._registeredTools[t]===a&&(delete i._registeredTools[t],o())},handler:async(u,c)=>{if(!a.enabled)throw Error(`Tool ${t} is disabled`);let l;if(s){let d=a.inputSchema,f=d?await tp(d,u??{},`Invalid input for tool ${t}: `):u??{};l=await r(f,c)}else l=await r(c);return a.outputSchema&&!l.isError&&(l.structuredContent=await tp(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(),o(),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,i])=>i.enabled).map(async([r,i])=>{let o={name:r,title:i.title,description:i.description,inputSchema:i.inputSchema?await ep(i.inputSchema,"input"):{type:"object",properties:{}}};return i.outputSchema&&(o.outputSchema=await ep(i.outputSchema,"output")),i.annotations&&(o.annotations=i.annotations),i._meta&&(o._meta=i._meta),o}))}))}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(I$,(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(fw,(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(dw,(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},Ba,{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},uw,n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},aw,n)}async createSamplingMessage(t,n){this._assertInitialized("createSamplingMessage");let r=t.tools?mw:pw;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},x$,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},Ef,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},k$,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},S$,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},L$,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,r=0,i=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let s=document.documentElement,a=s.style.height;s.style.height="max-content";let u=Math.ceil(s.getBoundingClientRect().height);s.style.height=a;let c=Math.ceil(window.innerWidth);(c!==n||u!==r)&&(n=c,r=u,this.sendSizeChanged({width:c,height:u}))}))};i();let o=new ResizeObserver(i);return o.observe(document.documentElement),o.observe(document.body),()=>o.disconnect()}async connect(t=new gw(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:y$}},O$,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 G$="Chain Insights graph",j$="This graph is no longer available. Ask for it again.",ts=e=>!!e&&typeof e=="object"&&!Array.isArray(e),Z$=new Set(["127.0.0.1","localhost","[::1]","::1"]);function B$(e){const t=new URLSearchParams(e.search).get("view");if(t&&t.trim())return t.trim();if(!Z$.has(e.hostname))return null;const n=/^\/view\/([^/]+)\/?$/.exec(e.pathname);if(!n?.[1])return null;try{return decodeURIComponent(n[1])||null}catch{return null}}async function H$(e,t){try{const n=await t(`/api/view/${encodeURIComponent(e)}`,{headers:{Accept:"application/json"}});if(!n.ok)return null;const r=await n.json();return!ts(r)||!ts(r.result)?null:{arguments:ts(r.arguments)?r.arguments:null,result:r.result}}catch{return null}}function V$(e,t){return{async callServerTool({name:n,arguments:r}){const i=await e(`/api/tools/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({arguments:r})});let o=null;try{o=await i.json()}catch{o=null}if(ts(o)&&(Array.isArray(o.content)||"structuredContent"in o||"isError"in o))return o;throw new Error(i.ok?"the local Chain Insights page answered with no tool result":`the local Chain Insights page answered HTTP ${i.status}`)},async openLink({url:n}){return t(n,"_blank","noopener"),{}}}}const vw=new Map;function q$(e,t){vw.set(e,t)}function np(e){return vw.get(e)??null}const W$=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i;function K$(e){try{const t=e.createElement("canvas");if(typeof t.getContext!="function")return!1;const n={failIfMajorPerformanceCaveat:!0},r=t.getContext("webgl2",n)??t.getContext("webgl",n);if(!r)return!1;const i=r.getExtension?.("WEBGL_debug_renderer_info"),o=String(i?r.getParameter(i.UNMASKED_RENDERER_WEBGL):r.getParameter(r.RENDERER)??"");return W$.test(o)?(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!1):(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!0)}catch{return!1}}const J$="http://www.w3.org/2000/svg";let Y$=0;function Mo(e){return Math.round(e*10)/10}function X$(e,t,n={}){const r=e.createElementNS(J$,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}function rp(e,t,n,r){const i=`cia-graph-svg-${++Y$}`,o=e.ownerDocument,s=(F,B)=>X$(o,F,B),a=(F,B,W)=>{const Q=s("text",{x:0,y:B,"text-anchor":"middle",class:W,"pointer-events":"none"});return Q.textContent=F,Q},{width:u,height:c}=t.dimensions(),l=s("svg",{class:"cia-graph-svg",viewBox:`0 0 ${u} ${c}`,role:"group",tabindex:0,"aria-label":r.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."}),d=s("defs"),f=s("pattern",{id:`${i}-dots`,width:24,height:24,patternUnits:"userSpaceOnUse"});f.append(s("circle",{class:"cia-graph-dot",cx:1,cy:1,r:1})),d.append(f);const h=s("rect",{class:"cia-graph-backdrop",width:"100%",height:"100%","data-canvas":""}),p=s("rect",{class:"cia-graph-dots",width:"100%",height:"100%",fill:`url(#${i}-dots)`,"data-canvas":""}),m=s("g",{"data-viewport":""}),y=s("g",{"data-edges":"",class:"cia-graph-edges"}),w=s("g",{"data-nodes":"",class:"cia-graph-nodes"});m.append(y,w),l.append(d,h,p,m),e.append(l);const g=new Map,b=new Map,v=new Map;let k=null;function _(){if(k)return k;const F=t.model(),B=t.positions(),W=new Map;k=W;const Q=F.nodes.length>GT,K=new Map(F.nodes.map(R=>[R.address,R])),I=Q?[]:RT(F,B,t.notes());for(const R of F.edges){const U=K.get(R.from),ne=K.get(R.to),ce=U&&B[U.id],ee=ne&&B[ne.id];if(!U||!ne||!ce||!ee){W.set(R.id,null);continue}if(Q){W.set(R.id,Ju(ce,ee,jn(U,F.checked_address),jn(ne,F.checked_address)));continue}const Ee=I.filter(Ae=>Ae.id!==U.id&&Ae.id!==ne.id);W.set(R.id,jT(ce,ee,jn(U,F.checked_address),jn(ne,F.checked_address),Ee))}return W}function $(F){let B=g.get(F);if(B)return B;B=`${i}-arrow-${g.size}`;const W=s("marker",{id:B,viewBox:"0 0 10 10",refX:9,refY:5,markerWidth:6,markerHeight:6,orient:"auto-start-reverse",markerUnits:"strokeWidth"}),Q=s("path",{d:"M0 0L10 5L0 10Z",class:"cia-graph-arrowhead"});return Q.style.fill=F,W.append(Q),d.append(W),g.set(F,B),B}function O(){return[...t.model().nodes??[]].sort((F,B)=>String(F.id).localeCompare(String(B.id)))}function M(){k=null;const F=t.model();y.replaceChildren(),w.replaceChildren(),b.clear(),v.clear();const B=new Map(F.nodes.map(W=>[W.address,W]));for(const W of F.edges){const Q=B.get(W.from);if(!Q||!B.get(W.to))continue;const K=t.colorOf(Q),I=s("g",{class:"cia-graph-edge graph-edge",tabindex:0,role:"button","aria-label":tc(W,t.now())});I.dataset.edgeId=W.id,I.style.setProperty("--edge-tone",K);const R=BT(),U=s("path",{class:"cia-graph-edge-hit","stroke-width":R.hit.width,"pointer-events":"stroke"}),ne=s("path",{class:"cia-graph-edge-line","stroke-width":R.line.width,"marker-end":`url(#${$(K)})`,"pointer-events":"none"});I.append(U,ne),I.addEventListener("keydown",ce=>{dp(ce.key)&&(ce.preventDefault(),n.selectEdge(W.id,"keyboard"))}),I.addEventListener("pointerenter",ce=>n.showTooltip(ce,tc(W,t.now()))),I.addEventListener("pointerleave",()=>n.hideTooltip()),y.append(I),v.set(W.id,{group:I,hit:U,line:ne})}for(const W of O())w.append(D(W));se(),_e()}function D(F){const B=t.model(),W=F.address===B.checked_address,Q=t.notes().get(F.id),K=jr(F,B.checked_address,Q),I=K.radius,R=s("g",{class:"cia-graph-node graph-node",tabindex:0,role:"button","aria-label":ec(F),"aria-pressed":"false"});R.dataset.nodeId=F.id,W&&(R.dataset.checked=""),R.style.setProperty("--node-tone",t.colorOf(F)),W&&R.append(s("circle",{class:"cia-graph-node-ring",r:I+6})),R.append(s("circle",{class:"cia-graph-node-body",r:I})),R.append(s("circle",{class:"cia-graph-node-dot",r:K.dot}));for(const U of K.texts)R.append(a(U.text,U.y,`cia-graph-node-${U.kind}`));Q&&(R.dataset.state="refused");for(const U of t.flags().get(F.id)??[])R.setAttribute(`data-flag-${U}`,"");return R.addEventListener("keydown",U=>{dp(U.key)&&(U.preventDefault(),n.selectNode(F.id,"keyboard"))}),R.addEventListener("pointerenter",U=>n.showTooltip(U,ec(F))),R.addEventListener("pointerleave",()=>n.hideTooltip()),b.set(F.id,R),R}function J(){const F=t.transform();m.setAttribute("transform",`translate(${F.x} ${F.y}) scale(${F.scale})`)}function se(){J();const F=t.positions(),{width:B,height:W}=t.dimensions();for(const[K,I]of b){const R=F[K]??{x:B/2,y:W/2};I.setAttribute("transform",`translate(${Mo(R.x)} ${Mo(R.y)})`)}const Q=_();for(const K of t.model().edges){const I=v.get(K.id);if(!I)continue;const R=Q.get(K.id)??null;I.group.style.display=R?"":"none",R&&(I.hit.setAttribute("d",R.d),I.line.setAttribute("d",R.d))}}function we(F){const B=t.model(),W=t.positions(),Q=W[F],K=b.get(F);if(!Q||!K)return;K.setAttribute("transform",`translate(${Mo(Q.x)} ${Mo(Q.y)})`);const I=B.nodes.find(U=>U.id===F);if(!I)return;const R=new Map(B.nodes.map(U=>[U.address,U]));for(const U of B.edges){if(U.from!==I.address&&U.to!==I.address)continue;const ne=v.get(U.id),ce=R.get(U.from),ee=R.get(U.to),Ee=ce&&W[ce.id],Ae=ee&&W[ee.id];if(!ne||!ce||!ee||!Ee||!Ae)continue;const z=Ju(Ee,Ae,jn(ce,B.checked_address),jn(ee,B.checked_address));ne.group.style.display=z?"":"none",z&&(ne.hit.setAttribute("d",z.d),ne.line.setAttribute("d",z.d))}}function _e(){const F=t.model(),B=t.selected(),W=t.highlighted(),Q=B?.kind==="node"?F.nodes.find(K=>K.id===B.id)?.address??null:null;for(const K of F.edges){const I=v.get(K.id);if(!I)continue;const R=B?.kind==="edge"&&B.id===K.id,U=B?.kind==="edge"?R?Xt.related:Xt.faded:Sw(K,Q),ne=U===Xt.faded;I.group.setAttribute("opacity",ne?String(U):"1"),I.line.setAttribute("stroke-opacity",ne?"1":String(U)),I.group.dataset.opacity=String(U),I.group.dataset.state=U===Xt.rest?"rest":U===Xt.related?"related":"faded",I.group.setAttribute("aria-pressed",String(R))}for(const[K,I]of b){const R=B?.kind==="node"&&B.id===K;I.classList.toggle("is-selected",R),I.classList.toggle("is-focused",W===K),I.setAttribute("aria-pressed",String(R))}}function Ge(){let F=null;for(const B of _().values())B?.bounds&&(F=F??{...B.bounds},F.x1=Math.min(F.x1,B.bounds.x1),F.y1=Math.min(F.y1,B.bounds.y1),F.x2=Math.max(F.x2,B.bounds.x2),F.y2=Math.max(F.y2,B.bounds.y2));return F}return{kind:"svg",surface:l,build:M,geometry(){k=null,se()},moveNode:we,endMove(){k=null,se()},camera:J,selection:_e,flag(F,B,W){b.get(F)?.toggleAttribute(`data-flag-${B}`,W)},theme(){for(const F of t.model().nodes)b.get(F.id)?.style.setProperty("--node-tone",t.colorOf(F))},resize(F,B){l.setAttribute("viewBox",`0 0 ${F} ${B}`)},pick:()=>null,linkBounds:Ge,destroy(){l.remove()}}}const Q$=.45,eT=2.5,tT=5,nT="chain-insights.flows.v1",Bf="cia-graph-model",rT=90,Xt={rest:.6,related:.95,faded:.07},ip={checked:24,other:19},pi=16,iT=[["Sanctioned","Sanctioned"],["Scam","Scam"],["Poisoned","Poisoned"],["OnMoneyTrail","On money trail"],["Mixer","Mixer"],["Bridge","Bridge"],["Exchange","Exchange"],["Victim","Victim"],["Targeted","Targeted"]],$o=["exchange","scam","sanctioned","victim","pool","other"],oT={exchange:"infrastructure",scam:"danger",sanctioned:"danger",victim:"target",pool:"trail",other:"neutral"},bw={exchange:"Exchange",scam:"Scam",sanctioned:"Sanctioned",victim:"Victim",pool:"Pool",other:""};function Hf(e){return!!e&&e.schema===nT}function sT(e){return!!e&&e.kind===Bf}function Ke(e){return String(e??"").trim().toLowerCase()}function aT(e){const t=Ke(e);return $o.includes(t)?t:"other"}function bn(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Wu(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function uT(e){const t=String(e??"").toUpperCase();return t==="IN"||t==="OUT"||t==="MIXED"||t==="CHECKED"?t:"OUT"}function Pt(e){return sT(e)?e:Hf(e)?cT(e):dT(e)}function cT(e){const t=Ke(e.center),n=new Map;for(const a of e.nodes??[]){const u=Ke(a?.address);u&&!n.has(u)&&n.set(u,a)}const r=[],i=new Set;for(const a of e.edges??[]){const u=Ke(a?.from),c=Ke(a?.to);if(!n.has(u)||!n.has(c)||u===c)continue;const l=`${u}->${c}`;i.has(l)||(i.add(l),r.push({id:l,from:u,to:c,source:"flows",amount_usd_sum:bn(a.usd),tx_count:bn(a.tx_count),first_seen_timestamp:bn(a.first_seen_ms),last_seen_timestamp:bn(a.last_seen_ms),...typeof a.link_kind=="string"&&a.link_kind?{link_kind:a.link_kind}:{}}))}const o=lT(t,[...n.keys()],r),s=[...n.entries()].map(([a,u])=>{const c=o.get(a)??{direction:"OUT",hop:2};return{id:a,address:a,direction:a===t?"CHECKED":c.direction,hop:a===t?0:c.hop,labels:Wu(u.labels),taxonomy:[],role:aT(u.role),total_in_usd:bn(u.total_in_usd),total_out_usd:bn(u.total_out_usd),degree_in:bn(u.degree_in),degree_out:bn(u.degree_out)}});return{kind:Bf,checked_address:t,network:e.network??null,nodes:s,edges:r,truncated:!!e.truncated,cursor:e.cursor??null}}function lT(e,t,n){const r=new Map,i=new Map,o=new Map,s=(d,f,h)=>d.set(f,[...d.get(f)??[],h]);for(const d of n)s(r,d.from,d.to),s(i,d.to,d.from),s(o,d.from,d.to),s(o,d.to,d.from);const a=d=>{const f=new Map([[e,0]]);for(let h=[e];h.length;){const p=[];for(const m of h)for(const y of d.get(m)??[])f.has(y)||(f.set(y,(f.get(m)??0)+1),p.push(y));h=p}return f},u=a(r),c=a(i),l=new Map;for(const d of t){if(d===e)continue;const f=u.get(d),h=c.get(d);if(f==null&&h==null)continue;const p=f!=null&&h!=null?f<h?"OUT":h<f?"IN":"MIXED":f!=null?"OUT":"IN";l.set(d,{direction:p,hop:Math.min(2,Math.min(f??1/0,h??1/0))})}for(let d=!0;d;){d=!1;for(const f of t){if(f===e||l.has(f))continue;const h=(o.get(f)??[]).find(m=>m!==e&&l.has(m));if(h==null)continue;const p=l.get(h);l.set(f,{direction:p.direction==="MIXED"?"OUT":p.direction,hop:2}),d=!0}}return l}function dT(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":uT(r.direction),labels:Wu(r.labels),taxonomy:Wu(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:Bf,checked_address:e?.checked_address??"",network:null,nodes:t,edges:n,truncated:!1,cursor:null}}function fT(e,t,n){const r=Pt(t),i=Gn(e,n??r.checked_address),o=e.nodes.find(d=>d.id===i),s=new Map(e.nodes.map(d=>[Ke(d.address),d])),a=[];for(const d of r.nodes){if(s.has(Ke(d.address)))continue;const f=!o||o.direction==="CHECKED"?d.direction==="CHECKED"?"OUT":d.direction:o.direction,h={...d,id:d.id,direction:f,hop:Math.min(2,(o?.hop??0)+1)};a.push(h),s.set(Ke(d.address),h)}const u=new Set(e.edges.map(d=>d.id)),c=new Set(e.edges.map(d=>`${Ke(d.from)}->${Ke(d.to)}`)),l=[...e.edges];for(const d of r.edges){const f=`${Ke(d.from)}->${Ke(d.to)}`;if(u.has(d.id)||c.has(f)||!s.has(Ke(d.from))||!s.has(Ke(d.to)))continue;const h=s.get(Ke(d.from)).address,p=s.get(Ke(d.to)).address;l.push({...d,from:h,to:p}),u.add(d.id),c.add(f)}return{model:{...e,nodes:[...e.nodes,...a],edges:l,truncated:e.truncated||r.truncated},added:a.map(d=>d.id)}}function Gn(e,t){if(t==null)return null;const n=Ke(t);return e.nodes.find(i=>i.id===t||Ke(i.address)===n)?.id??null}function mi(e){return typeof e!="string"||e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function Vf(e){return String(e??"").trim().replace(/\s+/g," ")}function ps(e){return Vf(e).replaceAll(" ","").toLowerCase()}function An(e){const t=[...e.taxonomy??[],...e.labels??[]],n=new Set,r=[];for(const i of t){const o=Vf(i),s=o.toLowerCase();!o||s==="address"||n.has(s)||(n.add(s),r.push(o))}return r}function Fo(e,t){const n=new Set(An(e).map(ps));return t.some(r=>n.has(ps(r)))}function hT(e){if(e.role&&$o.includes(e.role))return oT[e.role];if(Fo(e,["Sanctioned","Scam","Poisoned"]))return"danger";if(Fo(e,["Victim","Targeted"]))return"target";if(Fo(e,["OnMoneyTrail","Mixer"]))return"trail";if(Fo(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 We(e){return`var(--cia-graph-${e})`}const pT={semantic:{danger:{stroke:We("danger"),fill:We("node")},target:{stroke:We("target"),fill:We("node")},trail:{stroke:We("trail"),fill:We("node")},infrastructure:{stroke:We("infrastructure"),fill:We("node")},neutral:{stroke:We("neutral"),fill:We("node")}},risk:{CRITICAL:{stroke:We("critical"),fill:We("node")},HIGH:{stroke:We("high"),fill:We("node")},MEDIUM:{stroke:We("medium"),fill:We("node")},LOW:{stroke:We("low"),fill:We("node")}}};function mT(e,t=pT){const n=hT(e);return n==="critical"||n==="high"||n==="medium"||n==="low"?t.risk[n.toUpperCase()]??t.semantic.neutral:t.semantic[n]}function gT(e){return e.role&&$o.includes(e.role)?We(`role-${e.role}`):mT(e).stroke}function To(e){if(e.role&&e.role!=="other"&&$o.includes(e.role))return bw[e.role];const t=An(e);for(const[r,i]of iT)if(t.some(o=>ps(o)===ps(r)))return i;return(Array.isArray(e.labels)?e.labels.map(Vf).filter(Boolean).sort((r,i)=>r.localeCompare(i)):[])[0]??""}function Ku(e){return Math.min(eT,Math.max(Q$,e))}function Ha(e){return[...e.nodes??[]].sort((t,n)=>String(t.id).localeCompare(String(n.id)))}function qf(e,t=Ha(e)){return t.find(n=>n.address===e.checked_address)??t[0]}function op(e,t){return e.address===t?43:e.hop>=2?25:30}function jn(e,t){return e.address===t?ip.checked:ip.other}function jr(e,t,n){const r=e.address===t,i=jn(e,t),o=To(e),s=[];return o&&s.push({kind:"role",text:iC(o),y:i+17}),s.push({kind:"address",text:mi(e.address),y:i+(o?33:17)}),n&&s.push({kind:"note",text:n,y:i+(o?48:32)}),{radius:i,ring:r,dot:r?8:5,texts:s}}const yT={role:{size:13,advance:.68},address:{size:11,advance:.62},note:{size:11,advance:.6}},ou=2;function Wf(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 i=yT[r.kind],o=[...r.text].length*i.size*i.advance/2+ou;n.push({kind:r.kind,box:{x1:-o,y1:r.y-i.size*.8-ou,x2:o,y2:r.y+i.size*.25+ou}})}return n}function ww(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 _w(e){return ww(Wf(e).map(t=>t.box))}const Kf=(e,t)=>(e instanceof Map?e.get(t):e?.[t])??null;function vT(e,t,n){const r=Pt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of Wf(jr(o,r.checked_address,Kf(n,o.id))))i.push({id:o.id,kind:a,x1:s.x+u.x1,y1:s.y+u.y1,x2:s.x+u.x2,y2:s.y+u.y2})}return i}function bT(e,t,n){return ww(vT(e,t,n))}function wT(e,t){return e.x1<t.x2&&t.x1<e.x2&&e.y1<t.y2&&t.y1<e.y2}function _T(e){let t=0;for(const n of String(e))t=(t<<5)-t+n.charCodeAt(0)|0;return Math.abs(t)}function kT(e,t,n){const r=Pt(e),i={x:t/2,y:n/2},o={},s=Ha(r),a=qf(r,s);if(!a)return o;o[a.id]=i;const u=new Map;for(const c of s){if(c.id===a.id)continue;let l=c.direction==="IN"?-1:1;c.direction==="MIXED"&&(l=_T(c.id)%2?-1:1);const d=Math.min(2,Math.max(1,Number(c.hop)||1)),f=`${l}:${d}`;u.has(f)||u.set(f,[]),u.get(f).push(c)}for(const[c,l]of u){const[d,f]=c.split(":"),h=Number(d),p=Number(f),m=i.x+h*(p===1?t*.23:t*.43);Object.assign(o,ST(l,m,i.y,r.checked_address))}return o}function ST(e,t,n,r,i=24){const o=e.map((u,c)=>({node:u,x:t,y:n+(c-(e.length-1)/2)*64})),s=u=>_w(jr(u,r)),a=(u,c)=>Math.max(op(u,r)+op(c,r)+20,s(u).y2-s(c).y1+2);for(let u=0;u<i;u++){for(let d=1;d<o.length;d++){const f=o[d-1],h=o[d];!f||!h||(h.y=Math.max(h.y,f.y+a(f.node,h.node)))}for(let d=o.length-2;d>=0;d--){const f=o[d],h=o[d+1];!f||!h||(f.y=Math.min(f.y,h.y-a(f.node,h.node)))}const c=o[0],l=o[o.length-1];if(c&&l){const d=(c.y+l.y)/2,f=n-d;for(const h of o)h.y+=f}}return Object.fromEntries(o.map(u=>[u.node.id,{x:u.x,y:u.y}]))}function xT(e,t,n){const r=Pt(e),i={x:t/2,y:n/2},o={},s=Ha(r),a=qf(r,s);if(!a)return o;o[a.id]=i;const u=s.filter(c=>c.id!==a.id);return u.forEach((c,l)=>{const d=-Math.PI/2+l*Math.PI*2/Math.max(1,u.length),f=c.hop>=2?Math.min(t,n)*.39:Math.min(t,n)*.27;o[c.id]={x:i.x+Math.cos(d)*f,y:i.y+Math.sin(d)*f}}),o}function ET(e,t,n,r){const i=Pt(e),o=Ha(i).filter(u=>t[u.id]),s=o.find(u=>u.address===i.checked_address);for(let u=0;u<o.length;u++)for(let c=u+1;c<o.length;c++){const l=o[u],d=o[c],f=l&&t[l.id],h=d&&t[d.id];if(!f||!h)continue;const p=h.x-f.x||.1,m=h.y-f.y||.1,y=Math.max(1,Math.hypot(p,m)),w=Math.max(0,88-y)*.012;f.x-=p/y*w,f.y-=m/y*w,h.x+=p/y*w,h.y+=m/y*w}const a=new Map(o.map(u=>[u.address,u]));for(const u of i.edges){const c=a.get(u.from),l=a.get(u.to);if(!c||!l)continue;const d=t[c.id],f=t[l.id];if(!d||!f)continue;const h=f.x-d.x,p=f.y-d.y,m=Math.max(1,Math.hypot(h,p)),y=(m-155)*.003;c!==s&&(d.x+=h/m*y,d.y+=p/m*y),l!==s&&(f.x-=h/m*y,f.y-=p/m*y)}return s&&(t[s.id]={x:n/2,y:r/2}),t}function $T(e,t,n,r=rT){const i=Pt(e),o=xT(i,t,n);for(let s=0;s<r;s++)ET(i,o,t,n);return o}function Uo(e,t,n,r){return t==="tree"?kT(e,n,r):$T(e,n,r)}function TT(e,t,n,r,i={}){const o=Pt(e),s=t[n],a={...t};if(!s)return a;const u=i.spacing??80,c=i.gap??48,l=Math.max(1,i.perColumn??6),d=o.nodes.find(g=>g.id===n),f=new Map(o.nodes.map(g=>[g.id,g])),h=g=>_w(jr(g,o.checked_address,Kf(i.notes,g.id))),p=o.nodes.flatMap(g=>{const b=t[g.id];if(!b)return[];const v=h(g);return[{x1:b.x+v.x1,x2:b.x+v.x2}]});let m=p.length?Math.min(...p.map(g=>g.x1)):s.x,y=p.length?Math.max(...p.map(g=>g.x2)):s.x;const w={left:[],right:[]};for(const g of[...r].sort()){const b=f.get(g);if(!b||a[g])continue;const v=o.edges.some(_=>_.from===b.address&&_.to===d?.address),k=o.edges.some(_=>_.to===b.address&&_.from===d?.address);w[v&&!k?"left":"right"].push(b)}for(const g of["left","right"]){const b=w[g];for(let v=0;v<b.length;v+=l){const k=b.slice(v,v+l),_=k.map(h),$=Math.max(..._.map(D=>Math.max(-D.x1,D.x2))),O=Math.max(u,Math.max(..._.map(D=>D.y2))-Math.min(..._.map(D=>D.y1))+6),M=g==="left"?m-c-$:y+c+$;k.forEach((D,J)=>{a[D.id]={x:M,y:s.y+(J-(k.length-1)/2)*O}}),g==="left"?m=M-$:y=M+$}}return a}function CT(e,t,n,r=pi){const i=Math.max(1,e.x2-e.x1),o=Math.max(1,e.y2-e.y1),s=Ku(Math.min((t-r*2)/i,(n-r*2)/o));return{x:t/2-(e.x1+e.x2)/2*s,y:n/2-(e.y1+e.y2)/2*s,scale:s}}function sp(e,t,n,r=pi){return Math.min((t-r*2)/Math.max(1,e.x2-e.x1),(n-r*2)/Math.max(1,e.y2-e.y1))}function AT(e,t,n,r,i=4){const o=t.x-e.x,s=t.y-e.y,a=Math.hypot(o,s),u=n+i,c=r+i;if(!Number.isFinite(a)||a<=0||u+c>=a)return null;const l=o/a,d=s/a;return{x1:e.x+l*u,y1:e.y+d*u,x2:t.x-l*c,y2:t.y-d*c}}function En(e){return Math.round(e*100)/100}function su(e,t,n,r,i){const o=s=>`${En(s.x)},${En(s.y)}`;return{kind:e,start:t,end:i,controls:[n,r],d:`M${o(t)} C${o(n)} ${o(r)} ${o(i)}`}}function Ju(e,t,n,r,i=4){const o=t.x-e.x,s=t.y-e.y,a=Math.hypot(o,s),u=n+r+i*2;if(!Number.isFinite(a)||a<=u)return null;if(o>=u){const f={x:e.x+n+i,y:e.y},h={x:t.x-r-i,y:t.y},p=h.x-f.x,m=Math.max(p*.45,Math.min(65,p));return su("forward",f,{x:f.x+m,y:f.y},{x:h.x-m,y:h.y},h)}if(o<=-u){const f={x:e.x,y:e.y-n-i},h={x:t.x,y:t.y-r-i},p=Math.max(100,Math.abs(o)*.2);return su("backward",f,{x:f.x+85,y:f.y-p},{x:h.x+85,y:h.y-p},h)}if(Math.abs(s)>u){const f=s>0?1:-1,h={x:e.x,y:e.y+f*(n+i)},p={x:t.x,y:t.y-f*(r+i)},m=Math.abs(p.y-h.y),y=Math.max(m*.45,Math.min(40,m));return su("vertical",h,{x:h.x,y:h.y+f*y},{x:p.x,y:p.y-f*y},p)}const c=AT(e,t,n,r,i),l={x:c.x1,y:c.y1},d={x:c.x2,y:c.y2};return{kind:"straight",start:l,end:d,controls:null,d:`M${En(l.x)},${En(l.y)} L${En(d.x)},${En(d.y)}`}}const IT=6,au=IT+3,Yt=14,ap=10,NT=3,up=6;function RT(e,t,n){const r=Pt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of Wf(jr(o,r.checked_address,Kf(n,o.id))))a==="circle"?i.push({id:o.id,kind:"circle",x:s.x,y:s.y,r:u.x2}):i.push({id:o.id,kind:"box",x1:s.x+u.x1,y1:s.y+u.y1,x2:s.x+u.x2,y2:s.y+u.y2})}return i}function LT(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 zT(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 PT(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 DT(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 kw(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 OT(e,t){const n=[];for(const r of e){const i=Math.max(1,Math.ceil(kw(r.points)/t));for(let o=0;o<=i;o++){const s=o/i;if(r.kind==="L"){const[a,u]=r.points;n.push({x:a.x+(u.x-a.x)*s,y:a.y+(u.y-a.y)*s})}else n.push(PT(r.points,s))}}return n}function cp(e,t,n,r){const i=e.flatMap(a=>a.points),o={x1:Math.min(...i.map(a=>a.x)),y1:Math.min(...i.map(a=>a.y)),x2:Math.max(...i.map(a=>a.x)),y2:Math.max(...i.map(a=>a.y))},s=[];if(n.forEach((a,u)=>{a.x1<=o.x2&&o.x1<=a.x2&&a.y1<=o.y2&&o.y1<=a.y2&&s.push(u)}),!s.length)return!0;for(const a of OT(e,NT))for(const u of s){const c=n[u],l=t[u];if(!(!c||!l)&&!(a.x<c.x1||a.x>c.x2||a.y<c.y1||a.y>c.y2)&<(a,l)<r)return!1}return!0}function MT(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(kw(e.slice(s-1,s+1)));const i=[];let o=t;for(let s=1;s<e.length-1;s++){const a=e[s-1],u=e[s],c=e[s+1],l=r[s-1],d=r[s];if(!a||!u||!c||l===void 0||d===void 0)continue;const f=l/(s-1===0?1:2),h=d/(s===r.length-1?1:2),p=Math.min(Yt,f,h),m={x:(u.x-a.x)/l,y:(u.y-a.y)/l},y={x:(c.x-u.x)/d,y:(c.y-u.y)/d},w={x:u.x-m.x*p,y:u.y-m.y*p},g={x:u.x+y.x*p,y:u.y+y.y*p};i.push({kind:"L",points:[o,w]}),i.push({kind:"C",points:[w,{x:w.x+m.x*p*.55,y:w.y+m.y*p*.55},{x:g.x-y.x*p*.55,y:g.y-y.y*p*.55},g]}),o=g}return i.push({kind:"L",points:[o,n]}),i.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 FT(e){const t=i=>`${En(i.x)},${En(i.y)}`,n=e[0];if(!n)return"";let r=`M${t(n.points[0])}`;for(const i of e)r+=i.kind==="L"?` L${t(i.points[1])}`:` C${t(i.points[1])} ${t(i.points[2])} ${t(i.points[3])}`;return r}function lp(e,t,n,r,i){const o=Math.min(e.y,n)-Yt,s=Math.max(e.y,n)+Yt,a=d=>(d-e.x)*t;let u=1/0;for(const d of i)if(d.y1<e.y&&e.y<d.y2){const f=t===1?d.x1:d.x2,h=t===1?d.x2:d.x1;a(h)>0&&(u=Math.min(u,Math.max(0,a(f))))}const c=i.filter(d=>d.y1<s&&o<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[...c,[1/0,1/0]]){if(d>l+1){const h=Math.min(d,u);if(h<=l+1)return null;const p=Number.isFinite(h)&&h-l<80?(l+h)/2:l+40;return e.x+t*p}if(l=Math.max(l,f),l>=u)return null}return null}function UT(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 i=t[r-1],o=t[r+1];return!i||!o?!0:!(Math.abs(i.x-n.x)<.01&&Math.abs(o.x-n.x)<.01||Math.abs(i.y-n.y)<.01&&Math.abs(o.y-n.y)<.01)})}const GT=120;function jT(e,t,n,r,i,o=4){const s=Ju(e,t,n,r,o);if(!s||!i.length)return s;const a=i.map(f=>zT(f,au));if(cp(DT(s),i,a,au))return s;const u=new Set([e.y,t.y]),c=f=>Math.abs(f-e.y)<up?e.y:Math.abs(f-t.y)<up?t.y:f;for(const f of a)u.add(c(Math.round(f.y1)-Yt-1)),u.add(c(Math.round(f.y2)+Yt+1));const l=t.x>=e.x?1:-1,d=[[l,l],[l,-l],[-l,l],[-l,-l]];for(const[f,h]of d){const p={x:e.x+f*(n+o),y:e.y},m={x:t.x-h*(r+o),y:t.y},y=[];for(const w of u){const g=Math.abs(w-p.y)<.01?p.x:lp(p,f,w,Yt,a);if(g===null)continue;const b=Math.abs(w-m.y)<.01?m.x:lp(m,-h,w,Yt+ap,a);if(b===null||Math.abs(w-m.y)<.01&&(m.x-g)*h<Yt+ap||Math.abs(w-p.y)<.01&&(b-p.x)*f<Yt)continue;const v=UT([p,{x:g,y:p.y},{x:g,y:w},{x:b,y:w},{x:b,y:m.y},m]);if(!ZT(v,a))continue;let k=(v.length-2)*Yt,_;for(const $ of v)_&&(k+=Math.abs($.x-_.x)+Math.abs($.y-_.y)),_=$;y.push({points:v,length:k})}y.sort((w,g)=>{const b=w.points[2]?.y,v=g.points[2]?.y;return w.length-g.length||(b===void 0||v===void 0?0:b-v)});for(const w of y){const g=MT(w.points);if(!cp(g,i,a,au))continue;const b=w.points,v=b[0],k=b[b.length-1];if(!v||!k)continue;const _={x1:Math.min(...b.map($=>$.x)),y1:Math.min(...b.map($=>$.y)),x2:Math.max(...b.map($=>$.x)),y2:Math.max(...b.map($=>$.y))};return{kind:"routed",start:v,end:k,controls:null,d:FT(g),bounds:_}}}return s}function ZT(e,t){let n;for(const r of e){if(n){const i={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 o of t)if(wT(i,o))return!1}n=r}return!0}function Sw(e,t){if(!t)return Xt.rest;const n=Ke(t);return Ke(e.from)===n||Ke(e.to)===n?Xt.related:Xt.faded}function BT(){return{hit:{stroke:"transparent",width:16},line:{stroke:We("edge"),width:1.6},arrow:{fill:We("edge")}}}function HT(e,t,n){return e!=="gravity"&&e!=="tree"?null:{layout:e,id:t,pointerId:n}}function VT(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 qT(e,t,n,r=tT){if(!e||e.pointerId!==t)return e;const i=Math.hypot(n.x-e.start.x,n.y-e.start.y);return{...e,moved:e.moved||i>r}}function WT(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 dp(e){return e==="Enter"||e===" "}function KT(e,t){return{x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale}}function JT(e,t,n,r,i){return!t||t.pointerId!==n||!Object.hasOwn(e,t.id)?!1:(e[t.id]=KT(r,i),!0)}function YT(e,t){return e?.pointerId===t?null:e}function XT(e,t,n,r){const i=Math.min(t.width/n,t.height/r),o=t.left+(t.width-n*i)/2,s=t.top+(t.height-r*i)/2;return{x:(e.x-o)/i,y:(e.y-s)/i}}function QT(e,t,n){const r=new Map;let i=null,o=null,s=null;function a(h){if(h===e)return{kind:"canvas",id:null};const p=h;if(p?.closest?.("[data-canvas]"))return{kind:"canvas",id:null};const m=p?.closest?.("[data-node-id]");if(m)return{kind:"node",id:m.dataset.nodeId??null};const y=p?.closest?.("[data-edge-id]");return y?{kind:"edge",id:y.dataset.edgeId??null}:null}function u(h){if(h.pointerType==="mouse"&&h.button!==0)return;const p=n?n(h):a(h.target);if(!p)return;const m=t.point(h);if(r.set(h.pointerId,m),e.setPointerCapture(h.pointerId),p.kind!=="canvas"&&(h.preventDefault(),h.stopPropagation()),r.size===1){i=VT(p.kind,p.id,h.pointerId,{x:h.clientX,y:h.clientY}),o=p.kind==="canvas"?{point:m,transform:{...t.transform()}}:null;return}if(i&&(i={...i,moved:!0}),o=null,r.size===2){const[y,w]=[...r.values()];y&&w&&(s={distance:Math.hypot(w.x-y.x,w.y-y.y),scale:t.transform().scale},t.startPinch())}}function c(h){if(!r.has(h.pointerId))return;const p=t.point(h);if(r.set(h.pointerId,p),s){const[m,y]=[...r.values()];m&&y&&t.pinch(s,[m,y],h);return}if(i?.pointerId===h.pointerId){if(i=qT(i,h.pointerId,{x:h.clientX,y:h.clientY}),!i?.moved)return;if(i.kind==="node"){t.drag(i.id??"",h.pointerId,p,h);return}if(i.kind==="edge")return}o&&t.pan(o,p,h)}function l(h,p=!1){const m=WT(i,h.pointerId,p);m&&t.select(m),i?.pointerId===h.pointerId&&(i=null),t.endDrag(h.pointerId),r.delete(h.pointerId),r.size||(i=null,o=null,s=null),e.hasPointerCapture(h.pointerId)&&e.releasePointerCapture(h.pointerId)}const d=h=>l(h),f=h=>l(h,!0);return e.addEventListener("pointerdown",u,!0),e.addEventListener("pointermove",c),e.addEventListener("pointerup",d),e.addEventListener("pointercancel",f),()=>{e.removeEventListener("pointerdown",u,!0),e.removeEventListener("pointermove",c),e.removeEventListener("pointerup",d),e.removeEventListener("pointercancel",f)}}function eC(e,t,n){let r=!1;function i(o,s=!1){r=o,e.classList.toggle("graph-panel--expanded",o),n.classList.toggle("graph-expanded",o),t.classList.toggle("expand-control--expanded",o),t.setAttribute("aria-expanded",String(o)),t.setAttribute("aria-label",o?"Close expanded graph":"Expand graph"),t.setAttribute("title",o?"Close expanded graph":"Expand graph"),o?(e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true")):(e.removeAttribute("role"),e.removeAttribute("aria-modal"),s&&t.focus())}return{open(){i(!0)},close(o={}){i(!1,o.restoreFocus!==!1)},toggle(){i(!r,r)},isOpen(){return r}}}function xw(e){const t=String(e??"").toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown"}function Yu(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e)}function Xu(e){return e==null?"Unavailable":new Intl.NumberFormat("en-US").format(e)}function $n(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 Ew(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[i,o]of r){const s=Math.floor(n/i);if(s>=1)return`${s} ${o}${s===1?"":"s"} ago`}return"just now"}function Qu(e){if(e.amount_usd_sum==null||e.price_coverage_ratio===0)return"Unavailable";const t=e.price_coverage_ratio;return Yu(e.amount_usd_sum)+(t!=null&&t>0&&t<1?" (priced portion)":"")}function tC(e){const t=[["Incoming amount (USD)",e.total_in_usd==null?"Unavailable":Yu(e.total_in_usd)],["Outgoing amount (USD)",e.total_out_usd==null?"Unavailable":Yu(e.total_out_usd)]];return e.role&&$o.includes(e.role)?[["Role",bw[e.role]||"Other"],...t,["Senders",Xu(e.degree_in)],["Receivers",Xu(e.degree_out)],["Labels",An(e).join(", ")||"No labels"]]:[["Address risk",e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} · ${xw(e.risk_level)}`],["Confidence","Unavailable"],...t,["First activity (UTC)",$n(e.first_activity_timestamp)],["Last activity (UTC)",$n(e.last_activity_timestamp)],["Labels",An(e).join(", ")||"No labels"]]}function nC(e,t){if(e.source==="flows")return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",Qu(e)],["Transfers",Xu(e.tx_count)],["First seen (UTC)",$n(e.first_seen_timestamp)],["Last seen (UTC)",$n(e.last_seen_timestamp)],["Since last seen",Ew(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)",Qu(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)",$n(e.first_seen_timestamp)],["Last seen (UTC)",$n(e.last_seen_timestamp)],["First transaction",e.first_tx_id||"Unavailable"],["Last transaction",e.last_tx_id||"Unavailable"]]}function $w(e){return typeof e!="string"||!/^0x[a-fA-F0-9]{64}$/.test(e)?null:`https://robinhoodchain.blockscout.com/tx/${e.toLowerCase()}`}function ec(e){const t=To(e);if(e.role)return`${e.address}. ${t||"Other"}.${An(e).length?` Labels: ${An(e).join(", ")}.`:""}`;const n=e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} ${xw(e.risk_level)} risk`,r=An(e).join(", ");return`${e.address}. ${n}.${r?` Labels: ${r}.`:""}`}function tc(e,t){const n=`${e.from} to ${e.to}. Aggregate value ${Qu(e)}. ${e.tx_count??0} ${e.tx_count===1?"transfer":"transfers"}.`;return e.source==="flows"&&e.last_seen_timestamp?`${n} Last seen ${Ew(e.last_seen_timestamp,t)}.`:n}function rC(e,t){return Pt(e).nodes.map(n=>{const r={id:n.address,label:An(n).join(", ")||To(n)};n.role&&(r.role=n.role);const i=t?.(n.address);return i&&(r.href=i),r})}function iC(e,t=22){return e.length>t?`${e.slice(0,t-1)}…`:e}function oC(e,t,n={}){const r=e.ownerDocument;let i=Pt(t),o=n.layout??(Hf(t)?"tree":"gravity");const s={width:e.clientWidth||n.width||820,height:e.clientHeight||n.height||430};let a=Uo(i,o,s.width,s.height);const u=new Map,c=new Map;let l={x:0,y:0,scale:1},d=null,f=null,h=null;const p=n.now??(()=>Date.now()),m=C=>n.nodeStyle?.(C).stroke??gT(C);e.classList.add("cia-graph-engine"),e.closest(".cia-graph-surface")||e.classList.add("cia-graph-surface");const y={model:()=>i,positions:()=>a,transform:()=>l,notes:()=>u,flags:()=>c,selected:()=>d,highlighted:()=>f,colorOf:m,now:p,dimensions:()=>s},w={selectNode:(C,P)=>B(C,P),selectEdge:(C,P)=>W(C,P),showTooltip:(C,P)=>U(C,P),hideTooltip:()=>ne(),lost:()=>ie()};function g(C){const P=C==="webgl"?np("webgl"):null;if(P)try{return P(e,y,w,{label:n.label})}catch{}return rp(e,y,w,{label:n.label})}const b=n.renderer??(np("webgl")&&K$(r)?"webgl":"svg");let v=g(b);e.dataset.renderer=v.kind;const k=()=>{const C=bT(i,a,u);if(!C)return null;const P=v.linkBounds();return P&&(C.x1=Math.min(C.x1,P.x1),C.y1=Math.min(C.y1,P.y1),C.x2=Math.max(C.x2,P.x2),C.y2=Math.max(C.y2,P.y2)),C},_=()=>{const C=k();return C?CT(C,s.width,s.height,pi):{x:0,y:0,scale:1}};l=_();const $=r.createElement("div");$.className="graph-tooltip cia-graph-tooltip",$.hidden=!0,$.setAttribute("role","tooltip"),e.append($);let O=0,M=!1,D=!1;function J(){if(O){M=!0;return}v.build()}function se(){if(O){D=!0;return}l=_(),we()}function we(){v.camera()}function _e(C="program"){const P=rC(i,n.href),re=d?.kind==="node"?i.nodes.find(he=>he.id===d.id)??null:null,ve=d?.kind==="edge"?i.edges.find(he=>he.id===d.id)??null:null;if(re){const he=i.edges.filter(rt=>rt.from===re.address||rt.to===re.address);return{kind:"node",id:re.id,selectedId:re.address,nodes:P,title:"Selected address",identity:re.address,values:tC(re),related:he,node:re,edge:null,source:C}}return ve?{kind:"edge",id:ve.id,selectedId:null,nodes:P,title:"Selected aggregate flow",identity:`${ve.from} → ${ve.to}`,values:nC(ve,p()),related:[ve],node:null,edge:ve,source:C}:{kind:null,id:null,selectedId:null,nodes:P,title:"Nothing selected",identity:"",values:[],related:[],node:null,edge:null,source:C}}function Ge(C){const P=_e(C);F(P),n.onSelect?.(P)}function F(C){const P=n.selectionRoot,re=P?.querySelector("[data-selection-title]"),ve=P?.querySelector("[data-selection-identity]"),he=P?.querySelector("[data-selection-meta]");!re||!ve||!he||(re.textContent=C.title,ve.textContent=C.identity,he.replaceChildren(...C.values.map(([rt,It])=>{const Wt=r.createElement("div");Wt.className="meta-item",It!=="Unavailable"&&(["From","To","First transaction","Last transaction"].includes(rt)&&Wt.classList.add("meta-item--identity"),rt==="Incoming amount (USD)"&&Wt.classList.add("meta-item--incoming"),rt==="Outgoing amount (USD)"&&Wt.classList.add("meta-item--outgoing")),["From","To","First transaction","Last transaction","Labels"].includes(rt)&&Wt.classList.add("meta-item--wide");const Vr=r.createElement("span");Vr.textContent=rt;const yn=r.createElement("strong"),vn=["First transaction","Last transaction"].includes(rt)?$w(It):null;if(vn&&n.openLink){const jt=n.openLink,Kt=r.createElement("button");Kt.type="button",Kt.className="cia-graph-explorer-link",Kt.dataset.explorer=vn,Kt.textContent=It,Kt.setAttribute("aria-label",`${rt}: ${It} (opens the explorer)`),Kt.addEventListener("click",()=>jt(vn)),yn.append(Kt)}else if(vn){const jt=r.createElement("a");jt.href=vn,jt.target="_blank",jt.rel="noopener noreferrer",jt.textContent=It,jt.setAttribute("aria-label",`${rt}: ${It} (opens in new tab)`),yn.append(jt)}else yn.textContent=It;return Wt.append(Vr,yn),Wt})))}function B(C,P="program"){d=C?{kind:"node",id:C}:null,v.selection(),Ge(P)}function W(C,P="program"){d=C?{kind:"edge",id:C}:null,v.selection(),Ge(P)}function Q(C){if(C==null)return B(null);const P=Gn(i,C);if(P)return B(P);if(i.edges.some(re=>re.id===C))return W(C)}function K(){l=_(),we()}function I(C,P={x:s.width/2,y:s.height/2}){const re=Ku(l.scale*(1+C)),ve=re/l.scale;l={x:P.x-(P.x-l.x)*ve,y:P.y-(P.y-l.y)*ve,scale:re},we()}function R(C){o=C,n.controls?.querySelectorAll("[data-layout]").forEach(P=>{P.classList.toggle("active",P.dataset.layout===C),P.setAttribute("aria-pressed",String(P.dataset.layout===C))}),n.onLayoutChange?.(C),a=Uo(i,o,s.width,s.height),v.geometry(),K()}function U(C,P){$.textContent=P,$.hidden=!1;const re=e.getBoundingClientRect();$.style.left=`${Math.min(re.width-330,Math.max(8,C.clientX-re.left+12))}px`,$.style.top=`${Math.max(8,C.clientY-re.top+12)}px`}function ne(){$.hidden=!0}function ce(C){return XT({x:C.clientX,y:C.clientY},v.surface.getBoundingClientRect(),s.width,s.height)}const ee={point:ce,transform:()=>l,select(C){C.type==="select-node"?B(C.id,"pointer"):C.type==="select-edge"?W(C.id,"pointer"):B(qf(i)?.id??null,"canvas")},drag(C,P,re){!h&&(h=HT(o,C,P),!h)||JT(a,h,P,re,l)&&(Ee=!0,v.moveNode(h.id))},endDrag(C){const P=h?.pointerId===C&&Ee;h=YT(h,C),P&&(Ee=!1,v.endMove())},pan(C,P){l={x:C.transform.x+P.x-C.point.x,y:C.transform.y+P.y-C.point.y,scale:l.scale},we()},startPinch(){h=null},pinch(C,[P,re]){const ve=Math.hypot(re.x-P.x,re.y-P.y),he=Ku(C.scale*ve/Math.max(1,C.distance));I(he/l.scale-1,{x:(P.x+re.x)/2,y:(P.y+re.y)/2})}};let Ee=!1;const Ae=C=>{C.preventDefault(),I(C.deltaY>0?-.12:.12,ce(C))},z={ArrowLeft:[60,0],ArrowRight:[-60,0],ArrowUp:[0,60],ArrowDown:[0,-60]},G=C=>{if(C.target!==v.surface)return;const P=z[C.key];P?(C.preventDefault(),l={...l,x:l.x+P[0],y:l.y+P[1]},we()):C.key==="+"||C.key==="="?I(.18):C.key==="-"?I(-.18):C.key==="0"&&K()};let H=()=>{};function Y(){const C=v.surface,P=re=>v.pick(ce(re));H=QT(C,ee,v.kind==="svg"?void 0:P),C.addEventListener("wheel",Ae,{passive:!1}),C.addEventListener("keydown",G)}function le(){H(),v.surface.removeEventListener("wheel",Ae),v.surface.removeEventListener("keydown",G)}Y();function ie(){v.kind!=="svg"&&(le(),v.destroy(),v=rp(e,y,w,{label:n.label}),e.dataset.renderer=v.kind,e.append($),Y(),J())}const $e=n.controls?.querySelector("[data-expand]")??null,Ie=n.panel&&$e?eC(n.panel,$e,r.body):null,de=()=>{Ie?.toggle(),n.onExpansionChange?.(Ie?.isOpen()??!1),requestAnimationFrame(K)},ze=n.panel??e,fe=C=>{if(C.key==="Tab"&&Ie?.isOpen()&&n.panel){const P=Array.from(n.panel.querySelectorAll('button,a[href],[tabindex="0"],summary')).filter(he=>he.checkVisibility()),re=P[0],ve=P.at(-1);C.shiftKey&&r.activeElement===re?(C.preventDefault(),ve?.focus()):!C.shiftKey&&r.activeElement===ve&&(C.preventDefault(),re?.focus())}if(C.key==="Escape"){if(Ie?.isOpen()){Ie.close(),n.onExpansionChange?.(!1),requestAnimationFrame(K);return}B(null,"keyboard")}};ze.addEventListener("keydown",fe);const Je=[],He=(C,P)=>{C&&(C.addEventListener("click",P),Je.push([C,P]))};n.controls?.querySelectorAll("[data-layout]").forEach(C=>He(C,()=>R(C.dataset.layout==="tree"?"tree":"gravity"))),He(n.controls?.querySelector("[data-zoom='in']"),()=>I(.18)),He(n.controls?.querySelector("[data-zoom='out']"),()=>I(-.18)),He(n.controls?.querySelector("[data-zoom='fit']"),K),Ie&&He($e,de);const pt=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const C=e.clientWidth,P=e.clientHeight;!C||!P||C===s.width&&P===s.height||(s.width=C,s.height=P,v.resize(C,P),K())});pt?.observe(e),J(),n.selected&&Q(n.selected);const Ve={update(C){const P=a;i=Pt(C);const re=i.nodes.every(he=>P[he.id])?{}:Uo(i,o,s.width,s.height);a=Object.fromEntries(i.nodes.map(he=>[he.id,P[he.id]??re[he.id]]).filter(([,he])=>he)),d&&!(d.kind==="node"?i.nodes.some(he=>he.id===d.id):i.edges.some(he=>he.id===d.id))&&(d=null),f&&!i.nodes.some(he=>he.id===f)&&(f=null);const ve=new Set(i.nodes.map(he=>he.id));for(const he of[...c.keys()])ve.has(he)||c.delete(he);J(),se()},merge(C,P){const re=fT(i,C,P);i=re.model;const ve=Gn(i,P??Pt(C).checked_address);return a=ve?TT(i,a,ve,re.added,{notes:u}):{...a,...Uo(i,o,s.width,s.height),...a},J(),re.added.length&&se(),re.added},batch(C){O++;try{C()}finally{O--,!O&&M&&(M=!1,v.build()),!O&&D&&(D=!1,l=_(),we())}},setTheme(C){C&&r.documentElement.setAttribute("data-theme",C),v.theme()},select:Q,destroy(){pt?.disconnect(),le(),ze.removeEventListener("keydown",fe);for(const[C,P]of Je)C.removeEventListener("click",P);Ie?.close({restoreFocus:!1}),v.destroy(),$.remove(),e.classList.remove("cia-graph-engine"),delete e.dataset.renderer,delete e.ciaGraph},fit:K,zoom:C=>I(C),setLayout:R,markNode(C,P){const re=Gn(i,C);re&&(P?u.set(re,P):u.delete(re),J())},flagNode(C,P,re){const ve=Gn(i,C);if(!ve)return;const he=c.get(ve)??new Set;re?he.add(P):he.delete(P),he.size?c.set(ve,he):c.delete(ve),O?M=!0:v.flag(ve,P,re)},positions:()=>structuredClone(a),model:()=>i,contentBounds:()=>k(),transform:()=>({...l}),highlight(C){f=C==null?null:Gn(i,C),v.selection()},renderer:()=>v.kind,clientPoint(C){const P=Gn(i,C),re=P?a[P]:null;if(!re)return null;const ve=v.surface.getBoundingClientRect(),he=Math.min(ve.width/s.width,ve.height/s.height)||1,rt=ve.left+(ve.width-s.width*he)/2,It=ve.top+(ve.height-s.height*he)/2;return{x:rt+(re.x*l.scale+l.x)*he,y:It+(re.y*l.scale+l.y)*he}}};return Object.defineProperty(e,"ciaGraph",{value:Ve,configurable:!0}),Ve}const Tw="chain-insights.flows.v1",Jf="chain-insights.result.v1",Cw=5e3,fp=6,sC=3,Aw=/^0x[0-9a-fA-F]{40}$/,aC=/^0x[0-9a-fA-F]{64}$/;function uC(e){return typeof e=="string"&&(Aw.test(e)||aC.test(e))}function gi(e){return typeof e=="string"&&Aw.test(e)}function nc(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Va(e){const t=e?.facts?.query?.results;return Array.isArray(t)?t.filter(nc):[]}function cC(e){const t=e?.facts;return typeof t?.subject?.network=="string"&&t.subject.network?t.subject.network:"robinhood"}function Qt(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 Yf(e){return e<1e11?e*1e3:e}const Iw=/^\d{4}-\d{2}-\d{2}$/,lC=Date.UTC(2009,0,1),dC=Date.UTC(2100,0,1);function uu(e){return new Date(Yf(e)).toISOString().slice(0,10)}function hp(e){const t=Date.parse(`${e}T00:00:00Z`);return new Date(t-864e5).toISOString().slice(0,10)}function Xf(e){if(typeof e!="string"||!Iw.test(e))return!1;const t=Date.parse(`${e}T00:00:00Z`);return Number.isFinite(t)&&new Date(t).toISOString().slice(0,10)===e}const fC=new Set(["day","date","hour","week","month"]),hC=["_timestamp","_time","_at"];function pp(e){return fC.has(e)||hC.some(t=>e.endsWith(t))}function Nw(e){const t=[];for(const n of e)for(const r of Object.keys(n))t.includes(r)||t.push(r);return t}function pC(e){return Array.isArray(e)?e.some(gi):gi(e)}function mC(e){return e.some(t=>Object.values(t).some(pC))}function Rw(e){return e.length>0&&e.every(t=>gi(t.from_address)&&gi(t.to_address))}const gC=/^(\d{4})-(\d{2})$/,yC=/^(\d{4})-W(\d{2})$/,vC=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/,bC=/(?:Z|[+-]\d{2}:?\d{2})$/i;function wC(e,t){const n=Date.UTC(e,0,4);return n-(new Date(n).getUTCDay()+6)%7*864e5+(t-1)*7*864e5}function mp(e){if(typeof e=="string"){const r=e.trim();if(Iw.test(r))return Xf(r)?Date.parse(`${r}T00:00:00Z`):null;const i=gC.exec(r);if(i){const s=Number(i[2])-1;return s>=0&&s<12?Date.UTC(Number(i[1]),s,1):null}const o=yC.exec(r);if(o){const s=Number(o[2]);return s>=1&&s<=53?wC(Number(o[1]),s):null}if(vC.test(r)){const s=r.replace(" ","T"),a=Date.parse(bC.test(s)?s:`${s}Z`);return Number.isFinite(a)?a:null}}const t=Qt(e);if(t==null)return null;const n=Yf(t);return n>=lC&&n<dC?n:null}function Qf(e,t={}){if(e.length===0||mC(e))return null;const n=Nw(e),i=n.filter(pp).find(d=>e.some(f=>mp(f[d])!=null));if(!i)return null;const o=n.filter(d=>{if(pp(d))return!1;const f=e.map(h=>h[d]).filter(h=>h!=null);return f.length>0&&f.every(h=>Qt(h)!=null)});if(o.length===0)return null;const s=o.slice(0,fp),a=new Map;let u=0;for(const d of e){const f=mp(d[i]);if(f==null)continue;u++;const h=a.get(f)??{count:0,sums:s.map(()=>null)};h.count++,s.forEach((p,m)=>{const y=Qt(d[p]);y!=null&&(h.sums[m]=(h.sums[m]??0)+y)}),a.set(f,h)}const c=[...a.entries()].sort((d,f)=>d[0]-f[0]);return c.filter(([,d])=>d.sums.some(f=>f!=null)).length<(t.minPoints??sC)?null:{xColumn:i,times:c.map(([d])=>d),rowCounts:c.map(([,d])=>d.count),daily:c.every(([d])=>d%864e5===0),series:s.map((d,f)=>({column:d,values:c.map(([,h])=>h.sums[f]??null)})),omittedColumns:o.slice(fp),skippedRows:e.length-u,failures:[]}}function _C(e){if(!e)return"failed";const t=/^\s*([a-z][a-z0-9_]*)\s*:/.exec(e);if(t?.[1])return t[1];const n=e.trim().split(/\s+/).slice(0,4).join(" ");return n.length>40?`${n.slice(0,39)}…`:n||"failed"}const kC=e=>e==null||Qt(e)!=null;function Lw(e){const t=Pw(e);if(t.length<3||!t.every(c=>Xf(c.id))||new Set(t.map(c=>c.id)).size!==t.length)return null;const n=t.filter(c=>c.ok);if(n.length===0||!n.every(c=>c.rows.length===1))return null;const r=Object.keys(n[0].rows[0]),i=[...r].sort().join("\0");for(const c of n){const l=c.rows[0];if(Object.keys(l).sort().join("\0")!==i||!Object.values(l).every(kC))return null}if(r.length===0||r.includes("day"))return null;const o=[...t].sort((c,l)=>c.id.localeCompare(l.id)),s=o.map(c=>({day:c.id,...c.ok?c.rows[0]:Object.fromEntries(r.map(l=>[l,null]))})),a=o.filter(c=>!c.ok).map(c=>({day:c.id,time:Date.parse(`${c.id}T00:00:00Z`),code:_C(c.error)})),u=Qf(s,{minPoints:1});return u?{rows:s,columns:r,failures:a,model:{...u,failures:a}}:null}const SC=/\baddress\s*:\s*(["'])(0x[0-9a-fA-F]{40})\1/g,xC=/^\s*(<)?-(?:\[[^\]]*\])?-(>)?/,EC=/(<)?-(?:\[[^\]]*\])?-(>)?\s*$/;function gp(e,t){if(!e)return"none";const n=!!e[1],r=!!e[2];return n===r?null:t==="after"?r?"from":"to":r?"to":"from"}function zw(e){if(typeof e!="string"||!e)return null;const t=[...e.matchAll(SC)];if(t.length===0||new Set(t.map(r=>r[2].toLowerCase())).size!==1)return null;let n=null;for(const r of t){const i=r.index??0,o=e.lastIndexOf("(",i),s=e.indexOf(")",i);if(o<0||s<0)return null;const a=[gp(EC.exec(e.slice(0,o)),"before"),gp(xC.exec(e.slice(s+1)),"after")];if(a.includes(null))return null;for(const u of a)if(u!=="none"){if(n&&n!==u)return null;n=u}}return n?{address:t[0][2],end:n}:null}function $C(e,t){if(e.length===0||Rw(e))return null;const n=zw(t);if(!n)return null;const r=n.address.toLowerCase(),i=Nw(e).filter(s=>e.every(a=>gi(a[s]))&&!e.every(a=>String(a[s]).toLowerCase()===r));if(i.length!==1)return null;const o=i[0];return e.map(s=>n.end==="from"?{...s,from_address:n.address,to_address:s[o]}:{...s,from_address:s[o],to_address:n.address})}function TC(e){return Rw(e)?"graph":Qf(e)?"chart":"table"}const CC=[["sanctioned","sanctioned"],["scam","scam"],["victim","victim"],["pool","pool"],["exchange","exchange"]];function yp(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim()):[]}function AC(e,t){if(t)return"exchange";const n=new Set(e.map(r=>r.replace(/\s+/g,"").toLowerCase()));for(const[r,i]of CC)if(n.has(r))return i;return"other"}const vp=(e,t)=>e==null?t:t==null?e:e+t;function IC(e,t="robinhood",n){const r=new Map;for(const h of e)for(const p of new Set([String(h.from_address).toLowerCase(),String(h.to_address).toLowerCase()]))r.set(p,(r.get(p)??0)+1);let i="",o=0;for(const[h,p]of r)p>o&&(i=h,o=p);const s=n?.toLowerCase();s&&r.has(s)&&(i=s);const a=new Map,u=new Map,c=(h,p,m)=>{const y=a.get(h)??{address:h,labels:[],exchange:!1};for(const w of p)y.labels.some(g=>g.toLowerCase()===w.toLowerCase())||y.labels.push(w);y.exchange=y.exchange||m,a.set(h,y)};i&&a.set(i,{address:i,labels:[],exchange:!1});let l=0;for(const h of e){const p=String(h.from_address).toLowerCase(),m=String(h.to_address).toLowerCase(),y=[p,m].filter((k,_,$)=>!a.has(k)&&$.indexOf(k)===_).length;if(a.size+y>Cw||(l++,c(p,yp(h.from_labels),h.from_is_exchange===!0),c(m,yp(h.to_labels),h.to_is_exchange===!0),p===m))continue;const w=`${p}->${m}`,g=u.get(w)??{from:p,to:m,usd:null,tx:null,first:null,last:null,kinds:[]};g.usd=vp(g.usd,Qt(h.amount_usd_sum)),g.tx=vp(g.tx,Qt(h.tx_count));const b=Qt(h.first_seen_timestamp),v=Qt(h.last_seen_timestamp);b!=null&&(g.first=g.first==null?b:Math.min(g.first,b)),v!=null&&(g.last=g.last==null?v:Math.max(g.last,v)),typeof h.link_kind=="string"&&h.link_kind&&!g.kinds.includes(h.link_kind)&&g.kinds.push(h.link_kind),u.set(w,g)}const d=[...a.values()].map(h=>({address:h.address,role:AC(h.labels,h.exchange),labels:h.labels})),f=[...u.values()].map(h=>({from:h.from,to:h.to,usd:h.usd,tx_count:h.tx,first_seen_ms:h.first,last_seen_ms:h.last,...h.kinds.length?{link_kind:h.kinds.join(", ")}:{}}));return{view:{schema:Tw,network:t,center:i,nodes:d,edges:f,truncated:!1},rowsTotal:e.length,rowsDrawn:l,rowsLeftOut:e.length-l,addresses:a.size}}function Pw(e){const t=e?.facts?.queries;return Array.isArray(t)?t.filter(nc).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(nc):[],count:typeof n.count=="number"?n.count:null,truncated:n.truncated===!0,elapsedMs:typeof n.elapsed_ms=="number"?n.elapsed_ms:null,query:typeof n.query=="string"&&n.query?n.query:null})):[]}const bp=200;function Co(e){return(e?.content??[]).filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
109
|
-
`).trim()}function qr(e){if(typeof e=="string")return e.trim()||null;if(!e||typeof e!="object"||Array.isArray(e))return null;const{code:t,message:n,detail:r,error:i}=e,o=[n,r,i].find(a=>typeof a=="string"&&a.trim()!=="")?.trim()??null,s=typeof t=="string"&&t.trim()?t.trim():null;return o?s&&!o.startsWith(s)?`${s}: ${o}`:o:s}function Dw(e){if(!e)return null;const t=e.structuredContent,n=qr(t?.error)??qr(t?.facts?.error)??qr(t?.facts?.query?.error);if(!e.isError||n)return n;const r=Co(e);if(r.startsWith("{"))try{const i=JSON.parse(r),o=qr(i?.error)??qr(i);if(o)return o}catch{}return r||"The tool answered with an error."}const NC=new Set(["usage_status","subscription_status","meta_usage_status","meta_subscription_status"]);function Ow(e){if(!e||Dw(e)!=null)return"text";const t=e.structuredContent;if(t?.schema===Tw)return"flows";if(t?.schema===Jf){if(t.tool==="graph_query")return TC(Va(t));if(t.tool==="graph_query_batch")return!Array.isArray(t.facts?.queries)||t.facts.queries.length===0?"text":Lw(t)?"chart":"batch";if(typeof t.tool=="string"&&NC.has(t.tool))return"balance"}return"text"}function A(e,t,n={},...r){const i=e.createElement(t);for(const[o,s]of Object.entries(n))s==null||s===!1||(o==="class"?i.className=String(s):o==="text"?i.textContent=String(s):i.setAttribute(o,s===!0?"":String(s)));for(const o of r)o==null||o===!1||i.append(typeof o=="string"?e.createTextNode(o):o);return i}function RC(e,t){const n=A(e,"code",{class:"cv-addr",title:t,"data-full":t,text:mi(t)}),r=A(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",()=>{LC(e,t,n,r)}),A(e,"span",{class:"cv-addr-cell"},n,r)}async function LC(e,t,n,r){const i=e.defaultView?.navigator?.clipboard;try{if(i?.writeText)return await i.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 zC(e,t){return/(timestamp|seen|_at|_ms|time)$/i.test(t)&&e>1e9?$n(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)}const PC=160,wp=2e3;function DC(e,t=PC){const n=e.trim().split(/\r?\n/,1)[0]??"",r=n.search(/[.!?](?=\s|$)/),i=(r<0?n:n.slice(0,r+1)).trim();if(i.length<=t)return i;const o=i.slice(0,t-1),s=o.lastIndexOf(" ");return`${(s>t*.6?o.slice(0,s):o).trimEnd()}…`}function Mw(e,t,n){const r=e.ownerDocument,i=n.full!=null&&n.full.length>wp?`${n.full.slice(0,wp-1)}…`:n.full,o=i!=null&&i!==t,s=A(r,"section",{class:`cia-graph-surface cv-notice cv-notice-${n.kind}`,"data-view":n.view,"data-notice":n.kind,role:n.kind==="refused"?"alert":"status",title:o?i:null},o?A(r,"details",{class:"cv-notice-more"},A(r,"summary",{class:"cv-notice-line",text:t}),A(r,"p",{class:"cv-notice-full",text:i})):A(r,"p",{class:"cv-notice-line",text:t}));return e.replaceChildren(s),s}function OC(e){const t=e?.facts?.query,n=Array.isArray(t?.results)?t.results.filter(o=>!!o&&typeof o=="object"&&!Array.isArray(o)):[],r=n.slice(0,bp),i=[];for(const o of r)for(const s of Object.keys(o))i.includes(s)||i.push(s);return{columns:i,rows:r,total:n.length,truncated:n.length>bp||t?.truncated===!0,elapsedMs:typeof t?.elapsed_ms=="number"?t.elapsed_ms:null}}function MC(e,t,n){return t==null?A(e,"span",{class:"cv-null","aria-label":"empty",text:"—"}):uC(t)?RC(e,t):typeof t=="number"?e.createTextNode(zC(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 _p(e,t,n={}){const r=e.ownerDocument,i=OC(t.structuredContent),o=i.rows.length;if(i.total===0)return Mw(e,"No rows.",{kind:"empty",view:"table"}),i;const s=`${new Intl.NumberFormat("en-US").format(o)} ${o===1?"row":"rows"}${i.elapsedMs==null?"":` in ${i.elapsedMs} ms`}`,a=A(r,"table",{class:"cv-table"},A(r,"thead",{},A(r,"tr",{},...i.columns.map(u=>A(r,"th",{scope:"col",text:u})))),A(r,"tbody",{},...i.rows.map(u=>A(r,"tr",{},...i.columns.map(c=>A(r,"td",{},MC(r,u[c],c)))))));return e.replaceChildren(A(r,"section",{class:"cv-card cv-table-view","data-view":"table","aria-label":"Graph query result"},A(r,"header",{class:"cv-card-head"},A(r,"strong",{text:"Graph query result"}),A(r,"span",{class:"cv-muted",text:s}),n.toggle??null),i.truncated?A(r,"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(i.total)} rows. Narrow the query to see the rest.`}):null,i.columns.length?A(r,"div",{class:"cv-table-wrap"},a):null)),i}const Wr=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e:t,Go=e=>typeof e=="string"&&e?e:null;function FC(e){const t=e?.facts??{};if(typeof t.wallet=="string"&&t.wallet)return{kind:"wallet",wallet:t.wallet,tier:String(t.tier??"anonymous"),allowanceUsd:Wr(t.allowance_usd),consumedUsd:Wr(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,i=Go(n.access_mode);return{kind:"free",unit:r?"units":"seconds",used:Wr(r?n.daily_units_used:n.daily_seconds_used),limit:Wr(r?n.daily_units_limit:n.daily_seconds_limit),remaining:Wr(r?n.remaining_units:n.remaining_seconds),resetAt:Go(n.reset_at),identifierKind:Go(n.identifier_kind),accessMode:i,noLimit:!r&&i==="public_free"&&n.daily_seconds_limit===0}}return{kind:"unknown"}}const kp=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e),jo=(e,t)=>`${new Intl.NumberFormat("en-US").format(e)} ${t==="units"?e===1?"unit":"units":e===1?"second":"seconds"}`;function cu(e){if(!e)return"No active window";const t=Date.parse(e);return Number.isFinite(t)?`${$n(t)} UTC`:e}function Sp(e,t,n,r){const i=n>0?Math.min(1,t/n):0,o=A(e,"div",{class:"cv-meter",role:"meter","aria-label":r,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":Math.min(t,n)},A(e,"span"));return o.firstElementChild.style.width=`${Math.round(i*100)}%`,o}function lu(e,t){return A(e,"dl",{class:"cv-facts"},...t.flatMap(([n,r])=>[A(e,"dt",{text:n}),A(e,"dd",{text:r})]))}function UC(e,t){const n=e.ownerDocument,r=FC(t.structuredContent);let i,o,s;return r.kind==="wallet"?(o="Wallet allowance",s=`${mi(r.wallet)} · ${r.tier==="subscriber"?"Subscriber":"No active subscription"}`,i=[Sp(n,r.consumedUsd,r.allowanceUsd,"Share of today's allowance used"),lu(n,[["Daily allowance",kp(r.allowanceUsd)],["Used today",kp(r.consumedUsd)],["Window ends",cu(r.windowEnd)]])]):r.kind==="free"?(o="Free tier",s=`No wallet · counted per ${r.identifierKind==="ip"||!r.identifierKind?"network address":r.identifierKind}`,i=r.noLimit?[A(n,"p",{class:"cv-balance-note","data-no-limit":"",text:"Free access, no daily limit"}),lu(n,[["Daily allowance","No daily limit"],["Used today",jo(r.used,r.unit)],["Window ends",cu(r.resetAt)]])]:[Sp(n,r.used,r.limit,"Share of today's free allowance used"),lu(n,[["Daily allowance",jo(r.limit,r.unit)],["Used today",jo(r.used,r.unit)],["Left today",jo(r.remaining,r.unit)],["Window ends",cu(r.resetAt)]])]):(o="Usage",s="The server sent no allowance figures.",i=[A(n,"p",{class:"cv-muted",text:Co(t)||"Nothing to show."})]),e.replaceChildren(A(n,"section",{class:"cv-card cv-balance-view","data-view":"balance","data-balance":r.kind,"aria-label":o},A(n,"header",{class:"cv-card-head"},A(n,"strong",{text:o}),A(n,"span",{class:"cv-muted",text:s})),...i)),r}function yi(e,t,n="No drawing for this answer."){const r=e.ownerDocument,i=Dw(t);if(i!=null){Mw(e,DC(i),{kind:"refused",view:"text",full:i});return}const o=Co(t);e.replaceChildren(A(r,"section",{class:"cv-card cv-text-view","data-view":"text"},A(r,"p",{text:n}),o?A(r,"p",{class:"cv-muted cv-text-body",text:o.length>600?`${o.slice(0,599)}…`:o}):null))}function eh(e,t="Loading the Chain Insights view"){const n=e.ownerDocument;e.replaceChildren(A(n,"section",{class:"cv-card cv-skeleton","data-view":"loading","aria-busy":"true","aria-label":t},A(n,"span",{class:"cv-sr",text:t}),A(n,"div",{class:"cv-skel-line cv-skel-title"}),A(n,"div",{class:"cv-skel-line cv-skel-sub"}),A(n,"div",{class:"cv-skel-block"})))}const GC="http://www.w3.org/2000/svg",rc=720,jC=320,ZC=6,BC=420,xp=4,HC=120,ti={left:70,right:18,top:6},ic=18,Fw=16,Uw=6,Gw=26,VC=170,qC=82,WC=28,KC=80,Zn=1e3,xn=60*Zn,nr=60*xn,en=24*nr,JC=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function jw(e,t){if(/usd/i.test(e))return"usd";const n=t.filter(r=>r!=null);return n.length>0&&n.every(Number.isInteger)?"count":"number"}const YC=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),XC=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumSignificantDigits:2}),QC=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",notation:"compact",maximumFractionDigits:1}),vi=new Intl.NumberFormat("en-US",{maximumFractionDigits:0}),eA=new Intl.NumberFormat("en-US",{maximumFractionDigits:4}),Zw=new Intl.NumberFormat("en-US",{maximumSignificantDigits:3}),Bw=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:2}),tA=new Intl.NumberFormat("en-US",{maximumFractionDigits:6});function ms(e,t){if(e==null)return"—";const n=e!==0&&Math.abs(e)<.01;return t==="usd"?n?XC.format(e):YC.format(e):t==="count"?vi.format(e):n?Zw.format(e):eA.format(e)}function nA(e){return e!==0&&Math.abs(e)<.01?Zw.format(e):Math.abs(e)<1e3?tA.format(Math.round(e*100)/100):Bw.format(e)}function Ep(e,t){return t==="usd"?Math.abs(e)<1e3?ms(e,"usd"):QC.format(e):t==="count"?Math.abs(e)<1e3?vi.format(e):Bw.format(e):nA(e)}function rA(e,t){const n=new Date(e).toISOString();return t?`${n.slice(0,10)} (UTC day)`:`${n.slice(0,10)} ${n.slice(11,19)} UTC`}function Hw(e){return e<=en?"time":e<=HC*en?"day":"month"}const iA=[Zn,2*Zn,5*Zn,10*Zn,15*Zn,30*Zn,xn,2*xn,5*xn,10*xn,15*xn,30*xn,nr,2*nr,3*nr,6*nr,12*nr,en],oA=[1,2,3,7,14,30,60].map(e=>e*en),sA=[1,2,3,6,12,24,60,120],$p=4*en,aA={time:76,day:84,month:72},uA=e=>new Date(e).getUTCFullYear()*12+new Date(e).getUTCMonth(),du=e=>Date.UTC(Math.floor(e/12),e%12,1);function cA(e,t,n){const r=t-e,i=Hw(r);if(r<=0)return{unit:i,step:0,times:[e]};const o=Math.max(2,Math.floor(n));if(i==="month"){for(const s of sA){const a=[];let u=uA(e);for(du(u)<e&&u++;du(u)<=t;u++)u%s===0&&a.push(du(u));if(a.length<=o&&a.length>0)return{unit:i,step:s,times:a}}return{unit:i,step:0,times:[e,t]}}for(const s of i==="time"?iA:oA){const a=s===7*en||s===14*en?Math.ceil((e-$p)/s)*s+$p:i==="day"?Math.ceil(e/en)*en:Math.ceil(e/s)*s,u=a>t?0:Math.floor((t-a)/s)+1;if(u>0&&u<=o)return{unit:i,step:s,times:Array.from({length:u},(c,l)=>a+l*s)}}return{unit:i,step:0,times:[e,t]}}function lA(e,t,n){const r=new Date(e),i=r.toISOString();return t==="month"?n>=12?i.slice(0,4):`${JC[r.getUTCMonth()]} ${r.getUTCFullYear()}`:t==="day"||e%en===0?i.slice(0,10):n>0&&n<xn?i.slice(11,19):i.slice(11,16)}function dA(e){return e.series.map(t=>{let n=0,r=null,i=null;return t.values.forEach((o,s)=>{o!=null&&(n+=o,(r==null||o>r)&&(r=o,i=e.times[s]??null))}),{column:t.column,kind:jw(t.column,t.values),total:n,peak:r,peakTime:i}})}const Lt=e=>new Date(e).toISOString(),Vw=(e,t)=>Lt(e).slice(0,10)===Lt(t).slice(0,10);function fA(e){const t=e.times[0],n=e.times[e.times.length-1];if(t==null||n==null)return"no points";if(e.daily)return t===n?`${Lt(t).slice(0,10)} UTC`:`${Lt(t).slice(0,10)} to ${Lt(n).slice(0,10)} UTC`;const r=i=>`${Lt(i).slice(0,10)} ${Lt(i).slice(11,16)}`;return t===n?`${r(t)} UTC`:Vw(t,n)?`${r(t)} to ${Lt(n).slice(11,16)} UTC`:`${r(t)} to ${r(n)} UTC`}function hA(e,t=new Set){const n=e.times.map((u,c)=>e.series.some(l=>l.values[c]!=null)),r=n.filter(Boolean).length,i=e.rowCounts.reduce((u,c,l)=>u+(n[l]?c:0),0),o=[fA(e),`${vi.format(r)} ${r===1?"point":"points"}${i>r?` from ${vi.format(i)} transfers`:""}`],s=e.times[0]??0,a=e.times[e.times.length-1]??0;for(const u of dA(e)){if(t.has(u.column))continue;if(u.peak==null||u.peakTime==null){o.push(`${u.column}: no values`);continue}const c=e.daily?`on ${Lt(u.peakTime).slice(0,10)}`:Vw(s,a)?`at ${Lt(u.peakTime).slice(11,19)}`:`at ${Lt(u.peakTime).slice(0,10)} ${Lt(u.peakTime).slice(11,16)}`;o.push(`${u.column}: total ${ms(u.total,u.kind)}, peak ${ms(u.peak,u.kind)} ${c}`)}return e.failures.length&&o.push(`no answer for ${e.failures.map(u=>`${u.day} (${u.code})`).join(", ")}`),o.join(" · ")}function pA(e,t){if(e.length===0)return-1;let n=0,r=e.length-1;for(;n<r;){const i=n+r>>1;(e[i]??0)<t?n=i+1:r=i}return n>0&&Math.abs(t-(e[n-1]??0))<=Math.abs((e[n]??0)-t)?n-1:n}function mA(e,t,n){const r=Math.min(t,n),i=Math.max(t,n);let o=-1,s=-1;return e.forEach((a,u)=>{a<r||a>i||(o<0&&(o=u),s=u)}),o>=0&&s-o>=1?{start:o,end:s}:null}function gA(e,t,n){const r=Math.max(0,t),i=Math.min(e.times.length-1,n)+1,o=e.times.slice(r,i),s=o[0]??0,a=o[o.length-1]??0;return{...e,times:o,rowCounts:e.rowCounts.slice(r,i),series:e.series.map(u=>({column:u.column,values:u.values.slice(r,i)})),failures:e.failures.filter(u=>u.time>=s&&u.time<=a)}}function yA(e,t,n){if(e.has(t)){const r=new Set(e);return r.delete(t),r}return n.filter(r=>!e.has(r)).length<=1?e:new Set([...e,t])}const qw=e=>`var(--cia-graph-series-${e%ZC+1})`;function gs(e,t){const n=e.last-e.first,r=e.plotRight-e.plotLeft;return n>0?e.plotLeft+(t-e.first)/n*r:e.plotLeft+r/2}function fu(e,t){const n=e.plotRight-e.plotLeft,r=Math.min(e.plotRight,Math.max(e.plotLeft,t));return n>0?e.first+(r-e.plotLeft)/n*(e.last-e.first):e.first}function Ww(e,t){return e.plotBottom-(t-e.min)/(e.max-e.min||1)*(e.plotBottom-e.plotTop)}function vA(e){if(e<=1)return VC;const t=Math.floor((BC-ti.top-Uw-Gw-(e-1)*Fw)/e)-ic;return Math.max(WC,Math.min(qC,t))}function Tp(e,t=rc,n=new Set){const r=ti.left,i=t-ti.right,o=e.times[0]??0,s=e.times[e.times.length-1]??o,a={plotLeft:r,plotRight:i,first:o,last:s},u=e.series.map((p,m)=>({series:p,index:m})).filter(({series:p})=>!n.has(p.column)),c=vA(u.length),l=u.map(({series:p,index:m},y)=>{const w=ti.top+y*(ic+c+Fw),g=w+ic,b=g+c,v=p.values.filter(J=>J!=null),k=Math.min(0,...v),_=Math.max(...v,k+1e-9),$={plotTop:g,plotBottom:b,min:k,max:_},O=[],M=[];let D=[];return p.values.forEach((J,se)=>{if(J==null){D.length&&M.push(D),D=[];return}const we=e.times[se]??o,_e={x:gs(a,we),y:Ww($,J),time:we,value:J,index:se};O.push(_e),D.push(_e)}),D.length&&M.push(D),{column:p.column,index:m,kind:jw(p.column,p.values),color:qw(m),top:w,plotTop:g,plotBottom:b,min:k,max:_,runs:M,points:O}}),d=(l[l.length-1]?.plotBottom??ti.top)+Uw,f=Hw(s-o),h=[];if(e.times.length){const p=cA(o,s,(i-r)/aA[f]);for(const m of p.times){const y=gs(a,m),w=y-r<34?"start":i-y<34?"end":"middle";h.push({x:y,label:lA(m,p.unit,p.step),anchor:w})}}return{width:t,height:d+Gw,plotLeft:r,plotRight:i,first:o,last:s,unit:f,lanes:l,ticks:h,axisY:d}}function it(e,t,n={}){const r=e.createElementNS(GC,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}const Zt=e=>Math.round(e*10)/10;let bA=0;const wA="Time series plot. Left and Right arrows read the points one by one, Home and End jump to the ends, Escape hides the read-out. Drag across the plot to zoom.";function _A(e,t,n={}){const r=e.ownerDocument,i=t.series.map(I=>I.column),o={start:0,end:t.times.length-1};let s=new Set,a=o,u=null,c=null,l=rc,d=t,f=Tp(t,l);const h=A(r,"span",{class:"cv-muted cv-chart-summary","data-chart-summary":""}),p=t.series.map((I,R)=>{const U=A(r,"span",{class:"cv-chart-key","aria-hidden":"true"});U.style.setProperty("--cv-key",qw(R));const ne=A(r,"button",{type:"button",class:"cv-chart-series","data-series":I.column,"aria-pressed":"true"},U,A(r,"span",{text:I.column}));return ne.addEventListener("click",()=>{const ce=yA(s,I.column,i);ce!==s&&(s=ce,D())}),ne}),m=A(r,"div",{class:"cv-chart-legend",role:"group","aria-label":"Show or hide a series"},...p),y=A(r,"button",{type:"button",class:"cv-chart-reset","data-reset-zoom":"",hidden:!0,text:"Reset zoom"}),w=it(r,"svg",{class:"cv-chart-svg",role:"img",preserveAspectRatio:"xMidYMid meet"}),g=A(r,"div",{class:"cv-chart-readout",id:`cv-chart-readout-${++bA}`,"data-chart-readout":"",role:"status","aria-live":"polite",hidden:!0}),b=A(r,"div",{class:"cv-chart-plot",tabindex:0,role:"group","aria-label":wA,"aria-describedby":g.id},w),v=A(r,"div",{class:"cv-chart-body"},b,g),k=it(r,"rect",{class:"cv-chart-brush"}),_=it(r,"g",{class:"cv-chart-cross","aria-hidden":"true"}),$=[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),O=A(r,"section",{class:"cv-chart cia-graph-surface","data-view":"chart","aria-label":`Time series by ${t.xColumn}`},A(r,"header",{class:"cv-flows-head"},A(r,"div",{class:"cv-title"},A(r,"strong",{text:"Time series"}),h)),$.length?A(r,"p",{class:"cv-note",role:"note","data-chart-note":"",text:$.join(" ")}):null,A(r,"div",{class:"cv-chart-bar"},m,y,n.toggle??null),v);e.replaceChildren(O);function M(){const I=[],R=f.lanes[0]?.plotTop??0,U=d.times.length>1?(f.plotRight-f.plotLeft)/(d.times.length-1):24,ne=Math.max(6,Math.min(24,U*.6));for(const ee of d.failures){const Ee=gs(f,ee.time),Ae=it(r,"rect",{class:"cv-chart-failure","data-failure":ee.day,x:Zt(Ee-ne/2),y:R,width:Zt(ne),height:Math.max(0,f.axisY-R)});I.push(Ae)}for(const ee of f.lanes){const Ee=it(r,"g",{class:"cv-chart-lane","data-series":ee.column}),Ae=it(r,"rect",{class:"cv-chart-swatch",x:f.plotLeft,y:ee.top+4,width:14,height:4,rx:2});Ae.style.fill=ee.color;const z=it(r,"text",{class:"cv-chart-name",x:f.plotLeft+20,y:ee.top+11});z.textContent=ee.column,Ee.append(Ae,z,it(r,"line",{class:"cv-chart-grid",x1:f.plotLeft,x2:f.plotRight,y1:ee.plotTop,y2:ee.plotTop}),it(r,"line",{class:"cv-chart-base",x1:f.plotLeft,x2:f.plotRight,y1:ee.plotBottom,y2:ee.plotBottom}));const G=it(r,"text",{class:"cv-chart-tick",x:f.plotLeft-8,y:ee.plotTop+4,"text-anchor":"end"});G.textContent=Ep(ee.max,ee.kind);const H=it(r,"text",{class:"cv-chart-tick",x:f.plotLeft-8,y:ee.plotBottom+4,"text-anchor":"end"});H.textContent=Ep(ee.min,ee.kind),Ee.append(G,H);for(const Y of ee.runs){if(Y.length<2)continue;const le=it(r,"polyline",{class:"cv-chart-line",points:Y.map(ie=>`${Zt(ie.x)},${Zt(ie.y)}`).join(" "),fill:"none"});le.style.stroke=ee.color,Ee.append(le)}if(ee.points.length<=KC)for(const Y of ee.points){const le=it(r,"circle",{class:"cv-chart-dot",cx:Zt(Y.x),cy:Zt(Y.y),r:3,"data-index":a.start+Y.index,"data-time":Y.time});le.style.fill=ee.color,Ee.append(le)}I.push(Ee)}const ce=it(r,"g",{class:"cv-chart-axis"});for(const ee of f.ticks){const Ee=it(r,"text",{class:"cv-chart-tick",x:Zt(ee.x),y:f.axisY+14,"text-anchor":ee.anchor});Ee.textContent=ee.label,ce.append(Ee)}return I.push(ce),I}function D(){d=gA(t,a.start,a.end),f=Tp(d,l,s);const I=f.lanes.map(U=>U.column);w.setAttribute("viewBox",`0 0 ${f.width} ${f.height}`),w.setAttribute("aria-label",`Line chart of ${I.join(", ")} by ${t.xColumn}, ${d.times.length} ${d.times.length===1?"point":"points"}`),w.replaceChildren(k,...M(),_),h.textContent=hA(d,s);for(const U of p){const ne=!s.has(U.dataset.series??"");U.setAttribute("aria-pressed",String(ne)),ne&&I.length===1?(U.setAttribute("aria-disabled","true"),U.title="At least one series stays visible"):(U.removeAttribute("aria-disabled"),U.removeAttribute("title"))}const R=a.start!==o.start||a.end!==o.end;y.hidden=!R,O.dataset.zoomed=String(R),J(),se()}function J(){if(!c||Math.abs(c.to-c.from)<xp){k.style.display="none";return}const I=f.lanes[0]?.plotTop??0,R=Math.max(f.plotLeft,Math.min(c.from,c.to)),U=Math.min(f.plotRight,Math.max(c.from,c.to));k.setAttribute("x",String(Zt(R))),k.setAttribute("width",String(Zt(Math.max(0,U-R)))),k.setAttribute("y",String(I)),k.setAttribute("height",String(Math.max(0,f.axisY-I))),k.style.display=""}function se(){if(_.replaceChildren(),u==null||u<a.start||u>a.end){u=null,_.style.display="none",g.hidden=!0,g.replaceChildren(),delete b.dataset.focus;return}const I=u-a.start,R=d.times[I]??f.first,U=Zt(gs(f,R)),ne=f.lanes[0]?.plotTop??0;_.append(it(r,"line",{class:"cv-chart-crossline",x1:U,x2:U,y1:ne,y2:f.axisY}));const ce=[];for(const Ae of f.lanes){const z=d.series[Ae.index]?.values[I]??null;if(z!=null){const H=it(r,"circle",{class:"cv-chart-focus",cx:U,cy:Zt(Ww(Ae,z)),r:4.5});H.style.fill=Ae.color,_.append(H)}const G=A(r,"span",{class:"cv-chart-key","aria-hidden":"true"});G.style.setProperty("--cv-key",Ae.color),ce.push(A(r,"dt",{},G,Ae.column),A(r,"dd",{"data-value":Ae.column,text:ms(z,Ae.kind)}))}_.style.display="",_.dataset.index=String(u),_.dataset.time=String(R),b.dataset.focus=String(u);const ee=d.failures.find(Ae=>Ae.time===R),Ee=d.rowCounts[I]??1;g.replaceChildren(...[A(r,"time",{datetime:new Date(R).toISOString(),text:rA(R,d.daily)}),ee?A(r,"p",{class:"cv-chart-readout-note","data-failure":ee.code,text:`No answer: ${ee.code}`}):null,Ee>1?A(r,"p",{class:"cv-chart-readout-note","data-rows":Ee,text:`${vi.format(Ee)} transfers`}):null,A(r,"dl",{},...ce)].filter(Ae=>Ae!=null)),g.hidden=!1,we(U,ne)}function we(I,R){const U=w.getBoundingClientRect(),ne=v.getBoundingClientRect(),ce=U.width>0?U.width/f.width:1,ee=U.left-ne.left+I*ce,Ee=I>(f.plotLeft+f.plotRight)/2;g.style.left=`${Math.round(Ee?ee-12:ee+12)}px`,g.style.top=`${Math.round(U.top-ne.top+R*ce)}px`,g.dataset.side=Ee?"left":"right"}const _e=I=>{const R=w.getBoundingClientRect();return R.width>0?(I-R.left)*f.width/R.width:Number.NaN},Ge=I=>a.start+pA(d.times,fu(f,I));b.addEventListener("pointermove",I=>{const R=_e(I.clientX);Number.isFinite(R)&&(c&&(c.to=R,J()),u=Ge(R),se())}),b.addEventListener("pointerdown",I=>{if(I.button!==0)return;const R=_e(I.clientX);if(Number.isFinite(R)){I.preventDefault(),b.focus({preventScroll:!0}),c={from:R,to:R,pointer:I.pointerId};try{b.setPointerCapture(I.pointerId)}catch{}}});const F=I=>{if(!c)return;const{from:R,to:U,pointer:ne}=c;c=null;try{b.releasePointerCapture(ne)}catch{}if(J(),!I||Math.abs(U-R)<xp)return;const ce=mA(t.times,fu(f,R),fu(f,U));!ce||ce.start===a.start&&ce.end===a.end||(a=ce,u=Ge(U),D())};b.addEventListener("pointerup",()=>F(!0)),b.addEventListener("pointercancel",()=>F(!1)),b.addEventListener("pointerleave",()=>{c||(u=null,se())}),b.addEventListener("keydown",I=>{let R;if(I.key==="ArrowRight")R=u==null?a.start:Math.min(a.end,u+1);else if(I.key==="ArrowLeft")R=u==null?a.end:Math.max(a.start,u-1);else if(I.key==="Home")R=a.start;else if(I.key==="End")R=a.end;else if(I.key==="Escape"){if(u==null&&!c)return;c&&F(!1),R=null}else return;I.preventDefault(),u=R,se()}),y.addEventListener("click",()=>{a=o,u=null,D(),b.focus({preventScroll:!0})});const B=()=>{const I=Math.round(b.clientWidth);return I>0?Math.max(jC,I):null},W=()=>{const I=B();I==null||I===l||(l=I,D())};l=B()??rc,D();const Q=r.defaultView?.ResizeObserver,K=Q?new Q(()=>W()):null;return K?.observe(b),{root:O,get layout(){return f},refit:W,destroy(){K?.disconnect()}}}const kA="chain-insights.transfers.v1",SA="graph_expand",xA="2015-01-01";function EA(e,t,n,r){return{network:e,from:t,to:n,day:r}}function $A(e,t){const n=typeof e.first_seen_timestamp=="number"&&e.first_seen_timestamp>0?uu(e.first_seen_timestamp):null,r=typeof e.last_seen_timestamp=="number"&&e.last_seen_timestamp>0?uu(e.last_seen_timestamp):uu(t);return{first:n,last:n&&r<n?n:r}}function Zo(e,t){return e<=(t??xA)}function TA(e){if(!e)return"no answer";const t=Co(e);return e.isError?t||"the server refused the read":/query_timeout|topology_busy/.test(t)?t:Kw(e.structuredContent)?null:t||"the answer held no transfers"}function Kw(e){const t=e;if(!t||t.schema!==kA||!Array.isArray(t.transfers)||typeof t.from!="string"||typeof t.to!="string"||!Xf(t.day))return null;const n=[];for(const r of t.transfers){if(!r||typeof r!="object")continue;const i=r;if(typeof i.tx_id!="string")continue;const o=Qt(i.block_timestamp);n.push({tx_id:i.tx_id,block_timestamp:o,amount:typeof i.amount=="string"?i.amount:typeof i.amount=="number"?String(i.amount):null,asset_symbol:typeof i.asset_symbol=="string"&&i.asset_symbol?i.asset_symbol:null,amount_usd:Qt(i.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 CA(e){return[...e].sort((t,n)=>(n.block_timestamp??0)-(t.block_timestamp??0)||t.tx_id.localeCompare(n.tx_id))}function AA(e){if(e==null)return"—";const t=e.trim().match(/^(-?)(\d+)(?:\.(\d+))?$/);if(!t)return e;const[,n="",r="0",i=""]=t,o=i.replace(/0+$/,"");return`${n}${r.replace(/\B(?=(\d{3})+(?!\d))/g,",")}${o?`.${o}`:""}`}function IA(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 NA(e){return e==null?"—":`${new Date(Yf(e)).toISOString().slice(11,19)} UTC`}function hu(e){return new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeZone:"UTC"}).format(new Date(`${e}T00:00:00Z`))}function RA(e,t){const n=t.now??Date.now,r=A(e,"strong",{"data-link-title":"",text:"Transfers"}),i=A(e,"button",{type:"button",class:"cv-button cv-icon","data-link-close":"","aria-label":"Close the transfers",text:"×"}),o=A(e,"p",{class:"cv-link-pair","data-link-pair":""}),s=A(e,"p",{class:"cv-link-day","data-link-day":""}),a=A(e,"div",{class:"cv-link-body","data-link-body":"",role:"status","aria-live":"polite"}),u=A(e,"button",{type:"button",class:"cv-button","data-link-earlier":"",text:"Earlier day"}),c=A(e,"section",{class:"cv-linkpanel cv-linkpanel-embedded","data-link-panel":"","aria-label":"Transfers of the selected link",hidden:!0},A(e,"header",{class:"cv-link-head"},r,null),o,s,a,u);let l=null,d=0;function f(){if(!l){c.hidden=!0;return}c.hidden=!1,o.replaceChildren(A(e,"code",{"data-link-from":"",text:l.from})," → ",A(e,"code",{"data-link-to":"",text:l.to})),s.textContent=`${hu(l.day)} (UTC)`,u.disabled=l.status==="loading"||Zo(l.day,l.firstDay);const w=Zo(l.day,l.firstDay)?null:hp(l.day);u.setAttribute("aria-label",w?`Earlier day: show the transfers of ${hu(w)}`:"Earlier day: this is the first day the link was seen"),l.status==="loading"?a.replaceChildren(A(e,"p",{class:"cv-muted",text:`Loading the transfers of ${hu(l.day)}…`})):l.status==="error"?a.replaceChildren(A(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(A(e,"p",{class:"cv-muted","data-link-empty":"",text:"No transfers between these two addresses on this day."})):(a.replaceChildren(A(e,"ol",{class:"cv-transfers"},...l.transfers.map(g=>LA(e,g,t.host)))),l.truncated&&a.append(A(e,"p",{class:"cv-muted","data-link-truncated":"",text:`${l.transfers.length} transfers shown. This day holds more.`}))),l.status!=="loading"&&Zo(l.day,l.firstDay)&&l.firstDay&&a.append(A(e,"p",{class:"cv-muted","data-link-first":"",text:"This is the first day the link was seen."}))}async function h(w){const g=++d,b=l;b.day=w,b.status="loading",b.error=null,f(),t.onLayout?.();let v=null;try{v=await t.host.callServerTool({name:SA,arguments:EA(t.network,b.from,b.to,w)})}catch(_){v={isError:!0,content:[{type:"text",text:_ instanceof Error?_.message:String(_)}]}}if(g!==d||l!==b)return b;const k=TA(v);if(k)b.status="error",b.transfers=[],b.error=k.length>300?`${k.slice(0,299)}…`:k;else{const _=Kw(v.structuredContent);b.status="ready",b.transfers=CA(_.transfers),b.truncated=_.truncated}return f(),t.onLayout?.(),b}const p=()=>y.close(),m=()=>{y.earlier()};i.addEventListener("click",p),u.addEventListener("click",m);const y={element:c,open(w){const g=$A(w,n());return l={from:w.from,to:w.to,day:g.last,firstDay:g.first,status:"loading",transfers:[],truncated:!1,error:null},h(g.last)},async earlier(){return!l||l.status==="loading"||Zo(l.day,l.firstDay)?null:h(hp(l.day))},close(){d++,l=null,f(),t.onLayout?.()},state:()=>l?{...l,transfers:[...l.transfers]}:null,destroy(){d++,i.removeEventListener("click",p),u.removeEventListener("click",m)}};return y}function LA(e,t,n){const r=$w(t.tx_id),i=n.openLink,o=r&&i?A(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:mi(t.tx_id)}):A(e,"code",{title:t.tx_id,text:mi(t.tx_id)});return r&&i&&o.addEventListener("click",()=>{i.call(n,{url:r}).catch(()=>{})}),A(e,"li",{class:"cv-transfer","data-tx":t.tx_id},A(e,"span",{class:"cv-transfer-time",text:NA(t.block_timestamp)}),A(e,"span",{class:"cv-transfer-amount",text:`${AA(t.amount)}${t.asset_symbol?` ${t.asset_symbol}`:""}`}),A(e,"span",{class:"cv-transfer-usd",text:t.amount_usd==null?"— USD":IA(t.amount_usd)}),o)}const zA="graph_expand",Bo="too busy to expand",Jw=640,PA=300,pu=.45,DA="Full screen shows the whole graph",OA="Open in browser",mu="The host did not open the link.",Cp=400,gu="expanded",Yw=5e3,MA="Click an address for its details. Double-click it to load its senders and receivers, and again to fold them back. Click a link to list its transfers.",oc=new Intl.NumberFormat("en-US");function Ap(e){const t=e.remaining;if(!t||typeof t!="object")return null;const n=Number(t.senders),r=Number(t.receivers);return!Number.isFinite(n)||!Number.isFinite(r)?null:{senders:Math.max(0,n),receivers:Math.max(0,r)}}function FA(e){if(!e||e.senders+e.receivers<=0)return null;const t=(n,r)=>`${oc.format(n)} more ${r}${n===1?"":"s"}`;return`${t(e.senders,"sender")}, ${t(e.receivers,"receiver")} not loaded`}function UA(e,t){return`Not loaded: ${oc.format(e)} ${e===1?"link":"links"} of ${t} would take the picture past ${oc.format(Yw)} addresses. Fold another address to make room.`}const Ip=e=>!!(e&&(e.truncated||e.remaining&&e.remaining.senders+e.remaining.receivers>0));let GA=0;const jA=[["scam","Scam"],["sanctioned","Sanctioned"],["exchange","Exchange"],["victim","Victim"],["pool","Pool"],["other","Other"]];function th(e){return typeof e=="string"&&/^http:\/\/(?:127\.0\.0\.1|localhost):\d+(?:[/?#]|$)/.test(e)}function ZA(e){return!e.browser&&!!e.host.openLink&&th(e.viewUrl)}function BA(e,t,n){return{network:e,address:t,in_offset:n?.in_offset??0,out_offset:n?.out_offset??0}}function HA(e){const t=Co(e);return e?e.isError?t||"the server refused the expansion":/query_timeout|topology_busy/.test(t)?t:Hf(e.structuredContent)?null:t||"the answer held no money flows":"no answer"}function VA(e,t,n,r=Jw,i=PA){if(!e||t<=0)return{height:r,fits:!0};const o=Math.max(1,e.x2-e.x1),s=Math.max(1,e.y2-e.y1),a=Math.max(pu,Math.min(1,(t-pi*2)/o)),u=Math.ceil(n+s*a+pi*2),c=Math.min(r,Math.max(i,u));return sp(e,t,c-n)>=pu?{height:c,fits:!0}:{height:r,fits:sp(e,t,r-n)>=pu}}function qA(e){return/query_timeout|topology_busy|timed? ?out/i.test(e)}function WA(e){const t=e.split(`
|
|
110
|
-
`)[0].trim();return t.length>200?`${t.slice(0,199)}…`:t}function KA(e,t){return`investigator expanded ${e}: ${t} new addresses`}function JA(e,t){const n=e.nodes.find(r=>r.address.toLowerCase()===t.toLowerCase());return n&&To({role:n.role??null,labels:n.labels??[]})||"Other"}function Xw(e,t,n){const r=e.ownerDocument,i=t.network??"robinhood",o=t.center.toLowerCase(),s=()=>new Map(t.cursor?[[o,{cursor:t.cursor,truncated:!!t.truncated,remaining:Ap(t)}]]:[]);let a=s();const u=new Set,c=new Set;let l=[];const d=new Set;let f=null,h=null;const p=n.now??Date.now,m=n.title??"Money flow graph",y=A(r,"p",{class:"cv-status",role:"status","aria-live":"polite",text:MA}),w=A(r,"ul",{class:"cv-roles","aria-label":"Address roles"}),g=A(r,"div",{class:"cv-canvas","data-graph":""}),b=A(r,"div",{class:"cv-detail","aria-label":"Selection"},A(r,"strong",{"data-selection-title":""}),A(r,"code",{"data-selection-identity":""}),A(r,"div",{class:"cv-detail-meta","data-selection-meta":""})),v=A(r,"strong",{"data-side-title":"",text:"Details"}),k=A(r,"button",{type:"button",class:"cv-button cv-icon","data-side-close":"","aria-label":"Close the details",text:"×"}),_=A(r,"button",{type:"button",class:"cv-button","data-toggle-expand":"",hidden:!0,text:"Expand"}),$=A(r,"button",{type:"button",class:"cv-button","data-more":"",hidden:!0,text:"More flows"}),O=A(r,"p",{class:"cv-remaining cv-muted","data-remaining":"",hidden:!0}),M=RA(r,{host:n.host,network:i,now:n.now,embedded:!0,onLayout:()=>Ve()}),D=A(r,"aside",{class:"cv-side","data-side-panel":"","aria-label":"Details of the selection",hidden:!0},A(r,"header",{class:"cv-side-head"},v,k),b,O,A(r,"div",{class:"cv-side-actions"},_,$),M.element),J=A(r,"button",{type:"button",class:"cv-button","data-fullscreen":"",hidden:!0,"aria-label":"Open full screen",text:"Full screen"}),se=A(r,"button",{type:"button",class:"cv-button","data-reset":"","aria-label":"Reset the graph to the first answer",text:"Reset"}),we=A(r,"span",{class:"cv-hint","data-fullscreen-hint":"",hidden:!0,text:DA}),_e=A(r,"button",{type:"button",class:"cv-button","data-open-browser":"",hidden:!ZA(n),"aria-label":"Open the graph in your browser",title:"Open the graph in your browser",text:OA}),Ge=A(r,"div",{class:"cv-actions"},A(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"out","aria-label":"Zoom out",text:"−"}),A(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"in","aria-label":"Zoom in",text:"+"}),A(r,"button",{type:"button",class:"cv-button","data-zoom":"fit","aria-label":"Fit the graph",text:"Fit"}),se,we,J,_e),F=A(r,"span",{class:"cv-muted","data-subtitle":""}),B=`cv-addresses-${++GA}`,W=A(r,"div",{class:"cv-visually-hidden",role:"listbox",tabindex:"0",id:B,"data-address-list":"","aria-label":"Drawn addresses. Down and Up move, Enter shows the details, Shift+Enter expands or folds."});let Q=[],K=-1;const I=A(r,"section",{class:"cv-flows cia-graph-surface","data-view":"flows","aria-label":`${m} of ${o}`},A(r,"header",{class:"cv-flows-head"},A(r,"div",{class:"cv-title"},A(r,"strong",{text:m}),F),n.toggle??null,Ge),w,n.note?A(r,"p",{class:"cv-note",role:"note","data-left-out":"",text:n.note}):null,A(r,"div",{class:"cv-body"},W,g,D),y);e.replaceChildren(I);function R(){const j=fe.model(),me=j.truncated?" · more flows than shown":"";F.textContent=`${o} · ${JA(t,o)} · ${i} · ${j.nodes.length} addresses${me}`;const be=new Set(j.nodes.map(Ne=>Ne.role??"other"));w.replaceChildren(...jA.filter(([Ne])=>be.has(Ne)).map(([Ne,Ye])=>{const Nt=A(r,"i",{"aria-hidden":"true"});return Nt.style.background=`var(--cia-graph-role-${Ne})`,A(r,"li",{"data-role":Ne},Nt,Ye)})),U()}function U(){const j=fe.model().nodes,me=Q[K]??null;Q=j.map(Ne=>Ne.address.toLowerCase()),W.replaceChildren(...j.map((Ne,Ye)=>A(r,"div",{role:"option",id:`${B}-${Ye}`,"data-list-address":Q[Ye],"aria-selected":"false",text:`${Ne.address} ${To({role:Ne.role??null,labels:Ne.labels??[]})||"Other"}`})));const be=me?Q.indexOf(me):-1;K=be>=0?be:Q.length?Math.min(Math.max(K,-1),Q.length-1):-1,ne()}function ne(){for(const me of W.children)me.setAttribute("aria-selected",String(me.id===`${B}-${K}`));K>=0?W.setAttribute("aria-activedescendant",`${B}-${K}`):W.removeAttribute("aria-activedescendant");const j=r.activeElement===W;fe.highlight(j?Q[K]??null:null)}function ce(j){return j?fe.model().nodes.find(me=>me.id===j)?.address.toLowerCase()??null:null}const ee=j=>{const me=j.target,be=j.key==="Enter"||j.key===" ",Ne=me?.closest?.("[data-node-id]");if(be&&j.shiftKey&&Ne){j.preventDefault();const Ye=ce(Ne.dataset.nodeId);Ye&&ve(Ye)}};g.addEventListener("keydown",ee,!0);function Ee(j){Q.length&&(K=Math.max(0,Math.min(Q.length-1,j)),ne())}const Ae=()=>{K<0&&Q.length&&(K=0),ne()},z=()=>fe.highlight(null),G=j=>{const me=Q[K];switch(j.key){case"ArrowDown":j.preventDefault(),Ee(K+1);return;case"ArrowUp":j.preventDefault(),Ee(K-1);return;case"Home":j.preventDefault(),Ee(0);return;case"End":j.preventDefault(),Ee(Q.length-1);return;case"Escape":yn();return;case"Enter":case" ":if(j.preventDefault(),!me)return;j.shiftKey?ve(me):fe.select(me);return}};W.addEventListener("focus",Ae),W.addEventListener("blur",z),W.addEventListener("keydown",G);function H(){const j=h;if(!j){_.hidden=!0,$.hidden=!0,O.hidden=!0;return}const me=d.has(j),be=me?FA(a.get(j)?.remaining??null):null;O.hidden=!be,O.textContent=be??"",_.hidden=!1,_.disabled=u.has(j)||c.has(j),_.textContent=u.has(j)?"Too busy to expand":me?"Collapse":"Expand",_.setAttribute("aria-label",`${_.textContent} ${j}`),$.hidden=!(me&&Ip(a.get(j)))}function Y(j){const me=D.hidden;D.hidden=j.kind==null,j.kind==="node"&&j.node?(h=j.node.address.toLowerCase(),v.textContent="Address details",M.close()):(h=null,j.kind==="edge"?v.textContent="Link details":M.close()),H(),me!==D.hidden&&Ve()}let le=null;function ie(){le&&clearTimeout(le),le=null}function $e(j){const me=j.source==="pointer"&&j.kind==="node"&&j.node,be=j.source!=="program"&&j.kind==="edge"&&j.edge;if(ie(),me){const Ne=j.node.address.toLowerCase(),Ye=p();f&&f.address===Ne&&Ye-f.at<=Cp?(f=null,yn(),ve(Ne)):(f={address:Ne,at:Ye},le=setTimeout(()=>{le=null,Y(j)},Cp));return}j.kind!=="node"&&(f=null),Y(j),be&&M.open(j.edge)}const Ie=n.height??Jw,de=`${m} of ${o}: senders on the left, receivers on the right. Select an address for its details; double-click it, or press Shift+Enter, to load its senders and receivers, and again to fold them back. Select a link to list its transfers.`;function ze(){return oC(g,t,{layout:"tree",width:n.width??720,height:Ie,now:n.now,controls:Ge,selectionRoot:b,onSelect:$e,openLink:j=>{n.host.openLink?.({url:j}).catch(()=>{y.textContent=mu})},label:de})}let fe=ze();R();let Je=n.displayMode??"inline",He=n.availableDisplayModes??[];const pt=()=>!n.browser&&!!n.host.requestDisplayMode&&(He.length===0||He.includes("fullscreen"));function Ve(){if(Je==="fullscreen"){I.style.removeProperty("height"),we.hidden=!0;return}const j=g.clientWidth||n.width||720,me=Math.max(0,I.offsetHeight-g.offsetHeight)||140,{height:be,fits:Ne}=VA(fe.contentBounds(),j,me);I.style.height=`${be}px`,we.hidden=Ne||!pt(),I.dataset.fits=String(Ne),fe.fit()}async function C(j){try{await n.host.updateModelContext?.({content:[{type:"text",text:j}]})}catch{}}async function P(j,me=!1){const be=j.toLowerCase();if(u.has(be))return y.textContent=`${be} is ${Bo}.`,{added:[],refused:Bo};if(c.has(be))return{added:[],refused:null};const Ne=a.get(be);if(Ne&&!Ip(Ne))return y.textContent=`Every recent flow of ${be} is drawn.`,{added:[],refused:null};c.add(be),H(),y.textContent=`Loading the flows of ${be}…`;let Ye=null;try{Ye=await n.host.callServerTool({name:zA,arguments:BA(i,be,me||Ne?Ne?.cursor:null)})}catch(kt){Ye={isError:!0,content:[{type:"text",text:kt instanceof Error?kt.message:String(kt)}]}}finally{c.delete(be)}const Nt=HA(Ye);if(Nt)return qA(Nt)?(u.add(be),fe.markNode(be,Bo),y.textContent=`${be} is ${Bo}. The drawing is kept.`):y.textContent=`${be} could not be expanded: ${WA(Nt)}. The drawing is kept; try again.`,H(),{added:[],refused:Nt};const qe=Ye.structuredContent,Xa=fe.model(),zn=new Set(Xa.nodes.map(kt=>kt.address.toLowerCase())),Qa=new Set;for(const kt of qe.nodes)zn.has(kt.address.toLowerCase())||Qa.add(kt.address.toLowerCase());for(const kt of qe.edges)for(const Io of[kt.from,kt.to])zn.has(Io.toLowerCase())||Qa.add(Io.toLowerCase());if(zn.size+Qa.size>Yw){const kt=new Set(Xa.edges.map(Pn=>`${Pn.from.toLowerCase()}->${Pn.to.toLowerCase()}`)),Io=new Set(qe.edges.map(Pn=>`${Pn.from.toLowerCase()}->${Pn.to.toLowerCase()}`).filter(Pn=>!kt.has(Pn))).size,uh=UA(Io,be);return y.textContent=uh,H(),{added:[],refused:uh}}const Ao=fe.merge(qe,be);return l.push({address:be,page:qe}),d.add(be),fe.flagNode(be,gu,!0),a.set(be,{cursor:qe.cursor??null,truncated:!!qe.truncated,remaining:Ap(qe)}),R(),Ve(),H(),y.textContent=`${Ao.length} new ${Ao.length===1?"address":"addresses"} linked to ${be}. Double-click it again to fold them back.`,await C(KA(be,Ao.length)),{added:Ao,refused:null}}function re(j){const me=j.toLowerCase();if(!d.has(me))return{removed:0};const be=fe.model().nodes.length;d.delete(me),a.delete(me);const Ne=l.filter(qe=>qe.address!==me),Ye=[];fe.batch(()=>{fe.flagNode(me,gu,!1),fe.update(t);for(const qe of Ne)fe.model().nodes.some(zn=>zn.address.toLowerCase()===qe.address)?(fe.merge(qe.page,qe.address),Ye.push(qe)):Ye.some(zn=>zn.address===qe.address)||(fe.flagNode(qe.address,gu,!1),d.delete(qe.address),a.delete(qe.address))}),l=Ye;const Nt=Math.max(0,be-fe.model().nodes.length);return h&&!fe.model().nodes.some(qe=>qe.address.toLowerCase()===h)&&(D.hidden=!0,h=null),R(),Ve(),H(),y.textContent=`Folded ${me} back: ${Nt} ${Nt===1?"address":"addresses"} removed.`,C(`investigator collapsed ${me}: ${Nt} addresses removed`),{removed:Nt}}async function ve(j){d.has(j)?re(j):await P(j)}function he(){ie(),fe.destroy(),l=[],d.clear(),u.clear(),c.clear(),a=s(),f=null,h=null,M.close(),D.hidden=!0,fe=ze(),R(),Ve(),H(),y.textContent="Back to the first answer."}function rt(j,me){j&&(Je=j),me&&(He=me),I.dataset.displayMode=Je,J.hidden=!pt(),J.textContent=Je==="fullscreen"?"Exit full screen":"Full screen",J.setAttribute("aria-label",Je==="fullscreen"?"Back to the inline view":"Open full screen"),Ve()}rt(Je);const It=async()=>{const j=Je==="fullscreen"?"inline":"fullscreen";try{const me=await n.host.requestDisplayMode?.({mode:j});rt(me?.mode??j)}catch{y.textContent="The host did not change the display mode."}},Wt=async()=>{const j=n.viewUrl;if(!(!th(j)||!n.host.openLink))try{(await n.host.openLink({url:j}))?.isError===!0&&(y.textContent=mu)}catch{y.textContent=mu}},Vr=()=>he();function yn(){ie();const j=!D.hidden;fe.select(null),M.close(),D.hidden=!0,h=null,H(),j&&Ve()}const vn=()=>yn(),jt=()=>{h&&ve(h)},Kt=()=>{h&&P(h,!0)};return J.addEventListener("click",It),_e.addEventListener("click",Wt),se.addEventListener("click",Vr),k.addEventListener("click",vn),_.addEventListener("click",jt),$.addEventListener("click",Kt),{root:I,get graph(){return fe},expand:j=>P(j),collapse:re,reset:he,expanded:()=>[...d],linkPanel:M,openLink(j,me){const be=fe.model().edges.find(Ne=>Ne.from===j.toLowerCase()&&Ne.to===me.toLowerCase());return be?(fe.select(be.id),M.open(be)):Promise.resolve(null)},setTheme(j){fe.setTheme(j)},setDisplayMode:rt,refit:Ve,destroy(){ie(),g.removeEventListener("keydown",ee,!0),W.removeEventListener("focus",Ae),W.removeEventListener("blur",z),W.removeEventListener("keydown",G),J.removeEventListener("click",It),_e.removeEventListener("click",Wt),se.removeEventListener("click",Vr),k.removeEventListener("click",vn),_.removeEventListener("click",jt),$.removeEventListener("click",Kt),M.destroy(),fe.destroy()}}}function sc(e){return{kind:e,flows:()=>[],setTheme(){},setDisplayMode(){},refit(){},destroy(){}}}function YA(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 Qw=e=>({host:e.host,availableDisplayModes:e.availableDisplayModes,displayMode:e.displayMode,now:e.now,width:e.width,height:e.height,viewUrl:e.browser?null:e.viewUrl??null,browser:e.browser===!0});function XA(e){return typeof e?.query=="string"&&e.query?e.query:null}function QA(e,t,n){const r=Array.isArray(e?.queries)?e.queries:[],i=s=>{const a=s?.query;return typeof a=="string"&&a?a:null},o=r.find(s=>s?.id===t);return i(o||r[n])}function eI(e,t){const n=e.structuredContent;if(!t||!n?.facts?.query)return e;const r=$C(Va(n),t);return r?{...e,structuredContent:{...n,facts:{...n.facts,query:{...n.facts.query,results:r}}}}:e}function tI(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 ${n.format(Cw)} addresses. The table has the rows.`}function nI(e,t,n){const r=[];let i="picture";const o=s=>{for(const a of s.querySelectorAll("[data-show]"))a.setAttribute("aria-pressed",String(a.dataset.show===i))};return{make(){const s=A(e,"button",{type:"button",class:"cv-toggle-button","data-show":"picture",text:t}),a=A(e,"button",{type:"button",class:"cv-toggle-button","data-show":"table",text:"Table"});s.addEventListener("click",()=>n("picture")),a.addEventListener("click",()=>n("table"));const u=A(e,"div",{class:"cv-toggle",role:"group","aria-label":"Show the rows as"},s,a);return r.push(u),o(u),u},set(s){i=s,r.forEach(o)}}}function rI(e,t){const n=t?.facts?.subject;return{content:[],structuredContent:{schema:Jf,tool:"graph_query",facts:{...n?{subject:n}:{},query:{results:e,count:e.length,truncated:!1}}}}}function iI(e){const t=Lw(e.structuredContent);if(t)return{model:t.model,table:rI(t.rows,e.structuredContent)};const n=Qf(Va(e.structuredContent));return n?{model:n,table:e}:null}function e_(e,t,n,r=null){const i=e.ownerDocument,o=eI(t,r),s=Ow(o),a=s==="chart"?iI(o):null;if(s!=="graph"&&!a)return s==="table"?_p(e,o):yi(e,o),sc(s==="table"?"table":"text");const u=o.structuredContent,c=Va(u),l=a?.table??t,d=A(i,"div",{class:"cv-face","data-face":"picture"}),f=A(i,"div",{class:"cv-face","data-face":"table",hidden:!0});e.replaceChildren(d,f);const h=nI(i,s==="graph"?"Graph":"Chart",g=>w(g));let p=null,m=null,y=!1;if(s==="graph"){const g=IC(c,cC(u),zw(r)?.address);p=Xw(d,g.view,{...Qw(n),title:"Money flow graph",toggle:h.make(),note:tI(g.rowsLeftOut,g.rowsTotal)})}else m=_A(d,a.model,{toggle:h.make()});function w(g){d.hidden=g!=="picture",f.hidden=g!=="table",g==="table"&&!y&&(y=!0,_p(f,l,{toggle:h.make()})),h.set(g),g==="picture"&&(p?.refit(),m?.refit())}return{kind:s,flows:()=>p?[p]:[],setTheme(g){p?.setTheme(g)},setDisplayMode(g,b){p?.setDisplayMode(g,b)},refit(){d.hidden||(p?.refit(),m?.refit())},destroy(){p?.destroy(),m?.destroy()}}}function oI(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:Jf,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 sI(e,t,n){const r=e.ownerDocument,i=Pw(t.structuredContent),o=i.map((p,m)=>A(r,"button",{type:"button",role:"tab",class:"cv-tab",id:`cv-tab-${m}`,"data-tab":p.id,"aria-controls":`cv-panel-${m}`,"aria-selected":"false",tabindex:-1,text:p.ok?p.id:`${p.id} (failed)`})),s=i.map((p,m)=>A(r,"div",{class:"cv-tabpanel",role:"tabpanel",id:`cv-panel-${m}`,"aria-labelledby":`cv-tab-${m}`,hidden:!0})),a=A(r,"div",{class:"cv-tabs",role:"tablist","aria-label":"Queries of the batch"},...o);e.replaceChildren(a,...s);const u=i.map(()=>null);let c=n.displayMode,l=n.availableDisplayModes,d=-1;const f=()=>e.style.setProperty("--cv-tabs-h",`${a.offsetHeight}px`);function h(p){const m=i[p],y=s[p];if(!m||!y)return;d=p,o.forEach((g,b)=>{g.setAttribute("aria-selected",String(b===p)),g.tabIndex=b===p?0:-1}),s.forEach((g,b)=>{g.hidden=b!==p});const w=u[p];if(w)w.refit();else{const g=m.query??QA(n.toolInput,m.id,p),b=e_(y,oI(m,t.structuredContent),{...n,displayMode:c,availableDisplayModes:l},g);u[p]=b,y.dataset.view=b.kind}f()}return o.forEach((p,m)=>{p.addEventListener("click",()=>h(m)),p.addEventListener("keydown",y=>{const w=o.length-1,g=y.key==="ArrowRight"?m===w?0:m+1:y.key==="ArrowLeft"?m===0?w:m-1:y.key==="Home"?0:y.key==="End"?w:null;g!=null&&(y.preventDefault(),h(g),o[g]?.focus())})}),h(0),{kind:"batch",flows:()=>u.flatMap(p=>p?.flows()??[]),setTheme(p){for(const m of u)m?.setTheme(p)},setDisplayMode(p,m){p&&(c=p),m&&(l=m);for(const y of u)y?.setDisplayMode(p,m);f()},refit(){d>=0&&u[d]?.refit()},destroy(){for(const p of u)p?.destroy()}}}function aI(e){const t=e?.structuredContent?.view_url;return th(t)?t:null}function t_(e,t,n){const r={...n,viewUrl:n.viewUrl??aI(t)},i=Ow(t);if(i==="flows"){const o=Xw(e,t.structuredContent,Qw(r));return YA("flows",()=>o)}return i==="graph"||i==="chart"||i==="table"?e_(e,t,r,XA(r.toolInput)):i==="batch"?sI(e,t,r):i==="balance"?(UC(e,t),sc("balance")):(yi(e,t),sc("text"))}function uI(e){return e==="light"||e==="dark"}function cI(e,t=()=>!1){return uI(e?.theme)?e.theme:t()?"dark":"light"}function yu(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 ys(e,t,n={}){const r=e.documentElement,i=cI(t,n.prefersDark);r.setAttribute("data-theme",i),r.style.colorScheme=i;const o=t?.styles?.variables;o&&n.applyVariables&&n.applyVariables(o,r);const s=t?.styles?.css?.fonts;return s&&n.applyFonts&&n.applyFonts(s),i}function lI(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ho={exports:{}},Np;function dI(){if(Np)return Ho.exports;Np=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(k,_,$){return Function.prototype.apply.call(k,_,$)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(k){return Object.getOwnPropertyNames(k).concat(Object.getOwnPropertySymbols(k))}:n=function(k){return Object.getOwnPropertyNames(k)};function r(v){console&&console.warn&&console.warn(v)}var i=Number.isNaN||function(k){return k!==k};function o(){o.init.call(this)}Ho.exports=o,Ho.exports.once=w,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(v){if(typeof v!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof v)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(v){if(typeof v!="number"||v<0||i(v))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+v+".");s=v}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(k){if(typeof k!="number"||k<0||i(k))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+k+".");return this._maxListeners=k,this};function u(v){return v._maxListeners===void 0?o.defaultMaxListeners:v._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(k){for(var _=[],$=1;$<arguments.length;$++)_.push(arguments[$]);var O=k==="error",M=this._events;if(M!==void 0)O=O&&M.error===void 0;else if(!O)return!1;if(O){var D;if(_.length>0&&(D=_[0]),D instanceof Error)throw D;var J=new Error("Unhandled error."+(D?" ("+D.message+")":""));throw J.context=D,J}var se=M[k];if(se===void 0)return!1;if(typeof se=="function")t(se,this,_);else for(var we=se.length,_e=p(se,we),$=0;$<we;++$)t(_e[$],this,_);return!0};function c(v,k,_,$){var O,M,D;if(a(_),M=v._events,M===void 0?(M=v._events=Object.create(null),v._eventsCount=0):(M.newListener!==void 0&&(v.emit("newListener",k,_.listener?_.listener:_),M=v._events),D=M[k]),D===void 0)D=M[k]=_,++v._eventsCount;else if(typeof D=="function"?D=M[k]=$?[_,D]:[D,_]:$?D.unshift(_):D.push(_),O=u(v),O>0&&D.length>O&&!D.warned){D.warned=!0;var J=new Error("Possible EventEmitter memory leak detected. "+D.length+" "+String(k)+" listeners added. Use emitter.setMaxListeners() to increase limit");J.name="MaxListenersExceededWarning",J.emitter=v,J.type=k,J.count=D.length,r(J)}return v}o.prototype.addListener=function(k,_){return c(this,k,_,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(k,_){return c(this,k,_,!0)};function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(v,k,_){var $={fired:!1,wrapFn:void 0,target:v,type:k,listener:_},O=l.bind($);return O.listener=_,$.wrapFn=O,O}o.prototype.once=function(k,_){return a(_),this.on(k,d(this,k,_)),this},o.prototype.prependOnceListener=function(k,_){return a(_),this.prependListener(k,d(this,k,_)),this},o.prototype.removeListener=function(k,_){var $,O,M,D,J;if(a(_),O=this._events,O===void 0)return this;if($=O[k],$===void 0)return this;if($===_||$.listener===_)--this._eventsCount===0?this._events=Object.create(null):(delete O[k],O.removeListener&&this.emit("removeListener",k,$.listener||_));else if(typeof $!="function"){for(M=-1,D=$.length-1;D>=0;D--)if($[D]===_||$[D].listener===_){J=$[D].listener,M=D;break}if(M<0)return this;M===0?$.shift():m($,M),$.length===1&&(O[k]=$[0]),O.removeListener!==void 0&&this.emit("removeListener",k,J||_)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(k){var _,$,O;if($=this._events,$===void 0)return this;if($.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):$[k]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete $[k]),this;if(arguments.length===0){var M=Object.keys($),D;for(O=0;O<M.length;++O)D=M[O],D!=="removeListener"&&this.removeAllListeners(D);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(_=$[k],typeof _=="function")this.removeListener(k,_);else if(_!==void 0)for(O=_.length-1;O>=0;O--)this.removeListener(k,_[O]);return this};function f(v,k,_){var $=v._events;if($===void 0)return[];var O=$[k];return O===void 0?[]:typeof O=="function"?_?[O.listener||O]:[O]:_?y(O):p(O,O.length)}o.prototype.listeners=function(k){return f(this,k,!0)},o.prototype.rawListeners=function(k){return f(this,k,!1)},o.listenerCount=function(v,k){return typeof v.listenerCount=="function"?v.listenerCount(k):h.call(v,k)},o.prototype.listenerCount=h;function h(v){var k=this._events;if(k!==void 0){var _=k[v];if(typeof _=="function")return 1;if(_!==void 0)return _.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function p(v,k){for(var _=new Array(k),$=0;$<k;++$)_[$]=v[$];return _}function m(v,k){for(;k+1<v.length;k++)v[k]=v[k+1];v.pop()}function y(v){for(var k=new Array(v.length),_=0;_<k.length;++_)k[_]=v[_].listener||v[_];return k}function w(v,k){return new Promise(function(_,$){function O(D){v.removeListener(k,M),$(D)}function M(){typeof v.removeListener=="function"&&v.removeListener("error",O),_([].slice.call(arguments))}b(v,k,M,{once:!0}),k!=="error"&&g(v,O,{once:!0})})}function g(v,k,_){typeof v.on=="function"&&b(v,"error",k,_)}function b(v,k,_,$){if(typeof v.on=="function")$.once?v.once(k,_):v.on(k,_);else if(typeof v.addEventListener=="function")v.addEventListener(k,function O(M){$.once&&v.removeEventListener(k,O),_(M)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof v)}return Ho.exports}var n_=dI();function fI(){const e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(const r in arguments[t])e[r]=arguments[t][r];return e}let Xe=fI;typeof Object.assign=="function"&&(Xe=Object.assign);function Dt(e,t,n,r){const i=e._nodes.get(t);let o=null;return i&&(r==="mixed"?o=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?o=i.out&&i.out[n]:o=i.undirected&&i.undirected[n]),o}function ot(e){return typeof e=="object"&&e!==null}function r_(e){let t;for(t in e)return!1;return!0}function Rt(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Bt(e,t,n){const r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function Rp(e){return!(!ot(e)||e.attributes&&!Array.isArray(e.attributes))}function hI(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function an(){const e=arguments;let t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done){t=null;continue}break}while(!0);return r}}}function Zr(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class nh extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class q extends nh{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,q.prototype.constructor)}}class Z extends nh{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Z.prototype.constructor)}}class oe extends nh{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,oe.prototype.constructor)}}function i_(e,t){this.key=e,this.attributes=t,this.clear()}i_.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function o_(e,t){this.key=e,this.attributes=t,this.clear()}o_.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function s_(e,t){this.key=e,this.attributes=t,this.clear()}s_.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Br(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Br.prototype.attach=function(){let e="out",t="in";this.undirected&&(e=t="undirected");const n=this.source.key,r=this.target.key;this.source[e][r]=this,!(this.undirected&&n===r)&&(this.target[t][n]=this)};Br.prototype.attachMulti=function(){let e="out",t="in";const n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");const i=this.source[e],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[t][n]=this};Br.prototype.detach=function(){const e=this.source.key,t=this.target.key;let n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][t],delete this.target[r][e]};Br.prototype.detachMulti=function(){const e=this.source.key,t=this.target.key;let n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const a_=0,u_=1,pI=2,c_=3;function gn(e,t,n,r,i,o,s){let a,u,c,l;if(r=""+r,n===a_){if(a=e._nodes.get(r),!a)throw new Z(`Graph.${t}: could not find the "${r}" node in the graph.`);c=i,l=o}else if(n===c_){if(i=""+i,u=e._edges.get(i),!u)throw new Z(`Graph.${t}: could not find the "${i}" edge in the graph.`);const d=u.source.key,f=u.target.key;if(r===d)a=u.target;else if(r===f)a=u.source;else throw new Z(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${d}, ${f}).`);c=o,l=s}else{if(u=e._edges.get(r),!u)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===u_?a=u.source:a=u.target,c=i,l=o}return[a,c,l]}function mI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=gn(this,t,n,r,i,o);return s.attributes[a]}}function gI(e,t,n){e.prototype[t]=function(r,i){const[o]=gn(this,t,n,r,i);return o.attributes}}function yI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=gn(this,t,n,r,i,o);return s.attributes.hasOwnProperty(a)}}function vI(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=gn(this,t,n,r,i,o,s);return a.attributes[u]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:u}),this}}function bI(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=gn(this,t,n,r,i,o,s);if(typeof c!="function")throw new q(`Graph.${t}: updater should be a function.`);const l=a.attributes,d=c(l[u]);return l[u]=d,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:u}),this}}function wI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=gn(this,t,n,r,i,o);return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}function _I(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=gn(this,t,n,r,i,o);if(!ot(a))throw new q(`Graph.${t}: provided attributes are not a plain object.`);return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function kI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=gn(this,t,n,r,i,o);if(!ot(a))throw new q(`Graph.${t}: provided attributes are not a plain object.`);return Xe(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function SI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=gn(this,t,n,r,i,o);if(typeof a!="function")throw new q(`Graph.${t}: provided updater is not a function.`);return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const xI=[{name:e=>`get${e}Attribute`,attacher:mI},{name:e=>`get${e}Attributes`,attacher:gI},{name:e=>`has${e}Attribute`,attacher:yI},{name:e=>`set${e}Attribute`,attacher:vI},{name:e=>`update${e}Attribute`,attacher:bI},{name:e=>`remove${e}Attribute`,attacher:wI},{name:e=>`replace${e}Attributes`,attacher:_I},{name:e=>`merge${e}Attributes`,attacher:kI},{name:e=>`update${e}Attributes`,attacher:SI}];function EI(e){xI.forEach(function({name:t,attacher:n}){n(e,t("Node"),a_),n(e,t("Source"),u_),n(e,t("Target"),pI),n(e,t("Opposite"),c_)})}function $I(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Dt(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function TI(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+r,s=""+arguments[1];if(i=Dt(this,o,s,n),!i)throw new Z(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,i=this._edges.get(r),!i)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function CI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Dt(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function AI(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+r,u=""+i;if(i=arguments[2],o=arguments[3],s=Dt(this,a,u,n),!s)throw new Z(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,s=this._edges.get(r),!s)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return s.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function II(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+r,u=""+i;if(i=arguments[2],o=arguments[3],s=Dt(this,a,u,n),!s)throw new Z(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,s=this._edges.get(r),!s)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new q(`Graph.${t}: updater should be a function.`);return s.attributes[i]=o(s.attributes[i]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function NI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Dt(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function RI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Dt(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!ot(i))throw new q(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function LI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Dt(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!ot(i))throw new q(`Graph.${t}: provided attributes are not a plain object.`);return Xe(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function zI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Dt(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new q(`Graph.${t}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const PI=[{name:e=>`get${e}Attribute`,attacher:$I},{name:e=>`get${e}Attributes`,attacher:TI},{name:e=>`has${e}Attribute`,attacher:CI},{name:e=>`set${e}Attribute`,attacher:AI},{name:e=>`update${e}Attribute`,attacher:II},{name:e=>`remove${e}Attribute`,attacher:NI},{name:e=>`replace${e}Attributes`,attacher:RI},{name:e=>`merge${e}Attributes`,attacher:LI},{name:e=>`update${e}Attributes`,attacher:zI}];function DI(e){PI.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const OI=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function MI(e,t,n,r){let i=!1;for(const o in t){if(o===r)continue;const s=t[o];if(i=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),e&&i)return s.key}}function FI(e,t,n,r){let i,o,s,a=!1;for(const u in t)if(u!==r){i=t[u];do{if(o=i.source,s=i.target,a=n(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected),e&&a)return i.key;i=i.next}while(i!==void 0)}}function vu(e,t){const n=Object.keys(e),r=n.length;let i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=r)return{done:!0};const s=n[o++];if(s===t){i=void 0;continue}i=e[s]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function UI(e,t,n,r){const i=t[n];if(!i)return;const o=i.source,s=i.target;if(r(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected)&&e)return i.key}function GI(e,t,n,r){let i=t[n];if(!i)return;let o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&o)return i.key;i=i.next}while(i!==void 0)}function bu(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};const i={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:i}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function jI(e,t){if(e.size===0)return[];if(t==="mixed"||t===e.type)return Array.from(e._edges.keys());const n=t==="undirected"?e.undirectedSize:e.directedSize,r=new Array(n),i=t==="undirected",o=e._edges.values();let s=0,a,u;for(;a=o.next(),a.done!==!0;)u=a.value,u.undirected===i&&(r[s++]=u.key);return r}function l_(e,t,n,r){if(t.size===0)return;const i=n!=="mixed"&&n!==t.type,o=n==="undirected";let s,a,u=!1;const c=t._edges.values();for(;s=c.next(),s.done!==!0;){if(a=s.value,i&&a.undirected!==o)continue;const{key:l,attributes:d,source:f,target:h}=a;if(u=r(l,d,f.key,h.key,f.attributes,h.attributes,a.undirected),e&&u)return l}}function ZI(e,t){if(e.size===0)return Zr();const n=t!=="mixed"&&t!==e.type,r=t==="undirected",i=e._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=i.next(),o.done)return o;if(s=o.value,!(n&&s.undirected!==r))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function rh(e,t,n,r,i,o){const s=t?FI:MI;let a;if(n!=="undirected"&&(r!=="out"&&(a=s(e,i.in,o),e&&a)||r!=="in"&&(a=s(e,i.out,o,r?void 0:i.key),e&&a))||n!=="directed"&&(a=s(e,i.undirected,o),e&&a))return a}function BI(e,t,n,r){const i=[];return rh(!1,e,t,n,r,function(o){i.push(o)}),i}function HI(e,t,n){let r=Zr();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=an(r,vu(n.in))),t!=="in"&&typeof n.out<"u"&&(r=an(r,vu(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=an(r,vu(n.undirected))),r}function ih(e,t,n,r,i,o,s){const a=n?GI:UI;let u;if(t!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(u=a(e,i.in,o,s),e&&u)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(u=a(e,i.out,o,s),e&&u))||t!=="directed"&&typeof i.undirected<"u"&&(u=a(e,i.undirected,o,s),e&&u))return u}function VI(e,t,n,r,i){const o=[];return ih(!1,e,t,n,r,i,function(s){o.push(s)}),o}function qI(e,t,n,r){let i=Zr();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=an(i,bu(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=an(i,bu(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=an(i,bu(n.undirected,r))),i}function WI(e,t){const{name:n,type:r,direction:i}=t;e.prototype[n]=function(o,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return jI(this,r);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new Z(`Graph.${n}: could not find the "${o}" node in the graph.`);return BI(this.multi,r==="mixed"?this.type:r,i,a)}if(arguments.length===2){o=""+o,s=""+s;const a=this._nodes.get(o);if(!a)throw new Z(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new Z(`Graph.${n}: could not find the "${s}" target node in the graph.`);return VI(r,this.multi,i,a,s)}throw new q(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function KI(e,t){const{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,l,d){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return d=c,l_(!1,this,r,d);if(arguments.length===2){c=""+c,d=l;const f=this._nodes.get(c);if(typeof f>"u")throw new Z(`Graph.${o}: could not find the "${c}" node in the graph.`);return rh(!1,this.multi,r==="mixed"?this.type:r,i,f,d)}if(arguments.length===3){c=""+c,l=""+l;const f=this._nodes.get(c);if(!f)throw new Z(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(l))throw new Z(`Graph.${o}: could not find the "${l}" target node in the graph.`);return ih(!1,r,this.multi,i,f,l,d)}throw new q(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop();let d;if(c.length===0){let f=0;r!=="directed"&&(f+=this.undirectedSize),r!=="undirected"&&(f+=this.directedSize),d=new Array(f);let h=0;c.push((p,m,y,w,g,b,v)=>{d[h++]=l(p,m,y,w,g,b,v)})}else d=[],c.push((f,h,p,m,y,w,g)=>{d.push(l(f,h,p,m,y,w,g))});return this[o].apply(this,c),d};const a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop(),d=[];return c.push((f,h,p,m,y,w,g)=>{l(f,h,p,m,y,w,g)&&d.push(f)}),this[o].apply(this,c),d};const u="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[u]=function(){let c=Array.prototype.slice.call(arguments);if(c.length<2||c.length>4)throw new q(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${c.length}).`);if(typeof c[c.length-1]=="function"&&typeof c[c.length-2]!="function")throw new q(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let l,d;c.length===2?(l=c[0],d=c[1],c=[]):c.length===3?(l=c[1],d=c[2],c=[c[0]]):c.length===4&&(l=c[2],d=c[3],c=[c[0],c[1]]);let f=d;return c.push((h,p,m,y,w,g,b)=>{f=l(f,h,p,m,y,w,g,b)}),this[o].apply(this,c),f}}function JI(e,t){const{name:n,type:r,direction:i}=t,o="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(u,c,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return l=u,l_(!0,this,r,l);if(arguments.length===2){u=""+u,l=c;const d=this._nodes.get(u);if(typeof d>"u")throw new Z(`Graph.${o}: could not find the "${u}" node in the graph.`);return rh(!0,this.multi,r==="mixed"?this.type:r,i,d,l)}if(arguments.length===3){u=""+u,c=""+c;const d=this._nodes.get(u);if(!d)throw new Z(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new Z(`Graph.${o}: could not find the "${c}" target node in the graph.`);return ih(!0,r,this.multi,i,d,c,l)}throw new q(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),c=u.pop();return u.push((d,f,h,p,m,y,w)=>c(d,f,h,p,m,y,w)),!!this[o].apply(this,u)};const a="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),c=u.pop();return u.push((d,f,h,p,m,y,w)=>!c(d,f,h,p,m,y,w)),!this[o].apply(this,u)}}function YI(e,t){const{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Zr();if(!arguments.length)return ZI(this,r);if(arguments.length===1){s=""+s;const u=this._nodes.get(s);if(!u)throw new Z(`Graph.${o}: could not find the "${s}" node in the graph.`);return HI(r,i,u)}if(arguments.length===2){s=""+s,a=""+a;const u=this._nodes.get(s);if(!u)throw new Z(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new Z(`Graph.${o}: could not find the "${a}" target node in the graph.`);return qI(r,i,u,a)}throw new q(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function XI(e){OI.forEach(t=>{WI(e,t),KI(e,t),JI(e,t),YI(e,t)})}const QI=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function qa(){this.A=null,this.B=null}qa.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};qa.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function Kr(e,t,n,r,i){for(const o in r){const s=r[o],a=s.source,u=s.target,c=a===n?u:a;if(t&&t.has(c.key))continue;const l=i(c.key,c.attributes);if(e&&l)return c.key}}function oh(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return Kr(e,null,r,r.undirected,i);if(typeof n=="string")return Kr(e,null,r,r[n],i)}const o=new qa;let s;if(t!=="undirected"){if(n!=="out"){if(s=Kr(e,null,r,r.in,i),e&&s)return s;o.wrap(r.in)}if(n!=="in"){if(s=Kr(e,o,r,r.out,i),e&&s)return s;o.wrap(r.out)}}if(t!=="directed"&&(s=Kr(e,o,r,r.undirected,i),e&&s))return s}function eN(e,t,n){if(e!=="mixed"){if(e==="undirected")return Object.keys(n.undirected);if(typeof t=="string")return Object.keys(n[t])}const r=[];return oh(!1,e,t,n,function(i){r.push(i)}),r}function Jr(e,t,n){const r=Object.keys(n),i=r.length;let o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=i)return e&&e.wrap(n),{done:!0};const a=n[r[o++]],u=a.source,c=a.target;if(s=u===t?c:u,e&&e.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function tN(e,t,n){if(e!=="mixed"){if(e==="undirected")return Jr(null,n,n.undirected);if(typeof t=="string")return Jr(null,n,n[t])}let r=Zr();const i=new qa;return e!=="undirected"&&(t!=="out"&&(r=an(r,Jr(i,n,n.in))),t!=="in"&&(r=an(r,Jr(i,n,n.out)))),e!=="directed"&&(r=an(r,Jr(i,n,n.undirected))),r}function nN(e,t){const{name:n,type:r,direction:i}=t;e.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new Z(`Graph.${n}: could not find the "${o}" node in the graph.`);return eN(r==="mixed"?this.type:r,i,s)}}function rN(e,t){const{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;const d=this._nodes.get(c);if(typeof d>"u")throw new Z(`Graph.${o}: could not find the "${c}" node in the graph.`);oh(!1,r==="mixed"?this.type:r,i,d,l)};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(c,l){const d=[];return this[o](c,(f,h)=>{d.push(l(f,h))}),d};const a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(c,l){const d=[];return this[o](c,(f,h)=>{l(f,h)&&d.push(f)}),d};const u="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[u]=function(c,l,d){if(arguments.length<3)throw new q(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let f=d;return this[o](c,(h,p)=>{f=l(f,h,p)}),f}}function iN(e,t){const{name:n,type:r,direction:i}=t,o=n[0].toUpperCase()+n.slice(1,-1),s="find"+o;e.prototype[s]=function(c,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;const d=this._nodes.get(c);if(typeof d>"u")throw new Z(`Graph.${s}: could not find the "${c}" node in the graph.`);return oh(!0,r==="mixed"?this.type:r,i,d,l)};const a="some"+o;e.prototype[a]=function(c,l){return!!this[s](c,l)};const u="every"+o;e.prototype[u]=function(c,l){return!this[s](c,(f,h)=>!l(f,h))}}function oN(e,t){const{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Zr();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new Z(`Graph.${o}: could not find the "${s}" node in the graph.`);return tN(r==="mixed"?this.type:r,i,a)}}function sN(e){QI.forEach(t=>{nN(e,t),rN(e,t),iN(e,t),oN(e,t)})}function Vo(e,t,n,r,i){const o=r._nodes.values(),s=r.type;let a,u,c,l,d,f;for(;a=o.next(),a.done!==!0;){let h=!1;if(u=a.value,s!=="undirected"){l=u.out;for(c in l){d=l[c];do f=d.target,h=!0,i(u.key,f.key,u.attributes,f.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(s!=="directed"){l=u.undirected;for(c in l)if(!(t&&u.key>c)){d=l[c];do f=d.target,f.key!==c&&(f=d.source),h=!0,i(u.key,f.key,u.attributes,f.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}n&&!h&&i(u.key,null,u.attributes,null,null,null,null)}}function aN(e,t){const n={key:e};return r_(t.attributes)||(n.attributes=Xe({},t.attributes)),n}function uN(e,t,n){const r={key:t,source:n.source.key,target:n.target.key};return r_(n.attributes)||(r.attributes=Xe({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function cN(e){if(!ot(e))throw new q('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new q("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!ot(e.attributes)||e.attributes===null))throw new q("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function lN(e){if(!ot(e))throw new q('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new q("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new q("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!ot(e.attributes)||e.attributes===null))throw new q("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new q("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const dN=hI(),fN=new Set(["directed","undirected","mixed"]),Lp=new Set(["domain","_events","_eventsCount","_maxListeners"]),hN=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:"directed"},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:"directed"},{name:e=>`${e}UndirectedEdgeWithKey`,type:"undirected"}],pN={allowSelfLoops:!0,multi:!1,type:"mixed"};function mN(e,t,n){if(n&&!ot(n))throw new q(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new oe(`Graph.addNode: the "${t}" node already exist in the graph.`);const r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function zp(e,t,n){const r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function d_(e,t,n,r,i,o,s,a){if(!r&&e.type==="undirected")throw new oe(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new oe(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!ot(a))throw new q(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!e.allowSelfLoops&&o===s)throw new oe(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=e._nodes.get(o),c=e._nodes.get(s);if(!u)throw new Z(`Graph.${t}: source node "${o}" not found.`);if(!c)throw new Z(`Graph.${t}: target node "${s}" not found.`);const l={key:null,undirected:r,source:o,target:s,attributes:a};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new oe(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?typeof u.undirected[s]<"u":typeof u.out[s]<"u"))throw new oe(`Graph.${t}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new Br(r,i,u,c,a);e._edges.set(i,d);const f=o===s;return r?(u.undirectedDegree++,c.undirectedDegree++,f&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,c.inDegree++,f&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,l.key=i,e.emit("edgeAdded",l),i}function gN(e,t,n,r,i,o,s,a,u){if(!r&&e.type==="undirected")throw new oe(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new oe(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(u){if(typeof a!="function")throw new q(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!ot(a))throw new q(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`)}o=""+o,s=""+s;let c;if(u&&(c=a,a=void 0),!e.allowSelfLoops&&o===s)throw new oe(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),d=e._nodes.get(s),f,h;if(!n&&(f=e._edges.get(i),f)){if((f.source.key!==o||f.target.key!==s)&&(!r||f.source.key!==s||f.target.key!==o))throw new oe(`Graph.${t}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${s}" target vs. ("${f.source.key}", "${f.target.key}").`);h=f}if(!h&&!e.multi&&l&&(h=r?l.undirected[s]:l.out[s]),h){const g=[h.key,!1,!1,!1];if(u?!c:!a)return g;if(u){const b=h.attributes;h.attributes=c(b),e.emit("edgeAttributesUpdated",{type:"replace",key:h.key,attributes:h.attributes})}else Xe(h.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:h.key,attributes:h.attributes,data:a});return g}a=a||{},u&&c&&(a=c(a));const p={key:null,undirected:r,source:o,target:s,attributes:a};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new oe(`Graph.${t}: the "${i}" edge already exists in the graph.`);let m=!1,y=!1;l||(l=zp(e,o,{}),m=!0,o===s&&(d=l,y=!0)),d||(d=zp(e,s,{}),y=!0),f=new Br(r,i,l,d,a),e._edges.set(i,f);const w=o===s;return r?(l.undirectedDegree++,d.undirectedDegree++,w&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,d.inDegree++,w&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?f.attachMulti():f.attach(),r?e._undirectedSize++:e._directedSize++,p.key=i,e.emit("edgeAdded",p),[i,!0,m,y]}function Qn(e,t){e._edges.delete(t.key);const{source:n,target:r,attributes:i}=t,o=t.undirected,s=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,s&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,s&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),o?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:i,source:n.key,target:r.key,undirected:o})}class Me extends n_.EventEmitter{constructor(t){if(super(),t=Xe({},pN,t),typeof t.multi!="boolean")throw new q(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!fN.has(t.type))throw new q(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new q(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?i_:t.type==="directed"?o_:s_;Rt(this,"NodeDataClass",n);const r="geid_"+dN()+"_";let i=0;const o=()=>{let s;do s=r+i++;while(this._edges.has(s));return s};Rt(this,"_attributes",{}),Rt(this,"_nodes",new Map),Rt(this,"_edges",new Map),Rt(this,"_directedSize",0),Rt(this,"_undirectedSize",0),Rt(this,"_directedSelfLoopCount",0),Rt(this,"_undirectedSelfLoopCount",0),Rt(this,"_edgeKeyGenerator",o),Rt(this,"_options",t),Lp.forEach(s=>Rt(this,s,this[s])),Bt(this,"order",()=>this._nodes.size),Bt(this,"size",()=>this._edges.size),Bt(this,"directedSize",()=>this._directedSize),Bt(this,"undirectedSize",()=>this._undirectedSize),Bt(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Bt(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Bt(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Bt(this,"multi",this._options.multi),Bt(this,"type",this._options.type),Bt(this,"allowSelfLoops",this._options.allowSelfLoops),Bt(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(t){return this._nodes.has(""+t)}hasDirectedEdge(t,n){if(this.type==="undirected")return!1;if(arguments.length===1){const r=""+t,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?r.out.hasOwnProperty(n):!1}throw new q(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(t,n){if(this.type==="directed")return!1;if(arguments.length===1){const r=""+t,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?r.undirected.hasOwnProperty(n):!1}throw new q(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(t,n){if(arguments.length===1){const r=""+t;return this._edges.has(r)}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new q(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(t,n){if(this.type==="undirected")return;if(t=""+t,n=""+n,this.multi)throw new oe("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const r=this._nodes.get(t);if(!r)throw new Z(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Z(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);const i=r.out&&r.out[n]||void 0;if(i)return i.key}undirectedEdge(t,n){if(this.type==="directed")return;if(t=""+t,n=""+n,this.multi)throw new oe("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const r=this._nodes.get(t);if(!r)throw new Z(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Z(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);const i=r.undirected&&r.undirected[n]||void 0;if(i)return i.key}edge(t,n){if(this.multi)throw new oe("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Z(`Graph.edge: could not find the "${n}" target node in the graph.`);const i=r.out&&r.out[n]||r.undirected&&r.undirected[n]||void 0;if(i)return i.key}areDirectedNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areDirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areOutNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areInNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areUndirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areInboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areOutboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.directedDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.undirectedDegree: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.degree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.directedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree,i+=n.directedLoops),r-i}outboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.outDegree,i+=n.directedLoops),r-i}degreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.degreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree,i+=n.directedLoops*2),r-i}source(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.source: could not find the "${t}" edge in the graph.`);return n.source.key}target(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.target: could not find the "${t}" edge in the graph.`);return n.target.key}extremities(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.extremities: could not find the "${t}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(t,n){t=""+t,n=""+n;const r=this._edges.get(n);if(!r)throw new Z(`Graph.opposite: could not find the "${n}" edge in the graph.`);const i=r.source.key,o=r.target.key;if(t===i)return o;if(t===o)return i;throw new Z(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(t,n){t=""+t,n=""+n;const r=this._edges.get(t);if(!r)throw new Z(`Graph.hasExtremity: could not find the "${t}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.isUndirected: could not find the "${t}" edge in the graph.`);return n.undirected}isDirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.isDirected: could not find the "${t}" edge in the graph.`);return!n.undirected}isSelfLoop(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return mN(this,t,n).key}mergeNode(t,n){if(n&&!ot(n))throw new q(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(Xe(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:r.attributes,data:n})),[t,!1]):(r=new this.NodeDataClass(t,n),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:n}),[t,!0])}updateNode(t,n){if(n&&typeof n!="function")throw new q(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let r=this._nodes.get(t);if(r){if(n){const o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:r.attributes})}return[t,!1]}const i=n?n({}):{};return r=new this.NodeDataClass(t,i),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:i}),[t,!0]}dropNode(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.dropNode: could not find the "${t}" node in the graph.`);let r;if(this.type!=="undirected"){for(const i in n.out){r=n.out[i];do Qn(this,r),r=r.next;while(r)}for(const i in n.in){r=n.in[i];do Qn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(const i in n.undirected){r=n.undirected[i];do Qn(this,r),r=r.next;while(r)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})}dropEdge(t){let n;if(arguments.length>1){const r=""+arguments[0],i=""+arguments[1];if(n=Dt(this,r,i,this.type),!n)throw new Z(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new Z(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return Qn(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new oe("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new oe("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");t=""+t,n=""+n;const r=Dt(this,t,n,"directed");if(!r)throw new Z(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Qn(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new oe("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new oe("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const r=Dt(this,t,n,"undirected");if(!r)throw new Z(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Qn(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const t=this._nodes.values();let n;for(;n=t.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(t){return this._attributes[t]}getAttributes(){return this._attributes}hasAttribute(t){return this._attributes.hasOwnProperty(t)}setAttribute(t,n){return this._attributes[t]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}updateAttribute(t,n){if(typeof n!="function")throw new q("Graph.updateAttribute: updater should be a function.");const r=this._attributes[t];return this._attributes[t]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}removeAttribute(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this}replaceAttributes(t){if(!ot(t))throw new q("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(t){if(!ot(t))throw new q("Graph.mergeAttributes: provided attributes are not a plain object.");return Xe(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new q("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(t,n){if(typeof t!="function")throw new q("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!Rp(n))throw new q("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const r=this._nodes.values();let i,o;for(;i=r.next(),i.done!==!0;)o=i.value,o.attributes=t(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new q("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!Rp(n))throw new q("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const r=this._edges.values();let i,o,s,a;for(;i=r.next(),i.done!==!0;)o=i.value,s=o.source,a=o.target,o.attributes=t(o.key,o.attributes,s.key,a.key,s.attributes,a.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new q("Graph.forEachAdjacencyEntry: expecting a callback.");Vo(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new q("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Vo(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new q("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Vo(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new q("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Vo(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new q("Graph.forEachNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)}findNode(t){if(typeof t!="function")throw new q("Graph.findNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return i.key}mapNodes(t){if(typeof t!="function")throw new q("Graph.mapNode: expecting a callback.");const n=this._nodes.values();let r,i;const o=new Array(this.order);let s=0;for(;r=n.next(),r.done!==!0;)i=r.value,o[s++]=t(i.key,i.attributes);return o}someNode(t){if(typeof t!="function")throw new q("Graph.someNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return!0;return!1}everyNode(t){if(typeof t!="function")throw new q("Graph.everyNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!t(i.key,i.attributes))return!1;return!0}filterNodes(t){if(typeof t!="function")throw new q("Graph.filterNodes: expecting a callback.");const n=this._nodes.values();let r,i;const o=[];for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(t,n){if(typeof t!="function")throw new q("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new q("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let r=n;const i=this._nodes.values();let o,s;for(;o=i.next(),o.done!==!0;)s=o.value,r=t(r,s.key,s.attributes);return r}nodeEntries(){const t=this._nodes.values();return{[Symbol.iterator](){return this},next(){const n=t.next();if(n.done)return n;const r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){const t=new Array(this._nodes.size);let n=0;this._nodes.forEach((i,o)=>{t[n++]=aN(o,i)});const r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=uN(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:r}}import(t,n=!1){if(t instanceof Me)return t.forEachNode((u,c)=>{n?this.mergeNode(u,c):this.addNode(u,c)}),t.forEachEdge((u,c,l,d,f,h,p)=>{n?p?this.mergeUndirectedEdgeWithKey(u,l,d,c):this.mergeDirectedEdgeWithKey(u,l,d,c):p?this.addUndirectedEdgeWithKey(u,l,d,c):this.addDirectedEdgeWithKey(u,l,d,c)}),this;if(!ot(t))throw new q("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!ot(t.attributes))throw new q("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,o,s,a;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new q("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],cN(s);const{key:u,attributes:c}=s;n?this.mergeNode(u,c):this.addNode(u,c)}}if(t.edges){let u=!1;if(this.type==="undirected"&&(u=!0),o=t.edges,!Array.isArray(o))throw new q("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],lN(a);const{source:c,target:l,attributes:d,undirected:f=u}=a;let h;"key"in a?(h=n?f?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:f?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,h.call(this,a.key,c,l,d)):(h=n?f?this.mergeUndirectedEdge:this.mergeDirectedEdge:f?this.addUndirectedEdge:this.addDirectedEdge,h.call(this,c,l,d))}}return this}nullCopy(t){const n=new Me(Xe({},this._options,t));return n.replaceAttributes(Xe({},this.getAttributes())),n}emptyCopy(t){const n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{const o=Xe({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new oe(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${t.type}" because this would mean losing information about the current graph.`);if(typeof t.multi=="boolean"&&t.multi!==this.multi&&t.multi!==!0)throw new oe("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof t.allowSelfLoops=="boolean"&&t.allowSelfLoops!==this.allowSelfLoops&&t.allowSelfLoops!==!0)throw new oe("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const n=this.emptyCopy(t),r=this._edges.values();let i,o;for(;i=r.next(),i.done!==!0;)o=i.value,d_(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,Xe({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const t={};this._nodes.forEach((o,s)=>{t[s]=o.attributes});const n={},r={};this._edges.forEach((o,s)=>{const a=o.undirected?"--":"->";let u="",c=o.source.key,l=o.target.key,d;o.undirected&&c>l&&(d=c,c=l,l=d);const f=`(${c})${a}(${l})`;s.startsWith("geid_")?this.multi&&(typeof r[f]>"u"?r[f]=0:r[f]++,u+=`${r[f]}. `):u+=`[${s}]: `,u+=f,n[u]=o.attributes});const i={};for(const o in this)this.hasOwnProperty(o)&&!Lp.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,Rt(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(Me.prototype[Symbol.for("nodejs.util.inspect.custom")]=Me.prototype.inspect);hN.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),r=t==="add"?d_:gN;e.generateKey?Me.prototype[n]=function(i,o,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,s,t==="update")}:Me.prototype[n]=function(i,o,s,a){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,s,a,t==="update")}})});EI(Me);DI(Me);XI(Me);sN(Me);class f_ extends Me{constructor(t){const n=Xe({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new q("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new q('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class h_ extends Me{constructor(t){const n=Xe({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new q("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new q('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class p_ extends Me{constructor(t){const n=Xe({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new q("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class m_ extends Me{constructor(t){const n=Xe({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new q("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new q('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class g_ extends Me{constructor(t){const n=Xe({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new q("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new q('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function Hr(e){e.from=function(t,n){const r=Xe({},t.options,n),i=new e(r);return i.import(t),i}}Hr(Me);Hr(f_);Hr(h_);Hr(p_);Hr(m_);Hr(g_);Me.Graph=Me;Me.DirectedGraph=f_;Me.UndirectedGraph=h_;Me.MultiGraph=p_;Me.MultiDirectedGraph=m_;Me.MultiUndirectedGraph=g_;Me.InvalidArgumentsGraphError=q;Me.NotFoundGraphError=Z;Me.UsageGraphError=oe;function yN(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function si(e){var t=yN(e,"string");return typeof t=="symbol"?t:t+""}function ft(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Pp(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,si(r.key),r)}}function ht(e,t,n){return t&&Pp(e.prototype,t),n&&Pp(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function vr(e){return vr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},vr(e)}function y_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(y_=function(){return!!e})()}function vN(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function bN(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return vN(e)}function Ut(e,t,n){return t=vr(t),bN(e,y_()?Reflect.construct(t,n||[],vr(e).constructor):t.apply(e,n))}function ac(e,t){return ac=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},ac(e,t)}function Gt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ac(e,t)}function wN(e){if(Array.isArray(e))return e}function _N(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,s,a=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(l){c=!0,i=l}finally{try{if(!u&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}function uc(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function v_(e,t){if(e){if(typeof e=="string")return uc(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uc(e,t):void 0}}function kN(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
111
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function br(e,t){return
|
|
107
|
+
- "app": Tool callable by the app from this server only`),csp:Wn().optional(),permissions:Wn().optional()});T({mimeTypes:ae(E()).optional().describe('Array of supported MIME types for UI resources.\nMust include `"text/html;profile=mcp-app"` for MCP Apps support.')});T({method:x("ui/download-file"),params:T({contents:ae(ke([dw,fw])).describe("Resource contents to download — embedded (inline data) or linked (host fetches). Uses standard MCP resource types.")})});T({method:x("ui/message"),params:T({role:x("user").describe('Message role, currently only "user" is supported.'),content:ae(xo).describe("Message content blocks (text, image, etc.).")})});T({method:x("ui/notifications/sandbox-resource-ready"),params:T({html:E().describe("HTML content to load into the inner iframe."),sandbox:E().optional().describe("Optional override for the inner iframe's sandbox attribute."),csp:Gf.optional().describe("CSP configuration from resource metadata."),permissions:jf.optional().describe("Sandbox permissions from resource metadata.")})});var M$=T({method:x("ui/notifications/tool-result"),params:Ba.describe("Standard MCP tool execution result.")}),bw=T({toolInfo:T({id:bo.optional().describe("JSON-RPC id of the tools/call request."),tool:Uf.describe("Tool definition including name, inputSchema, etc.")}).optional().describe("Metadata of the tool call that instantiated this App."),theme:k$.optional().describe("Current color theme preference."),styles:R$.optional().describe("Style configuration for theming the app."),displayMode:hi.optional().describe("How the UI is currently displayed."),availableDisplayModes:ae(hi).optional().describe("Display modes the host supports."),containerDimensions:ke([T({height:ge().describe("Fixed container height in pixels.")}),T({maxHeight:ke([ge(),pr()]).optional().describe("Maximum container height in pixels.")})]).and(ke([T({width:ge().describe("Fixed container width in pixels.")}),T({maxWidth:ke([ge(),pr()]).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:E().optional().describe("User's language and region preference in BCP 47 format."),timeZone:E().optional().describe("User's timezone in IANA format."),userAgent:E().optional().describe("Host application identifier."),platform:ke([x("web"),x("desktop"),x("mobile")]).optional().describe("Platform type for responsive design decisions."),deviceCapabilities:T({touch:Pe().optional().describe("Whether the device supports touch input."),hover:Pe().optional().describe("Whether the device supports hover interactions.")}).optional().describe("Device input capabilities."),safeAreaInsets:T({top:ge().describe("Top safe area inset in pixels."),right:ge().describe("Right safe area inset in pixels."),bottom:ge().describe("Bottom safe area inset in pixels."),left:ge().describe("Left safe area inset in pixels.")}).optional().describe("Mobile safe area boundaries in pixels.")}).passthrough(),F$=T({method:x("ui/notifications/host-context-changed"),params:bw.describe("Partial context update containing only changed fields.")});T({method:x("ui/update-model-context"),params:T({content:ae(xo).optional().describe("Context content blocks (text, image, etc.)."),structuredContent:Ee(E(),Le().describe("Structured content for machine-readable context data.")).optional().describe("Structured content for machine-readable context data.")})});T({method:x("ui/initialize"),params:T({appInfo:ja.describe("App identification (name and version)."),appCapabilities:P$.describe("Features and capabilities this app provides."),protocolVersion:E().describe("Protocol version this app supports.")})});var U$=T({protocolVersion:E().describe('Negotiated protocol version string (e.g., "2025-11-21").'),hostInfo:ja.describe("Host application identification and version."),hostCapabilities:z$.describe("Features and capabilities provided by the host."),hostContext:bw.describe("Rich context about the host environment.")}).passthrough(),G$={target:"draft-2020-12"};async function tp(e,t){let n=e["~standard"];if(n.jsonSchema)return n.jsonSchema[t](G$);if(n.vendor==="zod"){let{z:r}=await ik(()=>Promise.resolve().then(()=>IE),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 np(e,t,n=""){let r=await e["~standard"].validate(t);if(r.issues){let i=r.issues.map(o=>{let s=o.path?.map(a=>typeof a=="object"?a.key:a).join(".");return s?`${s}: ${o.message}`:o.message}).join("; ");throw Error(n+i)}return r.value}function j$(e,t=document.documentElement){for(let[n,r]of Object.entries(e))r!==void 0&&t.style.setProperty(n,r)}function Z$(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 Zf extends b${_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:C$,toolinputpartial:A$,toolresult:M$,toolcancelled:I$,hostcontextchanged:F$};static ONE_SHOT_EVENTS=new Set(["toolinput","toolinputpartial","toolresult","toolcancelled"]);_everHadListener=new Set;_assertHandlerTiming(t){if(!Zf.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||et({jitless:!0}),this.setRequestHandler(Za,i=>(console.log("Received ping:",i.params),{})),this.setEventHandler("hostcontextchanged",void 0)}registerCapabilities(t){if(this.transport)throw Error("Cannot register capabilities after transport is established");this._capabilities=v$(this._capabilities,t)}registerTool(t,n,r){if(this._registeredTools[t])throw Error(`Tool ${t} is already registered`);let i=this,o=()=>{i._initializedSent&&i._capabilities.tools?.listChanged&&i.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,o()},disable(){this.enabled=!1,o()},update(u){Object.assign(this,u),o()},remove(){i._registeredTools[t]===a&&(delete i._registeredTools[t],o())},handler:async(u,c)=>{if(!a.enabled)throw Error(`Tool ${t} is disabled`);let l;if(s){let d=a.inputSchema,f=d?await np(d,u??{},`Invalid input for tool ${t}: `):u??{};l=await r(f,c)}else l=await r(c);return a.outputSchema&&!l.isError&&(l.structuredContent=await np(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(),o(),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,i])=>i.enabled).map(async([r,i])=>{let o={name:r,title:i.title,description:i.description,inputSchema:i.inputSchema?await tp(i.inputSchema,"input"):{type:"object",properties:{}}};return i.outputSchema&&(o.outputSchema=await tp(i.outputSchema,"output")),i.annotations&&(o.annotations=i.annotations),i._meta&&(o._meta=i._meta),o}))}))}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(L$,(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(pw,(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(hw,(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},Ba,{onprogress:()=>{},resetTimeoutOnProgress:!0,...n})}async readServerResource(t,n){return this._assertInitialized("readServerResource"),await this.request({method:"resources/read",params:t},lw,n)}async listServerResources(t,n){return this._assertInitialized("listServerResources"),await this.request({method:"resources/list",params:t},cw,n)}async createSamplingMessage(t,n){this._assertInitialized("createSamplingMessage");let r=t.tools?yw:gw;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},T$,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},xf,n)}openLink(t,n){return this._assertInitialized("openLink"),this.request({method:"ui/open-link",params:t},x$,n)}sendOpenLink=this.openLink;downloadFile(t,n){return this._assertInitialized("downloadFile"),this.request({method:"ui/download-file",params:t},$$,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},O$,n)}sendSizeChanged(t){return this.notification({method:"ui/notifications/size-changed",params:t})}setupSizeChangedNotifications(){let t=!1,n=0,r=0,i=()=>{t||(t=!0,requestAnimationFrame(()=>{t=!1;let s=document.documentElement,a=s.style.height;s.style.height="max-content";let u=Math.ceil(s.getBoundingClientRect().height);s.style.height=a;let c=Math.ceil(window.innerWidth);(c!==n||u!==r)&&(n=c,r=u,this.sendSizeChanged({width:c,height:u}))}))};i();let o=new ResizeObserver(i);return o.observe(document.documentElement),o.observe(document.body),()=>o.disconnect()}async connect(t=new vw(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:w$}},U$,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 B$="Chain Insights graph",H$="This graph is no longer available. Ask for it again.",rp="data-chain-insights-view",V$="This window cannot reach the local Chain Insights page. Open the link in your own browser for clicks that load more",ts=e=>!!e&&typeof e=="object"&&!Array.isArray(e),ww=e=>!ts(e)||!ts(e.result)?null:{arguments:ts(e.arguments)?e.arguments:null,result:e.result};function q$(e,t){const n=t.querySelector(`script[type="application/json"][${rp}]`);if(!n||n.getAttribute(rp)!==e)return null;try{return ww(JSON.parse(n.textContent??""))}catch{return null}}const W$=new Set(["127.0.0.1","localhost","[::1]","::1"]);function K$(e){const t=new URLSearchParams(e.search).get("view");if(t&&t.trim())return t.trim();if(!W$.has(e.hostname))return null;const n=/^\/view\/([^/]+)\/?$/.exec(e.pathname);if(!n?.[1])return null;try{return decodeURIComponent(n[1])||null}catch{return null}}async function J$(e,t,n){const r=n?q$(e,n):null;if(r)return r;try{const i=await t(`/api/view/${encodeURIComponent(e)}`,{headers:{Accept:"application/json"}});return i.ok?ww(await i.json()):null}catch{return null}}function Y$(e,t){return{async callServerTool({name:n,arguments:r}){let i;try{i=await e(`/api/tools/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({arguments:r})})}catch{throw new Error(V$)}let o=null;try{o=await i.json()}catch{o=null}if(ts(o)&&(Array.isArray(o.content)||"structuredContent"in o||"isError"in o))return o;throw new Error(i.ok?"the local Chain Insights page answered with no tool result":`the local Chain Insights page answered HTTP ${i.status}`)},async openLink({url:n}){return t(n,"_blank","noopener"),{}}}}const _w=new Map;function X$(e,t){_w.set(e,t)}function ip(e){return _w.get(e)??null}const Q$=/swiftshader|llvmpipe|softpipe|software|microsoft basic render/i;function eT(e){try{const t=e.createElement("canvas");if(typeof t.getContext!="function")return!1;const n={failIfMajorPerformanceCaveat:!0},r=t.getContext("webgl2",n)??t.getContext("webgl",n);if(!r)return!1;const i=r.getExtension?.("WEBGL_debug_renderer_info"),o=String(i?r.getParameter(i.UNMASKED_RENDERER_WEBGL):r.getParameter(r.RENDERER)??"");return Q$.test(o)?(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!1):(r.getExtension?.("WEBGL_lose_context")?.loseContext(),!0)}catch{return!1}}const tT="http://www.w3.org/2000/svg";let nT=0;function Mo(e){return Math.round(e*10)/10}function rT(e,t,n={}){const r=e.createElementNS(tT,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}function op(e,t,n,r){const i=`cia-graph-svg-${++nT}`,o=e.ownerDocument,s=(F,B)=>rT(o,F,B),a=(F,B,W)=>{const Q=s("text",{x:0,y:B,"text-anchor":"middle",class:W,"pointer-events":"none"});return Q.textContent=F,Q},{width:u,height:c}=t.dimensions(),l=s("svg",{class:"cia-graph-svg",viewBox:`0 0 ${u} ${c}`,role:"group",tabindex:0,"aria-label":r.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."}),d=s("defs"),f=s("pattern",{id:`${i}-dots`,width:24,height:24,patternUnits:"userSpaceOnUse"});f.append(s("circle",{class:"cia-graph-dot",cx:1,cy:1,r:1})),d.append(f);const h=s("rect",{class:"cia-graph-backdrop",width:"100%",height:"100%","data-canvas":""}),p=s("rect",{class:"cia-graph-dots",width:"100%",height:"100%",fill:`url(#${i}-dots)`,"data-canvas":""}),m=s("g",{"data-viewport":""}),y=s("g",{"data-edges":"",class:"cia-graph-edges"}),w=s("g",{"data-nodes":"",class:"cia-graph-nodes"});m.append(y,w),l.append(d,h,p,m),e.append(l);const g=new Map,b=new Map,v=new Map;let k=null;function _(){if(k)return k;const F=t.model(),B=t.positions(),W=new Map;k=W;const Q=F.nodes.length>VT,K=new Map(F.nodes.map(R=>[R.address,R])),I=Q?[]:DT(F,B,t.notes());for(const R of F.edges){const G=K.get(R.from),ne=K.get(R.to),ce=G&&B[G.id],ee=ne&&B[ne.id];if(!G||!ne||!ce||!ee){W.set(R.id,null);continue}if(Q){W.set(R.id,Ju(ce,ee,jn(G,F.checked_address),jn(ne,F.checked_address)));continue}const xe=I.filter(Ae=>Ae.id!==G.id&&Ae.id!==ne.id);W.set(R.id,qT(ce,ee,jn(G,F.checked_address),jn(ne,F.checked_address),xe))}return W}function $(F){let B=g.get(F);if(B)return B;B=`${i}-arrow-${g.size}`;const W=s("marker",{id:B,viewBox:"0 0 10 10",refX:9,refY:5,markerWidth:6,markerHeight:6,orient:"auto-start-reverse",markerUnits:"strokeWidth"}),Q=s("path",{d:"M0 0L10 5L0 10Z",class:"cia-graph-arrowhead"});return Q.style.fill=F,W.append(Q),d.append(W),g.set(F,B),B}function D(){return[...t.model().nodes??[]].sort((F,B)=>String(F.id).localeCompare(String(B.id)))}function M(){k=null;const F=t.model();y.replaceChildren(),w.replaceChildren(),b.clear(),v.clear();const B=new Map(F.nodes.map(W=>[W.address,W]));for(const W of F.edges){const Q=B.get(W.from);if(!Q||!B.get(W.to))continue;const K=t.colorOf(Q),I=s("g",{class:"cia-graph-edge graph-edge",tabindex:0,role:"button","aria-label":tc(W,t.now())});I.dataset.edgeId=W.id,I.style.setProperty("--edge-tone",K);const R=KT(),G=s("path",{class:"cia-graph-edge-hit","stroke-width":R.hit.width,"pointer-events":"stroke"}),ne=s("path",{class:"cia-graph-edge-line","stroke-width":R.line.width,"marker-end":`url(#${$(K)})`,"pointer-events":"none"});I.append(G,ne),I.addEventListener("keydown",ce=>{hp(ce.key)&&(ce.preventDefault(),n.selectEdge(W.id,"keyboard"))}),I.addEventListener("pointerenter",ce=>n.showTooltip(ce,tc(W,t.now()))),I.addEventListener("pointerleave",()=>n.hideTooltip()),y.append(I),v.set(W.id,{group:I,hit:G,line:ne})}for(const W of D())w.append(O(W));se(),_e()}function O(F){const B=t.model(),W=F.address===B.checked_address,Q=t.notes().get(F.id),K=jr(F,B.checked_address,Q),I=K.radius,R=s("g",{class:"cia-graph-node graph-node",tabindex:0,role:"button","aria-label":ec(F),"aria-pressed":"false"});R.dataset.nodeId=F.id,W&&(R.dataset.checked=""),R.style.setProperty("--node-tone",t.colorOf(F)),W&&R.append(s("circle",{class:"cia-graph-node-ring",r:I+6})),R.append(s("circle",{class:"cia-graph-node-body",r:I})),R.append(s("circle",{class:"cia-graph-node-dot",r:K.dot}));for(const G of K.texts)R.append(a(G.text,G.y,`cia-graph-node-${G.kind}`));Q&&(R.dataset.state="refused");for(const G of t.flags().get(F.id)??[])R.setAttribute(`data-flag-${G}`,"");return R.addEventListener("keydown",G=>{hp(G.key)&&(G.preventDefault(),n.selectNode(F.id,"keyboard"))}),R.addEventListener("pointerenter",G=>n.showTooltip(G,ec(F))),R.addEventListener("pointerleave",()=>n.hideTooltip()),b.set(F.id,R),R}function J(){const F=t.transform();m.setAttribute("transform",`translate(${F.x} ${F.y}) scale(${F.scale})`)}function se(){J();const F=t.positions(),{width:B,height:W}=t.dimensions();for(const[K,I]of b){const R=F[K]??{x:B/2,y:W/2};I.setAttribute("transform",`translate(${Mo(R.x)} ${Mo(R.y)})`)}const Q=_();for(const K of t.model().edges){const I=v.get(K.id);if(!I)continue;const R=Q.get(K.id)??null;I.group.style.display=R?"":"none",R&&(I.hit.setAttribute("d",R.d),I.line.setAttribute("d",R.d))}}function we(F){const B=t.model(),W=t.positions(),Q=W[F],K=b.get(F);if(!Q||!K)return;K.setAttribute("transform",`translate(${Mo(Q.x)} ${Mo(Q.y)})`);const I=B.nodes.find(G=>G.id===F);if(!I)return;const R=new Map(B.nodes.map(G=>[G.address,G]));for(const G of B.edges){if(G.from!==I.address&&G.to!==I.address)continue;const ne=v.get(G.id),ce=R.get(G.from),ee=R.get(G.to),xe=ce&&W[ce.id],Ae=ee&&W[ee.id];if(!ne||!ce||!ee||!xe||!Ae)continue;const z=Ju(xe,Ae,jn(ce,B.checked_address),jn(ee,B.checked_address));ne.group.style.display=z?"":"none",z&&(ne.hit.setAttribute("d",z.d),ne.line.setAttribute("d",z.d))}}function _e(){const F=t.model(),B=t.selected(),W=t.highlighted(),Q=B?.kind==="node"?F.nodes.find(K=>K.id===B.id)?.address??null:null;for(const K of F.edges){const I=v.get(K.id);if(!I)continue;const R=B?.kind==="edge"&&B.id===K.id,G=B?.kind==="edge"?R?Xt.related:Xt.faded:$w(K,Q),ne=G===Xt.faded;I.group.setAttribute("opacity",ne?String(G):"1"),I.line.setAttribute("stroke-opacity",ne?"1":String(G)),I.group.dataset.opacity=String(G),I.group.dataset.state=G===Xt.rest?"rest":G===Xt.related?"related":"faded",I.group.setAttribute("aria-pressed",String(R))}for(const[K,I]of b){const R=B?.kind==="node"&&B.id===K;I.classList.toggle("is-selected",R),I.classList.toggle("is-focused",W===K),I.setAttribute("aria-pressed",String(R))}}function Ge(){let F=null;for(const B of _().values())B?.bounds&&(F=F??{...B.bounds},F.x1=Math.min(F.x1,B.bounds.x1),F.y1=Math.min(F.y1,B.bounds.y1),F.x2=Math.max(F.x2,B.bounds.x2),F.y2=Math.max(F.y2,B.bounds.y2));return F}return{kind:"svg",surface:l,build:M,geometry(){k=null,se()},moveNode:we,endMove(){k=null,se()},camera:J,selection:_e,flag(F,B,W){b.get(F)?.toggleAttribute(`data-flag-${B}`,W)},theme(){for(const F of t.model().nodes)b.get(F.id)?.style.setProperty("--node-tone",t.colorOf(F))},resize(F,B){l.setAttribute("viewBox",`0 0 ${F} ${B}`)},pick:()=>null,linkBounds:Ge,destroy(){l.remove()}}}const iT=.45,oT=2.5,sT=5,aT="chain-insights.flows.v1",Bf="cia-graph-model",uT=90,Xt={rest:.6,related:.95,faded:.07},sp={checked:24,other:19},pi=16,cT=[["Sanctioned","Sanctioned"],["Scam","Scam"],["Poisoned","Poisoned"],["OnMoneyTrail","On money trail"],["Mixer","Mixer"],["Bridge","Bridge"],["Exchange","Exchange"],["Victim","Victim"],["Targeted","Targeted"]],$o=["exchange","scam","sanctioned","victim","pool","other"],lT={exchange:"infrastructure",scam:"danger",sanctioned:"danger",victim:"target",pool:"trail",other:"neutral"},kw={exchange:"Exchange",scam:"Scam",sanctioned:"Sanctioned",victim:"Victim",pool:"Pool",other:""};function Hf(e){return!!e&&e.schema===aT}function dT(e){return!!e&&e.kind===Bf}function Ke(e){return String(e??"").trim().toLowerCase()}function fT(e){const t=Ke(e);return $o.includes(t)?t:"other"}function vn(e){return typeof e=="number"&&Number.isFinite(e)?e:null}function Wu(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"):[]}function hT(e){const t=String(e??"").toUpperCase();return t==="IN"||t==="OUT"||t==="MIXED"||t==="CHECKED"?t:"OUT"}function Pt(e){return dT(e)?e:Hf(e)?pT(e):gT(e)}function pT(e){const t=Ke(e.center),n=new Map;for(const a of e.nodes??[]){const u=Ke(a?.address);u&&!n.has(u)&&n.set(u,a)}const r=[],i=new Set;for(const a of e.edges??[]){const u=Ke(a?.from),c=Ke(a?.to);if(!n.has(u)||!n.has(c)||u===c)continue;const l=`${u}->${c}`;i.has(l)||(i.add(l),r.push({id:l,from:u,to:c,source:"flows",amount_usd_sum:vn(a.usd),tx_count:vn(a.tx_count),first_seen_timestamp:vn(a.first_seen_ms),last_seen_timestamp:vn(a.last_seen_ms),...typeof a.link_kind=="string"&&a.link_kind?{link_kind:a.link_kind}:{}}))}const o=mT(t,[...n.keys()],r),s=[...n.entries()].map(([a,u])=>{const c=o.get(a)??{direction:"OUT",hop:2};return{id:a,address:a,direction:a===t?"CHECKED":c.direction,hop:a===t?0:c.hop,labels:Wu(u.labels),taxonomy:[],role:fT(u.role),total_in_usd:vn(u.total_in_usd),total_out_usd:vn(u.total_out_usd),degree_in:vn(u.degree_in),degree_out:vn(u.degree_out)}});return{kind:Bf,checked_address:t,network:e.network??null,nodes:s,edges:r,truncated:!!e.truncated,cursor:e.cursor??null}}function mT(e,t,n){const r=new Map,i=new Map,o=new Map,s=(d,f,h)=>d.set(f,[...d.get(f)??[],h]);for(const d of n)s(r,d.from,d.to),s(i,d.to,d.from),s(o,d.from,d.to),s(o,d.to,d.from);const a=d=>{const f=new Map([[e,0]]);for(let h=[e];h.length;){const p=[];for(const m of h)for(const y of d.get(m)??[])f.has(y)||(f.set(y,(f.get(m)??0)+1),p.push(y));h=p}return f},u=a(r),c=a(i),l=new Map;for(const d of t){if(d===e)continue;const f=u.get(d),h=c.get(d);if(f==null&&h==null)continue;const p=f!=null&&h!=null?f<h?"OUT":h<f?"IN":"MIXED":f!=null?"OUT":"IN";l.set(d,{direction:p,hop:Math.min(2,Math.min(f??1/0,h??1/0))})}for(let d=!0;d;){d=!1;for(const f of t){if(f===e||l.has(f))continue;const h=(o.get(f)??[]).find(m=>m!==e&&l.has(m));if(h==null)continue;const p=l.get(h);l.set(f,{direction:p.direction==="MIXED"?"OUT":p.direction,hop:2}),d=!0}}return l}function gT(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":hT(r.direction),labels:Wu(r.labels),taxonomy:Wu(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:Bf,checked_address:e?.checked_address??"",network:null,nodes:t,edges:n,truncated:!1,cursor:null}}function yT(e,t,n){const r=Pt(t),i=Gn(e,n??r.checked_address),o=e.nodes.find(d=>d.id===i),s=new Map(e.nodes.map(d=>[Ke(d.address),d])),a=[];for(const d of r.nodes){if(s.has(Ke(d.address)))continue;const f=!o||o.direction==="CHECKED"?d.direction==="CHECKED"?"OUT":d.direction:o.direction,h={...d,id:d.id,direction:f,hop:Math.min(2,(o?.hop??0)+1)};a.push(h),s.set(Ke(d.address),h)}const u=new Set(e.edges.map(d=>d.id)),c=new Set(e.edges.map(d=>`${Ke(d.from)}->${Ke(d.to)}`)),l=[...e.edges];for(const d of r.edges){const f=`${Ke(d.from)}->${Ke(d.to)}`;if(u.has(d.id)||c.has(f)||!s.has(Ke(d.from))||!s.has(Ke(d.to)))continue;const h=s.get(Ke(d.from)).address,p=s.get(Ke(d.to)).address;l.push({...d,from:h,to:p}),u.add(d.id),c.add(f)}return{model:{...e,nodes:[...e.nodes,...a],edges:l,truncated:e.truncated||r.truncated},added:a.map(d=>d.id)}}function Gn(e,t){if(t==null)return null;const n=Ke(t);return e.nodes.find(i=>i.id===t||Ke(i.address)===n)?.id??null}function mi(e){return typeof e!="string"||e.length<=12?e:`${e.slice(0,6)}…${e.slice(-4)}`}function Vf(e){return String(e??"").trim().replace(/\s+/g," ")}function ps(e){return Vf(e).replaceAll(" ","").toLowerCase()}function Cn(e){const t=[...e.taxonomy??[],...e.labels??[]],n=new Set,r=[];for(const i of t){const o=Vf(i),s=o.toLowerCase();!o||s==="address"||n.has(s)||(n.add(s),r.push(o))}return r}function Fo(e,t){const n=new Set(Cn(e).map(ps));return t.some(r=>n.has(ps(r)))}function vT(e){if(e.role&&$o.includes(e.role))return lT[e.role];if(Fo(e,["Sanctioned","Scam","Poisoned"]))return"danger";if(Fo(e,["Victim","Targeted"]))return"target";if(Fo(e,["OnMoneyTrail","Mixer"]))return"trail";if(Fo(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 We(e){return`var(--cia-graph-${e})`}const bT={semantic:{danger:{stroke:We("danger"),fill:We("node")},target:{stroke:We("target"),fill:We("node")},trail:{stroke:We("trail"),fill:We("node")},infrastructure:{stroke:We("infrastructure"),fill:We("node")},neutral:{stroke:We("neutral"),fill:We("node")}},risk:{CRITICAL:{stroke:We("critical"),fill:We("node")},HIGH:{stroke:We("high"),fill:We("node")},MEDIUM:{stroke:We("medium"),fill:We("node")},LOW:{stroke:We("low"),fill:We("node")}}};function wT(e,t=bT){const n=vT(e);return n==="critical"||n==="high"||n==="medium"||n==="low"?t.risk[n.toUpperCase()]??t.semantic.neutral:t.semantic[n]}function _T(e){return e.role&&$o.includes(e.role)?We(`role-${e.role}`):wT(e).stroke}function To(e){if(e.role&&e.role!=="other"&&$o.includes(e.role))return kw[e.role];const t=Cn(e);for(const[r,i]of cT)if(t.some(o=>ps(o)===ps(r)))return i;return(Array.isArray(e.labels)?e.labels.map(Vf).filter(Boolean).sort((r,i)=>r.localeCompare(i)):[])[0]??""}function Ku(e){return Math.min(oT,Math.max(iT,e))}function Ha(e){return[...e.nodes??[]].sort((t,n)=>String(t.id).localeCompare(String(n.id)))}function qf(e,t=Ha(e)){return t.find(n=>n.address===e.checked_address)??t[0]}function ap(e,t){return e.address===t?43:e.hop>=2?25:30}function jn(e,t){return e.address===t?sp.checked:sp.other}function jr(e,t,n){const r=e.address===t,i=jn(e,t),o=To(e),s=[];return o&&s.push({kind:"role",text:cC(o),y:i+17}),s.push({kind:"address",text:mi(e.address),y:i+(o?33:17)}),n&&s.push({kind:"note",text:n,y:i+(o?48:32)}),{radius:i,ring:r,dot:r?8:5,texts:s}}const kT={role:{size:13,advance:.68},address:{size:11,advance:.62},note:{size:11,advance:.6}},ou=2;function Wf(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 i=kT[r.kind],o=[...r.text].length*i.size*i.advance/2+ou;n.push({kind:r.kind,box:{x1:-o,y1:r.y-i.size*.8-ou,x2:o,y2:r.y+i.size*.25+ou}})}return n}function Sw(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 Ew(e){return Sw(Wf(e).map(t=>t.box))}const Kf=(e,t)=>(e instanceof Map?e.get(t):e?.[t])??null;function ST(e,t,n){const r=Pt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of Wf(jr(o,r.checked_address,Kf(n,o.id))))i.push({id:o.id,kind:a,x1:s.x+u.x1,y1:s.y+u.y1,x2:s.x+u.x2,y2:s.y+u.y2})}return i}function ET(e,t,n){return Sw(ST(e,t,n))}function xT(e,t){return e.x1<t.x2&&t.x1<e.x2&&e.y1<t.y2&&t.y1<e.y2}function $T(e){let t=0;for(const n of String(e))t=(t<<5)-t+n.charCodeAt(0)|0;return Math.abs(t)}function TT(e,t,n){const r=Pt(e),i={x:t/2,y:n/2},o={},s=Ha(r),a=qf(r,s);if(!a)return o;o[a.id]=i;const u=new Map;for(const c of s){if(c.id===a.id)continue;let l=c.direction==="IN"?-1:1;c.direction==="MIXED"&&(l=$T(c.id)%2?-1:1);const d=Math.min(2,Math.max(1,Number(c.hop)||1)),f=`${l}:${d}`;u.has(f)||u.set(f,[]),u.get(f).push(c)}for(const[c,l]of u){const[d,f]=c.split(":"),h=Number(d),p=Number(f),m=i.x+h*(p===1?t*.23:t*.43);Object.assign(o,CT(l,m,i.y,r.checked_address))}return o}function CT(e,t,n,r,i=24){const o=e.map((u,c)=>({node:u,x:t,y:n+(c-(e.length-1)/2)*64})),s=u=>Ew(jr(u,r)),a=(u,c)=>Math.max(ap(u,r)+ap(c,r)+20,s(u).y2-s(c).y1+2);for(let u=0;u<i;u++){for(let d=1;d<o.length;d++){const f=o[d-1],h=o[d];!f||!h||(h.y=Math.max(h.y,f.y+a(f.node,h.node)))}for(let d=o.length-2;d>=0;d--){const f=o[d],h=o[d+1];!f||!h||(f.y=Math.min(f.y,h.y-a(f.node,h.node)))}const c=o[0],l=o[o.length-1];if(c&&l){const d=(c.y+l.y)/2,f=n-d;for(const h of o)h.y+=f}}return Object.fromEntries(o.map(u=>[u.node.id,{x:u.x,y:u.y}]))}function AT(e,t,n){const r=Pt(e),i={x:t/2,y:n/2},o={},s=Ha(r),a=qf(r,s);if(!a)return o;o[a.id]=i;const u=s.filter(c=>c.id!==a.id);return u.forEach((c,l)=>{const d=-Math.PI/2+l*Math.PI*2/Math.max(1,u.length),f=c.hop>=2?Math.min(t,n)*.39:Math.min(t,n)*.27;o[c.id]={x:i.x+Math.cos(d)*f,y:i.y+Math.sin(d)*f}}),o}function IT(e,t,n,r){const i=Pt(e),o=Ha(i).filter(u=>t[u.id]),s=o.find(u=>u.address===i.checked_address);for(let u=0;u<o.length;u++)for(let c=u+1;c<o.length;c++){const l=o[u],d=o[c],f=l&&t[l.id],h=d&&t[d.id];if(!f||!h)continue;const p=h.x-f.x||.1,m=h.y-f.y||.1,y=Math.max(1,Math.hypot(p,m)),w=Math.max(0,88-y)*.012;f.x-=p/y*w,f.y-=m/y*w,h.x+=p/y*w,h.y+=m/y*w}const a=new Map(o.map(u=>[u.address,u]));for(const u of i.edges){const c=a.get(u.from),l=a.get(u.to);if(!c||!l)continue;const d=t[c.id],f=t[l.id];if(!d||!f)continue;const h=f.x-d.x,p=f.y-d.y,m=Math.max(1,Math.hypot(h,p)),y=(m-155)*.003;c!==s&&(d.x+=h/m*y,d.y+=p/m*y),l!==s&&(f.x-=h/m*y,f.y-=p/m*y)}return s&&(t[s.id]={x:n/2,y:r/2}),t}function NT(e,t,n,r=uT){const i=Pt(e),o=AT(i,t,n);for(let s=0;s<r;s++)IT(i,o,t,n);return o}function Uo(e,t,n,r){return t==="tree"?TT(e,n,r):NT(e,n,r)}function RT(e,t,n,r,i={}){const o=Pt(e),s=t[n],a={...t};if(!s)return a;const u=i.spacing??80,c=i.gap??48,l=Math.max(1,i.perColumn??6),d=o.nodes.find(g=>g.id===n),f=new Map(o.nodes.map(g=>[g.id,g])),h=g=>Ew(jr(g,o.checked_address,Kf(i.notes,g.id))),p=o.nodes.flatMap(g=>{const b=t[g.id];if(!b)return[];const v=h(g);return[{x1:b.x+v.x1,x2:b.x+v.x2}]});let m=p.length?Math.min(...p.map(g=>g.x1)):s.x,y=p.length?Math.max(...p.map(g=>g.x2)):s.x;const w={left:[],right:[]};for(const g of[...r].sort()){const b=f.get(g);if(!b||a[g])continue;const v=o.edges.some(_=>_.from===b.address&&_.to===d?.address),k=o.edges.some(_=>_.to===b.address&&_.from===d?.address);w[v&&!k?"left":"right"].push(b)}for(const g of["left","right"]){const b=w[g];for(let v=0;v<b.length;v+=l){const k=b.slice(v,v+l),_=k.map(h),$=Math.max(..._.map(O=>Math.max(-O.x1,O.x2))),D=Math.max(u,Math.max(..._.map(O=>O.y2))-Math.min(..._.map(O=>O.y1))+6),M=g==="left"?m-c-$:y+c+$;k.forEach((O,J)=>{a[O.id]={x:M,y:s.y+(J-(k.length-1)/2)*D}}),g==="left"?m=M-$:y=M+$}}return a}function LT(e,t,n,r=pi){const i=Math.max(1,e.x2-e.x1),o=Math.max(1,e.y2-e.y1),s=Ku(Math.min((t-r*2)/i,(n-r*2)/o));return{x:t/2-(e.x1+e.x2)/2*s,y:n/2-(e.y1+e.y2)/2*s,scale:s}}function up(e,t,n,r=pi){return Math.min((t-r*2)/Math.max(1,e.x2-e.x1),(n-r*2)/Math.max(1,e.y2-e.y1))}function zT(e,t,n,r,i=4){const o=t.x-e.x,s=t.y-e.y,a=Math.hypot(o,s),u=n+i,c=r+i;if(!Number.isFinite(a)||a<=0||u+c>=a)return null;const l=o/a,d=s/a;return{x1:e.x+l*u,y1:e.y+d*u,x2:t.x-l*c,y2:t.y-d*c}}function En(e){return Math.round(e*100)/100}function su(e,t,n,r,i){const o=s=>`${En(s.x)},${En(s.y)}`;return{kind:e,start:t,end:i,controls:[n,r],d:`M${o(t)} C${o(n)} ${o(r)} ${o(i)}`}}function Ju(e,t,n,r,i=4){const o=t.x-e.x,s=t.y-e.y,a=Math.hypot(o,s),u=n+r+i*2;if(!Number.isFinite(a)||a<=u)return null;if(o>=u){const f={x:e.x+n+i,y:e.y},h={x:t.x-r-i,y:t.y},p=h.x-f.x,m=Math.max(p*.45,Math.min(65,p));return su("forward",f,{x:f.x+m,y:f.y},{x:h.x-m,y:h.y},h)}if(o<=-u){const f={x:e.x,y:e.y-n-i},h={x:t.x,y:t.y-r-i},p=Math.max(100,Math.abs(o)*.2);return su("backward",f,{x:f.x+85,y:f.y-p},{x:h.x+85,y:h.y-p},h)}if(Math.abs(s)>u){const f=s>0?1:-1,h={x:e.x,y:e.y+f*(n+i)},p={x:t.x,y:t.y-f*(r+i)},m=Math.abs(p.y-h.y),y=Math.max(m*.45,Math.min(40,m));return su("vertical",h,{x:h.x,y:h.y+f*y},{x:p.x,y:p.y-f*y},p)}const c=zT(e,t,n,r,i),l={x:c.x1,y:c.y1},d={x:c.x2,y:c.y2};return{kind:"straight",start:l,end:d,controls:null,d:`M${En(l.x)},${En(l.y)} L${En(d.x)},${En(d.y)}`}}const PT=6,au=PT+3,Yt=14,cp=10,OT=3,lp=6;function DT(e,t,n){const r=Pt(e),i=[];for(const o of r.nodes){const s=t[o.id];if(s)for(const{kind:a,box:u}of Wf(jr(o,r.checked_address,Kf(n,o.id))))a==="circle"?i.push({id:o.id,kind:"circle",x:s.x,y:s.y,r:u.x2}):i.push({id:o.id,kind:"box",x1:s.x+u.x1,y1:s.y+u.y1,x2:s.x+u.x2,y2:s.y+u.y2})}return i}function MT(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 FT(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 UT(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 GT(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 xw(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 jT(e,t){const n=[];for(const r of e){const i=Math.max(1,Math.ceil(xw(r.points)/t));for(let o=0;o<=i;o++){const s=o/i;if(r.kind==="L"){const[a,u]=r.points;n.push({x:a.x+(u.x-a.x)*s,y:a.y+(u.y-a.y)*s})}else n.push(UT(r.points,s))}}return n}function dp(e,t,n,r){const i=e.flatMap(a=>a.points),o={x1:Math.min(...i.map(a=>a.x)),y1:Math.min(...i.map(a=>a.y)),x2:Math.max(...i.map(a=>a.x)),y2:Math.max(...i.map(a=>a.y))},s=[];if(n.forEach((a,u)=>{a.x1<=o.x2&&o.x1<=a.x2&&a.y1<=o.y2&&o.y1<=a.y2&&s.push(u)}),!s.length)return!0;for(const a of jT(e,OT))for(const u of s){const c=n[u],l=t[u];if(!(!c||!l)&&!(a.x<c.x1||a.x>c.x2||a.y<c.y1||a.y>c.y2)&&MT(a,l)<r)return!1}return!0}function ZT(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(xw(e.slice(s-1,s+1)));const i=[];let o=t;for(let s=1;s<e.length-1;s++){const a=e[s-1],u=e[s],c=e[s+1],l=r[s-1],d=r[s];if(!a||!u||!c||l===void 0||d===void 0)continue;const f=l/(s-1===0?1:2),h=d/(s===r.length-1?1:2),p=Math.min(Yt,f,h),m={x:(u.x-a.x)/l,y:(u.y-a.y)/l},y={x:(c.x-u.x)/d,y:(c.y-u.y)/d},w={x:u.x-m.x*p,y:u.y-m.y*p},g={x:u.x+y.x*p,y:u.y+y.y*p};i.push({kind:"L",points:[o,w]}),i.push({kind:"C",points:[w,{x:w.x+m.x*p*.55,y:w.y+m.y*p*.55},{x:g.x-y.x*p*.55,y:g.y-y.y*p*.55},g]}),o=g}return i.push({kind:"L",points:[o,n]}),i.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 BT(e){const t=i=>`${En(i.x)},${En(i.y)}`,n=e[0];if(!n)return"";let r=`M${t(n.points[0])}`;for(const i of e)r+=i.kind==="L"?` L${t(i.points[1])}`:` C${t(i.points[1])} ${t(i.points[2])} ${t(i.points[3])}`;return r}function fp(e,t,n,r,i){const o=Math.min(e.y,n)-Yt,s=Math.max(e.y,n)+Yt,a=d=>(d-e.x)*t;let u=1/0;for(const d of i)if(d.y1<e.y&&e.y<d.y2){const f=t===1?d.x1:d.x2,h=t===1?d.x2:d.x1;a(h)>0&&(u=Math.min(u,Math.max(0,a(f))))}const c=i.filter(d=>d.y1<s&&o<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[...c,[1/0,1/0]]){if(d>l+1){const h=Math.min(d,u);if(h<=l+1)return null;const p=Number.isFinite(h)&&h-l<80?(l+h)/2:l+40;return e.x+t*p}if(l=Math.max(l,f),l>=u)return null}return null}function HT(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 i=t[r-1],o=t[r+1];return!i||!o?!0:!(Math.abs(i.x-n.x)<.01&&Math.abs(o.x-n.x)<.01||Math.abs(i.y-n.y)<.01&&Math.abs(o.y-n.y)<.01)})}const VT=120;function qT(e,t,n,r,i,o=4){const s=Ju(e,t,n,r,o);if(!s||!i.length)return s;const a=i.map(f=>FT(f,au));if(dp(GT(s),i,a,au))return s;const u=new Set([e.y,t.y]),c=f=>Math.abs(f-e.y)<lp?e.y:Math.abs(f-t.y)<lp?t.y:f;for(const f of a)u.add(c(Math.round(f.y1)-Yt-1)),u.add(c(Math.round(f.y2)+Yt+1));const l=t.x>=e.x?1:-1,d=[[l,l],[l,-l],[-l,l],[-l,-l]];for(const[f,h]of d){const p={x:e.x+f*(n+o),y:e.y},m={x:t.x-h*(r+o),y:t.y},y=[];for(const w of u){const g=Math.abs(w-p.y)<.01?p.x:fp(p,f,w,Yt,a);if(g===null)continue;const b=Math.abs(w-m.y)<.01?m.x:fp(m,-h,w,Yt+cp,a);if(b===null||Math.abs(w-m.y)<.01&&(m.x-g)*h<Yt+cp||Math.abs(w-p.y)<.01&&(b-p.x)*f<Yt)continue;const v=HT([p,{x:g,y:p.y},{x:g,y:w},{x:b,y:w},{x:b,y:m.y},m]);if(!WT(v,a))continue;let k=(v.length-2)*Yt,_;for(const $ of v)_&&(k+=Math.abs($.x-_.x)+Math.abs($.y-_.y)),_=$;y.push({points:v,length:k})}y.sort((w,g)=>{const b=w.points[2]?.y,v=g.points[2]?.y;return w.length-g.length||(b===void 0||v===void 0?0:b-v)});for(const w of y){const g=ZT(w.points);if(!dp(g,i,a,au))continue;const b=w.points,v=b[0],k=b[b.length-1];if(!v||!k)continue;const _={x1:Math.min(...b.map($=>$.x)),y1:Math.min(...b.map($=>$.y)),x2:Math.max(...b.map($=>$.x)),y2:Math.max(...b.map($=>$.y))};return{kind:"routed",start:v,end:k,controls:null,d:BT(g),bounds:_}}}return s}function WT(e,t){let n;for(const r of e){if(n){const i={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 o of t)if(xT(i,o))return!1}n=r}return!0}function $w(e,t){if(!t)return Xt.rest;const n=Ke(t);return Ke(e.from)===n||Ke(e.to)===n?Xt.related:Xt.faded}function KT(){return{hit:{stroke:"transparent",width:16},line:{stroke:We("edge"),width:1.6},arrow:{fill:We("edge")}}}function JT(e,t,n){return e!=="gravity"&&e!=="tree"?null:{layout:e,id:t,pointerId:n}}function YT(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 XT(e,t,n,r=sT){if(!e||e.pointerId!==t)return e;const i=Math.hypot(n.x-e.start.x,n.y-e.start.y);return{...e,moved:e.moved||i>r}}function QT(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 hp(e){return e==="Enter"||e===" "}function eC(e,t){return{x:(e.x-t.x)/t.scale,y:(e.y-t.y)/t.scale}}function tC(e,t,n,r,i){return!t||t.pointerId!==n||!Object.hasOwn(e,t.id)?!1:(e[t.id]=eC(r,i),!0)}function nC(e,t){return e?.pointerId===t?null:e}function rC(e,t,n,r){const i=Math.min(t.width/n,t.height/r),o=t.left+(t.width-n*i)/2,s=t.top+(t.height-r*i)/2;return{x:(e.x-o)/i,y:(e.y-s)/i}}function iC(e,t,n){const r=new Map;let i=null,o=null,s=null;function a(h){if(h===e)return{kind:"canvas",id:null};const p=h;if(p?.closest?.("[data-canvas]"))return{kind:"canvas",id:null};const m=p?.closest?.("[data-node-id]");if(m)return{kind:"node",id:m.dataset.nodeId??null};const y=p?.closest?.("[data-edge-id]");return y?{kind:"edge",id:y.dataset.edgeId??null}:null}function u(h){if(h.pointerType==="mouse"&&h.button!==0)return;const p=n?n(h):a(h.target);if(!p)return;const m=t.point(h);if(r.set(h.pointerId,m),e.setPointerCapture(h.pointerId),p.kind!=="canvas"&&(h.preventDefault(),h.stopPropagation()),r.size===1){i=YT(p.kind,p.id,h.pointerId,{x:h.clientX,y:h.clientY}),o=p.kind==="canvas"?{point:m,transform:{...t.transform()}}:null;return}if(i&&(i={...i,moved:!0}),o=null,r.size===2){const[y,w]=[...r.values()];y&&w&&(s={distance:Math.hypot(w.x-y.x,w.y-y.y),scale:t.transform().scale},t.startPinch())}}function c(h){if(!r.has(h.pointerId))return;const p=t.point(h);if(r.set(h.pointerId,p),s){const[m,y]=[...r.values()];m&&y&&t.pinch(s,[m,y],h);return}if(i?.pointerId===h.pointerId){if(i=XT(i,h.pointerId,{x:h.clientX,y:h.clientY}),!i?.moved)return;if(i.kind==="node"){t.drag(i.id??"",h.pointerId,p,h);return}if(i.kind==="edge")return}o&&t.pan(o,p,h)}function l(h,p=!1){const m=QT(i,h.pointerId,p);m&&t.select(m),i?.pointerId===h.pointerId&&(i=null),t.endDrag(h.pointerId),r.delete(h.pointerId),r.size||(i=null,o=null,s=null),e.hasPointerCapture(h.pointerId)&&e.releasePointerCapture(h.pointerId)}const d=h=>l(h),f=h=>l(h,!0);return e.addEventListener("pointerdown",u,!0),e.addEventListener("pointermove",c),e.addEventListener("pointerup",d),e.addEventListener("pointercancel",f),()=>{e.removeEventListener("pointerdown",u,!0),e.removeEventListener("pointermove",c),e.removeEventListener("pointerup",d),e.removeEventListener("pointercancel",f)}}function oC(e,t,n){let r=!1;function i(o,s=!1){r=o,e.classList.toggle("graph-panel--expanded",o),n.classList.toggle("graph-expanded",o),t.classList.toggle("expand-control--expanded",o),t.setAttribute("aria-expanded",String(o)),t.setAttribute("aria-label",o?"Close expanded graph":"Expand graph"),t.setAttribute("title",o?"Close expanded graph":"Expand graph"),o?(e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true")):(e.removeAttribute("role"),e.removeAttribute("aria-modal"),s&&t.focus())}return{open(){i(!0)},close(o={}){i(!1,o.restoreFocus!==!1)},toggle(){i(!r,r)},isOpen(){return r}}}function Tw(e){const t=String(e??"").toLowerCase();return t?t.charAt(0).toUpperCase()+t.slice(1):"Unknown"}function Yu(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e)}function Xu(e){return e==null?"Unavailable":new Intl.NumberFormat("en-US").format(e)}function xn(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 Cw(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[i,o]of r){const s=Math.floor(n/i);if(s>=1)return`${s} ${o}${s===1?"":"s"} ago`}return"just now"}function Qu(e){if(e.amount_usd_sum==null||e.price_coverage_ratio===0)return"Unavailable";const t=e.price_coverage_ratio;return Yu(e.amount_usd_sum)+(t!=null&&t>0&&t<1?" (priced portion)":"")}function sC(e){const t=[["Incoming amount (USD)",e.total_in_usd==null?"Unavailable":Yu(e.total_in_usd)],["Outgoing amount (USD)",e.total_out_usd==null?"Unavailable":Yu(e.total_out_usd)]];return e.role&&$o.includes(e.role)?[["Role",kw[e.role]||"Other"],...t,["Senders",Xu(e.degree_in)],["Receivers",Xu(e.degree_out)],["Labels",Cn(e).join(", ")||"No labels"]]:[["Address risk",e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} · ${Tw(e.risk_level)}`],["Confidence","Unavailable"],...t,["First activity (UTC)",xn(e.first_activity_timestamp)],["Last activity (UTC)",xn(e.last_activity_timestamp)],["Labels",Cn(e).join(", ")||"No labels"]]}function aC(e,t){if(e.source==="flows")return[["From",e.from||"Unavailable"],["To",e.to||"Unavailable"],["Value (USD)",Qu(e)],["Transfers",Xu(e.tx_count)],["First seen (UTC)",xn(e.first_seen_timestamp)],["Last seen (UTC)",xn(e.last_seen_timestamp)],["Since last seen",Cw(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)",Qu(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)",xn(e.first_seen_timestamp)],["Last seen (UTC)",xn(e.last_seen_timestamp)],["First transaction",e.first_tx_id||"Unavailable"],["Last transaction",e.last_tx_id||"Unavailable"]]}function Aw(e){return typeof e!="string"||!/^0x[a-fA-F0-9]{64}$/.test(e)?null:`https://robinhoodchain.blockscout.com/tx/${e.toLowerCase()}`}function ec(e){const t=To(e);if(e.role)return`${e.address}. ${t||"Other"}.${Cn(e).length?` Labels: ${Cn(e).join(", ")}.`:""}`;const n=e.risk_score==null?"Not scored":`${Math.round(e.risk_score*100)} ${Tw(e.risk_level)} risk`,r=Cn(e).join(", ");return`${e.address}. ${n}.${r?` Labels: ${r}.`:""}`}function tc(e,t){const n=`${e.from} to ${e.to}. Aggregate value ${Qu(e)}. ${e.tx_count??0} ${e.tx_count===1?"transfer":"transfers"}.`;return e.source==="flows"&&e.last_seen_timestamp?`${n} Last seen ${Cw(e.last_seen_timestamp,t)}.`:n}function uC(e,t){return Pt(e).nodes.map(n=>{const r={id:n.address,label:Cn(n).join(", ")||To(n)};n.role&&(r.role=n.role);const i=t?.(n.address);return i&&(r.href=i),r})}function cC(e,t=22){return e.length>t?`${e.slice(0,t-1)}…`:e}function lC(e,t,n={}){const r=e.ownerDocument;let i=Pt(t),o=n.layout??(Hf(t)?"tree":"gravity");const s={width:e.clientWidth||n.width||820,height:e.clientHeight||n.height||430};let a=Uo(i,o,s.width,s.height);const u=new Map,c=new Map;let l={x:0,y:0,scale:1},d=null,f=null,h=null;const p=n.now??(()=>Date.now()),m=C=>n.nodeStyle?.(C).stroke??_T(C);e.classList.add("cia-graph-engine"),e.closest(".cia-graph-surface")||e.classList.add("cia-graph-surface");const y={model:()=>i,positions:()=>a,transform:()=>l,notes:()=>u,flags:()=>c,selected:()=>d,highlighted:()=>f,colorOf:m,now:p,dimensions:()=>s},w={selectNode:(C,P)=>B(C,P),selectEdge:(C,P)=>W(C,P),showTooltip:(C,P)=>G(C,P),hideTooltip:()=>ne(),lost:()=>ie()};function g(C){const P=C==="webgl"?ip("webgl"):null;if(P)try{return P(e,y,w,{label:n.label})}catch{}return op(e,y,w,{label:n.label})}const b=n.renderer??(ip("webgl")&&eT(r)?"webgl":"svg");let v=g(b);e.dataset.renderer=v.kind;const k=()=>{const C=ET(i,a,u);if(!C)return null;const P=v.linkBounds();return P&&(C.x1=Math.min(C.x1,P.x1),C.y1=Math.min(C.y1,P.y1),C.x2=Math.max(C.x2,P.x2),C.y2=Math.max(C.y2,P.y2)),C},_=()=>{const C=k();return C?LT(C,s.width,s.height,pi):{x:0,y:0,scale:1}};l=_();const $=r.createElement("div");$.className="graph-tooltip cia-graph-tooltip",$.hidden=!0,$.setAttribute("role","tooltip"),e.append($);let D=0,M=!1,O=!1;function J(){if(D){M=!0;return}v.build()}function se(){if(D){O=!0;return}l=_(),we()}function we(){v.camera()}function _e(C="program"){const P=uC(i,n.href),re=d?.kind==="node"?i.nodes.find(pe=>pe.id===d.id)??null:null,ve=d?.kind==="edge"?i.edges.find(pe=>pe.id===d.id)??null:null;if(re){const pe=i.edges.filter(rt=>rt.from===re.address||rt.to===re.address);return{kind:"node",id:re.id,selectedId:re.address,nodes:P,title:"Selected address",identity:re.address,values:sC(re),related:pe,node:re,edge:null,source:C}}return ve?{kind:"edge",id:ve.id,selectedId:null,nodes:P,title:"Selected aggregate flow",identity:`${ve.from} → ${ve.to}`,values:aC(ve,p()),related:[ve],node:null,edge:ve,source:C}:{kind:null,id:null,selectedId:null,nodes:P,title:"Nothing selected",identity:"",values:[],related:[],node:null,edge:null,source:C}}function Ge(C){const P=_e(C);F(P),n.onSelect?.(P)}function F(C){const P=n.selectionRoot,re=P?.querySelector("[data-selection-title]"),ve=P?.querySelector("[data-selection-identity]"),pe=P?.querySelector("[data-selection-meta]");!re||!ve||!pe||(re.textContent=C.title,ve.textContent=C.identity,pe.replaceChildren(...C.values.map(([rt,It])=>{const jt=r.createElement("div");jt.className="meta-item",It!=="Unavailable"&&(["From","To","First transaction","Last transaction"].includes(rt)&&jt.classList.add("meta-item--identity"),rt==="Incoming amount (USD)"&&jt.classList.add("meta-item--incoming"),rt==="Outgoing amount (USD)"&&jt.classList.add("meta-item--outgoing")),["From","To","First transaction","Last transaction","Labels"].includes(rt)&&jt.classList.add("meta-item--wide");const Vr=r.createElement("span");Vr.textContent=rt;const Ln=r.createElement("strong"),nn=["First transaction","Last transaction"].includes(rt)?Aw(It):null;if(nn&&n.openLink){const Zt=n.openLink,Kt=r.createElement("button");Kt.type="button",Kt.className="cia-graph-explorer-link",Kt.dataset.explorer=nn,Kt.textContent=It,Kt.setAttribute("aria-label",`${rt}: ${It} (opens the explorer)`),Kt.addEventListener("click",()=>Zt(nn)),Ln.append(Kt)}else if(nn){const Zt=r.createElement("a");Zt.href=nn,Zt.target="_blank",Zt.rel="noopener noreferrer",Zt.textContent=It,Zt.setAttribute("aria-label",`${rt}: ${It} (opens in new tab)`),Ln.append(Zt)}else Ln.textContent=It;return jt.append(Vr,Ln),jt})))}function B(C,P="program"){d=C?{kind:"node",id:C}:null,v.selection(),Ge(P)}function W(C,P="program"){d=C?{kind:"edge",id:C}:null,v.selection(),Ge(P)}function Q(C){if(C==null)return B(null);const P=Gn(i,C);if(P)return B(P);if(i.edges.some(re=>re.id===C))return W(C)}function K(){l=_(),we()}function I(C,P={x:s.width/2,y:s.height/2}){const re=Ku(l.scale*(1+C)),ve=re/l.scale;l={x:P.x-(P.x-l.x)*ve,y:P.y-(P.y-l.y)*ve,scale:re},we()}function R(C){o=C,n.controls?.querySelectorAll("[data-layout]").forEach(P=>{P.classList.toggle("active",P.dataset.layout===C),P.setAttribute("aria-pressed",String(P.dataset.layout===C))}),n.onLayoutChange?.(C),a=Uo(i,o,s.width,s.height),v.geometry(),K()}function G(C,P){$.textContent=P,$.hidden=!1;const re=e.getBoundingClientRect();$.style.left=`${Math.min(re.width-330,Math.max(8,C.clientX-re.left+12))}px`,$.style.top=`${Math.max(8,C.clientY-re.top+12)}px`}function ne(){$.hidden=!0}function ce(C){return rC({x:C.clientX,y:C.clientY},v.surface.getBoundingClientRect(),s.width,s.height)}const ee={point:ce,transform:()=>l,select(C){C.type==="select-node"?B(C.id,"pointer"):C.type==="select-edge"?W(C.id,"pointer"):B(qf(i)?.id??null,"canvas")},drag(C,P,re){!h&&(h=JT(o,C,P),!h)||tC(a,h,P,re,l)&&(xe=!0,v.moveNode(h.id))},endDrag(C){const P=h?.pointerId===C&&xe;h=nC(h,C),P&&(xe=!1,v.endMove())},pan(C,P){l={x:C.transform.x+P.x-C.point.x,y:C.transform.y+P.y-C.point.y,scale:l.scale},we()},startPinch(){h=null},pinch(C,[P,re]){const ve=Math.hypot(re.x-P.x,re.y-P.y),pe=Ku(C.scale*ve/Math.max(1,C.distance));I(pe/l.scale-1,{x:(P.x+re.x)/2,y:(P.y+re.y)/2})}};let xe=!1;const Ae=C=>{C.preventDefault(),I(C.deltaY>0?-.12:.12,ce(C))},z={ArrowLeft:[60,0],ArrowRight:[-60,0],ArrowUp:[0,60],ArrowDown:[0,-60]},j=C=>{if(C.target!==v.surface)return;const P=z[C.key];P?(C.preventDefault(),l={...l,x:l.x+P[0],y:l.y+P[1]},we()):C.key==="+"||C.key==="="?I(.18):C.key==="-"?I(-.18):C.key==="0"&&K()};let H=()=>{};function Y(){const C=v.surface,P=re=>v.pick(ce(re));H=iC(C,ee,v.kind==="svg"?void 0:P),C.addEventListener("wheel",Ae,{passive:!1}),C.addEventListener("keydown",j)}function le(){H(),v.surface.removeEventListener("wheel",Ae),v.surface.removeEventListener("keydown",j)}Y();function ie(){v.kind!=="svg"&&(le(),v.destroy(),v=op(e,y,w,{label:n.label}),e.dataset.renderer=v.kind,e.append($),Y(),J())}const $e=n.controls?.querySelector("[data-expand]")??null,Ie=n.panel&&$e?oC(n.panel,$e,r.body):null,de=()=>{Ie?.toggle(),n.onExpansionChange?.(Ie?.isOpen()??!1),requestAnimationFrame(K)},ze=n.panel??e,fe=C=>{if(C.key==="Tab"&&Ie?.isOpen()&&n.panel){const P=Array.from(n.panel.querySelectorAll('button,a[href],[tabindex="0"],summary')).filter(pe=>pe.checkVisibility()),re=P[0],ve=P.at(-1);C.shiftKey&&r.activeElement===re?(C.preventDefault(),ve?.focus()):!C.shiftKey&&r.activeElement===ve&&(C.preventDefault(),re?.focus())}if(C.key==="Escape"){if(Ie?.isOpen()){Ie.close(),n.onExpansionChange?.(!1),requestAnimationFrame(K);return}B(null,"keyboard")}};ze.addEventListener("keydown",fe);const Je=[],He=(C,P)=>{C&&(C.addEventListener("click",P),Je.push([C,P]))};n.controls?.querySelectorAll("[data-layout]").forEach(C=>He(C,()=>R(C.dataset.layout==="tree"?"tree":"gravity"))),He(n.controls?.querySelector("[data-zoom='in']"),()=>I(.18)),He(n.controls?.querySelector("[data-zoom='out']"),()=>I(-.18)),He(n.controls?.querySelector("[data-zoom='fit']"),K),Ie&&He($e,de);const pt=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{const C=e.clientWidth,P=e.clientHeight;!C||!P||C===s.width&&P===s.height||(s.width=C,s.height=P,v.resize(C,P),K())});pt?.observe(e),J(),n.selected&&Q(n.selected);const Ve={update(C){const P=a;i=Pt(C);const re=i.nodes.every(pe=>P[pe.id])?{}:Uo(i,o,s.width,s.height);a=Object.fromEntries(i.nodes.map(pe=>[pe.id,P[pe.id]??re[pe.id]]).filter(([,pe])=>pe)),d&&!(d.kind==="node"?i.nodes.some(pe=>pe.id===d.id):i.edges.some(pe=>pe.id===d.id))&&(d=null),f&&!i.nodes.some(pe=>pe.id===f)&&(f=null);const ve=new Set(i.nodes.map(pe=>pe.id));for(const pe of[...c.keys()])ve.has(pe)||c.delete(pe);J(),se()},merge(C,P){const re=yT(i,C,P);i=re.model;const ve=Gn(i,P??Pt(C).checked_address);return a=ve?RT(i,a,ve,re.added,{notes:u}):{...a,...Uo(i,o,s.width,s.height),...a},J(),re.added.length&&se(),re.added},batch(C){D++;try{C()}finally{D--,!D&&M&&(M=!1,v.build()),!D&&O&&(O=!1,l=_(),we())}},setTheme(C){C&&r.documentElement.setAttribute("data-theme",C),v.theme()},select:Q,destroy(){pt?.disconnect(),le(),ze.removeEventListener("keydown",fe);for(const[C,P]of Je)C.removeEventListener("click",P);Ie?.close({restoreFocus:!1}),v.destroy(),$.remove(),e.classList.remove("cia-graph-engine"),delete e.dataset.renderer,delete e.ciaGraph},fit:K,zoom:C=>I(C),setLayout:R,markNode(C,P){const re=Gn(i,C);re&&(P?u.set(re,P):u.delete(re),J())},flagNode(C,P,re){const ve=Gn(i,C);if(!ve)return;const pe=c.get(ve)??new Set;re?pe.add(P):pe.delete(P),pe.size?c.set(ve,pe):c.delete(ve),D?M=!0:v.flag(ve,P,re)},positions:()=>structuredClone(a),model:()=>i,contentBounds:()=>k(),transform:()=>({...l}),highlight(C){f=C==null?null:Gn(i,C),v.selection()},renderer:()=>v.kind,clientPoint(C){const P=Gn(i,C),re=P?a[P]:null;if(!re)return null;const ve=v.surface.getBoundingClientRect(),pe=Math.min(ve.width/s.width,ve.height/s.height)||1,rt=ve.left+(ve.width-s.width*pe)/2,It=ve.top+(ve.height-s.height*pe)/2;return{x:rt+(re.x*l.scale+l.x)*pe,y:It+(re.y*l.scale+l.y)*pe}}};return Object.defineProperty(e,"ciaGraph",{value:Ve,configurable:!0}),Ve}const Iw="chain-insights.flows.v1",Jf="chain-insights.result.v1",Nw=5e3,pp=6,dC=3,Rw=/^0x[0-9a-fA-F]{40}$/,fC=/^0x[0-9a-fA-F]{64}$/;function hC(e){return typeof e=="string"&&(Rw.test(e)||fC.test(e))}function gi(e){return typeof e=="string"&&Rw.test(e)}function nc(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Va(e){const t=e?.facts?.query?.results;return Array.isArray(t)?t.filter(nc):[]}function pC(e){const t=e?.facts;return typeof t?.subject?.network=="string"&&t.subject.network?t.subject.network:"robinhood"}function Qt(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 Yf(e){return e<1e11?e*1e3:e}const Lw=/^\d{4}-\d{2}-\d{2}$/,mC=Date.UTC(2009,0,1),gC=Date.UTC(2100,0,1);function uu(e){return new Date(Yf(e)).toISOString().slice(0,10)}function mp(e){const t=Date.parse(`${e}T00:00:00Z`);return new Date(t-864e5).toISOString().slice(0,10)}function Xf(e){if(typeof e!="string"||!Lw.test(e))return!1;const t=Date.parse(`${e}T00:00:00Z`);return Number.isFinite(t)&&new Date(t).toISOString().slice(0,10)===e}const yC=new Set(["day","date","hour","week","month"]),vC=["_timestamp","_time","_at"];function gp(e){return yC.has(e)||vC.some(t=>e.endsWith(t))}function zw(e){const t=[];for(const n of e)for(const r of Object.keys(n))t.includes(r)||t.push(r);return t}function bC(e){return Array.isArray(e)?e.some(gi):gi(e)}function wC(e){return e.some(t=>Object.values(t).some(bC))}function Pw(e){return e.length>0&&e.every(t=>gi(t.from_address)&&gi(t.to_address))}const _C=/^(\d{4})-(\d{2})$/,kC=/^(\d{4})-W(\d{2})$/,SC=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}/,EC=/(?:Z|[+-]\d{2}:?\d{2})$/i;function xC(e,t){const n=Date.UTC(e,0,4);return n-(new Date(n).getUTCDay()+6)%7*864e5+(t-1)*7*864e5}function yp(e){if(typeof e=="string"){const r=e.trim();if(Lw.test(r))return Xf(r)?Date.parse(`${r}T00:00:00Z`):null;const i=_C.exec(r);if(i){const s=Number(i[2])-1;return s>=0&&s<12?Date.UTC(Number(i[1]),s,1):null}const o=kC.exec(r);if(o){const s=Number(o[2]);return s>=1&&s<=53?xC(Number(o[1]),s):null}if(SC.test(r)){const s=r.replace(" ","T"),a=Date.parse(EC.test(s)?s:`${s}Z`);return Number.isFinite(a)?a:null}}const t=Qt(e);if(t==null)return null;const n=Yf(t);return n>=mC&&n<gC?n:null}function Qf(e,t={}){if(e.length===0||wC(e))return null;const n=zw(e),i=n.filter(gp).find(d=>e.some(f=>yp(f[d])!=null));if(!i)return null;const o=n.filter(d=>{if(gp(d))return!1;const f=e.map(h=>h[d]).filter(h=>h!=null);return f.length>0&&f.every(h=>Qt(h)!=null)});if(o.length===0)return null;const s=o.slice(0,pp),a=new Map;let u=0;for(const d of e){const f=yp(d[i]);if(f==null)continue;u++;const h=a.get(f)??{count:0,sums:s.map(()=>null)};h.count++,s.forEach((p,m)=>{const y=Qt(d[p]);y!=null&&(h.sums[m]=(h.sums[m]??0)+y)}),a.set(f,h)}const c=[...a.entries()].sort((d,f)=>d[0]-f[0]);return c.filter(([,d])=>d.sums.some(f=>f!=null)).length<(t.minPoints??dC)?null:{xColumn:i,times:c.map(([d])=>d),rowCounts:c.map(([,d])=>d.count),daily:c.every(([d])=>d%864e5===0),series:s.map((d,f)=>({column:d,values:c.map(([,h])=>h.sums[f]??null)})),omittedColumns:o.slice(pp),skippedRows:e.length-u,failures:[]}}function $C(e){if(!e)return"failed";const t=/^\s*([a-z][a-z0-9_]*)\s*:/.exec(e);if(t?.[1])return t[1];const n=e.trim().split(/\s+/).slice(0,4).join(" ");return n.length>40?`${n.slice(0,39)}…`:n||"failed"}const TC=e=>e==null||Qt(e)!=null;function Ow(e){const t=Mw(e);if(t.length<3||!t.every(c=>Xf(c.id))||new Set(t.map(c=>c.id)).size!==t.length)return null;const n=t.filter(c=>c.ok);if(n.length===0||!n.every(c=>c.rows.length===1))return null;const r=Object.keys(n[0].rows[0]),i=[...r].sort().join("\0");for(const c of n){const l=c.rows[0];if(Object.keys(l).sort().join("\0")!==i||!Object.values(l).every(TC))return null}if(r.length===0||r.includes("day"))return null;const o=[...t].sort((c,l)=>c.id.localeCompare(l.id)),s=o.map(c=>({day:c.id,...c.ok?c.rows[0]:Object.fromEntries(r.map(l=>[l,null]))})),a=o.filter(c=>!c.ok).map(c=>({day:c.id,time:Date.parse(`${c.id}T00:00:00Z`),code:$C(c.error)})),u=Qf(s,{minPoints:1});return u?{rows:s,columns:r,failures:a,model:{...u,failures:a}}:null}const CC=/\baddress\s*:\s*(["'])(0x[0-9a-fA-F]{40})\1/g,AC=/^\s*(<)?-(?:\[[^\]]*\])?-(>)?/,IC=/(<)?-(?:\[[^\]]*\])?-(>)?\s*$/;function vp(e,t){if(!e)return"none";const n=!!e[1],r=!!e[2];return n===r?null:t==="after"?r?"from":"to":r?"to":"from"}function Dw(e){if(typeof e!="string"||!e)return null;const t=[...e.matchAll(CC)];if(t.length===0||new Set(t.map(r=>r[2].toLowerCase())).size!==1)return null;let n=null;for(const r of t){const i=r.index??0,o=e.lastIndexOf("(",i),s=e.indexOf(")",i);if(o<0||s<0)return null;const a=[vp(IC.exec(e.slice(0,o)),"before"),vp(AC.exec(e.slice(s+1)),"after")];if(a.includes(null))return null;for(const u of a)if(u!=="none"){if(n&&n!==u)return null;n=u}}return n?{address:t[0][2],end:n}:null}function NC(e,t){if(e.length===0||Pw(e))return null;const n=Dw(t);if(!n)return null;const r=n.address.toLowerCase(),i=zw(e).filter(s=>e.every(a=>gi(a[s]))&&!e.every(a=>String(a[s]).toLowerCase()===r));if(i.length!==1)return null;const o=i[0];return e.map(s=>n.end==="from"?{...s,from_address:n.address,to_address:s[o]}:{...s,from_address:s[o],to_address:n.address})}function RC(e){return Pw(e)?"graph":Qf(e)?"chart":"table"}const LC=[["sanctioned","sanctioned"],["scam","scam"],["victim","victim"],["pool","pool"],["exchange","exchange"]];function bp(e){return Array.isArray(e)?e.filter(t=>typeof t=="string"&&t.trim()!=="").map(t=>t.trim()):[]}function zC(e,t){if(t)return"exchange";const n=new Set(e.map(r=>r.replace(/\s+/g,"").toLowerCase()));for(const[r,i]of LC)if(n.has(r))return i;return"other"}const wp=(e,t)=>e==null?t:t==null?e:e+t;function PC(e,t="robinhood",n){const r=new Map;for(const h of e)for(const p of new Set([String(h.from_address).toLowerCase(),String(h.to_address).toLowerCase()]))r.set(p,(r.get(p)??0)+1);let i="",o=0;for(const[h,p]of r)p>o&&(i=h,o=p);const s=n?.toLowerCase();s&&r.has(s)&&(i=s);const a=new Map,u=new Map,c=(h,p,m)=>{const y=a.get(h)??{address:h,labels:[],exchange:!1};for(const w of p)y.labels.some(g=>g.toLowerCase()===w.toLowerCase())||y.labels.push(w);y.exchange=y.exchange||m,a.set(h,y)};i&&a.set(i,{address:i,labels:[],exchange:!1});let l=0;for(const h of e){const p=String(h.from_address).toLowerCase(),m=String(h.to_address).toLowerCase(),y=[p,m].filter((k,_,$)=>!a.has(k)&&$.indexOf(k)===_).length;if(a.size+y>Nw||(l++,c(p,bp(h.from_labels),h.from_is_exchange===!0),c(m,bp(h.to_labels),h.to_is_exchange===!0),p===m))continue;const w=`${p}->${m}`,g=u.get(w)??{from:p,to:m,usd:null,tx:null,first:null,last:null,kinds:[]};g.usd=wp(g.usd,Qt(h.amount_usd_sum)),g.tx=wp(g.tx,Qt(h.tx_count));const b=Qt(h.first_seen_timestamp),v=Qt(h.last_seen_timestamp);b!=null&&(g.first=g.first==null?b:Math.min(g.first,b)),v!=null&&(g.last=g.last==null?v:Math.max(g.last,v)),typeof h.link_kind=="string"&&h.link_kind&&!g.kinds.includes(h.link_kind)&&g.kinds.push(h.link_kind),u.set(w,g)}const d=[...a.values()].map(h=>({address:h.address,role:zC(h.labels,h.exchange),labels:h.labels})),f=[...u.values()].map(h=>({from:h.from,to:h.to,usd:h.usd,tx_count:h.tx,first_seen_ms:h.first,last_seen_ms:h.last,...h.kinds.length?{link_kind:h.kinds.join(", ")}:{}}));return{view:{schema:Iw,network:t,center:i,nodes:d,edges:f,truncated:!1},rowsTotal:e.length,rowsDrawn:l,rowsLeftOut:e.length-l,addresses:a.size}}function Mw(e){const t=e?.facts?.queries;return Array.isArray(t)?t.filter(nc).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(nc):[],count:typeof n.count=="number"?n.count:null,truncated:n.truncated===!0,elapsedMs:typeof n.elapsed_ms=="number"?n.elapsed_ms:null,query:typeof n.query=="string"&&n.query?n.query:null})):[]}const _p=200;function Co(e){return(e?.content??[]).filter(t=>t?.type==="text"&&typeof t.text=="string").map(t=>t.text).join(`
|
|
109
|
+
`).trim()}function qr(e){if(typeof e=="string")return e.trim()||null;if(!e||typeof e!="object"||Array.isArray(e))return null;const{code:t,message:n,detail:r,error:i}=e,o=[n,r,i].find(a=>typeof a=="string"&&a.trim()!=="")?.trim()??null,s=typeof t=="string"&&t.trim()?t.trim():null;return o?s&&!o.startsWith(s)?`${s}: ${o}`:o:s}function Fw(e){if(!e)return null;const t=e.structuredContent,n=qr(t?.error)??qr(t?.facts?.error)??qr(t?.facts?.query?.error);if(!e.isError||n)return n;const r=Co(e);if(r.startsWith("{"))try{const i=JSON.parse(r),o=qr(i?.error)??qr(i);if(o)return o}catch{}return r||"The tool answered with an error."}const OC=new Set(["usage_status","subscription_status","meta_usage_status","meta_subscription_status"]);function Uw(e){if(!e||Fw(e)!=null)return"text";const t=e.structuredContent;if(t?.schema===Iw)return"flows";if(t?.schema===Jf){if(t.tool==="graph_query")return RC(Va(t));if(t.tool==="graph_query_batch")return!Array.isArray(t.facts?.queries)||t.facts.queries.length===0?"text":Ow(t)?"chart":"batch";if(typeof t.tool=="string"&&OC.has(t.tool))return"balance"}return"text"}function A(e,t,n={},...r){const i=e.createElement(t);for(const[o,s]of Object.entries(n))s==null||s===!1||(o==="class"?i.className=String(s):o==="text"?i.textContent=String(s):i.setAttribute(o,s===!0?"":String(s)));for(const o of r)o==null||o===!1||i.append(typeof o=="string"?e.createTextNode(o):o);return i}function DC(e,t){const n=A(e,"code",{class:"cv-addr",title:t,"data-full":t,text:mi(t)}),r=A(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",()=>{MC(e,t,n,r)}),A(e,"span",{class:"cv-addr-cell"},n,r)}async function MC(e,t,n,r){const i=e.defaultView?.navigator?.clipboard;try{if(i?.writeText)return await i.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 FC(e,t){return/(timestamp|seen|_at|_ms|time)$/i.test(t)&&e>1e9?xn(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)}const UC=160,kp=2e3;function GC(e,t=UC){const n=e.trim().split(/\r?\n/,1)[0]??"",r=n.search(/[.!?](?=\s|$)/),i=(r<0?n:n.slice(0,r+1)).trim();if(i.length<=t)return i;const o=i.slice(0,t-1),s=o.lastIndexOf(" ");return`${(s>t*.6?o.slice(0,s):o).trimEnd()}…`}function Gw(e,t,n){const r=e.ownerDocument,i=n.full!=null&&n.full.length>kp?`${n.full.slice(0,kp-1)}…`:n.full,o=i!=null&&i!==t,s=A(r,"section",{class:`cia-graph-surface cv-notice cv-notice-${n.kind}`,"data-view":n.view,"data-notice":n.kind,role:n.kind==="refused"?"alert":"status",title:o?i:null},o?A(r,"details",{class:"cv-notice-more"},A(r,"summary",{class:"cv-notice-line",text:t}),A(r,"p",{class:"cv-notice-full",text:i})):A(r,"p",{class:"cv-notice-line",text:t}));return e.replaceChildren(s),s}function jC(e){const t=e?.facts?.query,n=Array.isArray(t?.results)?t.results.filter(o=>!!o&&typeof o=="object"&&!Array.isArray(o)):[],r=n.slice(0,_p),i=[];for(const o of r)for(const s of Object.keys(o))i.includes(s)||i.push(s);return{columns:i,rows:r,total:n.length,truncated:n.length>_p||t?.truncated===!0,elapsedMs:typeof t?.elapsed_ms=="number"?t.elapsed_ms:null}}function ZC(e,t,n){return t==null?A(e,"span",{class:"cv-null","aria-label":"empty",text:"—"}):hC(t)?DC(e,t):typeof t=="number"?e.createTextNode(FC(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 Sp(e,t,n={}){const r=e.ownerDocument,i=jC(t.structuredContent),o=i.rows.length;if(i.total===0)return Gw(e,"No rows.",{kind:"empty",view:"table"}),i;const s=`${new Intl.NumberFormat("en-US").format(o)} ${o===1?"row":"rows"}${i.elapsedMs==null?"":` in ${i.elapsedMs} ms`}`,a=A(r,"table",{class:"cv-table"},A(r,"thead",{},A(r,"tr",{},...i.columns.map(u=>A(r,"th",{scope:"col",text:u})))),A(r,"tbody",{},...i.rows.map(u=>A(r,"tr",{},...i.columns.map(c=>A(r,"td",{},ZC(r,u[c],c)))))));return e.replaceChildren(A(r,"section",{class:"cv-card cv-table-view","data-view":"table","aria-label":"Graph query result"},A(r,"header",{class:"cv-card-head"},A(r,"strong",{text:"Graph query result"}),A(r,"span",{class:"cv-muted",text:s}),n.toggle??null),i.truncated?A(r,"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(i.total)} rows. Narrow the query to see the rest.`}):null,i.columns.length?A(r,"div",{class:"cv-table-wrap"},a):null)),i}const Wr=(e,t=0)=>typeof e=="number"&&Number.isFinite(e)?e:t,Go=e=>typeof e=="string"&&e?e:null;function BC(e){const t=e?.facts??{};if(typeof t.wallet=="string"&&t.wallet)return{kind:"wallet",wallet:t.wallet,tier:String(t.tier??"anonymous"),allowanceUsd:Wr(t.allowance_usd),consumedUsd:Wr(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,i=Go(n.access_mode);return{kind:"free",unit:r?"units":"seconds",used:Wr(r?n.daily_units_used:n.daily_seconds_used),limit:Wr(r?n.daily_units_limit:n.daily_seconds_limit),remaining:Wr(r?n.remaining_units:n.remaining_seconds),resetAt:Go(n.reset_at),identifierKind:Go(n.identifier_kind),accessMode:i,noLimit:!r&&i==="public_free"&&n.daily_seconds_limit===0}}return{kind:"unknown"}}const Ep=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumFractionDigits:2}).format(e),jo=(e,t)=>`${new Intl.NumberFormat("en-US").format(e)} ${t==="units"?e===1?"unit":"units":e===1?"second":"seconds"}`;function cu(e){if(!e)return"No active window";const t=Date.parse(e);return Number.isFinite(t)?`${xn(t)} UTC`:e}function xp(e,t,n,r){const i=n>0?Math.min(1,t/n):0,o=A(e,"div",{class:"cv-meter",role:"meter","aria-label":r,"aria-valuemin":0,"aria-valuemax":n,"aria-valuenow":Math.min(t,n)},A(e,"span"));return o.firstElementChild.style.width=`${Math.round(i*100)}%`,o}function lu(e,t){return A(e,"dl",{class:"cv-facts"},...t.flatMap(([n,r])=>[A(e,"dt",{text:n}),A(e,"dd",{text:r})]))}function HC(e,t){const n=e.ownerDocument,r=BC(t.structuredContent);let i,o,s;return r.kind==="wallet"?(o="Wallet allowance",s=`${mi(r.wallet)} · ${r.tier==="subscriber"?"Subscriber":"No active subscription"}`,i=[xp(n,r.consumedUsd,r.allowanceUsd,"Share of today's allowance used"),lu(n,[["Daily allowance",Ep(r.allowanceUsd)],["Used today",Ep(r.consumedUsd)],["Window ends",cu(r.windowEnd)]])]):r.kind==="free"?(o="Free tier",s=`No wallet · counted per ${r.identifierKind==="ip"||!r.identifierKind?"network address":r.identifierKind}`,i=r.noLimit?[A(n,"p",{class:"cv-balance-note","data-no-limit":"",text:"Free access, no daily limit"}),lu(n,[["Daily allowance","No daily limit"],["Used today",jo(r.used,r.unit)],["Window ends",cu(r.resetAt)]])]:[xp(n,r.used,r.limit,"Share of today's free allowance used"),lu(n,[["Daily allowance",jo(r.limit,r.unit)],["Used today",jo(r.used,r.unit)],["Left today",jo(r.remaining,r.unit)],["Window ends",cu(r.resetAt)]])]):(o="Usage",s="The server sent no allowance figures.",i=[A(n,"p",{class:"cv-muted",text:Co(t)||"Nothing to show."})]),e.replaceChildren(A(n,"section",{class:"cv-card cv-balance-view","data-view":"balance","data-balance":r.kind,"aria-label":o},A(n,"header",{class:"cv-card-head"},A(n,"strong",{text:o}),A(n,"span",{class:"cv-muted",text:s})),...i)),r}function yi(e,t,n="No drawing for this answer."){const r=e.ownerDocument,i=Fw(t);if(i!=null){Gw(e,GC(i),{kind:"refused",view:"text",full:i});return}const o=Co(t);e.replaceChildren(A(r,"section",{class:"cv-card cv-text-view","data-view":"text"},A(r,"p",{text:n}),o?A(r,"p",{class:"cv-muted cv-text-body",text:o.length>600?`${o.slice(0,599)}…`:o}):null))}function eh(e,t="Loading the Chain Insights view"){const n=e.ownerDocument;e.replaceChildren(A(n,"section",{class:"cv-card cv-skeleton","data-view":"loading","aria-busy":"true","aria-label":t},A(n,"span",{class:"cv-sr",text:t}),A(n,"div",{class:"cv-skel-line cv-skel-title"}),A(n,"div",{class:"cv-skel-line cv-skel-sub"}),A(n,"div",{class:"cv-skel-block"})))}const VC="http://www.w3.org/2000/svg",rc=720,qC=320,WC=6,KC=420,$p=4,JC=120,ti={left:70,right:18,top:6},ic=18,jw=16,Zw=6,Bw=26,YC=170,XC=82,QC=28,eA=80,Zn=1e3,Sn=60*Zn,nr=60*Sn,en=24*nr,tA=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Hw(e,t){if(/usd/i.test(e))return"usd";const n=t.filter(r=>r!=null);return n.length>0&&n.every(Number.isInteger)?"count":"number"}const nA=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}),rA=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",maximumSignificantDigits:2}),iA=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",notation:"compact",maximumFractionDigits:1}),vi=new Intl.NumberFormat("en-US",{maximumFractionDigits:0}),oA=new Intl.NumberFormat("en-US",{maximumFractionDigits:4}),Vw=new Intl.NumberFormat("en-US",{maximumSignificantDigits:3}),qw=new Intl.NumberFormat("en-US",{notation:"compact",maximumFractionDigits:2}),sA=new Intl.NumberFormat("en-US",{maximumFractionDigits:6});function ms(e,t){if(e==null)return"—";const n=e!==0&&Math.abs(e)<.01;return t==="usd"?n?rA.format(e):nA.format(e):t==="count"?vi.format(e):n?Vw.format(e):oA.format(e)}function aA(e){return e!==0&&Math.abs(e)<.01?Vw.format(e):Math.abs(e)<1e3?sA.format(Math.round(e*100)/100):qw.format(e)}function Tp(e,t){return t==="usd"?Math.abs(e)<1e3?ms(e,"usd"):iA.format(e):t==="count"?Math.abs(e)<1e3?vi.format(e):qw.format(e):aA(e)}function uA(e,t){const n=new Date(e).toISOString();return t?`${n.slice(0,10)} (UTC day)`:`${n.slice(0,10)} ${n.slice(11,19)} UTC`}function Ww(e){return e<=en?"time":e<=JC*en?"day":"month"}const cA=[Zn,2*Zn,5*Zn,10*Zn,15*Zn,30*Zn,Sn,2*Sn,5*Sn,10*Sn,15*Sn,30*Sn,nr,2*nr,3*nr,6*nr,12*nr,en],lA=[1,2,3,7,14,30,60].map(e=>e*en),dA=[1,2,3,6,12,24,60,120],Cp=4*en,fA={time:76,day:84,month:72},hA=e=>new Date(e).getUTCFullYear()*12+new Date(e).getUTCMonth(),du=e=>Date.UTC(Math.floor(e/12),e%12,1);function pA(e,t,n){const r=t-e,i=Ww(r);if(r<=0)return{unit:i,step:0,times:[e]};const o=Math.max(2,Math.floor(n));if(i==="month"){for(const s of dA){const a=[];let u=hA(e);for(du(u)<e&&u++;du(u)<=t;u++)u%s===0&&a.push(du(u));if(a.length<=o&&a.length>0)return{unit:i,step:s,times:a}}return{unit:i,step:0,times:[e,t]}}for(const s of i==="time"?cA:lA){const a=s===7*en||s===14*en?Math.ceil((e-Cp)/s)*s+Cp:i==="day"?Math.ceil(e/en)*en:Math.ceil(e/s)*s,u=a>t?0:Math.floor((t-a)/s)+1;if(u>0&&u<=o)return{unit:i,step:s,times:Array.from({length:u},(c,l)=>a+l*s)}}return{unit:i,step:0,times:[e,t]}}function mA(e,t,n){const r=new Date(e),i=r.toISOString();return t==="month"?n>=12?i.slice(0,4):`${tA[r.getUTCMonth()]} ${r.getUTCFullYear()}`:t==="day"||e%en===0?i.slice(0,10):n>0&&n<Sn?i.slice(11,19):i.slice(11,16)}function gA(e){return e.series.map(t=>{let n=0,r=null,i=null;return t.values.forEach((o,s)=>{o!=null&&(n+=o,(r==null||o>r)&&(r=o,i=e.times[s]??null))}),{column:t.column,kind:Hw(t.column,t.values),total:n,peak:r,peakTime:i}})}const Lt=e=>new Date(e).toISOString(),Kw=(e,t)=>Lt(e).slice(0,10)===Lt(t).slice(0,10);function yA(e){const t=e.times[0],n=e.times[e.times.length-1];if(t==null||n==null)return"no points";if(e.daily)return t===n?`${Lt(t).slice(0,10)} UTC`:`${Lt(t).slice(0,10)} to ${Lt(n).slice(0,10)} UTC`;const r=i=>`${Lt(i).slice(0,10)} ${Lt(i).slice(11,16)}`;return t===n?`${r(t)} UTC`:Kw(t,n)?`${r(t)} to ${Lt(n).slice(11,16)} UTC`:`${r(t)} to ${r(n)} UTC`}function vA(e,t=new Set){const n=e.times.map((u,c)=>e.series.some(l=>l.values[c]!=null)),r=n.filter(Boolean).length,i=e.rowCounts.reduce((u,c,l)=>u+(n[l]?c:0),0),o=[yA(e),`${vi.format(r)} ${r===1?"point":"points"}${i>r?` from ${vi.format(i)} transfers`:""}`],s=e.times[0]??0,a=e.times[e.times.length-1]??0;for(const u of gA(e)){if(t.has(u.column))continue;if(u.peak==null||u.peakTime==null){o.push(`${u.column}: no values`);continue}const c=e.daily?`on ${Lt(u.peakTime).slice(0,10)}`:Kw(s,a)?`at ${Lt(u.peakTime).slice(11,19)}`:`at ${Lt(u.peakTime).slice(0,10)} ${Lt(u.peakTime).slice(11,16)}`;o.push(`${u.column}: total ${ms(u.total,u.kind)}, peak ${ms(u.peak,u.kind)} ${c}`)}return e.failures.length&&o.push(`no answer for ${e.failures.map(u=>`${u.day} (${u.code})`).join(", ")}`),o.join(" · ")}function bA(e,t){if(e.length===0)return-1;let n=0,r=e.length-1;for(;n<r;){const i=n+r>>1;(e[i]??0)<t?n=i+1:r=i}return n>0&&Math.abs(t-(e[n-1]??0))<=Math.abs((e[n]??0)-t)?n-1:n}function wA(e,t,n){const r=Math.min(t,n),i=Math.max(t,n);let o=-1,s=-1;return e.forEach((a,u)=>{a<r||a>i||(o<0&&(o=u),s=u)}),o>=0&&s-o>=1?{start:o,end:s}:null}function _A(e,t,n){const r=Math.max(0,t),i=Math.min(e.times.length-1,n)+1,o=e.times.slice(r,i),s=o[0]??0,a=o[o.length-1]??0;return{...e,times:o,rowCounts:e.rowCounts.slice(r,i),series:e.series.map(u=>({column:u.column,values:u.values.slice(r,i)})),failures:e.failures.filter(u=>u.time>=s&&u.time<=a)}}function kA(e,t,n){if(e.has(t)){const r=new Set(e);return r.delete(t),r}return n.filter(r=>!e.has(r)).length<=1?e:new Set([...e,t])}const Jw=e=>`var(--cia-graph-series-${e%WC+1})`;function gs(e,t){const n=e.last-e.first,r=e.plotRight-e.plotLeft;return n>0?e.plotLeft+(t-e.first)/n*r:e.plotLeft+r/2}function fu(e,t){const n=e.plotRight-e.plotLeft,r=Math.min(e.plotRight,Math.max(e.plotLeft,t));return n>0?e.first+(r-e.plotLeft)/n*(e.last-e.first):e.first}function Yw(e,t){return e.plotBottom-(t-e.min)/(e.max-e.min||1)*(e.plotBottom-e.plotTop)}function SA(e){if(e<=1)return YC;const t=Math.floor((KC-ti.top-Zw-Bw-(e-1)*jw)/e)-ic;return Math.max(QC,Math.min(XC,t))}function Ap(e,t=rc,n=new Set){const r=ti.left,i=t-ti.right,o=e.times[0]??0,s=e.times[e.times.length-1]??o,a={plotLeft:r,plotRight:i,first:o,last:s},u=e.series.map((p,m)=>({series:p,index:m})).filter(({series:p})=>!n.has(p.column)),c=SA(u.length),l=u.map(({series:p,index:m},y)=>{const w=ti.top+y*(ic+c+jw),g=w+ic,b=g+c,v=p.values.filter(J=>J!=null),k=Math.min(0,...v),_=Math.max(...v,k+1e-9),$={plotTop:g,plotBottom:b,min:k,max:_},D=[],M=[];let O=[];return p.values.forEach((J,se)=>{if(J==null){O.length&&M.push(O),O=[];return}const we=e.times[se]??o,_e={x:gs(a,we),y:Yw($,J),time:we,value:J,index:se};D.push(_e),O.push(_e)}),O.length&&M.push(O),{column:p.column,index:m,kind:Hw(p.column,p.values),color:Jw(m),top:w,plotTop:g,plotBottom:b,min:k,max:_,runs:M,points:D}}),d=(l[l.length-1]?.plotBottom??ti.top)+Zw,f=Ww(s-o),h=[];if(e.times.length){const p=pA(o,s,(i-r)/fA[f]);for(const m of p.times){const y=gs(a,m),w=y-r<34?"start":i-y<34?"end":"middle";h.push({x:y,label:mA(m,p.unit,p.step),anchor:w})}}return{width:t,height:d+Bw,plotLeft:r,plotRight:i,first:o,last:s,unit:f,lanes:l,ticks:h,axisY:d}}function it(e,t,n={}){const r=e.createElementNS(VC,t);for(const[i,o]of Object.entries(n))r.setAttribute(i,String(o));return r}const Bt=e=>Math.round(e*10)/10;let EA=0;const xA="Time series plot. Left and Right arrows read the points one by one, Home and End jump to the ends, Escape hides the read-out. Drag across the plot to zoom.";function $A(e,t,n={}){const r=e.ownerDocument,i=t.series.map(I=>I.column),o={start:0,end:t.times.length-1};let s=new Set,a=o,u=null,c=null,l=rc,d=t,f=Ap(t,l);const h=A(r,"span",{class:"cv-muted cv-chart-summary","data-chart-summary":""}),p=t.series.map((I,R)=>{const G=A(r,"span",{class:"cv-chart-key","aria-hidden":"true"});G.style.setProperty("--cv-key",Jw(R));const ne=A(r,"button",{type:"button",class:"cv-chart-series","data-series":I.column,"aria-pressed":"true"},G,A(r,"span",{text:I.column}));return ne.addEventListener("click",()=>{const ce=kA(s,I.column,i);ce!==s&&(s=ce,O())}),ne}),m=A(r,"div",{class:"cv-chart-legend",role:"group","aria-label":"Show or hide a series"},...p),y=A(r,"button",{type:"button",class:"cv-chart-reset","data-reset-zoom":"",hidden:!0,text:"Reset zoom"}),w=it(r,"svg",{class:"cv-chart-svg",role:"img",preserveAspectRatio:"xMidYMid meet"}),g=A(r,"div",{class:"cv-chart-readout",id:`cv-chart-readout-${++EA}`,"data-chart-readout":"",role:"status","aria-live":"polite",hidden:!0}),b=A(r,"div",{class:"cv-chart-plot",tabindex:0,role:"group","aria-label":xA,"aria-describedby":g.id},w),v=A(r,"div",{class:"cv-chart-body"},b,g),k=it(r,"rect",{class:"cv-chart-brush"}),_=it(r,"g",{class:"cv-chart-cross","aria-hidden":"true"}),$=[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),D=A(r,"section",{class:"cv-chart cia-graph-surface","data-view":"chart","aria-label":`Time series by ${t.xColumn}`},A(r,"header",{class:"cv-flows-head"},A(r,"div",{class:"cv-title"},A(r,"strong",{text:"Time series"}),h)),$.length?A(r,"p",{class:"cv-note",role:"note","data-chart-note":"",text:$.join(" ")}):null,A(r,"div",{class:"cv-chart-bar"},m,y,n.toggle??null),v);e.replaceChildren(D);function M(){const I=[],R=f.lanes[0]?.plotTop??0,G=d.times.length>1?(f.plotRight-f.plotLeft)/(d.times.length-1):24,ne=Math.max(6,Math.min(24,G*.6));for(const ee of d.failures){const xe=gs(f,ee.time),Ae=it(r,"rect",{class:"cv-chart-failure","data-failure":ee.day,x:Bt(xe-ne/2),y:R,width:Bt(ne),height:Math.max(0,f.axisY-R)});I.push(Ae)}for(const ee of f.lanes){const xe=it(r,"g",{class:"cv-chart-lane","data-series":ee.column}),Ae=it(r,"rect",{class:"cv-chart-swatch",x:f.plotLeft,y:ee.top+4,width:14,height:4,rx:2});Ae.style.fill=ee.color;const z=it(r,"text",{class:"cv-chart-name",x:f.plotLeft+20,y:ee.top+11});z.textContent=ee.column,xe.append(Ae,z,it(r,"line",{class:"cv-chart-grid",x1:f.plotLeft,x2:f.plotRight,y1:ee.plotTop,y2:ee.plotTop}),it(r,"line",{class:"cv-chart-base",x1:f.plotLeft,x2:f.plotRight,y1:ee.plotBottom,y2:ee.plotBottom}));const j=it(r,"text",{class:"cv-chart-tick",x:f.plotLeft-8,y:ee.plotTop+4,"text-anchor":"end"});j.textContent=Tp(ee.max,ee.kind);const H=it(r,"text",{class:"cv-chart-tick",x:f.plotLeft-8,y:ee.plotBottom+4,"text-anchor":"end"});H.textContent=Tp(ee.min,ee.kind),xe.append(j,H);for(const Y of ee.runs){if(Y.length<2)continue;const le=it(r,"polyline",{class:"cv-chart-line",points:Y.map(ie=>`${Bt(ie.x)},${Bt(ie.y)}`).join(" "),fill:"none"});le.style.stroke=ee.color,xe.append(le)}if(ee.points.length<=eA)for(const Y of ee.points){const le=it(r,"circle",{class:"cv-chart-dot",cx:Bt(Y.x),cy:Bt(Y.y),r:3,"data-index":a.start+Y.index,"data-time":Y.time});le.style.fill=ee.color,xe.append(le)}I.push(xe)}const ce=it(r,"g",{class:"cv-chart-axis"});for(const ee of f.ticks){const xe=it(r,"text",{class:"cv-chart-tick",x:Bt(ee.x),y:f.axisY+14,"text-anchor":ee.anchor});xe.textContent=ee.label,ce.append(xe)}return I.push(ce),I}function O(){d=_A(t,a.start,a.end),f=Ap(d,l,s);const I=f.lanes.map(G=>G.column);w.setAttribute("viewBox",`0 0 ${f.width} ${f.height}`),w.setAttribute("aria-label",`Line chart of ${I.join(", ")} by ${t.xColumn}, ${d.times.length} ${d.times.length===1?"point":"points"}`),w.replaceChildren(k,...M(),_),h.textContent=vA(d,s);for(const G of p){const ne=!s.has(G.dataset.series??"");G.setAttribute("aria-pressed",String(ne)),ne&&I.length===1?(G.setAttribute("aria-disabled","true"),G.title="At least one series stays visible"):(G.removeAttribute("aria-disabled"),G.removeAttribute("title"))}const R=a.start!==o.start||a.end!==o.end;y.hidden=!R,D.dataset.zoomed=String(R),J(),se()}function J(){if(!c||Math.abs(c.to-c.from)<$p){k.style.display="none";return}const I=f.lanes[0]?.plotTop??0,R=Math.max(f.plotLeft,Math.min(c.from,c.to)),G=Math.min(f.plotRight,Math.max(c.from,c.to));k.setAttribute("x",String(Bt(R))),k.setAttribute("width",String(Bt(Math.max(0,G-R)))),k.setAttribute("y",String(I)),k.setAttribute("height",String(Math.max(0,f.axisY-I))),k.style.display=""}function se(){if(_.replaceChildren(),u==null||u<a.start||u>a.end){u=null,_.style.display="none",g.hidden=!0,g.replaceChildren(),delete b.dataset.focus;return}const I=u-a.start,R=d.times[I]??f.first,G=Bt(gs(f,R)),ne=f.lanes[0]?.plotTop??0;_.append(it(r,"line",{class:"cv-chart-crossline",x1:G,x2:G,y1:ne,y2:f.axisY}));const ce=[];for(const Ae of f.lanes){const z=d.series[Ae.index]?.values[I]??null;if(z!=null){const H=it(r,"circle",{class:"cv-chart-focus",cx:G,cy:Bt(Yw(Ae,z)),r:4.5});H.style.fill=Ae.color,_.append(H)}const j=A(r,"span",{class:"cv-chart-key","aria-hidden":"true"});j.style.setProperty("--cv-key",Ae.color),ce.push(A(r,"dt",{},j,Ae.column),A(r,"dd",{"data-value":Ae.column,text:ms(z,Ae.kind)}))}_.style.display="",_.dataset.index=String(u),_.dataset.time=String(R),b.dataset.focus=String(u);const ee=d.failures.find(Ae=>Ae.time===R),xe=d.rowCounts[I]??1;g.replaceChildren(...[A(r,"time",{datetime:new Date(R).toISOString(),text:uA(R,d.daily)}),ee?A(r,"p",{class:"cv-chart-readout-note","data-failure":ee.code,text:`No answer: ${ee.code}`}):null,xe>1?A(r,"p",{class:"cv-chart-readout-note","data-rows":xe,text:`${vi.format(xe)} transfers`}):null,A(r,"dl",{},...ce)].filter(Ae=>Ae!=null)),g.hidden=!1,we(G,ne)}function we(I,R){const G=w.getBoundingClientRect(),ne=v.getBoundingClientRect(),ce=G.width>0?G.width/f.width:1,ee=G.left-ne.left+I*ce,xe=I>(f.plotLeft+f.plotRight)/2;g.style.left=`${Math.round(xe?ee-12:ee+12)}px`,g.style.top=`${Math.round(G.top-ne.top+R*ce)}px`,g.dataset.side=xe?"left":"right"}const _e=I=>{const R=w.getBoundingClientRect();return R.width>0?(I-R.left)*f.width/R.width:Number.NaN},Ge=I=>a.start+bA(d.times,fu(f,I));b.addEventListener("pointermove",I=>{const R=_e(I.clientX);Number.isFinite(R)&&(c&&(c.to=R,J()),u=Ge(R),se())}),b.addEventListener("pointerdown",I=>{if(I.button!==0)return;const R=_e(I.clientX);if(Number.isFinite(R)){I.preventDefault(),b.focus({preventScroll:!0}),c={from:R,to:R,pointer:I.pointerId};try{b.setPointerCapture(I.pointerId)}catch{}}});const F=I=>{if(!c)return;const{from:R,to:G,pointer:ne}=c;c=null;try{b.releasePointerCapture(ne)}catch{}if(J(),!I||Math.abs(G-R)<$p)return;const ce=wA(t.times,fu(f,R),fu(f,G));!ce||ce.start===a.start&&ce.end===a.end||(a=ce,u=Ge(G),O())};b.addEventListener("pointerup",()=>F(!0)),b.addEventListener("pointercancel",()=>F(!1)),b.addEventListener("pointerleave",()=>{c||(u=null,se())}),b.addEventListener("keydown",I=>{let R;if(I.key==="ArrowRight")R=u==null?a.start:Math.min(a.end,u+1);else if(I.key==="ArrowLeft")R=u==null?a.end:Math.max(a.start,u-1);else if(I.key==="Home")R=a.start;else if(I.key==="End")R=a.end;else if(I.key==="Escape"){if(u==null&&!c)return;c&&F(!1),R=null}else return;I.preventDefault(),u=R,se()}),y.addEventListener("click",()=>{a=o,u=null,O(),b.focus({preventScroll:!0})});const B=()=>{const I=Math.round(b.clientWidth);return I>0?Math.max(qC,I):null},W=()=>{const I=B();I==null||I===l||(l=I,O())};l=B()??rc,O();const Q=r.defaultView?.ResizeObserver,K=Q?new Q(()=>W()):null;return K?.observe(b),{root:D,get layout(){return f},refit:W,destroy(){K?.disconnect()}}}const TA="chain-insights.transfers.v1",CA="graph_expand",AA="2015-01-01";function IA(e,t,n,r){return{network:e,from:t,to:n,day:r}}function NA(e,t){const n=typeof e.first_seen_timestamp=="number"&&e.first_seen_timestamp>0?uu(e.first_seen_timestamp):null,r=typeof e.last_seen_timestamp=="number"&&e.last_seen_timestamp>0?uu(e.last_seen_timestamp):uu(t);return{first:n,last:n&&r<n?n:r}}function Zo(e,t){return e<=(t??AA)}function RA(e){if(!e)return"no answer";const t=Co(e);return e.isError?t||"the server refused the read":/query_timeout|topology_busy/.test(t)?t:Xw(e.structuredContent)?null:t||"the answer held no transfers"}function Xw(e){const t=e;if(!t||t.schema!==TA||!Array.isArray(t.transfers)||typeof t.from!="string"||typeof t.to!="string"||!Xf(t.day))return null;const n=[];for(const r of t.transfers){if(!r||typeof r!="object")continue;const i=r;if(typeof i.tx_id!="string")continue;const o=Qt(i.block_timestamp);n.push({tx_id:i.tx_id,block_timestamp:o,amount:typeof i.amount=="string"?i.amount:typeof i.amount=="number"?String(i.amount):null,asset_symbol:typeof i.asset_symbol=="string"&&i.asset_symbol?i.asset_symbol:null,amount_usd:Qt(i.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 LA(e){return[...e].sort((t,n)=>(n.block_timestamp??0)-(t.block_timestamp??0)||t.tx_id.localeCompare(n.tx_id))}function zA(e){if(e==null)return"—";const t=e.trim().match(/^(-?)(\d+)(?:\.(\d+))?$/);if(!t)return e;const[,n="",r="0",i=""]=t,o=i.replace(/0+$/,"");return`${n}${r.replace(/\B(?=(\d{3})+(?!\d))/g,",")}${o?`.${o}`:""}`}function PA(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 OA(e){return e==null?"—":`${new Date(Yf(e)).toISOString().slice(11,19)} UTC`}function hu(e){return new Intl.DateTimeFormat("en-GB",{dateStyle:"medium",timeZone:"UTC"}).format(new Date(`${e}T00:00:00Z`))}function DA(e,t){const n=t.now??Date.now,r=A(e,"strong",{"data-link-title":"",text:"Transfers"}),i=A(e,"button",{type:"button",class:"cv-button cv-icon","data-link-close":"","aria-label":"Close the transfers",text:"×"}),o=A(e,"p",{class:"cv-link-pair","data-link-pair":""}),s=A(e,"p",{class:"cv-link-day","data-link-day":""}),a=A(e,"div",{class:"cv-link-body","data-link-body":"",role:"status","aria-live":"polite"}),u=A(e,"button",{type:"button",class:"cv-button","data-link-earlier":"",text:"Earlier day"}),c=A(e,"section",{class:"cv-linkpanel cv-linkpanel-embedded","data-link-panel":"","aria-label":"Transfers of the selected link",hidden:!0},A(e,"header",{class:"cv-link-head"},r,null),o,s,a,u);let l=null,d=0;function f(){if(!l){c.hidden=!0;return}c.hidden=!1,o.replaceChildren(A(e,"code",{"data-link-from":"",text:l.from})," → ",A(e,"code",{"data-link-to":"",text:l.to})),s.textContent=`${hu(l.day)} (UTC)`,u.disabled=l.status==="loading"||Zo(l.day,l.firstDay);const w=Zo(l.day,l.firstDay)?null:mp(l.day);u.setAttribute("aria-label",w?`Earlier day: show the transfers of ${hu(w)}`:"Earlier day: this is the first day the link was seen"),l.status==="loading"?a.replaceChildren(A(e,"p",{class:"cv-muted",text:`Loading the transfers of ${hu(l.day)}…`})):l.status==="error"?a.replaceChildren(A(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(A(e,"p",{class:"cv-muted","data-link-empty":"",text:"No transfers between these two addresses on this day."})):(a.replaceChildren(A(e,"ol",{class:"cv-transfers"},...l.transfers.map(g=>MA(e,g,t.host)))),l.truncated&&a.append(A(e,"p",{class:"cv-muted","data-link-truncated":"",text:`${l.transfers.length} transfers shown. This day holds more.`}))),l.status!=="loading"&&Zo(l.day,l.firstDay)&&l.firstDay&&a.append(A(e,"p",{class:"cv-muted","data-link-first":"",text:"This is the first day the link was seen."}))}async function h(w){const g=++d,b=l;b.day=w,b.status="loading",b.error=null,f(),t.onLayout?.();let v=null;try{v=await t.host.callServerTool({name:CA,arguments:IA(t.network,b.from,b.to,w)})}catch(_){v={isError:!0,content:[{type:"text",text:_ instanceof Error?_.message:String(_)}]}}if(g!==d||l!==b)return b;const k=RA(v);if(k)b.status="error",b.transfers=[],b.error=k.length>300?`${k.slice(0,299)}…`:k;else{const _=Xw(v.structuredContent);b.status="ready",b.transfers=LA(_.transfers),b.truncated=_.truncated}return f(),t.onLayout?.(),b}const p=()=>y.close(),m=()=>{y.earlier()};i.addEventListener("click",p),u.addEventListener("click",m);const y={element:c,open(w){const g=NA(w,n());return l={from:w.from,to:w.to,day:g.last,firstDay:g.first,status:"loading",transfers:[],truncated:!1,error:null},h(g.last)},async earlier(){return!l||l.status==="loading"||Zo(l.day,l.firstDay)?null:h(mp(l.day))},close(){d++,l=null,f(),t.onLayout?.()},state:()=>l?{...l,transfers:[...l.transfers]}:null,destroy(){d++,i.removeEventListener("click",p),u.removeEventListener("click",m)}};return y}function MA(e,t,n){const r=Aw(t.tx_id),i=n.openLink,o=r&&i?A(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:mi(t.tx_id)}):A(e,"code",{title:t.tx_id,text:mi(t.tx_id)});return r&&i&&o.addEventListener("click",()=>{i.call(n,{url:r}).catch(()=>{})}),A(e,"li",{class:"cv-transfer","data-tx":t.tx_id},A(e,"span",{class:"cv-transfer-time",text:OA(t.block_timestamp)}),A(e,"span",{class:"cv-transfer-amount",text:`${zA(t.amount)}${t.asset_symbol?` ${t.asset_symbol}`:""}`}),A(e,"span",{class:"cv-transfer-usd",text:t.amount_usd==null?"— USD":PA(t.amount_usd)}),o)}const FA="graph_expand",Bo="too busy to expand",Qw=640,UA=300,pu=.45,GA="Full screen shows the whole graph",jA="Open in browser",mu="The host did not open the link.",ZA="If nothing opened, copy this link into your browser:",Ip=400,gu="expanded",e_=5e3,BA="Click an address for its details. Double-click it to load its senders and receivers, and again to fold them back. Click a link to list its transfers.",oc=new Intl.NumberFormat("en-US");function Np(e){const t=e.remaining;if(!t||typeof t!="object")return null;const n=Number(t.senders),r=Number(t.receivers);return!Number.isFinite(n)||!Number.isFinite(r)?null:{senders:Math.max(0,n),receivers:Math.max(0,r)}}function HA(e){if(!e||e.senders+e.receivers<=0)return null;const t=(n,r)=>`${oc.format(n)} more ${r}${n===1?"":"s"}`;return`${t(e.senders,"sender")}, ${t(e.receivers,"receiver")} not loaded`}function VA(e,t){return`Not loaded: ${oc.format(e)} ${e===1?"link":"links"} of ${t} would take the picture past ${oc.format(e_)} addresses. Fold another address to make room.`}const Rp=e=>!!(e&&(e.truncated||e.remaining&&e.remaining.senders+e.remaining.receivers>0));let qA=0;const WA=[["scam","Scam"],["sanctioned","Sanctioned"],["exchange","Exchange"],["victim","Victim"],["pool","Pool"],["other","Other"]];function th(e){return typeof e=="string"&&/^http:\/\/(?:127\.0\.0\.1|localhost):\d+(?:[/?#]|$)/.test(e)}function KA(e){return!e.browser&&!!e.host.openLink&&th(e.viewUrl)}function JA(e,t,n){return{network:e,address:t,in_offset:n?.in_offset??0,out_offset:n?.out_offset??0}}function YA(e){const t=Co(e);return e?e.isError?t||"the server refused the expansion":/query_timeout|topology_busy/.test(t)?t:Hf(e.structuredContent)?null:t||"the answer held no money flows":"no answer"}function XA(e,t,n,r=Qw,i=UA){if(!e||t<=0)return{height:r,fits:!0};const o=Math.max(1,e.x2-e.x1),s=Math.max(1,e.y2-e.y1),a=Math.max(pu,Math.min(1,(t-pi*2)/o)),u=Math.ceil(n+s*a+pi*2),c=Math.min(r,Math.max(i,u));return up(e,t,c-n)>=pu?{height:c,fits:!0}:{height:r,fits:up(e,t,r-n)>=pu}}function QA(e){return/query_timeout|topology_busy|timed? ?out/i.test(e)}function eI(e){const t=e.split(`
|
|
110
|
+
`)[0].trim();return t.length>200?`${t.slice(0,199)}…`:t}function tI(e,t){return`investigator expanded ${e}: ${t} new addresses`}function nI(e,t){const n=e.nodes.find(r=>r.address.toLowerCase()===t.toLowerCase());return n&&To({role:n.role??null,labels:n.labels??[]})||"Other"}function t_(e,t,n){const r=e.ownerDocument,i=t.network??"robinhood",o=t.center.toLowerCase(),s=()=>new Map(t.cursor?[[o,{cursor:t.cursor,truncated:!!t.truncated,remaining:Np(t)}]]:[]);let a=s();const u=new Set,c=new Set;let l=[];const d=new Set;let f=null,h=null;const p=n.now??Date.now,m=n.title??"Money flow graph",y=A(r,"p",{class:"cv-status",role:"status","aria-live":"polite",text:BA}),w=A(r,"ul",{class:"cv-roles","aria-label":"Address roles"}),g=A(r,"div",{class:"cv-canvas","data-graph":""}),b=A(r,"div",{class:"cv-detail","aria-label":"Selection"},A(r,"strong",{"data-selection-title":""}),A(r,"code",{"data-selection-identity":""}),A(r,"div",{class:"cv-detail-meta","data-selection-meta":""})),v=A(r,"strong",{"data-side-title":"",text:"Details"}),k=A(r,"button",{type:"button",class:"cv-button cv-icon","data-side-close":"","aria-label":"Close the details",text:"×"}),_=A(r,"button",{type:"button",class:"cv-button","data-toggle-expand":"",hidden:!0,text:"Expand"}),$=A(r,"button",{type:"button",class:"cv-button","data-more":"",hidden:!0,text:"More flows"}),D=A(r,"p",{class:"cv-remaining cv-muted","data-remaining":"",hidden:!0}),M=DA(r,{host:n.host,network:i,now:n.now,embedded:!0,onLayout:()=>Ve()}),O=A(r,"aside",{class:"cv-side","data-side-panel":"","aria-label":"Details of the selection",hidden:!0},A(r,"header",{class:"cv-side-head"},v,k),b,D,A(r,"div",{class:"cv-side-actions"},_,$),M.element),J=A(r,"button",{type:"button",class:"cv-button","data-fullscreen":"",hidden:!0,"aria-label":"Open full screen",text:"Full screen"}),se=A(r,"button",{type:"button",class:"cv-button","data-reset":"","aria-label":"Reset the graph to the first answer",text:"Reset"}),we=A(r,"span",{class:"cv-hint","data-fullscreen-hint":"",hidden:!0,text:GA}),_e=A(r,"button",{type:"button",class:"cv-button","data-open-browser":"",hidden:!KA(n),"aria-label":"Open the graph in your browser",title:"Open the graph in your browser",text:jA}),Ge=A(r,"div",{class:"cv-actions"},A(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"out","aria-label":"Zoom out",text:"−"}),A(r,"button",{type:"button",class:"cv-button cv-icon","data-zoom":"in","aria-label":"Zoom in",text:"+"}),A(r,"button",{type:"button",class:"cv-button","data-zoom":"fit","aria-label":"Fit the graph",text:"Fit"}),se,we,J,_e),F=A(r,"span",{class:"cv-muted","data-subtitle":""}),B=`cv-addresses-${++qA}`,W=A(r,"div",{class:"cv-visually-hidden",role:"listbox",tabindex:"0",id:B,"data-address-list":"","aria-label":"Drawn addresses. Down and Up move, Enter shows the details, Shift+Enter expands or folds."});let Q=[],K=-1;const I=A(r,"section",{class:"cv-flows cia-graph-surface","data-view":"flows","aria-label":`${m} of ${o}`},A(r,"header",{class:"cv-flows-head"},A(r,"div",{class:"cv-title"},A(r,"strong",{text:m}),F),n.toggle??null,Ge),w,n.note?A(r,"p",{class:"cv-note",role:"note","data-left-out":"",text:n.note}):null,A(r,"div",{class:"cv-body"},W,g,O),y);e.replaceChildren(I);function R(){const U=fe.model(),he=U.truncated?" · more flows than shown":"";F.textContent=`${o} · ${nI(t,o)} · ${i} · ${U.nodes.length} addresses${he}`;const be=new Set(U.nodes.map(Ne=>Ne.role??"other"));w.replaceChildren(...WA.filter(([Ne])=>be.has(Ne)).map(([Ne,Ye])=>{const Nt=A(r,"i",{"aria-hidden":"true"});return Nt.style.background=`var(--cia-graph-role-${Ne})`,A(r,"li",{"data-role":Ne},Nt,Ye)})),G()}function G(){const U=fe.model().nodes,he=Q[K]??null;Q=U.map(Ne=>Ne.address.toLowerCase()),W.replaceChildren(...U.map((Ne,Ye)=>A(r,"div",{role:"option",id:`${B}-${Ye}`,"data-list-address":Q[Ye],"aria-selected":"false",text:`${Ne.address} ${To({role:Ne.role??null,labels:Ne.labels??[]})||"Other"}`})));const be=he?Q.indexOf(he):-1;K=be>=0?be:Q.length?Math.min(Math.max(K,-1),Q.length-1):-1,ne()}function ne(){for(const he of W.children)he.setAttribute("aria-selected",String(he.id===`${B}-${K}`));K>=0?W.setAttribute("aria-activedescendant",`${B}-${K}`):W.removeAttribute("aria-activedescendant");const U=r.activeElement===W;fe.highlight(U?Q[K]??null:null)}function ce(U){return U?fe.model().nodes.find(he=>he.id===U)?.address.toLowerCase()??null:null}const ee=U=>{const he=U.target,be=U.key==="Enter"||U.key===" ",Ne=he?.closest?.("[data-node-id]");if(be&&U.shiftKey&&Ne){U.preventDefault();const Ye=ce(Ne.dataset.nodeId);Ye&&ve(Ye)}};g.addEventListener("keydown",ee,!0);function xe(U){Q.length&&(K=Math.max(0,Math.min(Q.length-1,U)),ne())}const Ae=()=>{K<0&&Q.length&&(K=0),ne()},z=()=>fe.highlight(null),j=U=>{const he=Q[K];switch(U.key){case"ArrowDown":U.preventDefault(),xe(K+1);return;case"ArrowUp":U.preventDefault(),xe(K-1);return;case"Home":U.preventDefault(),xe(0);return;case"End":U.preventDefault(),xe(Q.length-1);return;case"Escape":nn();return;case"Enter":case" ":if(U.preventDefault(),!he)return;U.shiftKey?ve(he):fe.select(he);return}};W.addEventListener("focus",Ae),W.addEventListener("blur",z),W.addEventListener("keydown",j);function H(){const U=h;if(!U){_.hidden=!0,$.hidden=!0,D.hidden=!0;return}const he=d.has(U),be=he?HA(a.get(U)?.remaining??null):null;D.hidden=!be,D.textContent=be??"",_.hidden=!1,_.disabled=u.has(U)||c.has(U),_.textContent=u.has(U)?"Too busy to expand":he?"Collapse":"Expand",_.setAttribute("aria-label",`${_.textContent} ${U}`),$.hidden=!(he&&Rp(a.get(U)))}function Y(U){const he=O.hidden;O.hidden=U.kind==null,U.kind==="node"&&U.node?(h=U.node.address.toLowerCase(),v.textContent="Address details",M.close()):(h=null,U.kind==="edge"?v.textContent="Link details":M.close()),H(),he!==O.hidden&&Ve()}let le=null;function ie(){le&&clearTimeout(le),le=null}function $e(U){const he=U.source==="pointer"&&U.kind==="node"&&U.node,be=U.source!=="program"&&U.kind==="edge"&&U.edge;if(ie(),he){const Ne=U.node.address.toLowerCase(),Ye=p();f&&f.address===Ne&&Ye-f.at<=Ip?(f=null,nn(),ve(Ne)):(f={address:Ne,at:Ye},le=setTimeout(()=>{le=null,Y(U)},Ip));return}U.kind!=="node"&&(f=null),Y(U),be&&M.open(U.edge)}const Ie=n.height??Qw,de=`${m} of ${o}: senders on the left, receivers on the right. Select an address for its details; double-click it, or press Shift+Enter, to load its senders and receivers, and again to fold them back. Select a link to list its transfers.`;function ze(){return lC(g,t,{layout:"tree",width:n.width??720,height:Ie,now:n.now,controls:Ge,selectionRoot:b,onSelect:$e,openLink:U=>{n.host.openLink?.({url:U}).catch(()=>{y.textContent=mu})},label:de})}let fe=ze();R();let Je=n.displayMode??"inline",He=n.availableDisplayModes??[];const pt=()=>!n.browser&&!!n.host.requestDisplayMode&&(He.length===0||He.includes("fullscreen"));function Ve(){if(Je==="fullscreen"){I.style.removeProperty("height"),we.hidden=!0;return}const U=g.clientWidth||n.width||720,he=Math.max(0,I.offsetHeight-g.offsetHeight)||140,{height:be,fits:Ne}=XA(fe.contentBounds(),U,he);I.style.height=`${be}px`,we.hidden=Ne||!pt(),I.dataset.fits=String(Ne),fe.fit()}async function C(U){try{await n.host.updateModelContext?.({content:[{type:"text",text:U}]})}catch{}}async function P(U,he=!1){const be=U.toLowerCase();if(u.has(be))return y.textContent=`${be} is ${Bo}.`,{added:[],refused:Bo};if(c.has(be))return{added:[],refused:null};const Ne=a.get(be);if(Ne&&!Rp(Ne))return y.textContent=`Every recent flow of ${be} is drawn.`,{added:[],refused:null};c.add(be),H(),y.textContent=`Loading the flows of ${be}…`;let Ye=null;try{Ye=await n.host.callServerTool({name:FA,arguments:JA(i,be,he||Ne?Ne?.cursor:null)})}catch(kt){Ye={isError:!0,content:[{type:"text",text:kt instanceof Error?kt.message:String(kt)}]}}finally{c.delete(be)}const Nt=YA(Ye);if(Nt)return QA(Nt)?(u.add(be),fe.markNode(be,Bo),y.textContent=`${be} is ${Bo}. The drawing is kept.`):y.textContent=`${be} could not be expanded: ${eI(Nt)}. The drawing is kept; try again.`,H(),{added:[],refused:Nt};const qe=Ye.structuredContent,Xa=fe.model(),zn=new Set(Xa.nodes.map(kt=>kt.address.toLowerCase())),Qa=new Set;for(const kt of qe.nodes)zn.has(kt.address.toLowerCase())||Qa.add(kt.address.toLowerCase());for(const kt of qe.edges)for(const Io of[kt.from,kt.to])zn.has(Io.toLowerCase())||Qa.add(Io.toLowerCase());if(zn.size+Qa.size>e_){const kt=new Set(Xa.edges.map(Pn=>`${Pn.from.toLowerCase()}->${Pn.to.toLowerCase()}`)),Io=new Set(qe.edges.map(Pn=>`${Pn.from.toLowerCase()}->${Pn.to.toLowerCase()}`).filter(Pn=>!kt.has(Pn))).size,ch=VA(Io,be);return y.textContent=ch,H(),{added:[],refused:ch}}const Ao=fe.merge(qe,be);return l.push({address:be,page:qe}),d.add(be),fe.flagNode(be,gu,!0),a.set(be,{cursor:qe.cursor??null,truncated:!!qe.truncated,remaining:Np(qe)}),R(),Ve(),H(),y.textContent=`${Ao.length} new ${Ao.length===1?"address":"addresses"} linked to ${be}. Double-click it again to fold them back.`,await C(tI(be,Ao.length)),{added:Ao,refused:null}}function re(U){const he=U.toLowerCase();if(!d.has(he))return{removed:0};const be=fe.model().nodes.length;d.delete(he),a.delete(he);const Ne=l.filter(qe=>qe.address!==he),Ye=[];fe.batch(()=>{fe.flagNode(he,gu,!1),fe.update(t);for(const qe of Ne)fe.model().nodes.some(zn=>zn.address.toLowerCase()===qe.address)?(fe.merge(qe.page,qe.address),Ye.push(qe)):Ye.some(zn=>zn.address===qe.address)||(fe.flagNode(qe.address,gu,!1),d.delete(qe.address),a.delete(qe.address))}),l=Ye;const Nt=Math.max(0,be-fe.model().nodes.length);return h&&!fe.model().nodes.some(qe=>qe.address.toLowerCase()===h)&&(O.hidden=!0,h=null),R(),Ve(),H(),y.textContent=`Folded ${he} back: ${Nt} ${Nt===1?"address":"addresses"} removed.`,C(`investigator collapsed ${he}: ${Nt} addresses removed`),{removed:Nt}}async function ve(U){d.has(U)?re(U):await P(U)}function pe(){ie(),fe.destroy(),l=[],d.clear(),u.clear(),c.clear(),a=s(),f=null,h=null,M.close(),O.hidden=!0,fe=ze(),R(),Ve(),H(),y.textContent="Back to the first answer."}function rt(U,he){U&&(Je=U),he&&(He=he),I.dataset.displayMode=Je,J.hidden=!pt(),J.textContent=Je==="fullscreen"?"Exit full screen":"Full screen",J.setAttribute("aria-label",Je==="fullscreen"?"Back to the inline view":"Open full screen"),Ve()}rt(Je);const It=async()=>{const U=Je==="fullscreen"?"inline":"fullscreen";try{const he=await n.host.requestDisplayMode?.({mode:U});rt(he?.mode??U)}catch{y.textContent="The host did not change the display mode."}},jt=(U,he)=>{y.replaceChildren(A(r,"span",{text:`${U} `}),A(r,"code",{class:"cv-view-link","data-view-link":"",text:he}))},Vr=async()=>{const U=n.viewUrl;if(!(!th(U)||!n.host.openLink)){jt(ZA,U);try{(await n.host.openLink({url:U}))?.isError===!0&&jt(mu,U)}catch{jt(mu,U)}}},Ln=()=>pe();function nn(){ie();const U=!O.hidden;fe.select(null),M.close(),O.hidden=!0,h=null,H(),U&&Ve()}const Zt=()=>nn(),Kt=()=>{h&&ve(h)},uh=()=>{h&&P(h,!0)};return J.addEventListener("click",It),_e.addEventListener("click",Vr),se.addEventListener("click",Ln),k.addEventListener("click",Zt),_.addEventListener("click",Kt),$.addEventListener("click",uh),{root:I,get graph(){return fe},expand:U=>P(U),collapse:re,reset:pe,expanded:()=>[...d],linkPanel:M,openLink(U,he){const be=fe.model().edges.find(Ne=>Ne.from===U.toLowerCase()&&Ne.to===he.toLowerCase());return be?(fe.select(be.id),M.open(be)):Promise.resolve(null)},setTheme(U){fe.setTheme(U)},setDisplayMode:rt,refit:Ve,destroy(){ie(),g.removeEventListener("keydown",ee,!0),W.removeEventListener("focus",Ae),W.removeEventListener("blur",z),W.removeEventListener("keydown",j),J.removeEventListener("click",It),_e.removeEventListener("click",Vr),se.removeEventListener("click",Ln),k.removeEventListener("click",Zt),_.removeEventListener("click",Kt),$.removeEventListener("click",uh),M.destroy(),fe.destroy()}}}function sc(e){return{kind:e,flows:()=>[],setTheme(){},setDisplayMode(){},refit(){},destroy(){}}}function rI(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 n_=e=>({host:e.host,availableDisplayModes:e.availableDisplayModes,displayMode:e.displayMode,now:e.now,width:e.width,height:e.height,viewUrl:e.browser?null:e.viewUrl??null,browser:e.browser===!0});function iI(e){return typeof e?.query=="string"&&e.query?e.query:null}function oI(e,t,n){const r=Array.isArray(e?.queries)?e.queries:[],i=s=>{const a=s?.query;return typeof a=="string"&&a?a:null},o=r.find(s=>s?.id===t);return i(o||r[n])}function sI(e,t){const n=e.structuredContent;if(!t||!n?.facts?.query)return e;const r=NC(Va(n),t);return r?{...e,structuredContent:{...n,facts:{...n.facts,query:{...n.facts.query,results:r}}}}:e}function aI(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 ${n.format(Nw)} addresses. The table has the rows.`}function uI(e,t,n){const r=[];let i="picture";const o=s=>{for(const a of s.querySelectorAll("[data-show]"))a.setAttribute("aria-pressed",String(a.dataset.show===i))};return{make(){const s=A(e,"button",{type:"button",class:"cv-toggle-button","data-show":"picture",text:t}),a=A(e,"button",{type:"button",class:"cv-toggle-button","data-show":"table",text:"Table"});s.addEventListener("click",()=>n("picture")),a.addEventListener("click",()=>n("table"));const u=A(e,"div",{class:"cv-toggle",role:"group","aria-label":"Show the rows as"},s,a);return r.push(u),o(u),u},set(s){i=s,r.forEach(o)}}}function cI(e,t){const n=t?.facts?.subject;return{content:[],structuredContent:{schema:Jf,tool:"graph_query",facts:{...n?{subject:n}:{},query:{results:e,count:e.length,truncated:!1}}}}}function lI(e){const t=Ow(e.structuredContent);if(t)return{model:t.model,table:cI(t.rows,e.structuredContent)};const n=Qf(Va(e.structuredContent));return n?{model:n,table:e}:null}function r_(e,t,n,r=null){const i=e.ownerDocument,o=sI(t,r),s=Uw(o),a=s==="chart"?lI(o):null;if(s!=="graph"&&!a)return s==="table"?Sp(e,o):yi(e,o),sc(s==="table"?"table":"text");const u=o.structuredContent,c=Va(u),l=a?.table??t,d=A(i,"div",{class:"cv-face","data-face":"picture"}),f=A(i,"div",{class:"cv-face","data-face":"table",hidden:!0});e.replaceChildren(d,f);const h=uI(i,s==="graph"?"Graph":"Chart",g=>w(g));let p=null,m=null,y=!1;if(s==="graph"){const g=PC(c,pC(u),Dw(r)?.address);p=t_(d,g.view,{...n_(n),title:"Money flow graph",toggle:h.make(),note:aI(g.rowsLeftOut,g.rowsTotal)})}else m=$A(d,a.model,{toggle:h.make()});function w(g){d.hidden=g!=="picture",f.hidden=g!=="table",g==="table"&&!y&&(y=!0,Sp(f,l,{toggle:h.make()})),h.set(g),g==="picture"&&(p?.refit(),m?.refit())}return{kind:s,flows:()=>p?[p]:[],setTheme(g){p?.setTheme(g)},setDisplayMode(g,b){p?.setDisplayMode(g,b)},refit(){d.hidden||(p?.refit(),m?.refit())},destroy(){p?.destroy(),m?.destroy()}}}function dI(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:Jf,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 fI(e,t,n){const r=e.ownerDocument,i=Mw(t.structuredContent),o=i.map((p,m)=>A(r,"button",{type:"button",role:"tab",class:"cv-tab",id:`cv-tab-${m}`,"data-tab":p.id,"aria-controls":`cv-panel-${m}`,"aria-selected":"false",tabindex:-1,text:p.ok?p.id:`${p.id} (failed)`})),s=i.map((p,m)=>A(r,"div",{class:"cv-tabpanel",role:"tabpanel",id:`cv-panel-${m}`,"aria-labelledby":`cv-tab-${m}`,hidden:!0})),a=A(r,"div",{class:"cv-tabs",role:"tablist","aria-label":"Queries of the batch"},...o);e.replaceChildren(a,...s);const u=i.map(()=>null);let c=n.displayMode,l=n.availableDisplayModes,d=-1;const f=()=>e.style.setProperty("--cv-tabs-h",`${a.offsetHeight}px`);function h(p){const m=i[p],y=s[p];if(!m||!y)return;d=p,o.forEach((g,b)=>{g.setAttribute("aria-selected",String(b===p)),g.tabIndex=b===p?0:-1}),s.forEach((g,b)=>{g.hidden=b!==p});const w=u[p];if(w)w.refit();else{const g=m.query??oI(n.toolInput,m.id,p),b=r_(y,dI(m,t.structuredContent),{...n,displayMode:c,availableDisplayModes:l},g);u[p]=b,y.dataset.view=b.kind}f()}return o.forEach((p,m)=>{p.addEventListener("click",()=>h(m)),p.addEventListener("keydown",y=>{const w=o.length-1,g=y.key==="ArrowRight"?m===w?0:m+1:y.key==="ArrowLeft"?m===0?w:m-1:y.key==="Home"?0:y.key==="End"?w:null;g!=null&&(y.preventDefault(),h(g),o[g]?.focus())})}),h(0),{kind:"batch",flows:()=>u.flatMap(p=>p?.flows()??[]),setTheme(p){for(const m of u)m?.setTheme(p)},setDisplayMode(p,m){p&&(c=p),m&&(l=m);for(const y of u)y?.setDisplayMode(p,m);f()},refit(){d>=0&&u[d]?.refit()},destroy(){for(const p of u)p?.destroy()}}}function hI(e){const t=e?.structuredContent?.view_url;return th(t)?t:null}function i_(e,t,n){const r={...n,viewUrl:n.viewUrl??hI(t)},i=Uw(t);if(i==="flows"){const o=t_(e,t.structuredContent,n_(r));return rI("flows",()=>o)}return i==="graph"||i==="chart"||i==="table"?r_(e,t,r,iI(r.toolInput)):i==="batch"?fI(e,t,r):i==="balance"?(HC(e,t),sc("balance")):(yi(e,t),sc("text"))}function pI(e){return e==="light"||e==="dark"}function mI(e,t=()=>!1){return pI(e?.theme)?e.theme:t()?"dark":"light"}function yu(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 ys(e,t,n={}){const r=e.documentElement,i=mI(t,n.prefersDark);r.setAttribute("data-theme",i),r.style.colorScheme=i;const o=t?.styles?.variables;o&&n.applyVariables&&n.applyVariables(o,r);const s=t?.styles?.css?.fonts;return s&&n.applyFonts&&n.applyFonts(s),i}function gI(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ho={exports:{}},Lp;function yI(){if(Lp)return Ho.exports;Lp=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(k,_,$){return Function.prototype.apply.call(k,_,$)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(k){return Object.getOwnPropertyNames(k).concat(Object.getOwnPropertySymbols(k))}:n=function(k){return Object.getOwnPropertyNames(k)};function r(v){console&&console.warn&&console.warn(v)}var i=Number.isNaN||function(k){return k!==k};function o(){o.init.call(this)}Ho.exports=o,Ho.exports.once=w,o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(v){if(typeof v!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof v)}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(v){if(typeof v!="number"||v<0||i(v))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+v+".");s=v}}),o.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(k){if(typeof k!="number"||k<0||i(k))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+k+".");return this._maxListeners=k,this};function u(v){return v._maxListeners===void 0?o.defaultMaxListeners:v._maxListeners}o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(k){for(var _=[],$=1;$<arguments.length;$++)_.push(arguments[$]);var D=k==="error",M=this._events;if(M!==void 0)D=D&&M.error===void 0;else if(!D)return!1;if(D){var O;if(_.length>0&&(O=_[0]),O instanceof Error)throw O;var J=new Error("Unhandled error."+(O?" ("+O.message+")":""));throw J.context=O,J}var se=M[k];if(se===void 0)return!1;if(typeof se=="function")t(se,this,_);else for(var we=se.length,_e=p(se,we),$=0;$<we;++$)t(_e[$],this,_);return!0};function c(v,k,_,$){var D,M,O;if(a(_),M=v._events,M===void 0?(M=v._events=Object.create(null),v._eventsCount=0):(M.newListener!==void 0&&(v.emit("newListener",k,_.listener?_.listener:_),M=v._events),O=M[k]),O===void 0)O=M[k]=_,++v._eventsCount;else if(typeof O=="function"?O=M[k]=$?[_,O]:[O,_]:$?O.unshift(_):O.push(_),D=u(v),D>0&&O.length>D&&!O.warned){O.warned=!0;var J=new Error("Possible EventEmitter memory leak detected. "+O.length+" "+String(k)+" listeners added. Use emitter.setMaxListeners() to increase limit");J.name="MaxListenersExceededWarning",J.emitter=v,J.type=k,J.count=O.length,r(J)}return v}o.prototype.addListener=function(k,_){return c(this,k,_,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(k,_){return c(this,k,_,!0)};function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(v,k,_){var $={fired:!1,wrapFn:void 0,target:v,type:k,listener:_},D=l.bind($);return D.listener=_,$.wrapFn=D,D}o.prototype.once=function(k,_){return a(_),this.on(k,d(this,k,_)),this},o.prototype.prependOnceListener=function(k,_){return a(_),this.prependListener(k,d(this,k,_)),this},o.prototype.removeListener=function(k,_){var $,D,M,O,J;if(a(_),D=this._events,D===void 0)return this;if($=D[k],$===void 0)return this;if($===_||$.listener===_)--this._eventsCount===0?this._events=Object.create(null):(delete D[k],D.removeListener&&this.emit("removeListener",k,$.listener||_));else if(typeof $!="function"){for(M=-1,O=$.length-1;O>=0;O--)if($[O]===_||$[O].listener===_){J=$[O].listener,M=O;break}if(M<0)return this;M===0?$.shift():m($,M),$.length===1&&(D[k]=$[0]),D.removeListener!==void 0&&this.emit("removeListener",k,J||_)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(k){var _,$,D;if($=this._events,$===void 0)return this;if($.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):$[k]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete $[k]),this;if(arguments.length===0){var M=Object.keys($),O;for(D=0;D<M.length;++D)O=M[D],O!=="removeListener"&&this.removeAllListeners(O);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(_=$[k],typeof _=="function")this.removeListener(k,_);else if(_!==void 0)for(D=_.length-1;D>=0;D--)this.removeListener(k,_[D]);return this};function f(v,k,_){var $=v._events;if($===void 0)return[];var D=$[k];return D===void 0?[]:typeof D=="function"?_?[D.listener||D]:[D]:_?y(D):p(D,D.length)}o.prototype.listeners=function(k){return f(this,k,!0)},o.prototype.rawListeners=function(k){return f(this,k,!1)},o.listenerCount=function(v,k){return typeof v.listenerCount=="function"?v.listenerCount(k):h.call(v,k)},o.prototype.listenerCount=h;function h(v){var k=this._events;if(k!==void 0){var _=k[v];if(typeof _=="function")return 1;if(_!==void 0)return _.length}return 0}o.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function p(v,k){for(var _=new Array(k),$=0;$<k;++$)_[$]=v[$];return _}function m(v,k){for(;k+1<v.length;k++)v[k]=v[k+1];v.pop()}function y(v){for(var k=new Array(v.length),_=0;_<k.length;++_)k[_]=v[_].listener||v[_];return k}function w(v,k){return new Promise(function(_,$){function D(O){v.removeListener(k,M),$(O)}function M(){typeof v.removeListener=="function"&&v.removeListener("error",D),_([].slice.call(arguments))}b(v,k,M,{once:!0}),k!=="error"&&g(v,D,{once:!0})})}function g(v,k,_){typeof v.on=="function"&&b(v,"error",k,_)}function b(v,k,_,$){if(typeof v.on=="function")$.once?v.once(k,_):v.on(k,_);else if(typeof v.addEventListener=="function")v.addEventListener(k,function D(M){$.once&&v.removeEventListener(k,D),_(M)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof v)}return Ho.exports}var o_=yI();function vI(){const e=arguments[0];for(let t=1,n=arguments.length;t<n;t++)if(arguments[t])for(const r in arguments[t])e[r]=arguments[t][r];return e}let Xe=vI;typeof Object.assign=="function"&&(Xe=Object.assign);function Ot(e,t,n,r){const i=e._nodes.get(t);let o=null;return i&&(r==="mixed"?o=i.out&&i.out[n]||i.undirected&&i.undirected[n]:r==="directed"?o=i.out&&i.out[n]:o=i.undirected&&i.undirected[n]),o}function ot(e){return typeof e=="object"&&e!==null}function s_(e){let t;for(t in e)return!1;return!0}function Rt(e,t,n){Object.defineProperty(e,t,{enumerable:!1,configurable:!1,writable:!0,value:n})}function Ht(e,t,n){const r={enumerable:!0,configurable:!0};typeof n=="function"?r.get=n:(r.value=n,r.writable=!1),Object.defineProperty(e,t,r)}function zp(e){return!(!ot(e)||e.attributes&&!Array.isArray(e.attributes))}function bI(){let e=Math.floor(Math.random()*256)&255;return()=>e++}function un(){const e=arguments;let t=null,n=-1;return{[Symbol.iterator](){return this},next(){let r=null;do{if(t===null){if(n++,n>=e.length)return{done:!0};t=e[n][Symbol.iterator]()}if(r=t.next(),r.done){t=null;continue}break}while(!0);return r}}}function Zr(){return{[Symbol.iterator](){return this},next(){return{done:!0}}}}class nh extends Error{constructor(t){super(),this.name="GraphError",this.message=t}}class q extends nh{constructor(t){super(t),this.name="InvalidArgumentsGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,q.prototype.constructor)}}class Z extends nh{constructor(t){super(t),this.name="NotFoundGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,Z.prototype.constructor)}}class oe extends nh{constructor(t){super(t),this.name="UsageGraphError",typeof Error.captureStackTrace=="function"&&Error.captureStackTrace(this,oe.prototype.constructor)}}function a_(e,t){this.key=e,this.attributes=t,this.clear()}a_.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.undirectedDegree=0,this.undirectedLoops=0,this.directedLoops=0,this.in={},this.out={},this.undirected={}};function u_(e,t){this.key=e,this.attributes=t,this.clear()}u_.prototype.clear=function(){this.inDegree=0,this.outDegree=0,this.directedLoops=0,this.in={},this.out={}};function c_(e,t){this.key=e,this.attributes=t,this.clear()}c_.prototype.clear=function(){this.undirectedDegree=0,this.undirectedLoops=0,this.undirected={}};function Br(e,t,n,r,i){this.key=t,this.attributes=i,this.undirected=e,this.source=n,this.target=r}Br.prototype.attach=function(){let e="out",t="in";this.undirected&&(e=t="undirected");const n=this.source.key,r=this.target.key;this.source[e][r]=this,!(this.undirected&&n===r)&&(this.target[t][n]=this)};Br.prototype.attachMulti=function(){let e="out",t="in";const n=this.source.key,r=this.target.key;this.undirected&&(e=t="undirected");const i=this.source[e],o=i[r];if(typeof o>"u"){i[r]=this,this.undirected&&n===r||(this.target[t][n]=this);return}o.previous=this,this.next=o,i[r]=this,this.target[t][n]=this};Br.prototype.detach=function(){const e=this.source.key,t=this.target.key;let n="out",r="in";this.undirected&&(n=r="undirected"),delete this.source[n][t],delete this.target[r][e]};Br.prototype.detachMulti=function(){const e=this.source.key,t=this.target.key;let n="out",r="in";this.undirected&&(n=r="undirected"),this.previous===void 0?this.next===void 0?(delete this.source[n][t],delete this.target[r][e]):(this.next.previous=void 0,this.source[n][t]=this.next,this.target[r][e]=this.next):(this.previous.next=this.next,this.next!==void 0&&(this.next.previous=this.previous))};const l_=0,d_=1,wI=2,f_=3;function yn(e,t,n,r,i,o,s){let a,u,c,l;if(r=""+r,n===l_){if(a=e._nodes.get(r),!a)throw new Z(`Graph.${t}: could not find the "${r}" node in the graph.`);c=i,l=o}else if(n===f_){if(i=""+i,u=e._edges.get(i),!u)throw new Z(`Graph.${t}: could not find the "${i}" edge in the graph.`);const d=u.source.key,f=u.target.key;if(r===d)a=u.target;else if(r===f)a=u.source;else throw new Z(`Graph.${t}: the "${r}" node is not attached to the "${i}" edge (${d}, ${f}).`);c=o,l=s}else{if(u=e._edges.get(r),!u)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`);n===d_?a=u.source:a=u.target,c=i,l=o}return[a,c,l]}function _I(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);return s.attributes[a]}}function kI(e,t,n){e.prototype[t]=function(r,i){const[o]=yn(this,t,n,r,i);return o.attributes}}function SI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);return s.attributes.hasOwnProperty(a)}}function EI(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=yn(this,t,n,r,i,o,s);return a.attributes[u]=c,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:u}),this}}function xI(e,t,n){e.prototype[t]=function(r,i,o,s){const[a,u,c]=yn(this,t,n,r,i,o,s);if(typeof c!="function")throw new q(`Graph.${t}: updater should be a function.`);const l=a.attributes,d=c(l[u]);return l[u]=d,this.emit("nodeAttributesUpdated",{key:a.key,type:"set",attributes:a.attributes,name:u}),this}}function $I(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);return delete s.attributes[a],this.emit("nodeAttributesUpdated",{key:s.key,type:"remove",attributes:s.attributes,name:a}),this}}function TI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);if(!ot(a))throw new q(`Graph.${t}: provided attributes are not a plain object.`);return s.attributes=a,this.emit("nodeAttributesUpdated",{key:s.key,type:"replace",attributes:s.attributes}),this}}function CI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);if(!ot(a))throw new q(`Graph.${t}: provided attributes are not a plain object.`);return Xe(s.attributes,a),this.emit("nodeAttributesUpdated",{key:s.key,type:"merge",attributes:s.attributes,data:a}),this}}function AI(e,t,n){e.prototype[t]=function(r,i,o){const[s,a]=yn(this,t,n,r,i,o);if(typeof a!="function")throw new q(`Graph.${t}: provided updater is not a function.`);return s.attributes=a(s.attributes),this.emit("nodeAttributesUpdated",{key:s.key,type:"update",attributes:s.attributes}),this}}const II=[{name:e=>`get${e}Attribute`,attacher:_I},{name:e=>`get${e}Attributes`,attacher:kI},{name:e=>`has${e}Attribute`,attacher:SI},{name:e=>`set${e}Attribute`,attacher:EI},{name:e=>`update${e}Attribute`,attacher:xI},{name:e=>`remove${e}Attribute`,attacher:$I},{name:e=>`replace${e}Attributes`,attacher:TI},{name:e=>`merge${e}Attributes`,attacher:CI},{name:e=>`update${e}Attributes`,attacher:AI}];function NI(e){II.forEach(function({name:t,attacher:n}){n(e,t("Node"),l_),n(e,t("Source"),d_),n(e,t("Target"),wI),n(e,t("Opposite"),f_)})}function RI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ot(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes[i]}}function LI(e,t,n){e.prototype[t]=function(r){let i;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>1){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const o=""+r,s=""+arguments[1];if(i=Ot(this,o,s,n),!i)throw new Z(`Graph.${t}: could not find an edge for the given path ("${o}" - "${s}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,i=this._edges.get(r),!i)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return i.attributes}}function zI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ot(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return o.attributes.hasOwnProperty(i)}}function PI(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+r,u=""+i;if(i=arguments[2],o=arguments[3],s=Ot(this,a,u,n),!s)throw new Z(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,s=this._edges.get(r),!s)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return s.attributes[i]=o,this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function OI(e,t,n){e.prototype[t]=function(r,i,o){let s;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>3){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const a=""+r,u=""+i;if(i=arguments[2],o=arguments[3],s=Ot(this,a,u,n),!s)throw new Z(`Graph.${t}: could not find an edge for the given path ("${a}" - "${u}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,s=this._edges.get(r),!s)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof o!="function")throw new q(`Graph.${t}: updater should be a function.`);return s.attributes[i]=o(s.attributes[i]),this.emit("edgeAttributesUpdated",{key:s.key,type:"set",attributes:s.attributes,name:i}),this}}function DI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ot(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}return delete o.attributes[i],this.emit("edgeAttributesUpdated",{key:o.key,type:"remove",attributes:o.attributes,name:i}),this}}function MI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ot(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!ot(i))throw new q(`Graph.${t}: provided attributes are not a plain object.`);return o.attributes=i,this.emit("edgeAttributesUpdated",{key:o.key,type:"replace",attributes:o.attributes}),this}}function FI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ot(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(!ot(i))throw new q(`Graph.${t}: provided attributes are not a plain object.`);return Xe(o.attributes,i),this.emit("edgeAttributesUpdated",{key:o.key,type:"merge",attributes:o.attributes,data:i}),this}}function UI(e,t,n){e.prototype[t]=function(r,i){let o;if(this.type!=="mixed"&&n!=="mixed"&&n!==this.type)throw new oe(`Graph.${t}: cannot find this type of edges in your ${this.type} graph.`);if(arguments.length>2){if(this.multi)throw new oe(`Graph.${t}: cannot use a {source,target} combo when asking about an edge's attributes in a MultiGraph since we cannot infer the one you want information about.`);const s=""+r,a=""+i;if(i=arguments[2],o=Ot(this,s,a,n),!o)throw new Z(`Graph.${t}: could not find an edge for the given path ("${s}" - "${a}").`)}else{if(n!=="mixed")throw new oe(`Graph.${t}: calling this method with only a key (vs. a source and target) does not make sense since an edge with this key could have the other type.`);if(r=""+r,o=this._edges.get(r),!o)throw new Z(`Graph.${t}: could not find the "${r}" edge in the graph.`)}if(typeof i!="function")throw new q(`Graph.${t}: provided updater is not a function.`);return o.attributes=i(o.attributes),this.emit("edgeAttributesUpdated",{key:o.key,type:"update",attributes:o.attributes}),this}}const GI=[{name:e=>`get${e}Attribute`,attacher:RI},{name:e=>`get${e}Attributes`,attacher:LI},{name:e=>`has${e}Attribute`,attacher:zI},{name:e=>`set${e}Attribute`,attacher:PI},{name:e=>`update${e}Attribute`,attacher:OI},{name:e=>`remove${e}Attribute`,attacher:DI},{name:e=>`replace${e}Attributes`,attacher:MI},{name:e=>`merge${e}Attributes`,attacher:FI},{name:e=>`update${e}Attributes`,attacher:UI}];function jI(e){GI.forEach(function({name:t,attacher:n}){n(e,t("Edge"),"mixed"),n(e,t("DirectedEdge"),"directed"),n(e,t("UndirectedEdge"),"undirected")})}const ZI=[{name:"edges",type:"mixed"},{name:"inEdges",type:"directed",direction:"in"},{name:"outEdges",type:"directed",direction:"out"},{name:"inboundEdges",type:"mixed",direction:"in"},{name:"outboundEdges",type:"mixed",direction:"out"},{name:"directedEdges",type:"directed"},{name:"undirectedEdges",type:"undirected"}];function BI(e,t,n,r){let i=!1;for(const o in t){if(o===r)continue;const s=t[o];if(i=n(s.key,s.attributes,s.source.key,s.target.key,s.source.attributes,s.target.attributes,s.undirected),e&&i)return s.key}}function HI(e,t,n,r){let i,o,s,a=!1;for(const u in t)if(u!==r){i=t[u];do{if(o=i.source,s=i.target,a=n(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected),e&&a)return i.key;i=i.next}while(i!==void 0)}}function vu(e,t){const n=Object.keys(e),r=n.length;let i,o=0;return{[Symbol.iterator](){return this},next(){do if(i)i=i.next;else{if(o>=r)return{done:!0};const s=n[o++];if(s===t){i=void 0;continue}i=e[s]}while(!i);return{done:!1,value:{edge:i.key,attributes:i.attributes,source:i.source.key,target:i.target.key,sourceAttributes:i.source.attributes,targetAttributes:i.target.attributes,undirected:i.undirected}}}}}function VI(e,t,n,r){const i=t[n];if(!i)return;const o=i.source,s=i.target;if(r(i.key,i.attributes,o.key,s.key,o.attributes,s.attributes,i.undirected)&&e)return i.key}function qI(e,t,n,r){let i=t[n];if(!i)return;let o=!1;do{if(o=r(i.key,i.attributes,i.source.key,i.target.key,i.source.attributes,i.target.attributes,i.undirected),e&&o)return i.key;i=i.next}while(i!==void 0)}function bu(e,t){let n=e[t];if(n.next!==void 0)return{[Symbol.iterator](){return this},next(){if(!n)return{done:!0};const i={edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected};return n=n.next,{done:!1,value:i}}};let r=!1;return{[Symbol.iterator](){return this},next(){return r===!0?{done:!0}:(r=!0,{done:!1,value:{edge:n.key,attributes:n.attributes,source:n.source.key,target:n.target.key,sourceAttributes:n.source.attributes,targetAttributes:n.target.attributes,undirected:n.undirected}})}}}function WI(e,t){if(e.size===0)return[];if(t==="mixed"||t===e.type)return Array.from(e._edges.keys());const n=t==="undirected"?e.undirectedSize:e.directedSize,r=new Array(n),i=t==="undirected",o=e._edges.values();let s=0,a,u;for(;a=o.next(),a.done!==!0;)u=a.value,u.undirected===i&&(r[s++]=u.key);return r}function h_(e,t,n,r){if(t.size===0)return;const i=n!=="mixed"&&n!==t.type,o=n==="undirected";let s,a,u=!1;const c=t._edges.values();for(;s=c.next(),s.done!==!0;){if(a=s.value,i&&a.undirected!==o)continue;const{key:l,attributes:d,source:f,target:h}=a;if(u=r(l,d,f.key,h.key,f.attributes,h.attributes,a.undirected),e&&u)return l}}function KI(e,t){if(e.size===0)return Zr();const n=t!=="mixed"&&t!==e.type,r=t==="undirected",i=e._edges.values();return{[Symbol.iterator](){return this},next(){let o,s;for(;;){if(o=i.next(),o.done)return o;if(s=o.value,!(n&&s.undirected!==r))break}return{value:{edge:s.key,attributes:s.attributes,source:s.source.key,target:s.target.key,sourceAttributes:s.source.attributes,targetAttributes:s.target.attributes,undirected:s.undirected},done:!1}}}}function rh(e,t,n,r,i,o){const s=t?HI:BI;let a;if(n!=="undirected"&&(r!=="out"&&(a=s(e,i.in,o),e&&a)||r!=="in"&&(a=s(e,i.out,o,r?void 0:i.key),e&&a))||n!=="directed"&&(a=s(e,i.undirected,o),e&&a))return a}function JI(e,t,n,r){const i=[];return rh(!1,e,t,n,r,function(o){i.push(o)}),i}function YI(e,t,n){let r=Zr();return e!=="undirected"&&(t!=="out"&&typeof n.in<"u"&&(r=un(r,vu(n.in))),t!=="in"&&typeof n.out<"u"&&(r=un(r,vu(n.out,t?void 0:n.key)))),e!=="directed"&&typeof n.undirected<"u"&&(r=un(r,vu(n.undirected))),r}function ih(e,t,n,r,i,o,s){const a=n?qI:VI;let u;if(t!=="undirected"&&(typeof i.in<"u"&&r!=="out"&&(u=a(e,i.in,o,s),e&&u)||typeof i.out<"u"&&r!=="in"&&(r||i.key!==o)&&(u=a(e,i.out,o,s),e&&u))||t!=="directed"&&typeof i.undirected<"u"&&(u=a(e,i.undirected,o,s),e&&u))return u}function XI(e,t,n,r,i){const o=[];return ih(!1,e,t,n,r,i,function(s){o.push(s)}),o}function QI(e,t,n,r){let i=Zr();return e!=="undirected"&&(typeof n.in<"u"&&t!=="out"&&r in n.in&&(i=un(i,bu(n.in,r))),typeof n.out<"u"&&t!=="in"&&r in n.out&&(t||n.key!==r)&&(i=un(i,bu(n.out,r)))),e!=="directed"&&typeof n.undirected<"u"&&r in n.undirected&&(i=un(i,bu(n.undirected,r))),i}function eN(e,t){const{name:n,type:r,direction:i}=t;e.prototype[n]=function(o,s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];if(!arguments.length)return WI(this,r);if(arguments.length===1){o=""+o;const a=this._nodes.get(o);if(typeof a>"u")throw new Z(`Graph.${n}: could not find the "${o}" node in the graph.`);return JI(this.multi,r==="mixed"?this.type:r,i,a)}if(arguments.length===2){o=""+o,s=""+s;const a=this._nodes.get(o);if(!a)throw new Z(`Graph.${n}: could not find the "${o}" source node in the graph.`);if(!this._nodes.has(s))throw new Z(`Graph.${n}: could not find the "${s}" target node in the graph.`);return XI(r,this.multi,i,a,s)}throw new q(`Graph.${n}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function tN(e,t){const{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,l,d){if(!(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)){if(arguments.length===1)return d=c,h_(!1,this,r,d);if(arguments.length===2){c=""+c,d=l;const f=this._nodes.get(c);if(typeof f>"u")throw new Z(`Graph.${o}: could not find the "${c}" node in the graph.`);return rh(!1,this.multi,r==="mixed"?this.type:r,i,f,d)}if(arguments.length===3){c=""+c,l=""+l;const f=this._nodes.get(c);if(!f)throw new Z(`Graph.${o}: could not find the "${c}" source node in the graph.`);if(!this._nodes.has(l))throw new Z(`Graph.${o}: could not find the "${l}" target node in the graph.`);return ih(!1,r,this.multi,i,f,l,d)}throw new q(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)}};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop();let d;if(c.length===0){let f=0;r!=="directed"&&(f+=this.undirectedSize),r!=="undirected"&&(f+=this.directedSize),d=new Array(f);let h=0;c.push((p,m,y,w,g,b,v)=>{d[h++]=l(p,m,y,w,g,b,v)})}else d=[],c.push((f,h,p,m,y,w,g)=>{d.push(l(f,h,p,m,y,w,g))});return this[o].apply(this,c),d};const a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(){const c=Array.prototype.slice.call(arguments),l=c.pop(),d=[];return c.push((f,h,p,m,y,w,g)=>{l(f,h,p,m,y,w,g)&&d.push(f)}),this[o].apply(this,c),d};const u="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[u]=function(){let c=Array.prototype.slice.call(arguments);if(c.length<2||c.length>4)throw new q(`Graph.${u}: invalid number of arguments (expecting 2, 3 or 4 and got ${c.length}).`);if(typeof c[c.length-1]=="function"&&typeof c[c.length-2]!="function")throw new q(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let l,d;c.length===2?(l=c[0],d=c[1],c=[]):c.length===3?(l=c[1],d=c[2],c=[c[0]]):c.length===4&&(l=c[2],d=c[3],c=[c[0],c[1]]);let f=d;return c.push((h,p,m,y,w,g,b)=>{f=l(f,h,p,m,y,w,g,b)}),this[o].apply(this,c),f}}function nN(e,t){const{name:n,type:r,direction:i}=t,o="find"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(u,c,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return!1;if(arguments.length===1)return l=u,h_(!0,this,r,l);if(arguments.length===2){u=""+u,l=c;const d=this._nodes.get(u);if(typeof d>"u")throw new Z(`Graph.${o}: could not find the "${u}" node in the graph.`);return rh(!0,this.multi,r==="mixed"?this.type:r,i,d,l)}if(arguments.length===3){u=""+u,c=""+c;const d=this._nodes.get(u);if(!d)throw new Z(`Graph.${o}: could not find the "${u}" source node in the graph.`);if(!this._nodes.has(c))throw new Z(`Graph.${o}: could not find the "${c}" target node in the graph.`);return ih(!0,r,this.multi,i,d,c,l)}throw new q(`Graph.${o}: too many arguments (expecting 1, 2 or 3 and got ${arguments.length}).`)};const s="some"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[s]=function(){const u=Array.prototype.slice.call(arguments),c=u.pop();return u.push((d,f,h,p,m,y,w)=>c(d,f,h,p,m,y,w)),!!this[o].apply(this,u)};const a="every"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[a]=function(){const u=Array.prototype.slice.call(arguments),c=u.pop();return u.push((d,f,h,p,m,y,w)=>!c(d,f,h,p,m,y,w)),!this[o].apply(this,u)}}function rN(e,t){const{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s,a){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Zr();if(!arguments.length)return KI(this,r);if(arguments.length===1){s=""+s;const u=this._nodes.get(s);if(!u)throw new Z(`Graph.${o}: could not find the "${s}" node in the graph.`);return YI(r,i,u)}if(arguments.length===2){s=""+s,a=""+a;const u=this._nodes.get(s);if(!u)throw new Z(`Graph.${o}: could not find the "${s}" source node in the graph.`);if(!this._nodes.has(a))throw new Z(`Graph.${o}: could not find the "${a}" target node in the graph.`);return QI(r,i,u,a)}throw new q(`Graph.${o}: too many arguments (expecting 0, 1 or 2 and got ${arguments.length}).`)}}function iN(e){ZI.forEach(t=>{eN(e,t),tN(e,t),nN(e,t),rN(e,t)})}const oN=[{name:"neighbors",type:"mixed"},{name:"inNeighbors",type:"directed",direction:"in"},{name:"outNeighbors",type:"directed",direction:"out"},{name:"inboundNeighbors",type:"mixed",direction:"in"},{name:"outboundNeighbors",type:"mixed",direction:"out"},{name:"directedNeighbors",type:"directed"},{name:"undirectedNeighbors",type:"undirected"}];function qa(){this.A=null,this.B=null}qa.prototype.wrap=function(e){this.A===null?this.A=e:this.B===null&&(this.B=e)};qa.prototype.has=function(e){return this.A!==null&&e in this.A||this.B!==null&&e in this.B};function Kr(e,t,n,r,i){for(const o in r){const s=r[o],a=s.source,u=s.target,c=a===n?u:a;if(t&&t.has(c.key))continue;const l=i(c.key,c.attributes);if(e&&l)return c.key}}function oh(e,t,n,r,i){if(t!=="mixed"){if(t==="undirected")return Kr(e,null,r,r.undirected,i);if(typeof n=="string")return Kr(e,null,r,r[n],i)}const o=new qa;let s;if(t!=="undirected"){if(n!=="out"){if(s=Kr(e,null,r,r.in,i),e&&s)return s;o.wrap(r.in)}if(n!=="in"){if(s=Kr(e,o,r,r.out,i),e&&s)return s;o.wrap(r.out)}}if(t!=="directed"&&(s=Kr(e,o,r,r.undirected,i),e&&s))return s}function sN(e,t,n){if(e!=="mixed"){if(e==="undirected")return Object.keys(n.undirected);if(typeof t=="string")return Object.keys(n[t])}const r=[];return oh(!1,e,t,n,function(i){r.push(i)}),r}function Jr(e,t,n){const r=Object.keys(n),i=r.length;let o=0;return{[Symbol.iterator](){return this},next(){let s=null;do{if(o>=i)return e&&e.wrap(n),{done:!0};const a=n[r[o++]],u=a.source,c=a.target;if(s=u===t?c:u,e&&e.has(s.key)){s=null;continue}}while(s===null);return{done:!1,value:{neighbor:s.key,attributes:s.attributes}}}}}function aN(e,t,n){if(e!=="mixed"){if(e==="undirected")return Jr(null,n,n.undirected);if(typeof t=="string")return Jr(null,n,n[t])}let r=Zr();const i=new qa;return e!=="undirected"&&(t!=="out"&&(r=un(r,Jr(i,n,n.in))),t!=="in"&&(r=un(r,Jr(i,n,n.out)))),e!=="directed"&&(r=un(r,Jr(i,n,n.undirected))),r}function uN(e,t){const{name:n,type:r,direction:i}=t;e.prototype[n]=function(o){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return[];o=""+o;const s=this._nodes.get(o);if(typeof s>"u")throw new Z(`Graph.${n}: could not find the "${o}" node in the graph.`);return sN(r==="mixed"?this.type:r,i,s)}}function cN(e,t){const{name:n,type:r,direction:i}=t,o="forEach"+n[0].toUpperCase()+n.slice(1,-1);e.prototype[o]=function(c,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;const d=this._nodes.get(c);if(typeof d>"u")throw new Z(`Graph.${o}: could not find the "${c}" node in the graph.`);oh(!1,r==="mixed"?this.type:r,i,d,l)};const s="map"+n[0].toUpperCase()+n.slice(1);e.prototype[s]=function(c,l){const d=[];return this[o](c,(f,h)=>{d.push(l(f,h))}),d};const a="filter"+n[0].toUpperCase()+n.slice(1);e.prototype[a]=function(c,l){const d=[];return this[o](c,(f,h)=>{l(f,h)&&d.push(f)}),d};const u="reduce"+n[0].toUpperCase()+n.slice(1);e.prototype[u]=function(c,l,d){if(arguments.length<3)throw new q(`Graph.${u}: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.`);let f=d;return this[o](c,(h,p)=>{f=l(f,h,p)}),f}}function lN(e,t){const{name:n,type:r,direction:i}=t,o=n[0].toUpperCase()+n.slice(1,-1),s="find"+o;e.prototype[s]=function(c,l){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return;c=""+c;const d=this._nodes.get(c);if(typeof d>"u")throw new Z(`Graph.${s}: could not find the "${c}" node in the graph.`);return oh(!0,r==="mixed"?this.type:r,i,d,l)};const a="some"+o;e.prototype[a]=function(c,l){return!!this[s](c,l)};const u="every"+o;e.prototype[u]=function(c,l){return!this[s](c,(f,h)=>!l(f,h))}}function dN(e,t){const{name:n,type:r,direction:i}=t,o=n.slice(0,-1)+"Entries";e.prototype[o]=function(s){if(r!=="mixed"&&this.type!=="mixed"&&r!==this.type)return Zr();s=""+s;const a=this._nodes.get(s);if(typeof a>"u")throw new Z(`Graph.${o}: could not find the "${s}" node in the graph.`);return aN(r==="mixed"?this.type:r,i,a)}}function fN(e){oN.forEach(t=>{uN(e,t),cN(e,t),lN(e,t),dN(e,t)})}function Vo(e,t,n,r,i){const o=r._nodes.values(),s=r.type;let a,u,c,l,d,f;for(;a=o.next(),a.done!==!0;){let h=!1;if(u=a.value,s!=="undirected"){l=u.out;for(c in l){d=l[c];do f=d.target,h=!0,i(u.key,f.key,u.attributes,f.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}if(s!=="directed"){l=u.undirected;for(c in l)if(!(t&&u.key>c)){d=l[c];do f=d.target,f.key!==c&&(f=d.source),h=!0,i(u.key,f.key,u.attributes,f.attributes,d.key,d.attributes,d.undirected),d=d.next;while(d)}}n&&!h&&i(u.key,null,u.attributes,null,null,null,null)}}function hN(e,t){const n={key:e};return s_(t.attributes)||(n.attributes=Xe({},t.attributes)),n}function pN(e,t,n){const r={key:t,source:n.source.key,target:n.target.key};return s_(n.attributes)||(r.attributes=Xe({},n.attributes)),e==="mixed"&&n.undirected&&(r.undirected=!0),r}function mN(e){if(!ot(e))throw new q('Graph.import: invalid serialized node. A serialized node should be a plain object with at least a "key" property.');if(!("key"in e))throw new q("Graph.import: serialized node is missing its key.");if("attributes"in e&&(!ot(e.attributes)||e.attributes===null))throw new q("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.")}function gN(e){if(!ot(e))throw new q('Graph.import: invalid serialized edge. A serialized edge should be a plain object with at least a "source" & "target" property.');if(!("source"in e))throw new q("Graph.import: serialized edge is missing its source.");if(!("target"in e))throw new q("Graph.import: serialized edge is missing its target.");if("attributes"in e&&(!ot(e.attributes)||e.attributes===null))throw new q("Graph.import: invalid attributes. Attributes should be a plain object, null or omitted.");if("undirected"in e&&typeof e.undirected!="boolean")throw new q("Graph.import: invalid undirectedness information. Undirected should be boolean or omitted.")}const yN=bI(),vN=new Set(["directed","undirected","mixed"]),Pp=new Set(["domain","_events","_eventsCount","_maxListeners"]),bN=[{name:e=>`${e}Edge`,generateKey:!0},{name:e=>`${e}DirectedEdge`,generateKey:!0,type:"directed"},{name:e=>`${e}UndirectedEdge`,generateKey:!0,type:"undirected"},{name:e=>`${e}EdgeWithKey`},{name:e=>`${e}DirectedEdgeWithKey`,type:"directed"},{name:e=>`${e}UndirectedEdgeWithKey`,type:"undirected"}],wN={allowSelfLoops:!0,multi:!1,type:"mixed"};function _N(e,t,n){if(n&&!ot(n))throw new q(`Graph.addNode: invalid attributes. Expecting an object but got "${n}"`);if(t=""+t,n=n||{},e._nodes.has(t))throw new oe(`Graph.addNode: the "${t}" node already exist in the graph.`);const r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function Op(e,t,n){const r=new e.NodeDataClass(t,n);return e._nodes.set(t,r),e.emit("nodeAdded",{key:t,attributes:n}),r}function p_(e,t,n,r,i,o,s,a){if(!r&&e.type==="undirected")throw new oe(`Graph.${t}: you cannot add a directed edge to an undirected graph. Use the #.addEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new oe(`Graph.${t}: you cannot add an undirected edge to a directed graph. Use the #.addEdge or #.addDirectedEdge instead.`);if(a&&!ot(a))throw new q(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`);if(o=""+o,s=""+s,a=a||{},!e.allowSelfLoops&&o===s)throw new oe(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);const u=e._nodes.get(o),c=e._nodes.get(s);if(!u)throw new Z(`Graph.${t}: source node "${o}" not found.`);if(!c)throw new Z(`Graph.${t}: target node "${s}" not found.`);const l={key:null,undirected:r,source:o,target:s,attributes:a};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new oe(`Graph.${t}: the "${i}" edge already exists in the graph.`);if(!e.multi&&(r?typeof u.undirected[s]<"u":typeof u.out[s]<"u"))throw new oe(`Graph.${t}: an edge linking "${o}" to "${s}" already exists. If you really want to add multiple edges linking those nodes, you should create a multi graph by using the 'multi' option.`);const d=new Br(r,i,u,c,a);e._edges.set(i,d);const f=o===s;return r?(u.undirectedDegree++,c.undirectedDegree++,f&&(u.undirectedLoops++,e._undirectedSelfLoopCount++)):(u.outDegree++,c.inDegree++,f&&(u.directedLoops++,e._directedSelfLoopCount++)),e.multi?d.attachMulti():d.attach(),r?e._undirectedSize++:e._directedSize++,l.key=i,e.emit("edgeAdded",l),i}function kN(e,t,n,r,i,o,s,a,u){if(!r&&e.type==="undirected")throw new oe(`Graph.${t}: you cannot merge/update a directed edge to an undirected graph. Use the #.mergeEdge/#.updateEdge or #.addUndirectedEdge instead.`);if(r&&e.type==="directed")throw new oe(`Graph.${t}: you cannot merge/update an undirected edge to a directed graph. Use the #.mergeEdge/#.updateEdge or #.addDirectedEdge instead.`);if(a){if(u){if(typeof a!="function")throw new q(`Graph.${t}: invalid updater function. Expecting a function but got "${a}"`)}else if(!ot(a))throw new q(`Graph.${t}: invalid attributes. Expecting an object but got "${a}"`)}o=""+o,s=""+s;let c;if(u&&(c=a,a=void 0),!e.allowSelfLoops&&o===s)throw new oe(`Graph.${t}: source & target are the same ("${o}"), thus creating a loop explicitly forbidden by this graph 'allowSelfLoops' option set to false.`);let l=e._nodes.get(o),d=e._nodes.get(s),f,h;if(!n&&(f=e._edges.get(i),f)){if((f.source.key!==o||f.target.key!==s)&&(!r||f.source.key!==s||f.target.key!==o))throw new oe(`Graph.${t}: inconsistency detected when attempting to merge the "${i}" edge with "${o}" source & "${s}" target vs. ("${f.source.key}", "${f.target.key}").`);h=f}if(!h&&!e.multi&&l&&(h=r?l.undirected[s]:l.out[s]),h){const g=[h.key,!1,!1,!1];if(u?!c:!a)return g;if(u){const b=h.attributes;h.attributes=c(b),e.emit("edgeAttributesUpdated",{type:"replace",key:h.key,attributes:h.attributes})}else Xe(h.attributes,a),e.emit("edgeAttributesUpdated",{type:"merge",key:h.key,attributes:h.attributes,data:a});return g}a=a||{},u&&c&&(a=c(a));const p={key:null,undirected:r,source:o,target:s,attributes:a};if(n)i=e._edgeKeyGenerator();else if(i=""+i,e._edges.has(i))throw new oe(`Graph.${t}: the "${i}" edge already exists in the graph.`);let m=!1,y=!1;l||(l=Op(e,o,{}),m=!0,o===s&&(d=l,y=!0)),d||(d=Op(e,s,{}),y=!0),f=new Br(r,i,l,d,a),e._edges.set(i,f);const w=o===s;return r?(l.undirectedDegree++,d.undirectedDegree++,w&&(l.undirectedLoops++,e._undirectedSelfLoopCount++)):(l.outDegree++,d.inDegree++,w&&(l.directedLoops++,e._directedSelfLoopCount++)),e.multi?f.attachMulti():f.attach(),r?e._undirectedSize++:e._directedSize++,p.key=i,e.emit("edgeAdded",p),[i,!0,m,y]}function Qn(e,t){e._edges.delete(t.key);const{source:n,target:r,attributes:i}=t,o=t.undirected,s=n===r;o?(n.undirectedDegree--,r.undirectedDegree--,s&&(n.undirectedLoops--,e._undirectedSelfLoopCount--)):(n.outDegree--,r.inDegree--,s&&(n.directedLoops--,e._directedSelfLoopCount--)),e.multi?t.detachMulti():t.detach(),o?e._undirectedSize--:e._directedSize--,e.emit("edgeDropped",{key:t.key,attributes:i,source:n.key,target:r.key,undirected:o})}class Me extends o_.EventEmitter{constructor(t){if(super(),t=Xe({},wN,t),typeof t.multi!="boolean")throw new q(`Graph.constructor: invalid 'multi' option. Expecting a boolean but got "${t.multi}".`);if(!vN.has(t.type))throw new q(`Graph.constructor: invalid 'type' option. Should be one of "mixed", "directed" or "undirected" but got "${t.type}".`);if(typeof t.allowSelfLoops!="boolean")throw new q(`Graph.constructor: invalid 'allowSelfLoops' option. Expecting a boolean but got "${t.allowSelfLoops}".`);const n=t.type==="mixed"?a_:t.type==="directed"?u_:c_;Rt(this,"NodeDataClass",n);const r="geid_"+yN()+"_";let i=0;const o=()=>{let s;do s=r+i++;while(this._edges.has(s));return s};Rt(this,"_attributes",{}),Rt(this,"_nodes",new Map),Rt(this,"_edges",new Map),Rt(this,"_directedSize",0),Rt(this,"_undirectedSize",0),Rt(this,"_directedSelfLoopCount",0),Rt(this,"_undirectedSelfLoopCount",0),Rt(this,"_edgeKeyGenerator",o),Rt(this,"_options",t),Pp.forEach(s=>Rt(this,s,this[s])),Ht(this,"order",()=>this._nodes.size),Ht(this,"size",()=>this._edges.size),Ht(this,"directedSize",()=>this._directedSize),Ht(this,"undirectedSize",()=>this._undirectedSize),Ht(this,"selfLoopCount",()=>this._directedSelfLoopCount+this._undirectedSelfLoopCount),Ht(this,"directedSelfLoopCount",()=>this._directedSelfLoopCount),Ht(this,"undirectedSelfLoopCount",()=>this._undirectedSelfLoopCount),Ht(this,"multi",this._options.multi),Ht(this,"type",this._options.type),Ht(this,"allowSelfLoops",this._options.allowSelfLoops),Ht(this,"implementation",()=>"graphology")}_resetInstanceCounters(){this._directedSize=0,this._undirectedSize=0,this._directedSelfLoopCount=0,this._undirectedSelfLoopCount=0}hasNode(t){return this._nodes.has(""+t)}hasDirectedEdge(t,n){if(this.type==="undirected")return!1;if(arguments.length===1){const r=""+t,i=this._edges.get(r);return!!i&&!i.undirected}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?r.out.hasOwnProperty(n):!1}throw new q(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasUndirectedEdge(t,n){if(this.type==="directed")return!1;if(arguments.length===1){const r=""+t,i=this._edges.get(r);return!!i&&i.undirected}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?r.undirected.hasOwnProperty(n):!1}throw new q(`Graph.hasDirectedEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}hasEdge(t,n){if(arguments.length===1){const r=""+t;return this._edges.has(r)}else if(arguments.length===2){t=""+t,n=""+n;const r=this._nodes.get(t);return r?typeof r.out<"u"&&r.out.hasOwnProperty(n)||typeof r.undirected<"u"&&r.undirected.hasOwnProperty(n):!1}throw new q(`Graph.hasEdge: invalid arity (${arguments.length}, instead of 1 or 2). You can either ask for an edge id or for the existence of an edge between a source & a target.`)}directedEdge(t,n){if(this.type==="undirected")return;if(t=""+t,n=""+n,this.multi)throw new oe("Graph.directedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.directedEdges instead.");const r=this._nodes.get(t);if(!r)throw new Z(`Graph.directedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Z(`Graph.directedEdge: could not find the "${n}" target node in the graph.`);const i=r.out&&r.out[n]||void 0;if(i)return i.key}undirectedEdge(t,n){if(this.type==="directed")return;if(t=""+t,n=""+n,this.multi)throw new oe("Graph.undirectedEdge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.undirectedEdges instead.");const r=this._nodes.get(t);if(!r)throw new Z(`Graph.undirectedEdge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Z(`Graph.undirectedEdge: could not find the "${n}" target node in the graph.`);const i=r.undirected&&r.undirected[n]||void 0;if(i)return i.key}edge(t,n){if(this.multi)throw new oe("Graph.edge: this method is irrelevant with multigraphs since there might be multiple edges between source & target. See #.edges instead.");t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.edge: could not find the "${t}" source node in the graph.`);if(!this._nodes.has(n))throw new Z(`Graph.edge: could not find the "${n}" target node in the graph.`);const i=r.out&&r.out[n]||r.undirected&&r.undirected[n]||void 0;if(i)return i.key}areDirectedNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areDirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in||n in r.out}areOutNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areOutNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.out}areInNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areInNeighbors: could not find the "${t}" node in the graph.`);return this.type==="undirected"?!1:n in r.in}areUndirectedNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areUndirectedNeighbors: could not find the "${t}" node in the graph.`);return this.type==="directed"?!1:n in r.undirected}areNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&(n in r.in||n in r.out)||this.type!=="directed"&&n in r.undirected}areInboundNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areInboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.in||this.type!=="directed"&&n in r.undirected}areOutboundNeighbors(t,n){t=""+t,n=""+n;const r=this._nodes.get(t);if(!r)throw new Z(`Graph.areOutboundNeighbors: could not find the "${t}" node in the graph.`);return this.type!=="undirected"&&n in r.out||this.type!=="directed"&&n in r.undirected}inDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree}outDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree}directedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.directedDegree: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree}undirectedDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.undirectedDegree: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree}inboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree),r}outboundDegree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outboundDegree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.outDegree),r}degree(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.degree: could not find the "${t}" node in the graph.`);let r=0;return this.type!=="directed"&&(r+=n.undirectedDegree),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree),r}inDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree-n.directedLoops}outDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.outDegree-n.directedLoops}directedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.directedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="undirected"?0:n.inDegree+n.outDegree-n.directedLoops*2}undirectedDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.undirectedDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);return this.type==="directed"?0:n.undirectedDegree-n.undirectedLoops*2}inboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.inboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree,i+=n.directedLoops),r-i}outboundDegreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.outboundDegreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.outDegree,i+=n.directedLoops),r-i}degreeWithoutSelfLoops(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.degreeWithoutSelfLoops: could not find the "${t}" node in the graph.`);let r=0,i=0;return this.type!=="directed"&&(r+=n.undirectedDegree,i+=n.undirectedLoops*2),this.type!=="undirected"&&(r+=n.inDegree+n.outDegree,i+=n.directedLoops*2),r-i}source(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.source: could not find the "${t}" edge in the graph.`);return n.source.key}target(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.target: could not find the "${t}" edge in the graph.`);return n.target.key}extremities(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.extremities: could not find the "${t}" edge in the graph.`);return[n.source.key,n.target.key]}opposite(t,n){t=""+t,n=""+n;const r=this._edges.get(n);if(!r)throw new Z(`Graph.opposite: could not find the "${n}" edge in the graph.`);const i=r.source.key,o=r.target.key;if(t===i)return o;if(t===o)return i;throw new Z(`Graph.opposite: the "${t}" node is not attached to the "${n}" edge (${i}, ${o}).`)}hasExtremity(t,n){t=""+t,n=""+n;const r=this._edges.get(t);if(!r)throw new Z(`Graph.hasExtremity: could not find the "${t}" edge in the graph.`);return r.source.key===n||r.target.key===n}isUndirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.isUndirected: could not find the "${t}" edge in the graph.`);return n.undirected}isDirected(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.isDirected: could not find the "${t}" edge in the graph.`);return!n.undirected}isSelfLoop(t){t=""+t;const n=this._edges.get(t);if(!n)throw new Z(`Graph.isSelfLoop: could not find the "${t}" edge in the graph.`);return n.source===n.target}addNode(t,n){return _N(this,t,n).key}mergeNode(t,n){if(n&&!ot(n))throw new q(`Graph.mergeNode: invalid attributes. Expecting an object but got "${n}"`);t=""+t,n=n||{};let r=this._nodes.get(t);return r?(n&&(Xe(r.attributes,n),this.emit("nodeAttributesUpdated",{type:"merge",key:t,attributes:r.attributes,data:n})),[t,!1]):(r=new this.NodeDataClass(t,n),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:n}),[t,!0])}updateNode(t,n){if(n&&typeof n!="function")throw new q(`Graph.updateNode: invalid updater function. Expecting a function but got "${n}"`);t=""+t;let r=this._nodes.get(t);if(r){if(n){const o=r.attributes;r.attributes=n(o),this.emit("nodeAttributesUpdated",{type:"replace",key:t,attributes:r.attributes})}return[t,!1]}const i=n?n({}):{};return r=new this.NodeDataClass(t,i),this._nodes.set(t,r),this.emit("nodeAdded",{key:t,attributes:i}),[t,!0]}dropNode(t){t=""+t;const n=this._nodes.get(t);if(!n)throw new Z(`Graph.dropNode: could not find the "${t}" node in the graph.`);let r;if(this.type!=="undirected"){for(const i in n.out){r=n.out[i];do Qn(this,r),r=r.next;while(r)}for(const i in n.in){r=n.in[i];do Qn(this,r),r=r.next;while(r)}}if(this.type!=="directed")for(const i in n.undirected){r=n.undirected[i];do Qn(this,r),r=r.next;while(r)}this._nodes.delete(t),this.emit("nodeDropped",{key:t,attributes:n.attributes})}dropEdge(t){let n;if(arguments.length>1){const r=""+arguments[0],i=""+arguments[1];if(n=Ot(this,r,i,this.type),!n)throw new Z(`Graph.dropEdge: could not find the "${r}" -> "${i}" edge in the graph.`)}else if(t=""+t,n=this._edges.get(t),!n)throw new Z(`Graph.dropEdge: could not find the "${t}" edge in the graph.`);return Qn(this,n),this}dropDirectedEdge(t,n){if(arguments.length<2)throw new oe("Graph.dropDirectedEdge: it does not make sense to try and drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new oe("Graph.dropDirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");t=""+t,n=""+n;const r=Ot(this,t,n,"directed");if(!r)throw new Z(`Graph.dropDirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Qn(this,r),this}dropUndirectedEdge(t,n){if(arguments.length<2)throw new oe("Graph.dropUndirectedEdge: it does not make sense to drop a directed edge by key. What if the edge with this key is undirected? Use #.dropEdge for this purpose instead.");if(this.multi)throw new oe("Graph.dropUndirectedEdge: cannot use a {source,target} combo when dropping an edge in a MultiGraph since we cannot infer the one you want to delete as there could be multiple ones.");const r=Ot(this,t,n,"undirected");if(!r)throw new Z(`Graph.dropUndirectedEdge: could not find a "${t}" -> "${n}" edge in the graph.`);return Qn(this,r),this}clear(){this._edges.clear(),this._nodes.clear(),this._resetInstanceCounters(),this.emit("cleared")}clearEdges(){const t=this._nodes.values();let n;for(;n=t.next(),n.done!==!0;)n.value.clear();this._edges.clear(),this._resetInstanceCounters(),this.emit("edgesCleared")}getAttribute(t){return this._attributes[t]}getAttributes(){return this._attributes}hasAttribute(t){return this._attributes.hasOwnProperty(t)}setAttribute(t,n){return this._attributes[t]=n,this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}updateAttribute(t,n){if(typeof n!="function")throw new q("Graph.updateAttribute: updater should be a function.");const r=this._attributes[t];return this._attributes[t]=n(r),this.emit("attributesUpdated",{type:"set",attributes:this._attributes,name:t}),this}removeAttribute(t){return delete this._attributes[t],this.emit("attributesUpdated",{type:"remove",attributes:this._attributes,name:t}),this}replaceAttributes(t){if(!ot(t))throw new q("Graph.replaceAttributes: provided attributes are not a plain object.");return this._attributes=t,this.emit("attributesUpdated",{type:"replace",attributes:this._attributes}),this}mergeAttributes(t){if(!ot(t))throw new q("Graph.mergeAttributes: provided attributes are not a plain object.");return Xe(this._attributes,t),this.emit("attributesUpdated",{type:"merge",attributes:this._attributes,data:t}),this}updateAttributes(t){if(typeof t!="function")throw new q("Graph.updateAttributes: provided updater is not a function.");return this._attributes=t(this._attributes),this.emit("attributesUpdated",{type:"update",attributes:this._attributes}),this}updateEachNodeAttributes(t,n){if(typeof t!="function")throw new q("Graph.updateEachNodeAttributes: expecting an updater function.");if(n&&!zp(n))throw new q("Graph.updateEachNodeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const r=this._nodes.values();let i,o;for(;i=r.next(),i.done!==!0;)o=i.value,o.attributes=t(o.key,o.attributes);this.emit("eachNodeAttributesUpdated",{hints:n||null})}updateEachEdgeAttributes(t,n){if(typeof t!="function")throw new q("Graph.updateEachEdgeAttributes: expecting an updater function.");if(n&&!zp(n))throw new q("Graph.updateEachEdgeAttributes: invalid hints. Expecting an object having the following shape: {attributes?: [string]}");const r=this._edges.values();let i,o,s,a;for(;i=r.next(),i.done!==!0;)o=i.value,s=o.source,a=o.target,o.attributes=t(o.key,o.attributes,s.key,a.key,s.attributes,a.attributes,o.undirected);this.emit("eachEdgeAttributesUpdated",{hints:n||null})}forEachAdjacencyEntry(t){if(typeof t!="function")throw new q("Graph.forEachAdjacencyEntry: expecting a callback.");Vo(!1,!1,!1,this,t)}forEachAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new q("Graph.forEachAdjacencyEntryWithOrphans: expecting a callback.");Vo(!1,!1,!0,this,t)}forEachAssymetricAdjacencyEntry(t){if(typeof t!="function")throw new q("Graph.forEachAssymetricAdjacencyEntry: expecting a callback.");Vo(!1,!0,!1,this,t)}forEachAssymetricAdjacencyEntryWithOrphans(t){if(typeof t!="function")throw new q("Graph.forEachAssymetricAdjacencyEntryWithOrphans: expecting a callback.");Vo(!1,!0,!0,this,t)}nodes(){return Array.from(this._nodes.keys())}forEachNode(t){if(typeof t!="function")throw new q("Graph.forEachNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)}findNode(t){if(typeof t!="function")throw new q("Graph.findNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return i.key}mapNodes(t){if(typeof t!="function")throw new q("Graph.mapNode: expecting a callback.");const n=this._nodes.values();let r,i;const o=new Array(this.order);let s=0;for(;r=n.next(),r.done!==!0;)i=r.value,o[s++]=t(i.key,i.attributes);return o}someNode(t){if(typeof t!="function")throw new q("Graph.someNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,t(i.key,i.attributes))return!0;return!1}everyNode(t){if(typeof t!="function")throw new q("Graph.everyNode: expecting a callback.");const n=this._nodes.values();let r,i;for(;r=n.next(),r.done!==!0;)if(i=r.value,!t(i.key,i.attributes))return!1;return!0}filterNodes(t){if(typeof t!="function")throw new q("Graph.filterNodes: expecting a callback.");const n=this._nodes.values();let r,i;const o=[];for(;r=n.next(),r.done!==!0;)i=r.value,t(i.key,i.attributes)&&o.push(i.key);return o}reduceNodes(t,n){if(typeof t!="function")throw new q("Graph.reduceNodes: expecting a callback.");if(arguments.length<2)throw new q("Graph.reduceNodes: missing initial value. You must provide it because the callback takes more than one argument and we cannot infer the initial value from the first iteration, as you could with a simple array.");let r=n;const i=this._nodes.values();let o,s;for(;o=i.next(),o.done!==!0;)s=o.value,r=t(r,s.key,s.attributes);return r}nodeEntries(){const t=this._nodes.values();return{[Symbol.iterator](){return this},next(){const n=t.next();if(n.done)return n;const r=n.value;return{value:{node:r.key,attributes:r.attributes},done:!1}}}}export(){const t=new Array(this._nodes.size);let n=0;this._nodes.forEach((i,o)=>{t[n++]=hN(o,i)});const r=new Array(this._edges.size);return n=0,this._edges.forEach((i,o)=>{r[n++]=pN(this.type,o,i)}),{options:{type:this.type,multi:this.multi,allowSelfLoops:this.allowSelfLoops},attributes:this.getAttributes(),nodes:t,edges:r}}import(t,n=!1){if(t instanceof Me)return t.forEachNode((u,c)=>{n?this.mergeNode(u,c):this.addNode(u,c)}),t.forEachEdge((u,c,l,d,f,h,p)=>{n?p?this.mergeUndirectedEdgeWithKey(u,l,d,c):this.mergeDirectedEdgeWithKey(u,l,d,c):p?this.addUndirectedEdgeWithKey(u,l,d,c):this.addDirectedEdgeWithKey(u,l,d,c)}),this;if(!ot(t))throw new q("Graph.import: invalid argument. Expecting a serialized graph or, alternatively, a Graph instance.");if(t.attributes){if(!ot(t.attributes))throw new q("Graph.import: invalid attributes. Expecting a plain object.");n?this.mergeAttributes(t.attributes):this.replaceAttributes(t.attributes)}let r,i,o,s,a;if(t.nodes){if(o=t.nodes,!Array.isArray(o))throw new q("Graph.import: invalid nodes. Expecting an array.");for(r=0,i=o.length;r<i;r++){s=o[r],mN(s);const{key:u,attributes:c}=s;n?this.mergeNode(u,c):this.addNode(u,c)}}if(t.edges){let u=!1;if(this.type==="undirected"&&(u=!0),o=t.edges,!Array.isArray(o))throw new q("Graph.import: invalid edges. Expecting an array.");for(r=0,i=o.length;r<i;r++){a=o[r],gN(a);const{source:c,target:l,attributes:d,undirected:f=u}=a;let h;"key"in a?(h=n?f?this.mergeUndirectedEdgeWithKey:this.mergeDirectedEdgeWithKey:f?this.addUndirectedEdgeWithKey:this.addDirectedEdgeWithKey,h.call(this,a.key,c,l,d)):(h=n?f?this.mergeUndirectedEdge:this.mergeDirectedEdge:f?this.addUndirectedEdge:this.addDirectedEdge,h.call(this,c,l,d))}}return this}nullCopy(t){const n=new Me(Xe({},this._options,t));return n.replaceAttributes(Xe({},this.getAttributes())),n}emptyCopy(t){const n=this.nullCopy(t);return this._nodes.forEach((r,i)=>{const o=Xe({},r.attributes);r=new n.NodeDataClass(i,o),n._nodes.set(i,r)}),n}copy(t){if(t=t||{},typeof t.type=="string"&&t.type!==this.type&&t.type!=="mixed")throw new oe(`Graph.copy: cannot create an incompatible copy from "${this.type}" type to "${t.type}" because this would mean losing information about the current graph.`);if(typeof t.multi=="boolean"&&t.multi!==this.multi&&t.multi!==!0)throw new oe("Graph.copy: cannot create an incompatible copy by downgrading a multi graph to a simple one because this would mean losing information about the current graph.");if(typeof t.allowSelfLoops=="boolean"&&t.allowSelfLoops!==this.allowSelfLoops&&t.allowSelfLoops!==!0)throw new oe("Graph.copy: cannot create an incompatible copy from a graph allowing self loops to one that does not because this would mean losing information about the current graph.");const n=this.emptyCopy(t),r=this._edges.values();let i,o;for(;i=r.next(),i.done!==!0;)o=i.value,p_(n,"copy",!1,o.undirected,o.key,o.source.key,o.target.key,Xe({},o.attributes));return n}toJSON(){return this.export()}toString(){return"[object Graph]"}inspect(){const t={};this._nodes.forEach((o,s)=>{t[s]=o.attributes});const n={},r={};this._edges.forEach((o,s)=>{const a=o.undirected?"--":"->";let u="",c=o.source.key,l=o.target.key,d;o.undirected&&c>l&&(d=c,c=l,l=d);const f=`(${c})${a}(${l})`;s.startsWith("geid_")?this.multi&&(typeof r[f]>"u"?r[f]=0:r[f]++,u+=`${r[f]}. `):u+=`[${s}]: `,u+=f,n[u]=o.attributes});const i={};for(const o in this)this.hasOwnProperty(o)&&!Pp.has(o)&&typeof this[o]!="function"&&typeof o!="symbol"&&(i[o]=this[o]);return i.attributes=this._attributes,i.nodes=t,i.edges=n,Rt(i,"constructor",this.constructor),i}}typeof Symbol<"u"&&(Me.prototype[Symbol.for("nodejs.util.inspect.custom")]=Me.prototype.inspect);bN.forEach(e=>{["add","merge","update"].forEach(t=>{const n=e.name(t),r=t==="add"?p_:kN;e.generateKey?Me.prototype[n]=function(i,o,s){return r(this,n,!0,(e.type||this.type)==="undirected",null,i,o,s,t==="update")}:Me.prototype[n]=function(i,o,s,a){return r(this,n,!1,(e.type||this.type)==="undirected",i,o,s,a,t==="update")}})});NI(Me);jI(Me);iN(Me);fN(Me);class m_ extends Me{constructor(t){const n=Xe({type:"directed"},t);if("multi"in n&&n.multi!==!1)throw new q("DirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="directed")throw new q('DirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class g_ extends Me{constructor(t){const n=Xe({type:"undirected"},t);if("multi"in n&&n.multi!==!1)throw new q("UndirectedGraph.from: inconsistent indication that the graph should be multi in given options!");if(n.type!=="undirected")throw new q('UndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class y_ extends Me{constructor(t){const n=Xe({multi:!0},t);if("multi"in n&&n.multi!==!0)throw new q("MultiGraph.from: inconsistent indication that the graph should be simple in given options!");super(n)}}class v_ extends Me{constructor(t){const n=Xe({type:"directed",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new q("MultiDirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="directed")throw new q('MultiDirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}class b_ extends Me{constructor(t){const n=Xe({type:"undirected",multi:!0},t);if("multi"in n&&n.multi!==!0)throw new q("MultiUndirectedGraph.from: inconsistent indication that the graph should be simple in given options!");if(n.type!=="undirected")throw new q('MultiUndirectedGraph.from: inconsistent "'+n.type+'" type in given options!');super(n)}}function Hr(e){e.from=function(t,n){const r=Xe({},t.options,n),i=new e(r);return i.import(t),i}}Hr(Me);Hr(m_);Hr(g_);Hr(y_);Hr(v_);Hr(b_);Me.Graph=Me;Me.DirectedGraph=m_;Me.UndirectedGraph=g_;Me.MultiGraph=y_;Me.MultiDirectedGraph=v_;Me.MultiUndirectedGraph=b_;Me.InvalidArgumentsGraphError=q;Me.NotFoundGraphError=Z;Me.UsageGraphError=oe;function SN(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function si(e){var t=SN(e,"string");return typeof t=="symbol"?t:t+""}function ft(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Dp(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,si(r.key),r)}}function ht(e,t,n){return t&&Dp(e.prototype,t),n&&Dp(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function vr(e){return vr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},vr(e)}function w_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(w_=function(){return!!e})()}function EN(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function xN(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return EN(e)}function Ut(e,t,n){return t=vr(t),xN(e,w_()?Reflect.construct(t,n||[],vr(e).constructor):t.apply(e,n))}function ac(e,t){return ac=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},ac(e,t)}function Gt(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&ac(e,t)}function $N(e){if(Array.isArray(e))return e}function TN(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,s,a=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(l){c=!0,i=l}finally{try{if(!u&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}function uc(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function __(e,t){if(e){if(typeof e=="string")return uc(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?uc(e,t):void 0}}function CN(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
111
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function br(e,t){return $N(e)||TN(e,t)||__(e,t)||CN()}var wu={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},k_=new Int8Array(4),ns=new Int32Array(k_.buffer,0,1),S_=new Float32Array(k_.buffer,0,1),AN=/^\s*rgba?\s*\(/,IN=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function NN(e){var t=0,n=0,r=0,i=1;if(e[0]==="#")e.length===4?(t=parseInt(e.charAt(1)+e.charAt(1),16),n=parseInt(e.charAt(2)+e.charAt(2),16),r=parseInt(e.charAt(3)+e.charAt(3),16)):(t=parseInt(e.charAt(1)+e.charAt(2),16),n=parseInt(e.charAt(3)+e.charAt(4),16),r=parseInt(e.charAt(5)+e.charAt(6),16)),e.length===9&&(i=parseInt(e.charAt(7)+e.charAt(8),16)/255);else if(AN.test(e)){var o=e.match(IN);o&&(t=+o[1],n=+o[2],r=+o[3],o[4]&&(i=+o[4]))}return{r:t,g:n,b:r,a:i}}var or={};for(var qo in wu)or[qo]=Rn(wu[qo]),or[wu[qo]]=or[qo];function E_(e,t,n,r,i){return ns[0]=r<<24|n<<16|t<<8|e,ns[0]=ns[0]&4278190079,S_[0]}function Rn(e){if(e=e.toLowerCase(),typeof or[e]<"u")return or[e];var t=NN(e),n=t.r,r=t.g,i=t.b,o=t.a;o=o*255|0;var s=E_(n,r,i,o);return or[e]=s,s}function RN(e,t){S_[0]=Rn(e);var n=ns[0],r=n&255,i=n>>8&255,o=n>>16&255,s=n>>24&255;return[r,i,o,s]}var _u={};function x_(e){if(typeof _u[e]<"u")return _u[e];var t=(e&16711680)>>>16,n=(e&65280)>>>8,r=e&255,i=255,o=E_(t,n,r,i);return _u[e]=o,o}function Mp(e,t,n,r){return n+(t<<8)+(e<<16)}function Fp(e,t,n,r,i,o){var s=Math.floor(n/o*i),a=Math.floor(e.drawingBufferHeight/o-r/o*i),u=new Uint8Array(4);e.bindFramebuffer(e.FRAMEBUFFER,t),e.readPixels(s,a,1,1,e.RGBA,e.UNSIGNED_BYTE,u);var c=br(u,4),l=c[0],d=c[1],f=c[2],h=c[3];return[l,d,f,h]}function L(e,t,n){return(t=si(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Up(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function X(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Up(Object(n),!0).forEach(function(r){L(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Up(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function LN(e,t){for(;!{}.hasOwnProperty.call(e,t)&&(e=vr(e))!==null;);return e}function cc(){return cc=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(e,t,n){var r=LN(e,t);if(r){var i=Object.getOwnPropertyDescriptor(r,t);return i.get?i.get.call(arguments.length<3?e:n):i.value}},cc.apply(null,arguments)}function $_(e,t,n,r){var i=cc(vr(e.prototype),t,n);return typeof i=="function"?function(o){return i.apply(n,o)}:i}function zN(e){return e.normalized?1:e.size}function ku(e){var t=0;return e.forEach(function(n){return t+=zN(n)}),t}function T_(e,t,n){var r=e==="VERTEX"?t.VERTEX_SHADER:t.FRAGMENT_SHADER,i=t.createShader(r);if(i===null)throw new Error("loadShader: error while creating the shader");t.shaderSource(i,n),t.compileShader(i);var o=t.getShaderParameter(i,t.COMPILE_STATUS);if(!o){var s=t.getShaderInfoLog(i);throw t.deleteShader(i),new Error(`loadShader: error while compiling the shader:
|
|
112
112
|
`.concat(s,`
|
|
113
|
-
`).concat(n))}return i}function
|
|
114
|
-
`,
|
|
113
|
+
`).concat(n))}return i}function PN(e,t){return T_("VERTEX",e,t)}function ON(e,t){return T_("FRAGMENT",e,t)}function DN(e,t){var n=e.createProgram();if(n===null)throw new Error("loadProgram: error while creating the program.");var r,i;for(r=0,i=t.length;r<i;r++)e.attachShader(n,t[r]);e.linkProgram(n);var o=e.getProgramParameter(n,e.LINK_STATUS);if(!o){var s=e.getProgramInfoLog(n);throw e.deleteProgram(n),new Error("loadProgram: error while linking the program: ".concat(s))}return n}function Gp(e){var t=e.gl,n=e.buffer,r=e.program,i=e.vertexShader,o=e.fragmentShader;t.deleteShader(i),t.deleteShader(o),t.deleteProgram(r),t.deleteBuffer(n)}function jp(e){return e%1===0?e.toFixed(1):e.toString()}var Zp=`#define PICKING_MODE
|
|
114
|
+
`,MN=L(L(L(L(L(L(L(L({},WebGL2RenderingContext.BOOL,1),WebGL2RenderingContext.BYTE,1),WebGL2RenderingContext.UNSIGNED_BYTE,1),WebGL2RenderingContext.SHORT,2),WebGL2RenderingContext.UNSIGNED_SHORT,2),WebGL2RenderingContext.INT,4),WebGL2RenderingContext.UNSIGNED_INT,4),WebGL2RenderingContext.FLOAT,4),C_=(function(){function e(t,n,r){ft(this,e),L(this,"array",new Float32Array),L(this,"constantArray",new Float32Array),L(this,"capacity",0),L(this,"verticesCount",0);var i=this.getDefinition();if(this.VERTICES=i.VERTICES,this.VERTEX_SHADER_SOURCE=i.VERTEX_SHADER_SOURCE,this.FRAGMENT_SHADER_SOURCE=i.FRAGMENT_SHADER_SOURCE,this.UNIFORMS=i.UNIFORMS,this.ATTRIBUTES=i.ATTRIBUTES,this.METHOD=i.METHOD,this.CONSTANT_ATTRIBUTES="CONSTANT_ATTRIBUTES"in i?i.CONSTANT_ATTRIBUTES:[],this.CONSTANT_DATA="CONSTANT_DATA"in i?i.CONSTANT_DATA:[],this.isInstanced="CONSTANT_ATTRIBUTES"in i,this.ATTRIBUTES_ITEMS_COUNT=ku(this.ATTRIBUTES),this.STRIDE=this.VERTICES*this.ATTRIBUTES_ITEMS_COUNT,this.renderer=r,this.normalProgram=this.getProgramInfo("normal",t,i.VERTEX_SHADER_SOURCE,i.FRAGMENT_SHADER_SOURCE,null),this.pickProgram=n?this.getProgramInfo("pick",t,Zp+i.VERTEX_SHADER_SOURCE,Zp+i.FRAGMENT_SHADER_SOURCE,n):null,this.isInstanced){var o=ku(this.CONSTANT_ATTRIBUTES);if(this.CONSTANT_DATA.length!==this.VERTICES)throw new Error("Program: error while getting constant data (expected ".concat(this.VERTICES," items, received ").concat(this.CONSTANT_DATA.length," instead)"));this.constantArray=new Float32Array(this.CONSTANT_DATA.length*o);for(var s=0;s<this.CONSTANT_DATA.length;s++){var a=this.CONSTANT_DATA[s];if(a.length!==o)throw new Error("Program: error while getting constant data (one vector has ".concat(a.length," items instead of ").concat(o,")"));for(var u=0;u<a.length;u++)this.constantArray[s*o+u]=a[u]}this.STRIDE=this.ATTRIBUTES_ITEMS_COUNT}}return ht(e,[{key:"kill",value:function(){Gp(this.normalProgram),this.pickProgram&&(Gp(this.pickProgram),this.pickProgram=null)}},{key:"getProgramInfo",value:function(n,r,i,o,s){var a=this.getDefinition(),u=r.createBuffer();if(u===null)throw new Error("Program: error while creating the WebGL buffer.");var c=PN(r,i),l=ON(r,o),d=DN(r,[c,l]),f={};a.UNIFORMS.forEach(function(m){var y=r.getUniformLocation(d,m);y&&(f[m]=y)});var h={};a.ATTRIBUTES.forEach(function(m){h[m.name]=r.getAttribLocation(d,m.name)});var p;if("CONSTANT_ATTRIBUTES"in a&&(a.CONSTANT_ATTRIBUTES.forEach(function(m){h[m.name]=r.getAttribLocation(d,m.name)}),p=r.createBuffer(),p===null))throw new Error("Program: error while creating the WebGL constant buffer.");return{name:n,program:d,gl:r,frameBuffer:s,buffer:u,constantBuffer:p||{},uniformLocations:f,attributeLocations:h,isPicking:n==="pick",vertexShader:c,fragmentShader:l}}},{key:"bindProgram",value:function(n){var r=this,i=0,o=n.gl,s=n.buffer;this.isInstanced?(o.bindBuffer(o.ARRAY_BUFFER,n.constantBuffer),i=0,this.CONSTANT_ATTRIBUTES.forEach(function(a){return i+=r.bindAttribute(a,n,i,!1)}),o.bufferData(o.ARRAY_BUFFER,this.constantArray,o.STATIC_DRAW),o.bindBuffer(o.ARRAY_BUFFER,n.buffer),i=0,this.ATTRIBUTES.forEach(function(a){return i+=r.bindAttribute(a,n,i,!0)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)):(o.bindBuffer(o.ARRAY_BUFFER,s),i=0,this.ATTRIBUTES.forEach(function(a){return i+=r.bindAttribute(a,n,i)}),o.bufferData(o.ARRAY_BUFFER,this.array,o.DYNAMIC_DRAW)),o.bindBuffer(o.ARRAY_BUFFER,null)}},{key:"unbindProgram",value:function(n){var r=this;this.isInstanced?(this.CONSTANT_ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!1)}),this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n,!0)})):this.ATTRIBUTES.forEach(function(i){return r.unbindAttribute(i,n)})}},{key:"bindAttribute",value:function(n,r,i,o){var s=MN[n.type];if(typeof s!="number")throw new Error('Program.bind: yet unsupported attribute type "'.concat(n.type,'"'));var a=r.attributeLocations[n.name],u=r.gl;if(a!==-1){u.enableVertexAttribArray(a);var c=this.isInstanced?(o?this.ATTRIBUTES_ITEMS_COUNT:ku(this.CONSTANT_ATTRIBUTES))*Float32Array.BYTES_PER_ELEMENT:this.ATTRIBUTES_ITEMS_COUNT*Float32Array.BYTES_PER_ELEMENT;if(u.vertexAttribPointer(a,n.size,n.type,n.normalized||!1,c,i),this.isInstanced&&o)if(u instanceof WebGL2RenderingContext)u.vertexAttribDivisor(a,1);else{var l=u.getExtension("ANGLE_instanced_arrays");l&&l.vertexAttribDivisorANGLE(a,1)}}return n.size*s}},{key:"unbindAttribute",value:function(n,r,i){var o=r.attributeLocations[n.name],s=r.gl;if(o!==-1&&(s.disableVertexAttribArray(o),this.isInstanced&&i))if(s instanceof WebGL2RenderingContext)s.vertexAttribDivisor(o,0);else{var a=s.getExtension("ANGLE_instanced_arrays");a&&a.vertexAttribDivisorANGLE(o,0)}}},{key:"reallocate",value:function(n){n!==this.capacity&&(this.capacity=n,this.verticesCount=this.VERTICES*n,this.array=new Float32Array(this.isInstanced?this.capacity*this.ATTRIBUTES_ITEMS_COUNT:this.verticesCount*this.ATTRIBUTES_ITEMS_COUNT))}},{key:"hasNothingToRender",value:function(){return this.verticesCount===0}},{key:"renderProgram",value:function(n,r){var i=r.gl,o=r.program;i.enable(i.BLEND),i.useProgram(o),this.setUniforms(n,r),this.drawWebGL(this.METHOD,r)}},{key:"render",value:function(n){this.hasNothingToRender()||(this.pickProgram&&(this.pickProgram.gl.viewport(0,0,n.width*n.pixelRatio/n.downSizingRatio,n.height*n.pixelRatio/n.downSizingRatio),this.bindProgram(this.pickProgram),this.renderProgram(X(X({},n),{},{pixelRatio:n.pixelRatio/n.downSizingRatio}),this.pickProgram),this.unbindProgram(this.pickProgram)),this.normalProgram.gl.viewport(0,0,n.width*n.pixelRatio,n.height*n.pixelRatio),this.bindProgram(this.normalProgram),this.renderProgram(n,this.normalProgram),this.unbindProgram(this.normalProgram))}},{key:"drawWebGL",value:function(n,r){var i=r.gl,o=r.frameBuffer;if(i.bindFramebuffer(i.FRAMEBUFFER,o),!this.isInstanced)i.drawArrays(n,0,this.verticesCount);else if(i instanceof WebGL2RenderingContext)i.drawArraysInstanced(n,0,this.VERTICES,this.capacity);else{var s=i.getExtension("ANGLE_instanced_arrays");s&&s.drawArraysInstancedANGLE(n,0,this.VERTICES,this.capacity)}}}])})(),A_=(function(e){function t(){return ft(this,t),Ut(this,t,arguments)}return Gt(t,e),ht(t,[{key:"kill",value:function(){$_(t,"kill",this)([])}},{key:"process",value:function(r,i,o){var s=i*this.STRIDE;if(o.hidden){for(var a=s+this.STRIDE;s<a;s++)this.array[s]=0;return}return this.processVisibleItem(x_(r),s,o)}}])})(C_),Wa=(function(e){function t(){var n;ft(this,t);for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];return n=Ut(this,t,[].concat(i)),L(n,"drawLabel",void 0),n}return Gt(t,e),ht(t,[{key:"kill",value:function(){$_(t,"kill",this)([])}},{key:"process",value:function(r,i,o,s,a){var u=i*this.STRIDE;if(a.hidden||o.hidden||s.hidden){for(var c=u+this.STRIDE;u<c;u++)this.array[u]=0;return}return this.processVisibleItem(x_(r),u,o,s,a)}}])})(C_);function FN(e,t){return(function(){function n(r,i,o){ft(this,n),L(this,"drawLabel",t),this.programs=e.map(function(s){return new s(r,i,o)})}return ht(n,[{key:"reallocate",value:function(i){this.programs.forEach(function(o){return o.reallocate(i)})}},{key:"process",value:function(i,o,s,a,u){this.programs.forEach(function(c){return c.process(i,o,s,a,u)})}},{key:"render",value:function(i){this.programs.forEach(function(o){return o.render(i)})}},{key:"kill",value:function(){this.programs.forEach(function(i){return i.kill()})}}])})()}function UN(e,t,n,r,i){var o=i.edgeLabelSize,s=i.edgeLabelFont,a=i.edgeLabelWeight,u=i.edgeLabelColor.attribute?t[i.edgeLabelColor.attribute]||i.edgeLabelColor.color||"#000":i.edgeLabelColor.color,c=t.label;if(c){e.fillStyle=u,e.font="".concat(a," ").concat(o,"px ").concat(s);var l=n.size,d=r.size,f=n.x,h=n.y,p=r.x,m=r.y,y=(f+p)/2,w=(h+m)/2,g=p-f,b=m-h,v=Math.sqrt(g*g+b*b);if(!(v<l+d)){f+=g*l/v,h+=b*l/v,p-=g*d/v,m-=b*d/v,y=(f+p)/2,w=(h+m)/2,g=p-f,b=m-h,v=Math.sqrt(g*g+b*b);var k=e.measureText(c).width;if(k>v){var _="…";for(c=c+_,k=e.measureText(c).width;k>v&&c.length>1;)c=c.slice(0,-2)+_,k=e.measureText(c).width;if(c.length<4)return}var $;g>0?b>0?$=Math.acos(g/v):$=Math.asin(b/v):b>0?$=Math.acos(g/v)+Math.PI:$=Math.asin(g/v)+Math.PI/2,e.save(),e.translate(y,w),e.rotate($),e.fillText(c,-k/2,t.size/2+o),e.restore()}}}function I_(e,t,n){if(t.label){var r=n.labelSize,i=n.labelFont,o=n.labelWeight,s=n.labelColor.attribute?t[n.labelColor.attribute]||n.labelColor.color||"#000":n.labelColor.color;e.fillStyle=s,e.font="".concat(o," ").concat(r,"px ").concat(i),e.fillText(t.label,t.x+t.size+3,t.y+r/3)}}function GN(e,t,n){var r=n.labelSize,i=n.labelFont,o=n.labelWeight;e.font="".concat(o," ").concat(r,"px ").concat(i),e.fillStyle="#FFF",e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=8,e.shadowColor="#000";var s=2;if(typeof t.label=="string"){var a=e.measureText(t.label).width,u=Math.round(a+5),c=Math.round(r+2*s),l=Math.max(t.size,r/2)+s,d=Math.asin(c/2/l),f=Math.sqrt(Math.abs(Math.pow(l,2)-Math.pow(c/2,2)));e.beginPath(),e.moveTo(t.x+f,t.y+c/2),e.lineTo(t.x+l+u,t.y+c/2),e.lineTo(t.x+l+u,t.y-c/2),e.lineTo(t.x+f,t.y-c/2),e.arc(t.x,t.y,l,d,-d),e.closePath(),e.fill()}else e.beginPath(),e.arc(t.x,t.y,t.size+s,0,Math.PI*2),e.closePath(),e.fill();e.shadowOffsetX=0,e.shadowOffsetY=0,e.shadowBlur=0,I_(e,t,n)}var jN=`
|
|
115
115
|
precision highp float;
|
|
116
116
|
|
|
117
117
|
varying vec4 v_color;
|
|
@@ -143,7 +143,7 @@ void main(void) {
|
|
|
143
143
|
gl_FragColor = mix(v_color, transparent, t);
|
|
144
144
|
#endif
|
|
145
145
|
}
|
|
146
|
-
`,
|
|
146
|
+
`,ZN=jN,BN=`
|
|
147
147
|
attribute vec4 a_id;
|
|
148
148
|
attribute vec4 a_color;
|
|
149
149
|
attribute vec2 a_position;
|
|
@@ -184,7 +184,7 @@ void main() {
|
|
|
184
184
|
|
|
185
185
|
v_color.a *= bias;
|
|
186
186
|
}
|
|
187
|
-
`,
|
|
187
|
+
`,HN=BN,N_=WebGLRenderingContext,Bp=N_.UNSIGNED_BYTE,Su=N_.FLOAT,VN=["u_sizeRatio","u_correctionRatio","u_matrix"],Ka=(function(e){function t(){return ft(this,t),Ut(this,t,arguments)}return Gt(t,e),ht(t,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:HN,FRAGMENT_SHADER_SOURCE:ZN,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:VN,ATTRIBUTES:[{name:"a_position",size:2,type:Su},{name:"a_size",size:1,type:Su},{name:"a_color",size:4,type:Bp,normalized:!0},{name:"a_id",size:4,type:Bp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Su}],CONSTANT_DATA:[[t.ANGLE_1],[t.ANGLE_2],[t.ANGLE_3]]}}},{key:"processVisibleItem",value:function(r,i,o){var s=this.array,a=Rn(o.color);s[i++]=o.x,s[i++]=o.y,s[i++]=o.size,s[i++]=a,s[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,s=i.uniformLocations,a=s.u_sizeRatio,u=s.u_correctionRatio,c=s.u_matrix;o.uniform1f(u,r.correctionRatio),o.uniform1f(a,r.sizeRatio),o.uniformMatrix3fv(c,!1,r.matrix)}}])})(A_);L(Ka,"ANGLE_1",0);L(Ka,"ANGLE_2",2*Math.PI/3);L(Ka,"ANGLE_3",4*Math.PI/3);var qN=`
|
|
188
188
|
precision mediump float;
|
|
189
189
|
|
|
190
190
|
varying vec4 v_color;
|
|
@@ -192,7 +192,7 @@ varying vec4 v_color;
|
|
|
192
192
|
void main(void) {
|
|
193
193
|
gl_FragColor = v_color;
|
|
194
194
|
}
|
|
195
|
-
`,
|
|
195
|
+
`,WN=qN,KN=`
|
|
196
196
|
attribute vec2 a_position;
|
|
197
197
|
attribute vec2 a_normal;
|
|
198
198
|
attribute float a_radius;
|
|
@@ -258,7 +258,7 @@ void main() {
|
|
|
258
258
|
|
|
259
259
|
v_color.a *= bias;
|
|
260
260
|
}
|
|
261
|
-
`,
|
|
261
|
+
`,JN=KN,R_=WebGLRenderingContext,Hp=R_.UNSIGNED_BYTE,Wo=R_.FLOAT,YN=["u_matrix","u_sizeRatio","u_correctionRatio","u_minEdgeThickness","u_lengthToThicknessRatio","u_widenessToThicknessRatio"],Ja={extremity:"target",lengthToThicknessRatio:2.5,widenessToThicknessRatio:2};function L_(e){var t=X(X({},Ja),e||{});return(function(n){function r(){return ft(this,r),Ut(this,r,arguments)}return Gt(r,n),ht(r,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:JN,FRAGMENT_SHADER_SOURCE:WN,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:YN,ATTRIBUTES:[{name:"a_position",size:2,type:Wo},{name:"a_normal",size:2,type:Wo},{name:"a_radius",size:1,type:Wo},{name:"a_color",size:4,type:Hp,normalized:!0},{name:"a_id",size:4,type:Hp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_barycentric",size:3,type:Wo}],CONSTANT_DATA:[[1,0,0],[0,1,0],[0,0,1]]}}},{key:"processVisibleItem",value:function(o,s,a,u,c){if(t.extremity==="source"){var l=[u,a];a=l[0],u=l[1]}var d=c.size||1,f=u.size||1,h=a.x,p=a.y,m=u.x,y=u.y,w=Rn(c.color),g=m-h,b=y-p,v=g*g+b*b,k=0,_=0;v&&(v=1/Math.sqrt(v),k=-b*v*d,_=g*v*d);var $=this.array;$[s++]=m,$[s++]=y,$[s++]=-k,$[s++]=-_,$[s++]=f,$[s++]=w,$[s++]=o}},{key:"setUniforms",value:function(o,s){var a=s.gl,u=s.uniformLocations,c=u.u_matrix,l=u.u_sizeRatio,d=u.u_correctionRatio,f=u.u_minEdgeThickness,h=u.u_lengthToThicknessRatio,p=u.u_widenessToThicknessRatio;a.uniformMatrix3fv(c,!1,o.matrix),a.uniform1f(l,o.sizeRatio),a.uniform1f(d,o.correctionRatio),a.uniform1f(f,o.minEdgeThickness),a.uniform1f(h,t.lengthToThicknessRatio),a.uniform1f(p,t.widenessToThicknessRatio)}}])})(Wa)}L_();var XN=`
|
|
262
262
|
precision mediump float;
|
|
263
263
|
|
|
264
264
|
varying vec4 v_color;
|
|
@@ -284,7 +284,7 @@ void main(void) {
|
|
|
284
284
|
gl_FragColor = mix(v_color, transparent, t);
|
|
285
285
|
#endif
|
|
286
286
|
}
|
|
287
|
-
`,
|
|
287
|
+
`,z_=XN,QN=`
|
|
288
288
|
attribute vec4 a_id;
|
|
289
289
|
attribute vec4 a_color;
|
|
290
290
|
attribute vec2 a_normal;
|
|
@@ -352,7 +352,7 @@ void main() {
|
|
|
352
352
|
|
|
353
353
|
v_color.a *= bias;
|
|
354
354
|
}
|
|
355
|
-
`,
|
|
355
|
+
`,e1=QN,P_=WebGLRenderingContext,Vp=P_.UNSIGNED_BYTE,Dn=P_.FLOAT,t1=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness","u_lengthToThicknessRatio"],n1={lengthToThicknessRatio:Ja.lengthToThicknessRatio};function O_(e){var t=X(X({},n1),e||{});return(function(n){function r(){return ft(this,r),Ut(this,r,arguments)}return Gt(r,n),ht(r,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:e1,FRAGMENT_SHADER_SOURCE:z_,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:t1,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Dn},{name:"a_positionEnd",size:2,type:Dn},{name:"a_normal",size:2,type:Dn},{name:"a_color",size:4,type:Vp,normalized:!0},{name:"a_id",size:4,type:Vp,normalized:!0},{name:"a_radius",size:1,type:Dn}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Dn},{name:"a_normalCoef",size:1,type:Dn},{name:"a_radiusCoef",size:1,type:Dn}],CONSTANT_DATA:[[0,1,0],[0,-1,0],[1,1,1],[1,1,1],[0,-1,0],[1,-1,-1]]}}},{key:"processVisibleItem",value:function(o,s,a,u,c){var l=c.size||1,d=a.x,f=a.y,h=u.x,p=u.y,m=Rn(c.color),y=h-d,w=p-f,g=u.size||1,b=y*y+w*w,v=0,k=0;b&&(b=1/Math.sqrt(b),v=-w*b*l,k=y*b*l);var _=this.array;_[s++]=d,_[s++]=f,_[s++]=h,_[s++]=p,_[s++]=v,_[s++]=k,_[s++]=m,_[s++]=o,_[s++]=g}},{key:"setUniforms",value:function(o,s){var a=s.gl,u=s.uniformLocations,c=u.u_matrix,l=u.u_zoomRatio,d=u.u_feather,f=u.u_pixelRatio,h=u.u_correctionRatio,p=u.u_sizeRatio,m=u.u_minEdgeThickness,y=u.u_lengthToThicknessRatio;a.uniformMatrix3fv(c,!1,o.matrix),a.uniform1f(l,o.zoomRatio),a.uniform1f(p,o.sizeRatio),a.uniform1f(h,o.correctionRatio),a.uniform1f(f,o.pixelRatio),a.uniform1f(d,o.antiAliasingFeather),a.uniform1f(m,o.minEdgeThickness),a.uniform1f(y,t.lengthToThicknessRatio)}}])})(Wa)}O_();function D_(e){return FN([O_(e),L_(e)])}var r1=D_(),i1=r1,o1=`
|
|
356
356
|
attribute vec4 a_id;
|
|
357
357
|
attribute vec4 a_color;
|
|
358
358
|
attribute vec2 a_normal;
|
|
@@ -417,9 +417,9 @@ void main() {
|
|
|
417
417
|
|
|
418
418
|
v_color.a *= bias;
|
|
419
419
|
}
|
|
420
|
-
`,e1=QN,P_=WebGLRenderingContext,Hp=P_.UNSIGNED_BYTE,Yr=P_.FLOAT,t1=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],n1=(function(e){function t(){return ft(this,t),Ut(this,t,arguments)}return Gt(t,e),ht(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:e1,FRAGMENT_SHADER_SOURCE:N_,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:t1,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Yr},{name:"a_positionEnd",size:2,type:Yr},{name:"a_normal",size:2,type:Yr},{name:"a_color",size:4,type:Hp,normalized:!0},{name:"a_id",size:4,type:Hp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Yr},{name:"a_normalCoef",size:1,type:Yr}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,o,s,a){var u=a.size||1,c=o.x,l=o.y,d=s.x,f=s.y,h=Ln(a.color),p=d-c,m=f-l,y=p*p+m*m,w=0,g=0;y&&(y=1/Math.sqrt(y),w=-m*y*u,g=p*y*u);var b=this.array;b[i++]=c,b[i++]=l,b[i++]=d,b[i++]=f,b[i++]=w,b[i++]=g,b[i++]=h,b[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,s=i.uniformLocations,a=s.u_matrix,u=s.u_zoomRatio,c=s.u_feather,l=s.u_pixelRatio,d=s.u_correctionRatio,f=s.u_sizeRatio,h=s.u_minEdgeThickness;o.uniformMatrix3fv(a,!1,r.matrix),o.uniform1f(u,r.zoomRatio),o.uniform1f(f,r.sizeRatio),o.uniform1f(d,r.correctionRatio),o.uniform1f(l,r.pixelRatio),o.uniform1f(c,r.antiAliasingFeather),o.uniform1f(h,r.minEdgeThickness)}}])})(Wa),sh=(function(e){function t(){var n;return ft(this,t),n=Ut(this,t),n.rawEmitter=n,n}return Gt(t,e),ht(t)})(n_.EventEmitter),xu,Vp;function r1(){return Vp||(Vp=1,xu=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}),xu}var i1=r1();const o1=lI(i1);var s1=function(t){return t},a1=function(t){return t*t},u1=function(t){return t*(2-t)},c1=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},l1=function(t){return t*t*t},d1=function(t){return--t*t*t+1},f1=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},h1={linear:s1,quadraticIn:a1,quadraticOut:u1,quadraticInOut:c1,cubicIn:l1,cubicOut:d1,cubicInOut:f1},p1={easing:"quadraticInOut",duration:150};function Ht(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ko(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function qp(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[3]=-n,e[4]=r,e}function Wp(e,t,n){return e[6]=t,e[7]=n,e}function wn(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],s=e[4],a=e[5],u=e[6],c=e[7],l=e[8],d=t[0],f=t[1],h=t[2],p=t[3],m=t[4],y=t[5],w=t[6],g=t[7],b=t[8];return e[0]=d*n+f*o+h*u,e[1]=d*r+f*s+h*c,e[2]=d*i+f*a+h*l,e[3]=p*n+m*o+y*u,e[4]=p*r+m*s+y*c,e[5]=p*i+m*a+y*l,e[6]=w*n+g*o+b*u,e[7]=w*r+g*s+b*c,e[8]=w*i+g*a+b*l,e}function lc(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],o=e[3],s=e[4],a=e[6],u=e[7],c=t.x,l=t.y;return{x:c*r+l*o+a*n,y:c*i+l*s+u*n}}function m1(e,t){var n=e.height/e.width,r=t.height/t.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function Xr(e,t,n,r,i){var o=e.angle,s=e.ratio,a=e.x,u=e.y,c=t.width,l=t.height,d=Ht(),f=Math.min(c,l)-2*r,h=m1(t,n);return i?(wn(d,Wp(Ht(),a,u)),wn(d,Ko(Ht(),s)),wn(d,qp(Ht(),o)),wn(d,Ko(Ht(),c/f/2/h,l/f/2/h))):(wn(d,Ko(Ht(),2*(f/c)*h,2*(f/l)*h)),wn(d,qp(Ht(),-o)),wn(d,Ko(Ht(),1/s)),wn(d,Wp(Ht(),-a,-u))),d}function g1(e,t,n){var r=lc(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function y1(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,r=1/0,i=-1/0;return e.forEachNode(function(o,s){var a=s.x,u=s.y;a<t&&(t=a),a>n&&(n=a),u<r&&(r=u),u>i&&(i=u)}),{x:[t,n],y:[r,i]}}function v1(e){if(!o1(e))throw new Error("Sigma: invalid graph instance.");e.forEachNode(function(t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(t," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function b1(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function Kp(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Jp(e,t,n){return n.sort(function(r,i){var o=t(r)||0,s=t(i)||0;return o<s?-1:o>s?1:0})}function Yp(e){var t=br(e.x,2),n=t[0],r=t[1],i=br(e.y,2),o=i[0],s=i[1],a=Math.max(r-n,s-o),u=(r+n)/2,c=(s+o)/2;(a===0||Math.abs(a)===1/0||isNaN(a))&&(a=1),isNaN(u)&&(u=0),isNaN(c)&&(c=0);var l=function(f){return{x:.5+(f.x-u)/a,y:.5+(f.y-c)/a}};return l.applyTo=function(d){d.x=.5+(d.x-u)/a,d.y=.5+(d.y-c)/a},l.inverse=function(d){return{x:u+a*(d.x-.5),y:c+a*(d.y-.5)}},l.ratio=a,l}function dc(e){"@babel/helpers - typeof";return dc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dc(e)}function Xp(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(o){e[r+i]=o,i++})}}function Eu(e){e=e||{};for(var t=0,n=arguments.length<=1?0:arguments.length-1;t<n;t++){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];r&&Object.assign(e,r)}return e}var ah={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:zN,defaultDrawNodeLabel:T_,defaultDrawNodeHover:PN,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},w1={circle:Ka},_1={arrow:XN,line:n1};function $u(e){if(typeof e.labelDensity!="number"||e.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var t=e.minCameraRatio,n=e.maxCameraRatio;if(typeof t=="number"&&typeof n=="number"&&n<t)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function k1(e){var t=Eu({},ah,e);return t.nodeProgramClasses=Eu({},w1,t.nodeProgramClasses),t.edgeProgramClasses=Eu({},_1,t.edgeProgramClasses),t}var Jo=1.5,Qp=(function(e){function t(){var n;return ft(this,t),n=Ut(this,t),L(n,"x",.5),L(n,"y",.5),L(n,"angle",0),L(n,"ratio",1),L(n,"minRatio",null),L(n,"maxRatio",null),L(n,"enabledZooming",!0),L(n,"enabledPanning",!0),L(n,"enabledRotation",!0),L(n,"clean",null),L(n,"nextFrame",null),L(n,"previousState",null),L(n,"enabled",!0),n.previousState=n.getState(),n}return Gt(t,e),ht(t,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(r){return this.x===r.x&&this.y===r.y&&this.ratio===r.ratio&&this.angle===r.angle}},{key:"getPreviousState",value:function(){var r=this.previousState;return r?{x:r.x,y:r.y,angle:r.angle,ratio:r.ratio}:null}},{key:"getBoundedRatio",value:function(r){var i=r;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(r){var i={};return this.enabledPanning&&typeof r.x=="number"&&(i.x=r.x),this.enabledPanning&&typeof r.y=="number"&&(i.y=r.y),this.enabledZooming&&typeof r.ratio=="number"&&(i.ratio=this.getBoundedRatio(r.ratio)),this.enabledRotation&&typeof r.angle=="number"&&(i.angle=r.angle),this.clean?this.clean(X(X({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(r){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(r);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(r){return this.setState(r(this.getState())),this}},{key:"animate",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(!s)return new Promise(function(h){return i.animate(r,o,h)});if(this.enabled){var a=X(X({},p1),o),u=this.validateState(r),c=typeof a.easing=="function"?a.easing:h1[a.easing],l=Date.now(),d=this.getState(),f=function(){var p=(Date.now()-l)/a.duration;if(p>=1){i.nextFrame=null,i.setState(u),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var m=c(p),y={};typeof u.x=="number"&&(y.x=d.x+(u.x-d.x)*m),typeof u.y=="number"&&(y.y=d.y+(u.y-d.y)*m),i.enabledRotation&&typeof u.angle=="number"&&(y.angle=d.angle+(u.angle-d.angle)*m),typeof u.ratio=="number"&&(y.ratio=d.ratio+(u.ratio-d.ratio)*m),i.setState(y),i.nextFrame=requestAnimationFrame(f)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(f)):f(),this.animationCallback=s}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||Jo)},r):this.animate({ratio:this.ratio/Jo})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Jo)},r):this.animate({ratio:this.ratio*Jo})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return t.from(this.getState())}}],[{key:"from",value:function(r){var i=new t;return i.setState(r)}}])})(sh);function Vt(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function nn(e,t){var n=X(X({},Vt(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function Qr(e){var t="x"in e?e:X(X({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function S1(e,t){return X(X({},nn(e,t)),{},{delta:D_(e)})}var x1=2;function rs(e){for(var t=[],n=0,r=Math.min(e.length,x1);n<r;n++)t.push(e[n]);return t}function ei(e,t,n){var r={touches:rs(e.touches).map(function(i){return Vt(i,n)}),previousTouches:t.map(function(i){return Vt(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function D_(e){if(typeof e.deltaY<"u")return e.deltaY*-3/360;if(typeof e.detail<"u")return e.detail/-9;throw new Error("Captor: could not extract delta from event.")}var O_=(function(e){function t(n,r){var i;return ft(this,t),i=Ut(this,t),i.container=n,i.renderer=r,i}return Gt(t,e),ht(t)})(sh),E1=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],$1=E1.reduce(function(e,t){return X(X({},e),{},L({},t,ah[t]))},{}),T1=(function(e){function t(n,r){var i;return ft(this,t),i=Ut(this,t,[n,r]),L(i,"enabled",!0),L(i,"draggedEvents",0),L(i,"downStartTime",null),L(i,"lastMouseX",null),L(i,"lastMouseY",null),L(i,"isMouseDown",!1),L(i,"isMoving",!1),L(i,"movingTimeout",null),L(i,"startCameraState",null),L(i,"clicks",0),L(i,"doubleClickTimeout",null),L(i,"currentWheelDirection",0),L(i,"settings",$1),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),n.addEventListener("click",i.handleClick,{capture:!1}),n.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),n.addEventListener("mousedown",i.handleDown,{capture:!1}),n.addEventListener("wheel",i.handleWheel,{capture:!1}),n.addEventListener("mouseleave",i.handleLeave,{capture:!1}),n.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return Gt(t,e),ht(t,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("click",this.handleClick),r.removeEventListener("contextmenu",this.handleRightClick),r.removeEventListener("mousedown",this.handleDown),r.removeEventListener("wheel",this.handleWheel),r.removeEventListener("mouseleave",this.handleLeave),r.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(r){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(r);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",nn(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",nn(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=nn(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),s=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(Vt(r,this.container),s),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(r){if(this.enabled){if(r.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=Vt(r,this.container),o=i.x,s=i.y;this.lastMouseX=o,this.lastMouseY=s,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",nn(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var s=Vt(r,this.container),a=s.x,u=s.y,c=o.getState(),l=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:c.x+this.settings.inertiaRatio*(c.x-l.x),y:c.y+this.settings.inertiaRatio*(c.y-l.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==a||this.lastMouseY!==u)&&o.setState({x:c.x,y:c.y}),this.isMoving=!1,setTimeout(function(){var d=i.draggedEvents>0;i.draggedEvents=0,d&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",nn(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=nn(r,this.container);if(this.emit("mousemovebody",o),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var s=this.renderer.getCamera(),a=Vt(r,this.container),u=a.x,c=a.y,l=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:u,y:c}),f=l.x-d.x,h=l.y-d.y,p=s.getState(),m=p.x+f,y=p.y+h;s.setState({x:m,y}),this.lastMouseX=u,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",nn(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",nn(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var s=D_(r);if(s){var a=S1(r,this.container);if(this.emit("wheel",a),a.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var u=o.getState().ratio,c=s>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,l=o.getBoundedRatio(u*c),d=s>0?1:-1,f=Date.now();u!==l&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&f-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(Vt(r,this.container),l),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=f))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(O_),C1=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],A1=C1.reduce(function(e,t){return X(X({},e),{},L({},t,ah[t]))},{}),I1=(function(e){function t(n,r){var i;return ft(this,t),i=Ut(this,t,[n,r]),L(i,"enabled",!0),L(i,"isMoving",!1),L(i,"hasMoved",!1),L(i,"touchMode",0),L(i,"startTouchesPositions",[]),L(i,"lastTouches",[]),L(i,"lastTap",null),L(i,"settings",A1),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),n.addEventListener("touchstart",i.handleStart,{capture:!1}),n.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return Gt(t,e),ht(t,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("touchstart",this.handleStart),r.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(r){var i=this;if(this.enabled){r.preventDefault();var o=rs(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(h){return Vt(h,i.container)}),this.touchMode===2){var s=br(this.startTouchesPositions,2),a=s[0],u=a.x,c=a.y,l=s[1],d=l.x,f=l.y;this.startTouchesAngle=Math.atan2(f-c,d-u),this.startTouchesDistance=Math.sqrt(Math.pow(d-u,2)+Math.pow(f-c,2))}this.emit("touchdown",ei(r,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(r){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(r.cancelable&&r.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(r.touches.length===1){this.handleStart(r),r.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),o=i.getState(),s=i.getPreviousState()||{x:0,y:0};i.animate({x:o.x+this.settings.inertiaRatio*(o.x-s.x),y:o.y+this.settings.inertiaRatio*(o.y-s.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",ei(r,this.lastTouches,this.container)),!r.touches.length){var a=Vt(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],c=Math.pow(a.x-u.x,2)+Math.pow(a.y-u.y,2);if(!r.touches.length&&c<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var l=ei(r,this.lastTouches,this.container);if(this.emit("doubletap",l),this.lastTap=null,!l.sigmaDefaultPrevented){var d=this.renderer.getCamera(),f=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(a,f),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var h=ei(r,this.lastTouches,this.container);this.emit("tap",h),this.lastTap={time:Date.now(),position:h.touches[0]||h.previousTouches[0]}}}this.lastTouches=rs(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=rs(r.touches),s=o.map(function(I){return Vt(I,i.container)}),a=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=s;var u=ei(r,a,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=s.some(function(I,R){var U=i.startTouchesPositions[R];return U&&(I.x!==U.x||I.y!==U.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var c=this.renderer.getCamera(),l=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var f=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),h=f.x,p=f.y,m=this.renderer.viewportToFramedGraph(s[0]),y=m.x,w=m.y;c.setState({x:l.x+h-y,y:l.y+p-w});break}case 2:{var g={x:.5,y:.5,angle:0,ratio:1},b=s[0],v=b.x,k=b.y,_=s[1],$=_.x,O=_.y,M=Math.atan2(O-k,$-v)-this.startTouchesAngle,D=Math.hypot(O-k,$-v)/this.startTouchesDistance,J=c.getBoundedRatio(l.ratio/D);g.ratio=J,g.angle=l.angle+M;var se=this.getDimensions(),we=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:l}),_e=Math.min(se.width,se.height)-2*d,Ge=_e/se.width,F=_e/se.height,B=J/_e,W=v-_e/2/Ge,Q=k-_e/2/F,K=[W*Math.cos(-g.angle)-Q*Math.sin(-g.angle),Q*Math.cos(-g.angle)+W*Math.sin(-g.angle)];W=K[0],Q=K[1],g.x=we.x-W*B,g.y=we.y+Q*B,c.setState(g);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(O_);function N1(e){if(Array.isArray(e))return uc(e)}function R1(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function L1(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
421
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function em(e){return N1(e)||R1(e)||v_(e)||L1()}function z1(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Tu(e,t){if(e==null)return{};var n,r,i=z1(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var tm=(function(){function e(t,n){ft(this,e),this.key=t,this.size=n}return ht(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),nm=(function(){function e(){ft(this,e),L(this,"width",0),L(this,"height",0),L(this,"cellSize",0),L(this,"columns",0),L(this,"rows",0),L(this,"cells",{})}return ht(e,[{key:"resizeAndClear",value:function(n,r){this.width=n.width,this.height=n.height,this.cellSize=r,this.columns=Math.ceil(n.width/r),this.rows=Math.ceil(n.height/r),this.cells={}}},{key:"getIndex",value:function(n){var r=Math.floor(n.x/this.cellSize),i=Math.floor(n.y/this.cellSize);return i*this.columns+r}},{key:"add",value:function(n,r,i){var o=new tm(n,r),s=this.getIndex(i),a=this.cells[s];a||(a=[],this.cells[s]=a),a.push(o)}},{key:"organize",value:function(){for(var n in this.cells){var r=this.cells[n];r.sort(tm.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,o=i/n/n,s=o*r/i,a=Math.ceil(s),u=[];for(var c in this.cells)for(var l=this.cells[c],d=0;d<Math.min(a,l.length);d++)u.push(l[d].key);return u}}])})();function P1(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,o=[];return t.forEachEdge(function(s,a,u,c){(u===n||c===n||r.has(u)||r.has(c)||i.has(u)&&i.has(c))&&o.push(s)}),o}var rm=150,im=50,rn=Object.prototype.hasOwnProperty;function D1(e,t,n){if(!rn.call(n,"x")||!rn.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(t,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=e.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),rn.call(n,"hidden")||(n.hidden=!1),rn.call(n,"highlighted")||(n.highlighted=!1),rn.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function O1(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),rn.call(n,"hidden")||(n.hidden=!1),rn.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var M1=(function(e){function t(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(ft(this,t),i=Ut(this,t),L(i,"elements",{}),L(i,"canvasContexts",{}),L(i,"webGLContexts",{}),L(i,"pickingLayers",new Set),L(i,"textures",{}),L(i,"frameBuffers",{}),L(i,"activeListeners",{}),L(i,"labelGrid",new nm),L(i,"nodeDataCache",{}),L(i,"edgeDataCache",{}),L(i,"nodeProgramIndex",{}),L(i,"edgeProgramIndex",{}),L(i,"nodesWithForcedLabels",new Set),L(i,"edgesWithForcedLabels",new Set),L(i,"nodeExtent",{x:[0,1],y:[0,1]}),L(i,"nodeZExtent",[1/0,-1/0]),L(i,"edgeZExtent",[1/0,-1/0]),L(i,"matrix",Ht()),L(i,"invMatrix",Ht()),L(i,"correctionRatio",1),L(i,"customBBox",null),L(i,"normalizationFunction",Yp({x:[0,1],y:[0,1]})),L(i,"graphToViewportRatio",1),L(i,"itemIDsIndex",{}),L(i,"nodeIndices",{}),L(i,"edgeIndices",{}),L(i,"width",0),L(i,"height",0),L(i,"pixelRatio",Kp()),L(i,"pickingDownSizingRatio",2*i.pixelRatio),L(i,"displayedNodeLabels",new Set),L(i,"displayedEdgeLabels",new Set),L(i,"highlightedNodes",new Set),L(i,"hoveredNode",null),L(i,"hoveredEdge",null),L(i,"renderFrame",null),L(i,"renderHighlightedNodesFrame",null),L(i,"needToProcess",!1),L(i,"checkEdgesEventsFrame",null),L(i,"nodePrograms",{}),L(i,"nodeHoverPrograms",{}),L(i,"edgePrograms",{}),i.settings=k1(o),$u(i.settings),v1(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var s in i.settings.nodeProgramClasses)i.registerNodeProgram(s,i.settings.nodeProgramClasses[s],i.settings.nodeHoverProgramClasses[s]);for(var a in i.settings.edgeProgramClasses)i.registerEdgeProgram(a,i.settings.edgeProgramClasses[a]);return i.camera=new Qp,i.bindCameraHandlers(),i.mouseCaptor=new T1(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new I1(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Gt(t,e),ht(t,[{key:"registerNodeProgram",value:function(r,i,o){return this.nodePrograms[r]&&this.nodePrograms[r].kill(),this.nodeHoverPrograms[r]&&this.nodeHoverPrograms[r].kill(),this.nodePrograms[r]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[r]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(r,i){return this.edgePrograms[r]&&this.edgePrograms[r].kill(),this.edgePrograms[r]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(r){if(this.nodePrograms[r]){var i=this.nodePrograms,o=i[r],s=Tu(i,[r].map(si));o.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[r]){var a=this.nodeHoverPrograms,u=a[r],c=Tu(a,[r].map(si));u.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],s=Tu(i,[r].map(si));o.kill(),this.edgePrograms=s}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],o=this.frameBuffers[r],s=this.textures[r];s&&i.deleteTexture(s);var a=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,a),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,a,0),this.textures[r]=a,this}},{key:"bindCameraHandlers",value:function(){var r=this;return this.activeListeners.camera=function(){r.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(r){var i=r.x,o=r.y,s=Op(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),a=Dp.apply(void 0,em(s)),u=this.itemIDsIndex[a];return u&&u.type==="node"?u.id:null}},{key:"bindEventHandlers",value:function(){var r=this;this.activeListeners.handleResize=function(){r.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var s=Qr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}},u=r.getNodeAtPosition(s);if(u&&r.hoveredNode!==u&&!r.nodeDataCache[u].hidden){r.hoveredNode&&r.emit("leaveNode",X(X({},a),{},{node:r.hoveredNode})),r.hoveredNode=u,r.emit("enterNode",X(X({},a),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(s)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",X(X({},a),{},{node:c})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var l=r.hoveredNode?null:r.getEdgeAtPoint(a.event.x,a.event.y);l!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",X(X({},a),{},{edge:r.hoveredEdge})),l&&r.emit("enterEdge",X(X({},a),{},{edge:l})),r.hoveredEdge=l)}},this.activeListeners.handleMoveBody=function(o){var s=Qr(o);r.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var s=Qr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",X(X({},a),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",X(X({},a),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",X({},a))},this.activeListeners.handleEnter=function(o){var s=Qr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.emit("enterStage",X({},a))};var i=function(s){return function(a){var u=Qr(a),c={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},l=r.getNodeAtPosition(u);if(l)return r.emit("".concat(s,"Node"),X(X({},c),{},{node:l}));if(r.settings.enableEdgeEvents){var d=r.getEdgeAtPoint(u.x,u.y);if(d)return r.emit("".concat(s,"Edge"),X(X({},c),{},{edge:d}))}return r.emit("".concat(s,"Stage"),c)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var r=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(s){var a,u=(a=s.hints)===null||a===void 0?void 0:a.attributes;r.graph.forEachNode(function(l){return r.updateNode(l)});var c=!u||u.some(function(l){return o.has(l)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!c,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(s){var a,u=(a=s.hints)===null||a===void 0?void 0:a.attributes;r.graph.forEachEdge(function(l){return r.updateEdge(l)});var c=u&&["zIndex","type"].some(function(l){return u?.includes(l)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!c,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(s){var a=s.key;r.addNode(a),r.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(s){var a=s.key;r.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(s){var a=s.key;r.removeNode(a),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(s){var a=s.key;r.addEdge(a),r.refresh({partialGraph:{edges:[a]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(s){var a=s.key;r.refresh({partialGraph:{edges:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(s){var a=s.key;r.removeEdge(a),r.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){r.clearEdgeState(),r.clearEdgeIndices(),r.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){r.clearEdgeState(),r.clearNodeState(),r.clearEdgeIndices(),r.clearNodeIndices(),r.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var r=this.graph;r.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(r,i){var o=Op(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),s=Dp.apply(void 0,em(o)),a=this.itemIDsIndex[s];return a&&a.type==="edge"?a.id:null}},{key:"process",value:function(){var r=this;this.emit("beforeProcess");var i=this.graph,o=this.settings,s=this.getDimensions();if(this.nodeExtent=y1(this.graph),!this.settings.autoRescale){var a=s.width,u=s.height,c=this.nodeExtent,l=c.x,d=c.y;this.nodeExtent={x:[(l[0]+l[1])/2-a/2,(l[0]+l[1])/2+a/2],y:[(d[0]+d[1])/2-u/2,(d[0]+d[1])/2+u/2]}}this.normalizationFunction=Yp(this.customBBox||this.nodeExtent);var f=new Qp,h=Xr(f.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,o.labelGridCellSize);for(var p={},m={},y={},w={},g=1,b=i.nodes(),v=0,k=b.length;v<k;v++){var _=b[v],$=this.nodeDataCache[_],O=i.getNodeAttributes(_);$.x=O.x,$.y=O.y,this.normalizationFunction.applyTo($),typeof $.label=="string"&&!$.hidden&&this.labelGrid.add(_,$.size,this.framedGraphToViewport($,{matrix:h})),p[$.type]=(p[$.type]||0)+1}this.labelGrid.organize();for(var M in this.nodePrograms){if(!rn.call(this.nodePrograms,M))throw new Error('Sigma: could not find a suitable program for node type "'.concat(M,'"!'));this.nodePrograms[M].reallocate(p[M]||0),p[M]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(b=Jp(this.nodeZExtent,function(ce){return r.nodeDataCache[ce].zIndex},b));for(var D=0,J=b.length;D<J;D++){var se=b[D];m[se]=g,w[m[se]]={type:"node",id:se},g++;var we=this.nodeDataCache[se];this.addNodeToProgram(se,m[se],p[we.type]++)}for(var _e={},Ge=i.edges(),F=0,B=Ge.length;F<B;F++){var W=Ge[F],Q=this.edgeDataCache[W];_e[Q.type]=(_e[Q.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(Ge=Jp(this.edgeZExtent,function(ce){return r.edgeDataCache[ce].zIndex},Ge));for(var K in this.edgePrograms){if(!rn.call(this.edgePrograms,K))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(K,'"!'));this.edgePrograms[K].reallocate(_e[K]||0),_e[K]=0}for(var I=0,R=Ge.length;I<R;I++){var U=Ge[I];y[U]=g,w[y[U]]={type:"edge",id:U},g++;var ne=this.edgeDataCache[U];this.addEdgeToProgram(U,y[U],_e[ne.type]++)}return this.itemIDsIndex=w,this.nodeIndices=m,this.edgeIndices=y,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(l){return i.cleanCameraState(l,o.cameraPanBoundaries&&dc(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==o.edgeProgramClasses){for(var s in o.edgeProgramClasses)o.edgeProgramClasses[s]!==r.edgeProgramClasses[s]&&this.registerEdgeProgram(s,o.edgeProgramClasses[s]);for(var a in r.edgeProgramClasses)o.edgeProgramClasses[a]||this.unregisterEdgeProgram(a)}if(r.nodeProgramClasses!==o.nodeProgramClasses||r.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var u in o.nodeProgramClasses)(o.nodeProgramClasses[u]!==r.nodeProgramClasses[u]||o.nodeHoverProgramClasses[u]!==r.nodeHoverProgramClasses[u])&&this.registerNodeProgram(u,o.nodeProgramClasses[u],o.nodeHoverProgramClasses[u]);for(var c in r.nodeProgramClasses)o.nodeProgramClasses[c]||this.unregisterNodeProgram(c)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,s=o===void 0?0:o,a=i.boundaries,u=X({},r),c=a||this.nodeExtent,l=br(c.x,2),d=l[0],f=l[1],h=br(c.y,2),p=h[0],m=h[1],y=[this.graphToViewport({x:d,y:p},{cameraState:r}),this.graphToViewport({x:f,y:p},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r}),this.graphToViewport({x:f,y:m},{cameraState:r})],w=1/0,g=-1/0,b=1/0,v=-1/0;y.forEach(function(_e){var Ge=_e.x,F=_e.y;w=Math.min(w,Ge),g=Math.max(g,Ge),b=Math.min(b,F),v=Math.max(v,F)});var k=g-w,_=v-b,$=this.getDimensions(),O=$.width,M=$.height,D=0,J=0;if(k>=O?g<O-s?D=g-(O-s):w>s&&(D=w-s):g>O+s?D=g-(O+s):w<-s&&(D=w+s),_>=M?v<M-s?J=v-(M-s):b>s&&(J=b-s):v>M+s?J=v-(M+s):b<-s&&(J=b+s),D||J){var se=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),we=this.viewportToFramedGraph({x:D,y:J},{cameraState:r});D=we.x-se.x,J=we.y-se.y,u.x+=D,u.y+=J}return u}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var r=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(r.ratio,this.settings.labelDensity);Xp(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,s=0,a=i.length;s<a;s++){var u=i[s],c=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!c.hidden){var l=this.framedGraphToViewport(c),d=l.x,f=l.y,h=this.scaleSize(c.size);if(!(!c.forceLabel&&h<this.settings.labelRenderedSizeThreshold)&&!(d<-rm||d>this.width+rm||f<-im||f>this.height+im)){this.displayedNodeLabels.add(u);var p=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[c.type],y=m?.drawLabel||p;y(o,X(X({key:u},c),{},{size:h,x:d,y:f}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var r=this.canvasContexts.edgeLabels;r.clearRect(0,0,this.width,this.height);var i=P1({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});Xp(i,this.edgesWithForcedLabels);for(var o=new Set,s=0,a=i.length;s<a;s++){var u=i[s],c=this.graph.extremities(u),l=this.nodeDataCache[c[0]],d=this.nodeDataCache[c[1]],f=this.edgeDataCache[u];if(!o.has(u)&&!(f.hidden||l.hidden||d.hidden)){var h=this.settings.defaultDrawEdgeLabel,p=this.edgePrograms[f.type],m=p?.drawLabel||h;m(r,X(X({key:u},f),{},{size:this.scaleSize(f.size)}),X(X(X({key:c[0]},l),this.framedGraphToViewport(l)),{},{size:this.scaleSize(l.size)}),X(X(X({key:c[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),o.add(u)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(h){var p=r.nodeDataCache[h],m=r.framedGraphToViewport(p),y=m.x,w=m.y,g=r.scaleSize(p.size),b=r.settings.defaultDrawNodeHover,v=r.nodePrograms[p.type],k=v?.drawHover||b;k(i,X(X({key:h},p),{},{size:g,x:y,y:w}),r.settings)},s=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&s.push(this.hoveredNode),this.highlightedNodes.forEach(function(f){f!==r.hoveredNode&&s.push(f)}),s.forEach(function(f){return o(f)});var a={};s.forEach(function(f){var h=r.nodeDataCache[f].type;a[h]=(a[h]||0)+1});for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].reallocate(a[u]||0),a[u]=0;s.forEach(function(f){var h=r.nodeDataCache[f];r.nodeHoverPrograms[h.type].process(0,a[h.type]++,h)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var c=this.getRenderParams();for(var l in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[l];d.render(c)}}},{key:"scheduleHighlightedNodesRender",value:function(){var r=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){r.renderHighlightedNodesFrame=null,r.renderHighlightedNodes(),r.renderEdgeLabels()}))}},{key:"render",value:function(){var r=this;this.emit("beforeRender");var i=function(){return r.emit("afterRender"),r};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(y){return r.resetWebGLTexture(y)}),!this.graph.order)return i();var o=this.mouseCaptor,s=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,a=this.camera.getState(),u=this.getDimensions(),c=this.getGraphDimensions(),l=this.getStagePadding();this.matrix=Xr(a,u,c,l),this.invMatrix=Xr(a,u,c,l,!0),this.correctionRatio=g1(this.matrix,a,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var f in this.nodePrograms){var h=this.nodePrograms[f];h.render(d)}if(!this.settings.hideEdgesOnMove||!s)for(var p in this.edgePrograms){var m=this.edgePrograms[p];m.render(d)}return this.settings.hideLabelsOnMove&&s||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(r){var i=Object.assign({},this.graph.getNodeAttributes(r));this.settings.nodeReducer&&(i=this.settings.nodeReducer(r,i));var o=D1(this.settings,r,i);this.nodeDataCache[r]=o,this.nodesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(r),this.highlightedNodes.delete(r),o.highlighted&&!o.hidden&&this.highlightedNodes.add(r),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(r){this.addNode(r);var i=this.nodeDataCache[r];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(r){delete this.nodeDataCache[r],delete this.nodeProgramIndex[r],this.highlightedNodes.delete(r),this.hoveredNode===r&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(r)}},{key:"addEdge",value:function(r){var i=Object.assign({},this.graph.getEdgeAttributes(r));this.settings.edgeReducer&&(i=this.settings.edgeReducer(r,i));var o=O1(this.settings,r,i);this.edgeDataCache[r]=o,this.edgesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(r),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(r){this.addEdge(r)}},{key:"removeEdge",value:function(r){delete this.edgeDataCache[r],delete this.edgeProgramIndex[r],this.hoveredEdge===r&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(r)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new nm,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(r,i,o){var s=this.nodeDataCache[r],a=this.nodePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for node type "'.concat(s.type,'"!'));a.process(i,o,s),this.nodeProgramIndex[r]=o}},{key:"addEdgeToProgram",value:function(r,i,o){var s=this.edgeDataCache[r],a=this.edgePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(s.type,'"!'));var u=this.graph.extremities(r),c=this.nodeDataCache[u[0]],l=this.nodeDataCache[u[1]];a.process(i,o,c,l,s),this.edgeProgramIndex[r]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var r=this.settings,i=r.stagePadding,o=r.autoRescale;return o&&i||0}},{key:"createLayer",value:function(r,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[r])throw new Error('Sigma: a layer named "'.concat(r,'" already exists'));var s=b1(i,{position:"absolute"},{class:"sigma-".concat(r)});return o.style&&Object.assign(s.style,o.style),this.elements[r]=s,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(s):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(s):this.container.appendChild(s),s}},{key:"createCanvas",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(r,"canvas",i)}},{key:"createCanvasContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(r,i),s={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=o.getContext("2d",s),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i?.canvas||this.createCanvas(r,i);i.hidden&&o.remove();var s=X({preserveDrawingBuffer:!1,antialias:!1},i),a;a=o.getContext("webgl2",s),a||(a=o.getContext("webgl",s)),a||(a=o.getContext("experimental-webgl",s));var u=a;if(this.webGLContexts[r]=u,u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var c=u.createFramebuffer();if(!c)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=c}return u}},{key:"killLayer",value:function(r){var i=this.elements[r];if(!i)throw new Error("Sigma: cannot kill layer ".concat(r,", which does not exist"));if(this.webGLContexts[r]){var o,s=this.webGLContexts[r];(o=s.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[r]}else this.canvasContexts[r]&&delete this.canvasContexts[r];return i.remove(),delete this.elements[r],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(r){this.unbindCameraHandlers(),this.camera=r,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(r){r!==this.graph&&(this.hoveredNode&&!r.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!r.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=r,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var r=this.customBBox||this.nodeExtent;return{width:r.x[1]-r.x[0]||1,height:r.y[1]-r.y[0]||1}}},{key:"getNodeDisplayData",value:function(r){var i=this.nodeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(r){var i=this.edgeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return X({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=X({},this.settings);return this.settings[r]=i,$u(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(r,i){return this.setSetting(r,i(this.settings[r])),this}},{key:"setSettings",value:function(r){var i=X({},this.settings);return this.settings=X(X({},this.settings),r),$u(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=Kp(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!r&&i===this.width&&o===this.height)return this;for(var s in this.elements){var a=this.elements[s];a.style.width=this.width+"px",a.style.height=this.height+"px"}for(var u in this.canvasContexts)this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[u].scale(this.pixelRatio,this.pixelRatio);for(var c in this.webGLContexts){this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px");var l=this.webGLContexts[c];if(l.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(c)){var d=this.textures[c];d&&l.deleteTexture(d)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(r){var i=this,o=r?.skipIndexation!==void 0?r?.skipIndexation:!1,s=r?.schedule!==void 0?r.schedule:!1,a=!r||!r.partialGraph;if(a)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(v){return i.addNode(v)}),this.graph.forEachEdge(function(v){return i.addEdge(v)});else{for(var u,c,l=((u=r.partialGraph)===null||u===void 0?void 0:u.nodes)||[],d=0,f=l?.length||0;d<f;d++){var h=l[d];if(this.updateNode(h),o){var p=this.nodeProgramIndex[h];if(p===void 0)throw new Error('Sigma: node "'.concat(h,`" can't be repaint`));this.addNodeToProgram(h,this.nodeIndices[h],p)}}for(var m=(r==null||(c=r.partialGraph)===null||c===void 0?void 0:c.edges)||[],y=0,w=m.length;y<w;y++){var g=m[y];if(this.updateEdge(g),o){var b=this.edgeProgramIndex[g];if(b===void 0)throw new Error('Sigma: edge "'.concat(g,`" can't be repaint`));this.addEdgeToProgram(g,this.edgeIndices[g],b)}}}return(a||!o)&&(this.needToProcess=!0),s?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var r=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){r.render()})),this}},{key:"scheduleRefresh",value:function(r){return this.refresh(X(X({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),s=o.ratio,a=o.angle,u=o.x,c=o.y,l=this.settings,d=l.minCameraRatio,f=l.maxCameraRatio;typeof f=="number"&&(i=Math.min(i,f)),typeof d=="number"&&(i=Math.max(i,d));var h=i/s,p={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(r),y=this.viewportToFramedGraph(p);return{angle:a,x:(m.x-y.x)*(1-h)+u,y:(m.y-y.y)*(1-h)+c,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,s=i.matrix?i.matrix:o?Xr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,a=lc(s,r);return{x:(1+a.x)*this.width/2,y:(1-a.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,s=i.matrix?i.matrix:o?Xr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,a=lc(s,{x:r.x/this.width*2-1,y:1-r.y/this.height*2});return isNaN(a.x)&&(a.x=0),isNaN(a.y)&&(a.y=0),a}},{key:"viewportToGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(r,i))}},{key:"graphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(r),i)}},{key:"getGraphToViewportRatio",value:function(){var r={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),s=this.graphToViewport(r),a=this.graphToViewport(i),u=Math.sqrt(Math.pow(s.x-a.x,2)+Math.pow(s.y-a.y,2));return u/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(r){return this.customBBox=r,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var r=this.container;r.firstChild;)r.removeChild(r.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var s in this.edgePrograms)this.edgePrograms[s].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var a in this.elements)this.killLayer(a);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return r/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var r={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(r[i]=this.elements[i]);return r}}])})(sh),F1=M1;function U1(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function M_(e){var t=U1(e,"string");return typeof t=="symbol"?t:t+""}function F_(e,t,n){return(t=M_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function om(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function vs(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?om(Object(n),!0).forEach(function(r){F_(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):om(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function G1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function j1(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,M_(r.key),r)}}function Z1(e,t,n){return t&&j1(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function bs(e){return bs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},bs(e)}function U_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(U_=function(){return!!e})()}function G_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function B1(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return G_(e)}function H1(e,t,n){return t=bs(t),B1(e,U_()?Reflect.construct(t,n||[],bs(e).constructor):t.apply(e,n))}function fc(e,t){return fc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},fc(e,t)}function V1(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&fc(e,t)}function hc(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function q1(e){if(Array.isArray(e))return hc(e)}function W1(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function K1(e,t){if(e){if(typeof e=="string")return hc(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?hc(e,t):void 0}}function J1(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
422
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Cu(e){return
|
|
420
|
+
`,s1=o1,M_=WebGLRenderingContext,qp=M_.UNSIGNED_BYTE,Yr=M_.FLOAT,a1=["u_matrix","u_zoomRatio","u_sizeRatio","u_correctionRatio","u_pixelRatio","u_feather","u_minEdgeThickness"],u1=(function(e){function t(){return ft(this,t),Ut(this,t,arguments)}return Gt(t,e),ht(t,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:s1,FRAGMENT_SHADER_SOURCE:z_,METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:a1,ATTRIBUTES:[{name:"a_positionStart",size:2,type:Yr},{name:"a_positionEnd",size:2,type:Yr},{name:"a_normal",size:2,type:Yr},{name:"a_color",size:4,type:qp,normalized:!0},{name:"a_id",size:4,type:qp,normalized:!0}],CONSTANT_ATTRIBUTES:[{name:"a_positionCoef",size:1,type:Yr},{name:"a_normalCoef",size:1,type:Yr}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[1,1],[0,-1],[1,-1]]}}},{key:"processVisibleItem",value:function(r,i,o,s,a){var u=a.size||1,c=o.x,l=o.y,d=s.x,f=s.y,h=Rn(a.color),p=d-c,m=f-l,y=p*p+m*m,w=0,g=0;y&&(y=1/Math.sqrt(y),w=-m*y*u,g=p*y*u);var b=this.array;b[i++]=c,b[i++]=l,b[i++]=d,b[i++]=f,b[i++]=w,b[i++]=g,b[i++]=h,b[i++]=r}},{key:"setUniforms",value:function(r,i){var o=i.gl,s=i.uniformLocations,a=s.u_matrix,u=s.u_zoomRatio,c=s.u_feather,l=s.u_pixelRatio,d=s.u_correctionRatio,f=s.u_sizeRatio,h=s.u_minEdgeThickness;o.uniformMatrix3fv(a,!1,r.matrix),o.uniform1f(u,r.zoomRatio),o.uniform1f(f,r.sizeRatio),o.uniform1f(d,r.correctionRatio),o.uniform1f(l,r.pixelRatio),o.uniform1f(c,r.antiAliasingFeather),o.uniform1f(h,r.minEdgeThickness)}}])})(Wa),sh=(function(e){function t(){var n;return ft(this,t),n=Ut(this,t),n.rawEmitter=n,n}return Gt(t,e),ht(t)})(o_.EventEmitter),Eu,Wp;function c1(){return Wp||(Wp=1,Eu=function(t){return t!==null&&typeof t=="object"&&typeof t.addUndirectedEdgeWithKey=="function"&&typeof t.dropNode=="function"&&typeof t.multi=="boolean"}),Eu}var l1=c1();const d1=gI(l1);var f1=function(t){return t},h1=function(t){return t*t},p1=function(t){return t*(2-t)},m1=function(t){return(t*=2)<1?.5*t*t:-.5*(--t*(t-2)-1)},g1=function(t){return t*t*t},y1=function(t){return--t*t*t+1},v1=function(t){return(t*=2)<1?.5*t*t*t:.5*((t-=2)*t*t+2)},b1={linear:f1,quadraticIn:h1,quadraticOut:p1,quadraticInOut:m1,cubicIn:g1,cubicOut:y1,cubicInOut:v1},w1={easing:"quadraticInOut",duration:150};function Vt(){return Float32Array.of(1,0,0,0,1,0,0,0,1)}function Ko(e,t,n){return e[0]=t,e[4]=typeof n=="number"?n:t,e}function Kp(e,t){var n=Math.sin(t),r=Math.cos(t);return e[0]=r,e[1]=n,e[3]=-n,e[4]=r,e}function Jp(e,t,n){return e[6]=t,e[7]=n,e}function bn(e,t){var n=e[0],r=e[1],i=e[2],o=e[3],s=e[4],a=e[5],u=e[6],c=e[7],l=e[8],d=t[0],f=t[1],h=t[2],p=t[3],m=t[4],y=t[5],w=t[6],g=t[7],b=t[8];return e[0]=d*n+f*o+h*u,e[1]=d*r+f*s+h*c,e[2]=d*i+f*a+h*l,e[3]=p*n+m*o+y*u,e[4]=p*r+m*s+y*c,e[5]=p*i+m*a+y*l,e[6]=w*n+g*o+b*u,e[7]=w*r+g*s+b*c,e[8]=w*i+g*a+b*l,e}function lc(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,r=e[0],i=e[1],o=e[3],s=e[4],a=e[6],u=e[7],c=t.x,l=t.y;return{x:c*r+l*o+a*n,y:c*i+l*s+u*n}}function _1(e,t){var n=e.height/e.width,r=t.height/t.width;return n<1&&r>1||n>1&&r<1?1:Math.min(Math.max(r,1/r),Math.max(1/n,n))}function Xr(e,t,n,r,i){var o=e.angle,s=e.ratio,a=e.x,u=e.y,c=t.width,l=t.height,d=Vt(),f=Math.min(c,l)-2*r,h=_1(t,n);return i?(bn(d,Jp(Vt(),a,u)),bn(d,Ko(Vt(),s)),bn(d,Kp(Vt(),o)),bn(d,Ko(Vt(),c/f/2/h,l/f/2/h))):(bn(d,Ko(Vt(),2*(f/c)*h,2*(f/l)*h)),bn(d,Kp(Vt(),-o)),bn(d,Ko(Vt(),1/s)),bn(d,Jp(Vt(),-a,-u))),d}function k1(e,t,n){var r=lc(e,{x:Math.cos(t.angle),y:Math.sin(t.angle)},0),i=r.x,o=r.y;return 1/Math.sqrt(Math.pow(i,2)+Math.pow(o,2))/n.width}function S1(e){if(!e.order)return{x:[0,1],y:[0,1]};var t=1/0,n=-1/0,r=1/0,i=-1/0;return e.forEachNode(function(o,s){var a=s.x,u=s.y;a<t&&(t=a),a>n&&(n=a),u<r&&(r=u),u>i&&(i=u)}),{x:[t,n],y:[r,i]}}function E1(e){if(!d1(e))throw new Error("Sigma: invalid graph instance.");e.forEachNode(function(t,n){if(!Number.isFinite(n.x)||!Number.isFinite(n.y))throw new Error("Sigma: Coordinates of node ".concat(t," are invalid. A node must have a numeric 'x' and 'y' attribute."))})}function x1(e,t,n){var r=document.createElement(e);if(t)for(var i in t)r.style[i]=t[i];if(n)for(var o in n)r.setAttribute(o,n[o]);return r}function Yp(){return typeof window.devicePixelRatio<"u"?window.devicePixelRatio:1}function Xp(e,t,n){return n.sort(function(r,i){var o=t(r)||0,s=t(i)||0;return o<s?-1:o>s?1:0})}function Qp(e){var t=br(e.x,2),n=t[0],r=t[1],i=br(e.y,2),o=i[0],s=i[1],a=Math.max(r-n,s-o),u=(r+n)/2,c=(s+o)/2;(a===0||Math.abs(a)===1/0||isNaN(a))&&(a=1),isNaN(u)&&(u=0),isNaN(c)&&(c=0);var l=function(f){return{x:.5+(f.x-u)/a,y:.5+(f.y-c)/a}};return l.applyTo=function(d){d.x=.5+(d.x-u)/a,d.y=.5+(d.y-c)/a},l.inverse=function(d){return{x:u+a*(d.x-.5),y:c+a*(d.y-.5)}},l.ratio=a,l}function dc(e){"@babel/helpers - typeof";return dc=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},dc(e)}function em(e,t){var n=t.size;if(n!==0){var r=e.length;e.length+=n;var i=0;t.forEach(function(o){e[r+i]=o,i++})}}function xu(e){e=e||{};for(var t=0,n=arguments.length<=1?0:arguments.length-1;t<n;t++){var r=t+1<1||arguments.length<=t+1?void 0:arguments[t+1];r&&Object.assign(e,r)}return e}var ah={hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderLabels:!0,renderEdgeLabels:!1,enableEdgeEvents:!1,defaultNodeColor:"#999",defaultNodeType:"circle",defaultEdgeColor:"#ccc",defaultEdgeType:"line",labelFont:"Arial",labelSize:14,labelWeight:"normal",labelColor:{color:"#000"},edgeLabelFont:"Arial",edgeLabelSize:14,edgeLabelWeight:"normal",edgeLabelColor:{attribute:"color"},stagePadding:30,defaultDrawEdgeLabel:UN,defaultDrawNodeLabel:I_,defaultDrawNodeHover:GN,minEdgeThickness:1.7,antiAliasingFeather:1,dragTimeout:100,draggedEventsTolerance:3,inertiaDuration:200,inertiaRatio:3,zoomDuration:250,zoomingRatio:1.7,doubleClickTimeout:300,doubleClickZoomingRatio:2.2,doubleClickZoomingDuration:200,tapMoveTolerance:10,zoomToSizeRatioFunction:Math.sqrt,itemSizesReference:"screen",autoRescale:!0,autoCenter:!0,labelDensity:1,labelGridCellSize:100,labelRenderedSizeThreshold:6,nodeReducer:null,edgeReducer:null,zIndex:!1,minCameraRatio:null,maxCameraRatio:null,enableCameraZooming:!0,enableCameraPanning:!0,enableCameraRotation:!0,cameraPanBoundaries:null,allowInvalidContainer:!1,nodeProgramClasses:{},nodeHoverProgramClasses:{},edgeProgramClasses:{}},$1={circle:Ka},T1={arrow:i1,line:u1};function $u(e){if(typeof e.labelDensity!="number"||e.labelDensity<0)throw new Error("Settings: invalid `labelDensity`. Expecting a positive number.");var t=e.minCameraRatio,n=e.maxCameraRatio;if(typeof t=="number"&&typeof n=="number"&&n<t)throw new Error("Settings: invalid camera ratio boundaries. Expecting `maxCameraRatio` to be greater than `minCameraRatio`.")}function C1(e){var t=xu({},ah,e);return t.nodeProgramClasses=xu({},$1,t.nodeProgramClasses),t.edgeProgramClasses=xu({},T1,t.edgeProgramClasses),t}var Jo=1.5,tm=(function(e){function t(){var n;return ft(this,t),n=Ut(this,t),L(n,"x",.5),L(n,"y",.5),L(n,"angle",0),L(n,"ratio",1),L(n,"minRatio",null),L(n,"maxRatio",null),L(n,"enabledZooming",!0),L(n,"enabledPanning",!0),L(n,"enabledRotation",!0),L(n,"clean",null),L(n,"nextFrame",null),L(n,"previousState",null),L(n,"enabled",!0),n.previousState=n.getState(),n}return Gt(t,e),ht(t,[{key:"enable",value:function(){return this.enabled=!0,this}},{key:"disable",value:function(){return this.enabled=!1,this}},{key:"getState",value:function(){return{x:this.x,y:this.y,angle:this.angle,ratio:this.ratio}}},{key:"hasState",value:function(r){return this.x===r.x&&this.y===r.y&&this.ratio===r.ratio&&this.angle===r.angle}},{key:"getPreviousState",value:function(){var r=this.previousState;return r?{x:r.x,y:r.y,angle:r.angle,ratio:r.ratio}:null}},{key:"getBoundedRatio",value:function(r){var i=r;return typeof this.minRatio=="number"&&(i=Math.max(i,this.minRatio)),typeof this.maxRatio=="number"&&(i=Math.min(i,this.maxRatio)),i}},{key:"validateState",value:function(r){var i={};return this.enabledPanning&&typeof r.x=="number"&&(i.x=r.x),this.enabledPanning&&typeof r.y=="number"&&(i.y=r.y),this.enabledZooming&&typeof r.ratio=="number"&&(i.ratio=this.getBoundedRatio(r.ratio)),this.enabledRotation&&typeof r.angle=="number"&&(i.angle=r.angle),this.clean?this.clean(X(X({},this.getState()),i)):i}},{key:"isAnimated",value:function(){return!!this.nextFrame}},{key:"setState",value:function(r){if(!this.enabled)return this;this.previousState=this.getState();var i=this.validateState(r);return typeof i.x=="number"&&(this.x=i.x),typeof i.y=="number"&&(this.y=i.y),typeof i.ratio=="number"&&(this.ratio=i.ratio),typeof i.angle=="number"&&(this.angle=i.angle),this.hasState(this.previousState)||this.emit("updated",this.getState()),this}},{key:"updateState",value:function(r){return this.setState(r(this.getState())),this}},{key:"animate",value:function(r){var i=this,o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},s=arguments.length>2?arguments[2]:void 0;if(!s)return new Promise(function(h){return i.animate(r,o,h)});if(this.enabled){var a=X(X({},w1),o),u=this.validateState(r),c=typeof a.easing=="function"?a.easing:b1[a.easing],l=Date.now(),d=this.getState(),f=function(){var p=(Date.now()-l)/a.duration;if(p>=1){i.nextFrame=null,i.setState(u),i.animationCallback&&(i.animationCallback.call(null),i.animationCallback=void 0);return}var m=c(p),y={};typeof u.x=="number"&&(y.x=d.x+(u.x-d.x)*m),typeof u.y=="number"&&(y.y=d.y+(u.y-d.y)*m),i.enabledRotation&&typeof u.angle=="number"&&(y.angle=d.angle+(u.angle-d.angle)*m),typeof u.ratio=="number"&&(y.ratio=d.ratio+(u.ratio-d.ratio)*m),i.setState(y),i.nextFrame=requestAnimationFrame(f)};this.nextFrame?(cancelAnimationFrame(this.nextFrame),this.animationCallback&&this.animationCallback.call(null),this.nextFrame=requestAnimationFrame(f)):f(),this.animationCallback=s}}},{key:"animatedZoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio/r}):this.animate({ratio:this.ratio/(r.factor||Jo)},r):this.animate({ratio:this.ratio/Jo})}},{key:"animatedUnzoom",value:function(r){return r?typeof r=="number"?this.animate({ratio:this.ratio*r}):this.animate({ratio:this.ratio*(r.factor||Jo)},r):this.animate({ratio:this.ratio*Jo})}},{key:"animatedReset",value:function(r){return this.animate({x:.5,y:.5,ratio:1,angle:0},r)}},{key:"copy",value:function(){return t.from(this.getState())}}],[{key:"from",value:function(r){var i=new t;return i.setState(r)}}])})(sh);function qt(e,t){var n=t.getBoundingClientRect();return{x:e.clientX-n.left,y:e.clientY-n.top}}function rn(e,t){var n=X(X({},qt(e,t)),{},{sigmaDefaultPrevented:!1,preventSigmaDefault:function(){n.sigmaDefaultPrevented=!0},original:e});return n}function Qr(e){var t="x"in e?e:X(X({},e.touches[0]||e.previousTouches[0]),{},{original:e.original,sigmaDefaultPrevented:e.sigmaDefaultPrevented,preventSigmaDefault:function(){e.sigmaDefaultPrevented=!0,t.sigmaDefaultPrevented=!0}});return t}function A1(e,t){return X(X({},rn(e,t)),{},{delta:F_(e)})}var I1=2;function rs(e){for(var t=[],n=0,r=Math.min(e.length,I1);n<r;n++)t.push(e[n]);return t}function ei(e,t,n){var r={touches:rs(e.touches).map(function(i){return qt(i,n)}),previousTouches:t.map(function(i){return qt(i,n)}),sigmaDefaultPrevented:!1,preventSigmaDefault:function(){r.sigmaDefaultPrevented=!0},original:e};return r}function F_(e){if(typeof e.deltaY<"u")return e.deltaY*-3/360;if(typeof e.detail<"u")return e.detail/-9;throw new Error("Captor: could not extract delta from event.")}var U_=(function(e){function t(n,r){var i;return ft(this,t),i=Ut(this,t),i.container=n,i.renderer=r,i}return Gt(t,e),ht(t)})(sh),N1=["doubleClickTimeout","doubleClickZoomingDuration","doubleClickZoomingRatio","dragTimeout","draggedEventsTolerance","inertiaDuration","inertiaRatio","zoomDuration","zoomingRatio"],R1=N1.reduce(function(e,t){return X(X({},e),{},L({},t,ah[t]))},{}),L1=(function(e){function t(n,r){var i;return ft(this,t),i=Ut(this,t,[n,r]),L(i,"enabled",!0),L(i,"draggedEvents",0),L(i,"downStartTime",null),L(i,"lastMouseX",null),L(i,"lastMouseY",null),L(i,"isMouseDown",!1),L(i,"isMoving",!1),L(i,"movingTimeout",null),L(i,"startCameraState",null),L(i,"clicks",0),L(i,"doubleClickTimeout",null),L(i,"currentWheelDirection",0),L(i,"settings",R1),i.handleClick=i.handleClick.bind(i),i.handleRightClick=i.handleRightClick.bind(i),i.handleDown=i.handleDown.bind(i),i.handleUp=i.handleUp.bind(i),i.handleMove=i.handleMove.bind(i),i.handleWheel=i.handleWheel.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleEnter=i.handleEnter.bind(i),n.addEventListener("click",i.handleClick,{capture:!1}),n.addEventListener("contextmenu",i.handleRightClick,{capture:!1}),n.addEventListener("mousedown",i.handleDown,{capture:!1}),n.addEventListener("wheel",i.handleWheel,{capture:!1}),n.addEventListener("mouseleave",i.handleLeave,{capture:!1}),n.addEventListener("mouseenter",i.handleEnter,{capture:!1}),document.addEventListener("mousemove",i.handleMove,{capture:!1}),document.addEventListener("mouseup",i.handleUp,{capture:!1}),i}return Gt(t,e),ht(t,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("click",this.handleClick),r.removeEventListener("contextmenu",this.handleRightClick),r.removeEventListener("mousedown",this.handleDown),r.removeEventListener("wheel",this.handleWheel),r.removeEventListener("mouseleave",this.handleLeave),r.removeEventListener("mouseenter",this.handleEnter),document.removeEventListener("mousemove",this.handleMove),document.removeEventListener("mouseup",this.handleUp)}},{key:"handleClick",value:function(r){var i=this;if(this.enabled){if(this.clicks++,this.clicks===2)return this.clicks=0,typeof this.doubleClickTimeout=="number"&&(clearTimeout(this.doubleClickTimeout),this.doubleClickTimeout=null),this.handleDoubleClick(r);setTimeout(function(){i.clicks=0,i.doubleClickTimeout=null},this.settings.doubleClickTimeout),this.draggedEvents<this.settings.draggedEventsTolerance&&this.emit("click",rn(r,this.container))}}},{key:"handleRightClick",value:function(r){this.enabled&&this.emit("rightClick",rn(r,this.container))}},{key:"handleDoubleClick",value:function(r){if(this.enabled){r.preventDefault(),r.stopPropagation();var i=rn(r,this.container);if(this.emit("doubleClick",i),!i.sigmaDefaultPrevented){var o=this.renderer.getCamera(),s=o.getBoundedRatio(o.getState().ratio/this.settings.doubleClickZoomingRatio);o.animate(this.renderer.getViewportZoomedState(qt(r,this.container),s),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}}},{key:"handleDown",value:function(r){if(this.enabled){if(r.button===0){this.startCameraState=this.renderer.getCamera().getState();var i=qt(r,this.container),o=i.x,s=i.y;this.lastMouseX=o,this.lastMouseY=s,this.draggedEvents=0,this.downStartTime=Date.now(),this.isMouseDown=!0}this.emit("mousedown",rn(r,this.container))}}},{key:"handleUp",value:function(r){var i=this;if(!(!this.enabled||!this.isMouseDown)){var o=this.renderer.getCamera();this.isMouseDown=!1,typeof this.movingTimeout=="number"&&(clearTimeout(this.movingTimeout),this.movingTimeout=null);var s=qt(r,this.container),a=s.x,u=s.y,c=o.getState(),l=o.getPreviousState()||{x:0,y:0};this.isMoving?o.animate({x:c.x+this.settings.inertiaRatio*(c.x-l.x),y:c.y+this.settings.inertiaRatio*(c.y-l.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"}):(this.lastMouseX!==a||this.lastMouseY!==u)&&o.setState({x:c.x,y:c.y}),this.isMoving=!1,setTimeout(function(){var d=i.draggedEvents>0;i.draggedEvents=0,d&&i.renderer.getSetting("hideEdgesOnMove")&&i.renderer.refresh()},0),this.emit("mouseup",rn(r,this.container))}}},{key:"handleMove",value:function(r){var i=this;if(this.enabled){var o=rn(r,this.container);if(this.emit("mousemovebody",o),(r.target===this.container||r.composedPath()[0]===this.container)&&this.emit("mousemove",o),!o.sigmaDefaultPrevented&&this.isMouseDown){this.isMoving=!0,this.draggedEvents++,typeof this.movingTimeout=="number"&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.movingTimeout=null,i.isMoving=!1},this.settings.dragTimeout);var s=this.renderer.getCamera(),a=qt(r,this.container),u=a.x,c=a.y,l=this.renderer.viewportToFramedGraph({x:this.lastMouseX,y:this.lastMouseY}),d=this.renderer.viewportToFramedGraph({x:u,y:c}),f=l.x-d.x,h=l.y-d.y,p=s.getState(),m=p.x+f,y=p.y+h;s.setState({x:m,y}),this.lastMouseX=u,this.lastMouseY=c,r.preventDefault(),r.stopPropagation()}}}},{key:"handleLeave",value:function(r){this.emit("mouseleave",rn(r,this.container))}},{key:"handleEnter",value:function(r){this.emit("mouseenter",rn(r,this.container))}},{key:"handleWheel",value:function(r){var i=this,o=this.renderer.getCamera();if(!(!this.enabled||!o.enabledZooming)){var s=F_(r);if(s){var a=A1(r,this.container);if(this.emit("wheel",a),a.sigmaDefaultPrevented){r.preventDefault(),r.stopPropagation();return}var u=o.getState().ratio,c=s>0?1/this.settings.zoomingRatio:this.settings.zoomingRatio,l=o.getBoundedRatio(u*c),d=s>0?1:-1,f=Date.now();u!==l&&(r.preventDefault(),r.stopPropagation(),!(this.currentWheelDirection===d&&this.lastWheelTriggerTime&&f-this.lastWheelTriggerTime<this.settings.zoomDuration/5)&&(o.animate(this.renderer.getViewportZoomedState(qt(r,this.container),l),{easing:"quadraticOut",duration:this.settings.zoomDuration},function(){i.currentWheelDirection=0}),this.currentWheelDirection=d,this.lastWheelTriggerTime=f))}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(U_),z1=["dragTimeout","inertiaDuration","inertiaRatio","doubleClickTimeout","doubleClickZoomingRatio","doubleClickZoomingDuration","tapMoveTolerance"],P1=z1.reduce(function(e,t){return X(X({},e),{},L({},t,ah[t]))},{}),O1=(function(e){function t(n,r){var i;return ft(this,t),i=Ut(this,t,[n,r]),L(i,"enabled",!0),L(i,"isMoving",!1),L(i,"hasMoved",!1),L(i,"touchMode",0),L(i,"startTouchesPositions",[]),L(i,"lastTouches",[]),L(i,"lastTap",null),L(i,"settings",P1),i.handleStart=i.handleStart.bind(i),i.handleLeave=i.handleLeave.bind(i),i.handleMove=i.handleMove.bind(i),n.addEventListener("touchstart",i.handleStart,{capture:!1}),n.addEventListener("touchcancel",i.handleLeave,{capture:!1}),document.addEventListener("touchend",i.handleLeave,{capture:!1,passive:!1}),document.addEventListener("touchmove",i.handleMove,{capture:!1,passive:!1}),i}return Gt(t,e),ht(t,[{key:"kill",value:function(){var r=this.container;r.removeEventListener("touchstart",this.handleStart),r.removeEventListener("touchcancel",this.handleLeave),document.removeEventListener("touchend",this.handleLeave),document.removeEventListener("touchmove",this.handleMove)}},{key:"getDimensions",value:function(){return{width:this.container.offsetWidth,height:this.container.offsetHeight}}},{key:"handleStart",value:function(r){var i=this;if(this.enabled){r.preventDefault();var o=rs(r.touches);if(this.touchMode=o.length,this.startCameraState=this.renderer.getCamera().getState(),this.startTouchesPositions=o.map(function(h){return qt(h,i.container)}),this.touchMode===2){var s=br(this.startTouchesPositions,2),a=s[0],u=a.x,c=a.y,l=s[1],d=l.x,f=l.y;this.startTouchesAngle=Math.atan2(f-c,d-u),this.startTouchesDistance=Math.sqrt(Math.pow(d-u,2)+Math.pow(f-c,2))}this.emit("touchdown",ei(r,this.lastTouches,this.container)),this.lastTouches=o,this.lastTouchesPositions=this.startTouchesPositions}}},{key:"handleLeave",value:function(r){if(!(!this.enabled||!this.startTouchesPositions.length)){switch(r.cancelable&&r.preventDefault(),this.movingTimeout&&(this.isMoving=!1,clearTimeout(this.movingTimeout)),this.touchMode){case 2:if(r.touches.length===1){this.handleStart(r),r.preventDefault();break}case 1:if(this.isMoving){var i=this.renderer.getCamera(),o=i.getState(),s=i.getPreviousState()||{x:0,y:0};i.animate({x:o.x+this.settings.inertiaRatio*(o.x-s.x),y:o.y+this.settings.inertiaRatio*(o.y-s.y)},{duration:this.settings.inertiaDuration,easing:"quadraticOut"})}this.hasMoved=!1,this.isMoving=!1,this.touchMode=0;break}if(this.emit("touchup",ei(r,this.lastTouches,this.container)),!r.touches.length){var a=qt(this.lastTouches[0],this.container),u=this.startTouchesPositions[0],c=Math.pow(a.x-u.x,2)+Math.pow(a.y-u.y,2);if(!r.touches.length&&c<Math.pow(this.settings.tapMoveTolerance,2))if(this.lastTap&&Date.now()-this.lastTap.time<this.settings.doubleClickTimeout){var l=ei(r,this.lastTouches,this.container);if(this.emit("doubletap",l),this.lastTap=null,!l.sigmaDefaultPrevented){var d=this.renderer.getCamera(),f=d.getBoundedRatio(d.getState().ratio/this.settings.doubleClickZoomingRatio);d.animate(this.renderer.getViewportZoomedState(a,f),{easing:"quadraticInOut",duration:this.settings.doubleClickZoomingDuration})}}else{var h=ei(r,this.lastTouches,this.container);this.emit("tap",h),this.lastTap={time:Date.now(),position:h.touches[0]||h.previousTouches[0]}}}this.lastTouches=rs(r.touches),this.startTouchesPositions=[]}}},{key:"handleMove",value:function(r){var i=this;if(!(!this.enabled||!this.startTouchesPositions.length)){r.preventDefault();var o=rs(r.touches),s=o.map(function(I){return qt(I,i.container)}),a=this.lastTouches;this.lastTouches=o,this.lastTouchesPositions=s;var u=ei(r,a,this.container);if(this.emit("touchmove",u),!u.sigmaDefaultPrevented&&(this.hasMoved||(this.hasMoved=s.some(function(I,R){var G=i.startTouchesPositions[R];return G&&(I.x!==G.x||I.y!==G.y)})),!!this.hasMoved)){this.isMoving=!0,this.movingTimeout&&clearTimeout(this.movingTimeout),this.movingTimeout=window.setTimeout(function(){i.isMoving=!1},this.settings.dragTimeout);var c=this.renderer.getCamera(),l=this.startCameraState,d=this.renderer.getSetting("stagePadding");switch(this.touchMode){case 1:{var f=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0]),h=f.x,p=f.y,m=this.renderer.viewportToFramedGraph(s[0]),y=m.x,w=m.y;c.setState({x:l.x+h-y,y:l.y+p-w});break}case 2:{var g={x:.5,y:.5,angle:0,ratio:1},b=s[0],v=b.x,k=b.y,_=s[1],$=_.x,D=_.y,M=Math.atan2(D-k,$-v)-this.startTouchesAngle,O=Math.hypot(D-k,$-v)/this.startTouchesDistance,J=c.getBoundedRatio(l.ratio/O);g.ratio=J,g.angle=l.angle+M;var se=this.getDimensions(),we=this.renderer.viewportToFramedGraph((this.startTouchesPositions||[])[0],{cameraState:l}),_e=Math.min(se.width,se.height)-2*d,Ge=_e/se.width,F=_e/se.height,B=J/_e,W=v-_e/2/Ge,Q=k-_e/2/F,K=[W*Math.cos(-g.angle)-Q*Math.sin(-g.angle),Q*Math.cos(-g.angle)+W*Math.sin(-g.angle)];W=K[0],Q=K[1],g.x=we.x-W*B,g.y=we.y+Q*B,c.setState(g);break}}}}}},{key:"setSettings",value:function(r){this.settings=r}}])})(U_);function D1(e){if(Array.isArray(e))return uc(e)}function M1(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function F1(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
421
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nm(e){return D1(e)||M1(e)||__(e)||F1()}function U1(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Tu(e,t){if(e==null)return{};var n,r,i=U1(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}var rm=(function(){function e(t,n){ft(this,e),this.key=t,this.size=n}return ht(e,null,[{key:"compare",value:function(n,r){return n.size>r.size?-1:n.size<r.size||n.key>r.key?1:-1}}])})(),im=(function(){function e(){ft(this,e),L(this,"width",0),L(this,"height",0),L(this,"cellSize",0),L(this,"columns",0),L(this,"rows",0),L(this,"cells",{})}return ht(e,[{key:"resizeAndClear",value:function(n,r){this.width=n.width,this.height=n.height,this.cellSize=r,this.columns=Math.ceil(n.width/r),this.rows=Math.ceil(n.height/r),this.cells={}}},{key:"getIndex",value:function(n){var r=Math.floor(n.x/this.cellSize),i=Math.floor(n.y/this.cellSize);return i*this.columns+r}},{key:"add",value:function(n,r,i){var o=new rm(n,r),s=this.getIndex(i),a=this.cells[s];a||(a=[],this.cells[s]=a),a.push(o)}},{key:"organize",value:function(){for(var n in this.cells){var r=this.cells[n];r.sort(rm.compare)}}},{key:"getLabelsToDisplay",value:function(n,r){var i=this.cellSize*this.cellSize,o=i/n/n,s=o*r/i,a=Math.ceil(s),u=[];for(var c in this.cells)for(var l=this.cells[c],d=0;d<Math.min(a,l.length);d++)u.push(l[d].key);return u}}])})();function G1(e){var t=e.graph,n=e.hoveredNode,r=e.highlightedNodes,i=e.displayedNodeLabels,o=[];return t.forEachEdge(function(s,a,u,c){(u===n||c===n||r.has(u)||r.has(c)||i.has(u)&&i.has(c))&&o.push(s)}),o}var om=150,sm=50,on=Object.prototype.hasOwnProperty;function j1(e,t,n){if(!on.call(n,"x")||!on.call(n,"y"))throw new Error('Sigma: could not find a valid position (x, y) for node "'.concat(t,'". All your nodes must have a number "x" and "y". Maybe your forgot to apply a layout or your "nodeReducer" is not returning the correct data?'));return n.color||(n.color=e.defaultNodeColor),!n.label&&n.label!==""&&(n.label=null),n.label!==void 0&&n.label!==null?n.label=""+n.label:n.label=null,n.size||(n.size=2),on.call(n,"hidden")||(n.hidden=!1),on.call(n,"highlighted")||(n.highlighted=!1),on.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultNodeType),n.zIndex||(n.zIndex=0),n}function Z1(e,t,n){return n.color||(n.color=e.defaultEdgeColor),n.label||(n.label=""),n.size||(n.size=.5),on.call(n,"hidden")||(n.hidden=!1),on.call(n,"forceLabel")||(n.forceLabel=!1),(!n.type||n.type==="")&&(n.type=e.defaultEdgeType),n.zIndex||(n.zIndex=0),n}var B1=(function(e){function t(n,r){var i,o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(ft(this,t),i=Ut(this,t),L(i,"elements",{}),L(i,"canvasContexts",{}),L(i,"webGLContexts",{}),L(i,"pickingLayers",new Set),L(i,"textures",{}),L(i,"frameBuffers",{}),L(i,"activeListeners",{}),L(i,"labelGrid",new im),L(i,"nodeDataCache",{}),L(i,"edgeDataCache",{}),L(i,"nodeProgramIndex",{}),L(i,"edgeProgramIndex",{}),L(i,"nodesWithForcedLabels",new Set),L(i,"edgesWithForcedLabels",new Set),L(i,"nodeExtent",{x:[0,1],y:[0,1]}),L(i,"nodeZExtent",[1/0,-1/0]),L(i,"edgeZExtent",[1/0,-1/0]),L(i,"matrix",Vt()),L(i,"invMatrix",Vt()),L(i,"correctionRatio",1),L(i,"customBBox",null),L(i,"normalizationFunction",Qp({x:[0,1],y:[0,1]})),L(i,"graphToViewportRatio",1),L(i,"itemIDsIndex",{}),L(i,"nodeIndices",{}),L(i,"edgeIndices",{}),L(i,"width",0),L(i,"height",0),L(i,"pixelRatio",Yp()),L(i,"pickingDownSizingRatio",2*i.pixelRatio),L(i,"displayedNodeLabels",new Set),L(i,"displayedEdgeLabels",new Set),L(i,"highlightedNodes",new Set),L(i,"hoveredNode",null),L(i,"hoveredEdge",null),L(i,"renderFrame",null),L(i,"renderHighlightedNodesFrame",null),L(i,"needToProcess",!1),L(i,"checkEdgesEventsFrame",null),L(i,"nodePrograms",{}),L(i,"nodeHoverPrograms",{}),L(i,"edgePrograms",{}),i.settings=C1(o),$u(i.settings),E1(n),!(r instanceof HTMLElement))throw new Error("Sigma: container should be an html element.");i.graph=n,i.container=r,i.createWebGLContext("edges",{picking:o.enableEdgeEvents}),i.createCanvasContext("edgeLabels"),i.createWebGLContext("nodes",{picking:!0}),i.createCanvasContext("labels"),i.createCanvasContext("hovers"),i.createWebGLContext("hoverNodes"),i.createCanvasContext("mouse",{style:{touchAction:"none",userSelect:"none"}}),i.resize();for(var s in i.settings.nodeProgramClasses)i.registerNodeProgram(s,i.settings.nodeProgramClasses[s],i.settings.nodeHoverProgramClasses[s]);for(var a in i.settings.edgeProgramClasses)i.registerEdgeProgram(a,i.settings.edgeProgramClasses[a]);return i.camera=new tm,i.bindCameraHandlers(),i.mouseCaptor=new L1(i.elements.mouse,i),i.mouseCaptor.setSettings(i.settings),i.touchCaptor=new O1(i.elements.mouse,i),i.touchCaptor.setSettings(i.settings),i.bindEventHandlers(),i.bindGraphHandlers(),i.handleSettingsUpdate(),i.refresh(),i}return Gt(t,e),ht(t,[{key:"registerNodeProgram",value:function(r,i,o){return this.nodePrograms[r]&&this.nodePrograms[r].kill(),this.nodeHoverPrograms[r]&&this.nodeHoverPrograms[r].kill(),this.nodePrograms[r]=new i(this.webGLContexts.nodes,this.frameBuffers.nodes,this),this.nodeHoverPrograms[r]=new(o||i)(this.webGLContexts.hoverNodes,null,this),this}},{key:"registerEdgeProgram",value:function(r,i){return this.edgePrograms[r]&&this.edgePrograms[r].kill(),this.edgePrograms[r]=new i(this.webGLContexts.edges,this.frameBuffers.edges,this),this}},{key:"unregisterNodeProgram",value:function(r){if(this.nodePrograms[r]){var i=this.nodePrograms,o=i[r],s=Tu(i,[r].map(si));o.kill(),this.nodePrograms=s}if(this.nodeHoverPrograms[r]){var a=this.nodeHoverPrograms,u=a[r],c=Tu(a,[r].map(si));u.kill(),this.nodePrograms=c}return this}},{key:"unregisterEdgeProgram",value:function(r){if(this.edgePrograms[r]){var i=this.edgePrograms,o=i[r],s=Tu(i,[r].map(si));o.kill(),this.edgePrograms=s}return this}},{key:"resetWebGLTexture",value:function(r){var i=this.webGLContexts[r],o=this.frameBuffers[r],s=this.textures[r];s&&i.deleteTexture(s);var a=i.createTexture();return i.bindFramebuffer(i.FRAMEBUFFER,o),i.bindTexture(i.TEXTURE_2D,a),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,this.width,this.height,0,i.RGBA,i.UNSIGNED_BYTE,null),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,a,0),this.textures[r]=a,this}},{key:"bindCameraHandlers",value:function(){var r=this;return this.activeListeners.camera=function(){r.scheduleRender()},this.camera.on("updated",this.activeListeners.camera),this}},{key:"unbindCameraHandlers",value:function(){return this.camera.removeListener("updated",this.activeListeners.camera),this}},{key:"getNodeAtPosition",value:function(r){var i=r.x,o=r.y,s=Fp(this.webGLContexts.nodes,this.frameBuffers.nodes,i,o,this.pixelRatio,this.pickingDownSizingRatio),a=Mp.apply(void 0,nm(s)),u=this.itemIDsIndex[a];return u&&u.type==="node"?u.id:null}},{key:"bindEventHandlers",value:function(){var r=this;this.activeListeners.handleResize=function(){r.scheduleRefresh()},window.addEventListener("resize",this.activeListeners.handleResize),this.activeListeners.handleMove=function(o){var s=Qr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}},u=r.getNodeAtPosition(s);if(u&&r.hoveredNode!==u&&!r.nodeDataCache[u].hidden){r.hoveredNode&&r.emit("leaveNode",X(X({},a),{},{node:r.hoveredNode})),r.hoveredNode=u,r.emit("enterNode",X(X({},a),{},{node:u})),r.scheduleHighlightedNodesRender();return}if(r.hoveredNode&&r.getNodeAtPosition(s)!==r.hoveredNode){var c=r.hoveredNode;r.hoveredNode=null,r.emit("leaveNode",X(X({},a),{},{node:c})),r.scheduleHighlightedNodesRender();return}if(r.settings.enableEdgeEvents){var l=r.hoveredNode?null:r.getEdgeAtPoint(a.event.x,a.event.y);l!==r.hoveredEdge&&(r.hoveredEdge&&r.emit("leaveEdge",X(X({},a),{},{edge:r.hoveredEdge})),l&&r.emit("enterEdge",X(X({},a),{},{edge:l})),r.hoveredEdge=l)}},this.activeListeners.handleMoveBody=function(o){var s=Qr(o);r.emit("moveBody",{event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}})},this.activeListeners.handleLeave=function(o){var s=Qr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.hoveredNode&&(r.emit("leaveNode",X(X({},a),{},{node:r.hoveredNode})),r.scheduleHighlightedNodesRender()),r.settings.enableEdgeEvents&&r.hoveredEdge&&(r.emit("leaveEdge",X(X({},a),{},{edge:r.hoveredEdge})),r.scheduleHighlightedNodesRender()),r.emit("leaveStage",X({},a))},this.activeListeners.handleEnter=function(o){var s=Qr(o),a={event:s,preventSigmaDefault:function(){s.preventSigmaDefault()}};r.emit("enterStage",X({},a))};var i=function(s){return function(a){var u=Qr(a),c={event:u,preventSigmaDefault:function(){u.preventSigmaDefault()}},l=r.getNodeAtPosition(u);if(l)return r.emit("".concat(s,"Node"),X(X({},c),{},{node:l}));if(r.settings.enableEdgeEvents){var d=r.getEdgeAtPoint(u.x,u.y);if(d)return r.emit("".concat(s,"Edge"),X(X({},c),{},{edge:d}))}return r.emit("".concat(s,"Stage"),c)}};return this.activeListeners.handleClick=i("click"),this.activeListeners.handleRightClick=i("rightClick"),this.activeListeners.handleDoubleClick=i("doubleClick"),this.activeListeners.handleWheel=i("wheel"),this.activeListeners.handleDown=i("down"),this.activeListeners.handleUp=i("up"),this.mouseCaptor.on("mousemove",this.activeListeners.handleMove),this.mouseCaptor.on("mousemovebody",this.activeListeners.handleMoveBody),this.mouseCaptor.on("click",this.activeListeners.handleClick),this.mouseCaptor.on("rightClick",this.activeListeners.handleRightClick),this.mouseCaptor.on("doubleClick",this.activeListeners.handleDoubleClick),this.mouseCaptor.on("wheel",this.activeListeners.handleWheel),this.mouseCaptor.on("mousedown",this.activeListeners.handleDown),this.mouseCaptor.on("mouseup",this.activeListeners.handleUp),this.mouseCaptor.on("mouseleave",this.activeListeners.handleLeave),this.mouseCaptor.on("mouseenter",this.activeListeners.handleEnter),this.touchCaptor.on("touchdown",this.activeListeners.handleDown),this.touchCaptor.on("touchdown",this.activeListeners.handleMove),this.touchCaptor.on("touchup",this.activeListeners.handleUp),this.touchCaptor.on("touchmove",this.activeListeners.handleMove),this.touchCaptor.on("tap",this.activeListeners.handleClick),this.touchCaptor.on("doubletap",this.activeListeners.handleDoubleClick),this.touchCaptor.on("touchmove",this.activeListeners.handleMoveBody),this}},{key:"bindGraphHandlers",value:function(){var r=this,i=this.graph,o=new Set(["x","y","zIndex","type"]);return this.activeListeners.eachNodeAttributesUpdatedGraphUpdate=function(s){var a,u=(a=s.hints)===null||a===void 0?void 0:a.attributes;r.graph.forEachNode(function(l){return r.updateNode(l)});var c=!u||u.some(function(l){return o.has(l)});r.refresh({partialGraph:{nodes:i.nodes()},skipIndexation:!c,schedule:!0})},this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate=function(s){var a,u=(a=s.hints)===null||a===void 0?void 0:a.attributes;r.graph.forEachEdge(function(l){return r.updateEdge(l)});var c=u&&["zIndex","type"].some(function(l){return u?.includes(l)});r.refresh({partialGraph:{edges:i.edges()},skipIndexation:!c,schedule:!0})},this.activeListeners.addNodeGraphUpdate=function(s){var a=s.key;r.addNode(a),r.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.updateNodeGraphUpdate=function(s){var a=s.key;r.refresh({partialGraph:{nodes:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropNodeGraphUpdate=function(s){var a=s.key;r.removeNode(a),r.refresh({schedule:!0})},this.activeListeners.addEdgeGraphUpdate=function(s){var a=s.key;r.addEdge(a),r.refresh({partialGraph:{edges:[a]},schedule:!0})},this.activeListeners.updateEdgeGraphUpdate=function(s){var a=s.key;r.refresh({partialGraph:{edges:[a]},skipIndexation:!1,schedule:!0})},this.activeListeners.dropEdgeGraphUpdate=function(s){var a=s.key;r.removeEdge(a),r.refresh({schedule:!0})},this.activeListeners.clearEdgesGraphUpdate=function(){r.clearEdgeState(),r.clearEdgeIndices(),r.refresh({schedule:!0})},this.activeListeners.clearGraphUpdate=function(){r.clearEdgeState(),r.clearNodeState(),r.clearEdgeIndices(),r.clearNodeIndices(),r.refresh({schedule:!0})},i.on("nodeAdded",this.activeListeners.addNodeGraphUpdate),i.on("nodeDropped",this.activeListeners.dropNodeGraphUpdate),i.on("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),i.on("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),i.on("edgeAdded",this.activeListeners.addEdgeGraphUpdate),i.on("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),i.on("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),i.on("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),i.on("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),i.on("cleared",this.activeListeners.clearGraphUpdate),this}},{key:"unbindGraphHandlers",value:function(){var r=this.graph;r.removeListener("nodeAdded",this.activeListeners.addNodeGraphUpdate),r.removeListener("nodeDropped",this.activeListeners.dropNodeGraphUpdate),r.removeListener("nodeAttributesUpdated",this.activeListeners.updateNodeGraphUpdate),r.removeListener("eachNodeAttributesUpdated",this.activeListeners.eachNodeAttributesUpdatedGraphUpdate),r.removeListener("edgeAdded",this.activeListeners.addEdgeGraphUpdate),r.removeListener("edgeDropped",this.activeListeners.dropEdgeGraphUpdate),r.removeListener("edgeAttributesUpdated",this.activeListeners.updateEdgeGraphUpdate),r.removeListener("eachEdgeAttributesUpdated",this.activeListeners.eachEdgeAttributesUpdatedGraphUpdate),r.removeListener("edgesCleared",this.activeListeners.clearEdgesGraphUpdate),r.removeListener("cleared",this.activeListeners.clearGraphUpdate)}},{key:"getEdgeAtPoint",value:function(r,i){var o=Fp(this.webGLContexts.edges,this.frameBuffers.edges,r,i,this.pixelRatio,this.pickingDownSizingRatio),s=Mp.apply(void 0,nm(o)),a=this.itemIDsIndex[s];return a&&a.type==="edge"?a.id:null}},{key:"process",value:function(){var r=this;this.emit("beforeProcess");var i=this.graph,o=this.settings,s=this.getDimensions();if(this.nodeExtent=S1(this.graph),!this.settings.autoRescale){var a=s.width,u=s.height,c=this.nodeExtent,l=c.x,d=c.y;this.nodeExtent={x:[(l[0]+l[1])/2-a/2,(l[0]+l[1])/2+a/2],y:[(d[0]+d[1])/2-u/2,(d[0]+d[1])/2+u/2]}}this.normalizationFunction=Qp(this.customBBox||this.nodeExtent);var f=new tm,h=Xr(f.getState(),s,this.getGraphDimensions(),this.getStagePadding());this.labelGrid.resizeAndClear(s,o.labelGridCellSize);for(var p={},m={},y={},w={},g=1,b=i.nodes(),v=0,k=b.length;v<k;v++){var _=b[v],$=this.nodeDataCache[_],D=i.getNodeAttributes(_);$.x=D.x,$.y=D.y,this.normalizationFunction.applyTo($),typeof $.label=="string"&&!$.hidden&&this.labelGrid.add(_,$.size,this.framedGraphToViewport($,{matrix:h})),p[$.type]=(p[$.type]||0)+1}this.labelGrid.organize();for(var M in this.nodePrograms){if(!on.call(this.nodePrograms,M))throw new Error('Sigma: could not find a suitable program for node type "'.concat(M,'"!'));this.nodePrograms[M].reallocate(p[M]||0),p[M]=0}this.settings.zIndex&&this.nodeZExtent[0]!==this.nodeZExtent[1]&&(b=Xp(this.nodeZExtent,function(ce){return r.nodeDataCache[ce].zIndex},b));for(var O=0,J=b.length;O<J;O++){var se=b[O];m[se]=g,w[m[se]]={type:"node",id:se},g++;var we=this.nodeDataCache[se];this.addNodeToProgram(se,m[se],p[we.type]++)}for(var _e={},Ge=i.edges(),F=0,B=Ge.length;F<B;F++){var W=Ge[F],Q=this.edgeDataCache[W];_e[Q.type]=(_e[Q.type]||0)+1}this.settings.zIndex&&this.edgeZExtent[0]!==this.edgeZExtent[1]&&(Ge=Xp(this.edgeZExtent,function(ce){return r.edgeDataCache[ce].zIndex},Ge));for(var K in this.edgePrograms){if(!on.call(this.edgePrograms,K))throw new Error('Sigma: could not find a suitable program for edge type "'.concat(K,'"!'));this.edgePrograms[K].reallocate(_e[K]||0),_e[K]=0}for(var I=0,R=Ge.length;I<R;I++){var G=Ge[I];y[G]=g,w[y[G]]={type:"edge",id:G},g++;var ne=this.edgeDataCache[G];this.addEdgeToProgram(G,y[G],_e[ne.type]++)}return this.itemIDsIndex=w,this.nodeIndices=m,this.edgeIndices=y,this.emit("afterProcess"),this}},{key:"handleSettingsUpdate",value:function(r){var i=this,o=this.settings;if(this.camera.minRatio=o.minCameraRatio,this.camera.maxRatio=o.maxCameraRatio,this.camera.enabledZooming=o.enableCameraZooming,this.camera.enabledPanning=o.enableCameraPanning,this.camera.enabledRotation=o.enableCameraRotation,o.cameraPanBoundaries?this.camera.clean=function(l){return i.cleanCameraState(l,o.cameraPanBoundaries&&dc(o.cameraPanBoundaries)==="object"?o.cameraPanBoundaries:{})}:this.camera.clean=null,this.camera.setState(this.camera.validateState(this.camera.getState())),r){if(r.edgeProgramClasses!==o.edgeProgramClasses){for(var s in o.edgeProgramClasses)o.edgeProgramClasses[s]!==r.edgeProgramClasses[s]&&this.registerEdgeProgram(s,o.edgeProgramClasses[s]);for(var a in r.edgeProgramClasses)o.edgeProgramClasses[a]||this.unregisterEdgeProgram(a)}if(r.nodeProgramClasses!==o.nodeProgramClasses||r.nodeHoverProgramClasses!==o.nodeHoverProgramClasses){for(var u in o.nodeProgramClasses)(o.nodeProgramClasses[u]!==r.nodeProgramClasses[u]||o.nodeHoverProgramClasses[u]!==r.nodeHoverProgramClasses[u])&&this.registerNodeProgram(u,o.nodeProgramClasses[u],o.nodeHoverProgramClasses[u]);for(var c in r.nodeProgramClasses)o.nodeProgramClasses[c]||this.unregisterNodeProgram(c)}}return this.mouseCaptor.setSettings(this.settings),this.touchCaptor.setSettings(this.settings),this}},{key:"cleanCameraState",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i.tolerance,s=o===void 0?0:o,a=i.boundaries,u=X({},r),c=a||this.nodeExtent,l=br(c.x,2),d=l[0],f=l[1],h=br(c.y,2),p=h[0],m=h[1],y=[this.graphToViewport({x:d,y:p},{cameraState:r}),this.graphToViewport({x:f,y:p},{cameraState:r}),this.graphToViewport({x:d,y:m},{cameraState:r}),this.graphToViewport({x:f,y:m},{cameraState:r})],w=1/0,g=-1/0,b=1/0,v=-1/0;y.forEach(function(_e){var Ge=_e.x,F=_e.y;w=Math.min(w,Ge),g=Math.max(g,Ge),b=Math.min(b,F),v=Math.max(v,F)});var k=g-w,_=v-b,$=this.getDimensions(),D=$.width,M=$.height,O=0,J=0;if(k>=D?g<D-s?O=g-(D-s):w>s&&(O=w-s):g>D+s?O=g-(D+s):w<-s&&(O=w+s),_>=M?v<M-s?J=v-(M-s):b>s&&(J=b-s):v>M+s?J=v-(M+s):b<-s&&(J=b+s),O||J){var se=this.viewportToFramedGraph({x:0,y:0},{cameraState:r}),we=this.viewportToFramedGraph({x:O,y:J},{cameraState:r});O=we.x-se.x,J=we.y-se.y,u.x+=O,u.y+=J}return u}},{key:"renderLabels",value:function(){if(!this.settings.renderLabels)return this;var r=this.camera.getState(),i=this.labelGrid.getLabelsToDisplay(r.ratio,this.settings.labelDensity);em(i,this.nodesWithForcedLabels),this.displayedNodeLabels=new Set;for(var o=this.canvasContexts.labels,s=0,a=i.length;s<a;s++){var u=i[s],c=this.nodeDataCache[u];if(!this.displayedNodeLabels.has(u)&&!c.hidden){var l=this.framedGraphToViewport(c),d=l.x,f=l.y,h=this.scaleSize(c.size);if(!(!c.forceLabel&&h<this.settings.labelRenderedSizeThreshold)&&!(d<-om||d>this.width+om||f<-sm||f>this.height+sm)){this.displayedNodeLabels.add(u);var p=this.settings.defaultDrawNodeLabel,m=this.nodePrograms[c.type],y=m?.drawLabel||p;y(o,X(X({key:u},c),{},{size:h,x:d,y:f}),this.settings)}}}return this}},{key:"renderEdgeLabels",value:function(){if(!this.settings.renderEdgeLabels)return this;var r=this.canvasContexts.edgeLabels;r.clearRect(0,0,this.width,this.height);var i=G1({graph:this.graph,hoveredNode:this.hoveredNode,displayedNodeLabels:this.displayedNodeLabels,highlightedNodes:this.highlightedNodes});em(i,this.edgesWithForcedLabels);for(var o=new Set,s=0,a=i.length;s<a;s++){var u=i[s],c=this.graph.extremities(u),l=this.nodeDataCache[c[0]],d=this.nodeDataCache[c[1]],f=this.edgeDataCache[u];if(!o.has(u)&&!(f.hidden||l.hidden||d.hidden)){var h=this.settings.defaultDrawEdgeLabel,p=this.edgePrograms[f.type],m=p?.drawLabel||h;m(r,X(X({key:u},f),{},{size:this.scaleSize(f.size)}),X(X(X({key:c[0]},l),this.framedGraphToViewport(l)),{},{size:this.scaleSize(l.size)}),X(X(X({key:c[1]},d),this.framedGraphToViewport(d)),{},{size:this.scaleSize(d.size)}),this.settings),o.add(u)}}return this.displayedEdgeLabels=o,this}},{key:"renderHighlightedNodes",value:function(){var r=this,i=this.canvasContexts.hovers;i.clearRect(0,0,this.width,this.height);var o=function(h){var p=r.nodeDataCache[h],m=r.framedGraphToViewport(p),y=m.x,w=m.y,g=r.scaleSize(p.size),b=r.settings.defaultDrawNodeHover,v=r.nodePrograms[p.type],k=v?.drawHover||b;k(i,X(X({key:h},p),{},{size:g,x:y,y:w}),r.settings)},s=[];this.hoveredNode&&!this.nodeDataCache[this.hoveredNode].hidden&&s.push(this.hoveredNode),this.highlightedNodes.forEach(function(f){f!==r.hoveredNode&&s.push(f)}),s.forEach(function(f){return o(f)});var a={};s.forEach(function(f){var h=r.nodeDataCache[f].type;a[h]=(a[h]||0)+1});for(var u in this.nodeHoverPrograms)this.nodeHoverPrograms[u].reallocate(a[u]||0),a[u]=0;s.forEach(function(f){var h=r.nodeDataCache[f];r.nodeHoverPrograms[h.type].process(0,a[h.type]++,h)}),this.webGLContexts.hoverNodes.clear(this.webGLContexts.hoverNodes.COLOR_BUFFER_BIT);var c=this.getRenderParams();for(var l in this.nodeHoverPrograms){var d=this.nodeHoverPrograms[l];d.render(c)}}},{key:"scheduleHighlightedNodesRender",value:function(){var r=this;this.renderHighlightedNodesFrame||this.renderFrame||(this.renderHighlightedNodesFrame=requestAnimationFrame(function(){r.renderHighlightedNodesFrame=null,r.renderHighlightedNodes(),r.renderEdgeLabels()}))}},{key:"render",value:function(){var r=this;this.emit("beforeRender");var i=function(){return r.emit("afterRender"),r};if(this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.resize(),this.needToProcess&&this.process(),this.needToProcess=!1,this.clear(),this.pickingLayers.forEach(function(y){return r.resetWebGLTexture(y)}),!this.graph.order)return i();var o=this.mouseCaptor,s=this.camera.isAnimated()||o.isMoving||o.draggedEvents||o.currentWheelDirection,a=this.camera.getState(),u=this.getDimensions(),c=this.getGraphDimensions(),l=this.getStagePadding();this.matrix=Xr(a,u,c,l),this.invMatrix=Xr(a,u,c,l,!0),this.correctionRatio=k1(this.matrix,a,u),this.graphToViewportRatio=this.getGraphToViewportRatio();var d=this.getRenderParams();for(var f in this.nodePrograms){var h=this.nodePrograms[f];h.render(d)}if(!this.settings.hideEdgesOnMove||!s)for(var p in this.edgePrograms){var m=this.edgePrograms[p];m.render(d)}return this.settings.hideLabelsOnMove&&s||(this.renderLabels(),this.renderEdgeLabels(),this.renderHighlightedNodes()),i()}},{key:"addNode",value:function(r){var i=Object.assign({},this.graph.getNodeAttributes(r));this.settings.nodeReducer&&(i=this.settings.nodeReducer(r,i));var o=j1(this.settings,r,i);this.nodeDataCache[r]=o,this.nodesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.nodesWithForcedLabels.add(r),this.highlightedNodes.delete(r),o.highlighted&&!o.hidden&&this.highlightedNodes.add(r),this.settings.zIndex&&(o.zIndex<this.nodeZExtent[0]&&(this.nodeZExtent[0]=o.zIndex),o.zIndex>this.nodeZExtent[1]&&(this.nodeZExtent[1]=o.zIndex))}},{key:"updateNode",value:function(r){this.addNode(r);var i=this.nodeDataCache[r];this.normalizationFunction.applyTo(i)}},{key:"removeNode",value:function(r){delete this.nodeDataCache[r],delete this.nodeProgramIndex[r],this.highlightedNodes.delete(r),this.hoveredNode===r&&(this.hoveredNode=null),this.nodesWithForcedLabels.delete(r)}},{key:"addEdge",value:function(r){var i=Object.assign({},this.graph.getEdgeAttributes(r));this.settings.edgeReducer&&(i=this.settings.edgeReducer(r,i));var o=Z1(this.settings,r,i);this.edgeDataCache[r]=o,this.edgesWithForcedLabels.delete(r),o.forceLabel&&!o.hidden&&this.edgesWithForcedLabels.add(r),this.settings.zIndex&&(o.zIndex<this.edgeZExtent[0]&&(this.edgeZExtent[0]=o.zIndex),o.zIndex>this.edgeZExtent[1]&&(this.edgeZExtent[1]=o.zIndex))}},{key:"updateEdge",value:function(r){this.addEdge(r)}},{key:"removeEdge",value:function(r){delete this.edgeDataCache[r],delete this.edgeProgramIndex[r],this.hoveredEdge===r&&(this.hoveredEdge=null),this.edgesWithForcedLabels.delete(r)}},{key:"clearNodeIndices",value:function(){this.labelGrid=new im,this.nodeExtent={x:[0,1],y:[0,1]},this.nodeDataCache={},this.edgeProgramIndex={},this.nodesWithForcedLabels=new Set,this.nodeZExtent=[1/0,-1/0],this.highlightedNodes=new Set}},{key:"clearEdgeIndices",value:function(){this.edgeDataCache={},this.edgeProgramIndex={},this.edgesWithForcedLabels=new Set,this.edgeZExtent=[1/0,-1/0]}},{key:"clearIndices",value:function(){this.clearEdgeIndices(),this.clearNodeIndices()}},{key:"clearNodeState",value:function(){this.displayedNodeLabels=new Set,this.highlightedNodes=new Set,this.hoveredNode=null}},{key:"clearEdgeState",value:function(){this.displayedEdgeLabels=new Set,this.highlightedNodes=new Set,this.hoveredEdge=null}},{key:"clearState",value:function(){this.clearEdgeState(),this.clearNodeState()}},{key:"addNodeToProgram",value:function(r,i,o){var s=this.nodeDataCache[r],a=this.nodePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for node type "'.concat(s.type,'"!'));a.process(i,o,s),this.nodeProgramIndex[r]=o}},{key:"addEdgeToProgram",value:function(r,i,o){var s=this.edgeDataCache[r],a=this.edgePrograms[s.type];if(!a)throw new Error('Sigma: could not find a suitable program for edge type "'.concat(s.type,'"!'));var u=this.graph.extremities(r),c=this.nodeDataCache[u[0]],l=this.nodeDataCache[u[1]];a.process(i,o,c,l,s),this.edgeProgramIndex[r]=o}},{key:"getRenderParams",value:function(){return{matrix:this.matrix,invMatrix:this.invMatrix,width:this.width,height:this.height,pixelRatio:this.pixelRatio,zoomRatio:this.camera.ratio,cameraAngle:this.camera.angle,sizeRatio:1/this.scaleSize(),correctionRatio:this.correctionRatio,downSizingRatio:this.pickingDownSizingRatio,minEdgeThickness:this.settings.minEdgeThickness,antiAliasingFeather:this.settings.antiAliasingFeather}}},{key:"getStagePadding",value:function(){var r=this.settings,i=r.stagePadding,o=r.autoRescale;return o&&i||0}},{key:"createLayer",value:function(r,i){var o=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(this.elements[r])throw new Error('Sigma: a layer named "'.concat(r,'" already exists'));var s=x1(i,{position:"absolute"},{class:"sigma-".concat(r)});return o.style&&Object.assign(s.style,o.style),this.elements[r]=s,"beforeLayer"in o&&o.beforeLayer?this.elements[o.beforeLayer].before(s):"afterLayer"in o&&o.afterLayer?this.elements[o.afterLayer].after(s):this.container.appendChild(s),s}},{key:"createCanvas",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.createLayer(r,"canvas",i)}},{key:"createCanvasContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=this.createCanvas(r,i),s={preserveDrawingBuffer:!1,antialias:!1};return this.canvasContexts[r]=o.getContext("2d",s),this}},{key:"createWebGLContext",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=i?.canvas||this.createCanvas(r,i);i.hidden&&o.remove();var s=X({preserveDrawingBuffer:!1,antialias:!1},i),a;a=o.getContext("webgl2",s),a||(a=o.getContext("webgl",s)),a||(a=o.getContext("experimental-webgl",s));var u=a;if(this.webGLContexts[r]=u,u.blendFunc(u.ONE,u.ONE_MINUS_SRC_ALPHA),i.picking){this.pickingLayers.add(r);var c=u.createFramebuffer();if(!c)throw new Error("Sigma: cannot create a new frame buffer for layer ".concat(r));this.frameBuffers[r]=c}return u}},{key:"killLayer",value:function(r){var i=this.elements[r];if(!i)throw new Error("Sigma: cannot kill layer ".concat(r,", which does not exist"));if(this.webGLContexts[r]){var o,s=this.webGLContexts[r];(o=s.getExtension("WEBGL_lose_context"))===null||o===void 0||o.loseContext(),delete this.webGLContexts[r]}else this.canvasContexts[r]&&delete this.canvasContexts[r];return i.remove(),delete this.elements[r],this}},{key:"getCamera",value:function(){return this.camera}},{key:"setCamera",value:function(r){this.unbindCameraHandlers(),this.camera=r,this.bindCameraHandlers()}},{key:"getContainer",value:function(){return this.container}},{key:"getGraph",value:function(){return this.graph}},{key:"setGraph",value:function(r){r!==this.graph&&(this.hoveredNode&&!r.hasNode(this.hoveredNode)&&(this.hoveredNode=null),this.hoveredEdge&&!r.hasEdge(this.hoveredEdge)&&(this.hoveredEdge=null),this.unbindGraphHandlers(),this.checkEdgesEventsFrame!==null&&(cancelAnimationFrame(this.checkEdgesEventsFrame),this.checkEdgesEventsFrame=null),this.graph=r,this.bindGraphHandlers(),this.refresh())}},{key:"getMouseCaptor",value:function(){return this.mouseCaptor}},{key:"getTouchCaptor",value:function(){return this.touchCaptor}},{key:"getDimensions",value:function(){return{width:this.width,height:this.height}}},{key:"getGraphDimensions",value:function(){var r=this.customBBox||this.nodeExtent;return{width:r.x[1]-r.x[0]||1,height:r.y[1]-r.y[0]||1}}},{key:"getNodeDisplayData",value:function(r){var i=this.nodeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getEdgeDisplayData",value:function(r){var i=this.edgeDataCache[r];return i?Object.assign({},i):void 0}},{key:"getNodeDisplayedLabels",value:function(){return new Set(this.displayedNodeLabels)}},{key:"getEdgeDisplayedLabels",value:function(){return new Set(this.displayedEdgeLabels)}},{key:"getSettings",value:function(){return X({},this.settings)}},{key:"getSetting",value:function(r){return this.settings[r]}},{key:"setSetting",value:function(r,i){var o=X({},this.settings);return this.settings[r]=i,$u(this.settings),this.handleSettingsUpdate(o),this.scheduleRefresh(),this}},{key:"updateSetting",value:function(r,i){return this.setSetting(r,i(this.settings[r])),this}},{key:"setSettings",value:function(r){var i=X({},this.settings);return this.settings=X(X({},this.settings),r),$u(this.settings),this.handleSettingsUpdate(i),this.scheduleRefresh(),this}},{key:"resize",value:function(r){var i=this.width,o=this.height;if(this.width=this.container.offsetWidth,this.height=this.container.offsetHeight,this.pixelRatio=Yp(),this.width===0)if(this.settings.allowInvalidContainer)this.width=1;else throw new Error("Sigma: Container has no width. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(this.height===0)if(this.settings.allowInvalidContainer)this.height=1;else throw new Error("Sigma: Container has no height. You can set the allowInvalidContainer setting to true to stop seeing this error.");if(!r&&i===this.width&&o===this.height)return this;for(var s in this.elements){var a=this.elements[s];a.style.width=this.width+"px",a.style.height=this.height+"px"}for(var u in this.canvasContexts)this.elements[u].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[u].setAttribute("height",this.height*this.pixelRatio+"px"),this.pixelRatio!==1&&this.canvasContexts[u].scale(this.pixelRatio,this.pixelRatio);for(var c in this.webGLContexts){this.elements[c].setAttribute("width",this.width*this.pixelRatio+"px"),this.elements[c].setAttribute("height",this.height*this.pixelRatio+"px");var l=this.webGLContexts[c];if(l.viewport(0,0,this.width*this.pixelRatio,this.height*this.pixelRatio),this.pickingLayers.has(c)){var d=this.textures[c];d&&l.deleteTexture(d)}}return this.emit("resize"),this}},{key:"clear",value:function(){return this.emit("beforeClear"),this.webGLContexts.nodes.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.nodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.edges.bindFramebuffer(WebGLRenderingContext.FRAMEBUFFER,null),this.webGLContexts.edges.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.webGLContexts.hoverNodes.clear(WebGLRenderingContext.COLOR_BUFFER_BIT),this.canvasContexts.labels.clearRect(0,0,this.width,this.height),this.canvasContexts.hovers.clearRect(0,0,this.width,this.height),this.canvasContexts.edgeLabels.clearRect(0,0,this.width,this.height),this.emit("afterClear"),this}},{key:"refresh",value:function(r){var i=this,o=r?.skipIndexation!==void 0?r?.skipIndexation:!1,s=r?.schedule!==void 0?r.schedule:!1,a=!r||!r.partialGraph;if(a)this.clearEdgeIndices(),this.clearNodeIndices(),this.graph.forEachNode(function(v){return i.addNode(v)}),this.graph.forEachEdge(function(v){return i.addEdge(v)});else{for(var u,c,l=((u=r.partialGraph)===null||u===void 0?void 0:u.nodes)||[],d=0,f=l?.length||0;d<f;d++){var h=l[d];if(this.updateNode(h),o){var p=this.nodeProgramIndex[h];if(p===void 0)throw new Error('Sigma: node "'.concat(h,`" can't be repaint`));this.addNodeToProgram(h,this.nodeIndices[h],p)}}for(var m=(r==null||(c=r.partialGraph)===null||c===void 0?void 0:c.edges)||[],y=0,w=m.length;y<w;y++){var g=m[y];if(this.updateEdge(g),o){var b=this.edgeProgramIndex[g];if(b===void 0)throw new Error('Sigma: edge "'.concat(g,`" can't be repaint`));this.addEdgeToProgram(g,this.edgeIndices[g],b)}}}return(a||!o)&&(this.needToProcess=!0),s?this.scheduleRender():this.render(),this}},{key:"scheduleRender",value:function(){var r=this;return this.renderFrame||(this.renderFrame=requestAnimationFrame(function(){r.render()})),this}},{key:"scheduleRefresh",value:function(r){return this.refresh(X(X({},r),{},{schedule:!0}))}},{key:"getViewportZoomedState",value:function(r,i){var o=this.camera.getState(),s=o.ratio,a=o.angle,u=o.x,c=o.y,l=this.settings,d=l.minCameraRatio,f=l.maxCameraRatio;typeof f=="number"&&(i=Math.min(i,f)),typeof d=="number"&&(i=Math.max(i,d));var h=i/s,p={x:this.width/2,y:this.height/2},m=this.viewportToFramedGraph(r),y=this.viewportToFramedGraph(p);return{angle:a,x:(m.x-y.x)*(1-h)+u,y:(m.y-y.y)*(1-h)+c,ratio:i}}},{key:"viewRectangle",value:function(){var r=this.viewportToFramedGraph({x:0,y:0}),i=this.viewportToFramedGraph({x:this.width,y:0}),o=this.viewportToFramedGraph({x:0,y:this.height});return{x1:r.x,y1:r.y,x2:i.x,y2:i.y,height:i.y-o.y}}},{key:"framedGraphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!!i.graphDimensions,s=i.matrix?i.matrix:o?Xr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding()):this.matrix,a=lc(s,r);return{x:(1+a.x)*this.width/2,y:(1-a.y)*this.height/2}}},{key:"viewportToFramedGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=!!i.cameraState||!!i.viewportDimensions||!i.graphDimensions,s=i.matrix?i.matrix:o?Xr(i.cameraState||this.camera.getState(),i.viewportDimensions||this.getDimensions(),i.graphDimensions||this.getGraphDimensions(),i.padding||this.getStagePadding(),!0):this.invMatrix,a=lc(s,{x:r.x/this.width*2-1,y:1-r.y/this.height*2});return isNaN(a.x)&&(a.x=0),isNaN(a.y)&&(a.y=0),a}},{key:"viewportToGraph",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.normalizationFunction.inverse(this.viewportToFramedGraph(r,i))}},{key:"graphToViewport",value:function(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return this.framedGraphToViewport(this.normalizationFunction(r),i)}},{key:"getGraphToViewportRatio",value:function(){var r={x:0,y:0},i={x:1,y:1},o=Math.sqrt(Math.pow(r.x-i.x,2)+Math.pow(r.y-i.y,2)),s=this.graphToViewport(r),a=this.graphToViewport(i),u=Math.sqrt(Math.pow(s.x-a.x,2)+Math.pow(s.y-a.y,2));return u/o}},{key:"getBBox",value:function(){return this.nodeExtent}},{key:"getCustomBBox",value:function(){return this.customBBox}},{key:"setCustomBBox",value:function(r){return this.customBBox=r,this.scheduleRender(),this}},{key:"kill",value:function(){this.emit("kill"),this.removeAllListeners(),this.unbindCameraHandlers(),window.removeEventListener("resize",this.activeListeners.handleResize),this.mouseCaptor.kill(),this.touchCaptor.kill(),this.unbindGraphHandlers(),this.clearIndices(),this.clearState(),this.nodeDataCache={},this.edgeDataCache={},this.highlightedNodes.clear(),this.renderFrame&&(cancelAnimationFrame(this.renderFrame),this.renderFrame=null),this.renderHighlightedNodesFrame&&(cancelAnimationFrame(this.renderHighlightedNodesFrame),this.renderHighlightedNodesFrame=null);for(var r=this.container;r.firstChild;)r.removeChild(r.firstChild);for(var i in this.nodePrograms)this.nodePrograms[i].kill();for(var o in this.nodeHoverPrograms)this.nodeHoverPrograms[o].kill();for(var s in this.edgePrograms)this.edgePrograms[s].kill();this.nodePrograms={},this.nodeHoverPrograms={},this.edgePrograms={};for(var a in this.elements)this.killLayer(a);this.canvasContexts={},this.webGLContexts={},this.elements={}}},{key:"scaleSize",value:function(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:1,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:this.camera.ratio;return r/this.settings.zoomToSizeRatioFunction(i)*(this.getSetting("itemSizesReference")==="positions"?i*this.graphToViewportRatio:1)}},{key:"getCanvases",value:function(){var r={};for(var i in this.elements)this.elements[i]instanceof HTMLCanvasElement&&(r[i]=this.elements[i]);return r}}])})(sh),H1=B1;function V1(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function G_(e){var t=V1(e,"string");return typeof t=="symbol"?t:t+""}function j_(e,t,n){return(t=G_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function am(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function vs(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?am(Object(n),!0).forEach(function(r){j_(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):am(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function q1(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function W1(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,G_(r.key),r)}}function K1(e,t,n){return t&&W1(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function bs(e){return bs=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},bs(e)}function Z_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Z_=function(){return!!e})()}function B_(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function J1(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return B_(e)}function Y1(e,t,n){return t=bs(t),J1(e,Z_()?Reflect.construct(t,n||[],bs(e).constructor):t.apply(e,n))}function fc(e,t){return fc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},fc(e,t)}function X1(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&fc(e,t)}function hc(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function Q1(e){if(Array.isArray(e))return hc(e)}function eR(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function tR(e,t){if(e){if(typeof e=="string")return hc(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?hc(e,t):void 0}}function nR(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
422
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Cu(e){return Q1(e)||eR(e)||tR(e)||nR()}function H_(e,t,n,r){var i=Math.pow(1-e,2)*t.x+2*(1-e)*e*n.x+Math.pow(e,2)*r.x,o=Math.pow(1-e,2)*t.y+2*(1-e)*e*n.y+Math.pow(e,2)*r.y;return{x:i,y:o}}function rR(e,t,n){for(var r=20,i=0,o=e,s=0;s<r;s++){var a=H_((s+1)/r,e,t,n);i+=Math.sqrt(Math.pow(o.x-a.x,2)+Math.pow(o.y-a.y,2)),o=a}return i}function iR(e){var t=e.curvatureAttribute,n=e.defaultCurvature,r=e.keepLabelUpright,i=r===void 0?!0:r;return function(o,s,a,u,c){var l=c.edgeLabelSize,d=s[t]||n,f=c.edgeLabelFont,h=c.edgeLabelWeight,p=c.edgeLabelColor.attribute?s[c.edgeLabelColor.attribute]||c.edgeLabelColor.color||"#000":c.edgeLabelColor.color,m=s.label;if(m){o.fillStyle=p,o.font="".concat(h," ").concat(l,"px ").concat(f);var y=!i||a.x<u.x,w=y?a.x:u.x,g=y?a.y:u.y,b=y?u.x:a.x,v=y?u.y:a.y,k=(w+b)/2,_=(g+v)/2,$=b-w,D=v-g,M=Math.sqrt(Math.pow($,2)+Math.pow(D,2)),O=y?1:-1,J=k+D*d*O,se=_-$*d*O,we=s.size*.7+5,_e={x:se-g,y:-(J-w)},Ge=Math.sqrt(Math.pow(_e.x,2)+Math.pow(_e.y,2)),F={x:v-se,y:-(b-J)},B=Math.sqrt(Math.pow(F.x,2)+Math.pow(F.y,2));w+=we*_e.x/Ge,g+=we*_e.y/Ge,b+=we*F.x/B,v+=we*F.y/B,J+=we*D/M,se-=we*$/M;var W={x:J,y:se},Q={x:w,y:g},K={x:b,y:v},I=rR(Q,W,K);if(!(I<a.size+u.size)){var R=o.measureText(m).width,G=I-a.size-u.size;if(R>G){var ne="…";for(m=m+ne,R=o.measureText(m).width;R>G&&m.length>1;)m=m.slice(0,-2)+ne,R=o.measureText(m).width;if(m.length<4)return}for(var ce={},ee=0,xe=m.length;ee<xe;ee++){var Ae=m[ee];ce[Ae]||(ce[Ae]=o.measureText(Ae).width*(1+d*.35))}for(var z=.5-R/I/2,j=0,H=m.length;j<H;j++){var Y=m[j],le=H_(z,Q,W,K),ie=2*(1-z)*(J-w)+2*z*(b-J),$e=2*(1-z)*(se-g)+2*z*(v-se),Ie=Math.atan2($e,ie);o.save(),o.translate(le.x,le.y),o.rotate(Ie),o.fillText(Y,0,0),o.restore(),z+=ce[Y]/I}}}}}function oR(e){var t=e.arrowHead,n=t?.extremity==="target"||t?.extremity==="both",r=t?.extremity==="source"||t?.extremity==="both",i=`
|
|
423
423
|
precision highp float;
|
|
424
424
|
|
|
425
425
|
varying vec4 v_color;
|
|
@@ -494,7 +494,7 @@ void main(void) {
|
|
|
494
494
|
gl_FragColor = transparent;
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
|
-
`);return i}function
|
|
497
|
+
`);return i}function sR(e){var t=e.arrowHead,n=t?.extremity==="target"||t?.extremity==="both",r=t?.extremity==="source"||t?.extremity==="both",i=`
|
|
498
498
|
attribute vec4 a_id;
|
|
499
499
|
attribute vec4 a_color;
|
|
500
500
|
attribute float a_direction;
|
|
@@ -604,9 +604,9 @@ void main() {
|
|
|
604
604
|
|
|
605
605
|
v_color.a *= bias;
|
|
606
606
|
}
|
|
607
|
-
`);return i}var
|
|
608
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function
|
|
609
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Au(e){return
|
|
607
|
+
`);return i}var V_=.25,aR={arrowHead:null,curvatureAttribute:"curvature",defaultCurvature:V_},q_=WebGLRenderingContext,um=q_.UNSIGNED_BYTE,wn=q_.FLOAT;function Ya(e){var t=vs(vs({},aR),e||{}),n=t,r=n.arrowHead,i=n.curvatureAttribute,o=n.drawLabel,s=r?.extremity==="target"||r?.extremity==="both",a=r?.extremity==="source"||r?.extremity==="both",u=["u_matrix","u_sizeRatio","u_dimensions","u_pixelRatio","u_feather","u_minEdgeThickness"].concat(Cu(r?["u_lengthToThicknessRatio","u_widenessToThicknessRatio"]:[]));return(function(c){X1(l,c);function l(){var d;q1(this,l);for(var f=arguments.length,h=new Array(f),p=0;p<f;p++)h[p]=arguments[p];return d=Y1(this,l,[].concat(h)),j_(B_(d),"drawLabel",o||iR(t)),d}return K1(l,[{key:"getDefinition",value:function(){return{VERTICES:6,VERTEX_SHADER_SOURCE:sR(t),FRAGMENT_SHADER_SOURCE:oR(t),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:u,ATTRIBUTES:[{name:"a_source",size:2,type:wn},{name:"a_target",size:2,type:wn}].concat(Cu(s?[{name:"a_targetSize",size:1,type:wn}]:[]),Cu(a?[{name:"a_sourceSize",size:1,type:wn}]:[]),[{name:"a_thickness",size:1,type:wn},{name:"a_curvature",size:1,type:wn},{name:"a_color",size:4,type:um,normalized:!0},{name:"a_id",size:4,type:um,normalized:!0}]),CONSTANT_ATTRIBUTES:[{name:"a_current",size:1,type:wn},{name:"a_direction",size:1,type:wn}],CONSTANT_DATA:[[0,1],[0,-1],[1,1],[0,-1],[1,1],[1,-1]]}}},{key:"processVisibleItem",value:function(f,h,p,m,y){var w,g=y.size||1,b=p.x,v=p.y,k=m.x,_=m.y,$=Rn(y.color),D=(w=y[i])!==null&&w!==void 0?w:V_,M=this.array;M[h++]=b,M[h++]=v,M[h++]=k,M[h++]=_,s&&(M[h++]=m.size),a&&(M[h++]=p.size),M[h++]=g,M[h++]=D,M[h++]=$,M[h++]=f}},{key:"setUniforms",value:function(f,h){var p=h.gl,m=h.uniformLocations,y=m.u_matrix,w=m.u_pixelRatio,g=m.u_feather,b=m.u_sizeRatio,v=m.u_dimensions,k=m.u_minEdgeThickness;if(p.uniformMatrix3fv(y,!1,f.matrix),p.uniform1f(w,f.pixelRatio),p.uniform1f(b,f.sizeRatio),p.uniform1f(g,f.antiAliasingFeather),p.uniform2f(v,f.width*f.pixelRatio,f.height*f.pixelRatio),p.uniform1f(k,f.minEdgeThickness),r){var _=m.u_lengthToThicknessRatio,$=m.u_widenessToThicknessRatio;p.uniform1f(_,r.lengthToThicknessRatio),p.uniform1f($,r.widenessToThicknessRatio)}}}]),l})(Wa)}Ya();Ya({arrowHead:Ja});Ya({arrowHead:vs(vs({},Ja),{},{extremity:"both"})});function uR(e){if(Array.isArray(e))return e}function cR(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,s,a=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,t!==0)for(;!(u=(r=o.call(n)).done)&&(a.push(r.value),a.length!==t);u=!0);}catch(l){c=!0,i=l}finally{try{if(!u&&n.return!=null&&(s=n.return(),Object(s)!==s))return}finally{if(c)throw i}}return a}}function pc(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function W_(e,t){if(e){if(typeof e=="string")return pc(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?pc(e,t):void 0}}function lR(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
608
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dR(e,t){return uR(e)||cR(e,t)||W_(e,t)||lR()}function fR(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function hR(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function K_(e){var t=hR(e,"string");return typeof t=="symbol"?t:t+""}function pR(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,K_(r.key),r)}}function mR(e,t,n){return t&&pR(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function ws(e){return ws=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ws(e)}function J_(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(J_=function(){return!!e})()}function mc(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function gR(e,t){if(t&&(typeof t=="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return mc(e)}function yR(e,t,n){return t=ws(t),gR(e,J_()?Reflect.construct(t,n||[],ws(e).constructor):t.apply(e,n))}function gc(e,t){return gc=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,r){return n.__proto__=r,n},gc(e,t)}function vR(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&gc(e,t)}function rr(e,t,n){return(t=K_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bR(e){if(Array.isArray(e))return pc(e)}function wR(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function _R(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
609
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Au(e){return bR(e)||wR(e)||W_(e)||_R()}function cm(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function lm(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?cm(Object(n),!0).forEach(function(r){rr(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cm(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}var kR="relative",SR={drawLabel:void 0,drawHover:void 0,borders:[{size:{value:.1},color:{attribute:"borderColor"}},{size:{fill:!0},color:{attribute:"color"}}]},ER="#000000";function xR(e){var t=e.borders,n=jp(t.filter(function(i){var o=i.size;return"fill"in o}).length),r=`
|
|
610
610
|
precision highp float;
|
|
611
611
|
|
|
612
612
|
varying vec2 v_diffVector;
|
|
@@ -643,7 +643,7 @@ void main(void) {
|
|
|
643
643
|
}
|
|
644
644
|
#else
|
|
645
645
|
// Sizes:
|
|
646
|
-
`).concat(t.flatMap(function(i,o){var s=i.size;if("fill"in s)return[];s=s;var a="attribute"in s?"v_borderSize_".concat(o+1):
|
|
646
|
+
`).concat(t.flatMap(function(i,o){var s=i.size;if("fill"in s)return[];s=s;var a="attribute"in s?"v_borderSize_".concat(o+1):jp(s.value),u=(s.mode||kR)==="pixels"?"u_correctionRatio":"v_radius";return[" float borderSize_".concat(o+1," = ").concat(u," * ").concat(a,";")]}).join(`
|
|
647
647
|
`),`
|
|
648
648
|
// Now, let's split the remaining space between "fill" borders:
|
|
649
649
|
float fillBorderSize = (v_radius - (`).concat(t.flatMap(function(i,o){var s=i.size;return"fill"in s?[]:["borderSize_".concat(o+1)]}).join(" + "),") ) / ").concat(n,`;
|
|
@@ -669,7 +669,7 @@ void main(void) {
|
|
|
669
669
|
} else `)}).join(""),` { /* Nothing to add here */ }
|
|
670
670
|
#endif
|
|
671
671
|
}
|
|
672
|
-
`);return r}function
|
|
672
|
+
`);return r}function $R(e){var t=e.borders,n=`
|
|
673
673
|
attribute vec2 a_position;
|
|
674
674
|
attribute float a_size;
|
|
675
675
|
attribute float a_angle;
|
|
@@ -716,9 +716,9 @@ void main() {
|
|
|
716
716
|
`),`
|
|
717
717
|
#endif
|
|
718
718
|
}
|
|
719
|
-
`);return n}var W_=WebGLRenderingContext,cm=W_.UNSIGNED_BYTE,Yo=W_.FLOAT;function K_(e){var t,n=um(um({},yR),e||{}),r=n.borders,i=n.drawLabel,o=n.drawHover,s=["u_sizeRatio","u_correctionRatio","u_matrix"].concat(Au(r.flatMap(function(a,u){var c=a.color;return"value"in c?["u_borderColor_".concat(u+1)]:[]})));return t=(function(a){fR(u,a);function u(){var c;sR(this,u);for(var l=arguments.length,d=new Array(l),f=0;f<l;f++)d[f]=arguments[f];return c=dR(this,u,[].concat(d)),rr(mc(c),"drawLabel",i),rr(mc(c),"drawHover",o),c}return cR(u,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:wR(n),FRAGMENT_SHADER_SOURCE:bR(n),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:s,ATTRIBUTES:[{name:"a_position",size:2,type:Yo},{name:"a_id",size:4,type:cm,normalized:!0},{name:"a_size",size:1,type:Yo}].concat(Au(r.flatMap(function(l,d){var f=l.color;return"attribute"in f?[{name:"a_borderColor_".concat(d+1),size:4,type:cm,normalized:!0}]:[]})),Au(r.flatMap(function(l,d){var f=l.size;return"attribute"in f?[{name:"a_borderSize_".concat(d+1),size:1,type:Yo}]:[]}))),CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Yo}],CONSTANT_DATA:[[u.ANGLE_1],[u.ANGLE_2],[u.ANGLE_3]]}}},{key:"processVisibleItem",value:function(l,d,f){var h=this.array;h[d++]=f.x,h[d++]=f.y,h[d++]=l,h[d++]=f.size,r.forEach(function(p){var m=p.color;"attribute"in m&&(h[d++]=Ln(f[m.attribute]||m.defaultValue||vR))}),r.forEach(function(p){var m=p.size;"attribute"in m&&(h[d++]=f[m.attribute]||m.defaultValue)})}},{key:"setUniforms",value:function(l,d){var f=d.gl,h=d.uniformLocations,p=h.u_sizeRatio,m=h.u_correctionRatio,y=h.u_matrix;f.uniform1f(m,l.correctionRatio),f.uniform1f(p,l.sizeRatio),f.uniformMatrix3fv(y,!1,l.matrix),r.forEach(function(w,g){var b=w.color;if("value"in b){var v=h["u_borderColor_".concat(g+1)],k=$N(b.value),_=oR(k,4),$=_[0],O=_[1],M=_[2],D=_[3];f.uniform4f(v,$/255,O/255,M/255,D/255)}})}}]),u})($_),rr(t,"ANGLE_1",0),rr(t,"ANGLE_2",2*Math.PI/3),rr(t,"ANGLE_3",4*Math.PI/3),t}K_();const _s=.18,_R=500,kR=2,SR=3,Xo={rest:2,selected:4,expanded:5},xR=6,Iu=2,ER=8,lm=6,Nu=400,$R=2e3,TR={x:[0,1e3],y:[0,1e3]},Ru=1e3,dm=500,CR={role:{size:13,font:e=>`600 ${e}px Inter, system-ui, sans-serif`},address:{size:11,font:e=>`400 ${e}px ui-monospace, monospace`},note:{size:11,font:e=>`italic 400 ${e}px Inter, system-ui, sans-serif`}};function Qo(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")}function Jt(e,t=1){return`#${Qo(e.r)}${Qo(e.g)}${Qo(e.b)}${Qo(e.a*t*255)}`}function J_(e,t,n,r){const i=1-r;return{x:i*i*e.x+2*i*r*t.x+r*r*n.x,y:i*i*e.y+2*i*r*t.y+r*r*n.y}}function Y_(e,t,n=_s){const r=t.x-e.x,i=t.y-e.y;return{x:(e.x+t.x)/2+i*n,y:(e.y+t.y)/2-r*n}}function X_(e,t,n){const r=n.x-t.x,i=n.y-t.y,o=r*r+i*i,s=o?Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*i)/o)):0;return Math.hypot(e.x-(t.x+s*r),e.y-(t.y+s*i))}function AR(e,t,n,r=_s){const i=Y_(t,n,r);let o=1/0,s=t;for(let a=1;a<=12;a++){const u=J_(t,i,n,a/12);o=Math.min(o,X_(e,s,u)),s=u}return o}function IR(e,t,n,r){const i=e.ownerDocument,o=i.defaultView,s=i.createElement("div");s.className="cia-graph-webgl",s.tabIndex=0,s.setAttribute("role","group"),s.setAttribute("aria-label",r.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.");const a=i.createElement("span");a.hidden=!0,s.append(a),e.append(s);const u=new Map;function c(z){const G=u.get(z);if(G)return G;a.style.color="",a.style.color=z;const H=o.getComputedStyle(a).color.match(/[\d.]+/g)?.map(Number)??[0,0,0],Y={r:H[0]??0,g:H[1]??0,b:H[2]??0,a:H[3]??1};return u.set(z,Y),Y}const l=z=>c(`var(--cia-graph-${z})`);let d;function f(){u.clear(),d={node:l("node"),edge:l("edge"),halo:l("halo"),selected:l("selected"),expanded:l("expanded"),text:l("text"),muted:l("muted")}}f();function h(z,G){if(!G.texts?.length||!G.outer)return;const H=G.size/G.outer;z.textAlign="center",z.textBaseline="alphabetic",z.lineJoin="round";for(const Y of G.texts){const le=CR[Y.kind],ie=le.size*H;if(ie<lm)continue;z.font=le.font(ie);const $e=G.y+Y.y*H;z.lineWidth=4*H,z.strokeStyle=G.haloColor??"#000",z.strokeText(Y.text,G.x,$e),z.fillStyle=Y.kind==="role"?G.toneColor??"#fff":Y.kind==="address"?G.mutedColor??"#aaa":G.textColor??"#fff",z.fillText(Y.text,G.x,$e)}}const p=()=>{},m=K_({borders:[{size:{attribute:"ringSize",defaultValue:0},color:{attribute:"ringColor"}},{size:{attribute:"gapSize",defaultValue:0},color:{transparent:!0}},{size:{attribute:"strokeSize",defaultValue:.1},color:{attribute:"strokeColor"}},{size:{fill:!0},color:{attribute:"bodyColor"}},{size:{attribute:"dotSize",defaultValue:.25},color:{attribute:"dotColor"}}],drawLabel:h,drawHover:p}),y=Ya({arrowHead:{extremity:"target",lengthToThicknessRatio:6,widenessToThicknessRatio:4}}),w=z_({lengthToThicknessRatio:6,widenessToThicknessRatio:4});let g=new Me({type:"directed",multi:!1,allowSelfLoops:!1});const b=new F1(g,s,{allowInvalidContainer:!0,autoRescale:!0,stagePadding:0,itemSizesReference:"positions",zoomToSizeRatioFunction:z=>z,enableCameraPanning:!0,enableCameraZooming:!0,enableCameraRotation:!1,enableEdgeEvents:!1,hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderEdgeLabels:!1,renderLabels:!0,labelRenderedSizeThreshold:lm,labelDensity:1,labelGridCellSize:120,minEdgeThickness:1.6,defaultNodeType:"address",defaultEdgeType:"link",nodeProgramClasses:{address:m},edgeProgramClasses:{link:y,straight:w},defaultDrawNodeLabel:h,defaultDrawNodeHover:p});b.setCustomBBox(TR);const v=b.getMouseCaptor(),k=b.getTouchCaptor();v.removeAllListeners(),k.removeAllListeners(),v.enabled=!1,k.enabled=!1;const _=new Map;let $=_s;function O(z){const G=t.flags().get(z),H=t.selected();return G?.has("expanded")?{width:Xo.expanded,color:d.expanded}:H?.kind==="node"&&H.id===z||t.highlighted()===z?{width:Xo.selected,color:d.selected}:{width:Xo.rest,color:c(t.colorOf(_.get(z)))}}function M(z,G,H){const Y=t.model(),le=t.notes().get(z.id)??null,ie=jr(z,Y.checked_address,le),$e=c(t.colorOf(z)),Ie=O(z.id),de=ie.radius+Ie.width/2,ze=ie.ring?ie.radius+xR+Iu/2:de,fe=ie.ring?Iu/ze:0,Je=ie.ring?Math.max(0,ze-Iu-de)/ze:0,He=t.selected(),pt=ie.ring||Ie.width!==Xo.rest||He?.kind==="node"&&He.id===z.id;return{x:G.x,y:-G.y,size:ze,label:ie.texts.find(Ve=>Ve.kind==="address")?.text??z.address,color:Jt($e),forceLabel:!H||pt,ringColor:Jt(d.edge),ringSize:fe,gapSize:Je,strokeColor:Jt(Ie.color,le?.5:1),strokeSize:Ie.width/ze,bodyColor:Jt(d.node),dotColor:Jt($e),dotSize:ie.dot/ze,outer:ze,texts:ie.texts,toneColor:Jt($e),mutedColor:Jt(d.muted),textColor:Jt(d.text),haloColor:Jt(d.halo)}}function D(z,G){const H=t.selected(),Y=H?.kind==="node"?_.get(H.id)?.address??null:null,le=H?.kind==="edge"&&H.id===z.id,ie=H?.kind==="edge"?le?Xt.related:Xt.faded:Sw(z,Y);return{size:le?SR:kR,color:Jt(c(t.colorOf(G)),ie),curvature:$,type:$?"link":"straight"}}function J(){const z=t.model(),G=t.positions(),{width:H,height:Y}=t.dimensions();_.clear();for(const de of z.nodes)_.set(de.id,de);const le=z.nodes.length>Nu;$=z.edges.length>_R?0:_s;const ie=new Me({type:"directed",multi:!1,allowSelfLoops:!1}),$e=new Map(z.nodes.map(de=>[de.address,de]));for(const de of z.nodes)ie.addNode(de.id,M(de,G[de.id]??{x:H/2,y:Y/2},le));for(const de of z.edges){const ze=$e.get(de.from),fe=$e.get(de.to);!ze||!fe||ze.id===fe.id||ie.hasEdge(de.id)||ie.hasDirectedEdge(ze.id,fe.id)||ie.addDirectedEdgeWithKey(de.id,ze.id,fe.id,D(de,ze))}g=ie;const Ie=t.selected();_e=[Ie?.kind==="node"?Ie.id:null,t.highlighted()].filter(de=>!!de),b.setGraph(g),B()}function se(){const G=t.model().nodes.length>Nu,H=t.positions();g.updateEachNodeAttributes((Y,le)=>{const ie=_.get(Y);return ie?M(ie,H[Y]??{x:le.x,y:-le.y},G):le}),F()}function we(z){const G=z?_.get(z):null;if(!G||!g.hasNode(G.id))return;const H=t.positions()[G.id],Y=g.getNodeAttributes(G.id);g.replaceNodeAttributes(G.id,M(G,H??{x:Y.x,y:-Y.y},t.model().nodes.length>Nu))}let _e=[];function Ge(){const z=t.selected(),G=[z?.kind==="node"?z.id:null,t.highlighted()].filter(H=>!!H);for(const H of new Set([..._e,...G]))we(H);_e=G,F()}function F(){const z=t.model(),G=new Map(z.nodes.map(Y=>[Y.address,Y])),H=new Map(z.edges.map(Y=>[Y.id,Y]));g.updateEachEdgeAttributes((Y,le)=>{const ie=H.get(Y),$e=ie&&G.get(ie.from);return ie&&$e?D(ie,$e):le})}function B(){const{width:z,height:G}=t.dimensions(),H=b.getDimensions();if(!H.width||!H.height)return;const Y=Math.min(H.width/z,H.height/G),le=t.transform(),ie=le.scale*Y,$e=(H.width-z*Y)/2+le.x*Y,Ie=(H.height-G*Y)/2+le.y*Y,de={x:.5,y:.5,ratio:1,angle:0},ze=b.framedGraphToViewport({x:.5,y:.5},{cameraState:de}),fe=(b.framedGraphToViewport({x:.6,y:.5},{cameraState:de}).x-ze.x)/.1,Je=(b.framedGraphToViewport({x:.5,y:.6},{cameraState:de}).y-ze.y)/.1,He=fe/(Ru*ie);b.getCamera().setState({ratio:He,angle:0,x:.5-dm/Ru-($e-ze.x)*He/fe,y:.5-dm/Ru-(Ie-ze.y)*He/Je})}function W(z){const G=t.transform(),H={x:(z.x-G.x)/G.scale,y:(z.y-G.y)/G.scale},Y=t.positions();let le=null,ie=1/0;if(g.forEachNode((ze,fe)=>{const Je=Y[ze];if(!Je)return;const He=Math.hypot(H.x-Je.x,H.y-Je.y);He<=fe.size+1/G.scale&&He<ie&&(le=ze,ie=He)}),le)return{kind:"node",id:le};const $e=ER/G.scale;let Ie=null,de=1/0;return g.forEachEdge((ze,fe,Je,He)=>{const pt=Y[Je],Ve=Y[He];if(!pt||!Ve)return;const C=Math.hypot(Ve.x-pt.x,Ve.y-pt.y)*(.5+$)+$e;if(Math.hypot(H.x-(pt.x+Ve.x)/2,H.y-(pt.y+Ve.y)/2)>C)return;const P=$?AR(H,pt,Ve,$):X_(H,pt,Ve);P<=$e&&P<de&&(Ie=ze,de=P)}),Ie?{kind:"edge",id:Ie}:{kind:"canvas",id:null}}let Q=0,K=null,I=null;const R=z=>{z.buttons||(I=z,!Q&&(Q=o.requestAnimationFrame(()=>{Q=0;const G=I;if(!G)return;const H=s.getBoundingClientRect(),{width:Y,height:le}=t.dimensions(),ie=Math.min(H.width/Y,H.height/le)||1,$e=W({x:(G.clientX-H.left-(H.width-Y*ie)/2)/ie,y:(G.clientY-H.top-(H.height-le*ie)/2)/ie}),Ie=$e.kind==="canvas"?null:`${$e.kind}:${$e.id}`;if(s.style.cursor=Ie?"pointer":"",Ie!==K){if(K=Ie,!Ie){n.hideTooltip();return}if($e.kind==="node"){const de=_.get($e.id);de&&n.showTooltip(G,ec(de))}else{const de=t.model().edges.find(ze=>ze.id===$e.id);de&&n.showTooltip(G,tc(de,t.now()))}}})))},U=()=>{K=null,s.style.cursor="",n.hideTooltip()};s.addEventListener("pointermove",R),s.addEventListener("pointerleave",U);let ne=null;const ce=z=>{z.preventDefault(),!ne&&(ne=setTimeout(()=>{ne=null,n.lost()},$R))},ee=()=>{ne&&clearTimeout(ne),ne=null,n.lost()},Ee=Object.values(b.getCanvases());for(const z of Ee)z.addEventListener("webglcontextlost",ce),z.addEventListener("webglcontextrestored",ee);function Ae(){const z=t.positions();let G=null;return g.forEachEdge((H,Y,le,ie)=>{const $e=z[le],Ie=z[ie];if(!$e||!Ie||!$)return;const de=J_($e,Y_($e,Ie,$),Ie,.5);G=G??{x1:de.x,y1:de.y,x2:de.x,y2:de.y},G.x1=Math.min(G.x1,de.x),G.y1=Math.min(G.y1,de.y),G.x2=Math.max(G.x2,de.x),G.y2=Math.max(G.y2,de.y)}),G}return{kind:"webgl",surface:s,build:J,geometry(){const z=t.positions();g.updateEachNodeAttributes((G,H)=>{const Y=z[G];return Y?{...H,x:Y.x,y:-Y.y}:H},{attributes:["x","y"]}),B()},moveNode(z){const G=t.positions()[z];G&&g.hasNode(z)&&g.mergeNodeAttributes(z,{x:G.x,y:-G.y})},endMove(){},camera:B,selection:Ge,flag:z=>we(z),theme(){f(),se()},resize(){b.resize(!0),B()},pick:W,linkBounds:Ae,destroy(){ne&&clearTimeout(ne),Q&&o.cancelAnimationFrame(Q),s.removeEventListener("pointermove",R),s.removeEventListener("pointerleave",U);for(const z of Ee)z.removeEventListener("webglcontextlost",ce),z.removeEventListener("webglcontextrestored",ee);b.kill(),s.remove()}}}q$("webgl",IR);const Tn=document.getElementById("view"),ks=()=>typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches;let Sn={},on=ys(document,Sn,{prefersDark:ks}),gt=null,fm=null;eh(Tn);const hm=B$(location);hm?NR(hm):RR();async function NR(e){document.documentElement.dataset.mode="browser",document.title=G$,on=ys(document,{},{prefersDark:ks}),typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").addEventListener?.("change",()=>{const n=on;on=ys(document,{},{prefersDark:ks}),gt&&on!==n&>.setTheme(on)}),eh(Tn,"Loading the graph");const t=await H$(e,(n,r)=>fetch(n,r));if(!t){yi(Tn,null,j$),document.documentElement.dataset.view="text";return}gt=t_(Tn,t.result,{host:V$((n,r)=>fetch(n,r),(n,r,i)=>window.open(n,r,i)),displayMode:"fullscreen",availableDisplayModes:["fullscreen"],toolInput:t.arguments,browser:!0}),document.documentElement.dataset.view=gt.kind}function RR(){const e=new Zf({name:"chain-insights-view",version:"1.0.0"},{});function t(r){const i=on;on=ys(document,r,{prefersDark:ks,applyVariables:(o,s)=>F$(o,s),applyFonts:U$}),gt&&on!==i&>.setTheme(on),gt?.setDisplayMode(r.displayMode,r.availableDisplayModes)}function n(r){gt?.destroy(),gt=null;const i=yu(e.getHostContext(),Sn);gt=t_(Tn,r,{host:e,availableDisplayModes:i.availableDisplayModes,displayMode:i.displayMode,toolInput:fm}),document.documentElement.dataset.view=gt.kind}e.ontoolinput=r=>{fm=r.arguments&&typeof r.arguments=="object"?r.arguments:null;const i=typeof r.arguments?.address=="string"?r.arguments.address:null;gt||eh(Tn,i?`Loading the graph of ${i}`:"Loading the Chain Insights view")},e.ontoolresult=r=>{n(r)},e.ontoolcancelled=()=>{gt||yi(Tn,null,"The tool call was cancelled. Nothing to draw.")},e.onhostcontextchanged=r=>{Sn=yu(Sn,r),t(Sn)},e.onteardown=async()=>(gt?.destroy(),gt=null,{}),e.onerror=r=>{console.warn("chain-insights-view:",r)},e.connect(new gw(window.parent,window.parent)).then(()=>{Sn=yu(Sn,e.getHostContext()),t(Sn)},r=>{console.warn("chain-insights-view: no host answered",r),yi(Tn,null,"This view opens inside Claude, next to a Chain Insights tool answer.")})}
|
|
719
|
+
`);return n}var Y_=WebGLRenderingContext,dm=Y_.UNSIGNED_BYTE,Yo=Y_.FLOAT;function X_(e){var t,n=lm(lm({},SR),e||{}),r=n.borders,i=n.drawLabel,o=n.drawHover,s=["u_sizeRatio","u_correctionRatio","u_matrix"].concat(Au(r.flatMap(function(a,u){var c=a.color;return"value"in c?["u_borderColor_".concat(u+1)]:[]})));return t=(function(a){vR(u,a);function u(){var c;fR(this,u);for(var l=arguments.length,d=new Array(l),f=0;f<l;f++)d[f]=arguments[f];return c=yR(this,u,[].concat(d)),rr(mc(c),"drawLabel",i),rr(mc(c),"drawHover",o),c}return mR(u,[{key:"getDefinition",value:function(){return{VERTICES:3,VERTEX_SHADER_SOURCE:$R(n),FRAGMENT_SHADER_SOURCE:xR(n),METHOD:WebGLRenderingContext.TRIANGLES,UNIFORMS:s,ATTRIBUTES:[{name:"a_position",size:2,type:Yo},{name:"a_id",size:4,type:dm,normalized:!0},{name:"a_size",size:1,type:Yo}].concat(Au(r.flatMap(function(l,d){var f=l.color;return"attribute"in f?[{name:"a_borderColor_".concat(d+1),size:4,type:dm,normalized:!0}]:[]})),Au(r.flatMap(function(l,d){var f=l.size;return"attribute"in f?[{name:"a_borderSize_".concat(d+1),size:1,type:Yo}]:[]}))),CONSTANT_ATTRIBUTES:[{name:"a_angle",size:1,type:Yo}],CONSTANT_DATA:[[u.ANGLE_1],[u.ANGLE_2],[u.ANGLE_3]]}}},{key:"processVisibleItem",value:function(l,d,f){var h=this.array;h[d++]=f.x,h[d++]=f.y,h[d++]=l,h[d++]=f.size,r.forEach(function(p){var m=p.color;"attribute"in m&&(h[d++]=Rn(f[m.attribute]||m.defaultValue||ER))}),r.forEach(function(p){var m=p.size;"attribute"in m&&(h[d++]=f[m.attribute]||m.defaultValue)})}},{key:"setUniforms",value:function(l,d){var f=d.gl,h=d.uniformLocations,p=h.u_sizeRatio,m=h.u_correctionRatio,y=h.u_matrix;f.uniform1f(m,l.correctionRatio),f.uniform1f(p,l.sizeRatio),f.uniformMatrix3fv(y,!1,l.matrix),r.forEach(function(w,g){var b=w.color;if("value"in b){var v=h["u_borderColor_".concat(g+1)],k=RN(b.value),_=dR(k,4),$=_[0],D=_[1],M=_[2],O=_[3];f.uniform4f(v,$/255,D/255,M/255,O/255)}})}}]),u})(A_),rr(t,"ANGLE_1",0),rr(t,"ANGLE_2",2*Math.PI/3),rr(t,"ANGLE_3",4*Math.PI/3),t}X_();const _s=.18,TR=500,CR=2,AR=3,Xo={rest:2,selected:4,expanded:5},IR=6,Iu=2,NR=8,fm=6,Nu=400,RR=2e3,LR={x:[0,1e3],y:[0,1e3]},Ru=1e3,hm=500,zR={role:{size:13,font:e=>`600 ${e}px Inter, system-ui, sans-serif`},address:{size:11,font:e=>`400 ${e}px ui-monospace, monospace`},note:{size:11,font:e=>`italic 400 ${e}px Inter, system-ui, sans-serif`}};function Qo(e){return Math.max(0,Math.min(255,Math.round(e))).toString(16).padStart(2,"0")}function Jt(e,t=1){return`#${Qo(e.r)}${Qo(e.g)}${Qo(e.b)}${Qo(e.a*t*255)}`}function Q_(e,t,n,r){const i=1-r;return{x:i*i*e.x+2*i*r*t.x+r*r*n.x,y:i*i*e.y+2*i*r*t.y+r*r*n.y}}function ek(e,t,n=_s){const r=t.x-e.x,i=t.y-e.y;return{x:(e.x+t.x)/2+i*n,y:(e.y+t.y)/2-r*n}}function tk(e,t,n){const r=n.x-t.x,i=n.y-t.y,o=r*r+i*i,s=o?Math.max(0,Math.min(1,((e.x-t.x)*r+(e.y-t.y)*i)/o)):0;return Math.hypot(e.x-(t.x+s*r),e.y-(t.y+s*i))}function PR(e,t,n,r=_s){const i=ek(t,n,r);let o=1/0,s=t;for(let a=1;a<=12;a++){const u=Q_(t,i,n,a/12);o=Math.min(o,tk(e,s,u)),s=u}return o}function OR(e,t,n,r){const i=e.ownerDocument,o=i.defaultView,s=i.createElement("div");s.className="cia-graph-webgl",s.tabIndex=0,s.setAttribute("role","group"),s.setAttribute("aria-label",r.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.");const a=i.createElement("span");a.hidden=!0,s.append(a),e.append(s);const u=new Map;function c(z){const j=u.get(z);if(j)return j;a.style.color="",a.style.color=z;const H=o.getComputedStyle(a).color.match(/[\d.]+/g)?.map(Number)??[0,0,0],Y={r:H[0]??0,g:H[1]??0,b:H[2]??0,a:H[3]??1};return u.set(z,Y),Y}const l=z=>c(`var(--cia-graph-${z})`);let d;function f(){u.clear(),d={node:l("node"),edge:l("edge"),halo:l("halo"),selected:l("selected"),expanded:l("expanded"),text:l("text"),muted:l("muted")}}f();function h(z,j){if(!j.texts?.length||!j.outer)return;const H=j.size/j.outer;z.textAlign="center",z.textBaseline="alphabetic",z.lineJoin="round";for(const Y of j.texts){const le=zR[Y.kind],ie=le.size*H;if(ie<fm)continue;z.font=le.font(ie);const $e=j.y+Y.y*H;z.lineWidth=4*H,z.strokeStyle=j.haloColor??"#000",z.strokeText(Y.text,j.x,$e),z.fillStyle=Y.kind==="role"?j.toneColor??"#fff":Y.kind==="address"?j.mutedColor??"#aaa":j.textColor??"#fff",z.fillText(Y.text,j.x,$e)}}const p=()=>{},m=X_({borders:[{size:{attribute:"ringSize",defaultValue:0},color:{attribute:"ringColor"}},{size:{attribute:"gapSize",defaultValue:0},color:{transparent:!0}},{size:{attribute:"strokeSize",defaultValue:.1},color:{attribute:"strokeColor"}},{size:{fill:!0},color:{attribute:"bodyColor"}},{size:{attribute:"dotSize",defaultValue:.25},color:{attribute:"dotColor"}}],drawLabel:h,drawHover:p}),y=Ya({arrowHead:{extremity:"target",lengthToThicknessRatio:6,widenessToThicknessRatio:4}}),w=D_({lengthToThicknessRatio:6,widenessToThicknessRatio:4});let g=new Me({type:"directed",multi:!1,allowSelfLoops:!1});const b=new H1(g,s,{allowInvalidContainer:!0,autoRescale:!0,stagePadding:0,itemSizesReference:"positions",zoomToSizeRatioFunction:z=>z,enableCameraPanning:!0,enableCameraZooming:!0,enableCameraRotation:!1,enableEdgeEvents:!1,hideEdgesOnMove:!1,hideLabelsOnMove:!1,renderEdgeLabels:!1,renderLabels:!0,labelRenderedSizeThreshold:fm,labelDensity:1,labelGridCellSize:120,minEdgeThickness:1.6,defaultNodeType:"address",defaultEdgeType:"link",nodeProgramClasses:{address:m},edgeProgramClasses:{link:y,straight:w},defaultDrawNodeLabel:h,defaultDrawNodeHover:p});b.setCustomBBox(LR);const v=b.getMouseCaptor(),k=b.getTouchCaptor();v.removeAllListeners(),k.removeAllListeners(),v.enabled=!1,k.enabled=!1;const _=new Map;let $=_s;function D(z){const j=t.flags().get(z),H=t.selected();return j?.has("expanded")?{width:Xo.expanded,color:d.expanded}:H?.kind==="node"&&H.id===z||t.highlighted()===z?{width:Xo.selected,color:d.selected}:{width:Xo.rest,color:c(t.colorOf(_.get(z)))}}function M(z,j,H){const Y=t.model(),le=t.notes().get(z.id)??null,ie=jr(z,Y.checked_address,le),$e=c(t.colorOf(z)),Ie=D(z.id),de=ie.radius+Ie.width/2,ze=ie.ring?ie.radius+IR+Iu/2:de,fe=ie.ring?Iu/ze:0,Je=ie.ring?Math.max(0,ze-Iu-de)/ze:0,He=t.selected(),pt=ie.ring||Ie.width!==Xo.rest||He?.kind==="node"&&He.id===z.id;return{x:j.x,y:-j.y,size:ze,label:ie.texts.find(Ve=>Ve.kind==="address")?.text??z.address,color:Jt($e),forceLabel:!H||pt,ringColor:Jt(d.edge),ringSize:fe,gapSize:Je,strokeColor:Jt(Ie.color,le?.5:1),strokeSize:Ie.width/ze,bodyColor:Jt(d.node),dotColor:Jt($e),dotSize:ie.dot/ze,outer:ze,texts:ie.texts,toneColor:Jt($e),mutedColor:Jt(d.muted),textColor:Jt(d.text),haloColor:Jt(d.halo)}}function O(z,j){const H=t.selected(),Y=H?.kind==="node"?_.get(H.id)?.address??null:null,le=H?.kind==="edge"&&H.id===z.id,ie=H?.kind==="edge"?le?Xt.related:Xt.faded:$w(z,Y);return{size:le?AR:CR,color:Jt(c(t.colorOf(j)),ie),curvature:$,type:$?"link":"straight"}}function J(){const z=t.model(),j=t.positions(),{width:H,height:Y}=t.dimensions();_.clear();for(const de of z.nodes)_.set(de.id,de);const le=z.nodes.length>Nu;$=z.edges.length>TR?0:_s;const ie=new Me({type:"directed",multi:!1,allowSelfLoops:!1}),$e=new Map(z.nodes.map(de=>[de.address,de]));for(const de of z.nodes)ie.addNode(de.id,M(de,j[de.id]??{x:H/2,y:Y/2},le));for(const de of z.edges){const ze=$e.get(de.from),fe=$e.get(de.to);!ze||!fe||ze.id===fe.id||ie.hasEdge(de.id)||ie.hasDirectedEdge(ze.id,fe.id)||ie.addDirectedEdgeWithKey(de.id,ze.id,fe.id,O(de,ze))}g=ie;const Ie=t.selected();_e=[Ie?.kind==="node"?Ie.id:null,t.highlighted()].filter(de=>!!de),b.setGraph(g),B()}function se(){const j=t.model().nodes.length>Nu,H=t.positions();g.updateEachNodeAttributes((Y,le)=>{const ie=_.get(Y);return ie?M(ie,H[Y]??{x:le.x,y:-le.y},j):le}),F()}function we(z){const j=z?_.get(z):null;if(!j||!g.hasNode(j.id))return;const H=t.positions()[j.id],Y=g.getNodeAttributes(j.id);g.replaceNodeAttributes(j.id,M(j,H??{x:Y.x,y:-Y.y},t.model().nodes.length>Nu))}let _e=[];function Ge(){const z=t.selected(),j=[z?.kind==="node"?z.id:null,t.highlighted()].filter(H=>!!H);for(const H of new Set([..._e,...j]))we(H);_e=j,F()}function F(){const z=t.model(),j=new Map(z.nodes.map(Y=>[Y.address,Y])),H=new Map(z.edges.map(Y=>[Y.id,Y]));g.updateEachEdgeAttributes((Y,le)=>{const ie=H.get(Y),$e=ie&&j.get(ie.from);return ie&&$e?O(ie,$e):le})}function B(){const{width:z,height:j}=t.dimensions(),H=b.getDimensions();if(!H.width||!H.height)return;const Y=Math.min(H.width/z,H.height/j),le=t.transform(),ie=le.scale*Y,$e=(H.width-z*Y)/2+le.x*Y,Ie=(H.height-j*Y)/2+le.y*Y,de={x:.5,y:.5,ratio:1,angle:0},ze=b.framedGraphToViewport({x:.5,y:.5},{cameraState:de}),fe=(b.framedGraphToViewport({x:.6,y:.5},{cameraState:de}).x-ze.x)/.1,Je=(b.framedGraphToViewport({x:.5,y:.6},{cameraState:de}).y-ze.y)/.1,He=fe/(Ru*ie);b.getCamera().setState({ratio:He,angle:0,x:.5-hm/Ru-($e-ze.x)*He/fe,y:.5-hm/Ru-(Ie-ze.y)*He/Je})}function W(z){const j=t.transform(),H={x:(z.x-j.x)/j.scale,y:(z.y-j.y)/j.scale},Y=t.positions();let le=null,ie=1/0;if(g.forEachNode((ze,fe)=>{const Je=Y[ze];if(!Je)return;const He=Math.hypot(H.x-Je.x,H.y-Je.y);He<=fe.size+1/j.scale&&He<ie&&(le=ze,ie=He)}),le)return{kind:"node",id:le};const $e=NR/j.scale;let Ie=null,de=1/0;return g.forEachEdge((ze,fe,Je,He)=>{const pt=Y[Je],Ve=Y[He];if(!pt||!Ve)return;const C=Math.hypot(Ve.x-pt.x,Ve.y-pt.y)*(.5+$)+$e;if(Math.hypot(H.x-(pt.x+Ve.x)/2,H.y-(pt.y+Ve.y)/2)>C)return;const P=$?PR(H,pt,Ve,$):tk(H,pt,Ve);P<=$e&&P<de&&(Ie=ze,de=P)}),Ie?{kind:"edge",id:Ie}:{kind:"canvas",id:null}}let Q=0,K=null,I=null;const R=z=>{z.buttons||(I=z,!Q&&(Q=o.requestAnimationFrame(()=>{Q=0;const j=I;if(!j)return;const H=s.getBoundingClientRect(),{width:Y,height:le}=t.dimensions(),ie=Math.min(H.width/Y,H.height/le)||1,$e=W({x:(j.clientX-H.left-(H.width-Y*ie)/2)/ie,y:(j.clientY-H.top-(H.height-le*ie)/2)/ie}),Ie=$e.kind==="canvas"?null:`${$e.kind}:${$e.id}`;if(s.style.cursor=Ie?"pointer":"",Ie!==K){if(K=Ie,!Ie){n.hideTooltip();return}if($e.kind==="node"){const de=_.get($e.id);de&&n.showTooltip(j,ec(de))}else{const de=t.model().edges.find(ze=>ze.id===$e.id);de&&n.showTooltip(j,tc(de,t.now()))}}})))},G=()=>{K=null,s.style.cursor="",n.hideTooltip()};s.addEventListener("pointermove",R),s.addEventListener("pointerleave",G);let ne=null;const ce=z=>{z.preventDefault(),!ne&&(ne=setTimeout(()=>{ne=null,n.lost()},RR))},ee=()=>{ne&&clearTimeout(ne),ne=null,n.lost()},xe=Object.values(b.getCanvases());for(const z of xe)z.addEventListener("webglcontextlost",ce),z.addEventListener("webglcontextrestored",ee);function Ae(){const z=t.positions();let j=null;return g.forEachEdge((H,Y,le,ie)=>{const $e=z[le],Ie=z[ie];if(!$e||!Ie||!$)return;const de=Q_($e,ek($e,Ie,$),Ie,.5);j=j??{x1:de.x,y1:de.y,x2:de.x,y2:de.y},j.x1=Math.min(j.x1,de.x),j.y1=Math.min(j.y1,de.y),j.x2=Math.max(j.x2,de.x),j.y2=Math.max(j.y2,de.y)}),j}return{kind:"webgl",surface:s,build:J,geometry(){const z=t.positions();g.updateEachNodeAttributes((j,H)=>{const Y=z[j];return Y?{...H,x:Y.x,y:-Y.y}:H},{attributes:["x","y"]}),B()},moveNode(z){const j=t.positions()[z];j&&g.hasNode(z)&&g.mergeNodeAttributes(z,{x:j.x,y:-j.y})},endMove(){},camera:B,selection:Ge,flag:z=>we(z),theme(){f(),se()},resize(){b.resize(!0),B()},pick:W,linkBounds:Ae,destroy(){ne&&clearTimeout(ne),Q&&o.cancelAnimationFrame(Q),s.removeEventListener("pointermove",R),s.removeEventListener("pointerleave",G);for(const z of xe)z.removeEventListener("webglcontextlost",ce),z.removeEventListener("webglcontextrestored",ee);b.kill(),s.remove()}}}X$("webgl",OR);const $n=document.getElementById("view"),ks=()=>typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches;let kn={},sn=ys(document,kn,{prefersDark:ks}),gt=null,pm=null;eh($n);const mm=K$(location);mm?DR(mm):MR();async function DR(e){document.documentElement.dataset.mode="browser",document.title=B$,sn=ys(document,{},{prefersDark:ks}),typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").addEventListener?.("change",()=>{const n=sn;sn=ys(document,{},{prefersDark:ks}),gt&&sn!==n&>.setTheme(sn)}),eh($n,"Loading the graph");const t=await J$(e,(n,r)=>fetch(n,r),document);if(!t){yi($n,null,H$),document.documentElement.dataset.view="text";return}gt=i_($n,t.result,{host:Y$((n,r)=>fetch(n,r),(n,r,i)=>window.open(n,r,i)),displayMode:"fullscreen",availableDisplayModes:["fullscreen"],toolInput:t.arguments,browser:!0}),document.documentElement.dataset.view=gt.kind}function MR(){const e=new Zf({name:"chain-insights-view",version:"1.0.0"},{});function t(r){const i=sn;sn=ys(document,r,{prefersDark:ks,applyVariables:(o,s)=>j$(o,s),applyFonts:Z$}),gt&&sn!==i&>.setTheme(sn),gt?.setDisplayMode(r.displayMode,r.availableDisplayModes)}function n(r){gt?.destroy(),gt=null;const i=yu(e.getHostContext(),kn);gt=i_($n,r,{host:e,availableDisplayModes:i.availableDisplayModes,displayMode:i.displayMode,toolInput:pm}),document.documentElement.dataset.view=gt.kind}e.ontoolinput=r=>{pm=r.arguments&&typeof r.arguments=="object"?r.arguments:null;const i=typeof r.arguments?.address=="string"?r.arguments.address:null;gt||eh($n,i?`Loading the graph of ${i}`:"Loading the Chain Insights view")},e.ontoolresult=r=>{n(r)},e.ontoolcancelled=()=>{gt||yi($n,null,"The tool call was cancelled. Nothing to draw.")},e.onhostcontextchanged=r=>{kn=yu(kn,r),t(kn)},e.onteardown=async()=>(gt?.destroy(),gt=null,{}),e.onerror=r=>{console.warn("chain-insights-view:",r)},e.connect(new vw(window.parent,window.parent)).then(()=>{kn=yu(kn,e.getHostContext()),t(kn)},r=>{console.warn("chain-insights-view: no host answered",r),yi($n,null,"This view opens inside Claude, next to a Chain Insights tool answer.")})}
|
|
720
720
|
</script>
|
|
721
|
-
<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-expanded:#4da3ff;--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-expanded:#0057d9;--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.is-focused .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 .cia-graph-node[data-flag-expanded] .cia-graph-node-body{stroke:var(--cia-graph-expanded);stroke-width:5}.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}.cia-graph-webgl{position:relative;display:block;width:100%;height:100%;min-height:inherit;touch-action:none;outline:none;overflow:hidden;background:radial-gradient(circle,var(--cia-graph-dot) 1px,transparent 1px) 0 0/24px 24px,var(--cia-graph-canvas)}.cia-graph-webgl:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:-2px}: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-visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);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}.cia-graph-surface.cv-notice{box-sizing:border-box;margin:0;padding:6px 12px;border-radius:8px;font:400 13px/1.4 var(--font-sans,system-ui,-apple-system,"Segoe UI",sans-serif)}.cia-graph-surface.cv-notice-refused{border-left:3px solid var(--cia-graph-danger)}.cv-notice-empty{color:var(--cia-graph-muted)}.cv-notice p{margin:0}.cv-notice-line{overflow-wrap:anywhere}.cv-notice summary{cursor:pointer}.cv-notice summary:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:2px}.cv-notice-full{margin:4px 0 0;color:var(--cia-graph-muted);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:640px;max-height:640px;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;padding:0 0 8px;color:var(--cia-graph-text);font-size:12px;display:flex;flex-direction:column;gap:4px}.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;word-break:break-all}.cv-detail-meta{display:flex;flex-direction:column;gap:3px}.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;max-height:640px;overflow:auto;font-family:var(--font-sans,system-ui,sans-serif)}.cv-chart .cv-muted{color:var(--cia-graph-muted);font-size:12px}.cv-chart-summary{line-height:1.45}.cv-chart-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;padding:2px 14px 4px}.cv-chart-legend{display:flex;flex-wrap:wrap;gap:6px}.cv-chart-series,.cv-chart-reset{display:inline-flex;align-items:center;gap:6px;min-height:28px;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-chart-series:hover,.cv-chart-reset:hover{background:var(--cia-graph-hover)}.cv-chart-series[aria-pressed=false]{color:var(--cia-graph-muted);text-decoration:line-through}.cv-chart-series[aria-disabled=true]{cursor:default}.cv-chart-reset{margin-left:auto}.cv-chart-bar>.cv-toggle{margin-left:auto}.cv-chart-reset:not([hidden])+.cv-toggle{margin-left:0}.cv-chart-failure{fill:var(--cia-graph-hover)}.cv-chart-reset[hidden]{display:none}.cv-chart-key{display:inline-block;flex:none;width:10px;height:10px;box-sizing:border-box;border-radius:3px;border:2px solid var(--cv-key);background:var(--cv-key)}.cv-chart-series[aria-pressed=false] .cv-chart-key{background:transparent}.cv-chart-series:focus-visible,.cv-chart-reset:focus-visible,.cv-chart-plot:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:2px}.cv-chart-body{position:relative;padding:4px 14px 12px}.cv-chart-plot{border-radius:4px;cursor:crosshair;touch-action:pan-y;user-select:none;-webkit-user-select:none}.cv-chart-svg{display:block;width:100%;height:auto}.cv-chart-brush{fill:var(--cia-graph-hover);stroke:var(--cia-graph-active);stroke-width:1}.cv-chart-crossline{stroke:var(--cia-graph-muted);stroke-width:1;stroke-dasharray:3 3}.cv-chart-focus{stroke:var(--cia-graph-canvas);stroke-width:2}.cv-chart-readout{position:absolute;z-index:2;box-sizing:border-box;min-width:170px;max-width:280px;padding:8px 10px;border:1px solid var(--cia-graph-border);border-radius:8px;background:var(--cia-graph-canvas);color:var(--cia-graph-text);font:12px/1.4 var(--font-sans,system-ui,sans-serif);pointer-events:none}.cv-chart-readout[hidden]{display:none}.cv-chart-readout[data-side=left]{transform:translate(-100%)}.cv-chart-readout time{display:block;margin-bottom:4px;font-weight:600}.cv-chart-readout-note{margin:0 0 4px;color:var(--cia-graph-muted)}.cv-chart-readout dl{display:grid;grid-template-columns:auto auto;gap:2px 12px;margin:0}.cv-chart-readout dt{display:flex;align-items:center;gap:6px;min-width:0;color:var(--cia-graph-muted);overflow-wrap:anywhere}.cv-chart-readout dd{margin:0;text-align:right;font-variant-numeric:tabular-nums;font-weight:600}.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)}}.cv-side{display:flex;flex-direction:column;flex:none;box-sizing:border-box;width:min(46%,340px);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-side[hidden]{display:none}.cv-side-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}.cv-side-head strong{font-size:13px}.cv-side-actions{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px}.cv-remaining{margin:0 0 8px;font-size:12px;color:var(--cia-graph-muted)}.cv-remaining[hidden]{display:none}.cv-side-actions:not(:has(button:not([hidden]))){display:none}.cv-side .cv-button:disabled{opacity:.5;cursor:default}.cv-linkpanel-embedded{flex:1;min-height:0;width:auto;padding:8px 0 0;border:0;border-top:1px solid var(--cia-graph-divider);overflow:hidden}.cv-side>.cv-detail{max-height:40%;overflow:auto}.cv-linkpanel-embedded>[data-link-pair]{display:none}.cv-linkpanel-embedded .cv-link-body{min-height:44px}.cv-side:not(:has(.cv-linkpanel-embedded:not([hidden])))>.cv-detail{max-height:none}.cv-link-pair code{word-break:break-all}@media(max-width:560px){.cv-side{position:absolute;inset:0;width:auto;border-left:0;background:var(--cia-graph-surface)}.cv-side .cv-linkpanel-embedded{position:static;width:auto;border:0;border-top:1px solid var(--cia-graph-divider);background:none}}html[data-mode=browser],html[data-mode=browser] body{height:100%}html[data-mode=browser] body{background:var(--cv-surface)}
|
|
721
|
+
<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-expanded:#4da3ff;--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-expanded:#0057d9;--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.is-focused .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 .cia-graph-node[data-flag-expanded] .cia-graph-node-body{stroke:var(--cia-graph-expanded);stroke-width:5}.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}.cia-graph-webgl{position:relative;display:block;width:100%;height:100%;min-height:inherit;touch-action:none;outline:none;overflow:hidden;background:radial-gradient(circle,var(--cia-graph-dot) 1px,transparent 1px) 0 0/24px 24px,var(--cia-graph-canvas)}.cia-graph-webgl:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:-2px}: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-visually-hidden{position:absolute;width:1px;height:1px;margin:-1px;padding:0;border:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);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}.cia-graph-surface.cv-notice{box-sizing:border-box;margin:0;padding:6px 12px;border-radius:8px;font:400 13px/1.4 var(--font-sans,system-ui,-apple-system,"Segoe UI",sans-serif)}.cia-graph-surface.cv-notice-refused{border-left:3px solid var(--cia-graph-danger)}.cv-notice-empty{color:var(--cia-graph-muted)}.cv-notice p{margin:0}.cv-notice-line{overflow-wrap:anywhere}.cv-notice summary{cursor:pointer}.cv-notice summary:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:2px}.cv-notice-full{margin:4px 0 0;color:var(--cia-graph-muted);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:640px;max-height:640px;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;padding:0 0 8px;color:var(--cia-graph-text);font-size:12px;display:flex;flex-direction:column;gap:4px}.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;word-break:break-all}.cv-detail-meta{display:flex;flex-direction:column;gap:3px}.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;max-height:640px;overflow:auto;font-family:var(--font-sans,system-ui,sans-serif)}.cv-chart .cv-muted{color:var(--cia-graph-muted);font-size:12px}.cv-chart-summary{line-height:1.45}.cv-chart-bar{display:flex;flex-wrap:wrap;align-items:center;gap:6px 8px;padding:2px 14px 4px}.cv-chart-legend{display:flex;flex-wrap:wrap;gap:6px}.cv-chart-series,.cv-chart-reset{display:inline-flex;align-items:center;gap:6px;min-height:28px;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-chart-series:hover,.cv-chart-reset:hover{background:var(--cia-graph-hover)}.cv-chart-series[aria-pressed=false]{color:var(--cia-graph-muted);text-decoration:line-through}.cv-chart-series[aria-disabled=true]{cursor:default}.cv-chart-reset{margin-left:auto}.cv-chart-bar>.cv-toggle{margin-left:auto}.cv-chart-reset:not([hidden])+.cv-toggle{margin-left:0}.cv-chart-failure{fill:var(--cia-graph-hover)}.cv-chart-reset[hidden]{display:none}.cv-chart-key{display:inline-block;flex:none;width:10px;height:10px;box-sizing:border-box;border-radius:3px;border:2px solid var(--cv-key);background:var(--cv-key)}.cv-chart-series[aria-pressed=false] .cv-chart-key{background:transparent}.cv-chart-series:focus-visible,.cv-chart-reset:focus-visible,.cv-chart-plot:focus-visible{outline:2px solid var(--cia-graph-active);outline-offset:2px}.cv-chart-body{position:relative;padding:4px 14px 12px}.cv-chart-plot{border-radius:4px;cursor:crosshair;touch-action:pan-y;user-select:none;-webkit-user-select:none}.cv-chart-svg{display:block;width:100%;height:auto}.cv-chart-brush{fill:var(--cia-graph-hover);stroke:var(--cia-graph-active);stroke-width:1}.cv-chart-crossline{stroke:var(--cia-graph-muted);stroke-width:1;stroke-dasharray:3 3}.cv-chart-focus{stroke:var(--cia-graph-canvas);stroke-width:2}.cv-chart-readout{position:absolute;z-index:2;box-sizing:border-box;min-width:170px;max-width:280px;padding:8px 10px;border:1px solid var(--cia-graph-border);border-radius:8px;background:var(--cia-graph-canvas);color:var(--cia-graph-text);font:12px/1.4 var(--font-sans,system-ui,sans-serif);pointer-events:none}.cv-chart-readout[hidden]{display:none}.cv-chart-readout[data-side=left]{transform:translate(-100%)}.cv-chart-readout time{display:block;margin-bottom:4px;font-weight:600}.cv-chart-readout-note{margin:0 0 4px;color:var(--cia-graph-muted)}.cv-chart-readout dl{display:grid;grid-template-columns:auto auto;gap:2px 12px;margin:0}.cv-chart-readout dt{display:flex;align-items:center;gap:6px;min-width:0;color:var(--cia-graph-muted);overflow-wrap:anywhere}.cv-chart-readout dd{margin:0;text-align:right;font-variant-numeric:tabular-nums;font-weight:600}.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)}}.cv-side{display:flex;flex-direction:column;flex:none;box-sizing:border-box;width:min(46%,340px);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-side[hidden]{display:none}.cv-side-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}.cv-side-head strong{font-size:13px}.cv-side-actions{display:flex;gap:6px;flex-wrap:wrap;margin-bottom:8px}.cv-remaining{margin:0 0 8px;font-size:12px;color:var(--cia-graph-muted)}.cv-remaining[hidden]{display:none}.cv-side-actions:not(:has(button:not([hidden]))){display:none}.cv-side .cv-button:disabled{opacity:.5;cursor:default}.cv-linkpanel-embedded{flex:1;min-height:0;width:auto;padding:8px 0 0;border:0;border-top:1px solid var(--cia-graph-divider);overflow:hidden}.cv-side>.cv-detail{max-height:40%;overflow:auto}.cv-linkpanel-embedded>[data-link-pair]{display:none}.cv-linkpanel-embedded .cv-link-body{min-height:44px}.cv-side:not(:has(.cv-linkpanel-embedded:not([hidden])))>.cv-detail{max-height:none}.cv-link-pair code{word-break:break-all}@media(max-width:560px){.cv-side{position:absolute;inset:0;width:auto;border-left:0;background:var(--cia-graph-surface)}.cv-side .cv-linkpanel-embedded{position:static;width:auto;border:0;border-top:1px solid var(--cia-graph-divider);background:none}}html[data-mode=browser],html[data-mode=browser] body{height:100%}html[data-mode=browser] body{background:var(--cv-surface)}.cv-view-link{user-select:all;-webkit-user-select:all;overflow-wrap:anywhere;font-size:.85em}
|
|
722
722
|
</style>
|
|
723
723
|
</head>
|
|
724
724
|
<body>
|